creator.d.ts 686 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635
  1. /** !#en
  2. The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
  3. !#zh
  4. Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */
  5. declare module cc {
  6. /** The current version of Cocos2d being used.<br/>
  7. Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
  8. If you post a bug to forum, please attach this flag. */
  9. export var ENGINE_VERSION: string;
  10. /** The element contains the game canvas */
  11. export var container: HTMLDivElement;
  12. /**
  13. !#en Init Debug setting.
  14. !#zh 设置调试模式。
  15. @param mode mode
  16. */
  17. export function _initDebugSetting(mode: DebugMode): void;
  18. /**
  19. !#en
  20. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  21. - In Cocos Creator, error is red.<br/>
  22. - In Chrome, error have a red icon along with red message text.<br/>
  23. !#zh
  24. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  25. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  26. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  27. @param msg A JavaScript string containing zero or more substitution strings.
  28. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  29. */
  30. export function error(msg: any, ...subst: any[]): void;
  31. /**
  32. !#en
  33. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  34. - In Cocos Creator, warning is yellow.
  35. - In Chrome, warning have a yellow warning icon with the message text.
  36. !#zh
  37. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  38. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  39. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  40. @param msg A JavaScript string containing zero or more substitution strings.
  41. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  42. */
  43. export function warn(msg: any, ...subst: any[]): void;
  44. /**
  45. !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  46. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  47. @param msg A JavaScript string containing zero or more substitution strings.
  48. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  49. */
  50. export function log(msg: string|any, ...subst: any[]): void;
  51. /**
  52. !#en
  53. Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
  54. - In Cocos Creator, info is blue.
  55. - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
  56. !#zh
  57. 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  58. - 在 Cocos Creator 中,Info 信息显示是蓝色的。<br/>
  59. - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。
  60. @param msg A JavaScript string containing zero or more substitution strings.
  61. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  62. */
  63. export function info(msg: any, ...subst: any[]): void;
  64. /**
  65. !#en
  66. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  67. or less (speed < 1) time. <br/>
  68. Useful to simulate 'slow motion' or 'fast forward' effect.
  69. !#zh 修改目标动作的速率。
  70. @param action action
  71. @param speed speed
  72. @example
  73. ```js
  74. // change the target action speed;
  75. var action = cc.scaleTo(0.2, 1, 0.6);
  76. var newAction = cc.speed(action, 0.5);
  77. ```
  78. */
  79. export function speed(action: ActionInterval, speed: number): Action;
  80. /**
  81. !#en Create a follow action which makes its target follows another node.
  82. !#zh 追踪目标节点的位置。
  83. @param followedNode followedNode
  84. @param rect rect
  85. @example
  86. ```js
  87. // example
  88. // creates the action with a set boundary
  89. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  90. node.runAction(followAction);
  91. // creates the action with no boundary set
  92. var followAction = cc.follow(targetNode);
  93. node.runAction(followAction);
  94. ```
  95. */
  96. export function follow(followedNode: Node, rect: Rect): Action;
  97. /**
  98. Points setter
  99. @param points points
  100. */
  101. export function setPoints(points: any[]): void;
  102. /**
  103. !#en Creates an action with a Cardinal Spline array of points and tension.
  104. !#zh 按基数样条曲线轨迹移动到目标位置。
  105. @param duration duration
  106. @param points array of control points
  107. @param tension tension
  108. @example
  109. ```js
  110. //create a cc.CardinalSplineTo
  111. var action1 = cc.cardinalSplineTo(3, array, 0);
  112. ```
  113. */
  114. export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
  115. /**
  116. update position of target
  117. @param newPos newPos
  118. */
  119. export function updatePosition(newPos: Vec2): void;
  120. /**
  121. !#en Creates an action with a Cardinal Spline array of points and tension.
  122. !#zh 按基数样条曲线轨迹移动指定的距离。
  123. @param duration duration
  124. @param points points
  125. @param tension tension
  126. */
  127. export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
  128. /**
  129. !#en Creates an action with a Cardinal Spline array of points and tension.
  130. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  131. @param dt dt
  132. @param points points
  133. @example
  134. ```js
  135. var action1 = cc.catmullRomTo(3, array);
  136. ```
  137. */
  138. export function catmullRomTo(dt: number, points: any[]): ActionInterval;
  139. /**
  140. !#en Creates an action with a Cardinal Spline array of points and tension.
  141. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  142. @param dt dt
  143. @param points points
  144. @example
  145. ```js
  146. var action1 = cc.catmullRomBy(3, array);
  147. ```
  148. */
  149. export function catmullRomBy(dt: number, points: any[]): ActionInterval;
  150. /**
  151. !#en
  152. Creates the action easing object with the rate parameter. <br />
  153. From slow to fast.
  154. !#zh 创建 easeIn 缓动对象,由慢到快。
  155. @param rate rate
  156. @example
  157. ```js
  158. action.easing(cc.easeIn(3.0));
  159. ```
  160. */
  161. export function easeIn(rate: number): any;
  162. /**
  163. !#en
  164. Creates the action easing object with the rate parameter. <br />
  165. From fast to slow.
  166. !#zh 创建 easeOut 缓动对象,由快到慢。
  167. @param rate rate
  168. @example
  169. ```js
  170. action.easing(cc.easeOut(3.0));
  171. ```
  172. */
  173. export function easeOut(rate: number): any;
  174. /**
  175. !#en
  176. Creates the action easing object with the rate parameter. <br />
  177. Slow to fast then to slow.
  178. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  179. @param rate rate
  180. @example
  181. ```js
  182. action.easing(cc.easeInOut(3.0));
  183. ```
  184. */
  185. export function easeInOut(rate: number): any;
  186. /**
  187. !#en
  188. Creates the action easing object with the rate parameter. <br />
  189. Reference easeInExpo: <br />
  190. http://www.zhihu.com/question/21981571/answer/19925418
  191. !#zh
  192. 创建 easeExponentialIn 缓动对象。<br />
  193. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  194. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  195. @example
  196. ```js
  197. action.easing(cc.easeExponentialIn());
  198. ```
  199. */
  200. export function easeExponentialIn(): any;
  201. /**
  202. !#en
  203. Creates the action easing object. <br />
  204. Reference easeOutExpo: <br />
  205. http://www.zhihu.com/question/21981571/answer/19925418
  206. !#zh
  207. 创建 easeExponentialOut 缓动对象。<br />
  208. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  209. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  210. @example
  211. ```js
  212. action.easing(cc.easeExponentialOut());
  213. ```
  214. */
  215. export function easeExponentialOut(): any;
  216. /**
  217. !#en
  218. Creates an EaseExponentialInOut action easing object. <br />
  219. Reference easeInOutExpo: <br />
  220. http://www.zhihu.com/question/21981571/answer/19925418
  221. !#zh
  222. 创建 easeExponentialInOut 缓动对象。<br />
  223. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  224. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  225. @example
  226. ```js
  227. action.easing(cc.easeExponentialInOut());
  228. ```
  229. */
  230. export function easeExponentialInOut(): any;
  231. /**
  232. !#en
  233. Creates an EaseSineIn action. <br />
  234. Reference easeInSine: <br />
  235. http://www.zhihu.com/question/21981571/answer/19925418
  236. !#zh
  237. 创建 EaseSineIn 缓动对象。<br />
  238. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  239. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  240. @example
  241. ```js
  242. action.easing(cc.easeSineIn());
  243. ```
  244. */
  245. export function easeSineIn(): any;
  246. /**
  247. !#en
  248. Creates an EaseSineOut action easing object. <br />
  249. Reference easeOutSine: <br />
  250. http://www.zhihu.com/question/21981571/answer/19925418
  251. !#zh
  252. 创建 EaseSineOut 缓动对象。<br />
  253. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  254. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  255. @example
  256. ```js
  257. action.easing(cc.easeSineOut());
  258. ```
  259. */
  260. export function easeSineOut(): any;
  261. /**
  262. !#en
  263. Creates the action easing object. <br />
  264. Reference easeInOutSine: <br />
  265. http://www.zhihu.com/question/21981571/answer/19925418
  266. !#zh
  267. 创建 easeSineInOut 缓动对象。<br />
  268. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  269. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  270. @example
  271. ```js
  272. action.easing(cc.easeSineInOut());
  273. ```
  274. */
  275. export function easeSineInOut(): any;
  276. /**
  277. !#en
  278. Creates the action easing obejct with the period in radians (default is 0.3). <br />
  279. Reference easeInElastic: <br />
  280. http://www.zhihu.com/question/21981571/answer/19925418
  281. !#zh
  282. 创建 easeElasticIn 缓动对象。<br />
  283. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  284. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  285. @param period period
  286. @example
  287. ```js
  288. // example
  289. action.easing(cc.easeElasticIn(3.0));
  290. ```
  291. */
  292. export function easeElasticIn(period: number): any;
  293. /**
  294. !#en
  295. Creates the action easing object with the period in radians (default is 0.3). <br />
  296. Reference easeOutElastic: <br />
  297. http://www.zhihu.com/question/21981571/answer/19925418
  298. !#zh
  299. 创建 easeElasticOut 缓动对象。<br />
  300. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  301. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  302. @param period period
  303. @example
  304. ```js
  305. // example
  306. action.easing(cc.easeElasticOut(3.0));
  307. ```
  308. */
  309. export function easeElasticOut(period: number): any;
  310. /**
  311. !#en
  312. Creates the action easing object with the period in radians (default is 0.3). <br />
  313. Reference easeInOutElastic: <br />
  314. http://www.zhihu.com/question/21981571/answer/19925418
  315. !#zh
  316. 创建 easeElasticInOut 缓动对象。<br />
  317. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  318. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  319. @param period period
  320. @example
  321. ```js
  322. // example
  323. action.easing(cc.easeElasticInOut(3.0));
  324. ```
  325. */
  326. export function easeElasticInOut(period: number): any;
  327. /**
  328. !#en
  329. Creates the action easing object. <br />
  330. Eased bounce effect at the beginning.
  331. !#zh
  332. 创建 easeBounceIn 缓动对象。<br />
  333. EaseBounceIn 是按弹跳动作缓动进入的动作。
  334. @example
  335. ```js
  336. // example
  337. action.easing(cc.easeBounceIn());
  338. ```
  339. */
  340. export function easeBounceIn(): any;
  341. /**
  342. !#en
  343. Creates the action easing object. <br />
  344. Eased bounce effect at the ending.
  345. !#zh
  346. 创建 easeBounceOut 缓动对象。<br />
  347. EaseBounceOut 是按弹跳动作缓动退出的动作。
  348. @example
  349. ```js
  350. // example
  351. action.easing(cc.easeBounceOut());
  352. ```
  353. */
  354. export function easeBounceOut(): any;
  355. /**
  356. !#en
  357. Creates the action easing object. <br />
  358. Eased bounce effect at the begining and ending.
  359. !#zh
  360. 创建 easeBounceInOut 缓动对象。<br />
  361. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  362. @example
  363. ```js
  364. // example
  365. action.easing(cc.easeBounceInOut());
  366. ```
  367. */
  368. export function easeBounceInOut(): any;
  369. /**
  370. !#en
  371. Creates the action easing object. <br />
  372. In the opposite direction to move slowly, and then accelerated to the right direction.
  373. !#zh
  374. 创建 easeBackIn 缓动对象。<br />
  375. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  376. @example
  377. ```js
  378. // example
  379. action.easing(cc.easeBackIn());
  380. ```
  381. */
  382. export function easeBackIn(): any;
  383. /**
  384. !#en
  385. Creates the action easing object. <br />
  386. Fast moving more than the finish, and then slowly back to the finish.
  387. !#zh
  388. 创建 easeBackOut 缓动对象。<br />
  389. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  390. @example
  391. ```js
  392. // example
  393. action.easing(cc.easeBackOut());
  394. ```
  395. */
  396. export function easeBackOut(): any;
  397. /**
  398. !#en
  399. Creates the action easing object. <br />
  400. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  401. !#zh
  402. 创建 easeBackInOut 缓动对象。<br />
  403. @example
  404. ```js
  405. // example
  406. action.easing(cc.easeBackInOut());
  407. ```
  408. */
  409. export function easeBackInOut(): any;
  410. /**
  411. !#en
  412. Creates the action easing object. <br />
  413. Into the 4 reference point. <br />
  414. To calculate the motion curve.
  415. !#zh
  416. 创建 easeBezierAction 缓动对象。<br />
  417. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  418. @param p0 The first bezier parameter
  419. @param p1 The second bezier parameter
  420. @param p2 The third bezier parameter
  421. @param p3 The fourth bezier parameter
  422. @example
  423. ```js
  424. // example
  425. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  426. ```
  427. */
  428. export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
  429. /**
  430. !#en
  431. Creates the action easing object. <br />
  432. Reference easeInQuad: <br />
  433. http://www.zhihu.com/question/21981571/answer/19925418
  434. !#zh
  435. 创建 easeQuadraticActionIn 缓动对象。<br />
  436. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  437. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  438. @example
  439. ```js
  440. //example
  441. action.easing(cc.easeQuadraticActionIn());
  442. ```
  443. */
  444. export function easeQuadraticActionIn(): any;
  445. /**
  446. !#en
  447. Creates the action easing object. <br />
  448. Reference easeOutQuad: <br />
  449. http://www.zhihu.com/question/21981571/answer/19925418
  450. !#zh
  451. 创建 easeQuadraticActionOut 缓动对象。<br />
  452. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  453. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  454. @example
  455. ```js
  456. //example
  457. action.easing(cc.easeQuadraticActionOut());
  458. ```
  459. */
  460. export function easeQuadraticActionOut(): any;
  461. /**
  462. !#en
  463. Creates the action easing object. <br />
  464. Reference easeInOutQuad: <br />
  465. http://www.zhihu.com/question/21981571/answer/19925418
  466. !#zh
  467. 创建 easeQuadraticActionInOut 缓动对象。<br />
  468. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  469. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  470. @example
  471. ```js
  472. //example
  473. action.easing(cc.easeQuadraticActionInOut());
  474. ```
  475. */
  476. export function easeQuadraticActionInOut(): any;
  477. /**
  478. !#en
  479. Creates the action easing object. <br />
  480. Reference easeIntQuart: <br />
  481. http://www.zhihu.com/question/21981571/answer/19925418
  482. !#zh
  483. 创建 easeQuarticActionIn 缓动对象。<br />
  484. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  485. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  486. @example
  487. ```js
  488. //example
  489. action.easing(cc.easeQuarticActionIn());
  490. ```
  491. */
  492. export function easeQuarticActionIn(): any;
  493. /**
  494. !#en
  495. Creates the action easing object. <br />
  496. Reference easeOutQuart: <br />
  497. http://www.zhihu.com/question/21981571/answer/19925418
  498. !#zh
  499. 创建 easeQuarticActionOut 缓动对象。<br />
  500. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  501. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  502. @example
  503. ```js
  504. //example
  505. action.easing(cc.QuarticActionOut());
  506. ```
  507. */
  508. export function easeQuarticActionOut(): any;
  509. /**
  510. !#en
  511. Creates the action easing object. <br />
  512. Reference easeInOutQuart: <br />
  513. http://www.zhihu.com/question/21981571/answer/19925418
  514. !#zh
  515. 创建 easeQuarticActionInOut 缓动对象。<br />
  516. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  517. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  518. */
  519. export function easeQuarticActionInOut(): any;
  520. /**
  521. !#en
  522. Creates the action easing object. <br />
  523. Reference easeInQuint: <br />
  524. http://www.zhihu.com/question/21981571/answer/19925418
  525. !#zh
  526. 创建 easeQuinticActionIn 缓动对象。<br />
  527. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  528. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  529. @example
  530. ```js
  531. //example
  532. action.easing(cc.easeQuinticActionIn());
  533. ```
  534. */
  535. export function easeQuinticActionIn(): any;
  536. /**
  537. !#en
  538. Creates the action easing object. <br />
  539. Reference easeOutQuint: <br />
  540. http://www.zhihu.com/question/21981571/answer/19925418
  541. !#zh
  542. 创建 easeQuinticActionOut 缓动对象。<br />
  543. EaseQuinticOut 是按五次函数缓动退出的动作
  544. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  545. @example
  546. ```js
  547. //example
  548. action.easing(cc.easeQuadraticActionOut());
  549. ```
  550. */
  551. export function easeQuinticActionOut(): any;
  552. /**
  553. !#en
  554. Creates the action easing object. <br />
  555. Reference easeInOutQuint: <br />
  556. http://www.zhihu.com/question/21981571/answer/19925418
  557. !#zh
  558. 创建 easeQuinticActionInOut 缓动对象。<br />
  559. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  560. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  561. @example
  562. ```js
  563. //example
  564. action.easing(cc.easeQuinticActionInOut());
  565. ```
  566. */
  567. export function easeQuinticActionInOut(): any;
  568. /**
  569. !#en
  570. Creates the action easing object. <br />
  571. Reference easeInCirc: <br />
  572. http://www.zhihu.com/question/21981571/answer/19925418
  573. !#zh
  574. 创建 easeCircleActionIn 缓动对象。<br />
  575. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  576. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  577. @example
  578. ```js
  579. //example
  580. action.easing(cc.easeCircleActionIn());
  581. ```
  582. */
  583. export function easeCircleActionIn(): any;
  584. /**
  585. !#en
  586. Creates the action easing object. <br />
  587. Reference easeOutCirc: <br />
  588. http://www.zhihu.com/question/21981571/answer/19925418
  589. !#zh
  590. 创建 easeCircleActionOut 缓动对象。<br />
  591. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  592. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  593. */
  594. export function easeCircleActionOut(): any;
  595. /**
  596. !#en
  597. Creates the action easing object. <br />
  598. Reference easeInOutCirc: <br />
  599. http://www.zhihu.com/question/21981571/answer/19925418
  600. !#zh
  601. 创建 easeCircleActionInOut 缓动对象。<br />
  602. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  603. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  604. @example
  605. ```js
  606. //example
  607. action.easing(cc.easeCircleActionInOut());
  608. ```
  609. */
  610. export function easeCircleActionInOut(): any;
  611. /**
  612. !#en
  613. Creates the action easing object. <br />
  614. Reference easeInCubic: <br />
  615. http://www.zhihu.com/question/21981571/answer/19925418
  616. !#zh
  617. 创建 easeCubicActionIn 缓动对象。<br />
  618. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  619. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  620. @example
  621. ```js
  622. //example
  623. action.easing(cc.easeCubicActionIn());
  624. ```
  625. */
  626. export function easeCubicActionIn(): any;
  627. /**
  628. !#en
  629. Creates the action easing object. <br />
  630. Reference easeOutCubic: <br />
  631. http://www.zhihu.com/question/21981571/answer/19925418
  632. !#zh
  633. 创建 easeCubicActionOut 缓动对象。<br />
  634. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  635. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  636. @example
  637. ```js
  638. //example
  639. action.easing(cc.easeCubicActionOut());
  640. ```
  641. */
  642. export function easeCubicActionOut(): any;
  643. /**
  644. !#en
  645. Creates the action easing object. <br />
  646. Reference easeInOutCubic: <br />
  647. http://www.zhihu.com/question/21981571/answer/19925418
  648. !#zh
  649. 创建 easeCubicActionInOut 缓动对象。<br />
  650. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  651. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  652. */
  653. export function easeCubicActionInOut(): any;
  654. /**
  655. !#en Show the Node.
  656. !#zh 立即显示。
  657. @example
  658. ```js
  659. // example
  660. var showAction = cc.show();
  661. ```
  662. */
  663. export function show(): ActionInstant;
  664. /**
  665. !#en Hide the node.
  666. !#zh 立即隐藏。
  667. @example
  668. ```js
  669. // example
  670. var hideAction = cc.hide();
  671. ```
  672. */
  673. export function hide(): ActionInstant;
  674. /**
  675. !#en Toggles the visibility of a node.
  676. !#zh 显隐状态切换。
  677. @example
  678. ```js
  679. // example
  680. var toggleVisibilityAction = cc.toggleVisibility();
  681. ```
  682. */
  683. export function toggleVisibility(): ActionInstant;
  684. /**
  685. !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  686. !#zh 从父节点移除自身。
  687. @param isNeedCleanUp isNeedCleanUp
  688. @example
  689. ```js
  690. // example
  691. var removeSelfAction = cc.removeSelf();
  692. ```
  693. */
  694. export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
  695. /**
  696. !#en Create a FlipX action to flip or unflip the target.
  697. !#zh X轴翻转。
  698. @param flip Indicate whether the target should be flipped or not
  699. @example
  700. ```js
  701. var flipXAction = cc.flipX(true);
  702. ```
  703. */
  704. export function flipX(flip: boolean): ActionInstant;
  705. /**
  706. !#en Create a FlipY action to flip or unflip the target.
  707. !#zh Y轴翻转。
  708. @param flip flip
  709. @example
  710. ```js
  711. var flipYAction = cc.flipY(true);
  712. ```
  713. */
  714. export function flipY(flip: boolean): ActionInstant;
  715. /**
  716. !#en Creates a Place action with a position.
  717. !#zh 放置在目标位置。
  718. @param pos pos
  719. @param y y
  720. @example
  721. ```js
  722. // example
  723. var placeAction = cc.place(cc.p(200, 200));
  724. var placeAction = cc.place(200, 200);
  725. ```
  726. */
  727. export function place(pos: Vec2|number, y?: number): ActionInstant;
  728. /**
  729. !#en Creates the action with the callback.
  730. !#zh 执行回调函数。
  731. @param selector selector
  732. @param selectorTarget selectorTarget
  733. @param data data for function, it accepts all data types.
  734. @example
  735. ```js
  736. // example
  737. // CallFunc without data
  738. var finish = cc.callFunc(this.removeSprite, this);
  739. // CallFunc with data
  740. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  741. ```
  742. */
  743. export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
  744. /**
  745. !#en
  746. Helper constructor to create an array of sequenceable actions
  747. The created action will run actions sequentially, one after another.
  748. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  749. @param actionOrActionArray actionOrActionArray
  750. @param tempArray tempArray
  751. @example
  752. ```js
  753. // example
  754. // create sequence with actions
  755. var seq = cc.sequence(act1, act2);
  756. // create sequence with array
  757. var seq = cc.sequence(actArray);
  758. ```
  759. */
  760. export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
  761. /**
  762. !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  763. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  764. @param action action
  765. @param times times
  766. @example
  767. ```js
  768. // example
  769. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  770. ```
  771. */
  772. export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
  773. /**
  774. !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
  775. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
  776. @param action action
  777. @example
  778. ```js
  779. // example
  780. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  781. ```
  782. */
  783. export function repeatForever(action: FiniteTimeAction): ActionInterval;
  784. /**
  785. !#en Create a spawn action which runs several actions in parallel.
  786. !#zh 同步执行动作,同步执行一组动作。
  787. @param actionOrActionArray actionOrActionArray
  788. @param tempArray tempArray
  789. @example
  790. ```js
  791. // example
  792. var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
  793. todo:It should be the direct use new
  794. ```
  795. */
  796. export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
  797. /**
  798. !#en
  799. Rotates a Node object to a certain angle by modifying its rotation property. <br/>
  800. The direction will be decided by the shortest angle.
  801. !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
  802. @param duration duration in seconds
  803. @param deltaAngleX deltaAngleX in degrees.
  804. @param deltaAngleY deltaAngleY in degrees.
  805. @example
  806. ```js
  807. // example
  808. var rotateTo = cc.rotateTo(2, 61.0);
  809. ```
  810. */
  811. export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  812. /**
  813. !#en
  814. Rotates a Node object clockwise a number of degrees by modifying its rotation property.
  815. Relative to its properties to modify.
  816. !#zh 旋转指定的角度。
  817. @param duration duration in seconds
  818. @param deltaAngleX deltaAngleX in degrees
  819. @param deltaAngleY deltaAngleY in degrees
  820. @example
  821. ```js
  822. // example
  823. var actionBy = cc.rotateBy(2, 360);
  824. ```
  825. */
  826. export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  827. /**
  828. !#en
  829. Moves a Node object x,y pixels by modifying its position property. <br/>
  830. x and y are relative to the position of the object. <br/>
  831. Several MoveBy actions can be concurrently called, and the resulting <br/>
  832. movement will be the sum of individual movements.
  833. !#zh 移动指定的距离。
  834. @param duration duration in seconds
  835. @param deltaPos deltaPos
  836. @param deltaY deltaY
  837. @example
  838. ```js
  839. // example
  840. var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
  841. ```
  842. */
  843. export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
  844. /**
  845. !#en
  846. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  847. Several MoveTo actions can be concurrently called, and the resulting <br/>
  848. movement will be the sum of individual movements.
  849. !#zh 移动到目标位置。
  850. @param duration duration in seconds
  851. @param position position
  852. @param y y
  853. @example
  854. ```js
  855. // example
  856. var actionBy = cc.moveTo(2, cc.p(80, 80));
  857. ```
  858. */
  859. export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
  860. /**
  861. !#en
  862. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  863. Changes to the specified value.
  864. !#zh 偏斜到目标角度。
  865. @param t time in seconds
  866. @param sx sx
  867. @param sy sy
  868. @example
  869. ```js
  870. // example
  871. var actionTo = cc.skewTo(2, 37.2, -37.2);
  872. ```
  873. */
  874. export function skewTo(t: number, sx: number, sy: number): ActionInterval;
  875. /**
  876. !#en
  877. Skews a Node object by skewX and skewY degrees. <br />
  878. Relative to its property modification.
  879. !#zh 偏斜指定的角度。
  880. @param t time in seconds
  881. @param sx sx skew in degrees for X axis
  882. @param sy sy skew in degrees for Y axis
  883. @example
  884. ```js
  885. // example
  886. var actionBy = cc.skewBy(2, 0, -90);
  887. ```
  888. */
  889. export function skewBy(t: number, sx: number, sy: number): ActionInterval;
  890. /**
  891. !#en
  892. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  893. Relative to its movement.
  894. !#zh 用跳跃的方式移动指定的距离。
  895. @param duration duration
  896. @param position position
  897. @param y y
  898. @param height height
  899. @param jumps jumps
  900. @example
  901. ```js
  902. // example
  903. var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
  904. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  905. ```
  906. */
  907. export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  908. /**
  909. !#en
  910. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  911. Jump to the specified location.
  912. !#zh 用跳跃的方式移动到目标位置。
  913. @param duration duration
  914. @param position position
  915. @param y y
  916. @param height height
  917. @param jumps jumps
  918. @example
  919. ```js
  920. // example
  921. var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
  922. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  923. ```
  924. */
  925. export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  926. /**
  927. !#en
  928. An action that moves the target with a cubic Bezier curve by a certain distance.
  929. Relative to its movement.
  930. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  931. @param t time in seconds
  932. @param c Array of points
  933. @example
  934. ```js
  935. // example
  936. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  937. var bezierForward = cc.bezierBy(3, bezier);
  938. ```
  939. */
  940. export function bezierBy(t: number, c: Vec2[]): ActionInterval;
  941. /**
  942. !#en An action that moves the target with a cubic Bezier curve to a destination point.
  943. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  944. @param t t
  945. @param c Array of points
  946. @example
  947. ```js
  948. // example
  949. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  950. var bezierTo = cc.bezierTo(2, bezier);
  951. ```
  952. */
  953. export function bezierTo(t: number, c: Vec2[]): ActionInterval;
  954. /**
  955. !#en Scales a Node object to a zoom factor by modifying it's scale property.
  956. !#zh 将节点大小缩放到指定的倍数。
  957. @param duration duration
  958. @param sx scale parameter in X
  959. @param sy scale parameter in Y, if Null equal to sx
  960. @example
  961. ```js
  962. // example
  963. // It scales to 0.5 in both X and Y.
  964. var actionTo = cc.scaleTo(2, 0.5);
  965. // It scales to 0.5 in x and 2 in Y
  966. var actionTo = cc.scaleTo(2, 0.5, 2);
  967. ```
  968. */
  969. export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
  970. /**
  971. !#en
  972. Scales a Node object a zoom factor by modifying it's scale property.
  973. Relative to its changes.
  974. !#zh 按指定的倍数缩放节点大小。
  975. @param duration duration in seconds
  976. @param sx sx scale parameter in X
  977. @param sy sy scale parameter in Y, if Null equal to sx
  978. @example
  979. ```js
  980. // example without sy, it scales by 2 both in X and Y
  981. var actionBy = cc.scaleBy(2, 2);
  982. //example with sy, it scales by 0.25 in X and 4.5 in Y
  983. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  984. ```
  985. */
  986. export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
  987. /**
  988. !#en Blinks a Node object by modifying it's visible property.
  989. !#zh 闪烁(基于透明度)。
  990. @param duration duration in seconds
  991. @param blinks blinks in times
  992. @example
  993. ```js
  994. // example
  995. var action = cc.blink(2, 10);
  996. ```
  997. */
  998. export function blink(duration: number, blinks: number): ActionInterval;
  999. /**
  1000. !#en
  1001. Fades an object that implements the cc.RGBAProtocol protocol.
  1002. It modifies the opacity from the current value to a custom one.
  1003. !#zh 修改透明度到指定值。
  1004. @param duration duration
  1005. @param opacity 0-255, 0 is transparent
  1006. @example
  1007. ```js
  1008. // example
  1009. var action = cc.fadeTo(1.0, 0);
  1010. ```
  1011. */
  1012. export function fadeTo(duration: number, opacity: number): ActionInterval;
  1013. /**
  1014. !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  1015. !#zh 渐显效果。
  1016. @param duration duration in seconds
  1017. @example
  1018. ```js
  1019. //example
  1020. var action = cc.fadeIn(1.0);
  1021. ```
  1022. */
  1023. export function fadeIn(duration: number): ActionInterval;
  1024. /**
  1025. !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  1026. !#zh 渐隐效果。
  1027. @param d duration in seconds
  1028. @example
  1029. ```js
  1030. // example
  1031. var action = cc.fadeOut(1.0);
  1032. ```
  1033. */
  1034. export function fadeOut(d: number): ActionInterval;
  1035. /**
  1036. !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1037. !#zh 修改颜色到指定值。
  1038. @param duration duration
  1039. @param red 0-255
  1040. @param green 0-255
  1041. @param blue 0-255
  1042. @example
  1043. ```js
  1044. // example
  1045. var action = cc.tintTo(2, 255, 0, 255);
  1046. ```
  1047. */
  1048. export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
  1049. /**
  1050. !#en
  1051. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1052. Relative to their own color change.
  1053. !#zh 按照指定的增量修改颜色。
  1054. @param duration duration in seconds
  1055. @param deltaRed deltaRed
  1056. @param deltaGreen deltaGreen
  1057. @param deltaBlue deltaBlue
  1058. @example
  1059. ```js
  1060. // example
  1061. var action = cc.tintBy(2, -127, -255, -127);
  1062. ```
  1063. */
  1064. export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
  1065. /**
  1066. !#en Delays the action a certain amount of seconds.
  1067. !#en 延迟指定的时间量。
  1068. @param d duration in seconds
  1069. @example
  1070. ```js
  1071. // example
  1072. var delay = cc.delayTime(1);
  1073. ```
  1074. */
  1075. export function delayTime(d: number): ActionInterval;
  1076. /**
  1077. !#en Executes an action in reverse order, from time=duration to time=0.
  1078. !#zh 反转目标动作的时间轴。
  1079. @param action action
  1080. @example
  1081. ```js
  1082. // example
  1083. var reverse = cc.reverseTime(this);
  1084. ```
  1085. */
  1086. export function reverseTime(action: FiniteTimeAction): ActionInterval;
  1087. /**
  1088. !#en Create an action with the specified action and forced target.
  1089. !#zh 用已有动作和一个新的目标节点创建动作。
  1090. @param target target
  1091. @param action action
  1092. */
  1093. export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
  1094. /** !#en cc.view is the shared view object.
  1095. !#zh cc.view 是全局的视图对象。 */
  1096. export var view: View;
  1097. /** !#en Director
  1098. !#zh 导演类。 */
  1099. export var director: Director;
  1100. /** !#en cc.winSize is the alias object for the size of the current game window.
  1101. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  1102. export var winSize: Size;
  1103. export var game: Game;
  1104. /** !#en The System event singleton for global usage
  1105. !#zh 系统事件单例,方便全局使用 */
  1106. export var systemEvent: SystemEvent;
  1107. /**
  1108. @param touches touches
  1109. */
  1110. export function handleTouchesBegin(touches: any[]): void;
  1111. /**
  1112. @param touches touches
  1113. */
  1114. export function handleTouchesMove(touches: any[]): void;
  1115. /**
  1116. @param touches touches
  1117. */
  1118. export function handleTouchesEnd(touches: any[]): void;
  1119. /**
  1120. @param touches touches
  1121. */
  1122. export function handleTouchesCancel(touches: any[]): void;
  1123. /**
  1124. @param touches touches
  1125. */
  1126. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1127. /**
  1128. @param element element
  1129. */
  1130. export function getHTMLElementPosition(element: HTMLElement): any;
  1131. /**
  1132. @param touch touch
  1133. */
  1134. export function getPreTouch(touch: Touch): Touch;
  1135. /**
  1136. @param touch touch
  1137. */
  1138. export function setPreTouch(touch: Touch): void;
  1139. /**
  1140. @param tx tx
  1141. @param ty ty
  1142. @param pos pos
  1143. */
  1144. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1145. /**
  1146. @param event event
  1147. @param pos pos
  1148. */
  1149. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1150. /**
  1151. @param event event
  1152. @param pos pos
  1153. */
  1154. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1155. /**
  1156. @param element element
  1157. */
  1158. export function registerSystemEvent(element: HTMLElement): void;
  1159. /**
  1160. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1161. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1162. @param options options
  1163. @example
  1164. ```js
  1165. // define base class
  1166. var Node = cc.Class();
  1167. // define sub class
  1168. var Sprite = cc.Class({
  1169. name: 'Sprite',
  1170. extends: Node,
  1171. ctor: function () {
  1172. this.url = "";
  1173. this.id = 0;
  1174. },
  1175. statics: {
  1176. // define static members
  1177. count: 0,
  1178. getBounds: function (spriteList) {
  1179. // compute bounds...
  1180. }
  1181. },
  1182. properties {
  1183. width: {
  1184. default: 128,
  1185. type: 'Integer',
  1186. tooltip: 'The width of sprite'
  1187. },
  1188. height: 128,
  1189. size: {
  1190. get: function () {
  1191. return cc.v2(this.width, this.height);
  1192. }
  1193. }
  1194. },
  1195. load: function () {
  1196. // load this.url...
  1197. };
  1198. });
  1199. // instantiate
  1200. var obj = new Sprite();
  1201. obj.url = 'sprite.png';
  1202. obj.load();
  1203. ```
  1204. */
  1205. export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function;
  1206. /**
  1207. Checks whether subclass is child of superclass or equals to superclass
  1208. @param subclass subclass
  1209. @param superclass superclass
  1210. */
  1211. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  1212. /**
  1213. Return all super classes
  1214. @param constructor constructor
  1215. */
  1216. export function getInheritanceChain(constructor: Function): Function[];
  1217. /**
  1218. !#en
  1219. Define an enum type. <br/>
  1220. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.<br/>
  1221. Otherwise it will use the value specified by user who writes the enum definition.
  1222. !#zh
  1223. 定义一个枚举类型。<br/>
  1224. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1225. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1226. @example
  1227. ```js
  1228. // JavaScript:
  1229. var WrapMode = cc.Enum({
  1230. Repeat: -1,
  1231. Clamp: -1
  1232. });
  1233. // Texture.WrapMode.Repeat == 0
  1234. // Texture.WrapMode.Clamp == 1
  1235. // Texture.WrapMode[0] == "Repeat"
  1236. // Texture.WrapMode[1] == "Clamp"
  1237. var FlagType = cc.Enum({
  1238. Flag1: 1,
  1239. Flag2: 2,
  1240. Flag3: 4,
  1241. Flag4: 8,
  1242. });
  1243. var AtlasSizeList = cc.Enum({
  1244. 128: 128,
  1245. 256: 256,
  1246. 512: 512,
  1247. 1024: 1024,
  1248. });
  1249. // TypeScript:
  1250. // If used in TypeScript, just define a TypeScript enum:
  1251. enum Direction {
  1252. Up,
  1253. Down,
  1254. Left,
  1255. Right
  1256. }
  1257. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1258. const {ccclass, property} = cc._decorator;
  1259. @ccclass
  1260. class NewScript extends cc.Component {
  1261. @property({
  1262. default: Direction.Up,
  1263. type: cc.Enum(Direction) // call cc.Enum
  1264. })
  1265. direction: Direction = Direction.Up;
  1266. }
  1267. ```
  1268. */
  1269. export function Enum<T>(obj: T): T;
  1270. /**
  1271. whether enable accelerometer event
  1272. @param isEnable isEnable
  1273. */
  1274. export function setAccelerometerEnabled(isEnable: boolean): void;
  1275. /**
  1276. set accelerometer interval value
  1277. @param interval interval
  1278. */
  1279. export function setAccelerometerInterval(interval: number): void;
  1280. /**
  1281. @param touches touches
  1282. */
  1283. export function handleTouchesBegin(touches: any[]): void;
  1284. /**
  1285. @param touches touches
  1286. */
  1287. export function handleTouchesMove(touches: any[]): void;
  1288. /**
  1289. @param touches touches
  1290. */
  1291. export function handleTouchesEnd(touches: any[]): void;
  1292. /**
  1293. @param touches touches
  1294. */
  1295. export function handleTouchesCancel(touches: any[]): void;
  1296. /**
  1297. @param touches touches
  1298. */
  1299. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1300. /**
  1301. @param element element
  1302. */
  1303. export function getHTMLElementPosition(element: HTMLElement): any;
  1304. /**
  1305. @param touch touch
  1306. */
  1307. export function getPreTouch(touch: Touch): Touch;
  1308. /**
  1309. @param touch touch
  1310. */
  1311. export function setPreTouch(touch: Touch): void;
  1312. /**
  1313. @param tx tx
  1314. @param ty ty
  1315. @param pos pos
  1316. */
  1317. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1318. /**
  1319. @param location location
  1320. @param pos pos
  1321. @param eventType eventType
  1322. */
  1323. export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1324. /**
  1325. @param event event
  1326. @param pos pos
  1327. */
  1328. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1329. /**
  1330. @param event event
  1331. @param pos pos
  1332. */
  1333. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1334. /**
  1335. @param element element
  1336. */
  1337. export function registerSystemEvent(element: HTMLElement): void;
  1338. /**
  1339. @param dt dt
  1340. */
  1341. export function update(dt: number): void;
  1342. /**
  1343. <p>
  1344. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  1345. </p>
  1346. @param a number A
  1347. @param b number B
  1348. @param r ratio between 0 and 1
  1349. @example
  1350. ```js
  1351. ----
  1352. lerp
  1353. cc.lerp(2,10,0.5)//returns 6
  1354. cc.lerp(2,10,0.2)//returns 3.6
  1355. ```
  1356. */
  1357. export function lerp(a: number, b: number, r: number): void;
  1358. /**
  1359. get a random number from 0 to 0xffffff
  1360. */
  1361. export function rand(): number;
  1362. /**
  1363. returns a random float between -1 and 1
  1364. */
  1365. export function randomMinus1To1(): number;
  1366. /**
  1367. returns a random float between 0 and 1, use Math.random directly
  1368. */
  1369. export function random0To1(): number;
  1370. /**
  1371. converts degrees to radians
  1372. @param angle angle
  1373. */
  1374. export function degreesToRadians(angle: number): number;
  1375. /**
  1376. converts radians to degrees
  1377. @param angle angle
  1378. */
  1379. export function radiansToDegrees(angle: number): number;
  1380. /**
  1381. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
  1382. @param node setup node
  1383. */
  1384. export function nodeDrawSetup(node: Node): void;
  1385. /**
  1386. <p>
  1387. Increments the GL Draws counts by one.<br/>
  1388. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.<br/>
  1389. </p>
  1390. @param addNumber addNumber
  1391. */
  1392. export function incrementGLDraws(addNumber: number): void;
  1393. /**
  1394. Check webgl error.Error will be shown in console if exists.
  1395. */
  1396. export function checkGLErrorDebug(): void;
  1397. /**
  1398. !#en
  1399. Checks whether the object is non-nil and not yet destroyed.<br>
  1400. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  1401. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  1402. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  1403. but this is often caused by a particular logical requirements, which is not normally required.
  1404. !#zh
  1405. 检查该对象是否不为 null 并且尚未销毁。<br>
  1406. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
  1407. @param value value
  1408. @param strictMode If true, Object called destroy() in this frame will also treated as invalid.
  1409. @example
  1410. ```js
  1411. var node = new cc.Node();
  1412. cc.log(cc.isValid(node)); // true
  1413. node.destroy();
  1414. cc.log(cc.isValid(node)); // true, still valid in this frame
  1415. // after a frame...
  1416. cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
  1417. ```
  1418. */
  1419. export function isValid(value: any, strictMode?: boolean): boolean;
  1420. /** Specify that the input value must be integer in Inspector.
  1421. Also used to indicates that the elements in array should be type integer. */
  1422. export var Integer: string;
  1423. /** Indicates that the elements in array should be type double. */
  1424. export var Float: string;
  1425. /** Indicates that the elements in array should be type boolean. */
  1426. export var Boolean: string;
  1427. /** Indicates that the elements in array should be type string. */
  1428. export var String: string;
  1429. /**
  1430. !#en Deserialize json to cc.Asset
  1431. !#zh 将 JSON 反序列化为对象实例。
  1432. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1433. 也不会将 uuid 保存到 result 对象中。
  1434. @param data the serialized cc.Asset json string or json object.
  1435. @param details additional loading result
  1436. @param options options
  1437. */
  1438. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1439. /**
  1440. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1441. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1442. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1443. @param original An existing object that you want to make a copy of.
  1444. @example
  1445. ```js
  1446. // instantiate node from prefab
  1447. var scene = cc.director.getScene();
  1448. var node = cc.instantiate(prefabAsset);
  1449. node.parent = scene;
  1450. // clone node
  1451. var scene = cc.director.getScene();
  1452. var node = cc.instantiate(targetNode);
  1453. node.parent = scene;
  1454. ```
  1455. */
  1456. export function instantiate(original: Prefab): Node;
  1457. export function instantiate<T>(original: T): T;
  1458. /**
  1459. Finds a node by hierarchy path, the path is case-sensitive.
  1460. It will traverse the hierarchy by splitting the path using '/' character.
  1461. This function will still returns the node even if it is inactive.
  1462. It is recommended to not use this function every frame instead cache the result at startup.
  1463. @param path path
  1464. @param referenceNode referenceNode
  1465. */
  1466. export function find(path: string, referenceNode?: Node): Node;
  1467. /**
  1468. !#en
  1469. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1470. Alpha channel is optional. Default value is 255.
  1471. !#zh
  1472. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1473. Alpha 通道是可选的。默认值是 255。
  1474. @param r r
  1475. @param g g
  1476. @param b b
  1477. @param a a
  1478. @example
  1479. ```js
  1480. -----------------------
  1481. // 1. All channels seperately as parameters
  1482. var color1 = new cc.Color(255, 255, 255, 255);
  1483. // 2. Convert a hex string to a color
  1484. var color2 = new cc.Color("#000000");
  1485. // 3. An color object as parameter
  1486. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1487. ```
  1488. */
  1489. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1490. /**
  1491. !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1492. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1493. @param color1 color1
  1494. @param color2 color2
  1495. @example
  1496. ```js
  1497. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1498. ```
  1499. */
  1500. export function colorEqual(color1: Color, color2: Color): boolean;
  1501. /**
  1502. !#en
  1503. convert a string of color for style to Color.
  1504. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1505. !#zh 16 进制转换为 Color
  1506. @param hex hex
  1507. @example
  1508. ```js
  1509. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1510. ```
  1511. */
  1512. export function hexToColor(hex: string): Color;
  1513. /**
  1514. !#en
  1515. convert Color to a string of color for style.
  1516. e.g. cc.color(255,6,255) to : "#ff06ff"
  1517. !#zh Color 转换为 16进制。
  1518. @param color color
  1519. @example
  1520. ```js
  1521. var color = new cc.Color(255, 6, 255)
  1522. cc.colorToHex(color); // #ff06ff;
  1523. ```
  1524. */
  1525. export function colorToHex(color: Color): string;
  1526. /**
  1527. !#en Returns opposite of Vec2.
  1528. !#zh 返回相反的向量。
  1529. @param point point
  1530. @example
  1531. ```js
  1532. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1533. ```
  1534. */
  1535. export function pNeg(point: Vec2): Vec2;
  1536. /**
  1537. !#en Calculates sum of two points.
  1538. !#zh 返回两个向量的和。
  1539. @param v1 v1
  1540. @param v2 v2
  1541. @example
  1542. ```js
  1543. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1544. ```
  1545. */
  1546. export function pAdd(v1: Vec2, v2: Vec2): Vec2;
  1547. /**
  1548. !#en Calculates difference of two points.
  1549. !#zh 返回两个向量的差。
  1550. @param v1 v1
  1551. @param v2 v2
  1552. @example
  1553. ```js
  1554. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1555. ```
  1556. */
  1557. export function pSub(v1: Vec2, v2: Vec2): Vec2;
  1558. /**
  1559. !#en Returns point multiplied by given factor.
  1560. !#zh 向量缩放。
  1561. @param point point
  1562. @param floatVar floatVar
  1563. @example
  1564. ```js
  1565. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1566. ```
  1567. */
  1568. export function pMult(point: Vec2, floatVar: number): Vec2;
  1569. /**
  1570. !#en Calculates midpoint between two points.
  1571. !#zh 两个向量之间的中心点。
  1572. @param v1 v1
  1573. @param v2 v2
  1574. @example
  1575. ```js
  1576. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1577. ```
  1578. */
  1579. export function pMidpoint(v1: Vec2, v2: Vec2): Vec2;
  1580. /**
  1581. !#en Calculates dot product of two points.
  1582. !#zh 两个向量之间进行点乘。
  1583. @param v1 v1
  1584. @param v2 v2
  1585. @example
  1586. ```js
  1587. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1588. ```
  1589. */
  1590. export function pDot(v1: Vec2, v2: Vec2): number;
  1591. /**
  1592. !#en Calculates cross product of two points.
  1593. !#zh 两个向量之间进行叉乘。
  1594. @param v1 v1
  1595. @param v2 v2
  1596. @example
  1597. ```js
  1598. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1599. ```
  1600. */
  1601. export function pCross(v1: Vec2, v2: Vec2): number;
  1602. /**
  1603. !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1604. !#zh 返回逆时针旋转 90 度后的新向量。
  1605. @param point point
  1606. @example
  1607. ```js
  1608. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1609. ```
  1610. */
  1611. export function pPerp(point: Vec2): Vec2;
  1612. /**
  1613. !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1614. !#zh 将指定向量顺时针旋转 90 度并返回。
  1615. @param point point
  1616. @example
  1617. ```js
  1618. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1619. ```
  1620. */
  1621. export function pRPerp(point: Vec2): Vec2;
  1622. /**
  1623. !#en Calculates the projection of v1 over v2.
  1624. !#zh 返回 v1 在 v2 上的投影向量。
  1625. @param v1 v1
  1626. @param v2 v2
  1627. @example
  1628. ```js
  1629. var v1 = cc.v2(20, 20);
  1630. var v2 = cc.v2(5, 5);
  1631. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1632. ```
  1633. */
  1634. export function pProject(v1: Vec2, v2: Vec2): Vec2;
  1635. /**
  1636. !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1637. !#zh 返回指定向量长度的平方。
  1638. @param v v
  1639. @example
  1640. ```js
  1641. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1642. ```
  1643. */
  1644. export function pLengthSQ(v: Vec2): number;
  1645. /**
  1646. !#en Calculates the square distance between two points (not calling sqrt() ).
  1647. !#zh 返回两个点之间距离的平方。
  1648. @param point1 point1
  1649. @param point2 point2
  1650. @example
  1651. ```js
  1652. var point1 = cc.v2(20, 20);
  1653. var point2 = cc.v2(5, 5);
  1654. cc.pDistanceSQ(point1, point2); // 450;
  1655. ```
  1656. */
  1657. export function pDistanceSQ(point1: Vec2, point2: Vec2): number;
  1658. /**
  1659. !#en Calculates distance between point an origin.
  1660. !#zh 返回指定向量的长度.
  1661. @param v v
  1662. @example
  1663. ```js
  1664. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1665. ```
  1666. */
  1667. export function pLength(v: Vec2): number;
  1668. /**
  1669. !#en Calculates the distance between two points.
  1670. !#zh 返回指定 2 个向量之间的距离。
  1671. @param v1 v1
  1672. @param v2 v2
  1673. @example
  1674. ```js
  1675. var v1 = cc.v2(20, 20);
  1676. var v2 = cc.v2(5, 5);
  1677. cc.pDistance(v1, v2); // 21.213203435596427;
  1678. ```
  1679. */
  1680. export function pDistance(v1: Vec2, v2: Vec2): number;
  1681. /**
  1682. !#en Returns this vector with a magnitude of 1.
  1683. !#zh 返回一个长度为 1 的标准化过后的向量。
  1684. @param v v
  1685. @example
  1686. ```js
  1687. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1688. ```
  1689. */
  1690. export function pNormalize(v: Vec2): Vec2;
  1691. /**
  1692. !#en Converts radians to a normalized vector.
  1693. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1694. @param a a
  1695. @example
  1696. ```js
  1697. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1698. ```
  1699. */
  1700. export function pForAngle(a: number): Vec2;
  1701. /**
  1702. !#en Converts a vector to radians.
  1703. !#zh 返回指定向量的弧度。
  1704. @param v v
  1705. @example
  1706. ```js
  1707. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1708. ```
  1709. */
  1710. export function pToAngle(v: Vec2): number;
  1711. /**
  1712. !#en Clamp a value between from and to.
  1713. !#zh
  1714. 限定浮点数的最大最小值。<br/>
  1715. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1716. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1717. 否则返回自身。
  1718. @param value value
  1719. @param min_inclusive min_inclusive
  1720. @param max_inclusive max_inclusive
  1721. @example
  1722. ```js
  1723. var v1 = cc.clampf(20, 0, 20); // 20;
  1724. var v2 = cc.clampf(-1, 0, 20); // 0;
  1725. var v3 = cc.clampf(10, 0, 20); // 10;
  1726. ```
  1727. */
  1728. export function clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  1729. /**
  1730. !#en Clamp a value between 0 and 1.
  1731. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1732. @param value value
  1733. @example
  1734. ```js
  1735. var v1 = cc.clampf(20); // 1;
  1736. var v2 = cc.clampf(-1); // 0;
  1737. var v3 = cc.clampf(0.5); // 0.5;
  1738. ```
  1739. */
  1740. export function clamp01(value: number): number;
  1741. /**
  1742. !#en Clamp a point between from and to.
  1743. !#zh
  1744. 返回指定限制区域后的向量。<br/>
  1745. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1746. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1747. 否则返回自身。
  1748. @param p p
  1749. @param min_inclusive min_inclusive
  1750. @param max_inclusive max_inclusive
  1751. @example
  1752. ```js
  1753. var min_inclusive = cc.v2(0, 0);
  1754. var max_inclusive = cc.v2(20, 20);
  1755. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1756. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1757. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1758. ```
  1759. */
  1760. export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  1761. /**
  1762. !#en Quickly convert cc.Size to a cc.Vec2.
  1763. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1764. @param s s
  1765. @example
  1766. ```js
  1767. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1768. ```
  1769. */
  1770. export function pFromSize(s: Size): Vec2;
  1771. /**
  1772. !#en
  1773. Run a math operation function on each point component <br />
  1774. Math.abs, Math.fllor, Math.ceil, Math.round.
  1775. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1776. @param p p
  1777. @param opFunc opFunc
  1778. @example
  1779. ```js
  1780. cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1781. ```
  1782. */
  1783. export function pCompOp(p: Vec2, opFunc: Function): Vec2;
  1784. /**
  1785. !#en
  1786. Linear Interpolation between two points a and b.<br />
  1787. alpha == 0 ? a <br />
  1788. alpha == 1 ? b <br />
  1789. otherwise a value between a..b.
  1790. !#zh
  1791. 两个点 A 和 B 之间的线性插值。 <br />
  1792. alpha == 0 ? a <br />
  1793. alpha == 1 ? b <br />
  1794. 否则这个数值在 a ~ b 之间。
  1795. @param a a
  1796. @param b b
  1797. @param alpha alpha
  1798. @example
  1799. ```js
  1800. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1801. ```
  1802. */
  1803. export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2;
  1804. /**
  1805. !#en TODO
  1806. !#zh
  1807. 近似判断两个点是否相等。<br/>
  1808. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1809. @param a a
  1810. @param b b
  1811. @param variance variance
  1812. @example
  1813. ```js
  1814. var a = cc.v2(20, 20);
  1815. var b = cc.v2(5, 5);
  1816. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1817. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1818. ```
  1819. */
  1820. export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean;
  1821. /**
  1822. !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1823. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1824. @param a a
  1825. @param b b
  1826. @example
  1827. ```js
  1828. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1829. ```
  1830. */
  1831. export function pCompMult(a: Vec2, b: Vec2): Vec2;
  1832. /**
  1833. !#en TODO
  1834. !#zh 返回两个向量之间带正负号的弧度。
  1835. @param a a
  1836. @param b b
  1837. */
  1838. export function pAngleSigned(a: Vec2, b: Vec2): number;
  1839. /**
  1840. !#en TODO
  1841. !#zh 获取当前向量与指定向量之间的弧度角。
  1842. @param a a
  1843. @param b b
  1844. */
  1845. export function pAngle(a: Vec2, b: Vec2): number;
  1846. /**
  1847. !#en Rotates a point counter clockwise by the angle around a pivot.
  1848. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1849. @param v v is the point to rotate
  1850. @param pivot pivot is the pivot, naturally
  1851. @param angle angle is the angle of rotation cw in radians
  1852. */
  1853. export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2;
  1854. /**
  1855. !#en
  1856. A general line-line intersection test
  1857. indicating successful intersection of a line<br />
  1858. note that to truly test intersection for segments we have to make<br />
  1859. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1860. the hit point is p3 + t * (p4 - p3);<br />
  1861. the hit point also is p1 + s * (p2 - p1);
  1862. !#zh
  1863. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1864. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1865. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1866. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1867. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1868. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1869. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1870. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1871. */
  1872. export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean;
  1873. /**
  1874. !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1875. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1876. @param A A
  1877. @param B B
  1878. @param C C
  1879. @param D D
  1880. */
  1881. export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean;
  1882. /**
  1883. !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1884. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1885. @param A A
  1886. @param B B
  1887. @param C C
  1888. @param D D
  1889. */
  1890. export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2;
  1891. /**
  1892. !#en check to see if both points are equal.
  1893. !#zh 检查指定的 2 个向量是否相等。
  1894. @param A A ccp a
  1895. @param B B ccp b to be compared
  1896. */
  1897. export function pSameAs(A: Vec2, B: Vec2): boolean;
  1898. /**
  1899. !#en sets the position of the point to 0.
  1900. !#zh 设置指定向量归 0。
  1901. @param v v
  1902. */
  1903. export function pZeroIn(v: Vec2): void;
  1904. /**
  1905. !#en copies the position of one point to another.
  1906. !#zh 令 v1 向量等同于 v2。
  1907. @param v1 v1
  1908. @param v2 v2
  1909. */
  1910. export function pIn(v1: Vec2, v2: Vec2): void;
  1911. /**
  1912. !#en multiplies the point with the given factor (inplace).
  1913. !#zh 向量缩放,结果保存到第一个向量。
  1914. @param point point
  1915. @param floatVar floatVar
  1916. */
  1917. export function pMultIn(point: Vec2, floatVar: number): void;
  1918. /**
  1919. !#en subtracts one point from another (inplace).
  1920. !#zh 向量减法,结果保存到第一个向量。
  1921. @param v1 v1
  1922. @param v2 v2
  1923. */
  1924. export function pSubIn(v1: Vec2, v2: Vec2): void;
  1925. /**
  1926. !#en adds one point to another (inplace).
  1927. !#zh 向量加法,结果保存到第一个向量。
  1928. @param v1 v1
  1929. @param v2 v2
  1930. */
  1931. export function pAddIn(v1: Vec2, v2: Vec2): void;
  1932. /**
  1933. !#en normalizes the point (inplace).
  1934. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1935. @param v v
  1936. */
  1937. export function pNormalizeIn(v: Vec2): void;
  1938. /**
  1939. !#en
  1940. The convenience method to create a new Rect.
  1941. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1942. !#zh
  1943. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1944. @param x x
  1945. @param y y
  1946. @param w w
  1947. @param h h
  1948. @example
  1949. ```js
  1950. var a = new cc.Rect(0 , 0, 10, 0);
  1951. ```
  1952. */
  1953. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1954. /**
  1955. !#en Check whether a rect's value equals to another.
  1956. !#zh 判断两个矩形是否相等。
  1957. @param rect1 rect1
  1958. @param rect2 rect2
  1959. @example
  1960. ```js
  1961. var a = new cc.Rect(0, 0, 10, 10);
  1962. var b = new cc.Rect(0, 0, 5, 5);
  1963. cc.rectEqualToRect(a, b); // false;
  1964. var c = new cc.Rect(0, 0, 5, 5);
  1965. cc.rectEqualToRect(b, c); // true;
  1966. ```
  1967. */
  1968. export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean;
  1969. /**
  1970. !#en Check whether the rect1 contains rect2.
  1971. !#zh
  1972. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1973. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1974. @param rect1 rect1
  1975. @param rect2 rect2
  1976. @example
  1977. ```js
  1978. var a = new cc.Rect(0, 0, 20, 20);
  1979. var b = new cc.Rect(10, 10, 20, 20);
  1980. cc.rectContainsRect(a, b); // true;
  1981. ```
  1982. */
  1983. export function rectContainsRect(rect1: Rect, rect2: Rect): boolean;
  1984. /**
  1985. !#en Returns the rightmost x-value of a rect.
  1986. !#zh 返回矩形在 x 轴上的最大值
  1987. @param rect rect
  1988. @example
  1989. ```js
  1990. var a = new cc.Rect(10, 0, 20, 20);
  1991. cc.rectGetMaxX(a); // 30;
  1992. ```
  1993. */
  1994. export function rectGetMaxX(rect: Rect): number;
  1995. /**
  1996. !#en Return the midpoint x-value of a rect.
  1997. !#zh 返回矩形在 x 轴上的中点。
  1998. @param rect rect
  1999. @example
  2000. ```js
  2001. var a = new cc.Rect(10, 0, 20, 20);
  2002. cc.rectGetMidX(a); // 20;
  2003. ```
  2004. */
  2005. export function rectGetMidX(rect: Rect): number;
  2006. /**
  2007. !#en Returns the leftmost x-value of a rect.
  2008. !#zh 返回矩形在 x 轴上的最小值。
  2009. @param rect rect
  2010. @example
  2011. ```js
  2012. var a = new cc.Rect(10, 0, 20, 20);
  2013. cc.rectGetMinX(a); // 10;
  2014. ```
  2015. */
  2016. export function rectGetMinX(rect: Rect): number;
  2017. /**
  2018. !#en Return the topmost y-value of a rect.
  2019. !#zh 返回矩形在 y 轴上的最大值。
  2020. @param rect rect
  2021. @example
  2022. ```js
  2023. var a = new cc.Rect(0, 10, 20, 20);
  2024. cc.rectGetMaxY(a); // 30;
  2025. ```
  2026. */
  2027. export function rectGetMaxY(rect: Rect): number;
  2028. /**
  2029. !#en Return the midpoint y-value of `rect'.
  2030. !#zh 返回矩形在 y 轴上的中点。
  2031. @param rect rect
  2032. @example
  2033. ```js
  2034. var a = new cc.Rect(0, 10, 20, 20);
  2035. cc.rectGetMidY(a); // 20;
  2036. ```
  2037. */
  2038. export function rectGetMidY(rect: Rect): number;
  2039. /**
  2040. !#en Return the bottommost y-value of a rect.
  2041. !#zh 返回矩形在 y 轴上的最小值。
  2042. @param rect rect
  2043. @example
  2044. ```js
  2045. var a = new cc.Rect(0, 10, 20, 20);
  2046. cc.rectGetMinY(a); // 10;
  2047. ```
  2048. */
  2049. export function rectGetMinY(rect: Rect): number;
  2050. /**
  2051. !#en Check whether a rect contains a point.
  2052. !#zh 检查一个矩形是否包含某个坐标点。
  2053. @param rect rect
  2054. @param point point
  2055. @example
  2056. ```js
  2057. var a = new cc.Rect(0, 10, 20, 20);
  2058. var b = new cc.Vec2(0, 10, 10, 10);
  2059. cc.rectContainsPoint(a, b); // true;
  2060. ```
  2061. */
  2062. export function rectContainsPoint(rect: Rect, point: Vec2): boolean;
  2063. /**
  2064. !#en Check whether a rect intersect with another.
  2065. !#zh 检查一个矩形是否与另一个相交。
  2066. @param rectA rectA
  2067. @param rectB rectB
  2068. @example
  2069. ```js
  2070. var a = new cc.Rect(0, 10, 20, 20);
  2071. var b = new cc.Rect(0, 10, 10, 10);
  2072. cc.rectIntersectsRect(a, b); // true;
  2073. ```
  2074. */
  2075. export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean;
  2076. /**
  2077. !#en Check whether a rect overlaps another.
  2078. !#zh 检查一个矩形是否重叠另一个。
  2079. @param rectA rectA
  2080. @param rectB rectB
  2081. @example
  2082. ```js
  2083. var a = new cc.Rect(0, 10, 20, 20);
  2084. var b = new cc.Rect(0, 10, 10, 10);
  2085. cc.rectOverlapsRect(a, b); // true;
  2086. ```
  2087. */
  2088. export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean;
  2089. /**
  2090. !#en Returns the smallest rectangle that contains the two source rectangles.
  2091. !#zh 返回一个包含两个指定矩形的最小矩形。
  2092. @param rectA rectA
  2093. @param rectB rectB
  2094. @example
  2095. ```js
  2096. var a = new cc.Rect(0, 10, 20, 20);
  2097. var b = new cc.Rect(0, 10, 10, 10);
  2098. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  2099. ```
  2100. */
  2101. export function rectUnion(rectA: Rect, rectB: Rect): Rect;
  2102. /**
  2103. !#en Returns the overlapping portion of 2 rectangles.
  2104. !#zh 返回 2 个矩形重叠的部分。
  2105. @param rectA rectA
  2106. @param rectB rectB
  2107. @example
  2108. ```js
  2109. var a = new cc.Rect(0, 10, 20, 20);
  2110. var b = new cc.Rect(0, 10, 10, 10);
  2111. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  2112. ```
  2113. */
  2114. export function rectIntersection(rectA: Rect, rectB: Rect): Rect;
  2115. /**
  2116. !#en
  2117. Helper function that creates a cc.Size.<br/>
  2118. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  2119. !#zh
  2120. 创建一个 cc.Size 对象的帮助函数。<br/>
  2121. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  2122. @param w width or a size object
  2123. @param h height
  2124. @example
  2125. ```js
  2126. var size1 = cc.size();
  2127. var size2 = cc.size(100,100);
  2128. var size3 = cc.size(size2);
  2129. var size4 = cc.size({width: 100, height: 100});
  2130. ```
  2131. */
  2132. export function size(w: number|Size, h?: number): Size;
  2133. /**
  2134. !#en Check whether a point's value equals to another.
  2135. !#zh 检查 Size 对象是否等于另一个。
  2136. @param size1 size1
  2137. @param size2 size2
  2138. @example
  2139. ```js
  2140. var a = new cc.size(10, 10);
  2141. var b = new cc.size(10, 10);
  2142. cc.sizeEqualToSize(a, b);// return true;
  2143. var b = new cc.size(5, 10);
  2144. cc.sizeEqualToSize(a, b);// return false;
  2145. ```
  2146. */
  2147. export function sizeEqualToSize(size1: Size, size2: Size): boolean;
  2148. export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad;
  2149. /**
  2150. @param sourceQuad sourceQuad
  2151. */
  2152. export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad;
  2153. /**
  2154. @param sourceQuads sourceQuads
  2155. */
  2156. export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[];
  2157. /**
  2158. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2159. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2160. @param x x
  2161. @param y y
  2162. @example
  2163. ```js
  2164. var v1 = cc.v2();
  2165. var v2 = cc.v2(0, 0);
  2166. var v3 = cc.v2(v2);
  2167. var v4 = cc.v2({x: 100, y: 100});
  2168. ```
  2169. */
  2170. export function v2(x?: number|any, y?: number): Vec2;
  2171. /**
  2172. !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2173. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2174. @param x a Number or a size object
  2175. @param y y
  2176. @example
  2177. ```js
  2178. var point1 = cc.p();
  2179. var point2 = cc.p(100, 100);
  2180. var point3 = cc.p(point2);
  2181. var point4 = cc.p({x: 100, y: 100});
  2182. ```
  2183. */
  2184. export function p(x?: number|any, y?: number): Vec2;
  2185. /**
  2186. !#en Check whether a point's value equals to another.
  2187. !#zh 判断两个向量是否相等。
  2188. @param point1 point1
  2189. @param point2 point2
  2190. */
  2191. export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean;
  2192. /** !#en Enum for debug modes.
  2193. !#zh 调试模式 */
  2194. export enum DebugMode {
  2195. NONE = 0,
  2196. INFO = 0,
  2197. WARN = 0,
  2198. ERROR = 0,
  2199. INFO_FOR_WEB_PAGE = 0,
  2200. WARN_FOR_WEB_PAGE = 0,
  2201. ERROR_FOR_WEB_PAGE = 0,
  2202. }
  2203. /** !#en Base class cc.Action for action classes.
  2204. !#zh Action 类是所有动作类型的基类。 */
  2205. export class Action {
  2206. /**
  2207. !#en
  2208. to copy object with deep copy.
  2209. returns a clone of action.
  2210. !#zh 返回一个克隆的动作。
  2211. */
  2212. clone(): Action;
  2213. /**
  2214. !#en
  2215. return true if the action has finished.
  2216. !#zh 如果动作已完成就返回 true。
  2217. */
  2218. isDone(): boolean;
  2219. /**
  2220. !#en get the target.
  2221. !#zh 获取当前目标节点。
  2222. */
  2223. getTarget(): Node;
  2224. /**
  2225. !#en The action will modify the target properties.
  2226. !#zh 设置目标节点。
  2227. @param target target
  2228. */
  2229. setTarget(target: Node): void;
  2230. /**
  2231. !#en get the original target.
  2232. !#zh 获取原始目标节点。
  2233. */
  2234. getOriginalTarget(): Node;
  2235. /**
  2236. !#en get tag number.
  2237. !#zh 获取用于识别动作的标签。
  2238. */
  2239. getTag(): number;
  2240. /**
  2241. !#en set tag number.
  2242. !#zh 设置标签,用于识别动作。
  2243. @param tag tag
  2244. */
  2245. setTag(tag: number): void;
  2246. /** !#en Default Action tag.
  2247. !#zh 默认动作标签。 */
  2248. static TAG_INVALID: number;
  2249. }
  2250. /** !#en
  2251. Base class actions that do have a finite time duration. <br/>
  2252. Possible actions: <br/>
  2253. - An action with a duration of 0 seconds. <br/>
  2254. - An action with a duration of 35.5 seconds.
  2255. Infinite time actions are valid
  2256. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2257. export class FiniteTimeAction extends Action {
  2258. /**
  2259. !#en get duration of the action. (seconds).
  2260. !#zh 获取动作以秒为单位的持续时间。
  2261. */
  2262. getDuration(): number;
  2263. /**
  2264. !#en set duration of the action. (seconds).
  2265. !#zh 设置动作以秒为单位的持续时间。
  2266. @param duration duration
  2267. */
  2268. setDuration(duration: number): void;
  2269. /**
  2270. !#en
  2271. Returns a reversed action. <br />
  2272. For example: <br />
  2273. - The action will be x coordinates of 0 move to 100. <br />
  2274. - The reversed action will be x of 100 move to 0.
  2275. - Will be rewritten
  2276. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2277. */
  2278. reverse(): void;
  2279. /**
  2280. !#en
  2281. to copy object with deep copy.
  2282. returns a clone of action.
  2283. !#zh 返回一个克隆的动作。
  2284. */
  2285. clone(): FiniteTimeAction;
  2286. }
  2287. /** !#en Base class for Easing actions.
  2288. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2289. export class ActionEase extends ActionInterval {
  2290. }
  2291. /** !#en Base class for Easing actions with rate parameters
  2292. !#zh 拥有速率属性的缓动动作基类。 */
  2293. export class EaseRateAction extends ActionEase {
  2294. }
  2295. /** !#en Ease Elastic abstract class.
  2296. !#zh 弹性缓动动作基类。 */
  2297. export class EaseElastic extends ActionEase {
  2298. }
  2299. /** !#en cc.EaseBounce abstract class.
  2300. !#zh 反弹缓动动作基类。 */
  2301. export class EaseBounce extends ActionEase {
  2302. }
  2303. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2304. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2305. export class ActionInstant extends FiniteTimeAction {
  2306. }
  2307. /** !#en
  2308. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2309. It has an start time, and a finish time. The finish time is the parameter<br/>
  2310. duration plus the start time.</p>
  2311. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2312. - They can run normally (default) <br/>
  2313. - They can run reversed with the reverse method <br/>
  2314. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2315. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2316. then running it again in Reverse mode. </p>
  2317. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2318. export class ActionInterval extends FiniteTimeAction {
  2319. /**
  2320. !#en Implementation of ease motion.
  2321. !#zh 缓动运动。
  2322. @param easeObj easeObj
  2323. @example
  2324. ```js
  2325. action.easing(cc.easeIn(3.0));
  2326. ```
  2327. */
  2328. easing(easeObj: any): ActionInterval;
  2329. /**
  2330. !#en
  2331. Repeats an action a number of times.
  2332. To repeat an action forever use the CCRepeatForever action.
  2333. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2334. @param times times
  2335. */
  2336. repeat(times: number): ActionInterval;
  2337. /**
  2338. !#en
  2339. Repeats an action for ever. <br/>
  2340. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2341. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2342. */
  2343. repeatForever(): ActionInterval;
  2344. }
  2345. /** !#en
  2346. cc.ActionManager is a class that can manage actions.<br/>
  2347. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2348. which uses this class's singleton object.
  2349. But there are some cases where you might need to use this class. <br/>
  2350. Examples:<br/>
  2351. - When you want to run an action where the target is different from a CCNode.<br/>
  2352. - When you want to pause / resume the actions<br/>
  2353. !#zh
  2354. cc.ActionManager 是可以管理动作的单例类。<br/>
  2355. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2356. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2357. 例如:
  2358. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2359. - 当你想要暂停/恢复动作时。 <br/> */
  2360. export class ActionManager {
  2361. /**
  2362. !#en
  2363. Adds an action with a target.<br/>
  2364. If the target is already present, then the action will be added to the existing target.
  2365. 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.
  2366. When the target is paused, the queued actions won't be 'ticked'.
  2367. !#zh
  2368. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2369. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2370. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2371. 当目标状态的 paused 为 true,动作将不会被执行
  2372. @param action action
  2373. @param target target
  2374. @param paused paused
  2375. */
  2376. addAction(action: Action, target: Node, paused: boolean): void;
  2377. /**
  2378. !#en Removes all actions from all the targets.
  2379. !#zh 移除所有对象的所有动作。
  2380. */
  2381. removeAllActions(): void;
  2382. /**
  2383. !#en
  2384. Removes all actions from a certain target. <br/>
  2385. All the actions that belongs to the target will be removed.
  2386. !#zh
  2387. 移除指定对象上的所有动作。<br/>
  2388. 属于该目标的所有的动作将被删除。
  2389. @param target target
  2390. @param forceDelete forceDelete
  2391. */
  2392. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2393. /**
  2394. !#en Removes an action given an action reference.
  2395. !#zh 移除指定的动作。
  2396. @param action action
  2397. */
  2398. removeAction(action: Action): void;
  2399. /**
  2400. !#en Removes an action given its tag and the target.
  2401. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2402. @param tag tag
  2403. @param target target
  2404. */
  2405. removeActionByTag(tag: number, target: Node): void;
  2406. /**
  2407. !#en Gets an action given its tag an a target.
  2408. !#zh 通过目标对象和标签获取一个动作。
  2409. @param tag tag
  2410. @param target target
  2411. */
  2412. getActionByTag(tag: number, target: Node): Action;
  2413. /**
  2414. !#en
  2415. Returns the numbers of actions that are running in a certain target. <br/>
  2416. Composable actions are counted as 1 action. <br/>
  2417. Example: <br/>
  2418. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2419. - If you are running 7 Sequences of 2 actions, it will return 7.
  2420. !#zh
  2421. 返回指定对象下所有正在运行的动作数量。 <br/>
  2422. 组合动作被算作一个动作。<br/>
  2423. 例如:<br/>
  2424. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2425. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2426. @param target target
  2427. */
  2428. getNumberOfRunningActionsInTarget(target: Node): number;
  2429. /**
  2430. !#en Pauses the target: all running actions and newly added actions will be paused.
  2431. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2432. @param target target
  2433. */
  2434. pauseTarget(target: Node): void;
  2435. /**
  2436. !#en Resumes the target. All queued actions will be resumed.
  2437. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2438. @param target target
  2439. */
  2440. resumeTarget(target: Node): void;
  2441. /**
  2442. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2443. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2444. */
  2445. pauseAllRunningActions(): any[];
  2446. /**
  2447. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2448. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2449. @param targetsToResume targetsToResume
  2450. */
  2451. resumeTargets(targetsToResume: any[]): void;
  2452. /**
  2453. !#en Pause a set of targets.
  2454. !#zh 暂停一组指定对象。
  2455. @param targetsToPause targetsToPause
  2456. */
  2457. pauseTargets(targetsToPause: any[]): void;
  2458. /**
  2459. !#en
  2460. purges the shared action manager. It releases the retained instance. <br/>
  2461. because it uses this, so it can not be static.
  2462. !#zh
  2463. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2464. 因为它使用 this,因此它不能是静态的。
  2465. */
  2466. purgeSharedManager(): void;
  2467. /**
  2468. !#en The ActionManager update。
  2469. !#zh ActionManager 主循环。
  2470. @param dt delta time in seconds
  2471. */
  2472. update(dt: number): void;
  2473. }
  2474. /** !#en Class for animation data handling.
  2475. !#zh 动画剪辑,用于存储动画数据。 */
  2476. export class AnimationClip extends Asset {
  2477. /** !#en Duration of this animation.
  2478. !#zh 动画的持续时间。 */
  2479. duration: number;
  2480. /** !#en FrameRate of this animation.
  2481. !#zh 动画的帧速率。 */
  2482. sample: number;
  2483. /** !#en Speed of this animation.
  2484. !#zh 动画的播放速度。 */
  2485. speed: number;
  2486. /** !#en WrapMode of this animation.
  2487. !#zh 动画的循环模式。 */
  2488. wrapMode: WrapMode;
  2489. /** !#en Curve data.
  2490. !#zh 曲线数据。 */
  2491. curveData: any;
  2492. /** !#en Event data.
  2493. !#zh 事件数据。 */
  2494. events: {frame: number, func: string, params: string[]}[];
  2495. /**
  2496. !#en Crate clip with a set of sprite frames
  2497. !#zh 使用一组序列帧图片来创建动画剪辑
  2498. @param spriteFrames spriteFrames
  2499. @param sample sample
  2500. @example
  2501. ```js
  2502. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  2503. ```
  2504. */
  2505. static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip;
  2506. }
  2507. /** !#en
  2508. The AnimationState gives full control over animation playback process.
  2509. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  2510. !#zh
  2511. AnimationState 完全控制动画播放过程。<br/>
  2512. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  2513. export class AnimationState extends Playable {
  2514. /**
  2515. @param clip clip
  2516. @param name name
  2517. */
  2518. constructor(clip: AnimationClip, name?: string);
  2519. animator: AnimationAnimator;
  2520. /** !#en The curves list.
  2521. !#zh 曲线列表。 */
  2522. curves: any[];
  2523. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  2524. the active interval.
  2525. !#zh 延迟多少秒播放。 */
  2526. delay: number;
  2527. /** !#en The animation's iteration count property.
  2528. A real number greater than or equal to zero (including positive infinity) representing the number of times
  2529. to repeat the animation node.
  2530. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  2531. calculations.
  2532. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  2533. repeatCount: number;
  2534. /** !#en The iteration duration of this animation in seconds. (length)
  2535. !#zh 单次动画的持续时间,秒。 */
  2536. duration: number;
  2537. /** !#en The animation's playback speed. 1 is normal playback speed.
  2538. !#zh 播放速率。 */
  2539. speed: number;
  2540. /** !#en
  2541. Wrapping mode of the playing animation.
  2542. Notice : dynamic change wrapMode will reset time and repeatCount property
  2543. !#zh
  2544. 动画循环方式。
  2545. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  2546. wrapMode: WrapMode;
  2547. /** !#en The current time of this animation in seconds.
  2548. !#zh 动画当前的时间,秒。 */
  2549. time: number;
  2550. /** !#en The clip that is being played by this animation state.
  2551. !#zh 此动画状态正在播放的剪辑。 */
  2552. clip: AnimationClip;
  2553. /** !#en The name of the playing animation.
  2554. !#zh 动画的名字 */
  2555. name: string;
  2556. }
  2557. /** undefined */
  2558. export class Playable {
  2559. /** !#en Is playing or paused in play mode?
  2560. !#zh 当前是否正在播放。 */
  2561. isPlaying: boolean;
  2562. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  2563. !#zh 当前是否正在暂停 */
  2564. isPaused: boolean;
  2565. /**
  2566. !#en Play this animation.
  2567. !#zh 播放动画。
  2568. */
  2569. play(): void;
  2570. /**
  2571. !#en Stop this animation.
  2572. !#zh 停止动画播放。
  2573. */
  2574. stop(): void;
  2575. /**
  2576. !#en Pause this animation.
  2577. !#zh 暂停动画。
  2578. */
  2579. pause(): void;
  2580. /**
  2581. !#en Resume this animation.
  2582. !#zh 重新播放动画。
  2583. */
  2584. resume(): void;
  2585. /**
  2586. !#en Perform a single frame step.
  2587. !#zh 执行一帧动画。
  2588. */
  2589. step(): void;
  2590. }
  2591. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  2592. !#zh 动画使用的循环模式。 */
  2593. export enum WrapMode {
  2594. Default = 0,
  2595. Normal = 0,
  2596. Reverse = 0,
  2597. Loop = 0,
  2598. LoopReverse = 0,
  2599. PingPong = 0,
  2600. PingPongReverse = 0,
  2601. }
  2602. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  2603. !#zh
  2604. cc.audioengine是单例对象。<br/>
  2605. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  2606. 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放 <br/>
  2607. 注意:<br/>
  2608. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  2609. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  2610. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  2611. export class audioEngine {
  2612. /**
  2613. !#en Play audio.
  2614. !#zh 播放音频
  2615. @param filePath The path of the audio file without filename extension.
  2616. @param loop Whether the music loop or not.
  2617. @param volume Volume size.
  2618. @example
  2619. ```js
  2620. var audioID = cc.audioEngine.play(path, false, 0.5);
  2621. ```
  2622. */
  2623. static play(filePath: string, loop: boolean, volume: number): number;
  2624. /**
  2625. !#en Set audio loop.
  2626. !#zh 设置音频是否循环。
  2627. @param audioID audio id.
  2628. @param loop Whether cycle.
  2629. @example
  2630. ```js
  2631. cc.audioEngine.setLoop(id, true);
  2632. ```
  2633. */
  2634. static setLoop(audioID: number, loop: boolean): void;
  2635. /**
  2636. !#en Get audio cycle state.
  2637. !#zh 获取音频的循环状态。
  2638. @param audioID audio id.
  2639. @example
  2640. ```js
  2641. cc.audioEngine.isLoop(id);
  2642. ```
  2643. */
  2644. static isLoop(audioID: number): boolean;
  2645. /**
  2646. !#en Set the volume of audio.
  2647. !#zh 设置音量(0.0 ~ 1.0)。
  2648. @param audioID audio id.
  2649. @param volume Volume must be in 0.0~1.0 .
  2650. @example
  2651. ```js
  2652. cc.audioEngine.setVolume(id, 0.5);
  2653. ```
  2654. */
  2655. static setVolume(audioID: number, volume: number): void;
  2656. /**
  2657. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  2658. !#zh 获取音量(0.0 ~ 1.0)。
  2659. @param audioID audio id.
  2660. @example
  2661. ```js
  2662. var volume = cc.audioEngine.getVolume(id);
  2663. ```
  2664. */
  2665. static getVolume(audioID: number): number;
  2666. /**
  2667. !#en Set current time
  2668. !#zh 设置当前的音频时间。
  2669. @param audioID audio id.
  2670. @param sec current time.
  2671. @example
  2672. ```js
  2673. cc.audioEngine.setCurrentTime(id, 2);
  2674. ```
  2675. */
  2676. static setCurrentTime(audioID: number, sec: number): boolean;
  2677. /**
  2678. !#en Get current time
  2679. !#zh 获取当前的音频播放时间。
  2680. @param audioID audio id.
  2681. @example
  2682. ```js
  2683. var time = cc.audioEngine.getCurrentTime(id);
  2684. ```
  2685. */
  2686. static getCurrentTime(audioID: number): number;
  2687. /**
  2688. !#en Get audio duration
  2689. !#zh 获取音频总时长。
  2690. @param audioID audio id.
  2691. @example
  2692. ```js
  2693. var time = cc.audioEngine.getDuration(id);
  2694. ```
  2695. */
  2696. static getDuration(audioID: number): number;
  2697. /**
  2698. !#en Get audio state
  2699. !#zh 获取音频状态。
  2700. @param audioID audio id.
  2701. @example
  2702. ```js
  2703. var state = cc.audioEngine.getState(id);
  2704. ```
  2705. */
  2706. static getState(audioID: number): audioEngine.AudioState;
  2707. /**
  2708. !#en Set Audio finish callback
  2709. !#zh 设置一个音频结束后的回调
  2710. @param audioID audio id.
  2711. @param callback loaded callback.
  2712. @example
  2713. ```js
  2714. cc.audioEngine.setFinishCallback(id, function () {});
  2715. ```
  2716. */
  2717. static setFinishCallback(audioID: number, callback: Function): void;
  2718. /**
  2719. !#en Pause playing audio.
  2720. !#zh 暂停正在播放音频。
  2721. @param audioID The return value of function play.
  2722. @example
  2723. ```js
  2724. cc.audioEngine.pause(audioID);
  2725. ```
  2726. */
  2727. static pause(audioID: number): void;
  2728. /**
  2729. !#en Pause all playing audio
  2730. !#zh 暂停现在正在播放的所有音频。
  2731. @example
  2732. ```js
  2733. cc.audioEngine.pauseAll();
  2734. ```
  2735. */
  2736. static pauseAll(): void;
  2737. /**
  2738. !#en Resume playing audio.
  2739. !#zh 恢复播放指定的音频。
  2740. @param audioID The return value of function play.
  2741. @example
  2742. ```js
  2743. cc.audioEngine.resume(audioID);
  2744. ```
  2745. */
  2746. static resume(audioID: number): void;
  2747. /**
  2748. !#en Resume all playing audio.
  2749. !#zh 恢复播放所有之前暂停的所有音频。
  2750. @example
  2751. ```js
  2752. cc.audioEngine.resumeAll();
  2753. ```
  2754. */
  2755. static resumeAll(): void;
  2756. /**
  2757. !#en Stop playing audio.
  2758. !#zh 停止播放指定音频。
  2759. @param audioID The return value of function play.
  2760. @example
  2761. ```js
  2762. cc.audioEngine.stop(audioID);
  2763. ```
  2764. */
  2765. static stop(audioID: number): void;
  2766. /**
  2767. !#en Stop all playing audio.
  2768. !#zh 停止正在播放的所有音频。
  2769. @example
  2770. ```js
  2771. cc.audioEngine.stopAll();
  2772. ```
  2773. */
  2774. static stopAll(): void;
  2775. /**
  2776. !#en Set up an audio can generate a few examples.
  2777. !#zh 设置一个音频可以设置几个实例
  2778. @param num a number of instances to be created from within an audio
  2779. @example
  2780. ```js
  2781. cc.audioEngine.setMaxAudioInstance(20);
  2782. ```
  2783. */
  2784. static setMaxAudioInstance(num: number): void;
  2785. /**
  2786. !#en Getting audio can produce several examples.
  2787. !#zh 获取一个音频可以设置几个实例
  2788. @example
  2789. ```js
  2790. cc.audioEngine.getMaxAudioInstance();
  2791. ```
  2792. */
  2793. static getMaxAudioInstance(): number;
  2794. /**
  2795. !#en Unload the preloaded audio from internal buffer.
  2796. !#zh 卸载预加载的音频。
  2797. @param filePath filePath
  2798. @example
  2799. ```js
  2800. cc.audioEngine.uncache(filePath);
  2801. ```
  2802. */
  2803. static uncache(filePath: string): void;
  2804. /**
  2805. !#en Unload all audio from internal buffer.
  2806. !#zh 卸载所有音频。
  2807. @example
  2808. ```js
  2809. cc.audioEngine.uncacheAll();
  2810. ```
  2811. */
  2812. static uncacheAll(): void;
  2813. /**
  2814. !#en Preload audio file.
  2815. !#zh 预加载一个音频
  2816. @param filePath The file path of an audio.
  2817. @param callback The callback of an audio.
  2818. @example
  2819. ```js
  2820. cc.audioEngine.preload(path);
  2821. ```
  2822. */
  2823. static preload(filePath: string, callback?: Function): void;
  2824. /**
  2825. !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
  2826. !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
  2827. @param kb The file path of an audio.
  2828. @example
  2829. ```js
  2830. cc.audioEngine.setMaxWebAudioSize(300);
  2831. ```
  2832. */
  2833. static setMaxWebAudioSize(kb: number): void;
  2834. }
  2835. /** !#en
  2836. <p>
  2837. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  2838. cc.director is a singleton object which manage your game's logic flow.<br/>
  2839. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  2840. the standard way to use it is by calling:<br/>
  2841. - cc.director.methodName(); <br/>
  2842. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  2843. <br/>
  2844. The cc.director is also responsible for:<br/>
  2845. - initializing the OpenGL context<br/>
  2846. - setting the OpenGL pixel format (default on is RGB565)<br/>
  2847. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  2848. - setting the color for clear screen (default one is BLACK)<br/>
  2849. - setting the projection (default one is 3D)<br/>
  2850. - setting the orientation (default one is Portrait)<br/>
  2851. <br/>
  2852. <br/>
  2853. The cc.director also sets the default OpenGL context:<br/>
  2854. - GL_TEXTURE_2D is enabled<br/>
  2855. - GL_VERTEX_ARRAY is enabled<br/>
  2856. - GL_COLOR_ARRAY is enabled<br/>
  2857. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  2858. </p>
  2859. <p>
  2860. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  2861. Features and Limitations:<br/>
  2862. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  2863. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  2864. </p>
  2865. !#zh
  2866. <p>
  2867. 注意:用 cc.director 代替 cc.Director。<br/>
  2868. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  2869. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  2870. 使用它的标准方法是通过调用:<br/>
  2871. - cc.director.methodName();
  2872. <br/>
  2873. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  2874. <br/>
  2875. cc.director 还负责:<br/>
  2876. - 初始化 OpenGL 环境。<br/>
  2877. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  2878. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  2879. - 设置空白场景的颜色 (默认是 黑色)<br/>
  2880. - 设置投影 (默认是 3D)<br/>
  2881. - 设置方向 (默认是 Portrait)<br/>
  2882. <br/>
  2883. cc.director 设置了 OpenGL 默认环境 <br/>
  2884. - GL_TEXTURE_2D 启用。<br/>
  2885. - GL_VERTEX_ARRAY 启用。<br/>
  2886. - GL_COLOR_ARRAY 启用。<br/>
  2887. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  2888. </p>
  2889. <p>
  2890. cc.director 也同步定时器与显示器的刷新速率。
  2891. <br/>
  2892. 特点和局限性: <br/>
  2893. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  2894. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  2895. </p> */
  2896. export class Director extends EventTarget {
  2897. /**
  2898. !#en
  2899. Converts an OpenGL coordinate to a view coordinate<br/>
  2900. Useful to convert node points to window points for calls such as glScissor<br/>
  2901. Implementation can be found in CCDirectorWebGL.
  2902. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  2903. @param glPoint glPoint
  2904. */
  2905. convertToUI(glPoint: Vec2): Vec2;
  2906. /**
  2907. !#en
  2908. Returns the size of the WebGL view in points.<br/>
  2909. It takes into account any possible rotation (device orientation) of the window.
  2910. !#zh 获取视图的大小,以点为单位。
  2911. */
  2912. getWinSize(): Size;
  2913. /**
  2914. !#en
  2915. Returns the size of the OpenGL view in pixels.<br/>
  2916. It takes into account any possible rotation (device orientation) of the window.<br/>
  2917. On Mac winSize and winSizeInPixels return the same value.
  2918. (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())
  2919. !#zh
  2920. 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。
  2921. 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
  2922. */
  2923. getWinSizeInPixels(): Size;
  2924. /**
  2925. !#en Returns the visible size of the running scene.
  2926. !#zh 获取运行场景的可见大小。
  2927. */
  2928. getVisibleSize(): Size;
  2929. /**
  2930. !#en Returns the visible origin of the running scene.
  2931. !#zh 获取视图在游戏内容中的坐标原点。
  2932. */
  2933. getVisibleOrigin(): Vec2;
  2934. /**
  2935. !#en Pause the director's ticker, only involve the game logic execution.
  2936. It won't pause the rendering process nor the event manager.
  2937. If you want to pause the entier game including rendering, audio and event,
  2938. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  2939. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  2940. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  2941. */
  2942. pause(): void;
  2943. /**
  2944. !#en
  2945. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  2946. The new scene will be launched immediately.
  2947. !#zh 立刻切换指定场景。
  2948. @param scene The need run scene.
  2949. @param onBeforeLoadScene The function invoked at the scene before loading.
  2950. @param onLaunched The function invoked at the scene after launch.
  2951. */
  2952. runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  2953. /**
  2954. !#en Loads the scene by its name.
  2955. !#zh 通过场景名称进行加载场景。
  2956. @param sceneName The name of the scene to load.
  2957. @param onLaunched callback, will be called after scene launched.
  2958. */
  2959. loadScene(sceneName: string, onLaunched?: Function): boolean;
  2960. /**
  2961. !#en
  2962. Preloads the scene to reduces loading time. You can call this method at any time you want.
  2963. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  2964. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  2965. yet finished, the scene will be launched after loaded automatically.
  2966. !#zh 预加载场景,你可以在任何时候调用这个方法。
  2967. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  2968. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  2969. @param sceneName The name of the scene to preload.
  2970. @param onLoaded callback, will be called after scene loaded.
  2971. */
  2972. preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void;
  2973. /**
  2974. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  2975. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  2976. */
  2977. resume(): void;
  2978. /**
  2979. !#en
  2980. Enables or disables WebGL depth test.<br/>
  2981. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  2982. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  2983. @param on on
  2984. */
  2985. setDepthTest(on: boolean): void;
  2986. /**
  2987. !#en
  2988. Set color for clear screen.<br/>
  2989. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  2990. !#zh
  2991. 设置场景的默认擦除颜色。<br/>
  2992. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  2993. @param clearColor clearColor
  2994. */
  2995. setClearColor(clearColor: Color): void;
  2996. /**
  2997. !#en
  2998. Sets an OpenGL projection.<br/>
  2999. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3000. !#zh 设置 OpenGL 投影。
  3001. @param projection projection
  3002. */
  3003. setProjection(projection: number): void;
  3004. /**
  3005. !#en
  3006. Update the view port.<br/>
  3007. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3008. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  3009. */
  3010. setViewport(): void;
  3011. /**
  3012. !#en
  3013. Sets an OpenGL projection.<br/>
  3014. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3015. !#zh 获取 OpenGL 投影。
  3016. */
  3017. getProjection(): number;
  3018. /**
  3019. !#en
  3020. Enables/disables OpenGL alpha blending.<br/>
  3021. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3022. !#zh 启用/禁用 透明度融合。
  3023. @param on on
  3024. */
  3025. setAlphaBlending(on: boolean): void;
  3026. /**
  3027. !#en
  3028. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  3029. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  3030. If the new scene replaces the old one, the it will receive the "cleanup" message.
  3031. !#zh
  3032. 更换场景时是否接收清理消息。<br>
  3033. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  3034. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  3035. */
  3036. isSendCleanupToScene(): boolean;
  3037. /**
  3038. !#en Returns current logic Scene.
  3039. !#zh 获取当前逻辑场景。
  3040. @example
  3041. ```js
  3042. // This will help you to get the Canvas node in scene
  3043. cc.director.getScene().getChildByName('Canvas');
  3044. ```
  3045. */
  3046. getScene(): Scene;
  3047. /**
  3048. !#en Returns the FPS value.
  3049. !#zh 获取单位帧执行时间。
  3050. */
  3051. getAnimationInterval(): number;
  3052. /**
  3053. !#en Returns whether or not to display the FPS informations.
  3054. !#zh 获取是否显示 FPS 信息。
  3055. */
  3056. isDisplayStats(): boolean;
  3057. /**
  3058. !#en Sets whether display the FPS on the bottom-left corner.
  3059. !#zh 设置是否在左下角显示 FPS。
  3060. @param displayStats displayStats
  3061. */
  3062. setDisplayStats(displayStats: boolean): void;
  3063. /**
  3064. !#en Returns whether next delta time equals to zero.
  3065. !#zh 返回下一个 “delta time” 是否等于零。
  3066. */
  3067. isNextDeltaTimeZero(): boolean;
  3068. /**
  3069. !#en Returns whether or not the Director is paused.
  3070. !#zh 是否处于暂停状态。
  3071. */
  3072. isPaused(): boolean;
  3073. /**
  3074. !#en Returns how many frames were called since the director started.
  3075. !#zh 获取 director 启动以来游戏运行的总帧数。
  3076. */
  3077. getTotalFrames(): number;
  3078. /**
  3079. !#en Returns the cc.Scheduler associated with this director.
  3080. !#zh 获取和 director 相关联的 cc.Scheduler。
  3081. */
  3082. getScheduler(): Scheduler;
  3083. /**
  3084. !#en Sets the cc.Scheduler associated with this director.
  3085. !#zh 设置和 director 相关联的 cc.Scheduler。
  3086. @param scheduler scheduler
  3087. */
  3088. setScheduler(scheduler: Scheduler): void;
  3089. /**
  3090. !#en Returns the cc.ActionManager associated with this director.
  3091. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  3092. */
  3093. getActionManager(): ActionManager;
  3094. /**
  3095. !#en Sets the cc.ActionManager associated with this director.
  3096. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  3097. @param actionManager actionManager
  3098. */
  3099. setActionManager(actionManager: ActionManager): void;
  3100. /**
  3101. Returns the cc.CollisionManager associated with this director.
  3102. */
  3103. getCollisionManager(): CollisionManager;
  3104. /**
  3105. Returns the cc.PhysicsManager associated with this director.
  3106. */
  3107. getPhysicsManager(): PhysicsManager;
  3108. /**
  3109. !#en Returns the delta time since last frame.
  3110. !#zh 获取上一帧的 “delta time”。
  3111. */
  3112. getDeltaTime(): number;
  3113. /** !#en The event projection changed of cc.Director.
  3114. !#zh cc.Director 投影变化的事件。 */
  3115. static EVENT_PROJECTION_CHANGED: string;
  3116. /** !#en The event which will be triggered before loading a new scene.
  3117. !#zh 加载新场景之前所触发的事件。 */
  3118. static EVENT_BEFORE_SCENE_LOADING: string;
  3119. /** !#en The event which will be triggered before launching a new scene.
  3120. !#zh 运行新场景之前所触发的事件。 */
  3121. static EVENT_BEFORE_SCENE_LAUNCH: string;
  3122. /** !#en The event which will be triggered after launching a new scene.
  3123. !#zh 运行新场景之后所触发的事件。 */
  3124. static EVENT_AFTER_SCENE_LAUNCH: string;
  3125. /** !#en The event which will be triggered at the beginning of every frame.
  3126. !#zh 每个帧的开始时所触发的事件。 */
  3127. static EVENT_BEFORE_UPDATE: string;
  3128. /** !#en The event which will be triggered after engine and components update logic.
  3129. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  3130. static EVENT_AFTER_UPDATE: string;
  3131. /** !#en The event which will be triggered before visiting the rendering scene graph.
  3132. !#zh 访问渲染场景树之前所触发的事件。 */
  3133. static EVENT_BEFORE_VISIT: string;
  3134. /** !#en
  3135. The event which will be triggered after visiting the rendering scene graph,
  3136. the render queue is ready but not rendered at this point.
  3137. !#zh
  3138. 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */
  3139. static EVENT_AFTER_VISIT: string;
  3140. /** !#en The event which will be triggered after the rendering process.
  3141. !#zh 渲染过程之后所触发的事件。 */
  3142. static EVENT_AFTER_DRAW: string;
  3143. /** Constant for 2D projection (orthogonal projection) */
  3144. static PROJECTION_2D: number;
  3145. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  3146. static PROJECTION_3D: number;
  3147. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  3148. static PROJECTION_CUSTOM: number;
  3149. /** Constant for default projection of cc.Director, default projection is 2D projection */
  3150. static PROJECTION_DEFAULT: number;
  3151. }
  3152. /** !#en cc.game is the singleton object for game related functions.
  3153. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  3154. export class Game extends EventTarget {
  3155. /** !#en Event triggered when game hide to background.
  3156. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3157. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  3158. !#zh 游戏进入后台时触发的事件。
  3159. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3160. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  3161. EVENT_HIDE: string;
  3162. /** Event triggered when game back to foreground
  3163. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3164. on native platforms, it corresponds to enter foreground event.
  3165. !#zh 游戏进入前台运行时触发的事件。
  3166. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3167. 在原生平台,它对应的是应用被切换到前台事件。 */
  3168. EVENT_SHOW: string;
  3169. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  3170. EVENT_GAME_INITED: string;
  3171. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  3172. EVENT_RENDERER_INITED: string;
  3173. /** Key of config */
  3174. CONFIG_KEY: any;
  3175. /** !#en The outer frame of the game canvas, parent of cc.container.
  3176. !#zh 游戏画布的外框,cc.container 的父类。 */
  3177. frame: any;
  3178. /** !#en The container of game canvas, equals to cc.container.
  3179. !#zh 游戏画布的容器。 */
  3180. container: HTMLDivElement;
  3181. /** !#en The canvas of the game, equals to cc._canvas.
  3182. !#zh 游戏的画布。 */
  3183. canvas: HTMLCanvasElement;
  3184. /** !#en
  3185. The current game configuration, including:<br/>
  3186. 1. debugMode<br/>
  3187. "debugMode" possible values :<br/>
  3188. 0 - No message will be printed. <br/>
  3189. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  3190. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  3191. 3 - cc.error, cc.assert will print in console. <br/>
  3192. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  3193. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  3194. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  3195. 2. showFPS<br/>
  3196. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  3197. 3. exposeClassName<br/>
  3198. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  3199. 4. frameRate<br/>
  3200. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  3201. 5. id<br/>
  3202. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  3203. 6. renderMode<br/>
  3204. "renderMode" sets the renderer type, only useful on web :<br/>
  3205. 0 - Automatically chosen by engine<br/>
  3206. 1 - Forced to use canvas renderer<br/>
  3207. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  3208. 7. scenes<br/>
  3209. "scenes" include available scenes in the current bundle.<br/>
  3210. <br/>
  3211. Please DO NOT modify this object directly, it won't have any effect.<br/>
  3212. !#zh
  3213. 当前的游戏配置,包括: <br/>
  3214. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  3215. "debugMode" 各种设置选项的意义。 <br/>
  3216. 0 - 没有消息被打印出来。 <br/>
  3217. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  3218. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  3219. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  3220. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3221. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3222. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3223. 2. showFPS(显示 FPS) <br/>
  3224. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  3225. 3. exposeClassName <br/>
  3226. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  3227. 4. frameRate (帧率) <br/>
  3228. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  3229. 5. id <br/>
  3230. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  3231. 6. renderMode(渲染模式) <br/>
  3232. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  3233. 0 - 通过引擎自动选择。 <br/>
  3234. 1 - 强制使用 canvas 渲染。
  3235. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  3236. 7. scenes <br/>
  3237. “scenes” 当前包中可用场景。 <br/>
  3238. <br/>
  3239. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  3240. config: any;
  3241. /**
  3242. !#en Callback when the scripts of engine have been load.
  3243. !#zh 当引擎完成启动后的回调函数。
  3244. */
  3245. onStart(): void;
  3246. /**
  3247. !#en Set frameRate of game.
  3248. !#zh 设置游戏帧率。
  3249. @param frameRate frameRate
  3250. */
  3251. setFrameRate(frameRate: number): void;
  3252. /**
  3253. !#en Run the game frame by frame.
  3254. !#zh 执行一帧游戏循环。
  3255. */
  3256. step(): void;
  3257. /**
  3258. !#en Pause the game main loop. This will pause:
  3259. game logic execution, rendering process, event manager, background music and all audio effects.
  3260. This is different with cc.director.pause which only pause the game logic execution.
  3261. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  3262. */
  3263. pause(): void;
  3264. /**
  3265. !#en Resume the game from pause. This will resume:
  3266. game logic execution, rendering process, event manager, background music and all audio effects.
  3267. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  3268. */
  3269. resume(): void;
  3270. /**
  3271. !#en Check whether the game is paused.
  3272. !#zh 判断游戏是否暂停。
  3273. */
  3274. isPaused(): boolean;
  3275. /**
  3276. !#en Restart game.
  3277. !#zh 重新开始游戏
  3278. */
  3279. restart(): void;
  3280. /**
  3281. !#en End game, it will close the game window
  3282. !#zh 退出游戏
  3283. */
  3284. end(): void;
  3285. /**
  3286. !#en Prepare game.
  3287. !#zh 准备引擎,请不要直接调用这个函数。
  3288. @param cb cb
  3289. */
  3290. prepare(cb: Function): void;
  3291. /**
  3292. !#en Run game with configuration object and onStart function.
  3293. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  3294. @param config Pass configuration object or onStart function
  3295. @param onStart function to be executed after game initialized
  3296. */
  3297. run(config?: any|Function, onStart?: Function): void;
  3298. /**
  3299. !#en
  3300. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  3301. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  3302. !#zh
  3303. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  3304. 目标节点必须位于为层级的根节点,否则无效。
  3305. @param node The node to be made persistent
  3306. */
  3307. addPersistRootNode(node: Node): void;
  3308. /**
  3309. !#en Remove a persistent root node.
  3310. !#zh 取消常驻根节点。
  3311. @param node The node to be removed from persistent node list
  3312. */
  3313. removePersistRootNode(node: Node): void;
  3314. /**
  3315. !#en Check whether the node is a persistent root node.
  3316. !#zh 检查节点是否是常驻根节点。
  3317. @param node The node to be checked
  3318. */
  3319. isPersistRootNode(node: Node): boolean;
  3320. }
  3321. /** !#en
  3322. Class of all entities in Cocos Creator scenes.<br/>
  3323. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  3324. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  3325. !#zh
  3326. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  3327. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  3328. export class Node extends _BaseNode {
  3329. /** !#en
  3330. Group index of node.<br/>
  3331. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3332. !#zh
  3333. 节点的分组索引。<br/>
  3334. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3335. groupIndex: number;
  3336. /** !#en
  3337. Group of node.<br/>
  3338. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  3339. !#zh
  3340. 节点的分组。<br/>
  3341. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  3342. group: string;
  3343. /** !#en The position (x, y) of the node in its parent's coordinates.
  3344. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  3345. position: Vec2;
  3346. /** !#en x axis position of node.
  3347. !#zh 节点 X 轴坐标。 */
  3348. x: number;
  3349. /** !#en y axis position of node.
  3350. !#zh 节点 Y 轴坐标。 */
  3351. y: number;
  3352. /** !#en Rotation of node.
  3353. !#zh 该节点旋转角度。 */
  3354. rotation: number;
  3355. /** !#en Rotation on x axis.
  3356. !#zh 该节点 X 轴旋转角度。 */
  3357. rotationX: number;
  3358. /** !#en Rotation on y axis.
  3359. !#zh 该节点 Y 轴旋转角度。 */
  3360. rotationY: number;
  3361. /** !#en Scale on x axis.
  3362. !#zh 节点 X 轴缩放。 */
  3363. scaleX: number;
  3364. /** !#en Scale on y axis.
  3365. !#zh 节点 Y 轴缩放。 */
  3366. scaleY: number;
  3367. /** !#en Skew x
  3368. !#zh 该节点 Y 轴倾斜角度。 */
  3369. skewX: number;
  3370. /** !#en Skew y
  3371. !#zh 该节点 X 轴倾斜角度。 */
  3372. skewY: number;
  3373. /** !#en Opacity of node, default value is 255.
  3374. !#zh 节点透明度,默认值为 255。 */
  3375. opacity: number;
  3376. /** !#en Indicate whether node's opacity value affect its child nodes, default value is true.
  3377. !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */
  3378. cascadeOpacity: boolean;
  3379. /** !#en Color of node, default value is white: (255, 255, 255).
  3380. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  3381. color: Color;
  3382. /** !#en Anchor point's position on x axis.
  3383. !#zh 节点 X 轴锚点位置。 */
  3384. anchorX: number;
  3385. /** !#en Anchor point's position on y axis.
  3386. !#zh 节点 Y 轴锚点位置。 */
  3387. anchorY: number;
  3388. /** !#en Width of node.
  3389. !#zh 节点宽度。 */
  3390. width: number;
  3391. /** !#en Height of node.
  3392. !#zh 节点高度。 */
  3393. height: number;
  3394. /** !#en Z order in depth which stands for the drawing order.
  3395. !#zh 该节点渲染排序的 Z 轴深度。 */
  3396. zIndex: number;
  3397. /**
  3398. @param name name
  3399. */
  3400. constructor(name?: string);
  3401. /**
  3402. !#en
  3403. Register a callback of a specific event type on Node.<br/>
  3404. Use this method to register touch or mouse event permit propagation based on scene graph,
  3405. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  3406. It's the recommended way to register touch/mouse event for Node,
  3407. please do not use cc.eventManager directly for Node.
  3408. !#zh
  3409. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  3410. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  3411. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  3412. @param type A string representing the event type to listen for.<br>
  3413. See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events.
  3414. @param callback The callback that will be invoked when the event is dispatched.
  3415. The callback is ignored if it is a duplicate (the callbacks are unique).
  3416. @param target The target (this object) to invoke the callback, can be null
  3417. @param useCapture When set to true, the capture argument prevents callback
  3418. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  3419. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  3420. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  3421. @example
  3422. ```js
  3423. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  3424. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  3425. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  3426. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  3427. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  3428. node.on("anchor-changed", callback, this);
  3429. ```
  3430. */
  3431. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  3432. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  3433. /**
  3434. !#en
  3435. Removes the callback previously registered with the same type, callback, target and or useCapture.
  3436. This method is merely an alias to removeEventListener.
  3437. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  3438. @param type A string representing the event type being removed.
  3439. @param callback The callback to remove.
  3440. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  3441. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  3442. If not specified, useCapture defaults to false. If a callback was registered twice,
  3443. one with capture and one without, each must be removed separately. Removal of a capturing callback
  3444. does not affect a non-capturing version of the same listener, and vice versa.
  3445. @example
  3446. ```js
  3447. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  3448. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  3449. node.off("anchor-changed", callback, this);
  3450. ```
  3451. */
  3452. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  3453. /**
  3454. !#en Removes all callbacks previously registered with the same target.
  3455. !#zh 移除目标上的所有注册事件。
  3456. @param target The target to be searched for all related callbacks
  3457. @example
  3458. ```js
  3459. node.targetOff(target);
  3460. ```
  3461. */
  3462. targetOff(target: any): void;
  3463. /**
  3464. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  3465. 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.
  3466. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3467. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3468. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  3469. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3470. @param recursive Whether to pause node system events on the sub node tree.
  3471. @example
  3472. ```js
  3473. node.pauseSystemEvents(true);
  3474. ```
  3475. */
  3476. pauseSystemEvents(recursive: boolean): void;
  3477. /**
  3478. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  3479. 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.
  3480. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3481. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3482. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  3483. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3484. @param recursive Whether to resume node system events on the sub node tree.
  3485. @example
  3486. ```js
  3487. node.resumeSystemEvents(true);
  3488. ```
  3489. */
  3490. resumeSystemEvents(recursive: boolean): void;
  3491. /**
  3492. !#en
  3493. Executes an action, and returns the action that is executed.<br/>
  3494. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  3495. Calling runAction while the node is not active won't have any effect. <br/>
  3496. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  3497. if you want to modify, when you define action plus.
  3498. !#zh
  3499. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  3500. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  3501. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  3502. @param action action
  3503. @example
  3504. ```js
  3505. var action = cc.scaleTo(0.2, 1, 0.6);
  3506. node.runAction(action);
  3507. node.runAction(action).repeatForever(); // fail
  3508. node.runAction(action.repeatForever()); // right
  3509. ```
  3510. */
  3511. runAction(action: Action): Action;
  3512. /**
  3513. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  3514. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  3515. @example
  3516. ```js
  3517. node.pauseAllActions();
  3518. ```
  3519. */
  3520. pauseAllActions(): void;
  3521. /**
  3522. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  3523. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  3524. @example
  3525. ```js
  3526. node.resumeAllActions();
  3527. ```
  3528. */
  3529. resumeAllActions(): void;
  3530. /**
  3531. !#en Stops and removes all actions from the running action list .
  3532. !#zh 停止并且移除所有正在运行的动作列表。
  3533. @example
  3534. ```js
  3535. node.stopAllActions();
  3536. ```
  3537. */
  3538. stopAllActions(): void;
  3539. /**
  3540. !#en Stops and removes an action from the running action list.
  3541. !#zh 停止并移除指定的动作。
  3542. @param action An action object to be removed.
  3543. @example
  3544. ```js
  3545. var action = cc.scaleTo(0.2, 1, 0.6);
  3546. node.stopAction(action);
  3547. ```
  3548. */
  3549. stopAction(action: Action): void;
  3550. /**
  3551. !#en Removes an action from the running action list by its tag.
  3552. !#zh 停止并且移除指定标签的动作。
  3553. @param tag A tag that indicates the action to be removed.
  3554. @example
  3555. ```js
  3556. node.stopAction(1);
  3557. ```
  3558. */
  3559. stopActionByTag(tag: number): void;
  3560. /**
  3561. !#en Returns an action from the running action list by its tag.
  3562. !#zh 通过标签获取指定动作。
  3563. @param tag tag
  3564. @example
  3565. ```js
  3566. var action = node.getActionByTag(1);
  3567. ```
  3568. */
  3569. getActionByTag(tag: number): Action;
  3570. /**
  3571. !#en
  3572. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  3573. Composable actions are counted as 1 action. Example:<br/>
  3574. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  3575. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  3576. !#zh
  3577. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  3578. 例如:<br/>
  3579. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  3580. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  3581. @example
  3582. ```js
  3583. var count = node.getNumberOfRunningActions();
  3584. cc.log("Running Action Count: " + count);
  3585. ```
  3586. */
  3587. getNumberOfRunningActions(): number;
  3588. /**
  3589. !#en Returns a copy of the position (x, y) of the node in its parent's coordinates.
  3590. !#zh 获取节点在父节点坐标系中的位置(x, y)。
  3591. @example
  3592. ```js
  3593. cc.log("Node Position: " + node.getPosition());
  3594. ```
  3595. */
  3596. getPosition(): Vec2;
  3597. /**
  3598. !#en
  3599. Sets the position (x, y) of the node in its parent's coordinates.<br/>
  3600. Usually we use cc.v2(x, y) to compose cc.Vec2 object.<br/>
  3601. and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object.
  3602. !#zh
  3603. 设置节点在父节点坐标系中的位置。<br/>
  3604. 可以通过两种方式设置坐标点:<br/>
  3605. 1. 传入 2 个数值 x 和 y。<br/>
  3606. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
  3607. @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates
  3608. @param y Y coordinate for position
  3609. @example
  3610. ```js
  3611. node.setPosition(cc.v2(0, 0));
  3612. node.setPosition(0, 0);
  3613. ```
  3614. */
  3615. setPosition(newPosOrX: Vec2|number, y?: number): void;
  3616. /**
  3617. !#en
  3618. Returns the scale factor of the node.
  3619. Assertion will fail when _scaleX != _scaleY.
  3620. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  3621. @example
  3622. ```js
  3623. cc.log("Node Scale: " + node.getScale());
  3624. ```
  3625. */
  3626. getScale(): number;
  3627. /**
  3628. !#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.
  3629. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  3630. @param scaleX scaleX or scale
  3631. @param scaleY scaleY
  3632. @example
  3633. ```js
  3634. node.setScale(cc.v2(1, 1));
  3635. node.setScale(1, 1);
  3636. ```
  3637. */
  3638. setScale(scaleX: number|Vec2, scaleY?: number): void;
  3639. /**
  3640. !#en
  3641. Returns a copy the untransformed size of the node. <br/>
  3642. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3643. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  3644. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  3645. @param ignoreSizeProvider true if you need to get the original size of the node
  3646. @example
  3647. ```js
  3648. cc.log("Content Size: " + node.getContentSize());
  3649. ```
  3650. */
  3651. getContentSize(ignoreSizeProvider?: boolean): Size;
  3652. /**
  3653. !#en
  3654. Sets the untransformed size of the node.<br/>
  3655. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3656. All nodes has a size. Layer and Scene has the same size of the screen.
  3657. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  3658. @param size The untransformed size of the node or The untransformed size's width of the node.
  3659. @param height The untransformed size's height of the node.
  3660. @example
  3661. ```js
  3662. node.setContentSize(cc.size(100, 100));
  3663. node.setContentSize(100, 100);
  3664. ```
  3665. */
  3666. setContentSize(size: Size|number, height?: number): void;
  3667. /**
  3668. !#en
  3669. Set whether color should be changed with the opacity value,
  3670. useless in ccsg.Node, but this function is override in some class to have such behavior.
  3671. !#zh 设置更改透明度时是否修改RGB值,
  3672. @param opacityValue opacityValue
  3673. @example
  3674. ```js
  3675. node.setOpacityModifyRGB(true);
  3676. ```
  3677. */
  3678. setOpacityModifyRGB(opacityValue: boolean): void;
  3679. /**
  3680. !#en Get whether color should be changed with the opacity value.
  3681. !#zh 更改透明度时是否修改RGB值。
  3682. @example
  3683. ```js
  3684. var hasChange = node.isOpacityModifyRGB();
  3685. ```
  3686. */
  3687. isOpacityModifyRGB(): boolean;
  3688. /**
  3689. !#en
  3690. Returns a copy of the anchor point.<br/>
  3691. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  3692. It's like a pin in the node where it is "attached" to its parent. <br/>
  3693. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  3694. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  3695. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3696. !#zh
  3697. 获取节点锚点,用百分比表示。<br/>
  3698. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3699. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3700. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3701. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3702. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3703. @example
  3704. ```js
  3705. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  3706. ```
  3707. */
  3708. getAnchorPoint(): Vec2;
  3709. /**
  3710. !#en
  3711. Sets the anchor point in percent. <br/>
  3712. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  3713. It's like a pin in the node where it is "attached" to its parent. <br/>
  3714. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  3715. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  3716. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3717. !#zh
  3718. 设置锚点的百分比。<br/>
  3719. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3720. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3721. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3722. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3723. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3724. @param point The anchor point of node or The x axis anchor of node.
  3725. @param y The y axis anchor of node.
  3726. @example
  3727. ```js
  3728. node.setAnchorPoint(cc.v2(1, 1));
  3729. node.setAnchorPoint(1, 1);
  3730. ```
  3731. */
  3732. setAnchorPoint(point: Vec2|number, y?: number): void;
  3733. /**
  3734. !#en
  3735. Returns a copy of the anchor point in absolute pixels. <br/>
  3736. you can only read it. If you wish to modify it, use setAnchorPoint.
  3737. !#zh
  3738. 返回锚点的绝对像素位置。<br/>
  3739. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  3740. @example
  3741. ```js
  3742. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  3743. ```
  3744. */
  3745. getAnchorPointInPoints(): Vec2;
  3746. /**
  3747. !#en
  3748. Returns the displayed opacity of Node,
  3749. 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.
  3750. !#zh
  3751. 获取节点显示透明度,
  3752. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  3753. 显示透明度是基于自身透明度和父节点透明度计算的。
  3754. @example
  3755. ```js
  3756. var displayOpacity = node.getDisplayedOpacity();
  3757. ```
  3758. */
  3759. getDisplayedOpacity(): number;
  3760. /**
  3761. !#en
  3762. Returns the displayed color of Node,
  3763. 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.
  3764. !#zh
  3765. 获取节点的显示颜色,
  3766. 显示颜色和颜色之间的不同之处在于当启用级连颜色时,
  3767. 显示颜色是基于自身颜色和父节点颜色计算的。
  3768. @example
  3769. ```js
  3770. var displayColor = node.getDisplayedColor();
  3771. ```
  3772. */
  3773. getDisplayedColor(): Color;
  3774. /**
  3775. !#en
  3776. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3777. The matrix is in Pixels.<br/>
  3778. This method is AR (Anchor Relative).
  3779. !#zh
  3780. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  3781. 这个矩阵以像素为单位。<br/>
  3782. 该方法基于节点坐标。
  3783. @example
  3784. ```js
  3785. var affineTransform = node.getNodeToParentTransformAR();
  3786. ```
  3787. */
  3788. getNodeToParentTransformAR(): AffineTransform;
  3789. /**
  3790. !#en
  3791. Returns a "local" axis aligned bounding box of the node. <br/>
  3792. The returned box is relative only to its parent.
  3793. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  3794. @example
  3795. ```js
  3796. var boundingBox = node.getBoundingBox();
  3797. ```
  3798. */
  3799. getBoundingBox(): Rect;
  3800. /**
  3801. !#en
  3802. Returns a "world" axis aligned bounding box of the node.<br/>
  3803. The bounding box contains self and active children's world bounding box.
  3804. !#zh
  3805. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  3806. 该边框包含自身和已激活的子节点的世界边框。
  3807. @example
  3808. ```js
  3809. var newRect = node.getBoundingBoxToWorld();
  3810. ```
  3811. */
  3812. getBoundingBoxToWorld(): Rect;
  3813. /**
  3814. !#en
  3815. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3816. The matrix is in Pixels.
  3817. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  3818. @example
  3819. ```js
  3820. var affineTransform = node.getNodeToParentTransform();
  3821. ```
  3822. */
  3823. getNodeToParentTransform(): AffineTransform;
  3824. /**
  3825. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  3826. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  3827. @example
  3828. ```js
  3829. var affineTransform = node.getNodeToWorldTransform();
  3830. ```
  3831. */
  3832. getNodeToWorldTransform(): AffineTransform;
  3833. /**
  3834. !#en
  3835. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  3836. This method is AR (Anchor Relative).
  3837. !#zh
  3838. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  3839. 该方法基于节点坐标。
  3840. @example
  3841. ```js
  3842. var mat = node.getNodeToWorldTransformAR();
  3843. ```
  3844. */
  3845. getNodeToWorldTransformAR(): AffineTransform;
  3846. /**
  3847. !#en
  3848. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  3849. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  3850. !#zh
  3851. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  3852. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  3853. @example
  3854. ```js
  3855. var affineTransform = node.getParentToNodeTransform();
  3856. ```
  3857. */
  3858. getParentToNodeTransform(): AffineTransform;
  3859. /**
  3860. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  3861. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  3862. @example
  3863. ```js
  3864. var affineTransform = node.getWorldToNodeTransform();
  3865. ```
  3866. */
  3867. getWorldToNodeTransform(): AffineTransform;
  3868. /**
  3869. !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  3870. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  3871. @param worldPoint worldPoint
  3872. @example
  3873. ```js
  3874. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  3875. ```
  3876. */
  3877. convertToNodeSpace(worldPoint: Vec2): Vec2;
  3878. /**
  3879. !#en Converts a Point to world space coordinates. The result is in Points.
  3880. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  3881. @param nodePoint nodePoint
  3882. @example
  3883. ```js
  3884. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  3885. ```
  3886. */
  3887. convertToWorldSpace(nodePoint: Vec2): Vec2;
  3888. /**
  3889. !#en
  3890. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  3891. treating the returned/received node point as anchor relative.
  3892. !#zh
  3893. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  3894. 返回值将基于节点坐标。
  3895. @param worldPoint worldPoint
  3896. @example
  3897. ```js
  3898. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  3899. ```
  3900. */
  3901. convertToNodeSpaceAR(worldPoint: Vec2): Vec2;
  3902. /**
  3903. !#en
  3904. Converts a local Point to world space coordinates.The result is in Points.<br/>
  3905. treating the returned/received node point as anchor relative.
  3906. !#zh
  3907. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  3908. 返回值将基于世界坐标。
  3909. @param nodePoint nodePoint
  3910. @example
  3911. ```js
  3912. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  3913. ```
  3914. */
  3915. convertToWorldSpaceAR(nodePoint: Vec2): Vec2;
  3916. /**
  3917. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  3918. !#zh 将触摸点转换成本地坐标系中位置。
  3919. @param touch The touch object
  3920. @example
  3921. ```js
  3922. var newVec2 = node.convertTouchToNodeSpace(touch);
  3923. ```
  3924. */
  3925. convertTouchToNodeSpace(touch: Touch): Vec2;
  3926. /**
  3927. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  3928. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  3929. @param touch The touch object
  3930. @example
  3931. ```js
  3932. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  3933. ```
  3934. */
  3935. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  3936. /**
  3937. !#en
  3938. Adds a child to the node with z order and tag.
  3939. !#zh
  3940. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  3941. @param child A child node
  3942. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  3943. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  3944. @example
  3945. ```js
  3946. node.addChild(newNode, 1, 1001);
  3947. ```
  3948. */
  3949. addChild(child: Node, localZOrder?: number, tag?: number|string): void;
  3950. /**
  3951. !#en Stops all running actions and schedulers.
  3952. !#zh 停止所有正在播放的动作和计时器。
  3953. @example
  3954. ```js
  3955. node.cleanup();
  3956. ```
  3957. */
  3958. cleanup(): void;
  3959. /**
  3960. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  3961. normally you won't need to invoke this function.
  3962. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  3963. */
  3964. sortAllChildren(): void;
  3965. /** !#en The local scale relative to the parent.
  3966. !#zh 节点相对父节点的缩放。 */
  3967. scale: number;
  3968. /**
  3969. !#en Returns the x axis position of the node in cocos2d coordinates.
  3970. !#zh 获取节点 X 轴坐标。
  3971. @example
  3972. ```js
  3973. var posX = node.getPositionX();
  3974. ```
  3975. */
  3976. getPositionX(): number;
  3977. /**
  3978. !#en Sets the x axis position of the node in cocos2d coordinates.
  3979. !#zh 设置节点 X 轴坐标。
  3980. @param x x
  3981. @example
  3982. ```js
  3983. node.setPositionX(1);
  3984. ```
  3985. */
  3986. setPositionX(x: number): void;
  3987. /**
  3988. !#en Returns the y axis position of the node in cocos2d coordinates.
  3989. !#zh 获取节点 Y 轴坐标。
  3990. @example
  3991. ```js
  3992. var posY = node.getPositionY();
  3993. ```
  3994. */
  3995. getPositionY(): number;
  3996. /**
  3997. !#en Sets the y axis position of the node in cocos2d coordinates.
  3998. !#zh 设置节点 Y 轴坐标。
  3999. @param y The new position in y axis
  4000. @example
  4001. ```js
  4002. node.setPositionY(100);
  4003. ```
  4004. */
  4005. setPositionY(y: number): void;
  4006. /**
  4007. !#en Returns the local Z order of this node.
  4008. !#zh 获取节点局部 Z 轴顺序。
  4009. @example
  4010. ```js
  4011. var localZorder = node.getLocalZOrder();
  4012. ```
  4013. */
  4014. getLocalZOrder(): number;
  4015. /**
  4016. !#en
  4017. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  4018. <br/>
  4019. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  4020. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  4021. will be in front of the other node in the array. <br/>
  4022. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  4023. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  4024. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  4025. !#zh
  4026. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  4027. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  4028. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  4029. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  4030. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  4031. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  4032. @param localZOrder localZOrder
  4033. @example
  4034. ```js
  4035. node.setLocalZOrder(1);
  4036. ```
  4037. */
  4038. setLocalZOrder(localZOrder: number): void;
  4039. /**
  4040. !#en Returns whether node's opacity value affect its child nodes.
  4041. !#zh 返回节点的不透明度值是否影响其子节点。
  4042. @example
  4043. ```js
  4044. cc.log(node.isCascadeOpacityEnabled());
  4045. ```
  4046. */
  4047. isCascadeOpacityEnabled(): boolean;
  4048. /**
  4049. !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  4050. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  4051. @param cascadeOpacityEnabled cascadeOpacityEnabled
  4052. @example
  4053. ```js
  4054. node.setCascadeOpacityEnabled(true);
  4055. ```
  4056. */
  4057. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  4058. }
  4059. /** !#en
  4060. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  4061. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  4062. !#zh
  4063. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  4064. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  4065. export class Scene extends Node {
  4066. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  4067. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  4068. autoReleaseAssets: boolean;
  4069. }
  4070. /** !#en
  4071. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  4072. You should not use NSTimer. Instead use this class.<br/>
  4073. <br/>
  4074. There are 2 different types of callbacks (selectors):<br/>
  4075. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  4076. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  4077. <br/>
  4078. The 'custom selectors' should be avoided when possible. It is faster,
  4079. and consumes less memory to use the 'update callback'. *
  4080. !#zh
  4081. Scheduler 是负责触发回调函数的类。<br/>
  4082. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  4083. 有两种不同类型的定时器:<br/>
  4084. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  4085. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  4086. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  4087. export class Scheduler {
  4088. /**
  4089. !#en
  4090. Modifies the time of all scheduled callbacks.<br/>
  4091. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  4092. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  4093. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  4094. Note:It will affect EVERY scheduled selector / action.
  4095. !#zh
  4096. 设置时间间隔的缩放比例。<br/>
  4097. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  4098. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  4099. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  4100. 注意:它影响该 Scheduler 下管理的所有定时器。
  4101. @param timeScale timeScale
  4102. */
  4103. setTimeScale(timeScale: number): void;
  4104. /**
  4105. !#en Returns time scale of scheduler.
  4106. !#zh 获取时间间隔的缩放比例。
  4107. */
  4108. getTimeScale(): number;
  4109. /**
  4110. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  4111. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  4112. @param dt delta time
  4113. */
  4114. update(dt: number): void;
  4115. /**
  4116. !#en
  4117. <p>
  4118. The scheduled method will be called every 'interval' seconds.</br>
  4119. If paused is YES, then it won't be called until it is resumed.<br/>
  4120. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  4121. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  4122. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  4123. delay is the amount of time the action will wait before it'll start<br/>
  4124. </p>
  4125. !#zh
  4126. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  4127. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  4128. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  4129. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  4130. 建议使用 scheduleUpdateForTarget 代替。</br>
  4131. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  4132. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  4133. 可以让定时器一直循环触发。<br/>
  4134. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  4135. @param target target
  4136. @param callback_fn callback_fn
  4137. @param interval interval
  4138. @param repeat repeat
  4139. @param delay delay
  4140. @param paused paused
  4141. @example
  4142. ```js
  4143. //register a schedule to scheduler
  4144. var scheduler = cc.director.getScheduler();
  4145. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  4146. ```
  4147. */
  4148. scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4149. scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void;
  4150. /**
  4151. !#en The schedule
  4152. !#zh 定时器
  4153. @param callback callback
  4154. @param target target
  4155. @param interval interval
  4156. @param repeat repeat
  4157. @param delay delay
  4158. @param paused paused
  4159. @example
  4160. ```js
  4161. //register a schedule to scheduler
  4162. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  4163. ```
  4164. */
  4165. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4166. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  4167. /**
  4168. !#en
  4169. Schedules the update callback for a given target,
  4170. the callback will be invoked every frame after schedule started.
  4171. !#zh
  4172. 使用指定的优先级为指定的对象设置 update 定时器。
  4173. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  4174. @param target target
  4175. @param priority priority
  4176. @param paused paused
  4177. @param updateFunc updateFunc
  4178. */
  4179. scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void;
  4180. /**
  4181. !#en
  4182. Unschedules a callback for a callback and a given target.
  4183. If you want to unschedule the "update", use `unscheduleUpdate()`
  4184. !#zh
  4185. 根据指定的回调函数和调用对象。
  4186. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  4187. @param callback The callback to be unscheduled
  4188. @param target The target bound to the callback.
  4189. */
  4190. unschedule(callback: Function, target: any): void;
  4191. /**
  4192. !#en Unschedules the update callback for a given target.
  4193. !#zh 取消指定对象的 update 定时器。
  4194. @param target The target to be unscheduled.
  4195. */
  4196. unscheduleUpdate(target: any): void;
  4197. /**
  4198. !#en
  4199. Unschedules all scheduled callbacks for a given target.
  4200. This also includes the "update" callback.
  4201. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4202. @param target The target to be unscheduled.
  4203. */
  4204. unscheduleAllForTarget(target: any): void;
  4205. /**
  4206. !#en
  4207. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  4208. You should NEVER call this method, unless you know what you are doing.
  4209. !#zh
  4210. 取消所有对象的所有定时器,包括系统定时器。<br/>
  4211. 不用调用此函数,除非你确定你在做什么。
  4212. */
  4213. unscheduleAll(): void;
  4214. /**
  4215. !#en
  4216. Unschedules all callbacks from all targets with a minimum priority.<br/>
  4217. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  4218. !#zh
  4219. 取消所有优先级的值大于指定优先级的定时器。<br/>
  4220. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4221. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  4222. priority is higher than minPriority will be unscheduled.
  4223. */
  4224. unscheduleAllWithMinPriority(minPriority: number): void;
  4225. /**
  4226. !#en Checks whether a callback for a given target is scheduled.
  4227. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  4228. @param callback The callback to check.
  4229. @param target The target of the callback.
  4230. */
  4231. isScheduled(callback: Function, target: any): boolean;
  4232. /**
  4233. !#en
  4234. Pause all selectors from all targets.<br/>
  4235. You should NEVER call this method, unless you know what you are doing.
  4236. !#zh
  4237. 暂停所有对象的所有定时器。<br/>
  4238. 不要调用这个方法,除非你知道你正在做什么。
  4239. */
  4240. pauseAllTargets(): void;
  4241. /**
  4242. !#en
  4243. Pause all selectors from all targets with a minimum priority. <br/>
  4244. You should only call this with kCCPriorityNonSystemMin or higher.
  4245. !#zh
  4246. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  4247. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4248. @param minPriority minPriority
  4249. */
  4250. pauseAllTargetsWithMinPriority(minPriority: number): void;
  4251. /**
  4252. !#en
  4253. Resume selectors on a set of targets.<br/>
  4254. This can be useful for undoing a call to pauseAllCallbacks.
  4255. !#zh
  4256. 恢复指定数组中所有对象的定时器。<br/>
  4257. 这个函数是 pauseAllCallbacks 的逆操作。
  4258. @param targetsToResume targetsToResume
  4259. */
  4260. resumeTargets(targetsToResume: any[]): void;
  4261. /**
  4262. !#en
  4263. Pauses the target.<br/>
  4264. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  4265. If the target is not present, nothing happens.
  4266. !#zh
  4267. 暂停指定对象的定时器。<br/>
  4268. 指定对象的所有定时器都会被暂停。<br/>
  4269. 如果指定的对象没有定时器,什么也不会发生。
  4270. @param target target
  4271. */
  4272. pauseTarget(target: any): void;
  4273. /**
  4274. !#en
  4275. Resumes the target.<br/>
  4276. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  4277. If the target is not present, nothing happens.
  4278. !#zh
  4279. 恢复指定对象的所有定时器。<br/>
  4280. 指定对象的所有定时器将继续工作。<br/>
  4281. 如果指定的对象没有定时器,什么也不会发生。
  4282. @param target target
  4283. */
  4284. resumeTarget(target: any): void;
  4285. /**
  4286. !#en Returns whether or not the target is paused.
  4287. !#zh 返回指定对象的定时器是否暂停了。
  4288. @param target target
  4289. */
  4290. isTargetPaused(target: any): boolean;
  4291. /**
  4292. !#en
  4293. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  4294. The 'update' callback_fn will be called every frame.<br/>
  4295. The lower the priority, the earlier it is called.
  4296. !#zh
  4297. 为指定对象设置 update 定时器。<br/>
  4298. update 定时器每一帧都会被调用。<br/>
  4299. 优先级的值越低,越早被调用。
  4300. @param target target
  4301. @param priority priority
  4302. @param paused paused
  4303. @example
  4304. ```js
  4305. //register this object to scheduler
  4306. var scheduler = cc.director.getScheduler();
  4307. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  4308. ```
  4309. */
  4310. scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void;
  4311. /**
  4312. !#en
  4313. Unschedule a callback function for a given target.<br/>
  4314. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  4315. !#zh
  4316. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  4317. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  4318. @param target target
  4319. @param callback callback[Function] or key[String]
  4320. @example
  4321. ```js
  4322. //unschedule a callback of target
  4323. var scheduler = cc.director.getScheduler();
  4324. scheduler.unscheduleCallbackForTarget(this, callback);
  4325. ```
  4326. */
  4327. unscheduleCallbackForTarget(target: any, callback: Function): void;
  4328. /**
  4329. !#en Unschedules the update callback function for a given target.
  4330. !#zh 取消指定对象的所有定时器。
  4331. @param target target
  4332. @example
  4333. ```js
  4334. //unschedules the "update" method.
  4335. var scheduler = cc.director.getScheduler();
  4336. scheduler.unscheduleUpdateForTarget(this);
  4337. ```
  4338. */
  4339. unscheduleUpdateForTarget(target: any): void;
  4340. /**
  4341. !#en
  4342. Unschedules all function callbacks for a given target.<br/>
  4343. This also includes the "update" callback function.
  4344. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4345. @param target target
  4346. */
  4347. unscheduleAllCallbacksForTarget(target: any): void;
  4348. /**
  4349. !#en
  4350. Unschedules all function callbacks from all targets. <br/>
  4351. You should NEVER call this method, unless you know what you are doing.
  4352. !#zh
  4353. 取消所有对象的所有定时器。<br/>
  4354. 不要调用这个方法,除非你知道你正在做什么。
  4355. */
  4356. unscheduleAllCallbacks(): void;
  4357. /**
  4358. !#en
  4359. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  4360. You should only call this with kCCPriorityNonSystemMin or higher.
  4361. !#zh
  4362. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  4363. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4364. @param minPriority minPriority
  4365. */
  4366. unscheduleAllCallbacksWithMinPriority(minPriority: number): void;
  4367. /** !#en Priority level reserved for system services.
  4368. !#zh 系统服务的优先级。 */
  4369. static PRIORITY_SYSTEM: number;
  4370. /** !#en Minimum priority level for user scheduling.
  4371. !#zh 用户调度最低优先级。 */
  4372. static PRIORITY_NON_SYSTEM: number;
  4373. }
  4374. /** !#en
  4375. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  4376. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  4377. length and color. The fadeTime controls how long it takes each vertex in <br/>
  4378. the streak to fade out, the minimum segment size it how many pixels the <br/>
  4379. streak will move before adding a new ribbon segment, and the texture <br/>
  4380. length is the how many pixels the texture is stretched across. The texture <br/>
  4381. is vertically aligned along the streak segment.
  4382. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  4383. export class MotionStreak extends Component {
  4384. /** !#en
  4385. !#zh 在编辑器模式下预览拖尾效果。 */
  4386. preview: boolean;
  4387. /** !#en The fade time to fade.
  4388. !#zh 拖尾的渐隐时间,以秒为单位。 */
  4389. fadeTime: number;
  4390. /** !#en The minimum segment size.
  4391. !#zh 拖尾之间最小距离。 */
  4392. minSeg: number;
  4393. /** !#en The stroke's width.
  4394. !#zh 拖尾的宽度。 */
  4395. stroke: number;
  4396. /** !#en The texture of the MotionStreak.
  4397. !#zh 拖尾的贴图。 */
  4398. texture: Texture2D;
  4399. /** !#en The color of the MotionStreak.
  4400. !#zh 拖尾的颜色 */
  4401. color: Color;
  4402. /** !#en The fast Mode.
  4403. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  4404. fastMode: boolean;
  4405. /**
  4406. !#en Remove all living segments of the ribbon.
  4407. !#zh 删除当前所有的拖尾片段。
  4408. @example
  4409. ```js
  4410. // stop particle system.
  4411. myParticleSystem.stopSystem();
  4412. ```
  4413. */
  4414. reset(): void;
  4415. }
  4416. /** Particle System base class. <br/>
  4417. Attributes of a Particle System:<br/>
  4418. - emmision rate of the particles<br/>
  4419. - Gravity Mode (Mode A): <br/>
  4420. - gravity <br/>
  4421. - direction <br/>
  4422. - speed +- variance <br/>
  4423. - tangential acceleration +- variance<br/>
  4424. - radial acceleration +- variance<br/>
  4425. - Radius Mode (Mode B): <br/>
  4426. - startRadius +- variance <br/>
  4427. - endRadius +- variance <br/>
  4428. - rotate +- variance <br/>
  4429. - Properties common to all modes: <br/>
  4430. - life +- life variance <br/>
  4431. - start spin +- variance <br/>
  4432. - end spin +- variance <br/>
  4433. - start size +- variance <br/>
  4434. - end size +- variance <br/>
  4435. - start color +- variance <br/>
  4436. - end color +- variance <br/>
  4437. - life +- variance <br/>
  4438. - blending function <br/>
  4439. - texture <br/>
  4440. <br/>
  4441. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  4442. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  4443. cocos2d uses a another approach, but the results are almost identical.<br/>
  4444. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  4445. - spinning particles (supported when using ParticleSystem) <br/>
  4446. - tangential acceleration (Gravity mode) <br/>
  4447. - radial acceleration (Gravity mode) <br/>
  4448. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  4449. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  4450. export class ParticleSystem extends _RendererUnderSG {
  4451. /** !#en Play particle in edit mode.
  4452. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  4453. preview: boolean;
  4454. /** !#en
  4455. If set custom to true, then use custom properties insteadof read particle file.
  4456. !#zh 是否自定义粒子属性。 */
  4457. custom: boolean;
  4458. /** !#en The plist file.
  4459. !#zh plist 格式的粒子配置文件。 */
  4460. file: string;
  4461. /** . */
  4462. texture: Texture2D;
  4463. /** !#en Current quantity of particles that are being simulated.
  4464. !#zh 当前播放的粒子数量。 */
  4465. particleCount: number;
  4466. /** !#en Specify the source Blend Factor.
  4467. !#zh 指定原图混合模式。 */
  4468. srcBlendFactor: BlendFactor;
  4469. /** !#en Specify the destination Blend Factor.
  4470. !#zh 指定目标的混合模式。 */
  4471. dstBlendFactor: BlendFactor;
  4472. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  4473. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  4474. playOnLoad: boolean;
  4475. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  4476. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  4477. autoRemoveOnFinish: boolean;
  4478. /** !#en Indicate whether the particle system is activated.
  4479. !#zh 是否激活粒子。 */
  4480. active: boolean;
  4481. /** !#en Maximum particles of the system.
  4482. !#zh 粒子最大数量。 */
  4483. totalParticles: number;
  4484. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  4485. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  4486. duration: number;
  4487. /** !#en Emission rate of the particles.
  4488. !#zh 每秒发射的粒子数目。 */
  4489. emissionRate: number;
  4490. /** !#en Life of each particle setter.
  4491. !#zh 粒子的运行时间。 */
  4492. life: number;
  4493. /** !#en Variation of life.
  4494. !#zh 粒子的运行时间变化范围。 */
  4495. lifeVar: number;
  4496. /** !#en Start color of each particle.
  4497. !#zh 粒子初始颜色。 */
  4498. startColor: Color;
  4499. /** !#en Variation of the start color.
  4500. !#zh 粒子初始颜色变化范围。 */
  4501. startColorVar: Color;
  4502. /** !#en Ending color of each particle.
  4503. !#zh 粒子结束颜色。 */
  4504. endColor: Color;
  4505. /** !#en Variation of the end color.
  4506. !#zh 粒子结束颜色变化范围。 */
  4507. endColorVar: Color;
  4508. /** !#en Angle of each particle setter.
  4509. !#zh 粒子角度。 */
  4510. angle: number;
  4511. /** !#en Variation of angle of each particle setter.
  4512. !#zh 粒子角度变化范围。 */
  4513. angleVar: number;
  4514. /** !#en Start size in pixels of each particle.
  4515. !#zh 粒子的初始大小。 */
  4516. startSize: number;
  4517. /** !#en Variation of start size in pixels.
  4518. !#zh 粒子初始大小的变化范围。 */
  4519. startSizeVar: number;
  4520. /** !#en End size in pixels of each particle.
  4521. !#zh 粒子结束时的大小。 */
  4522. endSize: number;
  4523. /** !#en Variation of end size in pixels.
  4524. !#zh 粒子结束大小的变化范围。 */
  4525. endSizeVar: number;
  4526. /** !#en Start angle of each particle.
  4527. !#zh 粒子开始自旋角度。 */
  4528. startSpin: number;
  4529. /** !#en Variation of start angle.
  4530. !#zh 粒子开始自旋角度变化范围。 */
  4531. startSpinVar: number;
  4532. /** !#en End angle of each particle.
  4533. !#zh 粒子结束自旋角度。 */
  4534. endSpin: number;
  4535. /** !#en Variation of end angle.
  4536. !#zh 粒子结束自旋角度变化范围。 */
  4537. endSpinVar: number;
  4538. /** !#en Source position of the emitter.
  4539. !#zh 发射器位置。 */
  4540. sourcePos: Vec2;
  4541. /** !#en Variation of source position.
  4542. !#zh 发射器位置的变化范围。(横向和纵向) */
  4543. posVar: Vec2;
  4544. /** !#en Particles movement type.
  4545. !#zh 粒子位置类型。 */
  4546. positionType: ParticleSystem.PositionType;
  4547. /** !#en Particles emitter modes.
  4548. !#zh 发射器类型。 */
  4549. emitterMode: ParticleSystem.EmitterMode;
  4550. /** !#en Gravity of the emitter.
  4551. !#zh 重力。 */
  4552. gravity: Vec2;
  4553. /** !#en Speed of the emitter.
  4554. !#zh 速度。 */
  4555. speed: number;
  4556. /** !#en Variation of the speed.
  4557. !#zh 速度变化范围。 */
  4558. speedVar: number;
  4559. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  4560. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  4561. tangentialAccel: number;
  4562. /** !#en Variation of the tangential acceleration.
  4563. !#zh 每个粒子的切向加速度变化范围。 */
  4564. tangentialAccelVar: number;
  4565. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  4566. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  4567. radialAccel: number;
  4568. /** !#en Variation of the radial acceleration.
  4569. !#zh 粒子径向加速度变化范围。 */
  4570. radialAccelVar: number;
  4571. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  4572. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  4573. rotationIsDir: boolean;
  4574. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  4575. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  4576. startRadius: number;
  4577. /** !#en Variation of the starting radius.
  4578. !#zh 初始半径变化范围。 */
  4579. startRadiusVar: number;
  4580. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  4581. !#zh 结束半径,只有在半径模式下可用。 */
  4582. endRadius: number;
  4583. /** !#en Variation of the ending radius.
  4584. !#zh 结束半径变化范围。 */
  4585. endRadiusVar: number;
  4586. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  4587. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  4588. rotatePerS: number;
  4589. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  4590. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  4591. rotatePerSVar: number;
  4592. /** !#en The Particle emitter lives forever.
  4593. !#zh 表示发射器永久存在 */
  4594. static DURATION_INFINITY: number;
  4595. /** !#en The starting size of the particle is equal to the ending size.
  4596. !#zh 表示粒子的起始大小等于结束大小。 */
  4597. static START_SIZE_EQUAL_TO_END_SIZE: number;
  4598. /** !#en The starting radius of the particle is equal to the ending radius.
  4599. !#zh 表示粒子的起始半径等于结束半径。 */
  4600. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  4601. /**
  4602. !#en Add a particle to the emitter.
  4603. !#zh 添加一个粒子到发射器中。
  4604. */
  4605. addParticle(): boolean;
  4606. /**
  4607. !#en Stop emitting particles. Running particles will continue to run until they die.
  4608. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  4609. @example
  4610. ```js
  4611. // stop particle system.
  4612. myParticleSystem.stopSystem();
  4613. ```
  4614. */
  4615. stopSystem(): void;
  4616. /**
  4617. !#en Kill all living particles.
  4618. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  4619. @example
  4620. ```js
  4621. // play particle system.
  4622. myParticleSystem.resetSystem();
  4623. ```
  4624. */
  4625. resetSystem(): void;
  4626. /**
  4627. !#en Whether or not the system is full.
  4628. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  4629. */
  4630. isFull(): boolean;
  4631. /**
  4632. !#en
  4633. <p> Sets a new CCSpriteFrame as particle.</br>
  4634. WARNING: this method is experimental. Use setTextureWithRect instead.
  4635. </p>
  4636. !#zh
  4637. <p> 设置一个新的精灵帧为粒子。</br>
  4638. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  4639. </p>
  4640. @param spriteFrame spriteFrame
  4641. */
  4642. setDisplayFrame(spriteFrame: SpriteFrame): void;
  4643. /**
  4644. !#en Sets a new texture with a rect. The rect is in texture position and size.
  4645. !#zh 设置一张新贴图和关联的矩形。
  4646. @param texture texture
  4647. @param rect rect
  4648. */
  4649. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  4650. }
  4651. /** !#en Renders the TMX object.
  4652. !#zh 渲染 tmx object。 */
  4653. export class TMXObject {
  4654. /**
  4655. !#en Get the name of object
  4656. !#zh 获取对象的名称
  4657. */
  4658. getObjectName(): string;
  4659. /**
  4660. !#en Get the property of object
  4661. !#zh 获取对象的属性
  4662. @param propertyName propertyName
  4663. */
  4664. getProperty(propertyName: string): any;
  4665. /**
  4666. !#en Get the properties of object
  4667. !#zh 获取对象的属性
  4668. */
  4669. getProperties(): any;
  4670. /**
  4671. !#en Set the object name
  4672. !#zh 设置对象名称
  4673. @param name name
  4674. */
  4675. setObjectName(name: string): void;
  4676. /**
  4677. !#en Set the properties of the object
  4678. !#zh 设置对象的属性
  4679. @param props props
  4680. */
  4681. setProperties(props: any): void;
  4682. }
  4683. /** !#en Render the TMX layer.
  4684. !#zh 渲染 TMX layer。 */
  4685. export class TiledLayer extends _SGComponent {
  4686. /**
  4687. !#en Gets the layer name.
  4688. !#zh 获取层的名称。
  4689. @example
  4690. ```js
  4691. var layerName = tiledLayer.getLayerName();
  4692. cc.log(layerName);
  4693. ```
  4694. */
  4695. getLayerName(): string;
  4696. /**
  4697. !#en Set the layer name.
  4698. !#zh 设置层的名称
  4699. @param layerName layerName
  4700. @example
  4701. ```js
  4702. tiledLayer.setLayerName("New Layer");
  4703. ```
  4704. */
  4705. SetLayerName(layerName: string): void;
  4706. /**
  4707. !#en Return the value for the specific property name.
  4708. !#zh 获取指定属性名的值。
  4709. @param propertyName propertyName
  4710. @example
  4711. ```js
  4712. var property = tiledLayer.getProperty("info");
  4713. cc.log(property);
  4714. ```
  4715. */
  4716. getProperty(propertyName: string): any;
  4717. /**
  4718. !#en Returns the position in pixels of a given tile coordinate.
  4719. !#zh 获取指定 tile 的像素坐标。
  4720. @param pos position or x
  4721. @param y y
  4722. @example
  4723. ```js
  4724. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  4725. cc.log("Pos: " + pos);
  4726. var pos = tiledLayer.getPositionAt(0, 0);
  4727. cc.log("Pos: " + pos);
  4728. ```
  4729. */
  4730. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  4731. /**
  4732. !#en Removes a tile at given tile coordinate.
  4733. !#zh 删除指定坐标上的 tile。
  4734. @param pos position or x
  4735. @param y y
  4736. @example
  4737. ```js
  4738. tiledLayer.removeTileAt(cc.v2(0, 0));
  4739. tiledLayer.removeTileAt(0, 0);
  4740. ```
  4741. */
  4742. removeTileAt(pos: Vec2|number, y?: number): void;
  4743. /**
  4744. !#en
  4745. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  4746. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  4747. If a tile is already placed at that position, then it will be removed.
  4748. !#zh
  4749. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  4750. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  4751. 如果一个 tile 已经放在那个位置,那么它将被删除。
  4752. @param gid gid
  4753. @param posOrX position or x
  4754. @param flagsOrY flags or y
  4755. @param flags flags
  4756. @example
  4757. ```js
  4758. tiledLayer.setTileGID(1001, 10, 10, 1)
  4759. ```
  4760. */
  4761. setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  4762. /**
  4763. !#en
  4764. Returns the tile gid at a given tile coordinate. <br />
  4765. if it returns 0, it means that the tile is empty. <br />
  4766. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  4767. !#zh
  4768. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  4769. 如果它返回 0,则表示该 tile 为空。<br />
  4770. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  4771. @param pos or x
  4772. @param y y
  4773. @example
  4774. ```js
  4775. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  4776. ```
  4777. */
  4778. getTileGIDAt(pos: Vec2|number, y?: number): number;
  4779. /**
  4780. !#en
  4781. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  4782. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  4783. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  4784. You can remove either by calling: <br/>
  4785. - layer.removeChild(sprite, cleanup); <br/>
  4786. - or layer.removeTileAt(ccp(x,y));
  4787. !#zh
  4788. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  4789. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  4790. 你可以通过调用以下方法来对它进行删除:<br/>
  4791. 1. layer.removeChild(sprite, cleanup);<br/>
  4792. 2. 或 layer.removeTileAt(cc.v2(x,y));
  4793. @param pos or x
  4794. @param y y
  4795. @example
  4796. ```js
  4797. var title = tiledLayer.getTileAt(100, 100);
  4798. cc.log(title);
  4799. ```
  4800. */
  4801. getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite;
  4802. /**
  4803. !#en
  4804. Dealloc the map that contains the tile position from memory. <br />
  4805. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  4806. If you are going to call layer.getTileGIDAt() then, don't release the map.
  4807. !#zh
  4808. 从内存中释放包含 tile 位置信息的地图。<br />
  4809. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  4810. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  4811. @example
  4812. ```js
  4813. tiledLayer.releaseMap();
  4814. ```
  4815. */
  4816. releaseMap(): void;
  4817. /**
  4818. !#en Sets the untransformed size of the _ccsg.TMXLayer.
  4819. !#zh 设置未转换的 layer 大小。
  4820. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  4821. @param height The untransformed size's height of the _ccsg.TMXLayer.
  4822. @example
  4823. ```js
  4824. tiledLayer.setContentSize(100, 100);
  4825. ```
  4826. */
  4827. setContentSize(size: Size|number, height?: number): void;
  4828. /**
  4829. !#en Return texture of cc.SpriteBatchNode.
  4830. !#zh 获取纹理。
  4831. @example
  4832. ```js
  4833. var texture = tiledLayer.getTexture();
  4834. cc.log("Texture: " + texture);
  4835. ```
  4836. */
  4837. getTexture(): Texture2D;
  4838. /**
  4839. !#en Set the texture of cc.SpriteBatchNode.
  4840. !#zh 设置纹理。
  4841. @param texture texture
  4842. @example
  4843. ```js
  4844. tiledLayer.setTexture(texture);
  4845. ```
  4846. */
  4847. setTexture(texture: Texture2D): void;
  4848. /**
  4849. !#en Set the opacity of all tiles
  4850. !#zh 设置所有 Tile 的透明度
  4851. @param opacity opacity
  4852. @example
  4853. ```js
  4854. tiledLayer.setTileOpacity(128);
  4855. ```
  4856. */
  4857. setTileOpacity(opacity: number): void;
  4858. /**
  4859. !#en Gets layer size.
  4860. !#zh 获得层大小。
  4861. @example
  4862. ```js
  4863. var size = tiledLayer.getLayerSize();
  4864. cc.log("layer size: " + size);
  4865. ```
  4866. */
  4867. getLayerSize(): Size;
  4868. /**
  4869. !#en Set layer size.
  4870. !#zh 设置层大小。
  4871. @param layerSize layerSize
  4872. @example
  4873. ```js
  4874. tiledLayer.setLayerSize(new cc.size(5, 5));
  4875. ```
  4876. */
  4877. setLayerSize(layerSize: Size): void;
  4878. /**
  4879. !#en Size of the map's tile (could be different from the tile's size).
  4880. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  4881. @example
  4882. ```js
  4883. var mapTileSize = tiledLayer.getMapTileSize();
  4884. cc.log("MapTile size: " + mapTileSize);
  4885. ```
  4886. */
  4887. getMapTileSize(): Size;
  4888. /**
  4889. !#en Set the map tile size.
  4890. !#zh 设置 tile 的大小。
  4891. @param tileSize tileSize
  4892. @example
  4893. ```js
  4894. tiledLayer.setMapTileSize(new cc.size(10, 10));
  4895. ```
  4896. */
  4897. setMapTileSize(tileSize: Size): void;
  4898. /**
  4899. !#en Pointer to the map of tiles.
  4900. !#zh 获取地图 tiles。
  4901. @example
  4902. ```js
  4903. var tiles = tiledLayer.getTiles();
  4904. ```
  4905. */
  4906. getTiles(): any[];
  4907. /**
  4908. !#en Pointer to the map of tiles.
  4909. !#zh 设置地图 tiles
  4910. @param tiles tiles
  4911. @example
  4912. ```js
  4913. tiledLayer.setTiles(tiles);
  4914. ```
  4915. */
  4916. setTiles(tiles: any[]): void;
  4917. /**
  4918. !#en Tile set information for the layer.
  4919. !#zh 获取 layer 的 Tileset 信息。
  4920. @example
  4921. ```js
  4922. var tileset = tiledLayer.getTileSet();
  4923. ```
  4924. */
  4925. getTileSet(): TMXTilesetInfo;
  4926. /**
  4927. !#en Tile set information for the layer.
  4928. !#zh 设置 layer 的 Tileset 信息。
  4929. @param tileset tileset
  4930. @example
  4931. ```js
  4932. tiledLayer.setTileSet(tileset);
  4933. ```
  4934. */
  4935. setTileSet(tileset: TMXTilesetInfo): void;
  4936. /**
  4937. !#en Layer orientation, which is the same as the map orientation.
  4938. !#zh 获取 Layer 方向(同地图方向)。
  4939. @example
  4940. ```js
  4941. var orientation = tiledLayer.getLayerOrientation();
  4942. cc.log("Layer Orientation: " + orientation);
  4943. ```
  4944. */
  4945. getLayerOrientation(): number;
  4946. /**
  4947. !#en Layer orientation, which is the same as the map orientation.
  4948. !#zh 设置 Layer 方向(同地图方向)。
  4949. @param orientation orientation
  4950. @example
  4951. ```js
  4952. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  4953. ```
  4954. */
  4955. setLayerOrientation(orientation: TiledMap.Orientation): void;
  4956. /**
  4957. !#en properties from the layer. They can be added using Tiled.
  4958. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  4959. @example
  4960. ```js
  4961. var properties = tiledLayer.getProperties();
  4962. cc.log("Properties: " + properties);
  4963. ```
  4964. */
  4965. getProperties(): any[];
  4966. /**
  4967. !#en properties from the layer. They can be added using Tiled.
  4968. !#zh 设置层属性。
  4969. @param properties properties
  4970. @example
  4971. ```js
  4972. tiledLayer.setLayerOrientation(properties);
  4973. ```
  4974. */
  4975. setProperties(properties: any[]): void;
  4976. }
  4977. /** !#en Renders a TMX Tile Map in the scene.
  4978. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  4979. export class TiledMap extends Component {
  4980. /** !#en The TiledMap Asset.
  4981. !#zh TiledMap 资源。 */
  4982. tmxAsset: TiledMapAsset;
  4983. /**
  4984. !#en Gets the map size.
  4985. !#zh 获取地图大小。
  4986. @example
  4987. ```js
  4988. var mapSize = tiledMap.getMapSize();
  4989. cc.log("Map Size: " + mapSize);
  4990. ```
  4991. */
  4992. getMapSize(): Size;
  4993. /**
  4994. !#en Set the map size.
  4995. !#zh 设置地图大小。
  4996. @param mapSize mapSize
  4997. @example
  4998. ```js
  4999. tiledMap.setMapSize(new cc.size(960, 640));
  5000. ```
  5001. */
  5002. setMapSize(mapSize: Size): void;
  5003. /**
  5004. !#en Gets the tile size.
  5005. !#zh 获取地图背景中 tile 元素的大小。
  5006. @example
  5007. ```js
  5008. var tileSize = tiledMap.getTileSize();
  5009. cc.log("Tile Size: " + tileSize);
  5010. ```
  5011. */
  5012. getTileSize(): Size;
  5013. /**
  5014. !#en Set the tile size.
  5015. !#zh 设置地图背景中 tile 元素的大小。
  5016. @param tileSize tileSize
  5017. @example
  5018. ```js
  5019. tiledMap.setTileSize(new cc.size(10, 10));
  5020. ```
  5021. */
  5022. setTileSize(tileSize: Size): void;
  5023. /**
  5024. !#en map orientation.
  5025. !#zh 获取地图方向。
  5026. @example
  5027. ```js
  5028. var mapOrientation = tiledMap.getMapOrientation();
  5029. cc.log("Map Orientation: " + mapOrientation);
  5030. ```
  5031. */
  5032. getMapOrientation(): number;
  5033. /**
  5034. !#en map orientation.
  5035. !#zh 设置地图方向。
  5036. @param orientation orientation
  5037. @example
  5038. ```js
  5039. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  5040. ```
  5041. */
  5042. setMapOrientation(orientation: TiledMap.Orientation): void;
  5043. /**
  5044. !#en object groups.
  5045. !#zh 获取所有的对象层。
  5046. @example
  5047. ```js
  5048. var objGroups = titledMap.getObjectGroups();
  5049. for (var i = 0; i < objGroups.length; ++i) {
  5050. cc.log("obj: " + objGroups[i]);
  5051. }
  5052. ```
  5053. */
  5054. getObjectGroups(): TiledObjectGroup[];
  5055. /**
  5056. !#en Gets the map properties.
  5057. !#zh 获取地图的属性。
  5058. @example
  5059. ```js
  5060. var properties = titledMap.getProperties();
  5061. for (var i = 0; i < properties.length; ++i) {
  5062. cc.log("Properties: " + properties[i]);
  5063. }
  5064. ```
  5065. */
  5066. getProperties(): any[];
  5067. /**
  5068. !#en Set the map properties.
  5069. !#zh 设置地图的属性。
  5070. @param properties properties
  5071. @example
  5072. ```js
  5073. titledMap.setProperties(properties);
  5074. ```
  5075. */
  5076. setProperties(properties: any[]): void;
  5077. /**
  5078. !#en Return All layers array.
  5079. !#zh 返回包含所有 layer 的数组。
  5080. @example
  5081. ```js
  5082. var layers = titledMap.allLayers();
  5083. for (var i = 0; i < layers.length; ++i) {
  5084. cc.log("Layers: " + layers[i]);
  5085. }
  5086. ```
  5087. */
  5088. allLayers(): TiledLayer[];
  5089. /**
  5090. !#en return the cc.TiledLayer for the specific layer.
  5091. !#zh 获取指定名称的 layer。
  5092. @param layerName layerName
  5093. @example
  5094. ```js
  5095. var layer = titledMap.getLayer("Player");
  5096. cc.log(layer);
  5097. ```
  5098. */
  5099. getLayer(layerName: string): TiledLayer;
  5100. /**
  5101. !#en Return the TMXObjectGroup for the specific group.
  5102. !#zh 获取指定的 TMXObjectGroup。
  5103. @param groupName groupName
  5104. @example
  5105. ```js
  5106. var group = titledMap.getObjectGroup("Players");
  5107. cc.log("ObjectGroup: " + group);
  5108. ```
  5109. */
  5110. getObjectGroup(groupName: string): TiledObjectGroup;
  5111. /**
  5112. !#en Return the value for the specific property name.
  5113. !#zh 通过属性名称,获取指定的属性。
  5114. @param propertyName propertyName
  5115. @example
  5116. ```js
  5117. var property = titledMap.getProperty("info");
  5118. cc.log("Property: " + property);
  5119. ```
  5120. */
  5121. getProperty(propertyName: string): string;
  5122. /**
  5123. !#en Return properties dictionary for tile GID.
  5124. !#zh 通过 GID ,获取指定的属性。
  5125. @param GID GID
  5126. @example
  5127. ```js
  5128. var properties = titledMap.getPropertiesForGID(GID);
  5129. cc.log("Properties: " + properties);
  5130. ```
  5131. */
  5132. getPropertiesForGID(GID: number): any;
  5133. }
  5134. /** Class for tiled map asset handling. */
  5135. export class TiledMapAsset extends Asset {
  5136. }
  5137. /** !#en Renders the TMX object group.
  5138. !#zh 渲染 tmx object group。 */
  5139. export class TiledObjectGroup extends _SGComponent {
  5140. /**
  5141. !#en Offset position of child objects.
  5142. !#zh 获取子对象的偏移位置。
  5143. @example
  5144. ```js
  5145. var offset = tMXObjectGroup.getPositionOffset();
  5146. ```
  5147. */
  5148. getPositionOffset(): Vec2;
  5149. /**
  5150. !#en Offset position of child objects.
  5151. !#zh 设置子对象的偏移位置。
  5152. @param offset offset
  5153. @example
  5154. ```js
  5155. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  5156. ```
  5157. */
  5158. setPositionOffset(offset: Vec2): void;
  5159. /**
  5160. !#en List of properties stored in a dictionary.
  5161. !#zh 以映射的形式获取属性列表。
  5162. @example
  5163. ```js
  5164. var offset = tMXObjectGroup.getProperties();
  5165. ```
  5166. */
  5167. getProperties(): any;
  5168. /**
  5169. !#en Set the properties of the object group.
  5170. !#zh 设置属性列表。
  5171. @param Var Var
  5172. @example
  5173. ```js
  5174. tMXObjectGroup.setProperties(obj);
  5175. ```
  5176. */
  5177. setProperties(Var: any): void;
  5178. /**
  5179. !#en Gets the Group name.
  5180. !#zh 获取组名称。
  5181. @example
  5182. ```js
  5183. var groupName = tMXObjectGroup.getGroupName;
  5184. ```
  5185. */
  5186. getGroupName(): string;
  5187. /**
  5188. !#en Set the Group name.
  5189. !#zh 设置组名称。
  5190. @param groupName groupName
  5191. @example
  5192. ```js
  5193. tMXObjectGroup.setGroupName("New Group");
  5194. ```
  5195. */
  5196. setGroupName(groupName: string): void;
  5197. /**
  5198. !#en
  5199. Return the object for the specific object name. <br />
  5200. It will return the 1st object found on the array for the given name.
  5201. !#zh 获取指定的对象。
  5202. @param objectName objectName
  5203. @example
  5204. ```js
  5205. var object = tMXObjectGroup.getObject("Group");
  5206. ```
  5207. */
  5208. getObject(objectName: string): any;
  5209. /**
  5210. !#en Gets the objects.
  5211. !#zh 获取对象数组。
  5212. @example
  5213. ```js
  5214. var objects = tMXObjectGroup.getObjects();
  5215. ```
  5216. */
  5217. getObjects(): any[];
  5218. }
  5219. /** !#en
  5220. cc.NodePool is the cache pool designed for node type.<br/>
  5221. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5222. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  5223. for example, a prefab is a specific node type. <br/>
  5224. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  5225. Some common use case is :<br/>
  5226. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  5227. 2. Blocks in candy crash (massive creation and recreation)<br/>
  5228. etc...
  5229. !#zh
  5230. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  5231. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  5232. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  5233. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  5234. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  5235. 一些常见的用例是:<br/>
  5236. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  5237. 2.糖果粉碎传奇中的木块(频繁创建)。
  5238. 等等.... */
  5239. export class NodePool {
  5240. /**
  5241. !#en
  5242. 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.
  5243. !#zh
  5244. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  5245. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  5246. @example
  5247. ```js
  5248. properties: {
  5249. template: cc.Prefab
  5250. },
  5251. onLoad () {
  5252. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  5253. this.myPool = new cc.NodePool('MyTemplateHandler');
  5254. }
  5255. ```
  5256. */
  5257. constructor(poolHandlerComp?: {prototype: Component}|string);
  5258. /** !#en The pool handler component, it could be the class name or the constructor.
  5259. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  5260. poolHandlerComp: Function|string;
  5261. /**
  5262. !#en The current available size in the pool
  5263. !#zh 获取当前缓冲池的可用对象数量
  5264. */
  5265. size(): number;
  5266. /**
  5267. !#en Destroy all cached nodes in the pool
  5268. !#zh 销毁对象池中缓存的所有节点
  5269. */
  5270. clear(): void;
  5271. /**
  5272. !#en Put a new Node into the pool.
  5273. It will automatically remove the node from its parent without cleanup.
  5274. It will also invoke unuse method of the poolHandlerComp if exist.
  5275. !#zh 向缓冲池中存入一个不再需要的节点对象。
  5276. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  5277. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  5278. @param obj obj
  5279. @example
  5280. ```js
  5281. let myNode = cc.instantiate(this.template);
  5282. this.myPool.put(myNode);
  5283. ```
  5284. */
  5285. put(obj: Node): void;
  5286. /**
  5287. !#en Get a obj from pool, if no available object in pool, null will be returned.
  5288. This function will invoke the reuse function of poolHandlerComp if exist.
  5289. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  5290. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  5291. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  5292. @example
  5293. ```js
  5294. let newNode = this.myPool.get();
  5295. ```
  5296. */
  5297. get(...params: any[]): Node;
  5298. }
  5299. /** !#en
  5300. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  5301. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  5302. cc.pool is a singleton object serves as an object cache pool.<br/>
  5303. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5304. !#zh
  5305. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  5306. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  5307. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  5308. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  5309. export class pool {
  5310. /**
  5311. !#en Put the obj in pool.
  5312. !#zh 加入对象到对象池中。
  5313. @param obj The need put in pool object.
  5314. @example
  5315. ```js
  5316. ---------------------------------
  5317. var sp = new _ccsg.Sprite("a.png");
  5318. this.addChild(sp);
  5319. cc.pool.putInPool(sp);
  5320. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  5321. ```
  5322. */
  5323. putInPool(obj: any): void;
  5324. /**
  5325. !#en Check if this kind of obj has already in pool.
  5326. !#zh 检查对象池中是否有指定对象的存在。
  5327. @param objClass The check object class.
  5328. */
  5329. hasObject(objClass: any): boolean;
  5330. /**
  5331. !#en Remove the obj if you want to delete it.
  5332. !#zh 移除在对象池中指定的对象。
  5333. */
  5334. removeObject(): void;
  5335. /**
  5336. !#en Get the obj from pool.
  5337. !#zh 获取对象池中的指定对象。
  5338. */
  5339. getFromPool(): any;
  5340. /**
  5341. !#en Remove all objs in pool and reset the pool.
  5342. !#zh 移除对象池中的所有对象,并且重置对象池。
  5343. */
  5344. drainAllPools(): void;
  5345. }
  5346. /** !#en Box Collider.
  5347. !#zh 包围盒碰撞组件 */
  5348. export class BoxCollider extends Collider implements Collider.Box {
  5349. /** !#en Position offset
  5350. !#zh 位置偏移量 */
  5351. offset: Vec2;
  5352. /** !#en Box size
  5353. !#zh 包围盒大小 */
  5354. size: Size;
  5355. }
  5356. /** !#en Circle Collider.
  5357. !#zh 圆形碰撞组件 */
  5358. export class CircleCollider extends Collider implements Collider.Circle {
  5359. /** !#en Position offset
  5360. !#zh 位置偏移量 */
  5361. offset: Vec2;
  5362. /** !#en Circle radius
  5363. !#zh 圆形半径 */
  5364. radius: number;
  5365. }
  5366. /** !#en Collider component base class.
  5367. !#zh 碰撞组件基类 */
  5368. export class Collider extends Component {
  5369. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  5370. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  5371. tag: number;
  5372. }
  5373. /** !#en
  5374. A simple collision manager class.
  5375. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  5376. !#zh
  5377. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  5378. export class CollisionManager implements EventTarget {
  5379. /** !#en
  5380. !#zh
  5381. 是否开启碰撞管理,默认为不开启 */
  5382. enabled: boolean;
  5383. /** !#en
  5384. !#zh
  5385. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  5386. enabledDrawBoundingBox: boolean;
  5387. /** !#en
  5388. !#zh
  5389. 是否绘制碰撞组件的形状,默认为不绘制 */
  5390. enabledDebugDraw: boolean;
  5391. /**
  5392. !#en
  5393. Register an callback of a specific event type on the EventTarget.
  5394. !#zh
  5395. 注册事件目标的特定事件类型回调。
  5396. @param type A string representing the event type to listen for.
  5397. @param callback The callback that will be invoked when the event is dispatched.
  5398. The callback is ignored if it is a duplicate (the callbacks are unique).
  5399. @param target The target (this object) to invoke the callback, can be null
  5400. @param useCapture When set to true, the capture argument prevents callback
  5401. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5402. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5403. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5404. @example
  5405. ```js
  5406. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5407. cc.log("this is callback");
  5408. }, node);
  5409. ```
  5410. */
  5411. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5412. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5413. /**
  5414. !#en
  5415. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5416. if only type is passed as parameter, all listeners registered with that type will be removed.
  5417. !#zh
  5418. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5419. @param type A string representing the event type being removed.
  5420. @param callback The callback to remove.
  5421. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5422. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5423. If not specified, useCapture defaults to false. If a callback was registered twice,
  5424. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5425. does not affect a non-capturing version of the same listener, and vice versa.
  5426. @example
  5427. ```js
  5428. // register touchEnd eventListener
  5429. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5430. cc.log("this is callback");
  5431. }, node);
  5432. // remove touch end event listener
  5433. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5434. // remove all touch end event listeners
  5435. node.off(cc.Node.EventType.TOUCH_END);
  5436. ```
  5437. */
  5438. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5439. /**
  5440. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5441. This is not for removing all listeners in the current event target,
  5442. and this is not for removing all listeners the target parameter have registered.
  5443. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5444. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5445. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5446. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5447. @param target The target to be searched for all related listeners
  5448. */
  5449. targetOff(target: any): void;
  5450. /**
  5451. !#en
  5452. Register an callback of a specific event type on the EventTarget,
  5453. the callback will remove itself after the first time it is triggered.
  5454. !#zh
  5455. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5456. @param type A string representing the event type to listen for.
  5457. @param callback The callback that will be invoked when the event is dispatched.
  5458. The callback is ignored if it is a duplicate (the callbacks are unique).
  5459. @param target The target (this object) to invoke the callback, can be null
  5460. @param useCapture When set to true, the capture argument prevents callback
  5461. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5462. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5463. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5464. @example
  5465. ```js
  5466. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5467. cc.log("this is callback");
  5468. }, node);
  5469. ```
  5470. */
  5471. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5472. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5473. /**
  5474. !#en
  5475. Dispatches an event into the event flow.
  5476. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5477. !#zh 分发事件到事件流中。
  5478. @param event The Event object that is dispatched into the event flow
  5479. */
  5480. dispatchEvent(event: Event): void;
  5481. /**
  5482. !#en
  5483. Send an event to this object directly, this method will not propagate the event to any other objects.
  5484. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5485. !#zh
  5486. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5487. @param message the message to send
  5488. @param detail whatever argument the message needs
  5489. */
  5490. emit(message: string, detail?: any): void;
  5491. }
  5492. /** !#en Intersection helper class
  5493. !#zh 辅助类,用于测试形状与形状是否相交 */
  5494. export class Intersection {
  5495. /**
  5496. !#en Test line and line
  5497. !#zh 测试线段与线段是否相交
  5498. @param a1 The start point of the first line
  5499. @param a2 The end point of the first line
  5500. @param b1 The start point of the second line
  5501. @param b2 The end point of the second line
  5502. */
  5503. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  5504. /**
  5505. !#en Test line and rect
  5506. !#zh 测试线段与矩形是否相交
  5507. @param a1 The start point of the line
  5508. @param a2 The end point of the line
  5509. @param b The rect
  5510. */
  5511. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  5512. /**
  5513. !#en Test line and polygon
  5514. !#zh 测试线段与多边形是否相交
  5515. @param a1 The start point of the line
  5516. @param a2 The end point of the line
  5517. @param b The polygon, a set of points
  5518. */
  5519. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  5520. /**
  5521. !#en Test rect and rect
  5522. !#zh 测试矩形与矩形是否相交
  5523. @param a The first rect
  5524. @param b The second rect
  5525. */
  5526. static rectRect(a: Rect, b: Rect): boolean;
  5527. /**
  5528. !#en Test rect and polygon
  5529. !#zh 测试矩形与多边形是否相交
  5530. @param a The rect
  5531. @param b The polygon, a set of points
  5532. */
  5533. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  5534. /**
  5535. !#en Test polygon and polygon
  5536. !#zh 测试多边形与多边形是否相交
  5537. @param a The first polygon, a set of points
  5538. @param b The second polygon, a set of points
  5539. */
  5540. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  5541. /**
  5542. !#en Test circle and circle
  5543. !#zh 测试圆形与圆形是否相交
  5544. @param a Object contains position and radius
  5545. @param b Object contains position and radius
  5546. */
  5547. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  5548. /**
  5549. !#en Test polygon and circle
  5550. !#zh 测试矩形与圆形是否相交
  5551. @param polygon The Polygon, a set of points
  5552. @param circle Object contains position and radius
  5553. */
  5554. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  5555. /**
  5556. !#en Test whether the point is in the polygon
  5557. !#zh 测试一个点是否在一个多边形中
  5558. @param point The point
  5559. @param polygon The polygon, a set of points
  5560. */
  5561. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  5562. /**
  5563. !#en Calculate the distance of point to line.
  5564. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  5565. @param point The point
  5566. @param start The start point of line
  5567. @param end The end point of line
  5568. @param isSegment whether this line is a segment
  5569. */
  5570. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean;
  5571. }
  5572. /** !#en Polygon Collider.
  5573. !#zh 多边形碰撞组件 */
  5574. export class PolygonCollider extends Collider implements Collider.Polygon {
  5575. /** !#en Position offset
  5576. !#zh 位置偏移量 */
  5577. offset: Vec2;
  5578. /** !#en Polygon points
  5579. !#zh 多边形顶点数组 */
  5580. points: [Vec2];
  5581. }
  5582. /** !#en
  5583. Base class for handling assets used in Fireball. This class can be instantiate.
  5584. You may want to override:<br/>
  5585. - createNode<br/>
  5586. - cc.Object._serialize<br/>
  5587. - cc.Object._deserialize<br/>
  5588. !#zh
  5589. 资源基类,该类可以被实例化。<br/>
  5590. 您可能需要重写:<br/>
  5591. - createNode <br/>
  5592. - cc.Object._serialize<br/>
  5593. - cc.Object._deserialize<br/> */
  5594. export class Asset extends RawAsset {
  5595. /** !#en
  5596. Returns the url of this asset's first raw file, if none of rawFile exists,
  5597. it will returns an empty string.
  5598. !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */
  5599. rawUrl: string;
  5600. /** !#en
  5601. Returns the url of this asset's raw files, if none of rawFile exists,
  5602. it will returns an empty array.
  5603. !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */
  5604. rawUrls: string[];
  5605. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  5606. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  5607. static preventDeferredLoadDependents: boolean;
  5608. /**
  5609. !#en
  5610. Create a new node using this asset in the scene.<br/>
  5611. If this type of asset dont have its corresponding node type, this method should be null.
  5612. !#zh
  5613. 使用该资源在场景中创建一个新节点。<br/>
  5614. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5615. @param callback callback
  5616. */
  5617. createNode(callback: (error: string, node: any) => void): void;
  5618. }
  5619. /** !#en Class for audio data handling.
  5620. !#zh 音频资源类。 */
  5621. export class AudioClip extends RawAsset {
  5622. }
  5623. /** !#en Class for BitmapFont handling.
  5624. !#zh 位图字体资源类。 */
  5625. export class BitmapFont extends RawAsset {
  5626. }
  5627. /** !#en Class for Font handling.
  5628. !#zh 字体资源类。 */
  5629. export class Font extends RawAsset {
  5630. }
  5631. /** !#en Class for LabelAtlas handling.
  5632. !#zh 艺术数字字体资源类。 */
  5633. export class LabelAtlas extends BitmapFont {
  5634. }
  5635. /** !#en Class for prefab handling.
  5636. !#zh 预制资源类。 */
  5637. export class Prefab extends Asset {
  5638. /** the main cc.Node in the prefab */
  5639. data: Node;
  5640. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  5641. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  5642. asyncLoadAssets: boolean;
  5643. /**
  5644. Dynamically translation prefab data into minimized code.<br/>
  5645. This method will be called automatically before the first time the prefab being instantiated,
  5646. but you can re-call to refresh the create function once you modified the original prefab data in script.
  5647. */
  5648. compileCreateFunction(): void;
  5649. }
  5650. /** !#en
  5651. The base class for registering asset types.
  5652. You may want to override:
  5653. - createNode (static)
  5654. !#zh
  5655. 注册用的资源基类。<br/>
  5656. 你可能要重写:<br/>
  5657. - createNode (static) */
  5658. export class RawAsset extends Object {
  5659. /**
  5660. !#en
  5661. Create a new node in the scene.<br/>
  5662. If this type of asset dont have its corresponding node type, this method should be null.
  5663. !#zh
  5664. 在场景中创建一个新节点。<br/>
  5665. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5666. @param Info Info
  5667. @param callback callback
  5668. */
  5669. static createNodeByInfo(Info: any, callback: (error: string, node: any) => void): void;
  5670. }
  5671. /** !#en Class for scene handling.
  5672. !#zh 场景资源类。 */
  5673. export class SceneAsset extends Asset {
  5674. scene: Scene;
  5675. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  5676. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  5677. asyncLoadAssets: boolean;
  5678. }
  5679. /** !#en Class for script handling.
  5680. !#zh Script 资源类。 */
  5681. export class _Script extends Asset {
  5682. }
  5683. /** !#en Class for JavaScript handling.
  5684. !#zh JavaScript 资源类。 */
  5685. export class _JavaScript extends Asset {
  5686. }
  5687. /** !#en Class for coffeescript handling.
  5688. !#zh CoffeeScript 资源类。 */
  5689. export class CoffeeScript extends Asset {
  5690. }
  5691. /** !#en Class for TypeScript handling.
  5692. !#zh TypeScript 资源类。 */
  5693. export class TypeScript extends Asset {
  5694. }
  5695. /** !#en Class for sprite atlas handling.
  5696. !#zh 精灵图集资源类。 */
  5697. export class SpriteAtlas extends RawAsset {
  5698. /**
  5699. Returns the texture of the sprite atlas
  5700. */
  5701. getTexture(): Texture2D;
  5702. /**
  5703. Returns the sprite frame correspond to the given key in sprite atlas.
  5704. @param key key
  5705. */
  5706. getSpriteFrame(key: string): SpriteFrame;
  5707. /**
  5708. Returns the sprite frames in sprite atlas.
  5709. */
  5710. getSpriteFrames(): [SpriteFrame];
  5711. }
  5712. /** !#en Class for TTFFont handling.
  5713. !#zh TTF 字体资源类。 */
  5714. export class TTFFont extends Asset {
  5715. }
  5716. /** !#en Class for text file.
  5717. !#zh 文本资源类。 */
  5718. export class TextAsset extends Asset {
  5719. }
  5720. /** !#en
  5721. Camera is usefull when making reel game or other games which need scroll screen.
  5722. Using camera will be more efficient than moving node to scroll screen.
  5723. Camera
  5724. !#zh
  5725. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5726. export class Camera extends _RendererUnderSG {
  5727. /** !#en
  5728. The camera zoom ratio.
  5729. !#zh
  5730. 摄像机缩放比率 */
  5731. zoomRatio: number;
  5732. /** !#en
  5733. Current active camera, the scene should only have one active camera at the same time.
  5734. !#zh
  5735. 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */
  5736. static main: Camera;
  5737. /**
  5738. !#en
  5739. Add the specified target to camera.
  5740. !#zh
  5741. 将指定的节点添加到摄像机中。
  5742. @param target target
  5743. */
  5744. addTarget(target: Node): void;
  5745. /**
  5746. !#en
  5747. Remove the specified target from camera.
  5748. !#zh
  5749. 将指定的节点从摄像机中移除。
  5750. @param target target
  5751. */
  5752. removeTarget(target: Node): void;
  5753. /**
  5754. !#en
  5755. Get all camera targets.
  5756. !#zh
  5757. 获取所有摄像机目标节点。
  5758. */
  5759. getTargets(): [Node];
  5760. /**
  5761. !#en
  5762. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5763. !#zh
  5764. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5765. @param node the node which should transform
  5766. */
  5767. getNodeToCameraTransform(node: Node): AffineTransform;
  5768. /**
  5769. !#en
  5770. Conver a camera coordinates point to world coordinates.
  5771. !#zh
  5772. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5773. @param point the point which should transform
  5774. */
  5775. getCameraToWorldPoint(point: Node): Vec2;
  5776. /**
  5777. !#en
  5778. Check whether the node is in the camera.
  5779. !#zh
  5780. 检测节点是否被此摄像机影响
  5781. @param node the node which need to check
  5782. */
  5783. containsNode(node: Node): boolean;
  5784. }
  5785. /** !#en The animation component is used to play back animations.
  5786. Animation provide several events to register:
  5787. - play : Emit when begin playing animation
  5788. - stop : Emit when stop playing animation
  5789. - pause : Emit when pause animation
  5790. - resume : Emit when resume animation
  5791. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  5792. - finished : Emit when finish playing animation
  5793. !#zh Animation 组件用于播放动画。
  5794. Animation 提供了一系列可注册的事件:
  5795. - play : 开始播放时
  5796. - stop : 停止播放时
  5797. - pause : 暂停播放时
  5798. - resume : 恢复播放时
  5799. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  5800. - finished : 动画播放完成时 */
  5801. export class Animation extends Component implements EventTarget {
  5802. /** !#en Animation will play the default clip when start game.
  5803. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  5804. defaultClip: AnimationClip;
  5805. /** !#en Current played clip.
  5806. !#zh 当前播放的动画剪辑。 */
  5807. currentClip: AnimationClip;
  5808. /** !#en Whether the animation should auto play the default clip when start game.
  5809. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  5810. playOnLoad: boolean;
  5811. /**
  5812. !#en Get all the clips used in this animation.
  5813. !#zh 获取动画组件上的所有动画剪辑。
  5814. */
  5815. getClips(): AnimationClip[];
  5816. /**
  5817. !#en Plays an animation and stop other animations.
  5818. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  5819. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5820. @param startTime play an animation from startTime
  5821. @example
  5822. ```js
  5823. var animCtrl = this.node.getComponent(cc.Animation);
  5824. animCtrl.play("linear");
  5825. ```
  5826. */
  5827. play(name?: string, startTime?: number): AnimationState;
  5828. /**
  5829. !#en
  5830. Plays an additive animation, it will not stop other animations.
  5831. If there are other animations playing, then will play several animations at the same time.
  5832. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  5833. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5834. @param startTime play an animation from startTime
  5835. @example
  5836. ```js
  5837. // linear_1 and linear_2 at the same time playing.
  5838. var animCtrl = this.node.getComponent(cc.Animation);
  5839. animCtrl.playAdditive("linear_1");
  5840. animCtrl.playAdditive("linear_2");
  5841. ```
  5842. */
  5843. playAdditive(name?: string, startTime?: number): AnimationState;
  5844. /**
  5845. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  5846. Stopping an animation also Rewinds it to the Start.
  5847. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  5848. @param name The animation to stop, if not supplied then stops all playing animations.
  5849. */
  5850. stop(name?: string): void;
  5851. /**
  5852. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  5853. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  5854. @param name The animation to pauses, if not supplied then pauses all playing animations.
  5855. */
  5856. pause(name?: string): void;
  5857. /**
  5858. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  5859. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  5860. @param name The animation to resumes, if not supplied then resumes all paused animations.
  5861. */
  5862. resume(name?: string): void;
  5863. /**
  5864. !#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.
  5865. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  5866. @param time The time to go to
  5867. @param name Specified animation name, if not supplied then make all animations go to the time.
  5868. */
  5869. setCurrentTime(time?: number, name?: string): void;
  5870. /**
  5871. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  5872. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  5873. @param name name
  5874. */
  5875. getAnimationState(name: string): AnimationState;
  5876. /**
  5877. !#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.
  5878. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  5879. @param clip the clip to add
  5880. @param newName newName
  5881. */
  5882. addClip(clip: AnimationClip, newName?: string): AnimationState;
  5883. /**
  5884. !#en
  5885. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  5886. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  5887. 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
  5888. !#zh
  5889. 从动画列表中移除指定的动画剪辑,<br/>
  5890. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  5891. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  5892. @param clip clip
  5893. @param force If force is true, then will always remove the clip and any animation states based on it.
  5894. */
  5895. removeClip(clip: AnimationClip, force?: boolean): void;
  5896. /**
  5897. !#en
  5898. Samples animations at the current state.<br/>
  5899. This is useful when you explicitly want to set up some animation state, and sample it once.
  5900. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  5901. @param name name
  5902. */
  5903. sample(name: string): void;
  5904. /**
  5905. !#en
  5906. Register animation event callback.
  5907. The event arguments will provide the AnimationState which emit the event.
  5908. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  5909. !#zh
  5910. 注册动画事件回调。
  5911. 回调的事件里将会附上发送事件的 AnimationState。
  5912. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  5913. @param type A string representing the event type to listen for.
  5914. @param callback The callback that will be invoked when the event is dispatched.
  5915. The callback is ignored if it is a duplicate (the callbacks are unique).
  5916. @param target The target (this object) to invoke the callback, can be null
  5917. @param useCapture When set to true, the capture argument prevents callback
  5918. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5919. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5920. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5921. @example
  5922. ```js
  5923. onPlay: function (event) {
  5924. var state = event.detail; // state instanceof cc.AnimationState
  5925. var type = event.type; // type === 'play';
  5926. }
  5927. // register event to all animation
  5928. animation.on('play', this.onPlay, this);
  5929. ```
  5930. */
  5931. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5932. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5933. /**
  5934. !#en
  5935. Unregister animation event callback.
  5936. !#zh
  5937. 取消注册动画事件回调。
  5938. @param type A string representing the event type being removed.
  5939. @param callback The callback to remove.
  5940. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5941. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5942. If not specified, useCapture defaults to false. If a callback was registered twice,
  5943. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5944. does not affect a non-capturing version of the same listener, and vice versa.
  5945. @example
  5946. ```js
  5947. // unregister event to all animation
  5948. animation.off('play', this.onPlay, this);
  5949. ```
  5950. */
  5951. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  5952. /**
  5953. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5954. This is not for removing all listeners in the current event target,
  5955. and this is not for removing all listeners the target parameter have registered.
  5956. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5957. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5958. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5959. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5960. @param target The target to be searched for all related listeners
  5961. */
  5962. targetOff(target: any): void;
  5963. /**
  5964. !#en
  5965. Register an callback of a specific event type on the EventTarget,
  5966. the callback will remove itself after the first time it is triggered.
  5967. !#zh
  5968. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5969. @param type A string representing the event type to listen for.
  5970. @param callback The callback that will be invoked when the event is dispatched.
  5971. The callback is ignored if it is a duplicate (the callbacks are unique).
  5972. @param target The target (this object) to invoke the callback, can be null
  5973. @param useCapture When set to true, the capture argument prevents callback
  5974. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5975. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5976. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5977. @example
  5978. ```js
  5979. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5980. cc.log("this is callback");
  5981. }, node);
  5982. ```
  5983. */
  5984. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5985. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5986. /**
  5987. !#en
  5988. Dispatches an event into the event flow.
  5989. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5990. !#zh 分发事件到事件流中。
  5991. @param event The Event object that is dispatched into the event flow
  5992. */
  5993. dispatchEvent(event: Event): void;
  5994. /**
  5995. !#en
  5996. Send an event to this object directly, this method will not propagate the event to any other objects.
  5997. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5998. !#zh
  5999. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  6000. @param message the message to send
  6001. @param detail whatever argument the message needs
  6002. */
  6003. emit(message: string, detail?: any): void;
  6004. }
  6005. /** !#en Audio Source.
  6006. !#zh 音频源组件,能对音频剪辑。 */
  6007. export class AudioSource extends Component {
  6008. /** !#en
  6009. Is the audio source playing (Read Only). <br/>
  6010. Note: isPlaying is not supported for Native platforms.
  6011. !#zh
  6012. 该音频剪辑是否正播放(只读)。<br/>
  6013. 注意:Native 平台暂时不支持 isPlaying。 */
  6014. isPlaying: boolean;
  6015. /** !#en The clip of the audio source.
  6016. !#zh 默认要播放的音频剪辑。 */
  6017. clip: AudioClip;
  6018. /** !#en The volume of the audio source.
  6019. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  6020. volume: number;
  6021. /** !#en Is the audio source mute?
  6022. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  6023. mute: boolean;
  6024. /** !#en Is the audio source looping?
  6025. !#zh 音频源是否循环播放? */
  6026. loop: boolean;
  6027. /** !#en If set to true, the audio source will automatically start playing on onLoad.
  6028. !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */
  6029. playOnLoad: boolean;
  6030. /**
  6031. !#en Plays the clip.
  6032. !#zh 播放音频剪辑。
  6033. */
  6034. play(): void;
  6035. /**
  6036. !#en Stops the clip.
  6037. !#zh 停止当前音频剪辑。
  6038. */
  6039. stop(): void;
  6040. /**
  6041. !#en Pause the clip.
  6042. !#zh 暂停当前音频剪辑。
  6043. */
  6044. pause(): void;
  6045. /**
  6046. !#en Resume the clip.
  6047. !#zh 恢复播放。
  6048. */
  6049. resume(): void;
  6050. /**
  6051. !#en Rewind playing music.
  6052. !#zh 从头开始播放。
  6053. */
  6054. rewind(): void;
  6055. /**
  6056. !#en Get current time
  6057. !#zh 获取当前的播放时间
  6058. */
  6059. getCurrentTime(): void;
  6060. /**
  6061. !#en Set current time
  6062. !#zh 设置当前的播放时间
  6063. @param time time
  6064. */
  6065. setCurrentTime(time: number): void;
  6066. /**
  6067. !#en Get audio duration
  6068. !#zh 获取当前音频的长度
  6069. */
  6070. getDuration(): void;
  6071. }
  6072. /** !#en
  6073. 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>
  6074. This component does not have any API interface and can be added directly to the scene to take effect.
  6075. !#zh
  6076. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6077. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6078. export class BlockInputEvents extends Component {
  6079. }
  6080. /** !#en
  6081. Button has 4 Transition types
  6082. When Button state changed:
  6083. If Transition type is Button.Transition.NONE, Button will do nothing
  6084. If Transition type is Button.Transition.COLOR, Button will change target's color
  6085. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6086. If Transition type is Button.Transition.SCALE, Button will change target node's scale
  6087. Button will trigger 5 events:
  6088. Button.EVENT_TOUCH_DOWN
  6089. Button.EVENT_TOUCH_UP
  6090. Button.EVENT_HOVER_IN
  6091. Button.EVENT_HOVER_MOVE
  6092. Button.EVENT_HOVER_OUT
  6093. !#zh
  6094. 按钮组件。可以被按下,或者点击。</br>
  6095. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:</br>
  6096. -Button.Transition.NONE // 不做任何过渡</br>
  6097. -Button.Transition.COLOR // 进行颜色之间过渡</br>
  6098. -Button.Transition.SPRITE // 进行精灵之间过渡</br>
  6099. -Button.Transition.SCALE // 进行缩放过渡</br>
  6100. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):</br>
  6101. // 以下事件可以在全平台上都触发</br>
  6102. -cc.Node.EventType.TOUCH_START // 按下时事件</br>
  6103. -cc.Node.EventType.TOUCH_Move // 按住移动后事件</br>
  6104. -cc.Node.EventType.TOUCH_END // 按下后松开后事件</br>
  6105. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件</br>
  6106. // 以下事件只在 PC 平台上触发</br>
  6107. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件</br>
  6108. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件</br>
  6109. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件</br>
  6110. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件</br>
  6111. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件</br>
  6112. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件</br> */
  6113. export class Button extends Component {
  6114. /** !#en
  6115. Whether the Button is disabled.
  6116. If true, the Button will trigger event and do transition.
  6117. !#zh
  6118. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6119. interactable: boolean;
  6120. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6121. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6122. enableAutoGrayEffect: boolean;
  6123. /** !#en Transition type
  6124. !#zh 按钮状态改变时过渡方式。 */
  6125. transition: Button.Transition;
  6126. /** !#en Normal state color.
  6127. !#zh 普通状态下按钮所显示的颜色。 */
  6128. normalColor: Color;
  6129. /** !#en Pressed state color
  6130. !#zh 按下状态时按钮所显示的颜色。 */
  6131. pressedColor: Color;
  6132. /** !#en Hover state color
  6133. !#zh 悬停状态下按钮所显示的颜色。 */
  6134. hoverColor: Color;
  6135. /** !#en Disabled state color
  6136. !#zh 禁用状态下按钮所显示的颜色。 */
  6137. disabledColor: Color;
  6138. /** !#en Color and Scale transition duration
  6139. !#zh 颜色过渡和缩放过渡时所需时间 */
  6140. duration: number;
  6141. /** !#en When user press the button, the button will zoom to a scale.
  6142. The final scale of the button equals (button original scale * zoomScale)
  6143. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6144. zoomScale: number;
  6145. /** !#en Normal state sprite
  6146. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6147. normalSprite: SpriteFrame;
  6148. /** !#en Pressed state sprite
  6149. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6150. pressedSprite: SpriteFrame;
  6151. /** !#en Hover state sprite
  6152. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6153. hoverSprite: SpriteFrame;
  6154. /** !#en Disabled state sprite
  6155. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6156. disabledSprite: SpriteFrame;
  6157. /** !#en
  6158. Transition target.
  6159. When Button state changed:
  6160. If Transition type is Button.Transition.NONE, Button will do nothing
  6161. If Transition type is Button.Transition.COLOR, Button will change target's color
  6162. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6163. !#zh
  6164. 需要过渡的目标。
  6165. 当前按钮状态改变规则:
  6166. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6167. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6168. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6169. target: Node;
  6170. /** !#en If Button is clicked, it will trigger event's handler
  6171. !#zh 按钮的点击事件列表。 */
  6172. clickEvents: Component.EventHandler[];
  6173. }
  6174. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  6175. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6176. export class Canvas extends Component {
  6177. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6178. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6179. static instance: Canvas;
  6180. /** !#en The desigin resolution for current scene.
  6181. !#zh 当前场景设计分辨率。 */
  6182. designResolution: Size;
  6183. /** !#en TODO
  6184. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6185. fitHeight: boolean;
  6186. /** !#en TODO
  6187. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6188. fitWidth: boolean;
  6189. }
  6190. /** !#en
  6191. Base class for everything attached to Node(Entity).<br/>
  6192. <br/>
  6193. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6194. because Component is created by the engine.
  6195. !#zh
  6196. 所有附加到节点的基类。<br/>
  6197. <br/>
  6198. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6199. export class Component extends Object {
  6200. /** !#en The node this component is attached to. A component is always attached to a node.
  6201. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6202. node: Node;
  6203. /** !#en The uuid for editor.
  6204. !#zh 组件的 uuid,用于编辑器。 */
  6205. uuid: string;
  6206. /** !#en indicates whether this component is enabled or not.
  6207. !#zh 表示该组件自身是否启用。 */
  6208. enabled: boolean;
  6209. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6210. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6211. enabledInHierarchy: boolean;
  6212. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6213. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6214. _isOnLoadCalled: number;
  6215. /**
  6216. !#en Update is called every frame, if the Component is enabled.
  6217. !#zh 如果该组件启用,则每帧调用 update。
  6218. @param dt the delta time in seconds it took to complete the last frame
  6219. */
  6220. protected update(dt: number): void;
  6221. /**
  6222. !#en LateUpdate is called every frame, if the Component is enabled.
  6223. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  6224. */
  6225. protected lateUpdate(): void;
  6226. /**
  6227. !#en
  6228. When attaching to an active node or its node first activated.
  6229. onLoad is always called before any start functions, this allows you to order initialization of scripts.
  6230. !#zh
  6231. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
  6232. */
  6233. protected onLoad(): void;
  6234. /**
  6235. !#en
  6236. Called before all scripts' update if the Component is enabled the first time.
  6237. Usually used to initialize some logic which need to be called after all components' `onload` methods called.
  6238. !#zh
  6239. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
  6240. */
  6241. protected start(): void;
  6242. /**
  6243. !#en Called when this component becomes enabled and its node is active.
  6244. !#zh 当该组件被启用,并且它的节点也激活时。
  6245. */
  6246. protected onEnable(): void;
  6247. /**
  6248. !#en Called when this component becomes disabled or its node becomes inactive.
  6249. !#zh 当该组件被禁用或节点变为无效时调用。
  6250. */
  6251. protected onDisable(): void;
  6252. /**
  6253. !#en Called when this component will be destroyed.
  6254. !#zh 当该组件被销毁时调用
  6255. */
  6256. protected onDestroy(): void;
  6257. protected onFocusInEditor(): void;
  6258. protected onLostFocusInEditor(): void;
  6259. /**
  6260. !#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.
  6261. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6262. */
  6263. protected resetInEditor(): void;
  6264. /**
  6265. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6266. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6267. @param typeOrClassName the constructor or the class name of the component to add
  6268. @example
  6269. ```js
  6270. var sprite = node.addComponent(cc.Sprite);
  6271. var test = node.addComponent("Test");
  6272. ```
  6273. */
  6274. addComponent<T extends Component>(type: {new(): T}): T;
  6275. addComponent(className: string): any;
  6276. /**
  6277. !#en
  6278. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6279. You can also get component in the node by passing in the name of the script.
  6280. !#zh
  6281. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6282. 传入参数也可以是脚本的名称。
  6283. @param typeOrClassName typeOrClassName
  6284. @example
  6285. ```js
  6286. // get sprite component.
  6287. var sprite = node.getComponent(cc.Sprite);
  6288. // get custom test calss.
  6289. var test = node.getComponent("Test");
  6290. ```
  6291. */
  6292. getComponent<T extends Component>(type: {prototype: T}): T;
  6293. getComponent(className: string): any;
  6294. /**
  6295. !#en Returns all components of supplied Type in the node.
  6296. !#zh 返回节点上指定类型的所有组件。
  6297. @param typeOrClassName typeOrClassName
  6298. @example
  6299. ```js
  6300. var sprites = node.getComponents(cc.Sprite);
  6301. var tests = node.getComponents("Test");
  6302. ```
  6303. */
  6304. getComponents<T extends Component>(type: {prototype: T}): T[];
  6305. getComponents(className: string): any[];
  6306. /**
  6307. !#en Returns the component of supplied type in any of its children using depth first search.
  6308. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6309. @param typeOrClassName typeOrClassName
  6310. @example
  6311. ```js
  6312. var sprite = node.getComponentInChildren(cc.Sprite);
  6313. var Test = node.getComponentInChildren("Test");
  6314. ```
  6315. */
  6316. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6317. getComponentInChildren(className: string): any;
  6318. /**
  6319. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6320. !#zh 递归查找自身或所有子节点中指定类型的组件
  6321. @param typeOrClassName typeOrClassName
  6322. @example
  6323. ```js
  6324. var sprites = node.getComponentsInChildren(cc.Sprite);
  6325. var tests = node.getComponentsInChildren("Test");
  6326. ```
  6327. */
  6328. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6329. getComponentsInChildren(className: string): any[];
  6330. /**
  6331. !#en
  6332. If the component's bounding box is different from the node's, you can implement this method to supply
  6333. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6334. !#zh
  6335. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6336. 以便编辑器的场景视图可以正确地执行点选测试。
  6337. @param out_rect the Rect to receive the bounding box
  6338. */
  6339. _getLocalBounds(out_rect: Rect): void;
  6340. /**
  6341. !#en
  6342. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6343. an undo operation on this component.<br/>
  6344. <br/>
  6345. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6346. in its CCClass properties", then you may need to implement this function.<br/>
  6347. <br/>
  6348. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6349. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6350. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6351. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6352. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6353. will be recorded or restored by editor.<br/>
  6354. <br/>
  6355. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6356. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6357. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6358. will not be called during reset operation. Which means that only the properties with default value<br/>
  6359. will be reset by editor.
  6360. This function is only called in editor mode.
  6361. !#zh
  6362. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6363. <br/>
  6364. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6365. <br/>
  6366. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  6367. 然而,在极端的情况下,它可能无法良好运作。<br/>
  6368. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  6369. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  6370. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6371. <br/>
  6372. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  6373. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  6374. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  6375. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  6376. <br/>
  6377. 此方法仅在编辑器下会被调用。
  6378. */
  6379. onRestore(): void;
  6380. /**
  6381. !#en
  6382. Schedules a custom selector.<br/>
  6383. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6384. !#zh
  6385. 调度一个自定义的回调函数。<br/>
  6386. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6387. @param callback The callback function
  6388. @param interval Tick interval in seconds. 0 means tick every frame.
  6389. @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  6390. @param delay The amount of time that the first tick will wait before execution.
  6391. @example
  6392. ```js
  6393. var timeCallback = function (dt) {
  6394. cc.log("time: " + dt);
  6395. }
  6396. this.schedule(timeCallback, 1);
  6397. ```
  6398. */
  6399. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6400. /**
  6401. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6402. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6403. @param callback A function wrapped as a selector
  6404. @param delay The amount of time that the first tick will wait before execution.
  6405. @example
  6406. ```js
  6407. var timeCallback = function (dt) {
  6408. cc.log("time: " + dt);
  6409. }
  6410. this.scheduleOnce(timeCallback, 2);
  6411. ```
  6412. */
  6413. scheduleOnce(callback: Function, delay?: number): void;
  6414. /**
  6415. !#en Unschedules a custom callback function.
  6416. !#zh 取消调度一个自定义的回调函数。
  6417. @param callback_fn A function wrapped as a selector
  6418. @example
  6419. ```js
  6420. this.unschedule(_callback);
  6421. ```
  6422. */
  6423. unschedule(callback_fn: Function): void;
  6424. /**
  6425. !#en
  6426. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6427. Actions are not affected by this method.
  6428. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  6429. @example
  6430. ```js
  6431. this.unscheduleAllCallbacks();
  6432. ```
  6433. */
  6434. unscheduleAllCallbacks(): void;
  6435. }
  6436. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  6437. !#zh EditBox 组件,用于获取用户的输入文本。 */
  6438. export class EditBox extends _RendererUnderSG {
  6439. /** !#en Input string of EditBox.
  6440. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  6441. string: string;
  6442. /** !#en The background image of EditBox.
  6443. !#zh 输入框的背景图片 */
  6444. backgroundImage: SpriteFrame;
  6445. /** !#en
  6446. The return key type of EditBox.
  6447. Note: it is meaningless for web platforms and desktop platforms.
  6448. !#zh
  6449. 指定移动设备上面回车按钮的样式。
  6450. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  6451. returnType: EditBox.KeyboardReturnType;
  6452. /** !#en Set the input flags that are to be applied to the EditBox.
  6453. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  6454. inputFlag: EditBox.InputFlag;
  6455. /** !#en
  6456. Set the input mode of the edit box.
  6457. If you pass ANY, it will create a multiline EditBox.
  6458. !#zh
  6459. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  6460. inputMode: EditBox.InputMode;
  6461. /** !#en Font size of the input text.
  6462. !#zh 输入框文本的字体大小 */
  6463. fontSize: number;
  6464. /** !#en Change the lineHeight of displayed text.
  6465. !#zh 输入框文本的行高。 */
  6466. lineHeight: number;
  6467. /** !#en Font color of the input text.
  6468. !#zh 输入框文本的颜色。 */
  6469. fontColor: Color;
  6470. /** !#en The display text of placeholder.
  6471. !#zh 输入框占位符的文本内容。 */
  6472. placeholder: string;
  6473. /** !#en The font size of placeholder.
  6474. !#zh 输入框占位符的字体大小。 */
  6475. placeholderFontSize: number;
  6476. /** !#en The font color of placeholder.
  6477. !#zh 输入框最大允许输入的字符个数。 */
  6478. placeholderFontColor: Color;
  6479. /** !#en The maximize input length of EditBox.
  6480. - If pass a value less than 0, it won't limit the input number of characters.
  6481. - If pass 0, it doesn't allow input any characters.
  6482. !#zh 输入框最大允许输入的字符个数。
  6483. - 如果值为小于 0 的值,则不会限制输入字符个数。
  6484. - 如果值为 0,则不允许用户进行任何输入。 */
  6485. maxLength: number;
  6486. /** !#en The input is always visible and be on top of the game view.
  6487. !zh 输入框总是可见,并且永远在游戏视图的上面
  6488. Note: only available on Web at the moment. */
  6489. stayOnTop: boolean;
  6490. /** !#en Set the tabIndex of the DOM input element, only useful on Web.
  6491. !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */
  6492. tabIndex: number;
  6493. /** !#en The event handler to be called when EditBox began to edit text.
  6494. !#zh 开始编辑文本输入框触发的事件回调。 */
  6495. editingDidBegan: Component.EventHandler[];
  6496. /** !#en The event handler to be called when EditBox text changes.
  6497. !#zh 编辑文本输入框时触发的事件回调。 */
  6498. textChanged: Component.EventHandler[];
  6499. /** !#en The event handler to be called when EditBox edit ends.
  6500. !#zh 结束编辑文本输入框时触发的事件回调。 */
  6501. editingDidEnded: Component.EventHandler[];
  6502. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  6503. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  6504. editingReturn: Component.EventHandler[];
  6505. /**
  6506. !#en Let the EditBox get focus, only valid when stayOnTop is true.
  6507. !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
  6508. Note: only available on Web at the moment.
  6509. */
  6510. setFocus(): void;
  6511. /**
  6512. !#en Determine whether EditBox is getting focus or not.
  6513. !#zh 判断 EditBox 是否获得了焦点
  6514. Note: only available on Web at the moment.
  6515. */
  6516. isFocused(): void;
  6517. /**
  6518. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  6519. call the destroy method on this component or the associated node explicitly.
  6520. Otherwise, the created DOM element won't be removed from web page.
  6521. !#zh
  6522. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  6523. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  6524. @example
  6525. ```js
  6526. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  6527. // when you don't need editbox anymore
  6528. editbox.node.destroy();
  6529. ```
  6530. */
  6531. destroy(): boolean;
  6532. }
  6533. /** !#en The Label Component.
  6534. !#zh 文字标签组件 */
  6535. export class Label extends _RendererUnderSG {
  6536. /** !#en Content string of label.
  6537. !#zh 标签显示的文本内容。 */
  6538. string: string;
  6539. /** !#en Horizontal Alignment of label.
  6540. !#zh 文本内容的水平对齐方式。 */
  6541. horizontalAlign: Label.HorizontalAlign;
  6542. /** !#en Vertical Alignment of label.
  6543. !#zh 文本内容的垂直对齐方式。 */
  6544. verticalAlign: Label.VerticalAlign;
  6545. /** !#en The actual rendering font size in shrink mode
  6546. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6547. actualFontSize: number;
  6548. /** !#en Font size of label.
  6549. !#zh 文本字体大小。 */
  6550. fontSize: number;
  6551. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6552. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6553. fontFamily: string;
  6554. /** !#en Line Height of label.
  6555. !#zh 文本行高。 */
  6556. lineHeight: number;
  6557. /** !#en Overflow of label.
  6558. !#zh 文字显示超出范围时的处理方式。 */
  6559. overflow: Label.Overflow;
  6560. /** !#en Whether auto wrap label when string width is large than label width.
  6561. !#zh 是否自动换行。 */
  6562. enableWrapText: boolean;
  6563. /** !#en The font of label.
  6564. !#zh 文本字体。 */
  6565. font: Font;
  6566. /** !#en Whether use system font name or not.
  6567. !#zh 是否使用系统字体。 */
  6568. isSystemFontUsed: boolean;
  6569. }
  6570. /** !#en Outline effect used to change the display, only used for TTF font
  6571. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6572. export class LabelOutline extends Component {
  6573. /** !#en Change the outline color
  6574. !#zh 改变描边的颜色 */
  6575. color: Color;
  6576. /** !#en Change the outline width
  6577. !#zh 改变描边的宽度 */
  6578. width: number;
  6579. }
  6580. /** !#en
  6581. The Layout is a container component, use it to arrange child elements easily.<br>
  6582. Note:<br>
  6583. 1.Scaling and rotation of child nodes are not considered.<br>
  6584. 2.After setting the Layout, the results need to be updated until the next frame,
  6585. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6586. !#zh
  6587. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6588. 注意:<br>
  6589. 1.不会考虑子节点的缩放和旋转。<br>
  6590. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6591. export class Layout extends Component {
  6592. /** !#en The layout type.
  6593. !#zh 布局类型 */
  6594. type: Layout.Type;
  6595. /** !#en
  6596. The are three resize modes for Layout.
  6597. None, resize Container and resize children.
  6598. !#zh 缩放模式 */
  6599. resizeMode: Layout.ResizeMode;
  6600. /** !#en The cell size for grid layout.
  6601. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6602. cellSize: Size;
  6603. /** !#en
  6604. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6605. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6606. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6607. startAxis: Layout.AxisDirection;
  6608. /** !#en The left padding of layout, it only effect the layout in one direction.
  6609. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6610. paddingLeft: number;
  6611. /** !#en The right padding of layout, it only effect the layout in one direction.
  6612. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6613. paddingRight: number;
  6614. /** !#en The top padding of layout, it only effect the layout in one direction.
  6615. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6616. paddingTop: number;
  6617. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6618. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6619. paddingBottom: number;
  6620. /** !#en The distance in x-axis between each element in layout.
  6621. !#zh 子节点之间的水平间距。 */
  6622. spacingX: number;
  6623. /** !#en The distance in y-axis between each element in layout.
  6624. !#zh 子节点之间的垂直间距。 */
  6625. spacingY: number;
  6626. /** !#en
  6627. Only take effect in Vertical layout mode.
  6628. This option changes the start element's positioning.
  6629. !#zh 垂直排列子节点的方向。 */
  6630. verticalDirection: Layout.VerticalDirection;
  6631. /** !#en
  6632. Only take effect in Horizontal layout mode.
  6633. This option changes the start element's positioning.
  6634. !#zh 水平排列子节点的方向。 */
  6635. horizontalDirection: Layout.HorizontalDirection;
  6636. /**
  6637. !#en Perform the layout update
  6638. !#zh 立即执行更新布局
  6639. @example
  6640. ```js
  6641. layout.type = cc.Layout.HORIZONTAL;
  6642. layout.node.addChild(childNode);
  6643. cc.log(childNode.x); // not yet changed
  6644. layout.updateLayout();
  6645. cc.log(childNode.x); // changed
  6646. ```
  6647. */
  6648. updateLayout(): void;
  6649. /** !#en The padding of layout, it effects the layout in four direction.
  6650. !#zh 容器内边距,该属性会在四个布局方向上生效。 */
  6651. padding: number;
  6652. }
  6653. /** !#en The Mask Component
  6654. !#zh 遮罩组件 */
  6655. export class Mask extends _RendererInSG {
  6656. /** !#en The mask type.
  6657. !#zh 遮罩类型 */
  6658. type: Mask.Type;
  6659. /** !#en The mask image
  6660. !#zh 遮罩所需要的贴图 */
  6661. spriteFrame: SpriteFrame;
  6662. /** !#en
  6663. The alpha threshold.(Not supported Canvas Mode) <br/>
  6664. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6665. Should be a float between 0 and 1. <br/>
  6666. This default to 1 (so alpha test is disabled).
  6667. !#zh
  6668. Alpha 阈值(不支持 Canvas 模式)<br/>
  6669. 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。<br/>
  6670. 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */
  6671. alphaThreshold: number;
  6672. /** !#en Reverse mask (Not supported Canvas Mode)
  6673. !#zh 反向遮罩(不支持 Canvas 模式) */
  6674. inverted: boolean;
  6675. /** !#en The segements for ellipse mask.
  6676. !#zh 椭圆遮罩的曲线细分数 */
  6677. segements: number;
  6678. }
  6679. /** !#en The PageView control
  6680. !#zh 页面视图组件 */
  6681. export class PageView extends ScrollView {
  6682. /** !#en Specify the size type of each page in PageView.
  6683. !#zh 页面视图中每个页面大小类型 */
  6684. sizeMode: PageView.SizeMode;
  6685. /** !#en The page view direction
  6686. !#zh 页面视图滚动类型 */
  6687. direction: PageView.Direction;
  6688. /** !#en
  6689. The scroll threshold value, when drag exceeds this value,
  6690. release the next page will automatically scroll, less than the restore
  6691. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6692. scrollThreshold: number;
  6693. /** !#en
  6694. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6695. it will calculate a velocity based on the scroll distance and time,
  6696. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6697. !#zh
  6698. 快速滑动翻页临界值。
  6699. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6700. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6701. autoPageTurningThreshold: number;
  6702. /** !#en Change the PageTurning event timing of PageView.
  6703. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6704. pageTurningEventTiming: number;
  6705. /** !#en The Page View Indicator
  6706. !#zh 页面视图指示器组件 */
  6707. indicator: PageViewIndicator;
  6708. /** !#en The time required to turn over a page. unit: second
  6709. !#zh 每个页面翻页时所需时间。单位:秒 */
  6710. pageTurningSpeed: number;
  6711. /** !#en PageView events callback
  6712. !#zh 滚动视图的事件回调函数 */
  6713. pageEvents: Component.EventHandler[];
  6714. /**
  6715. !#en Returns current page index
  6716. !#zh 返回当前页面索引
  6717. */
  6718. getCurrentPageIndex(): number;
  6719. /**
  6720. !#en Set current page index
  6721. !#zh 设置当前页面索引
  6722. @param index index
  6723. */
  6724. setCurrentPageIndex(index: number): void;
  6725. /**
  6726. !#en Returns all pages of pageview
  6727. !#zh 返回视图中的所有页面
  6728. */
  6729. getPages(): Node[];
  6730. /**
  6731. !#en At the end of the current page view to insert a new view
  6732. !#zh 在当前页面视图的尾部插入一个新视图
  6733. @param page page
  6734. */
  6735. addPage(page: Node): void;
  6736. /**
  6737. !#en Inserts a page in the specified location
  6738. !#zh 将页面插入指定位置中
  6739. @param page page
  6740. @param index index
  6741. */
  6742. insertPage(page: Node, index: number): void;
  6743. /**
  6744. !#en Removes a page from PageView.
  6745. !#zh 移除指定页面
  6746. @param page page
  6747. */
  6748. removePage(page: Node): void;
  6749. /**
  6750. !#en Removes a page at index of PageView.
  6751. !#zh 移除指定下标的页面
  6752. @param index index
  6753. */
  6754. removePageAtIndex(index: number): void;
  6755. /**
  6756. !#en Removes all pages from PageView
  6757. !#zh 移除所有页面
  6758. */
  6759. removeAllPages(): void;
  6760. /**
  6761. !#en Scroll PageView to index.
  6762. !#zh 滚动到指定页面
  6763. @param idx index of page.
  6764. @param timeInSecond scrolling time
  6765. */
  6766. scrollToPage(idx: number, timeInSecond: number): void;
  6767. }
  6768. /** !#en The Page View Indicator Component
  6769. !#zh 页面视图每页标记组件 */
  6770. export class PageViewIndicator extends Component {
  6771. /** !#en The spriteFrame for each element.
  6772. !#zh 每个页面标记显示的图片 */
  6773. spriteFrame: SpriteFrame;
  6774. /** !#en The location direction of PageViewIndicator.
  6775. !#zh 页面标记摆放方向 */
  6776. direction: PageViewIndicator.Direction;
  6777. /** !#en The cellSize for each element.
  6778. !#zh 每个页面标记的大小 */
  6779. cellSize: Size;
  6780. /** !#en The distance between each element.
  6781. !#zh 每个页面标记之间的边距 */
  6782. spacing: number;
  6783. /**
  6784. !#en Set Page View
  6785. !#zh 设置页面视图
  6786. @param target target
  6787. */
  6788. setPageView(target: PageView): void;
  6789. }
  6790. /** !#en
  6791. Visual indicator of progress in some operation.
  6792. Displays a bar to the user representing how far the operation has progressed.
  6793. !#zh
  6794. 进度条组件,可用于显示加载资源时的进度。 */
  6795. export class ProgressBar extends Component {
  6796. /** !#en The targeted Sprite which will be changed progressively.
  6797. !#zh 用来显示进度条比例的 Sprite 对象。 */
  6798. barSprite: Sprite;
  6799. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  6800. !#zh 进度条的模式 */
  6801. mode: ProgressBar.Mode;
  6802. /** !#en The total width or height of the bar sprite.
  6803. !#zh 进度条实际的总长度 */
  6804. totalLength: number;
  6805. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  6806. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  6807. progress: number;
  6808. /** !#en Whether reverse the progress direction of the bar sprite.
  6809. !#zh 进度条是否进行反方向变化。 */
  6810. reverse: boolean;
  6811. }
  6812. /** Rendering component in scene graph.
  6813. Maintains a node which will be the scene graph of component's Node. */
  6814. export class _RendererInSG extends _SGComponent {
  6815. }
  6816. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  6817. export class _RendererUnderSG extends _SGComponent {
  6818. }
  6819. /** !#en The RichText Component.
  6820. !#zh 富文本组件 */
  6821. export class RichText extends Component {
  6822. /** !#en Content string of RichText.
  6823. !#zh 富文本显示的文本内容。 */
  6824. string: string;
  6825. /** !#en Horizontal Alignment of each line in RichText.
  6826. !#zh 文本内容的水平对齐方式。 */
  6827. horizontalAlign: TextAlignment;
  6828. /** !#en Font size of RichText.
  6829. !#zh 富文本字体大小。 */
  6830. fontSize: number;
  6831. /** !#en Custom TTF font of RichText
  6832. !#zh 富文本定制字体 */
  6833. font: cc.TTFFont;
  6834. /** !#en The maximize width of the RichText
  6835. !#zh 富文本的最大宽度 */
  6836. maxWidth: number;
  6837. /** !#en Line Height of RichText.
  6838. !#zh 富文本行高。 */
  6839. lineHeight: number;
  6840. /** !#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.
  6841. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  6842. imageAtlas: SpriteAtlas;
  6843. /** !#en
  6844. Once checked, the RichText will block all input events (mouse and touch) within
  6845. the bounding box of the node, preventing the input from penetrating into the underlying node.
  6846. !#zh
  6847. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  6848. handleTouchEvent: boolean;
  6849. }
  6850. /** The base class for all rendering component in scene graph.
  6851. You should override:
  6852. - _createSgNode
  6853. - _initSgNode */
  6854. export class _SGComponent extends Component {
  6855. }
  6856. /** !#en
  6857. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  6858. !#zh 滚动条组件 */
  6859. export class Scrollbar extends Component {
  6860. /** !#en The "handle" part of the scrollbar.
  6861. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  6862. handle: Sprite;
  6863. /** !#en The direction of scrollbar.
  6864. !#zh ScrollBar 的滚动方向。 */
  6865. direction: Scrollbar.Direction;
  6866. /** !#en Whether enable auto hide or not.
  6867. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  6868. enableAutoHide: boolean;
  6869. /** !#en
  6870. The time to hide scrollbar when scroll finished.
  6871. Note: This value is only useful when enableAutoHide is true.
  6872. !#zh
  6873. 没有滚动动作后经过多久会自动隐藏。
  6874. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  6875. autoHideTime: number;
  6876. }
  6877. /** !#en
  6878. Layout container for a view hierarchy that can be scrolled by the user,
  6879. allowing it to be larger than the physical display.
  6880. !#zh
  6881. 滚动视图组件 */
  6882. export class ScrollView extends Component {
  6883. /** !#en This is a reference to the UI element to be scrolled.
  6884. !#zh 可滚动展示内容的节点。 */
  6885. content: Node;
  6886. /** !#en Enable horizontal scroll.
  6887. !#zh 是否开启水平滚动。 */
  6888. horizontal: boolean;
  6889. /** !#en Enable vertical scroll.
  6890. !#zh 是否开启垂直滚动。 */
  6891. vertical: boolean;
  6892. /** !#en When inertia is set, the content will continue to move when touch ended.
  6893. !#zh 是否开启滚动惯性。 */
  6894. inertia: boolean;
  6895. /** !#en
  6896. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  6897. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  6898. !#zh
  6899. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  6900. brake: number;
  6901. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  6902. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  6903. elastic: boolean;
  6904. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  6905. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  6906. bounceDuration: number;
  6907. /** !#en The horizontal scrollbar reference.
  6908. !#zh 水平滚动的 ScrollBar。 */
  6909. horizontalScrollBar: Scrollbar;
  6910. /** !#en The vertical scrollbar reference.
  6911. !#zh 垂直滚动的 ScrollBar。 */
  6912. verticalScrollBar: Scrollbar;
  6913. /** !#en Scrollview events callback
  6914. !#zh 滚动视图的事件回调函数 */
  6915. scrollEvents: Component.EventHandler[];
  6916. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  6917. It's set to true by default.
  6918. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  6919. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  6920. cancelInnerEvents: boolean;
  6921. /**
  6922. !#en Scroll the content to the bottom boundary of ScrollView.
  6923. !#zh 视图内容将在规定时间内滚动到视图底部。
  6924. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6925. the content will jump to the bottom boundary immediately.
  6926. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6927. @example
  6928. ```js
  6929. // Scroll to the bottom of the view.
  6930. scrollView.scrollToBottom(0.1);
  6931. ```
  6932. */
  6933. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  6934. /**
  6935. !#en Scroll the content to the top boundary of ScrollView.
  6936. !#zh 视图内容将在规定时间内滚动到视图顶部。
  6937. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6938. the content will jump to the top boundary immediately.
  6939. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6940. @example
  6941. ```js
  6942. // Scroll to the top of the view.
  6943. scrollView.scrollToTop(0.1);
  6944. ```
  6945. */
  6946. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  6947. /**
  6948. !#en Scroll the content to the left boundary of ScrollView.
  6949. !#zh 视图内容将在规定时间内滚动到视图左边。
  6950. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6951. the content will jump to the left boundary immediately.
  6952. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6953. @example
  6954. ```js
  6955. // Scroll to the left of the view.
  6956. scrollView.scrollToLeft(0.1);
  6957. ```
  6958. */
  6959. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  6960. /**
  6961. !#en Scroll the content to the right boundary of ScrollView.
  6962. !#zh 视图内容将在规定时间内滚动到视图右边。
  6963. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6964. the content will jump to the right boundary immediately.
  6965. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6966. @example
  6967. ```js
  6968. // Scroll to the right of the view.
  6969. scrollView.scrollToRight(0.1);
  6970. ```
  6971. */
  6972. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  6973. /**
  6974. !#en Scroll the content to the top left boundary of ScrollView.
  6975. !#zh 视图内容将在规定时间内滚动到视图左上角。
  6976. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6977. the content will jump to the top left boundary immediately.
  6978. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6979. @example
  6980. ```js
  6981. // Scroll to the upper left corner of the view.
  6982. scrollView.scrollToTopLeft(0.1);
  6983. ```
  6984. */
  6985. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  6986. /**
  6987. !#en Scroll the content to the top right boundary of ScrollView.
  6988. !#zh 视图内容将在规定时间内滚动到视图右上角。
  6989. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6990. the content will jump to the top right boundary immediately.
  6991. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6992. @example
  6993. ```js
  6994. // Scroll to the top right corner of the view.
  6995. scrollView.scrollToTopRight(0.1);
  6996. ```
  6997. */
  6998. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  6999. /**
  7000. !#en Scroll the content to the bottom left boundary of ScrollView.
  7001. !#zh 视图内容将在规定时间内滚动到视图左下角。
  7002. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7003. the content will jump to the bottom left boundary immediately.
  7004. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7005. @example
  7006. ```js
  7007. // Scroll to the lower left corner of the view.
  7008. scrollView.scrollToBottomLeft(0.1);
  7009. ```
  7010. */
  7011. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  7012. /**
  7013. !#en Scroll the content to the bottom right boundary of ScrollView.
  7014. !#zh 视图内容将在规定时间内滚动到视图右下角。
  7015. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7016. the content will jump to the bottom right boundary immediately.
  7017. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7018. @example
  7019. ```js
  7020. // Scroll to the lower right corner of the view.
  7021. scrollView.scrollToBottomRight(0.1);
  7022. ```
  7023. */
  7024. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  7025. /**
  7026. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  7027. specific offset immediately.
  7028. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  7029. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  7030. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7031. the content will jump to the specific offset of ScrollView immediately.
  7032. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7033. @example
  7034. ```js
  7035. // Scroll to middle position in 0.1 second in x-axis
  7036. var maxScrollOffset = this.getMaxScrollOffset();
  7037. scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1);
  7038. ```
  7039. */
  7040. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7041. /**
  7042. !#en Get the positive offset value corresponds to the content's top left boundary.
  7043. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  7044. */
  7045. getScrollOffset(): Vec2;
  7046. /**
  7047. !#en Get the maximize available scroll offset
  7048. !#zh 获取滚动视图最大可以滚动的偏移量
  7049. */
  7050. getMaxScrollOffset(): Vec2;
  7051. /**
  7052. !#en Scroll the content to the horizontal percent position of ScrollView.
  7053. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  7054. @param percent A value between 0 and 1.
  7055. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7056. the content will jump to the horizontal percent position of ScrollView immediately.
  7057. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7058. @example
  7059. ```js
  7060. // Scroll to middle position.
  7061. scrollView.scrollToBottomRight(0.5, 0.1);
  7062. ```
  7063. */
  7064. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7065. /**
  7066. !#en Scroll the content to the percent position of ScrollView in any direction.
  7067. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  7068. @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1).
  7069. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7070. the content will jump to the percent position of ScrollView immediately.
  7071. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7072. @example
  7073. ```js
  7074. // Vertical scroll to the bottom of the view.
  7075. scrollView.scrollTo(cc.p(0, 1), 0.1);
  7076. // Horizontal scroll to view right.
  7077. scrollView.scrollTo(cc.p(1, 0), 0.1);
  7078. ```
  7079. */
  7080. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7081. /**
  7082. !#en Scroll the content to the vertical percent position of ScrollView.
  7083. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7084. @param percent A value between 0 and 1.
  7085. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7086. the content will jump to the vertical percent position of ScrollView immediately.
  7087. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7088. // Scroll to middle position.
  7089. scrollView.scrollToPercentVertical(0.5, 0.1);
  7090. */
  7091. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7092. /**
  7093. !#en Stop auto scroll immediately
  7094. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7095. */
  7096. stopAutoScroll(): void;
  7097. /**
  7098. !#en Modify the content position.
  7099. !#zh 设置当前视图内容的坐标点。
  7100. @param position The position in content's parent space.
  7101. */
  7102. setContentPosition(position: Vec2): void;
  7103. /**
  7104. !#en Query the content's position in its parent space.
  7105. !#zh 获取当前视图内容的坐标点。
  7106. */
  7107. getContentPosition(): Position;
  7108. /**
  7109. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7110. !#zh 用户是否在拖拽当前滚动视图
  7111. */
  7112. isScrolling(): boolean;
  7113. /**
  7114. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7115. !#zh 当前滚动视图是否在惯性滚动
  7116. */
  7117. isAutoScrolling(): boolean;
  7118. }
  7119. /** !#en The Slider Control
  7120. !#zh 滑动器组件 */
  7121. export class Slider extends Component {
  7122. /** !#en The "handle" part of the slider
  7123. !#zh 滑动器滑块按钮部件 */
  7124. handle: Button;
  7125. /** !#en The slider direction
  7126. !#zh 滑动器方向 */
  7127. direction: Slider.Direction;
  7128. /** !#en The current progress of the slider. The valid value is between 0-1
  7129. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7130. progress: number;
  7131. /** !#en The slider events callback
  7132. !#zh 滑动器组件事件回调函数 */
  7133. slideEvents: Component.EventHandler[];
  7134. }
  7135. /** !#en Renders a sprite in the scene.
  7136. !#zh 该组件用于在场景中渲染精灵。 */
  7137. export class Sprite extends _RendererUnderSG {
  7138. /** !#en The sprite frame of the sprite.
  7139. !#zh 精灵的精灵帧 */
  7140. spriteFrame: SpriteFrame;
  7141. /** !#en The sprite render type.
  7142. !#zh 精灵渲染类型 */
  7143. type: Sprite.SpriteType;
  7144. /** !#en
  7145. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7146. !#zh
  7147. 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7148. fillType: Sprite.FillType;
  7149. /** !#en
  7150. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7151. !#zh
  7152. 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7153. fillCenter: Vec2;
  7154. /** !#en
  7155. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7156. !#zh
  7157. 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7158. fillStart: number;
  7159. /** !#en
  7160. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7161. !#zh
  7162. 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7163. fillRange: number;
  7164. /** !#en specify the frame is trimmed or not.
  7165. !#zh 是否使用裁剪模式 */
  7166. trim: boolean;
  7167. /** !#en specify the source Blend Factor.
  7168. !#zh 指定原图的混合模式 */
  7169. srcBlendFactor: BlendFactor;
  7170. /** !#en specify the destination Blend Factor.
  7171. !#zh 指定目标的混合模式 */
  7172. dstBlendFactor: BlendFactor;
  7173. /** !#en specify the size tracing mode.
  7174. !#zh 精灵尺寸调整模式 */
  7175. sizeMode: Sprite.SizeMode;
  7176. /**
  7177. !#en Change the left sprite's cap inset.
  7178. !#zh 设置精灵左边框-用于九宫格。
  7179. @param insetLeft The values to use for the cap inset.
  7180. @example
  7181. ```js
  7182. sprite.setInsetLeft(5);
  7183. ```
  7184. */
  7185. setInsetLeft(insetLeft: number): void;
  7186. /**
  7187. !#en Query the left sprite's cap inset.
  7188. !#zh 获取精灵左边框
  7189. @example
  7190. ```js
  7191. var insetLeft = sprite.getInsetLeft();
  7192. cc.log("Inset Left:" + insetLeft);
  7193. ```
  7194. */
  7195. getInsetLeft(): number;
  7196. /**
  7197. !#en Change the top sprite's cap inset.
  7198. !#zh 设置精灵上边框-用于九宫格。
  7199. @param insetTop The values to use for the cap inset.
  7200. @example
  7201. ```js
  7202. sprite.setInsetTop(5);
  7203. ```
  7204. */
  7205. setInsetTop(insetTop: number): void;
  7206. /**
  7207. !#en Query the top sprite's cap inset.
  7208. !#zh 获取精灵上边框。
  7209. @example
  7210. ```js
  7211. var insetTop = sprite.getInsetTop();
  7212. cc.log("Inset Top:" + insetTop);
  7213. ```
  7214. */
  7215. getInsetTop(): number;
  7216. /**
  7217. !#en Change the right sprite's cap inset.
  7218. !#zh 设置精灵右边框-用于九宫格。
  7219. @param insetRight The values to use for the cap inset.
  7220. @example
  7221. ```js
  7222. sprite.setInsetRight(5);
  7223. ```
  7224. */
  7225. setInsetRight(insetRight: number): void;
  7226. /**
  7227. !#en Query the right sprite's cap inset.
  7228. !#zh 获取精灵右边框。
  7229. @example
  7230. ```js
  7231. var insetRight = sprite.getInsetRight();
  7232. cc.log("Inset Right:" + insetRight);
  7233. ```
  7234. */
  7235. getInsetRight(): number;
  7236. /**
  7237. !#en Change the bottom sprite's cap inset.
  7238. !#zh 设置精灵下边框-用于九宫格。
  7239. @param bottomInset The values to use for the cap inset.
  7240. @example
  7241. ```js
  7242. sprite.setInsetBottom(5);
  7243. ```
  7244. */
  7245. setInsetBottom(bottomInset: number): void;
  7246. /**
  7247. !#en Query the bottom sprite's cap inset.
  7248. !#zh 获取精灵下边框。
  7249. @example
  7250. ```js
  7251. var insetBottom = sprite.getInsetBottom();
  7252. cc.log("Inset Bottom:" + insetBottom);
  7253. ```
  7254. */
  7255. getInsetBottom(): number;
  7256. }
  7257. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  7258. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  7259. export class SpriteDistortion extends Component {
  7260. /** !#en Change the UV offset for distortion rendering.
  7261. !#zh 在渲染时改变UV的整体偏移. */
  7262. offset: Vec2;
  7263. /** !#en Change the UV scale for distortion rendering.
  7264. !#zh 在渲染时改变UV的寻址系数 */
  7265. tiling: Vec2;
  7266. }
  7267. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7268. could be treated as a RadioButton.
  7269. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7270. export class Toggle extends Button {
  7271. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7272. the check mark component will be disabled.
  7273. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7274. isChecked: boolean;
  7275. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7276. Otherwise, the toggle is a RadioButton.
  7277. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7278. 否则,Toggle 是一个 RadioButton。 */
  7279. toggleGroup: ToggleGroup;
  7280. /** !#en The image used for the checkmark.
  7281. !#zh Toggle 处于选中状态时显示的图片 */
  7282. checkMark: Sprite;
  7283. /** !#en If Toggle is clicked, it will trigger event's handler
  7284. !#zh Toggle 按钮的点击事件列表。 */
  7285. checkEvents: Component.EventHandler[];
  7286. /**
  7287. !#en Make the toggle button checked.
  7288. !#zh 使 toggle 按钮处于选中状态
  7289. */
  7290. check(): void;
  7291. /**
  7292. !#en Make the toggle button unchecked.
  7293. !#zh 使 toggle 按钮处于未选中状态
  7294. */
  7295. uncheck(): void;
  7296. }
  7297. /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. </br>
  7298. Toggles that belong to the same group could only have one of them to be switched on at a time.</br>
  7299. Note: All the first layer child node containing the toggle component will auto be added to the container
  7300. !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。</br>
  7301. 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。</br>
  7302. 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
  7303. export class ToggleContainer extends Component {
  7304. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7305. If it is false, it will make sure there is always only one toggle could be switched on
  7306. and the already switched on toggle can't be switched off.
  7307. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7308. allowSwitchOff: boolean;
  7309. /** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
  7310. !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
  7311. toggleItems: Toggle[];
  7312. }
  7313. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7314. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7315. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7316. 任何时候只能有一个 Toggle 处于选中状态。 */
  7317. export class ToggleGroup extends Component {
  7318. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7319. If it is false, it will make sure there is always only one toggle could be switched on
  7320. and the already switched on toggle can't be switched off.
  7321. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7322. allowSwitchOff: boolean;
  7323. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7324. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7325. toggleItems: any[];
  7326. }
  7327. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  7328. !#zh Video 组件,用于在游戏中播放视频 */
  7329. export class VideoPlayer extends _RendererUnderSG {
  7330. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  7331. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  7332. resourceType: VideoPlayer.ResourceType;
  7333. /** !#en The remote URL of video.
  7334. !#zh 远程视频的 URL */
  7335. remoteURL: string;
  7336. /** !#en The local video full path.
  7337. !#zh 本地视频的 URL */
  7338. clip: string;
  7339. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  7340. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  7341. currentTime: number;
  7342. /** !#en Whether keep the aspect ration of the original video.
  7343. !#zh 是否保持视频原来的宽高比 */
  7344. keepAspectRatio: boolean;
  7345. /** !#en Whether play video in fullscreen mode.
  7346. !#zh 是否全屏播放视频 */
  7347. isFullscreen: boolean;
  7348. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  7349. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  7350. videoPlayerEvent: Component.EventHandler[];
  7351. /**
  7352. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  7353. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  7354. */
  7355. play(): void;
  7356. /**
  7357. !#en If a video is paused, call this method to resume playing.
  7358. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  7359. */
  7360. resume(): void;
  7361. /**
  7362. !#en If a video is playing, call this method to pause playing.
  7363. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  7364. */
  7365. pause(): void;
  7366. /**
  7367. !#en If a video is playing, call this method to stop playing immediately.
  7368. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  7369. */
  7370. stop(): void;
  7371. /**
  7372. !#en Gets the duration of the video
  7373. !#zh 获取视频文件的播放总时长
  7374. */
  7375. getDuration(): number;
  7376. /**
  7377. !#en Determine whether video is playing or not.
  7378. !#zh 判断当前视频是否处于播放状态
  7379. */
  7380. isPlaying(): boolean;
  7381. /**
  7382. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  7383. call the destroy method on this component or the associated node explicitly.
  7384. Otherwise, the created DOM element won't be removed from web page.
  7385. !#zh
  7386. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7387. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7388. @example
  7389. ```js
  7390. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  7391. // when you don't need videoplayer anymore
  7392. videoplayer.node.destroy();
  7393. ```
  7394. */
  7395. destroy(): boolean;
  7396. }
  7397. /** !#en
  7398. Handling touch events in a ViewGroup takes special care,
  7399. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7400. To make sure that each view correctly receives the touch events intended for it,
  7401. ViewGroup should register capture phase event and handle the event propagation properly.
  7402. Please refer to Scrollview for more information.
  7403. !#zh
  7404. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7405. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7406. 请参考 ScrollView 的实现来获取更多信息。 */
  7407. export class ViewGroup extends Component {
  7408. }
  7409. /** !#en cc.WebView is a component for display web pages in the game
  7410. !#zh WebView 组件,用于在游戏中显示网页 */
  7411. export class WebView extends _RendererUnderSG {
  7412. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  7413. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  7414. url: string;
  7415. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  7416. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  7417. webviewLoadedEvents: Component.EventHandler[];
  7418. /**
  7419. !#en
  7420. Set javascript interface scheme (see also setOnJSCallback). <br/>
  7421. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7422. Please refer to the official documentation for more details.
  7423. !#zh
  7424. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  7425. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  7426. 详情请参阅官方文档
  7427. @param scheme scheme
  7428. */
  7429. setJavascriptInterfaceScheme(scheme: string): void;
  7430. /**
  7431. !#en
  7432. This callback called when load URL that start with javascript
  7433. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  7434. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7435. Please refer to the official documentation for more details.
  7436. !#zh
  7437. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  7438. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  7439. 详情请参阅官方文档
  7440. @param callback callback
  7441. */
  7442. setOnJSCallback(callback: Function): void;
  7443. /**
  7444. !#en
  7445. Evaluates JavaScript in the context of the currently displayed page. <br/>
  7446. Please refer to the official document for more details <br/>
  7447. Note: Cross domain issues need to be resolved by yourself <br/>
  7448. !#zh
  7449. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  7450. 注意:需要自行解决跨域问题
  7451. @param str str
  7452. */
  7453. evaluateJS(str: string): void;
  7454. /**
  7455. !#en if you don't need the WebView and it isn't in any running Scene, you should
  7456. call the destroy method on this component or the associated node explicitly.
  7457. Otherwise, the created DOM element won't be removed from web page.
  7458. !#zh
  7459. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7460. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7461. @example
  7462. ```js
  7463. webview.node.parent = null; // or webview.node.removeFromParent(false);
  7464. // when you don't need webview anymore
  7465. webview.node.destroy();
  7466. ```
  7467. */
  7468. destroy(): void;
  7469. }
  7470. /** !#en
  7471. Stores and manipulate the anchoring based on its parent.
  7472. Widget are used for GUI but can also be used for other things.
  7473. 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.
  7474. !#zh
  7475. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7476. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7477. export class Widget extends Component {
  7478. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7479. The default value is null, and when null, indicates the current parent.
  7480. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7481. target: Node;
  7482. /** !#en Whether to align the top.
  7483. !#zh 是否对齐上边。 */
  7484. isAlignTop: boolean;
  7485. /** !#en
  7486. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7487. !#zh
  7488. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7489. isAlignVerticalCenter: boolean;
  7490. /** !#en Whether to align the bottom.
  7491. !#zh 是否对齐下边。 */
  7492. isAlignBottom: boolean;
  7493. /** !#en Whether to align the left.
  7494. !#zh 是否对齐左边 */
  7495. isAlignLeft: boolean;
  7496. /** !#en
  7497. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7498. !#zh
  7499. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7500. isAlignHorizontalCenter: boolean;
  7501. /** !#en Whether to align the right.
  7502. !#zh 是否对齐右边。 */
  7503. isAlignRight: boolean;
  7504. /** !#en
  7505. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7506. the width setting is invalid (read only).
  7507. !#zh
  7508. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7509. isStretchWidth: boolean;
  7510. /** !#en
  7511. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7512. then height setting is invalid (read only)
  7513. !#zh
  7514. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7515. isStretchHeight: boolean;
  7516. /** !#en
  7517. The margins between the top of this node and the top of parent node,
  7518. the value can be negative, Only available in 'isAlignTop' open.
  7519. !#zh
  7520. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7521. top: number;
  7522. /** !#en
  7523. The margins between the bottom of this node and the bottom of parent node,
  7524. the value can be negative, Only available in 'isAlignBottom' open.
  7525. !#zh
  7526. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7527. bottom: number;
  7528. /** !#en
  7529. The margins between the left of this node and the left of parent node,
  7530. the value can be negative, Only available in 'isAlignLeft' open.
  7531. !#zh
  7532. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7533. left: number;
  7534. /** !#en
  7535. The margins between the right of this node and the right of parent node,
  7536. the value can be negative, Only available in 'isAlignRight' open.
  7537. !#zh
  7538. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7539. right: number;
  7540. /** !#en
  7541. Horizontal aligns the midpoint offset value,
  7542. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7543. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7544. horizontalCenter: number;
  7545. /** !#en
  7546. Vertical aligns the midpoint offset value,
  7547. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7548. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7549. verticalCenter: number;
  7550. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7551. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7552. isAbsoluteHorizontalCenter: boolean;
  7553. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7554. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7555. isAbsoluteVerticalCenter: boolean;
  7556. /** !#en
  7557. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7558. !#zh
  7559. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7560. isAbsoluteTop: boolean;
  7561. /** !#en
  7562. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7563. !#zh
  7564. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7565. isAbsoluteBottom: boolean;
  7566. /** !#en
  7567. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7568. !#zh
  7569. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7570. isAbsoluteLeft: boolean;
  7571. /** !#en
  7572. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7573. !#zh
  7574. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7575. isAbsoluteRight: boolean;
  7576. /** !#en TODO
  7577. !#zh
  7578. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7579. 这样便于脚本或动画继续控制当前节点。
  7580. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7581. isAlignOnce: boolean;
  7582. /**
  7583. !#en
  7584. Immediately perform the widget alignment. You need to manually call this method only if
  7585. you need to get the latest results after the alignment before the end of current frame.
  7586. !#zh
  7587. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7588. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7589. @example
  7590. ```js
  7591. widget.top = 10; // change top margin
  7592. cc.log(widget.node.y); // not yet changed
  7593. widget.updateAlignment();
  7594. cc.log(widget.node.y); // changed
  7595. ```
  7596. */
  7597. updateAlignment(): void;
  7598. }
  7599. /** !#en
  7600. EventTarget is an object to which an event is dispatched when something has occurred.
  7601. Entity are the most common event targets, but other objects can be event targets too.
  7602. Event targets are an important part of the Fireball event model.
  7603. The event target serves as the focal point for how events flow through the scene graph.
  7604. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7605. into the event flow from the root of the hierarchy. The event object then makes its way through
  7606. the scene graph until it reaches the event target, at which point it begins its return trip through
  7607. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7608. - The capture phase comprises the journey from the root to the last node before the event target's node
  7609. - The target phase comprises only the event target node
  7610. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7611. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7612. Event targets can implement the following methods:
  7613. - _getCapturingTargets
  7614. - _getBubblingTargets
  7615. !#zh
  7616. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7617. 但是其他对象也可以是事件目标。<br/> */
  7618. export class EventTarget {
  7619. /**
  7620. !#en
  7621. Register an callback of a specific event type on the EventTarget.
  7622. !#zh
  7623. 注册事件目标的特定事件类型回调。
  7624. @param type A string representing the event type to listen for.
  7625. @param callback The callback that will be invoked when the event is dispatched.
  7626. The callback is ignored if it is a duplicate (the callbacks are unique).
  7627. @param target The target (this object) to invoke the callback, can be null
  7628. @param useCapture When set to true, the capture argument prevents callback
  7629. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7630. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7631. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7632. @example
  7633. ```js
  7634. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7635. cc.log("this is callback");
  7636. }, node);
  7637. ```
  7638. */
  7639. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7640. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7641. /**
  7642. !#en
  7643. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7644. if only type is passed as parameter, all listeners registered with that type will be removed.
  7645. !#zh
  7646. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7647. @param type A string representing the event type being removed.
  7648. @param callback The callback to remove.
  7649. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7650. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7651. If not specified, useCapture defaults to false. If a callback was registered twice,
  7652. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7653. does not affect a non-capturing version of the same listener, and vice versa.
  7654. @example
  7655. ```js
  7656. // register touchEnd eventListener
  7657. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7658. cc.log("this is callback");
  7659. }, node);
  7660. // remove touch end event listener
  7661. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7662. // remove all touch end event listeners
  7663. node.off(cc.Node.EventType.TOUCH_END);
  7664. ```
  7665. */
  7666. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7667. /**
  7668. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7669. This is not for removing all listeners in the current event target,
  7670. and this is not for removing all listeners the target parameter have registered.
  7671. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7672. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7673. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7674. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7675. @param target The target to be searched for all related listeners
  7676. */
  7677. targetOff(target: any): void;
  7678. /**
  7679. !#en
  7680. Register an callback of a specific event type on the EventTarget,
  7681. the callback will remove itself after the first time it is triggered.
  7682. !#zh
  7683. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7684. @param type A string representing the event type to listen for.
  7685. @param callback The callback that will be invoked when the event is dispatched.
  7686. The callback is ignored if it is a duplicate (the callbacks are unique).
  7687. @param target The target (this object) to invoke the callback, can be null
  7688. @param useCapture When set to true, the capture argument prevents callback
  7689. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7690. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7691. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7692. @example
  7693. ```js
  7694. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7695. cc.log("this is callback");
  7696. }, node);
  7697. ```
  7698. */
  7699. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7700. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7701. /**
  7702. !#en
  7703. Dispatches an event into the event flow.
  7704. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7705. !#zh 分发事件到事件流中。
  7706. @param event The Event object that is dispatched into the event flow
  7707. */
  7708. dispatchEvent(event: Event): void;
  7709. /**
  7710. !#en
  7711. Send an event to this object directly, this method will not propagate the event to any other objects.
  7712. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  7713. !#zh
  7714. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  7715. @param message the message to send
  7716. @param detail whatever argument the message needs
  7717. */
  7718. emit(message: string, detail?: any): void;
  7719. }
  7720. /** !#en Base class of all kinds of events.
  7721. !#zh 包含事件相关信息的对象。 */
  7722. export class Event {
  7723. /**
  7724. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  7725. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  7726. */
  7727. constructor(type: string, bubbles: boolean);
  7728. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  7729. !#zh 事件类型。 */
  7730. type: string;
  7731. /** !#en Indicate whether the event bubbles up through the tree or not.
  7732. !#zh 表示该事件是否进行冒泡。 */
  7733. bubbles: boolean;
  7734. /** !#en A reference to the target to which the event was originally dispatched.
  7735. !#zh 最初事件触发的目标 */
  7736. target: any;
  7737. /** !#en A reference to the currently registered target for the event.
  7738. !#zh 当前目标 */
  7739. currentTarget: any;
  7740. /** !#en
  7741. Indicates which phase of the event flow is currently being evaluated.
  7742. Returns an integer value represented by 4 constants:
  7743. - Event.NONE = 0
  7744. - Event.CAPTURING_PHASE = 1
  7745. - Event.AT_TARGET = 2
  7746. - Event.BUBBLING_PHASE = 3
  7747. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  7748. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  7749. !#zh 事件阶段 */
  7750. eventPhase: number;
  7751. /**
  7752. !#en Reset the event for being stored in the object pool.
  7753. !#zh 重置对象池中存储的事件。
  7754. */
  7755. unuse(): string;
  7756. /**
  7757. !#en Reuse the event for being used again by the object pool.
  7758. !#zh 用于对象池再次使用的事件。
  7759. */
  7760. reuse(): string;
  7761. /**
  7762. !#en Stops propagation for current event.
  7763. !#zh 停止传递当前事件。
  7764. */
  7765. stopPropagation(): void;
  7766. /**
  7767. !#en Stops propagation for current event immediately,
  7768. the event won't even be dispatched to the listeners attached in the current target.
  7769. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  7770. */
  7771. stopPropagationImmediate(): void;
  7772. /**
  7773. !#en Checks whether the event has been stopped.
  7774. !#zh 检查该事件是否已经停止传递.
  7775. */
  7776. isStopped(): boolean;
  7777. /**
  7778. !#en
  7779. <p>
  7780. Gets current target of the event <br/>
  7781. note: It only be available when the event listener is associated with node. <br/>
  7782. It returns 0 when the listener is associated with fixed priority.
  7783. </p>
  7784. !#zh 获取当前目标节点
  7785. */
  7786. getCurrentTarget(): Node;
  7787. /**
  7788. !#en Gets the event type.
  7789. !#zh 获取事件类型
  7790. */
  7791. getType(): string;
  7792. /** !#en Code for event without type.
  7793. !#zh 没有类型的事件 */
  7794. static NO_TYPE: string;
  7795. /** !#en The type code of Touch event.
  7796. !#zh 触摸事件类型 */
  7797. static TOUCH: string;
  7798. /** !#en The type code of Mouse event.
  7799. !#zh 鼠标事件类型 */
  7800. static MOUSE: string;
  7801. /** !#en The type code of Keyboard event.
  7802. !#zh 键盘事件类型 */
  7803. static KEYBOARD: string;
  7804. /** !#en The type code of Acceleration event.
  7805. !#zh 加速器事件类型 */
  7806. static ACCELERATION: string;
  7807. /** !#en Events not currently dispatched are in this phase
  7808. !#zh 尚未派发事件阶段 */
  7809. static NONE: number;
  7810. /** !#en
  7811. The capturing phase comprises the journey from the root to the last node before the event target's node
  7812. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7813. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  7814. static CAPTURING_PHASE: number;
  7815. /** !#en
  7816. The target phase comprises only the event target node
  7817. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7818. !#zh 目标阶段仅包括事件目标节点。 */
  7819. static AT_TARGET: number;
  7820. /** !#en
  7821. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  7822. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7823. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  7824. static BUBBLING_PHASE: number;
  7825. }
  7826. /** !#en The System event, it currently supports the key events and accelerometer events
  7827. !#zh 系统事件,它目前支持按键事件和重力感应事件 */
  7828. export class SystemEvent extends EventTarget {
  7829. /**
  7830. !#en whether enable accelerometer event
  7831. !#zh 是否启用加速度计事件
  7832. @param isEnable isEnable
  7833. */
  7834. setAccelerometerEnabled(isEnable: boolean): void;
  7835. /**
  7836. !#en set accelerometer interval value
  7837. !#zh 设置加速度计间隔值
  7838. @param interval interval
  7839. */
  7840. setAccelerometerInterval(interval: number): void;
  7841. }
  7842. /** !#en
  7843. <p>
  7844. The base class of event listener. <br/>
  7845. If you need custom listener which with different callback, you need to inherit this class. <br/>
  7846. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  7847. EventListenerTouchOneByOne, EventListenerCustom.
  7848. </p>
  7849. !#zh
  7850. 封装用户的事件处理逻辑。
  7851. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  7852. export class EventListener {
  7853. /**
  7854. Constructor
  7855. @param type type
  7856. @param listenerID listenerID
  7857. @param callback callback
  7858. */
  7859. constructor(type: number, listenerID: number, callback: number);
  7860. /**
  7861. !#en Checks whether the listener is available.
  7862. !#zh 检测监听器是否有效
  7863. */
  7864. checkAvailable(): boolean;
  7865. /**
  7866. !#en Clones the listener, its subclasses have to override this method.
  7867. !#zh 克隆监听器,它的子类必须重写此方法。
  7868. */
  7869. clone(): EventListener;
  7870. /**
  7871. !#en Enables or disables the listener
  7872. !#zh 启用或禁用监听器。
  7873. @param enabled enabled
  7874. */
  7875. setEnabled(enabled: boolean): void;
  7876. /**
  7877. !#en Checks whether the listener is enabled
  7878. !#zh 检查监听器是否可用。
  7879. */
  7880. isEnabled(): boolean;
  7881. /** !#en The type code of unknown event listener.
  7882. !#zh 未知的事件监听器类型 */
  7883. static UNKNOWN: number;
  7884. /** !#en The type code of keyboard event listener.
  7885. !#zh 键盘事件监听器类型 */
  7886. static KEYBOARD: number;
  7887. /** !#en The type code of acceleration event listener.
  7888. !#zh 加速器事件监听器类型 */
  7889. static ACCELERATION: number;
  7890. /**
  7891. !#en
  7892. Create a EventListener object with configuration including the event type, handlers and other parameters.
  7893. In handlers, this refer to the event listener object itself.
  7894. You can also pass custom parameters in the configuration object,
  7895. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  7896. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  7897. @param argObj a json object
  7898. @example
  7899. ```js
  7900. // Create KEYBOARD EventListener.
  7901. cc.EventListener.create({
  7902. event: cc.EventListener.KEYBOARD,
  7903. onKeyPressed: function (keyCode, event) {
  7904. cc.log('pressed key: ' + keyCode);
  7905. },
  7906. onKeyReleased: function (keyCode, event) {
  7907. cc.log('released key: ' + keyCode);
  7908. }
  7909. });
  7910. // Create ACCELERATION EventListener.
  7911. cc.EventListener.create({
  7912. event: cc.EventListener.ACCELERATION,
  7913. callback: function (acc, event) {
  7914. cc.log('acc: ' + keyCode);
  7915. }
  7916. });
  7917. ```
  7918. */
  7919. static create(argObj: any): EventListener;
  7920. }
  7921. /** !#en
  7922. 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>
  7923. <br>
  7924. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
  7925. The EventListener list is managed in such way so that event listeners can be added and removed
  7926. while events are being dispatched.
  7927. !#zh
  7928. 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。<br>
  7929. <br>
  7930. 事件管理器,它主要管理事件监听器注册和派发系统事件。 */
  7931. export class eventManager {
  7932. /**
  7933. !#en Pauses all listeners which are associated the specified target.
  7934. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  7935. @param node node
  7936. @param recursive recursive
  7937. */
  7938. static pauseTarget(node: Node, recursive?: boolean): void;
  7939. /**
  7940. !#en Resumes all listeners which are associated the specified target.
  7941. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  7942. @param node node
  7943. @param recursive recursive
  7944. */
  7945. static resumeTarget(node: Node, recursive?: boolean): void;
  7946. /**
  7947. !#en Query whether the specified event listener id has been added.
  7948. !#zh 查询指定的事件 ID 是否存在
  7949. @param listenerID The listener id.
  7950. */
  7951. static hasEventListener(listenerID: string|number): boolean;
  7952. /**
  7953. !#en
  7954. <p>
  7955. Adds a event listener for a specified event.<br/>
  7956. if the parameter "nodeOrPriority" is a node,
  7957. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  7958. if the parameter "nodeOrPriority" is a Number,
  7959. it means to add a event listener for a specified event with the fixed priority.<br/>
  7960. </p>
  7961. !#zh
  7962. 将事件监听器添加到事件管理器中。<br/>
  7963. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  7964. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  7965. @param listener The listener of a specified event or a object of some event parameters.
  7966. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  7967. */
  7968. static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener;
  7969. /**
  7970. !#en Remove a listener.
  7971. !#zh 移除一个已添加的监听器。
  7972. @param listener an event listener or a registered node target
  7973. @example
  7974. ```js
  7975. // 1. remove eventManager add Listener;
  7976. var mouseListener1 = cc.eventManager.addListener({
  7977. event: cc.EventListener.MOUSE,
  7978. onMouseDown: function(keyCode, event){ },
  7979. onMouseUp: function(keyCode, event){ },
  7980. onMouseMove: function () { },
  7981. onMouseScroll: function () { }
  7982. }, node);
  7983. cc.eventManager.removeListener(mouseListener1);
  7984. // 2. remove eventListener create Listener;
  7985. var mouseListener2 = cc.EventListener.create({
  7986. event: cc.EventListener.MOUSE,
  7987. onMouseDown: function(keyCode, event){ },
  7988. onMouseUp: function(keyCode, event){ },
  7989. onMouseMove: function () { },
  7990. onMouseScroll: function () { }
  7991. });
  7992. cc.eventManager.removeListener(mouseListener2);
  7993. ```
  7994. */
  7995. static removeListener(listener: EventListener): void;
  7996. /**
  7997. !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  7998. !#zh
  7999. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  8000. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  8001. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  8002. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  8003. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  8004. 下列是目前存在监听器类型: <br/>
  8005. cc.EventListener.UNKNOWN <br/>
  8006. cc.EventListener.KEYBOARD <br/>
  8007. cc.EventListener.ACCELERATION,<br/>
  8008. @param listenerType listenerType or a node
  8009. @param recursive recursive
  8010. */
  8011. static removeListeners(listenerType: number|Node, recursive?: boolean): void;
  8012. /**
  8013. !#en Removes all listeners
  8014. !#zh 移除所有事件监听器。
  8015. */
  8016. static removeAllListeners(): void;
  8017. /**
  8018. !#en Sets listener's priority with fixed value.
  8019. !#zh 设置 FixedPriority 类型监听器的优先级。
  8020. @param listener listener
  8021. @param fixedPriority fixedPriority
  8022. */
  8023. static setPriority(listener: EventListener, fixedPriority: number): void;
  8024. /**
  8025. !#en Whether to enable dispatching events
  8026. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  8027. @param enabled enabled
  8028. */
  8029. static setEnabled(enabled: boolean): void;
  8030. /**
  8031. !#en Checks whether dispatching events is enabled
  8032. !#zh 检测事件管理器是否启用。
  8033. */
  8034. static isEnabled(): boolean;
  8035. }
  8036. /** !#en The touch event class
  8037. !#zh 封装了触摸相关的信息。 */
  8038. export class Touch {
  8039. /**
  8040. !#en Returns the current touch location in OpenGL coordinates.、
  8041. !#zh 获取当前触点位置。
  8042. */
  8043. getLocation(): Vec2;
  8044. /**
  8045. !#en Returns X axis location value.
  8046. !#zh 获取当前触点 X 轴位置。
  8047. */
  8048. getLocationX(): number;
  8049. /**
  8050. !#en Returns Y axis location value.
  8051. !#zh 获取当前触点 Y 轴位置。
  8052. */
  8053. getLocationY(): number;
  8054. /**
  8055. !#en Returns the previous touch location in OpenGL coordinates.
  8056. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  8057. */
  8058. getPreviousLocation(): Vec2;
  8059. /**
  8060. !#en Returns the start touch location in OpenGL coordinates.
  8061. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  8062. */
  8063. getStartLocation(): Vec2;
  8064. /**
  8065. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  8066. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  8067. */
  8068. getDelta(): Vec2;
  8069. /**
  8070. !#en Returns the current touch location in screen coordinates.
  8071. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  8072. */
  8073. getLocationInView(): Vec2;
  8074. /**
  8075. !#en Returns the previous touch location in screen coordinates.
  8076. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8077. */
  8078. getPreviousLocationInView(): Vec2;
  8079. /**
  8080. !#en Returns the start touch location in screen coordinates.
  8081. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8082. */
  8083. getStartLocationInView(): Vec2;
  8084. /**
  8085. !#en Returns the id of cc.Touch.
  8086. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  8087. */
  8088. getID(): number;
  8089. /**
  8090. !#en Sets information to touch.
  8091. !#zh 设置触摸相关的信息。用于监控触摸事件。
  8092. @param id id
  8093. @param x x
  8094. @param y y
  8095. */
  8096. setTouchInfo(id: number, x: number, y: number): void;
  8097. }
  8098. /** undefined */
  8099. export class Graphics extends _RendererUnderSG {
  8100. /** !#en
  8101. Current line width.
  8102. !#zh
  8103. 当前线条宽度 */
  8104. lineWidth: number;
  8105. /** !#en
  8106. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  8107. !#zh
  8108. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  8109. lineJoin: Graphics.LineJoin;
  8110. /** !#en
  8111. lineCap determines how the end points of every line are drawn.
  8112. !#zh
  8113. lineCap 指定如何绘制每一条线段末端。 */
  8114. lineCap: Graphics.LineCap;
  8115. /** !#en
  8116. stroke color
  8117. !#zh
  8118. 线段颜色 */
  8119. strokeColor: Color;
  8120. /** !#en
  8121. fill color
  8122. !#zh
  8123. 填充颜色 */
  8124. fillColor: Color;
  8125. /** !#en
  8126. Sets the miter limit ratio
  8127. !#zh
  8128. 设置斜接面限制比例 */
  8129. miterLimit: number;
  8130. /**
  8131. !#en Move path start point to (x,y).
  8132. !#zh 移动路径起点到坐标(x, y)
  8133. @param x The x axis of the coordinate for the end point.
  8134. @param y The y axis of the coordinate for the end point.
  8135. */
  8136. moveTo(x?: number, y?: number): void;
  8137. /**
  8138. !#en Adds a straight line to the path
  8139. !#zh 绘制直线路径
  8140. @param x The x axis of the coordinate for the end point.
  8141. @param y The y axis of the coordinate for the end point.
  8142. */
  8143. lineTo(x?: number, y?: number): void;
  8144. /**
  8145. !#en Adds a cubic Bézier curve to the path
  8146. !#zh 绘制三次贝赛尔曲线路径
  8147. @param c1x The x axis of the coordinate for the first control point.
  8148. @param c1y The y axis of the coordinate for first control point.
  8149. @param c2x The x axis of the coordinate for the second control point.
  8150. @param c2y The y axis of the coordinate for the second control point.
  8151. @param x The x axis of the coordinate for the end point.
  8152. @param y The y axis of the coordinate for the end point.
  8153. */
  8154. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  8155. /**
  8156. !#en Adds a quadratic Bézier curve to the path
  8157. !#zh 绘制二次贝赛尔曲线路径
  8158. @param cx The x axis of the coordinate for the control point.
  8159. @param cy The y axis of the coordinate for the control point.
  8160. @param x The x axis of the coordinate for the end point.
  8161. @param y The y axis of the coordinate for the end point.
  8162. */
  8163. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  8164. /**
  8165. !#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).
  8166. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  8167. @param cx The x axis of the coordinate for the center point.
  8168. @param cy The y axis of the coordinate for the center point.
  8169. @param r The arc's radius.
  8170. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  8171. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  8172. @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.
  8173. */
  8174. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: number): void;
  8175. /**
  8176. !#en Adds an ellipse to the path.
  8177. !#zh 绘制椭圆路径。
  8178. @param cx The x axis of the coordinate for the center point.
  8179. @param cy The y axis of the coordinate for the center point.
  8180. @param rx The ellipse's x-axis radius.
  8181. @param ry The ellipse's y-axis radius.
  8182. */
  8183. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  8184. /**
  8185. !#en Adds an circle to the path.
  8186. !#zh 绘制圆形路径。
  8187. @param cx The x axis of the coordinate for the center point.
  8188. @param cy The y axis of the coordinate for the center point.
  8189. @param r The circle's radius.
  8190. */
  8191. circle(cx?: number, cy?: number, r?: number): void;
  8192. /**
  8193. !#en Adds an rectangle to the path.
  8194. !#zh 绘制矩形路径。
  8195. @param x The x axis of the coordinate for the rectangle starting point.
  8196. @param y The y axis of the coordinate for the rectangle starting point.
  8197. @param w The rectangle's width.
  8198. @param h The rectangle's height.
  8199. */
  8200. rect(x?: number, y?: number, w?: number, h?: number): void;
  8201. /**
  8202. !#en Adds an round corner rectangle to the path.
  8203. !#zh 绘制圆角矩形路径。
  8204. @param x The x axis of the coordinate for the rectangle starting point.
  8205. @param y The y axis of the coordinate for the rectangle starting point.
  8206. @param w The rectangles width.
  8207. @param h The rectangle's height.
  8208. @param r The radius of the rectangle.
  8209. */
  8210. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  8211. /**
  8212. !#en Draws a filled rectangle.
  8213. !#zh 绘制填充矩形。
  8214. @param x The x axis of the coordinate for the rectangle starting point.
  8215. @param y The y axis of the coordinate for the rectangle starting point.
  8216. @param w The rectangle's width.
  8217. @param h The rectangle's height.
  8218. */
  8219. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  8220. /**
  8221. !#en Erasing any previously drawn content.
  8222. !#zh 擦除之前绘制的所有内容的方法。
  8223. @param clean Whether to clean the graphics inner cache.
  8224. */
  8225. clear(clean?: boolean): void;
  8226. /**
  8227. !#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.
  8228. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  8229. */
  8230. close(): void;
  8231. /**
  8232. !#en Strokes the current or given path with the current stroke style.
  8233. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  8234. */
  8235. stroke(): void;
  8236. /**
  8237. !#en Fills the current or given path with the current fill style.
  8238. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  8239. */
  8240. fill(): void;
  8241. }
  8242. /** undefined */
  8243. export class WorldManifold {
  8244. /** !#en
  8245. world contact point (point of intersection)
  8246. !#zh
  8247. 碰撞点集合 */
  8248. points: [Vec2];
  8249. /** !#en
  8250. world vector pointing from A to B
  8251. !#zh
  8252. 世界坐标系下由 A 指向 B 的向量 */
  8253. normal: Vec2;
  8254. }
  8255. /** !#en
  8256. A manifold point is a contact point belonging to a contact manifold.
  8257. It holds details related to the geometry and dynamics of the contact points.
  8258. Note: the impulses are used for internal caching and may not
  8259. provide reliable contact forces, especially for high speed collisions.
  8260. !#zh
  8261. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  8262. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  8263. export class ManifoldPoint {
  8264. /** !#en
  8265. The local point usage depends on the manifold type:
  8266. -e_circles: the local center of circleB
  8267. -e_faceA: the local center of circleB or the clip point of polygonB
  8268. -e_faceB: the clip point of polygonA
  8269. !#zh
  8270. 本地坐标点的用途取决于 manifold 的类型
  8271. - e_circles: circleB 的本地中心点
  8272. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  8273. - e_faceB: polygonB 的截取点 */
  8274. localPoint: Vec2;
  8275. /** !#en
  8276. Normal impulse.
  8277. !#zh
  8278. 法线冲量。 */
  8279. normalImpulse: number;
  8280. /** !#en
  8281. Tangent impulse.
  8282. !#zh
  8283. 切线冲量。 */
  8284. tangentImpulse: number;
  8285. }
  8286. /** undefined */
  8287. export class Manifold {
  8288. /** !#en
  8289. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  8290. !#zh
  8291. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  8292. type: number;
  8293. /** !#en
  8294. The local point usage depends on the manifold type:
  8295. -e_circles: the local center of circleA
  8296. -e_faceA: the center of faceA
  8297. -e_faceB: the center of faceB
  8298. !#zh
  8299. 用途取决于 manifold 类型
  8300. -e_circles: circleA 的本地中心点
  8301. -e_faceA: faceA 的本地中心点
  8302. -e_faceB: faceB 的本地中心点 */
  8303. localPoint: Vec2;
  8304. /** !#en
  8305. -e_circles: not used
  8306. -e_faceA: the normal on polygonA
  8307. -e_faceB: the normal on polygonB
  8308. !#zh
  8309. -e_circles: 没被使用到
  8310. -e_faceA: polygonA 的法向量
  8311. -e_faceB: polygonB 的法向量 */
  8312. localNormal: Vec2;
  8313. /** !#en
  8314. the points of contact.
  8315. !#zh
  8316. 接触点信息。 */
  8317. points: [ManifoldPoint];
  8318. }
  8319. /** !#en
  8320. Contact impulses for reporting.
  8321. !#zh
  8322. 用于返回给回调的接触冲量。 */
  8323. export class PhysicsImpulse {
  8324. /** !#en
  8325. Normal impulses.
  8326. !#zh
  8327. 法线方向的冲量 */
  8328. normalImpulses: void;
  8329. /** !#en
  8330. Tangent impulses
  8331. !#zh
  8332. 切线方向的冲量 */
  8333. tangentImpulses: void;
  8334. }
  8335. /** !#en
  8336. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  8337. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  8338. !#zh
  8339. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  8340. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  8341. export class PhysicsContact {
  8342. /**
  8343. !#en
  8344. Get the world manifold.
  8345. !#zh
  8346. 获取世界坐标系下的碰撞信息。
  8347. */
  8348. getWorldManifold(): WorldManifold;
  8349. /**
  8350. !#en
  8351. Get the manifold.
  8352. !#zh
  8353. 获取世界坐标系下的碰撞信息。
  8354. */
  8355. getManifold(): Manifold;
  8356. /**
  8357. !#en
  8358. Get the impulses.
  8359. Note: PhysicsImpulse can only used in onPostSolve callback.
  8360. !#zh
  8361. 获取冲量信息
  8362. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  8363. */
  8364. getImpulse(): PhysicsImpulse;
  8365. colliderA: Collider;
  8366. colliderB: Collider;
  8367. /** !#en
  8368. If set disabled to true, the contact will be ignored until contact end.
  8369. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  8370. !#zh
  8371. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  8372. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  8373. disabled: boolean;
  8374. /** !#en
  8375. Disabled contact for current time step or sub-step.
  8376. !#zh
  8377. 在当前时间步或子步中忽略此接触。 */
  8378. disabledOnce: boolean;
  8379. /**
  8380. !#en
  8381. Is this contact touching?
  8382. !#zh
  8383. 返回碰撞体是否已经接触到。
  8384. */
  8385. isTouching(): boolean;
  8386. /**
  8387. !#en
  8388. Set the desired tangent speed for a conveyor belt behavior.
  8389. !#zh
  8390. 为传送带设置期望的切线速度
  8391. @param tangentSpeed tangentSpeed
  8392. */
  8393. setTangentSpeed(tangentSpeed: number): void;
  8394. /**
  8395. !#en
  8396. Get the desired tangent speed.
  8397. !#zh
  8398. 获取切线速度
  8399. */
  8400. getTangentSpeed(): number;
  8401. /**
  8402. !#en
  8403. Override the default friction mixture. You can call this in onPreSolve callback.
  8404. !#zh
  8405. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  8406. @param friction friction
  8407. */
  8408. setFriction(friction: number): void;
  8409. /**
  8410. !#en
  8411. Get the friction.
  8412. !#zh
  8413. 获取当前摩擦力系数
  8414. */
  8415. getFriction(): number;
  8416. /**
  8417. !#en
  8418. Reset the friction mixture to the default value.
  8419. !#zh
  8420. 重置摩擦力系数到默认值
  8421. */
  8422. resetFriction(): void;
  8423. /**
  8424. !#en
  8425. Override the default restitution mixture. You can call this in onPreSolve callback.
  8426. !#zh
  8427. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  8428. @param restitution restitution
  8429. */
  8430. setRestitution(restitution: number): void;
  8431. /**
  8432. !#en
  8433. Get the restitution.
  8434. !#zh
  8435. 获取当前恢复系数
  8436. */
  8437. getRestitution(): number;
  8438. /**
  8439. !#en
  8440. Reset the restitution mixture to the default value.
  8441. !#zh
  8442. 重置恢复系数到默认值
  8443. */
  8444. resetRestitution(): void;
  8445. }
  8446. /** !#en
  8447. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  8448. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  8449. Physics manager distributes the collision information to each collision callback when collision is produced.
  8450. Note: You need first enable the collision listener in the rigidbody.
  8451. !#zh
  8452. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  8453. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  8454. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  8455. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */
  8456. export class PhysicsManager implements EventTarget {
  8457. /** !#en
  8458. The draw bits for drawing physics debug information.
  8459. !#zh
  8460. 指定物理系统需要绘制哪些调试信息。 */
  8461. static DrawBits: DrawBits;
  8462. /** !#en
  8463. The ratio transform between physics unit and pixel unit, generally is 32.
  8464. !#zh
  8465. 物理单位与像素单位互相转换的比率,一般是 32。 */
  8466. static PTM_RATIO: number;
  8467. /** !#en
  8468. The velocity iterations for the velocity constraint solver.
  8469. !#zh
  8470. 速度更新迭代数 */
  8471. static VELOCITY_ITERATIONS: number;
  8472. /** !#en
  8473. The position Iterations for the position constraint solver.
  8474. !#zh
  8475. 位置迭代更新数 */
  8476. static POSITION_ITERATIONS: number;
  8477. /** !#en
  8478. Specify the fixed time step.
  8479. Need enabledAccumulator to make it work.
  8480. !#zh
  8481. 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */
  8482. static FIXED_TIME_STEP: number;
  8483. /** !#en
  8484. Specify the max accumulator time.
  8485. Need enabledAccumulator to make it work.
  8486. !#zh
  8487. 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */
  8488. static MAX_ACCUMULATOR: number;
  8489. /** !#en
  8490. If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
  8491. And if the update dt is bigger than the time step, then will call step function several times.
  8492. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  8493. !#zh
  8494. 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
  8495. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */
  8496. enabledAccumulator: boolean;
  8497. /**
  8498. !#en
  8499. Test which collider contains the given world point
  8500. !#zh
  8501. 获取包含给定世界坐标系点的碰撞体
  8502. @param point the world point
  8503. */
  8504. testPoint(point: Vec2): PhysicsCollider;
  8505. /**
  8506. !#en
  8507. Test which colliders intersect the given world rect
  8508. !#zh
  8509. 获取与给定世界坐标系矩形相交的碰撞体
  8510. @param rect the world rect
  8511. */
  8512. testAABB(rect: Rect): [PhysicsCollider];
  8513. /**
  8514. !#en
  8515. Raycast the world for all colliders in the path of the ray.
  8516. The raycast ignores colliders that contain the starting point.
  8517. !#zh
  8518. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  8519. @param p1 start point of the raycast
  8520. @param p2 end point of the raycast
  8521. @param type optional, default is RayCastType.Closest
  8522. */
  8523. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult];
  8524. /**
  8525. !#en
  8526. Attach physics debug draw to camera
  8527. !#zh
  8528. 将物理的调试绘制信息附加到指定摄像机上
  8529. @param camera camera
  8530. */
  8531. attachDebugDrawToCamera(camera: Camera): void;
  8532. /**
  8533. !#en
  8534. Detach physics debug draw to camera
  8535. !#zh
  8536. 将物理的调试绘制信息从指定摄像机上移除
  8537. @param camera camera
  8538. */
  8539. detachDebugDrawFromCamera(camera: Camera): void;
  8540. /** !#en
  8541. Enabled the physics manager?
  8542. !#zh
  8543. 指定是否启用物理系统? */
  8544. enabled: boolean;
  8545. /** !#en
  8546. Debug draw flags.
  8547. !#zh
  8548. 设置调试绘制标志 */
  8549. debugDrawFlags: number;
  8550. /** !#en
  8551. The physics world gravity.
  8552. !#zh
  8553. 物理世界重力值 */
  8554. gravity: Vec2;
  8555. /**
  8556. !#en
  8557. Register an callback of a specific event type on the EventTarget.
  8558. !#zh
  8559. 注册事件目标的特定事件类型回调。
  8560. @param type A string representing the event type to listen for.
  8561. @param callback The callback that will be invoked when the event is dispatched.
  8562. The callback is ignored if it is a duplicate (the callbacks are unique).
  8563. @param target The target (this object) to invoke the callback, can be null
  8564. @param useCapture When set to true, the capture argument prevents callback
  8565. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  8566. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  8567. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  8568. @example
  8569. ```js
  8570. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  8571. cc.log("this is callback");
  8572. }, node);
  8573. ```
  8574. */
  8575. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  8576. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  8577. /**
  8578. !#en
  8579. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  8580. if only type is passed as parameter, all listeners registered with that type will be removed.
  8581. !#zh
  8582. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  8583. @param type A string representing the event type being removed.
  8584. @param callback The callback to remove.
  8585. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  8586. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  8587. If not specified, useCapture defaults to false. If a callback was registered twice,
  8588. one with capture and one without, each must be removed separately. Removal of a capturing callback
  8589. does not affect a non-capturing version of the same listener, and vice versa.
  8590. @example
  8591. ```js
  8592. // register touchEnd eventListener
  8593. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  8594. cc.log("this is callback");
  8595. }, node);
  8596. // remove touch end event listener
  8597. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  8598. // remove all touch end event listeners
  8599. node.off(cc.Node.EventType.TOUCH_END);
  8600. ```
  8601. */
  8602. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  8603. /**
  8604. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  8605. This is not for removing all listeners in the current event target,
  8606. and this is not for removing all listeners the target parameter have registered.
  8607. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  8608. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  8609. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  8610. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  8611. @param target The target to be searched for all related listeners
  8612. */
  8613. targetOff(target: any): void;
  8614. /**
  8615. !#en
  8616. Register an callback of a specific event type on the EventTarget,
  8617. the callback will remove itself after the first time it is triggered.
  8618. !#zh
  8619. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  8620. @param type A string representing the event type to listen for.
  8621. @param callback The callback that will be invoked when the event is dispatched.
  8622. The callback is ignored if it is a duplicate (the callbacks are unique).
  8623. @param target The target (this object) to invoke the callback, can be null
  8624. @param useCapture When set to true, the capture argument prevents callback
  8625. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  8626. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  8627. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  8628. @example
  8629. ```js
  8630. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  8631. cc.log("this is callback");
  8632. }, node);
  8633. ```
  8634. */
  8635. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  8636. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  8637. /**
  8638. !#en
  8639. Dispatches an event into the event flow.
  8640. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  8641. !#zh 分发事件到事件流中。
  8642. @param event The Event object that is dispatched into the event flow
  8643. */
  8644. dispatchEvent(event: Event): void;
  8645. /**
  8646. !#en
  8647. Send an event to this object directly, this method will not propagate the event to any other objects.
  8648. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  8649. !#zh
  8650. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  8651. @param message the message to send
  8652. @param detail whatever argument the message needs
  8653. */
  8654. emit(message: string, detail?: any): void;
  8655. }
  8656. /** undefined */
  8657. export enum DrawBits {
  8658. e_aabbBit = 0,
  8659. e_pairBit = 0,
  8660. e_centerOfMassBit = 0,
  8661. e_jointBit = 0,
  8662. e_shapeBit = 0,
  8663. }
  8664. /** undefined */
  8665. export class PhysicsRayCastResult {
  8666. /** !#en
  8667. The PhysicsCollider which intersects with the raycast
  8668. !#zh
  8669. 与射线相交的碰撞体 */
  8670. collider: PhysicsCollider;
  8671. /** !#en
  8672. The intersection point
  8673. !#zh
  8674. 射线与碰撞体相交的点 */
  8675. point: Vec2;
  8676. /** !#en
  8677. The normal vector at the point of intersection
  8678. !#zh
  8679. 射线与碰撞体相交的点的法向量 */
  8680. normal: Vec2;
  8681. /** !#en
  8682. The fraction of the raycast path at the point of intersection
  8683. !#zh
  8684. 射线与碰撞体相交的点占射线长度的分数 */
  8685. fraction: number;
  8686. }
  8687. /** !#en Enum for RigidBodyType.
  8688. !#zh 刚体类型 */
  8689. export enum RigidBodyType {
  8690. Static = 0,
  8691. Kinematic = 0,
  8692. Dynamic = 0,
  8693. Animated = 0,
  8694. }
  8695. /** !#en Enum for RayCastType.
  8696. !#zh 射线检测类型 */
  8697. export enum RayCastType {
  8698. Closest = 0,
  8699. Any = 0,
  8700. AllClosest = 0,
  8701. All = 0,
  8702. }
  8703. /** undefined */
  8704. export class RigidBody extends Component {
  8705. /** !#en
  8706. Should enabled contact listener?
  8707. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  8708. !#zh
  8709. 是否启用接触接听器。
  8710. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  8711. enabledContactListener: boolean;
  8712. /**
  8713. !#en
  8714. Collision callback.
  8715. Called when two collider begin to touch.
  8716. !#zh
  8717. 碰撞回调。
  8718. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  8719. @param contact contact information
  8720. @param selfCollider the collider belong to this rigidbody
  8721. @param otherCollider the collider belong to another rigidbody
  8722. */
  8723. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  8724. /**
  8725. !#en
  8726. Collision callback.
  8727. Called when two collider cease to touch.
  8728. !#zh
  8729. 碰撞回调。
  8730. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  8731. @param contact contact information
  8732. @param selfCollider the collider belong to this rigidbody
  8733. @param otherCollider the collider belong to another rigidbody
  8734. */
  8735. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  8736. /**
  8737. !#en
  8738. Collision callback.
  8739. This is called when a contact is updated.
  8740. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  8741. Note: this is called only for awake bodies.
  8742. Note: this is called even when the number of contact points is zero.
  8743. Note: this is not called for sensors.
  8744. !#zh
  8745. 碰撞回调。
  8746. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  8747. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  8748. 注意:回调只会为醒着的刚体调用。
  8749. 注意:接触点为零的时候也有可能被调用。
  8750. 注意:感知体(sensor)的回调不会被调用。
  8751. @param contact contact information
  8752. @param selfCollider the collider belong to this rigidbody
  8753. @param otherCollider the collider belong to another rigidbody
  8754. */
  8755. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  8756. /**
  8757. !#en
  8758. Collision callback.
  8759. This is called after a contact is updated.
  8760. You can get the impulses from the contact in this callback.
  8761. !#zh
  8762. 碰撞回调。
  8763. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  8764. 你可以在这个回调中从接触信息中获取到冲量信息。
  8765. @param contact contact information
  8766. @param selfCollider the collider belong to this rigidbody
  8767. @param otherCollider the collider belong to another rigidbody
  8768. */
  8769. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  8770. /** !#en
  8771. Is this a fast moving body that should be prevented from tunneling through
  8772. other moving bodies?
  8773. Note :
  8774. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  8775. - You should use this flag sparingly since it increases processing time.
  8776. !#zh
  8777. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  8778. 需要注意的是 :
  8779. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  8780. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  8781. bullet: boolean;
  8782. /** !#en
  8783. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  8784. !#zh
  8785. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  8786. type: RigidBodyType;
  8787. /** !#en
  8788. Set this flag to false if this body should never fall asleep.
  8789. Note that this increases CPU usage.
  8790. !#zh
  8791. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  8792. 需要注意这将使 CPU 占用率提高。 */
  8793. allowSleep: boolean;
  8794. /** !#en
  8795. Scale the gravity applied to this body.
  8796. !#zh
  8797. 缩放应用在此刚体上的重力值 */
  8798. gravityScale: number;
  8799. /** !#en
  8800. Linear damping is use to reduce the linear velocity.
  8801. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  8802. time step when the damping parameter is large.
  8803. !#zh
  8804. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  8805. linearDamping: number;
  8806. /** !#en
  8807. Angular damping is use to reduce the angular velocity. The damping parameter
  8808. can be larger than 1 but the damping effect becomes sensitive to the
  8809. time step when the damping parameter is large.
  8810. !#zh
  8811. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  8812. angularDamping: number;
  8813. /** !#en
  8814. The linear velocity of the body's origin in world co-ordinates.
  8815. !#zh
  8816. 刚体在世界坐标下的线性速度 */
  8817. linearVelocity: Vec2;
  8818. /** !#en
  8819. The angular velocity of the body.
  8820. !#zh
  8821. 刚体的角速度 */
  8822. angularVelocity: number;
  8823. /** !#en
  8824. Should this body be prevented from rotating?
  8825. !#zh
  8826. 是否禁止此刚体进行旋转 */
  8827. fixedRotation: boolean;
  8828. /** !#en
  8829. Is this body initially awake or sleeping?
  8830. !#zh
  8831. 是否立刻唤醒此刚体 */
  8832. awake: boolean;
  8833. /** !#en
  8834. Set the active state of the body. An inactive body is not
  8835. simulated and cannot be collided with or woken up.
  8836. If body is active, all fixtures will be added to the
  8837. broad-phase.
  8838. If body is inactive, all fixtures will be removed from
  8839. the broad-phase and all contacts will be destroyed.
  8840. Fixtures on an inactive body are implicitly inactive and will
  8841. not participate in collisions, ray-casts, or queries.
  8842. Joints connected to an inactive body are implicitly inactive.
  8843. !#zh
  8844. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  8845. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  8846. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  8847. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  8848. 链接到非激活状态下刚体的关节也是非激活的。 */
  8849. active: boolean;
  8850. /**
  8851. !#en
  8852. Gets a local point relative to the body's origin given a world point.
  8853. !#zh
  8854. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  8855. @param worldPoint a point in world coordinates.
  8856. @param out optional, the receiving point
  8857. */
  8858. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  8859. /**
  8860. !#en
  8861. Get the world coordinates of a point given the local coordinates.
  8862. !#zh
  8863. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  8864. @param localPoint a point in local coordinates.
  8865. @param out optional, the receiving point
  8866. */
  8867. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  8868. /**
  8869. !#en
  8870. Get the world coordinates of a vector given the local coordinates.
  8871. !#zh
  8872. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  8873. @param localVector a vector in world coordinates.
  8874. @param out optional, the receiving vector
  8875. */
  8876. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  8877. /**
  8878. !#en
  8879. Gets a local vector relative to the body's origin given a world vector.
  8880. !#zh
  8881. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  8882. @param worldVector a vector in world coordinates.
  8883. @param out optional, the receiving vector
  8884. */
  8885. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  8886. /**
  8887. !#en
  8888. Get the world body origin position.
  8889. !#zh
  8890. 获取刚体世界坐标系下的原点值
  8891. @param out optional, the receiving point
  8892. */
  8893. getWorldPosition(out: Vec2): Vec2;
  8894. /**
  8895. !#en
  8896. Get the world body rotation angle.
  8897. !#zh
  8898. 获取刚体世界坐标系下的旋转值。
  8899. */
  8900. getWorldRotation(): number;
  8901. /**
  8902. !#en
  8903. Get the local position of the center of mass.
  8904. !#zh
  8905. 获取刚体本地坐标系下的质心
  8906. */
  8907. getLocalCenter(): Vec2;
  8908. /**
  8909. !#en
  8910. Get the world position of the center of mass.
  8911. !#zh
  8912. 获取刚体世界坐标系下的质心
  8913. */
  8914. getWorldCenter(): Vec2;
  8915. /**
  8916. !#en
  8917. Get the world linear velocity of a world point attached to this body.
  8918. !#zh
  8919. 获取刚体上指定点的线性速度
  8920. @param worldPoint a point in world coordinates.
  8921. @param out optional, the receiving point
  8922. */
  8923. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  8924. /**
  8925. !#en
  8926. Get total mass of the body.
  8927. !#zh
  8928. 获取刚体的质量。
  8929. */
  8930. getMass(): number;
  8931. /**
  8932. !#en
  8933. Get the rotational inertia of the body about the local origin.
  8934. !#zh
  8935. 获取刚体本地坐标系下原点的旋转惯性
  8936. */
  8937. getInertia(): number;
  8938. /**
  8939. !#en
  8940. Get all the joints connect to the rigidbody.
  8941. !#zh
  8942. 获取链接到此刚体的所有关节
  8943. */
  8944. getJointList(): [Joint];
  8945. /**
  8946. !#en
  8947. Apply a force at a world point. If the force is not
  8948. applied at the center of mass, it will generate a torque and
  8949. affect the angular velocity.
  8950. !#zh
  8951. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  8952. @param force the world force vector.
  8953. @param point the world position.
  8954. @param wake also wake up the body.
  8955. */
  8956. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  8957. /**
  8958. !#en
  8959. Apply a force to the center of mass.
  8960. !#zh
  8961. 施加一个力到刚体上的质心上。
  8962. @param force the world force vector.
  8963. @param wake also wake up the body.
  8964. */
  8965. applyForceToCenter(force: Vec2, wake: boolean): void;
  8966. /**
  8967. !#en
  8968. Apply a torque. This affects the angular velocity.
  8969. !#zh
  8970. 施加一个扭矩力,将影响刚体的角速度
  8971. @param torque about the z-axis (out of the screen), usually in N-m.
  8972. @param wake also wake up the body
  8973. */
  8974. applyTorque(torque: number, wake: boolean): void;
  8975. /**
  8976. !#en
  8977. Apply a impulse at a world point, This immediately modifies the velocity.
  8978. If the impulse is not applied at the center of mass, it will generate a torque and
  8979. affect the angular velocity.
  8980. !#zh
  8981. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  8982. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  8983. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  8984. @param point the world position
  8985. @param wake alse wake up the body
  8986. */
  8987. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  8988. /**
  8989. !#en
  8990. Apply an angular impulse.
  8991. !#zh
  8992. 施加一个角速度冲量。
  8993. @param impulse the angular impulse in units of kg*m*m/s
  8994. @param wake also wake up the body
  8995. */
  8996. applyAngularImpulse(impulse: number, wake: boolean): void;
  8997. /**
  8998. !#en
  8999. Synchronize node's world position to box2d rigidbody's position.
  9000. If enableAnimated is true and rigidbody's type is Animated type,
  9001. will set linear velocity instead of directly set rigidbody's position.
  9002. !#zh
  9003. 同步节点的世界坐标到 box2d 刚体的坐标上。
  9004. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  9005. @param enableAnimated enableAnimated
  9006. */
  9007. syncPosition(enableAnimated: boolean): void;
  9008. /**
  9009. !#en
  9010. Synchronize node's world angle to box2d rigidbody's angle.
  9011. If enableAnimated is true and rigidbody's type is Animated type,
  9012. will set angular velocity instead of directly set rigidbody's angle.
  9013. !#zh
  9014. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  9015. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  9016. @param enableAnimated enableAnimated
  9017. */
  9018. syncRotation(enableAnimated: boolean): void;
  9019. }
  9020. /** Loader for resource loading process. It's a singleton object. */
  9021. export class loader extends Pipeline {
  9022. /** The asset loader in cc.loader's pipeline, it's by default the first pipe.
  9023. It's used to identify an asset's type, and determine how to download it. */
  9024. static assetLoader: any;
  9025. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  9026. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  9027. You can add your own download function with addDownloadHandlers */
  9028. static downloader: any;
  9029. /** The downloader in cc.loader's pipeline, it's by default the third pipe.
  9030. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  9031. You can add your own download function with addLoadHandlers */
  9032. static loader: any;
  9033. /**
  9034. Gets a new XMLHttpRequest instance.
  9035. */
  9036. static getXMLHttpRequest(): XMLHttpRequest;
  9037. /**
  9038. Add custom supported types handler or modify existing type handler for download process.
  9039. @param extMap Custom supported types with corresponded handler
  9040. @example
  9041. ```js
  9042. cc.loader.addDownloadHandlers({
  9043. // This will match all url with `.scene` extension or all url with `scene` type
  9044. 'scene' : function (url, callback) {}
  9045. });
  9046. ```
  9047. */
  9048. static addDownloadHandlers(extMap: any): void;
  9049. /**
  9050. Add custom supported types handler or modify existing type handler for load process.
  9051. @param extMap Custom supported types with corresponded handler
  9052. @example
  9053. ```js
  9054. cc.loader.addLoadHandlers({
  9055. // This will match all url with `.scene` extension or all url with `scene` type
  9056. 'scene' : function (url, callback) {}
  9057. });
  9058. ```
  9059. */
  9060. static addLoadHandlers(extMap: any): void;
  9061. /**
  9062. Load resources with a progression callback and a complete callback.
  9063. The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}}
  9064. The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}}
  9065. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  9066. @param resources Url list in an array
  9067. @param progressCallback Callback invoked when progression change
  9068. @param completeCallback Callback invoked when all resources loaded
  9069. @example
  9070. ```js
  9071. cc.loader.load('a.png', function (err, tex) {
  9072. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  9073. });
  9074. cc.loader.load('http://example.com/a.png', function (err, tex) {
  9075. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  9076. });
  9077. cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  9078. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  9079. });
  9080. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  9081. if (errors) {
  9082. for (var i = 0; i < errors.length; i++) {
  9083. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  9084. }
  9085. }
  9086. var aTex = results.getContent('a.png');
  9087. var bJsonObj = results.getContent('b.json');
  9088. });
  9089. ```
  9090. */
  9091. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  9092. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  9093. /**
  9094. Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  9095. <br>
  9096. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  9097. @param url Url of the target resource.
  9098. The url is relative to the "resources" folder, extensions must be omitted.
  9099. @param type Only asset of type will be loaded if this argument is supplied.
  9100. @param progressCallback Callback invoked when progression change.
  9101. @param completeCallback Callback invoked when the resource loaded.
  9102. @example
  9103. ```js
  9104. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  9105. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  9106. if (err) {
  9107. cc.error(err.message || err);
  9108. return;
  9109. }
  9110. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  9111. });
  9112. // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder
  9113. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  9114. if (err) {
  9115. cc.error(err.message || err);
  9116. return;
  9117. }
  9118. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  9119. });
  9120. ```
  9121. */
  9122. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  9123. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  9124. static loadRes(url: string, type: typeof cc.Asset): void;
  9125. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  9126. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  9127. static loadRes(url: string): void;
  9128. /**
  9129. This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url.
  9130. @param urls Array of URLs of the target resource.
  9131. The url is relative to the "resources" folder, extensions must be omitted.
  9132. @param type Only asset of type will be loaded if this argument is supplied.
  9133. @param progressCallback Callback invoked when progression change.
  9134. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  9135. @example
  9136. ```js
  9137. // load the SpriteFrames from resources folder
  9138. var spriteFrames;
  9139. var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01'];
  9140. cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) {
  9141. if (err) {
  9142. cc.error(err);
  9143. return;
  9144. }
  9145. spriteFrames = assets;
  9146. // ...
  9147. });
  9148. ```
  9149. */
  9150. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  9151. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  9152. static loadResArray(url: string[], type: typeof cc.Asset): void;
  9153. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  9154. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  9155. static loadResArray(url: string[]): void;
  9156. /**
  9157. Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  9158. <br>
  9159. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  9160. @param url Url of the target folder.
  9161. The url is relative to the "resources" folder, extensions must be omitted.
  9162. @param type Only asset of type will be loaded if this argument is supplied.
  9163. @param progressCallback Callback invoked when progression change.
  9164. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  9165. @example
  9166. ```js
  9167. // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame
  9168. cc.loader.loadResDir('imgs/cocos', function (err, assets) {
  9169. if (err) {
  9170. cc.error(err);
  9171. return;
  9172. }
  9173. var texture = assets[0];
  9174. var spriteFrame = assets[1];
  9175. });
  9176. // load all textures in "resources/imgs/"
  9177. cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) {
  9178. var texture1 = textures[0];
  9179. var texture2 = textures[1];
  9180. });
  9181. // load all JSONs in "resources/data/"
  9182. cc.loader.loadResDir('data', function (err, objects, urls) {
  9183. var data = objects[0];
  9184. var url = urls[0];
  9185. });
  9186. ```
  9187. */
  9188. 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;
  9189. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  9190. static loadResDir(url: string, type: typeof cc.Asset): void;
  9191. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  9192. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  9193. static loadResDir(url: string): void;
  9194. /**
  9195. Get resource data by id. <br>
  9196. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  9197. the url will be the unique identity of the resource.
  9198. After loaded, you can acquire them by passing the url to this API.
  9199. @param url url
  9200. @param type Only asset of type will be returned if this argument is supplied.
  9201. */
  9202. static getRes(url: string, type?: Function): any;
  9203. /**
  9204. !#en Get all resource dependencies of the requested asset in an array, including itself.
  9205. The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.<br>
  9206. The returned array stores the dependencies with their uuids, after retrieve dependencies,
  9207. you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.<br>
  9208. For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}}
  9209. Here is some examples:
  9210. !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。<br>
  9211. 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。<br>
  9212. 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码:
  9213. @param owner The owner asset or the resource url or the asset's uuid
  9214. @example
  9215. ```js
  9216. // Release all dependencies of a loaded prefab
  9217. var deps = cc.loader.getDependsRecursively(prefab);
  9218. cc.loader.release(deps);
  9219. // Retrieve all dependent textures
  9220. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  9221. var textures = [];
  9222. for (var i = 0; i < deps.length; ++i) {
  9223. var item = cc.loader.getRes(deps[i]);
  9224. if (item instanceof cc.Texture2D) {
  9225. textures.push(item);
  9226. }
  9227. }
  9228. ```
  9229. */
  9230. static getDependsRecursively(owner: Asset|RawAsset|string): any[];
  9231. /**
  9232. !#en
  9233. Release the content of an asset or an array of assets by uuid.
  9234. Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content.
  9235. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  9236. In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances.
  9237. 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.
  9238. If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  9239. !#zh
  9240. 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。
  9241. 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。
  9242. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  9243. 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。
  9244. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  9245. 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  9246. @param asset asset
  9247. @example
  9248. ```js
  9249. // Release a texture which is no longer need
  9250. cc.loader.release(texture);
  9251. // Release all dependencies of a loaded prefab
  9252. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  9253. cc.loader.release(deps);
  9254. // 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.
  9255. // If you have some other nodes share a texture in this prefab, you can skip it in two ways:
  9256. // 1. Forbid auto release a texture before release
  9257. cc.loader.setAutoRelease(texture2d, false);
  9258. // 2. Remove it from the dependencies array
  9259. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  9260. var index = deps.indexOf(texture2d._uuid);
  9261. if (index !== -1)
  9262. deps.splice(index, 1);
  9263. cc.loader.release(deps);
  9264. ```
  9265. */
  9266. static release(asset: Asset|RawAsset|string|any[]): void;
  9267. /**
  9268. !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  9269. !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  9270. @param asset asset
  9271. */
  9272. static releaseAsset(asset: Asset): void;
  9273. /**
  9274. !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  9275. !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  9276. @param url url
  9277. @param type Only asset of type will be released if this argument is supplied.
  9278. */
  9279. static releaseRes(url: string, type?: Function): void;
  9280. /**
  9281. !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  9282. !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  9283. @param url url
  9284. @param type Only asset of type will be released if this argument is supplied.
  9285. */
  9286. static releaseResDir(url: string, type?: Function): void;
  9287. /**
  9288. !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  9289. !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  9290. */
  9291. static releaseAll(): void;
  9292. /**
  9293. !#en
  9294. Indicates whether to release the asset when loading a new scene.<br>
  9295. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  9296. according to whether the previous scene checked the "Auto Release Assets" option.
  9297. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  9298. will not be affected by that option, remain not released by default.<br>
  9299. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  9300. <br>
  9301. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  9302. !#zh
  9303. 设置当场景切换时是否自动释放资源。<br>
  9304. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  9305. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  9306. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  9307. <br>
  9308. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  9309. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  9310. @param autoRelease indicates whether should release automatically
  9311. @example
  9312. ```js
  9313. // auto release the texture event if "Auto Release Assets" disabled in current scene
  9314. cc.loader.setAutoRelease(texture2d, true);
  9315. // don't release the texture even if "Auto Release Assets" enabled in current scene
  9316. cc.loader.setAutoRelease(texture2d, false);
  9317. // first parameter can be url
  9318. cc.loader.setAutoRelease(audioUrl, false);
  9319. ```
  9320. */
  9321. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  9322. /**
  9323. !#en
  9324. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  9325. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  9326. according to whether the previous scene checked the "Auto Release Assets" option.
  9327. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  9328. will not be affected by that option, remain not released by default.<br>
  9329. 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>
  9330. <br>
  9331. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  9332. !#zh
  9333. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  9334. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  9335. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  9336. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  9337. <br>
  9338. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  9339. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  9340. @param autoRelease indicates whether should release automatically
  9341. @example
  9342. ```js
  9343. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  9344. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  9345. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  9346. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  9347. // don't release the Prefab and all the referenced assets
  9348. cc.loader.setAutoReleaseRecursively(prefab, false);
  9349. ```
  9350. */
  9351. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  9352. /**
  9353. !#en
  9354. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  9355. <br>
  9356. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  9357. !#zh
  9358. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  9359. <br>
  9360. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  9361. @param assetOrUrl asset object or the raw asset's url
  9362. */
  9363. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  9364. }
  9365. /** !#en
  9366. LoadingItems is the queue of items which can flow them into the loading pipeline.</br>
  9367. Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.</br>
  9368. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  9369. Each item always contains the following property:</br>
  9370. - id: The identification of the item, usually it's identical to url</br>
  9371. - url: The url </br>
  9372. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  9373. - error: The error happened in pipeline will be stored in this property.</br>
  9374. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  9375. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  9376. - 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>
  9377. </br>
  9378. Item can hold other custom properties.</br>
  9379. Each LoadingItems object will be destroyed for recycle after onComplete callback</br>
  9380. So please don't hold its reference for later usage, you can copy properties in it though.
  9381. !#zh
  9382. LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。</br>
  9383. 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
  9384. 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。</br>
  9385. 每个对象都会包含下列属性:</br>
  9386. - id:该对象的标识,通常与 url 相同。</br>
  9387. - url:路径 </br>
  9388. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  9389. - error:pipeline 中发生的错误将被保存在这个属性中。</br>
  9390. - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。</br>
  9391. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  9392. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  9393. </br>
  9394. 对象可容纳其他自定义属性。</br>
  9395. 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */
  9396. export class LoadingItems extends CallbacksInvoker {
  9397. /**
  9398. !#en This is a callback which will be invoked while an item flow out the pipeline.
  9399. You can pass the callback function in LoadingItems.create or set it later.
  9400. !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  9401. @param completedCount The number of the items that are already completed.
  9402. @param totalCount The total number of the items.
  9403. @param item The latest item which flow out the pipeline.
  9404. @example
  9405. ```js
  9406. loadingItems.onProgress = function (completedCount, totalCount, item) {
  9407. var progress = (100 * completedCount / totalCount).toFixed(2);
  9408. cc.log(progress + '%');
  9409. }
  9410. ```
  9411. */
  9412. onProgress(completedCount: number, totalCount: number, item: any): void;
  9413. /**
  9414. !#en This is a callback which will be invoked while all items is completed,
  9415. You can pass the callback function in LoadingItems.create or set it later.
  9416. !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  9417. @param errors All errored urls will be stored in this array, if no error happened, then it will be null
  9418. @param items All items.
  9419. @example
  9420. ```js
  9421. loadingItems.onComplete = function (errors, items) {
  9422. if (error)
  9423. cc.log('Completed with ' + errors.length + ' errors');
  9424. else
  9425. cc.log('Completed ' + items.totalCount + ' items');
  9426. }
  9427. ```
  9428. */
  9429. onComplete(errors: any[], items: LoadingItems): void;
  9430. /** !#en The map of all items.
  9431. !#zh 存储所有加载项的对象。 */
  9432. map: any;
  9433. /** !#en The map of completed items.
  9434. !#zh 存储已经完成的加载项。 */
  9435. completed: any;
  9436. /** !#en Total count of all items.
  9437. !#zh 所有加载项的总数。 */
  9438. totalCount: number;
  9439. /** !#en Total count of completed items.
  9440. !#zh 所有完成加载项的总数。 */
  9441. completedCount: number;
  9442. /** !#en Activated or not.
  9443. !#zh 是否启用。 */
  9444. active: boolean;
  9445. /**
  9446. !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible.
  9447. You can pass onProgress and onComplete callbacks to visualize the loading process.
  9448. !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。
  9449. 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。
  9450. @param pipeline The pipeline to process the queue.
  9451. @param urlList The items array.
  9452. @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}}
  9453. @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
  9454. @example
  9455. ```js
  9456. LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
  9457. var progress = (100 * completedCount / totalCount).toFixed(2);
  9458. cc.log(progress + '%');
  9459. }, function (errors, items) {
  9460. if (errors) {
  9461. for (var i = 0; i < errors.length; ++i) {
  9462. cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i]));
  9463. }
  9464. }
  9465. else {
  9466. var result_a = items.getContent('a.png');
  9467. // ...
  9468. }
  9469. })
  9470. ```
  9471. */
  9472. static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems;
  9473. /**
  9474. !#en Retrieve the LoadingItems queue object for an item.
  9475. !#zh 通过 item 对象获取它的 LoadingItems 队列。
  9476. @param item The item to query
  9477. */
  9478. static getQueue(item: any): LoadingItems;
  9479. /**
  9480. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  9481. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  9482. @param item The item which has completed
  9483. */
  9484. static itemComplete(item: any): void;
  9485. /**
  9486. !#en Add urls to the LoadingItems queue.
  9487. !#zh 向一个 LoadingItems 队列添加加载项。
  9488. @param urlList The url list to be appended, the url can be object or string
  9489. */
  9490. append(urlList: any[]): any[];
  9491. /**
  9492. !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening.
  9493. !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。
  9494. */
  9495. allComplete(): void;
  9496. /**
  9497. !#en Check whether all items are completed.
  9498. !#zh 检查是否所有加载项都已经完成。
  9499. */
  9500. isCompleted(): boolean;
  9501. /**
  9502. !#en Check whether an item is completed.
  9503. !#zh 通过 id 检查指定加载项是否已经加载完成。
  9504. @param id The item's id.
  9505. */
  9506. isItemCompleted(id: string): boolean;
  9507. /**
  9508. !#en Check whether an item exists.
  9509. !#zh 通过 id 检查加载项是否存在。
  9510. @param id The item's id.
  9511. */
  9512. exists(id: string): boolean;
  9513. /**
  9514. !#en Returns the content of an internal item.
  9515. !#zh 通过 id 获取指定对象的内容。
  9516. @param id The item's id.
  9517. */
  9518. getContent(id: string): any;
  9519. /**
  9520. !#en Returns the error of an internal item.
  9521. !#zh 通过 id 获取指定对象的错误信息。
  9522. @param id The item's id.
  9523. */
  9524. getError(id: string): any;
  9525. /**
  9526. !#en Add a listener for an item, the callback will be invoked when the item is completed.
  9527. !#zh 监听加载项(通过 key 指定)的完成事件。
  9528. @param key key
  9529. @param callback can be null
  9530. @param target can be null
  9531. */
  9532. addListener(key: string, callback: Function, target: any): boolean;
  9533. /**
  9534. !#en
  9535. Check if the specified key has any registered callback. </br>
  9536. If a callback is also specified, it will only return true if the callback is registered.
  9537. !#zh
  9538. 检查指定的加载项是否有完成事件监听器。</br>
  9539. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。
  9540. @param key key
  9541. @param callback callback
  9542. @param target target
  9543. */
  9544. hasListener(key: string, callback?: Function, target?: any): boolean;
  9545. /**
  9546. !#en
  9547. Removes a listener. </br>
  9548. It will only remove when key, callback, target all match correctly.
  9549. !#zh
  9550. 移除指定加载项已经注册的完成事件监听器。</br>
  9551. 只会删除 key, callback, target 均匹配的监听器。
  9552. @param key key
  9553. @param callback callback
  9554. @param target target
  9555. */
  9556. remove(key: string, callback: Function, target: any): boolean;
  9557. /**
  9558. !#en
  9559. Removes all callbacks registered in a certain event
  9560. type or all callbacks registered with a certain target.
  9561. !#zh 删除指定目标的所有完成事件监听器。
  9562. @param key The event key to be removed or the target to be removed
  9563. */
  9564. removeAllListeners(key: string|any): void;
  9565. /**
  9566. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  9567. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  9568. @param id The item url
  9569. */
  9570. itemComplete(id: string): void;
  9571. /**
  9572. !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable.
  9573. !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。
  9574. */
  9575. destroy(): void;
  9576. }
  9577. /** !#en
  9578. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  9579. 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>
  9580. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  9581. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  9582. Finally all items will flow out the pipeline and the process is finished.
  9583. !#zh
  9584. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  9585. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  9586. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  9587. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  9588. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  9589. export class Pipeline {
  9590. /**
  9591. !#en
  9592. Constructor, pass an array of pipes to construct a new Pipeline,
  9593. the pipes will be chained in the given order.</br>
  9594. A pipe is an object which must contain an `id` in string and a `handle` function,
  9595. the id must be unique in the pipeline.</br>
  9596. It can also include `async` property to identify whether it's an asynchronous process.
  9597. !#zh
  9598. 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。</br>
  9599. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。</br>
  9600. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  9601. @param pipes pipes
  9602. @example
  9603. ```js
  9604. var pipeline = new Pipeline([
  9605. {
  9606. id: 'Downloader',
  9607. handle: function (item, callback) {},
  9608. async: true
  9609. },
  9610. {id: 'Parser', handle: function (item) {}, async: false}
  9611. ]);
  9612. ```
  9613. */
  9614. constructor(pipes: any[]);
  9615. /**
  9616. !#en
  9617. Insert a new pipe at the given index of the pipeline. </br>
  9618. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  9619. !#zh
  9620. 在给定的索引位置插入一个新的 pipe。</br>
  9621. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  9622. @param pipe The pipe to be inserted
  9623. @param index The index to insert
  9624. */
  9625. insertPipe(pipe: any, index: number): void;
  9626. /**
  9627. !en
  9628. Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline.
  9629. !zh
  9630. 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  9631. @param refPipe An existing pipe in the pipeline.
  9632. @param newPipe The pipe to be inserted.
  9633. */
  9634. insertPipeAfter(refPipe: any, newPipe: any): void;
  9635. /**
  9636. !#en
  9637. Add a new pipe at the end of the pipeline. </br>
  9638. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  9639. !#zh
  9640. 添加一个新的 pipe 到 pipeline 尾部。 </br>
  9641. 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  9642. @param pipe The pipe to be appended
  9643. */
  9644. appendPipe(pipe: any): void;
  9645. /**
  9646. !#en
  9647. Let new items flow into the pipeline. </br>
  9648. Each item can be a simple url string or an object,
  9649. if it's an object, it must contain `id` property. </br>
  9650. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  9651. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  9652. The object can contain any supplementary property as you want. </br>
  9653. !#zh
  9654. 让新的 item 流入 pipeline 中。</br>
  9655. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  9656. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  9657. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  9658. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  9659. 该对象可以包含任何附加属性。
  9660. @param items items
  9661. @example
  9662. ```js
  9663. pipeline.flowIn([
  9664. 'res/Background.png',
  9665. {
  9666. id: 'res/scene.json',
  9667. type: 'scene',
  9668. name: 'scene',
  9669. skips: ['Downloader']
  9670. }
  9671. ]);
  9672. ```
  9673. */
  9674. flowIn(items: any[]): void;
  9675. /**
  9676. !#en
  9677. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  9678. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  9679. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  9680. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  9681. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  9682. !#zh
  9683. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  9684. 这个 API 的使用通常是为了加载依赖项。</br>
  9685. 例如:</br>
  9686. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  9687. @param urlList urlList
  9688. @param callback callback
  9689. */
  9690. flowInDeps(urlList: any[], callback: Function): any[];
  9691. /**
  9692. !#en
  9693. Copy the item states from one source item to all destination items. </br>
  9694. It's quite useful when a pipe generate new items from one source item,</br>
  9695. then you should flowIn these generated items into pipeline, </br>
  9696. but you probably want them to skip all pipes the source item already go through,</br>
  9697. you can achieve it with this API. </br>
  9698. </br>
  9699. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  9700. !#zh
  9701. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  9702. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  9703. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  9704. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  9705. 这个时候就可以使用这个 API。
  9706. @param srcItem The source item
  9707. @param dstItems A single destination item or an array of destination items
  9708. */
  9709. copyItemStates(srcItem: any, dstItems: any[]|any): void;
  9710. /**
  9711. !#en Returns whether the pipeline is flowing (contains item) currently.
  9712. !#zh 获取 pipeline 当前是否正在处理中。
  9713. */
  9714. isFlowing(): boolean;
  9715. /**
  9716. !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  9717. !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。
  9718. */
  9719. getItems(): LoadingItems;
  9720. /**
  9721. !#en Returns an item in pipeline.
  9722. !#zh 根据 id 获取一个 item
  9723. @param id The id of the item
  9724. */
  9725. getItem(id: any): any;
  9726. /**
  9727. !#en Removes an completed item in pipeline.
  9728. It will only remove the cache in the pipeline or loader, its dependencies won't be released.
  9729. cc.loader provided another method to completely cleanup the resource and its dependencies,
  9730. please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9731. !#zh 移除指定的已完成 item。
  9732. 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
  9733. cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9734. @param id The id of the item
  9735. */
  9736. removeItem(id: any): boolean;
  9737. /**
  9738. !#en Clear the current pipeline, this function will clean up the items.
  9739. !#zh 清空当前 pipeline,该函数将清理 items。
  9740. */
  9741. clear(): void;
  9742. }
  9743. /** !#en Key map for keyboard event
  9744. !#zh 键盘事件的按键值 */
  9745. export enum KEY {
  9746. none = 0,
  9747. back = 0,
  9748. menu = 0,
  9749. backspace = 0,
  9750. tab = 0,
  9751. enter = 0,
  9752. shift = 0,
  9753. ctrl = 0,
  9754. alt = 0,
  9755. pause = 0,
  9756. capslock = 0,
  9757. escape = 0,
  9758. space = 0,
  9759. pageup = 0,
  9760. pagedown = 0,
  9761. end = 0,
  9762. home = 0,
  9763. left = 0,
  9764. up = 0,
  9765. right = 0,
  9766. down = 0,
  9767. select = 0,
  9768. insert = 0,
  9769. Delete = 0,
  9770. a = 0,
  9771. b = 0,
  9772. c = 0,
  9773. d = 0,
  9774. e = 0,
  9775. f = 0,
  9776. g = 0,
  9777. h = 0,
  9778. i = 0,
  9779. j = 0,
  9780. k = 0,
  9781. l = 0,
  9782. m = 0,
  9783. n = 0,
  9784. o = 0,
  9785. p = 0,
  9786. q = 0,
  9787. r = 0,
  9788. s = 0,
  9789. t = 0,
  9790. u = 0,
  9791. v = 0,
  9792. w = 0,
  9793. x = 0,
  9794. y = 0,
  9795. z = 0,
  9796. num0 = 0,
  9797. num1 = 0,
  9798. num2 = 0,
  9799. num3 = 0,
  9800. num4 = 0,
  9801. num5 = 0,
  9802. num6 = 0,
  9803. num7 = 0,
  9804. num8 = 0,
  9805. num9 = 0,
  9806. '*' = 0,
  9807. '+' = 0,
  9808. '-' = 0,
  9809. numdel = 0,
  9810. '/' = 0,
  9811. f1 = 0,
  9812. f2 = 0,
  9813. f3 = 0,
  9814. f4 = 0,
  9815. f5 = 0,
  9816. f6 = 0,
  9817. f7 = 0,
  9818. f8 = 0,
  9819. f9 = 0,
  9820. f10 = 0,
  9821. f11 = 0,
  9822. f12 = 0,
  9823. numlock = 0,
  9824. scrolllock = 0,
  9825. ';' = 0,
  9826. semicolon = 0,
  9827. equal = 0,
  9828. '=' = 0,
  9829. ',' = 0,
  9830. comma = 0,
  9831. dash = 0,
  9832. '.' = 0,
  9833. period = 0,
  9834. forwardslash = 0,
  9835. grave = 0,
  9836. '[' = 0,
  9837. openbracket = 0,
  9838. backslash = 0,
  9839. ']' = 0,
  9840. closebracket = 0,
  9841. quote = 0,
  9842. dpadLeft = 0,
  9843. dpadRight = 0,
  9844. dpadUp = 0,
  9845. dpadDown = 0,
  9846. dpadCenter = 0,
  9847. }
  9848. /** Image formats */
  9849. export enum ImageFormat {
  9850. JPG = 0,
  9851. PNG = 0,
  9852. TIFF = 0,
  9853. WEBP = 0,
  9854. PVR = 0,
  9855. ETC = 0,
  9856. S3TC = 0,
  9857. ATITC = 0,
  9858. TGA = 0,
  9859. RAWDATA = 0,
  9860. UNKNOWN = 0,
  9861. getImageFormatByData = 0,
  9862. }
  9863. /** Predefined constants */
  9864. export enum macro {
  9865. INVALID_INDEX = 0,
  9866. NODE_TAG_INVALID = 0,
  9867. PI = 0,
  9868. PI2 = 0,
  9869. FLT_MAX = 0,
  9870. FLT_MIN = 0,
  9871. RAD = 0,
  9872. DEG = 0,
  9873. UINT_MAX = 0,
  9874. REPEAT_FOREVER = 0,
  9875. FLT_EPSILON = 0,
  9876. ONE = 0,
  9877. ZERO = 0,
  9878. SRC_ALPHA = 0,
  9879. SRC_ALPHA_SATURATE = 0,
  9880. SRC_COLOR = 0,
  9881. DST_ALPHA = 0,
  9882. DST_COLOR = 0,
  9883. ONE_MINUS_SRC_ALPHA = 0,
  9884. ONE_MINUS_SRC_COLOR = 0,
  9885. ONE_MINUS_DST_ALPHA = 0,
  9886. ONE_MINUS_DST_COLOR = 0,
  9887. ONE_MINUS_CONSTANT_ALPHA = 0,
  9888. ONE_MINUS_CONSTANT_COLOR = 0,
  9889. LINEAR = 0,
  9890. BLEND_DST = 0,
  9891. WEB_ORIENTATION_PORTRAIT = 0,
  9892. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  9893. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  9894. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  9895. ORIENTATION_PORTRAIT = 0,
  9896. ORIENTATION_LANDSCAPE = 0,
  9897. ORIENTATION_AUTO = 0,
  9898. VERTEX_ATTRIB_FLAG_NONE = 0,
  9899. VERTEX_ATTRIB_FLAG_POSITION = 0,
  9900. VERTEX_ATTRIB_FLAG_COLOR = 0,
  9901. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  9902. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  9903. GL_ALL = 0,
  9904. VERTEX_ATTRIB_POSITION = 0,
  9905. VERTEX_ATTRIB_COLOR = 0,
  9906. VERTEX_ATTRIB_TEX_COORDS = 0,
  9907. VERTEX_ATTRIB_MAX = 0,
  9908. UNIFORM_PMATRIX = 0,
  9909. UNIFORM_MVMATRIX = 0,
  9910. UNIFORM_MVPMATRIX = 0,
  9911. UNIFORM_TIME = 0,
  9912. UNIFORM_SINTIME = 0,
  9913. UNIFORM_COSTIME = 0,
  9914. UNIFORM_RANDOM01 = 0,
  9915. UNIFORM_SAMPLER = 0,
  9916. UNIFORM_MAX = 0,
  9917. SHADER_POSITION_TEXTURECOLOR = 0,
  9918. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  9919. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  9920. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  9921. SHADER_POSITION_COLOR = 0,
  9922. SHADER_SPRITE_POSITION_COLOR = 0,
  9923. SHADER_POSITION_TEXTURE = 0,
  9924. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  9925. SHADER_POSITION_TEXTUREA8COLOR = 0,
  9926. SHADER_POSITION_UCOLOR = 0,
  9927. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  9928. UNIFORM_PMATRIX_S = 0,
  9929. UNIFORM_MVMATRIX_S = 0,
  9930. UNIFORM_MVPMATRIX_S = 0,
  9931. UNIFORM_TIME_S = 0,
  9932. UNIFORM_SINTIME_S = 0,
  9933. UNIFORM_COSTIME_S = 0,
  9934. UNIFORM_RANDOM01_S = 0,
  9935. UNIFORM_SAMPLER_S = 0,
  9936. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  9937. ATTRIBUTE_NAME_COLOR = 0,
  9938. ATTRIBUTE_NAME_POSITION = 0,
  9939. ATTRIBUTE_NAME_TEX_COORD = 0,
  9940. ITEM_SIZE = 0,
  9941. CURRENT_ITEM = 0,
  9942. ZOOM_ACTION_TAG = 0,
  9943. NORMAL_TAG = 0,
  9944. SELECTED_TAG = 0,
  9945. DISABLE_TAG = 0,
  9946. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  9947. FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0,
  9948. DIRECTOR_STATS_POSITION = 0,
  9949. DIRECTOR_FPS_INTERVAL = 0,
  9950. COCOSNODE_RENDER_SUBPIXEL = 0,
  9951. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  9952. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  9953. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  9954. TEXTURE_NPOT_SUPPORT = 0,
  9955. USE_LA88_LABELS = 0,
  9956. SPRITE_DEBUG_DRAW = 0,
  9957. LABELBMFONT_DEBUG_DRAW = 0,
  9958. LABELATLAS_DEBUG_DRAW = 0,
  9959. ENABLE_STACKABLE_ACTIONS = 0,
  9960. ENABLE_GL_STATE_CACHE = 0,
  9961. TOUCH_TIMEOUT = 0,
  9962. BATCH_VERTEX_COUNT = 0,
  9963. ENABLE_GC_FOR_NATIVE_OBJECTS = 0,
  9964. ENABLE_TILEDMAP_CULLING = 0,
  9965. DOWNLOAD_MAX_CONCURRENT = 0,
  9966. ENABLE_TRANSPARENT_CANVAS = 0,
  9967. ENABLE_WEBGL_ANTIALIAS = 0,
  9968. ENABLE_CULLING = 0,
  9969. BLEND_SRC = 0,
  9970. }
  9971. /** The base class of most of all the objects in Fireball. */
  9972. export class Object {
  9973. /** !#en The name of the object.
  9974. !#zh 该对象的名称。 */
  9975. name: string;
  9976. /** !#en
  9977. Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)<br>
  9978. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  9979. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  9980. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  9981. but this is often caused by a particular logical requirements, which is not normally required.
  9982. !#zh
  9983. 表示该对象是否可用(被 destroy 后将不可用)。<br>
  9984. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */
  9985. isValid: boolean;
  9986. /**
  9987. !#en
  9988. Destroy this Object, and release all its own references to other objects.<br/>
  9989. Actual object destruction will delayed until before rendering.
  9990. From the next frame, this CCObject is not usable any more.
  9991. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  9992. !#zh
  9993. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  9994. 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,CCObject 将不再可用。
  9995. 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  9996. @example
  9997. ```js
  9998. obj.destroy();
  9999. ```
  10000. */
  10001. destroy(): boolean;
  10002. }
  10003. /** Bit mask that controls object states. */
  10004. export enum Flags {
  10005. DontSave = 0,
  10006. EditorOnly = 0,
  10007. }
  10008. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  10009. It's invalid on safari, QQbrowser and android browser */
  10010. export class screen {
  10011. /**
  10012. initialize
  10013. */
  10014. init(): void;
  10015. /**
  10016. return true if it's full now.
  10017. */
  10018. fullScreen(): boolean;
  10019. /**
  10020. change the screen to full mode.
  10021. @param element element
  10022. @param onFullScreenChange onFullScreenChange
  10023. */
  10024. requestFullScreen(element: Element, onFullScreenChange: Function): void;
  10025. /**
  10026. exit the full mode.
  10027. */
  10028. exitFullScreen(): boolean;
  10029. /**
  10030. Automatically request full screen with a touch/click event
  10031. @param element element
  10032. @param onFullScreenChange onFullScreenChange
  10033. */
  10034. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  10035. }
  10036. /** System variables */
  10037. export class sys {
  10038. /** English language code */
  10039. static LANGUAGE_ENGLISH: string;
  10040. /** Chinese language code */
  10041. static LANGUAGE_CHINESE: string;
  10042. /** French language code */
  10043. static LANGUAGE_FRENCH: string;
  10044. /** Italian language code */
  10045. static LANGUAGE_ITALIAN: string;
  10046. /** German language code */
  10047. static LANGUAGE_GERMAN: string;
  10048. /** Spanish language code */
  10049. static LANGUAGE_SPANISH: string;
  10050. /** Spanish language code */
  10051. static LANGUAGE_DUTCH: string;
  10052. /** Russian language code */
  10053. static LANGUAGE_RUSSIAN: string;
  10054. /** Korean language code */
  10055. static LANGUAGE_KOREAN: string;
  10056. /** Japanese language code */
  10057. static LANGUAGE_JAPANESE: string;
  10058. /** Hungarian language code */
  10059. static LANGUAGE_HUNGARIAN: string;
  10060. /** Portuguese language code */
  10061. static LANGUAGE_PORTUGUESE: string;
  10062. /** Arabic language code */
  10063. static LANGUAGE_ARABIC: string;
  10064. /** Norwegian language code */
  10065. static LANGUAGE_NORWEGIAN: string;
  10066. /** Polish language code */
  10067. static LANGUAGE_POLISH: string;
  10068. /** Turkish language code */
  10069. static LANGUAGE_TURKISH: string;
  10070. /** Ukrainian language code */
  10071. static LANGUAGE_UKRAINIAN: string;
  10072. /** Romanian language code */
  10073. static LANGUAGE_ROMANIAN: string;
  10074. /** Bulgarian language code */
  10075. static LANGUAGE_BULGARIAN: string;
  10076. /** Unknown language code */
  10077. static LANGUAGE_UNKNOWN: string;
  10078. static OS_IOS: string;
  10079. static OS_ANDROID: string;
  10080. static OS_WINDOWS: string;
  10081. static OS_MARMALADE: string;
  10082. static OS_LINUX: string;
  10083. static OS_BADA: string;
  10084. static OS_BLACKBERRY: string;
  10085. static OS_OSX: string;
  10086. static OS_WP8: string;
  10087. static OS_WINRT: string;
  10088. static OS_UNKNOWN: string;
  10089. static UNKNOWN: number;
  10090. static WIN32: number;
  10091. static LINUX: number;
  10092. static MACOS: number;
  10093. static ANDROID: number;
  10094. static IPHONE: number;
  10095. static IPAD: number;
  10096. static BLACKBERRY: number;
  10097. static NACL: number;
  10098. static EMSCRIPTEN: number;
  10099. static TIZEN: number;
  10100. static WINRT: number;
  10101. static WP8: number;
  10102. static MOBILE_BROWSER: number;
  10103. static DESKTOP_BROWSER: number;
  10104. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  10105. static EDITOR_PAGE: number;
  10106. /** Indicates whether executes in editor's main process (Electron's browser context) */
  10107. static EDITOR_CORE: number;
  10108. static WECHAT_GAME: number;
  10109. static QQ_PLAY: number;
  10110. /** BROWSER_TYPE_WECHAT */
  10111. static BROWSER_TYPE_WECHAT: string;
  10112. /** BROWSER_TYPE_WECHAT_GAME */
  10113. static BROWSER_TYPE_WECHAT_GAME: string;
  10114. /** BROWSER_TYPE_QQ_PLAY */
  10115. static BROWSER_TYPE_QQ_PLAY: string;
  10116. static BROWSER_TYPE_ANDROID: string;
  10117. static BROWSER_TYPE_IE: string;
  10118. static BROWSER_TYPE_QQ: string;
  10119. static BROWSER_TYPE_MOBILE_QQ: string;
  10120. static BROWSER_TYPE_UC: string;
  10121. static BROWSER_TYPE_360: string;
  10122. static BROWSER_TYPE_BAIDU_APP: string;
  10123. static BROWSER_TYPE_BAIDU: string;
  10124. static BROWSER_TYPE_MAXTHON: string;
  10125. static BROWSER_TYPE_OPERA: string;
  10126. static BROWSER_TYPE_OUPENG: string;
  10127. static BROWSER_TYPE_MIUI: string;
  10128. static BROWSER_TYPE_FIREFOX: string;
  10129. static BROWSER_TYPE_SAFARI: string;
  10130. static BROWSER_TYPE_CHROME: string;
  10131. static BROWSER_TYPE_LIEBAO: string;
  10132. static BROWSER_TYPE_QZONE: string;
  10133. static BROWSER_TYPE_SOUGOU: string;
  10134. static BROWSER_TYPE_UNKNOWN: string;
  10135. /** Is native ? This is set to be true in jsb auto. */
  10136. static isNative: boolean;
  10137. /** Is web browser ? */
  10138. static isBrowser: boolean;
  10139. /** Indicate whether system is mobile system */
  10140. static isMobile: boolean;
  10141. /** Indicate the running platform */
  10142. static platform: number;
  10143. /** Indicate the current language of the running system */
  10144. static language: string;
  10145. /** Indicate the running os name */
  10146. static os: string;
  10147. /** Indicate the running os version */
  10148. static osVersion: string;
  10149. /** Indicate the running os main version */
  10150. static osMainVersion: number;
  10151. /** Indicate the running browser type */
  10152. static browserType: string;
  10153. /** Indicate the running browser version */
  10154. static browserVersion: string;
  10155. /** Indicate the real pixel resolution of the whole game window */
  10156. static windowPixelResolution: Size;
  10157. /** cc.sys.localStorage is a local storage component. */
  10158. static localStorage: any;
  10159. /** The capabilities of the current platform */
  10160. static capabilities: any;
  10161. /**
  10162. Forces the garbage collection, only available in JSB
  10163. */
  10164. static garbageCollect(): void;
  10165. /**
  10166. Dumps rooted objects, only available in JSB
  10167. */
  10168. static dumpRoot(): void;
  10169. /**
  10170. Restart the JS VM, only available in JSB
  10171. */
  10172. static restartVM(): void;
  10173. /**
  10174. Clean a script in the JS VM, only available in JSB
  10175. @param jsfile jsfile
  10176. */
  10177. static cleanScript(jsfile: string): void;
  10178. /**
  10179. Check whether an object is valid,
  10180. In web engine, it will return true if the object exist
  10181. In native engine, it will return true if the JS object and the correspond native object are both valid
  10182. @param obj obj
  10183. */
  10184. static isObjectValid(obj: any): boolean;
  10185. /**
  10186. Dump system informations
  10187. */
  10188. static dump(): void;
  10189. /**
  10190. Open a url in browser
  10191. @param url url
  10192. */
  10193. static openURL(url: string): void;
  10194. /**
  10195. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  10196. */
  10197. static now(): number;
  10198. }
  10199. /** cc.view is the singleton object which represents the game window.<br/>
  10200. It's main task include: <br/>
  10201. - Apply the design resolution policy<br/>
  10202. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  10203. - Manage the game view port which can be different with the window<br/>
  10204. - Manage the content scale and translation<br/>
  10205. <br/>
  10206. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  10207. the standard way to use it is by calling:<br/>
  10208. - cc.view.methodName(); <br/> */
  10209. export class View {
  10210. /**
  10211. <p>
  10212. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  10213. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  10214. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  10215. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  10216. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  10217. 5. Custom value, e.g: "480" <br/>
  10218. </p>
  10219. @param densityDPI densityDPI
  10220. */
  10221. setTargetDensityDPI(densityDPI: string): void;
  10222. /**
  10223. Returns the current target-densitydpi value of cc.view.
  10224. */
  10225. getTargetDensityDPI(): string;
  10226. /**
  10227. Sets whether resize canvas automatically when browser's size changed.<br/>
  10228. Useful only on web.
  10229. @param enabled Whether enable automatic resize with browser's resize event
  10230. */
  10231. resizeWithBrowserSize(enabled: boolean): void;
  10232. /**
  10233. Sets the callback function for cc.view's resize action,<br/>
  10234. this callback will be invoked before applying resolution policy, <br/>
  10235. so you can do any additional modifications within the callback.<br/>
  10236. Useful only on web.
  10237. @param callback The callback function
  10238. */
  10239. setResizeCallback(callback: Function|void): void;
  10240. /**
  10241. Sets the orientation of the game, it can be landscape, portrait or auto.
  10242. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  10243. cc.view will automatically rotate the game canvas using CSS.
  10244. Note that this function doesn't have any effect in native,
  10245. in native, you need to set the application orientation in native project settings
  10246. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  10247. */
  10248. setOrientation(orientation: number): void;
  10249. /**
  10250. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  10251. It's enabled by default, we strongly suggest you not to disable it.<br/>
  10252. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  10253. Only useful on web
  10254. @param enabled Enable automatic modification to "viewport" meta
  10255. */
  10256. adjustViewPort(enabled: boolean): void;
  10257. /**
  10258. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  10259. it takes effect only when you called setDesignResolutionPolicy<br/>
  10260. Only useful on web
  10261. @param enabled Enable or disable retina display
  10262. */
  10263. enableRetina(enabled: boolean): void;
  10264. /**
  10265. Check whether retina display is enabled.<br/>
  10266. Only useful on web
  10267. */
  10268. isRetinaEnabled(): boolean;
  10269. /**
  10270. !#en Whether to Enable on anti-alias
  10271. !#zh 控制抗锯齿是否开启
  10272. @param enabled Enable or not anti-alias
  10273. */
  10274. enableAntiAlias(enabled: boolean): void;
  10275. /**
  10276. !#en Returns whether the current enable on anti-alias
  10277. !#zh 返回当前是否抗锯齿
  10278. */
  10279. isAntiAliasEnabled(): boolean;
  10280. /**
  10281. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  10282. You can pass true as parameter to enable it and disable it by passing false.<br/>
  10283. Only useful on web
  10284. @param enabled Enable or disable auto full screen on mobile devices
  10285. */
  10286. enableAutoFullScreen(enabled: boolean): void;
  10287. /**
  10288. Check whether auto full screen is enabled.<br/>
  10289. Only useful on web
  10290. */
  10291. isAutoFullScreenEnabled(): boolean;
  10292. /**
  10293. Get whether render system is ready(no matter opengl or canvas),<br/>
  10294. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  10295. */
  10296. isViewReady(): boolean;
  10297. /**
  10298. Sets the resolution translate on View.
  10299. @param offsetLeft offsetLeft
  10300. @param offsetTop offsetTop
  10301. */
  10302. setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void;
  10303. /**
  10304. Returns the resolution translate on View
  10305. */
  10306. getContentTranslateLeftTop(): Size;
  10307. /**
  10308. Returns the frame size of the view.<br/>
  10309. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  10310. On web, it returns the size of the canvas's outer DOM element.
  10311. */
  10312. getFrameSize(): Size;
  10313. /**
  10314. On native, it sets the frame size of view.<br/>
  10315. On web, it sets the size of the canvas's outer DOM element.
  10316. @param width width
  10317. @param height height
  10318. */
  10319. setFrameSize(width: number, height: number): void;
  10320. /**
  10321. Returns the visible area size of the view port.
  10322. */
  10323. getVisibleSize(): Size;
  10324. /**
  10325. Returns the visible area size of the view port.
  10326. */
  10327. getVisibleSizeInPixel(): Size;
  10328. /**
  10329. Returns the visible origin of the view port.
  10330. */
  10331. getVisibleOrigin(): Vec2;
  10332. /**
  10333. Returns the visible origin of the view port.
  10334. */
  10335. getVisibleOriginInPixel(): Vec2;
  10336. /**
  10337. Returns whether developer can set content's scale factor.
  10338. */
  10339. canSetContentScaleFactor(): boolean;
  10340. /**
  10341. Returns the current resolution policy
  10342. */
  10343. getResolutionPolicy(): ResolutionPolicy;
  10344. /**
  10345. Sets the current resolution policy
  10346. @param resolutionPolicy resolutionPolicy
  10347. */
  10348. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  10349. /**
  10350. Sets the resolution policy with designed view size in points.<br/>
  10351. The resolution policy include: <br/>
  10352. [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/>
  10353. [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/>
  10354. [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/>
  10355. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  10356. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  10357. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  10358. @param width Design resolution width.
  10359. @param height Design resolution height.
  10360. @param resolutionPolicy The resolution policy desired
  10361. */
  10362. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10363. /**
  10364. Returns the designed size for the view.
  10365. Default resolution size is the same as 'getFrameSize'.
  10366. */
  10367. getDesignResolutionSize(): Size;
  10368. /**
  10369. Sets the container to desired pixel resolution and fit the game content to it.
  10370. This function is very useful for adaptation in mobile browsers.
  10371. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  10372. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  10373. But this API can be helpful to set a desired pixel resolution which is in between.
  10374. This API will do the following:
  10375. 1. Set viewport's width to the desired width in pixel
  10376. 2. Set body width to the exact pixel resolution
  10377. 3. The resolution policy will be reset with designed view size in points.
  10378. @param width Design resolution width.
  10379. @param height Design resolution height.
  10380. @param resolutionPolicy The resolution policy desired
  10381. */
  10382. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10383. /**
  10384. Sets view port rectangle with points.
  10385. @param x x
  10386. @param y y
  10387. @param w width
  10388. @param h height
  10389. */
  10390. setViewPortInPoints(x: number, y: number, w: number, h: number): void;
  10391. /**
  10392. Sets Scissor rectangle with points.
  10393. @param x x
  10394. @param y y
  10395. @param w w
  10396. @param h h
  10397. */
  10398. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  10399. /**
  10400. Returns whether GL_SCISSOR_TEST is enable
  10401. */
  10402. isScissorEnabled(): boolean;
  10403. /**
  10404. Returns the current scissor rectangle
  10405. */
  10406. getScissorRect(): Rect;
  10407. /**
  10408. Sets the name of the view
  10409. @param viewName viewName
  10410. */
  10411. setViewName(viewName: string): void;
  10412. /**
  10413. Returns the name of the view
  10414. */
  10415. getViewName(): string;
  10416. /**
  10417. Returns the view port rectangle.
  10418. */
  10419. getViewPortRect(): Rect;
  10420. /**
  10421. Returns scale factor of the horizontal direction (X axis).
  10422. */
  10423. getScaleX(): number;
  10424. /**
  10425. Returns scale factor of the vertical direction (Y axis).
  10426. */
  10427. getScaleY(): number;
  10428. /**
  10429. Returns device pixel ratio for retina display.
  10430. */
  10431. getDevicePixelRatio(): number;
  10432. /**
  10433. Returns the real location in view for a translation based on a related position
  10434. @param tx The X axis translation
  10435. @param ty The Y axis translation
  10436. @param relatedPos The related position object including "left", "top", "width", "height" informations
  10437. */
  10438. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  10439. }
  10440. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  10441. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  10442. export class ContainerStrategy {
  10443. /**
  10444. Manipulation before appling the strategy
  10445. @param view The target view
  10446. */
  10447. preApply(view: View): void;
  10448. /**
  10449. Function to apply this strategy
  10450. @param view view
  10451. @param designedResolution designedResolution
  10452. */
  10453. apply(view: View, designedResolution: Size): void;
  10454. /**
  10455. Manipulation after applying the strategy
  10456. @param view The target view
  10457. */
  10458. postApply(view: View): void;
  10459. }
  10460. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  10461. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  10462. export class ContentStrategy {
  10463. /**
  10464. Manipulation before applying the strategy
  10465. @param view The target view
  10466. */
  10467. preApply(view: View): void;
  10468. /**
  10469. Function to apply this strategy
  10470. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10471. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10472. @param view view
  10473. @param designedResolution designedResolution
  10474. */
  10475. apply(view: View, designedResolution: Size): any;
  10476. /**
  10477. Manipulation after applying the strategy
  10478. @param view The target view
  10479. */
  10480. postApply(view: View): void;
  10481. }
  10482. /** undefined */
  10483. export class EqualToFrame extends ContainerStrategy {
  10484. }
  10485. /** undefined */
  10486. export class ProportionalToFrame extends ContainerStrategy {
  10487. }
  10488. /** undefined */
  10489. export class EqualToWindow extends EqualToFrame {
  10490. }
  10491. /** undefined */
  10492. export class ProportionalToWindow extends ProportionalToFrame {
  10493. }
  10494. /** undefined */
  10495. export class OriginalContainer extends ContainerStrategy {
  10496. }
  10497. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  10498. its main task is to maintain the compatibility with Cocos2d-x</p> */
  10499. export class ResolutionPolicy {
  10500. /**
  10501. @param containerStg The container strategy
  10502. @param contentStg The content strategy
  10503. */
  10504. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  10505. /**
  10506. Manipulation before applying the resolution policy
  10507. @param view The target view
  10508. */
  10509. preApply(view: View): void;
  10510. /**
  10511. Function to apply this resolution policy
  10512. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10513. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10514. @param view The target view
  10515. @param designedResolution The user defined design resolution
  10516. */
  10517. apply(view: View, designedResolution: Size): any;
  10518. /**
  10519. Manipulation after appyling the strategy
  10520. @param view The target view
  10521. */
  10522. postApply(view: View): void;
  10523. /**
  10524. Setup the container's scale strategy
  10525. @param containerStg containerStg
  10526. */
  10527. setContainerStrategy(containerStg: ContainerStrategy): void;
  10528. /**
  10529. Setup the content's scale strategy
  10530. @param contentStg contentStg
  10531. */
  10532. setContentStrategy(contentStg: ContentStrategy): void;
  10533. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  10534. Distortion can occur, and the application may appear stretched or compressed. */
  10535. static EXACT_FIT: number;
  10536. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  10537. while maintaining the original aspect ratio of the application. */
  10538. static NO_BORDER: number;
  10539. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  10540. aspect ratio of the application. Borders can appear on two sides of the application. */
  10541. static SHOW_ALL: number;
  10542. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  10543. canvas so that it fits the aspect ratio of the device<br/>
  10544. no distortion will occur however you must make sure your application works on different<br/>
  10545. aspect ratios */
  10546. static FIXED_HEIGHT: number;
  10547. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  10548. canvas so that it fits the aspect ratio of the device<br/>
  10549. no distortion will occur however you must make sure your application works on different<br/>
  10550. aspect ratios */
  10551. static FIXED_WIDTH: number;
  10552. /** Unknow policy */
  10553. static UNKNOWN: number;
  10554. }
  10555. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  10556. it should represent the same rect as cc.view.getViewportRect() */
  10557. export class visibleRect {
  10558. /**
  10559. initialize
  10560. @param visibleRect visibleRect
  10561. */
  10562. init(visibleRect: Rect): void;
  10563. /** Top left coordinate of the screen related to the game scene. */
  10564. topLeft: Vec2;
  10565. /** Top right coordinate of the screen related to the game scene. */
  10566. topRight: Vec2;
  10567. /** Top center coordinate of the screen related to the game scene. */
  10568. top: Vec2;
  10569. /** Bottom left coordinate of the screen related to the game scene. */
  10570. bottomLeft: Vec2;
  10571. /** Bottom right coordinate of the screen related to the game scene. */
  10572. bottomRight: Vec2;
  10573. /** Bottom center coordinate of the screen related to the game scene. */
  10574. bottom: Vec2;
  10575. /** Center coordinate of the screen related to the game scene. */
  10576. center: Vec2;
  10577. /** Left center coordinate of the screen related to the game scene. */
  10578. left: Vec2;
  10579. /** Right center coordinate of the screen related to the game scene. */
  10580. right: Vec2;
  10581. /** Width of the screen. */
  10582. width: number;
  10583. /** Height of the screen. */
  10584. height: number;
  10585. }
  10586. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  10587. Subclasses should implement their own methods about how to invoke the callbacks. */
  10588. export class _CallbacksHandler {
  10589. /**
  10590. @param key key
  10591. @param callback callback
  10592. @param target can be null
  10593. */
  10594. add(key: string, callback: Function, target?: any): void;
  10595. /**
  10596. Check if the specified key has any registered callback. If a callback is also specified,
  10597. it will only return true if the callback is registered.
  10598. @param key key
  10599. @param callback callback
  10600. @param target target
  10601. */
  10602. has(key: string, callback?: Function, target?: any): boolean;
  10603. /**
  10604. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  10605. @param keyOrTarget The event key to be removed or the target to be removed
  10606. */
  10607. removeAll(keyOrTarget: string|any): void;
  10608. /**
  10609. @param key key
  10610. @param callback callback
  10611. @param target target
  10612. */
  10613. remove(key: string, callback: Function, target?: any): void;
  10614. }
  10615. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  10616. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  10617. export class CallbacksInvoker extends _CallbacksHandler {
  10618. /**
  10619. @param key key
  10620. @param p1 p1
  10621. @param p2 p2
  10622. @param p3 p3
  10623. @param p4 p4
  10624. @param p5 p5
  10625. */
  10626. invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void;
  10627. }
  10628. /** !#en Contains information collected during deserialization
  10629. !#zh 包含反序列化时的一些信息 */
  10630. export class Details {
  10631. /** list of the depends assets' uuid */
  10632. uuidList: string[];
  10633. /** the obj list whose field needs to load asset by uuid */
  10634. uuidObjList: any[];
  10635. /** the corresponding field name which referenced to the asset */
  10636. uuidPropList: string[];
  10637. /** the corresponding field name which referenced to the raw object */
  10638. rawProp: string;
  10639. reset(): void;
  10640. /**
  10641. @param obj obj
  10642. @param propName propName
  10643. */
  10644. getUuidOf(obj: any, propName: string): string;
  10645. /**
  10646. @param obj obj
  10647. @param propName propName
  10648. @param uuid uuid
  10649. */
  10650. push(obj: any, propName: string, uuid: string): void;
  10651. }
  10652. /** undefined */
  10653. export class url {
  10654. /**
  10655. Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  10656. @param url url
  10657. @example
  10658. ```js
  10659. ---
  10660. var url = cc.url.raw("textures/myTexture.png");
  10661. console.log(url); // "resources/raw/textures/myTexture.png"
  10662. ```
  10663. */
  10664. static raw(url: string): string;
  10665. /**
  10666. Returns the url of builtin raw assets. This method can only used in editor.
  10667. @param url url
  10668. @example
  10669. ```js
  10670. ---
  10671. var url = cc.url.builtinRaw("textures/myTexture.png");
  10672. console.log(url); // "resources/default-raw/textures/myTexture.png"
  10673. ```
  10674. */
  10675. static builtinRaw(url: string): string;
  10676. }
  10677. /** !#en
  10678. A cc.SpriteFrame has:<br/>
  10679. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  10680. - rectangle: A rectangle of the texture
  10681. !#zh
  10682. 一个 SpriteFrame 包含:<br/>
  10683. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  10684. - 矩形:在纹理中的矩形区域。 */
  10685. export class SpriteFrame extends Asset implements EventTarget {
  10686. /**
  10687. !#en
  10688. Constructor of SpriteFrame class.
  10689. !#zh
  10690. SpriteFrame 类的构造函数。
  10691. @param filename filename
  10692. @param rect rect
  10693. @param rotated Whether the frame is rotated in the texture
  10694. @param offset The offset of the frame in the texture
  10695. @param originalSize The size of the frame in the texture
  10696. */
  10697. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  10698. /** !#en Top border of the sprite
  10699. !#zh sprite 的顶部边框 */
  10700. insetTop: number;
  10701. /** !#en Bottom border of the sprite
  10702. !#zh sprite 的底部边框 */
  10703. insetBottom: number;
  10704. /** !#en Left border of the sprite
  10705. !#zh sprite 的左边边框 */
  10706. insetLeft: number;
  10707. /** !#en Right border of the sprite
  10708. !#zh sprite 的左边边框 */
  10709. insetRight: number;
  10710. /**
  10711. !#en Returns whether the texture have been loaded
  10712. !#zh 返回是否已加载纹理
  10713. */
  10714. textureLoaded(): boolean;
  10715. /**
  10716. Add a event listener for texture loaded event.
  10717. @param callback callback
  10718. @param target target
  10719. */
  10720. addLoadedEventListener(callback: Function, target: any): void;
  10721. /**
  10722. !#en Returns whether the sprite frame is rotated in the texture.
  10723. !#zh 获取 SpriteFrame 是否旋转
  10724. */
  10725. isRotated(): boolean;
  10726. /**
  10727. !#en Set whether the sprite frame is rotated in the texture.
  10728. !#zh 设置 SpriteFrame 是否旋转
  10729. @param bRotated bRotated
  10730. */
  10731. setRotated(bRotated: boolean): void;
  10732. /**
  10733. !#en Returns the rect of the sprite frame in the texture.
  10734. !#zh 获取 SpriteFrame 的纹理矩形区域
  10735. */
  10736. getRect(): Rect;
  10737. /**
  10738. !#en Sets the rect of the sprite frame in the texture.
  10739. !#zh 设置 SpriteFrame 的纹理矩形区域
  10740. @param rect rect
  10741. */
  10742. setRect(rect: Rect): void;
  10743. /**
  10744. !#en Returns the original size of the trimmed image.
  10745. !#zh 获取修剪前的原始大小
  10746. */
  10747. getOriginalSize(): Size;
  10748. /**
  10749. !#en Sets the original size of the trimmed image.
  10750. !#zh 设置修剪前的原始大小
  10751. @param size size
  10752. */
  10753. setOriginalSize(size: Size): void;
  10754. /**
  10755. !#en Returns the texture of the frame.
  10756. !#zh 获取使用的纹理实例
  10757. */
  10758. getTexture(): Texture2D;
  10759. /**
  10760. !#en Returns the offset of the frame in the texture.
  10761. !#zh 获取偏移量
  10762. */
  10763. getOffset(): Vec2;
  10764. /**
  10765. !#en Sets the offset of the frame in the texture.
  10766. !#zh 设置偏移量
  10767. @param offsets offsets
  10768. */
  10769. setOffset(offsets: Vec2): void;
  10770. /**
  10771. !#en Clone the sprite frame.
  10772. !#zh 克隆 SpriteFrame
  10773. */
  10774. clone(): SpriteFrame;
  10775. /**
  10776. !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  10777. !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame
  10778. @param textureOrTextureFile textureOrTextureFile
  10779. @param rect rect
  10780. @param rotated rotated
  10781. @param offset offset
  10782. @param originalSize originalSize
  10783. */
  10784. setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  10785. /**
  10786. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  10787. associated by user's custom Components in the scene, will not preload automatically.
  10788. These textures will be load when Sprite component is going to render the SpriteFrames.
  10789. You can call this method if you want to load the texture early.
  10790. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  10791. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  10792. @example
  10793. ```js
  10794. if (spriteFrame.textureLoaded()) {
  10795. this._onSpriteFrameLoaded();
  10796. }
  10797. else {
  10798. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  10799. spriteFrame.ensureLoadTexture();
  10800. }
  10801. ```
  10802. */
  10803. ensureLoadTexture(): void;
  10804. /**
  10805. !#en
  10806. 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.
  10807. !#zh
  10808. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  10809. @example
  10810. ```js
  10811. spriteFrame.clearTexture();
  10812. // when you need the SpriteFrame again...
  10813. spriteFrame.once('load', onSpriteFrameLoaded);
  10814. spriteFrame.ensureLoadTexture();
  10815. ```
  10816. */
  10817. clearTexture(): void;
  10818. /**
  10819. !#en
  10820. Register an callback of a specific event type on the EventTarget.
  10821. !#zh
  10822. 注册事件目标的特定事件类型回调。
  10823. @param type A string representing the event type to listen for.
  10824. @param callback The callback that will be invoked when the event is dispatched.
  10825. The callback is ignored if it is a duplicate (the callbacks are unique).
  10826. @param target The target (this object) to invoke the callback, can be null
  10827. @param useCapture When set to true, the capture argument prevents callback
  10828. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  10829. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  10830. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  10831. @example
  10832. ```js
  10833. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10834. cc.log("this is callback");
  10835. }, node);
  10836. ```
  10837. */
  10838. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  10839. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  10840. /**
  10841. !#en
  10842. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10843. if only type is passed as parameter, all listeners registered with that type will be removed.
  10844. !#zh
  10845. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10846. @param type A string representing the event type being removed.
  10847. @param callback The callback to remove.
  10848. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10849. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  10850. If not specified, useCapture defaults to false. If a callback was registered twice,
  10851. one with capture and one without, each must be removed separately. Removal of a capturing callback
  10852. does not affect a non-capturing version of the same listener, and vice versa.
  10853. @example
  10854. ```js
  10855. // register touchEnd eventListener
  10856. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10857. cc.log("this is callback");
  10858. }, node);
  10859. // remove touch end event listener
  10860. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  10861. // remove all touch end event listeners
  10862. node.off(cc.Node.EventType.TOUCH_END);
  10863. ```
  10864. */
  10865. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  10866. /**
  10867. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10868. This is not for removing all listeners in the current event target,
  10869. and this is not for removing all listeners the target parameter have registered.
  10870. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10871. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10872. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10873. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10874. @param target The target to be searched for all related listeners
  10875. */
  10876. targetOff(target: any): void;
  10877. /**
  10878. !#en
  10879. Register an callback of a specific event type on the EventTarget,
  10880. the callback will remove itself after the first time it is triggered.
  10881. !#zh
  10882. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  10883. @param type A string representing the event type to listen for.
  10884. @param callback The callback that will be invoked when the event is dispatched.
  10885. The callback is ignored if it is a duplicate (the callbacks are unique).
  10886. @param target The target (this object) to invoke the callback, can be null
  10887. @param useCapture When set to true, the capture argument prevents callback
  10888. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  10889. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  10890. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  10891. @example
  10892. ```js
  10893. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  10894. cc.log("this is callback");
  10895. }, node);
  10896. ```
  10897. */
  10898. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  10899. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  10900. /**
  10901. !#en
  10902. Dispatches an event into the event flow.
  10903. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  10904. !#zh 分发事件到事件流中。
  10905. @param event The Event object that is dispatched into the event flow
  10906. */
  10907. dispatchEvent(event: Event): void;
  10908. /**
  10909. !#en
  10910. Send an event to this object directly, this method will not propagate the event to any other objects.
  10911. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  10912. !#zh
  10913. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  10914. @param message the message to send
  10915. @param detail whatever argument the message needs
  10916. */
  10917. emit(message: string, detail?: any): void;
  10918. }
  10919. /** <p>
  10920. This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
  10921. The created cc.Texture2D object will always have power-of-two dimensions. <br/>
  10922. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  10923. i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
  10924. Be aware that the content of the generated textures will be upside-down! </p> */
  10925. export class Texture2D extends RawAsset implements EventTarget {
  10926. /** !#en
  10927. The url of the texture, this coule be empty if the texture wasn't created via a file.
  10928. !#zh
  10929. 贴图文件的 url,当贴图不是由文件创建时值可能为空 */
  10930. url: string;
  10931. /** !#en
  10932. Whether the texture is loaded or not
  10933. !#zh
  10934. 贴图是否已经成功加载 */
  10935. loaded: boolean;
  10936. /** !#en
  10937. Texture width in pixel
  10938. !#zh
  10939. 贴图像素宽度 */
  10940. width: number;
  10941. /** !#en
  10942. Texture height in pixel
  10943. !#zh
  10944. 贴图像素高度 */
  10945. height: number;
  10946. /**
  10947. Update texture options, not available in Canvas render mode.
  10948. image, format, premultiplyAlpha can not be updated in native.
  10949. @param options options
  10950. */
  10951. update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  10952. /**
  10953. Get width in pixels.
  10954. */
  10955. getPixelWidth(): number;
  10956. /**
  10957. Get height of in pixels.
  10958. */
  10959. getPixelHeight(): number;
  10960. /**
  10961. Get content size.
  10962. */
  10963. getContentSize(): Size;
  10964. /**
  10965. Get content size in pixels.
  10966. */
  10967. getContentSizeInPixels(): Size;
  10968. /**
  10969. Init with HTML element.
  10970. @param element element
  10971. @example
  10972. ```js
  10973. var img = new Image();
  10974. img.src = dataURL;
  10975. texture.initWithElement(img);
  10976. texture.handleLoadedTexture();
  10977. ```
  10978. */
  10979. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  10980. /**
  10981. Intializes with a texture2d with data.
  10982. @param data data
  10983. @param pixelFormat pixelFormat
  10984. @param pixelsWidth pixelsWidth
  10985. @param pixelsHeight pixelsHeight
  10986. @param contentSize contentSize is deprecated and ignored
  10987. */
  10988. initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean;
  10989. /**
  10990. Initializes a texture from a UIImage object.
  10991. Extensions to make it easy to create a CCTexture2D object from an image file.
  10992. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  10993. @param uiImage uiImage
  10994. */
  10995. initWithImage(uiImage: HTMLImageElement): boolean;
  10996. /**
  10997. HTMLElement Object getter, available only on web.
  10998. 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.
  10999. */
  11000. getHtmlElementObj(): HTMLImageElement;
  11001. /**
  11002. Check whether texture is loaded.
  11003. */
  11004. isLoaded(): boolean;
  11005. /**
  11006. Handler of texture loaded event.
  11007. @param premultiplied premultiplied
  11008. */
  11009. handleLoadedTexture(premultiplied?: boolean): void;
  11010. /**
  11011. Description of cc.Texture2D.
  11012. */
  11013. description(): string;
  11014. /**
  11015. Release texture.
  11016. */
  11017. releaseTexture(): void;
  11018. /**
  11019. Pixel format of the texture.
  11020. */
  11021. getPixelFormat(): number;
  11022. /**
  11023. Whether or not the texture has their Alpha premultiplied,
  11024. support only in WebGl rendering mode.
  11025. */
  11026. hasPremultipliedAlpha(): boolean;
  11027. /**
  11028. Whether or not use mipmap, support only in WebGl rendering mode.
  11029. */
  11030. hasMipmaps(): boolean;
  11031. /**
  11032. Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  11033. 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}.
  11034. @param texParams texParams object or minFilter
  11035. @param magFilter magFilter
  11036. @param wrapS wrapS
  11037. @param wrapT wrapT
  11038. */
  11039. setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void;
  11040. /**
  11041. sets antialias texture parameters: <br/>
  11042. - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11043. - GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11044. supported only in native or WebGl rendering mode
  11045. */
  11046. setAntiAliasTexParameters(): void;
  11047. /**
  11048. Sets alias texture parameters: <br/>
  11049. GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11050. GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11051. supported only in native or WebGl rendering mode
  11052. */
  11053. setAliasTexParameters(): void;
  11054. /** Pixel format of the texture. */
  11055. pixelFormat: number;
  11056. /** Width in pixels. */
  11057. pixelWidth: number;
  11058. /** Height in pixels. */
  11059. pixelHeight: number;
  11060. /**
  11061. !#en
  11062. Register an callback of a specific event type on the EventTarget.
  11063. !#zh
  11064. 注册事件目标的特定事件类型回调。
  11065. @param type A string representing the event type to listen for.
  11066. @param callback The callback that will be invoked when the event is dispatched.
  11067. The callback is ignored if it is a duplicate (the callbacks are unique).
  11068. @param target The target (this object) to invoke the callback, can be null
  11069. @param useCapture When set to true, the capture argument prevents callback
  11070. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11071. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11072. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11073. @example
  11074. ```js
  11075. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11076. cc.log("this is callback");
  11077. }, node);
  11078. ```
  11079. */
  11080. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11081. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11082. /**
  11083. !#en
  11084. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11085. if only type is passed as parameter, all listeners registered with that type will be removed.
  11086. !#zh
  11087. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11088. @param type A string representing the event type being removed.
  11089. @param callback The callback to remove.
  11090. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11091. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11092. If not specified, useCapture defaults to false. If a callback was registered twice,
  11093. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11094. does not affect a non-capturing version of the same listener, and vice versa.
  11095. @example
  11096. ```js
  11097. // register touchEnd eventListener
  11098. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11099. cc.log("this is callback");
  11100. }, node);
  11101. // remove touch end event listener
  11102. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11103. // remove all touch end event listeners
  11104. node.off(cc.Node.EventType.TOUCH_END);
  11105. ```
  11106. */
  11107. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11108. /**
  11109. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11110. This is not for removing all listeners in the current event target,
  11111. and this is not for removing all listeners the target parameter have registered.
  11112. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11113. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11114. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11115. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11116. @param target The target to be searched for all related listeners
  11117. */
  11118. targetOff(target: any): void;
  11119. /**
  11120. !#en
  11121. Register an callback of a specific event type on the EventTarget,
  11122. the callback will remove itself after the first time it is triggered.
  11123. !#zh
  11124. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11125. @param type A string representing the event type to listen for.
  11126. @param callback The callback that will be invoked when the event is dispatched.
  11127. The callback is ignored if it is a duplicate (the callbacks are unique).
  11128. @param target The target (this object) to invoke the callback, can be null
  11129. @param useCapture When set to true, the capture argument prevents callback
  11130. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11131. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11132. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11133. @example
  11134. ```js
  11135. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11136. cc.log("this is callback");
  11137. }, node);
  11138. ```
  11139. */
  11140. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11141. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11142. /**
  11143. !#en
  11144. Dispatches an event into the event flow.
  11145. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11146. !#zh 分发事件到事件流中。
  11147. @param event The Event object that is dispatched into the event flow
  11148. */
  11149. dispatchEvent(event: Event): void;
  11150. /**
  11151. !#en
  11152. Send an event to this object directly, this method will not propagate the event to any other objects.
  11153. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11154. !#zh
  11155. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11156. @param message the message to send
  11157. @param detail whatever argument the message needs
  11158. */
  11159. emit(message: string, detail?: any): void;
  11160. }
  11161. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  11162. export class textureCache {
  11163. /**
  11164. Description
  11165. */
  11166. static description(): string;
  11167. /**
  11168. Returns an already created texture. Returns null if the texture doesn't exist.
  11169. @param textureKeyName textureKeyName
  11170. @example
  11171. ```js
  11172. ------------------
  11173. var key = cc.textureCache.textureForKey("hello.png");
  11174. ```
  11175. */
  11176. static textureForKey(textureKeyName: string): Texture2D;
  11177. /**
  11178. Returns an already created texture. Returns null if the texture doesn't exist.
  11179. @param textureKeyName textureKeyName
  11180. @example
  11181. ```js
  11182. ------------------
  11183. var key = cc.textureCache.getTextureForKey("hello.png");
  11184. ```
  11185. */
  11186. static getTextureForKey(textureKeyName: string): Texture2D;
  11187. /**
  11188. @param texture texture
  11189. @example
  11190. ```js
  11191. ---------------
  11192. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  11193. ```
  11194. */
  11195. static getTextureColors(texture: HTMLImageElement): any[];
  11196. /**
  11197. !#en get all textures
  11198. !#zh 获取所有贴图
  11199. */
  11200. static getAllTextures(): Texture2D[];
  11201. /**
  11202. <p>Purges the dictionary of loaded textures. <br />
  11203. Call this method if you receive the "Memory Warning" <br />
  11204. In the short term: it will free some resources preventing your app from being killed <br />
  11205. In the medium term: it will allocate more resources <br />
  11206. In the long term: it will be the same</p>
  11207. @example
  11208. ```js
  11209. --------
  11210. cc.textureCache.removeAllTextures();
  11211. ```
  11212. */
  11213. static removeAllTextures(): void;
  11214. /**
  11215. Deletes a texture from the cache given a texture.
  11216. @param texture texture
  11217. @example
  11218. ```js
  11219. -----
  11220. cc.textureCache.removeTexture(texture);
  11221. ```
  11222. */
  11223. static removeTexture(texture: HTMLImageElement): void;
  11224. /**
  11225. Deletes a texture from the cache given a its key name.
  11226. @param textureKeyName textureKeyName
  11227. @example
  11228. ```js
  11229. ------
  11230. cc.textureCache.removeTexture("hello.png");
  11231. ```
  11232. */
  11233. static removeTextureForKey(textureKeyName: string): void;
  11234. /**
  11235. <p>Returns a Texture2D object given an file image <br />
  11236. If the file image was not previously loaded, it will create a new Texture2D <br />
  11237. object and it will return it. It will use the filename as a key.<br />
  11238. Otherwise it will return a reference of a previously loaded image. <br />
  11239. Supported image extensions: .png, .jpg, .gif</p>
  11240. @param url url
  11241. @param cb cb
  11242. @param target target
  11243. @example
  11244. ```js
  11245. ----
  11246. cc.textureCache.addImage("hello.png");
  11247. ```
  11248. */
  11249. static addImage(url: string, cb: Function, target: any): Texture2D;
  11250. /**
  11251. Cache the image data.
  11252. @param path path
  11253. @param texture texture
  11254. */
  11255. static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void;
  11256. }
  11257. /** A base node for CCNode, it will:
  11258. - maintain scene hierarchy and active logic
  11259. - notifications if some properties changed
  11260. - define some interfaces shares between CCNode
  11261. - define machanisms for Enity Component Systems
  11262. - define prefab and serialize functions */
  11263. export class _BaseNode extends Object implements EventTarget {
  11264. /** !#en Name of node.
  11265. !#zh 该节点名称。 */
  11266. name: string;
  11267. /** !#en The uuid for editor, will be stripped before building project.
  11268. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  11269. uuid: string;
  11270. /** !#en All children nodes.
  11271. !#zh 节点的所有子节点。 */
  11272. children: Node[];
  11273. /** !#en All children nodes.
  11274. !#zh 节点的子节点数量。 */
  11275. childrenCount: number;
  11276. /** !#en
  11277. The local active state of this node.<br/>
  11278. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  11279. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  11280. !#zh
  11281. 当前节点的自身激活状态。<br/>
  11282. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  11283. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  11284. active: boolean;
  11285. /** !#en Indicates whether this node is active in the scene.
  11286. !#zh 表示此节点是否在场景中激活。 */
  11287. activeInHierarchy: boolean;
  11288. /** !#en Tag of node.
  11289. !#zh 节点标签。 */
  11290. tag: number;
  11291. /**
  11292. @param name name
  11293. */
  11294. constructor(name?: string);
  11295. /** !#en The parent of the node.
  11296. !#zh 该节点的父节点。 */
  11297. parent: Node;
  11298. /**
  11299. !#en
  11300. Properties configuration function </br>
  11301. All properties in attrs will be set to the node, </br>
  11302. when the setter of the node is available, </br>
  11303. the property will be set via setter function.</br>
  11304. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  11305. @param attrs Properties to be set to node
  11306. @example
  11307. ```js
  11308. var attrs = { key: 0, num: 100 };
  11309. node.attr(attrs);
  11310. ```
  11311. */
  11312. attr(attrs: any): void;
  11313. /**
  11314. !#en Returns a child from the container given its tag.
  11315. !#zh 通过标签获取节点的子节点。
  11316. @param aTag An identifier to find the child node.
  11317. @example
  11318. ```js
  11319. var child = node.getChildByTag(1001);
  11320. ```
  11321. */
  11322. getChildByTag(aTag: number): Node;
  11323. /**
  11324. !#en Returns a child from the container given its uuid.
  11325. !#zh 通过 uuid 获取节点的子节点。
  11326. @param uuid The uuid to find the child node.
  11327. @example
  11328. ```js
  11329. var child = node.getChildByUuid(uuid);
  11330. ```
  11331. */
  11332. getChildByUuid(uuid: string): Node;
  11333. /**
  11334. !#en Returns a child from the container given its name.
  11335. !#zh 通过名称获取节点的子节点。
  11336. @param name A name to find the child node.
  11337. @example
  11338. ```js
  11339. var child = node.getChildByName("Test Node");
  11340. ```
  11341. */
  11342. getChildByName(name: string): Node;
  11343. /**
  11344. !#en
  11345. Inserts a child to the node at a specified index.
  11346. !#zh
  11347. 插入子节点到指定位置
  11348. @param child the child node to be inserted
  11349. @param siblingIndex the sibling index to place the child in
  11350. @example
  11351. ```js
  11352. node.insertChild(child, 2);
  11353. ```
  11354. */
  11355. insertChild(child: Node, siblingIndex: number): void;
  11356. /**
  11357. !#en Get the sibling index.
  11358. !#zh 获取同级索引。
  11359. @example
  11360. ```js
  11361. var index = node.getSiblingIndex();
  11362. ```
  11363. */
  11364. getSiblingIndex(): number;
  11365. /**
  11366. !#en Set the sibling index of this node.
  11367. !#zh 设置节点同级索引。
  11368. @param index index
  11369. @example
  11370. ```js
  11371. node.setSiblingIndex(1);
  11372. ```
  11373. */
  11374. setSiblingIndex(index: number): void;
  11375. /**
  11376. !#en
  11377. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  11378. 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/>
  11379. If the node orphan, then nothing happens.
  11380. !#zh
  11381. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  11382. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  11383. 如果这个节点是一个孤节点,那么什么都不会发生。
  11384. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  11385. @example
  11386. ```js
  11387. node.removeFromParent();
  11388. node.removeFromParent(false);
  11389. ```
  11390. */
  11391. removeFromParent(cleanup?: boolean): void;
  11392. /**
  11393. !#en
  11394. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  11395. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11396. "remove" logic MUST only be on this method <br/>
  11397. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  11398. to override this method.
  11399. !#zh
  11400. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11401. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  11402. @param child The child node which will be removed.
  11403. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11404. @example
  11405. ```js
  11406. node.removeChild(newNode);
  11407. node.removeChild(newNode, false);
  11408. ```
  11409. */
  11410. removeChild(child: Node, cleanup?: boolean): void;
  11411. /**
  11412. !#en
  11413. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  11414. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11415. !#zh
  11416. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11417. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11418. @param tag An integer number that identifies a child node
  11419. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11420. @example
  11421. ```js
  11422. node.removeChildByTag(1001);
  11423. node.removeChildByTag(1001, false);
  11424. ```
  11425. */
  11426. removeChildByTag(tag: number, cleanup?: boolean): void;
  11427. /**
  11428. !#en
  11429. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  11430. If the cleanup parameter is not passed, it will force a cleanup.
  11431. !#zh
  11432. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11433. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11434. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  11435. @example
  11436. ```js
  11437. node.removeAllChildren();
  11438. node.removeAllChildren(false);
  11439. ```
  11440. */
  11441. removeAllChildren(cleanup?: boolean): void;
  11442. /**
  11443. !#en Is this node a child of the given node?
  11444. !#zh 是否是指定节点的子节点?
  11445. @param parent parent
  11446. @example
  11447. ```js
  11448. node.isChildOf(newNode);
  11449. ```
  11450. */
  11451. isChildOf(parent: Node): boolean;
  11452. /**
  11453. !#en
  11454. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  11455. You can also get component in the node by passing in the name of the script.
  11456. !#zh
  11457. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  11458. 传入参数也可以是脚本的名称。
  11459. @param typeOrClassName typeOrClassName
  11460. @example
  11461. ```js
  11462. // get sprite component.
  11463. var sprite = node.getComponent(cc.Sprite);
  11464. // get custom test calss.
  11465. var test = node.getComponent("Test");
  11466. ```
  11467. */
  11468. getComponent<T extends Component>(type: {prototype: T}): T;
  11469. getComponent(className: string): any;
  11470. /**
  11471. !#en Returns all components of supplied type in the node.
  11472. !#zh 返回节点上指定类型的所有组件。
  11473. @param typeOrClassName typeOrClassName
  11474. @example
  11475. ```js
  11476. var sprites = node.getComponents(cc.Sprite);
  11477. var tests = node.getComponents("Test");
  11478. ```
  11479. */
  11480. getComponents<T extends Component>(type: {prototype: T}): T[];
  11481. getComponents(className: string): any[];
  11482. /**
  11483. !#en Returns the component of supplied type in any of its children using depth first search.
  11484. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  11485. @param typeOrClassName typeOrClassName
  11486. @example
  11487. ```js
  11488. var sprite = node.getComponentInChildren(cc.Sprite);
  11489. var Test = node.getComponentInChildren("Test");
  11490. ```
  11491. */
  11492. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  11493. getComponentInChildren(className: string): any;
  11494. /**
  11495. !#en Returns all components of supplied type in self or any of its children.
  11496. !#zh 递归查找自身或所有子节点中指定类型的组件
  11497. @param typeOrClassName typeOrClassName
  11498. @example
  11499. ```js
  11500. var sprites = node.getComponentsInChildren(cc.Sprite);
  11501. var tests = node.getComponentsInChildren("Test");
  11502. ```
  11503. */
  11504. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  11505. getComponentsInChildren(className: string): any[];
  11506. /**
  11507. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  11508. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  11509. @param typeOrClassName The constructor or the class name of the component to add
  11510. @example
  11511. ```js
  11512. var sprite = node.addComponent(cc.Sprite);
  11513. var test = node.addComponent("Test");
  11514. ```
  11515. */
  11516. addComponent<T extends Component>(type: {new(): T}): T;
  11517. addComponent(className: string): any;
  11518. /**
  11519. !#en
  11520. Removes a component identified by the given name or removes the component object given.
  11521. You can also use component.destroy() if you already have the reference.
  11522. !#zh
  11523. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  11524. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  11525. @param component The need remove component.
  11526. @example
  11527. ```js
  11528. node.removeComponent(cc.Sprite);
  11529. var Test = require("Test");
  11530. node.removeComponent(Test);
  11531. ```
  11532. */
  11533. removeComponent(component: string|Function|Component): void;
  11534. /**
  11535. !#en
  11536. Destroy all children from the node, and release all their own references to other objects.<br/>
  11537. Actual destruct operation will delayed until before rendering.
  11538. !#zh
  11539. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  11540. 实际销毁操作会延迟到当前帧渲染前执行。
  11541. @example
  11542. ```js
  11543. node.destroyAllChildren();
  11544. ```
  11545. */
  11546. destroyAllChildren(): void;
  11547. /**
  11548. !#en
  11549. Register an callback of a specific event type on the EventTarget.
  11550. !#zh
  11551. 注册事件目标的特定事件类型回调。
  11552. @param type A string representing the event type to listen for.
  11553. @param callback The callback that will be invoked when the event is dispatched.
  11554. The callback is ignored if it is a duplicate (the callbacks are unique).
  11555. @param target The target (this object) to invoke the callback, can be null
  11556. @param useCapture When set to true, the capture argument prevents callback
  11557. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11558. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11559. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11560. @example
  11561. ```js
  11562. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11563. cc.log("this is callback");
  11564. }, node);
  11565. ```
  11566. */
  11567. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11568. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11569. /**
  11570. !#en
  11571. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11572. if only type is passed as parameter, all listeners registered with that type will be removed.
  11573. !#zh
  11574. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11575. @param type A string representing the event type being removed.
  11576. @param callback The callback to remove.
  11577. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11578. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11579. If not specified, useCapture defaults to false. If a callback was registered twice,
  11580. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11581. does not affect a non-capturing version of the same listener, and vice versa.
  11582. @example
  11583. ```js
  11584. // register touchEnd eventListener
  11585. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11586. cc.log("this is callback");
  11587. }, node);
  11588. // remove touch end event listener
  11589. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11590. // remove all touch end event listeners
  11591. node.off(cc.Node.EventType.TOUCH_END);
  11592. ```
  11593. */
  11594. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11595. /**
  11596. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11597. This is not for removing all listeners in the current event target,
  11598. and this is not for removing all listeners the target parameter have registered.
  11599. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11600. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11601. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11602. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11603. @param target The target to be searched for all related listeners
  11604. */
  11605. targetOff(target: any): void;
  11606. /**
  11607. !#en
  11608. Register an callback of a specific event type on the EventTarget,
  11609. the callback will remove itself after the first time it is triggered.
  11610. !#zh
  11611. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11612. @param type A string representing the event type to listen for.
  11613. @param callback The callback that will be invoked when the event is dispatched.
  11614. The callback is ignored if it is a duplicate (the callbacks are unique).
  11615. @param target The target (this object) to invoke the callback, can be null
  11616. @param useCapture When set to true, the capture argument prevents callback
  11617. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11618. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11619. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11620. @example
  11621. ```js
  11622. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11623. cc.log("this is callback");
  11624. }, node);
  11625. ```
  11626. */
  11627. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11628. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11629. /**
  11630. !#en
  11631. Dispatches an event into the event flow.
  11632. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11633. !#zh 分发事件到事件流中。
  11634. @param event The Event object that is dispatched into the event flow
  11635. */
  11636. dispatchEvent(event: Event): void;
  11637. /**
  11638. !#en
  11639. Send an event to this object directly, this method will not propagate the event to any other objects.
  11640. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11641. !#zh
  11642. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11643. @param message the message to send
  11644. @param detail whatever argument the message needs
  11645. */
  11646. emit(message: string, detail?: any): void;
  11647. }
  11648. /** !#en
  11649. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  11650. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  11651. !#zh
  11652. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  11653. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  11654. export class AffineTransform {
  11655. /**
  11656. !#en Create a cc.AffineTransform object with all contents in the matrix.
  11657. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  11658. @param a a
  11659. @param b b
  11660. @param c c
  11661. @param d d
  11662. @param tx tx
  11663. @param ty ty
  11664. */
  11665. affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  11666. /**
  11667. !#en Clone a cc.AffineTransform object from the specified transform.
  11668. !#zh 克隆指定的 cc.AffineTransform 对象。
  11669. @param t t
  11670. */
  11671. affineTransformClone(t: AffineTransform): AffineTransform;
  11672. /**
  11673. !#en Apply the affine transformation on a point.
  11674. !#zh 对一个点应用矩阵变换。
  11675. @param point or x.
  11676. @param transOrY transform matrix or y.
  11677. @param t transform matrix or y.
  11678. */
  11679. pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2;
  11680. /**
  11681. !#en Apply the affine transformation on a size.
  11682. !#zh 应用 Size 到仿射变换矩阵上。
  11683. @param size size
  11684. @param t t
  11685. */
  11686. sizeApplyAffineTransform(size: Size, t: AffineTransform): Size;
  11687. /**
  11688. !#en
  11689. Create a identity transformation matrix: <br/>
  11690. [ 1, 0, 0, <br/>
  11691. 0, 1, 0 ]
  11692. !#zh
  11693. 单位矩阵:<br/>
  11694. [ 1, 0, 0, <br/>
  11695. 0, 1, 0 ]
  11696. */
  11697. affineTransformMakeIdentity(): AffineTransform;
  11698. /**
  11699. !#en Apply the affine transformation on a rect.
  11700. !#zh 应用 Rect 到仿射变换矩阵上。
  11701. @param rect rect
  11702. @param anAffineTransform anAffineTransform
  11703. */
  11704. rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect;
  11705. /**
  11706. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  11707. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  11708. @param rect rect
  11709. @param anAffineTransform anAffineTransform
  11710. @param out_bl out_bl
  11711. @param out_tl out_tl
  11712. @param out_tr out_tr
  11713. @param out_br out_br
  11714. */
  11715. obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void;
  11716. /**
  11717. !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  11718. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  11719. @param t The base affine transform object.
  11720. @param tx The translation on x axis.
  11721. @param ty The translation on y axis.
  11722. */
  11723. affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform;
  11724. /**
  11725. !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  11726. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  11727. @param t The base affine transform object.
  11728. @param sx The scale on x axis.
  11729. @param sy The scale on y axis.
  11730. */
  11731. affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform;
  11732. /**
  11733. !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  11734. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  11735. @param aTransform The base affine transform object.
  11736. @param anAngle The angle to rotate.
  11737. */
  11738. affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform;
  11739. /**
  11740. !#en
  11741. Concatenate a transform matrix to another and return the result:<br/>
  11742. t' = t1 * t2
  11743. !#zh 拼接两个矩阵,并返回结果:<br/>
  11744. t' = t1 * t2
  11745. @param t1 The first transform object.
  11746. @param t2 The transform object to concatenate.
  11747. */
  11748. affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11749. /**
  11750. !#en
  11751. Concatenate a transform matrix to another<br/>
  11752. The results are reflected in the first matrix.<br/>
  11753. t' = t1 * t2
  11754. !#zh
  11755. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  11756. t' = t1 * t2
  11757. @param t1 The first transform object.
  11758. @param t2 The transform object to concatenate.
  11759. */
  11760. affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11761. /**
  11762. !#en Return true if an affine transform equals to another, false otherwise.
  11763. !#zh 判断两个矩阵是否相等。
  11764. @param t1 t1
  11765. @param t2 t2
  11766. */
  11767. affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean;
  11768. /**
  11769. !#en Get the invert transform of an AffineTransform object.
  11770. !#zh 求逆矩阵。
  11771. @param t t
  11772. */
  11773. affineTransformInvert(t: AffineTransform): AffineTransform;
  11774. /**
  11775. !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
  11776. !#zh 求逆矩阵并存入用户传入的矩阵对象参数。
  11777. @param t t
  11778. @param out out
  11779. */
  11780. affineTransformInvert(t: AffineTransform, out: AffineTransform): void;
  11781. }
  11782. /** !#en
  11783. Representation of RGBA colors.
  11784. Each color component is a floating point value with a range from 0 to 255.
  11785. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  11786. !#zh
  11787. cc.Color 用于表示颜色。
  11788. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  11789. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  11790. export class Color extends ValueType {
  11791. /**
  11792. @param r red component of the color, default value is 0.
  11793. @param g green component of the color, defualt value is 0.
  11794. @param b blue component of the color, default value is 0.
  11795. @param a alpha component of the color, default value is 255.
  11796. */
  11797. constructor(r?: number, g?: number, b?: number, a?: number);
  11798. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  11799. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  11800. static WHITE: Color;
  11801. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  11802. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  11803. static BLACK: Color;
  11804. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  11805. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  11806. static TRANSPARENT: Color;
  11807. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  11808. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  11809. static GRAY: Color;
  11810. /** !#en Solid red, RGBA is [255, 0, 0].
  11811. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  11812. static RED: Color;
  11813. /** !#en Solid green, RGBA is [0, 255, 0].
  11814. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  11815. static GREEN: Color;
  11816. /** !#en Solid blue, RGBA is [0, 0, 255].
  11817. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  11818. static BLUE: Color;
  11819. /** !#en Yellow, RGBA is [255, 235, 4].
  11820. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  11821. static YELLOW: Color;
  11822. /** !#en Orange, RGBA is [255, 127, 0].
  11823. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  11824. static ORANGE: Color;
  11825. /** !#en Cyan, RGBA is [0, 255, 255].
  11826. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  11827. static CYAN: Color;
  11828. /** !#en Magenta, RGBA is [255, 0, 255].
  11829. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  11830. static MAGENTA: Color;
  11831. /**
  11832. !#en Clone a new color from the current color.
  11833. !#zh 克隆当前颜色。
  11834. @example
  11835. ```js
  11836. var color = new cc.Color();
  11837. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  11838. ```
  11839. */
  11840. clone(): Color;
  11841. /**
  11842. !#en TODO
  11843. !#zh 判断两个颜色是否相等。
  11844. @param other other
  11845. @example
  11846. ```js
  11847. var color1 = cc.Color.WHITE;
  11848. var color2 = new cc.Color(255, 255, 255);
  11849. cc.log(color1.equals(color2)); // true;
  11850. color2 = cc.Color.RED;
  11851. cc.log(color2.equals(color1)); // false;
  11852. ```
  11853. */
  11854. equals(other: Color): boolean;
  11855. /**
  11856. !#en TODO
  11857. !#zh 线性插值
  11858. @param to to
  11859. @param ratio the interpolation coefficient.
  11860. @param out optional, the receiving vector.
  11861. @example
  11862. ```js
  11863. // Converts a white color to a black one trough time.
  11864. update: function (dt) {
  11865. var color = this.node.color;
  11866. if (color.equals(cc.Color.BLACK)) {
  11867. return;
  11868. }
  11869. this.ratio += dt * 0.1;
  11870. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  11871. }
  11872. ```
  11873. */
  11874. lerp(to: Color, ratio: number, out?: Color): Color;
  11875. /**
  11876. !#en TODO
  11877. !#zh 转换为方便阅读的字符串。
  11878. @example
  11879. ```js
  11880. var color = cc.Color.WHITE;
  11881. color.toString(); // "rgba(255, 255, 255, 255)"
  11882. ```
  11883. */
  11884. toString(): string;
  11885. /**
  11886. !#en Gets red channel value
  11887. !#zh 获取当前颜色的红色值。
  11888. */
  11889. getR(): number;
  11890. /**
  11891. !#en Sets red value and return the current color object
  11892. !#zh 设置当前的红色值,并返回当前对象。
  11893. @param red the new Red component.
  11894. @example
  11895. ```js
  11896. var color = new cc.Color();
  11897. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  11898. ```
  11899. */
  11900. setR(red: number): Color;
  11901. /**
  11902. !#en Gets green channel value
  11903. !#zh 获取当前颜色的绿色值。
  11904. */
  11905. getG(): number;
  11906. /**
  11907. !#en Sets green value and return the current color object
  11908. !#zh 设置当前的绿色值,并返回当前对象。
  11909. @param green the new Green component.
  11910. @example
  11911. ```js
  11912. var color = new cc.Color();
  11913. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  11914. ```
  11915. */
  11916. setG(green: number): Color;
  11917. /**
  11918. !#en Gets blue channel value
  11919. !#zh 获取当前颜色的蓝色值。
  11920. */
  11921. getB(): number;
  11922. /**
  11923. !#en Sets blue value and return the current color object
  11924. !#zh 设置当前的蓝色值,并返回当前对象。
  11925. @param blue the new Blue component.
  11926. @example
  11927. ```js
  11928. var color = new cc.Color();
  11929. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  11930. ```
  11931. */
  11932. setB(blue: number): Color;
  11933. /**
  11934. !#en Gets alpha channel value
  11935. !#zh 获取当前颜色的透明度值。
  11936. */
  11937. getA(): number;
  11938. /**
  11939. !#en Sets alpha value and return the current color object
  11940. !#zh 设置当前的透明度,并返回当前对象。
  11941. @param alpha the new Alpha component.
  11942. @example
  11943. ```js
  11944. var color = new cc.Color();
  11945. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  11946. ```
  11947. */
  11948. setA(alpha: number): Color;
  11949. /**
  11950. !#en Convert color to css format.
  11951. !#zh 转换为 CSS 格式。
  11952. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  11953. @example
  11954. ```js
  11955. var color = cc.Color.BLACK;
  11956. color.toCSS(); // "#000";
  11957. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  11958. color.toCSS("rgb"); // "rgba(0,0,0)";
  11959. color.toCSS("#rgb"); // "#000";
  11960. color.toCSS("#rrggbb"); // "#000000";
  11961. ```
  11962. */
  11963. toCSS(opt: string): string;
  11964. /**
  11965. !#en Clamp this color to make all components between 0 to 255。
  11966. !#zh 限制颜色数值,在 0 到 255 之间。
  11967. @example
  11968. ```js
  11969. var color = new cc.Color(1000, 0, 0, 255);
  11970. color.clamp();
  11971. cc.log(color); // (255, 0, 0, 255)
  11972. ```
  11973. */
  11974. clamp(): void;
  11975. /**
  11976. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  11977. !#zh 读取 16 进制颜色。
  11978. @param hexString hexString
  11979. @example
  11980. ```js
  11981. var color = cc.Color.BLACK;
  11982. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  11983. ```
  11984. */
  11985. fromHEX(hexString: string): Color;
  11986. /**
  11987. !#en TODO
  11988. !#zh 转换为 16 进制。
  11989. @param fmt "#rgb" or "#rrggbb".
  11990. @example
  11991. ```js
  11992. var color = cc.Color.BLACK;
  11993. color.toHEX("#rgb"); // "000";
  11994. color.toHEX("#rrggbb"); // "000000";
  11995. ```
  11996. */
  11997. toHEX(fmt: string): string;
  11998. /**
  11999. !#en Convert to 24bit rgb value.
  12000. !#zh 转换为 24bit 的 RGB 值。
  12001. @example
  12002. ```js
  12003. var color = cc.Color.YELLOW;
  12004. color.toRGBValue(); // 16771844;
  12005. ```
  12006. */
  12007. toRGBValue(): number;
  12008. /**
  12009. !#en TODO
  12010. !#zh 读取 HSV(色彩模型)格式。
  12011. @param h h
  12012. @param s s
  12013. @param v v
  12014. @example
  12015. ```js
  12016. var color = cc.Color.YELLOW;
  12017. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  12018. ```
  12019. */
  12020. fromHSV(h: number, s: number, v: number): Color;
  12021. /**
  12022. !#en TODO
  12023. !#zh 转换为 HSV(色彩模型)格式。
  12024. @example
  12025. ```js
  12026. var color = cc.Color.YELLOW;
  12027. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  12028. ```
  12029. */
  12030. toHSV(): any;
  12031. /**
  12032. !#en TODO
  12033. !#zh RGB 转换为 HSV。
  12034. @param r red, must be [0, 255].
  12035. @param g red, must be [0, 255].
  12036. @param b red, must be [0, 255].
  12037. @example
  12038. ```js
  12039. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  12040. ```
  12041. */
  12042. static rgb2hsv(r: number, g: number, b: number): any;
  12043. /**
  12044. !#en TODO
  12045. !#zh HSV 转换为 RGB。
  12046. @param h h
  12047. @param s s
  12048. @param v v
  12049. @example
  12050. ```js
  12051. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  12052. ```
  12053. */
  12054. static hsv2rgb(h: number, s: number, v: number): any;
  12055. }
  12056. /** !#en A 2D rectangle defined by x, y position and width, height.
  12057. !#zh 通过位置和宽高定义的 2D 矩形。 */
  12058. export class Rect extends ValueType {
  12059. /**
  12060. !#en
  12061. Constructor of cc.Rect class.
  12062. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  12063. !#zh
  12064. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  12065. @param x x
  12066. @param y y
  12067. @param w w
  12068. @param h h
  12069. */
  12070. constructor(x?: number, y?: number, w?: number, h?: number);
  12071. x: number;
  12072. y: number;
  12073. width: number;
  12074. height: number;
  12075. /**
  12076. !#en Creates a rectangle from two coordinate values.
  12077. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  12078. @param v1 v1
  12079. @param v2 v2
  12080. @example
  12081. ```js
  12082. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  12083. ```
  12084. */
  12085. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  12086. /**
  12087. !#en Checks if rect contains.
  12088. !#zh
  12089. 判断 2 个矩形是否有包含。<br/>
  12090. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  12091. 0 这则都不包含。
  12092. @param a Rect a
  12093. @param b Rect b
  12094. @example
  12095. ```js
  12096. var a = new cc.Rect(0, 0, 10, 10);
  12097. var b = new cc.Rect(5, 5, 5, 5);
  12098. var c = new cc.Rect(20, 20, 10, 10);
  12099. cc.Rect.contain(a, b); // 1;
  12100. cc.Rect.contain(b, a); // -1;
  12101. cc.Rect.contain(a, c); // 0;
  12102. ```
  12103. */
  12104. static contain(a: Rect, b: Rect): number;
  12105. /**
  12106. !#en TODO
  12107. !#zh 克隆一个新的 Rect。
  12108. @example
  12109. ```js
  12110. var a = new cc.Rect(0, 0, 10, 10);
  12111. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  12112. ```
  12113. */
  12114. clone(): Rect;
  12115. /**
  12116. !#en TODO
  12117. !#zh 是否等于指定的矩形。
  12118. @param other other
  12119. @example
  12120. ```js
  12121. var a = new cc.Rect(0, 0, 10, 10);
  12122. var b = new cc.Rect(0, 0, 10, 10);
  12123. a.equals(b);// true;
  12124. ```
  12125. */
  12126. equals(other: Rect): boolean;
  12127. /**
  12128. !#en TODO
  12129. !#zh 线性插值
  12130. @param to to
  12131. @param ratio the interpolation coefficient.
  12132. @param out optional, the receiving vector.
  12133. @example
  12134. ```js
  12135. var a = new cc.Rect(0, 0, 10, 10);
  12136. var b = new cc.Rect(50, 50, 100, 100);
  12137. update (dt) {
  12138. // method 1;
  12139. var c = a.lerp(b, dt * 0.1);
  12140. // method 2;
  12141. a.lerp(b, dt * 0.1, c);
  12142. }
  12143. ```
  12144. */
  12145. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12146. /**
  12147. !#en TODO
  12148. !#zh 转换为方便阅读的字符串
  12149. @example
  12150. ```js
  12151. var a = new cc.Rect(0, 0, 10, 10);
  12152. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12153. ```
  12154. */
  12155. toString(): string;
  12156. /** !#en TODO
  12157. !#zh 矩形 x 轴上的最小值。 */
  12158. xMin: number;
  12159. /** !#en TODO
  12160. !#zh 矩形 y 轴上的最小值。 */
  12161. yMin: number;
  12162. /** !#en TODO
  12163. !#zh 矩形 x 轴上的最大值。 */
  12164. xMax: number;
  12165. /** !#en TODO
  12166. !#zh 矩形 y 轴上的最大值。 */
  12167. yMax: number;
  12168. /** !#en The position of the center of the rectangle.
  12169. !#zh 矩形的中心点。 */
  12170. center: Vec2;
  12171. /** !#en The X and Y position of the rectangle.
  12172. !#zh 矩形的 x 和 y 坐标。 */
  12173. origin: Vec2;
  12174. /** !#en Width and height of the rectangle.
  12175. !#zh 矩形的大小。 */
  12176. size: Size;
  12177. /**
  12178. !#en TODO
  12179. !#zh 当前矩形与指定矩形是否相交。
  12180. @param rect rect
  12181. @example
  12182. ```js
  12183. var a = new cc.Rect(0, 0, 10, 10);
  12184. var b = new cc.Rect(0, 0, 20, 20);
  12185. a.intersects(b);// true
  12186. ```
  12187. */
  12188. intersects(rect: Rect): void;
  12189. /**
  12190. !#en TODO
  12191. !#zh 当前矩形是否包含指定坐标点。
  12192. Returns true if the point inside this rectangle.
  12193. @param point point
  12194. @example
  12195. ```js
  12196. var a = new cc.Rect(0, 0, 10, 10);
  12197. var b = new cc.Vec2(0, 5);
  12198. a.contains(b);// true
  12199. ```
  12200. */
  12201. contains(point: Vec2): void;
  12202. /**
  12203. !#en Returns true if the other rect totally inside this rectangle.
  12204. !#zh 当前矩形是否包含指定矩形。
  12205. @param rect rect
  12206. @example
  12207. ```js
  12208. var a = new cc.Rect(0, 0, 20, 20);
  12209. var b = new cc.Rect(0, 0, 10, 10);
  12210. a.containsRect(b);// true
  12211. ```
  12212. */
  12213. containsRect(rect: Rect): void;
  12214. }
  12215. /** !#en
  12216. cc.Size is the class for size object,<br/>
  12217. please do not use its constructor to create sizes,<br/>
  12218. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12219. It will be deprecated soon, please use cc.Vec2 instead.
  12220. !#zh
  12221. cc.Size 是 size 对象的类。<br/>
  12222. 请不要使用它的构造函数创建的 size,<br/>
  12223. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12224. 它不久将被取消,请使用cc.Vec2代替。 */
  12225. export class Size {
  12226. /**
  12227. @param width width
  12228. @param height height
  12229. */
  12230. constructor(width: number|Size, height?: number);
  12231. width: number;
  12232. height: number;
  12233. /** !#en return a Size object with width = 0 and height = 0.
  12234. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12235. static ZERO: Size;
  12236. /**
  12237. !#en TODO
  12238. !#zh 克隆 size 对象。
  12239. @example
  12240. ```js
  12241. var a = new cc.size(10, 10);
  12242. a.clone();// return Size {width: 0, height: 0};
  12243. ```
  12244. */
  12245. clone(): Size;
  12246. /**
  12247. !#en TODO
  12248. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12249. @param other other
  12250. @example
  12251. ```js
  12252. var a = new cc.size(10, 10);
  12253. a.equals(new cc.size(10, 10));// return true;
  12254. ```
  12255. */
  12256. equals(other: Size): boolean;
  12257. /**
  12258. !#en TODO
  12259. !#zh 线性插值。
  12260. @param to to
  12261. @param ratio the interpolation coefficient.
  12262. @param out optional, the receiving vector.
  12263. @example
  12264. ```js
  12265. var a = new cc.size(10, 10);
  12266. var b = new cc.rect(50, 50, 100, 100);
  12267. update (dt) {
  12268. // method 1;
  12269. var c = a.lerp(b, dt * 0.1);
  12270. // method 2;
  12271. a.lerp(b, dt * 0.1, c);
  12272. }
  12273. ```
  12274. */
  12275. lerp(to: Rect, ratio: number, out?: Size): Size;
  12276. /**
  12277. !#en TODO
  12278. !#zh 转换为方便阅读的字符串。
  12279. @example
  12280. ```js
  12281. var a = new cc.size(10, 10);
  12282. a.toString();// return "(10.00, 10.00)";
  12283. ```
  12284. */
  12285. toString(): string;
  12286. }
  12287. /** !#en the device accelerometer reports values for each axis in units of g-force.
  12288. !#zh 设备重力传感器传递的各个轴的数据。 */
  12289. export class Acceleration {
  12290. /**
  12291. @param x x
  12292. @param y y
  12293. @param z z
  12294. @param timestamp timestamp
  12295. */
  12296. constructor(x: number, y: number, z: number, timestamp: number);
  12297. }
  12298. /** !#en Blend Function used for textures.
  12299. !#zh 图像的混合方式。 */
  12300. export class BlendFunc {
  12301. /**
  12302. @param src1 source blend function
  12303. @param dst1 destination blend function
  12304. */
  12305. constructor(src1: number, dst1: number);
  12306. }
  12307. /** !#en
  12308. Enum for blend factor
  12309. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  12310. !#zh
  12311. 混合因子
  12312. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  12313. export enum BlendFactor {
  12314. ONE = 0,
  12315. ZERO = 0,
  12316. SRC_ALPHA = 0,
  12317. SRC_COLOR = 0,
  12318. DST_ALPHA = 0,
  12319. DST_COLOR = 0,
  12320. ONE_MINUS_SRC_ALPHA = 0,
  12321. ONE_MINUS_SRC_COLOR = 0,
  12322. ONE_MINUS_DST_ALPHA = 0,
  12323. ONE_MINUS_DST_COLOR = 0,
  12324. blendFuncDisable = 0,
  12325. }
  12326. /** undefined */
  12327. export enum TextAlignment {
  12328. LEFT = 0,
  12329. CENTER = 0,
  12330. RIGHT = 0,
  12331. }
  12332. /** undefined */
  12333. export class WebGLColor {
  12334. /**
  12335. @param r r
  12336. @param g g
  12337. @param b b
  12338. @param a a
  12339. @param arrayBuffer arrayBuffer
  12340. @param offset offset
  12341. */
  12342. constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number);
  12343. BYTES_PER_ELEMENT: number;
  12344. }
  12345. /** undefined */
  12346. export class Vertex2F {
  12347. /**
  12348. @param x x
  12349. @param y y
  12350. @param arrayBuffer arrayBuffer
  12351. @param offset offset
  12352. */
  12353. constructor(x: number, y: number, arrayBuffer: any[], offset: number);
  12354. BYTES_PER_ELEMENT: number;
  12355. }
  12356. /** undefined */
  12357. export class Vertex3F {
  12358. /**
  12359. @param x x
  12360. @param y y
  12361. @param z z
  12362. @param arrayBuffer arrayBuffer
  12363. @param offset offset
  12364. */
  12365. constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number);
  12366. BYTES_PER_ELEMENT: number;
  12367. }
  12368. /** undefined */
  12369. export class Tex2F {
  12370. /**
  12371. @param u u
  12372. @param v v
  12373. @param arrayBuffer arrayBuffer
  12374. @param offset offset
  12375. */
  12376. constructor(u: number, v: number, arrayBuffer: any[], offset: number);
  12377. BYTES_PER_ELEMENT: number;
  12378. }
  12379. /** undefined */
  12380. export class Quad2 {
  12381. /**
  12382. @param tl tl
  12383. @param tr tr
  12384. @param bl bl
  12385. @param br br
  12386. @param arrayBuffer arrayBuffer
  12387. @param offset offset
  12388. */
  12389. constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number);
  12390. BYTES_PER_ELEMENT: number;
  12391. }
  12392. /** A 3D Quad. 4 * 3 floats */
  12393. export class Quad3 {
  12394. /**
  12395. @param bl1 bl1
  12396. @param br1 br1
  12397. @param tl1 tl1
  12398. @param tr1 tr1
  12399. @param arrayBuffer arrayBuffer
  12400. @param offset offset
  12401. */
  12402. constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number);
  12403. }
  12404. /** undefined */
  12405. export class V3F_C4B_T2F {
  12406. /**
  12407. @param vertices vertices
  12408. @param colors colors
  12409. @param texCoords texCoords
  12410. @param arrayBuffer arrayBuffer
  12411. @param offset offset
  12412. */
  12413. constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12414. BYTES_PER_ELEMENT(): void;
  12415. }
  12416. /** undefined */
  12417. export class V3F_C4B_T2F_Quad {
  12418. /**
  12419. @param tl tl
  12420. @param bl bl
  12421. @param tr tr
  12422. @param br br
  12423. @param arrayBuffer arrayBuffer
  12424. @param offset offset
  12425. */
  12426. constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number);
  12427. BYTES_PER_ELEMENT: number;
  12428. }
  12429. /** undefined */
  12430. export class V2F_C4B_T2F {
  12431. /**
  12432. @param vertices vertices
  12433. @param colors colors
  12434. @param texCoords texCoords
  12435. @param arrayBuffer arrayBuffer
  12436. @param offset offset
  12437. */
  12438. constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12439. BYTES_PER_ELEMENT: number;
  12440. }
  12441. /** undefined */
  12442. export class V2F_C4B_T2F_Triangle {
  12443. /**
  12444. @param a a
  12445. @param b b
  12446. @param c c
  12447. @param arrayBuffer arrayBuffer
  12448. @param offset offset
  12449. */
  12450. constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number);
  12451. }
  12452. /** !#en The base class of all value types.
  12453. !#zh 所有值类型的基类。 */
  12454. export class ValueType {
  12455. /**
  12456. !#en This method returns an exact copy of current value.
  12457. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12458. */
  12459. clone(): ValueType;
  12460. /**
  12461. !#en Compares this object with the other one.
  12462. !#zh 当前对象是否等于指定对象。
  12463. @param other other
  12464. */
  12465. equals(other: ValueType): boolean;
  12466. /**
  12467. !#en
  12468. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12469. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12470. !#zh
  12471. 线性插值。<br/>
  12472. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12473. @param to the to value
  12474. @param ratio the interpolation coefficient
  12475. */
  12476. lerp(to: ValueType, ratio: number): ValueType;
  12477. /**
  12478. !#en TODO
  12479. !#zh 转换为方便阅读的字符串。
  12480. */
  12481. toString(): string;
  12482. }
  12483. /** !#en Representation of 2D vectors and points.
  12484. !#zh 表示 2D 向量和坐标 */
  12485. export class Vec2 extends ValueType {
  12486. /**
  12487. !#en
  12488. Constructor
  12489. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12490. !#zh
  12491. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12492. @param x x
  12493. @param y y
  12494. */
  12495. constructor(x?: number, y?: number);
  12496. x: number;
  12497. y: number;
  12498. /**
  12499. !#en clone a Vec2 value
  12500. !#zh 克隆一个 Vec2 值
  12501. */
  12502. clone(): Vec2;
  12503. /**
  12504. !#en TODO
  12505. !#zh 设置向量值。
  12506. @param newValue !#en new value to set. !#zh 要设置的新值
  12507. */
  12508. set(newValue: Vec2): Vec2;
  12509. /**
  12510. !#en TODO
  12511. !#zh 当前的向量是否与指定的向量相等。
  12512. @param other other
  12513. */
  12514. equals(other: Vec2): boolean;
  12515. /**
  12516. !#en TODO
  12517. !#zh 转换为方便阅读的字符串。
  12518. */
  12519. toString(): string;
  12520. /**
  12521. !#en TODO
  12522. !#zh 线性插值。
  12523. @param to to
  12524. @param ratio the interpolation coefficient
  12525. @param out optional, the receiving vector
  12526. */
  12527. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12528. /**
  12529. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  12530. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  12531. @param vector vector
  12532. @example
  12533. ```js
  12534. var v = cc.v2(10, 10);
  12535. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  12536. ```
  12537. */
  12538. addSelf(vector: Vec2): Vec2;
  12539. /**
  12540. !#en Adds two vectors, and returns the new result.
  12541. !#zh 向量加法,并返回新结果。
  12542. @param vector vector
  12543. @param out optional, the receiving vector
  12544. @example
  12545. ```js
  12546. var v = cc.v2(10, 10);
  12547. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  12548. var v1;
  12549. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  12550. ```
  12551. */
  12552. add(vector: Vec2, out?: Vec2): Vec2;
  12553. /**
  12554. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12555. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12556. @param vector vector
  12557. @example
  12558. ```js
  12559. var v = cc.v2(10, 10);
  12560. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12561. ```
  12562. */
  12563. subSelf(vector: Vec2): Vec2;
  12564. /**
  12565. !#en Subtracts one vector from this, and returns the new result.
  12566. !#zh 向量减法,并返回新结果。
  12567. @param vector vector
  12568. @param out optional, the receiving vector
  12569. @example
  12570. ```js
  12571. var v = cc.v2(10, 10);
  12572. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12573. var v1;
  12574. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12575. ```
  12576. */
  12577. sub(vector: Vec2, out?: Vec2): Vec2;
  12578. /**
  12579. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12580. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12581. @param num num
  12582. @example
  12583. ```js
  12584. var v = cc.v2(10, 10);
  12585. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12586. ```
  12587. */
  12588. mulSelf(num: number): Vec2;
  12589. /**
  12590. !#en Multiplies by a number, and returns the new result.
  12591. !#zh 缩放向量,并返回新结果。
  12592. @param num num
  12593. @param out optional, the receiving vector
  12594. @example
  12595. ```js
  12596. var v = cc.v2(10, 10);
  12597. v.mul(5); // return Vec2 {x: 50, y: 50};
  12598. var v1;
  12599. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12600. ```
  12601. */
  12602. mul(num: number, out?: Vec2): Vec2;
  12603. /**
  12604. !#en Multiplies two vectors.
  12605. !#zh 分量相乘。
  12606. @param vector vector
  12607. @example
  12608. ```js
  12609. var v = cc.v2(10, 10);
  12610. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12611. ```
  12612. */
  12613. scaleSelf(vector: Vec2): Vec2;
  12614. /**
  12615. !#en Multiplies two vectors, and returns the new result.
  12616. !#zh 分量相乘,并返回新的结果。
  12617. @param vector vector
  12618. @param out optional, the receiving vector
  12619. @example
  12620. ```js
  12621. var v = cc.v2(10, 10);
  12622. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12623. var v1;
  12624. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12625. ```
  12626. */
  12627. scale(vector: Vec2, out?: Vec2): Vec2;
  12628. /**
  12629. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12630. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12631. @param vector vector
  12632. @example
  12633. ```js
  12634. var v = cc.v2(10, 10);
  12635. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12636. ```
  12637. */
  12638. divSelf(vector: Vec2): Vec2;
  12639. /**
  12640. !#en Divides by a number, and returns the new result.
  12641. !#zh 向量除法,并返回新的结果。
  12642. @param vector vector
  12643. @param out optional, the receiving vector
  12644. @example
  12645. ```js
  12646. var v = cc.v2(10, 10);
  12647. v.div(5); // return Vec2 {x: 2, y: 2};
  12648. var v1;
  12649. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12650. ```
  12651. */
  12652. div(vector: Vec2, out?: Vec2): Vec2;
  12653. /**
  12654. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12655. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12656. @example
  12657. ```js
  12658. var v = cc.v2(10, 10);
  12659. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12660. ```
  12661. */
  12662. negSelf(): Vec2;
  12663. /**
  12664. !#en Negates the components, and returns the new result.
  12665. !#zh 返回取反后的新向量。
  12666. @param out optional, the receiving vector
  12667. @example
  12668. ```js
  12669. var v = cc.v2(10, 10);
  12670. var v1;
  12671. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12672. ```
  12673. */
  12674. neg(out?: Vec2): Vec2;
  12675. /**
  12676. !#en Dot product
  12677. !#zh 当前向量与指定向量进行点乘。
  12678. @param vector vector
  12679. @example
  12680. ```js
  12681. var v = cc.v2(10, 10);
  12682. v.dot(cc.v2(5, 5)); // return 100;
  12683. ```
  12684. */
  12685. dot(vector?: Vec2): number;
  12686. /**
  12687. !#en Cross product
  12688. !#zh 当前向量与指定向量进行叉乘。
  12689. @param vector vector
  12690. @example
  12691. ```js
  12692. var v = cc.v2(10, 10);
  12693. v.cross(cc.v2(5, 5)); // return 0;
  12694. ```
  12695. */
  12696. cross(vector?: Vec2): number;
  12697. /**
  12698. !#en Returns the length of this vector.
  12699. !#zh 返回该向量的长度。
  12700. @example
  12701. ```js
  12702. var v = cc.v2(10, 10);
  12703. v.mag(); // return 14.142135623730951;
  12704. ```
  12705. */
  12706. mag(): number;
  12707. /**
  12708. !#en Returns the squared length of this vector.
  12709. !#zh 返回该向量的长度平方。
  12710. @example
  12711. ```js
  12712. var v = cc.v2(10, 10);
  12713. v.magSqr(); // return 200;
  12714. ```
  12715. */
  12716. magSqr(): number;
  12717. /**
  12718. !#en Make the length of this vector to 1.
  12719. !#zh 向量归一化,让这个向量的长度为 1。
  12720. @example
  12721. ```js
  12722. var v = cc.v2(10, 10);
  12723. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  12724. ```
  12725. */
  12726. normalizeSelf(): Vec2;
  12727. /**
  12728. !#en
  12729. Returns this vector with a magnitude of 1.<br/>
  12730. <br/>
  12731. 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.
  12732. !#zh
  12733. 返回归一化后的向量。<br/>
  12734. <br/>
  12735. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  12736. @param out optional, the receiving vector
  12737. */
  12738. normalize(out?: Vec2): Vec2;
  12739. /**
  12740. !#en Get angle in radian between this and vector.
  12741. !#zh 夹角的弧度。
  12742. @param vector vector
  12743. */
  12744. angle(vector: Vec2): number;
  12745. /**
  12746. !#en Get angle in radian between this and vector with direction.
  12747. !#zh 带方向的夹角的弧度。
  12748. @param vector vector
  12749. */
  12750. signAngle(vector: Vec2): number;
  12751. /**
  12752. !#en rotate
  12753. !#zh 返回旋转给定弧度后的新向量。
  12754. @param radians radians
  12755. @param out optional, the receiving vector
  12756. */
  12757. rotate(radians: number, out?: Vec2): Vec2;
  12758. /**
  12759. !#en rotate self
  12760. !#zh 按指定弧度旋转向量。
  12761. @param radians radians
  12762. */
  12763. rotateSelf(radians: number): Vec2;
  12764. /** !#en return a Vec2 object with x = 1 and y = 1.
  12765. !#zh 新 Vec2 对象。 */
  12766. static ONE: Vec2;
  12767. /** !#en return a Vec2 object with x = 0 and y = 0.
  12768. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  12769. static ZERO: Vec2;
  12770. /** !#en return a Vec2 object with x = 0 and y = 1.
  12771. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  12772. static UP: Vec2;
  12773. /** !#en return a Vec2 object with x = 1 and y = 0.
  12774. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  12775. static RIGHT: Vec2;
  12776. }
  12777. /** undefined */
  12778. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  12779. /** !#en Position offset
  12780. !#zh 位置偏移量 */
  12781. offset: Vec2;
  12782. /** !#en Box size
  12783. !#zh 包围盒大小 */
  12784. size: Size;
  12785. }
  12786. /** undefined */
  12787. export class PhysicsChainCollider extends PolygonCollider {
  12788. /** !#en Whether the chain is loop
  12789. !#zh 链条是否首尾相连 */
  12790. loop: boolean;
  12791. /** !#en Chain points
  12792. !#zh 链条顶点数组 */
  12793. points: [Vec2];
  12794. }
  12795. /** undefined */
  12796. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  12797. /** !#en Position offset
  12798. !#zh 位置偏移量 */
  12799. offset: Vec2;
  12800. /** !#en Circle radius
  12801. !#zh 圆形半径 */
  12802. radius: number;
  12803. }
  12804. /** undefined */
  12805. export class PhysicsCollider {
  12806. /** !#en
  12807. The density.
  12808. !#zh
  12809. 密度 */
  12810. density: number;
  12811. /** !#en
  12812. A sensor collider collects contact information but never generates a collision response
  12813. !#zh
  12814. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  12815. sensor: boolean;
  12816. /** !#en
  12817. The friction coefficient, usually in the range [0,1].
  12818. !#zh
  12819. 摩擦系数,取值一般在 [0, 1] 之间 */
  12820. friction: number;
  12821. /** !#en
  12822. The restitution (elasticity) usually in the range [0,1].
  12823. !#zh
  12824. 弹性系数,取值一般在 [0, 1]之间 */
  12825. restitution: number;
  12826. /** !#en
  12827. Physics collider will find the rigidbody component on the node and set to this property.
  12828. !#zh
  12829. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  12830. body: RigidBody;
  12831. /**
  12832. !#en
  12833. Apply current changes to collider, this will regenerate inner box2d fixtures.
  12834. !#zh
  12835. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  12836. */
  12837. apply(): void;
  12838. /**
  12839. !#en
  12840. Get the world aabb of the collider
  12841. !#zh
  12842. 获取碰撞体的世界坐标系下的包围盒
  12843. */
  12844. getAABB(): void;
  12845. }
  12846. /** undefined */
  12847. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  12848. /** !#en Position offset
  12849. !#zh 位置偏移量 */
  12850. offset: Vec2;
  12851. /** !#en Polygon points
  12852. !#zh 多边形顶点数组 */
  12853. points: [Vec2];
  12854. }
  12855. /** !#en
  12856. A distance joint constrains two points on two bodies
  12857. to remain at a fixed distance from each other. You can view
  12858. this as a massless, rigid rod.
  12859. !#zh
  12860. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  12861. export class DistanceJoint extends Joint {
  12862. /** !#en
  12863. The distance separating the two ends of the joint.
  12864. !#zh
  12865. 关节两端的距离 */
  12866. distance: number;
  12867. /** !#en
  12868. The spring frequency.
  12869. !#zh
  12870. 弹性系数。 */
  12871. frequency: number;
  12872. /** !#en
  12873. The damping ratio.
  12874. !#zh
  12875. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  12876. 0: number;
  12877. }
  12878. /** !#en
  12879. Base class for joints to connect rigidbody.
  12880. !#zh
  12881. 关节类的基类 */
  12882. export class Joint extends Component {
  12883. /** !#en
  12884. The anchor of the rigidbody.
  12885. !#zh
  12886. 刚体的锚点。 */
  12887. anchor: Vec2;
  12888. /** !#en
  12889. The anchor of the connected rigidbody.
  12890. !#zh
  12891. 关节另一端刚体的锚点。 */
  12892. connectedAnchor: Vec2;
  12893. /** !#en
  12894. The rigidbody to which the other end of the joint is attached.
  12895. !#zh
  12896. 关节另一端链接的刚体 */
  12897. connectedBody: RigidBody;
  12898. /** !#en
  12899. Should the two rigid bodies connected with this joint collide with each other?
  12900. !#zh
  12901. 链接到关节上的两个刚体是否应该相互碰撞? */
  12902. collideConnected: boolean;
  12903. /**
  12904. !#en
  12905. Apply current changes to joint, this will regenerate inner box2d joint.
  12906. !#zh
  12907. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  12908. */
  12909. apply(): void;
  12910. /**
  12911. !#en
  12912. Get the anchor point on rigidbody in world coordinates.
  12913. !#zh
  12914. 获取刚体世界坐标系下的锚点。
  12915. */
  12916. getWorldAnchor(): Vec2;
  12917. /**
  12918. !#en
  12919. Get the anchor point on connected rigidbody in world coordinates.
  12920. !#zh
  12921. 获取链接刚体世界坐标系下的锚点。
  12922. */
  12923. getWorldConnectedAnchor(): Vec2;
  12924. /**
  12925. !#en
  12926. Gets the reaction force of the joint.
  12927. !#zh
  12928. 获取关节的反作用力。
  12929. @param timeStep The time to calculate the reaction force for.
  12930. */
  12931. getReactionForce(timeStep: number): number;
  12932. /**
  12933. !#en
  12934. Gets the reaction torque of the joint.
  12935. !#zh
  12936. 获取关节的反扭矩。
  12937. @param timeStep The time to calculate the reaction torque for.
  12938. */
  12939. getReactionTorque(timeStep: number): number;
  12940. }
  12941. /** !#en
  12942. A motor joint is used to control the relative motion
  12943. between two bodies. A typical usage is to control the movement
  12944. of a dynamic body with respect to the ground.
  12945. !#zh
  12946. 马达关节被用来控制两个刚体间的相对运动。
  12947. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  12948. export class MotorJoint extends Joint {
  12949. /** !#en
  12950. The anchor of the rigidbody.
  12951. !#zh
  12952. 刚体的锚点。 */
  12953. anchor: Vec2;
  12954. /** !#en
  12955. The anchor of the connected rigidbody.
  12956. !#zh
  12957. 关节另一端刚体的锚点。 */
  12958. connectedAnchor: Vec2;
  12959. /** !#en
  12960. The linear offset from connected rigidbody to rigidbody.
  12961. !#zh
  12962. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  12963. linearOffset: Vec2;
  12964. /** !#en
  12965. The angular offset from connected rigidbody to rigidbody.
  12966. !#zh
  12967. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  12968. angularOffset: number;
  12969. /** !#en
  12970. The maximum force can be applied to rigidbody.
  12971. !#zh
  12972. 可以应用于刚体的最大的力值 */
  12973. maxForce: number;
  12974. /** !#en
  12975. The maximum torque can be applied to rigidbody.
  12976. !#zh
  12977. 可以应用于刚体的最大扭矩值 */
  12978. maxTorque: number;
  12979. /** !#en
  12980. The position correction factor in the range [0,1].
  12981. !#zh
  12982. 位置矫正系数,范围为 [0, 1] */
  12983. correctionFactor: number;
  12984. }
  12985. /** !#en
  12986. A mouse joint is used to make a point on a body track a
  12987. specified world point. This a soft constraint with a maximum
  12988. force. This allows the constraint to stretch and without
  12989. applying huge forces.
  12990. Mouse Joint will auto register the touch event with the mouse region node,
  12991. and move the choosed rigidbody in touch move event.
  12992. Note : generally mouse joint only used in test bed.
  12993. !#zh
  12994. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  12995. 鼠标关节可以指定一个最大的里来施加一个柔和的约束。
  12996. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  12997. 注意:一般鼠标关节只在测试环境中使用。 */
  12998. export class MouseJoint extends Joint {
  12999. /** !#en
  13000. The anchor of the rigidbody.
  13001. !#zh
  13002. 刚体的锚点。 */
  13003. anchor: Vec2;
  13004. /** !#en
  13005. The anchor of the connected rigidbody.
  13006. !#zh
  13007. 关节另一端刚体的锚点。 */
  13008. connectedAnchor: Vec2;
  13009. /** !#en
  13010. The node used to register touch evnet.
  13011. If this is null, it will be the joint's node.
  13012. !#zh
  13013. 用于注册触摸事件的节点。
  13014. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  13015. mouseRegion: Node;
  13016. /** !#en
  13017. The target point.
  13018. The mouse joint will move choosed rigidbody to target point.
  13019. !#zh
  13020. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  13021. target: Vec2;
  13022. /** !#en
  13023. The spring frequency.
  13024. !#zh
  13025. 弹簧系数。 */
  13026. frequency: number;
  13027. /** !#en
  13028. The damping ratio.
  13029. !#zh
  13030. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13031. 0: number;
  13032. /** !#en
  13033. The maximum force
  13034. !#zh
  13035. 最大阻力值 */
  13036. maxForce: number;
  13037. }
  13038. /** !#en
  13039. A prismatic joint. This joint provides one degree of freedom: translation
  13040. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  13041. use a joint limit to restrict the range of motion and a joint motor to
  13042. drive the motion or to model joint friction.
  13043. !#zh
  13044. 移动关节指定了只能在一个方向上移动刚体。
  13045. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  13046. export class PrismaticJoint extends Joint {
  13047. /** !#en
  13048. The local joint axis relative to rigidbody.
  13049. !#zh
  13050. 指定刚体可以移动的方向。 */
  13051. localAxisA: Vec2;
  13052. /** !#en
  13053. The reference angle.
  13054. !#zh
  13055. 相对角度 */
  13056. referenceAngle: number;
  13057. /** !#en
  13058. Enable joint distance limit?
  13059. !#zh
  13060. 是否开启关节的距离限制? */
  13061. enableLimit: boolean;
  13062. /** !#en
  13063. Enable joint motor?
  13064. !#zh
  13065. 是否开启关节马达? */
  13066. enableMotor: boolean;
  13067. /** !#en
  13068. The lower joint limit.
  13069. !#zh
  13070. 刚体能够移动的最小值 */
  13071. lowerLimit: number;
  13072. /** !#en
  13073. The upper joint limit.
  13074. !#zh
  13075. 刚体能够移动的最大值 */
  13076. upperLimit: number;
  13077. /** !#en
  13078. The maxium force can be applied to rigidbody to rearch the target motor speed.
  13079. !#zh
  13080. 可以施加到刚体的最大力。 */
  13081. maxMotorForce: number;
  13082. /** !#en
  13083. The expected motor speed.
  13084. !#zh
  13085. 期望的马达速度。 */
  13086. motorSpeed: number;
  13087. }
  13088. /** !#en
  13089. A revolute joint constrains two bodies to share a common point while they
  13090. are free to rotate about the point. The relative rotation about the shared
  13091. point is the joint angle. You can limit the relative rotation with
  13092. a joint limit that specifies a lower and upper angle. You can use a motor
  13093. to drive the relative rotation about the shared point. A maximum motor torque
  13094. is provided so that infinite forces are not generated.
  13095. !#zh
  13096. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  13097. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  13098. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  13099. export class RevoluteJoint extends Joint {
  13100. /** !#en
  13101. The reference angle.
  13102. An angle between bodies considered to be zero for the joint angle.
  13103. !#zh
  13104. 相对角度。
  13105. 两个物体之间角度为零时可以看作相等于关节角度 */
  13106. referenceAngle: number;
  13107. /** !#en
  13108. The lower angle.
  13109. !#zh
  13110. 角度的最低限制。 */
  13111. lowerAngle: number;
  13112. /** !#en
  13113. The upper angle.
  13114. !#zh
  13115. 角度的最高限制。 */
  13116. upperAngle: number;
  13117. /** !#en
  13118. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13119. !#zh
  13120. 可以施加到刚体的最大扭矩。 */
  13121. maxMotorTorque: number;
  13122. /** !#en
  13123. The expected motor speed.
  13124. !#zh
  13125. 期望的马达速度。 */
  13126. motorSpeed: number;
  13127. /** !#en
  13128. Enable joint limit?
  13129. !#zh
  13130. 是否开启关节的限制? */
  13131. enableLimit: boolean;
  13132. /** !#en
  13133. Enable joint motor?
  13134. !#zh
  13135. 是否开启关节马达? */
  13136. enableMotor: boolean;
  13137. /**
  13138. !#en
  13139. Get the joint angle.
  13140. !#zh
  13141. 获取关节角度。
  13142. */
  13143. getJointAngle(): number;
  13144. }
  13145. /** !#en
  13146. A rope joint enforces a maximum distance between two points
  13147. on two bodies. It has no other effect.
  13148. Warning: if you attempt to change the maximum length during
  13149. the simulation you will get some non-physical behavior.
  13150. !#zh
  13151. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  13152. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  13153. export class RopeJoint extends Joint {
  13154. /** !#en
  13155. The max length.
  13156. !#zh
  13157. 最大长度。 */
  13158. maxLength: number;
  13159. }
  13160. /** !#en
  13161. A weld joint essentially glues two bodies together. A weld joint may
  13162. distort somewhat because the island constraint solver is approximate.
  13163. !#zh
  13164. 熔接关节相当于将两个刚体粘在了一起。
  13165. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  13166. export class WeldJoint extends Joint {
  13167. /** !#en
  13168. The reference angle.
  13169. !#zh
  13170. 相对角度。 */
  13171. referenceAngle: number;
  13172. /** !#en
  13173. The frequency.
  13174. !#zh
  13175. 弹性系数。 */
  13176. frequency: number;
  13177. /** !#en
  13178. The damping ratio.
  13179. !#zh
  13180. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13181. 0: number;
  13182. }
  13183. /** !#en
  13184. A wheel joint. This joint provides two degrees of freedom: translation
  13185. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  13186. the rotation or to model rotational friction.
  13187. This joint is designed for vehicle suspensions.
  13188. !#zh
  13189. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  13190. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  13191. 轮组关节是专门为机动车类型设计的。 */
  13192. export class WheelJoint extends Joint {
  13193. /** !#en
  13194. The local joint axis relative to rigidbody.
  13195. !#zh
  13196. 指定刚体可以移动的方向。 */
  13197. localAxisA: Vec2;
  13198. /** !#en
  13199. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13200. !#zh
  13201. 可以施加到刚体的最大扭矩。 */
  13202. maxMotorTorque: number;
  13203. /** !#en
  13204. The expected motor speed.
  13205. !#zh
  13206. 期望的马达速度。 */
  13207. motorSpeed: number;
  13208. /** !#en
  13209. Enable joint motor?
  13210. !#zh
  13211. 是否开启关节马达? */
  13212. enableMotor: boolean;
  13213. /** !#en
  13214. The spring frequency.
  13215. !#zh
  13216. 弹性系数。 */
  13217. frequency: number;
  13218. /** !#en
  13219. The damping ratio.
  13220. !#zh
  13221. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13222. dampingRatio: number;
  13223. }
  13224. /****************************************************
  13225. * audioEngine
  13226. *****************************************************/
  13227. export module audioEngine {
  13228. /** !#en Audio state.
  13229. !#zh 声音播放状态 */
  13230. export enum AudioState {
  13231. ERROR = 0,
  13232. INITIALZING = 0,
  13233. PLAYING = 0,
  13234. PAUSED = 0,
  13235. }
  13236. }
  13237. /****************************************************
  13238. * Node
  13239. *****************************************************/
  13240. export module Node {
  13241. /** !#en The event type supported by Node
  13242. !#zh Node 支持的事件类型 */
  13243. export class EventType {
  13244. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  13245. !#zh 当手指触摸到屏幕时。 */
  13246. static TOUCH_START: string;
  13247. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  13248. !#zh 当手指在屏幕上目标节点区域内移动时。 */
  13249. static TOUCH_MOVE: string;
  13250. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  13251. !#zh 当手指在目标节点区域内离开屏幕时。 */
  13252. static TOUCH_END: string;
  13253. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  13254. !#zh 当手指在目标节点区域外离开屏幕时。 */
  13255. static TOUCH_CANCEL: string;
  13256. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  13257. !#zh 当鼠标按下时触发一次。 */
  13258. static MOUSE_DOWN: string;
  13259. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  13260. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  13261. static MOUSE_MOVE: string;
  13262. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  13263. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  13264. static MOUSE_ENTER: string;
  13265. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  13266. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  13267. static MOUSE_LEAVE: string;
  13268. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  13269. !#zh 当鼠标从按下状态松开时触发一次。 */
  13270. static MOUSE_UP: string;
  13271. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  13272. !#zh 当鼠标滚轮滚动时。 */
  13273. static MOUSE_WHEEL: string;
  13274. }
  13275. }
  13276. /****************************************************
  13277. * ParticleSystem
  13278. *****************************************************/
  13279. export module ParticleSystem {
  13280. /** !#en Enum for emitter modes
  13281. !#zh 发射模式 */
  13282. export enum EmitterMode {
  13283. GRAVITY = 0,
  13284. RADIUS = 0,
  13285. }
  13286. }
  13287. /****************************************************
  13288. * ParticleSystem
  13289. *****************************************************/
  13290. export module ParticleSystem {
  13291. /** !#en Enum for particles movement type.
  13292. !#zh 粒子位置类型 */
  13293. export enum PositionType {
  13294. FREE = 0,
  13295. RELATIVE = 0,
  13296. GROUPED = 0,
  13297. }
  13298. }
  13299. /****************************************************
  13300. * TiledMap
  13301. *****************************************************/
  13302. export module TiledMap {
  13303. /** !#en The orientation of tiled map.
  13304. !#zh Tiled Map 地图方向。 */
  13305. export enum Orientation {
  13306. ORTHO = 0,
  13307. HEX = 0,
  13308. ISO = 0,
  13309. NONE = 0,
  13310. MAP = 0,
  13311. LAYER = 0,
  13312. OBJECTGROUP = 0,
  13313. OBJECT = 0,
  13314. TILE = 0,
  13315. HORIZONTAL = 0,
  13316. VERTICAL = 0,
  13317. DIAGONAL = 0,
  13318. FLIPPED_ALL = 0,
  13319. FLIPPED_MASK = 0,
  13320. STAGGERAXIS_X = 0,
  13321. STAGGERAXIS_Y = 0,
  13322. STAGGERINDEX_ODD = 0,
  13323. STAGGERINDEX_EVEN = 0,
  13324. }
  13325. }
  13326. /****************************************************
  13327. * Collider
  13328. *****************************************************/
  13329. export module Collider {
  13330. /** !#en Defines a Box Collider .
  13331. !#zh 用来定义包围盒碰撞体 */
  13332. export class Box {
  13333. /** !#en Position offset
  13334. !#zh 位置偏移量 */
  13335. offset: Vec2;
  13336. /** !#en Box size
  13337. !#zh 包围盒大小 */
  13338. size: Size;
  13339. }
  13340. }
  13341. /****************************************************
  13342. * Collider
  13343. *****************************************************/
  13344. export module Collider {
  13345. /** !#en Defines a Circle Collider .
  13346. !#zh 用来定义圆形碰撞体 */
  13347. export class Circle {
  13348. /** !#en Position offset
  13349. !#zh 位置偏移量 */
  13350. offset: Vec2;
  13351. /** !#en Circle radius
  13352. !#zh 圆形半径 */
  13353. radius: number;
  13354. }
  13355. }
  13356. /****************************************************
  13357. * Collider
  13358. *****************************************************/
  13359. export module Collider {
  13360. /** !#en Defines a Polygon Collider .
  13361. !#zh 用来定义多边形碰撞体 */
  13362. export class Polygon {
  13363. /** !#en Position offset
  13364. !#zh 位置偏移量 */
  13365. offset: Vec2;
  13366. /** !#en Polygon points
  13367. !#zh 多边形顶点数组 */
  13368. points: [Vec2];
  13369. }
  13370. }
  13371. /****************************************************
  13372. * Button
  13373. *****************************************************/
  13374. export module Button {
  13375. /** !#en Enum for transition type.
  13376. !#zh 过渡类型 */
  13377. export enum Transition {
  13378. NONE = 0,
  13379. COLOR = 0,
  13380. SPRITE = 0,
  13381. SCALE = 0,
  13382. }
  13383. }
  13384. /****************************************************
  13385. * Component
  13386. *****************************************************/
  13387. export module Component {
  13388. /** !#en
  13389. Component will register a event to target component's handler.
  13390. And it will trigger the handler when a certain event occurs.
  13391. !@zh
  13392. “EventHandler” 类用来设置场景中的事件回调,
  13393. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  13394. 并可通过 emit 方法调用目标函数。 */
  13395. export class EventHandler {
  13396. /** !#en Event target
  13397. !#zh 目标节点 */
  13398. target: Node;
  13399. /** !#en Component name
  13400. !#zh 目标组件名 */
  13401. component: string;
  13402. /** !#en Event handler
  13403. !#zh 响应事件函数名 */
  13404. handler: string;
  13405. /** !#en Custom Event Data
  13406. !#zh 自定义事件数据 */
  13407. customEventData: string;
  13408. /**
  13409. @param events events
  13410. @param params params
  13411. */
  13412. static emitEvents(events: Component.EventHandler[], ...params: any[]): void;
  13413. /**
  13414. !#en Emit event with params
  13415. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  13416. @param params params
  13417. @example
  13418. ```js
  13419. // Call Function
  13420. var eventHandler = new cc.Component.EventHandler();
  13421. eventHandler.target = newTarget;
  13422. eventHandler.component = "MainMenu";
  13423. eventHandler.handler = "OnClick"
  13424. eventHandler.emit(["param1", "param2", ....]);
  13425. ```
  13426. */
  13427. emit(params: any[]): void;
  13428. }
  13429. }
  13430. /****************************************************
  13431. * EditBox
  13432. *****************************************************/
  13433. export module EditBox {
  13434. /** !#en Enum for keyboard return types
  13435. !#zh 键盘的返回键类型 */
  13436. export enum KeyboardReturnType {
  13437. DEFAULT = 0,
  13438. DONE = 0,
  13439. SEND = 0,
  13440. SEARCH = 0,
  13441. GO = 0,
  13442. }
  13443. }
  13444. /****************************************************
  13445. * EditBox
  13446. *****************************************************/
  13447. export module EditBox {
  13448. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  13449. !#zh 输入模式 */
  13450. export enum InputMode {
  13451. ANY = 0,
  13452. EMAIL_ADDR = 0,
  13453. NUMERIC = 0,
  13454. PHONE_NUMBER = 0,
  13455. URL = 0,
  13456. DECIMAL = 0,
  13457. SINGLE_LINE = 0,
  13458. }
  13459. }
  13460. /****************************************************
  13461. * EditBox
  13462. *****************************************************/
  13463. export module EditBox {
  13464. /** !#en Enum for the EditBox's input flags
  13465. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  13466. export enum InputFlag {
  13467. PASSWORD = 0,
  13468. SENSITIVE = 0,
  13469. INITIAL_CAPS_WORD = 0,
  13470. INITIAL_CAPS_SENTENCE = 0,
  13471. INITIAL_CAPS_ALL_CHARACTERS = 0,
  13472. }
  13473. }
  13474. /****************************************************
  13475. * Label
  13476. *****************************************************/
  13477. export module Label {
  13478. /** !#en Enum for text alignment.
  13479. !#zh 文本横向对齐类型 */
  13480. export enum HorizontalAlign {
  13481. LEFT = 0,
  13482. CENTER = 0,
  13483. RIGHT = 0,
  13484. }
  13485. }
  13486. /****************************************************
  13487. * Label
  13488. *****************************************************/
  13489. export module Label {
  13490. /** !#en Enum for vertical text alignment.
  13491. !#zh 文本垂直对齐类型 */
  13492. export enum VerticalAlign {
  13493. TOP = 0,
  13494. CENTER = 0,
  13495. BOTTOM = 0,
  13496. }
  13497. }
  13498. /****************************************************
  13499. * Label
  13500. *****************************************************/
  13501. export module Label {
  13502. /** !#en Enum for Overflow.
  13503. !#zh Overflow 类型 */
  13504. export enum Overflow {
  13505. NONE = 0,
  13506. CLAMP = 0,
  13507. SHRINK = 0,
  13508. RESIZE_HEIGHT = 0,
  13509. }
  13510. }
  13511. /****************************************************
  13512. * Label
  13513. *****************************************************/
  13514. export module Label {
  13515. /** !#en Enum for font type.
  13516. !#zh Type 类型 */
  13517. export enum Type {
  13518. TTF = 0,
  13519. BMFont = 0,
  13520. SystemFont = 0,
  13521. }
  13522. }
  13523. /****************************************************
  13524. * Layout
  13525. *****************************************************/
  13526. export module Layout {
  13527. /** !#en Enum for Layout type
  13528. !#zh 布局类型 */
  13529. export enum Type {
  13530. NONE = 0,
  13531. HORIZONTAL = 0,
  13532. VERTICAL = 0,
  13533. GRID = 0,
  13534. }
  13535. }
  13536. /****************************************************
  13537. * Layout
  13538. *****************************************************/
  13539. export module Layout {
  13540. /** !#en Enum for Layout Resize Mode
  13541. !#zh 缩放模式 */
  13542. export enum ResizeMode {
  13543. NONE = 0,
  13544. CONTAINER = 0,
  13545. CHILDREN = 0,
  13546. }
  13547. }
  13548. /****************************************************
  13549. * Layout
  13550. *****************************************************/
  13551. export module Layout {
  13552. /** !#en Enum for Grid Layout start axis direction.
  13553. The items in grid layout will be arranged in each axis at first.;
  13554. !#zh 布局轴向,只用于 GRID 布局。 */
  13555. export enum AxisDirection {
  13556. HORIZONTAL = 0,
  13557. VERTICAL = 0,
  13558. }
  13559. }
  13560. /****************************************************
  13561. * Layout
  13562. *****************************************************/
  13563. export module Layout {
  13564. /** !#en Enum for vertical layout direction.
  13565. Used in Grid Layout together with AxisDirection is VERTICAL
  13566. !#zh 垂直方向布局方式 */
  13567. export enum VerticalDirection {
  13568. BOTTOM_TO_TOP = 0,
  13569. TOP_TO_BOTTOM = 0,
  13570. }
  13571. }
  13572. /****************************************************
  13573. * Layout
  13574. *****************************************************/
  13575. export module Layout {
  13576. /** !#en Enum for horizontal layout direction.
  13577. Used in Grid Layout together with AxisDirection is HORIZONTAL
  13578. !#zh 水平方向布局方式 */
  13579. export enum HorizontalDirection {
  13580. LEFT_TO_RIGHT = 0,
  13581. RIGHT_TO_LEFT = 0,
  13582. }
  13583. }
  13584. /****************************************************
  13585. * Mask
  13586. *****************************************************/
  13587. export module Mask {
  13588. /** !#en the type for mask.
  13589. !#zh 遮罩组件类型 */
  13590. export enum Type {
  13591. RECT = 0,
  13592. ELLIPSE = 0,
  13593. IMAGE_STENCIL = 0,
  13594. }
  13595. }
  13596. /****************************************************
  13597. * PageView
  13598. *****************************************************/
  13599. export module PageView {
  13600. /** !#en The Page View Size Mode
  13601. !#zh 页面视图每个页面统一的大小类型 */
  13602. export enum SizeMode {
  13603. Unified = 0,
  13604. Free = 0,
  13605. }
  13606. }
  13607. /****************************************************
  13608. * PageView
  13609. *****************************************************/
  13610. export module PageView {
  13611. /** !#en The Page View Direction
  13612. !#zh 页面视图滚动类型 */
  13613. export enum Direction {
  13614. Horizontal = 0,
  13615. Vertical = 0,
  13616. }
  13617. }
  13618. /****************************************************
  13619. * PageView
  13620. *****************************************************/
  13621. export module PageView {
  13622. /** !#en Enum for ScrollView event type.
  13623. !#zh 滚动视图事件类型 */
  13624. export enum EventType {
  13625. PAGE_TURNING = 0,
  13626. }
  13627. }
  13628. /****************************************************
  13629. * PageViewIndicator
  13630. *****************************************************/
  13631. export module PageViewIndicator {
  13632. /** !#en Enum for PageView Indicator direction
  13633. !#zh 页面视图指示器的摆放方向 */
  13634. export enum Direction {
  13635. HORIZONTAL = 0,
  13636. VERTICAL = 0,
  13637. }
  13638. }
  13639. /****************************************************
  13640. * ProgressBar
  13641. *****************************************************/
  13642. export module ProgressBar {
  13643. /** !#en Enum for ProgressBar mode
  13644. !#zh 进度条模式 */
  13645. export enum Mode {
  13646. HORIZONTAL = 0,
  13647. VERTICAL = 0,
  13648. FILLED = 0,
  13649. }
  13650. }
  13651. /****************************************************
  13652. * Scrollbar
  13653. *****************************************************/
  13654. export module Scrollbar {
  13655. /** Enum for Scrollbar direction */
  13656. export enum Direction {
  13657. HORIZONTAL = 0,
  13658. VERTICAL = 0,
  13659. }
  13660. }
  13661. /****************************************************
  13662. * ScrollView
  13663. *****************************************************/
  13664. export module ScrollView {
  13665. /** !#en Enum for ScrollView event type.
  13666. !#zh 滚动视图事件类型 */
  13667. export enum EventType {
  13668. SCROLL_TO_TOP = 0,
  13669. SCROLL_TO_BOTTOM = 0,
  13670. SCROLL_TO_LEFT = 0,
  13671. SCROLL_TO_RIGHT = 0,
  13672. SCROLLING = 0,
  13673. BOUNCE_TOP = 0,
  13674. BOUNCE_BOTTOM = 0,
  13675. BOUNCE_LEFT = 0,
  13676. BOUNCE_RIGHT = 0,
  13677. SCROLL_ENDED = 0,
  13678. TOUCH_UP = 0,
  13679. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  13680. SCROLL_BEGAN = 0,
  13681. }
  13682. }
  13683. /****************************************************
  13684. * Slider
  13685. *****************************************************/
  13686. export module Slider {
  13687. /** !#en The Slider Direction
  13688. !#zh 滑动器方向 */
  13689. export enum Direction {
  13690. Horizontal = 0,
  13691. Vertical = 0,
  13692. }
  13693. }
  13694. /****************************************************
  13695. * Sprite
  13696. *****************************************************/
  13697. export module Sprite {
  13698. /** !#en Enum for sprite type.
  13699. !#zh Sprite 类型 */
  13700. export enum Type {
  13701. SIMPLE = 0,
  13702. SLICED = 0,
  13703. TILED = 0,
  13704. FILLED = 0,
  13705. }
  13706. }
  13707. /****************************************************
  13708. * Sprite
  13709. *****************************************************/
  13710. export module Sprite {
  13711. /** !#en Enum for fill type.
  13712. !#zh 填充类型 */
  13713. export enum FillType {
  13714. HORIZONTAL = 0,
  13715. VERTICAL = 0,
  13716. RADIAL = 0,
  13717. }
  13718. }
  13719. /****************************************************
  13720. * Sprite
  13721. *****************************************************/
  13722. export module Sprite {
  13723. /** !#en Sprite Size can track trimmed size, raw size or none.
  13724. !#zh 精灵尺寸调整模式 */
  13725. export enum SizeMode {
  13726. CUSTOM = 0,
  13727. TRIMMED = 0,
  13728. RAW = 0,
  13729. }
  13730. }
  13731. /****************************************************
  13732. * VideoPlayer
  13733. *****************************************************/
  13734. export module VideoPlayer {
  13735. /** !#en Video event type
  13736. !#zh 视频事件类型 */
  13737. export enum EventType {
  13738. PLAYING = 0,
  13739. PAUSED = 0,
  13740. STOPPED = 0,
  13741. COMPLETED = 0,
  13742. META_LOADED = 0,
  13743. CLICKED = 0,
  13744. READY_TO_PLAY = 0,
  13745. }
  13746. }
  13747. /****************************************************
  13748. * VideoPlayer
  13749. *****************************************************/
  13750. export module VideoPlayer {
  13751. /** !#en Enum for video resouce type type.
  13752. !#zh 视频来源 */
  13753. export enum ResourceType {
  13754. REMOTE = 0,
  13755. LOCAL = 0,
  13756. }
  13757. }
  13758. /****************************************************
  13759. * WebView
  13760. *****************************************************/
  13761. export module WebView {
  13762. /** !#en WebView event type
  13763. !#zh 网页视图事件类型 */
  13764. export enum EventType {
  13765. LOADED = 0,
  13766. LOADING = 0,
  13767. ERROR = 0,
  13768. }
  13769. }
  13770. /****************************************************
  13771. * Event
  13772. *****************************************************/
  13773. export module Event {
  13774. /** !#en The Custom event
  13775. !#zh 自定义事件 */
  13776. export class EventCustom extends Event {
  13777. /**
  13778. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  13779. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13780. */
  13781. constructor(type: string, bubbles: boolean);
  13782. /** !#en A reference to the detailed data of the event
  13783. !#zh 事件的详细数据 */
  13784. detail: any;
  13785. /**
  13786. !#en Sets user data
  13787. !#zh 设置用户数据
  13788. @param data data
  13789. */
  13790. setUserData(data: any): void;
  13791. /**
  13792. !#en Gets user data
  13793. !#zh 获取用户数据
  13794. */
  13795. getUserData(): any;
  13796. /**
  13797. !#en Gets event name
  13798. !#zh 获取事件名称
  13799. */
  13800. getEventName(): string;
  13801. /** !#en
  13802. The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. </br>
  13803. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.</br>
  13804. If the key can't be identified, this value is 0.</br>
  13805. !#zh
  13806. keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。</br>
  13807. 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。</br>
  13808. 如果无法识别该键,则该值为 0。 */
  13809. keyCode: number;
  13810. }
  13811. }
  13812. /****************************************************
  13813. * SystemEvent
  13814. *****************************************************/
  13815. export module SystemEvent {
  13816. /** !#en The event type supported by SystemEvent
  13817. !#zh SystemEvent 支持的事件类型 */
  13818. export class EventType {
  13819. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  13820. !#zh 当按下按键时触发的事件 */
  13821. static KEY_DOWN: string;
  13822. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  13823. !#zh 当松开按键时触发的事件 */
  13824. static KEY_UP: string;
  13825. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  13826. !#zh 重力感应 */
  13827. static DEVICEMOTION: string;
  13828. }
  13829. }
  13830. /****************************************************
  13831. * Event
  13832. *****************************************************/
  13833. export module Event {
  13834. /** !#en The mouse event
  13835. !#zh 鼠标事件类型 */
  13836. export class EventMouse extends Event {
  13837. /**
  13838. !#en Sets scroll data.
  13839. !#zh 设置鼠标的滚动数据。
  13840. @param scrollX scrollX
  13841. @param scrollY scrollY
  13842. */
  13843. setScrollData(scrollX: number, scrollY: number): void;
  13844. /**
  13845. !#en Returns the x axis scroll value.
  13846. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  13847. */
  13848. getScrollX(): number;
  13849. /**
  13850. !#en Returns the y axis scroll value.
  13851. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  13852. */
  13853. getScrollY(): number;
  13854. /**
  13855. !#en Sets cursor location.
  13856. !#zh 设置当前鼠标位置。
  13857. @param x x
  13858. @param y y
  13859. */
  13860. setLocation(x: number, y: number): void;
  13861. /**
  13862. !#en Returns cursor location.
  13863. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  13864. */
  13865. getLocation(): Vec2;
  13866. /**
  13867. !#en Returns the current cursor location in screen coordinates.
  13868. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  13869. */
  13870. getLocationInView(): Vec2;
  13871. /**
  13872. !#en Returns the previous touch location.
  13873. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  13874. */
  13875. getPreviousLocation(): Vec2;
  13876. /**
  13877. !#en Returns the delta distance from the previous location to current location.
  13878. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  13879. */
  13880. getDelta(): Vec2;
  13881. /**
  13882. !#en Returns the X axis delta distance from the previous location to current location.
  13883. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  13884. */
  13885. getDeltaX(): number;
  13886. /**
  13887. !#en Returns the Y axis delta distance from the previous location to current location.
  13888. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  13889. */
  13890. getDeltaY(): number;
  13891. /**
  13892. !#en Sets mouse button.
  13893. !#zh 设置鼠标按键。
  13894. @param button button
  13895. */
  13896. setButton(button: number): void;
  13897. /**
  13898. !#en Returns mouse button.
  13899. !#zh 获取鼠标按键。
  13900. */
  13901. getButton(): number;
  13902. /**
  13903. !#en Returns location X axis data.
  13904. !#zh 获取鼠标当前位置 X 轴。
  13905. */
  13906. getLocationX(): number;
  13907. /**
  13908. !#en Returns location Y axis data.
  13909. !#zh 获取鼠标当前位置 Y 轴。
  13910. */
  13911. getLocationY(): number;
  13912. /** !#en The none event code of mouse event.
  13913. !#zh 无。 */
  13914. static NONE: number;
  13915. /** !#en The event type code of mouse down event.
  13916. !#zh 鼠标按下事件。 */
  13917. static DOWN: number;
  13918. /** !#en The event type code of mouse up event.
  13919. !#zh 鼠标按下后释放事件。 */
  13920. static UP: number;
  13921. /** !#en The event type code of mouse move event.
  13922. !#zh 鼠标移动事件。 */
  13923. static MOVE: number;
  13924. /** !#en The event type code of mouse scroll event.
  13925. !#zh 鼠标滚轮事件。 */
  13926. static SCROLL: number;
  13927. /** !#en The tag of Mouse left button.
  13928. !#zh 鼠标左键的标签。 */
  13929. static BUTTON_LEFT: number;
  13930. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  13931. !#zh 鼠标右键的标签。 */
  13932. static BUTTON_RIGHT: number;
  13933. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  13934. !#zh 鼠标中键的标签。 */
  13935. static BUTTON_MIDDLE: number;
  13936. /** !#en The tag of Mouse button 4.
  13937. !#zh 鼠标按键 4 的标签。 */
  13938. static BUTTON_4: number;
  13939. /** !#en The tag of Mouse button 5.
  13940. !#zh 鼠标按键 5 的标签。 */
  13941. static BUTTON_5: number;
  13942. /** !#en The tag of Mouse button 6.
  13943. !#zh 鼠标按键 6 的标签。 */
  13944. static BUTTON_6: number;
  13945. /** !#en The tag of Mouse button 7.
  13946. !#zh 鼠标按键 7 的标签。 */
  13947. static BUTTON_7: number;
  13948. /** !#en The tag of Mouse button 8.
  13949. !#zh 鼠标按键 8 的标签。 */
  13950. static BUTTON_8: number;
  13951. }
  13952. }
  13953. /****************************************************
  13954. * Event
  13955. *****************************************************/
  13956. export module Event {
  13957. /** !#en The touch event
  13958. !#zh 触摸事件 */
  13959. export class EventTouch extends Event {
  13960. /**
  13961. @param touchArr The array of the touches
  13962. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13963. */
  13964. constructor(touchArr: any[], bubbles: boolean);
  13965. /** !#en The current touch object
  13966. !#zh 当前触点对象 */
  13967. touch: Touch;
  13968. /**
  13969. !#en Returns event code.
  13970. !#zh 获取事件类型。
  13971. */
  13972. getEventCode(): number;
  13973. /**
  13974. !#en Returns touches of event.
  13975. !#zh 获取触摸点的列表。
  13976. */
  13977. getTouches(): any[];
  13978. /**
  13979. !#en Sets touch location.
  13980. !#zh 设置当前触点位置
  13981. @param x x
  13982. @param y y
  13983. */
  13984. setLocation(x: number, y: number): void;
  13985. /**
  13986. !#en Returns touch location.
  13987. !#zh 获取触点位置。
  13988. */
  13989. getLocation(): Vec2;
  13990. /**
  13991. !#en Returns the current touch location in screen coordinates.
  13992. !#zh 获取当前触点在游戏窗口中的位置。
  13993. */
  13994. getLocationInView(): Vec2;
  13995. /**
  13996. !#en Returns the previous touch location.
  13997. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  13998. */
  13999. getPreviousLocation(): Vec2;
  14000. /**
  14001. !#en Returns the start touch location.
  14002. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  14003. */
  14004. getStartLocation(): Vec2;
  14005. /**
  14006. !#en Returns the id of cc.Touch.
  14007. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  14008. */
  14009. getID(): number;
  14010. /**
  14011. !#en Returns the delta distance from the previous location to current location.
  14012. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14013. */
  14014. getDelta(): Vec2;
  14015. /**
  14016. !#en Returns the X axis delta distance from the previous location to current location.
  14017. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  14018. */
  14019. getDeltaX(): number;
  14020. /**
  14021. !#en Returns the Y axis delta distance from the previous location to current location.
  14022. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  14023. */
  14024. getDeltaY(): number;
  14025. /**
  14026. !#en Returns location X axis data.
  14027. !#zh 获取当前触点 X 轴位置。
  14028. */
  14029. getLocationX(): number;
  14030. /**
  14031. !#en Returns location Y axis data.
  14032. !#zh 获取当前触点 Y 轴位置。
  14033. */
  14034. getLocationY(): number;
  14035. }
  14036. }
  14037. /****************************************************
  14038. * Event
  14039. *****************************************************/
  14040. export module Event {
  14041. /** !#en The acceleration event
  14042. !#zh 加速度事件 */
  14043. export class EventAcceleration extends Event {
  14044. }
  14045. }
  14046. /****************************************************
  14047. * Event
  14048. *****************************************************/
  14049. export module Event {
  14050. /** !#en The keyboard event
  14051. !#zh 键盘事件 */
  14052. export class EventKeyboard extends Event {
  14053. }
  14054. }
  14055. /****************************************************
  14056. * Graphics
  14057. *****************************************************/
  14058. export module Graphics {
  14059. /** !#en Enum for LineCap.
  14060. !#zh 线段末端属性 */
  14061. export enum LineCap {
  14062. BUTT = 0,
  14063. ROUND = 0,
  14064. SQUARE = 0,
  14065. }
  14066. }
  14067. /****************************************************
  14068. * Graphics
  14069. *****************************************************/
  14070. export module Graphics {
  14071. /** !#en Enum for LineJoin.
  14072. !#zh 线段拐角属性 */
  14073. export enum LineJoin {
  14074. BEVEL = 0,
  14075. ROUND = 0,
  14076. MITER = 0,
  14077. }
  14078. }
  14079. /****************************************************
  14080. * Pipeline
  14081. *****************************************************/
  14082. export module Pipeline {
  14083. /** The downloader pipe, it can download several types of files:
  14084. 1. Text
  14085. 2. Image
  14086. 3. Script
  14087. 4. Audio
  14088. 5. Assets
  14089. All unknown type will be downloaded as plain text.
  14090. You can pass custom supported types in the constructor. */
  14091. export class Downloader {
  14092. /**
  14093. Constructor of Downloader, you can pass custom supported types.
  14094. @param extMap Custom supported types with corresponded handler
  14095. @example
  14096. ```js
  14097. var downloader = new Downloader({
  14098. // This will match all url with `.scene` extension or all url with `scene` type
  14099. 'scene' : function (url, callback) {}
  14100. });
  14101. ```
  14102. */
  14103. constructor(extMap: any);
  14104. /**
  14105. Add custom supported types handler or modify existing type handler.
  14106. @param extMap Custom supported types with corresponded handler
  14107. */
  14108. addHandlers(extMap: any): void;
  14109. }
  14110. }
  14111. /****************************************************
  14112. * Pipeline
  14113. *****************************************************/
  14114. export module Pipeline {
  14115. /** The loader pipe, it can load several types of files:
  14116. 1. Images
  14117. 2. JSON
  14118. 3. Plist
  14119. 4. Audio
  14120. 5. Font
  14121. 6. Cocos Creator scene
  14122. It will not interfere with items of unknown type.
  14123. You can pass custom supported types in the constructor. */
  14124. export class Loader {
  14125. /**
  14126. Constructor of Loader, you can pass custom supported types.
  14127. @param extMap Custom supported types with corresponded handler
  14128. @example
  14129. ```js
  14130. var loader = new Loader({
  14131. // This will match all url with `.scene` extension or all url with `scene` type
  14132. 'scene' : function (url, callback) {}
  14133. });
  14134. ```
  14135. */
  14136. constructor(extMap: any);
  14137. /**
  14138. Add custom supported types handler or modify existing type handler.
  14139. @param extMap Custom supported types with corresponded handler
  14140. */
  14141. addHandlers(extMap: any): void;
  14142. }
  14143. }
  14144. /****************************************************
  14145. * LoadingItems
  14146. *****************************************************/
  14147. export module LoadingItems {
  14148. /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR
  14149. !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */
  14150. export enum ItemState {
  14151. WORKING = 0,
  14152. COMPLETET = 0,
  14153. ERROR = 0,
  14154. }
  14155. }
  14156. /****************************************************
  14157. * Texture2D
  14158. *****************************************************/
  14159. export module Texture2D {
  14160. /** The texture pixel format, default value is RGBA8888 */
  14161. export enum PixelFormat {
  14162. RGB565 = 0,
  14163. RGB5A1 = 0,
  14164. RGBA4444 = 0,
  14165. RGB888 = 0,
  14166. RGBA8888 = 0,
  14167. A8 = 0,
  14168. I8 = 0,
  14169. AI88 = 0,
  14170. }
  14171. }
  14172. /****************************************************
  14173. * Texture2D
  14174. *****************************************************/
  14175. export module Texture2D {
  14176. /** The texture wrap mode */
  14177. export enum WrapMode {
  14178. REPEAT = 0,
  14179. CLAMP_TO_EDGE = 0,
  14180. MIRRORED_REPEAT = 0,
  14181. }
  14182. }
  14183. /****************************************************
  14184. * Texture2D
  14185. *****************************************************/
  14186. export module Texture2D {
  14187. /** The texture filter mode */
  14188. export enum Filter {
  14189. LINEAR = 0,
  14190. NEAREST = 0,
  14191. }
  14192. }
  14193. }
  14194. /** !#en
  14195. 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.
  14196. !#zh
  14197. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  14198. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  14199. declare module anysdk {
  14200. /** !#en
  14201. agent manager of plugin
  14202. !#zh
  14203. 插件管理对象 */
  14204. export var agentManager: anysdk.AgentManager;
  14205. /** !#en
  14206. agent manager of plugin
  14207. !#zh
  14208. 插件管理类 */
  14209. export class AgentManager {
  14210. /**
  14211. !#en
  14212. AppKey appSecret and privateKey are the only three parameters generated
  14213. after the packing tool client finishes creating the game.
  14214. The oauthLoginServer parameter is the API address provided by the game service
  14215. to login verification
  14216. !#zh
  14217. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  14218. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  14219. @param appKey appKey
  14220. @param appSecret appSecret
  14221. @param privateKey privateKey
  14222. @param oauthLoginServer oauthLoginServer
  14223. */
  14224. init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void;
  14225. /**
  14226. !#en
  14227. load all plugins, the operation includes SDK`s initialization
  14228. !#zh
  14229. 加载所有插件,该操作包含了 SDKs 初始化
  14230. @param callback callback
  14231. @param target The object to bind to.
  14232. */
  14233. loadAllPlugins(callback: Function, target: any): void;
  14234. /**
  14235. !#en
  14236. unload all plugins
  14237. !#zh
  14238. 卸载插件
  14239. */
  14240. unloadAllPlugins(): void;
  14241. /**
  14242. !#en
  14243. get user system plugin
  14244. !#zh
  14245. 获取用户系统插件
  14246. */
  14247. getUserPlugin(): anysdk.ProtocolUser;
  14248. /**
  14249. !#en
  14250. get IAP system plugins
  14251. !#zh
  14252. 获取支付系统插件
  14253. */
  14254. getIAPPlugins(): anysdk.ProtocolIAP[];
  14255. /**
  14256. !#en
  14257. get IAP system plugin
  14258. !#zh
  14259. 获取支付系统插件
  14260. */
  14261. getIAPPlugin(): anysdk.ProtocolIAP;
  14262. /**
  14263. !#en
  14264. get social system plugin
  14265. !#zh
  14266. 获取社交系统插件
  14267. */
  14268. getSocialPlugin(): anysdk.ProtocolSocial;
  14269. /**
  14270. !#en
  14271. get share system plugin
  14272. !#zh
  14273. 获取分享系统插件
  14274. */
  14275. getSharePlugin(): anysdk.ProtocolShare;
  14276. /**
  14277. !#en
  14278. get analytics system plugin
  14279. !#zh
  14280. 获取统计系统插件
  14281. */
  14282. getAnalyticsPlugin(): anysdk.ProtocolAnalytics;
  14283. /**
  14284. !#en
  14285. get ads system plugin
  14286. !#zh
  14287. 获取广告系统插件
  14288. */
  14289. getAdsPlugin(): anysdk.ProtocolAds;
  14290. /**
  14291. !#en
  14292. get push system plugin
  14293. !#zh
  14294. 获取推送系统插件
  14295. */
  14296. getPushPlugin(): anysdk.ProtocolPush;
  14297. /**
  14298. !#en
  14299. get REC system plugin
  14300. !#zh
  14301. 获取录屏系统插件
  14302. */
  14303. getRECPlugin(): anysdk.ProtocolREC;
  14304. /**
  14305. !#en
  14306. get crash system plugin
  14307. !#zh
  14308. 获取崩溃分析系统插件
  14309. */
  14310. getCrashPlugin(): anysdk.ProtocolCrash;
  14311. /**
  14312. !#en
  14313. get ad track system plugin
  14314. !#zh
  14315. 获取广告追踪系统插件
  14316. */
  14317. getAdTrackingPlugin(): anysdk.ProtocolAdTracking;
  14318. /**
  14319. !#en
  14320. get custom system plugin
  14321. !#zh
  14322. 获取自定义系统插件
  14323. */
  14324. getCustomPlugin(): anysdk.ProtocolCustom;
  14325. /**
  14326. !#en
  14327. get custom parameter
  14328. !#zh
  14329. 获取自定义参数
  14330. */
  14331. getCustomParam(): string;
  14332. /**
  14333. !#en
  14334. get channel id
  14335. !#zh
  14336. 获取渠道唯一表示符
  14337. */
  14338. getChannelId(): string;
  14339. /**
  14340. !#en
  14341. get status of analytics
  14342. !#zh
  14343. 获取统计状态
  14344. */
  14345. isAnaylticsEnabled(): boolean;
  14346. /**
  14347. !#en
  14348. set whether to analytics
  14349. !#zh
  14350. 设置是否统计
  14351. @param enabled enabled
  14352. */
  14353. setIsAnaylticsEnabled(enabled: boolean): void;
  14354. /**
  14355. !#en
  14356. destory instance
  14357. !#zh
  14358. 销毁单例
  14359. */
  14360. static end(): void;
  14361. /**
  14362. !#en
  14363. get instance
  14364. !#zh
  14365. 获取单例
  14366. */
  14367. static getInstance(): anysdk.AgentManager;
  14368. }
  14369. /** !#en
  14370. plugin protocol
  14371. !#zh
  14372. 插件协议 */
  14373. export class PluginProtocol {
  14374. /**
  14375. !#en
  14376. Check whether the function is supported
  14377. !#zh
  14378. 判断函数是否支持
  14379. @param functionName functionName
  14380. */
  14381. isFunctionSupported(functionName: string): boolean;
  14382. /**
  14383. !#en
  14384. get plugin name
  14385. !#zh
  14386. 获取插件名称
  14387. */
  14388. getPluginName(): string;
  14389. /**
  14390. !#en
  14391. get plugin version
  14392. !#zh
  14393. 获取插件版本
  14394. */
  14395. getPluginVersion(): string;
  14396. /**
  14397. !#en
  14398. get SDK version
  14399. !#zh
  14400. 获取 SDK 版本
  14401. */
  14402. getSDKVersion(): string;
  14403. /**
  14404. !#en
  14405. void methods for reflections with parameter
  14406. !#zh
  14407. 反射调用带参数的void方法
  14408. @param funName funName
  14409. @param args optional arguments
  14410. */
  14411. callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void;
  14412. /**
  14413. !#en
  14414. String methods for reflections with parameter
  14415. !#zh
  14416. 反射调用带参数的 String 方法
  14417. @param funName funName
  14418. @param args optional arguments
  14419. */
  14420. callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string;
  14421. /**
  14422. !#en
  14423. int methods for reflections with parameter
  14424. !#zh
  14425. 反射调用带参数的 Int 方法
  14426. @param funName funName
  14427. @param args optional arguments
  14428. */
  14429. callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14430. /**
  14431. !#en
  14432. boolean methods for reflections with parameter
  14433. !#zh
  14434. 反射调用带参数的 boolean 方法
  14435. @param funName funName
  14436. @param args optional arguments
  14437. */
  14438. callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean;
  14439. /**
  14440. !#en
  14441. float methods for reflections with parameter
  14442. !#zh
  14443. 反射调用带参数的 float 方法
  14444. @param funName funName
  14445. @param args optional arguments
  14446. */
  14447. callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14448. }
  14449. /** !#en
  14450. user protocol
  14451. !#zh
  14452. 用户系统协议接口 */
  14453. export class ProtocolUser extends PluginProtocol {
  14454. /**
  14455. !#en
  14456. login interface
  14457. !#zh
  14458. 登录接口
  14459. @param args optional arguments
  14460. */
  14461. login(...args: string|any[]): void;
  14462. /**
  14463. !#en
  14464. get status of login
  14465. !#zh
  14466. 获取登录状态
  14467. */
  14468. isLogined(): boolean;
  14469. /**
  14470. !#en
  14471. get user ID
  14472. !#zh
  14473. 获取用户唯一标示符
  14474. */
  14475. getUserID(): string;
  14476. /**
  14477. !#en
  14478. get plugin ID
  14479. !#zh
  14480. 获取插件ID
  14481. */
  14482. getPluginId(): string;
  14483. /**
  14484. !#en
  14485. set listener
  14486. !#zh
  14487. 设置用户系统的监听
  14488. @param listener listener
  14489. @param target target
  14490. */
  14491. setListener(listener: Function, target: any): void;
  14492. /**
  14493. !#en
  14494. get listener
  14495. !#zh
  14496. 获取用户系统的监听
  14497. */
  14498. getListener(): Function;
  14499. /**
  14500. !#en
  14501. logout
  14502. Before to invoke, you need to verdict whether this properties existed
  14503. !#zh
  14504. 登出,调用前需要判断属性是否存在
  14505. */
  14506. logout(): void;
  14507. /**
  14508. !#en
  14509. show toolbar
  14510. Before to invoke, you need to verdict whether this properties existed
  14511. !#zh
  14512. 显示悬浮窗,调用前需要判断属性是否存在
  14513. @param place place
  14514. */
  14515. showToolBar(place: anysdk.ToolBarPlace): void;
  14516. /**
  14517. !#en
  14518. hide toolbar
  14519. Before to invoke, you need to verdict whether this properties existed
  14520. !#zh
  14521. 隐藏悬浮窗,调用前需要判断属性是否存在
  14522. */
  14523. hideToolBar(): void;
  14524. /**
  14525. !#en
  14526. enter platform
  14527. Before to invoke, you need to verdict whether this properties existed
  14528. !#zh
  14529. 显示平台中心,调用前需要判断属性是否存在
  14530. */
  14531. enterPlatform(): void;
  14532. /**
  14533. !#en
  14534. show exit page
  14535. Before to invoke, you need to verdict whether this properties existed
  14536. !#zh
  14537. 显示退出界面,调用前需要判断属性是否存在
  14538. */
  14539. exit(): void;
  14540. /**
  14541. !#en
  14542. show pause page
  14543. Before to invoke, you need to verdict whether this properties existed
  14544. !#zh
  14545. 显示暂停界面,调用前需要判断属性是否存在
  14546. */
  14547. pause(): void;
  14548. /**
  14549. !#en
  14550. Real-name registration
  14551. Before to invoke, you need to verdict whether this properties existed
  14552. !#zh
  14553. 实名注册,调用前需要判断属性是否存在
  14554. */
  14555. realNameRegister(): void;
  14556. /**
  14557. !#en
  14558. Anti-addiction query
  14559. Before to invoke, you need to verdict whether this properties existed
  14560. !#zh
  14561. 防沉迷查询,调用前需要判断属性是否存在
  14562. */
  14563. antiAddictionQuery(): void;
  14564. /**
  14565. !#en
  14566. submit game role information
  14567. Before to invoke, you need to verdict whether this properties existed
  14568. !#zh
  14569. 提交角色信息,调用前需要判断属性是否存在
  14570. @param data data
  14571. */
  14572. submitLoginGameRole(data: any): void;
  14573. /**
  14574. !#en
  14575. get user information
  14576. Before to invoke, you need to verdict whether this properties existed
  14577. !#zh
  14578. 获取用户信息,调用前需要判断属性是否存在
  14579. @param info info
  14580. */
  14581. getUserInfo(info: any): void;
  14582. /**
  14583. !#en
  14584. set login type
  14585. Before to invoke, you need to verdict whether this properties existed
  14586. !#zh
  14587. 设置登录类型,调用前需要判断属性是否存在
  14588. @param info info
  14589. */
  14590. getAvailableLoginType(info: any): void;
  14591. /**
  14592. !#en
  14593. set login type
  14594. Before to invoke, you need to verdict whether this properties existed
  14595. !#zh
  14596. 设置登录类型,调用前需要判断属性是否存在
  14597. @param loginType loginType
  14598. */
  14599. setLoginType(loginType: string): void;
  14600. /**
  14601. !#en
  14602. send to desktop
  14603. Before to invoke, you need to verdict whether this properties existed
  14604. !#zh
  14605. 发送到桌面,调用前需要判断属性是否存在
  14606. */
  14607. sendToDesktop(): void;
  14608. /**
  14609. !#en
  14610. open bbs
  14611. Before to invoke, you need to verdict whether this properties existed
  14612. !#zh
  14613. 打开论坛,调用前需要判断属性是否存在
  14614. */
  14615. openBBS(): void;
  14616. }
  14617. /** !#en
  14618. IAP protocol
  14619. !#zh
  14620. 支付系统协议接口 */
  14621. export class ProtocolIAP extends PluginProtocol {
  14622. /**
  14623. !#en
  14624. pay interface
  14625. !#zh
  14626. 支付接口
  14627. @param info Type:map
  14628. */
  14629. payForProduct(info: any): void;
  14630. /**
  14631. !#en
  14632. get order ID
  14633. !#zh
  14634. 获取订单ID
  14635. */
  14636. getOrderId(): string;
  14637. /**
  14638. !#en
  14639. reset the pay status
  14640. !#zh
  14641. 重置支付状态
  14642. */
  14643. static resetPayState(): void;
  14644. /**
  14645. !#en
  14646. get plugin ID
  14647. !#zh
  14648. 获取插件ID
  14649. */
  14650. getPluginId(): string;
  14651. /**
  14652. !#en
  14653. set listener
  14654. !#zh
  14655. 设置支付系统的监听
  14656. @param listener listener
  14657. @param target target
  14658. */
  14659. setListener(listener: Function, target: any): void;
  14660. /**
  14661. !#en
  14662. get listener
  14663. !#zh
  14664. 获取支付系统的监听
  14665. */
  14666. getListener(): Function;
  14667. }
  14668. /** !#en
  14669. analytics protocol
  14670. !#zh
  14671. 统计系统协议接口 */
  14672. export class ProtocolAnalytics extends PluginProtocol {
  14673. /**
  14674. !#en
  14675. Start a new session.
  14676. !#zh
  14677. 启动会话
  14678. */
  14679. startSession(): void;
  14680. /**
  14681. !#en
  14682. Stop a session.
  14683. !#zh
  14684. 关闭会话
  14685. */
  14686. stopSession(): void;
  14687. /**
  14688. !#en
  14689. Set the timeout for expiring a session.
  14690. !#zh
  14691. 设置会话超时时间
  14692. @param millis Type: long
  14693. */
  14694. setSessionContinueMillis(millis: number): void;
  14695. /**
  14696. !#en
  14697. log an error
  14698. !#zh
  14699. 捕捉异常
  14700. @param errorId errorId
  14701. @param message message
  14702. */
  14703. logError(errorId: string, message: string): void;
  14704. /**
  14705. !#en
  14706. log an event.
  14707. !#zh
  14708. 捕捉事件
  14709. @param errorId errorId
  14710. @param args optional arguments Type: map
  14711. */
  14712. logEvent(errorId: string, ...args: any[]): void;
  14713. /**
  14714. !#en
  14715. Track an event begin.
  14716. !#zh
  14717. 统计事件开始
  14718. @param eventId eventId
  14719. */
  14720. logTimedEventBegin(eventId: string): void;
  14721. /**
  14722. !#en
  14723. Track an event end.
  14724. !#zh
  14725. 统计事件结束
  14726. @param eventId eventId
  14727. */
  14728. logTimedEventEnd(eventId: string): void;
  14729. /**
  14730. !#en
  14731. set Whether to catch uncaught exceptions to server.
  14732. !#zh
  14733. 设置是否开启自动异常捕捉
  14734. @param enabled enabled
  14735. */
  14736. setCaptureUncaughtException(enabled: boolean): void;
  14737. /**
  14738. !#en
  14739. analytics account information
  14740. !#zh
  14741. 统计玩家帐户信息
  14742. @param paramMap Type: map
  14743. */
  14744. setAccount(paramMap: any): void;
  14745. /**
  14746. !#en
  14747. track user to request payment
  14748. !#zh
  14749. 跟踪用户支付请求
  14750. @param paramMap Type: map
  14751. */
  14752. onChargeRequest(paramMap: any): void;
  14753. /**
  14754. !#en
  14755. track Successful payment
  14756. !#zh
  14757. 追踪用户支付成功
  14758. @param orderID orderID
  14759. */
  14760. onChargeSuccess(orderID: string): void;
  14761. /**
  14762. !#en
  14763. track failed payment
  14764. !#zh
  14765. 追踪用户支付失败
  14766. @param paramMap Type: map
  14767. */
  14768. onChargeFail(paramMap: any): void;
  14769. /**
  14770. !#en
  14771. track Successful payment
  14772. !#zh
  14773. 统计玩家支付成功
  14774. @param paramMap Type: map
  14775. */
  14776. onChargeOnlySuccess(paramMap: any): void;
  14777. /**
  14778. !#en
  14779. track user purchase
  14780. !#zh
  14781. 统计玩家消费
  14782. @param paramMap Type: map
  14783. */
  14784. onPurchase(paramMap: any): void;
  14785. /**
  14786. !#en
  14787. track user to use goods
  14788. !#zh
  14789. 统计玩家使用道具
  14790. @param paramMap Type: map
  14791. */
  14792. onUse(paramMap: any): void;
  14793. /**
  14794. !#en
  14795. track user to reward goods
  14796. !#zh
  14797. 统计玩家获取奖励
  14798. @param paramMap Type: map
  14799. */
  14800. onReward(paramMap: any): void;
  14801. /**
  14802. !#en
  14803. start level
  14804. !#zh
  14805. 开始关卡
  14806. @param paramMap Type: map
  14807. */
  14808. startLevel(paramMap: any): void;
  14809. /**
  14810. !#en
  14811. finish level
  14812. !#zh
  14813. 结束关卡
  14814. @param levelID levelID
  14815. */
  14816. finishLevel(levelID: string): void;
  14817. /**
  14818. !#en
  14819. failed level
  14820. !#zh
  14821. 关卡失败
  14822. @param paramMap Type: map
  14823. */
  14824. failLevel(paramMap: any): void;
  14825. /**
  14826. !#en
  14827. start task
  14828. !#zh
  14829. 开始任务
  14830. @param paramMap Type: map
  14831. */
  14832. startTask(paramMap: any): void;
  14833. /**
  14834. !#en
  14835. finish task
  14836. !#zh
  14837. 完成任务
  14838. @param taskID taskID
  14839. */
  14840. finishTask(taskID: string): void;
  14841. /**
  14842. !#en
  14843. failed task
  14844. !#zh
  14845. 任务失败
  14846. @param paramMap Type: map
  14847. */
  14848. failTask(paramMap: any): void;
  14849. }
  14850. /** !#en
  14851. share protocol
  14852. !#zh
  14853. 分享系统协议接口 */
  14854. export class ProtocolShare extends PluginProtocol {
  14855. /**
  14856. !#en
  14857. share interface
  14858. !#zh
  14859. 分享
  14860. @param info Type: map
  14861. */
  14862. share(info: any): void;
  14863. /**
  14864. !#en
  14865. set listener
  14866. !#zh
  14867. 设置分享系统的监听
  14868. @param listener listener
  14869. @param target target
  14870. */
  14871. setListener(listener: Function, target: any): void;
  14872. /**
  14873. !#en
  14874. get listener
  14875. !#zh
  14876. 获取分享系统的监听
  14877. */
  14878. getListener(): Function;
  14879. }
  14880. /** !#en
  14881. ads protocol
  14882. !#zh
  14883. 广告系统协议接口 */
  14884. export class ProtocolAds extends PluginProtocol {
  14885. /**
  14886. !#en
  14887. hide ads view
  14888. !#zh
  14889. 隐藏广告
  14890. @param adstype adstype
  14891. @param idx idx
  14892. */
  14893. hideAds(adstype: anysdk.AdsType, idx: number): void;
  14894. /**
  14895. !#en
  14896. preload ads view
  14897. !#zh
  14898. 预加载广告
  14899. @param adstype adstype
  14900. @param idx idx
  14901. */
  14902. preloadAds(adstype: anysdk.AdsType, idx: number): void;
  14903. /**
  14904. !#en
  14905. query points
  14906. !#zh
  14907. 查询分数
  14908. */
  14909. queryPoints(): number;
  14910. /**
  14911. !#en
  14912. get whether the ads type is supported
  14913. !#zh
  14914. 获取广告类型是否支持
  14915. @param arg0 arg0
  14916. */
  14917. isAdTypeSupported(arg0: anysdk.AdsType): boolean;
  14918. /**
  14919. !#en
  14920. spend point
  14921. !#zh
  14922. 消费分数
  14923. @param points points
  14924. */
  14925. spendPoints(points: number): void;
  14926. /**
  14927. !#en
  14928. set listener
  14929. !#zh
  14930. 设置广告系统的监听
  14931. @param listener listener
  14932. @param target target
  14933. */
  14934. setListener(listener: Function, target: any): void;
  14935. /**
  14936. !#en
  14937. get listener
  14938. !#zh
  14939. 获取广告系统的监听
  14940. */
  14941. getListener(): Function;
  14942. }
  14943. /** !#en
  14944. social protocol
  14945. !#zh
  14946. 社交系统协议接口 */
  14947. export class ProtocolSocial extends PluginProtocol {
  14948. /**
  14949. !#en
  14950. sign in
  14951. !#zh
  14952. 登录
  14953. */
  14954. signIn(): void;
  14955. /**
  14956. !#en
  14957. sign out
  14958. !#zh
  14959. 登出
  14960. */
  14961. signOut(): void;
  14962. /**
  14963. !#en
  14964. submit score
  14965. !#zh
  14966. 提交分数
  14967. @param leadboardID leadboardID
  14968. @param score Type: long
  14969. */
  14970. submitScore(leadboardID: string, score: number): void;
  14971. /**
  14972. !#en
  14973. show the id of Leaderboard page
  14974. !#zh
  14975. 根据唯一标识符显示排行榜
  14976. @param leaderboardID leaderboardID
  14977. */
  14978. showLeaderboard(leaderboardID: string): void;
  14979. /**
  14980. !#en
  14981. show the page of achievements
  14982. !#zh
  14983. 显示成就榜
  14984. */
  14985. showAchievements(): void;
  14986. /**
  14987. !#en
  14988. unlock achievement
  14989. !#zh
  14990. 解锁成就
  14991. @param info Type: map
  14992. */
  14993. share(info: any): void;
  14994. /**
  14995. !#en
  14996. set listener
  14997. !#zh
  14998. 设置社交系统的监听
  14999. @param listener listener
  15000. @param target target
  15001. */
  15002. setListener(listener: Function, target: any): void;
  15003. /**
  15004. !#en
  15005. get listener
  15006. !#zh
  15007. 获取社交系统的监听
  15008. */
  15009. getListener(): Function;
  15010. /**
  15011. !#en
  15012. get friends info
  15013. Before to invoke, you need to verdict whether this properties existed
  15014. !#zh
  15015. 获取好友信息,调用前需要判断属性是否存在
  15016. */
  15017. pauseRecording(): void;
  15018. /**
  15019. !#en
  15020. interact
  15021. Before to invoke, you need to verdict whether this properties existed
  15022. !#zh
  15023. 订阅,调用前需要判断属性是否存在
  15024. */
  15025. interact(): void;
  15026. /**
  15027. !#en
  15028. subscribe
  15029. Before to invoke, you need to verdict whether this properties existed
  15030. !#zh
  15031. 关注,调用前需要判断属性是否存在
  15032. */
  15033. subscribe(): void;
  15034. }
  15035. /** !#en
  15036. push protocol
  15037. !#zh
  15038. 推送系统协议接口 */
  15039. export class ProtocolPush extends PluginProtocol {
  15040. /**
  15041. !#en
  15042. start Push services
  15043. !#zh
  15044. 启动推送服务
  15045. */
  15046. startPush(): void;
  15047. /**
  15048. !#en
  15049. close Push services
  15050. !#zh
  15051. 暂停推送服务
  15052. */
  15053. closePush(): void;
  15054. /**
  15055. !#en
  15056. delete alias
  15057. !#zh
  15058. 删除别名
  15059. @param alias alias
  15060. */
  15061. delAlias(alias: string): void;
  15062. /**
  15063. !#en
  15064. set alias
  15065. !#zh
  15066. 设置别名
  15067. @param alias alias
  15068. */
  15069. setAlias(alias: string): void;
  15070. /**
  15071. !#en
  15072. delete tags
  15073. !#zh
  15074. 删除标签
  15075. @param tags Type: list
  15076. */
  15077. delTags(tags: any): void;
  15078. /**
  15079. !#en
  15080. set tags
  15081. !#zh
  15082. 设置标签
  15083. @param tags Type: list
  15084. */
  15085. setTags(tags: any): void;
  15086. /**
  15087. !#en
  15088. set listener
  15089. !#zh
  15090. 设置推送系统的监听
  15091. @param listener listener
  15092. @param target target
  15093. */
  15094. setListener(listener: Function, target: any): void;
  15095. /**
  15096. !#en
  15097. get listener
  15098. !#zh
  15099. 获取推送系统的监听
  15100. */
  15101. getListener(): Function;
  15102. }
  15103. /** !#en
  15104. crash protocol
  15105. !#zh
  15106. 崩溃分析系统协议接口 */
  15107. export class ProtocolCrash extends PluginProtocol {
  15108. /**
  15109. !#en
  15110. set user identifier
  15111. !#zh
  15112. 统计用户唯一标识符
  15113. @param identifier identifier
  15114. */
  15115. setUserIdentifier(identifier: string): void;
  15116. /**
  15117. !#en
  15118. The uploader captured in exception information
  15119. !#zh
  15120. 上报异常信息
  15121. @param message message
  15122. @param exception exception
  15123. */
  15124. reportException(message: string, exception: string): void;
  15125. /**
  15126. !#en
  15127. customize logging
  15128. !#zh
  15129. 自定义日志记录
  15130. @param breadcrumb breadcrumb
  15131. */
  15132. leaveBreadcrumb(breadcrumb: string): void;
  15133. }
  15134. /** !#en
  15135. REC protocol
  15136. !#zh
  15137. 录屏系统协议接口 */
  15138. export class ProtocolREC extends PluginProtocol {
  15139. /**
  15140. !#en
  15141. share video
  15142. !#zh
  15143. 分享视频
  15144. @param info Type: map
  15145. */
  15146. share(info: any): void;
  15147. /**
  15148. !#en
  15149. Start to record video
  15150. !#zh
  15151. 开始录制视频
  15152. */
  15153. startRecording(): void;
  15154. /**
  15155. !#en
  15156. Start to record video
  15157. !#zh
  15158. 结束录制视频
  15159. */
  15160. stopRecording(): void;
  15161. /**
  15162. !#en
  15163. set listener
  15164. !#zh
  15165. 设置录屏系统的监听
  15166. @param listener listener
  15167. @param target target
  15168. */
  15169. setListener(listener: Function, target: any): void;
  15170. /**
  15171. !#en
  15172. get listener
  15173. !#zh
  15174. 获取录屏系统的监听
  15175. */
  15176. getListener(): Function;
  15177. /**
  15178. !#en
  15179. pause to record video
  15180. Before to invoke, you need to verdict whether this properties existed
  15181. !#zh
  15182. 暂停录制视频,调用前需要判断属性是否存在
  15183. */
  15184. pauseRecording(): void;
  15185. /**
  15186. !#en
  15187. resume to record video
  15188. Before to invoke, you need to verdict whether this properties existed
  15189. !#zh
  15190. 恢复录制视频,调用前需要判断属性是否存在
  15191. */
  15192. resumeRecording(): void;
  15193. /**
  15194. !#en
  15195. get whether the device is isAvailable
  15196. Before to invoke, you need to verdict whether this properties existed
  15197. !#zh
  15198. 获取设备是否可用,调用前需要判断属性是否存在
  15199. */
  15200. isAvailable(): boolean;
  15201. /**
  15202. !#en
  15203. get status of recording
  15204. Before to invoke, you need to verdict whether this properties existed
  15205. !#zh
  15206. 获取录制状态,调用前需要判断属性是否存在
  15207. */
  15208. isRecording(): boolean;
  15209. /**
  15210. !#en
  15211. show toolbar
  15212. Before to invoke, you need to verdict whether this properties existed
  15213. !#zh
  15214. 显示悬浮窗,调用前需要判断属性是否存在
  15215. */
  15216. showToolBar(): void;
  15217. /**
  15218. !#en
  15219. hide toolbar
  15220. Before to invoke, you need to verdict whether this properties existed
  15221. !#zh
  15222. 隐藏悬浮窗,调用前需要判断属性是否存在
  15223. */
  15224. hideToolBar(): void;
  15225. /**
  15226. !#en
  15227. show video center
  15228. Before to invoke, you need to verdict whether this properties existed
  15229. !#zh
  15230. 显示视频中心,调用前需要判断属性是否存在
  15231. */
  15232. showVideoCenter(): void;
  15233. /**
  15234. !#en
  15235. enter platform
  15236. Before to invoke, you need to verdict whether this properties existed
  15237. !#zh
  15238. 显示平台中心,调用前需要判断属性是否存在
  15239. */
  15240. enterPlatform(): void;
  15241. /**
  15242. !#en
  15243. Set the video data, it is recommended to check whether are recorded firstly
  15244. Before to invoke, you need to verdict whether this properties existed
  15245. !#zh
  15246. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  15247. @param info Type: map
  15248. */
  15249. setMetaData(info: any): void;
  15250. }
  15251. /** !#en
  15252. ad tracking protocol
  15253. !#zh
  15254. 广告追踪系统协议接口 */
  15255. export class ProtocolAdTracking extends PluginProtocol {
  15256. /**
  15257. !#en
  15258. Call this method if you want to track register events as happening during a section.
  15259. !#zh
  15260. 统计用户注册信息
  15261. @param productInfo Type: map
  15262. */
  15263. onPay(productInfo: any): void;
  15264. /**
  15265. !#en
  15266. Call this method if you want to track register events as happening during a section.
  15267. !#zh
  15268. 统计用户注册信息
  15269. @param userInfo Type: map
  15270. */
  15271. onLogin(userInfo: any): void;
  15272. /**
  15273. !#en
  15274. Call this method if you want to track register events as happening during a section.
  15275. !#zh
  15276. 统计用户注册信息
  15277. @param userId userId
  15278. */
  15279. onRegister(userId: string): void;
  15280. /**
  15281. !#en
  15282. Call this method if you want to track custom events with parameters as happening during a section.
  15283. !#zh
  15284. 统计自定义事件
  15285. @param eventId eventId
  15286. @param paramMap Type: map
  15287. */
  15288. trackEvent(eventId: string, paramMap: any): void;
  15289. /**
  15290. !#en
  15291. Call this method with parameters if you want to create role as happening during a section.
  15292. !#zh
  15293. 统计创建角色事件,调用前需要判断属性是否存在
  15294. @param userInfo Type: map
  15295. */
  15296. onCreateRole(userInfo: any): void;
  15297. /**
  15298. !#en
  15299. Call this method if you want to track levelup events with parameters as happening during a section.
  15300. Before to invoke, you need to verdict whether this properties existed
  15301. !#zh
  15302. 统计角色升级事件,调用前需要判断属性是否存在
  15303. @param info Type: map
  15304. */
  15305. onLevelUp(info: any): void;
  15306. /**
  15307. !#en
  15308. Invoke this method with parameters if you want to start to pay as happening during a section.
  15309. Before to invoke, you need to verdict whether this properties existed
  15310. !#zh
  15311. 统计开始充值事件,调用前需要判断属性是否存在
  15312. @param info Type: map
  15313. */
  15314. onStartToPay(info: any): void;
  15315. }
  15316. /** !#en
  15317. custom protocol
  15318. !#zh
  15319. 自定义系统协议接口 */
  15320. export class ProtocolCustom extends PluginProtocol {
  15321. /**
  15322. !#en
  15323. set listener
  15324. !#zh
  15325. 设置自定义系统的监听
  15326. @param listener listener
  15327. @param target target
  15328. */
  15329. setListener(listener: Function, target: any): void;
  15330. /**
  15331. !#en
  15332. get listener
  15333. !#zh
  15334. 获取自定义系统的监听
  15335. */
  15336. getListener(): Function;
  15337. }
  15338. /** !#en
  15339. Data structure class
  15340. !#zh
  15341. 数据结构类 */
  15342. export class PluginParam {
  15343. /**
  15344. !#en
  15345. create plugin parameters
  15346. !#zh
  15347. 创建对象
  15348. @param parameters parameters
  15349. */
  15350. static create(parameters: number|string|any): anysdk.PluginParam;
  15351. }
  15352. /** !#en The callback of user system
  15353. !#zh 用户系统回调 */
  15354. export enum UserActionResultCode {
  15355. kInitSuccess = 0,
  15356. kInitFail = 0,
  15357. kLoginSuccess = 0,
  15358. kLoginNetworkError = 0,
  15359. kLoginNoNeed = 0,
  15360. kLoginFail = 0,
  15361. kLoginCancel = 0,
  15362. kLogoutSuccess = 0,
  15363. kLogoutFail = 0,
  15364. kPlatformEnter = 0,
  15365. kPlatformBack = 0,
  15366. kPausePage = 0,
  15367. kExitPage = 0,
  15368. kAntiAddictionQuery = 0,
  15369. kRealNameRegister = 0,
  15370. kAccountSwitchSuccess = 0,
  15371. kAccountSwitchFail = 0,
  15372. kOpenShop = 0,
  15373. kAccountSwitchCancel = 0,
  15374. kUserExtension = 0,
  15375. kSendToDesktopSuccess = 0,
  15376. kSendToDesktopFail = 0,
  15377. kGetAvailableLoginTypeSuccess = 0,
  15378. kGetAvailableLoginTypeFail = 0,
  15379. kGetUserInfoSuccess = 0,
  15380. kGetUserInfoFail = 0,
  15381. kOpenBBSSuccess = 0,
  15382. kOpenBBSFail = 0,
  15383. }
  15384. /** !#en The toolbar position of user type
  15385. !#zh 用户系统悬浮窗位置 */
  15386. export enum ToolBarPlace {
  15387. kToolBarTopLeft = 0,
  15388. kToolBarTopRight = 0,
  15389. kToolBarMidLeft = 0,
  15390. kToolBarMidRight = 0,
  15391. kToolBarBottomLeft = 0,
  15392. kToolBarBottomRight = 0,
  15393. }
  15394. /** !#en The callback of requesting reStringge
  15395. !#zh 支付系统支付请求回调 */
  15396. export enum PayResultCode {
  15397. kPaySuccess = 0,
  15398. kPayFail = 0,
  15399. kPayCancel = 0,
  15400. kPayNetworkError = 0,
  15401. kPayProductionInforIncomplete = 0,
  15402. kPayInitSuccess = 0,
  15403. kPayInitFail = 0,
  15404. kPayNowPaying = 0,
  15405. kPayReStringgeSuccess = 0,
  15406. kPayExtension = 0,
  15407. kPayNeedLoginAgain = 0,
  15408. kRequestSuccess = 0,
  15409. kRequestFail = 0,
  15410. }
  15411. /** !#en The enum of account type
  15412. !#zh 统计系统的账号类型 */
  15413. export enum AccountType {
  15414. ANONYMOUS = 0,
  15415. REGISTED = 0,
  15416. SINA_WEIBO = 0,
  15417. TENCENT_WEIBO = 0,
  15418. QQ = 0,
  15419. ND91 = 0,
  15420. }
  15421. /** !#en The enum of account operation
  15422. !#zh 统计系统的账号操作 */
  15423. export enum AccountOperate {
  15424. LOGIN = 0,
  15425. LOGOUT = 0,
  15426. REGISTER = 0,
  15427. }
  15428. /** !#en The enum of gender
  15429. !#zh 统计系统的账号性别 */
  15430. export enum AccountGender {
  15431. MALE = 0,
  15432. FEMALE = 0,
  15433. UNKNOWN = 0,
  15434. }
  15435. /** !#en The enum of task type
  15436. !#zh 统计系统的任务类型 */
  15437. export enum TaskType {
  15438. GUIDE_LINE = 0,
  15439. MAIN_LINE = 0,
  15440. BRANCH_LINE = 0,
  15441. DAILY = 0,
  15442. ACTIVITY = 0,
  15443. OTHER = 0,
  15444. }
  15445. /** !#en The callback of share system
  15446. !#zh 分享系统回调 */
  15447. export enum ShareResultCode {
  15448. kShareSuccess = 0,
  15449. kShareFail = 0,
  15450. kShareCancel = 0,
  15451. kShareNetworkError = 0,
  15452. kShareExtension = 0,
  15453. }
  15454. /** !#en The callback of social system
  15455. !#zh 社交系统回调 */
  15456. export enum SocialRetCode {
  15457. kScoreSubmitSucceed = 0,
  15458. kScoreSubmitfail = 0,
  15459. kAchUnlockSucceed = 0,
  15460. kAchUnlockFail = 0,
  15461. kSocialSignInSucceed = 0,
  15462. kSocialSignInFail = 0,
  15463. kSocialSignOutSucceed = 0,
  15464. kSocialSignOutFail = 0,
  15465. kSocialGetGameFriends = 0,
  15466. kSocialExtensionCode = 0,
  15467. kSocialGetFriendsInfoSuccess = 0,
  15468. kSocialGetFriendsInfoFail = 0,
  15469. kSocialAlreadySubscription = 0,
  15470. kSocialNoSubscription = 0,
  15471. kSocialSubscriptionFail = 0,
  15472. }
  15473. /** !#en The callback of ads system
  15474. !#zh 广告系统回调 */
  15475. export enum AdsResultCode {
  15476. kAdsReceived = 0,
  15477. kAdsShown = 0,
  15478. kAdsDismissed = 0,
  15479. kPointsSpendSucceed = 0,
  15480. kPointsSpendFailed = 0,
  15481. kNetworkError = 0,
  15482. kUnknownError = 0,
  15483. kOfferWallOnPointsChanged = 0,
  15484. kRewardedVideoWithReward = 0,
  15485. kInAppPurchaseFinished = 0,
  15486. kAdsClicked = 0,
  15487. kAdsExtension = 0,
  15488. }
  15489. /** !#en The enum of ads position
  15490. !#zh 广告位置 */
  15491. export enum AdsPos {
  15492. kPosCenter = 0,
  15493. kPosTop = 0,
  15494. kPosTopLeft = 0,
  15495. kPosTopRight = 0,
  15496. kPosBottom = 0,
  15497. kPosBottomLeft = 0,
  15498. kPosBottomRight = 0,
  15499. }
  15500. /** !#en The enum of ads type
  15501. !#zh 广告类型 */
  15502. export enum AdsType {
  15503. AD_TYPE_BANNER = 0,
  15504. AD_TYPE_FULLSCREEN = 0,
  15505. AD_TYPE_MOREAPP = 0,
  15506. AD_TYPE_OFFERWALL = 0,
  15507. AD_TYPE_REWARDEDVIDEO = 0,
  15508. AD_TYPE_NATIVEEXPRESS = 0,
  15509. AD_TYPE_NATIVEADVANCED = 0,
  15510. }
  15511. /** !#en The callback of push system
  15512. !#zh 推送系统回调 */
  15513. export enum PushActionResultCode {
  15514. kPushReceiveMessage = 0,
  15515. kPushExtensionCode = 0,
  15516. }
  15517. /** !#en The callback of custom system
  15518. !#zh 自定义系统回调 */
  15519. export enum CustomResultCode {
  15520. kCustomExtension = 0,
  15521. }
  15522. /** !#en The callback of REC system
  15523. !#zh 录屏系统回调 */
  15524. export enum RECResultCode {
  15525. kRECInitSuccess = 0,
  15526. kRECInitFail = 0,
  15527. kRECStartRecording = 0,
  15528. kRECStopRecording = 0,
  15529. kRECPauseRecording = 0,
  15530. kRECResumeRecording = 0,
  15531. kRECEnterSDKPage = 0,
  15532. kRECQuitSDKPage = 0,
  15533. kRECShareSuccess = 0,
  15534. kRECShareFail = 0,
  15535. kRECExtension = 0,
  15536. }
  15537. }
  15538. /** !#en
  15539. The global main namespace of DragonBones, all classes, functions,
  15540. properties and constants of DragonBones are defined in this namespace
  15541. !#zh
  15542. DragonBones 的全局的命名空间,
  15543. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15544. declare module dragonBones {
  15545. /** !#en
  15546. The Armature Display of DragonBones <br/>
  15547. <br/>
  15548. (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  15549. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15550. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/>
  15551. !#zh
  15552. DragonBones 骨骼动画 <br/>
  15553. <br/>
  15554. (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15555. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15556. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)<br/> */
  15557. export class ArmatureDisplay extends cc._RendererUnderSG {
  15558. /** !#en
  15559. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  15560. attachments, skins, etc) and animations but does not hold any state.<br/>
  15561. Multiple ArmatureDisplay can share the same DragonBones data.
  15562. !#zh
  15563. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15564. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15565. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  15566. dragonAsset: DragonBonesAsset;
  15567. /** !#en
  15568. The atlas asset for the DragonBones.
  15569. !#zh
  15570. 骨骼数据所需的 Atlas Texture 数据。 */
  15571. dragonAtlasAsset: DragonBonesAtlasAsset;
  15572. /** !#en The name of current armature.
  15573. !#zh 当前的 Armature 名称。 */
  15574. armatureName: string;
  15575. /** !#en The name of current playing animation.
  15576. !#zh 当前播放的动画名称。 */
  15577. animationName: string;
  15578. _defaultArmatureIndex: number;
  15579. /** !#en The time scale of this armature.
  15580. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15581. timeScale: number;
  15582. /** !#en The play times of the default animation.
  15583. -1 means using the value of config file;
  15584. 0 means repeat for ever
  15585. >0 means repeat times
  15586. !#zh 播放默认动画的循环次数
  15587. -1 表示使用配置文件中的默认值;
  15588. 0 表示无限循环
  15589. >0 表示循环次数 */
  15590. playTimes: number;
  15591. /** !#en Indicates whether open debug bones.
  15592. !#zh 是否显示 bone 的 debug 信息。 */
  15593. debugBones: boolean;
  15594. /**
  15595. !#en
  15596. Play the specified animation.
  15597. Parameter animName specify the animation name.
  15598. Parameter playTimes specify the repeat times of the animation.
  15599. -1 means use the value of the config file.
  15600. 0 means play the animation for ever.
  15601. >0 means repeat times.
  15602. !#zh
  15603. 播放指定的动画.
  15604. animName 指定播放动画的名称。
  15605. playTimes 指定播放动画的次数。
  15606. -1 为使用配置文件中的次数。
  15607. 0 为无限循环播放。
  15608. >0 为动画的重复次数。
  15609. @param animName animName
  15610. @param playTimes playTimes
  15611. */
  15612. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  15613. /**
  15614. !#en
  15615. Get the all armature names in the DragonBones Data.
  15616. !#zh
  15617. 获取 DragonBones 数据中所有的 armature 名称
  15618. */
  15619. getArmatureNames(): any[];
  15620. /**
  15621. !#en
  15622. Get the all animation names of specified armature.
  15623. !#zh
  15624. 获取指定的 armature 的所有动画名称。
  15625. @param armatureName armatureName
  15626. */
  15627. getAnimationNames(armatureName: string): any[];
  15628. /**
  15629. !#en
  15630. Add event listener for the DragonBones Event.
  15631. !#zh
  15632. 添加 DragonBones 事件监听器。
  15633. @param eventType eventType
  15634. @param listener listener
  15635. @param target target
  15636. */
  15637. addEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15638. /**
  15639. !#en
  15640. Remove the event listener for the DragonBones Event.
  15641. !#zh
  15642. 移除 DragonBones 事件监听器。
  15643. @param eventType eventType
  15644. @param listener listener
  15645. @param target target
  15646. */
  15647. removeEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15648. /**
  15649. !#en
  15650. Build the armature for specified name.
  15651. !#zh
  15652. 构建指定名称的 armature 对象
  15653. @param armatureName armatureName
  15654. */
  15655. buildArmature(armatureName: string): dragonBones.Armature;
  15656. /**
  15657. !#en
  15658. Get the current armature object of the ArmatureDisplay.
  15659. !#zh
  15660. 获取 ArmatureDisplay 当前使用的 Armature 对象
  15661. */
  15662. armature(): any;
  15663. }
  15664. /** !#en The skeleton data of dragonBones.
  15665. !#zh dragonBones 的 骨骼数据。 */
  15666. export class DragonBonesAsset extends cc.Asset {
  15667. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  15668. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  15669. dragonBonesJson: string;
  15670. }
  15671. /** !#en The skeleton atlas data of dragonBones.
  15672. !#zh dragonBones 的骨骼纹理数据。 */
  15673. export class DragonBonesAtlasAsset extends cc.Asset {
  15674. atlasJson: string;
  15675. texture: cc.Texture2D;
  15676. }
  15677. }
  15678. /** !#en
  15679. The global main namespace of Spine, all classes, functions,
  15680. properties and constants of Spine are defined in this namespace
  15681. !#zh
  15682. Spine 的全局的命名空间,
  15683. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15684. declare module sp {
  15685. /** !#en
  15686. The skeleton of Spine <br/>
  15687. <br/>
  15688. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  15689. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15690. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  15691. !#zh
  15692. Spine 骨骼动画 <br/>
  15693. <br/>
  15694. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15695. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15696. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  15697. export class Skeleton extends cc._RendererUnderSG {
  15698. /** !#en The skeletal animation is paused?
  15699. !#zh 该骨骼动画是否暂停。 */
  15700. paused: boolean;
  15701. /** !#en
  15702. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  15703. attachments, skins, etc) and animations but does not hold any state.<br/>
  15704. Multiple skeletons can share the same skeleton data.
  15705. !#zh
  15706. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15707. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15708. 多个 Skeleton 可以共用相同的骨骼数据。 */
  15709. skeletonData: SkeletonData;
  15710. /** !#en The name of default skin.
  15711. !#zh 默认的皮肤名称。 */
  15712. defaultSkin: string;
  15713. /** !#en The name of default animation.
  15714. !#zh 默认的动画名称。 */
  15715. defaultAnimation: string;
  15716. /** !#en The name of current playing animation.
  15717. !#zh 当前播放的动画名称。 */
  15718. animation: string;
  15719. _defaultSkinIndex: number;
  15720. /** !#en TODO
  15721. !#zh 是否循环播放当前骨骼动画。 */
  15722. loop: boolean;
  15723. /** !#en Indicates whether to enable premultiplied alpha.
  15724. You should disable this option when image's transparent area appears to have opaque pixels,
  15725. or enable this option when image's half transparent area appears to be darken.
  15726. !#zh 是否启用贴图预乘。
  15727. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  15728. premultipliedAlpha: boolean;
  15729. /** !#en The time scale of this skeleton.
  15730. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15731. timeScale: number;
  15732. /** !#en Indicates whether open debug slots.
  15733. !#zh 是否显示 slot 的 debug 信息。 */
  15734. debugSlots: boolean;
  15735. /** !#en Indicates whether open debug bones.
  15736. !#zh 是否显示 bone 的 debug 信息。 */
  15737. debugBones: boolean;
  15738. /**
  15739. !#en Computes the world SRT from the local SRT for each bone.
  15740. !#zh 重新更新所有骨骼的世界 Transform,
  15741. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  15742. @example
  15743. ```js
  15744. var bone = spine.findBone('head');
  15745. cc.log(bone.worldX); // return 0;
  15746. spine.updateWorldTransform();
  15747. bone = spine.findBone('head');
  15748. cc.log(bone.worldX); // return -23.12;
  15749. ```
  15750. */
  15751. updateWorldTransform(): void;
  15752. /**
  15753. !#en Sets the bones and slots to the setup pose.
  15754. !#zh 还原到起始动作
  15755. */
  15756. setToSetupPose(): void;
  15757. /**
  15758. !#en
  15759. Sets the bones to the setup pose,
  15760. using the values from the `BoneData` list in the `SkeletonData`.
  15761. !#zh
  15762. 设置 bone 到起始动作
  15763. 使用 SkeletonData 中的 BoneData 列表中的值。
  15764. */
  15765. setBonesToSetupPose(): void;
  15766. /**
  15767. !#en
  15768. Sets the slots to the setup pose,
  15769. using the values from the `SlotData` list in the `SkeletonData`.
  15770. !#zh
  15771. 设置 slot 到起始动作。
  15772. 使用 SkeletonData 中的 SlotData 列表中的值。
  15773. */
  15774. setSlotsToSetupPose(): void;
  15775. /**
  15776. !#en
  15777. Finds a bone by name.
  15778. This does a string comparison for every bone.<br>
  15779. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  15780. !#zh
  15781. 通过名称查找 bone。
  15782. 这里对每个 bone 的名称进行了对比。<br>
  15783. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  15784. @param boneName boneName
  15785. */
  15786. findBone(boneName: string): sp.spine.Bone;
  15787. /**
  15788. !#en
  15789. Finds a slot by name. This does a string comparison for every slot.<br>
  15790. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  15791. !#zh
  15792. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  15793. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  15794. @param slotName slotName
  15795. */
  15796. findSlot(slotName: string): sp.spine.Slot;
  15797. /**
  15798. !#en
  15799. Finds a skin by name and makes it the active skin.
  15800. This does a string comparison for every skin.<br>
  15801. Note that setting the skin does not change which attachments are visible.<br>
  15802. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  15803. !#zh
  15804. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  15805. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  15806. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  15807. @param skinName skinName
  15808. */
  15809. setSkin(skinName: string): sp.spine.Skin;
  15810. /**
  15811. !#en
  15812. Returns the attachment for the slot and attachment name.
  15813. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  15814. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  15815. !#zh
  15816. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  15817. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  15818. @param slotName slotName
  15819. @param attachmentName attachmentName
  15820. */
  15821. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  15822. /**
  15823. !#en
  15824. Sets the attachment for the slot and attachment name.
  15825. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  15826. !#zh
  15827. 通过 slot 和 attachment 的名字来设置 attachment。
  15828. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  15829. @param slotName slotName
  15830. @param attachmentName attachmentName
  15831. */
  15832. setAttachment(slotName: string, attachmentName: string): void;
  15833. /**
  15834. !#en
  15835. Sets runtime skeleton data to sp.Skeleton.<br>
  15836. 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.
  15837. !#zh
  15838. 设置底层运行时用到的 SkeletonData。<br>
  15839. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  15840. @param skeletonData skeletonData
  15841. @param ownsSkeletonData ownsSkeletonData
  15842. */
  15843. setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
  15844. /**
  15845. !#en Sets animation state data.<br>
  15846. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  15847. !#zh 设置动画状态数据。<br>
  15848. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  15849. @param stateData stateData
  15850. */
  15851. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  15852. /**
  15853. !#en
  15854. Mix applies all keyframe values,
  15855. interpolated for the specified time and mixed with the current values.
  15856. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  15857. @param fromAnimation fromAnimation
  15858. @param toAnimation toAnimation
  15859. @param duration duration
  15860. */
  15861. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  15862. /**
  15863. !#en Sets event listener.
  15864. !#zh 设置动画事件监听器。
  15865. @param target target
  15866. @param callback callback
  15867. */
  15868. setAnimationListener(target: any, callback: Function): void;
  15869. /**
  15870. !#en Set the current animation. Any queued animations are cleared.<br>
  15871. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15872. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  15873. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15874. @param trackIndex trackIndex
  15875. @param name name
  15876. @param loop loop
  15877. */
  15878. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  15879. /**
  15880. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  15881. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15882. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  15883. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15884. @param trackIndex trackIndex
  15885. @param name name
  15886. @param loop loop
  15887. @param delay delay
  15888. */
  15889. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  15890. /**
  15891. !#en Find animation with specified name.
  15892. !#zh 查找指定名称的动画
  15893. @param name name
  15894. */
  15895. findAnimation(name: string): sp.spine.Animation;
  15896. /**
  15897. !#en Returns track entry by trackIndex.<br>
  15898. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15899. !#zh 通过 track 索引获取 TrackEntry。<br>
  15900. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15901. @param trackIndex trackIndex
  15902. */
  15903. getCurrent(trackIndex: void): sp.spine.TrackEntry;
  15904. /**
  15905. !#en Clears all tracks of animation state.
  15906. !#zh 清除所有 track 的动画状态。
  15907. */
  15908. clearTracks(): void;
  15909. /**
  15910. !#en Clears track of animation state by trackIndex.
  15911. !#zh 清除出指定 track 的动画状态。
  15912. @param trackIndex trackIndex
  15913. */
  15914. clearTrack(trackIndex: number): void;
  15915. /**
  15916. !#en Set the start event listener.
  15917. !#zh 用来设置开始播放动画的事件监听。
  15918. @param listener listener
  15919. */
  15920. setStartListener(listener: Function): void;
  15921. /**
  15922. !#en Set the interrupt event listener.
  15923. !#zh 用来设置动画被打断的事件监听。
  15924. @param listener listener
  15925. */
  15926. setInterruptListener(listener: Function): void;
  15927. /**
  15928. !#en Set the end event listener.
  15929. !#zh 用来设置动画播放完后的事件监听。
  15930. @param listener listener
  15931. */
  15932. setEndListener(listener: Function): void;
  15933. /**
  15934. !#en Set the dispose event listener.
  15935. !#zh 用来设置动画将被销毁的事件监听。
  15936. @param listener listener
  15937. */
  15938. setDisposeListener(listener: Function): void;
  15939. /**
  15940. !#en Set the complete event listener.
  15941. !#zh 用来设置动画播放一次循环结束后的事件监听。
  15942. @param listener listener
  15943. */
  15944. setCompleteListener(listener: Function): void;
  15945. /**
  15946. !#en Set the animation event listener.
  15947. !#zh 用来设置动画播放过程中帧事件的监听。
  15948. @param listener listener
  15949. */
  15950. setEventListener(listener: Function): void;
  15951. /**
  15952. !#en Set the start event listener for specified TrackEntry (only supported on Web).
  15953. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
  15954. @param entry entry
  15955. @param listener listener
  15956. */
  15957. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15958. /**
  15959. !#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
  15960. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
  15961. @param entry entry
  15962. @param listener listener
  15963. */
  15964. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15965. /**
  15966. !#en Set the end event listener for specified TrackEntry (only supported on Web).
  15967. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
  15968. @param entry entry
  15969. @param listener listener
  15970. */
  15971. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15972. /**
  15973. !#en Set the dispose event listener for specified TrackEntry (only supported on Web).
  15974. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
  15975. @param entry entry
  15976. @param listener listener
  15977. */
  15978. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15979. /**
  15980. !#en Set the complete event listener for specified TrackEntry (only supported on Web).
  15981. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
  15982. @param entry entry
  15983. @param listener listener
  15984. */
  15985. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15986. /**
  15987. !#en Set the event listener for specified TrackEntry (only supported on Web).
  15988. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
  15989. @param entry entry
  15990. @param listener listener
  15991. */
  15992. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15993. }
  15994. /** !#en The skeleton data of spine.
  15995. !#zh Spine 的 骨骼数据。 */
  15996. export class SkeletonData extends cc.Asset {
  15997. /** !#en See http://en.esotericsoftware.com/spine-json-format
  15998. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  15999. skeletonJson: any;
  16000. atlasText: string;
  16001. textures: cc.Texture2D[];
  16002. /** !#en
  16003. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  16004. image sizes, and animation translations.
  16005. This can be useful when using different sized images than were used when designing the skeleton
  16006. in Spine. For example, if using images that are half the size than were used in Spine,
  16007. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  16008. resolution texture atlases.
  16009. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  16010. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  16011. scale: number;
  16012. /**
  16013. !#en Get the included SkeletonData used in spine runtime.<br>
  16014. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  16015. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  16016. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  16017. @param quiet quiet
  16018. */
  16019. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  16020. }
  16021. /** !#en The event type of spine skeleton animation.
  16022. !#zh 骨骼动画事件类型。 */
  16023. export enum AnimationEventType {
  16024. START = 0,
  16025. END = 0,
  16026. COMPLETE = 0,
  16027. EVENT = 0,
  16028. }
  16029. }
  16030. /** !#en
  16031. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  16032. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  16033. !#zh
  16034. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  16035. declare module sp.spine {
  16036. }
  16037. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  16038. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  16039. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  16040. declare module cc._decorator {
  16041. /**
  16042. !#en
  16043. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  16044. as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details.
  16045. !#zh
  16046. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。
  16047. @param name The class name used for serialization.
  16048. @example
  16049. ```js
  16050. const {ccclass} = cc._decorator;
  16051. // define a CCClass, omit the name
  16052. &#64;ccclass
  16053. class NewScript extends cc.Component {
  16054. // ...
  16055. }
  16056. // define a CCClass with a name
  16057. &#64;ccclass('LoginData')
  16058. class LoginData {
  16059. // ...
  16060. }
  16061. ```
  16062. */
  16063. export function ccclass(name?: string): Function;
  16064. export function ccclass(_class?: Function): void;
  16065. /**
  16066. !#en
  16067. Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/).
  16068. !#zh
  16069. 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。
  16070. @param options an object with some property attributes
  16071. @example
  16072. ```js
  16073. const {ccclass, property} = cc._decorator;
  16074. &#64;ccclass
  16075. class NewScript extends cc.Component {
  16076. &#64;property({
  16077. type: cc.Node
  16078. })
  16079. targetNode1 = null;
  16080. &#64;property(cc.Node)
  16081. targetNode2 = null;
  16082. &#64;property(cc.Button)
  16083. targetButton = null;
  16084. &#64;property
  16085. _width = 100;
  16086. &#64;property
  16087. get width () {
  16088. return this._width;
  16089. }
  16090. &#64;property
  16091. set width (value) {
  16092. this._width = value;
  16093. }
  16094. &#64;property
  16095. offset = new cc.Vec2(100, 100);
  16096. &#64;property(cc.Vec2)
  16097. offsets = [];
  16098. &#64;property(cc.Texture2D)
  16099. texture = "";
  16100. }
  16101. // above is equivalent to (上面的代码相当于):
  16102. var NewScript = cc.Class({
  16103. properties: {
  16104. targetNode1: {
  16105. default: null,
  16106. type: cc.Node
  16107. },
  16108. targetNode2: {
  16109. default: null,
  16110. type: cc.Node
  16111. },
  16112. targetButton: {
  16113. default: null,
  16114. type: cc.Button
  16115. },
  16116. _width: 100,
  16117. width: {
  16118. get () {
  16119. return this._width;
  16120. },
  16121. set (value) {
  16122. this._width = value;
  16123. }
  16124. },
  16125. offset: new cc.Vec2(100, 100)
  16126. offsets: {
  16127. default: [],
  16128. type: cc.Vec2
  16129. }
  16130. texture: {
  16131. default: "",
  16132. url: cc.Texture2D
  16133. },
  16134. }
  16135. });
  16136. ```
  16137. */
  16138. export function property(options?: {type?: any; url?: typeof cc.RawAsset; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function;
  16139. export function property(_target: Object, _key: any, _desc?: any): void;
  16140. /**
  16141. !#en
  16142. Makes a CCClass that inherit from component execute in edit mode.<br>
  16143. By default, all components are only executed in play mode,
  16144. which means they will not have their callback functions executed while the Editor is in edit mode.
  16145. !#zh
  16146. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  16147. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  16148. @example
  16149. ```js
  16150. const {ccclass, executeInEditMode} = cc._decorator;
  16151. &#64;ccclass
  16152. &#64;executeInEditMode
  16153. class NewScript extends cc.Component {
  16154. // ...
  16155. }
  16156. ```
  16157. */
  16158. export function executeInEditMode(): Function;
  16159. export function executeInEditMode(_class: Function): void;
  16160. /**
  16161. !#en
  16162. Automatically add required component as a dependency for the CCClass that inherit from component.
  16163. !#zh
  16164. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  16165. @param requiredComponent requiredComponent
  16166. @example
  16167. ```js
  16168. const {ccclass, requireComponent} = cc._decorator;
  16169. &#64;ccclass
  16170. &#64;requireComponent(cc.Sprite)
  16171. class SpriteCtrl extends cc.Component {
  16172. // ...
  16173. }
  16174. ```
  16175. */
  16176. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  16177. /**
  16178. !#en
  16179. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  16180. !#zh
  16181. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  16182. @param path The path is the menu represented like a pathname.
  16183. For example the menu could be "Rendering/CameraCtrl".
  16184. @example
  16185. ```js
  16186. const {ccclass, menu} = cc._decorator;
  16187. &#64;ccclass
  16188. &#64;menu("Rendering/CameraCtrl")
  16189. class NewScript extends cc.Component {
  16190. // ...
  16191. }
  16192. ```
  16193. */
  16194. export function menu(path: string): Function;
  16195. /**
  16196. !#en
  16197. The execution order of lifecycle methods for Component.
  16198. Those less than 0 will execute before while those greater than 0 will execute after.
  16199. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  16200. !#zh
  16201. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  16202. @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.
  16203. @example
  16204. ```js
  16205. const {ccclass, executionOrder} = cc._decorator;
  16206. &#64;ccclass
  16207. &#64;executionOrder(1)
  16208. class CameraCtrl extends cc.Component {
  16209. // ...
  16210. }
  16211. ```
  16212. */
  16213. export function executionOrder(order: number): Function;
  16214. /**
  16215. !#en
  16216. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  16217. !#zh
  16218. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  16219. @example
  16220. ```js
  16221. const {ccclass, disallowMultiple} = cc._decorator;
  16222. &#64;ccclass
  16223. &#64;disallowMultiple
  16224. class CameraCtrl extends cc.Component {
  16225. // ...
  16226. }
  16227. ```
  16228. */
  16229. export function disallowMultiple(): Function;
  16230. export function disallowMultiple(_class: Function): void;
  16231. /**
  16232. !#en
  16233. 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>
  16234. This property is only available if executeInEditMode is true.
  16235. !#zh
  16236. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  16237. @example
  16238. ```js
  16239. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  16240. &#64;ccclass
  16241. &#64;executeInEditMode
  16242. &#64;playOnFocus
  16243. class CameraCtrl extends cc.Component {
  16244. // ...
  16245. }
  16246. ```
  16247. */
  16248. export function playOnFocus(): Function;
  16249. export function playOnFocus(_class: Function): void;
  16250. /**
  16251. !#en
  16252. Specifying the url of the custom html to draw the component in **Properties**.
  16253. !#zh
  16254. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  16255. @param url url
  16256. @example
  16257. ```js
  16258. const {ccclass, inspector} = cc._decorator;
  16259. &#64;ccclass
  16260. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  16261. class NewScript extends cc.Component {
  16262. // ...
  16263. }
  16264. ```
  16265. */
  16266. export function inspector(path: string): Function;
  16267. /**
  16268. !#en
  16269. The custom documentation URL.
  16270. !#zh
  16271. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  16272. @param url url
  16273. @example
  16274. ```js
  16275. const {ccclass, help} = cc._decorator;
  16276. &#64;ccclass
  16277. &#64;help("app://docs/html/components/spine.html")
  16278. class NewScript extends cc.Component {
  16279. // ...
  16280. }
  16281. ```
  16282. */
  16283. export function help(path: string): Function;
  16284. /**
  16285. NOTE:<br>
  16286. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  16287. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  16288. so we can not mix in ES6 Classes.<br>
  16289. See:<br>
  16290. [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>
  16291. One possible solution (but IDE unfriendly):<br>
  16292. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  16293. <br>
  16294. NOTE:<br>
  16295. You must manually call mixins constructor, this is different from cc.Class(ES5).
  16296. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  16297. not support ES6 Classes.
  16298. @example
  16299. ```js
  16300. const {ccclass, mixins} = cc._decorator;
  16301. class Animal { ... }
  16302. const Fly = cc.Class({
  16303. constructor () { ... }
  16304. });
  16305. &#64;ccclass
  16306. &#64;mixins(cc.EventTarget, Fly)
  16307. class Bird extends Animal {
  16308. constructor () {
  16309. super();
  16310. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  16311. cc.EventTarget.call(this);
  16312. Fly.call(this);
  16313. }
  16314. // ...
  16315. }
  16316. ```
  16317. */
  16318. export function mixins(ctor: Function, ...rest: Function[]): Function;
  16319. }
  16320. /** This module provides some JavaScript utilities.
  16321. All members can be accessed with "cc.js". */
  16322. declare module cc.js {
  16323. /**
  16324. Check the obj whether is number or not
  16325. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  16326. Then you can use this function if you care about this case.
  16327. @param obj obj
  16328. */
  16329. export function isNumber(obj: any): boolean;
  16330. /**
  16331. Check the obj whether is string or not.
  16332. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  16333. Then you can use this function if you care about this case.
  16334. @param obj obj
  16335. */
  16336. export function isString(obj: any): boolean;
  16337. /**
  16338. This method is deprecated, use cc.js.mixin please.<br>
  16339. Copy all properties not defined in obj from arguments[1...n]
  16340. @param obj object to extend its properties
  16341. @param sourceObj source object to copy properties from
  16342. */
  16343. export function addon(obj: any, ...sourceObj: any[]): any;
  16344. /**
  16345. copy all properties from arguments[1...n] to obj
  16346. @param obj obj
  16347. @param sourceObj sourceObj
  16348. */
  16349. export function mixin(obj: any, ...sourceObj: any[]): any;
  16350. /**
  16351. Derive the class from the supplied base class.
  16352. Both classes are just native javascript constructors, not created by cc.Class, so
  16353. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  16354. @param cls cls
  16355. @param base the baseclass to inherit
  16356. */
  16357. export function extend(cls: Function, base: Function): Function;
  16358. /**
  16359. Get super class
  16360. @param ctor the constructor of subclass
  16361. */
  16362. export function getSuper(ctor: Function): Function;
  16363. /**
  16364. Removes all enumerable properties from object
  16365. @param obj obj
  16366. */
  16367. export function clear(obj: any): void;
  16368. /**
  16369. Get property descriptor in object and all its ancestors
  16370. @param obj obj
  16371. @param name name
  16372. */
  16373. export function getPropertyDescriptor(obj: any, name: string): any;
  16374. /**
  16375. Define value, just help to call Object.defineProperty.<br>
  16376. The configurable will be true.
  16377. @param obj obj
  16378. @param prop prop
  16379. @param value value
  16380. @param writable writable
  16381. @param enumerable enumerable
  16382. */
  16383. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  16384. /**
  16385. Define get set accessor, just help to call Object.defineProperty(...)
  16386. @param obj obj
  16387. @param prop prop
  16388. @param getter getter
  16389. @param setter setter
  16390. @param enumerable enumerable
  16391. */
  16392. export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void;
  16393. /**
  16394. Define get accessor, just help to call Object.defineProperty(...)
  16395. @param obj obj
  16396. @param prop prop
  16397. @param getter getter
  16398. @param enumerable enumerable
  16399. @param configurable configurable
  16400. */
  16401. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  16402. /**
  16403. Define set accessor, just help to call Object.defineProperty(...)
  16404. @param obj obj
  16405. @param prop prop
  16406. @param setter setter
  16407. @param enumerable enumerable
  16408. @param configurable configurable
  16409. */
  16410. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  16411. /**
  16412. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  16413. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  16414. @param objOrCtor instance or constructor
  16415. */
  16416. export function getClassName(objOrCtor: any|Function): string;
  16417. /**
  16418. Register the class by specified name manually
  16419. @param className className
  16420. @param constructor constructor
  16421. */
  16422. export function setClassName(className: string, constructor: Function): void;
  16423. /**
  16424. Unregister a class from fireball.
  16425. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  16426. Please note that its still your responsibility to free other references to the class.
  16427. @param constructor the class you will want to unregister, any number of classes can be added
  16428. */
  16429. export function unregisterClass(...constructor: Function[]): void;
  16430. /**
  16431. Get the registered class by name
  16432. @param classname classname
  16433. */
  16434. export function getClassByName(classname: string): Function;
  16435. /**
  16436. Defines a polyfill field for obsoleted codes.
  16437. @param obj YourObject or YourClass.prototype
  16438. @param obsoleted "OldParam" or "YourClass.OldParam"
  16439. @param newPropName "NewParam"
  16440. @param writable writable
  16441. */
  16442. export function obsolete(obj: any, obsoleted: string, newPropName: string, writable?: boolean): void;
  16443. /**
  16444. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  16445. @param obj YourObject or YourClass.prototype
  16446. @param objName "YourObject" or "YourClass"
  16447. @param props props
  16448. @param writable writable
  16449. */
  16450. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  16451. /**
  16452. A string tool to construct a string with format string.
  16453. @param msg A JavaScript string containing zero or more substitution strings (%s).
  16454. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  16455. @example
  16456. ```js
  16457. cc.js.formatStr("a: %s, b: %s", a, b);
  16458. cc.js.formatStr(a, b, c);
  16459. ```
  16460. */
  16461. export function formatStr(msg: string|any, ...subst: any[]): string;
  16462. /**
  16463. !#en
  16464. 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.
  16465. !#zh
  16466. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  16467. @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.
  16468. */
  16469. export function createMap(forceDictMode?: boolean): any;
  16470. /** undefined */
  16471. export class array {
  16472. /**
  16473. Removes the array item at the specified index.
  16474. @param array array
  16475. @param index index
  16476. */
  16477. static removeAt(array: any[], index: number): void;
  16478. /**
  16479. Removes the array item at the specified index.
  16480. It's faster but the order of the array will be changed.
  16481. @param array array
  16482. @param index index
  16483. */
  16484. static fastRemoveAt(array: any[], index: number): void;
  16485. /**
  16486. Removes the first occurrence of a specific object from the array.
  16487. @param array array
  16488. @param value value
  16489. */
  16490. static remove(array: any[], value: any): boolean;
  16491. /**
  16492. Removes the first occurrence of a specific object from the array.
  16493. It's faster but the order of the array will be changed.
  16494. @param array array
  16495. @param value value
  16496. */
  16497. static fastRemove(array: any[], value: number): void;
  16498. /**
  16499. Verify array's Type
  16500. @param array array
  16501. @param type type
  16502. */
  16503. static verifyType(array: any[], type: Function): boolean;
  16504. /**
  16505. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  16506. @param array Source Array
  16507. @param minusArr minus Array
  16508. */
  16509. static removeArray(array: any[], minusArr: any[]): void;
  16510. /**
  16511. Inserts some objects at index
  16512. @param array array
  16513. @param addObjs addObjs
  16514. @param index index
  16515. */
  16516. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  16517. /**
  16518. Exact same function as Array.prototype.indexOf.<br>
  16519. 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>
  16520. 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!
  16521. @param searchElement Element to locate in the array.
  16522. @param fromIndex The index to start the search at
  16523. */
  16524. static indexOf(searchElement: any, fromIndex?: number): number;
  16525. /**
  16526. Determines whether the array contains a specific value.
  16527. @param array array
  16528. @param value value
  16529. */
  16530. static contains(array: any[], value: any): boolean;
  16531. /**
  16532. Copy an array's item to a new array (its performance is better than Array.slice)
  16533. @param array array
  16534. */
  16535. static copy(array: any[]): any[];
  16536. }
  16537. /** !#en
  16538. A fixed-length object pool designed for general type.<br>
  16539. The implementation of this object pool is very simple,
  16540. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  16541. !#zh
  16542. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  16543. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  16544. export class Pool {
  16545. /**
  16546. !#en
  16547. Constructor for creating an object pool for the specific object type.
  16548. You can pass a callback argument for process the cleanup logic when the object is recycled.
  16549. !#zh
  16550. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  16551. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  16552. @param size initializes the length of the array
  16553. */
  16554. constructor(cleanupFunc: (obj: any) => void, size: number);
  16555. constructor(size: number);
  16556. /**
  16557. !#en
  16558. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  16559. !#zh
  16560. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  16561. @param params parameters to used to initialize the object
  16562. */
  16563. get(...params: any[]): any;
  16564. /** !#en
  16565. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  16566. the maximum will not exceed the size specified when the constructor is called.
  16567. !#zh
  16568. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  16569. count: number;
  16570. /**
  16571. !#en
  16572. Get an object from pool, if no available object in the pool, null will be returned.
  16573. !#zh
  16574. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  16575. */
  16576. _get(): any;
  16577. /**
  16578. !#en Put an object into the pool.
  16579. !#zh 向对象池返还一个不再需要的对象。
  16580. */
  16581. put(): void;
  16582. /**
  16583. !#en Resize the pool.
  16584. !#zh 设置对象池容量。
  16585. */
  16586. resize(): void;
  16587. }
  16588. }
  16589. declare namespace dragonBones {
  16590. /**
  16591. * @private
  16592. */
  16593. const enum ArmatureType {
  16594. Armature = 0,
  16595. MovieClip = 1,
  16596. Stage = 2,
  16597. }
  16598. /**
  16599. * @private
  16600. */
  16601. const enum DisplayType {
  16602. Image = 0,
  16603. Armature = 1,
  16604. Mesh = 2,
  16605. }
  16606. /**
  16607. * @private
  16608. */
  16609. const enum ExtensionType {
  16610. FFD = 0,
  16611. AdjustColor = 10,
  16612. BevelFilter = 11,
  16613. BlurFilter = 12,
  16614. DropShadowFilter = 13,
  16615. GlowFilter = 14,
  16616. GradientBevelFilter = 15,
  16617. GradientGlowFilter = 16,
  16618. }
  16619. /**
  16620. * @private
  16621. */
  16622. const enum EventType {
  16623. Frame = 10,
  16624. Sound = 11,
  16625. }
  16626. /**
  16627. * @private
  16628. */
  16629. const enum ActionType {
  16630. Play = 0,
  16631. Stop = 1,
  16632. GotoAndPlay = 2,
  16633. GotoAndStop = 3,
  16634. FadeIn = 4,
  16635. FadeOut = 5,
  16636. }
  16637. /**
  16638. * @private
  16639. */
  16640. const enum BlendMode {
  16641. Normal = 0,
  16642. Add = 1,
  16643. Alpha = 2,
  16644. Darken = 3,
  16645. Difference = 4,
  16646. Erase = 5,
  16647. HardLight = 6,
  16648. Invert = 7,
  16649. Layer = 8,
  16650. Lighten = 9,
  16651. Multiply = 10,
  16652. Overlay = 11,
  16653. Screen = 12,
  16654. Subtract = 13,
  16655. }
  16656. /**
  16657. * @private
  16658. */
  16659. interface Map<T> {
  16660. [key: string]: T;
  16661. }
  16662. /**
  16663. * DragonBones
  16664. */
  16665. class DragonBones {
  16666. /**
  16667. * @private
  16668. */
  16669. static PI_D: number;
  16670. /**
  16671. * @private
  16672. */
  16673. static PI_H: number;
  16674. /**
  16675. * @private
  16676. */
  16677. static PI_Q: number;
  16678. /**
  16679. * @private
  16680. */
  16681. static ANGLE_TO_RADIAN: number;
  16682. /**
  16683. * @private
  16684. */
  16685. static RADIAN_TO_ANGLE: number;
  16686. /**
  16687. * @private
  16688. */
  16689. static SECOND_TO_MILLISECOND: number;
  16690. static VERSION: string;
  16691. /**
  16692. * @private
  16693. */
  16694. static debug: boolean;
  16695. /**
  16696. * @private
  16697. */
  16698. static debugDraw: boolean;
  16699. }
  16700. }
  16701. declare namespace dragonBones {
  16702. /**
  16703. * @language zh_CN
  16704. * 基础对象。
  16705. * @version DragonBones 4.5
  16706. */
  16707. abstract class BaseObject {
  16708. private static _hashCode;
  16709. private static _defaultMaxCount;
  16710. private static _maxCountMap;
  16711. private static _poolsMap;
  16712. private static _returnObject(object);
  16713. /**
  16714. * @language zh_CN
  16715. * 设置每种对象池的最大缓存数量。
  16716. * @param objectConstructor 对象类。
  16717. * @param maxCount 最大缓存数量。 (设置为 0 则不缓存)
  16718. * @version DragonBones 4.5
  16719. */
  16720. static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
  16721. /**
  16722. * @language zh_CN
  16723. * 清除对象池缓存的对象。
  16724. * @param objectConstructor 对象类。 (不设置则清除所有缓存)
  16725. * @version DragonBones 4.5
  16726. */
  16727. static clearPool(objectConstructor?: typeof BaseObject): void;
  16728. /**
  16729. * @language zh_CN
  16730. * 从对象池中创建指定对象。
  16731. * @param objectConstructor 对象类。
  16732. * @version DragonBones 4.5
  16733. */
  16734. static borrowObject<T extends BaseObject>(objectConstructor: {
  16735. new (): T;
  16736. }): T;
  16737. /**
  16738. * @language zh_CN
  16739. * 对象的唯一标识。
  16740. * @version DragonBones 4.5
  16741. */
  16742. hashCode: number;
  16743. /**
  16744. * @private
  16745. */
  16746. protected abstract _onClear(): void;
  16747. /**
  16748. * @language zh_CN
  16749. * 清除数据并返还对象池。
  16750. * @version DragonBones 4.5
  16751. */
  16752. returnToPool(): void;
  16753. }
  16754. }
  16755. declare namespace dragonBones {
  16756. }
  16757. declare namespace dragonBones {
  16758. /**
  16759. * @language zh_CN
  16760. * 动画混合时,使用的淡出方式。
  16761. * @see dragonBones.Animation#fadeIn()
  16762. * @version DragonBones 4.5
  16763. */
  16764. const enum AnimationFadeOutMode {
  16765. /**
  16766. * @language zh_CN
  16767. * 不淡出动画。
  16768. * @version DragonBones 4.5
  16769. */
  16770. None = 0,
  16771. /**
  16772. * @language zh_CN
  16773. * 淡出同层的动画。
  16774. * @version DragonBones 4.5
  16775. */
  16776. SameLayer = 1,
  16777. /**
  16778. * @language zh_CN
  16779. * 淡出同组的动画。
  16780. * @version DragonBones 4.5
  16781. */
  16782. SameGroup = 2,
  16783. /**
  16784. * @language zh_CN
  16785. * 淡出同层并且同组的动画。
  16786. * @version DragonBones 4.5
  16787. */
  16788. SameLayerAndGroup = 3,
  16789. /**
  16790. * @language zh_CN
  16791. * 淡出所有动画。
  16792. * @version DragonBones 4.5
  16793. */
  16794. All = 4,
  16795. }
  16796. /**
  16797. * @language zh_CN
  16798. * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口)
  16799. * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。
  16800. * @see dragonBones.WorldClock
  16801. * @see dragonBones.Armature
  16802. * @version DragonBones 3.0
  16803. */
  16804. interface IAnimateble {
  16805. /**
  16806. * @language zh_CN
  16807. * 更新一个指定的时间。
  16808. * @param passedTime 前进的时间。 (以秒为单位)
  16809. * @version DragonBones 3.0
  16810. */
  16811. advanceTime(passedTime: number): void;
  16812. }
  16813. /**
  16814. * @language zh_CN
  16815. * 动画控制器,用来播放动画数据,管理动画状态。
  16816. * @see dragonBones.AnimationData
  16817. * @see dragonBones.AnimationState
  16818. * @version DragonBones 3.0
  16819. */
  16820. class Animation extends BaseObject {
  16821. /**
  16822. * @private
  16823. */
  16824. private static _sortAnimationState(a, b);
  16825. /**
  16826. * @private
  16827. */
  16828. static toString(): string;
  16829. /**
  16830. * @language zh_CN
  16831. * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  16832. * @default 1
  16833. * @version DragonBones 3.0
  16834. */
  16835. timeScale: number;
  16836. /**
  16837. * @private
  16838. */
  16839. _armature: Armature;
  16840. private _isPlaying;
  16841. private _time;
  16842. private _duration;
  16843. private _lastAnimationState;
  16844. private _animations;
  16845. private _animationNames;
  16846. private _animationStates;
  16847. /**
  16848. * @inheritDoc
  16849. */
  16850. protected _onClear(): void;
  16851. private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut);
  16852. /**
  16853. * @language zh_CN
  16854. * 清除所有正在播放的动画状态。
  16855. * @version DragonBones 4.5
  16856. */
  16857. reset(): void;
  16858. /**
  16859. * @language zh_CN
  16860. * 暂停播放动画。
  16861. * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。
  16862. * @see dragonBones.AnimationState
  16863. * @version DragonBones 3.0
  16864. */
  16865. stop(animationName?: string): void;
  16866. /**
  16867. * @language zh_CN
  16868. * 播放动画。
  16869. * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。
  16870. * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16871. * @returns 返回控制这个动画数据的动画状态。
  16872. * @see dragonBones.AnimationState
  16873. * @version DragonBones 3.0
  16874. */
  16875. play(animationName?: string, playTimes?: number): AnimationState;
  16876. /**
  16877. * @language zh_CN
  16878. * 淡入播放指定名称的动画。
  16879. * @param animationName 动画数据的名称。
  16880. * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16881. * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
  16882. * @param layer 混合的图层,图层高会优先获取混合权重。
  16883. * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
  16884. * @param fadeOutMode 淡出的模式。
  16885. * @param additiveBlending 以叠加的形式混合。
  16886. * @param displayControl 是否对显示对象属性可控。
  16887. * @param pauseFadeOut 暂停需要淡出的动画。
  16888. * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
  16889. * @returns 返回控制这个动画数据的动画状态。
  16890. * @see dragonBones.AnimationFadeOutMode
  16891. * @see dragonBones.AnimationState
  16892. * @version DragonBones 4.5
  16893. */
  16894. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  16895. /**
  16896. * @language zh_CN
  16897. * 指定名称的动画从指定时间开始播放。
  16898. * @param animationName 动画数据的名称。
  16899. * @param time 时间。 (以秒为单位)
  16900. * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16901. * @param toTime 播放到指定的时间,如果未设置则播放整个动画。
  16902. * @returns 返回控制这个动画数据的动画状态。
  16903. * @see dragonBones.AnimationState
  16904. * @version DragonBones 4.5
  16905. */
  16906. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState;
  16907. /**
  16908. * @language zh_CN
  16909. * 指定名称的动画从指定帧开始播放。
  16910. * @param animationName 动画数据的名称。
  16911. * @param frame 帧。
  16912. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16913. * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。
  16914. * @returns 返回控制这个动画数据的动画状态。
  16915. * @see dragonBones.AnimationState
  16916. * @version DragonBones 4.5
  16917. */
  16918. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState;
  16919. /**
  16920. * @language zh_CN
  16921. * 指定名称的动画从指定进度开始播放。
  16922. * @param animationName 动画数据的名称。
  16923. * @param progress 进度。 [0~1]
  16924. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16925. * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。
  16926. * @returns 返回控制这个动画数据的动画状态。
  16927. * @see dragonBones.AnimationState
  16928. * @version DragonBones 4.5
  16929. */
  16930. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState;
  16931. /**
  16932. * @language zh_CN
  16933. * 播放指定名称的动画到指定的时间并停止。
  16934. * @param animationName 动画数据的名称。
  16935. * @param time 时间。 (以秒为单位)
  16936. * @returns 返回控制这个动画数据的动画状态。
  16937. * @see dragonBones.AnimationState
  16938. * @version DragonBones 4.5
  16939. */
  16940. gotoAndStopByTime(animationName: string, time?: number): AnimationState;
  16941. /**
  16942. * @language zh_CN
  16943. * 播放指定名称的动画到指定的帧并停止。
  16944. * @param animationName 动画数据的名称。
  16945. * @param frame 帧。
  16946. * @returns 返回控制这个动画数据的动画状态。
  16947. * @see dragonBones.AnimationState
  16948. * @version DragonBones 4.5
  16949. */
  16950. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState;
  16951. /**
  16952. * @language zh_CN
  16953. * 播放指定名称的动画到指定的进度并停止。
  16954. * @param animationName 动画数据的名称。
  16955. * @param progress 进度。 [0~1]
  16956. * @returns 返回控制这个动画数据的动画状态。
  16957. * @see dragonBones.AnimationState
  16958. * @version DragonBones 4.5
  16959. */
  16960. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState;
  16961. /**
  16962. * @language zh_CN
  16963. * 获取指定名称的动画状态。
  16964. * @param animationName 动画状态的名称。
  16965. * @see dragonBones.AnimationState
  16966. * @version DragonBones 3.0
  16967. */
  16968. getState(animationName: string): AnimationState;
  16969. /**
  16970. * @language zh_CN
  16971. * 是否包含指定名称的动画数据。
  16972. * @param animationName 动画数据的名称。
  16973. * @see dragonBones.AnimationData
  16974. * @version DragonBones 3.0
  16975. */
  16976. hasAnimation(animationName: string): boolean;
  16977. /**
  16978. * @language zh_CN
  16979. * 动画是否处于播放状态。
  16980. * @version DragonBones 3.0
  16981. */
  16982. isPlaying: boolean;
  16983. /**
  16984. * @language zh_CN
  16985. * 所有动画状态是否均已播放完毕。
  16986. * @see dragonBones.AnimationState
  16987. * @version DragonBones 3.0
  16988. */
  16989. isCompleted: boolean;
  16990. /**
  16991. * @language zh_CN
  16992. * 上一个正在播放的动画状态的名称。
  16993. * @see #lastAnimationState
  16994. * @version DragonBones 3.0
  16995. */
  16996. lastAnimationName: string;
  16997. /**
  16998. * @language zh_CN
  16999. * 上一个正在播放的动画状态。
  17000. * @see dragonBones.AnimationState
  17001. * @version DragonBones 3.0
  17002. */
  17003. lastAnimationState: AnimationState;
  17004. /**
  17005. * @language zh_CN
  17006. * 所有动画数据名称。
  17007. * @see #animations
  17008. * @version DragonBones 4.5
  17009. */
  17010. animationNames: Array<string>;
  17011. /**
  17012. * @language zh_CN
  17013. * 所有的动画数据。
  17014. * @see dragonBones.AnimationData
  17015. * @version DragonBones 4.5
  17016. */
  17017. animations: Map<AnimationData>;
  17018. /**
  17019. * @deprecated
  17020. * @see #play()
  17021. * @see #fadeIn()
  17022. * @see #gotoAndPlayByTime()
  17023. * @see #gotoAndPlayByFrame()
  17024. * @see #gotoAndPlayByProgress()
  17025. */
  17026. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17027. /**
  17028. * @deprecated
  17029. * @see #gotoAndStopByTime()
  17030. * @see #gotoAndStopByFrame()
  17031. * @see #gotoAndStopByProgress()
  17032. */
  17033. gotoAndStop(animationName: string, time?: number): AnimationState;
  17034. /**
  17035. * @deprecated
  17036. * @see #animationNames
  17037. * @see #animations
  17038. */
  17039. animationList: Array<string>;
  17040. /**
  17041. * @language zh_CN
  17042. * @deprecated
  17043. * @see #animationNames
  17044. * @see #animations
  17045. */
  17046. animationDataList: Array<AnimationData>;
  17047. }
  17048. }
  17049. declare namespace dragonBones {
  17050. /**
  17051. * @language zh_CN
  17052. * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。
  17053. * @see dragonBones.Animation
  17054. * @see dragonBones.AnimationData
  17055. * @version DragonBones 3.0
  17056. */
  17057. class AnimationState extends BaseObject {
  17058. /**
  17059. * @private
  17060. */
  17061. static stateActionEnabled: boolean;
  17062. /**
  17063. * @private
  17064. */
  17065. static toString(): string;
  17066. /**
  17067. * @language zh_CN
  17068. * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。
  17069. * @see dragonBones.Slot#displayController
  17070. * @version DragonBones 3.0
  17071. */
  17072. displayControl: boolean;
  17073. /**
  17074. * @language zh_CN
  17075. * 是否以叠加的方式混合动画。
  17076. * @version DragonBones 3.0
  17077. */
  17078. additiveBlending: boolean;
  17079. /**
  17080. * @private
  17081. */
  17082. actionEnabled: boolean;
  17083. /**
  17084. * @language zh_CN
  17085. * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  17086. * @version DragonBones 3.0
  17087. */
  17088. playTimes: number;
  17089. /**
  17090. * @language zh_CN
  17091. * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17092. * @default 1
  17093. * @version DragonBones 3.0
  17094. */
  17095. timeScale: number;
  17096. /**
  17097. * @language zh_CN
  17098. * 进行动画混合时的权重。
  17099. * @default 1
  17100. * @version DragonBones 3.0
  17101. */
  17102. weight: number;
  17103. /**
  17104. * @language zh_CN
  17105. * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位)
  17106. * @default -1
  17107. * @version DragonBones 3.0
  17108. */
  17109. autoFadeOutTime: number;
  17110. /**
  17111. * @private
  17112. */
  17113. fadeTotalTime: number;
  17114. /**
  17115. * @private
  17116. */
  17117. private _isPlaying;
  17118. /**
  17119. * @private
  17120. */
  17121. private _isPausePlayhead;
  17122. /**
  17123. * @private
  17124. */
  17125. private _fadeTime;
  17126. /**
  17127. * @private
  17128. */
  17129. private _time;
  17130. /**
  17131. * @private
  17132. */
  17133. private _name;
  17134. /**
  17135. * @private
  17136. */
  17137. private _armature;
  17138. /**
  17139. * @private
  17140. */
  17141. private _animationData;
  17142. /**
  17143. * @private
  17144. */
  17145. private _zOrderTimeline;
  17146. /**
  17147. * @private
  17148. */
  17149. private _boneMask;
  17150. /**
  17151. * @private
  17152. */
  17153. private _boneTimelines;
  17154. /**
  17155. * @private
  17156. */
  17157. private _slotTimelines;
  17158. /**
  17159. * @private
  17160. */
  17161. private _ffdTimelines;
  17162. /**
  17163. * @inheritDoc
  17164. */
  17165. protected _onClear(): void;
  17166. private _updateTimelineStates();
  17167. private _advanceFadeTime(passedTime);
  17168. /**
  17169. * @language zh_CN
  17170. * 继续播放。
  17171. * @version DragonBones 3.0
  17172. */
  17173. play(): void;
  17174. /**
  17175. * @language zh_CN
  17176. * 暂停播放。
  17177. * @version DragonBones 3.0
  17178. */
  17179. stop(): void;
  17180. /**
  17181. * @language zh_CN
  17182. * 淡出动画。
  17183. * @param fadeOutTime 淡出时间。 (以秒为单位)
  17184. * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停]
  17185. * @version DragonBones 3.0
  17186. */
  17187. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  17188. /**
  17189. * @language zh_CN
  17190. * 是否包含指定的骨骼遮罩。
  17191. * @param name 指定的骨骼名称。
  17192. * @version DragonBones 3.0
  17193. */
  17194. containsBoneMask(name: string): boolean;
  17195. /**
  17196. * @language zh_CN
  17197. * 添加指定的骨骼遮罩。
  17198. * @param boneName 指定的骨骼名称。
  17199. * @param recursive 是否为该骨骼的子骨骼添加遮罩。
  17200. * @version DragonBones 3.0
  17201. */
  17202. addBoneMask(name: string, recursive?: boolean): void;
  17203. /**
  17204. * @language zh_CN
  17205. * 删除指定的骨骼遮罩。
  17206. * @param boneName 指定的骨骼名称。
  17207. * @param recursive 是否删除该骨骼的子骨骼遮罩。
  17208. * @version DragonBones 3.0
  17209. */
  17210. removeBoneMask(name: string, recursive?: boolean): void;
  17211. /**
  17212. * @language zh_CN
  17213. * 删除所有骨骼遮罩。
  17214. * @version DragonBones 3.0
  17215. */
  17216. removeAllBoneMask(): void;
  17217. /**
  17218. * @language zh_CN
  17219. * 动画图层。
  17220. * @see dragonBones.Animation#fadeIn()
  17221. * @version DragonBones 3.0
  17222. */
  17223. layer: number;
  17224. /**
  17225. * @language zh_CN
  17226. * 动画组。
  17227. * @see dragonBones.Animation#fadeIn()
  17228. * @version DragonBones 3.0
  17229. */
  17230. group: string;
  17231. /**
  17232. * @language zh_CN
  17233. * 动画名称。
  17234. * @see dragonBones.AnimationData#name
  17235. * @version DragonBones 3.0
  17236. */
  17237. name: string;
  17238. /**
  17239. * @language zh_CN
  17240. * 动画数据。
  17241. * @see dragonBones.AnimationData
  17242. * @version DragonBones 3.0
  17243. */
  17244. animationData: AnimationData;
  17245. /**
  17246. * @language zh_CN
  17247. * 是否播放完毕。
  17248. * @version DragonBones 3.0
  17249. */
  17250. isCompleted: boolean;
  17251. /**
  17252. * @language zh_CN
  17253. * 是否正在播放。
  17254. * @version DragonBones 3.0
  17255. */
  17256. isPlaying: boolean;
  17257. /**
  17258. * @language zh_CN
  17259. * 当前动画的播放次数。
  17260. * @version DragonBones 3.0
  17261. */
  17262. currentPlayTimes: number;
  17263. /**
  17264. * @language zh_CN
  17265. * 当前动画的总时间。 (以秒为单位)
  17266. * @version DragonBones 3.0
  17267. */
  17268. totalTime: number;
  17269. /**
  17270. * @language zh_CN
  17271. * 当前动画的播放时间。 (以秒为单位)
  17272. * @version DragonBones 3.0
  17273. */
  17274. currentTime: number;
  17275. /**
  17276. * @deprecated
  17277. */
  17278. autoTween: boolean;
  17279. /**
  17280. * @deprecated
  17281. * @see #animationData
  17282. */
  17283. clip: AnimationData;
  17284. }
  17285. }
  17286. declare namespace dragonBones {
  17287. }
  17288. declare namespace dragonBones {
  17289. /**
  17290. * @language zh_CN
  17291. * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。
  17292. * @see dragonBones.IAnimatable
  17293. * @see dragonBones.Armature
  17294. * @version DragonBones 3.0
  17295. */
  17296. class WorldClock implements IAnimateble {
  17297. private static _clock;
  17298. /**
  17299. * @language zh_CN
  17300. * 一个可以直接使用的全局 WorldClock 实例.
  17301. * @version DragonBones 3.0
  17302. */
  17303. static clock: WorldClock;
  17304. /**
  17305. * @language zh_CN
  17306. * 当前的时间。 (以秒为单位)
  17307. * @version DragonBones 3.0
  17308. */
  17309. time: number;
  17310. /**
  17311. * @language zh_CN
  17312. * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17313. * @default 1
  17314. * @version DragonBones 3.0
  17315. */
  17316. timeScale: number;
  17317. private _animatebles;
  17318. /**
  17319. * @language zh_CN
  17320. * 创建一个新的 WorldClock 实例。
  17321. * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。
  17322. * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放)
  17323. * @version DragonBones 3.0
  17324. */
  17325. constructor();
  17326. /**
  17327. * @language zh_CN
  17328. * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用)
  17329. * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差)
  17330. * @version DragonBones 3.0
  17331. */
  17332. advanceTime(passedTime: number): void;
  17333. /**
  17334. * 是否包含指定的 IAnimatable 实例
  17335. * @param value 指定的 IAnimatable 实例。
  17336. * @returns [true: 包含,false: 不包含]。
  17337. * @version DragonBones 3.0
  17338. */
  17339. contains(value: IAnimateble): boolean;
  17340. /**
  17341. * @language zh_CN
  17342. * 添加指定的 IAnimatable 实例。
  17343. * @param value IAnimatable 实例。
  17344. * @version DragonBones 3.0
  17345. */
  17346. add(value: IAnimateble): void;
  17347. /**
  17348. * @language zh_CN
  17349. * 移除指定的 IAnimatable 实例。
  17350. * @param value IAnimatable 实例。
  17351. * @version DragonBones 3.0
  17352. */
  17353. remove(value: IAnimateble): void;
  17354. /**
  17355. * @language zh_CN
  17356. * 清除所有的 IAnimatable 实例。
  17357. * @version DragonBones 3.0
  17358. */
  17359. clear(): void;
  17360. }
  17361. }
  17362. declare namespace dragonBones {
  17363. /**
  17364. * @language zh_CN
  17365. * 基础变换对象。
  17366. * @version DragonBones 4.5
  17367. */
  17368. abstract class TransformObject extends BaseObject {
  17369. /**
  17370. * @language zh_CN
  17371. * 可以用于存储临时数据。
  17372. * @version DragonBones 3.0
  17373. */
  17374. userData: any;
  17375. /**
  17376. * @language zh_CN
  17377. * 对象的名称。
  17378. * @version DragonBones 3.0
  17379. */
  17380. name: string;
  17381. /**
  17382. * @language zh_CN
  17383. * 相对于骨架坐标系的矩阵。
  17384. * @version DragonBones 3.0
  17385. */
  17386. globalTransformMatrix: Matrix;
  17387. /**
  17388. * @language zh_CN
  17389. * 相对于骨架坐标系的变换。
  17390. * @see dragonBones.Transform
  17391. * @version DragonBones 3.0
  17392. */
  17393. global: Transform;
  17394. /**
  17395. * @language zh_CN
  17396. * 相对于骨架或父骨骼坐标系的绑定变换。
  17397. * @see dragonBones.Transform
  17398. * @version DragonBones 3.0
  17399. */
  17400. origin: Transform;
  17401. /**
  17402. * @language zh_CN
  17403. * 相对于骨架或父骨骼坐标系的偏移变换。
  17404. * @see dragonBones.Transform
  17405. * @version DragonBones 3.0
  17406. */
  17407. offset: Transform;
  17408. /**
  17409. * @private
  17410. */
  17411. _armature: Armature;
  17412. /**
  17413. * @private
  17414. */
  17415. _parent: Bone;
  17416. /**
  17417. * @private
  17418. */
  17419. protected _globalTransformMatrix: Matrix;
  17420. /**
  17421. * @inheritDoc
  17422. */
  17423. protected _onClear(): void;
  17424. /**
  17425. * @language zh_CN
  17426. * 所属的骨架。
  17427. * @see dragonBones.Armature
  17428. * @version DragonBones 3.0
  17429. */
  17430. armature: Armature;
  17431. /**
  17432. * @language zh_CN
  17433. * 所属的父骨骼。
  17434. * @see dragonBones.Bone
  17435. * @version DragonBones 3.0
  17436. */
  17437. parent: Bone;
  17438. }
  17439. }
  17440. declare namespace dragonBones {
  17441. /**
  17442. * @language zh_CN
  17443. * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。
  17444. * @see dragonBones.ArmatureData
  17445. * @see dragonBones.Bone
  17446. * @see dragonBones.Slot
  17447. * @see dragonBones.Animation
  17448. * @see dragonBones.IArmatureDisplay
  17449. * @version DragonBones 3.0
  17450. */
  17451. class Armature extends BaseObject implements IAnimateble {
  17452. /**
  17453. * @private
  17454. */
  17455. static toString(): string;
  17456. private static _onSortSlots(a, b);
  17457. /**
  17458. * @language zh_CN
  17459. * 可以用于存储临时数据。
  17460. * @version DragonBones 3.0
  17461. */
  17462. userData: any;
  17463. /**
  17464. * @private
  17465. */
  17466. _cacheFrameIndex: number;
  17467. /**
  17468. * @private
  17469. */
  17470. _armatureData: ArmatureData;
  17471. /**
  17472. * @private
  17473. */
  17474. _skinData: SkinData;
  17475. /**
  17476. * @private
  17477. */
  17478. _animation: Animation;
  17479. /**
  17480. * @private
  17481. */
  17482. _display: IArmatureDisplay;
  17483. /**
  17484. * @private
  17485. */
  17486. _eventManager: IEventDispatcher;
  17487. private _delayDispose;
  17488. private _lockDispose;
  17489. private _slotsDirty;
  17490. private _replacedTexture;
  17491. private _bones;
  17492. private _slots;
  17493. private _actions;
  17494. private _events;
  17495. /**
  17496. * @inheritDoc
  17497. */
  17498. protected _onClear(): void;
  17499. private _sortBones();
  17500. private _sortSlots();
  17501. private _doAction(value);
  17502. /**
  17503. * @private
  17504. */
  17505. _sortZOrder(slotIndices: Array<number>): void;
  17506. /**
  17507. * @private
  17508. */
  17509. _bufferAction(value: ActionData): void;
  17510. /**
  17511. * @language zh_CN
  17512. * 释放骨架。 (会回收到内存池)
  17513. * @version DragonBones 3.0
  17514. */
  17515. dispose(): void;
  17516. /**
  17517. * @language zh_CN
  17518. * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新)
  17519. * @param passedTime 两帧之前的时间间隔。 (以秒为单位)
  17520. * @see dragonBones.IAnimateble
  17521. * @see dragonBones.WorldClock
  17522. * @see dragonBones.IArmatureDisplay
  17523. * @version DragonBones 3.0
  17524. */
  17525. advanceTime(passedTime: number): void;
  17526. /**
  17527. * @language zh_CN
  17528. * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17529. * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。
  17530. * @param updateSlotDisplay 是否更新插槽的显示对象。
  17531. * @see dragonBones.Bone
  17532. * @see dragonBones.Slot
  17533. * @version DragonBones 3.0
  17534. */
  17535. invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void;
  17536. /**
  17537. * @language zh_CN
  17538. * 获取指定名称的骨骼。
  17539. * @param name 骨骼的名称。
  17540. * @returns 骨骼。
  17541. * @see dragonBones.Bone
  17542. * @version DragonBones 3.0
  17543. */
  17544. getBone(name: string): Bone;
  17545. /**
  17546. * @language zh_CN
  17547. * 通过显示对象获取骨骼。
  17548. * @param display 显示对象。
  17549. * @returns 包含这个显示对象的骨骼。
  17550. * @see dragonBones.Bone
  17551. * @version DragonBones 3.0
  17552. */
  17553. getBoneByDisplay(display: any): Bone;
  17554. /**
  17555. * @language zh_CN
  17556. * 获取指定名称的插槽。
  17557. * @param name 插槽的名称。
  17558. * @returns 插槽。
  17559. * @see dragonBones.Slot
  17560. * @version DragonBones 3.0
  17561. */
  17562. getSlot(name: string): Slot;
  17563. /**
  17564. * @language zh_CN
  17565. * 通过显示对象获取插槽。
  17566. * @param display 显示对象。
  17567. * @returns 包含这个显示对象的插槽。
  17568. * @see dragonBones.Slot
  17569. * @version DragonBones 3.0
  17570. */
  17571. getSlotByDisplay(display: any): Slot;
  17572. /**
  17573. * @language zh_CN
  17574. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17575. * @param texture 贴图。
  17576. * @version DragonBones 4.5
  17577. */
  17578. replaceTexture(texture: any): void;
  17579. /**
  17580. * @language zh_CN
  17581. * 获取所有骨骼。
  17582. * @see dragonBones.Bone
  17583. * @version DragonBones 3.0
  17584. */
  17585. getBones(): Array<Bone>;
  17586. /**
  17587. * @language zh_CN
  17588. * 获取所有插槽。
  17589. * @see dragonBones.Slot
  17590. * @version DragonBones 3.0
  17591. */
  17592. getSlots(): Array<Slot>;
  17593. /**
  17594. * @language zh_CN
  17595. * 骨架名称。
  17596. * @see dragonBones.ArmatureData#name
  17597. * @version DragonBones 3.0
  17598. */
  17599. name: string;
  17600. /**
  17601. * @language zh_CN
  17602. * 获取骨架数据。
  17603. * @see dragonBones.ArmatureData
  17604. * @version DragonBones 4.5
  17605. */
  17606. armatureData: ArmatureData;
  17607. /**
  17608. * @language zh_CN
  17609. * 获得动画控制器。
  17610. * @see dragonBones.Animation
  17611. * @version DragonBones 3.0
  17612. */
  17613. animation: Animation;
  17614. /**
  17615. * @language zh_CN
  17616. * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  17617. * @version DragonBones 3.0
  17618. */
  17619. display: IArmatureDisplay | any;
  17620. /**
  17621. * @language zh_CN
  17622. * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系)
  17623. * @see dragonBones.Slot
  17624. * @version DragonBones 4.5
  17625. */
  17626. parent: Slot;
  17627. /**
  17628. * @language zh_CN
  17629. * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。
  17630. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  17631. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  17632. * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。
  17633. * @see dragonBones.DragonBonesData#frameRate
  17634. * @see dragonBones.ArmatureData#frameRate
  17635. * @version DragonBones 4.5
  17636. */
  17637. cacheFrameRate: number;
  17638. /**
  17639. * @language zh_CN
  17640. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17641. * @version DragonBones 4.5
  17642. */
  17643. replacedTexture: any;
  17644. /**
  17645. * @language zh_CN
  17646. * 开启动画缓存。
  17647. * @param frameRate 动画缓存的帧率
  17648. * @see #cacheFrameRate
  17649. * @version DragonBones 4.5
  17650. */
  17651. enableAnimationCache(frameRate: number): void;
  17652. /**
  17653. * @language zh_CN
  17654. * 是否包含指定类型的事件。
  17655. * @param type 事件类型。
  17656. * @returns [true: 包含, false: 不包含]
  17657. * @version DragonBones 3.0
  17658. */
  17659. hasEventListener(type: EventStringType): void;
  17660. /**
  17661. * @language zh_CN
  17662. * 添加事件。
  17663. * @param type 事件类型。
  17664. * @param listener 事件回调。
  17665. * @version DragonBones 3.0
  17666. */
  17667. addEventListener(type: EventStringType, listener: Function, target: any): void;
  17668. /**
  17669. * @language zh_CN
  17670. * 移除事件。
  17671. * @param type 事件类型。
  17672. * @param listener 事件回调。
  17673. * @version DragonBones 3.0
  17674. */
  17675. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  17676. /**
  17677. * @deprecated
  17678. */
  17679. addBone(value: Bone, parentName?: string): void;
  17680. /**
  17681. * @deprecated
  17682. */
  17683. addSlot(value: Slot, parentName: string): void;
  17684. /**
  17685. * @deprecated
  17686. */
  17687. removeBone(value: Bone): void;
  17688. /**
  17689. * @deprecated
  17690. */
  17691. removeSlot(value: Slot): void;
  17692. /**
  17693. * @deprecated
  17694. * @see #display
  17695. */
  17696. getDisplay(): any;
  17697. /**
  17698. * @deprecated
  17699. * @see #cacheFrameRate
  17700. */
  17701. enableCache: boolean;
  17702. }
  17703. }
  17704. declare namespace dragonBones {
  17705. /**
  17706. * @language zh_CN
  17707. * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。
  17708. * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。
  17709. * @see dragonBones.BoneData
  17710. * @see dragonBones.Armature
  17711. * @see dragonBones.Slot
  17712. * @version DragonBones 3.0
  17713. */
  17714. class Bone extends TransformObject {
  17715. /**
  17716. * @private
  17717. */
  17718. static toString(): string;
  17719. /**
  17720. * @language zh_CN
  17721. * 是否继承父骨骼的平移。 [true: 继承, false: 不继承]
  17722. * @version DragonBones 3.0
  17723. */
  17724. inheritTranslation: boolean;
  17725. /**
  17726. * @language zh_CN
  17727. * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承]
  17728. * @version DragonBones 3.0
  17729. */
  17730. inheritRotation: boolean;
  17731. /**
  17732. * @language zh_CN
  17733. * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承]
  17734. * @version DragonBones 4.5
  17735. */
  17736. inheritScale: boolean;
  17737. /**
  17738. * @language zh_CN
  17739. * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针]
  17740. * @version DragonBones 4.5
  17741. */
  17742. ikBendPositive: boolean;
  17743. /**
  17744. * @language zh_CN
  17745. * IK 约束的权重。
  17746. * @version DragonBones 4.5
  17747. */
  17748. ikWeight: number;
  17749. /**
  17750. * @language zh_CN
  17751. * 骨骼长度。
  17752. * @version DragonBones 4.5
  17753. */
  17754. length: number;
  17755. /**
  17756. * @private
  17757. */
  17758. private _visible;
  17759. /**
  17760. * @private
  17761. */
  17762. private _ikChain;
  17763. /**
  17764. * @private
  17765. */
  17766. private _ikChainIndex;
  17767. /**
  17768. * @private
  17769. */
  17770. private _ik;
  17771. /**
  17772. * @private
  17773. */
  17774. private _bones;
  17775. /**
  17776. * @private
  17777. */
  17778. private _slots;
  17779. /**
  17780. * @inheritDoc
  17781. */
  17782. protected _onClear(): void;
  17783. /**
  17784. * @private
  17785. */
  17786. private _updateGlobalTransformMatrix();
  17787. /**
  17788. * @private
  17789. */
  17790. private _computeIKA();
  17791. /**
  17792. * @private
  17793. */
  17794. private _computeIKB();
  17795. /**
  17796. * @inheritDoc
  17797. */
  17798. _setArmature(value: Armature): void;
  17799. /**
  17800. * @language zh_CN
  17801. * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17802. * @version DragonBones 3.0
  17803. */
  17804. invalidUpdate(): void;
  17805. /**
  17806. * @language zh_CN
  17807. * 是否包含某个指定的骨骼或插槽。
  17808. * @returns [true: 包含,false: 不包含]
  17809. * @see dragonBones.TransformObject
  17810. * @version DragonBones 3.0
  17811. */
  17812. contains(child: TransformObject): boolean;
  17813. /**
  17814. * @language zh_CN
  17815. * 所有的子骨骼。
  17816. * @version DragonBones 3.0
  17817. */
  17818. getBones(): Array<Bone>;
  17819. /**
  17820. * @language zh_CN
  17821. * 所有的插槽。
  17822. * @see dragonBones.Slot
  17823. * @version DragonBones 3.0
  17824. */
  17825. getSlots(): Array<Slot>;
  17826. /**
  17827. * @private
  17828. */
  17829. ikChain: number;
  17830. /**
  17831. * @private
  17832. */
  17833. ikChainIndex: number;
  17834. /**
  17835. * @language zh_CN
  17836. * 当前的 IK 约束目标。
  17837. * @version DragonBones 4.5
  17838. */
  17839. ik: Bone;
  17840. /**
  17841. * @language zh_CN
  17842. * 控制此骨骼所有插槽的显示。
  17843. * @default true
  17844. * @see dragonBones.Slot
  17845. * @version DragonBones 3.0
  17846. */
  17847. visible: boolean;
  17848. /**
  17849. * @deprecated
  17850. * @see dragonBones.Armature#getSlot()
  17851. */
  17852. slot: Slot;
  17853. }
  17854. }
  17855. declare namespace dragonBones {
  17856. /**
  17857. * @language zh_CN
  17858. * 骨架显示容器和事件的接口。
  17859. * @see dragonBones.Armature#display
  17860. * @version DragonBones 4.5
  17861. */
  17862. interface IArmatureDisplay extends IEventDispatcher {
  17863. /**
  17864. * @language zh_CN
  17865. * 释放显示对象和骨架。
  17866. * @version DragonBones 4.5
  17867. */
  17868. dispose(): void;
  17869. /**
  17870. * @language zh_CN
  17871. * 获取使用这个显示容器的骨架。
  17872. * @readOnly
  17873. * @see dragonBones.Armature
  17874. * @version DragonBones 4.5
  17875. */
  17876. armature: Armature;
  17877. /**
  17878. * @language zh_CN
  17879. * 获取使用骨架的动画控制器。
  17880. * @readOnly
  17881. * @see dragonBones.Animation
  17882. * @version DragonBones 4.5
  17883. */
  17884. animation: Animation;
  17885. /**
  17886. * @language zh_CN
  17887. * 由显示容器来更新骨架和动画。
  17888. * @param on 开启或关闭显示容器对骨架与动画的更新。
  17889. * @version DragonBones 4.5
  17890. */
  17891. advanceTimeBySelf(on: boolean): void;
  17892. }
  17893. }
  17894. declare namespace dragonBones {
  17895. /**
  17896. * @language zh_CN
  17897. * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。
  17898. * 一个骨骼上可以包含多个插槽。
  17899. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  17900. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  17901. * @see dragonBones.Armature
  17902. * @see dragonBones.Bone
  17903. * @see dragonBones.SlotData
  17904. * @version DragonBones 3.0
  17905. */
  17906. abstract class Slot extends TransformObject {
  17907. private static _helpPoint;
  17908. private static _helpMatrix;
  17909. /**
  17910. * @language zh_CN
  17911. * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承]
  17912. * @default true
  17913. * @version DragonBones 4.5
  17914. */
  17915. inheritAnimation: boolean;
  17916. /**
  17917. * @language zh_CN
  17918. * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。
  17919. * @default null
  17920. * @see dragonBones.AnimationState#displayControl
  17921. * @see dragonBones.AnimationState#name
  17922. * @see dragonBones.AnimationState#group
  17923. * @version DragonBones 4.5
  17924. */
  17925. displayController: string;
  17926. /**
  17927. * @private
  17928. */
  17929. _zOrder: number;
  17930. /**
  17931. * @private
  17932. */
  17933. _pivotX: number;
  17934. /**
  17935. * @private
  17936. */
  17937. _pivotY: number;
  17938. /**
  17939. * @private
  17940. */
  17941. _displayDataSet: SlotDisplayDataSet;
  17942. /**
  17943. * @private
  17944. */
  17945. _meshData: MeshData;
  17946. /**
  17947. * @private
  17948. */
  17949. _childArmature: Armature;
  17950. /**
  17951. * @private
  17952. */
  17953. _rawDisplay: any;
  17954. /**
  17955. * @private
  17956. */
  17957. _meshDisplay: any;
  17958. /**
  17959. * @private
  17960. */
  17961. _cacheFrames: Array<Matrix>;
  17962. /**
  17963. * @private
  17964. */
  17965. _colorTransform: ColorTransform;
  17966. /**
  17967. * @private
  17968. */
  17969. _ffdVertices: Array<number>;
  17970. /**
  17971. * @private
  17972. */
  17973. _replacedDisplayDataSet: Array<DisplayData>;
  17974. /**
  17975. * @private
  17976. */
  17977. protected _displayDirty: boolean;
  17978. /**
  17979. * @private
  17980. */
  17981. protected _blendModeDirty: boolean;
  17982. /**
  17983. * @private
  17984. */
  17985. protected _originDirty: boolean;
  17986. /**
  17987. * @private
  17988. */
  17989. protected _transformDirty: boolean;
  17990. /**
  17991. * @private
  17992. */
  17993. protected _displayIndex: number;
  17994. /**
  17995. * @private
  17996. */
  17997. protected _blendMode: BlendMode;
  17998. /**
  17999. * @private
  18000. */
  18001. protected _display: any;
  18002. /**
  18003. * @private
  18004. */
  18005. protected _localMatrix: Matrix;
  18006. /**
  18007. * @private
  18008. */
  18009. protected _displayList: Array<any | Armature>;
  18010. /**
  18011. * @private
  18012. */
  18013. protected _meshBones: Array<Bone>;
  18014. /**
  18015. * @inheritDoc
  18016. */
  18017. protected _onClear(): void;
  18018. /**
  18019. * @private
  18020. */
  18021. protected abstract _initDisplay(value: any): void;
  18022. /**
  18023. * @private
  18024. */
  18025. protected abstract _disposeDisplay(value: any): void;
  18026. /**
  18027. * @private
  18028. */
  18029. protected abstract _onUpdateDisplay(): void;
  18030. /**
  18031. * @private
  18032. */
  18033. protected abstract _addDisplay(): void;
  18034. /**
  18035. * @private
  18036. */
  18037. protected abstract _replaceDisplay(value: any): void;
  18038. /**
  18039. * @private
  18040. */
  18041. protected abstract _removeDisplay(): void;
  18042. /**
  18043. * @private
  18044. */
  18045. protected abstract _updateZOrder(): void;
  18046. /**
  18047. * @private
  18048. */
  18049. protected abstract _updateBlendMode(): void;
  18050. /**
  18051. * @private
  18052. */
  18053. protected abstract _updateColor(): void;
  18054. /**
  18055. * @private
  18056. */
  18057. protected abstract _updateFilters(): void;
  18058. /**
  18059. * @private
  18060. */
  18061. protected abstract _updateFrame(): void;
  18062. /**
  18063. * @private
  18064. */
  18065. protected abstract _updateMesh(): void;
  18066. /**
  18067. * @private
  18068. */
  18069. protected abstract _updateTransform(): void;
  18070. private _isMeshBonesUpdate();
  18071. /**
  18072. * @private
  18073. */
  18074. protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void;
  18075. /**
  18076. * @private
  18077. */
  18078. protected _updateDisplay(): void;
  18079. /**
  18080. * @private
  18081. */
  18082. protected _updateLocalTransformMatrix(): void;
  18083. /**
  18084. * @private
  18085. */
  18086. protected _updateGlobalTransformMatrix(): void;
  18087. /**
  18088. * @private Factory
  18089. */
  18090. _setDisplayList(value: Array<any>): boolean;
  18091. /**
  18092. * @language zh_CN
  18093. * 在下一帧更新显示对象的状态。
  18094. * @version DragonBones 4.5
  18095. */
  18096. invalidUpdate(): void;
  18097. /**
  18098. * @private
  18099. */
  18100. rawDisplay: any;
  18101. /**
  18102. * @private
  18103. */
  18104. MeshDisplay: any;
  18105. /**
  18106. * @language zh_CN
  18107. * 此时显示的显示对象在显示列表中的索引。
  18108. * @version DragonBones 4.5
  18109. */
  18110. displayIndex: number;
  18111. /**
  18112. * @language zh_CN
  18113. * 包含显示对象或子骨架的显示列表。
  18114. * @version DragonBones 3.0
  18115. */
  18116. displayList: Array<any>;
  18117. /**
  18118. * @language zh_CN
  18119. * 此时显示的显示对象。
  18120. * @version DragonBones 3.0
  18121. */
  18122. display: any;
  18123. /**
  18124. * @language zh_CN
  18125. * 此时显示的子骨架。
  18126. * @see dragonBones.Armature
  18127. * @version DragonBones 3.0
  18128. */
  18129. childArmature: Armature;
  18130. /**
  18131. * @deprecated
  18132. * @see #display
  18133. */
  18134. getDisplay(): any;
  18135. /**
  18136. * @deprecated
  18137. * @see #display
  18138. */
  18139. setDisplay(value: any): void;
  18140. }
  18141. }
  18142. declare namespace dragonBones {
  18143. /**
  18144. * @private
  18145. */
  18146. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  18147. /**
  18148. * @language zh_CN
  18149. * 事件接口。
  18150. * @version DragonBones 4.5
  18151. */
  18152. interface IEventDispatcher {
  18153. /**
  18154. * @language zh_CN
  18155. * 是否包含指定类型的事件。
  18156. * @param type 事件类型。
  18157. * @returns [true: 包含, false: 不包含]
  18158. * @version DragonBones 4.5
  18159. */
  18160. hasEvent(type: EventStringType): boolean;
  18161. /**
  18162. * @language zh_CN
  18163. * 添加事件。
  18164. * @param type 事件类型。
  18165. * @param listener 事件回调。
  18166. * @version DragonBones 4.5
  18167. */
  18168. addEvent(type: EventStringType, listener: Function, target: any): void;
  18169. /**
  18170. * @language zh_CN
  18171. * 移除事件。
  18172. * @param type 事件类型。
  18173. * @param listener 事件回调。
  18174. * @version DragonBones 4.5
  18175. */
  18176. removeEvent(type: EventStringType, listener: Function, target: any): void;
  18177. }
  18178. /**
  18179. * @language zh_CN
  18180. * 事件数据。
  18181. * @version DragonBones 4.5
  18182. */
  18183. class EventObject extends BaseObject {
  18184. /**
  18185. * @language zh_CN
  18186. * 动画开始。
  18187. * @version DragonBones 4.5
  18188. */
  18189. static START: string;
  18190. /**
  18191. * @language zh_CN
  18192. * 动画循环播放一次完成。
  18193. * @version DragonBones 4.5
  18194. */
  18195. static LOOP_COMPLETE: string;
  18196. /**
  18197. * @language zh_CN
  18198. * 动画播放完成。
  18199. * @version DragonBones 4.5
  18200. */
  18201. static COMPLETE: string;
  18202. /**
  18203. * @language zh_CN
  18204. * 动画淡入开始。
  18205. * @version DragonBones 4.5
  18206. */
  18207. static FADE_IN: string;
  18208. /**
  18209. * @language zh_CN
  18210. * 动画淡入完成。
  18211. * @version DragonBones 4.5
  18212. */
  18213. static FADE_IN_COMPLETE: string;
  18214. /**
  18215. * @language zh_CN
  18216. * 动画淡出开始。
  18217. * @version DragonBones 4.5
  18218. */
  18219. static FADE_OUT: string;
  18220. /**
  18221. * @language zh_CN
  18222. * 动画淡出完成。
  18223. * @version DragonBones 4.5
  18224. */
  18225. static FADE_OUT_COMPLETE: string;
  18226. /**
  18227. * @language zh_CN
  18228. * 动画帧事件。
  18229. * @version DragonBones 4.5
  18230. */
  18231. static FRAME_EVENT: string;
  18232. /**
  18233. * @language zh_CN
  18234. * 动画声音事件。
  18235. * @version DragonBones 4.5
  18236. */
  18237. static SOUND_EVENT: string;
  18238. /**
  18239. * @private
  18240. */
  18241. static toString(): string;
  18242. /**
  18243. * @language zh_CN
  18244. * 事件类型。
  18245. * @version DragonBones 4.5
  18246. */
  18247. type: EventStringType;
  18248. /**
  18249. * @language zh_CN
  18250. * 事件名称。 (帧标签的名称或声音的名称)
  18251. * @version DragonBones 4.5
  18252. */
  18253. name: string;
  18254. /**
  18255. * @language zh_CN
  18256. * 扩展的数据。
  18257. * @version DragonBones 4.5
  18258. */
  18259. data: any;
  18260. /**
  18261. * @language zh_CN
  18262. * 发出事件的骨架。
  18263. * @version DragonBones 4.5
  18264. */
  18265. armature: Armature;
  18266. /**
  18267. * @language zh_CN
  18268. * 发出事件的骨骼。
  18269. * @version DragonBones 4.5
  18270. */
  18271. bone: Bone;
  18272. /**
  18273. * @language zh_CN
  18274. * 发出事件的插槽。
  18275. * @version DragonBones 4.5
  18276. */
  18277. slot: Slot;
  18278. /**
  18279. * @language zh_CN
  18280. * 发出事件的动画状态。
  18281. * @version DragonBones 4.5
  18282. */
  18283. animationState: AnimationState;
  18284. /**
  18285. * @private
  18286. */
  18287. frame: AnimationFrameData;
  18288. /**
  18289. * @language zh_CN
  18290. * 用户数据。
  18291. * @version DragonBones 4.5
  18292. */
  18293. userData: any;
  18294. /**
  18295. * @inheritDoc
  18296. */
  18297. protected _onClear(): void;
  18298. }
  18299. }
  18300. declare namespace dragonBones {
  18301. /**
  18302. * @private
  18303. */
  18304. class ColorTransform {
  18305. alphaMultiplier: number;
  18306. redMultiplier: number;
  18307. greenMultiplier: number;
  18308. blueMultiplier: number;
  18309. alphaOffset: number;
  18310. redOffset: number;
  18311. greenOffset: number;
  18312. blueOffset: number;
  18313. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  18314. copyFrom(value: ColorTransform): void;
  18315. identity(): void;
  18316. }
  18317. }
  18318. declare namespace dragonBones {
  18319. /**
  18320. * @language zh_CN
  18321. * 2D 矩阵。
  18322. * @version DragonBones 3.0
  18323. */
  18324. class Matrix {
  18325. a: number;
  18326. b: number;
  18327. c: number;
  18328. d: number;
  18329. tx: number;
  18330. ty: number;
  18331. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  18332. /**
  18333. * @private
  18334. */
  18335. toString(): string;
  18336. /**
  18337. * @language zh_CN
  18338. * 复制矩阵。
  18339. * @param value 需要复制的矩阵。
  18340. * @version DragonBones 3.0
  18341. */
  18342. copyFrom(value: Matrix): void;
  18343. /**
  18344. * @language zh_CN
  18345. * 转换为恒等矩阵。
  18346. * @version DragonBones 3.0
  18347. */
  18348. identity(): void;
  18349. /**
  18350. * @language zh_CN
  18351. * 将当前矩阵与另一个矩阵相乘。
  18352. * @param value 需要相乘的矩阵。
  18353. * @version DragonBones 3.0
  18354. */
  18355. concat(value: Matrix): void;
  18356. /**
  18357. * @language zh_CN
  18358. * 转换为逆矩阵。
  18359. * @version DragonBones 3.0
  18360. */
  18361. invert(): void;
  18362. /**
  18363. * @language zh_CN
  18364. * 将矩阵转换应用于指定点。
  18365. * @param x 横坐标。
  18366. * @param y 纵坐标。
  18367. * @param result 应用转换之后的坐标。
  18368. * @params delta 是否忽略 tx,ty 对坐标的转换。
  18369. * @version DragonBones 3.0
  18370. */
  18371. transformPoint(x: number, y: number, result: {
  18372. x: number;
  18373. y: number;
  18374. }, delta?: boolean): void;
  18375. }
  18376. }
  18377. declare namespace dragonBones {
  18378. /**
  18379. * @private
  18380. */
  18381. class Point {
  18382. x: number;
  18383. y: number;
  18384. constructor(x?: number, y?: number);
  18385. copyFrom(value: Point): void;
  18386. clear(): void;
  18387. }
  18388. }
  18389. declare namespace dragonBones {
  18390. /**
  18391. * @private
  18392. */
  18393. class Rectangle {
  18394. x: number;
  18395. y: number;
  18396. width: number;
  18397. height: number;
  18398. constructor(x?: number, y?: number, width?: number, height?: number);
  18399. copyFrom(value: Rectangle): void;
  18400. clear(): void;
  18401. }
  18402. }
  18403. declare namespace dragonBones {
  18404. /**
  18405. * @language zh_CN
  18406. * 2D 变换。
  18407. * @version DragonBones 3.0
  18408. */
  18409. class Transform {
  18410. /**
  18411. * @language zh_CN
  18412. * 水平位移。
  18413. * @version DragonBones 3.0
  18414. */
  18415. x: number;
  18416. /**
  18417. * @language zh_CN
  18418. * 垂直位移。
  18419. * @version DragonBones 3.0
  18420. */
  18421. y: number;
  18422. /**
  18423. * @language zh_CN
  18424. * 水平倾斜。 (以弧度为单位)
  18425. * @version DragonBones 3.0
  18426. */
  18427. skewX: number;
  18428. /**
  18429. * @language zh_CN
  18430. * 垂直倾斜。 (以弧度为单位)
  18431. * @version DragonBones 3.0
  18432. */
  18433. skewY: number;
  18434. /**
  18435. * @language zh_CN
  18436. * 水平缩放。
  18437. * @version DragonBones 3.0
  18438. */
  18439. scaleX: number;
  18440. /**
  18441. * @language zh_CN
  18442. * 垂直缩放。
  18443. * @version DragonBones 3.0
  18444. */
  18445. scaleY: number;
  18446. /**
  18447. * @private
  18448. */
  18449. static normalizeRadian(value: number): number;
  18450. /**
  18451. * @private
  18452. */
  18453. constructor(
  18454. /**
  18455. * @language zh_CN
  18456. * 水平位移。
  18457. * @version DragonBones 3.0
  18458. */
  18459. x?: number,
  18460. /**
  18461. * @language zh_CN
  18462. * 垂直位移。
  18463. * @version DragonBones 3.0
  18464. */
  18465. y?: number,
  18466. /**
  18467. * @language zh_CN
  18468. * 水平倾斜。 (以弧度为单位)
  18469. * @version DragonBones 3.0
  18470. */
  18471. skewX?: number,
  18472. /**
  18473. * @language zh_CN
  18474. * 垂直倾斜。 (以弧度为单位)
  18475. * @version DragonBones 3.0
  18476. */
  18477. skewY?: number,
  18478. /**
  18479. * @language zh_CN
  18480. * 水平缩放。
  18481. * @version DragonBones 3.0
  18482. */
  18483. scaleX?: number,
  18484. /**
  18485. * @language zh_CN
  18486. * 垂直缩放。
  18487. * @version DragonBones 3.0
  18488. */
  18489. scaleY?: number);
  18490. /**
  18491. * @private
  18492. */
  18493. toString(): string;
  18494. /**
  18495. * @private
  18496. */
  18497. copyFrom(value: Transform): Transform;
  18498. /**
  18499. * @private
  18500. */
  18501. identity(): Transform;
  18502. /**
  18503. * @private
  18504. */
  18505. add(value: Transform): Transform;
  18506. /**
  18507. * @private
  18508. */
  18509. minus(value: Transform): Transform;
  18510. /**
  18511. * @private
  18512. */
  18513. fromMatrix(matrix: Matrix): Transform;
  18514. /**
  18515. * @language zh_CN
  18516. * 转换为矩阵。
  18517. * @param 矩阵。
  18518. * @version DragonBones 3.0
  18519. */
  18520. toMatrix(matrix: Matrix): Transform;
  18521. /**
  18522. * @language zh_CN
  18523. * 旋转。 (以弧度为单位)
  18524. * @version DragonBones 3.0
  18525. */
  18526. rotation: number;
  18527. }
  18528. }
  18529. declare namespace dragonBones {
  18530. /**
  18531. * @private
  18532. */
  18533. abstract class TimelineData<T extends FrameData<T>> extends BaseObject {
  18534. /**
  18535. * @private
  18536. */
  18537. static toString(): string;
  18538. scale: number;
  18539. /**
  18540. * @private
  18541. */
  18542. offset: number;
  18543. /**
  18544. * @private
  18545. */
  18546. frames: Array<T>;
  18547. constructor();
  18548. /**
  18549. * @inheritDoc
  18550. */
  18551. protected _onClear(): void;
  18552. }
  18553. /**
  18554. * @private
  18555. */
  18556. class ZOrderTimelineData extends TimelineData<ZOrderFrameData> {
  18557. static toString(): string;
  18558. }
  18559. /**
  18560. * @private
  18561. */
  18562. class BoneTimelineData extends TimelineData<BoneFrameData> {
  18563. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18564. static toString(): string;
  18565. bone: BoneData;
  18566. originalTransform: Transform;
  18567. cachedFrames: Array<Matrix>;
  18568. constructor();
  18569. /**
  18570. * @inheritDoc
  18571. */
  18572. protected _onClear(): void;
  18573. cacheFrames(cacheFrameCount: number): void;
  18574. }
  18575. /**
  18576. * @private
  18577. */
  18578. class SlotTimelineData extends TimelineData<SlotFrameData> {
  18579. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18580. static toString(): string;
  18581. slot: SlotData;
  18582. cachedFrames: Array<Matrix>;
  18583. constructor();
  18584. /**
  18585. * @inheritDoc
  18586. */
  18587. protected _onClear(): void;
  18588. cacheFrames(cacheFrameCount: number): void;
  18589. }
  18590. /**
  18591. * @private
  18592. */
  18593. class FFDTimelineData extends TimelineData<ExtensionFrameData> {
  18594. static toString(): string;
  18595. displayIndex: number;
  18596. skin: SkinData;
  18597. slot: SlotDisplayDataSet;
  18598. constructor();
  18599. /**
  18600. * @inheritDoc
  18601. */
  18602. protected _onClear(): void;
  18603. }
  18604. }
  18605. declare namespace dragonBones {
  18606. /**
  18607. * @language zh_CN
  18608. * 动画数据。
  18609. * @version DragonBones 3.0
  18610. */
  18611. class AnimationData extends TimelineData<AnimationFrameData> {
  18612. /**
  18613. * @private
  18614. */
  18615. static toString(): string;
  18616. /**
  18617. * @private
  18618. */
  18619. hasAsynchronyTimeline: boolean;
  18620. /**
  18621. * @language zh_CN
  18622. * 持续的帧数。
  18623. * @version DragonBones 3.0
  18624. */
  18625. frameCount: number;
  18626. /**
  18627. * @language zh_CN
  18628. * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  18629. * @version DragonBones 3.0
  18630. */
  18631. playTimes: number;
  18632. /**
  18633. * @language zh_CN
  18634. * 开始的时间。 (以秒为单位)
  18635. * @version DragonBones 3.0
  18636. */
  18637. position: number;
  18638. /**
  18639. * @language zh_CN
  18640. * 持续的时间。 (以秒为单位)
  18641. * @version DragonBones 3.0
  18642. */
  18643. duration: number;
  18644. /**
  18645. * @language zh_CN
  18646. * 淡入混合的时间。 (以秒为单位)
  18647. * @version DragonBones 3.0
  18648. */
  18649. fadeInTime: number;
  18650. /**
  18651. * @private
  18652. */
  18653. cacheTimeToFrameScale: number;
  18654. /**
  18655. * @language zh_CN
  18656. * 数据名称。
  18657. * @version DragonBones 3.0
  18658. */
  18659. name: string;
  18660. /**
  18661. * @private
  18662. */
  18663. animation: AnimationData;
  18664. /**
  18665. * @private
  18666. */
  18667. zOrderTimeline: TimelineData<ZOrderFrameData>;
  18668. /**
  18669. * @private
  18670. */
  18671. boneTimelines: Map<BoneTimelineData>;
  18672. /**
  18673. * @private
  18674. */
  18675. slotTimelines: Map<SlotTimelineData>;
  18676. /**
  18677. * @private
  18678. */
  18679. ffdTimelines: Map<Map<Map<FFDTimelineData>>>;
  18680. /**
  18681. * @private
  18682. */
  18683. cachedFrames: Array<boolean>;
  18684. /**
  18685. * @private
  18686. */
  18687. constructor();
  18688. /**
  18689. * @inheritDoc
  18690. */
  18691. protected _onClear(): void;
  18692. /**
  18693. * @private
  18694. */
  18695. cacheFrames(value: number): void;
  18696. /**
  18697. * @private
  18698. */
  18699. addBoneTimeline(value: BoneTimelineData): void;
  18700. /**
  18701. * @private
  18702. */
  18703. addSlotTimeline(value: SlotTimelineData): void;
  18704. /**
  18705. * @private
  18706. */
  18707. addFFDTimeline(value: FFDTimelineData): void;
  18708. /**
  18709. * @private
  18710. */
  18711. getBoneTimeline(name: string): BoneTimelineData;
  18712. /**
  18713. * @private
  18714. */
  18715. getSlotTimeline(name: string): SlotTimelineData;
  18716. /**
  18717. * @private
  18718. */
  18719. getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData;
  18720. }
  18721. }
  18722. declare namespace dragonBones {
  18723. /**
  18724. * @language zh_CN
  18725. * 骨架数据。
  18726. * @see dragonBones.Armature
  18727. * @version DragonBones 3.0
  18728. */
  18729. class ArmatureData extends BaseObject {
  18730. private static _onSortSlots(a, b);
  18731. /**
  18732. * @private
  18733. */
  18734. static toString(): string;
  18735. /**
  18736. * @language zh_CN
  18737. * 动画帧率。
  18738. * @version DragonBones 3.0
  18739. */
  18740. frameRate: number;
  18741. /**
  18742. * @language zh_CN
  18743. * 骨架类型。
  18744. * @see dragonBones.ArmatureType
  18745. * @version DragonBones 3.0
  18746. */
  18747. type: ArmatureType;
  18748. /**
  18749. * @language zh_CN
  18750. * 数据名称。
  18751. * @version DragonBones 3.0
  18752. */
  18753. name: string;
  18754. /**
  18755. * @private
  18756. */
  18757. parent: DragonBonesData;
  18758. /**
  18759. * @private
  18760. */
  18761. userData: any;
  18762. /**
  18763. * @private
  18764. */
  18765. aabb: Rectangle;
  18766. /**
  18767. * @language zh_CN
  18768. * 所有的骨骼数据。
  18769. * @see dragonBones.BoneData
  18770. * @version DragonBones 3.0
  18771. */
  18772. bones: Map<BoneData>;
  18773. /**
  18774. * @language zh_CN
  18775. * 所有的插槽数据。
  18776. * @see dragonBones.SlotData
  18777. * @version DragonBones 3.0
  18778. */
  18779. slots: Map<SlotData>;
  18780. /**
  18781. * @language zh_CN
  18782. * 所有的皮肤数据。
  18783. * @see dragonBones.SkinData
  18784. * @version DragonBones 3.0
  18785. */
  18786. skins: Map<SkinData>;
  18787. /**
  18788. * @language zh_CN
  18789. * 所有的动画数据。
  18790. * @see dragonBones.AnimationData
  18791. * @version DragonBones 3.0
  18792. */
  18793. animations: Map<AnimationData>;
  18794. /**
  18795. * @private
  18796. */
  18797. actions: Array<ActionData>;
  18798. /**
  18799. * @private
  18800. */
  18801. cacheFrameRate: number;
  18802. /**
  18803. * @private
  18804. */
  18805. scale: number;
  18806. private _boneDirty;
  18807. private _slotDirty;
  18808. private _defaultSkin;
  18809. private _defaultAnimation;
  18810. private _sortedBones;
  18811. private _sortedSlots;
  18812. private _bonesChildren;
  18813. /**
  18814. * @private
  18815. */
  18816. constructor();
  18817. /**
  18818. * @inheritDoc
  18819. */
  18820. protected _onClear(): void;
  18821. private _sortBones();
  18822. private _sortSlots();
  18823. /**
  18824. * @private
  18825. */
  18826. cacheFrames(value: number): void;
  18827. /**
  18828. * @private
  18829. */
  18830. addBone(value: BoneData, parentName: string): void;
  18831. /**
  18832. * @private
  18833. */
  18834. addSlot(value: SlotData): void;
  18835. /**
  18836. * @private
  18837. */
  18838. addSkin(value: SkinData): void;
  18839. /**
  18840. * @private
  18841. */
  18842. addAnimation(value: AnimationData): void;
  18843. /**
  18844. * @language zh_CN
  18845. * 获取指定名称的骨骼数据。
  18846. * @param name 骨骼数据名称。
  18847. * @see dragonBones.BoneData
  18848. * @version DragonBones 3.0
  18849. */
  18850. getBone(name: string): BoneData;
  18851. /**
  18852. * @language zh_CN
  18853. * 获取指定名称的插槽数据。
  18854. * @param name 插槽数据名称。
  18855. * @see dragonBones.SlotData
  18856. * @version DragonBones 3.0
  18857. */
  18858. getSlot(name: string): SlotData;
  18859. /**
  18860. * @language zh_CN
  18861. * 获取指定名称的皮肤数据。
  18862. * @param name 皮肤数据名称。
  18863. * @see dragonBones.SkinData
  18864. * @version DragonBones 3.0
  18865. */
  18866. getSkin(name: string): SkinData;
  18867. /**
  18868. * @language zh_CN
  18869. * 获取指定名称的动画数据。
  18870. * @param name 动画数据名称。
  18871. * @see dragonBones.AnimationData
  18872. * @version DragonBones 3.0
  18873. */
  18874. getAnimation(name: string): AnimationData;
  18875. /**
  18876. * @private
  18877. */
  18878. sortedBones: Array<BoneData>;
  18879. /**
  18880. * @private
  18881. */
  18882. sortedSlots: Array<SlotData>;
  18883. /**
  18884. * @language zh_CN
  18885. * 获取默认的皮肤数据。
  18886. * @see dragonBones.SkinData
  18887. * @version DragonBones 4.5
  18888. */
  18889. defaultSkin: SkinData;
  18890. /**
  18891. * @language zh_CN
  18892. * 获取默认的动画数据。
  18893. * @see dragonBones.AnimationData
  18894. * @version DragonBones 4.5
  18895. */
  18896. defaultAnimation: AnimationData;
  18897. }
  18898. /**
  18899. * @language zh_CN
  18900. * 骨骼数据。
  18901. * @see dragonBones.Bone
  18902. * @version DragonBones 3.0
  18903. */
  18904. class BoneData extends BaseObject {
  18905. /**
  18906. * @private
  18907. */
  18908. static toString(): string;
  18909. /**
  18910. * @private
  18911. */
  18912. inheritTranslation: boolean;
  18913. /**
  18914. * @private
  18915. */
  18916. inheritRotation: boolean;
  18917. /**
  18918. * @private
  18919. */
  18920. inheritScale: boolean;
  18921. /**
  18922. * @private
  18923. */
  18924. bendPositive: boolean;
  18925. /**
  18926. * @private
  18927. */
  18928. chain: number;
  18929. /**
  18930. * @private
  18931. */
  18932. chainIndex: number;
  18933. /**
  18934. * @private
  18935. */
  18936. weight: number;
  18937. /**
  18938. * @private
  18939. */
  18940. length: number;
  18941. /**
  18942. * @language zh_CN
  18943. * 数据名称。
  18944. * @version DragonBones 3.0
  18945. */
  18946. name: string;
  18947. /**
  18948. * @language zh_CN
  18949. * 所属的父骨骼数据。
  18950. * @version DragonBones 3.0
  18951. */
  18952. parent: BoneData;
  18953. /**
  18954. * @private
  18955. */
  18956. ik: BoneData;
  18957. /**
  18958. * @private
  18959. */
  18960. transform: Transform;
  18961. /**
  18962. * @private
  18963. */
  18964. constructor();
  18965. /**
  18966. * @inheritDoc
  18967. */
  18968. protected _onClear(): void;
  18969. }
  18970. /**
  18971. * @language zh_CN
  18972. * 插槽数据。
  18973. * @see dragonBones.Slot
  18974. * @version DragonBones 3.0
  18975. */
  18976. class SlotData extends BaseObject {
  18977. /**
  18978. * @private
  18979. */
  18980. static DEFAULT_COLOR: ColorTransform;
  18981. /**
  18982. * @private
  18983. */
  18984. static generateColor(): ColorTransform;
  18985. /**
  18986. * @private
  18987. */
  18988. static toString(): string;
  18989. /**
  18990. * @private
  18991. */
  18992. displayIndex: number;
  18993. /**
  18994. * @private
  18995. */
  18996. zOrder: number;
  18997. /**
  18998. * @private
  18999. */
  19000. blendMode: BlendMode;
  19001. /**
  19002. * @language zh_CN
  19003. * 数据名称。
  19004. * @version DragonBones 3.0
  19005. */
  19006. name: string;
  19007. /**
  19008. * @language zh_CN
  19009. * 所属的父骨骼数据。
  19010. * @see dragonBones.BoneData
  19011. * @version DragonBones 3.0
  19012. */
  19013. parent: BoneData;
  19014. /**
  19015. * @private
  19016. */
  19017. color: ColorTransform;
  19018. /**
  19019. * @private
  19020. */
  19021. actions: Array<ActionData>;
  19022. /**
  19023. * @private
  19024. */
  19025. constructor();
  19026. /**
  19027. * @inheritDoc
  19028. */
  19029. protected _onClear(): void;
  19030. }
  19031. /**
  19032. * @language zh_CN
  19033. * 皮肤数据。
  19034. * @version DragonBones 3.0
  19035. */
  19036. class SkinData extends BaseObject {
  19037. /**
  19038. * @private
  19039. */
  19040. static toString(): string;
  19041. /**
  19042. * @language zh_CN
  19043. * 数据名称。
  19044. * @version DragonBones 3.0
  19045. */
  19046. name: string;
  19047. /**
  19048. * @private
  19049. */
  19050. slots: Map<SlotDisplayDataSet>;
  19051. /**
  19052. * @private
  19053. */
  19054. constructor();
  19055. /**
  19056. * @inheritDoc
  19057. */
  19058. protected _onClear(): void;
  19059. /**
  19060. * @private
  19061. */
  19062. addSlot(value: SlotDisplayDataSet): void;
  19063. /**
  19064. * @private
  19065. */
  19066. getSlot(name: string): SlotDisplayDataSet;
  19067. }
  19068. /**
  19069. * @private
  19070. */
  19071. class SlotDisplayDataSet extends BaseObject {
  19072. static toString(): string;
  19073. slot: SlotData;
  19074. displays: Array<DisplayData>;
  19075. constructor();
  19076. /**
  19077. * @inheritDoc
  19078. */
  19079. protected _onClear(): void;
  19080. }
  19081. /**
  19082. * @private
  19083. */
  19084. class DisplayData extends BaseObject {
  19085. static toString(): string;
  19086. isRelativePivot: boolean;
  19087. type: DisplayType;
  19088. name: string;
  19089. texture: TextureData;
  19090. armature: ArmatureData;
  19091. mesh: MeshData;
  19092. pivot: Point;
  19093. transform: Transform;
  19094. constructor();
  19095. /**
  19096. * @inheritDoc
  19097. */
  19098. protected _onClear(): void;
  19099. }
  19100. /**
  19101. * @private
  19102. */
  19103. class MeshData extends BaseObject {
  19104. static toString(): string;
  19105. skinned: boolean;
  19106. slotPose: Matrix;
  19107. uvs: Array<number>;
  19108. vertices: Array<number>;
  19109. vertexIndices: Array<number>;
  19110. boneIndices: Array<Array<number>>;
  19111. weights: Array<Array<number>>;
  19112. boneVertices: Array<Array<number>>;
  19113. bones: Array<BoneData>;
  19114. inverseBindPose: Array<Matrix>;
  19115. constructor();
  19116. /**
  19117. * @inheritDoc
  19118. */
  19119. protected _onClear(): void;
  19120. }
  19121. }
  19122. declare namespace dragonBones {
  19123. /**
  19124. * @language zh_CN
  19125. * 龙骨数据,包含多个骨架数据。
  19126. * @see dragonBones.ArmatureData
  19127. * @version DragonBones 3.0
  19128. */
  19129. class DragonBonesData extends BaseObject {
  19130. /**
  19131. * @private
  19132. */
  19133. static toString(): string;
  19134. /**
  19135. * @language zh_CN
  19136. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19137. * @default false
  19138. * @see dragonBones.ArmatureData
  19139. * @version DragonBones 4.5
  19140. */
  19141. autoSearch: boolean;
  19142. /**
  19143. * @language zh_CN
  19144. * 动画帧频。
  19145. * @version DragonBones 3.0
  19146. */
  19147. frameRate: number;
  19148. /**
  19149. * @language zh_CN
  19150. * 数据名称。
  19151. * @version DragonBones 3.0
  19152. */
  19153. name: string;
  19154. /**
  19155. * @language zh_CN
  19156. * 所有的骨架数据。
  19157. * @see dragonBones.ArmatureData
  19158. * @version DragonBones 3.0
  19159. */
  19160. armatures: Map<ArmatureData>;
  19161. private _armatureNames;
  19162. /**
  19163. * @inheritDoc
  19164. */
  19165. protected _onClear(): void;
  19166. /**
  19167. * @language zh_CN
  19168. * 获取指定名称的骨架。
  19169. * @param name 骨架数据骨架名称。
  19170. * @see dragonBones.ArmatureData
  19171. * @version DragonBones 3.0
  19172. */
  19173. getArmature(name: string): ArmatureData;
  19174. /**
  19175. * @language zh_CN
  19176. * 所有的骨架数据名称。
  19177. * @see #armatures
  19178. * @version DragonBones 3.0
  19179. */
  19180. armatureNames: Array<string>;
  19181. /**
  19182. * @deprecated
  19183. * @see dragonBones.BaseFactory#removeDragonBonesData()
  19184. */
  19185. dispose(): void;
  19186. }
  19187. }
  19188. declare namespace dragonBones {
  19189. /**
  19190. * @private
  19191. */
  19192. class ActionData extends BaseObject {
  19193. static toString(): string;
  19194. type: ActionType;
  19195. bone: BoneData;
  19196. slot: SlotData;
  19197. data: Array<any>;
  19198. constructor();
  19199. protected _onClear(): void;
  19200. }
  19201. /**
  19202. * @private
  19203. */
  19204. class EventData extends BaseObject {
  19205. static toString(): string;
  19206. type: EventType;
  19207. name: string;
  19208. data: any;
  19209. bone: BoneData;
  19210. slot: SlotData;
  19211. constructor();
  19212. protected _onClear(): void;
  19213. }
  19214. /**
  19215. * @private
  19216. */
  19217. abstract class FrameData<T> extends BaseObject {
  19218. position: number;
  19219. duration: number;
  19220. prev: T;
  19221. next: T;
  19222. constructor();
  19223. /**
  19224. * @inheritDoc
  19225. */
  19226. protected _onClear(): void;
  19227. }
  19228. /**
  19229. * @private
  19230. */
  19231. abstract class TweenFrameData<T> extends FrameData<T> {
  19232. static samplingCurve(curve: Array<number>, frameCount: number): Array<number>;
  19233. tweenEasing: number;
  19234. curve: Array<number>;
  19235. constructor();
  19236. /**
  19237. * @inheritDoc
  19238. */
  19239. protected _onClear(): void;
  19240. }
  19241. /**
  19242. * @private
  19243. */
  19244. class AnimationFrameData extends FrameData<AnimationFrameData> {
  19245. static toString(): string;
  19246. actions: Array<ActionData>;
  19247. events: Array<EventData>;
  19248. constructor();
  19249. /**
  19250. * @inheritDoc
  19251. */
  19252. protected _onClear(): void;
  19253. }
  19254. /**
  19255. * @private
  19256. */
  19257. class ZOrderFrameData extends FrameData<ZOrderFrameData> {
  19258. zOrder: Array<number>;
  19259. constructor();
  19260. /**
  19261. * @inheritDoc
  19262. */
  19263. protected _onClear(): void;
  19264. }
  19265. /**
  19266. * @private
  19267. */
  19268. class BoneFrameData extends TweenFrameData<BoneFrameData> {
  19269. static toString(): string;
  19270. tweenScale: boolean;
  19271. tweenRotate: number;
  19272. guideCurve: Array<number>;
  19273. transform: Transform;
  19274. constructor();
  19275. /**
  19276. * @inheritDoc
  19277. */
  19278. protected _onClear(): void;
  19279. }
  19280. /**
  19281. * @private
  19282. */
  19283. class SlotFrameData extends TweenFrameData<SlotFrameData> {
  19284. static DEFAULT_COLOR: ColorTransform;
  19285. static generateColor(): ColorTransform;
  19286. static toString(): string;
  19287. displayIndex: number;
  19288. color: ColorTransform;
  19289. constructor();
  19290. /**
  19291. * @inheritDoc
  19292. */
  19293. protected _onClear(): void;
  19294. }
  19295. /**
  19296. * @private
  19297. */
  19298. class ExtensionFrameData extends TweenFrameData<ExtensionFrameData> {
  19299. static toString(): string;
  19300. type: ExtensionType;
  19301. tweens: Array<number>;
  19302. keys: Array<number>;
  19303. constructor();
  19304. /**
  19305. * @inheritDoc
  19306. */
  19307. protected _onClear(): void;
  19308. }
  19309. }
  19310. declare namespace dragonBones {
  19311. /**
  19312. * @private
  19313. */
  19314. abstract class DataParser {
  19315. protected static DATA_VERSION_2_3: string;
  19316. protected static DATA_VERSION_3_0: string;
  19317. protected static DATA_VERSION_4_0: string;
  19318. protected static DATA_VERSION: string;
  19319. protected static TEXTURE_ATLAS: string;
  19320. protected static SUB_TEXTURE: string;
  19321. protected static FORMAT: string;
  19322. protected static IMAGE_PATH: string;
  19323. protected static WIDTH: string;
  19324. protected static HEIGHT: string;
  19325. protected static ROTATED: string;
  19326. protected static FRAME_X: string;
  19327. protected static FRAME_Y: string;
  19328. protected static FRAME_WIDTH: string;
  19329. protected static FRAME_HEIGHT: string;
  19330. protected static DRADON_BONES: string;
  19331. protected static ARMATURE: string;
  19332. protected static BONE: string;
  19333. protected static IK: string;
  19334. protected static SLOT: string;
  19335. protected static SKIN: string;
  19336. protected static DISPLAY: string;
  19337. protected static ANIMATION: string;
  19338. protected static Z_ORDER: string;
  19339. protected static FFD: string;
  19340. protected static FRAME: string;
  19341. protected static PIVOT: string;
  19342. protected static TRANSFORM: string;
  19343. protected static AABB: string;
  19344. protected static COLOR: string;
  19345. protected static FILTER: string;
  19346. protected static VERSION: string;
  19347. protected static IS_GLOBAL: string;
  19348. protected static FRAME_RATE: string;
  19349. protected static TYPE: string;
  19350. protected static NAME: string;
  19351. protected static PARENT: string;
  19352. protected static LENGTH: string;
  19353. protected static DATA: string;
  19354. protected static DISPLAY_INDEX: string;
  19355. protected static BLEND_MODE: string;
  19356. protected static INHERIT_TRANSLATION: string;
  19357. protected static INHERIT_ROTATION: string;
  19358. protected static INHERIT_SCALE: string;
  19359. protected static TARGET: string;
  19360. protected static BEND_POSITIVE: string;
  19361. protected static CHAIN: string;
  19362. protected static WEIGHT: string;
  19363. protected static FADE_IN_TIME: string;
  19364. protected static PLAY_TIMES: string;
  19365. protected static SCALE: string;
  19366. protected static OFFSET: string;
  19367. protected static POSITION: string;
  19368. protected static DURATION: string;
  19369. protected static TWEEN_EASING: string;
  19370. protected static TWEEN_ROTATE: string;
  19371. protected static TWEEN_SCALE: string;
  19372. protected static CURVE: string;
  19373. protected static GUIDE_CURVE: string;
  19374. protected static EVENT: string;
  19375. protected static SOUND: string;
  19376. protected static ACTION: string;
  19377. protected static ACTIONS: string;
  19378. protected static DEFAULT_ACTIONS: string;
  19379. protected static X: string;
  19380. protected static Y: string;
  19381. protected static SKEW_X: string;
  19382. protected static SKEW_Y: string;
  19383. protected static SCALE_X: string;
  19384. protected static SCALE_Y: string;
  19385. protected static ALPHA_OFFSET: string;
  19386. protected static RED_OFFSET: string;
  19387. protected static GREEN_OFFSET: string;
  19388. protected static BLUE_OFFSET: string;
  19389. protected static ALPHA_MULTIPLIER: string;
  19390. protected static RED_MULTIPLIER: string;
  19391. protected static GREEN_MULTIPLIER: string;
  19392. protected static BLUE_MULTIPLIER: string;
  19393. protected static UVS: string;
  19394. protected static VERTICES: string;
  19395. protected static TRIANGLES: string;
  19396. protected static WEIGHTS: string;
  19397. protected static SLOT_POSE: string;
  19398. protected static BONE_POSE: string;
  19399. protected static TWEEN: string;
  19400. protected static KEY: string;
  19401. protected static COLOR_TRANSFORM: string;
  19402. protected static TIMELINE: string;
  19403. protected static PIVOT_X: string;
  19404. protected static PIVOT_Y: string;
  19405. protected static Z: string;
  19406. protected static LOOP: string;
  19407. protected static AUTO_TWEEN: string;
  19408. protected static HIDE: string;
  19409. protected static _getArmatureType(value: string): ArmatureType;
  19410. protected static _getDisplayType(value: string): DisplayType;
  19411. protected static _getBlendMode(value: string): BlendMode;
  19412. protected static _getActionType(value: string): ActionType;
  19413. protected _data: DragonBonesData;
  19414. protected _armature: ArmatureData;
  19415. protected _skin: SkinData;
  19416. protected _slotDisplayDataSet: SlotDisplayDataSet;
  19417. protected _mesh: MeshData;
  19418. protected _animation: AnimationData;
  19419. protected _timeline: any;
  19420. protected _isOldData: boolean;
  19421. protected _isGlobalTransform: boolean;
  19422. protected _isAutoTween: boolean;
  19423. protected _animationTweenEasing: number;
  19424. protected _timelinePivot: Point;
  19425. protected _helpPoint: Point;
  19426. protected _helpTransformA: Transform;
  19427. protected _helpTransformB: Transform;
  19428. protected _helpMatrix: Matrix;
  19429. protected _rawBones: Array<BoneData>;
  19430. constructor();
  19431. /**
  19432. * @private
  19433. */
  19434. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData;
  19435. /**
  19436. * @private
  19437. */
  19438. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void;
  19439. private _getTimelineFrameMatrix(animation, timeline, position, transform);
  19440. protected _globalToLocal(armature: ArmatureData): void;
  19441. protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array<ActionData>, events: Array<EventData>): void;
  19442. /**
  19443. * @deprecated
  19444. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19445. */
  19446. static parseDragonBonesData(rawData: any): DragonBonesData;
  19447. /**
  19448. * @deprecated
  19449. * @see dragonBones.BaseFactory#parsetTextureAtlasData()
  19450. */
  19451. static parseTextureAtlasData(rawData: any, scale?: number): any;
  19452. }
  19453. }
  19454. declare namespace dragonBones {
  19455. /**
  19456. * @private
  19457. */
  19458. class ObjectDataParser extends DataParser {
  19459. /**
  19460. * @private
  19461. */
  19462. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  19463. /**
  19464. * @private
  19465. */
  19466. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  19467. /**
  19468. * @private
  19469. */
  19470. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  19471. /**
  19472. * @private
  19473. */
  19474. protected static _getParameter(rawData: Array<any>, index: number, defaultValue: any): any;
  19475. /**
  19476. * @private
  19477. */
  19478. constructor();
  19479. /**
  19480. * @private
  19481. */
  19482. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  19483. /**
  19484. * @private
  19485. */
  19486. protected _parseBone(rawData: any): BoneData;
  19487. /**
  19488. * @private
  19489. */
  19490. protected _parseIK(rawData: any): void;
  19491. /**
  19492. * @private
  19493. */
  19494. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  19495. /**
  19496. * @private
  19497. */
  19498. protected _parseSkin(rawData: any): SkinData;
  19499. /**
  19500. * @private
  19501. */
  19502. protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet;
  19503. /**
  19504. * @private
  19505. */
  19506. protected _parseDisplay(rawData: any): DisplayData;
  19507. /**
  19508. * @private
  19509. */
  19510. protected _parseMesh(rawData: any): MeshData;
  19511. /**
  19512. * @private
  19513. */
  19514. protected _parseAnimation(rawData: any): AnimationData;
  19515. /**
  19516. * @private
  19517. */
  19518. protected _parseBoneTimeline(rawData: any): BoneTimelineData;
  19519. /**
  19520. * @private
  19521. */
  19522. protected _parseSlotTimeline(rawData: any): SlotTimelineData;
  19523. /**
  19524. * @private
  19525. */
  19526. protected _parseFFDTimeline(rawData: any): FFDTimelineData;
  19527. /**
  19528. * @private
  19529. */
  19530. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData;
  19531. /**
  19532. * @private
  19533. */
  19534. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData;
  19535. /**
  19536. * @private
  19537. */
  19538. protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData;
  19539. /**
  19540. * @private
  19541. */
  19542. protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData;
  19543. /**
  19544. * @private
  19545. */
  19546. protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData;
  19547. /**
  19548. * @private
  19549. */
  19550. protected _parseTweenFrame<T extends TweenFrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19551. /**
  19552. * @private
  19553. */
  19554. protected _parseFrame<T extends FrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19555. /**
  19556. * @private
  19557. */
  19558. protected _parseTimeline<T extends FrameData<T>>(rawData: Object, timeline: TimelineData<T>, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void;
  19559. /**
  19560. * @private
  19561. */
  19562. protected _parseActionData(rawData: any, actions: Array<ActionData>, bone: BoneData, slot: SlotData): void;
  19563. /**
  19564. * @private
  19565. */
  19566. protected _parseEventData(rawData: any, events: Array<EventData>, bone: BoneData, slot: SlotData): void;
  19567. /**
  19568. * @private
  19569. */
  19570. protected _parseTransform(rawData: Object, transform: Transform): void;
  19571. /**
  19572. * @private
  19573. */
  19574. protected _parseColorTransform(rawData: Object, color: ColorTransform): void;
  19575. /**
  19576. * @inheritDoc
  19577. */
  19578. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData;
  19579. /**
  19580. * @inheritDoc
  19581. */
  19582. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void;
  19583. /**
  19584. * @private
  19585. */
  19586. private static _instance;
  19587. /**
  19588. * @deprecated
  19589. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19590. */
  19591. static getInstance(): ObjectDataParser;
  19592. }
  19593. }
  19594. declare namespace dragonBones {
  19595. /**
  19596. * @language zh_CN
  19597. * 贴图集数据。
  19598. * @version DragonBones 3.0
  19599. */
  19600. abstract class TextureAtlasData extends BaseObject {
  19601. /**
  19602. * @language zh_CN
  19603. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19604. * @default false
  19605. * @version DragonBones 4.5
  19606. */
  19607. autoSearch: boolean;
  19608. /**
  19609. * @language zh_CN
  19610. * 贴图集缩放系数。
  19611. * @version DragonBones 3.0
  19612. */
  19613. scale: number;
  19614. /**
  19615. * @language zh_CN
  19616. * 贴图集名称。
  19617. * @version DragonBones 3.0
  19618. */
  19619. name: string;
  19620. /**
  19621. * @language zh_CN
  19622. * 贴图集图片路径。
  19623. * @version DragonBones 3.0
  19624. */
  19625. imagePath: string;
  19626. /**
  19627. * @inheritDoc
  19628. */
  19629. protected _onClear(): void;
  19630. /**
  19631. * @private
  19632. */
  19633. getTexture(name: string): TextureData;
  19634. }
  19635. /**
  19636. * @private
  19637. */
  19638. abstract class TextureData extends BaseObject {
  19639. static generateRectangle(): Rectangle;
  19640. rotated: boolean;
  19641. name: string;
  19642. frame: Rectangle;
  19643. parent: TextureAtlasData;
  19644. region: Rectangle;
  19645. constructor();
  19646. /**
  19647. * @inheritDoc
  19648. */
  19649. protected _onClear(): void;
  19650. }
  19651. }
  19652. declare namespace dragonBones {
  19653. /**
  19654. * @private
  19655. */
  19656. type BuildArmaturePackage = {
  19657. dataName?: string;
  19658. textureAtlasName?: string;
  19659. data?: DragonBonesData;
  19660. armature?: ArmatureData;
  19661. skin?: SkinData;
  19662. };
  19663. /**
  19664. * @language zh_CN
  19665. * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例)
  19666. * @see dragonBones.DragonBonesData
  19667. * @see dragonBones.TextureAtlasData
  19668. * @see dragonBones.ArmatureData
  19669. * @see dragonBones.Armature
  19670. * @version DragonBones 3.0
  19671. */
  19672. abstract class BaseFactory {
  19673. protected static _defaultParser: ObjectDataParser;
  19674. /**
  19675. * @language zh_CN
  19676. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19677. * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启)
  19678. * @see dragonBones.DragonBonesData#autoSearch
  19679. * @see dragonBones.TextureAtlasData#autoSearch
  19680. * @version DragonBones 4.5
  19681. */
  19682. autoSearch: boolean;
  19683. /**
  19684. * @private
  19685. */
  19686. protected _dataParser: DataParser;
  19687. /**
  19688. * @private
  19689. */
  19690. protected _dragonBonesDataMap: Map<DragonBonesData>;
  19691. /**
  19692. * @private
  19693. */
  19694. protected _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  19695. /**
  19696. * @private
  19697. */
  19698. constructor(dataParser?: DataParser);
  19699. /**
  19700. * @private
  19701. */
  19702. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData;
  19703. /**
  19704. * @private
  19705. */
  19706. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  19707. /**
  19708. * @private
  19709. */
  19710. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19711. /**
  19712. * @private
  19713. */
  19714. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19715. /**
  19716. * @private
  19717. */
  19718. protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void;
  19719. /**
  19720. * @private
  19721. */
  19722. protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData;
  19723. /**
  19724. * @private
  19725. */
  19726. protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature;
  19727. /**
  19728. * @private
  19729. */
  19730. protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot;
  19731. /**
  19732. * @language zh_CN
  19733. * 解析并添加龙骨数据。
  19734. * @param rawData 需要解析的原始数据。 (JSON)
  19735. * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19736. * @returns DragonBonesData
  19737. * @see #getDragonBonesData()
  19738. * @see #addDragonBonesData()
  19739. * @see #removeDragonBonesData()
  19740. * @see dragonBones.DragonBonesData
  19741. * @version DragonBones 4.5
  19742. */
  19743. parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData;
  19744. /**
  19745. * @language zh_CN
  19746. * 解析并添加贴图集数据。
  19747. * @param rawData 需要解析的原始数据。 (JSON)
  19748. * @param textureAtlas 贴图集数据。 (JSON)
  19749. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19750. * @param scale 为贴图集设置一个缩放值。
  19751. * @returns 贴图集数据
  19752. * @see #getTextureAtlasData()
  19753. * @see #addTextureAtlasData()
  19754. * @see #removeTextureAtlasData()
  19755. * @see dragonBones.TextureAtlasData
  19756. * @version DragonBones 4.5
  19757. */
  19758. parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData;
  19759. /**
  19760. * @language zh_CN
  19761. * 获取指定名称的龙骨数据。
  19762. * @param name 数据名称。
  19763. * @returns DragonBonesData
  19764. * @see #parseDragonBonesData()
  19765. * @see #addDragonBonesData()
  19766. * @see #removeDragonBonesData()
  19767. * @see dragonBones.DragonBonesData
  19768. * @version DragonBones 3.0
  19769. */
  19770. getDragonBonesData(name: string): DragonBonesData;
  19771. /**
  19772. * @language zh_CN
  19773. * 添加龙骨数据。
  19774. * @param data 龙骨数据。
  19775. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19776. * @see #parseDragonBonesData()
  19777. * @see #getDragonBonesData()
  19778. * @see #removeDragonBonesData()
  19779. * @see dragonBones.DragonBonesData
  19780. * @version DragonBones 3.0
  19781. */
  19782. addDragonBonesData(data: DragonBonesData, name?: string): void;
  19783. /**
  19784. * @language zh_CN
  19785. * 移除龙骨数据。
  19786. * @param name 数据名称。
  19787. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19788. * @see #parseDragonBonesData()
  19789. * @see #getDragonBonesData()
  19790. * @see #addDragonBonesData()
  19791. * @see dragonBones.DragonBonesData
  19792. * @version DragonBones 3.0
  19793. */
  19794. removeDragonBonesData(name: string, disposeData?: boolean): void;
  19795. /**
  19796. * @language zh_CN
  19797. * 获取指定名称的贴图集数据列表。
  19798. * @param name 数据名称。
  19799. * @returns 贴图集数据列表。
  19800. * @see #parseTextureAtlasData()
  19801. * @see #addTextureAtlasData()
  19802. * @see #removeTextureAtlasData()
  19803. * @see dragonBones.textures.TextureAtlasData
  19804. * @version DragonBones 3.0
  19805. */
  19806. getTextureAtlasData(name: string): Array<TextureAtlasData>;
  19807. /**
  19808. * @language zh_CN
  19809. * 添加贴图集数据。
  19810. * @param data 贴图集数据。
  19811. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19812. * @see #parseTextureAtlasData()
  19813. * @see #getTextureAtlasData()
  19814. * @see #removeTextureAtlasData()
  19815. * @see dragonBones.textures.TextureAtlasData
  19816. * @version DragonBones 3.0
  19817. */
  19818. addTextureAtlasData(data: TextureAtlasData, name?: string): void;
  19819. /**
  19820. * @language zh_CN
  19821. * 移除贴图集数据。
  19822. * @param name 数据名称。
  19823. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19824. * @see #parseTextureAtlasData()
  19825. * @see #getTextureAtlasData()
  19826. * @see #addTextureAtlasData()
  19827. * @see dragonBones.textures.TextureAtlasData
  19828. * @version DragonBones 3.0
  19829. */
  19830. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  19831. /**
  19832. * @language zh_CN
  19833. * 清除所有的数据。
  19834. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19835. * @version DragonBones 4.5
  19836. */
  19837. clear(disposeData?: boolean): void;
  19838. /**
  19839. * @language zh_CN
  19840. * 创建一个指定名称的骨架。
  19841. * @param armatureName 骨架数据名称。
  19842. * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。
  19843. * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。
  19844. * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。
  19845. * @returns 骨架
  19846. * @see dragonBones.Armature
  19847. * @version DragonBones 3.0
  19848. */
  19849. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature;
  19850. /**
  19851. * @language zh_CN
  19852. * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构)
  19853. * @param toArmature 指定的骨架。
  19854. * @param fromArmatreName 其他骨架的名称。
  19855. * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。
  19856. * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。
  19857. * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除]
  19858. * @returns 是否替换成功。 [true: 成功, false: 不成功]
  19859. * @see dragonBones.Armature
  19860. * @version DragonBones 4.5
  19861. */
  19862. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean;
  19863. /**
  19864. * @language zh_CN
  19865. * 将指定插槽的显示对象替换为指定资源创造出的显示对象。
  19866. * @param dragonBonesName 指定的龙骨数据名称。
  19867. * @param armatureName 指定的骨架名称。
  19868. * @param slotName 指定的插槽名称。
  19869. * @param displayName 指定的显示对象名称。
  19870. * @param slot 指定的插槽实例。
  19871. * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
  19872. * @version DragonBones 4.5
  19873. */
  19874. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void;
  19875. /**
  19876. * @language zh_CN
  19877. * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。
  19878. * @param dragonBonesName 指定的 DragonBonesData 名称。
  19879. * @param armatureName 指定的骨架名称。
  19880. * @param slotName 指定的插槽名称。
  19881. * @param slot 指定的插槽实例。
  19882. * @version DragonBones 4.5
  19883. */
  19884. replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void;
  19885. /**
  19886. * @private
  19887. */
  19888. getAllDragonBonesData(): Map<DragonBonesData>;
  19889. /**
  19890. * @private
  19891. */
  19892. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  19893. }
  19894. }
  19895. declare let jsb: any;
  19896. /** Running in the editor. */
  19897. declare let CC_EDITOR: boolean;
  19898. /** Preview in browser or simulator. */
  19899. declare let CC_PREVIEW: boolean;
  19900. /** Running in the editor or preview. */
  19901. declare let CC_DEV: boolean;
  19902. /** Running in the editor or preview, or build in debug mode. */
  19903. declare let CC_DEBUG: boolean;
  19904. /** Running in published project. */
  19905. declare let CC_BUILD: boolean;
  19906. /** Running in native platform (mobile app, desktop app, or simulator). */
  19907. declare let CC_JSB: boolean;
  19908. /** Running in the engine's unit test. */
  19909. declare let CC_TEST: boolean;