creator.d.ts 695 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982
  1. /** !#en
  2. The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
  3. !#zh
  4. Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */
  5. declare module cc {
  6. /** The element contains the game canvas */
  7. export var container: HTMLDivElement;
  8. /**
  9. !#en Init Debug setting.
  10. !#zh 设置调试模式。
  11. @param mode mode
  12. */
  13. export function _initDebugSetting(mode: DebugMode): void;
  14. /**
  15. !#en
  16. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  17. - In Cocos Creator, error is red.<br/>
  18. - In Chrome, error have a red icon along with red message text.<br/>
  19. !#zh
  20. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  21. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  22. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  23. @param msg A JavaScript string containing zero or more substitution strings.
  24. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  25. */
  26. export function error(msg: any, ...subst: any[]): void;
  27. /**
  28. !#en
  29. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  30. - In Cocos Creator, warning is yellow.
  31. - In Chrome, warning have a yellow warning icon with the message text.
  32. !#zh
  33. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  34. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  35. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  36. @param msg A JavaScript string containing zero or more substitution strings.
  37. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  38. */
  39. export function warn(msg: any, ...subst: any[]): void;
  40. /**
  41. !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  42. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  43. @param msg A JavaScript string containing zero or more substitution strings.
  44. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  45. */
  46. export function log(msg: string|any, ...subst: any[]): void;
  47. /**
  48. !#en
  49. Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
  50. - In Cocos Creator, info is blue.
  51. - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
  52. !#zh
  53. 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  54. - 在 Cocos Creator 中,Info 信息显示是蓝色的。<br/>
  55. - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。
  56. @param msg A JavaScript string containing zero or more substitution strings.
  57. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  58. */
  59. export function info(msg: any, ...subst: any[]): void;
  60. /** The current version of Cocos2d being used.<br/>
  61. Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
  62. If you post a bug to forum, please attach this flag. */
  63. export var ENGINE_VERSION: string;
  64. /**
  65. !#en
  66. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  67. or less (speed < 1) time. <br/>
  68. Useful to simulate 'slow motion' or 'fast forward' effect.
  69. !#zh 修改目标动作的速率。
  70. @param action action
  71. @param speed speed
  72. @example
  73. ```js
  74. // change the target action speed;
  75. var action = cc.scaleTo(0.2, 1, 0.6);
  76. var newAction = cc.speed(action, 0.5);
  77. ```
  78. */
  79. export function speed(action: ActionInterval, speed: number): Action;
  80. /**
  81. !#en Create a follow action which makes its target follows another node.
  82. !#zh 追踪目标节点的位置。
  83. @param followedNode followedNode
  84. @param rect rect
  85. @example
  86. ```js
  87. // example
  88. // creates the action with a set boundary
  89. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  90. node.runAction(followAction);
  91. // creates the action with no boundary set
  92. var followAction = cc.follow(targetNode);
  93. node.runAction(followAction);
  94. ```
  95. */
  96. export function follow(followedNode: Node, rect: Rect): Action;
  97. /**
  98. Points setter
  99. @param points points
  100. */
  101. export function setPoints(points: any[]): void;
  102. /**
  103. !#en Creates an action with a Cardinal Spline array of points and tension.
  104. !#zh 按基数样条曲线轨迹移动到目标位置。
  105. @param duration duration
  106. @param points array of control points
  107. @param tension tension
  108. @example
  109. ```js
  110. //create a cc.CardinalSplineTo
  111. var action1 = cc.cardinalSplineTo(3, array, 0);
  112. ```
  113. */
  114. export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
  115. /**
  116. update position of target
  117. @param newPos newPos
  118. */
  119. export function updatePosition(newPos: Vec2): void;
  120. /**
  121. !#en Creates an action with a Cardinal Spline array of points and tension.
  122. !#zh 按基数样条曲线轨迹移动指定的距离。
  123. @param duration duration
  124. @param points points
  125. @param tension tension
  126. */
  127. export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
  128. /**
  129. !#en Creates an action with a Cardinal Spline array of points and tension.
  130. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  131. @param dt dt
  132. @param points points
  133. @example
  134. ```js
  135. var action1 = cc.catmullRomTo(3, array);
  136. ```
  137. */
  138. export function catmullRomTo(dt: number, points: any[]): ActionInterval;
  139. /**
  140. !#en Creates an action with a Cardinal Spline array of points and tension.
  141. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  142. @param dt dt
  143. @param points points
  144. @example
  145. ```js
  146. var action1 = cc.catmullRomBy(3, array);
  147. ```
  148. */
  149. export function catmullRomBy(dt: number, points: any[]): ActionInterval;
  150. /**
  151. !#en
  152. Creates the action easing object with the rate parameter. <br />
  153. From slow to fast.
  154. !#zh 创建 easeIn 缓动对象,由慢到快。
  155. @param rate rate
  156. @example
  157. ```js
  158. action.easing(cc.easeIn(3.0));
  159. ```
  160. */
  161. export function easeIn(rate: number): any;
  162. /**
  163. !#en
  164. Creates the action easing object with the rate parameter. <br />
  165. From fast to slow.
  166. !#zh 创建 easeOut 缓动对象,由快到慢。
  167. @param rate rate
  168. @example
  169. ```js
  170. action.easing(cc.easeOut(3.0));
  171. ```
  172. */
  173. export function easeOut(rate: number): any;
  174. /**
  175. !#en
  176. Creates the action easing object with the rate parameter. <br />
  177. Slow to fast then to slow.
  178. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  179. @param rate rate
  180. @example
  181. ```js
  182. action.easing(cc.easeInOut(3.0));
  183. ```
  184. */
  185. export function easeInOut(rate: number): any;
  186. /**
  187. !#en
  188. Creates the action easing object with the rate parameter. <br />
  189. Reference easeInExpo: <br />
  190. http://www.zhihu.com/question/21981571/answer/19925418
  191. !#zh
  192. 创建 easeExponentialIn 缓动对象。<br />
  193. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  194. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  195. @example
  196. ```js
  197. action.easing(cc.easeExponentialIn());
  198. ```
  199. */
  200. export function easeExponentialIn(): any;
  201. /**
  202. !#en
  203. Creates the action easing object. <br />
  204. Reference easeOutExpo: <br />
  205. http://www.zhihu.com/question/21981571/answer/19925418
  206. !#zh
  207. 创建 easeExponentialOut 缓动对象。<br />
  208. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  209. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  210. @example
  211. ```js
  212. action.easing(cc.easeExponentialOut());
  213. ```
  214. */
  215. export function easeExponentialOut(): any;
  216. /**
  217. !#en
  218. Creates an EaseExponentialInOut action easing object. <br />
  219. Reference easeInOutExpo: <br />
  220. http://www.zhihu.com/question/21981571/answer/19925418
  221. !#zh
  222. 创建 easeExponentialInOut 缓动对象。<br />
  223. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  224. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  225. @example
  226. ```js
  227. action.easing(cc.easeExponentialInOut());
  228. ```
  229. */
  230. export function easeExponentialInOut(): any;
  231. /**
  232. !#en
  233. Creates an EaseSineIn action. <br />
  234. Reference easeInSine: <br />
  235. http://www.zhihu.com/question/21981571/answer/19925418
  236. !#zh
  237. 创建 EaseSineIn 缓动对象。<br />
  238. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  239. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  240. @example
  241. ```js
  242. action.easing(cc.easeSineIn());
  243. ```
  244. */
  245. export function easeSineIn(): any;
  246. /**
  247. !#en
  248. Creates an EaseSineOut action easing object. <br />
  249. Reference easeOutSine: <br />
  250. http://www.zhihu.com/question/21981571/answer/19925418
  251. !#zh
  252. 创建 EaseSineOut 缓动对象。<br />
  253. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  254. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  255. @example
  256. ```js
  257. action.easing(cc.easeSineOut());
  258. ```
  259. */
  260. export function easeSineOut(): any;
  261. /**
  262. !#en
  263. Creates the action easing object. <br />
  264. Reference easeInOutSine: <br />
  265. http://www.zhihu.com/question/21981571/answer/19925418
  266. !#zh
  267. 创建 easeSineInOut 缓动对象。<br />
  268. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  269. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  270. @example
  271. ```js
  272. action.easing(cc.easeSineInOut());
  273. ```
  274. */
  275. export function easeSineInOut(): any;
  276. /**
  277. !#en
  278. Creates the action easing object with the period in radians (default is 0.3). <br />
  279. Reference easeInElastic: <br />
  280. http://www.zhihu.com/question/21981571/answer/19925418
  281. !#zh
  282. 创建 easeElasticIn 缓动对象。<br />
  283. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  284. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  285. @param period period
  286. @example
  287. ```js
  288. // example
  289. action.easing(cc.easeElasticIn(3.0));
  290. ```
  291. */
  292. export function easeElasticIn(period: number): any;
  293. /**
  294. !#en
  295. Creates the action easing object with the period in radians (default is 0.3). <br />
  296. Reference easeOutElastic: <br />
  297. http://www.zhihu.com/question/21981571/answer/19925418
  298. !#zh
  299. 创建 easeElasticOut 缓动对象。<br />
  300. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  301. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  302. @param period period
  303. @example
  304. ```js
  305. // example
  306. action.easing(cc.easeElasticOut(3.0));
  307. ```
  308. */
  309. export function easeElasticOut(period: number): any;
  310. /**
  311. !#en
  312. Creates the action easing object with the period in radians (default is 0.3). <br />
  313. Reference easeInOutElastic: <br />
  314. http://www.zhihu.com/question/21981571/answer/19925418
  315. !#zh
  316. 创建 easeElasticInOut 缓动对象。<br />
  317. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  318. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  319. @param period period
  320. @example
  321. ```js
  322. // example
  323. action.easing(cc.easeElasticInOut(3.0));
  324. ```
  325. */
  326. export function easeElasticInOut(period: number): any;
  327. /**
  328. !#en
  329. Creates the action easing object. <br />
  330. Eased bounce effect at the beginning.
  331. !#zh
  332. 创建 easeBounceIn 缓动对象。<br />
  333. EaseBounceIn 是按弹跳动作缓动进入的动作。
  334. @example
  335. ```js
  336. // example
  337. action.easing(cc.easeBounceIn());
  338. ```
  339. */
  340. export function easeBounceIn(): any;
  341. /**
  342. !#en
  343. Creates the action easing object. <br />
  344. Eased bounce effect at the ending.
  345. !#zh
  346. 创建 easeBounceOut 缓动对象。<br />
  347. EaseBounceOut 是按弹跳动作缓动退出的动作。
  348. @example
  349. ```js
  350. // example
  351. action.easing(cc.easeBounceOut());
  352. ```
  353. */
  354. export function easeBounceOut(): any;
  355. /**
  356. !#en
  357. Creates the action easing object. <br />
  358. Eased bounce effect at the begining and ending.
  359. !#zh
  360. 创建 easeBounceInOut 缓动对象。<br />
  361. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  362. @example
  363. ```js
  364. // example
  365. action.easing(cc.easeBounceInOut());
  366. ```
  367. */
  368. export function easeBounceInOut(): any;
  369. /**
  370. !#en
  371. Creates the action easing object. <br />
  372. In the opposite direction to move slowly, and then accelerated to the right direction.
  373. !#zh
  374. 创建 easeBackIn 缓动对象。<br />
  375. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  376. @example
  377. ```js
  378. // example
  379. action.easing(cc.easeBackIn());
  380. ```
  381. */
  382. export function easeBackIn(): any;
  383. /**
  384. !#en
  385. Creates the action easing object. <br />
  386. Fast moving more than the finish, and then slowly back to the finish.
  387. !#zh
  388. 创建 easeBackOut 缓动对象。<br />
  389. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  390. @example
  391. ```js
  392. // example
  393. action.easing(cc.easeBackOut());
  394. ```
  395. */
  396. export function easeBackOut(): any;
  397. /**
  398. !#en
  399. Creates the action easing object. <br />
  400. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  401. !#zh
  402. 创建 easeBackInOut 缓动对象。<br />
  403. @example
  404. ```js
  405. // example
  406. action.easing(cc.easeBackInOut());
  407. ```
  408. */
  409. export function easeBackInOut(): any;
  410. /**
  411. !#en
  412. Creates the action easing object. <br />
  413. Into the 4 reference point. <br />
  414. To calculate the motion curve.
  415. !#zh
  416. 创建 easeBezierAction 缓动对象。<br />
  417. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  418. @param p0 The first bezier parameter
  419. @param p1 The second bezier parameter
  420. @param p2 The third bezier parameter
  421. @param p3 The fourth bezier parameter
  422. @example
  423. ```js
  424. // example
  425. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  426. ```
  427. */
  428. export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
  429. /**
  430. !#en
  431. Creates the action easing object. <br />
  432. Reference easeInQuad: <br />
  433. http://www.zhihu.com/question/21981571/answer/19925418
  434. !#zh
  435. 创建 easeQuadraticActionIn 缓动对象。<br />
  436. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  437. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  438. @example
  439. ```js
  440. //example
  441. action.easing(cc.easeQuadraticActionIn());
  442. ```
  443. */
  444. export function easeQuadraticActionIn(): any;
  445. /**
  446. !#en
  447. Creates the action easing object. <br />
  448. Reference easeOutQuad: <br />
  449. http://www.zhihu.com/question/21981571/answer/19925418
  450. !#zh
  451. 创建 easeQuadraticActionOut 缓动对象。<br />
  452. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  453. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  454. @example
  455. ```js
  456. //example
  457. action.easing(cc.easeQuadraticActionOut());
  458. ```
  459. */
  460. export function easeQuadraticActionOut(): any;
  461. /**
  462. !#en
  463. Creates the action easing object. <br />
  464. Reference easeInOutQuad: <br />
  465. http://www.zhihu.com/question/21981571/answer/19925418
  466. !#zh
  467. 创建 easeQuadraticActionInOut 缓动对象。<br />
  468. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  469. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  470. @example
  471. ```js
  472. //example
  473. action.easing(cc.easeQuadraticActionInOut());
  474. ```
  475. */
  476. export function easeQuadraticActionInOut(): any;
  477. /**
  478. !#en
  479. Creates the action easing object. <br />
  480. Reference easeIntQuart: <br />
  481. http://www.zhihu.com/question/21981571/answer/19925418
  482. !#zh
  483. 创建 easeQuarticActionIn 缓动对象。<br />
  484. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  485. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  486. @example
  487. ```js
  488. //example
  489. action.easing(cc.easeQuarticActionIn());
  490. ```
  491. */
  492. export function easeQuarticActionIn(): any;
  493. /**
  494. !#en
  495. Creates the action easing object. <br />
  496. Reference easeOutQuart: <br />
  497. http://www.zhihu.com/question/21981571/answer/19925418
  498. !#zh
  499. 创建 easeQuarticActionOut 缓动对象。<br />
  500. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  501. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  502. @example
  503. ```js
  504. //example
  505. action.easing(cc.QuarticActionOut());
  506. ```
  507. */
  508. export function easeQuarticActionOut(): any;
  509. /**
  510. !#en
  511. Creates the action easing object. <br />
  512. Reference easeInOutQuart: <br />
  513. http://www.zhihu.com/question/21981571/answer/19925418
  514. !#zh
  515. 创建 easeQuarticActionInOut 缓动对象。<br />
  516. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  517. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  518. */
  519. export function easeQuarticActionInOut(): any;
  520. /**
  521. !#en
  522. Creates the action easing object. <br />
  523. Reference easeInQuint: <br />
  524. http://www.zhihu.com/question/21981571/answer/19925418
  525. !#zh
  526. 创建 easeQuinticActionIn 缓动对象。<br />
  527. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  528. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  529. @example
  530. ```js
  531. //example
  532. action.easing(cc.easeQuinticActionIn());
  533. ```
  534. */
  535. export function easeQuinticActionIn(): any;
  536. /**
  537. !#en
  538. Creates the action easing object. <br />
  539. Reference easeOutQuint: <br />
  540. http://www.zhihu.com/question/21981571/answer/19925418
  541. !#zh
  542. 创建 easeQuinticActionOut 缓动对象。<br />
  543. EaseQuinticOut 是按五次函数缓动退出的动作
  544. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  545. @example
  546. ```js
  547. //example
  548. action.easing(cc.easeQuadraticActionOut());
  549. ```
  550. */
  551. export function easeQuinticActionOut(): any;
  552. /**
  553. !#en
  554. Creates the action easing object. <br />
  555. Reference easeInOutQuint: <br />
  556. http://www.zhihu.com/question/21981571/answer/19925418
  557. !#zh
  558. 创建 easeQuinticActionInOut 缓动对象。<br />
  559. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  560. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  561. @example
  562. ```js
  563. //example
  564. action.easing(cc.easeQuinticActionInOut());
  565. ```
  566. */
  567. export function easeQuinticActionInOut(): any;
  568. /**
  569. !#en
  570. Creates the action easing object. <br />
  571. Reference easeInCirc: <br />
  572. http://www.zhihu.com/question/21981571/answer/19925418
  573. !#zh
  574. 创建 easeCircleActionIn 缓动对象。<br />
  575. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  576. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  577. @example
  578. ```js
  579. //example
  580. action.easing(cc.easeCircleActionIn());
  581. ```
  582. */
  583. export function easeCircleActionIn(): any;
  584. /**
  585. !#en
  586. Creates the action easing object. <br />
  587. Reference easeOutCirc: <br />
  588. http://www.zhihu.com/question/21981571/answer/19925418
  589. !#zh
  590. 创建 easeCircleActionOut 缓动对象。<br />
  591. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  592. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  593. @example
  594. ```js
  595. //example
  596. actioneasing(cc.easeCircleActionOut());
  597. ```
  598. */
  599. export function easeCircleActionOut(): any;
  600. /**
  601. !#en
  602. Creates the action easing object. <br />
  603. Reference easeInOutCirc: <br />
  604. http://www.zhihu.com/question/21981571/answer/19925418
  605. !#zh
  606. 创建 easeCircleActionInOut 缓动对象。<br />
  607. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  608. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  609. @example
  610. ```js
  611. //example
  612. action.easing(cc.easeCircleActionInOut());
  613. ```
  614. */
  615. export function easeCircleActionInOut(): any;
  616. /**
  617. !#en
  618. Creates the action easing object. <br />
  619. Reference easeInCubic: <br />
  620. http://www.zhihu.com/question/21981571/answer/19925418
  621. !#zh
  622. 创建 easeCubicActionIn 缓动对象。<br />
  623. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  624. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  625. @example
  626. ```js
  627. //example
  628. action.easing(cc.easeCubicActionIn());
  629. ```
  630. */
  631. export function easeCubicActionIn(): any;
  632. /**
  633. !#en
  634. Creates the action easing object. <br />
  635. Reference easeOutCubic: <br />
  636. http://www.zhihu.com/question/21981571/answer/19925418
  637. !#zh
  638. 创建 easeCubicActionOut 缓动对象。<br />
  639. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  640. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  641. @example
  642. ```js
  643. //example
  644. action.easing(cc.easeCubicActionOut());
  645. ```
  646. */
  647. export function easeCubicActionOut(): any;
  648. /**
  649. !#en
  650. Creates the action easing object. <br />
  651. Reference easeInOutCubic: <br />
  652. http://www.zhihu.com/question/21981571/answer/19925418
  653. !#zh
  654. 创建 easeCubicActionInOut 缓动对象。<br />
  655. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  656. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  657. */
  658. export function easeCubicActionInOut(): any;
  659. /**
  660. !#en Show the Node.
  661. !#zh 立即显示。
  662. @example
  663. ```js
  664. // example
  665. var showAction = cc.show();
  666. ```
  667. */
  668. export function show(): ActionInstant;
  669. /**
  670. !#en Hide the node.
  671. !#zh 立即隐藏。
  672. @example
  673. ```js
  674. // example
  675. var hideAction = cc.hide();
  676. ```
  677. */
  678. export function hide(): ActionInstant;
  679. /**
  680. !#en Toggles the visibility of a node.
  681. !#zh 显隐状态切换。
  682. @example
  683. ```js
  684. // example
  685. var toggleVisibilityAction = cc.toggleVisibility();
  686. ```
  687. */
  688. export function toggleVisibility(): ActionInstant;
  689. /**
  690. !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  691. !#zh 从父节点移除自身。
  692. @param isNeedCleanUp isNeedCleanUp
  693. @example
  694. ```js
  695. // example
  696. var removeSelfAction = cc.removeSelf();
  697. ```
  698. */
  699. export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
  700. /**
  701. !#en Create a FlipX action to flip or unflip the target.
  702. !#zh X轴翻转。
  703. @param flip Indicate whether the target should be flipped or not
  704. @example
  705. ```js
  706. var flipXAction = cc.flipX(true);
  707. ```
  708. */
  709. export function flipX(flip: boolean): ActionInstant;
  710. /**
  711. !#en Create a FlipY action to flip or unflip the target.
  712. !#zh Y轴翻转。
  713. @param flip flip
  714. @example
  715. ```js
  716. var flipYAction = cc.flipY(true);
  717. ```
  718. */
  719. export function flipY(flip: boolean): ActionInstant;
  720. /**
  721. !#en Creates a Place action with a position.
  722. !#zh 放置在目标位置。
  723. @param pos pos
  724. @param y y
  725. @example
  726. ```js
  727. // example
  728. var placeAction = cc.place(cc.p(200, 200));
  729. var placeAction = cc.place(200, 200);
  730. ```
  731. */
  732. export function place(pos: Vec2|number, y?: number): ActionInstant;
  733. /**
  734. !#en Creates the action with the callback.
  735. !#zh 执行回调函数。
  736. @param selector selector
  737. @param selectorTarget selectorTarget
  738. @param data data for function, it accepts all data types.
  739. @example
  740. ```js
  741. // example
  742. // CallFunc without data
  743. var finish = cc.callFunc(this.removeSprite, this);
  744. // CallFunc with data
  745. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  746. ```
  747. */
  748. export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
  749. /**
  750. !#en
  751. Helper constructor to create an array of sequenceable actions
  752. The created action will run actions sequentially, one after another.
  753. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  754. @param actionOrActionArray actionOrActionArray
  755. @param tempArray tempArray
  756. @example
  757. ```js
  758. // example
  759. // create sequence with actions
  760. var seq = cc.sequence(act1, act2);
  761. // create sequence with array
  762. var seq = cc.sequence(actArray);
  763. ```
  764. */
  765. export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
  766. /**
  767. !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  768. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  769. @param action action
  770. @param times times
  771. @example
  772. ```js
  773. // example
  774. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  775. ```
  776. */
  777. export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
  778. /**
  779. !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
  780. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
  781. @param action action
  782. @example
  783. ```js
  784. // example
  785. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  786. ```
  787. */
  788. export function repeatForever(action: FiniteTimeAction): ActionInterval;
  789. /**
  790. !#en Create a spawn action which runs several actions in parallel.
  791. !#zh 同步执行动作,同步执行一组动作。
  792. @param actionOrActionArray actionOrActionArray
  793. @param tempArray tempArray
  794. @example
  795. ```js
  796. // example
  797. var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
  798. todo:It should be the direct use new
  799. ```
  800. */
  801. export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
  802. /**
  803. !#en
  804. Rotates a Node object to a certain angle by modifying its rotation property. <br/>
  805. The direction will be decided by the shortest angle.
  806. !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
  807. @param duration duration in seconds
  808. @param deltaAngleX deltaAngleX in degrees.
  809. @param deltaAngleY deltaAngleY in degrees.
  810. @example
  811. ```js
  812. // example
  813. var rotateTo = cc.rotateTo(2, 61.0);
  814. ```
  815. */
  816. export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  817. /**
  818. !#en
  819. Rotates a Node object clockwise a number of degrees by modifying its rotation property.
  820. Relative to its properties to modify.
  821. !#zh 旋转指定的角度。
  822. @param duration duration in seconds
  823. @param deltaAngleX deltaAngleX in degrees
  824. @param deltaAngleY deltaAngleY in degrees
  825. @example
  826. ```js
  827. // example
  828. var actionBy = cc.rotateBy(2, 360);
  829. ```
  830. */
  831. export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  832. /**
  833. !#en
  834. Moves a Node object x,y pixels by modifying its position property. <br/>
  835. x and y are relative to the position of the object. <br/>
  836. Several MoveBy actions can be concurrently called, and the resulting <br/>
  837. movement will be the sum of individual movements.
  838. !#zh 移动指定的距离。
  839. @param duration duration in seconds
  840. @param deltaPos deltaPos
  841. @param deltaY deltaY
  842. @example
  843. ```js
  844. // example
  845. var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
  846. ```
  847. */
  848. export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
  849. /**
  850. !#en
  851. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  852. Several MoveTo actions can be concurrently called, and the resulting <br/>
  853. movement will be the sum of individual movements.
  854. !#zh 移动到目标位置。
  855. @param duration duration in seconds
  856. @param position position
  857. @param y y
  858. @example
  859. ```js
  860. // example
  861. var actionBy = cc.moveTo(2, cc.p(80, 80));
  862. ```
  863. */
  864. export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
  865. /**
  866. !#en
  867. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  868. Changes to the specified value.
  869. !#zh 偏斜到目标角度。
  870. @param t time in seconds
  871. @param sx sx
  872. @param sy sy
  873. @example
  874. ```js
  875. // example
  876. var actionTo = cc.skewTo(2, 37.2, -37.2);
  877. ```
  878. */
  879. export function skewTo(t: number, sx: number, sy: number): ActionInterval;
  880. /**
  881. !#en
  882. Skews a Node object by skewX and skewY degrees. <br />
  883. Relative to its property modification.
  884. !#zh 偏斜指定的角度。
  885. @param t time in seconds
  886. @param sx sx skew in degrees for X axis
  887. @param sy sy skew in degrees for Y axis
  888. @example
  889. ```js
  890. // example
  891. var actionBy = cc.skewBy(2, 0, -90);
  892. ```
  893. */
  894. export function skewBy(t: number, sx: number, sy: number): ActionInterval;
  895. /**
  896. !#en
  897. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  898. Relative to its movement.
  899. !#zh 用跳跃的方式移动指定的距离。
  900. @param duration duration
  901. @param position position
  902. @param y y
  903. @param height height
  904. @param jumps jumps
  905. @example
  906. ```js
  907. // example
  908. var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
  909. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  910. ```
  911. */
  912. export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  913. /**
  914. !#en
  915. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  916. Jump to the specified location.
  917. !#zh 用跳跃的方式移动到目标位置。
  918. @param duration duration
  919. @param position position
  920. @param y y
  921. @param height height
  922. @param jumps jumps
  923. @example
  924. ```js
  925. // example
  926. var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
  927. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  928. ```
  929. */
  930. export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  931. /**
  932. !#en
  933. An action that moves the target with a cubic Bezier curve by a certain distance.
  934. Relative to its movement.
  935. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  936. @param t time in seconds
  937. @param c Array of points
  938. @example
  939. ```js
  940. // example
  941. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  942. var bezierForward = cc.bezierBy(3, bezier);
  943. ```
  944. */
  945. export function bezierBy(t: number, c: Vec2[]): ActionInterval;
  946. /**
  947. !#en An action that moves the target with a cubic Bezier curve to a destination point.
  948. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  949. @param t t
  950. @param c Array of points
  951. @example
  952. ```js
  953. // example
  954. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  955. var bezierTo = cc.bezierTo(2, bezier);
  956. ```
  957. */
  958. export function bezierTo(t: number, c: Vec2[]): ActionInterval;
  959. /**
  960. !#en Scales a Node object to a zoom factor by modifying it's scale property.
  961. !#zh 将节点大小缩放到指定的倍数。
  962. @param duration duration
  963. @param sx scale parameter in X
  964. @param sy scale parameter in Y, if Null equal to sx
  965. @example
  966. ```js
  967. // example
  968. // It scales to 0.5 in both X and Y.
  969. var actionTo = cc.scaleTo(2, 0.5);
  970. // It scales to 0.5 in x and 2 in Y
  971. var actionTo = cc.scaleTo(2, 0.5, 2);
  972. ```
  973. */
  974. export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
  975. /**
  976. !#en
  977. Scales a Node object a zoom factor by modifying it's scale property.
  978. Relative to its changes.
  979. !#zh 按指定的倍数缩放节点大小。
  980. @param duration duration in seconds
  981. @param sx sx scale parameter in X
  982. @param sy sy scale parameter in Y, if Null equal to sx
  983. @example
  984. ```js
  985. // example without sy, it scales by 2 both in X and Y
  986. var actionBy = cc.scaleBy(2, 2);
  987. //example with sy, it scales by 0.25 in X and 4.5 in Y
  988. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  989. ```
  990. */
  991. export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
  992. /**
  993. !#en Blinks a Node object by modifying it's visible property.
  994. !#zh 闪烁(基于透明度)。
  995. @param duration duration in seconds
  996. @param blinks blinks in times
  997. @example
  998. ```js
  999. // example
  1000. var action = cc.blink(2, 10);
  1001. ```
  1002. */
  1003. export function blink(duration: number, blinks: number): ActionInterval;
  1004. /**
  1005. !#en
  1006. Fades an object that implements the cc.RGBAProtocol protocol.
  1007. It modifies the opacity from the current value to a custom one.
  1008. !#zh 修改透明度到指定值。
  1009. @param duration duration
  1010. @param opacity 0-255, 0 is transparent
  1011. @example
  1012. ```js
  1013. // example
  1014. var action = cc.fadeTo(1.0, 0);
  1015. ```
  1016. */
  1017. export function fadeTo(duration: number, opacity: number): ActionInterval;
  1018. /**
  1019. !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  1020. !#zh 渐显效果。
  1021. @param duration duration in seconds
  1022. @example
  1023. ```js
  1024. //example
  1025. var action = cc.fadeIn(1.0);
  1026. ```
  1027. */
  1028. export function fadeIn(duration: number): ActionInterval;
  1029. /**
  1030. !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  1031. !#zh 渐隐效果。
  1032. @param d duration in seconds
  1033. @example
  1034. ```js
  1035. // example
  1036. var action = cc.fadeOut(1.0);
  1037. ```
  1038. */
  1039. export function fadeOut(d: number): ActionInterval;
  1040. /**
  1041. !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1042. !#zh 修改颜色到指定值。
  1043. @param duration duration
  1044. @param red 0-255
  1045. @param green 0-255
  1046. @param blue 0-255
  1047. @example
  1048. ```js
  1049. // example
  1050. var action = cc.tintTo(2, 255, 0, 255);
  1051. ```
  1052. */
  1053. export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
  1054. /**
  1055. !#en
  1056. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1057. Relative to their own color change.
  1058. !#zh 按照指定的增量修改颜色。
  1059. @param duration duration in seconds
  1060. @param deltaRed deltaRed
  1061. @param deltaGreen deltaGreen
  1062. @param deltaBlue deltaBlue
  1063. @example
  1064. ```js
  1065. // example
  1066. var action = cc.tintBy(2, -127, -255, -127);
  1067. ```
  1068. */
  1069. export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
  1070. /**
  1071. !#en Delays the action a certain amount of seconds.
  1072. !#en 延迟指定的时间量。
  1073. @param d duration in seconds
  1074. @example
  1075. ```js
  1076. // example
  1077. var delay = cc.delayTime(1);
  1078. ```
  1079. */
  1080. export function delayTime(d: number): ActionInterval;
  1081. /**
  1082. !#en Executes an action in reverse order, from time=duration to time=0.
  1083. !#zh 反转目标动作的时间轴。
  1084. @param action action
  1085. @example
  1086. ```js
  1087. // example
  1088. var reverse = cc.reverseTime(this);
  1089. ```
  1090. */
  1091. export function reverseTime(action: FiniteTimeAction): ActionInterval;
  1092. /**
  1093. !#en Create an action with the specified action and forced target.
  1094. !#zh 用已有动作和一个新的目标节点创建动作。
  1095. @param target target
  1096. @param action action
  1097. */
  1098. export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
  1099. /** !#en cc.view is the shared view object.
  1100. !#zh cc.view 是全局的视图对象。 */
  1101. export var view: View;
  1102. /** !#en Director
  1103. !#zh 导演类。 */
  1104. export var director: Director;
  1105. /** !#en cc.winSize is the alias object for the size of the current game window.
  1106. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  1107. export var winSize: Size;
  1108. export var game: Game;
  1109. /** !#en The System event singleton for global usage
  1110. !#zh 系统事件单例,方便全局使用 */
  1111. export var systemEvent: SystemEvent;
  1112. /**
  1113. @param touches touches
  1114. */
  1115. export function handleTouchesBegin(touches: any[]): void;
  1116. /**
  1117. @param touches touches
  1118. */
  1119. export function handleTouchesMove(touches: any[]): void;
  1120. /**
  1121. @param touches touches
  1122. */
  1123. export function handleTouchesEnd(touches: any[]): void;
  1124. /**
  1125. @param touches touches
  1126. */
  1127. export function handleTouchesCancel(touches: any[]): void;
  1128. /**
  1129. @param touches touches
  1130. */
  1131. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1132. /**
  1133. @param element element
  1134. */
  1135. export function getHTMLElementPosition(element: HTMLElement): any;
  1136. /**
  1137. @param touch touch
  1138. */
  1139. export function getPreTouch(touch: Touch): Touch;
  1140. /**
  1141. @param touch touch
  1142. */
  1143. export function setPreTouch(touch: Touch): void;
  1144. /**
  1145. @param tx tx
  1146. @param ty ty
  1147. @param pos pos
  1148. */
  1149. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1150. /**
  1151. @param event event
  1152. @param pos pos
  1153. */
  1154. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1155. /**
  1156. @param event event
  1157. @param pos pos
  1158. */
  1159. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1160. /**
  1161. @param element element
  1162. */
  1163. export function registerSystemEvent(element: HTMLElement): void;
  1164. /**
  1165. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1166. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1167. @param options options
  1168. @example
  1169. ```js
  1170. // define base class
  1171. var Node = cc.Class();
  1172. // define sub class
  1173. var Sprite = cc.Class({
  1174. name: 'Sprite',
  1175. extends: Node,
  1176. ctor: function () {
  1177. this.url = "";
  1178. this.id = 0;
  1179. },
  1180. statics: {
  1181. // define static members
  1182. count: 0,
  1183. getBounds: function (spriteList) {
  1184. // compute bounds...
  1185. }
  1186. },
  1187. properties {
  1188. width: {
  1189. default: 128,
  1190. type: 'Integer',
  1191. tooltip: 'The width of sprite'
  1192. },
  1193. height: 128,
  1194. size: {
  1195. get: function () {
  1196. return cc.v2(this.width, this.height);
  1197. }
  1198. }
  1199. },
  1200. load: function () {
  1201. // load this.url...
  1202. };
  1203. });
  1204. // instantiate
  1205. var obj = new Sprite();
  1206. obj.url = 'sprite.png';
  1207. obj.load();
  1208. ```
  1209. */
  1210. 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;
  1211. /**
  1212. Checks whether subclass is child of superclass or equals to superclass
  1213. @param subclass subclass
  1214. @param superclass superclass
  1215. */
  1216. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  1217. /**
  1218. !#en
  1219. Define an enum type. <br/>
  1220. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.<br/>
  1221. Otherwise it will use the value specified by user who writes the enum definition.
  1222. !#zh
  1223. 定义一个枚举类型。<br/>
  1224. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1225. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1226. @example
  1227. ```js
  1228. // JavaScript:
  1229. var WrapMode = cc.Enum({
  1230. Repeat: -1,
  1231. Clamp: -1
  1232. });
  1233. // Texture.WrapMode.Repeat == 0
  1234. // Texture.WrapMode.Clamp == 1
  1235. // Texture.WrapMode[0] == "Repeat"
  1236. // Texture.WrapMode[1] == "Clamp"
  1237. var FlagType = cc.Enum({
  1238. Flag1: 1,
  1239. Flag2: 2,
  1240. Flag3: 4,
  1241. Flag4: 8,
  1242. });
  1243. var AtlasSizeList = cc.Enum({
  1244. 128: 128,
  1245. 256: 256,
  1246. 512: 512,
  1247. 1024: 1024,
  1248. });
  1249. // TypeScript:
  1250. // If used in TypeScript, just define a TypeScript enum:
  1251. enum Direction {
  1252. Up,
  1253. Down,
  1254. Left,
  1255. Right
  1256. }
  1257. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1258. const {ccclass, property} = cc._decorator;
  1259. @ccclass
  1260. class NewScript extends cc.Component {
  1261. @property({
  1262. type: cc.Enum(Direction) // call cc.Enum
  1263. })
  1264. direction: Direction = Direction.Up;
  1265. }
  1266. ```
  1267. */
  1268. export function Enum<T>(obj: T): T;
  1269. /**
  1270. whether enable accelerometer event
  1271. @param isEnable isEnable
  1272. */
  1273. export function setAccelerometerEnabled(isEnable: boolean): void;
  1274. /**
  1275. set accelerometer interval value
  1276. @param interval interval
  1277. */
  1278. export function setAccelerometerInterval(interval: number): void;
  1279. /**
  1280. @param touches touches
  1281. */
  1282. export function handleTouchesBegin(touches: any[]): void;
  1283. /**
  1284. @param touches touches
  1285. */
  1286. export function handleTouchesMove(touches: any[]): void;
  1287. /**
  1288. @param touches touches
  1289. */
  1290. export function handleTouchesEnd(touches: any[]): void;
  1291. /**
  1292. @param touches touches
  1293. */
  1294. export function handleTouchesCancel(touches: any[]): void;
  1295. /**
  1296. @param touches touches
  1297. */
  1298. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1299. /**
  1300. @param element element
  1301. */
  1302. export function getHTMLElementPosition(element: HTMLElement): any;
  1303. /**
  1304. @param touch touch
  1305. */
  1306. export function getPreTouch(touch: Touch): Touch;
  1307. /**
  1308. @param touch touch
  1309. */
  1310. export function setPreTouch(touch: Touch): void;
  1311. /**
  1312. @param tx tx
  1313. @param ty ty
  1314. @param pos pos
  1315. */
  1316. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1317. /**
  1318. @param location location
  1319. @param pos pos
  1320. @param eventType eventType
  1321. */
  1322. export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1323. /**
  1324. @param event event
  1325. @param pos pos
  1326. */
  1327. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1328. /**
  1329. @param event event
  1330. @param pos pos
  1331. */
  1332. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1333. /**
  1334. @param element element
  1335. */
  1336. export function registerSystemEvent(element: HTMLElement): void;
  1337. /**
  1338. @param dt dt
  1339. */
  1340. export function update(dt: number): void;
  1341. /**
  1342. <p>
  1343. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  1344. </p>
  1345. @param a number A
  1346. @param b number B
  1347. @param r ratio between 0 and 1
  1348. @example
  1349. ```js
  1350. ----
  1351. lerp
  1352. cc.lerp(2,10,0.5)//returns 6
  1353. cc.lerp(2,10,0.2)//returns 3.6
  1354. ```
  1355. */
  1356. export function lerp(a: number, b: number, r: number): number;
  1357. /**
  1358. get a random number from 0 to 0xffffff
  1359. */
  1360. export function rand(): number;
  1361. /**
  1362. returns a random float between -1 and 1
  1363. */
  1364. export function randomMinus1To1(): number;
  1365. /**
  1366. returns a random float between 0 and 1, use Math.random directly
  1367. */
  1368. export function random0To1(): number;
  1369. /**
  1370. converts degrees to radians
  1371. @param angle angle
  1372. */
  1373. export function degreesToRadians(angle: number): number;
  1374. /**
  1375. converts radians to degrees
  1376. @param angle angle
  1377. */
  1378. export function radiansToDegrees(angle: number): number;
  1379. /**
  1380. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
  1381. @param node setup node
  1382. */
  1383. export function nodeDrawSetup(node: Node): void;
  1384. /**
  1385. <p>
  1386. Increments the GL Draws counts by one.<br/>
  1387. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.<br/>
  1388. </p>
  1389. @param addNumber addNumber
  1390. */
  1391. export function incrementGLDraws(addNumber: number): void;
  1392. /**
  1393. Check webgl error.Error will be shown in console if exists.
  1394. */
  1395. export function checkGLErrorDebug(): void;
  1396. /**
  1397. !#en
  1398. Checks whether the object is non-nil and not yet destroyed.<br>
  1399. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  1400. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  1401. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  1402. but this is often caused by a particular logical requirements, which is not normally required.
  1403. !#zh
  1404. 检查该对象是否不为 null 并且尚未销毁。<br>
  1405. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
  1406. @param value value
  1407. @param strictMode If true, Object called destroy() in this frame will also treated as invalid.
  1408. @example
  1409. ```js
  1410. var node = new cc.Node();
  1411. cc.log(cc.isValid(node)); // true
  1412. node.destroy();
  1413. cc.log(cc.isValid(node)); // true, still valid in this frame
  1414. // after a frame...
  1415. cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
  1416. ```
  1417. */
  1418. export function isValid(value: any, strictMode?: boolean): boolean;
  1419. /** Specify that the input value must be integer in Inspector.
  1420. Also used to indicates that the elements in array should be type integer. */
  1421. export var Integer: string;
  1422. /** Indicates that the elements in array should be type double. */
  1423. export var Float: string;
  1424. /** Indicates that the elements in array should be type boolean. */
  1425. export var Boolean: string;
  1426. /** Indicates that the elements in array should be type string. */
  1427. export var String: string;
  1428. /**
  1429. !#en Deserialize json to cc.Asset
  1430. !#zh 将 JSON 反序列化为对象实例。
  1431. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1432. 也不会将 uuid 保存到 result 对象中。
  1433. @param data the serialized cc.Asset json string or json object.
  1434. @param details additional loading result
  1435. @param options options
  1436. */
  1437. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1438. /**
  1439. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1440. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1441. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1442. @param original An existing object that you want to make a copy of.
  1443. @example
  1444. ```js
  1445. // instantiate node from prefab
  1446. var scene = cc.director.getScene();
  1447. var node = cc.instantiate(prefabAsset);
  1448. node.parent = scene;
  1449. // clone node
  1450. var scene = cc.director.getScene();
  1451. var node = cc.instantiate(targetNode);
  1452. node.parent = scene;
  1453. ```
  1454. */
  1455. export function instantiate(original: Prefab): Node;
  1456. export function instantiate<T>(original: T): T;
  1457. /**
  1458. Finds a node by hierarchy path, the path is case-sensitive.
  1459. It will traverse the hierarchy by splitting the path using '/' character.
  1460. This function will still returns the node even if it is inactive.
  1461. It is recommended to not use this function every frame instead cache the result at startup.
  1462. @param path path
  1463. @param referenceNode referenceNode
  1464. */
  1465. export function find(path: string, referenceNode?: Node): Node;
  1466. /**
  1467. !#en
  1468. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1469. Alpha channel is optional. Default value is 255.
  1470. !#zh
  1471. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1472. Alpha 通道是可选的。默认值是 255。
  1473. @param r r
  1474. @param g g
  1475. @param b b
  1476. @param a a
  1477. @example
  1478. ```js
  1479. -----------------------
  1480. // 1. All channels seperately as parameters
  1481. var color1 = new cc.Color(255, 255, 255, 255);
  1482. // 2. Convert a hex string to a color
  1483. var color2 = new cc.Color("#000000");
  1484. // 3. An color object as parameter
  1485. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1486. ```
  1487. */
  1488. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1489. /**
  1490. !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1491. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1492. @param color1 color1
  1493. @param color2 color2
  1494. @example
  1495. ```js
  1496. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1497. ```
  1498. */
  1499. export function colorEqual(color1: Color, color2: Color): boolean;
  1500. /**
  1501. !#en
  1502. convert a string of color for style to Color.
  1503. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1504. !#zh 16 进制转换为 Color
  1505. @param hex hex
  1506. @example
  1507. ```js
  1508. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1509. ```
  1510. */
  1511. export function hexToColor(hex: string): Color;
  1512. /**
  1513. !#en
  1514. convert Color to a string of color for style.
  1515. e.g. cc.color(255,6,255) to : "#ff06ff"
  1516. !#zh Color 转换为 16进制。
  1517. @param color color
  1518. @example
  1519. ```js
  1520. var color = new cc.Color(255, 6, 255)
  1521. cc.colorToHex(color); // #ff06ff;
  1522. ```
  1523. */
  1524. export function colorToHex(color: Color): string;
  1525. /**
  1526. !#en Returns opposite of Vec2.
  1527. !#zh 返回相反的向量。
  1528. @param point point
  1529. @example
  1530. ```js
  1531. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1532. ```
  1533. */
  1534. export function pNeg(point: Vec2): Vec2;
  1535. /**
  1536. !#en Calculates sum of two points.
  1537. !#zh 返回两个向量的和。
  1538. @param v1 v1
  1539. @param v2 v2
  1540. @example
  1541. ```js
  1542. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1543. ```
  1544. */
  1545. export function pAdd(v1: Vec2, v2: Vec2): Vec2;
  1546. /**
  1547. !#en Calculates difference of two points.
  1548. !#zh 返回两个向量的差。
  1549. @param v1 v1
  1550. @param v2 v2
  1551. @example
  1552. ```js
  1553. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1554. ```
  1555. */
  1556. export function pSub(v1: Vec2, v2: Vec2): Vec2;
  1557. /**
  1558. !#en Returns point multiplied by given factor.
  1559. !#zh 向量缩放。
  1560. @param point point
  1561. @param floatVar floatVar
  1562. @example
  1563. ```js
  1564. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1565. ```
  1566. */
  1567. export function pMult(point: Vec2, floatVar: number): Vec2;
  1568. /**
  1569. !#en Calculates midpoint between two points.
  1570. !#zh 两个向量之间的中心点。
  1571. @param v1 v1
  1572. @param v2 v2
  1573. @example
  1574. ```js
  1575. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1576. ```
  1577. */
  1578. export function pMidpoint(v1: Vec2, v2: Vec2): Vec2;
  1579. /**
  1580. !#en Calculates dot product of two points.
  1581. !#zh 两个向量之间进行点乘。
  1582. @param v1 v1
  1583. @param v2 v2
  1584. @example
  1585. ```js
  1586. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1587. ```
  1588. */
  1589. export function pDot(v1: Vec2, v2: Vec2): number;
  1590. /**
  1591. !#en Calculates cross product of two points.
  1592. !#zh 两个向量之间进行叉乘。
  1593. @param v1 v1
  1594. @param v2 v2
  1595. @example
  1596. ```js
  1597. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1598. ```
  1599. */
  1600. export function pCross(v1: Vec2, v2: Vec2): number;
  1601. /**
  1602. !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1603. !#zh 返回逆时针旋转 90 度后的新向量。
  1604. @param point point
  1605. @example
  1606. ```js
  1607. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1608. ```
  1609. */
  1610. export function pPerp(point: Vec2): Vec2;
  1611. /**
  1612. !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1613. !#zh 将指定向量顺时针旋转 90 度并返回。
  1614. @param point point
  1615. @example
  1616. ```js
  1617. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1618. ```
  1619. */
  1620. export function pRPerp(point: Vec2): Vec2;
  1621. /**
  1622. !#en Calculates the projection of v1 over v2.
  1623. !#zh 返回 v1 在 v2 上的投影向量。
  1624. @param v1 v1
  1625. @param v2 v2
  1626. @example
  1627. ```js
  1628. var v1 = cc.v2(20, 20);
  1629. var v2 = cc.v2(5, 5);
  1630. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1631. ```
  1632. */
  1633. export function pProject(v1: Vec2, v2: Vec2): Vec2;
  1634. /**
  1635. !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1636. !#zh 返回指定向量长度的平方。
  1637. @param v v
  1638. @example
  1639. ```js
  1640. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1641. ```
  1642. */
  1643. export function pLengthSQ(v: Vec2): number;
  1644. /**
  1645. !#en Calculates the square distance between two points (not calling sqrt() ).
  1646. !#zh 返回两个点之间距离的平方。
  1647. @param point1 point1
  1648. @param point2 point2
  1649. @example
  1650. ```js
  1651. var point1 = cc.v2(20, 20);
  1652. var point2 = cc.v2(5, 5);
  1653. cc.pDistanceSQ(point1, point2); // 450;
  1654. ```
  1655. */
  1656. export function pDistanceSQ(point1: Vec2, point2: Vec2): number;
  1657. /**
  1658. !#en Calculates distance between point an origin.
  1659. !#zh 返回指定向量的长度.
  1660. @param v v
  1661. @example
  1662. ```js
  1663. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1664. ```
  1665. */
  1666. export function pLength(v: Vec2): number;
  1667. /**
  1668. !#en Calculates the distance between two points.
  1669. !#zh 返回指定 2 个向量之间的距离。
  1670. @param v1 v1
  1671. @param v2 v2
  1672. @example
  1673. ```js
  1674. var v1 = cc.v2(20, 20);
  1675. var v2 = cc.v2(5, 5);
  1676. cc.pDistance(v1, v2); // 21.213203435596427;
  1677. ```
  1678. */
  1679. export function pDistance(v1: Vec2, v2: Vec2): number;
  1680. /**
  1681. !#en Returns this vector with a magnitude of 1.
  1682. !#zh 返回一个长度为 1 的标准化过后的向量。
  1683. @param v v
  1684. @example
  1685. ```js
  1686. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1687. ```
  1688. */
  1689. export function pNormalize(v: Vec2): Vec2;
  1690. /**
  1691. !#en Converts radians to a normalized vector.
  1692. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1693. @param a a
  1694. @example
  1695. ```js
  1696. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1697. ```
  1698. */
  1699. export function pForAngle(a: number): Vec2;
  1700. /**
  1701. !#en Converts a vector to radians.
  1702. !#zh 返回指定向量的弧度。
  1703. @param v v
  1704. @example
  1705. ```js
  1706. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1707. ```
  1708. */
  1709. export function pToAngle(v: Vec2): number;
  1710. /**
  1711. !#en Clamp a value between from and to.
  1712. !#zh
  1713. 限定浮点数的最大最小值。<br/>
  1714. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1715. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1716. 否则返回自身。
  1717. @param value value
  1718. @param min_inclusive min_inclusive
  1719. @param max_inclusive max_inclusive
  1720. @example
  1721. ```js
  1722. var v1 = cc.clampf(20, 0, 20); // 20;
  1723. var v2 = cc.clampf(-1, 0, 20); // 0;
  1724. var v3 = cc.clampf(10, 0, 20); // 10;
  1725. ```
  1726. */
  1727. export function clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  1728. /**
  1729. !#en Clamp a value between 0 and 1.
  1730. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1731. @param value value
  1732. @example
  1733. ```js
  1734. var v1 = cc.clampf(20); // 1;
  1735. var v2 = cc.clampf(-1); // 0;
  1736. var v3 = cc.clampf(0.5); // 0.5;
  1737. ```
  1738. */
  1739. export function clamp01(value: number): number;
  1740. /**
  1741. !#en Clamp a point between from and to.
  1742. !#zh
  1743. 返回指定限制区域后的向量。<br/>
  1744. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1745. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1746. 否则返回自身。
  1747. @param p p
  1748. @param min_inclusive min_inclusive
  1749. @param max_inclusive max_inclusive
  1750. @example
  1751. ```js
  1752. var min_inclusive = cc.v2(0, 0);
  1753. var max_inclusive = cc.v2(20, 20);
  1754. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1755. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1756. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1757. ```
  1758. */
  1759. export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  1760. /**
  1761. !#en Quickly convert cc.Size to a cc.Vec2.
  1762. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1763. @param s s
  1764. @example
  1765. ```js
  1766. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1767. ```
  1768. */
  1769. export function pFromSize(s: Size): Vec2;
  1770. /**
  1771. !#en
  1772. Run a math operation function on each point component <br />
  1773. Math.abs, Math.fllor, Math.ceil, Math.round.
  1774. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1775. @param p p
  1776. @param opFunc opFunc
  1777. @example
  1778. ```js
  1779. cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1780. ```
  1781. */
  1782. export function pCompOp(p: Vec2, opFunc: Function): Vec2;
  1783. /**
  1784. !#en
  1785. Linear Interpolation between two points a and b.<br />
  1786. alpha == 0 ? a <br />
  1787. alpha == 1 ? b <br />
  1788. otherwise a value between a..b.
  1789. !#zh
  1790. 两个点 A 和 B 之间的线性插值。 <br />
  1791. alpha == 0 ? a <br />
  1792. alpha == 1 ? b <br />
  1793. 否则这个数值在 a ~ b 之间。
  1794. @param a a
  1795. @param b b
  1796. @param alpha alpha
  1797. @example
  1798. ```js
  1799. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1800. ```
  1801. */
  1802. export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2;
  1803. /**
  1804. !#en TODO
  1805. !#zh
  1806. 近似判断两个点是否相等。<br/>
  1807. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1808. @param a a
  1809. @param b b
  1810. @param variance variance
  1811. @example
  1812. ```js
  1813. var a = cc.v2(20, 20);
  1814. var b = cc.v2(5, 5);
  1815. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1816. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1817. ```
  1818. */
  1819. export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean;
  1820. /**
  1821. !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1822. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1823. @param a a
  1824. @param b b
  1825. @example
  1826. ```js
  1827. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1828. ```
  1829. */
  1830. export function pCompMult(a: Vec2, b: Vec2): Vec2;
  1831. /**
  1832. !#en TODO
  1833. !#zh 返回两个向量之间带正负号的弧度。
  1834. @param a a
  1835. @param b b
  1836. */
  1837. export function pAngleSigned(a: Vec2, b: Vec2): number;
  1838. /**
  1839. !#en TODO
  1840. !#zh 获取当前向量与指定向量之间的弧度角。
  1841. @param a a
  1842. @param b b
  1843. */
  1844. export function pAngle(a: Vec2, b: Vec2): number;
  1845. /**
  1846. !#en Rotates a point counter clockwise by the angle around a pivot.
  1847. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1848. @param v v is the point to rotate
  1849. @param pivot pivot is the pivot, naturally
  1850. @param angle angle is the angle of rotation cw in radians
  1851. */
  1852. export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2;
  1853. /**
  1854. !#en
  1855. A general line-line intersection test
  1856. indicating successful intersection of a line<br />
  1857. note that to truly test intersection for segments we have to make<br />
  1858. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1859. the hit point is p3 + t * (p4 - p3);<br />
  1860. the hit point also is p1 + s * (p2 - p1);
  1861. !#zh
  1862. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1863. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1864. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1865. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1866. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1867. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1868. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1869. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1870. */
  1871. export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean;
  1872. /**
  1873. !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1874. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1875. @param A A
  1876. @param B B
  1877. @param C C
  1878. @param D D
  1879. */
  1880. export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean;
  1881. /**
  1882. !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1883. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1884. @param A A
  1885. @param B B
  1886. @param C C
  1887. @param D D
  1888. */
  1889. export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2;
  1890. /**
  1891. !#en check to see if both points are equal.
  1892. !#zh 检查指定的 2 个向量是否相等。
  1893. @param A A ccp a
  1894. @param B B ccp b to be compared
  1895. */
  1896. export function pSameAs(A: Vec2, B: Vec2): boolean;
  1897. /**
  1898. !#en sets the position of the point to 0.
  1899. !#zh 设置指定向量归 0。
  1900. @param v v
  1901. */
  1902. export function pZeroIn(v: Vec2): void;
  1903. /**
  1904. !#en copies the position of one point to another.
  1905. !#zh 令 v1 向量等同于 v2。
  1906. @param v1 v1
  1907. @param v2 v2
  1908. */
  1909. export function pIn(v1: Vec2, v2: Vec2): void;
  1910. /**
  1911. !#en multiplies the point with the given factor (inplace).
  1912. !#zh 向量缩放,结果保存到第一个向量。
  1913. @param point point
  1914. @param floatVar floatVar
  1915. */
  1916. export function pMultIn(point: Vec2, floatVar: number): void;
  1917. /**
  1918. !#en subtracts one point from another (inplace).
  1919. !#zh 向量减法,结果保存到第一个向量。
  1920. @param v1 v1
  1921. @param v2 v2
  1922. */
  1923. export function pSubIn(v1: Vec2, v2: Vec2): void;
  1924. /**
  1925. !#en adds one point to another (inplace).
  1926. !#zh 向量加法,结果保存到第一个向量。
  1927. @param v1 v1
  1928. @param v2 v2
  1929. */
  1930. export function pAddIn(v1: Vec2, v2: Vec2): void;
  1931. /**
  1932. !#en normalizes the point (inplace).
  1933. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1934. @param v v
  1935. */
  1936. export function pNormalizeIn(v: Vec2): void;
  1937. /**
  1938. !#en
  1939. The convenience method to create a new Rect.
  1940. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1941. !#zh
  1942. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1943. @param x x
  1944. @param y y
  1945. @param w w
  1946. @param h h
  1947. @example
  1948. ```js
  1949. var a = new cc.Rect(0 , 0, 10, 0);
  1950. ```
  1951. */
  1952. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1953. /**
  1954. !#en Check whether a rect's value equals to another.
  1955. !#zh 判断两个矩形是否相等。
  1956. @param rect1 rect1
  1957. @param rect2 rect2
  1958. @example
  1959. ```js
  1960. var a = new cc.Rect(0, 0, 10, 10);
  1961. var b = new cc.Rect(0, 0, 5, 5);
  1962. cc.rectEqualToRect(a, b); // false;
  1963. var c = new cc.Rect(0, 0, 5, 5);
  1964. cc.rectEqualToRect(b, c); // true;
  1965. ```
  1966. */
  1967. export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean;
  1968. /**
  1969. !#en Check whether the rect1 contains rect2.
  1970. !#zh
  1971. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1972. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1973. @param rect1 rect1
  1974. @param rect2 rect2
  1975. @example
  1976. ```js
  1977. var a = new cc.Rect(0, 0, 20, 20);
  1978. var b = new cc.Rect(10, 10, 20, 20);
  1979. cc.rectContainsRect(a, b); // true;
  1980. ```
  1981. */
  1982. export function rectContainsRect(rect1: Rect, rect2: Rect): boolean;
  1983. /**
  1984. !#en Returns the rightmost x-value of a rect.
  1985. !#zh 返回矩形在 x 轴上的最大值
  1986. @param rect rect
  1987. @example
  1988. ```js
  1989. var a = new cc.Rect(10, 0, 20, 20);
  1990. cc.rectGetMaxX(a); // 30;
  1991. ```
  1992. */
  1993. export function rectGetMaxX(rect: Rect): number;
  1994. /**
  1995. !#en Return the midpoint x-value of a rect.
  1996. !#zh 返回矩形在 x 轴上的中点。
  1997. @param rect rect
  1998. @example
  1999. ```js
  2000. var a = new cc.Rect(10, 0, 20, 20);
  2001. cc.rectGetMidX(a); // 20;
  2002. ```
  2003. */
  2004. export function rectGetMidX(rect: Rect): number;
  2005. /**
  2006. !#en Returns the leftmost x-value of a rect.
  2007. !#zh 返回矩形在 x 轴上的最小值。
  2008. @param rect rect
  2009. @example
  2010. ```js
  2011. var a = new cc.Rect(10, 0, 20, 20);
  2012. cc.rectGetMinX(a); // 10;
  2013. ```
  2014. */
  2015. export function rectGetMinX(rect: Rect): number;
  2016. /**
  2017. !#en Return the topmost y-value of a rect.
  2018. !#zh 返回矩形在 y 轴上的最大值。
  2019. @param rect rect
  2020. @example
  2021. ```js
  2022. var a = new cc.Rect(0, 10, 20, 20);
  2023. cc.rectGetMaxY(a); // 30;
  2024. ```
  2025. */
  2026. export function rectGetMaxY(rect: Rect): number;
  2027. /**
  2028. !#en Return the midpoint y-value of `rect'.
  2029. !#zh 返回矩形在 y 轴上的中点。
  2030. @param rect rect
  2031. @example
  2032. ```js
  2033. var a = new cc.Rect(0, 10, 20, 20);
  2034. cc.rectGetMidY(a); // 20;
  2035. ```
  2036. */
  2037. export function rectGetMidY(rect: Rect): number;
  2038. /**
  2039. !#en Return the bottommost y-value of a rect.
  2040. !#zh 返回矩形在 y 轴上的最小值。
  2041. @param rect rect
  2042. @example
  2043. ```js
  2044. var a = new cc.Rect(0, 10, 20, 20);
  2045. cc.rectGetMinY(a); // 10;
  2046. ```
  2047. */
  2048. export function rectGetMinY(rect: Rect): number;
  2049. /**
  2050. !#en Check whether a rect contains a point.
  2051. !#zh 检查一个矩形是否包含某个坐标点。
  2052. @param rect rect
  2053. @param point point
  2054. @example
  2055. ```js
  2056. var a = new cc.Rect(0, 10, 20, 20);
  2057. var b = new cc.Vec2(0, 10, 10, 10);
  2058. cc.rectContainsPoint(a, b); // true;
  2059. ```
  2060. */
  2061. export function rectContainsPoint(rect: Rect, point: Vec2): boolean;
  2062. /**
  2063. !#en Check whether a rect intersect with another.
  2064. !#zh 检查一个矩形是否与另一个相交。
  2065. @param rectA rectA
  2066. @param rectB rectB
  2067. @example
  2068. ```js
  2069. var a = new cc.Rect(0, 10, 20, 20);
  2070. var b = new cc.Rect(0, 10, 10, 10);
  2071. cc.rectIntersectsRect(a, b); // true;
  2072. ```
  2073. */
  2074. export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean;
  2075. /**
  2076. !#en Check whether a rect overlaps another.
  2077. !#zh 检查一个矩形是否重叠另一个。
  2078. @param rectA rectA
  2079. @param rectB rectB
  2080. @example
  2081. ```js
  2082. var a = new cc.Rect(0, 10, 20, 20);
  2083. var b = new cc.Rect(0, 10, 10, 10);
  2084. cc.rectOverlapsRect(a, b); // true;
  2085. ```
  2086. */
  2087. export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean;
  2088. /**
  2089. !#en Returns the smallest rectangle that contains the two source rectangles.
  2090. !#zh 返回一个包含两个指定矩形的最小矩形。
  2091. @param rectA rectA
  2092. @param rectB rectB
  2093. @example
  2094. ```js
  2095. var a = new cc.Rect(0, 10, 20, 20);
  2096. var b = new cc.Rect(0, 10, 10, 10);
  2097. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  2098. ```
  2099. */
  2100. export function rectUnion(rectA: Rect, rectB: Rect): Rect;
  2101. /**
  2102. !#en Returns the overlapping portion of 2 rectangles.
  2103. !#zh 返回 2 个矩形重叠的部分。
  2104. @param rectA rectA
  2105. @param rectB rectB
  2106. @example
  2107. ```js
  2108. var a = new cc.Rect(0, 10, 20, 20);
  2109. var b = new cc.Rect(0, 10, 10, 10);
  2110. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  2111. ```
  2112. */
  2113. export function rectIntersection(rectA: Rect, rectB: Rect): Rect;
  2114. /**
  2115. !#en
  2116. Helper function that creates a cc.Size.<br/>
  2117. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  2118. !#zh
  2119. 创建一个 cc.Size 对象的帮助函数。<br/>
  2120. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  2121. @param w width or a size object
  2122. @param h height
  2123. @example
  2124. ```js
  2125. var size1 = cc.size();
  2126. var size2 = cc.size(100,100);
  2127. var size3 = cc.size(size2);
  2128. var size4 = cc.size({width: 100, height: 100});
  2129. ```
  2130. */
  2131. export function size(w: number|Size, h?: number): Size;
  2132. /**
  2133. !#en Check whether a point's value equals to another.
  2134. !#zh 检查 Size 对象是否等于另一个。
  2135. @param size1 size1
  2136. @param size2 size2
  2137. @example
  2138. ```js
  2139. var a = new cc.size(10, 10);
  2140. var b = new cc.size(10, 10);
  2141. cc.sizeEqualToSize(a, b);// return true;
  2142. var b = new cc.size(5, 10);
  2143. cc.sizeEqualToSize(a, b);// return false;
  2144. ```
  2145. */
  2146. export function sizeEqualToSize(size1: Size, size2: Size): boolean;
  2147. export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad;
  2148. /**
  2149. @param sourceQuad sourceQuad
  2150. */
  2151. export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad;
  2152. /**
  2153. @param sourceQuads sourceQuads
  2154. */
  2155. export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[];
  2156. /**
  2157. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2158. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2159. @param x x
  2160. @param y y
  2161. @example
  2162. ```js
  2163. var v1 = cc.v2();
  2164. var v2 = cc.v2(0, 0);
  2165. var v3 = cc.v2(v2);
  2166. var v4 = cc.v2({x: 100, y: 100});
  2167. ```
  2168. */
  2169. export function v2(x?: number|any, y?: number): Vec2;
  2170. /**
  2171. !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2172. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2173. @param x a Number or a size object
  2174. @param y y
  2175. @example
  2176. ```js
  2177. var point1 = cc.p();
  2178. var point2 = cc.p(100, 100);
  2179. var point3 = cc.p(point2);
  2180. var point4 = cc.p({x: 100, y: 100});
  2181. ```
  2182. */
  2183. export function p(x?: number|any, y?: number): Vec2;
  2184. /**
  2185. !#en Check whether a point's value equals to another.
  2186. !#zh 判断两个向量是否相等。
  2187. @param point1 point1
  2188. @param point2 point2
  2189. */
  2190. export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean;
  2191. /** !#en Enum for debug modes.
  2192. !#zh 调试模式 */
  2193. export enum DebugMode {
  2194. NONE = 0,
  2195. INFO = 0,
  2196. WARN = 0,
  2197. ERROR = 0,
  2198. INFO_FOR_WEB_PAGE = 0,
  2199. WARN_FOR_WEB_PAGE = 0,
  2200. ERROR_FOR_WEB_PAGE = 0,
  2201. }
  2202. /** !#en
  2203. cc.NodePool is the cache pool designed for node type.<br/>
  2204. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  2205. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  2206. for example, a prefab is a specific node type. <br/>
  2207. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  2208. Some common use case is :<br/>
  2209. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  2210. 2. Blocks in candy crash (massive creation and recreation)<br/>
  2211. etc...
  2212. !#zh
  2213. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  2214. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  2215. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  2216. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  2217. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  2218. 一些常见的用例是:<br/>
  2219. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  2220. 2.糖果粉碎传奇中的木块(频繁创建)。
  2221. 等等.... */
  2222. export class NodePool {
  2223. /**
  2224. !#en
  2225. 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.
  2226. !#zh
  2227. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  2228. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  2229. @example
  2230. ```js
  2231. properties: {
  2232. template: cc.Prefab
  2233. },
  2234. onLoad () {
  2235. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  2236. this.myPool = new cc.NodePool('MyTemplateHandler');
  2237. }
  2238. ```
  2239. */
  2240. constructor(poolHandlerComp?: {prototype: Component}|string);
  2241. /** !#en The pool handler component, it could be the class name or the constructor.
  2242. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  2243. poolHandlerComp: Function|string;
  2244. /**
  2245. !#en The current available size in the pool
  2246. !#zh 获取当前缓冲池的可用对象数量
  2247. */
  2248. size(): number;
  2249. /**
  2250. !#en Destroy all cached nodes in the pool
  2251. !#zh 销毁对象池中缓存的所有节点
  2252. */
  2253. clear(): void;
  2254. /**
  2255. !#en Put a new Node into the pool.
  2256. It will automatically remove the node from its parent without cleanup.
  2257. It will also invoke unuse method of the poolHandlerComp if exist.
  2258. !#zh 向缓冲池中存入一个不再需要的节点对象。
  2259. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  2260. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  2261. @param obj obj
  2262. @example
  2263. ```js
  2264. let myNode = cc.instantiate(this.template);
  2265. this.myPool.put(myNode);
  2266. ```
  2267. */
  2268. put(obj: Node): void;
  2269. /**
  2270. !#en Get a obj from pool, if no available object in pool, null will be returned.
  2271. This function will invoke the reuse function of poolHandlerComp if exist.
  2272. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  2273. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  2274. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  2275. @example
  2276. ```js
  2277. let newNode = this.myPool.get();
  2278. ```
  2279. */
  2280. get(...params: any[]): Node;
  2281. }
  2282. /** !#en
  2283. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  2284. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  2285. cc.pool is a singleton object serves as an object cache pool.<br/>
  2286. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  2287. !#zh
  2288. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  2289. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  2290. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  2291. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  2292. export class pool {
  2293. /**
  2294. !#en Put the obj in pool.
  2295. !#zh 加入对象到对象池中。
  2296. @param obj The need put in pool object.
  2297. @example
  2298. ```js
  2299. ---------------------------------
  2300. var sp = new _ccsg.Sprite("a.png");
  2301. this.addChild(sp);
  2302. cc.pool.putInPool(sp);
  2303. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  2304. ```
  2305. */
  2306. putInPool(obj: any): void;
  2307. /**
  2308. !#en Check if this kind of obj has already in pool.
  2309. !#zh 检查对象池中是否有指定对象的存在。
  2310. @param objClass The check object class.
  2311. */
  2312. hasObject(objClass: any): boolean;
  2313. /**
  2314. !#en Remove the obj if you want to delete it.
  2315. !#zh 移除在对象池中指定的对象。
  2316. */
  2317. removeObject(): void;
  2318. /**
  2319. !#en Get the obj from pool.
  2320. !#zh 获取对象池中的指定对象。
  2321. */
  2322. getFromPool(): any;
  2323. /**
  2324. !#en Remove all objs in pool and reset the pool.
  2325. !#zh 移除对象池中的所有对象,并且重置对象池。
  2326. */
  2327. drainAllPools(): void;
  2328. }
  2329. /** !#en Base class cc.Action for action classes.
  2330. !#zh Action 类是所有动作类型的基类。 */
  2331. export class Action {
  2332. /**
  2333. !#en
  2334. to copy object with deep copy.
  2335. returns a clone of action.
  2336. !#zh 返回一个克隆的动作。
  2337. */
  2338. clone(): Action;
  2339. /**
  2340. !#en
  2341. return true if the action has finished.
  2342. !#zh 如果动作已完成就返回 true。
  2343. */
  2344. isDone(): boolean;
  2345. /**
  2346. !#en get the target.
  2347. !#zh 获取当前目标节点。
  2348. */
  2349. getTarget(): Node;
  2350. /**
  2351. !#en The action will modify the target properties.
  2352. !#zh 设置目标节点。
  2353. @param target target
  2354. */
  2355. setTarget(target: Node): void;
  2356. /**
  2357. !#en get the original target.
  2358. !#zh 获取原始目标节点。
  2359. */
  2360. getOriginalTarget(): Node;
  2361. /**
  2362. !#en get tag number.
  2363. !#zh 获取用于识别动作的标签。
  2364. */
  2365. getTag(): number;
  2366. /**
  2367. !#en set tag number.
  2368. !#zh 设置标签,用于识别动作。
  2369. @param tag tag
  2370. */
  2371. setTag(tag: number): void;
  2372. /** !#en Default Action tag.
  2373. !#zh 默认动作标签。 */
  2374. static TAG_INVALID: number;
  2375. }
  2376. /** !#en
  2377. Base class actions that do have a finite time duration. <br/>
  2378. Possible actions: <br/>
  2379. - An action with a duration of 0 seconds. <br/>
  2380. - An action with a duration of 35.5 seconds.
  2381. Infinite time actions are valid
  2382. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2383. export class FiniteTimeAction extends Action {
  2384. /**
  2385. !#en get duration of the action. (seconds).
  2386. !#zh 获取动作以秒为单位的持续时间。
  2387. */
  2388. getDuration(): number;
  2389. /**
  2390. !#en set duration of the action. (seconds).
  2391. !#zh 设置动作以秒为单位的持续时间。
  2392. @param duration duration
  2393. */
  2394. setDuration(duration: number): void;
  2395. /**
  2396. !#en
  2397. Returns a reversed action. <br />
  2398. For example: <br />
  2399. - The action will be x coordinates of 0 move to 100. <br />
  2400. - The reversed action will be x of 100 move to 0.
  2401. - Will be rewritten
  2402. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2403. */
  2404. reverse(): void;
  2405. /**
  2406. !#en
  2407. to copy object with deep copy.
  2408. returns a clone of action.
  2409. !#zh 返回一个克隆的动作。
  2410. */
  2411. clone(): FiniteTimeAction;
  2412. }
  2413. /** !#en Base class for Easing actions.
  2414. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2415. export class ActionEase extends ActionInterval {
  2416. }
  2417. /** !#en Base class for Easing actions with rate parameters
  2418. !#zh 拥有速率属性的缓动动作基类。 */
  2419. export class EaseRateAction extends ActionEase {
  2420. }
  2421. /** !#en Ease Elastic abstract class.
  2422. !#zh 弹性缓动动作基类。 */
  2423. export class EaseElastic extends ActionEase {
  2424. }
  2425. /** !#en cc.EaseBounce abstract class.
  2426. !#zh 反弹缓动动作基类。 */
  2427. export class EaseBounce extends ActionEase {
  2428. }
  2429. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2430. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2431. export class ActionInstant extends FiniteTimeAction {
  2432. }
  2433. /** !#en
  2434. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2435. It has an start time, and a finish time. The finish time is the parameter<br/>
  2436. duration plus the start time.</p>
  2437. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2438. - They can run normally (default) <br/>
  2439. - They can run reversed with the reverse method <br/>
  2440. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2441. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2442. then running it again in Reverse mode. </p>
  2443. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2444. export class ActionInterval extends FiniteTimeAction {
  2445. /**
  2446. !#en Implementation of ease motion.
  2447. !#zh 缓动运动。
  2448. @param easeObj easeObj
  2449. @example
  2450. ```js
  2451. action.easing(cc.easeIn(3.0));
  2452. ```
  2453. */
  2454. easing(easeObj: any): ActionInterval;
  2455. /**
  2456. !#en
  2457. Repeats an action a number of times.
  2458. To repeat an action forever use the CCRepeatForever action.
  2459. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2460. @param times times
  2461. */
  2462. repeat(times: number): ActionInterval;
  2463. /**
  2464. !#en
  2465. Repeats an action for ever. <br/>
  2466. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2467. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2468. */
  2469. repeatForever(): ActionInterval;
  2470. }
  2471. /** !#en
  2472. cc.ActionManager is a class that can manage actions.<br/>
  2473. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2474. which uses this class's singleton object.
  2475. But there are some cases where you might need to use this class. <br/>
  2476. Examples:<br/>
  2477. - When you want to run an action where the target is different from a CCNode.<br/>
  2478. - When you want to pause / resume the actions<br/>
  2479. !#zh
  2480. cc.ActionManager 是可以管理动作的单例类。<br/>
  2481. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2482. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2483. 例如:
  2484. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2485. - 当你想要暂停/恢复动作时。 <br/> */
  2486. export class ActionManager {
  2487. /**
  2488. !#en
  2489. Adds an action with a target.<br/>
  2490. If the target is already present, then the action will be added to the existing target.
  2491. 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.
  2492. When the target is paused, the queued actions won't be 'ticked'.
  2493. !#zh
  2494. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2495. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2496. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2497. 当目标状态的 paused 为 true,动作将不会被执行
  2498. @param action action
  2499. @param target target
  2500. @param paused paused
  2501. */
  2502. addAction(action: Action, target: Node, paused: boolean): void;
  2503. /**
  2504. !#en Removes all actions from all the targets.
  2505. !#zh 移除所有对象的所有动作。
  2506. */
  2507. removeAllActions(): void;
  2508. /**
  2509. !#en
  2510. Removes all actions from a certain target. <br/>
  2511. All the actions that belongs to the target will be removed.
  2512. !#zh
  2513. 移除指定对象上的所有动作。<br/>
  2514. 属于该目标的所有的动作将被删除。
  2515. @param target target
  2516. @param forceDelete forceDelete
  2517. */
  2518. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2519. /**
  2520. !#en Removes an action given an action reference.
  2521. !#zh 移除指定的动作。
  2522. @param action action
  2523. */
  2524. removeAction(action: Action): void;
  2525. /**
  2526. !#en Removes an action given its tag and the target.
  2527. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2528. @param tag tag
  2529. @param target target
  2530. */
  2531. removeActionByTag(tag: number, target: Node): void;
  2532. /**
  2533. !#en Gets an action given its tag an a target.
  2534. !#zh 通过目标对象和标签获取一个动作。
  2535. @param tag tag
  2536. @param target target
  2537. */
  2538. getActionByTag(tag: number, target: Node): Action;
  2539. /**
  2540. !#en
  2541. Returns the numbers of actions that are running in a certain target. <br/>
  2542. Composable actions are counted as 1 action. <br/>
  2543. Example: <br/>
  2544. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2545. - If you are running 7 Sequences of 2 actions, it will return 7.
  2546. !#zh
  2547. 返回指定对象下所有正在运行的动作数量。 <br/>
  2548. 组合动作被算作一个动作。<br/>
  2549. 例如:<br/>
  2550. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2551. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2552. @param target target
  2553. */
  2554. getNumberOfRunningActionsInTarget(target: Node): number;
  2555. /**
  2556. !#en Pauses the target: all running actions and newly added actions will be paused.
  2557. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2558. @param target target
  2559. */
  2560. pauseTarget(target: Node): void;
  2561. /**
  2562. !#en Resumes the target. All queued actions will be resumed.
  2563. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2564. @param target target
  2565. */
  2566. resumeTarget(target: Node): void;
  2567. /**
  2568. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2569. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2570. */
  2571. pauseAllRunningActions(): any[];
  2572. /**
  2573. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2574. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2575. @param targetsToResume targetsToResume
  2576. */
  2577. resumeTargets(targetsToResume: any[]): void;
  2578. /**
  2579. !#en Pause a set of targets.
  2580. !#zh 暂停一组指定对象。
  2581. @param targetsToPause targetsToPause
  2582. */
  2583. pauseTargets(targetsToPause: any[]): void;
  2584. /**
  2585. !#en
  2586. purges the shared action manager. It releases the retained instance. <br/>
  2587. because it uses this, so it can not be static.
  2588. !#zh
  2589. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2590. 因为它使用 this,因此它不能是静态的。
  2591. */
  2592. purgeSharedManager(): void;
  2593. /**
  2594. !#en The ActionManager update。
  2595. !#zh ActionManager 主循环。
  2596. @param dt delta time in seconds
  2597. */
  2598. update(dt: number): void;
  2599. }
  2600. /** !#en Class for animation data handling.
  2601. !#zh 动画剪辑,用于存储动画数据。 */
  2602. export class AnimationClip extends Asset {
  2603. /** !#en Duration of this animation.
  2604. !#zh 动画的持续时间。 */
  2605. duration: number;
  2606. /** !#en FrameRate of this animation.
  2607. !#zh 动画的帧速率。 */
  2608. sample: number;
  2609. /** !#en Speed of this animation.
  2610. !#zh 动画的播放速度。 */
  2611. speed: number;
  2612. /** !#en WrapMode of this animation.
  2613. !#zh 动画的循环模式。 */
  2614. wrapMode: WrapMode;
  2615. /** !#en Curve data.
  2616. !#zh 曲线数据。 */
  2617. curveData: any;
  2618. /** !#en Event data.
  2619. !#zh 事件数据。 */
  2620. events: {frame: number, func: string, params: string[]}[];
  2621. /**
  2622. !#en Crate clip with a set of sprite frames
  2623. !#zh 使用一组序列帧图片来创建动画剪辑
  2624. @param spriteFrames spriteFrames
  2625. @param sample sample
  2626. @example
  2627. ```js
  2628. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  2629. ```
  2630. */
  2631. static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip;
  2632. }
  2633. /** !#en
  2634. The AnimationState gives full control over animation playback process.
  2635. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  2636. !#zh
  2637. AnimationState 完全控制动画播放过程。<br/>
  2638. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  2639. export class AnimationState extends Playable {
  2640. /**
  2641. @param clip clip
  2642. @param name name
  2643. */
  2644. constructor(clip: AnimationClip, name?: string);
  2645. animator: AnimationAnimator;
  2646. /** !#en The curves list.
  2647. !#zh 曲线列表。 */
  2648. curves: any[];
  2649. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  2650. the active interval.
  2651. !#zh 延迟多少秒播放。 */
  2652. delay: number;
  2653. /** !#en The animation's iteration count property.
  2654. A real number greater than or equal to zero (including positive infinity) representing the number of times
  2655. to repeat the animation node.
  2656. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  2657. calculations.
  2658. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  2659. repeatCount: number;
  2660. /** !#en The iteration duration of this animation in seconds. (length)
  2661. !#zh 单次动画的持续时间,秒。 */
  2662. duration: number;
  2663. /** !#en The animation's playback speed. 1 is normal playback speed.
  2664. !#zh 播放速率。 */
  2665. speed: number;
  2666. /** !#en
  2667. Wrapping mode of the playing animation.
  2668. Notice : dynamic change wrapMode will reset time and repeatCount property
  2669. !#zh
  2670. 动画循环方式。
  2671. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  2672. wrapMode: WrapMode;
  2673. /** !#en The current time of this animation in seconds.
  2674. !#zh 动画当前的时间,秒。 */
  2675. time: number;
  2676. /** !#en The clip that is being played by this animation state.
  2677. !#zh 此动画状态正在播放的剪辑。 */
  2678. clip: AnimationClip;
  2679. /** !#en The name of the playing animation.
  2680. !#zh 动画的名字 */
  2681. name: string;
  2682. }
  2683. /** undefined */
  2684. export class Playable {
  2685. /** !#en Is playing or paused in play mode?
  2686. !#zh 当前是否正在播放。 */
  2687. isPlaying: boolean;
  2688. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  2689. !#zh 当前是否正在暂停 */
  2690. isPaused: boolean;
  2691. /**
  2692. !#en Play this animation.
  2693. !#zh 播放动画。
  2694. */
  2695. play(): void;
  2696. /**
  2697. !#en Stop this animation.
  2698. !#zh 停止动画播放。
  2699. */
  2700. stop(): void;
  2701. /**
  2702. !#en Pause this animation.
  2703. !#zh 暂停动画。
  2704. */
  2705. pause(): void;
  2706. /**
  2707. !#en Resume this animation.
  2708. !#zh 重新播放动画。
  2709. */
  2710. resume(): void;
  2711. /**
  2712. !#en Perform a single frame step.
  2713. !#zh 执行一帧动画。
  2714. */
  2715. step(): void;
  2716. }
  2717. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  2718. !#zh 动画使用的循环模式。 */
  2719. export enum WrapMode {
  2720. Default = 0,
  2721. Normal = 0,
  2722. Reverse = 0,
  2723. Loop = 0,
  2724. LoopReverse = 0,
  2725. PingPong = 0,
  2726. PingPongReverse = 0,
  2727. }
  2728. /** !#en
  2729. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  2730. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  2731. length and color. The fadeTime controls how long it takes each vertex in <br/>
  2732. the streak to fade out, the minimum segment size it how many pixels the <br/>
  2733. streak will move before adding a new ribbon segment, and the texture <br/>
  2734. length is the how many pixels the texture is stretched across. The texture <br/>
  2735. is vertically aligned along the streak segment.
  2736. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  2737. export class MotionStreak extends Component {
  2738. /** !#en
  2739. !#zh 在编辑器模式下预览拖尾效果。 */
  2740. preview: boolean;
  2741. /** !#en The fade time to fade.
  2742. !#zh 拖尾的渐隐时间,以秒为单位。 */
  2743. fadeTime: number;
  2744. /** !#en The minimum segment size.
  2745. !#zh 拖尾之间最小距离。 */
  2746. minSeg: number;
  2747. /** !#en The stroke's width.
  2748. !#zh 拖尾的宽度。 */
  2749. stroke: number;
  2750. /** !#en The texture of the MotionStreak.
  2751. !#zh 拖尾的贴图。 */
  2752. texture: Texture2D;
  2753. /** !#en The color of the MotionStreak.
  2754. !#zh 拖尾的颜色 */
  2755. color: Color;
  2756. /** !#en The fast Mode.
  2757. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  2758. fastMode: boolean;
  2759. /**
  2760. !#en Remove all living segments of the ribbon.
  2761. !#zh 删除当前所有的拖尾片段。
  2762. @example
  2763. ```js
  2764. // Remove all living segments of the ribbon.
  2765. myMotionStreak.reset();
  2766. ```
  2767. */
  2768. reset(): void;
  2769. }
  2770. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  2771. !#zh
  2772. cc.audioengine是单例对象。<br/>
  2773. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  2774. 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放 <br/>
  2775. 注意:<br/>
  2776. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  2777. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  2778. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  2779. export class audioEngine {
  2780. /**
  2781. !#en Play audio.
  2782. !#zh 播放音频
  2783. @param clip The audio clip to play.
  2784. @param loop Whether the music loop or not.
  2785. @param volume Volume size.
  2786. @example
  2787. ```js
  2788. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  2789. var audioID = cc.audioEngine.play(clip, false, 0.5);
  2790. });
  2791. ```
  2792. */
  2793. static play(clip: AudioClip, loop: boolean, volume: number): number;
  2794. /**
  2795. !#en Set audio loop.
  2796. !#zh 设置音频是否循环。
  2797. @param audioID audio id.
  2798. @param loop Whether cycle.
  2799. @example
  2800. ```js
  2801. cc.audioEngine.setLoop(id, true);
  2802. ```
  2803. */
  2804. static setLoop(audioID: number, loop: boolean): void;
  2805. /**
  2806. !#en Get audio cycle state.
  2807. !#zh 获取音频的循环状态。
  2808. @param audioID audio id.
  2809. @example
  2810. ```js
  2811. cc.audioEngine.isLoop(id);
  2812. ```
  2813. */
  2814. static isLoop(audioID: number): boolean;
  2815. /**
  2816. !#en Set the volume of audio.
  2817. !#zh 设置音量(0.0 ~ 1.0)。
  2818. @param audioID audio id.
  2819. @param volume Volume must be in 0.0~1.0 .
  2820. @example
  2821. ```js
  2822. cc.audioEngine.setVolume(id, 0.5);
  2823. ```
  2824. */
  2825. static setVolume(audioID: number, volume: number): void;
  2826. /**
  2827. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  2828. !#zh 获取音量(0.0 ~ 1.0)。
  2829. @param audioID audio id.
  2830. @example
  2831. ```js
  2832. var volume = cc.audioEngine.getVolume(id);
  2833. ```
  2834. */
  2835. static getVolume(audioID: number): number;
  2836. /**
  2837. !#en Set current time
  2838. !#zh 设置当前的音频时间。
  2839. @param audioID audio id.
  2840. @param sec current time.
  2841. @example
  2842. ```js
  2843. cc.audioEngine.setCurrentTime(id, 2);
  2844. ```
  2845. */
  2846. static setCurrentTime(audioID: number, sec: number): boolean;
  2847. /**
  2848. !#en Get current time
  2849. !#zh 获取当前的音频播放时间。
  2850. @param audioID audio id.
  2851. @example
  2852. ```js
  2853. var time = cc.audioEngine.getCurrentTime(id);
  2854. ```
  2855. */
  2856. static getCurrentTime(audioID: number): number;
  2857. /**
  2858. !#en Get audio duration
  2859. !#zh 获取音频总时长。
  2860. @param audioID audio id.
  2861. @example
  2862. ```js
  2863. var time = cc.audioEngine.getDuration(id);
  2864. ```
  2865. */
  2866. static getDuration(audioID: number): number;
  2867. /**
  2868. !#en Get audio state
  2869. !#zh 获取音频状态。
  2870. @param audioID audio id.
  2871. @example
  2872. ```js
  2873. var state = cc.audioEngine.getState(id);
  2874. ```
  2875. */
  2876. static getState(audioID: number): audioEngine.AudioState;
  2877. /**
  2878. !#en Set Audio finish callback
  2879. !#zh 设置一个音频结束后的回调
  2880. @param audioID audio id.
  2881. @param callback loaded callback.
  2882. @example
  2883. ```js
  2884. cc.audioEngine.setFinishCallback(id, function () {});
  2885. ```
  2886. */
  2887. static setFinishCallback(audioID: number, callback: Function): void;
  2888. /**
  2889. !#en Pause playing audio.
  2890. !#zh 暂停正在播放音频。
  2891. @param audioID The return value of function play.
  2892. @example
  2893. ```js
  2894. cc.audioEngine.pause(audioID);
  2895. ```
  2896. */
  2897. static pause(audioID: number): void;
  2898. /**
  2899. !#en Pause all playing audio
  2900. !#zh 暂停现在正在播放的所有音频。
  2901. @example
  2902. ```js
  2903. cc.audioEngine.pauseAll();
  2904. ```
  2905. */
  2906. static pauseAll(): void;
  2907. /**
  2908. !#en Resume playing audio.
  2909. !#zh 恢复播放指定的音频。
  2910. @param audioID The return value of function play.
  2911. @example
  2912. ```js
  2913. cc.audioEngine.resume(audioID);
  2914. ```
  2915. */
  2916. static resume(audioID: number): void;
  2917. /**
  2918. !#en Resume all playing audio.
  2919. !#zh 恢复播放所有之前暂停的所有音频。
  2920. @example
  2921. ```js
  2922. cc.audioEngine.resumeAll();
  2923. ```
  2924. */
  2925. static resumeAll(): void;
  2926. /**
  2927. !#en Stop playing audio.
  2928. !#zh 停止播放指定音频。
  2929. @param audioID The return value of function play.
  2930. @example
  2931. ```js
  2932. cc.audioEngine.stop(audioID);
  2933. ```
  2934. */
  2935. static stop(audioID: number): void;
  2936. /**
  2937. !#en Stop all playing audio.
  2938. !#zh 停止正在播放的所有音频。
  2939. @example
  2940. ```js
  2941. cc.audioEngine.stopAll();
  2942. ```
  2943. */
  2944. static stopAll(): void;
  2945. /**
  2946. !#en Set up an audio can generate a few examples.
  2947. !#zh 设置一个音频可以设置几个实例
  2948. @param num a number of instances to be created from within an audio
  2949. @example
  2950. ```js
  2951. cc.audioEngine.setMaxAudioInstance(20);
  2952. ```
  2953. */
  2954. static setMaxAudioInstance(num: number): void;
  2955. /**
  2956. !#en Getting audio can produce several examples.
  2957. !#zh 获取一个音频可以设置几个实例
  2958. @example
  2959. ```js
  2960. cc.audioEngine.getMaxAudioInstance();
  2961. ```
  2962. */
  2963. static getMaxAudioInstance(): number;
  2964. /**
  2965. !#en Unload the preloaded audio from internal buffer.
  2966. !#zh 卸载预加载的音频。
  2967. @param clip clip
  2968. @example
  2969. ```js
  2970. cc.audioEngine.uncache(filePath);
  2971. ```
  2972. */
  2973. static uncache(clip: AudioClip): void;
  2974. /**
  2975. !#en Unload all audio from internal buffer.
  2976. !#zh 卸载所有音频。
  2977. @example
  2978. ```js
  2979. cc.audioEngine.uncacheAll();
  2980. ```
  2981. */
  2982. static uncacheAll(): void;
  2983. /**
  2984. !#en Preload audio file.
  2985. !#zh 预加载一个音频
  2986. @param filePath The file path of an audio.
  2987. @param callback The callback of an audio.
  2988. @example
  2989. ```js
  2990. cc.audioEngine.preload(path);
  2991. ```
  2992. */
  2993. static preload(filePath: string, callback?: Function): void;
  2994. /**
  2995. !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
  2996. !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
  2997. @param kb The file path of an audio.
  2998. @example
  2999. ```js
  3000. cc.audioEngine.setMaxWebAudioSize(300);
  3001. ```
  3002. */
  3003. static setMaxWebAudioSize(kb: number): void;
  3004. /**
  3005. !#en Play background music
  3006. !#zh 播放背景音乐
  3007. @param clip The audio clip to play.
  3008. @param loop Whether the music loop or not.
  3009. @example
  3010. ```js
  3011. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  3012. var audioID = cc.audioEngine.playMusic(clip, false);
  3013. });
  3014. ```
  3015. */
  3016. static playMusic(clip: AudioClip, loop: boolean): number;
  3017. /**
  3018. !#en Stop background music.
  3019. !#zh 停止播放背景音乐。
  3020. @example
  3021. ```js
  3022. cc.audioEngine.stopMusic();
  3023. ```
  3024. */
  3025. static stopMusic(): void;
  3026. /**
  3027. !#en Pause the background music.
  3028. !#zh 暂停播放背景音乐。
  3029. @example
  3030. ```js
  3031. cc.audioEngine.pauseMusic();
  3032. ```
  3033. */
  3034. static pauseMusic(): void;
  3035. /**
  3036. !#en Resume playing background music.
  3037. !#zh 恢复播放背景音乐。
  3038. @example
  3039. ```js
  3040. cc.audioEngine.resumeMusic();
  3041. ```
  3042. */
  3043. static resumeMusic(): void;
  3044. /**
  3045. !#en Get the volume(0.0 ~ 1.0).
  3046. !#zh 获取音量(0.0 ~ 1.0)。
  3047. @example
  3048. ```js
  3049. var volume = cc.audioEngine.getMusicVolume();
  3050. ```
  3051. */
  3052. static getMusicVolume(): number;
  3053. /**
  3054. !#en Set the background music volume.
  3055. !#zh 设置背景音乐音量(0.0 ~ 1.0)。
  3056. @param volume Volume must be in 0.0~1.0.
  3057. @example
  3058. ```js
  3059. cc.audioEngine.setMusicVolume(0.5);
  3060. ```
  3061. */
  3062. static setMusicVolume(volume: number): void;
  3063. /**
  3064. !#en Background music playing state
  3065. !#zh 背景音乐是否正在播放
  3066. @example
  3067. ```js
  3068. cc.audioEngine.isMusicPlaying();
  3069. ```
  3070. */
  3071. static isMusicPlaying(): boolean;
  3072. /**
  3073. !#en Play effect audio.
  3074. !#zh 播放音效
  3075. @param clip The audio clip to play.
  3076. @param loop Whether the music loop or not.
  3077. @example
  3078. ```js
  3079. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  3080. var audioID = cc.audioEngine.playEffect(clip, false);
  3081. });
  3082. ```
  3083. */
  3084. static playEffect(clip: AudioClip, loop: boolean): number;
  3085. /**
  3086. !#en Set the volume of effect audio.
  3087. !#zh 设置音效音量(0.0 ~ 1.0)。
  3088. @param volume Volume must be in 0.0~1.0.
  3089. @example
  3090. ```js
  3091. cc.audioEngine.setEffectsVolume(0.5);
  3092. ```
  3093. */
  3094. static setEffectsVolume(volume: number): void;
  3095. /**
  3096. !#en The volume of the effect audio max value is 1.0,the min value is 0.0 .
  3097. !#zh 获取音效音量(0.0 ~ 1.0)。
  3098. @example
  3099. ```js
  3100. var volume = cc.audioEngine.getEffectsVolume();
  3101. ```
  3102. */
  3103. static getEffectsVolume(): number;
  3104. /**
  3105. !#en Pause effect audio.
  3106. !#zh 暂停播放音效。
  3107. @param audioID audio id.
  3108. @example
  3109. ```js
  3110. cc.audioEngine.pauseEffect(audioID);
  3111. ```
  3112. */
  3113. static pauseEffect(audioID: number): void;
  3114. /**
  3115. !#en Stop playing all the sound effects.
  3116. !#zh 暂停播放所有音效。
  3117. @example
  3118. ```js
  3119. cc.audioEngine.pauseAllEffects();
  3120. ```
  3121. */
  3122. static pauseAllEffects(): void;
  3123. /**
  3124. !#en Resume effect audio.
  3125. !#zh 恢复播放音效音频。
  3126. @param audioID The return value of function play.
  3127. @example
  3128. ```js
  3129. cc.audioEngine.resumeEffect(audioID);
  3130. ```
  3131. */
  3132. static resumeEffect(audioID: number): void;
  3133. /**
  3134. !#en Resume all effect audio.
  3135. !#zh 恢复播放所有之前暂停的音效。
  3136. @example
  3137. ```js
  3138. cc.audioEngine.resumeAllEffects();
  3139. ```
  3140. */
  3141. static resumeAllEffects(): void;
  3142. /**
  3143. !#en Stop playing the effect audio.
  3144. !#zh 停止播放音效。
  3145. @param audioID audio id.
  3146. @example
  3147. ```js
  3148. cc.audioEngine.stopEffect(id);
  3149. ```
  3150. */
  3151. static stopEffect(audioID: number): void;
  3152. /**
  3153. !#en Stop playing all the effects.
  3154. !#zh 停止播放所有音效。
  3155. @example
  3156. ```js
  3157. cc.audioEngine.stopAllEffects();
  3158. ```
  3159. */
  3160. static stopAllEffects(): void;
  3161. }
  3162. /** !#en
  3163. <p>
  3164. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  3165. cc.director is a singleton object which manage your game's logic flow.<br/>
  3166. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  3167. the standard way to use it is by calling:<br/>
  3168. - cc.director.methodName(); <br/>
  3169. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  3170. <br/>
  3171. The cc.director is also responsible for:<br/>
  3172. - initializing the OpenGL context<br/>
  3173. - setting the OpenGL pixel format (default on is RGB565)<br/>
  3174. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  3175. - setting the color for clear screen (default one is BLACK)<br/>
  3176. - setting the projection (default one is 3D)<br/>
  3177. - setting the orientation (default one is Portrait)<br/>
  3178. <br/>
  3179. <br/>
  3180. The cc.director also sets the default OpenGL context:<br/>
  3181. - GL_TEXTURE_2D is enabled<br/>
  3182. - GL_VERTEX_ARRAY is enabled<br/>
  3183. - GL_COLOR_ARRAY is enabled<br/>
  3184. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  3185. </p>
  3186. <p>
  3187. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  3188. Features and Limitations:<br/>
  3189. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  3190. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  3191. </p>
  3192. !#zh
  3193. <p>
  3194. 注意:用 cc.director 代替 cc.Director。<br/>
  3195. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  3196. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  3197. 使用它的标准方法是通过调用:<br/>
  3198. - cc.director.methodName();
  3199. <br/>
  3200. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  3201. <br/>
  3202. cc.director 还负责:<br/>
  3203. - 初始化 OpenGL 环境。<br/>
  3204. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  3205. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  3206. - 设置空白场景的颜色 (默认是 黑色)<br/>
  3207. - 设置投影 (默认是 3D)<br/>
  3208. - 设置方向 (默认是 Portrait)<br/>
  3209. <br/>
  3210. cc.director 设置了 OpenGL 默认环境 <br/>
  3211. - GL_TEXTURE_2D 启用。<br/>
  3212. - GL_VERTEX_ARRAY 启用。<br/>
  3213. - GL_COLOR_ARRAY 启用。<br/>
  3214. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  3215. </p>
  3216. <p>
  3217. cc.director 也同步定时器与显示器的刷新速率。
  3218. <br/>
  3219. 特点和局限性: <br/>
  3220. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  3221. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  3222. </p> */
  3223. export class Director extends EventTarget {
  3224. /**
  3225. !#en
  3226. Converts an OpenGL coordinate to a view coordinate<br/>
  3227. Useful to convert node points to window points for calls such as glScissor<br/>
  3228. Implementation can be found in CCDirectorWebGL.
  3229. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  3230. @param glPoint glPoint
  3231. */
  3232. convertToUI(glPoint: Vec2): Vec2;
  3233. /**
  3234. !#en
  3235. Returns the size of the WebGL view in points.<br/>
  3236. It takes into account any possible rotation (device orientation) of the window.
  3237. !#zh 获取视图的大小,以点为单位。
  3238. */
  3239. getWinSize(): Size;
  3240. /**
  3241. !#en
  3242. Returns the size of the OpenGL view in pixels.<br/>
  3243. It takes into account any possible rotation (device orientation) of the window.<br/>
  3244. On Mac winSize and winSizeInPixels return the same value.
  3245. (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())
  3246. !#zh
  3247. 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。
  3248. 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
  3249. */
  3250. getWinSizeInPixels(): Size;
  3251. /**
  3252. !#en Returns the visible size of the running scene.
  3253. !#zh 获取运行场景的可见大小。
  3254. */
  3255. getVisibleSize(): Size;
  3256. /**
  3257. !#en Returns the visible origin of the running scene.
  3258. !#zh 获取视图在游戏内容中的坐标原点。
  3259. */
  3260. getVisibleOrigin(): Vec2;
  3261. /**
  3262. !#en Pause the director's ticker, only involve the game logic execution.
  3263. It won't pause the rendering process nor the event manager.
  3264. If you want to pause the entier game including rendering, audio and event,
  3265. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  3266. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  3267. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  3268. */
  3269. pause(): void;
  3270. /**
  3271. !#en
  3272. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  3273. The new scene will be launched immediately.
  3274. !#zh 立刻切换指定场景。
  3275. @param scene The need run scene.
  3276. @param onBeforeLoadScene The function invoked at the scene before loading.
  3277. @param onLaunched The function invoked at the scene after launch.
  3278. */
  3279. runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  3280. /**
  3281. !#en Loads the scene by its name.
  3282. !#zh 通过场景名称进行加载场景。
  3283. @param sceneName The name of the scene to load.
  3284. @param onLaunched callback, will be called after scene launched.
  3285. */
  3286. loadScene(sceneName: string, onLaunched?: Function): boolean;
  3287. /**
  3288. !#en
  3289. Preloads the scene to reduces loading time. You can call this method at any time you want.
  3290. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  3291. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  3292. yet finished, the scene will be launched after loaded automatically.
  3293. !#zh 预加载场景,你可以在任何时候调用这个方法。
  3294. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  3295. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  3296. @param sceneName The name of the scene to preload.
  3297. @param onLoaded callback, will be called after scene loaded.
  3298. */
  3299. preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void;
  3300. /**
  3301. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  3302. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  3303. */
  3304. resume(): void;
  3305. /**
  3306. !#en
  3307. Enables or disables WebGL depth test.<br/>
  3308. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  3309. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  3310. @param on on
  3311. */
  3312. setDepthTest(on: boolean): void;
  3313. /**
  3314. !#en
  3315. Set color for clear screen.<br/>
  3316. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  3317. !#zh
  3318. 设置场景的默认擦除颜色。<br/>
  3319. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  3320. @param clearColor clearColor
  3321. */
  3322. setClearColor(clearColor: Color): void;
  3323. /**
  3324. !#en
  3325. Sets an OpenGL projection.<br/>
  3326. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3327. !#zh 设置 OpenGL 投影。
  3328. @param projection projection
  3329. */
  3330. setProjection(projection: number): void;
  3331. /**
  3332. !#en
  3333. Update the view port.<br/>
  3334. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3335. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  3336. */
  3337. setViewport(): void;
  3338. /**
  3339. !#en
  3340. Sets an OpenGL projection.<br/>
  3341. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3342. !#zh 获取 OpenGL 投影。
  3343. */
  3344. getProjection(): number;
  3345. /**
  3346. !#en
  3347. Enables/disables OpenGL alpha blending.<br/>
  3348. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3349. !#zh 启用/禁用 透明度融合。
  3350. @param on on
  3351. */
  3352. setAlphaBlending(on: boolean): void;
  3353. /**
  3354. !#en
  3355. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  3356. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  3357. If the new scene replaces the old one, the it will receive the "cleanup" message.
  3358. !#zh
  3359. 更换场景时是否接收清理消息。<br>
  3360. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  3361. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  3362. */
  3363. isSendCleanupToScene(): boolean;
  3364. /**
  3365. !#en Returns current logic Scene.
  3366. !#zh 获取当前逻辑场景。
  3367. @example
  3368. ```js
  3369. // This will help you to get the Canvas node in scene
  3370. cc.director.getScene().getChildByName('Canvas');
  3371. ```
  3372. */
  3373. getScene(): Scene;
  3374. /**
  3375. !#en Returns the FPS value.
  3376. !#zh 获取单位帧执行时间。
  3377. */
  3378. getAnimationInterval(): number;
  3379. /**
  3380. !#en Returns whether or not to display the FPS informations.
  3381. !#zh 获取是否显示 FPS 信息。
  3382. */
  3383. isDisplayStats(): boolean;
  3384. /**
  3385. !#en Sets whether display the FPS on the bottom-left corner.
  3386. !#zh 设置是否在左下角显示 FPS。
  3387. @param displayStats displayStats
  3388. */
  3389. setDisplayStats(displayStats: boolean): void;
  3390. /**
  3391. !#en Returns whether next delta time equals to zero.
  3392. !#zh 返回下一个 “delta time” 是否等于零。
  3393. */
  3394. isNextDeltaTimeZero(): boolean;
  3395. /**
  3396. !#en Returns whether or not the Director is paused.
  3397. !#zh 是否处于暂停状态。
  3398. */
  3399. isPaused(): boolean;
  3400. /**
  3401. !#en Returns how many frames were called since the director started.
  3402. !#zh 获取 director 启动以来游戏运行的总帧数。
  3403. */
  3404. getTotalFrames(): number;
  3405. /**
  3406. !#en Returns the cc.Scheduler associated with this director.
  3407. !#zh 获取和 director 相关联的 cc.Scheduler。
  3408. */
  3409. getScheduler(): Scheduler;
  3410. /**
  3411. !#en Sets the cc.Scheduler associated with this director.
  3412. !#zh 设置和 director 相关联的 cc.Scheduler。
  3413. @param scheduler scheduler
  3414. */
  3415. setScheduler(scheduler: Scheduler): void;
  3416. /**
  3417. !#en Returns the cc.ActionManager associated with this director.
  3418. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  3419. */
  3420. getActionManager(): ActionManager;
  3421. /**
  3422. !#en Sets the cc.ActionManager associated with this director.
  3423. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  3424. @param actionManager actionManager
  3425. */
  3426. setActionManager(actionManager: ActionManager): void;
  3427. /**
  3428. Returns the cc.CollisionManager associated with this director.
  3429. */
  3430. getCollisionManager(): CollisionManager;
  3431. /**
  3432. Returns the cc.PhysicsManager associated with this director.
  3433. */
  3434. getPhysicsManager(): PhysicsManager;
  3435. /**
  3436. !#en Returns the delta time since last frame.
  3437. !#zh 获取上一帧的 “delta time”。
  3438. */
  3439. getDeltaTime(): number;
  3440. /** !#en The event projection changed of cc.Director.
  3441. !#zh cc.Director 投影变化的事件。 */
  3442. static EVENT_PROJECTION_CHANGED: string;
  3443. /** !#en The event which will be triggered before loading a new scene.
  3444. !#zh 加载新场景之前所触发的事件。 */
  3445. static EVENT_BEFORE_SCENE_LOADING: string;
  3446. /** !#en The event which will be triggered before launching a new scene.
  3447. !#zh 运行新场景之前所触发的事件。 */
  3448. static EVENT_BEFORE_SCENE_LAUNCH: string;
  3449. /** !#en The event which will be triggered after launching a new scene.
  3450. !#zh 运行新场景之后所触发的事件。 */
  3451. static EVENT_AFTER_SCENE_LAUNCH: string;
  3452. /** !#en The event which will be triggered at the beginning of every frame.
  3453. !#zh 每个帧的开始时所触发的事件。 */
  3454. static EVENT_BEFORE_UPDATE: string;
  3455. /** !#en The event which will be triggered after engine and components update logic.
  3456. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  3457. static EVENT_AFTER_UPDATE: string;
  3458. /** !#en The event which will be triggered before visiting the rendering scene graph.
  3459. !#zh 访问渲染场景树之前所触发的事件。 */
  3460. static EVENT_BEFORE_VISIT: string;
  3461. /** !#en
  3462. The event which will be triggered after visiting the rendering scene graph,
  3463. the render queue is ready but not rendered at this point.
  3464. !#zh
  3465. 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */
  3466. static EVENT_AFTER_VISIT: string;
  3467. /** !#en The event which will be triggered after the rendering process.
  3468. !#zh 渲染过程之后所触发的事件。 */
  3469. static EVENT_AFTER_DRAW: string;
  3470. /** Constant for 2D projection (orthogonal projection) */
  3471. static PROJECTION_2D: number;
  3472. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  3473. static PROJECTION_3D: number;
  3474. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  3475. static PROJECTION_CUSTOM: number;
  3476. /** Constant for default projection of cc.Director, default projection is 2D projection */
  3477. static PROJECTION_DEFAULT: number;
  3478. }
  3479. /** !#en cc.game is the singleton object for game related functions.
  3480. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  3481. export class Game extends EventTarget {
  3482. /** !#en Event triggered when game hide to background.
  3483. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3484. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  3485. !#zh 游戏进入后台时触发的事件。
  3486. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3487. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  3488. EVENT_HIDE: string;
  3489. /** Event triggered when game back to foreground
  3490. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3491. on native platforms, it corresponds to enter foreground event.
  3492. !#zh 游戏进入前台运行时触发的事件。
  3493. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3494. 在原生平台,它对应的是应用被切换到前台事件。 */
  3495. EVENT_SHOW: string;
  3496. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  3497. EVENT_GAME_INITED: string;
  3498. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  3499. EVENT_RENDERER_INITED: string;
  3500. /** Key of config */
  3501. CONFIG_KEY: any;
  3502. /** !#en The outer frame of the game canvas, parent of cc.container.
  3503. !#zh 游戏画布的外框,cc.container 的父类。 */
  3504. frame: any;
  3505. /** !#en The container of game canvas, equals to cc.container.
  3506. !#zh 游戏画布的容器。 */
  3507. container: HTMLDivElement;
  3508. /** !#en The canvas of the game, equals to cc._canvas.
  3509. !#zh 游戏的画布。 */
  3510. canvas: HTMLCanvasElement;
  3511. /** !#en
  3512. The current game configuration, including:<br/>
  3513. 1. debugMode<br/>
  3514. "debugMode" possible values :<br/>
  3515. 0 - No message will be printed. <br/>
  3516. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  3517. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  3518. 3 - cc.error, cc.assert will print in console. <br/>
  3519. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  3520. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  3521. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  3522. 2. showFPS<br/>
  3523. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  3524. 3. exposeClassName<br/>
  3525. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  3526. 4. frameRate<br/>
  3527. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  3528. 5. id<br/>
  3529. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  3530. 6. renderMode<br/>
  3531. "renderMode" sets the renderer type, only useful on web :<br/>
  3532. 0 - Automatically chosen by engine<br/>
  3533. 1 - Forced to use canvas renderer<br/>
  3534. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  3535. 7. scenes<br/>
  3536. "scenes" include available scenes in the current bundle.<br/>
  3537. <br/>
  3538. Please DO NOT modify this object directly, it won't have any effect.<br/>
  3539. !#zh
  3540. 当前的游戏配置,包括: <br/>
  3541. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  3542. "debugMode" 各种设置选项的意义。 <br/>
  3543. 0 - 没有消息被打印出来。 <br/>
  3544. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  3545. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  3546. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  3547. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3548. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3549. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3550. 2. showFPS(显示 FPS) <br/>
  3551. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  3552. 3. exposeClassName <br/>
  3553. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  3554. 4. frameRate (帧率) <br/>
  3555. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  3556. 5. id <br/>
  3557. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  3558. 6. renderMode(渲染模式) <br/>
  3559. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  3560. 0 - 通过引擎自动选择。 <br/>
  3561. 1 - 强制使用 canvas 渲染。
  3562. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  3563. 7. scenes <br/>
  3564. “scenes” 当前包中可用场景。 <br/>
  3565. <br/>
  3566. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  3567. config: any;
  3568. /**
  3569. !#en Callback when the scripts of engine have been load.
  3570. !#zh 当引擎完成启动后的回调函数。
  3571. */
  3572. onStart(): void;
  3573. /**
  3574. !#en Set frameRate of game.
  3575. !#zh 设置游戏帧率。
  3576. @param frameRate frameRate
  3577. */
  3578. setFrameRate(frameRate: number): void;
  3579. /**
  3580. !#en Run the game frame by frame.
  3581. !#zh 执行一帧游戏循环。
  3582. */
  3583. step(): void;
  3584. /**
  3585. !#en Pause the game main loop. This will pause:
  3586. game logic execution, rendering process, event manager, background music and all audio effects.
  3587. This is different with cc.director.pause which only pause the game logic execution.
  3588. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  3589. */
  3590. pause(): void;
  3591. /**
  3592. !#en Resume the game from pause. This will resume:
  3593. game logic execution, rendering process, event manager, background music and all audio effects.
  3594. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  3595. */
  3596. resume(): void;
  3597. /**
  3598. !#en Check whether the game is paused.
  3599. !#zh 判断游戏是否暂停。
  3600. */
  3601. isPaused(): boolean;
  3602. /**
  3603. !#en Restart game.
  3604. !#zh 重新开始游戏
  3605. */
  3606. restart(): void;
  3607. /**
  3608. !#en End game, it will close the game window
  3609. !#zh 退出游戏
  3610. */
  3611. end(): void;
  3612. /**
  3613. !#en Prepare game.
  3614. !#zh 准备引擎,请不要直接调用这个函数。
  3615. @param cb cb
  3616. */
  3617. prepare(cb: Function): void;
  3618. /**
  3619. !#en Run game with configuration object and onStart function.
  3620. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  3621. @param config Pass configuration object or onStart function
  3622. @param onStart function to be executed after game initialized
  3623. */
  3624. run(config?: any|Function, onStart?: Function): void;
  3625. /**
  3626. !#en
  3627. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  3628. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  3629. !#zh
  3630. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  3631. 目标节点必须位于为层级的根节点,否则无效。
  3632. @param node The node to be made persistent
  3633. */
  3634. addPersistRootNode(node: Node): void;
  3635. /**
  3636. !#en Remove a persistent root node.
  3637. !#zh 取消常驻根节点。
  3638. @param node The node to be removed from persistent node list
  3639. */
  3640. removePersistRootNode(node: Node): void;
  3641. /**
  3642. !#en Check whether the node is a persistent root node.
  3643. !#zh 检查节点是否是常驻根节点。
  3644. @param node The node to be checked
  3645. */
  3646. isPersistRootNode(node: Node): boolean;
  3647. }
  3648. /** !#en
  3649. Class of all entities in Cocos Creator scenes.<br/>
  3650. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  3651. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  3652. !#zh
  3653. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  3654. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  3655. export class Node extends _BaseNode {
  3656. /** !#en
  3657. Group index of node.<br/>
  3658. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3659. !#zh
  3660. 节点的分组索引。<br/>
  3661. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3662. groupIndex: number;
  3663. /** !#en
  3664. Group of node.<br/>
  3665. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3666. !#zh
  3667. 节点的分组。<br/>
  3668. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3669. group: string;
  3670. /** !#en The position (x, y) of the node in its parent's coordinates.
  3671. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  3672. position: Vec2;
  3673. /** !#en x axis position of node.
  3674. !#zh 节点 X 轴坐标。 */
  3675. x: number;
  3676. /** !#en y axis position of node.
  3677. !#zh 节点 Y 轴坐标。 */
  3678. y: number;
  3679. /** !#en Rotation of node.
  3680. !#zh 该节点旋转角度。 */
  3681. rotation: number;
  3682. /** !#en Rotation on x axis.
  3683. !#zh 该节点 X 轴旋转角度。 */
  3684. rotationX: number;
  3685. /** !#en Rotation on y axis.
  3686. !#zh 该节点 Y 轴旋转角度。 */
  3687. rotationY: number;
  3688. /** !#en Scale on x axis.
  3689. !#zh 节点 X 轴缩放。 */
  3690. scaleX: number;
  3691. /** !#en Scale on y axis.
  3692. !#zh 节点 Y 轴缩放。 */
  3693. scaleY: number;
  3694. /** !#en Skew x
  3695. !#zh 该节点 Y 轴倾斜角度。 */
  3696. skewX: number;
  3697. /** !#en Skew y
  3698. !#zh 该节点 X 轴倾斜角度。 */
  3699. skewY: number;
  3700. /** !#en Opacity of node, default value is 255.
  3701. !#zh 节点透明度,默认值为 255。 */
  3702. opacity: number;
  3703. /** !#en Indicate whether node's opacity value affect its child nodes, default value is true.
  3704. !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */
  3705. cascadeOpacity: boolean;
  3706. /** !#en Color of node, default value is white: (255, 255, 255).
  3707. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  3708. color: Color;
  3709. /** !#en Anchor point's position on x axis.
  3710. !#zh 节点 X 轴锚点位置。 */
  3711. anchorX: number;
  3712. /** !#en Anchor point's position on y axis.
  3713. !#zh 节点 Y 轴锚点位置。 */
  3714. anchorY: number;
  3715. /** !#en Width of node.
  3716. !#zh 节点宽度。 */
  3717. width: number;
  3718. /** !#en Height of node.
  3719. !#zh 节点高度。 */
  3720. height: number;
  3721. /** !#en Z order in depth which stands for the drawing order.
  3722. !#zh 该节点渲染排序的 Z 轴深度。 */
  3723. zIndex: number;
  3724. /**
  3725. @param name name
  3726. */
  3727. constructor(name?: string);
  3728. /**
  3729. !#en
  3730. Register a callback of a specific event type on Node.<br/>
  3731. Use this method to register touch or mouse event permit propagation based on scene graph,
  3732. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  3733. It's the recommended way to register touch/mouse event for Node,
  3734. please do not use cc.eventManager directly for Node.
  3735. !#zh
  3736. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  3737. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  3738. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  3739. @param type A string representing the event type to listen for.<br>
  3740. See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events.
  3741. @param callback The callback that will be invoked when the event is dispatched.
  3742. The callback is ignored if it is a duplicate (the callbacks are unique).
  3743. @param target The target (this object) to invoke the callback, can be null
  3744. @param useCapture When set to true, the capture argument prevents callback
  3745. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  3746. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  3747. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  3748. @example
  3749. ```js
  3750. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  3751. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  3752. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  3753. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  3754. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  3755. node.on("anchor-changed", callback, this);
  3756. ```
  3757. */
  3758. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  3759. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  3760. /**
  3761. !#en
  3762. Removes the callback previously registered with the same type, callback, target and or useCapture.
  3763. This method is merely an alias to removeEventListener.
  3764. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  3765. @param type A string representing the event type being removed.
  3766. @param callback The callback to remove.
  3767. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  3768. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  3769. If not specified, useCapture defaults to false. If a callback was registered twice,
  3770. one with capture and one without, each must be removed separately. Removal of a capturing callback
  3771. does not affect a non-capturing version of the same listener, and vice versa.
  3772. @example
  3773. ```js
  3774. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  3775. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  3776. node.off("anchor-changed", callback, this);
  3777. ```
  3778. */
  3779. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  3780. /**
  3781. !#en Removes all callbacks previously registered with the same target.
  3782. !#zh 移除目标上的所有注册事件。
  3783. @param target The target to be searched for all related callbacks
  3784. @example
  3785. ```js
  3786. node.targetOff(target);
  3787. ```
  3788. */
  3789. targetOff(target: any): void;
  3790. /**
  3791. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  3792. 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.
  3793. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3794. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3795. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  3796. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3797. @param recursive Whether to pause node system events on the sub node tree.
  3798. @example
  3799. ```js
  3800. node.pauseSystemEvents(true);
  3801. ```
  3802. */
  3803. pauseSystemEvents(recursive: boolean): void;
  3804. /**
  3805. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  3806. 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.
  3807. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3808. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3809. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  3810. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3811. @param recursive Whether to resume node system events on the sub node tree.
  3812. @example
  3813. ```js
  3814. node.resumeSystemEvents(true);
  3815. ```
  3816. */
  3817. resumeSystemEvents(recursive: boolean): void;
  3818. /**
  3819. !#en
  3820. Executes an action, and returns the action that is executed.<br/>
  3821. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  3822. Calling runAction while the node is not active won't have any effect. <br/>
  3823. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  3824. if you want to modify, when you define action plus.
  3825. !#zh
  3826. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  3827. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  3828. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  3829. @param action action
  3830. @example
  3831. ```js
  3832. var action = cc.scaleTo(0.2, 1, 0.6);
  3833. node.runAction(action);
  3834. node.runAction(action).repeatForever(); // fail
  3835. node.runAction(action.repeatForever()); // right
  3836. ```
  3837. */
  3838. runAction(action: Action): Action;
  3839. /**
  3840. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  3841. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  3842. @example
  3843. ```js
  3844. node.pauseAllActions();
  3845. ```
  3846. */
  3847. pauseAllActions(): void;
  3848. /**
  3849. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  3850. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  3851. @example
  3852. ```js
  3853. node.resumeAllActions();
  3854. ```
  3855. */
  3856. resumeAllActions(): void;
  3857. /**
  3858. !#en Stops and removes all actions from the running action list .
  3859. !#zh 停止并且移除所有正在运行的动作列表。
  3860. @example
  3861. ```js
  3862. node.stopAllActions();
  3863. ```
  3864. */
  3865. stopAllActions(): void;
  3866. /**
  3867. !#en Stops and removes an action from the running action list.
  3868. !#zh 停止并移除指定的动作。
  3869. @param action An action object to be removed.
  3870. @example
  3871. ```js
  3872. var action = cc.scaleTo(0.2, 1, 0.6);
  3873. node.stopAction(action);
  3874. ```
  3875. */
  3876. stopAction(action: Action): void;
  3877. /**
  3878. !#en Removes an action from the running action list by its tag.
  3879. !#zh 停止并且移除指定标签的动作。
  3880. @param tag A tag that indicates the action to be removed.
  3881. @example
  3882. ```js
  3883. node.stopAction(1);
  3884. ```
  3885. */
  3886. stopActionByTag(tag: number): void;
  3887. /**
  3888. !#en Returns an action from the running action list by its tag.
  3889. !#zh 通过标签获取指定动作。
  3890. @param tag tag
  3891. @example
  3892. ```js
  3893. var action = node.getActionByTag(1);
  3894. ```
  3895. */
  3896. getActionByTag(tag: number): Action;
  3897. /**
  3898. !#en
  3899. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  3900. Composable actions are counted as 1 action. Example:<br/>
  3901. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  3902. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  3903. !#zh
  3904. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  3905. 例如:<br/>
  3906. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  3907. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  3908. @example
  3909. ```js
  3910. var count = node.getNumberOfRunningActions();
  3911. cc.log("Running Action Count: " + count);
  3912. ```
  3913. */
  3914. getNumberOfRunningActions(): number;
  3915. /**
  3916. !#en Returns a copy of the position (x, y) of the node in its parent's coordinates.
  3917. !#zh 获取节点在父节点坐标系中的位置(x, y)。
  3918. @example
  3919. ```js
  3920. cc.log("Node Position: " + node.getPosition());
  3921. ```
  3922. */
  3923. getPosition(): Vec2;
  3924. /**
  3925. !#en
  3926. Sets the position (x, y) of the node in its parent's coordinates.<br/>
  3927. Usually we use cc.v2(x, y) to compose cc.Vec2 object.<br/>
  3928. and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object.
  3929. !#zh
  3930. 设置节点在父节点坐标系中的位置。<br/>
  3931. 可以通过两种方式设置坐标点:<br/>
  3932. 1. 传入 2 个数值 x 和 y。<br/>
  3933. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
  3934. @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates
  3935. @param y Y coordinate for position
  3936. @example
  3937. ```js
  3938. node.setPosition(cc.v2(0, 0));
  3939. node.setPosition(0, 0);
  3940. ```
  3941. */
  3942. setPosition(newPosOrX: Vec2|number, y?: number): void;
  3943. /**
  3944. !#en
  3945. Returns the scale factor of the node.
  3946. Assertion will fail when _scaleX != _scaleY.
  3947. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  3948. @example
  3949. ```js
  3950. cc.log("Node Scale: " + node.getScale());
  3951. ```
  3952. */
  3953. getScale(): number;
  3954. /**
  3955. !#en Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time.
  3956. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  3957. @param scaleX scaleX or scale
  3958. @param scaleY scaleY
  3959. @example
  3960. ```js
  3961. node.setScale(cc.v2(1, 1));
  3962. node.setScale(1, 1);
  3963. ```
  3964. */
  3965. setScale(scaleX: number|Vec2, scaleY?: number): void;
  3966. /**
  3967. !#en
  3968. Returns a copy the untransformed size of the node. <br/>
  3969. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3970. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  3971. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  3972. @param ignoreSizeProvider true if you need to get the original size of the node
  3973. @example
  3974. ```js
  3975. cc.log("Content Size: " + node.getContentSize());
  3976. ```
  3977. */
  3978. getContentSize(ignoreSizeProvider?: boolean): Size;
  3979. /**
  3980. !#en
  3981. Sets the untransformed size of the node.<br/>
  3982. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3983. All nodes has a size. Layer and Scene has the same size of the screen.
  3984. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  3985. @param size The untransformed size of the node or The untransformed size's width of the node.
  3986. @param height The untransformed size's height of the node.
  3987. @example
  3988. ```js
  3989. node.setContentSize(cc.size(100, 100));
  3990. node.setContentSize(100, 100);
  3991. ```
  3992. */
  3993. setContentSize(size: Size|number, height?: number): void;
  3994. /**
  3995. !#en
  3996. Set whether color should be changed with the opacity value,
  3997. useless in ccsg.Node, but this function is override in some class to have such behavior.
  3998. !#zh 设置更改透明度时是否修改RGB值,
  3999. @param opacityValue opacityValue
  4000. @example
  4001. ```js
  4002. node.setOpacityModifyRGB(true);
  4003. ```
  4004. */
  4005. setOpacityModifyRGB(opacityValue: boolean): void;
  4006. /**
  4007. !#en Get whether color should be changed with the opacity value.
  4008. !#zh 更改透明度时是否修改RGB值。
  4009. @example
  4010. ```js
  4011. var hasChange = node.isOpacityModifyRGB();
  4012. ```
  4013. */
  4014. isOpacityModifyRGB(): boolean;
  4015. /**
  4016. !#en
  4017. Returns a copy of the anchor point.<br/>
  4018. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  4019. It's like a pin in the node where it is "attached" to its parent. <br/>
  4020. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  4021. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  4022. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  4023. !#zh
  4024. 获取节点锚点,用百分比表示。<br/>
  4025. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  4026. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  4027. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  4028. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  4029. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  4030. @example
  4031. ```js
  4032. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  4033. ```
  4034. */
  4035. getAnchorPoint(): Vec2;
  4036. /**
  4037. !#en
  4038. Sets the anchor point in percent. <br/>
  4039. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  4040. It's like a pin in the node where it is "attached" to its parent. <br/>
  4041. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  4042. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  4043. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  4044. !#zh
  4045. 设置锚点的百分比。<br/>
  4046. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  4047. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  4048. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  4049. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  4050. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  4051. @param point The anchor point of node or The x axis anchor of node.
  4052. @param y The y axis anchor of node.
  4053. @example
  4054. ```js
  4055. node.setAnchorPoint(cc.v2(1, 1));
  4056. node.setAnchorPoint(1, 1);
  4057. ```
  4058. */
  4059. setAnchorPoint(point: Vec2|number, y?: number): void;
  4060. /**
  4061. !#en
  4062. Returns a copy of the anchor point in absolute pixels. <br/>
  4063. you can only read it. If you wish to modify it, use setAnchorPoint.
  4064. !#zh
  4065. 返回锚点的绝对像素位置。<br/>
  4066. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  4067. @example
  4068. ```js
  4069. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  4070. ```
  4071. */
  4072. getAnchorPointInPoints(): Vec2;
  4073. /**
  4074. !#en
  4075. Returns the displayed opacity of Node,
  4076. 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.
  4077. !#zh
  4078. 获取节点显示透明度,
  4079. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  4080. 显示透明度是基于自身透明度和父节点透明度计算的。
  4081. @example
  4082. ```js
  4083. var displayOpacity = node.getDisplayedOpacity();
  4084. ```
  4085. */
  4086. getDisplayedOpacity(): number;
  4087. /**
  4088. !#en
  4089. Returns the displayed color of Node,
  4090. 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.
  4091. !#zh
  4092. 获取节点的显示颜色,
  4093. 显示颜色和颜色之间的不同之处在于当启用级连颜色时,
  4094. 显示颜色是基于自身颜色和父节点颜色计算的。
  4095. @example
  4096. ```js
  4097. var displayColor = node.getDisplayedColor();
  4098. ```
  4099. */
  4100. getDisplayedColor(): Color;
  4101. /**
  4102. !#en
  4103. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4104. The matrix is in Pixels.<br/>
  4105. This method is AR (Anchor Relative).
  4106. !#zh
  4107. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  4108. 这个矩阵以像素为单位。<br/>
  4109. 该方法基于节点坐标。
  4110. @example
  4111. ```js
  4112. var affineTransform = node.getNodeToParentTransformAR();
  4113. ```
  4114. */
  4115. getNodeToParentTransformAR(): AffineTransform;
  4116. /**
  4117. !#en
  4118. Returns a "local" axis aligned bounding box of the node. <br/>
  4119. The returned box is relative only to its parent.
  4120. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  4121. @example
  4122. ```js
  4123. var boundingBox = node.getBoundingBox();
  4124. ```
  4125. */
  4126. getBoundingBox(): Rect;
  4127. /**
  4128. !#en
  4129. Returns a "world" axis aligned bounding box of the node.<br/>
  4130. The bounding box contains self and active children's world bounding box.
  4131. !#zh
  4132. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  4133. 该边框包含自身和已激活的子节点的世界边框。
  4134. @example
  4135. ```js
  4136. var newRect = node.getBoundingBoxToWorld();
  4137. ```
  4138. */
  4139. getBoundingBoxToWorld(): Rect;
  4140. /**
  4141. !#en
  4142. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4143. The matrix is in Pixels.
  4144. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  4145. @example
  4146. ```js
  4147. var affineTransform = node.getNodeToParentTransform();
  4148. ```
  4149. */
  4150. getNodeToParentTransform(): AffineTransform;
  4151. /**
  4152. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  4153. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  4154. @example
  4155. ```js
  4156. var affineTransform = node.getNodeToWorldTransform();
  4157. ```
  4158. */
  4159. getNodeToWorldTransform(): AffineTransform;
  4160. /**
  4161. !#en
  4162. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  4163. This method is AR (Anchor Relative).
  4164. !#zh
  4165. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  4166. 该方法基于节点坐标。
  4167. @example
  4168. ```js
  4169. var mat = node.getNodeToWorldTransformAR();
  4170. ```
  4171. */
  4172. getNodeToWorldTransformAR(): AffineTransform;
  4173. /**
  4174. !#en
  4175. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  4176. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  4177. !#zh
  4178. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  4179. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  4180. @example
  4181. ```js
  4182. var affineTransform = node.getParentToNodeTransform();
  4183. ```
  4184. */
  4185. getParentToNodeTransform(): AffineTransform;
  4186. /**
  4187. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  4188. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  4189. @example
  4190. ```js
  4191. var affineTransform = node.getWorldToNodeTransform();
  4192. ```
  4193. */
  4194. getWorldToNodeTransform(): AffineTransform;
  4195. /**
  4196. !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  4197. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  4198. @param worldPoint worldPoint
  4199. @example
  4200. ```js
  4201. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  4202. ```
  4203. */
  4204. convertToNodeSpace(worldPoint: Vec2): Vec2;
  4205. /**
  4206. !#en Converts a Point to world space coordinates. The result is in Points.
  4207. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  4208. @param nodePoint nodePoint
  4209. @example
  4210. ```js
  4211. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  4212. ```
  4213. */
  4214. convertToWorldSpace(nodePoint: Vec2): Vec2;
  4215. /**
  4216. !#en
  4217. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  4218. treating the returned/received node point as anchor relative.
  4219. !#zh
  4220. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  4221. 返回值将基于节点坐标。
  4222. @param worldPoint worldPoint
  4223. @example
  4224. ```js
  4225. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  4226. ```
  4227. */
  4228. convertToNodeSpaceAR(worldPoint: Vec2): Vec2;
  4229. /**
  4230. !#en
  4231. Converts a local Point to world space coordinates.The result is in Points.<br/>
  4232. treating the returned/received node point as anchor relative.
  4233. !#zh
  4234. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  4235. 返回值将基于世界坐标。
  4236. @param nodePoint nodePoint
  4237. @example
  4238. ```js
  4239. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  4240. ```
  4241. */
  4242. convertToWorldSpaceAR(nodePoint: Vec2): Vec2;
  4243. /**
  4244. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  4245. !#zh 将触摸点转换成本地坐标系中位置。
  4246. @param touch The touch object
  4247. @example
  4248. ```js
  4249. var newVec2 = node.convertTouchToNodeSpace(touch);
  4250. ```
  4251. */
  4252. convertTouchToNodeSpace(touch: Touch): Vec2;
  4253. /**
  4254. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  4255. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  4256. @param touch The touch object
  4257. @example
  4258. ```js
  4259. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  4260. ```
  4261. */
  4262. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  4263. /**
  4264. !#en
  4265. Adds a child to the node with z order and tag.
  4266. !#zh
  4267. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  4268. @param child A child node
  4269. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  4270. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  4271. @example
  4272. ```js
  4273. node.addChild(newNode, 1, 1001);
  4274. ```
  4275. */
  4276. addChild(child: Node, localZOrder?: number, tag?: number|string): void;
  4277. /**
  4278. !#en Stops all running actions and schedulers.
  4279. !#zh 停止所有正在播放的动作和计时器。
  4280. @example
  4281. ```js
  4282. node.cleanup();
  4283. ```
  4284. */
  4285. cleanup(): void;
  4286. /**
  4287. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  4288. normally you won't need to invoke this function.
  4289. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  4290. */
  4291. sortAllChildren(): void;
  4292. /** !#en The local scale relative to the parent.
  4293. !#zh 节点相对父节点的缩放。 */
  4294. scale: number;
  4295. /**
  4296. !#en Returns the x axis position of the node in cocos2d coordinates.
  4297. !#zh 获取节点 X 轴坐标。
  4298. @example
  4299. ```js
  4300. var posX = node.getPositionX();
  4301. ```
  4302. */
  4303. getPositionX(): number;
  4304. /**
  4305. !#en Sets the x axis position of the node in cocos2d coordinates.
  4306. !#zh 设置节点 X 轴坐标。
  4307. @param x x
  4308. @example
  4309. ```js
  4310. node.setPositionX(1);
  4311. ```
  4312. */
  4313. setPositionX(x: number): void;
  4314. /**
  4315. !#en Returns the y axis position of the node in cocos2d coordinates.
  4316. !#zh 获取节点 Y 轴坐标。
  4317. @example
  4318. ```js
  4319. var posY = node.getPositionY();
  4320. ```
  4321. */
  4322. getPositionY(): number;
  4323. /**
  4324. !#en Sets the y axis position of the node in cocos2d coordinates.
  4325. !#zh 设置节点 Y 轴坐标。
  4326. @param y The new position in y axis
  4327. @example
  4328. ```js
  4329. node.setPositionY(100);
  4330. ```
  4331. */
  4332. setPositionY(y: number): void;
  4333. /**
  4334. !#en Returns the local Z order of this node.
  4335. !#zh 获取节点局部 Z 轴顺序。
  4336. @example
  4337. ```js
  4338. var localZorder = node.getLocalZOrder();
  4339. ```
  4340. */
  4341. getLocalZOrder(): number;
  4342. /**
  4343. !#en
  4344. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  4345. <br/>
  4346. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  4347. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  4348. will be in front of the other node in the array. <br/>
  4349. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  4350. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  4351. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  4352. !#zh
  4353. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  4354. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  4355. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  4356. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  4357. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  4358. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  4359. @param localZOrder localZOrder
  4360. @example
  4361. ```js
  4362. node.setLocalZOrder(1);
  4363. ```
  4364. */
  4365. setLocalZOrder(localZOrder: number): void;
  4366. /**
  4367. !#en Returns whether node's opacity value affect its child nodes.
  4368. !#zh 返回节点的不透明度值是否影响其子节点。
  4369. @example
  4370. ```js
  4371. cc.log(node.isCascadeOpacityEnabled());
  4372. ```
  4373. */
  4374. isCascadeOpacityEnabled(): boolean;
  4375. /**
  4376. !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  4377. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  4378. @param cascadeOpacityEnabled cascadeOpacityEnabled
  4379. @example
  4380. ```js
  4381. node.setCascadeOpacityEnabled(true);
  4382. ```
  4383. */
  4384. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  4385. }
  4386. /** !#en
  4387. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  4388. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  4389. !#zh
  4390. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  4391. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  4392. export class Scene extends Node {
  4393. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  4394. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  4395. autoReleaseAssets: boolean;
  4396. }
  4397. /** !#en
  4398. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  4399. You should not use NSTimer. Instead use this class.<br/>
  4400. <br/>
  4401. There are 2 different types of callbacks (selectors):<br/>
  4402. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  4403. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  4404. <br/>
  4405. The 'custom selectors' should be avoided when possible. It is faster,
  4406. and consumes less memory to use the 'update callback'. *
  4407. !#zh
  4408. Scheduler 是负责触发回调函数的类。<br/>
  4409. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  4410. 有两种不同类型的定时器:<br/>
  4411. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  4412. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  4413. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  4414. export class Scheduler {
  4415. /**
  4416. !#en
  4417. Modifies the time of all scheduled callbacks.<br/>
  4418. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  4419. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  4420. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  4421. Note:It will affect EVERY scheduled selector / action.
  4422. !#zh
  4423. 设置时间间隔的缩放比例。<br/>
  4424. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  4425. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  4426. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  4427. 注意:它影响该 Scheduler 下管理的所有定时器。
  4428. @param timeScale timeScale
  4429. */
  4430. setTimeScale(timeScale: number): void;
  4431. /**
  4432. !#en Returns time scale of scheduler.
  4433. !#zh 获取时间间隔的缩放比例。
  4434. */
  4435. getTimeScale(): number;
  4436. /**
  4437. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  4438. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  4439. @param dt delta time
  4440. */
  4441. update(dt: number): void;
  4442. /**
  4443. !#en
  4444. <p>
  4445. The scheduled method will be called every 'interval' seconds.</br>
  4446. If paused is YES, then it won't be called until it is resumed.<br/>
  4447. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  4448. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  4449. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  4450. delay is the amount of time the action will wait before it'll start<br/>
  4451. </p>
  4452. !#zh
  4453. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  4454. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  4455. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  4456. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  4457. 建议使用 scheduleUpdateForTarget 代替。</br>
  4458. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  4459. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  4460. 可以让定时器一直循环触发。<br/>
  4461. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  4462. @param target target
  4463. @param callback_fn callback_fn
  4464. @param interval interval
  4465. @param repeat repeat
  4466. @param delay delay
  4467. @param paused paused
  4468. @example
  4469. ```js
  4470. //register a schedule to scheduler
  4471. var scheduler = cc.director.getScheduler();
  4472. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  4473. ```
  4474. */
  4475. scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4476. scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void;
  4477. /**
  4478. !#en The schedule
  4479. !#zh 定时器
  4480. @param callback callback
  4481. @param target target
  4482. @param interval interval
  4483. @param repeat repeat
  4484. @param delay delay
  4485. @param paused paused
  4486. @example
  4487. ```js
  4488. //register a schedule to scheduler
  4489. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  4490. ```
  4491. */
  4492. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4493. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  4494. /**
  4495. !#en
  4496. Schedules the update callback for a given target,
  4497. the callback will be invoked every frame after schedule started.
  4498. !#zh
  4499. 使用指定的优先级为指定的对象设置 update 定时器。
  4500. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  4501. @param target target
  4502. @param priority priority
  4503. @param paused paused
  4504. @param updateFunc updateFunc
  4505. */
  4506. scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void;
  4507. /**
  4508. !#en
  4509. Unschedules a callback for a callback and a given target.
  4510. If you want to unschedule the "update", use `unscheduleUpdate()`
  4511. !#zh
  4512. 根据指定的回调函数和调用对象。
  4513. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  4514. @param callback The callback to be unscheduled
  4515. @param target The target bound to the callback.
  4516. */
  4517. unschedule(callback: Function, target: any): void;
  4518. /**
  4519. !#en Unschedules the update callback for a given target.
  4520. !#zh 取消指定对象的 update 定时器。
  4521. @param target The target to be unscheduled.
  4522. */
  4523. unscheduleUpdate(target: any): void;
  4524. /**
  4525. !#en
  4526. Unschedules all scheduled callbacks for a given target.
  4527. This also includes the "update" callback.
  4528. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4529. @param target The target to be unscheduled.
  4530. */
  4531. unscheduleAllForTarget(target: any): void;
  4532. /**
  4533. !#en
  4534. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  4535. You should NEVER call this method, unless you know what you are doing.
  4536. !#zh
  4537. 取消所有对象的所有定时器,包括系统定时器。<br/>
  4538. 不用调用此函数,除非你确定你在做什么。
  4539. */
  4540. unscheduleAll(): void;
  4541. /**
  4542. !#en
  4543. Unschedules all callbacks from all targets with a minimum priority.<br/>
  4544. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  4545. !#zh
  4546. 取消所有优先级的值大于指定优先级的定时器。<br/>
  4547. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4548. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  4549. priority is higher than minPriority will be unscheduled.
  4550. */
  4551. unscheduleAllWithMinPriority(minPriority: number): void;
  4552. /**
  4553. !#en Checks whether a callback for a given target is scheduled.
  4554. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  4555. @param callback The callback to check.
  4556. @param target The target of the callback.
  4557. */
  4558. isScheduled(callback: Function, target: any): boolean;
  4559. /**
  4560. !#en
  4561. Pause all selectors from all targets.<br/>
  4562. You should NEVER call this method, unless you know what you are doing.
  4563. !#zh
  4564. 暂停所有对象的所有定时器。<br/>
  4565. 不要调用这个方法,除非你知道你正在做什么。
  4566. */
  4567. pauseAllTargets(): void;
  4568. /**
  4569. !#en
  4570. Pause all selectors from all targets with a minimum priority. <br/>
  4571. You should only call this with kCCPriorityNonSystemMin or higher.
  4572. !#zh
  4573. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  4574. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4575. @param minPriority minPriority
  4576. */
  4577. pauseAllTargetsWithMinPriority(minPriority: number): void;
  4578. /**
  4579. !#en
  4580. Resume selectors on a set of targets.<br/>
  4581. This can be useful for undoing a call to pauseAllCallbacks.
  4582. !#zh
  4583. 恢复指定数组中所有对象的定时器。<br/>
  4584. 这个函数是 pauseAllCallbacks 的逆操作。
  4585. @param targetsToResume targetsToResume
  4586. */
  4587. resumeTargets(targetsToResume: any[]): void;
  4588. /**
  4589. !#en
  4590. Pauses the target.<br/>
  4591. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  4592. If the target is not present, nothing happens.
  4593. !#zh
  4594. 暂停指定对象的定时器。<br/>
  4595. 指定对象的所有定时器都会被暂停。<br/>
  4596. 如果指定的对象没有定时器,什么也不会发生。
  4597. @param target target
  4598. */
  4599. pauseTarget(target: any): void;
  4600. /**
  4601. !#en
  4602. Resumes the target.<br/>
  4603. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  4604. If the target is not present, nothing happens.
  4605. !#zh
  4606. 恢复指定对象的所有定时器。<br/>
  4607. 指定对象的所有定时器将继续工作。<br/>
  4608. 如果指定的对象没有定时器,什么也不会发生。
  4609. @param target target
  4610. */
  4611. resumeTarget(target: any): void;
  4612. /**
  4613. !#en Returns whether or not the target is paused.
  4614. !#zh 返回指定对象的定时器是否暂停了。
  4615. @param target target
  4616. */
  4617. isTargetPaused(target: any): boolean;
  4618. /**
  4619. !#en
  4620. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  4621. The 'update' callback_fn will be called every frame.<br/>
  4622. The lower the priority, the earlier it is called.
  4623. !#zh
  4624. 为指定对象设置 update 定时器。<br/>
  4625. update 定时器每一帧都会被调用。<br/>
  4626. 优先级的值越低,越早被调用。
  4627. @param target target
  4628. @param priority priority
  4629. @param paused paused
  4630. @example
  4631. ```js
  4632. //register this object to scheduler
  4633. var scheduler = cc.director.getScheduler();
  4634. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  4635. ```
  4636. */
  4637. scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void;
  4638. /**
  4639. !#en
  4640. Unschedule a callback function for a given target.<br/>
  4641. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  4642. !#zh
  4643. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  4644. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  4645. @param target target
  4646. @param callback callback[Function] or key[String]
  4647. @example
  4648. ```js
  4649. //unschedule a callback of target
  4650. var scheduler = cc.director.getScheduler();
  4651. scheduler.unscheduleCallbackForTarget(this, callback);
  4652. ```
  4653. */
  4654. unscheduleCallbackForTarget(target: any, callback: Function): void;
  4655. /**
  4656. !#en Unschedules the update callback function for a given target.
  4657. !#zh 取消指定对象的所有定时器。
  4658. @param target target
  4659. @example
  4660. ```js
  4661. //unschedules the "update" method.
  4662. var scheduler = cc.director.getScheduler();
  4663. scheduler.unscheduleUpdateForTarget(this);
  4664. ```
  4665. */
  4666. unscheduleUpdateForTarget(target: any): void;
  4667. /**
  4668. !#en
  4669. Unschedules all function callbacks for a given target.<br/>
  4670. This also includes the "update" callback function.
  4671. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4672. @param target target
  4673. */
  4674. unscheduleAllCallbacksForTarget(target: any): void;
  4675. /**
  4676. !#en
  4677. Unschedules all function callbacks from all targets. <br/>
  4678. You should NEVER call this method, unless you know what you are doing.
  4679. !#zh
  4680. 取消所有对象的所有定时器。<br/>
  4681. 不要调用这个方法,除非你知道你正在做什么。
  4682. */
  4683. unscheduleAllCallbacks(): void;
  4684. /**
  4685. !#en
  4686. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  4687. You should only call this with kCCPriorityNonSystemMin or higher.
  4688. !#zh
  4689. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  4690. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4691. @param minPriority minPriority
  4692. */
  4693. unscheduleAllCallbacksWithMinPriority(minPriority: number): void;
  4694. /** !#en Priority level reserved for system services.
  4695. !#zh 系统服务的优先级。 */
  4696. static PRIORITY_SYSTEM: number;
  4697. /** !#en Minimum priority level for user scheduling.
  4698. !#zh 用户调度最低优先级。 */
  4699. static PRIORITY_NON_SYSTEM: number;
  4700. }
  4701. /** Particle System base class. <br/>
  4702. Attributes of a Particle System:<br/>
  4703. - emmision rate of the particles<br/>
  4704. - Gravity Mode (Mode A): <br/>
  4705. - gravity <br/>
  4706. - direction <br/>
  4707. - speed +- variance <br/>
  4708. - tangential acceleration +- variance<br/>
  4709. - radial acceleration +- variance<br/>
  4710. - Radius Mode (Mode B): <br/>
  4711. - startRadius +- variance <br/>
  4712. - endRadius +- variance <br/>
  4713. - rotate +- variance <br/>
  4714. - Properties common to all modes: <br/>
  4715. - life +- life variance <br/>
  4716. - start spin +- variance <br/>
  4717. - end spin +- variance <br/>
  4718. - start size +- variance <br/>
  4719. - end size +- variance <br/>
  4720. - start color +- variance <br/>
  4721. - end color +- variance <br/>
  4722. - life +- variance <br/>
  4723. - blending function <br/>
  4724. - texture <br/>
  4725. <br/>
  4726. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  4727. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  4728. cocos2d uses a another approach, but the results are almost identical.<br/>
  4729. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  4730. - spinning particles (supported when using ParticleSystem) <br/>
  4731. - tangential acceleration (Gravity mode) <br/>
  4732. - radial acceleration (Gravity mode) <br/>
  4733. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  4734. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  4735. export class ParticleSystem extends _RendererUnderSG {
  4736. /** !#en Play particle in edit mode.
  4737. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  4738. preview: boolean;
  4739. /** !#en
  4740. If set custom to true, then use custom properties insteadof read particle file.
  4741. !#zh 是否自定义粒子属性。 */
  4742. custom: boolean;
  4743. /** !#en The plist file.
  4744. !#zh plist 格式的粒子配置文件。 */
  4745. file: string;
  4746. /** . */
  4747. texture: Texture2D;
  4748. /** !#en Current quantity of particles that are being simulated.
  4749. !#zh 当前播放的粒子数量。 */
  4750. particleCount: number;
  4751. /** !#en Specify the source Blend Factor.
  4752. !#zh 指定原图混合模式。 */
  4753. srcBlendFactor: BlendFactor;
  4754. /** !#en Specify the destination Blend Factor.
  4755. !#zh 指定目标的混合模式。 */
  4756. dstBlendFactor: BlendFactor;
  4757. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  4758. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  4759. playOnLoad: boolean;
  4760. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  4761. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  4762. autoRemoveOnFinish: boolean;
  4763. /** !#en Indicate whether the particle system is activated.
  4764. !#zh 是否激活粒子。 */
  4765. active: boolean;
  4766. /** !#en Maximum particles of the system.
  4767. !#zh 粒子最大数量。 */
  4768. totalParticles: number;
  4769. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  4770. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  4771. duration: number;
  4772. /** !#en Emission rate of the particles.
  4773. !#zh 每秒发射的粒子数目。 */
  4774. emissionRate: number;
  4775. /** !#en Life of each particle setter.
  4776. !#zh 粒子的运行时间。 */
  4777. life: number;
  4778. /** !#en Variation of life.
  4779. !#zh 粒子的运行时间变化范围。 */
  4780. lifeVar: number;
  4781. /** !#en Start color of each particle.
  4782. !#zh 粒子初始颜色。 */
  4783. startColor: Color;
  4784. /** !#en Variation of the start color.
  4785. !#zh 粒子初始颜色变化范围。 */
  4786. startColorVar: Color;
  4787. /** !#en Ending color of each particle.
  4788. !#zh 粒子结束颜色。 */
  4789. endColor: Color;
  4790. /** !#en Variation of the end color.
  4791. !#zh 粒子结束颜色变化范围。 */
  4792. endColorVar: Color;
  4793. /** !#en Angle of each particle setter.
  4794. !#zh 粒子角度。 */
  4795. angle: number;
  4796. /** !#en Variation of angle of each particle setter.
  4797. !#zh 粒子角度变化范围。 */
  4798. angleVar: number;
  4799. /** !#en Start size in pixels of each particle.
  4800. !#zh 粒子的初始大小。 */
  4801. startSize: number;
  4802. /** !#en Variation of start size in pixels.
  4803. !#zh 粒子初始大小的变化范围。 */
  4804. startSizeVar: number;
  4805. /** !#en End size in pixels of each particle.
  4806. !#zh 粒子结束时的大小。 */
  4807. endSize: number;
  4808. /** !#en Variation of end size in pixels.
  4809. !#zh 粒子结束大小的变化范围。 */
  4810. endSizeVar: number;
  4811. /** !#en Start angle of each particle.
  4812. !#zh 粒子开始自旋角度。 */
  4813. startSpin: number;
  4814. /** !#en Variation of start angle.
  4815. !#zh 粒子开始自旋角度变化范围。 */
  4816. startSpinVar: number;
  4817. /** !#en End angle of each particle.
  4818. !#zh 粒子结束自旋角度。 */
  4819. endSpin: number;
  4820. /** !#en Variation of end angle.
  4821. !#zh 粒子结束自旋角度变化范围。 */
  4822. endSpinVar: number;
  4823. /** !#en Source position of the emitter.
  4824. !#zh 发射器位置。 */
  4825. sourcePos: Vec2;
  4826. /** !#en Variation of source position.
  4827. !#zh 发射器位置的变化范围。(横向和纵向) */
  4828. posVar: Vec2;
  4829. /** !#en Particles movement type.
  4830. !#zh 粒子位置类型。 */
  4831. positionType: ParticleSystem.PositionType;
  4832. /** !#en Particles emitter modes.
  4833. !#zh 发射器类型。 */
  4834. emitterMode: ParticleSystem.EmitterMode;
  4835. /** !#en Gravity of the emitter.
  4836. !#zh 重力。 */
  4837. gravity: Vec2;
  4838. /** !#en Speed of the emitter.
  4839. !#zh 速度。 */
  4840. speed: number;
  4841. /** !#en Variation of the speed.
  4842. !#zh 速度变化范围。 */
  4843. speedVar: number;
  4844. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  4845. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  4846. tangentialAccel: number;
  4847. /** !#en Variation of the tangential acceleration.
  4848. !#zh 每个粒子的切向加速度变化范围。 */
  4849. tangentialAccelVar: number;
  4850. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  4851. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  4852. radialAccel: number;
  4853. /** !#en Variation of the radial acceleration.
  4854. !#zh 粒子径向加速度变化范围。 */
  4855. radialAccelVar: number;
  4856. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  4857. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  4858. rotationIsDir: boolean;
  4859. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  4860. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  4861. startRadius: number;
  4862. /** !#en Variation of the starting radius.
  4863. !#zh 初始半径变化范围。 */
  4864. startRadiusVar: number;
  4865. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  4866. !#zh 结束半径,只有在半径模式下可用。 */
  4867. endRadius: number;
  4868. /** !#en Variation of the ending radius.
  4869. !#zh 结束半径变化范围。 */
  4870. endRadiusVar: number;
  4871. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  4872. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  4873. rotatePerS: number;
  4874. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  4875. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  4876. rotatePerSVar: number;
  4877. /** !#en The Particle emitter lives forever.
  4878. !#zh 表示发射器永久存在 */
  4879. static DURATION_INFINITY: number;
  4880. /** !#en The starting size of the particle is equal to the ending size.
  4881. !#zh 表示粒子的起始大小等于结束大小。 */
  4882. static START_SIZE_EQUAL_TO_END_SIZE: number;
  4883. /** !#en The starting radius of the particle is equal to the ending radius.
  4884. !#zh 表示粒子的起始半径等于结束半径。 */
  4885. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  4886. /**
  4887. !#en Add a particle to the emitter.
  4888. !#zh 添加一个粒子到发射器中。
  4889. */
  4890. addParticle(): boolean;
  4891. /**
  4892. !#en Stop emitting particles. Running particles will continue to run until they die.
  4893. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  4894. @example
  4895. ```js
  4896. // stop particle system.
  4897. myParticleSystem.stopSystem();
  4898. ```
  4899. */
  4900. stopSystem(): void;
  4901. /**
  4902. !#en Kill all living particles.
  4903. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  4904. @example
  4905. ```js
  4906. // play particle system.
  4907. myParticleSystem.resetSystem();
  4908. ```
  4909. */
  4910. resetSystem(): void;
  4911. /**
  4912. !#en Whether or not the system is full.
  4913. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  4914. */
  4915. isFull(): boolean;
  4916. /**
  4917. !#en
  4918. <p> Sets a new CCSpriteFrame as particle.</br>
  4919. WARNING: this method is experimental. Use setTextureWithRect instead.
  4920. </p>
  4921. !#zh
  4922. <p> 设置一个新的精灵帧为粒子。</br>
  4923. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  4924. </p>
  4925. @param spriteFrame spriteFrame
  4926. */
  4927. setDisplayFrame(spriteFrame: SpriteFrame): void;
  4928. /**
  4929. !#en Sets a new texture with a rect. The rect is in texture position and size.
  4930. !#zh 设置一张新贴图和关联的矩形。
  4931. @param texture texture
  4932. @param rect rect
  4933. */
  4934. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  4935. }
  4936. /** !#en Renders the TMX object.
  4937. !#zh 渲染 tmx object。 */
  4938. export class TMXObject {
  4939. /**
  4940. !#en Get the name of object
  4941. !#zh 获取对象的名称
  4942. */
  4943. getObjectName(): string;
  4944. /**
  4945. !#en Get the property of object
  4946. !#zh 获取对象的属性
  4947. @param propertyName propertyName
  4948. */
  4949. getProperty(propertyName: string): any;
  4950. /**
  4951. !#en Get the properties of object
  4952. !#zh 获取对象的属性
  4953. */
  4954. getProperties(): any;
  4955. /**
  4956. !#en Set the object name
  4957. !#zh 设置对象名称
  4958. @param name name
  4959. */
  4960. setObjectName(name: string): void;
  4961. /**
  4962. !#en Set the properties of the object
  4963. !#zh 设置对象的属性
  4964. @param props props
  4965. */
  4966. setProperties(props: any): void;
  4967. }
  4968. /** !#en Render the TMX layer.
  4969. !#zh 渲染 TMX layer。 */
  4970. export class TiledLayer extends _SGComponent {
  4971. /**
  4972. !#en Gets the layer name.
  4973. !#zh 获取层的名称。
  4974. @example
  4975. ```js
  4976. var layerName = tiledLayer.getLayerName();
  4977. cc.log(layerName);
  4978. ```
  4979. */
  4980. getLayerName(): string;
  4981. /**
  4982. !#en Set the layer name.
  4983. !#zh 设置层的名称
  4984. @param layerName layerName
  4985. @example
  4986. ```js
  4987. tiledLayer.setLayerName("New Layer");
  4988. ```
  4989. */
  4990. SetLayerName(layerName: string): void;
  4991. /**
  4992. !#en Return the value for the specific property name.
  4993. !#zh 获取指定属性名的值。
  4994. @param propertyName propertyName
  4995. @example
  4996. ```js
  4997. var property = tiledLayer.getProperty("info");
  4998. cc.log(property);
  4999. ```
  5000. */
  5001. getProperty(propertyName: string): any;
  5002. /**
  5003. !#en Returns the position in pixels of a given tile coordinate.
  5004. !#zh 获取指定 tile 的像素坐标。
  5005. @param pos position or x
  5006. @param y y
  5007. @example
  5008. ```js
  5009. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  5010. cc.log("Pos: " + pos);
  5011. var pos = tiledLayer.getPositionAt(0, 0);
  5012. cc.log("Pos: " + pos);
  5013. ```
  5014. */
  5015. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  5016. /**
  5017. !#en Removes a tile at given tile coordinate.
  5018. !#zh 删除指定坐标上的 tile。
  5019. @param pos position or x
  5020. @param y y
  5021. @example
  5022. ```js
  5023. tiledLayer.removeTileAt(cc.v2(0, 0));
  5024. tiledLayer.removeTileAt(0, 0);
  5025. ```
  5026. */
  5027. removeTileAt(pos: Vec2|number, y?: number): void;
  5028. /**
  5029. !#en
  5030. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  5031. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  5032. If a tile is already placed at that position, then it will be removed.
  5033. !#zh
  5034. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  5035. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  5036. 如果一个 tile 已经放在那个位置,那么它将被删除。
  5037. @param gid gid
  5038. @param posOrX position or x
  5039. @param flagsOrY flags or y
  5040. @param flags flags
  5041. @example
  5042. ```js
  5043. tiledLayer.setTileGID(1001, 10, 10, 1)
  5044. ```
  5045. */
  5046. setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  5047. /**
  5048. !#en
  5049. Returns the tile gid at a given tile coordinate. <br />
  5050. if it returns 0, it means that the tile is empty. <br />
  5051. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  5052. !#zh
  5053. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  5054. 如果它返回 0,则表示该 tile 为空。<br />
  5055. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  5056. @param pos or x
  5057. @param y y
  5058. @example
  5059. ```js
  5060. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  5061. ```
  5062. */
  5063. getTileGIDAt(pos: Vec2|number, y?: number): number;
  5064. /**
  5065. !#en
  5066. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  5067. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  5068. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  5069. You can remove either by calling: <br/>
  5070. - layer.removeChild(sprite, cleanup); <br/>
  5071. - or layer.removeTileAt(ccp(x,y));
  5072. !#zh
  5073. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  5074. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  5075. 你可以通过调用以下方法来对它进行删除:<br/>
  5076. 1. layer.removeChild(sprite, cleanup);<br/>
  5077. 2. 或 layer.removeTileAt(cc.v2(x,y));
  5078. @param pos or x
  5079. @param y y
  5080. @example
  5081. ```js
  5082. var title = tiledLayer.getTileAt(100, 100);
  5083. cc.log(title);
  5084. ```
  5085. */
  5086. getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite;
  5087. /**
  5088. !#en
  5089. Dealloc the map that contains the tile position from memory. <br />
  5090. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  5091. If you are going to call layer.getTileGIDAt() then, don't release the map.
  5092. !#zh
  5093. 从内存中释放包含 tile 位置信息的地图。<br />
  5094. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  5095. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  5096. @example
  5097. ```js
  5098. tiledLayer.releaseMap();
  5099. ```
  5100. */
  5101. releaseMap(): void;
  5102. /**
  5103. !#en Sets the untransformed size of the _ccsg.TMXLayer.
  5104. !#zh 设置未转换的 layer 大小。
  5105. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  5106. @param height The untransformed size's height of the _ccsg.TMXLayer.
  5107. @example
  5108. ```js
  5109. tiledLayer.setContentSize(100, 100);
  5110. ```
  5111. */
  5112. setContentSize(size: Size|number, height?: number): void;
  5113. /**
  5114. !#en Return texture of cc.SpriteBatchNode.
  5115. !#zh 获取纹理。
  5116. @example
  5117. ```js
  5118. var texture = tiledLayer.getTexture();
  5119. cc.log("Texture: " + texture);
  5120. ```
  5121. */
  5122. getTexture(): Texture2D;
  5123. /**
  5124. !#en Set the texture of cc.SpriteBatchNode.
  5125. !#zh 设置纹理。
  5126. @param texture texture
  5127. @example
  5128. ```js
  5129. tiledLayer.setTexture(texture);
  5130. ```
  5131. */
  5132. setTexture(texture: Texture2D): void;
  5133. /**
  5134. !#en Set the opacity of all tiles
  5135. !#zh 设置所有 Tile 的透明度
  5136. @param opacity opacity
  5137. @example
  5138. ```js
  5139. tiledLayer.setTileOpacity(128);
  5140. ```
  5141. */
  5142. setTileOpacity(opacity: number): void;
  5143. /**
  5144. !#en Gets layer size.
  5145. !#zh 获得层大小。
  5146. @example
  5147. ```js
  5148. var size = tiledLayer.getLayerSize();
  5149. cc.log("layer size: " + size);
  5150. ```
  5151. */
  5152. getLayerSize(): Size;
  5153. /**
  5154. !#en Set layer size.
  5155. !#zh 设置层大小。
  5156. @param layerSize layerSize
  5157. @example
  5158. ```js
  5159. tiledLayer.setLayerSize(new cc.size(5, 5));
  5160. ```
  5161. */
  5162. setLayerSize(layerSize: Size): void;
  5163. /**
  5164. !#en Size of the map's tile (could be different from the tile's size).
  5165. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  5166. @example
  5167. ```js
  5168. var mapTileSize = tiledLayer.getMapTileSize();
  5169. cc.log("MapTile size: " + mapTileSize);
  5170. ```
  5171. */
  5172. getMapTileSize(): Size;
  5173. /**
  5174. !#en Set the map tile size.
  5175. !#zh 设置 tile 的大小。
  5176. @param tileSize tileSize
  5177. @example
  5178. ```js
  5179. tiledLayer.setMapTileSize(new cc.size(10, 10));
  5180. ```
  5181. */
  5182. setMapTileSize(tileSize: Size): void;
  5183. /**
  5184. !#en Pointer to the map of tiles.
  5185. !#zh 获取地图 tiles。
  5186. @example
  5187. ```js
  5188. var tiles = tiledLayer.getTiles();
  5189. ```
  5190. */
  5191. getTiles(): any[];
  5192. /**
  5193. !#en Pointer to the map of tiles.
  5194. !#zh 设置地图 tiles
  5195. @param tiles tiles
  5196. @example
  5197. ```js
  5198. tiledLayer.setTiles(tiles);
  5199. ```
  5200. */
  5201. setTiles(tiles: any[]): void;
  5202. /**
  5203. !#en Tile set information for the layer.
  5204. !#zh 获取 layer 的 Tileset 信息。
  5205. @example
  5206. ```js
  5207. var tileset = tiledLayer.getTileSet();
  5208. ```
  5209. */
  5210. getTileSet(): TMXTilesetInfo;
  5211. /**
  5212. !#en Tile set information for the layer.
  5213. !#zh 设置 layer 的 Tileset 信息。
  5214. @param tileset tileset
  5215. @example
  5216. ```js
  5217. tiledLayer.setTileSet(tileset);
  5218. ```
  5219. */
  5220. setTileSet(tileset: TMXTilesetInfo): void;
  5221. /**
  5222. !#en Layer orientation, which is the same as the map orientation.
  5223. !#zh 获取 Layer 方向(同地图方向)。
  5224. @example
  5225. ```js
  5226. var orientation = tiledLayer.getLayerOrientation();
  5227. cc.log("Layer Orientation: " + orientation);
  5228. ```
  5229. */
  5230. getLayerOrientation(): number;
  5231. /**
  5232. !#en Layer orientation, which is the same as the map orientation.
  5233. !#zh 设置 Layer 方向(同地图方向)。
  5234. @param orientation orientation
  5235. @example
  5236. ```js
  5237. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  5238. ```
  5239. */
  5240. setLayerOrientation(orientation: TiledMap.Orientation): void;
  5241. /**
  5242. !#en properties from the layer. They can be added using Tiled.
  5243. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  5244. @example
  5245. ```js
  5246. var properties = tiledLayer.getProperties();
  5247. cc.log("Properties: " + properties);
  5248. ```
  5249. */
  5250. getProperties(): any[];
  5251. /**
  5252. !#en properties from the layer. They can be added using Tiled.
  5253. !#zh 设置层属性。
  5254. @param properties properties
  5255. @example
  5256. ```js
  5257. tiledLayer.setLayerOrientation(properties);
  5258. ```
  5259. */
  5260. setProperties(properties: any[]): void;
  5261. }
  5262. /** !#en Renders a TMX Tile Map in the scene.
  5263. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  5264. export class TiledMap extends Component {
  5265. /** !#en The TiledMap Asset.
  5266. !#zh TiledMap 资源。 */
  5267. tmxAsset: TiledMapAsset;
  5268. /**
  5269. !#en Gets the map size.
  5270. !#zh 获取地图大小。
  5271. @example
  5272. ```js
  5273. var mapSize = tiledMap.getMapSize();
  5274. cc.log("Map Size: " + mapSize);
  5275. ```
  5276. */
  5277. getMapSize(): Size;
  5278. /**
  5279. !#en Set the map size.
  5280. !#zh 设置地图大小。
  5281. @param mapSize mapSize
  5282. @example
  5283. ```js
  5284. tiledMap.setMapSize(new cc.size(960, 640));
  5285. ```
  5286. */
  5287. setMapSize(mapSize: Size): void;
  5288. /**
  5289. !#en Gets the tile size.
  5290. !#zh 获取地图背景中 tile 元素的大小。
  5291. @example
  5292. ```js
  5293. var tileSize = tiledMap.getTileSize();
  5294. cc.log("Tile Size: " + tileSize);
  5295. ```
  5296. */
  5297. getTileSize(): Size;
  5298. /**
  5299. !#en Set the tile size.
  5300. !#zh 设置地图背景中 tile 元素的大小。
  5301. @param tileSize tileSize
  5302. @example
  5303. ```js
  5304. tiledMap.setTileSize(new cc.size(10, 10));
  5305. ```
  5306. */
  5307. setTileSize(tileSize: Size): void;
  5308. /**
  5309. !#en map orientation.
  5310. !#zh 获取地图方向。
  5311. @example
  5312. ```js
  5313. var mapOrientation = tiledMap.getMapOrientation();
  5314. cc.log("Map Orientation: " + mapOrientation);
  5315. ```
  5316. */
  5317. getMapOrientation(): number;
  5318. /**
  5319. !#en map orientation.
  5320. !#zh 设置地图方向。
  5321. @param orientation orientation
  5322. @example
  5323. ```js
  5324. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  5325. ```
  5326. */
  5327. setMapOrientation(orientation: TiledMap.Orientation): void;
  5328. /**
  5329. !#en object groups.
  5330. !#zh 获取所有的对象层。
  5331. @example
  5332. ```js
  5333. var objGroups = titledMap.getObjectGroups();
  5334. for (var i = 0; i < objGroups.length; ++i) {
  5335. cc.log("obj: " + objGroups[i]);
  5336. }
  5337. ```
  5338. */
  5339. getObjectGroups(): TiledObjectGroup[];
  5340. /**
  5341. !#en Gets the map properties.
  5342. !#zh 获取地图的属性。
  5343. @example
  5344. ```js
  5345. var properties = titledMap.getProperties();
  5346. for (var i = 0; i < properties.length; ++i) {
  5347. cc.log("Properties: " + properties[i]);
  5348. }
  5349. ```
  5350. */
  5351. getProperties(): any[];
  5352. /**
  5353. !#en Set the map properties.
  5354. !#zh 设置地图的属性。
  5355. @param properties properties
  5356. @example
  5357. ```js
  5358. titledMap.setProperties(properties);
  5359. ```
  5360. */
  5361. setProperties(properties: any[]): void;
  5362. /**
  5363. !#en Return All layers array.
  5364. !#zh 返回包含所有 layer 的数组。
  5365. @example
  5366. ```js
  5367. var layers = titledMap.allLayers();
  5368. for (var i = 0; i < layers.length; ++i) {
  5369. cc.log("Layers: " + layers[i]);
  5370. }
  5371. ```
  5372. */
  5373. allLayers(): TiledLayer[];
  5374. /**
  5375. !#en return the cc.TiledLayer for the specific layer.
  5376. !#zh 获取指定名称的 layer。
  5377. @param layerName layerName
  5378. @example
  5379. ```js
  5380. var layer = titledMap.getLayer("Player");
  5381. cc.log(layer);
  5382. ```
  5383. */
  5384. getLayer(layerName: string): TiledLayer;
  5385. /**
  5386. !#en Return the TMXObjectGroup for the specific group.
  5387. !#zh 获取指定的 TMXObjectGroup。
  5388. @param groupName groupName
  5389. @example
  5390. ```js
  5391. var group = titledMap.getObjectGroup("Players");
  5392. cc.log("ObjectGroup: " + group);
  5393. ```
  5394. */
  5395. getObjectGroup(groupName: string): TiledObjectGroup;
  5396. /**
  5397. !#en Return the value for the specific property name.
  5398. !#zh 通过属性名称,获取指定的属性。
  5399. @param propertyName propertyName
  5400. @example
  5401. ```js
  5402. var property = titledMap.getProperty("info");
  5403. cc.log("Property: " + property);
  5404. ```
  5405. */
  5406. getProperty(propertyName: string): string;
  5407. /**
  5408. !#en Return properties dictionary for tile GID.
  5409. !#zh 通过 GID ,获取指定的属性。
  5410. @param GID GID
  5411. @example
  5412. ```js
  5413. var properties = titledMap.getPropertiesForGID(GID);
  5414. cc.log("Properties: " + properties);
  5415. ```
  5416. */
  5417. getPropertiesForGID(GID: number): any;
  5418. }
  5419. /** Class for tiled map asset handling. */
  5420. export class TiledMapAsset extends Asset {
  5421. textures: Texture2D[];
  5422. textureNames: string[];
  5423. }
  5424. /** !#en Renders the TMX object group.
  5425. !#zh 渲染 tmx object group。 */
  5426. export class TiledObjectGroup extends _SGComponent {
  5427. /**
  5428. !#en Offset position of child objects.
  5429. !#zh 获取子对象的偏移位置。
  5430. @example
  5431. ```js
  5432. var offset = tMXObjectGroup.getPositionOffset();
  5433. ```
  5434. */
  5435. getPositionOffset(): Vec2;
  5436. /**
  5437. !#en Offset position of child objects.
  5438. !#zh 设置子对象的偏移位置。
  5439. @param offset offset
  5440. @example
  5441. ```js
  5442. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  5443. ```
  5444. */
  5445. setPositionOffset(offset: Vec2): void;
  5446. /**
  5447. !#en List of properties stored in a dictionary.
  5448. !#zh 以映射的形式获取属性列表。
  5449. @example
  5450. ```js
  5451. var offset = tMXObjectGroup.getProperties();
  5452. ```
  5453. */
  5454. getProperties(): any;
  5455. /**
  5456. !#en Set the properties of the object group.
  5457. !#zh 设置属性列表。
  5458. @param Var Var
  5459. @example
  5460. ```js
  5461. tMXObjectGroup.setProperties(obj);
  5462. ```
  5463. */
  5464. setProperties(Var: any): void;
  5465. /**
  5466. !#en Gets the Group name.
  5467. !#zh 获取组名称。
  5468. @example
  5469. ```js
  5470. var groupName = tMXObjectGroup.getGroupName;
  5471. ```
  5472. */
  5473. getGroupName(): string;
  5474. /**
  5475. !#en Set the Group name.
  5476. !#zh 设置组名称。
  5477. @param groupName groupName
  5478. @example
  5479. ```js
  5480. tMXObjectGroup.setGroupName("New Group");
  5481. ```
  5482. */
  5483. setGroupName(groupName: string): void;
  5484. /**
  5485. !#en
  5486. Return the object for the specific object name. <br />
  5487. It will return the 1st object found on the array for the given name.
  5488. !#zh 获取指定的对象。
  5489. @param objectName objectName
  5490. @example
  5491. ```js
  5492. var object = tMXObjectGroup.getObject("Group");
  5493. ```
  5494. */
  5495. getObject(objectName: string): any;
  5496. /**
  5497. !#en Gets the objects.
  5498. !#zh 获取对象数组。
  5499. @example
  5500. ```js
  5501. var objects = tMXObjectGroup.getObjects();
  5502. ```
  5503. */
  5504. getObjects(): any[];
  5505. }
  5506. /** !#en
  5507. Camera is usefull when making reel game or other games which need scroll screen.
  5508. Using camera will be more efficient than moving node to scroll screen.
  5509. Camera
  5510. !#zh
  5511. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5512. export class Camera extends _RendererUnderSG {
  5513. /** !#en
  5514. The camera zoom ratio.
  5515. !#zh
  5516. 摄像机缩放比率 */
  5517. zoomRatio: number;
  5518. /** !#en
  5519. Current active camera, the scene should only have one active camera at the same time.
  5520. !#zh
  5521. 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */
  5522. static main: Camera;
  5523. /**
  5524. !#en
  5525. Add the specified target to camera.
  5526. !#zh
  5527. 将指定的节点添加到摄像机中。
  5528. @param target target
  5529. */
  5530. addTarget(target: Node): void;
  5531. /**
  5532. !#en
  5533. Remove the specified target from camera.
  5534. !#zh
  5535. 将指定的节点从摄像机中移除。
  5536. @param target target
  5537. */
  5538. removeTarget(target: Node): void;
  5539. /**
  5540. !#en
  5541. Get all camera targets.
  5542. !#zh
  5543. 获取所有摄像机目标节点。
  5544. */
  5545. getTargets(): [Node];
  5546. /**
  5547. !#en
  5548. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5549. !#zh
  5550. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5551. @param node the node which should transform
  5552. */
  5553. getNodeToCameraTransform(node: Node): AffineTransform;
  5554. /**
  5555. !#en
  5556. Conver a camera coordinates point to world coordinates.
  5557. !#zh
  5558. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5559. @param point the point which should transform
  5560. */
  5561. getCameraToWorldPoint(point: Node): Vec2;
  5562. /**
  5563. !#en
  5564. Check whether the node is in the camera.
  5565. !#zh
  5566. 检测节点是否被此摄像机影响
  5567. @param node the node which need to check
  5568. */
  5569. containsNode(node: Node): boolean;
  5570. }
  5571. /** !#en
  5572. Base class for handling assets used in Creator.<br/>
  5573. You may want to override:<br/>
  5574. - createNode<br/>
  5575. - getset functions of _nativeAsset<br/>
  5576. - cc.Object._serialize<br/>
  5577. - cc.Object._deserialize<br/>
  5578. !#zh
  5579. Creator 中的资源基类。<br/>
  5580. 您可能需要重写:<br/>
  5581. - createNode <br/>
  5582. - _nativeAsset 的 getset 方法<br/>
  5583. - cc.Object._serialize<br/>
  5584. - cc.Object._deserialize<br/> */
  5585. export class Asset extends RawAsset {
  5586. /** !#en
  5587. Whether the asset is loaded or not
  5588. !#zh
  5589. 该资源是否已经成功加载 */
  5590. loaded: boolean;
  5591. /** !#en
  5592. Returns the url of this asset's native object, if none it will returns an empty string.
  5593. !#zh
  5594. 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
  5595. nativeUrl: string;
  5596. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  5597. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  5598. static preventDeferredLoadDependents: boolean;
  5599. /** !#en Indicates whether its native object should be preloaded from native url.
  5600. !#zh 禁止预加载原生对象。 */
  5601. static preventPreloadNativeObject: boolean;
  5602. /**
  5603. Returns the asset's url.
  5604. The `Asset` object overrides the `toString()` method of the `Object` object.
  5605. For `Asset` objects, the toString() method returns a string representation of the object.
  5606. 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.
  5607. */
  5608. toString(): string;
  5609. /**
  5610. !#en
  5611. Create a new node using this asset in the scene.<br/>
  5612. If this type of asset dont have its corresponding node type, this method should be null.
  5613. !#zh
  5614. 使用该资源在场景中创建一个新节点。<br/>
  5615. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5616. @param callback callback
  5617. */
  5618. createNode(callback: (error: string, node: any) => void): void;
  5619. }
  5620. /** !#en Class for audio data handling.
  5621. !#zh 音频资源类。 */
  5622. export class AudioClip extends Asset implements EventTarget {
  5623. /**
  5624. !#en
  5625. Register an callback of a specific event type on the EventTarget.
  5626. !#zh
  5627. 注册事件目标的特定事件类型回调。
  5628. @param type A string representing the event type to listen for.
  5629. @param callback The callback that will be invoked when the event is dispatched.
  5630. The callback is ignored if it is a duplicate (the callbacks are unique).
  5631. @param target The target (this object) to invoke the callback, can be null
  5632. @param useCapture When set to true, the capture argument prevents callback
  5633. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5634. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5635. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5636. @example
  5637. ```js
  5638. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5639. cc.log("this is callback");
  5640. }, node);
  5641. ```
  5642. */
  5643. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5644. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5645. /**
  5646. !#en
  5647. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5648. if only type is passed as parameter, all listeners registered with that type will be removed.
  5649. !#zh
  5650. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5651. @param type A string representing the event type being removed.
  5652. @param callback The callback to remove.
  5653. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5654. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5655. If not specified, useCapture defaults to false. If a callback was registered twice,
  5656. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5657. does not affect a non-capturing version of the same listener, and vice versa.
  5658. @example
  5659. ```js
  5660. // register touchEnd eventListener
  5661. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5662. cc.log("this is callback");
  5663. }, node);
  5664. // remove touch end event listener
  5665. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5666. // remove all touch end event listeners
  5667. node.off(cc.Node.EventType.TOUCH_END);
  5668. ```
  5669. */
  5670. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5671. /**
  5672. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5673. This is not for removing all listeners in the current event target,
  5674. and this is not for removing all listeners the target parameter have registered.
  5675. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5676. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5677. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5678. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5679. @param target The target to be searched for all related listeners
  5680. */
  5681. targetOff(target: any): void;
  5682. /**
  5683. !#en
  5684. Register an callback of a specific event type on the EventTarget,
  5685. the callback will remove itself after the first time it is triggered.
  5686. !#zh
  5687. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5688. @param type A string representing the event type to listen for.
  5689. @param callback The callback that will be invoked when the event is dispatched.
  5690. The callback is ignored if it is a duplicate (the callbacks are unique).
  5691. @param target The target (this object) to invoke the callback, can be null
  5692. @param useCapture When set to true, the capture argument prevents callback
  5693. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5694. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5695. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5696. @example
  5697. ```js
  5698. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5699. cc.log("this is callback");
  5700. }, node);
  5701. ```
  5702. */
  5703. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5704. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5705. /**
  5706. !#en
  5707. Dispatches an event into the event flow.
  5708. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5709. !#zh 分发事件到事件流中。
  5710. @param event The Event object that is dispatched into the event flow
  5711. */
  5712. dispatchEvent(event: Event): void;
  5713. /**
  5714. !#en
  5715. Send an event to this object directly, this method will not propagate the event to any other objects.
  5716. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5717. !#zh
  5718. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5719. @param message the message to send
  5720. @param detail whatever argument the message needs
  5721. */
  5722. emit(message: string, detail?: any): void;
  5723. }
  5724. /** !#en Class for BitmapFont handling.
  5725. !#zh 位图字体资源类。 */
  5726. export class BitmapFont extends Font {
  5727. }
  5728. /** !#en Class for Font handling.
  5729. !#zh 字体资源类。 */
  5730. export class Font extends Asset {
  5731. }
  5732. /** !#en
  5733. Class for JSON file. When the JSON file is loaded, this object is returned.
  5734. The parsed JSON object can be accessed through the `json` attribute in it.<br>
  5735. If you want to get the original JSON text, you should modify the extname to `.txt`
  5736. so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
  5737. !#zh
  5738. JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。<br>
  5739. 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */
  5740. export class JsonAsset extends Asset {
  5741. /** The loaded JSON object. */
  5742. json: any;
  5743. }
  5744. /** !#en Class for LabelAtlas handling.
  5745. !#zh 艺术数字字体资源类。 */
  5746. export class LabelAtlas extends BitmapFont {
  5747. }
  5748. /** !#en Class for prefab handling.
  5749. !#zh 预制资源类。 */
  5750. export class Prefab extends Asset {
  5751. /** the main cc.Node in the prefab */
  5752. data: Node;
  5753. /** !#zh
  5754. 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
  5755. !#en
  5756. Indicates the optimization policy for instantiating this prefab.
  5757. Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
  5758. optimizationPolicy: Prefab.OptimizationPolicy;
  5759. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  5760. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  5761. asyncLoadAssets: boolean;
  5762. /**
  5763. Dynamically translation prefab data into minimized code.<br/>
  5764. This method will be called automatically before the first time the prefab being instantiated,
  5765. but you can re-call to refresh the create function once you modified the original prefab data in script.
  5766. */
  5767. compileCreateFunction(): void;
  5768. }
  5769. /** !#en
  5770. The base class for registering asset types.
  5771. !#zh
  5772. 注册用的资源基类。 */
  5773. export class RawAsset extends Object {
  5774. }
  5775. /** !#en Class for scene handling.
  5776. !#zh 场景资源类。 */
  5777. export class SceneAsset extends Asset {
  5778. scene: Scene;
  5779. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  5780. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  5781. asyncLoadAssets: boolean;
  5782. }
  5783. /** !#en Class for script handling.
  5784. !#zh Script 资源类。 */
  5785. export class _Script extends Asset {
  5786. }
  5787. /** !#en Class for JavaScript handling.
  5788. !#zh JavaScript 资源类。 */
  5789. export class _JavaScript extends Asset {
  5790. }
  5791. /** !#en Class for coffeescript handling.
  5792. !#zh CoffeeScript 资源类。 */
  5793. export class CoffeeScript extends Asset {
  5794. }
  5795. /** !#en Class for TypeScript handling.
  5796. !#zh TypeScript 资源类。 */
  5797. export class TypeScript extends Asset {
  5798. }
  5799. /** !#en Class for sprite atlas handling.
  5800. !#zh 精灵图集资源类。 */
  5801. export class SpriteAtlas extends Asset {
  5802. /**
  5803. Returns the texture of the sprite atlas
  5804. */
  5805. getTexture(): Texture2D;
  5806. /**
  5807. Returns the sprite frame correspond to the given key in sprite atlas.
  5808. @param key key
  5809. */
  5810. getSpriteFrame(key: string): SpriteFrame;
  5811. /**
  5812. Returns the sprite frames in sprite atlas.
  5813. */
  5814. getSpriteFrames(): [SpriteFrame];
  5815. }
  5816. /** !#en Class for TTFFont handling.
  5817. !#zh TTF 字体资源类。 */
  5818. export class TTFFont extends Font {
  5819. }
  5820. /** !#en Class for text file.
  5821. !#zh 文本资源类。 */
  5822. export class TextAsset extends Asset {
  5823. /** The text contents of the resource. */
  5824. text: string;
  5825. }
  5826. /** !#en The animation component is used to play back animations.
  5827. Animation provide several events to register:
  5828. - play : Emit when begin playing animation
  5829. - stop : Emit when stop playing animation
  5830. - pause : Emit when pause animation
  5831. - resume : Emit when resume animation
  5832. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  5833. - finished : Emit when finish playing animation
  5834. !#zh Animation 组件用于播放动画。
  5835. Animation 提供了一系列可注册的事件:
  5836. - play : 开始播放时
  5837. - stop : 停止播放时
  5838. - pause : 暂停播放时
  5839. - resume : 恢复播放时
  5840. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  5841. - finished : 动画播放完成时 */
  5842. export class Animation extends Component implements EventTarget {
  5843. /** !#en Animation will play the default clip when start game.
  5844. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  5845. defaultClip: AnimationClip;
  5846. /** !#en Current played clip.
  5847. !#zh 当前播放的动画剪辑。 */
  5848. currentClip: AnimationClip;
  5849. /** !#en Whether the animation should auto play the default clip when start game.
  5850. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  5851. playOnLoad: boolean;
  5852. /**
  5853. !#en Get all the clips used in this animation.
  5854. !#zh 获取动画组件上的所有动画剪辑。
  5855. */
  5856. getClips(): AnimationClip[];
  5857. /**
  5858. !#en Plays an animation and stop other animations.
  5859. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  5860. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5861. @param startTime play an animation from startTime
  5862. @example
  5863. ```js
  5864. var animCtrl = this.node.getComponent(cc.Animation);
  5865. animCtrl.play("linear");
  5866. ```
  5867. */
  5868. play(name?: string, startTime?: number): AnimationState;
  5869. /**
  5870. !#en
  5871. Plays an additive animation, it will not stop other animations.
  5872. If there are other animations playing, then will play several animations at the same time.
  5873. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  5874. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5875. @param startTime play an animation from startTime
  5876. @example
  5877. ```js
  5878. // linear_1 and linear_2 at the same time playing.
  5879. var animCtrl = this.node.getComponent(cc.Animation);
  5880. animCtrl.playAdditive("linear_1");
  5881. animCtrl.playAdditive("linear_2");
  5882. ```
  5883. */
  5884. playAdditive(name?: string, startTime?: number): AnimationState;
  5885. /**
  5886. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  5887. Stopping an animation also Rewinds it to the Start.
  5888. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  5889. @param name The animation to stop, if not supplied then stops all playing animations.
  5890. */
  5891. stop(name?: string): void;
  5892. /**
  5893. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  5894. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  5895. @param name The animation to pauses, if not supplied then pauses all playing animations.
  5896. */
  5897. pause(name?: string): void;
  5898. /**
  5899. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  5900. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  5901. @param name The animation to resumes, if not supplied then resumes all paused animations.
  5902. */
  5903. resume(name?: string): void;
  5904. /**
  5905. !#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.
  5906. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  5907. @param time The time to go to
  5908. @param name Specified animation name, if not supplied then make all animations go to the time.
  5909. */
  5910. setCurrentTime(time?: number, name?: string): void;
  5911. /**
  5912. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  5913. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  5914. @param name name
  5915. */
  5916. getAnimationState(name: string): AnimationState;
  5917. /**
  5918. !#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.
  5919. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  5920. @param clip the clip to add
  5921. @param newName newName
  5922. */
  5923. addClip(clip: AnimationClip, newName?: string): AnimationState;
  5924. /**
  5925. !#en
  5926. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  5927. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  5928. 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
  5929. !#zh
  5930. 从动画列表中移除指定的动画剪辑,<br/>
  5931. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  5932. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  5933. @param clip clip
  5934. @param force If force is true, then will always remove the clip and any animation states based on it.
  5935. */
  5936. removeClip(clip: AnimationClip, force?: boolean): void;
  5937. /**
  5938. !#en
  5939. Samples animations at the current state.<br/>
  5940. This is useful when you explicitly want to set up some animation state, and sample it once.
  5941. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  5942. @param name name
  5943. */
  5944. sample(name: string): void;
  5945. /**
  5946. !#en
  5947. Register animation event callback.
  5948. The event arguments will provide the AnimationState which emit the event.
  5949. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  5950. !#zh
  5951. 注册动画事件回调。
  5952. 回调的事件里将会附上发送事件的 AnimationState。
  5953. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  5954. @param type A string representing the event type to listen for.
  5955. @param callback The callback that will be invoked when the event is dispatched.
  5956. The callback is ignored if it is a duplicate (the callbacks are unique).
  5957. @param target The target (this object) to invoke the callback, can be null
  5958. @param useCapture When set to true, the capture argument prevents callback
  5959. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5960. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5961. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5962. @example
  5963. ```js
  5964. onPlay: function (event) {
  5965. var state = event.detail; // state instanceof cc.AnimationState
  5966. var type = event.type; // type === 'play';
  5967. }
  5968. // register event to all animation
  5969. animation.on('play', this.onPlay, this);
  5970. ```
  5971. */
  5972. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5973. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5974. /**
  5975. !#en
  5976. Unregister animation event callback.
  5977. !#zh
  5978. 取消注册动画事件回调。
  5979. @param type A string representing the event type being removed.
  5980. @param callback The callback to remove.
  5981. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5982. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5983. If not specified, useCapture defaults to false. If a callback was registered twice,
  5984. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5985. does not affect a non-capturing version of the same listener, and vice versa.
  5986. @example
  5987. ```js
  5988. // unregister event to all animation
  5989. animation.off('play', this.onPlay, this);
  5990. ```
  5991. */
  5992. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5993. /**
  5994. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5995. This is not for removing all listeners in the current event target,
  5996. and this is not for removing all listeners the target parameter have registered.
  5997. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5998. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5999. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  6000. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  6001. @param target The target to be searched for all related listeners
  6002. */
  6003. targetOff(target: any): void;
  6004. /**
  6005. !#en
  6006. Register an callback of a specific event type on the EventTarget,
  6007. the callback will remove itself after the first time it is triggered.
  6008. !#zh
  6009. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  6010. @param type A string representing the event type to listen for.
  6011. @param callback The callback that will be invoked when the event is dispatched.
  6012. The callback is ignored if it is a duplicate (the callbacks are unique).
  6013. @param target The target (this object) to invoke the callback, can be null
  6014. @param useCapture When set to true, the capture argument prevents callback
  6015. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  6016. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  6017. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  6018. @example
  6019. ```js
  6020. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  6021. cc.log("this is callback");
  6022. }, node);
  6023. ```
  6024. */
  6025. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  6026. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  6027. /**
  6028. !#en
  6029. Dispatches an event into the event flow.
  6030. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  6031. !#zh 分发事件到事件流中。
  6032. @param event The Event object that is dispatched into the event flow
  6033. */
  6034. dispatchEvent(event: Event): void;
  6035. /**
  6036. !#en
  6037. Send an event to this object directly, this method will not propagate the event to any other objects.
  6038. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  6039. !#zh
  6040. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  6041. @param message the message to send
  6042. @param detail whatever argument the message needs
  6043. */
  6044. emit(message: string, detail?: any): void;
  6045. }
  6046. /** !#en Audio Source.
  6047. !#zh 音频源组件,能对音频剪辑。 */
  6048. export class AudioSource extends Component {
  6049. /** !#en
  6050. Is the audio source playing (Read Only). <br/>
  6051. Note: isPlaying is not supported for Native platforms.
  6052. !#zh
  6053. 该音频剪辑是否正播放(只读)。<br/>
  6054. 注意:Native 平台暂时不支持 isPlaying。 */
  6055. isPlaying: boolean;
  6056. /** !#en The clip of the audio source to play.
  6057. !#zh 要播放的音频剪辑。 */
  6058. clip: AudioClip;
  6059. /** !#en The volume of the audio source.
  6060. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  6061. volume: number;
  6062. /** !#en Is the audio source mute?
  6063. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  6064. mute: boolean;
  6065. /** !#en Is the audio source looping?
  6066. !#zh 音频源是否循环播放? */
  6067. loop: boolean;
  6068. /** !#en If set to true, the audio source will automatically start playing on onEnable.
  6069. !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */
  6070. playOnLoad: boolean;
  6071. /**
  6072. !#en Plays the clip.
  6073. !#zh 播放音频剪辑。
  6074. */
  6075. play(): void;
  6076. /**
  6077. !#en Stops the clip.
  6078. !#zh 停止当前音频剪辑。
  6079. */
  6080. stop(): void;
  6081. /**
  6082. !#en Pause the clip.
  6083. !#zh 暂停当前音频剪辑。
  6084. */
  6085. pause(): void;
  6086. /**
  6087. !#en Resume the clip.
  6088. !#zh 恢复播放。
  6089. */
  6090. resume(): void;
  6091. /**
  6092. !#en Rewind playing music.
  6093. !#zh 从头开始播放。
  6094. */
  6095. rewind(): void;
  6096. /**
  6097. !#en Get current time
  6098. !#zh 获取当前的播放时间
  6099. */
  6100. getCurrentTime(): void;
  6101. /**
  6102. !#en Set current time
  6103. !#zh 设置当前的播放时间
  6104. @param time time
  6105. */
  6106. setCurrentTime(time: number): void;
  6107. /**
  6108. !#en Get audio duration
  6109. !#zh 获取当前音频的长度
  6110. */
  6111. getDuration(): void;
  6112. }
  6113. /** !#en
  6114. 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>
  6115. This component does not have any API interface and can be added directly to the scene to take effect.
  6116. !#zh
  6117. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6118. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6119. export class BlockInputEvents extends Component {
  6120. }
  6121. /** !#en
  6122. Button has 4 Transition types<br/>
  6123. When Button state changed:<br/>
  6124. If Transition type is Button.Transition.NONE, Button will do nothing<br/>
  6125. If Transition type is Button.Transition.COLOR, Button will change target's color<br/>
  6126. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite<br/>
  6127. If Transition type is Button.Transition.SCALE, Button will change target node's scale<br/>
  6128. Button will trigger 5 events:<br/>
  6129. Button.EVENT_TOUCH_DOWN<br/>
  6130. Button.EVENT_TOUCH_UP<br/>
  6131. Button.EVENT_HOVER_IN<br/>
  6132. Button.EVENT_HOVER_MOVE<br/>
  6133. Button.EVENT_HOVER_OUT<br/>
  6134. !#zh
  6135. 按钮组件。可以被按下,或者点击。<br/>
  6136. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:<br/>
  6137. -Button.Transition.NONE // 不做任何过渡<br/>
  6138. -Button.Transition.COLOR // 进行颜色之间过渡<br/>
  6139. -Button.Transition.SPRITE // 进行精灵之间过渡<br/>
  6140. -Button.Transition.SCALE // 进行缩放过渡<br/>
  6141. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):<br/>
  6142. // 以下事件可以在全平台上都触发<br/>
  6143. -cc.Node.EventType.TOUCH_START // 按下时事件<br/>
  6144. -cc.Node.EventType.TOUCH_Move // 按住移动后事件<br/>
  6145. -cc.Node.EventType.TOUCH_END // 按下后松开后事件<br/>
  6146. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件<br/>
  6147. // 以下事件只在 PC 平台上触发<br/>
  6148. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件<br/>
  6149. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件<br/>
  6150. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件<br/>
  6151. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件<br/>
  6152. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件<br/>
  6153. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件<br/> */
  6154. export class Button extends Component {
  6155. /** !#en
  6156. Whether the Button is disabled.
  6157. If true, the Button will trigger event and do transition.
  6158. !#zh
  6159. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6160. interactable: boolean;
  6161. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6162. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6163. enableAutoGrayEffect: boolean;
  6164. /** !#en Transition type
  6165. !#zh 按钮状态改变时过渡方式。 */
  6166. transition: Button.Transition;
  6167. /** !#en Normal state color.
  6168. !#zh 普通状态下按钮所显示的颜色。 */
  6169. normalColor: Color;
  6170. /** !#en Pressed state color
  6171. !#zh 按下状态时按钮所显示的颜色。 */
  6172. pressedColor: Color;
  6173. /** !#en Hover state color
  6174. !#zh 悬停状态下按钮所显示的颜色。 */
  6175. hoverColor: Color;
  6176. /** !#en Disabled state color
  6177. !#zh 禁用状态下按钮所显示的颜色。 */
  6178. disabledColor: Color;
  6179. /** !#en Color and Scale transition duration
  6180. !#zh 颜色过渡和缩放过渡时所需时间 */
  6181. duration: number;
  6182. /** !#en When user press the button, the button will zoom to a scale.
  6183. The final scale of the button equals (button original scale * zoomScale)
  6184. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6185. zoomScale: number;
  6186. /** !#en Normal state sprite
  6187. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6188. normalSprite: SpriteFrame;
  6189. /** !#en Pressed state sprite
  6190. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6191. pressedSprite: SpriteFrame;
  6192. /** !#en Hover state sprite
  6193. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6194. hoverSprite: SpriteFrame;
  6195. /** !#en Disabled state sprite
  6196. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6197. disabledSprite: SpriteFrame;
  6198. /** !#en
  6199. Transition target.
  6200. When Button state changed:
  6201. If Transition type is Button.Transition.NONE, Button will do nothing
  6202. If Transition type is Button.Transition.COLOR, Button will change target's color
  6203. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6204. !#zh
  6205. 需要过渡的目标。
  6206. 当前按钮状态改变规则:
  6207. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6208. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6209. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6210. target: Node;
  6211. /** !#en If Button is clicked, it will trigger event's handler
  6212. !#zh 按钮的点击事件列表。 */
  6213. clickEvents: Component.EventHandler[];
  6214. }
  6215. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  6216. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6217. export class Canvas extends Component {
  6218. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6219. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6220. static instance: Canvas;
  6221. /** !#en The desigin resolution for current scene.
  6222. !#zh 当前场景设计分辨率。 */
  6223. designResolution: Size;
  6224. /** !#en TODO
  6225. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6226. fitHeight: boolean;
  6227. /** !#en TODO
  6228. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6229. fitWidth: boolean;
  6230. }
  6231. /** !#en
  6232. Base class for everything attached to Node(Entity).<br/>
  6233. <br/>
  6234. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6235. because Component is created by the engine.
  6236. !#zh
  6237. 所有附加到节点的基类。<br/>
  6238. <br/>
  6239. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6240. export class Component extends Object {
  6241. /** !#en The node this component is attached to. A component is always attached to a node.
  6242. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6243. node: Node;
  6244. /** !#en The uuid for editor.
  6245. !#zh 组件的 uuid,用于编辑器。 */
  6246. uuid: string;
  6247. /** !#en indicates whether this component is enabled or not.
  6248. !#zh 表示该组件自身是否启用。 */
  6249. enabled: boolean;
  6250. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6251. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6252. enabledInHierarchy: boolean;
  6253. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6254. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6255. _isOnLoadCalled: number;
  6256. /**
  6257. !#en Update is called every frame, if the Component is enabled.
  6258. !#zh 如果该组件启用,则每帧调用 update。
  6259. @param dt the delta time in seconds it took to complete the last frame
  6260. */
  6261. protected update(dt: number): void;
  6262. /**
  6263. !#en LateUpdate is called every frame, if the Component is enabled.
  6264. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  6265. */
  6266. protected lateUpdate(): void;
  6267. /**
  6268. !#en
  6269. When attaching to an active node or its node first activated.
  6270. onLoad is always called before any start functions, this allows you to order initialization of scripts.
  6271. !#zh
  6272. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
  6273. */
  6274. protected onLoad(): void;
  6275. /**
  6276. !#en
  6277. Called before all scripts' update if the Component is enabled the first time.
  6278. Usually used to initialize some logic which need to be called after all components' `onload` methods called.
  6279. !#zh
  6280. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
  6281. */
  6282. protected start(): void;
  6283. /**
  6284. !#en Called when this component becomes enabled and its node is active.
  6285. !#zh 当该组件被启用,并且它的节点也激活时。
  6286. */
  6287. protected onEnable(): void;
  6288. /**
  6289. !#en Called when this component becomes disabled or its node becomes inactive.
  6290. !#zh 当该组件被禁用或节点变为无效时调用。
  6291. */
  6292. protected onDisable(): void;
  6293. /**
  6294. !#en Called when this component will be destroyed.
  6295. !#zh 当该组件被销毁时调用
  6296. */
  6297. protected onDestroy(): void;
  6298. protected onFocusInEditor(): void;
  6299. protected onLostFocusInEditor(): void;
  6300. /**
  6301. !#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.
  6302. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6303. */
  6304. protected resetInEditor(): void;
  6305. /**
  6306. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6307. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6308. @param typeOrClassName the constructor or the class name of the component to add
  6309. @example
  6310. ```js
  6311. var sprite = node.addComponent(cc.Sprite);
  6312. var test = node.addComponent("Test");
  6313. ```
  6314. */
  6315. addComponent<T extends Component>(type: {new(): T}): T;
  6316. addComponent(className: string): any;
  6317. /**
  6318. !#en
  6319. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6320. You can also get component in the node by passing in the name of the script.
  6321. !#zh
  6322. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6323. 传入参数也可以是脚本的名称。
  6324. @param typeOrClassName typeOrClassName
  6325. @example
  6326. ```js
  6327. // get sprite component.
  6328. var sprite = node.getComponent(cc.Sprite);
  6329. // get custom test calss.
  6330. var test = node.getComponent("Test");
  6331. ```
  6332. */
  6333. getComponent<T extends Component>(type: {prototype: T}): T;
  6334. getComponent(className: string): any;
  6335. /**
  6336. !#en Returns all components of supplied Type in the node.
  6337. !#zh 返回节点上指定类型的所有组件。
  6338. @param typeOrClassName typeOrClassName
  6339. @example
  6340. ```js
  6341. var sprites = node.getComponents(cc.Sprite);
  6342. var tests = node.getComponents("Test");
  6343. ```
  6344. */
  6345. getComponents<T extends Component>(type: {prototype: T}): T[];
  6346. getComponents(className: string): any[];
  6347. /**
  6348. !#en Returns the component of supplied type in any of its children using depth first search.
  6349. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6350. @param typeOrClassName typeOrClassName
  6351. @example
  6352. ```js
  6353. var sprite = node.getComponentInChildren(cc.Sprite);
  6354. var Test = node.getComponentInChildren("Test");
  6355. ```
  6356. */
  6357. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6358. getComponentInChildren(className: string): any;
  6359. /**
  6360. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6361. !#zh 递归查找自身或所有子节点中指定类型的组件
  6362. @param typeOrClassName typeOrClassName
  6363. @example
  6364. ```js
  6365. var sprites = node.getComponentsInChildren(cc.Sprite);
  6366. var tests = node.getComponentsInChildren("Test");
  6367. ```
  6368. */
  6369. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6370. getComponentsInChildren(className: string): any[];
  6371. /**
  6372. !#en
  6373. If the component's bounding box is different from the node's, you can implement this method to supply
  6374. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6375. !#zh
  6376. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6377. 以便编辑器的场景视图可以正确地执行点选测试。
  6378. @param out_rect the Rect to receive the bounding box
  6379. */
  6380. _getLocalBounds(out_rect: Rect): void;
  6381. /**
  6382. !#en
  6383. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6384. an undo operation on this component.<br/>
  6385. <br/>
  6386. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6387. in its CCClass properties", then you may need to implement this function.<br/>
  6388. <br/>
  6389. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6390. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6391. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6392. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6393. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6394. will be recorded or restored by editor.<br/>
  6395. <br/>
  6396. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6397. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6398. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6399. will not be called during reset operation. Which means that only the properties with default value<br/>
  6400. will be reset by editor.
  6401. This function is only called in editor mode.
  6402. !#zh
  6403. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6404. <br/>
  6405. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6406. <br/>
  6407. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  6408. 然而,在极端的情况下,它可能无法良好运作。<br/>
  6409. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  6410. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  6411. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6412. <br/>
  6413. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  6414. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  6415. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  6416. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  6417. <br/>
  6418. 此方法仅在编辑器下会被调用。
  6419. */
  6420. onRestore(): void;
  6421. /**
  6422. !#en
  6423. Schedules a custom selector.<br/>
  6424. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6425. !#zh
  6426. 调度一个自定义的回调函数。<br/>
  6427. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6428. @param callback The callback function
  6429. @param interval Tick interval in seconds. 0 means tick every frame.
  6430. @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  6431. @param delay The amount of time that the first tick will wait before execution.
  6432. @example
  6433. ```js
  6434. var timeCallback = function (dt) {
  6435. cc.log("time: " + dt);
  6436. }
  6437. this.schedule(timeCallback, 1);
  6438. ```
  6439. */
  6440. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6441. /**
  6442. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6443. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6444. @param callback A function wrapped as a selector
  6445. @param delay The amount of time that the first tick will wait before execution.
  6446. @example
  6447. ```js
  6448. var timeCallback = function (dt) {
  6449. cc.log("time: " + dt);
  6450. }
  6451. this.scheduleOnce(timeCallback, 2);
  6452. ```
  6453. */
  6454. scheduleOnce(callback: Function, delay?: number): void;
  6455. /**
  6456. !#en Unschedules a custom callback function.
  6457. !#zh 取消调度一个自定义的回调函数。
  6458. @param callback_fn A function wrapped as a selector
  6459. @example
  6460. ```js
  6461. this.unschedule(_callback);
  6462. ```
  6463. */
  6464. unschedule(callback_fn: Function): void;
  6465. /**
  6466. !#en
  6467. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6468. Actions are not affected by this method.
  6469. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  6470. @example
  6471. ```js
  6472. this.unscheduleAllCallbacks();
  6473. ```
  6474. */
  6475. unscheduleAllCallbacks(): void;
  6476. }
  6477. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  6478. !#zh EditBox 组件,用于获取用户的输入文本。 */
  6479. export class EditBox extends _RendererUnderSG {
  6480. /** !#en Input string of EditBox.
  6481. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  6482. string: string;
  6483. /** !#en The background image of EditBox.
  6484. !#zh 输入框的背景图片 */
  6485. backgroundImage: SpriteFrame;
  6486. /** !#en
  6487. The return key type of EditBox.
  6488. Note: it is meaningless for web platforms and desktop platforms.
  6489. !#zh
  6490. 指定移动设备上面回车按钮的样式。
  6491. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  6492. returnType: EditBox.KeyboardReturnType;
  6493. /** !#en Set the input flags that are to be applied to the EditBox.
  6494. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  6495. inputFlag: EditBox.InputFlag;
  6496. /** !#en
  6497. Set the input mode of the edit box.
  6498. If you pass ANY, it will create a multiline EditBox.
  6499. !#zh
  6500. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  6501. inputMode: EditBox.InputMode;
  6502. /** !#en Font size of the input text.
  6503. !#zh 输入框文本的字体大小 */
  6504. fontSize: number;
  6505. /** !#en Change the lineHeight of displayed text.
  6506. !#zh 输入框文本的行高。 */
  6507. lineHeight: number;
  6508. /** !#en Font color of the input text.
  6509. !#zh 输入框文本的颜色。 */
  6510. fontColor: Color;
  6511. /** !#en The display text of placeholder.
  6512. !#zh 输入框占位符的文本内容。 */
  6513. placeholder: string;
  6514. /** !#en The font size of placeholder.
  6515. !#zh 输入框占位符的字体大小。 */
  6516. placeholderFontSize: number;
  6517. /** !#en The font color of placeholder.
  6518. !#zh 输入框占位符的字体颜色。 */
  6519. placeholderFontColor: Color;
  6520. /** !#en The maximize input length of EditBox.
  6521. - If pass a value less than 0, it won't limit the input number of characters.
  6522. - If pass 0, it doesn't allow input any characters.
  6523. !#zh 输入框最大允许输入的字符个数。
  6524. - 如果值为小于 0 的值,则不会限制输入字符个数。
  6525. - 如果值为 0,则不允许用户进行任何输入。 */
  6526. maxLength: number;
  6527. /** !#en The input is always visible and be on top of the game view.
  6528. !zh 输入框总是可见,并且永远在游戏视图的上面
  6529. Note: only available on Web at the moment. */
  6530. stayOnTop: boolean;
  6531. /** !#en Set the tabIndex of the DOM input element, only useful on Web.
  6532. !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */
  6533. tabIndex: number;
  6534. /** !#en The event handler to be called when EditBox began to edit text.
  6535. !#zh 开始编辑文本输入框触发的事件回调。 */
  6536. editingDidBegan: Component.EventHandler[];
  6537. /** !#en The event handler to be called when EditBox text changes.
  6538. !#zh 编辑文本输入框时触发的事件回调。 */
  6539. textChanged: Component.EventHandler[];
  6540. /** !#en The event handler to be called when EditBox edit ends.
  6541. !#zh 结束编辑文本输入框时触发的事件回调。 */
  6542. editingDidEnded: Component.EventHandler[];
  6543. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  6544. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  6545. editingReturn: Component.EventHandler[];
  6546. /**
  6547. !#en Let the EditBox get focus, only valid when stayOnTop is true.
  6548. !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
  6549. Note: only available on Web at the moment.
  6550. */
  6551. setFocus(): void;
  6552. /**
  6553. !#en Determine whether EditBox is getting focus or not.
  6554. !#zh 判断 EditBox 是否获得了焦点
  6555. Note: only available on Web at the moment.
  6556. */
  6557. isFocused(): void;
  6558. /**
  6559. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  6560. call the destroy method on this component or the associated node explicitly.
  6561. Otherwise, the created DOM element won't be removed from web page.
  6562. !#zh
  6563. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  6564. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  6565. @example
  6566. ```js
  6567. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  6568. // when you don't need editbox anymore
  6569. editbox.node.destroy();
  6570. ```
  6571. */
  6572. destroy(): boolean;
  6573. }
  6574. /** !#en The Label Component.
  6575. !#zh 文字标签组件 */
  6576. export class Label extends _RendererUnderSG {
  6577. /** !#en Content string of label.
  6578. !#zh 标签显示的文本内容。 */
  6579. string: string;
  6580. /** !#en Horizontal Alignment of label.
  6581. !#zh 文本内容的水平对齐方式。 */
  6582. horizontalAlign: Label.HorizontalAlign;
  6583. /** !#en Vertical Alignment of label.
  6584. !#zh 文本内容的垂直对齐方式。 */
  6585. verticalAlign: Label.VerticalAlign;
  6586. /** !#en The actual rendering font size in shrink mode
  6587. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6588. actualFontSize: number;
  6589. /** !#en Font size of label.
  6590. !#zh 文本字体大小。 */
  6591. fontSize: number;
  6592. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6593. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6594. fontFamily: string;
  6595. /** !#en Line Height of label.
  6596. !#zh 文本行高。 */
  6597. lineHeight: number;
  6598. /** !#en Overflow of label.
  6599. !#zh 文字显示超出范围时的处理方式。 */
  6600. overflow: Label.Overflow;
  6601. /** !#en Whether auto wrap label when string width is large than label width.
  6602. !#zh 是否自动换行。 */
  6603. enableWrapText: boolean;
  6604. /** !#en The font of label.
  6605. !#zh 文本字体。 */
  6606. font: Font;
  6607. /** !#en Whether use system font name or not.
  6608. !#zh 是否使用系统字体。 */
  6609. isSystemFontUsed: boolean;
  6610. }
  6611. /** !#en Outline effect used to change the display, only used for TTF font
  6612. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6613. export class LabelOutline extends Component {
  6614. /** !#en Change the outline color
  6615. !#zh 改变描边的颜色 */
  6616. color: Color;
  6617. /** !#en Change the outline width
  6618. !#zh 改变描边的宽度 */
  6619. width: number;
  6620. }
  6621. /** !#en
  6622. The Layout is a container component, use it to arrange child elements easily.<br>
  6623. Note:<br>
  6624. 1.Scaling and rotation of child nodes are not considered.<br>
  6625. 2.After setting the Layout, the results need to be updated until the next frame,
  6626. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6627. !#zh
  6628. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6629. 注意:<br>
  6630. 1.不会考虑子节点的缩放和旋转。<br>
  6631. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6632. export class Layout extends Component {
  6633. /** !#en The layout type.
  6634. !#zh 布局类型 */
  6635. type: Layout.Type;
  6636. /** !#en
  6637. The are three resize modes for Layout.
  6638. None, resize Container and resize children.
  6639. !#zh 缩放模式 */
  6640. resizeMode: Layout.ResizeMode;
  6641. /** !#en The cell size for grid layout.
  6642. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6643. cellSize: Size;
  6644. /** !#en
  6645. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6646. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6647. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6648. startAxis: Layout.AxisDirection;
  6649. /** !#en The left padding of layout, it only effect the layout in one direction.
  6650. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6651. paddingLeft: number;
  6652. /** !#en The right padding of layout, it only effect the layout in one direction.
  6653. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6654. paddingRight: number;
  6655. /** !#en The top padding of layout, it only effect the layout in one direction.
  6656. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6657. paddingTop: number;
  6658. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6659. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6660. paddingBottom: number;
  6661. /** !#en The distance in x-axis between each element in layout.
  6662. !#zh 子节点之间的水平间距。 */
  6663. spacingX: number;
  6664. /** !#en The distance in y-axis between each element in layout.
  6665. !#zh 子节点之间的垂直间距。 */
  6666. spacingY: number;
  6667. /** !#en
  6668. Only take effect in Vertical layout mode.
  6669. This option changes the start element's positioning.
  6670. !#zh 垂直排列子节点的方向。 */
  6671. verticalDirection: Layout.VerticalDirection;
  6672. /** !#en
  6673. Only take effect in Horizontal layout mode.
  6674. This option changes the start element's positioning.
  6675. !#zh 水平排列子节点的方向。 */
  6676. horizontalDirection: Layout.HorizontalDirection;
  6677. /**
  6678. !#en Perform the layout update
  6679. !#zh 立即执行更新布局
  6680. @example
  6681. ```js
  6682. layout.type = cc.Layout.HORIZONTAL;
  6683. layout.node.addChild(childNode);
  6684. cc.log(childNode.x); // not yet changed
  6685. layout.updateLayout();
  6686. cc.log(childNode.x); // changed
  6687. ```
  6688. */
  6689. updateLayout(): void;
  6690. /** !#en The padding of layout, it effects the layout in four direction.
  6691. !#zh 容器内边距,该属性会在四个布局方向上生效。 */
  6692. padding: number;
  6693. }
  6694. /** !#en The Mask Component
  6695. !#zh 遮罩组件 */
  6696. export class Mask extends _RendererInSG {
  6697. /** !#en The mask type.
  6698. !#zh 遮罩类型 */
  6699. type: Mask.Type;
  6700. /** !#en The mask image
  6701. !#zh 遮罩所需要的贴图 */
  6702. spriteFrame: SpriteFrame;
  6703. /** !#en
  6704. The alpha threshold.(Not supported Canvas Mode) <br/>
  6705. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6706. Should be a float between 0 and 1. <br/>
  6707. This default to 1 (so alpha test is disabled).
  6708. !#zh
  6709. Alpha 阈值(不支持 Canvas 模式)<br/>
  6710. 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。<br/>
  6711. 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */
  6712. alphaThreshold: number;
  6713. /** !#en Reverse mask (Not supported Canvas Mode)
  6714. !#zh 反向遮罩(不支持 Canvas 模式) */
  6715. inverted: boolean;
  6716. /** !#en The segements for ellipse mask.
  6717. !#zh 椭圆遮罩的曲线细分数 */
  6718. segements: number;
  6719. }
  6720. /** !#en The PageView control
  6721. !#zh 页面视图组件 */
  6722. export class PageView extends ScrollView {
  6723. /** !#en Specify the size type of each page in PageView.
  6724. !#zh 页面视图中每个页面大小类型 */
  6725. sizeMode: PageView.SizeMode;
  6726. /** !#en The page view direction
  6727. !#zh 页面视图滚动类型 */
  6728. direction: PageView.Direction;
  6729. /** !#en
  6730. The scroll threshold value, when drag exceeds this value,
  6731. release the next page will automatically scroll, less than the restore
  6732. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6733. scrollThreshold: number;
  6734. /** !#en
  6735. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6736. it will calculate a velocity based on the scroll distance and time,
  6737. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6738. !#zh
  6739. 快速滑动翻页临界值。
  6740. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6741. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6742. autoPageTurningThreshold: number;
  6743. /** !#en Change the PageTurning event timing of PageView.
  6744. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6745. pageTurningEventTiming: number;
  6746. /** !#en The Page View Indicator
  6747. !#zh 页面视图指示器组件 */
  6748. indicator: PageViewIndicator;
  6749. /** !#en The time required to turn over a page. unit: second
  6750. !#zh 每个页面翻页时所需时间。单位:秒 */
  6751. pageTurningSpeed: number;
  6752. /** !#en PageView events callback
  6753. !#zh 滚动视图的事件回调函数 */
  6754. pageEvents: Component.EventHandler[];
  6755. /**
  6756. !#en Returns current page index
  6757. !#zh 返回当前页面索引
  6758. */
  6759. getCurrentPageIndex(): number;
  6760. /**
  6761. !#en Set current page index
  6762. !#zh 设置当前页面索引
  6763. @param index index
  6764. */
  6765. setCurrentPageIndex(index: number): void;
  6766. /**
  6767. !#en Returns all pages of pageview
  6768. !#zh 返回视图中的所有页面
  6769. */
  6770. getPages(): Node[];
  6771. /**
  6772. !#en At the end of the current page view to insert a new view
  6773. !#zh 在当前页面视图的尾部插入一个新视图
  6774. @param page page
  6775. */
  6776. addPage(page: Node): void;
  6777. /**
  6778. !#en Inserts a page in the specified location
  6779. !#zh 将页面插入指定位置中
  6780. @param page page
  6781. @param index index
  6782. */
  6783. insertPage(page: Node, index: number): void;
  6784. /**
  6785. !#en Removes a page from PageView.
  6786. !#zh 移除指定页面
  6787. @param page page
  6788. */
  6789. removePage(page: Node): void;
  6790. /**
  6791. !#en Removes a page at index of PageView.
  6792. !#zh 移除指定下标的页面
  6793. @param index index
  6794. */
  6795. removePageAtIndex(index: number): void;
  6796. /**
  6797. !#en Removes all pages from PageView
  6798. !#zh 移除所有页面
  6799. */
  6800. removeAllPages(): void;
  6801. /**
  6802. !#en Scroll PageView to index.
  6803. !#zh 滚动到指定页面
  6804. @param idx index of page.
  6805. @param timeInSecond scrolling time
  6806. */
  6807. scrollToPage(idx: number, timeInSecond: number): void;
  6808. }
  6809. /** !#en The Page View Indicator Component
  6810. !#zh 页面视图每页标记组件 */
  6811. export class PageViewIndicator extends Component {
  6812. /** !#en The spriteFrame for each element.
  6813. !#zh 每个页面标记显示的图片 */
  6814. spriteFrame: SpriteFrame;
  6815. /** !#en The location direction of PageViewIndicator.
  6816. !#zh 页面标记摆放方向 */
  6817. direction: PageViewIndicator.Direction;
  6818. /** !#en The cellSize for each element.
  6819. !#zh 每个页面标记的大小 */
  6820. cellSize: Size;
  6821. /** !#en The distance between each element.
  6822. !#zh 每个页面标记之间的边距 */
  6823. spacing: number;
  6824. /**
  6825. !#en Set Page View
  6826. !#zh 设置页面视图
  6827. @param target target
  6828. */
  6829. setPageView(target: PageView): void;
  6830. }
  6831. /** !#en
  6832. Visual indicator of progress in some operation.
  6833. Displays a bar to the user representing how far the operation has progressed.
  6834. !#zh
  6835. 进度条组件,可用于显示加载资源时的进度。 */
  6836. export class ProgressBar extends Component {
  6837. /** !#en The targeted Sprite which will be changed progressively.
  6838. !#zh 用来显示进度条比例的 Sprite 对象。 */
  6839. barSprite: Sprite;
  6840. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  6841. !#zh 进度条的模式 */
  6842. mode: ProgressBar.Mode;
  6843. /** !#en The total width or height of the bar sprite.
  6844. !#zh 进度条实际的总长度 */
  6845. totalLength: number;
  6846. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  6847. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  6848. progress: number;
  6849. /** !#en Whether reverse the progress direction of the bar sprite.
  6850. !#zh 进度条是否进行反方向变化。 */
  6851. reverse: boolean;
  6852. }
  6853. /** Rendering component in scene graph.
  6854. Maintains a node which will be the scene graph of component's Node. */
  6855. export class _RendererInSG extends _SGComponent {
  6856. }
  6857. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  6858. export class _RendererUnderSG extends _SGComponent {
  6859. }
  6860. /** !#en The RichText Component.
  6861. !#zh 富文本组件 */
  6862. export class RichText extends Component {
  6863. /** !#en Content string of RichText.
  6864. !#zh 富文本显示的文本内容。 */
  6865. string: string;
  6866. /** !#en Horizontal Alignment of each line in RichText.
  6867. !#zh 文本内容的水平对齐方式。 */
  6868. horizontalAlign: TextAlignment;
  6869. /** !#en Font size of RichText.
  6870. !#zh 富文本字体大小。 */
  6871. fontSize: number;
  6872. /** !#en Custom TTF font of RichText
  6873. !#zh 富文本定制字体 */
  6874. font: cc.TTFFont;
  6875. /** !#en The maximize width of the RichText
  6876. !#zh 富文本的最大宽度 */
  6877. maxWidth: number;
  6878. /** !#en Line Height of RichText.
  6879. !#zh 富文本行高。 */
  6880. lineHeight: number;
  6881. /** !#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.
  6882. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  6883. imageAtlas: SpriteAtlas;
  6884. /** !#en
  6885. Once checked, the RichText will block all input events (mouse and touch) within
  6886. the bounding box of the node, preventing the input from penetrating into the underlying node.
  6887. !#zh
  6888. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  6889. handleTouchEvent: boolean;
  6890. }
  6891. /** The base class for all rendering component in scene graph.
  6892. You should override:
  6893. - _createSgNode
  6894. - _initSgNode */
  6895. export class _SGComponent extends Component {
  6896. }
  6897. /** !#en
  6898. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  6899. !#zh 滚动条组件 */
  6900. export class Scrollbar extends Component {
  6901. /** !#en The "handle" part of the scrollbar.
  6902. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  6903. handle: Sprite;
  6904. /** !#en The direction of scrollbar.
  6905. !#zh ScrollBar 的滚动方向。 */
  6906. direction: Scrollbar.Direction;
  6907. /** !#en Whether enable auto hide or not.
  6908. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  6909. enableAutoHide: boolean;
  6910. /** !#en
  6911. The time to hide scrollbar when scroll finished.
  6912. Note: This value is only useful when enableAutoHide is true.
  6913. !#zh
  6914. 没有滚动动作后经过多久会自动隐藏。
  6915. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  6916. autoHideTime: number;
  6917. }
  6918. /** !#en
  6919. Layout container for a view hierarchy that can be scrolled by the user,
  6920. allowing it to be larger than the physical display.
  6921. !#zh
  6922. 滚动视图组件 */
  6923. export class ScrollView extends Component {
  6924. /** !#en This is a reference to the UI element to be scrolled.
  6925. !#zh 可滚动展示内容的节点。 */
  6926. content: Node;
  6927. /** !#en Enable horizontal scroll.
  6928. !#zh 是否开启水平滚动。 */
  6929. horizontal: boolean;
  6930. /** !#en Enable vertical scroll.
  6931. !#zh 是否开启垂直滚动。 */
  6932. vertical: boolean;
  6933. /** !#en When inertia is set, the content will continue to move when touch ended.
  6934. !#zh 是否开启滚动惯性。 */
  6935. inertia: boolean;
  6936. /** !#en
  6937. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  6938. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  6939. !#zh
  6940. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  6941. brake: number;
  6942. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  6943. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  6944. elastic: boolean;
  6945. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  6946. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  6947. bounceDuration: number;
  6948. /** !#en The horizontal scrollbar reference.
  6949. !#zh 水平滚动的 ScrollBar。 */
  6950. horizontalScrollBar: Scrollbar;
  6951. /** !#en The vertical scrollbar reference.
  6952. !#zh 垂直滚动的 ScrollBar。 */
  6953. verticalScrollBar: Scrollbar;
  6954. /** !#en Scrollview events callback
  6955. !#zh 滚动视图的事件回调函数 */
  6956. scrollEvents: Component.EventHandler[];
  6957. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  6958. It's set to true by default.
  6959. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  6960. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  6961. cancelInnerEvents: boolean;
  6962. /**
  6963. !#en Scroll the content to the bottom boundary of ScrollView.
  6964. !#zh 视图内容将在规定时间内滚动到视图底部。
  6965. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6966. the content will jump to the bottom boundary immediately.
  6967. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6968. @example
  6969. ```js
  6970. // Scroll to the bottom of the view.
  6971. scrollView.scrollToBottom(0.1);
  6972. ```
  6973. */
  6974. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  6975. /**
  6976. !#en Scroll the content to the top boundary of ScrollView.
  6977. !#zh 视图内容将在规定时间内滚动到视图顶部。
  6978. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6979. the content will jump to the top boundary immediately.
  6980. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6981. @example
  6982. ```js
  6983. // Scroll to the top of the view.
  6984. scrollView.scrollToTop(0.1);
  6985. ```
  6986. */
  6987. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  6988. /**
  6989. !#en Scroll the content to the left boundary of ScrollView.
  6990. !#zh 视图内容将在规定时间内滚动到视图左边。
  6991. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6992. the content will jump to the left boundary immediately.
  6993. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6994. @example
  6995. ```js
  6996. // Scroll to the left of the view.
  6997. scrollView.scrollToLeft(0.1);
  6998. ```
  6999. */
  7000. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  7001. /**
  7002. !#en Scroll the content to the right boundary of ScrollView.
  7003. !#zh 视图内容将在规定时间内滚动到视图右边。
  7004. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7005. the content will jump to the right boundary immediately.
  7006. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7007. @example
  7008. ```js
  7009. // Scroll to the right of the view.
  7010. scrollView.scrollToRight(0.1);
  7011. ```
  7012. */
  7013. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  7014. /**
  7015. !#en Scroll the content to the top left boundary of ScrollView.
  7016. !#zh 视图内容将在规定时间内滚动到视图左上角。
  7017. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7018. the content will jump to the top left boundary immediately.
  7019. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7020. @example
  7021. ```js
  7022. // Scroll to the upper left corner of the view.
  7023. scrollView.scrollToTopLeft(0.1);
  7024. ```
  7025. */
  7026. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  7027. /**
  7028. !#en Scroll the content to the top right boundary of ScrollView.
  7029. !#zh 视图内容将在规定时间内滚动到视图右上角。
  7030. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7031. the content will jump to the top right boundary immediately.
  7032. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7033. @example
  7034. ```js
  7035. // Scroll to the top right corner of the view.
  7036. scrollView.scrollToTopRight(0.1);
  7037. ```
  7038. */
  7039. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  7040. /**
  7041. !#en Scroll the content to the bottom left boundary of ScrollView.
  7042. !#zh 视图内容将在规定时间内滚动到视图左下角。
  7043. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7044. the content will jump to the bottom left boundary immediately.
  7045. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7046. @example
  7047. ```js
  7048. // Scroll to the lower left corner of the view.
  7049. scrollView.scrollToBottomLeft(0.1);
  7050. ```
  7051. */
  7052. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  7053. /**
  7054. !#en Scroll the content to the bottom right boundary of ScrollView.
  7055. !#zh 视图内容将在规定时间内滚动到视图右下角。
  7056. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7057. the content will jump to the bottom right boundary immediately.
  7058. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7059. @example
  7060. ```js
  7061. // Scroll to the lower right corner of the view.
  7062. scrollView.scrollToBottomRight(0.1);
  7063. ```
  7064. */
  7065. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  7066. /**
  7067. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  7068. specific offset immediately.
  7069. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  7070. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  7071. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7072. the content will jump to the specific offset of ScrollView immediately.
  7073. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7074. @example
  7075. ```js
  7076. // Scroll to middle position in 0.1 second in x-axis
  7077. var maxScrollOffset = this.getMaxScrollOffset();
  7078. scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1);
  7079. ```
  7080. */
  7081. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7082. /**
  7083. !#en Get the positive offset value corresponds to the content's top left boundary.
  7084. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  7085. */
  7086. getScrollOffset(): Vec2;
  7087. /**
  7088. !#en Get the maximize available scroll offset
  7089. !#zh 获取滚动视图最大可以滚动的偏移量
  7090. */
  7091. getMaxScrollOffset(): Vec2;
  7092. /**
  7093. !#en Scroll the content to the horizontal percent position of ScrollView.
  7094. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  7095. @param percent A value between 0 and 1.
  7096. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7097. the content will jump to the horizontal percent position of ScrollView immediately.
  7098. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7099. @example
  7100. ```js
  7101. // Scroll to middle position.
  7102. scrollView.scrollToBottomRight(0.5, 0.1);
  7103. ```
  7104. */
  7105. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7106. /**
  7107. !#en Scroll the content to the percent position of ScrollView in any direction.
  7108. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  7109. @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1).
  7110. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7111. the content will jump to the percent position of ScrollView immediately.
  7112. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7113. @example
  7114. ```js
  7115. // Vertical scroll to the bottom of the view.
  7116. scrollView.scrollTo(cc.p(0, 1), 0.1);
  7117. // Horizontal scroll to view right.
  7118. scrollView.scrollTo(cc.p(1, 0), 0.1);
  7119. ```
  7120. */
  7121. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7122. /**
  7123. !#en Scroll the content to the vertical percent position of ScrollView.
  7124. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7125. @param percent A value between 0 and 1.
  7126. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7127. the content will jump to the vertical percent position of ScrollView immediately.
  7128. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7129. // Scroll to middle position.
  7130. scrollView.scrollToPercentVertical(0.5, 0.1);
  7131. */
  7132. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7133. /**
  7134. !#en Stop auto scroll immediately
  7135. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7136. */
  7137. stopAutoScroll(): void;
  7138. /**
  7139. !#en Modify the content position.
  7140. !#zh 设置当前视图内容的坐标点。
  7141. @param position The position in content's parent space.
  7142. */
  7143. setContentPosition(position: Vec2): void;
  7144. /**
  7145. !#en Query the content's position in its parent space.
  7146. !#zh 获取当前视图内容的坐标点。
  7147. */
  7148. getContentPosition(): Position;
  7149. /**
  7150. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7151. !#zh 用户是否在拖拽当前滚动视图
  7152. */
  7153. isScrolling(): boolean;
  7154. /**
  7155. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7156. !#zh 当前滚动视图是否在惯性滚动
  7157. */
  7158. isAutoScrolling(): boolean;
  7159. }
  7160. /** !#en The Slider Control
  7161. !#zh 滑动器组件 */
  7162. export class Slider extends Component {
  7163. /** !#en The "handle" part of the slider
  7164. !#zh 滑动器滑块按钮部件 */
  7165. handle: Button;
  7166. /** !#en The slider direction
  7167. !#zh 滑动器方向 */
  7168. direction: Slider.Direction;
  7169. /** !#en The current progress of the slider. The valid value is between 0-1
  7170. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7171. progress: number;
  7172. /** !#en The slider events callback
  7173. !#zh 滑动器组件事件回调函数 */
  7174. slideEvents: Component.EventHandler[];
  7175. }
  7176. /** !#en Renders a sprite in the scene.
  7177. !#zh 该组件用于在场景中渲染精灵。 */
  7178. export class Sprite extends _RendererUnderSG {
  7179. /** !#en The sprite frame of the sprite.
  7180. !#zh 精灵的精灵帧 */
  7181. spriteFrame: SpriteFrame;
  7182. /** !#en The sprite render type.
  7183. !#zh 精灵渲染类型 */
  7184. type: Sprite.Type;
  7185. /** !#en
  7186. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7187. !#zh
  7188. 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7189. fillType: Sprite.FillType;
  7190. /** !#en
  7191. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7192. !#zh
  7193. 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7194. fillCenter: Vec2;
  7195. /** !#en
  7196. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7197. !#zh
  7198. 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7199. fillStart: number;
  7200. /** !#en
  7201. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7202. !#zh
  7203. 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7204. fillRange: number;
  7205. /** !#en specify the frame is trimmed or not.
  7206. !#zh 是否使用裁剪模式 */
  7207. trim: boolean;
  7208. /** !#en specify the source Blend Factor.
  7209. !#zh 指定原图的混合模式 */
  7210. srcBlendFactor: BlendFactor;
  7211. /** !#en specify the destination Blend Factor.
  7212. !#zh 指定目标的混合模式 */
  7213. dstBlendFactor: BlendFactor;
  7214. /** !#en specify the size tracing mode.
  7215. !#zh 精灵尺寸调整模式 */
  7216. sizeMode: Sprite.SizeMode;
  7217. /**
  7218. !#en Change the left sprite's cap inset.
  7219. !#zh 设置精灵左边框-用于九宫格。
  7220. @param insetLeft The values to use for the cap inset.
  7221. @example
  7222. ```js
  7223. sprite.setInsetLeft(5);
  7224. ```
  7225. */
  7226. setInsetLeft(insetLeft: number): void;
  7227. /**
  7228. !#en Query the left sprite's cap inset.
  7229. !#zh 获取精灵左边框
  7230. @example
  7231. ```js
  7232. var insetLeft = sprite.getInsetLeft();
  7233. cc.log("Inset Left:" + insetLeft);
  7234. ```
  7235. */
  7236. getInsetLeft(): number;
  7237. /**
  7238. !#en Change the top sprite's cap inset.
  7239. !#zh 设置精灵上边框-用于九宫格。
  7240. @param insetTop The values to use for the cap inset.
  7241. @example
  7242. ```js
  7243. sprite.setInsetTop(5);
  7244. ```
  7245. */
  7246. setInsetTop(insetTop: number): void;
  7247. /**
  7248. !#en Query the top sprite's cap inset.
  7249. !#zh 获取精灵上边框。
  7250. @example
  7251. ```js
  7252. var insetTop = sprite.getInsetTop();
  7253. cc.log("Inset Top:" + insetTop);
  7254. ```
  7255. */
  7256. getInsetTop(): number;
  7257. /**
  7258. !#en Change the right sprite's cap inset.
  7259. !#zh 设置精灵右边框-用于九宫格。
  7260. @param insetRight The values to use for the cap inset.
  7261. @example
  7262. ```js
  7263. sprite.setInsetRight(5);
  7264. ```
  7265. */
  7266. setInsetRight(insetRight: number): void;
  7267. /**
  7268. !#en Query the right sprite's cap inset.
  7269. !#zh 获取精灵右边框。
  7270. @example
  7271. ```js
  7272. var insetRight = sprite.getInsetRight();
  7273. cc.log("Inset Right:" + insetRight);
  7274. ```
  7275. */
  7276. getInsetRight(): number;
  7277. /**
  7278. !#en Change the bottom sprite's cap inset.
  7279. !#zh 设置精灵下边框-用于九宫格。
  7280. @param bottomInset The values to use for the cap inset.
  7281. @example
  7282. ```js
  7283. sprite.setInsetBottom(5);
  7284. ```
  7285. */
  7286. setInsetBottom(bottomInset: number): void;
  7287. /**
  7288. !#en Query the bottom sprite's cap inset.
  7289. !#zh 获取精灵下边框。
  7290. @example
  7291. ```js
  7292. var insetBottom = sprite.getInsetBottom();
  7293. cc.log("Inset Bottom:" + insetBottom);
  7294. ```
  7295. */
  7296. getInsetBottom(): number;
  7297. }
  7298. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  7299. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  7300. export class SpriteDistortion extends Component {
  7301. /** !#en Change the UV offset for distortion rendering.
  7302. !#zh 在渲染时改变UV的整体偏移. */
  7303. offset: Vec2;
  7304. /** !#en Change the UV scale for distortion rendering.
  7305. !#zh 在渲染时改变UV的寻址系数 */
  7306. tiling: Vec2;
  7307. }
  7308. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7309. could be treated as a RadioButton.
  7310. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7311. export class Toggle extends Button {
  7312. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7313. the check mark component will be disabled.
  7314. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7315. isChecked: boolean;
  7316. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7317. Otherwise, the toggle is a RadioButton.
  7318. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7319. 否则,Toggle 是一个 RadioButton。 */
  7320. toggleGroup: ToggleGroup;
  7321. /** !#en The image used for the checkmark.
  7322. !#zh Toggle 处于选中状态时显示的图片 */
  7323. checkMark: Sprite;
  7324. /** !#en If Toggle is clicked, it will trigger event's handler
  7325. !#zh Toggle 按钮的点击事件列表。 */
  7326. checkEvents: Component.EventHandler[];
  7327. /**
  7328. !#en Make the toggle button checked.
  7329. !#zh 使 toggle 按钮处于选中状态
  7330. */
  7331. check(): void;
  7332. /**
  7333. !#en Make the toggle button unchecked.
  7334. !#zh 使 toggle 按钮处于未选中状态
  7335. */
  7336. uncheck(): void;
  7337. }
  7338. /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. </br>
  7339. Toggles that belong to the same group could only have one of them to be switched on at a time.</br>
  7340. Note: All the first layer child node containing the toggle component will auto be added to the container
  7341. !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。</br>
  7342. 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。</br>
  7343. 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
  7344. export class ToggleContainer extends Component {
  7345. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7346. If it is false, it will make sure there is always only one toggle could be switched on
  7347. and the already switched on toggle can't be switched off.
  7348. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7349. allowSwitchOff: boolean;
  7350. /** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
  7351. !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
  7352. toggleItems: Toggle[];
  7353. }
  7354. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7355. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7356. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7357. 任何时候只能有一个 Toggle 处于选中状态。 */
  7358. export class ToggleGroup extends Component {
  7359. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7360. If it is false, it will make sure there is always only one toggle could be switched on
  7361. and the already switched on toggle can't be switched off.
  7362. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7363. allowSwitchOff: boolean;
  7364. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7365. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7366. toggleItems: any[];
  7367. }
  7368. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  7369. !#zh Video 组件,用于在游戏中播放视频 */
  7370. export class VideoPlayer extends _RendererUnderSG {
  7371. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  7372. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  7373. resourceType: VideoPlayer.ResourceType;
  7374. /** !#en The remote URL of video.
  7375. !#zh 远程视频的 URL */
  7376. remoteURL: string;
  7377. /** !#en The local video full path.
  7378. !#zh 本地视频的 URL */
  7379. clip: string;
  7380. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  7381. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  7382. currentTime: number;
  7383. /** !#en The volume of the video.
  7384. !#zh 视频的音量(0.0 ~ 1.0) */
  7385. volume: number;
  7386. /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume.
  7387. !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */
  7388. mute: boolean;
  7389. /** !#en Whether keep the aspect ration of the original video.
  7390. !#zh 是否保持视频原来的宽高比 */
  7391. keepAspectRatio: boolean;
  7392. /** !#en Whether play video in fullscreen mode.
  7393. !#zh 是否全屏播放视频 */
  7394. isFullscreen: boolean;
  7395. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  7396. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  7397. videoPlayerEvent: Component.EventHandler[];
  7398. /**
  7399. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  7400. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  7401. */
  7402. play(): void;
  7403. /**
  7404. !#en If a video is paused, call this method to resume playing.
  7405. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  7406. */
  7407. resume(): void;
  7408. /**
  7409. !#en If a video is playing, call this method to pause playing.
  7410. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  7411. */
  7412. pause(): void;
  7413. /**
  7414. !#en If a video is playing, call this method to stop playing immediately.
  7415. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  7416. */
  7417. stop(): void;
  7418. /**
  7419. !#en Gets the duration of the video
  7420. !#zh 获取视频文件的播放总时长
  7421. */
  7422. getDuration(): number;
  7423. /**
  7424. !#en Determine whether video is playing or not.
  7425. !#zh 判断当前视频是否处于播放状态
  7426. */
  7427. isPlaying(): boolean;
  7428. /**
  7429. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  7430. call the destroy method on this component or the associated node explicitly.
  7431. Otherwise, the created DOM element won't be removed from web page.
  7432. !#zh
  7433. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7434. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7435. @example
  7436. ```js
  7437. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  7438. // when you don't need videoplayer anymore
  7439. videoplayer.node.destroy();
  7440. ```
  7441. */
  7442. destroy(): boolean;
  7443. }
  7444. /** !#en
  7445. Handling touch events in a ViewGroup takes special care,
  7446. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7447. To make sure that each view correctly receives the touch events intended for it,
  7448. ViewGroup should register capture phase event and handle the event propagation properly.
  7449. Please refer to Scrollview for more information.
  7450. !#zh
  7451. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7452. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7453. 请参考 ScrollView 的实现来获取更多信息。 */
  7454. export class ViewGroup extends Component {
  7455. }
  7456. /** !#en cc.WebView is a component for display web pages in the game
  7457. !#zh WebView 组件,用于在游戏中显示网页 */
  7458. export class WebView extends _RendererUnderSG {
  7459. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  7460. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  7461. url: string;
  7462. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  7463. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  7464. webviewLoadedEvents: Component.EventHandler[];
  7465. /**
  7466. !#en
  7467. Set javascript interface scheme (see also setOnJSCallback). <br/>
  7468. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7469. Please refer to the official documentation for more details.
  7470. !#zh
  7471. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  7472. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  7473. 详情请参阅官方文档
  7474. @param scheme scheme
  7475. */
  7476. setJavascriptInterfaceScheme(scheme: string): void;
  7477. /**
  7478. !#en
  7479. This callback called when load URL that start with javascript
  7480. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  7481. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7482. Please refer to the official documentation for more details.
  7483. !#zh
  7484. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  7485. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  7486. 详情请参阅官方文档
  7487. @param callback callback
  7488. */
  7489. setOnJSCallback(callback: Function): void;
  7490. /**
  7491. !#en
  7492. Evaluates JavaScript in the context of the currently displayed page. <br/>
  7493. Please refer to the official document for more details <br/>
  7494. Note: Cross domain issues need to be resolved by yourself <br/>
  7495. !#zh
  7496. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  7497. 注意:需要自行解决跨域问题
  7498. @param str str
  7499. */
  7500. evaluateJS(str: string): void;
  7501. /**
  7502. !#en if you don't need the WebView and it isn't in any running Scene, you should
  7503. call the destroy method on this component or the associated node explicitly.
  7504. Otherwise, the created DOM element won't be removed from web page.
  7505. !#zh
  7506. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7507. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7508. @example
  7509. ```js
  7510. webview.node.parent = null; // or webview.node.removeFromParent(false);
  7511. // when you don't need webview anymore
  7512. webview.node.destroy();
  7513. ```
  7514. */
  7515. destroy(): boolean;
  7516. }
  7517. /** !#en
  7518. Stores and manipulate the anchoring based on its parent.
  7519. Widget are used for GUI but can also be used for other things.
  7520. 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.
  7521. !#zh
  7522. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7523. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7524. export class Widget extends Component {
  7525. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7526. The default value is null, and when null, indicates the current parent.
  7527. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7528. target: Node;
  7529. /** !#en Whether to align the top.
  7530. !#zh 是否对齐上边。 */
  7531. isAlignTop: boolean;
  7532. /** !#en
  7533. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7534. !#zh
  7535. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7536. isAlignVerticalCenter: boolean;
  7537. /** !#en Whether to align the bottom.
  7538. !#zh 是否对齐下边。 */
  7539. isAlignBottom: boolean;
  7540. /** !#en Whether to align the left.
  7541. !#zh 是否对齐左边 */
  7542. isAlignLeft: boolean;
  7543. /** !#en
  7544. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7545. !#zh
  7546. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7547. isAlignHorizontalCenter: boolean;
  7548. /** !#en Whether to align the right.
  7549. !#zh 是否对齐右边。 */
  7550. isAlignRight: boolean;
  7551. /** !#en
  7552. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7553. the width setting is invalid (read only).
  7554. !#zh
  7555. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7556. isStretchWidth: boolean;
  7557. /** !#en
  7558. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7559. then height setting is invalid (read only)
  7560. !#zh
  7561. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7562. isStretchHeight: boolean;
  7563. /** !#en
  7564. The margins between the top of this node and the top of parent node,
  7565. the value can be negative, Only available in 'isAlignTop' open.
  7566. !#zh
  7567. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7568. top: number;
  7569. /** !#en
  7570. The margins between the bottom of this node and the bottom of parent node,
  7571. the value can be negative, Only available in 'isAlignBottom' open.
  7572. !#zh
  7573. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7574. bottom: number;
  7575. /** !#en
  7576. The margins between the left of this node and the left of parent node,
  7577. the value can be negative, Only available in 'isAlignLeft' open.
  7578. !#zh
  7579. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7580. left: number;
  7581. /** !#en
  7582. The margins between the right of this node and the right of parent node,
  7583. the value can be negative, Only available in 'isAlignRight' open.
  7584. !#zh
  7585. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7586. right: number;
  7587. /** !#en
  7588. Horizontal aligns the midpoint offset value,
  7589. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7590. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7591. horizontalCenter: number;
  7592. /** !#en
  7593. Vertical aligns the midpoint offset value,
  7594. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7595. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7596. verticalCenter: number;
  7597. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7598. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7599. isAbsoluteHorizontalCenter: boolean;
  7600. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7601. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7602. isAbsoluteVerticalCenter: boolean;
  7603. /** !#en
  7604. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7605. !#zh
  7606. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7607. isAbsoluteTop: boolean;
  7608. /** !#en
  7609. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7610. !#zh
  7611. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7612. isAbsoluteBottom: boolean;
  7613. /** !#en
  7614. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7615. !#zh
  7616. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7617. isAbsoluteLeft: boolean;
  7618. /** !#en
  7619. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7620. !#zh
  7621. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7622. isAbsoluteRight: boolean;
  7623. /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh.
  7624. !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */
  7625. alignMode: Widget.AlignMode;
  7626. /**
  7627. !#en
  7628. Immediately perform the widget alignment. You need to manually call this method only if
  7629. you need to get the latest results after the alignment before the end of current frame.
  7630. !#zh
  7631. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7632. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7633. @example
  7634. ```js
  7635. widget.top = 10; // change top margin
  7636. cc.log(widget.node.y); // not yet changed
  7637. widget.updateAlignment();
  7638. cc.log(widget.node.y); // changed
  7639. ```
  7640. */
  7641. updateAlignment(): void;
  7642. /** !#en
  7643. When turned on, it will only be aligned once at the end of the onEnable frame,
  7644. then immediately disables the current component.
  7645. This will allow the script or animation to continue controlling the current node.
  7646. Note: It will still be aligned at the frame when onEnable is called.
  7647. !#zh
  7648. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7649. 这样便于脚本或动画继续控制当前节点。
  7650. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7651. isAlignOnce: boolean;
  7652. }
  7653. /** !#en Box Collider.
  7654. !#zh 包围盒碰撞组件 */
  7655. export class BoxCollider extends Collider implements Collider.Box {
  7656. /** !#en Position offset
  7657. !#zh 位置偏移量 */
  7658. offset: Vec2;
  7659. /** !#en Box size
  7660. !#zh 包围盒大小 */
  7661. size: Size;
  7662. }
  7663. /** !#en Circle Collider.
  7664. !#zh 圆形碰撞组件 */
  7665. export class CircleCollider extends Collider implements Collider.Circle {
  7666. /** !#en Position offset
  7667. !#zh 位置偏移量 */
  7668. offset: Vec2;
  7669. /** !#en Circle radius
  7670. !#zh 圆形半径 */
  7671. radius: number;
  7672. }
  7673. /** !#en Collider component base class.
  7674. !#zh 碰撞组件基类 */
  7675. export class Collider extends Component {
  7676. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  7677. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  7678. tag: number;
  7679. }
  7680. /** !#en
  7681. A simple collision manager class.
  7682. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  7683. !#zh
  7684. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  7685. export class CollisionManager implements EventTarget {
  7686. /** !#en
  7687. !#zh
  7688. 是否开启碰撞管理,默认为不开启 */
  7689. enabled: boolean;
  7690. /** !#en
  7691. !#zh
  7692. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  7693. enabledDrawBoundingBox: boolean;
  7694. /** !#en
  7695. !#zh
  7696. 是否绘制碰撞组件的形状,默认为不绘制 */
  7697. enabledDebugDraw: boolean;
  7698. /**
  7699. !#en
  7700. Register an callback of a specific event type on the EventTarget.
  7701. !#zh
  7702. 注册事件目标的特定事件类型回调。
  7703. @param type A string representing the event type to listen for.
  7704. @param callback The callback that will be invoked when the event is dispatched.
  7705. The callback is ignored if it is a duplicate (the callbacks are unique).
  7706. @param target The target (this object) to invoke the callback, can be null
  7707. @param useCapture When set to true, the capture argument prevents callback
  7708. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7709. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7710. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7711. @example
  7712. ```js
  7713. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7714. cc.log("this is callback");
  7715. }, node);
  7716. ```
  7717. */
  7718. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7719. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7720. /**
  7721. !#en
  7722. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7723. if only type is passed as parameter, all listeners registered with that type will be removed.
  7724. !#zh
  7725. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7726. @param type A string representing the event type being removed.
  7727. @param callback The callback to remove.
  7728. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7729. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7730. If not specified, useCapture defaults to false. If a callback was registered twice,
  7731. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7732. does not affect a non-capturing version of the same listener, and vice versa.
  7733. @example
  7734. ```js
  7735. // register touchEnd eventListener
  7736. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7737. cc.log("this is callback");
  7738. }, node);
  7739. // remove touch end event listener
  7740. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7741. // remove all touch end event listeners
  7742. node.off(cc.Node.EventType.TOUCH_END);
  7743. ```
  7744. */
  7745. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7746. /**
  7747. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7748. This is not for removing all listeners in the current event target,
  7749. and this is not for removing all listeners the target parameter have registered.
  7750. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7751. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7752. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7753. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7754. @param target The target to be searched for all related listeners
  7755. */
  7756. targetOff(target: any): void;
  7757. /**
  7758. !#en
  7759. Register an callback of a specific event type on the EventTarget,
  7760. the callback will remove itself after the first time it is triggered.
  7761. !#zh
  7762. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7763. @param type A string representing the event type to listen for.
  7764. @param callback The callback that will be invoked when the event is dispatched.
  7765. The callback is ignored if it is a duplicate (the callbacks are unique).
  7766. @param target The target (this object) to invoke the callback, can be null
  7767. @param useCapture When set to true, the capture argument prevents callback
  7768. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7769. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7770. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7771. @example
  7772. ```js
  7773. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7774. cc.log("this is callback");
  7775. }, node);
  7776. ```
  7777. */
  7778. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7779. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7780. /**
  7781. !#en
  7782. Dispatches an event into the event flow.
  7783. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7784. !#zh 分发事件到事件流中。
  7785. @param event The Event object that is dispatched into the event flow
  7786. */
  7787. dispatchEvent(event: Event): void;
  7788. /**
  7789. !#en
  7790. Send an event to this object directly, this method will not propagate the event to any other objects.
  7791. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  7792. !#zh
  7793. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  7794. @param message the message to send
  7795. @param detail whatever argument the message needs
  7796. */
  7797. emit(message: string, detail?: any): void;
  7798. }
  7799. /** !#en Intersection helper class
  7800. !#zh 辅助类,用于测试形状与形状是否相交 */
  7801. export class Intersection {
  7802. /**
  7803. !#en Test line and line
  7804. !#zh 测试线段与线段是否相交
  7805. @param a1 The start point of the first line
  7806. @param a2 The end point of the first line
  7807. @param b1 The start point of the second line
  7808. @param b2 The end point of the second line
  7809. */
  7810. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  7811. /**
  7812. !#en Test line and rect
  7813. !#zh 测试线段与矩形是否相交
  7814. @param a1 The start point of the line
  7815. @param a2 The end point of the line
  7816. @param b The rect
  7817. */
  7818. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  7819. /**
  7820. !#en Test line and polygon
  7821. !#zh 测试线段与多边形是否相交
  7822. @param a1 The start point of the line
  7823. @param a2 The end point of the line
  7824. @param b The polygon, a set of points
  7825. */
  7826. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  7827. /**
  7828. !#en Test rect and rect
  7829. !#zh 测试矩形与矩形是否相交
  7830. @param a The first rect
  7831. @param b The second rect
  7832. */
  7833. static rectRect(a: Rect, b: Rect): boolean;
  7834. /**
  7835. !#en Test rect and polygon
  7836. !#zh 测试矩形与多边形是否相交
  7837. @param a The rect
  7838. @param b The polygon, a set of points
  7839. */
  7840. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  7841. /**
  7842. !#en Test polygon and polygon
  7843. !#zh 测试多边形与多边形是否相交
  7844. @param a The first polygon, a set of points
  7845. @param b The second polygon, a set of points
  7846. */
  7847. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  7848. /**
  7849. !#en Test circle and circle
  7850. !#zh 测试圆形与圆形是否相交
  7851. @param a Object contains position and radius
  7852. @param b Object contains position and radius
  7853. */
  7854. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  7855. /**
  7856. !#en Test polygon and circle
  7857. !#zh 测试矩形与圆形是否相交
  7858. @param polygon The Polygon, a set of points
  7859. @param circle Object contains position and radius
  7860. */
  7861. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  7862. /**
  7863. !#en Test whether the point is in the polygon
  7864. !#zh 测试一个点是否在一个多边形中
  7865. @param point The point
  7866. @param polygon The polygon, a set of points
  7867. */
  7868. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  7869. /**
  7870. !#en Calculate the distance of point to line.
  7871. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  7872. @param point The point
  7873. @param start The start point of line
  7874. @param end The end point of line
  7875. @param isSegment whether this line is a segment
  7876. */
  7877. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean;
  7878. }
  7879. /** !#en Polygon Collider.
  7880. !#zh 多边形碰撞组件 */
  7881. export class PolygonCollider extends Collider implements Collider.Polygon {
  7882. /** !#en Position offset
  7883. !#zh 位置偏移量 */
  7884. offset: Vec2;
  7885. /** !#en Polygon points
  7886. !#zh 多边形顶点数组 */
  7887. points: Vec2[];
  7888. }
  7889. /** !#en
  7890. EventTarget is an object to which an event is dispatched when something has occurred.
  7891. Entity are the most common event targets, but other objects can be event targets too.
  7892. Event targets are an important part of the Fireball event model.
  7893. The event target serves as the focal point for how events flow through the scene graph.
  7894. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7895. into the event flow from the root of the hierarchy. The event object then makes its way through
  7896. the scene graph until it reaches the event target, at which point it begins its return trip through
  7897. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7898. - The capture phase comprises the journey from the root to the last node before the event target's node
  7899. - The target phase comprises only the event target node
  7900. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7901. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7902. Event targets can implement the following methods:
  7903. - _getCapturingTargets
  7904. - _getBubblingTargets
  7905. !#zh
  7906. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7907. 但是其他对象也可以是事件目标。<br/> */
  7908. export class EventTarget {
  7909. /**
  7910. !#en
  7911. Register an callback of a specific event type on the EventTarget.
  7912. !#zh
  7913. 注册事件目标的特定事件类型回调。
  7914. @param type A string representing the event type to listen for.
  7915. @param callback The callback that will be invoked when the event is dispatched.
  7916. The callback is ignored if it is a duplicate (the callbacks are unique).
  7917. @param target The target (this object) to invoke the callback, can be null
  7918. @param useCapture When set to true, the capture argument prevents callback
  7919. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7920. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7921. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7922. @example
  7923. ```js
  7924. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7925. cc.log("this is callback");
  7926. }, node);
  7927. ```
  7928. */
  7929. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7930. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7931. /**
  7932. !#en
  7933. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7934. if only type is passed as parameter, all listeners registered with that type will be removed.
  7935. !#zh
  7936. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7937. @param type A string representing the event type being removed.
  7938. @param callback The callback to remove.
  7939. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7940. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7941. If not specified, useCapture defaults to false. If a callback was registered twice,
  7942. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7943. does not affect a non-capturing version of the same listener, and vice versa.
  7944. @example
  7945. ```js
  7946. // register touchEnd eventListener
  7947. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7948. cc.log("this is callback");
  7949. }, node);
  7950. // remove touch end event listener
  7951. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7952. // remove all touch end event listeners
  7953. node.off(cc.Node.EventType.TOUCH_END);
  7954. ```
  7955. */
  7956. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7957. /**
  7958. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7959. This is not for removing all listeners in the current event target,
  7960. and this is not for removing all listeners the target parameter have registered.
  7961. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7962. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7963. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7964. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7965. @param target The target to be searched for all related listeners
  7966. */
  7967. targetOff(target: any): void;
  7968. /**
  7969. !#en
  7970. Register an callback of a specific event type on the EventTarget,
  7971. the callback will remove itself after the first time it is triggered.
  7972. !#zh
  7973. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7974. @param type A string representing the event type to listen for.
  7975. @param callback The callback that will be invoked when the event is dispatched.
  7976. The callback is ignored if it is a duplicate (the callbacks are unique).
  7977. @param target The target (this object) to invoke the callback, can be null
  7978. @param useCapture When set to true, the capture argument prevents callback
  7979. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7980. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7981. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7982. @example
  7983. ```js
  7984. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7985. cc.log("this is callback");
  7986. }, node);
  7987. ```
  7988. */
  7989. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7990. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7991. /**
  7992. !#en
  7993. Dispatches an event into the event flow.
  7994. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7995. !#zh 分发事件到事件流中。
  7996. @param event The Event object that is dispatched into the event flow
  7997. */
  7998. dispatchEvent(event: Event): void;
  7999. /**
  8000. !#en
  8001. Send an event to this object directly, this method will not propagate the event to any other objects.
  8002. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  8003. !#zh
  8004. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  8005. @param message the message to send
  8006. @param detail whatever argument the message needs
  8007. */
  8008. emit(message: string, detail?: any): void;
  8009. }
  8010. /** !#en Base class of all kinds of events.
  8011. !#zh 包含事件相关信息的对象。 */
  8012. export class Event {
  8013. /**
  8014. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  8015. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  8016. */
  8017. constructor(type: string, bubbles: boolean);
  8018. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  8019. !#zh 事件类型。 */
  8020. type: string;
  8021. /** !#en Indicate whether the event bubbles up through the tree or not.
  8022. !#zh 表示该事件是否进行冒泡。 */
  8023. bubbles: boolean;
  8024. /** !#en A reference to the target to which the event was originally dispatched.
  8025. !#zh 最初事件触发的目标 */
  8026. target: any;
  8027. /** !#en A reference to the currently registered target for the event.
  8028. !#zh 当前目标 */
  8029. currentTarget: any;
  8030. /** !#en
  8031. Indicates which phase of the event flow is currently being evaluated.
  8032. Returns an integer value represented by 4 constants:
  8033. - Event.NONE = 0
  8034. - Event.CAPTURING_PHASE = 1
  8035. - Event.AT_TARGET = 2
  8036. - Event.BUBBLING_PHASE = 3
  8037. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  8038. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  8039. !#zh 事件阶段 */
  8040. eventPhase: number;
  8041. /**
  8042. !#en Reset the event for being stored in the object pool.
  8043. !#zh 重置对象池中存储的事件。
  8044. */
  8045. unuse(): string;
  8046. /**
  8047. !#en Reuse the event for being used again by the object pool.
  8048. !#zh 用于对象池再次使用的事件。
  8049. */
  8050. reuse(): string;
  8051. /**
  8052. !#en Stops propagation for current event.
  8053. !#zh 停止传递当前事件。
  8054. */
  8055. stopPropagation(): void;
  8056. /**
  8057. !#en Stops propagation for current event immediately,
  8058. the event won't even be dispatched to the listeners attached in the current target.
  8059. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  8060. */
  8061. stopPropagationImmediate(): void;
  8062. /**
  8063. !#en Checks whether the event has been stopped.
  8064. !#zh 检查该事件是否已经停止传递.
  8065. */
  8066. isStopped(): boolean;
  8067. /**
  8068. !#en
  8069. <p>
  8070. Gets current target of the event <br/>
  8071. note: It only be available when the event listener is associated with node. <br/>
  8072. It returns 0 when the listener is associated with fixed priority.
  8073. </p>
  8074. !#zh 获取当前目标节点
  8075. */
  8076. getCurrentTarget(): Node;
  8077. /**
  8078. !#en Gets the event type.
  8079. !#zh 获取事件类型
  8080. */
  8081. getType(): string;
  8082. /** !#en Code for event without type.
  8083. !#zh 没有类型的事件 */
  8084. static NO_TYPE: string;
  8085. /** !#en The type code of Touch event.
  8086. !#zh 触摸事件类型 */
  8087. static TOUCH: string;
  8088. /** !#en The type code of Mouse event.
  8089. !#zh 鼠标事件类型 */
  8090. static MOUSE: string;
  8091. /** !#en The type code of Keyboard event.
  8092. !#zh 键盘事件类型 */
  8093. static KEYBOARD: string;
  8094. /** !#en The type code of Acceleration event.
  8095. !#zh 加速器事件类型 */
  8096. static ACCELERATION: string;
  8097. /** !#en Events not currently dispatched are in this phase
  8098. !#zh 尚未派发事件阶段 */
  8099. static NONE: number;
  8100. /** !#en
  8101. The capturing phase comprises the journey from the root to the last node before the event target's node
  8102. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8103. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  8104. static CAPTURING_PHASE: number;
  8105. /** !#en
  8106. The target phase comprises only the event target node
  8107. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8108. !#zh 目标阶段仅包括事件目标节点。 */
  8109. static AT_TARGET: number;
  8110. /** !#en
  8111. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  8112. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8113. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  8114. static BUBBLING_PHASE: number;
  8115. }
  8116. /** !#en The System event, it currently supports the key events and accelerometer events
  8117. !#zh 系统事件,它目前支持按键事件和重力感应事件 */
  8118. export class SystemEvent extends EventTarget {
  8119. /**
  8120. !#en whether enable accelerometer event
  8121. !#zh 是否启用加速度计事件
  8122. @param isEnable isEnable
  8123. */
  8124. setAccelerometerEnabled(isEnable: boolean): void;
  8125. /**
  8126. !#en set accelerometer interval value
  8127. !#zh 设置加速度计间隔值
  8128. @param interval interval
  8129. */
  8130. setAccelerometerInterval(interval: number): void;
  8131. }
  8132. /** !#en
  8133. <p>
  8134. The base class of event listener. <br/>
  8135. If you need custom listener which with different callback, you need to inherit this class. <br/>
  8136. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  8137. EventListenerTouchOneByOne, EventListenerCustom.
  8138. </p>
  8139. !#zh
  8140. 封装用户的事件处理逻辑。
  8141. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  8142. export class EventListener {
  8143. /**
  8144. Constructor
  8145. @param type type
  8146. @param listenerID listenerID
  8147. @param callback callback
  8148. */
  8149. constructor(type: number, listenerID: number, callback: number);
  8150. /**
  8151. !#en Checks whether the listener is available.
  8152. !#zh 检测监听器是否有效
  8153. */
  8154. checkAvailable(): boolean;
  8155. /**
  8156. !#en Clones the listener, its subclasses have to override this method.
  8157. !#zh 克隆监听器,它的子类必须重写此方法。
  8158. */
  8159. clone(): EventListener;
  8160. /**
  8161. !#en Enables or disables the listener
  8162. !#zh 启用或禁用监听器。
  8163. @param enabled enabled
  8164. */
  8165. setEnabled(enabled: boolean): void;
  8166. /**
  8167. !#en Checks whether the listener is enabled
  8168. !#zh 检查监听器是否可用。
  8169. */
  8170. isEnabled(): boolean;
  8171. /** !#en The type code of unknown event listener.
  8172. !#zh 未知的事件监听器类型 */
  8173. static UNKNOWN: number;
  8174. /** !#en The type code of keyboard event listener.
  8175. !#zh 键盘事件监听器类型 */
  8176. static KEYBOARD: number;
  8177. /** !#en The type code of acceleration event listener.
  8178. !#zh 加速器事件监听器类型 */
  8179. static ACCELERATION: number;
  8180. /**
  8181. !#en
  8182. Create a EventListener object with configuration including the event type, handlers and other parameters.
  8183. In handlers, this refer to the event listener object itself.
  8184. You can also pass custom parameters in the configuration object,
  8185. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  8186. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  8187. @param argObj a json object
  8188. @example
  8189. ```js
  8190. // Create KEYBOARD EventListener.
  8191. cc.EventListener.create({
  8192. event: cc.EventListener.KEYBOARD,
  8193. onKeyPressed: function (keyCode, event) {
  8194. cc.log('pressed key: ' + keyCode);
  8195. },
  8196. onKeyReleased: function (keyCode, event) {
  8197. cc.log('released key: ' + keyCode);
  8198. }
  8199. });
  8200. // Create ACCELERATION EventListener.
  8201. cc.EventListener.create({
  8202. event: cc.EventListener.ACCELERATION,
  8203. callback: function (acc, event) {
  8204. cc.log('acc: ' + keyCode);
  8205. }
  8206. });
  8207. ```
  8208. */
  8209. static create(argObj: any): EventListener;
  8210. }
  8211. /** !#en
  8212. This class has been deprecated, please use cc.systemEvent or cc.EventTarget instead. See [Listen to and launch events](../../../manual/en/scripting/events.md) for details.<br>
  8213. <br>
  8214. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
  8215. The EventListener list is managed in such way so that event listeners can be added and removed
  8216. while events are being dispatched.
  8217. !#zh
  8218. 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。<br>
  8219. <br>
  8220. 事件管理器,它主要管理事件监听器注册和派发系统事件。 */
  8221. export class eventManager {
  8222. /**
  8223. !#en Pauses all listeners which are associated the specified target.
  8224. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  8225. @param node node
  8226. @param recursive recursive
  8227. */
  8228. static pauseTarget(node: Node, recursive?: boolean): void;
  8229. /**
  8230. !#en Resumes all listeners which are associated the specified target.
  8231. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  8232. @param node node
  8233. @param recursive recursive
  8234. */
  8235. static resumeTarget(node: Node, recursive?: boolean): void;
  8236. /**
  8237. !#en Query whether the specified event listener id has been added.
  8238. !#zh 查询指定的事件 ID 是否存在
  8239. @param listenerID The listener id.
  8240. */
  8241. static hasEventListener(listenerID: string|number): boolean;
  8242. /**
  8243. !#en
  8244. <p>
  8245. Adds a event listener for a specified event.<br/>
  8246. if the parameter "nodeOrPriority" is a node,
  8247. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  8248. if the parameter "nodeOrPriority" is a Number,
  8249. it means to add a event listener for a specified event with the fixed priority.<br/>
  8250. </p>
  8251. !#zh
  8252. 将事件监听器添加到事件管理器中。<br/>
  8253. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  8254. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  8255. @param listener The listener of a specified event or a object of some event parameters.
  8256. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  8257. */
  8258. static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener;
  8259. /**
  8260. !#en Remove a listener.
  8261. !#zh 移除一个已添加的监听器。
  8262. @param listener an event listener or a registered node target
  8263. @example
  8264. ```js
  8265. // 1. remove eventManager add Listener;
  8266. var mouseListener1 = cc.eventManager.addListener({
  8267. event: cc.EventListener.MOUSE,
  8268. onMouseDown: function(keyCode, event){ },
  8269. onMouseUp: function(keyCode, event){ },
  8270. onMouseMove: function () { },
  8271. onMouseScroll: function () { }
  8272. }, node);
  8273. cc.eventManager.removeListener(mouseListener1);
  8274. // 2. remove eventListener create Listener;
  8275. var mouseListener2 = cc.EventListener.create({
  8276. event: cc.EventListener.MOUSE,
  8277. onMouseDown: function(keyCode, event){ },
  8278. onMouseUp: function(keyCode, event){ },
  8279. onMouseMove: function () { },
  8280. onMouseScroll: function () { }
  8281. });
  8282. cc.eventManager.removeListener(mouseListener2);
  8283. ```
  8284. */
  8285. static removeListener(listener: EventListener): void;
  8286. /**
  8287. !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  8288. !#zh
  8289. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  8290. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  8291. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  8292. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  8293. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  8294. 下列是目前存在监听器类型: <br/>
  8295. cc.EventListener.UNKNOWN <br/>
  8296. cc.EventListener.KEYBOARD <br/>
  8297. cc.EventListener.ACCELERATION,<br/>
  8298. @param listenerType listenerType or a node
  8299. @param recursive recursive
  8300. */
  8301. static removeListeners(listenerType: number|Node, recursive?: boolean): void;
  8302. /**
  8303. !#en Removes all listeners
  8304. !#zh 移除所有事件监听器。
  8305. */
  8306. static removeAllListeners(): void;
  8307. /**
  8308. !#en Sets listener's priority with fixed value.
  8309. !#zh 设置 FixedPriority 类型监听器的优先级。
  8310. @param listener listener
  8311. @param fixedPriority fixedPriority
  8312. */
  8313. static setPriority(listener: EventListener, fixedPriority: number): void;
  8314. /**
  8315. !#en Whether to enable dispatching events
  8316. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  8317. @param enabled enabled
  8318. */
  8319. static setEnabled(enabled: boolean): void;
  8320. /**
  8321. !#en Checks whether dispatching events is enabled
  8322. !#zh 检测事件管理器是否启用。
  8323. */
  8324. static isEnabled(): boolean;
  8325. }
  8326. /** !#en The touch event class
  8327. !#zh 封装了触摸相关的信息。 */
  8328. export class Touch {
  8329. /**
  8330. !#en Returns the current touch location in OpenGL coordinates.、
  8331. !#zh 获取当前触点位置。
  8332. */
  8333. getLocation(): Vec2;
  8334. /**
  8335. !#en Returns X axis location value.
  8336. !#zh 获取当前触点 X 轴位置。
  8337. */
  8338. getLocationX(): number;
  8339. /**
  8340. !#en Returns Y axis location value.
  8341. !#zh 获取当前触点 Y 轴位置。
  8342. */
  8343. getLocationY(): number;
  8344. /**
  8345. !#en Returns the previous touch location in OpenGL coordinates.
  8346. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  8347. */
  8348. getPreviousLocation(): Vec2;
  8349. /**
  8350. !#en Returns the start touch location in OpenGL coordinates.
  8351. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  8352. */
  8353. getStartLocation(): Vec2;
  8354. /**
  8355. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  8356. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  8357. */
  8358. getDelta(): Vec2;
  8359. /**
  8360. !#en Returns the current touch location in screen coordinates.
  8361. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  8362. */
  8363. getLocationInView(): Vec2;
  8364. /**
  8365. !#en Returns the previous touch location in screen coordinates.
  8366. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8367. */
  8368. getPreviousLocationInView(): Vec2;
  8369. /**
  8370. !#en Returns the start touch location in screen coordinates.
  8371. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8372. */
  8373. getStartLocationInView(): Vec2;
  8374. /**
  8375. !#en Returns the id of cc.Touch.
  8376. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  8377. */
  8378. getID(): number;
  8379. /**
  8380. !#en Sets information to touch.
  8381. !#zh 设置触摸相关的信息。用于监控触摸事件。
  8382. @param id id
  8383. @param x x
  8384. @param y y
  8385. */
  8386. setTouchInfo(id: number, x: number, y: number): void;
  8387. }
  8388. /** undefined */
  8389. export class Graphics extends _RendererUnderSG {
  8390. /** !#en
  8391. Current line width.
  8392. !#zh
  8393. 当前线条宽度 */
  8394. lineWidth: number;
  8395. /** !#en
  8396. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  8397. !#zh
  8398. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  8399. lineJoin: Graphics.LineJoin;
  8400. /** !#en
  8401. lineCap determines how the end points of every line are drawn.
  8402. !#zh
  8403. lineCap 指定如何绘制每一条线段末端。 */
  8404. lineCap: Graphics.LineCap;
  8405. /** !#en
  8406. stroke color
  8407. !#zh
  8408. 线段颜色 */
  8409. strokeColor: Color;
  8410. /** !#en
  8411. fill color
  8412. !#zh
  8413. 填充颜色 */
  8414. fillColor: Color;
  8415. /** !#en
  8416. Sets the miter limit ratio
  8417. !#zh
  8418. 设置斜接面限制比例 */
  8419. miterLimit: number;
  8420. /**
  8421. !#en Move path start point to (x,y).
  8422. !#zh 移动路径起点到坐标(x, y)
  8423. @param x The x axis of the coordinate for the end point.
  8424. @param y The y axis of the coordinate for the end point.
  8425. */
  8426. moveTo(x?: number, y?: number): void;
  8427. /**
  8428. !#en Adds a straight line to the path
  8429. !#zh 绘制直线路径
  8430. @param x The x axis of the coordinate for the end point.
  8431. @param y The y axis of the coordinate for the end point.
  8432. */
  8433. lineTo(x?: number, y?: number): void;
  8434. /**
  8435. !#en Adds a cubic Bézier curve to the path
  8436. !#zh 绘制三次贝赛尔曲线路径
  8437. @param c1x The x axis of the coordinate for the first control point.
  8438. @param c1y The y axis of the coordinate for first control point.
  8439. @param c2x The x axis of the coordinate for the second control point.
  8440. @param c2y The y axis of the coordinate for the second control point.
  8441. @param x The x axis of the coordinate for the end point.
  8442. @param y The y axis of the coordinate for the end point.
  8443. */
  8444. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  8445. /**
  8446. !#en Adds a quadratic Bézier curve to the path
  8447. !#zh 绘制二次贝赛尔曲线路径
  8448. @param cx The x axis of the coordinate for the control point.
  8449. @param cy The y axis of the coordinate for the control point.
  8450. @param x The x axis of the coordinate for the end point.
  8451. @param y The y axis of the coordinate for the end point.
  8452. */
  8453. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  8454. /**
  8455. !#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).
  8456. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  8457. @param cx The x axis of the coordinate for the center point.
  8458. @param cy The y axis of the coordinate for the center point.
  8459. @param r The arc's radius.
  8460. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  8461. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  8462. @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.
  8463. */
  8464. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void;
  8465. /**
  8466. !#en Adds an ellipse to the path.
  8467. !#zh 绘制椭圆路径。
  8468. @param cx The x axis of the coordinate for the center point.
  8469. @param cy The y axis of the coordinate for the center point.
  8470. @param rx The ellipse's x-axis radius.
  8471. @param ry The ellipse's y-axis radius.
  8472. */
  8473. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  8474. /**
  8475. !#en Adds an circle to the path.
  8476. !#zh 绘制圆形路径。
  8477. @param cx The x axis of the coordinate for the center point.
  8478. @param cy The y axis of the coordinate for the center point.
  8479. @param r The circle's radius.
  8480. */
  8481. circle(cx?: number, cy?: number, r?: number): void;
  8482. /**
  8483. !#en Adds an rectangle to the path.
  8484. !#zh 绘制矩形路径。
  8485. @param x The x axis of the coordinate for the rectangle starting point.
  8486. @param y The y axis of the coordinate for the rectangle starting point.
  8487. @param w The rectangle's width.
  8488. @param h The rectangle's height.
  8489. */
  8490. rect(x?: number, y?: number, w?: number, h?: number): void;
  8491. /**
  8492. !#en Adds an round corner rectangle to the path.
  8493. !#zh 绘制圆角矩形路径。
  8494. @param x The x axis of the coordinate for the rectangle starting point.
  8495. @param y The y axis of the coordinate for the rectangle starting point.
  8496. @param w The rectangles width.
  8497. @param h The rectangle's height.
  8498. @param r The radius of the rectangle.
  8499. */
  8500. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  8501. /**
  8502. !#en Draws a filled rectangle.
  8503. !#zh 绘制填充矩形。
  8504. @param x The x axis of the coordinate for the rectangle starting point.
  8505. @param y The y axis of the coordinate for the rectangle starting point.
  8506. @param w The rectangle's width.
  8507. @param h The rectangle's height.
  8508. */
  8509. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  8510. /**
  8511. !#en Erasing any previously drawn content.
  8512. !#zh 擦除之前绘制的所有内容的方法。
  8513. @param clean Whether to clean the graphics inner cache.
  8514. */
  8515. clear(clean?: boolean): void;
  8516. /**
  8517. !#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.
  8518. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  8519. */
  8520. close(): void;
  8521. /**
  8522. !#en Strokes the current or given path with the current stroke style.
  8523. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  8524. */
  8525. stroke(): void;
  8526. /**
  8527. !#en Fills the current or given path with the current fill style.
  8528. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  8529. */
  8530. fill(): void;
  8531. }
  8532. /** Loader for resource loading process. It's a singleton object. */
  8533. export class loader extends Pipeline {
  8534. /** The asset loader in cc.loader's pipeline, it's by default the first pipe.
  8535. It's used to identify an asset's type, and determine how to download it. */
  8536. static assetLoader: any;
  8537. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  8538. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  8539. You can add your own download function with addDownloadHandlers */
  8540. static downloader: any;
  8541. /** The downloader in cc.loader's pipeline, it's by default the third pipe.
  8542. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  8543. You can add your own download function with addLoadHandlers */
  8544. static loader: any;
  8545. /**
  8546. Gets a new XMLHttpRequest instance.
  8547. */
  8548. static getXMLHttpRequest(): XMLHttpRequest;
  8549. /**
  8550. Add custom supported types handler or modify existing type handler for download process.
  8551. @param extMap Custom supported types with corresponded handler
  8552. @example
  8553. ```js
  8554. cc.loader.addDownloadHandlers({
  8555. // This will match all url with `.scene` extension or all url with `scene` type
  8556. 'scene' : function (url, callback) {}
  8557. });
  8558. ```
  8559. */
  8560. static addDownloadHandlers(extMap: any): void;
  8561. /**
  8562. Add custom supported types handler or modify existing type handler for load process.
  8563. @param extMap Custom supported types with corresponded handler
  8564. @example
  8565. ```js
  8566. cc.loader.addLoadHandlers({
  8567. // This will match all url with `.scene` extension or all url with `scene` type
  8568. 'scene' : function (url, callback) {}
  8569. });
  8570. ```
  8571. */
  8572. static addLoadHandlers(extMap: any): void;
  8573. /**
  8574. Load resources with a progression callback and a complete callback.
  8575. The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}}
  8576. The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}}
  8577. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  8578. @param resources Url list in an array
  8579. @param progressCallback Callback invoked when progression change
  8580. @param completeCallback Callback invoked when all resources loaded
  8581. @example
  8582. ```js
  8583. cc.loader.load('a.png', function (err, tex) {
  8584. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  8585. });
  8586. cc.loader.load('http://example.com/a.png', function (err, tex) {
  8587. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  8588. });
  8589. cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  8590. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  8591. });
  8592. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  8593. if (errors) {
  8594. for (var i = 0; i < errors.length; i++) {
  8595. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  8596. }
  8597. }
  8598. var aTex = results.getContent('a.png');
  8599. var bJsonObj = results.getContent('b.json');
  8600. });
  8601. ```
  8602. */
  8603. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  8604. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  8605. /**
  8606. Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  8607. <br>
  8608. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8609. @param url Url of the target resource.
  8610. The url is relative to the "resources" folder, extensions must be omitted.
  8611. @param type Only asset of type will be loaded if this argument is supplied.
  8612. @param progressCallback Callback invoked when progression change.
  8613. @param completeCallback Callback invoked when the resource loaded.
  8614. @example
  8615. ```js
  8616. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  8617. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  8618. if (err) {
  8619. cc.error(err.message || err);
  8620. return;
  8621. }
  8622. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  8623. });
  8624. // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder
  8625. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  8626. if (err) {
  8627. cc.error(err.message || err);
  8628. return;
  8629. }
  8630. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  8631. });
  8632. ```
  8633. */
  8634. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8635. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  8636. static loadRes(url: string, type: typeof cc.Asset): void;
  8637. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8638. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  8639. static loadRes(url: string): void;
  8640. /**
  8641. This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url.
  8642. @param urls Array of URLs of the target resource.
  8643. The url is relative to the "resources" folder, extensions must be omitted.
  8644. @param type Only asset of type will be loaded if this argument is supplied.
  8645. @param progressCallback Callback invoked when progression change.
  8646. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8647. @example
  8648. ```js
  8649. // load the SpriteFrames from resources folder
  8650. var spriteFrames;
  8651. var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01'];
  8652. cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) {
  8653. if (err) {
  8654. cc.error(err);
  8655. return;
  8656. }
  8657. spriteFrames = assets;
  8658. // ...
  8659. });
  8660. ```
  8661. */
  8662. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8663. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  8664. static loadResArray(url: string[], type: typeof cc.Asset): void;
  8665. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8666. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  8667. static loadResArray(url: string[]): void;
  8668. /**
  8669. Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  8670. <br>
  8671. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8672. @param url Url of the target folder.
  8673. The url is relative to the "resources" folder, extensions must be omitted.
  8674. @param type Only asset of type will be loaded if this argument is supplied.
  8675. @param progressCallback Callback invoked when progression change.
  8676. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8677. @example
  8678. ```js
  8679. // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame
  8680. cc.loader.loadResDir('imgs/cocos', function (err, assets) {
  8681. if (err) {
  8682. cc.error(err);
  8683. return;
  8684. }
  8685. var texture = assets[0];
  8686. var spriteFrame = assets[1];
  8687. });
  8688. // load all textures in "resources/imgs/"
  8689. cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) {
  8690. var texture1 = textures[0];
  8691. var texture2 = textures[1];
  8692. });
  8693. // load all JSONs in "resources/data/"
  8694. cc.loader.loadResDir('data', function (err, objects, urls) {
  8695. var data = objects[0];
  8696. var url = urls[0];
  8697. });
  8698. ```
  8699. */
  8700. 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;
  8701. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8702. static loadResDir(url: string, type: typeof cc.Asset): void;
  8703. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8704. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8705. static loadResDir(url: string): void;
  8706. /**
  8707. Get resource data by id. <br>
  8708. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  8709. the url will be the unique identity of the resource.
  8710. After loaded, you can acquire them by passing the url to this API.
  8711. @param url url
  8712. @param type Only asset of type will be returned if this argument is supplied.
  8713. */
  8714. static getRes(url: string, type?: Function): any;
  8715. /**
  8716. !#en Get all resource dependencies of the requested asset in an array, including itself.
  8717. The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.<br>
  8718. The returned array stores the dependencies with their uuids, after retrieve dependencies,
  8719. you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.<br>
  8720. For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}}
  8721. Here is some examples:
  8722. !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。<br>
  8723. 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。<br>
  8724. 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码:
  8725. @param owner The owner asset or the resource url or the asset's uuid
  8726. @example
  8727. ```js
  8728. // Release all dependencies of a loaded prefab
  8729. var deps = cc.loader.getDependsRecursively(prefab);
  8730. cc.loader.release(deps);
  8731. // Retrieve all dependent textures
  8732. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8733. var textures = [];
  8734. for (var i = 0; i < deps.length; ++i) {
  8735. var item = cc.loader.getRes(deps[i]);
  8736. if (item instanceof cc.Texture2D) {
  8737. textures.push(item);
  8738. }
  8739. }
  8740. ```
  8741. */
  8742. static getDependsRecursively(owner: Asset|RawAsset|string): any[];
  8743. /**
  8744. !#en
  8745. Release the content of an asset or an array of assets by uuid.
  8746. Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content.
  8747. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  8748. In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances.
  8749. 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.
  8750. If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8751. !#zh
  8752. 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。
  8753. 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。
  8754. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  8755. 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。
  8756. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  8757. 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8758. @param asset asset
  8759. @example
  8760. ```js
  8761. // Release a texture which is no longer need
  8762. cc.loader.release(texture);
  8763. // Release all dependencies of a loaded prefab
  8764. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8765. cc.loader.release(deps);
  8766. // If there is no instance of this prefab in the scene, the prefab and its dependencies like textures, sprite frames, etc, will be freed up.
  8767. // If you have some other nodes share a texture in this prefab, you can skip it in two ways:
  8768. // 1. Forbid auto release a texture before release
  8769. cc.loader.setAutoRelease(texture2d, false);
  8770. // 2. Remove it from the dependencies array
  8771. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8772. var index = deps.indexOf(texture2d._uuid);
  8773. if (index !== -1)
  8774. deps.splice(index, 1);
  8775. cc.loader.release(deps);
  8776. ```
  8777. */
  8778. static release(asset: Asset|RawAsset|string|any[]): void;
  8779. /**
  8780. !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8781. !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8782. @param asset asset
  8783. */
  8784. static releaseAsset(asset: Asset): void;
  8785. /**
  8786. !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8787. !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8788. @param url url
  8789. @param type Only asset of type will be released if this argument is supplied.
  8790. */
  8791. static releaseRes(url: string, type?: Function): void;
  8792. /**
  8793. !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8794. !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8795. @param url url
  8796. @param type Only asset of type will be released if this argument is supplied.
  8797. */
  8798. static releaseResDir(url: string, type?: Function): void;
  8799. /**
  8800. !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8801. !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8802. */
  8803. static releaseAll(): void;
  8804. /**
  8805. !#en
  8806. Indicates whether to release the asset when loading a new scene.<br>
  8807. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8808. according to whether the previous scene checked the "Auto Release Assets" option.
  8809. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8810. will not be affected by that option, remain not released by default.<br>
  8811. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  8812. <br>
  8813. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8814. !#zh
  8815. 设置当场景切换时是否自动释放资源。<br>
  8816. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8817. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8818. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8819. <br>
  8820. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8821. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8822. @param autoRelease indicates whether should release automatically
  8823. @example
  8824. ```js
  8825. // auto release the texture event if "Auto Release Assets" disabled in current scene
  8826. cc.loader.setAutoRelease(texture2d, true);
  8827. // don't release the texture even if "Auto Release Assets" enabled in current scene
  8828. cc.loader.setAutoRelease(texture2d, false);
  8829. // first parameter can be url
  8830. cc.loader.setAutoRelease(audioUrl, false);
  8831. ```
  8832. */
  8833. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8834. /**
  8835. !#en
  8836. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  8837. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8838. according to whether the previous scene checked the "Auto Release Assets" option.
  8839. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8840. will not be affected by that option, remain not released by default.<br>
  8841. Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.<br>
  8842. <br>
  8843. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8844. !#zh
  8845. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  8846. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8847. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8848. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8849. <br>
  8850. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8851. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8852. @param autoRelease indicates whether should release automatically
  8853. @example
  8854. ```js
  8855. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  8856. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  8857. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  8858. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  8859. // don't release the Prefab and all the referenced assets
  8860. cc.loader.setAutoReleaseRecursively(prefab, false);
  8861. ```
  8862. */
  8863. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8864. /**
  8865. !#en
  8866. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  8867. <br>
  8868. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8869. !#zh
  8870. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  8871. <br>
  8872. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8873. @param assetOrUrl asset object or the raw asset's url
  8874. */
  8875. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  8876. }
  8877. /** !#en
  8878. LoadingItems is the queue of items which can flow them into the loading pipeline.</br>
  8879. Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.</br>
  8880. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  8881. Each item always contains the following property:</br>
  8882. - id: The identification of the item, usually it's identical to url</br>
  8883. - url: The url </br>
  8884. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  8885. - error: The error happened in pipeline will be stored in this property.</br>
  8886. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  8887. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  8888. - states: An object stores the states of each pipe the item go through, the state can be: Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  8889. </br>
  8890. Item can hold other custom properties.</br>
  8891. Each LoadingItems object will be destroyed for recycle after onComplete callback</br>
  8892. So please don't hold its reference for later usage, you can copy properties in it though.
  8893. !#zh
  8894. LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。</br>
  8895. 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
  8896. 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。</br>
  8897. 每个对象都会包含下列属性:</br>
  8898. - id:该对象的标识,通常与 url 相同。</br>
  8899. - url:路径 </br>
  8900. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  8901. - error:pipeline 中发生的错误将被保存在这个属性中。</br>
  8902. - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。</br>
  8903. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  8904. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  8905. </br>
  8906. 对象可容纳其他自定义属性。</br>
  8907. 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */
  8908. export class LoadingItems extends CallbacksInvoker {
  8909. /**
  8910. !#en This is a callback which will be invoked while an item flow out the pipeline.
  8911. You can pass the callback function in LoadingItems.create or set it later.
  8912. !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8913. @param completedCount The number of the items that are already completed.
  8914. @param totalCount The total number of the items.
  8915. @param item The latest item which flow out the pipeline.
  8916. @example
  8917. ```js
  8918. loadingItems.onProgress = function (completedCount, totalCount, item) {
  8919. var progress = (100 * completedCount / totalCount).toFixed(2);
  8920. cc.log(progress + '%');
  8921. }
  8922. ```
  8923. */
  8924. onProgress(completedCount: number, totalCount: number, item: any): void;
  8925. /**
  8926. !#en This is a callback which will be invoked while all items is completed,
  8927. You can pass the callback function in LoadingItems.create or set it later.
  8928. !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8929. @param errors All errored urls will be stored in this array, if no error happened, then it will be null
  8930. @param items All items.
  8931. @example
  8932. ```js
  8933. loadingItems.onComplete = function (errors, items) {
  8934. if (error)
  8935. cc.log('Completed with ' + errors.length + ' errors');
  8936. else
  8937. cc.log('Completed ' + items.totalCount + ' items');
  8938. }
  8939. ```
  8940. */
  8941. onComplete(errors: any[], items: LoadingItems): void;
  8942. /** !#en The map of all items.
  8943. !#zh 存储所有加载项的对象。 */
  8944. map: any;
  8945. /** !#en The map of completed items.
  8946. !#zh 存储已经完成的加载项。 */
  8947. completed: any;
  8948. /** !#en Total count of all items.
  8949. !#zh 所有加载项的总数。 */
  8950. totalCount: number;
  8951. /** !#en Total count of completed items.
  8952. !#zh 所有完成加载项的总数。 */
  8953. completedCount: number;
  8954. /** !#en Activated or not.
  8955. !#zh 是否启用。 */
  8956. active: boolean;
  8957. /**
  8958. !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible.
  8959. You can pass onProgress and onComplete callbacks to visualize the loading process.
  8960. !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。
  8961. 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。
  8962. @param pipeline The pipeline to process the queue.
  8963. @param urlList The items array.
  8964. @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}}
  8965. @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
  8966. @example
  8967. ```js
  8968. cc.LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
  8969. var progress = (100 * completedCount / totalCount).toFixed(2);
  8970. cc.log(progress + '%');
  8971. }, function (errors, items) {
  8972. if (errors) {
  8973. for (var i = 0; i < errors.length; ++i) {
  8974. cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i]));
  8975. }
  8976. }
  8977. else {
  8978. var result_a = items.getContent('a.png');
  8979. // ...
  8980. }
  8981. })
  8982. ```
  8983. */
  8984. static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems;
  8985. /**
  8986. !#en Retrieve the LoadingItems queue object for an item.
  8987. !#zh 通过 item 对象获取它的 LoadingItems 队列。
  8988. @param item The item to query
  8989. */
  8990. static getQueue(item: any): LoadingItems;
  8991. /**
  8992. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8993. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8994. @param item The item which has completed
  8995. */
  8996. static itemComplete(item: any): void;
  8997. /**
  8998. !#en Add urls to the LoadingItems queue.
  8999. !#zh 向一个 LoadingItems 队列添加加载项。
  9000. @param urlList The url list to be appended, the url can be object or string
  9001. */
  9002. append(urlList: any[]): any[];
  9003. /**
  9004. !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening.
  9005. !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。
  9006. */
  9007. allComplete(): void;
  9008. /**
  9009. !#en Check whether all items are completed.
  9010. !#zh 检查是否所有加载项都已经完成。
  9011. */
  9012. isCompleted(): boolean;
  9013. /**
  9014. !#en Check whether an item is completed.
  9015. !#zh 通过 id 检查指定加载项是否已经加载完成。
  9016. @param id The item's id.
  9017. */
  9018. isItemCompleted(id: string): boolean;
  9019. /**
  9020. !#en Check whether an item exists.
  9021. !#zh 通过 id 检查加载项是否存在。
  9022. @param id The item's id.
  9023. */
  9024. exists(id: string): boolean;
  9025. /**
  9026. !#en Returns the content of an internal item.
  9027. !#zh 通过 id 获取指定对象的内容。
  9028. @param id The item's id.
  9029. */
  9030. getContent(id: string): any;
  9031. /**
  9032. !#en Returns the error of an internal item.
  9033. !#zh 通过 id 获取指定对象的错误信息。
  9034. @param id The item's id.
  9035. */
  9036. getError(id: string): any;
  9037. /**
  9038. !#en Add a listener for an item, the callback will be invoked when the item is completed.
  9039. !#zh 监听加载项(通过 key 指定)的完成事件。
  9040. @param key key
  9041. @param callback can be null
  9042. @param target can be null
  9043. */
  9044. addListener(key: string, callback: Function, target: any): boolean;
  9045. /**
  9046. !#en
  9047. Check if the specified key has any registered callback. </br>
  9048. If a callback is also specified, it will only return true if the callback is registered.
  9049. !#zh
  9050. 检查指定的加载项是否有完成事件监听器。</br>
  9051. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。
  9052. @param key key
  9053. @param callback callback
  9054. @param target target
  9055. */
  9056. hasListener(key: string, callback?: Function, target?: any): boolean;
  9057. /**
  9058. !#en
  9059. Removes a listener. </br>
  9060. It will only remove when key, callback, target all match correctly.
  9061. !#zh
  9062. 移除指定加载项已经注册的完成事件监听器。</br>
  9063. 只会删除 key, callback, target 均匹配的监听器。
  9064. @param key key
  9065. @param callback callback
  9066. @param target target
  9067. */
  9068. remove(key: string, callback: Function, target: any): boolean;
  9069. /**
  9070. !#en
  9071. Removes all callbacks registered in a certain event
  9072. type or all callbacks registered with a certain target.
  9073. !#zh 删除指定目标的所有完成事件监听器。
  9074. @param key The event key to be removed or the target to be removed
  9075. */
  9076. removeAllListeners(key: string|any): void;
  9077. /**
  9078. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  9079. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  9080. @param id The item url
  9081. */
  9082. itemComplete(id: string): void;
  9083. /**
  9084. !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable.
  9085. !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。
  9086. */
  9087. destroy(): void;
  9088. }
  9089. /** !#en
  9090. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  9091. It's designed for loading process. so items should be urls, and the url will be the identity of each item during the process.</br>
  9092. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  9093. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  9094. Finally all items will flow out the pipeline and the process is finished.
  9095. !#zh
  9096. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  9097. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  9098. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  9099. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  9100. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  9101. export class Pipeline {
  9102. /**
  9103. !#en
  9104. Constructor, pass an array of pipes to construct a new Pipeline,
  9105. the pipes will be chained in the given order.</br>
  9106. A pipe is an object which must contain an `id` in string and a `handle` function,
  9107. the id must be unique in the pipeline.</br>
  9108. It can also include `async` property to identify whether it's an asynchronous process.
  9109. !#zh
  9110. 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。</br>
  9111. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。</br>
  9112. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  9113. @param pipes pipes
  9114. @example
  9115. ```js
  9116. var pipeline = new Pipeline([
  9117. {
  9118. id: 'Downloader',
  9119. handle: function (item, callback) {},
  9120. async: true
  9121. },
  9122. {id: 'Parser', handle: function (item) {}, async: false}
  9123. ]);
  9124. ```
  9125. */
  9126. constructor(pipes: any[]);
  9127. /**
  9128. !#en
  9129. Insert a new pipe at the given index of the pipeline. </br>
  9130. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  9131. !#zh
  9132. 在给定的索引位置插入一个新的 pipe。</br>
  9133. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  9134. @param pipe The pipe to be inserted
  9135. @param index The index to insert
  9136. */
  9137. insertPipe(pipe: any, index: number): void;
  9138. /**
  9139. !en
  9140. Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline.
  9141. !zh
  9142. 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  9143. @param refPipe An existing pipe in the pipeline.
  9144. @param newPipe The pipe to be inserted.
  9145. */
  9146. insertPipeAfter(refPipe: any, newPipe: any): void;
  9147. /**
  9148. !#en
  9149. Add a new pipe at the end of the pipeline. </br>
  9150. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  9151. !#zh
  9152. 添加一个新的 pipe 到 pipeline 尾部。 </br>
  9153. 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  9154. @param pipe The pipe to be appended
  9155. */
  9156. appendPipe(pipe: any): void;
  9157. /**
  9158. !#en
  9159. Let new items flow into the pipeline. </br>
  9160. Each item can be a simple url string or an object,
  9161. if it's an object, it must contain `id` property. </br>
  9162. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  9163. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  9164. The object can contain any supplementary property as you want. </br>
  9165. !#zh
  9166. 让新的 item 流入 pipeline 中。</br>
  9167. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  9168. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  9169. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  9170. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  9171. 该对象可以包含任何附加属性。
  9172. @param items items
  9173. @example
  9174. ```js
  9175. pipeline.flowIn([
  9176. 'res/Background.png',
  9177. {
  9178. id: 'res/scene.json',
  9179. type: 'scene',
  9180. name: 'scene',
  9181. skips: ['Downloader']
  9182. }
  9183. ]);
  9184. ```
  9185. */
  9186. flowIn(items: any[]): void;
  9187. /**
  9188. !#en
  9189. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  9190. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  9191. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  9192. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  9193. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  9194. !#zh
  9195. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  9196. 这个 API 的使用通常是为了加载依赖项。</br>
  9197. 例如:</br>
  9198. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  9199. @param urlList urlList
  9200. @param callback callback
  9201. */
  9202. flowInDeps(urlList: any[], callback: Function): any[];
  9203. /**
  9204. !#en
  9205. Copy the item states from one source item to all destination items. </br>
  9206. It's quite useful when a pipe generate new items from one source item,</br>
  9207. then you should flowIn these generated items into pipeline, </br>
  9208. but you probably want them to skip all pipes the source item already go through,</br>
  9209. you can achieve it with this API. </br>
  9210. </br>
  9211. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  9212. !#zh
  9213. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  9214. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  9215. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  9216. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  9217. 这个时候就可以使用这个 API。
  9218. @param srcItem The source item
  9219. @param dstItems A single destination item or an array of destination items
  9220. */
  9221. copyItemStates(srcItem: any, dstItems: any[]|any): void;
  9222. /**
  9223. !#en Returns whether the pipeline is flowing (contains item) currently.
  9224. !#zh 获取 pipeline 当前是否正在处理中。
  9225. */
  9226. isFlowing(): boolean;
  9227. /**
  9228. !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  9229. !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。
  9230. */
  9231. getItems(): LoadingItems;
  9232. /**
  9233. !#en Returns an item in pipeline.
  9234. !#zh 根据 id 获取一个 item
  9235. @param id The id of the item
  9236. */
  9237. getItem(id: any): any;
  9238. /**
  9239. !#en Removes an completed item in pipeline.
  9240. It will only remove the cache in the pipeline or loader, its dependencies won't be released.
  9241. cc.loader provided another method to completely cleanup the resource and its dependencies,
  9242. please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9243. !#zh 移除指定的已完成 item。
  9244. 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
  9245. cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9246. @param id The id of the item
  9247. */
  9248. removeItem(id: any): boolean;
  9249. /**
  9250. !#en Clear the current pipeline, this function will clean up the items.
  9251. !#zh 清空当前 pipeline,该函数将清理 items。
  9252. */
  9253. clear(): void;
  9254. }
  9255. /** undefined */
  9256. export class WorldManifold {
  9257. /** !#en
  9258. world contact point (point of intersection)
  9259. !#zh
  9260. 碰撞点集合 */
  9261. points: [Vec2];
  9262. /** !#en
  9263. world vector pointing from A to B
  9264. !#zh
  9265. 世界坐标系下由 A 指向 B 的向量 */
  9266. normal: Vec2;
  9267. }
  9268. /** !#en
  9269. A manifold point is a contact point belonging to a contact manifold.
  9270. It holds details related to the geometry and dynamics of the contact points.
  9271. Note: the impulses are used for internal caching and may not
  9272. provide reliable contact forces, especially for high speed collisions.
  9273. !#zh
  9274. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  9275. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  9276. export class ManifoldPoint {
  9277. /** !#en
  9278. The local point usage depends on the manifold type:
  9279. -e_circles: the local center of circleB
  9280. -e_faceA: the local center of circleB or the clip point of polygonB
  9281. -e_faceB: the clip point of polygonA
  9282. !#zh
  9283. 本地坐标点的用途取决于 manifold 的类型
  9284. - e_circles: circleB 的本地中心点
  9285. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  9286. - e_faceB: polygonB 的截取点 */
  9287. localPoint: Vec2;
  9288. /** !#en
  9289. Normal impulse.
  9290. !#zh
  9291. 法线冲量。 */
  9292. normalImpulse: number;
  9293. /** !#en
  9294. Tangent impulse.
  9295. !#zh
  9296. 切线冲量。 */
  9297. tangentImpulse: number;
  9298. }
  9299. /** undefined */
  9300. export class Manifold {
  9301. /** !#en
  9302. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  9303. !#zh
  9304. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  9305. type: number;
  9306. /** !#en
  9307. The local point usage depends on the manifold type:
  9308. -e_circles: the local center of circleA
  9309. -e_faceA: the center of faceA
  9310. -e_faceB: the center of faceB
  9311. !#zh
  9312. 用途取决于 manifold 类型
  9313. -e_circles: circleA 的本地中心点
  9314. -e_faceA: faceA 的本地中心点
  9315. -e_faceB: faceB 的本地中心点 */
  9316. localPoint: Vec2;
  9317. /** !#en
  9318. -e_circles: not used
  9319. -e_faceA: the normal on polygonA
  9320. -e_faceB: the normal on polygonB
  9321. !#zh
  9322. -e_circles: 没被使用到
  9323. -e_faceA: polygonA 的法向量
  9324. -e_faceB: polygonB 的法向量 */
  9325. localNormal: Vec2;
  9326. /** !#en
  9327. the points of contact.
  9328. !#zh
  9329. 接触点信息。 */
  9330. points: [ManifoldPoint];
  9331. }
  9332. /** !#en
  9333. Contact impulses for reporting.
  9334. !#zh
  9335. 用于返回给回调的接触冲量。 */
  9336. export class PhysicsImpulse {
  9337. /** !#en
  9338. Normal impulses.
  9339. !#zh
  9340. 法线方向的冲量 */
  9341. normalImpulses: void;
  9342. /** !#en
  9343. Tangent impulses
  9344. !#zh
  9345. 切线方向的冲量 */
  9346. tangentImpulses: void;
  9347. }
  9348. /** !#en
  9349. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  9350. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  9351. !#zh
  9352. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  9353. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  9354. export class PhysicsContact {
  9355. /**
  9356. !#en
  9357. Get the world manifold.
  9358. !#zh
  9359. 获取世界坐标系下的碰撞信息。
  9360. */
  9361. getWorldManifold(): WorldManifold;
  9362. /**
  9363. !#en
  9364. Get the manifold.
  9365. !#zh
  9366. 获取本地(局部)坐标系下的碰撞信息。
  9367. */
  9368. getManifold(): Manifold;
  9369. /**
  9370. !#en
  9371. Get the impulses.
  9372. Note: PhysicsImpulse can only used in onPostSolve callback.
  9373. !#zh
  9374. 获取冲量信息
  9375. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  9376. */
  9377. getImpulse(): PhysicsImpulse;
  9378. colliderA: Collider;
  9379. colliderB: Collider;
  9380. /** !#en
  9381. If set disabled to true, the contact will be ignored until contact end.
  9382. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  9383. !#zh
  9384. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  9385. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  9386. disabled: boolean;
  9387. /** !#en
  9388. Disabled contact for current time step or sub-step.
  9389. !#zh
  9390. 在当前时间步或子步中忽略此接触。 */
  9391. disabledOnce: boolean;
  9392. /**
  9393. !#en
  9394. Is this contact touching?
  9395. !#zh
  9396. 返回碰撞体是否已经接触到。
  9397. */
  9398. isTouching(): boolean;
  9399. /**
  9400. !#en
  9401. Set the desired tangent speed for a conveyor belt behavior.
  9402. !#zh
  9403. 为传送带设置期望的切线速度
  9404. @param tangentSpeed tangentSpeed
  9405. */
  9406. setTangentSpeed(tangentSpeed: number): void;
  9407. /**
  9408. !#en
  9409. Get the desired tangent speed.
  9410. !#zh
  9411. 获取切线速度
  9412. */
  9413. getTangentSpeed(): number;
  9414. /**
  9415. !#en
  9416. Override the default friction mixture. You can call this in onPreSolve callback.
  9417. !#zh
  9418. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  9419. @param friction friction
  9420. */
  9421. setFriction(friction: number): void;
  9422. /**
  9423. !#en
  9424. Get the friction.
  9425. !#zh
  9426. 获取当前摩擦力系数
  9427. */
  9428. getFriction(): number;
  9429. /**
  9430. !#en
  9431. Reset the friction mixture to the default value.
  9432. !#zh
  9433. 重置摩擦力系数到默认值
  9434. */
  9435. resetFriction(): void;
  9436. /**
  9437. !#en
  9438. Override the default restitution mixture. You can call this in onPreSolve callback.
  9439. !#zh
  9440. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  9441. @param restitution restitution
  9442. */
  9443. setRestitution(restitution: number): void;
  9444. /**
  9445. !#en
  9446. Get the restitution.
  9447. !#zh
  9448. 获取当前恢复系数
  9449. */
  9450. getRestitution(): number;
  9451. /**
  9452. !#en
  9453. Reset the restitution mixture to the default value.
  9454. !#zh
  9455. 重置恢复系数到默认值
  9456. */
  9457. resetRestitution(): void;
  9458. }
  9459. /** !#en
  9460. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  9461. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  9462. Physics manager distributes the collision information to each collision callback when collision is produced.
  9463. Note: You need first enable the collision listener in the rigidbody.
  9464. !#zh
  9465. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  9466. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  9467. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  9468. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */
  9469. export class PhysicsManager implements EventTarget {
  9470. /** !#en
  9471. The draw bits for drawing physics debug information.
  9472. !#zh
  9473. 指定物理系统需要绘制哪些调试信息。 */
  9474. static DrawBits: DrawBits;
  9475. /** !#en
  9476. The ratio transform between physics unit and pixel unit, generally is 32.
  9477. !#zh
  9478. 物理单位与像素单位互相转换的比率,一般是 32。 */
  9479. static PTM_RATIO: number;
  9480. /** !#en
  9481. The velocity iterations for the velocity constraint solver.
  9482. !#zh
  9483. 速度更新迭代数 */
  9484. static VELOCITY_ITERATIONS: number;
  9485. /** !#en
  9486. The position Iterations for the position constraint solver.
  9487. !#zh
  9488. 位置迭代更新数 */
  9489. static POSITION_ITERATIONS: number;
  9490. /** !#en
  9491. Specify the fixed time step.
  9492. Need enabledAccumulator to make it work.
  9493. !#zh
  9494. 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */
  9495. static FIXED_TIME_STEP: number;
  9496. /** !#en
  9497. Specify the max accumulator time.
  9498. Need enabledAccumulator to make it work.
  9499. !#zh
  9500. 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */
  9501. static MAX_ACCUMULATOR: number;
  9502. /** !#en
  9503. If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
  9504. And if the update dt is bigger than the time step, then will call step function several times.
  9505. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  9506. !#zh
  9507. 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
  9508. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */
  9509. enabledAccumulator: boolean;
  9510. /**
  9511. !#en
  9512. Test which collider contains the given world point
  9513. !#zh
  9514. 获取包含给定世界坐标系点的碰撞体
  9515. @param point the world point
  9516. */
  9517. testPoint(point: Vec2): PhysicsCollider;
  9518. /**
  9519. !#en
  9520. Test which colliders intersect the given world rect
  9521. !#zh
  9522. 获取与给定世界坐标系矩形相交的碰撞体
  9523. @param rect the world rect
  9524. */
  9525. testAABB(rect: Rect): [PhysicsCollider];
  9526. /**
  9527. !#en
  9528. Raycast the world for all colliders in the path of the ray.
  9529. The raycast ignores colliders that contain the starting point.
  9530. !#zh
  9531. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  9532. @param p1 start point of the raycast
  9533. @param p2 end point of the raycast
  9534. @param type optional, default is RayCastType.Closest
  9535. */
  9536. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult];
  9537. /**
  9538. !#en
  9539. Attach physics debug draw to camera
  9540. !#zh
  9541. 将物理的调试绘制信息附加到指定摄像机上
  9542. @param camera camera
  9543. */
  9544. attachDebugDrawToCamera(camera: Camera): void;
  9545. /**
  9546. !#en
  9547. Detach physics debug draw to camera
  9548. !#zh
  9549. 将物理的调试绘制信息从指定摄像机上移除
  9550. @param camera camera
  9551. */
  9552. detachDebugDrawFromCamera(camera: Camera): void;
  9553. /** !#en
  9554. Enabled the physics manager?
  9555. !#zh
  9556. 指定是否启用物理系统? */
  9557. enabled: boolean;
  9558. /** !#en
  9559. Debug draw flags.
  9560. !#zh
  9561. 设置调试绘制标志 */
  9562. debugDrawFlags: number;
  9563. /** !#en
  9564. The physics world gravity.
  9565. !#zh
  9566. 物理世界重力值 */
  9567. gravity: Vec2;
  9568. /**
  9569. !#en
  9570. Register an callback of a specific event type on the EventTarget.
  9571. !#zh
  9572. 注册事件目标的特定事件类型回调。
  9573. @param type A string representing the event type to listen for.
  9574. @param callback The callback that will be invoked when the event is dispatched.
  9575. The callback is ignored if it is a duplicate (the callbacks are unique).
  9576. @param target The target (this object) to invoke the callback, can be null
  9577. @param useCapture When set to true, the capture argument prevents callback
  9578. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9579. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9580. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9581. @example
  9582. ```js
  9583. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9584. cc.log("this is callback");
  9585. }, node);
  9586. ```
  9587. */
  9588. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9589. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9590. /**
  9591. !#en
  9592. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  9593. if only type is passed as parameter, all listeners registered with that type will be removed.
  9594. !#zh
  9595. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  9596. @param type A string representing the event type being removed.
  9597. @param callback The callback to remove.
  9598. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  9599. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  9600. If not specified, useCapture defaults to false. If a callback was registered twice,
  9601. one with capture and one without, each must be removed separately. Removal of a capturing callback
  9602. does not affect a non-capturing version of the same listener, and vice versa.
  9603. @example
  9604. ```js
  9605. // register touchEnd eventListener
  9606. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9607. cc.log("this is callback");
  9608. }, node);
  9609. // remove touch end event listener
  9610. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  9611. // remove all touch end event listeners
  9612. node.off(cc.Node.EventType.TOUCH_END);
  9613. ```
  9614. */
  9615. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  9616. /**
  9617. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  9618. This is not for removing all listeners in the current event target,
  9619. and this is not for removing all listeners the target parameter have registered.
  9620. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  9621. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  9622. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  9623. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  9624. @param target The target to be searched for all related listeners
  9625. */
  9626. targetOff(target: any): void;
  9627. /**
  9628. !#en
  9629. Register an callback of a specific event type on the EventTarget,
  9630. the callback will remove itself after the first time it is triggered.
  9631. !#zh
  9632. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  9633. @param type A string representing the event type to listen for.
  9634. @param callback The callback that will be invoked when the event is dispatched.
  9635. The callback is ignored if it is a duplicate (the callbacks are unique).
  9636. @param target The target (this object) to invoke the callback, can be null
  9637. @param useCapture When set to true, the capture argument prevents callback
  9638. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9639. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9640. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9641. @example
  9642. ```js
  9643. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  9644. cc.log("this is callback");
  9645. }, node);
  9646. ```
  9647. */
  9648. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9649. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9650. /**
  9651. !#en
  9652. Dispatches an event into the event flow.
  9653. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  9654. !#zh 分发事件到事件流中。
  9655. @param event The Event object that is dispatched into the event flow
  9656. */
  9657. dispatchEvent(event: Event): void;
  9658. /**
  9659. !#en
  9660. Send an event to this object directly, this method will not propagate the event to any other objects.
  9661. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  9662. !#zh
  9663. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  9664. @param message the message to send
  9665. @param detail whatever argument the message needs
  9666. */
  9667. emit(message: string, detail?: any): void;
  9668. }
  9669. /** undefined */
  9670. export enum DrawBits {
  9671. e_aabbBit = 0,
  9672. e_pairBit = 0,
  9673. e_centerOfMassBit = 0,
  9674. e_jointBit = 0,
  9675. e_shapeBit = 0,
  9676. }
  9677. /** undefined */
  9678. export class PhysicsRayCastResult {
  9679. /** !#en
  9680. The PhysicsCollider which intersects with the raycast
  9681. !#zh
  9682. 与射线相交的碰撞体 */
  9683. collider: PhysicsCollider;
  9684. /** !#en
  9685. The intersection point
  9686. !#zh
  9687. 射线与碰撞体相交的点 */
  9688. point: Vec2;
  9689. /** !#en
  9690. The normal vector at the point of intersection
  9691. !#zh
  9692. 射线与碰撞体相交的点的法向量 */
  9693. normal: Vec2;
  9694. /** !#en
  9695. The fraction of the raycast path at the point of intersection
  9696. !#zh
  9697. 射线与碰撞体相交的点占射线长度的分数 */
  9698. fraction: number;
  9699. }
  9700. /** !#en Enum for RigidBodyType.
  9701. !#zh 刚体类型 */
  9702. export enum RigidBodyType {
  9703. Static = 0,
  9704. Kinematic = 0,
  9705. Dynamic = 0,
  9706. Animated = 0,
  9707. }
  9708. /** !#en Enum for RayCastType.
  9709. !#zh 射线检测类型 */
  9710. export enum RayCastType {
  9711. Closest = 0,
  9712. Any = 0,
  9713. AllClosest = 0,
  9714. All = 0,
  9715. }
  9716. /** undefined */
  9717. export class RigidBody extends Component {
  9718. /** !#en
  9719. Should enabled contact listener?
  9720. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  9721. !#zh
  9722. 是否启用接触接听器。
  9723. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  9724. enabledContactListener: boolean;
  9725. /**
  9726. !#en
  9727. Collision callback.
  9728. Called when two collider begin to touch.
  9729. !#zh
  9730. 碰撞回调。
  9731. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  9732. @param contact contact information
  9733. @param selfCollider the collider belong to this rigidbody
  9734. @param otherCollider the collider belong to another rigidbody
  9735. */
  9736. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9737. /**
  9738. !#en
  9739. Collision callback.
  9740. Called when two collider cease to touch.
  9741. !#zh
  9742. 碰撞回调。
  9743. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  9744. @param contact contact information
  9745. @param selfCollider the collider belong to this rigidbody
  9746. @param otherCollider the collider belong to another rigidbody
  9747. */
  9748. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9749. /**
  9750. !#en
  9751. Collision callback.
  9752. This is called when a contact is updated.
  9753. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  9754. Note: this is called only for awake bodies.
  9755. Note: this is called even when the number of contact points is zero.
  9756. Note: this is not called for sensors.
  9757. !#zh
  9758. 碰撞回调。
  9759. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  9760. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  9761. 注意:回调只会为醒着的刚体调用。
  9762. 注意:接触点为零的时候也有可能被调用。
  9763. 注意:感知体(sensor)的回调不会被调用。
  9764. @param contact contact information
  9765. @param selfCollider the collider belong to this rigidbody
  9766. @param otherCollider the collider belong to another rigidbody
  9767. */
  9768. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9769. /**
  9770. !#en
  9771. Collision callback.
  9772. This is called after a contact is updated.
  9773. You can get the impulses from the contact in this callback.
  9774. !#zh
  9775. 碰撞回调。
  9776. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  9777. 你可以在这个回调中从接触信息中获取到冲量信息。
  9778. @param contact contact information
  9779. @param selfCollider the collider belong to this rigidbody
  9780. @param otherCollider the collider belong to another rigidbody
  9781. */
  9782. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9783. /** !#en
  9784. Is this a fast moving body that should be prevented from tunneling through
  9785. other moving bodies?
  9786. Note :
  9787. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  9788. - You should use this flag sparingly since it increases processing time.
  9789. !#zh
  9790. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  9791. 需要注意的是 :
  9792. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  9793. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  9794. bullet: boolean;
  9795. /** !#en
  9796. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  9797. !#zh
  9798. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  9799. type: RigidBodyType;
  9800. /** !#en
  9801. Set this flag to false if this body should never fall asleep.
  9802. Note that this increases CPU usage.
  9803. !#zh
  9804. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  9805. 需要注意这将使 CPU 占用率提高。 */
  9806. allowSleep: boolean;
  9807. /** !#en
  9808. Scale the gravity applied to this body.
  9809. !#zh
  9810. 缩放应用在此刚体上的重力值 */
  9811. gravityScale: number;
  9812. /** !#en
  9813. Linear damping is use to reduce the linear velocity.
  9814. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  9815. time step when the damping parameter is large.
  9816. !#zh
  9817. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9818. linearDamping: number;
  9819. /** !#en
  9820. Angular damping is use to reduce the angular velocity. The damping parameter
  9821. can be larger than 1 but the damping effect becomes sensitive to the
  9822. time step when the damping parameter is large.
  9823. !#zh
  9824. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9825. angularDamping: number;
  9826. /** !#en
  9827. The linear velocity of the body's origin in world co-ordinates.
  9828. !#zh
  9829. 刚体在世界坐标下的线性速度 */
  9830. linearVelocity: Vec2;
  9831. /** !#en
  9832. The angular velocity of the body.
  9833. !#zh
  9834. 刚体的角速度 */
  9835. angularVelocity: number;
  9836. /** !#en
  9837. Should this body be prevented from rotating?
  9838. !#zh
  9839. 是否禁止此刚体进行旋转 */
  9840. fixedRotation: boolean;
  9841. /** !#en
  9842. Is this body initially awake or sleeping?
  9843. !#zh
  9844. 是否立刻唤醒此刚体 */
  9845. awake: boolean;
  9846. /** !#en
  9847. Set the active state of the body. An inactive body is not
  9848. simulated and cannot be collided with or woken up.
  9849. If body is active, all fixtures will be added to the
  9850. broad-phase.
  9851. If body is inactive, all fixtures will be removed from
  9852. the broad-phase and all contacts will be destroyed.
  9853. Fixtures on an inactive body are implicitly inactive and will
  9854. not participate in collisions, ray-casts, or queries.
  9855. Joints connected to an inactive body are implicitly inactive.
  9856. !#zh
  9857. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  9858. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  9859. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  9860. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  9861. 链接到非激活状态下刚体的关节也是非激活的。 */
  9862. active: boolean;
  9863. /**
  9864. !#en
  9865. Gets a local point relative to the body's origin given a world point.
  9866. !#zh
  9867. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9868. @param worldPoint a point in world coordinates.
  9869. @param out optional, the receiving point
  9870. */
  9871. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9872. /**
  9873. !#en
  9874. Get the world coordinates of a point given the local coordinates.
  9875. !#zh
  9876. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  9877. @param localPoint a point in local coordinates.
  9878. @param out optional, the receiving point
  9879. */
  9880. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  9881. /**
  9882. !#en
  9883. Get the world coordinates of a vector given the local coordinates.
  9884. !#zh
  9885. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  9886. @param localVector a vector in world coordinates.
  9887. @param out optional, the receiving vector
  9888. */
  9889. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  9890. /**
  9891. !#en
  9892. Gets a local vector relative to the body's origin given a world vector.
  9893. !#zh
  9894. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9895. @param worldVector a vector in world coordinates.
  9896. @param out optional, the receiving vector
  9897. */
  9898. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  9899. /**
  9900. !#en
  9901. Get the world body origin position.
  9902. !#zh
  9903. 获取刚体世界坐标系下的原点值
  9904. @param out optional, the receiving point
  9905. */
  9906. getWorldPosition(out: Vec2): Vec2;
  9907. /**
  9908. !#en
  9909. Get the world body rotation angle.
  9910. !#zh
  9911. 获取刚体世界坐标系下的旋转值。
  9912. */
  9913. getWorldRotation(): number;
  9914. /**
  9915. !#en
  9916. Get the local position of the center of mass.
  9917. !#zh
  9918. 获取刚体本地坐标系下的质心
  9919. */
  9920. getLocalCenter(): Vec2;
  9921. /**
  9922. !#en
  9923. Get the world position of the center of mass.
  9924. !#zh
  9925. 获取刚体世界坐标系下的质心
  9926. */
  9927. getWorldCenter(): Vec2;
  9928. /**
  9929. !#en
  9930. Get the world linear velocity of a world point attached to this body.
  9931. !#zh
  9932. 获取刚体上指定点的线性速度
  9933. @param worldPoint a point in world coordinates.
  9934. @param out optional, the receiving point
  9935. */
  9936. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9937. /**
  9938. !#en
  9939. Get total mass of the body.
  9940. !#zh
  9941. 获取刚体的质量。
  9942. */
  9943. getMass(): number;
  9944. /**
  9945. !#en
  9946. Get the rotational inertia of the body about the local origin.
  9947. !#zh
  9948. 获取刚体本地坐标系下原点的旋转惯性
  9949. */
  9950. getInertia(): number;
  9951. /**
  9952. !#en
  9953. Get all the joints connect to the rigidbody.
  9954. !#zh
  9955. 获取链接到此刚体的所有关节
  9956. */
  9957. getJointList(): [Joint];
  9958. /**
  9959. !#en
  9960. Apply a force at a world point. If the force is not
  9961. applied at the center of mass, it will generate a torque and
  9962. affect the angular velocity.
  9963. !#zh
  9964. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  9965. @param force the world force vector.
  9966. @param point the world position.
  9967. @param wake also wake up the body.
  9968. */
  9969. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  9970. /**
  9971. !#en
  9972. Apply a force to the center of mass.
  9973. !#zh
  9974. 施加一个力到刚体上的质心上。
  9975. @param force the world force vector.
  9976. @param wake also wake up the body.
  9977. */
  9978. applyForceToCenter(force: Vec2, wake: boolean): void;
  9979. /**
  9980. !#en
  9981. Apply a torque. This affects the angular velocity.
  9982. !#zh
  9983. 施加一个扭矩力,将影响刚体的角速度
  9984. @param torque about the z-axis (out of the screen), usually in N-m.
  9985. @param wake also wake up the body
  9986. */
  9987. applyTorque(torque: number, wake: boolean): void;
  9988. /**
  9989. !#en
  9990. Apply a impulse at a world point, This immediately modifies the velocity.
  9991. If the impulse is not applied at the center of mass, it will generate a torque and
  9992. affect the angular velocity.
  9993. !#zh
  9994. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  9995. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  9996. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  9997. @param point the world position
  9998. @param wake alse wake up the body
  9999. */
  10000. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  10001. /**
  10002. !#en
  10003. Apply an angular impulse.
  10004. !#zh
  10005. 施加一个角速度冲量。
  10006. @param impulse the angular impulse in units of kg*m*m/s
  10007. @param wake also wake up the body
  10008. */
  10009. applyAngularImpulse(impulse: number, wake: boolean): void;
  10010. /**
  10011. !#en
  10012. Synchronize node's world position to box2d rigidbody's position.
  10013. If enableAnimated is true and rigidbody's type is Animated type,
  10014. will set linear velocity instead of directly set rigidbody's position.
  10015. !#zh
  10016. 同步节点的世界坐标到 box2d 刚体的坐标上。
  10017. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  10018. @param enableAnimated enableAnimated
  10019. */
  10020. syncPosition(enableAnimated: boolean): void;
  10021. /**
  10022. !#en
  10023. Synchronize node's world angle to box2d rigidbody's angle.
  10024. If enableAnimated is true and rigidbody's type is Animated type,
  10025. will set angular velocity instead of directly set rigidbody's angle.
  10026. !#zh
  10027. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  10028. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  10029. @param enableAnimated enableAnimated
  10030. */
  10031. syncRotation(enableAnimated: boolean): void;
  10032. }
  10033. /** !#en Key map for keyboard event
  10034. !#zh 键盘事件的按键值 */
  10035. export enum KEY {
  10036. none = 0,
  10037. back = 0,
  10038. menu = 0,
  10039. backspace = 0,
  10040. tab = 0,
  10041. enter = 0,
  10042. shift = 0,
  10043. ctrl = 0,
  10044. alt = 0,
  10045. pause = 0,
  10046. capslock = 0,
  10047. escape = 0,
  10048. space = 0,
  10049. pageup = 0,
  10050. pagedown = 0,
  10051. end = 0,
  10052. home = 0,
  10053. left = 0,
  10054. up = 0,
  10055. right = 0,
  10056. down = 0,
  10057. select = 0,
  10058. insert = 0,
  10059. Delete = 0,
  10060. a = 0,
  10061. b = 0,
  10062. c = 0,
  10063. d = 0,
  10064. e = 0,
  10065. f = 0,
  10066. g = 0,
  10067. h = 0,
  10068. i = 0,
  10069. j = 0,
  10070. k = 0,
  10071. l = 0,
  10072. m = 0,
  10073. n = 0,
  10074. o = 0,
  10075. p = 0,
  10076. q = 0,
  10077. r = 0,
  10078. s = 0,
  10079. t = 0,
  10080. u = 0,
  10081. v = 0,
  10082. w = 0,
  10083. x = 0,
  10084. y = 0,
  10085. z = 0,
  10086. num0 = 0,
  10087. num1 = 0,
  10088. num2 = 0,
  10089. num3 = 0,
  10090. num4 = 0,
  10091. num5 = 0,
  10092. num6 = 0,
  10093. num7 = 0,
  10094. num8 = 0,
  10095. num9 = 0,
  10096. '*' = 0,
  10097. '+' = 0,
  10098. '-' = 0,
  10099. numdel = 0,
  10100. '/' = 0,
  10101. f1 = 0,
  10102. f2 = 0,
  10103. f3 = 0,
  10104. f4 = 0,
  10105. f5 = 0,
  10106. f6 = 0,
  10107. f7 = 0,
  10108. f8 = 0,
  10109. f9 = 0,
  10110. f10 = 0,
  10111. f11 = 0,
  10112. f12 = 0,
  10113. numlock = 0,
  10114. scrolllock = 0,
  10115. ';' = 0,
  10116. semicolon = 0,
  10117. equal = 0,
  10118. '=' = 0,
  10119. ',' = 0,
  10120. comma = 0,
  10121. dash = 0,
  10122. '.' = 0,
  10123. period = 0,
  10124. forwardslash = 0,
  10125. grave = 0,
  10126. '[' = 0,
  10127. openbracket = 0,
  10128. backslash = 0,
  10129. ']' = 0,
  10130. closebracket = 0,
  10131. quote = 0,
  10132. dpadLeft = 0,
  10133. dpadRight = 0,
  10134. dpadUp = 0,
  10135. dpadDown = 0,
  10136. dpadCenter = 0,
  10137. }
  10138. /** Image formats */
  10139. export enum ImageFormat {
  10140. JPG = 0,
  10141. PNG = 0,
  10142. TIFF = 0,
  10143. WEBP = 0,
  10144. PVR = 0,
  10145. ETC = 0,
  10146. S3TC = 0,
  10147. ATITC = 0,
  10148. TGA = 0,
  10149. RAWDATA = 0,
  10150. UNKNOWN = 0,
  10151. getImageFormatByData = 0,
  10152. }
  10153. /** Predefined constants */
  10154. export enum macro {
  10155. INVALID_INDEX = 0,
  10156. NODE_TAG_INVALID = 0,
  10157. PI = 0,
  10158. PI2 = 0,
  10159. FLT_MAX = 0,
  10160. FLT_MIN = 0,
  10161. RAD = 0,
  10162. DEG = 0,
  10163. UINT_MAX = 0,
  10164. REPEAT_FOREVER = 0,
  10165. FLT_EPSILON = 0,
  10166. ONE = 0,
  10167. ZERO = 0,
  10168. SRC_ALPHA = 0,
  10169. SRC_ALPHA_SATURATE = 0,
  10170. SRC_COLOR = 0,
  10171. DST_ALPHA = 0,
  10172. DST_COLOR = 0,
  10173. ONE_MINUS_SRC_ALPHA = 0,
  10174. ONE_MINUS_SRC_COLOR = 0,
  10175. ONE_MINUS_DST_ALPHA = 0,
  10176. ONE_MINUS_DST_COLOR = 0,
  10177. ONE_MINUS_CONSTANT_ALPHA = 0,
  10178. ONE_MINUS_CONSTANT_COLOR = 0,
  10179. LINEAR = 0,
  10180. BLEND_DST = 0,
  10181. WEB_ORIENTATION_PORTRAIT = 0,
  10182. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  10183. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  10184. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  10185. ORIENTATION_PORTRAIT = 0,
  10186. ORIENTATION_LANDSCAPE = 0,
  10187. ORIENTATION_AUTO = 0,
  10188. VERTEX_ATTRIB_FLAG_NONE = 0,
  10189. VERTEX_ATTRIB_FLAG_POSITION = 0,
  10190. VERTEX_ATTRIB_FLAG_COLOR = 0,
  10191. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  10192. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  10193. GL_ALL = 0,
  10194. VERTEX_ATTRIB_POSITION = 0,
  10195. VERTEX_ATTRIB_COLOR = 0,
  10196. VERTEX_ATTRIB_TEX_COORDS = 0,
  10197. VERTEX_ATTRIB_MAX = 0,
  10198. UNIFORM_PMATRIX = 0,
  10199. UNIFORM_MVMATRIX = 0,
  10200. UNIFORM_MVPMATRIX = 0,
  10201. UNIFORM_TIME = 0,
  10202. UNIFORM_SINTIME = 0,
  10203. UNIFORM_COSTIME = 0,
  10204. UNIFORM_RANDOM01 = 0,
  10205. UNIFORM_SAMPLER = 0,
  10206. UNIFORM_MAX = 0,
  10207. SHADER_POSITION_TEXTURECOLOR = 0,
  10208. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  10209. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  10210. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  10211. SHADER_POSITION_COLOR = 0,
  10212. SHADER_SPRITE_POSITION_COLOR = 0,
  10213. SHADER_POSITION_TEXTURE = 0,
  10214. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  10215. SHADER_POSITION_TEXTUREA8COLOR = 0,
  10216. SHADER_POSITION_UCOLOR = 0,
  10217. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  10218. UNIFORM_PMATRIX_S = 0,
  10219. UNIFORM_MVMATRIX_S = 0,
  10220. UNIFORM_MVPMATRIX_S = 0,
  10221. UNIFORM_TIME_S = 0,
  10222. UNIFORM_SINTIME_S = 0,
  10223. UNIFORM_COSTIME_S = 0,
  10224. UNIFORM_RANDOM01_S = 0,
  10225. UNIFORM_SAMPLER_S = 0,
  10226. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  10227. ATTRIBUTE_NAME_COLOR = 0,
  10228. ATTRIBUTE_NAME_POSITION = 0,
  10229. ATTRIBUTE_NAME_TEX_COORD = 0,
  10230. ITEM_SIZE = 0,
  10231. CURRENT_ITEM = 0,
  10232. ZOOM_ACTION_TAG = 0,
  10233. NORMAL_TAG = 0,
  10234. SELECTED_TAG = 0,
  10235. DISABLE_TAG = 0,
  10236. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  10237. FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0,
  10238. DIRECTOR_STATS_POSITION = 0,
  10239. DIRECTOR_FPS_INTERVAL = 0,
  10240. COCOSNODE_RENDER_SUBPIXEL = 0,
  10241. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  10242. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  10243. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  10244. TEXTURE_NPOT_SUPPORT = 0,
  10245. USE_LA88_LABELS = 0,
  10246. SPRITE_DEBUG_DRAW = 0,
  10247. LABELBMFONT_DEBUG_DRAW = 0,
  10248. LABELATLAS_DEBUG_DRAW = 0,
  10249. ENABLE_STACKABLE_ACTIONS = 0,
  10250. ENABLE_GL_STATE_CACHE = 0,
  10251. TOUCH_TIMEOUT = 0,
  10252. BATCH_VERTEX_COUNT = 0,
  10253. ENABLE_GC_FOR_NATIVE_OBJECTS = 0,
  10254. ENABLE_TILEDMAP_CULLING = 0,
  10255. DOWNLOAD_MAX_CONCURRENT = 0,
  10256. ENABLE_TRANSPARENT_CANVAS = 0,
  10257. ENABLE_WEBGL_ANTIALIAS = 0,
  10258. ENABLE_CULLING = 0,
  10259. BLEND_SRC = 0,
  10260. }
  10261. /** The base class of most of all the objects in Fireball. */
  10262. export class Object {
  10263. /** !#en The name of the object.
  10264. !#zh 该对象的名称。 */
  10265. name: string;
  10266. /** !#en
  10267. Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)<br>
  10268. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  10269. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  10270. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  10271. but this is often caused by a particular logical requirements, which is not normally required.
  10272. !#zh
  10273. 表示该对象是否可用(被 destroy 后将不可用)。<br>
  10274. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */
  10275. isValid: boolean;
  10276. /**
  10277. !#en
  10278. Destroy this Object, and release all its own references to other objects.<br/>
  10279. Actual object destruction will delayed until before rendering.
  10280. From the next frame, this object is not usable any more.
  10281. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  10282. !#zh
  10283. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  10284. 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。
  10285. 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  10286. @example
  10287. ```js
  10288. obj.destroy();
  10289. ```
  10290. */
  10291. destroy(): boolean;
  10292. }
  10293. /** Bit mask that controls object states. */
  10294. export enum Flags {
  10295. DontSave = 0,
  10296. EditorOnly = 0,
  10297. }
  10298. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  10299. It's invalid on safari, QQbrowser and android browser */
  10300. export class screen {
  10301. /**
  10302. initialize
  10303. */
  10304. init(): void;
  10305. /**
  10306. return true if it's full now.
  10307. */
  10308. fullScreen(): boolean;
  10309. /**
  10310. change the screen to full mode.
  10311. @param element element
  10312. @param onFullScreenChange onFullScreenChange
  10313. */
  10314. requestFullScreen(element: Element, onFullScreenChange: Function): void;
  10315. /**
  10316. exit the full mode.
  10317. */
  10318. exitFullScreen(): boolean;
  10319. /**
  10320. Automatically request full screen with a touch/click event
  10321. @param element element
  10322. @param onFullScreenChange onFullScreenChange
  10323. */
  10324. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  10325. }
  10326. /** System variables */
  10327. export class sys {
  10328. /** English language code */
  10329. static LANGUAGE_ENGLISH: string;
  10330. /** Chinese language code */
  10331. static LANGUAGE_CHINESE: string;
  10332. /** French language code */
  10333. static LANGUAGE_FRENCH: string;
  10334. /** Italian language code */
  10335. static LANGUAGE_ITALIAN: string;
  10336. /** German language code */
  10337. static LANGUAGE_GERMAN: string;
  10338. /** Spanish language code */
  10339. static LANGUAGE_SPANISH: string;
  10340. /** Spanish language code */
  10341. static LANGUAGE_DUTCH: string;
  10342. /** Russian language code */
  10343. static LANGUAGE_RUSSIAN: string;
  10344. /** Korean language code */
  10345. static LANGUAGE_KOREAN: string;
  10346. /** Japanese language code */
  10347. static LANGUAGE_JAPANESE: string;
  10348. /** Hungarian language code */
  10349. static LANGUAGE_HUNGARIAN: string;
  10350. /** Portuguese language code */
  10351. static LANGUAGE_PORTUGUESE: string;
  10352. /** Arabic language code */
  10353. static LANGUAGE_ARABIC: string;
  10354. /** Norwegian language code */
  10355. static LANGUAGE_NORWEGIAN: string;
  10356. /** Polish language code */
  10357. static LANGUAGE_POLISH: string;
  10358. /** Turkish language code */
  10359. static LANGUAGE_TURKISH: string;
  10360. /** Ukrainian language code */
  10361. static LANGUAGE_UKRAINIAN: string;
  10362. /** Romanian language code */
  10363. static LANGUAGE_ROMANIAN: string;
  10364. /** Bulgarian language code */
  10365. static LANGUAGE_BULGARIAN: string;
  10366. /** Unknown language code */
  10367. static LANGUAGE_UNKNOWN: string;
  10368. static OS_IOS: string;
  10369. static OS_ANDROID: string;
  10370. static OS_WINDOWS: string;
  10371. static OS_MARMALADE: string;
  10372. static OS_LINUX: string;
  10373. static OS_BADA: string;
  10374. static OS_BLACKBERRY: string;
  10375. static OS_OSX: string;
  10376. static OS_WP8: string;
  10377. static OS_WINRT: string;
  10378. static OS_UNKNOWN: string;
  10379. static UNKNOWN: number;
  10380. static WIN32: number;
  10381. static LINUX: number;
  10382. static MACOS: number;
  10383. static ANDROID: number;
  10384. static IPHONE: number;
  10385. static IPAD: number;
  10386. static BLACKBERRY: number;
  10387. static NACL: number;
  10388. static EMSCRIPTEN: number;
  10389. static TIZEN: number;
  10390. static WINRT: number;
  10391. static WP8: number;
  10392. static MOBILE_BROWSER: number;
  10393. static DESKTOP_BROWSER: number;
  10394. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  10395. static EDITOR_PAGE: number;
  10396. /** Indicates whether executes in editor's main process (Electron's browser context) */
  10397. static EDITOR_CORE: number;
  10398. static WECHAT_GAME: number;
  10399. static QQ_PLAY: number;
  10400. /** BROWSER_TYPE_WECHAT */
  10401. static BROWSER_TYPE_WECHAT: string;
  10402. /** BROWSER_TYPE_WECHAT_GAME */
  10403. static BROWSER_TYPE_WECHAT_GAME: string;
  10404. /** BROWSER_TYPE_QQ_PLAY */
  10405. static BROWSER_TYPE_QQ_PLAY: string;
  10406. static BROWSER_TYPE_ANDROID: string;
  10407. static BROWSER_TYPE_IE: string;
  10408. static BROWSER_TYPE_QQ: string;
  10409. static BROWSER_TYPE_MOBILE_QQ: string;
  10410. static BROWSER_TYPE_UC: string;
  10411. /** uc third party integration. */
  10412. static BROWSER_TYPE_UCBS: string;
  10413. static BROWSER_TYPE_360: string;
  10414. static BROWSER_TYPE_BAIDU_APP: string;
  10415. static BROWSER_TYPE_BAIDU: string;
  10416. static BROWSER_TYPE_MAXTHON: string;
  10417. static BROWSER_TYPE_OPERA: string;
  10418. static BROWSER_TYPE_OUPENG: string;
  10419. static BROWSER_TYPE_MIUI: string;
  10420. static BROWSER_TYPE_FIREFOX: string;
  10421. static BROWSER_TYPE_SAFARI: string;
  10422. static BROWSER_TYPE_CHROME: string;
  10423. static BROWSER_TYPE_LIEBAO: string;
  10424. static BROWSER_TYPE_QZONE: string;
  10425. static BROWSER_TYPE_SOUGOU: string;
  10426. static BROWSER_TYPE_UNKNOWN: string;
  10427. /**
  10428. !#en
  10429. Get the battery level of current device, return 1.0 if failure.
  10430. !#zh
  10431. 获取当前设备的电池电量,如果电量无法获取,默认将返回 1
  10432. */
  10433. static getBatteryLevel(): number;
  10434. /**
  10435. !#en
  10436. Get the network type of current device, return cc.sys.NetworkType.LAN if failure.
  10437. !#zh
  10438. 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN
  10439. */
  10440. static getNetworkType(): NetworkType;
  10441. /** Is native ? This is set to be true in jsb auto. */
  10442. static isNative: boolean;
  10443. /** Is web browser ? */
  10444. static isBrowser: boolean;
  10445. /** Indicate whether system is mobile system */
  10446. static isMobile: boolean;
  10447. /** Indicate the running platform */
  10448. static platform: number;
  10449. /** Indicate the current language of the running system */
  10450. static language: string;
  10451. /** Indicate the running os name */
  10452. static os: string;
  10453. /** Indicate the running os version */
  10454. static osVersion: string;
  10455. /** Indicate the running os main version */
  10456. static osMainVersion: number;
  10457. /** Indicate the running browser type */
  10458. static browserType: string;
  10459. /** Indicate the running browser version */
  10460. static browserVersion: string;
  10461. /** Indicate the real pixel resolution of the whole game window */
  10462. static windowPixelResolution: Size;
  10463. /** cc.sys.localStorage is a local storage component. */
  10464. static localStorage: any;
  10465. /** The capabilities of the current platform */
  10466. static capabilities: any;
  10467. /**
  10468. Forces the garbage collection, only available in JSB
  10469. */
  10470. static garbageCollect(): void;
  10471. /**
  10472. Dumps rooted objects, only available in JSB
  10473. */
  10474. static dumpRoot(): void;
  10475. /**
  10476. Restart the JS VM, only available in JSB
  10477. */
  10478. static restartVM(): void;
  10479. /**
  10480. Clean a script in the JS VM, only available in JSB
  10481. @param jsfile jsfile
  10482. */
  10483. static cleanScript(jsfile: string): void;
  10484. /**
  10485. Check whether an object is valid,
  10486. In web engine, it will return true if the object exist
  10487. In native engine, it will return true if the JS object and the correspond native object are both valid
  10488. @param obj obj
  10489. */
  10490. static isObjectValid(obj: any): boolean;
  10491. /**
  10492. Dump system informations
  10493. */
  10494. static dump(): void;
  10495. /**
  10496. Open a url in browser
  10497. @param url url
  10498. */
  10499. static openURL(url: string): void;
  10500. /**
  10501. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  10502. */
  10503. static now(): number;
  10504. }
  10505. /** !#en
  10506. Network type enumeration
  10507. !#zh
  10508. 网络类型枚举 */
  10509. export enum NetworkType {
  10510. NONE = 0,
  10511. LAN = 0,
  10512. WWAN = 0,
  10513. }
  10514. /** cc.view is the singleton object which represents the game window.<br/>
  10515. It's main task include: <br/>
  10516. - Apply the design resolution policy<br/>
  10517. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  10518. - Manage the game view port which can be different with the window<br/>
  10519. - Manage the content scale and translation<br/>
  10520. <br/>
  10521. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  10522. the standard way to use it is by calling:<br/>
  10523. - cc.view.methodName(); <br/> */
  10524. export class View {
  10525. /**
  10526. <p>
  10527. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  10528. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  10529. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  10530. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  10531. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  10532. 5. Custom value, e.g: "480" <br/>
  10533. </p>
  10534. @param densityDPI densityDPI
  10535. */
  10536. setTargetDensityDPI(densityDPI: string): void;
  10537. /**
  10538. Returns the current target-densitydpi value of cc.view.
  10539. */
  10540. getTargetDensityDPI(): string;
  10541. /**
  10542. Sets whether resize canvas automatically when browser's size changed.<br/>
  10543. Useful only on web.
  10544. @param enabled Whether enable automatic resize with browser's resize event
  10545. */
  10546. resizeWithBrowserSize(enabled: boolean): void;
  10547. /**
  10548. Sets the callback function for cc.view's resize action,<br/>
  10549. this callback will be invoked before applying resolution policy, <br/>
  10550. so you can do any additional modifications within the callback.<br/>
  10551. Useful only on web.
  10552. @param callback The callback function
  10553. */
  10554. setResizeCallback(callback: Function|void): void;
  10555. /**
  10556. Sets the orientation of the game, it can be landscape, portrait or auto.
  10557. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  10558. cc.view will automatically rotate the game canvas using CSS.
  10559. Note that this function doesn't have any effect in native,
  10560. in native, you need to set the application orientation in native project settings
  10561. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  10562. */
  10563. setOrientation(orientation: number): void;
  10564. /**
  10565. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  10566. It's enabled by default, we strongly suggest you not to disable it.<br/>
  10567. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  10568. Only useful on web
  10569. @param enabled Enable automatic modification to "viewport" meta
  10570. */
  10571. adjustViewPort(enabled: boolean): void;
  10572. /**
  10573. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  10574. it takes effect only when you called setDesignResolutionPolicy<br/>
  10575. Only useful on web
  10576. @param enabled Enable or disable retina display
  10577. */
  10578. enableRetina(enabled: boolean): void;
  10579. /**
  10580. Check whether retina display is enabled.<br/>
  10581. Only useful on web
  10582. */
  10583. isRetinaEnabled(): boolean;
  10584. /**
  10585. !#en Whether to Enable on anti-alias
  10586. !#zh 控制抗锯齿是否开启
  10587. @param enabled Enable or not anti-alias
  10588. */
  10589. enableAntiAlias(enabled: boolean): void;
  10590. /**
  10591. !#en Returns whether the current enable on anti-alias
  10592. !#zh 返回当前是否抗锯齿
  10593. */
  10594. isAntiAliasEnabled(): boolean;
  10595. /**
  10596. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  10597. You can pass true as parameter to enable it and disable it by passing false.<br/>
  10598. Only useful on web
  10599. @param enabled Enable or disable auto full screen on mobile devices
  10600. */
  10601. enableAutoFullScreen(enabled: boolean): void;
  10602. /**
  10603. Check whether auto full screen is enabled.<br/>
  10604. Only useful on web
  10605. */
  10606. isAutoFullScreenEnabled(): boolean;
  10607. /**
  10608. Get whether render system is ready(no matter opengl or canvas),<br/>
  10609. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  10610. */
  10611. isViewReady(): boolean;
  10612. /**
  10613. Sets the resolution translate on View.
  10614. @param offsetLeft offsetLeft
  10615. @param offsetTop offsetTop
  10616. */
  10617. setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void;
  10618. /**
  10619. Returns the resolution translate on View
  10620. */
  10621. getContentTranslateLeftTop(): Size;
  10622. /**
  10623. Returns the frame size of the view.<br/>
  10624. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  10625. On web, it returns the size of the canvas's outer DOM element.
  10626. */
  10627. getFrameSize(): Size;
  10628. /**
  10629. On native, it sets the frame size of view.<br/>
  10630. On web, it sets the size of the canvas's outer DOM element.
  10631. @param width width
  10632. @param height height
  10633. */
  10634. setFrameSize(width: number, height: number): void;
  10635. /**
  10636. Returns the visible area size of the view port.
  10637. */
  10638. getVisibleSize(): Size;
  10639. /**
  10640. Returns the visible area size of the view port.
  10641. */
  10642. getVisibleSizeInPixel(): Size;
  10643. /**
  10644. Returns the visible origin of the view port.
  10645. */
  10646. getVisibleOrigin(): Vec2;
  10647. /**
  10648. Returns the visible origin of the view port.
  10649. */
  10650. getVisibleOriginInPixel(): Vec2;
  10651. /**
  10652. Returns whether developer can set content's scale factor.
  10653. */
  10654. canSetContentScaleFactor(): boolean;
  10655. /**
  10656. Returns the current resolution policy
  10657. */
  10658. getResolutionPolicy(): ResolutionPolicy;
  10659. /**
  10660. Sets the current resolution policy
  10661. @param resolutionPolicy resolutionPolicy
  10662. */
  10663. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  10664. /**
  10665. Sets the resolution policy with designed view size in points.<br/>
  10666. The resolution policy include: <br/>
  10667. [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/>
  10668. [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/>
  10669. [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/>
  10670. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  10671. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  10672. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  10673. @param width Design resolution width.
  10674. @param height Design resolution height.
  10675. @param resolutionPolicy The resolution policy desired
  10676. */
  10677. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10678. /**
  10679. Returns the designed size for the view.
  10680. Default resolution size is the same as 'getFrameSize'.
  10681. */
  10682. getDesignResolutionSize(): Size;
  10683. /**
  10684. Sets the container to desired pixel resolution and fit the game content to it.
  10685. This function is very useful for adaptation in mobile browsers.
  10686. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  10687. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  10688. But this API can be helpful to set a desired pixel resolution which is in between.
  10689. This API will do the following:
  10690. 1. Set viewport's width to the desired width in pixel
  10691. 2. Set body width to the exact pixel resolution
  10692. 3. The resolution policy will be reset with designed view size in points.
  10693. @param width Design resolution width.
  10694. @param height Design resolution height.
  10695. @param resolutionPolicy The resolution policy desired
  10696. */
  10697. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10698. /**
  10699. Sets view port rectangle with points.
  10700. @param x x
  10701. @param y y
  10702. @param w width
  10703. @param h height
  10704. */
  10705. setViewPortInPoints(x: number, y: number, w: number, h: number): void;
  10706. /**
  10707. Sets Scissor rectangle with points.
  10708. @param x x
  10709. @param y y
  10710. @param w w
  10711. @param h h
  10712. */
  10713. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  10714. /**
  10715. Returns whether GL_SCISSOR_TEST is enable
  10716. */
  10717. isScissorEnabled(): boolean;
  10718. /**
  10719. Returns the current scissor rectangle
  10720. */
  10721. getScissorRect(): Rect;
  10722. /**
  10723. Sets the name of the view
  10724. @param viewName viewName
  10725. */
  10726. setViewName(viewName: string): void;
  10727. /**
  10728. Returns the name of the view
  10729. */
  10730. getViewName(): string;
  10731. /**
  10732. Returns the view port rectangle.
  10733. */
  10734. getViewPortRect(): Rect;
  10735. /**
  10736. Returns scale factor of the horizontal direction (X axis).
  10737. */
  10738. getScaleX(): number;
  10739. /**
  10740. Returns scale factor of the vertical direction (Y axis).
  10741. */
  10742. getScaleY(): number;
  10743. /**
  10744. Returns device pixel ratio for retina display.
  10745. */
  10746. getDevicePixelRatio(): number;
  10747. /**
  10748. Returns the real location in view for a translation based on a related position
  10749. @param tx The X axis translation
  10750. @param ty The Y axis translation
  10751. @param relatedPos The related position object including "left", "top", "width", "height" informations
  10752. */
  10753. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  10754. }
  10755. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  10756. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  10757. export class ContainerStrategy {
  10758. /**
  10759. Manipulation before appling the strategy
  10760. @param view The target view
  10761. */
  10762. preApply(view: View): void;
  10763. /**
  10764. Function to apply this strategy
  10765. @param view view
  10766. @param designedResolution designedResolution
  10767. */
  10768. apply(view: View, designedResolution: Size): void;
  10769. /**
  10770. Manipulation after applying the strategy
  10771. @param view The target view
  10772. */
  10773. postApply(view: View): void;
  10774. }
  10775. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  10776. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  10777. export class ContentStrategy {
  10778. /**
  10779. Manipulation before applying the strategy
  10780. @param view The target view
  10781. */
  10782. preApply(view: View): void;
  10783. /**
  10784. Function to apply this strategy
  10785. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10786. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10787. @param view view
  10788. @param designedResolution designedResolution
  10789. */
  10790. apply(view: View, designedResolution: Size): any;
  10791. /**
  10792. Manipulation after applying the strategy
  10793. @param view The target view
  10794. */
  10795. postApply(view: View): void;
  10796. }
  10797. /** undefined */
  10798. export class EqualToFrame extends ContainerStrategy {
  10799. }
  10800. /** undefined */
  10801. export class ProportionalToFrame extends ContainerStrategy {
  10802. }
  10803. /** undefined */
  10804. export class EqualToWindow extends EqualToFrame {
  10805. }
  10806. /** undefined */
  10807. export class ProportionalToWindow extends ProportionalToFrame {
  10808. }
  10809. /** undefined */
  10810. export class OriginalContainer extends ContainerStrategy {
  10811. }
  10812. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  10813. its main task is to maintain the compatibility with Cocos2d-x</p> */
  10814. export class ResolutionPolicy {
  10815. /**
  10816. @param containerStg The container strategy
  10817. @param contentStg The content strategy
  10818. */
  10819. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  10820. /**
  10821. Manipulation before applying the resolution policy
  10822. @param view The target view
  10823. */
  10824. preApply(view: View): void;
  10825. /**
  10826. Function to apply this resolution policy
  10827. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10828. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10829. @param view The target view
  10830. @param designedResolution The user defined design resolution
  10831. */
  10832. apply(view: View, designedResolution: Size): any;
  10833. /**
  10834. Manipulation after appyling the strategy
  10835. @param view The target view
  10836. */
  10837. postApply(view: View): void;
  10838. /**
  10839. Setup the container's scale strategy
  10840. @param containerStg containerStg
  10841. */
  10842. setContainerStrategy(containerStg: ContainerStrategy): void;
  10843. /**
  10844. Setup the content's scale strategy
  10845. @param contentStg contentStg
  10846. */
  10847. setContentStrategy(contentStg: ContentStrategy): void;
  10848. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  10849. Distortion can occur, and the application may appear stretched or compressed. */
  10850. static EXACT_FIT: number;
  10851. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  10852. while maintaining the original aspect ratio of the application. */
  10853. static NO_BORDER: number;
  10854. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  10855. aspect ratio of the application. Borders can appear on two sides of the application. */
  10856. static SHOW_ALL: number;
  10857. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  10858. canvas so that it fits the aspect ratio of the device<br/>
  10859. no distortion will occur however you must make sure your application works on different<br/>
  10860. aspect ratios */
  10861. static FIXED_HEIGHT: number;
  10862. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  10863. canvas so that it fits the aspect ratio of the device<br/>
  10864. no distortion will occur however you must make sure your application works on different<br/>
  10865. aspect ratios */
  10866. static FIXED_WIDTH: number;
  10867. /** Unknow policy */
  10868. static UNKNOWN: number;
  10869. }
  10870. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  10871. it should represent the same rect as cc.view.getViewportRect() */
  10872. export class visibleRect {
  10873. /**
  10874. initialize
  10875. @param visibleRect visibleRect
  10876. */
  10877. init(visibleRect: Rect): void;
  10878. /** Top left coordinate of the screen related to the game scene. */
  10879. topLeft: Vec2;
  10880. /** Top right coordinate of the screen related to the game scene. */
  10881. topRight: Vec2;
  10882. /** Top center coordinate of the screen related to the game scene. */
  10883. top: Vec2;
  10884. /** Bottom left coordinate of the screen related to the game scene. */
  10885. bottomLeft: Vec2;
  10886. /** Bottom right coordinate of the screen related to the game scene. */
  10887. bottomRight: Vec2;
  10888. /** Bottom center coordinate of the screen related to the game scene. */
  10889. bottom: Vec2;
  10890. /** Center coordinate of the screen related to the game scene. */
  10891. center: Vec2;
  10892. /** Left center coordinate of the screen related to the game scene. */
  10893. left: Vec2;
  10894. /** Right center coordinate of the screen related to the game scene. */
  10895. right: Vec2;
  10896. /** Width of the screen. */
  10897. width: number;
  10898. /** Height of the screen. */
  10899. height: number;
  10900. }
  10901. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  10902. Subclasses should implement their own methods about how to invoke the callbacks. */
  10903. export class _CallbacksHandler {
  10904. /**
  10905. @param key key
  10906. @param callback callback
  10907. @param target can be null
  10908. */
  10909. add(key: string, callback: Function, target?: any): void;
  10910. /**
  10911. Check if the specified key has any registered callback. If a callback is also specified,
  10912. it will only return true if the callback is registered.
  10913. @param key key
  10914. @param callback callback
  10915. @param target target
  10916. */
  10917. has(key: string, callback?: Function, target?: any): boolean;
  10918. /**
  10919. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  10920. @param keyOrTarget The event key to be removed or the target to be removed
  10921. */
  10922. removeAll(keyOrTarget: string|any): void;
  10923. /**
  10924. @param key key
  10925. @param callback callback
  10926. @param target target
  10927. */
  10928. remove(key: string, callback: Function, target?: any): void;
  10929. }
  10930. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  10931. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  10932. export class CallbacksInvoker extends _CallbacksHandler {
  10933. /**
  10934. @param key key
  10935. @param p1 p1
  10936. @param p2 p2
  10937. @param p3 p3
  10938. @param p4 p4
  10939. @param p5 p5
  10940. */
  10941. invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void;
  10942. }
  10943. /** !#en Contains information collected during deserialization
  10944. !#zh 包含反序列化时的一些信息 */
  10945. export class Details {
  10946. /** list of the depends assets' uuid */
  10947. uuidList: string[];
  10948. /** the obj list whose field needs to load asset by uuid */
  10949. uuidObjList: any[];
  10950. /** the corresponding field name which referenced to the asset */
  10951. uuidPropList: string[];
  10952. reset(): void;
  10953. /**
  10954. @param obj obj
  10955. @param propName propName
  10956. @param uuid uuid
  10957. */
  10958. push(obj: any, propName: string, uuid: string): void;
  10959. }
  10960. /** undefined */
  10961. export class url {
  10962. /**
  10963. Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  10964. @param url url
  10965. @example
  10966. ```js
  10967. ---
  10968. var url = cc.url.raw("textures/myTexture.png");
  10969. console.log(url); // "resources/raw/textures/myTexture.png"
  10970. ```
  10971. */
  10972. static raw(url: string): string;
  10973. }
  10974. /** !#en
  10975. A cc.SpriteFrame has:<br/>
  10976. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  10977. - rectangle: A rectangle of the texture
  10978. !#zh
  10979. 一个 SpriteFrame 包含:<br/>
  10980. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  10981. - 矩形:在纹理中的矩形区域。 */
  10982. export class SpriteFrame extends Asset implements EventTarget {
  10983. /**
  10984. !#en
  10985. Constructor of SpriteFrame class.
  10986. !#zh
  10987. SpriteFrame 类的构造函数。
  10988. @param filename filename
  10989. @param rect rect
  10990. @param rotated Whether the frame is rotated in the texture
  10991. @param offset The offset of the frame in the texture
  10992. @param originalSize The size of the frame in the texture
  10993. */
  10994. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  10995. /** !#en Top border of the sprite
  10996. !#zh sprite 的顶部边框 */
  10997. insetTop: number;
  10998. /** !#en Bottom border of the sprite
  10999. !#zh sprite 的底部边框 */
  11000. insetBottom: number;
  11001. /** !#en Left border of the sprite
  11002. !#zh sprite 的左边边框 */
  11003. insetLeft: number;
  11004. /** !#en Right border of the sprite
  11005. !#zh sprite 的左边边框 */
  11006. insetRight: number;
  11007. /**
  11008. !#en Returns whether the texture have been loaded
  11009. !#zh 返回是否已加载纹理
  11010. */
  11011. textureLoaded(): boolean;
  11012. /**
  11013. Add a event listener for texture loaded event.
  11014. @param callback callback
  11015. @param target target
  11016. */
  11017. addLoadedEventListener(callback: Function, target: any): void;
  11018. /**
  11019. !#en Returns whether the sprite frame is rotated in the texture.
  11020. !#zh 获取 SpriteFrame 是否旋转
  11021. */
  11022. isRotated(): boolean;
  11023. /**
  11024. !#en Set whether the sprite frame is rotated in the texture.
  11025. !#zh 设置 SpriteFrame 是否旋转
  11026. @param bRotated bRotated
  11027. */
  11028. setRotated(bRotated: boolean): void;
  11029. /**
  11030. !#en Returns the rect of the sprite frame in the texture.
  11031. !#zh 获取 SpriteFrame 的纹理矩形区域
  11032. */
  11033. getRect(): Rect;
  11034. /**
  11035. !#en Sets the rect of the sprite frame in the texture.
  11036. !#zh 设置 SpriteFrame 的纹理矩形区域
  11037. @param rect rect
  11038. */
  11039. setRect(rect: Rect): void;
  11040. /**
  11041. !#en Returns the original size of the trimmed image.
  11042. !#zh 获取修剪前的原始大小
  11043. */
  11044. getOriginalSize(): Size;
  11045. /**
  11046. !#en Sets the original size of the trimmed image.
  11047. !#zh 设置修剪前的原始大小
  11048. @param size size
  11049. */
  11050. setOriginalSize(size: Size): void;
  11051. /**
  11052. !#en Returns the texture of the frame.
  11053. !#zh 获取使用的纹理实例
  11054. */
  11055. getTexture(): Texture2D;
  11056. /**
  11057. !#en Returns the offset of the frame in the texture.
  11058. !#zh 获取偏移量
  11059. */
  11060. getOffset(): Vec2;
  11061. /**
  11062. !#en Sets the offset of the frame in the texture.
  11063. !#zh 设置偏移量
  11064. @param offsets offsets
  11065. */
  11066. setOffset(offsets: Vec2): void;
  11067. /**
  11068. !#en Clone the sprite frame.
  11069. !#zh 克隆 SpriteFrame
  11070. */
  11071. clone(): SpriteFrame;
  11072. /**
  11073. !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  11074. !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame
  11075. @param textureOrTextureFile textureOrTextureFile
  11076. @param rect rect
  11077. @param rotated rotated
  11078. @param offset offset
  11079. @param originalSize originalSize
  11080. */
  11081. setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  11082. /**
  11083. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  11084. associated by user's custom Components in the scene, will not preload automatically.
  11085. These textures will be load when Sprite component is going to render the SpriteFrames.
  11086. You can call this method if you want to load the texture early.
  11087. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  11088. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  11089. @example
  11090. ```js
  11091. if (spriteFrame.textureLoaded()) {
  11092. this._onSpriteFrameLoaded();
  11093. }
  11094. else {
  11095. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  11096. spriteFrame.ensureLoadTexture();
  11097. }
  11098. ```
  11099. */
  11100. ensureLoadTexture(): void;
  11101. /**
  11102. !#en
  11103. 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.
  11104. !#zh
  11105. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  11106. @example
  11107. ```js
  11108. spriteFrame.clearTexture();
  11109. // when you need the SpriteFrame again...
  11110. spriteFrame.once('load', onSpriteFrameLoaded);
  11111. spriteFrame.ensureLoadTexture();
  11112. ```
  11113. */
  11114. clearTexture(): void;
  11115. /**
  11116. !#en
  11117. Register an callback of a specific event type on the EventTarget.
  11118. !#zh
  11119. 注册事件目标的特定事件类型回调。
  11120. @param type A string representing the event type to listen for.
  11121. @param callback The callback that will be invoked when the event is dispatched.
  11122. The callback is ignored if it is a duplicate (the callbacks are unique).
  11123. @param target The target (this object) to invoke the callback, can be null
  11124. @param useCapture When set to true, the capture argument prevents callback
  11125. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11126. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11127. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11128. @example
  11129. ```js
  11130. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11131. cc.log("this is callback");
  11132. }, node);
  11133. ```
  11134. */
  11135. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11136. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11137. /**
  11138. !#en
  11139. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11140. if only type is passed as parameter, all listeners registered with that type will be removed.
  11141. !#zh
  11142. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11143. @param type A string representing the event type being removed.
  11144. @param callback The callback to remove.
  11145. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11146. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11147. If not specified, useCapture defaults to false. If a callback was registered twice,
  11148. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11149. does not affect a non-capturing version of the same listener, and vice versa.
  11150. @example
  11151. ```js
  11152. // register touchEnd eventListener
  11153. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11154. cc.log("this is callback");
  11155. }, node);
  11156. // remove touch end event listener
  11157. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11158. // remove all touch end event listeners
  11159. node.off(cc.Node.EventType.TOUCH_END);
  11160. ```
  11161. */
  11162. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11163. /**
  11164. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11165. This is not for removing all listeners in the current event target,
  11166. and this is not for removing all listeners the target parameter have registered.
  11167. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11168. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11169. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11170. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11171. @param target The target to be searched for all related listeners
  11172. */
  11173. targetOff(target: any): void;
  11174. /**
  11175. !#en
  11176. Register an callback of a specific event type on the EventTarget,
  11177. the callback will remove itself after the first time it is triggered.
  11178. !#zh
  11179. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11180. @param type A string representing the event type to listen for.
  11181. @param callback The callback that will be invoked when the event is dispatched.
  11182. The callback is ignored if it is a duplicate (the callbacks are unique).
  11183. @param target The target (this object) to invoke the callback, can be null
  11184. @param useCapture When set to true, the capture argument prevents callback
  11185. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11186. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11187. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11188. @example
  11189. ```js
  11190. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11191. cc.log("this is callback");
  11192. }, node);
  11193. ```
  11194. */
  11195. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11196. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11197. /**
  11198. !#en
  11199. Dispatches an event into the event flow.
  11200. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11201. !#zh 分发事件到事件流中。
  11202. @param event The Event object that is dispatched into the event flow
  11203. */
  11204. dispatchEvent(event: Event): void;
  11205. /**
  11206. !#en
  11207. Send an event to this object directly, this method will not propagate the event to any other objects.
  11208. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11209. !#zh
  11210. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11211. @param message the message to send
  11212. @param detail whatever argument the message needs
  11213. */
  11214. emit(message: string, detail?: any): void;
  11215. }
  11216. /** This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data.<br/>
  11217. The created cc.Texture2D object will always have power-of-two dimensions.<br/>
  11218. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  11219. i.e. "contentSize" != (pixelsWidth, pixelsHight) and (maxS, maxT) != (1.0, 1.0).<br/>
  11220. Be aware that the content of the generated textures will be upside-down! */
  11221. export class Texture2D extends Asset implements EventTarget {
  11222. /** !#en
  11223. The url of the texture, this could be empty if the texture wasn't created via a file.
  11224. !#zh
  11225. 贴图文件的 url,当贴图不是由文件创建时值可能为空 */
  11226. url: string;
  11227. /** !#en
  11228. Texture width in pixel
  11229. !#zh
  11230. 贴图像素宽度 */
  11231. width: number;
  11232. /** !#en
  11233. Texture height in pixel
  11234. !#zh
  11235. 贴图像素高度 */
  11236. height: number;
  11237. /**
  11238. Update texture options, not available in Canvas render mode.
  11239. image, format, premultiplyAlpha can not be updated in native.
  11240. @param options options
  11241. */
  11242. update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  11243. /**
  11244. Get width in pixels.
  11245. */
  11246. getPixelWidth(): number;
  11247. /**
  11248. Get height of in pixels.
  11249. */
  11250. getPixelHeight(): number;
  11251. /**
  11252. Get content size.
  11253. */
  11254. getContentSize(): Size;
  11255. /**
  11256. Get content size in pixels.
  11257. */
  11258. getContentSizeInPixels(): Size;
  11259. /**
  11260. Init with HTML element.
  11261. @param element element
  11262. @example
  11263. ```js
  11264. var img = new Image();
  11265. img.src = dataURL;
  11266. texture.initWithElement(img);
  11267. texture.handleLoadedTexture();
  11268. ```
  11269. */
  11270. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  11271. /**
  11272. Intializes with a texture2d with data.
  11273. @param data data
  11274. @param pixelFormat pixelFormat
  11275. @param pixelsWidth pixelsWidth
  11276. @param pixelsHeight pixelsHeight
  11277. @param contentSize contentSize is deprecated and ignored
  11278. */
  11279. initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean;
  11280. /**
  11281. Initializes a texture from a UIImage object.
  11282. Extensions to make it easy to create a CCTexture2D object from an image file.
  11283. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  11284. @param uiImage uiImage
  11285. */
  11286. initWithImage(uiImage: HTMLImageElement): boolean;
  11287. /**
  11288. HTMLElement Object getter, available only on web.
  11289. In most case, it will return null, because we are recycling the dom image element for better loading performance and lower image cache memory usage.
  11290. */
  11291. getHtmlElementObj(): HTMLImageElement;
  11292. /**
  11293. Check whether texture is loaded.
  11294. */
  11295. isLoaded(): boolean;
  11296. /**
  11297. Handler of texture loaded event.
  11298. */
  11299. handleLoadedTexture(): void;
  11300. /**
  11301. Description of cc.Texture2D.
  11302. */
  11303. description(): string;
  11304. /**
  11305. !#en
  11306. Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br>
  11307. After destroy, this object is not usable any more.
  11308. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  11309. !#zh
  11310. 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)<br/>
  11311. 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  11312. */
  11313. destroy(): void;
  11314. /**
  11315. Pixel format of the texture.
  11316. */
  11317. getPixelFormat(): number;
  11318. /**
  11319. Whether or not the texture has their Alpha premultiplied,
  11320. support only in WebGl rendering mode.
  11321. */
  11322. hasPremultipliedAlpha(): boolean;
  11323. /**
  11324. Whether or not use mipmap, support only in WebGl rendering mode.
  11325. */
  11326. hasMipmaps(): boolean;
  11327. /**
  11328. Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  11329. 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}.
  11330. @param texParams texParams object or minFilter
  11331. @param magFilter magFilter
  11332. @param wrapS wrapS
  11333. @param wrapT wrapT
  11334. */
  11335. setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void;
  11336. /**
  11337. sets antialias texture parameters: <br/>
  11338. - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11339. - GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11340. supported only in native or WebGl rendering mode
  11341. */
  11342. setAntiAliasTexParameters(): void;
  11343. /**
  11344. Sets alias texture parameters: <br/>
  11345. GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11346. GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11347. supported only in native or WebGl rendering mode
  11348. */
  11349. setAliasTexParameters(): void;
  11350. /** Pixel format of the texture. */
  11351. pixelFormat: number;
  11352. /** Width in pixels. */
  11353. pixelWidth: number;
  11354. /** Height in pixels. */
  11355. pixelHeight: number;
  11356. /**
  11357. !#en
  11358. Register an callback of a specific event type on the EventTarget.
  11359. !#zh
  11360. 注册事件目标的特定事件类型回调。
  11361. @param type A string representing the event type to listen for.
  11362. @param callback The callback that will be invoked when the event is dispatched.
  11363. The callback is ignored if it is a duplicate (the callbacks are unique).
  11364. @param target The target (this object) to invoke the callback, can be null
  11365. @param useCapture When set to true, the capture argument prevents callback
  11366. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11367. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11368. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11369. @example
  11370. ```js
  11371. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11372. cc.log("this is callback");
  11373. }, node);
  11374. ```
  11375. */
  11376. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11377. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11378. /**
  11379. !#en
  11380. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11381. if only type is passed as parameter, all listeners registered with that type will be removed.
  11382. !#zh
  11383. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11384. @param type A string representing the event type being removed.
  11385. @param callback The callback to remove.
  11386. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11387. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11388. If not specified, useCapture defaults to false. If a callback was registered twice,
  11389. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11390. does not affect a non-capturing version of the same listener, and vice versa.
  11391. @example
  11392. ```js
  11393. // register touchEnd eventListener
  11394. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11395. cc.log("this is callback");
  11396. }, node);
  11397. // remove touch end event listener
  11398. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11399. // remove all touch end event listeners
  11400. node.off(cc.Node.EventType.TOUCH_END);
  11401. ```
  11402. */
  11403. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11404. /**
  11405. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11406. This is not for removing all listeners in the current event target,
  11407. and this is not for removing all listeners the target parameter have registered.
  11408. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11409. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11410. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11411. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11412. @param target The target to be searched for all related listeners
  11413. */
  11414. targetOff(target: any): void;
  11415. /**
  11416. !#en
  11417. Register an callback of a specific event type on the EventTarget,
  11418. the callback will remove itself after the first time it is triggered.
  11419. !#zh
  11420. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11421. @param type A string representing the event type to listen for.
  11422. @param callback The callback that will be invoked when the event is dispatched.
  11423. The callback is ignored if it is a duplicate (the callbacks are unique).
  11424. @param target The target (this object) to invoke the callback, can be null
  11425. @param useCapture When set to true, the capture argument prevents callback
  11426. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11427. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11428. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11429. @example
  11430. ```js
  11431. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11432. cc.log("this is callback");
  11433. }, node);
  11434. ```
  11435. */
  11436. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11437. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11438. /**
  11439. !#en
  11440. Dispatches an event into the event flow.
  11441. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11442. !#zh 分发事件到事件流中。
  11443. @param event The Event object that is dispatched into the event flow
  11444. */
  11445. dispatchEvent(event: Event): void;
  11446. /**
  11447. !#en
  11448. Send an event to this object directly, this method will not propagate the event to any other objects.
  11449. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11450. !#zh
  11451. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11452. @param message the message to send
  11453. @param detail whatever argument the message needs
  11454. */
  11455. emit(message: string, detail?: any): void;
  11456. }
  11457. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  11458. export class textureCache {
  11459. /**
  11460. Description
  11461. */
  11462. static description(): string;
  11463. /**
  11464. Returns an already created texture. Returns null if the texture doesn't exist.
  11465. @param textureKeyName textureKeyName
  11466. @example
  11467. ```js
  11468. ------------------
  11469. var key = cc.textureCache.getTextureForKey("hello.png");
  11470. ```
  11471. */
  11472. static getTextureForKey(textureKeyName: string): Texture2D;
  11473. /**
  11474. @param texture texture
  11475. @example
  11476. ```js
  11477. ---------------
  11478. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  11479. ```
  11480. */
  11481. static getTextureColors(texture: HTMLImageElement): any[];
  11482. /**
  11483. !#en get all textures
  11484. !#zh 获取所有贴图
  11485. */
  11486. static getAllTextures(): Texture2D[];
  11487. /**
  11488. <p>Purges the dictionary of loaded textures. <br />
  11489. Call this method if you receive the "Memory Warning" <br />
  11490. In the short term: it will free some resources preventing your app from being killed <br />
  11491. In the medium term: it will allocate more resources <br />
  11492. In the long term: it will be the same</p>
  11493. @example
  11494. ```js
  11495. --------
  11496. cc.textureCache.removeAllTextures();
  11497. ```
  11498. */
  11499. static removeAllTextures(): void;
  11500. /**
  11501. Deletes a texture from the cache given a texture.
  11502. @param texture texture
  11503. @example
  11504. ```js
  11505. -----
  11506. cc.textureCache.removeTexture(texture);
  11507. ```
  11508. */
  11509. static removeTexture(texture: HTMLImageElement): void;
  11510. /**
  11511. Deletes a texture from the cache given a its key name.
  11512. @param textureKeyName textureKeyName
  11513. @example
  11514. ```js
  11515. ------
  11516. cc.textureCache.removeTexture("hello.png");
  11517. ```
  11518. */
  11519. static removeTextureForKey(textureKeyName: string): void;
  11520. /**
  11521. Returns a Texture2D object given an file image <br />
  11522. If the file image was not previously loaded, it will create a new Texture2D
  11523. object and it will return it. It will use the filename as a key.
  11524. Otherwise it will return a reference of a previously loaded image. <br />
  11525. Supported image extensions: .png, .jpg, .gif
  11526. @param url url
  11527. @param cb cb
  11528. @param target target
  11529. @example
  11530. ```js
  11531. ----
  11532. cc.textureCache.addImage("hello.png");
  11533. ```
  11534. */
  11535. static addImage(url: string, cb: Function, target: any): Texture2D;
  11536. /**
  11537. Cache the image data.
  11538. @param path path
  11539. @param texture texture
  11540. */
  11541. static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void;
  11542. }
  11543. /** A base node for CCNode, it will:
  11544. - maintain scene hierarchy and active logic
  11545. - notifications if some properties changed
  11546. - define some interfaces shares between CCNode
  11547. - define machanisms for Enity Component Systems
  11548. - define prefab and serialize functions */
  11549. export class _BaseNode extends Object implements EventTarget {
  11550. /** !#en Name of node.
  11551. !#zh 该节点名称。 */
  11552. name: string;
  11553. /** !#en The uuid for editor, will be stripped before building project.
  11554. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  11555. uuid: string;
  11556. /** !#en All children nodes.
  11557. !#zh 节点的所有子节点。 */
  11558. children: Node[];
  11559. /** !#en All children nodes.
  11560. !#zh 节点的子节点数量。 */
  11561. childrenCount: number;
  11562. /** !#en
  11563. The local active state of this node.<br/>
  11564. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  11565. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  11566. !#zh
  11567. 当前节点的自身激活状态。<br/>
  11568. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  11569. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  11570. active: boolean;
  11571. /** !#en Indicates whether this node is active in the scene.
  11572. !#zh 表示此节点是否在场景中激活。 */
  11573. activeInHierarchy: boolean;
  11574. /** !#en Tag of node.
  11575. !#zh 节点标签。 */
  11576. tag: number;
  11577. /**
  11578. @param name name
  11579. */
  11580. constructor(name?: string);
  11581. /** !#en The parent of the node.
  11582. !#zh 该节点的父节点。 */
  11583. parent: Node;
  11584. /**
  11585. !#en
  11586. Properties configuration function </br>
  11587. All properties in attrs will be set to the node, </br>
  11588. when the setter of the node is available, </br>
  11589. the property will be set via setter function.</br>
  11590. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  11591. @param attrs Properties to be set to node
  11592. @example
  11593. ```js
  11594. var attrs = { key: 0, num: 100 };
  11595. node.attr(attrs);
  11596. ```
  11597. */
  11598. attr(attrs: any): void;
  11599. /**
  11600. !#en Returns a child from the container given its tag.
  11601. !#zh 通过标签获取节点的子节点。
  11602. @param aTag An identifier to find the child node.
  11603. @example
  11604. ```js
  11605. var child = node.getChildByTag(1001);
  11606. ```
  11607. */
  11608. getChildByTag(aTag: number): Node;
  11609. /**
  11610. !#en Returns a child from the container given its uuid.
  11611. !#zh 通过 uuid 获取节点的子节点。
  11612. @param uuid The uuid to find the child node.
  11613. @example
  11614. ```js
  11615. var child = node.getChildByUuid(uuid);
  11616. ```
  11617. */
  11618. getChildByUuid(uuid: string): Node;
  11619. /**
  11620. !#en Returns a child from the container given its name.
  11621. !#zh 通过名称获取节点的子节点。
  11622. @param name A name to find the child node.
  11623. @example
  11624. ```js
  11625. var child = node.getChildByName("Test Node");
  11626. ```
  11627. */
  11628. getChildByName(name: string): Node;
  11629. /**
  11630. !#en
  11631. Inserts a child to the node at a specified index.
  11632. !#zh
  11633. 插入子节点到指定位置
  11634. @param child the child node to be inserted
  11635. @param siblingIndex the sibling index to place the child in
  11636. @example
  11637. ```js
  11638. node.insertChild(child, 2);
  11639. ```
  11640. */
  11641. insertChild(child: Node, siblingIndex: number): void;
  11642. /**
  11643. !#en Get the sibling index.
  11644. !#zh 获取同级索引。
  11645. @example
  11646. ```js
  11647. var index = node.getSiblingIndex();
  11648. ```
  11649. */
  11650. getSiblingIndex(): number;
  11651. /**
  11652. !#en Set the sibling index of this node.
  11653. !#zh 设置节点同级索引。
  11654. @param index index
  11655. @example
  11656. ```js
  11657. node.setSiblingIndex(1);
  11658. ```
  11659. */
  11660. setSiblingIndex(index: number): void;
  11661. /**
  11662. !#en
  11663. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  11664. 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/>
  11665. If the node orphan, then nothing happens.
  11666. !#zh
  11667. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  11668. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  11669. 如果这个节点是一个孤节点,那么什么都不会发生。
  11670. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  11671. @example
  11672. ```js
  11673. node.removeFromParent();
  11674. node.removeFromParent(false);
  11675. ```
  11676. */
  11677. removeFromParent(cleanup?: boolean): void;
  11678. /**
  11679. !#en
  11680. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  11681. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11682. "remove" logic MUST only be on this method <br/>
  11683. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  11684. to override this method.
  11685. !#zh
  11686. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11687. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  11688. @param child The child node which will be removed.
  11689. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11690. @example
  11691. ```js
  11692. node.removeChild(newNode);
  11693. node.removeChild(newNode, false);
  11694. ```
  11695. */
  11696. removeChild(child: Node, cleanup?: boolean): void;
  11697. /**
  11698. !#en
  11699. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  11700. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11701. !#zh
  11702. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11703. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11704. @param tag An integer number that identifies a child node
  11705. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11706. @example
  11707. ```js
  11708. node.removeChildByTag(1001);
  11709. node.removeChildByTag(1001, false);
  11710. ```
  11711. */
  11712. removeChildByTag(tag: number, cleanup?: boolean): void;
  11713. /**
  11714. !#en
  11715. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  11716. If the cleanup parameter is not passed, it will force a cleanup.
  11717. !#zh
  11718. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11719. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11720. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  11721. @example
  11722. ```js
  11723. node.removeAllChildren();
  11724. node.removeAllChildren(false);
  11725. ```
  11726. */
  11727. removeAllChildren(cleanup?: boolean): void;
  11728. /**
  11729. !#en Is this node a child of the given node?
  11730. !#zh 是否是指定节点的子节点?
  11731. @param parent parent
  11732. @example
  11733. ```js
  11734. node.isChildOf(newNode);
  11735. ```
  11736. */
  11737. isChildOf(parent: Node): boolean;
  11738. /**
  11739. !#en
  11740. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  11741. You can also get component in the node by passing in the name of the script.
  11742. !#zh
  11743. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  11744. 传入参数也可以是脚本的名称。
  11745. @param typeOrClassName typeOrClassName
  11746. @example
  11747. ```js
  11748. // get sprite component.
  11749. var sprite = node.getComponent(cc.Sprite);
  11750. // get custom test calss.
  11751. var test = node.getComponent("Test");
  11752. ```
  11753. */
  11754. getComponent<T extends Component>(type: {prototype: T}): T;
  11755. getComponent(className: string): any;
  11756. /**
  11757. !#en Returns all components of supplied type in the node.
  11758. !#zh 返回节点上指定类型的所有组件。
  11759. @param typeOrClassName typeOrClassName
  11760. @example
  11761. ```js
  11762. var sprites = node.getComponents(cc.Sprite);
  11763. var tests = node.getComponents("Test");
  11764. ```
  11765. */
  11766. getComponents<T extends Component>(type: {prototype: T}): T[];
  11767. getComponents(className: string): any[];
  11768. /**
  11769. !#en Returns the component of supplied type in any of its children using depth first search.
  11770. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  11771. @param typeOrClassName typeOrClassName
  11772. @example
  11773. ```js
  11774. var sprite = node.getComponentInChildren(cc.Sprite);
  11775. var Test = node.getComponentInChildren("Test");
  11776. ```
  11777. */
  11778. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  11779. getComponentInChildren(className: string): any;
  11780. /**
  11781. !#en Returns all components of supplied type in self or any of its children.
  11782. !#zh 递归查找自身或所有子节点中指定类型的组件
  11783. @param typeOrClassName typeOrClassName
  11784. @example
  11785. ```js
  11786. var sprites = node.getComponentsInChildren(cc.Sprite);
  11787. var tests = node.getComponentsInChildren("Test");
  11788. ```
  11789. */
  11790. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  11791. getComponentsInChildren(className: string): any[];
  11792. /**
  11793. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  11794. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  11795. @param typeOrClassName The constructor or the class name of the component to add
  11796. @example
  11797. ```js
  11798. var sprite = node.addComponent(cc.Sprite);
  11799. var test = node.addComponent("Test");
  11800. ```
  11801. */
  11802. addComponent<T extends Component>(type: {new(): T}): T;
  11803. addComponent(className: string): any;
  11804. /**
  11805. !#en
  11806. Removes a component identified by the given name or removes the component object given.
  11807. You can also use component.destroy() if you already have the reference.
  11808. !#zh
  11809. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  11810. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  11811. @param component The need remove component.
  11812. @example
  11813. ```js
  11814. node.removeComponent(cc.Sprite);
  11815. var Test = require("Test");
  11816. node.removeComponent(Test);
  11817. ```
  11818. */
  11819. removeComponent(component: string|Function|Component): void;
  11820. /**
  11821. !#en
  11822. Destroy all children from the node, and release all their own references to other objects.<br/>
  11823. Actual destruct operation will delayed until before rendering.
  11824. !#zh
  11825. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  11826. 实际销毁操作会延迟到当前帧渲染前执行。
  11827. @example
  11828. ```js
  11829. node.destroyAllChildren();
  11830. ```
  11831. */
  11832. destroyAllChildren(): void;
  11833. /**
  11834. !#en
  11835. Register an callback of a specific event type on the EventTarget.
  11836. !#zh
  11837. 注册事件目标的特定事件类型回调。
  11838. @param type A string representing the event type to listen for.
  11839. @param callback The callback that will be invoked when the event is dispatched.
  11840. The callback is ignored if it is a duplicate (the callbacks are unique).
  11841. @param target The target (this object) to invoke the callback, can be null
  11842. @param useCapture When set to true, the capture argument prevents callback
  11843. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11844. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11845. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11846. @example
  11847. ```js
  11848. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11849. cc.log("this is callback");
  11850. }, node);
  11851. ```
  11852. */
  11853. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11854. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11855. /**
  11856. !#en
  11857. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11858. if only type is passed as parameter, all listeners registered with that type will be removed.
  11859. !#zh
  11860. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11861. @param type A string representing the event type being removed.
  11862. @param callback The callback to remove.
  11863. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11864. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11865. If not specified, useCapture defaults to false. If a callback was registered twice,
  11866. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11867. does not affect a non-capturing version of the same listener, and vice versa.
  11868. @example
  11869. ```js
  11870. // register touchEnd eventListener
  11871. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11872. cc.log("this is callback");
  11873. }, node);
  11874. // remove touch end event listener
  11875. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11876. // remove all touch end event listeners
  11877. node.off(cc.Node.EventType.TOUCH_END);
  11878. ```
  11879. */
  11880. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11881. /**
  11882. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11883. This is not for removing all listeners in the current event target,
  11884. and this is not for removing all listeners the target parameter have registered.
  11885. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11886. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11887. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11888. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11889. @param target The target to be searched for all related listeners
  11890. */
  11891. targetOff(target: any): void;
  11892. /**
  11893. !#en
  11894. Register an callback of a specific event type on the EventTarget,
  11895. the callback will remove itself after the first time it is triggered.
  11896. !#zh
  11897. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11898. @param type A string representing the event type to listen for.
  11899. @param callback The callback that will be invoked when the event is dispatched.
  11900. The callback is ignored if it is a duplicate (the callbacks are unique).
  11901. @param target The target (this object) to invoke the callback, can be null
  11902. @param useCapture When set to true, the capture argument prevents callback
  11903. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11904. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11905. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11906. @example
  11907. ```js
  11908. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11909. cc.log("this is callback");
  11910. }, node);
  11911. ```
  11912. */
  11913. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11914. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11915. /**
  11916. !#en
  11917. Dispatches an event into the event flow.
  11918. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11919. !#zh 分发事件到事件流中。
  11920. @param event The Event object that is dispatched into the event flow
  11921. */
  11922. dispatchEvent(event: Event): void;
  11923. /**
  11924. !#en
  11925. Send an event to this object directly, this method will not propagate the event to any other objects.
  11926. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11927. !#zh
  11928. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11929. @param message the message to send
  11930. @param detail whatever argument the message needs
  11931. */
  11932. emit(message: string, detail?: any): void;
  11933. }
  11934. /** !#en
  11935. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  11936. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  11937. !#zh
  11938. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  11939. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  11940. export class AffineTransform {
  11941. /**
  11942. !#en Create a cc.AffineTransform object with all contents in the matrix.
  11943. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  11944. @param a a
  11945. @param b b
  11946. @param c c
  11947. @param d d
  11948. @param tx tx
  11949. @param ty ty
  11950. */
  11951. affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  11952. /**
  11953. !#en Clone a cc.AffineTransform object from the specified transform.
  11954. !#zh 克隆指定的 cc.AffineTransform 对象。
  11955. @param t t
  11956. */
  11957. affineTransformClone(t: AffineTransform): AffineTransform;
  11958. /**
  11959. !#en Apply the affine transformation on a point.
  11960. !#zh 对一个点应用矩阵变换。
  11961. @param point or x.
  11962. @param transOrY transform matrix or y.
  11963. @param t transform matrix or y.
  11964. */
  11965. pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2;
  11966. /**
  11967. !#en Apply the affine transformation on a size.
  11968. !#zh 应用 Size 到仿射变换矩阵上。
  11969. @param size size
  11970. @param t t
  11971. */
  11972. sizeApplyAffineTransform(size: Size, t: AffineTransform): Size;
  11973. /**
  11974. !#en
  11975. Create a identity transformation matrix: <br/>
  11976. [ 1, 0, 0, <br/>
  11977. 0, 1, 0 ]
  11978. !#zh
  11979. 单位矩阵:<br/>
  11980. [ 1, 0, 0, <br/>
  11981. 0, 1, 0 ]
  11982. */
  11983. affineTransformMakeIdentity(): AffineTransform;
  11984. /**
  11985. !#en Apply the affine transformation on a rect.
  11986. !#zh 应用 Rect 到仿射变换矩阵上。
  11987. @param rect rect
  11988. @param anAffineTransform anAffineTransform
  11989. */
  11990. rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect;
  11991. /**
  11992. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  11993. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  11994. @param rect rect
  11995. @param anAffineTransform anAffineTransform
  11996. @param out_bl out_bl
  11997. @param out_tl out_tl
  11998. @param out_tr out_tr
  11999. @param out_br out_br
  12000. */
  12001. obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void;
  12002. /**
  12003. !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  12004. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  12005. @param t The base affine transform object.
  12006. @param tx The translation on x axis.
  12007. @param ty The translation on y axis.
  12008. */
  12009. affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform;
  12010. /**
  12011. !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  12012. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  12013. @param t The base affine transform object.
  12014. @param sx The scale on x axis.
  12015. @param sy The scale on y axis.
  12016. */
  12017. affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform;
  12018. /**
  12019. !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  12020. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  12021. @param aTransform The base affine transform object.
  12022. @param anAngle The angle to rotate.
  12023. */
  12024. affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform;
  12025. /**
  12026. !#en
  12027. Concatenate a transform matrix to another and return the result:<br/>
  12028. t' = t1 * t2
  12029. !#zh 拼接两个矩阵,并返回结果:<br/>
  12030. t' = t1 * t2
  12031. @param t1 The first transform object.
  12032. @param t2 The transform object to concatenate.
  12033. */
  12034. affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  12035. /**
  12036. !#en
  12037. Concatenate a transform matrix to another<br/>
  12038. The results are reflected in the first matrix.<br/>
  12039. t' = t1 * t2
  12040. !#zh
  12041. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  12042. t' = t1 * t2
  12043. @param t1 The first transform object.
  12044. @param t2 The transform object to concatenate.
  12045. */
  12046. affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  12047. /**
  12048. !#en Return true if an affine transform equals to another, false otherwise.
  12049. !#zh 判断两个矩阵是否相等。
  12050. @param t1 t1
  12051. @param t2 t2
  12052. */
  12053. affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean;
  12054. /**
  12055. !#en Get the invert transform of an AffineTransform object.
  12056. !#zh 求逆矩阵。
  12057. @param t t
  12058. */
  12059. affineTransformInvert(t: AffineTransform): AffineTransform;
  12060. /**
  12061. !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
  12062. !#zh 求逆矩阵并存入用户传入的矩阵对象参数。
  12063. @param t t
  12064. @param out out
  12065. */
  12066. affineTransformInvert(t: AffineTransform, out: AffineTransform): void;
  12067. }
  12068. /** !#en
  12069. Representation of RGBA colors.
  12070. Each color component is a floating point value with a range from 0 to 255.
  12071. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  12072. !#zh
  12073. cc.Color 用于表示颜色。
  12074. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  12075. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  12076. export class Color extends ValueType {
  12077. /**
  12078. @param r red component of the color, default value is 0.
  12079. @param g green component of the color, defualt value is 0.
  12080. @param b blue component of the color, default value is 0.
  12081. @param a alpha component of the color, default value is 255.
  12082. */
  12083. constructor(r?: number, g?: number, b?: number, a?: number);
  12084. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  12085. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  12086. static WHITE: Color;
  12087. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  12088. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  12089. static BLACK: Color;
  12090. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  12091. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  12092. static TRANSPARENT: Color;
  12093. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  12094. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  12095. static GRAY: Color;
  12096. /** !#en Solid red, RGBA is [255, 0, 0].
  12097. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  12098. static RED: Color;
  12099. /** !#en Solid green, RGBA is [0, 255, 0].
  12100. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  12101. static GREEN: Color;
  12102. /** !#en Solid blue, RGBA is [0, 0, 255].
  12103. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  12104. static BLUE: Color;
  12105. /** !#en Yellow, RGBA is [255, 235, 4].
  12106. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  12107. static YELLOW: Color;
  12108. /** !#en Orange, RGBA is [255, 127, 0].
  12109. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  12110. static ORANGE: Color;
  12111. /** !#en Cyan, RGBA is [0, 255, 255].
  12112. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  12113. static CYAN: Color;
  12114. /** !#en Magenta, RGBA is [255, 0, 255].
  12115. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  12116. static MAGENTA: Color;
  12117. /**
  12118. !#en Clone a new color from the current color.
  12119. !#zh 克隆当前颜色。
  12120. @example
  12121. ```js
  12122. var color = new cc.Color();
  12123. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  12124. ```
  12125. */
  12126. clone(): Color;
  12127. /**
  12128. !#en TODO
  12129. !#zh 判断两个颜色是否相等。
  12130. @param other other
  12131. @example
  12132. ```js
  12133. var color1 = cc.Color.WHITE;
  12134. var color2 = new cc.Color(255, 255, 255);
  12135. cc.log(color1.equals(color2)); // true;
  12136. color2 = cc.Color.RED;
  12137. cc.log(color2.equals(color1)); // false;
  12138. ```
  12139. */
  12140. equals(other: Color): boolean;
  12141. /**
  12142. !#en TODO
  12143. !#zh 线性插值
  12144. @param to to
  12145. @param ratio the interpolation coefficient.
  12146. @param out optional, the receiving vector.
  12147. @example
  12148. ```js
  12149. // Converts a white color to a black one trough time.
  12150. update: function (dt) {
  12151. var color = this.node.color;
  12152. if (color.equals(cc.Color.BLACK)) {
  12153. return;
  12154. }
  12155. this.ratio += dt * 0.1;
  12156. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  12157. }
  12158. ```
  12159. */
  12160. lerp(to: Color, ratio: number, out?: Color): Color;
  12161. /**
  12162. !#en TODO
  12163. !#zh 转换为方便阅读的字符串。
  12164. @example
  12165. ```js
  12166. var color = cc.Color.WHITE;
  12167. color.toString(); // "rgba(255, 255, 255, 255)"
  12168. ```
  12169. */
  12170. toString(): string;
  12171. /**
  12172. !#en Gets red channel value
  12173. !#zh 获取当前颜色的红色值。
  12174. */
  12175. getR(): number;
  12176. /**
  12177. !#en Sets red value and return the current color object
  12178. !#zh 设置当前的红色值,并返回当前对象。
  12179. @param red the new Red component.
  12180. @example
  12181. ```js
  12182. var color = new cc.Color();
  12183. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  12184. ```
  12185. */
  12186. setR(red: number): Color;
  12187. /**
  12188. !#en Gets green channel value
  12189. !#zh 获取当前颜色的绿色值。
  12190. */
  12191. getG(): number;
  12192. /**
  12193. !#en Sets green value and return the current color object
  12194. !#zh 设置当前的绿色值,并返回当前对象。
  12195. @param green the new Green component.
  12196. @example
  12197. ```js
  12198. var color = new cc.Color();
  12199. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  12200. ```
  12201. */
  12202. setG(green: number): Color;
  12203. /**
  12204. !#en Gets blue channel value
  12205. !#zh 获取当前颜色的蓝色值。
  12206. */
  12207. getB(): number;
  12208. /**
  12209. !#en Sets blue value and return the current color object
  12210. !#zh 设置当前的蓝色值,并返回当前对象。
  12211. @param blue the new Blue component.
  12212. @example
  12213. ```js
  12214. var color = new cc.Color();
  12215. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  12216. ```
  12217. */
  12218. setB(blue: number): Color;
  12219. /**
  12220. !#en Gets alpha channel value
  12221. !#zh 获取当前颜色的透明度值。
  12222. */
  12223. getA(): number;
  12224. /**
  12225. !#en Sets alpha value and return the current color object
  12226. !#zh 设置当前的透明度,并返回当前对象。
  12227. @param alpha the new Alpha component.
  12228. @example
  12229. ```js
  12230. var color = new cc.Color();
  12231. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  12232. ```
  12233. */
  12234. setA(alpha: number): Color;
  12235. /**
  12236. !#en Convert color to css format.
  12237. !#zh 转换为 CSS 格式。
  12238. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  12239. @example
  12240. ```js
  12241. var color = cc.Color.BLACK;
  12242. color.toCSS(); // "#000";
  12243. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  12244. color.toCSS("rgb"); // "rgba(0,0,0)";
  12245. color.toCSS("#rgb"); // "#000";
  12246. color.toCSS("#rrggbb"); // "#000000";
  12247. ```
  12248. */
  12249. toCSS(opt: string): string;
  12250. /**
  12251. !#en Clamp this color to make all components between 0 to 255。
  12252. !#zh 限制颜色数值,在 0 到 255 之间。
  12253. @example
  12254. ```js
  12255. var color = new cc.Color(1000, 0, 0, 255);
  12256. color.clamp();
  12257. cc.log(color); // (255, 0, 0, 255)
  12258. ```
  12259. */
  12260. clamp(): void;
  12261. /**
  12262. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  12263. !#zh 读取 16 进制颜色。
  12264. @param hexString hexString
  12265. @example
  12266. ```js
  12267. var color = cc.Color.BLACK;
  12268. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  12269. ```
  12270. */
  12271. fromHEX(hexString: string): Color;
  12272. /**
  12273. !#en TODO
  12274. !#zh 转换为 16 进制。
  12275. @param fmt "#rgb" or "#rrggbb".
  12276. @example
  12277. ```js
  12278. var color = cc.Color.BLACK;
  12279. color.toHEX("#rgb"); // "000";
  12280. color.toHEX("#rrggbb"); // "000000";
  12281. ```
  12282. */
  12283. toHEX(fmt: string): string;
  12284. /**
  12285. !#en Convert to 24bit rgb value.
  12286. !#zh 转换为 24bit 的 RGB 值。
  12287. @example
  12288. ```js
  12289. var color = cc.Color.YELLOW;
  12290. color.toRGBValue(); // 16771844;
  12291. ```
  12292. */
  12293. toRGBValue(): number;
  12294. /**
  12295. !#en TODO
  12296. !#zh 读取 HSV(色彩模型)格式。
  12297. @param h h
  12298. @param s s
  12299. @param v v
  12300. @example
  12301. ```js
  12302. var color = cc.Color.YELLOW;
  12303. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  12304. ```
  12305. */
  12306. fromHSV(h: number, s: number, v: number): Color;
  12307. /**
  12308. !#en TODO
  12309. !#zh 转换为 HSV(色彩模型)格式。
  12310. @example
  12311. ```js
  12312. var color = cc.Color.YELLOW;
  12313. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  12314. ```
  12315. */
  12316. toHSV(): any;
  12317. /**
  12318. !#en TODO
  12319. !#zh RGB 转换为 HSV。
  12320. @param r red, must be [0, 255].
  12321. @param g red, must be [0, 255].
  12322. @param b red, must be [0, 255].
  12323. @example
  12324. ```js
  12325. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  12326. ```
  12327. */
  12328. static rgb2hsv(r: number, g: number, b: number): any;
  12329. /**
  12330. !#en TODO
  12331. !#zh HSV 转换为 RGB。
  12332. @param h h
  12333. @param s s
  12334. @param v v
  12335. @example
  12336. ```js
  12337. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  12338. ```
  12339. */
  12340. static hsv2rgb(h: number, s: number, v: number): any;
  12341. }
  12342. /** !#en A 2D rectangle defined by x, y position and width, height.
  12343. !#zh 通过位置和宽高定义的 2D 矩形。 */
  12344. export class Rect extends ValueType {
  12345. /**
  12346. !#en
  12347. Constructor of cc.Rect class.
  12348. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  12349. !#zh
  12350. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  12351. @param x x
  12352. @param y y
  12353. @param w w
  12354. @param h h
  12355. */
  12356. constructor(x?: number, y?: number, w?: number, h?: number);
  12357. x: number;
  12358. y: number;
  12359. width: number;
  12360. height: number;
  12361. /**
  12362. !#en Creates a rectangle from two coordinate values.
  12363. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  12364. @param v1 v1
  12365. @param v2 v2
  12366. @example
  12367. ```js
  12368. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  12369. ```
  12370. */
  12371. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  12372. /**
  12373. !#en Checks if rect contains.
  12374. !#zh
  12375. 判断 2 个矩形是否有包含。<br/>
  12376. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  12377. 0 这则都不包含。
  12378. @param a Rect a
  12379. @param b Rect b
  12380. @example
  12381. ```js
  12382. var a = new cc.Rect(0, 0, 10, 10);
  12383. var b = new cc.Rect(5, 5, 5, 5);
  12384. var c = new cc.Rect(20, 20, 10, 10);
  12385. cc.Rect.contain(a, b); // 1;
  12386. cc.Rect.contain(b, a); // -1;
  12387. cc.Rect.contain(a, c); // 0;
  12388. ```
  12389. */
  12390. static contain(a: Rect, b: Rect): number;
  12391. /**
  12392. !#en TODO
  12393. !#zh 克隆一个新的 Rect。
  12394. @example
  12395. ```js
  12396. var a = new cc.Rect(0, 0, 10, 10);
  12397. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  12398. ```
  12399. */
  12400. clone(): Rect;
  12401. /**
  12402. !#en TODO
  12403. !#zh 是否等于指定的矩形。
  12404. @param other other
  12405. @example
  12406. ```js
  12407. var a = new cc.Rect(0, 0, 10, 10);
  12408. var b = new cc.Rect(0, 0, 10, 10);
  12409. a.equals(b);// true;
  12410. ```
  12411. */
  12412. equals(other: Rect): boolean;
  12413. /**
  12414. !#en TODO
  12415. !#zh 线性插值
  12416. @param to to
  12417. @param ratio the interpolation coefficient.
  12418. @param out optional, the receiving vector.
  12419. @example
  12420. ```js
  12421. var a = new cc.Rect(0, 0, 10, 10);
  12422. var b = new cc.Rect(50, 50, 100, 100);
  12423. update (dt) {
  12424. // method 1;
  12425. var c = a.lerp(b, dt * 0.1);
  12426. // method 2;
  12427. a.lerp(b, dt * 0.1, c);
  12428. }
  12429. ```
  12430. */
  12431. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12432. /**
  12433. !#en TODO
  12434. !#zh 转换为方便阅读的字符串
  12435. @example
  12436. ```js
  12437. var a = new cc.Rect(0, 0, 10, 10);
  12438. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12439. ```
  12440. */
  12441. toString(): string;
  12442. /** !#en TODO
  12443. !#zh 矩形 x 轴上的最小值。 */
  12444. xMin: number;
  12445. /** !#en TODO
  12446. !#zh 矩形 y 轴上的最小值。 */
  12447. yMin: number;
  12448. /** !#en TODO
  12449. !#zh 矩形 x 轴上的最大值。 */
  12450. xMax: number;
  12451. /** !#en TODO
  12452. !#zh 矩形 y 轴上的最大值。 */
  12453. yMax: number;
  12454. /** !#en The position of the center of the rectangle.
  12455. !#zh 矩形的中心点。 */
  12456. center: Vec2;
  12457. /** !#en The X and Y position of the rectangle.
  12458. !#zh 矩形的 x 和 y 坐标。 */
  12459. origin: Vec2;
  12460. /** !#en Width and height of the rectangle.
  12461. !#zh 矩形的大小。 */
  12462. size: Size;
  12463. /**
  12464. !#en TODO
  12465. !#zh 当前矩形与指定矩形是否相交。
  12466. @param rect rect
  12467. @example
  12468. ```js
  12469. var a = new cc.Rect(0, 0, 10, 10);
  12470. var b = new cc.Rect(0, 0, 20, 20);
  12471. a.intersects(b);// true
  12472. ```
  12473. */
  12474. intersects(rect: Rect): void;
  12475. /**
  12476. !#en TODO
  12477. !#zh 当前矩形是否包含指定坐标点。
  12478. Returns true if the point inside this rectangle.
  12479. @param point point
  12480. @example
  12481. ```js
  12482. var a = new cc.Rect(0, 0, 10, 10);
  12483. var b = new cc.Vec2(0, 5);
  12484. a.contains(b);// true
  12485. ```
  12486. */
  12487. contains(point: Vec2): void;
  12488. /**
  12489. !#en Returns true if the other rect totally inside this rectangle.
  12490. !#zh 当前矩形是否包含指定矩形。
  12491. @param rect rect
  12492. @example
  12493. ```js
  12494. var a = new cc.Rect(0, 0, 20, 20);
  12495. var b = new cc.Rect(0, 0, 10, 10);
  12496. a.containsRect(b);// true
  12497. ```
  12498. */
  12499. containsRect(rect: Rect): void;
  12500. }
  12501. /** !#en
  12502. cc.Size is the class for size object,<br/>
  12503. please do not use its constructor to create sizes,<br/>
  12504. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12505. It will be deprecated soon, please use cc.Vec2 instead.
  12506. !#zh
  12507. cc.Size 是 size 对象的类。<br/>
  12508. 请不要使用它的构造函数创建的 size,<br/>
  12509. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12510. 它不久将被取消,请使用cc.Vec2代替。 */
  12511. export class Size {
  12512. /**
  12513. @param width width
  12514. @param height height
  12515. */
  12516. constructor(width: number|Size, height?: number);
  12517. width: number;
  12518. height: number;
  12519. /** !#en return a Size object with width = 0 and height = 0.
  12520. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12521. static ZERO: Size;
  12522. /**
  12523. !#en TODO
  12524. !#zh 克隆 size 对象。
  12525. @example
  12526. ```js
  12527. var a = new cc.size(10, 10);
  12528. a.clone();// return Size {width: 0, height: 0};
  12529. ```
  12530. */
  12531. clone(): Size;
  12532. /**
  12533. !#en TODO
  12534. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12535. @param other other
  12536. @example
  12537. ```js
  12538. var a = new cc.size(10, 10);
  12539. a.equals(new cc.size(10, 10));// return true;
  12540. ```
  12541. */
  12542. equals(other: Size): boolean;
  12543. /**
  12544. !#en TODO
  12545. !#zh 线性插值。
  12546. @param to to
  12547. @param ratio the interpolation coefficient.
  12548. @param out optional, the receiving vector.
  12549. @example
  12550. ```js
  12551. var a = new cc.size(10, 10);
  12552. var b = new cc.rect(50, 50, 100, 100);
  12553. update (dt) {
  12554. // method 1;
  12555. var c = a.lerp(b, dt * 0.1);
  12556. // method 2;
  12557. a.lerp(b, dt * 0.1, c);
  12558. }
  12559. ```
  12560. */
  12561. lerp(to: Rect, ratio: number, out?: Size): Size;
  12562. /**
  12563. !#en TODO
  12564. !#zh 转换为方便阅读的字符串。
  12565. @example
  12566. ```js
  12567. var a = new cc.size(10, 10);
  12568. a.toString();// return "(10.00, 10.00)";
  12569. ```
  12570. */
  12571. toString(): string;
  12572. }
  12573. /** !#en the device accelerometer reports values for each axis in units of g-force.
  12574. !#zh 设备重力传感器传递的各个轴的数据。 */
  12575. export class Acceleration {
  12576. /**
  12577. @param x x
  12578. @param y y
  12579. @param z z
  12580. @param timestamp timestamp
  12581. */
  12582. constructor(x: number, y: number, z: number, timestamp: number);
  12583. }
  12584. /** !#en Blend Function used for textures.
  12585. !#zh 图像的混合方式。 */
  12586. export class BlendFunc {
  12587. /**
  12588. @param src1 source blend function
  12589. @param dst1 destination blend function
  12590. */
  12591. constructor(src1: number, dst1: number);
  12592. }
  12593. /** !#en
  12594. Enum for blend factor
  12595. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  12596. !#zh
  12597. 混合因子
  12598. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  12599. export enum BlendFactor {
  12600. ONE = 0,
  12601. ZERO = 0,
  12602. SRC_ALPHA = 0,
  12603. SRC_COLOR = 0,
  12604. DST_ALPHA = 0,
  12605. DST_COLOR = 0,
  12606. ONE_MINUS_SRC_ALPHA = 0,
  12607. ONE_MINUS_SRC_COLOR = 0,
  12608. ONE_MINUS_DST_ALPHA = 0,
  12609. ONE_MINUS_DST_COLOR = 0,
  12610. blendFuncDisable = 0,
  12611. }
  12612. /** undefined */
  12613. export enum TextAlignment {
  12614. LEFT = 0,
  12615. CENTER = 0,
  12616. RIGHT = 0,
  12617. }
  12618. /** undefined */
  12619. export class WebGLColor {
  12620. /**
  12621. @param r r
  12622. @param g g
  12623. @param b b
  12624. @param a a
  12625. @param arrayBuffer arrayBuffer
  12626. @param offset offset
  12627. */
  12628. constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number);
  12629. BYTES_PER_ELEMENT: number;
  12630. }
  12631. /** undefined */
  12632. export class Vertex2F {
  12633. /**
  12634. @param x x
  12635. @param y y
  12636. @param arrayBuffer arrayBuffer
  12637. @param offset offset
  12638. */
  12639. constructor(x: number, y: number, arrayBuffer: any[], offset: number);
  12640. BYTES_PER_ELEMENT: number;
  12641. }
  12642. /** undefined */
  12643. export class Vertex3F {
  12644. /**
  12645. @param x x
  12646. @param y y
  12647. @param z z
  12648. @param arrayBuffer arrayBuffer
  12649. @param offset offset
  12650. */
  12651. constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number);
  12652. BYTES_PER_ELEMENT: number;
  12653. }
  12654. /** undefined */
  12655. export class Tex2F {
  12656. /**
  12657. @param u u
  12658. @param v v
  12659. @param arrayBuffer arrayBuffer
  12660. @param offset offset
  12661. */
  12662. constructor(u: number, v: number, arrayBuffer: any[], offset: number);
  12663. BYTES_PER_ELEMENT: number;
  12664. }
  12665. /** undefined */
  12666. export class Quad2 {
  12667. /**
  12668. @param tl tl
  12669. @param tr tr
  12670. @param bl bl
  12671. @param br br
  12672. @param arrayBuffer arrayBuffer
  12673. @param offset offset
  12674. */
  12675. constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number);
  12676. BYTES_PER_ELEMENT: number;
  12677. }
  12678. /** A 3D Quad. 4 * 3 floats */
  12679. export class Quad3 {
  12680. /**
  12681. @param bl1 bl1
  12682. @param br1 br1
  12683. @param tl1 tl1
  12684. @param tr1 tr1
  12685. @param arrayBuffer arrayBuffer
  12686. @param offset offset
  12687. */
  12688. constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number);
  12689. }
  12690. /** undefined */
  12691. export class V3F_C4B_T2F {
  12692. /**
  12693. @param vertices vertices
  12694. @param colors colors
  12695. @param texCoords texCoords
  12696. @param arrayBuffer arrayBuffer
  12697. @param offset offset
  12698. */
  12699. constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12700. BYTES_PER_ELEMENT(): void;
  12701. }
  12702. /** undefined */
  12703. export class V3F_C4B_T2F_Quad {
  12704. /**
  12705. @param tl tl
  12706. @param bl bl
  12707. @param tr tr
  12708. @param br br
  12709. @param arrayBuffer arrayBuffer
  12710. @param offset offset
  12711. */
  12712. constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number);
  12713. BYTES_PER_ELEMENT: number;
  12714. }
  12715. /** undefined */
  12716. export class V2F_C4B_T2F {
  12717. /**
  12718. @param vertices vertices
  12719. @param colors colors
  12720. @param texCoords texCoords
  12721. @param arrayBuffer arrayBuffer
  12722. @param offset offset
  12723. */
  12724. constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12725. BYTES_PER_ELEMENT: number;
  12726. }
  12727. /** undefined */
  12728. export class V2F_C4B_T2F_Triangle {
  12729. /**
  12730. @param a a
  12731. @param b b
  12732. @param c c
  12733. @param arrayBuffer arrayBuffer
  12734. @param offset offset
  12735. */
  12736. constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number);
  12737. }
  12738. /** !#en The base class of all value types.
  12739. !#zh 所有值类型的基类。 */
  12740. export class ValueType {
  12741. /**
  12742. !#en This method returns an exact copy of current value.
  12743. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12744. */
  12745. clone(): ValueType;
  12746. /**
  12747. !#en Compares this object with the other one.
  12748. !#zh 当前对象是否等于指定对象。
  12749. @param other other
  12750. */
  12751. equals(other: ValueType): boolean;
  12752. /**
  12753. !#en
  12754. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12755. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12756. !#zh
  12757. 线性插值。<br/>
  12758. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12759. @param to the to value
  12760. @param ratio the interpolation coefficient
  12761. */
  12762. lerp(to: ValueType, ratio: number): ValueType;
  12763. /**
  12764. !#en TODO
  12765. !#zh 转换为方便阅读的字符串。
  12766. */
  12767. toString(): string;
  12768. }
  12769. /** !#en Representation of 2D vectors and points.
  12770. !#zh 表示 2D 向量和坐标 */
  12771. export class Vec2 extends ValueType {
  12772. /**
  12773. !#en
  12774. Constructor
  12775. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12776. !#zh
  12777. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12778. @param x x
  12779. @param y y
  12780. */
  12781. constructor(x?: number, y?: number);
  12782. x: number;
  12783. y: number;
  12784. /**
  12785. !#en clone a Vec2 value
  12786. !#zh 克隆一个 Vec2 值
  12787. */
  12788. clone(): Vec2;
  12789. /**
  12790. !#en TODO
  12791. !#zh 设置向量值。
  12792. @param newValue !#en new value to set. !#zh 要设置的新值
  12793. */
  12794. set(newValue: Vec2): Vec2;
  12795. /**
  12796. !#en TODO
  12797. !#zh 当前的向量是否与指定的向量相等。
  12798. @param other other
  12799. */
  12800. equals(other: Vec2): boolean;
  12801. /**
  12802. !#en TODO
  12803. !#zh 转换为方便阅读的字符串。
  12804. */
  12805. toString(): string;
  12806. /**
  12807. !#en TODO
  12808. !#zh 线性插值。
  12809. @param to to
  12810. @param ratio the interpolation coefficient
  12811. @param out optional, the receiving vector
  12812. */
  12813. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12814. /**
  12815. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  12816. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  12817. @param vector vector
  12818. @example
  12819. ```js
  12820. var v = cc.v2(10, 10);
  12821. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  12822. ```
  12823. */
  12824. addSelf(vector: Vec2): Vec2;
  12825. /**
  12826. !#en Adds two vectors, and returns the new result.
  12827. !#zh 向量加法,并返回新结果。
  12828. @param vector vector
  12829. @param out optional, the receiving vector
  12830. @example
  12831. ```js
  12832. var v = cc.v2(10, 10);
  12833. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  12834. var v1;
  12835. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  12836. ```
  12837. */
  12838. add(vector: Vec2, out?: Vec2): Vec2;
  12839. /**
  12840. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12841. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12842. @param vector vector
  12843. @example
  12844. ```js
  12845. var v = cc.v2(10, 10);
  12846. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12847. ```
  12848. */
  12849. subSelf(vector: Vec2): Vec2;
  12850. /**
  12851. !#en Subtracts one vector from this, and returns the new result.
  12852. !#zh 向量减法,并返回新结果。
  12853. @param vector vector
  12854. @param out optional, the receiving vector
  12855. @example
  12856. ```js
  12857. var v = cc.v2(10, 10);
  12858. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12859. var v1;
  12860. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12861. ```
  12862. */
  12863. sub(vector: Vec2, out?: Vec2): Vec2;
  12864. /**
  12865. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12866. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12867. @param num num
  12868. @example
  12869. ```js
  12870. var v = cc.v2(10, 10);
  12871. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12872. ```
  12873. */
  12874. mulSelf(num: number): Vec2;
  12875. /**
  12876. !#en Multiplies by a number, and returns the new result.
  12877. !#zh 缩放向量,并返回新结果。
  12878. @param num num
  12879. @param out optional, the receiving vector
  12880. @example
  12881. ```js
  12882. var v = cc.v2(10, 10);
  12883. v.mul(5); // return Vec2 {x: 50, y: 50};
  12884. var v1;
  12885. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12886. ```
  12887. */
  12888. mul(num: number, out?: Vec2): Vec2;
  12889. /**
  12890. !#en Multiplies two vectors.
  12891. !#zh 分量相乘。
  12892. @param vector vector
  12893. @example
  12894. ```js
  12895. var v = cc.v2(10, 10);
  12896. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12897. ```
  12898. */
  12899. scaleSelf(vector: Vec2): Vec2;
  12900. /**
  12901. !#en Multiplies two vectors, and returns the new result.
  12902. !#zh 分量相乘,并返回新的结果。
  12903. @param vector vector
  12904. @param out optional, the receiving vector
  12905. @example
  12906. ```js
  12907. var v = cc.v2(10, 10);
  12908. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12909. var v1;
  12910. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12911. ```
  12912. */
  12913. scale(vector: Vec2, out?: Vec2): Vec2;
  12914. /**
  12915. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12916. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12917. @param divisor divisor
  12918. @example
  12919. ```js
  12920. var v = cc.v2(10, 10);
  12921. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12922. ```
  12923. */
  12924. divSelf(divisor: number): Vec2;
  12925. /**
  12926. !#en Divides by a number, and returns the new result.
  12927. !#zh 向量除法,并返回新的结果。
  12928. @param divisor divisor
  12929. @param out optional, the receiving vector
  12930. @example
  12931. ```js
  12932. var v = cc.v2(10, 10);
  12933. v.div(5); // return Vec2 {x: 2, y: 2};
  12934. var v1;
  12935. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12936. ```
  12937. */
  12938. div(divisor: number, out?: Vec2): Vec2;
  12939. /**
  12940. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12941. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12942. @example
  12943. ```js
  12944. var v = cc.v2(10, 10);
  12945. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12946. ```
  12947. */
  12948. negSelf(): Vec2;
  12949. /**
  12950. !#en Negates the components, and returns the new result.
  12951. !#zh 返回取反后的新向量。
  12952. @param out optional, the receiving vector
  12953. @example
  12954. ```js
  12955. var v = cc.v2(10, 10);
  12956. var v1;
  12957. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12958. ```
  12959. */
  12960. neg(out?: Vec2): Vec2;
  12961. /**
  12962. !#en Dot product
  12963. !#zh 当前向量与指定向量进行点乘。
  12964. @param vector vector
  12965. @example
  12966. ```js
  12967. var v = cc.v2(10, 10);
  12968. v.dot(cc.v2(5, 5)); // return 100;
  12969. ```
  12970. */
  12971. dot(vector?: Vec2): number;
  12972. /**
  12973. !#en Cross product
  12974. !#zh 当前向量与指定向量进行叉乘。
  12975. @param vector vector
  12976. @example
  12977. ```js
  12978. var v = cc.v2(10, 10);
  12979. v.cross(cc.v2(5, 5)); // return 0;
  12980. ```
  12981. */
  12982. cross(vector?: Vec2): number;
  12983. /**
  12984. !#en Returns the length of this vector.
  12985. !#zh 返回该向量的长度。
  12986. @example
  12987. ```js
  12988. var v = cc.v2(10, 10);
  12989. v.mag(); // return 14.142135623730951;
  12990. ```
  12991. */
  12992. mag(): number;
  12993. /**
  12994. !#en Returns the squared length of this vector.
  12995. !#zh 返回该向量的长度平方。
  12996. @example
  12997. ```js
  12998. var v = cc.v2(10, 10);
  12999. v.magSqr(); // return 200;
  13000. ```
  13001. */
  13002. magSqr(): number;
  13003. /**
  13004. !#en Make the length of this vector to 1.
  13005. !#zh 向量归一化,让这个向量的长度为 1。
  13006. @example
  13007. ```js
  13008. var v = cc.v2(10, 10);
  13009. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  13010. ```
  13011. */
  13012. normalizeSelf(): Vec2;
  13013. /**
  13014. !#en
  13015. Returns this vector with a magnitude of 1.<br/>
  13016. <br/>
  13017. 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.
  13018. !#zh
  13019. 返回归一化后的向量。<br/>
  13020. <br/>
  13021. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  13022. @param out optional, the receiving vector
  13023. */
  13024. normalize(out?: Vec2): Vec2;
  13025. /**
  13026. !#en Get angle in radian between this and vector.
  13027. !#zh 夹角的弧度。
  13028. @param vector vector
  13029. */
  13030. angle(vector: Vec2): number;
  13031. /**
  13032. !#en Get angle in radian between this and vector with direction.
  13033. !#zh 带方向的夹角的弧度。
  13034. @param vector vector
  13035. */
  13036. signAngle(vector: Vec2): number;
  13037. /**
  13038. !#en rotate
  13039. !#zh 返回旋转给定弧度后的新向量。
  13040. @param radians radians
  13041. @param out optional, the receiving vector
  13042. */
  13043. rotate(radians: number, out?: Vec2): Vec2;
  13044. /**
  13045. !#en rotate self
  13046. !#zh 按指定弧度旋转向量。
  13047. @param radians radians
  13048. */
  13049. rotateSelf(radians: number): Vec2;
  13050. /** !#en return a Vec2 object with x = 1 and y = 1.
  13051. !#zh 新 Vec2 对象。 */
  13052. static ONE: Vec2;
  13053. /** !#en return a Vec2 object with x = 0 and y = 0.
  13054. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  13055. static ZERO: Vec2;
  13056. /** !#en return a Vec2 object with x = 0 and y = 1.
  13057. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  13058. static UP: Vec2;
  13059. /** !#en return a Vec2 object with x = 1 and y = 0.
  13060. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  13061. static RIGHT: Vec2;
  13062. }
  13063. /** undefined */
  13064. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  13065. /** !#en Position offset
  13066. !#zh 位置偏移量 */
  13067. offset: Vec2;
  13068. /** !#en Box size
  13069. !#zh 包围盒大小 */
  13070. size: Size;
  13071. }
  13072. /** undefined */
  13073. export class PhysicsChainCollider extends PolygonCollider {
  13074. /** !#en Whether the chain is loop
  13075. !#zh 链条是否首尾相连 */
  13076. loop: boolean;
  13077. /** !#en Chain points
  13078. !#zh 链条顶点数组 */
  13079. points: Vec2[];
  13080. }
  13081. /** undefined */
  13082. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  13083. /** !#en Position offset
  13084. !#zh 位置偏移量 */
  13085. offset: Vec2;
  13086. /** !#en Circle radius
  13087. !#zh 圆形半径 */
  13088. radius: number;
  13089. }
  13090. /** undefined */
  13091. export class PhysicsCollider {
  13092. /** !#en
  13093. The density.
  13094. !#zh
  13095. 密度 */
  13096. density: number;
  13097. /** !#en
  13098. A sensor collider collects contact information but never generates a collision response
  13099. !#zh
  13100. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  13101. sensor: boolean;
  13102. /** !#en
  13103. The friction coefficient, usually in the range [0,1].
  13104. !#zh
  13105. 摩擦系数,取值一般在 [0, 1] 之间 */
  13106. friction: number;
  13107. /** !#en
  13108. The restitution (elasticity) usually in the range [0,1].
  13109. !#zh
  13110. 弹性系数,取值一般在 [0, 1]之间 */
  13111. restitution: number;
  13112. /** !#en
  13113. Physics collider will find the rigidbody component on the node and set to this property.
  13114. !#zh
  13115. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  13116. body: RigidBody;
  13117. /**
  13118. !#en
  13119. Apply current changes to collider, this will regenerate inner box2d fixtures.
  13120. !#zh
  13121. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  13122. */
  13123. apply(): void;
  13124. /**
  13125. !#en
  13126. Get the world aabb of the collider
  13127. !#zh
  13128. 获取碰撞体的世界坐标系下的包围盒
  13129. */
  13130. getAABB(): void;
  13131. }
  13132. /** undefined */
  13133. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  13134. /** !#en Position offset
  13135. !#zh 位置偏移量 */
  13136. offset: Vec2;
  13137. /** !#en Polygon points
  13138. !#zh 多边形顶点数组 */
  13139. points: Vec2[];
  13140. }
  13141. /** !#en
  13142. A distance joint constrains two points on two bodies
  13143. to remain at a fixed distance from each other. You can view
  13144. this as a massless, rigid rod.
  13145. !#zh
  13146. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  13147. export class DistanceJoint extends Joint {
  13148. /** !#en
  13149. The distance separating the two ends of the joint.
  13150. !#zh
  13151. 关节两端的距离 */
  13152. distance: number;
  13153. /** !#en
  13154. The spring frequency.
  13155. !#zh
  13156. 弹性系数。 */
  13157. frequency: number;
  13158. /** !#en
  13159. The damping ratio.
  13160. !#zh
  13161. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13162. 0: number;
  13163. }
  13164. /** !#en
  13165. Base class for joints to connect rigidbody.
  13166. !#zh
  13167. 关节类的基类 */
  13168. export class Joint extends Component {
  13169. /** !#en
  13170. The anchor of the rigidbody.
  13171. !#zh
  13172. 刚体的锚点。 */
  13173. anchor: Vec2;
  13174. /** !#en
  13175. The anchor of the connected rigidbody.
  13176. !#zh
  13177. 关节另一端刚体的锚点。 */
  13178. connectedAnchor: Vec2;
  13179. /** !#en
  13180. The rigidbody to which the other end of the joint is attached.
  13181. !#zh
  13182. 关节另一端链接的刚体 */
  13183. connectedBody: RigidBody;
  13184. /** !#en
  13185. Should the two rigid bodies connected with this joint collide with each other?
  13186. !#zh
  13187. 链接到关节上的两个刚体是否应该相互碰撞? */
  13188. collideConnected: boolean;
  13189. /**
  13190. !#en
  13191. Apply current changes to joint, this will regenerate inner box2d joint.
  13192. !#zh
  13193. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  13194. */
  13195. apply(): void;
  13196. /**
  13197. !#en
  13198. Get the anchor point on rigidbody in world coordinates.
  13199. !#zh
  13200. 获取刚体世界坐标系下的锚点。
  13201. */
  13202. getWorldAnchor(): Vec2;
  13203. /**
  13204. !#en
  13205. Get the anchor point on connected rigidbody in world coordinates.
  13206. !#zh
  13207. 获取链接刚体世界坐标系下的锚点。
  13208. */
  13209. getWorldConnectedAnchor(): Vec2;
  13210. /**
  13211. !#en
  13212. Gets the reaction force of the joint.
  13213. !#zh
  13214. 获取关节的反作用力。
  13215. @param timeStep The time to calculate the reaction force for.
  13216. */
  13217. getReactionForce(timeStep: number): number;
  13218. /**
  13219. !#en
  13220. Gets the reaction torque of the joint.
  13221. !#zh
  13222. 获取关节的反扭矩。
  13223. @param timeStep The time to calculate the reaction torque for.
  13224. */
  13225. getReactionTorque(timeStep: number): number;
  13226. }
  13227. /** !#en
  13228. A motor joint is used to control the relative motion
  13229. between two bodies. A typical usage is to control the movement
  13230. of a dynamic body with respect to the ground.
  13231. !#zh
  13232. 马达关节被用来控制两个刚体间的相对运动。
  13233. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  13234. export class MotorJoint extends Joint {
  13235. /** !#en
  13236. The anchor of the rigidbody.
  13237. !#zh
  13238. 刚体的锚点。 */
  13239. anchor: Vec2;
  13240. /** !#en
  13241. The anchor of the connected rigidbody.
  13242. !#zh
  13243. 关节另一端刚体的锚点。 */
  13244. connectedAnchor: Vec2;
  13245. /** !#en
  13246. The linear offset from connected rigidbody to rigidbody.
  13247. !#zh
  13248. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  13249. linearOffset: Vec2;
  13250. /** !#en
  13251. The angular offset from connected rigidbody to rigidbody.
  13252. !#zh
  13253. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  13254. angularOffset: number;
  13255. /** !#en
  13256. The maximum force can be applied to rigidbody.
  13257. !#zh
  13258. 可以应用于刚体的最大的力值 */
  13259. maxForce: number;
  13260. /** !#en
  13261. The maximum torque can be applied to rigidbody.
  13262. !#zh
  13263. 可以应用于刚体的最大扭矩值 */
  13264. maxTorque: number;
  13265. /** !#en
  13266. The position correction factor in the range [0,1].
  13267. !#zh
  13268. 位置矫正系数,范围为 [0, 1] */
  13269. correctionFactor: number;
  13270. }
  13271. /** !#en
  13272. A mouse joint is used to make a point on a body track a
  13273. specified world point. This a soft constraint with a maximum
  13274. force. This allows the constraint to stretch and without
  13275. applying huge forces.
  13276. Mouse Joint will auto register the touch event with the mouse region node,
  13277. and move the choosed rigidbody in touch move event.
  13278. Note : generally mouse joint only used in test bed.
  13279. !#zh
  13280. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  13281. 鼠标关节可以指定一个最大的里来施加一个柔和的约束。
  13282. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  13283. 注意:一般鼠标关节只在测试环境中使用。 */
  13284. export class MouseJoint extends Joint {
  13285. /** !#en
  13286. The anchor of the rigidbody.
  13287. !#zh
  13288. 刚体的锚点。 */
  13289. anchor: Vec2;
  13290. /** !#en
  13291. The anchor of the connected rigidbody.
  13292. !#zh
  13293. 关节另一端刚体的锚点。 */
  13294. connectedAnchor: Vec2;
  13295. /** !#en
  13296. The node used to register touch evnet.
  13297. If this is null, it will be the joint's node.
  13298. !#zh
  13299. 用于注册触摸事件的节点。
  13300. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  13301. mouseRegion: Node;
  13302. /** !#en
  13303. The target point.
  13304. The mouse joint will move choosed rigidbody to target point.
  13305. !#zh
  13306. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  13307. target: Vec2;
  13308. /** !#en
  13309. The spring frequency.
  13310. !#zh
  13311. 弹簧系数。 */
  13312. frequency: number;
  13313. /** !#en
  13314. The damping ratio.
  13315. !#zh
  13316. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13317. 0: number;
  13318. /** !#en
  13319. The maximum force
  13320. !#zh
  13321. 最大阻力值 */
  13322. maxForce: number;
  13323. }
  13324. /** !#en
  13325. A prismatic joint. This joint provides one degree of freedom: translation
  13326. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  13327. use a joint limit to restrict the range of motion and a joint motor to
  13328. drive the motion or to model joint friction.
  13329. !#zh
  13330. 移动关节指定了只能在一个方向上移动刚体。
  13331. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  13332. export class PrismaticJoint extends Joint {
  13333. /** !#en
  13334. The local joint axis relative to rigidbody.
  13335. !#zh
  13336. 指定刚体可以移动的方向。 */
  13337. localAxisA: Vec2;
  13338. /** !#en
  13339. The reference angle.
  13340. !#zh
  13341. 相对角度 */
  13342. referenceAngle: number;
  13343. /** !#en
  13344. Enable joint distance limit?
  13345. !#zh
  13346. 是否开启关节的距离限制? */
  13347. enableLimit: boolean;
  13348. /** !#en
  13349. Enable joint motor?
  13350. !#zh
  13351. 是否开启关节马达? */
  13352. enableMotor: boolean;
  13353. /** !#en
  13354. The lower joint limit.
  13355. !#zh
  13356. 刚体能够移动的最小值 */
  13357. lowerLimit: number;
  13358. /** !#en
  13359. The upper joint limit.
  13360. !#zh
  13361. 刚体能够移动的最大值 */
  13362. upperLimit: number;
  13363. /** !#en
  13364. The maxium force can be applied to rigidbody to rearch the target motor speed.
  13365. !#zh
  13366. 可以施加到刚体的最大力。 */
  13367. maxMotorForce: number;
  13368. /** !#en
  13369. The expected motor speed.
  13370. !#zh
  13371. 期望的马达速度。 */
  13372. motorSpeed: number;
  13373. }
  13374. /** !#en
  13375. A revolute joint constrains two bodies to share a common point while they
  13376. are free to rotate about the point. The relative rotation about the shared
  13377. point is the joint angle. You can limit the relative rotation with
  13378. a joint limit that specifies a lower and upper angle. You can use a motor
  13379. to drive the relative rotation about the shared point. A maximum motor torque
  13380. is provided so that infinite forces are not generated.
  13381. !#zh
  13382. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  13383. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  13384. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  13385. export class RevoluteJoint extends Joint {
  13386. /** !#en
  13387. The reference angle.
  13388. An angle between bodies considered to be zero for the joint angle.
  13389. !#zh
  13390. 相对角度。
  13391. 两个物体之间角度为零时可以看作相等于关节角度 */
  13392. referenceAngle: number;
  13393. /** !#en
  13394. The lower angle.
  13395. !#zh
  13396. 角度的最低限制。 */
  13397. lowerAngle: number;
  13398. /** !#en
  13399. The upper angle.
  13400. !#zh
  13401. 角度的最高限制。 */
  13402. upperAngle: number;
  13403. /** !#en
  13404. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13405. !#zh
  13406. 可以施加到刚体的最大扭矩。 */
  13407. maxMotorTorque: number;
  13408. /** !#en
  13409. The expected motor speed.
  13410. !#zh
  13411. 期望的马达速度。 */
  13412. motorSpeed: number;
  13413. /** !#en
  13414. Enable joint limit?
  13415. !#zh
  13416. 是否开启关节的限制? */
  13417. enableLimit: boolean;
  13418. /** !#en
  13419. Enable joint motor?
  13420. !#zh
  13421. 是否开启关节马达? */
  13422. enableMotor: boolean;
  13423. /**
  13424. !#en
  13425. Get the joint angle.
  13426. !#zh
  13427. 获取关节角度。
  13428. */
  13429. getJointAngle(): number;
  13430. }
  13431. /** !#en
  13432. A rope joint enforces a maximum distance between two points
  13433. on two bodies. It has no other effect.
  13434. Warning: if you attempt to change the maximum length during
  13435. the simulation you will get some non-physical behavior.
  13436. !#zh
  13437. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  13438. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  13439. export class RopeJoint extends Joint {
  13440. /** !#en
  13441. The max length.
  13442. !#zh
  13443. 最大长度。 */
  13444. maxLength: number;
  13445. }
  13446. /** !#en
  13447. A weld joint essentially glues two bodies together. A weld joint may
  13448. distort somewhat because the island constraint solver is approximate.
  13449. !#zh
  13450. 熔接关节相当于将两个刚体粘在了一起。
  13451. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  13452. export class WeldJoint extends Joint {
  13453. /** !#en
  13454. The reference angle.
  13455. !#zh
  13456. 相对角度。 */
  13457. referenceAngle: number;
  13458. /** !#en
  13459. The frequency.
  13460. !#zh
  13461. 弹性系数。 */
  13462. frequency: number;
  13463. /** !#en
  13464. The damping ratio.
  13465. !#zh
  13466. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13467. 0: number;
  13468. }
  13469. /** !#en
  13470. A wheel joint. This joint provides two degrees of freedom: translation
  13471. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  13472. the rotation or to model rotational friction.
  13473. This joint is designed for vehicle suspensions.
  13474. !#zh
  13475. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  13476. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  13477. 轮组关节是专门为机动车类型设计的。 */
  13478. export class WheelJoint extends Joint {
  13479. /** !#en
  13480. The local joint axis relative to rigidbody.
  13481. !#zh
  13482. 指定刚体可以移动的方向。 */
  13483. localAxisA: Vec2;
  13484. /** !#en
  13485. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13486. !#zh
  13487. 可以施加到刚体的最大扭矩。 */
  13488. maxMotorTorque: number;
  13489. /** !#en
  13490. The expected motor speed.
  13491. !#zh
  13492. 期望的马达速度。 */
  13493. motorSpeed: number;
  13494. /** !#en
  13495. Enable joint motor?
  13496. !#zh
  13497. 是否开启关节马达? */
  13498. enableMotor: boolean;
  13499. /** !#en
  13500. The spring frequency.
  13501. !#zh
  13502. 弹性系数。 */
  13503. frequency: number;
  13504. /** !#en
  13505. The damping ratio.
  13506. !#zh
  13507. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13508. dampingRatio: number;
  13509. }
  13510. /****************************************************
  13511. * audioEngine
  13512. *****************************************************/
  13513. export module audioEngine {
  13514. /** !#en Audio state.
  13515. !#zh 声音播放状态 */
  13516. export enum AudioState {
  13517. ERROR = 0,
  13518. INITIALZING = 0,
  13519. PLAYING = 0,
  13520. PAUSED = 0,
  13521. }
  13522. }
  13523. /****************************************************
  13524. * Node
  13525. *****************************************************/
  13526. export module Node {
  13527. /** !#en The event type supported by Node
  13528. !#zh Node 支持的事件类型 */
  13529. export class EventType {
  13530. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  13531. !#zh 当手指触摸到屏幕时。 */
  13532. static TOUCH_START: string;
  13533. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  13534. !#zh 当手指在屏幕上目标节点区域内移动时。 */
  13535. static TOUCH_MOVE: string;
  13536. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  13537. !#zh 当手指在目标节点区域内离开屏幕时。 */
  13538. static TOUCH_END: string;
  13539. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  13540. !#zh 当手指在目标节点区域外离开屏幕时。 */
  13541. static TOUCH_CANCEL: string;
  13542. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  13543. !#zh 当鼠标按下时触发一次。 */
  13544. static MOUSE_DOWN: string;
  13545. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  13546. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  13547. static MOUSE_MOVE: string;
  13548. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  13549. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  13550. static MOUSE_ENTER: string;
  13551. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  13552. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  13553. static MOUSE_LEAVE: string;
  13554. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  13555. !#zh 当鼠标从按下状态松开时触发一次。 */
  13556. static MOUSE_UP: string;
  13557. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  13558. !#zh 当鼠标滚轮滚动时。 */
  13559. static MOUSE_WHEEL: string;
  13560. }
  13561. }
  13562. /****************************************************
  13563. * ParticleSystem
  13564. *****************************************************/
  13565. export module ParticleSystem {
  13566. /** !#en Enum for emitter modes
  13567. !#zh 发射模式 */
  13568. export enum EmitterMode {
  13569. GRAVITY = 0,
  13570. RADIUS = 0,
  13571. }
  13572. }
  13573. /****************************************************
  13574. * ParticleSystem
  13575. *****************************************************/
  13576. export module ParticleSystem {
  13577. /** !#en Enum for particles movement type.
  13578. !#zh 粒子位置类型 */
  13579. export enum PositionType {
  13580. FREE = 0,
  13581. RELATIVE = 0,
  13582. GROUPED = 0,
  13583. }
  13584. }
  13585. /****************************************************
  13586. * TiledMap
  13587. *****************************************************/
  13588. export module TiledMap {
  13589. /** !#en The orientation of tiled map.
  13590. !#zh Tiled Map 地图方向。 */
  13591. export enum Orientation {
  13592. ORTHO = 0,
  13593. HEX = 0,
  13594. ISO = 0,
  13595. NONE = 0,
  13596. MAP = 0,
  13597. LAYER = 0,
  13598. OBJECTGROUP = 0,
  13599. OBJECT = 0,
  13600. TILE = 0,
  13601. HORIZONTAL = 0,
  13602. VERTICAL = 0,
  13603. DIAGONAL = 0,
  13604. FLIPPED_ALL = 0,
  13605. FLIPPED_MASK = 0,
  13606. STAGGERAXIS_X = 0,
  13607. STAGGERAXIS_Y = 0,
  13608. STAGGERINDEX_ODD = 0,
  13609. STAGGERINDEX_EVEN = 0,
  13610. }
  13611. }
  13612. /****************************************************
  13613. * Prefab
  13614. *****************************************************/
  13615. export module Prefab {
  13616. /** !#zh
  13617. Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。
  13618. !#en
  13619. An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}}
  13620. to specify how to optimize the instantiate operation. */
  13621. export enum OptimizationPolicy {
  13622. AUTO = 0,
  13623. SINGLE_INSTANCE = 0,
  13624. MULTI_INSTANCE = 0,
  13625. }
  13626. }
  13627. /****************************************************
  13628. * Button
  13629. *****************************************************/
  13630. export module Button {
  13631. /** !#en Enum for transition type.
  13632. !#zh 过渡类型 */
  13633. export enum Transition {
  13634. NONE = 0,
  13635. COLOR = 0,
  13636. SPRITE = 0,
  13637. SCALE = 0,
  13638. }
  13639. }
  13640. /****************************************************
  13641. * Component
  13642. *****************************************************/
  13643. export module Component {
  13644. /** !#en
  13645. Component will register a event to target component's handler.
  13646. And it will trigger the handler when a certain event occurs.
  13647. !@zh
  13648. “EventHandler” 类用来设置场景中的事件回调,
  13649. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  13650. 并可通过 emit 方法调用目标函数。 */
  13651. export class EventHandler {
  13652. /** !#en Event target
  13653. !#zh 目标节点 */
  13654. target: Node;
  13655. /** !#en Component name
  13656. !#zh 目标组件名 */
  13657. component: string;
  13658. /** !#en Event handler
  13659. !#zh 响应事件函数名 */
  13660. handler: string;
  13661. /** !#en Custom Event Data
  13662. !#zh 自定义事件数据 */
  13663. customEventData: string;
  13664. /**
  13665. @param events events
  13666. @param params params
  13667. */
  13668. static emitEvents(events: Component.EventHandler[], ...params: any[]): void;
  13669. /**
  13670. !#en Emit event with params
  13671. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  13672. @param params params
  13673. @example
  13674. ```js
  13675. // Call Function
  13676. var eventHandler = new cc.Component.EventHandler();
  13677. eventHandler.target = newTarget;
  13678. eventHandler.component = "MainMenu";
  13679. eventHandler.handler = "OnClick"
  13680. eventHandler.emit(["param1", "param2", ....]);
  13681. ```
  13682. */
  13683. emit(params: any[]): void;
  13684. }
  13685. }
  13686. /****************************************************
  13687. * EditBox
  13688. *****************************************************/
  13689. export module EditBox {
  13690. /** !#en Enum for keyboard return types
  13691. !#zh 键盘的返回键类型 */
  13692. export enum KeyboardReturnType {
  13693. DEFAULT = 0,
  13694. DONE = 0,
  13695. SEND = 0,
  13696. SEARCH = 0,
  13697. GO = 0,
  13698. }
  13699. }
  13700. /****************************************************
  13701. * EditBox
  13702. *****************************************************/
  13703. export module EditBox {
  13704. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  13705. !#zh 输入模式 */
  13706. export enum InputMode {
  13707. ANY = 0,
  13708. EMAIL_ADDR = 0,
  13709. NUMERIC = 0,
  13710. PHONE_NUMBER = 0,
  13711. URL = 0,
  13712. DECIMAL = 0,
  13713. SINGLE_LINE = 0,
  13714. }
  13715. }
  13716. /****************************************************
  13717. * EditBox
  13718. *****************************************************/
  13719. export module EditBox {
  13720. /** !#en Enum for the EditBox's input flags
  13721. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  13722. export enum InputFlag {
  13723. PASSWORD = 0,
  13724. SENSITIVE = 0,
  13725. INITIAL_CAPS_WORD = 0,
  13726. INITIAL_CAPS_SENTENCE = 0,
  13727. INITIAL_CAPS_ALL_CHARACTERS = 0,
  13728. }
  13729. }
  13730. /****************************************************
  13731. * Label
  13732. *****************************************************/
  13733. export module Label {
  13734. /** !#en Enum for text alignment.
  13735. !#zh 文本横向对齐类型 */
  13736. export enum HorizontalAlign {
  13737. LEFT = 0,
  13738. CENTER = 0,
  13739. RIGHT = 0,
  13740. }
  13741. }
  13742. /****************************************************
  13743. * Label
  13744. *****************************************************/
  13745. export module Label {
  13746. /** !#en Enum for vertical text alignment.
  13747. !#zh 文本垂直对齐类型 */
  13748. export enum VerticalAlign {
  13749. TOP = 0,
  13750. CENTER = 0,
  13751. BOTTOM = 0,
  13752. }
  13753. }
  13754. /****************************************************
  13755. * Label
  13756. *****************************************************/
  13757. export module Label {
  13758. /** !#en Enum for Overflow.
  13759. !#zh Overflow 类型 */
  13760. export enum Overflow {
  13761. NONE = 0,
  13762. CLAMP = 0,
  13763. SHRINK = 0,
  13764. RESIZE_HEIGHT = 0,
  13765. }
  13766. }
  13767. /****************************************************
  13768. * Label
  13769. *****************************************************/
  13770. export module Label {
  13771. /** !#en Enum for font type.
  13772. !#zh Type 类型 */
  13773. export enum Type {
  13774. TTF = 0,
  13775. BMFont = 0,
  13776. SystemFont = 0,
  13777. }
  13778. }
  13779. /****************************************************
  13780. * Layout
  13781. *****************************************************/
  13782. export module Layout {
  13783. /** !#en Enum for Layout type
  13784. !#zh 布局类型 */
  13785. export enum Type {
  13786. NONE = 0,
  13787. HORIZONTAL = 0,
  13788. VERTICAL = 0,
  13789. GRID = 0,
  13790. }
  13791. }
  13792. /****************************************************
  13793. * Layout
  13794. *****************************************************/
  13795. export module Layout {
  13796. /** !#en Enum for Layout Resize Mode
  13797. !#zh 缩放模式 */
  13798. export enum ResizeMode {
  13799. NONE = 0,
  13800. CONTAINER = 0,
  13801. CHILDREN = 0,
  13802. }
  13803. }
  13804. /****************************************************
  13805. * Layout
  13806. *****************************************************/
  13807. export module Layout {
  13808. /** !#en Enum for Grid Layout start axis direction.
  13809. The items in grid layout will be arranged in each axis at first.;
  13810. !#zh 布局轴向,只用于 GRID 布局。 */
  13811. export enum AxisDirection {
  13812. HORIZONTAL = 0,
  13813. VERTICAL = 0,
  13814. }
  13815. }
  13816. /****************************************************
  13817. * Layout
  13818. *****************************************************/
  13819. export module Layout {
  13820. /** !#en Enum for vertical layout direction.
  13821. Used in Grid Layout together with AxisDirection is VERTICAL
  13822. !#zh 垂直方向布局方式 */
  13823. export enum VerticalDirection {
  13824. BOTTOM_TO_TOP = 0,
  13825. TOP_TO_BOTTOM = 0,
  13826. }
  13827. }
  13828. /****************************************************
  13829. * Layout
  13830. *****************************************************/
  13831. export module Layout {
  13832. /** !#en Enum for horizontal layout direction.
  13833. Used in Grid Layout together with AxisDirection is HORIZONTAL
  13834. !#zh 水平方向布局方式 */
  13835. export enum HorizontalDirection {
  13836. LEFT_TO_RIGHT = 0,
  13837. RIGHT_TO_LEFT = 0,
  13838. }
  13839. }
  13840. /****************************************************
  13841. * Mask
  13842. *****************************************************/
  13843. export module Mask {
  13844. /** !#en the type for mask.
  13845. !#zh 遮罩组件类型 */
  13846. export enum Type {
  13847. RECT = 0,
  13848. ELLIPSE = 0,
  13849. IMAGE_STENCIL = 0,
  13850. }
  13851. }
  13852. /****************************************************
  13853. * PageView
  13854. *****************************************************/
  13855. export module PageView {
  13856. /** !#en The Page View Size Mode
  13857. !#zh 页面视图每个页面统一的大小类型 */
  13858. export enum SizeMode {
  13859. Unified = 0,
  13860. Free = 0,
  13861. }
  13862. }
  13863. /****************************************************
  13864. * PageView
  13865. *****************************************************/
  13866. export module PageView {
  13867. /** !#en The Page View Direction
  13868. !#zh 页面视图滚动类型 */
  13869. export enum Direction {
  13870. Horizontal = 0,
  13871. Vertical = 0,
  13872. }
  13873. }
  13874. /****************************************************
  13875. * PageView
  13876. *****************************************************/
  13877. export module PageView {
  13878. /** !#en Enum for ScrollView event type.
  13879. !#zh 滚动视图事件类型 */
  13880. export enum EventType {
  13881. PAGE_TURNING = 0,
  13882. }
  13883. }
  13884. /****************************************************
  13885. * PageViewIndicator
  13886. *****************************************************/
  13887. export module PageViewIndicator {
  13888. /** !#en Enum for PageView Indicator direction
  13889. !#zh 页面视图指示器的摆放方向 */
  13890. export enum Direction {
  13891. HORIZONTAL = 0,
  13892. VERTICAL = 0,
  13893. }
  13894. }
  13895. /****************************************************
  13896. * ProgressBar
  13897. *****************************************************/
  13898. export module ProgressBar {
  13899. /** !#en Enum for ProgressBar mode
  13900. !#zh 进度条模式 */
  13901. export enum Mode {
  13902. HORIZONTAL = 0,
  13903. VERTICAL = 0,
  13904. FILLED = 0,
  13905. }
  13906. }
  13907. /****************************************************
  13908. * Scrollbar
  13909. *****************************************************/
  13910. export module Scrollbar {
  13911. /** Enum for Scrollbar direction */
  13912. export enum Direction {
  13913. HORIZONTAL = 0,
  13914. VERTICAL = 0,
  13915. }
  13916. }
  13917. /****************************************************
  13918. * ScrollView
  13919. *****************************************************/
  13920. export module ScrollView {
  13921. /** !#en Enum for ScrollView event type.
  13922. !#zh 滚动视图事件类型 */
  13923. export enum EventType {
  13924. SCROLL_TO_TOP = 0,
  13925. SCROLL_TO_BOTTOM = 0,
  13926. SCROLL_TO_LEFT = 0,
  13927. SCROLL_TO_RIGHT = 0,
  13928. SCROLLING = 0,
  13929. BOUNCE_TOP = 0,
  13930. BOUNCE_BOTTOM = 0,
  13931. BOUNCE_LEFT = 0,
  13932. BOUNCE_RIGHT = 0,
  13933. SCROLL_ENDED = 0,
  13934. TOUCH_UP = 0,
  13935. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  13936. SCROLL_BEGAN = 0,
  13937. }
  13938. }
  13939. /****************************************************
  13940. * Slider
  13941. *****************************************************/
  13942. export module Slider {
  13943. /** !#en The Slider Direction
  13944. !#zh 滑动器方向 */
  13945. export enum Direction {
  13946. Horizontal = 0,
  13947. Vertical = 0,
  13948. }
  13949. }
  13950. /****************************************************
  13951. * Sprite
  13952. *****************************************************/
  13953. export module Sprite {
  13954. /** !#en Enum for sprite type.
  13955. !#zh Sprite 类型 */
  13956. export enum Type {
  13957. SIMPLE = 0,
  13958. SLICED = 0,
  13959. TILED = 0,
  13960. FILLED = 0,
  13961. }
  13962. }
  13963. /****************************************************
  13964. * Sprite
  13965. *****************************************************/
  13966. export module Sprite {
  13967. /** !#en Enum for fill type.
  13968. !#zh 填充类型 */
  13969. export enum FillType {
  13970. HORIZONTAL = 0,
  13971. VERTICAL = 0,
  13972. RADIAL = 0,
  13973. }
  13974. }
  13975. /****************************************************
  13976. * Sprite
  13977. *****************************************************/
  13978. export module Sprite {
  13979. /** !#en Sprite Size can track trimmed size, raw size or none.
  13980. !#zh 精灵尺寸调整模式 */
  13981. export enum SizeMode {
  13982. CUSTOM = 0,
  13983. TRIMMED = 0,
  13984. RAW = 0,
  13985. }
  13986. }
  13987. /****************************************************
  13988. * VideoPlayer
  13989. *****************************************************/
  13990. export module VideoPlayer {
  13991. /** !#en Video event type
  13992. !#zh 视频事件类型 */
  13993. export enum EventType {
  13994. PLAYING = 0,
  13995. PAUSED = 0,
  13996. STOPPED = 0,
  13997. COMPLETED = 0,
  13998. META_LOADED = 0,
  13999. CLICKED = 0,
  14000. READY_TO_PLAY = 0,
  14001. }
  14002. }
  14003. /****************************************************
  14004. * VideoPlayer
  14005. *****************************************************/
  14006. export module VideoPlayer {
  14007. /** !#en Enum for video resouce type type.
  14008. !#zh 视频来源 */
  14009. export enum ResourceType {
  14010. REMOTE = 0,
  14011. LOCAL = 0,
  14012. }
  14013. }
  14014. /****************************************************
  14015. * WebView
  14016. *****************************************************/
  14017. export module WebView {
  14018. /** !#en WebView event type
  14019. !#zh 网页视图事件类型 */
  14020. export enum EventType {
  14021. LOADED = 0,
  14022. LOADING = 0,
  14023. ERROR = 0,
  14024. }
  14025. }
  14026. /****************************************************
  14027. * Widget
  14028. *****************************************************/
  14029. export module Widget {
  14030. /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh.
  14031. !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */
  14032. export enum AlignMode {
  14033. ONCE = 0,
  14034. ON_WINDOW_RESIZE = 0,
  14035. ALWAYS = 0,
  14036. }
  14037. }
  14038. /****************************************************
  14039. * Collider
  14040. *****************************************************/
  14041. export module Collider {
  14042. /** !#en Defines a Box Collider .
  14043. !#zh 用来定义包围盒碰撞体 */
  14044. export class Box {
  14045. /** !#en Position offset
  14046. !#zh 位置偏移量 */
  14047. offset: Vec2;
  14048. /** !#en Box size
  14049. !#zh 包围盒大小 */
  14050. size: Size;
  14051. }
  14052. }
  14053. /****************************************************
  14054. * Collider
  14055. *****************************************************/
  14056. export module Collider {
  14057. /** !#en Defines a Circle Collider .
  14058. !#zh 用来定义圆形碰撞体 */
  14059. export class Circle {
  14060. /** !#en Position offset
  14061. !#zh 位置偏移量 */
  14062. offset: Vec2;
  14063. /** !#en Circle radius
  14064. !#zh 圆形半径 */
  14065. radius: number;
  14066. }
  14067. }
  14068. /****************************************************
  14069. * Collider
  14070. *****************************************************/
  14071. export module Collider {
  14072. /** !#en Defines a Polygon Collider .
  14073. !#zh 用来定义多边形碰撞体 */
  14074. export class Polygon {
  14075. /** !#en Position offset
  14076. !#zh 位置偏移量 */
  14077. offset: Vec2;
  14078. /** !#en Polygon points
  14079. !#zh 多边形顶点数组 */
  14080. points: Vec2[];
  14081. }
  14082. }
  14083. /****************************************************
  14084. * Event
  14085. *****************************************************/
  14086. export module Event {
  14087. /** !#en The Custom event
  14088. !#zh 自定义事件 */
  14089. export class EventCustom extends Event {
  14090. /**
  14091. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  14092. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  14093. */
  14094. constructor(type: string, bubbles: boolean);
  14095. /** !#en A reference to the detailed data of the event
  14096. !#zh 事件的详细数据 */
  14097. detail: any;
  14098. /**
  14099. !#en Sets user data
  14100. !#zh 设置用户数据
  14101. @param data data
  14102. */
  14103. setUserData(data: any): void;
  14104. /**
  14105. !#en Gets user data
  14106. !#zh 获取用户数据
  14107. */
  14108. getUserData(): any;
  14109. /**
  14110. !#en Gets event name
  14111. !#zh 获取事件名称
  14112. */
  14113. getEventName(): string;
  14114. /** !#en
  14115. The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. </br>
  14116. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.</br>
  14117. If the key can't be identified, this value is 0.</br>
  14118. !#zh
  14119. keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。</br>
  14120. 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。</br>
  14121. 如果无法识别该键,则该值为 0。 */
  14122. keyCode: number;
  14123. }
  14124. }
  14125. /****************************************************
  14126. * SystemEvent
  14127. *****************************************************/
  14128. export module SystemEvent {
  14129. /** !#en The event type supported by SystemEvent
  14130. !#zh SystemEvent 支持的事件类型 */
  14131. export class EventType {
  14132. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  14133. !#zh 当按下按键时触发的事件 */
  14134. static KEY_DOWN: string;
  14135. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  14136. !#zh 当松开按键时触发的事件 */
  14137. static KEY_UP: string;
  14138. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  14139. !#zh 重力感应 */
  14140. static DEVICEMOTION: string;
  14141. }
  14142. }
  14143. /****************************************************
  14144. * Event
  14145. *****************************************************/
  14146. export module Event {
  14147. /** !#en The mouse event
  14148. !#zh 鼠标事件类型 */
  14149. export class EventMouse extends Event {
  14150. /**
  14151. !#en Sets scroll data.
  14152. !#zh 设置鼠标的滚动数据。
  14153. @param scrollX scrollX
  14154. @param scrollY scrollY
  14155. */
  14156. setScrollData(scrollX: number, scrollY: number): void;
  14157. /**
  14158. !#en Returns the x axis scroll value.
  14159. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  14160. */
  14161. getScrollX(): number;
  14162. /**
  14163. !#en Returns the y axis scroll value.
  14164. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  14165. */
  14166. getScrollY(): number;
  14167. /**
  14168. !#en Sets cursor location.
  14169. !#zh 设置当前鼠标位置。
  14170. @param x x
  14171. @param y y
  14172. */
  14173. setLocation(x: number, y: number): void;
  14174. /**
  14175. !#en Returns cursor location.
  14176. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  14177. */
  14178. getLocation(): Vec2;
  14179. /**
  14180. !#en Returns the current cursor location in screen coordinates.
  14181. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  14182. */
  14183. getLocationInView(): Vec2;
  14184. /**
  14185. !#en Returns the previous touch location.
  14186. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  14187. */
  14188. getPreviousLocation(): Vec2;
  14189. /**
  14190. !#en Returns the delta distance from the previous location to current location.
  14191. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14192. */
  14193. getDelta(): Vec2;
  14194. /**
  14195. !#en Returns the X axis delta distance from the previous location to current location.
  14196. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  14197. */
  14198. getDeltaX(): number;
  14199. /**
  14200. !#en Returns the Y axis delta distance from the previous location to current location.
  14201. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  14202. */
  14203. getDeltaY(): number;
  14204. /**
  14205. !#en Sets mouse button.
  14206. !#zh 设置鼠标按键。
  14207. @param button button
  14208. */
  14209. setButton(button: number): void;
  14210. /**
  14211. !#en Returns mouse button.
  14212. !#zh 获取鼠标按键。
  14213. */
  14214. getButton(): number;
  14215. /**
  14216. !#en Returns location X axis data.
  14217. !#zh 获取鼠标当前位置 X 轴。
  14218. */
  14219. getLocationX(): number;
  14220. /**
  14221. !#en Returns location Y axis data.
  14222. !#zh 获取鼠标当前位置 Y 轴。
  14223. */
  14224. getLocationY(): number;
  14225. /** !#en The none event code of mouse event.
  14226. !#zh 无。 */
  14227. static NONE: number;
  14228. /** !#en The event type code of mouse down event.
  14229. !#zh 鼠标按下事件。 */
  14230. static DOWN: number;
  14231. /** !#en The event type code of mouse up event.
  14232. !#zh 鼠标按下后释放事件。 */
  14233. static UP: number;
  14234. /** !#en The event type code of mouse move event.
  14235. !#zh 鼠标移动事件。 */
  14236. static MOVE: number;
  14237. /** !#en The event type code of mouse scroll event.
  14238. !#zh 鼠标滚轮事件。 */
  14239. static SCROLL: number;
  14240. /** !#en The tag of Mouse left button.
  14241. !#zh 鼠标左键的标签。 */
  14242. static BUTTON_LEFT: number;
  14243. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  14244. !#zh 鼠标右键的标签。 */
  14245. static BUTTON_RIGHT: number;
  14246. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  14247. !#zh 鼠标中键的标签。 */
  14248. static BUTTON_MIDDLE: number;
  14249. /** !#en The tag of Mouse button 4.
  14250. !#zh 鼠标按键 4 的标签。 */
  14251. static BUTTON_4: number;
  14252. /** !#en The tag of Mouse button 5.
  14253. !#zh 鼠标按键 5 的标签。 */
  14254. static BUTTON_5: number;
  14255. /** !#en The tag of Mouse button 6.
  14256. !#zh 鼠标按键 6 的标签。 */
  14257. static BUTTON_6: number;
  14258. /** !#en The tag of Mouse button 7.
  14259. !#zh 鼠标按键 7 的标签。 */
  14260. static BUTTON_7: number;
  14261. /** !#en The tag of Mouse button 8.
  14262. !#zh 鼠标按键 8 的标签。 */
  14263. static BUTTON_8: number;
  14264. }
  14265. }
  14266. /****************************************************
  14267. * Event
  14268. *****************************************************/
  14269. export module Event {
  14270. /** !#en The touch event
  14271. !#zh 触摸事件 */
  14272. export class EventTouch extends Event {
  14273. /**
  14274. @param touchArr The array of the touches
  14275. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  14276. */
  14277. constructor(touchArr: any[], bubbles: boolean);
  14278. /** !#en The current touch object
  14279. !#zh 当前触点对象 */
  14280. touch: Touch;
  14281. /**
  14282. !#en Returns event code.
  14283. !#zh 获取事件类型。
  14284. */
  14285. getEventCode(): number;
  14286. /**
  14287. !#en Returns touches of event.
  14288. !#zh 获取触摸点的列表。
  14289. */
  14290. getTouches(): any[];
  14291. /**
  14292. !#en Sets touch location.
  14293. !#zh 设置当前触点位置
  14294. @param x x
  14295. @param y y
  14296. */
  14297. setLocation(x: number, y: number): void;
  14298. /**
  14299. !#en Returns touch location.
  14300. !#zh 获取触点位置。
  14301. */
  14302. getLocation(): Vec2;
  14303. /**
  14304. !#en Returns the current touch location in screen coordinates.
  14305. !#zh 获取当前触点在游戏窗口中的位置。
  14306. */
  14307. getLocationInView(): Vec2;
  14308. /**
  14309. !#en Returns the previous touch location.
  14310. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  14311. */
  14312. getPreviousLocation(): Vec2;
  14313. /**
  14314. !#en Returns the start touch location.
  14315. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  14316. */
  14317. getStartLocation(): Vec2;
  14318. /**
  14319. !#en Returns the id of cc.Touch.
  14320. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  14321. */
  14322. getID(): number;
  14323. /**
  14324. !#en Returns the delta distance from the previous location to current location.
  14325. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14326. */
  14327. getDelta(): Vec2;
  14328. /**
  14329. !#en Returns the X axis delta distance from the previous location to current location.
  14330. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  14331. */
  14332. getDeltaX(): number;
  14333. /**
  14334. !#en Returns the Y axis delta distance from the previous location to current location.
  14335. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  14336. */
  14337. getDeltaY(): number;
  14338. /**
  14339. !#en Returns location X axis data.
  14340. !#zh 获取当前触点 X 轴位置。
  14341. */
  14342. getLocationX(): number;
  14343. /**
  14344. !#en Returns location Y axis data.
  14345. !#zh 获取当前触点 Y 轴位置。
  14346. */
  14347. getLocationY(): number;
  14348. }
  14349. }
  14350. /****************************************************
  14351. * Event
  14352. *****************************************************/
  14353. export module Event {
  14354. /** !#en The acceleration event
  14355. !#zh 加速度事件 */
  14356. export class EventAcceleration extends Event {
  14357. }
  14358. }
  14359. /****************************************************
  14360. * Event
  14361. *****************************************************/
  14362. export module Event {
  14363. /** !#en The keyboard event
  14364. !#zh 键盘事件 */
  14365. export class EventKeyboard extends Event {
  14366. }
  14367. }
  14368. /****************************************************
  14369. * Graphics
  14370. *****************************************************/
  14371. export module Graphics {
  14372. /** !#en Enum for LineCap.
  14373. !#zh 线段末端属性 */
  14374. export enum LineCap {
  14375. BUTT = 0,
  14376. ROUND = 0,
  14377. SQUARE = 0,
  14378. }
  14379. }
  14380. /****************************************************
  14381. * Graphics
  14382. *****************************************************/
  14383. export module Graphics {
  14384. /** !#en Enum for LineJoin.
  14385. !#zh 线段拐角属性 */
  14386. export enum LineJoin {
  14387. BEVEL = 0,
  14388. ROUND = 0,
  14389. MITER = 0,
  14390. }
  14391. }
  14392. /****************************************************
  14393. * Pipeline
  14394. *****************************************************/
  14395. export module Pipeline {
  14396. /** The downloader pipe, it can download several types of files:
  14397. 1. Text
  14398. 2. Image
  14399. 3. Script
  14400. 4. Audio
  14401. 5. Assets
  14402. All unknown type will be downloaded as plain text.
  14403. You can pass custom supported types in the constructor. */
  14404. export class Downloader {
  14405. /**
  14406. Constructor of Downloader, you can pass custom supported types.
  14407. @param extMap Custom supported types with corresponded handler
  14408. @example
  14409. ```js
  14410. var downloader = new Downloader({
  14411. // This will match all url with `.scene` extension or all url with `scene` type
  14412. 'scene' : function (url, callback) {}
  14413. });
  14414. ```
  14415. */
  14416. constructor(extMap: any);
  14417. /**
  14418. Add custom supported types handler or modify existing type handler.
  14419. @param extMap Custom supported types with corresponded handler
  14420. */
  14421. addHandlers(extMap: any): void;
  14422. /**
  14423. !#en
  14424. Load subpackage with name.
  14425. !#zh
  14426. 通过子包名加载子包代码。
  14427. @param name Subpackage name
  14428. @param completeCallback Callback invoked when subpackage loaded
  14429. */
  14430. loadSubpackage(name: string, completeCallback?: (error: Error) => void): void;
  14431. }
  14432. }
  14433. /****************************************************
  14434. * Pipeline
  14435. *****************************************************/
  14436. export module Pipeline {
  14437. /** The loader pipe, it can load several types of files:
  14438. 1. Images
  14439. 2. JSON
  14440. 3. Plist
  14441. 4. Audio
  14442. 5. Font
  14443. 6. Cocos Creator scene
  14444. It will not interfere with items of unknown type.
  14445. You can pass custom supported types in the constructor. */
  14446. export class Loader {
  14447. /**
  14448. Constructor of Loader, you can pass custom supported types.
  14449. @param extMap Custom supported types with corresponded handler
  14450. @example
  14451. ```js
  14452. var loader = new Loader({
  14453. // This will match all url with `.scene` extension or all url with `scene` type
  14454. 'scene' : function (url, callback) {}
  14455. });
  14456. ```
  14457. */
  14458. constructor(extMap: any);
  14459. /**
  14460. Add custom supported types handler or modify existing type handler.
  14461. @param extMap Custom supported types with corresponded handler
  14462. */
  14463. addHandlers(extMap: any): void;
  14464. }
  14465. }
  14466. /****************************************************
  14467. * LoadingItems
  14468. *****************************************************/
  14469. export module LoadingItems {
  14470. /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR
  14471. !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */
  14472. export enum ItemState {
  14473. WORKING = 0,
  14474. COMPLETET = 0,
  14475. ERROR = 0,
  14476. }
  14477. }
  14478. /****************************************************
  14479. * Texture2D
  14480. *****************************************************/
  14481. export module Texture2D {
  14482. /** The texture pixel format, default value is RGBA8888 */
  14483. export enum PixelFormat {
  14484. RGB565 = 0,
  14485. RGB5A1 = 0,
  14486. RGBA4444 = 0,
  14487. RGB888 = 0,
  14488. RGBA8888 = 0,
  14489. A8 = 0,
  14490. I8 = 0,
  14491. AI88 = 0,
  14492. }
  14493. }
  14494. /****************************************************
  14495. * Texture2D
  14496. *****************************************************/
  14497. export module Texture2D {
  14498. /** The texture wrap mode */
  14499. export enum WrapMode {
  14500. REPEAT = 0,
  14501. CLAMP_TO_EDGE = 0,
  14502. MIRRORED_REPEAT = 0,
  14503. }
  14504. }
  14505. /****************************************************
  14506. * Texture2D
  14507. *****************************************************/
  14508. export module Texture2D {
  14509. /** The texture filter mode */
  14510. export enum Filter {
  14511. LINEAR = 0,
  14512. NEAREST = 0,
  14513. }
  14514. }
  14515. }
  14516. /** !#en
  14517. The global main namespace of DragonBones, all classes, functions,
  14518. properties and constants of DragonBones are defined in this namespace
  14519. !#zh
  14520. DragonBones 的全局的命名空间,
  14521. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  14522. declare module dragonBones {
  14523. /** !#en
  14524. The Armature Display of DragonBones <br/>
  14525. <br/>
  14526. (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  14527. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  14528. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/>
  14529. !#zh
  14530. DragonBones 骨骼动画 <br/>
  14531. <br/>
  14532. (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  14533. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  14534. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)<br/> */
  14535. export class ArmatureDisplay extends cc._RendererUnderSG {
  14536. /** !#en
  14537. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  14538. attachments, skins, etc) and animations but does not hold any state.<br/>
  14539. Multiple ArmatureDisplay can share the same DragonBones data.
  14540. !#zh
  14541. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  14542. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  14543. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  14544. dragonAsset: DragonBonesAsset;
  14545. /** !#en
  14546. The atlas asset for the DragonBones.
  14547. !#zh
  14548. 骨骼数据所需的 Atlas Texture 数据。 */
  14549. dragonAtlasAsset: DragonBonesAtlasAsset;
  14550. /** !#en The name of current armature.
  14551. !#zh 当前的 Armature 名称。 */
  14552. armatureName: string;
  14553. /** !#en The name of current playing animation.
  14554. !#zh 当前播放的动画名称。 */
  14555. animationName: string;
  14556. _defaultArmatureIndex: number;
  14557. /** !#en The time scale of this armature.
  14558. !#zh 当前骨骼中所有动画的时间缩放率。 */
  14559. timeScale: number;
  14560. /** !#en The play times of the default animation.
  14561. -1 means using the value of config file;
  14562. 0 means repeat for ever
  14563. >0 means repeat times
  14564. !#zh 播放默认动画的循环次数
  14565. -1 表示使用配置文件中的默认值;
  14566. 0 表示无限循环
  14567. >0 表示循环次数 */
  14568. playTimes: number;
  14569. /** !#en Indicates whether open debug bones.
  14570. !#zh 是否显示 bone 的 debug 信息。 */
  14571. debugBones: boolean;
  14572. /**
  14573. !#en
  14574. Play the specified animation.
  14575. Parameter animName specify the animation name.
  14576. Parameter playTimes specify the repeat times of the animation.
  14577. -1 means use the value of the config file.
  14578. 0 means play the animation for ever.
  14579. >0 means repeat times.
  14580. !#zh
  14581. 播放指定的动画.
  14582. animName 指定播放动画的名称。
  14583. playTimes 指定播放动画的次数。
  14584. -1 为使用配置文件中的次数。
  14585. 0 为无限循环播放。
  14586. >0 为动画的重复次数。
  14587. @param animName animName
  14588. @param playTimes playTimes
  14589. */
  14590. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  14591. /**
  14592. !#en
  14593. Get the all armature names in the DragonBones Data.
  14594. !#zh
  14595. 获取 DragonBones 数据中所有的 armature 名称
  14596. */
  14597. getArmatureNames(): any[];
  14598. /**
  14599. !#en
  14600. Get the all animation names of specified armature.
  14601. !#zh
  14602. 获取指定的 armature 的所有动画名称。
  14603. @param armatureName armatureName
  14604. */
  14605. getAnimationNames(armatureName: string): any[];
  14606. /**
  14607. !#en
  14608. Add event listener for the DragonBones Event.
  14609. !#zh
  14610. 添加 DragonBones 事件监听器。
  14611. @param type A string representing the event type to listen for.
  14612. @param listener The callback that will be invoked when the event is dispatched.
  14613. @param target The target (this object) to invoke the callback, can be null
  14614. */
  14615. addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void;
  14616. /**
  14617. !#en
  14618. Remove the event listener for the DragonBones Event.
  14619. !#zh
  14620. 移除 DragonBones 事件监听器。
  14621. @param type A string representing the event type to listen for.
  14622. @param listener listener
  14623. @param target target
  14624. */
  14625. removeEventListener(type: string, listener?: Function, target?: any): void;
  14626. /**
  14627. !#en
  14628. Build the armature for specified name.
  14629. !#zh
  14630. 构建指定名称的 armature 对象
  14631. @param armatureName armatureName
  14632. */
  14633. buildArmature(armatureName: string): dragonBones.Armature;
  14634. /**
  14635. !#en
  14636. Get the current armature object of the ArmatureDisplay.
  14637. !#zh
  14638. 获取 ArmatureDisplay 当前使用的 Armature 对象
  14639. */
  14640. armature(): any;
  14641. }
  14642. /** !#en The skeleton data of dragonBones.
  14643. !#zh dragonBones 的 骨骼数据。 */
  14644. export class DragonBonesAsset extends cc.Asset {
  14645. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  14646. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  14647. dragonBonesJson: string;
  14648. }
  14649. /** !#en The skeleton atlas data of dragonBones.
  14650. !#zh dragonBones 的骨骼纹理数据。 */
  14651. export class DragonBonesAtlasAsset extends cc.Asset {
  14652. atlasJson: string;
  14653. texture: cc.Texture2D;
  14654. }
  14655. }
  14656. /** !#en
  14657. AnySDK is a third party solution that offers game developers SDK integration without making changes to the SDK's features or parameters.It can do all of this while remaining invisible to your end user.Our goal is to handle all the tedious SDK integration work for you so that you can use your time to focus on the game itself.No matter if it’s the channel SDK, user system, payment system, ad system, statistics system, sharing system or any other type of SDK: we’ll take care of it for you.
  14658. !#zh
  14659. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  14660. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  14661. declare module anysdk {
  14662. /** !#en
  14663. agent manager of plugin
  14664. !#zh
  14665. 插件管理对象 */
  14666. export var agentManager: anysdk.AgentManager;
  14667. /** !#en
  14668. agent manager of plugin
  14669. !#zh
  14670. 插件管理类 */
  14671. export class AgentManager {
  14672. /**
  14673. !#en
  14674. AppKey appSecret and privateKey are the only three parameters generated
  14675. after the packing tool client finishes creating the game.
  14676. The oauthLoginServer parameter is the API address provided by the game service
  14677. to login verification
  14678. !#zh
  14679. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  14680. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  14681. @param appKey appKey
  14682. @param appSecret appSecret
  14683. @param privateKey privateKey
  14684. @param oauthLoginServer oauthLoginServer
  14685. */
  14686. init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void;
  14687. /**
  14688. !#en
  14689. load all plugins, the operation includes SDK`s initialization
  14690. !#zh
  14691. 加载所有插件,该操作包含了 SDKs 初始化
  14692. @param callback callback
  14693. @param target The object to bind to.
  14694. */
  14695. loadAllPlugins(callback: Function, target: any): void;
  14696. /**
  14697. !#en
  14698. unload all plugins
  14699. !#zh
  14700. 卸载插件
  14701. */
  14702. unloadAllPlugins(): void;
  14703. /**
  14704. !#en
  14705. get user system plugin
  14706. !#zh
  14707. 获取用户系统插件
  14708. */
  14709. getUserPlugin(): anysdk.ProtocolUser;
  14710. /**
  14711. !#en
  14712. get IAP system plugins
  14713. !#zh
  14714. 获取支付系统插件
  14715. */
  14716. getIAPPlugins(): anysdk.ProtocolIAP[];
  14717. /**
  14718. !#en
  14719. get IAP system plugin
  14720. !#zh
  14721. 获取支付系统插件
  14722. */
  14723. getIAPPlugin(): anysdk.ProtocolIAP;
  14724. /**
  14725. !#en
  14726. get social system plugin
  14727. !#zh
  14728. 获取社交系统插件
  14729. */
  14730. getSocialPlugin(): anysdk.ProtocolSocial;
  14731. /**
  14732. !#en
  14733. get share system plugin
  14734. !#zh
  14735. 获取分享系统插件
  14736. */
  14737. getSharePlugin(): anysdk.ProtocolShare;
  14738. /**
  14739. !#en
  14740. get analytics system plugin
  14741. !#zh
  14742. 获取统计系统插件
  14743. */
  14744. getAnalyticsPlugin(): anysdk.ProtocolAnalytics;
  14745. /**
  14746. !#en
  14747. get ads system plugin
  14748. !#zh
  14749. 获取广告系统插件
  14750. */
  14751. getAdsPlugin(): anysdk.ProtocolAds;
  14752. /**
  14753. !#en
  14754. get push system plugin
  14755. !#zh
  14756. 获取推送系统插件
  14757. */
  14758. getPushPlugin(): anysdk.ProtocolPush;
  14759. /**
  14760. !#en
  14761. get REC system plugin
  14762. !#zh
  14763. 获取录屏系统插件
  14764. */
  14765. getRECPlugin(): anysdk.ProtocolREC;
  14766. /**
  14767. !#en
  14768. get crash system plugin
  14769. !#zh
  14770. 获取崩溃分析系统插件
  14771. */
  14772. getCrashPlugin(): anysdk.ProtocolCrash;
  14773. /**
  14774. !#en
  14775. get ad track system plugin
  14776. !#zh
  14777. 获取广告追踪系统插件
  14778. */
  14779. getAdTrackingPlugin(): anysdk.ProtocolAdTracking;
  14780. /**
  14781. !#en
  14782. get custom system plugin
  14783. !#zh
  14784. 获取自定义系统插件
  14785. */
  14786. getCustomPlugin(): anysdk.ProtocolCustom;
  14787. /**
  14788. !#en
  14789. get custom parameter
  14790. !#zh
  14791. 获取自定义参数
  14792. */
  14793. getCustomParam(): string;
  14794. /**
  14795. !#en
  14796. get channel id
  14797. !#zh
  14798. 获取渠道唯一表示符
  14799. */
  14800. getChannelId(): string;
  14801. /**
  14802. !#en
  14803. get status of analytics
  14804. !#zh
  14805. 获取统计状态
  14806. */
  14807. isAnaylticsEnabled(): boolean;
  14808. /**
  14809. !#en
  14810. set whether to analytics
  14811. !#zh
  14812. 设置是否统计
  14813. @param enabled enabled
  14814. */
  14815. setIsAnaylticsEnabled(enabled: boolean): void;
  14816. /**
  14817. !#en
  14818. destory instance
  14819. !#zh
  14820. 销毁单例
  14821. */
  14822. static end(): void;
  14823. /**
  14824. !#en
  14825. get instance
  14826. !#zh
  14827. 获取单例
  14828. */
  14829. static getInstance(): anysdk.AgentManager;
  14830. }
  14831. /** !#en
  14832. plugin protocol
  14833. !#zh
  14834. 插件协议 */
  14835. export class PluginProtocol {
  14836. /**
  14837. !#en
  14838. Check whether the function is supported
  14839. !#zh
  14840. 判断函数是否支持
  14841. @param functionName functionName
  14842. */
  14843. isFunctionSupported(functionName: string): boolean;
  14844. /**
  14845. !#en
  14846. get plugin name
  14847. !#zh
  14848. 获取插件名称
  14849. */
  14850. getPluginName(): string;
  14851. /**
  14852. !#en
  14853. get plugin version
  14854. !#zh
  14855. 获取插件版本
  14856. */
  14857. getPluginVersion(): string;
  14858. /**
  14859. !#en
  14860. get SDK version
  14861. !#zh
  14862. 获取 SDK 版本
  14863. */
  14864. getSDKVersion(): string;
  14865. /**
  14866. !#en
  14867. void methods for reflections with parameter
  14868. !#zh
  14869. 反射调用带参数的void方法
  14870. @param funName funName
  14871. @param args optional arguments
  14872. */
  14873. callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void;
  14874. /**
  14875. !#en
  14876. String methods for reflections with parameter
  14877. !#zh
  14878. 反射调用带参数的 String 方法
  14879. @param funName funName
  14880. @param args optional arguments
  14881. */
  14882. callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string;
  14883. /**
  14884. !#en
  14885. int methods for reflections with parameter
  14886. !#zh
  14887. 反射调用带参数的 Int 方法
  14888. @param funName funName
  14889. @param args optional arguments
  14890. */
  14891. callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14892. /**
  14893. !#en
  14894. boolean methods for reflections with parameter
  14895. !#zh
  14896. 反射调用带参数的 boolean 方法
  14897. @param funName funName
  14898. @param args optional arguments
  14899. */
  14900. callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean;
  14901. /**
  14902. !#en
  14903. float methods for reflections with parameter
  14904. !#zh
  14905. 反射调用带参数的 float 方法
  14906. @param funName funName
  14907. @param args optional arguments
  14908. */
  14909. callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14910. }
  14911. /** !#en
  14912. user protocol
  14913. !#zh
  14914. 用户系统协议接口 */
  14915. export class ProtocolUser extends PluginProtocol {
  14916. /**
  14917. !#en
  14918. login interface
  14919. !#zh
  14920. 登录接口
  14921. @param args optional arguments
  14922. */
  14923. login(...args: string|any[]): void;
  14924. /**
  14925. !#en
  14926. get status of login
  14927. !#zh
  14928. 获取登录状态
  14929. */
  14930. isLogined(): boolean;
  14931. /**
  14932. !#en
  14933. get user ID
  14934. !#zh
  14935. 获取用户唯一标示符
  14936. */
  14937. getUserID(): string;
  14938. /**
  14939. !#en
  14940. get plugin ID
  14941. !#zh
  14942. 获取插件ID
  14943. */
  14944. getPluginId(): string;
  14945. /**
  14946. !#en
  14947. set listener
  14948. !#zh
  14949. 设置用户系统的监听
  14950. @param listener listener
  14951. @param target target
  14952. */
  14953. setListener(listener: Function, target: any): void;
  14954. /**
  14955. !#en
  14956. get listener
  14957. !#zh
  14958. 获取用户系统的监听
  14959. */
  14960. getListener(): Function;
  14961. /**
  14962. !#en
  14963. logout
  14964. Before to invoke, you need to verdict whether this properties existed
  14965. !#zh
  14966. 登出,调用前需要判断属性是否存在
  14967. */
  14968. logout(): void;
  14969. /**
  14970. !#en
  14971. show toolbar
  14972. Before to invoke, you need to verdict whether this properties existed
  14973. !#zh
  14974. 显示悬浮窗,调用前需要判断属性是否存在
  14975. @param place place
  14976. */
  14977. showToolBar(place: anysdk.ToolBarPlace): void;
  14978. /**
  14979. !#en
  14980. hide toolbar
  14981. Before to invoke, you need to verdict whether this properties existed
  14982. !#zh
  14983. 隐藏悬浮窗,调用前需要判断属性是否存在
  14984. */
  14985. hideToolBar(): void;
  14986. /**
  14987. !#en
  14988. enter platform
  14989. Before to invoke, you need to verdict whether this properties existed
  14990. !#zh
  14991. 显示平台中心,调用前需要判断属性是否存在
  14992. */
  14993. enterPlatform(): void;
  14994. /**
  14995. !#en
  14996. show exit page
  14997. Before to invoke, you need to verdict whether this properties existed
  14998. !#zh
  14999. 显示退出界面,调用前需要判断属性是否存在
  15000. */
  15001. exit(): void;
  15002. /**
  15003. !#en
  15004. show pause page
  15005. Before to invoke, you need to verdict whether this properties existed
  15006. !#zh
  15007. 显示暂停界面,调用前需要判断属性是否存在
  15008. */
  15009. pause(): void;
  15010. /**
  15011. !#en
  15012. Real-name registration
  15013. Before to invoke, you need to verdict whether this properties existed
  15014. !#zh
  15015. 实名注册,调用前需要判断属性是否存在
  15016. */
  15017. realNameRegister(): void;
  15018. /**
  15019. !#en
  15020. Anti-addiction query
  15021. Before to invoke, you need to verdict whether this properties existed
  15022. !#zh
  15023. 防沉迷查询,调用前需要判断属性是否存在
  15024. */
  15025. antiAddictionQuery(): void;
  15026. /**
  15027. !#en
  15028. submit game role information
  15029. Before to invoke, you need to verdict whether this properties existed
  15030. !#zh
  15031. 提交角色信息,调用前需要判断属性是否存在
  15032. @param data data
  15033. */
  15034. submitLoginGameRole(data: any): void;
  15035. /**
  15036. !#en
  15037. get user information
  15038. Before to invoke, you need to verdict whether this properties existed
  15039. !#zh
  15040. 获取用户信息,调用前需要判断属性是否存在
  15041. @param info info
  15042. */
  15043. getUserInfo(info: any): void;
  15044. /**
  15045. !#en
  15046. set login type
  15047. Before to invoke, you need to verdict whether this properties existed
  15048. !#zh
  15049. 设置登录类型,调用前需要判断属性是否存在
  15050. @param info info
  15051. */
  15052. getAvailableLoginType(info: any): void;
  15053. /**
  15054. !#en
  15055. set login type
  15056. Before to invoke, you need to verdict whether this properties existed
  15057. !#zh
  15058. 设置登录类型,调用前需要判断属性是否存在
  15059. @param loginType loginType
  15060. */
  15061. setLoginType(loginType: string): void;
  15062. /**
  15063. !#en
  15064. send to desktop
  15065. Before to invoke, you need to verdict whether this properties existed
  15066. !#zh
  15067. 发送到桌面,调用前需要判断属性是否存在
  15068. */
  15069. sendToDesktop(): void;
  15070. /**
  15071. !#en
  15072. open bbs
  15073. Before to invoke, you need to verdict whether this properties existed
  15074. !#zh
  15075. 打开论坛,调用前需要判断属性是否存在
  15076. */
  15077. openBBS(): void;
  15078. }
  15079. /** !#en
  15080. IAP protocol
  15081. !#zh
  15082. 支付系统协议接口 */
  15083. export class ProtocolIAP extends PluginProtocol {
  15084. /**
  15085. !#en
  15086. pay interface
  15087. !#zh
  15088. 支付接口
  15089. @param info Type:map
  15090. */
  15091. payForProduct(info: any): void;
  15092. /**
  15093. !#en
  15094. get order ID
  15095. !#zh
  15096. 获取订单ID
  15097. */
  15098. getOrderId(): string;
  15099. /**
  15100. !#en
  15101. reset the pay status
  15102. !#zh
  15103. 重置支付状态
  15104. */
  15105. static resetPayState(): void;
  15106. /**
  15107. !#en
  15108. get plugin ID
  15109. !#zh
  15110. 获取插件ID
  15111. */
  15112. getPluginId(): string;
  15113. /**
  15114. !#en
  15115. set listener
  15116. !#zh
  15117. 设置支付系统的监听
  15118. @param listener listener
  15119. @param target target
  15120. */
  15121. setListener(listener: Function, target: any): void;
  15122. /**
  15123. !#en
  15124. get listener
  15125. !#zh
  15126. 获取支付系统的监听
  15127. */
  15128. getListener(): Function;
  15129. }
  15130. /** !#en
  15131. analytics protocol
  15132. !#zh
  15133. 统计系统协议接口 */
  15134. export class ProtocolAnalytics extends PluginProtocol {
  15135. /**
  15136. !#en
  15137. Start a new session.
  15138. !#zh
  15139. 启动会话
  15140. */
  15141. startSession(): void;
  15142. /**
  15143. !#en
  15144. Stop a session.
  15145. !#zh
  15146. 关闭会话
  15147. */
  15148. stopSession(): void;
  15149. /**
  15150. !#en
  15151. Set the timeout for expiring a session.
  15152. !#zh
  15153. 设置会话超时时间
  15154. @param millis Type: long
  15155. */
  15156. setSessionContinueMillis(millis: number): void;
  15157. /**
  15158. !#en
  15159. log an error
  15160. !#zh
  15161. 捕捉异常
  15162. @param errorId errorId
  15163. @param message message
  15164. */
  15165. logError(errorId: string, message: string): void;
  15166. /**
  15167. !#en
  15168. log an event.
  15169. !#zh
  15170. 捕捉事件
  15171. @param errorId errorId
  15172. @param args optional arguments Type: map
  15173. */
  15174. logEvent(errorId: string, ...args: any[]): void;
  15175. /**
  15176. !#en
  15177. Track an event begin.
  15178. !#zh
  15179. 统计事件开始
  15180. @param eventId eventId
  15181. */
  15182. logTimedEventBegin(eventId: string): void;
  15183. /**
  15184. !#en
  15185. Track an event end.
  15186. !#zh
  15187. 统计事件结束
  15188. @param eventId eventId
  15189. */
  15190. logTimedEventEnd(eventId: string): void;
  15191. /**
  15192. !#en
  15193. set Whether to catch uncaught exceptions to server.
  15194. !#zh
  15195. 设置是否开启自动异常捕捉
  15196. @param enabled enabled
  15197. */
  15198. setCaptureUncaughtException(enabled: boolean): void;
  15199. /**
  15200. !#en
  15201. analytics account information
  15202. !#zh
  15203. 统计玩家帐户信息
  15204. @param paramMap Type: map
  15205. */
  15206. setAccount(paramMap: any): void;
  15207. /**
  15208. !#en
  15209. track user to request payment
  15210. !#zh
  15211. 跟踪用户支付请求
  15212. @param paramMap Type: map
  15213. */
  15214. onChargeRequest(paramMap: any): void;
  15215. /**
  15216. !#en
  15217. track Successful payment
  15218. !#zh
  15219. 追踪用户支付成功
  15220. @param orderID orderID
  15221. */
  15222. onChargeSuccess(orderID: string): void;
  15223. /**
  15224. !#en
  15225. track failed payment
  15226. !#zh
  15227. 追踪用户支付失败
  15228. @param paramMap Type: map
  15229. */
  15230. onChargeFail(paramMap: any): void;
  15231. /**
  15232. !#en
  15233. track Successful payment
  15234. !#zh
  15235. 统计玩家支付成功
  15236. @param paramMap Type: map
  15237. */
  15238. onChargeOnlySuccess(paramMap: any): void;
  15239. /**
  15240. !#en
  15241. track user purchase
  15242. !#zh
  15243. 统计玩家消费
  15244. @param paramMap Type: map
  15245. */
  15246. onPurchase(paramMap: any): void;
  15247. /**
  15248. !#en
  15249. track user to use goods
  15250. !#zh
  15251. 统计玩家使用道具
  15252. @param paramMap Type: map
  15253. */
  15254. onUse(paramMap: any): void;
  15255. /**
  15256. !#en
  15257. track user to reward goods
  15258. !#zh
  15259. 统计玩家获取奖励
  15260. @param paramMap Type: map
  15261. */
  15262. onReward(paramMap: any): void;
  15263. /**
  15264. !#en
  15265. start level
  15266. !#zh
  15267. 开始关卡
  15268. @param paramMap Type: map
  15269. */
  15270. startLevel(paramMap: any): void;
  15271. /**
  15272. !#en
  15273. finish level
  15274. !#zh
  15275. 结束关卡
  15276. @param levelID levelID
  15277. */
  15278. finishLevel(levelID: string): void;
  15279. /**
  15280. !#en
  15281. failed level
  15282. !#zh
  15283. 关卡失败
  15284. @param paramMap Type: map
  15285. */
  15286. failLevel(paramMap: any): void;
  15287. /**
  15288. !#en
  15289. start task
  15290. !#zh
  15291. 开始任务
  15292. @param paramMap Type: map
  15293. */
  15294. startTask(paramMap: any): void;
  15295. /**
  15296. !#en
  15297. finish task
  15298. !#zh
  15299. 完成任务
  15300. @param taskID taskID
  15301. */
  15302. finishTask(taskID: string): void;
  15303. /**
  15304. !#en
  15305. failed task
  15306. !#zh
  15307. 任务失败
  15308. @param paramMap Type: map
  15309. */
  15310. failTask(paramMap: any): void;
  15311. }
  15312. /** !#en
  15313. share protocol
  15314. !#zh
  15315. 分享系统协议接口 */
  15316. export class ProtocolShare extends PluginProtocol {
  15317. /**
  15318. !#en
  15319. share interface
  15320. !#zh
  15321. 分享
  15322. @param info Type: map
  15323. */
  15324. share(info: any): void;
  15325. /**
  15326. !#en
  15327. set listener
  15328. !#zh
  15329. 设置分享系统的监听
  15330. @param listener listener
  15331. @param target target
  15332. */
  15333. setListener(listener: Function, target: any): void;
  15334. /**
  15335. !#en
  15336. get listener
  15337. !#zh
  15338. 获取分享系统的监听
  15339. */
  15340. getListener(): Function;
  15341. }
  15342. /** !#en
  15343. ads protocol
  15344. !#zh
  15345. 广告系统协议接口 */
  15346. export class ProtocolAds extends PluginProtocol {
  15347. /**
  15348. !#en
  15349. hide ads view
  15350. !#zh
  15351. 隐藏广告
  15352. @param adstype adstype
  15353. @param idx idx
  15354. */
  15355. hideAds(adstype: anysdk.AdsType, idx: number): void;
  15356. /**
  15357. !#en
  15358. preload ads view
  15359. !#zh
  15360. 预加载广告
  15361. @param adstype adstype
  15362. @param idx idx
  15363. */
  15364. preloadAds(adstype: anysdk.AdsType, idx: number): void;
  15365. /**
  15366. !#en
  15367. query points
  15368. !#zh
  15369. 查询分数
  15370. */
  15371. queryPoints(): number;
  15372. /**
  15373. !#en
  15374. get whether the ads type is supported
  15375. !#zh
  15376. 获取广告类型是否支持
  15377. @param arg0 arg0
  15378. */
  15379. isAdTypeSupported(arg0: anysdk.AdsType): boolean;
  15380. /**
  15381. !#en
  15382. spend point
  15383. !#zh
  15384. 消费分数
  15385. @param points points
  15386. */
  15387. spendPoints(points: number): void;
  15388. /**
  15389. !#en
  15390. set listener
  15391. !#zh
  15392. 设置广告系统的监听
  15393. @param listener listener
  15394. @param target target
  15395. */
  15396. setListener(listener: Function, target: any): void;
  15397. /**
  15398. !#en
  15399. get listener
  15400. !#zh
  15401. 获取广告系统的监听
  15402. */
  15403. getListener(): Function;
  15404. }
  15405. /** !#en
  15406. social protocol
  15407. !#zh
  15408. 社交系统协议接口 */
  15409. export class ProtocolSocial extends PluginProtocol {
  15410. /**
  15411. !#en
  15412. sign in
  15413. !#zh
  15414. 登录
  15415. */
  15416. signIn(): void;
  15417. /**
  15418. !#en
  15419. sign out
  15420. !#zh
  15421. 登出
  15422. */
  15423. signOut(): void;
  15424. /**
  15425. !#en
  15426. submit score
  15427. !#zh
  15428. 提交分数
  15429. @param leadboardID leadboardID
  15430. @param score Type: long
  15431. */
  15432. submitScore(leadboardID: string, score: number): void;
  15433. /**
  15434. !#en
  15435. show the id of Leaderboard page
  15436. !#zh
  15437. 根据唯一标识符显示排行榜
  15438. @param leaderboardID leaderboardID
  15439. */
  15440. showLeaderboard(leaderboardID: string): void;
  15441. /**
  15442. !#en
  15443. show the page of achievements
  15444. !#zh
  15445. 显示成就榜
  15446. */
  15447. showAchievements(): void;
  15448. /**
  15449. !#en
  15450. unlock achievement
  15451. !#zh
  15452. 解锁成就
  15453. @param info Type: map
  15454. */
  15455. share(info: any): void;
  15456. /**
  15457. !#en
  15458. set listener
  15459. !#zh
  15460. 设置社交系统的监听
  15461. @param listener listener
  15462. @param target target
  15463. */
  15464. setListener(listener: Function, target: any): void;
  15465. /**
  15466. !#en
  15467. get listener
  15468. !#zh
  15469. 获取社交系统的监听
  15470. */
  15471. getListener(): Function;
  15472. /**
  15473. !#en
  15474. get friends info
  15475. Before to invoke, you need to verdict whether this properties existed
  15476. !#zh
  15477. 获取好友信息,调用前需要判断属性是否存在
  15478. */
  15479. pauseRecording(): void;
  15480. /**
  15481. !#en
  15482. interact
  15483. Before to invoke, you need to verdict whether this properties existed
  15484. !#zh
  15485. 订阅,调用前需要判断属性是否存在
  15486. */
  15487. interact(): void;
  15488. /**
  15489. !#en
  15490. subscribe
  15491. Before to invoke, you need to verdict whether this properties existed
  15492. !#zh
  15493. 关注,调用前需要判断属性是否存在
  15494. */
  15495. subscribe(): void;
  15496. }
  15497. /** !#en
  15498. push protocol
  15499. !#zh
  15500. 推送系统协议接口 */
  15501. export class ProtocolPush extends PluginProtocol {
  15502. /**
  15503. !#en
  15504. start Push services
  15505. !#zh
  15506. 启动推送服务
  15507. */
  15508. startPush(): void;
  15509. /**
  15510. !#en
  15511. close Push services
  15512. !#zh
  15513. 暂停推送服务
  15514. */
  15515. closePush(): void;
  15516. /**
  15517. !#en
  15518. delete alias
  15519. !#zh
  15520. 删除别名
  15521. @param alias alias
  15522. */
  15523. delAlias(alias: string): void;
  15524. /**
  15525. !#en
  15526. set alias
  15527. !#zh
  15528. 设置别名
  15529. @param alias alias
  15530. */
  15531. setAlias(alias: string): void;
  15532. /**
  15533. !#en
  15534. delete tags
  15535. !#zh
  15536. 删除标签
  15537. @param tags Type: list
  15538. */
  15539. delTags(tags: any): void;
  15540. /**
  15541. !#en
  15542. set tags
  15543. !#zh
  15544. 设置标签
  15545. @param tags Type: list
  15546. */
  15547. setTags(tags: any): void;
  15548. /**
  15549. !#en
  15550. set listener
  15551. !#zh
  15552. 设置推送系统的监听
  15553. @param listener listener
  15554. @param target target
  15555. */
  15556. setListener(listener: Function, target: any): void;
  15557. /**
  15558. !#en
  15559. get listener
  15560. !#zh
  15561. 获取推送系统的监听
  15562. */
  15563. getListener(): Function;
  15564. }
  15565. /** !#en
  15566. crash protocol
  15567. !#zh
  15568. 崩溃分析系统协议接口 */
  15569. export class ProtocolCrash extends PluginProtocol {
  15570. /**
  15571. !#en
  15572. set user identifier
  15573. !#zh
  15574. 统计用户唯一标识符
  15575. @param identifier identifier
  15576. */
  15577. setUserIdentifier(identifier: string): void;
  15578. /**
  15579. !#en
  15580. The uploader captured in exception information
  15581. !#zh
  15582. 上报异常信息
  15583. @param message message
  15584. @param exception exception
  15585. */
  15586. reportException(message: string, exception: string): void;
  15587. /**
  15588. !#en
  15589. customize logging
  15590. !#zh
  15591. 自定义日志记录
  15592. @param breadcrumb breadcrumb
  15593. */
  15594. leaveBreadcrumb(breadcrumb: string): void;
  15595. }
  15596. /** !#en
  15597. REC protocol
  15598. !#zh
  15599. 录屏系统协议接口 */
  15600. export class ProtocolREC extends PluginProtocol {
  15601. /**
  15602. !#en
  15603. share video
  15604. !#zh
  15605. 分享视频
  15606. @param info Type: map
  15607. */
  15608. share(info: any): void;
  15609. /**
  15610. !#en
  15611. Start to record video
  15612. !#zh
  15613. 开始录制视频
  15614. */
  15615. startRecording(): void;
  15616. /**
  15617. !#en
  15618. Start to record video
  15619. !#zh
  15620. 结束录制视频
  15621. */
  15622. stopRecording(): void;
  15623. /**
  15624. !#en
  15625. set listener
  15626. !#zh
  15627. 设置录屏系统的监听
  15628. @param listener listener
  15629. @param target target
  15630. */
  15631. setListener(listener: Function, target: any): void;
  15632. /**
  15633. !#en
  15634. get listener
  15635. !#zh
  15636. 获取录屏系统的监听
  15637. */
  15638. getListener(): Function;
  15639. /**
  15640. !#en
  15641. pause to record video
  15642. Before to invoke, you need to verdict whether this properties existed
  15643. !#zh
  15644. 暂停录制视频,调用前需要判断属性是否存在
  15645. */
  15646. pauseRecording(): void;
  15647. /**
  15648. !#en
  15649. resume to record video
  15650. Before to invoke, you need to verdict whether this properties existed
  15651. !#zh
  15652. 恢复录制视频,调用前需要判断属性是否存在
  15653. */
  15654. resumeRecording(): void;
  15655. /**
  15656. !#en
  15657. get whether the device is isAvailable
  15658. Before to invoke, you need to verdict whether this properties existed
  15659. !#zh
  15660. 获取设备是否可用,调用前需要判断属性是否存在
  15661. */
  15662. isAvailable(): boolean;
  15663. /**
  15664. !#en
  15665. get status of recording
  15666. Before to invoke, you need to verdict whether this properties existed
  15667. !#zh
  15668. 获取录制状态,调用前需要判断属性是否存在
  15669. */
  15670. isRecording(): boolean;
  15671. /**
  15672. !#en
  15673. show toolbar
  15674. Before to invoke, you need to verdict whether this properties existed
  15675. !#zh
  15676. 显示悬浮窗,调用前需要判断属性是否存在
  15677. */
  15678. showToolBar(): void;
  15679. /**
  15680. !#en
  15681. hide toolbar
  15682. Before to invoke, you need to verdict whether this properties existed
  15683. !#zh
  15684. 隐藏悬浮窗,调用前需要判断属性是否存在
  15685. */
  15686. hideToolBar(): void;
  15687. /**
  15688. !#en
  15689. show video center
  15690. Before to invoke, you need to verdict whether this properties existed
  15691. !#zh
  15692. 显示视频中心,调用前需要判断属性是否存在
  15693. */
  15694. showVideoCenter(): void;
  15695. /**
  15696. !#en
  15697. enter platform
  15698. Before to invoke, you need to verdict whether this properties existed
  15699. !#zh
  15700. 显示平台中心,调用前需要判断属性是否存在
  15701. */
  15702. enterPlatform(): void;
  15703. /**
  15704. !#en
  15705. Set the video data, it is recommended to check whether are recorded firstly
  15706. Before to invoke, you need to verdict whether this properties existed
  15707. !#zh
  15708. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  15709. @param info Type: map
  15710. */
  15711. setMetaData(info: any): void;
  15712. }
  15713. /** !#en
  15714. ad tracking protocol
  15715. !#zh
  15716. 广告追踪系统协议接口 */
  15717. export class ProtocolAdTracking extends PluginProtocol {
  15718. /**
  15719. !#en
  15720. Call this method if you want to track register events as happening during a section.
  15721. !#zh
  15722. 统计用户注册信息
  15723. @param productInfo Type: map
  15724. */
  15725. onPay(productInfo: any): void;
  15726. /**
  15727. !#en
  15728. Call this method if you want to track register events as happening during a section.
  15729. !#zh
  15730. 统计用户注册信息
  15731. @param userInfo Type: map
  15732. */
  15733. onLogin(userInfo: any): void;
  15734. /**
  15735. !#en
  15736. Call this method if you want to track register events as happening during a section.
  15737. !#zh
  15738. 统计用户注册信息
  15739. @param userId userId
  15740. */
  15741. onRegister(userId: string): void;
  15742. /**
  15743. !#en
  15744. Call this method if you want to track custom events with parameters as happening during a section.
  15745. !#zh
  15746. 统计自定义事件
  15747. @param eventId eventId
  15748. @param paramMap Type: map
  15749. */
  15750. trackEvent(eventId: string, paramMap: any): void;
  15751. /**
  15752. !#en
  15753. Call this method with parameters if you want to create role as happening during a section.
  15754. !#zh
  15755. 统计创建角色事件,调用前需要判断属性是否存在
  15756. @param userInfo Type: map
  15757. */
  15758. onCreateRole(userInfo: any): void;
  15759. /**
  15760. !#en
  15761. Call this method if you want to track levelup events with parameters as happening during a section.
  15762. Before to invoke, you need to verdict whether this properties existed
  15763. !#zh
  15764. 统计角色升级事件,调用前需要判断属性是否存在
  15765. @param info Type: map
  15766. */
  15767. onLevelUp(info: any): void;
  15768. /**
  15769. !#en
  15770. Invoke this method with parameters if you want to start to pay as happening during a section.
  15771. Before to invoke, you need to verdict whether this properties existed
  15772. !#zh
  15773. 统计开始充值事件,调用前需要判断属性是否存在
  15774. @param info Type: map
  15775. */
  15776. onStartToPay(info: any): void;
  15777. }
  15778. /** !#en
  15779. custom protocol
  15780. !#zh
  15781. 自定义系统协议接口 */
  15782. export class ProtocolCustom extends PluginProtocol {
  15783. /**
  15784. !#en
  15785. set listener
  15786. !#zh
  15787. 设置自定义系统的监听
  15788. @param listener listener
  15789. @param target target
  15790. */
  15791. setListener(listener: Function, target: any): void;
  15792. /**
  15793. !#en
  15794. get listener
  15795. !#zh
  15796. 获取自定义系统的监听
  15797. */
  15798. getListener(): Function;
  15799. }
  15800. /** !#en
  15801. Data structure class
  15802. !#zh
  15803. 数据结构类 */
  15804. export class PluginParam {
  15805. /**
  15806. !#en
  15807. create plugin parameters
  15808. !#zh
  15809. 创建对象
  15810. @param parameters parameters
  15811. */
  15812. static create(parameters: number|string|any): anysdk.PluginParam;
  15813. }
  15814. /** !#en The callback of user system
  15815. !#zh 用户系统回调 */
  15816. export enum UserActionResultCode {
  15817. kInitSuccess = 0,
  15818. kInitFail = 0,
  15819. kLoginSuccess = 0,
  15820. kLoginNetworkError = 0,
  15821. kLoginNoNeed = 0,
  15822. kLoginFail = 0,
  15823. kLoginCancel = 0,
  15824. kLogoutSuccess = 0,
  15825. kLogoutFail = 0,
  15826. kPlatformEnter = 0,
  15827. kPlatformBack = 0,
  15828. kPausePage = 0,
  15829. kExitPage = 0,
  15830. kAntiAddictionQuery = 0,
  15831. kRealNameRegister = 0,
  15832. kAccountSwitchSuccess = 0,
  15833. kAccountSwitchFail = 0,
  15834. kOpenShop = 0,
  15835. kAccountSwitchCancel = 0,
  15836. kUserExtension = 0,
  15837. kSendToDesktopSuccess = 0,
  15838. kSendToDesktopFail = 0,
  15839. kGetAvailableLoginTypeSuccess = 0,
  15840. kGetAvailableLoginTypeFail = 0,
  15841. kGetUserInfoSuccess = 0,
  15842. kGetUserInfoFail = 0,
  15843. kOpenBBSSuccess = 0,
  15844. kOpenBBSFail = 0,
  15845. }
  15846. /** !#en The toolbar position of user type
  15847. !#zh 用户系统悬浮窗位置 */
  15848. export enum ToolBarPlace {
  15849. kToolBarTopLeft = 0,
  15850. kToolBarTopRight = 0,
  15851. kToolBarMidLeft = 0,
  15852. kToolBarMidRight = 0,
  15853. kToolBarBottomLeft = 0,
  15854. kToolBarBottomRight = 0,
  15855. }
  15856. /** !#en The callback of requesting reStringge
  15857. !#zh 支付系统支付请求回调 */
  15858. export enum PayResultCode {
  15859. kPaySuccess = 0,
  15860. kPayFail = 0,
  15861. kPayCancel = 0,
  15862. kPayNetworkError = 0,
  15863. kPayProductionInforIncomplete = 0,
  15864. kPayInitSuccess = 0,
  15865. kPayInitFail = 0,
  15866. kPayNowPaying = 0,
  15867. kPayReStringgeSuccess = 0,
  15868. kPayExtension = 0,
  15869. kPayNeedLoginAgain = 0,
  15870. kRequestSuccess = 0,
  15871. kRequestFail = 0,
  15872. }
  15873. /** !#en The enum of account type
  15874. !#zh 统计系统的账号类型 */
  15875. export enum AccountType {
  15876. ANONYMOUS = 0,
  15877. REGISTED = 0,
  15878. SINA_WEIBO = 0,
  15879. TENCENT_WEIBO = 0,
  15880. QQ = 0,
  15881. ND91 = 0,
  15882. }
  15883. /** !#en The enum of account operation
  15884. !#zh 统计系统的账号操作 */
  15885. export enum AccountOperate {
  15886. LOGIN = 0,
  15887. LOGOUT = 0,
  15888. REGISTER = 0,
  15889. }
  15890. /** !#en The enum of gender
  15891. !#zh 统计系统的账号性别 */
  15892. export enum AccountGender {
  15893. MALE = 0,
  15894. FEMALE = 0,
  15895. UNKNOWN = 0,
  15896. }
  15897. /** !#en The enum of task type
  15898. !#zh 统计系统的任务类型 */
  15899. export enum TaskType {
  15900. GUIDE_LINE = 0,
  15901. MAIN_LINE = 0,
  15902. BRANCH_LINE = 0,
  15903. DAILY = 0,
  15904. ACTIVITY = 0,
  15905. OTHER = 0,
  15906. }
  15907. /** !#en The callback of share system
  15908. !#zh 分享系统回调 */
  15909. export enum ShareResultCode {
  15910. kShareSuccess = 0,
  15911. kShareFail = 0,
  15912. kShareCancel = 0,
  15913. kShareNetworkError = 0,
  15914. kShareExtension = 0,
  15915. }
  15916. /** !#en The callback of social system
  15917. !#zh 社交系统回调 */
  15918. export enum SocialRetCode {
  15919. kScoreSubmitSucceed = 0,
  15920. kScoreSubmitfail = 0,
  15921. kAchUnlockSucceed = 0,
  15922. kAchUnlockFail = 0,
  15923. kSocialSignInSucceed = 0,
  15924. kSocialSignInFail = 0,
  15925. kSocialSignOutSucceed = 0,
  15926. kSocialSignOutFail = 0,
  15927. kSocialGetGameFriends = 0,
  15928. kSocialExtensionCode = 0,
  15929. kSocialGetFriendsInfoSuccess = 0,
  15930. kSocialGetFriendsInfoFail = 0,
  15931. kSocialAlreadySubscription = 0,
  15932. kSocialNoSubscription = 0,
  15933. kSocialSubscriptionFail = 0,
  15934. }
  15935. /** !#en The callback of ads system
  15936. !#zh 广告系统回调 */
  15937. export enum AdsResultCode {
  15938. kAdsReceived = 0,
  15939. kAdsShown = 0,
  15940. kAdsDismissed = 0,
  15941. kPointsSpendSucceed = 0,
  15942. kPointsSpendFailed = 0,
  15943. kNetworkError = 0,
  15944. kUnknownError = 0,
  15945. kOfferWallOnPointsChanged = 0,
  15946. kRewardedVideoWithReward = 0,
  15947. kInAppPurchaseFinished = 0,
  15948. kAdsClicked = 0,
  15949. kAdsExtension = 0,
  15950. }
  15951. /** !#en The enum of ads position
  15952. !#zh 广告位置 */
  15953. export enum AdsPos {
  15954. kPosCenter = 0,
  15955. kPosTop = 0,
  15956. kPosTopLeft = 0,
  15957. kPosTopRight = 0,
  15958. kPosBottom = 0,
  15959. kPosBottomLeft = 0,
  15960. kPosBottomRight = 0,
  15961. }
  15962. /** !#en The enum of ads type
  15963. !#zh 广告类型 */
  15964. export enum AdsType {
  15965. AD_TYPE_BANNER = 0,
  15966. AD_TYPE_FULLSCREEN = 0,
  15967. AD_TYPE_MOREAPP = 0,
  15968. AD_TYPE_OFFERWALL = 0,
  15969. AD_TYPE_REWARDEDVIDEO = 0,
  15970. AD_TYPE_NATIVEEXPRESS = 0,
  15971. AD_TYPE_NATIVEADVANCED = 0,
  15972. }
  15973. /** !#en The callback of push system
  15974. !#zh 推送系统回调 */
  15975. export enum PushActionResultCode {
  15976. kPushReceiveMessage = 0,
  15977. kPushExtensionCode = 0,
  15978. }
  15979. /** !#en The callback of custom system
  15980. !#zh 自定义系统回调 */
  15981. export enum CustomResultCode {
  15982. kCustomExtension = 0,
  15983. }
  15984. /** !#en The callback of REC system
  15985. !#zh 录屏系统回调 */
  15986. export enum RECResultCode {
  15987. kRECInitSuccess = 0,
  15988. kRECInitFail = 0,
  15989. kRECStartRecording = 0,
  15990. kRECStopRecording = 0,
  15991. kRECPauseRecording = 0,
  15992. kRECResumeRecording = 0,
  15993. kRECEnterSDKPage = 0,
  15994. kRECQuitSDKPage = 0,
  15995. kRECShareSuccess = 0,
  15996. kRECShareFail = 0,
  15997. kRECExtension = 0,
  15998. }
  15999. }
  16000. /** !#en
  16001. The global main namespace of Spine, all classes, functions,
  16002. properties and constants of Spine are defined in this namespace
  16003. !#zh
  16004. Spine 的全局的命名空间,
  16005. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  16006. declare module sp {
  16007. /** !#en
  16008. The skeleton of Spine <br/>
  16009. <br/>
  16010. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  16011. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  16012. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  16013. !#zh
  16014. Spine 骨骼动画 <br/>
  16015. <br/>
  16016. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  16017. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  16018. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  16019. export class Skeleton extends cc._RendererUnderSG {
  16020. /** !#en The skeletal animation is paused?
  16021. !#zh 该骨骼动画是否暂停。 */
  16022. paused: boolean;
  16023. /** !#en
  16024. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  16025. attachments, skins, etc) and animations but does not hold any state.<br/>
  16026. Multiple skeletons can share the same skeleton data.
  16027. !#zh
  16028. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  16029. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  16030. 多个 Skeleton 可以共用相同的骨骼数据。 */
  16031. skeletonData: SkeletonData;
  16032. /** !#en The name of default skin.
  16033. !#zh 默认的皮肤名称。 */
  16034. defaultSkin: string;
  16035. /** !#en The name of default animation.
  16036. !#zh 默认的动画名称。 */
  16037. defaultAnimation: string;
  16038. /** !#en The name of current playing animation.
  16039. !#zh 当前播放的动画名称。 */
  16040. animation: string;
  16041. _defaultSkinIndex: number;
  16042. /** !#en TODO
  16043. !#zh 是否循环播放当前骨骼动画。 */
  16044. loop: boolean;
  16045. /** !#en Indicates whether to enable premultiplied alpha.
  16046. You should disable this option when image's transparent area appears to have opaque pixels,
  16047. or enable this option when image's half transparent area appears to be darken.
  16048. !#zh 是否启用贴图预乘。
  16049. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  16050. premultipliedAlpha: boolean;
  16051. /** !#en The time scale of this skeleton.
  16052. !#zh 当前骨骼中所有动画的时间缩放率。 */
  16053. timeScale: number;
  16054. /** !#en Indicates whether open debug slots.
  16055. !#zh 是否显示 slot 的 debug 信息。 */
  16056. debugSlots: boolean;
  16057. /** !#en Indicates whether open debug bones.
  16058. !#zh 是否显示 bone 的 debug 信息。 */
  16059. debugBones: boolean;
  16060. /**
  16061. !#en Computes the world SRT from the local SRT for each bone.
  16062. !#zh 重新更新所有骨骼的世界 Transform,
  16063. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  16064. @example
  16065. ```js
  16066. var bone = spine.findBone('head');
  16067. cc.log(bone.worldX); // return 0;
  16068. spine.updateWorldTransform();
  16069. bone = spine.findBone('head');
  16070. cc.log(bone.worldX); // return -23.12;
  16071. ```
  16072. */
  16073. updateWorldTransform(): void;
  16074. /**
  16075. !#en Sets the bones and slots to the setup pose.
  16076. !#zh 还原到起始动作
  16077. */
  16078. setToSetupPose(): void;
  16079. /**
  16080. !#en
  16081. Sets the bones to the setup pose,
  16082. using the values from the `BoneData` list in the `SkeletonData`.
  16083. !#zh
  16084. 设置 bone 到起始动作
  16085. 使用 SkeletonData 中的 BoneData 列表中的值。
  16086. */
  16087. setBonesToSetupPose(): void;
  16088. /**
  16089. !#en
  16090. Sets the slots to the setup pose,
  16091. using the values from the `SlotData` list in the `SkeletonData`.
  16092. !#zh
  16093. 设置 slot 到起始动作。
  16094. 使用 SkeletonData 中的 SlotData 列表中的值。
  16095. */
  16096. setSlotsToSetupPose(): void;
  16097. /**
  16098. !#en
  16099. Finds a bone by name.
  16100. This does a string comparison for every bone.<br>
  16101. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  16102. !#zh
  16103. 通过名称查找 bone。
  16104. 这里对每个 bone 的名称进行了对比。<br>
  16105. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  16106. @param boneName boneName
  16107. */
  16108. findBone(boneName: string): sp.spine.Bone;
  16109. /**
  16110. !#en
  16111. Finds a slot by name. This does a string comparison for every slot.<br>
  16112. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  16113. !#zh
  16114. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  16115. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  16116. @param slotName slotName
  16117. */
  16118. findSlot(slotName: string): sp.spine.Slot;
  16119. /**
  16120. !#en
  16121. Finds a skin by name and makes it the active skin.
  16122. This does a string comparison for every skin.<br>
  16123. Note that setting the skin does not change which attachments are visible.<br>
  16124. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  16125. !#zh
  16126. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  16127. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  16128. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  16129. @param skinName skinName
  16130. */
  16131. setSkin(skinName: string): sp.spine.Skin;
  16132. /**
  16133. !#en
  16134. Returns the attachment for the slot and attachment name.
  16135. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  16136. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  16137. !#zh
  16138. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  16139. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  16140. @param slotName slotName
  16141. @param attachmentName attachmentName
  16142. */
  16143. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  16144. /**
  16145. !#en
  16146. Sets the attachment for the slot and attachment name.
  16147. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  16148. !#zh
  16149. 通过 slot 和 attachment 的名字来设置 attachment。
  16150. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  16151. @param slotName slotName
  16152. @param attachmentName attachmentName
  16153. */
  16154. setAttachment(slotName: string, attachmentName: string): void;
  16155. /**
  16156. !#en
  16157. Sets runtime skeleton data to sp.Skeleton.<br>
  16158. 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.
  16159. !#zh
  16160. 设置底层运行时用到的 SkeletonData。<br>
  16161. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  16162. @param skeletonData skeletonData
  16163. @param ownsSkeletonData ownsSkeletonData
  16164. */
  16165. setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
  16166. /**
  16167. !#en Sets animation state data.<br>
  16168. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  16169. !#zh 设置动画状态数据。<br>
  16170. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  16171. @param stateData stateData
  16172. */
  16173. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  16174. /**
  16175. !#en
  16176. Mix applies all keyframe values,
  16177. interpolated for the specified time and mixed with the current values.
  16178. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  16179. @param fromAnimation fromAnimation
  16180. @param toAnimation toAnimation
  16181. @param duration duration
  16182. */
  16183. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  16184. /**
  16185. !#en Sets event listener.
  16186. !#zh 设置动画事件监听器。
  16187. @param target target
  16188. @param callback callback
  16189. */
  16190. setAnimationListener(target: any, callback: Function): void;
  16191. /**
  16192. !#en Set the current animation. Any queued animations are cleared.<br>
  16193. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16194. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  16195. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16196. @param trackIndex trackIndex
  16197. @param name name
  16198. @param loop loop
  16199. */
  16200. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  16201. /**
  16202. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  16203. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16204. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  16205. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16206. @param trackIndex trackIndex
  16207. @param name name
  16208. @param loop loop
  16209. @param delay delay
  16210. */
  16211. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  16212. /**
  16213. !#en Find animation with specified name.
  16214. !#zh 查找指定名称的动画
  16215. @param name name
  16216. */
  16217. findAnimation(name: string): sp.spine.Animation;
  16218. /**
  16219. !#en Returns track entry by trackIndex.<br>
  16220. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16221. !#zh 通过 track 索引获取 TrackEntry。<br>
  16222. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16223. @param trackIndex trackIndex
  16224. */
  16225. getCurrent(trackIndex: void): sp.spine.TrackEntry;
  16226. /**
  16227. !#en Clears all tracks of animation state.
  16228. !#zh 清除所有 track 的动画状态。
  16229. */
  16230. clearTracks(): void;
  16231. /**
  16232. !#en Clears track of animation state by trackIndex.
  16233. !#zh 清除出指定 track 的动画状态。
  16234. @param trackIndex trackIndex
  16235. */
  16236. clearTrack(trackIndex: number): void;
  16237. /**
  16238. !#en Set the start event listener.
  16239. !#zh 用来设置开始播放动画的事件监听。
  16240. @param listener listener
  16241. */
  16242. setStartListener(listener: Function): void;
  16243. /**
  16244. !#en Set the interrupt event listener.
  16245. !#zh 用来设置动画被打断的事件监听。
  16246. @param listener listener
  16247. */
  16248. setInterruptListener(listener: Function): void;
  16249. /**
  16250. !#en Set the end event listener.
  16251. !#zh 用来设置动画播放完后的事件监听。
  16252. @param listener listener
  16253. */
  16254. setEndListener(listener: Function): void;
  16255. /**
  16256. !#en Set the dispose event listener.
  16257. !#zh 用来设置动画将被销毁的事件监听。
  16258. @param listener listener
  16259. */
  16260. setDisposeListener(listener: Function): void;
  16261. /**
  16262. !#en Set the complete event listener.
  16263. !#zh 用来设置动画播放一次循环结束后的事件监听。
  16264. @param listener listener
  16265. */
  16266. setCompleteListener(listener: Function): void;
  16267. /**
  16268. !#en Set the animation event listener.
  16269. !#zh 用来设置动画播放过程中帧事件的监听。
  16270. @param listener listener
  16271. */
  16272. setEventListener(listener: Function): void;
  16273. /**
  16274. !#en Set the start event listener for specified TrackEntry (only supported on Web).
  16275. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
  16276. @param entry entry
  16277. @param listener listener
  16278. */
  16279. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16280. /**
  16281. !#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
  16282. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
  16283. @param entry entry
  16284. @param listener listener
  16285. */
  16286. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16287. /**
  16288. !#en Set the end event listener for specified TrackEntry (only supported on Web).
  16289. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
  16290. @param entry entry
  16291. @param listener listener
  16292. */
  16293. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16294. /**
  16295. !#en Set the dispose event listener for specified TrackEntry (only supported on Web).
  16296. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
  16297. @param entry entry
  16298. @param listener listener
  16299. */
  16300. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16301. /**
  16302. !#en Set the complete event listener for specified TrackEntry (only supported on Web).
  16303. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
  16304. @param entry entry
  16305. @param listener listener
  16306. */
  16307. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16308. /**
  16309. !#en Set the event listener for specified TrackEntry (only supported on Web).
  16310. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
  16311. @param entry entry
  16312. @param listener listener
  16313. */
  16314. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16315. }
  16316. /** !#en The skeleton data of spine.
  16317. !#zh Spine 的 骨骼数据。 */
  16318. export class SkeletonData extends cc.Asset {
  16319. /** !#en See http://en.esotericsoftware.com/spine-json-format
  16320. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  16321. skeletonJson: any;
  16322. atlasText: string;
  16323. textures: cc.Texture2D[];
  16324. /** !#en
  16325. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  16326. image sizes, and animation translations.
  16327. This can be useful when using different sized images than were used when designing the skeleton
  16328. in Spine. For example, if using images that are half the size than were used in Spine,
  16329. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  16330. resolution texture atlases.
  16331. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  16332. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  16333. scale: number;
  16334. /**
  16335. !#en Get the included SkeletonData used in spine runtime.<br>
  16336. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  16337. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  16338. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  16339. @param quiet quiet
  16340. */
  16341. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  16342. }
  16343. /** !#en The event type of spine skeleton animation.
  16344. !#zh 骨骼动画事件类型。 */
  16345. export enum AnimationEventType {
  16346. START = 0,
  16347. END = 0,
  16348. COMPLETE = 0,
  16349. EVENT = 0,
  16350. }
  16351. }
  16352. /** !#en
  16353. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  16354. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  16355. !#zh
  16356. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  16357. declare module sp.spine {
  16358. }
  16359. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  16360. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  16361. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  16362. declare module cc._decorator {
  16363. /**
  16364. !#en
  16365. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  16366. as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details.
  16367. !#zh
  16368. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。
  16369. @param name The class name used for serialization.
  16370. @example
  16371. ```js
  16372. const {ccclass} = cc._decorator;
  16373. // define a CCClass, omit the name
  16374. &#64;ccclass
  16375. class NewScript extends cc.Component {
  16376. // ...
  16377. }
  16378. // define a CCClass with a name
  16379. &#64;ccclass('LoginData')
  16380. class LoginData {
  16381. // ...
  16382. }
  16383. ```
  16384. */
  16385. export function ccclass(name?: string): Function;
  16386. export function ccclass(_class?: Function): void;
  16387. /**
  16388. !#en
  16389. Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/).
  16390. !#zh
  16391. 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。
  16392. @param options an object with some property attributes
  16393. @example
  16394. ```js
  16395. const {ccclass, property} = cc._decorator;
  16396. &#64;ccclass
  16397. class NewScript extends cc.Component {
  16398. &#64;property({
  16399. type: cc.Node
  16400. })
  16401. targetNode1 = null;
  16402. &#64;property(cc.Node)
  16403. targetNode2 = null;
  16404. &#64;property(cc.Button)
  16405. targetButton = null;
  16406. &#64;property
  16407. _width = 100;
  16408. &#64;property
  16409. get width () {
  16410. return this._width;
  16411. }
  16412. &#64;property
  16413. set width (value) {
  16414. this._width = value;
  16415. }
  16416. &#64;property
  16417. offset = new cc.Vec2(100, 100);
  16418. &#64;property(cc.Vec2)
  16419. offsets = [];
  16420. &#64;property(cc.SpriteFrame)
  16421. frame = null;
  16422. }
  16423. // above is equivalent to (上面的代码相当于):
  16424. var NewScript = cc.Class({
  16425. properties: {
  16426. targetNode1: {
  16427. default: null,
  16428. type: cc.Node
  16429. },
  16430. targetNode2: {
  16431. default: null,
  16432. type: cc.Node
  16433. },
  16434. targetButton: {
  16435. default: null,
  16436. type: cc.Button
  16437. },
  16438. _width: 100,
  16439. width: {
  16440. get () {
  16441. return this._width;
  16442. },
  16443. set (value) {
  16444. this._width = value;
  16445. }
  16446. },
  16447. offset: new cc.Vec2(100, 100)
  16448. offsets: {
  16449. default: [],
  16450. type: cc.Vec2
  16451. }
  16452. frame: {
  16453. default: null,
  16454. type: cc.SpriteFrame
  16455. },
  16456. }
  16457. });
  16458. ```
  16459. */
  16460. 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} | any[]|Function|cc.ValueType|number|string|boolean): Function;
  16461. export function property(_target: Object, _key: any, _desc?: any): void;
  16462. /**
  16463. !#en
  16464. Makes a CCClass that inherit from component execute in edit mode.<br>
  16465. By default, all components are only executed in play mode,
  16466. which means they will not have their callback functions executed while the Editor is in edit mode.
  16467. !#zh
  16468. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  16469. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  16470. @example
  16471. ```js
  16472. const {ccclass, executeInEditMode} = cc._decorator;
  16473. &#64;ccclass
  16474. &#64;executeInEditMode
  16475. class NewScript extends cc.Component {
  16476. // ...
  16477. }
  16478. ```
  16479. */
  16480. export function executeInEditMode(): Function;
  16481. export function executeInEditMode(_class: Function): void;
  16482. /**
  16483. !#en
  16484. Automatically add required component as a dependency for the CCClass that inherit from component.
  16485. !#zh
  16486. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  16487. @param requiredComponent requiredComponent
  16488. @example
  16489. ```js
  16490. const {ccclass, requireComponent} = cc._decorator;
  16491. &#64;ccclass
  16492. &#64;requireComponent(cc.Sprite)
  16493. class SpriteCtrl extends cc.Component {
  16494. // ...
  16495. }
  16496. ```
  16497. */
  16498. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  16499. /**
  16500. !#en
  16501. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  16502. !#zh
  16503. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  16504. @param path The path is the menu represented like a pathname.
  16505. For example the menu could be "Rendering/CameraCtrl".
  16506. @example
  16507. ```js
  16508. const {ccclass, menu} = cc._decorator;
  16509. &#64;ccclass
  16510. &#64;menu("Rendering/CameraCtrl")
  16511. class NewScript extends cc.Component {
  16512. // ...
  16513. }
  16514. ```
  16515. */
  16516. export function menu(path: string): Function;
  16517. /**
  16518. !#en
  16519. The execution order of lifecycle methods for Component.
  16520. Those less than 0 will execute before while those greater than 0 will execute after.
  16521. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  16522. !#zh
  16523. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  16524. @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.
  16525. @example
  16526. ```js
  16527. const {ccclass, executionOrder} = cc._decorator;
  16528. &#64;ccclass
  16529. &#64;executionOrder(1)
  16530. class CameraCtrl extends cc.Component {
  16531. // ...
  16532. }
  16533. ```
  16534. */
  16535. export function executionOrder(order: number): Function;
  16536. /**
  16537. !#en
  16538. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  16539. !#zh
  16540. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  16541. @example
  16542. ```js
  16543. const {ccclass, disallowMultiple} = cc._decorator;
  16544. &#64;ccclass
  16545. &#64;disallowMultiple
  16546. class CameraCtrl extends cc.Component {
  16547. // ...
  16548. }
  16549. ```
  16550. */
  16551. export function disallowMultiple(): Function;
  16552. export function disallowMultiple(_class: Function): void;
  16553. /**
  16554. !#en
  16555. 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>
  16556. This property is only available if executeInEditMode is true.
  16557. !#zh
  16558. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  16559. @example
  16560. ```js
  16561. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  16562. &#64;ccclass
  16563. &#64;executeInEditMode
  16564. &#64;playOnFocus
  16565. class CameraCtrl extends cc.Component {
  16566. // ...
  16567. }
  16568. ```
  16569. */
  16570. export function playOnFocus(): Function;
  16571. export function playOnFocus(_class: Function): void;
  16572. /**
  16573. !#en
  16574. Specifying the url of the custom html to draw the component in **Properties**.
  16575. !#zh
  16576. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  16577. @param url url
  16578. @example
  16579. ```js
  16580. const {ccclass, inspector} = cc._decorator;
  16581. &#64;ccclass
  16582. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  16583. class NewScript extends cc.Component {
  16584. // ...
  16585. }
  16586. ```
  16587. */
  16588. export function inspector(path: string): Function;
  16589. /**
  16590. !#en
  16591. The custom documentation URL.
  16592. !#zh
  16593. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  16594. @param url url
  16595. @example
  16596. ```js
  16597. const {ccclass, help} = cc._decorator;
  16598. &#64;ccclass
  16599. &#64;help("app://docs/html/components/spine.html")
  16600. class NewScript extends cc.Component {
  16601. // ...
  16602. }
  16603. ```
  16604. */
  16605. export function help(path: string): Function;
  16606. /**
  16607. NOTE:<br>
  16608. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  16609. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  16610. so we can not mix in ES6 Classes.<br>
  16611. See:<br>
  16612. [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>
  16613. One possible solution (but IDE unfriendly):<br>
  16614. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  16615. <br>
  16616. NOTE:<br>
  16617. You must manually call mixins constructor, this is different from cc.Class(ES5).
  16618. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  16619. not support ES6 Classes.
  16620. @example
  16621. ```js
  16622. const {ccclass, mixins} = cc._decorator;
  16623. class Animal { ... }
  16624. const Fly = cc.Class({
  16625. constructor () { ... }
  16626. });
  16627. &#64;ccclass
  16628. &#64;mixins(cc.EventTarget, Fly)
  16629. class Bird extends Animal {
  16630. constructor () {
  16631. super();
  16632. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  16633. cc.EventTarget.call(this);
  16634. Fly.call(this);
  16635. }
  16636. // ...
  16637. }
  16638. ```
  16639. */
  16640. export function mixins(ctor: Function, ...rest: Function[]): Function;
  16641. }
  16642. /** This module provides some JavaScript utilities.
  16643. All members can be accessed with "cc.js". */
  16644. declare module cc.js {
  16645. /**
  16646. Check the obj whether is number or not
  16647. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  16648. Then you can use this function if you care about this case.
  16649. @param obj obj
  16650. */
  16651. export function isNumber(obj: any): boolean;
  16652. /**
  16653. Check the obj whether is string or not.
  16654. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  16655. Then you can use this function if you care about this case.
  16656. @param obj obj
  16657. */
  16658. export function isString(obj: any): boolean;
  16659. /**
  16660. This method is deprecated, use cc.js.mixin please.<br>
  16661. Copy all properties not defined in obj from arguments[1...n]
  16662. @param obj object to extend its properties
  16663. @param sourceObj source object to copy properties from
  16664. */
  16665. export function addon(obj: any, ...sourceObj: any[]): any;
  16666. /**
  16667. copy all properties from arguments[1...n] to obj
  16668. @param obj obj
  16669. @param sourceObj sourceObj
  16670. */
  16671. export function mixin(obj: any, ...sourceObj: any[]): any;
  16672. /**
  16673. Derive the class from the supplied base class.
  16674. Both classes are just native javascript constructors, not created by cc.Class, so
  16675. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  16676. @param cls cls
  16677. @param base the baseclass to inherit
  16678. */
  16679. export function extend(cls: Function, base: Function): Function;
  16680. /**
  16681. Get super class
  16682. @param ctor the constructor of subclass
  16683. */
  16684. export function getSuper(ctor: Function): Function;
  16685. /**
  16686. Removes all enumerable properties from object
  16687. @param obj obj
  16688. */
  16689. export function clear(obj: any): void;
  16690. /**
  16691. Get property descriptor in object and all its ancestors
  16692. @param obj obj
  16693. @param name name
  16694. */
  16695. export function getPropertyDescriptor(obj: any, name: string): any;
  16696. /**
  16697. Define value, just help to call Object.defineProperty.<br>
  16698. The configurable will be true.
  16699. @param obj obj
  16700. @param prop prop
  16701. @param value value
  16702. @param writable writable
  16703. @param enumerable enumerable
  16704. */
  16705. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  16706. /**
  16707. Define get set accessor, just help to call Object.defineProperty(...)
  16708. @param obj obj
  16709. @param prop prop
  16710. @param getter getter
  16711. @param setter setter
  16712. @param enumerable enumerable
  16713. */
  16714. export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void;
  16715. /**
  16716. Define get accessor, just help to call Object.defineProperty(...)
  16717. @param obj obj
  16718. @param prop prop
  16719. @param getter getter
  16720. @param enumerable enumerable
  16721. @param configurable configurable
  16722. */
  16723. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  16724. /**
  16725. Define set accessor, just help to call Object.defineProperty(...)
  16726. @param obj obj
  16727. @param prop prop
  16728. @param setter setter
  16729. @param enumerable enumerable
  16730. @param configurable configurable
  16731. */
  16732. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  16733. /**
  16734. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  16735. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  16736. @param objOrCtor instance or constructor
  16737. */
  16738. export function getClassName(objOrCtor: any|Function): string;
  16739. /**
  16740. Register the class by specified name manually
  16741. @param className className
  16742. @param constructor constructor
  16743. */
  16744. export function setClassName(className: string, constructor: Function): void;
  16745. /**
  16746. Unregister a class from fireball.
  16747. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  16748. Please note that its still your responsibility to free other references to the class.
  16749. @param constructor the class you will want to unregister, any number of classes can be added
  16750. */
  16751. export function unregisterClass(...constructor: Function[]): void;
  16752. /**
  16753. Get the registered class by name
  16754. @param classname classname
  16755. */
  16756. export function getClassByName(classname: string): Function;
  16757. /**
  16758. Defines a polyfill field for obsoleted codes.
  16759. @param obj YourObject or YourClass.prototype
  16760. @param obsoleted "OldParam" or "YourClass.OldParam"
  16761. @param newExpr "NewParam" or "YourClass.NewParam"
  16762. @param writable writable
  16763. */
  16764. export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void;
  16765. /**
  16766. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  16767. @param obj YourObject or YourClass.prototype
  16768. @param objName "YourObject" or "YourClass"
  16769. @param props props
  16770. @param writable writable
  16771. */
  16772. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  16773. /**
  16774. A string tool to construct a string with format string.
  16775. @param msg A JavaScript string containing zero or more substitution strings (%s).
  16776. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  16777. @example
  16778. ```js
  16779. cc.js.formatStr("a: %s, b: %s", a, b);
  16780. cc.js.formatStr(a, b, c);
  16781. ```
  16782. */
  16783. export function formatStr(msg: string|any, ...subst: any[]): string;
  16784. /**
  16785. !#en
  16786. 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.
  16787. !#zh
  16788. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  16789. @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.
  16790. */
  16791. export function createMap(forceDictMode?: boolean): any;
  16792. /** undefined */
  16793. export class array {
  16794. /**
  16795. Removes the array item at the specified index.
  16796. @param array array
  16797. @param index index
  16798. */
  16799. static removeAt(array: any[], index: number): void;
  16800. /**
  16801. Removes the array item at the specified index.
  16802. It's faster but the order of the array will be changed.
  16803. @param array array
  16804. @param index index
  16805. */
  16806. static fastRemoveAt(array: any[], index: number): void;
  16807. /**
  16808. Removes the first occurrence of a specific object from the array.
  16809. @param array array
  16810. @param value value
  16811. */
  16812. static remove(array: any[], value: any): boolean;
  16813. /**
  16814. Removes the first occurrence of a specific object from the array.
  16815. It's faster but the order of the array will be changed.
  16816. @param array array
  16817. @param value value
  16818. */
  16819. static fastRemove(array: any[], value: number): void;
  16820. /**
  16821. Verify array's Type
  16822. @param array array
  16823. @param type type
  16824. */
  16825. static verifyType(array: any[], type: Function): boolean;
  16826. /**
  16827. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  16828. @param array Source Array
  16829. @param minusArr minus Array
  16830. */
  16831. static removeArray(array: any[], minusArr: any[]): void;
  16832. /**
  16833. Inserts some objects at index
  16834. @param array array
  16835. @param addObjs addObjs
  16836. @param index index
  16837. */
  16838. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  16839. /**
  16840. Exact same function as Array.prototype.indexOf.<br>
  16841. HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.<br>
  16842. Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously!
  16843. @param searchElement Element to locate in the array.
  16844. @param fromIndex The index to start the search at
  16845. */
  16846. static indexOf(searchElement: any, fromIndex?: number): number;
  16847. /**
  16848. Determines whether the array contains a specific value.
  16849. @param array array
  16850. @param value value
  16851. */
  16852. static contains(array: any[], value: any): boolean;
  16853. /**
  16854. Copy an array's item to a new array (its performance is better than Array.slice)
  16855. @param array array
  16856. */
  16857. static copy(array: any[]): any[];
  16858. }
  16859. /** !#en
  16860. A fixed-length object pool designed for general type.<br>
  16861. The implementation of this object pool is very simple,
  16862. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  16863. !#zh
  16864. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  16865. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  16866. export class Pool {
  16867. /**
  16868. !#en
  16869. Constructor for creating an object pool for the specific object type.
  16870. You can pass a callback argument for process the cleanup logic when the object is recycled.
  16871. !#zh
  16872. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  16873. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  16874. @param size initializes the length of the array
  16875. */
  16876. constructor(cleanupFunc: (obj: any) => void, size: number);
  16877. constructor(size: number);
  16878. /**
  16879. !#en
  16880. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  16881. !#zh
  16882. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  16883. @param params parameters to used to initialize the object
  16884. */
  16885. get(...params: any[]): any;
  16886. /** !#en
  16887. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  16888. the maximum will not exceed the size specified when the constructor is called.
  16889. !#zh
  16890. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  16891. count: number;
  16892. /**
  16893. !#en
  16894. Get an object from pool, if no available object in the pool, null will be returned.
  16895. !#zh
  16896. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  16897. */
  16898. _get(): any;
  16899. /**
  16900. !#en Put an object into the pool.
  16901. !#zh 向对象池返还一个不再需要的对象。
  16902. */
  16903. put(): void;
  16904. /**
  16905. !#en Resize the pool.
  16906. !#zh 设置对象池容量。
  16907. */
  16908. resize(): void;
  16909. }
  16910. }
  16911. declare namespace dragonBones {
  16912. /**
  16913. * @private
  16914. */
  16915. const enum ArmatureType {
  16916. Armature = 0,
  16917. MovieClip = 1,
  16918. Stage = 2,
  16919. }
  16920. /**
  16921. * @private
  16922. */
  16923. const enum DisplayType {
  16924. Image = 0,
  16925. Armature = 1,
  16926. Mesh = 2,
  16927. }
  16928. /**
  16929. * @private
  16930. */
  16931. const enum ExtensionType {
  16932. FFD = 0,
  16933. AdjustColor = 10,
  16934. BevelFilter = 11,
  16935. BlurFilter = 12,
  16936. DropShadowFilter = 13,
  16937. GlowFilter = 14,
  16938. GradientBevelFilter = 15,
  16939. GradientGlowFilter = 16,
  16940. }
  16941. /**
  16942. * @private
  16943. */
  16944. const enum EventType {
  16945. Frame = 10,
  16946. Sound = 11,
  16947. }
  16948. /**
  16949. * @private
  16950. */
  16951. const enum ActionType {
  16952. Play = 0,
  16953. Stop = 1,
  16954. GotoAndPlay = 2,
  16955. GotoAndStop = 3,
  16956. FadeIn = 4,
  16957. FadeOut = 5,
  16958. }
  16959. /**
  16960. * @private
  16961. */
  16962. const enum BlendMode {
  16963. Normal = 0,
  16964. Add = 1,
  16965. Alpha = 2,
  16966. Darken = 3,
  16967. Difference = 4,
  16968. Erase = 5,
  16969. HardLight = 6,
  16970. Invert = 7,
  16971. Layer = 8,
  16972. Lighten = 9,
  16973. Multiply = 10,
  16974. Overlay = 11,
  16975. Screen = 12,
  16976. Subtract = 13,
  16977. }
  16978. /**
  16979. * @private
  16980. */
  16981. interface Map<T> {
  16982. [key: string]: T;
  16983. }
  16984. /**
  16985. * DragonBones
  16986. */
  16987. class DragonBones {
  16988. /**
  16989. * @private
  16990. */
  16991. static PI_D: number;
  16992. /**
  16993. * @private
  16994. */
  16995. static PI_H: number;
  16996. /**
  16997. * @private
  16998. */
  16999. static PI_Q: number;
  17000. /**
  17001. * @private
  17002. */
  17003. static ANGLE_TO_RADIAN: number;
  17004. /**
  17005. * @private
  17006. */
  17007. static RADIAN_TO_ANGLE: number;
  17008. /**
  17009. * @private
  17010. */
  17011. static SECOND_TO_MILLISECOND: number;
  17012. static VERSION: string;
  17013. /**
  17014. * @private
  17015. */
  17016. static debug: boolean;
  17017. /**
  17018. * @private
  17019. */
  17020. static debugDraw: boolean;
  17021. }
  17022. }
  17023. declare namespace dragonBones {
  17024. /**
  17025. * @language zh_CN
  17026. * 基础对象。
  17027. * @version DragonBones 4.5
  17028. */
  17029. abstract class BaseObject {
  17030. private static _hashCode;
  17031. private static _defaultMaxCount;
  17032. private static _maxCountMap;
  17033. private static _poolsMap;
  17034. private static _returnObject(object);
  17035. /**
  17036. * @language zh_CN
  17037. * 设置每种对象池的最大缓存数量。
  17038. * @param objectConstructor 对象类。
  17039. * @param maxCount 最大缓存数量。 (设置为 0 则不缓存)
  17040. * @version DragonBones 4.5
  17041. */
  17042. static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
  17043. /**
  17044. * @language zh_CN
  17045. * 清除对象池缓存的对象。
  17046. * @param objectConstructor 对象类。 (不设置则清除所有缓存)
  17047. * @version DragonBones 4.5
  17048. */
  17049. static clearPool(objectConstructor?: typeof BaseObject): void;
  17050. /**
  17051. * @language zh_CN
  17052. * 从对象池中创建指定对象。
  17053. * @param objectConstructor 对象类。
  17054. * @version DragonBones 4.5
  17055. */
  17056. static borrowObject<T extends BaseObject>(objectConstructor: {
  17057. new (): T;
  17058. }): T;
  17059. /**
  17060. * @language zh_CN
  17061. * 对象的唯一标识。
  17062. * @version DragonBones 4.5
  17063. */
  17064. hashCode: number;
  17065. /**
  17066. * @private
  17067. */
  17068. protected abstract _onClear(): void;
  17069. /**
  17070. * @language zh_CN
  17071. * 清除数据并返还对象池。
  17072. * @version DragonBones 4.5
  17073. */
  17074. returnToPool(): void;
  17075. }
  17076. }
  17077. declare namespace dragonBones {
  17078. }
  17079. declare namespace dragonBones {
  17080. /**
  17081. * @language zh_CN
  17082. * 动画混合时,使用的淡出方式。
  17083. * @see dragonBones.Animation#fadeIn()
  17084. * @version DragonBones 4.5
  17085. */
  17086. const enum AnimationFadeOutMode {
  17087. /**
  17088. * @language zh_CN
  17089. * 不淡出动画。
  17090. * @version DragonBones 4.5
  17091. */
  17092. None = 0,
  17093. /**
  17094. * @language zh_CN
  17095. * 淡出同层的动画。
  17096. * @version DragonBones 4.5
  17097. */
  17098. SameLayer = 1,
  17099. /**
  17100. * @language zh_CN
  17101. * 淡出同组的动画。
  17102. * @version DragonBones 4.5
  17103. */
  17104. SameGroup = 2,
  17105. /**
  17106. * @language zh_CN
  17107. * 淡出同层并且同组的动画。
  17108. * @version DragonBones 4.5
  17109. */
  17110. SameLayerAndGroup = 3,
  17111. /**
  17112. * @language zh_CN
  17113. * 淡出所有动画。
  17114. * @version DragonBones 4.5
  17115. */
  17116. All = 4,
  17117. }
  17118. /**
  17119. * @language zh_CN
  17120. * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口)
  17121. * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。
  17122. * @see dragonBones.WorldClock
  17123. * @see dragonBones.Armature
  17124. * @version DragonBones 3.0
  17125. */
  17126. interface IAnimateble {
  17127. /**
  17128. * @language zh_CN
  17129. * 更新一个指定的时间。
  17130. * @param passedTime 前进的时间。 (以秒为单位)
  17131. * @version DragonBones 3.0
  17132. */
  17133. advanceTime(passedTime: number): void;
  17134. }
  17135. /**
  17136. * @language zh_CN
  17137. * 动画控制器,用来播放动画数据,管理动画状态。
  17138. * @see dragonBones.AnimationData
  17139. * @see dragonBones.AnimationState
  17140. * @version DragonBones 3.0
  17141. */
  17142. class Animation extends BaseObject {
  17143. /**
  17144. * @private
  17145. */
  17146. private static _sortAnimationState(a, b);
  17147. /**
  17148. * @private
  17149. */
  17150. static toString(): string;
  17151. /**
  17152. * @language zh_CN
  17153. * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17154. * @default 1
  17155. * @version DragonBones 3.0
  17156. */
  17157. timeScale: number;
  17158. /**
  17159. * @private
  17160. */
  17161. _armature: Armature;
  17162. private _isPlaying;
  17163. private _time;
  17164. private _duration;
  17165. private _lastAnimationState;
  17166. private _animations;
  17167. private _animationNames;
  17168. private _animationStates;
  17169. /**
  17170. * @inheritDoc
  17171. */
  17172. protected _onClear(): void;
  17173. private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut);
  17174. /**
  17175. * @language zh_CN
  17176. * 清除所有正在播放的动画状态。
  17177. * @version DragonBones 4.5
  17178. */
  17179. reset(): void;
  17180. /**
  17181. * @language zh_CN
  17182. * 暂停播放动画。
  17183. * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。
  17184. * @see dragonBones.AnimationState
  17185. * @version DragonBones 3.0
  17186. */
  17187. stop(animationName?: string): void;
  17188. /**
  17189. * @language zh_CN
  17190. * 播放动画。
  17191. * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。
  17192. * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17193. * @returns 返回控制这个动画数据的动画状态。
  17194. * @see dragonBones.AnimationState
  17195. * @version DragonBones 3.0
  17196. */
  17197. play(animationName?: string, playTimes?: number): AnimationState;
  17198. /**
  17199. * @language zh_CN
  17200. * 淡入播放指定名称的动画。
  17201. * @param animationName 动画数据的名称。
  17202. * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17203. * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
  17204. * @param layer 混合的图层,图层高会优先获取混合权重。
  17205. * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
  17206. * @param fadeOutMode 淡出的模式。
  17207. * @param additiveBlending 以叠加的形式混合。
  17208. * @param displayControl 是否对显示对象属性可控。
  17209. * @param pauseFadeOut 暂停需要淡出的动画。
  17210. * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
  17211. * @returns 返回控制这个动画数据的动画状态。
  17212. * @see dragonBones.AnimationFadeOutMode
  17213. * @see dragonBones.AnimationState
  17214. * @version DragonBones 4.5
  17215. */
  17216. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17217. /**
  17218. * @language zh_CN
  17219. * 指定名称的动画从指定时间开始播放。
  17220. * @param animationName 动画数据的名称。
  17221. * @param time 时间。 (以秒为单位)
  17222. * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17223. * @param toTime 播放到指定的时间,如果未设置则播放整个动画。
  17224. * @returns 返回控制这个动画数据的动画状态。
  17225. * @see dragonBones.AnimationState
  17226. * @version DragonBones 4.5
  17227. */
  17228. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState;
  17229. /**
  17230. * @language zh_CN
  17231. * 指定名称的动画从指定帧开始播放。
  17232. * @param animationName 动画数据的名称。
  17233. * @param frame 帧。
  17234. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17235. * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。
  17236. * @returns 返回控制这个动画数据的动画状态。
  17237. * @see dragonBones.AnimationState
  17238. * @version DragonBones 4.5
  17239. */
  17240. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState;
  17241. /**
  17242. * @language zh_CN
  17243. * 指定名称的动画从指定进度开始播放。
  17244. * @param animationName 动画数据的名称。
  17245. * @param progress 进度。 [0~1]
  17246. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17247. * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。
  17248. * @returns 返回控制这个动画数据的动画状态。
  17249. * @see dragonBones.AnimationState
  17250. * @version DragonBones 4.5
  17251. */
  17252. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState;
  17253. /**
  17254. * @language zh_CN
  17255. * 播放指定名称的动画到指定的时间并停止。
  17256. * @param animationName 动画数据的名称。
  17257. * @param time 时间。 (以秒为单位)
  17258. * @returns 返回控制这个动画数据的动画状态。
  17259. * @see dragonBones.AnimationState
  17260. * @version DragonBones 4.5
  17261. */
  17262. gotoAndStopByTime(animationName: string, time?: number): AnimationState;
  17263. /**
  17264. * @language zh_CN
  17265. * 播放指定名称的动画到指定的帧并停止。
  17266. * @param animationName 动画数据的名称。
  17267. * @param frame 帧。
  17268. * @returns 返回控制这个动画数据的动画状态。
  17269. * @see dragonBones.AnimationState
  17270. * @version DragonBones 4.5
  17271. */
  17272. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState;
  17273. /**
  17274. * @language zh_CN
  17275. * 播放指定名称的动画到指定的进度并停止。
  17276. * @param animationName 动画数据的名称。
  17277. * @param progress 进度。 [0~1]
  17278. * @returns 返回控制这个动画数据的动画状态。
  17279. * @see dragonBones.AnimationState
  17280. * @version DragonBones 4.5
  17281. */
  17282. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState;
  17283. /**
  17284. * @language zh_CN
  17285. * 获取指定名称的动画状态。
  17286. * @param animationName 动画状态的名称。
  17287. * @see dragonBones.AnimationState
  17288. * @version DragonBones 3.0
  17289. */
  17290. getState(animationName: string): AnimationState;
  17291. /**
  17292. * @language zh_CN
  17293. * 是否包含指定名称的动画数据。
  17294. * @param animationName 动画数据的名称。
  17295. * @see dragonBones.AnimationData
  17296. * @version DragonBones 3.0
  17297. */
  17298. hasAnimation(animationName: string): boolean;
  17299. /**
  17300. * @language zh_CN
  17301. * 动画是否处于播放状态。
  17302. * @version DragonBones 3.0
  17303. */
  17304. isPlaying: boolean;
  17305. /**
  17306. * @language zh_CN
  17307. * 所有动画状态是否均已播放完毕。
  17308. * @see dragonBones.AnimationState
  17309. * @version DragonBones 3.0
  17310. */
  17311. isCompleted: boolean;
  17312. /**
  17313. * @language zh_CN
  17314. * 上一个正在播放的动画状态的名称。
  17315. * @see #lastAnimationState
  17316. * @version DragonBones 3.0
  17317. */
  17318. lastAnimationName: string;
  17319. /**
  17320. * @language zh_CN
  17321. * 上一个正在播放的动画状态。
  17322. * @see dragonBones.AnimationState
  17323. * @version DragonBones 3.0
  17324. */
  17325. lastAnimationState: AnimationState;
  17326. /**
  17327. * @language zh_CN
  17328. * 所有动画数据名称。
  17329. * @see #animations
  17330. * @version DragonBones 4.5
  17331. */
  17332. animationNames: Array<string>;
  17333. /**
  17334. * @language zh_CN
  17335. * 所有的动画数据。
  17336. * @see dragonBones.AnimationData
  17337. * @version DragonBones 4.5
  17338. */
  17339. animations: Map<AnimationData>;
  17340. /**
  17341. * @deprecated
  17342. * @see #play()
  17343. * @see #fadeIn()
  17344. * @see #gotoAndPlayByTime()
  17345. * @see #gotoAndPlayByFrame()
  17346. * @see #gotoAndPlayByProgress()
  17347. */
  17348. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17349. /**
  17350. * @deprecated
  17351. * @see #gotoAndStopByTime()
  17352. * @see #gotoAndStopByFrame()
  17353. * @see #gotoAndStopByProgress()
  17354. */
  17355. gotoAndStop(animationName: string, time?: number): AnimationState;
  17356. /**
  17357. * @deprecated
  17358. * @see #animationNames
  17359. * @see #animations
  17360. */
  17361. animationList: Array<string>;
  17362. /**
  17363. * @language zh_CN
  17364. * @deprecated
  17365. * @see #animationNames
  17366. * @see #animations
  17367. */
  17368. animationDataList: Array<AnimationData>;
  17369. }
  17370. }
  17371. declare namespace dragonBones {
  17372. /**
  17373. * @language zh_CN
  17374. * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。
  17375. * @see dragonBones.Animation
  17376. * @see dragonBones.AnimationData
  17377. * @version DragonBones 3.0
  17378. */
  17379. class AnimationState extends BaseObject {
  17380. /**
  17381. * @private
  17382. */
  17383. static stateActionEnabled: boolean;
  17384. /**
  17385. * @private
  17386. */
  17387. static toString(): string;
  17388. /**
  17389. * @language zh_CN
  17390. * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。
  17391. * @see dragonBones.Slot#displayController
  17392. * @version DragonBones 3.0
  17393. */
  17394. displayControl: boolean;
  17395. /**
  17396. * @language zh_CN
  17397. * 是否以叠加的方式混合动画。
  17398. * @version DragonBones 3.0
  17399. */
  17400. additiveBlending: boolean;
  17401. /**
  17402. * @private
  17403. */
  17404. actionEnabled: boolean;
  17405. /**
  17406. * @language zh_CN
  17407. * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  17408. * @version DragonBones 3.0
  17409. */
  17410. playTimes: number;
  17411. /**
  17412. * @language zh_CN
  17413. * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17414. * @default 1
  17415. * @version DragonBones 3.0
  17416. */
  17417. timeScale: number;
  17418. /**
  17419. * @language zh_CN
  17420. * 进行动画混合时的权重。
  17421. * @default 1
  17422. * @version DragonBones 3.0
  17423. */
  17424. weight: number;
  17425. /**
  17426. * @language zh_CN
  17427. * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位)
  17428. * @default -1
  17429. * @version DragonBones 3.0
  17430. */
  17431. autoFadeOutTime: number;
  17432. /**
  17433. * @private
  17434. */
  17435. fadeTotalTime: number;
  17436. /**
  17437. * @private
  17438. */
  17439. private _isPlaying;
  17440. /**
  17441. * @private
  17442. */
  17443. private _isPausePlayhead;
  17444. /**
  17445. * @private
  17446. */
  17447. private _fadeTime;
  17448. /**
  17449. * @private
  17450. */
  17451. private _time;
  17452. /**
  17453. * @private
  17454. */
  17455. private _name;
  17456. /**
  17457. * @private
  17458. */
  17459. private _armature;
  17460. /**
  17461. * @private
  17462. */
  17463. private _animationData;
  17464. /**
  17465. * @private
  17466. */
  17467. private _zOrderTimeline;
  17468. /**
  17469. * @private
  17470. */
  17471. private _boneMask;
  17472. /**
  17473. * @private
  17474. */
  17475. private _boneTimelines;
  17476. /**
  17477. * @private
  17478. */
  17479. private _slotTimelines;
  17480. /**
  17481. * @private
  17482. */
  17483. private _ffdTimelines;
  17484. /**
  17485. * @inheritDoc
  17486. */
  17487. protected _onClear(): void;
  17488. private _updateTimelineStates();
  17489. private _advanceFadeTime(passedTime);
  17490. /**
  17491. * @language zh_CN
  17492. * 继续播放。
  17493. * @version DragonBones 3.0
  17494. */
  17495. play(): void;
  17496. /**
  17497. * @language zh_CN
  17498. * 暂停播放。
  17499. * @version DragonBones 3.0
  17500. */
  17501. stop(): void;
  17502. /**
  17503. * @language zh_CN
  17504. * 淡出动画。
  17505. * @param fadeOutTime 淡出时间。 (以秒为单位)
  17506. * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停]
  17507. * @version DragonBones 3.0
  17508. */
  17509. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  17510. /**
  17511. * @language zh_CN
  17512. * 是否包含指定的骨骼遮罩。
  17513. * @param name 指定的骨骼名称。
  17514. * @version DragonBones 3.0
  17515. */
  17516. containsBoneMask(name: string): boolean;
  17517. /**
  17518. * @language zh_CN
  17519. * 添加指定的骨骼遮罩。
  17520. * @param boneName 指定的骨骼名称。
  17521. * @param recursive 是否为该骨骼的子骨骼添加遮罩。
  17522. * @version DragonBones 3.0
  17523. */
  17524. addBoneMask(name: string, recursive?: boolean): void;
  17525. /**
  17526. * @language zh_CN
  17527. * 删除指定的骨骼遮罩。
  17528. * @param boneName 指定的骨骼名称。
  17529. * @param recursive 是否删除该骨骼的子骨骼遮罩。
  17530. * @version DragonBones 3.0
  17531. */
  17532. removeBoneMask(name: string, recursive?: boolean): void;
  17533. /**
  17534. * @language zh_CN
  17535. * 删除所有骨骼遮罩。
  17536. * @version DragonBones 3.0
  17537. */
  17538. removeAllBoneMask(): void;
  17539. /**
  17540. * @language zh_CN
  17541. * 动画图层。
  17542. * @see dragonBones.Animation#fadeIn()
  17543. * @version DragonBones 3.0
  17544. */
  17545. layer: number;
  17546. /**
  17547. * @language zh_CN
  17548. * 动画组。
  17549. * @see dragonBones.Animation#fadeIn()
  17550. * @version DragonBones 3.0
  17551. */
  17552. group: string;
  17553. /**
  17554. * @language zh_CN
  17555. * 动画名称。
  17556. * @see dragonBones.AnimationData#name
  17557. * @version DragonBones 3.0
  17558. */
  17559. name: string;
  17560. /**
  17561. * @language zh_CN
  17562. * 动画数据。
  17563. * @see dragonBones.AnimationData
  17564. * @version DragonBones 3.0
  17565. */
  17566. animationData: AnimationData;
  17567. /**
  17568. * @language zh_CN
  17569. * 是否播放完毕。
  17570. * @version DragonBones 3.0
  17571. */
  17572. isCompleted: boolean;
  17573. /**
  17574. * @language zh_CN
  17575. * 是否正在播放。
  17576. * @version DragonBones 3.0
  17577. */
  17578. isPlaying: boolean;
  17579. /**
  17580. * @language zh_CN
  17581. * 当前动画的播放次数。
  17582. * @version DragonBones 3.0
  17583. */
  17584. currentPlayTimes: number;
  17585. /**
  17586. * @language zh_CN
  17587. * 当前动画的总时间。 (以秒为单位)
  17588. * @version DragonBones 3.0
  17589. */
  17590. totalTime: number;
  17591. /**
  17592. * @language zh_CN
  17593. * 当前动画的播放时间。 (以秒为单位)
  17594. * @version DragonBones 3.0
  17595. */
  17596. currentTime: number;
  17597. /**
  17598. * @deprecated
  17599. */
  17600. autoTween: boolean;
  17601. /**
  17602. * @deprecated
  17603. * @see #animationData
  17604. */
  17605. clip: AnimationData;
  17606. }
  17607. }
  17608. declare namespace dragonBones {
  17609. }
  17610. declare namespace dragonBones {
  17611. /**
  17612. * @language zh_CN
  17613. * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。
  17614. * @see dragonBones.IAnimatable
  17615. * @see dragonBones.Armature
  17616. * @version DragonBones 3.0
  17617. */
  17618. class WorldClock implements IAnimateble {
  17619. private static _clock;
  17620. /**
  17621. * @language zh_CN
  17622. * 一个可以直接使用的全局 WorldClock 实例.
  17623. * @version DragonBones 3.0
  17624. */
  17625. static clock: WorldClock;
  17626. /**
  17627. * @language zh_CN
  17628. * 当前的时间。 (以秒为单位)
  17629. * @version DragonBones 3.0
  17630. */
  17631. time: number;
  17632. /**
  17633. * @language zh_CN
  17634. * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17635. * @default 1
  17636. * @version DragonBones 3.0
  17637. */
  17638. timeScale: number;
  17639. private _animatebles;
  17640. /**
  17641. * @language zh_CN
  17642. * 创建一个新的 WorldClock 实例。
  17643. * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。
  17644. * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放)
  17645. * @version DragonBones 3.0
  17646. */
  17647. constructor();
  17648. /**
  17649. * @language zh_CN
  17650. * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用)
  17651. * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差)
  17652. * @version DragonBones 3.0
  17653. */
  17654. advanceTime(passedTime: number): void;
  17655. /**
  17656. * 是否包含指定的 IAnimatable 实例
  17657. * @param value 指定的 IAnimatable 实例。
  17658. * @returns [true: 包含,false: 不包含]。
  17659. * @version DragonBones 3.0
  17660. */
  17661. contains(value: IAnimateble): boolean;
  17662. /**
  17663. * @language zh_CN
  17664. * 添加指定的 IAnimatable 实例。
  17665. * @param value IAnimatable 实例。
  17666. * @version DragonBones 3.0
  17667. */
  17668. add(value: IAnimateble): void;
  17669. /**
  17670. * @language zh_CN
  17671. * 移除指定的 IAnimatable 实例。
  17672. * @param value IAnimatable 实例。
  17673. * @version DragonBones 3.0
  17674. */
  17675. remove(value: IAnimateble): void;
  17676. /**
  17677. * @language zh_CN
  17678. * 清除所有的 IAnimatable 实例。
  17679. * @version DragonBones 3.0
  17680. */
  17681. clear(): void;
  17682. }
  17683. }
  17684. declare namespace dragonBones {
  17685. /**
  17686. * @language zh_CN
  17687. * 基础变换对象。
  17688. * @version DragonBones 4.5
  17689. */
  17690. abstract class TransformObject extends BaseObject {
  17691. /**
  17692. * @language zh_CN
  17693. * 可以用于存储临时数据。
  17694. * @version DragonBones 3.0
  17695. */
  17696. userData: any;
  17697. /**
  17698. * @language zh_CN
  17699. * 对象的名称。
  17700. * @version DragonBones 3.0
  17701. */
  17702. name: string;
  17703. /**
  17704. * @language zh_CN
  17705. * 相对于骨架坐标系的矩阵。
  17706. * @version DragonBones 3.0
  17707. */
  17708. globalTransformMatrix: Matrix;
  17709. /**
  17710. * @language zh_CN
  17711. * 相对于骨架坐标系的变换。
  17712. * @see dragonBones.Transform
  17713. * @version DragonBones 3.0
  17714. */
  17715. global: Transform;
  17716. /**
  17717. * @language zh_CN
  17718. * 相对于骨架或父骨骼坐标系的绑定变换。
  17719. * @see dragonBones.Transform
  17720. * @version DragonBones 3.0
  17721. */
  17722. origin: Transform;
  17723. /**
  17724. * @language zh_CN
  17725. * 相对于骨架或父骨骼坐标系的偏移变换。
  17726. * @see dragonBones.Transform
  17727. * @version DragonBones 3.0
  17728. */
  17729. offset: Transform;
  17730. /**
  17731. * @private
  17732. */
  17733. _armature: Armature;
  17734. /**
  17735. * @private
  17736. */
  17737. _parent: Bone;
  17738. /**
  17739. * @private
  17740. */
  17741. protected _globalTransformMatrix: Matrix;
  17742. /**
  17743. * @inheritDoc
  17744. */
  17745. protected _onClear(): void;
  17746. /**
  17747. * @language zh_CN
  17748. * 所属的骨架。
  17749. * @see dragonBones.Armature
  17750. * @version DragonBones 3.0
  17751. */
  17752. armature: Armature;
  17753. /**
  17754. * @language zh_CN
  17755. * 所属的父骨骼。
  17756. * @see dragonBones.Bone
  17757. * @version DragonBones 3.0
  17758. */
  17759. parent: Bone;
  17760. }
  17761. }
  17762. declare namespace dragonBones {
  17763. /**
  17764. * @language zh_CN
  17765. * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。
  17766. * @see dragonBones.ArmatureData
  17767. * @see dragonBones.Bone
  17768. * @see dragonBones.Slot
  17769. * @see dragonBones.Animation
  17770. * @see dragonBones.IArmatureDisplay
  17771. * @version DragonBones 3.0
  17772. */
  17773. class Armature extends BaseObject implements IAnimateble {
  17774. /**
  17775. * @private
  17776. */
  17777. static toString(): string;
  17778. private static _onSortSlots(a, b);
  17779. /**
  17780. * @language zh_CN
  17781. * 可以用于存储临时数据。
  17782. * @version DragonBones 3.0
  17783. */
  17784. userData: any;
  17785. /**
  17786. * @private
  17787. */
  17788. _cacheFrameIndex: number;
  17789. /**
  17790. * @private
  17791. */
  17792. _armatureData: ArmatureData;
  17793. /**
  17794. * @private
  17795. */
  17796. _skinData: SkinData;
  17797. /**
  17798. * @private
  17799. */
  17800. _animation: Animation;
  17801. /**
  17802. * @private
  17803. */
  17804. _display: IArmatureDisplay;
  17805. /**
  17806. * @private
  17807. */
  17808. _eventManager: IEventDispatcher;
  17809. private _delayDispose;
  17810. private _lockDispose;
  17811. private _slotsDirty;
  17812. private _replacedTexture;
  17813. private _bones;
  17814. private _slots;
  17815. private _actions;
  17816. private _events;
  17817. /**
  17818. * @inheritDoc
  17819. */
  17820. protected _onClear(): void;
  17821. private _sortBones();
  17822. private _sortSlots();
  17823. private _doAction(value);
  17824. /**
  17825. * @private
  17826. */
  17827. _sortZOrder(slotIndices: Array<number>): void;
  17828. /**
  17829. * @private
  17830. */
  17831. _bufferAction(value: ActionData): void;
  17832. /**
  17833. * @language zh_CN
  17834. * 释放骨架。 (会回收到内存池)
  17835. * @version DragonBones 3.0
  17836. */
  17837. dispose(): void;
  17838. /**
  17839. * @language zh_CN
  17840. * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新)
  17841. * @param passedTime 两帧之前的时间间隔。 (以秒为单位)
  17842. * @see dragonBones.IAnimateble
  17843. * @see dragonBones.WorldClock
  17844. * @see dragonBones.IArmatureDisplay
  17845. * @version DragonBones 3.0
  17846. */
  17847. advanceTime(passedTime: number): void;
  17848. /**
  17849. * @language zh_CN
  17850. * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17851. * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。
  17852. * @param updateSlotDisplay 是否更新插槽的显示对象。
  17853. * @see dragonBones.Bone
  17854. * @see dragonBones.Slot
  17855. * @version DragonBones 3.0
  17856. */
  17857. invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void;
  17858. /**
  17859. * @language zh_CN
  17860. * 获取指定名称的骨骼。
  17861. * @param name 骨骼的名称。
  17862. * @returns 骨骼。
  17863. * @see dragonBones.Bone
  17864. * @version DragonBones 3.0
  17865. */
  17866. getBone(name: string): Bone;
  17867. /**
  17868. * @language zh_CN
  17869. * 通过显示对象获取骨骼。
  17870. * @param display 显示对象。
  17871. * @returns 包含这个显示对象的骨骼。
  17872. * @see dragonBones.Bone
  17873. * @version DragonBones 3.0
  17874. */
  17875. getBoneByDisplay(display: any): Bone;
  17876. /**
  17877. * @language zh_CN
  17878. * 获取指定名称的插槽。
  17879. * @param name 插槽的名称。
  17880. * @returns 插槽。
  17881. * @see dragonBones.Slot
  17882. * @version DragonBones 3.0
  17883. */
  17884. getSlot(name: string): Slot;
  17885. /**
  17886. * @language zh_CN
  17887. * 通过显示对象获取插槽。
  17888. * @param display 显示对象。
  17889. * @returns 包含这个显示对象的插槽。
  17890. * @see dragonBones.Slot
  17891. * @version DragonBones 3.0
  17892. */
  17893. getSlotByDisplay(display: any): Slot;
  17894. /**
  17895. * @language zh_CN
  17896. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17897. * @param texture 贴图。
  17898. * @version DragonBones 4.5
  17899. */
  17900. replaceTexture(texture: any): void;
  17901. /**
  17902. * @language zh_CN
  17903. * 获取所有骨骼。
  17904. * @see dragonBones.Bone
  17905. * @version DragonBones 3.0
  17906. */
  17907. getBones(): Array<Bone>;
  17908. /**
  17909. * @language zh_CN
  17910. * 获取所有插槽。
  17911. * @see dragonBones.Slot
  17912. * @version DragonBones 3.0
  17913. */
  17914. getSlots(): Array<Slot>;
  17915. /**
  17916. * @language zh_CN
  17917. * 骨架名称。
  17918. * @see dragonBones.ArmatureData#name
  17919. * @version DragonBones 3.0
  17920. */
  17921. name: string;
  17922. /**
  17923. * @language zh_CN
  17924. * 获取骨架数据。
  17925. * @see dragonBones.ArmatureData
  17926. * @version DragonBones 4.5
  17927. */
  17928. armatureData: ArmatureData;
  17929. /**
  17930. * @language zh_CN
  17931. * 获得动画控制器。
  17932. * @see dragonBones.Animation
  17933. * @version DragonBones 3.0
  17934. */
  17935. animation: Animation;
  17936. /**
  17937. * @language zh_CN
  17938. * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  17939. * @version DragonBones 3.0
  17940. */
  17941. display: IArmatureDisplay | any;
  17942. /**
  17943. * @language zh_CN
  17944. * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系)
  17945. * @see dragonBones.Slot
  17946. * @version DragonBones 4.5
  17947. */
  17948. parent: Slot;
  17949. /**
  17950. * @language zh_CN
  17951. * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。
  17952. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  17953. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  17954. * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。
  17955. * @see dragonBones.DragonBonesData#frameRate
  17956. * @see dragonBones.ArmatureData#frameRate
  17957. * @version DragonBones 4.5
  17958. */
  17959. cacheFrameRate: number;
  17960. /**
  17961. * @language zh_CN
  17962. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17963. * @version DragonBones 4.5
  17964. */
  17965. replacedTexture: any;
  17966. /**
  17967. * @language zh_CN
  17968. * 开启动画缓存。
  17969. * @param frameRate 动画缓存的帧率
  17970. * @see #cacheFrameRate
  17971. * @version DragonBones 4.5
  17972. */
  17973. enableAnimationCache(frameRate: number): void;
  17974. /**
  17975. * @language zh_CN
  17976. * 是否包含指定类型的事件。
  17977. * @param type 事件类型。
  17978. * @returns [true: 包含, false: 不包含]
  17979. * @version DragonBones 3.0
  17980. */
  17981. hasEventListener(type: EventStringType): void;
  17982. /**
  17983. * @language zh_CN
  17984. * 添加事件。
  17985. * @param type 事件类型。
  17986. * @param listener 事件回调。
  17987. * @version DragonBones 3.0
  17988. */
  17989. addEventListener(type: EventStringType, listener: Function, target: any): void;
  17990. /**
  17991. * @language zh_CN
  17992. * 移除事件。
  17993. * @param type 事件类型。
  17994. * @param listener 事件回调。
  17995. * @version DragonBones 3.0
  17996. */
  17997. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  17998. /**
  17999. * @deprecated
  18000. */
  18001. addBone(value: Bone, parentName?: string): void;
  18002. /**
  18003. * @deprecated
  18004. */
  18005. addSlot(value: Slot, parentName: string): void;
  18006. /**
  18007. * @deprecated
  18008. */
  18009. removeBone(value: Bone): void;
  18010. /**
  18011. * @deprecated
  18012. */
  18013. removeSlot(value: Slot): void;
  18014. /**
  18015. * @deprecated
  18016. * @see #display
  18017. */
  18018. getDisplay(): any;
  18019. /**
  18020. * @deprecated
  18021. * @see #cacheFrameRate
  18022. */
  18023. enableCache: boolean;
  18024. }
  18025. }
  18026. declare namespace dragonBones {
  18027. /**
  18028. * @language zh_CN
  18029. * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。
  18030. * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。
  18031. * @see dragonBones.BoneData
  18032. * @see dragonBones.Armature
  18033. * @see dragonBones.Slot
  18034. * @version DragonBones 3.0
  18035. */
  18036. class Bone extends TransformObject {
  18037. /**
  18038. * @private
  18039. */
  18040. static toString(): string;
  18041. /**
  18042. * @language zh_CN
  18043. * 是否继承父骨骼的平移。 [true: 继承, false: 不继承]
  18044. * @version DragonBones 3.0
  18045. */
  18046. inheritTranslation: boolean;
  18047. /**
  18048. * @language zh_CN
  18049. * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承]
  18050. * @version DragonBones 3.0
  18051. */
  18052. inheritRotation: boolean;
  18053. /**
  18054. * @language zh_CN
  18055. * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承]
  18056. * @version DragonBones 4.5
  18057. */
  18058. inheritScale: boolean;
  18059. /**
  18060. * @language zh_CN
  18061. * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针]
  18062. * @version DragonBones 4.5
  18063. */
  18064. ikBendPositive: boolean;
  18065. /**
  18066. * @language zh_CN
  18067. * IK 约束的权重。
  18068. * @version DragonBones 4.5
  18069. */
  18070. ikWeight: number;
  18071. /**
  18072. * @language zh_CN
  18073. * 骨骼长度。
  18074. * @version DragonBones 4.5
  18075. */
  18076. length: number;
  18077. /**
  18078. * @private
  18079. */
  18080. private _visible;
  18081. /**
  18082. * @private
  18083. */
  18084. private _ikChain;
  18085. /**
  18086. * @private
  18087. */
  18088. private _ikChainIndex;
  18089. /**
  18090. * @private
  18091. */
  18092. private _ik;
  18093. /**
  18094. * @private
  18095. */
  18096. private _bones;
  18097. /**
  18098. * @private
  18099. */
  18100. private _slots;
  18101. /**
  18102. * @inheritDoc
  18103. */
  18104. protected _onClear(): void;
  18105. /**
  18106. * @private
  18107. */
  18108. private _updateGlobalTransformMatrix();
  18109. /**
  18110. * @private
  18111. */
  18112. private _computeIKA();
  18113. /**
  18114. * @private
  18115. */
  18116. private _computeIKB();
  18117. /**
  18118. * @inheritDoc
  18119. */
  18120. _setArmature(value: Armature): void;
  18121. /**
  18122. * @language zh_CN
  18123. * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  18124. * @version DragonBones 3.0
  18125. */
  18126. invalidUpdate(): void;
  18127. /**
  18128. * @language zh_CN
  18129. * 是否包含某个指定的骨骼或插槽。
  18130. * @returns [true: 包含,false: 不包含]
  18131. * @see dragonBones.TransformObject
  18132. * @version DragonBones 3.0
  18133. */
  18134. contains(child: TransformObject): boolean;
  18135. /**
  18136. * @language zh_CN
  18137. * 所有的子骨骼。
  18138. * @version DragonBones 3.0
  18139. */
  18140. getBones(): Array<Bone>;
  18141. /**
  18142. * @language zh_CN
  18143. * 所有的插槽。
  18144. * @see dragonBones.Slot
  18145. * @version DragonBones 3.0
  18146. */
  18147. getSlots(): Array<Slot>;
  18148. /**
  18149. * @private
  18150. */
  18151. ikChain: number;
  18152. /**
  18153. * @private
  18154. */
  18155. ikChainIndex: number;
  18156. /**
  18157. * @language zh_CN
  18158. * 当前的 IK 约束目标。
  18159. * @version DragonBones 4.5
  18160. */
  18161. ik: Bone;
  18162. /**
  18163. * @language zh_CN
  18164. * 控制此骨骼所有插槽的显示。
  18165. * @default true
  18166. * @see dragonBones.Slot
  18167. * @version DragonBones 3.0
  18168. */
  18169. visible: boolean;
  18170. /**
  18171. * @deprecated
  18172. * @see dragonBones.Armature#getSlot()
  18173. */
  18174. slot: Slot;
  18175. }
  18176. }
  18177. declare namespace dragonBones {
  18178. /**
  18179. * @language zh_CN
  18180. * 骨架显示容器和事件的接口。
  18181. * @see dragonBones.Armature#display
  18182. * @version DragonBones 4.5
  18183. */
  18184. interface IArmatureDisplay extends IEventDispatcher {
  18185. /**
  18186. * @language zh_CN
  18187. * 释放显示对象和骨架。
  18188. * @version DragonBones 4.5
  18189. */
  18190. dispose(): void;
  18191. /**
  18192. * @language zh_CN
  18193. * 获取使用这个显示容器的骨架。
  18194. * @readOnly
  18195. * @see dragonBones.Armature
  18196. * @version DragonBones 4.5
  18197. */
  18198. armature: Armature;
  18199. /**
  18200. * @language zh_CN
  18201. * 获取使用骨架的动画控制器。
  18202. * @readOnly
  18203. * @see dragonBones.Animation
  18204. * @version DragonBones 4.5
  18205. */
  18206. animation: Animation;
  18207. /**
  18208. * @language zh_CN
  18209. * 由显示容器来更新骨架和动画。
  18210. * @param on 开启或关闭显示容器对骨架与动画的更新。
  18211. * @version DragonBones 4.5
  18212. */
  18213. advanceTimeBySelf(on: boolean): void;
  18214. }
  18215. }
  18216. declare namespace dragonBones {
  18217. /**
  18218. * @language zh_CN
  18219. * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。
  18220. * 一个骨骼上可以包含多个插槽。
  18221. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  18222. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  18223. * @see dragonBones.Armature
  18224. * @see dragonBones.Bone
  18225. * @see dragonBones.SlotData
  18226. * @version DragonBones 3.0
  18227. */
  18228. abstract class Slot extends TransformObject {
  18229. private static _helpPoint;
  18230. private static _helpMatrix;
  18231. /**
  18232. * @language zh_CN
  18233. * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承]
  18234. * @default true
  18235. * @version DragonBones 4.5
  18236. */
  18237. inheritAnimation: boolean;
  18238. /**
  18239. * @language zh_CN
  18240. * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。
  18241. * @default null
  18242. * @see dragonBones.AnimationState#displayControl
  18243. * @see dragonBones.AnimationState#name
  18244. * @see dragonBones.AnimationState#group
  18245. * @version DragonBones 4.5
  18246. */
  18247. displayController: string;
  18248. /**
  18249. * @private
  18250. */
  18251. _zOrder: number;
  18252. /**
  18253. * @private
  18254. */
  18255. _pivotX: number;
  18256. /**
  18257. * @private
  18258. */
  18259. _pivotY: number;
  18260. /**
  18261. * @private
  18262. */
  18263. _displayDataSet: SlotDisplayDataSet;
  18264. /**
  18265. * @private
  18266. */
  18267. _meshData: MeshData;
  18268. /**
  18269. * @private
  18270. */
  18271. _childArmature: Armature;
  18272. /**
  18273. * @private
  18274. */
  18275. _rawDisplay: any;
  18276. /**
  18277. * @private
  18278. */
  18279. _meshDisplay: any;
  18280. /**
  18281. * @private
  18282. */
  18283. _cacheFrames: Array<Matrix>;
  18284. /**
  18285. * @private
  18286. */
  18287. _colorTransform: ColorTransform;
  18288. /**
  18289. * @private
  18290. */
  18291. _ffdVertices: Array<number>;
  18292. /**
  18293. * @private
  18294. */
  18295. _replacedDisplayDataSet: Array<DisplayData>;
  18296. /**
  18297. * @private
  18298. */
  18299. protected _displayDirty: boolean;
  18300. /**
  18301. * @private
  18302. */
  18303. protected _blendModeDirty: boolean;
  18304. /**
  18305. * @private
  18306. */
  18307. protected _originDirty: boolean;
  18308. /**
  18309. * @private
  18310. */
  18311. protected _transformDirty: boolean;
  18312. /**
  18313. * @private
  18314. */
  18315. protected _displayIndex: number;
  18316. /**
  18317. * @private
  18318. */
  18319. protected _blendMode: BlendMode;
  18320. /**
  18321. * @private
  18322. */
  18323. protected _display: any;
  18324. /**
  18325. * @private
  18326. */
  18327. protected _localMatrix: Matrix;
  18328. /**
  18329. * @private
  18330. */
  18331. protected _displayList: Array<any | Armature>;
  18332. /**
  18333. * @private
  18334. */
  18335. protected _meshBones: Array<Bone>;
  18336. /**
  18337. * @inheritDoc
  18338. */
  18339. protected _onClear(): void;
  18340. /**
  18341. * @private
  18342. */
  18343. protected abstract _initDisplay(value: any): void;
  18344. /**
  18345. * @private
  18346. */
  18347. protected abstract _disposeDisplay(value: any): void;
  18348. /**
  18349. * @private
  18350. */
  18351. protected abstract _onUpdateDisplay(): void;
  18352. /**
  18353. * @private
  18354. */
  18355. protected abstract _addDisplay(): void;
  18356. /**
  18357. * @private
  18358. */
  18359. protected abstract _replaceDisplay(value: any): void;
  18360. /**
  18361. * @private
  18362. */
  18363. protected abstract _removeDisplay(): void;
  18364. /**
  18365. * @private
  18366. */
  18367. protected abstract _updateZOrder(): void;
  18368. /**
  18369. * @private
  18370. */
  18371. protected abstract _updateBlendMode(): void;
  18372. /**
  18373. * @private
  18374. */
  18375. protected abstract _updateColor(): void;
  18376. /**
  18377. * @private
  18378. */
  18379. protected abstract _updateFilters(): void;
  18380. /**
  18381. * @private
  18382. */
  18383. protected abstract _updateFrame(): void;
  18384. /**
  18385. * @private
  18386. */
  18387. protected abstract _updateMesh(): void;
  18388. /**
  18389. * @private
  18390. */
  18391. protected abstract _updateTransform(): void;
  18392. private _isMeshBonesUpdate();
  18393. /**
  18394. * @private
  18395. */
  18396. protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void;
  18397. /**
  18398. * @private
  18399. */
  18400. protected _updateDisplay(): void;
  18401. /**
  18402. * @private
  18403. */
  18404. protected _updateLocalTransformMatrix(): void;
  18405. /**
  18406. * @private
  18407. */
  18408. protected _updateGlobalTransformMatrix(): void;
  18409. /**
  18410. * @private Factory
  18411. */
  18412. _setDisplayList(value: Array<any>): boolean;
  18413. /**
  18414. * @language zh_CN
  18415. * 在下一帧更新显示对象的状态。
  18416. * @version DragonBones 4.5
  18417. */
  18418. invalidUpdate(): void;
  18419. /**
  18420. * @private
  18421. */
  18422. rawDisplay: any;
  18423. /**
  18424. * @private
  18425. */
  18426. MeshDisplay: any;
  18427. /**
  18428. * @language zh_CN
  18429. * 此时显示的显示对象在显示列表中的索引。
  18430. * @version DragonBones 4.5
  18431. */
  18432. displayIndex: number;
  18433. /**
  18434. * @language zh_CN
  18435. * 包含显示对象或子骨架的显示列表。
  18436. * @version DragonBones 3.0
  18437. */
  18438. displayList: Array<any>;
  18439. /**
  18440. * @language zh_CN
  18441. * 此时显示的显示对象。
  18442. * @version DragonBones 3.0
  18443. */
  18444. display: any;
  18445. /**
  18446. * @language zh_CN
  18447. * 此时显示的子骨架。
  18448. * @see dragonBones.Armature
  18449. * @version DragonBones 3.0
  18450. */
  18451. childArmature: Armature;
  18452. /**
  18453. * @deprecated
  18454. * @see #display
  18455. */
  18456. getDisplay(): any;
  18457. /**
  18458. * @deprecated
  18459. * @see #display
  18460. */
  18461. setDisplay(value: any): void;
  18462. }
  18463. }
  18464. declare namespace dragonBones {
  18465. /**
  18466. * @private
  18467. */
  18468. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  18469. /**
  18470. * @language zh_CN
  18471. * 事件接口。
  18472. * @version DragonBones 4.5
  18473. */
  18474. interface IEventDispatcher {
  18475. /**
  18476. * @language zh_CN
  18477. * 是否包含指定类型的事件。
  18478. * @param type 事件类型。
  18479. * @returns [true: 包含, false: 不包含]
  18480. * @version DragonBones 4.5
  18481. */
  18482. hasEvent(type: EventStringType): boolean;
  18483. /**
  18484. * @language zh_CN
  18485. * 添加事件。
  18486. * @param type 事件类型。
  18487. * @param listener 事件回调。
  18488. * @version DragonBones 4.5
  18489. */
  18490. addEvent(type: EventStringType, listener: Function, target: any): void;
  18491. /**
  18492. * @language zh_CN
  18493. * 移除事件。
  18494. * @param type 事件类型。
  18495. * @param listener 事件回调。
  18496. * @version DragonBones 4.5
  18497. */
  18498. removeEvent(type: EventStringType, listener: Function, target: any): void;
  18499. }
  18500. /**
  18501. * @language zh_CN
  18502. * 事件数据。
  18503. * @version DragonBones 4.5
  18504. */
  18505. class EventObject extends BaseObject {
  18506. /**
  18507. * @language zh_CN
  18508. * 动画开始。
  18509. * @version DragonBones 4.5
  18510. */
  18511. static START: string;
  18512. /**
  18513. * @language zh_CN
  18514. * 动画循环播放一次完成。
  18515. * @version DragonBones 4.5
  18516. */
  18517. static LOOP_COMPLETE: string;
  18518. /**
  18519. * @language zh_CN
  18520. * 动画播放完成。
  18521. * @version DragonBones 4.5
  18522. */
  18523. static COMPLETE: string;
  18524. /**
  18525. * @language zh_CN
  18526. * 动画淡入开始。
  18527. * @version DragonBones 4.5
  18528. */
  18529. static FADE_IN: string;
  18530. /**
  18531. * @language zh_CN
  18532. * 动画淡入完成。
  18533. * @version DragonBones 4.5
  18534. */
  18535. static FADE_IN_COMPLETE: string;
  18536. /**
  18537. * @language zh_CN
  18538. * 动画淡出开始。
  18539. * @version DragonBones 4.5
  18540. */
  18541. static FADE_OUT: string;
  18542. /**
  18543. * @language zh_CN
  18544. * 动画淡出完成。
  18545. * @version DragonBones 4.5
  18546. */
  18547. static FADE_OUT_COMPLETE: string;
  18548. /**
  18549. * @language zh_CN
  18550. * 动画帧事件。
  18551. * @version DragonBones 4.5
  18552. */
  18553. static FRAME_EVENT: string;
  18554. /**
  18555. * @language zh_CN
  18556. * 动画声音事件。
  18557. * @version DragonBones 4.5
  18558. */
  18559. static SOUND_EVENT: string;
  18560. /**
  18561. * @private
  18562. */
  18563. static toString(): string;
  18564. /**
  18565. * @language zh_CN
  18566. * 事件类型。
  18567. * @version DragonBones 4.5
  18568. */
  18569. type: EventStringType;
  18570. /**
  18571. * @language zh_CN
  18572. * 事件名称。 (帧标签的名称或声音的名称)
  18573. * @version DragonBones 4.5
  18574. */
  18575. name: string;
  18576. /**
  18577. * @language zh_CN
  18578. * 扩展的数据。
  18579. * @version DragonBones 4.5
  18580. */
  18581. data: any;
  18582. /**
  18583. * @language zh_CN
  18584. * 发出事件的骨架。
  18585. * @version DragonBones 4.5
  18586. */
  18587. armature: Armature;
  18588. /**
  18589. * @language zh_CN
  18590. * 发出事件的骨骼。
  18591. * @version DragonBones 4.5
  18592. */
  18593. bone: Bone;
  18594. /**
  18595. * @language zh_CN
  18596. * 发出事件的插槽。
  18597. * @version DragonBones 4.5
  18598. */
  18599. slot: Slot;
  18600. /**
  18601. * @language zh_CN
  18602. * 发出事件的动画状态。
  18603. * @version DragonBones 4.5
  18604. */
  18605. animationState: AnimationState;
  18606. /**
  18607. * @private
  18608. */
  18609. frame: AnimationFrameData;
  18610. /**
  18611. * @language zh_CN
  18612. * 用户数据。
  18613. * @version DragonBones 4.5
  18614. */
  18615. userData: any;
  18616. /**
  18617. * @inheritDoc
  18618. */
  18619. protected _onClear(): void;
  18620. }
  18621. }
  18622. declare namespace dragonBones {
  18623. /**
  18624. * @private
  18625. */
  18626. class ColorTransform {
  18627. alphaMultiplier: number;
  18628. redMultiplier: number;
  18629. greenMultiplier: number;
  18630. blueMultiplier: number;
  18631. alphaOffset: number;
  18632. redOffset: number;
  18633. greenOffset: number;
  18634. blueOffset: number;
  18635. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  18636. copyFrom(value: ColorTransform): void;
  18637. identity(): void;
  18638. }
  18639. }
  18640. declare namespace dragonBones {
  18641. /**
  18642. * @language zh_CN
  18643. * 2D 矩阵。
  18644. * @version DragonBones 3.0
  18645. */
  18646. class Matrix {
  18647. a: number;
  18648. b: number;
  18649. c: number;
  18650. d: number;
  18651. tx: number;
  18652. ty: number;
  18653. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  18654. /**
  18655. * @private
  18656. */
  18657. toString(): string;
  18658. /**
  18659. * @language zh_CN
  18660. * 复制矩阵。
  18661. * @param value 需要复制的矩阵。
  18662. * @version DragonBones 3.0
  18663. */
  18664. copyFrom(value: Matrix): void;
  18665. /**
  18666. * @language zh_CN
  18667. * 转换为恒等矩阵。
  18668. * @version DragonBones 3.0
  18669. */
  18670. identity(): void;
  18671. /**
  18672. * @language zh_CN
  18673. * 将当前矩阵与另一个矩阵相乘。
  18674. * @param value 需要相乘的矩阵。
  18675. * @version DragonBones 3.0
  18676. */
  18677. concat(value: Matrix): void;
  18678. /**
  18679. * @language zh_CN
  18680. * 转换为逆矩阵。
  18681. * @version DragonBones 3.0
  18682. */
  18683. invert(): void;
  18684. /**
  18685. * @language zh_CN
  18686. * 将矩阵转换应用于指定点。
  18687. * @param x 横坐标。
  18688. * @param y 纵坐标。
  18689. * @param result 应用转换之后的坐标。
  18690. * @params delta 是否忽略 tx,ty 对坐标的转换。
  18691. * @version DragonBones 3.0
  18692. */
  18693. transformPoint(x: number, y: number, result: {
  18694. x: number;
  18695. y: number;
  18696. }, delta?: boolean): void;
  18697. }
  18698. }
  18699. declare namespace dragonBones {
  18700. /**
  18701. * @private
  18702. */
  18703. class Point {
  18704. x: number;
  18705. y: number;
  18706. constructor(x?: number, y?: number);
  18707. copyFrom(value: Point): void;
  18708. clear(): void;
  18709. }
  18710. }
  18711. declare namespace dragonBones {
  18712. /**
  18713. * @private
  18714. */
  18715. class Rectangle {
  18716. x: number;
  18717. y: number;
  18718. width: number;
  18719. height: number;
  18720. constructor(x?: number, y?: number, width?: number, height?: number);
  18721. copyFrom(value: Rectangle): void;
  18722. clear(): void;
  18723. }
  18724. }
  18725. declare namespace dragonBones {
  18726. /**
  18727. * @language zh_CN
  18728. * 2D 变换。
  18729. * @version DragonBones 3.0
  18730. */
  18731. class Transform {
  18732. /**
  18733. * @language zh_CN
  18734. * 水平位移。
  18735. * @version DragonBones 3.0
  18736. */
  18737. x: number;
  18738. /**
  18739. * @language zh_CN
  18740. * 垂直位移。
  18741. * @version DragonBones 3.0
  18742. */
  18743. y: number;
  18744. /**
  18745. * @language zh_CN
  18746. * 水平倾斜。 (以弧度为单位)
  18747. * @version DragonBones 3.0
  18748. */
  18749. skewX: number;
  18750. /**
  18751. * @language zh_CN
  18752. * 垂直倾斜。 (以弧度为单位)
  18753. * @version DragonBones 3.0
  18754. */
  18755. skewY: number;
  18756. /**
  18757. * @language zh_CN
  18758. * 水平缩放。
  18759. * @version DragonBones 3.0
  18760. */
  18761. scaleX: number;
  18762. /**
  18763. * @language zh_CN
  18764. * 垂直缩放。
  18765. * @version DragonBones 3.0
  18766. */
  18767. scaleY: number;
  18768. /**
  18769. * @private
  18770. */
  18771. static normalizeRadian(value: number): number;
  18772. /**
  18773. * @private
  18774. */
  18775. constructor(
  18776. /**
  18777. * @language zh_CN
  18778. * 水平位移。
  18779. * @version DragonBones 3.0
  18780. */
  18781. x?: number,
  18782. /**
  18783. * @language zh_CN
  18784. * 垂直位移。
  18785. * @version DragonBones 3.0
  18786. */
  18787. y?: number,
  18788. /**
  18789. * @language zh_CN
  18790. * 水平倾斜。 (以弧度为单位)
  18791. * @version DragonBones 3.0
  18792. */
  18793. skewX?: number,
  18794. /**
  18795. * @language zh_CN
  18796. * 垂直倾斜。 (以弧度为单位)
  18797. * @version DragonBones 3.0
  18798. */
  18799. skewY?: number,
  18800. /**
  18801. * @language zh_CN
  18802. * 水平缩放。
  18803. * @version DragonBones 3.0
  18804. */
  18805. scaleX?: number,
  18806. /**
  18807. * @language zh_CN
  18808. * 垂直缩放。
  18809. * @version DragonBones 3.0
  18810. */
  18811. scaleY?: number);
  18812. /**
  18813. * @private
  18814. */
  18815. toString(): string;
  18816. /**
  18817. * @private
  18818. */
  18819. copyFrom(value: Transform): Transform;
  18820. /**
  18821. * @private
  18822. */
  18823. identity(): Transform;
  18824. /**
  18825. * @private
  18826. */
  18827. add(value: Transform): Transform;
  18828. /**
  18829. * @private
  18830. */
  18831. minus(value: Transform): Transform;
  18832. /**
  18833. * @private
  18834. */
  18835. fromMatrix(matrix: Matrix): Transform;
  18836. /**
  18837. * @language zh_CN
  18838. * 转换为矩阵。
  18839. * @param 矩阵。
  18840. * @version DragonBones 3.0
  18841. */
  18842. toMatrix(matrix: Matrix): Transform;
  18843. /**
  18844. * @language zh_CN
  18845. * 旋转。 (以弧度为单位)
  18846. * @version DragonBones 3.0
  18847. */
  18848. rotation: number;
  18849. }
  18850. }
  18851. declare namespace dragonBones {
  18852. /**
  18853. * @private
  18854. */
  18855. abstract class TimelineData<T extends FrameData<T>> extends BaseObject {
  18856. /**
  18857. * @private
  18858. */
  18859. static toString(): string;
  18860. scale: number;
  18861. /**
  18862. * @private
  18863. */
  18864. offset: number;
  18865. /**
  18866. * @private
  18867. */
  18868. frames: Array<T>;
  18869. constructor();
  18870. /**
  18871. * @inheritDoc
  18872. */
  18873. protected _onClear(): void;
  18874. }
  18875. /**
  18876. * @private
  18877. */
  18878. class ZOrderTimelineData extends TimelineData<ZOrderFrameData> {
  18879. static toString(): string;
  18880. }
  18881. /**
  18882. * @private
  18883. */
  18884. class BoneTimelineData extends TimelineData<BoneFrameData> {
  18885. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18886. static toString(): string;
  18887. bone: BoneData;
  18888. originalTransform: Transform;
  18889. cachedFrames: Array<Matrix>;
  18890. constructor();
  18891. /**
  18892. * @inheritDoc
  18893. */
  18894. protected _onClear(): void;
  18895. cacheFrames(cacheFrameCount: number): void;
  18896. }
  18897. /**
  18898. * @private
  18899. */
  18900. class SlotTimelineData extends TimelineData<SlotFrameData> {
  18901. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18902. static toString(): string;
  18903. slot: SlotData;
  18904. cachedFrames: Array<Matrix>;
  18905. constructor();
  18906. /**
  18907. * @inheritDoc
  18908. */
  18909. protected _onClear(): void;
  18910. cacheFrames(cacheFrameCount: number): void;
  18911. }
  18912. /**
  18913. * @private
  18914. */
  18915. class FFDTimelineData extends TimelineData<ExtensionFrameData> {
  18916. static toString(): string;
  18917. displayIndex: number;
  18918. skin: SkinData;
  18919. slot: SlotDisplayDataSet;
  18920. constructor();
  18921. /**
  18922. * @inheritDoc
  18923. */
  18924. protected _onClear(): void;
  18925. }
  18926. }
  18927. declare namespace dragonBones {
  18928. /**
  18929. * @language zh_CN
  18930. * 动画数据。
  18931. * @version DragonBones 3.0
  18932. */
  18933. class AnimationData extends TimelineData<AnimationFrameData> {
  18934. /**
  18935. * @private
  18936. */
  18937. static toString(): string;
  18938. /**
  18939. * @private
  18940. */
  18941. hasAsynchronyTimeline: boolean;
  18942. /**
  18943. * @language zh_CN
  18944. * 持续的帧数。
  18945. * @version DragonBones 3.0
  18946. */
  18947. frameCount: number;
  18948. /**
  18949. * @language zh_CN
  18950. * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  18951. * @version DragonBones 3.0
  18952. */
  18953. playTimes: number;
  18954. /**
  18955. * @language zh_CN
  18956. * 开始的时间。 (以秒为单位)
  18957. * @version DragonBones 3.0
  18958. */
  18959. position: number;
  18960. /**
  18961. * @language zh_CN
  18962. * 持续的时间。 (以秒为单位)
  18963. * @version DragonBones 3.0
  18964. */
  18965. duration: number;
  18966. /**
  18967. * @language zh_CN
  18968. * 淡入混合的时间。 (以秒为单位)
  18969. * @version DragonBones 3.0
  18970. */
  18971. fadeInTime: number;
  18972. /**
  18973. * @private
  18974. */
  18975. cacheTimeToFrameScale: number;
  18976. /**
  18977. * @language zh_CN
  18978. * 数据名称。
  18979. * @version DragonBones 3.0
  18980. */
  18981. name: string;
  18982. /**
  18983. * @private
  18984. */
  18985. animation: AnimationData;
  18986. /**
  18987. * @private
  18988. */
  18989. zOrderTimeline: TimelineData<ZOrderFrameData>;
  18990. /**
  18991. * @private
  18992. */
  18993. boneTimelines: Map<BoneTimelineData>;
  18994. /**
  18995. * @private
  18996. */
  18997. slotTimelines: Map<SlotTimelineData>;
  18998. /**
  18999. * @private
  19000. */
  19001. ffdTimelines: Map<Map<Map<FFDTimelineData>>>;
  19002. /**
  19003. * @private
  19004. */
  19005. cachedFrames: Array<boolean>;
  19006. /**
  19007. * @private
  19008. */
  19009. constructor();
  19010. /**
  19011. * @inheritDoc
  19012. */
  19013. protected _onClear(): void;
  19014. /**
  19015. * @private
  19016. */
  19017. cacheFrames(value: number): void;
  19018. /**
  19019. * @private
  19020. */
  19021. addBoneTimeline(value: BoneTimelineData): void;
  19022. /**
  19023. * @private
  19024. */
  19025. addSlotTimeline(value: SlotTimelineData): void;
  19026. /**
  19027. * @private
  19028. */
  19029. addFFDTimeline(value: FFDTimelineData): void;
  19030. /**
  19031. * @private
  19032. */
  19033. getBoneTimeline(name: string): BoneTimelineData;
  19034. /**
  19035. * @private
  19036. */
  19037. getSlotTimeline(name: string): SlotTimelineData;
  19038. /**
  19039. * @private
  19040. */
  19041. getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData;
  19042. }
  19043. }
  19044. declare namespace dragonBones {
  19045. /**
  19046. * @language zh_CN
  19047. * 骨架数据。
  19048. * @see dragonBones.Armature
  19049. * @version DragonBones 3.0
  19050. */
  19051. class ArmatureData extends BaseObject {
  19052. private static _onSortSlots(a, b);
  19053. /**
  19054. * @private
  19055. */
  19056. static toString(): string;
  19057. /**
  19058. * @language zh_CN
  19059. * 动画帧率。
  19060. * @version DragonBones 3.0
  19061. */
  19062. frameRate: number;
  19063. /**
  19064. * @language zh_CN
  19065. * 骨架类型。
  19066. * @see dragonBones.ArmatureType
  19067. * @version DragonBones 3.0
  19068. */
  19069. type: ArmatureType;
  19070. /**
  19071. * @language zh_CN
  19072. * 数据名称。
  19073. * @version DragonBones 3.0
  19074. */
  19075. name: string;
  19076. /**
  19077. * @private
  19078. */
  19079. parent: DragonBonesData;
  19080. /**
  19081. * @private
  19082. */
  19083. userData: any;
  19084. /**
  19085. * @private
  19086. */
  19087. aabb: Rectangle;
  19088. /**
  19089. * @language zh_CN
  19090. * 所有的骨骼数据。
  19091. * @see dragonBones.BoneData
  19092. * @version DragonBones 3.0
  19093. */
  19094. bones: Map<BoneData>;
  19095. /**
  19096. * @language zh_CN
  19097. * 所有的插槽数据。
  19098. * @see dragonBones.SlotData
  19099. * @version DragonBones 3.0
  19100. */
  19101. slots: Map<SlotData>;
  19102. /**
  19103. * @language zh_CN
  19104. * 所有的皮肤数据。
  19105. * @see dragonBones.SkinData
  19106. * @version DragonBones 3.0
  19107. */
  19108. skins: Map<SkinData>;
  19109. /**
  19110. * @language zh_CN
  19111. * 所有的动画数据。
  19112. * @see dragonBones.AnimationData
  19113. * @version DragonBones 3.0
  19114. */
  19115. animations: Map<AnimationData>;
  19116. /**
  19117. * @private
  19118. */
  19119. actions: Array<ActionData>;
  19120. /**
  19121. * @private
  19122. */
  19123. cacheFrameRate: number;
  19124. /**
  19125. * @private
  19126. */
  19127. scale: number;
  19128. private _boneDirty;
  19129. private _slotDirty;
  19130. private _defaultSkin;
  19131. private _defaultAnimation;
  19132. private _sortedBones;
  19133. private _sortedSlots;
  19134. private _bonesChildren;
  19135. /**
  19136. * @private
  19137. */
  19138. constructor();
  19139. /**
  19140. * @inheritDoc
  19141. */
  19142. protected _onClear(): void;
  19143. private _sortBones();
  19144. private _sortSlots();
  19145. /**
  19146. * @private
  19147. */
  19148. cacheFrames(value: number): void;
  19149. /**
  19150. * @private
  19151. */
  19152. addBone(value: BoneData, parentName: string): void;
  19153. /**
  19154. * @private
  19155. */
  19156. addSlot(value: SlotData): void;
  19157. /**
  19158. * @private
  19159. */
  19160. addSkin(value: SkinData): void;
  19161. /**
  19162. * @private
  19163. */
  19164. addAnimation(value: AnimationData): void;
  19165. /**
  19166. * @language zh_CN
  19167. * 获取指定名称的骨骼数据。
  19168. * @param name 骨骼数据名称。
  19169. * @see dragonBones.BoneData
  19170. * @version DragonBones 3.0
  19171. */
  19172. getBone(name: string): BoneData;
  19173. /**
  19174. * @language zh_CN
  19175. * 获取指定名称的插槽数据。
  19176. * @param name 插槽数据名称。
  19177. * @see dragonBones.SlotData
  19178. * @version DragonBones 3.0
  19179. */
  19180. getSlot(name: string): SlotData;
  19181. /**
  19182. * @language zh_CN
  19183. * 获取指定名称的皮肤数据。
  19184. * @param name 皮肤数据名称。
  19185. * @see dragonBones.SkinData
  19186. * @version DragonBones 3.0
  19187. */
  19188. getSkin(name: string): SkinData;
  19189. /**
  19190. * @language zh_CN
  19191. * 获取指定名称的动画数据。
  19192. * @param name 动画数据名称。
  19193. * @see dragonBones.AnimationData
  19194. * @version DragonBones 3.0
  19195. */
  19196. getAnimation(name: string): AnimationData;
  19197. /**
  19198. * @private
  19199. */
  19200. sortedBones: Array<BoneData>;
  19201. /**
  19202. * @private
  19203. */
  19204. sortedSlots: Array<SlotData>;
  19205. /**
  19206. * @language zh_CN
  19207. * 获取默认的皮肤数据。
  19208. * @see dragonBones.SkinData
  19209. * @version DragonBones 4.5
  19210. */
  19211. defaultSkin: SkinData;
  19212. /**
  19213. * @language zh_CN
  19214. * 获取默认的动画数据。
  19215. * @see dragonBones.AnimationData
  19216. * @version DragonBones 4.5
  19217. */
  19218. defaultAnimation: AnimationData;
  19219. }
  19220. /**
  19221. * @language zh_CN
  19222. * 骨骼数据。
  19223. * @see dragonBones.Bone
  19224. * @version DragonBones 3.0
  19225. */
  19226. class BoneData extends BaseObject {
  19227. /**
  19228. * @private
  19229. */
  19230. static toString(): string;
  19231. /**
  19232. * @private
  19233. */
  19234. inheritTranslation: boolean;
  19235. /**
  19236. * @private
  19237. */
  19238. inheritRotation: boolean;
  19239. /**
  19240. * @private
  19241. */
  19242. inheritScale: boolean;
  19243. /**
  19244. * @private
  19245. */
  19246. bendPositive: boolean;
  19247. /**
  19248. * @private
  19249. */
  19250. chain: number;
  19251. /**
  19252. * @private
  19253. */
  19254. chainIndex: number;
  19255. /**
  19256. * @private
  19257. */
  19258. weight: number;
  19259. /**
  19260. * @private
  19261. */
  19262. length: number;
  19263. /**
  19264. * @language zh_CN
  19265. * 数据名称。
  19266. * @version DragonBones 3.0
  19267. */
  19268. name: string;
  19269. /**
  19270. * @language zh_CN
  19271. * 所属的父骨骼数据。
  19272. * @version DragonBones 3.0
  19273. */
  19274. parent: BoneData;
  19275. /**
  19276. * @private
  19277. */
  19278. ik: BoneData;
  19279. /**
  19280. * @private
  19281. */
  19282. transform: Transform;
  19283. /**
  19284. * @private
  19285. */
  19286. constructor();
  19287. /**
  19288. * @inheritDoc
  19289. */
  19290. protected _onClear(): void;
  19291. }
  19292. /**
  19293. * @language zh_CN
  19294. * 插槽数据。
  19295. * @see dragonBones.Slot
  19296. * @version DragonBones 3.0
  19297. */
  19298. class SlotData extends BaseObject {
  19299. /**
  19300. * @private
  19301. */
  19302. static DEFAULT_COLOR: ColorTransform;
  19303. /**
  19304. * @private
  19305. */
  19306. static generateColor(): ColorTransform;
  19307. /**
  19308. * @private
  19309. */
  19310. static toString(): string;
  19311. /**
  19312. * @private
  19313. */
  19314. displayIndex: number;
  19315. /**
  19316. * @private
  19317. */
  19318. zOrder: number;
  19319. /**
  19320. * @private
  19321. */
  19322. blendMode: BlendMode;
  19323. /**
  19324. * @language zh_CN
  19325. * 数据名称。
  19326. * @version DragonBones 3.0
  19327. */
  19328. name: string;
  19329. /**
  19330. * @language zh_CN
  19331. * 所属的父骨骼数据。
  19332. * @see dragonBones.BoneData
  19333. * @version DragonBones 3.0
  19334. */
  19335. parent: BoneData;
  19336. /**
  19337. * @private
  19338. */
  19339. color: ColorTransform;
  19340. /**
  19341. * @private
  19342. */
  19343. actions: Array<ActionData>;
  19344. /**
  19345. * @private
  19346. */
  19347. constructor();
  19348. /**
  19349. * @inheritDoc
  19350. */
  19351. protected _onClear(): void;
  19352. }
  19353. /**
  19354. * @language zh_CN
  19355. * 皮肤数据。
  19356. * @version DragonBones 3.0
  19357. */
  19358. class SkinData extends BaseObject {
  19359. /**
  19360. * @private
  19361. */
  19362. static toString(): string;
  19363. /**
  19364. * @language zh_CN
  19365. * 数据名称。
  19366. * @version DragonBones 3.0
  19367. */
  19368. name: string;
  19369. /**
  19370. * @private
  19371. */
  19372. slots: Map<SlotDisplayDataSet>;
  19373. /**
  19374. * @private
  19375. */
  19376. constructor();
  19377. /**
  19378. * @inheritDoc
  19379. */
  19380. protected _onClear(): void;
  19381. /**
  19382. * @private
  19383. */
  19384. addSlot(value: SlotDisplayDataSet): void;
  19385. /**
  19386. * @private
  19387. */
  19388. getSlot(name: string): SlotDisplayDataSet;
  19389. }
  19390. /**
  19391. * @private
  19392. */
  19393. class SlotDisplayDataSet extends BaseObject {
  19394. static toString(): string;
  19395. slot: SlotData;
  19396. displays: Array<DisplayData>;
  19397. constructor();
  19398. /**
  19399. * @inheritDoc
  19400. */
  19401. protected _onClear(): void;
  19402. }
  19403. /**
  19404. * @private
  19405. */
  19406. class DisplayData extends BaseObject {
  19407. static toString(): string;
  19408. isRelativePivot: boolean;
  19409. type: DisplayType;
  19410. name: string;
  19411. texture: TextureData;
  19412. armature: ArmatureData;
  19413. mesh: MeshData;
  19414. pivot: Point;
  19415. transform: Transform;
  19416. constructor();
  19417. /**
  19418. * @inheritDoc
  19419. */
  19420. protected _onClear(): void;
  19421. }
  19422. /**
  19423. * @private
  19424. */
  19425. class MeshData extends BaseObject {
  19426. static toString(): string;
  19427. skinned: boolean;
  19428. slotPose: Matrix;
  19429. uvs: Array<number>;
  19430. vertices: Array<number>;
  19431. vertexIndices: Array<number>;
  19432. boneIndices: Array<Array<number>>;
  19433. weights: Array<Array<number>>;
  19434. boneVertices: Array<Array<number>>;
  19435. bones: Array<BoneData>;
  19436. inverseBindPose: Array<Matrix>;
  19437. constructor();
  19438. /**
  19439. * @inheritDoc
  19440. */
  19441. protected _onClear(): void;
  19442. }
  19443. }
  19444. declare namespace dragonBones {
  19445. /**
  19446. * @language zh_CN
  19447. * 龙骨数据,包含多个骨架数据。
  19448. * @see dragonBones.ArmatureData
  19449. * @version DragonBones 3.0
  19450. */
  19451. class DragonBonesData extends BaseObject {
  19452. /**
  19453. * @private
  19454. */
  19455. static toString(): string;
  19456. /**
  19457. * @language zh_CN
  19458. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19459. * @default false
  19460. * @see dragonBones.ArmatureData
  19461. * @version DragonBones 4.5
  19462. */
  19463. autoSearch: boolean;
  19464. /**
  19465. * @language zh_CN
  19466. * 动画帧频。
  19467. * @version DragonBones 3.0
  19468. */
  19469. frameRate: number;
  19470. /**
  19471. * @language zh_CN
  19472. * 数据名称。
  19473. * @version DragonBones 3.0
  19474. */
  19475. name: string;
  19476. /**
  19477. * @language zh_CN
  19478. * 所有的骨架数据。
  19479. * @see dragonBones.ArmatureData
  19480. * @version DragonBones 3.0
  19481. */
  19482. armatures: Map<ArmatureData>;
  19483. private _armatureNames;
  19484. /**
  19485. * @inheritDoc
  19486. */
  19487. protected _onClear(): void;
  19488. /**
  19489. * @language zh_CN
  19490. * 获取指定名称的骨架。
  19491. * @param name 骨架数据骨架名称。
  19492. * @see dragonBones.ArmatureData
  19493. * @version DragonBones 3.0
  19494. */
  19495. getArmature(name: string): ArmatureData;
  19496. /**
  19497. * @language zh_CN
  19498. * 所有的骨架数据名称。
  19499. * @see #armatures
  19500. * @version DragonBones 3.0
  19501. */
  19502. armatureNames: Array<string>;
  19503. /**
  19504. * @deprecated
  19505. * @see dragonBones.BaseFactory#removeDragonBonesData()
  19506. */
  19507. dispose(): void;
  19508. }
  19509. }
  19510. declare namespace dragonBones {
  19511. /**
  19512. * @private
  19513. */
  19514. class ActionData extends BaseObject {
  19515. static toString(): string;
  19516. type: ActionType;
  19517. bone: BoneData;
  19518. slot: SlotData;
  19519. data: Array<any>;
  19520. constructor();
  19521. protected _onClear(): void;
  19522. }
  19523. /**
  19524. * @private
  19525. */
  19526. class EventData extends BaseObject {
  19527. static toString(): string;
  19528. type: EventType;
  19529. name: string;
  19530. data: any;
  19531. bone: BoneData;
  19532. slot: SlotData;
  19533. constructor();
  19534. protected _onClear(): void;
  19535. }
  19536. /**
  19537. * @private
  19538. */
  19539. abstract class FrameData<T> extends BaseObject {
  19540. position: number;
  19541. duration: number;
  19542. prev: T;
  19543. next: T;
  19544. constructor();
  19545. /**
  19546. * @inheritDoc
  19547. */
  19548. protected _onClear(): void;
  19549. }
  19550. /**
  19551. * @private
  19552. */
  19553. abstract class TweenFrameData<T> extends FrameData<T> {
  19554. static samplingCurve(curve: Array<number>, frameCount: number): Array<number>;
  19555. tweenEasing: number;
  19556. curve: Array<number>;
  19557. constructor();
  19558. /**
  19559. * @inheritDoc
  19560. */
  19561. protected _onClear(): void;
  19562. }
  19563. /**
  19564. * @private
  19565. */
  19566. class AnimationFrameData extends FrameData<AnimationFrameData> {
  19567. static toString(): string;
  19568. actions: Array<ActionData>;
  19569. events: Array<EventData>;
  19570. constructor();
  19571. /**
  19572. * @inheritDoc
  19573. */
  19574. protected _onClear(): void;
  19575. }
  19576. /**
  19577. * @private
  19578. */
  19579. class ZOrderFrameData extends FrameData<ZOrderFrameData> {
  19580. zOrder: Array<number>;
  19581. constructor();
  19582. /**
  19583. * @inheritDoc
  19584. */
  19585. protected _onClear(): void;
  19586. }
  19587. /**
  19588. * @private
  19589. */
  19590. class BoneFrameData extends TweenFrameData<BoneFrameData> {
  19591. static toString(): string;
  19592. tweenScale: boolean;
  19593. tweenRotate: number;
  19594. guideCurve: Array<number>;
  19595. transform: Transform;
  19596. constructor();
  19597. /**
  19598. * @inheritDoc
  19599. */
  19600. protected _onClear(): void;
  19601. }
  19602. /**
  19603. * @private
  19604. */
  19605. class SlotFrameData extends TweenFrameData<SlotFrameData> {
  19606. static DEFAULT_COLOR: ColorTransform;
  19607. static generateColor(): ColorTransform;
  19608. static toString(): string;
  19609. displayIndex: number;
  19610. color: ColorTransform;
  19611. constructor();
  19612. /**
  19613. * @inheritDoc
  19614. */
  19615. protected _onClear(): void;
  19616. }
  19617. /**
  19618. * @private
  19619. */
  19620. class ExtensionFrameData extends TweenFrameData<ExtensionFrameData> {
  19621. static toString(): string;
  19622. type: ExtensionType;
  19623. tweens: Array<number>;
  19624. keys: Array<number>;
  19625. constructor();
  19626. /**
  19627. * @inheritDoc
  19628. */
  19629. protected _onClear(): void;
  19630. }
  19631. }
  19632. declare namespace dragonBones {
  19633. /**
  19634. * @private
  19635. */
  19636. abstract class DataParser {
  19637. protected static DATA_VERSION_2_3: string;
  19638. protected static DATA_VERSION_3_0: string;
  19639. protected static DATA_VERSION_4_0: string;
  19640. protected static DATA_VERSION: string;
  19641. protected static TEXTURE_ATLAS: string;
  19642. protected static SUB_TEXTURE: string;
  19643. protected static FORMAT: string;
  19644. protected static IMAGE_PATH: string;
  19645. protected static WIDTH: string;
  19646. protected static HEIGHT: string;
  19647. protected static ROTATED: string;
  19648. protected static FRAME_X: string;
  19649. protected static FRAME_Y: string;
  19650. protected static FRAME_WIDTH: string;
  19651. protected static FRAME_HEIGHT: string;
  19652. protected static DRADON_BONES: string;
  19653. protected static ARMATURE: string;
  19654. protected static BONE: string;
  19655. protected static IK: string;
  19656. protected static SLOT: string;
  19657. protected static SKIN: string;
  19658. protected static DISPLAY: string;
  19659. protected static ANIMATION: string;
  19660. protected static Z_ORDER: string;
  19661. protected static FFD: string;
  19662. protected static FRAME: string;
  19663. protected static PIVOT: string;
  19664. protected static TRANSFORM: string;
  19665. protected static AABB: string;
  19666. protected static COLOR: string;
  19667. protected static FILTER: string;
  19668. protected static VERSION: string;
  19669. protected static IS_GLOBAL: string;
  19670. protected static FRAME_RATE: string;
  19671. protected static TYPE: string;
  19672. protected static NAME: string;
  19673. protected static PARENT: string;
  19674. protected static LENGTH: string;
  19675. protected static DATA: string;
  19676. protected static DISPLAY_INDEX: string;
  19677. protected static BLEND_MODE: string;
  19678. protected static INHERIT_TRANSLATION: string;
  19679. protected static INHERIT_ROTATION: string;
  19680. protected static INHERIT_SCALE: string;
  19681. protected static TARGET: string;
  19682. protected static BEND_POSITIVE: string;
  19683. protected static CHAIN: string;
  19684. protected static WEIGHT: string;
  19685. protected static FADE_IN_TIME: string;
  19686. protected static PLAY_TIMES: string;
  19687. protected static SCALE: string;
  19688. protected static OFFSET: string;
  19689. protected static POSITION: string;
  19690. protected static DURATION: string;
  19691. protected static TWEEN_EASING: string;
  19692. protected static TWEEN_ROTATE: string;
  19693. protected static TWEEN_SCALE: string;
  19694. protected static CURVE: string;
  19695. protected static GUIDE_CURVE: string;
  19696. protected static EVENT: string;
  19697. protected static SOUND: string;
  19698. protected static ACTION: string;
  19699. protected static ACTIONS: string;
  19700. protected static DEFAULT_ACTIONS: string;
  19701. protected static X: string;
  19702. protected static Y: string;
  19703. protected static SKEW_X: string;
  19704. protected static SKEW_Y: string;
  19705. protected static SCALE_X: string;
  19706. protected static SCALE_Y: string;
  19707. protected static ALPHA_OFFSET: string;
  19708. protected static RED_OFFSET: string;
  19709. protected static GREEN_OFFSET: string;
  19710. protected static BLUE_OFFSET: string;
  19711. protected static ALPHA_MULTIPLIER: string;
  19712. protected static RED_MULTIPLIER: string;
  19713. protected static GREEN_MULTIPLIER: string;
  19714. protected static BLUE_MULTIPLIER: string;
  19715. protected static UVS: string;
  19716. protected static VERTICES: string;
  19717. protected static TRIANGLES: string;
  19718. protected static WEIGHTS: string;
  19719. protected static SLOT_POSE: string;
  19720. protected static BONE_POSE: string;
  19721. protected static TWEEN: string;
  19722. protected static KEY: string;
  19723. protected static COLOR_TRANSFORM: string;
  19724. protected static TIMELINE: string;
  19725. protected static PIVOT_X: string;
  19726. protected static PIVOT_Y: string;
  19727. protected static Z: string;
  19728. protected static LOOP: string;
  19729. protected static AUTO_TWEEN: string;
  19730. protected static HIDE: string;
  19731. protected static _getArmatureType(value: string): ArmatureType;
  19732. protected static _getDisplayType(value: string): DisplayType;
  19733. protected static _getBlendMode(value: string): BlendMode;
  19734. protected static _getActionType(value: string): ActionType;
  19735. protected _data: DragonBonesData;
  19736. protected _armature: ArmatureData;
  19737. protected _skin: SkinData;
  19738. protected _slotDisplayDataSet: SlotDisplayDataSet;
  19739. protected _mesh: MeshData;
  19740. protected _animation: AnimationData;
  19741. protected _timeline: any;
  19742. protected _isOldData: boolean;
  19743. protected _isGlobalTransform: boolean;
  19744. protected _isAutoTween: boolean;
  19745. protected _animationTweenEasing: number;
  19746. protected _timelinePivot: Point;
  19747. protected _helpPoint: Point;
  19748. protected _helpTransformA: Transform;
  19749. protected _helpTransformB: Transform;
  19750. protected _helpMatrix: Matrix;
  19751. protected _rawBones: Array<BoneData>;
  19752. constructor();
  19753. /**
  19754. * @private
  19755. */
  19756. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData;
  19757. /**
  19758. * @private
  19759. */
  19760. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void;
  19761. private _getTimelineFrameMatrix(animation, timeline, position, transform);
  19762. protected _globalToLocal(armature: ArmatureData): void;
  19763. protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array<ActionData>, events: Array<EventData>): void;
  19764. /**
  19765. * @deprecated
  19766. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19767. */
  19768. static parseDragonBonesData(rawData: any): DragonBonesData;
  19769. /**
  19770. * @deprecated
  19771. * @see dragonBones.BaseFactory#parsetTextureAtlasData()
  19772. */
  19773. static parseTextureAtlasData(rawData: any, scale?: number): any;
  19774. }
  19775. }
  19776. declare namespace dragonBones {
  19777. /**
  19778. * @private
  19779. */
  19780. class ObjectDataParser extends DataParser {
  19781. /**
  19782. * @private
  19783. */
  19784. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  19785. /**
  19786. * @private
  19787. */
  19788. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  19789. /**
  19790. * @private
  19791. */
  19792. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  19793. /**
  19794. * @private
  19795. */
  19796. protected static _getParameter(rawData: Array<any>, index: number, defaultValue: any): any;
  19797. /**
  19798. * @private
  19799. */
  19800. constructor();
  19801. /**
  19802. * @private
  19803. */
  19804. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  19805. /**
  19806. * @private
  19807. */
  19808. protected _parseBone(rawData: any): BoneData;
  19809. /**
  19810. * @private
  19811. */
  19812. protected _parseIK(rawData: any): void;
  19813. /**
  19814. * @private
  19815. */
  19816. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  19817. /**
  19818. * @private
  19819. */
  19820. protected _parseSkin(rawData: any): SkinData;
  19821. /**
  19822. * @private
  19823. */
  19824. protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet;
  19825. /**
  19826. * @private
  19827. */
  19828. protected _parseDisplay(rawData: any): DisplayData;
  19829. /**
  19830. * @private
  19831. */
  19832. protected _parseMesh(rawData: any): MeshData;
  19833. /**
  19834. * @private
  19835. */
  19836. protected _parseAnimation(rawData: any): AnimationData;
  19837. /**
  19838. * @private
  19839. */
  19840. protected _parseBoneTimeline(rawData: any): BoneTimelineData;
  19841. /**
  19842. * @private
  19843. */
  19844. protected _parseSlotTimeline(rawData: any): SlotTimelineData;
  19845. /**
  19846. * @private
  19847. */
  19848. protected _parseFFDTimeline(rawData: any): FFDTimelineData;
  19849. /**
  19850. * @private
  19851. */
  19852. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData;
  19853. /**
  19854. * @private
  19855. */
  19856. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData;
  19857. /**
  19858. * @private
  19859. */
  19860. protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData;
  19861. /**
  19862. * @private
  19863. */
  19864. protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData;
  19865. /**
  19866. * @private
  19867. */
  19868. protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData;
  19869. /**
  19870. * @private
  19871. */
  19872. protected _parseTweenFrame<T extends TweenFrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19873. /**
  19874. * @private
  19875. */
  19876. protected _parseFrame<T extends FrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19877. /**
  19878. * @private
  19879. */
  19880. protected _parseTimeline<T extends FrameData<T>>(rawData: Object, timeline: TimelineData<T>, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void;
  19881. /**
  19882. * @private
  19883. */
  19884. protected _parseActionData(rawData: any, actions: Array<ActionData>, bone: BoneData, slot: SlotData): void;
  19885. /**
  19886. * @private
  19887. */
  19888. protected _parseEventData(rawData: any, events: Array<EventData>, bone: BoneData, slot: SlotData): void;
  19889. /**
  19890. * @private
  19891. */
  19892. protected _parseTransform(rawData: Object, transform: Transform): void;
  19893. /**
  19894. * @private
  19895. */
  19896. protected _parseColorTransform(rawData: Object, color: ColorTransform): void;
  19897. /**
  19898. * @inheritDoc
  19899. */
  19900. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData;
  19901. /**
  19902. * @inheritDoc
  19903. */
  19904. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void;
  19905. /**
  19906. * @private
  19907. */
  19908. private static _instance;
  19909. /**
  19910. * @deprecated
  19911. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19912. */
  19913. static getInstance(): ObjectDataParser;
  19914. }
  19915. }
  19916. declare namespace dragonBones {
  19917. /**
  19918. * @language zh_CN
  19919. * 贴图集数据。
  19920. * @version DragonBones 3.0
  19921. */
  19922. abstract class TextureAtlasData extends BaseObject {
  19923. /**
  19924. * @language zh_CN
  19925. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19926. * @default false
  19927. * @version DragonBones 4.5
  19928. */
  19929. autoSearch: boolean;
  19930. /**
  19931. * @language zh_CN
  19932. * 贴图集缩放系数。
  19933. * @version DragonBones 3.0
  19934. */
  19935. scale: number;
  19936. /**
  19937. * @language zh_CN
  19938. * 贴图集名称。
  19939. * @version DragonBones 3.0
  19940. */
  19941. name: string;
  19942. /**
  19943. * @language zh_CN
  19944. * 贴图集图片路径。
  19945. * @version DragonBones 3.0
  19946. */
  19947. imagePath: string;
  19948. /**
  19949. * @inheritDoc
  19950. */
  19951. protected _onClear(): void;
  19952. /**
  19953. * @private
  19954. */
  19955. getTexture(name: string): TextureData;
  19956. }
  19957. /**
  19958. * @private
  19959. */
  19960. abstract class TextureData extends BaseObject {
  19961. static generateRectangle(): Rectangle;
  19962. rotated: boolean;
  19963. name: string;
  19964. frame: Rectangle;
  19965. parent: TextureAtlasData;
  19966. region: Rectangle;
  19967. constructor();
  19968. /**
  19969. * @inheritDoc
  19970. */
  19971. protected _onClear(): void;
  19972. }
  19973. }
  19974. declare namespace dragonBones {
  19975. /**
  19976. * @private
  19977. */
  19978. type BuildArmaturePackage = {
  19979. dataName?: string;
  19980. textureAtlasName?: string;
  19981. data?: DragonBonesData;
  19982. armature?: ArmatureData;
  19983. skin?: SkinData;
  19984. };
  19985. /**
  19986. * @language zh_CN
  19987. * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例)
  19988. * @see dragonBones.DragonBonesData
  19989. * @see dragonBones.TextureAtlasData
  19990. * @see dragonBones.ArmatureData
  19991. * @see dragonBones.Armature
  19992. * @version DragonBones 3.0
  19993. */
  19994. abstract class BaseFactory {
  19995. protected static _defaultParser: ObjectDataParser;
  19996. /**
  19997. * @language zh_CN
  19998. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19999. * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启)
  20000. * @see dragonBones.DragonBonesData#autoSearch
  20001. * @see dragonBones.TextureAtlasData#autoSearch
  20002. * @version DragonBones 4.5
  20003. */
  20004. autoSearch: boolean;
  20005. /**
  20006. * @private
  20007. */
  20008. protected _dataParser: DataParser;
  20009. /**
  20010. * @private
  20011. */
  20012. protected _dragonBonesDataMap: Map<DragonBonesData>;
  20013. /**
  20014. * @private
  20015. */
  20016. protected _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  20017. /**
  20018. * @private
  20019. */
  20020. constructor(dataParser?: DataParser);
  20021. /**
  20022. * @private
  20023. */
  20024. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData;
  20025. /**
  20026. * @private
  20027. */
  20028. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  20029. /**
  20030. * @private
  20031. */
  20032. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  20033. /**
  20034. * @private
  20035. */
  20036. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  20037. /**
  20038. * @private
  20039. */
  20040. protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void;
  20041. /**
  20042. * @private
  20043. */
  20044. protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData;
  20045. /**
  20046. * @private
  20047. */
  20048. protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature;
  20049. /**
  20050. * @private
  20051. */
  20052. protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot;
  20053. /**
  20054. * @language zh_CN
  20055. * 解析并添加龙骨数据。
  20056. * @param rawData 需要解析的原始数据。 (JSON)
  20057. * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20058. * @returns DragonBonesData
  20059. * @see #getDragonBonesData()
  20060. * @see #addDragonBonesData()
  20061. * @see #removeDragonBonesData()
  20062. * @see dragonBones.DragonBonesData
  20063. * @version DragonBones 4.5
  20064. */
  20065. parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData;
  20066. /**
  20067. * @language zh_CN
  20068. * 解析并添加贴图集数据。
  20069. * @param rawData 需要解析的原始数据。 (JSON)
  20070. * @param textureAtlas 贴图集数据。 (JSON)
  20071. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20072. * @param scale 为贴图集设置一个缩放值。
  20073. * @returns 贴图集数据
  20074. * @see #getTextureAtlasData()
  20075. * @see #addTextureAtlasData()
  20076. * @see #removeTextureAtlasData()
  20077. * @see dragonBones.TextureAtlasData
  20078. * @version DragonBones 4.5
  20079. */
  20080. parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData;
  20081. /**
  20082. * @language zh_CN
  20083. * 获取指定名称的龙骨数据。
  20084. * @param name 数据名称。
  20085. * @returns DragonBonesData
  20086. * @see #parseDragonBonesData()
  20087. * @see #addDragonBonesData()
  20088. * @see #removeDragonBonesData()
  20089. * @see dragonBones.DragonBonesData
  20090. * @version DragonBones 3.0
  20091. */
  20092. getDragonBonesData(name: string): DragonBonesData;
  20093. /**
  20094. * @language zh_CN
  20095. * 添加龙骨数据。
  20096. * @param data 龙骨数据。
  20097. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20098. * @see #parseDragonBonesData()
  20099. * @see #getDragonBonesData()
  20100. * @see #removeDragonBonesData()
  20101. * @see dragonBones.DragonBonesData
  20102. * @version DragonBones 3.0
  20103. */
  20104. addDragonBonesData(data: DragonBonesData, name?: string): void;
  20105. /**
  20106. * @language zh_CN
  20107. * 移除龙骨数据。
  20108. * @param name 数据名称。
  20109. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20110. * @see #parseDragonBonesData()
  20111. * @see #getDragonBonesData()
  20112. * @see #addDragonBonesData()
  20113. * @see dragonBones.DragonBonesData
  20114. * @version DragonBones 3.0
  20115. */
  20116. removeDragonBonesData(name: string, disposeData?: boolean): void;
  20117. /**
  20118. * @language zh_CN
  20119. * 获取指定名称的贴图集数据列表。
  20120. * @param name 数据名称。
  20121. * @returns 贴图集数据列表。
  20122. * @see #parseTextureAtlasData()
  20123. * @see #addTextureAtlasData()
  20124. * @see #removeTextureAtlasData()
  20125. * @see dragonBones.textures.TextureAtlasData
  20126. * @version DragonBones 3.0
  20127. */
  20128. getTextureAtlasData(name: string): Array<TextureAtlasData>;
  20129. /**
  20130. * @language zh_CN
  20131. * 添加贴图集数据。
  20132. * @param data 贴图集数据。
  20133. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20134. * @see #parseTextureAtlasData()
  20135. * @see #getTextureAtlasData()
  20136. * @see #removeTextureAtlasData()
  20137. * @see dragonBones.textures.TextureAtlasData
  20138. * @version DragonBones 3.0
  20139. */
  20140. addTextureAtlasData(data: TextureAtlasData, name?: string): void;
  20141. /**
  20142. * @language zh_CN
  20143. * 移除贴图集数据。
  20144. * @param name 数据名称。
  20145. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20146. * @see #parseTextureAtlasData()
  20147. * @see #getTextureAtlasData()
  20148. * @see #addTextureAtlasData()
  20149. * @see dragonBones.textures.TextureAtlasData
  20150. * @version DragonBones 3.0
  20151. */
  20152. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  20153. /**
  20154. * @language zh_CN
  20155. * 清除所有的数据。
  20156. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20157. * @version DragonBones 4.5
  20158. */
  20159. clear(disposeData?: boolean): void;
  20160. /**
  20161. * @language zh_CN
  20162. * 创建一个指定名称的骨架。
  20163. * @param armatureName 骨架数据名称。
  20164. * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。
  20165. * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。
  20166. * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。
  20167. * @returns 骨架
  20168. * @see dragonBones.Armature
  20169. * @version DragonBones 3.0
  20170. */
  20171. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature;
  20172. /**
  20173. * @language zh_CN
  20174. * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构)
  20175. * @param toArmature 指定的骨架。
  20176. * @param fromArmatreName 其他骨架的名称。
  20177. * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。
  20178. * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。
  20179. * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除]
  20180. * @returns 是否替换成功。 [true: 成功, false: 不成功]
  20181. * @see dragonBones.Armature
  20182. * @version DragonBones 4.5
  20183. */
  20184. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean;
  20185. /**
  20186. * @language zh_CN
  20187. * 将指定插槽的显示对象替换为指定资源创造出的显示对象。
  20188. * @param dragonBonesName 指定的龙骨数据名称。
  20189. * @param armatureName 指定的骨架名称。
  20190. * @param slotName 指定的插槽名称。
  20191. * @param displayName 指定的显示对象名称。
  20192. * @param slot 指定的插槽实例。
  20193. * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
  20194. * @version DragonBones 4.5
  20195. */
  20196. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void;
  20197. /**
  20198. * @language zh_CN
  20199. * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。
  20200. * @param dragonBonesName 指定的 DragonBonesData 名称。
  20201. * @param armatureName 指定的骨架名称。
  20202. * @param slotName 指定的插槽名称。
  20203. * @param slot 指定的插槽实例。
  20204. * @version DragonBones 4.5
  20205. */
  20206. replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void;
  20207. /**
  20208. * @private
  20209. */
  20210. getAllDragonBonesData(): Map<DragonBonesData>;
  20211. /**
  20212. * @private
  20213. */
  20214. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  20215. }
  20216. }
  20217. declare let jsb: any;
  20218. /** Running in the editor. */
  20219. declare let CC_EDITOR: boolean;
  20220. /** Preview in browser or simulator. */
  20221. declare let CC_PREVIEW: boolean;
  20222. /** Running in the editor or preview. */
  20223. declare let CC_DEV: boolean;
  20224. /** Running in the editor or preview, or build in debug mode. */
  20225. declare let CC_DEBUG: boolean;
  20226. /** Running in published project. */
  20227. declare let CC_BUILD: boolean;
  20228. /** Running in native platform (mobile app, desktop app, or simulator). */
  20229. declare let CC_JSB: boolean;
  20230. /** Running in the engine's unit test. */
  20231. declare let CC_TEST: boolean;
  20232. /** Running in the Wechat's mini game. */
  20233. declare let CC_WECHATGAME: boolean;
  20234. /** Running in the bricks. */
  20235. declare let CC_QQPLAY: boolean;