creator.d.ts 680 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485
  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. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1109. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1110. @param options options
  1111. @example
  1112. ```js
  1113. // define base class
  1114. var Node = cc.Class();
  1115. // define sub class
  1116. var Sprite = cc.Class({
  1117. name: 'Sprite',
  1118. extends: Node,
  1119. ctor: function () {
  1120. this.url = "";
  1121. this.id = 0;
  1122. },
  1123. statics: {
  1124. // define static members
  1125. count: 0,
  1126. getBounds: function (spriteList) {
  1127. // compute bounds...
  1128. }
  1129. },
  1130. properties {
  1131. width: {
  1132. default: 128,
  1133. type: 'Integer',
  1134. tooltip: 'The width of sprite'
  1135. },
  1136. height: 128,
  1137. size: {
  1138. get: function () {
  1139. return cc.v2(this.width, this.height);
  1140. }
  1141. }
  1142. },
  1143. load: function () {
  1144. // load this.url...
  1145. };
  1146. });
  1147. // instantiate
  1148. var obj = new Sprite();
  1149. obj.url = 'sprite.png';
  1150. obj.load();
  1151. ```
  1152. */
  1153. 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;
  1154. /**
  1155. Checks whether subclass is child of superclass or equals to superclass
  1156. @param subclass subclass
  1157. @param superclass superclass
  1158. */
  1159. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  1160. /**
  1161. Return all super classes
  1162. @param constructor constructor
  1163. */
  1164. export function getInheritanceChain(constructor: Function): Function[];
  1165. /**
  1166. !#en
  1167. Define an enum type. <br/>
  1168. 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/>
  1169. Otherwise it will use the value specified by user who writes the enum definition.
  1170. !#zh
  1171. 定义一个枚举类型。<br/>
  1172. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1173. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1174. @example
  1175. ```js
  1176. // JavaScript:
  1177. var WrapMode = cc.Enum({
  1178. Repeat: -1,
  1179. Clamp: -1
  1180. });
  1181. // Texture.WrapMode.Repeat == 0
  1182. // Texture.WrapMode.Clamp == 1
  1183. // Texture.WrapMode[0] == "Repeat"
  1184. // Texture.WrapMode[1] == "Clamp"
  1185. var FlagType = cc.Enum({
  1186. Flag1: 1,
  1187. Flag2: 2,
  1188. Flag3: 4,
  1189. Flag4: 8,
  1190. });
  1191. var AtlasSizeList = cc.Enum({
  1192. 128: 128,
  1193. 256: 256,
  1194. 512: 512,
  1195. 1024: 1024,
  1196. });
  1197. // TypeScript:
  1198. // If used in TypeScript, just define a TypeScript enum:
  1199. enum Direction {
  1200. Up,
  1201. Down,
  1202. Left,
  1203. Right
  1204. }
  1205. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1206. const {ccclass, property} = cc._decorator;
  1207. @ccclass
  1208. class NewScript extends cc.Component {
  1209. @property({
  1210. default: Direction.Up,
  1211. type: cc.Enum(Direction) // call cc.Enum
  1212. })
  1213. direction: Direction = Direction.Up;
  1214. }
  1215. ```
  1216. */
  1217. export function Enum<T>(obj: T): T;
  1218. /**
  1219. whether enable accelerometer event
  1220. @param isEnable isEnable
  1221. */
  1222. export function setAccelerometerEnabled(isEnable: boolean): void;
  1223. /**
  1224. set accelerometer interval value
  1225. @param interval interval
  1226. */
  1227. export function setAccelerometerInterval(interval: number): void;
  1228. /**
  1229. @param touches touches
  1230. */
  1231. export function handleTouchesBegin(touches: any[]): void;
  1232. /**
  1233. @param touches touches
  1234. */
  1235. export function handleTouchesMove(touches: any[]): void;
  1236. /**
  1237. @param touches touches
  1238. */
  1239. export function handleTouchesEnd(touches: any[]): void;
  1240. /**
  1241. @param touches touches
  1242. */
  1243. export function handleTouchesCancel(touches: any[]): void;
  1244. /**
  1245. @param touches touches
  1246. */
  1247. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1248. /**
  1249. @param element element
  1250. */
  1251. export function getHTMLElementPosition(element: HTMLElement): any;
  1252. /**
  1253. @param touch touch
  1254. */
  1255. export function getPreTouch(touch: Touch): Touch;
  1256. /**
  1257. @param touch touch
  1258. */
  1259. export function setPreTouch(touch: Touch): void;
  1260. /**
  1261. @param tx tx
  1262. @param ty ty
  1263. @param pos pos
  1264. */
  1265. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1266. /**
  1267. @param location location
  1268. @param pos pos
  1269. @param eventType eventType
  1270. */
  1271. export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1272. /**
  1273. @param event event
  1274. @param pos pos
  1275. */
  1276. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1277. /**
  1278. @param event event
  1279. @param pos pos
  1280. */
  1281. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1282. /**
  1283. @param element element
  1284. */
  1285. export function registerSystemEvent(element: HTMLElement): void;
  1286. /**
  1287. @param dt dt
  1288. */
  1289. export function update(dt: number): void;
  1290. /**
  1291. <p>
  1292. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  1293. </p>
  1294. @param a number A
  1295. @param b number B
  1296. @param r ratio between 0 and 1
  1297. @example
  1298. ```js
  1299. ----
  1300. lerp
  1301. cc.lerp(2,10,0.5)//returns 6
  1302. cc.lerp(2,10,0.2)//returns 3.6
  1303. ```
  1304. */
  1305. export function lerp(a: number, b: number, r: number): void;
  1306. /**
  1307. get a random number from 0 to 0xffffff
  1308. */
  1309. export function rand(): number;
  1310. /**
  1311. returns a random float between -1 and 1
  1312. */
  1313. export function randomMinus1To1(): number;
  1314. /**
  1315. returns a random float between 0 and 1, use Math.random directly
  1316. */
  1317. export function random0To1(): number;
  1318. /**
  1319. converts degrees to radians
  1320. @param angle angle
  1321. */
  1322. export function degreesToRadians(angle: number): number;
  1323. /**
  1324. converts radians to degrees
  1325. @param angle angle
  1326. */
  1327. export function radiansToDegrees(angle: number): number;
  1328. /**
  1329. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
  1330. @param node setup node
  1331. */
  1332. export function nodeDrawSetup(node: Node): void;
  1333. /**
  1334. <p>
  1335. Increments the GL Draws counts by one.<br/>
  1336. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.<br/>
  1337. </p>
  1338. @param addNumber addNumber
  1339. */
  1340. export function incrementGLDraws(addNumber: number): void;
  1341. /**
  1342. Check webgl error.Error will be shown in console if exists.
  1343. */
  1344. export function checkGLErrorDebug(): void;
  1345. /**
  1346. !#en Checks whether the object is non-nil and not yet destroyed.
  1347. !#zh 检查该对象是否不为 null 并且尚未销毁。
  1348. @param value value
  1349. @example
  1350. ```js
  1351. cc.log(cc.isValid(target));
  1352. ```
  1353. */
  1354. export function isValid(value: any): boolean;
  1355. /** Specify that the input value must be integer in Inspector.
  1356. Also used to indicates that the elements in array should be type integer. */
  1357. export var Integer: string;
  1358. /** Indicates that the elements in array should be type double. */
  1359. export var Float: string;
  1360. /** Indicates that the elements in array should be type boolean. */
  1361. export var Boolean: string;
  1362. /** Indicates that the elements in array should be type string. */
  1363. export var String: string;
  1364. /**
  1365. !#en Deserialize json to cc.Asset
  1366. !#zh 将 JSON 反序列化为对象实例。
  1367. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1368. 也不会将 uuid 保存到 result 对象中。
  1369. @param data the serialized cc.Asset json string or json object.
  1370. @param details additional loading result
  1371. @param options options
  1372. */
  1373. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1374. /**
  1375. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1376. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1377. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1378. @param original An existing object that you want to make a copy of.
  1379. @example
  1380. ```js
  1381. // instantiate node from prefab
  1382. var scene = cc.director.getScene();
  1383. var node = cc.instantiate(prefabAsset);
  1384. node.parent = scene;
  1385. // clone node
  1386. var scene = cc.director.getScene();
  1387. var node = cc.instantiate(targetNode);
  1388. node.parent = scene;
  1389. ```
  1390. */
  1391. export function instantiate(original: Prefab): Node;
  1392. export function instantiate<T>(original: T): T;
  1393. /**
  1394. Finds a node by hierarchy path, the path is case-sensitive.
  1395. It will traverse the hierarchy by splitting the path using '/' character.
  1396. This function will still returns the node even if it is inactive.
  1397. It is recommended to not use this function every frame instead cache the result at startup.
  1398. @param path path
  1399. @param referenceNode referenceNode
  1400. */
  1401. export function find(path: string, referenceNode?: Node): Node;
  1402. /**
  1403. !#en
  1404. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1405. Alpha channel is optional. Default value is 255.
  1406. !#zh
  1407. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1408. Alpha 通道是可选的。默认值是 255。
  1409. @param r r
  1410. @param g g
  1411. @param b b
  1412. @param a a
  1413. @example
  1414. ```js
  1415. -----------------------
  1416. // 1. All channels seperately as parameters
  1417. var color1 = new cc.Color(255, 255, 255, 255);
  1418. // 2. Convert a hex string to a color
  1419. var color2 = new cc.Color("#000000");
  1420. // 3. An color object as parameter
  1421. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1422. ```
  1423. */
  1424. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1425. /**
  1426. !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1427. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1428. @param color1 color1
  1429. @param color2 color2
  1430. @example
  1431. ```js
  1432. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1433. ```
  1434. */
  1435. export function colorEqual(color1: Color, color2: Color): boolean;
  1436. /**
  1437. !#en
  1438. convert a string of color for style to Color.
  1439. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1440. !#zh 16 进制转换为 Color
  1441. @param hex hex
  1442. @example
  1443. ```js
  1444. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1445. ```
  1446. */
  1447. export function hexToColor(hex: string): Color;
  1448. /**
  1449. !#en
  1450. convert Color to a string of color for style.
  1451. e.g. cc.color(255,6,255) to : "#ff06ff"
  1452. !#zh Color 转换为 16进制。
  1453. @param color color
  1454. @example
  1455. ```js
  1456. var color = new cc.Color(255, 6, 255)
  1457. cc.colorToHex(color); // #ff06ff;
  1458. ```
  1459. */
  1460. export function colorToHex(color: Color): string;
  1461. /**
  1462. !#en Returns opposite of Vec2.
  1463. !#zh 返回相反的向量。
  1464. @param point point
  1465. @example
  1466. ```js
  1467. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1468. ```
  1469. */
  1470. export function pNeg(point: Vec2): Vec2;
  1471. /**
  1472. !#en Calculates sum of two points.
  1473. !#zh 返回两个向量的和。
  1474. @param v1 v1
  1475. @param v2 v2
  1476. @example
  1477. ```js
  1478. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1479. ```
  1480. */
  1481. export function pAdd(v1: Vec2, v2: Vec2): Vec2;
  1482. /**
  1483. !#en Calculates difference of two points.
  1484. !#zh 返回两个向量的差。
  1485. @param v1 v1
  1486. @param v2 v2
  1487. @example
  1488. ```js
  1489. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1490. ```
  1491. */
  1492. export function pSub(v1: Vec2, v2: Vec2): Vec2;
  1493. /**
  1494. !#en Returns point multiplied by given factor.
  1495. !#zh 向量缩放。
  1496. @param point point
  1497. @param floatVar floatVar
  1498. @example
  1499. ```js
  1500. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1501. ```
  1502. */
  1503. export function pMult(point: Vec2, floatVar: number): Vec2;
  1504. /**
  1505. !#en Calculates midpoint between two points.
  1506. !#zh 两个向量之间的中心点。
  1507. @param v1 v1
  1508. @param v2 v2
  1509. @example
  1510. ```js
  1511. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1512. ```
  1513. */
  1514. export function pMidpoint(v1: Vec2, v2: Vec2): Vec2;
  1515. /**
  1516. !#en Calculates dot product of two points.
  1517. !#zh 两个向量之间进行点乘。
  1518. @param v1 v1
  1519. @param v2 v2
  1520. @example
  1521. ```js
  1522. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1523. ```
  1524. */
  1525. export function pDot(v1: Vec2, v2: Vec2): number;
  1526. /**
  1527. !#en Calculates cross product of two points.
  1528. !#zh 两个向量之间进行叉乘。
  1529. @param v1 v1
  1530. @param v2 v2
  1531. @example
  1532. ```js
  1533. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1534. ```
  1535. */
  1536. export function pCross(v1: Vec2, v2: Vec2): number;
  1537. /**
  1538. !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1539. !#zh 返回逆时针旋转 90 度后的新向量。
  1540. @param point point
  1541. @example
  1542. ```js
  1543. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1544. ```
  1545. */
  1546. export function pPerp(point: Vec2): Vec2;
  1547. /**
  1548. !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1549. !#zh 将指定向量顺时针旋转 90 度并返回。
  1550. @param point point
  1551. @example
  1552. ```js
  1553. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1554. ```
  1555. */
  1556. export function pRPerp(point: Vec2): Vec2;
  1557. /**
  1558. !#en Calculates the projection of v1 over v2.
  1559. !#zh 返回 v1 在 v2 上的投影向量。
  1560. @param v1 v1
  1561. @param v2 v2
  1562. @example
  1563. ```js
  1564. var v1 = cc.v2(20, 20);
  1565. var v2 = cc.v2(5, 5);
  1566. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1567. ```
  1568. */
  1569. export function pProject(v1: Vec2, v2: Vec2): Vec2;
  1570. /**
  1571. !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1572. !#zh 返回指定向量长度的平方。
  1573. @param v v
  1574. @example
  1575. ```js
  1576. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1577. ```
  1578. */
  1579. export function pLengthSQ(v: Vec2): number;
  1580. /**
  1581. !#en Calculates the square distance between two points (not calling sqrt() ).
  1582. !#zh 返回两个点之间距离的平方。
  1583. @param point1 point1
  1584. @param point2 point2
  1585. @example
  1586. ```js
  1587. var point1 = cc.v2(20, 20);
  1588. var point2 = cc.v2(5, 5);
  1589. cc.pDistanceSQ(point1, point2); // 450;
  1590. ```
  1591. */
  1592. export function pDistanceSQ(point1: Vec2, point2: Vec2): number;
  1593. /**
  1594. !#en Calculates distance between point an origin.
  1595. !#zh 返回指定向量的长度.
  1596. @param v v
  1597. @example
  1598. ```js
  1599. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1600. ```
  1601. */
  1602. export function pLength(v: Vec2): number;
  1603. /**
  1604. !#en Calculates the distance between two points.
  1605. !#zh 返回指定 2 个向量之间的距离。
  1606. @param v1 v1
  1607. @param v2 v2
  1608. @example
  1609. ```js
  1610. var v1 = cc.v2(20, 20);
  1611. var v2 = cc.v2(5, 5);
  1612. cc.pDistance(v1, v2); // 21.213203435596427;
  1613. ```
  1614. */
  1615. export function pDistance(v1: Vec2, v2: Vec2): number;
  1616. /**
  1617. !#en Returns this vector with a magnitude of 1.
  1618. !#zh 返回一个长度为 1 的标准化过后的向量。
  1619. @param v v
  1620. @example
  1621. ```js
  1622. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1623. ```
  1624. */
  1625. export function pNormalize(v: Vec2): Vec2;
  1626. /**
  1627. !#en Converts radians to a normalized vector.
  1628. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1629. @param a a
  1630. @example
  1631. ```js
  1632. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1633. ```
  1634. */
  1635. export function pForAngle(a: number): Vec2;
  1636. /**
  1637. !#en Converts a vector to radians.
  1638. !#zh 返回指定向量的弧度。
  1639. @param v v
  1640. @example
  1641. ```js
  1642. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1643. ```
  1644. */
  1645. export function pToAngle(v: Vec2): number;
  1646. /**
  1647. !#en Clamp a value between from and to.
  1648. !#zh
  1649. 限定浮点数的最大最小值。<br/>
  1650. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1651. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1652. 否则返回自身。
  1653. @param value value
  1654. @param min_inclusive min_inclusive
  1655. @param max_inclusive max_inclusive
  1656. @example
  1657. ```js
  1658. var v1 = cc.clampf(20, 0, 20); // 20;
  1659. var v2 = cc.clampf(-1, 0, 20); // 0;
  1660. var v3 = cc.clampf(10, 0, 20); // 10;
  1661. ```
  1662. */
  1663. export function clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  1664. /**
  1665. !#en Clamp a value between 0 and 1.
  1666. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1667. @param value value
  1668. @example
  1669. ```js
  1670. var v1 = cc.clampf(20); // 1;
  1671. var v2 = cc.clampf(-1); // 0;
  1672. var v3 = cc.clampf(0.5); // 0.5;
  1673. ```
  1674. */
  1675. export function clamp01(value: number): number;
  1676. /**
  1677. !#en Clamp a point between from and to.
  1678. !#zh
  1679. 返回指定限制区域后的向量。<br/>
  1680. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1681. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1682. 否则返回自身。
  1683. @param p p
  1684. @param min_inclusive min_inclusive
  1685. @param max_inclusive max_inclusive
  1686. @example
  1687. ```js
  1688. var min_inclusive = cc.v2(0, 0);
  1689. var max_inclusive = cc.v2(20, 20);
  1690. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1691. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1692. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1693. ```
  1694. */
  1695. export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  1696. /**
  1697. !#en Quickly convert cc.Size to a cc.Vec2.
  1698. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1699. @param s s
  1700. @example
  1701. ```js
  1702. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1703. ```
  1704. */
  1705. export function pFromSize(s: Size): Vec2;
  1706. /**
  1707. !#en
  1708. Run a math operation function on each point component <br />
  1709. Math.abs, Math.fllor, Math.ceil, Math.round.
  1710. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1711. @param p p
  1712. @param opFunc opFunc
  1713. @example
  1714. ```js
  1715. cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1716. ```
  1717. */
  1718. export function pCompOp(p: Vec2, opFunc: Function): Vec2;
  1719. /**
  1720. !#en
  1721. Linear Interpolation between two points a and b.<br />
  1722. alpha == 0 ? a <br />
  1723. alpha == 1 ? b <br />
  1724. otherwise a value between a..b.
  1725. !#zh
  1726. 两个点 A 和 B 之间的线性插值。 <br />
  1727. alpha == 0 ? a <br />
  1728. alpha == 1 ? b <br />
  1729. 否则这个数值在 a ~ b 之间。
  1730. @param a a
  1731. @param b b
  1732. @param alpha alpha
  1733. @example
  1734. ```js
  1735. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1736. ```
  1737. */
  1738. export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2;
  1739. /**
  1740. !#en TODO
  1741. !#zh
  1742. 近似判断两个点是否相等。<br/>
  1743. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1744. @param a a
  1745. @param b b
  1746. @param variance variance
  1747. @example
  1748. ```js
  1749. var a = cc.v2(20, 20);
  1750. var b = cc.v2(5, 5);
  1751. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1752. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1753. ```
  1754. */
  1755. export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean;
  1756. /**
  1757. !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1758. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1759. @param a a
  1760. @param b b
  1761. @example
  1762. ```js
  1763. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1764. ```
  1765. */
  1766. export function pCompMult(a: Vec2, b: Vec2): Vec2;
  1767. /**
  1768. !#en TODO
  1769. !#zh 返回两个向量之间带正负号的弧度。
  1770. @param a a
  1771. @param b b
  1772. */
  1773. export function pAngleSigned(a: Vec2, b: Vec2): number;
  1774. /**
  1775. !#en TODO
  1776. !#zh 获取当前向量与指定向量之间的弧度角。
  1777. @param a a
  1778. @param b b
  1779. */
  1780. export function pAngle(a: Vec2, b: Vec2): number;
  1781. /**
  1782. !#en Rotates a point counter clockwise by the angle around a pivot.
  1783. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1784. @param v v is the point to rotate
  1785. @param pivot pivot is the pivot, naturally
  1786. @param angle angle is the angle of rotation cw in radians
  1787. */
  1788. export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2;
  1789. /**
  1790. !#en
  1791. A general line-line intersection test
  1792. indicating successful intersection of a line<br />
  1793. note that to truly test intersection for segments we have to make<br />
  1794. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1795. the hit point is p3 + t * (p4 - p3);<br />
  1796. the hit point also is p1 + s * (p2 - p1);
  1797. !#zh
  1798. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1799. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1800. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1801. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1802. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1803. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1804. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1805. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1806. */
  1807. export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean;
  1808. /**
  1809. !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1810. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1811. @param A A
  1812. @param B B
  1813. @param C C
  1814. @param D D
  1815. */
  1816. export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean;
  1817. /**
  1818. !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1819. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1820. @param A A
  1821. @param B B
  1822. @param C C
  1823. @param D D
  1824. */
  1825. export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2;
  1826. /**
  1827. !#en check to see if both points are equal.
  1828. !#zh 检查指定的 2 个向量是否相等。
  1829. @param A A ccp a
  1830. @param B B ccp b to be compared
  1831. */
  1832. export function pSameAs(A: Vec2, B: Vec2): boolean;
  1833. /**
  1834. !#en sets the position of the point to 0.
  1835. !#zh 设置指定向量归 0。
  1836. @param v v
  1837. */
  1838. export function pZeroIn(v: Vec2): void;
  1839. /**
  1840. !#en copies the position of one point to another.
  1841. !#zh 令 v1 向量等同于 v2。
  1842. @param v1 v1
  1843. @param v2 v2
  1844. */
  1845. export function pIn(v1: Vec2, v2: Vec2): void;
  1846. /**
  1847. !#en multiplies the point with the given factor (inplace).
  1848. !#zh 向量缩放,结果保存到第一个向量。
  1849. @param point point
  1850. @param floatVar floatVar
  1851. */
  1852. export function pMultIn(point: Vec2, floatVar: number): void;
  1853. /**
  1854. !#en subtracts one point from another (inplace).
  1855. !#zh 向量减法,结果保存到第一个向量。
  1856. @param v1 v1
  1857. @param v2 v2
  1858. */
  1859. export function pSubIn(v1: Vec2, v2: Vec2): void;
  1860. /**
  1861. !#en adds one point to another (inplace).
  1862. !#zh 向量加法,结果保存到第一个向量。
  1863. @param v1 v1
  1864. @param v2 v2
  1865. */
  1866. export function pAddIn(v1: Vec2, v2: Vec2): void;
  1867. /**
  1868. !#en normalizes the point (inplace).
  1869. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1870. @param v v
  1871. */
  1872. export function pNormalizeIn(v: Vec2): void;
  1873. /**
  1874. !#en
  1875. The convenience method to create a new Rect.
  1876. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1877. !#zh
  1878. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1879. @param x x
  1880. @param y y
  1881. @param w w
  1882. @param h h
  1883. @example
  1884. ```js
  1885. var a = new cc.Rect(0 , 0, 10, 0);
  1886. ```
  1887. */
  1888. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1889. /**
  1890. !#en Check whether a rect's value equals to another.
  1891. !#zh 判断两个矩形是否相等。
  1892. @param rect1 rect1
  1893. @param rect2 rect2
  1894. @example
  1895. ```js
  1896. var a = new cc.Rect(0, 0, 10, 10);
  1897. var b = new cc.Rect(0, 0, 5, 5);
  1898. cc.rectEqualToRect(a, b); // false;
  1899. var c = new cc.Rect(0, 0, 5, 5);
  1900. cc.rectEqualToRect(b, c); // true;
  1901. ```
  1902. */
  1903. export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean;
  1904. /**
  1905. !#en Check whether the rect1 contains rect2.
  1906. !#zh
  1907. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1908. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1909. @param rect1 rect1
  1910. @param rect2 rect2
  1911. @example
  1912. ```js
  1913. var a = new cc.Rect(0, 0, 20, 20);
  1914. var b = new cc.Rect(10, 10, 20, 20);
  1915. cc.rectContainsRect(a, b); // true;
  1916. ```
  1917. */
  1918. export function rectContainsRect(rect1: Rect, rect2: Rect): boolean;
  1919. /**
  1920. !#en Returns the rightmost x-value of a rect.
  1921. !#zh 返回矩形在 x 轴上的最大值
  1922. @param rect rect
  1923. @example
  1924. ```js
  1925. var a = new cc.Rect(10, 0, 20, 20);
  1926. cc.rectGetMaxX(a); // 30;
  1927. ```
  1928. */
  1929. export function rectGetMaxX(rect: Rect): number;
  1930. /**
  1931. !#en Return the midpoint x-value of a rect.
  1932. !#zh 返回矩形在 x 轴上的中点。
  1933. @param rect rect
  1934. @example
  1935. ```js
  1936. var a = new cc.Rect(10, 0, 20, 20);
  1937. cc.rectGetMidX(a); // 20;
  1938. ```
  1939. */
  1940. export function rectGetMidX(rect: Rect): number;
  1941. /**
  1942. !#en Returns the leftmost x-value of a rect.
  1943. !#zh 返回矩形在 x 轴上的最小值。
  1944. @param rect rect
  1945. @example
  1946. ```js
  1947. var a = new cc.Rect(10, 0, 20, 20);
  1948. cc.rectGetMinX(a); // 10;
  1949. ```
  1950. */
  1951. export function rectGetMinX(rect: Rect): number;
  1952. /**
  1953. !#en Return the topmost y-value of a rect.
  1954. !#zh 返回矩形在 y 轴上的最大值。
  1955. @param rect rect
  1956. @example
  1957. ```js
  1958. var a = new cc.Rect(0, 10, 20, 20);
  1959. cc.rectGetMaxY(a); // 30;
  1960. ```
  1961. */
  1962. export function rectGetMaxY(rect: Rect): number;
  1963. /**
  1964. !#en Return the midpoint y-value of `rect'.
  1965. !#zh 返回矩形在 y 轴上的中点。
  1966. @param rect rect
  1967. @example
  1968. ```js
  1969. var a = new cc.Rect(0, 10, 20, 20);
  1970. cc.rectGetMidY(a); // 20;
  1971. ```
  1972. */
  1973. export function rectGetMidY(rect: Rect): number;
  1974. /**
  1975. !#en Return the bottommost y-value of a rect.
  1976. !#zh 返回矩形在 y 轴上的最小值。
  1977. @param rect rect
  1978. @example
  1979. ```js
  1980. var a = new cc.Rect(0, 10, 20, 20);
  1981. cc.rectGetMinY(a); // 10;
  1982. ```
  1983. */
  1984. export function rectGetMinY(rect: Rect): number;
  1985. /**
  1986. !#en Check whether a rect contains a point.
  1987. !#zh 检查一个矩形是否包含某个坐标点。
  1988. @param rect rect
  1989. @param point point
  1990. @example
  1991. ```js
  1992. var a = new cc.Rect(0, 10, 20, 20);
  1993. var b = new cc.Vec2(0, 10, 10, 10);
  1994. cc.rectContainsPoint(a, b); // true;
  1995. ```
  1996. */
  1997. export function rectContainsPoint(rect: Rect, point: Vec2): boolean;
  1998. /**
  1999. !#en Check whether a rect intersect with another.
  2000. !#zh 检查一个矩形是否与另一个相交。
  2001. @param rectA rectA
  2002. @param rectB rectB
  2003. @example
  2004. ```js
  2005. var a = new cc.Rect(0, 10, 20, 20);
  2006. var b = new cc.Rect(0, 10, 10, 10);
  2007. cc.rectIntersectsRect(a, b); // true;
  2008. ```
  2009. */
  2010. export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean;
  2011. /**
  2012. !#en Check whether a rect overlaps another.
  2013. !#zh 检查一个矩形是否重叠另一个。
  2014. @param rectA rectA
  2015. @param rectB rectB
  2016. @example
  2017. ```js
  2018. var a = new cc.Rect(0, 10, 20, 20);
  2019. var b = new cc.Rect(0, 10, 10, 10);
  2020. cc.rectOverlapsRect(a, b); // true;
  2021. ```
  2022. */
  2023. export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean;
  2024. /**
  2025. !#en Returns the smallest rectangle that contains the two source rectangles.
  2026. !#zh 返回一个包含两个指定矩形的最小矩形。
  2027. @param rectA rectA
  2028. @param rectB rectB
  2029. @example
  2030. ```js
  2031. var a = new cc.Rect(0, 10, 20, 20);
  2032. var b = new cc.Rect(0, 10, 10, 10);
  2033. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  2034. ```
  2035. */
  2036. export function rectUnion(rectA: Rect, rectB: Rect): Rect;
  2037. /**
  2038. !#en Returns the overlapping portion of 2 rectangles.
  2039. !#zh 返回 2 个矩形重叠的部分。
  2040. @param rectA rectA
  2041. @param rectB rectB
  2042. @example
  2043. ```js
  2044. var a = new cc.Rect(0, 10, 20, 20);
  2045. var b = new cc.Rect(0, 10, 10, 10);
  2046. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  2047. ```
  2048. */
  2049. export function rectIntersection(rectA: Rect, rectB: Rect): Rect;
  2050. /**
  2051. !#en
  2052. Helper function that creates a cc.Size.<br/>
  2053. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  2054. !#zh
  2055. 创建一个 cc.Size 对象的帮助函数。<br/>
  2056. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  2057. @param w width or a size object
  2058. @param h height
  2059. @example
  2060. ```js
  2061. var size1 = cc.size();
  2062. var size2 = cc.size(100,100);
  2063. var size3 = cc.size(size2);
  2064. var size4 = cc.size({width: 100, height: 100});
  2065. ```
  2066. */
  2067. export function size(w: number|Size, h?: number): Size;
  2068. /**
  2069. !#en Check whether a point's value equals to another.
  2070. !#zh 检查 Size 对象是否等于另一个。
  2071. @param size1 size1
  2072. @param size2 size2
  2073. @example
  2074. ```js
  2075. var a = new cc.size(10, 10);
  2076. var b = new cc.size(10, 10);
  2077. cc.sizeEqualToSize(a, b);// return true;
  2078. var b = new cc.size(5, 10);
  2079. cc.sizeEqualToSize(a, b);// return false;
  2080. ```
  2081. */
  2082. export function sizeEqualToSize(size1: Size, size2: Size): boolean;
  2083. export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad;
  2084. /**
  2085. @param sourceQuad sourceQuad
  2086. */
  2087. export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad;
  2088. /**
  2089. @param sourceQuads sourceQuads
  2090. */
  2091. export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[];
  2092. /**
  2093. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2094. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2095. @param x x
  2096. @param y y
  2097. @example
  2098. ```js
  2099. var v1 = cc.v2();
  2100. var v2 = cc.v2(0, 0);
  2101. var v3 = cc.v2(v2);
  2102. var v4 = cc.v2({x: 100, y: 100});
  2103. ```
  2104. */
  2105. export function v2(x?: number|any, y?: number): Vec2;
  2106. /**
  2107. !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2108. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2109. @param x a Number or a size object
  2110. @param y y
  2111. @example
  2112. ```js
  2113. var point1 = cc.p();
  2114. var point2 = cc.p(100, 100);
  2115. var point3 = cc.p(point2);
  2116. var point4 = cc.p({x: 100, y: 100});
  2117. ```
  2118. */
  2119. export function p(x?: number|any, y?: number): Vec2;
  2120. /**
  2121. !#en Check whether a point's value equals to another.
  2122. !#zh 判断两个向量是否相等。
  2123. @param point1 point1
  2124. @param point2 point2
  2125. */
  2126. export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean;
  2127. /** !#en Enum for debug modes.
  2128. !#zh 调试模式 */
  2129. export enum DebugMode {
  2130. NONE = 0,
  2131. INFO = 0,
  2132. WARN = 0,
  2133. ERROR = 0,
  2134. INFO_FOR_WEB_PAGE = 0,
  2135. WARN_FOR_WEB_PAGE = 0,
  2136. ERROR_FOR_WEB_PAGE = 0,
  2137. }
  2138. /** !#en Base class cc.Action for action classes.
  2139. !#zh Action 类是所有动作类型的基类。 */
  2140. export class Action {
  2141. /**
  2142. !#en
  2143. to copy object with deep copy.
  2144. returns a clone of action.
  2145. !#zh 返回一个克隆的动作。
  2146. */
  2147. clone(): Action;
  2148. /**
  2149. !#en
  2150. return true if the action has finished.
  2151. !#zh 如果动作已完成就返回 true。
  2152. */
  2153. isDone(): boolean;
  2154. /**
  2155. !#en get the target.
  2156. !#zh 获取当前目标节点。
  2157. */
  2158. getTarget(): Node;
  2159. /**
  2160. !#en The action will modify the target properties.
  2161. !#zh 设置目标节点。
  2162. @param target target
  2163. */
  2164. setTarget(target: Node): void;
  2165. /**
  2166. !#en get the original target.
  2167. !#zh 获取原始目标节点。
  2168. */
  2169. getOriginalTarget(): Node;
  2170. /**
  2171. !#en get tag number.
  2172. !#zh 获取用于识别动作的标签。
  2173. */
  2174. getTag(): number;
  2175. /**
  2176. !#en set tag number.
  2177. !#zh 设置标签,用于识别动作。
  2178. @param tag tag
  2179. */
  2180. setTag(tag: number): void;
  2181. /** !#en Default Action tag.
  2182. !#zh 默认动作标签。 */
  2183. static TAG_INVALID: number;
  2184. }
  2185. /** !#en
  2186. Base class actions that do have a finite time duration. <br/>
  2187. Possible actions: <br/>
  2188. - An action with a duration of 0 seconds. <br/>
  2189. - An action with a duration of 35.5 seconds.
  2190. Infinite time actions are valid
  2191. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2192. export class FiniteTimeAction extends Action {
  2193. /**
  2194. !#en get duration of the action. (seconds).
  2195. !#zh 获取动作以秒为单位的持续时间。
  2196. */
  2197. getDuration(): number;
  2198. /**
  2199. !#en set duration of the action. (seconds).
  2200. !#zh 设置动作以秒为单位的持续时间。
  2201. @param duration duration
  2202. */
  2203. setDuration(duration: number): void;
  2204. /**
  2205. !#en
  2206. Returns a reversed action. <br />
  2207. For example: <br />
  2208. - The action will be x coordinates of 0 move to 100. <br />
  2209. - The reversed action will be x of 100 move to 0.
  2210. - Will be rewritten
  2211. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2212. */
  2213. reverse(): void;
  2214. /**
  2215. !#en
  2216. to copy object with deep copy.
  2217. returns a clone of action.
  2218. !#zh 返回一个克隆的动作。
  2219. */
  2220. clone(): FiniteTimeAction;
  2221. }
  2222. /** !#en Base class for Easing actions.
  2223. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2224. export class ActionEase extends ActionInterval {
  2225. }
  2226. /** !#en Base class for Easing actions with rate parameters
  2227. !#zh 拥有速率属性的缓动动作基类。 */
  2228. export class EaseRateAction extends ActionEase {
  2229. }
  2230. /** !#en Ease Elastic abstract class.
  2231. !#zh 弹性缓动动作基类。 */
  2232. export class EaseElastic extends ActionEase {
  2233. }
  2234. /** !#en cc.EaseBounce abstract class.
  2235. !#zh 反弹缓动动作基类。 */
  2236. export class EaseBounce extends ActionEase {
  2237. }
  2238. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2239. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2240. export class ActionInstant extends FiniteTimeAction {
  2241. }
  2242. /** !#en
  2243. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2244. It has an start time, and a finish time. The finish time is the parameter<br/>
  2245. duration plus the start time.</p>
  2246. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2247. - They can run normally (default) <br/>
  2248. - They can run reversed with the reverse method <br/>
  2249. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2250. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2251. then running it again in Reverse mode. </p>
  2252. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2253. export class ActionInterval extends FiniteTimeAction {
  2254. /**
  2255. !#en Implementation of ease motion.
  2256. !#zh 缓动运动。
  2257. @param easeObj easeObj
  2258. @example
  2259. ```js
  2260. action.easing(cc.easeIn(3.0));
  2261. ```
  2262. */
  2263. easing(easeObj: any): ActionInterval;
  2264. /**
  2265. !#en
  2266. Repeats an action a number of times.
  2267. To repeat an action forever use the CCRepeatForever action.
  2268. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2269. @param times times
  2270. */
  2271. repeat(times: number): ActionInterval;
  2272. /**
  2273. !#en
  2274. Repeats an action for ever. <br/>
  2275. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2276. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2277. */
  2278. repeatForever(): ActionInterval;
  2279. }
  2280. /** !#en
  2281. cc.ActionManager is a class that can manage actions.<br/>
  2282. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2283. which uses this class's singleton object.
  2284. But there are some cases where you might need to use this class. <br/>
  2285. Examples:<br/>
  2286. - When you want to run an action where the target is different from a CCNode.<br/>
  2287. - When you want to pause / resume the actions<br/>
  2288. !#zh
  2289. cc.ActionManager 是可以管理动作的单例类。<br/>
  2290. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2291. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2292. 例如:
  2293. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2294. - 当你想要暂停/恢复动作时。 <br/> */
  2295. export class ActionManager {
  2296. /**
  2297. !#en
  2298. Adds an action with a target.<br/>
  2299. If the target is already present, then the action will be added to the existing target.
  2300. 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.
  2301. When the target is paused, the queued actions won't be 'ticked'.
  2302. !#zh
  2303. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2304. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2305. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2306. 当目标状态的 paused 为 true,动作将不会被执行
  2307. @param action action
  2308. @param target target
  2309. @param paused paused
  2310. */
  2311. addAction(action: Action, target: Node, paused: boolean): void;
  2312. /**
  2313. !#en Removes all actions from all the targets.
  2314. !#zh 移除所有对象的所有动作。
  2315. */
  2316. removeAllActions(): void;
  2317. /**
  2318. !#en
  2319. Removes all actions from a certain target. <br/>
  2320. All the actions that belongs to the target will be removed.
  2321. !#zh
  2322. 移除指定对象上的所有动作。<br/>
  2323. 属于该目标的所有的动作将被删除。
  2324. @param target target
  2325. @param forceDelete forceDelete
  2326. */
  2327. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2328. /**
  2329. !#en Removes an action given an action reference.
  2330. !#zh 移除指定的动作。
  2331. @param action action
  2332. */
  2333. removeAction(action: Action): void;
  2334. /**
  2335. !#en Removes an action given its tag and the target.
  2336. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2337. @param tag tag
  2338. @param target target
  2339. */
  2340. removeActionByTag(tag: number, target: Node): void;
  2341. /**
  2342. !#en Gets an action given its tag an a target.
  2343. !#zh 通过目标对象和标签获取一个动作。
  2344. @param tag tag
  2345. @param target target
  2346. */
  2347. getActionByTag(tag: number, target: Node): Action;
  2348. /**
  2349. !#en
  2350. Returns the numbers of actions that are running in a certain target. <br/>
  2351. Composable actions are counted as 1 action. <br/>
  2352. Example: <br/>
  2353. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2354. - If you are running 7 Sequences of 2 actions, it will return 7.
  2355. !#zh
  2356. 返回指定对象下所有正在运行的动作数量。 <br/>
  2357. 组合动作被算作一个动作。<br/>
  2358. 例如:<br/>
  2359. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2360. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2361. @param target target
  2362. */
  2363. getNumberOfRunningActionsInTarget(target: Node): number;
  2364. /**
  2365. !#en Pauses the target: all running actions and newly added actions will be paused.
  2366. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2367. @param target target
  2368. */
  2369. pauseTarget(target: Node): void;
  2370. /**
  2371. !#en Resumes the target. All queued actions will be resumed.
  2372. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2373. @param target target
  2374. */
  2375. resumeTarget(target: Node): void;
  2376. /**
  2377. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2378. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2379. */
  2380. pauseAllRunningActions(): any[];
  2381. /**
  2382. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2383. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2384. @param targetsToResume targetsToResume
  2385. */
  2386. resumeTargets(targetsToResume: any[]): void;
  2387. /**
  2388. !#en Pause a set of targets.
  2389. !#zh 暂停一组指定对象。
  2390. @param targetsToPause targetsToPause
  2391. */
  2392. pauseTargets(targetsToPause: any[]): void;
  2393. /**
  2394. !#en
  2395. purges the shared action manager. It releases the retained instance. <br/>
  2396. because it uses this, so it can not be static.
  2397. !#zh
  2398. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2399. 因为它使用 this,因此它不能是静态的。
  2400. */
  2401. purgeSharedManager(): void;
  2402. /**
  2403. !#en The ActionManager update。
  2404. !#zh ActionManager 主循环。
  2405. @param dt delta time in seconds
  2406. */
  2407. update(dt: number): void;
  2408. }
  2409. /** !#en Class for animation data handling.
  2410. !#zh 动画剪辑,用于存储动画数据。 */
  2411. export class AnimationClip extends Asset {
  2412. /** !#en Duration of this animation.
  2413. !#zh 动画的持续时间。 */
  2414. duration: number;
  2415. /** !#en FrameRate of this animation.
  2416. !#zh 动画的帧速率。 */
  2417. sample: number;
  2418. /** !#en Speed of this animation.
  2419. !#zh 动画的播放速度。 */
  2420. speed: number;
  2421. /** !#en WrapMode of this animation.
  2422. !#zh 动画的循环模式。 */
  2423. wrapMode: WrapMode;
  2424. /** !#en Curve data.
  2425. !#zh 曲线数据。 */
  2426. curveData: any;
  2427. /** !#en Event data.
  2428. !#zh 事件数据。 */
  2429. events: {frame: number, func: string, params: string[]}[];
  2430. /**
  2431. !#en Crate clip with a set of sprite frames
  2432. !#zh 使用一组序列帧图片来创建动画剪辑
  2433. @param spriteFrames spriteFrames
  2434. @param sample sample
  2435. @example
  2436. ```js
  2437. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  2438. ```
  2439. */
  2440. static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip;
  2441. }
  2442. /** !#en
  2443. The AnimationState gives full control over animation playback process.
  2444. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  2445. !#zh
  2446. AnimationState 完全控制动画播放过程。<br/>
  2447. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  2448. export class AnimationState extends Playable {
  2449. /**
  2450. @param clip clip
  2451. @param name name
  2452. */
  2453. constructor(clip: AnimationClip, name?: string);
  2454. animator: AnimationAnimator;
  2455. /** !#en The curves list.
  2456. !#zh 曲线列表。 */
  2457. curves: any[];
  2458. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  2459. the active interval.
  2460. !#zh 延迟多少秒播放。 */
  2461. delay: number;
  2462. /** !#en The animation's iteration count property.
  2463. A real number greater than or equal to zero (including positive infinity) representing the number of times
  2464. to repeat the animation node.
  2465. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  2466. calculations.
  2467. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  2468. repeatCount: number;
  2469. /** !#en The iteration duration of this animation in seconds. (length)
  2470. !#zh 单次动画的持续时间,秒。 */
  2471. duration: number;
  2472. /** !#en The animation's playback speed. 1 is normal playback speed.
  2473. !#zh 播放速率。 */
  2474. speed: number;
  2475. /** !#en
  2476. Wrapping mode of the playing animation.
  2477. Notice : dynamic change wrapMode will reset time and repeatCount property
  2478. !#zh
  2479. 动画循环方式。
  2480. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  2481. wrapMode: WrapMode;
  2482. /** !#en The current time of this animation in seconds.
  2483. !#zh 动画当前的时间,秒。 */
  2484. time: number;
  2485. /** !#en The clip that is being played by this animation state.
  2486. !#zh 此动画状态正在播放的剪辑。 */
  2487. clip: AnimationClip;
  2488. /** !#en The name of the playing animation.
  2489. !#zh 动画的名字 */
  2490. name: string;
  2491. }
  2492. /** undefined */
  2493. export class Playable {
  2494. /** !#en Is playing or paused in play mode?
  2495. !#zh 当前是否正在播放。 */
  2496. isPlaying: boolean;
  2497. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  2498. !#zh 当前是否正在暂停 */
  2499. isPaused: boolean;
  2500. /**
  2501. !#en Play this animation.
  2502. !#zh 播放动画。
  2503. */
  2504. play(): void;
  2505. /**
  2506. !#en Stop this animation.
  2507. !#zh 停止动画播放。
  2508. */
  2509. stop(): void;
  2510. /**
  2511. !#en Pause this animation.
  2512. !#zh 暂停动画。
  2513. */
  2514. pause(): void;
  2515. /**
  2516. !#en Resume this animation.
  2517. !#zh 重新播放动画。
  2518. */
  2519. resume(): void;
  2520. /**
  2521. !#en Perform a single frame step.
  2522. !#zh 执行一帧动画。
  2523. */
  2524. step(): void;
  2525. }
  2526. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  2527. !#zh 动画使用的循环模式。 */
  2528. export enum WrapMode {
  2529. Default = 0,
  2530. Normal = 0,
  2531. Reverse = 0,
  2532. Loop = 0,
  2533. LoopReverse = 0,
  2534. PingPong = 0,
  2535. PingPongReverse = 0,
  2536. }
  2537. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  2538. !#zh
  2539. cc.audioengine是单例对象。<br/>
  2540. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  2541. 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放 <br/>
  2542. 注意:<br/>
  2543. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  2544. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  2545. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  2546. export class audioEngine {
  2547. /**
  2548. !#en Play audio.
  2549. !#zh 播放音频
  2550. @param filePath The path of the audio file without filename extension.
  2551. @param loop Whether the music loop or not.
  2552. @param volume Volume size.
  2553. @example
  2554. ```js
  2555. var audioID = cc.audioEngine.play(path, false, 0.5);
  2556. ```
  2557. */
  2558. static play(filePath: string, loop: boolean, volume: number): number;
  2559. /**
  2560. !#en Set audio loop.
  2561. !#zh 设置音频是否循环。
  2562. @param audioID audio id.
  2563. @param loop Whether cycle.
  2564. @example
  2565. ```js
  2566. cc.audioEngine.setLoop(id, true);
  2567. ```
  2568. */
  2569. static setLoop(audioID: number, loop: boolean): void;
  2570. /**
  2571. !#en Get audio cycle state.
  2572. !#zh 获取音频的循环状态。
  2573. @param audioID audio id.
  2574. @example
  2575. ```js
  2576. cc.audioEngine.isLoop(id);
  2577. ```
  2578. */
  2579. static isLoop(audioID: number): boolean;
  2580. /**
  2581. !#en Set the volume of audio.
  2582. !#zh 设置音量(0.0 ~ 1.0)。
  2583. @param audioID audio id.
  2584. @param volume Volume must be in 0.0~1.0 .
  2585. @example
  2586. ```js
  2587. cc.audioEngine.setVolume(id, 0.5);
  2588. ```
  2589. */
  2590. static setVolume(audioID: number, volume: number): void;
  2591. /**
  2592. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  2593. !#zh 获取音量(0.0 ~ 1.0)。
  2594. @param audioID audio id.
  2595. @example
  2596. ```js
  2597. var volume = cc.audioEngine.getVolume(id);
  2598. ```
  2599. */
  2600. static getVolume(audioID: number): boolean;
  2601. /**
  2602. !#en Set current time
  2603. !#zh 设置当前的音频时间。
  2604. @param audioID audio id.
  2605. @param sec current time.
  2606. @example
  2607. ```js
  2608. cc.audioEngine.setCurrentTime(id, 2);
  2609. ```
  2610. */
  2611. static setCurrentTime(audioID: number, sec: number): boolean;
  2612. /**
  2613. !#en Get current time
  2614. !#zh 获取当前的音频播放时间。
  2615. @param audioID audio id.
  2616. @example
  2617. ```js
  2618. var time = cc.audioEngine.getCurrentTime(id);
  2619. ```
  2620. */
  2621. static getCurrentTime(audioID: number): number;
  2622. /**
  2623. !#en Get audio duration
  2624. !#zh 获取音频总时长。
  2625. @param audioID audio id.
  2626. @example
  2627. ```js
  2628. var time = cc.audioEngine.getDuration(id);
  2629. ```
  2630. */
  2631. static getDuration(audioID: number): number;
  2632. /**
  2633. !#en Get audio state
  2634. !#zh 获取音频状态。
  2635. @param audioID audio id.
  2636. @example
  2637. ```js
  2638. var state = cc.audioEngine.getState(id);
  2639. ```
  2640. */
  2641. static getState(audioID: number): audioEngine.AudioState;
  2642. /**
  2643. !#en Set Audio finish callback
  2644. !#zh 设置一个音频结束后的回调
  2645. @param audioID audio id.
  2646. @param callback loaded callback.
  2647. @example
  2648. ```js
  2649. cc.audioEngine.setFinishCallback(id, function () {});
  2650. ```
  2651. */
  2652. static setFinishCallback(audioID: number, callback: Function): void;
  2653. /**
  2654. !#en Pause playing audio.
  2655. !#zh 暂停正在播放音频。
  2656. @param audioID The return value of function play.
  2657. @example
  2658. ```js
  2659. cc.audioEngine.pause(audioID);
  2660. ```
  2661. */
  2662. static pause(audioID: number): void;
  2663. /**
  2664. !#en Pause all playing audio
  2665. !#zh 暂停现在正在播放的所有音频。
  2666. @example
  2667. ```js
  2668. cc.audioEngine.pauseAll();
  2669. ```
  2670. */
  2671. static pauseAll(): void;
  2672. /**
  2673. !#en Resume playing audio.
  2674. !#zh 恢复播放指定的音频。
  2675. @param audioID The return value of function play.
  2676. //example
  2677. cc.audioEngine.resume(audioID);
  2678. */
  2679. static resume(audioID: number): void;
  2680. /**
  2681. !#en Resume all playing audio.
  2682. !#zh 恢复播放所有之前暂停的所有音频。
  2683. @example
  2684. ```js
  2685. cc.audioEngine.resumeAll();
  2686. ```
  2687. */
  2688. static resumeAll(): void;
  2689. /**
  2690. !#en Stop playing audio.
  2691. !#zh 停止播放指定音频。
  2692. @param audioID The return value of function play.
  2693. @example
  2694. ```js
  2695. cc.audioEngine.stop(audioID);
  2696. ```
  2697. */
  2698. static stop(audioID: number): void;
  2699. /**
  2700. !#en Stop all playing audio.
  2701. !#zh 停止正在播放的所有音频。
  2702. @example
  2703. ```js
  2704. cc.audioEngine.stopAll();
  2705. ```
  2706. */
  2707. static stopAll(): void;
  2708. /**
  2709. !#en Set up an audio can generate a few examples.
  2710. !#zh 设置一个音频可以设置几个实例
  2711. @param num a number of instances to be created from within an audio
  2712. @example
  2713. ```js
  2714. cc.audioEngine.setMaxAudioInstance(20);
  2715. ```
  2716. */
  2717. static setMaxAudioInstance(num: number): void;
  2718. /**
  2719. !#en Getting audio can produce several examples.
  2720. !#zh 获取一个音频可以设置几个实例
  2721. @example
  2722. ```js
  2723. cc.audioEngine.getMaxAudioInstance();
  2724. ```
  2725. */
  2726. static getMaxAudioInstance(): number;
  2727. /**
  2728. !#en Unload the preloaded audio from internal buffer.
  2729. !#zh 卸载预加载的音频。
  2730. @param filePath filePath
  2731. @example
  2732. ```js
  2733. cc.audioEngine.uncache(filePath);
  2734. ```
  2735. */
  2736. static uncache(filePath: string): void;
  2737. /**
  2738. !#en Unload all audio from internal buffer.
  2739. !#zh 卸载所有音频。
  2740. @example
  2741. ```js
  2742. cc.audioEngine.uncacheAll();
  2743. ```
  2744. */
  2745. static uncacheAll(): void;
  2746. /**
  2747. !#en Preload audio file.
  2748. !#zh 预加载一个音频
  2749. @param filePath The file path of an audio.
  2750. @param callback The callback of an audio.
  2751. @example
  2752. ```js
  2753. cc.audioEngine.preload(path);
  2754. ```
  2755. */
  2756. static preload(filePath: string, callback?: Function): void;
  2757. /**
  2758. !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
  2759. !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
  2760. @param kb The file path of an audio.
  2761. @example
  2762. ```js
  2763. cc.audioEngine.setMaxWebAudioSize(300);
  2764. ```
  2765. */
  2766. static setMaxWebAudioSize(kb: number): void;
  2767. }
  2768. /** !#en
  2769. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  2770. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  2771. length and color. The fadeTime controls how long it takes each vertex in <br/>
  2772. the streak to fade out, the minimum segment size it how many pixels the <br/>
  2773. streak will move before adding a new ribbon segment, and the texture <br/>
  2774. length is the how many pixels the texture is stretched across. The texture <br/>
  2775. is vertically aligned along the streak segment.
  2776. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  2777. export class MotionStreak extends Component {
  2778. /** !#en
  2779. !#zh 在编辑器模式下预览拖尾效果。 */
  2780. preview: boolean;
  2781. /** !#en The fade time to fade.
  2782. !#zh 拖尾的渐隐时间,以秒为单位。 */
  2783. fadeTime: number;
  2784. /** !#en The minimum segment size.
  2785. !#zh 拖尾之间最小距离。 */
  2786. minSeg: number;
  2787. /** !#en The stroke's width.
  2788. !#zh 拖尾的宽度。 */
  2789. stroke: number;
  2790. /** !#en The texture of the MotionStreak.
  2791. !#zh 拖尾的贴图。 */
  2792. texture: Texture2D;
  2793. /** !#en The color of the MotionStreak.
  2794. !#zh 拖尾的颜色 */
  2795. color: Color;
  2796. /** !#en The fast Mode.
  2797. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  2798. fastMode: boolean;
  2799. /**
  2800. !#en Remove all living segments of the ribbon.
  2801. !#zh 删除当前所有的拖尾片段。
  2802. @example
  2803. ```js
  2804. // stop particle system.
  2805. myParticleSystem.stopSystem();
  2806. ```
  2807. */
  2808. reset(): void;
  2809. }
  2810. /** Particle System base class. <br/>
  2811. Attributes of a Particle System:<br/>
  2812. - emmision rate of the particles<br/>
  2813. - Gravity Mode (Mode A): <br/>
  2814. - gravity <br/>
  2815. - direction <br/>
  2816. - speed +- variance <br/>
  2817. - tangential acceleration +- variance<br/>
  2818. - radial acceleration +- variance<br/>
  2819. - Radius Mode (Mode B): <br/>
  2820. - startRadius +- variance <br/>
  2821. - endRadius +- variance <br/>
  2822. - rotate +- variance <br/>
  2823. - Properties common to all modes: <br/>
  2824. - life +- life variance <br/>
  2825. - start spin +- variance <br/>
  2826. - end spin +- variance <br/>
  2827. - start size +- variance <br/>
  2828. - end size +- variance <br/>
  2829. - start color +- variance <br/>
  2830. - end color +- variance <br/>
  2831. - life +- variance <br/>
  2832. - blending function <br/>
  2833. - texture <br/>
  2834. <br/>
  2835. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  2836. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  2837. cocos2d uses a another approach, but the results are almost identical.<br/>
  2838. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  2839. - spinning particles (supported when using ParticleSystem) <br/>
  2840. - tangential acceleration (Gravity mode) <br/>
  2841. - radial acceleration (Gravity mode) <br/>
  2842. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  2843. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  2844. export class ParticleSystem extends _RendererUnderSG {
  2845. /** !#en Play particle in edit mode.
  2846. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  2847. preview: boolean;
  2848. /** !#en
  2849. If set custom to true, then use custom properties insteadof read particle file.
  2850. !#zh 是否自定义粒子属性。 */
  2851. custom: boolean;
  2852. /** !#en The plist file.
  2853. !#zh plist 格式的粒子配置文件。 */
  2854. file: string;
  2855. /** . */
  2856. texture: Texture2D;
  2857. /** !#en Current quantity of particles that are being simulated.
  2858. !#zh 当前播放的粒子数量。 */
  2859. particleCount: number;
  2860. /** !#en Specify the source Blend Factor.
  2861. !#zh 指定原图混合模式。 */
  2862. srcBlendFactor: BlendFactor;
  2863. /** !#en Specify the destination Blend Factor.
  2864. !#zh 指定目标的混合模式。 */
  2865. dstBlendFactor: BlendFactor;
  2866. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  2867. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  2868. playOnLoad: boolean;
  2869. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  2870. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  2871. autoRemoveOnFinish: boolean;
  2872. /** !#en Indicate whether the particle system is activated.
  2873. !#zh 是否激活粒子。 */
  2874. active: boolean;
  2875. /** !#en Maximum particles of the system.
  2876. !#zh 粒子最大数量。 */
  2877. totalParticles: number;
  2878. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  2879. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  2880. duration: number;
  2881. /** !#en Emission rate of the particles.
  2882. !#zh 每秒发射的粒子数目。 */
  2883. emissionRate: number;
  2884. /** !#en Life of each particle setter.
  2885. !#zh 粒子的运行时间。 */
  2886. life: number;
  2887. /** !#en Variation of life.
  2888. !#zh 粒子的运行时间变化范围。 */
  2889. lifeVar: number;
  2890. /** !#en Start color of each particle.
  2891. !#zh 粒子初始颜色。 */
  2892. startColor: Color;
  2893. /** !#en Variation of the start color.
  2894. !#zh 粒子初始颜色变化范围。 */
  2895. startColorVar: Color;
  2896. /** !#en Ending color of each particle.
  2897. !#zh 粒子结束颜色。 */
  2898. endColor: Color;
  2899. /** !#en Variation of the end color.
  2900. !#zh 粒子结束颜色变化范围。 */
  2901. endColorVar: Color;
  2902. /** !#en Angle of each particle setter.
  2903. !#zh 粒子角度。 */
  2904. angle: number;
  2905. /** !#en Variation of angle of each particle setter.
  2906. !#zh 粒子角度变化范围。 */
  2907. angleVar: number;
  2908. /** !#en Start size in pixels of each particle.
  2909. !#zh 粒子的初始大小。 */
  2910. startSize: number;
  2911. /** !#en Variation of start size in pixels.
  2912. !#zh 粒子初始大小的变化范围。 */
  2913. startSizeVar: number;
  2914. /** !#en End size in pixels of each particle.
  2915. !#zh 粒子结束时的大小。 */
  2916. endSize: number;
  2917. /** !#en Variation of end size in pixels.
  2918. !#zh 粒子结束大小的变化范围。 */
  2919. endSizeVar: number;
  2920. /** !#en Start angle of each particle.
  2921. !#zh 粒子开始自旋角度。 */
  2922. startSpin: number;
  2923. /** !#en Variation of start angle.
  2924. !#zh 粒子开始自旋角度变化范围。 */
  2925. startSpinVar: number;
  2926. /** !#en End angle of each particle.
  2927. !#zh 粒子结束自旋角度。 */
  2928. endSpin: number;
  2929. /** !#en Variation of end angle.
  2930. !#zh 粒子结束自旋角度变化范围。 */
  2931. endSpinVar: number;
  2932. /** !#en Source position of the emitter.
  2933. !#zh 发射器位置。 */
  2934. sourcePos: Vec2;
  2935. /** !#en Variation of source position.
  2936. !#zh 发射器位置的变化范围。(横向和纵向) */
  2937. posVar: Vec2;
  2938. /** !#en Particles movement type.
  2939. !#zh 粒子位置类型。 */
  2940. positionType: ParticleSystem.PositionType;
  2941. /** !#en Particles emitter modes.
  2942. !#zh 发射器类型。 */
  2943. emitterMode: ParticleSystem.EmitterMode;
  2944. /** !#en Gravity of the emitter.
  2945. !#zh 重力。 */
  2946. gravity: Vec2;
  2947. /** !#en Speed of the emitter.
  2948. !#zh 速度。 */
  2949. speed: number;
  2950. /** !#en Variation of the speed.
  2951. !#zh 速度变化范围。 */
  2952. speedVar: number;
  2953. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  2954. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  2955. tangentialAccel: number;
  2956. /** !#en Variation of the tangential acceleration.
  2957. !#zh 每个粒子的切向加速度变化范围。 */
  2958. tangentialAccelVar: number;
  2959. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  2960. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  2961. radialAccel: number;
  2962. /** !#en Variation of the radial acceleration.
  2963. !#zh 粒子径向加速度变化范围。 */
  2964. radialAccelVar: number;
  2965. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  2966. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  2967. rotationIsDir: boolean;
  2968. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  2969. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  2970. startRadius: number;
  2971. /** !#en Variation of the starting radius.
  2972. !#zh 初始半径变化范围。 */
  2973. startRadiusVar: number;
  2974. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  2975. !#zh 结束半径,只有在半径模式下可用。 */
  2976. endRadius: number;
  2977. /** !#en Variation of the ending radius.
  2978. !#zh 结束半径变化范围。 */
  2979. endRadiusVar: number;
  2980. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  2981. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  2982. rotatePerS: number;
  2983. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  2984. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  2985. rotatePerSVar: number;
  2986. /** !#en The Particle emitter lives forever.
  2987. !#zh 表示发射器永久存在 */
  2988. static DURATION_INFINITY: number;
  2989. /** !#en The starting size of the particle is equal to the ending size.
  2990. !#zh 表示粒子的起始大小等于结束大小。 */
  2991. static START_SIZE_EQUAL_TO_END_SIZE: number;
  2992. /** !#en The starting radius of the particle is equal to the ending radius.
  2993. !#zh 表示粒子的起始半径等于结束半径。 */
  2994. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  2995. /**
  2996. !#en Add a particle to the emitter.
  2997. !#zh 添加一个粒子到发射器中。
  2998. */
  2999. addParticle(): boolean;
  3000. /**
  3001. !#en Stop emitting particles. Running particles will continue to run until they die.
  3002. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  3003. @example
  3004. ```js
  3005. // stop particle system.
  3006. myParticleSystem.stopSystem();
  3007. ```
  3008. */
  3009. stopSystem(): void;
  3010. /**
  3011. !#en Kill all living particles.
  3012. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  3013. @example
  3014. ```js
  3015. // play particle system.
  3016. myParticleSystem.resetSystem();
  3017. ```
  3018. */
  3019. resetSystem(): void;
  3020. /**
  3021. !#en Whether or not the system is full.
  3022. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  3023. */
  3024. isFull(): boolean;
  3025. /**
  3026. !#en
  3027. <p> Sets a new CCSpriteFrame as particle.</br>
  3028. WARNING: this method is experimental. Use setTextureWithRect instead.
  3029. </p>
  3030. !#zh
  3031. <p> 设置一个新的精灵帧为粒子。</br>
  3032. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  3033. </p>
  3034. @param spriteFrame spriteFrame
  3035. */
  3036. setDisplayFrame(spriteFrame: SpriteFrame): void;
  3037. /**
  3038. !#en Sets a new texture with a rect. The rect is in texture position and size.
  3039. !#zh 设置一张新贴图和关联的矩形。
  3040. @param texture texture
  3041. @param rect rect
  3042. */
  3043. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  3044. }
  3045. /** !#en Renders the TMX object.
  3046. !#zh 渲染 tmx object。 */
  3047. export class TMXObject {
  3048. /**
  3049. !#en Get the name of object
  3050. !#zh 获取对象的名称
  3051. */
  3052. getObjectName(): string;
  3053. /**
  3054. !#en Get the property of object
  3055. !#zh 获取对象的属性
  3056. */
  3057. getProperty(): any;
  3058. /**
  3059. !#en Get the properties of object
  3060. !#zh 获取对象的属性
  3061. */
  3062. getProperties(): any;
  3063. /**
  3064. !#en Set the object name
  3065. !#zh 设置对象名称
  3066. @param name name
  3067. */
  3068. setObjectName(name: string): void;
  3069. /**
  3070. !#en Set the properties of the object
  3071. !#zh 设置对象的属性
  3072. @param props props
  3073. */
  3074. setProperties(props: any): void;
  3075. }
  3076. /** !#en Render the TMX layer.
  3077. !#zh 渲染 TMX layer。 */
  3078. export class TiledLayer extends _SGComponent {
  3079. /**
  3080. !#en Gets the layer name.
  3081. !#zh 获取层的名称。
  3082. @example
  3083. ```js
  3084. var layerName = tiledLayer.getLayerName();
  3085. cc.log(layerName);
  3086. ```
  3087. */
  3088. getLayerName(): string;
  3089. /**
  3090. !#en Set the layer name.
  3091. !#zh 设置层的名称
  3092. @param layerName layerName
  3093. @example
  3094. ```js
  3095. tiledLayer.setLayerName("New Layer");
  3096. ```
  3097. */
  3098. SetLayerName(layerName: string): void;
  3099. /**
  3100. !#en Return the value for the specific property name.
  3101. !#zh 获取指定属性名的值。
  3102. @param propertyName propertyName
  3103. @example
  3104. ```js
  3105. var property = tiledLayer.getProperty("info");
  3106. cc.log(property);
  3107. ```
  3108. */
  3109. getProperty(propertyName: string): any;
  3110. /**
  3111. !#en Returns the position in pixels of a given tile coordinate.
  3112. !#zh 获取指定 tile 的像素坐标。
  3113. @param pos position or x
  3114. @param y y
  3115. @example
  3116. ```js
  3117. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  3118. cc.log("Pos: " + pos);
  3119. var pos = tiledLayer.getPositionAt(0, 0);
  3120. cc.log("Pos: " + pos);
  3121. ```
  3122. */
  3123. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  3124. /**
  3125. !#en Removes a tile at given tile coordinate.
  3126. !#zh 删除指定坐标上的 tile。
  3127. @param pos position or x
  3128. @param y y
  3129. @example
  3130. ```js
  3131. tiledLayer.removeTileAt(cc.v2(0, 0));
  3132. tiledLayer.removeTileAt(0, 0);
  3133. ```
  3134. */
  3135. removeTileAt(pos: Vec2|number, y?: number): void;
  3136. /**
  3137. !#en
  3138. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  3139. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  3140. If a tile is already placed at that position, then it will be removed.
  3141. !#zh
  3142. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  3143. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  3144. 如果一个 tile 已经放在那个位置,那么它将被删除。
  3145. @param gid gid
  3146. @param posOrX position or x
  3147. @param flagsOrY flags or y
  3148. @param flags flags
  3149. @example
  3150. ```js
  3151. tiledLayer.setTileGID(1001, 10, 10, 1)
  3152. ```
  3153. */
  3154. setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  3155. /**
  3156. !#en
  3157. Returns the tile gid at a given tile coordinate. <br />
  3158. if it returns 0, it means that the tile is empty. <br />
  3159. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  3160. !#zh
  3161. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  3162. 如果它返回 0,则表示该 tile 为空。<br />
  3163. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  3164. @param pos or x
  3165. @param y y
  3166. @example
  3167. ```js
  3168. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  3169. ```
  3170. */
  3171. getTileGIDAt(pos: Vec2|number, y?: number): number;
  3172. /**
  3173. !#en
  3174. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  3175. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  3176. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  3177. You can remove either by calling: <br/>
  3178. - layer.removeChild(sprite, cleanup); <br/>
  3179. - or layer.removeTileAt(ccp(x,y));
  3180. !#zh
  3181. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  3182. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  3183. 你可以通过调用以下方法来对它进行删除:<br/>
  3184. 1. layer.removeChild(sprite, cleanup);<br/>
  3185. 2. 或 layer.removeTileAt(cc.v2(x,y));
  3186. @param pos or x
  3187. @param y y
  3188. @example
  3189. ```js
  3190. var title = tiledLayer.getTileAt(100, 100);
  3191. cc.log(title);
  3192. ```
  3193. */
  3194. getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite;
  3195. /**
  3196. !#en
  3197. Dealloc the map that contains the tile position from memory. <br />
  3198. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  3199. If you are going to call layer.getTileGIDAt() then, don't release the map.
  3200. !#zh
  3201. 从内存中释放包含 tile 位置信息的地图。<br />
  3202. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  3203. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  3204. @example
  3205. ```js
  3206. tiledLayer.releaseMap();
  3207. ```
  3208. */
  3209. releaseMap(): void;
  3210. /**
  3211. !#en Sets the untransformed size of the _ccsg.TMXLayer.
  3212. !#zh 设置未转换的 layer 大小。
  3213. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  3214. @param height The untransformed size's height of the _ccsg.TMXLayer.
  3215. @example
  3216. ```js
  3217. tiledLayer.setContentSize(100, 100);
  3218. ```
  3219. */
  3220. setContentSize(size: Size|number, height?: number): void;
  3221. /**
  3222. !#en Return texture of cc.SpriteBatchNode.
  3223. !#zh 获取纹理。
  3224. @example
  3225. ```js
  3226. var texture = tiledLayer.getTexture();
  3227. cc.log("Texture: " + texture);
  3228. ```
  3229. */
  3230. getTexture(): Texture2D;
  3231. /**
  3232. !#en Set the texture of cc.SpriteBatchNode.
  3233. !#zh 设置纹理。
  3234. @param texture texture
  3235. @example
  3236. ```js
  3237. tiledLayer.setTexture(texture);
  3238. ```
  3239. */
  3240. setTexture(texture: Texture2D): void;
  3241. /**
  3242. !#en Set the opacity of all tiles
  3243. !#zh 设置所有 Tile 的透明度
  3244. @param opacity opacity
  3245. @example
  3246. ```js
  3247. tiledLayer.setTileOpacity(128);
  3248. ```
  3249. */
  3250. setTileOpacity(opacity: number): void;
  3251. /**
  3252. !#en Gets layer size.
  3253. !#zh 获得层大小。
  3254. @example
  3255. ```js
  3256. var size = tiledLayer.getLayerSize();
  3257. cc.log("layer size: " + size);
  3258. ```
  3259. */
  3260. getLayerSize(): Size;
  3261. /**
  3262. !#en Set layer size.
  3263. !#zh 设置层大小。
  3264. @param layerSize layerSize
  3265. @example
  3266. ```js
  3267. tiledLayer.setLayerSize(new cc.size(5, 5));
  3268. ```
  3269. */
  3270. setLayerSize(layerSize: Size): void;
  3271. /**
  3272. !#en Size of the map's tile (could be different from the tile's size).
  3273. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  3274. @example
  3275. ```js
  3276. var mapTileSize = tiledLayer.getMapTileSize();
  3277. cc.log("MapTile size: " + mapTileSize);
  3278. ```
  3279. */
  3280. getMapTileSize(): Size;
  3281. /**
  3282. !#en Set the map tile size.
  3283. !#zh 设置 tile 的大小。
  3284. @param tileSize tileSize
  3285. @example
  3286. ```js
  3287. tiledLayer.setMapTileSize(new cc.size(10, 10));
  3288. ```
  3289. */
  3290. setMapTileSize(tileSize: Size): void;
  3291. /**
  3292. !#en Pointer to the map of tiles.
  3293. !#zh 获取地图 tiles。
  3294. @example
  3295. ```js
  3296. var tiles = tiledLayer.getTiles();
  3297. ```
  3298. */
  3299. getTiles(): any[];
  3300. /**
  3301. !#en Pointer to the map of tiles.
  3302. !#zh 设置地图 tiles
  3303. @param tiles tiles
  3304. @example
  3305. ```js
  3306. tiledLayer.setTiles(tiles);
  3307. ```
  3308. */
  3309. setTiles(tiles: any[]): void;
  3310. /**
  3311. !#en Tile set information for the layer.
  3312. !#zh 获取 layer 的 Tileset 信息。
  3313. @example
  3314. ```js
  3315. var tileset = tiledLayer.getTileSet();
  3316. ```
  3317. */
  3318. getTileSet(): TMXTilesetInfo;
  3319. /**
  3320. !#en Tile set information for the layer.
  3321. !#zh 设置 layer 的 Tileset 信息。
  3322. @param tileset tileset
  3323. @example
  3324. ```js
  3325. tiledLayer.setTileSet(tileset);
  3326. ```
  3327. */
  3328. setTileSet(tileset: TMXTilesetInfo): void;
  3329. /**
  3330. !#en Layer orientation, which is the same as the map orientation.
  3331. !#zh 获取 Layer 方向(同地图方向)。
  3332. @example
  3333. ```js
  3334. var orientation = tiledLayer.getLayerOrientation();
  3335. cc.log("Layer Orientation: " + orientation);
  3336. ```
  3337. */
  3338. getLayerOrientation(): number;
  3339. /**
  3340. !#en Layer orientation, which is the same as the map orientation.
  3341. !#zh 设置 Layer 方向(同地图方向)。
  3342. @param orientation orientation
  3343. @example
  3344. ```js
  3345. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  3346. ```
  3347. */
  3348. setLayerOrientation(orientation: TiledMap.Orientation): void;
  3349. /**
  3350. !#en properties from the layer. They can be added using Tiled.
  3351. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  3352. @example
  3353. ```js
  3354. var properties = tiledLayer.getProperties();
  3355. cc.log("Properties: " + properties);
  3356. ```
  3357. */
  3358. getProperties(): any[];
  3359. /**
  3360. !#en properties from the layer. They can be added using Tiled.
  3361. !#zh 设置层属性。
  3362. @param properties properties
  3363. @example
  3364. ```js
  3365. tiledLayer.setLayerOrientation(properties);
  3366. ```
  3367. */
  3368. setProperties(properties: any[]): void;
  3369. }
  3370. /** !#en Renders a TMX Tile Map in the scene.
  3371. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  3372. export class TiledMap extends Component {
  3373. /** !#en The TiledMap Asset.
  3374. !#zh TiledMap 资源。 */
  3375. tmxAsset: TiledMapAsset;
  3376. /**
  3377. !#en Gets the map size.
  3378. !#zh 获取地图大小。
  3379. @example
  3380. ```js
  3381. var mapSize = tiledMap.getMapSize();
  3382. cc.log("Map Size: " + mapSize);
  3383. ```
  3384. */
  3385. getMapSize(): Size;
  3386. /**
  3387. !#en Set the map size.
  3388. !#zh 设置地图大小。
  3389. @param mapSize mapSize
  3390. @example
  3391. ```js
  3392. tiledMap.setMapSize(new cc.size(960, 640));
  3393. ```
  3394. */
  3395. setMapSize(mapSize: Size): void;
  3396. /**
  3397. !#en Gets the tile size.
  3398. !#zh 获取地图背景中 tile 元素的大小。
  3399. @example
  3400. ```js
  3401. var tileSize = tiledMap.getTileSize();
  3402. cc.log("Tile Size: " + tileSize);
  3403. ```
  3404. */
  3405. getTileSize(): Size;
  3406. /**
  3407. !#en Set the tile size.
  3408. !#zh 设置地图背景中 tile 元素的大小。
  3409. @param tileSize tileSize
  3410. @example
  3411. ```js
  3412. tiledMap.setTileSize(new cc.size(10, 10));
  3413. ```
  3414. */
  3415. setTileSize(tileSize: Size): void;
  3416. /**
  3417. !#en map orientation.
  3418. !#zh 获取地图方向。
  3419. @example
  3420. ```js
  3421. var mapOrientation = tiledMap.getMapOrientation();
  3422. cc.log("Map Orientation: " + mapOrientation);
  3423. ```
  3424. */
  3425. getMapOrientation(): number;
  3426. /**
  3427. !#en map orientation.
  3428. !#zh 设置地图方向。
  3429. @param orientation orientation
  3430. @example
  3431. ```js
  3432. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  3433. ```
  3434. */
  3435. setMapOrientation(orientation: TiledMap.Orientation): void;
  3436. /**
  3437. !#en object groups.
  3438. !#zh 获取所有的对象层。
  3439. @example
  3440. ```js
  3441. var objGroups = titledMap.getObjectGroups();
  3442. for (var i = 0; i < objGroups.length; ++i) {
  3443. cc.log("obj: " + objGroups[i]);
  3444. }
  3445. ```
  3446. */
  3447. getObjectGroups(): TiledObjectGroup[];
  3448. /**
  3449. !#en Gets the map properties.
  3450. !#zh 获取地图的属性。
  3451. @example
  3452. ```js
  3453. var properties = titledMap.getProperties();
  3454. for (var i = 0; i < properties.length; ++i) {
  3455. cc.log("Properties: " + properties[i]);
  3456. }
  3457. ```
  3458. */
  3459. getProperties(): any[];
  3460. /**
  3461. !#en Set the map properties.
  3462. !#zh 设置地图的属性。
  3463. @param properties properties
  3464. @example
  3465. ```js
  3466. titledMap.setProperties(properties);
  3467. ```
  3468. */
  3469. setProperties(properties: any[]): void;
  3470. /**
  3471. !#en Return All layers array.
  3472. !#zh 返回包含所有 layer 的数组。
  3473. @example
  3474. ```js
  3475. var layers = titledMap.allLayers();
  3476. for (var i = 0; i < layers.length; ++i) {
  3477. cc.log("Layers: " + layers[i]);
  3478. }
  3479. ```
  3480. */
  3481. allLayers(): TiledLayer[];
  3482. /**
  3483. !#en return the cc.TiledLayer for the specific layer.
  3484. !#zh 获取指定名称的 layer。
  3485. @param layerName layerName
  3486. @example
  3487. ```js
  3488. var layer = titledMap.getLayer("Player");
  3489. cc.log(layer);
  3490. ```
  3491. */
  3492. getLayer(layerName: string): TiledLayer;
  3493. /**
  3494. !#en Return the TMXObjectGroup for the specific group.
  3495. !#zh 获取指定的 TMXObjectGroup。
  3496. @param groupName groupName
  3497. @example
  3498. ```js
  3499. var group = titledMap.getObjectGroup("Players");
  3500. cc.log("ObjectGroup: " + group);
  3501. ```
  3502. */
  3503. getObjectGroup(groupName: string): TiledObjectGroup;
  3504. /**
  3505. !#en Return the value for the specific property name.
  3506. !#zh 通过属性名称,获取指定的属性。
  3507. @param propertyName propertyName
  3508. @example
  3509. ```js
  3510. var property = titledMap.getProperty("info");
  3511. cc.log("Property: " + property);
  3512. ```
  3513. */
  3514. getProperty(propertyName: string): string;
  3515. /**
  3516. !#en Return properties dictionary for tile GID.
  3517. !#zh 通过 GID ,获取指定的属性。
  3518. @param GID GID
  3519. @example
  3520. ```js
  3521. var properties = titledMap.getPropertiesForGID(GID);
  3522. cc.log("Properties: " + properties);
  3523. ```
  3524. */
  3525. getPropertiesForGID(GID: number): any;
  3526. }
  3527. /** !#en Renders the TMX object group.
  3528. !#zh 渲染 tmx object group。 */
  3529. export class TiledObjectGroup extends _SGComponent {
  3530. /**
  3531. !#en Offset position of child objects.
  3532. !#zh 获取子对象的偏移位置。
  3533. @example
  3534. ```js
  3535. var offset = tMXObjectGroup.getPositionOffset();
  3536. ```
  3537. */
  3538. getPositionOffset(): Vec2;
  3539. /**
  3540. !#en Offset position of child objects.
  3541. !#zh 设置子对象的偏移位置。
  3542. @param offset offset
  3543. @example
  3544. ```js
  3545. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  3546. ```
  3547. */
  3548. setPositionOffset(offset: Vec2): void;
  3549. /**
  3550. !#en List of properties stored in a dictionary.
  3551. !#zh 以映射的形式获取属性列表。
  3552. @example
  3553. ```js
  3554. var offset = tMXObjectGroup.getProperties();
  3555. ```
  3556. */
  3557. getProperties(): any;
  3558. /**
  3559. !#en Set the properties of the object group.
  3560. !#zh 设置属性列表。
  3561. @param Var Var
  3562. @example
  3563. ```js
  3564. tMXObjectGroup.setProperties(obj);
  3565. ```
  3566. */
  3567. setProperties(Var: any): void;
  3568. /**
  3569. !#en Gets the Group name.
  3570. !#zh 获取组名称。
  3571. @example
  3572. ```js
  3573. var groupName = tMXObjectGroup.getGroupName;
  3574. ```
  3575. */
  3576. getGroupName(): string;
  3577. /**
  3578. !#en Set the Group name.
  3579. !#zh 设置组名称。
  3580. @param groupName groupName
  3581. @example
  3582. ```js
  3583. tMXObjectGroup.setGroupName("New Group");
  3584. ```
  3585. */
  3586. setGroupName(groupName: string): void;
  3587. /**
  3588. !#en
  3589. Return the object for the specific object name. <br />
  3590. It will return the 1st object found on the array for the given name.
  3591. !#zh 获取指定的对象。
  3592. @param objectName objectName
  3593. @example
  3594. ```js
  3595. var object = tMXObjectGroup.getObject("Group");
  3596. ```
  3597. */
  3598. getObject(objectName: string): any;
  3599. /**
  3600. !#en Gets the objects.
  3601. !#zh 获取对象数组。
  3602. @example
  3603. ```js
  3604. var objects = tMXObjectGroup.getObjects();
  3605. ```
  3606. */
  3607. getObjects(): any[];
  3608. }
  3609. /** Class for tiled map asset handling. */
  3610. export class TiledMapAsset extends Asset {
  3611. }
  3612. /** !#en
  3613. <p>
  3614. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  3615. cc.director is a singleton object which manage your game's logic flow.<br/>
  3616. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  3617. the standard way to use it is by calling:<br/>
  3618. - cc.director.methodName(); <br/>
  3619. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  3620. <br/>
  3621. The cc.director is also responsible for:<br/>
  3622. - initializing the OpenGL context<br/>
  3623. - setting the OpenGL pixel format (default on is RGB565)<br/>
  3624. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  3625. - setting the color for clear screen (default one is BLACK)<br/>
  3626. - setting the projection (default one is 3D)<br/>
  3627. - setting the orientation (default one is Portrait)<br/>
  3628. <br/>
  3629. <br/>
  3630. The cc.director also sets the default OpenGL context:<br/>
  3631. - GL_TEXTURE_2D is enabled<br/>
  3632. - GL_VERTEX_ARRAY is enabled<br/>
  3633. - GL_COLOR_ARRAY is enabled<br/>
  3634. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  3635. </p>
  3636. <p>
  3637. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  3638. Features and Limitations:<br/>
  3639. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  3640. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  3641. </p>
  3642. !#zh
  3643. <p>
  3644. 注意:用 cc.director 代替 cc.Director。<br/>
  3645. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  3646. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  3647. 使用它的标准方法是通过调用:<br/>
  3648. - cc.director.methodName();
  3649. <br/>
  3650. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  3651. <br/>
  3652. cc.director 还负责:<br/>
  3653. - 初始化 OpenGL 环境。<br/>
  3654. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  3655. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  3656. - 设置空白场景的颜色 (默认是 黑色)<br/>
  3657. - 设置投影 (默认是 3D)<br/>
  3658. - 设置方向 (默认是 Portrait)<br/>
  3659. <br/>
  3660. cc.director 设置了 OpenGL 默认环境 <br/>
  3661. - GL_TEXTURE_2D 启用。<br/>
  3662. - GL_VERTEX_ARRAY 启用。<br/>
  3663. - GL_COLOR_ARRAY 启用。<br/>
  3664. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  3665. </p>
  3666. <p>
  3667. cc.director 也同步定时器与显示器的刷新速率。
  3668. <br/>
  3669. 特点和局限性: <br/>
  3670. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  3671. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  3672. </p> */
  3673. export class Director extends EventTarget {
  3674. /**
  3675. !#en
  3676. Converts an OpenGL coordinate to a view coordinate<br/>
  3677. Useful to convert node points to window points for calls such as glScissor<br/>
  3678. Implementation can be found in CCDirectorWebGL.
  3679. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  3680. @param glPoint glPoint
  3681. */
  3682. convertToUI(glPoint: Vec2): Vec2;
  3683. /**
  3684. !#en
  3685. Returns the size of the WebGL view in points.<br/>
  3686. It takes into account any possible rotation (device orientation) of the window.
  3687. !#zh 获取视图的大小,以点为单位。
  3688. */
  3689. getWinSize(): Size;
  3690. /**
  3691. !#en
  3692. Returns the size of the OpenGL view in pixels.<br/>
  3693. It takes into account any possible rotation (device orientation) of the window.<br/>
  3694. On Mac winSize and winSizeInPixels return the same value.
  3695. !#zh 获取视图大小,以像素为单位。
  3696. */
  3697. getWinSizeInPixels(): Size;
  3698. /**
  3699. !#en Returns the visible size of the running scene.
  3700. !#zh 获取运行场景的可见大小。
  3701. */
  3702. getVisibleSize(): Size;
  3703. /**
  3704. !#en Returns the visible origin of the running scene.
  3705. !#zh 获取视图在游戏内容中的坐标原点。
  3706. */
  3707. getVisibleOrigin(): Vec2;
  3708. /**
  3709. !#en Pause the director's ticker, only involve the game logic execution.
  3710. It won't pause the rendering process nor the event manager.
  3711. If you want to pause the entier game including rendering, audio and event,
  3712. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  3713. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  3714. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  3715. */
  3716. pause(): void;
  3717. /**
  3718. !#en
  3719. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  3720. The new scene will be launched immediately.
  3721. !#zh 立刻切换指定场景。
  3722. @param scene The need run scene.
  3723. @param onBeforeLoadScene The function invoked at the scene before loading.
  3724. @param onLaunched The function invoked at the scene after launch.
  3725. */
  3726. runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  3727. /**
  3728. !#en Loads the scene by its name.
  3729. !#zh 通过场景名称进行加载场景。
  3730. @param sceneName The name of the scene to load.
  3731. @param onLaunched callback, will be called after scene launched.
  3732. */
  3733. loadScene(sceneName: string, onLaunched?: Function): boolean;
  3734. /**
  3735. !#en
  3736. Preloads the scene to reduces loading time. You can call this method at any time you want.
  3737. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  3738. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  3739. yet finished, the scene will be launched after loaded automatically.
  3740. !#zh 预加载场景,你可以在任何时候调用这个方法。
  3741. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  3742. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  3743. @param sceneName The name of the scene to preload.
  3744. @param onLoaded callback, will be called after scene loaded.
  3745. */
  3746. preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void;
  3747. /**
  3748. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  3749. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  3750. */
  3751. resume(): void;
  3752. /**
  3753. !#en
  3754. Enables or disables WebGL depth test.<br/>
  3755. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  3756. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  3757. @param on on
  3758. */
  3759. setDepthTest(on: boolean): void;
  3760. /**
  3761. !#en
  3762. Set color for clear screen.<br/>
  3763. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  3764. !#zh
  3765. 设置场景的默认擦除颜色。<br/>
  3766. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  3767. @param clearColor clearColor
  3768. */
  3769. setClearColor(clearColor: Color): void;
  3770. /**
  3771. !#en
  3772. Sets an OpenGL projection.<br/>
  3773. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3774. !#zh 设置 OpenGL 投影。
  3775. @param projection projection
  3776. */
  3777. setProjection(projection: number): void;
  3778. /**
  3779. !#en
  3780. Update the view port.<br/>
  3781. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3782. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  3783. */
  3784. setViewport(): void;
  3785. /**
  3786. !#en
  3787. Sets an OpenGL projection.<br/>
  3788. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3789. !#zh 获取 OpenGL 投影。
  3790. */
  3791. getProjection(): number;
  3792. /**
  3793. !#en
  3794. Enables/disables OpenGL alpha blending.<br/>
  3795. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  3796. !#zh 启用/禁用 透明度融合。
  3797. @param on on
  3798. */
  3799. setAlphaBlending(on: boolean): void;
  3800. /**
  3801. !#en
  3802. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  3803. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  3804. If the new scene replaces the old one, the it will receive the "cleanup" message.
  3805. !#zh
  3806. 更换场景时是否接收清理消息。<br>
  3807. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  3808. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  3809. */
  3810. isSendCleanupToScene(): boolean;
  3811. /**
  3812. !#en Returns current logic Scene.
  3813. !#zh 获取当前逻辑场景。
  3814. @example
  3815. ```js
  3816. // This will help you to get the Canvas node in scene
  3817. cc.director.getScene().getChildByName('Canvas');
  3818. ```
  3819. */
  3820. getScene(): Scene;
  3821. /**
  3822. !#en Returns the FPS value.
  3823. !#zh 获取单位帧执行时间。
  3824. */
  3825. getAnimationInterval(): number;
  3826. /**
  3827. !#en Returns whether or not to display the FPS informations.
  3828. !#zh 获取是否显示 FPS 信息。
  3829. */
  3830. isDisplayStats(): boolean;
  3831. /**
  3832. !#en Sets whether display the FPS on the bottom-left corner.
  3833. !#zh 设置是否在左下角显示 FPS。
  3834. @param displayStats displayStats
  3835. */
  3836. setDisplayStats(displayStats: boolean): void;
  3837. /**
  3838. !#en Returns whether next delta time equals to zero.
  3839. !#zh 返回下一个 “delta time” 是否等于零。
  3840. */
  3841. isNextDeltaTimeZero(): boolean;
  3842. /**
  3843. !#en Returns whether or not the Director is paused.
  3844. !#zh 是否处于暂停状态。
  3845. */
  3846. isPaused(): boolean;
  3847. /**
  3848. !#en Returns how many frames were called since the director started.
  3849. !#zh 获取 director 启动以来游戏运行的总帧数。
  3850. */
  3851. getTotalFrames(): number;
  3852. /**
  3853. !#en Returns the cc.Scheduler associated with this director.
  3854. !#zh 获取和 director 相关联的 cc.Scheduler。
  3855. */
  3856. getScheduler(): Scheduler;
  3857. /**
  3858. !#en Sets the cc.Scheduler associated with this director.
  3859. !#zh 设置和 director 相关联的 cc.Scheduler。
  3860. @param scheduler scheduler
  3861. */
  3862. setScheduler(scheduler: Scheduler): void;
  3863. /**
  3864. !#en Returns the cc.ActionManager associated with this director.
  3865. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  3866. */
  3867. getActionManager(): ActionManager;
  3868. /**
  3869. !#en Sets the cc.ActionManager associated with this director.
  3870. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  3871. @param actionManager actionManager
  3872. */
  3873. setActionManager(actionManager: ActionManager): void;
  3874. /**
  3875. Returns the cc.CollisionManager associated with this director.
  3876. */
  3877. getCollisionManager(): CollisionManager;
  3878. /**
  3879. Returns the cc.PhysicsManager associated with this director.
  3880. */
  3881. getPhysicsManager(): PhysicsManager;
  3882. /**
  3883. !#en Returns the delta time since last frame.
  3884. !#zh 获取上一帧的 “delta time”。
  3885. */
  3886. getDeltaTime(): number;
  3887. /** !#en The event projection changed of cc.Director.
  3888. !#zh cc.Director 投影变化的事件。 */
  3889. static EVENT_PROJECTION_CHANGED: string;
  3890. /** !#en The event which will be triggered before loading a new scene.
  3891. !#zh 加载新场景之前所触发的事件。 */
  3892. static EVENT_BEFORE_SCENE_LOADING: string;
  3893. /** !#en The event which will be triggered before launching a new scene.
  3894. !#zh 运行新场景之前所触发的事件。 */
  3895. static EVENT_BEFORE_SCENE_LAUNCH: string;
  3896. /** !#en The event which will be triggered after launching a new scene.
  3897. !#zh 运行新场景之后所触发的事件。 */
  3898. static EVENT_AFTER_SCENE_LAUNCH: string;
  3899. /** !#en The event which will be triggered at the beginning of every frame.
  3900. !#zh 每个帧的开始时所触发的事件。 */
  3901. static EVENT_BEFORE_UPDATE: string;
  3902. /** !#en The event which will be triggered after engine and components update logic.
  3903. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  3904. static EVENT_AFTER_UPDATE: string;
  3905. /** !#en The event which will be triggered before visiting the rendering scene graph.
  3906. !#zh 访问渲染场景树之前所触发的事件。 */
  3907. static EVENT_BEFORE_VISIT: string;
  3908. /** !#en
  3909. The event which will be triggered after visiting the rendering scene graph,
  3910. the render queue is ready but not rendered at this point.
  3911. !#zh
  3912. 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */
  3913. static EVENT_AFTER_VISIT: string;
  3914. /** !#en The event which will be triggered after the rendering process.
  3915. !#zh 渲染过程之后所触发的事件。 */
  3916. static EVENT_AFTER_DRAW: string;
  3917. /** Constant for 2D projection (orthogonal projection) */
  3918. static PROJECTION_2D: number;
  3919. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  3920. static PROJECTION_3D: number;
  3921. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  3922. static PROJECTION_CUSTOM: number;
  3923. /** Constant for default projection of cc.Director, default projection is 2D projection */
  3924. static PROJECTION_DEFAULT: number;
  3925. }
  3926. /** !#en cc.game is the singleton object for game related functions.
  3927. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  3928. export class Game extends EventTarget {
  3929. /** !#en Event triggered when game hide to background.
  3930. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3931. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  3932. !#zh 游戏进入后台时触发的事件。
  3933. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3934. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  3935. EVENT_HIDE: string;
  3936. /** Event triggered when game back to foreground
  3937. Please note that this event is not 100% guaranteed to be fired on Web platform,
  3938. on native platforms, it corresponds to enter foreground event.
  3939. !#zh 游戏进入前台运行时触发的事件。
  3940. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  3941. 在原生平台,它对应的是应用被切换到前台事件。 */
  3942. EVENT_SHOW: string;
  3943. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  3944. EVENT_GAME_INITED: string;
  3945. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  3946. EVENT_RENDERER_INITED: string;
  3947. /** Key of config */
  3948. CONFIG_KEY: any;
  3949. /** !#en The outer frame of the game canvas, parent of cc.container.
  3950. !#zh 游戏画布的外框,cc.container 的父类。 */
  3951. frame: any;
  3952. /** !#en The container of game canvas, equals to cc.container.
  3953. !#zh 游戏画布的容器。 */
  3954. container: HTMLDivElement;
  3955. /** !#en The canvas of the game, equals to cc._canvas.
  3956. !#zh 游戏的画布。 */
  3957. canvas: HTMLCanvasElement;
  3958. /** !#en
  3959. The current game configuration, including:<br/>
  3960. 1. debugMode<br/>
  3961. "debugMode" possible values :<br/>
  3962. 0 - No message will be printed. <br/>
  3963. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  3964. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  3965. 3 - cc.error, cc.assert will print in console. <br/>
  3966. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  3967. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  3968. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  3969. 2. showFPS<br/>
  3970. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  3971. 3. exposeClassName<br/>
  3972. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  3973. 4. frameRate<br/>
  3974. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  3975. 5. id<br/>
  3976. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  3977. 6. renderMode<br/>
  3978. "renderMode" sets the renderer type, only useful on web :<br/>
  3979. 0 - Automatically chosen by engine<br/>
  3980. 1 - Forced to use canvas renderer<br/>
  3981. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  3982. 7. scenes<br/>
  3983. "scenes" include available scenes in the current bundle.<br/>
  3984. <br/>
  3985. Please DO NOT modify this object directly, it won't have any effect.<br/>
  3986. !#zh
  3987. 当前的游戏配置,包括: <br/>
  3988. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  3989. "debugMode" 各种设置选项的意义。 <br/>
  3990. 0 - 没有消息被打印出来。 <br/>
  3991. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  3992. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  3993. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  3994. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3995. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3996. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  3997. 2. showFPS(显示 FPS) <br/>
  3998. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  3999. 3. exposeClassName <br/>
  4000. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  4001. 4. frameRate (帧率) <br/>
  4002. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  4003. 5. id <br/>
  4004. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  4005. 6. renderMode(渲染模式) <br/>
  4006. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  4007. 0 - 通过引擎自动选择。 <br/>
  4008. 1 - 强制使用 canvas 渲染。
  4009. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  4010. 7. scenes <br/>
  4011. “scenes” 当前包中可用场景。 <br/>
  4012. <br/>
  4013. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  4014. config: any;
  4015. /**
  4016. !#en Callback when the scripts of engine have been load.
  4017. !#zh 当引擎完成启动后的回调函数。
  4018. */
  4019. onStart(): void;
  4020. /**
  4021. !#en Set frameRate of game.
  4022. !#zh 设置游戏帧率。
  4023. @param frameRate frameRate
  4024. */
  4025. setFrameRate(frameRate: number): void;
  4026. /**
  4027. !#en Run the game frame by frame.
  4028. !#zh 执行一帧游戏循环。
  4029. */
  4030. step(): void;
  4031. /**
  4032. !#en Pause the game main loop. This will pause:
  4033. game logic execution, rendering process, event manager, background music and all audio effects.
  4034. This is different with cc.director.pause which only pause the game logic execution.
  4035. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  4036. */
  4037. pause(): void;
  4038. /**
  4039. !#en Resume the game from pause. This will resume:
  4040. game logic execution, rendering process, event manager, background music and all audio effects.
  4041. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  4042. */
  4043. resume(): void;
  4044. /**
  4045. !#en Check whether the game is paused.
  4046. !#zh 判断游戏是否暂停。
  4047. */
  4048. isPaused(): boolean;
  4049. /**
  4050. !#en Restart game.
  4051. !#zh 重新开始游戏
  4052. */
  4053. restart(): void;
  4054. /**
  4055. !#en End game, it will close the game window
  4056. !#zh 退出游戏
  4057. */
  4058. end(): void;
  4059. /**
  4060. !#en Prepare game.
  4061. !#zh 准备引擎,请不要直接调用这个函数。
  4062. @param cb cb
  4063. */
  4064. prepare(cb: Function): void;
  4065. /**
  4066. !#en Run game with configuration object and onStart function.
  4067. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  4068. @param config Pass configuration object or onStart function
  4069. @param onStart function to be executed after game initialized
  4070. */
  4071. run(config?: any|Function, onStart?: Function): void;
  4072. /**
  4073. !#en
  4074. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  4075. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  4076. !#zh
  4077. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  4078. 目标节点必须位于为层级的根节点,否则无效。
  4079. @param node The node to be made persistent
  4080. */
  4081. addPersistRootNode(node: Node): void;
  4082. /**
  4083. !#en Remove a persistent root node.
  4084. !#zh 取消常驻根节点。
  4085. @param node The node to be removed from persistent node list
  4086. */
  4087. removePersistRootNode(node: Node): void;
  4088. /**
  4089. !#en Check whether the node is a persistent root node.
  4090. !#zh 检查节点是否是常驻根节点。
  4091. @param node The node to be checked
  4092. */
  4093. isPersistRootNode(node: Node): boolean;
  4094. }
  4095. /** !#en
  4096. Class of all entities in Cocos Creator scenes.<br/>
  4097. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  4098. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  4099. !#zh
  4100. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  4101. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  4102. export class Node extends _BaseNode {
  4103. /** !#en
  4104. Group index of node.<br/>
  4105. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  4106. !#zh
  4107. 节点的分组索引。<br/>
  4108. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  4109. groupIndex: number;
  4110. /** !#en
  4111. Group of node.<br/>
  4112. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  4113. !#zh
  4114. 节点的分组。<br/>
  4115. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  4116. group: string;
  4117. /** !#en The position (x, y) of the node in its parent's coordinates.
  4118. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  4119. position: Vec2;
  4120. /** !#en x axis position of node.
  4121. !#zh 节点 X 轴坐标。 */
  4122. x: number;
  4123. /** !#en y axis position of node.
  4124. !#zh 节点 Y 轴坐标。 */
  4125. y: number;
  4126. /** !#en Rotation of node.
  4127. !#zh 该节点旋转角度。 */
  4128. rotation: number;
  4129. /** !#en Rotation on x axis.
  4130. !#zh 该节点 X 轴旋转角度。 */
  4131. rotationX: number;
  4132. /** !#en Rotation on y axis.
  4133. !#zh 该节点 Y 轴旋转角度。 */
  4134. rotationY: number;
  4135. /** !#en Scale on x axis.
  4136. !#zh 节点 X 轴缩放。 */
  4137. scaleX: number;
  4138. /** !#en Scale on y axis.
  4139. !#zh 节点 Y 轴缩放。 */
  4140. scaleY: number;
  4141. /** !#en Skew x
  4142. !#zh 该节点 Y 轴倾斜角度。 */
  4143. skewX: number;
  4144. /** !#en Skew y
  4145. !#zh 该节点 X 轴倾斜角度。 */
  4146. skewY: number;
  4147. /** !#en Opacity of node, default value is 255.
  4148. !#zh 节点透明度,默认值为 255。 */
  4149. opacity: number;
  4150. /** !#en Indicate whether node's opacity value affect its child nodes, default value is true.
  4151. !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */
  4152. cascadeOpacity: boolean;
  4153. /** !#en Color of node, default value is white: (255, 255, 255).
  4154. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  4155. color: Color;
  4156. /** !#en Anchor point's position on x axis.
  4157. !#zh 节点 X 轴锚点位置。 */
  4158. anchorX: number;
  4159. /** !#en Anchor point's position on y axis.
  4160. !#zh 节点 Y 轴锚点位置。 */
  4161. anchorY: number;
  4162. /** !#en Width of node.
  4163. !#zh 节点宽度。 */
  4164. width: number;
  4165. /** !#en Height of node.
  4166. !#zh 节点高度。 */
  4167. height: number;
  4168. /** !#en Z order in depth which stands for the drawing order.
  4169. !#zh 该节点渲染排序的 Z 轴深度。 */
  4170. zIndex: number;
  4171. /**
  4172. @param name name
  4173. */
  4174. constructor(name?: string);
  4175. /**
  4176. !#en
  4177. Register a callback of a specific event type on Node.<br/>
  4178. Use this method to register touch or mouse event permit propagation based on scene graph,
  4179. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  4180. It's the recommended way to register touch/mouse event for Node,
  4181. please do not use cc.eventManager directly for Node.
  4182. !#zh
  4183. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  4184. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  4185. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  4186. @param type A string representing the event type to listen for.<br>
  4187. See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events.
  4188. @param callback The callback that will be invoked when the event is dispatched.
  4189. The callback is ignored if it is a duplicate (the callbacks are unique).
  4190. @param target The target (this object) to invoke the callback, can be null
  4191. @param useCapture When set to true, the capture argument prevents callback
  4192. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  4193. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  4194. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  4195. @example
  4196. ```js
  4197. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  4198. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  4199. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  4200. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  4201. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  4202. node.on("anchor-changed", callback, this);
  4203. ```
  4204. */
  4205. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  4206. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  4207. /**
  4208. !#en
  4209. Removes the callback previously registered with the same type, callback, target and or useCapture.
  4210. This method is merely an alias to removeEventListener.
  4211. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  4212. @param type A string representing the event type being removed.
  4213. @param callback The callback to remove.
  4214. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  4215. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  4216. If not specified, useCapture defaults to false. If a callback was registered twice,
  4217. one with capture and one without, each must be removed separately. Removal of a capturing callback
  4218. does not affect a non-capturing version of the same listener, and vice versa.
  4219. @example
  4220. ```js
  4221. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  4222. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  4223. node.off("anchor-changed", callback, this);
  4224. ```
  4225. */
  4226. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  4227. /**
  4228. !#en Removes all callbacks previously registered with the same target.
  4229. !#zh 移除目标上的所有注册事件。
  4230. @param target The target to be searched for all related callbacks
  4231. @example
  4232. ```js
  4233. node.targetOff(target);
  4234. ```
  4235. */
  4236. targetOff(target: any): void;
  4237. /**
  4238. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  4239. 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.
  4240. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  4241. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  4242. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  4243. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  4244. @param recursive Whether to pause node system events on the sub node tree.
  4245. @example
  4246. ```js
  4247. node.pauseSystemEvents(true);
  4248. ```
  4249. */
  4250. pauseSystemEvents(recursive: boolean): void;
  4251. /**
  4252. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  4253. 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.
  4254. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  4255. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  4256. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  4257. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  4258. @param recursive Whether to resume node system events on the sub node tree.
  4259. @example
  4260. ```js
  4261. node.resumeSystemEvents(true);
  4262. ```
  4263. */
  4264. resumeSystemEvents(recursive: boolean): void;
  4265. /**
  4266. !#en
  4267. Executes an action, and returns the action that is executed.<br/>
  4268. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  4269. Calling runAction while the node is not active won't have any effect. <br/>
  4270. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  4271. if you want to modify, when you define action plus.
  4272. !#zh
  4273. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  4274. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  4275. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  4276. @param action action
  4277. @example
  4278. ```js
  4279. var action = cc.scaleTo(0.2, 1, 0.6);
  4280. node.runAction(action);
  4281. node.runAction(action).repeatForever(); // fail
  4282. node.runAction(action.repeatForever()); // right
  4283. ```
  4284. */
  4285. runAction(action: Action): Action;
  4286. /**
  4287. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  4288. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  4289. @example
  4290. ```js
  4291. node.pauseAllActions();
  4292. ```
  4293. */
  4294. pauseAllActions(): void;
  4295. /**
  4296. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  4297. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  4298. @example
  4299. ```js
  4300. node.resumeAllActions();
  4301. ```
  4302. */
  4303. resumeAllActions(): void;
  4304. /**
  4305. !#en Stops and removes all actions from the running action list .
  4306. !#zh 停止并且移除所有正在运行的动作列表。
  4307. @example
  4308. ```js
  4309. node.stopAllActions();
  4310. ```
  4311. */
  4312. stopAllActions(): void;
  4313. /**
  4314. !#en Stops and removes an action from the running action list.
  4315. !#zh 停止并移除指定的动作。
  4316. @param action An action object to be removed.
  4317. @example
  4318. ```js
  4319. var action = cc.scaleTo(0.2, 1, 0.6);
  4320. node.stopAction(action);
  4321. ```
  4322. */
  4323. stopAction(action: Action): void;
  4324. /**
  4325. !#en Removes an action from the running action list by its tag.
  4326. !#zh 停止并且移除指定标签的动作。
  4327. @param tag A tag that indicates the action to be removed.
  4328. @example
  4329. ```js
  4330. node.stopAction(1);
  4331. ```
  4332. */
  4333. stopActionByTag(tag: number): void;
  4334. /**
  4335. !#en Returns an action from the running action list by its tag.
  4336. !#zh 通过标签获取指定动作。
  4337. @param tag tag
  4338. @example
  4339. ```js
  4340. var action = node.getActionByTag(1);
  4341. ```
  4342. */
  4343. getActionByTag(tag: number): Action;
  4344. /**
  4345. !#en
  4346. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  4347. Composable actions are counted as 1 action. Example:<br/>
  4348. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  4349. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  4350. !#zh
  4351. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  4352. 例如:<br/>
  4353. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  4354. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  4355. @example
  4356. ```js
  4357. var count = node.getNumberOfRunningActions();
  4358. cc.log("Running Action Count: " + count);
  4359. ```
  4360. */
  4361. getNumberOfRunningActions(): number;
  4362. /**
  4363. !#en Returns a copy of the position (x, y) of the node in its parent's coordinates.
  4364. !#zh 获取节点在父节点坐标系中的位置(x, y)。
  4365. @example
  4366. ```js
  4367. cc.log("Node Position: " + node.getPosition());
  4368. ```
  4369. */
  4370. getPosition(): Vec2;
  4371. /**
  4372. !#en
  4373. Sets the position (x, y) of the node in its parent's coordinates.<br/>
  4374. Usually we use cc.v2(x, y) to compose cc.Vec2 object.<br/>
  4375. and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object.
  4376. !#zh
  4377. 设置节点在父节点坐标系中的位置。<br/>
  4378. 可以通过两种方式设置坐标点:<br/>
  4379. 1. 传入 2 个数值 x 和 y。<br/>
  4380. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
  4381. @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates
  4382. @param y Y coordinate for position
  4383. @example
  4384. ```js
  4385. node.setPosition(cc.v2(0, 0));
  4386. node.setPosition(0, 0);
  4387. ```
  4388. */
  4389. setPosition(newPosOrX: Vec2|number, y?: number): void;
  4390. /**
  4391. !#en
  4392. Returns the scale factor of the node.
  4393. Assertion will fail when _scaleX != _scaleY.
  4394. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  4395. @example
  4396. ```js
  4397. cc.log("Node Scale: " + node.getScale());
  4398. ```
  4399. */
  4400. getScale(): number;
  4401. /**
  4402. !#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.
  4403. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  4404. @param scaleX scaleX or scale
  4405. @param scaleY scaleY
  4406. @example
  4407. ```js
  4408. node.setScale(cc.v2(1, 1));
  4409. node.setScale(1, 1);
  4410. ```
  4411. */
  4412. setScale(scaleX: number|Vec2, scaleY?: number): void;
  4413. /**
  4414. !#en
  4415. Returns a copy the untransformed size of the node. <br/>
  4416. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  4417. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  4418. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  4419. @param ignoreSizeProvider true if you need to get the original size of the node
  4420. @example
  4421. ```js
  4422. cc.log("Content Size: " + node.getContentSize());
  4423. ```
  4424. */
  4425. getContentSize(ignoreSizeProvider?: boolean): Size;
  4426. /**
  4427. !#en
  4428. Sets the untransformed size of the node.<br/>
  4429. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  4430. All nodes has a size. Layer and Scene has the same size of the screen.
  4431. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  4432. @param size The untransformed size of the node or The untransformed size's width of the node.
  4433. @param height The untransformed size's height of the node.
  4434. @example
  4435. ```js
  4436. node.setContentSize(cc.size(100, 100));
  4437. node.setContentSize(100, 100);
  4438. ```
  4439. */
  4440. setContentSize(size: Size|number, height?: number): void;
  4441. /**
  4442. !#en
  4443. Set whether color should be changed with the opacity value,
  4444. useless in ccsg.Node, but this function is override in some class to have such behavior.
  4445. !#zh 设置更改透明度时是否修改RGB值,
  4446. @param opacityValue opacityValue
  4447. @example
  4448. ```js
  4449. node.setOpacityModifyRGB(true);
  4450. ```
  4451. */
  4452. setOpacityModifyRGB(opacityValue: boolean): void;
  4453. /**
  4454. !#en Get whether color should be changed with the opacity value.
  4455. !#zh 更改透明度时是否修改RGB值。
  4456. @example
  4457. ```js
  4458. var hasChange = node.isOpacityModifyRGB();
  4459. ```
  4460. */
  4461. isOpacityModifyRGB(): boolean;
  4462. /**
  4463. !#en
  4464. Returns a copy of the anchor point.<br/>
  4465. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  4466. It's like a pin in the node where it is "attached" to its parent. <br/>
  4467. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  4468. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  4469. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  4470. !#zh
  4471. 获取节点锚点,用百分比表示。<br/>
  4472. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  4473. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  4474. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  4475. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  4476. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  4477. @example
  4478. ```js
  4479. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  4480. ```
  4481. */
  4482. getAnchorPoint(): Vec2;
  4483. /**
  4484. !#en
  4485. Sets the anchor point in percent. <br/>
  4486. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  4487. It's like a pin in the node where it is "attached" to its parent. <br/>
  4488. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  4489. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  4490. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  4491. !#zh
  4492. 设置锚点的百分比。<br/>
  4493. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  4494. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  4495. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  4496. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  4497. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  4498. @param point The anchor point of node or The x axis anchor of node.
  4499. @param y The y axis anchor of node.
  4500. @example
  4501. ```js
  4502. node.setAnchorPoint(cc.v2(1, 1));
  4503. node.setAnchorPoint(1, 1);
  4504. ```
  4505. */
  4506. setAnchorPoint(point: Vec2|number, y?: number): void;
  4507. /**
  4508. !#en
  4509. Returns a copy of the anchor point in absolute pixels. <br/>
  4510. you can only read it. If you wish to modify it, use setAnchorPoint.
  4511. !#zh
  4512. 返回锚点的绝对像素位置。<br/>
  4513. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  4514. @example
  4515. ```js
  4516. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  4517. ```
  4518. */
  4519. getAnchorPointInPoints(): Vec2;
  4520. /**
  4521. !#en
  4522. Returns the displayed opacity of Node,
  4523. 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.
  4524. !#zh
  4525. 获取节点显示透明度,
  4526. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  4527. 显示透明度是基于自身透明度和父节点透明度计算的。
  4528. @example
  4529. ```js
  4530. var displayOpacity = node.getDisplayedOpacity();
  4531. ```
  4532. */
  4533. getDisplayedOpacity(): number;
  4534. /**
  4535. !#en
  4536. Returns the displayed color of Node,
  4537. 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.
  4538. !#zh
  4539. 获取节点的显示透明度,
  4540. 显示透明度和透明度之间的不同之处在于显示透明度是基于透明度和父节点透明度启用级连透明度时计算的。
  4541. @example
  4542. ```js
  4543. var displayColor = node.getDisplayedColor();
  4544. ```
  4545. */
  4546. getDisplayedColor(): Color;
  4547. /**
  4548. !#en
  4549. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4550. The matrix is in Pixels.<br/>
  4551. This method is AR (Anchor Relative).
  4552. !#zh
  4553. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  4554. 这个矩阵以像素为单位。<br/>
  4555. 该方法基于节点坐标。
  4556. @example
  4557. ```js
  4558. var affineTransform = node.getNodeToParentTransformAR();
  4559. ```
  4560. */
  4561. getNodeToParentTransformAR(): AffineTransform;
  4562. /**
  4563. !#en
  4564. Returns a "local" axis aligned bounding box of the node. <br/>
  4565. The returned box is relative only to its parent.
  4566. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  4567. @example
  4568. ```js
  4569. var boundingBox = node.getBoundingBox();
  4570. ```
  4571. */
  4572. getBoundingBox(): Rect;
  4573. /**
  4574. !#en
  4575. Returns a "world" axis aligned bounding box of the node.<br/>
  4576. The bounding box contains self and active children's world bounding box.
  4577. !#zh
  4578. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  4579. 该边框包含自身和已激活的子节点的世界边框。
  4580. @example
  4581. ```js
  4582. var newRect = node.getBoundingBoxToWorld();
  4583. ```
  4584. */
  4585. getBoundingBoxToWorld(): Rect;
  4586. /**
  4587. !#en
  4588. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  4589. The matrix is in Pixels.
  4590. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  4591. @example
  4592. ```js
  4593. var affineTransform = node.getNodeToParentTransform();
  4594. ```
  4595. */
  4596. getNodeToParentTransform(): AffineTransform;
  4597. /**
  4598. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  4599. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  4600. @example
  4601. ```js
  4602. var affineTransform = node.getNodeToWorldTransform();
  4603. ```
  4604. */
  4605. getNodeToWorldTransform(): AffineTransform;
  4606. /**
  4607. !#en
  4608. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  4609. This method is AR (Anchor Relative).
  4610. !#zh
  4611. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  4612. 该方法基于节点坐标。
  4613. @example
  4614. ```js
  4615. var mat = node.getNodeToWorldTransformAR();
  4616. ```
  4617. */
  4618. getNodeToWorldTransformAR(): AffineTransform;
  4619. /**
  4620. !#en
  4621. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  4622. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  4623. !#zh
  4624. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  4625. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  4626. @example
  4627. ```js
  4628. var affineTransform = node.getParentToNodeTransform();
  4629. ```
  4630. */
  4631. getParentToNodeTransform(): AffineTransform;
  4632. /**
  4633. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  4634. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  4635. @example
  4636. ```js
  4637. var affineTransform = node.getWorldToNodeTransform();
  4638. ```
  4639. */
  4640. getWorldToNodeTransform(): AffineTransform;
  4641. /**
  4642. !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  4643. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  4644. @param worldPoint worldPoint
  4645. @example
  4646. ```js
  4647. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  4648. ```
  4649. */
  4650. convertToNodeSpace(worldPoint: Vec2): Vec2;
  4651. /**
  4652. !#en Converts a Point to world space coordinates. The result is in Points.
  4653. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  4654. @param nodePoint nodePoint
  4655. @example
  4656. ```js
  4657. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  4658. ```
  4659. */
  4660. convertToWorldSpace(nodePoint: Vec2): Vec2;
  4661. /**
  4662. !#en
  4663. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  4664. treating the returned/received node point as anchor relative.
  4665. !#zh
  4666. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  4667. 返回值将基于节点坐标。
  4668. @param worldPoint worldPoint
  4669. @example
  4670. ```js
  4671. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  4672. ```
  4673. */
  4674. convertToNodeSpaceAR(worldPoint: Vec2): Vec2;
  4675. /**
  4676. !#en
  4677. Converts a local Point to world space coordinates.The result is in Points.<br/>
  4678. treating the returned/received node point as anchor relative.
  4679. !#zh
  4680. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  4681. 返回值将基于世界坐标。
  4682. @param nodePoint nodePoint
  4683. @example
  4684. ```js
  4685. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  4686. ```
  4687. */
  4688. convertToWorldSpaceAR(nodePoint: Vec2): Vec2;
  4689. /**
  4690. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  4691. !#zh 将触摸点转换成本地坐标系中位置。
  4692. @param touch The touch object
  4693. @example
  4694. ```js
  4695. var newVec2 = node.convertTouchToNodeSpace(touch);
  4696. ```
  4697. */
  4698. convertTouchToNodeSpace(touch: Touch): Vec2;
  4699. /**
  4700. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  4701. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  4702. @param touch The touch object
  4703. @example
  4704. ```js
  4705. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  4706. ```
  4707. */
  4708. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  4709. /**
  4710. !#en
  4711. Adds a child to the node with z order and tag.
  4712. !#zh
  4713. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  4714. @param child A child node
  4715. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  4716. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  4717. @example
  4718. ```js
  4719. node.addChild(newNode, 1, 1001);
  4720. ```
  4721. */
  4722. addChild(child: Node, localZOrder?: number, tag?: number|string): void;
  4723. /**
  4724. !#en Stops all running actions and schedulers.
  4725. !#zh 停止所有正在播放的动作和计时器。
  4726. @example
  4727. ```js
  4728. node.cleanup();
  4729. ```
  4730. */
  4731. cleanup(): void;
  4732. /**
  4733. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  4734. normally you won't need to invoke this function.
  4735. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  4736. */
  4737. sortAllChildren(): void;
  4738. /** !#en The local scale relative to the parent.
  4739. !#zh 节点相对父节点的缩放。 */
  4740. scale: number;
  4741. /**
  4742. !#en Returns the x axis position of the node in cocos2d coordinates.
  4743. !#zh 获取节点 X 轴坐标。
  4744. @example
  4745. ```js
  4746. var posX = node.getPositionX();
  4747. ```
  4748. */
  4749. getPositionX(): number;
  4750. /**
  4751. !#en Sets the x axis position of the node in cocos2d coordinates.
  4752. !#zh 设置节点 X 轴坐标。
  4753. @param x x
  4754. @example
  4755. ```js
  4756. node.setPositionX(1);
  4757. ```
  4758. */
  4759. setPositionX(x: number): void;
  4760. /**
  4761. !#en Returns the y axis position of the node in cocos2d coordinates.
  4762. !#zh 获取节点 Y 轴坐标。
  4763. @example
  4764. ```js
  4765. var posY = node.getPositionY();
  4766. ```
  4767. */
  4768. getPositionY(): number;
  4769. /**
  4770. !#en Sets the y axis position of the node in cocos2d coordinates.
  4771. !#zh 设置节点 Y 轴坐标。
  4772. @param y The new position in y axis
  4773. @example
  4774. ```js
  4775. node.setPositionY(100);
  4776. ```
  4777. */
  4778. setPositionY(y: number): void;
  4779. /**
  4780. !#en Returns the local Z order of this node.
  4781. !#zh 获取节点局部 Z 轴顺序。
  4782. @example
  4783. ```js
  4784. var localZorder = node.getLocalZOrder();
  4785. ```
  4786. */
  4787. getLocalZOrder(): number;
  4788. /**
  4789. !#en
  4790. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  4791. <br/>
  4792. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  4793. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  4794. will be in front of the other node in the array. <br/>
  4795. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  4796. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  4797. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  4798. !#zh
  4799. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  4800. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  4801. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  4802. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  4803. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  4804. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  4805. @param localZOrder localZOrder
  4806. @example
  4807. ```js
  4808. node.setLocalZOrder(1);
  4809. ```
  4810. */
  4811. setLocalZOrder(localZOrder: number): void;
  4812. /**
  4813. !#en Returns whether node's opacity value affect its child nodes.
  4814. !#zh 返回节点的不透明度值是否影响其子节点。
  4815. @example
  4816. ```js
  4817. cc.log(node.isCascadeOpacityEnabled());
  4818. ```
  4819. */
  4820. isCascadeOpacityEnabled(): boolean;
  4821. /**
  4822. !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  4823. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  4824. @param cascadeOpacityEnabled cascadeOpacityEnabled
  4825. @example
  4826. ```js
  4827. node.setCascadeOpacityEnabled(true);
  4828. ```
  4829. */
  4830. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  4831. }
  4832. /** !#en
  4833. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  4834. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  4835. !#zh
  4836. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  4837. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  4838. export class Scene extends Node {
  4839. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  4840. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  4841. autoReleaseAssets: boolean;
  4842. }
  4843. /** !#en
  4844. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  4845. You should not use NSTimer. Instead use this class.<br/>
  4846. <br/>
  4847. There are 2 different types of callbacks (selectors):<br/>
  4848. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  4849. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  4850. <br/>
  4851. The 'custom selectors' should be avoided when possible. It is faster,
  4852. and consumes less memory to use the 'update callback'. *
  4853. !#zh
  4854. Scheduler 是负责触发回调函数的类。<br/>
  4855. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  4856. 有两种不同类型的定时器:<br/>
  4857. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  4858. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  4859. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  4860. export class Scheduler {
  4861. /**
  4862. !#en
  4863. Modifies the time of all scheduled callbacks.<br/>
  4864. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  4865. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  4866. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  4867. Note:It will affect EVERY scheduled selector / action.
  4868. !#zh
  4869. 设置时间间隔的缩放比例。<br/>
  4870. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  4871. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  4872. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  4873. 注意:它影响该 Scheduler 下管理的所有定时器。
  4874. @param timeScale timeScale
  4875. */
  4876. setTimeScale(timeScale: number): void;
  4877. /**
  4878. !#en Returns time scale of scheduler.
  4879. !#zh 获取时间间隔的缩放比例。
  4880. */
  4881. getTimeScale(): number;
  4882. /**
  4883. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  4884. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  4885. @param dt delta time
  4886. */
  4887. update(dt: number): void;
  4888. /**
  4889. !#en
  4890. <p>
  4891. The scheduled method will be called every 'interval' seconds.</br>
  4892. If paused is YES, then it won't be called until it is resumed.<br/>
  4893. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  4894. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  4895. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  4896. delay is the amount of time the action will wait before it'll start<br/>
  4897. </p>
  4898. !#zh
  4899. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  4900. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  4901. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  4902. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  4903. 建议使用 scheduleUpdateForTarget 代替。</br>
  4904. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  4905. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  4906. 可以让定时器一直循环触发。<br/>
  4907. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  4908. @param target target
  4909. @param callback_fn callback_fn
  4910. @param interval interval
  4911. @param repeat repeat
  4912. @param delay delay
  4913. @param paused paused
  4914. @example
  4915. ```js
  4916. //register a schedule to scheduler
  4917. var scheduler = cc.director.getScheduler();
  4918. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  4919. ```
  4920. */
  4921. scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4922. scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void;
  4923. /**
  4924. !#en The schedule
  4925. !#zh 定时器
  4926. @param callback callback
  4927. @param target target
  4928. @param interval interval
  4929. @param repeat repeat
  4930. @param delay delay
  4931. @param paused paused
  4932. @example
  4933. ```js
  4934. //register a schedule to scheduler
  4935. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  4936. ```
  4937. */
  4938. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  4939. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  4940. /**
  4941. !#en
  4942. Schedules the update callback for a given target,
  4943. the callback will be invoked every frame after schedule started.
  4944. !#zh
  4945. 使用指定的优先级为指定的对象设置 update 定时器。
  4946. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  4947. @param target target
  4948. @param priority priority
  4949. @param paused paused
  4950. @param updateFunc updateFunc
  4951. */
  4952. scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void;
  4953. /**
  4954. !#en
  4955. Unschedules a callback for a callback and a given target.
  4956. If you want to unschedule the "update", use `unscheduleUpdate()`
  4957. !#zh
  4958. 根据指定的回调函数和调用对象。
  4959. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  4960. @param callback The callback to be unscheduled
  4961. @param target The target bound to the callback.
  4962. */
  4963. unschedule(callback: Function, target: any): void;
  4964. /**
  4965. !#en Unschedules the update callback for a given target.
  4966. !#zh 取消指定对象的 update 定时器。
  4967. @param target The target to be unscheduled.
  4968. */
  4969. unscheduleUpdate(target: any): void;
  4970. /**
  4971. !#en
  4972. Unschedules all scheduled callbacks for a given target.
  4973. This also includes the "update" callback.
  4974. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  4975. @param target The target to be unscheduled.
  4976. */
  4977. unscheduleAllForTarget(target: any): void;
  4978. /**
  4979. !#en
  4980. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  4981. You should NEVER call this method, unless you know what you are doing.
  4982. !#zh
  4983. 取消所有对象的所有定时器,包括系统定时器。<br/>
  4984. 不用调用此函数,除非你确定你在做什么。
  4985. */
  4986. unscheduleAll(): void;
  4987. /**
  4988. !#en
  4989. Unschedules all callbacks from all targets with a minimum priority.<br/>
  4990. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  4991. !#zh
  4992. 取消所有优先级的值大于指定优先级的定时器。<br/>
  4993. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4994. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  4995. priority is higher than minPriority will be unscheduled.
  4996. */
  4997. unscheduleAllWithMinPriority(minPriority: number): void;
  4998. /**
  4999. !#en Checks whether a callback for a given target is scheduled.
  5000. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  5001. @param callback The callback to check.
  5002. @param target The target of the callback.
  5003. */
  5004. isScheduled(callback: Function, target: any): boolean;
  5005. /**
  5006. !#en
  5007. Pause all selectors from all targets.<br/>
  5008. You should NEVER call this method, unless you know what you are doing.
  5009. !#zh
  5010. 暂停所有对象的所有定时器。<br/>
  5011. 不要调用这个方法,除非你知道你正在做什么。
  5012. */
  5013. pauseAllTargets(): void;
  5014. /**
  5015. !#en
  5016. Pause all selectors from all targets with a minimum priority. <br/>
  5017. You should only call this with kCCPriorityNonSystemMin or higher.
  5018. !#zh
  5019. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  5020. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  5021. @param minPriority minPriority
  5022. */
  5023. pauseAllTargetsWithMinPriority(minPriority: number): void;
  5024. /**
  5025. !#en
  5026. Resume selectors on a set of targets.<br/>
  5027. This can be useful for undoing a call to pauseAllCallbacks.
  5028. !#zh
  5029. 恢复指定数组中所有对象的定时器。<br/>
  5030. 这个函数是 pauseAllCallbacks 的逆操作。
  5031. @param targetsToResume targetsToResume
  5032. */
  5033. resumeTargets(targetsToResume: any[]): void;
  5034. /**
  5035. !#en
  5036. Pauses the target.<br/>
  5037. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  5038. If the target is not present, nothing happens.
  5039. !#zh
  5040. 暂停指定对象的定时器。<br/>
  5041. 指定对象的所有定时器都会被暂停。<br/>
  5042. 如果指定的对象没有定时器,什么也不会发生。
  5043. @param target target
  5044. */
  5045. pauseTarget(target: any): void;
  5046. /**
  5047. !#en
  5048. Resumes the target.<br/>
  5049. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  5050. If the target is not present, nothing happens.
  5051. !#zh
  5052. 恢复指定对象的所有定时器。<br/>
  5053. 指定对象的所有定时器将继续工作。<br/>
  5054. 如果指定的对象没有定时器,什么也不会发生。
  5055. @param target target
  5056. */
  5057. resumeTarget(target: any): void;
  5058. /**
  5059. !#en Returns whether or not the target is paused.
  5060. !#zh 返回指定对象的定时器是否暂停了。
  5061. @param target target
  5062. */
  5063. isTargetPaused(target: any): boolean;
  5064. /**
  5065. !#en
  5066. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  5067. The 'update' callback_fn will be called every frame.<br/>
  5068. The lower the priority, the earlier it is called.
  5069. !#zh
  5070. 为指定对象设置 update 定时器。<br/>
  5071. update 定时器每一帧都会被调用。<br/>
  5072. 优先级的值越低,越早被调用。
  5073. @param target target
  5074. @param priority priority
  5075. @param paused paused
  5076. @example
  5077. ```js
  5078. //register this object to scheduler
  5079. var scheduler = cc.director.getScheduler();
  5080. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  5081. ```
  5082. */
  5083. scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void;
  5084. /**
  5085. !#en
  5086. Unschedule a callback function for a given target.<br/>
  5087. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  5088. !#zh
  5089. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  5090. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  5091. @param target target
  5092. @param callback callback[Function] or key[String]
  5093. @example
  5094. ```js
  5095. //unschedule a callback of target
  5096. var scheduler = cc.director.getScheduler();
  5097. scheduler.unscheduleCallbackForTarget(this, callback);
  5098. ```
  5099. */
  5100. unscheduleCallbackForTarget(target: any, callback: Function): void;
  5101. /**
  5102. !#en Unschedules the update callback function for a given target.
  5103. !#zh 取消指定对象的所有定时器。
  5104. @param target target
  5105. @example
  5106. ```js
  5107. //unschedules the "update" method.
  5108. var scheduler = cc.director.getScheduler();
  5109. scheduler.unscheduleUpdateForTarget(this);
  5110. ```
  5111. */
  5112. unscheduleUpdateForTarget(target: any): void;
  5113. /**
  5114. !#en
  5115. Unschedules all function callbacks for a given target.<br/>
  5116. This also includes the "update" callback function.
  5117. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  5118. @param target target
  5119. */
  5120. unscheduleAllCallbacksForTarget(target: any): void;
  5121. /**
  5122. !#en
  5123. Unschedules all function callbacks from all targets. <br/>
  5124. You should NEVER call this method, unless you know what you are doing.
  5125. !#zh
  5126. 取消所有对象的所有定时器。<br/>
  5127. 不要调用这个方法,除非你知道你正在做什么。
  5128. */
  5129. unscheduleAllCallbacks(): void;
  5130. /**
  5131. !#en
  5132. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  5133. You should only call this with kCCPriorityNonSystemMin or higher.
  5134. !#zh
  5135. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  5136. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  5137. @param minPriority minPriority
  5138. */
  5139. unscheduleAllCallbacksWithMinPriority(minPriority: number): void;
  5140. /** !#en Priority level reserved for system services.
  5141. !#zh 系统服务的优先级。 */
  5142. static PRIORITY_SYSTEM: number;
  5143. /** !#en Minimum priority level for user scheduling.
  5144. !#zh 用户调度最低优先级。 */
  5145. static PRIORITY_NON_SYSTEM: number;
  5146. }
  5147. /** !#en
  5148. cc.NodePool is the cache pool designed for node type.<br/>
  5149. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5150. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  5151. for example, a prefab is a specific node type. <br/>
  5152. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  5153. Some common use case is :<br/>
  5154. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  5155. 2. Blocks in candy crash (massive creation and recreation)<br/>
  5156. etc...
  5157. !#zh
  5158. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  5159. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  5160. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  5161. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  5162. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  5163. 一些常见的用例是:<br/>
  5164. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  5165. 2.糖果粉碎传奇中的木块(频繁创建)。
  5166. 等等.... */
  5167. export class NodePool {
  5168. /**
  5169. !#en
  5170. 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.
  5171. !#zh
  5172. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  5173. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  5174. @example
  5175. ```js
  5176. properties: {
  5177. template: cc.Prefab
  5178. },
  5179. onLoad () {
  5180. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  5181. this.myPool = new cc.NodePool('MyTemplateHandler');
  5182. }
  5183. ```
  5184. */
  5185. constructor(poolHandlerComp?: {prototype: Component}|string);
  5186. /** !#en The pool handler component, it could be the class name or the constructor.
  5187. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  5188. poolHandlerComp: Function|string;
  5189. /**
  5190. !#en The current available size in the pool
  5191. !#zh 获取当前缓冲池的可用对象数量
  5192. */
  5193. size(): number;
  5194. /**
  5195. !#en Destroy all cached nodes in the pool
  5196. !#zh 销毁对象池中缓存的所有节点
  5197. */
  5198. clear(): void;
  5199. /**
  5200. !#en Put a new Node into the pool.
  5201. It will automatically remove the node from its parent without cleanup.
  5202. It will also invoke unuse method of the poolHandlerComp if exist.
  5203. !#zh 向缓冲池中存入一个不再需要的节点对象。
  5204. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  5205. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  5206. @param obj obj
  5207. @example
  5208. ```js
  5209. let myNode = cc.instantiate(this.template);
  5210. this.myPool.put(myNode);
  5211. ```
  5212. */
  5213. put(obj: Node): void;
  5214. /**
  5215. !#en Get a obj from pool, if no available object in pool, null will be returned.
  5216. This function will invoke the reuse function of poolHandlerComp if exist.
  5217. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  5218. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  5219. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  5220. @example
  5221. ```js
  5222. let newNode = this.myPool.get();
  5223. ```
  5224. */
  5225. get(...params: any[]): Node;
  5226. }
  5227. /** !#en
  5228. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  5229. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  5230. cc.pool is a singleton object serves as an object cache pool.<br/>
  5231. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5232. !#zh
  5233. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  5234. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  5235. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  5236. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  5237. export class pool {
  5238. /**
  5239. !#en Put the obj in pool.
  5240. !#zh 加入对象到对象池中。
  5241. @param obj The need put in pool object.
  5242. @example
  5243. ```js
  5244. ---------------------------------
  5245. var sp = new _ccsg.Sprite("a.png");
  5246. this.addChild(sp);
  5247. cc.pool.putInPool(sp);
  5248. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  5249. ```
  5250. */
  5251. putInPool(obj: any): void;
  5252. /**
  5253. !#en Check if this kind of obj has already in pool.
  5254. !#zh 检查对象池中是否有指定对象的存在。
  5255. @param objClass The check object class.
  5256. */
  5257. hasObject(objClass: any): boolean;
  5258. /**
  5259. !#en Remove the obj if you want to delete it.
  5260. !#zh 移除在对象池中指定的对象。
  5261. */
  5262. removeObject(): void;
  5263. /**
  5264. !#en Get the obj from pool.
  5265. !#zh 获取对象池中的指定对象。
  5266. */
  5267. getFromPool(): any;
  5268. /**
  5269. !#en Remove all objs in pool and reset the pool.
  5270. !#zh 移除对象池中的所有对象,并且重置对象池。
  5271. */
  5272. drainAllPools(): void;
  5273. }
  5274. /** !#en
  5275. Camera is usefull when making reel game or other games which need scroll screen.
  5276. Using camera will be more efficient than moving node to scroll screen.
  5277. Camera
  5278. !#zh
  5279. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5280. export class Camera extends _RendererUnderSG {
  5281. /** !#en
  5282. The camera zoom ratio.
  5283. !#zh
  5284. 摄像机缩放比率 */
  5285. zoomRatio: number;
  5286. /** !#en
  5287. Current active camera, the scene should only have one active camera at the same time.
  5288. !#zh
  5289. 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */
  5290. static main: Camera;
  5291. /**
  5292. !#en
  5293. Add the specified target to camera.
  5294. !#zh
  5295. 将指定的节点添加到摄像机中。
  5296. @param target target
  5297. */
  5298. addTarget(target: Node): void;
  5299. /**
  5300. !#en
  5301. Remove the specified target from camera.
  5302. !#zh
  5303. 将指定的节点从摄像机中移除。
  5304. @param target target
  5305. */
  5306. removeTarget(target: Node): void;
  5307. /**
  5308. !#en
  5309. Get all camera targets.
  5310. !#zh
  5311. 获取所有摄像机目标节点。
  5312. */
  5313. getTargets(): [Node];
  5314. /**
  5315. !#en
  5316. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5317. !#zh
  5318. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5319. @param node the node which should transform
  5320. */
  5321. getNodeToCameraTransform(node: Node): AffineTransform;
  5322. /**
  5323. !#en
  5324. Conver a camera coordinates point to world coordinates.
  5325. !#zh
  5326. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5327. @param point the point which should transform
  5328. */
  5329. getCameraToWorldPoint(point: Node): Vec2;
  5330. /**
  5331. !#en
  5332. Check whether the node is in the camera.
  5333. !#zh
  5334. 检测节点是否被此摄像机影响
  5335. @param node the node which need to check
  5336. */
  5337. containsNode(node: Node): boolean;
  5338. }
  5339. /** !#en
  5340. Base class for handling assets used in Fireball. This class can be instantiate.
  5341. You may want to override:<br/>
  5342. - createNode<br/>
  5343. - cc.Object._serialize<br/>
  5344. - cc.Object._deserialize<br/>
  5345. !#zh
  5346. 资源基类,该类可以被实例化。<br/>
  5347. 您可能需要重写:<br/>
  5348. - createNode <br/>
  5349. - cc.Object._serialize<br/>
  5350. - cc.Object._deserialize<br/> */
  5351. export class Asset extends RawAsset {
  5352. /** !#en
  5353. Returns the url of this asset's first raw file, if none of rawFile exists,
  5354. it will returns an empty string.
  5355. !#zh 返回该资源的原始文件的 URL,如果不支持 RAW 文件,它将返回一个空字符串。 */
  5356. rawUrl: string;
  5357. /** !#en
  5358. Returns the url of this asset's raw files, if none of rawFile exists,
  5359. it will returns an empty array.
  5360. !#zh 返回该资源的原文件的 URL 数组,如果不支持 RAW 文件,它将返回一个空数组。 */
  5361. rawUrls: string[];
  5362. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  5363. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  5364. static preventDeferredLoadDependents: boolean;
  5365. /**
  5366. !#en
  5367. Create a new node using this asset in the scene.<br/>
  5368. If this type of asset dont have its corresponding node type, this method should be null.
  5369. !#zh
  5370. 使用该资源在场景中创建一个新节点。<br/>
  5371. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5372. @param callback callback
  5373. */
  5374. createNode(callback: (error: string, node: any) => void): void;
  5375. }
  5376. /** !#en Class for audio data handling.
  5377. !#zh 音频资源类。 */
  5378. export class AudioClip extends RawAsset {
  5379. }
  5380. /** !#en Class for BitmapFont handling.
  5381. !#zh 位图字体资源类。 */
  5382. export class BitmapFont extends RawAsset {
  5383. }
  5384. /** !#en Class for Font handling.
  5385. !#zh 字体资源类。 */
  5386. export class Font extends RawAsset {
  5387. }
  5388. /** !#en Class for prefab handling.
  5389. !#zh 预制资源类。 */
  5390. export class Prefab extends Asset {
  5391. /** the main cc.Node in the prefab */
  5392. data: Node;
  5393. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  5394. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  5395. asyncLoadAssets: boolean;
  5396. /**
  5397. Dynamically translation prefab data into minimized code.<br/>
  5398. This method will be called automatically before the first time the prefab being instantiated,
  5399. but you can re-call to refresh the create function once you modified the original prefab data in script.
  5400. */
  5401. compileCreateFunction(): void;
  5402. }
  5403. /** !#en Class for LabelAtlas handling.
  5404. !#zh 艺术数字字体资源类。 */
  5405. export class LabelAtlas extends BitmapFont {
  5406. }
  5407. /** !#en
  5408. The base class for registering asset types.
  5409. You may want to override:
  5410. - createNode (static)
  5411. !#zh
  5412. 注册用的资源基类。<br/>
  5413. 你可能要重写:<br/>
  5414. - createNode (static) */
  5415. export class RawAsset extends Object {
  5416. /**
  5417. !#en
  5418. Create a new node in the scene.<br/>
  5419. If this type of asset dont have its corresponding node type, this method should be null.
  5420. !#zh
  5421. 在场景中创建一个新节点。<br/>
  5422. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5423. @param Info Info
  5424. @param callback callback
  5425. */
  5426. static createNodeByInfo(Info: any, callback: (error: string, node: any) => void): void;
  5427. }
  5428. /** !#en Class for scene handling.
  5429. !#zh 场景资源类。 */
  5430. export class SceneAsset extends Asset {
  5431. scene: Scene;
  5432. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  5433. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  5434. asyncLoadAssets: boolean;
  5435. }
  5436. /** !#en Class for script handling.
  5437. !#zh Script 资源类。 */
  5438. export class _Script extends Asset {
  5439. }
  5440. /** !#en Class for JavaScript handling.
  5441. !#zh JavaScript 资源类。 */
  5442. export class _JavaScript extends Asset {
  5443. }
  5444. /** !#en Class for coffeescript handling.
  5445. !#zh CoffeeScript 资源类。 */
  5446. export class CoffeeScript extends Asset {
  5447. }
  5448. /** !#en Class for TypeScript handling.
  5449. !#zh TypeScript 资源类。 */
  5450. export class TypeScript extends Asset {
  5451. }
  5452. /** !#en Class for sprite atlas handling.
  5453. !#zh 精灵图集资源类。 */
  5454. export class SpriteAtlas extends RawAsset {
  5455. /**
  5456. Returns the texture of the sprite atlas
  5457. */
  5458. getTexture(): Texture2D;
  5459. /**
  5460. Returns the sprite frame correspond to the given key in sprite atlas.
  5461. @param key key
  5462. */
  5463. getSpriteFrame(key: string): SpriteFrame;
  5464. /**
  5465. Returns the sprite frames in sprite atlas.
  5466. */
  5467. getSpriteFrames(): [SpriteFrame];
  5468. }
  5469. /** !#en Class for TTFFont handling.
  5470. !#zh TTF 字体资源类。 */
  5471. export class TTFFont extends Asset {
  5472. }
  5473. /** !#en Class for text file.
  5474. !#zh 文本资源类。 */
  5475. export class TextAsset extends Asset {
  5476. }
  5477. /** !#en Box Collider.
  5478. !#zh 包围盒碰撞组件 */
  5479. export class BoxCollider extends Collider implements Collider.Box {
  5480. /** !#en Position offset
  5481. !#zh 位置偏移量 */
  5482. offset: Vec2;
  5483. /** !#en Box size
  5484. !#zh 包围盒大小 */
  5485. size: Size;
  5486. }
  5487. /** !#en Circle Collider.
  5488. !#zh 圆形碰撞组件 */
  5489. export class CircleCollider extends Collider implements Collider.Circle {
  5490. /** !#en Position offset
  5491. !#zh 位置偏移量 */
  5492. offset: Vec2;
  5493. /** !#en Circle radius
  5494. !#zh 圆形半径 */
  5495. radius: number;
  5496. }
  5497. /** !#en Collider component base class.
  5498. !#zh 碰撞组件基类 */
  5499. export class Collider extends Component {
  5500. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  5501. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  5502. tag: number;
  5503. }
  5504. /** !#en
  5505. A simple collision manager class.
  5506. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  5507. !#zh
  5508. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  5509. export class CollisionManager implements EventTarget {
  5510. /** !#en
  5511. !#zh
  5512. 是否开启碰撞管理,默认为不开启 */
  5513. enabled: boolean;
  5514. /** !#en
  5515. !#zh
  5516. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  5517. enabledDrawBoundingBox: boolean;
  5518. /** !#en
  5519. !#zh
  5520. 是否绘制碰撞组件的形状,默认为不绘制 */
  5521. enabledDebugDraw: boolean;
  5522. /**
  5523. !#en
  5524. Register an callback of a specific event type on the EventTarget.
  5525. !#zh
  5526. 注册事件目标的特定事件类型回调。
  5527. @param type A string representing the event type to listen for.
  5528. @param callback The callback that will be invoked when the event is dispatched.
  5529. The callback is ignored if it is a duplicate (the callbacks are unique).
  5530. @param target The target (this object) to invoke the callback, can be null
  5531. @param useCapture When set to true, the capture argument prevents callback
  5532. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5533. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5534. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5535. @example
  5536. ```js
  5537. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5538. cc.log("this is callback");
  5539. }, node);
  5540. ```
  5541. */
  5542. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5543. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5544. /**
  5545. !#en
  5546. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5547. if only type is passed as parameter, all listeners registered with that type will be removed.
  5548. !#zh
  5549. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5550. @param type A string representing the event type being removed.
  5551. @param callback The callback to remove.
  5552. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5553. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5554. If not specified, useCapture defaults to false. If a callback was registered twice,
  5555. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5556. does not affect a non-capturing version of the same listener, and vice versa.
  5557. @example
  5558. ```js
  5559. // register touchEnd eventListener
  5560. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5561. cc.log("this is callback");
  5562. }, node);
  5563. // remove touch end event listener
  5564. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5565. // remove all touch end event listeners
  5566. node.off(cc.Node.EventType.TOUCH_END);
  5567. ```
  5568. */
  5569. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5570. /**
  5571. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5572. This is not for removing all listeners in the current event target,
  5573. and this is not for removing all listeners the target parameter have registered.
  5574. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5575. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5576. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5577. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5578. @param target The target to be searched for all related listeners
  5579. */
  5580. targetOff(target: any): void;
  5581. /**
  5582. !#en
  5583. Register an callback of a specific event type on the EventTarget,
  5584. the callback will remove itself after the first time it is triggered.
  5585. !#zh
  5586. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5587. @param type A string representing the event type to listen for.
  5588. @param callback The callback that will be invoked when the event is dispatched.
  5589. The callback is ignored if it is a duplicate (the callbacks are unique).
  5590. @param target The target (this object) to invoke the callback, can be null
  5591. @param useCapture When set to true, the capture argument prevents callback
  5592. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5593. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5594. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5595. @example
  5596. ```js
  5597. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5598. cc.log("this is callback");
  5599. }, node);
  5600. ```
  5601. */
  5602. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5603. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5604. /**
  5605. !#en
  5606. Dispatches an event into the event flow.
  5607. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5608. !#zh 分发事件到事件流中。
  5609. @param event The Event object that is dispatched into the event flow
  5610. */
  5611. dispatchEvent(event: Event): void;
  5612. /**
  5613. !#en
  5614. Send an event to this object directly, this method will not propagate the event to any other objects.
  5615. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5616. !#zh
  5617. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5618. @param message the message to send
  5619. @param detail whatever argument the message needs
  5620. */
  5621. emit(message: string, detail?: any): void;
  5622. }
  5623. /** !#en Intersection helper class
  5624. !#zh 辅助类,用于测试形状与形状是否相交 */
  5625. export class Intersection {
  5626. /**
  5627. !#en Test line and line
  5628. !#zh 测试线段与线段是否相交
  5629. @param a1 The start point of the first line
  5630. @param a2 The end point of the first line
  5631. @param b1 The start point of the second line
  5632. @param b2 The end point of the second line
  5633. */
  5634. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  5635. /**
  5636. !#en Test line and rect
  5637. !#zh 测试线段与矩形是否相交
  5638. @param a1 The start point of the line
  5639. @param a2 The end point of the line
  5640. @param b The rect
  5641. */
  5642. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  5643. /**
  5644. !#en Test line and polygon
  5645. !#zh 测试线段与多边形是否相交
  5646. @param a1 The start point of the line
  5647. @param a2 The end point of the line
  5648. @param b The polygon, a set of points
  5649. */
  5650. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  5651. /**
  5652. !#en Test rect and rect
  5653. !#zh 测试矩形与矩形是否相交
  5654. @param a The first rect
  5655. @param b The second rect
  5656. */
  5657. static rectRect(a: Rect, b: Rect): boolean;
  5658. /**
  5659. !#en Test rect and polygon
  5660. !#zh 测试矩形与多边形是否相交
  5661. @param a The rect
  5662. @param b The polygon, a set of points
  5663. */
  5664. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  5665. /**
  5666. !#en Test polygon and polygon
  5667. !#zh 测试多边形与多边形是否相交
  5668. @param a The first polygon, a set of points
  5669. @param b The second polygon, a set of points
  5670. */
  5671. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  5672. /**
  5673. !#en Test circle and circle
  5674. !#zh 测试圆形与圆形是否相交
  5675. @param a Object contains position and radius
  5676. @param b Object contains position and radius
  5677. */
  5678. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  5679. /**
  5680. !#en Test polygon and circle
  5681. !#zh 测试矩形与圆形是否相交
  5682. @param polygon The Polygon, a set of points
  5683. @param circle Object contains position and radius
  5684. */
  5685. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  5686. /**
  5687. !#en Test whether the point is in the polygon
  5688. !#zh 测试一个点是否在一个多边形中
  5689. @param point The point
  5690. @param polygon The polygon, a set of points
  5691. */
  5692. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  5693. /**
  5694. !#en Calculate the distance of point to line.
  5695. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  5696. @param point The point
  5697. @param start The start point of line
  5698. @param end The end point of line
  5699. @param isSegment whether this line is a segment
  5700. */
  5701. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean;
  5702. }
  5703. /** !#en Polygon Collider.
  5704. !#zh 多边形碰撞组件 */
  5705. export class PolygonCollider extends Collider implements Collider.Polygon {
  5706. /** !#en Position offset
  5707. !#zh 位置偏移量 */
  5708. offset: Vec2;
  5709. /** !#en Polygon points
  5710. !#zh 多边形顶点数组 */
  5711. points: [Vec2];
  5712. }
  5713. /** !#en The animation component is used to play back animations.
  5714. Animation provide several events to register:
  5715. - play : Emit when begin playing animation
  5716. - stop : Emit when stop playing animation
  5717. - pause : Emit when pause animation
  5718. - resume : Emit when resume animation
  5719. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  5720. - finished : Emit when finish playing animation
  5721. !#zh Animation 组件用于播放动画。
  5722. Animation 提供了一系列可注册的事件:
  5723. - play : 开始播放时
  5724. - stop : 停止播放时
  5725. - pause : 暂停播放时
  5726. - resume : 恢复播放时
  5727. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  5728. - finished : 动画播放完成时 */
  5729. export class Animation extends Component implements EventTarget {
  5730. /** !#en Animation will play the default clip when start game.
  5731. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  5732. defaultClip: AnimationClip;
  5733. /** !#en Current played clip.
  5734. !#zh 当前播放的动画剪辑。 */
  5735. currentClip: AnimationClip;
  5736. /** !#en Whether the animation should auto play the default clip when start game.
  5737. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  5738. playOnLoad: boolean;
  5739. /**
  5740. !#en Get all the clips used in this animation.
  5741. !#zh 获取动画组件上的所有动画剪辑。
  5742. */
  5743. getClips(): AnimationClip[];
  5744. /**
  5745. !#en Plays an animation and stop other animations.
  5746. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  5747. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5748. @param startTime play an animation from startTime
  5749. @example
  5750. ```js
  5751. var animCtrl = this.node.getComponent(cc.Animation);
  5752. animCtrl.play("linear");
  5753. ```
  5754. */
  5755. play(name?: string, startTime?: number): AnimationState;
  5756. /**
  5757. !#en
  5758. Plays an additive animation, it will not stop other animations.
  5759. If there are other animations playing, then will play several animations at the same time.
  5760. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  5761. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  5762. @param startTime play an animation from startTime
  5763. @example
  5764. ```js
  5765. // linear_1 and linear_2 at the same time playing.
  5766. var animCtrl = this.node.getComponent(cc.Animation);
  5767. animCtrl.playAdditive("linear_1");
  5768. animCtrl.playAdditive("linear_2");
  5769. ```
  5770. */
  5771. playAdditive(name?: string, startTime?: number): AnimationState;
  5772. /**
  5773. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  5774. Stopping an animation also Rewinds it to the Start.
  5775. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  5776. @param name The animation to stop, if not supplied then stops all playing animations.
  5777. */
  5778. stop(name?: string): void;
  5779. /**
  5780. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  5781. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  5782. @param name The animation to pauses, if not supplied then pauses all playing animations.
  5783. */
  5784. pause(name?: string): void;
  5785. /**
  5786. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  5787. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  5788. @param name The animation to resumes, if not supplied then resumes all paused animations.
  5789. */
  5790. resume(name?: string): void;
  5791. /**
  5792. !#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.
  5793. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  5794. @param time The time to go to
  5795. @param name Specified animation name, if not supplied then make all animations go to the time.
  5796. */
  5797. setCurrentTime(time?: number, name?: string): void;
  5798. /**
  5799. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  5800. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  5801. @param name name
  5802. */
  5803. getAnimationState(name: string): AnimationState;
  5804. /**
  5805. !#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.
  5806. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  5807. @param clip the clip to add
  5808. @param newName newName
  5809. */
  5810. addClip(clip: AnimationClip, newName?: string): AnimationState;
  5811. /**
  5812. !#en
  5813. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  5814. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  5815. 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
  5816. !#zh
  5817. 从动画列表中移除指定的动画剪辑,<br/>
  5818. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  5819. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  5820. @param clip clip
  5821. @param force If force is true, then will always remove the clip and any animation states based on it.
  5822. */
  5823. removeClip(clip: AnimationClip, force?: boolean): void;
  5824. /**
  5825. !#en
  5826. Samples animations at the current state.<br/>
  5827. This is useful when you explicitly want to set up some animation state, and sample it once.
  5828. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  5829. @param name name
  5830. */
  5831. sample(name: string): void;
  5832. /**
  5833. !#en
  5834. Register animation event callback.
  5835. The event arguments will provide the AnimationState which emit the event.
  5836. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  5837. !#zh
  5838. 注册动画事件回调。
  5839. 回调的事件里将会附上发送事件的 AnimationState。
  5840. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  5841. @param type A string representing the event type to listen for.
  5842. @param callback The callback that will be invoked when the event is dispatched.
  5843. The callback is ignored if it is a duplicate (the callbacks are unique).
  5844. @param target The target (this object) to invoke the callback, can be null
  5845. @param useCapture When set to true, the capture argument prevents callback
  5846. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5847. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5848. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5849. @example
  5850. ```js
  5851. onPlay: function (event) {
  5852. var state = event.detail; // state instanceof cc.AnimationState
  5853. var type = event.type; // type === 'play';
  5854. }
  5855. // register event to all animation
  5856. animation.on('play', this.onPlay, this);
  5857. ```
  5858. */
  5859. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5860. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5861. /**
  5862. !#en
  5863. Unregister animation event callback.
  5864. !#zh
  5865. 取消注册动画事件回调。
  5866. @param type A string representing the event type being removed.
  5867. @param callback The callback to remove.
  5868. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5869. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5870. If not specified, useCapture defaults to false. If a callback was registered twice,
  5871. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5872. does not affect a non-capturing version of the same listener, and vice versa.
  5873. @example
  5874. ```js
  5875. // unregister event to all animation
  5876. animation.off('play', this.onPlay, this);
  5877. ```
  5878. */
  5879. off(type: string, callback: Function, target?: any, useCapture?: boolean): void;
  5880. /**
  5881. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5882. This is not for removing all listeners in the current event target,
  5883. and this is not for removing all listeners the target parameter have registered.
  5884. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5885. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5886. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5887. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5888. @param target The target to be searched for all related listeners
  5889. */
  5890. targetOff(target: any): void;
  5891. /**
  5892. !#en
  5893. Register an callback of a specific event type on the EventTarget,
  5894. the callback will remove itself after the first time it is triggered.
  5895. !#zh
  5896. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5897. @param type A string representing the event type to listen for.
  5898. @param callback The callback that will be invoked when the event is dispatched.
  5899. The callback is ignored if it is a duplicate (the callbacks are unique).
  5900. @param target The target (this object) to invoke the callback, can be null
  5901. @param useCapture When set to true, the capture argument prevents callback
  5902. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5903. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5904. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5905. @example
  5906. ```js
  5907. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5908. cc.log("this is callback");
  5909. }, node);
  5910. ```
  5911. */
  5912. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5913. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5914. /**
  5915. !#en
  5916. Dispatches an event into the event flow.
  5917. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5918. !#zh 分发事件到事件流中。
  5919. @param event The Event object that is dispatched into the event flow
  5920. */
  5921. dispatchEvent(event: Event): void;
  5922. /**
  5923. !#en
  5924. Send an event to this object directly, this method will not propagate the event to any other objects.
  5925. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5926. !#zh
  5927. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5928. @param message the message to send
  5929. @param detail whatever argument the message needs
  5930. */
  5931. emit(message: string, detail?: any): void;
  5932. }
  5933. /** !#en Audio Source.
  5934. !#zh 音频源组件,能对音频剪辑。 */
  5935. export class AudioSource extends Component {
  5936. /** !#en
  5937. Is the audio source playing (Read Only). <br/>
  5938. Note: isPlaying is not supported for Native platforms.
  5939. !#zh
  5940. 该音频剪辑是否正播放(只读)。<br/>
  5941. 注意:Native 平台暂时不支持 isPlaying。 */
  5942. isPlaying: boolean;
  5943. /** !#en The clip of the audio source.
  5944. !#zh 默认要播放的音频剪辑。 */
  5945. clip: AudioClip;
  5946. /** !#en The volume of the audio source.
  5947. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  5948. volume: number;
  5949. /** !#en Is the audio source mute?
  5950. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  5951. mute: boolean;
  5952. /** !#en Is the audio source looping?
  5953. !#zh 音频源是否循环播放? */
  5954. loop: boolean;
  5955. /** !#en If set to true, the audio source will automatically start playing on onLoad.
  5956. !#zh 如果设置为true,音频源将在 onLoad 时自动播放。 */
  5957. playOnLoad: boolean;
  5958. /**
  5959. !#en Plays the clip.
  5960. !#zh 播放音频剪辑。
  5961. */
  5962. play(): void;
  5963. /**
  5964. !#en Stops the clip.
  5965. !#zh 停止当前音频剪辑。
  5966. */
  5967. stop(): void;
  5968. /**
  5969. !#en Pause the clip.
  5970. !#zh 暂停当前音频剪辑。
  5971. */
  5972. pause(): void;
  5973. /**
  5974. !#en Resume the clip.
  5975. !#zh 恢复播放。
  5976. */
  5977. resume(): void;
  5978. /**
  5979. !#en Rewind playing music.
  5980. !#zh 从头开始播放。
  5981. */
  5982. rewind(): void;
  5983. /**
  5984. !#en Get current time
  5985. !#zh 获取当前的播放时间
  5986. */
  5987. getCurrentTime(): void;
  5988. /**
  5989. !#en Set current time
  5990. !#zh 设置当前的播放时间
  5991. @param time time
  5992. */
  5993. setCurrentTime(time: number): void;
  5994. /**
  5995. !#en Get audio duration
  5996. !#zh 获取当前音频的长度
  5997. */
  5998. getDuration(): void;
  5999. }
  6000. /** !#en
  6001. 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>
  6002. This component does not have any API interface and can be added directly to the scene to take effect.
  6003. !#zh
  6004. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6005. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6006. export class BlockInputEvents extends Component {
  6007. }
  6008. /** !#en
  6009. Button has 4 Transition types
  6010. When Button state changed:
  6011. If Transition type is Button.Transition.NONE, Button will do nothing
  6012. If Transition type is Button.Transition.COLOR, Button will change target's color
  6013. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6014. If Transition type is Button.Transition.SCALE, Button will change target node's scale
  6015. Button will trigger 5 events:
  6016. Button.EVENT_TOUCH_DOWN
  6017. Button.EVENT_TOUCH_UP
  6018. Button.EVENT_HOVER_IN
  6019. Button.EVENT_HOVER_MOVE
  6020. Button.EVENT_HOVER_OUT
  6021. !#zh
  6022. 按钮组件。可以被按下,或者点击。</br>
  6023. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:</br>
  6024. -Button.Transition.NONE // 不做任何过渡</br>
  6025. -Button.Transition.COLOR // 进行颜色之间过渡</br>
  6026. -Button.Transition.SPRITE // 进行精灵之间过渡</br>
  6027. -Button.Transition.SCALE // 进行缩放过渡</br>
  6028. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):</br>
  6029. // 以下事件可以在全平台上都触发</br>
  6030. -cc.Node.EventType.TOUCH_START // 按下时事件</br>
  6031. -cc.Node.EventType.TOUCH_Move // 按住移动后事件</br>
  6032. -cc.Node.EventType.TOUCH_END // 按下后松开后事件</br>
  6033. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件</br>
  6034. // 以下事件只在 PC 平台上触发</br>
  6035. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件</br>
  6036. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件</br>
  6037. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件</br>
  6038. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件</br>
  6039. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件</br>
  6040. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件</br> */
  6041. export class Button extends Component {
  6042. /** !#en
  6043. Whether the Button is disabled.
  6044. If true, the Button will trigger event and do transition.
  6045. !#zh
  6046. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6047. interactable: boolean;
  6048. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6049. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6050. enableAutoGrayEffect: boolean;
  6051. /** !#en Transition type
  6052. !#zh 按钮状态改变时过渡方式。 */
  6053. transition: Button.Transition;
  6054. /** !#en Normal state color.
  6055. !#zh 普通状态下按钮所显示的颜色。 */
  6056. normalColor: Color;
  6057. /** !#en Pressed state color
  6058. !#zh 按下状态时按钮所显示的颜色。 */
  6059. pressedColor: Color;
  6060. /** !#en Hover state color
  6061. !#zh 悬停状态下按钮所显示的颜色。 */
  6062. hoverColor: Color;
  6063. /** !#en Disabled state color
  6064. !#zh 禁用状态下按钮所显示的颜色。 */
  6065. disabledColor: Color;
  6066. /** !#en Color and Scale transition duration
  6067. !#zh 颜色过渡和缩放过渡时所需时间 */
  6068. duration: number;
  6069. /** !#en When user press the button, the button will zoom to a scale.
  6070. The final scale of the button equals (button original scale * zoomScale)
  6071. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6072. zoomScale: number;
  6073. /** !#en Normal state sprite
  6074. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6075. normalSprite: SpriteFrame;
  6076. /** !#en Pressed state sprite
  6077. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6078. pressedSprite: SpriteFrame;
  6079. /** !#en Hover state sprite
  6080. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6081. hoverSprite: SpriteFrame;
  6082. /** !#en Disabled state sprite
  6083. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6084. disabledSprite: SpriteFrame;
  6085. /** !#en
  6086. Transition target.
  6087. When Button state changed:
  6088. If Transition type is Button.Transition.NONE, Button will do nothing
  6089. If Transition type is Button.Transition.COLOR, Button will change target's color
  6090. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6091. !#zh
  6092. 需要过渡的目标。
  6093. 当前按钮状态改变规则:
  6094. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6095. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6096. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6097. target: Node;
  6098. /** !#en If Button is clicked, it will trigger event's handler
  6099. !#zh 按钮的点击事件列表。 */
  6100. clickEvents: Component.EventHandler[];
  6101. }
  6102. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  6103. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6104. export class Canvas extends Component {
  6105. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6106. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6107. static instance: Canvas;
  6108. /** !#en The desigin resolution for current scene.
  6109. !#zh 当前场景设计分辨率。 */
  6110. designResolution: Size;
  6111. /** !#en TODO
  6112. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6113. fitHeight: boolean;
  6114. /** !#en TODO
  6115. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6116. fitWidth: boolean;
  6117. }
  6118. /** !#en
  6119. Base class for everything attached to Node(Entity).<br/>
  6120. <br/>
  6121. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6122. because Component is created by the engine.
  6123. !#zh
  6124. 所有附加到节点的基类。<br/>
  6125. <br/>
  6126. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6127. export class Component extends Object {
  6128. /** !#en The node this component is attached to. A component is always attached to a node.
  6129. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6130. node: Node;
  6131. /** !#en The uuid for editor.
  6132. !#zh 组件的 uuid,用于编辑器。 */
  6133. uuid: string;
  6134. /** !#en indicates whether this component is enabled or not.
  6135. !#zh 表示该组件自身是否启用。 */
  6136. enabled: boolean;
  6137. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6138. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6139. enabledInHierarchy: boolean;
  6140. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6141. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6142. _isOnLoadCalled: number;
  6143. /**
  6144. !#en Update is called every frame, if the Component is enabled.
  6145. !#zh 如果该组件启用,则每帧调用 update。
  6146. @param dt the delta time in seconds it took to complete the last frame
  6147. */
  6148. protected update(dt: number): void;
  6149. /**
  6150. !#en LateUpdate is called every frame, if the Component is enabled.
  6151. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  6152. */
  6153. protected lateUpdate(): void;
  6154. /**
  6155. !#en
  6156. When attaching to an active node or its node first activated.
  6157. onLoad is always called before any start functions, this allows you to order initialization of scripts.
  6158. !#zh
  6159. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
  6160. */
  6161. protected onLoad(): void;
  6162. /**
  6163. !#en
  6164. Called before all scripts' update if the Component is enabled the first time.
  6165. Usually used to initialize some logic which need to be called after all components' `onload` methods called.
  6166. !#zh
  6167. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
  6168. */
  6169. protected start(): void;
  6170. /**
  6171. !#en Called when this component becomes enabled and its node is active.
  6172. !#zh 当该组件被启用,并且它的节点也激活时。
  6173. */
  6174. protected onEnable(): void;
  6175. /**
  6176. !#en Called when this component becomes disabled or its node becomes inactive.
  6177. !#zh 当该组件被禁用或节点变为无效时调用。
  6178. */
  6179. protected onDisable(): void;
  6180. /**
  6181. !#en Called when this component will be destroyed.
  6182. !#zh 当该组件被销毁时调用
  6183. */
  6184. protected onDestroy(): void;
  6185. protected onFocusInEditor(): void;
  6186. protected onLostFocusInEditor(): void;
  6187. /**
  6188. !#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.
  6189. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6190. */
  6191. protected resetInEditor(): void;
  6192. /**
  6193. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6194. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6195. @param typeOrClassName the constructor or the class name of the component to add
  6196. @example
  6197. ```js
  6198. var sprite = node.addComponent(cc.Sprite);
  6199. var test = node.addComponent("Test");
  6200. ```
  6201. */
  6202. addComponent<T extends Component>(type: {new(): T}): T;
  6203. addComponent(className: string): any;
  6204. /**
  6205. !#en
  6206. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6207. You can also get component in the node by passing in the name of the script.
  6208. !#zh
  6209. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6210. 传入参数也可以是脚本的名称。
  6211. @param typeOrClassName typeOrClassName
  6212. @example
  6213. ```js
  6214. // get sprite component.
  6215. var sprite = node.getComponent(cc.Sprite);
  6216. // get custom test calss.
  6217. var test = node.getComponent("Test");
  6218. ```
  6219. */
  6220. getComponent<T extends Component>(type: {prototype: T}): T;
  6221. getComponent(className: string): any;
  6222. /**
  6223. !#en Returns all components of supplied Type in the node.
  6224. !#zh 返回节点上指定类型的所有组件。
  6225. @param typeOrClassName typeOrClassName
  6226. @example
  6227. ```js
  6228. var sprites = node.getComponents(cc.Sprite);
  6229. var tests = node.getComponents("Test");
  6230. ```
  6231. */
  6232. getComponents<T extends Component>(type: {prototype: T}): T[];
  6233. getComponents(className: string): any[];
  6234. /**
  6235. !#en Returns the component of supplied type in any of its children using depth first search.
  6236. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6237. @param typeOrClassName typeOrClassName
  6238. @example
  6239. ```js
  6240. var sprite = node.getComponentInChildren(cc.Sprite);
  6241. var Test = node.getComponentInChildren("Test");
  6242. ```
  6243. */
  6244. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6245. getComponentInChildren(className: string): any;
  6246. /**
  6247. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6248. !#zh 递归查找自身或所有子节点中指定类型的组件
  6249. @param typeOrClassName typeOrClassName
  6250. @example
  6251. ```js
  6252. var sprites = node.getComponentsInChildren(cc.Sprite);
  6253. var tests = node.getComponentsInChildren("Test");
  6254. ```
  6255. */
  6256. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6257. getComponentsInChildren(className: string): any[];
  6258. /**
  6259. !#en
  6260. If the component's bounding box is different from the node's, you can implement this method to supply
  6261. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6262. !#zh
  6263. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6264. 以便编辑器的场景视图可以正确地执行点选测试。
  6265. @param out_rect the Rect to receive the bounding box
  6266. */
  6267. _getLocalBounds(out_rect: Rect): void;
  6268. /**
  6269. !#en
  6270. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6271. an undo operation on this component.<br/>
  6272. <br/>
  6273. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6274. in its CCClass properties", then you may need to implement this function.<br/>
  6275. <br/>
  6276. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6277. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6278. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6279. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6280. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6281. will be recorded or restored by editor.<br/>
  6282. <br/>
  6283. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6284. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6285. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6286. will not be called during reset operation. Which means that only the properties with default value<br/>
  6287. will be reset by editor.
  6288. This function is only called in editor mode.
  6289. !#zh
  6290. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6291. <br/>
  6292. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6293. <br/>
  6294. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  6295. 然而,在极端的情况下,它可能无法良好运作。<br/>
  6296. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  6297. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  6298. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6299. <br/>
  6300. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  6301. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  6302. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  6303. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  6304. <br/>
  6305. 此方法仅在编辑器下会被调用。
  6306. */
  6307. onRestore(): void;
  6308. /**
  6309. !#en
  6310. Schedules a custom selector.<br/>
  6311. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6312. !#zh
  6313. 调度一个自定义的回调函数。<br/>
  6314. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6315. @param callback The callback function
  6316. @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead.
  6317. @param repeat The selector will be executed (repeat + 1) times, you can use kCCRepeatForever for tick infinitely.
  6318. @param delay The amount of time that the first tick will wait before execution.
  6319. @example
  6320. ```js
  6321. var timeCallback = function (dt) {
  6322. cc.log("time: " + dt);
  6323. }
  6324. this.schedule(timeCallback, 1);
  6325. ```
  6326. */
  6327. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6328. /**
  6329. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6330. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6331. @param callback A function wrapped as a selector
  6332. @param delay The amount of time that the first tick will wait before execution.
  6333. @example
  6334. ```js
  6335. var timeCallback = function (dt) {
  6336. cc.log("time: " + dt);
  6337. }
  6338. this.scheduleOnce(timeCallback, 2);
  6339. ```
  6340. */
  6341. scheduleOnce(callback: Function, delay?: number): void;
  6342. /**
  6343. !#en Unschedules a custom callback function.
  6344. !#zh 取消调度一个自定义的回调函数。
  6345. @param callback_fn A function wrapped as a selector
  6346. @example
  6347. ```js
  6348. this.unschedule(_callback);
  6349. ```
  6350. */
  6351. unschedule(callback_fn: Function): void;
  6352. /**
  6353. !#en
  6354. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6355. Actions are not affected by this method.
  6356. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  6357. @example
  6358. ```js
  6359. this.unscheduleAllCallbacks();
  6360. ```
  6361. */
  6362. unscheduleAllCallbacks(): void;
  6363. }
  6364. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  6365. !#zh EditBox 组件,用于获取用户的输入文本。 */
  6366. export class EditBox extends _RendererUnderSG {
  6367. /** !#en Input string of EditBox.
  6368. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  6369. string: string;
  6370. /** !#en The background image of EditBox.
  6371. !#zh 输入框的背景图片 */
  6372. backgroundImage: SpriteFrame;
  6373. /** !#en
  6374. The return key type of EditBox.
  6375. Note: it is meaningless for web platforms and desktop platforms.
  6376. !#zh
  6377. 指定移动设备上面回车按钮的样式。
  6378. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  6379. returnType: EditBox.KeyboardReturnType;
  6380. /** !#en Set the input flags that are to be applied to the EditBox.
  6381. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  6382. inputFlag: EditBox.InputFlag;
  6383. /** !#en
  6384. Set the input mode of the edit box.
  6385. If you pass ANY, it will create a multiline EditBox.
  6386. !#zh
  6387. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  6388. inputMode: EditBox.InputMode;
  6389. /** !#en Font size of the input text.
  6390. !#zh 输入框文本的字体大小 */
  6391. fontSize: number;
  6392. /** !#en Change the lineHeight of displayed text.
  6393. !#zh 输入框文本的行高。 */
  6394. lineHeight: number;
  6395. /** !#en Font color of the input text.
  6396. !#zh 输入框文本的颜色。 */
  6397. fontColor: Color;
  6398. /** !#en The display text of placeholder.
  6399. !#zh 输入框占位符的文本内容。 */
  6400. placeholder: string;
  6401. /** !#en The font size of placeholder.
  6402. !#zh 输入框占位符的字体大小。 */
  6403. placeholderFontSize: number;
  6404. /** !#en The font color of placeholder.
  6405. !#zh 输入框最大允许输入的字符个数。 */
  6406. placeholderFontColor: Color;
  6407. /** !#en The maximize input length of EditBox.
  6408. - If pass a value less than 0, it won't limit the input number of characters.
  6409. - If pass 0, it doesn't allow input any characters.
  6410. !#zh 输入框最大允许输入的字符个数。
  6411. - 如果值为小于 0 的值,则不会限制输入字符个数。
  6412. - 如果值为 0,则不允许用户进行任何输入。 */
  6413. maxLength: number;
  6414. /** !#en The input is always visible and be on top of the game view.
  6415. !zh 输入框总是可见,并且永远在游戏视图的上面
  6416. Note: only available on Web at the moment. */
  6417. stayOnTop: boolean;
  6418. /** !#en Set the tabIndex of the DOM input element, only useful on Web.
  6419. !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */
  6420. tabIndex: number;
  6421. /** !#en The event handler to be called when EditBox began to edit text.
  6422. !#zh 开始编辑文本输入框触发的事件回调。 */
  6423. editingDidBegan: Component.EventHandler[];
  6424. /** !#en The event handler to be called when EditBox text changes.
  6425. !#zh 编辑文本输入框时触发的事件回调。 */
  6426. textChanged: Component.EventHandler[];
  6427. /** !#en The event handler to be called when EditBox edit ends.
  6428. !#zh 结束编辑文本输入框时触发的事件回调。 */
  6429. editingDidEnded: Component.EventHandler[];
  6430. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  6431. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  6432. editingReturn: Component.EventHandler[];
  6433. /**
  6434. !#en Let the EditBox get focus, only valid when stayOnTop is true.
  6435. !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
  6436. Note: only available on Web at the moment.
  6437. */
  6438. setFocus(): void;
  6439. /**
  6440. !#en Determine whether EditBox is getting focus or not.
  6441. !#zh 判断 EditBox 是否获得了焦点
  6442. Note: only available on Web at the moment.
  6443. */
  6444. isFocused(): void;
  6445. /**
  6446. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  6447. call the destroy method on this component or the associated node explicitly.
  6448. Otherwise, the created DOM element won't be removed from web page.
  6449. !#zh
  6450. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  6451. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  6452. @example
  6453. ```js
  6454. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  6455. // when you don't need editbox anymore
  6456. editbox.node.destroy();
  6457. ```
  6458. */
  6459. destroy(): boolean;
  6460. }
  6461. /** !#en The Label Component.
  6462. !#zh 文字标签组件 */
  6463. export class Label extends _RendererUnderSG {
  6464. /** !#en Content string of label.
  6465. !#zh 标签显示的文本内容。 */
  6466. string: string;
  6467. /** !#en Horizontal Alignment of label.
  6468. !#zh 文本内容的水平对齐方式。 */
  6469. horizontalAlign: Label.HorizontalAlign;
  6470. /** !#en Vertical Alignment of label.
  6471. !#zh 文本内容的垂直对齐方式。 */
  6472. verticalAlign: Label.VerticalAlign;
  6473. /** !#en The actual rendering font size in shrink mode
  6474. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6475. actualFontSize: number;
  6476. /** !#en Font size of label.
  6477. !#zh 文本字体大小。 */
  6478. fontSize: number;
  6479. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6480. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6481. fontFamily: string;
  6482. /** !#en Line Height of label.
  6483. !#zh 文本行高。 */
  6484. lineHeight: number;
  6485. /** !#en Overflow of label.
  6486. !#zh 文字显示超出范围时的处理方式。 */
  6487. overflow: Label.Overflow;
  6488. /** !#en Whether auto wrap label when string width is large than label width.
  6489. !#zh 是否自动换行。 */
  6490. enableWrapText: boolean;
  6491. /** !#en The font of label.
  6492. !#zh 文本字体。 */
  6493. font: Font;
  6494. /** !#en Whether use system font name or not.
  6495. !#zh 是否使用系统字体。 */
  6496. isSystemFontUsed: boolean;
  6497. }
  6498. /** !#en Outline effect used to change the display, only used for TTF font
  6499. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6500. export class LabelOutline extends Component {
  6501. /** !#en Change the outline color
  6502. !#zh 改变描边的颜色 */
  6503. color: Color;
  6504. /** !#en Change the outline width
  6505. !#zh 改变描边的宽度 */
  6506. width: number;
  6507. }
  6508. /** !#en
  6509. The Layout is a container component, use it to arrange child elements easily.<br>
  6510. Note:<br>
  6511. 1.Scaling and rotation of child nodes are not considered.<br>
  6512. 2.After setting the Layout, the results need to be updated until the next frame,
  6513. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6514. !#zh
  6515. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6516. 注意:<br>
  6517. 1.不会考虑子节点的缩放和旋转。<br>
  6518. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6519. export class Layout extends Component {
  6520. /** !#en The layout type.
  6521. !#zh 布局类型 */
  6522. type: Layout.Type;
  6523. /** !#en
  6524. The are three resize modes for Layout.
  6525. None, resize Container and resize children.
  6526. !#zh 缩放模式 */
  6527. resizeMode: Layout.ResizeMode;
  6528. /** !#en The cell size for grid layout.
  6529. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6530. cellSize: Size;
  6531. /** !#en
  6532. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6533. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6534. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6535. startAxis: Layout.AxisDirection;
  6536. /** !#en The left padding of layout, it only effect the layout in one direction.
  6537. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6538. paddingLeft: number;
  6539. /** !#en The right padding of layout, it only effect the layout in one direction.
  6540. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6541. paddingRight: number;
  6542. /** !#en The top padding of layout, it only effect the layout in one direction.
  6543. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6544. paddingTop: number;
  6545. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6546. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6547. paddingBottom: number;
  6548. /** !#en The distance in x-axis between each element in layout.
  6549. !#zh 子节点之间的水平间距。 */
  6550. spacingX: number;
  6551. /** !#en The distance in y-axis between each element in layout.
  6552. !#zh 子节点之间的垂直间距。 */
  6553. spacingY: number;
  6554. /** !#en
  6555. Only take effect in Vertical layout mode.
  6556. This option changes the start element's positioning.
  6557. !#zh 垂直排列子节点的方向。 */
  6558. verticalDirection: Layout.VerticalDirection;
  6559. /** !#en
  6560. Only take effect in Horizontal layout mode.
  6561. This option changes the start element's positioning.
  6562. !#zh 水平排列子节点的方向。 */
  6563. horizontalDirection: Layout.HorizontalDirection;
  6564. /**
  6565. !#en Perform the layout update
  6566. !#zh 立即执行更新布局
  6567. @example
  6568. ```js
  6569. layout.type = cc.Layout.HORIZONTAL;
  6570. layout.node.addChild(childNode);
  6571. cc.log(childNode.x); // not yet changed
  6572. layout.updateLayout();
  6573. cc.log(childNode.x); // changed
  6574. ```
  6575. */
  6576. updateLayout(): void;
  6577. /** !#en The padding of layout, it effects the layout in four direction.
  6578. !#zh 容器内边距,该属性会在四个布局方向上生效。 */
  6579. padding: number;
  6580. }
  6581. /** !#en The Mask Component
  6582. !#zh 遮罩组件 */
  6583. export class Mask extends _RendererInSG {
  6584. /** !#en The mask type.
  6585. !#zh 遮罩类型 */
  6586. type: Mask.Type;
  6587. /** !#en The mask image
  6588. !#zh 遮罩所需要的贴图 */
  6589. spriteFrame: SpriteFrame;
  6590. /** !#en
  6591. The alpha threshold.(Not supported Canvas Mode) <br/>
  6592. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6593. Should be a float between 0 and 1. <br/>
  6594. This default to 1 (so alpha test is disabled).
  6595. !#zh
  6596. Alpha 阈值(不支持 Canvas 模式)<br/>
  6597. 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。<br/>
  6598. 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */
  6599. alphaThreshold: number;
  6600. /** !#en Reverse mask (Not supported Canvas Mode)
  6601. !#zh 反向遮罩(不支持 Canvas 模式) */
  6602. inverted: boolean;
  6603. /** !#en The segements for ellipse mask.
  6604. !#zh 椭圆遮罩的曲线细分数 */
  6605. segements: number;
  6606. }
  6607. /** !#en The PageView control
  6608. !#zh 页面视图组件 */
  6609. export class PageView extends ScrollView {
  6610. /** !#en Specify the size type of each page in PageView.
  6611. !#zh 页面视图中每个页面大小类型 */
  6612. sizeMode: PageView.SizeMode;
  6613. /** !#en The page view direction
  6614. !#zh 页面视图滚动类型 */
  6615. direction: PageView.Direction;
  6616. /** !#en
  6617. The scroll threshold value, when drag exceeds this value,
  6618. release the next page will automatically scroll, less than the restore
  6619. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6620. scrollThreshold: number;
  6621. /** !#en
  6622. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6623. it will calculate a velocity based on the scroll distance and time,
  6624. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6625. !#zh
  6626. 快速滑动翻页临界值。
  6627. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6628. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6629. autoPageTurningThreshold: number;
  6630. /** !#en Change the PageTurning event timing of PageView.
  6631. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6632. pageTurningEventTiming: number;
  6633. /** !#en The Page View Indicator
  6634. !#zh 页面视图指示器组件 */
  6635. indicator: PageViewIndicator;
  6636. /** !#en The time required to turn over a page. unit: second
  6637. !#zh 每个页面翻页时所需时间。单位:秒 */
  6638. pageTurningSpeed: number;
  6639. /** !#en PageView events callback
  6640. !#zh 滚动视图的事件回调函数 */
  6641. pageEvents: Component.EventHandler[];
  6642. /**
  6643. !#en Returns current page index
  6644. !#zh 返回当前页面索引
  6645. */
  6646. getCurrentPageIndex(): number;
  6647. /**
  6648. !#en Set current page index
  6649. !#zh 设置当前页面索引
  6650. @param index index
  6651. */
  6652. setCurrentPageIndex(index: number): void;
  6653. /**
  6654. !#en Returns all pages of pageview
  6655. !#zh 返回视图中的所有页面
  6656. */
  6657. getPages(): Node[];
  6658. /**
  6659. !#en At the end of the current page view to insert a new view
  6660. !#zh 在当前页面视图的尾部插入一个新视图
  6661. @param page page
  6662. */
  6663. addPage(page: Node): void;
  6664. /**
  6665. !#en Inserts a page in the specified location
  6666. !#zh 将页面插入指定位置中
  6667. @param page page
  6668. @param index index
  6669. */
  6670. insertPage(page: Node, index: number): void;
  6671. /**
  6672. !#en Removes a page from PageView.
  6673. !#zh 移除指定页面
  6674. @param page page
  6675. */
  6676. removePage(page: Node): void;
  6677. /**
  6678. !#en Removes a page at index of PageView.
  6679. !#zh 移除指定下标的页面
  6680. @param index index
  6681. */
  6682. removePageAtIndex(index: number): void;
  6683. /**
  6684. !#en Removes all pages from PageView
  6685. !#zh 移除所有页面
  6686. */
  6687. removeAllPages(): void;
  6688. /**
  6689. !#en Scroll PageView to index.
  6690. !#zh 滚动到指定页面
  6691. @param idx index of page.
  6692. @param timeInSecond scrolling time
  6693. */
  6694. scrollToPage(idx: number, timeInSecond: number): void;
  6695. }
  6696. /** !#en The Page View Indicator Component
  6697. !#zh 页面视图每页标记组件 */
  6698. export class PageViewIndicator extends Component {
  6699. /** !#en The spriteFrame for each element.
  6700. !#zh 每个页面标记显示的图片 */
  6701. spriteFrame: SpriteFrame;
  6702. /** !#en The location direction of PageViewIndicator.
  6703. !#zh 页面标记摆放方向 */
  6704. direction: PageViewIndicator.Direction;
  6705. /** !#en The cellSize for each element.
  6706. !#zh 每个页面标记的大小 */
  6707. cellSize: Size;
  6708. /** !#en The distance between each element.
  6709. !#zh 每个页面标记之间的边距 */
  6710. spacing: number;
  6711. /**
  6712. !#en Set Page View
  6713. !#zh 设置页面视图
  6714. @param target target
  6715. */
  6716. setPageView(target: PageView): void;
  6717. }
  6718. /** !#en
  6719. Visual indicator of progress in some operation.
  6720. Displays a bar to the user representing how far the operation has progressed.
  6721. !#zh
  6722. 进度条组件,可用于显示加载资源时的进度。 */
  6723. export class ProgressBar extends Component {
  6724. /** !#en The targeted Sprite which will be changed progressively.
  6725. !#zh 用来显示进度条比例的 Sprite 对象。 */
  6726. barSprite: Sprite;
  6727. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  6728. !#zh 进度条的模式 */
  6729. mode: ProgressBar.Mode;
  6730. /** !#en The total width or height of the bar sprite.
  6731. !#zh 进度条实际的总长度 */
  6732. totalLength: number;
  6733. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  6734. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  6735. progress: number;
  6736. /** !#en Whether reverse the progress direction of the bar sprite.
  6737. !#zh 进度条是否进行反方向变化。 */
  6738. reverse: boolean;
  6739. }
  6740. /** Rendering component in scene graph.
  6741. Maintains a node which will be the scene graph of component's Node. */
  6742. export class _RendererInSG extends _SGComponent {
  6743. }
  6744. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  6745. export class _RendererUnderSG extends _SGComponent {
  6746. }
  6747. /** !#en The RichText Component.
  6748. !#zh 富文本组件 */
  6749. export class RichText extends Component {
  6750. /** !#en Content string of RichText.
  6751. !#zh 富文本显示的文本内容。 */
  6752. string: string;
  6753. /** !#en Horizontal Alignment of each line in RichText.
  6754. !#zh 文本内容的水平对齐方式。 */
  6755. horizontalAlign: TextAlignment;
  6756. /** !#en Font size of RichText.
  6757. !#zh 富文本字体大小。 */
  6758. fontSize: number;
  6759. /** !#en Custom TTF font of RichText
  6760. !#zh 富文本定制字体 */
  6761. font: cc.TTFFont;
  6762. /** !#en The maximize width of the RichText
  6763. !#zh 富文本的最大宽度 */
  6764. maxWidth: number;
  6765. /** !#en Line Height of RichText.
  6766. !#zh 富文本行高。 */
  6767. lineHeight: number;
  6768. /** !#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.
  6769. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  6770. imageAtlas: SpriteAtlas;
  6771. /** !#en
  6772. Once checked, the RichText will block all input events (mouse and touch) within
  6773. the bounding box of the node, preventing the input from penetrating into the underlying node.
  6774. !#zh
  6775. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  6776. handleTouchEvent: boolean;
  6777. }
  6778. /** The base class for all rendering component in scene graph.
  6779. You should override:
  6780. - _createSgNode
  6781. - _initSgNode */
  6782. export class _SGComponent extends Component {
  6783. }
  6784. /** !#en
  6785. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  6786. !#zh 滚动条组件 */
  6787. export class Scrollbar extends Component {
  6788. /** !#en The "handle" part of the scrollbar.
  6789. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  6790. handle: Sprite;
  6791. /** !#en The direction of scrollbar.
  6792. !#zh ScrollBar 的滚动方向。 */
  6793. direction: Scrollbar.Direction;
  6794. /** !#en Whether enable auto hide or not.
  6795. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  6796. enableAutoHide: boolean;
  6797. /** !#en
  6798. The time to hide scrollbar when scroll finished.
  6799. Note: This value is only useful when enableAutoHide is true.
  6800. !#zh
  6801. 没有滚动动作后经过多久会自动隐藏。
  6802. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  6803. autoHideTime: number;
  6804. }
  6805. /** !#en
  6806. Layout container for a view hierarchy that can be scrolled by the user,
  6807. allowing it to be larger than the physical display.
  6808. !#zh
  6809. 滚动视图组件 */
  6810. export class ScrollView extends Component {
  6811. /** !#en This is a reference to the UI element to be scrolled.
  6812. !#zh 可滚动展示内容的节点。 */
  6813. content: Node;
  6814. /** !#en Enable horizontal scroll.
  6815. !#zh 是否开启水平滚动。 */
  6816. horizontal: boolean;
  6817. /** !#en Enable vertical scroll.
  6818. !#zh 是否开启垂直滚动。 */
  6819. vertical: boolean;
  6820. /** !#en When inertia is set, the content will continue to move when touch ended.
  6821. !#zh 是否开启滚动惯性。 */
  6822. inertia: boolean;
  6823. /** !#en
  6824. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  6825. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  6826. !#zh
  6827. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  6828. brake: number;
  6829. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  6830. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  6831. elastic: boolean;
  6832. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  6833. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  6834. bounceDuration: number;
  6835. /** !#en The horizontal scrollbar reference.
  6836. !#zh 水平滚动的 ScrollBar。 */
  6837. horizontalScrollBar: Scrollbar;
  6838. /** !#en The vertical scrollbar reference.
  6839. !#zh 垂直滚动的 ScrollBar。 */
  6840. verticalScrollBar: Scrollbar;
  6841. /** !#en Scrollview events callback
  6842. !#zh 滚动视图的事件回调函数 */
  6843. scrollEvents: Component.EventHandler[];
  6844. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  6845. It's set to true by default.
  6846. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  6847. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  6848. cancelInnerEvents: boolean;
  6849. /**
  6850. !#en Scroll the content to the bottom boundary of ScrollView.
  6851. !#zh 视图内容将在规定时间内滚动到视图底部。
  6852. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6853. the content will jump to the bottom boundary immediately.
  6854. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6855. @example
  6856. ```js
  6857. // Scroll to the bottom of the view.
  6858. scrollView.scrollToBottom(0.1);
  6859. ```
  6860. */
  6861. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  6862. /**
  6863. !#en Scroll the content to the top boundary of ScrollView.
  6864. !#zh 视图内容将在规定时间内滚动到视图顶部。
  6865. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6866. the content will jump to the top boundary immediately.
  6867. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6868. @example
  6869. ```js
  6870. // Scroll to the top of the view.
  6871. scrollView.scrollToTop(0.1);
  6872. ```
  6873. */
  6874. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  6875. /**
  6876. !#en Scroll the content to the left boundary of ScrollView.
  6877. !#zh 视图内容将在规定时间内滚动到视图左边。
  6878. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6879. the content will jump to the left boundary immediately.
  6880. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6881. @example
  6882. ```js
  6883. // Scroll to the left of the view.
  6884. scrollView.scrollToLeft(0.1);
  6885. ```
  6886. */
  6887. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  6888. /**
  6889. !#en Scroll the content to the right boundary of ScrollView.
  6890. !#zh 视图内容将在规定时间内滚动到视图右边。
  6891. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6892. the content will jump to the right boundary immediately.
  6893. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6894. @example
  6895. ```js
  6896. // Scroll to the right of the view.
  6897. scrollView.scrollToRight(0.1);
  6898. ```
  6899. */
  6900. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  6901. /**
  6902. !#en Scroll the content to the top left boundary of ScrollView.
  6903. !#zh 视图内容将在规定时间内滚动到视图左上角。
  6904. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6905. the content will jump to the top left boundary immediately.
  6906. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6907. @example
  6908. ```js
  6909. // Scroll to the upper left corner of the view.
  6910. scrollView.scrollToTopLeft(0.1);
  6911. ```
  6912. */
  6913. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  6914. /**
  6915. !#en Scroll the content to the top right boundary of ScrollView.
  6916. !#zh 视图内容将在规定时间内滚动到视图右上角。
  6917. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6918. the content will jump to the top right boundary immediately.
  6919. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6920. @example
  6921. ```js
  6922. // Scroll to the top right corner of the view.
  6923. scrollView.scrollToTopRight(0.1);
  6924. ```
  6925. */
  6926. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  6927. /**
  6928. !#en Scroll the content to the bottom left boundary of ScrollView.
  6929. !#zh 视图内容将在规定时间内滚动到视图左下角。
  6930. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6931. the content will jump to the bottom left boundary immediately.
  6932. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6933. @example
  6934. ```js
  6935. // Scroll to the lower left corner of the view.
  6936. scrollView.scrollToBottomLeft(0.1);
  6937. ```
  6938. */
  6939. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  6940. /**
  6941. !#en Scroll the content to the bottom right boundary of ScrollView.
  6942. !#zh 视图内容将在规定时间内滚动到视图右下角。
  6943. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6944. the content will jump to the bottom right boundary immediately.
  6945. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6946. @example
  6947. ```js
  6948. // Scroll to the lower right corner of the view.
  6949. scrollView.scrollToBottomRight(0.1);
  6950. ```
  6951. */
  6952. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  6953. /**
  6954. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  6955. specific offset immediately.
  6956. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  6957. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  6958. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6959. the content will jump to the specific offset of ScrollView immediately.
  6960. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6961. @example
  6962. ```js
  6963. // Scroll to middle position in 0.1 second in x-axis
  6964. var maxScrollOffset = this.getMaxScrollOffset();
  6965. scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1);
  6966. ```
  6967. */
  6968. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  6969. /**
  6970. !#en Get the positive offset value corresponds to the content's top left boundary.
  6971. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  6972. */
  6973. getScrollOffset(): Vec2;
  6974. /**
  6975. !#en Get the maximize available scroll offset
  6976. !#zh 获取滚动视图最大可以滚动的偏移量
  6977. */
  6978. getMaxScrollOffset(): Vec2;
  6979. /**
  6980. !#en Scroll the content to the horizontal percent position of ScrollView.
  6981. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  6982. @param percent A value between 0 and 1.
  6983. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6984. the content will jump to the horizontal percent position of ScrollView immediately.
  6985. @param attenuated Whether the scroll acceleration attenuated, default is true.
  6986. @example
  6987. ```js
  6988. // Scroll to middle position.
  6989. scrollView.scrollToBottomRight(0.5, 0.1);
  6990. ```
  6991. */
  6992. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  6993. /**
  6994. !#en Scroll the content to the percent position of ScrollView in any direction.
  6995. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  6996. @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1).
  6997. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  6998. the content will jump to the percent position of ScrollView immediately.
  6999. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7000. @example
  7001. ```js
  7002. // Vertical scroll to the bottom of the view.
  7003. scrollView.scrollTo(cc.p(0, 1), 0.1);
  7004. // Horizontal scroll to view right.
  7005. scrollView.scrollTo(cc.p(1, 0), 0.1);
  7006. ```
  7007. */
  7008. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7009. /**
  7010. !#en Scroll the content to the vertical percent position of ScrollView.
  7011. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7012. @param percent A value between 0 and 1.
  7013. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7014. the content will jump to the vertical percent position of ScrollView immediately.
  7015. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7016. // Scroll to middle position.
  7017. scrollView.scrollToPercentVertical(0.5, 0.1);
  7018. */
  7019. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7020. /**
  7021. !#en Stop auto scroll immediately
  7022. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7023. */
  7024. stopAutoScroll(): void;
  7025. /**
  7026. !#en Modify the content position.
  7027. !#zh 设置当前视图内容的坐标点。
  7028. @param position The position in content's parent space.
  7029. */
  7030. setContentPosition(position: Vec2): void;
  7031. /**
  7032. !#en Query the content's position in its parent space.
  7033. !#zh 获取当前视图内容的坐标点。
  7034. */
  7035. getContentPosition(): Position;
  7036. /**
  7037. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7038. !#zh 用户是否在拖拽当前滚动视图
  7039. */
  7040. isScrolling(): boolean;
  7041. /**
  7042. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7043. !#zh 当前滚动视图是否在惯性滚动
  7044. */
  7045. isAutoScrolling(): boolean;
  7046. }
  7047. /** !#en The Slider Control
  7048. !#zh 滑动器组件 */
  7049. export class Slider extends Component {
  7050. /** !#en The "handle" part of the slider
  7051. !#zh 滑动器滑块按钮部件 */
  7052. handle: Button;
  7053. /** !#en The slider direction
  7054. !#zh 滑动器方向 */
  7055. direction: Slider.Direction;
  7056. /** !#en The current progress of the slider. The valid value is between 0-1
  7057. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7058. progress: number;
  7059. /** !#en The slider events callback
  7060. !#zh 滑动器组件事件回调函数 */
  7061. slideEvents: Component.EventHandler[];
  7062. }
  7063. /** !#en Renders a sprite in the scene.
  7064. !#zh 该组件用于在场景中渲染精灵。 */
  7065. export class Sprite extends _RendererUnderSG {
  7066. /** !#en The sprite frame of the sprite.
  7067. !#zh 精灵的精灵帧 */
  7068. spriteFrame: SpriteFrame;
  7069. /** !#en The sprite render type.
  7070. !#zh 精灵渲染类型 */
  7071. type: Sprite.SpriteType;
  7072. /** !#en
  7073. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7074. !#zh
  7075. 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7076. fillType: Sprite.FillType;
  7077. /** !#en
  7078. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7079. !#zh
  7080. 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7081. fillCenter: Vec2;
  7082. /** !#en
  7083. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7084. !#zh
  7085. 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7086. fillStart: number;
  7087. /** !#en
  7088. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7089. !#zh
  7090. 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。 */
  7091. fillRange: number;
  7092. /** !#en specify the frame is trimmed or not.
  7093. !#zh 是否使用裁剪模式 */
  7094. trim: boolean;
  7095. /** !#en specify the source Blend Factor.
  7096. !#zh 指定原图的混合模式 */
  7097. srcBlendFactor: BlendFactor;
  7098. /** !#en specify the destination Blend Factor.
  7099. !#zh 指定目标的混合模式 */
  7100. dstBlendFactor: BlendFactor;
  7101. /** !#en specify the size tracing mode.
  7102. !#zh 精灵尺寸调整模式 */
  7103. sizeMode: Sprite.SizeMode;
  7104. /**
  7105. !#en Change the left sprite's cap inset.
  7106. !#zh 设置精灵左边框-用于九宫格。
  7107. @param insetLeft The values to use for the cap inset.
  7108. @example
  7109. ```js
  7110. sprite.setInsetLeft(5);
  7111. ```
  7112. */
  7113. setInsetLeft(insetLeft: number): void;
  7114. /**
  7115. !#en Query the left sprite's cap inset.
  7116. !#zh 获取精灵左边框
  7117. @example
  7118. ```js
  7119. var insetLeft = sprite.getInsetLeft();
  7120. cc.log("Inset Left:" + insetLeft);
  7121. ```
  7122. */
  7123. getInsetLeft(): number;
  7124. /**
  7125. !#en Change the top sprite's cap inset.
  7126. !#zh 设置精灵上边框-用于九宫格。
  7127. @param insetTop The values to use for the cap inset.
  7128. @example
  7129. ```js
  7130. sprite.setInsetTop(5);
  7131. ```
  7132. */
  7133. setInsetTop(insetTop: number): void;
  7134. /**
  7135. !#en Query the top sprite's cap inset.
  7136. !#zh 获取精灵上边框。
  7137. @example
  7138. ```js
  7139. var insetTop = sprite.getInsetTop();
  7140. cc.log("Inset Top:" + insetTop);
  7141. ```
  7142. */
  7143. getInsetTop(): number;
  7144. /**
  7145. !#en Change the right sprite's cap inset.
  7146. !#zh 设置精灵右边框-用于九宫格。
  7147. @param insetRight The values to use for the cap inset.
  7148. @example
  7149. ```js
  7150. sprite.setInsetRight(5);
  7151. ```
  7152. */
  7153. setInsetRight(insetRight: number): void;
  7154. /**
  7155. !#en Query the right sprite's cap inset.
  7156. !#zh 获取精灵右边框。
  7157. @example
  7158. ```js
  7159. var insetRight = sprite.getInsetRight();
  7160. cc.log("Inset Right:" + insetRight);
  7161. ```
  7162. */
  7163. getInsetRight(): number;
  7164. /**
  7165. !#en Change the bottom sprite's cap inset.
  7166. !#zh 设置精灵下边框-用于九宫格。
  7167. @param bottomInset The values to use for the cap inset.
  7168. @example
  7169. ```js
  7170. sprite.setInsetBottom(5);
  7171. ```
  7172. */
  7173. setInsetBottom(bottomInset: number): void;
  7174. /**
  7175. !#en Query the bottom sprite's cap inset.
  7176. !#zh 获取精灵下边框。
  7177. @example
  7178. ```js
  7179. var insetBottom = sprite.getInsetBottom();
  7180. cc.log("Inset Bottom:" + insetBottom);
  7181. ```
  7182. */
  7183. getInsetBottom(): number;
  7184. }
  7185. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  7186. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  7187. export class SpriteDistortion extends Component {
  7188. /** !#en Change the UV offset for distortion rendering.
  7189. !#zh 在渲染时改变UV的整体偏移. */
  7190. offset: Vec2;
  7191. /** !#en Change the UV scale for distortion rendering.
  7192. !#zh 在渲染时改变UV的寻址系数 */
  7193. tiling: Vec2;
  7194. }
  7195. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7196. could be treated as a RadioButton.
  7197. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7198. export class Toggle extends Button {
  7199. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7200. the check mark component will be disabled.
  7201. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7202. isChecked: boolean;
  7203. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7204. Otherwise, the toggle is a RadioButton.
  7205. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7206. 否则,Toggle 是一个 RadioButton。 */
  7207. toggleGroup: ToggleGroup;
  7208. /** !#en The image used for the checkmark.
  7209. !#zh Toggle 处于选中状态时显示的图片 */
  7210. checkMark: Sprite;
  7211. /** !#en If Toggle is clicked, it will trigger event's handler
  7212. !#zh Toggle 按钮的点击事件列表。 */
  7213. checkEvents: Component.EventHandler[];
  7214. /**
  7215. !#en Make the toggle button checked.
  7216. !#zh 使 toggle 按钮处于选中状态
  7217. */
  7218. check(): void;
  7219. /**
  7220. !#en Make the toggle button unchecked.
  7221. !#zh 使 toggle 按钮处于未选中状态
  7222. */
  7223. uncheck(): void;
  7224. }
  7225. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7226. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7227. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7228. 任何时候只能有一个 Toggle 处于选中状态。 */
  7229. export class ToggleGroup extends Component {
  7230. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7231. If it is false, it will make sure there is always only one toggle could be switched on
  7232. and the already switched on toggle can't be switched off.
  7233. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7234. allowSwitchOff: boolean;
  7235. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7236. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7237. toggleItems: any[];
  7238. }
  7239. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  7240. !#zh Video 组件,用于在游戏中播放视频 */
  7241. export class VideoPlayer extends _RendererUnderSG {
  7242. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  7243. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  7244. resourceType: VideoPlayer.ResourceType;
  7245. /** !#en The remote URL of video.
  7246. !#zh 远程视频的 URL */
  7247. remoteURL: string;
  7248. /** !#en The local video full path.
  7249. !#zh 本地视频的 URL */
  7250. clip: string;
  7251. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  7252. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  7253. currentTime: number;
  7254. /** !#en Whether keep the aspect ration of the original video.
  7255. !#zh 是否保持视频原来的宽高比 */
  7256. keepAspectRatio: boolean;
  7257. /** !#en Whether play video in fullscreen mode.
  7258. !#zh 是否全屏播放视频 */
  7259. isFullscreen: boolean;
  7260. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  7261. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  7262. videoPlayerEvent: Component.EventHandler[];
  7263. /**
  7264. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  7265. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  7266. */
  7267. play(): void;
  7268. /**
  7269. !#en If a video is paused, call this method to resume playing.
  7270. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  7271. */
  7272. resume(): void;
  7273. /**
  7274. !#en If a video is playing, call this method to pause playing.
  7275. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  7276. */
  7277. pause(): void;
  7278. /**
  7279. !#en If a video is playing, call this method to stop playing immediately.
  7280. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  7281. */
  7282. stop(): void;
  7283. /**
  7284. !#en Gets the duration of the video
  7285. !#zh 获取视频文件的播放总时长
  7286. */
  7287. getDuration(): number;
  7288. /**
  7289. !#en Determine whether video is playing or not.
  7290. !#zh 判断当前视频是否处于播放状态
  7291. */
  7292. isPlaying(): boolean;
  7293. /**
  7294. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  7295. call the destroy method on this component or the associated node explicitly.
  7296. Otherwise, the created DOM element won't be removed from web page.
  7297. !#zh
  7298. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7299. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7300. @example
  7301. ```js
  7302. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  7303. // when you don't need videoplayer anymore
  7304. videoplayer.node.destroy();
  7305. ```
  7306. */
  7307. destroy(): boolean;
  7308. }
  7309. /** !#en
  7310. Handling touch events in a ViewGroup takes special care,
  7311. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7312. To make sure that each view correctly receives the touch events intended for it,
  7313. ViewGroup should register capture phase event and handle the event propagation properly.
  7314. Please refer to Scrollview for more information.
  7315. !#zh
  7316. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7317. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7318. 请参考 ScrollView 的实现来获取更多信息。 */
  7319. export class ViewGroup extends Component {
  7320. }
  7321. /** !#en cc.WebView is a component for display web pages in the game
  7322. !#zh WebView 组件,用于在游戏中显示网页 */
  7323. export class WebView extends _RendererUnderSG {
  7324. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  7325. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  7326. url: string;
  7327. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  7328. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  7329. webviewLoadedEvents: Component.EventHandler[];
  7330. /**
  7331. !#en
  7332. Set javascript interface scheme (see also setOnJSCallback). <br/>
  7333. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7334. Please refer to the official documentation for more details.
  7335. !#zh
  7336. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  7337. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  7338. 详情请参阅官方文档
  7339. @param scheme scheme
  7340. */
  7341. setJavascriptInterfaceScheme(scheme: string): void;
  7342. /**
  7343. !#en
  7344. This callback called when load URL that start with javascript
  7345. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  7346. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7347. Please refer to the official documentation for more details.
  7348. !#zh
  7349. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  7350. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  7351. 详情请参阅官方文档
  7352. @param callback callback
  7353. */
  7354. setOnJSCallback(callback: Function): void;
  7355. /**
  7356. !#en
  7357. Evaluates JavaScript in the context of the currently displayed page. <br/>
  7358. Please refer to the official document for more details <br/>
  7359. Note: Cross domain issues need to be resolved by yourself <br/>
  7360. !#zh
  7361. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  7362. 注意:需要自行解决跨域问题
  7363. @param str str
  7364. */
  7365. evaluateJS(str: string): void;
  7366. /**
  7367. !#en if you don't need the WebView and it isn't in any running Scene, you should
  7368. call the destroy method on this component or the associated node explicitly.
  7369. Otherwise, the created DOM element won't be removed from web page.
  7370. !#zh
  7371. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7372. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7373. @example
  7374. ```js
  7375. webview.node.parent = null; // or webview.node.removeFromParent(false);
  7376. // when you don't need webview anymore
  7377. webview.node.destroy();
  7378. ```
  7379. */
  7380. destroy(): void;
  7381. }
  7382. /** !#en
  7383. Stores and manipulate the anchoring based on its parent.
  7384. Widget are used for GUI but can also be used for other things.
  7385. 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.
  7386. !#zh
  7387. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7388. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7389. export class Widget extends Component {
  7390. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7391. The default value is null, and when null, indicates the current parent.
  7392. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7393. target: Node;
  7394. /** !#en Whether to align the top.
  7395. !#zh 是否对齐上边。 */
  7396. isAlignTop: boolean;
  7397. /** !#en
  7398. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7399. !#zh
  7400. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7401. isAlignVerticalCenter: boolean;
  7402. /** !#en Whether to align the bottom.
  7403. !#zh 是否对齐下边。 */
  7404. isAlignBottom: boolean;
  7405. /** !#en Whether to align the left.
  7406. !#zh 是否对齐左边 */
  7407. isAlignLeft: boolean;
  7408. /** !#en
  7409. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7410. !#zh
  7411. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7412. isAlignHorizontalCenter: boolean;
  7413. /** !#en Whether to align the right.
  7414. !#zh 是否对齐右边。 */
  7415. isAlignRight: boolean;
  7416. /** !#en
  7417. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7418. the width setting is invalid (read only).
  7419. !#zh
  7420. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7421. isStretchWidth: boolean;
  7422. /** !#en
  7423. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7424. then height setting is invalid (read only)
  7425. !#zh
  7426. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7427. isStretchHeight: boolean;
  7428. /** !#en
  7429. The margins between the top of this node and the top of parent node,
  7430. the value can be negative, Only available in 'isAlignTop' open.
  7431. !#zh
  7432. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7433. top: number;
  7434. /** !#en
  7435. The margins between the bottom of this node and the bottom of parent node,
  7436. the value can be negative, Only available in 'isAlignBottom' open.
  7437. !#zh
  7438. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7439. bottom: number;
  7440. /** !#en
  7441. The margins between the left of this node and the left of parent node,
  7442. the value can be negative, Only available in 'isAlignLeft' open.
  7443. !#zh
  7444. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7445. left: number;
  7446. /** !#en
  7447. The margins between the right of this node and the right of parent node,
  7448. the value can be negative, Only available in 'isAlignRight' open.
  7449. !#zh
  7450. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7451. right: number;
  7452. /** !#en
  7453. Horizontal aligns the midpoint offset value,
  7454. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7455. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7456. horizontalCenter: number;
  7457. /** !#en
  7458. Vertical aligns the midpoint offset value,
  7459. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7460. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7461. verticalCenter: number;
  7462. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7463. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7464. isAbsoluteHorizontalCenter: boolean;
  7465. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7466. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7467. isAbsoluteVerticalCenter: boolean;
  7468. /** !#en
  7469. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7470. !#zh
  7471. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7472. isAbsoluteTop: boolean;
  7473. /** !#en
  7474. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7475. !#zh
  7476. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7477. isAbsoluteBottom: boolean;
  7478. /** !#en
  7479. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7480. !#zh
  7481. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7482. isAbsoluteLeft: boolean;
  7483. /** !#en
  7484. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7485. !#zh
  7486. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7487. isAbsoluteRight: boolean;
  7488. /** !#en TODO
  7489. !#zh
  7490. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7491. 这样便于脚本或动画继续控制当前节点。
  7492. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7493. isAlignOnce: boolean;
  7494. /**
  7495. !#en
  7496. Immediately perform the widget alignment. You need to manually call this method only if
  7497. you need to get the latest results after the alignment before the end of current frame.
  7498. !#zh
  7499. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7500. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7501. @example
  7502. ```js
  7503. widget.top = 10; // change top margin
  7504. cc.log(widget.node.y); // not yet changed
  7505. widget.updateAlignment();
  7506. cc.log(widget.node.y); // changed
  7507. ```
  7508. */
  7509. updateAlignment(): void;
  7510. }
  7511. /** !#en
  7512. EventTarget is an object to which an event is dispatched when something has occurred.
  7513. Entity are the most common event targets, but other objects can be event targets too.
  7514. Event targets are an important part of the Fireball event model.
  7515. The event target serves as the focal point for how events flow through the scene graph.
  7516. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7517. into the event flow from the root of the hierarchy. The event object then makes its way through
  7518. the scene graph until it reaches the event target, at which point it begins its return trip through
  7519. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7520. - The capture phase comprises the journey from the root to the last node before the event target's node
  7521. - The target phase comprises only the event target node
  7522. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7523. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7524. Event targets can implement the following methods:
  7525. - _getCapturingTargets
  7526. - _getBubblingTargets
  7527. !#zh
  7528. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7529. 但是其他对象也可以是事件目标。<br/> */
  7530. export class EventTarget {
  7531. /**
  7532. !#en
  7533. Register an callback of a specific event type on the EventTarget.
  7534. !#zh
  7535. 注册事件目标的特定事件类型回调。
  7536. @param type A string representing the event type to listen for.
  7537. @param callback The callback that will be invoked when the event is dispatched.
  7538. The callback is ignored if it is a duplicate (the callbacks are unique).
  7539. @param target The target (this object) to invoke the callback, can be null
  7540. @param useCapture When set to true, the capture argument prevents callback
  7541. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7542. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7543. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7544. @example
  7545. ```js
  7546. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7547. cc.log("this is callback");
  7548. }, node);
  7549. ```
  7550. */
  7551. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7552. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7553. /**
  7554. !#en
  7555. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7556. if only type is passed as parameter, all listeners registered with that type will be removed.
  7557. !#zh
  7558. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7559. @param type A string representing the event type being removed.
  7560. @param callback The callback to remove.
  7561. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7562. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7563. If not specified, useCapture defaults to false. If a callback was registered twice,
  7564. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7565. does not affect a non-capturing version of the same listener, and vice versa.
  7566. @example
  7567. ```js
  7568. // register touchEnd eventListener
  7569. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7570. cc.log("this is callback");
  7571. }, node);
  7572. // remove touch end event listener
  7573. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7574. // remove all touch end event listeners
  7575. node.off(cc.Node.EventType.TOUCH_END);
  7576. ```
  7577. */
  7578. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7579. /**
  7580. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7581. This is not for removing all listeners in the current event target,
  7582. and this is not for removing all listeners the target parameter have registered.
  7583. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7584. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7585. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7586. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7587. @param target The target to be searched for all related listeners
  7588. */
  7589. targetOff(target: any): void;
  7590. /**
  7591. !#en
  7592. Register an callback of a specific event type on the EventTarget,
  7593. the callback will remove itself after the first time it is triggered.
  7594. !#zh
  7595. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7596. @param type A string representing the event type to listen for.
  7597. @param callback The callback that will be invoked when the event is dispatched.
  7598. The callback is ignored if it is a duplicate (the callbacks are unique).
  7599. @param target The target (this object) to invoke the callback, can be null
  7600. @param useCapture When set to true, the capture argument prevents callback
  7601. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7602. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7603. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7604. @example
  7605. ```js
  7606. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7607. cc.log("this is callback");
  7608. }, node);
  7609. ```
  7610. */
  7611. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7612. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7613. /**
  7614. !#en
  7615. Dispatches an event into the event flow.
  7616. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7617. !#zh 分发事件到事件流中。
  7618. @param event The Event object that is dispatched into the event flow
  7619. */
  7620. dispatchEvent(event: Event): void;
  7621. /**
  7622. !#en
  7623. Send an event to this object directly, this method will not propagate the event to any other objects.
  7624. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  7625. !#zh
  7626. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  7627. @param message the message to send
  7628. @param detail whatever argument the message needs
  7629. */
  7630. emit(message: string, detail?: any): void;
  7631. }
  7632. /** !#en Base class of all kinds of events.
  7633. !#zh 包含事件相关信息的对象。 */
  7634. export class Event {
  7635. /**
  7636. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  7637. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  7638. */
  7639. constructor(type: string, bubbles: boolean);
  7640. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  7641. !#zh 事件类型。 */
  7642. type: string;
  7643. /** !#en Indicate whether the event bubbles up through the tree or not.
  7644. !#zh 表示该事件是否进行冒泡。 */
  7645. bubbles: boolean;
  7646. /** !#en A reference to the target to which the event was originally dispatched.
  7647. !#zh 最初事件触发的目标 */
  7648. target: any;
  7649. /** !#en A reference to the currently registered target for the event.
  7650. !#zh 当前目标 */
  7651. currentTarget: any;
  7652. /** !#en
  7653. Indicates which phase of the event flow is currently being evaluated.
  7654. Returns an integer value represented by 4 constants:
  7655. - Event.NONE = 0
  7656. - Event.CAPTURING_PHASE = 1
  7657. - Event.AT_TARGET = 2
  7658. - Event.BUBBLING_PHASE = 3
  7659. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  7660. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  7661. !#zh 事件阶段 */
  7662. eventPhase: number;
  7663. /**
  7664. !#en Reset the event for being stored in the object pool.
  7665. !#zh 重置对象池中存储的事件。
  7666. */
  7667. unuse(): string;
  7668. /**
  7669. !#en Reuse the event for being used again by the object pool.
  7670. !#zh 用于对象池再次使用的事件。
  7671. */
  7672. reuse(): string;
  7673. /**
  7674. !#en Stops propagation for current event.
  7675. !#zh 停止传递当前事件。
  7676. */
  7677. stopPropagation(): void;
  7678. /**
  7679. !#en Stops propagation for current event immediately,
  7680. the event won't even be dispatched to the listeners attached in the current target.
  7681. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  7682. */
  7683. stopPropagationImmediate(): void;
  7684. /**
  7685. !#en Checks whether the event has been stopped.
  7686. !#zh 检查该事件是否已经停止传递.
  7687. */
  7688. isStopped(): boolean;
  7689. /**
  7690. !#en
  7691. <p>
  7692. Gets current target of the event <br/>
  7693. note: It only be available when the event listener is associated with node. <br/>
  7694. It returns 0 when the listener is associated with fixed priority.
  7695. </p>
  7696. !#zh 获取当前目标节点
  7697. */
  7698. getCurrentTarget(): Node;
  7699. /**
  7700. !#en Gets the event type.
  7701. !#zh 获取事件类型
  7702. */
  7703. getType(): string;
  7704. /** !#en Code for event without type.
  7705. !#zh 没有类型的事件 */
  7706. static NO_TYPE: string;
  7707. /** !#en The type code of Touch event.
  7708. !#zh 触摸事件类型 */
  7709. static TOUCH: string;
  7710. /** !#en The type code of Mouse event.
  7711. !#zh 鼠标事件类型 */
  7712. static MOUSE: string;
  7713. /** !#en The type code of Keyboard event.
  7714. !#zh 键盘事件类型 */
  7715. static KEYBOARD: string;
  7716. /** !#en The type code of Acceleration event.
  7717. !#zh 加速器事件类型 */
  7718. static ACCELERATION: string;
  7719. /** !#en Events not currently dispatched are in this phase
  7720. !#zh 尚未派发事件阶段 */
  7721. static NONE: number;
  7722. /** !#en
  7723. The capturing phase comprises the journey from the root to the last node before the event target's node
  7724. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7725. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  7726. static CAPTURING_PHASE: number;
  7727. /** !#en
  7728. The target phase comprises only the event target node
  7729. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7730. !#zh 目标阶段仅包括事件目标节点。 */
  7731. static AT_TARGET: number;
  7732. /** !#en
  7733. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  7734. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7735. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  7736. static BUBBLING_PHASE: number;
  7737. }
  7738. /** !#en
  7739. <p>
  7740. The base class of event listener. <br/>
  7741. If you need custom listener which with different callback, you need to inherit this class. <br/>
  7742. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  7743. EventListenerTouchOneByOne, EventListenerCustom.
  7744. </p>
  7745. !#zh
  7746. 封装用户的事件处理逻辑。
  7747. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  7748. export class EventListener {
  7749. /**
  7750. Constructor
  7751. @param type type
  7752. @param listenerID listenerID
  7753. @param callback callback
  7754. */
  7755. constructor(type: number, listenerID: number, callback: number);
  7756. /**
  7757. !#en Checks whether the listener is available.
  7758. !#zh 检测监听器是否有效
  7759. */
  7760. checkAvailable(): boolean;
  7761. /**
  7762. !#en Clones the listener, its subclasses have to override this method.
  7763. !#zh 克隆监听器,它的子类必须重写此方法。
  7764. */
  7765. clone(): EventListener;
  7766. /**
  7767. !#en Enables or disables the listener
  7768. !#zh 启用或禁用监听器。
  7769. @param enabled enabled
  7770. */
  7771. setEnabled(enabled: boolean): void;
  7772. /**
  7773. !#en Checks whether the listener is enabled
  7774. !#zh 检查监听器是否可用。
  7775. */
  7776. isEnabled(): boolean;
  7777. /** !#en The type code of unknown event listener.
  7778. !#zh 未知的事件监听器类型 */
  7779. static UNKNOWN: number;
  7780. /** !#en The type code of keyboard event listener.
  7781. !#zh 键盘事件监听器类型 */
  7782. static KEYBOARD: number;
  7783. /** !#en The type code of acceleration event listener.
  7784. !#zh 加速器事件监听器类型 */
  7785. static ACCELERATION: number;
  7786. /**
  7787. !#en
  7788. Create a EventListener object with configuration including the event type, handlers and other parameters.
  7789. In handlers, this refer to the event listener object itself.
  7790. You can also pass custom parameters in the configuration object,
  7791. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  7792. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  7793. @param argObj a json object
  7794. @example
  7795. ```js
  7796. // Create KEYBOARD EventListener.
  7797. cc.EventListener.create({
  7798. event: cc.EventListener.KEYBOARD,
  7799. onKeyPressed: function (keyCode, event) {
  7800. cc.log('pressed key: ' + keyCode);
  7801. },
  7802. onKeyReleased: function (keyCode, event) {
  7803. cc.log('released key: ' + keyCode);
  7804. }
  7805. });
  7806. // Create ACCELERATION EventListener.
  7807. cc.EventListener.create({
  7808. event: cc.EventListener.ACCELERATION,
  7809. callback: function (acc, event) {
  7810. cc.log('acc: ' + keyCode);
  7811. }
  7812. });
  7813. ```
  7814. */
  7815. static create(argObj: any): EventListener;
  7816. }
  7817. /** !#en
  7818. <p>
  7819. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. <br/>
  7820. <br/>
  7821. The EventListener list is managed in such way so that event listeners can be added and removed <br/>
  7822. while events are being dispatched.
  7823. </p>
  7824. !#zh
  7825. 事件管理器,它主要管理事件监听器注册和派发系统事件。
  7826. 原始设计中,它支持鼠标,触摸,键盘,陀螺仪和自定义事件。
  7827. 在 Creator 的设计中,鼠标,触摸和自定义事件的监听和派发请参考 http://cocos.com/docs/creator/scripting/events.html。 */
  7828. export class eventManager {
  7829. /**
  7830. !#en Pauses all listeners which are associated the specified target.
  7831. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  7832. @param node node
  7833. @param recursive recursive
  7834. */
  7835. static pauseTarget(node: Node, recursive?: boolean): void;
  7836. /**
  7837. !#en Resumes all listeners which are associated the specified target.
  7838. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  7839. @param node node
  7840. @param recursive recursive
  7841. */
  7842. static resumeTarget(node: Node, recursive?: boolean): void;
  7843. /**
  7844. !#en Query whether the specified event listener id has been added.
  7845. !#zh 查询指定的事件 ID 是否存在
  7846. @param listenerID The listener id.
  7847. */
  7848. static hasEventListener(listenerID: string|number): boolean;
  7849. /**
  7850. !#en
  7851. <p>
  7852. Adds a event listener for a specified event.<br/>
  7853. if the parameter "nodeOrPriority" is a node,
  7854. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  7855. if the parameter "nodeOrPriority" is a Number,
  7856. it means to add a event listener for a specified event with the fixed priority.<br/>
  7857. </p>
  7858. !#zh
  7859. 将事件监听器添加到事件管理器中。<br/>
  7860. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  7861. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  7862. @param listener The listener of a specified event or a object of some event parameters.
  7863. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  7864. */
  7865. static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener;
  7866. /**
  7867. !#en Remove a listener.
  7868. !#zh 移除一个已添加的监听器。
  7869. @param listener an event listener or a registered node target
  7870. @example
  7871. ```js
  7872. // 1. remove eventManager add Listener;
  7873. var mouseListener1 = cc.eventManager.addListener({
  7874. event: cc.EventListener.MOUSE,
  7875. onMouseDown: function(keyCode, event){ },
  7876. onMouseUp: function(keyCode, event){ },
  7877. onMouseMove: function () { },
  7878. onMouseScroll: function () { }
  7879. }, node);
  7880. cc.eventManager.removeListener(mouseListener1);
  7881. // 2. remove eventListener create Listener;
  7882. var mouseListener2 = cc.EventListener.create({
  7883. event: cc.EventListener.MOUSE,
  7884. onMouseDown: function(keyCode, event){ },
  7885. onMouseUp: function(keyCode, event){ },
  7886. onMouseMove: function () { },
  7887. onMouseScroll: function () { }
  7888. });
  7889. cc.eventManager.removeListener(mouseListener2);
  7890. ```
  7891. */
  7892. static removeListener(listener: EventListener): void;
  7893. /**
  7894. !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  7895. !#zh
  7896. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  7897. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  7898. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  7899. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  7900. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  7901. 下列是目前存在监听器类型: <br/>
  7902. cc.EventListener.UNKNOWN <br/>
  7903. cc.EventListener.KEYBOARD <br/>
  7904. cc.EventListener.ACCELERATION,<br/>
  7905. @param listenerType listenerType or a node
  7906. @param recursive recursive
  7907. */
  7908. static removeListeners(listenerType: number|Node, recursive?: boolean): void;
  7909. /**
  7910. !#en Removes all listeners
  7911. !#zh 移除所有事件监听器。
  7912. */
  7913. static removeAllListeners(): void;
  7914. /**
  7915. !#en Sets listener's priority with fixed value.
  7916. !#zh 设置 FixedPriority 类型监听器的优先级。
  7917. @param listener listener
  7918. @param fixedPriority fixedPriority
  7919. */
  7920. static setPriority(listener: EventListener, fixedPriority: number): void;
  7921. /**
  7922. !#en Whether to enable dispatching events
  7923. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  7924. @param enabled enabled
  7925. */
  7926. static setEnabled(enabled: boolean): void;
  7927. /**
  7928. !#en Checks whether dispatching events is enabled
  7929. !#zh 检测事件管理器是否启用。
  7930. */
  7931. static isEnabled(): boolean;
  7932. }
  7933. /** !#en The touch event class
  7934. !#zh 封装了触摸相关的信息。 */
  7935. export class Touch {
  7936. /**
  7937. !#en Returns the current touch location in OpenGL coordinates.、
  7938. !#zh 获取当前触点位置。
  7939. */
  7940. getLocation(): Vec2;
  7941. /**
  7942. !#en Returns X axis location value.
  7943. !#zh 获取当前触点 X 轴位置。
  7944. */
  7945. getLocationX(): number;
  7946. /**
  7947. !#en Returns Y axis location value.
  7948. !#zh 获取当前触点 Y 轴位置。
  7949. */
  7950. getLocationY(): number;
  7951. /**
  7952. !#en Returns the previous touch location in OpenGL coordinates.
  7953. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  7954. */
  7955. getPreviousLocation(): Vec2;
  7956. /**
  7957. !#en Returns the start touch location in OpenGL coordinates.
  7958. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  7959. */
  7960. getStartLocation(): Vec2;
  7961. /**
  7962. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  7963. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  7964. */
  7965. getDelta(): Vec2;
  7966. /**
  7967. !#en Returns the current touch location in screen coordinates.
  7968. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  7969. */
  7970. getLocationInView(): Vec2;
  7971. /**
  7972. !#en Returns the previous touch location in screen coordinates.
  7973. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  7974. */
  7975. getPreviousLocationInView(): Vec2;
  7976. /**
  7977. !#en Returns the start touch location in screen coordinates.
  7978. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  7979. */
  7980. getStartLocationInView(): Vec2;
  7981. /**
  7982. !#en Returns the id of cc.Touch.
  7983. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  7984. */
  7985. getID(): number;
  7986. /**
  7987. !#en Sets information to touch.
  7988. !#zh 设置触摸相关的信息。用于监控触摸事件。
  7989. @param id id
  7990. @param x x
  7991. @param y y
  7992. */
  7993. setTouchInfo(id: number, x: number, y: number): void;
  7994. }
  7995. /** !#en The System event, it currently supports the key events and accelerometer events
  7996. !#zh 系统事件,它目前支持按键事件和重力感应事件 */
  7997. export class SystemEvent extends EventTarget {
  7998. }
  7999. /** undefined */
  8000. export class Graphics extends _RendererUnderSG {
  8001. /** !#en
  8002. Current line width.
  8003. !#zh
  8004. 当前线条宽度 */
  8005. lineWidth: number;
  8006. /** !#en
  8007. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  8008. !#zh
  8009. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  8010. lineJoin: Graphics.LineJoin;
  8011. /** !#en
  8012. lineCap determines how the end points of every line are drawn.
  8013. !#zh
  8014. lineCap 指定如何绘制每一条线段末端。 */
  8015. lineCap: Graphics.LineCap;
  8016. /** !#en
  8017. stroke color
  8018. !#zh
  8019. 线段颜色 */
  8020. strokeColor: Color;
  8021. /** !#en
  8022. fill color
  8023. !#zh
  8024. 填充颜色 */
  8025. fillColor: Color;
  8026. /** !#en
  8027. Sets the miter limit ratio
  8028. !#zh
  8029. 设置斜接面限制比例 */
  8030. miterLimit: number;
  8031. /**
  8032. !#en Move path start point to (x,y).
  8033. !#zh 移动路径起点到坐标(x, y)
  8034. @param x The x axis of the coordinate for the end point.
  8035. @param y The y axis of the coordinate for the end point.
  8036. */
  8037. moveTo(x?: number, y?: number): void;
  8038. /**
  8039. !#en Adds a straight line to the path
  8040. !#zh 绘制直线路径
  8041. @param x The x axis of the coordinate for the end point.
  8042. @param y The y axis of the coordinate for the end point.
  8043. */
  8044. lineTo(x?: number, y?: number): void;
  8045. /**
  8046. !#en Adds a cubic Bézier curve to the path
  8047. !#zh 绘制三次贝赛尔曲线路径
  8048. @param c1x The x axis of the coordinate for the first control point.
  8049. @param c1y The y axis of the coordinate for first control point.
  8050. @param c2x The x axis of the coordinate for the second control point.
  8051. @param c2y The y axis of the coordinate for the second control point.
  8052. @param x The x axis of the coordinate for the end point.
  8053. @param y The y axis of the coordinate for the end point.
  8054. */
  8055. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  8056. /**
  8057. !#en Adds a quadratic Bézier curve to the path
  8058. !#zh 绘制二次贝赛尔曲线路径
  8059. @param cx The x axis of the coordinate for the control point.
  8060. @param cy The y axis of the coordinate for the control point.
  8061. @param x The x axis of the coordinate for the end point.
  8062. @param y The y axis of the coordinate for the end point.
  8063. */
  8064. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  8065. /**
  8066. !#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).
  8067. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  8068. @param cx The x axis of the coordinate for the center point.
  8069. @param cy The y axis of the coordinate for the center point.
  8070. @param r The arc's radius.
  8071. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  8072. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  8073. @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.
  8074. */
  8075. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: number): void;
  8076. /**
  8077. !#en Adds an ellipse to the path.
  8078. !#zh 绘制椭圆路径。
  8079. @param cx The x axis of the coordinate for the center point.
  8080. @param cy The y axis of the coordinate for the center point.
  8081. @param rx The ellipse's x-axis radius.
  8082. @param ry The ellipse's y-axis radius.
  8083. */
  8084. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  8085. /**
  8086. !#en Adds an circle to the path.
  8087. !#zh 绘制圆形路径。
  8088. @param cx The x axis of the coordinate for the center point.
  8089. @param cy The y axis of the coordinate for the center point.
  8090. @param r The circle's radius.
  8091. */
  8092. circle(cx?: number, cy?: number, r?: number): void;
  8093. /**
  8094. !#en Adds an rectangle to the path.
  8095. !#zh 绘制矩形路径。
  8096. @param x The x axis of the coordinate for the rectangle starting point.
  8097. @param y The y axis of the coordinate for the rectangle starting point.
  8098. @param w The rectangle's width.
  8099. @param h The rectangle's height.
  8100. */
  8101. rect(x?: number, y?: number, w?: number, h?: number): void;
  8102. /**
  8103. !#en Adds an round corner rectangle to the path.
  8104. !#zh 绘制圆角矩形路径。
  8105. @param x The x axis of the coordinate for the rectangle starting point.
  8106. @param y The y axis of the coordinate for the rectangle starting point.
  8107. @param w The rectangles width.
  8108. @param h The rectangle's height.
  8109. @param r The radius of the rectangle.
  8110. */
  8111. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  8112. /**
  8113. !#en Draws a filled rectangle.
  8114. !#zh 绘制填充矩形。
  8115. @param x The x axis of the coordinate for the rectangle starting point.
  8116. @param y The y axis of the coordinate for the rectangle starting point.
  8117. @param w The rectangle's width.
  8118. @param h The rectangle's height.
  8119. */
  8120. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  8121. /**
  8122. !#en Erasing any previously drawn content.
  8123. !#zh 擦除之前绘制的所有内容的方法。
  8124. @param clean Whether to clean the graphics inner cache.
  8125. */
  8126. clear(clean?: boolean): void;
  8127. /**
  8128. !#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.
  8129. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  8130. */
  8131. close(): void;
  8132. /**
  8133. !#en Strokes the current or given path with the current stroke style.
  8134. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  8135. */
  8136. stroke(): void;
  8137. /**
  8138. !#en Fills the current or given path with the current fill style.
  8139. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  8140. */
  8141. fill(): void;
  8142. }
  8143. /** Loader for resource loading process. It's a singleton object. */
  8144. export class loader extends Pipeline {
  8145. /** The asset loader in cc.loader's pipeline, it's by default the first pipe.
  8146. It's used to identify an asset's type, and determine how to download it. */
  8147. static assetLoader: any;
  8148. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  8149. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  8150. You can add your own download function with addDownloadHandlers */
  8151. static downloader: any;
  8152. /** The downloader in cc.loader's pipeline, it's by default the third pipe.
  8153. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  8154. You can add your own download function with addLoadHandlers */
  8155. static loader: any;
  8156. /**
  8157. Gets a new XMLHttpRequest instance.
  8158. */
  8159. static getXMLHttpRequest(): XMLHttpRequest;
  8160. /**
  8161. Add custom supported types handler or modify existing type handler for download process.
  8162. @param extMap Custom supported types with corresponded handler
  8163. @example
  8164. ```js
  8165. cc.loader.addDownloadHandlers({
  8166. // This will match all url with `.scene` extension or all url with `scene` type
  8167. 'scene' : function (url, callback) {}
  8168. });
  8169. ```
  8170. */
  8171. static addDownloadHandlers(extMap: any): void;
  8172. /**
  8173. Add custom supported types handler or modify existing type handler for load process.
  8174. @param extMap Custom supported types with corresponded handler
  8175. @example
  8176. ```js
  8177. cc.loader.addLoadHandlers({
  8178. // This will match all url with `.scene` extension or all url with `scene` type
  8179. 'scene' : function (url, callback) {}
  8180. });
  8181. ```
  8182. */
  8183. static addLoadHandlers(extMap: any): void;
  8184. /**
  8185. Load resources with a progression callback and a complete callback.
  8186. The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}}
  8187. The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}}
  8188. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  8189. @param resources Url list in an array
  8190. @param progressCallback Callback invoked when progression change
  8191. @param completeCallback Callback invoked when all resources loaded
  8192. @example
  8193. ```js
  8194. cc.loader.load('a.png', function (err, tex) {
  8195. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  8196. });
  8197. cc.loader.load('http://example.com/a.png', function (err, tex) {
  8198. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  8199. });
  8200. cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  8201. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  8202. });
  8203. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  8204. if (errors) {
  8205. for (var i = 0; i < errors.length; i++) {
  8206. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  8207. }
  8208. }
  8209. var aTex = results.getContent('a.png');
  8210. var bJsonObj = results.getContent('b.json');
  8211. });
  8212. ```
  8213. */
  8214. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  8215. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  8216. /**
  8217. Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  8218. <br>
  8219. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8220. @param url Url of the target resource.
  8221. The url is relative to the "resources" folder, extensions must be omitted.
  8222. @param type Only asset of type will be loaded if this argument is supplied.
  8223. @param progressCallback Callback invoked when progression change.
  8224. @param completeCallback Callback invoked when the resource loaded.
  8225. @example
  8226. ```js
  8227. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  8228. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  8229. if (err) {
  8230. cc.error(err.message || err);
  8231. return;
  8232. }
  8233. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  8234. });
  8235. // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder
  8236. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  8237. if (err) {
  8238. cc.error(err.message || err);
  8239. return;
  8240. }
  8241. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  8242. });
  8243. ```
  8244. */
  8245. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8246. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  8247. static loadRes(url: string, type: typeof cc.Asset): void;
  8248. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8249. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  8250. static loadRes(url: string): void;
  8251. /**
  8252. This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url.
  8253. @param urls Array of URLs of the target resource.
  8254. The url is relative to the "resources" folder, extensions must be omitted.
  8255. @param type Only asset of type will be loaded if this argument is supplied.
  8256. @param progressCallback Callback invoked when progression change.
  8257. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8258. @example
  8259. ```js
  8260. // load the SpriteFrames from resources folder
  8261. var spriteFrames;
  8262. var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01'];
  8263. cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) {
  8264. if (err) {
  8265. cc.error(err);
  8266. return;
  8267. }
  8268. spriteFrames = assets;
  8269. // ...
  8270. });
  8271. ```
  8272. */
  8273. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8274. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  8275. static loadResArray(url: string[], type: typeof cc.Asset): void;
  8276. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8277. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  8278. static loadResArray(url: string[]): void;
  8279. /**
  8280. Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  8281. <br>
  8282. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8283. @param url Url of the target folder.
  8284. The url is relative to the "resources" folder, extensions must be omitted.
  8285. @param type Only asset of type will be loaded if this argument is supplied.
  8286. @param progressCallback Callback invoked when progression change.
  8287. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8288. @example
  8289. ```js
  8290. // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame
  8291. cc.loader.loadResDir('imgs/cocos', function (err, assets) {
  8292. if (err) {
  8293. cc.error(err);
  8294. return;
  8295. }
  8296. var texture = assets[0];
  8297. var spriteFrame = assets[1];
  8298. });
  8299. // load all textures in "resources/imgs/"
  8300. cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) {
  8301. var texture1 = textures[0];
  8302. var texture2 = textures[1];
  8303. });
  8304. // load all JSONs in "resources/data/"
  8305. cc.loader.loadResDir('data', function (err, objects, urls) {
  8306. var data = objects[0];
  8307. var url = urls[0];
  8308. });
  8309. ```
  8310. */
  8311. 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;
  8312. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8313. static loadResDir(url: string, type: typeof cc.Asset): void;
  8314. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8315. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8316. static loadResDir(url: string): void;
  8317. /**
  8318. Get resource data by id. <br>
  8319. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  8320. the url will be the unique identity of the resource.
  8321. After loaded, you can acquire them by passing the url to this API.
  8322. @param url url
  8323. @param type Only asset of type will be returned if this argument is supplied.
  8324. */
  8325. static getRes(url: string, type?: Function): any;
  8326. /**
  8327. !#en Get all resource dependencies of the requested asset in an array, including itself.
  8328. The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.<br>
  8329. The returned array stores the dependencies with their uuids, after retrieve dependencies,
  8330. you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.<br>
  8331. For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}}
  8332. Here is some examples:
  8333. !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。<br>
  8334. 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。<br>
  8335. 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码:
  8336. @param owner The owner asset or the resource url or the asset's uuid
  8337. @example
  8338. ```js
  8339. // Release all dependencies of a loaded prefab
  8340. var deps = cc.loader.getDependsRecursively(prefab);
  8341. cc.loader.release(deps);
  8342. // Retrieve all dependent textures
  8343. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8344. var textures = [];
  8345. for (var i = 0; i < deps.length; ++i) {
  8346. var item = cc.loader.getRes(deps[i]);
  8347. if (item instanceof cc.Texture2D) {
  8348. textures.push(item);
  8349. }
  8350. }
  8351. ```
  8352. */
  8353. static getDependsRecursively(owner: Asset|RawAsset|string): any[];
  8354. /**
  8355. !#en
  8356. Release the content of an asset or an array of assets by uuid.
  8357. Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content.
  8358. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  8359. In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances.
  8360. 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.
  8361. If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8362. !#zh
  8363. 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。
  8364. 从 v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。
  8365. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  8366. 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。
  8367. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  8368. 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8369. @param asset asset
  8370. @example
  8371. ```js
  8372. // Release a texture which is no longer need
  8373. cc.loader.release(texture);
  8374. // Release all dependencies of a loaded prefab
  8375. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8376. cc.loader.release(deps);
  8377. // 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.
  8378. // If you have some other nodes share a texture in this prefab, you can skip it in two ways:
  8379. // 1. Forbid auto release a texture before release
  8380. cc.loader.setAutoRelease(texture2d, false);
  8381. // 2. Remove it from the dependencies array
  8382. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8383. var index = deps.indexOf(texture2d._uuid);
  8384. if (index !== -1)
  8385. deps.splice(index, 1);
  8386. cc.loader.release(deps);
  8387. ```
  8388. */
  8389. static release(asset: Asset|RawAsset|string|any[]): void;
  8390. /**
  8391. !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8392. !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8393. @param asset asset
  8394. */
  8395. static releaseAsset(asset: Asset): void;
  8396. /**
  8397. !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8398. !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8399. @param url url
  8400. @param type Only asset of type will be released if this argument is supplied.
  8401. */
  8402. static releaseRes(url: string, type?: Function): void;
  8403. /**
  8404. !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8405. !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8406. @param url url
  8407. @param type Only asset of type will be released if this argument is supplied.
  8408. */
  8409. static releaseResDir(url: string, type?: Function): void;
  8410. /**
  8411. !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8412. !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8413. */
  8414. static releaseAll(): void;
  8415. /**
  8416. !#en
  8417. Indicates whether to release the asset when loading a new scene.<br>
  8418. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8419. according to whether the previous scene checked the "Auto Release Assets" option.
  8420. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8421. will not be affected by that option, remain not released by default.<br>
  8422. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  8423. <br>
  8424. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8425. !#zh
  8426. 设置当场景切换时是否自动释放资源。<br>
  8427. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8428. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8429. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8430. <br>
  8431. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8432. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8433. @param autoRelease indicates whether should release automatically
  8434. @example
  8435. ```js
  8436. // auto release the texture event if "Auto Release Assets" disabled in current scene
  8437. cc.loader.setAutoRelease(texture2d, true);
  8438. // don't release the texture even if "Auto Release Assets" enabled in current scene
  8439. cc.loader.setAutoRelease(texture2d, false);
  8440. // first parameter can be url
  8441. cc.loader.setAutoRelease(audioUrl, false);
  8442. ```
  8443. */
  8444. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8445. /**
  8446. !#en
  8447. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  8448. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8449. according to whether the previous scene checked the "Auto Release Assets" option.
  8450. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8451. will not be affected by that option, remain not released by default.<br>
  8452. 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>
  8453. <br>
  8454. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8455. !#zh
  8456. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  8457. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8458. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8459. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8460. <br>
  8461. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8462. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8463. @param autoRelease indicates whether should release automatically
  8464. @example
  8465. ```js
  8466. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  8467. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  8468. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  8469. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  8470. // don't release the Prefab and all the referenced assets
  8471. cc.loader.setAutoReleaseRecursively(prefab, false);
  8472. ```
  8473. */
  8474. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8475. /**
  8476. !#en
  8477. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  8478. <br>
  8479. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8480. !#zh
  8481. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  8482. <br>
  8483. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8484. @param assetOrUrl asset object or the raw asset's url
  8485. */
  8486. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  8487. }
  8488. /** !#en
  8489. LoadingItems is the queue of items which can flow them into the loading pipeline.</br>
  8490. 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>
  8491. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  8492. Each item always contains the following property:</br>
  8493. - id: The identification of the item, usually it's identical to url</br>
  8494. - url: The url </br>
  8495. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  8496. - error: The error happened in pipeline will be stored in this property.</br>
  8497. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  8498. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  8499. - 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>
  8500. </br>
  8501. Item can hold other custom properties.</br>
  8502. Each LoadingItems object will be destroyed for recycle after onComplete callback</br>
  8503. So please don't hold its reference for later usage, you can copy properties in it though.
  8504. !#zh
  8505. LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。</br>
  8506. 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
  8507. 它有一个 map 属性用来存放加载项,在 map 对象中已 url 为 key 值。</br>
  8508. 每个对象都会包含下列属性:</br>
  8509. - id:该对象的标识,通常与 url 相同。</br>
  8510. - url:路径 </br>
  8511. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  8512. - error:pipeline 中发生的错误将被保存在这个属性中。</br>
  8513. - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。</br>
  8514. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  8515. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  8516. </br>
  8517. 对象可容纳其他自定义属性。</br>
  8518. 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */
  8519. export class LoadingItems extends CallbacksInvoker {
  8520. /**
  8521. !#en This is a callback which will be invoked while an item flow out the pipeline.
  8522. You can pass the callback function in LoadingItems.create or set it later.
  8523. !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8524. @param completedCount The number of the items that are already completed.
  8525. @param totalCount The total number of the items.
  8526. @param item The latest item which flow out the pipeline.
  8527. @example
  8528. ```js
  8529. loadingItems.onProgress = function (completedCount, totalCount, item) {
  8530. var progress = (100 * completedCount / totalCount).toFixed(2);
  8531. cc.log(progress + '%');
  8532. }
  8533. ```
  8534. */
  8535. onProgress(completedCount: number, totalCount: number, item: any): void;
  8536. /**
  8537. !#en This is a callback which will be invoked while all items is completed,
  8538. You can pass the callback function in LoadingItems.create or set it later.
  8539. !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8540. @param errors All errored urls will be stored in this array, if no error happened, then it will be null
  8541. @param items All items.
  8542. @example
  8543. ```js
  8544. loadingItems.onComplete = function (errors, items) {
  8545. if (error)
  8546. cc.log('Completed with ' + errors.length + ' errors');
  8547. else
  8548. cc.log('Completed ' + items.totalCount + ' items');
  8549. }
  8550. ```
  8551. */
  8552. onComplete(errors: any[], items: LoadingItems): void;
  8553. /** !#en The map of all items.
  8554. !#zh 存储所有加载项的对象。 */
  8555. map: any;
  8556. /** !#en The map of completed items.
  8557. !#zh 存储已经完成的加载项。 */
  8558. completed: any;
  8559. /** !#en Total count of all items.
  8560. !#zh 所有加载项的总数。 */
  8561. totalCount: number;
  8562. /** !#en Total count of completed items.
  8563. !#zh 所有完成加载项的总数。 */
  8564. completedCount: number;
  8565. /** !#en Activated or not.
  8566. !#zh 是否启用。 */
  8567. active: boolean;
  8568. /**
  8569. !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible.
  8570. You can pass onProgress and onComplete callbacks to visualize the loading process.
  8571. !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。
  8572. 你可以传递 onProgress 和 onComplete 回调函数来获知加载进度信息。
  8573. @param pipeline The pipeline to process the queue.
  8574. @param urlList The items array.
  8575. @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}}
  8576. @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
  8577. @example
  8578. ```js
  8579. LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
  8580. var progress = (100 * completedCount / totalCount).toFixed(2);
  8581. cc.log(progress + '%');
  8582. }, function (errors, items) {
  8583. if (errors) {
  8584. for (var i = 0; i < errors.length; ++i) {
  8585. cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i]));
  8586. }
  8587. }
  8588. else {
  8589. var result_a = items.getContent('a.png');
  8590. // ...
  8591. }
  8592. })
  8593. ```
  8594. */
  8595. static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems;
  8596. /**
  8597. !#en Retrieve the LoadingItems queue object for an item.
  8598. !#zh 通过 item 对象获取它的 LoadingItems 队列。
  8599. @param item The item to query
  8600. */
  8601. static getQueue(item: any): LoadingItems;
  8602. /**
  8603. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8604. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8605. @param item The item which has completed
  8606. */
  8607. static itemComplete(item: any): void;
  8608. /**
  8609. !#en Add urls to the LoadingItems queue.
  8610. !#zh 向一个 LoadingItems 队列添加加载项。
  8611. @param urlList The url list to be appended, the url can be object or string
  8612. */
  8613. append(urlList: any[]): any[];
  8614. /**
  8615. !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening.
  8616. !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。
  8617. */
  8618. allComplete(): void;
  8619. /**
  8620. !#en Check whether all items are completed.
  8621. !#zh 检查是否所有加载项都已经完成。
  8622. */
  8623. isCompleted(): boolean;
  8624. /**
  8625. !#en Check whether an item is completed.
  8626. !#zh 通过 id 检查指定加载项是否已经加载完成。
  8627. @param id The item's id.
  8628. */
  8629. isItemCompleted(id: string): boolean;
  8630. /**
  8631. !#en Check whether an item exists.
  8632. !#zh 通过 id 检查加载项是否存在。
  8633. @param id The item's id.
  8634. */
  8635. exists(id: string): boolean;
  8636. /**
  8637. !#en Returns the content of an internal item.
  8638. !#zh 通过 id 获取指定对象的内容。
  8639. @param id The item's id.
  8640. */
  8641. getContent(id: string): any;
  8642. /**
  8643. !#en Returns the error of an internal item.
  8644. !#zh 通过 id 获取指定对象的错误信息。
  8645. @param id The item's id.
  8646. */
  8647. getError(id: string): any;
  8648. /**
  8649. !#en Add a listener for an item, the callback will be invoked when the item is completed.
  8650. !#zh 监听加载项(通过 key 指定)的完成事件。
  8651. @param key key
  8652. @param callback can be null
  8653. @param target can be null
  8654. */
  8655. addListener(key: string, callback: Function, target: any): boolean;
  8656. /**
  8657. !#en
  8658. Check if the specified key has any registered callback. </br>
  8659. If a callback is also specified, it will only return true if the callback is registered.
  8660. !#zh
  8661. 检查指定的加载项是否有完成事件监听器。</br>
  8662. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true。
  8663. @param key key
  8664. @param callback callback
  8665. @param target target
  8666. */
  8667. hasListener(key: string, callback?: Function, target?: any): boolean;
  8668. /**
  8669. !#en
  8670. Removes a listener. </br>
  8671. It will only remove when key, callback, target all match correctly.
  8672. !#zh
  8673. 移除指定加载项已经注册的完成事件监听器。</br>
  8674. 只会删除 key, callback, target 均匹配的监听器。
  8675. @param key key
  8676. @param callback callback
  8677. @param target target
  8678. */
  8679. remove(key: string, callback: Function, target: any): boolean;
  8680. /**
  8681. !#en
  8682. Removes all callbacks registered in a certain event
  8683. type or all callbacks registered with a certain target.
  8684. !#zh 删除指定目标的所有完成事件监听器。
  8685. @param key The event key to be removed or the target to be removed
  8686. */
  8687. removeAllListeners(key: string|any): void;
  8688. /**
  8689. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8690. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8691. @param id The item url
  8692. */
  8693. itemComplete(id: string): void;
  8694. /**
  8695. !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable.
  8696. !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。
  8697. */
  8698. destroy(): void;
  8699. }
  8700. /** !#en
  8701. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  8702. 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>
  8703. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  8704. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  8705. Finally all items will flow out the pipeline and the process is finished.
  8706. !#zh
  8707. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  8708. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  8709. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  8710. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  8711. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  8712. export class Pipeline {
  8713. /**
  8714. !#en
  8715. Constructor, pass an array of pipes to construct a new Pipeline,
  8716. the pipes will be chained in the given order.</br>
  8717. A pipe is an object which must contain an `id` in string and a `handle` function,
  8718. the id must be unique in the pipeline.</br>
  8719. It can also include `async` property to identify whether it's an asynchronous process.
  8720. !#zh
  8721. 构造函数,通过一系列的 pipe 来构造一个新的 pipeline,pipes 将会在给定的顺序中被锁定。</br>
  8722. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipeline 中 id 必须是唯一的。</br>
  8723. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  8724. @param pipes pipes
  8725. @example
  8726. ```js
  8727. var pipeline = new Pipeline([
  8728. {
  8729. id: 'Downloader',
  8730. handle: function (item, callback) {},
  8731. async: true
  8732. },
  8733. {id: 'Parser', handle: function (item) {}, async: false}
  8734. ]);
  8735. ```
  8736. */
  8737. constructor(pipes: any[]);
  8738. /**
  8739. !#en
  8740. Insert a new pipe at the given index of the pipeline. </br>
  8741. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  8742. !#zh
  8743. 在给定的索引位置插入一个新的 pipe。</br>
  8744. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  8745. @param pipe The pipe to be inserted
  8746. @param index The index to insert
  8747. */
  8748. insertPipe(pipe: any, index: number): void;
  8749. /**
  8750. !en
  8751. Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline.
  8752. !zh
  8753. 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe。
  8754. @param refPipe An existing pipe in the pipeline.
  8755. @param newPipe The pipe to be inserted.
  8756. */
  8757. insertPipeAfter(refPipe: any, newPipe: any): void;
  8758. /**
  8759. !#en
  8760. Add a new pipe at the end of the pipeline. </br>
  8761. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  8762. !#zh
  8763. 添加一个新的 pipe 到 pipeline 尾部。 </br>
  8764. 该 pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 id 在 pipeline 必须是唯一标识。
  8765. @param pipe The pipe to be appended
  8766. */
  8767. appendPipe(pipe: any): void;
  8768. /**
  8769. !#en
  8770. Let new items flow into the pipeline. </br>
  8771. Each item can be a simple url string or an object,
  8772. if it's an object, it must contain `id` property. </br>
  8773. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  8774. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  8775. The object can contain any supplementary property as you want. </br>
  8776. !#zh
  8777. 让新的 item 流入 pipeline 中。</br>
  8778. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  8779. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  8780. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  8781. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  8782. 该对象可以包含任何附加属性。
  8783. @param items items
  8784. @example
  8785. ```js
  8786. pipeline.flowIn([
  8787. 'res/Background.png',
  8788. {
  8789. id: 'res/scene.json',
  8790. type: 'scene',
  8791. name: 'scene',
  8792. skips: ['Downloader']
  8793. }
  8794. ]);
  8795. ```
  8796. */
  8797. flowIn(items: any[]): void;
  8798. /**
  8799. !#en
  8800. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  8801. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  8802. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  8803. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  8804. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  8805. !#zh
  8806. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  8807. 这个 API 的使用通常是为了加载依赖项。</br>
  8808. 例如:</br>
  8809. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  8810. @param urlList urlList
  8811. @param callback callback
  8812. */
  8813. flowInDeps(urlList: any[], callback: Function): any[];
  8814. /**
  8815. !#en
  8816. Copy the item states from one source item to all destination items. </br>
  8817. It's quite useful when a pipe generate new items from one source item,</br>
  8818. then you should flowIn these generated items into pipeline, </br>
  8819. but you probably want them to skip all pipes the source item already go through,</br>
  8820. you can achieve it with this API. </br>
  8821. </br>
  8822. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  8823. !#zh
  8824. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  8825. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  8826. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  8827. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  8828. 这个时候就可以使用这个 API。
  8829. @param srcItem The source item
  8830. @param dstItems A single destination item or an array of destination items
  8831. */
  8832. copyItemStates(srcItem: any, dstItems: any[]|any): void;
  8833. /**
  8834. !#en Returns whether the pipeline is flowing (contains item) currently.
  8835. !#zh 获取 pipeline 当前是否正在处理中。
  8836. */
  8837. isFlowing(): boolean;
  8838. /**
  8839. !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  8840. !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。
  8841. */
  8842. getItems(): LoadingItems;
  8843. /**
  8844. !#en Returns an item in pipeline.
  8845. !#zh 根据 id 获取一个 item
  8846. @param id The id of the item
  8847. */
  8848. getItem(id: any): any;
  8849. /**
  8850. !#en Removes an completed item in pipeline.
  8851. It will only remove the cache in the pipeline or loader, its dependencies won't be released.
  8852. cc.loader provided another method to completely cleanup the resource and its dependencies,
  8853. please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  8854. !#zh 移除指定的已完成 item。
  8855. 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
  8856. cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  8857. @param id The id of the item
  8858. */
  8859. removeItem(id: any): boolean;
  8860. /**
  8861. !#en Clear the current pipeline, this function will clean up the items.
  8862. !#zh 清空当前 pipeline,该函数将清理 items。
  8863. */
  8864. clear(): void;
  8865. }
  8866. /** undefined */
  8867. export class WorldManifold {
  8868. /** !#en
  8869. world contact point (point of intersection)
  8870. !#zh
  8871. 碰撞点集合 */
  8872. points: [Vec2];
  8873. /** !#en
  8874. world vector pointing from A to B
  8875. !#zh
  8876. 世界坐标系下由 A 指向 B 的向量 */
  8877. normal: Vec2;
  8878. }
  8879. /** !#en
  8880. A manifold point is a contact point belonging to a contact manifold.
  8881. It holds details related to the geometry and dynamics of the contact points.
  8882. Note: the impulses are used for internal caching and may not
  8883. provide reliable contact forces, especially for high speed collisions.
  8884. !#zh
  8885. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  8886. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  8887. export class ManifoldPoint {
  8888. /** !#en
  8889. The local point usage depends on the manifold type:
  8890. -e_circles: the local center of circleB
  8891. -e_faceA: the local center of circleB or the clip point of polygonB
  8892. -e_faceB: the clip point of polygonA
  8893. !#zh
  8894. 本地坐标点的用途取决于 manifold 的类型
  8895. - e_circles: circleB 的本地中心点
  8896. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  8897. - e_faceB: polygonB 的截取点 */
  8898. localPoint: Vec2;
  8899. /** !#en
  8900. Normal impulse.
  8901. !#zh
  8902. 法线冲量。 */
  8903. normalImpulse: number;
  8904. /** !#en
  8905. Tangent impulse.
  8906. !#zh
  8907. 切线冲量。 */
  8908. tangentImpulse: number;
  8909. }
  8910. /** undefined */
  8911. export class Manifold {
  8912. /** !#en
  8913. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  8914. !#zh
  8915. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  8916. type: number;
  8917. /** !#en
  8918. The local point usage depends on the manifold type:
  8919. -e_circles: the local center of circleA
  8920. -e_faceA: the center of faceA
  8921. -e_faceB: the center of faceB
  8922. !#zh
  8923. 用途取决于 manifold 类型
  8924. -e_circles: circleA 的本地中心点
  8925. -e_faceA: faceA 的本地中心点
  8926. -e_faceB: faceB 的本地中心点 */
  8927. localPoint: Vec2;
  8928. /** !#en
  8929. -e_circles: not used
  8930. -e_faceA: the normal on polygonA
  8931. -e_faceB: the normal on polygonB
  8932. !#zh
  8933. -e_circles: 没被使用到
  8934. -e_faceA: polygonA 的法向量
  8935. -e_faceB: polygonB 的法向量 */
  8936. localNormal: Vec2;
  8937. /** !#en
  8938. the points of contact.
  8939. !#zh
  8940. 接触点信息。 */
  8941. points: [ManifoldPoint];
  8942. }
  8943. /** !#en
  8944. Contact impulses for reporting.
  8945. !#zh
  8946. 用于返回给回调的接触冲量。 */
  8947. export class PhysicsImpulse {
  8948. /** !#en
  8949. Normal impulses.
  8950. !#zh
  8951. 法线方向的冲量 */
  8952. normalImpulses: void;
  8953. /** !#en
  8954. Tangent impulses
  8955. !#zh
  8956. 切线方向的冲量 */
  8957. tangentImpulses: void;
  8958. }
  8959. /** !#en
  8960. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  8961. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  8962. !#zh
  8963. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  8964. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  8965. export class PhysicsContact {
  8966. /**
  8967. !#en
  8968. Get the world manifold.
  8969. !#zh
  8970. 获取世界坐标系下的碰撞信息。
  8971. */
  8972. getWorldManifold(): WorldManifold;
  8973. /**
  8974. !#en
  8975. Get the manifold.
  8976. !#zh
  8977. 获取世界坐标系下的碰撞信息。
  8978. */
  8979. getManifold(): Manifold;
  8980. /**
  8981. !#en
  8982. Get the impulses.
  8983. Note: PhysicsImpulse can only used in onPostSolve callback.
  8984. !#zh
  8985. 获取冲量信息
  8986. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  8987. */
  8988. getImpulse(): PhysicsImpulse;
  8989. colliderA: Collider;
  8990. colliderB: Collider;
  8991. /** !#en
  8992. If set disabled to true, the contact will be ignored until contact end.
  8993. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  8994. !#zh
  8995. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  8996. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  8997. disabled: boolean;
  8998. /** !#en
  8999. Disabled contact for current time step or sub-step.
  9000. !#zh
  9001. 在当前时间步或子步中忽略此接触。 */
  9002. disabledOnce: boolean;
  9003. /**
  9004. !#en
  9005. Is this contact touching?
  9006. !#zh
  9007. 返回碰撞体是否已经接触到。
  9008. */
  9009. isTouching(): boolean;
  9010. /**
  9011. !#en
  9012. Set the desired tangent speed for a conveyor belt behavior.
  9013. !#zh
  9014. 为传送带设置期望的切线速度
  9015. @param tangentSpeed tangentSpeed
  9016. */
  9017. setTangentSpeed(tangentSpeed: number): void;
  9018. /**
  9019. !#en
  9020. Get the desired tangent speed.
  9021. !#zh
  9022. 获取切线速度
  9023. */
  9024. getTangentSpeed(): number;
  9025. /**
  9026. !#en
  9027. Override the default friction mixture. You can call this in onPreSolve callback.
  9028. !#zh
  9029. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  9030. @param friction friction
  9031. */
  9032. setFriction(friction: number): void;
  9033. /**
  9034. !#en
  9035. Get the friction.
  9036. !#zh
  9037. 获取当前摩擦力系数
  9038. */
  9039. getFriction(): number;
  9040. /**
  9041. !#en
  9042. Reset the friction mixture to the default value.
  9043. !#zh
  9044. 重置摩擦力系数到默认值
  9045. */
  9046. resetFriction(): void;
  9047. /**
  9048. !#en
  9049. Override the default restitution mixture. You can call this in onPreSolve callback.
  9050. !#zh
  9051. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  9052. @param restitution restitution
  9053. */
  9054. setRestitution(restitution: number): void;
  9055. /**
  9056. !#en
  9057. Get the restitution.
  9058. !#zh
  9059. 获取当前恢复系数
  9060. */
  9061. getRestitution(): number;
  9062. /**
  9063. !#en
  9064. Reset the restitution mixture to the default value.
  9065. !#zh
  9066. 重置恢复系数到默认值
  9067. */
  9068. resetRestitution(): void;
  9069. }
  9070. /** !#en
  9071. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  9072. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  9073. Physics manager distributes the collision information to each collision callback when collision is produced.
  9074. Note: You need first enable the collision listener in the rigidbody.
  9075. !#zh
  9076. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  9077. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  9078. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  9079. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */
  9080. export class PhysicsManager implements EventTarget {
  9081. /** !#en
  9082. The draw bits for drawing physics debug information.
  9083. !#zh
  9084. 指定物理系统需要绘制哪些调试信息。 */
  9085. static DrawBits: DrawBits;
  9086. /** !#en
  9087. The ratio transform between physics unit and pixel unit, generally is 32.
  9088. !#zh
  9089. 物理单位与像素单位互相转换的比率,一般是 32。 */
  9090. static PTM_RATIO: number;
  9091. /** !#en
  9092. The velocity iterations for the velocity constraint solver.
  9093. !#zh
  9094. 速度更新迭代数 */
  9095. static VELOCITY_ITERATIONS: number;
  9096. /** !#en
  9097. The position Iterations for the position constraint solver.
  9098. !#zh
  9099. 位置迭代更新数 */
  9100. static POSITION_ITERATIONS: number;
  9101. /** !#en
  9102. If enabled accumulator, then will call step function with a fixed time step.
  9103. And if the update dt is bigger than the time step, then will call step function several times.
  9104. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  9105. !#zh
  9106. 如果开启此选项,那么将会以一个固定的时间步来更新物理引擎,如果一个 update 的间隔时间大于这个时间步,则会对物理引擎进行多次更新。
  9107. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个时间步来更新物理引擎。 */
  9108. enabledAccumulator: boolean;
  9109. /**
  9110. !#en
  9111. Test which collider contains the given world point
  9112. !#zh
  9113. 获取包含给定世界坐标系点的碰撞体
  9114. @param point the world point
  9115. */
  9116. testPoint(point: Vec2): PhysicsCollider;
  9117. /**
  9118. !#en
  9119. Test which colliders intersect the given world rect
  9120. !#zh
  9121. 获取与给定世界坐标系矩形相交的碰撞体
  9122. @param rect the world rect
  9123. */
  9124. testAABB(rect: Rect): [PhysicsCollider];
  9125. /**
  9126. !#en
  9127. Raycast the world for all colliders in the path of the ray.
  9128. The raycast ignores colliders that contain the starting point.
  9129. !#zh
  9130. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  9131. @param p1 start point of the raycast
  9132. @param p2 end point of the raycast
  9133. @param type optional, default is RayCastType.Closest
  9134. */
  9135. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult];
  9136. /**
  9137. !#en
  9138. Attach physics debug draw to camera
  9139. !#zh
  9140. 将物理的调试绘制信息附加到指定摄像机上
  9141. @param camera camera
  9142. */
  9143. attachDebugDrawToCamera(camera: Camera): void;
  9144. /**
  9145. !#en
  9146. Detach physics debug draw to camera
  9147. !#zh
  9148. 将物理的调试绘制信息从指定摄像机上移除
  9149. @param camera camera
  9150. */
  9151. detachDebugDrawFromCamera(camera: Camera): void;
  9152. /** !#en
  9153. Enabled the physics manager?
  9154. !#zh
  9155. 指定是否启用物理系统? */
  9156. enabled: boolean;
  9157. /** !#en
  9158. Debug draw flags.
  9159. !#zh
  9160. 设置调试绘制标志 */
  9161. debugDrawFlags: number;
  9162. /** !#en
  9163. The physics world gravity.
  9164. !#zh
  9165. 物理世界重力值 */
  9166. gravity: Vec2;
  9167. /**
  9168. !#en
  9169. Register an callback of a specific event type on the EventTarget.
  9170. !#zh
  9171. 注册事件目标的特定事件类型回调。
  9172. @param type A string representing the event type to listen for.
  9173. @param callback The callback that will be invoked when the event is dispatched.
  9174. The callback is ignored if it is a duplicate (the callbacks are unique).
  9175. @param target The target (this object) to invoke the callback, can be null
  9176. @param useCapture When set to true, the capture argument prevents callback
  9177. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9178. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9179. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9180. @example
  9181. ```js
  9182. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9183. cc.log("this is callback");
  9184. }, node);
  9185. ```
  9186. */
  9187. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9188. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9189. /**
  9190. !#en
  9191. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  9192. if only type is passed as parameter, all listeners registered with that type will be removed.
  9193. !#zh
  9194. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  9195. @param type A string representing the event type being removed.
  9196. @param callback The callback to remove.
  9197. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  9198. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  9199. If not specified, useCapture defaults to false. If a callback was registered twice,
  9200. one with capture and one without, each must be removed separately. Removal of a capturing callback
  9201. does not affect a non-capturing version of the same listener, and vice versa.
  9202. @example
  9203. ```js
  9204. // register touchEnd eventListener
  9205. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9206. cc.log("this is callback");
  9207. }, node);
  9208. // remove touch end event listener
  9209. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  9210. // remove all touch end event listeners
  9211. node.off(cc.Node.EventType.TOUCH_END);
  9212. ```
  9213. */
  9214. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  9215. /**
  9216. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  9217. This is not for removing all listeners in the current event target,
  9218. and this is not for removing all listeners the target parameter have registered.
  9219. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  9220. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  9221. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  9222. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  9223. @param target The target to be searched for all related listeners
  9224. */
  9225. targetOff(target: any): void;
  9226. /**
  9227. !#en
  9228. Register an callback of a specific event type on the EventTarget,
  9229. the callback will remove itself after the first time it is triggered.
  9230. !#zh
  9231. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  9232. @param type A string representing the event type to listen for.
  9233. @param callback The callback that will be invoked when the event is dispatched.
  9234. The callback is ignored if it is a duplicate (the callbacks are unique).
  9235. @param target The target (this object) to invoke the callback, can be null
  9236. @param useCapture When set to true, the capture argument prevents callback
  9237. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9238. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9239. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9240. @example
  9241. ```js
  9242. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  9243. cc.log("this is callback");
  9244. }, node);
  9245. ```
  9246. */
  9247. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9248. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9249. /**
  9250. !#en
  9251. Dispatches an event into the event flow.
  9252. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  9253. !#zh 分发事件到事件流中。
  9254. @param event The Event object that is dispatched into the event flow
  9255. */
  9256. dispatchEvent(event: Event): void;
  9257. /**
  9258. !#en
  9259. Send an event to this object directly, this method will not propagate the event to any other objects.
  9260. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  9261. !#zh
  9262. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  9263. @param message the message to send
  9264. @param detail whatever argument the message needs
  9265. */
  9266. emit(message: string, detail?: any): void;
  9267. }
  9268. /** undefined */
  9269. export enum DrawBits {
  9270. e_aabbBit = 0,
  9271. e_pairBit = 0,
  9272. e_centerOfMassBit = 0,
  9273. e_jointBit = 0,
  9274. e_shapeBit = 0,
  9275. }
  9276. /** undefined */
  9277. export class PhysicsRayCastResult {
  9278. /** !#en
  9279. The PhysicsCollider which intersects with the raycast
  9280. !#zh
  9281. 与射线相交的碰撞体 */
  9282. collider: PhysicsCollider;
  9283. /** !#en
  9284. The intersection point
  9285. !#zh
  9286. 射线与碰撞体相交的点 */
  9287. point: Vec2;
  9288. /** !#en
  9289. The normal vector at the point of intersection
  9290. !#zh
  9291. 射线与碰撞体相交的点的法向量 */
  9292. normal: Vec2;
  9293. /** !#en
  9294. The fraction of the raycast path at the point of intersection
  9295. !#zh
  9296. 射线与碰撞体相交的点占射线长度的分数 */
  9297. fraction: number;
  9298. }
  9299. /** !#en Enum for RigidBodyType.
  9300. !#zh 刚体类型 */
  9301. export enum RigidBodyType {
  9302. Static = 0,
  9303. Kinematic = 0,
  9304. Dynamic = 0,
  9305. Animated = 0,
  9306. }
  9307. /** !#en Enum for RayCastType.
  9308. !#zh 射线检测类型 */
  9309. export enum RayCastType {
  9310. Closest = 0,
  9311. Any = 0,
  9312. AllClosest = 0,
  9313. All = 0,
  9314. }
  9315. /** undefined */
  9316. export class RigidBody extends Component {
  9317. /** !#en
  9318. Should enabled contact listener?
  9319. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  9320. !#zh
  9321. 是否启用接触接听器。
  9322. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  9323. enabledContactListener: boolean;
  9324. /**
  9325. !#en
  9326. Collision callback.
  9327. Called when two collider begin to touch.
  9328. !#zh
  9329. 碰撞回调。
  9330. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  9331. @param contact contact information
  9332. @param selfCollider the collider belong to this rigidbody
  9333. @param otherCollider the collider belong to another rigidbody
  9334. */
  9335. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9336. /**
  9337. !#en
  9338. Collision callback.
  9339. Called when two collider cease to touch.
  9340. !#zh
  9341. 碰撞回调。
  9342. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  9343. @param contact contact information
  9344. @param selfCollider the collider belong to this rigidbody
  9345. @param otherCollider the collider belong to another rigidbody
  9346. */
  9347. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9348. /**
  9349. !#en
  9350. Collision callback.
  9351. This is called when a contact is updated.
  9352. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  9353. Note: this is called only for awake bodies.
  9354. Note: this is called even when the number of contact points is zero.
  9355. Note: this is not called for sensors.
  9356. !#zh
  9357. 碰撞回调。
  9358. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  9359. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  9360. 注意:回调只会为醒着的刚体调用。
  9361. 注意:接触点为零的时候也有可能被调用。
  9362. 注意:感知体(sensor)的回调不会被调用。
  9363. @param contact contact information
  9364. @param selfCollider the collider belong to this rigidbody
  9365. @param otherCollider the collider belong to another rigidbody
  9366. */
  9367. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9368. /**
  9369. !#en
  9370. Collision callback.
  9371. This is called after a contact is updated.
  9372. You can get the impulses from the contact in this callback.
  9373. !#zh
  9374. 碰撞回调。
  9375. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  9376. 你可以在这个回调中从接触信息中获取到冲量信息。
  9377. @param contact contact information
  9378. @param selfCollider the collider belong to this rigidbody
  9379. @param otherCollider the collider belong to another rigidbody
  9380. */
  9381. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9382. /** !#en
  9383. Is this a fast moving body that should be prevented from tunneling through
  9384. other moving bodies?
  9385. Note :
  9386. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  9387. - You should use this flag sparingly since it increases processing time.
  9388. !#zh
  9389. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  9390. 需要注意的是 :
  9391. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  9392. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  9393. bullet: boolean;
  9394. /** !#en
  9395. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  9396. !#zh
  9397. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  9398. type: RigidBodyType;
  9399. /** !#en
  9400. Set this flag to false if this body should never fall asleep.
  9401. Note that this increases CPU usage.
  9402. !#zh
  9403. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  9404. 需要注意这将使 CPU 占用率提高。 */
  9405. allowSleep: boolean;
  9406. /** !#en
  9407. Scale the gravity applied to this body.
  9408. !#zh
  9409. 缩放应用在此刚体上的重力值 */
  9410. gravityScale: number;
  9411. /** !#en
  9412. Linear damping is use to reduce the linear velocity.
  9413. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  9414. time step when the damping parameter is large.
  9415. !#zh
  9416. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9417. linearDamping: number;
  9418. /** !#en
  9419. Angular damping is use to reduce the angular velocity. The damping parameter
  9420. can be larger than 1 but the damping effect becomes sensitive to the
  9421. time step when the damping parameter is large.
  9422. !#zh
  9423. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9424. angularDamping: number;
  9425. /** !#en
  9426. The linear velocity of the body's origin in world co-ordinates.
  9427. !#zh
  9428. 刚体在世界坐标下的线性速度 */
  9429. linearVelocity: Vec2;
  9430. /** !#en
  9431. The angular velocity of the body.
  9432. !#zh
  9433. 刚体的角速度 */
  9434. angularVelocity: number;
  9435. /** !#en
  9436. Should this body be prevented from rotating?
  9437. !#zh
  9438. 是否禁止此刚体进行旋转 */
  9439. fixedRotation: boolean;
  9440. /** !#en
  9441. Is this body initially awake or sleeping?
  9442. !#zh
  9443. 是否立刻唤醒此刚体 */
  9444. awake: boolean;
  9445. /** !#en
  9446. Set the active state of the body. An inactive body is not
  9447. simulated and cannot be collided with or woken up.
  9448. If body is active, all fixtures will be added to the
  9449. broad-phase.
  9450. If body is inactive, all fixtures will be removed from
  9451. the broad-phase and all contacts will be destroyed.
  9452. Fixtures on an inactive body are implicitly inactive and will
  9453. not participate in collisions, ray-casts, or queries.
  9454. Joints connected to an inactive body are implicitly inactive.
  9455. !#zh
  9456. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  9457. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  9458. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  9459. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  9460. 链接到非激活状态下刚体的关节也是非激活的。 */
  9461. active: boolean;
  9462. /**
  9463. !#en
  9464. Gets a local point relative to the body's origin given a world point.
  9465. !#zh
  9466. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9467. @param worldPoint a point in world coordinates.
  9468. @param out optional, the receiving point
  9469. */
  9470. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9471. /**
  9472. !#en
  9473. Get the world coordinates of a point given the local coordinates.
  9474. !#zh
  9475. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  9476. @param localPoint a point in local coordinates.
  9477. @param out optional, the receiving point
  9478. */
  9479. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  9480. /**
  9481. !#en
  9482. Get the world coordinates of a vector given the local coordinates.
  9483. !#zh
  9484. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  9485. @param localVector a vector in world coordinates.
  9486. @param out optional, the receiving vector
  9487. */
  9488. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  9489. /**
  9490. !#en
  9491. Gets a local vector relative to the body's origin given a world vector.
  9492. !#zh
  9493. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9494. @param worldVector a vector in world coordinates.
  9495. @param out optional, the receiving vector
  9496. */
  9497. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  9498. /**
  9499. !#en
  9500. Get the world body origin position.
  9501. !#zh
  9502. 获取刚体世界坐标系下的原点值
  9503. @param out optional, the receiving point
  9504. */
  9505. getWorldPosition(out: Vec2): Vec2;
  9506. /**
  9507. !#en
  9508. Get the world body rotation angle.
  9509. !#zh
  9510. 获取刚体世界坐标系下的旋转值。
  9511. */
  9512. getWorldRotation(): number;
  9513. /**
  9514. !#en
  9515. Get the local position of the center of mass.
  9516. !#zh
  9517. 获取刚体本地坐标系下的质心
  9518. */
  9519. getLocalCenter(): Vec2;
  9520. /**
  9521. !#en
  9522. Get the world position of the center of mass.
  9523. !#zh
  9524. 获取刚体世界坐标系下的质心
  9525. */
  9526. getWorldCenter(): Vec2;
  9527. /**
  9528. !#en
  9529. Get the world linear velocity of a world point attached to this body.
  9530. !#zh
  9531. 获取刚体上指定点的线性速度
  9532. @param worldPoint a point in world coordinates.
  9533. @param out optional, the receiving point
  9534. */
  9535. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9536. /**
  9537. !#en
  9538. Get total mass of the body.
  9539. !#zh
  9540. 获取刚体的质量。
  9541. */
  9542. getMass(): number;
  9543. /**
  9544. !#en
  9545. Get the rotational inertia of the body about the local origin.
  9546. !#zh
  9547. 获取刚体本地坐标系下原点的旋转惯性
  9548. */
  9549. getInertia(): number;
  9550. /**
  9551. !#en
  9552. Get all the joints connect to the rigidbody.
  9553. !#zh
  9554. 获取链接到此刚体的所有关节
  9555. */
  9556. getJointList(): [Joint];
  9557. /**
  9558. !#en
  9559. Apply a force at a world point. If the force is not
  9560. applied at the center of mass, it will generate a torque and
  9561. affect the angular velocity.
  9562. !#zh
  9563. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  9564. @param force the world force vector.
  9565. @param point the world position.
  9566. @param wake also wake up the body.
  9567. */
  9568. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  9569. /**
  9570. !#en
  9571. Apply a force to the center of mass.
  9572. !#zh
  9573. 施加一个力到刚体上的质心上。
  9574. @param force the world force vector.
  9575. @param wake also wake up the body.
  9576. */
  9577. applyForceToCenter(force: Vec2, wake: boolean): void;
  9578. /**
  9579. !#en
  9580. Apply a torque. This affects the angular velocity.
  9581. !#zh
  9582. 施加一个扭矩力,将影响刚体的角速度
  9583. @param torque about the z-axis (out of the screen), usually in N-m.
  9584. @param wake also wake up the body
  9585. */
  9586. applyTorque(torque: number, wake: boolean): void;
  9587. /**
  9588. !#en
  9589. Apply a impulse at a world point, This immediately modifies the velocity.
  9590. If the impulse is not applied at the center of mass, it will generate a torque and
  9591. affect the angular velocity.
  9592. !#zh
  9593. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  9594. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  9595. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  9596. @param point the world position
  9597. @param wake alse wake up the body
  9598. */
  9599. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  9600. /**
  9601. !#en
  9602. Apply an angular impulse.
  9603. !#zh
  9604. 施加一个角速度冲量。
  9605. @param impulse the angular impulse in units of kg*m*m/s
  9606. @param wake also wake up the body
  9607. */
  9608. applyAngularImpulse(impulse: number, wake: boolean): void;
  9609. /**
  9610. !#en
  9611. Synchronize node's world position to box2d rigidbody's position.
  9612. If enableAnimated is true and rigidbody's type is Animated type,
  9613. will set linear velocity instead of directly set rigidbody's position.
  9614. !#zh
  9615. 同步节点的世界坐标到 box2d 刚体的坐标上。
  9616. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  9617. @param enableAnimated enableAnimated
  9618. */
  9619. syncPosition(enableAnimated: boolean): void;
  9620. /**
  9621. !#en
  9622. Synchronize node's world angle to box2d rigidbody's angle.
  9623. If enableAnimated is true and rigidbody's type is Animated type,
  9624. will set angular velocity instead of directly set rigidbody's angle.
  9625. !#zh
  9626. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  9627. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  9628. @param enableAnimated enableAnimated
  9629. */
  9630. syncRotation(enableAnimated: boolean): void;
  9631. }
  9632. /** !#en Key map for keyboard event
  9633. !#zh 键盘事件的按键值 */
  9634. export enum KEY {
  9635. none = 0,
  9636. back = 0,
  9637. menu = 0,
  9638. backspace = 0,
  9639. tab = 0,
  9640. enter = 0,
  9641. shift = 0,
  9642. ctrl = 0,
  9643. alt = 0,
  9644. pause = 0,
  9645. capslock = 0,
  9646. escape = 0,
  9647. space = 0,
  9648. pageup = 0,
  9649. pagedown = 0,
  9650. end = 0,
  9651. home = 0,
  9652. left = 0,
  9653. up = 0,
  9654. right = 0,
  9655. down = 0,
  9656. select = 0,
  9657. insert = 0,
  9658. Delete = 0,
  9659. a = 0,
  9660. b = 0,
  9661. c = 0,
  9662. d = 0,
  9663. e = 0,
  9664. f = 0,
  9665. g = 0,
  9666. h = 0,
  9667. i = 0,
  9668. j = 0,
  9669. k = 0,
  9670. l = 0,
  9671. m = 0,
  9672. n = 0,
  9673. o = 0,
  9674. p = 0,
  9675. q = 0,
  9676. r = 0,
  9677. s = 0,
  9678. t = 0,
  9679. u = 0,
  9680. v = 0,
  9681. w = 0,
  9682. x = 0,
  9683. y = 0,
  9684. z = 0,
  9685. num0 = 0,
  9686. num1 = 0,
  9687. num2 = 0,
  9688. num3 = 0,
  9689. num4 = 0,
  9690. num5 = 0,
  9691. num6 = 0,
  9692. num7 = 0,
  9693. num8 = 0,
  9694. num9 = 0,
  9695. '*' = 0,
  9696. '+' = 0,
  9697. '-' = 0,
  9698. numdel = 0,
  9699. '/' = 0,
  9700. f1 = 0,
  9701. f2 = 0,
  9702. f3 = 0,
  9703. f4 = 0,
  9704. f5 = 0,
  9705. f6 = 0,
  9706. f7 = 0,
  9707. f8 = 0,
  9708. f9 = 0,
  9709. f10 = 0,
  9710. f11 = 0,
  9711. f12 = 0,
  9712. numlock = 0,
  9713. scrolllock = 0,
  9714. ';' = 0,
  9715. semicolon = 0,
  9716. equal = 0,
  9717. '=' = 0,
  9718. ',' = 0,
  9719. comma = 0,
  9720. dash = 0,
  9721. '.' = 0,
  9722. period = 0,
  9723. forwardslash = 0,
  9724. grave = 0,
  9725. '[' = 0,
  9726. openbracket = 0,
  9727. backslash = 0,
  9728. ']' = 0,
  9729. closebracket = 0,
  9730. quote = 0,
  9731. dpadLeft = 0,
  9732. dpadRight = 0,
  9733. dpadUp = 0,
  9734. dpadDown = 0,
  9735. dpadCenter = 0,
  9736. }
  9737. /** Image formats */
  9738. export enum ImageFormat {
  9739. JPG = 0,
  9740. PNG = 0,
  9741. TIFF = 0,
  9742. WEBP = 0,
  9743. PVR = 0,
  9744. ETC = 0,
  9745. S3TC = 0,
  9746. ATITC = 0,
  9747. TGA = 0,
  9748. RAWDATA = 0,
  9749. UNKNOWN = 0,
  9750. getImageFormatByData = 0,
  9751. }
  9752. /** Predefined constants */
  9753. export enum macro {
  9754. INVALID_INDEX = 0,
  9755. NODE_TAG_INVALID = 0,
  9756. PI = 0,
  9757. PI2 = 0,
  9758. FLT_MAX = 0,
  9759. FLT_MIN = 0,
  9760. RAD = 0,
  9761. DEG = 0,
  9762. UINT_MAX = 0,
  9763. REPEAT_FOREVER = 0,
  9764. FLT_EPSILON = 0,
  9765. ONE = 0,
  9766. ZERO = 0,
  9767. SRC_ALPHA = 0,
  9768. SRC_ALPHA_SATURATE = 0,
  9769. SRC_COLOR = 0,
  9770. DST_ALPHA = 0,
  9771. DST_COLOR = 0,
  9772. ONE_MINUS_SRC_ALPHA = 0,
  9773. ONE_MINUS_SRC_COLOR = 0,
  9774. ONE_MINUS_DST_ALPHA = 0,
  9775. ONE_MINUS_DST_COLOR = 0,
  9776. ONE_MINUS_CONSTANT_ALPHA = 0,
  9777. ONE_MINUS_CONSTANT_COLOR = 0,
  9778. LINEAR = 0,
  9779. BLEND_DST = 0,
  9780. WEB_ORIENTATION_PORTRAIT = 0,
  9781. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  9782. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  9783. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  9784. ORIENTATION_PORTRAIT = 0,
  9785. ORIENTATION_LANDSCAPE = 0,
  9786. ORIENTATION_AUTO = 0,
  9787. VERTEX_ATTRIB_FLAG_NONE = 0,
  9788. VERTEX_ATTRIB_FLAG_POSITION = 0,
  9789. VERTEX_ATTRIB_FLAG_COLOR = 0,
  9790. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  9791. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  9792. GL_ALL = 0,
  9793. VERTEX_ATTRIB_POSITION = 0,
  9794. VERTEX_ATTRIB_COLOR = 0,
  9795. VERTEX_ATTRIB_TEX_COORDS = 0,
  9796. VERTEX_ATTRIB_MAX = 0,
  9797. UNIFORM_PMATRIX = 0,
  9798. UNIFORM_MVMATRIX = 0,
  9799. UNIFORM_MVPMATRIX = 0,
  9800. UNIFORM_TIME = 0,
  9801. UNIFORM_SINTIME = 0,
  9802. UNIFORM_COSTIME = 0,
  9803. UNIFORM_RANDOM01 = 0,
  9804. UNIFORM_SAMPLER = 0,
  9805. UNIFORM_MAX = 0,
  9806. SHADER_POSITION_TEXTURECOLOR = 0,
  9807. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  9808. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  9809. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  9810. SHADER_POSITION_COLOR = 0,
  9811. SHADER_SPRITE_POSITION_COLOR = 0,
  9812. SHADER_POSITION_TEXTURE = 0,
  9813. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  9814. SHADER_POSITION_TEXTUREA8COLOR = 0,
  9815. SHADER_POSITION_UCOLOR = 0,
  9816. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  9817. UNIFORM_PMATRIX_S = 0,
  9818. UNIFORM_MVMATRIX_S = 0,
  9819. UNIFORM_MVPMATRIX_S = 0,
  9820. UNIFORM_TIME_S = 0,
  9821. UNIFORM_SINTIME_S = 0,
  9822. UNIFORM_COSTIME_S = 0,
  9823. UNIFORM_RANDOM01_S = 0,
  9824. UNIFORM_SAMPLER_S = 0,
  9825. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  9826. ATTRIBUTE_NAME_COLOR = 0,
  9827. ATTRIBUTE_NAME_POSITION = 0,
  9828. ATTRIBUTE_NAME_TEX_COORD = 0,
  9829. ITEM_SIZE = 0,
  9830. CURRENT_ITEM = 0,
  9831. ZOOM_ACTION_TAG = 0,
  9832. NORMAL_TAG = 0,
  9833. SELECTED_TAG = 0,
  9834. DISABLE_TAG = 0,
  9835. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  9836. FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0,
  9837. DIRECTOR_STATS_POSITION = 0,
  9838. DIRECTOR_FPS_INTERVAL = 0,
  9839. COCOSNODE_RENDER_SUBPIXEL = 0,
  9840. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  9841. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  9842. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  9843. TEXTURE_NPOT_SUPPORT = 0,
  9844. USE_LA88_LABELS = 0,
  9845. SPRITE_DEBUG_DRAW = 0,
  9846. LABELBMFONT_DEBUG_DRAW = 0,
  9847. LABELATLAS_DEBUG_DRAW = 0,
  9848. ENABLE_STACKABLE_ACTIONS = 0,
  9849. ENABLE_GL_STATE_CACHE = 0,
  9850. TOUCH_TIMEOUT = 0,
  9851. BATCH_VERTEX_COUNT = 0,
  9852. ENABLE_GC_FOR_NATIVE_OBJECTS = 0,
  9853. ENABLE_TILEDMAP_CULLING = 0,
  9854. DOWNLOAD_MAX_CONCURRENT = 0,
  9855. ENABLE_TRANSPARENT_CANVAS = 0,
  9856. ENABLE_CULLING = 0,
  9857. BLEND_SRC = 0,
  9858. }
  9859. /** The base class of most of all the objects in Fireball. */
  9860. export class Object {
  9861. /** !#en The name of the object.
  9862. !#zh 该对象的名称。 */
  9863. name: string;
  9864. /** !#en Indicates whether the object is not yet destroyed.
  9865. !#zh 表示该对象是否可用(被销毁后将不可用)。 */
  9866. isValid: boolean;
  9867. /**
  9868. !#en
  9869. Destroy this Object, and release all its own references to other objects.<br/>
  9870. Actual object destruction will delayed until before rendering.
  9871. <br/>
  9872. After destroy, this CCObject is not usable any more.
  9873. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  9874. !#zh
  9875. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  9876. 销毁后,CCObject 不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  9877. 实际销毁操作会延迟到当前帧渲染前执行。
  9878. @example
  9879. ```js
  9880. obj.destroy();
  9881. ```
  9882. */
  9883. destroy(): boolean;
  9884. }
  9885. /** Bit mask that controls object states. */
  9886. export enum Flags {
  9887. DontSave = 0,
  9888. EditorOnly = 0,
  9889. }
  9890. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  9891. It's invalid on safari, QQbrowser and android browser */
  9892. export class screen {
  9893. /**
  9894. initialize
  9895. */
  9896. init(): void;
  9897. /**
  9898. return true if it's full now.
  9899. */
  9900. fullScreen(): boolean;
  9901. /**
  9902. change the screen to full mode.
  9903. @param element element
  9904. @param onFullScreenChange onFullScreenChange
  9905. */
  9906. requestFullScreen(element: Element, onFullScreenChange: Function): void;
  9907. /**
  9908. exit the full mode.
  9909. */
  9910. exitFullScreen(): boolean;
  9911. /**
  9912. Automatically request full screen with a touch/click event
  9913. @param element element
  9914. @param onFullScreenChange onFullScreenChange
  9915. */
  9916. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  9917. }
  9918. /** System variables */
  9919. export class sys {
  9920. /** English language code */
  9921. static LANGUAGE_ENGLISH: string;
  9922. /** Chinese language code */
  9923. static LANGUAGE_CHINESE: string;
  9924. /** French language code */
  9925. static LANGUAGE_FRENCH: string;
  9926. /** Italian language code */
  9927. static LANGUAGE_ITALIAN: string;
  9928. /** German language code */
  9929. static LANGUAGE_GERMAN: string;
  9930. /** Spanish language code */
  9931. static LANGUAGE_SPANISH: string;
  9932. /** Spanish language code */
  9933. static LANGUAGE_DUTCH: string;
  9934. /** Russian language code */
  9935. static LANGUAGE_RUSSIAN: string;
  9936. /** Korean language code */
  9937. static LANGUAGE_KOREAN: string;
  9938. /** Japanese language code */
  9939. static LANGUAGE_JAPANESE: string;
  9940. /** Hungarian language code */
  9941. static LANGUAGE_HUNGARIAN: string;
  9942. /** Portuguese language code */
  9943. static LANGUAGE_PORTUGUESE: string;
  9944. /** Arabic language code */
  9945. static LANGUAGE_ARABIC: string;
  9946. /** Norwegian language code */
  9947. static LANGUAGE_NORWEGIAN: string;
  9948. /** Polish language code */
  9949. static LANGUAGE_POLISH: string;
  9950. /** Turkish language code */
  9951. static LANGUAGE_TURKISH: string;
  9952. /** Ukrainian language code */
  9953. static LANGUAGE_UKRAINIAN: string;
  9954. /** Romanian language code */
  9955. static LANGUAGE_ROMANIAN: string;
  9956. /** Bulgarian language code */
  9957. static LANGUAGE_BULGARIAN: string;
  9958. /** Unknown language code */
  9959. static LANGUAGE_UNKNOWN: string;
  9960. static OS_IOS: string;
  9961. static OS_ANDROID: string;
  9962. static OS_WINDOWS: string;
  9963. static OS_MARMALADE: string;
  9964. static OS_LINUX: string;
  9965. static OS_BADA: string;
  9966. static OS_BLACKBERRY: string;
  9967. static OS_OSX: string;
  9968. static OS_WP8: string;
  9969. static OS_WINRT: string;
  9970. static OS_UNKNOWN: string;
  9971. static UNKNOWN: number;
  9972. static WIN32: number;
  9973. static LINUX: number;
  9974. static MACOS: number;
  9975. static ANDROID: number;
  9976. static IPHONE: number;
  9977. static IPAD: number;
  9978. static BLACKBERRY: number;
  9979. static NACL: number;
  9980. static EMSCRIPTEN: number;
  9981. static TIZEN: number;
  9982. static WINRT: number;
  9983. static WP8: number;
  9984. static MOBILE_BROWSER: number;
  9985. static DESKTOP_BROWSER: number;
  9986. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  9987. static EDITOR_PAGE: number;
  9988. /** Indicates whether executes in editor's main process (Electron's browser context) */
  9989. static EDITOR_CORE: number;
  9990. static WECHAT_GAME: number;
  9991. /** BROWSER_TYPE_WECHAT */
  9992. static BROWSER_TYPE_WECHAT: string;
  9993. /** BROWSER_TYPE_WECHAT_GAME */
  9994. static BROWSER_TYPE_WECHAT_GAME: string;
  9995. static BROWSER_TYPE_ANDROID: string;
  9996. static BROWSER_TYPE_IE: string;
  9997. static BROWSER_TYPE_QQ: string;
  9998. static BROWSER_TYPE_MOBILE_QQ: string;
  9999. static BROWSER_TYPE_UC: string;
  10000. static BROWSER_TYPE_360: string;
  10001. static BROWSER_TYPE_BAIDU_APP: string;
  10002. static BROWSER_TYPE_BAIDU: string;
  10003. static BROWSER_TYPE_MAXTHON: string;
  10004. static BROWSER_TYPE_OPERA: string;
  10005. static BROWSER_TYPE_OUPENG: string;
  10006. static BROWSER_TYPE_MIUI: string;
  10007. static BROWSER_TYPE_FIREFOX: string;
  10008. static BROWSER_TYPE_SAFARI: string;
  10009. static BROWSER_TYPE_CHROME: string;
  10010. static BROWSER_TYPE_LIEBAO: string;
  10011. static BROWSER_TYPE_QZONE: string;
  10012. static BROWSER_TYPE_SOUGOU: string;
  10013. static BROWSER_TYPE_UNKNOWN: string;
  10014. /** Is native ? This is set to be true in jsb auto. */
  10015. static isNative: boolean;
  10016. /** Is web browser ? */
  10017. static isBrowser: boolean;
  10018. /** Indicate whether system is mobile system */
  10019. static isMobile: boolean;
  10020. /** Indicate the running platform */
  10021. static platform: number;
  10022. /** Indicate the current language of the running system */
  10023. static language: string;
  10024. /** Indicate the running os name */
  10025. static os: string;
  10026. /** Indicate the running os version */
  10027. static osVersion: string;
  10028. /** Indicate the running os main version */
  10029. static osMainVersion: number;
  10030. /** Indicate the running browser type */
  10031. static browserType: string;
  10032. /** Indicate the running browser version */
  10033. static browserVersion: string;
  10034. /** Indicate the real pixel resolution of the whole game window */
  10035. static windowPixelResolution: Size;
  10036. /** cc.sys.localStorage is a local storage component. */
  10037. static localStorage: any;
  10038. /** The capabilities of the current platform */
  10039. static capabilities: any;
  10040. /**
  10041. Forces the garbage collection, only available in JSB
  10042. */
  10043. static garbageCollect(): void;
  10044. /**
  10045. Dumps rooted objects, only available in JSB
  10046. */
  10047. static dumpRoot(): void;
  10048. /**
  10049. Restart the JS VM, only available in JSB
  10050. */
  10051. static restartVM(): void;
  10052. /**
  10053. Clean a script in the JS VM, only available in JSB
  10054. @param jsfile jsfile
  10055. */
  10056. static cleanScript(jsfile: string): void;
  10057. /**
  10058. Check whether an object is valid,
  10059. In web engine, it will return true if the object exist
  10060. In native engine, it will return true if the JS object and the correspond native object are both valid
  10061. @param obj obj
  10062. */
  10063. static isObjectValid(obj: any): boolean;
  10064. /**
  10065. Dump system informations
  10066. */
  10067. static dump(): void;
  10068. /**
  10069. Open a url in browser
  10070. @param url url
  10071. */
  10072. static openURL(url: string): void;
  10073. /**
  10074. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  10075. */
  10076. static now(): number;
  10077. }
  10078. /** cc.view is the singleton object which represents the game window.<br/>
  10079. It's main task include: <br/>
  10080. - Apply the design resolution policy<br/>
  10081. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  10082. - Manage the game view port which can be different with the window<br/>
  10083. - Manage the content scale and translation<br/>
  10084. <br/>
  10085. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  10086. the standard way to use it is by calling:<br/>
  10087. - cc.view.methodName(); <br/> */
  10088. export class View {
  10089. /**
  10090. <p>
  10091. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  10092. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  10093. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  10094. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  10095. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  10096. 5. Custom value, e.g: "480" <br/>
  10097. </p>
  10098. @param densityDPI densityDPI
  10099. */
  10100. setTargetDensityDPI(densityDPI: string): void;
  10101. /**
  10102. Returns the current target-densitydpi value of cc.view.
  10103. */
  10104. getTargetDensityDPI(): string;
  10105. /**
  10106. Sets whether resize canvas automatically when browser's size changed.<br/>
  10107. Useful only on web.
  10108. @param enabled Whether enable automatic resize with browser's resize event
  10109. */
  10110. resizeWithBrowserSize(enabled: boolean): void;
  10111. /**
  10112. Sets the callback function for cc.view's resize action,<br/>
  10113. this callback will be invoked before applying resolution policy, <br/>
  10114. so you can do any additional modifications within the callback.<br/>
  10115. Useful only on web.
  10116. @param callback The callback function
  10117. */
  10118. setResizeCallback(callback: Function|void): void;
  10119. /**
  10120. Sets the orientation of the game, it can be landscape, portrait or auto.
  10121. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  10122. cc.view will automatically rotate the game canvas using CSS.
  10123. Note that this function doesn't have any effect in native,
  10124. in native, you need to set the application orientation in native project settings
  10125. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  10126. */
  10127. setOrientation(orientation: number): void;
  10128. /**
  10129. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  10130. It's enabled by default, we strongly suggest you not to disable it.<br/>
  10131. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  10132. Only useful on web
  10133. @param enabled Enable automatic modification to "viewport" meta
  10134. */
  10135. adjustViewPort(enabled: boolean): void;
  10136. /**
  10137. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  10138. it takes effect only when you called setDesignResolutionPolicy<br/>
  10139. Only useful on web
  10140. @param enabled Enable or disable retina display
  10141. */
  10142. enableRetina(enabled: boolean): void;
  10143. /**
  10144. Check whether retina display is enabled.<br/>
  10145. Only useful on web
  10146. */
  10147. isRetinaEnabled(): boolean;
  10148. /**
  10149. !#en Whether to Enable on anti-alias
  10150. !#zh 控制抗锯齿是否开启
  10151. @param enabled Enable or not anti-alias
  10152. */
  10153. enableAntiAlias(enabled: boolean): void;
  10154. /**
  10155. !#en Returns whether the current enable on anti-alias
  10156. !#zh 返回当前是否抗锯齿
  10157. */
  10158. isAntiAliasEnabled(): boolean;
  10159. /**
  10160. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  10161. You can pass true as parameter to enable it and disable it by passing false.<br/>
  10162. Only useful on web
  10163. @param enabled Enable or disable auto full screen on mobile devices
  10164. */
  10165. enableAutoFullScreen(enabled: boolean): void;
  10166. /**
  10167. Check whether auto full screen is enabled.<br/>
  10168. Only useful on web
  10169. */
  10170. isAutoFullScreenEnabled(): boolean;
  10171. /**
  10172. Get whether render system is ready(no matter opengl or canvas),<br/>
  10173. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  10174. */
  10175. isViewReady(): boolean;
  10176. /**
  10177. Sets the resolution translate on View.
  10178. @param offsetLeft offsetLeft
  10179. @param offsetTop offsetTop
  10180. */
  10181. setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void;
  10182. /**
  10183. Returns the resolution translate on View
  10184. */
  10185. getContentTranslateLeftTop(): Size;
  10186. /**
  10187. Returns the frame size of the view.<br/>
  10188. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  10189. On web, it returns the size of the canvas's outer DOM element.
  10190. */
  10191. getFrameSize(): Size;
  10192. /**
  10193. On native, it sets the frame size of view.<br/>
  10194. On web, it sets the size of the canvas's outer DOM element.
  10195. @param width width
  10196. @param height height
  10197. */
  10198. setFrameSize(width: number, height: number): void;
  10199. /**
  10200. Returns the visible area size of the view port.
  10201. */
  10202. getVisibleSize(): Size;
  10203. /**
  10204. Returns the visible area size of the view port.
  10205. */
  10206. getVisibleSizeInPixel(): Size;
  10207. /**
  10208. Returns the visible origin of the view port.
  10209. */
  10210. getVisibleOrigin(): Vec2;
  10211. /**
  10212. Returns the visible origin of the view port.
  10213. */
  10214. getVisibleOriginInPixel(): Vec2;
  10215. /**
  10216. Returns whether developer can set content's scale factor.
  10217. */
  10218. canSetContentScaleFactor(): boolean;
  10219. /**
  10220. Returns the current resolution policy
  10221. */
  10222. getResolutionPolicy(): ResolutionPolicy;
  10223. /**
  10224. Sets the current resolution policy
  10225. @param resolutionPolicy resolutionPolicy
  10226. */
  10227. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  10228. /**
  10229. Sets the resolution policy with designed view size in points.<br/>
  10230. The resolution policy include: <br/>
  10231. [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/>
  10232. [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/>
  10233. [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/>
  10234. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  10235. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  10236. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  10237. @param width Design resolution width.
  10238. @param height Design resolution height.
  10239. @param resolutionPolicy The resolution policy desired
  10240. */
  10241. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10242. /**
  10243. Returns the designed size for the view.
  10244. Default resolution size is the same as 'getFrameSize'.
  10245. */
  10246. getDesignResolutionSize(): Size;
  10247. /**
  10248. Sets the container to desired pixel resolution and fit the game content to it.
  10249. This function is very useful for adaptation in mobile browsers.
  10250. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  10251. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  10252. But this API can be helpful to set a desired pixel resolution which is in between.
  10253. This API will do the following:
  10254. 1. Set viewport's width to the desired width in pixel
  10255. 2. Set body width to the exact pixel resolution
  10256. 3. The resolution policy will be reset with designed view size in points.
  10257. @param width Design resolution width.
  10258. @param height Design resolution height.
  10259. @param resolutionPolicy The resolution policy desired
  10260. */
  10261. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10262. /**
  10263. Sets view port rectangle with points.
  10264. @param x x
  10265. @param y y
  10266. @param w width
  10267. @param h height
  10268. */
  10269. setViewPortInPoints(x: number, y: number, w: number, h: number): void;
  10270. /**
  10271. Sets Scissor rectangle with points.
  10272. @param x x
  10273. @param y y
  10274. @param w w
  10275. @param h h
  10276. */
  10277. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  10278. /**
  10279. Returns whether GL_SCISSOR_TEST is enable
  10280. */
  10281. isScissorEnabled(): boolean;
  10282. /**
  10283. Returns the current scissor rectangle
  10284. */
  10285. getScissorRect(): Rect;
  10286. /**
  10287. Sets the name of the view
  10288. @param viewName viewName
  10289. */
  10290. setViewName(viewName: string): void;
  10291. /**
  10292. Returns the name of the view
  10293. */
  10294. getViewName(): string;
  10295. /**
  10296. Returns the view port rectangle.
  10297. */
  10298. getViewPortRect(): Rect;
  10299. /**
  10300. Returns scale factor of the horizontal direction (X axis).
  10301. */
  10302. getScaleX(): number;
  10303. /**
  10304. Returns scale factor of the vertical direction (Y axis).
  10305. */
  10306. getScaleY(): number;
  10307. /**
  10308. Returns device pixel ratio for retina display.
  10309. */
  10310. getDevicePixelRatio(): number;
  10311. /**
  10312. Returns the real location in view for a translation based on a related position
  10313. @param tx The X axis translation
  10314. @param ty The Y axis translation
  10315. @param relatedPos The related position object including "left", "top", "width", "height" informations
  10316. */
  10317. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  10318. }
  10319. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  10320. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  10321. export class ContainerStrategy {
  10322. /**
  10323. Manipulation before appling the strategy
  10324. @param view The target view
  10325. */
  10326. preApply(view: View): void;
  10327. /**
  10328. Function to apply this strategy
  10329. @param view view
  10330. @param designedResolution designedResolution
  10331. */
  10332. apply(view: View, designedResolution: Size): void;
  10333. /**
  10334. Manipulation after applying the strategy
  10335. @param view The target view
  10336. */
  10337. postApply(view: View): void;
  10338. }
  10339. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  10340. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  10341. export class ContentStrategy {
  10342. /**
  10343. Manipulation before applying the strategy
  10344. @param view The target view
  10345. */
  10346. preApply(view: View): void;
  10347. /**
  10348. Function to apply this strategy
  10349. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10350. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10351. @param view view
  10352. @param designedResolution designedResolution
  10353. */
  10354. apply(view: View, designedResolution: Size): any;
  10355. /**
  10356. Manipulation after applying the strategy
  10357. @param view The target view
  10358. */
  10359. postApply(view: View): void;
  10360. }
  10361. /** undefined */
  10362. export class EqualToFrame extends ContainerStrategy {
  10363. }
  10364. /** undefined */
  10365. export class ProportionalToFrame extends ContainerStrategy {
  10366. }
  10367. /** undefined */
  10368. export class EqualToWindow extends EqualToFrame {
  10369. }
  10370. /** undefined */
  10371. export class ProportionalToWindow extends ProportionalToFrame {
  10372. }
  10373. /** undefined */
  10374. export class OriginalContainer extends ContainerStrategy {
  10375. }
  10376. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  10377. its main task is to maintain the compatibility with Cocos2d-x</p> */
  10378. export class ResolutionPolicy {
  10379. /**
  10380. @param containerStg The container strategy
  10381. @param contentStg The content strategy
  10382. */
  10383. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  10384. /**
  10385. Manipulation before applying the resolution policy
  10386. @param view The target view
  10387. */
  10388. preApply(view: View): void;
  10389. /**
  10390. Function to apply this resolution policy
  10391. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10392. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10393. @param view The target view
  10394. @param designedResolution The user defined design resolution
  10395. */
  10396. apply(view: View, designedResolution: Size): any;
  10397. /**
  10398. Manipulation after appyling the strategy
  10399. @param view The target view
  10400. */
  10401. postApply(view: View): void;
  10402. /**
  10403. Setup the container's scale strategy
  10404. @param containerStg containerStg
  10405. */
  10406. setContainerStrategy(containerStg: ContainerStrategy): void;
  10407. /**
  10408. Setup the content's scale strategy
  10409. @param contentStg contentStg
  10410. */
  10411. setContentStrategy(contentStg: ContentStrategy): void;
  10412. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  10413. Distortion can occur, and the application may appear stretched or compressed. */
  10414. static EXACT_FIT: number;
  10415. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  10416. while maintaining the original aspect ratio of the application. */
  10417. static NO_BORDER: number;
  10418. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  10419. aspect ratio of the application. Borders can appear on two sides of the application. */
  10420. static SHOW_ALL: number;
  10421. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  10422. canvas so that it fits the aspect ratio of the device<br/>
  10423. no distortion will occur however you must make sure your application works on different<br/>
  10424. aspect ratios */
  10425. static FIXED_HEIGHT: number;
  10426. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  10427. canvas so that it fits the aspect ratio of the device<br/>
  10428. no distortion will occur however you must make sure your application works on different<br/>
  10429. aspect ratios */
  10430. static FIXED_WIDTH: number;
  10431. /** Unknow policy */
  10432. static UNKNOWN: number;
  10433. }
  10434. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  10435. it should represent the same rect as cc.view.getViewportRect() */
  10436. export class visibleRect {
  10437. /**
  10438. initialize
  10439. @param visibleRect visibleRect
  10440. */
  10441. init(visibleRect: Rect): void;
  10442. /** Top left coordinate of the screen related to the game scene. */
  10443. topLeft: Vec2;
  10444. /** Top right coordinate of the screen related to the game scene. */
  10445. topRight: Vec2;
  10446. /** Top center coordinate of the screen related to the game scene. */
  10447. top: Vec2;
  10448. /** Bottom left coordinate of the screen related to the game scene. */
  10449. bottomLeft: Vec2;
  10450. /** Bottom right coordinate of the screen related to the game scene. */
  10451. bottomRight: Vec2;
  10452. /** Bottom center coordinate of the screen related to the game scene. */
  10453. bottom: Vec2;
  10454. /** Center coordinate of the screen related to the game scene. */
  10455. center: Vec2;
  10456. /** Left center coordinate of the screen related to the game scene. */
  10457. left: Vec2;
  10458. /** Right center coordinate of the screen related to the game scene. */
  10459. right: Vec2;
  10460. /** Width of the screen. */
  10461. width: number;
  10462. /** Height of the screen. */
  10463. height: number;
  10464. }
  10465. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  10466. Subclasses should implement their own methods about how to invoke the callbacks. */
  10467. export class _CallbacksHandler {
  10468. /**
  10469. @param key key
  10470. @param callback callback
  10471. @param target can be null
  10472. */
  10473. add(key: string, callback: Function, target?: any): void;
  10474. /**
  10475. Check if the specified key has any registered callback. If a callback is also specified,
  10476. it will only return true if the callback is registered.
  10477. @param key key
  10478. @param callback callback
  10479. @param target target
  10480. */
  10481. has(key: string, callback?: Function, target?: any): boolean;
  10482. /**
  10483. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  10484. @param keyOrTarget The event key to be removed or the target to be removed
  10485. */
  10486. removeAll(keyOrTarget: string|any): void;
  10487. /**
  10488. @param key key
  10489. @param callback callback
  10490. @param target target
  10491. */
  10492. remove(key: string, callback: Function, target?: any): void;
  10493. }
  10494. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  10495. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  10496. export class CallbacksInvoker extends _CallbacksHandler {
  10497. /**
  10498. @param key key
  10499. @param p1 p1
  10500. @param p2 p2
  10501. @param p3 p3
  10502. @param p4 p4
  10503. @param p5 p5
  10504. */
  10505. invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void;
  10506. }
  10507. /** !#en Contains information collected during deserialization
  10508. !#zh 包含反序列化时的一些信息 */
  10509. export class Details {
  10510. /** list of the depends assets' uuid */
  10511. uuidList: string[];
  10512. /** the obj list whose field needs to load asset by uuid */
  10513. uuidObjList: any[];
  10514. /** the corresponding field name which referenced to the asset */
  10515. uuidPropList: string[];
  10516. /** the corresponding field name which referenced to the raw object */
  10517. rawProp: string;
  10518. reset(): void;
  10519. /**
  10520. @param obj obj
  10521. @param propName propName
  10522. */
  10523. getUuidOf(obj: any, propName: string): string;
  10524. /**
  10525. @param obj obj
  10526. @param propName propName
  10527. @param uuid uuid
  10528. */
  10529. push(obj: any, propName: string, uuid: string): void;
  10530. }
  10531. /** undefined */
  10532. export class url {
  10533. /**
  10534. Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  10535. @param url url
  10536. @example
  10537. ```js
  10538. ---
  10539. var url = cc.url.raw("textures/myTexture.png");
  10540. console.log(url); // "resources/raw/textures/myTexture.png"
  10541. ```
  10542. */
  10543. static raw(url: string): string;
  10544. /**
  10545. Returns the url of builtin raw assets. This method can only used in editor.
  10546. @param url url
  10547. @example
  10548. ```js
  10549. ---
  10550. var url = cc.url.builtinRaw("textures/myTexture.png");
  10551. console.log(url); // "resources/default-raw/textures/myTexture.png"
  10552. ```
  10553. */
  10554. static builtinRaw(url: string): string;
  10555. }
  10556. /** !#en
  10557. A cc.SpriteFrame has:<br/>
  10558. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  10559. - rectangle: A rectangle of the texture
  10560. !#zh
  10561. 一个 SpriteFrame 包含:<br/>
  10562. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  10563. - 矩形:在纹理中的矩形区域。 */
  10564. export class SpriteFrame extends Asset implements EventTarget {
  10565. /**
  10566. !#en
  10567. Constructor of SpriteFrame class.
  10568. !#zh
  10569. SpriteFrame 类的构造函数。
  10570. @param filename filename
  10571. @param rect rect
  10572. @param rotated Whether the frame is rotated in the texture
  10573. @param offset The offset of the frame in the texture
  10574. @param originalSize The size of the frame in the texture
  10575. */
  10576. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  10577. /** !#en Top border of the sprite
  10578. !#zh sprite 的顶部边框 */
  10579. insetTop: number;
  10580. /** !#en Bottom border of the sprite
  10581. !#zh sprite 的底部边框 */
  10582. insetBottom: number;
  10583. /** !#en Left border of the sprite
  10584. !#zh sprite 的左边边框 */
  10585. insetLeft: number;
  10586. /** !#en Right border of the sprite
  10587. !#zh sprite 的左边边框 */
  10588. insetRight: number;
  10589. /**
  10590. !#en Returns whether the texture have been loaded
  10591. !#zh 返回是否已加载纹理
  10592. */
  10593. textureLoaded(): boolean;
  10594. /**
  10595. Add a event listener for texture loaded event.
  10596. @param callback callback
  10597. @param target target
  10598. */
  10599. addLoadedEventListener(callback: Function, target: any): void;
  10600. /**
  10601. !#en Returns whether the sprite frame is rotated in the texture.
  10602. !#zh 获取 SpriteFrame 是否旋转
  10603. */
  10604. isRotated(): boolean;
  10605. /**
  10606. !#en Set whether the sprite frame is rotated in the texture.
  10607. !#zh 设置 SpriteFrame 是否旋转
  10608. @param bRotated bRotated
  10609. */
  10610. setRotated(bRotated: boolean): void;
  10611. /**
  10612. !#en Returns the rect of the sprite frame in the texture.
  10613. !#zh 获取 SpriteFrame 的纹理矩形区域
  10614. */
  10615. getRect(): Rect;
  10616. /**
  10617. !#en Sets the rect of the sprite frame in the texture.
  10618. !#zh 设置 SpriteFrame 的纹理矩形区域
  10619. @param rect rect
  10620. */
  10621. setRect(rect: Rect): void;
  10622. /**
  10623. !#en Returns the original size of the trimmed image.
  10624. !#zh 获取修剪前的原始大小
  10625. */
  10626. getOriginalSize(): Size;
  10627. /**
  10628. !#en Sets the original size of the trimmed image.
  10629. !#zh 设置修剪前的原始大小
  10630. @param size size
  10631. */
  10632. setOriginalSize(size: Size): void;
  10633. /**
  10634. !#en Returns the texture of the frame.
  10635. !#zh 获取使用的纹理实例
  10636. */
  10637. getTexture(): Texture2D;
  10638. /**
  10639. !#en Returns the offset of the frame in the texture.
  10640. !#zh 获取偏移量
  10641. */
  10642. getOffset(): Vec2;
  10643. /**
  10644. !#en Sets the offset of the frame in the texture.
  10645. !#zh 设置偏移量
  10646. @param offsets offsets
  10647. */
  10648. setOffset(offsets: Vec2): void;
  10649. /**
  10650. !#en Clone the sprite frame.
  10651. !#zh 克隆 SpriteFrame
  10652. */
  10653. clone(): SpriteFrame;
  10654. /**
  10655. #en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  10656. #zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame
  10657. @param textureOrTextureFile textureOrTextureFile
  10658. @param rect rect
  10659. @param rotated rotated
  10660. @param offset offset
  10661. @param originalSize originalSize
  10662. */
  10663. setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  10664. /**
  10665. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  10666. associated by user's custom Components in the scene, will not preload automatically.
  10667. These textures will be load when Sprite component is going to render the SpriteFrames.
  10668. You can call this method if you want to load the texture early.
  10669. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  10670. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  10671. @example
  10672. ```js
  10673. if (spriteFrame.textureLoaded()) {
  10674. this._onSpriteFrameLoaded();
  10675. }
  10676. else {
  10677. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  10678. spriteFrame.ensureLoadTexture();
  10679. }
  10680. ```
  10681. */
  10682. ensureLoadTexture(): void;
  10683. /**
  10684. !#en
  10685. 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.
  10686. !#zh
  10687. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  10688. @example
  10689. ```js
  10690. spriteFrame.clearTexture();
  10691. // when you need the SpriteFrame again...
  10692. spriteFrame.once('load', onSpriteFrameLoaded);
  10693. spriteFrame.ensureLoadTexture();
  10694. ```
  10695. */
  10696. clearTexture(): void;
  10697. /**
  10698. !#en
  10699. Register an callback of a specific event type on the EventTarget.
  10700. !#zh
  10701. 注册事件目标的特定事件类型回调。
  10702. @param type A string representing the event type to listen for.
  10703. @param callback The callback that will be invoked when the event is dispatched.
  10704. The callback is ignored if it is a duplicate (the callbacks are unique).
  10705. @param target The target (this object) to invoke the callback, can be null
  10706. @param useCapture When set to true, the capture argument prevents callback
  10707. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  10708. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  10709. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  10710. @example
  10711. ```js
  10712. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10713. cc.log("this is callback");
  10714. }, node);
  10715. ```
  10716. */
  10717. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  10718. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  10719. /**
  10720. !#en
  10721. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10722. if only type is passed as parameter, all listeners registered with that type will be removed.
  10723. !#zh
  10724. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10725. @param type A string representing the event type being removed.
  10726. @param callback The callback to remove.
  10727. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10728. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  10729. If not specified, useCapture defaults to false. If a callback was registered twice,
  10730. one with capture and one without, each must be removed separately. Removal of a capturing callback
  10731. does not affect a non-capturing version of the same listener, and vice versa.
  10732. @example
  10733. ```js
  10734. // register touchEnd eventListener
  10735. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10736. cc.log("this is callback");
  10737. }, node);
  10738. // remove touch end event listener
  10739. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  10740. // remove all touch end event listeners
  10741. node.off(cc.Node.EventType.TOUCH_END);
  10742. ```
  10743. */
  10744. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  10745. /**
  10746. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10747. This is not for removing all listeners in the current event target,
  10748. and this is not for removing all listeners the target parameter have registered.
  10749. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10750. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10751. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10752. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10753. @param target The target to be searched for all related listeners
  10754. */
  10755. targetOff(target: any): void;
  10756. /**
  10757. !#en
  10758. Register an callback of a specific event type on the EventTarget,
  10759. the callback will remove itself after the first time it is triggered.
  10760. !#zh
  10761. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  10762. @param type A string representing the event type to listen for.
  10763. @param callback The callback that will be invoked when the event is dispatched.
  10764. The callback is ignored if it is a duplicate (the callbacks are unique).
  10765. @param target The target (this object) to invoke the callback, can be null
  10766. @param useCapture When set to true, the capture argument prevents callback
  10767. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  10768. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  10769. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  10770. @example
  10771. ```js
  10772. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  10773. cc.log("this is callback");
  10774. }, node);
  10775. ```
  10776. */
  10777. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  10778. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  10779. /**
  10780. !#en
  10781. Dispatches an event into the event flow.
  10782. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  10783. !#zh 分发事件到事件流中。
  10784. @param event The Event object that is dispatched into the event flow
  10785. */
  10786. dispatchEvent(event: Event): void;
  10787. /**
  10788. !#en
  10789. Send an event to this object directly, this method will not propagate the event to any other objects.
  10790. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  10791. !#zh
  10792. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  10793. @param message the message to send
  10794. @param detail whatever argument the message needs
  10795. */
  10796. emit(message: string, detail?: any): void;
  10797. }
  10798. /** <p>
  10799. This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
  10800. The created cc.Texture2D object will always have power-of-two dimensions. <br/>
  10801. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  10802. i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
  10803. Be aware that the content of the generated textures will be upside-down! </p> */
  10804. export class Texture2D extends RawAsset implements EventTarget {
  10805. /** !#en
  10806. The url of the texture, this coule be empty if the texture wasn't created via a file.
  10807. !#zh
  10808. 贴图文件的 url,当贴图不是由文件创建时值可能为空 */
  10809. url: string;
  10810. /** !#en
  10811. Whether the texture is loaded or not
  10812. !#zh
  10813. 贴图是否已经成功加载 */
  10814. loaded: boolean;
  10815. /** !#en
  10816. Texture width in pixel
  10817. !#zh
  10818. 贴图像素宽度 */
  10819. width: number;
  10820. /** !#en
  10821. Texture height in pixel
  10822. !#zh
  10823. 贴图像素高度 */
  10824. height: number;
  10825. /**
  10826. Update texture options, not available in Canvas render mode.
  10827. image, format, premultiplyAlpha can not be updated in native.
  10828. @param options options
  10829. */
  10830. update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  10831. /**
  10832. Get width in pixels.
  10833. */
  10834. getPixelWidth(): number;
  10835. /**
  10836. Get height of in pixels.
  10837. */
  10838. getPixelHeight(): number;
  10839. /**
  10840. Get content size.
  10841. */
  10842. getContentSize(): Size;
  10843. /**
  10844. Get content size in pixels.
  10845. */
  10846. getContentSizeInPixels(): Size;
  10847. /**
  10848. Init with HTML element.
  10849. @param element element
  10850. @example
  10851. ```js
  10852. var img = new Image();
  10853. img.src = dataURL;
  10854. texture.initWithElement(img);
  10855. texture.handleLoadedTexture();
  10856. ```
  10857. */
  10858. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  10859. /**
  10860. Intializes with a texture2d with data.
  10861. @param data data
  10862. @param pixelFormat pixelFormat
  10863. @param pixelsWidth pixelsWidth
  10864. @param pixelsHeight pixelsHeight
  10865. @param contentSize contentSize
  10866. */
  10867. initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean;
  10868. /**
  10869. Initializes a texture from a UIImage object.
  10870. Extensions to make it easy to create a CCTexture2D object from an image file.
  10871. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  10872. @param uiImage uiImage
  10873. */
  10874. initWithImage(uiImage: HTMLImageElement): boolean;
  10875. /**
  10876. HTMLElement Object getter, available only on web.
  10877. 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.
  10878. */
  10879. getHtmlElementObj(): HTMLImageElement;
  10880. /**
  10881. Check whether texture is loaded.
  10882. */
  10883. isLoaded(): boolean;
  10884. /**
  10885. Handler of texture loaded event.
  10886. @param premultiplied premultiplied
  10887. */
  10888. handleLoadedTexture(premultiplied?: boolean): void;
  10889. /**
  10890. Description of cc.Texture2D.
  10891. */
  10892. description(): string;
  10893. /**
  10894. Release texture.
  10895. */
  10896. releaseTexture(): void;
  10897. /**
  10898. Pixel format of the texture.
  10899. */
  10900. getPixelFormat(): number;
  10901. /**
  10902. Whether or not the texture has their Alpha premultiplied,
  10903. support only in WebGl rendering mode.
  10904. */
  10905. hasPremultipliedAlpha(): boolean;
  10906. /**
  10907. Whether or not use mipmap, support only in WebGl rendering mode.
  10908. */
  10909. hasMipmaps(): boolean;
  10910. /**
  10911. Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  10912. 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}.
  10913. @param texParams texParams object or minFilter
  10914. @param magFilter magFilter
  10915. @param wrapS wrapS
  10916. @param wrapT wrapT
  10917. */
  10918. setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void;
  10919. /**
  10920. sets antialias texture parameters: <br/>
  10921. - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  10922. - GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  10923. supported only in native or WebGl rendering mode
  10924. */
  10925. setAntiAliasTexParameters(): void;
  10926. /**
  10927. Sets alias texture parameters: <br/>
  10928. GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  10929. GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  10930. supported only in native or WebGl rendering mode
  10931. */
  10932. setAliasTexParameters(): void;
  10933. /** Pixel format of the texture. */
  10934. pixelFormat: number;
  10935. /** Width in pixels. */
  10936. pixelWidth: number;
  10937. /** Height in pixels. */
  10938. pixelHeight: number;
  10939. /**
  10940. !#en
  10941. Register an callback of a specific event type on the EventTarget.
  10942. !#zh
  10943. 注册事件目标的特定事件类型回调。
  10944. @param type A string representing the event type to listen for.
  10945. @param callback The callback that will be invoked when the event is dispatched.
  10946. The callback is ignored if it is a duplicate (the callbacks are unique).
  10947. @param target The target (this object) to invoke the callback, can be null
  10948. @param useCapture When set to true, the capture argument prevents callback
  10949. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  10950. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  10951. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  10952. @example
  10953. ```js
  10954. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10955. cc.log("this is callback");
  10956. }, node);
  10957. ```
  10958. */
  10959. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  10960. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  10961. /**
  10962. !#en
  10963. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  10964. if only type is passed as parameter, all listeners registered with that type will be removed.
  10965. !#zh
  10966. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  10967. @param type A string representing the event type being removed.
  10968. @param callback The callback to remove.
  10969. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  10970. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  10971. If not specified, useCapture defaults to false. If a callback was registered twice,
  10972. one with capture and one without, each must be removed separately. Removal of a capturing callback
  10973. does not affect a non-capturing version of the same listener, and vice versa.
  10974. @example
  10975. ```js
  10976. // register touchEnd eventListener
  10977. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  10978. cc.log("this is callback");
  10979. }, node);
  10980. // remove touch end event listener
  10981. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  10982. // remove all touch end event listeners
  10983. node.off(cc.Node.EventType.TOUCH_END);
  10984. ```
  10985. */
  10986. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  10987. /**
  10988. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  10989. This is not for removing all listeners in the current event target,
  10990. and this is not for removing all listeners the target parameter have registered.
  10991. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  10992. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  10993. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  10994. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  10995. @param target The target to be searched for all related listeners
  10996. */
  10997. targetOff(target: any): void;
  10998. /**
  10999. !#en
  11000. Register an callback of a specific event type on the EventTarget,
  11001. the callback will remove itself after the first time it is triggered.
  11002. !#zh
  11003. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11004. @param type A string representing the event type to listen for.
  11005. @param callback The callback that will be invoked when the event is dispatched.
  11006. The callback is ignored if it is a duplicate (the callbacks are unique).
  11007. @param target The target (this object) to invoke the callback, can be null
  11008. @param useCapture When set to true, the capture argument prevents callback
  11009. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11010. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11011. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11012. @example
  11013. ```js
  11014. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11015. cc.log("this is callback");
  11016. }, node);
  11017. ```
  11018. */
  11019. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11020. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11021. /**
  11022. !#en
  11023. Dispatches an event into the event flow.
  11024. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11025. !#zh 分发事件到事件流中。
  11026. @param event The Event object that is dispatched into the event flow
  11027. */
  11028. dispatchEvent(event: Event): void;
  11029. /**
  11030. !#en
  11031. Send an event to this object directly, this method will not propagate the event to any other objects.
  11032. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11033. !#zh
  11034. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11035. @param message the message to send
  11036. @param detail whatever argument the message needs
  11037. */
  11038. emit(message: string, detail?: any): void;
  11039. }
  11040. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  11041. export class textureCache {
  11042. /**
  11043. Description
  11044. */
  11045. static description(): string;
  11046. /**
  11047. Returns an already created texture. Returns null if the texture doesn't exist.
  11048. @param textureKeyName textureKeyName
  11049. @example
  11050. ```js
  11051. ------------------
  11052. var key = cc.textureCache.textureForKey("hello.png");
  11053. ```
  11054. */
  11055. static textureForKey(textureKeyName: string): Texture2D;
  11056. /**
  11057. Returns an already created texture. Returns null if the texture doesn't exist.
  11058. @param textureKeyName textureKeyName
  11059. @example
  11060. ```js
  11061. ------------------
  11062. var key = cc.textureCache.getTextureForKey("hello.png");
  11063. ```
  11064. */
  11065. static getTextureForKey(textureKeyName: string): Texture2D;
  11066. /**
  11067. @param texture texture
  11068. @example
  11069. ```js
  11070. ---------------
  11071. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  11072. ```
  11073. */
  11074. static getTextureColors(texture: HTMLImageElement): any[];
  11075. /**
  11076. #en get all textures
  11077. #zh 获取所有贴图
  11078. */
  11079. static getAllTextures(): Texture2D[];
  11080. /**
  11081. <p>Purges the dictionary of loaded textures. <br />
  11082. Call this method if you receive the "Memory Warning" <br />
  11083. In the short term: it will free some resources preventing your app from being killed <br />
  11084. In the medium term: it will allocate more resources <br />
  11085. In the long term: it will be the same</p>
  11086. @example
  11087. ```js
  11088. --------
  11089. cc.textureCache.removeAllTextures();
  11090. ```
  11091. */
  11092. static removeAllTextures(): void;
  11093. /**
  11094. Deletes a texture from the cache given a texture.
  11095. @param texture texture
  11096. @example
  11097. ```js
  11098. -----
  11099. cc.textureCache.removeTexture(texture);
  11100. ```
  11101. */
  11102. static removeTexture(texture: HTMLImageElement): void;
  11103. /**
  11104. Deletes a texture from the cache given a its key name.
  11105. @param textureKeyName textureKeyName
  11106. @example
  11107. ```js
  11108. ------
  11109. cc.textureCache.removeTexture("hello.png");
  11110. ```
  11111. */
  11112. static removeTextureForKey(textureKeyName: string): void;
  11113. /**
  11114. <p>Returns a Texture2D object given an file image <br />
  11115. If the file image was not previously loaded, it will create a new Texture2D <br />
  11116. object and it will return it. It will use the filename as a key.<br />
  11117. Otherwise it will return a reference of a previously loaded image. <br />
  11118. Supported image extensions: .png, .jpg, .gif</p>
  11119. @param url url
  11120. @param cb cb
  11121. @param target target
  11122. @example
  11123. ```js
  11124. ----
  11125. cc.textureCache.addImage("hello.png");
  11126. ```
  11127. */
  11128. static addImage(url: string, cb: Function, target: any): Texture2D;
  11129. /**
  11130. Cache the image data.
  11131. @param path path
  11132. @param texture texture
  11133. */
  11134. static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void;
  11135. }
  11136. /** A base node for CCNode, it will:
  11137. - maintain scene hierarchy and active logic
  11138. - notifications if some properties changed
  11139. - define some interfaces shares between CCNode
  11140. - define machanisms for Enity Component Systems
  11141. - define prefab and serialize functions */
  11142. export class _BaseNode extends Object implements EventTarget {
  11143. /** !#en Name of node.
  11144. !#zh 该节点名称。 */
  11145. name: string;
  11146. /** !#en The uuid for editor, will be stripped before building project.
  11147. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  11148. uuid: string;
  11149. /** !#en All children nodes.
  11150. !#zh 节点的所有子节点。 */
  11151. children: Node[];
  11152. /** !#en All children nodes.
  11153. !#zh 节点的子节点数量。 */
  11154. childrenCount: number;
  11155. /** !#en
  11156. The local active state of this node.<br/>
  11157. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  11158. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  11159. !#zh
  11160. 当前节点的自身激活状态。<br/>
  11161. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  11162. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  11163. active: boolean;
  11164. /** !#en Indicates whether this node is active in the scene.
  11165. !#zh 表示此节点是否在场景中激活。 */
  11166. activeInHierarchy: boolean;
  11167. /** !#en Tag of node.
  11168. !#zh 节点标签。 */
  11169. tag: number;
  11170. /**
  11171. @param name name
  11172. */
  11173. constructor(name?: string);
  11174. /** !#en The parent of the node.
  11175. !#zh 该节点的父节点。 */
  11176. parent: Node;
  11177. /**
  11178. !#en
  11179. Properties configuration function </br>
  11180. All properties in attrs will be set to the node, </br>
  11181. when the setter of the node is available, </br>
  11182. the property will be set via setter function.</br>
  11183. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  11184. @param attrs Properties to be set to node
  11185. @example
  11186. ```js
  11187. var attrs = { key: 0, num: 100 };
  11188. node.attr(attrs);
  11189. ```
  11190. */
  11191. attr(attrs: any): void;
  11192. /**
  11193. !#en Returns a child from the container given its tag.
  11194. !#zh 通过标签获取节点的子节点。
  11195. @param aTag An identifier to find the child node.
  11196. @example
  11197. ```js
  11198. var child = node.getChildByTag(1001);
  11199. ```
  11200. */
  11201. getChildByTag(aTag: number): Node;
  11202. /**
  11203. !#en Returns a child from the container given its uuid.
  11204. !#zh 通过 uuid 获取节点的子节点。
  11205. @param uuid The uuid to find the child node.
  11206. @example
  11207. ```js
  11208. var child = node.getChildByUuid(uuid);
  11209. ```
  11210. */
  11211. getChildByUuid(uuid: string): Node;
  11212. /**
  11213. !#en Returns a child from the container given its name.
  11214. !#zh 通过名称获取节点的子节点。
  11215. @param name A name to find the child node.
  11216. @example
  11217. ```js
  11218. var child = node.getChildByName("Test Node");
  11219. ```
  11220. */
  11221. getChildByName(name: string): Node;
  11222. /**
  11223. !#en
  11224. Inserts a child to the node at a specified index.
  11225. !#zh
  11226. 插入子节点到指定位置
  11227. @param child the child node to be inserted
  11228. @param siblingIndex the sibling index to place the child in
  11229. @example
  11230. ```js
  11231. node.insertChild(child, 2);
  11232. ```
  11233. */
  11234. insertChild(child: Node, siblingIndex: number): void;
  11235. /**
  11236. !#en Get the sibling index.
  11237. !#zh 获取同级索引。
  11238. @example
  11239. ```js
  11240. var index = node.getSiblingIndex();
  11241. ```
  11242. */
  11243. getSiblingIndex(): number;
  11244. /**
  11245. !#en Set the sibling index of this node.
  11246. !#zh 设置节点同级索引。
  11247. @param index index
  11248. @example
  11249. ```js
  11250. node.setSiblingIndex(1);
  11251. ```
  11252. */
  11253. setSiblingIndex(index: number): void;
  11254. /**
  11255. !#en
  11256. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  11257. 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/>
  11258. If the node orphan, then nothing happens.
  11259. !#zh
  11260. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  11261. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  11262. 如果这个节点是一个孤节点,那么什么都不会发生。
  11263. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  11264. @example
  11265. ```js
  11266. node.removeFromParent();
  11267. node.removeFromParent(false);
  11268. ```
  11269. */
  11270. removeFromParent(cleanup?: boolean): void;
  11271. /**
  11272. !#en
  11273. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  11274. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11275. "remove" logic MUST only be on this method <br/>
  11276. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  11277. to override this method.
  11278. !#zh
  11279. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11280. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  11281. @param child The child node which will be removed.
  11282. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11283. @example
  11284. ```js
  11285. node.removeChild(newNode);
  11286. node.removeChild(newNode, false);
  11287. ```
  11288. */
  11289. removeChild(child: Node, cleanup?: boolean): void;
  11290. /**
  11291. !#en
  11292. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  11293. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11294. !#zh
  11295. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11296. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11297. @param tag An integer number that identifies a child node
  11298. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11299. @example
  11300. ```js
  11301. node.removeChildByTag(1001);
  11302. node.removeChildByTag(1001, false);
  11303. ```
  11304. */
  11305. removeChildByTag(tag: number, cleanup?: boolean): void;
  11306. /**
  11307. !#en
  11308. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  11309. If the cleanup parameter is not passed, it will force a cleanup.
  11310. !#zh
  11311. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11312. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11313. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  11314. @example
  11315. ```js
  11316. node.removeAllChildren();
  11317. node.removeAllChildren(false);
  11318. ```
  11319. */
  11320. removeAllChildren(cleanup?: boolean): void;
  11321. /**
  11322. !#en Is this node a child of the given node?
  11323. !#zh 是否是指定节点的子节点?
  11324. @param parent parent
  11325. @example
  11326. ```js
  11327. node.isChildOf(newNode);
  11328. ```
  11329. */
  11330. isChildOf(parent: Node): boolean;
  11331. /**
  11332. !#en
  11333. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  11334. You can also get component in the node by passing in the name of the script.
  11335. !#zh
  11336. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  11337. 传入参数也可以是脚本的名称。
  11338. @param typeOrClassName typeOrClassName
  11339. @example
  11340. ```js
  11341. // get sprite component.
  11342. var sprite = node.getComponent(cc.Sprite);
  11343. // get custom test calss.
  11344. var test = node.getComponent("Test");
  11345. ```
  11346. */
  11347. getComponent<T extends Component>(type: {prototype: T}): T;
  11348. getComponent(className: string): any;
  11349. /**
  11350. !#en Returns all components of supplied type in the node.
  11351. !#zh 返回节点上指定类型的所有组件。
  11352. @param typeOrClassName typeOrClassName
  11353. @example
  11354. ```js
  11355. var sprites = node.getComponents(cc.Sprite);
  11356. var tests = node.getComponents("Test");
  11357. ```
  11358. */
  11359. getComponents<T extends Component>(type: {prototype: T}): T[];
  11360. getComponents(className: string): any[];
  11361. /**
  11362. !#en Returns the component of supplied type in any of its children using depth first search.
  11363. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  11364. @param typeOrClassName typeOrClassName
  11365. @example
  11366. ```js
  11367. var sprite = node.getComponentInChildren(cc.Sprite);
  11368. var Test = node.getComponentInChildren("Test");
  11369. ```
  11370. */
  11371. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  11372. getComponentInChildren(className: string): any;
  11373. /**
  11374. !#en Returns all components of supplied type in self or any of its children.
  11375. !#zh 递归查找自身或所有子节点中指定类型的组件
  11376. @param typeOrClassName typeOrClassName
  11377. @example
  11378. ```js
  11379. var sprites = node.getComponentsInChildren(cc.Sprite);
  11380. var tests = node.getComponentsInChildren("Test");
  11381. ```
  11382. */
  11383. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  11384. getComponentsInChildren(className: string): any[];
  11385. /**
  11386. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  11387. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  11388. @param typeOrClassName The constructor or the class name of the component to add
  11389. @example
  11390. ```js
  11391. var sprite = node.addComponent(cc.Sprite);
  11392. var test = node.addComponent("Test");
  11393. ```
  11394. */
  11395. addComponent<T extends Component>(type: {new(): T}): T;
  11396. addComponent(className: string): any;
  11397. /**
  11398. !#en
  11399. Removes a component identified by the given name or removes the component object given.
  11400. You can also use component.destroy() if you already have the reference.
  11401. !#zh
  11402. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  11403. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  11404. @param component The need remove component.
  11405. @example
  11406. ```js
  11407. node.removeComponent(cc.Sprite);
  11408. var Test = require("Test");
  11409. node.removeComponent(Test);
  11410. ```
  11411. */
  11412. removeComponent(component: string|Function|Component): void;
  11413. /**
  11414. !#en
  11415. Destroy all children from the node, and release all their own references to other objects.<br/>
  11416. Actual destruct operation will delayed until before rendering.
  11417. !#zh
  11418. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  11419. 实际销毁操作会延迟到当前帧渲染前执行。
  11420. @example
  11421. ```js
  11422. node.destroyAllChildren();
  11423. ```
  11424. */
  11425. destroyAllChildren(): void;
  11426. /**
  11427. !#en
  11428. Register an callback of a specific event type on the EventTarget.
  11429. !#zh
  11430. 注册事件目标的特定事件类型回调。
  11431. @param type A string representing the event type to listen for.
  11432. @param callback The callback that will be invoked when the event is dispatched.
  11433. The callback is ignored if it is a duplicate (the callbacks are unique).
  11434. @param target The target (this object) to invoke the callback, can be null
  11435. @param useCapture When set to true, the capture argument prevents callback
  11436. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11437. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11438. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11439. @example
  11440. ```js
  11441. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11442. cc.log("this is callback");
  11443. }, node);
  11444. ```
  11445. */
  11446. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11447. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11448. /**
  11449. !#en
  11450. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11451. if only type is passed as parameter, all listeners registered with that type will be removed.
  11452. !#zh
  11453. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11454. @param type A string representing the event type being removed.
  11455. @param callback The callback to remove.
  11456. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11457. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11458. If not specified, useCapture defaults to false. If a callback was registered twice,
  11459. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11460. does not affect a non-capturing version of the same listener, and vice versa.
  11461. @example
  11462. ```js
  11463. // register touchEnd eventListener
  11464. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11465. cc.log("this is callback");
  11466. }, node);
  11467. // remove touch end event listener
  11468. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11469. // remove all touch end event listeners
  11470. node.off(cc.Node.EventType.TOUCH_END);
  11471. ```
  11472. */
  11473. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11474. /**
  11475. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11476. This is not for removing all listeners in the current event target,
  11477. and this is not for removing all listeners the target parameter have registered.
  11478. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11479. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11480. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11481. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11482. @param target The target to be searched for all related listeners
  11483. */
  11484. targetOff(target: any): void;
  11485. /**
  11486. !#en
  11487. Register an callback of a specific event type on the EventTarget,
  11488. the callback will remove itself after the first time it is triggered.
  11489. !#zh
  11490. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11491. @param type A string representing the event type to listen for.
  11492. @param callback The callback that will be invoked when the event is dispatched.
  11493. The callback is ignored if it is a duplicate (the callbacks are unique).
  11494. @param target The target (this object) to invoke the callback, can be null
  11495. @param useCapture When set to true, the capture argument prevents callback
  11496. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11497. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11498. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11499. @example
  11500. ```js
  11501. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11502. cc.log("this is callback");
  11503. }, node);
  11504. ```
  11505. */
  11506. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11507. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11508. /**
  11509. !#en
  11510. Dispatches an event into the event flow.
  11511. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11512. !#zh 分发事件到事件流中。
  11513. @param event The Event object that is dispatched into the event flow
  11514. */
  11515. dispatchEvent(event: Event): void;
  11516. /**
  11517. !#en
  11518. Send an event to this object directly, this method will not propagate the event to any other objects.
  11519. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11520. !#zh
  11521. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11522. @param message the message to send
  11523. @param detail whatever argument the message needs
  11524. */
  11525. emit(message: string, detail?: any): void;
  11526. }
  11527. /** !#en
  11528. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  11529. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  11530. !#zh
  11531. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  11532. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  11533. export class AffineTransform {
  11534. /**
  11535. !#en Create a cc.AffineTransform object with all contents in the matrix.
  11536. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  11537. @param a a
  11538. @param b b
  11539. @param c c
  11540. @param d d
  11541. @param tx tx
  11542. @param ty ty
  11543. */
  11544. affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  11545. /**
  11546. !#en Clone a cc.AffineTransform object from the specified transform.
  11547. !#zh 克隆指定的 cc.AffineTransform 对象。
  11548. @param t t
  11549. */
  11550. affineTransformClone(t: AffineTransform): AffineTransform;
  11551. /**
  11552. !#en Apply the affine transformation on a point.
  11553. !#zh 对一个点应用矩阵变换。
  11554. @param point or x.
  11555. @param transOrY transform matrix or y.
  11556. @param t transform matrix or y.
  11557. */
  11558. pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2;
  11559. /**
  11560. !#en Apply the affine transformation on a size.
  11561. !#zh 应用 Size 到仿射变换矩阵上。
  11562. @param size size
  11563. @param t t
  11564. */
  11565. sizeApplyAffineTransform(size: Size, t: AffineTransform): Size;
  11566. /**
  11567. !#en
  11568. Create a identity transformation matrix: <br/>
  11569. [ 1, 0, 0, <br/>
  11570. 0, 1, 0 ]
  11571. !#zh
  11572. 单位矩阵:<br/>
  11573. [ 1, 0, 0, <br/>
  11574. 0, 1, 0 ]
  11575. */
  11576. affineTransformMakeIdentity(): AffineTransform;
  11577. /**
  11578. !#en Apply the affine transformation on a rect.
  11579. !#zh 应用 Rect 到仿射变换矩阵上。
  11580. @param rect rect
  11581. @param anAffineTransform anAffineTransform
  11582. */
  11583. rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect;
  11584. /**
  11585. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  11586. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  11587. @param rect rect
  11588. @param anAffineTransform anAffineTransform
  11589. @param out_bl out_bl
  11590. @param out_tl out_tl
  11591. @param out_tr out_tr
  11592. @param out_br out_br
  11593. */
  11594. obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void;
  11595. /**
  11596. !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  11597. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  11598. @param t The base affine transform object.
  11599. @param tx The translation on x axis.
  11600. @param ty The translation on y axis.
  11601. */
  11602. affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform;
  11603. /**
  11604. !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  11605. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  11606. @param t The base affine transform object.
  11607. @param sx The scale on x axis.
  11608. @param sy The scale on y axis.
  11609. */
  11610. affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform;
  11611. /**
  11612. !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  11613. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  11614. @param aTransform The base affine transform object.
  11615. @param anAngle The angle to rotate.
  11616. */
  11617. affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform;
  11618. /**
  11619. !#en
  11620. Concatenate a transform matrix to another and return the result:<br/>
  11621. t' = t1 * t2
  11622. !#zh 拼接两个矩阵,并返回结果:<br/>
  11623. t' = t1 * t2
  11624. @param t1 The first transform object.
  11625. @param t2 The transform object to concatenate.
  11626. */
  11627. affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11628. /**
  11629. !#en
  11630. Concatenate a transform matrix to another<br/>
  11631. The results are reflected in the first matrix.<br/>
  11632. t' = t1 * t2
  11633. !#zh
  11634. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  11635. t' = t1 * t2
  11636. @param t1 The first transform object.
  11637. @param t2 The transform object to concatenate.
  11638. */
  11639. affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  11640. /**
  11641. !#en Return true if an affine transform equals to another, false otherwise.
  11642. !#zh 判断两个矩阵是否相等。
  11643. @param t1 t1
  11644. @param t2 t2
  11645. */
  11646. affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean;
  11647. /**
  11648. !#en Get the invert transform of an AffineTransform object.
  11649. !#zh 求逆矩阵。
  11650. @param t t
  11651. */
  11652. affineTransformInvert(t: AffineTransform): AffineTransform;
  11653. /**
  11654. !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
  11655. !#zh 求逆矩阵并存入用户传入的矩阵对象参数。
  11656. @param t t
  11657. @param out out
  11658. */
  11659. affineTransformInvert(t: AffineTransform, out: AffineTransform): void;
  11660. }
  11661. /** !#en
  11662. Representation of RGBA colors.
  11663. Each color component is a floating point value with a range from 0 to 255.
  11664. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  11665. !#zh
  11666. cc.Color 用于表示颜色。
  11667. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  11668. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  11669. export class Color extends ValueType {
  11670. /**
  11671. @param r red component of the color, default value is 0.
  11672. @param g green component of the color, defualt value is 0.
  11673. @param b blue component of the color, default value is 0.
  11674. @param a alpha component of the color, default value is 255.
  11675. */
  11676. constructor(r?: number, g?: number, b?: number, a?: number);
  11677. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  11678. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  11679. static WHITE: Color;
  11680. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  11681. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  11682. static BLACK: Color;
  11683. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  11684. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  11685. static TRANSPARENT: Color;
  11686. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  11687. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  11688. static GRAY: Color;
  11689. /** !#en Solid red, RGBA is [255, 0, 0].
  11690. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  11691. static RED: Color;
  11692. /** !#en Solid green, RGBA is [0, 255, 0].
  11693. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  11694. static GREEN: Color;
  11695. /** !#en Solid blue, RGBA is [0, 0, 255].
  11696. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  11697. static BLUE: Color;
  11698. /** !#en Yellow, RGBA is [255, 235, 4].
  11699. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  11700. static YELLOW: Color;
  11701. /** !#en Orange, RGBA is [255, 127, 0].
  11702. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  11703. static ORANGE: Color;
  11704. /** !#en Cyan, RGBA is [0, 255, 255].
  11705. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  11706. static CYAN: Color;
  11707. /** !#en Magenta, RGBA is [255, 0, 255].
  11708. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  11709. static MAGENTA: Color;
  11710. /**
  11711. !#en Clone a new color from the current color.
  11712. !#zh 克隆当前颜色。
  11713. @example
  11714. ```js
  11715. var color = new cc.Color();
  11716. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  11717. ```
  11718. */
  11719. clone(): Color;
  11720. /**
  11721. !#en TODO
  11722. !#zh 判断两个颜色是否相等。
  11723. @param other other
  11724. @example
  11725. ```js
  11726. var color1 = cc.Color.WHITE;
  11727. var color2 = new cc.Color(255, 255, 255);
  11728. cc.log(color1.equals(color2)); // true;
  11729. color2 = cc.Color.RED;
  11730. cc.log(color2.equals(color1)); // false;
  11731. ```
  11732. */
  11733. equals(other: Color): boolean;
  11734. /**
  11735. !#en TODO
  11736. !#zh 线性插值
  11737. @param to to
  11738. @param ratio the interpolation coefficient.
  11739. @param out optional, the receiving vector.
  11740. @example
  11741. ```js
  11742. // Converts a white color to a black one trough time.
  11743. update: function (dt) {
  11744. var color = this.node.color;
  11745. if (color.equals(cc.Color.BLACK)) {
  11746. return;
  11747. }
  11748. this.ratio += dt * 0.1;
  11749. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  11750. }
  11751. ```
  11752. */
  11753. lerp(to: Color, ratio: number, out?: Color): Color;
  11754. /**
  11755. !#en TODO
  11756. !#zh 转换为方便阅读的字符串。
  11757. @example
  11758. ```js
  11759. var color = cc.Color.WHITE;
  11760. color.toString(); // "rgba(255, 255, 255, 255)"
  11761. ```
  11762. */
  11763. toString(): string;
  11764. /**
  11765. !#en Gets red channel value
  11766. !#zh 获取当前颜色的红色值。
  11767. */
  11768. getR(): number;
  11769. /**
  11770. !#en Sets red value and return the current color object
  11771. !#zh 设置当前的红色值,并返回当前对象。
  11772. @param red the new Red component.
  11773. @example
  11774. ```js
  11775. var color = new cc.Color();
  11776. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  11777. ```
  11778. */
  11779. setR(red: number): Color;
  11780. /**
  11781. !#en Gets green channel value
  11782. !#zh 获取当前颜色的绿色值。
  11783. */
  11784. getG(): number;
  11785. /**
  11786. !#en Sets green value and return the current color object
  11787. !#zh 设置当前的绿色值,并返回当前对象。
  11788. @param green the new Green component.
  11789. @example
  11790. ```js
  11791. var color = new cc.Color();
  11792. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  11793. ```
  11794. */
  11795. setG(green: number): Color;
  11796. /**
  11797. !#en Gets blue channel value
  11798. !#zh 获取当前颜色的蓝色值。
  11799. */
  11800. getB(): number;
  11801. /**
  11802. !#en Sets blue value and return the current color object
  11803. !#zh 设置当前的蓝色值,并返回当前对象。
  11804. @param blue the new Blue component.
  11805. @example
  11806. ```js
  11807. var color = new cc.Color();
  11808. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  11809. ```
  11810. */
  11811. setB(blue: number): Color;
  11812. /**
  11813. !#en Gets alpha channel value
  11814. !#zh 获取当前颜色的透明度值。
  11815. */
  11816. getA(): number;
  11817. /**
  11818. !#en Sets alpha value and return the current color object
  11819. !#zh 设置当前的透明度,并返回当前对象。
  11820. @param alpha the new Alpha component.
  11821. @example
  11822. ```js
  11823. var color = new cc.Color();
  11824. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  11825. ```
  11826. */
  11827. setA(alpha: number): Color;
  11828. /**
  11829. !#en Convert color to css format.
  11830. !#zh 转换为 CSS 格式。
  11831. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  11832. @example
  11833. ```js
  11834. var color = cc.Color.BLACK;
  11835. color.toCSS(); // "#000";
  11836. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  11837. color.toCSS("rgb"); // "rgba(0,0,0)";
  11838. color.toCSS("#rgb"); // "#000";
  11839. color.toCSS("#rrggbb"); // "#000000";
  11840. ```
  11841. */
  11842. toCSS(opt: string): string;
  11843. /**
  11844. !#en Clamp this color to make all components between 0 to 255。
  11845. !#zh 限制颜色数值,在 0 到 255 之间。
  11846. @example
  11847. ```js
  11848. var color = new cc.Color(1000, 0, 0, 255);
  11849. color.clamp();
  11850. cc.log(color); // (255, 0, 0, 255)
  11851. ```
  11852. */
  11853. clamp(): void;
  11854. /**
  11855. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  11856. !#zh 读取 16 进制颜色。
  11857. @param hexString hexString
  11858. @example
  11859. ```js
  11860. var color = cc.Color.BLACK;
  11861. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  11862. ```
  11863. */
  11864. fromHEX(hexString: string): Color;
  11865. /**
  11866. !#en TODO
  11867. !#zh 转换为 16 进制。
  11868. @param fmt "#rgb" or "#rrggbb".
  11869. @example
  11870. ```js
  11871. var color = cc.Color.BLACK;
  11872. color.toHEX("#rgb"); // "000";
  11873. color.toHEX("#rrggbb"); // "000000";
  11874. ```
  11875. */
  11876. toHEX(fmt: string): string;
  11877. /**
  11878. !#en Convert to 24bit rgb value.
  11879. !#zh 转换为 24bit 的 RGB 值。
  11880. @example
  11881. ```js
  11882. var color = cc.Color.YELLOW;
  11883. color.toRGBValue(); // 16771844;
  11884. ```
  11885. */
  11886. toRGBValue(): number;
  11887. /**
  11888. !#en TODO
  11889. !#zh 读取 HSV(色彩模型)格式。
  11890. @param h h
  11891. @param s s
  11892. @param v v
  11893. @example
  11894. ```js
  11895. var color = cc.Color.YELLOW;
  11896. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  11897. ```
  11898. */
  11899. fromHSV(h: number, s: number, v: number): Color;
  11900. /**
  11901. !#en TODO
  11902. !#zh 转换为 HSV(色彩模型)格式。
  11903. @example
  11904. ```js
  11905. var color = cc.Color.YELLOW;
  11906. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  11907. ```
  11908. */
  11909. toHSV(): any;
  11910. /**
  11911. !#en TODO
  11912. !#zh RGB 转换为 HSV。
  11913. @param r red, must be [0, 255].
  11914. @param g red, must be [0, 255].
  11915. @param b red, must be [0, 255].
  11916. @example
  11917. ```js
  11918. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  11919. ```
  11920. */
  11921. static rgb2hsv(r: number, g: number, b: number): any;
  11922. /**
  11923. !#en TODO
  11924. !#zh HSV 转换为 RGB。
  11925. @param h h
  11926. @param s s
  11927. @param v v
  11928. @example
  11929. ```js
  11930. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  11931. ```
  11932. */
  11933. static hsv2rgb(h: number, s: number, v: number): any;
  11934. }
  11935. /** !#en A 2D rectangle defined by x, y position and width, height.
  11936. !#zh 通过位置和宽高定义的 2D 矩形。 */
  11937. export class Rect extends ValueType {
  11938. /**
  11939. !#en
  11940. Constructor of cc.Rect class.
  11941. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  11942. !#zh
  11943. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  11944. @param x x
  11945. @param y y
  11946. @param w w
  11947. @param h h
  11948. */
  11949. constructor(x?: number, y?: number, w?: number, h?: number);
  11950. x: number;
  11951. y: number;
  11952. width: number;
  11953. height: number;
  11954. /**
  11955. !#en Creates a rectangle from two coordinate values.
  11956. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  11957. @param v1 v1
  11958. @param v2 v2
  11959. @example
  11960. ```js
  11961. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  11962. ```
  11963. */
  11964. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  11965. /**
  11966. !#en Checks if rect contains.
  11967. !#zh
  11968. 判断 2 个矩形是否有包含。<br/>
  11969. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  11970. 0 这则都不包含。
  11971. @param a Rect a
  11972. @param b Rect b
  11973. @example
  11974. ```js
  11975. var a = new cc.Rect(0, 0, 10, 10);
  11976. var b = new cc.Rect(5, 5, 5, 5);
  11977. var c = new cc.Rect(20, 20, 10, 10);
  11978. cc.Rect.contain(a, b); // 1;
  11979. cc.Rect.contain(b, a); // -1;
  11980. cc.Rect.contain(a, c); // 0;
  11981. ```
  11982. */
  11983. static contain(a: Rect, b: Rect): number;
  11984. /**
  11985. !#en TODO
  11986. !#zh 克隆一个新的 Rect。
  11987. @example
  11988. ```js
  11989. var a = new cc.Rect(0, 0, 10, 10);
  11990. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  11991. ```
  11992. */
  11993. clone(): Rect;
  11994. /**
  11995. !#en TODO
  11996. !#zh 是否等于指定的矩形。
  11997. @param other other
  11998. @example
  11999. ```js
  12000. var a = new cc.Rect(0, 0, 10, 10);
  12001. var b = new cc.Rect(0, 0, 10, 10);
  12002. a.equals(b);// true;
  12003. ```
  12004. */
  12005. equals(other: Rect): boolean;
  12006. /**
  12007. !#en TODO
  12008. !#zh 线性插值
  12009. @param to to
  12010. @param ratio the interpolation coefficient.
  12011. @param out optional, the receiving vector.
  12012. @example
  12013. ```js
  12014. var a = new cc.Rect(0, 0, 10, 10);
  12015. var b = new cc.Rect(50, 50, 100, 100);
  12016. update (dt) {
  12017. // method 1;
  12018. var c = a.lerp(b, dt * 0.1);
  12019. // method 2;
  12020. a.lerp(b, dt * 0.1, c);
  12021. }
  12022. ```
  12023. */
  12024. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12025. /**
  12026. !#en TODO
  12027. !#zh 转换为方便阅读的字符串
  12028. @example
  12029. ```js
  12030. var a = new cc.Rect(0, 0, 10, 10);
  12031. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12032. ```
  12033. */
  12034. toString(): string;
  12035. /** !#en TODO
  12036. !#zh 矩形 x 轴上的最小值。 */
  12037. xMin: number;
  12038. /** !#en TODO
  12039. !#zh 矩形 y 轴上的最小值。 */
  12040. yMin: number;
  12041. /** !#en TODO
  12042. !#zh 矩形 x 轴上的最大值。 */
  12043. xMax: number;
  12044. /** !#en TODO
  12045. !#zh 矩形 y 轴上的最大值。 */
  12046. yMax: number;
  12047. /** !#en The position of the center of the rectangle.
  12048. !#zh 矩形的中心点。 */
  12049. center: Vec2;
  12050. /** !#en The X and Y position of the rectangle.
  12051. !#zh 矩形的 x 和 y 坐标。 */
  12052. origin: Vec2;
  12053. /** !#en Width and height of the rectangle.
  12054. !#zh 矩形的大小。 */
  12055. size: Size;
  12056. /**
  12057. !#en TODO
  12058. !#zh 当前矩形与指定矩形是否相交。
  12059. @param rect rect
  12060. @example
  12061. ```js
  12062. var a = new cc.Rect(0, 0, 10, 10);
  12063. var b = new cc.Rect(0, 0, 20, 20);
  12064. a.intersects(b);// true
  12065. ```
  12066. */
  12067. intersects(rect: Rect): void;
  12068. /**
  12069. !#en TODO
  12070. !#zh 当前矩形是否包含指定坐标点。
  12071. Returns true if the point inside this rectangle.
  12072. @param point point
  12073. @example
  12074. ```js
  12075. var a = new cc.Rect(0, 0, 10, 10);
  12076. var b = new cc.Vec2(0, 5);
  12077. a.contains(b);// true
  12078. ```
  12079. */
  12080. contains(point: Vec2): void;
  12081. /**
  12082. !#en Returns true if the other rect totally inside this rectangle.
  12083. !#zh 当前矩形是否包含指定矩形。
  12084. @param rect rect
  12085. @example
  12086. ```js
  12087. var a = new cc.Rect(0, 0, 10, 10);
  12088. var b = new cc.Rect(0, 0, 20, 20);
  12089. a.containsRect(b);// true
  12090. ```
  12091. */
  12092. containsRect(rect: Rect): void;
  12093. }
  12094. /** !#en
  12095. cc.Size is the class for size object,<br/>
  12096. please do not use its constructor to create sizes,<br/>
  12097. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12098. It will be deprecated soon, please use cc.Vec2 instead.
  12099. !#zh
  12100. cc.Size 是 size 对象的类。<br/>
  12101. 请不要使用它的构造函数创建的 size,<br/>
  12102. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12103. 它不久将被取消,请使用cc.Vec2代替。 */
  12104. export class Size {
  12105. /**
  12106. @param width width
  12107. @param height height
  12108. */
  12109. constructor(width: number|Size, height?: number);
  12110. width: number;
  12111. height: number;
  12112. /** !#en return a Size object with width = 0 and height = 0.
  12113. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12114. static ZERO: Size;
  12115. /**
  12116. !#en TODO
  12117. !#zh 克隆 size 对象。
  12118. @example
  12119. ```js
  12120. var a = new cc.size(10, 10);
  12121. a.clone();// return Size {width: 0, height: 0};
  12122. ```
  12123. */
  12124. clone(): Size;
  12125. /**
  12126. !#en TODO
  12127. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12128. @param other other
  12129. @example
  12130. ```js
  12131. var a = new cc.size(10, 10);
  12132. a.equals(new cc.size(10, 10));// return true;
  12133. ```
  12134. */
  12135. equals(other: Size): boolean;
  12136. /**
  12137. !#en TODO
  12138. !#zh 线性插值。
  12139. @param to to
  12140. @param ratio the interpolation coefficient.
  12141. @param out optional, the receiving vector.
  12142. @example
  12143. ```js
  12144. var a = new cc.size(10, 10);
  12145. var b = new cc.rect(50, 50, 100, 100);
  12146. update (dt) {
  12147. // method 1;
  12148. var c = a.lerp(b, dt * 0.1);
  12149. // method 2;
  12150. a.lerp(b, dt * 0.1, c);
  12151. }
  12152. ```
  12153. */
  12154. lerp(to: Rect, ratio: number, out?: Size): Size;
  12155. /**
  12156. !#en TODO
  12157. !#zh 转换为方便阅读的字符串。
  12158. @example
  12159. ```js
  12160. var a = new cc.size(10, 10);
  12161. a.toString();// return "(10.00, 10.00)";
  12162. ```
  12163. */
  12164. toString(): string;
  12165. }
  12166. /** !#en the device accelerometer reports values for each axis in units of g-force.
  12167. !#zh 设备重力传感器传递的各个轴的数据。 */
  12168. export class Acceleration {
  12169. /**
  12170. @param x x
  12171. @param y y
  12172. @param z z
  12173. @param timestamp timestamp
  12174. */
  12175. constructor(x: number, y: number, z: number, timestamp: number);
  12176. }
  12177. /** !#en Blend Function used for textures.
  12178. !#zh 图像的混合方式。 */
  12179. export class BlendFunc {
  12180. /**
  12181. @param src1 source blend function
  12182. @param dst1 destination blend function
  12183. */
  12184. constructor(src1: number, dst1: number);
  12185. }
  12186. /** !#en
  12187. Enum for blend factor
  12188. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  12189. !#zh
  12190. 混合因子
  12191. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  12192. export enum BlendFactor {
  12193. ONE = 0,
  12194. ZERO = 0,
  12195. SRC_ALPHA = 0,
  12196. SRC_COLOR = 0,
  12197. DST_ALPHA = 0,
  12198. DST_COLOR = 0,
  12199. ONE_MINUS_SRC_ALPHA = 0,
  12200. ONE_MINUS_SRC_COLOR = 0,
  12201. ONE_MINUS_DST_ALPHA = 0,
  12202. ONE_MINUS_DST_COLOR = 0,
  12203. blendFuncDisable = 0,
  12204. }
  12205. /** undefined */
  12206. export enum TextAlignment {
  12207. LEFT = 0,
  12208. CENTER = 0,
  12209. RIGHT = 0,
  12210. }
  12211. /** undefined */
  12212. export class WebGLColor {
  12213. /**
  12214. @param r r
  12215. @param g g
  12216. @param b b
  12217. @param a a
  12218. @param arrayBuffer arrayBuffer
  12219. @param offset offset
  12220. */
  12221. constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number);
  12222. BYTES_PER_ELEMENT: number;
  12223. }
  12224. /** undefined */
  12225. export class Vertex2F {
  12226. /**
  12227. @param x x
  12228. @param y y
  12229. @param arrayBuffer arrayBuffer
  12230. @param offset offset
  12231. */
  12232. constructor(x: number, y: number, arrayBuffer: any[], offset: number);
  12233. BYTES_PER_ELEMENT: number;
  12234. }
  12235. /** undefined */
  12236. export class Vertex3F {
  12237. /**
  12238. @param x x
  12239. @param y y
  12240. @param z z
  12241. @param arrayBuffer arrayBuffer
  12242. @param offset offset
  12243. */
  12244. constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number);
  12245. BYTES_PER_ELEMENT: number;
  12246. }
  12247. /** undefined */
  12248. export class Tex2F {
  12249. /**
  12250. @param u u
  12251. @param v v
  12252. @param arrayBuffer arrayBuffer
  12253. @param offset offset
  12254. */
  12255. constructor(u: number, v: number, arrayBuffer: any[], offset: number);
  12256. BYTES_PER_ELEMENT: number;
  12257. }
  12258. /** undefined */
  12259. export class Quad2 {
  12260. /**
  12261. @param tl tl
  12262. @param tr tr
  12263. @param bl bl
  12264. @param br br
  12265. @param arrayBuffer arrayBuffer
  12266. @param offset offset
  12267. */
  12268. constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number);
  12269. BYTES_PER_ELEMENT: number;
  12270. }
  12271. /** A 3D Quad. 4 * 3 floats */
  12272. export class Quad3 {
  12273. /**
  12274. @param bl1 bl1
  12275. @param br1 br1
  12276. @param tl1 tl1
  12277. @param tr1 tr1
  12278. @param arrayBuffer arrayBuffer
  12279. @param offset offset
  12280. */
  12281. constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number);
  12282. }
  12283. /** undefined */
  12284. export class V3F_C4B_T2F {
  12285. /**
  12286. @param vertices vertices
  12287. @param colors colors
  12288. @param texCoords texCoords
  12289. @param arrayBuffer arrayBuffer
  12290. @param offset offset
  12291. */
  12292. constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12293. BYTES_PER_ELEMENT(): void;
  12294. }
  12295. /** undefined */
  12296. export class V3F_C4B_T2F_Quad {
  12297. /**
  12298. @param tl tl
  12299. @param bl bl
  12300. @param tr tr
  12301. @param br br
  12302. @param arrayBuffer arrayBuffer
  12303. @param offset offset
  12304. */
  12305. constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number);
  12306. BYTES_PER_ELEMENT: number;
  12307. }
  12308. /** undefined */
  12309. export class V2F_C4B_T2F {
  12310. /**
  12311. @param vertices vertices
  12312. @param colors colors
  12313. @param texCoords texCoords
  12314. @param arrayBuffer arrayBuffer
  12315. @param offset offset
  12316. */
  12317. constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12318. BYTES_PER_ELEMENT: number;
  12319. }
  12320. /** undefined */
  12321. export class V2F_C4B_T2F_Triangle {
  12322. /**
  12323. @param a a
  12324. @param b b
  12325. @param c c
  12326. @param arrayBuffer arrayBuffer
  12327. @param offset offset
  12328. */
  12329. constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number);
  12330. }
  12331. /** !#en The base class of all value types.
  12332. !#zh 所有值类型的基类。 */
  12333. export class ValueType {
  12334. /**
  12335. !#en This method returns an exact copy of current value.
  12336. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12337. */
  12338. clone(): ValueType;
  12339. /**
  12340. !#en Compares this object with the other one.
  12341. !#zh 当前对象是否等于指定对象。
  12342. @param other other
  12343. */
  12344. equals(other: ValueType): boolean;
  12345. /**
  12346. !#en
  12347. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12348. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12349. !#zh
  12350. 线性插值。<br/>
  12351. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12352. @param to the to value
  12353. @param ratio the interpolation coefficient
  12354. */
  12355. lerp(to: ValueType, ratio: number): ValueType;
  12356. /**
  12357. !#en TODO
  12358. !#zh 转换为方便阅读的字符串。
  12359. */
  12360. toString(): string;
  12361. }
  12362. /** !#en Representation of 2D vectors and points.
  12363. !#zh 表示 2D 向量和坐标 */
  12364. export class Vec2 extends ValueType {
  12365. /**
  12366. !#en
  12367. Constructor
  12368. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12369. !#zh
  12370. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12371. @param x x
  12372. @param y y
  12373. */
  12374. constructor(x?: number, y?: number);
  12375. x: number;
  12376. y: number;
  12377. /**
  12378. !#en clone a Vec2 value
  12379. !#zh 克隆一个 Vec2 值
  12380. */
  12381. clone(): Vec2;
  12382. /**
  12383. !#en TODO
  12384. !#zh 设置向量值。
  12385. @param newValue !#en new value to set. !#zh 要设置的新值
  12386. */
  12387. set(newValue: Vec2): Vec2;
  12388. /**
  12389. !#en TODO
  12390. !#zh 当前的向量是否与指定的向量相等。
  12391. @param other other
  12392. */
  12393. equals(other: Vec2): boolean;
  12394. /**
  12395. !#en TODO
  12396. !#zh 转换为方便阅读的字符串。
  12397. */
  12398. toString(): string;
  12399. /**
  12400. !#en TODO
  12401. !#zh 线性插值。
  12402. @param to to
  12403. @param ratio the interpolation coefficient
  12404. @param out optional, the receiving vector
  12405. */
  12406. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12407. /**
  12408. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  12409. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  12410. @param vector vector
  12411. @example
  12412. ```js
  12413. var v = cc.v2(10, 10);
  12414. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  12415. ```
  12416. */
  12417. addSelf(vector: Vec2): Vec2;
  12418. /**
  12419. !#en Adds two vectors, and returns the new result.
  12420. !#zh 向量加法,并返回新结果。
  12421. @param vector vector
  12422. @param out optional, the receiving vector
  12423. @example
  12424. ```js
  12425. var v = cc.v2(10, 10);
  12426. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  12427. var v1;
  12428. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  12429. ```
  12430. */
  12431. add(vector: Vec2, out?: Vec2): Vec2;
  12432. /**
  12433. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12434. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12435. @param vector vector
  12436. @example
  12437. ```js
  12438. var v = cc.v2(10, 10);
  12439. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12440. ```
  12441. */
  12442. subSelf(vector: Vec2): Vec2;
  12443. /**
  12444. !#en Subtracts one vector from this, and returns the new result.
  12445. !#zh 向量减法,并返回新结果。
  12446. @param vector vector
  12447. @param out optional, the receiving vector
  12448. @example
  12449. ```js
  12450. var v = cc.v2(10, 10);
  12451. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12452. var v1;
  12453. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12454. ```
  12455. */
  12456. sub(vector: Vec2, out?: Vec2): Vec2;
  12457. /**
  12458. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12459. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12460. @param num num
  12461. @example
  12462. ```js
  12463. var v = cc.v2(10, 10);
  12464. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12465. ```
  12466. */
  12467. mulSelf(num: number): Vec2;
  12468. /**
  12469. !#en Multiplies by a number, and returns the new result.
  12470. !#zh 缩放当前向量,并返回新结果。
  12471. @param num num
  12472. @param out optional, the receiving vector
  12473. @example
  12474. ```js
  12475. var v = cc.v2(10, 10);
  12476. v.mul(5); // return Vec2 {x: 50, y: 50};
  12477. var v1;
  12478. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12479. ```
  12480. */
  12481. mul(num: number, out?: Vec2): Vec2;
  12482. /**
  12483. !#en Multiplies two vectors.
  12484. !#zh 分量相乘。
  12485. @param vector vector
  12486. @example
  12487. ```js
  12488. var v = cc.v2(10, 10);
  12489. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12490. ```
  12491. */
  12492. scaleSelf(vector: Vec2): Vec2;
  12493. /**
  12494. !#en Multiplies two vectors, and returns the new result.
  12495. !#zh 分量相乘,并返回新的结果。
  12496. @param vector vector
  12497. @param out optional, the receiving vector
  12498. @example
  12499. ```js
  12500. var v = cc.v2(10, 10);
  12501. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12502. var v1;
  12503. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12504. ```
  12505. */
  12506. scale(vector: Vec2, out?: Vec2): Vec2;
  12507. /**
  12508. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12509. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12510. @param vector vector
  12511. @example
  12512. ```js
  12513. var v = cc.v2(10, 10);
  12514. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12515. ```
  12516. */
  12517. divSelf(vector: Vec2): Vec2;
  12518. /**
  12519. !#en Divides by a number, and returns the new result.
  12520. !#zh 向量除法,并返回新的结果。
  12521. @param vector vector
  12522. @param out optional, the receiving vector
  12523. @example
  12524. ```js
  12525. var v = cc.v2(10, 10);
  12526. v.div(5); // return Vec2 {x: 2, y: 2};
  12527. var v1;
  12528. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12529. ```
  12530. */
  12531. div(vector: Vec2, out?: Vec2): Vec2;
  12532. /**
  12533. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12534. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12535. @example
  12536. ```js
  12537. var v = cc.v2(10, 10);
  12538. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12539. ```
  12540. */
  12541. negSelf(): Vec2;
  12542. /**
  12543. !#en Negates the components, and returns the new result.
  12544. !#zh 返回取反后的新向量。
  12545. @param out optional, the receiving vector
  12546. @example
  12547. ```js
  12548. var v = cc.v2(10, 10);
  12549. var v1;
  12550. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12551. ```
  12552. */
  12553. neg(out?: Vec2): Vec2;
  12554. /**
  12555. !#en Dot product
  12556. !#zh 当前向量与指定向量进行点乘。
  12557. @param vector vector
  12558. @example
  12559. ```js
  12560. var v = cc.v2(10, 10);
  12561. v.dot(cc.v2(5, 5)); // return 100;
  12562. ```
  12563. */
  12564. dot(vector?: Vec2): number;
  12565. /**
  12566. !#en Cross product
  12567. !#zh 当前向量与指定向量进行叉乘。
  12568. @param vector vector
  12569. @example
  12570. ```js
  12571. var v = cc.v2(10, 10);
  12572. v.cross(cc.v2(5, 5)); // return 0;
  12573. ```
  12574. */
  12575. cross(vector?: Vec2): number;
  12576. /**
  12577. !#en Returns the length of this vector.
  12578. !#zh 返回该向量的长度。
  12579. @example
  12580. ```js
  12581. var v = cc.v2(10, 10);
  12582. v.mag(); // return 14.142135623730951;
  12583. ```
  12584. */
  12585. mag(): number;
  12586. /**
  12587. !#en Returns the squared length of this vector.
  12588. !#zh 返回该向量的长度平方。
  12589. @example
  12590. ```js
  12591. var v = cc.v2(10, 10);
  12592. v.magSqr(); // return 200;
  12593. ```
  12594. */
  12595. magSqr(): number;
  12596. /**
  12597. !#en Make the length of this vector to 1.
  12598. !#zh 向量归一化,让这个向量的长度为 1。
  12599. @example
  12600. ```js
  12601. var v = cc.v2(10, 10);
  12602. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  12603. ```
  12604. */
  12605. normalizeSelf(): Vec2;
  12606. /**
  12607. !#en
  12608. Returns this vector with a magnitude of 1.<br/>
  12609. <br/>
  12610. 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.
  12611. !#zh
  12612. 返回归一化后的向量。<br/>
  12613. <br/>
  12614. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  12615. @param out optional, the receiving vector
  12616. */
  12617. normalize(out?: Vec2): Vec2;
  12618. /**
  12619. !#en Get angle in radian between this and vector.
  12620. !#zh 夹角的弧度。
  12621. @param vector vector
  12622. */
  12623. angle(vector: Vec2): number;
  12624. /**
  12625. !#en Get angle in radian between this and vector with direction.
  12626. !#zh 带方向的夹角的弧度。
  12627. @param vector vector
  12628. */
  12629. signAngle(vector: Vec2): number;
  12630. /**
  12631. !#en rotate
  12632. !#zh 返回旋转给定弧度后的新向量。
  12633. @param radians radians
  12634. @param out optional, the receiving vector
  12635. */
  12636. rotate(radians: number, out?: Vec2): Vec2;
  12637. /**
  12638. !#en rotate self
  12639. !#zh 按指定弧度旋转向量。
  12640. @param radians radians
  12641. */
  12642. rotateSelf(radians: number): Vec2;
  12643. /** !#en return a Vec2 object with x = 1 and y = 1.
  12644. !#zh 新 Vec2 对象。 */
  12645. static ONE: Vec2;
  12646. /** !#en return a Vec2 object with x = 0 and y = 0.
  12647. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  12648. static ZERO: Vec2;
  12649. /** !#en return a Vec2 object with x = 0 and y = 1.
  12650. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  12651. static UP: Vec2;
  12652. /** !#en return a Vec2 object with x = 1 and y = 0.
  12653. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  12654. static RIGHT: Vec2;
  12655. }
  12656. /** undefined */
  12657. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  12658. /** !#en Position offset
  12659. !#zh 位置偏移量 */
  12660. offset: Vec2;
  12661. /** !#en Box size
  12662. !#zh 包围盒大小 */
  12663. size: Size;
  12664. }
  12665. /** undefined */
  12666. export class PhysicsChainCollider extends PolygonCollider {
  12667. /** !#en Whether the chain is loop
  12668. !#zh 链条是否首尾相连 */
  12669. loop: boolean;
  12670. /** !#en Chain points
  12671. !#zh 链条顶点数组 */
  12672. points: [Vec2];
  12673. }
  12674. /** undefined */
  12675. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  12676. /** !#en Position offset
  12677. !#zh 位置偏移量 */
  12678. offset: Vec2;
  12679. /** !#en Circle radius
  12680. !#zh 圆形半径 */
  12681. radius: number;
  12682. }
  12683. /** undefined */
  12684. export class PhysicsCollider {
  12685. /** !#en
  12686. The density.
  12687. !#zh
  12688. 密度 */
  12689. density: number;
  12690. /** !#en
  12691. A sensor collider collects contact information but never generates a collision response
  12692. !#zh
  12693. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  12694. sensor: boolean;
  12695. /** !#en
  12696. The friction coefficient, usually in the range [0,1].
  12697. !#zh
  12698. 摩擦系数,取值一般在 [0, 1] 之间 */
  12699. friction: number;
  12700. /** !#en
  12701. The restitution (elasticity) usually in the range [0,1].
  12702. !#zh
  12703. 弹性系数,取值一般在 [0, 1]之间 */
  12704. restitution: number;
  12705. /** !#en
  12706. Physics collider will find the rigidbody component on the node and set to this property.
  12707. !#zh
  12708. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  12709. body: RigidBody;
  12710. /**
  12711. !#en
  12712. Apply current changes to collider, this will regenerate inner box2d fixtures.
  12713. !#zh
  12714. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  12715. */
  12716. apply(): void;
  12717. /**
  12718. !#en
  12719. Get the world aabb of the collider
  12720. !#zh
  12721. 获取碰撞体的世界坐标系下的包围盒
  12722. */
  12723. getAABB(): void;
  12724. }
  12725. /** undefined */
  12726. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  12727. /** !#en Position offset
  12728. !#zh 位置偏移量 */
  12729. offset: Vec2;
  12730. /** !#en Polygon points
  12731. !#zh 多边形顶点数组 */
  12732. points: [Vec2];
  12733. }
  12734. /** !#en
  12735. A distance joint constrains two points on two bodies
  12736. to remain at a fixed distance from each other. You can view
  12737. this as a massless, rigid rod.
  12738. !#zh
  12739. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  12740. export class DistanceJoint extends Joint {
  12741. /** !#en
  12742. The distance separating the two ends of the joint.
  12743. !#zh
  12744. 关节两端的距离 */
  12745. distance: number;
  12746. /** !#en
  12747. The spring frequency.
  12748. !#zh
  12749. 弹性系数。 */
  12750. frequency: number;
  12751. /** !#en
  12752. The damping ratio.
  12753. !#zh
  12754. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  12755. 0: number;
  12756. }
  12757. /** !#en
  12758. Base class for joints to connect rigidbody.
  12759. !#zh
  12760. 关节类的基类 */
  12761. export class Joint extends Component {
  12762. /** !#en
  12763. The anchor of the rigidbody.
  12764. !#zh
  12765. 刚体的锚点。 */
  12766. anchor: Vec2;
  12767. /** !#en
  12768. The anchor of the connected rigidbody.
  12769. !#zh
  12770. 关节另一端刚体的锚点。 */
  12771. connectedAnchor: Vec2;
  12772. /** !#en
  12773. The rigidbody to which the other end of the joint is attached.
  12774. !#zh
  12775. 关节另一端链接的刚体 */
  12776. connectedBody: RigidBody;
  12777. /** !#en
  12778. Should the two rigid bodies connected with this joint collide with each other?
  12779. !#zh
  12780. 链接到关节上的两个刚体是否应该相互碰撞? */
  12781. collideConnected: boolean;
  12782. /**
  12783. !#en
  12784. Apply current changes to joint, this will regenerate inner box2d joint.
  12785. !#zh
  12786. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  12787. */
  12788. apply(): void;
  12789. /**
  12790. !#en
  12791. Get the anchor point on rigidbody in world coordinates.
  12792. !#zh
  12793. 获取刚体世界坐标系下的锚点。
  12794. */
  12795. getWorldAnchor(): Vec2;
  12796. /**
  12797. !#en
  12798. Get the anchor point on connected rigidbody in world coordinates.
  12799. !#zh
  12800. 获取链接刚体世界坐标系下的锚点。
  12801. */
  12802. getWorldConnectedAnchor(): Vec2;
  12803. /**
  12804. !#en
  12805. Gets the reaction force of the joint.
  12806. !#zh
  12807. 获取关节的反作用力。
  12808. @param timeStep The time to calculate the reaction force for.
  12809. */
  12810. getReactionForce(timeStep: number): number;
  12811. /**
  12812. !#en
  12813. Gets the reaction torque of the joint.
  12814. !#zh
  12815. 获取关节的反扭矩。
  12816. @param timeStep The time to calculate the reaction torque for.
  12817. */
  12818. getReactionTorque(timeStep: number): number;
  12819. }
  12820. /** !#en
  12821. A motor joint is used to control the relative motion
  12822. between two bodies. A typical usage is to control the movement
  12823. of a dynamic body with respect to the ground.
  12824. !#zh
  12825. 马达关节被用来控制两个刚体间的相对运动。
  12826. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  12827. export class MotorJoint extends Joint {
  12828. /** !#en
  12829. The anchor of the rigidbody.
  12830. !#zh
  12831. 刚体的锚点。 */
  12832. anchor: Vec2;
  12833. /** !#en
  12834. The anchor of the connected rigidbody.
  12835. !#zh
  12836. 关节另一端刚体的锚点。 */
  12837. connectedAnchor: Vec2;
  12838. /** !#en
  12839. The linear offset from connected rigidbody to rigidbody.
  12840. !#zh
  12841. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  12842. linearOffset: Vec2;
  12843. /** !#en
  12844. The angular offset from connected rigidbody to rigidbody.
  12845. !#zh
  12846. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  12847. angularOffset: number;
  12848. /** !#en
  12849. The maximum force can be applied to rigidbody.
  12850. !#zh
  12851. 可以应用于刚体的最大的力值 */
  12852. maxForce: number;
  12853. /** !#en
  12854. The maximum torque can be applied to rigidbody.
  12855. !#zh
  12856. 可以应用于刚体的最大扭矩值 */
  12857. maxTorque: number;
  12858. /** !#en
  12859. The position correction factor in the range [0,1].
  12860. !#zh
  12861. 位置矫正系数,范围为 [0, 1] */
  12862. correctionFactor: number;
  12863. }
  12864. /** !#en
  12865. A mouse joint is used to make a point on a body track a
  12866. specified world point. This a soft constraint with a maximum
  12867. force. This allows the constraint to stretch and without
  12868. applying huge forces.
  12869. Mouse Joint will auto register the touch event with the mouse region node,
  12870. and move the choosed rigidbody in touch move event.
  12871. Note : generally mouse joint only used in test bed.
  12872. !#zh
  12873. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  12874. 鼠标关节可以指定一个最大的里来施加一个柔和的约束。
  12875. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  12876. 注意:一般鼠标关节只在测试环境中使用。 */
  12877. export class MouseJoint extends Joint {
  12878. /** !#en
  12879. The anchor of the rigidbody.
  12880. !#zh
  12881. 刚体的锚点。 */
  12882. anchor: Vec2;
  12883. /** !#en
  12884. The anchor of the connected rigidbody.
  12885. !#zh
  12886. 关节另一端刚体的锚点。 */
  12887. connectedAnchor: Vec2;
  12888. /** !#en
  12889. The node used to register touch evnet.
  12890. If this is null, it will be the joint's node.
  12891. !#zh
  12892. 用于注册触摸事件的节点。
  12893. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  12894. mouseRegion: Node;
  12895. /** !#en
  12896. The target point.
  12897. The mouse joint will move choosed rigidbody to target point.
  12898. !#zh
  12899. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  12900. target: Vec2;
  12901. /** !#en
  12902. The spring frequency.
  12903. !#zh
  12904. 弹簧系数。 */
  12905. frequency: number;
  12906. /** !#en
  12907. The damping ratio.
  12908. !#zh
  12909. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  12910. 0: number;
  12911. /** !#en
  12912. The maximum force
  12913. !#zh
  12914. 最大阻力值 */
  12915. maxForce: number;
  12916. }
  12917. /** !#en
  12918. A prismatic joint. This joint provides one degree of freedom: translation
  12919. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  12920. use a joint limit to restrict the range of motion and a joint motor to
  12921. drive the motion or to model joint friction.
  12922. !#zh
  12923. 移动关节指定了只能在一个方向上移动刚体。
  12924. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  12925. export class PrismaticJoint extends Joint {
  12926. /** !#en
  12927. The local joint axis relative to rigidbody.
  12928. !#zh
  12929. 指定刚体可以移动的方向。 */
  12930. localAxisA: Vec2;
  12931. /** !#en
  12932. The reference angle.
  12933. !#zh
  12934. 相对角度 */
  12935. referenceAngle: number;
  12936. /** !#en
  12937. Enable joint distance limit?
  12938. !#zh
  12939. 是否开启关节的距离限制? */
  12940. enableLimit: boolean;
  12941. /** !#en
  12942. Enable joint motor?
  12943. !#zh
  12944. 是否开启关节马达? */
  12945. enableMotor: boolean;
  12946. /** !#en
  12947. The lower joint limit.
  12948. !#zh
  12949. 刚体能够移动的最小值 */
  12950. lowerLimit: number;
  12951. /** !#en
  12952. The upper joint limit.
  12953. !#zh
  12954. 刚体能够移动的最大值 */
  12955. upperLimit: number;
  12956. /** !#en
  12957. The maxium force can be applied to rigidbody to rearch the target motor speed.
  12958. !#zh
  12959. 可以施加到刚体的最大力。 */
  12960. maxMotorForce: number;
  12961. /** !#en
  12962. The expected motor speed.
  12963. !#zh
  12964. 期望的马达速度。 */
  12965. motorSpeed: number;
  12966. }
  12967. /** !#en
  12968. A revolute joint constrains two bodies to share a common point while they
  12969. are free to rotate about the point. The relative rotation about the shared
  12970. point is the joint angle. You can limit the relative rotation with
  12971. a joint limit that specifies a lower and upper angle. You can use a motor
  12972. to drive the relative rotation about the shared point. A maximum motor torque
  12973. is provided so that infinite forces are not generated.
  12974. !#zh
  12975. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  12976. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  12977. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  12978. export class RevoluteJoint extends Joint {
  12979. /** !#en
  12980. The reference angle.
  12981. An angle between bodies considered to be zero for the joint angle.
  12982. !#zh
  12983. 相对角度。
  12984. 两个物体之间角度为零时可以看作相等于关节角度 */
  12985. referenceAngle: number;
  12986. /** !#en
  12987. The lower angle.
  12988. !#zh
  12989. 角度的最低限制。 */
  12990. lowerAngle: number;
  12991. /** !#en
  12992. The upper angle.
  12993. !#zh
  12994. 角度的最高限制。 */
  12995. upperAngle: number;
  12996. /** !#en
  12997. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  12998. !#zh
  12999. 可以施加到刚体的最大扭矩。 */
  13000. maxMotorTorque: number;
  13001. /** !#en
  13002. The expected motor speed.
  13003. !#zh
  13004. 期望的马达速度。 */
  13005. motorSpeed: number;
  13006. /** !#en
  13007. Enable joint limit?
  13008. !#zh
  13009. 是否开启关节的限制? */
  13010. enableLimit: boolean;
  13011. /** !#en
  13012. Enable joint motor?
  13013. !#zh
  13014. 是否开启关节马达? */
  13015. enableMotor: boolean;
  13016. /**
  13017. !#en
  13018. Get the joint angle.
  13019. !#zh
  13020. 获取关节角度。
  13021. */
  13022. getJointAngle(): number;
  13023. }
  13024. /** !#en
  13025. A rope joint enforces a maximum distance between two points
  13026. on two bodies. It has no other effect.
  13027. Warning: if you attempt to change the maximum length during
  13028. the simulation you will get some non-physical behavior.
  13029. !#zh
  13030. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  13031. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  13032. export class RopeJoint extends Joint {
  13033. /** !#en
  13034. The max length.
  13035. !#zh
  13036. 最大长度。 */
  13037. maxLength: number;
  13038. }
  13039. /** !#en
  13040. A weld joint essentially glues two bodies together. A weld joint may
  13041. distort somewhat because the island constraint solver is approximate.
  13042. !#zh
  13043. 熔接关节相当于将两个刚体粘在了一起。
  13044. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  13045. export class WeldJoint extends Joint {
  13046. /** !#en
  13047. The reference angle.
  13048. !#zh
  13049. 相对角度。 */
  13050. referenceAngle: number;
  13051. /** !#en
  13052. The frequency.
  13053. !#zh
  13054. 弹性系数。 */
  13055. frequency: number;
  13056. /** !#en
  13057. The damping ratio.
  13058. !#zh
  13059. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13060. 0: number;
  13061. }
  13062. /** !#en
  13063. A wheel joint. This joint provides two degrees of freedom: translation
  13064. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  13065. the rotation or to model rotational friction.
  13066. This joint is designed for vehicle suspensions.
  13067. !#zh
  13068. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  13069. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  13070. 轮组关节是专门为机动车类型设计的。 */
  13071. export class WheelJoint extends Joint {
  13072. /** !#en
  13073. The local joint axis relative to rigidbody.
  13074. !#zh
  13075. 指定刚体可以移动的方向。 */
  13076. localAxisA: Vec2;
  13077. /** !#en
  13078. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13079. !#zh
  13080. 可以施加到刚体的最大扭矩。 */
  13081. maxMotorTorque: number;
  13082. /** !#en
  13083. The expected motor speed.
  13084. !#zh
  13085. 期望的马达速度。 */
  13086. motorSpeed: number;
  13087. /** !#en
  13088. Enable joint motor?
  13089. !#zh
  13090. 是否开启关节马达? */
  13091. enableMotor: boolean;
  13092. /** !#en
  13093. The spring frequency.
  13094. !#zh
  13095. 弹性系数。 */
  13096. frequency: number;
  13097. /** !#en
  13098. The damping ratio.
  13099. !#zh
  13100. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13101. dampingRatio: number;
  13102. }
  13103. /****************************************************
  13104. * audioEngine
  13105. *****************************************************/
  13106. export module audioEngine {
  13107. /** !#en Audio state.
  13108. !#zh 声音播放状态 */
  13109. export enum AudioState {
  13110. ERROR = 0,
  13111. INITIALZING = 0,
  13112. PLAYING = 0,
  13113. PAUSED = 0,
  13114. }
  13115. }
  13116. /****************************************************
  13117. * ParticleSystem
  13118. *****************************************************/
  13119. export module ParticleSystem {
  13120. /** !#en Enum for emitter modes
  13121. !#zh 发射模式 */
  13122. export enum EmitterMode {
  13123. GRAVITY = 0,
  13124. RADIUS = 0,
  13125. }
  13126. }
  13127. /****************************************************
  13128. * ParticleSystem
  13129. *****************************************************/
  13130. export module ParticleSystem {
  13131. /** !#en Enum for particles movement type.
  13132. !#zh 粒子位置类型 */
  13133. export enum PositionType {
  13134. FREE = 0,
  13135. RELATIVE = 0,
  13136. GROUPED = 0,
  13137. }
  13138. }
  13139. /****************************************************
  13140. * TiledMap
  13141. *****************************************************/
  13142. export module TiledMap {
  13143. /** !#en The orientation of tiled map.
  13144. !#zh Tiled Map 地图方向。 */
  13145. export enum Orientation {
  13146. ORTHO = 0,
  13147. HEX = 0,
  13148. ISO = 0,
  13149. NONE = 0,
  13150. MAP = 0,
  13151. LAYER = 0,
  13152. OBJECTGROUP = 0,
  13153. OBJECT = 0,
  13154. TILE = 0,
  13155. HORIZONTAL = 0,
  13156. VERTICAL = 0,
  13157. DIAGONAL = 0,
  13158. FLIPPED_ALL = 0,
  13159. FLIPPED_MASK = 0,
  13160. STAGGERAXIS_X = 0,
  13161. STAGGERAXIS_Y = 0,
  13162. STAGGERINDEX_ODD = 0,
  13163. STAGGERINDEX_EVEN = 0,
  13164. }
  13165. }
  13166. /****************************************************
  13167. * Node
  13168. *****************************************************/
  13169. export module Node {
  13170. /** !#en The event type supported by Node
  13171. !#zh Node 支持的事件类型 */
  13172. export class EventType {
  13173. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  13174. !#zh 当手指触摸到屏幕时。 */
  13175. static TOUCH_START: string;
  13176. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  13177. !#zh 当手指在屏幕上目标节点区域内移动时。 */
  13178. static TOUCH_MOVE: string;
  13179. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  13180. !#zh 当手指在目标节点区域内离开屏幕时。 */
  13181. static TOUCH_END: string;
  13182. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  13183. !#zh 当手指在目标节点区域外离开屏幕时。 */
  13184. static TOUCH_CANCEL: string;
  13185. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  13186. !#zh 当鼠标按下时触发一次。 */
  13187. static MOUSE_DOWN: string;
  13188. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  13189. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  13190. static MOUSE_MOVE: string;
  13191. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  13192. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  13193. static MOUSE_ENTER: string;
  13194. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  13195. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  13196. static MOUSE_LEAVE: string;
  13197. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  13198. !#zh 当鼠标从按下状态松开时触发一次。 */
  13199. static MOUSE_UP: string;
  13200. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  13201. !#zh 当鼠标滚轮滚动时。 */
  13202. static MOUSE_WHEEL: string;
  13203. }
  13204. }
  13205. /****************************************************
  13206. * Collider
  13207. *****************************************************/
  13208. export module Collider {
  13209. /** !#en Defines a Box Collider .
  13210. !#zh 用来定义包围盒碰撞体 */
  13211. export class Box {
  13212. /** !#en Position offset
  13213. !#zh 位置偏移量 */
  13214. offset: Vec2;
  13215. /** !#en Box size
  13216. !#zh 包围盒大小 */
  13217. size: Size;
  13218. }
  13219. }
  13220. /****************************************************
  13221. * Collider
  13222. *****************************************************/
  13223. export module Collider {
  13224. /** !#en Defines a Circle Collider .
  13225. !#zh 用来定义圆形碰撞体 */
  13226. export class Circle {
  13227. /** !#en Position offset
  13228. !#zh 位置偏移量 */
  13229. offset: Vec2;
  13230. /** !#en Circle radius
  13231. !#zh 圆形半径 */
  13232. radius: number;
  13233. }
  13234. }
  13235. /****************************************************
  13236. * Collider
  13237. *****************************************************/
  13238. export module Collider {
  13239. /** !#en Defines a Polygon Collider .
  13240. !#zh 用来定义多边形碰撞体 */
  13241. export class Polygon {
  13242. /** !#en Position offset
  13243. !#zh 位置偏移量 */
  13244. offset: Vec2;
  13245. /** !#en Polygon points
  13246. !#zh 多边形顶点数组 */
  13247. points: [Vec2];
  13248. }
  13249. }
  13250. /****************************************************
  13251. * Button
  13252. *****************************************************/
  13253. export module Button {
  13254. /** !#en Enum for transition type.
  13255. !#zh 过渡类型 */
  13256. export enum Transition {
  13257. NONE = 0,
  13258. COLOR = 0,
  13259. SPRITE = 0,
  13260. SCALE = 0,
  13261. }
  13262. }
  13263. /****************************************************
  13264. * Component
  13265. *****************************************************/
  13266. export module Component {
  13267. /** !#en
  13268. Component will register a event to target component's handler.
  13269. And it will trigger the handler when a certain event occurs.
  13270. !@zh
  13271. “EventHandler” 类用来设置场景中的事件回调,
  13272. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  13273. 并可通过 emit 方法调用目标函数。 */
  13274. export class EventHandler {
  13275. /** !#en Event target
  13276. !#zh 目标节点 */
  13277. target: Node;
  13278. /** !#en Component name
  13279. !#zh 目标组件名 */
  13280. component: string;
  13281. /** !#en Event handler
  13282. !#zh 响应事件函数名 */
  13283. handler: string;
  13284. /** !#en Custom Event Data
  13285. !#zh 自定义事件数据 */
  13286. customEventData: string;
  13287. /**
  13288. @param events events
  13289. @param params params
  13290. */
  13291. static emitEvents(events: Component.EventHandler[], ...params: any[]): void;
  13292. /**
  13293. !#en Emit event with params
  13294. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  13295. @param params params
  13296. @example
  13297. ```js
  13298. // Call Function
  13299. var eventHandler = new cc.Component.EventHandler();
  13300. eventHandler.target = newTarget;
  13301. eventHandler.component = "MainMenu";
  13302. eventHandler.handler = "OnClick"
  13303. eventHandler.emit(["param1", "param2", ....]);
  13304. ```
  13305. */
  13306. emit(params: any[]): void;
  13307. }
  13308. }
  13309. /****************************************************
  13310. * EditBox
  13311. *****************************************************/
  13312. export module EditBox {
  13313. /** !#en Enum for keyboard return types
  13314. !#zh 键盘的返回键类型 */
  13315. export enum KeyboardReturnType {
  13316. DEFAULT = 0,
  13317. DONE = 0,
  13318. SEND = 0,
  13319. SEARCH = 0,
  13320. GO = 0,
  13321. }
  13322. }
  13323. /****************************************************
  13324. * EditBox
  13325. *****************************************************/
  13326. export module EditBox {
  13327. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  13328. !#zh 输入模式 */
  13329. export enum InputMode {
  13330. ANY = 0,
  13331. EMAIL_ADDR = 0,
  13332. NUMERIC = 0,
  13333. PHONE_NUMBER = 0,
  13334. URL = 0,
  13335. DECIMAL = 0,
  13336. SINGLE_LINE = 0,
  13337. }
  13338. }
  13339. /****************************************************
  13340. * EditBox
  13341. *****************************************************/
  13342. export module EditBox {
  13343. /** !#en Enum for the EditBox's input flags
  13344. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  13345. export enum InputFlag {
  13346. PASSWORD = 0,
  13347. SENSITIVE = 0,
  13348. INITIAL_CAPS_WORD = 0,
  13349. INITIAL_CAPS_SENTENCE = 0,
  13350. INITIAL_CAPS_ALL_CHARACTERS = 0,
  13351. }
  13352. }
  13353. /****************************************************
  13354. * Label
  13355. *****************************************************/
  13356. export module Label {
  13357. /** !#en Enum for text alignment.
  13358. !#zh 文本横向对齐类型 */
  13359. export enum HorizontalAlign {
  13360. LEFT = 0,
  13361. CENTER = 0,
  13362. RIGHT = 0,
  13363. }
  13364. }
  13365. /****************************************************
  13366. * Label
  13367. *****************************************************/
  13368. export module Label {
  13369. /** !#en Enum for vertical text alignment.
  13370. !#zh 文本垂直对齐类型 */
  13371. export enum VerticalAlign {
  13372. TOP = 0,
  13373. CENTER = 0,
  13374. BOTTOM = 0,
  13375. }
  13376. }
  13377. /****************************************************
  13378. * Label
  13379. *****************************************************/
  13380. export module Label {
  13381. /** !#en Enum for Overflow.
  13382. !#zh Overflow 类型 */
  13383. export enum Overflow {
  13384. NONE = 0,
  13385. CLAMP = 0,
  13386. SHRINK = 0,
  13387. RESIZE_HEIGHT = 0,
  13388. }
  13389. }
  13390. /****************************************************
  13391. * Label
  13392. *****************************************************/
  13393. export module Label {
  13394. /** !#en Enum for font type.
  13395. !#zh Type 类型 */
  13396. export enum Type {
  13397. TTF = 0,
  13398. BMFont = 0,
  13399. SystemFont = 0,
  13400. }
  13401. }
  13402. /****************************************************
  13403. * Layout
  13404. *****************************************************/
  13405. export module Layout {
  13406. /** !#en Enum for Layout type
  13407. !#zh 布局类型 */
  13408. export enum Type {
  13409. NONE = 0,
  13410. HORIZONTAL = 0,
  13411. VERTICAL = 0,
  13412. GRID = 0,
  13413. }
  13414. }
  13415. /****************************************************
  13416. * Layout
  13417. *****************************************************/
  13418. export module Layout {
  13419. /** !#en Enum for Layout Resize Mode
  13420. !#zh 缩放模式 */
  13421. export enum ResizeMode {
  13422. NONE = 0,
  13423. CONTAINER = 0,
  13424. CHILDREN = 0,
  13425. }
  13426. }
  13427. /****************************************************
  13428. * Layout
  13429. *****************************************************/
  13430. export module Layout {
  13431. /** !#en Enum for Grid Layout start axis direction.
  13432. The items in grid layout will be arranged in each axis at first.;
  13433. !#zh 布局轴向,只用于 GRID 布局。 */
  13434. export enum AxisDirection {
  13435. HORIZONTAL = 0,
  13436. VERTICAL = 0,
  13437. }
  13438. }
  13439. /****************************************************
  13440. * Layout
  13441. *****************************************************/
  13442. export module Layout {
  13443. /** !#en Enum for vertical layout direction.
  13444. Used in Grid Layout together with AxisDirection is VERTICAL
  13445. !#zh 垂直方向布局方式 */
  13446. export enum VerticalDirection {
  13447. BOTTOM_TO_TOP = 0,
  13448. TOP_TO_BOTTOM = 0,
  13449. }
  13450. }
  13451. /****************************************************
  13452. * Layout
  13453. *****************************************************/
  13454. export module Layout {
  13455. /** !#en Enum for horizontal layout direction.
  13456. Used in Grid Layout together with AxisDirection is HORIZONTAL
  13457. !#zh 水平方向布局方式 */
  13458. export enum HorizontalDirection {
  13459. LEFT_TO_RIGHT = 0,
  13460. RIGHT_TO_LEFT = 0,
  13461. }
  13462. }
  13463. /****************************************************
  13464. * Mask
  13465. *****************************************************/
  13466. export module Mask {
  13467. /** !#en the type for mask.
  13468. !#zh 遮罩组件类型 */
  13469. export enum Type {
  13470. RECT = 0,
  13471. ELLIPSE = 0,
  13472. IMAGE_STENCIL = 0,
  13473. }
  13474. }
  13475. /****************************************************
  13476. * PageView
  13477. *****************************************************/
  13478. export module PageView {
  13479. /** !#en The Page View Size Mode
  13480. !#zh 页面视图每个页面统一的大小类型 */
  13481. export enum SizeMode {
  13482. Unified = 0,
  13483. Free = 0,
  13484. }
  13485. }
  13486. /****************************************************
  13487. * PageView
  13488. *****************************************************/
  13489. export module PageView {
  13490. /** !#en The Page View Direction
  13491. !#zh 页面视图滚动类型 */
  13492. export enum Direction {
  13493. Horizontal = 0,
  13494. Vertical = 0,
  13495. }
  13496. }
  13497. /****************************************************
  13498. * PageView
  13499. *****************************************************/
  13500. export module PageView {
  13501. /** !#en Enum for ScrollView event type.
  13502. !#zh 滚动视图事件类型 */
  13503. export enum EventType {
  13504. PAGE_TURNING = 0,
  13505. }
  13506. }
  13507. /****************************************************
  13508. * PageViewIndicator
  13509. *****************************************************/
  13510. export module PageViewIndicator {
  13511. /** !#en Enum for PageView Indicator direction
  13512. !#zh 页面视图指示器的摆放方向 */
  13513. export enum Direction {
  13514. HORIZONTAL = 0,
  13515. VERTICAL = 0,
  13516. }
  13517. }
  13518. /****************************************************
  13519. * ProgressBar
  13520. *****************************************************/
  13521. export module ProgressBar {
  13522. /** !#en Enum for ProgressBar mode
  13523. !#zh 进度条模式 */
  13524. export enum Mode {
  13525. HORIZONTAL = 0,
  13526. VERTICAL = 0,
  13527. FILLED = 0,
  13528. }
  13529. }
  13530. /****************************************************
  13531. * Scrollbar
  13532. *****************************************************/
  13533. export module Scrollbar {
  13534. /** Enum for Scrollbar direction */
  13535. export enum Direction {
  13536. HORIZONTAL = 0,
  13537. VERTICAL = 0,
  13538. }
  13539. }
  13540. /****************************************************
  13541. * ScrollView
  13542. *****************************************************/
  13543. export module ScrollView {
  13544. /** !#en Enum for ScrollView event type.
  13545. !#zh 滚动视图事件类型 */
  13546. export enum EventType {
  13547. SCROLL_TO_TOP = 0,
  13548. SCROLL_TO_BOTTOM = 0,
  13549. SCROLL_TO_LEFT = 0,
  13550. SCROLL_TO_RIGHT = 0,
  13551. SCROLLING = 0,
  13552. BOUNCE_TOP = 0,
  13553. BOUNCE_BOTTOM = 0,
  13554. BOUNCE_LEFT = 0,
  13555. BOUNCE_RIGHT = 0,
  13556. SCROLL_ENDED = 0,
  13557. TOUCH_UP = 0,
  13558. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  13559. SCROLL_BEGAN = 0,
  13560. }
  13561. }
  13562. /****************************************************
  13563. * Slider
  13564. *****************************************************/
  13565. export module Slider {
  13566. /** !#en The Slider Direction
  13567. !#zh 滑动器方向 */
  13568. export enum Direction {
  13569. Horizontal = 0,
  13570. Vertical = 0,
  13571. }
  13572. }
  13573. /****************************************************
  13574. * Sprite
  13575. *****************************************************/
  13576. export module Sprite {
  13577. /** !#en Enum for sprite type.
  13578. !#zh Sprite 类型 */
  13579. export enum Type {
  13580. SIMPLE = 0,
  13581. SLICED = 0,
  13582. TILED = 0,
  13583. FILLED = 0,
  13584. }
  13585. }
  13586. /****************************************************
  13587. * Sprite
  13588. *****************************************************/
  13589. export module Sprite {
  13590. /** !#en Enum for fill type.
  13591. !#zh 填充类型 */
  13592. export enum FillType {
  13593. HORIZONTAL = 0,
  13594. VERTICAL = 0,
  13595. RADIAL = 0,
  13596. }
  13597. }
  13598. /****************************************************
  13599. * Sprite
  13600. *****************************************************/
  13601. export module Sprite {
  13602. /** !#en Sprite Size can track trimmed size, raw size or none.
  13603. !#zh 精灵尺寸调整模式 */
  13604. export enum SizeMode {
  13605. CUSTOM = 0,
  13606. TRIMMED = 0,
  13607. RAW = 0,
  13608. }
  13609. }
  13610. /****************************************************
  13611. * VideoPlayer
  13612. *****************************************************/
  13613. export module VideoPlayer {
  13614. /** !#en Video event type
  13615. !#zh 视频事件类型 */
  13616. export enum EventType {
  13617. PLAYING = 0,
  13618. PAUSED = 0,
  13619. STOPPED = 0,
  13620. COMPLETED = 0,
  13621. }
  13622. }
  13623. /****************************************************
  13624. * VideoPlayer
  13625. *****************************************************/
  13626. export module VideoPlayer {
  13627. /** !#en Enum for video resouce type type.
  13628. !#zh 视频来源 */
  13629. export enum ResourceType {
  13630. REMOTE = 0,
  13631. LOCAL = 0,
  13632. }
  13633. }
  13634. /****************************************************
  13635. * WebView
  13636. *****************************************************/
  13637. export module WebView {
  13638. /** !#en WebView event type
  13639. !#zh 网页视图事件类型 */
  13640. export enum EventType {
  13641. LOADED = 0,
  13642. LOADING = 0,
  13643. ERROR = 0,
  13644. }
  13645. }
  13646. /****************************************************
  13647. * Event
  13648. *****************************************************/
  13649. export module Event {
  13650. /** !#en The Custom event
  13651. !#zh 自定义事件 */
  13652. export class EventCustom extends Event {
  13653. /**
  13654. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  13655. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13656. */
  13657. constructor(type: string, bubbles: boolean);
  13658. /** !#en A reference to the detailed data of the event
  13659. !#zh 事件的详细数据 */
  13660. detail: any;
  13661. /**
  13662. !#en Sets user data
  13663. !#zh 设置用户数据
  13664. @param data data
  13665. */
  13666. setUserData(data: any): void;
  13667. /**
  13668. !#en Gets user data
  13669. !#zh 获取用户数据
  13670. */
  13671. getUserData(): any;
  13672. /**
  13673. !#en Gets event name
  13674. !#zh 获取事件名称
  13675. */
  13676. getEventName(): string;
  13677. }
  13678. }
  13679. /****************************************************
  13680. * Event
  13681. *****************************************************/
  13682. export module Event {
  13683. /** !#en The mouse event
  13684. !#zh 鼠标事件类型 */
  13685. export class EventMouse extends Event {
  13686. /**
  13687. !#en Sets scroll data.
  13688. !#zh 设置鼠标的滚动数据。
  13689. @param scrollX scrollX
  13690. @param scrollY scrollY
  13691. */
  13692. setScrollData(scrollX: number, scrollY: number): void;
  13693. /**
  13694. !#en Returns the x axis scroll value.
  13695. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  13696. */
  13697. getScrollX(): number;
  13698. /**
  13699. !#en Returns the y axis scroll value.
  13700. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  13701. */
  13702. getScrollY(): number;
  13703. /**
  13704. !#en Sets cursor location.
  13705. !#zh 设置当前鼠标位置。
  13706. @param x x
  13707. @param y y
  13708. */
  13709. setLocation(x: number, y: number): void;
  13710. /**
  13711. !#en Returns cursor location.
  13712. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  13713. */
  13714. getLocation(): Vec2;
  13715. /**
  13716. !#en Returns the current cursor location in screen coordinates.
  13717. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  13718. */
  13719. getLocationInView(): Vec2;
  13720. /**
  13721. !#en Returns the previous touch location.
  13722. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  13723. */
  13724. getPreviousLocation(): Vec2;
  13725. /**
  13726. !#en Returns the delta distance from the previous location to current location.
  13727. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  13728. */
  13729. getDelta(): Vec2;
  13730. /**
  13731. !#en Returns the X axis delta distance from the previous location to current location.
  13732. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  13733. */
  13734. getDeltaX(): number;
  13735. /**
  13736. !#en Returns the Y axis delta distance from the previous location to current location.
  13737. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  13738. */
  13739. getDeltaY(): number;
  13740. /**
  13741. !#en Sets mouse button.
  13742. !#zh 设置鼠标按键。
  13743. @param button button
  13744. */
  13745. setButton(button: number): void;
  13746. /**
  13747. !#en Returns mouse button.
  13748. !#zh 获取鼠标按键。
  13749. */
  13750. getButton(): number;
  13751. /**
  13752. !#en Returns location X axis data.
  13753. !#zh 获取鼠标当前位置 X 轴。
  13754. */
  13755. getLocationX(): number;
  13756. /**
  13757. !#en Returns location Y axis data.
  13758. !#zh 获取鼠标当前位置 Y 轴。
  13759. */
  13760. getLocationY(): number;
  13761. /** !#en The none event code of mouse event.
  13762. !#zh 无。 */
  13763. static NONE: number;
  13764. /** !#en The event type code of mouse down event.
  13765. !#zh 鼠标按下事件。 */
  13766. static DOWN: number;
  13767. /** !#en The event type code of mouse up event.
  13768. !#zh 鼠标按下后释放事件。 */
  13769. static UP: number;
  13770. /** !#en The event type code of mouse move event.
  13771. !#zh 鼠标移动事件。 */
  13772. static MOVE: number;
  13773. /** !#en The event type code of mouse scroll event.
  13774. !#zh 鼠标滚轮事件。 */
  13775. static SCROLL: number;
  13776. /** !#en The tag of Mouse left button.
  13777. !#zh 鼠标左键的标签。 */
  13778. static BUTTON_LEFT: number;
  13779. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  13780. !#zh 鼠标右键的标签。 */
  13781. static BUTTON_RIGHT: number;
  13782. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  13783. !#zh 鼠标中键的标签。 */
  13784. static BUTTON_MIDDLE: number;
  13785. /** !#en The tag of Mouse button 4.
  13786. !#zh 鼠标按键 4 的标签。 */
  13787. static BUTTON_4: number;
  13788. /** !#en The tag of Mouse button 5.
  13789. !#zh 鼠标按键 5 的标签。 */
  13790. static BUTTON_5: number;
  13791. /** !#en The tag of Mouse button 6.
  13792. !#zh 鼠标按键 6 的标签。 */
  13793. static BUTTON_6: number;
  13794. /** !#en The tag of Mouse button 7.
  13795. !#zh 鼠标按键 7 的标签。 */
  13796. static BUTTON_7: number;
  13797. /** !#en The tag of Mouse button 8.
  13798. !#zh 鼠标按键 8 的标签。 */
  13799. static BUTTON_8: number;
  13800. }
  13801. }
  13802. /****************************************************
  13803. * Event
  13804. *****************************************************/
  13805. export module Event {
  13806. /** !#en The touch event
  13807. !#zh 触摸事件 */
  13808. export class EventTouch extends Event {
  13809. /**
  13810. @param touchArr The array of the touches
  13811. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  13812. */
  13813. constructor(touchArr: any[], bubbles: boolean);
  13814. /** !#en The current touch object
  13815. !#zh 当前触点对象 */
  13816. touch: Touch;
  13817. /**
  13818. !#en Returns event code.
  13819. !#zh 获取事件类型。
  13820. */
  13821. getEventCode(): number;
  13822. /**
  13823. !#en Returns touches of event.
  13824. !#zh 获取触摸点的列表。
  13825. */
  13826. getTouches(): any[];
  13827. /**
  13828. !#en Sets touch location.
  13829. !#zh 设置当前触点位置
  13830. @param x x
  13831. @param y y
  13832. */
  13833. setLocation(x: number, y: number): void;
  13834. /**
  13835. !#en Returns touch location.
  13836. !#zh 获取触点位置。
  13837. */
  13838. getLocation(): Vec2;
  13839. /**
  13840. !#en Returns the current touch location in screen coordinates.
  13841. !#zh 获取当前触点在游戏窗口中的位置。
  13842. */
  13843. getLocationInView(): Vec2;
  13844. /**
  13845. !#en Returns the previous touch location.
  13846. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  13847. */
  13848. getPreviousLocation(): Vec2;
  13849. /**
  13850. !#en Returns the start touch location.
  13851. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  13852. */
  13853. getStartLocation(): Vec2;
  13854. /**
  13855. !#en Returns the id of cc.Touch.
  13856. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  13857. */
  13858. getID(): number;
  13859. /**
  13860. !#en Returns the delta distance from the previous location to current location.
  13861. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  13862. */
  13863. getDelta(): Vec2;
  13864. /**
  13865. !#en Returns the X axis delta distance from the previous location to current location.
  13866. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  13867. */
  13868. getDeltaX(): number;
  13869. /**
  13870. !#en Returns the Y axis delta distance from the previous location to current location.
  13871. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  13872. */
  13873. getDeltaY(): number;
  13874. /**
  13875. !#en Returns location X axis data.
  13876. !#zh 获取当前触点 X 轴位置。
  13877. */
  13878. getLocationX(): number;
  13879. /**
  13880. !#en Returns location Y axis data.
  13881. !#zh 获取当前触点 Y 轴位置。
  13882. */
  13883. getLocationY(): number;
  13884. }
  13885. }
  13886. /****************************************************
  13887. * Event
  13888. *****************************************************/
  13889. export module Event {
  13890. /** !#en The acceleration event
  13891. !#zh 加速度事件 */
  13892. export class EventAcceleration extends Event {
  13893. }
  13894. }
  13895. /****************************************************
  13896. * Event
  13897. *****************************************************/
  13898. export module Event {
  13899. /** !#en The keyboard event
  13900. !#zh 键盘事件 */
  13901. export class EventKeyboard extends Event {
  13902. }
  13903. }
  13904. /****************************************************
  13905. * SystemEvent
  13906. *****************************************************/
  13907. export module SystemEvent {
  13908. /** !#en The event type supported by SystemEvent
  13909. !#zh SystemEvent 支持的事件类型 */
  13910. export class EventType {
  13911. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  13912. !#zh 当按下按键时触发的事件 */
  13913. static KEY_DOWN: string;
  13914. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  13915. !#zh 当松开按键时触发的事件 */
  13916. static KEY_UP: string;
  13917. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  13918. !#zh 重力感应 */
  13919. static DEVICEMOTION: string;
  13920. }
  13921. }
  13922. /****************************************************
  13923. * Graphics
  13924. *****************************************************/
  13925. export module Graphics {
  13926. /** !#en Enum for LineCap.
  13927. !#zh 线段末端属性 */
  13928. export enum LineCap {
  13929. BUTT = 0,
  13930. ROUND = 0,
  13931. SQUARE = 0,
  13932. }
  13933. }
  13934. /****************************************************
  13935. * Graphics
  13936. *****************************************************/
  13937. export module Graphics {
  13938. /** !#en Enum for LineJoin.
  13939. !#zh 线段拐角属性 */
  13940. export enum LineJoin {
  13941. BEVEL = 0,
  13942. ROUND = 0,
  13943. MITER = 0,
  13944. }
  13945. }
  13946. /****************************************************
  13947. * Pipeline
  13948. *****************************************************/
  13949. export module Pipeline {
  13950. /** The downloader pipe, it can download several types of files:
  13951. 1. Text
  13952. 2. Image
  13953. 3. Script
  13954. 4. Audio
  13955. 5. Assets
  13956. All unknown type will be downloaded as plain text.
  13957. You can pass custom supported types in the constructor. */
  13958. export class Downloader {
  13959. /**
  13960. Constructor of Downloader, you can pass custom supported types.
  13961. @param extMap Custom supported types with corresponded handler
  13962. @example
  13963. ```js
  13964. var downloader = new Downloader({
  13965. // This will match all url with `.scene` extension or all url with `scene` type
  13966. 'scene' : function (url, callback) {}
  13967. });
  13968. ```
  13969. */
  13970. constructor(extMap: any);
  13971. /**
  13972. Add custom supported types handler or modify existing type handler.
  13973. @param extMap Custom supported types with corresponded handler
  13974. */
  13975. addHandlers(extMap: any): void;
  13976. }
  13977. }
  13978. /****************************************************
  13979. * Pipeline
  13980. *****************************************************/
  13981. export module Pipeline {
  13982. /** The loader pipe, it can load several types of files:
  13983. 1. Images
  13984. 2. JSON
  13985. 3. Plist
  13986. 4. Audio
  13987. 5. Font
  13988. 6. Cocos Creator scene
  13989. It will not interfere with items of unknown type.
  13990. You can pass custom supported types in the constructor. */
  13991. export class Loader {
  13992. /**
  13993. Constructor of Loader, you can pass custom supported types.
  13994. @param extMap Custom supported types with corresponded handler
  13995. @example
  13996. ```js
  13997. var loader = new Loader({
  13998. // This will match all url with `.scene` extension or all url with `scene` type
  13999. 'scene' : function (url, callback) {}
  14000. });
  14001. ```
  14002. */
  14003. constructor(extMap: any);
  14004. /**
  14005. Add custom supported types handler or modify existing type handler.
  14006. @param extMap Custom supported types with corresponded handler
  14007. */
  14008. addHandlers(extMap: any): void;
  14009. }
  14010. }
  14011. /****************************************************
  14012. * LoadingItems
  14013. *****************************************************/
  14014. export module LoadingItems {
  14015. /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR
  14016. !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */
  14017. export enum ItemState {
  14018. WORKING = 0,
  14019. COMPLETET = 0,
  14020. ERROR = 0,
  14021. }
  14022. }
  14023. /****************************************************
  14024. * Texture2D
  14025. *****************************************************/
  14026. export module Texture2D {
  14027. /** The texture pixel format, default value is RGBA8888 */
  14028. export enum PixelFormat {
  14029. RGB565 = 0,
  14030. RGB5A1 = 0,
  14031. RGBA4444 = 0,
  14032. RGB888 = 0,
  14033. RGBA8888 = 0,
  14034. A8 = 0,
  14035. I8 = 0,
  14036. AI88 = 0,
  14037. }
  14038. }
  14039. /****************************************************
  14040. * Texture2D
  14041. *****************************************************/
  14042. export module Texture2D {
  14043. /** The texture wrap mode */
  14044. export enum WrapMode {
  14045. REPEAT = 0,
  14046. CLAMP_TO_EDGE = 0,
  14047. MIRRORED_REPEAT = 0,
  14048. }
  14049. }
  14050. /****************************************************
  14051. * Texture2D
  14052. *****************************************************/
  14053. export module Texture2D {
  14054. /** The texture filter mode */
  14055. export enum Filter {
  14056. LINEAR = 0,
  14057. NEAREST = 0,
  14058. }
  14059. }
  14060. }
  14061. /** !#en
  14062. 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.
  14063. !#zh
  14064. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  14065. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  14066. declare module anysdk {
  14067. /** !#en
  14068. agent manager of plugin
  14069. !#zh
  14070. 插件管理对象 */
  14071. export var agentManager: anysdk.AgentManager;
  14072. /** !#en
  14073. agent manager of plugin
  14074. !#zh
  14075. 插件管理类 */
  14076. export class AgentManager {
  14077. /**
  14078. !#en
  14079. AppKey appSecret and privateKey are the only three parameters generated
  14080. after the packing tool client finishes creating the game.
  14081. The oauthLoginServer parameter is the API address provided by the game service
  14082. to login verification
  14083. !#zh
  14084. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  14085. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  14086. @param appKey appKey
  14087. @param appSecret appSecret
  14088. @param privateKey privateKey
  14089. @param oauthLoginServer oauthLoginServer
  14090. */
  14091. init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void;
  14092. /**
  14093. !#en
  14094. load all plugins, the operation includes SDK`s initialization
  14095. !#zh
  14096. 加载所有插件,该操作包含了 SDKs 初始化
  14097. @param callback callback
  14098. @param target The object to bind to.
  14099. */
  14100. loadAllPlugins(callback: Function, target: any): void;
  14101. /**
  14102. !#en
  14103. unload all plugins
  14104. !#zh
  14105. 卸载插件
  14106. */
  14107. unloadAllPlugins(): void;
  14108. /**
  14109. !#en
  14110. get user system plugin
  14111. !#zh
  14112. 获取用户系统插件
  14113. */
  14114. getUserPlugin(): anysdk.ProtocolUser;
  14115. /**
  14116. !#en
  14117. get IAP system plugins
  14118. !#zh
  14119. 获取支付系统插件
  14120. */
  14121. getIAPPlugins(): anysdk.ProtocolIAP[];
  14122. /**
  14123. !#en
  14124. get IAP system plugin
  14125. !#zh
  14126. 获取支付系统插件
  14127. */
  14128. getIAPPlugin(): anysdk.ProtocolIAP;
  14129. /**
  14130. !#en
  14131. get social system plugin
  14132. !#zh
  14133. 获取社交系统插件
  14134. */
  14135. getSocialPlugin(): anysdk.ProtocolSocial;
  14136. /**
  14137. !#en
  14138. get share system plugin
  14139. !#zh
  14140. 获取分享系统插件
  14141. */
  14142. getSharePlugin(): anysdk.ProtocolShare;
  14143. /**
  14144. !#en
  14145. get analytics system plugin
  14146. !#zh
  14147. 获取统计系统插件
  14148. */
  14149. getAnalyticsPlugin(): anysdk.ProtocolAnalytics;
  14150. /**
  14151. !#en
  14152. get ads system plugin
  14153. !#zh
  14154. 获取广告系统插件
  14155. */
  14156. getAdsPlugin(): anysdk.ProtocolAds;
  14157. /**
  14158. !#en
  14159. get push system plugin
  14160. !#zh
  14161. 获取推送系统插件
  14162. */
  14163. getPushPlugin(): anysdk.ProtocolPush;
  14164. /**
  14165. !#en
  14166. get REC system plugin
  14167. !#zh
  14168. 获取录屏系统插件
  14169. */
  14170. getRECPlugin(): anysdk.ProtocolREC;
  14171. /**
  14172. !#en
  14173. get crash system plugin
  14174. !#zh
  14175. 获取崩溃分析系统插件
  14176. */
  14177. getCrashPlugin(): anysdk.ProtocolCrash;
  14178. /**
  14179. !#en
  14180. get ad track system plugin
  14181. !#zh
  14182. 获取广告追踪系统插件
  14183. */
  14184. getAdTrackingPlugin(): anysdk.ProtocolAdTracking;
  14185. /**
  14186. !#en
  14187. get custom system plugin
  14188. !#zh
  14189. 获取自定义系统插件
  14190. */
  14191. getCustomPlugin(): anysdk.ProtocolCustom;
  14192. /**
  14193. !#en
  14194. get custom parameter
  14195. !#zh
  14196. 获取自定义参数
  14197. */
  14198. getCustomParam(): string;
  14199. /**
  14200. !#en
  14201. get channel id
  14202. !#zh
  14203. 获取渠道唯一表示符
  14204. */
  14205. getChannelId(): string;
  14206. /**
  14207. !#en
  14208. get status of analytics
  14209. !#zh
  14210. 获取统计状态
  14211. */
  14212. isAnaylticsEnabled(): boolean;
  14213. /**
  14214. !#en
  14215. set whether to analytics
  14216. !#zh
  14217. 设置是否统计
  14218. @param enabled enabled
  14219. */
  14220. setIsAnaylticsEnabled(enabled: boolean): void;
  14221. /**
  14222. !#en
  14223. destory instance
  14224. !#zh
  14225. 销毁单例
  14226. */
  14227. static end(): void;
  14228. /**
  14229. !#en
  14230. get instance
  14231. !#zh
  14232. 获取单例
  14233. */
  14234. static getInstance(): anysdk.AgentManager;
  14235. }
  14236. /** !#en
  14237. plugin protocol
  14238. !#zh
  14239. 插件协议 */
  14240. export class PluginProtocol {
  14241. /**
  14242. !#en
  14243. Check whether the function is supported
  14244. !#zh
  14245. 判断函数是否支持
  14246. @param functionName functionName
  14247. */
  14248. isFunctionSupported(functionName: string): boolean;
  14249. /**
  14250. !#en
  14251. get plugin name
  14252. !#zh
  14253. 获取插件名称
  14254. */
  14255. getPluginName(): string;
  14256. /**
  14257. !#en
  14258. get plugin version
  14259. !#zh
  14260. 获取插件版本
  14261. */
  14262. getPluginVersion(): string;
  14263. /**
  14264. !#en
  14265. get SDK version
  14266. !#zh
  14267. 获取 SDK 版本
  14268. */
  14269. getSDKVersion(): string;
  14270. /**
  14271. !#en
  14272. void methods for reflections with parameter
  14273. !#zh
  14274. 反射调用带参数的void方法
  14275. @param funName funName
  14276. @param args optional arguments
  14277. */
  14278. callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void;
  14279. /**
  14280. !#en
  14281. String methods for reflections with parameter
  14282. !#zh
  14283. 反射调用带参数的 String 方法
  14284. @param funName funName
  14285. @param args optional arguments
  14286. */
  14287. callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string;
  14288. /**
  14289. !#en
  14290. int methods for reflections with parameter
  14291. !#zh
  14292. 反射调用带参数的 Int 方法
  14293. @param funName funName
  14294. @param args optional arguments
  14295. */
  14296. callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14297. /**
  14298. !#en
  14299. boolean methods for reflections with parameter
  14300. !#zh
  14301. 反射调用带参数的 boolean 方法
  14302. @param funName funName
  14303. @param args optional arguments
  14304. */
  14305. callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean;
  14306. /**
  14307. !#en
  14308. float methods for reflections with parameter
  14309. !#zh
  14310. 反射调用带参数的 float 方法
  14311. @param funName funName
  14312. @param args optional arguments
  14313. */
  14314. callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14315. }
  14316. /** !#en
  14317. user protocol
  14318. !#zh
  14319. 用户系统协议接口 */
  14320. export class ProtocolUser extends PluginProtocol {
  14321. /**
  14322. !#en
  14323. login interface
  14324. !#zh
  14325. 登录接口
  14326. @param args optional arguments
  14327. */
  14328. login(...args: string|any[]): void;
  14329. /**
  14330. !#en
  14331. get status of login
  14332. !#zh
  14333. 获取登录状态
  14334. */
  14335. isLogined(): boolean;
  14336. /**
  14337. !#en
  14338. get user ID
  14339. !#zh
  14340. 获取用户唯一标示符
  14341. */
  14342. getUserID(): string;
  14343. /**
  14344. !#en
  14345. get plugin ID
  14346. !#zh
  14347. 获取插件ID
  14348. */
  14349. getPluginId(): string;
  14350. /**
  14351. !#en
  14352. set listener
  14353. !#zh
  14354. 设置用户系统的监听
  14355. @param listener listener
  14356. @param target target
  14357. */
  14358. setListener(listener: Function, target: any): void;
  14359. /**
  14360. !#en
  14361. get listener
  14362. !#zh
  14363. 获取用户系统的监听
  14364. */
  14365. getListener(): Function;
  14366. /**
  14367. !#en
  14368. logout
  14369. Before to invoke, you need to verdict whether this properties existed
  14370. !#zh
  14371. 登出,调用前需要判断属性是否存在
  14372. */
  14373. logout(): void;
  14374. /**
  14375. !#en
  14376. show toolbar
  14377. Before to invoke, you need to verdict whether this properties existed
  14378. !#zh
  14379. 显示悬浮窗,调用前需要判断属性是否存在
  14380. @param place place
  14381. */
  14382. showToolBar(place: anysdk.ToolBarPlace): void;
  14383. /**
  14384. !#en
  14385. hide toolbar
  14386. Before to invoke, you need to verdict whether this properties existed
  14387. !#zh
  14388. 隐藏悬浮窗,调用前需要判断属性是否存在
  14389. */
  14390. hideToolBar(): void;
  14391. /**
  14392. !#en
  14393. enter platform
  14394. Before to invoke, you need to verdict whether this properties existed
  14395. !#zh
  14396. 显示平台中心,调用前需要判断属性是否存在
  14397. */
  14398. enterPlatform(): void;
  14399. /**
  14400. !#en
  14401. show exit page
  14402. Before to invoke, you need to verdict whether this properties existed
  14403. !#zh
  14404. 显示退出界面,调用前需要判断属性是否存在
  14405. */
  14406. exit(): void;
  14407. /**
  14408. !#en
  14409. show pause page
  14410. Before to invoke, you need to verdict whether this properties existed
  14411. !#zh
  14412. 显示暂停界面,调用前需要判断属性是否存在
  14413. */
  14414. pause(): void;
  14415. /**
  14416. !#en
  14417. Real-name registration
  14418. Before to invoke, you need to verdict whether this properties existed
  14419. !#zh
  14420. 实名注册,调用前需要判断属性是否存在
  14421. */
  14422. realNameRegister(): void;
  14423. /**
  14424. !#en
  14425. Anti-addiction query
  14426. Before to invoke, you need to verdict whether this properties existed
  14427. !#zh
  14428. 防沉迷查询,调用前需要判断属性是否存在
  14429. */
  14430. antiAddictionQuery(): void;
  14431. /**
  14432. !#en
  14433. submit game role information
  14434. Before to invoke, you need to verdict whether this properties existed
  14435. !#zh
  14436. 提交角色信息,调用前需要判断属性是否存在
  14437. @param data data
  14438. */
  14439. submitLoginGameRole(data: any): void;
  14440. /**
  14441. !#en
  14442. get user information
  14443. Before to invoke, you need to verdict whether this properties existed
  14444. !#zh
  14445. 获取用户信息,调用前需要判断属性是否存在
  14446. @param info info
  14447. */
  14448. getUserInfo(info: any): void;
  14449. /**
  14450. !#en
  14451. set login type
  14452. Before to invoke, you need to verdict whether this properties existed
  14453. !#zh
  14454. 设置登录类型,调用前需要判断属性是否存在
  14455. @param info info
  14456. */
  14457. getAvailableLoginType(info: any): void;
  14458. /**
  14459. !#en
  14460. set login type
  14461. Before to invoke, you need to verdict whether this properties existed
  14462. !#zh
  14463. 设置登录类型,调用前需要判断属性是否存在
  14464. @param loginType loginType
  14465. */
  14466. setLoginType(loginType: string): void;
  14467. /**
  14468. !#en
  14469. send to desktop
  14470. Before to invoke, you need to verdict whether this properties existed
  14471. !#zh
  14472. 发送到桌面,调用前需要判断属性是否存在
  14473. */
  14474. sendToDesktop(): void;
  14475. /**
  14476. !#en
  14477. open bbs
  14478. Before to invoke, you need to verdict whether this properties existed
  14479. !#zh
  14480. 打开论坛,调用前需要判断属性是否存在
  14481. */
  14482. openBBS(): void;
  14483. }
  14484. /** !#en
  14485. IAP protocol
  14486. !#zh
  14487. 支付系统协议接口 */
  14488. export class ProtocolIAP extends PluginProtocol {
  14489. /**
  14490. !#en
  14491. pay interface
  14492. !#zh
  14493. 支付接口
  14494. @param info Type:map
  14495. */
  14496. payForProduct(info: any): void;
  14497. /**
  14498. !#en
  14499. get order ID
  14500. !#zh
  14501. 获取订单ID
  14502. */
  14503. getOrderId(): string;
  14504. /**
  14505. !#en
  14506. reset the pay status
  14507. !#zh
  14508. 重置支付状态
  14509. */
  14510. static resetPayState(): void;
  14511. /**
  14512. !#en
  14513. get plugin ID
  14514. !#zh
  14515. 获取插件ID
  14516. */
  14517. getPluginId(): string;
  14518. /**
  14519. !#en
  14520. set listener
  14521. !#zh
  14522. 设置支付系统的监听
  14523. @param listener listener
  14524. @param target target
  14525. */
  14526. setListener(listener: Function, target: any): void;
  14527. /**
  14528. !#en
  14529. get listener
  14530. !#zh
  14531. 获取支付系统的监听
  14532. */
  14533. getListener(): Function;
  14534. }
  14535. /** !#en
  14536. analytics protocol
  14537. !#zh
  14538. 统计系统协议接口 */
  14539. export class ProtocolAnalytics extends PluginProtocol {
  14540. /**
  14541. !#en
  14542. Start a new session.
  14543. !#zh
  14544. 启动会话
  14545. */
  14546. startSession(): void;
  14547. /**
  14548. !#en
  14549. Stop a session.
  14550. !#zh
  14551. 关闭会话
  14552. */
  14553. stopSession(): void;
  14554. /**
  14555. !#en
  14556. Set the timeout for expiring a session.
  14557. !#zh
  14558. 设置会话超时时间
  14559. @param millis Type: long
  14560. */
  14561. setSessionContinueMillis(millis: number): void;
  14562. /**
  14563. !#en
  14564. log an error
  14565. !#zh
  14566. 捕捉异常
  14567. @param errorId errorId
  14568. @param message message
  14569. */
  14570. logError(errorId: string, message: string): void;
  14571. /**
  14572. !#en
  14573. log an event.
  14574. !#zh
  14575. 捕捉事件
  14576. @param errorId errorId
  14577. @param args optional arguments Type: map
  14578. */
  14579. logEvent(errorId: string, ...args: any[]): void;
  14580. /**
  14581. !#en
  14582. Track an event begin.
  14583. !#zh
  14584. 统计事件开始
  14585. @param eventId eventId
  14586. */
  14587. logTimedEventBegin(eventId: string): void;
  14588. /**
  14589. !#en
  14590. Track an event end.
  14591. !#zh
  14592. 统计事件结束
  14593. @param eventId eventId
  14594. */
  14595. logTimedEventEnd(eventId: string): void;
  14596. /**
  14597. !#en
  14598. set Whether to catch uncaught exceptions to server.
  14599. !#zh
  14600. 设置是否开启自动异常捕捉
  14601. @param enabled enabled
  14602. */
  14603. setCaptureUncaughtException(enabled: boolean): void;
  14604. /**
  14605. !#en
  14606. analytics account information
  14607. !#zh
  14608. 统计玩家帐户信息
  14609. @param paramMap Type: map
  14610. */
  14611. setAccount(paramMap: any): void;
  14612. /**
  14613. !#en
  14614. track user to request payment
  14615. !#zh
  14616. 跟踪用户支付请求
  14617. @param paramMap Type: map
  14618. */
  14619. onChargeRequest(paramMap: any): void;
  14620. /**
  14621. !#en
  14622. track Successful payment
  14623. !#zh
  14624. 追踪用户支付成功
  14625. @param orderID orderID
  14626. */
  14627. onChargeSuccess(orderID: string): void;
  14628. /**
  14629. !#en
  14630. track failed payment
  14631. !#zh
  14632. 追踪用户支付失败
  14633. @param paramMap Type: map
  14634. */
  14635. onChargeFail(paramMap: any): void;
  14636. /**
  14637. !#en
  14638. track Successful payment
  14639. !#zh
  14640. 统计玩家支付成功
  14641. @param paramMap Type: map
  14642. */
  14643. onChargeOnlySuccess(paramMap: any): void;
  14644. /**
  14645. !#en
  14646. track user purchase
  14647. !#zh
  14648. 统计玩家消费
  14649. @param paramMap Type: map
  14650. */
  14651. onPurchase(paramMap: any): void;
  14652. /**
  14653. !#en
  14654. track user to use goods
  14655. !#zh
  14656. 统计玩家使用道具
  14657. @param paramMap Type: map
  14658. */
  14659. onUse(paramMap: any): void;
  14660. /**
  14661. !#en
  14662. track user to reward goods
  14663. !#zh
  14664. 统计玩家获取奖励
  14665. @param paramMap Type: map
  14666. */
  14667. onReward(paramMap: any): void;
  14668. /**
  14669. !#en
  14670. start level
  14671. !#zh
  14672. 开始关卡
  14673. @param paramMap Type: map
  14674. */
  14675. startLevel(paramMap: any): void;
  14676. /**
  14677. !#en
  14678. finish level
  14679. !#zh
  14680. 结束关卡
  14681. @param levelID levelID
  14682. */
  14683. finishLevel(levelID: string): void;
  14684. /**
  14685. !#en
  14686. failed level
  14687. !#zh
  14688. 关卡失败
  14689. @param paramMap Type: map
  14690. */
  14691. failLevel(paramMap: any): void;
  14692. /**
  14693. !#en
  14694. start task
  14695. !#zh
  14696. 开始任务
  14697. @param paramMap Type: map
  14698. */
  14699. startTask(paramMap: any): void;
  14700. /**
  14701. !#en
  14702. finish task
  14703. !#zh
  14704. 完成任务
  14705. @param taskID taskID
  14706. */
  14707. finishTask(taskID: string): void;
  14708. /**
  14709. !#en
  14710. failed task
  14711. !#zh
  14712. 任务失败
  14713. @param paramMap Type: map
  14714. */
  14715. failTask(paramMap: any): void;
  14716. }
  14717. /** !#en
  14718. share protocol
  14719. !#zh
  14720. 分享系统协议接口 */
  14721. export class ProtocolShare extends PluginProtocol {
  14722. /**
  14723. !#en
  14724. share interface
  14725. !#zh
  14726. 分享
  14727. @param info Type: map
  14728. */
  14729. share(info: any): void;
  14730. /**
  14731. !#en
  14732. set listener
  14733. !#zh
  14734. 设置分享系统的监听
  14735. @param listener listener
  14736. @param target target
  14737. */
  14738. setListener(listener: Function, target: any): void;
  14739. /**
  14740. !#en
  14741. get listener
  14742. !#zh
  14743. 获取分享系统的监听
  14744. */
  14745. getListener(): Function;
  14746. }
  14747. /** !#en
  14748. ads protocol
  14749. !#zh
  14750. 广告系统协议接口 */
  14751. export class ProtocolAds extends PluginProtocol {
  14752. /**
  14753. !#en
  14754. hide ads view
  14755. !#zh
  14756. 隐藏广告
  14757. @param adstype adstype
  14758. @param idx idx
  14759. */
  14760. hideAds(adstype: anysdk.AdsType, idx: number): void;
  14761. /**
  14762. !#en
  14763. preload ads view
  14764. !#zh
  14765. 预加载广告
  14766. @param adstype adstype
  14767. @param idx idx
  14768. */
  14769. preloadAds(adstype: anysdk.AdsType, idx: number): void;
  14770. /**
  14771. !#en
  14772. query points
  14773. !#zh
  14774. 查询分数
  14775. */
  14776. queryPoints(): number;
  14777. /**
  14778. !#en
  14779. get whether the ads type is supported
  14780. !#zh
  14781. 获取广告类型是否支持
  14782. @param arg0 arg0
  14783. */
  14784. isAdTypeSupported(arg0: anysdk.AdsType): boolean;
  14785. /**
  14786. !#en
  14787. spend point
  14788. !#zh
  14789. 消费分数
  14790. @param points points
  14791. */
  14792. spendPoints(points: number): void;
  14793. /**
  14794. !#en
  14795. set listener
  14796. !#zh
  14797. 设置广告系统的监听
  14798. @param listener listener
  14799. @param target target
  14800. */
  14801. setListener(listener: Function, target: any): void;
  14802. /**
  14803. !#en
  14804. get listener
  14805. !#zh
  14806. 获取广告系统的监听
  14807. */
  14808. getListener(): Function;
  14809. }
  14810. /** !#en
  14811. social protocol
  14812. !#zh
  14813. 社交系统协议接口 */
  14814. export class ProtocolSocial extends PluginProtocol {
  14815. /**
  14816. !#en
  14817. sign in
  14818. !#zh
  14819. 登录
  14820. */
  14821. signIn(): void;
  14822. /**
  14823. !#en
  14824. sign out
  14825. !#zh
  14826. 登出
  14827. */
  14828. signOut(): void;
  14829. /**
  14830. !#en
  14831. submit score
  14832. !#zh
  14833. 提交分数
  14834. @param leadboardID leadboardID
  14835. @param score Type: long
  14836. */
  14837. submitScore(leadboardID: string, score: number): void;
  14838. /**
  14839. !#en
  14840. show the id of Leaderboard page
  14841. !#zh
  14842. 根据唯一标识符显示排行榜
  14843. @param leaderboardID leaderboardID
  14844. */
  14845. showLeaderboard(leaderboardID: string): void;
  14846. /**
  14847. !#en
  14848. show the page of achievements
  14849. !#zh
  14850. 显示成就榜
  14851. */
  14852. showAchievements(): void;
  14853. /**
  14854. !#en
  14855. unlock achievement
  14856. !#zh
  14857. 解锁成就
  14858. @param info Type: map
  14859. */
  14860. share(info: any): void;
  14861. /**
  14862. !#en
  14863. set listener
  14864. !#zh
  14865. 设置社交系统的监听
  14866. @param listener listener
  14867. @param target target
  14868. */
  14869. setListener(listener: Function, target: any): void;
  14870. /**
  14871. !#en
  14872. get listener
  14873. !#zh
  14874. 获取社交系统的监听
  14875. */
  14876. getListener(): Function;
  14877. /**
  14878. !#en
  14879. get friends info
  14880. Before to invoke, you need to verdict whether this properties existed
  14881. !#zh
  14882. 获取好友信息,调用前需要判断属性是否存在
  14883. */
  14884. pauseRecording(): void;
  14885. /**
  14886. !#en
  14887. interact
  14888. Before to invoke, you need to verdict whether this properties existed
  14889. !#zh
  14890. 订阅,调用前需要判断属性是否存在
  14891. */
  14892. interact(): void;
  14893. /**
  14894. !#en
  14895. subscribe
  14896. Before to invoke, you need to verdict whether this properties existed
  14897. !#zh
  14898. 关注,调用前需要判断属性是否存在
  14899. */
  14900. subscribe(): void;
  14901. }
  14902. /** !#en
  14903. push protocol
  14904. !#zh
  14905. 推送系统协议接口 */
  14906. export class ProtocolPush extends PluginProtocol {
  14907. /**
  14908. !#en
  14909. start Push services
  14910. !#zh
  14911. 启动推送服务
  14912. */
  14913. startPush(): void;
  14914. /**
  14915. !#en
  14916. close Push services
  14917. !#zh
  14918. 暂停推送服务
  14919. */
  14920. closePush(): void;
  14921. /**
  14922. !#en
  14923. delete alias
  14924. !#zh
  14925. 删除别名
  14926. @param alias alias
  14927. */
  14928. delAlias(alias: string): void;
  14929. /**
  14930. !#en
  14931. set alias
  14932. !#zh
  14933. 设置别名
  14934. @param alias alias
  14935. */
  14936. setAlias(alias: string): void;
  14937. /**
  14938. !#en
  14939. delete tags
  14940. !#zh
  14941. 删除标签
  14942. @param tags Type: list
  14943. */
  14944. delTags(tags: any): void;
  14945. /**
  14946. !#en
  14947. set tags
  14948. !#zh
  14949. 设置标签
  14950. @param tags Type: list
  14951. */
  14952. setTags(tags: any): void;
  14953. /**
  14954. !#en
  14955. set listener
  14956. !#zh
  14957. 设置推送系统的监听
  14958. @param listener listener
  14959. @param target target
  14960. */
  14961. setListener(listener: Function, target: any): void;
  14962. /**
  14963. !#en
  14964. get listener
  14965. !#zh
  14966. 获取推送系统的监听
  14967. */
  14968. getListener(): Function;
  14969. }
  14970. /** !#en
  14971. crash protocol
  14972. !#zh
  14973. 崩溃分析系统协议接口 */
  14974. export class ProtocolCrash extends PluginProtocol {
  14975. /**
  14976. !#en
  14977. set user identifier
  14978. !#zh
  14979. 统计用户唯一标识符
  14980. @param identifier identifier
  14981. */
  14982. setUserIdentifier(identifier: string): void;
  14983. /**
  14984. !#en
  14985. The uploader captured in exception information
  14986. !#zh
  14987. 上报异常信息
  14988. @param message message
  14989. @param exception exception
  14990. */
  14991. reportException(message: string, exception: string): void;
  14992. /**
  14993. !#en
  14994. customize logging
  14995. !#zh
  14996. 自定义日志记录
  14997. @param breadcrumb breadcrumb
  14998. */
  14999. leaveBreadcrumb(breadcrumb: string): void;
  15000. }
  15001. /** !#en
  15002. REC protocol
  15003. !#zh
  15004. 录屏系统协议接口 */
  15005. export class ProtocolREC extends PluginProtocol {
  15006. /**
  15007. !#en
  15008. share video
  15009. !#zh
  15010. 分享视频
  15011. @param info Type: map
  15012. */
  15013. share(info: any): void;
  15014. /**
  15015. !#en
  15016. Start to record video
  15017. !#zh
  15018. 开始录制视频
  15019. */
  15020. startRecording(): void;
  15021. /**
  15022. !#en
  15023. Start to record video
  15024. !#zh
  15025. 结束录制视频
  15026. */
  15027. stopRecording(): void;
  15028. /**
  15029. !#en
  15030. set listener
  15031. !#zh
  15032. 设置录屏系统的监听
  15033. @param listener listener
  15034. @param target target
  15035. */
  15036. setListener(listener: Function, target: any): void;
  15037. /**
  15038. !#en
  15039. get listener
  15040. !#zh
  15041. 获取录屏系统的监听
  15042. */
  15043. getListener(): Function;
  15044. /**
  15045. !#en
  15046. pause to record video
  15047. Before to invoke, you need to verdict whether this properties existed
  15048. !#zh
  15049. 暂停录制视频,调用前需要判断属性是否存在
  15050. */
  15051. pauseRecording(): void;
  15052. /**
  15053. !#en
  15054. resume to record video
  15055. Before to invoke, you need to verdict whether this properties existed
  15056. !#zh
  15057. 恢复录制视频,调用前需要判断属性是否存在
  15058. */
  15059. resumeRecording(): void;
  15060. /**
  15061. !#en
  15062. get whether the device is isAvailable
  15063. Before to invoke, you need to verdict whether this properties existed
  15064. !#zh
  15065. 获取设备是否可用,调用前需要判断属性是否存在
  15066. */
  15067. isAvailable(): boolean;
  15068. /**
  15069. !#en
  15070. get status of recording
  15071. Before to invoke, you need to verdict whether this properties existed
  15072. !#zh
  15073. 获取录制状态,调用前需要判断属性是否存在
  15074. */
  15075. isRecording(): boolean;
  15076. /**
  15077. !#en
  15078. show toolbar
  15079. Before to invoke, you need to verdict whether this properties existed
  15080. !#zh
  15081. 显示悬浮窗,调用前需要判断属性是否存在
  15082. */
  15083. showToolBar(): void;
  15084. /**
  15085. !#en
  15086. hide toolbar
  15087. Before to invoke, you need to verdict whether this properties existed
  15088. !#zh
  15089. 隐藏悬浮窗,调用前需要判断属性是否存在
  15090. */
  15091. hideToolBar(): void;
  15092. /**
  15093. !#en
  15094. show video center
  15095. Before to invoke, you need to verdict whether this properties existed
  15096. !#zh
  15097. 显示视频中心,调用前需要判断属性是否存在
  15098. */
  15099. showVideoCenter(): void;
  15100. /**
  15101. !#en
  15102. enter platform
  15103. Before to invoke, you need to verdict whether this properties existed
  15104. !#zh
  15105. 显示平台中心,调用前需要判断属性是否存在
  15106. */
  15107. enterPlatform(): void;
  15108. /**
  15109. !#en
  15110. Set the video data, it is recommended to check whether are recorded firstly
  15111. Before to invoke, you need to verdict whether this properties existed
  15112. !#zh
  15113. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  15114. @param info Type: map
  15115. */
  15116. setMetaData(info: any): void;
  15117. }
  15118. /** !#en
  15119. ad tracking protocol
  15120. !#zh
  15121. 广告追踪系统协议接口 */
  15122. export class ProtocolAdTracking extends PluginProtocol {
  15123. /**
  15124. !#en
  15125. Call this method if you want to track register events as happening during a section.
  15126. !#zh
  15127. 统计用户注册信息
  15128. @param productInfo Type: map
  15129. */
  15130. onPay(productInfo: any): void;
  15131. /**
  15132. !#en
  15133. Call this method if you want to track register events as happening during a section.
  15134. !#zh
  15135. 统计用户注册信息
  15136. @param userInfo Type: map
  15137. */
  15138. onLogin(userInfo: any): void;
  15139. /**
  15140. !#en
  15141. Call this method if you want to track register events as happening during a section.
  15142. !#zh
  15143. 统计用户注册信息
  15144. @param userId userId
  15145. */
  15146. onRegister(userId: string): void;
  15147. /**
  15148. !#en
  15149. Call this method if you want to track custom events with parameters as happening during a section.
  15150. !#zh
  15151. 统计自定义事件
  15152. @param eventId eventId
  15153. @param paramMap Type: map
  15154. */
  15155. trackEvent(eventId: string, paramMap: any): void;
  15156. /**
  15157. !#en
  15158. Call this method with parameters if you want to create role as happening during a section.
  15159. !#zh
  15160. 统计创建角色事件,调用前需要判断属性是否存在
  15161. @param userInfo Type: map
  15162. */
  15163. onCreateRole(userInfo: any): void;
  15164. /**
  15165. !#en
  15166. Call this method if you want to track levelup events with parameters as happening during a section.
  15167. Before to invoke, you need to verdict whether this properties existed
  15168. !#zh
  15169. 统计角色升级事件,调用前需要判断属性是否存在
  15170. @param info Type: map
  15171. */
  15172. onLevelUp(info: any): void;
  15173. /**
  15174. !#en
  15175. Invoke this method with parameters if you want to start to pay as happening during a section.
  15176. Before to invoke, you need to verdict whether this properties existed
  15177. !#zh
  15178. 统计开始充值事件,调用前需要判断属性是否存在
  15179. @param info Type: map
  15180. */
  15181. onStartToPay(info: any): void;
  15182. }
  15183. /** !#en
  15184. custom protocol
  15185. !#zh
  15186. 自定义系统协议接口 */
  15187. export class ProtocolCustom extends PluginProtocol {
  15188. /**
  15189. !#en
  15190. set listener
  15191. !#zh
  15192. 设置自定义系统的监听
  15193. @param listener listener
  15194. @param target target
  15195. */
  15196. setListener(listener: Function, target: any): void;
  15197. /**
  15198. !#en
  15199. get listener
  15200. !#zh
  15201. 获取自定义系统的监听
  15202. */
  15203. getListener(): Function;
  15204. }
  15205. /** !#en
  15206. Data structure class
  15207. !#zh
  15208. 数据结构类 */
  15209. export class PluginParam {
  15210. /**
  15211. !#en
  15212. create plugin parameters
  15213. !#zh
  15214. 创建对象
  15215. @param parameters parameters
  15216. */
  15217. static create(parameters: number|string|any): anysdk.PluginParam;
  15218. }
  15219. /** !#en The callback of user system
  15220. !#zh 用户系统回调 */
  15221. export enum UserActionResultCode {
  15222. kInitSuccess = 0,
  15223. kInitFail = 0,
  15224. kLoginSuccess = 0,
  15225. kLoginNetworkError = 0,
  15226. kLoginNoNeed = 0,
  15227. kLoginFail = 0,
  15228. kLoginCancel = 0,
  15229. kLogoutSuccess = 0,
  15230. kLogoutFail = 0,
  15231. kPlatformEnter = 0,
  15232. kPlatformBack = 0,
  15233. kPausePage = 0,
  15234. kExitPage = 0,
  15235. kAntiAddictionQuery = 0,
  15236. kRealNameRegister = 0,
  15237. kAccountSwitchSuccess = 0,
  15238. kAccountSwitchFail = 0,
  15239. kOpenShop = 0,
  15240. kAccountSwitchCancel = 0,
  15241. kUserExtension = 0,
  15242. kSendToDesktopSuccess = 0,
  15243. kSendToDesktopFail = 0,
  15244. kGetAvailableLoginTypeSuccess = 0,
  15245. kGetAvailableLoginTypeFail = 0,
  15246. kGetUserInfoSuccess = 0,
  15247. kGetUserInfoFail = 0,
  15248. kOpenBBSSuccess = 0,
  15249. kOpenBBSFail = 0,
  15250. }
  15251. /** !#en The toolbar position of user type
  15252. !#zh 用户系统悬浮窗位置 */
  15253. export enum ToolBarPlace {
  15254. kToolBarTopLeft = 0,
  15255. kToolBarTopRight = 0,
  15256. kToolBarMidLeft = 0,
  15257. kToolBarMidRight = 0,
  15258. kToolBarBottomLeft = 0,
  15259. kToolBarBottomRight = 0,
  15260. }
  15261. /** !#en The callback of requesting reStringge
  15262. !#zh 支付系统支付请求回调 */
  15263. export enum PayResultCode {
  15264. kPaySuccess = 0,
  15265. kPayFail = 0,
  15266. kPayCancel = 0,
  15267. kPayNetworkError = 0,
  15268. kPayProductionInforIncomplete = 0,
  15269. kPayInitSuccess = 0,
  15270. kPayInitFail = 0,
  15271. kPayNowPaying = 0,
  15272. kPayReStringgeSuccess = 0,
  15273. kPayExtension = 0,
  15274. kPayNeedLoginAgain = 0,
  15275. kRequestSuccess = 0,
  15276. kRequestFail = 0,
  15277. }
  15278. /** !#en The enum of account type
  15279. !#zh 统计系统的账号类型 */
  15280. export enum AccountType {
  15281. ANONYMOUS = 0,
  15282. REGISTED = 0,
  15283. SINA_WEIBO = 0,
  15284. TENCENT_WEIBO = 0,
  15285. QQ = 0,
  15286. ND91 = 0,
  15287. }
  15288. /** !#en The enum of account operation
  15289. !#zh 统计系统的账号操作 */
  15290. export enum AccountOperate {
  15291. LOGIN = 0,
  15292. LOGOUT = 0,
  15293. REGISTER = 0,
  15294. }
  15295. /** !#en The enum of gender
  15296. !#zh 统计系统的账号性别 */
  15297. export enum AccountGender {
  15298. MALE = 0,
  15299. FEMALE = 0,
  15300. UNKNOWN = 0,
  15301. }
  15302. /** !#en The enum of task type
  15303. !#zh 统计系统的任务类型 */
  15304. export enum TaskType {
  15305. GUIDE_LINE = 0,
  15306. MAIN_LINE = 0,
  15307. BRANCH_LINE = 0,
  15308. DAILY = 0,
  15309. ACTIVITY = 0,
  15310. OTHER = 0,
  15311. }
  15312. /** !#en The callback of share system
  15313. !#zh 分享系统回调 */
  15314. export enum ShareResultCode {
  15315. kShareSuccess = 0,
  15316. kShareFail = 0,
  15317. kShareCancel = 0,
  15318. kShareNetworkError = 0,
  15319. kShareExtension = 0,
  15320. }
  15321. /** !#en The callback of social system
  15322. !#zh 社交系统回调 */
  15323. export enum SocialRetCode {
  15324. kScoreSubmitSucceed = 0,
  15325. kScoreSubmitfail = 0,
  15326. kAchUnlockSucceed = 0,
  15327. kAchUnlockFail = 0,
  15328. kSocialSignInSucceed = 0,
  15329. kSocialSignInFail = 0,
  15330. kSocialSignOutSucceed = 0,
  15331. kSocialSignOutFail = 0,
  15332. kSocialGetGameFriends = 0,
  15333. kSocialExtensionCode = 0,
  15334. kSocialGetFriendsInfoSuccess = 0,
  15335. kSocialGetFriendsInfoFail = 0,
  15336. kSocialAlreadySubscription = 0,
  15337. kSocialNoSubscription = 0,
  15338. kSocialSubscriptionFail = 0,
  15339. }
  15340. /** !#en The callback of ads system
  15341. !#zh 广告系统回调 */
  15342. export enum AdsResultCode {
  15343. kAdsReceived = 0,
  15344. kAdsShown = 0,
  15345. kAdsDismissed = 0,
  15346. kPointsSpendSucceed = 0,
  15347. kPointsSpendFailed = 0,
  15348. kNetworkError = 0,
  15349. kUnknownError = 0,
  15350. kOfferWallOnPointsChanged = 0,
  15351. kRewardedVideoWithReward = 0,
  15352. kInAppPurchaseFinished = 0,
  15353. kAdsClicked = 0,
  15354. kAdsExtension = 0,
  15355. }
  15356. /** !#en The enum of ads position
  15357. !#zh 广告位置 */
  15358. export enum AdsPos {
  15359. kPosCenter = 0,
  15360. kPosTop = 0,
  15361. kPosTopLeft = 0,
  15362. kPosTopRight = 0,
  15363. kPosBottom = 0,
  15364. kPosBottomLeft = 0,
  15365. kPosBottomRight = 0,
  15366. }
  15367. /** !#en The enum of ads type
  15368. !#zh 广告类型 */
  15369. export enum AdsType {
  15370. AD_TYPE_BANNER = 0,
  15371. AD_TYPE_FULLSCREEN = 0,
  15372. AD_TYPE_MOREAPP = 0,
  15373. AD_TYPE_OFFERWALL = 0,
  15374. AD_TYPE_REWARDEDVIDEO = 0,
  15375. AD_TYPE_NATIVEEXPRESS = 0,
  15376. AD_TYPE_NATIVEADVANCED = 0,
  15377. }
  15378. /** !#en The callback of push system
  15379. !#zh 推送系统回调 */
  15380. export enum PushActionResultCode {
  15381. kPushReceiveMessage = 0,
  15382. kPushExtensionCode = 0,
  15383. }
  15384. /** !#en The callback of custom system
  15385. !#zh 自定义系统回调 */
  15386. export enum CustomResultCode {
  15387. kCustomExtension = 0,
  15388. }
  15389. /** !#en The callback of REC system
  15390. !#zh 录屏系统回调 */
  15391. export enum RECResultCode {
  15392. kRECInitSuccess = 0,
  15393. kRECInitFail = 0,
  15394. kRECStartRecording = 0,
  15395. kRECStopRecording = 0,
  15396. kRECPauseRecording = 0,
  15397. kRECResumeRecording = 0,
  15398. kRECEnterSDKPage = 0,
  15399. kRECQuitSDKPage = 0,
  15400. kRECShareSuccess = 0,
  15401. kRECShareFail = 0,
  15402. kRECExtension = 0,
  15403. }
  15404. }
  15405. /** !#en
  15406. The global main namespace of Spine, all classes, functions,
  15407. properties and constants of Spine are defined in this namespace
  15408. !#zh
  15409. Spine 的全局的命名空间,
  15410. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15411. declare module sp {
  15412. /** !#en
  15413. The skeleton of Spine <br/>
  15414. <br/>
  15415. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  15416. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15417. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  15418. !#zh
  15419. Spine 骨骼动画 <br/>
  15420. <br/>
  15421. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15422. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15423. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  15424. export class Skeleton extends cc._RendererUnderSG {
  15425. /** !#en The skeletal animation is paused?
  15426. !#zh 该骨骼动画是否暂停。 */
  15427. paused: boolean;
  15428. /** !#en
  15429. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  15430. attachments, skins, etc) and animations but does not hold any state.<br/>
  15431. Multiple skeletons can share the same skeleton data.
  15432. !#zh
  15433. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15434. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15435. 多个 Skeleton 可以共用相同的骨骼数据。 */
  15436. skeletonData: SkeletonData;
  15437. /** !#en The name of default skin.
  15438. !#zh 默认的皮肤名称。 */
  15439. defaultSkin: string;
  15440. /** !#en The name of default animation.
  15441. !#zh 默认的动画名称。 */
  15442. defaultAnimation: string;
  15443. /** !#en The name of current playing animation.
  15444. !#zh 当前播放的动画名称。 */
  15445. animation: string;
  15446. _defaultSkinIndex: number;
  15447. /** !#en TODO
  15448. !#zh 是否循环播放当前骨骼动画。 */
  15449. loop: boolean;
  15450. /** !#en Indicates whether to enable premultiplied alpha.
  15451. You should disable this option when image's transparent area appears to have opaque pixels,
  15452. or enable this option when image's half transparent area appears to be darken.
  15453. !#zh 是否启用贴图预乘。
  15454. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  15455. premultipliedAlpha: boolean;
  15456. /** !#en The time scale of this skeleton.
  15457. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15458. timeScale: number;
  15459. /** !#en Indicates whether open debug slots.
  15460. !#zh 是否显示 slot 的 debug 信息。 */
  15461. debugSlots: boolean;
  15462. /** !#en Indicates whether open debug bones.
  15463. !#zh 是否显示 bone 的 debug 信息。 */
  15464. debugBones: boolean;
  15465. /**
  15466. !#en Computes the world SRT from the local SRT for each bone.
  15467. !#zh 重新更新所有骨骼的世界 Transform,
  15468. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  15469. @example
  15470. ```js
  15471. var bone = spine.findBone('head');
  15472. cc.log(bone.worldX); // return 0;
  15473. spine.updateWorldTransform();
  15474. bone = spine.findBone('head');
  15475. cc.log(bone.worldX); // return -23.12;
  15476. ```
  15477. */
  15478. updateWorldTransform(): void;
  15479. /**
  15480. !#en Sets the bones and slots to the setup pose.
  15481. !#zh 还原到起始动作
  15482. */
  15483. setToSetupPose(): void;
  15484. /**
  15485. !#en
  15486. Sets the bones to the setup pose,
  15487. using the values from the `BoneData` list in the `SkeletonData`.
  15488. !#zh
  15489. 设置 bone 到起始动作
  15490. 使用 SkeletonData 中的 BoneData 列表中的值。
  15491. */
  15492. setBonesToSetupPose(): void;
  15493. /**
  15494. !#en
  15495. Sets the slots to the setup pose,
  15496. using the values from the `SlotData` list in the `SkeletonData`.
  15497. !#zh
  15498. 设置 slot 到起始动作。
  15499. 使用 SkeletonData 中的 SlotData 列表中的值。
  15500. */
  15501. setSlotsToSetupPose(): void;
  15502. /**
  15503. !#en
  15504. Finds a bone by name.
  15505. This does a string comparison for every bone.<br>
  15506. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  15507. !#zh
  15508. 通过名称查找 bone。
  15509. 这里对每个 bone 的名称进行了对比。<br>
  15510. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  15511. @param boneName boneName
  15512. */
  15513. findBone(boneName: string): sp.spine.Bone;
  15514. /**
  15515. !#en
  15516. Finds a slot by name. This does a string comparison for every slot.<br>
  15517. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  15518. !#zh
  15519. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  15520. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  15521. @param slotName slotName
  15522. */
  15523. findSlot(slotName: string): sp.spine.Slot;
  15524. /**
  15525. !#en
  15526. Finds a skin by name and makes it the active skin.
  15527. This does a string comparison for every skin.<br>
  15528. Note that setting the skin does not change which attachments are visible.<br>
  15529. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  15530. !#zh
  15531. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  15532. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  15533. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  15534. @param skinName skinName
  15535. */
  15536. setSkin(skinName: string): sp.spine.Skin;
  15537. /**
  15538. !#en
  15539. Returns the attachment for the slot and attachment name.
  15540. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  15541. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  15542. !#zh
  15543. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  15544. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  15545. @param slotName slotName
  15546. @param attachmentName attachmentName
  15547. */
  15548. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  15549. /**
  15550. !#en
  15551. Sets the attachment for the slot and attachment name.
  15552. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  15553. !#zh
  15554. 通过 slot 和 attachment 的名字来设置 attachment。
  15555. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  15556. @param slotName slotName
  15557. @param attachmentName attachmentName
  15558. */
  15559. setAttachment(slotName: string, attachmentName: string): void;
  15560. /**
  15561. !#en
  15562. Sets runtime skeleton data to sp.Skeleton.<br>
  15563. 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.
  15564. !#zh
  15565. 设置底层运行时用到的 SkeletonData。<br>
  15566. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  15567. @param skeletonData skeletonData
  15568. @param ownsSkeletonData ownsSkeletonData
  15569. */
  15570. setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
  15571. /**
  15572. !#en Sets animation state data.<br>
  15573. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  15574. !#zh 设置动画状态数据。<br>
  15575. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  15576. @param stateData stateData
  15577. */
  15578. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  15579. /**
  15580. !#en
  15581. Mix applies all keyframe values,
  15582. interpolated for the specified time and mixed with the current values.
  15583. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  15584. @param fromAnimation fromAnimation
  15585. @param toAnimation toAnimation
  15586. @param duration duration
  15587. */
  15588. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  15589. /**
  15590. !#en Sets event listener.
  15591. !#zh 设置动画事件监听器。
  15592. @param target target
  15593. @param callback callback
  15594. */
  15595. setAnimationListener(target: any, callback: Function): void;
  15596. /**
  15597. !#en Set the current animation. Any queued animations are cleared.<br>
  15598. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15599. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  15600. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15601. @param trackIndex trackIndex
  15602. @param name name
  15603. @param loop loop
  15604. */
  15605. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  15606. /**
  15607. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  15608. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15609. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  15610. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15611. @param trackIndex trackIndex
  15612. @param name name
  15613. @param loop loop
  15614. @param delay delay
  15615. */
  15616. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  15617. /**
  15618. !#en Find animation with specified name.
  15619. !#zh 查找指定名称的动画
  15620. @param name name
  15621. */
  15622. findAnimation(name: string): sp.spine.Animation;
  15623. /**
  15624. !#en Returns track entry by trackIndex.<br>
  15625. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  15626. !#zh 通过 track 索引获取 TrackEntry。<br>
  15627. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  15628. @param trackIndex trackIndex
  15629. */
  15630. getCurrent(trackIndex: void): sp.spine.TrackEntry;
  15631. /**
  15632. !#en Clears all tracks of animation state.
  15633. !#zh 清除所有 track 的动画状态。
  15634. */
  15635. clearTracks(): void;
  15636. /**
  15637. !#en Clears track of animation state by trackIndex.
  15638. !#zh 清除出指定 track 的动画状态。
  15639. @param trackIndex trackIndex
  15640. */
  15641. clearTrack(trackIndex: number): void;
  15642. /**
  15643. !#en Set the start event listener.
  15644. !#zh 用来设置开始播放动画的事件监听。
  15645. @param listener listener
  15646. */
  15647. setStartListener(listener: Function): void;
  15648. /**
  15649. !#en Set the interrupt event listener.
  15650. !#zh 用来设置动画被打断的事件监听。
  15651. @param listener listener
  15652. */
  15653. setInterruptListener(listener: Function): void;
  15654. /**
  15655. !#en Set the end event listener.
  15656. !#zh 用来设置动画播放完后的事件监听。
  15657. @param listener listener
  15658. */
  15659. setEndListener(listener: Function): void;
  15660. /**
  15661. !#en Set the dispose event listener.
  15662. !#zh 用来设置动画将被销毁的事件监听。
  15663. @param listener listener
  15664. */
  15665. setDisposeListener(listener: Function): void;
  15666. /**
  15667. !#en Set the complete event listener.
  15668. !#zh 用来设置动画播放一次循环结束后的事件监听。
  15669. @param listener listener
  15670. */
  15671. setCompleteListener(listener: Function): void;
  15672. /**
  15673. !#en Set the animation event listener.
  15674. !#zh 用来设置动画播放过程中帧事件的监听。
  15675. @param listener listener
  15676. */
  15677. setEventListener(listener: Function): void;
  15678. /**
  15679. !#en Set the start event listener for specified TrackEntry (only supported on Web).
  15680. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
  15681. @param entry entry
  15682. @param listener listener
  15683. */
  15684. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15685. /**
  15686. !#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
  15687. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
  15688. @param entry entry
  15689. @param listener listener
  15690. */
  15691. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15692. /**
  15693. !#en Set the end event listener for specified TrackEntry (only supported on Web).
  15694. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
  15695. @param entry entry
  15696. @param listener listener
  15697. */
  15698. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15699. /**
  15700. !#en Set the dispose event listener for specified TrackEntry (only supported on Web).
  15701. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
  15702. @param entry entry
  15703. @param listener listener
  15704. */
  15705. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15706. /**
  15707. !#en Set the complete event listener for specified TrackEntry (only supported on Web).
  15708. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
  15709. @param entry entry
  15710. @param listener listener
  15711. */
  15712. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15713. /**
  15714. !#en Set the event listener for specified TrackEntry (only supported on Web).
  15715. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
  15716. @param entry entry
  15717. @param listener listener
  15718. */
  15719. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  15720. }
  15721. /** !#en The skeleton data of spine.
  15722. !#zh Spine 的 骨骼数据。 */
  15723. export class SkeletonData extends cc.Asset {
  15724. /** !#en See http://en.esotericsoftware.com/spine-json-format
  15725. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  15726. skeletonJson: any;
  15727. atlasText: string;
  15728. textures: cc.Texture2D[];
  15729. /** !#en
  15730. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  15731. image sizes, and animation translations.
  15732. This can be useful when using different sized images than were used when designing the skeleton
  15733. in Spine. For example, if using images that are half the size than were used in Spine,
  15734. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  15735. resolution texture atlases.
  15736. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  15737. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  15738. scale: number;
  15739. /**
  15740. !#en Get the included SkeletonData used in spine runtime.<br>
  15741. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  15742. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  15743. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  15744. @param quiet quiet
  15745. */
  15746. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  15747. }
  15748. /** !#en The event type of spine skeleton animation.
  15749. !#zh 骨骼动画事件类型。 */
  15750. export enum AnimationEventType {
  15751. START = 0,
  15752. END = 0,
  15753. COMPLETE = 0,
  15754. EVENT = 0,
  15755. }
  15756. }
  15757. /** !#en
  15758. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  15759. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  15760. !#zh
  15761. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  15762. declare module sp.spine {
  15763. }
  15764. /** !#en
  15765. The global main namespace of DragonBones, all classes, functions,
  15766. properties and constants of DragonBones are defined in this namespace
  15767. !#zh
  15768. DragonBones 的全局的命名空间,
  15769. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15770. declare module dragonBones {
  15771. /** !#en
  15772. The Armature Display of DragonBones <br/>
  15773. <br/>
  15774. (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  15775. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15776. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/>
  15777. !#zh
  15778. DragonBones 骨骼动画 <br/>
  15779. <br/>
  15780. (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15781. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15782. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)<br/> */
  15783. export class ArmatureDisplay extends cc._RendererUnderSG {
  15784. /** !#en
  15785. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  15786. attachments, skins, etc) and animations but does not hold any state.<br/>
  15787. Multiple ArmatureDisplay can share the same DragonBones data.
  15788. !#zh
  15789. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15790. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15791. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  15792. dragonAsset: DragonBonesAsset;
  15793. /** !#en
  15794. The atlas asset for the DragonBones.
  15795. !#zh
  15796. 骨骼数据所需的 Atlas Texture 数据。 */
  15797. dragonAtlasAsset: DragonBonesAtlasAsset;
  15798. /** !#en The name of current armature.
  15799. !#zh 当前的 Armature 名称。 */
  15800. armatureName: string;
  15801. /** !#en The name of current playing animation.
  15802. !#zh 当前播放的动画名称。 */
  15803. animationName: string;
  15804. _defaultArmatureIndex: number;
  15805. /** !#en The time scale of this armature.
  15806. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15807. timeScale: number;
  15808. /** !#en The play times of the default animation.
  15809. -1 means using the value of config file;
  15810. 0 means repeat for ever
  15811. >0 means repeat times
  15812. !#zh 播放默认动画的循环次数
  15813. -1 表示使用配置文件中的默认值;
  15814. 0 表示无限循环
  15815. >0 表示循环次数 */
  15816. playTimes: number;
  15817. /** !#en Indicates whether open debug bones.
  15818. !#zh 是否显示 bone 的 debug 信息。 */
  15819. debugBones: boolean;
  15820. /**
  15821. !#en
  15822. Play the specified animation.
  15823. Parameter animName specify the animation name.
  15824. Parameter playTimes specify the repeat times of the animation.
  15825. -1 means use the value of the config file.
  15826. 0 means play the animation for ever.
  15827. >0 means repeat times.
  15828. !#zh
  15829. 播放指定的动画.
  15830. animName 指定播放动画的名称。
  15831. playTimes 指定播放动画的次数。
  15832. -1 为使用配置文件中的次数。
  15833. 0 为无限循环播放。
  15834. >0 为动画的重复次数。
  15835. @param animName animName
  15836. @param playTimes playTimes
  15837. */
  15838. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  15839. /**
  15840. !#en
  15841. Get the all armature names in the DragonBones Data.
  15842. !#zh
  15843. 获取 DragonBones 数据中所有的 armature 名称
  15844. */
  15845. getArmatureNames(): any[];
  15846. /**
  15847. !#en
  15848. Get the all animation names of specified armature.
  15849. !#zh
  15850. 获取指定的 armature 的所有动画名称。
  15851. @param armatureName armatureName
  15852. */
  15853. getAnimationNames(armatureName: string): any[];
  15854. /**
  15855. !#en
  15856. Add event listener for the DragonBones Event.
  15857. !#zh
  15858. 添加 DragonBones 事件监听器。
  15859. @param eventType eventType
  15860. @param listener listener
  15861. @param target target
  15862. */
  15863. addEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15864. /**
  15865. !#en
  15866. Remove the event listener for the DragonBones Event.
  15867. !#zh
  15868. 移除 DragonBones 事件监听器。
  15869. @param eventType eventType
  15870. @param listener listener
  15871. @param target target
  15872. */
  15873. removeEventListener(eventType: dragonBones.EventObject, listener: Function, target: any): void;
  15874. /**
  15875. !#en
  15876. Build the armature for specified name.
  15877. !#zh
  15878. 构建指定名称的 armature 对象
  15879. @param armatureName armatureName
  15880. */
  15881. buildArmature(armatureName: string): dragonBones.Armature;
  15882. /**
  15883. !#en
  15884. Get the current armature object of the ArmatureDisplay.
  15885. !#zh
  15886. 获取 ArmatureDisplay 当前使用的 Armature 对象
  15887. */
  15888. armature(): any;
  15889. }
  15890. /** !#en The skeleton data of dragonBones.
  15891. !#zh dragonBones 的 骨骼数据。 */
  15892. export class DragonBonesAsset extends cc.Asset {
  15893. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  15894. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  15895. dragonBonesJson: string;
  15896. }
  15897. /** !#en The skeleton atlas data of dragonBones.
  15898. !#zh dragonBones 的骨骼纹理数据。 */
  15899. export class DragonBonesAtlasAsset extends cc.Asset {
  15900. atlasJson: string;
  15901. texture: cc.Texture2D;
  15902. }
  15903. }
  15904. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  15905. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  15906. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  15907. declare module cc._decorator {
  15908. /**
  15909. !#en
  15910. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  15911. as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details.
  15912. !#zh
  15913. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。
  15914. @param name The class name used for serialization.
  15915. @example
  15916. ```js
  15917. const {ccclass} = cc._decorator;
  15918. // define a CCClass, omit the name
  15919. &#64;ccclass
  15920. class NewScript extends cc.Component {
  15921. // ...
  15922. }
  15923. // define a CCClass with a name
  15924. &#64;ccclass('LoginData')
  15925. class LoginData {
  15926. // ...
  15927. }
  15928. ```
  15929. */
  15930. export function ccclass(name?: string): Function;
  15931. export function ccclass(_class?: Function): void;
  15932. /**
  15933. !#en
  15934. Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/).
  15935. !#zh
  15936. 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。
  15937. @param options an object with some property attributes
  15938. @example
  15939. ```js
  15940. const {ccclass, property} = cc._decorator;
  15941. &#64;ccclass
  15942. class NewScript extends cc.Component {
  15943. &#64;property({
  15944. type: cc.Node
  15945. })
  15946. targetNode1 = null;
  15947. &#64;property(cc.Node)
  15948. targetNode2 = null;
  15949. &#64;property(cc.Button)
  15950. targetButton = null;
  15951. &#64;property
  15952. _width = 100;
  15953. &#64;property
  15954. get width () {
  15955. return this._width;
  15956. }
  15957. &#64;property
  15958. set width (value) {
  15959. this._width = value;
  15960. }
  15961. &#64;property
  15962. offset = new cc.Vec2(100, 100);
  15963. &#64;property(cc.Vec2)
  15964. offsets = [];
  15965. &#64;property(cc.Texture2D)
  15966. texture = "";
  15967. }
  15968. // above is equivalent to (上面的代码相当于):
  15969. var NewScript = cc.Class({
  15970. properties: {
  15971. targetNode1: {
  15972. default: null,
  15973. type: cc.Node
  15974. },
  15975. targetNode2: {
  15976. default: null,
  15977. type: cc.Node
  15978. },
  15979. targetButton: {
  15980. default: null,
  15981. type: cc.Button
  15982. },
  15983. _width: 100,
  15984. width: {
  15985. get () {
  15986. return this._width;
  15987. },
  15988. set (value) {
  15989. this._width = value;
  15990. }
  15991. },
  15992. offset: new cc.Vec2(100, 100)
  15993. offsets: {
  15994. default: [],
  15995. type: cc.Vec2
  15996. }
  15997. texture: {
  15998. default: "",
  15999. url: cc.Texture2D
  16000. },
  16001. }
  16002. });
  16003. ```
  16004. */
  16005. 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;
  16006. export function property(_target: Object, _key: any, _desc?: any): void;
  16007. /**
  16008. !#en
  16009. Makes a CCClass that inherit from component execute in edit mode.<br>
  16010. By default, all components are only executed in play mode,
  16011. which means they will not have their callback functions executed while the Editor is in edit mode.
  16012. !#zh
  16013. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  16014. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  16015. @example
  16016. ```js
  16017. const {ccclass, executeInEditMode} = cc._decorator;
  16018. &#64;ccclass
  16019. &#64;executeInEditMode
  16020. class NewScript extends cc.Component {
  16021. // ...
  16022. }
  16023. ```
  16024. */
  16025. export function executeInEditMode(): Function;
  16026. export function executeInEditMode(_class: Function): void;
  16027. /**
  16028. !#en
  16029. Automatically add required component as a dependency for the CCClass that inherit from component.
  16030. !#zh
  16031. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  16032. @param requiredComponent requiredComponent
  16033. @example
  16034. ```js
  16035. const {ccclass, requireComponent} = cc._decorator;
  16036. &#64;ccclass
  16037. &#64;requireComponent(cc.Sprite)
  16038. class SpriteCtrl extends cc.Component {
  16039. // ...
  16040. }
  16041. ```
  16042. */
  16043. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  16044. /**
  16045. !#en
  16046. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  16047. !#zh
  16048. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  16049. @param path The path is the menu represented like a pathname.
  16050. For example the menu could be "Rendering/CameraCtrl".
  16051. @example
  16052. ```js
  16053. const {ccclass, menu} = cc._decorator;
  16054. &#64;ccclass
  16055. &#64;menu("Rendering/CameraCtrl")
  16056. class NewScript extends cc.Component {
  16057. // ...
  16058. }
  16059. ```
  16060. */
  16061. export function menu(path: string): Function;
  16062. /**
  16063. !#en
  16064. The execution order of lifecycle methods for Component.
  16065. Those less than 0 will execute before while those greater than 0 will execute after.
  16066. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  16067. !#zh
  16068. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  16069. @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.
  16070. @example
  16071. ```js
  16072. const {ccclass, executionOrder} = cc._decorator;
  16073. &#64;ccclass
  16074. &#64;executionOrder(1)
  16075. class CameraCtrl extends cc.Component {
  16076. // ...
  16077. }
  16078. ```
  16079. */
  16080. export function executionOrder(order: number): Function;
  16081. /**
  16082. !#en
  16083. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  16084. !#zh
  16085. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  16086. @example
  16087. ```js
  16088. const {ccclass, disallowMultiple} = cc._decorator;
  16089. &#64;ccclass
  16090. &#64;disallowMultiple
  16091. class CameraCtrl extends cc.Component {
  16092. // ...
  16093. }
  16094. ```
  16095. */
  16096. export function disallowMultiple(): Function;
  16097. export function disallowMultiple(_class: Function): void;
  16098. /**
  16099. !#en
  16100. 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>
  16101. This property is only available if executeInEditMode is true.
  16102. !#zh
  16103. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  16104. @example
  16105. ```js
  16106. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  16107. &#64;ccclass
  16108. &#64;executeInEditMode
  16109. &#64;playOnFocus
  16110. class CameraCtrl extends cc.Component {
  16111. // ...
  16112. }
  16113. ```
  16114. */
  16115. export function playOnFocus(): Function;
  16116. export function playOnFocus(_class: Function): void;
  16117. /**
  16118. !#en
  16119. Specifying the url of the custom html to draw the component in **Properties**.
  16120. !#zh
  16121. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  16122. @param url url
  16123. @example
  16124. ```js
  16125. const {ccclass, inspector} = cc._decorator;
  16126. &#64;ccclass
  16127. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  16128. class NewScript extends cc.Component {
  16129. // ...
  16130. }
  16131. ```
  16132. */
  16133. export function inspector(path: string): Function;
  16134. /**
  16135. !#en
  16136. The custom documentation URL.
  16137. !#zh
  16138. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  16139. @param url url
  16140. @example
  16141. ```js
  16142. const {ccclass, help} = cc._decorator;
  16143. &#64;ccclass
  16144. &#64;help("app://docs/html/components/spine.html")
  16145. class NewScript extends cc.Component {
  16146. // ...
  16147. }
  16148. ```
  16149. */
  16150. export function help(path: string): Function;
  16151. /**
  16152. NOTE:<br>
  16153. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  16154. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  16155. so we can not mix in ES6 Classes.<br>
  16156. See:<br>
  16157. [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>
  16158. One possible solution (but IDE unfriendly):<br>
  16159. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  16160. <br>
  16161. NOTE:<br>
  16162. You must manually call mixins constructor, this is different from cc.Class(ES5).
  16163. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  16164. not support ES6 Classes.
  16165. @example
  16166. ```js
  16167. const {ccclass, mixins} = cc._decorator;
  16168. class Animal { ... }
  16169. const Fly = cc.Class({
  16170. constructor () { ... }
  16171. });
  16172. &#64;ccclass
  16173. &#64;mixins(cc.EventTarget, Fly)
  16174. class Bird extends Animal {
  16175. constructor () {
  16176. super();
  16177. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  16178. cc.EventTarget.call(this);
  16179. Fly.call(this);
  16180. }
  16181. // ...
  16182. }
  16183. ```
  16184. */
  16185. export function mixins(ctor: Function, ...rest: Function[]): Function;
  16186. }
  16187. /** This module provides some JavaScript utilities.
  16188. All members can be accessed with "cc.js". */
  16189. declare module cc.js {
  16190. /**
  16191. Check the obj whether is number or not
  16192. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  16193. Then you can use this function if you care about this case.
  16194. @param obj obj
  16195. */
  16196. export function isNumber(obj: any): boolean;
  16197. /**
  16198. Check the obj whether is string or not.
  16199. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  16200. Then you can use this function if you care about this case.
  16201. @param obj obj
  16202. */
  16203. export function isString(obj: any): boolean;
  16204. /**
  16205. This method is deprecated, use cc.js.mixin please.<br>
  16206. Copy all properties not defined in obj from arguments[1...n]
  16207. @param obj object to extend its properties
  16208. @param sourceObj source object to copy properties from
  16209. */
  16210. export function addon(obj: any, ...sourceObj: any[]): any;
  16211. /**
  16212. copy all properties from arguments[1...n] to obj
  16213. @param obj obj
  16214. @param sourceObj sourceObj
  16215. */
  16216. export function mixin(obj: any, ...sourceObj: any[]): any;
  16217. /**
  16218. Derive the class from the supplied base class.
  16219. Both classes are just native javascript constructors, not created by cc.Class, so
  16220. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  16221. @param cls cls
  16222. @param base the baseclass to inherit
  16223. */
  16224. export function extend(cls: Function, base: Function): Function;
  16225. /**
  16226. Get super class
  16227. @param ctor the constructor of subclass
  16228. */
  16229. export function getSuper(ctor: Function): Function;
  16230. /**
  16231. Removes all enumerable properties from object
  16232. @param obj obj
  16233. */
  16234. export function clear(obj: any): void;
  16235. /**
  16236. Get property descriptor in object and all its ancestors
  16237. @param obj obj
  16238. @param name name
  16239. */
  16240. export function getPropertyDescriptor(obj: any, name: string): any;
  16241. /**
  16242. Define value, just help to call Object.defineProperty.<br>
  16243. The configurable will be true.
  16244. @param obj obj
  16245. @param prop prop
  16246. @param value value
  16247. @param writable writable
  16248. @param enumerable enumerable
  16249. */
  16250. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  16251. /**
  16252. Define get set accessor, just help to call Object.defineProperty(...)
  16253. @param obj obj
  16254. @param prop prop
  16255. @param getter getter
  16256. @param setter setter
  16257. @param enumerable enumerable
  16258. */
  16259. export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void;
  16260. /**
  16261. Define get accessor, just help to call Object.defineProperty(...)
  16262. @param obj obj
  16263. @param prop prop
  16264. @param getter getter
  16265. @param enumerable enumerable
  16266. @param configurable configurable
  16267. */
  16268. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  16269. /**
  16270. Define set accessor, just help to call Object.defineProperty(...)
  16271. @param obj obj
  16272. @param prop prop
  16273. @param setter setter
  16274. @param enumerable enumerable
  16275. @param configurable configurable
  16276. */
  16277. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  16278. /**
  16279. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  16280. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  16281. @param objOrCtor instance or constructor
  16282. */
  16283. export function getClassName(objOrCtor: any|Function): string;
  16284. /**
  16285. Register the class by specified name manually
  16286. @param className className
  16287. @param constructor constructor
  16288. */
  16289. export function setClassName(className: string, constructor: Function): void;
  16290. /**
  16291. Unregister a class from fireball.
  16292. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  16293. Please note that its still your responsibility to free other references to the class.
  16294. @param constructor the class you will want to unregister, any number of classes can be added
  16295. */
  16296. export function unregisterClass(...constructor: Function[]): void;
  16297. /**
  16298. Get the registered class by name
  16299. @param classname classname
  16300. */
  16301. export function getClassByName(classname: string): Function;
  16302. /**
  16303. Defines a polyfill field for obsoleted codes.
  16304. @param obj YourObject or YourClass.prototype
  16305. @param obsoleted "OldParam" or "YourClass.OldParam"
  16306. @param newPropName "NewParam"
  16307. @param writable writable
  16308. */
  16309. export function obsolete(obj: any, obsoleted: string, newPropName: string, writable?: boolean): void;
  16310. /**
  16311. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  16312. @param obj YourObject or YourClass.prototype
  16313. @param objName "YourObject" or "YourClass"
  16314. @param props props
  16315. @param writable writable
  16316. */
  16317. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  16318. /**
  16319. A string tool to construct a string with format string.
  16320. @param msg A JavaScript string containing zero or more substitution strings.
  16321. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  16322. @example
  16323. ```js
  16324. cc.js.formatStr("a: %s, b: %s", a, b);
  16325. cc.js.formatStr(a, b, c);
  16326. ```
  16327. */
  16328. export function formatStr(msg: string|any, ...subst: any[]): string;
  16329. /**
  16330. #en
  16331. 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.
  16332. #zh
  16333. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  16334. @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.
  16335. */
  16336. export function createMap(forceDictMode?: boolean): any;
  16337. /** undefined */
  16338. export class array {
  16339. /**
  16340. Removes the array item at the specified index.
  16341. @param array array
  16342. @param index index
  16343. */
  16344. static removeAt(array: any[], index: number): void;
  16345. /**
  16346. Removes the array item at the specified index.
  16347. It's faster but the order of the array will be changed.
  16348. @param array array
  16349. @param index index
  16350. */
  16351. static fastRemoveAt(array: any[], index: number): void;
  16352. /**
  16353. Removes the first occurrence of a specific object from the array.
  16354. @param array array
  16355. @param value value
  16356. */
  16357. static remove(array: any[], value: any): boolean;
  16358. /**
  16359. Removes the first occurrence of a specific object from the array.
  16360. It's faster but the order of the array will be changed.
  16361. @param array array
  16362. @param value value
  16363. */
  16364. static fastRemove(array: any[], value: number): void;
  16365. /**
  16366. Verify array's Type
  16367. @param array array
  16368. @param type type
  16369. */
  16370. static verifyType(array: any[], type: Function): boolean;
  16371. /**
  16372. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  16373. @param array Source Array
  16374. @param minusArr minus Array
  16375. */
  16376. static removeArray(array: any[], minusArr: any[]): void;
  16377. /**
  16378. Inserts some objects at index
  16379. @param array array
  16380. @param addObjs addObjs
  16381. @param index index
  16382. */
  16383. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  16384. /**
  16385. Exact same function as Array.prototype.indexOf.<br>
  16386. 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>
  16387. 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!
  16388. @param searchElement Element to locate in the array.
  16389. @param fromIndex The index to start the search at
  16390. */
  16391. static indexOf(searchElement: any, fromIndex?: number): number;
  16392. /**
  16393. Determines whether the array contains a specific value.
  16394. @param array array
  16395. @param value value
  16396. */
  16397. static contains(array: any[], value: any): boolean;
  16398. /**
  16399. Copy an array's item to a new array (its performance is better than Array.slice)
  16400. @param array array
  16401. */
  16402. static copy(array: any[]): any[];
  16403. }
  16404. /** !#en
  16405. A fixed-length object pool designed for general type.<br>
  16406. The implementation of this object pool is very simple,
  16407. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  16408. !#zh
  16409. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  16410. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  16411. export class Pool {
  16412. /**
  16413. !#en
  16414. Constructor for creating an object pool for the specific object type.
  16415. You can pass a callback argument for process the cleanup logic when the object is recycled.
  16416. !#zh
  16417. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  16418. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  16419. @param size initializes the length of the array
  16420. */
  16421. constructor(cleanupFunc: (obj: any) => void, size: number);
  16422. constructor(size: number);
  16423. /**
  16424. !#en
  16425. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  16426. !#zh
  16427. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  16428. @param params parameters to used to initialize the object
  16429. */
  16430. get(...params: any[]): any;
  16431. /** !#en
  16432. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  16433. the maximum will not exceed the size specified when the constructor is called.
  16434. !#zh
  16435. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  16436. count: number;
  16437. /**
  16438. !#en
  16439. Get an object from pool, if no available object in the pool, null will be returned.
  16440. !#zh
  16441. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  16442. */
  16443. _get(): any;
  16444. /**
  16445. !#en Put an object into the pool.
  16446. !#zh 向对象池返还一个不再需要的对象。
  16447. */
  16448. put(): void;
  16449. /**
  16450. !#en Resize the pool.
  16451. !#zh 设置对象池容量。
  16452. */
  16453. resize(): void;
  16454. }
  16455. }
  16456. declare namespace dragonBones {
  16457. /**
  16458. * @private
  16459. */
  16460. const enum ArmatureType {
  16461. Armature = 0,
  16462. MovieClip = 1,
  16463. Stage = 2,
  16464. }
  16465. /**
  16466. * @private
  16467. */
  16468. const enum DisplayType {
  16469. Image = 0,
  16470. Armature = 1,
  16471. Mesh = 2,
  16472. }
  16473. /**
  16474. * @private
  16475. */
  16476. const enum ExtensionType {
  16477. FFD = 0,
  16478. AdjustColor = 10,
  16479. BevelFilter = 11,
  16480. BlurFilter = 12,
  16481. DropShadowFilter = 13,
  16482. GlowFilter = 14,
  16483. GradientBevelFilter = 15,
  16484. GradientGlowFilter = 16,
  16485. }
  16486. /**
  16487. * @private
  16488. */
  16489. const enum EventType {
  16490. Frame = 10,
  16491. Sound = 11,
  16492. }
  16493. /**
  16494. * @private
  16495. */
  16496. const enum ActionType {
  16497. Play = 0,
  16498. Stop = 1,
  16499. GotoAndPlay = 2,
  16500. GotoAndStop = 3,
  16501. FadeIn = 4,
  16502. FadeOut = 5,
  16503. }
  16504. /**
  16505. * @private
  16506. */
  16507. const enum BlendMode {
  16508. Normal = 0,
  16509. Add = 1,
  16510. Alpha = 2,
  16511. Darken = 3,
  16512. Difference = 4,
  16513. Erase = 5,
  16514. HardLight = 6,
  16515. Invert = 7,
  16516. Layer = 8,
  16517. Lighten = 9,
  16518. Multiply = 10,
  16519. Overlay = 11,
  16520. Screen = 12,
  16521. Subtract = 13,
  16522. }
  16523. /**
  16524. * @private
  16525. */
  16526. interface Map<T> {
  16527. [key: string]: T;
  16528. }
  16529. /**
  16530. * DragonBones
  16531. */
  16532. class DragonBones {
  16533. /**
  16534. * @private
  16535. */
  16536. static PI_D: number;
  16537. /**
  16538. * @private
  16539. */
  16540. static PI_H: number;
  16541. /**
  16542. * @private
  16543. */
  16544. static PI_Q: number;
  16545. /**
  16546. * @private
  16547. */
  16548. static ANGLE_TO_RADIAN: number;
  16549. /**
  16550. * @private
  16551. */
  16552. static RADIAN_TO_ANGLE: number;
  16553. /**
  16554. * @private
  16555. */
  16556. static SECOND_TO_MILLISECOND: number;
  16557. static VERSION: string;
  16558. /**
  16559. * @private
  16560. */
  16561. static debug: boolean;
  16562. /**
  16563. * @private
  16564. */
  16565. static debugDraw: boolean;
  16566. }
  16567. }
  16568. declare namespace dragonBones {
  16569. /**
  16570. * @language zh_CN
  16571. * 基础对象。
  16572. * @version DragonBones 4.5
  16573. */
  16574. abstract class BaseObject {
  16575. private static _hashCode;
  16576. private static _defaultMaxCount;
  16577. private static _maxCountMap;
  16578. private static _poolsMap;
  16579. private static _returnObject(object);
  16580. /**
  16581. * @language zh_CN
  16582. * 设置每种对象池的最大缓存数量。
  16583. * @param objectConstructor 对象类。
  16584. * @param maxCount 最大缓存数量。 (设置为 0 则不缓存)
  16585. * @version DragonBones 4.5
  16586. */
  16587. static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
  16588. /**
  16589. * @language zh_CN
  16590. * 清除对象池缓存的对象。
  16591. * @param objectConstructor 对象类。 (不设置则清除所有缓存)
  16592. * @version DragonBones 4.5
  16593. */
  16594. static clearPool(objectConstructor?: typeof BaseObject): void;
  16595. /**
  16596. * @language zh_CN
  16597. * 从对象池中创建指定对象。
  16598. * @param objectConstructor 对象类。
  16599. * @version DragonBones 4.5
  16600. */
  16601. static borrowObject<T extends BaseObject>(objectConstructor: {
  16602. new (): T;
  16603. }): T;
  16604. /**
  16605. * @language zh_CN
  16606. * 对象的唯一标识。
  16607. * @version DragonBones 4.5
  16608. */
  16609. hashCode: number;
  16610. /**
  16611. * @private
  16612. */
  16613. protected abstract _onClear(): void;
  16614. /**
  16615. * @language zh_CN
  16616. * 清除数据并返还对象池。
  16617. * @version DragonBones 4.5
  16618. */
  16619. returnToPool(): void;
  16620. }
  16621. }
  16622. declare namespace dragonBones {
  16623. }
  16624. declare namespace dragonBones {
  16625. /**
  16626. * @language zh_CN
  16627. * 动画混合时,使用的淡出方式。
  16628. * @see dragonBones.Animation#fadeIn()
  16629. * @version DragonBones 4.5
  16630. */
  16631. const enum AnimationFadeOutMode {
  16632. /**
  16633. * @language zh_CN
  16634. * 不淡出动画。
  16635. * @version DragonBones 4.5
  16636. */
  16637. None = 0,
  16638. /**
  16639. * @language zh_CN
  16640. * 淡出同层的动画。
  16641. * @version DragonBones 4.5
  16642. */
  16643. SameLayer = 1,
  16644. /**
  16645. * @language zh_CN
  16646. * 淡出同组的动画。
  16647. * @version DragonBones 4.5
  16648. */
  16649. SameGroup = 2,
  16650. /**
  16651. * @language zh_CN
  16652. * 淡出同层并且同组的动画。
  16653. * @version DragonBones 4.5
  16654. */
  16655. SameLayerAndGroup = 3,
  16656. /**
  16657. * @language zh_CN
  16658. * 淡出所有动画。
  16659. * @version DragonBones 4.5
  16660. */
  16661. All = 4,
  16662. }
  16663. /**
  16664. * @language zh_CN
  16665. * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口)
  16666. * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。
  16667. * @see dragonBones.WorldClock
  16668. * @see dragonBones.Armature
  16669. * @version DragonBones 3.0
  16670. */
  16671. interface IAnimateble {
  16672. /**
  16673. * @language zh_CN
  16674. * 更新一个指定的时间。
  16675. * @param passedTime 前进的时间。 (以秒为单位)
  16676. * @version DragonBones 3.0
  16677. */
  16678. advanceTime(passedTime: number): void;
  16679. }
  16680. /**
  16681. * @language zh_CN
  16682. * 动画控制器,用来播放动画数据,管理动画状态。
  16683. * @see dragonBones.AnimationData
  16684. * @see dragonBones.AnimationState
  16685. * @version DragonBones 3.0
  16686. */
  16687. class Animation extends BaseObject {
  16688. /**
  16689. * @private
  16690. */
  16691. private static _sortAnimationState(a, b);
  16692. /**
  16693. * @private
  16694. */
  16695. static toString(): string;
  16696. /**
  16697. * @language zh_CN
  16698. * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  16699. * @default 1
  16700. * @version DragonBones 3.0
  16701. */
  16702. timeScale: number;
  16703. /**
  16704. * @private
  16705. */
  16706. _armature: Armature;
  16707. private _isPlaying;
  16708. private _time;
  16709. private _duration;
  16710. private _lastAnimationState;
  16711. private _animations;
  16712. private _animationNames;
  16713. private _animationStates;
  16714. /**
  16715. * @inheritDoc
  16716. */
  16717. protected _onClear(): void;
  16718. private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut);
  16719. /**
  16720. * @language zh_CN
  16721. * 清除所有正在播放的动画状态。
  16722. * @version DragonBones 4.5
  16723. */
  16724. reset(): void;
  16725. /**
  16726. * @language zh_CN
  16727. * 暂停播放动画。
  16728. * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。
  16729. * @see dragonBones.AnimationState
  16730. * @version DragonBones 3.0
  16731. */
  16732. stop(animationName?: string): void;
  16733. /**
  16734. * @language zh_CN
  16735. * 播放动画。
  16736. * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。
  16737. * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16738. * @returns 返回控制这个动画数据的动画状态。
  16739. * @see dragonBones.AnimationState
  16740. * @version DragonBones 3.0
  16741. */
  16742. play(animationName?: string, playTimes?: number): AnimationState;
  16743. /**
  16744. * @language zh_CN
  16745. * 淡入播放指定名称的动画。
  16746. * @param animationName 动画数据的名称。
  16747. * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16748. * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
  16749. * @param layer 混合的图层,图层高会优先获取混合权重。
  16750. * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
  16751. * @param fadeOutMode 淡出的模式。
  16752. * @param additiveBlending 以叠加的形式混合。
  16753. * @param displayControl 是否对显示对象属性可控。
  16754. * @param pauseFadeOut 暂停需要淡出的动画。
  16755. * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
  16756. * @returns 返回控制这个动画数据的动画状态。
  16757. * @see dragonBones.AnimationFadeOutMode
  16758. * @see dragonBones.AnimationState
  16759. * @version DragonBones 4.5
  16760. */
  16761. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  16762. /**
  16763. * @language zh_CN
  16764. * 指定名称的动画从指定时间开始播放。
  16765. * @param animationName 动画数据的名称。
  16766. * @param time 时间。 (以秒为单位)
  16767. * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16768. * @param toTime 播放到指定的时间,如果未设置则播放整个动画。
  16769. * @returns 返回控制这个动画数据的动画状态。
  16770. * @see dragonBones.AnimationState
  16771. * @version DragonBones 4.5
  16772. */
  16773. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState;
  16774. /**
  16775. * @language zh_CN
  16776. * 指定名称的动画从指定帧开始播放。
  16777. * @param animationName 动画数据的名称。
  16778. * @param frame 帧。
  16779. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16780. * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。
  16781. * @returns 返回控制这个动画数据的动画状态。
  16782. * @see dragonBones.AnimationState
  16783. * @version DragonBones 4.5
  16784. */
  16785. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState;
  16786. /**
  16787. * @language zh_CN
  16788. * 指定名称的动画从指定进度开始播放。
  16789. * @param animationName 动画数据的名称。
  16790. * @param progress 进度。 [0~1]
  16791. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  16792. * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。
  16793. * @returns 返回控制这个动画数据的动画状态。
  16794. * @see dragonBones.AnimationState
  16795. * @version DragonBones 4.5
  16796. */
  16797. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState;
  16798. /**
  16799. * @language zh_CN
  16800. * 播放指定名称的动画到指定的时间并停止。
  16801. * @param animationName 动画数据的名称。
  16802. * @param time 时间。 (以秒为单位)
  16803. * @returns 返回控制这个动画数据的动画状态。
  16804. * @see dragonBones.AnimationState
  16805. * @version DragonBones 4.5
  16806. */
  16807. gotoAndStopByTime(animationName: string, time?: number): AnimationState;
  16808. /**
  16809. * @language zh_CN
  16810. * 播放指定名称的动画到指定的帧并停止。
  16811. * @param animationName 动画数据的名称。
  16812. * @param frame 帧。
  16813. * @returns 返回控制这个动画数据的动画状态。
  16814. * @see dragonBones.AnimationState
  16815. * @version DragonBones 4.5
  16816. */
  16817. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState;
  16818. /**
  16819. * @language zh_CN
  16820. * 播放指定名称的动画到指定的进度并停止。
  16821. * @param animationName 动画数据的名称。
  16822. * @param progress 进度。 [0~1]
  16823. * @returns 返回控制这个动画数据的动画状态。
  16824. * @see dragonBones.AnimationState
  16825. * @version DragonBones 4.5
  16826. */
  16827. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState;
  16828. /**
  16829. * @language zh_CN
  16830. * 获取指定名称的动画状态。
  16831. * @param animationName 动画状态的名称。
  16832. * @see dragonBones.AnimationState
  16833. * @version DragonBones 3.0
  16834. */
  16835. getState(animationName: string): AnimationState;
  16836. /**
  16837. * @language zh_CN
  16838. * 是否包含指定名称的动画数据。
  16839. * @param animationName 动画数据的名称。
  16840. * @see dragonBones.AnimationData
  16841. * @version DragonBones 3.0
  16842. */
  16843. hasAnimation(animationName: string): boolean;
  16844. /**
  16845. * @language zh_CN
  16846. * 动画是否处于播放状态。
  16847. * @version DragonBones 3.0
  16848. */
  16849. isPlaying: boolean;
  16850. /**
  16851. * @language zh_CN
  16852. * 所有动画状态是否均已播放完毕。
  16853. * @see dragonBones.AnimationState
  16854. * @version DragonBones 3.0
  16855. */
  16856. isCompleted: boolean;
  16857. /**
  16858. * @language zh_CN
  16859. * 上一个正在播放的动画状态的名称。
  16860. * @see #lastAnimationState
  16861. * @version DragonBones 3.0
  16862. */
  16863. lastAnimationName: string;
  16864. /**
  16865. * @language zh_CN
  16866. * 上一个正在播放的动画状态。
  16867. * @see dragonBones.AnimationState
  16868. * @version DragonBones 3.0
  16869. */
  16870. lastAnimationState: AnimationState;
  16871. /**
  16872. * @language zh_CN
  16873. * 所有动画数据名称。
  16874. * @see #animations
  16875. * @version DragonBones 4.5
  16876. */
  16877. animationNames: Array<string>;
  16878. /**
  16879. * @language zh_CN
  16880. * 所有的动画数据。
  16881. * @see dragonBones.AnimationData
  16882. * @version DragonBones 4.5
  16883. */
  16884. animations: Map<AnimationData>;
  16885. /**
  16886. * @deprecated
  16887. * @see #play()
  16888. * @see #fadeIn()
  16889. * @see #gotoAndPlayByTime()
  16890. * @see #gotoAndPlayByFrame()
  16891. * @see #gotoAndPlayByProgress()
  16892. */
  16893. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  16894. /**
  16895. * @deprecated
  16896. * @see #gotoAndStopByTime()
  16897. * @see #gotoAndStopByFrame()
  16898. * @see #gotoAndStopByProgress()
  16899. */
  16900. gotoAndStop(animationName: string, time?: number): AnimationState;
  16901. /**
  16902. * @deprecated
  16903. * @see #animationNames
  16904. * @see #animations
  16905. */
  16906. animationList: Array<string>;
  16907. /**
  16908. * @language zh_CN
  16909. * @deprecated
  16910. * @see #animationNames
  16911. * @see #animations
  16912. */
  16913. animationDataList: Array<AnimationData>;
  16914. }
  16915. }
  16916. declare namespace dragonBones {
  16917. /**
  16918. * @language zh_CN
  16919. * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。
  16920. * @see dragonBones.Animation
  16921. * @see dragonBones.AnimationData
  16922. * @version DragonBones 3.0
  16923. */
  16924. class AnimationState extends BaseObject {
  16925. /**
  16926. * @private
  16927. */
  16928. static stateActionEnabled: boolean;
  16929. /**
  16930. * @private
  16931. */
  16932. static toString(): string;
  16933. /**
  16934. * @language zh_CN
  16935. * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。
  16936. * @see dragonBones.Slot#displayController
  16937. * @version DragonBones 3.0
  16938. */
  16939. displayControl: boolean;
  16940. /**
  16941. * @language zh_CN
  16942. * 是否以叠加的方式混合动画。
  16943. * @version DragonBones 3.0
  16944. */
  16945. additiveBlending: boolean;
  16946. /**
  16947. * @private
  16948. */
  16949. actionEnabled: boolean;
  16950. /**
  16951. * @language zh_CN
  16952. * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  16953. * @version DragonBones 3.0
  16954. */
  16955. playTimes: number;
  16956. /**
  16957. * @language zh_CN
  16958. * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  16959. * @default 1
  16960. * @version DragonBones 3.0
  16961. */
  16962. timeScale: number;
  16963. /**
  16964. * @language zh_CN
  16965. * 进行动画混合时的权重。
  16966. * @default 1
  16967. * @version DragonBones 3.0
  16968. */
  16969. weight: number;
  16970. /**
  16971. * @language zh_CN
  16972. * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位)
  16973. * @default -1
  16974. * @version DragonBones 3.0
  16975. */
  16976. autoFadeOutTime: number;
  16977. /**
  16978. * @private
  16979. */
  16980. fadeTotalTime: number;
  16981. /**
  16982. * @private
  16983. */
  16984. private _isPlaying;
  16985. /**
  16986. * @private
  16987. */
  16988. private _isPausePlayhead;
  16989. /**
  16990. * @private
  16991. */
  16992. private _fadeTime;
  16993. /**
  16994. * @private
  16995. */
  16996. private _time;
  16997. /**
  16998. * @private
  16999. */
  17000. private _name;
  17001. /**
  17002. * @private
  17003. */
  17004. private _armature;
  17005. /**
  17006. * @private
  17007. */
  17008. private _animationData;
  17009. /**
  17010. * @private
  17011. */
  17012. private _zOrderTimeline;
  17013. /**
  17014. * @private
  17015. */
  17016. private _boneMask;
  17017. /**
  17018. * @private
  17019. */
  17020. private _boneTimelines;
  17021. /**
  17022. * @private
  17023. */
  17024. private _slotTimelines;
  17025. /**
  17026. * @private
  17027. */
  17028. private _ffdTimelines;
  17029. /**
  17030. * @inheritDoc
  17031. */
  17032. protected _onClear(): void;
  17033. private _updateTimelineStates();
  17034. private _advanceFadeTime(passedTime);
  17035. /**
  17036. * @language zh_CN
  17037. * 继续播放。
  17038. * @version DragonBones 3.0
  17039. */
  17040. play(): void;
  17041. /**
  17042. * @language zh_CN
  17043. * 暂停播放。
  17044. * @version DragonBones 3.0
  17045. */
  17046. stop(): void;
  17047. /**
  17048. * @language zh_CN
  17049. * 淡出动画。
  17050. * @param fadeOutTime 淡出时间。 (以秒为单位)
  17051. * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停]
  17052. * @version DragonBones 3.0
  17053. */
  17054. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  17055. /**
  17056. * @language zh_CN
  17057. * 是否包含指定的骨骼遮罩。
  17058. * @param name 指定的骨骼名称。
  17059. * @version DragonBones 3.0
  17060. */
  17061. containsBoneMask(name: string): boolean;
  17062. /**
  17063. * @language zh_CN
  17064. * 添加指定的骨骼遮罩。
  17065. * @param boneName 指定的骨骼名称。
  17066. * @param recursive 是否为该骨骼的子骨骼添加遮罩。
  17067. * @version DragonBones 3.0
  17068. */
  17069. addBoneMask(name: string, recursive?: boolean): void;
  17070. /**
  17071. * @language zh_CN
  17072. * 删除指定的骨骼遮罩。
  17073. * @param boneName 指定的骨骼名称。
  17074. * @param recursive 是否删除该骨骼的子骨骼遮罩。
  17075. * @version DragonBones 3.0
  17076. */
  17077. removeBoneMask(name: string, recursive?: boolean): void;
  17078. /**
  17079. * @language zh_CN
  17080. * 删除所有骨骼遮罩。
  17081. * @version DragonBones 3.0
  17082. */
  17083. removeAllBoneMask(): void;
  17084. /**
  17085. * @language zh_CN
  17086. * 动画图层。
  17087. * @see dragonBones.Animation#fadeIn()
  17088. * @version DragonBones 3.0
  17089. */
  17090. layer: number;
  17091. /**
  17092. * @language zh_CN
  17093. * 动画组。
  17094. * @see dragonBones.Animation#fadeIn()
  17095. * @version DragonBones 3.0
  17096. */
  17097. group: string;
  17098. /**
  17099. * @language zh_CN
  17100. * 动画名称。
  17101. * @see dragonBones.AnimationData#name
  17102. * @version DragonBones 3.0
  17103. */
  17104. name: string;
  17105. /**
  17106. * @language zh_CN
  17107. * 动画数据。
  17108. * @see dragonBones.AnimationData
  17109. * @version DragonBones 3.0
  17110. */
  17111. animationData: AnimationData;
  17112. /**
  17113. * @language zh_CN
  17114. * 是否播放完毕。
  17115. * @version DragonBones 3.0
  17116. */
  17117. isCompleted: boolean;
  17118. /**
  17119. * @language zh_CN
  17120. * 是否正在播放。
  17121. * @version DragonBones 3.0
  17122. */
  17123. isPlaying: boolean;
  17124. /**
  17125. * @language zh_CN
  17126. * 当前动画的播放次数。
  17127. * @version DragonBones 3.0
  17128. */
  17129. currentPlayTimes: number;
  17130. /**
  17131. * @language zh_CN
  17132. * 当前动画的总时间。 (以秒为单位)
  17133. * @version DragonBones 3.0
  17134. */
  17135. totalTime: number;
  17136. /**
  17137. * @language zh_CN
  17138. * 当前动画的播放时间。 (以秒为单位)
  17139. * @version DragonBones 3.0
  17140. */
  17141. currentTime: number;
  17142. /**
  17143. * @deprecated
  17144. */
  17145. autoTween: boolean;
  17146. /**
  17147. * @deprecated
  17148. * @see #animationData
  17149. */
  17150. clip: AnimationData;
  17151. }
  17152. }
  17153. declare namespace dragonBones {
  17154. }
  17155. declare namespace dragonBones {
  17156. /**
  17157. * @language zh_CN
  17158. * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。
  17159. * @see dragonBones.IAnimatable
  17160. * @see dragonBones.Armature
  17161. * @version DragonBones 3.0
  17162. */
  17163. class WorldClock implements IAnimateble {
  17164. private static _clock;
  17165. /**
  17166. * @language zh_CN
  17167. * 一个可以直接使用的全局 WorldClock 实例.
  17168. * @version DragonBones 3.0
  17169. */
  17170. static clock: WorldClock;
  17171. /**
  17172. * @language zh_CN
  17173. * 当前的时间。 (以秒为单位)
  17174. * @version DragonBones 3.0
  17175. */
  17176. time: number;
  17177. /**
  17178. * @language zh_CN
  17179. * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17180. * @default 1
  17181. * @version DragonBones 3.0
  17182. */
  17183. timeScale: number;
  17184. private _animatebles;
  17185. /**
  17186. * @language zh_CN
  17187. * 创建一个新的 WorldClock 实例。
  17188. * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。
  17189. * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放)
  17190. * @version DragonBones 3.0
  17191. */
  17192. constructor();
  17193. /**
  17194. * @language zh_CN
  17195. * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用)
  17196. * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差)
  17197. * @version DragonBones 3.0
  17198. */
  17199. advanceTime(passedTime: number): void;
  17200. /**
  17201. * 是否包含指定的 IAnimatable 实例
  17202. * @param value 指定的 IAnimatable 实例。
  17203. * @returns [true: 包含,false: 不包含]。
  17204. * @version DragonBones 3.0
  17205. */
  17206. contains(value: IAnimateble): boolean;
  17207. /**
  17208. * @language zh_CN
  17209. * 添加指定的 IAnimatable 实例。
  17210. * @param value IAnimatable 实例。
  17211. * @version DragonBones 3.0
  17212. */
  17213. add(value: IAnimateble): void;
  17214. /**
  17215. * @language zh_CN
  17216. * 移除指定的 IAnimatable 实例。
  17217. * @param value IAnimatable 实例。
  17218. * @version DragonBones 3.0
  17219. */
  17220. remove(value: IAnimateble): void;
  17221. /**
  17222. * @language zh_CN
  17223. * 清除所有的 IAnimatable 实例。
  17224. * @version DragonBones 3.0
  17225. */
  17226. clear(): void;
  17227. }
  17228. }
  17229. declare namespace dragonBones {
  17230. /**
  17231. * @language zh_CN
  17232. * 基础变换对象。
  17233. * @version DragonBones 4.5
  17234. */
  17235. abstract class TransformObject extends BaseObject {
  17236. /**
  17237. * @language zh_CN
  17238. * 可以用于存储临时数据。
  17239. * @version DragonBones 3.0
  17240. */
  17241. userData: any;
  17242. /**
  17243. * @language zh_CN
  17244. * 对象的名称。
  17245. * @version DragonBones 3.0
  17246. */
  17247. name: string;
  17248. /**
  17249. * @language zh_CN
  17250. * 相对于骨架坐标系的矩阵。
  17251. * @version DragonBones 3.0
  17252. */
  17253. globalTransformMatrix: Matrix;
  17254. /**
  17255. * @language zh_CN
  17256. * 相对于骨架坐标系的变换。
  17257. * @see dragonBones.Transform
  17258. * @version DragonBones 3.0
  17259. */
  17260. global: Transform;
  17261. /**
  17262. * @language zh_CN
  17263. * 相对于骨架或父骨骼坐标系的绑定变换。
  17264. * @see dragonBones.Transform
  17265. * @version DragonBones 3.0
  17266. */
  17267. origin: Transform;
  17268. /**
  17269. * @language zh_CN
  17270. * 相对于骨架或父骨骼坐标系的偏移变换。
  17271. * @see dragonBones.Transform
  17272. * @version DragonBones 3.0
  17273. */
  17274. offset: Transform;
  17275. /**
  17276. * @private
  17277. */
  17278. _armature: Armature;
  17279. /**
  17280. * @private
  17281. */
  17282. _parent: Bone;
  17283. /**
  17284. * @private
  17285. */
  17286. protected _globalTransformMatrix: Matrix;
  17287. /**
  17288. * @inheritDoc
  17289. */
  17290. protected _onClear(): void;
  17291. /**
  17292. * @language zh_CN
  17293. * 所属的骨架。
  17294. * @see dragonBones.Armature
  17295. * @version DragonBones 3.0
  17296. */
  17297. armature: Armature;
  17298. /**
  17299. * @language zh_CN
  17300. * 所属的父骨骼。
  17301. * @see dragonBones.Bone
  17302. * @version DragonBones 3.0
  17303. */
  17304. parent: Bone;
  17305. }
  17306. }
  17307. declare namespace dragonBones {
  17308. /**
  17309. * @language zh_CN
  17310. * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。
  17311. * @see dragonBones.ArmatureData
  17312. * @see dragonBones.Bone
  17313. * @see dragonBones.Slot
  17314. * @see dragonBones.Animation
  17315. * @see dragonBones.IArmatureDisplay
  17316. * @version DragonBones 3.0
  17317. */
  17318. class Armature extends BaseObject implements IAnimateble {
  17319. /**
  17320. * @private
  17321. */
  17322. static toString(): string;
  17323. private static _onSortSlots(a, b);
  17324. /**
  17325. * @language zh_CN
  17326. * 可以用于存储临时数据。
  17327. * @version DragonBones 3.0
  17328. */
  17329. userData: any;
  17330. /**
  17331. * @private
  17332. */
  17333. _cacheFrameIndex: number;
  17334. /**
  17335. * @private
  17336. */
  17337. _armatureData: ArmatureData;
  17338. /**
  17339. * @private
  17340. */
  17341. _skinData: SkinData;
  17342. /**
  17343. * @private
  17344. */
  17345. _animation: Animation;
  17346. /**
  17347. * @private
  17348. */
  17349. _display: IArmatureDisplay;
  17350. /**
  17351. * @private
  17352. */
  17353. _eventManager: IEventDispatcher;
  17354. private _delayDispose;
  17355. private _lockDispose;
  17356. private _slotsDirty;
  17357. private _replacedTexture;
  17358. private _bones;
  17359. private _slots;
  17360. private _actions;
  17361. private _events;
  17362. /**
  17363. * @inheritDoc
  17364. */
  17365. protected _onClear(): void;
  17366. private _sortBones();
  17367. private _sortSlots();
  17368. private _doAction(value);
  17369. /**
  17370. * @private
  17371. */
  17372. _sortZOrder(slotIndices: Array<number>): void;
  17373. /**
  17374. * @private
  17375. */
  17376. _bufferAction(value: ActionData): void;
  17377. /**
  17378. * @language zh_CN
  17379. * 释放骨架。 (会回收到内存池)
  17380. * @version DragonBones 3.0
  17381. */
  17382. dispose(): void;
  17383. /**
  17384. * @language zh_CN
  17385. * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新)
  17386. * @param passedTime 两帧之前的时间间隔。 (以秒为单位)
  17387. * @see dragonBones.IAnimateble
  17388. * @see dragonBones.WorldClock
  17389. * @see dragonBones.IArmatureDisplay
  17390. * @version DragonBones 3.0
  17391. */
  17392. advanceTime(passedTime: number): void;
  17393. /**
  17394. * @language zh_CN
  17395. * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17396. * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。
  17397. * @param updateSlotDisplay 是否更新插槽的显示对象。
  17398. * @see dragonBones.Bone
  17399. * @see dragonBones.Slot
  17400. * @version DragonBones 3.0
  17401. */
  17402. invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void;
  17403. /**
  17404. * @language zh_CN
  17405. * 获取指定名称的骨骼。
  17406. * @param name 骨骼的名称。
  17407. * @returns 骨骼。
  17408. * @see dragonBones.Bone
  17409. * @version DragonBones 3.0
  17410. */
  17411. getBone(name: string): Bone;
  17412. /**
  17413. * @language zh_CN
  17414. * 通过显示对象获取骨骼。
  17415. * @param display 显示对象。
  17416. * @returns 包含这个显示对象的骨骼。
  17417. * @see dragonBones.Bone
  17418. * @version DragonBones 3.0
  17419. */
  17420. getBoneByDisplay(display: any): Bone;
  17421. /**
  17422. * @language zh_CN
  17423. * 获取指定名称的插槽。
  17424. * @param name 插槽的名称。
  17425. * @returns 插槽。
  17426. * @see dragonBones.Slot
  17427. * @version DragonBones 3.0
  17428. */
  17429. getSlot(name: string): Slot;
  17430. /**
  17431. * @language zh_CN
  17432. * 通过显示对象获取插槽。
  17433. * @param display 显示对象。
  17434. * @returns 包含这个显示对象的插槽。
  17435. * @see dragonBones.Slot
  17436. * @version DragonBones 3.0
  17437. */
  17438. getSlotByDisplay(display: any): Slot;
  17439. /**
  17440. * @language zh_CN
  17441. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17442. * @param texture 贴图。
  17443. * @version DragonBones 4.5
  17444. */
  17445. replaceTexture(texture: any): void;
  17446. /**
  17447. * @language zh_CN
  17448. * 获取所有骨骼。
  17449. * @see dragonBones.Bone
  17450. * @version DragonBones 3.0
  17451. */
  17452. getBones(): Array<Bone>;
  17453. /**
  17454. * @language zh_CN
  17455. * 获取所有插槽。
  17456. * @see dragonBones.Slot
  17457. * @version DragonBones 3.0
  17458. */
  17459. getSlots(): Array<Slot>;
  17460. /**
  17461. * @language zh_CN
  17462. * 骨架名称。
  17463. * @see dragonBones.ArmatureData#name
  17464. * @version DragonBones 3.0
  17465. */
  17466. name: string;
  17467. /**
  17468. * @language zh_CN
  17469. * 获取骨架数据。
  17470. * @see dragonBones.ArmatureData
  17471. * @version DragonBones 4.5
  17472. */
  17473. armatureData: ArmatureData;
  17474. /**
  17475. * @language zh_CN
  17476. * 获得动画控制器。
  17477. * @see dragonBones.Animation
  17478. * @version DragonBones 3.0
  17479. */
  17480. animation: Animation;
  17481. /**
  17482. * @language zh_CN
  17483. * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  17484. * @version DragonBones 3.0
  17485. */
  17486. display: IArmatureDisplay | any;
  17487. /**
  17488. * @language zh_CN
  17489. * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系)
  17490. * @see dragonBones.Slot
  17491. * @version DragonBones 4.5
  17492. */
  17493. parent: Slot;
  17494. /**
  17495. * @language zh_CN
  17496. * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。
  17497. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  17498. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  17499. * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。
  17500. * @see dragonBones.DragonBonesData#frameRate
  17501. * @see dragonBones.ArmatureData#frameRate
  17502. * @version DragonBones 4.5
  17503. */
  17504. cacheFrameRate: number;
  17505. /**
  17506. * @language zh_CN
  17507. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17508. * @version DragonBones 4.5
  17509. */
  17510. replacedTexture: any;
  17511. /**
  17512. * @language zh_CN
  17513. * 开启动画缓存。
  17514. * @param frameRate 动画缓存的帧率
  17515. * @see #cacheFrameRate
  17516. * @version DragonBones 4.5
  17517. */
  17518. enableAnimationCache(frameRate: number): void;
  17519. /**
  17520. * @language zh_CN
  17521. * 是否包含指定类型的事件。
  17522. * @param type 事件类型。
  17523. * @returns [true: 包含, false: 不包含]
  17524. * @version DragonBones 3.0
  17525. */
  17526. hasEventListener(type: EventStringType): void;
  17527. /**
  17528. * @language zh_CN
  17529. * 添加事件。
  17530. * @param type 事件类型。
  17531. * @param listener 事件回调。
  17532. * @version DragonBones 3.0
  17533. */
  17534. addEventListener(type: EventStringType, listener: Function, target: any): void;
  17535. /**
  17536. * @language zh_CN
  17537. * 移除事件。
  17538. * @param type 事件类型。
  17539. * @param listener 事件回调。
  17540. * @version DragonBones 3.0
  17541. */
  17542. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  17543. /**
  17544. * @deprecated
  17545. */
  17546. addBone(value: Bone, parentName?: string): void;
  17547. /**
  17548. * @deprecated
  17549. */
  17550. addSlot(value: Slot, parentName: string): void;
  17551. /**
  17552. * @deprecated
  17553. */
  17554. removeBone(value: Bone): void;
  17555. /**
  17556. * @deprecated
  17557. */
  17558. removeSlot(value: Slot): void;
  17559. /**
  17560. * @deprecated
  17561. * @see #display
  17562. */
  17563. getDisplay(): any;
  17564. /**
  17565. * @deprecated
  17566. * @see #cacheFrameRate
  17567. */
  17568. enableCache: boolean;
  17569. }
  17570. }
  17571. declare namespace dragonBones {
  17572. /**
  17573. * @language zh_CN
  17574. * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。
  17575. * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。
  17576. * @see dragonBones.BoneData
  17577. * @see dragonBones.Armature
  17578. * @see dragonBones.Slot
  17579. * @version DragonBones 3.0
  17580. */
  17581. class Bone extends TransformObject {
  17582. /**
  17583. * @private
  17584. */
  17585. static toString(): string;
  17586. /**
  17587. * @language zh_CN
  17588. * 是否继承父骨骼的平移。 [true: 继承, false: 不继承]
  17589. * @version DragonBones 3.0
  17590. */
  17591. inheritTranslation: boolean;
  17592. /**
  17593. * @language zh_CN
  17594. * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承]
  17595. * @version DragonBones 3.0
  17596. */
  17597. inheritRotation: boolean;
  17598. /**
  17599. * @language zh_CN
  17600. * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承]
  17601. * @version DragonBones 4.5
  17602. */
  17603. inheritScale: boolean;
  17604. /**
  17605. * @language zh_CN
  17606. * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针]
  17607. * @version DragonBones 4.5
  17608. */
  17609. ikBendPositive: boolean;
  17610. /**
  17611. * @language zh_CN
  17612. * IK 约束的权重。
  17613. * @version DragonBones 4.5
  17614. */
  17615. ikWeight: number;
  17616. /**
  17617. * @language zh_CN
  17618. * 骨骼长度。
  17619. * @version DragonBones 4.5
  17620. */
  17621. length: number;
  17622. /**
  17623. * @private
  17624. */
  17625. private _visible;
  17626. /**
  17627. * @private
  17628. */
  17629. private _ikChain;
  17630. /**
  17631. * @private
  17632. */
  17633. private _ikChainIndex;
  17634. /**
  17635. * @private
  17636. */
  17637. private _ik;
  17638. /**
  17639. * @private
  17640. */
  17641. private _bones;
  17642. /**
  17643. * @private
  17644. */
  17645. private _slots;
  17646. /**
  17647. * @inheritDoc
  17648. */
  17649. protected _onClear(): void;
  17650. /**
  17651. * @private
  17652. */
  17653. private _updateGlobalTransformMatrix();
  17654. /**
  17655. * @private
  17656. */
  17657. private _computeIKA();
  17658. /**
  17659. * @private
  17660. */
  17661. private _computeIKB();
  17662. /**
  17663. * @inheritDoc
  17664. */
  17665. _setArmature(value: Armature): void;
  17666. /**
  17667. * @language zh_CN
  17668. * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17669. * @version DragonBones 3.0
  17670. */
  17671. invalidUpdate(): void;
  17672. /**
  17673. * @language zh_CN
  17674. * 是否包含某个指定的骨骼或插槽。
  17675. * @returns [true: 包含,false: 不包含]
  17676. * @see dragonBones.TransformObject
  17677. * @version DragonBones 3.0
  17678. */
  17679. contains(child: TransformObject): boolean;
  17680. /**
  17681. * @language zh_CN
  17682. * 所有的子骨骼。
  17683. * @version DragonBones 3.0
  17684. */
  17685. getBones(): Array<Bone>;
  17686. /**
  17687. * @language zh_CN
  17688. * 所有的插槽。
  17689. * @see dragonBones.Slot
  17690. * @version DragonBones 3.0
  17691. */
  17692. getSlots(): Array<Slot>;
  17693. /**
  17694. * @private
  17695. */
  17696. ikChain: number;
  17697. /**
  17698. * @private
  17699. */
  17700. ikChainIndex: number;
  17701. /**
  17702. * @language zh_CN
  17703. * 当前的 IK 约束目标。
  17704. * @version DragonBones 4.5
  17705. */
  17706. ik: Bone;
  17707. /**
  17708. * @language zh_CN
  17709. * 控制此骨骼所有插槽的显示。
  17710. * @default true
  17711. * @see dragonBones.Slot
  17712. * @version DragonBones 3.0
  17713. */
  17714. visible: boolean;
  17715. /**
  17716. * @deprecated
  17717. * @see dragonBones.Armature#getSlot()
  17718. */
  17719. slot: Slot;
  17720. }
  17721. }
  17722. declare namespace dragonBones {
  17723. /**
  17724. * @language zh_CN
  17725. * 骨架显示容器和事件的接口。
  17726. * @see dragonBones.Armature#display
  17727. * @version DragonBones 4.5
  17728. */
  17729. interface IArmatureDisplay extends IEventDispatcher {
  17730. /**
  17731. * @language zh_CN
  17732. * 释放显示对象和骨架。
  17733. * @version DragonBones 4.5
  17734. */
  17735. dispose(): void;
  17736. /**
  17737. * @language zh_CN
  17738. * 获取使用这个显示容器的骨架。
  17739. * @readOnly
  17740. * @see dragonBones.Armature
  17741. * @version DragonBones 4.5
  17742. */
  17743. armature: Armature;
  17744. /**
  17745. * @language zh_CN
  17746. * 获取使用骨架的动画控制器。
  17747. * @readOnly
  17748. * @see dragonBones.Animation
  17749. * @version DragonBones 4.5
  17750. */
  17751. animation: Animation;
  17752. /**
  17753. * @language zh_CN
  17754. * 由显示容器来更新骨架和动画。
  17755. * @param on 开启或关闭显示容器对骨架与动画的更新。
  17756. * @version DragonBones 4.5
  17757. */
  17758. advanceTimeBySelf(on: boolean): void;
  17759. }
  17760. }
  17761. declare namespace dragonBones {
  17762. /**
  17763. * @language zh_CN
  17764. * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。
  17765. * 一个骨骼上可以包含多个插槽。
  17766. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  17767. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  17768. * @see dragonBones.Armature
  17769. * @see dragonBones.Bone
  17770. * @see dragonBones.SlotData
  17771. * @version DragonBones 3.0
  17772. */
  17773. abstract class Slot extends TransformObject {
  17774. private static _helpPoint;
  17775. private static _helpMatrix;
  17776. /**
  17777. * @language zh_CN
  17778. * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承]
  17779. * @default true
  17780. * @version DragonBones 4.5
  17781. */
  17782. inheritAnimation: boolean;
  17783. /**
  17784. * @language zh_CN
  17785. * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。
  17786. * @default null
  17787. * @see dragonBones.AnimationState#displayControl
  17788. * @see dragonBones.AnimationState#name
  17789. * @see dragonBones.AnimationState#group
  17790. * @version DragonBones 4.5
  17791. */
  17792. displayController: string;
  17793. /**
  17794. * @private
  17795. */
  17796. _zOrder: number;
  17797. /**
  17798. * @private
  17799. */
  17800. _pivotX: number;
  17801. /**
  17802. * @private
  17803. */
  17804. _pivotY: number;
  17805. /**
  17806. * @private
  17807. */
  17808. _displayDataSet: SlotDisplayDataSet;
  17809. /**
  17810. * @private
  17811. */
  17812. _meshData: MeshData;
  17813. /**
  17814. * @private
  17815. */
  17816. _childArmature: Armature;
  17817. /**
  17818. * @private
  17819. */
  17820. _rawDisplay: any;
  17821. /**
  17822. * @private
  17823. */
  17824. _meshDisplay: any;
  17825. /**
  17826. * @private
  17827. */
  17828. _cacheFrames: Array<Matrix>;
  17829. /**
  17830. * @private
  17831. */
  17832. _colorTransform: ColorTransform;
  17833. /**
  17834. * @private
  17835. */
  17836. _ffdVertices: Array<number>;
  17837. /**
  17838. * @private
  17839. */
  17840. _replacedDisplayDataSet: Array<DisplayData>;
  17841. /**
  17842. * @private
  17843. */
  17844. protected _displayDirty: boolean;
  17845. /**
  17846. * @private
  17847. */
  17848. protected _blendModeDirty: boolean;
  17849. /**
  17850. * @private
  17851. */
  17852. protected _originDirty: boolean;
  17853. /**
  17854. * @private
  17855. */
  17856. protected _transformDirty: boolean;
  17857. /**
  17858. * @private
  17859. */
  17860. protected _displayIndex: number;
  17861. /**
  17862. * @private
  17863. */
  17864. protected _blendMode: BlendMode;
  17865. /**
  17866. * @private
  17867. */
  17868. protected _display: any;
  17869. /**
  17870. * @private
  17871. */
  17872. protected _localMatrix: Matrix;
  17873. /**
  17874. * @private
  17875. */
  17876. protected _displayList: Array<any | Armature>;
  17877. /**
  17878. * @private
  17879. */
  17880. protected _meshBones: Array<Bone>;
  17881. /**
  17882. * @inheritDoc
  17883. */
  17884. protected _onClear(): void;
  17885. /**
  17886. * @private
  17887. */
  17888. protected abstract _initDisplay(value: any): void;
  17889. /**
  17890. * @private
  17891. */
  17892. protected abstract _disposeDisplay(value: any): void;
  17893. /**
  17894. * @private
  17895. */
  17896. protected abstract _onUpdateDisplay(): void;
  17897. /**
  17898. * @private
  17899. */
  17900. protected abstract _addDisplay(): void;
  17901. /**
  17902. * @private
  17903. */
  17904. protected abstract _replaceDisplay(value: any): void;
  17905. /**
  17906. * @private
  17907. */
  17908. protected abstract _removeDisplay(): void;
  17909. /**
  17910. * @private
  17911. */
  17912. protected abstract _updateZOrder(): void;
  17913. /**
  17914. * @private
  17915. */
  17916. protected abstract _updateBlendMode(): void;
  17917. /**
  17918. * @private
  17919. */
  17920. protected abstract _updateColor(): void;
  17921. /**
  17922. * @private
  17923. */
  17924. protected abstract _updateFilters(): void;
  17925. /**
  17926. * @private
  17927. */
  17928. protected abstract _updateFrame(): void;
  17929. /**
  17930. * @private
  17931. */
  17932. protected abstract _updateMesh(): void;
  17933. /**
  17934. * @private
  17935. */
  17936. protected abstract _updateTransform(): void;
  17937. private _isMeshBonesUpdate();
  17938. /**
  17939. * @private
  17940. */
  17941. protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void;
  17942. /**
  17943. * @private
  17944. */
  17945. protected _updateDisplay(): void;
  17946. /**
  17947. * @private
  17948. */
  17949. protected _updateLocalTransformMatrix(): void;
  17950. /**
  17951. * @private
  17952. */
  17953. protected _updateGlobalTransformMatrix(): void;
  17954. /**
  17955. * @private Factory
  17956. */
  17957. _setDisplayList(value: Array<any>): boolean;
  17958. /**
  17959. * @language zh_CN
  17960. * 在下一帧更新显示对象的状态。
  17961. * @version DragonBones 4.5
  17962. */
  17963. invalidUpdate(): void;
  17964. /**
  17965. * @private
  17966. */
  17967. rawDisplay: any;
  17968. /**
  17969. * @private
  17970. */
  17971. MeshDisplay: any;
  17972. /**
  17973. * @language zh_CN
  17974. * 此时显示的显示对象在显示列表中的索引。
  17975. * @version DragonBones 4.5
  17976. */
  17977. displayIndex: number;
  17978. /**
  17979. * @language zh_CN
  17980. * 包含显示对象或子骨架的显示列表。
  17981. * @version DragonBones 3.0
  17982. */
  17983. displayList: Array<any>;
  17984. /**
  17985. * @language zh_CN
  17986. * 此时显示的显示对象。
  17987. * @version DragonBones 3.0
  17988. */
  17989. display: any;
  17990. /**
  17991. * @language zh_CN
  17992. * 此时显示的子骨架。
  17993. * @see dragonBones.Armature
  17994. * @version DragonBones 3.0
  17995. */
  17996. childArmature: Armature;
  17997. /**
  17998. * @deprecated
  17999. * @see #display
  18000. */
  18001. getDisplay(): any;
  18002. /**
  18003. * @deprecated
  18004. * @see #display
  18005. */
  18006. setDisplay(value: any): void;
  18007. }
  18008. }
  18009. declare namespace dragonBones {
  18010. /**
  18011. * @private
  18012. */
  18013. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  18014. /**
  18015. * @language zh_CN
  18016. * 事件接口。
  18017. * @version DragonBones 4.5
  18018. */
  18019. interface IEventDispatcher {
  18020. /**
  18021. * @language zh_CN
  18022. * 是否包含指定类型的事件。
  18023. * @param type 事件类型。
  18024. * @returns [true: 包含, false: 不包含]
  18025. * @version DragonBones 4.5
  18026. */
  18027. hasEvent(type: EventStringType): boolean;
  18028. /**
  18029. * @language zh_CN
  18030. * 添加事件。
  18031. * @param type 事件类型。
  18032. * @param listener 事件回调。
  18033. * @version DragonBones 4.5
  18034. */
  18035. addEvent(type: EventStringType, listener: Function, target: any): void;
  18036. /**
  18037. * @language zh_CN
  18038. * 移除事件。
  18039. * @param type 事件类型。
  18040. * @param listener 事件回调。
  18041. * @version DragonBones 4.5
  18042. */
  18043. removeEvent(type: EventStringType, listener: Function, target: any): void;
  18044. }
  18045. /**
  18046. * @language zh_CN
  18047. * 事件数据。
  18048. * @version DragonBones 4.5
  18049. */
  18050. class EventObject extends BaseObject {
  18051. /**
  18052. * @language zh_CN
  18053. * 动画开始。
  18054. * @version DragonBones 4.5
  18055. */
  18056. static START: string;
  18057. /**
  18058. * @language zh_CN
  18059. * 动画循环播放一次完成。
  18060. * @version DragonBones 4.5
  18061. */
  18062. static LOOP_COMPLETE: string;
  18063. /**
  18064. * @language zh_CN
  18065. * 动画播放完成。
  18066. * @version DragonBones 4.5
  18067. */
  18068. static COMPLETE: string;
  18069. /**
  18070. * @language zh_CN
  18071. * 动画淡入开始。
  18072. * @version DragonBones 4.5
  18073. */
  18074. static FADE_IN: string;
  18075. /**
  18076. * @language zh_CN
  18077. * 动画淡入完成。
  18078. * @version DragonBones 4.5
  18079. */
  18080. static FADE_IN_COMPLETE: string;
  18081. /**
  18082. * @language zh_CN
  18083. * 动画淡出开始。
  18084. * @version DragonBones 4.5
  18085. */
  18086. static FADE_OUT: string;
  18087. /**
  18088. * @language zh_CN
  18089. * 动画淡出完成。
  18090. * @version DragonBones 4.5
  18091. */
  18092. static FADE_OUT_COMPLETE: string;
  18093. /**
  18094. * @language zh_CN
  18095. * 动画帧事件。
  18096. * @version DragonBones 4.5
  18097. */
  18098. static FRAME_EVENT: string;
  18099. /**
  18100. * @language zh_CN
  18101. * 动画声音事件。
  18102. * @version DragonBones 4.5
  18103. */
  18104. static SOUND_EVENT: string;
  18105. /**
  18106. * @private
  18107. */
  18108. static toString(): string;
  18109. /**
  18110. * @language zh_CN
  18111. * 事件类型。
  18112. * @version DragonBones 4.5
  18113. */
  18114. type: EventStringType;
  18115. /**
  18116. * @language zh_CN
  18117. * 事件名称。 (帧标签的名称或声音的名称)
  18118. * @version DragonBones 4.5
  18119. */
  18120. name: string;
  18121. /**
  18122. * @language zh_CN
  18123. * 扩展的数据。
  18124. * @version DragonBones 4.5
  18125. */
  18126. data: any;
  18127. /**
  18128. * @language zh_CN
  18129. * 发出事件的骨架。
  18130. * @version DragonBones 4.5
  18131. */
  18132. armature: Armature;
  18133. /**
  18134. * @language zh_CN
  18135. * 发出事件的骨骼。
  18136. * @version DragonBones 4.5
  18137. */
  18138. bone: Bone;
  18139. /**
  18140. * @language zh_CN
  18141. * 发出事件的插槽。
  18142. * @version DragonBones 4.5
  18143. */
  18144. slot: Slot;
  18145. /**
  18146. * @language zh_CN
  18147. * 发出事件的动画状态。
  18148. * @version DragonBones 4.5
  18149. */
  18150. animationState: AnimationState;
  18151. /**
  18152. * @private
  18153. */
  18154. frame: AnimationFrameData;
  18155. /**
  18156. * @language zh_CN
  18157. * 用户数据。
  18158. * @version DragonBones 4.5
  18159. */
  18160. userData: any;
  18161. /**
  18162. * @inheritDoc
  18163. */
  18164. protected _onClear(): void;
  18165. }
  18166. }
  18167. declare namespace dragonBones {
  18168. /**
  18169. * @private
  18170. */
  18171. class ColorTransform {
  18172. alphaMultiplier: number;
  18173. redMultiplier: number;
  18174. greenMultiplier: number;
  18175. blueMultiplier: number;
  18176. alphaOffset: number;
  18177. redOffset: number;
  18178. greenOffset: number;
  18179. blueOffset: number;
  18180. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  18181. copyFrom(value: ColorTransform): void;
  18182. identity(): void;
  18183. }
  18184. }
  18185. declare namespace dragonBones {
  18186. /**
  18187. * @language zh_CN
  18188. * 2D 矩阵。
  18189. * @version DragonBones 3.0
  18190. */
  18191. class Matrix {
  18192. a: number;
  18193. b: number;
  18194. c: number;
  18195. d: number;
  18196. tx: number;
  18197. ty: number;
  18198. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  18199. /**
  18200. * @private
  18201. */
  18202. toString(): string;
  18203. /**
  18204. * @language zh_CN
  18205. * 复制矩阵。
  18206. * @param value 需要复制的矩阵。
  18207. * @version DragonBones 3.0
  18208. */
  18209. copyFrom(value: Matrix): void;
  18210. /**
  18211. * @language zh_CN
  18212. * 转换为恒等矩阵。
  18213. * @version DragonBones 3.0
  18214. */
  18215. identity(): void;
  18216. /**
  18217. * @language zh_CN
  18218. * 将当前矩阵与另一个矩阵相乘。
  18219. * @param value 需要相乘的矩阵。
  18220. * @version DragonBones 3.0
  18221. */
  18222. concat(value: Matrix): void;
  18223. /**
  18224. * @language zh_CN
  18225. * 转换为逆矩阵。
  18226. * @version DragonBones 3.0
  18227. */
  18228. invert(): void;
  18229. /**
  18230. * @language zh_CN
  18231. * 将矩阵转换应用于指定点。
  18232. * @param x 横坐标。
  18233. * @param y 纵坐标。
  18234. * @param result 应用转换之后的坐标。
  18235. * @params delta 是否忽略 tx,ty 对坐标的转换。
  18236. * @version DragonBones 3.0
  18237. */
  18238. transformPoint(x: number, y: number, result: {
  18239. x: number;
  18240. y: number;
  18241. }, delta?: boolean): void;
  18242. }
  18243. }
  18244. declare namespace dragonBones {
  18245. /**
  18246. * @private
  18247. */
  18248. class Point {
  18249. x: number;
  18250. y: number;
  18251. constructor(x?: number, y?: number);
  18252. copyFrom(value: Point): void;
  18253. clear(): void;
  18254. }
  18255. }
  18256. declare namespace dragonBones {
  18257. /**
  18258. * @private
  18259. */
  18260. class Rectangle {
  18261. x: number;
  18262. y: number;
  18263. width: number;
  18264. height: number;
  18265. constructor(x?: number, y?: number, width?: number, height?: number);
  18266. copyFrom(value: Rectangle): void;
  18267. clear(): void;
  18268. }
  18269. }
  18270. declare namespace dragonBones {
  18271. /**
  18272. * @language zh_CN
  18273. * 2D 变换。
  18274. * @version DragonBones 3.0
  18275. */
  18276. class Transform {
  18277. /**
  18278. * @language zh_CN
  18279. * 水平位移。
  18280. * @version DragonBones 3.0
  18281. */
  18282. x: number;
  18283. /**
  18284. * @language zh_CN
  18285. * 垂直位移。
  18286. * @version DragonBones 3.0
  18287. */
  18288. y: number;
  18289. /**
  18290. * @language zh_CN
  18291. * 水平倾斜。 (以弧度为单位)
  18292. * @version DragonBones 3.0
  18293. */
  18294. skewX: number;
  18295. /**
  18296. * @language zh_CN
  18297. * 垂直倾斜。 (以弧度为单位)
  18298. * @version DragonBones 3.0
  18299. */
  18300. skewY: number;
  18301. /**
  18302. * @language zh_CN
  18303. * 水平缩放。
  18304. * @version DragonBones 3.0
  18305. */
  18306. scaleX: number;
  18307. /**
  18308. * @language zh_CN
  18309. * 垂直缩放。
  18310. * @version DragonBones 3.0
  18311. */
  18312. scaleY: number;
  18313. /**
  18314. * @private
  18315. */
  18316. static normalizeRadian(value: number): number;
  18317. /**
  18318. * @private
  18319. */
  18320. constructor(
  18321. /**
  18322. * @language zh_CN
  18323. * 水平位移。
  18324. * @version DragonBones 3.0
  18325. */
  18326. x?: number,
  18327. /**
  18328. * @language zh_CN
  18329. * 垂直位移。
  18330. * @version DragonBones 3.0
  18331. */
  18332. y?: number,
  18333. /**
  18334. * @language zh_CN
  18335. * 水平倾斜。 (以弧度为单位)
  18336. * @version DragonBones 3.0
  18337. */
  18338. skewX?: number,
  18339. /**
  18340. * @language zh_CN
  18341. * 垂直倾斜。 (以弧度为单位)
  18342. * @version DragonBones 3.0
  18343. */
  18344. skewY?: number,
  18345. /**
  18346. * @language zh_CN
  18347. * 水平缩放。
  18348. * @version DragonBones 3.0
  18349. */
  18350. scaleX?: number,
  18351. /**
  18352. * @language zh_CN
  18353. * 垂直缩放。
  18354. * @version DragonBones 3.0
  18355. */
  18356. scaleY?: number);
  18357. /**
  18358. * @private
  18359. */
  18360. toString(): string;
  18361. /**
  18362. * @private
  18363. */
  18364. copyFrom(value: Transform): Transform;
  18365. /**
  18366. * @private
  18367. */
  18368. identity(): Transform;
  18369. /**
  18370. * @private
  18371. */
  18372. add(value: Transform): Transform;
  18373. /**
  18374. * @private
  18375. */
  18376. minus(value: Transform): Transform;
  18377. /**
  18378. * @private
  18379. */
  18380. fromMatrix(matrix: Matrix): Transform;
  18381. /**
  18382. * @language zh_CN
  18383. * 转换为矩阵。
  18384. * @param 矩阵。
  18385. * @version DragonBones 3.0
  18386. */
  18387. toMatrix(matrix: Matrix): Transform;
  18388. /**
  18389. * @language zh_CN
  18390. * 旋转。 (以弧度为单位)
  18391. * @version DragonBones 3.0
  18392. */
  18393. rotation: number;
  18394. }
  18395. }
  18396. declare namespace dragonBones {
  18397. /**
  18398. * @private
  18399. */
  18400. abstract class TimelineData<T extends FrameData<T>> extends BaseObject {
  18401. /**
  18402. * @private
  18403. */
  18404. static toString(): string;
  18405. scale: number;
  18406. /**
  18407. * @private
  18408. */
  18409. offset: number;
  18410. /**
  18411. * @private
  18412. */
  18413. frames: Array<T>;
  18414. constructor();
  18415. /**
  18416. * @inheritDoc
  18417. */
  18418. protected _onClear(): void;
  18419. }
  18420. /**
  18421. * @private
  18422. */
  18423. class ZOrderTimelineData extends TimelineData<ZOrderFrameData> {
  18424. static toString(): string;
  18425. }
  18426. /**
  18427. * @private
  18428. */
  18429. class BoneTimelineData extends TimelineData<BoneFrameData> {
  18430. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18431. static toString(): string;
  18432. bone: BoneData;
  18433. originalTransform: Transform;
  18434. cachedFrames: Array<Matrix>;
  18435. constructor();
  18436. /**
  18437. * @inheritDoc
  18438. */
  18439. protected _onClear(): void;
  18440. cacheFrames(cacheFrameCount: number): void;
  18441. }
  18442. /**
  18443. * @private
  18444. */
  18445. class SlotTimelineData extends TimelineData<SlotFrameData> {
  18446. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18447. static toString(): string;
  18448. slot: SlotData;
  18449. cachedFrames: Array<Matrix>;
  18450. constructor();
  18451. /**
  18452. * @inheritDoc
  18453. */
  18454. protected _onClear(): void;
  18455. cacheFrames(cacheFrameCount: number): void;
  18456. }
  18457. /**
  18458. * @private
  18459. */
  18460. class FFDTimelineData extends TimelineData<ExtensionFrameData> {
  18461. static toString(): string;
  18462. displayIndex: number;
  18463. skin: SkinData;
  18464. slot: SlotDisplayDataSet;
  18465. constructor();
  18466. /**
  18467. * @inheritDoc
  18468. */
  18469. protected _onClear(): void;
  18470. }
  18471. }
  18472. declare namespace dragonBones {
  18473. /**
  18474. * @language zh_CN
  18475. * 动画数据。
  18476. * @version DragonBones 3.0
  18477. */
  18478. class AnimationData extends TimelineData<AnimationFrameData> {
  18479. /**
  18480. * @private
  18481. */
  18482. static toString(): string;
  18483. /**
  18484. * @private
  18485. */
  18486. hasAsynchronyTimeline: boolean;
  18487. /**
  18488. * @language zh_CN
  18489. * 持续的帧数。
  18490. * @version DragonBones 3.0
  18491. */
  18492. frameCount: number;
  18493. /**
  18494. * @language zh_CN
  18495. * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  18496. * @version DragonBones 3.0
  18497. */
  18498. playTimes: number;
  18499. /**
  18500. * @language zh_CN
  18501. * 开始的时间。 (以秒为单位)
  18502. * @version DragonBones 3.0
  18503. */
  18504. position: number;
  18505. /**
  18506. * @language zh_CN
  18507. * 持续的时间。 (以秒为单位)
  18508. * @version DragonBones 3.0
  18509. */
  18510. duration: number;
  18511. /**
  18512. * @language zh_CN
  18513. * 淡入混合的时间。 (以秒为单位)
  18514. * @version DragonBones 3.0
  18515. */
  18516. fadeInTime: number;
  18517. /**
  18518. * @private
  18519. */
  18520. cacheTimeToFrameScale: number;
  18521. /**
  18522. * @language zh_CN
  18523. * 数据名称。
  18524. * @version DragonBones 3.0
  18525. */
  18526. name: string;
  18527. /**
  18528. * @private
  18529. */
  18530. animation: AnimationData;
  18531. /**
  18532. * @private
  18533. */
  18534. zOrderTimeline: TimelineData<ZOrderFrameData>;
  18535. /**
  18536. * @private
  18537. */
  18538. boneTimelines: Map<BoneTimelineData>;
  18539. /**
  18540. * @private
  18541. */
  18542. slotTimelines: Map<SlotTimelineData>;
  18543. /**
  18544. * @private
  18545. */
  18546. ffdTimelines: Map<Map<Map<FFDTimelineData>>>;
  18547. /**
  18548. * @private
  18549. */
  18550. cachedFrames: Array<boolean>;
  18551. /**
  18552. * @private
  18553. */
  18554. constructor();
  18555. /**
  18556. * @inheritDoc
  18557. */
  18558. protected _onClear(): void;
  18559. /**
  18560. * @private
  18561. */
  18562. cacheFrames(value: number): void;
  18563. /**
  18564. * @private
  18565. */
  18566. addBoneTimeline(value: BoneTimelineData): void;
  18567. /**
  18568. * @private
  18569. */
  18570. addSlotTimeline(value: SlotTimelineData): void;
  18571. /**
  18572. * @private
  18573. */
  18574. addFFDTimeline(value: FFDTimelineData): void;
  18575. /**
  18576. * @private
  18577. */
  18578. getBoneTimeline(name: string): BoneTimelineData;
  18579. /**
  18580. * @private
  18581. */
  18582. getSlotTimeline(name: string): SlotTimelineData;
  18583. /**
  18584. * @private
  18585. */
  18586. getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData;
  18587. }
  18588. }
  18589. declare namespace dragonBones {
  18590. /**
  18591. * @language zh_CN
  18592. * 骨架数据。
  18593. * @see dragonBones.Armature
  18594. * @version DragonBones 3.0
  18595. */
  18596. class ArmatureData extends BaseObject {
  18597. private static _onSortSlots(a, b);
  18598. /**
  18599. * @private
  18600. */
  18601. static toString(): string;
  18602. /**
  18603. * @language zh_CN
  18604. * 动画帧率。
  18605. * @version DragonBones 3.0
  18606. */
  18607. frameRate: number;
  18608. /**
  18609. * @language zh_CN
  18610. * 骨架类型。
  18611. * @see dragonBones.ArmatureType
  18612. * @version DragonBones 3.0
  18613. */
  18614. type: ArmatureType;
  18615. /**
  18616. * @language zh_CN
  18617. * 数据名称。
  18618. * @version DragonBones 3.0
  18619. */
  18620. name: string;
  18621. /**
  18622. * @private
  18623. */
  18624. parent: DragonBonesData;
  18625. /**
  18626. * @private
  18627. */
  18628. userData: any;
  18629. /**
  18630. * @private
  18631. */
  18632. aabb: Rectangle;
  18633. /**
  18634. * @language zh_CN
  18635. * 所有的骨骼数据。
  18636. * @see dragonBones.BoneData
  18637. * @version DragonBones 3.0
  18638. */
  18639. bones: Map<BoneData>;
  18640. /**
  18641. * @language zh_CN
  18642. * 所有的插槽数据。
  18643. * @see dragonBones.SlotData
  18644. * @version DragonBones 3.0
  18645. */
  18646. slots: Map<SlotData>;
  18647. /**
  18648. * @language zh_CN
  18649. * 所有的皮肤数据。
  18650. * @see dragonBones.SkinData
  18651. * @version DragonBones 3.0
  18652. */
  18653. skins: Map<SkinData>;
  18654. /**
  18655. * @language zh_CN
  18656. * 所有的动画数据。
  18657. * @see dragonBones.AnimationData
  18658. * @version DragonBones 3.0
  18659. */
  18660. animations: Map<AnimationData>;
  18661. /**
  18662. * @private
  18663. */
  18664. actions: Array<ActionData>;
  18665. /**
  18666. * @private
  18667. */
  18668. cacheFrameRate: number;
  18669. /**
  18670. * @private
  18671. */
  18672. scale: number;
  18673. private _boneDirty;
  18674. private _slotDirty;
  18675. private _defaultSkin;
  18676. private _defaultAnimation;
  18677. private _sortedBones;
  18678. private _sortedSlots;
  18679. private _bonesChildren;
  18680. /**
  18681. * @private
  18682. */
  18683. constructor();
  18684. /**
  18685. * @inheritDoc
  18686. */
  18687. protected _onClear(): void;
  18688. private _sortBones();
  18689. private _sortSlots();
  18690. /**
  18691. * @private
  18692. */
  18693. cacheFrames(value: number): void;
  18694. /**
  18695. * @private
  18696. */
  18697. addBone(value: BoneData, parentName: string): void;
  18698. /**
  18699. * @private
  18700. */
  18701. addSlot(value: SlotData): void;
  18702. /**
  18703. * @private
  18704. */
  18705. addSkin(value: SkinData): void;
  18706. /**
  18707. * @private
  18708. */
  18709. addAnimation(value: AnimationData): void;
  18710. /**
  18711. * @language zh_CN
  18712. * 获取指定名称的骨骼数据。
  18713. * @param name 骨骼数据名称。
  18714. * @see dragonBones.BoneData
  18715. * @version DragonBones 3.0
  18716. */
  18717. getBone(name: string): BoneData;
  18718. /**
  18719. * @language zh_CN
  18720. * 获取指定名称的插槽数据。
  18721. * @param name 插槽数据名称。
  18722. * @see dragonBones.SlotData
  18723. * @version DragonBones 3.0
  18724. */
  18725. getSlot(name: string): SlotData;
  18726. /**
  18727. * @language zh_CN
  18728. * 获取指定名称的皮肤数据。
  18729. * @param name 皮肤数据名称。
  18730. * @see dragonBones.SkinData
  18731. * @version DragonBones 3.0
  18732. */
  18733. getSkin(name: string): SkinData;
  18734. /**
  18735. * @language zh_CN
  18736. * 获取指定名称的动画数据。
  18737. * @param name 动画数据名称。
  18738. * @see dragonBones.AnimationData
  18739. * @version DragonBones 3.0
  18740. */
  18741. getAnimation(name: string): AnimationData;
  18742. /**
  18743. * @private
  18744. */
  18745. sortedBones: Array<BoneData>;
  18746. /**
  18747. * @private
  18748. */
  18749. sortedSlots: Array<SlotData>;
  18750. /**
  18751. * @language zh_CN
  18752. * 获取默认的皮肤数据。
  18753. * @see dragonBones.SkinData
  18754. * @version DragonBones 4.5
  18755. */
  18756. defaultSkin: SkinData;
  18757. /**
  18758. * @language zh_CN
  18759. * 获取默认的动画数据。
  18760. * @see dragonBones.AnimationData
  18761. * @version DragonBones 4.5
  18762. */
  18763. defaultAnimation: AnimationData;
  18764. }
  18765. /**
  18766. * @language zh_CN
  18767. * 骨骼数据。
  18768. * @see dragonBones.Bone
  18769. * @version DragonBones 3.0
  18770. */
  18771. class BoneData extends BaseObject {
  18772. /**
  18773. * @private
  18774. */
  18775. static toString(): string;
  18776. /**
  18777. * @private
  18778. */
  18779. inheritTranslation: boolean;
  18780. /**
  18781. * @private
  18782. */
  18783. inheritRotation: boolean;
  18784. /**
  18785. * @private
  18786. */
  18787. inheritScale: boolean;
  18788. /**
  18789. * @private
  18790. */
  18791. bendPositive: boolean;
  18792. /**
  18793. * @private
  18794. */
  18795. chain: number;
  18796. /**
  18797. * @private
  18798. */
  18799. chainIndex: number;
  18800. /**
  18801. * @private
  18802. */
  18803. weight: number;
  18804. /**
  18805. * @private
  18806. */
  18807. length: number;
  18808. /**
  18809. * @language zh_CN
  18810. * 数据名称。
  18811. * @version DragonBones 3.0
  18812. */
  18813. name: string;
  18814. /**
  18815. * @language zh_CN
  18816. * 所属的父骨骼数据。
  18817. * @version DragonBones 3.0
  18818. */
  18819. parent: BoneData;
  18820. /**
  18821. * @private
  18822. */
  18823. ik: BoneData;
  18824. /**
  18825. * @private
  18826. */
  18827. transform: Transform;
  18828. /**
  18829. * @private
  18830. */
  18831. constructor();
  18832. /**
  18833. * @inheritDoc
  18834. */
  18835. protected _onClear(): void;
  18836. }
  18837. /**
  18838. * @language zh_CN
  18839. * 插槽数据。
  18840. * @see dragonBones.Slot
  18841. * @version DragonBones 3.0
  18842. */
  18843. class SlotData extends BaseObject {
  18844. /**
  18845. * @private
  18846. */
  18847. static DEFAULT_COLOR: ColorTransform;
  18848. /**
  18849. * @private
  18850. */
  18851. static generateColor(): ColorTransform;
  18852. /**
  18853. * @private
  18854. */
  18855. static toString(): string;
  18856. /**
  18857. * @private
  18858. */
  18859. displayIndex: number;
  18860. /**
  18861. * @private
  18862. */
  18863. zOrder: number;
  18864. /**
  18865. * @private
  18866. */
  18867. blendMode: BlendMode;
  18868. /**
  18869. * @language zh_CN
  18870. * 数据名称。
  18871. * @version DragonBones 3.0
  18872. */
  18873. name: string;
  18874. /**
  18875. * @language zh_CN
  18876. * 所属的父骨骼数据。
  18877. * @see dragonBones.BoneData
  18878. * @version DragonBones 3.0
  18879. */
  18880. parent: BoneData;
  18881. /**
  18882. * @private
  18883. */
  18884. color: ColorTransform;
  18885. /**
  18886. * @private
  18887. */
  18888. actions: Array<ActionData>;
  18889. /**
  18890. * @private
  18891. */
  18892. constructor();
  18893. /**
  18894. * @inheritDoc
  18895. */
  18896. protected _onClear(): void;
  18897. }
  18898. /**
  18899. * @language zh_CN
  18900. * 皮肤数据。
  18901. * @version DragonBones 3.0
  18902. */
  18903. class SkinData extends BaseObject {
  18904. /**
  18905. * @private
  18906. */
  18907. static toString(): string;
  18908. /**
  18909. * @language zh_CN
  18910. * 数据名称。
  18911. * @version DragonBones 3.0
  18912. */
  18913. name: string;
  18914. /**
  18915. * @private
  18916. */
  18917. slots: Map<SlotDisplayDataSet>;
  18918. /**
  18919. * @private
  18920. */
  18921. constructor();
  18922. /**
  18923. * @inheritDoc
  18924. */
  18925. protected _onClear(): void;
  18926. /**
  18927. * @private
  18928. */
  18929. addSlot(value: SlotDisplayDataSet): void;
  18930. /**
  18931. * @private
  18932. */
  18933. getSlot(name: string): SlotDisplayDataSet;
  18934. }
  18935. /**
  18936. * @private
  18937. */
  18938. class SlotDisplayDataSet extends BaseObject {
  18939. static toString(): string;
  18940. slot: SlotData;
  18941. displays: Array<DisplayData>;
  18942. constructor();
  18943. /**
  18944. * @inheritDoc
  18945. */
  18946. protected _onClear(): void;
  18947. }
  18948. /**
  18949. * @private
  18950. */
  18951. class DisplayData extends BaseObject {
  18952. static toString(): string;
  18953. isRelativePivot: boolean;
  18954. type: DisplayType;
  18955. name: string;
  18956. texture: TextureData;
  18957. armature: ArmatureData;
  18958. mesh: MeshData;
  18959. pivot: Point;
  18960. transform: Transform;
  18961. constructor();
  18962. /**
  18963. * @inheritDoc
  18964. */
  18965. protected _onClear(): void;
  18966. }
  18967. /**
  18968. * @private
  18969. */
  18970. class MeshData extends BaseObject {
  18971. static toString(): string;
  18972. skinned: boolean;
  18973. slotPose: Matrix;
  18974. uvs: Array<number>;
  18975. vertices: Array<number>;
  18976. vertexIndices: Array<number>;
  18977. boneIndices: Array<Array<number>>;
  18978. weights: Array<Array<number>>;
  18979. boneVertices: Array<Array<number>>;
  18980. bones: Array<BoneData>;
  18981. inverseBindPose: Array<Matrix>;
  18982. constructor();
  18983. /**
  18984. * @inheritDoc
  18985. */
  18986. protected _onClear(): void;
  18987. }
  18988. }
  18989. declare namespace dragonBones {
  18990. /**
  18991. * @language zh_CN
  18992. * 龙骨数据,包含多个骨架数据。
  18993. * @see dragonBones.ArmatureData
  18994. * @version DragonBones 3.0
  18995. */
  18996. class DragonBonesData extends BaseObject {
  18997. /**
  18998. * @private
  18999. */
  19000. static toString(): string;
  19001. /**
  19002. * @language zh_CN
  19003. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19004. * @default false
  19005. * @see dragonBones.ArmatureData
  19006. * @version DragonBones 4.5
  19007. */
  19008. autoSearch: boolean;
  19009. /**
  19010. * @language zh_CN
  19011. * 动画帧频。
  19012. * @version DragonBones 3.0
  19013. */
  19014. frameRate: number;
  19015. /**
  19016. * @language zh_CN
  19017. * 数据名称。
  19018. * @version DragonBones 3.0
  19019. */
  19020. name: string;
  19021. /**
  19022. * @language zh_CN
  19023. * 所有的骨架数据。
  19024. * @see dragonBones.ArmatureData
  19025. * @version DragonBones 3.0
  19026. */
  19027. armatures: Map<ArmatureData>;
  19028. private _armatureNames;
  19029. /**
  19030. * @inheritDoc
  19031. */
  19032. protected _onClear(): void;
  19033. /**
  19034. * @language zh_CN
  19035. * 获取指定名称的骨架。
  19036. * @param name 骨架数据骨架名称。
  19037. * @see dragonBones.ArmatureData
  19038. * @version DragonBones 3.0
  19039. */
  19040. getArmature(name: string): ArmatureData;
  19041. /**
  19042. * @language zh_CN
  19043. * 所有的骨架数据名称。
  19044. * @see #armatures
  19045. * @version DragonBones 3.0
  19046. */
  19047. armatureNames: Array<string>;
  19048. /**
  19049. * @deprecated
  19050. * @see dragonBones.BaseFactory#removeDragonBonesData()
  19051. */
  19052. dispose(): void;
  19053. }
  19054. }
  19055. declare namespace dragonBones {
  19056. /**
  19057. * @private
  19058. */
  19059. class ActionData extends BaseObject {
  19060. static toString(): string;
  19061. type: ActionType;
  19062. bone: BoneData;
  19063. slot: SlotData;
  19064. data: Array<any>;
  19065. constructor();
  19066. protected _onClear(): void;
  19067. }
  19068. /**
  19069. * @private
  19070. */
  19071. class EventData extends BaseObject {
  19072. static toString(): string;
  19073. type: EventType;
  19074. name: string;
  19075. data: any;
  19076. bone: BoneData;
  19077. slot: SlotData;
  19078. constructor();
  19079. protected _onClear(): void;
  19080. }
  19081. /**
  19082. * @private
  19083. */
  19084. abstract class FrameData<T> extends BaseObject {
  19085. position: number;
  19086. duration: number;
  19087. prev: T;
  19088. next: T;
  19089. constructor();
  19090. /**
  19091. * @inheritDoc
  19092. */
  19093. protected _onClear(): void;
  19094. }
  19095. /**
  19096. * @private
  19097. */
  19098. abstract class TweenFrameData<T> extends FrameData<T> {
  19099. static samplingCurve(curve: Array<number>, frameCount: number): Array<number>;
  19100. tweenEasing: number;
  19101. curve: Array<number>;
  19102. constructor();
  19103. /**
  19104. * @inheritDoc
  19105. */
  19106. protected _onClear(): void;
  19107. }
  19108. /**
  19109. * @private
  19110. */
  19111. class AnimationFrameData extends FrameData<AnimationFrameData> {
  19112. static toString(): string;
  19113. actions: Array<ActionData>;
  19114. events: Array<EventData>;
  19115. constructor();
  19116. /**
  19117. * @inheritDoc
  19118. */
  19119. protected _onClear(): void;
  19120. }
  19121. /**
  19122. * @private
  19123. */
  19124. class ZOrderFrameData extends FrameData<ZOrderFrameData> {
  19125. zOrder: Array<number>;
  19126. constructor();
  19127. /**
  19128. * @inheritDoc
  19129. */
  19130. protected _onClear(): void;
  19131. }
  19132. /**
  19133. * @private
  19134. */
  19135. class BoneFrameData extends TweenFrameData<BoneFrameData> {
  19136. static toString(): string;
  19137. tweenScale: boolean;
  19138. tweenRotate: number;
  19139. guideCurve: Array<number>;
  19140. transform: Transform;
  19141. constructor();
  19142. /**
  19143. * @inheritDoc
  19144. */
  19145. protected _onClear(): void;
  19146. }
  19147. /**
  19148. * @private
  19149. */
  19150. class SlotFrameData extends TweenFrameData<SlotFrameData> {
  19151. static DEFAULT_COLOR: ColorTransform;
  19152. static generateColor(): ColorTransform;
  19153. static toString(): string;
  19154. displayIndex: number;
  19155. color: ColorTransform;
  19156. constructor();
  19157. /**
  19158. * @inheritDoc
  19159. */
  19160. protected _onClear(): void;
  19161. }
  19162. /**
  19163. * @private
  19164. */
  19165. class ExtensionFrameData extends TweenFrameData<ExtensionFrameData> {
  19166. static toString(): string;
  19167. type: ExtensionType;
  19168. tweens: Array<number>;
  19169. keys: Array<number>;
  19170. constructor();
  19171. /**
  19172. * @inheritDoc
  19173. */
  19174. protected _onClear(): void;
  19175. }
  19176. }
  19177. declare namespace dragonBones {
  19178. /**
  19179. * @private
  19180. */
  19181. abstract class DataParser {
  19182. protected static DATA_VERSION_2_3: string;
  19183. protected static DATA_VERSION_3_0: string;
  19184. protected static DATA_VERSION_4_0: string;
  19185. protected static DATA_VERSION: string;
  19186. protected static TEXTURE_ATLAS: string;
  19187. protected static SUB_TEXTURE: string;
  19188. protected static FORMAT: string;
  19189. protected static IMAGE_PATH: string;
  19190. protected static WIDTH: string;
  19191. protected static HEIGHT: string;
  19192. protected static ROTATED: string;
  19193. protected static FRAME_X: string;
  19194. protected static FRAME_Y: string;
  19195. protected static FRAME_WIDTH: string;
  19196. protected static FRAME_HEIGHT: string;
  19197. protected static DRADON_BONES: string;
  19198. protected static ARMATURE: string;
  19199. protected static BONE: string;
  19200. protected static IK: string;
  19201. protected static SLOT: string;
  19202. protected static SKIN: string;
  19203. protected static DISPLAY: string;
  19204. protected static ANIMATION: string;
  19205. protected static Z_ORDER: string;
  19206. protected static FFD: string;
  19207. protected static FRAME: string;
  19208. protected static PIVOT: string;
  19209. protected static TRANSFORM: string;
  19210. protected static AABB: string;
  19211. protected static COLOR: string;
  19212. protected static FILTER: string;
  19213. protected static VERSION: string;
  19214. protected static IS_GLOBAL: string;
  19215. protected static FRAME_RATE: string;
  19216. protected static TYPE: string;
  19217. protected static NAME: string;
  19218. protected static PARENT: string;
  19219. protected static LENGTH: string;
  19220. protected static DATA: string;
  19221. protected static DISPLAY_INDEX: string;
  19222. protected static BLEND_MODE: string;
  19223. protected static INHERIT_TRANSLATION: string;
  19224. protected static INHERIT_ROTATION: string;
  19225. protected static INHERIT_SCALE: string;
  19226. protected static TARGET: string;
  19227. protected static BEND_POSITIVE: string;
  19228. protected static CHAIN: string;
  19229. protected static WEIGHT: string;
  19230. protected static FADE_IN_TIME: string;
  19231. protected static PLAY_TIMES: string;
  19232. protected static SCALE: string;
  19233. protected static OFFSET: string;
  19234. protected static POSITION: string;
  19235. protected static DURATION: string;
  19236. protected static TWEEN_EASING: string;
  19237. protected static TWEEN_ROTATE: string;
  19238. protected static TWEEN_SCALE: string;
  19239. protected static CURVE: string;
  19240. protected static GUIDE_CURVE: string;
  19241. protected static EVENT: string;
  19242. protected static SOUND: string;
  19243. protected static ACTION: string;
  19244. protected static ACTIONS: string;
  19245. protected static DEFAULT_ACTIONS: string;
  19246. protected static X: string;
  19247. protected static Y: string;
  19248. protected static SKEW_X: string;
  19249. protected static SKEW_Y: string;
  19250. protected static SCALE_X: string;
  19251. protected static SCALE_Y: string;
  19252. protected static ALPHA_OFFSET: string;
  19253. protected static RED_OFFSET: string;
  19254. protected static GREEN_OFFSET: string;
  19255. protected static BLUE_OFFSET: string;
  19256. protected static ALPHA_MULTIPLIER: string;
  19257. protected static RED_MULTIPLIER: string;
  19258. protected static GREEN_MULTIPLIER: string;
  19259. protected static BLUE_MULTIPLIER: string;
  19260. protected static UVS: string;
  19261. protected static VERTICES: string;
  19262. protected static TRIANGLES: string;
  19263. protected static WEIGHTS: string;
  19264. protected static SLOT_POSE: string;
  19265. protected static BONE_POSE: string;
  19266. protected static TWEEN: string;
  19267. protected static KEY: string;
  19268. protected static COLOR_TRANSFORM: string;
  19269. protected static TIMELINE: string;
  19270. protected static PIVOT_X: string;
  19271. protected static PIVOT_Y: string;
  19272. protected static Z: string;
  19273. protected static LOOP: string;
  19274. protected static AUTO_TWEEN: string;
  19275. protected static HIDE: string;
  19276. protected static _getArmatureType(value: string): ArmatureType;
  19277. protected static _getDisplayType(value: string): DisplayType;
  19278. protected static _getBlendMode(value: string): BlendMode;
  19279. protected static _getActionType(value: string): ActionType;
  19280. protected _data: DragonBonesData;
  19281. protected _armature: ArmatureData;
  19282. protected _skin: SkinData;
  19283. protected _slotDisplayDataSet: SlotDisplayDataSet;
  19284. protected _mesh: MeshData;
  19285. protected _animation: AnimationData;
  19286. protected _timeline: any;
  19287. protected _isOldData: boolean;
  19288. protected _isGlobalTransform: boolean;
  19289. protected _isAutoTween: boolean;
  19290. protected _animationTweenEasing: number;
  19291. protected _timelinePivot: Point;
  19292. protected _helpPoint: Point;
  19293. protected _helpTransformA: Transform;
  19294. protected _helpTransformB: Transform;
  19295. protected _helpMatrix: Matrix;
  19296. protected _rawBones: Array<BoneData>;
  19297. constructor();
  19298. /**
  19299. * @private
  19300. */
  19301. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData;
  19302. /**
  19303. * @private
  19304. */
  19305. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void;
  19306. private _getTimelineFrameMatrix(animation, timeline, position, transform);
  19307. protected _globalToLocal(armature: ArmatureData): void;
  19308. protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array<ActionData>, events: Array<EventData>): void;
  19309. /**
  19310. * @deprecated
  19311. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19312. */
  19313. static parseDragonBonesData(rawData: any): DragonBonesData;
  19314. /**
  19315. * @deprecated
  19316. * @see dragonBones.BaseFactory#parsetTextureAtlasData()
  19317. */
  19318. static parseTextureAtlasData(rawData: any, scale?: number): any;
  19319. }
  19320. }
  19321. declare namespace dragonBones {
  19322. /**
  19323. * @private
  19324. */
  19325. class ObjectDataParser extends DataParser {
  19326. /**
  19327. * @private
  19328. */
  19329. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  19330. /**
  19331. * @private
  19332. */
  19333. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  19334. /**
  19335. * @private
  19336. */
  19337. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  19338. /**
  19339. * @private
  19340. */
  19341. protected static _getParameter(rawData: Array<any>, index: number, defaultValue: any): any;
  19342. /**
  19343. * @private
  19344. */
  19345. constructor();
  19346. /**
  19347. * @private
  19348. */
  19349. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  19350. /**
  19351. * @private
  19352. */
  19353. protected _parseBone(rawData: any): BoneData;
  19354. /**
  19355. * @private
  19356. */
  19357. protected _parseIK(rawData: any): void;
  19358. /**
  19359. * @private
  19360. */
  19361. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  19362. /**
  19363. * @private
  19364. */
  19365. protected _parseSkin(rawData: any): SkinData;
  19366. /**
  19367. * @private
  19368. */
  19369. protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet;
  19370. /**
  19371. * @private
  19372. */
  19373. protected _parseDisplay(rawData: any): DisplayData;
  19374. /**
  19375. * @private
  19376. */
  19377. protected _parseMesh(rawData: any): MeshData;
  19378. /**
  19379. * @private
  19380. */
  19381. protected _parseAnimation(rawData: any): AnimationData;
  19382. /**
  19383. * @private
  19384. */
  19385. protected _parseBoneTimeline(rawData: any): BoneTimelineData;
  19386. /**
  19387. * @private
  19388. */
  19389. protected _parseSlotTimeline(rawData: any): SlotTimelineData;
  19390. /**
  19391. * @private
  19392. */
  19393. protected _parseFFDTimeline(rawData: any): FFDTimelineData;
  19394. /**
  19395. * @private
  19396. */
  19397. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData;
  19398. /**
  19399. * @private
  19400. */
  19401. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData;
  19402. /**
  19403. * @private
  19404. */
  19405. protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData;
  19406. /**
  19407. * @private
  19408. */
  19409. protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData;
  19410. /**
  19411. * @private
  19412. */
  19413. protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData;
  19414. /**
  19415. * @private
  19416. */
  19417. protected _parseTweenFrame<T extends TweenFrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19418. /**
  19419. * @private
  19420. */
  19421. protected _parseFrame<T extends FrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19422. /**
  19423. * @private
  19424. */
  19425. protected _parseTimeline<T extends FrameData<T>>(rawData: Object, timeline: TimelineData<T>, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void;
  19426. /**
  19427. * @private
  19428. */
  19429. protected _parseActionData(rawData: any, actions: Array<ActionData>, bone: BoneData, slot: SlotData): void;
  19430. /**
  19431. * @private
  19432. */
  19433. protected _parseEventData(rawData: any, events: Array<EventData>, bone: BoneData, slot: SlotData): void;
  19434. /**
  19435. * @private
  19436. */
  19437. protected _parseTransform(rawData: Object, transform: Transform): void;
  19438. /**
  19439. * @private
  19440. */
  19441. protected _parseColorTransform(rawData: Object, color: ColorTransform): void;
  19442. /**
  19443. * @inheritDoc
  19444. */
  19445. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData;
  19446. /**
  19447. * @inheritDoc
  19448. */
  19449. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void;
  19450. /**
  19451. * @private
  19452. */
  19453. private static _instance;
  19454. /**
  19455. * @deprecated
  19456. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19457. */
  19458. static getInstance(): ObjectDataParser;
  19459. }
  19460. }
  19461. declare namespace dragonBones {
  19462. /**
  19463. * @language zh_CN
  19464. * 贴图集数据。
  19465. * @version DragonBones 3.0
  19466. */
  19467. abstract class TextureAtlasData extends BaseObject {
  19468. /**
  19469. * @language zh_CN
  19470. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19471. * @default false
  19472. * @version DragonBones 4.5
  19473. */
  19474. autoSearch: boolean;
  19475. /**
  19476. * @language zh_CN
  19477. * 贴图集缩放系数。
  19478. * @version DragonBones 3.0
  19479. */
  19480. scale: number;
  19481. /**
  19482. * @language zh_CN
  19483. * 贴图集名称。
  19484. * @version DragonBones 3.0
  19485. */
  19486. name: string;
  19487. /**
  19488. * @language zh_CN
  19489. * 贴图集图片路径。
  19490. * @version DragonBones 3.0
  19491. */
  19492. imagePath: string;
  19493. /**
  19494. * @inheritDoc
  19495. */
  19496. protected _onClear(): void;
  19497. /**
  19498. * @private
  19499. */
  19500. getTexture(name: string): TextureData;
  19501. }
  19502. /**
  19503. * @private
  19504. */
  19505. abstract class TextureData extends BaseObject {
  19506. static generateRectangle(): Rectangle;
  19507. rotated: boolean;
  19508. name: string;
  19509. frame: Rectangle;
  19510. parent: TextureAtlasData;
  19511. region: Rectangle;
  19512. constructor();
  19513. /**
  19514. * @inheritDoc
  19515. */
  19516. protected _onClear(): void;
  19517. }
  19518. }
  19519. declare namespace dragonBones {
  19520. /**
  19521. * @private
  19522. */
  19523. type BuildArmaturePackage = {
  19524. dataName?: string;
  19525. textureAtlasName?: string;
  19526. data?: DragonBonesData;
  19527. armature?: ArmatureData;
  19528. skin?: SkinData;
  19529. };
  19530. /**
  19531. * @language zh_CN
  19532. * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例)
  19533. * @see dragonBones.DragonBonesData
  19534. * @see dragonBones.TextureAtlasData
  19535. * @see dragonBones.ArmatureData
  19536. * @see dragonBones.Armature
  19537. * @version DragonBones 3.0
  19538. */
  19539. abstract class BaseFactory {
  19540. protected static _defaultParser: ObjectDataParser;
  19541. /**
  19542. * @language zh_CN
  19543. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19544. * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启)
  19545. * @see dragonBones.DragonBonesData#autoSearch
  19546. * @see dragonBones.TextureAtlasData#autoSearch
  19547. * @version DragonBones 4.5
  19548. */
  19549. autoSearch: boolean;
  19550. /**
  19551. * @private
  19552. */
  19553. protected _dataParser: DataParser;
  19554. /**
  19555. * @private
  19556. */
  19557. protected _dragonBonesDataMap: Map<DragonBonesData>;
  19558. /**
  19559. * @private
  19560. */
  19561. protected _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  19562. /**
  19563. * @private
  19564. */
  19565. constructor(dataParser?: DataParser);
  19566. /**
  19567. * @private
  19568. */
  19569. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData;
  19570. /**
  19571. * @private
  19572. */
  19573. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  19574. /**
  19575. * @private
  19576. */
  19577. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19578. /**
  19579. * @private
  19580. */
  19581. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  19582. /**
  19583. * @private
  19584. */
  19585. protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void;
  19586. /**
  19587. * @private
  19588. */
  19589. protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData;
  19590. /**
  19591. * @private
  19592. */
  19593. protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature;
  19594. /**
  19595. * @private
  19596. */
  19597. protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot;
  19598. /**
  19599. * @language zh_CN
  19600. * 解析并添加龙骨数据。
  19601. * @param rawData 需要解析的原始数据。 (JSON)
  19602. * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19603. * @returns DragonBonesData
  19604. * @see #getDragonBonesData()
  19605. * @see #addDragonBonesData()
  19606. * @see #removeDragonBonesData()
  19607. * @see dragonBones.DragonBonesData
  19608. * @version DragonBones 4.5
  19609. */
  19610. parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData;
  19611. /**
  19612. * @language zh_CN
  19613. * 解析并添加贴图集数据。
  19614. * @param rawData 需要解析的原始数据。 (JSON)
  19615. * @param textureAtlas 贴图集数据。 (JSON)
  19616. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19617. * @param scale 为贴图集设置一个缩放值。
  19618. * @returns 贴图集数据
  19619. * @see #getTextureAtlasData()
  19620. * @see #addTextureAtlasData()
  19621. * @see #removeTextureAtlasData()
  19622. * @see dragonBones.TextureAtlasData
  19623. * @version DragonBones 4.5
  19624. */
  19625. parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData;
  19626. /**
  19627. * @language zh_CN
  19628. * 获取指定名称的龙骨数据。
  19629. * @param name 数据名称。
  19630. * @returns DragonBonesData
  19631. * @see #parseDragonBonesData()
  19632. * @see #addDragonBonesData()
  19633. * @see #removeDragonBonesData()
  19634. * @see dragonBones.DragonBonesData
  19635. * @version DragonBones 3.0
  19636. */
  19637. getDragonBonesData(name: string): DragonBonesData;
  19638. /**
  19639. * @language zh_CN
  19640. * 添加龙骨数据。
  19641. * @param data 龙骨数据。
  19642. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19643. * @see #parseDragonBonesData()
  19644. * @see #getDragonBonesData()
  19645. * @see #removeDragonBonesData()
  19646. * @see dragonBones.DragonBonesData
  19647. * @version DragonBones 3.0
  19648. */
  19649. addDragonBonesData(data: DragonBonesData, name?: string): void;
  19650. /**
  19651. * @language zh_CN
  19652. * 移除龙骨数据。
  19653. * @param name 数据名称。
  19654. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19655. * @see #parseDragonBonesData()
  19656. * @see #getDragonBonesData()
  19657. * @see #addDragonBonesData()
  19658. * @see dragonBones.DragonBonesData
  19659. * @version DragonBones 3.0
  19660. */
  19661. removeDragonBonesData(name: string, disposeData?: boolean): void;
  19662. /**
  19663. * @language zh_CN
  19664. * 获取指定名称的贴图集数据列表。
  19665. * @param name 数据名称。
  19666. * @returns 贴图集数据列表。
  19667. * @see #parseTextureAtlasData()
  19668. * @see #addTextureAtlasData()
  19669. * @see #removeTextureAtlasData()
  19670. * @see dragonBones.textures.TextureAtlasData
  19671. * @version DragonBones 3.0
  19672. */
  19673. getTextureAtlasData(name: string): Array<TextureAtlasData>;
  19674. /**
  19675. * @language zh_CN
  19676. * 添加贴图集数据。
  19677. * @param data 贴图集数据。
  19678. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  19679. * @see #parseTextureAtlasData()
  19680. * @see #getTextureAtlasData()
  19681. * @see #removeTextureAtlasData()
  19682. * @see dragonBones.textures.TextureAtlasData
  19683. * @version DragonBones 3.0
  19684. */
  19685. addTextureAtlasData(data: TextureAtlasData, name?: string): void;
  19686. /**
  19687. * @language zh_CN
  19688. * 移除贴图集数据。
  19689. * @param name 数据名称。
  19690. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19691. * @see #parseTextureAtlasData()
  19692. * @see #getTextureAtlasData()
  19693. * @see #addTextureAtlasData()
  19694. * @see dragonBones.textures.TextureAtlasData
  19695. * @version DragonBones 3.0
  19696. */
  19697. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  19698. /**
  19699. * @language zh_CN
  19700. * 清除所有的数据。
  19701. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  19702. * @version DragonBones 4.5
  19703. */
  19704. clear(disposeData?: boolean): void;
  19705. /**
  19706. * @language zh_CN
  19707. * 创建一个指定名称的骨架。
  19708. * @param armatureName 骨架数据名称。
  19709. * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。
  19710. * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。
  19711. * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。
  19712. * @returns 骨架
  19713. * @see dragonBones.Armature
  19714. * @version DragonBones 3.0
  19715. */
  19716. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature;
  19717. /**
  19718. * @language zh_CN
  19719. * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构)
  19720. * @param toArmature 指定的骨架。
  19721. * @param fromArmatreName 其他骨架的名称。
  19722. * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。
  19723. * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。
  19724. * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除]
  19725. * @returns 是否替换成功。 [true: 成功, false: 不成功]
  19726. * @see dragonBones.Armature
  19727. * @version DragonBones 4.5
  19728. */
  19729. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean;
  19730. /**
  19731. * @language zh_CN
  19732. * 将指定插槽的显示对象替换为指定资源创造出的显示对象。
  19733. * @param dragonBonesName 指定的龙骨数据名称。
  19734. * @param armatureName 指定的骨架名称。
  19735. * @param slotName 指定的插槽名称。
  19736. * @param displayName 指定的显示对象名称。
  19737. * @param slot 指定的插槽实例。
  19738. * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
  19739. * @version DragonBones 4.5
  19740. */
  19741. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void;
  19742. /**
  19743. * @language zh_CN
  19744. * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。
  19745. * @param dragonBonesName 指定的 DragonBonesData 名称。
  19746. * @param armatureName 指定的骨架名称。
  19747. * @param slotName 指定的插槽名称。
  19748. * @param slot 指定的插槽实例。
  19749. * @version DragonBones 4.5
  19750. */
  19751. replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void;
  19752. /**
  19753. * @private
  19754. */
  19755. getAllDragonBonesData(): Map<DragonBonesData>;
  19756. /**
  19757. * @private
  19758. */
  19759. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  19760. }
  19761. }
  19762. declare let jsb: any;
  19763. /** Running in the editor. */
  19764. declare let CC_EDITOR: boolean;
  19765. /** Preview in browser or simulator. */
  19766. declare let CC_PREVIEW: boolean;
  19767. /** Running in the editor or preview. */
  19768. declare let CC_DEV: boolean;
  19769. /** Running in the editor or preview, or build in debug mode. */
  19770. declare let CC_DEBUG: boolean;
  19771. /** Running in published project. */
  19772. declare let CC_BUILD: boolean;
  19773. /** Running in native platform (mobile app, desktop app, or simulator). */
  19774. declare let CC_JSB: boolean;
  19775. /** Running in the engine's unit test. */
  19776. declare let CC_TEST: boolean;