creator.d.ts 695 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982
  1. /** !#en
  2. The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
  3. !#zh
  4. Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。 */
  5. declare module cc {
  6. /** The element contains the game canvas */
  7. export var container: HTMLDivElement;
  8. /**
  9. !#en Init Debug setting.
  10. !#zh 设置调试模式。
  11. @param mode mode
  12. */
  13. export function _initDebugSetting(mode: DebugMode): void;
  14. /**
  15. !#en
  16. Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
  17. - In Cocos Creator, error is red.<br/>
  18. - In Chrome, error have a red icon along with red message text.<br/>
  19. !#zh
  20. 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。<br/>
  21. - 在 Cocos Creator 中,错误信息显示是红色的。<br/>
  22. - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。<br/>
  23. @param msg A JavaScript string containing zero or more substitution strings.
  24. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  25. */
  26. export function error(msg: any, ...subst: any[]): void;
  27. /**
  28. !#en
  29. Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
  30. - In Cocos Creator, warning is yellow.
  31. - In Chrome, warning have a yellow warning icon with the message text.
  32. !#zh
  33. 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。<br/>
  34. - 在 Cocos Creator 中,警告信息显示是黄色的。<br/>
  35. - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。<br/>
  36. @param msg A JavaScript string containing zero or more substitution strings.
  37. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  38. */
  39. export function warn(msg: any, ...subst: any[]): void;
  40. /**
  41. !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
  42. !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  43. @param msg A JavaScript string containing zero or more substitution strings.
  44. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  45. */
  46. export function log(msg: string|any, ...subst: any[]): void;
  47. /**
  48. !#en
  49. Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).
  50. - In Cocos Creator, info is blue.
  51. - In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
  52. !#zh
  53. 输出一条信息消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
  54. - 在 Cocos Creator 中,Info 信息显示是蓝色的。<br/>
  55. - 在 Firefox 和 Chrome 中,Info 信息有着小 “i” 图标。
  56. @param msg A JavaScript string containing zero or more substitution strings.
  57. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  58. */
  59. export function info(msg: any, ...subst: any[]): void;
  60. /** The current version of Cocos2d being used.<br/>
  61. Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
  62. If you post a bug to forum, please attach this flag. */
  63. export var ENGINE_VERSION: string;
  64. /**
  65. !#en
  66. Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
  67. or less (speed < 1) time. <br/>
  68. Useful to simulate 'slow motion' or 'fast forward' effect.
  69. !#zh 修改目标动作的速率。
  70. @param action action
  71. @param speed speed
  72. @example
  73. ```js
  74. // change the target action speed;
  75. var action = cc.scaleTo(0.2, 1, 0.6);
  76. var newAction = cc.speed(action, 0.5);
  77. ```
  78. */
  79. export function speed(action: ActionInterval, speed: number): Action;
  80. /**
  81. !#en Create a follow action which makes its target follows another node.
  82. !#zh 追踪目标节点的位置。
  83. @param followedNode followedNode
  84. @param rect rect
  85. @example
  86. ```js
  87. // example
  88. // creates the action with a set boundary
  89. var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
  90. node.runAction(followAction);
  91. // creates the action with no boundary set
  92. var followAction = cc.follow(targetNode);
  93. node.runAction(followAction);
  94. ```
  95. */
  96. export function follow(followedNode: Node, rect: Rect): Action;
  97. /**
  98. Points setter
  99. @param points points
  100. */
  101. export function setPoints(points: any[]): void;
  102. /**
  103. !#en Creates an action with a Cardinal Spline array of points and tension.
  104. !#zh 按基数样条曲线轨迹移动到目标位置。
  105. @param duration duration
  106. @param points array of control points
  107. @param tension tension
  108. @example
  109. ```js
  110. //create a cc.CardinalSplineTo
  111. var action1 = cc.cardinalSplineTo(3, array, 0);
  112. ```
  113. */
  114. export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
  115. /**
  116. update position of target
  117. @param newPos newPos
  118. */
  119. export function updatePosition(newPos: Vec2): void;
  120. /**
  121. !#en Creates an action with a Cardinal Spline array of points and tension.
  122. !#zh 按基数样条曲线轨迹移动指定的距离。
  123. @param duration duration
  124. @param points points
  125. @param tension tension
  126. */
  127. export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
  128. /**
  129. !#en Creates an action with a Cardinal Spline array of points and tension.
  130. !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
  131. @param dt dt
  132. @param points points
  133. @example
  134. ```js
  135. var action1 = cc.catmullRomTo(3, array);
  136. ```
  137. */
  138. export function catmullRomTo(dt: number, points: any[]): ActionInterval;
  139. /**
  140. !#en Creates an action with a Cardinal Spline array of points and tension.
  141. !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
  142. @param dt dt
  143. @param points points
  144. @example
  145. ```js
  146. var action1 = cc.catmullRomBy(3, array);
  147. ```
  148. */
  149. export function catmullRomBy(dt: number, points: any[]): ActionInterval;
  150. /**
  151. !#en
  152. Creates the action easing object with the rate parameter. <br />
  153. From slow to fast.
  154. !#zh 创建 easeIn 缓动对象,由慢到快。
  155. @param rate rate
  156. @example
  157. ```js
  158. action.easing(cc.easeIn(3.0));
  159. ```
  160. */
  161. export function easeIn(rate: number): any;
  162. /**
  163. !#en
  164. Creates the action easing object with the rate parameter. <br />
  165. From fast to slow.
  166. !#zh 创建 easeOut 缓动对象,由快到慢。
  167. @param rate rate
  168. @example
  169. ```js
  170. action.easing(cc.easeOut(3.0));
  171. ```
  172. */
  173. export function easeOut(rate: number): any;
  174. /**
  175. !#en
  176. Creates the action easing object with the rate parameter. <br />
  177. Slow to fast then to slow.
  178. !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
  179. @param rate rate
  180. @example
  181. ```js
  182. action.easing(cc.easeInOut(3.0));
  183. ```
  184. */
  185. export function easeInOut(rate: number): any;
  186. /**
  187. !#en
  188. Creates the action easing object with the rate parameter. <br />
  189. Reference easeInExpo: <br />
  190. http://www.zhihu.com/question/21981571/answer/19925418
  191. !#zh
  192. 创建 easeExponentialIn 缓动对象。<br />
  193. EaseExponentialIn 是按指数函数缓动进入的动作。<br />
  194. 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
  195. @example
  196. ```js
  197. action.easing(cc.easeExponentialIn());
  198. ```
  199. */
  200. export function easeExponentialIn(): any;
  201. /**
  202. !#en
  203. Creates the action easing object. <br />
  204. Reference easeOutExpo: <br />
  205. http://www.zhihu.com/question/21981571/answer/19925418
  206. !#zh
  207. 创建 easeExponentialOut 缓动对象。<br />
  208. EaseExponentialOut 是按指数函数缓动退出的动作。<br />
  209. 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  210. @example
  211. ```js
  212. action.easing(cc.easeExponentialOut());
  213. ```
  214. */
  215. export function easeExponentialOut(): any;
  216. /**
  217. !#en
  218. Creates an EaseExponentialInOut action easing object. <br />
  219. Reference easeInOutExpo: <br />
  220. http://www.zhihu.com/question/21981571/answer/19925418
  221. !#zh
  222. 创建 easeExponentialInOut 缓动对象。<br />
  223. EaseExponentialInOut 是按指数函数缓动进入并退出的动作。<br />
  224. 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
  225. @example
  226. ```js
  227. action.easing(cc.easeExponentialInOut());
  228. ```
  229. */
  230. export function easeExponentialInOut(): any;
  231. /**
  232. !#en
  233. Creates an EaseSineIn action. <br />
  234. Reference easeInSine: <br />
  235. http://www.zhihu.com/question/21981571/answer/19925418
  236. !#zh
  237. 创建 EaseSineIn 缓动对象。<br />
  238. EaseSineIn 是按正弦函数缓动进入的动作。<br />
  239. 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
  240. @example
  241. ```js
  242. action.easing(cc.easeSineIn());
  243. ```
  244. */
  245. export function easeSineIn(): any;
  246. /**
  247. !#en
  248. Creates an EaseSineOut action easing object. <br />
  249. Reference easeOutSine: <br />
  250. http://www.zhihu.com/question/21981571/answer/19925418
  251. !#zh
  252. 创建 EaseSineOut 缓动对象。<br />
  253. EaseSineIn 是按正弦函数缓动退出的动作。<br />
  254. 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  255. @example
  256. ```js
  257. action.easing(cc.easeSineOut());
  258. ```
  259. */
  260. export function easeSineOut(): any;
  261. /**
  262. !#en
  263. Creates the action easing object. <br />
  264. Reference easeInOutSine: <br />
  265. http://www.zhihu.com/question/21981571/answer/19925418
  266. !#zh
  267. 创建 easeSineInOut 缓动对象。<br />
  268. EaseSineIn 是按正弦函数缓动进入并退出的动作。<br />
  269. 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
  270. @example
  271. ```js
  272. action.easing(cc.easeSineInOut());
  273. ```
  274. */
  275. export function easeSineInOut(): any;
  276. /**
  277. !#en
  278. Creates the action easing object with the period in radians (default is 0.3). <br />
  279. Reference easeInElastic: <br />
  280. http://www.zhihu.com/question/21981571/answer/19925418
  281. !#zh
  282. 创建 easeElasticIn 缓动对象。<br />
  283. EaseElasticIn 是按弹性曲线缓动进入的动作。<br />
  284. 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
  285. @param period period
  286. @example
  287. ```js
  288. // example
  289. action.easing(cc.easeElasticIn(3.0));
  290. ```
  291. */
  292. export function easeElasticIn(period: number): any;
  293. /**
  294. !#en
  295. Creates the action easing object with the period in radians (default is 0.3). <br />
  296. Reference easeOutElastic: <br />
  297. http://www.zhihu.com/question/21981571/answer/19925418
  298. !#zh
  299. 创建 easeElasticOut 缓动对象。<br />
  300. EaseElasticOut 是按弹性曲线缓动退出的动作。<br />
  301. 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  302. @param period period
  303. @example
  304. ```js
  305. // example
  306. action.easing(cc.easeElasticOut(3.0));
  307. ```
  308. */
  309. export function easeElasticOut(period: number): any;
  310. /**
  311. !#en
  312. Creates the action easing object with the period in radians (default is 0.3). <br />
  313. Reference easeInOutElastic: <br />
  314. http://www.zhihu.com/question/21981571/answer/19925418
  315. !#zh
  316. 创建 easeElasticInOut 缓动对象。<br />
  317. EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。<br />
  318. 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
  319. @param period period
  320. @example
  321. ```js
  322. // example
  323. action.easing(cc.easeElasticInOut(3.0));
  324. ```
  325. */
  326. export function easeElasticInOut(period: number): any;
  327. /**
  328. !#en
  329. Creates the action easing object. <br />
  330. Eased bounce effect at the beginning.
  331. !#zh
  332. 创建 easeBounceIn 缓动对象。<br />
  333. EaseBounceIn 是按弹跳动作缓动进入的动作。
  334. @example
  335. ```js
  336. // example
  337. action.easing(cc.easeBounceIn());
  338. ```
  339. */
  340. export function easeBounceIn(): any;
  341. /**
  342. !#en
  343. Creates the action easing object. <br />
  344. Eased bounce effect at the ending.
  345. !#zh
  346. 创建 easeBounceOut 缓动对象。<br />
  347. EaseBounceOut 是按弹跳动作缓动退出的动作。
  348. @example
  349. ```js
  350. // example
  351. action.easing(cc.easeBounceOut());
  352. ```
  353. */
  354. export function easeBounceOut(): any;
  355. /**
  356. !#en
  357. Creates the action easing object. <br />
  358. Eased bounce effect at the begining and ending.
  359. !#zh
  360. 创建 easeBounceInOut 缓动对象。<br />
  361. EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
  362. @example
  363. ```js
  364. // example
  365. action.easing(cc.easeBounceInOut());
  366. ```
  367. */
  368. export function easeBounceInOut(): any;
  369. /**
  370. !#en
  371. Creates the action easing object. <br />
  372. In the opposite direction to move slowly, and then accelerated to the right direction.
  373. !#zh
  374. 创建 easeBackIn 缓动对象。<br />
  375. easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。<br />
  376. @example
  377. ```js
  378. // example
  379. action.easing(cc.easeBackIn());
  380. ```
  381. */
  382. export function easeBackIn(): any;
  383. /**
  384. !#en
  385. Creates the action easing object. <br />
  386. Fast moving more than the finish, and then slowly back to the finish.
  387. !#zh
  388. 创建 easeBackOut 缓动对象。<br />
  389. easeBackOut 快速移动超出目标,然后慢慢回到目标点。
  390. @example
  391. ```js
  392. // example
  393. action.easing(cc.easeBackOut());
  394. ```
  395. */
  396. export function easeBackOut(): any;
  397. /**
  398. !#en
  399. Creates the action easing object. <br />
  400. Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  401. !#zh
  402. 创建 easeBackInOut 缓动对象。<br />
  403. @example
  404. ```js
  405. // example
  406. action.easing(cc.easeBackInOut());
  407. ```
  408. */
  409. export function easeBackInOut(): any;
  410. /**
  411. !#en
  412. Creates the action easing object. <br />
  413. Into the 4 reference point. <br />
  414. To calculate the motion curve.
  415. !#zh
  416. 创建 easeBezierAction 缓动对象。<br />
  417. EaseBezierAction 是按贝塞尔曲线缓动的动作。
  418. @param p0 The first bezier parameter
  419. @param p1 The second bezier parameter
  420. @param p2 The third bezier parameter
  421. @param p3 The fourth bezier parameter
  422. @example
  423. ```js
  424. // example
  425. action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  426. ```
  427. */
  428. export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
  429. /**
  430. !#en
  431. Creates the action easing object. <br />
  432. Reference easeInQuad: <br />
  433. http://www.zhihu.com/question/21981571/answer/19925418
  434. !#zh
  435. 创建 easeQuadraticActionIn 缓动对象。<br />
  436. EaseQuadraticIn是按二次函数缓动进入的动作。<br />
  437. 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
  438. @example
  439. ```js
  440. //example
  441. action.easing(cc.easeQuadraticActionIn());
  442. ```
  443. */
  444. export function easeQuadraticActionIn(): any;
  445. /**
  446. !#en
  447. Creates the action easing object. <br />
  448. Reference easeOutQuad: <br />
  449. http://www.zhihu.com/question/21981571/answer/19925418
  450. !#zh
  451. 创建 easeQuadraticActionOut 缓动对象。<br />
  452. EaseQuadraticOut 是按二次函数缓动退出的动作。<br />
  453. 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  454. @example
  455. ```js
  456. //example
  457. action.easing(cc.easeQuadraticActionOut());
  458. ```
  459. */
  460. export function easeQuadraticActionOut(): any;
  461. /**
  462. !#en
  463. Creates the action easing object. <br />
  464. Reference easeInOutQuad: <br />
  465. http://www.zhihu.com/question/21981571/answer/19925418
  466. !#zh
  467. 创建 easeQuadraticActionInOut 缓动对象。<br />
  468. EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。<br />
  469. 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
  470. @example
  471. ```js
  472. //example
  473. action.easing(cc.easeQuadraticActionInOut());
  474. ```
  475. */
  476. export function easeQuadraticActionInOut(): any;
  477. /**
  478. !#en
  479. Creates the action easing object. <br />
  480. Reference easeIntQuart: <br />
  481. http://www.zhihu.com/question/21981571/answer/19925418
  482. !#zh
  483. 创建 easeQuarticActionIn 缓动对象。<br />
  484. EaseQuarticIn 是按四次函数缓动进入的动作。<br />
  485. 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
  486. @example
  487. ```js
  488. //example
  489. action.easing(cc.easeQuarticActionIn());
  490. ```
  491. */
  492. export function easeQuarticActionIn(): any;
  493. /**
  494. !#en
  495. Creates the action easing object. <br />
  496. Reference easeOutQuart: <br />
  497. http://www.zhihu.com/question/21981571/answer/19925418
  498. !#zh
  499. 创建 easeQuarticActionOut 缓动对象。<br />
  500. EaseQuarticOut 是按四次函数缓动退出的动作。<br />
  501. 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  502. @example
  503. ```js
  504. //example
  505. action.easing(cc.QuarticActionOut());
  506. ```
  507. */
  508. export function easeQuarticActionOut(): any;
  509. /**
  510. !#en
  511. Creates the action easing object. <br />
  512. Reference easeInOutQuart: <br />
  513. http://www.zhihu.com/question/21981571/answer/19925418
  514. !#zh
  515. 创建 easeQuarticActionInOut 缓动对象。<br />
  516. EaseQuarticInOut 是按四次函数缓动进入并退出的动作。<br />
  517. 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
  518. */
  519. export function easeQuarticActionInOut(): any;
  520. /**
  521. !#en
  522. Creates the action easing object. <br />
  523. Reference easeInQuint: <br />
  524. http://www.zhihu.com/question/21981571/answer/19925418
  525. !#zh
  526. 创建 easeQuinticActionIn 缓动对象。<br />
  527. EaseQuinticIn 是按五次函数缓动进的动作。<br />
  528. 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
  529. @example
  530. ```js
  531. //example
  532. action.easing(cc.easeQuinticActionIn());
  533. ```
  534. */
  535. export function easeQuinticActionIn(): any;
  536. /**
  537. !#en
  538. Creates the action easing object. <br />
  539. Reference easeOutQuint: <br />
  540. http://www.zhihu.com/question/21981571/answer/19925418
  541. !#zh
  542. 创建 easeQuinticActionOut 缓动对象。<br />
  543. EaseQuinticOut 是按五次函数缓动退出的动作
  544. 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  545. @example
  546. ```js
  547. //example
  548. action.easing(cc.easeQuadraticActionOut());
  549. ```
  550. */
  551. export function easeQuinticActionOut(): any;
  552. /**
  553. !#en
  554. Creates the action easing object. <br />
  555. Reference easeInOutQuint: <br />
  556. http://www.zhihu.com/question/21981571/answer/19925418
  557. !#zh
  558. 创建 easeQuinticActionInOut 缓动对象。<br />
  559. EaseQuinticInOut是按五次函数缓动进入并退出的动作。<br />
  560. 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
  561. @example
  562. ```js
  563. //example
  564. action.easing(cc.easeQuinticActionInOut());
  565. ```
  566. */
  567. export function easeQuinticActionInOut(): any;
  568. /**
  569. !#en
  570. Creates the action easing object. <br />
  571. Reference easeInCirc: <br />
  572. http://www.zhihu.com/question/21981571/answer/19925418
  573. !#zh
  574. 创建 easeCircleActionIn 缓动对象。<br />
  575. EaseCircleIn是按圆形曲线缓动进入的动作。<br />
  576. 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
  577. @example
  578. ```js
  579. //example
  580. action.easing(cc.easeCircleActionIn());
  581. ```
  582. */
  583. export function easeCircleActionIn(): any;
  584. /**
  585. !#en
  586. Creates the action easing object. <br />
  587. Reference easeOutCirc: <br />
  588. http://www.zhihu.com/question/21981571/answer/19925418
  589. !#zh
  590. 创建 easeCircleActionOut 缓动对象。<br />
  591. EaseCircleOut是按圆形曲线缓动退出的动作。<br />
  592. 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  593. @example
  594. ```js
  595. //example
  596. actioneasing(cc.easeCircleActionOut());
  597. ```
  598. */
  599. export function easeCircleActionOut(): any;
  600. /**
  601. !#en
  602. Creates the action easing object. <br />
  603. Reference easeInOutCirc: <br />
  604. http://www.zhihu.com/question/21981571/answer/19925418
  605. !#zh
  606. 创建 easeCircleActionInOut 缓动对象。<br />
  607. EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。<br />
  608. 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
  609. @example
  610. ```js
  611. //example
  612. action.easing(cc.easeCircleActionInOut());
  613. ```
  614. */
  615. export function easeCircleActionInOut(): any;
  616. /**
  617. !#en
  618. Creates the action easing object. <br />
  619. Reference easeInCubic: <br />
  620. http://www.zhihu.com/question/21981571/answer/19925418
  621. !#zh
  622. 创建 easeCubicActionIn 缓动对象。<br />
  623. EaseCubicIn 是按三次函数缓动进入的动作。<br />
  624. 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
  625. @example
  626. ```js
  627. //example
  628. action.easing(cc.easeCubicActionIn());
  629. ```
  630. */
  631. export function easeCubicActionIn(): any;
  632. /**
  633. !#en
  634. Creates the action easing object. <br />
  635. Reference easeOutCubic: <br />
  636. http://www.zhihu.com/question/21981571/answer/19925418
  637. !#zh
  638. 创建 easeCubicActionOut 缓动对象。<br />
  639. EaseCubicOut 是按三次函数缓动退出的动作。<br />
  640. 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  641. @example
  642. ```js
  643. //example
  644. action.easing(cc.easeCubicActionOut());
  645. ```
  646. */
  647. export function easeCubicActionOut(): any;
  648. /**
  649. !#en
  650. Creates the action easing object. <br />
  651. Reference easeInOutCubic: <br />
  652. http://www.zhihu.com/question/21981571/answer/19925418
  653. !#zh
  654. 创建 easeCubicActionInOut 缓动对象。<br />
  655. EaseCubicInOut是按三次函数缓动进入并退出的动作。<br />
  656. 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
  657. */
  658. export function easeCubicActionInOut(): any;
  659. /**
  660. !#en Show the Node.
  661. !#zh 立即显示。
  662. @example
  663. ```js
  664. // example
  665. var showAction = cc.show();
  666. ```
  667. */
  668. export function show(): ActionInstant;
  669. /**
  670. !#en Hide the node.
  671. !#zh 立即隐藏。
  672. @example
  673. ```js
  674. // example
  675. var hideAction = cc.hide();
  676. ```
  677. */
  678. export function hide(): ActionInstant;
  679. /**
  680. !#en Toggles the visibility of a node.
  681. !#zh 显隐状态切换。
  682. @example
  683. ```js
  684. // example
  685. var toggleVisibilityAction = cc.toggleVisibility();
  686. ```
  687. */
  688. export function toggleVisibility(): ActionInstant;
  689. /**
  690. !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
  691. !#zh 从父节点移除自身。
  692. @param isNeedCleanUp isNeedCleanUp
  693. @example
  694. ```js
  695. // example
  696. var removeSelfAction = cc.removeSelf();
  697. ```
  698. */
  699. export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
  700. /**
  701. !#en Create a FlipX action to flip or unflip the target.
  702. !#zh X轴翻转。
  703. @param flip Indicate whether the target should be flipped or not
  704. @example
  705. ```js
  706. var flipXAction = cc.flipX(true);
  707. ```
  708. */
  709. export function flipX(flip: boolean): ActionInstant;
  710. /**
  711. !#en Create a FlipY action to flip or unflip the target.
  712. !#zh Y轴翻转。
  713. @param flip flip
  714. @example
  715. ```js
  716. var flipYAction = cc.flipY(true);
  717. ```
  718. */
  719. export function flipY(flip: boolean): ActionInstant;
  720. /**
  721. !#en Creates a Place action with a position.
  722. !#zh 放置在目标位置。
  723. @param pos pos
  724. @param y y
  725. @example
  726. ```js
  727. // example
  728. var placeAction = cc.place(cc.p(200, 200));
  729. var placeAction = cc.place(200, 200);
  730. ```
  731. */
  732. export function place(pos: Vec2|number, y?: number): ActionInstant;
  733. /**
  734. !#en Creates the action with the callback.
  735. !#zh 执行回调函数。
  736. @param selector selector
  737. @param selectorTarget selectorTarget
  738. @param data data for function, it accepts all data types.
  739. @example
  740. ```js
  741. // example
  742. // CallFunc without data
  743. var finish = cc.callFunc(this.removeSprite, this);
  744. // CallFunc with data
  745. var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
  746. ```
  747. */
  748. export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
  749. /**
  750. !#en
  751. Helper constructor to create an array of sequenceable actions
  752. The created action will run actions sequentially, one after another.
  753. !#zh 顺序执行动作,创建的动作将按顺序依次运行。
  754. @param actionOrActionArray actionOrActionArray
  755. @param tempArray tempArray
  756. @example
  757. ```js
  758. // example
  759. // create sequence with actions
  760. var seq = cc.sequence(act1, act2);
  761. // create sequence with array
  762. var seq = cc.sequence(actArray);
  763. ```
  764. */
  765. export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
  766. /**
  767. !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
  768. !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
  769. @param action action
  770. @param times times
  771. @example
  772. ```js
  773. // example
  774. var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
  775. ```
  776. */
  777. export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
  778. /**
  779. !#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
  780. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
  781. @param action action
  782. @example
  783. ```js
  784. // example
  785. var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
  786. ```
  787. */
  788. export function repeatForever(action: FiniteTimeAction): ActionInterval;
  789. /**
  790. !#en Create a spawn action which runs several actions in parallel.
  791. !#zh 同步执行动作,同步执行一组动作。
  792. @param actionOrActionArray actionOrActionArray
  793. @param tempArray tempArray
  794. @example
  795. ```js
  796. // example
  797. var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
  798. todo:It should be the direct use new
  799. ```
  800. */
  801. export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
  802. /**
  803. !#en
  804. Rotates a Node object to a certain angle by modifying its rotation property. <br/>
  805. The direction will be decided by the shortest angle.
  806. !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
  807. @param duration duration in seconds
  808. @param deltaAngleX deltaAngleX in degrees.
  809. @param deltaAngleY deltaAngleY in degrees.
  810. @example
  811. ```js
  812. // example
  813. var rotateTo = cc.rotateTo(2, 61.0);
  814. ```
  815. */
  816. export function rotateTo(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  817. /**
  818. !#en
  819. Rotates a Node object clockwise a number of degrees by modifying its rotation property.
  820. Relative to its properties to modify.
  821. !#zh 旋转指定的角度。
  822. @param duration duration in seconds
  823. @param deltaAngleX deltaAngleX in degrees
  824. @param deltaAngleY deltaAngleY in degrees
  825. @example
  826. ```js
  827. // example
  828. var actionBy = cc.rotateBy(2, 360);
  829. ```
  830. */
  831. export function rotateBy(duration: number, deltaAngleX: number, deltaAngleY?: number): ActionInterval;
  832. /**
  833. !#en
  834. Moves a Node object x,y pixels by modifying its position property. <br/>
  835. x and y are relative to the position of the object. <br/>
  836. Several MoveBy actions can be concurrently called, and the resulting <br/>
  837. movement will be the sum of individual movements.
  838. !#zh 移动指定的距离。
  839. @param duration duration in seconds
  840. @param deltaPos deltaPos
  841. @param deltaY deltaY
  842. @example
  843. ```js
  844. // example
  845. var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
  846. ```
  847. */
  848. export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
  849. /**
  850. !#en
  851. Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
  852. Several MoveTo actions can be concurrently called, and the resulting <br/>
  853. movement will be the sum of individual movements.
  854. !#zh 移动到目标位置。
  855. @param duration duration in seconds
  856. @param position position
  857. @param y y
  858. @example
  859. ```js
  860. // example
  861. var actionBy = cc.moveTo(2, cc.p(80, 80));
  862. ```
  863. */
  864. export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
  865. /**
  866. !#en
  867. Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
  868. Changes to the specified value.
  869. !#zh 偏斜到目标角度。
  870. @param t time in seconds
  871. @param sx sx
  872. @param sy sy
  873. @example
  874. ```js
  875. // example
  876. var actionTo = cc.skewTo(2, 37.2, -37.2);
  877. ```
  878. */
  879. export function skewTo(t: number, sx: number, sy: number): ActionInterval;
  880. /**
  881. !#en
  882. Skews a Node object by skewX and skewY degrees. <br />
  883. Relative to its property modification.
  884. !#zh 偏斜指定的角度。
  885. @param t time in seconds
  886. @param sx sx skew in degrees for X axis
  887. @param sy sy skew in degrees for Y axis
  888. @example
  889. ```js
  890. // example
  891. var actionBy = cc.skewBy(2, 0, -90);
  892. ```
  893. */
  894. export function skewBy(t: number, sx: number, sy: number): ActionInterval;
  895. /**
  896. !#en
  897. Moves a Node object simulating a parabolic jump movement by modifying it's position property.
  898. Relative to its movement.
  899. !#zh 用跳跃的方式移动指定的距离。
  900. @param duration duration
  901. @param position position
  902. @param y y
  903. @param height height
  904. @param jumps jumps
  905. @example
  906. ```js
  907. // example
  908. var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
  909. var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
  910. ```
  911. */
  912. export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  913. /**
  914. !#en
  915. Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
  916. Jump to the specified location.
  917. !#zh 用跳跃的方式移动到目标位置。
  918. @param duration duration
  919. @param position position
  920. @param y y
  921. @param height height
  922. @param jumps jumps
  923. @example
  924. ```js
  925. // example
  926. var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
  927. var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
  928. ```
  929. */
  930. export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
  931. /**
  932. !#en
  933. An action that moves the target with a cubic Bezier curve by a certain distance.
  934. Relative to its movement.
  935. !#zh 按贝赛尔曲线轨迹移动指定的距离。
  936. @param t time in seconds
  937. @param c Array of points
  938. @example
  939. ```js
  940. // example
  941. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  942. var bezierForward = cc.bezierBy(3, bezier);
  943. ```
  944. */
  945. export function bezierBy(t: number, c: Vec2[]): ActionInterval;
  946. /**
  947. !#en An action that moves the target with a cubic Bezier curve to a destination point.
  948. !#zh 按贝赛尔曲线轨迹移动到目标位置。
  949. @param t t
  950. @param c Array of points
  951. @example
  952. ```js
  953. // example
  954. var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
  955. var bezierTo = cc.bezierTo(2, bezier);
  956. ```
  957. */
  958. export function bezierTo(t: number, c: Vec2[]): ActionInterval;
  959. /**
  960. !#en Scales a Node object to a zoom factor by modifying it's scale property.
  961. !#zh 将节点大小缩放到指定的倍数。
  962. @param duration duration
  963. @param sx scale parameter in X
  964. @param sy scale parameter in Y, if Null equal to sx
  965. @example
  966. ```js
  967. // example
  968. // It scales to 0.5 in both X and Y.
  969. var actionTo = cc.scaleTo(2, 0.5);
  970. // It scales to 0.5 in x and 2 in Y
  971. var actionTo = cc.scaleTo(2, 0.5, 2);
  972. ```
  973. */
  974. export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
  975. /**
  976. !#en
  977. Scales a Node object a zoom factor by modifying it's scale property.
  978. Relative to its changes.
  979. !#zh 按指定的倍数缩放节点大小。
  980. @param duration duration in seconds
  981. @param sx sx scale parameter in X
  982. @param sy sy scale parameter in Y, if Null equal to sx
  983. @example
  984. ```js
  985. // example without sy, it scales by 2 both in X and Y
  986. var actionBy = cc.scaleBy(2, 2);
  987. //example with sy, it scales by 0.25 in X and 4.5 in Y
  988. var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
  989. ```
  990. */
  991. export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
  992. /**
  993. !#en Blinks a Node object by modifying it's visible property.
  994. !#zh 闪烁(基于透明度)。
  995. @param duration duration in seconds
  996. @param blinks blinks in times
  997. @example
  998. ```js
  999. // example
  1000. var action = cc.blink(2, 10);
  1001. ```
  1002. */
  1003. export function blink(duration: number, blinks: number): ActionInterval;
  1004. /**
  1005. !#en
  1006. Fades an object that implements the cc.RGBAProtocol protocol.
  1007. It modifies the opacity from the current value to a custom one.
  1008. !#zh 修改透明度到指定值。
  1009. @param duration duration
  1010. @param opacity 0-255, 0 is transparent
  1011. @example
  1012. ```js
  1013. // example
  1014. var action = cc.fadeTo(1.0, 0);
  1015. ```
  1016. */
  1017. export function fadeTo(duration: number, opacity: number): ActionInterval;
  1018. /**
  1019. !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
  1020. !#zh 渐显效果。
  1021. @param duration duration in seconds
  1022. @example
  1023. ```js
  1024. //example
  1025. var action = cc.fadeIn(1.0);
  1026. ```
  1027. */
  1028. export function fadeIn(duration: number): ActionInterval;
  1029. /**
  1030. !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
  1031. !#zh 渐隐效果。
  1032. @param d duration in seconds
  1033. @example
  1034. ```js
  1035. // example
  1036. var action = cc.fadeOut(1.0);
  1037. ```
  1038. */
  1039. export function fadeOut(d: number): ActionInterval;
  1040. /**
  1041. !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1042. !#zh 修改颜色到指定值。
  1043. @param duration duration
  1044. @param red 0-255
  1045. @param green 0-255
  1046. @param blue 0-255
  1047. @example
  1048. ```js
  1049. // example
  1050. var action = cc.tintTo(2, 255, 0, 255);
  1051. ```
  1052. */
  1053. export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
  1054. /**
  1055. !#en
  1056. Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
  1057. Relative to their own color change.
  1058. !#zh 按照指定的增量修改颜色。
  1059. @param duration duration in seconds
  1060. @param deltaRed deltaRed
  1061. @param deltaGreen deltaGreen
  1062. @param deltaBlue deltaBlue
  1063. @example
  1064. ```js
  1065. // example
  1066. var action = cc.tintBy(2, -127, -255, -127);
  1067. ```
  1068. */
  1069. export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
  1070. /**
  1071. !#en Delays the action a certain amount of seconds.
  1072. !#en 延迟指定的时间量。
  1073. @param d duration in seconds
  1074. @example
  1075. ```js
  1076. // example
  1077. var delay = cc.delayTime(1);
  1078. ```
  1079. */
  1080. export function delayTime(d: number): ActionInterval;
  1081. /**
  1082. !#en Executes an action in reverse order, from time=duration to time=0.
  1083. !#zh 反转目标动作的时间轴。
  1084. @param action action
  1085. @example
  1086. ```js
  1087. // example
  1088. var reverse = cc.reverseTime(this);
  1089. ```
  1090. */
  1091. export function reverseTime(action: FiniteTimeAction): ActionInterval;
  1092. /**
  1093. !#en Create an action with the specified action and forced target.
  1094. !#zh 用已有动作和一个新的目标节点创建动作。
  1095. @param target target
  1096. @param action action
  1097. */
  1098. export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
  1099. /** !#en cc.view is the shared view object.
  1100. !#zh cc.view 是全局的视图对象。 */
  1101. export var view: View;
  1102. /** !#en Director
  1103. !#zh 导演类。 */
  1104. export var director: Director;
  1105. /** !#en cc.winSize is the alias object for the size of the current game window.
  1106. !#zh cc.winSize 为当前的游戏窗口的大小。 */
  1107. export var winSize: Size;
  1108. export var game: Game;
  1109. /** !#en The System event singleton for global usage
  1110. !#zh 系统事件单例,方便全局使用 */
  1111. export var systemEvent: SystemEvent;
  1112. /**
  1113. @param touches touches
  1114. */
  1115. export function handleTouchesBegin(touches: any[]): void;
  1116. /**
  1117. @param touches touches
  1118. */
  1119. export function handleTouchesMove(touches: any[]): void;
  1120. /**
  1121. @param touches touches
  1122. */
  1123. export function handleTouchesEnd(touches: any[]): void;
  1124. /**
  1125. @param touches touches
  1126. */
  1127. export function handleTouchesCancel(touches: any[]): void;
  1128. /**
  1129. @param touches touches
  1130. */
  1131. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1132. /**
  1133. @param element element
  1134. */
  1135. export function getHTMLElementPosition(element: HTMLElement): any;
  1136. /**
  1137. @param touch touch
  1138. */
  1139. export function getPreTouch(touch: Touch): Touch;
  1140. /**
  1141. @param touch touch
  1142. */
  1143. export function setPreTouch(touch: Touch): void;
  1144. /**
  1145. @param tx tx
  1146. @param ty ty
  1147. @param pos pos
  1148. */
  1149. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1150. /**
  1151. @param event event
  1152. @param pos pos
  1153. */
  1154. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1155. /**
  1156. @param event event
  1157. @param pos pos
  1158. */
  1159. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1160. /**
  1161. @param element element
  1162. */
  1163. export function registerSystemEvent(element: HTMLElement): void;
  1164. /**
  1165. !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
  1166. !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
  1167. @param options options
  1168. @example
  1169. ```js
  1170. // define base class
  1171. var Node = cc.Class();
  1172. // define sub class
  1173. var Sprite = cc.Class({
  1174. name: 'Sprite',
  1175. extends: Node,
  1176. ctor: function () {
  1177. this.url = "";
  1178. this.id = 0;
  1179. },
  1180. statics: {
  1181. // define static members
  1182. count: 0,
  1183. getBounds: function (spriteList) {
  1184. // compute bounds...
  1185. }
  1186. },
  1187. properties {
  1188. width: {
  1189. default: 128,
  1190. type: 'Integer',
  1191. tooltip: 'The width of sprite'
  1192. },
  1193. height: 128,
  1194. size: {
  1195. get: function () {
  1196. return cc.v2(this.width, this.height);
  1197. }
  1198. }
  1199. },
  1200. load: function () {
  1201. // load this.url...
  1202. };
  1203. });
  1204. // instantiate
  1205. var obj = new Sprite();
  1206. obj.url = 'sprite.png';
  1207. obj.load();
  1208. ```
  1209. */
  1210. export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function;
  1211. /**
  1212. Checks whether subclass is child of superclass or equals to superclass
  1213. @param subclass subclass
  1214. @param superclass superclass
  1215. */
  1216. export function isChildClassOf(subclass: Function, superclass: Function): boolean;
  1217. /**
  1218. !#en
  1219. Define an enum type. <br/>
  1220. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.<br/>
  1221. Otherwise it will use the value specified by user who writes the enum definition.
  1222. !#zh
  1223. 定义一个枚举类型。<br/>
  1224. 用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
  1225. @param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
  1226. @example
  1227. ```js
  1228. // JavaScript:
  1229. var WrapMode = cc.Enum({
  1230. Repeat: -1,
  1231. Clamp: -1
  1232. });
  1233. // Texture.WrapMode.Repeat == 0
  1234. // Texture.WrapMode.Clamp == 1
  1235. // Texture.WrapMode[0] == "Repeat"
  1236. // Texture.WrapMode[1] == "Clamp"
  1237. var FlagType = cc.Enum({
  1238. Flag1: 1,
  1239. Flag2: 2,
  1240. Flag3: 4,
  1241. Flag4: 8,
  1242. });
  1243. var AtlasSizeList = cc.Enum({
  1244. 128: 128,
  1245. 256: 256,
  1246. 512: 512,
  1247. 1024: 1024,
  1248. });
  1249. // TypeScript:
  1250. // If used in TypeScript, just define a TypeScript enum:
  1251. enum Direction {
  1252. Up,
  1253. Down,
  1254. Left,
  1255. Right
  1256. }
  1257. // If you need to inspect the enum in Properties panel, you can call cc.Enum:
  1258. const {ccclass, property} = cc._decorator;
  1259. @ccclass
  1260. class NewScript extends cc.Component {
  1261. @property({
  1262. type: cc.Enum(Direction) // call cc.Enum
  1263. })
  1264. direction: Direction = Direction.Up;
  1265. }
  1266. ```
  1267. */
  1268. export function Enum<T>(obj: T): T;
  1269. /**
  1270. whether enable accelerometer event
  1271. @param isEnable isEnable
  1272. */
  1273. export function setAccelerometerEnabled(isEnable: boolean): void;
  1274. /**
  1275. set accelerometer interval value
  1276. @param interval interval
  1277. */
  1278. export function setAccelerometerInterval(interval: number): void;
  1279. /**
  1280. @param touches touches
  1281. */
  1282. export function handleTouchesBegin(touches: any[]): void;
  1283. /**
  1284. @param touches touches
  1285. */
  1286. export function handleTouchesMove(touches: any[]): void;
  1287. /**
  1288. @param touches touches
  1289. */
  1290. export function handleTouchesEnd(touches: any[]): void;
  1291. /**
  1292. @param touches touches
  1293. */
  1294. export function handleTouchesCancel(touches: any[]): void;
  1295. /**
  1296. @param touches touches
  1297. */
  1298. export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
  1299. /**
  1300. @param element element
  1301. */
  1302. export function getHTMLElementPosition(element: HTMLElement): any;
  1303. /**
  1304. @param touch touch
  1305. */
  1306. export function getPreTouch(touch: Touch): Touch;
  1307. /**
  1308. @param touch touch
  1309. */
  1310. export function setPreTouch(touch: Touch): void;
  1311. /**
  1312. @param tx tx
  1313. @param ty ty
  1314. @param pos pos
  1315. */
  1316. export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
  1317. /**
  1318. @param location location
  1319. @param pos pos
  1320. @param eventType eventType
  1321. */
  1322. export function getTouchByXY(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
  1323. /**
  1324. @param event event
  1325. @param pos pos
  1326. */
  1327. export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
  1328. /**
  1329. @param event event
  1330. @param pos pos
  1331. */
  1332. export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
  1333. /**
  1334. @param element element
  1335. */
  1336. export function registerSystemEvent(element: HTMLElement): void;
  1337. /**
  1338. @param dt dt
  1339. */
  1340. export function update(dt: number): void;
  1341. /**
  1342. <p>
  1343. Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  1344. </p>
  1345. @param a number A
  1346. @param b number B
  1347. @param r ratio between 0 and 1
  1348. @example
  1349. ```js
  1350. ----
  1351. lerp
  1352. cc.lerp(2,10,0.5)//returns 6
  1353. cc.lerp(2,10,0.2)//returns 3.6
  1354. ```
  1355. */
  1356. export function lerp(a: number, b: number, r: number): number;
  1357. /**
  1358. get a random number from 0 to 0xffffff
  1359. */
  1360. export function rand(): number;
  1361. /**
  1362. returns a random float between -1 and 1
  1363. */
  1364. export function randomMinus1To1(): number;
  1365. /**
  1366. returns a random float between 0 and 1, use Math.random directly
  1367. */
  1368. export function random0To1(): number;
  1369. /**
  1370. converts degrees to radians
  1371. @param angle angle
  1372. */
  1373. export function degreesToRadians(angle: number): number;
  1374. /**
  1375. converts radians to degrees
  1376. @param angle angle
  1377. */
  1378. export function radiansToDegrees(angle: number): number;
  1379. /**
  1380. Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
  1381. @param node setup node
  1382. */
  1383. export function nodeDrawSetup(node: Node): void;
  1384. /**
  1385. <p>
  1386. Increments the GL Draws counts by one.<br/>
  1387. The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.<br/>
  1388. </p>
  1389. @param addNumber addNumber
  1390. */
  1391. export function incrementGLDraws(addNumber: number): void;
  1392. /**
  1393. Check webgl error.Error will be shown in console if exists.
  1394. */
  1395. export function checkGLErrorDebug(): void;
  1396. /**
  1397. !#en
  1398. Checks whether the object is non-nil and not yet destroyed.<br>
  1399. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  1400. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  1401. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  1402. but this is often caused by a particular logical requirements, which is not normally required.
  1403. !#zh
  1404. 检查该对象是否不为 null 并且尚未销毁。<br>
  1405. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
  1406. @param value value
  1407. @param strictMode If true, Object called destroy() in this frame will also treated as invalid.
  1408. @example
  1409. ```js
  1410. var node = new cc.Node();
  1411. cc.log(cc.isValid(node)); // true
  1412. node.destroy();
  1413. cc.log(cc.isValid(node)); // true, still valid in this frame
  1414. // after a frame...
  1415. cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
  1416. ```
  1417. */
  1418. export function isValid(value: any, strictMode?: boolean): boolean;
  1419. /** Specify that the input value must be integer in Inspector.
  1420. Also used to indicates that the elements in array should be type integer. */
  1421. export var Integer: string;
  1422. /** Indicates that the elements in array should be type double. */
  1423. export var Float: string;
  1424. /** Indicates that the elements in array should be type boolean. */
  1425. export var Boolean: string;
  1426. /** Indicates that the elements in array should be type string. */
  1427. export var String: string;
  1428. /**
  1429. !#en Deserialize json to cc.Asset
  1430. !#zh 将 JSON 反序列化为对象实例。
  1431. 当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用,
  1432. 也不会将 uuid 保存到 result 对象中。
  1433. @param data the serialized cc.Asset json string or json object.
  1434. @param details additional loading result
  1435. @param options options
  1436. */
  1437. export function deserialize(data: string|any, details?: Details, options?: any): any;
  1438. /**
  1439. !#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
  1440. !#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
  1441. (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
  1442. @param original An existing object that you want to make a copy of.
  1443. @example
  1444. ```js
  1445. // instantiate node from prefab
  1446. var scene = cc.director.getScene();
  1447. var node = cc.instantiate(prefabAsset);
  1448. node.parent = scene;
  1449. // clone node
  1450. var scene = cc.director.getScene();
  1451. var node = cc.instantiate(targetNode);
  1452. node.parent = scene;
  1453. ```
  1454. */
  1455. export function instantiate(original: Prefab): Node;
  1456. export function instantiate<T>(original: T): T;
  1457. /**
  1458. Finds a node by hierarchy path, the path is case-sensitive.
  1459. It will traverse the hierarchy by splitting the path using '/' character.
  1460. This function will still returns the node even if it is inactive.
  1461. It is recommended to not use this function every frame instead cache the result at startup.
  1462. @param path path
  1463. @param referenceNode referenceNode
  1464. */
  1465. export function find(path: string, referenceNode?: Node): Node;
  1466. /**
  1467. !#en
  1468. The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
  1469. Alpha channel is optional. Default value is 255.
  1470. !#zh
  1471. 通过该方法来创建一个新的 {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} 对象。
  1472. Alpha 通道是可选的。默认值是 255。
  1473. @param r r
  1474. @param g g
  1475. @param b b
  1476. @param a a
  1477. @example
  1478. ```js
  1479. -----------------------
  1480. // 1. All channels seperately as parameters
  1481. var color1 = new cc.Color(255, 255, 255, 255);
  1482. // 2. Convert a hex string to a color
  1483. var color2 = new cc.Color("#000000");
  1484. // 3. An color object as parameter
  1485. var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
  1486. ```
  1487. */
  1488. export function color(r?: number, g?: number, b?: number, a?: number): Color;
  1489. /**
  1490. !#en returns true if both ccColor3B are equal. Otherwise it returns false.
  1491. !#zh 判断两个颜色对象的 RGB 部分是否相等,不比较透明度。
  1492. @param color1 color1
  1493. @param color2 color2
  1494. @example
  1495. ```js
  1496. cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
  1497. ```
  1498. */
  1499. export function colorEqual(color1: Color, color2: Color): boolean;
  1500. /**
  1501. !#en
  1502. convert a string of color for style to Color.
  1503. e.g. "#ff06ff" to : cc.color(255,6,255)。
  1504. !#zh 16 进制转换为 Color
  1505. @param hex hex
  1506. @example
  1507. ```js
  1508. cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  1509. ```
  1510. */
  1511. export function hexToColor(hex: string): Color;
  1512. /**
  1513. !#en
  1514. convert Color to a string of color for style.
  1515. e.g. cc.color(255,6,255) to : "#ff06ff"
  1516. !#zh Color 转换为 16进制。
  1517. @param color color
  1518. @example
  1519. ```js
  1520. var color = new cc.Color(255, 6, 255)
  1521. cc.colorToHex(color); // #ff06ff;
  1522. ```
  1523. */
  1524. export function colorToHex(color: Color): string;
  1525. /**
  1526. !#en Returns opposite of Vec2.
  1527. !#zh 返回相反的向量。
  1528. @param point point
  1529. @example
  1530. ```js
  1531. cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
  1532. ```
  1533. */
  1534. export function pNeg(point: Vec2): Vec2;
  1535. /**
  1536. !#en Calculates sum of two points.
  1537. !#zh 返回两个向量的和。
  1538. @param v1 v1
  1539. @param v2 v2
  1540. @example
  1541. ```js
  1542. cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
  1543. ```
  1544. */
  1545. export function pAdd(v1: Vec2, v2: Vec2): Vec2;
  1546. /**
  1547. !#en Calculates difference of two points.
  1548. !#zh 返回两个向量的差。
  1549. @param v1 v1
  1550. @param v2 v2
  1551. @example
  1552. ```js
  1553. cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
  1554. ```
  1555. */
  1556. export function pSub(v1: Vec2, v2: Vec2): Vec2;
  1557. /**
  1558. !#en Returns point multiplied by given factor.
  1559. !#zh 向量缩放。
  1560. @param point point
  1561. @param floatVar floatVar
  1562. @example
  1563. ```js
  1564. cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
  1565. ```
  1566. */
  1567. export function pMult(point: Vec2, floatVar: number): Vec2;
  1568. /**
  1569. !#en Calculates midpoint between two points.
  1570. !#zh 两个向量之间的中心点。
  1571. @param v1 v1
  1572. @param v2 v2
  1573. @example
  1574. ```js
  1575. cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
  1576. ```
  1577. */
  1578. export function pMidpoint(v1: Vec2, v2: Vec2): Vec2;
  1579. /**
  1580. !#en Calculates dot product of two points.
  1581. !#zh 两个向量之间进行点乘。
  1582. @param v1 v1
  1583. @param v2 v2
  1584. @example
  1585. ```js
  1586. cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
  1587. ```
  1588. */
  1589. export function pDot(v1: Vec2, v2: Vec2): number;
  1590. /**
  1591. !#en Calculates cross product of two points.
  1592. !#zh 两个向量之间进行叉乘。
  1593. @param v1 v1
  1594. @param v2 v2
  1595. @example
  1596. ```js
  1597. cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
  1598. ```
  1599. */
  1600. export function pCross(v1: Vec2, v2: Vec2): number;
  1601. /**
  1602. !#en Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.
  1603. !#zh 返回逆时针旋转 90 度后的新向量。
  1604. @param point point
  1605. @example
  1606. ```js
  1607. cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
  1608. ```
  1609. */
  1610. export function pPerp(point: Vec2): Vec2;
  1611. /**
  1612. !#en Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.
  1613. !#zh 将指定向量顺时针旋转 90 度并返回。
  1614. @param point point
  1615. @example
  1616. ```js
  1617. cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
  1618. ```
  1619. */
  1620. export function pRPerp(point: Vec2): Vec2;
  1621. /**
  1622. !#en Calculates the projection of v1 over v2.
  1623. !#zh 返回 v1 在 v2 上的投影向量。
  1624. @param v1 v1
  1625. @param v2 v2
  1626. @example
  1627. ```js
  1628. var v1 = cc.v2(20, 20);
  1629. var v2 = cc.v2(5, 5);
  1630. cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
  1631. ```
  1632. */
  1633. export function pProject(v1: Vec2, v2: Vec2): Vec2;
  1634. /**
  1635. !#en Calculates the square length of a cc.Vec2 (not calling sqrt() ).
  1636. !#zh 返回指定向量长度的平方。
  1637. @param v v
  1638. @example
  1639. ```js
  1640. cc.pLengthSQ(cc.v2(20, 20)); // 800;
  1641. ```
  1642. */
  1643. export function pLengthSQ(v: Vec2): number;
  1644. /**
  1645. !#en Calculates the square distance between two points (not calling sqrt() ).
  1646. !#zh 返回两个点之间距离的平方。
  1647. @param point1 point1
  1648. @param point2 point2
  1649. @example
  1650. ```js
  1651. var point1 = cc.v2(20, 20);
  1652. var point2 = cc.v2(5, 5);
  1653. cc.pDistanceSQ(point1, point2); // 450;
  1654. ```
  1655. */
  1656. export function pDistanceSQ(point1: Vec2, point2: Vec2): number;
  1657. /**
  1658. !#en Calculates distance between point an origin.
  1659. !#zh 返回指定向量的长度.
  1660. @param v v
  1661. @example
  1662. ```js
  1663. cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
  1664. ```
  1665. */
  1666. export function pLength(v: Vec2): number;
  1667. /**
  1668. !#en Calculates the distance between two points.
  1669. !#zh 返回指定 2 个向量之间的距离。
  1670. @param v1 v1
  1671. @param v2 v2
  1672. @example
  1673. ```js
  1674. var v1 = cc.v2(20, 20);
  1675. var v2 = cc.v2(5, 5);
  1676. cc.pDistance(v1, v2); // 21.213203435596427;
  1677. ```
  1678. */
  1679. export function pDistance(v1: Vec2, v2: Vec2): number;
  1680. /**
  1681. !#en Returns this vector with a magnitude of 1.
  1682. !#zh 返回一个长度为 1 的标准化过后的向量。
  1683. @param v v
  1684. @example
  1685. ```js
  1686. cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  1687. ```
  1688. */
  1689. export function pNormalize(v: Vec2): Vec2;
  1690. /**
  1691. !#en Converts radians to a normalized vector.
  1692. !#zh 将弧度转换为一个标准化后的向量,返回坐标 x = cos(a) , y = sin(a)。
  1693. @param a a
  1694. @example
  1695. ```js
  1696. cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
  1697. ```
  1698. */
  1699. export function pForAngle(a: number): Vec2;
  1700. /**
  1701. !#en Converts a vector to radians.
  1702. !#zh 返回指定向量的弧度。
  1703. @param v v
  1704. @example
  1705. ```js
  1706. cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
  1707. ```
  1708. */
  1709. export function pToAngle(v: Vec2): number;
  1710. /**
  1711. !#en Clamp a value between from and to.
  1712. !#zh
  1713. 限定浮点数的最大最小值。<br/>
  1714. 数值大于 max_inclusive 则返回 max_inclusive。<br/>
  1715. 数值小于 min_inclusive 则返回 min_inclusive。<br/>
  1716. 否则返回自身。
  1717. @param value value
  1718. @param min_inclusive min_inclusive
  1719. @param max_inclusive max_inclusive
  1720. @example
  1721. ```js
  1722. var v1 = cc.clampf(20, 0, 20); // 20;
  1723. var v2 = cc.clampf(-1, 0, 20); // 0;
  1724. var v3 = cc.clampf(10, 0, 20); // 10;
  1725. ```
  1726. */
  1727. export function clampf(value: number, min_inclusive: number, max_inclusive: number): number;
  1728. /**
  1729. !#en Clamp a value between 0 and 1.
  1730. !#zh 限定浮点数的取值范围为 0 ~ 1 之间。
  1731. @param value value
  1732. @example
  1733. ```js
  1734. var v1 = cc.clampf(20); // 1;
  1735. var v2 = cc.clampf(-1); // 0;
  1736. var v3 = cc.clampf(0.5); // 0.5;
  1737. ```
  1738. */
  1739. export function clamp01(value: number): number;
  1740. /**
  1741. !#en Clamp a point between from and to.
  1742. !#zh
  1743. 返回指定限制区域后的向量。<br/>
  1744. 向量大于 max_inclusive 则返回 max_inclusive。<br/>
  1745. 向量小于 min_inclusive 则返回 min_inclusive。<br/>
  1746. 否则返回自身。
  1747. @param p p
  1748. @param min_inclusive min_inclusive
  1749. @param max_inclusive max_inclusive
  1750. @example
  1751. ```js
  1752. var min_inclusive = cc.v2(0, 0);
  1753. var max_inclusive = cc.v2(20, 20);
  1754. var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
  1755. var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
  1756. var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
  1757. ```
  1758. */
  1759. export function pClamp(p: Vec2, min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
  1760. /**
  1761. !#en Quickly convert cc.Size to a cc.Vec2.
  1762. !#zh 快速转换 cc.Size 为 cc.Vec2。
  1763. @param s s
  1764. @example
  1765. ```js
  1766. cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
  1767. ```
  1768. */
  1769. export function pFromSize(s: Size): Vec2;
  1770. /**
  1771. !#en
  1772. Run a math operation function on each point component <br />
  1773. Math.abs, Math.fllor, Math.ceil, Math.round.
  1774. !#zh 通过运行指定的数学运算函数来计算指定的向量。
  1775. @param p p
  1776. @param opFunc opFunc
  1777. @example
  1778. ```js
  1779. cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
  1780. ```
  1781. */
  1782. export function pCompOp(p: Vec2, opFunc: Function): Vec2;
  1783. /**
  1784. !#en
  1785. Linear Interpolation between two points a and b.<br />
  1786. alpha == 0 ? a <br />
  1787. alpha == 1 ? b <br />
  1788. otherwise a value between a..b.
  1789. !#zh
  1790. 两个点 A 和 B 之间的线性插值。 <br />
  1791. alpha == 0 ? a <br />
  1792. alpha == 1 ? b <br />
  1793. 否则这个数值在 a ~ b 之间。
  1794. @param a a
  1795. @param b b
  1796. @param alpha alpha
  1797. @example
  1798. ```js
  1799. cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
  1800. ```
  1801. */
  1802. export function pLerp(a: Vec2, b: Vec2, alpha: number): Vec2;
  1803. /**
  1804. !#en TODO
  1805. !#zh
  1806. 近似判断两个点是否相等。<br/>
  1807. 判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
  1808. @param a a
  1809. @param b b
  1810. @param variance variance
  1811. @example
  1812. ```js
  1813. var a = cc.v2(20, 20);
  1814. var b = cc.v2(5, 5);
  1815. var b1 = cc.pFuzzyEqual(a, b, 10); // false;
  1816. var b2 = cc.pFuzzyEqual(a, b, 18); // true;
  1817. ```
  1818. */
  1819. export function pFuzzyEqual(a: Vec2, b: Vec2, variance: number): boolean;
  1820. /**
  1821. !#en Multiplies a nd b components, a.x*b.x, a.y*b.y.
  1822. !#zh 计算两个向量的每个分量的乘积, a.x * b.x, a.y * b.y。
  1823. @param a a
  1824. @param b b
  1825. @example
  1826. ```js
  1827. cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
  1828. ```
  1829. */
  1830. export function pCompMult(a: Vec2, b: Vec2): Vec2;
  1831. /**
  1832. !#en TODO
  1833. !#zh 返回两个向量之间带正负号的弧度。
  1834. @param a a
  1835. @param b b
  1836. */
  1837. export function pAngleSigned(a: Vec2, b: Vec2): number;
  1838. /**
  1839. !#en TODO
  1840. !#zh 获取当前向量与指定向量之间的弧度角。
  1841. @param a a
  1842. @param b b
  1843. */
  1844. export function pAngle(a: Vec2, b: Vec2): number;
  1845. /**
  1846. !#en Rotates a point counter clockwise by the angle around a pivot.
  1847. !#zh 返回给定向量围绕指定轴心顺时针旋转一定弧度后的结果。
  1848. @param v v is the point to rotate
  1849. @param pivot pivot is the pivot, naturally
  1850. @param angle angle is the angle of rotation cw in radians
  1851. */
  1852. export function pRotateByAngle(v: Vec2, pivot: Vec2, angle: number): Vec2;
  1853. /**
  1854. !#en
  1855. A general line-line intersection test
  1856. indicating successful intersection of a line<br />
  1857. note that to truly test intersection for segments we have to make<br />
  1858. sure that s & t lie within [0..1] and for rays, make sure s & t > 0<br />
  1859. the hit point is p3 + t * (p4 - p3);<br />
  1860. the hit point also is p1 + s * (p2 - p1);
  1861. !#zh
  1862. 返回 A 为起点 B 为终点线段 1 所在直线和 C 为起点 D 为终点线段 2 所在的直线是否相交,<br />
  1863. 如果相交返回 true,反之则为 false,参数 retP 是返回交点在线段 1、线段 2 上的比例。
  1864. @param A A is the startpoint for the first line P1 = (p1 - p2).
  1865. @param B B is the endpoint for the first line P1 = (p1 - p2).
  1866. @param C C is the startpoint for the second line P2 = (p3 - p4).
  1867. @param D D is the endpoint for the second line P2 = (p3 - p4).
  1868. @param retP retP.x is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)), <br />
  1869. retP.y is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)).
  1870. */
  1871. export function pLineIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2, retP: Vec2): boolean;
  1872. /**
  1873. !#en ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.
  1874. !#zh 返回线段 A - B 和线段 C - D 是否相交。
  1875. @param A A
  1876. @param B B
  1877. @param C C
  1878. @param D D
  1879. */
  1880. export function pSegmentIntersect(A: Vec2, B: Vec2, C: Vec2, D: Vec2): boolean;
  1881. /**
  1882. !#en ccpIntersectPoint return the intersection point of line A-B, C-D.
  1883. !#zh 返回线段 A - B 和线段 C - D 的交点。
  1884. @param A A
  1885. @param B B
  1886. @param C C
  1887. @param D D
  1888. */
  1889. export function pIntersectPoint(A: Vec2, B: Vec2, C: Vec2, D: Vec2): Vec2;
  1890. /**
  1891. !#en check to see if both points are equal.
  1892. !#zh 检查指定的 2 个向量是否相等。
  1893. @param A A ccp a
  1894. @param B B ccp b to be compared
  1895. */
  1896. export function pSameAs(A: Vec2, B: Vec2): boolean;
  1897. /**
  1898. !#en sets the position of the point to 0.
  1899. !#zh 设置指定向量归 0。
  1900. @param v v
  1901. */
  1902. export function pZeroIn(v: Vec2): void;
  1903. /**
  1904. !#en copies the position of one point to another.
  1905. !#zh 令 v1 向量等同于 v2。
  1906. @param v1 v1
  1907. @param v2 v2
  1908. */
  1909. export function pIn(v1: Vec2, v2: Vec2): void;
  1910. /**
  1911. !#en multiplies the point with the given factor (inplace).
  1912. !#zh 向量缩放,结果保存到第一个向量。
  1913. @param point point
  1914. @param floatVar floatVar
  1915. */
  1916. export function pMultIn(point: Vec2, floatVar: number): void;
  1917. /**
  1918. !#en subtracts one point from another (inplace).
  1919. !#zh 向量减法,结果保存到第一个向量。
  1920. @param v1 v1
  1921. @param v2 v2
  1922. */
  1923. export function pSubIn(v1: Vec2, v2: Vec2): void;
  1924. /**
  1925. !#en adds one point to another (inplace).
  1926. !#zh 向量加法,结果保存到第一个向量。
  1927. @param v1 v1
  1928. @param v2 v2
  1929. */
  1930. export function pAddIn(v1: Vec2, v2: Vec2): void;
  1931. /**
  1932. !#en normalizes the point (inplace).
  1933. !#zh 规范化 v 向量,设置 v 向量长度为 1。
  1934. @param v v
  1935. */
  1936. export function pNormalizeIn(v: Vec2): void;
  1937. /**
  1938. !#en
  1939. The convenience method to create a new Rect.
  1940. see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1941. !#zh
  1942. 该方法用来快速创建一个新的矩形。{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
  1943. @param x x
  1944. @param y y
  1945. @param w w
  1946. @param h h
  1947. @example
  1948. ```js
  1949. var a = new cc.Rect(0 , 0, 10, 0);
  1950. ```
  1951. */
  1952. export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
  1953. /**
  1954. !#en Check whether a rect's value equals to another.
  1955. !#zh 判断两个矩形是否相等。
  1956. @param rect1 rect1
  1957. @param rect2 rect2
  1958. @example
  1959. ```js
  1960. var a = new cc.Rect(0, 0, 10, 10);
  1961. var b = new cc.Rect(0, 0, 5, 5);
  1962. cc.rectEqualToRect(a, b); // false;
  1963. var c = new cc.Rect(0, 0, 5, 5);
  1964. cc.rectEqualToRect(b, c); // true;
  1965. ```
  1966. */
  1967. export function rectEqualToRect(rect1: Rect, rect2: Rect): boolean;
  1968. /**
  1969. !#en Check whether the rect1 contains rect2.
  1970. !#zh
  1971. 检查 rect1 矩形是否包含 rect2 矩形。 <br/>
  1972. 注意:如果要允许 rect1 和 rect2 的边界重合,应该用 cc.rectOverlapsRect
  1973. @param rect1 rect1
  1974. @param rect2 rect2
  1975. @example
  1976. ```js
  1977. var a = new cc.Rect(0, 0, 20, 20);
  1978. var b = new cc.Rect(10, 10, 20, 20);
  1979. cc.rectContainsRect(a, b); // true;
  1980. ```
  1981. */
  1982. export function rectContainsRect(rect1: Rect, rect2: Rect): boolean;
  1983. /**
  1984. !#en Returns the rightmost x-value of a rect.
  1985. !#zh 返回矩形在 x 轴上的最大值
  1986. @param rect rect
  1987. @example
  1988. ```js
  1989. var a = new cc.Rect(10, 0, 20, 20);
  1990. cc.rectGetMaxX(a); // 30;
  1991. ```
  1992. */
  1993. export function rectGetMaxX(rect: Rect): number;
  1994. /**
  1995. !#en Return the midpoint x-value of a rect.
  1996. !#zh 返回矩形在 x 轴上的中点。
  1997. @param rect rect
  1998. @example
  1999. ```js
  2000. var a = new cc.Rect(10, 0, 20, 20);
  2001. cc.rectGetMidX(a); // 20;
  2002. ```
  2003. */
  2004. export function rectGetMidX(rect: Rect): number;
  2005. /**
  2006. !#en Returns the leftmost x-value of a rect.
  2007. !#zh 返回矩形在 x 轴上的最小值。
  2008. @param rect rect
  2009. @example
  2010. ```js
  2011. var a = new cc.Rect(10, 0, 20, 20);
  2012. cc.rectGetMinX(a); // 10;
  2013. ```
  2014. */
  2015. export function rectGetMinX(rect: Rect): number;
  2016. /**
  2017. !#en Return the topmost y-value of a rect.
  2018. !#zh 返回矩形在 y 轴上的最大值。
  2019. @param rect rect
  2020. @example
  2021. ```js
  2022. var a = new cc.Rect(0, 10, 20, 20);
  2023. cc.rectGetMaxY(a); // 30;
  2024. ```
  2025. */
  2026. export function rectGetMaxY(rect: Rect): number;
  2027. /**
  2028. !#en Return the midpoint y-value of `rect'.
  2029. !#zh 返回矩形在 y 轴上的中点。
  2030. @param rect rect
  2031. @example
  2032. ```js
  2033. var a = new cc.Rect(0, 10, 20, 20);
  2034. cc.rectGetMidY(a); // 20;
  2035. ```
  2036. */
  2037. export function rectGetMidY(rect: Rect): number;
  2038. /**
  2039. !#en Return the bottommost y-value of a rect.
  2040. !#zh 返回矩形在 y 轴上的最小值。
  2041. @param rect rect
  2042. @example
  2043. ```js
  2044. var a = new cc.Rect(0, 10, 20, 20);
  2045. cc.rectGetMinY(a); // 10;
  2046. ```
  2047. */
  2048. export function rectGetMinY(rect: Rect): number;
  2049. /**
  2050. !#en Check whether a rect contains a point.
  2051. !#zh 检查一个矩形是否包含某个坐标点。
  2052. @param rect rect
  2053. @param point point
  2054. @example
  2055. ```js
  2056. var a = new cc.Rect(0, 10, 20, 20);
  2057. var b = new cc.Vec2(0, 10, 10, 10);
  2058. cc.rectContainsPoint(a, b); // true;
  2059. ```
  2060. */
  2061. export function rectContainsPoint(rect: Rect, point: Vec2): boolean;
  2062. /**
  2063. !#en Check whether a rect intersect with another.
  2064. !#zh 检查一个矩形是否与另一个相交。
  2065. @param rectA rectA
  2066. @param rectB rectB
  2067. @example
  2068. ```js
  2069. var a = new cc.Rect(0, 10, 20, 20);
  2070. var b = new cc.Rect(0, 10, 10, 10);
  2071. cc.rectIntersectsRect(a, b); // true;
  2072. ```
  2073. */
  2074. export function rectIntersectsRect(rectA: Rect, rectB: Rect): boolean;
  2075. /**
  2076. !#en Check whether a rect overlaps another.
  2077. !#zh 检查一个矩形是否重叠另一个。
  2078. @param rectA rectA
  2079. @param rectB rectB
  2080. @example
  2081. ```js
  2082. var a = new cc.Rect(0, 10, 20, 20);
  2083. var b = new cc.Rect(0, 10, 10, 10);
  2084. cc.rectOverlapsRect(a, b); // true;
  2085. ```
  2086. */
  2087. export function rectOverlapsRect(rectA: Rect, rectB: Rect): boolean;
  2088. /**
  2089. !#en Returns the smallest rectangle that contains the two source rectangles.
  2090. !#zh 返回一个包含两个指定矩形的最小矩形。
  2091. @param rectA rectA
  2092. @param rectB rectB
  2093. @example
  2094. ```js
  2095. var a = new cc.Rect(0, 10, 20, 20);
  2096. var b = new cc.Rect(0, 10, 10, 10);
  2097. cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
  2098. ```
  2099. */
  2100. export function rectUnion(rectA: Rect, rectB: Rect): Rect;
  2101. /**
  2102. !#en Returns the overlapping portion of 2 rectangles.
  2103. !#zh 返回 2 个矩形重叠的部分。
  2104. @param rectA rectA
  2105. @param rectB rectB
  2106. @example
  2107. ```js
  2108. var a = new cc.Rect(0, 10, 20, 20);
  2109. var b = new cc.Rect(0, 10, 10, 10);
  2110. cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
  2111. ```
  2112. */
  2113. export function rectIntersection(rectA: Rect, rectB: Rect): Rect;
  2114. /**
  2115. !#en
  2116. Helper function that creates a cc.Size.<br/>
  2117. Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
  2118. !#zh
  2119. 创建一个 cc.Size 对象的帮助函数。<br/>
  2120. 注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
  2121. @param w width or a size object
  2122. @param h height
  2123. @example
  2124. ```js
  2125. var size1 = cc.size();
  2126. var size2 = cc.size(100,100);
  2127. var size3 = cc.size(size2);
  2128. var size4 = cc.size({width: 100, height: 100});
  2129. ```
  2130. */
  2131. export function size(w: number|Size, h?: number): Size;
  2132. /**
  2133. !#en Check whether a point's value equals to another.
  2134. !#zh 检查 Size 对象是否等于另一个。
  2135. @param size1 size1
  2136. @param size2 size2
  2137. @example
  2138. ```js
  2139. var a = new cc.size(10, 10);
  2140. var b = new cc.size(10, 10);
  2141. cc.sizeEqualToSize(a, b);// return true;
  2142. var b = new cc.size(5, 10);
  2143. cc.sizeEqualToSize(a, b);// return false;
  2144. ```
  2145. */
  2146. export function sizeEqualToSize(size1: Size, size2: Size): boolean;
  2147. export function V3F_C4B_T2F_QuadZero(): V3F_C4B_T2F_Quad;
  2148. /**
  2149. @param sourceQuad sourceQuad
  2150. */
  2151. export function V3F_C4B_T2F_QuadCopy(sourceQuad: V3F_C4B_T2F_Quad): V3F_C4B_T2F_Quad;
  2152. /**
  2153. @param sourceQuads sourceQuads
  2154. */
  2155. export function V3F_C4B_T2F_QuadsCopy(sourceQuads: any[]): any[];
  2156. /**
  2157. !#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2158. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2159. @param x x
  2160. @param y y
  2161. @example
  2162. ```js
  2163. var v1 = cc.v2();
  2164. var v2 = cc.v2(0, 0);
  2165. var v3 = cc.v2(v2);
  2166. var v4 = cc.v2({x: 100, y: 100});
  2167. ```
  2168. */
  2169. export function v2(x?: number|any, y?: number): Vec2;
  2170. /**
  2171. !#en The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
  2172. !#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
  2173. @param x a Number or a size object
  2174. @param y y
  2175. @example
  2176. ```js
  2177. var point1 = cc.p();
  2178. var point2 = cc.p(100, 100);
  2179. var point3 = cc.p(point2);
  2180. var point4 = cc.p({x: 100, y: 100});
  2181. ```
  2182. */
  2183. export function p(x?: number|any, y?: number): Vec2;
  2184. /**
  2185. !#en Check whether a point's value equals to another.
  2186. !#zh 判断两个向量是否相等。
  2187. @param point1 point1
  2188. @param point2 point2
  2189. */
  2190. export function pointEqualToPoint(point1: Vec2, point2: Vec2): boolean;
  2191. /** !#en Enum for debug modes.
  2192. !#zh 调试模式 */
  2193. export enum DebugMode {
  2194. NONE = 0,
  2195. INFO = 0,
  2196. WARN = 0,
  2197. ERROR = 0,
  2198. INFO_FOR_WEB_PAGE = 0,
  2199. WARN_FOR_WEB_PAGE = 0,
  2200. ERROR_FOR_WEB_PAGE = 0,
  2201. }
  2202. /** !#en Base class cc.Action for action classes.
  2203. !#zh Action 类是所有动作类型的基类。 */
  2204. export class Action {
  2205. /**
  2206. !#en
  2207. to copy object with deep copy.
  2208. returns a clone of action.
  2209. !#zh 返回一个克隆的动作。
  2210. */
  2211. clone(): Action;
  2212. /**
  2213. !#en
  2214. return true if the action has finished.
  2215. !#zh 如果动作已完成就返回 true。
  2216. */
  2217. isDone(): boolean;
  2218. /**
  2219. !#en get the target.
  2220. !#zh 获取当前目标节点。
  2221. */
  2222. getTarget(): Node;
  2223. /**
  2224. !#en The action will modify the target properties.
  2225. !#zh 设置目标节点。
  2226. @param target target
  2227. */
  2228. setTarget(target: Node): void;
  2229. /**
  2230. !#en get the original target.
  2231. !#zh 获取原始目标节点。
  2232. */
  2233. getOriginalTarget(): Node;
  2234. /**
  2235. !#en get tag number.
  2236. !#zh 获取用于识别动作的标签。
  2237. */
  2238. getTag(): number;
  2239. /**
  2240. !#en set tag number.
  2241. !#zh 设置标签,用于识别动作。
  2242. @param tag tag
  2243. */
  2244. setTag(tag: number): void;
  2245. /** !#en Default Action tag.
  2246. !#zh 默认动作标签。 */
  2247. static TAG_INVALID: number;
  2248. }
  2249. /** !#en
  2250. Base class actions that do have a finite time duration. <br/>
  2251. Possible actions: <br/>
  2252. - An action with a duration of 0 seconds. <br/>
  2253. - An action with a duration of 35.5 seconds.
  2254. Infinite time actions are valid
  2255. !#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
  2256. export class FiniteTimeAction extends Action {
  2257. /**
  2258. !#en get duration of the action. (seconds).
  2259. !#zh 获取动作以秒为单位的持续时间。
  2260. */
  2261. getDuration(): number;
  2262. /**
  2263. !#en set duration of the action. (seconds).
  2264. !#zh 设置动作以秒为单位的持续时间。
  2265. @param duration duration
  2266. */
  2267. setDuration(duration: number): void;
  2268. /**
  2269. !#en
  2270. Returns a reversed action. <br />
  2271. For example: <br />
  2272. - The action will be x coordinates of 0 move to 100. <br />
  2273. - The reversed action will be x of 100 move to 0.
  2274. - Will be rewritten
  2275. !#zh 返回一个新的动作,执行与原动作完全相反的动作。
  2276. */
  2277. reverse(): void;
  2278. /**
  2279. !#en
  2280. to copy object with deep copy.
  2281. returns a clone of action.
  2282. !#zh 返回一个克隆的动作。
  2283. */
  2284. clone(): FiniteTimeAction;
  2285. }
  2286. /** !#en Base class for Easing actions.
  2287. !#zh 所有缓动动作基类,用于修饰 ActionInterval。 */
  2288. export class ActionEase extends ActionInterval {
  2289. }
  2290. /** !#en Base class for Easing actions with rate parameters
  2291. !#zh 拥有速率属性的缓动动作基类。 */
  2292. export class EaseRateAction extends ActionEase {
  2293. }
  2294. /** !#en Ease Elastic abstract class.
  2295. !#zh 弹性缓动动作基类。 */
  2296. export class EaseElastic extends ActionEase {
  2297. }
  2298. /** !#en cc.EaseBounce abstract class.
  2299. !#zh 反弹缓动动作基类。 */
  2300. export class EaseBounce extends ActionEase {
  2301. }
  2302. /** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
  2303. !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
  2304. export class ActionInstant extends FiniteTimeAction {
  2305. }
  2306. /** !#en
  2307. <p> An interval action is an action that takes place within a certain period of time. <br/>
  2308. It has an start time, and a finish time. The finish time is the parameter<br/>
  2309. duration plus the start time.</p>
  2310. <p>These CCActionInterval actions have some interesting properties, like:<br/>
  2311. - They can run normally (default) <br/>
  2312. - They can run reversed with the reverse method <br/>
  2313. - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
  2314. <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
  2315. then running it again in Reverse mode. </p>
  2316. !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。 */
  2317. export class ActionInterval extends FiniteTimeAction {
  2318. /**
  2319. !#en Implementation of ease motion.
  2320. !#zh 缓动运动。
  2321. @param easeObj easeObj
  2322. @example
  2323. ```js
  2324. action.easing(cc.easeIn(3.0));
  2325. ```
  2326. */
  2327. easing(easeObj: any): ActionInterval;
  2328. /**
  2329. !#en
  2330. Repeats an action a number of times.
  2331. To repeat an action forever use the CCRepeatForever action.
  2332. !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
  2333. @param times times
  2334. */
  2335. repeat(times: number): ActionInterval;
  2336. /**
  2337. !#en
  2338. Repeats an action for ever. <br/>
  2339. To repeat the an action for a limited number of times use the Repeat action. <br/>
  2340. !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
  2341. */
  2342. repeatForever(): ActionInterval;
  2343. }
  2344. /** !#en
  2345. cc.ActionManager is a class that can manage actions.<br/>
  2346. Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
  2347. which uses this class's singleton object.
  2348. But there are some cases where you might need to use this class. <br/>
  2349. Examples:<br/>
  2350. - When you want to run an action where the target is different from a CCNode.<br/>
  2351. - When you want to pause / resume the actions<br/>
  2352. !#zh
  2353. cc.ActionManager 是可以管理动作的单例类。<br/>
  2354. 通常你并不需要直接使用这个类,99%的情况您将使用 CCNode 的接口。<br/>
  2355. 但也有一些情况下,您可能需要使用这个类。 <br/>
  2356. 例如:
  2357. - 当你想要运行一个动作,但目标不是 CCNode 类型时。 <br/>
  2358. - 当你想要暂停/恢复动作时。 <br/> */
  2359. export class ActionManager {
  2360. /**
  2361. !#en
  2362. Adds an action with a target.<br/>
  2363. If the target is already present, then the action will be added to the existing target.
  2364. 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.
  2365. When the target is paused, the queued actions won't be 'ticked'.
  2366. !#zh
  2367. 增加一个动作,同时还需要提供动作的目标对象,目标对象是否暂停作为参数。<br/>
  2368. 如果目标已存在,动作将会被直接添加到现有的节点中。<br/>
  2369. 如果目标不存在,将为这一目标创建一个新的实例,并将动作添加进去。<br/>
  2370. 当目标状态的 paused 为 true,动作将不会被执行
  2371. @param action action
  2372. @param target target
  2373. @param paused paused
  2374. */
  2375. addAction(action: Action, target: Node, paused: boolean): void;
  2376. /**
  2377. !#en Removes all actions from all the targets.
  2378. !#zh 移除所有对象的所有动作。
  2379. */
  2380. removeAllActions(): void;
  2381. /**
  2382. !#en
  2383. Removes all actions from a certain target. <br/>
  2384. All the actions that belongs to the target will be removed.
  2385. !#zh
  2386. 移除指定对象上的所有动作。<br/>
  2387. 属于该目标的所有的动作将被删除。
  2388. @param target target
  2389. @param forceDelete forceDelete
  2390. */
  2391. removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
  2392. /**
  2393. !#en Removes an action given an action reference.
  2394. !#zh 移除指定的动作。
  2395. @param action action
  2396. */
  2397. removeAction(action: Action): void;
  2398. /**
  2399. !#en Removes an action given its tag and the target.
  2400. !#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
  2401. @param tag tag
  2402. @param target target
  2403. */
  2404. removeActionByTag(tag: number, target: Node): void;
  2405. /**
  2406. !#en Gets an action given its tag an a target.
  2407. !#zh 通过目标对象和标签获取一个动作。
  2408. @param tag tag
  2409. @param target target
  2410. */
  2411. getActionByTag(tag: number, target: Node): Action;
  2412. /**
  2413. !#en
  2414. Returns the numbers of actions that are running in a certain target. <br/>
  2415. Composable actions are counted as 1 action. <br/>
  2416. Example: <br/>
  2417. - If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  2418. - If you are running 7 Sequences of 2 actions, it will return 7.
  2419. !#zh
  2420. 返回指定对象下所有正在运行的动作数量。 <br/>
  2421. 组合动作被算作一个动作。<br/>
  2422. 例如:<br/>
  2423. - 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。<br/>
  2424. - 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。<br/>
  2425. @param target target
  2426. */
  2427. getNumberOfRunningActionsInTarget(target: Node): number;
  2428. /**
  2429. !#en Pauses the target: all running actions and newly added actions will be paused.
  2430. !#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
  2431. @param target target
  2432. */
  2433. pauseTarget(target: Node): void;
  2434. /**
  2435. !#en Resumes the target. All queued actions will be resumed.
  2436. !#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
  2437. @param target target
  2438. */
  2439. resumeTarget(target: Node): void;
  2440. /**
  2441. !#en Pauses all running actions, returning a list of targets whose actions were paused.
  2442. !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
  2443. */
  2444. pauseAllRunningActions(): any[];
  2445. /**
  2446. !#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
  2447. !#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
  2448. @param targetsToResume targetsToResume
  2449. */
  2450. resumeTargets(targetsToResume: any[]): void;
  2451. /**
  2452. !#en Pause a set of targets.
  2453. !#zh 暂停一组指定对象。
  2454. @param targetsToPause targetsToPause
  2455. */
  2456. pauseTargets(targetsToPause: any[]): void;
  2457. /**
  2458. !#en
  2459. purges the shared action manager. It releases the retained instance. <br/>
  2460. because it uses this, so it can not be static.
  2461. !#zh
  2462. 清除共用的动作管理器。它释放了持有的实例。 <br/>
  2463. 因为它使用 this,因此它不能是静态的。
  2464. */
  2465. purgeSharedManager(): void;
  2466. /**
  2467. !#en The ActionManager update。
  2468. !#zh ActionManager 主循环。
  2469. @param dt delta time in seconds
  2470. */
  2471. update(dt: number): void;
  2472. }
  2473. /** !#en
  2474. <p>
  2475. ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
  2476. cc.director is a singleton object which manage your game's logic flow.<br/>
  2477. Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
  2478. the standard way to use it is by calling:<br/>
  2479. - cc.director.methodName(); <br/>
  2480. It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
  2481. <br/>
  2482. The cc.director is also responsible for:<br/>
  2483. - initializing the OpenGL context<br/>
  2484. - setting the OpenGL pixel format (default on is RGB565)<br/>
  2485. - setting the OpenGL buffer depth (default on is 0-bit)<br/>
  2486. - setting the color for clear screen (default one is BLACK)<br/>
  2487. - setting the projection (default one is 3D)<br/>
  2488. - setting the orientation (default one is Portrait)<br/>
  2489. <br/>
  2490. <br/>
  2491. The cc.director also sets the default OpenGL context:<br/>
  2492. - GL_TEXTURE_2D is enabled<br/>
  2493. - GL_VERTEX_ARRAY is enabled<br/>
  2494. - GL_COLOR_ARRAY is enabled<br/>
  2495. - GL_TEXTURE_COORD_ARRAY is enabled<br/>
  2496. </p>
  2497. <p>
  2498. cc.director also synchronizes timers with the refresh rate of the display.<br/>
  2499. Features and Limitations:<br/>
  2500. - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
  2501. - Only supports animation intervals of 1/60 1/30 & 1/15<br/>
  2502. </p>
  2503. !#zh
  2504. <p>
  2505. 注意:用 cc.director 代替 cc.Director。<br/>
  2506. cc.director 一个管理你的游戏的逻辑流程的单例对象。<br/>
  2507. 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,<br/>
  2508. 使用它的标准方法是通过调用:<br/>
  2509. - cc.director.methodName();
  2510. <br/>
  2511. 它创建和处理主窗口并且管理什么时候执行场景。<br/>
  2512. <br/>
  2513. cc.director 还负责:<br/>
  2514. - 初始化 OpenGL 环境。<br/>
  2515. - 设置OpenGL像素格式。(默认是 RGB565)<br/>
  2516. - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/>
  2517. - 设置空白场景的颜色 (默认是 黑色)<br/>
  2518. - 设置投影 (默认是 3D)<br/>
  2519. - 设置方向 (默认是 Portrait)<br/>
  2520. <br/>
  2521. cc.director 设置了 OpenGL 默认环境 <br/>
  2522. - GL_TEXTURE_2D 启用。<br/>
  2523. - GL_VERTEX_ARRAY 启用。<br/>
  2524. - GL_COLOR_ARRAY 启用。<br/>
  2525. - GL_TEXTURE_COORD_ARRAY 启用。<br/>
  2526. </p>
  2527. <p>
  2528. cc.director 也同步定时器与显示器的刷新速率。
  2529. <br/>
  2530. 特点和局限性: <br/>
  2531. - 将计时器 & 渲染与显示器的刷新频率同步。<br/>
  2532. - 只支持动画的间隔 1/60 1/30 & 1/15。<br/>
  2533. </p> */
  2534. export class Director extends EventTarget {
  2535. /**
  2536. !#en
  2537. Converts an OpenGL coordinate to a view coordinate<br/>
  2538. Useful to convert node points to window points for calls such as glScissor<br/>
  2539. Implementation can be found in CCDirectorWebGL.
  2540. !#zh 将触摸点的 WebGL View 坐标转换为屏幕坐标。
  2541. @param glPoint glPoint
  2542. */
  2543. convertToUI(glPoint: Vec2): Vec2;
  2544. /**
  2545. !#en
  2546. Returns the size of the WebGL view in points.<br/>
  2547. It takes into account any possible rotation (device orientation) of the window.
  2548. !#zh 获取视图的大小,以点为单位。
  2549. */
  2550. getWinSize(): Size;
  2551. /**
  2552. !#en
  2553. Returns the size of the OpenGL view in pixels.<br/>
  2554. It takes into account any possible rotation (device orientation) of the window.<br/>
  2555. On Mac winSize and winSizeInPixels return the same value.
  2556. (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize())
  2557. !#zh
  2558. 获取视图大小,以像素为单位(这里的像素指的是资源分辨率。
  2559. 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
  2560. */
  2561. getWinSizeInPixels(): Size;
  2562. /**
  2563. !#en Returns the visible size of the running scene.
  2564. !#zh 获取运行场景的可见大小。
  2565. */
  2566. getVisibleSize(): Size;
  2567. /**
  2568. !#en Returns the visible origin of the running scene.
  2569. !#zh 获取视图在游戏内容中的坐标原点。
  2570. */
  2571. getVisibleOrigin(): Vec2;
  2572. /**
  2573. !#en Pause the director's ticker, only involve the game logic execution.
  2574. It won't pause the rendering process nor the event manager.
  2575. If you want to pause the entier game including rendering, audio and event,
  2576. please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
  2577. !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
  2578. 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
  2579. */
  2580. pause(): void;
  2581. /**
  2582. !#en
  2583. Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
  2584. The new scene will be launched immediately.
  2585. !#zh 立刻切换指定场景。
  2586. @param scene The need run scene.
  2587. @param onBeforeLoadScene The function invoked at the scene before loading.
  2588. @param onLaunched The function invoked at the scene after launch.
  2589. */
  2590. runSceneImmediate(scene: Scene, onBeforeLoadScene?: Function, onLaunched?: Function): void;
  2591. /**
  2592. !#en Loads the scene by its name.
  2593. !#zh 通过场景名称进行加载场景。
  2594. @param sceneName The name of the scene to load.
  2595. @param onLaunched callback, will be called after scene launched.
  2596. */
  2597. loadScene(sceneName: string, onLaunched?: Function): boolean;
  2598. /**
  2599. !#en
  2600. Preloads the scene to reduces loading time. You can call this method at any time you want.
  2601. After calling this method, you still need to launch the scene by `cc.director.loadScene`.
  2602. It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
  2603. yet finished, the scene will be launched after loaded automatically.
  2604. !#zh 预加载场景,你可以在任何时候调用这个方法。
  2605. 调用完后,你仍然需要通过 `cc.director.loadScene` 来启动场景,因为这个方法不会执行场景加载操作。
  2606. 就算预加载还没完成,你也可以直接调用 `cc.director.loadScene`,加载完成后场景就会启动。
  2607. @param sceneName The name of the scene to preload.
  2608. @param onLoaded callback, will be called after scene loaded.
  2609. */
  2610. preloadScene(sceneName: string, onLoaded?: (error: Error) => void): void;
  2611. /**
  2612. !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
  2613. !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
  2614. */
  2615. resume(): void;
  2616. /**
  2617. !#en
  2618. Enables or disables WebGL depth test.<br/>
  2619. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
  2620. !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
  2621. @param on on
  2622. */
  2623. setDepthTest(on: boolean): void;
  2624. /**
  2625. !#en
  2626. Set color for clear screen.<br/>
  2627. (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
  2628. !#zh
  2629. 设置场景的默认擦除颜色。<br/>
  2630. 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
  2631. @param clearColor clearColor
  2632. */
  2633. setClearColor(clearColor: Color): void;
  2634. /**
  2635. !#en
  2636. Sets an OpenGL projection.<br/>
  2637. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2638. !#zh 设置 OpenGL 投影。
  2639. @param projection projection
  2640. */
  2641. setProjection(projection: number): void;
  2642. /**
  2643. !#en
  2644. Update the view port.<br/>
  2645. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2646. !#zh 设置视窗(请不要主动调用这个接口,除非你知道你在做什么)。
  2647. */
  2648. setViewport(): void;
  2649. /**
  2650. !#en
  2651. Sets an OpenGL projection.<br/>
  2652. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2653. !#zh 获取 OpenGL 投影。
  2654. */
  2655. getProjection(): number;
  2656. /**
  2657. !#en
  2658. Enables/disables OpenGL alpha blending.<br/>
  2659. Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
  2660. !#zh 启用/禁用 透明度融合。
  2661. @param on on
  2662. */
  2663. setAlphaBlending(on: boolean): void;
  2664. /**
  2665. !#en
  2666. Returns whether or not the replaced scene will receive the cleanup message.<br/>
  2667. If the new scene is pushed, then the old scene won't receive the "cleanup" message.<br/>
  2668. If the new scene replaces the old one, the it will receive the "cleanup" message.
  2669. !#zh
  2670. 更换场景时是否接收清理消息。<br>
  2671. 如果新场景是采用 push 方式进入的,那么旧的场景将不会接收到 “cleanup” 消息。<br/>
  2672. 如果新场景取代旧的场景,它将会接收到 “cleanup” 消息。</br>
  2673. */
  2674. isSendCleanupToScene(): boolean;
  2675. /**
  2676. !#en Returns current logic Scene.
  2677. !#zh 获取当前逻辑场景。
  2678. @example
  2679. ```js
  2680. // This will help you to get the Canvas node in scene
  2681. cc.director.getScene().getChildByName('Canvas');
  2682. ```
  2683. */
  2684. getScene(): Scene;
  2685. /**
  2686. !#en Returns the FPS value.
  2687. !#zh 获取单位帧执行时间。
  2688. */
  2689. getAnimationInterval(): number;
  2690. /**
  2691. !#en Returns whether or not to display the FPS informations.
  2692. !#zh 获取是否显示 FPS 信息。
  2693. */
  2694. isDisplayStats(): boolean;
  2695. /**
  2696. !#en Sets whether display the FPS on the bottom-left corner.
  2697. !#zh 设置是否在左下角显示 FPS。
  2698. @param displayStats displayStats
  2699. */
  2700. setDisplayStats(displayStats: boolean): void;
  2701. /**
  2702. !#en Returns whether next delta time equals to zero.
  2703. !#zh 返回下一个 “delta time” 是否等于零。
  2704. */
  2705. isNextDeltaTimeZero(): boolean;
  2706. /**
  2707. !#en Returns whether or not the Director is paused.
  2708. !#zh 是否处于暂停状态。
  2709. */
  2710. isPaused(): boolean;
  2711. /**
  2712. !#en Returns how many frames were called since the director started.
  2713. !#zh 获取 director 启动以来游戏运行的总帧数。
  2714. */
  2715. getTotalFrames(): number;
  2716. /**
  2717. !#en Returns the cc.Scheduler associated with this director.
  2718. !#zh 获取和 director 相关联的 cc.Scheduler。
  2719. */
  2720. getScheduler(): Scheduler;
  2721. /**
  2722. !#en Sets the cc.Scheduler associated with this director.
  2723. !#zh 设置和 director 相关联的 cc.Scheduler。
  2724. @param scheduler scheduler
  2725. */
  2726. setScheduler(scheduler: Scheduler): void;
  2727. /**
  2728. !#en Returns the cc.ActionManager associated with this director.
  2729. !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
  2730. */
  2731. getActionManager(): ActionManager;
  2732. /**
  2733. !#en Sets the cc.ActionManager associated with this director.
  2734. !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
  2735. @param actionManager actionManager
  2736. */
  2737. setActionManager(actionManager: ActionManager): void;
  2738. /**
  2739. Returns the cc.CollisionManager associated with this director.
  2740. */
  2741. getCollisionManager(): CollisionManager;
  2742. /**
  2743. Returns the cc.PhysicsManager associated with this director.
  2744. */
  2745. getPhysicsManager(): PhysicsManager;
  2746. /**
  2747. !#en Returns the delta time since last frame.
  2748. !#zh 获取上一帧的 “delta time”。
  2749. */
  2750. getDeltaTime(): number;
  2751. /** !#en The event projection changed of cc.Director.
  2752. !#zh cc.Director 投影变化的事件。 */
  2753. static EVENT_PROJECTION_CHANGED: string;
  2754. /** !#en The event which will be triggered before loading a new scene.
  2755. !#zh 加载新场景之前所触发的事件。 */
  2756. static EVENT_BEFORE_SCENE_LOADING: string;
  2757. /** !#en The event which will be triggered before launching a new scene.
  2758. !#zh 运行新场景之前所触发的事件。 */
  2759. static EVENT_BEFORE_SCENE_LAUNCH: string;
  2760. /** !#en The event which will be triggered after launching a new scene.
  2761. !#zh 运行新场景之后所触发的事件。 */
  2762. static EVENT_AFTER_SCENE_LAUNCH: string;
  2763. /** !#en The event which will be triggered at the beginning of every frame.
  2764. !#zh 每个帧的开始时所触发的事件。 */
  2765. static EVENT_BEFORE_UPDATE: string;
  2766. /** !#en The event which will be triggered after engine and components update logic.
  2767. !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。 */
  2768. static EVENT_AFTER_UPDATE: string;
  2769. /** !#en The event which will be triggered before visiting the rendering scene graph.
  2770. !#zh 访问渲染场景树之前所触发的事件。 */
  2771. static EVENT_BEFORE_VISIT: string;
  2772. /** !#en
  2773. The event which will be triggered after visiting the rendering scene graph,
  2774. the render queue is ready but not rendered at this point.
  2775. !#zh
  2776. 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。 */
  2777. static EVENT_AFTER_VISIT: string;
  2778. /** !#en The event which will be triggered after the rendering process.
  2779. !#zh 渲染过程之后所触发的事件。 */
  2780. static EVENT_AFTER_DRAW: string;
  2781. /** Constant for 2D projection (orthogonal projection) */
  2782. static PROJECTION_2D: number;
  2783. /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
  2784. static PROJECTION_3D: number;
  2785. /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
  2786. static PROJECTION_CUSTOM: number;
  2787. /** Constant for default projection of cc.Director, default projection is 2D projection */
  2788. static PROJECTION_DEFAULT: number;
  2789. }
  2790. /** !#en cc.game is the singleton object for game related functions.
  2791. !#zh cc.game 是 Game 的实例,用来驱动整个游戏。 */
  2792. export class Game extends EventTarget {
  2793. /** !#en Event triggered when game hide to background.
  2794. Please note that this event is not 100% guaranteed to be fired on Web platform,
  2795. on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
  2796. !#zh 游戏进入后台时触发的事件。
  2797. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  2798. 在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
  2799. EVENT_HIDE: string;
  2800. /** Event triggered when game back to foreground
  2801. Please note that this event is not 100% guaranteed to be fired on Web platform,
  2802. on native platforms, it corresponds to enter foreground event.
  2803. !#zh 游戏进入前台运行时触发的事件。
  2804. 请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
  2805. 在原生平台,它对应的是应用被切换到前台事件。 */
  2806. EVENT_SHOW: string;
  2807. /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
  2808. EVENT_GAME_INITED: string;
  2809. /** Event triggered after renderer inited, at this point you will be able to use the render context */
  2810. EVENT_RENDERER_INITED: string;
  2811. /** Key of config */
  2812. CONFIG_KEY: any;
  2813. /** !#en The outer frame of the game canvas, parent of cc.container.
  2814. !#zh 游戏画布的外框,cc.container 的父类。 */
  2815. frame: any;
  2816. /** !#en The container of game canvas, equals to cc.container.
  2817. !#zh 游戏画布的容器。 */
  2818. container: HTMLDivElement;
  2819. /** !#en The canvas of the game, equals to cc._canvas.
  2820. !#zh 游戏的画布。 */
  2821. canvas: HTMLCanvasElement;
  2822. /** !#en
  2823. The current game configuration, including:<br/>
  2824. 1. debugMode<br/>
  2825. "debugMode" possible values :<br/>
  2826. 0 - No message will be printed. <br/>
  2827. 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
  2828. 2 - cc.error, cc.assert, cc.warn will print in console. <br/>
  2829. 3 - cc.error, cc.assert will print in console. <br/>
  2830. 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
  2831. 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
  2832. 6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
  2833. 2. showFPS<br/>
  2834. Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
  2835. 3. exposeClassName<br/>
  2836. Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
  2837. 4. frameRate<br/>
  2838. "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
  2839. 5. id<br/>
  2840. "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
  2841. 6. renderMode<br/>
  2842. "renderMode" sets the renderer type, only useful on web :<br/>
  2843. 0 - Automatically chosen by engine<br/>
  2844. 1 - Forced to use canvas renderer<br/>
  2845. 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
  2846. 7. scenes<br/>
  2847. "scenes" include available scenes in the current bundle.<br/>
  2848. <br/>
  2849. Please DO NOT modify this object directly, it won't have any effect.<br/>
  2850. !#zh
  2851. 当前的游戏配置,包括: <br/>
  2852. 1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略) <br/>
  2853. "debugMode" 各种设置选项的意义。 <br/>
  2854. 0 - 没有消息被打印出来。 <br/>
  2855. 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。 <br/>
  2856. 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。 <br/>
  2857. 3 - cc.error,cc.assert 将打印在 console 中。 <br/>
  2858. 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2859. 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2860. 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。 <br/>
  2861. 2. showFPS(显示 FPS) <br/>
  2862. 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。 <br/>
  2863. 3. exposeClassName <br/>
  2864. 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。 <br/>
  2865. 4. frameRate (帧率) <br/>
  2866. “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。 <br/>
  2867. 5. id <br/>
  2868. "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。 <br/>
  2869. 6. renderMode(渲染模式) <br/>
  2870. “renderMode” 设置渲染器类型,仅适用于 web 端: <br/>
  2871. 0 - 通过引擎自动选择。 <br/>
  2872. 1 - 强制使用 canvas 渲染。
  2873. 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。 <br/>
  2874. 7. scenes <br/>
  2875. “scenes” 当前包中可用场景。 <br/>
  2876. <br/>
  2877. 注意:请不要直接修改这个对象,它不会有任何效果。 */
  2878. config: any;
  2879. /**
  2880. !#en Callback when the scripts of engine have been load.
  2881. !#zh 当引擎完成启动后的回调函数。
  2882. */
  2883. onStart(): void;
  2884. /**
  2885. !#en Set frameRate of game.
  2886. !#zh 设置游戏帧率。
  2887. @param frameRate frameRate
  2888. */
  2889. setFrameRate(frameRate: number): void;
  2890. /**
  2891. !#en Run the game frame by frame.
  2892. !#zh 执行一帧游戏循环。
  2893. */
  2894. step(): void;
  2895. /**
  2896. !#en Pause the game main loop. This will pause:
  2897. game logic execution, rendering process, event manager, background music and all audio effects.
  2898. This is different with cc.director.pause which only pause the game logic execution.
  2899. !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
  2900. */
  2901. pause(): void;
  2902. /**
  2903. !#en Resume the game from pause. This will resume:
  2904. game logic execution, rendering process, event manager, background music and all audio effects.
  2905. !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
  2906. */
  2907. resume(): void;
  2908. /**
  2909. !#en Check whether the game is paused.
  2910. !#zh 判断游戏是否暂停。
  2911. */
  2912. isPaused(): boolean;
  2913. /**
  2914. !#en Restart game.
  2915. !#zh 重新开始游戏
  2916. */
  2917. restart(): void;
  2918. /**
  2919. !#en End game, it will close the game window
  2920. !#zh 退出游戏
  2921. */
  2922. end(): void;
  2923. /**
  2924. !#en Prepare game.
  2925. !#zh 准备引擎,请不要直接调用这个函数。
  2926. @param cb cb
  2927. */
  2928. prepare(cb: Function): void;
  2929. /**
  2930. !#en Run game with configuration object and onStart function.
  2931. !#zh 运行游戏,并且指定引擎配置和 onStart 的回调。
  2932. @param config Pass configuration object or onStart function
  2933. @param onStart function to be executed after game initialized
  2934. */
  2935. run(config?: any|Function, onStart?: Function): void;
  2936. /**
  2937. !#en
  2938. Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
  2939. The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
  2940. !#zh
  2941. 声明常驻根节点,该节点不会被在场景切换中被销毁。<br/>
  2942. 目标节点必须位于为层级的根节点,否则无效。
  2943. @param node The node to be made persistent
  2944. */
  2945. addPersistRootNode(node: Node): void;
  2946. /**
  2947. !#en Remove a persistent root node.
  2948. !#zh 取消常驻根节点。
  2949. @param node The node to be removed from persistent node list
  2950. */
  2951. removePersistRootNode(node: Node): void;
  2952. /**
  2953. !#en Check whether the node is a persistent root node.
  2954. !#zh 检查节点是否是常驻根节点。
  2955. @param node The node to be checked
  2956. */
  2957. isPersistRootNode(node: Node): boolean;
  2958. }
  2959. /** !#en
  2960. Class of all entities in Cocos Creator scenes.<br/>
  2961. Node also inherits from {{#crossLink "EventTarget"}}Event Target{{/crossLink}}, it permits Node to dispatch events.
  2962. For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
  2963. !#zh
  2964. Cocos Creator 场景中的所有节点类。节点也继承了 {{#crossLink "EventTarget"}}EventTarget{{/crossLink}},它允许节点发送事件。<br/>
  2965. 支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
  2966. export class Node extends _BaseNode {
  2967. /** !#en
  2968. Group index of node.<br/>
  2969. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2970. !#zh
  2971. 节点的分组索引。<br/>
  2972. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2973. groupIndex: number;
  2974. /** !#en
  2975. Group of node.<br/>
  2976. Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
  2977. !#zh
  2978. 节点的分组。<br/>
  2979. 节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。<br/> */
  2980. group: string;
  2981. /** !#en The position (x, y) of the node in its parent's coordinates.
  2982. !#zh 节点在父节点坐标系中的位置(x, y)。 */
  2983. position: Vec2;
  2984. /** !#en x axis position of node.
  2985. !#zh 节点 X 轴坐标。 */
  2986. x: number;
  2987. /** !#en y axis position of node.
  2988. !#zh 节点 Y 轴坐标。 */
  2989. y: number;
  2990. /** !#en Rotation of node.
  2991. !#zh 该节点旋转角度。 */
  2992. rotation: number;
  2993. /** !#en Rotation on x axis.
  2994. !#zh 该节点 X 轴旋转角度。 */
  2995. rotationX: number;
  2996. /** !#en Rotation on y axis.
  2997. !#zh 该节点 Y 轴旋转角度。 */
  2998. rotationY: number;
  2999. /** !#en Scale on x axis.
  3000. !#zh 节点 X 轴缩放。 */
  3001. scaleX: number;
  3002. /** !#en Scale on y axis.
  3003. !#zh 节点 Y 轴缩放。 */
  3004. scaleY: number;
  3005. /** !#en Skew x
  3006. !#zh 该节点 Y 轴倾斜角度。 */
  3007. skewX: number;
  3008. /** !#en Skew y
  3009. !#zh 该节点 X 轴倾斜角度。 */
  3010. skewY: number;
  3011. /** !#en Opacity of node, default value is 255.
  3012. !#zh 节点透明度,默认值为 255。 */
  3013. opacity: number;
  3014. /** !#en Indicate whether node's opacity value affect its child nodes, default value is true.
  3015. !#zh 节点的不透明度值是否影响其子节点,默认值为 true。 */
  3016. cascadeOpacity: boolean;
  3017. /** !#en Color of node, default value is white: (255, 255, 255).
  3018. !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
  3019. color: Color;
  3020. /** !#en Anchor point's position on x axis.
  3021. !#zh 节点 X 轴锚点位置。 */
  3022. anchorX: number;
  3023. /** !#en Anchor point's position on y axis.
  3024. !#zh 节点 Y 轴锚点位置。 */
  3025. anchorY: number;
  3026. /** !#en Width of node.
  3027. !#zh 节点宽度。 */
  3028. width: number;
  3029. /** !#en Height of node.
  3030. !#zh 节点高度。 */
  3031. height: number;
  3032. /** !#en Z order in depth which stands for the drawing order.
  3033. !#zh 该节点渲染排序的 Z 轴深度。 */
  3034. zIndex: number;
  3035. /**
  3036. @param name name
  3037. */
  3038. constructor(name?: string);
  3039. /**
  3040. !#en
  3041. Register a callback of a specific event type on Node.<br/>
  3042. Use this method to register touch or mouse event permit propagation based on scene graph,
  3043. you can propagate the event to the parents or swallow it by calling stopPropagation on the event.<br/>
  3044. It's the recommended way to register touch/mouse event for Node,
  3045. please do not use cc.eventManager directly for Node.
  3046. !#zh
  3047. 在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。<br/>
  3048. 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。<br/>
  3049. 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
  3050. @param type A string representing the event type to listen for.<br>
  3051. See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events.
  3052. @param callback The callback that will be invoked when the event is dispatched.
  3053. The callback is ignored if it is a duplicate (the callbacks are unique).
  3054. @param target The target (this object) to invoke the callback, can be null
  3055. @param useCapture When set to true, the capture argument prevents callback
  3056. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  3057. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  3058. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  3059. @example
  3060. ```js
  3061. this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
  3062. node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
  3063. node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
  3064. node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
  3065. node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
  3066. node.on("anchor-changed", callback, this);
  3067. ```
  3068. */
  3069. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  3070. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  3071. /**
  3072. !#en
  3073. Removes the callback previously registered with the same type, callback, target and or useCapture.
  3074. This method is merely an alias to removeEventListener.
  3075. !#zh 删除之前与同类型,回调,目标或 useCapture 注册的回调。
  3076. @param type A string representing the event type being removed.
  3077. @param callback The callback to remove.
  3078. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  3079. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  3080. If not specified, useCapture defaults to false. If a callback was registered twice,
  3081. one with capture and one without, each must be removed separately. Removal of a capturing callback
  3082. does not affect a non-capturing version of the same listener, and vice versa.
  3083. @example
  3084. ```js
  3085. this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
  3086. node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
  3087. node.off("anchor-changed", callback, this);
  3088. ```
  3089. */
  3090. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  3091. /**
  3092. !#en Removes all callbacks previously registered with the same target.
  3093. !#zh 移除目标上的所有注册事件。
  3094. @param target The target to be searched for all related callbacks
  3095. @example
  3096. ```js
  3097. node.targetOff(target);
  3098. ```
  3099. */
  3100. targetOff(target: any): void;
  3101. /**
  3102. !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
  3103. 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.
  3104. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3105. !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3106. 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
  3107. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3108. @param recursive Whether to pause node system events on the sub node tree.
  3109. @example
  3110. ```js
  3111. node.pauseSystemEvents(true);
  3112. ```
  3113. */
  3114. pauseSystemEvents(recursive: boolean): void;
  3115. /**
  3116. !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
  3117. 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.
  3118. Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/
  3119. !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。
  3120. 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
  3121. 参考:http://cocos.com/docs/creator/scripting/internal-events.html
  3122. @param recursive Whether to resume node system events on the sub node tree.
  3123. @example
  3124. ```js
  3125. node.resumeSystemEvents(true);
  3126. ```
  3127. */
  3128. resumeSystemEvents(recursive: boolean): void;
  3129. /**
  3130. !#en
  3131. Executes an action, and returns the action that is executed.<br/>
  3132. The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
  3133. Calling runAction while the node is not active won't have any effect. <br/>
  3134. Note:You shouldn't modify the action after runAction, that won't take any effect.<br/>
  3135. if you want to modify, when you define action plus.
  3136. !#zh
  3137. 执行并返回该执行的动作。该节点将会变成动作的目标。<br/>
  3138. 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。<br/>
  3139. 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
  3140. @param action action
  3141. @example
  3142. ```js
  3143. var action = cc.scaleTo(0.2, 1, 0.6);
  3144. node.runAction(action);
  3145. node.runAction(action).repeatForever(); // fail
  3146. node.runAction(action.repeatForever()); // right
  3147. ```
  3148. */
  3149. runAction(action: Action): Action;
  3150. /**
  3151. !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
  3152. !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
  3153. @example
  3154. ```js
  3155. node.pauseAllActions();
  3156. ```
  3157. */
  3158. pauseAllActions(): void;
  3159. /**
  3160. !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
  3161. !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
  3162. @example
  3163. ```js
  3164. node.resumeAllActions();
  3165. ```
  3166. */
  3167. resumeAllActions(): void;
  3168. /**
  3169. !#en Stops and removes all actions from the running action list .
  3170. !#zh 停止并且移除所有正在运行的动作列表。
  3171. @example
  3172. ```js
  3173. node.stopAllActions();
  3174. ```
  3175. */
  3176. stopAllActions(): void;
  3177. /**
  3178. !#en Stops and removes an action from the running action list.
  3179. !#zh 停止并移除指定的动作。
  3180. @param action An action object to be removed.
  3181. @example
  3182. ```js
  3183. var action = cc.scaleTo(0.2, 1, 0.6);
  3184. node.stopAction(action);
  3185. ```
  3186. */
  3187. stopAction(action: Action): void;
  3188. /**
  3189. !#en Removes an action from the running action list by its tag.
  3190. !#zh 停止并且移除指定标签的动作。
  3191. @param tag A tag that indicates the action to be removed.
  3192. @example
  3193. ```js
  3194. node.stopAction(1);
  3195. ```
  3196. */
  3197. stopActionByTag(tag: number): void;
  3198. /**
  3199. !#en Returns an action from the running action list by its tag.
  3200. !#zh 通过标签获取指定动作。
  3201. @param tag tag
  3202. @example
  3203. ```js
  3204. var action = node.getActionByTag(1);
  3205. ```
  3206. */
  3207. getActionByTag(tag: number): Action;
  3208. /**
  3209. !#en
  3210. Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/>
  3211. Composable actions are counted as 1 action. Example:<br/>
  3212. If you are running 1 Sequence of 7 actions, it will return 1. <br/>
  3213. If you are running 7 Sequences of 2 actions, it will return 7.</p>
  3214. !#zh
  3215. 获取运行着的动作加上正在调度运行的动作的总数。<br/>
  3216. 例如:<br/>
  3217. - 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。<br/>
  3218. - 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。<br/>
  3219. @example
  3220. ```js
  3221. var count = node.getNumberOfRunningActions();
  3222. cc.log("Running Action Count: " + count);
  3223. ```
  3224. */
  3225. getNumberOfRunningActions(): number;
  3226. /**
  3227. !#en Returns a copy of the position (x, y) of the node in its parent's coordinates.
  3228. !#zh 获取节点在父节点坐标系中的位置(x, y)。
  3229. @example
  3230. ```js
  3231. cc.log("Node Position: " + node.getPosition());
  3232. ```
  3233. */
  3234. getPosition(): Vec2;
  3235. /**
  3236. !#en
  3237. Sets the position (x, y) of the node in its parent's coordinates.<br/>
  3238. Usually we use cc.v2(x, y) to compose cc.Vec2 object.<br/>
  3239. and Passing two numbers (x, y) is more efficient than passing cc.Vec2 object.
  3240. !#zh
  3241. 设置节点在父节点坐标系中的位置。<br/>
  3242. 可以通过两种方式设置坐标点:<br/>
  3243. 1. 传入 2 个数值 x 和 y。<br/>
  3244. 2. 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
  3245. @param newPosOrX X coordinate for position or the position (x, y) of the node in coordinates
  3246. @param y Y coordinate for position
  3247. @example
  3248. ```js
  3249. node.setPosition(cc.v2(0, 0));
  3250. node.setPosition(0, 0);
  3251. ```
  3252. */
  3253. setPosition(newPosOrX: Vec2|number, y?: number): void;
  3254. /**
  3255. !#en
  3256. Returns the scale factor of the node.
  3257. Assertion will fail when _scaleX != _scaleY.
  3258. !#zh 获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
  3259. @example
  3260. ```js
  3261. cc.log("Node Scale: " + node.getScale());
  3262. ```
  3263. */
  3264. getScale(): number;
  3265. /**
  3266. !#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.
  3267. !#zh 设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
  3268. @param scaleX scaleX or scale
  3269. @param scaleY scaleY
  3270. @example
  3271. ```js
  3272. node.setScale(cc.v2(1, 1));
  3273. node.setScale(1, 1);
  3274. ```
  3275. */
  3276. setScale(scaleX: number|Vec2, scaleY?: number): void;
  3277. /**
  3278. !#en
  3279. Returns a copy the untransformed size of the node. <br/>
  3280. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3281. All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
  3282. !#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
  3283. @param ignoreSizeProvider true if you need to get the original size of the node
  3284. @example
  3285. ```js
  3286. cc.log("Content Size: " + node.getContentSize());
  3287. ```
  3288. */
  3289. getContentSize(ignoreSizeProvider?: boolean): Size;
  3290. /**
  3291. !#en
  3292. Sets the untransformed size of the node.<br/>
  3293. The contentSize remains the same no matter the node is scaled or rotated.<br/>
  3294. All nodes has a size. Layer and Scene has the same size of the screen.
  3295. !#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
  3296. @param size The untransformed size of the node or The untransformed size's width of the node.
  3297. @param height The untransformed size's height of the node.
  3298. @example
  3299. ```js
  3300. node.setContentSize(cc.size(100, 100));
  3301. node.setContentSize(100, 100);
  3302. ```
  3303. */
  3304. setContentSize(size: Size|number, height?: number): void;
  3305. /**
  3306. !#en
  3307. Set whether color should be changed with the opacity value,
  3308. useless in ccsg.Node, but this function is override in some class to have such behavior.
  3309. !#zh 设置更改透明度时是否修改RGB值,
  3310. @param opacityValue opacityValue
  3311. @example
  3312. ```js
  3313. node.setOpacityModifyRGB(true);
  3314. ```
  3315. */
  3316. setOpacityModifyRGB(opacityValue: boolean): void;
  3317. /**
  3318. !#en Get whether color should be changed with the opacity value.
  3319. !#zh 更改透明度时是否修改RGB值。
  3320. @example
  3321. ```js
  3322. var hasChange = node.isOpacityModifyRGB();
  3323. ```
  3324. */
  3325. isOpacityModifyRGB(): boolean;
  3326. /**
  3327. !#en
  3328. Returns a copy of the anchor point.<br/>
  3329. Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
  3330. It's like a pin in the node where it is "attached" to its parent. <br/>
  3331. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
  3332. But you can use values higher than (1,1) and lower than (0,0) too. <br/>
  3333. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3334. !#zh
  3335. 获取节点锚点,用百分比表示。<br/>
  3336. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3337. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3338. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3339. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3340. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3341. @example
  3342. ```js
  3343. cc.log("Node AnchorPoint: " + node.getAnchorPoint());
  3344. ```
  3345. */
  3346. getAnchorPoint(): Vec2;
  3347. /**
  3348. !#en
  3349. Sets the anchor point in percent. <br/>
  3350. anchor point is the point around which all transformations and positioning manipulations take place. <br/>
  3351. It's like a pin in the node where it is "attached" to its parent. <br/>
  3352. The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
  3353. But you can use values higher than (1,1) and lower than (0,0) too.<br/>
  3354. The default anchor point is (0.5,0.5), so it starts at the center of the node.
  3355. !#zh
  3356. 设置锚点的百分比。<br/>
  3357. 锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。<br/>
  3358. 锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。<br/>
  3359. 但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。<br/>
  3360. 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br/>
  3361. 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
  3362. @param point The anchor point of node or The x axis anchor of node.
  3363. @param y The y axis anchor of node.
  3364. @example
  3365. ```js
  3366. node.setAnchorPoint(cc.v2(1, 1));
  3367. node.setAnchorPoint(1, 1);
  3368. ```
  3369. */
  3370. setAnchorPoint(point: Vec2|number, y?: number): void;
  3371. /**
  3372. !#en
  3373. Returns a copy of the anchor point in absolute pixels. <br/>
  3374. you can only read it. If you wish to modify it, use setAnchorPoint.
  3375. !#zh
  3376. 返回锚点的绝对像素位置。<br/>
  3377. 你只能读它。如果您要修改它,使用 setAnchorPoint。
  3378. @example
  3379. ```js
  3380. cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
  3381. ```
  3382. */
  3383. getAnchorPointInPoints(): Vec2;
  3384. /**
  3385. !#en
  3386. Returns the displayed opacity of Node,
  3387. 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.
  3388. !#zh
  3389. 获取节点显示透明度,
  3390. 显示透明度和透明度之间的不同之处在于当启用级连透明度时,
  3391. 显示透明度是基于自身透明度和父节点透明度计算的。
  3392. @example
  3393. ```js
  3394. var displayOpacity = node.getDisplayedOpacity();
  3395. ```
  3396. */
  3397. getDisplayedOpacity(): number;
  3398. /**
  3399. !#en
  3400. Returns the displayed color of Node,
  3401. 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.
  3402. !#zh
  3403. 获取节点的显示颜色,
  3404. 显示颜色和颜色之间的不同之处在于当启用级连颜色时,
  3405. 显示颜色是基于自身颜色和父节点颜色计算的。
  3406. @example
  3407. ```js
  3408. var displayColor = node.getDisplayedColor();
  3409. ```
  3410. */
  3411. getDisplayedColor(): Color;
  3412. /**
  3413. !#en
  3414. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3415. The matrix is in Pixels.<br/>
  3416. This method is AR (Anchor Relative).
  3417. !#zh
  3418. 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。<br/>
  3419. 这个矩阵以像素为单位。<br/>
  3420. 该方法基于节点坐标。
  3421. @example
  3422. ```js
  3423. var affineTransform = node.getNodeToParentTransformAR();
  3424. ```
  3425. */
  3426. getNodeToParentTransformAR(): AffineTransform;
  3427. /**
  3428. !#en
  3429. Returns a "local" axis aligned bounding box of the node. <br/>
  3430. The returned box is relative only to its parent.
  3431. !#zh 返回父节坐标系下的轴向对齐的包围盒。
  3432. @example
  3433. ```js
  3434. var boundingBox = node.getBoundingBox();
  3435. ```
  3436. */
  3437. getBoundingBox(): Rect;
  3438. /**
  3439. !#en
  3440. Returns a "world" axis aligned bounding box of the node.<br/>
  3441. The bounding box contains self and active children's world bounding box.
  3442. !#zh
  3443. 返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。<br/>
  3444. 该边框包含自身和已激活的子节点的世界边框。
  3445. @example
  3446. ```js
  3447. var newRect = node.getBoundingBoxToWorld();
  3448. ```
  3449. */
  3450. getBoundingBoxToWorld(): Rect;
  3451. /**
  3452. !#en
  3453. Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
  3454. The matrix is in Pixels.
  3455. !#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
  3456. @example
  3457. ```js
  3458. var affineTransform = node.getNodeToParentTransform();
  3459. ```
  3460. */
  3461. getNodeToParentTransform(): AffineTransform;
  3462. /**
  3463. !#en Returns the world affine transform matrix. The matrix is in Pixels.
  3464. !#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
  3465. @example
  3466. ```js
  3467. var affineTransform = node.getNodeToWorldTransform();
  3468. ```
  3469. */
  3470. getNodeToWorldTransform(): AffineTransform;
  3471. /**
  3472. !#en
  3473. Returns the world affine transform matrix. The matrix is in Pixels.<br/>
  3474. This method is AR (Anchor Relative).
  3475. !#zh
  3476. 返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。<br/>
  3477. 该方法基于节点坐标。
  3478. @example
  3479. ```js
  3480. var mat = node.getNodeToWorldTransformAR();
  3481. ```
  3482. */
  3483. getNodeToWorldTransformAR(): AffineTransform;
  3484. /**
  3485. !#en
  3486. Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
  3487. The matrix is in Pixels. The returned transform is readonly and cannot be changed.
  3488. !#zh
  3489. 返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。<br/>
  3490. 该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
  3491. @example
  3492. ```js
  3493. var affineTransform = node.getParentToNodeTransform();
  3494. ```
  3495. */
  3496. getParentToNodeTransform(): AffineTransform;
  3497. /**
  3498. !#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
  3499. !#en 返回世界坐标系到节点坐标系的逆矩阵。
  3500. @example
  3501. ```js
  3502. var affineTransform = node.getWorldToNodeTransform();
  3503. ```
  3504. */
  3505. getWorldToNodeTransform(): AffineTransform;
  3506. /**
  3507. !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
  3508. !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
  3509. @param worldPoint worldPoint
  3510. @example
  3511. ```js
  3512. var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
  3513. ```
  3514. */
  3515. convertToNodeSpace(worldPoint: Vec2): Vec2;
  3516. /**
  3517. !#en Converts a Point to world space coordinates. The result is in Points.
  3518. !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
  3519. @param nodePoint nodePoint
  3520. @example
  3521. ```js
  3522. var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
  3523. ```
  3524. */
  3525. convertToWorldSpace(nodePoint: Vec2): Vec2;
  3526. /**
  3527. !#en
  3528. Converts a Point to node (local) space coordinates. The result is in Points.<br/>
  3529. treating the returned/received node point as anchor relative.
  3530. !#zh
  3531. 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
  3532. 返回值将基于节点坐标。
  3533. @param worldPoint worldPoint
  3534. @example
  3535. ```js
  3536. var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
  3537. ```
  3538. */
  3539. convertToNodeSpaceAR(worldPoint: Vec2): Vec2;
  3540. /**
  3541. !#en
  3542. Converts a local Point to world space coordinates.The result is in Points.<br/>
  3543. treating the returned/received node point as anchor relative.
  3544. !#zh
  3545. 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
  3546. 返回值将基于世界坐标。
  3547. @param nodePoint nodePoint
  3548. @example
  3549. ```js
  3550. var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
  3551. ```
  3552. */
  3553. convertToWorldSpaceAR(nodePoint: Vec2): Vec2;
  3554. /**
  3555. !#en convenience methods which take a cc.Touch instead of cc.Vec2.
  3556. !#zh 将触摸点转换成本地坐标系中位置。
  3557. @param touch The touch object
  3558. @example
  3559. ```js
  3560. var newVec2 = node.convertTouchToNodeSpace(touch);
  3561. ```
  3562. */
  3563. convertTouchToNodeSpace(touch: Touch): Vec2;
  3564. /**
  3565. !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
  3566. !#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
  3567. @param touch The touch object
  3568. @example
  3569. ```js
  3570. var newVec2 = node.convertTouchToNodeSpaceAR(touch);
  3571. ```
  3572. */
  3573. convertTouchToNodeSpaceAR(touch: Touch): Vec2;
  3574. /**
  3575. !#en
  3576. Adds a child to the node with z order and tag.
  3577. !#zh
  3578. 添加子节点,并且可以修改该节点的 局部 Z 顺序和标签。
  3579. @param child A child node
  3580. @param localZOrder Z order for drawing priority. Please refer to setZOrder(int)
  3581. @param tag An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
  3582. @example
  3583. ```js
  3584. node.addChild(newNode, 1, 1001);
  3585. ```
  3586. */
  3587. addChild(child: Node, localZOrder?: number, tag?: number|string): void;
  3588. /**
  3589. !#en Stops all running actions and schedulers.
  3590. !#zh 停止所有正在播放的动作和计时器。
  3591. @example
  3592. ```js
  3593. node.cleanup();
  3594. ```
  3595. */
  3596. cleanup(): void;
  3597. /**
  3598. !#en Sorts the children array depends on children's zIndex and arrivalOrder,
  3599. normally you won't need to invoke this function.
  3600. !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
  3601. */
  3602. sortAllChildren(): void;
  3603. /** !#en The local scale relative to the parent.
  3604. !#zh 节点相对父节点的缩放。 */
  3605. scale: number;
  3606. /**
  3607. !#en Returns the x axis position of the node in cocos2d coordinates.
  3608. !#zh 获取节点 X 轴坐标。
  3609. @example
  3610. ```js
  3611. var posX = node.getPositionX();
  3612. ```
  3613. */
  3614. getPositionX(): number;
  3615. /**
  3616. !#en Sets the x axis position of the node in cocos2d coordinates.
  3617. !#zh 设置节点 X 轴坐标。
  3618. @param x x
  3619. @example
  3620. ```js
  3621. node.setPositionX(1);
  3622. ```
  3623. */
  3624. setPositionX(x: number): void;
  3625. /**
  3626. !#en Returns the y axis position of the node in cocos2d coordinates.
  3627. !#zh 获取节点 Y 轴坐标。
  3628. @example
  3629. ```js
  3630. var posY = node.getPositionY();
  3631. ```
  3632. */
  3633. getPositionY(): number;
  3634. /**
  3635. !#en Sets the y axis position of the node in cocos2d coordinates.
  3636. !#zh 设置节点 Y 轴坐标。
  3637. @param y The new position in y axis
  3638. @example
  3639. ```js
  3640. node.setPositionY(100);
  3641. ```
  3642. */
  3643. setPositionY(y: number): void;
  3644. /**
  3645. !#en Returns the local Z order of this node.
  3646. !#zh 获取节点局部 Z 轴顺序。
  3647. @example
  3648. ```js
  3649. var localZorder = node.getLocalZOrder();
  3650. ```
  3651. */
  3652. getLocalZOrder(): number;
  3653. /**
  3654. !#en
  3655. LocalZOrder is the 'key' used to sort the node relative to its siblings. <br/>
  3656. <br/>
  3657. The Node's parent will sort all its children based ont the LocalZOrder value. <br/>
  3658. If two nodes have the same LocalZOrder, then the node that was added first to the children's array <br/>
  3659. will be in front of the other node in the array. <br/>
  3660. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) <br/>
  3661. And Nodes that have LocalZOder values smaller than 0 are the "left" subtree <br/>
  3662. While Nodes with LocalZOder greater than 0 are the "right" subtree.
  3663. !#zh
  3664. LocalZOrder 是 “key” (关键)来分辨节点和它兄弟节点的相关性。
  3665. 父节点将会通过 LocalZOrder 的值来分辨所有的子节点。
  3666. 如果两个节点有同样的 LocalZOrder,那么先加入子节点数组的节点将会显示在后加入的节点的前面。
  3667. 同样的,场景图使用 “In-Order(按顺序)” 遍历数算法来遍历
  3668. ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且拥有小于 0 的 LocalZOrder 的值的节点是 “ left ” 子树(左子树)
  3669. 所以拥有大于 0 的 LocalZOrder 的值得节点是 “ right ”子树(右子树)。
  3670. @param localZOrder localZOrder
  3671. @example
  3672. ```js
  3673. node.setLocalZOrder(1);
  3674. ```
  3675. */
  3676. setLocalZOrder(localZOrder: number): void;
  3677. /**
  3678. !#en Returns whether node's opacity value affect its child nodes.
  3679. !#zh 返回节点的不透明度值是否影响其子节点。
  3680. @example
  3681. ```js
  3682. cc.log(node.isCascadeOpacityEnabled());
  3683. ```
  3684. */
  3685. isCascadeOpacityEnabled(): boolean;
  3686. /**
  3687. !#en Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
  3688. !#zh 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
  3689. @param cascadeOpacityEnabled cascadeOpacityEnabled
  3690. @example
  3691. ```js
  3692. node.setCascadeOpacityEnabled(true);
  3693. ```
  3694. */
  3695. setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
  3696. }
  3697. /** !#en
  3698. cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
  3699. cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
  3700. !#zh
  3701. cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。<br/>
  3702. cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。 */
  3703. export class Scene extends Node {
  3704. /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
  3705. !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。 */
  3706. autoReleaseAssets: boolean;
  3707. }
  3708. /** !#en
  3709. Scheduler is responsible of triggering the scheduled callbacks.<br/>
  3710. You should not use NSTimer. Instead use this class.<br/>
  3711. <br/>
  3712. There are 2 different types of callbacks (selectors):<br/>
  3713. - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
  3714. - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
  3715. <br/>
  3716. The 'custom selectors' should be avoided when possible. It is faster,
  3717. and consumes less memory to use the 'update callback'. *
  3718. !#zh
  3719. Scheduler 是负责触发回调函数的类。<br/>
  3720. 通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。<br/>
  3721. 有两种不同类型的定时器:<br/>
  3722. - update 定时器:每一帧都会触发。您可以自定义优先级。<br/>
  3723. - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。<br/>
  3724. 如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
  3725. export class Scheduler {
  3726. /**
  3727. !#en
  3728. Modifies the time of all scheduled callbacks.<br/>
  3729. You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
  3730. Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
  3731. To create a 'fast forward' effect, use values higher than 1.0.<br/>
  3732. Note:It will affect EVERY scheduled selector / action.
  3733. !#zh
  3734. 设置时间间隔的缩放比例。<br/>
  3735. 您可以使用这个方法来创建一个 “slow motion(慢动作)” 或 “fast forward(快进)” 的效果。<br/>
  3736. 默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。<br/>
  3737. 要使用 “fast forward(快进)” 效果,使用值大于 1.0。<br/>
  3738. 注意:它影响该 Scheduler 下管理的所有定时器。
  3739. @param timeScale timeScale
  3740. */
  3741. setTimeScale(timeScale: number): void;
  3742. /**
  3743. !#en Returns time scale of scheduler.
  3744. !#zh 获取时间间隔的缩放比例。
  3745. */
  3746. getTimeScale(): number;
  3747. /**
  3748. !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
  3749. !#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
  3750. @param dt delta time
  3751. */
  3752. update(dt: number): void;
  3753. /**
  3754. !#en
  3755. <p>
  3756. The scheduled method will be called every 'interval' seconds.</br>
  3757. If paused is YES, then it won't be called until it is resumed.<br/>
  3758. If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
  3759. If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
  3760. repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
  3761. delay is the amount of time the action will wait before it'll start<br/>
  3762. </p>
  3763. !#zh
  3764. 指定回调函数,调用对象等信息来添加一个新的定时器。</br>
  3765. 当时间间隔达到指定值时,设置的回调函数将会被调用。</br>
  3766. 如果 paused 值为 true,那么直到 resume 被调用才开始计时。</br>
  3767. 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
  3768. 建议使用 scheduleUpdateForTarget 代替。</br>
  3769. 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。<br/>
  3770. repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
  3771. 可以让定时器一直循环触发。<br/>
  3772. delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
  3773. @param target target
  3774. @param callback_fn callback_fn
  3775. @param interval interval
  3776. @param repeat repeat
  3777. @param delay delay
  3778. @param paused paused
  3779. @example
  3780. ```js
  3781. //register a schedule to scheduler
  3782. var scheduler = cc.director.getScheduler();
  3783. scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
  3784. ```
  3785. */
  3786. scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void;
  3787. scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void;
  3788. /**
  3789. !#en The schedule
  3790. !#zh 定时器
  3791. @param callback callback
  3792. @param target target
  3793. @param interval interval
  3794. @param repeat repeat
  3795. @param delay delay
  3796. @param paused paused
  3797. @example
  3798. ```js
  3799. //register a schedule to scheduler
  3800. cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
  3801. ```
  3802. */
  3803. schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
  3804. schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
  3805. /**
  3806. !#en
  3807. Schedules the update callback for a given target,
  3808. the callback will be invoked every frame after schedule started.
  3809. !#zh
  3810. 使用指定的优先级为指定的对象设置 update 定时器。
  3811. update 定时器每一帧都会被触发。优先级的值越低,定时器被触发的越早。
  3812. @param target target
  3813. @param priority priority
  3814. @param paused paused
  3815. @param updateFunc updateFunc
  3816. */
  3817. scheduleUpdate(target: any, priority: number, paused: boolean, updateFunc: Function): void;
  3818. /**
  3819. !#en
  3820. Unschedules a callback for a callback and a given target.
  3821. If you want to unschedule the "update", use `unscheduleUpdate()`
  3822. !#zh
  3823. 根据指定的回调函数和调用对象。
  3824. 如果需要取消 update 定时器,请使用 unscheduleUpdate()。
  3825. @param callback The callback to be unscheduled
  3826. @param target The target bound to the callback.
  3827. */
  3828. unschedule(callback: Function, target: any): void;
  3829. /**
  3830. !#en Unschedules the update callback for a given target.
  3831. !#zh 取消指定对象的 update 定时器。
  3832. @param target The target to be unscheduled.
  3833. */
  3834. unscheduleUpdate(target: any): void;
  3835. /**
  3836. !#en
  3837. Unschedules all scheduled callbacks for a given target.
  3838. This also includes the "update" callback.
  3839. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  3840. @param target The target to be unscheduled.
  3841. */
  3842. unscheduleAllForTarget(target: any): void;
  3843. /**
  3844. !#en
  3845. Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
  3846. You should NEVER call this method, unless you know what you are doing.
  3847. !#zh
  3848. 取消所有对象的所有定时器,包括系统定时器。<br/>
  3849. 不用调用此函数,除非你确定你在做什么。
  3850. */
  3851. unscheduleAll(): void;
  3852. /**
  3853. !#en
  3854. Unschedules all callbacks from all targets with a minimum priority.<br/>
  3855. You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
  3856. !#zh
  3857. 取消所有优先级的值大于指定优先级的定时器。<br/>
  3858. 你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  3859. @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
  3860. priority is higher than minPriority will be unscheduled.
  3861. */
  3862. unscheduleAllWithMinPriority(minPriority: number): void;
  3863. /**
  3864. !#en Checks whether a callback for a given target is scheduled.
  3865. !#zh 检查指定的回调函数和回调对象组合是否存在定时器。
  3866. @param callback The callback to check.
  3867. @param target The target of the callback.
  3868. */
  3869. isScheduled(callback: Function, target: any): boolean;
  3870. /**
  3871. !#en
  3872. Pause all selectors from all targets.<br/>
  3873. You should NEVER call this method, unless you know what you are doing.
  3874. !#zh
  3875. 暂停所有对象的所有定时器。<br/>
  3876. 不要调用这个方法,除非你知道你正在做什么。
  3877. */
  3878. pauseAllTargets(): void;
  3879. /**
  3880. !#en
  3881. Pause all selectors from all targets with a minimum priority. <br/>
  3882. You should only call this with kCCPriorityNonSystemMin or higher.
  3883. !#zh
  3884. 暂停所有优先级的值大于指定优先级的定时器。<br/>
  3885. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  3886. @param minPriority minPriority
  3887. */
  3888. pauseAllTargetsWithMinPriority(minPriority: number): void;
  3889. /**
  3890. !#en
  3891. Resume selectors on a set of targets.<br/>
  3892. This can be useful for undoing a call to pauseAllCallbacks.
  3893. !#zh
  3894. 恢复指定数组中所有对象的定时器。<br/>
  3895. 这个函数是 pauseAllCallbacks 的逆操作。
  3896. @param targetsToResume targetsToResume
  3897. */
  3898. resumeTargets(targetsToResume: any[]): void;
  3899. /**
  3900. !#en
  3901. Pauses the target.<br/>
  3902. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
  3903. If the target is not present, nothing happens.
  3904. !#zh
  3905. 暂停指定对象的定时器。<br/>
  3906. 指定对象的所有定时器都会被暂停。<br/>
  3907. 如果指定的对象没有定时器,什么也不会发生。
  3908. @param target target
  3909. */
  3910. pauseTarget(target: any): void;
  3911. /**
  3912. !#en
  3913. Resumes the target.<br/>
  3914. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
  3915. If the target is not present, nothing happens.
  3916. !#zh
  3917. 恢复指定对象的所有定时器。<br/>
  3918. 指定对象的所有定时器将继续工作。<br/>
  3919. 如果指定的对象没有定时器,什么也不会发生。
  3920. @param target target
  3921. */
  3922. resumeTarget(target: any): void;
  3923. /**
  3924. !#en Returns whether or not the target is paused.
  3925. !#zh 返回指定对象的定时器是否暂停了。
  3926. @param target target
  3927. */
  3928. isTargetPaused(target: any): boolean;
  3929. /**
  3930. !#en
  3931. Schedules the 'update' callback_fn for a given target with a given priority.<br/>
  3932. The 'update' callback_fn will be called every frame.<br/>
  3933. The lower the priority, the earlier it is called.
  3934. !#zh
  3935. 为指定对象设置 update 定时器。<br/>
  3936. update 定时器每一帧都会被调用。<br/>
  3937. 优先级的值越低,越早被调用。
  3938. @param target target
  3939. @param priority priority
  3940. @param paused paused
  3941. @example
  3942. ```js
  3943. //register this object to scheduler
  3944. var scheduler = cc.director.getScheduler();
  3945. scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
  3946. ```
  3947. */
  3948. scheduleUpdateForTarget(target: any, priority: number, paused: boolean): void;
  3949. /**
  3950. !#en
  3951. Unschedule a callback function for a given target.<br/>
  3952. If you want to unschedule the "update", use unscheduleUpdateForTarget.
  3953. !#zh
  3954. 根据指定的回调函数和调用对象对象取消相应的定时器。<br/>
  3955. 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
  3956. @param target target
  3957. @param callback callback[Function] or key[String]
  3958. @example
  3959. ```js
  3960. //unschedule a callback of target
  3961. var scheduler = cc.director.getScheduler();
  3962. scheduler.unscheduleCallbackForTarget(this, callback);
  3963. ```
  3964. */
  3965. unscheduleCallbackForTarget(target: any, callback: Function): void;
  3966. /**
  3967. !#en Unschedules the update callback function for a given target.
  3968. !#zh 取消指定对象的所有定时器。
  3969. @param target target
  3970. @example
  3971. ```js
  3972. //unschedules the "update" method.
  3973. var scheduler = cc.director.getScheduler();
  3974. scheduler.unscheduleUpdateForTarget(this);
  3975. ```
  3976. */
  3977. unscheduleUpdateForTarget(target: any): void;
  3978. /**
  3979. !#en
  3980. Unschedules all function callbacks for a given target.<br/>
  3981. This also includes the "update" callback function.
  3982. !#zh 取消指定对象的所有定时器,包括 update 定时器。
  3983. @param target target
  3984. */
  3985. unscheduleAllCallbacksForTarget(target: any): void;
  3986. /**
  3987. !#en
  3988. Unschedules all function callbacks from all targets. <br/>
  3989. You should NEVER call this method, unless you know what you are doing.
  3990. !#zh
  3991. 取消所有对象的所有定时器。<br/>
  3992. 不要调用这个方法,除非你知道你正在做什么。
  3993. */
  3994. unscheduleAllCallbacks(): void;
  3995. /**
  3996. !#en
  3997. Unschedules all function callbacks from all targets with a minimum priority.<br/>
  3998. You should only call this with kCCPriorityNonSystemMin or higher.
  3999. !#zh
  4000. 取消所有优先级的值大于指定优先级的所有对象的所有定时器。<br/>
  4001. 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
  4002. @param minPriority minPriority
  4003. */
  4004. unscheduleAllCallbacksWithMinPriority(minPriority: number): void;
  4005. /** !#en Priority level reserved for system services.
  4006. !#zh 系统服务的优先级。 */
  4007. static PRIORITY_SYSTEM: number;
  4008. /** !#en Minimum priority level for user scheduling.
  4009. !#zh 用户调度最低优先级。 */
  4010. static PRIORITY_NON_SYSTEM: number;
  4011. }
  4012. /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs.
  4013. !#zh
  4014. cc.audioengine是单例对象。<br/>
  4015. 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。<br/>
  4016. 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放 <br/>
  4017. 注意:<br/>
  4018. 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。<br/>
  4019. 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,<br/>
  4020. 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
  4021. export class audioEngine {
  4022. /**
  4023. !#en Play audio.
  4024. !#zh 播放音频
  4025. @param clip The audio clip to play.
  4026. @param loop Whether the music loop or not.
  4027. @param volume Volume size.
  4028. @example
  4029. ```js
  4030. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  4031. var audioID = cc.audioEngine.play(clip, false, 0.5);
  4032. });
  4033. ```
  4034. */
  4035. static play(clip: AudioClip, loop: boolean, volume: number): number;
  4036. /**
  4037. !#en Set audio loop.
  4038. !#zh 设置音频是否循环。
  4039. @param audioID audio id.
  4040. @param loop Whether cycle.
  4041. @example
  4042. ```js
  4043. cc.audioEngine.setLoop(id, true);
  4044. ```
  4045. */
  4046. static setLoop(audioID: number, loop: boolean): void;
  4047. /**
  4048. !#en Get audio cycle state.
  4049. !#zh 获取音频的循环状态。
  4050. @param audioID audio id.
  4051. @example
  4052. ```js
  4053. cc.audioEngine.isLoop(id);
  4054. ```
  4055. */
  4056. static isLoop(audioID: number): boolean;
  4057. /**
  4058. !#en Set the volume of audio.
  4059. !#zh 设置音量(0.0 ~ 1.0)。
  4060. @param audioID audio id.
  4061. @param volume Volume must be in 0.0~1.0 .
  4062. @example
  4063. ```js
  4064. cc.audioEngine.setVolume(id, 0.5);
  4065. ```
  4066. */
  4067. static setVolume(audioID: number, volume: number): void;
  4068. /**
  4069. !#en The volume of the music max value is 1.0,the min value is 0.0 .
  4070. !#zh 获取音量(0.0 ~ 1.0)。
  4071. @param audioID audio id.
  4072. @example
  4073. ```js
  4074. var volume = cc.audioEngine.getVolume(id);
  4075. ```
  4076. */
  4077. static getVolume(audioID: number): number;
  4078. /**
  4079. !#en Set current time
  4080. !#zh 设置当前的音频时间。
  4081. @param audioID audio id.
  4082. @param sec current time.
  4083. @example
  4084. ```js
  4085. cc.audioEngine.setCurrentTime(id, 2);
  4086. ```
  4087. */
  4088. static setCurrentTime(audioID: number, sec: number): boolean;
  4089. /**
  4090. !#en Get current time
  4091. !#zh 获取当前的音频播放时间。
  4092. @param audioID audio id.
  4093. @example
  4094. ```js
  4095. var time = cc.audioEngine.getCurrentTime(id);
  4096. ```
  4097. */
  4098. static getCurrentTime(audioID: number): number;
  4099. /**
  4100. !#en Get audio duration
  4101. !#zh 获取音频总时长。
  4102. @param audioID audio id.
  4103. @example
  4104. ```js
  4105. var time = cc.audioEngine.getDuration(id);
  4106. ```
  4107. */
  4108. static getDuration(audioID: number): number;
  4109. /**
  4110. !#en Get audio state
  4111. !#zh 获取音频状态。
  4112. @param audioID audio id.
  4113. @example
  4114. ```js
  4115. var state = cc.audioEngine.getState(id);
  4116. ```
  4117. */
  4118. static getState(audioID: number): audioEngine.AudioState;
  4119. /**
  4120. !#en Set Audio finish callback
  4121. !#zh 设置一个音频结束后的回调
  4122. @param audioID audio id.
  4123. @param callback loaded callback.
  4124. @example
  4125. ```js
  4126. cc.audioEngine.setFinishCallback(id, function () {});
  4127. ```
  4128. */
  4129. static setFinishCallback(audioID: number, callback: Function): void;
  4130. /**
  4131. !#en Pause playing audio.
  4132. !#zh 暂停正在播放音频。
  4133. @param audioID The return value of function play.
  4134. @example
  4135. ```js
  4136. cc.audioEngine.pause(audioID);
  4137. ```
  4138. */
  4139. static pause(audioID: number): void;
  4140. /**
  4141. !#en Pause all playing audio
  4142. !#zh 暂停现在正在播放的所有音频。
  4143. @example
  4144. ```js
  4145. cc.audioEngine.pauseAll();
  4146. ```
  4147. */
  4148. static pauseAll(): void;
  4149. /**
  4150. !#en Resume playing audio.
  4151. !#zh 恢复播放指定的音频。
  4152. @param audioID The return value of function play.
  4153. @example
  4154. ```js
  4155. cc.audioEngine.resume(audioID);
  4156. ```
  4157. */
  4158. static resume(audioID: number): void;
  4159. /**
  4160. !#en Resume all playing audio.
  4161. !#zh 恢复播放所有之前暂停的所有音频。
  4162. @example
  4163. ```js
  4164. cc.audioEngine.resumeAll();
  4165. ```
  4166. */
  4167. static resumeAll(): void;
  4168. /**
  4169. !#en Stop playing audio.
  4170. !#zh 停止播放指定音频。
  4171. @param audioID The return value of function play.
  4172. @example
  4173. ```js
  4174. cc.audioEngine.stop(audioID);
  4175. ```
  4176. */
  4177. static stop(audioID: number): void;
  4178. /**
  4179. !#en Stop all playing audio.
  4180. !#zh 停止正在播放的所有音频。
  4181. @example
  4182. ```js
  4183. cc.audioEngine.stopAll();
  4184. ```
  4185. */
  4186. static stopAll(): void;
  4187. /**
  4188. !#en Set up an audio can generate a few examples.
  4189. !#zh 设置一个音频可以设置几个实例
  4190. @param num a number of instances to be created from within an audio
  4191. @example
  4192. ```js
  4193. cc.audioEngine.setMaxAudioInstance(20);
  4194. ```
  4195. */
  4196. static setMaxAudioInstance(num: number): void;
  4197. /**
  4198. !#en Getting audio can produce several examples.
  4199. !#zh 获取一个音频可以设置几个实例
  4200. @example
  4201. ```js
  4202. cc.audioEngine.getMaxAudioInstance();
  4203. ```
  4204. */
  4205. static getMaxAudioInstance(): number;
  4206. /**
  4207. !#en Unload the preloaded audio from internal buffer.
  4208. !#zh 卸载预加载的音频。
  4209. @param clip clip
  4210. @example
  4211. ```js
  4212. cc.audioEngine.uncache(filePath);
  4213. ```
  4214. */
  4215. static uncache(clip: AudioClip): void;
  4216. /**
  4217. !#en Unload all audio from internal buffer.
  4218. !#zh 卸载所有音频。
  4219. @example
  4220. ```js
  4221. cc.audioEngine.uncacheAll();
  4222. ```
  4223. */
  4224. static uncacheAll(): void;
  4225. /**
  4226. !#en Preload audio file.
  4227. !#zh 预加载一个音频
  4228. @param filePath The file path of an audio.
  4229. @param callback The callback of an audio.
  4230. @example
  4231. ```js
  4232. cc.audioEngine.preload(path);
  4233. ```
  4234. */
  4235. static preload(filePath: string, callback?: Function): void;
  4236. /**
  4237. !#en Set a size, the unit is KB. Over this size is directly resolved into DOM nodes.
  4238. !#zh 设置一个以 KB 为单位的尺寸,大于这个尺寸的音频在加载的时候会强制使用 dom 方式加载
  4239. @param kb The file path of an audio.
  4240. @example
  4241. ```js
  4242. cc.audioEngine.setMaxWebAudioSize(300);
  4243. ```
  4244. */
  4245. static setMaxWebAudioSize(kb: number): void;
  4246. /**
  4247. !#en Play background music
  4248. !#zh 播放背景音乐
  4249. @param clip The audio clip to play.
  4250. @param loop Whether the music loop or not.
  4251. @example
  4252. ```js
  4253. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  4254. var audioID = cc.audioEngine.playMusic(clip, false);
  4255. });
  4256. ```
  4257. */
  4258. static playMusic(clip: AudioClip, loop: boolean): number;
  4259. /**
  4260. !#en Stop background music.
  4261. !#zh 停止播放背景音乐。
  4262. @example
  4263. ```js
  4264. cc.audioEngine.stopMusic();
  4265. ```
  4266. */
  4267. static stopMusic(): void;
  4268. /**
  4269. !#en Pause the background music.
  4270. !#zh 暂停播放背景音乐。
  4271. @example
  4272. ```js
  4273. cc.audioEngine.pauseMusic();
  4274. ```
  4275. */
  4276. static pauseMusic(): void;
  4277. /**
  4278. !#en Resume playing background music.
  4279. !#zh 恢复播放背景音乐。
  4280. @example
  4281. ```js
  4282. cc.audioEngine.resumeMusic();
  4283. ```
  4284. */
  4285. static resumeMusic(): void;
  4286. /**
  4287. !#en Get the volume(0.0 ~ 1.0).
  4288. !#zh 获取音量(0.0 ~ 1.0)。
  4289. @example
  4290. ```js
  4291. var volume = cc.audioEngine.getMusicVolume();
  4292. ```
  4293. */
  4294. static getMusicVolume(): number;
  4295. /**
  4296. !#en Set the background music volume.
  4297. !#zh 设置背景音乐音量(0.0 ~ 1.0)。
  4298. @param volume Volume must be in 0.0~1.0.
  4299. @example
  4300. ```js
  4301. cc.audioEngine.setMusicVolume(0.5);
  4302. ```
  4303. */
  4304. static setMusicVolume(volume: number): void;
  4305. /**
  4306. !#en Background music playing state
  4307. !#zh 背景音乐是否正在播放
  4308. @example
  4309. ```js
  4310. cc.audioEngine.isMusicPlaying();
  4311. ```
  4312. */
  4313. static isMusicPlaying(): boolean;
  4314. /**
  4315. !#en Play effect audio.
  4316. !#zh 播放音效
  4317. @param clip The audio clip to play.
  4318. @param loop Whether the music loop or not.
  4319. @example
  4320. ```js
  4321. cc.loader.loadRes(url, cc.AudioClip, function (err, clip) {
  4322. var audioID = cc.audioEngine.playEffect(clip, false);
  4323. });
  4324. ```
  4325. */
  4326. static playEffect(clip: AudioClip, loop: boolean): number;
  4327. /**
  4328. !#en Set the volume of effect audio.
  4329. !#zh 设置音效音量(0.0 ~ 1.0)。
  4330. @param volume Volume must be in 0.0~1.0.
  4331. @example
  4332. ```js
  4333. cc.audioEngine.setEffectsVolume(0.5);
  4334. ```
  4335. */
  4336. static setEffectsVolume(volume: number): void;
  4337. /**
  4338. !#en The volume of the effect audio max value is 1.0,the min value is 0.0 .
  4339. !#zh 获取音效音量(0.0 ~ 1.0)。
  4340. @example
  4341. ```js
  4342. var volume = cc.audioEngine.getEffectsVolume();
  4343. ```
  4344. */
  4345. static getEffectsVolume(): number;
  4346. /**
  4347. !#en Pause effect audio.
  4348. !#zh 暂停播放音效。
  4349. @param audioID audio id.
  4350. @example
  4351. ```js
  4352. cc.audioEngine.pauseEffect(audioID);
  4353. ```
  4354. */
  4355. static pauseEffect(audioID: number): void;
  4356. /**
  4357. !#en Stop playing all the sound effects.
  4358. !#zh 暂停播放所有音效。
  4359. @example
  4360. ```js
  4361. cc.audioEngine.pauseAllEffects();
  4362. ```
  4363. */
  4364. static pauseAllEffects(): void;
  4365. /**
  4366. !#en Resume effect audio.
  4367. !#zh 恢复播放音效音频。
  4368. @param audioID The return value of function play.
  4369. @example
  4370. ```js
  4371. cc.audioEngine.resumeEffect(audioID);
  4372. ```
  4373. */
  4374. static resumeEffect(audioID: number): void;
  4375. /**
  4376. !#en Resume all effect audio.
  4377. !#zh 恢复播放所有之前暂停的音效。
  4378. @example
  4379. ```js
  4380. cc.audioEngine.resumeAllEffects();
  4381. ```
  4382. */
  4383. static resumeAllEffects(): void;
  4384. /**
  4385. !#en Stop playing the effect audio.
  4386. !#zh 停止播放音效。
  4387. @param audioID audio id.
  4388. @example
  4389. ```js
  4390. cc.audioEngine.stopEffect(id);
  4391. ```
  4392. */
  4393. static stopEffect(audioID: number): void;
  4394. /**
  4395. !#en Stop playing all the effects.
  4396. !#zh 停止播放所有音效。
  4397. @example
  4398. ```js
  4399. cc.audioEngine.stopAllEffects();
  4400. ```
  4401. */
  4402. static stopAllEffects(): void;
  4403. }
  4404. /** !#en
  4405. cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
  4406. You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
  4407. length and color. The fadeTime controls how long it takes each vertex in <br/>
  4408. the streak to fade out, the minimum segment size it how many pixels the <br/>
  4409. streak will move before adding a new ribbon segment, and the texture <br/>
  4410. length is the how many pixels the texture is stretched across. The texture <br/>
  4411. is vertically aligned along the streak segment.
  4412. !#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
  4413. export class MotionStreak extends Component {
  4414. /** !#en
  4415. !#zh 在编辑器模式下预览拖尾效果。 */
  4416. preview: boolean;
  4417. /** !#en The fade time to fade.
  4418. !#zh 拖尾的渐隐时间,以秒为单位。 */
  4419. fadeTime: number;
  4420. /** !#en The minimum segment size.
  4421. !#zh 拖尾之间最小距离。 */
  4422. minSeg: number;
  4423. /** !#en The stroke's width.
  4424. !#zh 拖尾的宽度。 */
  4425. stroke: number;
  4426. /** !#en The texture of the MotionStreak.
  4427. !#zh 拖尾的贴图。 */
  4428. texture: Texture2D;
  4429. /** !#en The color of the MotionStreak.
  4430. !#zh 拖尾的颜色 */
  4431. color: Color;
  4432. /** !#en The fast Mode.
  4433. !#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
  4434. fastMode: boolean;
  4435. /**
  4436. !#en Remove all living segments of the ribbon.
  4437. !#zh 删除当前所有的拖尾片段。
  4438. @example
  4439. ```js
  4440. // Remove all living segments of the ribbon.
  4441. myMotionStreak.reset();
  4442. ```
  4443. */
  4444. reset(): void;
  4445. }
  4446. /** !#en Class for animation data handling.
  4447. !#zh 动画剪辑,用于存储动画数据。 */
  4448. export class AnimationClip extends Asset {
  4449. /** !#en Duration of this animation.
  4450. !#zh 动画的持续时间。 */
  4451. duration: number;
  4452. /** !#en FrameRate of this animation.
  4453. !#zh 动画的帧速率。 */
  4454. sample: number;
  4455. /** !#en Speed of this animation.
  4456. !#zh 动画的播放速度。 */
  4457. speed: number;
  4458. /** !#en WrapMode of this animation.
  4459. !#zh 动画的循环模式。 */
  4460. wrapMode: WrapMode;
  4461. /** !#en Curve data.
  4462. !#zh 曲线数据。 */
  4463. curveData: any;
  4464. /** !#en Event data.
  4465. !#zh 事件数据。 */
  4466. events: {frame: number, func: string, params: string[]}[];
  4467. /**
  4468. !#en Crate clip with a set of sprite frames
  4469. !#zh 使用一组序列帧图片来创建动画剪辑
  4470. @param spriteFrames spriteFrames
  4471. @param sample sample
  4472. @example
  4473. ```js
  4474. var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
  4475. ```
  4476. */
  4477. static createWithSpriteFrames(spriteFrames: [SpriteFrame], sample: number): AnimationClip;
  4478. }
  4479. /** !#en
  4480. The AnimationState gives full control over animation playback process.
  4481. In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
  4482. !#zh
  4483. AnimationState 完全控制动画播放过程。<br/>
  4484. 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
  4485. export class AnimationState extends Playable {
  4486. /**
  4487. @param clip clip
  4488. @param name name
  4489. */
  4490. constructor(clip: AnimationClip, name?: string);
  4491. animator: AnimationAnimator;
  4492. /** !#en The curves list.
  4493. !#zh 曲线列表。 */
  4494. curves: any[];
  4495. /** !#en The start delay which represents the number of seconds from an animation's start time to the start of
  4496. the active interval.
  4497. !#zh 延迟多少秒播放。 */
  4498. delay: number;
  4499. /** !#en The animation's iteration count property.
  4500. A real number greater than or equal to zero (including positive infinity) representing the number of times
  4501. to repeat the animation node.
  4502. Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
  4503. calculations.
  4504. !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半) */
  4505. repeatCount: number;
  4506. /** !#en The iteration duration of this animation in seconds. (length)
  4507. !#zh 单次动画的持续时间,秒。 */
  4508. duration: number;
  4509. /** !#en The animation's playback speed. 1 is normal playback speed.
  4510. !#zh 播放速率。 */
  4511. speed: number;
  4512. /** !#en
  4513. Wrapping mode of the playing animation.
  4514. Notice : dynamic change wrapMode will reset time and repeatCount property
  4515. !#zh
  4516. 动画循环方式。
  4517. 需要注意的是,动态修改 wrapMode 时,会重置 time 以及 repeatCount */
  4518. wrapMode: WrapMode;
  4519. /** !#en The current time of this animation in seconds.
  4520. !#zh 动画当前的时间,秒。 */
  4521. time: number;
  4522. /** !#en The clip that is being played by this animation state.
  4523. !#zh 此动画状态正在播放的剪辑。 */
  4524. clip: AnimationClip;
  4525. /** !#en The name of the playing animation.
  4526. !#zh 动画的名字 */
  4527. name: string;
  4528. }
  4529. /** undefined */
  4530. export class Playable {
  4531. /** !#en Is playing or paused in play mode?
  4532. !#zh 当前是否正在播放。 */
  4533. isPlaying: boolean;
  4534. /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
  4535. !#zh 当前是否正在暂停 */
  4536. isPaused: boolean;
  4537. /**
  4538. !#en Play this animation.
  4539. !#zh 播放动画。
  4540. */
  4541. play(): void;
  4542. /**
  4543. !#en Stop this animation.
  4544. !#zh 停止动画播放。
  4545. */
  4546. stop(): void;
  4547. /**
  4548. !#en Pause this animation.
  4549. !#zh 暂停动画。
  4550. */
  4551. pause(): void;
  4552. /**
  4553. !#en Resume this animation.
  4554. !#zh 重新播放动画。
  4555. */
  4556. resume(): void;
  4557. /**
  4558. !#en Perform a single frame step.
  4559. !#zh 执行一帧动画。
  4560. */
  4561. step(): void;
  4562. }
  4563. /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
  4564. !#zh 动画使用的循环模式。 */
  4565. export enum WrapMode {
  4566. Default = 0,
  4567. Normal = 0,
  4568. Reverse = 0,
  4569. Loop = 0,
  4570. LoopReverse = 0,
  4571. PingPong = 0,
  4572. PingPongReverse = 0,
  4573. }
  4574. /** Particle System base class. <br/>
  4575. Attributes of a Particle System:<br/>
  4576. - emmision rate of the particles<br/>
  4577. - Gravity Mode (Mode A): <br/>
  4578. - gravity <br/>
  4579. - direction <br/>
  4580. - speed +- variance <br/>
  4581. - tangential acceleration +- variance<br/>
  4582. - radial acceleration +- variance<br/>
  4583. - Radius Mode (Mode B): <br/>
  4584. - startRadius +- variance <br/>
  4585. - endRadius +- variance <br/>
  4586. - rotate +- variance <br/>
  4587. - Properties common to all modes: <br/>
  4588. - life +- life variance <br/>
  4589. - start spin +- variance <br/>
  4590. - end spin +- variance <br/>
  4591. - start size +- variance <br/>
  4592. - end size +- variance <br/>
  4593. - start color +- variance <br/>
  4594. - end color +- variance <br/>
  4595. - life +- variance <br/>
  4596. - blending function <br/>
  4597. - texture <br/>
  4598. <br/>
  4599. cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
  4600. 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
  4601. cocos2d uses a another approach, but the results are almost identical.<br/>
  4602. cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
  4603. - spinning particles (supported when using ParticleSystem) <br/>
  4604. - tangential acceleration (Gravity mode) <br/>
  4605. - radial acceleration (Gravity mode) <br/>
  4606. - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
  4607. It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
  4608. export class ParticleSystem extends _RendererUnderSG {
  4609. /** !#en Play particle in edit mode.
  4610. !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
  4611. preview: boolean;
  4612. /** !#en
  4613. If set custom to true, then use custom properties insteadof read particle file.
  4614. !#zh 是否自定义粒子属性。 */
  4615. custom: boolean;
  4616. /** !#en The plist file.
  4617. !#zh plist 格式的粒子配置文件。 */
  4618. file: string;
  4619. /** . */
  4620. texture: Texture2D;
  4621. /** !#en Current quantity of particles that are being simulated.
  4622. !#zh 当前播放的粒子数量。 */
  4623. particleCount: number;
  4624. /** !#en Specify the source Blend Factor.
  4625. !#zh 指定原图混合模式。 */
  4626. srcBlendFactor: BlendFactor;
  4627. /** !#en Specify the destination Blend Factor.
  4628. !#zh 指定目标的混合模式。 */
  4629. dstBlendFactor: BlendFactor;
  4630. /** !#en If set to true, the particle system will automatically start playing on onLoad.
  4631. !#zh 如果设置为 true 运行时会自动发射粒子。 */
  4632. playOnLoad: boolean;
  4633. /** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
  4634. !#zh 粒子播放完毕后自动销毁所在的节点。 */
  4635. autoRemoveOnFinish: boolean;
  4636. /** !#en Indicate whether the particle system is activated.
  4637. !#zh 是否激活粒子。 */
  4638. active: boolean;
  4639. /** !#en Maximum particles of the system.
  4640. !#zh 粒子最大数量。 */
  4641. totalParticles: number;
  4642. /** !#en How many seconds the emitter wil run. -1 means 'forever'.
  4643. !#zh 发射器生存时间,单位秒,-1表示持续发射。 */
  4644. duration: number;
  4645. /** !#en Emission rate of the particles.
  4646. !#zh 每秒发射的粒子数目。 */
  4647. emissionRate: number;
  4648. /** !#en Life of each particle setter.
  4649. !#zh 粒子的运行时间。 */
  4650. life: number;
  4651. /** !#en Variation of life.
  4652. !#zh 粒子的运行时间变化范围。 */
  4653. lifeVar: number;
  4654. /** !#en Start color of each particle.
  4655. !#zh 粒子初始颜色。 */
  4656. startColor: Color;
  4657. /** !#en Variation of the start color.
  4658. !#zh 粒子初始颜色变化范围。 */
  4659. startColorVar: Color;
  4660. /** !#en Ending color of each particle.
  4661. !#zh 粒子结束颜色。 */
  4662. endColor: Color;
  4663. /** !#en Variation of the end color.
  4664. !#zh 粒子结束颜色变化范围。 */
  4665. endColorVar: Color;
  4666. /** !#en Angle of each particle setter.
  4667. !#zh 粒子角度。 */
  4668. angle: number;
  4669. /** !#en Variation of angle of each particle setter.
  4670. !#zh 粒子角度变化范围。 */
  4671. angleVar: number;
  4672. /** !#en Start size in pixels of each particle.
  4673. !#zh 粒子的初始大小。 */
  4674. startSize: number;
  4675. /** !#en Variation of start size in pixels.
  4676. !#zh 粒子初始大小的变化范围。 */
  4677. startSizeVar: number;
  4678. /** !#en End size in pixels of each particle.
  4679. !#zh 粒子结束时的大小。 */
  4680. endSize: number;
  4681. /** !#en Variation of end size in pixels.
  4682. !#zh 粒子结束大小的变化范围。 */
  4683. endSizeVar: number;
  4684. /** !#en Start angle of each particle.
  4685. !#zh 粒子开始自旋角度。 */
  4686. startSpin: number;
  4687. /** !#en Variation of start angle.
  4688. !#zh 粒子开始自旋角度变化范围。 */
  4689. startSpinVar: number;
  4690. /** !#en End angle of each particle.
  4691. !#zh 粒子结束自旋角度。 */
  4692. endSpin: number;
  4693. /** !#en Variation of end angle.
  4694. !#zh 粒子结束自旋角度变化范围。 */
  4695. endSpinVar: number;
  4696. /** !#en Source position of the emitter.
  4697. !#zh 发射器位置。 */
  4698. sourcePos: Vec2;
  4699. /** !#en Variation of source position.
  4700. !#zh 发射器位置的变化范围。(横向和纵向) */
  4701. posVar: Vec2;
  4702. /** !#en Particles movement type.
  4703. !#zh 粒子位置类型。 */
  4704. positionType: ParticleSystem.PositionType;
  4705. /** !#en Particles emitter modes.
  4706. !#zh 发射器类型。 */
  4707. emitterMode: ParticleSystem.EmitterMode;
  4708. /** !#en Gravity of the emitter.
  4709. !#zh 重力。 */
  4710. gravity: Vec2;
  4711. /** !#en Speed of the emitter.
  4712. !#zh 速度。 */
  4713. speed: number;
  4714. /** !#en Variation of the speed.
  4715. !#zh 速度变化范围。 */
  4716. speedVar: number;
  4717. /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
  4718. !#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
  4719. tangentialAccel: number;
  4720. /** !#en Variation of the tangential acceleration.
  4721. !#zh 每个粒子的切向加速度变化范围。 */
  4722. tangentialAccelVar: number;
  4723. /** !#en Acceleration of each particle. Only available in 'Gravity' mode.
  4724. !#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
  4725. radialAccel: number;
  4726. /** !#en Variation of the radial acceleration.
  4727. !#zh 粒子径向加速度变化范围。 */
  4728. radialAccelVar: number;
  4729. /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
  4730. !#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
  4731. rotationIsDir: boolean;
  4732. /** !#en Starting radius of the particles. Only available in 'Radius' mode.
  4733. !#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
  4734. startRadius: number;
  4735. /** !#en Variation of the starting radius.
  4736. !#zh 初始半径变化范围。 */
  4737. startRadiusVar: number;
  4738. /** !#en Ending radius of the particles. Only available in 'Radius' mode.
  4739. !#zh 结束半径,只有在半径模式下可用。 */
  4740. endRadius: number;
  4741. /** !#en Variation of the ending radius.
  4742. !#zh 结束半径变化范围。 */
  4743. endRadiusVar: number;
  4744. /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
  4745. !#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
  4746. rotatePerS: number;
  4747. /** !#en Variation of the degress to rotate a particle around the source pos per second.
  4748. !#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
  4749. rotatePerSVar: number;
  4750. /** !#en The Particle emitter lives forever.
  4751. !#zh 表示发射器永久存在 */
  4752. static DURATION_INFINITY: number;
  4753. /** !#en The starting size of the particle is equal to the ending size.
  4754. !#zh 表示粒子的起始大小等于结束大小。 */
  4755. static START_SIZE_EQUAL_TO_END_SIZE: number;
  4756. /** !#en The starting radius of the particle is equal to the ending radius.
  4757. !#zh 表示粒子的起始半径等于结束半径。 */
  4758. static START_RADIUS_EQUAL_TO_END_RADIUS: number;
  4759. /**
  4760. !#en Add a particle to the emitter.
  4761. !#zh 添加一个粒子到发射器中。
  4762. */
  4763. addParticle(): boolean;
  4764. /**
  4765. !#en Stop emitting particles. Running particles will continue to run until they die.
  4766. !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
  4767. @example
  4768. ```js
  4769. // stop particle system.
  4770. myParticleSystem.stopSystem();
  4771. ```
  4772. */
  4773. stopSystem(): void;
  4774. /**
  4775. !#en Kill all living particles.
  4776. !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
  4777. @example
  4778. ```js
  4779. // play particle system.
  4780. myParticleSystem.resetSystem();
  4781. ```
  4782. */
  4783. resetSystem(): void;
  4784. /**
  4785. !#en Whether or not the system is full.
  4786. !#zh 发射器中粒子是否大于等于设置的总粒子数量。
  4787. */
  4788. isFull(): boolean;
  4789. /**
  4790. !#en
  4791. <p> Sets a new CCSpriteFrame as particle.</br>
  4792. WARNING: this method is experimental. Use setTextureWithRect instead.
  4793. </p>
  4794. !#zh
  4795. <p> 设置一个新的精灵帧为粒子。</br>
  4796. 警告:这个函数只是试验,请使用 setTextureWithRect 实现。
  4797. </p>
  4798. @param spriteFrame spriteFrame
  4799. */
  4800. setDisplayFrame(spriteFrame: SpriteFrame): void;
  4801. /**
  4802. !#en Sets a new texture with a rect. The rect is in texture position and size.
  4803. !#zh 设置一张新贴图和关联的矩形。
  4804. @param texture texture
  4805. @param rect rect
  4806. */
  4807. setTextureWithRect(texture: Texture2D, rect: Rect): void;
  4808. }
  4809. /** !#en Renders the TMX object.
  4810. !#zh 渲染 tmx object。 */
  4811. export class TMXObject {
  4812. /**
  4813. !#en Get the name of object
  4814. !#zh 获取对象的名称
  4815. */
  4816. getObjectName(): string;
  4817. /**
  4818. !#en Get the property of object
  4819. !#zh 获取对象的属性
  4820. @param propertyName propertyName
  4821. */
  4822. getProperty(propertyName: string): any;
  4823. /**
  4824. !#en Get the properties of object
  4825. !#zh 获取对象的属性
  4826. */
  4827. getProperties(): any;
  4828. /**
  4829. !#en Set the object name
  4830. !#zh 设置对象名称
  4831. @param name name
  4832. */
  4833. setObjectName(name: string): void;
  4834. /**
  4835. !#en Set the properties of the object
  4836. !#zh 设置对象的属性
  4837. @param props props
  4838. */
  4839. setProperties(props: any): void;
  4840. }
  4841. /** !#en Render the TMX layer.
  4842. !#zh 渲染 TMX layer。 */
  4843. export class TiledLayer extends _SGComponent {
  4844. /**
  4845. !#en Gets the layer name.
  4846. !#zh 获取层的名称。
  4847. @example
  4848. ```js
  4849. var layerName = tiledLayer.getLayerName();
  4850. cc.log(layerName);
  4851. ```
  4852. */
  4853. getLayerName(): string;
  4854. /**
  4855. !#en Set the layer name.
  4856. !#zh 设置层的名称
  4857. @param layerName layerName
  4858. @example
  4859. ```js
  4860. tiledLayer.setLayerName("New Layer");
  4861. ```
  4862. */
  4863. SetLayerName(layerName: string): void;
  4864. /**
  4865. !#en Return the value for the specific property name.
  4866. !#zh 获取指定属性名的值。
  4867. @param propertyName propertyName
  4868. @example
  4869. ```js
  4870. var property = tiledLayer.getProperty("info");
  4871. cc.log(property);
  4872. ```
  4873. */
  4874. getProperty(propertyName: string): any;
  4875. /**
  4876. !#en Returns the position in pixels of a given tile coordinate.
  4877. !#zh 获取指定 tile 的像素坐标。
  4878. @param pos position or x
  4879. @param y y
  4880. @example
  4881. ```js
  4882. var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
  4883. cc.log("Pos: " + pos);
  4884. var pos = tiledLayer.getPositionAt(0, 0);
  4885. cc.log("Pos: " + pos);
  4886. ```
  4887. */
  4888. getPositionAt(pos: Vec2|number, y?: number): Vec2;
  4889. /**
  4890. !#en Removes a tile at given tile coordinate.
  4891. !#zh 删除指定坐标上的 tile。
  4892. @param pos position or x
  4893. @param y y
  4894. @example
  4895. ```js
  4896. tiledLayer.removeTileAt(cc.v2(0, 0));
  4897. tiledLayer.removeTileAt(0, 0);
  4898. ```
  4899. */
  4900. removeTileAt(pos: Vec2|number, y?: number): void;
  4901. /**
  4902. !#en
  4903. Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
  4904. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
  4905. If a tile is already placed at that position, then it will be removed.
  4906. !#zh
  4907. 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
  4908. tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
  4909. 如果一个 tile 已经放在那个位置,那么它将被删除。
  4910. @param gid gid
  4911. @param posOrX position or x
  4912. @param flagsOrY flags or y
  4913. @param flags flags
  4914. @example
  4915. ```js
  4916. tiledLayer.setTileGID(1001, 10, 10, 1)
  4917. ```
  4918. */
  4919. setTileGID(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
  4920. /**
  4921. !#en
  4922. Returns the tile gid at a given tile coordinate. <br />
  4923. if it returns 0, it means that the tile is empty. <br />
  4924. This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
  4925. !#zh
  4926. 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
  4927. 如果它返回 0,则表示该 tile 为空。<br />
  4928. 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
  4929. @param pos or x
  4930. @param y y
  4931. @example
  4932. ```js
  4933. var tileGid = tiledLayer.getTileGIDAt(0, 0);
  4934. ```
  4935. */
  4936. getTileGIDAt(pos: Vec2|number, y?: number): number;
  4937. /**
  4938. !#en
  4939. Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
  4940. The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
  4941. The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
  4942. You can remove either by calling: <br/>
  4943. - layer.removeChild(sprite, cleanup); <br/>
  4944. - or layer.removeTileAt(ccp(x,y));
  4945. !#zh
  4946. 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
  4947. 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
  4948. 你可以通过调用以下方法来对它进行删除:<br/>
  4949. 1. layer.removeChild(sprite, cleanup);<br/>
  4950. 2. 或 layer.removeTileAt(cc.v2(x,y));
  4951. @param pos or x
  4952. @param y y
  4953. @example
  4954. ```js
  4955. var title = tiledLayer.getTileAt(100, 100);
  4956. cc.log(title);
  4957. ```
  4958. */
  4959. getTileAt(pos: Vec2|number, y?: number): _ccsg.Sprite;
  4960. /**
  4961. !#en
  4962. Dealloc the map that contains the tile position from memory. <br />
  4963. Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
  4964. If you are going to call layer.getTileGIDAt() then, don't release the map.
  4965. !#zh
  4966. 从内存中释放包含 tile 位置信息的地图。<br />
  4967. 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
  4968. 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
  4969. @example
  4970. ```js
  4971. tiledLayer.releaseMap();
  4972. ```
  4973. */
  4974. releaseMap(): void;
  4975. /**
  4976. !#en Sets the untransformed size of the _ccsg.TMXLayer.
  4977. !#zh 设置未转换的 layer 大小。
  4978. @param size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
  4979. @param height The untransformed size's height of the _ccsg.TMXLayer.
  4980. @example
  4981. ```js
  4982. tiledLayer.setContentSize(100, 100);
  4983. ```
  4984. */
  4985. setContentSize(size: Size|number, height?: number): void;
  4986. /**
  4987. !#en Return texture of cc.SpriteBatchNode.
  4988. !#zh 获取纹理。
  4989. @example
  4990. ```js
  4991. var texture = tiledLayer.getTexture();
  4992. cc.log("Texture: " + texture);
  4993. ```
  4994. */
  4995. getTexture(): Texture2D;
  4996. /**
  4997. !#en Set the texture of cc.SpriteBatchNode.
  4998. !#zh 设置纹理。
  4999. @param texture texture
  5000. @example
  5001. ```js
  5002. tiledLayer.setTexture(texture);
  5003. ```
  5004. */
  5005. setTexture(texture: Texture2D): void;
  5006. /**
  5007. !#en Set the opacity of all tiles
  5008. !#zh 设置所有 Tile 的透明度
  5009. @param opacity opacity
  5010. @example
  5011. ```js
  5012. tiledLayer.setTileOpacity(128);
  5013. ```
  5014. */
  5015. setTileOpacity(opacity: number): void;
  5016. /**
  5017. !#en Gets layer size.
  5018. !#zh 获得层大小。
  5019. @example
  5020. ```js
  5021. var size = tiledLayer.getLayerSize();
  5022. cc.log("layer size: " + size);
  5023. ```
  5024. */
  5025. getLayerSize(): Size;
  5026. /**
  5027. !#en Set layer size.
  5028. !#zh 设置层大小。
  5029. @param layerSize layerSize
  5030. @example
  5031. ```js
  5032. tiledLayer.setLayerSize(new cc.size(5, 5));
  5033. ```
  5034. */
  5035. setLayerSize(layerSize: Size): void;
  5036. /**
  5037. !#en Size of the map's tile (could be different from the tile's size).
  5038. !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
  5039. @example
  5040. ```js
  5041. var mapTileSize = tiledLayer.getMapTileSize();
  5042. cc.log("MapTile size: " + mapTileSize);
  5043. ```
  5044. */
  5045. getMapTileSize(): Size;
  5046. /**
  5047. !#en Set the map tile size.
  5048. !#zh 设置 tile 的大小。
  5049. @param tileSize tileSize
  5050. @example
  5051. ```js
  5052. tiledLayer.setMapTileSize(new cc.size(10, 10));
  5053. ```
  5054. */
  5055. setMapTileSize(tileSize: Size): void;
  5056. /**
  5057. !#en Pointer to the map of tiles.
  5058. !#zh 获取地图 tiles。
  5059. @example
  5060. ```js
  5061. var tiles = tiledLayer.getTiles();
  5062. ```
  5063. */
  5064. getTiles(): any[];
  5065. /**
  5066. !#en Pointer to the map of tiles.
  5067. !#zh 设置地图 tiles
  5068. @param tiles tiles
  5069. @example
  5070. ```js
  5071. tiledLayer.setTiles(tiles);
  5072. ```
  5073. */
  5074. setTiles(tiles: any[]): void;
  5075. /**
  5076. !#en Tile set information for the layer.
  5077. !#zh 获取 layer 的 Tileset 信息。
  5078. @example
  5079. ```js
  5080. var tileset = tiledLayer.getTileSet();
  5081. ```
  5082. */
  5083. getTileSet(): TMXTilesetInfo;
  5084. /**
  5085. !#en Tile set information for the layer.
  5086. !#zh 设置 layer 的 Tileset 信息。
  5087. @param tileset tileset
  5088. @example
  5089. ```js
  5090. tiledLayer.setTileSet(tileset);
  5091. ```
  5092. */
  5093. setTileSet(tileset: TMXTilesetInfo): void;
  5094. /**
  5095. !#en Layer orientation, which is the same as the map orientation.
  5096. !#zh 获取 Layer 方向(同地图方向)。
  5097. @example
  5098. ```js
  5099. var orientation = tiledLayer.getLayerOrientation();
  5100. cc.log("Layer Orientation: " + orientation);
  5101. ```
  5102. */
  5103. getLayerOrientation(): number;
  5104. /**
  5105. !#en Layer orientation, which is the same as the map orientation.
  5106. !#zh 设置 Layer 方向(同地图方向)。
  5107. @param orientation orientation
  5108. @example
  5109. ```js
  5110. tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
  5111. ```
  5112. */
  5113. setLayerOrientation(orientation: TiledMap.Orientation): void;
  5114. /**
  5115. !#en properties from the layer. They can be added using Tiled.
  5116. !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
  5117. @example
  5118. ```js
  5119. var properties = tiledLayer.getProperties();
  5120. cc.log("Properties: " + properties);
  5121. ```
  5122. */
  5123. getProperties(): any[];
  5124. /**
  5125. !#en properties from the layer. They can be added using Tiled.
  5126. !#zh 设置层属性。
  5127. @param properties properties
  5128. @example
  5129. ```js
  5130. tiledLayer.setLayerOrientation(properties);
  5131. ```
  5132. */
  5133. setProperties(properties: any[]): void;
  5134. }
  5135. /** !#en Renders a TMX Tile Map in the scene.
  5136. !#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
  5137. export class TiledMap extends Component {
  5138. /** !#en The TiledMap Asset.
  5139. !#zh TiledMap 资源。 */
  5140. tmxAsset: TiledMapAsset;
  5141. /**
  5142. !#en Gets the map size.
  5143. !#zh 获取地图大小。
  5144. @example
  5145. ```js
  5146. var mapSize = tiledMap.getMapSize();
  5147. cc.log("Map Size: " + mapSize);
  5148. ```
  5149. */
  5150. getMapSize(): Size;
  5151. /**
  5152. !#en Set the map size.
  5153. !#zh 设置地图大小。
  5154. @param mapSize mapSize
  5155. @example
  5156. ```js
  5157. tiledMap.setMapSize(new cc.size(960, 640));
  5158. ```
  5159. */
  5160. setMapSize(mapSize: Size): void;
  5161. /**
  5162. !#en Gets the tile size.
  5163. !#zh 获取地图背景中 tile 元素的大小。
  5164. @example
  5165. ```js
  5166. var tileSize = tiledMap.getTileSize();
  5167. cc.log("Tile Size: " + tileSize);
  5168. ```
  5169. */
  5170. getTileSize(): Size;
  5171. /**
  5172. !#en Set the tile size.
  5173. !#zh 设置地图背景中 tile 元素的大小。
  5174. @param tileSize tileSize
  5175. @example
  5176. ```js
  5177. tiledMap.setTileSize(new cc.size(10, 10));
  5178. ```
  5179. */
  5180. setTileSize(tileSize: Size): void;
  5181. /**
  5182. !#en map orientation.
  5183. !#zh 获取地图方向。
  5184. @example
  5185. ```js
  5186. var mapOrientation = tiledMap.getMapOrientation();
  5187. cc.log("Map Orientation: " + mapOrientation);
  5188. ```
  5189. */
  5190. getMapOrientation(): number;
  5191. /**
  5192. !#en map orientation.
  5193. !#zh 设置地图方向。
  5194. @param orientation orientation
  5195. @example
  5196. ```js
  5197. tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
  5198. ```
  5199. */
  5200. setMapOrientation(orientation: TiledMap.Orientation): void;
  5201. /**
  5202. !#en object groups.
  5203. !#zh 获取所有的对象层。
  5204. @example
  5205. ```js
  5206. var objGroups = titledMap.getObjectGroups();
  5207. for (var i = 0; i < objGroups.length; ++i) {
  5208. cc.log("obj: " + objGroups[i]);
  5209. }
  5210. ```
  5211. */
  5212. getObjectGroups(): TiledObjectGroup[];
  5213. /**
  5214. !#en Gets the map properties.
  5215. !#zh 获取地图的属性。
  5216. @example
  5217. ```js
  5218. var properties = titledMap.getProperties();
  5219. for (var i = 0; i < properties.length; ++i) {
  5220. cc.log("Properties: " + properties[i]);
  5221. }
  5222. ```
  5223. */
  5224. getProperties(): any[];
  5225. /**
  5226. !#en Set the map properties.
  5227. !#zh 设置地图的属性。
  5228. @param properties properties
  5229. @example
  5230. ```js
  5231. titledMap.setProperties(properties);
  5232. ```
  5233. */
  5234. setProperties(properties: any[]): void;
  5235. /**
  5236. !#en Return All layers array.
  5237. !#zh 返回包含所有 layer 的数组。
  5238. @example
  5239. ```js
  5240. var layers = titledMap.allLayers();
  5241. for (var i = 0; i < layers.length; ++i) {
  5242. cc.log("Layers: " + layers[i]);
  5243. }
  5244. ```
  5245. */
  5246. allLayers(): TiledLayer[];
  5247. /**
  5248. !#en return the cc.TiledLayer for the specific layer.
  5249. !#zh 获取指定名称的 layer。
  5250. @param layerName layerName
  5251. @example
  5252. ```js
  5253. var layer = titledMap.getLayer("Player");
  5254. cc.log(layer);
  5255. ```
  5256. */
  5257. getLayer(layerName: string): TiledLayer;
  5258. /**
  5259. !#en Return the TMXObjectGroup for the specific group.
  5260. !#zh 获取指定的 TMXObjectGroup。
  5261. @param groupName groupName
  5262. @example
  5263. ```js
  5264. var group = titledMap.getObjectGroup("Players");
  5265. cc.log("ObjectGroup: " + group);
  5266. ```
  5267. */
  5268. getObjectGroup(groupName: string): TiledObjectGroup;
  5269. /**
  5270. !#en Return the value for the specific property name.
  5271. !#zh 通过属性名称,获取指定的属性。
  5272. @param propertyName propertyName
  5273. @example
  5274. ```js
  5275. var property = titledMap.getProperty("info");
  5276. cc.log("Property: " + property);
  5277. ```
  5278. */
  5279. getProperty(propertyName: string): string;
  5280. /**
  5281. !#en Return properties dictionary for tile GID.
  5282. !#zh 通过 GID ,获取指定的属性。
  5283. @param GID GID
  5284. @example
  5285. ```js
  5286. var properties = titledMap.getPropertiesForGID(GID);
  5287. cc.log("Properties: " + properties);
  5288. ```
  5289. */
  5290. getPropertiesForGID(GID: number): any;
  5291. }
  5292. /** Class for tiled map asset handling. */
  5293. export class TiledMapAsset extends Asset {
  5294. textures: Texture2D[];
  5295. textureNames: string[];
  5296. }
  5297. /** !#en Renders the TMX object group.
  5298. !#zh 渲染 tmx object group。 */
  5299. export class TiledObjectGroup extends _SGComponent {
  5300. /**
  5301. !#en Offset position of child objects.
  5302. !#zh 获取子对象的偏移位置。
  5303. @example
  5304. ```js
  5305. var offset = tMXObjectGroup.getPositionOffset();
  5306. ```
  5307. */
  5308. getPositionOffset(): Vec2;
  5309. /**
  5310. !#en Offset position of child objects.
  5311. !#zh 设置子对象的偏移位置。
  5312. @param offset offset
  5313. @example
  5314. ```js
  5315. tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
  5316. ```
  5317. */
  5318. setPositionOffset(offset: Vec2): void;
  5319. /**
  5320. !#en List of properties stored in a dictionary.
  5321. !#zh 以映射的形式获取属性列表。
  5322. @example
  5323. ```js
  5324. var offset = tMXObjectGroup.getProperties();
  5325. ```
  5326. */
  5327. getProperties(): any;
  5328. /**
  5329. !#en Set the properties of the object group.
  5330. !#zh 设置属性列表。
  5331. @param Var Var
  5332. @example
  5333. ```js
  5334. tMXObjectGroup.setProperties(obj);
  5335. ```
  5336. */
  5337. setProperties(Var: any): void;
  5338. /**
  5339. !#en Gets the Group name.
  5340. !#zh 获取组名称。
  5341. @example
  5342. ```js
  5343. var groupName = tMXObjectGroup.getGroupName;
  5344. ```
  5345. */
  5346. getGroupName(): string;
  5347. /**
  5348. !#en Set the Group name.
  5349. !#zh 设置组名称。
  5350. @param groupName groupName
  5351. @example
  5352. ```js
  5353. tMXObjectGroup.setGroupName("New Group");
  5354. ```
  5355. */
  5356. setGroupName(groupName: string): void;
  5357. /**
  5358. !#en
  5359. Return the object for the specific object name. <br />
  5360. It will return the 1st object found on the array for the given name.
  5361. !#zh 获取指定的对象。
  5362. @param objectName objectName
  5363. @example
  5364. ```js
  5365. var object = tMXObjectGroup.getObject("Group");
  5366. ```
  5367. */
  5368. getObject(objectName: string): any;
  5369. /**
  5370. !#en Gets the objects.
  5371. !#zh 获取对象数组。
  5372. @example
  5373. ```js
  5374. var objects = tMXObjectGroup.getObjects();
  5375. ```
  5376. */
  5377. getObjects(): any[];
  5378. }
  5379. /** !#en
  5380. cc.NodePool is the cache pool designed for node type.<br/>
  5381. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5382. It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
  5383. for example, a prefab is a specific node type. <br/>
  5384. When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
  5385. Some common use case is :<br/>
  5386. 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
  5387. 2. Blocks in candy crash (massive creation and recreation)<br/>
  5388. etc...
  5389. !#zh
  5390. cc.NodePool 是用于管理节点对象的对象缓存池。<br/>
  5391. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/>
  5392. 以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
  5393. 新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。<br/>
  5394. 在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。<br/>
  5395. 一些常见的用例是:<br/>
  5396. 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)<br/>
  5397. 2.糖果粉碎传奇中的木块(频繁创建)。
  5398. 等等.... */
  5399. export class NodePool {
  5400. /**
  5401. !#en
  5402. 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.
  5403. !#zh
  5404. 使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
  5405. @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
  5406. @example
  5407. ```js
  5408. properties: {
  5409. template: cc.Prefab
  5410. },
  5411. onLoad () {
  5412. // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
  5413. this.myPool = new cc.NodePool('MyTemplateHandler');
  5414. }
  5415. ```
  5416. */
  5417. constructor(poolHandlerComp?: {prototype: Component}|string);
  5418. /** !#en The pool handler component, it could be the class name or the constructor.
  5419. !#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
  5420. poolHandlerComp: Function|string;
  5421. /**
  5422. !#en The current available size in the pool
  5423. !#zh 获取当前缓冲池的可用对象数量
  5424. */
  5425. size(): number;
  5426. /**
  5427. !#en Destroy all cached nodes in the pool
  5428. !#zh 销毁对象池中缓存的所有节点
  5429. */
  5430. clear(): void;
  5431. /**
  5432. !#en Put a new Node into the pool.
  5433. It will automatically remove the node from its parent without cleanup.
  5434. It will also invoke unuse method of the poolHandlerComp if exist.
  5435. !#zh 向缓冲池中存入一个不再需要的节点对象。
  5436. 这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
  5437. 这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
  5438. @param obj obj
  5439. @example
  5440. ```js
  5441. let myNode = cc.instantiate(this.template);
  5442. this.myPool.put(myNode);
  5443. ```
  5444. */
  5445. put(obj: Node): void;
  5446. /**
  5447. !#en Get a obj from pool, if no available object in pool, null will be returned.
  5448. This function will invoke the reuse function of poolHandlerComp if exist.
  5449. !#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  5450. 这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
  5451. @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
  5452. @example
  5453. ```js
  5454. let newNode = this.myPool.get();
  5455. ```
  5456. */
  5457. get(...params: any[]): Node;
  5458. }
  5459. /** !#en
  5460. Attention: In creator, it's strongly not recommended to use cc.pool to manager cc.Node.
  5461. We provided {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} instead.
  5462. cc.pool is a singleton object serves as an object cache pool.<br/>
  5463. It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  5464. !#zh
  5465. 首先请注意,在 Creator 中我们强烈不建议使用 cc.pool 来管理 cc.Node 节点对象,请使用 {{#crossLink "NodePool"}}cc.NodePool{{/crossLink}} 代替
  5466. 因为 cc.pool 是面向类来设计的,而 cc.Node 中使用 Component 来进行组合,它的类永远都一样,实际却千差万别。
  5467. cc.pool 是一个单例对象,用作为对象缓存池。<br/>
  5468. 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁<br/> */
  5469. export class pool {
  5470. /**
  5471. !#en Put the obj in pool.
  5472. !#zh 加入对象到对象池中。
  5473. @param obj The need put in pool object.
  5474. @example
  5475. ```js
  5476. ---------------------------------
  5477. var sp = new _ccsg.Sprite("a.png");
  5478. this.addChild(sp);
  5479. cc.pool.putInPool(sp);
  5480. cc.pool.getFromPool(_ccsg.Sprite, "a.png");
  5481. ```
  5482. */
  5483. putInPool(obj: any): void;
  5484. /**
  5485. !#en Check if this kind of obj has already in pool.
  5486. !#zh 检查对象池中是否有指定对象的存在。
  5487. @param objClass The check object class.
  5488. */
  5489. hasObject(objClass: any): boolean;
  5490. /**
  5491. !#en Remove the obj if you want to delete it.
  5492. !#zh 移除在对象池中指定的对象。
  5493. */
  5494. removeObject(): void;
  5495. /**
  5496. !#en Get the obj from pool.
  5497. !#zh 获取对象池中的指定对象。
  5498. */
  5499. getFromPool(): any;
  5500. /**
  5501. !#en Remove all objs in pool and reset the pool.
  5502. !#zh 移除对象池中的所有对象,并且重置对象池。
  5503. */
  5504. drainAllPools(): void;
  5505. }
  5506. /** !#en
  5507. Camera is usefull when making reel game or other games which need scroll screen.
  5508. Using camera will be more efficient than moving node to scroll screen.
  5509. Camera
  5510. !#zh
  5511. 摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
  5512. export class Camera extends _RendererUnderSG {
  5513. /** !#en
  5514. The camera zoom ratio.
  5515. !#zh
  5516. 摄像机缩放比率 */
  5517. zoomRatio: number;
  5518. /** !#en
  5519. Current active camera, the scene should only have one active camera at the same time.
  5520. !#zh
  5521. 当前激活的摄像机,场景中在同一时间内只能有一个激活的摄像机。 */
  5522. static main: Camera;
  5523. /**
  5524. !#en
  5525. Add the specified target to camera.
  5526. !#zh
  5527. 将指定的节点添加到摄像机中。
  5528. @param target target
  5529. */
  5530. addTarget(target: Node): void;
  5531. /**
  5532. !#en
  5533. Remove the specified target from camera.
  5534. !#zh
  5535. 将指定的节点从摄像机中移除。
  5536. @param target target
  5537. */
  5538. removeTarget(target: Node): void;
  5539. /**
  5540. !#en
  5541. Get all camera targets.
  5542. !#zh
  5543. 获取所有摄像机目标节点。
  5544. */
  5545. getTargets(): [Node];
  5546. /**
  5547. !#en
  5548. Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
  5549. !#zh
  5550. 返回一个将节点坐标系转换到摄像机坐标系下的矩阵
  5551. @param node the node which should transform
  5552. */
  5553. getNodeToCameraTransform(node: Node): AffineTransform;
  5554. /**
  5555. !#en
  5556. Conver a camera coordinates point to world coordinates.
  5557. !#zh
  5558. 将一个摄像机坐标系下的点转换到世界坐标系下。
  5559. @param point the point which should transform
  5560. */
  5561. getCameraToWorldPoint(point: Node): Vec2;
  5562. /**
  5563. !#en
  5564. Check whether the node is in the camera.
  5565. !#zh
  5566. 检测节点是否被此摄像机影响
  5567. @param node the node which need to check
  5568. */
  5569. containsNode(node: Node): boolean;
  5570. }
  5571. /** !#en Box Collider.
  5572. !#zh 包围盒碰撞组件 */
  5573. export class BoxCollider extends Collider implements Collider.Box {
  5574. /** !#en Position offset
  5575. !#zh 位置偏移量 */
  5576. offset: Vec2;
  5577. /** !#en Box size
  5578. !#zh 包围盒大小 */
  5579. size: Size;
  5580. }
  5581. /** !#en Circle Collider.
  5582. !#zh 圆形碰撞组件 */
  5583. export class CircleCollider extends Collider implements Collider.Circle {
  5584. /** !#en Position offset
  5585. !#zh 位置偏移量 */
  5586. offset: Vec2;
  5587. /** !#en Circle radius
  5588. !#zh 圆形半径 */
  5589. radius: number;
  5590. }
  5591. /** !#en Collider component base class.
  5592. !#zh 碰撞组件基类 */
  5593. export class Collider extends Component {
  5594. /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
  5595. !#zh 标签。当一个节点上有多个碰撞组件时,在发生碰撞后,可以使用此标签来判断是节点上的哪个碰撞组件被碰撞了。 */
  5596. tag: number;
  5597. }
  5598. /** !#en
  5599. A simple collision manager class.
  5600. It will calculate whether the collider collides other colliders, if collides then call the callbacks.
  5601. !#zh
  5602. 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 */
  5603. export class CollisionManager implements EventTarget {
  5604. /** !#en
  5605. !#zh
  5606. 是否开启碰撞管理,默认为不开启 */
  5607. enabled: boolean;
  5608. /** !#en
  5609. !#zh
  5610. 是否绘制碰撞组件的包围盒,默认为不绘制 */
  5611. enabledDrawBoundingBox: boolean;
  5612. /** !#en
  5613. !#zh
  5614. 是否绘制碰撞组件的形状,默认为不绘制 */
  5615. enabledDebugDraw: boolean;
  5616. /**
  5617. !#en
  5618. Register an callback of a specific event type on the EventTarget.
  5619. !#zh
  5620. 注册事件目标的特定事件类型回调。
  5621. @param type A string representing the event type to listen for.
  5622. @param callback The callback that will be invoked when the event is dispatched.
  5623. The callback is ignored if it is a duplicate (the callbacks are unique).
  5624. @param target The target (this object) to invoke the callback, can be null
  5625. @param useCapture When set to true, the capture argument prevents callback
  5626. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5627. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5628. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5629. @example
  5630. ```js
  5631. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5632. cc.log("this is callback");
  5633. }, node);
  5634. ```
  5635. */
  5636. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5637. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5638. /**
  5639. !#en
  5640. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5641. if only type is passed as parameter, all listeners registered with that type will be removed.
  5642. !#zh
  5643. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5644. @param type A string representing the event type being removed.
  5645. @param callback The callback to remove.
  5646. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5647. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5648. If not specified, useCapture defaults to false. If a callback was registered twice,
  5649. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5650. does not affect a non-capturing version of the same listener, and vice versa.
  5651. @example
  5652. ```js
  5653. // register touchEnd eventListener
  5654. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5655. cc.log("this is callback");
  5656. }, node);
  5657. // remove touch end event listener
  5658. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5659. // remove all touch end event listeners
  5660. node.off(cc.Node.EventType.TOUCH_END);
  5661. ```
  5662. */
  5663. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5664. /**
  5665. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5666. This is not for removing all listeners in the current event target,
  5667. and this is not for removing all listeners the target parameter have registered.
  5668. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5669. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5670. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5671. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5672. @param target The target to be searched for all related listeners
  5673. */
  5674. targetOff(target: any): void;
  5675. /**
  5676. !#en
  5677. Register an callback of a specific event type on the EventTarget,
  5678. the callback will remove itself after the first time it is triggered.
  5679. !#zh
  5680. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5681. @param type A string representing the event type to listen for.
  5682. @param callback The callback that will be invoked when the event is dispatched.
  5683. The callback is ignored if it is a duplicate (the callbacks are unique).
  5684. @param target The target (this object) to invoke the callback, can be null
  5685. @param useCapture When set to true, the capture argument prevents callback
  5686. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5687. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5688. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5689. @example
  5690. ```js
  5691. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5692. cc.log("this is callback");
  5693. }, node);
  5694. ```
  5695. */
  5696. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5697. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5698. /**
  5699. !#en
  5700. Dispatches an event into the event flow.
  5701. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5702. !#zh 分发事件到事件流中。
  5703. @param event The Event object that is dispatched into the event flow
  5704. */
  5705. dispatchEvent(event: Event): void;
  5706. /**
  5707. !#en
  5708. Send an event to this object directly, this method will not propagate the event to any other objects.
  5709. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5710. !#zh
  5711. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5712. @param message the message to send
  5713. @param detail whatever argument the message needs
  5714. */
  5715. emit(message: string, detail?: any): void;
  5716. }
  5717. /** !#en Intersection helper class
  5718. !#zh 辅助类,用于测试形状与形状是否相交 */
  5719. export class Intersection {
  5720. /**
  5721. !#en Test line and line
  5722. !#zh 测试线段与线段是否相交
  5723. @param a1 The start point of the first line
  5724. @param a2 The end point of the first line
  5725. @param b1 The start point of the second line
  5726. @param b2 The end point of the second line
  5727. */
  5728. static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
  5729. /**
  5730. !#en Test line and rect
  5731. !#zh 测试线段与矩形是否相交
  5732. @param a1 The start point of the line
  5733. @param a2 The end point of the line
  5734. @param b The rect
  5735. */
  5736. static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
  5737. /**
  5738. !#en Test line and polygon
  5739. !#zh 测试线段与多边形是否相交
  5740. @param a1 The start point of the line
  5741. @param a2 The end point of the line
  5742. @param b The polygon, a set of points
  5743. */
  5744. static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
  5745. /**
  5746. !#en Test rect and rect
  5747. !#zh 测试矩形与矩形是否相交
  5748. @param a The first rect
  5749. @param b The second rect
  5750. */
  5751. static rectRect(a: Rect, b: Rect): boolean;
  5752. /**
  5753. !#en Test rect and polygon
  5754. !#zh 测试矩形与多边形是否相交
  5755. @param a The rect
  5756. @param b The polygon, a set of points
  5757. */
  5758. static rectPolygon(a: Rect, b: Vec2[]): boolean;
  5759. /**
  5760. !#en Test polygon and polygon
  5761. !#zh 测试多边形与多边形是否相交
  5762. @param a The first polygon, a set of points
  5763. @param b The second polygon, a set of points
  5764. */
  5765. static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
  5766. /**
  5767. !#en Test circle and circle
  5768. !#zh 测试圆形与圆形是否相交
  5769. @param a Object contains position and radius
  5770. @param b Object contains position and radius
  5771. */
  5772. static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
  5773. /**
  5774. !#en Test polygon and circle
  5775. !#zh 测试矩形与圆形是否相交
  5776. @param polygon The Polygon, a set of points
  5777. @param circle Object contains position and radius
  5778. */
  5779. static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
  5780. /**
  5781. !#en Test whether the point is in the polygon
  5782. !#zh 测试一个点是否在一个多边形中
  5783. @param point The point
  5784. @param polygon The polygon, a set of points
  5785. */
  5786. static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
  5787. /**
  5788. !#en Calculate the distance of point to line.
  5789. !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。
  5790. @param point The point
  5791. @param start The start point of line
  5792. @param end The end point of line
  5793. @param isSegment whether this line is a segment
  5794. */
  5795. static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): boolean;
  5796. }
  5797. /** !#en Polygon Collider.
  5798. !#zh 多边形碰撞组件 */
  5799. export class PolygonCollider extends Collider implements Collider.Polygon {
  5800. /** !#en Position offset
  5801. !#zh 位置偏移量 */
  5802. offset: Vec2;
  5803. /** !#en Polygon points
  5804. !#zh 多边形顶点数组 */
  5805. points: Vec2[];
  5806. }
  5807. /** !#en
  5808. Base class for handling assets used in Creator.<br/>
  5809. You may want to override:<br/>
  5810. - createNode<br/>
  5811. - getset functions of _nativeAsset<br/>
  5812. - cc.Object._serialize<br/>
  5813. - cc.Object._deserialize<br/>
  5814. !#zh
  5815. Creator 中的资源基类。<br/>
  5816. 您可能需要重写:<br/>
  5817. - createNode <br/>
  5818. - _nativeAsset 的 getset 方法<br/>
  5819. - cc.Object._serialize<br/>
  5820. - cc.Object._deserialize<br/> */
  5821. export class Asset extends RawAsset {
  5822. /** !#en
  5823. Whether the asset is loaded or not
  5824. !#zh
  5825. 该资源是否已经成功加载 */
  5826. loaded: boolean;
  5827. /** !#en
  5828. Returns the url of this asset's native object, if none it will returns an empty string.
  5829. !#zh
  5830. 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
  5831. nativeUrl: string;
  5832. /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
  5833. !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。 */
  5834. static preventDeferredLoadDependents: boolean;
  5835. /** !#en Indicates whether its native object should be preloaded from native url.
  5836. !#zh 禁止预加载原生对象。 */
  5837. static preventPreloadNativeObject: boolean;
  5838. /**
  5839. Returns the asset's url.
  5840. The `Asset` object overrides the `toString()` method of the `Object` object.
  5841. For `Asset` objects, the toString() method returns a string representation of the object.
  5842. JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
  5843. */
  5844. toString(): string;
  5845. /**
  5846. !#en
  5847. Create a new node using this asset in the scene.<br/>
  5848. If this type of asset dont have its corresponding node type, this method should be null.
  5849. !#zh
  5850. 使用该资源在场景中创建一个新节点。<br/>
  5851. 如果这类资源没有相应的节点类型,该方法应该是空的。
  5852. @param callback callback
  5853. */
  5854. createNode(callback: (error: string, node: any) => void): void;
  5855. }
  5856. /** !#en Class for audio data handling.
  5857. !#zh 音频资源类。 */
  5858. export class AudioClip extends Asset implements EventTarget {
  5859. /**
  5860. !#en
  5861. Register an callback of a specific event type on the EventTarget.
  5862. !#zh
  5863. 注册事件目标的特定事件类型回调。
  5864. @param type A string representing the event type to listen for.
  5865. @param callback The callback that will be invoked when the event is dispatched.
  5866. The callback is ignored if it is a duplicate (the callbacks are unique).
  5867. @param target The target (this object) to invoke the callback, can be null
  5868. @param useCapture When set to true, the capture argument prevents callback
  5869. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5870. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5871. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5872. @example
  5873. ```js
  5874. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5875. cc.log("this is callback");
  5876. }, node);
  5877. ```
  5878. */
  5879. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5880. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5881. /**
  5882. !#en
  5883. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  5884. if only type is passed as parameter, all listeners registered with that type will be removed.
  5885. !#zh
  5886. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  5887. @param type A string representing the event type being removed.
  5888. @param callback The callback to remove.
  5889. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  5890. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  5891. If not specified, useCapture defaults to false. If a callback was registered twice,
  5892. one with capture and one without, each must be removed separately. Removal of a capturing callback
  5893. does not affect a non-capturing version of the same listener, and vice versa.
  5894. @example
  5895. ```js
  5896. // register touchEnd eventListener
  5897. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  5898. cc.log("this is callback");
  5899. }, node);
  5900. // remove touch end event listener
  5901. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  5902. // remove all touch end event listeners
  5903. node.off(cc.Node.EventType.TOUCH_END);
  5904. ```
  5905. */
  5906. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  5907. /**
  5908. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  5909. This is not for removing all listeners in the current event target,
  5910. and this is not for removing all listeners the target parameter have registered.
  5911. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  5912. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  5913. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  5914. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  5915. @param target The target to be searched for all related listeners
  5916. */
  5917. targetOff(target: any): void;
  5918. /**
  5919. !#en
  5920. Register an callback of a specific event type on the EventTarget,
  5921. the callback will remove itself after the first time it is triggered.
  5922. !#zh
  5923. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  5924. @param type A string representing the event type to listen for.
  5925. @param callback The callback that will be invoked when the event is dispatched.
  5926. The callback is ignored if it is a duplicate (the callbacks are unique).
  5927. @param target The target (this object) to invoke the callback, can be null
  5928. @param useCapture When set to true, the capture argument prevents callback
  5929. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  5930. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  5931. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  5932. @example
  5933. ```js
  5934. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  5935. cc.log("this is callback");
  5936. }, node);
  5937. ```
  5938. */
  5939. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  5940. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  5941. /**
  5942. !#en
  5943. Dispatches an event into the event flow.
  5944. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  5945. !#zh 分发事件到事件流中。
  5946. @param event The Event object that is dispatched into the event flow
  5947. */
  5948. dispatchEvent(event: Event): void;
  5949. /**
  5950. !#en
  5951. Send an event to this object directly, this method will not propagate the event to any other objects.
  5952. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  5953. !#zh
  5954. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  5955. @param message the message to send
  5956. @param detail whatever argument the message needs
  5957. */
  5958. emit(message: string, detail?: any): void;
  5959. }
  5960. /** !#en Class for BitmapFont handling.
  5961. !#zh 位图字体资源类。 */
  5962. export class BitmapFont extends Font {
  5963. }
  5964. /** !#en Class for Font handling.
  5965. !#zh 字体资源类。 */
  5966. export class Font extends Asset {
  5967. }
  5968. /** !#en
  5969. Class for JSON file. When the JSON file is loaded, this object is returned.
  5970. The parsed JSON object can be accessed through the `json` attribute in it.<br>
  5971. If you want to get the original JSON text, you should modify the extname to `.txt`
  5972. so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
  5973. !#zh
  5974. JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。<br>
  5975. 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */
  5976. export class JsonAsset extends Asset {
  5977. /** The loaded JSON object. */
  5978. json: any;
  5979. }
  5980. /** !#en Class for LabelAtlas handling.
  5981. !#zh 艺术数字字体资源类。 */
  5982. export class LabelAtlas extends BitmapFont {
  5983. }
  5984. /** !#en Class for prefab handling.
  5985. !#zh 预制资源类。 */
  5986. export class Prefab extends Asset {
  5987. /** the main cc.Node in the prefab */
  5988. data: Node;
  5989. /** !#zh
  5990. 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
  5991. !#en
  5992. Indicates the optimization policy for instantiating this prefab.
  5993. Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
  5994. optimizationPolicy: Prefab.OptimizationPolicy;
  5995. /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
  5996. !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
  5997. asyncLoadAssets: boolean;
  5998. /**
  5999. Dynamically translation prefab data into minimized code.<br/>
  6000. This method will be called automatically before the first time the prefab being instantiated,
  6001. but you can re-call to refresh the create function once you modified the original prefab data in script.
  6002. */
  6003. compileCreateFunction(): void;
  6004. }
  6005. /** !#en
  6006. The base class for registering asset types.
  6007. !#zh
  6008. 注册用的资源基类。 */
  6009. export class RawAsset extends Object {
  6010. }
  6011. /** !#en Class for scene handling.
  6012. !#zh 场景资源类。 */
  6013. export class SceneAsset extends Asset {
  6014. scene: Scene;
  6015. /** !#en Indicates the raw assets of this scene can be load after scene launched.
  6016. !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
  6017. asyncLoadAssets: boolean;
  6018. }
  6019. /** !#en Class for script handling.
  6020. !#zh Script 资源类。 */
  6021. export class _Script extends Asset {
  6022. }
  6023. /** !#en Class for JavaScript handling.
  6024. !#zh JavaScript 资源类。 */
  6025. export class _JavaScript extends Asset {
  6026. }
  6027. /** !#en Class for coffeescript handling.
  6028. !#zh CoffeeScript 资源类。 */
  6029. export class CoffeeScript extends Asset {
  6030. }
  6031. /** !#en Class for TypeScript handling.
  6032. !#zh TypeScript 资源类。 */
  6033. export class TypeScript extends Asset {
  6034. }
  6035. /** !#en Class for sprite atlas handling.
  6036. !#zh 精灵图集资源类。 */
  6037. export class SpriteAtlas extends Asset {
  6038. /**
  6039. Returns the texture of the sprite atlas
  6040. */
  6041. getTexture(): Texture2D;
  6042. /**
  6043. Returns the sprite frame correspond to the given key in sprite atlas.
  6044. @param key key
  6045. */
  6046. getSpriteFrame(key: string): SpriteFrame;
  6047. /**
  6048. Returns the sprite frames in sprite atlas.
  6049. */
  6050. getSpriteFrames(): [SpriteFrame];
  6051. }
  6052. /** !#en Class for TTFFont handling.
  6053. !#zh TTF 字体资源类。 */
  6054. export class TTFFont extends Font {
  6055. }
  6056. /** !#en Class for text file.
  6057. !#zh 文本资源类。 */
  6058. export class TextAsset extends Asset {
  6059. /** The text contents of the resource. */
  6060. text: string;
  6061. }
  6062. /** !#en The animation component is used to play back animations.
  6063. Animation provide several events to register:
  6064. - play : Emit when begin playing animation
  6065. - stop : Emit when stop playing animation
  6066. - pause : Emit when pause animation
  6067. - resume : Emit when resume animation
  6068. - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
  6069. - finished : Emit when finish playing animation
  6070. !#zh Animation 组件用于播放动画。
  6071. Animation 提供了一系列可注册的事件:
  6072. - play : 开始播放时
  6073. - stop : 停止播放时
  6074. - pause : 暂停播放时
  6075. - resume : 恢复播放时
  6076. - lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
  6077. - finished : 动画播放完成时 */
  6078. export class Animation extends Component implements EventTarget {
  6079. /** !#en Animation will play the default clip when start game.
  6080. !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
  6081. defaultClip: AnimationClip;
  6082. /** !#en Current played clip.
  6083. !#zh 当前播放的动画剪辑。 */
  6084. currentClip: AnimationClip;
  6085. /** !#en Whether the animation should auto play the default clip when start game.
  6086. !#zh 是否在运行游戏后自动播放默认动画剪辑。 */
  6087. playOnLoad: boolean;
  6088. /**
  6089. !#en Get all the clips used in this animation.
  6090. !#zh 获取动画组件上的所有动画剪辑。
  6091. */
  6092. getClips(): AnimationClip[];
  6093. /**
  6094. !#en Plays an animation and stop other animations.
  6095. !#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
  6096. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  6097. @param startTime play an animation from startTime
  6098. @example
  6099. ```js
  6100. var animCtrl = this.node.getComponent(cc.Animation);
  6101. animCtrl.play("linear");
  6102. ```
  6103. */
  6104. play(name?: string, startTime?: number): AnimationState;
  6105. /**
  6106. !#en
  6107. Plays an additive animation, it will not stop other animations.
  6108. If there are other animations playing, then will play several animations at the same time.
  6109. !#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
  6110. @param name The name of animation to play. If no name is supplied then the default animation will be played.
  6111. @param startTime play an animation from startTime
  6112. @example
  6113. ```js
  6114. // linear_1 and linear_2 at the same time playing.
  6115. var animCtrl = this.node.getComponent(cc.Animation);
  6116. animCtrl.playAdditive("linear_1");
  6117. animCtrl.playAdditive("linear_2");
  6118. ```
  6119. */
  6120. playAdditive(name?: string, startTime?: number): AnimationState;
  6121. /**
  6122. !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/>
  6123. Stopping an animation also Rewinds it to the Start.
  6124. !#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
  6125. @param name The animation to stop, if not supplied then stops all playing animations.
  6126. */
  6127. stop(name?: string): void;
  6128. /**
  6129. !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
  6130. !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
  6131. @param name The animation to pauses, if not supplied then pauses all playing animations.
  6132. */
  6133. pause(name?: string): void;
  6134. /**
  6135. !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
  6136. !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
  6137. @param name The animation to resumes, if not supplied then resumes all paused animations.
  6138. */
  6139. resume(name?: string): void;
  6140. /**
  6141. !#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.
  6142. !#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
  6143. @param time The time to go to
  6144. @param name Specified animation name, if not supplied then make all animations go to the time.
  6145. */
  6146. setCurrentTime(time?: number, name?: string): void;
  6147. /**
  6148. !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
  6149. !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
  6150. @param name name
  6151. */
  6152. getAnimationState(name: string): AnimationState;
  6153. /**
  6154. !#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.
  6155. !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
  6156. @param clip the clip to add
  6157. @param newName newName
  6158. */
  6159. addClip(clip: AnimationClip, newName?: string): AnimationState;
  6160. /**
  6161. !#en
  6162. Remove clip from the animation list. This will remove the clip and any animation states based on it.
  6163. If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
  6164. 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
  6165. !#zh
  6166. 从动画列表中移除指定的动画剪辑,<br/>
  6167. 如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
  6168. 但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
  6169. @param clip clip
  6170. @param force If force is true, then will always remove the clip and any animation states based on it.
  6171. */
  6172. removeClip(clip: AnimationClip, force?: boolean): void;
  6173. /**
  6174. !#en
  6175. Samples animations at the current state.<br/>
  6176. This is useful when you explicitly want to set up some animation state, and sample it once.
  6177. !#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
  6178. @param name name
  6179. */
  6180. sample(name: string): void;
  6181. /**
  6182. !#en
  6183. Register animation event callback.
  6184. The event arguments will provide the AnimationState which emit the event.
  6185. When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
  6186. !#zh
  6187. 注册动画事件回调。
  6188. 回调的事件里将会附上发送事件的 AnimationState。
  6189. 当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
  6190. @param type A string representing the event type to listen for.
  6191. @param callback The callback that will be invoked when the event is dispatched.
  6192. The callback is ignored if it is a duplicate (the callbacks are unique).
  6193. @param target The target (this object) to invoke the callback, can be null
  6194. @param useCapture When set to true, the capture argument prevents callback
  6195. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  6196. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  6197. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  6198. @example
  6199. ```js
  6200. onPlay: function (event) {
  6201. var state = event.detail; // state instanceof cc.AnimationState
  6202. var type = event.type; // type === 'play';
  6203. }
  6204. // register event to all animation
  6205. animation.on('play', this.onPlay, this);
  6206. ```
  6207. */
  6208. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  6209. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  6210. /**
  6211. !#en
  6212. Unregister animation event callback.
  6213. !#zh
  6214. 取消注册动画事件回调。
  6215. @param type A string representing the event type being removed.
  6216. @param callback The callback to remove.
  6217. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  6218. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  6219. If not specified, useCapture defaults to false. If a callback was registered twice,
  6220. one with capture and one without, each must be removed separately. Removal of a capturing callback
  6221. does not affect a non-capturing version of the same listener, and vice versa.
  6222. @example
  6223. ```js
  6224. // unregister event to all animation
  6225. animation.off('play', this.onPlay, this);
  6226. ```
  6227. */
  6228. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  6229. /**
  6230. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  6231. This is not for removing all listeners in the current event target,
  6232. and this is not for removing all listeners the target parameter have registered.
  6233. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  6234. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  6235. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  6236. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  6237. @param target The target to be searched for all related listeners
  6238. */
  6239. targetOff(target: any): void;
  6240. /**
  6241. !#en
  6242. Register an callback of a specific event type on the EventTarget,
  6243. the callback will remove itself after the first time it is triggered.
  6244. !#zh
  6245. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  6246. @param type A string representing the event type to listen for.
  6247. @param callback The callback that will be invoked when the event is dispatched.
  6248. The callback is ignored if it is a duplicate (the callbacks are unique).
  6249. @param target The target (this object) to invoke the callback, can be null
  6250. @param useCapture When set to true, the capture argument prevents callback
  6251. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  6252. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  6253. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  6254. @example
  6255. ```js
  6256. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  6257. cc.log("this is callback");
  6258. }, node);
  6259. ```
  6260. */
  6261. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  6262. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  6263. /**
  6264. !#en
  6265. Dispatches an event into the event flow.
  6266. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  6267. !#zh 分发事件到事件流中。
  6268. @param event The Event object that is dispatched into the event flow
  6269. */
  6270. dispatchEvent(event: Event): void;
  6271. /**
  6272. !#en
  6273. Send an event to this object directly, this method will not propagate the event to any other objects.
  6274. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  6275. !#zh
  6276. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  6277. @param message the message to send
  6278. @param detail whatever argument the message needs
  6279. */
  6280. emit(message: string, detail?: any): void;
  6281. }
  6282. /** !#en Audio Source.
  6283. !#zh 音频源组件,能对音频剪辑。 */
  6284. export class AudioSource extends Component {
  6285. /** !#en
  6286. Is the audio source playing (Read Only). <br/>
  6287. Note: isPlaying is not supported for Native platforms.
  6288. !#zh
  6289. 该音频剪辑是否正播放(只读)。<br/>
  6290. 注意:Native 平台暂时不支持 isPlaying。 */
  6291. isPlaying: boolean;
  6292. /** !#en The clip of the audio source to play.
  6293. !#zh 要播放的音频剪辑。 */
  6294. clip: AudioClip;
  6295. /** !#en The volume of the audio source.
  6296. !#zh 音频源的音量(0.0 ~ 1.0)。 */
  6297. volume: number;
  6298. /** !#en Is the audio source mute?
  6299. !#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
  6300. mute: boolean;
  6301. /** !#en Is the audio source looping?
  6302. !#zh 音频源是否循环播放? */
  6303. loop: boolean;
  6304. /** !#en If set to true, the audio source will automatically start playing on onEnable.
  6305. !#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */
  6306. playOnLoad: boolean;
  6307. /**
  6308. !#en Plays the clip.
  6309. !#zh 播放音频剪辑。
  6310. */
  6311. play(): void;
  6312. /**
  6313. !#en Stops the clip.
  6314. !#zh 停止当前音频剪辑。
  6315. */
  6316. stop(): void;
  6317. /**
  6318. !#en Pause the clip.
  6319. !#zh 暂停当前音频剪辑。
  6320. */
  6321. pause(): void;
  6322. /**
  6323. !#en Resume the clip.
  6324. !#zh 恢复播放。
  6325. */
  6326. resume(): void;
  6327. /**
  6328. !#en Rewind playing music.
  6329. !#zh 从头开始播放。
  6330. */
  6331. rewind(): void;
  6332. /**
  6333. !#en Get current time
  6334. !#zh 获取当前的播放时间
  6335. */
  6336. getCurrentTime(): void;
  6337. /**
  6338. !#en Set current time
  6339. !#zh 设置当前的播放时间
  6340. @param time time
  6341. */
  6342. setCurrentTime(time: number): void;
  6343. /**
  6344. !#en Get audio duration
  6345. !#zh 获取当前音频的长度
  6346. */
  6347. getDuration(): void;
  6348. }
  6349. /** !#en
  6350. 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>
  6351. This component does not have any API interface and can be added directly to the scene to take effect.
  6352. !#zh
  6353. 该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。<br>
  6354. 该组件没有任何 API 接口,直接添加到场景即可生效。 */
  6355. export class BlockInputEvents extends Component {
  6356. }
  6357. /** !#en
  6358. Button has 4 Transition types<br/>
  6359. When Button state changed:<br/>
  6360. If Transition type is Button.Transition.NONE, Button will do nothing<br/>
  6361. If Transition type is Button.Transition.COLOR, Button will change target's color<br/>
  6362. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite<br/>
  6363. If Transition type is Button.Transition.SCALE, Button will change target node's scale<br/>
  6364. Button will trigger 5 events:<br/>
  6365. Button.EVENT_TOUCH_DOWN<br/>
  6366. Button.EVENT_TOUCH_UP<br/>
  6367. Button.EVENT_HOVER_IN<br/>
  6368. Button.EVENT_HOVER_MOVE<br/>
  6369. Button.EVENT_HOVER_OUT<br/>
  6370. !#zh
  6371. 按钮组件。可以被按下,或者点击。<br/>
  6372. 按钮可以通过修改 Transition 来设置按钮状态过渡的方式:<br/>
  6373. -Button.Transition.NONE // 不做任何过渡<br/>
  6374. -Button.Transition.COLOR // 进行颜色之间过渡<br/>
  6375. -Button.Transition.SPRITE // 进行精灵之间过渡<br/>
  6376. -Button.Transition.SCALE // 进行缩放过渡<br/>
  6377. 按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):<br/>
  6378. // 以下事件可以在全平台上都触发<br/>
  6379. -cc.Node.EventType.TOUCH_START // 按下时事件<br/>
  6380. -cc.Node.EventType.TOUCH_Move // 按住移动后事件<br/>
  6381. -cc.Node.EventType.TOUCH_END // 按下后松开后事件<br/>
  6382. -cc.Node.EventType.TOUCH_CANCEL // 按下取消事件<br/>
  6383. // 以下事件只在 PC 平台上触发<br/>
  6384. -cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件<br/>
  6385. -cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件<br/>
  6386. -cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件<br/>
  6387. -cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件<br/>
  6388. -cc.Node.EventType.MOUSE_UP // 鼠标松开事件<br/>
  6389. -cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件<br/> */
  6390. export class Button extends Component {
  6391. /** !#en
  6392. Whether the Button is disabled.
  6393. If true, the Button will trigger event and do transition.
  6394. !#zh
  6395. 按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
  6396. interactable: boolean;
  6397. /** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
  6398. !#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
  6399. enableAutoGrayEffect: boolean;
  6400. /** !#en Transition type
  6401. !#zh 按钮状态改变时过渡方式。 */
  6402. transition: Button.Transition;
  6403. /** !#en Normal state color.
  6404. !#zh 普通状态下按钮所显示的颜色。 */
  6405. normalColor: Color;
  6406. /** !#en Pressed state color
  6407. !#zh 按下状态时按钮所显示的颜色。 */
  6408. pressedColor: Color;
  6409. /** !#en Hover state color
  6410. !#zh 悬停状态下按钮所显示的颜色。 */
  6411. hoverColor: Color;
  6412. /** !#en Disabled state color
  6413. !#zh 禁用状态下按钮所显示的颜色。 */
  6414. disabledColor: Color;
  6415. /** !#en Color and Scale transition duration
  6416. !#zh 颜色过渡和缩放过渡时所需时间 */
  6417. duration: number;
  6418. /** !#en When user press the button, the button will zoom to a scale.
  6419. The final scale of the button equals (button original scale * zoomScale)
  6420. !#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
  6421. zoomScale: number;
  6422. /** !#en Normal state sprite
  6423. !#zh 普通状态下按钮所显示的 Sprite 。 */
  6424. normalSprite: SpriteFrame;
  6425. /** !#en Pressed state sprite
  6426. !#zh 按下状态时按钮所显示的 Sprite 。 */
  6427. pressedSprite: SpriteFrame;
  6428. /** !#en Hover state sprite
  6429. !#zh 悬停状态下按钮所显示的 Sprite 。 */
  6430. hoverSprite: SpriteFrame;
  6431. /** !#en Disabled state sprite
  6432. !#zh 禁用状态下按钮所显示的 Sprite 。 */
  6433. disabledSprite: SpriteFrame;
  6434. /** !#en
  6435. Transition target.
  6436. When Button state changed:
  6437. If Transition type is Button.Transition.NONE, Button will do nothing
  6438. If Transition type is Button.Transition.COLOR, Button will change target's color
  6439. If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
  6440. !#zh
  6441. 需要过渡的目标。
  6442. 当前按钮状态改变规则:
  6443. -如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
  6444. -如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
  6445. -如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
  6446. target: Node;
  6447. /** !#en If Button is clicked, it will trigger event's handler
  6448. !#zh 按钮的点击事件列表。 */
  6449. clickEvents: Component.EventHandler[];
  6450. }
  6451. /** !#zh: 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
  6452. 注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
  6453. export class Canvas extends Component {
  6454. /** !#en Current active canvas, the scene should only have one active canvas at the same time.
  6455. !#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
  6456. static instance: Canvas;
  6457. /** !#en The desigin resolution for current scene.
  6458. !#zh 当前场景设计分辨率。 */
  6459. designResolution: Size;
  6460. /** !#en TODO
  6461. !#zh: 是否优先将设计分辨率高度撑满视图高度。 */
  6462. fitHeight: boolean;
  6463. /** !#en TODO
  6464. !#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
  6465. fitWidth: boolean;
  6466. }
  6467. /** !#en
  6468. Base class for everything attached to Node(Entity).<br/>
  6469. <br/>
  6470. NOTE: Not allowed to use construction parameters for Component's subclasses,
  6471. because Component is created by the engine.
  6472. !#zh
  6473. 所有附加到节点的基类。<br/>
  6474. <br/>
  6475. 注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
  6476. export class Component extends Object {
  6477. /** !#en The node this component is attached to. A component is always attached to a node.
  6478. !#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
  6479. node: Node;
  6480. /** !#en The uuid for editor.
  6481. !#zh 组件的 uuid,用于编辑器。 */
  6482. uuid: string;
  6483. /** !#en indicates whether this component is enabled or not.
  6484. !#zh 表示该组件自身是否启用。 */
  6485. enabled: boolean;
  6486. /** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
  6487. !#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
  6488. enabledInHierarchy: boolean;
  6489. /** !#en Returns a value which used to indicate the onLoad get called or not.
  6490. !#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
  6491. _isOnLoadCalled: number;
  6492. /**
  6493. !#en Update is called every frame, if the Component is enabled.
  6494. !#zh 如果该组件启用,则每帧调用 update。
  6495. @param dt the delta time in seconds it took to complete the last frame
  6496. */
  6497. protected update(dt: number): void;
  6498. /**
  6499. !#en LateUpdate is called every frame, if the Component is enabled.
  6500. !#zh 如果该组件启用,则每帧调用 LateUpdate。
  6501. */
  6502. protected lateUpdate(): void;
  6503. /**
  6504. !#en
  6505. When attaching to an active node or its node first activated.
  6506. onLoad is always called before any start functions, this allows you to order initialization of scripts.
  6507. !#zh
  6508. 当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
  6509. */
  6510. protected onLoad(): void;
  6511. /**
  6512. !#en
  6513. Called before all scripts' update if the Component is enabled the first time.
  6514. Usually used to initialize some logic which need to be called after all components' `onload` methods called.
  6515. !#zh
  6516. 如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
  6517. */
  6518. protected start(): void;
  6519. /**
  6520. !#en Called when this component becomes enabled and its node is active.
  6521. !#zh 当该组件被启用,并且它的节点也激活时。
  6522. */
  6523. protected onEnable(): void;
  6524. /**
  6525. !#en Called when this component becomes disabled or its node becomes inactive.
  6526. !#zh 当该组件被禁用或节点变为无效时调用。
  6527. */
  6528. protected onDisable(): void;
  6529. /**
  6530. !#en Called when this component will be destroyed.
  6531. !#zh 当该组件被销毁时调用
  6532. */
  6533. protected onDestroy(): void;
  6534. protected onFocusInEditor(): void;
  6535. protected onLostFocusInEditor(): void;
  6536. /**
  6537. !#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.
  6538. !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
  6539. */
  6540. protected resetInEditor(): void;
  6541. /**
  6542. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  6543. !#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  6544. @param typeOrClassName the constructor or the class name of the component to add
  6545. @example
  6546. ```js
  6547. var sprite = node.addComponent(cc.Sprite);
  6548. var test = node.addComponent("Test");
  6549. ```
  6550. */
  6551. addComponent<T extends Component>(type: {new(): T}): T;
  6552. addComponent(className: string): any;
  6553. /**
  6554. !#en
  6555. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  6556. You can also get component in the node by passing in the name of the script.
  6557. !#zh
  6558. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  6559. 传入参数也可以是脚本的名称。
  6560. @param typeOrClassName typeOrClassName
  6561. @example
  6562. ```js
  6563. // get sprite component.
  6564. var sprite = node.getComponent(cc.Sprite);
  6565. // get custom test calss.
  6566. var test = node.getComponent("Test");
  6567. ```
  6568. */
  6569. getComponent<T extends Component>(type: {prototype: T}): T;
  6570. getComponent(className: string): any;
  6571. /**
  6572. !#en Returns all components of supplied Type in the node.
  6573. !#zh 返回节点上指定类型的所有组件。
  6574. @param typeOrClassName typeOrClassName
  6575. @example
  6576. ```js
  6577. var sprites = node.getComponents(cc.Sprite);
  6578. var tests = node.getComponents("Test");
  6579. ```
  6580. */
  6581. getComponents<T extends Component>(type: {prototype: T}): T[];
  6582. getComponents(className: string): any[];
  6583. /**
  6584. !#en Returns the component of supplied type in any of its children using depth first search.
  6585. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  6586. @param typeOrClassName typeOrClassName
  6587. @example
  6588. ```js
  6589. var sprite = node.getComponentInChildren(cc.Sprite);
  6590. var Test = node.getComponentInChildren("Test");
  6591. ```
  6592. */
  6593. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  6594. getComponentInChildren(className: string): any;
  6595. /**
  6596. !#en Returns the components of supplied type in self or any of its children using depth first search.
  6597. !#zh 递归查找自身或所有子节点中指定类型的组件
  6598. @param typeOrClassName typeOrClassName
  6599. @example
  6600. ```js
  6601. var sprites = node.getComponentsInChildren(cc.Sprite);
  6602. var tests = node.getComponentsInChildren("Test");
  6603. ```
  6604. */
  6605. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  6606. getComponentsInChildren(className: string): any[];
  6607. /**
  6608. !#en
  6609. If the component's bounding box is different from the node's, you can implement this method to supply
  6610. a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
  6611. !#zh
  6612. 如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB),
  6613. 以便编辑器的场景视图可以正确地执行点选测试。
  6614. @param out_rect the Rect to receive the bounding box
  6615. */
  6616. _getLocalBounds(out_rect: Rect): void;
  6617. /**
  6618. !#en
  6619. onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
  6620. an undo operation on this component.<br/>
  6621. <br/>
  6622. If the component contains the "internal state", short for "temporary member variables which not included<br/>
  6623. in its CCClass properties", then you may need to implement this function.<br/>
  6624. <br/>
  6625. The editor will call the getset accessors of your component to record/restore the component's state<br/>
  6626. for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
  6627. this function to manually synchronize your component's "internal states" with its public properties.<br/>
  6628. Once you implement this function, all the getset accessors of your component will not be called when<br/>
  6629. the user performs an undo/redo operation. Which means that only the properties with default value<br/>
  6630. will be recorded or restored by editor.<br/>
  6631. <br/>
  6632. Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
  6633. to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
  6634. properties in this function. Once you implement this function, all the getset accessors of your component<br/>
  6635. will not be called during reset operation. Which means that only the properties with default value<br/>
  6636. will be reset by editor.
  6637. This function is only called in editor mode.
  6638. !#zh
  6639. onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。<br/>
  6640. <br/>
  6641. 如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。<br/>
  6642. <br/>
  6643. 编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。
  6644. 然而,在极端的情况下,它可能无法良好运作。<br/>
  6645. 那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。
  6646. 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。
  6647. 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。<br/>
  6648. <br/>
  6649. 同样的,编辑可能无法在极端情况下正确地重置您的组件。<br/>
  6650. 于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。<br/>
  6651. 一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。
  6652. 这意味着仅仅指定了默认值的属性将被编辑器重置。
  6653. <br/>
  6654. 此方法仅在编辑器下会被调用。
  6655. */
  6656. onRestore(): void;
  6657. /**
  6658. !#en
  6659. Schedules a custom selector.<br/>
  6660. If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
  6661. !#zh
  6662. 调度一个自定义的回调函数。<br/>
  6663. 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。
  6664. @param callback The callback function
  6665. @param interval Tick interval in seconds. 0 means tick every frame.
  6666. @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  6667. @param delay The amount of time that the first tick will wait before execution.
  6668. @example
  6669. ```js
  6670. var timeCallback = function (dt) {
  6671. cc.log("time: " + dt);
  6672. }
  6673. this.schedule(timeCallback, 1);
  6674. ```
  6675. */
  6676. schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
  6677. /**
  6678. !#en Schedules a callback function that runs only once, with a delay of 0 or larger.
  6679. !#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  6680. @param callback A function wrapped as a selector
  6681. @param delay The amount of time that the first tick will wait before execution.
  6682. @example
  6683. ```js
  6684. var timeCallback = function (dt) {
  6685. cc.log("time: " + dt);
  6686. }
  6687. this.scheduleOnce(timeCallback, 2);
  6688. ```
  6689. */
  6690. scheduleOnce(callback: Function, delay?: number): void;
  6691. /**
  6692. !#en Unschedules a custom callback function.
  6693. !#zh 取消调度一个自定义的回调函数。
  6694. @param callback_fn A function wrapped as a selector
  6695. @example
  6696. ```js
  6697. this.unschedule(_callback);
  6698. ```
  6699. */
  6700. unschedule(callback_fn: Function): void;
  6701. /**
  6702. !#en
  6703. unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
  6704. Actions are not affected by this method.
  6705. !#zh 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。
  6706. @example
  6707. ```js
  6708. this.unscheduleAllCallbacks();
  6709. ```
  6710. */
  6711. unscheduleAllCallbacks(): void;
  6712. }
  6713. /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
  6714. !#zh EditBox 组件,用于获取用户的输入文本。 */
  6715. export class EditBox extends _RendererUnderSG {
  6716. /** !#en Input string of EditBox.
  6717. !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。 */
  6718. string: string;
  6719. /** !#en The background image of EditBox.
  6720. !#zh 输入框的背景图片 */
  6721. backgroundImage: SpriteFrame;
  6722. /** !#en
  6723. The return key type of EditBox.
  6724. Note: it is meaningless for web platforms and desktop platforms.
  6725. !#zh
  6726. 指定移动设备上面回车按钮的样式。
  6727. 注意:这个选项对 web 平台与 desktop 平台无效。 */
  6728. returnType: EditBox.KeyboardReturnType;
  6729. /** !#en Set the input flags that are to be applied to the EditBox.
  6730. !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。 */
  6731. inputFlag: EditBox.InputFlag;
  6732. /** !#en
  6733. Set the input mode of the edit box.
  6734. If you pass ANY, it will create a multiline EditBox.
  6735. !#zh
  6736. 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。 */
  6737. inputMode: EditBox.InputMode;
  6738. /** !#en Font size of the input text.
  6739. !#zh 输入框文本的字体大小 */
  6740. fontSize: number;
  6741. /** !#en Change the lineHeight of displayed text.
  6742. !#zh 输入框文本的行高。 */
  6743. lineHeight: number;
  6744. /** !#en Font color of the input text.
  6745. !#zh 输入框文本的颜色。 */
  6746. fontColor: Color;
  6747. /** !#en The display text of placeholder.
  6748. !#zh 输入框占位符的文本内容。 */
  6749. placeholder: string;
  6750. /** !#en The font size of placeholder.
  6751. !#zh 输入框占位符的字体大小。 */
  6752. placeholderFontSize: number;
  6753. /** !#en The font color of placeholder.
  6754. !#zh 输入框占位符的字体颜色。 */
  6755. placeholderFontColor: Color;
  6756. /** !#en The maximize input length of EditBox.
  6757. - If pass a value less than 0, it won't limit the input number of characters.
  6758. - If pass 0, it doesn't allow input any characters.
  6759. !#zh 输入框最大允许输入的字符个数。
  6760. - 如果值为小于 0 的值,则不会限制输入字符个数。
  6761. - 如果值为 0,则不允许用户进行任何输入。 */
  6762. maxLength: number;
  6763. /** !#en The input is always visible and be on top of the game view.
  6764. !zh 输入框总是可见,并且永远在游戏视图的上面
  6765. Note: only available on Web at the moment. */
  6766. stayOnTop: boolean;
  6767. /** !#en Set the tabIndex of the DOM input element, only useful on Web.
  6768. !#zh 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。 */
  6769. tabIndex: number;
  6770. /** !#en The event handler to be called when EditBox began to edit text.
  6771. !#zh 开始编辑文本输入框触发的事件回调。 */
  6772. editingDidBegan: Component.EventHandler[];
  6773. /** !#en The event handler to be called when EditBox text changes.
  6774. !#zh 编辑文本输入框时触发的事件回调。 */
  6775. textChanged: Component.EventHandler[];
  6776. /** !#en The event handler to be called when EditBox edit ends.
  6777. !#zh 结束编辑文本输入框时触发的事件回调。 */
  6778. editingDidEnded: Component.EventHandler[];
  6779. /** !#en The event handler to be called when return key is pressed. Windows is not supported.
  6780. !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台 */
  6781. editingReturn: Component.EventHandler[];
  6782. /**
  6783. !#en Let the EditBox get focus, only valid when stayOnTop is true.
  6784. !#zh 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效
  6785. Note: only available on Web at the moment.
  6786. */
  6787. setFocus(): void;
  6788. /**
  6789. !#en Determine whether EditBox is getting focus or not.
  6790. !#zh 判断 EditBox 是否获得了焦点
  6791. Note: only available on Web at the moment.
  6792. */
  6793. isFocused(): void;
  6794. /**
  6795. !#en if you don't need the EditBox and it isn't in any running Scene, you should
  6796. call the destroy method on this component or the associated node explicitly.
  6797. Otherwise, the created DOM element won't be removed from web page.
  6798. !#zh
  6799. 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  6800. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  6801. @example
  6802. ```js
  6803. editbox.node.parent = null; // or editbox.node.removeFromParent(false);
  6804. // when you don't need editbox anymore
  6805. editbox.node.destroy();
  6806. ```
  6807. */
  6808. destroy(): boolean;
  6809. }
  6810. /** !#en The Label Component.
  6811. !#zh 文字标签组件 */
  6812. export class Label extends _RendererUnderSG {
  6813. /** !#en Content string of label.
  6814. !#zh 标签显示的文本内容。 */
  6815. string: string;
  6816. /** !#en Horizontal Alignment of label.
  6817. !#zh 文本内容的水平对齐方式。 */
  6818. horizontalAlign: Label.HorizontalAlign;
  6819. /** !#en Vertical Alignment of label.
  6820. !#zh 文本内容的垂直对齐方式。 */
  6821. verticalAlign: Label.VerticalAlign;
  6822. /** !#en The actual rendering font size in shrink mode
  6823. !#zh SHRINK 模式下面文本实际渲染的字体大小 */
  6824. actualFontSize: number;
  6825. /** !#en Font size of label.
  6826. !#zh 文本字体大小。 */
  6827. fontSize: number;
  6828. /** !#en Font family of label, only take effect when useSystemFont property is true.
  6829. !#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
  6830. fontFamily: string;
  6831. /** !#en Line Height of label.
  6832. !#zh 文本行高。 */
  6833. lineHeight: number;
  6834. /** !#en Overflow of label.
  6835. !#zh 文字显示超出范围时的处理方式。 */
  6836. overflow: Label.Overflow;
  6837. /** !#en Whether auto wrap label when string width is large than label width.
  6838. !#zh 是否自动换行。 */
  6839. enableWrapText: boolean;
  6840. /** !#en The font of label.
  6841. !#zh 文本字体。 */
  6842. font: Font;
  6843. /** !#en Whether use system font name or not.
  6844. !#zh 是否使用系统字体。 */
  6845. isSystemFontUsed: boolean;
  6846. }
  6847. /** !#en Outline effect used to change the display, only used for TTF font
  6848. !#zh 描边效果组件,用于字体描边,只能用于系统字体 */
  6849. export class LabelOutline extends Component {
  6850. /** !#en Change the outline color
  6851. !#zh 改变描边的颜色 */
  6852. color: Color;
  6853. /** !#en Change the outline width
  6854. !#zh 改变描边的宽度 */
  6855. width: number;
  6856. }
  6857. /** !#en
  6858. The Layout is a container component, use it to arrange child elements easily.<br>
  6859. Note:<br>
  6860. 1.Scaling and rotation of child nodes are not considered.<br>
  6861. 2.After setting the Layout, the results need to be updated until the next frame,
  6862. unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。
  6863. !#zh
  6864. Layout 组件相当于一个容器,能自动对它的所有子节点进行统一排版。<br>
  6865. 注意:<br>
  6866. 1.不会考虑子节点的缩放和旋转。<br>
  6867. 2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
  6868. export class Layout extends Component {
  6869. /** !#en The layout type.
  6870. !#zh 布局类型 */
  6871. type: Layout.Type;
  6872. /** !#en
  6873. The are three resize modes for Layout.
  6874. None, resize Container and resize children.
  6875. !#zh 缩放模式 */
  6876. resizeMode: Layout.ResizeMode;
  6877. /** !#en The cell size for grid layout.
  6878. !#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
  6879. cellSize: Size;
  6880. /** !#en
  6881. The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
  6882. and then break line on demand. Choose vertical if you want to layout vertically at first .
  6883. !#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
  6884. startAxis: Layout.AxisDirection;
  6885. /** !#en The left padding of layout, it only effect the layout in one direction.
  6886. !#zh 容器内左边距,只会在一个布局方向上生效。 */
  6887. paddingLeft: number;
  6888. /** !#en The right padding of layout, it only effect the layout in one direction.
  6889. !#zh 容器内右边距,只会在一个布局方向上生效。 */
  6890. paddingRight: number;
  6891. /** !#en The top padding of layout, it only effect the layout in one direction.
  6892. !#zh 容器内上边距,只会在一个布局方向上生效。 */
  6893. paddingTop: number;
  6894. /** !#en The bottom padding of layout, it only effect the layout in one direction.
  6895. !#zh 容器内下边距,只会在一个布局方向上生效。 */
  6896. paddingBottom: number;
  6897. /** !#en The distance in x-axis between each element in layout.
  6898. !#zh 子节点之间的水平间距。 */
  6899. spacingX: number;
  6900. /** !#en The distance in y-axis between each element in layout.
  6901. !#zh 子节点之间的垂直间距。 */
  6902. spacingY: number;
  6903. /** !#en
  6904. Only take effect in Vertical layout mode.
  6905. This option changes the start element's positioning.
  6906. !#zh 垂直排列子节点的方向。 */
  6907. verticalDirection: Layout.VerticalDirection;
  6908. /** !#en
  6909. Only take effect in Horizontal layout mode.
  6910. This option changes the start element's positioning.
  6911. !#zh 水平排列子节点的方向。 */
  6912. horizontalDirection: Layout.HorizontalDirection;
  6913. /**
  6914. !#en Perform the layout update
  6915. !#zh 立即执行更新布局
  6916. @example
  6917. ```js
  6918. layout.type = cc.Layout.HORIZONTAL;
  6919. layout.node.addChild(childNode);
  6920. cc.log(childNode.x); // not yet changed
  6921. layout.updateLayout();
  6922. cc.log(childNode.x); // changed
  6923. ```
  6924. */
  6925. updateLayout(): void;
  6926. /** !#en The padding of layout, it effects the layout in four direction.
  6927. !#zh 容器内边距,该属性会在四个布局方向上生效。 */
  6928. padding: number;
  6929. }
  6930. /** !#en The Mask Component
  6931. !#zh 遮罩组件 */
  6932. export class Mask extends _RendererInSG {
  6933. /** !#en The mask type.
  6934. !#zh 遮罩类型 */
  6935. type: Mask.Type;
  6936. /** !#en The mask image
  6937. !#zh 遮罩所需要的贴图 */
  6938. spriteFrame: SpriteFrame;
  6939. /** !#en
  6940. The alpha threshold.(Not supported Canvas Mode) <br/>
  6941. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
  6942. Should be a float between 0 and 1. <br/>
  6943. This default to 1 (so alpha test is disabled).
  6944. !#zh
  6945. Alpha 阈值(不支持 Canvas 模式)<br/>
  6946. 只有当模板的像素的 alpha 大于 alphaThreshold 时,才会绘制内容。<br/>
  6947. 该数值 0 ~ 1 之间的浮点数,默认值为 1(因此禁用 alpha) */
  6948. alphaThreshold: number;
  6949. /** !#en Reverse mask (Not supported Canvas Mode)
  6950. !#zh 反向遮罩(不支持 Canvas 模式) */
  6951. inverted: boolean;
  6952. /** !#en The segements for ellipse mask.
  6953. !#zh 椭圆遮罩的曲线细分数 */
  6954. segements: number;
  6955. }
  6956. /** !#en The PageView control
  6957. !#zh 页面视图组件 */
  6958. export class PageView extends ScrollView {
  6959. /** !#en Specify the size type of each page in PageView.
  6960. !#zh 页面视图中每个页面大小类型 */
  6961. sizeMode: PageView.SizeMode;
  6962. /** !#en The page view direction
  6963. !#zh 页面视图滚动类型 */
  6964. direction: PageView.Direction;
  6965. /** !#en
  6966. The scroll threshold value, when drag exceeds this value,
  6967. release the next page will automatically scroll, less than the restore
  6968. !#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
  6969. scrollThreshold: number;
  6970. /** !#en
  6971. Auto page turning velocity threshold. When users swipe the PageView quickly,
  6972. it will calculate a velocity based on the scroll distance and time,
  6973. if the calculated velocity is larger than the threshold, then it will trigger page turning.
  6974. !#zh
  6975. 快速滑动翻页临界值。
  6976. 当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
  6977. 该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
  6978. autoPageTurningThreshold: number;
  6979. /** !#en Change the PageTurning event timing of PageView.
  6980. !#zh 设置 PageView PageTurning 事件的发送时机。 */
  6981. pageTurningEventTiming: number;
  6982. /** !#en The Page View Indicator
  6983. !#zh 页面视图指示器组件 */
  6984. indicator: PageViewIndicator;
  6985. /** !#en The time required to turn over a page. unit: second
  6986. !#zh 每个页面翻页时所需时间。单位:秒 */
  6987. pageTurningSpeed: number;
  6988. /** !#en PageView events callback
  6989. !#zh 滚动视图的事件回调函数 */
  6990. pageEvents: Component.EventHandler[];
  6991. /**
  6992. !#en Returns current page index
  6993. !#zh 返回当前页面索引
  6994. */
  6995. getCurrentPageIndex(): number;
  6996. /**
  6997. !#en Set current page index
  6998. !#zh 设置当前页面索引
  6999. @param index index
  7000. */
  7001. setCurrentPageIndex(index: number): void;
  7002. /**
  7003. !#en Returns all pages of pageview
  7004. !#zh 返回视图中的所有页面
  7005. */
  7006. getPages(): Node[];
  7007. /**
  7008. !#en At the end of the current page view to insert a new view
  7009. !#zh 在当前页面视图的尾部插入一个新视图
  7010. @param page page
  7011. */
  7012. addPage(page: Node): void;
  7013. /**
  7014. !#en Inserts a page in the specified location
  7015. !#zh 将页面插入指定位置中
  7016. @param page page
  7017. @param index index
  7018. */
  7019. insertPage(page: Node, index: number): void;
  7020. /**
  7021. !#en Removes a page from PageView.
  7022. !#zh 移除指定页面
  7023. @param page page
  7024. */
  7025. removePage(page: Node): void;
  7026. /**
  7027. !#en Removes a page at index of PageView.
  7028. !#zh 移除指定下标的页面
  7029. @param index index
  7030. */
  7031. removePageAtIndex(index: number): void;
  7032. /**
  7033. !#en Removes all pages from PageView
  7034. !#zh 移除所有页面
  7035. */
  7036. removeAllPages(): void;
  7037. /**
  7038. !#en Scroll PageView to index.
  7039. !#zh 滚动到指定页面
  7040. @param idx index of page.
  7041. @param timeInSecond scrolling time
  7042. */
  7043. scrollToPage(idx: number, timeInSecond: number): void;
  7044. }
  7045. /** !#en The Page View Indicator Component
  7046. !#zh 页面视图每页标记组件 */
  7047. export class PageViewIndicator extends Component {
  7048. /** !#en The spriteFrame for each element.
  7049. !#zh 每个页面标记显示的图片 */
  7050. spriteFrame: SpriteFrame;
  7051. /** !#en The location direction of PageViewIndicator.
  7052. !#zh 页面标记摆放方向 */
  7053. direction: PageViewIndicator.Direction;
  7054. /** !#en The cellSize for each element.
  7055. !#zh 每个页面标记的大小 */
  7056. cellSize: Size;
  7057. /** !#en The distance between each element.
  7058. !#zh 每个页面标记之间的边距 */
  7059. spacing: number;
  7060. /**
  7061. !#en Set Page View
  7062. !#zh 设置页面视图
  7063. @param target target
  7064. */
  7065. setPageView(target: PageView): void;
  7066. }
  7067. /** !#en
  7068. Visual indicator of progress in some operation.
  7069. Displays a bar to the user representing how far the operation has progressed.
  7070. !#zh
  7071. 进度条组件,可用于显示加载资源时的进度。 */
  7072. export class ProgressBar extends Component {
  7073. /** !#en The targeted Sprite which will be changed progressively.
  7074. !#zh 用来显示进度条比例的 Sprite 对象。 */
  7075. barSprite: Sprite;
  7076. /** !#en The progress mode, there are two modes supported now: horizontal and vertical.
  7077. !#zh 进度条的模式 */
  7078. mode: ProgressBar.Mode;
  7079. /** !#en The total width or height of the bar sprite.
  7080. !#zh 进度条实际的总长度 */
  7081. totalLength: number;
  7082. /** !#en The current progress of the bar sprite. The valid value is between 0-1.
  7083. !#zh 当前进度值,该数值的区间是 0-1 之间。 */
  7084. progress: number;
  7085. /** !#en Whether reverse the progress direction of the bar sprite.
  7086. !#zh 进度条是否进行反方向变化。 */
  7087. reverse: boolean;
  7088. }
  7089. /** Rendering component in scene graph.
  7090. Maintains a node which will be the scene graph of component's Node. */
  7091. export class _RendererInSG extends _SGComponent {
  7092. }
  7093. /** The base rendering component which will attach a leaf node to the cocos2d scene graph. */
  7094. export class _RendererUnderSG extends _SGComponent {
  7095. }
  7096. /** !#en The RichText Component.
  7097. !#zh 富文本组件 */
  7098. export class RichText extends Component {
  7099. /** !#en Content string of RichText.
  7100. !#zh 富文本显示的文本内容。 */
  7101. string: string;
  7102. /** !#en Horizontal Alignment of each line in RichText.
  7103. !#zh 文本内容的水平对齐方式。 */
  7104. horizontalAlign: TextAlignment;
  7105. /** !#en Font size of RichText.
  7106. !#zh 富文本字体大小。 */
  7107. fontSize: number;
  7108. /** !#en Custom TTF font of RichText
  7109. !#zh 富文本定制字体 */
  7110. font: cc.TTFFont;
  7111. /** !#en The maximize width of the RichText
  7112. !#zh 富文本的最大宽度 */
  7113. maxWidth: number;
  7114. /** !#en Line Height of RichText.
  7115. !#zh 富文本行高。 */
  7116. lineHeight: number;
  7117. /** !#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.
  7118. !#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
  7119. imageAtlas: SpriteAtlas;
  7120. /** !#en
  7121. Once checked, the RichText will block all input events (mouse and touch) within
  7122. the bounding box of the node, preventing the input from penetrating into the underlying node.
  7123. !#zh
  7124. 选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
  7125. handleTouchEvent: boolean;
  7126. }
  7127. /** The base class for all rendering component in scene graph.
  7128. You should override:
  7129. - _createSgNode
  7130. - _initSgNode */
  7131. export class _SGComponent extends Component {
  7132. }
  7133. /** !#en
  7134. The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
  7135. !#zh 滚动条组件 */
  7136. export class Scrollbar extends Component {
  7137. /** !#en The "handle" part of the scrollbar.
  7138. !#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
  7139. handle: Sprite;
  7140. /** !#en The direction of scrollbar.
  7141. !#zh ScrollBar 的滚动方向。 */
  7142. direction: Scrollbar.Direction;
  7143. /** !#en Whether enable auto hide or not.
  7144. !#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
  7145. enableAutoHide: boolean;
  7146. /** !#en
  7147. The time to hide scrollbar when scroll finished.
  7148. Note: This value is only useful when enableAutoHide is true.
  7149. !#zh
  7150. 没有滚动动作后经过多久会自动隐藏。
  7151. 注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
  7152. autoHideTime: number;
  7153. }
  7154. /** !#en
  7155. Layout container for a view hierarchy that can be scrolled by the user,
  7156. allowing it to be larger than the physical display.
  7157. !#zh
  7158. 滚动视图组件 */
  7159. export class ScrollView extends Component {
  7160. /** !#en This is a reference to the UI element to be scrolled.
  7161. !#zh 可滚动展示内容的节点。 */
  7162. content: Node;
  7163. /** !#en Enable horizontal scroll.
  7164. !#zh 是否开启水平滚动。 */
  7165. horizontal: boolean;
  7166. /** !#en Enable vertical scroll.
  7167. !#zh 是否开启垂直滚动。 */
  7168. vertical: boolean;
  7169. /** !#en When inertia is set, the content will continue to move when touch ended.
  7170. !#zh 是否开启滚动惯性。 */
  7171. inertia: boolean;
  7172. /** !#en
  7173. It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
  7174. A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
  7175. !#zh
  7176. 开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
  7177. brake: number;
  7178. /** !#en When elastic is set, the content will be bounce back when move out of boundary.
  7179. !#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
  7180. elastic: boolean;
  7181. /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
  7182. !#zh 回弹持续的时间,0 表示将立即反弹。 */
  7183. bounceDuration: number;
  7184. /** !#en The horizontal scrollbar reference.
  7185. !#zh 水平滚动的 ScrollBar。 */
  7186. horizontalScrollBar: Scrollbar;
  7187. /** !#en The vertical scrollbar reference.
  7188. !#zh 垂直滚动的 ScrollBar。 */
  7189. verticalScrollBar: Scrollbar;
  7190. /** !#en Scrollview events callback
  7191. !#zh 滚动视图的事件回调函数 */
  7192. scrollEvents: Component.EventHandler[];
  7193. /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
  7194. It's set to true by default.
  7195. !#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
  7196. 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
  7197. cancelInnerEvents: boolean;
  7198. /**
  7199. !#en Scroll the content to the bottom boundary of ScrollView.
  7200. !#zh 视图内容将在规定时间内滚动到视图底部。
  7201. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7202. the content will jump to the bottom boundary immediately.
  7203. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7204. @example
  7205. ```js
  7206. // Scroll to the bottom of the view.
  7207. scrollView.scrollToBottom(0.1);
  7208. ```
  7209. */
  7210. scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
  7211. /**
  7212. !#en Scroll the content to the top boundary of ScrollView.
  7213. !#zh 视图内容将在规定时间内滚动到视图顶部。
  7214. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7215. the content will jump to the top boundary immediately.
  7216. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7217. @example
  7218. ```js
  7219. // Scroll to the top of the view.
  7220. scrollView.scrollToTop(0.1);
  7221. ```
  7222. */
  7223. scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
  7224. /**
  7225. !#en Scroll the content to the left boundary of ScrollView.
  7226. !#zh 视图内容将在规定时间内滚动到视图左边。
  7227. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7228. the content will jump to the left boundary immediately.
  7229. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7230. @example
  7231. ```js
  7232. // Scroll to the left of the view.
  7233. scrollView.scrollToLeft(0.1);
  7234. ```
  7235. */
  7236. scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
  7237. /**
  7238. !#en Scroll the content to the right boundary of ScrollView.
  7239. !#zh 视图内容将在规定时间内滚动到视图右边。
  7240. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7241. the content will jump to the right boundary immediately.
  7242. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7243. @example
  7244. ```js
  7245. // Scroll to the right of the view.
  7246. scrollView.scrollToRight(0.1);
  7247. ```
  7248. */
  7249. scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
  7250. /**
  7251. !#en Scroll the content to the top left boundary of ScrollView.
  7252. !#zh 视图内容将在规定时间内滚动到视图左上角。
  7253. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7254. the content will jump to the top left boundary immediately.
  7255. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7256. @example
  7257. ```js
  7258. // Scroll to the upper left corner of the view.
  7259. scrollView.scrollToTopLeft(0.1);
  7260. ```
  7261. */
  7262. scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
  7263. /**
  7264. !#en Scroll the content to the top right boundary of ScrollView.
  7265. !#zh 视图内容将在规定时间内滚动到视图右上角。
  7266. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7267. the content will jump to the top right boundary immediately.
  7268. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7269. @example
  7270. ```js
  7271. // Scroll to the top right corner of the view.
  7272. scrollView.scrollToTopRight(0.1);
  7273. ```
  7274. */
  7275. scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
  7276. /**
  7277. !#en Scroll the content to the bottom left boundary of ScrollView.
  7278. !#zh 视图内容将在规定时间内滚动到视图左下角。
  7279. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7280. the content will jump to the bottom left boundary immediately.
  7281. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7282. @example
  7283. ```js
  7284. // Scroll to the lower left corner of the view.
  7285. scrollView.scrollToBottomLeft(0.1);
  7286. ```
  7287. */
  7288. scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
  7289. /**
  7290. !#en Scroll the content to the bottom right boundary of ScrollView.
  7291. !#zh 视图内容将在规定时间内滚动到视图右下角。
  7292. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7293. the content will jump to the bottom right boundary immediately.
  7294. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7295. @example
  7296. ```js
  7297. // Scroll to the lower right corner of the view.
  7298. scrollView.scrollToBottomRight(0.1);
  7299. ```
  7300. */
  7301. scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
  7302. /**
  7303. !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
  7304. specific offset immediately.
  7305. !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
  7306. @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
  7307. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7308. the content will jump to the specific offset of ScrollView immediately.
  7309. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7310. @example
  7311. ```js
  7312. // Scroll to middle position in 0.1 second in x-axis
  7313. var maxScrollOffset = this.getMaxScrollOffset();
  7314. scrollView.scrollToOffset(cc.p(maxScrollOffset.x / 2, 0), 0.1);
  7315. ```
  7316. */
  7317. scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7318. /**
  7319. !#en Get the positive offset value corresponds to the content's top left boundary.
  7320. !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
  7321. */
  7322. getScrollOffset(): Vec2;
  7323. /**
  7324. !#en Get the maximize available scroll offset
  7325. !#zh 获取滚动视图最大可以滚动的偏移量
  7326. */
  7327. getMaxScrollOffset(): Vec2;
  7328. /**
  7329. !#en Scroll the content to the horizontal percent position of ScrollView.
  7330. !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
  7331. @param percent A value between 0 and 1.
  7332. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7333. the content will jump to the horizontal percent position of ScrollView immediately.
  7334. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7335. @example
  7336. ```js
  7337. // Scroll to middle position.
  7338. scrollView.scrollToBottomRight(0.5, 0.1);
  7339. ```
  7340. */
  7341. scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7342. /**
  7343. !#en Scroll the content to the percent position of ScrollView in any direction.
  7344. !#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
  7345. @param anchor A point which will be clamp between cc.p(0,0) and cc.p(1,1).
  7346. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7347. the content will jump to the percent position of ScrollView immediately.
  7348. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7349. @example
  7350. ```js
  7351. // Vertical scroll to the bottom of the view.
  7352. scrollView.scrollTo(cc.p(0, 1), 0.1);
  7353. // Horizontal scroll to view right.
  7354. scrollView.scrollTo(cc.p(1, 0), 0.1);
  7355. ```
  7356. */
  7357. scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
  7358. /**
  7359. !#en Scroll the content to the vertical percent position of ScrollView.
  7360. !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
  7361. @param percent A value between 0 and 1.
  7362. @param timeInSecond Scroll time in second, if you don't pass timeInSecond,
  7363. the content will jump to the vertical percent position of ScrollView immediately.
  7364. @param attenuated Whether the scroll acceleration attenuated, default is true.
  7365. // Scroll to middle position.
  7366. scrollView.scrollToPercentVertical(0.5, 0.1);
  7367. */
  7368. scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
  7369. /**
  7370. !#en Stop auto scroll immediately
  7371. !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
  7372. */
  7373. stopAutoScroll(): void;
  7374. /**
  7375. !#en Modify the content position.
  7376. !#zh 设置当前视图内容的坐标点。
  7377. @param position The position in content's parent space.
  7378. */
  7379. setContentPosition(position: Vec2): void;
  7380. /**
  7381. !#en Query the content's position in its parent space.
  7382. !#zh 获取当前视图内容的坐标点。
  7383. */
  7384. getContentPosition(): Position;
  7385. /**
  7386. !#en Query whether the user is currently dragging the ScrollView to scroll it
  7387. !#zh 用户是否在拖拽当前滚动视图
  7388. */
  7389. isScrolling(): boolean;
  7390. /**
  7391. !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  7392. !#zh 当前滚动视图是否在惯性滚动
  7393. */
  7394. isAutoScrolling(): boolean;
  7395. }
  7396. /** !#en The Slider Control
  7397. !#zh 滑动器组件 */
  7398. export class Slider extends Component {
  7399. /** !#en The "handle" part of the slider
  7400. !#zh 滑动器滑块按钮部件 */
  7401. handle: Button;
  7402. /** !#en The slider direction
  7403. !#zh 滑动器方向 */
  7404. direction: Slider.Direction;
  7405. /** !#en The current progress of the slider. The valid value is between 0-1
  7406. !#zh 当前进度值,该数值的区间是 0-1 之间 */
  7407. progress: number;
  7408. /** !#en The slider events callback
  7409. !#zh 滑动器组件事件回调函数 */
  7410. slideEvents: Component.EventHandler[];
  7411. }
  7412. /** !#en Renders a sprite in the scene.
  7413. !#zh 该组件用于在场景中渲染精灵。 */
  7414. export class Sprite extends _RendererUnderSG {
  7415. /** !#en The sprite frame of the sprite.
  7416. !#zh 精灵的精灵帧 */
  7417. spriteFrame: SpriteFrame;
  7418. /** !#en The sprite render type.
  7419. !#zh 精灵渲染类型 */
  7420. type: Sprite.Type;
  7421. /** !#en
  7422. The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7423. !#zh
  7424. 精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7425. fillType: Sprite.FillType;
  7426. /** !#en
  7427. The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7428. !#zh
  7429. 填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7430. fillCenter: Vec2;
  7431. /** !#en
  7432. The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7433. !#zh
  7434. 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7435. fillStart: number;
  7436. /** !#en
  7437. The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
  7438. !#zh
  7439. 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
  7440. fillRange: number;
  7441. /** !#en specify the frame is trimmed or not.
  7442. !#zh 是否使用裁剪模式 */
  7443. trim: boolean;
  7444. /** !#en specify the source Blend Factor.
  7445. !#zh 指定原图的混合模式 */
  7446. srcBlendFactor: BlendFactor;
  7447. /** !#en specify the destination Blend Factor.
  7448. !#zh 指定目标的混合模式 */
  7449. dstBlendFactor: BlendFactor;
  7450. /** !#en specify the size tracing mode.
  7451. !#zh 精灵尺寸调整模式 */
  7452. sizeMode: Sprite.SizeMode;
  7453. /**
  7454. !#en Change the left sprite's cap inset.
  7455. !#zh 设置精灵左边框-用于九宫格。
  7456. @param insetLeft The values to use for the cap inset.
  7457. @example
  7458. ```js
  7459. sprite.setInsetLeft(5);
  7460. ```
  7461. */
  7462. setInsetLeft(insetLeft: number): void;
  7463. /**
  7464. !#en Query the left sprite's cap inset.
  7465. !#zh 获取精灵左边框
  7466. @example
  7467. ```js
  7468. var insetLeft = sprite.getInsetLeft();
  7469. cc.log("Inset Left:" + insetLeft);
  7470. ```
  7471. */
  7472. getInsetLeft(): number;
  7473. /**
  7474. !#en Change the top sprite's cap inset.
  7475. !#zh 设置精灵上边框-用于九宫格。
  7476. @param insetTop The values to use for the cap inset.
  7477. @example
  7478. ```js
  7479. sprite.setInsetTop(5);
  7480. ```
  7481. */
  7482. setInsetTop(insetTop: number): void;
  7483. /**
  7484. !#en Query the top sprite's cap inset.
  7485. !#zh 获取精灵上边框。
  7486. @example
  7487. ```js
  7488. var insetTop = sprite.getInsetTop();
  7489. cc.log("Inset Top:" + insetTop);
  7490. ```
  7491. */
  7492. getInsetTop(): number;
  7493. /**
  7494. !#en Change the right sprite's cap inset.
  7495. !#zh 设置精灵右边框-用于九宫格。
  7496. @param insetRight The values to use for the cap inset.
  7497. @example
  7498. ```js
  7499. sprite.setInsetRight(5);
  7500. ```
  7501. */
  7502. setInsetRight(insetRight: number): void;
  7503. /**
  7504. !#en Query the right sprite's cap inset.
  7505. !#zh 获取精灵右边框。
  7506. @example
  7507. ```js
  7508. var insetRight = sprite.getInsetRight();
  7509. cc.log("Inset Right:" + insetRight);
  7510. ```
  7511. */
  7512. getInsetRight(): number;
  7513. /**
  7514. !#en Change the bottom sprite's cap inset.
  7515. !#zh 设置精灵下边框-用于九宫格。
  7516. @param bottomInset The values to use for the cap inset.
  7517. @example
  7518. ```js
  7519. sprite.setInsetBottom(5);
  7520. ```
  7521. */
  7522. setInsetBottom(bottomInset: number): void;
  7523. /**
  7524. !#en Query the bottom sprite's cap inset.
  7525. !#zh 获取精灵下边框。
  7526. @example
  7527. ```js
  7528. var insetBottom = sprite.getInsetBottom();
  7529. cc.log("Inset Bottom:" + insetBottom);
  7530. ```
  7531. */
  7532. getInsetBottom(): number;
  7533. }
  7534. /** !#en A distortion used to change the rendering of simple sprite.If will take effect after sprite component is added.
  7535. !#zh 扭曲效果组件,用于改变SIMPLE类型sprite的渲染,只有当sprite组件已经添加后,才能起作用. */
  7536. export class SpriteDistortion extends Component {
  7537. /** !#en Change the UV offset for distortion rendering.
  7538. !#zh 在渲染时改变UV的整体偏移. */
  7539. offset: Vec2;
  7540. /** !#en Change the UV scale for distortion rendering.
  7541. !#zh 在渲染时改变UV的寻址系数 */
  7542. tiling: Vec2;
  7543. }
  7544. /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
  7545. could be treated as a RadioButton.
  7546. !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
  7547. export class Toggle extends Button {
  7548. /** !#en When this value is true, the check mark component will be enabled, otherwise
  7549. the check mark component will be disabled.
  7550. !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
  7551. isChecked: boolean;
  7552. /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
  7553. Otherwise, the toggle is a RadioButton.
  7554. !#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
  7555. 否则,Toggle 是一个 RadioButton。 */
  7556. toggleGroup: ToggleGroup;
  7557. /** !#en The image used for the checkmark.
  7558. !#zh Toggle 处于选中状态时显示的图片 */
  7559. checkMark: Sprite;
  7560. /** !#en If Toggle is clicked, it will trigger event's handler
  7561. !#zh Toggle 按钮的点击事件列表。 */
  7562. checkEvents: Component.EventHandler[];
  7563. /**
  7564. !#en Make the toggle button checked.
  7565. !#zh 使 toggle 按钮处于选中状态
  7566. */
  7567. check(): void;
  7568. /**
  7569. !#en Make the toggle button unchecked.
  7570. !#zh 使 toggle 按钮处于未选中状态
  7571. */
  7572. uncheck(): void;
  7573. }
  7574. /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. </br>
  7575. Toggles that belong to the same group could only have one of them to be switched on at a time.</br>
  7576. Note: All the first layer child node containing the toggle component will auto be added to the container
  7577. !#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。</br>
  7578. 当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。</br>
  7579. 注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
  7580. export class ToggleContainer extends Component {
  7581. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7582. If it is false, it will make sure there is always only one toggle could be switched on
  7583. and the already switched on toggle can't be switched off.
  7584. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7585. allowSwitchOff: boolean;
  7586. /** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
  7587. !#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
  7588. toggleItems: Toggle[];
  7589. }
  7590. /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
  7591. Toggles that belong to the same group could only have one of them to be switched on at a time.
  7592. !#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
  7593. 任何时候只能有一个 Toggle 处于选中状态。 */
  7594. export class ToggleGroup extends Component {
  7595. /** !#en If this setting is true, a toggle could be switched off and on when pressed.
  7596. If it is false, it will make sure there is always only one toggle could be switched on
  7597. and the already switched on toggle can't be switched off.
  7598. !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
  7599. allowSwitchOff: boolean;
  7600. /** !#en Read only property, return the toggle items array reference managed by toggleGroup.
  7601. !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
  7602. toggleItems: any[];
  7603. }
  7604. /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game.
  7605. !#zh Video 组件,用于在游戏中播放视频 */
  7606. export class VideoPlayer extends _RendererUnderSG {
  7607. /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
  7608. !#zh 视频来源:REMOTE 表示远程视频 URL,LOCAL 表示本地视频地址。 */
  7609. resourceType: VideoPlayer.ResourceType;
  7610. /** !#en The remote URL of video.
  7611. !#zh 远程视频的 URL */
  7612. remoteURL: string;
  7613. /** !#en The local video full path.
  7614. !#zh 本地视频的 URL */
  7615. clip: string;
  7616. /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
  7617. !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。 */
  7618. currentTime: number;
  7619. /** !#en The volume of the video.
  7620. !#zh 视频的音量(0.0 ~ 1.0) */
  7621. volume: number;
  7622. /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume.
  7623. !#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */
  7624. mute: boolean;
  7625. /** !#en Whether keep the aspect ration of the original video.
  7626. !#zh 是否保持视频原来的宽高比 */
  7627. keepAspectRatio: boolean;
  7628. /** !#en Whether play video in fullscreen mode.
  7629. !#zh 是否全屏播放视频 */
  7630. isFullscreen: boolean;
  7631. /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
  7632. !#zh 视频播放回调函数,该回调函数会在特定情况被触发,比如播放中,暂时,停止和完成播放。 */
  7633. videoPlayerEvent: Component.EventHandler[];
  7634. /**
  7635. !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
  7636. !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
  7637. */
  7638. play(): void;
  7639. /**
  7640. !#en If a video is paused, call this method to resume playing.
  7641. !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
  7642. */
  7643. resume(): void;
  7644. /**
  7645. !#en If a video is playing, call this method to pause playing.
  7646. !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
  7647. */
  7648. pause(): void;
  7649. /**
  7650. !#en If a video is playing, call this method to stop playing immediately.
  7651. !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
  7652. */
  7653. stop(): void;
  7654. /**
  7655. !#en Gets the duration of the video
  7656. !#zh 获取视频文件的播放总时长
  7657. */
  7658. getDuration(): number;
  7659. /**
  7660. !#en Determine whether video is playing or not.
  7661. !#zh 判断当前视频是否处于播放状态
  7662. */
  7663. isPlaying(): boolean;
  7664. /**
  7665. !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
  7666. call the destroy method on this component or the associated node explicitly.
  7667. Otherwise, the created DOM element won't be removed from web page.
  7668. !#zh
  7669. 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7670. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7671. @example
  7672. ```js
  7673. videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
  7674. // when you don't need videoplayer anymore
  7675. videoplayer.node.destroy();
  7676. ```
  7677. */
  7678. destroy(): boolean;
  7679. }
  7680. /** !#en
  7681. Handling touch events in a ViewGroup takes special care,
  7682. because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
  7683. To make sure that each view correctly receives the touch events intended for it,
  7684. ViewGroup should register capture phase event and handle the event propagation properly.
  7685. Please refer to Scrollview for more information.
  7686. !#zh
  7687. ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
  7688. 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
  7689. 请参考 ScrollView 的实现来获取更多信息。 */
  7690. export class ViewGroup extends Component {
  7691. }
  7692. /** !#en cc.WebView is a component for display web pages in the game
  7693. !#zh WebView 组件,用于在游戏中显示网页 */
  7694. export class WebView extends _RendererUnderSG {
  7695. /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
  7696. !#zh 指定 WebView 加载的网址,它应该是一个 http 或者 https 开头的字符串 */
  7697. url: string;
  7698. /** !#en The webview's event callback , it will be triggered when certain webview event occurs.
  7699. !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
  7700. webviewLoadedEvents: Component.EventHandler[];
  7701. /**
  7702. !#en
  7703. Set javascript interface scheme (see also setOnJSCallback). <br/>
  7704. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7705. Please refer to the official documentation for more details.
  7706. !#zh
  7707. 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
  7708. 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
  7709. 详情请参阅官方文档
  7710. @param scheme scheme
  7711. */
  7712. setJavascriptInterfaceScheme(scheme: string): void;
  7713. /**
  7714. !#en
  7715. This callback called when load URL that start with javascript
  7716. interface scheme (see also setJavascriptInterfaceScheme). <br/>
  7717. Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
  7718. Please refer to the official documentation for more details.
  7719. !#zh
  7720. 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
  7721. 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
  7722. 详情请参阅官方文档
  7723. @param callback callback
  7724. */
  7725. setOnJSCallback(callback: Function): void;
  7726. /**
  7727. !#en
  7728. Evaluates JavaScript in the context of the currently displayed page. <br/>
  7729. Please refer to the official document for more details <br/>
  7730. Note: Cross domain issues need to be resolved by yourself <br/>
  7731. !#zh
  7732. 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
  7733. 注意:需要自行解决跨域问题
  7734. @param str str
  7735. */
  7736. evaluateJS(str: string): void;
  7737. /**
  7738. !#en if you don't need the WebView and it isn't in any running Scene, you should
  7739. call the destroy method on this component or the associated node explicitly.
  7740. Otherwise, the created DOM element won't be removed from web page.
  7741. !#zh
  7742. 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  7743. 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
  7744. @example
  7745. ```js
  7746. webview.node.parent = null; // or webview.node.removeFromParent(false);
  7747. // when you don't need webview anymore
  7748. webview.node.destroy();
  7749. ```
  7750. */
  7751. destroy(): boolean;
  7752. }
  7753. /** !#en
  7754. Stores and manipulate the anchoring based on its parent.
  7755. Widget are used for GUI but can also be used for other things.
  7756. 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.
  7757. !#zh
  7758. Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
  7759. Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
  7760. export class Widget extends Component {
  7761. /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
  7762. The default value is null, and when null, indicates the current parent.
  7763. !#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
  7764. target: Node;
  7765. /** !#en Whether to align the top.
  7766. !#zh 是否对齐上边。 */
  7767. isAlignTop: boolean;
  7768. /** !#en
  7769. Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
  7770. !#zh
  7771. 是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
  7772. isAlignVerticalCenter: boolean;
  7773. /** !#en Whether to align the bottom.
  7774. !#zh 是否对齐下边。 */
  7775. isAlignBottom: boolean;
  7776. /** !#en Whether to align the left.
  7777. !#zh 是否对齐左边 */
  7778. isAlignLeft: boolean;
  7779. /** !#en
  7780. Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
  7781. !#zh
  7782. 是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
  7783. isAlignHorizontalCenter: boolean;
  7784. /** !#en Whether to align the right.
  7785. !#zh 是否对齐右边。 */
  7786. isAlignRight: boolean;
  7787. /** !#en
  7788. Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
  7789. the width setting is invalid (read only).
  7790. !#zh
  7791. 当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
  7792. isStretchWidth: boolean;
  7793. /** !#en
  7794. Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
  7795. then height setting is invalid (read only)
  7796. !#zh
  7797. 当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
  7798. isStretchHeight: boolean;
  7799. /** !#en
  7800. The margins between the top of this node and the top of parent node,
  7801. the value can be negative, Only available in 'isAlignTop' open.
  7802. !#zh
  7803. 本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
  7804. top: number;
  7805. /** !#en
  7806. The margins between the bottom of this node and the bottom of parent node,
  7807. the value can be negative, Only available in 'isAlignBottom' open.
  7808. !#zh
  7809. 本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
  7810. bottom: number;
  7811. /** !#en
  7812. The margins between the left of this node and the left of parent node,
  7813. the value can be negative, Only available in 'isAlignLeft' open.
  7814. !#zh
  7815. 本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
  7816. left: number;
  7817. /** !#en
  7818. The margins between the right of this node and the right of parent node,
  7819. the value can be negative, Only available in 'isAlignRight' open.
  7820. !#zh
  7821. 本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
  7822. right: number;
  7823. /** !#en
  7824. Horizontal aligns the midpoint offset value,
  7825. the value can be negative, Only available in 'isAlignHorizontalCenter' open.
  7826. !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
  7827. horizontalCenter: number;
  7828. /** !#en
  7829. Vertical aligns the midpoint offset value,
  7830. the value can be negative, Only available in 'isAlignVerticalCenter' open.
  7831. !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
  7832. verticalCenter: number;
  7833. /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7834. !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7835. isAbsoluteHorizontalCenter: boolean;
  7836. /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
  7837. !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
  7838. isAbsoluteVerticalCenter: boolean;
  7839. /** !#en
  7840. If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7841. !#zh
  7842. 如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7843. isAbsoluteTop: boolean;
  7844. /** !#en
  7845. If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
  7846. !#zh
  7847. 如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
  7848. isAbsoluteBottom: boolean;
  7849. /** !#en
  7850. If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7851. !#zh
  7852. 如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7853. isAbsoluteLeft: boolean;
  7854. /** !#en
  7855. If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
  7856. !#zh
  7857. 如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
  7858. isAbsoluteRight: boolean;
  7859. /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh.
  7860. !#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */
  7861. alignMode: Widget.AlignMode;
  7862. /**
  7863. !#en
  7864. Immediately perform the widget alignment. You need to manually call this method only if
  7865. you need to get the latest results after the alignment before the end of current frame.
  7866. !#zh
  7867. 立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
  7868. 只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
  7869. @example
  7870. ```js
  7871. widget.top = 10; // change top margin
  7872. cc.log(widget.node.y); // not yet changed
  7873. widget.updateAlignment();
  7874. cc.log(widget.node.y); // changed
  7875. ```
  7876. */
  7877. updateAlignment(): void;
  7878. /** !#en
  7879. When turned on, it will only be aligned once at the end of the onEnable frame,
  7880. then immediately disables the current component.
  7881. This will allow the script or animation to continue controlling the current node.
  7882. Note: It will still be aligned at the frame when onEnable is called.
  7883. !#zh
  7884. 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
  7885. 这样便于脚本或动画继续控制当前节点。
  7886. 注意:onEnable 时所在的那一帧仍然会进行对齐。 */
  7887. isAlignOnce: boolean;
  7888. }
  7889. /** !#en
  7890. EventTarget is an object to which an event is dispatched when something has occurred.
  7891. Entity are the most common event targets, but other objects can be event targets too.
  7892. Event targets are an important part of the Fireball event model.
  7893. The event target serves as the focal point for how events flow through the scene graph.
  7894. When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
  7895. into the event flow from the root of the hierarchy. The event object then makes its way through
  7896. the scene graph until it reaches the event target, at which point it begins its return trip through
  7897. the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
  7898. - The capture phase comprises the journey from the root to the last node before the event target's node
  7899. - The target phase comprises only the event target node
  7900. - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
  7901. See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  7902. Event targets can implement the following methods:
  7903. - _getCapturingTargets
  7904. - _getBubblingTargets
  7905. !#zh
  7906. 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
  7907. 但是其他对象也可以是事件目标。<br/> */
  7908. export class EventTarget {
  7909. /**
  7910. !#en
  7911. Register an callback of a specific event type on the EventTarget.
  7912. !#zh
  7913. 注册事件目标的特定事件类型回调。
  7914. @param type A string representing the event type to listen for.
  7915. @param callback The callback that will be invoked when the event is dispatched.
  7916. The callback is ignored if it is a duplicate (the callbacks are unique).
  7917. @param target The target (this object) to invoke the callback, can be null
  7918. @param useCapture When set to true, the capture argument prevents callback
  7919. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7920. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7921. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7922. @example
  7923. ```js
  7924. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7925. cc.log("this is callback");
  7926. }, node);
  7927. ```
  7928. */
  7929. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7930. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7931. /**
  7932. !#en
  7933. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  7934. if only type is passed as parameter, all listeners registered with that type will be removed.
  7935. !#zh
  7936. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  7937. @param type A string representing the event type being removed.
  7938. @param callback The callback to remove.
  7939. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  7940. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  7941. If not specified, useCapture defaults to false. If a callback was registered twice,
  7942. one with capture and one without, each must be removed separately. Removal of a capturing callback
  7943. does not affect a non-capturing version of the same listener, and vice versa.
  7944. @example
  7945. ```js
  7946. // register touchEnd eventListener
  7947. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  7948. cc.log("this is callback");
  7949. }, node);
  7950. // remove touch end event listener
  7951. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  7952. // remove all touch end event listeners
  7953. node.off(cc.Node.EventType.TOUCH_END);
  7954. ```
  7955. */
  7956. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  7957. /**
  7958. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  7959. This is not for removing all listeners in the current event target,
  7960. and this is not for removing all listeners the target parameter have registered.
  7961. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  7962. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  7963. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  7964. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  7965. @param target The target to be searched for all related listeners
  7966. */
  7967. targetOff(target: any): void;
  7968. /**
  7969. !#en
  7970. Register an callback of a specific event type on the EventTarget,
  7971. the callback will remove itself after the first time it is triggered.
  7972. !#zh
  7973. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  7974. @param type A string representing the event type to listen for.
  7975. @param callback The callback that will be invoked when the event is dispatched.
  7976. The callback is ignored if it is a duplicate (the callbacks are unique).
  7977. @param target The target (this object) to invoke the callback, can be null
  7978. @param useCapture When set to true, the capture argument prevents callback
  7979. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  7980. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  7981. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  7982. @example
  7983. ```js
  7984. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  7985. cc.log("this is callback");
  7986. }, node);
  7987. ```
  7988. */
  7989. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  7990. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  7991. /**
  7992. !#en
  7993. Dispatches an event into the event flow.
  7994. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  7995. !#zh 分发事件到事件流中。
  7996. @param event The Event object that is dispatched into the event flow
  7997. */
  7998. dispatchEvent(event: Event): void;
  7999. /**
  8000. !#en
  8001. Send an event to this object directly, this method will not propagate the event to any other objects.
  8002. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  8003. !#zh
  8004. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  8005. @param message the message to send
  8006. @param detail whatever argument the message needs
  8007. */
  8008. emit(message: string, detail?: any): void;
  8009. }
  8010. /** !#en Base class of all kinds of events.
  8011. !#zh 包含事件相关信息的对象。 */
  8012. export class Event {
  8013. /**
  8014. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  8015. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  8016. */
  8017. constructor(type: string, bubbles: boolean);
  8018. /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
  8019. !#zh 事件类型。 */
  8020. type: string;
  8021. /** !#en Indicate whether the event bubbles up through the tree or not.
  8022. !#zh 表示该事件是否进行冒泡。 */
  8023. bubbles: boolean;
  8024. /** !#en A reference to the target to which the event was originally dispatched.
  8025. !#zh 最初事件触发的目标 */
  8026. target: any;
  8027. /** !#en A reference to the currently registered target for the event.
  8028. !#zh 当前目标 */
  8029. currentTarget: any;
  8030. /** !#en
  8031. Indicates which phase of the event flow is currently being evaluated.
  8032. Returns an integer value represented by 4 constants:
  8033. - Event.NONE = 0
  8034. - Event.CAPTURING_PHASE = 1
  8035. - Event.AT_TARGET = 2
  8036. - Event.BUBBLING_PHASE = 3
  8037. The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
  8038. (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
  8039. !#zh 事件阶段 */
  8040. eventPhase: number;
  8041. /**
  8042. !#en Reset the event for being stored in the object pool.
  8043. !#zh 重置对象池中存储的事件。
  8044. */
  8045. unuse(): string;
  8046. /**
  8047. !#en Reuse the event for being used again by the object pool.
  8048. !#zh 用于对象池再次使用的事件。
  8049. */
  8050. reuse(): string;
  8051. /**
  8052. !#en Stops propagation for current event.
  8053. !#zh 停止传递当前事件。
  8054. */
  8055. stopPropagation(): void;
  8056. /**
  8057. !#en Stops propagation for current event immediately,
  8058. the event won't even be dispatched to the listeners attached in the current target.
  8059. !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
  8060. */
  8061. stopPropagationImmediate(): void;
  8062. /**
  8063. !#en Checks whether the event has been stopped.
  8064. !#zh 检查该事件是否已经停止传递.
  8065. */
  8066. isStopped(): boolean;
  8067. /**
  8068. !#en
  8069. <p>
  8070. Gets current target of the event <br/>
  8071. note: It only be available when the event listener is associated with node. <br/>
  8072. It returns 0 when the listener is associated with fixed priority.
  8073. </p>
  8074. !#zh 获取当前目标节点
  8075. */
  8076. getCurrentTarget(): Node;
  8077. /**
  8078. !#en Gets the event type.
  8079. !#zh 获取事件类型
  8080. */
  8081. getType(): string;
  8082. /** !#en Code for event without type.
  8083. !#zh 没有类型的事件 */
  8084. static NO_TYPE: string;
  8085. /** !#en The type code of Touch event.
  8086. !#zh 触摸事件类型 */
  8087. static TOUCH: string;
  8088. /** !#en The type code of Mouse event.
  8089. !#zh 鼠标事件类型 */
  8090. static MOUSE: string;
  8091. /** !#en The type code of Keyboard event.
  8092. !#zh 键盘事件类型 */
  8093. static KEYBOARD: string;
  8094. /** !#en The type code of Acceleration event.
  8095. !#zh 加速器事件类型 */
  8096. static ACCELERATION: string;
  8097. /** !#en Events not currently dispatched are in this phase
  8098. !#zh 尚未派发事件阶段 */
  8099. static NONE: number;
  8100. /** !#en
  8101. The capturing phase comprises the journey from the root to the last node before the event target's node
  8102. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8103. !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。 */
  8104. static CAPTURING_PHASE: number;
  8105. /** !#en
  8106. The target phase comprises only the event target node
  8107. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8108. !#zh 目标阶段仅包括事件目标节点。 */
  8109. static AT_TARGET: number;
  8110. /** !#en
  8111. The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
  8112. see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
  8113. !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。 */
  8114. static BUBBLING_PHASE: number;
  8115. }
  8116. /** !#en The System event, it currently supports the key events and accelerometer events
  8117. !#zh 系统事件,它目前支持按键事件和重力感应事件 */
  8118. export class SystemEvent extends EventTarget {
  8119. /**
  8120. !#en whether enable accelerometer event
  8121. !#zh 是否启用加速度计事件
  8122. @param isEnable isEnable
  8123. */
  8124. setAccelerometerEnabled(isEnable: boolean): void;
  8125. /**
  8126. !#en set accelerometer interval value
  8127. !#zh 设置加速度计间隔值
  8128. @param interval interval
  8129. */
  8130. setAccelerometerInterval(interval: number): void;
  8131. }
  8132. /** !#en
  8133. <p>
  8134. The base class of event listener. <br/>
  8135. If you need custom listener which with different callback, you need to inherit this class. <br/>
  8136. For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, <br/>
  8137. EventListenerTouchOneByOne, EventListenerCustom.
  8138. </p>
  8139. !#zh
  8140. 封装用户的事件处理逻辑。
  8141. 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。 */
  8142. export class EventListener {
  8143. /**
  8144. Constructor
  8145. @param type type
  8146. @param listenerID listenerID
  8147. @param callback callback
  8148. */
  8149. constructor(type: number, listenerID: number, callback: number);
  8150. /**
  8151. !#en Checks whether the listener is available.
  8152. !#zh 检测监听器是否有效
  8153. */
  8154. checkAvailable(): boolean;
  8155. /**
  8156. !#en Clones the listener, its subclasses have to override this method.
  8157. !#zh 克隆监听器,它的子类必须重写此方法。
  8158. */
  8159. clone(): EventListener;
  8160. /**
  8161. !#en Enables or disables the listener
  8162. !#zh 启用或禁用监听器。
  8163. @param enabled enabled
  8164. */
  8165. setEnabled(enabled: boolean): void;
  8166. /**
  8167. !#en Checks whether the listener is enabled
  8168. !#zh 检查监听器是否可用。
  8169. */
  8170. isEnabled(): boolean;
  8171. /** !#en The type code of unknown event listener.
  8172. !#zh 未知的事件监听器类型 */
  8173. static UNKNOWN: number;
  8174. /** !#en The type code of keyboard event listener.
  8175. !#zh 键盘事件监听器类型 */
  8176. static KEYBOARD: number;
  8177. /** !#en The type code of acceleration event listener.
  8178. !#zh 加速器事件监听器类型 */
  8179. static ACCELERATION: number;
  8180. /**
  8181. !#en
  8182. Create a EventListener object with configuration including the event type, handlers and other parameters.
  8183. In handlers, this refer to the event listener object itself.
  8184. You can also pass custom parameters in the configuration object,
  8185. all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
  8186. !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
  8187. @param argObj a json object
  8188. @example
  8189. ```js
  8190. // Create KEYBOARD EventListener.
  8191. cc.EventListener.create({
  8192. event: cc.EventListener.KEYBOARD,
  8193. onKeyPressed: function (keyCode, event) {
  8194. cc.log('pressed key: ' + keyCode);
  8195. },
  8196. onKeyReleased: function (keyCode, event) {
  8197. cc.log('released key: ' + keyCode);
  8198. }
  8199. });
  8200. // Create ACCELERATION EventListener.
  8201. cc.EventListener.create({
  8202. event: cc.EventListener.ACCELERATION,
  8203. callback: function (acc, event) {
  8204. cc.log('acc: ' + keyCode);
  8205. }
  8206. });
  8207. ```
  8208. */
  8209. static create(argObj: any): EventListener;
  8210. }
  8211. /** !#en
  8212. This class has been deprecated, please use cc.systemEvent or cc.EventTarget instead. See [Listen to and launch events](../../../manual/en/scripting/events.md) for details.<br>
  8213. <br>
  8214. cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
  8215. The EventListener list is managed in such way so that event listeners can be added and removed
  8216. while events are being dispatched.
  8217. !#zh
  8218. 该类已废弃,请使用 cc.systemEvent 或 cc.EventTarget 代替,详见 [监听和发射事件](../../../manual/zh/scripting/events.md)。<br>
  8219. <br>
  8220. 事件管理器,它主要管理事件监听器注册和派发系统事件。 */
  8221. export class eventManager {
  8222. /**
  8223. !#en Pauses all listeners which are associated the specified target.
  8224. !#zh 暂停传入的 node 相关的所有监听器的事件响应。
  8225. @param node node
  8226. @param recursive recursive
  8227. */
  8228. static pauseTarget(node: Node, recursive?: boolean): void;
  8229. /**
  8230. !#en Resumes all listeners which are associated the specified target.
  8231. !#zh 恢复传入的 node 相关的所有监听器的事件响应。
  8232. @param node node
  8233. @param recursive recursive
  8234. */
  8235. static resumeTarget(node: Node, recursive?: boolean): void;
  8236. /**
  8237. !#en Query whether the specified event listener id has been added.
  8238. !#zh 查询指定的事件 ID 是否存在
  8239. @param listenerID The listener id.
  8240. */
  8241. static hasEventListener(listenerID: string|number): boolean;
  8242. /**
  8243. !#en
  8244. <p>
  8245. Adds a event listener for a specified event.<br/>
  8246. if the parameter "nodeOrPriority" is a node,
  8247. it means to add a event listener for a specified event with the priority of scene graph.<br/>
  8248. if the parameter "nodeOrPriority" is a Number,
  8249. it means to add a event listener for a specified event with the fixed priority.<br/>
  8250. </p>
  8251. !#zh
  8252. 将事件监听器添加到事件管理器中。<br/>
  8253. 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。<br/>
  8254. 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。<br/>
  8255. @param listener The listener of a specified event or a object of some event parameters.
  8256. @param nodeOrPriority The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
  8257. */
  8258. static addListener(listener: EventListener|any, nodeOrPriority: Node|number): EventListener;
  8259. /**
  8260. !#en Remove a listener.
  8261. !#zh 移除一个已添加的监听器。
  8262. @param listener an event listener or a registered node target
  8263. @example
  8264. ```js
  8265. // 1. remove eventManager add Listener;
  8266. var mouseListener1 = cc.eventManager.addListener({
  8267. event: cc.EventListener.MOUSE,
  8268. onMouseDown: function(keyCode, event){ },
  8269. onMouseUp: function(keyCode, event){ },
  8270. onMouseMove: function () { },
  8271. onMouseScroll: function () { }
  8272. }, node);
  8273. cc.eventManager.removeListener(mouseListener1);
  8274. // 2. remove eventListener create Listener;
  8275. var mouseListener2 = cc.EventListener.create({
  8276. event: cc.EventListener.MOUSE,
  8277. onMouseDown: function(keyCode, event){ },
  8278. onMouseUp: function(keyCode, event){ },
  8279. onMouseMove: function () { },
  8280. onMouseScroll: function () { }
  8281. });
  8282. cc.eventManager.removeListener(mouseListener2);
  8283. ```
  8284. */
  8285. static removeListener(listener: EventListener): void;
  8286. /**
  8287. !#en Removes all listeners with the same event listener type or removes all listeners of a node.
  8288. !#zh
  8289. 移除注册到 eventManager 中指定类型的所有事件监听器。<br/>
  8290. 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
  8291. (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)<br/>
  8292. 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
  8293. 那么事件管理器将移除该类型的所有事件监听器。<br/>
  8294. 下列是目前存在监听器类型: <br/>
  8295. cc.EventListener.UNKNOWN <br/>
  8296. cc.EventListener.KEYBOARD <br/>
  8297. cc.EventListener.ACCELERATION,<br/>
  8298. @param listenerType listenerType or a node
  8299. @param recursive recursive
  8300. */
  8301. static removeListeners(listenerType: number|Node, recursive?: boolean): void;
  8302. /**
  8303. !#en Removes all listeners
  8304. !#zh 移除所有事件监听器。
  8305. */
  8306. static removeAllListeners(): void;
  8307. /**
  8308. !#en Sets listener's priority with fixed value.
  8309. !#zh 设置 FixedPriority 类型监听器的优先级。
  8310. @param listener listener
  8311. @param fixedPriority fixedPriority
  8312. */
  8313. static setPriority(listener: EventListener, fixedPriority: number): void;
  8314. /**
  8315. !#en Whether to enable dispatching events
  8316. !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
  8317. @param enabled enabled
  8318. */
  8319. static setEnabled(enabled: boolean): void;
  8320. /**
  8321. !#en Checks whether dispatching events is enabled
  8322. !#zh 检测事件管理器是否启用。
  8323. */
  8324. static isEnabled(): boolean;
  8325. }
  8326. /** !#en The touch event class
  8327. !#zh 封装了触摸相关的信息。 */
  8328. export class Touch {
  8329. /**
  8330. !#en Returns the current touch location in OpenGL coordinates.、
  8331. !#zh 获取当前触点位置。
  8332. */
  8333. getLocation(): Vec2;
  8334. /**
  8335. !#en Returns X axis location value.
  8336. !#zh 获取当前触点 X 轴位置。
  8337. */
  8338. getLocationX(): number;
  8339. /**
  8340. !#en Returns Y axis location value.
  8341. !#zh 获取当前触点 Y 轴位置。
  8342. */
  8343. getLocationY(): number;
  8344. /**
  8345. !#en Returns the previous touch location in OpenGL coordinates.
  8346. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  8347. */
  8348. getPreviousLocation(): Vec2;
  8349. /**
  8350. !#en Returns the start touch location in OpenGL coordinates.
  8351. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  8352. */
  8353. getStartLocation(): Vec2;
  8354. /**
  8355. !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
  8356. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  8357. */
  8358. getDelta(): Vec2;
  8359. /**
  8360. !#en Returns the current touch location in screen coordinates.
  8361. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  8362. */
  8363. getLocationInView(): Vec2;
  8364. /**
  8365. !#en Returns the previous touch location in screen coordinates.
  8366. !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8367. */
  8368. getPreviousLocationInView(): Vec2;
  8369. /**
  8370. !#en Returns the start touch location in screen coordinates.
  8371. !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
  8372. */
  8373. getStartLocationInView(): Vec2;
  8374. /**
  8375. !#en Returns the id of cc.Touch.
  8376. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  8377. */
  8378. getID(): number;
  8379. /**
  8380. !#en Sets information to touch.
  8381. !#zh 设置触摸相关的信息。用于监控触摸事件。
  8382. @param id id
  8383. @param x x
  8384. @param y y
  8385. */
  8386. setTouchInfo(id: number, x: number, y: number): void;
  8387. }
  8388. /** Loader for resource loading process. It's a singleton object. */
  8389. export class loader extends Pipeline {
  8390. /** The asset loader in cc.loader's pipeline, it's by default the first pipe.
  8391. It's used to identify an asset's type, and determine how to download it. */
  8392. static assetLoader: any;
  8393. /** The downloader in cc.loader's pipeline, it's by default the second pipe.
  8394. It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
  8395. You can add your own download function with addDownloadHandlers */
  8396. static downloader: any;
  8397. /** The downloader in cc.loader's pipeline, it's by default the third pipe.
  8398. It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
  8399. You can add your own download function with addLoadHandlers */
  8400. static loader: any;
  8401. /**
  8402. Gets a new XMLHttpRequest instance.
  8403. */
  8404. static getXMLHttpRequest(): XMLHttpRequest;
  8405. /**
  8406. Add custom supported types handler or modify existing type handler for download process.
  8407. @param extMap Custom supported types with corresponded handler
  8408. @example
  8409. ```js
  8410. cc.loader.addDownloadHandlers({
  8411. // This will match all url with `.scene` extension or all url with `scene` type
  8412. 'scene' : function (url, callback) {}
  8413. });
  8414. ```
  8415. */
  8416. static addDownloadHandlers(extMap: any): void;
  8417. /**
  8418. Add custom supported types handler or modify existing type handler for load process.
  8419. @param extMap Custom supported types with corresponded handler
  8420. @example
  8421. ```js
  8422. cc.loader.addLoadHandlers({
  8423. // This will match all url with `.scene` extension or all url with `scene` type
  8424. 'scene' : function (url, callback) {}
  8425. });
  8426. ```
  8427. */
  8428. static addLoadHandlers(extMap: any): void;
  8429. /**
  8430. Load resources with a progression callback and a complete callback.
  8431. The progression callback is the same as Pipeline's {{#crossLink "LoadingItems/onProgress:method"}}onProgress{{/crossLink}}
  8432. The complete callback is almost the same as Pipeline's {{#crossLink "LoadingItems/onComplete:method"}}onComplete{{/crossLink}}
  8433. The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
  8434. @param resources Url list in an array
  8435. @param progressCallback Callback invoked when progression change
  8436. @param completeCallback Callback invoked when all resources loaded
  8437. @example
  8438. ```js
  8439. cc.loader.load('a.png', function (err, tex) {
  8440. cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
  8441. });
  8442. cc.loader.load('http://example.com/a.png', function (err, tex) {
  8443. cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
  8444. });
  8445. cc.loader.load({url: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
  8446. cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
  8447. });
  8448. cc.loader.load(['a.png', 'b.json'], function (errors, results) {
  8449. if (errors) {
  8450. for (var i = 0; i < errors.length; i++) {
  8451. cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
  8452. }
  8453. }
  8454. var aTex = results.getContent('a.png');
  8455. var bJsonObj = results.getContent('b.json');
  8456. });
  8457. ```
  8458. */
  8459. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
  8460. static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
  8461. /**
  8462. Load resources from the "resources" folder inside the "assets" folder of your project.<br>
  8463. <br>
  8464. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8465. @param url Url of the target resource.
  8466. The url is relative to the "resources" folder, extensions must be omitted.
  8467. @param type Only asset of type will be loaded if this argument is supplied.
  8468. @param progressCallback Callback invoked when progression change.
  8469. @param completeCallback Callback invoked when the resource loaded.
  8470. @example
  8471. ```js
  8472. // load the prefab (project/assets/resources/misc/character/cocos) from resources folder
  8473. cc.loader.loadRes('misc/character/cocos', function (err, prefab) {
  8474. if (err) {
  8475. cc.error(err.message || err);
  8476. return;
  8477. }
  8478. cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
  8479. });
  8480. // load the sprite frame of (project/assets/resources/imgs/cocos.png) from resources folder
  8481. cc.loader.loadRes('imgs/cocos', cc.SpriteFrame, function (err, spriteFrame) {
  8482. if (err) {
  8483. cc.error(err.message || err);
  8484. return;
  8485. }
  8486. cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame));
  8487. });
  8488. ```
  8489. */
  8490. static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8491. static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
  8492. static loadRes(url: string, type: typeof cc.Asset): void;
  8493. static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
  8494. static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
  8495. static loadRes(url: string): void;
  8496. /**
  8497. This method is like {{#crossLink "loader/loadRes:method"}}{{/crossLink}} except that it accepts array of url.
  8498. @param urls Array of URLs of the target resource.
  8499. The url is relative to the "resources" folder, extensions must be omitted.
  8500. @param type Only asset of type will be loaded if this argument is supplied.
  8501. @param progressCallback Callback invoked when progression change.
  8502. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8503. @example
  8504. ```js
  8505. // load the SpriteFrames from resources folder
  8506. var spriteFrames;
  8507. var urls = ['misc/characters/character_01', 'misc/weapons/weapons_01'];
  8508. cc.loader.loadResArray(urls, cc.SpriteFrame, function (err, assets) {
  8509. if (err) {
  8510. cc.error(err);
  8511. return;
  8512. }
  8513. spriteFrames = assets;
  8514. // ...
  8515. });
  8516. ```
  8517. */
  8518. static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8519. static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
  8520. static loadResArray(url: string[], type: typeof cc.Asset): void;
  8521. static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
  8522. static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
  8523. static loadResArray(url: string[]): void;
  8524. /**
  8525. Load all assets in a folder inside the "assets/resources" folder of your project.<br>
  8526. <br>
  8527. Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
  8528. @param url Url of the target folder.
  8529. The url is relative to the "resources" folder, extensions must be omitted.
  8530. @param type Only asset of type will be loaded if this argument is supplied.
  8531. @param progressCallback Callback invoked when progression change.
  8532. @param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
  8533. @example
  8534. ```js
  8535. // load the texture (resources/imgs/cocos.png) and the corresponding sprite frame
  8536. cc.loader.loadResDir('imgs/cocos', function (err, assets) {
  8537. if (err) {
  8538. cc.error(err);
  8539. return;
  8540. }
  8541. var texture = assets[0];
  8542. var spriteFrame = assets[1];
  8543. });
  8544. // load all textures in "resources/imgs/"
  8545. cc.loader.loadResDir('imgs', cc.Texture2D, function (err, textures) {
  8546. var texture1 = textures[0];
  8547. var texture2 = textures[1];
  8548. });
  8549. // load all JSONs in "resources/data/"
  8550. cc.loader.loadResDir('data', function (err, objects, urls) {
  8551. var data = objects[0];
  8552. var url = urls[0];
  8553. });
  8554. ```
  8555. */
  8556. 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;
  8557. static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8558. static loadResDir(url: string, type: typeof cc.Asset): void;
  8559. static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
  8560. static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
  8561. static loadResDir(url: string): void;
  8562. /**
  8563. Get resource data by id. <br>
  8564. When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
  8565. the url will be the unique identity of the resource.
  8566. After loaded, you can acquire them by passing the url to this API.
  8567. @param url url
  8568. @param type Only asset of type will be returned if this argument is supplied.
  8569. */
  8570. static getRes(url: string, type?: Function): any;
  8571. /**
  8572. !#en Get all resource dependencies of the requested asset in an array, including itself.
  8573. The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.<br>
  8574. The returned array stores the dependencies with their uuids, after retrieve dependencies,
  8575. you can release them, access dependent assets by passing the uuid to {{#crossLink "loader/getRes:method"}}{{/crossLink}}, or other stuffs you want.<br>
  8576. For release all dependencies of an asset, please refer to {{#crossLink "loader/release:method"}}{{/crossLink}}
  8577. Here is some examples:
  8578. !#zh 获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。<br>
  8579. 返回的数组将仅保存依赖资源的 uuid,获取这些 uuid 后,你可以从 loader 释放这些资源;通过 {{#crossLink "loader/getRes:method"}}{{/crossLink}} 获取某个资源或者进行其他你需要的操作。<br>
  8580. 想要释放一个资源及其依赖资源,可以参考 {{#crossLink "loader/release:method"}}{{/crossLink}}。下面是一些示例代码:
  8581. @param owner The owner asset or the resource url or the asset's uuid
  8582. @example
  8583. ```js
  8584. // Release all dependencies of a loaded prefab
  8585. var deps = cc.loader.getDependsRecursively(prefab);
  8586. cc.loader.release(deps);
  8587. // Retrieve all dependent textures
  8588. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8589. var textures = [];
  8590. for (var i = 0; i < deps.length; ++i) {
  8591. var item = cc.loader.getRes(deps[i]);
  8592. if (item instanceof cc.Texture2D) {
  8593. textures.push(item);
  8594. }
  8595. }
  8596. ```
  8597. */
  8598. static getDependsRecursively(owner: Asset|RawAsset|string): any[];
  8599. /**
  8600. !#en
  8601. Release the content of an asset or an array of assets by uuid.
  8602. Start from v1.3, this method will not only remove the cache of the asset in loader, but also clean up its content.
  8603. For example, if you release a texture, the texture asset and its gl texture data will be freed up.
  8604. In complexe project, you can use this function with {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} to free up memory in critical circumstances.
  8605. 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.
  8606. If you only want to remove the cache of an asset, please use {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8607. !#zh
  8608. 通过 id(通常是资源 url)来释放一个资源或者一个资源数组。
  8609. v1.3 开始,这个方法不仅会从 loader 中删除资源的缓存引用,还会清理它的资源内容。
  8610. 比如说,当你释放一个 texture 资源,这个 texture 和它的 gl 贴图数据都会被释放。
  8611. 在复杂项目中,我们建议你结合 {{#crossLink "loader/getDependsRecursively:method"}}{{/crossLink}} 来使用,便于在设备内存告急的情况下更快地释放不再需要的资源的内存。
  8612. 注意,这个函数可能会导致资源贴图或资源所依赖的贴图不可用,如果场景中存在节点仍然依赖同样的贴图,它们可能会变黑并报 GL 错误。
  8613. 如果你只想删除一个资源的缓存引用,请使用 {{#crossLink "pipeline/removeItem:method"}}{{/crossLink}}
  8614. @param asset asset
  8615. @example
  8616. ```js
  8617. // Release a texture which is no longer need
  8618. cc.loader.release(texture);
  8619. // Release all dependencies of a loaded prefab
  8620. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8621. cc.loader.release(deps);
  8622. // 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.
  8623. // If you have some other nodes share a texture in this prefab, you can skip it in two ways:
  8624. // 1. Forbid auto release a texture before release
  8625. cc.loader.setAutoRelease(texture2d, false);
  8626. // 2. Remove it from the dependencies array
  8627. var deps = cc.loader.getDependsRecursively('prefabs/sample');
  8628. var index = deps.indexOf(texture2d._uuid);
  8629. if (index !== -1)
  8630. deps.splice(index, 1);
  8631. cc.loader.release(deps);
  8632. ```
  8633. */
  8634. static release(asset: Asset|RawAsset|string|any[]): void;
  8635. /**
  8636. !#en Release the asset by its object. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8637. !#zh 通过资源对象自身来释放资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8638. @param asset asset
  8639. */
  8640. static releaseAsset(asset: Asset): void;
  8641. /**
  8642. !#en Release the asset loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8643. !#zh 释放通过 {{#crossLink "loader/loadRes:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8644. @param url url
  8645. @param type Only asset of type will be released if this argument is supplied.
  8646. */
  8647. static releaseRes(url: string, type?: Function): void;
  8648. /**
  8649. !#en Release the all assets loaded by {{#crossLink "loader/loadResDir:method"}}{{/crossLink}}. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8650. !#zh 释放通过 {{#crossLink "loader/loadResDir:method"}}{{/crossLink}} 加载的资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8651. @param url url
  8652. @param type Only asset of type will be released if this argument is supplied.
  8653. */
  8654. static releaseResDir(url: string, type?: Function): void;
  8655. /**
  8656. !#en Resource all assets. Refer to {{#crossLink "loader/release:method"}}{{/crossLink}} for detailed informations.
  8657. !#zh 释放所有资源。详细信息请参考 {{#crossLink "loader/release:method"}}{{/crossLink}}
  8658. */
  8659. static releaseAll(): void;
  8660. /**
  8661. !#en
  8662. Indicates whether to release the asset when loading a new scene.<br>
  8663. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8664. according to whether the previous scene checked the "Auto Release Assets" option.
  8665. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8666. will not be affected by that option, remain not released by default.<br>
  8667. Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.<br>
  8668. <br>
  8669. See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8670. !#zh
  8671. 设置当场景切换时是否自动释放资源。<br>
  8672. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8673. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8674. 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8675. <br>
  8676. 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8677. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8678. @param autoRelease indicates whether should release automatically
  8679. @example
  8680. ```js
  8681. // auto release the texture event if "Auto Release Assets" disabled in current scene
  8682. cc.loader.setAutoRelease(texture2d, true);
  8683. // don't release the texture even if "Auto Release Assets" enabled in current scene
  8684. cc.loader.setAutoRelease(texture2d, false);
  8685. // first parameter can be url
  8686. cc.loader.setAutoRelease(audioUrl, false);
  8687. ```
  8688. */
  8689. static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8690. /**
  8691. !#en
  8692. Indicates whether to release the asset and its referenced other assets when loading a new scene.<br>
  8693. By default, when loading a new scene, all assets in the previous scene will be released or preserved
  8694. according to whether the previous scene checked the "Auto Release Assets" option.
  8695. On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResDir`
  8696. will not be affected by that option, remain not released by default.<br>
  8697. 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>
  8698. <br>
  8699. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8700. !#zh
  8701. 设置当场景切换时是否自动释放资源及资源引用的其它资源。<br>
  8702. 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
  8703. 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResDir` 动态加载的资源,则不受场景设置的影响,默认不自动释放。<br>
  8704. 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。<br>
  8705. <br>
  8706. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
  8707. @param assetOrUrlOrUuid asset object or the raw asset's url or uuid
  8708. @param autoRelease indicates whether should release automatically
  8709. @example
  8710. ```js
  8711. // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
  8712. cc.loader.setAutoReleaseRecursively(spriteFrame, true);
  8713. // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
  8714. cc.loader.setAutoReleaseRecursively(spriteFrame, false);
  8715. // don't release the Prefab and all the referenced assets
  8716. cc.loader.setAutoReleaseRecursively(prefab, false);
  8717. ```
  8718. */
  8719. static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
  8720. /**
  8721. !#en
  8722. Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.<br>
  8723. <br>
  8724. See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8725. !#zh
  8726. 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。<br>
  8727. <br>
  8728. 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
  8729. @param assetOrUrl asset object or the raw asset's url
  8730. */
  8731. static isAutoRelease(assetOrUrl: Asset|string): boolean;
  8732. }
  8733. /** !#en
  8734. LoadingItems is the queue of items which can flow them into the loading pipeline.</br>
  8735. Please don't construct it directly, use {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} instead, because we use an internal pool to recycle the queues.</br>
  8736. It hold a map of items, each entry in the map is a url to object key value pair.</br>
  8737. Each item always contains the following property:</br>
  8738. - id: The identification of the item, usually it's identical to url</br>
  8739. - url: The url </br>
  8740. - type: The type, it's the extension name of the url by default, could be specified manually too.</br>
  8741. - error: The error happened in pipeline will be stored in this property.</br>
  8742. - content: The content processed by the pipeline, the final result will also be stored in this property.</br>
  8743. - complete: The flag indicate whether the item is completed by the pipeline.</br>
  8744. - 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>
  8745. </br>
  8746. Item can hold other custom properties.</br>
  8747. Each LoadingItems object will be destroyed for recycle after onComplete callback</br>
  8748. So please don't hold its reference for later usage, you can copy properties in it though.
  8749. !#zh
  8750. LoadingItems 是一个加载对象队列,可以用来输送加载对象到加载管线中。</br>
  8751. 请不要直接使用 new 构造这个类的对象,你可以使用 {{#crossLink "LoadingItems.create"}}cc.LoadingItems.create{{/crossLink}} 来创建一个新的加载队列,这样可以允许我们的内部对象池回收并重利用加载队列。
  8752. 它有一个 map 属性用来存放加载项,在 map 对象中已 urlkey 值。</br>
  8753. 每个对象都会包含下列属性:</br>
  8754. - id:该对象的标识,通常与 url 相同。</br>
  8755. - url:路径 </br>
  8756. - type: 类型,它这是默认的 URL 的扩展名,可以手动指定赋值。</br>
  8757. - errorpipeline 中发生的错误将被保存在这个属性中。</br>
  8758. - content: pipeline 中处理的临时结果,最终的结果也将被存储在这个属性中。</br>
  8759. - complete:该标志表明该对象是否通过 pipeline 完成。</br>
  8760. - states:该对象存储每个管道中对象经历的状态,状态可以是 Pipeline.ItemState.WORKING | Pipeline.ItemState.ERROR | Pipeline.ItemState.COMPLETE</br>
  8761. </br>
  8762. 对象可容纳其他自定义属性。</br>
  8763. 每个 LoadingItems 对象都会在 onComplete 回调之后被销毁,所以请不要持有它的引用并在结束回调之后依赖它的内容执行任何逻辑,有这种需求的话你可以提前复制它的内容。 */
  8764. export class LoadingItems extends CallbacksInvoker {
  8765. /**
  8766. !#en This is a callback which will be invoked while an item flow out the pipeline.
  8767. You can pass the callback function in LoadingItems.create or set it later.
  8768. !#zh 这个回调函数将在 item 加载结束后被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8769. @param completedCount The number of the items that are already completed.
  8770. @param totalCount The total number of the items.
  8771. @param item The latest item which flow out the pipeline.
  8772. @example
  8773. ```js
  8774. loadingItems.onProgress = function (completedCount, totalCount, item) {
  8775. var progress = (100 * completedCount / totalCount).toFixed(2);
  8776. cc.log(progress + '%');
  8777. }
  8778. ```
  8779. */
  8780. onProgress(completedCount: number, totalCount: number, item: any): void;
  8781. /**
  8782. !#en This is a callback which will be invoked while all items is completed,
  8783. You can pass the callback function in LoadingItems.create or set it later.
  8784. !#zh 该函数将在加载队列全部完成时被调用。你可以在构造时传递这个回调函数或者是在构造之后直接设置。
  8785. @param errors All errored urls will be stored in this array, if no error happened, then it will be null
  8786. @param items All items.
  8787. @example
  8788. ```js
  8789. loadingItems.onComplete = function (errors, items) {
  8790. if (error)
  8791. cc.log('Completed with ' + errors.length + ' errors');
  8792. else
  8793. cc.log('Completed ' + items.totalCount + ' items');
  8794. }
  8795. ```
  8796. */
  8797. onComplete(errors: any[], items: LoadingItems): void;
  8798. /** !#en The map of all items.
  8799. !#zh 存储所有加载项的对象。 */
  8800. map: any;
  8801. /** !#en The map of completed items.
  8802. !#zh 存储已经完成的加载项。 */
  8803. completed: any;
  8804. /** !#en Total count of all items.
  8805. !#zh 所有加载项的总数。 */
  8806. totalCount: number;
  8807. /** !#en Total count of completed items.
  8808. !#zh 所有完成加载项的总数。 */
  8809. completedCount: number;
  8810. /** !#en Activated or not.
  8811. !#zh 是否启用。 */
  8812. active: boolean;
  8813. /**
  8814. !#en The constructor function of LoadingItems, this will use recycled LoadingItems in the internal pool if possible.
  8815. You can pass onProgress and onComplete callbacks to visualize the loading process.
  8816. !#zh LoadingItems 的构造函数,这种构造方式会重用内部对象缓冲池中的 LoadingItems 队列,以尽量避免对象创建。
  8817. 你可以传递 onProgressonComplete 回调函数来获知加载进度信息。
  8818. @param pipeline The pipeline to process the queue.
  8819. @param urlList The items array.
  8820. @param onProgress The progression callback, refer to {{#crossLink "LoadingItems.onProgress"}}{{/crossLink}}
  8821. @param onComplete The completion callback, refer to {{#crossLink "LoadingItems.onComplete"}}{{/crossLink}}
  8822. @example
  8823. ```js
  8824. cc.LoadingItems.create(cc.loader, ['a.png', 'b.plist'], function (completedCount, totalCount, item) {
  8825. var progress = (100 * completedCount / totalCount).toFixed(2);
  8826. cc.log(progress + '%');
  8827. }, function (errors, items) {
  8828. if (errors) {
  8829. for (var i = 0; i < errors.length; ++i) {
  8830. cc.log('Error url: ' + errors[i] + ', error: ' + items.getError(errors[i]));
  8831. }
  8832. }
  8833. else {
  8834. var result_a = items.getContent('a.png');
  8835. // ...
  8836. }
  8837. })
  8838. ```
  8839. */
  8840. static create(pipeline: Pipeline, urlList: any[], onProgress: Function, onComplete: Function): LoadingItems;
  8841. /**
  8842. !#en Retrieve the LoadingItems queue object for an item.
  8843. !#zh 通过 item 对象获取它的 LoadingItems 队列。
  8844. @param item The item to query
  8845. */
  8846. static getQueue(item: any): LoadingItems;
  8847. /**
  8848. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8849. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8850. @param item The item which has completed
  8851. */
  8852. static itemComplete(item: any): void;
  8853. /**
  8854. !#en Add urls to the LoadingItems queue.
  8855. !#zh 向一个 LoadingItems 队列添加加载项。
  8856. @param urlList The url list to be appended, the url can be object or string
  8857. */
  8858. append(urlList: any[]): any[];
  8859. /**
  8860. !#en Complete a LoadingItems queue, please do not call this method unless you know what's happening.
  8861. !#zh 完成一个 LoadingItems 队列,请不要调用这个函数,除非你知道自己在做什么。
  8862. */
  8863. allComplete(): void;
  8864. /**
  8865. !#en Check whether all items are completed.
  8866. !#zh 检查是否所有加载项都已经完成。
  8867. */
  8868. isCompleted(): boolean;
  8869. /**
  8870. !#en Check whether an item is completed.
  8871. !#zh 通过 id 检查指定加载项是否已经加载完成。
  8872. @param id The item's id.
  8873. */
  8874. isItemCompleted(id: string): boolean;
  8875. /**
  8876. !#en Check whether an item exists.
  8877. !#zh 通过 id 检查加载项是否存在。
  8878. @param id The item's id.
  8879. */
  8880. exists(id: string): boolean;
  8881. /**
  8882. !#en Returns the content of an internal item.
  8883. !#zh 通过 id 获取指定对象的内容。
  8884. @param id The item's id.
  8885. */
  8886. getContent(id: string): any;
  8887. /**
  8888. !#en Returns the error of an internal item.
  8889. !#zh 通过 id 获取指定对象的错误信息。
  8890. @param id The item's id.
  8891. */
  8892. getError(id: string): any;
  8893. /**
  8894. !#en Add a listener for an item, the callback will be invoked when the item is completed.
  8895. !#zh 监听加载项(通过 key 指定)的完成事件。
  8896. @param key key
  8897. @param callback can be null
  8898. @param target can be null
  8899. */
  8900. addListener(key: string, callback: Function, target: any): boolean;
  8901. /**
  8902. !#en
  8903. Check if the specified key has any registered callback. </br>
  8904. If a callback is also specified, it will only return true if the callback is registered.
  8905. !#zh
  8906. 检查指定的加载项是否有完成事件监听器。</br>
  8907. 如果同时还指定了一个回调方法,并且回调有注册,它只会返回 true
  8908. @param key key
  8909. @param callback callback
  8910. @param target target
  8911. */
  8912. hasListener(key: string, callback?: Function, target?: any): boolean;
  8913. /**
  8914. !#en
  8915. Removes a listener. </br>
  8916. It will only remove when key, callback, target all match correctly.
  8917. !#zh
  8918. 移除指定加载项已经注册的完成事件监听器。</br>
  8919. 只会删除 key, callback, target 均匹配的监听器。
  8920. @param key key
  8921. @param callback callback
  8922. @param target target
  8923. */
  8924. remove(key: string, callback: Function, target: any): boolean;
  8925. /**
  8926. !#en
  8927. Removes all callbacks registered in a certain event
  8928. type or all callbacks registered with a certain target.
  8929. !#zh 删除指定目标的所有完成事件监听器。
  8930. @param key The event key to be removed or the target to be removed
  8931. */
  8932. removeAllListeners(key: string|any): void;
  8933. /**
  8934. !#en Complete an item in the LoadingItems queue, please do not call this method unless you know what's happening.
  8935. !#zh 通知 LoadingItems 队列一个 item 对象已完成,请不要调用这个函数,除非你知道自己在做什么。
  8936. @param id The item url
  8937. */
  8938. itemComplete(id: string): void;
  8939. /**
  8940. !#en Destroy the LoadingItems queue, the queue object won't be garbage collected, it will be recycled, so every after destroy is not reliable.
  8941. !#zh 销毁一个 LoadingItems 队列,这个队列对象会被内部缓冲池回收,所以销毁后的所有内部信息都是不可依赖的。
  8942. */
  8943. destroy(): void;
  8944. }
  8945. /** !#en
  8946. A pipeline describes a sequence of manipulations, each manipulation is called a pipe.</br>
  8947. 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>
  8948. A list of items can flow in the pipeline and it will output the results of all pipes.</br>
  8949. They flow in the pipeline like water in tubes, they go through pipe by pipe separately.</br>
  8950. Finally all items will flow out the pipeline and the process is finished.
  8951. !#zh
  8952. pipeline 描述了一系列的操作,每个操作都被称为 pipe。</br>
  8953. 它被设计来做加载过程的流程管理。所以 item 应该是 url,并且该 url 将是在处理中的每个 item 的身份标识。</br>
  8954. 一个 item 列表可以在 pipeline 中流动,它将输出加载项经过所有 pipe 之后的结果。</br>
  8955. 它们穿过 pipeline 就像水在管子里流动,将会按顺序流过每个 pipe。</br>
  8956. 最后当所有加载项都流出 pipeline 时,整个加载流程就结束了。 */
  8957. export class Pipeline {
  8958. /**
  8959. !#en
  8960. Constructor, pass an array of pipes to construct a new Pipeline,
  8961. the pipes will be chained in the given order.</br>
  8962. A pipe is an object which must contain an `id` in string and a `handle` function,
  8963. the id must be unique in the pipeline.</br>
  8964. It can also include `async` property to identify whether it's an asynchronous process.
  8965. !#zh
  8966. 构造函数,通过一系列的 pipe 来构造一个新的 pipelinepipes 将会在给定的顺序中被锁定。</br>
  8967. 一个 pipe 就是一个对象,它包含了字符串类型的 ‘id’ 和 ‘handle’ 函数,在 pipelineid 必须是唯一的。</br>
  8968. 它还可以包括 ‘async’ 属性以确定它是否是一个异步过程。
  8969. @param pipes pipes
  8970. @example
  8971. ```js
  8972. var pipeline = new Pipeline([
  8973. {
  8974. id: 'Downloader',
  8975. handle: function (item, callback) {},
  8976. async: true
  8977. },
  8978. {id: 'Parser', handle: function (item) {}, async: false}
  8979. ]);
  8980. ```
  8981. */
  8982. constructor(pipes: any[]);
  8983. /**
  8984. !#en
  8985. Insert a new pipe at the given index of the pipeline. </br>
  8986. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  8987. !#zh
  8988. 在给定的索引位置插入一个新的 pipe。</br>
  8989. 一个 pipe 必须包含一个字符串类型的 ‘id’ 和 ‘handle’ 函数,该 idpipeline 必须是唯一标识。
  8990. @param pipe The pipe to be inserted
  8991. @param index The index to insert
  8992. */
  8993. insertPipe(pipe: any, index: number): void;
  8994. /**
  8995. !en
  8996. Insert a pipe to the end of an existing pipe. The existing pipe must be a valid pipe in the pipeline.
  8997. !zh
  8998. 在当前 pipeline 的一个已知 pipe 后面插入一个新的 pipe
  8999. @param refPipe An existing pipe in the pipeline.
  9000. @param newPipe The pipe to be inserted.
  9001. */
  9002. insertPipeAfter(refPipe: any, newPipe: any): void;
  9003. /**
  9004. !#en
  9005. Add a new pipe at the end of the pipeline. </br>
  9006. A pipe must contain an `id` in string and a `handle` function, the id must be unique in the pipeline.
  9007. !#zh
  9008. 添加一个新的 pipepipeline 尾部。 </br>
  9009. pipe 必须包含一个字符串类型 ‘id’ 和 ‘handle’ 函数,该 idpipeline 必须是唯一标识。
  9010. @param pipe The pipe to be appended
  9011. */
  9012. appendPipe(pipe: any): void;
  9013. /**
  9014. !#en
  9015. Let new items flow into the pipeline. </br>
  9016. Each item can be a simple url string or an object,
  9017. if it's an object, it must contain `id` property. </br>
  9018. You can specify its type by `type` property, by default, the type is the extension name in url. </br>
  9019. By adding a `skips` property including pipe ids, you can skip these pipe. </br>
  9020. The object can contain any supplementary property as you want. </br>
  9021. !#zh
  9022. 让新的 item 流入 pipeline 中。</br>
  9023. 这里的每个 item 可以是一个简单字符串类型的 url 或者是一个对象,
  9024. 如果它是一个对象的话,他必须要包含 ‘id’ 属性。</br>
  9025. 你也可以指定它的 ‘type’ 属性类型,默认情况下,该类型是 ‘url’ 的后缀名。</br>
  9026. 也通过添加一个 包含 ‘skips’ 属性的 item 对象,你就可以跳过 skips 中包含的 pipe。</br>
  9027. 该对象可以包含任何附加属性。
  9028. @param items items
  9029. @example
  9030. ```js
  9031. pipeline.flowIn([
  9032. 'res/Background.png',
  9033. {
  9034. id: 'res/scene.json',
  9035. type: 'scene',
  9036. name: 'scene',
  9037. skips: ['Downloader']
  9038. }
  9039. ]);
  9040. ```
  9041. */
  9042. flowIn(items: any[]): void;
  9043. /**
  9044. !#en
  9045. Let new items flow into the pipeline and give a callback when the list of items are all completed. </br>
  9046. This is for loading dependencies for an existing item in flow, usually used in a pipe logic. </br>
  9047. For example, we have a loader for scene configuration file in JSON, the scene will only be fully loaded </br>
  9048. after all its dependencies are loaded, then you will need to use function to flow in all dependencies </br>
  9049. found in the configuration file, and finish the loader pipe only after all dependencies are loaded (in the callback).
  9050. !#zh
  9051. 让新 items 流入 pipeline 并且当 item 列表完成时进行回调函数。</br>
  9052. 这个 API 的使用通常是为了加载依赖项。</br>
  9053. 例如:</br>
  9054. 我们需要加载一个场景配置的 JSON 文件,该场景会将所有的依赖项全部都加载完毕以后,进行回调表示加载完毕。
  9055. @param urlList urlList
  9056. @param callback callback
  9057. */
  9058. flowInDeps(urlList: any[], callback: Function): any[];
  9059. /**
  9060. !#en
  9061. Copy the item states from one source item to all destination items. </br>
  9062. It's quite useful when a pipe generate new items from one source item,</br>
  9063. then you should flowIn these generated items into pipeline, </br>
  9064. but you probably want them to skip all pipes the source item already go through,</br>
  9065. you can achieve it with this API. </br>
  9066. </br>
  9067. For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
  9068. !#zh
  9069. 从一个源 item 向所有目标 item 复制它的 pipe 状态,用于避免重复通过部分 pipe。</br>
  9070. 当一个源 item 生成了一系列新的 items 时很有用,</br>
  9071. 你希望让这些新的依赖项进入 pipeline,但是又不希望它们通过源 item 已经经过的 pipe,</br>
  9072. 但是你可能希望他们源 item 已经通过并跳过所有 pipes,</br>
  9073. 这个时候就可以使用这个 API
  9074. @param srcItem The source item
  9075. @param dstItems A single destination item or an array of destination items
  9076. */
  9077. copyItemStates(srcItem: any, dstItems: any[]|any): void;
  9078. /**
  9079. !#en Returns whether the pipeline is flowing (contains item) currently.
  9080. !#zh 获取 pipeline 当前是否正在处理中。
  9081. */
  9082. isFlowing(): boolean;
  9083. /**
  9084. !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
  9085. !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API
  9086. */
  9087. getItems(): LoadingItems;
  9088. /**
  9089. !#en Returns an item in pipeline.
  9090. !#zh 根据 id 获取一个 item
  9091. @param id The id of the item
  9092. */
  9093. getItem(id: any): any;
  9094. /**
  9095. !#en Removes an completed item in pipeline.
  9096. It will only remove the cache in the pipeline or loader, its dependencies won't be released.
  9097. cc.loader provided another method to completely cleanup the resource and its dependencies,
  9098. please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9099. !#zh 移除指定的已完成 item
  9100. 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
  9101. cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
  9102. @param id The id of the item
  9103. */
  9104. removeItem(id: any): boolean;
  9105. /**
  9106. !#en Clear the current pipeline, this function will clean up the items.
  9107. !#zh 清空当前 pipeline,该函数将清理 items
  9108. */
  9109. clear(): void;
  9110. }
  9111. /** undefined */
  9112. export class Graphics extends _RendererUnderSG {
  9113. /** !#en
  9114. Current line width.
  9115. !#zh
  9116. 当前线条宽度 */
  9117. lineWidth: number;
  9118. /** !#en
  9119. lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
  9120. !#zh
  9121. lineJoin 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */
  9122. lineJoin: Graphics.LineJoin;
  9123. /** !#en
  9124. lineCap determines how the end points of every line are drawn.
  9125. !#zh
  9126. lineCap 指定如何绘制每一条线段末端。 */
  9127. lineCap: Graphics.LineCap;
  9128. /** !#en
  9129. stroke color
  9130. !#zh
  9131. 线段颜色 */
  9132. strokeColor: Color;
  9133. /** !#en
  9134. fill color
  9135. !#zh
  9136. 填充颜色 */
  9137. fillColor: Color;
  9138. /** !#en
  9139. Sets the miter limit ratio
  9140. !#zh
  9141. 设置斜接面限制比例 */
  9142. miterLimit: number;
  9143. /**
  9144. !#en Move path start point to (x,y).
  9145. !#zh 移动路径起点到坐标(x, y)
  9146. @param x The x axis of the coordinate for the end point.
  9147. @param y The y axis of the coordinate for the end point.
  9148. */
  9149. moveTo(x?: number, y?: number): void;
  9150. /**
  9151. !#en Adds a straight line to the path
  9152. !#zh 绘制直线路径
  9153. @param x The x axis of the coordinate for the end point.
  9154. @param y The y axis of the coordinate for the end point.
  9155. */
  9156. lineTo(x?: number, y?: number): void;
  9157. /**
  9158. !#en Adds a cubic Bézier curve to the path
  9159. !#zh 绘制三次贝赛尔曲线路径
  9160. @param c1x The x axis of the coordinate for the first control point.
  9161. @param c1y The y axis of the coordinate for first control point.
  9162. @param c2x The x axis of the coordinate for the second control point.
  9163. @param c2y The y axis of the coordinate for the second control point.
  9164. @param x The x axis of the coordinate for the end point.
  9165. @param y The y axis of the coordinate for the end point.
  9166. */
  9167. bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
  9168. /**
  9169. !#en Adds a quadratic Bézier curve to the path
  9170. !#zh 绘制二次贝赛尔曲线路径
  9171. @param cx The x axis of the coordinate for the control point.
  9172. @param cy The y axis of the coordinate for the control point.
  9173. @param x The x axis of the coordinate for the end point.
  9174. @param y The y axis of the coordinate for the end point.
  9175. */
  9176. quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
  9177. /**
  9178. !#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).
  9179. !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) 位置,半径为 r ,根据 counterclockwise (默认为false)指定的方向从 startAngle 开始绘制,到 endAngle 结束。
  9180. @param cx The x axis of the coordinate for the center point.
  9181. @param cy The y axis of the coordinate for the center point.
  9182. @param r The arc's radius.
  9183. @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
  9184. @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
  9185. @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.
  9186. */
  9187. arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void;
  9188. /**
  9189. !#en Adds an ellipse to the path.
  9190. !#zh 绘制椭圆路径。
  9191. @param cx The x axis of the coordinate for the center point.
  9192. @param cy The y axis of the coordinate for the center point.
  9193. @param rx The ellipse's x-axis radius.
  9194. @param ry The ellipse's y-axis radius.
  9195. */
  9196. ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
  9197. /**
  9198. !#en Adds an circle to the path.
  9199. !#zh 绘制圆形路径。
  9200. @param cx The x axis of the coordinate for the center point.
  9201. @param cy The y axis of the coordinate for the center point.
  9202. @param r The circle's radius.
  9203. */
  9204. circle(cx?: number, cy?: number, r?: number): void;
  9205. /**
  9206. !#en Adds an rectangle to the path.
  9207. !#zh 绘制矩形路径。
  9208. @param x The x axis of the coordinate for the rectangle starting point.
  9209. @param y The y axis of the coordinate for the rectangle starting point.
  9210. @param w The rectangle's width.
  9211. @param h The rectangle's height.
  9212. */
  9213. rect(x?: number, y?: number, w?: number, h?: number): void;
  9214. /**
  9215. !#en Adds an round corner rectangle to the path.
  9216. !#zh 绘制圆角矩形路径。
  9217. @param x The x axis of the coordinate for the rectangle starting point.
  9218. @param y The y axis of the coordinate for the rectangle starting point.
  9219. @param w The rectangles width.
  9220. @param h The rectangle's height.
  9221. @param r The radius of the rectangle.
  9222. */
  9223. roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
  9224. /**
  9225. !#en Draws a filled rectangle.
  9226. !#zh 绘制填充矩形。
  9227. @param x The x axis of the coordinate for the rectangle starting point.
  9228. @param y The y axis of the coordinate for the rectangle starting point.
  9229. @param w The rectangle's width.
  9230. @param h The rectangle's height.
  9231. */
  9232. fillRect(x?: number, y?: number, w?: number, h?: number): void;
  9233. /**
  9234. !#en Erasing any previously drawn content.
  9235. !#zh 擦除之前绘制的所有内容的方法。
  9236. @param clean Whether to clean the graphics inner cache.
  9237. */
  9238. clear(clean?: boolean): void;
  9239. /**
  9240. !#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.
  9241. !#zh 将笔点返回到当前路径起始点的。它尝试从当前点到起始点绘制一条直线。
  9242. */
  9243. close(): void;
  9244. /**
  9245. !#en Strokes the current or given path with the current stroke style.
  9246. !#zh 根据当前的画线样式,绘制当前或已经存在的路径。
  9247. */
  9248. stroke(): void;
  9249. /**
  9250. !#en Fills the current or given path with the current fill style.
  9251. !#zh 根据当前的画线样式,填充当前或已经存在的路径。
  9252. */
  9253. fill(): void;
  9254. }
  9255. /** undefined */
  9256. export class WorldManifold {
  9257. /** !#en
  9258. world contact point (point of intersection)
  9259. !#zh
  9260. 碰撞点集合 */
  9261. points: [Vec2];
  9262. /** !#en
  9263. world vector pointing from A to B
  9264. !#zh
  9265. 世界坐标系下由 A 指向 B 的向量 */
  9266. normal: Vec2;
  9267. }
  9268. /** !#en
  9269. A manifold point is a contact point belonging to a contact manifold.
  9270. It holds details related to the geometry and dynamics of the contact points.
  9271. Note: the impulses are used for internal caching and may not
  9272. provide reliable contact forces, especially for high speed collisions.
  9273. !#zh
  9274. ManifoldPoint 是接触信息中的接触点信息。它拥有关于几何和接触点的详细信息。
  9275. 注意:信息中的冲量用于系统内部缓存,提供的接触力可能不是很准确,特别是高速移动中的碰撞信息。 */
  9276. export class ManifoldPoint {
  9277. /** !#en
  9278. The local point usage depends on the manifold type:
  9279. -e_circles: the local center of circleB
  9280. -e_faceA: the local center of circleB or the clip point of polygonB
  9281. -e_faceB: the clip point of polygonA
  9282. !#zh
  9283. 本地坐标点的用途取决于 manifold 的类型
  9284. - e_circles: circleB 的本地中心点
  9285. - e_faceA: circleB 的本地中心点 或者是 polygonB 的截取点
  9286. - e_faceB: polygonB 的截取点 */
  9287. localPoint: Vec2;
  9288. /** !#en
  9289. Normal impulse.
  9290. !#zh
  9291. 法线冲量。 */
  9292. normalImpulse: number;
  9293. /** !#en
  9294. Tangent impulse.
  9295. !#zh
  9296. 切线冲量。 */
  9297. tangentImpulse: number;
  9298. }
  9299. /** undefined */
  9300. export class Manifold {
  9301. /** !#en
  9302. Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
  9303. !#zh
  9304. Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */
  9305. type: number;
  9306. /** !#en
  9307. The local point usage depends on the manifold type:
  9308. -e_circles: the local center of circleA
  9309. -e_faceA: the center of faceA
  9310. -e_faceB: the center of faceB
  9311. !#zh
  9312. 用途取决于 manifold 类型
  9313. -e_circles: circleA 的本地中心点
  9314. -e_faceA: faceA 的本地中心点
  9315. -e_faceB: faceB 的本地中心点 */
  9316. localPoint: Vec2;
  9317. /** !#en
  9318. -e_circles: not used
  9319. -e_faceA: the normal on polygonA
  9320. -e_faceB: the normal on polygonB
  9321. !#zh
  9322. -e_circles: 没被使用到
  9323. -e_faceA: polygonA 的法向量
  9324. -e_faceB: polygonB 的法向量 */
  9325. localNormal: Vec2;
  9326. /** !#en
  9327. the points of contact.
  9328. !#zh
  9329. 接触点信息。 */
  9330. points: [ManifoldPoint];
  9331. }
  9332. /** !#en
  9333. Contact impulses for reporting.
  9334. !#zh
  9335. 用于返回给回调的接触冲量。 */
  9336. export class PhysicsImpulse {
  9337. /** !#en
  9338. Normal impulses.
  9339. !#zh
  9340. 法线方向的冲量 */
  9341. normalImpulses: void;
  9342. /** !#en
  9343. Tangent impulses
  9344. !#zh
  9345. 切线方向的冲量 */
  9346. tangentImpulses: void;
  9347. }
  9348. /** !#en
  9349. PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
  9350. Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
  9351. !#zh
  9352. 物理接触会在开始和结束碰撞之间生成,并作为参数传入到碰撞回调函数中。
  9353. 注意:传入的物理接触会被系统进行重用,所以不要在使用中缓存里面的任何信息。 */
  9354. export class PhysicsContact {
  9355. /**
  9356. !#en
  9357. Get the world manifold.
  9358. !#zh
  9359. 获取世界坐标系下的碰撞信息。
  9360. */
  9361. getWorldManifold(): WorldManifold;
  9362. /**
  9363. !#en
  9364. Get the manifold.
  9365. !#zh
  9366. 获取本地(局部)坐标系下的碰撞信息。
  9367. */
  9368. getManifold(): Manifold;
  9369. /**
  9370. !#en
  9371. Get the impulses.
  9372. Note: PhysicsImpulse can only used in onPostSolve callback.
  9373. !#zh
  9374. 获取冲量信息
  9375. 注意:这个信息只有在 onPostSolve 回调中才能获取到
  9376. */
  9377. getImpulse(): PhysicsImpulse;
  9378. colliderA: Collider;
  9379. colliderB: Collider;
  9380. /** !#en
  9381. If set disabled to true, the contact will be ignored until contact end.
  9382. If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
  9383. !#zh
  9384. 如果 disabled 被设置为 true,那么直到接触结束此接触都将被忽略。
  9385. 如果只是希望在当前时间步或子步中忽略此接触,请使用 disabledOnce 。 */
  9386. disabled: boolean;
  9387. /** !#en
  9388. Disabled contact for current time step or sub-step.
  9389. !#zh
  9390. 在当前时间步或子步中忽略此接触。 */
  9391. disabledOnce: boolean;
  9392. /**
  9393. !#en
  9394. Is this contact touching?
  9395. !#zh
  9396. 返回碰撞体是否已经接触到。
  9397. */
  9398. isTouching(): boolean;
  9399. /**
  9400. !#en
  9401. Set the desired tangent speed for a conveyor belt behavior.
  9402. !#zh
  9403. 为传送带设置期望的切线速度
  9404. @param tangentSpeed tangentSpeed
  9405. */
  9406. setTangentSpeed(tangentSpeed: number): void;
  9407. /**
  9408. !#en
  9409. Get the desired tangent speed.
  9410. !#zh
  9411. 获取切线速度
  9412. */
  9413. getTangentSpeed(): number;
  9414. /**
  9415. !#en
  9416. Override the default friction mixture. You can call this in onPreSolve callback.
  9417. !#zh
  9418. 覆盖默认的摩擦力系数。你可以在 onPreSolve 回调中调用此函数。
  9419. @param friction friction
  9420. */
  9421. setFriction(friction: number): void;
  9422. /**
  9423. !#en
  9424. Get the friction.
  9425. !#zh
  9426. 获取当前摩擦力系数
  9427. */
  9428. getFriction(): number;
  9429. /**
  9430. !#en
  9431. Reset the friction mixture to the default value.
  9432. !#zh
  9433. 重置摩擦力系数到默认值
  9434. */
  9435. resetFriction(): void;
  9436. /**
  9437. !#en
  9438. Override the default restitution mixture. You can call this in onPreSolve callback.
  9439. !#zh
  9440. 覆盖默认的恢复系数。你可以在 onPreSolve 回调中调用此函数。
  9441. @param restitution restitution
  9442. */
  9443. setRestitution(restitution: number): void;
  9444. /**
  9445. !#en
  9446. Get the restitution.
  9447. !#zh
  9448. 获取当前恢复系数
  9449. */
  9450. getRestitution(): number;
  9451. /**
  9452. !#en
  9453. Reset the restitution mixture to the default value.
  9454. !#zh
  9455. 重置恢复系数到默认值
  9456. */
  9457. resetRestitution(): void;
  9458. }
  9459. /** !#en
  9460. Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
  9461. You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
  9462. Physics manager distributes the collision information to each collision callback when collision is produced.
  9463. Note: You need first enable the collision listener in the rigidbody.
  9464. !#zh
  9465. 物理系统将 box2d 作为内部物理系统,并且隐藏了大部分 box2d 实现细节(比如创建刚体,同步刚体信息到节点中等)。
  9466. 你可以通过物理系统访问一些 box2d 常用的功能,比如点击测试,射线测试,设置测试信息等。
  9467. 物理系统还管理碰撞信息的分发,她会在产生碰撞时,将碰撞信息分发到各个碰撞回调中。
  9468. 注意:你需要先在刚体中开启碰撞接听才会产生相应的碰撞回调。 */
  9469. export class PhysicsManager implements EventTarget {
  9470. /** !#en
  9471. The draw bits for drawing physics debug information.
  9472. !#zh
  9473. 指定物理系统需要绘制哪些调试信息。 */
  9474. static DrawBits: DrawBits;
  9475. /** !#en
  9476. The ratio transform between physics unit and pixel unit, generally is 32.
  9477. !#zh
  9478. 物理单位与像素单位互相转换的比率,一般是 32。 */
  9479. static PTM_RATIO: number;
  9480. /** !#en
  9481. The velocity iterations for the velocity constraint solver.
  9482. !#zh
  9483. 速度更新迭代数 */
  9484. static VELOCITY_ITERATIONS: number;
  9485. /** !#en
  9486. The position Iterations for the position constraint solver.
  9487. !#zh
  9488. 位置迭代更新数 */
  9489. static POSITION_ITERATIONS: number;
  9490. /** !#en
  9491. Specify the fixed time step.
  9492. Need enabledAccumulator to make it work.
  9493. !#zh
  9494. 指定固定的物理更新间隔时间,需要开启 enabledAccumulator 才有效。 */
  9495. static FIXED_TIME_STEP: number;
  9496. /** !#en
  9497. Specify the max accumulator time.
  9498. Need enabledAccumulator to make it work.
  9499. !#zh
  9500. 每次可用于更新物理系统的最大时间,需要开启 enabledAccumulator 才有效。 */
  9501. static MAX_ACCUMULATOR: number;
  9502. /** !#en
  9503. If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
  9504. And if the update dt is bigger than the time step, then will call step function several times.
  9505. If disabled accumulator, then will call step function with a time step calculated with the frame rate.
  9506. !#zh
  9507. 如果开启此选项,那么将会以固定的间隔时间 FIXED_TIME_STEP 来更新物理引擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物理引擎进行多次更新。
  9508. 如果关闭此选项,那么将会根据设定的 frame rate 计算出一个间隔时间来更新物理引擎。 */
  9509. enabledAccumulator: boolean;
  9510. /**
  9511. !#en
  9512. Test which collider contains the given world point
  9513. !#zh
  9514. 获取包含给定世界坐标系点的碰撞体
  9515. @param point the world point
  9516. */
  9517. testPoint(point: Vec2): PhysicsCollider;
  9518. /**
  9519. !#en
  9520. Test which colliders intersect the given world rect
  9521. !#zh
  9522. 获取与给定世界坐标系矩形相交的碰撞体
  9523. @param rect the world rect
  9524. */
  9525. testAABB(rect: Rect): [PhysicsCollider];
  9526. /**
  9527. !#en
  9528. Raycast the world for all colliders in the path of the ray.
  9529. The raycast ignores colliders that contain the starting point.
  9530. !#zh
  9531. 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包含起始点的碰撞体。
  9532. @param p1 start point of the raycast
  9533. @param p2 end point of the raycast
  9534. @param type optional, default is RayCastType.Closest
  9535. */
  9536. rayCast(p1: Vec2, p2: Vec2, type: RayCastType): [PhysicsRayCastResult];
  9537. /**
  9538. !#en
  9539. Attach physics debug draw to camera
  9540. !#zh
  9541. 将物理的调试绘制信息附加到指定摄像机上
  9542. @param camera camera
  9543. */
  9544. attachDebugDrawToCamera(camera: Camera): void;
  9545. /**
  9546. !#en
  9547. Detach physics debug draw to camera
  9548. !#zh
  9549. 将物理的调试绘制信息从指定摄像机上移除
  9550. @param camera camera
  9551. */
  9552. detachDebugDrawFromCamera(camera: Camera): void;
  9553. /** !#en
  9554. Enabled the physics manager?
  9555. !#zh
  9556. 指定是否启用物理系统? */
  9557. enabled: boolean;
  9558. /** !#en
  9559. Debug draw flags.
  9560. !#zh
  9561. 设置调试绘制标志 */
  9562. debugDrawFlags: number;
  9563. /** !#en
  9564. The physics world gravity.
  9565. !#zh
  9566. 物理世界重力值 */
  9567. gravity: Vec2;
  9568. /**
  9569. !#en
  9570. Register an callback of a specific event type on the EventTarget.
  9571. !#zh
  9572. 注册事件目标的特定事件类型回调。
  9573. @param type A string representing the event type to listen for.
  9574. @param callback The callback that will be invoked when the event is dispatched.
  9575. The callback is ignored if it is a duplicate (the callbacks are unique).
  9576. @param target The target (this object) to invoke the callback, can be null
  9577. @param useCapture When set to true, the capture argument prevents callback
  9578. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9579. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9580. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9581. @example
  9582. ```js
  9583. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9584. cc.log("this is callback");
  9585. }, node);
  9586. ```
  9587. */
  9588. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9589. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9590. /**
  9591. !#en
  9592. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  9593. if only type is passed as parameter, all listeners registered with that type will be removed.
  9594. !#zh
  9595. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  9596. @param type A string representing the event type being removed.
  9597. @param callback The callback to remove.
  9598. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  9599. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  9600. If not specified, useCapture defaults to false. If a callback was registered twice,
  9601. one with capture and one without, each must be removed separately. Removal of a capturing callback
  9602. does not affect a non-capturing version of the same listener, and vice versa.
  9603. @example
  9604. ```js
  9605. // register touchEnd eventListener
  9606. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  9607. cc.log("this is callback");
  9608. }, node);
  9609. // remove touch end event listener
  9610. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  9611. // remove all touch end event listeners
  9612. node.off(cc.Node.EventType.TOUCH_END);
  9613. ```
  9614. */
  9615. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  9616. /**
  9617. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  9618. This is not for removing all listeners in the current event target,
  9619. and this is not for removing all listeners the target parameter have registered.
  9620. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  9621. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  9622. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  9623. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  9624. @param target The target to be searched for all related listeners
  9625. */
  9626. targetOff(target: any): void;
  9627. /**
  9628. !#en
  9629. Register an callback of a specific event type on the EventTarget,
  9630. the callback will remove itself after the first time it is triggered.
  9631. !#zh
  9632. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  9633. @param type A string representing the event type to listen for.
  9634. @param callback The callback that will be invoked when the event is dispatched.
  9635. The callback is ignored if it is a duplicate (the callbacks are unique).
  9636. @param target The target (this object) to invoke the callback, can be null
  9637. @param useCapture When set to true, the capture argument prevents callback
  9638. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  9639. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  9640. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  9641. @example
  9642. ```js
  9643. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  9644. cc.log("this is callback");
  9645. }, node);
  9646. ```
  9647. */
  9648. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  9649. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  9650. /**
  9651. !#en
  9652. Dispatches an event into the event flow.
  9653. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  9654. !#zh 分发事件到事件流中。
  9655. @param event The Event object that is dispatched into the event flow
  9656. */
  9657. dispatchEvent(event: Event): void;
  9658. /**
  9659. !#en
  9660. Send an event to this object directly, this method will not propagate the event to any other objects.
  9661. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  9662. !#zh
  9663. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  9664. @param message the message to send
  9665. @param detail whatever argument the message needs
  9666. */
  9667. emit(message: string, detail?: any): void;
  9668. }
  9669. /** undefined */
  9670. export enum DrawBits {
  9671. e_aabbBit = 0,
  9672. e_pairBit = 0,
  9673. e_centerOfMassBit = 0,
  9674. e_jointBit = 0,
  9675. e_shapeBit = 0,
  9676. }
  9677. /** undefined */
  9678. export class PhysicsRayCastResult {
  9679. /** !#en
  9680. The PhysicsCollider which intersects with the raycast
  9681. !#zh
  9682. 与射线相交的碰撞体 */
  9683. collider: PhysicsCollider;
  9684. /** !#en
  9685. The intersection point
  9686. !#zh
  9687. 射线与碰撞体相交的点 */
  9688. point: Vec2;
  9689. /** !#en
  9690. The normal vector at the point of intersection
  9691. !#zh
  9692. 射线与碰撞体相交的点的法向量 */
  9693. normal: Vec2;
  9694. /** !#en
  9695. The fraction of the raycast path at the point of intersection
  9696. !#zh
  9697. 射线与碰撞体相交的点占射线长度的分数 */
  9698. fraction: number;
  9699. }
  9700. /** !#en Enum for RigidBodyType.
  9701. !#zh 刚体类型 */
  9702. export enum RigidBodyType {
  9703. Static = 0,
  9704. Kinematic = 0,
  9705. Dynamic = 0,
  9706. Animated = 0,
  9707. }
  9708. /** !#en Enum for RayCastType.
  9709. !#zh 射线检测类型 */
  9710. export enum RayCastType {
  9711. Closest = 0,
  9712. Any = 0,
  9713. AllClosest = 0,
  9714. All = 0,
  9715. }
  9716. /** undefined */
  9717. export class RigidBody extends Component {
  9718. /** !#en
  9719. Should enabled contact listener?
  9720. When a collision is trigger, the collision callback will only be called when enabled contact listener.
  9721. !#zh
  9722. 是否启用接触接听器。
  9723. 当 collider 产生碰撞时,只有开启了接触接听器才会调用相应的回调函数 */
  9724. enabledContactListener: boolean;
  9725. /**
  9726. !#en
  9727. Collision callback.
  9728. Called when two collider begin to touch.
  9729. !#zh
  9730. 碰撞回调。
  9731. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体开始接触时被调用。
  9732. @param contact contact information
  9733. @param selfCollider the collider belong to this rigidbody
  9734. @param otherCollider the collider belong to another rigidbody
  9735. */
  9736. onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9737. /**
  9738. !#en
  9739. Collision callback.
  9740. Called when two collider cease to touch.
  9741. !#zh
  9742. 碰撞回调。
  9743. 如果你的脚本中实现了这个函数,那么它将会在两个碰撞体停止接触时被调用。
  9744. @param contact contact information
  9745. @param selfCollider the collider belong to this rigidbody
  9746. @param otherCollider the collider belong to another rigidbody
  9747. */
  9748. onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9749. /**
  9750. !#en
  9751. Collision callback.
  9752. This is called when a contact is updated.
  9753. This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
  9754. Note: this is called only for awake bodies.
  9755. Note: this is called even when the number of contact points is zero.
  9756. Note: this is not called for sensors.
  9757. !#zh
  9758. 碰撞回调。
  9759. 如果你的脚本中实现了这个函数,那么它将会在接触更新时被调用。
  9760. 你可以在接触被处理前根据他包含的信息作出相应的处理,比如将这个接触禁用掉。
  9761. 注意:回调只会为醒着的刚体调用。
  9762. 注意:接触点为零的时候也有可能被调用。
  9763. 注意:感知体(sensor)的回调不会被调用。
  9764. @param contact contact information
  9765. @param selfCollider the collider belong to this rigidbody
  9766. @param otherCollider the collider belong to another rigidbody
  9767. */
  9768. onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9769. /**
  9770. !#en
  9771. Collision callback.
  9772. This is called after a contact is updated.
  9773. You can get the impulses from the contact in this callback.
  9774. !#zh
  9775. 碰撞回调。
  9776. 如果你的脚本中实现了这个函数,那么它将会在接触更新完后被调用。
  9777. 你可以在这个回调中从接触信息中获取到冲量信息。
  9778. @param contact contact information
  9779. @param selfCollider the collider belong to this rigidbody
  9780. @param otherCollider the collider belong to another rigidbody
  9781. */
  9782. onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
  9783. /** !#en
  9784. Is this a fast moving body that should be prevented from tunneling through
  9785. other moving bodies?
  9786. Note :
  9787. - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
  9788. - You should use this flag sparingly since it increases processing time.
  9789. !#zh
  9790. 这个刚体是否是一个快速移动的刚体,并且需要禁止穿过其他快速移动的刚体?
  9791. 需要注意的是 :
  9792. - 所有刚体都被禁止从 运动刚体 和 静态刚体 中穿过。此选项只关注于 动态刚体。
  9793. - 应该尽量少的使用此选项,因为它会增加程序处理时间。 */
  9794. bullet: boolean;
  9795. /** !#en
  9796. Rigidbody type : Static, Kinematic, Dynamic or Animated.
  9797. !#zh
  9798. 刚体类型: Static, Kinematic, Dynamic or Animated. */
  9799. type: RigidBodyType;
  9800. /** !#en
  9801. Set this flag to false if this body should never fall asleep.
  9802. Note that this increases CPU usage.
  9803. !#zh
  9804. 如果此刚体永远都不应该进入睡眠,那么设置这个属性为 false。
  9805. 需要注意这将使 CPU 占用率提高。 */
  9806. allowSleep: boolean;
  9807. /** !#en
  9808. Scale the gravity applied to this body.
  9809. !#zh
  9810. 缩放应用在此刚体上的重力值 */
  9811. gravityScale: number;
  9812. /** !#en
  9813. Linear damping is use to reduce the linear velocity.
  9814. The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
  9815. time step when the damping parameter is large.
  9816. !#zh
  9817. Linear damping 用于衰减刚体的线性速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9818. linearDamping: number;
  9819. /** !#en
  9820. Angular damping is use to reduce the angular velocity. The damping parameter
  9821. can be larger than 1 but the damping effect becomes sensitive to the
  9822. time step when the damping parameter is large.
  9823. !#zh
  9824. Angular damping 用于衰减刚体的角速度。衰减系数可以大于 1,但是当衰减系数比较大的时候,衰减的效果会变得比较敏感。 */
  9825. angularDamping: number;
  9826. /** !#en
  9827. The linear velocity of the body's origin in world co-ordinates.
  9828. !#zh
  9829. 刚体在世界坐标下的线性速度 */
  9830. linearVelocity: Vec2;
  9831. /** !#en
  9832. The angular velocity of the body.
  9833. !#zh
  9834. 刚体的角速度 */
  9835. angularVelocity: number;
  9836. /** !#en
  9837. Should this body be prevented from rotating?
  9838. !#zh
  9839. 是否禁止此刚体进行旋转 */
  9840. fixedRotation: boolean;
  9841. /** !#en
  9842. Is this body initially awake or sleeping?
  9843. !#zh
  9844. 是否立刻唤醒此刚体 */
  9845. awake: boolean;
  9846. /** !#en
  9847. Set the active state of the body. An inactive body is not
  9848. simulated and cannot be collided with or woken up.
  9849. If body is active, all fixtures will be added to the
  9850. broad-phase.
  9851. If body is inactive, all fixtures will be removed from
  9852. the broad-phase and all contacts will be destroyed.
  9853. Fixtures on an inactive body are implicitly inactive and will
  9854. not participate in collisions, ray-casts, or queries.
  9855. Joints connected to an inactive body are implicitly inactive.
  9856. !#zh
  9857. 设置刚体的激活状态。一个非激活状态下的刚体是不会被模拟和碰撞的,不管它是否处于睡眠状态下。
  9858. 如果刚体处于激活状态下,所有夹具会被添加到 粗测阶段(broad-phase)。
  9859. 如果刚体处于非激活状态下,所有夹具会被从 粗测阶段(broad-phase)中移除。
  9860. 在非激活状态下的夹具不会参与到碰撞,射线,或者查找中
  9861. 链接到非激活状态下刚体的关节也是非激活的。 */
  9862. active: boolean;
  9863. /**
  9864. !#en
  9865. Gets a local point relative to the body's origin given a world point.
  9866. !#zh
  9867. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9868. @param worldPoint a point in world coordinates.
  9869. @param out optional, the receiving point
  9870. */
  9871. getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9872. /**
  9873. !#en
  9874. Get the world coordinates of a point given the local coordinates.
  9875. !#zh
  9876. 将一个给定的刚体本地坐标系下的点转换为世界坐标系下的点
  9877. @param localPoint a point in local coordinates.
  9878. @param out optional, the receiving point
  9879. */
  9880. getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
  9881. /**
  9882. !#en
  9883. Get the world coordinates of a vector given the local coordinates.
  9884. !#zh
  9885. 将一个给定的世界坐标系下的向量转换为刚体本地坐标系下的向量
  9886. @param localVector a vector in world coordinates.
  9887. @param out optional, the receiving vector
  9888. */
  9889. getWorldVector(localVector: Vec2, out: Vec2): Vec2;
  9890. /**
  9891. !#en
  9892. Gets a local vector relative to the body's origin given a world vector.
  9893. !#zh
  9894. 将一个给定的世界坐标系下的点转换为刚体本地坐标系下的点
  9895. @param worldVector a vector in world coordinates.
  9896. @param out optional, the receiving vector
  9897. */
  9898. getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
  9899. /**
  9900. !#en
  9901. Get the world body origin position.
  9902. !#zh
  9903. 获取刚体世界坐标系下的原点值
  9904. @param out optional, the receiving point
  9905. */
  9906. getWorldPosition(out: Vec2): Vec2;
  9907. /**
  9908. !#en
  9909. Get the world body rotation angle.
  9910. !#zh
  9911. 获取刚体世界坐标系下的旋转值。
  9912. */
  9913. getWorldRotation(): number;
  9914. /**
  9915. !#en
  9916. Get the local position of the center of mass.
  9917. !#zh
  9918. 获取刚体本地坐标系下的质心
  9919. */
  9920. getLocalCenter(): Vec2;
  9921. /**
  9922. !#en
  9923. Get the world position of the center of mass.
  9924. !#zh
  9925. 获取刚体世界坐标系下的质心
  9926. */
  9927. getWorldCenter(): Vec2;
  9928. /**
  9929. !#en
  9930. Get the world linear velocity of a world point attached to this body.
  9931. !#zh
  9932. 获取刚体上指定点的线性速度
  9933. @param worldPoint a point in world coordinates.
  9934. @param out optional, the receiving point
  9935. */
  9936. getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
  9937. /**
  9938. !#en
  9939. Get total mass of the body.
  9940. !#zh
  9941. 获取刚体的质量。
  9942. */
  9943. getMass(): number;
  9944. /**
  9945. !#en
  9946. Get the rotational inertia of the body about the local origin.
  9947. !#zh
  9948. 获取刚体本地坐标系下原点的旋转惯性
  9949. */
  9950. getInertia(): number;
  9951. /**
  9952. !#en
  9953. Get all the joints connect to the rigidbody.
  9954. !#zh
  9955. 获取链接到此刚体的所有关节
  9956. */
  9957. getJointList(): [Joint];
  9958. /**
  9959. !#en
  9960. Apply a force at a world point. If the force is not
  9961. applied at the center of mass, it will generate a torque and
  9962. affect the angular velocity.
  9963. !#zh
  9964. 施加一个力到刚体上的一个点。如果力没有施加到刚体的质心上,还会产生一个扭矩并且影响到角速度。
  9965. @param force the world force vector.
  9966. @param point the world position.
  9967. @param wake also wake up the body.
  9968. */
  9969. applyForce(force: Vec2, point: Vec2, wake: boolean): void;
  9970. /**
  9971. !#en
  9972. Apply a force to the center of mass.
  9973. !#zh
  9974. 施加一个力到刚体上的质心上。
  9975. @param force the world force vector.
  9976. @param wake also wake up the body.
  9977. */
  9978. applyForceToCenter(force: Vec2, wake: boolean): void;
  9979. /**
  9980. !#en
  9981. Apply a torque. This affects the angular velocity.
  9982. !#zh
  9983. 施加一个扭矩力,将影响刚体的角速度
  9984. @param torque about the z-axis (out of the screen), usually in N-m.
  9985. @param wake also wake up the body
  9986. */
  9987. applyTorque(torque: number, wake: boolean): void;
  9988. /**
  9989. !#en
  9990. Apply a impulse at a world point, This immediately modifies the velocity.
  9991. If the impulse is not applied at the center of mass, it will generate a torque and
  9992. affect the angular velocity.
  9993. !#zh
  9994. 施加冲量到刚体上的一个点,将立即改变刚体的线性速度。
  9995. 如果冲量施加到的点不是刚体的质心,那么将产生一个扭矩并影响刚体的角速度。
  9996. @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
  9997. @param point the world position
  9998. @param wake alse wake up the body
  9999. */
  10000. applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
  10001. /**
  10002. !#en
  10003. Apply an angular impulse.
  10004. !#zh
  10005. 施加一个角速度冲量。
  10006. @param impulse the angular impulse in units of kg*m*m/s
  10007. @param wake also wake up the body
  10008. */
  10009. applyAngularImpulse(impulse: number, wake: boolean): void;
  10010. /**
  10011. !#en
  10012. Synchronize node's world position to box2d rigidbody's position.
  10013. If enableAnimated is true and rigidbody's type is Animated type,
  10014. will set linear velocity instead of directly set rigidbody's position.
  10015. !#zh
  10016. 同步节点的世界坐标到 box2d 刚体的坐标上。
  10017. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度来代替直接设置刚体的位置。
  10018. @param enableAnimated enableAnimated
  10019. */
  10020. syncPosition(enableAnimated: boolean): void;
  10021. /**
  10022. !#en
  10023. Synchronize node's world angle to box2d rigidbody's angle.
  10024. If enableAnimated is true and rigidbody's type is Animated type,
  10025. will set angular velocity instead of directly set rigidbody's angle.
  10026. !#zh
  10027. 同步节点的世界旋转角度值到 box2d 刚体的旋转值上。
  10028. 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度来代替直接设置刚体的角度。
  10029. @param enableAnimated enableAnimated
  10030. */
  10031. syncRotation(enableAnimated: boolean): void;
  10032. }
  10033. /** !#en Key map for keyboard event
  10034. !#zh 键盘事件的按键值 */
  10035. export enum KEY {
  10036. none = 0,
  10037. back = 0,
  10038. menu = 0,
  10039. backspace = 0,
  10040. tab = 0,
  10041. enter = 0,
  10042. shift = 0,
  10043. ctrl = 0,
  10044. alt = 0,
  10045. pause = 0,
  10046. capslock = 0,
  10047. escape = 0,
  10048. space = 0,
  10049. pageup = 0,
  10050. pagedown = 0,
  10051. end = 0,
  10052. home = 0,
  10053. left = 0,
  10054. up = 0,
  10055. right = 0,
  10056. down = 0,
  10057. select = 0,
  10058. insert = 0,
  10059. Delete = 0,
  10060. a = 0,
  10061. b = 0,
  10062. c = 0,
  10063. d = 0,
  10064. e = 0,
  10065. f = 0,
  10066. g = 0,
  10067. h = 0,
  10068. i = 0,
  10069. j = 0,
  10070. k = 0,
  10071. l = 0,
  10072. m = 0,
  10073. n = 0,
  10074. o = 0,
  10075. p = 0,
  10076. q = 0,
  10077. r = 0,
  10078. s = 0,
  10079. t = 0,
  10080. u = 0,
  10081. v = 0,
  10082. w = 0,
  10083. x = 0,
  10084. y = 0,
  10085. z = 0,
  10086. num0 = 0,
  10087. num1 = 0,
  10088. num2 = 0,
  10089. num3 = 0,
  10090. num4 = 0,
  10091. num5 = 0,
  10092. num6 = 0,
  10093. num7 = 0,
  10094. num8 = 0,
  10095. num9 = 0,
  10096. '*' = 0,
  10097. '+' = 0,
  10098. '-' = 0,
  10099. numdel = 0,
  10100. '/' = 0,
  10101. f1 = 0,
  10102. f2 = 0,
  10103. f3 = 0,
  10104. f4 = 0,
  10105. f5 = 0,
  10106. f6 = 0,
  10107. f7 = 0,
  10108. f8 = 0,
  10109. f9 = 0,
  10110. f10 = 0,
  10111. f11 = 0,
  10112. f12 = 0,
  10113. numlock = 0,
  10114. scrolllock = 0,
  10115. ';' = 0,
  10116. semicolon = 0,
  10117. equal = 0,
  10118. '=' = 0,
  10119. ',' = 0,
  10120. comma = 0,
  10121. dash = 0,
  10122. '.' = 0,
  10123. period = 0,
  10124. forwardslash = 0,
  10125. grave = 0,
  10126. '[' = 0,
  10127. openbracket = 0,
  10128. backslash = 0,
  10129. ']' = 0,
  10130. closebracket = 0,
  10131. quote = 0,
  10132. dpadLeft = 0,
  10133. dpadRight = 0,
  10134. dpadUp = 0,
  10135. dpadDown = 0,
  10136. dpadCenter = 0,
  10137. }
  10138. /** Image formats */
  10139. export enum ImageFormat {
  10140. JPG = 0,
  10141. PNG = 0,
  10142. TIFF = 0,
  10143. WEBP = 0,
  10144. PVR = 0,
  10145. ETC = 0,
  10146. S3TC = 0,
  10147. ATITC = 0,
  10148. TGA = 0,
  10149. RAWDATA = 0,
  10150. UNKNOWN = 0,
  10151. getImageFormatByData = 0,
  10152. }
  10153. /** Predefined constants */
  10154. export enum macro {
  10155. INVALID_INDEX = 0,
  10156. NODE_TAG_INVALID = 0,
  10157. PI = 0,
  10158. PI2 = 0,
  10159. FLT_MAX = 0,
  10160. FLT_MIN = 0,
  10161. RAD = 0,
  10162. DEG = 0,
  10163. UINT_MAX = 0,
  10164. REPEAT_FOREVER = 0,
  10165. FLT_EPSILON = 0,
  10166. ONE = 0,
  10167. ZERO = 0,
  10168. SRC_ALPHA = 0,
  10169. SRC_ALPHA_SATURATE = 0,
  10170. SRC_COLOR = 0,
  10171. DST_ALPHA = 0,
  10172. DST_COLOR = 0,
  10173. ONE_MINUS_SRC_ALPHA = 0,
  10174. ONE_MINUS_SRC_COLOR = 0,
  10175. ONE_MINUS_DST_ALPHA = 0,
  10176. ONE_MINUS_DST_COLOR = 0,
  10177. ONE_MINUS_CONSTANT_ALPHA = 0,
  10178. ONE_MINUS_CONSTANT_COLOR = 0,
  10179. LINEAR = 0,
  10180. BLEND_DST = 0,
  10181. WEB_ORIENTATION_PORTRAIT = 0,
  10182. WEB_ORIENTATION_LANDSCAPE_LEFT = 0,
  10183. WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 0,
  10184. WEB_ORIENTATION_LANDSCAPE_RIGHT = 0,
  10185. ORIENTATION_PORTRAIT = 0,
  10186. ORIENTATION_LANDSCAPE = 0,
  10187. ORIENTATION_AUTO = 0,
  10188. VERTEX_ATTRIB_FLAG_NONE = 0,
  10189. VERTEX_ATTRIB_FLAG_POSITION = 0,
  10190. VERTEX_ATTRIB_FLAG_COLOR = 0,
  10191. VERTEX_ATTRIB_FLAG_TEX_COORDS = 0,
  10192. VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0,
  10193. GL_ALL = 0,
  10194. VERTEX_ATTRIB_POSITION = 0,
  10195. VERTEX_ATTRIB_COLOR = 0,
  10196. VERTEX_ATTRIB_TEX_COORDS = 0,
  10197. VERTEX_ATTRIB_MAX = 0,
  10198. UNIFORM_PMATRIX = 0,
  10199. UNIFORM_MVMATRIX = 0,
  10200. UNIFORM_MVPMATRIX = 0,
  10201. UNIFORM_TIME = 0,
  10202. UNIFORM_SINTIME = 0,
  10203. UNIFORM_COSTIME = 0,
  10204. UNIFORM_RANDOM01 = 0,
  10205. UNIFORM_SAMPLER = 0,
  10206. UNIFORM_MAX = 0,
  10207. SHADER_POSITION_TEXTURECOLOR = 0,
  10208. SHADER_SPRITE_POSITION_TEXTURECOLOR = 0,
  10209. SHADER_POSITION_TEXTURECOLORALPHATEST = 0,
  10210. SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST = 0,
  10211. SHADER_POSITION_COLOR = 0,
  10212. SHADER_SPRITE_POSITION_COLOR = 0,
  10213. SHADER_POSITION_TEXTURE = 0,
  10214. SHADER_POSITION_TEXTURE_UCOLOR = 0,
  10215. SHADER_POSITION_TEXTUREA8COLOR = 0,
  10216. SHADER_POSITION_UCOLOR = 0,
  10217. SHADER_POSITION_LENGTHTEXTURECOLOR = 0,
  10218. UNIFORM_PMATRIX_S = 0,
  10219. UNIFORM_MVMATRIX_S = 0,
  10220. UNIFORM_MVPMATRIX_S = 0,
  10221. UNIFORM_TIME_S = 0,
  10222. UNIFORM_SINTIME_S = 0,
  10223. UNIFORM_COSTIME_S = 0,
  10224. UNIFORM_RANDOM01_S = 0,
  10225. UNIFORM_SAMPLER_S = 0,
  10226. UNIFORM_ALPHA_TEST_VALUE_S = 0,
  10227. ATTRIBUTE_NAME_COLOR = 0,
  10228. ATTRIBUTE_NAME_POSITION = 0,
  10229. ATTRIBUTE_NAME_TEX_COORD = 0,
  10230. ITEM_SIZE = 0,
  10231. CURRENT_ITEM = 0,
  10232. ZOOM_ACTION_TAG = 0,
  10233. NORMAL_TAG = 0,
  10234. SELECTED_TAG = 0,
  10235. DISABLE_TAG = 0,
  10236. FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0,
  10237. FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX = 0,
  10238. DIRECTOR_STATS_POSITION = 0,
  10239. DIRECTOR_FPS_INTERVAL = 0,
  10240. COCOSNODE_RENDER_SUBPIXEL = 0,
  10241. SPRITEBATCHNODE_RENDER_SUBPIXEL = 0,
  10242. AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0,
  10243. OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0,
  10244. TEXTURE_NPOT_SUPPORT = 0,
  10245. USE_LA88_LABELS = 0,
  10246. SPRITE_DEBUG_DRAW = 0,
  10247. LABELBMFONT_DEBUG_DRAW = 0,
  10248. LABELATLAS_DEBUG_DRAW = 0,
  10249. ENABLE_STACKABLE_ACTIONS = 0,
  10250. ENABLE_GL_STATE_CACHE = 0,
  10251. TOUCH_TIMEOUT = 0,
  10252. BATCH_VERTEX_COUNT = 0,
  10253. ENABLE_GC_FOR_NATIVE_OBJECTS = 0,
  10254. ENABLE_TILEDMAP_CULLING = 0,
  10255. DOWNLOAD_MAX_CONCURRENT = 0,
  10256. ENABLE_TRANSPARENT_CANVAS = 0,
  10257. ENABLE_WEBGL_ANTIALIAS = 0,
  10258. ENABLE_CULLING = 0,
  10259. BLEND_SRC = 0,
  10260. }
  10261. /** The base class of most of all the objects in Fireball. */
  10262. export class Object {
  10263. /** !#en The name of the object.
  10264. !#zh 该对象的名称。 */
  10265. name: string;
  10266. /** !#en
  10267. Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)<br>
  10268. When an object's `destroy` is called, it is actually destroyed after the end of this frame.
  10269. So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
  10270. If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
  10271. but this is often caused by a particular logical requirements, which is not normally required.
  10272. !#zh
  10273. 表示该对象是否可用(被 destroy 后将不可用)。<br>
  10274. 当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。 */
  10275. isValid: boolean;
  10276. /**
  10277. !#en
  10278. Destroy this Object, and release all its own references to other objects.<br/>
  10279. Actual object destruction will delayed until before rendering.
  10280. From the next frame, this object is not usable any more.
  10281. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  10282. !#zh
  10283. 销毁该对象,并释放所有它对其它对象的引用。<br/>
  10284. 实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。
  10285. 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  10286. @example
  10287. ```js
  10288. obj.destroy();
  10289. ```
  10290. */
  10291. destroy(): boolean;
  10292. }
  10293. /** Bit mask that controls object states. */
  10294. export enum Flags {
  10295. DontSave = 0,
  10296. EditorOnly = 0,
  10297. }
  10298. /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
  10299. It's invalid on safari, QQbrowser and android browser */
  10300. export class screen {
  10301. /**
  10302. initialize
  10303. */
  10304. init(): void;
  10305. /**
  10306. return true if it's full now.
  10307. */
  10308. fullScreen(): boolean;
  10309. /**
  10310. change the screen to full mode.
  10311. @param element element
  10312. @param onFullScreenChange onFullScreenChange
  10313. */
  10314. requestFullScreen(element: Element, onFullScreenChange: Function): void;
  10315. /**
  10316. exit the full mode.
  10317. */
  10318. exitFullScreen(): boolean;
  10319. /**
  10320. Automatically request full screen with a touch/click event
  10321. @param element element
  10322. @param onFullScreenChange onFullScreenChange
  10323. */
  10324. autoFullScreen(element: Element, onFullScreenChange: Function): void;
  10325. }
  10326. /** System variables */
  10327. export class sys {
  10328. /** English language code */
  10329. static LANGUAGE_ENGLISH: string;
  10330. /** Chinese language code */
  10331. static LANGUAGE_CHINESE: string;
  10332. /** French language code */
  10333. static LANGUAGE_FRENCH: string;
  10334. /** Italian language code */
  10335. static LANGUAGE_ITALIAN: string;
  10336. /** German language code */
  10337. static LANGUAGE_GERMAN: string;
  10338. /** Spanish language code */
  10339. static LANGUAGE_SPANISH: string;
  10340. /** Spanish language code */
  10341. static LANGUAGE_DUTCH: string;
  10342. /** Russian language code */
  10343. static LANGUAGE_RUSSIAN: string;
  10344. /** Korean language code */
  10345. static LANGUAGE_KOREAN: string;
  10346. /** Japanese language code */
  10347. static LANGUAGE_JAPANESE: string;
  10348. /** Hungarian language code */
  10349. static LANGUAGE_HUNGARIAN: string;
  10350. /** Portuguese language code */
  10351. static LANGUAGE_PORTUGUESE: string;
  10352. /** Arabic language code */
  10353. static LANGUAGE_ARABIC: string;
  10354. /** Norwegian language code */
  10355. static LANGUAGE_NORWEGIAN: string;
  10356. /** Polish language code */
  10357. static LANGUAGE_POLISH: string;
  10358. /** Turkish language code */
  10359. static LANGUAGE_TURKISH: string;
  10360. /** Ukrainian language code */
  10361. static LANGUAGE_UKRAINIAN: string;
  10362. /** Romanian language code */
  10363. static LANGUAGE_ROMANIAN: string;
  10364. /** Bulgarian language code */
  10365. static LANGUAGE_BULGARIAN: string;
  10366. /** Unknown language code */
  10367. static LANGUAGE_UNKNOWN: string;
  10368. static OS_IOS: string;
  10369. static OS_ANDROID: string;
  10370. static OS_WINDOWS: string;
  10371. static OS_MARMALADE: string;
  10372. static OS_LINUX: string;
  10373. static OS_BADA: string;
  10374. static OS_BLACKBERRY: string;
  10375. static OS_OSX: string;
  10376. static OS_WP8: string;
  10377. static OS_WINRT: string;
  10378. static OS_UNKNOWN: string;
  10379. static UNKNOWN: number;
  10380. static WIN32: number;
  10381. static LINUX: number;
  10382. static MACOS: number;
  10383. static ANDROID: number;
  10384. static IPHONE: number;
  10385. static IPAD: number;
  10386. static BLACKBERRY: number;
  10387. static NACL: number;
  10388. static EMSCRIPTEN: number;
  10389. static TIZEN: number;
  10390. static WINRT: number;
  10391. static WP8: number;
  10392. static MOBILE_BROWSER: number;
  10393. static DESKTOP_BROWSER: number;
  10394. /** Indicates whether executes in editor's window process (Electron's renderer context) */
  10395. static EDITOR_PAGE: number;
  10396. /** Indicates whether executes in editor's main process (Electron's browser context) */
  10397. static EDITOR_CORE: number;
  10398. static WECHAT_GAME: number;
  10399. static QQ_PLAY: number;
  10400. /** BROWSER_TYPE_WECHAT */
  10401. static BROWSER_TYPE_WECHAT: string;
  10402. /** BROWSER_TYPE_WECHAT_GAME */
  10403. static BROWSER_TYPE_WECHAT_GAME: string;
  10404. /** BROWSER_TYPE_QQ_PLAY */
  10405. static BROWSER_TYPE_QQ_PLAY: string;
  10406. static BROWSER_TYPE_ANDROID: string;
  10407. static BROWSER_TYPE_IE: string;
  10408. static BROWSER_TYPE_QQ: string;
  10409. static BROWSER_TYPE_MOBILE_QQ: string;
  10410. static BROWSER_TYPE_UC: string;
  10411. /** uc third party integration. */
  10412. static BROWSER_TYPE_UCBS: string;
  10413. static BROWSER_TYPE_360: string;
  10414. static BROWSER_TYPE_BAIDU_APP: string;
  10415. static BROWSER_TYPE_BAIDU: string;
  10416. static BROWSER_TYPE_MAXTHON: string;
  10417. static BROWSER_TYPE_OPERA: string;
  10418. static BROWSER_TYPE_OUPENG: string;
  10419. static BROWSER_TYPE_MIUI: string;
  10420. static BROWSER_TYPE_FIREFOX: string;
  10421. static BROWSER_TYPE_SAFARI: string;
  10422. static BROWSER_TYPE_CHROME: string;
  10423. static BROWSER_TYPE_LIEBAO: string;
  10424. static BROWSER_TYPE_QZONE: string;
  10425. static BROWSER_TYPE_SOUGOU: string;
  10426. static BROWSER_TYPE_UNKNOWN: string;
  10427. /**
  10428. !#en
  10429. Get the battery level of current device, return 1.0 if failure.
  10430. !#zh
  10431. 获取当前设备的电池电量,如果电量无法获取,默认将返回 1
  10432. */
  10433. static getBatteryLevel(): number;
  10434. /**
  10435. !#en
  10436. Get the network type of current device, return cc.sys.NetworkType.LAN if failure.
  10437. !#zh
  10438. 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 cc.sys.NetworkType.LAN
  10439. */
  10440. static getNetworkType(): NetworkType;
  10441. /** Is native ? This is set to be true in jsb auto. */
  10442. static isNative: boolean;
  10443. /** Is web browser ? */
  10444. static isBrowser: boolean;
  10445. /** Indicate whether system is mobile system */
  10446. static isMobile: boolean;
  10447. /** Indicate the running platform */
  10448. static platform: number;
  10449. /** Indicate the current language of the running system */
  10450. static language: string;
  10451. /** Indicate the running os name */
  10452. static os: string;
  10453. /** Indicate the running os version */
  10454. static osVersion: string;
  10455. /** Indicate the running os main version */
  10456. static osMainVersion: number;
  10457. /** Indicate the running browser type */
  10458. static browserType: string;
  10459. /** Indicate the running browser version */
  10460. static browserVersion: string;
  10461. /** Indicate the real pixel resolution of the whole game window */
  10462. static windowPixelResolution: Size;
  10463. /** cc.sys.localStorage is a local storage component. */
  10464. static localStorage: any;
  10465. /** The capabilities of the current platform */
  10466. static capabilities: any;
  10467. /**
  10468. Forces the garbage collection, only available in JSB
  10469. */
  10470. static garbageCollect(): void;
  10471. /**
  10472. Dumps rooted objects, only available in JSB
  10473. */
  10474. static dumpRoot(): void;
  10475. /**
  10476. Restart the JS VM, only available in JSB
  10477. */
  10478. static restartVM(): void;
  10479. /**
  10480. Clean a script in the JS VM, only available in JSB
  10481. @param jsfile jsfile
  10482. */
  10483. static cleanScript(jsfile: string): void;
  10484. /**
  10485. Check whether an object is valid,
  10486. In web engine, it will return true if the object exist
  10487. In native engine, it will return true if the JS object and the correspond native object are both valid
  10488. @param obj obj
  10489. */
  10490. static isObjectValid(obj: any): boolean;
  10491. /**
  10492. Dump system informations
  10493. */
  10494. static dump(): void;
  10495. /**
  10496. Open a url in browser
  10497. @param url url
  10498. */
  10499. static openURL(url: string): void;
  10500. /**
  10501. Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  10502. */
  10503. static now(): number;
  10504. }
  10505. /** !#en
  10506. Network type enumeration
  10507. !#zh
  10508. 网络类型枚举 */
  10509. export enum NetworkType {
  10510. NONE = 0,
  10511. LAN = 0,
  10512. WWAN = 0,
  10513. }
  10514. /** cc.view is the singleton object which represents the game window.<br/>
  10515. It's main task include: <br/>
  10516. - Apply the design resolution policy<br/>
  10517. - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
  10518. - Manage the game view port which can be different with the window<br/>
  10519. - Manage the content scale and translation<br/>
  10520. <br/>
  10521. Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
  10522. the standard way to use it is by calling:<br/>
  10523. - cc.view.methodName(); <br/> */
  10524. export class View {
  10525. /**
  10526. <p>
  10527. Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
  10528. 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
  10529. 2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
  10530. 3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
  10531. 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
  10532. 5. Custom value, e.g: "480" <br/>
  10533. </p>
  10534. @param densityDPI densityDPI
  10535. */
  10536. setTargetDensityDPI(densityDPI: string): void;
  10537. /**
  10538. Returns the current target-densitydpi value of cc.view.
  10539. */
  10540. getTargetDensityDPI(): string;
  10541. /**
  10542. Sets whether resize canvas automatically when browser's size changed.<br/>
  10543. Useful only on web.
  10544. @param enabled Whether enable automatic resize with browser's resize event
  10545. */
  10546. resizeWithBrowserSize(enabled: boolean): void;
  10547. /**
  10548. Sets the callback function for cc.view's resize action,<br/>
  10549. this callback will be invoked before applying resolution policy, <br/>
  10550. so you can do any additional modifications within the callback.<br/>
  10551. Useful only on web.
  10552. @param callback The callback function
  10553. */
  10554. setResizeCallback(callback: Function|void): void;
  10555. /**
  10556. Sets the orientation of the game, it can be landscape, portrait or auto.
  10557. When set it to landscape or portrait, and screen w/h ratio doesn't fit,
  10558. cc.view will automatically rotate the game canvas using CSS.
  10559. Note that this function doesn't have any effect in native,
  10560. in native, you need to set the application orientation in native project settings
  10561. @param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
  10562. */
  10563. setOrientation(orientation: number): void;
  10564. /**
  10565. Sets whether the engine modify the "viewport" meta in your web page.<br/>
  10566. It's enabled by default, we strongly suggest you not to disable it.<br/>
  10567. And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
  10568. Only useful on web
  10569. @param enabled Enable automatic modification to "viewport" meta
  10570. */
  10571. adjustViewPort(enabled: boolean): void;
  10572. /**
  10573. Retina support is enabled by default for Apple device but disabled for other devices,<br/>
  10574. it takes effect only when you called setDesignResolutionPolicy<br/>
  10575. Only useful on web
  10576. @param enabled Enable or disable retina display
  10577. */
  10578. enableRetina(enabled: boolean): void;
  10579. /**
  10580. Check whether retina display is enabled.<br/>
  10581. Only useful on web
  10582. */
  10583. isRetinaEnabled(): boolean;
  10584. /**
  10585. !#en Whether to Enable on anti-alias
  10586. !#zh 控制抗锯齿是否开启
  10587. @param enabled Enable or not anti-alias
  10588. */
  10589. enableAntiAlias(enabled: boolean): void;
  10590. /**
  10591. !#en Returns whether the current enable on anti-alias
  10592. !#zh 返回当前是否抗锯齿
  10593. */
  10594. isAntiAliasEnabled(): boolean;
  10595. /**
  10596. If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
  10597. You can pass true as parameter to enable it and disable it by passing false.<br/>
  10598. Only useful on web
  10599. @param enabled Enable or disable auto full screen on mobile devices
  10600. */
  10601. enableAutoFullScreen(enabled: boolean): void;
  10602. /**
  10603. Check whether auto full screen is enabled.<br/>
  10604. Only useful on web
  10605. */
  10606. isAutoFullScreenEnabled(): boolean;
  10607. /**
  10608. Get whether render system is ready(no matter opengl or canvas),<br/>
  10609. this name is for the compatibility with cocos2d-x, subclass must implement this method.
  10610. */
  10611. isViewReady(): boolean;
  10612. /**
  10613. Sets the resolution translate on View.
  10614. @param offsetLeft offsetLeft
  10615. @param offsetTop offsetTop
  10616. */
  10617. setContentTranslateLeftTop(offsetLeft: number, offsetTop: number): void;
  10618. /**
  10619. Returns the resolution translate on View
  10620. */
  10621. getContentTranslateLeftTop(): Size;
  10622. /**
  10623. Returns the frame size of the view.<br/>
  10624. On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
  10625. On web, it returns the size of the canvas's outer DOM element.
  10626. */
  10627. getFrameSize(): Size;
  10628. /**
  10629. On native, it sets the frame size of view.<br/>
  10630. On web, it sets the size of the canvas's outer DOM element.
  10631. @param width width
  10632. @param height height
  10633. */
  10634. setFrameSize(width: number, height: number): void;
  10635. /**
  10636. Returns the visible area size of the view port.
  10637. */
  10638. getVisibleSize(): Size;
  10639. /**
  10640. Returns the visible area size of the view port.
  10641. */
  10642. getVisibleSizeInPixel(): Size;
  10643. /**
  10644. Returns the visible origin of the view port.
  10645. */
  10646. getVisibleOrigin(): Vec2;
  10647. /**
  10648. Returns the visible origin of the view port.
  10649. */
  10650. getVisibleOriginInPixel(): Vec2;
  10651. /**
  10652. Returns whether developer can set content's scale factor.
  10653. */
  10654. canSetContentScaleFactor(): boolean;
  10655. /**
  10656. Returns the current resolution policy
  10657. */
  10658. getResolutionPolicy(): ResolutionPolicy;
  10659. /**
  10660. Sets the current resolution policy
  10661. @param resolutionPolicy resolutionPolicy
  10662. */
  10663. setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
  10664. /**
  10665. Sets the resolution policy with designed view size in points.<br/>
  10666. The resolution policy include: <br/>
  10667. [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.<br/>
  10668. [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.<br/>
  10669. [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.<br/>
  10670. [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
  10671. [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
  10672. [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
  10673. @param width Design resolution width.
  10674. @param height Design resolution height.
  10675. @param resolutionPolicy The resolution policy desired
  10676. */
  10677. setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10678. /**
  10679. Returns the designed size for the view.
  10680. Default resolution size is the same as 'getFrameSize'.
  10681. */
  10682. getDesignResolutionSize(): Size;
  10683. /**
  10684. Sets the container to desired pixel resolution and fit the game content to it.
  10685. This function is very useful for adaptation in mobile browsers.
  10686. In some HD android devices, the resolution is very high, but its browser performance may not be very good.
  10687. In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
  10688. But this API can be helpful to set a desired pixel resolution which is in between.
  10689. This API will do the following:
  10690. 1. Set viewport's width to the desired width in pixel
  10691. 2. Set body width to the exact pixel resolution
  10692. 3. The resolution policy will be reset with designed view size in points.
  10693. @param width Design resolution width.
  10694. @param height Design resolution height.
  10695. @param resolutionPolicy The resolution policy desired
  10696. */
  10697. setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
  10698. /**
  10699. Sets view port rectangle with points.
  10700. @param x x
  10701. @param y y
  10702. @param w width
  10703. @param h height
  10704. */
  10705. setViewPortInPoints(x: number, y: number, w: number, h: number): void;
  10706. /**
  10707. Sets Scissor rectangle with points.
  10708. @param x x
  10709. @param y y
  10710. @param w w
  10711. @param h h
  10712. */
  10713. setScissorInPoints(x: number, y: number, w: number, h: number): void;
  10714. /**
  10715. Returns whether GL_SCISSOR_TEST is enable
  10716. */
  10717. isScissorEnabled(): boolean;
  10718. /**
  10719. Returns the current scissor rectangle
  10720. */
  10721. getScissorRect(): Rect;
  10722. /**
  10723. Sets the name of the view
  10724. @param viewName viewName
  10725. */
  10726. setViewName(viewName: string): void;
  10727. /**
  10728. Returns the name of the view
  10729. */
  10730. getViewName(): string;
  10731. /**
  10732. Returns the view port rectangle.
  10733. */
  10734. getViewPortRect(): Rect;
  10735. /**
  10736. Returns scale factor of the horizontal direction (X axis).
  10737. */
  10738. getScaleX(): number;
  10739. /**
  10740. Returns scale factor of the vertical direction (Y axis).
  10741. */
  10742. getScaleY(): number;
  10743. /**
  10744. Returns device pixel ratio for retina display.
  10745. */
  10746. getDevicePixelRatio(): number;
  10747. /**
  10748. Returns the real location in view for a translation based on a related position
  10749. @param tx The X axis translation
  10750. @param ty The Y axis translation
  10751. @param relatedPos The related position object including "left", "top", "width", "height" informations
  10752. */
  10753. convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
  10754. }
  10755. /** <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
  10756. it controls the behavior of how to scale the cc.container and cc.game.canvas object</p> */
  10757. export class ContainerStrategy {
  10758. /**
  10759. Manipulation before appling the strategy
  10760. @param view The target view
  10761. */
  10762. preApply(view: View): void;
  10763. /**
  10764. Function to apply this strategy
  10765. @param view view
  10766. @param designedResolution designedResolution
  10767. */
  10768. apply(view: View, designedResolution: Size): void;
  10769. /**
  10770. Manipulation after applying the strategy
  10771. @param view The target view
  10772. */
  10773. postApply(view: View): void;
  10774. }
  10775. /** <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
  10776. it controls the behavior of how to scale the scene and setup the viewport for the game</p> */
  10777. export class ContentStrategy {
  10778. /**
  10779. Manipulation before applying the strategy
  10780. @param view The target view
  10781. */
  10782. preApply(view: View): void;
  10783. /**
  10784. Function to apply this strategy
  10785. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10786. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10787. @param view view
  10788. @param designedResolution designedResolution
  10789. */
  10790. apply(view: View, designedResolution: Size): any;
  10791. /**
  10792. Manipulation after applying the strategy
  10793. @param view The target view
  10794. */
  10795. postApply(view: View): void;
  10796. }
  10797. /** undefined */
  10798. export class EqualToFrame extends ContainerStrategy {
  10799. }
  10800. /** undefined */
  10801. export class ProportionalToFrame extends ContainerStrategy {
  10802. }
  10803. /** undefined */
  10804. export class EqualToWindow extends EqualToFrame {
  10805. }
  10806. /** undefined */
  10807. export class ProportionalToWindow extends ProportionalToFrame {
  10808. }
  10809. /** undefined */
  10810. export class OriginalContainer extends ContainerStrategy {
  10811. }
  10812. /** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
  10813. its main task is to maintain the compatibility with Cocos2d-x</p> */
  10814. export class ResolutionPolicy {
  10815. /**
  10816. @param containerStg The container strategy
  10817. @param contentStg The content strategy
  10818. */
  10819. constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
  10820. /**
  10821. Manipulation before applying the resolution policy
  10822. @param view The target view
  10823. */
  10824. preApply(view: View): void;
  10825. /**
  10826. Function to apply this resolution policy
  10827. The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
  10828. The target view can then apply these value to itself, it's preferred not to modify directly its private variables
  10829. @param view The target view
  10830. @param designedResolution The user defined design resolution
  10831. */
  10832. apply(view: View, designedResolution: Size): any;
  10833. /**
  10834. Manipulation after appyling the strategy
  10835. @param view The target view
  10836. */
  10837. postApply(view: View): void;
  10838. /**
  10839. Setup the container's scale strategy
  10840. @param containerStg containerStg
  10841. */
  10842. setContainerStrategy(containerStg: ContainerStrategy): void;
  10843. /**
  10844. Setup the content's scale strategy
  10845. @param contentStg contentStg
  10846. */
  10847. setContentStrategy(contentStg: ContentStrategy): void;
  10848. /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
  10849. Distortion can occur, and the application may appear stretched or compressed. */
  10850. static EXACT_FIT: number;
  10851. /** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
  10852. while maintaining the original aspect ratio of the application. */
  10853. static NO_BORDER: number;
  10854. /** The entire application is visible in the specified area without distortion while maintaining the original<br/>
  10855. aspect ratio of the application. Borders can appear on two sides of the application. */
  10856. static SHOW_ALL: number;
  10857. /** The application takes the height of the design resolution size and modifies the width of the internal<br/>
  10858. canvas so that it fits the aspect ratio of the device<br/>
  10859. no distortion will occur however you must make sure your application works on different<br/>
  10860. aspect ratios */
  10861. static FIXED_HEIGHT: number;
  10862. /** The application takes the width of the design resolution size and modifies the height of the internal<br/>
  10863. canvas so that it fits the aspect ratio of the device<br/>
  10864. no distortion will occur however you must make sure your application works on different<br/>
  10865. aspect ratios */
  10866. static FIXED_WIDTH: number;
  10867. /** Unknow policy */
  10868. static UNKNOWN: number;
  10869. }
  10870. /** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
  10871. it should represent the same rect as cc.view.getViewportRect() */
  10872. export class visibleRect {
  10873. /**
  10874. initialize
  10875. @param visibleRect visibleRect
  10876. */
  10877. init(visibleRect: Rect): void;
  10878. /** Top left coordinate of the screen related to the game scene. */
  10879. topLeft: Vec2;
  10880. /** Top right coordinate of the screen related to the game scene. */
  10881. topRight: Vec2;
  10882. /** Top center coordinate of the screen related to the game scene. */
  10883. top: Vec2;
  10884. /** Bottom left coordinate of the screen related to the game scene. */
  10885. bottomLeft: Vec2;
  10886. /** Bottom right coordinate of the screen related to the game scene. */
  10887. bottomRight: Vec2;
  10888. /** Bottom center coordinate of the screen related to the game scene. */
  10889. bottom: Vec2;
  10890. /** Center coordinate of the screen related to the game scene. */
  10891. center: Vec2;
  10892. /** Left center coordinate of the screen related to the game scene. */
  10893. left: Vec2;
  10894. /** Right center coordinate of the screen related to the game scene. */
  10895. right: Vec2;
  10896. /** Width of the screen. */
  10897. width: number;
  10898. /** Height of the screen. */
  10899. height: number;
  10900. }
  10901. /** The CallbacksHandler is an abstract class that can register and unregister callbacks by key.
  10902. Subclasses should implement their own methods about how to invoke the callbacks. */
  10903. export class _CallbacksHandler {
  10904. /**
  10905. @param key key
  10906. @param callback callback
  10907. @param target can be null
  10908. */
  10909. add(key: string, callback: Function, target?: any): void;
  10910. /**
  10911. Check if the specified key has any registered callback. If a callback is also specified,
  10912. it will only return true if the callback is registered.
  10913. @param key key
  10914. @param callback callback
  10915. @param target target
  10916. */
  10917. has(key: string, callback?: Function, target?: any): boolean;
  10918. /**
  10919. Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
  10920. @param keyOrTarget The event key to be removed or the target to be removed
  10921. */
  10922. removeAll(keyOrTarget: string|any): void;
  10923. /**
  10924. @param key key
  10925. @param callback callback
  10926. @param target target
  10927. */
  10928. remove(key: string, callback: Function, target?: any): void;
  10929. }
  10930. /** !#en The callbacks invoker to handle and invoke callbacks by key.
  10931. !#zh CallbacksInvoker 用来根据 Key 管理并调用回调方法。 */
  10932. export class CallbacksInvoker extends _CallbacksHandler {
  10933. /**
  10934. @param key key
  10935. @param p1 p1
  10936. @param p2 p2
  10937. @param p3 p3
  10938. @param p4 p4
  10939. @param p5 p5
  10940. */
  10941. invoke(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any): void;
  10942. }
  10943. /** !#en Contains information collected during deserialization
  10944. !#zh 包含反序列化时的一些信息 */
  10945. export class Details {
  10946. /** list of the depends assets' uuid */
  10947. uuidList: string[];
  10948. /** the obj list whose field needs to load asset by uuid */
  10949. uuidObjList: any[];
  10950. /** the corresponding field name which referenced to the asset */
  10951. uuidPropList: string[];
  10952. reset(): void;
  10953. /**
  10954. @param obj obj
  10955. @param propName propName
  10956. @param uuid uuid
  10957. */
  10958. push(obj: any, propName: string, uuid: string): void;
  10959. }
  10960. /** undefined */
  10961. export class url {
  10962. /**
  10963. Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
  10964. @param url url
  10965. @example
  10966. ```js
  10967. ---
  10968. var url = cc.url.raw("textures/myTexture.png");
  10969. console.log(url); // "resources/raw/textures/myTexture.png"
  10970. ```
  10971. */
  10972. static raw(url: string): string;
  10973. }
  10974. /** !#en
  10975. A cc.SpriteFrame has:<br/>
  10976. - texture: A cc.Texture2D that will be used by the _ccsg.Sprite<br/>
  10977. - rectangle: A rectangle of the texture
  10978. !#zh
  10979. 一个 SpriteFrame 包含:<br/>
  10980. - 纹理:会被 Sprite 使用的 Texture2D 对象。<br/>
  10981. - 矩形:在纹理中的矩形区域。 */
  10982. export class SpriteFrame extends Asset implements EventTarget {
  10983. /**
  10984. !#en
  10985. Constructor of SpriteFrame class.
  10986. !#zh
  10987. SpriteFrame 类的构造函数。
  10988. @param filename filename
  10989. @param rect rect
  10990. @param rotated Whether the frame is rotated in the texture
  10991. @param offset The offset of the frame in the texture
  10992. @param originalSize The size of the frame in the texture
  10993. */
  10994. constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
  10995. /** !#en Top border of the sprite
  10996. !#zh sprite 的顶部边框 */
  10997. insetTop: number;
  10998. /** !#en Bottom border of the sprite
  10999. !#zh sprite 的底部边框 */
  11000. insetBottom: number;
  11001. /** !#en Left border of the sprite
  11002. !#zh sprite 的左边边框 */
  11003. insetLeft: number;
  11004. /** !#en Right border of the sprite
  11005. !#zh sprite 的左边边框 */
  11006. insetRight: number;
  11007. /**
  11008. !#en Returns whether the texture have been loaded
  11009. !#zh 返回是否已加载纹理
  11010. */
  11011. textureLoaded(): boolean;
  11012. /**
  11013. Add a event listener for texture loaded event.
  11014. @param callback callback
  11015. @param target target
  11016. */
  11017. addLoadedEventListener(callback: Function, target: any): void;
  11018. /**
  11019. !#en Returns whether the sprite frame is rotated in the texture.
  11020. !#zh 获取 SpriteFrame 是否旋转
  11021. */
  11022. isRotated(): boolean;
  11023. /**
  11024. !#en Set whether the sprite frame is rotated in the texture.
  11025. !#zh 设置 SpriteFrame 是否旋转
  11026. @param bRotated bRotated
  11027. */
  11028. setRotated(bRotated: boolean): void;
  11029. /**
  11030. !#en Returns the rect of the sprite frame in the texture.
  11031. !#zh 获取 SpriteFrame 的纹理矩形区域
  11032. */
  11033. getRect(): Rect;
  11034. /**
  11035. !#en Sets the rect of the sprite frame in the texture.
  11036. !#zh 设置 SpriteFrame 的纹理矩形区域
  11037. @param rect rect
  11038. */
  11039. setRect(rect: Rect): void;
  11040. /**
  11041. !#en Returns the original size of the trimmed image.
  11042. !#zh 获取修剪前的原始大小
  11043. */
  11044. getOriginalSize(): Size;
  11045. /**
  11046. !#en Sets the original size of the trimmed image.
  11047. !#zh 设置修剪前的原始大小
  11048. @param size size
  11049. */
  11050. setOriginalSize(size: Size): void;
  11051. /**
  11052. !#en Returns the texture of the frame.
  11053. !#zh 获取使用的纹理实例
  11054. */
  11055. getTexture(): Texture2D;
  11056. /**
  11057. !#en Returns the offset of the frame in the texture.
  11058. !#zh 获取偏移量
  11059. */
  11060. getOffset(): Vec2;
  11061. /**
  11062. !#en Sets the offset of the frame in the texture.
  11063. !#zh 设置偏移量
  11064. @param offsets offsets
  11065. */
  11066. setOffset(offsets: Vec2): void;
  11067. /**
  11068. !#en Clone the sprite frame.
  11069. !#zh 克隆 SpriteFrame
  11070. */
  11071. clone(): SpriteFrame;
  11072. /**
  11073. !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
  11074. !#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame
  11075. @param textureOrTextureFile textureOrTextureFile
  11076. @param rect rect
  11077. @param rotated rotated
  11078. @param offset offset
  11079. @param originalSize originalSize
  11080. */
  11081. setTexture(textureOrTextureFile: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
  11082. /**
  11083. !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
  11084. associated by user's custom Components in the scene, will not preload automatically.
  11085. These textures will be load when Sprite component is going to render the SpriteFrames.
  11086. You can call this method if you want to load the texture early.
  11087. !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
  11088. 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
  11089. @example
  11090. ```js
  11091. if (spriteFrame.textureLoaded()) {
  11092. this._onSpriteFrameLoaded();
  11093. }
  11094. else {
  11095. spriteFrame.once('load', this._onSpriteFrameLoaded, this);
  11096. spriteFrame.ensureLoadTexture();
  11097. }
  11098. ```
  11099. */
  11100. ensureLoadTexture(): void;
  11101. /**
  11102. !#en
  11103. If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture.
  11104. !#zh
  11105. 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
  11106. @example
  11107. ```js
  11108. spriteFrame.clearTexture();
  11109. // when you need the SpriteFrame again...
  11110. spriteFrame.once('load', onSpriteFrameLoaded);
  11111. spriteFrame.ensureLoadTexture();
  11112. ```
  11113. */
  11114. clearTexture(): void;
  11115. /**
  11116. !#en
  11117. Register an callback of a specific event type on the EventTarget.
  11118. !#zh
  11119. 注册事件目标的特定事件类型回调。
  11120. @param type A string representing the event type to listen for.
  11121. @param callback The callback that will be invoked when the event is dispatched.
  11122. The callback is ignored if it is a duplicate (the callbacks are unique).
  11123. @param target The target (this object) to invoke the callback, can be null
  11124. @param useCapture When set to true, the capture argument prevents callback
  11125. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11126. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11127. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11128. @example
  11129. ```js
  11130. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11131. cc.log("this is callback");
  11132. }, node);
  11133. ```
  11134. */
  11135. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11136. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11137. /**
  11138. !#en
  11139. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11140. if only type is passed as parameter, all listeners registered with that type will be removed.
  11141. !#zh
  11142. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11143. @param type A string representing the event type being removed.
  11144. @param callback The callback to remove.
  11145. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11146. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11147. If not specified, useCapture defaults to false. If a callback was registered twice,
  11148. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11149. does not affect a non-capturing version of the same listener, and vice versa.
  11150. @example
  11151. ```js
  11152. // register touchEnd eventListener
  11153. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11154. cc.log("this is callback");
  11155. }, node);
  11156. // remove touch end event listener
  11157. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11158. // remove all touch end event listeners
  11159. node.off(cc.Node.EventType.TOUCH_END);
  11160. ```
  11161. */
  11162. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11163. /**
  11164. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11165. This is not for removing all listeners in the current event target,
  11166. and this is not for removing all listeners the target parameter have registered.
  11167. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11168. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11169. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11170. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11171. @param target The target to be searched for all related listeners
  11172. */
  11173. targetOff(target: any): void;
  11174. /**
  11175. !#en
  11176. Register an callback of a specific event type on the EventTarget,
  11177. the callback will remove itself after the first time it is triggered.
  11178. !#zh
  11179. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11180. @param type A string representing the event type to listen for.
  11181. @param callback The callback that will be invoked when the event is dispatched.
  11182. The callback is ignored if it is a duplicate (the callbacks are unique).
  11183. @param target The target (this object) to invoke the callback, can be null
  11184. @param useCapture When set to true, the capture argument prevents callback
  11185. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11186. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11187. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11188. @example
  11189. ```js
  11190. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11191. cc.log("this is callback");
  11192. }, node);
  11193. ```
  11194. */
  11195. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11196. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11197. /**
  11198. !#en
  11199. Dispatches an event into the event flow.
  11200. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11201. !#zh 分发事件到事件流中。
  11202. @param event The Event object that is dispatched into the event flow
  11203. */
  11204. dispatchEvent(event: Event): void;
  11205. /**
  11206. !#en
  11207. Send an event to this object directly, this method will not propagate the event to any other objects.
  11208. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11209. !#zh
  11210. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11211. @param message the message to send
  11212. @param detail whatever argument the message needs
  11213. */
  11214. emit(message: string, detail?: any): void;
  11215. }
  11216. /** This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data.<br/>
  11217. The created cc.Texture2D object will always have power-of-two dimensions.<br/>
  11218. Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
  11219. i.e. "contentSize" != (pixelsWidth, pixelsHight) and (maxS, maxT) != (1.0, 1.0).<br/>
  11220. Be aware that the content of the generated textures will be upside-down! */
  11221. export class Texture2D extends Asset implements EventTarget {
  11222. /** !#en
  11223. The url of the texture, this could be empty if the texture wasn't created via a file.
  11224. !#zh
  11225. 贴图文件的 url,当贴图不是由文件创建时值可能为空 */
  11226. url: string;
  11227. /** !#en
  11228. Texture width in pixel
  11229. !#zh
  11230. 贴图像素宽度 */
  11231. width: number;
  11232. /** !#en
  11233. Texture height in pixel
  11234. !#zh
  11235. 贴图像素高度 */
  11236. height: number;
  11237. /**
  11238. Update texture options, not available in Canvas render mode.
  11239. image, format, premultiplyAlpha can not be updated in native.
  11240. @param options options
  11241. */
  11242. update(options: {image: DOMImageElement; mipmap: boolean; format: PixelFormat; minFilter: Filter; magFilter: Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
  11243. /**
  11244. Get width in pixels.
  11245. */
  11246. getPixelWidth(): number;
  11247. /**
  11248. Get height of in pixels.
  11249. */
  11250. getPixelHeight(): number;
  11251. /**
  11252. Get content size.
  11253. */
  11254. getContentSize(): Size;
  11255. /**
  11256. Get content size in pixels.
  11257. */
  11258. getContentSizeInPixels(): Size;
  11259. /**
  11260. Init with HTML element.
  11261. @param element element
  11262. @example
  11263. ```js
  11264. var img = new Image();
  11265. img.src = dataURL;
  11266. texture.initWithElement(img);
  11267. texture.handleLoadedTexture();
  11268. ```
  11269. */
  11270. initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
  11271. /**
  11272. Intializes with a texture2d with data.
  11273. @param data data
  11274. @param pixelFormat pixelFormat
  11275. @param pixelsWidth pixelsWidth
  11276. @param pixelsHeight pixelsHeight
  11277. @param contentSize contentSize is deprecated and ignored
  11278. */
  11279. initWithData(data: TypedArray, pixelFormat: number, pixelsWidth: number, pixelsHeight: number, contentSize: Size): boolean;
  11280. /**
  11281. Initializes a texture from a UIImage object.
  11282. Extensions to make it easy to create a CCTexture2D object from an image file.
  11283. Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
  11284. @param uiImage uiImage
  11285. */
  11286. initWithImage(uiImage: HTMLImageElement): boolean;
  11287. /**
  11288. HTMLElement Object getter, available only on web.
  11289. In most case, it will return null, because we are recycling the dom image element for better loading performance and lower image cache memory usage.
  11290. */
  11291. getHtmlElementObj(): HTMLImageElement;
  11292. /**
  11293. Check whether texture is loaded.
  11294. */
  11295. isLoaded(): boolean;
  11296. /**
  11297. Handler of texture loaded event.
  11298. */
  11299. handleLoadedTexture(): void;
  11300. /**
  11301. Description of cc.Texture2D.
  11302. */
  11303. description(): string;
  11304. /**
  11305. !#en
  11306. Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br>
  11307. After destroy, this object is not usable any more.
  11308. You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
  11309. !#zh
  11310. 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)<br/>
  11311. 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
  11312. */
  11313. destroy(): void;
  11314. /**
  11315. Pixel format of the texture.
  11316. */
  11317. getPixelFormat(): number;
  11318. /**
  11319. Whether or not the texture has their Alpha premultiplied,
  11320. support only in WebGl rendering mode.
  11321. */
  11322. hasPremultipliedAlpha(): boolean;
  11323. /**
  11324. Whether or not use mipmap, support only in WebGl rendering mode.
  11325. */
  11326. hasMipmaps(): boolean;
  11327. /**
  11328. Sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
  11329. If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}.
  11330. @param texParams texParams object or minFilter
  11331. @param magFilter magFilter
  11332. @param wrapS wrapS
  11333. @param wrapT wrapT
  11334. */
  11335. setTexParameters(texParams: any|number, magFilter?: number, wrapS?: Texture2D.WrapMode, wrapT?: Texture2D.WrapMode): void;
  11336. /**
  11337. sets antialias texture parameters: <br/>
  11338. - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11339. - GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11340. supported only in native or WebGl rendering mode
  11341. */
  11342. setAntiAliasTexParameters(): void;
  11343. /**
  11344. Sets alias texture parameters: <br/>
  11345. GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
  11346. GL_TEXTURE_MAG_FILTER = GL_NEAREST <br/>
  11347. supported only in native or WebGl rendering mode
  11348. */
  11349. setAliasTexParameters(): void;
  11350. /** Pixel format of the texture. */
  11351. pixelFormat: number;
  11352. /** Width in pixels. */
  11353. pixelWidth: number;
  11354. /** Height in pixels. */
  11355. pixelHeight: number;
  11356. /**
  11357. !#en
  11358. Register an callback of a specific event type on the EventTarget.
  11359. !#zh
  11360. 注册事件目标的特定事件类型回调。
  11361. @param type A string representing the event type to listen for.
  11362. @param callback The callback that will be invoked when the event is dispatched.
  11363. The callback is ignored if it is a duplicate (the callbacks are unique).
  11364. @param target The target (this object) to invoke the callback, can be null
  11365. @param useCapture When set to true, the capture argument prevents callback
  11366. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11367. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11368. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11369. @example
  11370. ```js
  11371. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11372. cc.log("this is callback");
  11373. }, node);
  11374. ```
  11375. */
  11376. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11377. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11378. /**
  11379. !#en
  11380. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11381. if only type is passed as parameter, all listeners registered with that type will be removed.
  11382. !#zh
  11383. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11384. @param type A string representing the event type being removed.
  11385. @param callback The callback to remove.
  11386. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11387. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11388. If not specified, useCapture defaults to false. If a callback was registered twice,
  11389. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11390. does not affect a non-capturing version of the same listener, and vice versa.
  11391. @example
  11392. ```js
  11393. // register touchEnd eventListener
  11394. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11395. cc.log("this is callback");
  11396. }, node);
  11397. // remove touch end event listener
  11398. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11399. // remove all touch end event listeners
  11400. node.off(cc.Node.EventType.TOUCH_END);
  11401. ```
  11402. */
  11403. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11404. /**
  11405. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11406. This is not for removing all listeners in the current event target,
  11407. and this is not for removing all listeners the target parameter have registered.
  11408. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11409. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11410. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11411. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11412. @param target The target to be searched for all related listeners
  11413. */
  11414. targetOff(target: any): void;
  11415. /**
  11416. !#en
  11417. Register an callback of a specific event type on the EventTarget,
  11418. the callback will remove itself after the first time it is triggered.
  11419. !#zh
  11420. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11421. @param type A string representing the event type to listen for.
  11422. @param callback The callback that will be invoked when the event is dispatched.
  11423. The callback is ignored if it is a duplicate (the callbacks are unique).
  11424. @param target The target (this object) to invoke the callback, can be null
  11425. @param useCapture When set to true, the capture argument prevents callback
  11426. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11427. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11428. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11429. @example
  11430. ```js
  11431. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11432. cc.log("this is callback");
  11433. }, node);
  11434. ```
  11435. */
  11436. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11437. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11438. /**
  11439. !#en
  11440. Dispatches an event into the event flow.
  11441. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11442. !#zh 分发事件到事件流中。
  11443. @param event The Event object that is dispatched into the event flow
  11444. */
  11445. dispatchEvent(event: Event): void;
  11446. /**
  11447. !#en
  11448. Send an event to this object directly, this method will not propagate the event to any other objects.
  11449. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11450. !#zh
  11451. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11452. @param message the message to send
  11453. @param detail whatever argument the message needs
  11454. */
  11455. emit(message: string, detail?: any): void;
  11456. }
  11457. /** cc.textureCache is a singleton object, it's the global cache for cc.Texture2D */
  11458. export class textureCache {
  11459. /**
  11460. Description
  11461. */
  11462. static description(): string;
  11463. /**
  11464. Returns an already created texture. Returns null if the texture doesn't exist.
  11465. @param textureKeyName textureKeyName
  11466. @example
  11467. ```js
  11468. ------------------
  11469. var key = cc.textureCache.getTextureForKey("hello.png");
  11470. ```
  11471. */
  11472. static getTextureForKey(textureKeyName: string): Texture2D;
  11473. /**
  11474. @param texture texture
  11475. @example
  11476. ```js
  11477. ---------------
  11478. var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
  11479. ```
  11480. */
  11481. static getTextureColors(texture: HTMLImageElement): any[];
  11482. /**
  11483. !#en get all textures
  11484. !#zh 获取所有贴图
  11485. */
  11486. static getAllTextures(): Texture2D[];
  11487. /**
  11488. <p>Purges the dictionary of loaded textures. <br />
  11489. Call this method if you receive the "Memory Warning" <br />
  11490. In the short term: it will free some resources preventing your app from being killed <br />
  11491. In the medium term: it will allocate more resources <br />
  11492. In the long term: it will be the same</p>
  11493. @example
  11494. ```js
  11495. --------
  11496. cc.textureCache.removeAllTextures();
  11497. ```
  11498. */
  11499. static removeAllTextures(): void;
  11500. /**
  11501. Deletes a texture from the cache given a texture.
  11502. @param texture texture
  11503. @example
  11504. ```js
  11505. -----
  11506. cc.textureCache.removeTexture(texture);
  11507. ```
  11508. */
  11509. static removeTexture(texture: HTMLImageElement): void;
  11510. /**
  11511. Deletes a texture from the cache given a its key name.
  11512. @param textureKeyName textureKeyName
  11513. @example
  11514. ```js
  11515. ------
  11516. cc.textureCache.removeTexture("hello.png");
  11517. ```
  11518. */
  11519. static removeTextureForKey(textureKeyName: string): void;
  11520. /**
  11521. Returns a Texture2D object given an file image <br />
  11522. If the file image was not previously loaded, it will create a new Texture2D
  11523. object and it will return it. It will use the filename as a key.
  11524. Otherwise it will return a reference of a previously loaded image. <br />
  11525. Supported image extensions: .png, .jpg, .gif
  11526. @param url url
  11527. @param cb cb
  11528. @param target target
  11529. @example
  11530. ```js
  11531. ----
  11532. cc.textureCache.addImage("hello.png");
  11533. ```
  11534. */
  11535. static addImage(url: string, cb: Function, target: any): Texture2D;
  11536. /**
  11537. Cache the image data.
  11538. @param path path
  11539. @param texture texture
  11540. */
  11541. static cacheImage(path: string, texture: HTMLImageElement|HTMLCanvasElement): void;
  11542. }
  11543. /** A base node for CCNode, it will:
  11544. - maintain scene hierarchy and active logic
  11545. - notifications if some properties changed
  11546. - define some interfaces shares between CCNode
  11547. - define machanisms for Enity Component Systems
  11548. - define prefab and serialize functions */
  11549. export class _BaseNode extends Object implements EventTarget {
  11550. /** !#en Name of node.
  11551. !#zh 该节点名称。 */
  11552. name: string;
  11553. /** !#en The uuid for editor, will be stripped before building project.
  11554. !#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
  11555. uuid: string;
  11556. /** !#en All children nodes.
  11557. !#zh 节点的所有子节点。 */
  11558. children: Node[];
  11559. /** !#en All children nodes.
  11560. !#zh 节点的子节点数量。 */
  11561. childrenCount: number;
  11562. /** !#en
  11563. The local active state of this node.<br/>
  11564. Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
  11565. Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
  11566. !#zh
  11567. 当前节点的自身激活状态。<br/>
  11568. 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。<br/>
  11569. 如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
  11570. active: boolean;
  11571. /** !#en Indicates whether this node is active in the scene.
  11572. !#zh 表示此节点是否在场景中激活。 */
  11573. activeInHierarchy: boolean;
  11574. /** !#en Tag of node.
  11575. !#zh 节点标签。 */
  11576. tag: number;
  11577. /**
  11578. @param name name
  11579. */
  11580. constructor(name?: string);
  11581. /** !#en The parent of the node.
  11582. !#zh 该节点的父节点。 */
  11583. parent: Node;
  11584. /**
  11585. !#en
  11586. Properties configuration function </br>
  11587. All properties in attrs will be set to the node, </br>
  11588. when the setter of the node is available, </br>
  11589. the property will be set via setter function.</br>
  11590. !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
  11591. @param attrs Properties to be set to node
  11592. @example
  11593. ```js
  11594. var attrs = { key: 0, num: 100 };
  11595. node.attr(attrs);
  11596. ```
  11597. */
  11598. attr(attrs: any): void;
  11599. /**
  11600. !#en Returns a child from the container given its tag.
  11601. !#zh 通过标签获取节点的子节点。
  11602. @param aTag An identifier to find the child node.
  11603. @example
  11604. ```js
  11605. var child = node.getChildByTag(1001);
  11606. ```
  11607. */
  11608. getChildByTag(aTag: number): Node;
  11609. /**
  11610. !#en Returns a child from the container given its uuid.
  11611. !#zh 通过 uuid 获取节点的子节点。
  11612. @param uuid The uuid to find the child node.
  11613. @example
  11614. ```js
  11615. var child = node.getChildByUuid(uuid);
  11616. ```
  11617. */
  11618. getChildByUuid(uuid: string): Node;
  11619. /**
  11620. !#en Returns a child from the container given its name.
  11621. !#zh 通过名称获取节点的子节点。
  11622. @param name A name to find the child node.
  11623. @example
  11624. ```js
  11625. var child = node.getChildByName("Test Node");
  11626. ```
  11627. */
  11628. getChildByName(name: string): Node;
  11629. /**
  11630. !#en
  11631. Inserts a child to the node at a specified index.
  11632. !#zh
  11633. 插入子节点到指定位置
  11634. @param child the child node to be inserted
  11635. @param siblingIndex the sibling index to place the child in
  11636. @example
  11637. ```js
  11638. node.insertChild(child, 2);
  11639. ```
  11640. */
  11641. insertChild(child: Node, siblingIndex: number): void;
  11642. /**
  11643. !#en Get the sibling index.
  11644. !#zh 获取同级索引。
  11645. @example
  11646. ```js
  11647. var index = node.getSiblingIndex();
  11648. ```
  11649. */
  11650. getSiblingIndex(): number;
  11651. /**
  11652. !#en Set the sibling index of this node.
  11653. !#zh 设置节点同级索引。
  11654. @param index index
  11655. @example
  11656. ```js
  11657. node.setSiblingIndex(1);
  11658. ```
  11659. */
  11660. setSiblingIndex(index: number): void;
  11661. /**
  11662. !#en
  11663. Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
  11664. If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.<br/>
  11665. If the node orphan, then nothing happens.
  11666. !#zh
  11667. 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。<br/>
  11668. 因此建议调用这个 API 时总是传入 `false` 参数。<br/>
  11669. 如果这个节点是一个孤节点,那么什么都不会发生。
  11670. @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
  11671. @example
  11672. ```js
  11673. node.removeFromParent();
  11674. node.removeFromParent(false);
  11675. ```
  11676. */
  11677. removeFromParent(cleanup?: boolean): void;
  11678. /**
  11679. !#en
  11680. Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
  11681. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11682. "remove" logic MUST only be on this method <br/>
  11683. If a class wants to extend the 'removeChild' behavior it only needs <br/>
  11684. to override this method.
  11685. !#zh
  11686. 移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11687. 如果 cleanup 参数不传入,默认为 true 表示清理。<br/>
  11688. @param child The child node which will be removed.
  11689. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11690. @example
  11691. ```js
  11692. node.removeChild(newNode);
  11693. node.removeChild(newNode, false);
  11694. ```
  11695. */
  11696. removeChild(child: Node, cleanup?: boolean): void;
  11697. /**
  11698. !#en
  11699. Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter.
  11700. If the cleanup parameter is not passed, it will force a cleanup. <br/>
  11701. !#zh
  11702. 通过标签移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11703. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11704. @param tag An integer number that identifies a child node
  11705. @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
  11706. @example
  11707. ```js
  11708. node.removeChildByTag(1001);
  11709. node.removeChildByTag(1001, false);
  11710. ```
  11711. */
  11712. removeChildByTag(tag: number, cleanup?: boolean): void;
  11713. /**
  11714. !#en
  11715. Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
  11716. If the cleanup parameter is not passed, it will force a cleanup.
  11717. !#zh
  11718. 移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。<br/>
  11719. 如果 cleanup 参数不传入,默认为 true 表示清理。
  11720. @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
  11721. @example
  11722. ```js
  11723. node.removeAllChildren();
  11724. node.removeAllChildren(false);
  11725. ```
  11726. */
  11727. removeAllChildren(cleanup?: boolean): void;
  11728. /**
  11729. !#en Is this node a child of the given node?
  11730. !#zh 是否是指定节点的子节点?
  11731. @param parent parent
  11732. @example
  11733. ```js
  11734. node.isChildOf(newNode);
  11735. ```
  11736. */
  11737. isChildOf(parent: Node): boolean;
  11738. /**
  11739. !#en
  11740. Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
  11741. You can also get component in the node by passing in the name of the script.
  11742. !#zh
  11743. 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。<br/>
  11744. 传入参数也可以是脚本的名称。
  11745. @param typeOrClassName typeOrClassName
  11746. @example
  11747. ```js
  11748. // get sprite component.
  11749. var sprite = node.getComponent(cc.Sprite);
  11750. // get custom test calss.
  11751. var test = node.getComponent("Test");
  11752. ```
  11753. */
  11754. getComponent<T extends Component>(type: {prototype: T}): T;
  11755. getComponent(className: string): any;
  11756. /**
  11757. !#en Returns all components of supplied type in the node.
  11758. !#zh 返回节点上指定类型的所有组件。
  11759. @param typeOrClassName typeOrClassName
  11760. @example
  11761. ```js
  11762. var sprites = node.getComponents(cc.Sprite);
  11763. var tests = node.getComponents("Test");
  11764. ```
  11765. */
  11766. getComponents<T extends Component>(type: {prototype: T}): T[];
  11767. getComponents(className: string): any[];
  11768. /**
  11769. !#en Returns the component of supplied type in any of its children using depth first search.
  11770. !#zh 递归查找所有子节点中第一个匹配指定类型的组件。
  11771. @param typeOrClassName typeOrClassName
  11772. @example
  11773. ```js
  11774. var sprite = node.getComponentInChildren(cc.Sprite);
  11775. var Test = node.getComponentInChildren("Test");
  11776. ```
  11777. */
  11778. getComponentInChildren<T extends Component>(type: {prototype: T}): T;
  11779. getComponentInChildren(className: string): any;
  11780. /**
  11781. !#en Returns all components of supplied type in self or any of its children.
  11782. !#zh 递归查找自身或所有子节点中指定类型的组件
  11783. @param typeOrClassName typeOrClassName
  11784. @example
  11785. ```js
  11786. var sprites = node.getComponentsInChildren(cc.Sprite);
  11787. var tests = node.getComponentsInChildren("Test");
  11788. ```
  11789. */
  11790. getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
  11791. getComponentsInChildren(className: string): any[];
  11792. /**
  11793. !#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
  11794. !#zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
  11795. @param typeOrClassName The constructor or the class name of the component to add
  11796. @example
  11797. ```js
  11798. var sprite = node.addComponent(cc.Sprite);
  11799. var test = node.addComponent("Test");
  11800. ```
  11801. */
  11802. addComponent<T extends Component>(type: {new(): T}): T;
  11803. addComponent(className: string): any;
  11804. /**
  11805. !#en
  11806. Removes a component identified by the given name or removes the component object given.
  11807. You can also use component.destroy() if you already have the reference.
  11808. !#zh
  11809. 删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。
  11810. 如果你已经获得组件引用,你也可以直接调用 component.destroy()
  11811. @param component The need remove component.
  11812. @example
  11813. ```js
  11814. node.removeComponent(cc.Sprite);
  11815. var Test = require("Test");
  11816. node.removeComponent(Test);
  11817. ```
  11818. */
  11819. removeComponent(component: string|Function|Component): void;
  11820. /**
  11821. !#en
  11822. Destroy all children from the node, and release all their own references to other objects.<br/>
  11823. Actual destruct operation will delayed until before rendering.
  11824. !#zh
  11825. 销毁所有子节点,并释放所有它们对其它对象的引用。<br/>
  11826. 实际销毁操作会延迟到当前帧渲染前执行。
  11827. @example
  11828. ```js
  11829. node.destroyAllChildren();
  11830. ```
  11831. */
  11832. destroyAllChildren(): void;
  11833. /**
  11834. !#en
  11835. Register an callback of a specific event type on the EventTarget.
  11836. !#zh
  11837. 注册事件目标的特定事件类型回调。
  11838. @param type A string representing the event type to listen for.
  11839. @param callback The callback that will be invoked when the event is dispatched.
  11840. The callback is ignored if it is a duplicate (the callbacks are unique).
  11841. @param target The target (this object) to invoke the callback, can be null
  11842. @param useCapture When set to true, the capture argument prevents callback
  11843. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11844. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11845. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11846. @example
  11847. ```js
  11848. node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11849. cc.log("this is callback");
  11850. }, node);
  11851. ```
  11852. */
  11853. on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11854. on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11855. /**
  11856. !#en
  11857. Removes the listeners previously registered with the same type, callback, target and or useCapture,
  11858. if only type is passed as parameter, all listeners registered with that type will be removed.
  11859. !#zh
  11860. 删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
  11861. @param type A string representing the event type being removed.
  11862. @param callback The callback to remove.
  11863. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
  11864. @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
  11865. If not specified, useCapture defaults to false. If a callback was registered twice,
  11866. one with capture and one without, each must be removed separately. Removal of a capturing callback
  11867. does not affect a non-capturing version of the same listener, and vice versa.
  11868. @example
  11869. ```js
  11870. // register touchEnd eventListener
  11871. var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
  11872. cc.log("this is callback");
  11873. }, node);
  11874. // remove touch end event listener
  11875. node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
  11876. // remove all touch end event listeners
  11877. node.off(cc.Node.EventType.TOUCH_END);
  11878. ```
  11879. */
  11880. off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
  11881. /**
  11882. !#en Removes all callbacks previously registered with the same target (passed as parameter).
  11883. This is not for removing all listeners in the current event target,
  11884. and this is not for removing all listeners the target parameter have registered.
  11885. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
  11886. !#zh 在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。
  11887. 这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。
  11888. 这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
  11889. @param target The target to be searched for all related listeners
  11890. */
  11891. targetOff(target: any): void;
  11892. /**
  11893. !#en
  11894. Register an callback of a specific event type on the EventTarget,
  11895. the callback will remove itself after the first time it is triggered.
  11896. !#zh
  11897. 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
  11898. @param type A string representing the event type to listen for.
  11899. @param callback The callback that will be invoked when the event is dispatched.
  11900. The callback is ignored if it is a duplicate (the callbacks are unique).
  11901. @param target The target (this object) to invoke the callback, can be null
  11902. @param useCapture When set to true, the capture argument prevents callback
  11903. from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
  11904. When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
  11905. Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
  11906. @example
  11907. ```js
  11908. node.once(cc.Node.EventType.TOUCH_END, function (event) {
  11909. cc.log("this is callback");
  11910. }, node);
  11911. ```
  11912. */
  11913. once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
  11914. once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
  11915. /**
  11916. !#en
  11917. Dispatches an event into the event flow.
  11918. The event target is the EventTarget object upon which the dispatchEvent() method is called.
  11919. !#zh 分发事件到事件流中。
  11920. @param event The Event object that is dispatched into the event flow
  11921. */
  11922. dispatchEvent(event: Event): void;
  11923. /**
  11924. !#en
  11925. Send an event to this object directly, this method will not propagate the event to any other objects.
  11926. The event will be created from the supplied message, you can get the "detail" argument from event.detail.
  11927. !#zh
  11928. 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
  11929. @param message the message to send
  11930. @param detail whatever argument the message needs
  11931. */
  11932. emit(message: string, detail?: any): void;
  11933. }
  11934. /** !#en
  11935. cc.AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
  11936. Please do not use its constructor directly, use cc.affineTransformMake alias function instead.
  11937. !#zh
  11938. cc.AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。<br/>
  11939. 请不要直接使用它的构造,请使用 cc.affineTransformMake 函数代替。 */
  11940. export class AffineTransform {
  11941. /**
  11942. !#en Create a cc.AffineTransform object with all contents in the matrix.
  11943. !#zh 用在矩阵中的所有内容创建一个 cc.AffineTransform 对象。
  11944. @param a a
  11945. @param b b
  11946. @param c c
  11947. @param d d
  11948. @param tx tx
  11949. @param ty ty
  11950. */
  11951. affineTransformMake(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
  11952. /**
  11953. !#en Clone a cc.AffineTransform object from the specified transform.
  11954. !#zh 克隆指定的 cc.AffineTransform 对象。
  11955. @param t t
  11956. */
  11957. affineTransformClone(t: AffineTransform): AffineTransform;
  11958. /**
  11959. !#en Apply the affine transformation on a point.
  11960. !#zh 对一个点应用矩阵变换。
  11961. @param point or x.
  11962. @param transOrY transform matrix or y.
  11963. @param t transform matrix or y.
  11964. */
  11965. pointApplyAffineTransform(point: Vec2|number, transOrY: AffineTransform|number, t: AffineTransform): Vec2;
  11966. /**
  11967. !#en Apply the affine transformation on a size.
  11968. !#zh 应用 Size 到仿射变换矩阵上。
  11969. @param size size
  11970. @param t t
  11971. */
  11972. sizeApplyAffineTransform(size: Size, t: AffineTransform): Size;
  11973. /**
  11974. !#en
  11975. Create a identity transformation matrix: <br/>
  11976. [ 1, 0, 0, <br/>
  11977. 0, 1, 0 ]
  11978. !#zh
  11979. 单位矩阵:<br/>
  11980. [ 1, 0, 0, <br/>
  11981. 0, 1, 0 ]
  11982. */
  11983. affineTransformMakeIdentity(): AffineTransform;
  11984. /**
  11985. !#en Apply the affine transformation on a rect.
  11986. !#zh 应用 Rect 到仿射变换矩阵上。
  11987. @param rect rect
  11988. @param anAffineTransform anAffineTransform
  11989. */
  11990. rectApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform): Rect;
  11991. /**
  11992. !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
  11993. !#zh 应用 Rect 到仿射变换矩阵上, 并转换为有向包围盒
  11994. @param rect rect
  11995. @param anAffineTransform anAffineTransform
  11996. @param out_bl out_bl
  11997. @param out_tl out_tl
  11998. @param out_tr out_tr
  11999. @param out_br out_br
  12000. */
  12001. obbApplyAffineTransform(rect: Rect, anAffineTransform: AffineTransform, out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2): void;
  12002. /**
  12003. !#en Create a new affine transformation with a base transformation matrix and a translation based on it.
  12004. !#zh 基于一个基础矩阵加上一个平移操作来创建一个新的矩阵。
  12005. @param t The base affine transform object.
  12006. @param tx The translation on x axis.
  12007. @param ty The translation on y axis.
  12008. */
  12009. affineTransformTranslate(t: AffineTransform, tx: number, ty: number): AffineTransform;
  12010. /**
  12011. !#en Create a new affine transformation with a base transformation matrix and a scale based on it.
  12012. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Scale 仿射变换。
  12013. @param t The base affine transform object.
  12014. @param sx The scale on x axis.
  12015. @param sy The scale on y axis.
  12016. */
  12017. affineTransformScale(t: AffineTransform, sx: number, sy: number): AffineTransform;
  12018. /**
  12019. !#en Create a new affine transformation with a base transformation matrix and a rotation based on it.
  12020. !#zh 创建一个基础变换矩阵,并在此基础上进行了 Rotation 仿射变换。
  12021. @param aTransform The base affine transform object.
  12022. @param anAngle The angle to rotate.
  12023. */
  12024. affineTransformRotate(aTransform: AffineTransform, anAngle: number): AffineTransform;
  12025. /**
  12026. !#en
  12027. Concatenate a transform matrix to another and return the result:<br/>
  12028. t' = t1 * t2
  12029. !#zh 拼接两个矩阵,并返回结果:<br/>
  12030. t' = t1 * t2
  12031. @param t1 The first transform object.
  12032. @param t2 The transform object to concatenate.
  12033. */
  12034. affineTransformConcat(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  12035. /**
  12036. !#en
  12037. Concatenate a transform matrix to another<br/>
  12038. The results are reflected in the first matrix.<br/>
  12039. t' = t1 * t2
  12040. !#zh
  12041. 拼接两个矩阵,将结果保存到第一个矩阵。<br/>
  12042. t' = t1 * t2
  12043. @param t1 The first transform object.
  12044. @param t2 The transform object to concatenate.
  12045. */
  12046. affineTransformConcatIn(t1: AffineTransform, t2: AffineTransform): AffineTransform;
  12047. /**
  12048. !#en Return true if an affine transform equals to another, false otherwise.
  12049. !#zh 判断两个矩阵是否相等。
  12050. @param t1 t1
  12051. @param t2 t2
  12052. */
  12053. affineTransformEqualToTransform(t1: AffineTransform, t2: AffineTransform): boolean;
  12054. /**
  12055. !#en Get the invert transform of an AffineTransform object.
  12056. !#zh 求逆矩阵。
  12057. @param t t
  12058. */
  12059. affineTransformInvert(t: AffineTransform): AffineTransform;
  12060. /**
  12061. !#en Put the invert transform of an AffineTransform object into the out AffineTransform object.
  12062. !#zh 求逆矩阵并存入用户传入的矩阵对象参数。
  12063. @param t t
  12064. @param out out
  12065. */
  12066. affineTransformInvert(t: AffineTransform, out: AffineTransform): void;
  12067. }
  12068. /** !#en
  12069. Representation of RGBA colors.
  12070. Each color component is a floating point value with a range from 0 to 255.
  12071. You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
  12072. !#zh
  12073. cc.Color 用于表示颜色。
  12074. 它包含 RGBA 四个以浮点数保存的颜色分量,每个的值都在 0 到 255 之间。
  12075. 您也可以通过使用 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
  12076. export class Color extends ValueType {
  12077. /**
  12078. @param r red component of the color, default value is 0.
  12079. @param g green component of the color, defualt value is 0.
  12080. @param b blue component of the color, default value is 0.
  12081. @param a alpha component of the color, default value is 255.
  12082. */
  12083. constructor(r?: number, g?: number, b?: number, a?: number);
  12084. /** !#en Solid white, RGBA is [255, 255, 255, 255].
  12085. !#zh 纯白色,RGBA 是 [255, 255, 255, 255]。 */
  12086. static WHITE: Color;
  12087. /** !#en Solid black, RGBA is [0, 0, 0, 255].
  12088. !#zh 纯黑色,RGBA 是 [0, 0, 0, 255]。 */
  12089. static BLACK: Color;
  12090. /** !#en Transparent, RGBA is [0, 0, 0, 0].
  12091. !#zh 透明,RGBA 是 [0, 0, 0, 0]。 */
  12092. static TRANSPARENT: Color;
  12093. /** !#en Grey, RGBA is [127.5, 127.5, 127.5].
  12094. !#zh 灰色,RGBA 是 [127.5, 127.5, 127.5]。 */
  12095. static GRAY: Color;
  12096. /** !#en Solid red, RGBA is [255, 0, 0].
  12097. !#zh 纯红色,RGBA 是 [255, 0, 0]。 */
  12098. static RED: Color;
  12099. /** !#en Solid green, RGBA is [0, 255, 0].
  12100. !#zh 纯绿色,RGBA 是 [0, 255, 0]。 */
  12101. static GREEN: Color;
  12102. /** !#en Solid blue, RGBA is [0, 0, 255].
  12103. !#zh 纯蓝色,RGBA 是 [0, 0, 255]。 */
  12104. static BLUE: Color;
  12105. /** !#en Yellow, RGBA is [255, 235, 4].
  12106. !#zh 黄色,RGBA 是 [255, 235, 4]。 */
  12107. static YELLOW: Color;
  12108. /** !#en Orange, RGBA is [255, 127, 0].
  12109. !#zh 橙色,RGBA 是 [255, 127, 0]。 */
  12110. static ORANGE: Color;
  12111. /** !#en Cyan, RGBA is [0, 255, 255].
  12112. !#zh 青色,RGBA 是 [0, 255, 255]。 */
  12113. static CYAN: Color;
  12114. /** !#en Magenta, RGBA is [255, 0, 255].
  12115. !#zh 洋红色(品红色),RGBA 是 [255, 0, 255]。 */
  12116. static MAGENTA: Color;
  12117. /**
  12118. !#en Clone a new color from the current color.
  12119. !#zh 克隆当前颜色。
  12120. @example
  12121. ```js
  12122. var color = new cc.Color();
  12123. var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
  12124. ```
  12125. */
  12126. clone(): Color;
  12127. /**
  12128. !#en TODO
  12129. !#zh 判断两个颜色是否相等。
  12130. @param other other
  12131. @example
  12132. ```js
  12133. var color1 = cc.Color.WHITE;
  12134. var color2 = new cc.Color(255, 255, 255);
  12135. cc.log(color1.equals(color2)); // true;
  12136. color2 = cc.Color.RED;
  12137. cc.log(color2.equals(color1)); // false;
  12138. ```
  12139. */
  12140. equals(other: Color): boolean;
  12141. /**
  12142. !#en TODO
  12143. !#zh 线性插值
  12144. @param to to
  12145. @param ratio the interpolation coefficient.
  12146. @param out optional, the receiving vector.
  12147. @example
  12148. ```js
  12149. // Converts a white color to a black one trough time.
  12150. update: function (dt) {
  12151. var color = this.node.color;
  12152. if (color.equals(cc.Color.BLACK)) {
  12153. return;
  12154. }
  12155. this.ratio += dt * 0.1;
  12156. this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
  12157. }
  12158. ```
  12159. */
  12160. lerp(to: Color, ratio: number, out?: Color): Color;
  12161. /**
  12162. !#en TODO
  12163. !#zh 转换为方便阅读的字符串。
  12164. @example
  12165. ```js
  12166. var color = cc.Color.WHITE;
  12167. color.toString(); // "rgba(255, 255, 255, 255)"
  12168. ```
  12169. */
  12170. toString(): string;
  12171. /**
  12172. !#en Gets red channel value
  12173. !#zh 获取当前颜色的红色值。
  12174. */
  12175. getR(): number;
  12176. /**
  12177. !#en Sets red value and return the current color object
  12178. !#zh 设置当前的红色值,并返回当前对象。
  12179. @param red the new Red component.
  12180. @example
  12181. ```js
  12182. var color = new cc.Color();
  12183. color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
  12184. ```
  12185. */
  12186. setR(red: number): Color;
  12187. /**
  12188. !#en Gets green channel value
  12189. !#zh 获取当前颜色的绿色值。
  12190. */
  12191. getG(): number;
  12192. /**
  12193. !#en Sets green value and return the current color object
  12194. !#zh 设置当前的绿色值,并返回当前对象。
  12195. @param green the new Green component.
  12196. @example
  12197. ```js
  12198. var color = new cc.Color();
  12199. color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
  12200. ```
  12201. */
  12202. setG(green: number): Color;
  12203. /**
  12204. !#en Gets blue channel value
  12205. !#zh 获取当前颜色的蓝色值。
  12206. */
  12207. getB(): number;
  12208. /**
  12209. !#en Sets blue value and return the current color object
  12210. !#zh 设置当前的蓝色值,并返回当前对象。
  12211. @param blue the new Blue component.
  12212. @example
  12213. ```js
  12214. var color = new cc.Color();
  12215. color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
  12216. ```
  12217. */
  12218. setB(blue: number): Color;
  12219. /**
  12220. !#en Gets alpha channel value
  12221. !#zh 获取当前颜色的透明度值。
  12222. */
  12223. getA(): number;
  12224. /**
  12225. !#en Sets alpha value and return the current color object
  12226. !#zh 设置当前的透明度,并返回当前对象。
  12227. @param alpha the new Alpha component.
  12228. @example
  12229. ```js
  12230. var color = new cc.Color();
  12231. color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
  12232. ```
  12233. */
  12234. setA(alpha: number): Color;
  12235. /**
  12236. !#en Convert color to css format.
  12237. !#zh 转换为 CSS 格式。
  12238. @param opt "rgba", "rgb", "#rgb" or "#rrggbb".
  12239. @example
  12240. ```js
  12241. var color = cc.Color.BLACK;
  12242. color.toCSS(); // "#000";
  12243. color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
  12244. color.toCSS("rgb"); // "rgba(0,0,0)";
  12245. color.toCSS("#rgb"); // "#000";
  12246. color.toCSS("#rrggbb"); // "#000000";
  12247. ```
  12248. */
  12249. toCSS(opt: string): string;
  12250. /**
  12251. !#en Clamp this color to make all components between 0 to 255。
  12252. !#zh 限制颜色数值,在 0 到 255 之间。
  12253. @example
  12254. ```js
  12255. var color = new cc.Color(1000, 0, 0, 255);
  12256. color.clamp();
  12257. cc.log(color); // (255, 0, 0, 255)
  12258. ```
  12259. */
  12260. clamp(): void;
  12261. /**
  12262. !#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
  12263. !#zh 读取 16 进制颜色。
  12264. @param hexString hexString
  12265. @example
  12266. ```js
  12267. var color = cc.Color.BLACK;
  12268. color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
  12269. ```
  12270. */
  12271. fromHEX(hexString: string): Color;
  12272. /**
  12273. !#en TODO
  12274. !#zh 转换为 16 进制。
  12275. @param fmt "#rgb" or "#rrggbb".
  12276. @example
  12277. ```js
  12278. var color = cc.Color.BLACK;
  12279. color.toHEX("#rgb"); // "000";
  12280. color.toHEX("#rrggbb"); // "000000";
  12281. ```
  12282. */
  12283. toHEX(fmt: string): string;
  12284. /**
  12285. !#en Convert to 24bit rgb value.
  12286. !#zh 转换为 24bit 的 RGB 值。
  12287. @example
  12288. ```js
  12289. var color = cc.Color.YELLOW;
  12290. color.toRGBValue(); // 16771844;
  12291. ```
  12292. */
  12293. toRGBValue(): number;
  12294. /**
  12295. !#en TODO
  12296. !#zh 读取 HSV(色彩模型)格式。
  12297. @param h h
  12298. @param s s
  12299. @param v v
  12300. @example
  12301. ```js
  12302. var color = cc.Color.YELLOW;
  12303. color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
  12304. ```
  12305. */
  12306. fromHSV(h: number, s: number, v: number): Color;
  12307. /**
  12308. !#en TODO
  12309. !#zh 转换为 HSV(色彩模型)格式。
  12310. @example
  12311. ```js
  12312. var color = cc.Color.YELLOW;
  12313. color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
  12314. ```
  12315. */
  12316. toHSV(): any;
  12317. /**
  12318. !#en TODO
  12319. !#zh RGB 转换为 HSV。
  12320. @param r red, must be [0, 255].
  12321. @param g red, must be [0, 255].
  12322. @param b red, must be [0, 255].
  12323. @example
  12324. ```js
  12325. cc.Color.rgb2hsv(255, 255, 255); // Object {h: 0, s: 0, v: 1};
  12326. ```
  12327. */
  12328. static rgb2hsv(r: number, g: number, b: number): any;
  12329. /**
  12330. !#en TODO
  12331. !#zh HSV 转换为 RGB。
  12332. @param h h
  12333. @param s s
  12334. @param v v
  12335. @example
  12336. ```js
  12337. cc.Color.hsv2rgb(0, 0, 1); // Object {r: 255, g: 255, b: 255};
  12338. ```
  12339. */
  12340. static hsv2rgb(h: number, s: number, v: number): any;
  12341. }
  12342. /** !#en A 2D rectangle defined by x, y position and width, height.
  12343. !#zh 通过位置和宽高定义的 2D 矩形。 */
  12344. export class Rect extends ValueType {
  12345. /**
  12346. !#en
  12347. Constructor of cc.Rect class.
  12348. see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
  12349. !#zh
  12350. cc.Rect类的构造函数。可以通过 {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 简便方法进行创建。
  12351. @param x x
  12352. @param y y
  12353. @param w w
  12354. @param h h
  12355. */
  12356. constructor(x?: number, y?: number, w?: number, h?: number);
  12357. x: number;
  12358. y: number;
  12359. width: number;
  12360. height: number;
  12361. /**
  12362. !#en Creates a rectangle from two coordinate values.
  12363. !#zh 根据指定 2 个坐标创建出一个矩形区域。
  12364. @param v1 v1
  12365. @param v2 v2
  12366. @example
  12367. ```js
  12368. cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
  12369. ```
  12370. */
  12371. static fromMinMax(v1: Vec2, v2: Vec2): Rect;
  12372. /**
  12373. !#en Checks if rect contains.
  12374. !#zh
  12375. 判断 2 个矩形是否有包含。<br/>
  12376. 返回 1 为 a 包含 b,如果 -1 为 b 包含 a,
  12377. 0 这则都不包含。
  12378. @param a Rect a
  12379. @param b Rect b
  12380. @example
  12381. ```js
  12382. var a = new cc.Rect(0, 0, 10, 10);
  12383. var b = new cc.Rect(5, 5, 5, 5);
  12384. var c = new cc.Rect(20, 20, 10, 10);
  12385. cc.Rect.contain(a, b); // 1;
  12386. cc.Rect.contain(b, a); // -1;
  12387. cc.Rect.contain(a, c); // 0;
  12388. ```
  12389. */
  12390. static contain(a: Rect, b: Rect): number;
  12391. /**
  12392. !#en TODO
  12393. !#zh 克隆一个新的 Rect。
  12394. @example
  12395. ```js
  12396. var a = new cc.Rect(0, 0, 10, 10);
  12397. a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
  12398. ```
  12399. */
  12400. clone(): Rect;
  12401. /**
  12402. !#en TODO
  12403. !#zh 是否等于指定的矩形。
  12404. @param other other
  12405. @example
  12406. ```js
  12407. var a = new cc.Rect(0, 0, 10, 10);
  12408. var b = new cc.Rect(0, 0, 10, 10);
  12409. a.equals(b);// true;
  12410. ```
  12411. */
  12412. equals(other: Rect): boolean;
  12413. /**
  12414. !#en TODO
  12415. !#zh 线性插值
  12416. @param to to
  12417. @param ratio the interpolation coefficient.
  12418. @param out optional, the receiving vector.
  12419. @example
  12420. ```js
  12421. var a = new cc.Rect(0, 0, 10, 10);
  12422. var b = new cc.Rect(50, 50, 100, 100);
  12423. update (dt) {
  12424. // method 1;
  12425. var c = a.lerp(b, dt * 0.1);
  12426. // method 2;
  12427. a.lerp(b, dt * 0.1, c);
  12428. }
  12429. ```
  12430. */
  12431. lerp(to: Rect, ratio: number, out?: Rect): Rect;
  12432. /**
  12433. !#en TODO
  12434. !#zh 转换为方便阅读的字符串
  12435. @example
  12436. ```js
  12437. var a = new cc.Rect(0, 0, 10, 10);
  12438. a.toString();// "(0.00, 0.00, 10.00, 10.00)";
  12439. ```
  12440. */
  12441. toString(): string;
  12442. /** !#en TODO
  12443. !#zh 矩形 x 轴上的最小值。 */
  12444. xMin: number;
  12445. /** !#en TODO
  12446. !#zh 矩形 y 轴上的最小值。 */
  12447. yMin: number;
  12448. /** !#en TODO
  12449. !#zh 矩形 x 轴上的最大值。 */
  12450. xMax: number;
  12451. /** !#en TODO
  12452. !#zh 矩形 y 轴上的最大值。 */
  12453. yMax: number;
  12454. /** !#en The position of the center of the rectangle.
  12455. !#zh 矩形的中心点。 */
  12456. center: Vec2;
  12457. /** !#en The X and Y position of the rectangle.
  12458. !#zh 矩形的 x 和 y 坐标。 */
  12459. origin: Vec2;
  12460. /** !#en Width and height of the rectangle.
  12461. !#zh 矩形的大小。 */
  12462. size: Size;
  12463. /**
  12464. !#en TODO
  12465. !#zh 当前矩形与指定矩形是否相交。
  12466. @param rect rect
  12467. @example
  12468. ```js
  12469. var a = new cc.Rect(0, 0, 10, 10);
  12470. var b = new cc.Rect(0, 0, 20, 20);
  12471. a.intersects(b);// true
  12472. ```
  12473. */
  12474. intersects(rect: Rect): void;
  12475. /**
  12476. !#en TODO
  12477. !#zh 当前矩形是否包含指定坐标点。
  12478. Returns true if the point inside this rectangle.
  12479. @param point point
  12480. @example
  12481. ```js
  12482. var a = new cc.Rect(0, 0, 10, 10);
  12483. var b = new cc.Vec2(0, 5);
  12484. a.contains(b);// true
  12485. ```
  12486. */
  12487. contains(point: Vec2): void;
  12488. /**
  12489. !#en Returns true if the other rect totally inside this rectangle.
  12490. !#zh 当前矩形是否包含指定矩形。
  12491. @param rect rect
  12492. @example
  12493. ```js
  12494. var a = new cc.Rect(0, 0, 20, 20);
  12495. var b = new cc.Rect(0, 0, 10, 10);
  12496. a.containsRect(b);// true
  12497. ```
  12498. */
  12499. containsRect(rect: Rect): void;
  12500. }
  12501. /** !#en
  12502. cc.Size is the class for size object,<br/>
  12503. please do not use its constructor to create sizes,<br/>
  12504. use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
  12505. It will be deprecated soon, please use cc.Vec2 instead.
  12506. !#zh
  12507. cc.Size 是 size 对象的类。<br/>
  12508. 请不要使用它的构造函数创建的 size,<br/>
  12509. 使用 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
  12510. 它不久将被取消,请使用cc.Vec2代替。 */
  12511. export class Size {
  12512. /**
  12513. @param width width
  12514. @param height height
  12515. */
  12516. constructor(width: number|Size, height?: number);
  12517. width: number;
  12518. height: number;
  12519. /** !#en return a Size object with width = 0 and height = 0.
  12520. !#zh 返回一个宽度为 0 和高度为 0 的 Size 对象。 */
  12521. static ZERO: Size;
  12522. /**
  12523. !#en TODO
  12524. !#zh 克隆 size 对象。
  12525. @example
  12526. ```js
  12527. var a = new cc.size(10, 10);
  12528. a.clone();// return Size {width: 0, height: 0};
  12529. ```
  12530. */
  12531. clone(): Size;
  12532. /**
  12533. !#en TODO
  12534. !#zh 当前 Size 对象是否等于指定 Size 对象。
  12535. @param other other
  12536. @example
  12537. ```js
  12538. var a = new cc.size(10, 10);
  12539. a.equals(new cc.size(10, 10));// return true;
  12540. ```
  12541. */
  12542. equals(other: Size): boolean;
  12543. /**
  12544. !#en TODO
  12545. !#zh 线性插值。
  12546. @param to to
  12547. @param ratio the interpolation coefficient.
  12548. @param out optional, the receiving vector.
  12549. @example
  12550. ```js
  12551. var a = new cc.size(10, 10);
  12552. var b = new cc.rect(50, 50, 100, 100);
  12553. update (dt) {
  12554. // method 1;
  12555. var c = a.lerp(b, dt * 0.1);
  12556. // method 2;
  12557. a.lerp(b, dt * 0.1, c);
  12558. }
  12559. ```
  12560. */
  12561. lerp(to: Rect, ratio: number, out?: Size): Size;
  12562. /**
  12563. !#en TODO
  12564. !#zh 转换为方便阅读的字符串。
  12565. @example
  12566. ```js
  12567. var a = new cc.size(10, 10);
  12568. a.toString();// return "(10.00, 10.00)";
  12569. ```
  12570. */
  12571. toString(): string;
  12572. }
  12573. /** !#en the device accelerometer reports values for each axis in units of g-force.
  12574. !#zh 设备重力传感器传递的各个轴的数据。 */
  12575. export class Acceleration {
  12576. /**
  12577. @param x x
  12578. @param y y
  12579. @param z z
  12580. @param timestamp timestamp
  12581. */
  12582. constructor(x: number, y: number, z: number, timestamp: number);
  12583. }
  12584. /** !#en Blend Function used for textures.
  12585. !#zh 图像的混合方式。 */
  12586. export class BlendFunc {
  12587. /**
  12588. @param src1 source blend function
  12589. @param dst1 destination blend function
  12590. */
  12591. constructor(src1: number, dst1: number);
  12592. }
  12593. /** !#en
  12594. Enum for blend factor
  12595. Refer to: http://www.andersriggelsen.dk/glblendfunc.php
  12596. !#zh
  12597. 混合因子
  12598. 可参考: http://www.andersriggelsen.dk/glblendfunc.php */
  12599. export enum BlendFactor {
  12600. ONE = 0,
  12601. ZERO = 0,
  12602. SRC_ALPHA = 0,
  12603. SRC_COLOR = 0,
  12604. DST_ALPHA = 0,
  12605. DST_COLOR = 0,
  12606. ONE_MINUS_SRC_ALPHA = 0,
  12607. ONE_MINUS_SRC_COLOR = 0,
  12608. ONE_MINUS_DST_ALPHA = 0,
  12609. ONE_MINUS_DST_COLOR = 0,
  12610. blendFuncDisable = 0,
  12611. }
  12612. /** undefined */
  12613. export enum TextAlignment {
  12614. LEFT = 0,
  12615. CENTER = 0,
  12616. RIGHT = 0,
  12617. }
  12618. /** undefined */
  12619. export class WebGLColor {
  12620. /**
  12621. @param r r
  12622. @param g g
  12623. @param b b
  12624. @param a a
  12625. @param arrayBuffer arrayBuffer
  12626. @param offset offset
  12627. */
  12628. constructor(r: number, g: number, b: number, a: number, arrayBuffer: any[], offset: number);
  12629. BYTES_PER_ELEMENT: number;
  12630. }
  12631. /** undefined */
  12632. export class Vertex2F {
  12633. /**
  12634. @param x x
  12635. @param y y
  12636. @param arrayBuffer arrayBuffer
  12637. @param offset offset
  12638. */
  12639. constructor(x: number, y: number, arrayBuffer: any[], offset: number);
  12640. BYTES_PER_ELEMENT: number;
  12641. }
  12642. /** undefined */
  12643. export class Vertex3F {
  12644. /**
  12645. @param x x
  12646. @param y y
  12647. @param z z
  12648. @param arrayBuffer arrayBuffer
  12649. @param offset offset
  12650. */
  12651. constructor(x: number, y: number, z: number, arrayBuffer: any[], offset: number);
  12652. BYTES_PER_ELEMENT: number;
  12653. }
  12654. /** undefined */
  12655. export class Tex2F {
  12656. /**
  12657. @param u u
  12658. @param v v
  12659. @param arrayBuffer arrayBuffer
  12660. @param offset offset
  12661. */
  12662. constructor(u: number, v: number, arrayBuffer: any[], offset: number);
  12663. BYTES_PER_ELEMENT: number;
  12664. }
  12665. /** undefined */
  12666. export class Quad2 {
  12667. /**
  12668. @param tl tl
  12669. @param tr tr
  12670. @param bl bl
  12671. @param br br
  12672. @param arrayBuffer arrayBuffer
  12673. @param offset offset
  12674. */
  12675. constructor(tl: Vertex2F, tr: Vertex2F, bl: Vertex2F, br: Vertex2F, arrayBuffer: any[], offset: number);
  12676. BYTES_PER_ELEMENT: number;
  12677. }
  12678. /** A 3D Quad. 4 * 3 floats */
  12679. export class Quad3 {
  12680. /**
  12681. @param bl1 bl1
  12682. @param br1 br1
  12683. @param tl1 tl1
  12684. @param tr1 tr1
  12685. @param arrayBuffer arrayBuffer
  12686. @param offset offset
  12687. */
  12688. constructor(bl1: Vertex3F, br1: Vertex3F, tl1: Vertex3F, tr1: Vertex3F, arrayBuffer: any[], offset: number);
  12689. }
  12690. /** undefined */
  12691. export class V3F_C4B_T2F {
  12692. /**
  12693. @param vertices vertices
  12694. @param colors colors
  12695. @param texCoords texCoords
  12696. @param arrayBuffer arrayBuffer
  12697. @param offset offset
  12698. */
  12699. constructor(vertices: Vertex3F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12700. BYTES_PER_ELEMENT(): void;
  12701. }
  12702. /** undefined */
  12703. export class V3F_C4B_T2F_Quad {
  12704. /**
  12705. @param tl tl
  12706. @param bl bl
  12707. @param tr tr
  12708. @param br br
  12709. @param arrayBuffer arrayBuffer
  12710. @param offset offset
  12711. */
  12712. constructor(tl: V3F_C4B_T2F, bl: V3F_C4B_T2F, tr: V3F_C4B_T2F, br: V3F_C4B_T2F, arrayBuffer: any[], offset: number);
  12713. BYTES_PER_ELEMENT: number;
  12714. }
  12715. /** undefined */
  12716. export class V2F_C4B_T2F {
  12717. /**
  12718. @param vertices vertices
  12719. @param colors colors
  12720. @param texCoords texCoords
  12721. @param arrayBuffer arrayBuffer
  12722. @param offset offset
  12723. */
  12724. constructor(vertices: Vertex2F, colors: Color, texCoords: Tex2F, arrayBuffer: any[], offset: number);
  12725. BYTES_PER_ELEMENT: number;
  12726. }
  12727. /** undefined */
  12728. export class V2F_C4B_T2F_Triangle {
  12729. /**
  12730. @param a a
  12731. @param b b
  12732. @param c c
  12733. @param arrayBuffer arrayBuffer
  12734. @param offset offset
  12735. */
  12736. constructor(a: V2F_C4B_T2F, b: V2F_C4B_T2F, c: V2F_C4B_T2F, arrayBuffer: any[], offset: number);
  12737. }
  12738. /** !#en The base class of all value types.
  12739. !#zh 所有值类型的基类。 */
  12740. export class ValueType {
  12741. /**
  12742. !#en This method returns an exact copy of current value.
  12743. !#zh 克隆当前值,该方法返回一个新对象,新对象的值和原对象相等。
  12744. */
  12745. clone(): ValueType;
  12746. /**
  12747. !#en Compares this object with the other one.
  12748. !#zh 当前对象是否等于指定对象。
  12749. @param other other
  12750. */
  12751. equals(other: ValueType): boolean;
  12752. /**
  12753. !#en
  12754. Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
  12755. When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
  12756. !#zh
  12757. 线性插值。<br/>
  12758. 当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
  12759. @param to the to value
  12760. @param ratio the interpolation coefficient
  12761. */
  12762. lerp(to: ValueType, ratio: number): ValueType;
  12763. /**
  12764. !#en TODO
  12765. !#zh 转换为方便阅读的字符串。
  12766. */
  12767. toString(): string;
  12768. }
  12769. /** !#en Representation of 2D vectors and points.
  12770. !#zh 表示 2D 向量和坐标 */
  12771. export class Vec2 extends ValueType {
  12772. /**
  12773. !#en
  12774. Constructor
  12775. see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12776. !#zh
  12777. 构造函数,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
  12778. @param x x
  12779. @param y y
  12780. */
  12781. constructor(x?: number, y?: number);
  12782. x: number;
  12783. y: number;
  12784. /**
  12785. !#en clone a Vec2 value
  12786. !#zh 克隆一个 Vec2 值
  12787. */
  12788. clone(): Vec2;
  12789. /**
  12790. !#en TODO
  12791. !#zh 设置向量值。
  12792. @param newValue !#en new value to set. !#zh 要设置的新值
  12793. */
  12794. set(newValue: Vec2): Vec2;
  12795. /**
  12796. !#en TODO
  12797. !#zh 当前的向量是否与指定的向量相等。
  12798. @param other other
  12799. */
  12800. equals(other: Vec2): boolean;
  12801. /**
  12802. !#en TODO
  12803. !#zh 转换为方便阅读的字符串。
  12804. */
  12805. toString(): string;
  12806. /**
  12807. !#en TODO
  12808. !#zh 线性插值。
  12809. @param to to
  12810. @param ratio the interpolation coefficient
  12811. @param out optional, the receiving vector
  12812. */
  12813. lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
  12814. /**
  12815. !#en Adds this vector. If you want to save result to another vector, use add() instead.
  12816. !#zh 向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
  12817. @param vector vector
  12818. @example
  12819. ```js
  12820. var v = cc.v2(10, 10);
  12821. v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
  12822. ```
  12823. */
  12824. addSelf(vector: Vec2): Vec2;
  12825. /**
  12826. !#en Adds two vectors, and returns the new result.
  12827. !#zh 向量加法,并返回新结果。
  12828. @param vector vector
  12829. @param out optional, the receiving vector
  12830. @example
  12831. ```js
  12832. var v = cc.v2(10, 10);
  12833. v.add(cc.v2(5, 5)); // return Vec2 {x: 15, y: 15};
  12834. var v1;
  12835. v.add(cc.v2(5, 5), v1); // return Vec2 {x: 15, y: 15};
  12836. ```
  12837. */
  12838. add(vector: Vec2, out?: Vec2): Vec2;
  12839. /**
  12840. !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
  12841. !#zh 向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
  12842. @param vector vector
  12843. @example
  12844. ```js
  12845. var v = cc.v2(10, 10);
  12846. v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
  12847. ```
  12848. */
  12849. subSelf(vector: Vec2): Vec2;
  12850. /**
  12851. !#en Subtracts one vector from this, and returns the new result.
  12852. !#zh 向量减法,并返回新结果。
  12853. @param vector vector
  12854. @param out optional, the receiving vector
  12855. @example
  12856. ```js
  12857. var v = cc.v2(10, 10);
  12858. v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
  12859. var v1;
  12860. v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
  12861. ```
  12862. */
  12863. sub(vector: Vec2, out?: Vec2): Vec2;
  12864. /**
  12865. !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
  12866. !#zh 缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
  12867. @param num num
  12868. @example
  12869. ```js
  12870. var v = cc.v2(10, 10);
  12871. v.mulSelf(5);// return Vec2 {x: 50, y: 50};
  12872. ```
  12873. */
  12874. mulSelf(num: number): Vec2;
  12875. /**
  12876. !#en Multiplies by a number, and returns the new result.
  12877. !#zh 缩放向量,并返回新结果。
  12878. @param num num
  12879. @param out optional, the receiving vector
  12880. @example
  12881. ```js
  12882. var v = cc.v2(10, 10);
  12883. v.mul(5); // return Vec2 {x: 50, y: 50};
  12884. var v1;
  12885. v.mul(5, v1); // return Vec2 {x: 50, y: 50};
  12886. ```
  12887. */
  12888. mul(num: number, out?: Vec2): Vec2;
  12889. /**
  12890. !#en Multiplies two vectors.
  12891. !#zh 分量相乘。
  12892. @param vector vector
  12893. @example
  12894. ```js
  12895. var v = cc.v2(10, 10);
  12896. v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
  12897. ```
  12898. */
  12899. scaleSelf(vector: Vec2): Vec2;
  12900. /**
  12901. !#en Multiplies two vectors, and returns the new result.
  12902. !#zh 分量相乘,并返回新的结果。
  12903. @param vector vector
  12904. @param out optional, the receiving vector
  12905. @example
  12906. ```js
  12907. var v = cc.v2(10, 10);
  12908. v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
  12909. var v1;
  12910. v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
  12911. ```
  12912. */
  12913. scale(vector: Vec2, out?: Vec2): Vec2;
  12914. /**
  12915. !#en Divides by a number. If you want to save result to another vector, use div() instead.
  12916. !#zh 向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
  12917. @param divisor divisor
  12918. @example
  12919. ```js
  12920. var v = cc.v2(10, 10);
  12921. v.divSelf(5); // return Vec2 {x: 2, y: 2};
  12922. ```
  12923. */
  12924. divSelf(divisor: number): Vec2;
  12925. /**
  12926. !#en Divides by a number, and returns the new result.
  12927. !#zh 向量除法,并返回新的结果。
  12928. @param divisor divisor
  12929. @param out optional, the receiving vector
  12930. @example
  12931. ```js
  12932. var v = cc.v2(10, 10);
  12933. v.div(5); // return Vec2 {x: 2, y: 2};
  12934. var v1;
  12935. v.div(5, v1); // return Vec2 {x: 2, y: 2};
  12936. ```
  12937. */
  12938. div(divisor: number, out?: Vec2): Vec2;
  12939. /**
  12940. !#en Negates the components. If you want to save result to another vector, use neg() instead.
  12941. !#zh 向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
  12942. @example
  12943. ```js
  12944. var v = cc.v2(10, 10);
  12945. v.negSelf(); // return Vec2 {x: -10, y: -10};
  12946. ```
  12947. */
  12948. negSelf(): Vec2;
  12949. /**
  12950. !#en Negates the components, and returns the new result.
  12951. !#zh 返回取反后的新向量。
  12952. @param out optional, the receiving vector
  12953. @example
  12954. ```js
  12955. var v = cc.v2(10, 10);
  12956. var v1;
  12957. v.neg(v1); // return Vec2 {x: -10, y: -10};
  12958. ```
  12959. */
  12960. neg(out?: Vec2): Vec2;
  12961. /**
  12962. !#en Dot product
  12963. !#zh 当前向量与指定向量进行点乘。
  12964. @param vector vector
  12965. @example
  12966. ```js
  12967. var v = cc.v2(10, 10);
  12968. v.dot(cc.v2(5, 5)); // return 100;
  12969. ```
  12970. */
  12971. dot(vector?: Vec2): number;
  12972. /**
  12973. !#en Cross product
  12974. !#zh 当前向量与指定向量进行叉乘。
  12975. @param vector vector
  12976. @example
  12977. ```js
  12978. var v = cc.v2(10, 10);
  12979. v.cross(cc.v2(5, 5)); // return 0;
  12980. ```
  12981. */
  12982. cross(vector?: Vec2): number;
  12983. /**
  12984. !#en Returns the length of this vector.
  12985. !#zh 返回该向量的长度。
  12986. @example
  12987. ```js
  12988. var v = cc.v2(10, 10);
  12989. v.mag(); // return 14.142135623730951;
  12990. ```
  12991. */
  12992. mag(): number;
  12993. /**
  12994. !#en Returns the squared length of this vector.
  12995. !#zh 返回该向量的长度平方。
  12996. @example
  12997. ```js
  12998. var v = cc.v2(10, 10);
  12999. v.magSqr(); // return 200;
  13000. ```
  13001. */
  13002. magSqr(): number;
  13003. /**
  13004. !#en Make the length of this vector to 1.
  13005. !#zh 向量归一化,让这个向量的长度为 1。
  13006. @example
  13007. ```js
  13008. var v = cc.v2(10, 10);
  13009. v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
  13010. ```
  13011. */
  13012. normalizeSelf(): Vec2;
  13013. /**
  13014. !#en
  13015. Returns this vector with a magnitude of 1.<br/>
  13016. <br/>
  13017. Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
  13018. !#zh
  13019. 返回归一化后的向量。<br/>
  13020. <br/>
  13021. 注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
  13022. @param out optional, the receiving vector
  13023. */
  13024. normalize(out?: Vec2): Vec2;
  13025. /**
  13026. !#en Get angle in radian between this and vector.
  13027. !#zh 夹角的弧度。
  13028. @param vector vector
  13029. */
  13030. angle(vector: Vec2): number;
  13031. /**
  13032. !#en Get angle in radian between this and vector with direction.
  13033. !#zh 带方向的夹角的弧度。
  13034. @param vector vector
  13035. */
  13036. signAngle(vector: Vec2): number;
  13037. /**
  13038. !#en rotate
  13039. !#zh 返回旋转给定弧度后的新向量。
  13040. @param radians radians
  13041. @param out optional, the receiving vector
  13042. */
  13043. rotate(radians: number, out?: Vec2): Vec2;
  13044. /**
  13045. !#en rotate self
  13046. !#zh 按指定弧度旋转向量。
  13047. @param radians radians
  13048. */
  13049. rotateSelf(radians: number): Vec2;
  13050. /** !#en return a Vec2 object with x = 1 and y = 1.
  13051. !#zh 新 Vec2 对象。 */
  13052. static ONE: Vec2;
  13053. /** !#en return a Vec2 object with x = 0 and y = 0.
  13054. !#zh 返回 x = 0 和 y = 0 的 Vec2 对象。 */
  13055. static ZERO: Vec2;
  13056. /** !#en return a Vec2 object with x = 0 and y = 1.
  13057. !#zh 返回 x = 0 和 y = 1 的 Vec2 对象。 */
  13058. static UP: Vec2;
  13059. /** !#en return a Vec2 object with x = 1 and y = 0.
  13060. !#zh 返回 x = 1 和 y = 0 的 Vec2 对象。 */
  13061. static RIGHT: Vec2;
  13062. }
  13063. /** !#en
  13064. A distance joint constrains two points on two bodies
  13065. to remain at a fixed distance from each other. You can view
  13066. this as a massless, rigid rod.
  13067. !#zh
  13068. 距离关节通过一个固定的长度来约束关节链接的两个刚体。你可以将它想象成一个无质量,坚固的木棍。 */
  13069. export class DistanceJoint extends Joint {
  13070. /** !#en
  13071. The distance separating the two ends of the joint.
  13072. !#zh
  13073. 关节两端的距离 */
  13074. distance: number;
  13075. /** !#en
  13076. The spring frequency.
  13077. !#zh
  13078. 弹性系数。 */
  13079. frequency: number;
  13080. /** !#en
  13081. The damping ratio.
  13082. !#zh
  13083. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13084. 0: number;
  13085. }
  13086. /** !#en
  13087. Base class for joints to connect rigidbody.
  13088. !#zh
  13089. 关节类的基类 */
  13090. export class Joint extends Component {
  13091. /** !#en
  13092. The anchor of the rigidbody.
  13093. !#zh
  13094. 刚体的锚点。 */
  13095. anchor: Vec2;
  13096. /** !#en
  13097. The anchor of the connected rigidbody.
  13098. !#zh
  13099. 关节另一端刚体的锚点。 */
  13100. connectedAnchor: Vec2;
  13101. /** !#en
  13102. The rigidbody to which the other end of the joint is attached.
  13103. !#zh
  13104. 关节另一端链接的刚体 */
  13105. connectedBody: RigidBody;
  13106. /** !#en
  13107. Should the two rigid bodies connected with this joint collide with each other?
  13108. !#zh
  13109. 链接到关节上的两个刚体是否应该相互碰撞? */
  13110. collideConnected: boolean;
  13111. /**
  13112. !#en
  13113. Apply current changes to joint, this will regenerate inner box2d joint.
  13114. !#zh
  13115. 应用当前关节中的修改,调用此函数会重新生成内部 box2d 的关节。
  13116. */
  13117. apply(): void;
  13118. /**
  13119. !#en
  13120. Get the anchor point on rigidbody in world coordinates.
  13121. !#zh
  13122. 获取刚体世界坐标系下的锚点。
  13123. */
  13124. getWorldAnchor(): Vec2;
  13125. /**
  13126. !#en
  13127. Get the anchor point on connected rigidbody in world coordinates.
  13128. !#zh
  13129. 获取链接刚体世界坐标系下的锚点。
  13130. */
  13131. getWorldConnectedAnchor(): Vec2;
  13132. /**
  13133. !#en
  13134. Gets the reaction force of the joint.
  13135. !#zh
  13136. 获取关节的反作用力。
  13137. @param timeStep The time to calculate the reaction force for.
  13138. */
  13139. getReactionForce(timeStep: number): number;
  13140. /**
  13141. !#en
  13142. Gets the reaction torque of the joint.
  13143. !#zh
  13144. 获取关节的反扭矩。
  13145. @param timeStep The time to calculate the reaction torque for.
  13146. */
  13147. getReactionTorque(timeStep: number): number;
  13148. }
  13149. /** !#en
  13150. A motor joint is used to control the relative motion
  13151. between two bodies. A typical usage is to control the movement
  13152. of a dynamic body with respect to the ground.
  13153. !#zh
  13154. 马达关节被用来控制两个刚体间的相对运动。
  13155. 一个典型的例子是用来控制一个动态刚体相对于地面的运动。 */
  13156. export class MotorJoint extends Joint {
  13157. /** !#en
  13158. The anchor of the rigidbody.
  13159. !#zh
  13160. 刚体的锚点。 */
  13161. anchor: Vec2;
  13162. /** !#en
  13163. The anchor of the connected rigidbody.
  13164. !#zh
  13165. 关节另一端刚体的锚点。 */
  13166. connectedAnchor: Vec2;
  13167. /** !#en
  13168. The linear offset from connected rigidbody to rigidbody.
  13169. !#zh
  13170. 关节另一端的刚体相对于起始端刚体的位置偏移量 */
  13171. linearOffset: Vec2;
  13172. /** !#en
  13173. The angular offset from connected rigidbody to rigidbody.
  13174. !#zh
  13175. 关节另一端的刚体相对于起始端刚体的角度偏移量 */
  13176. angularOffset: number;
  13177. /** !#en
  13178. The maximum force can be applied to rigidbody.
  13179. !#zh
  13180. 可以应用于刚体的最大的力值 */
  13181. maxForce: number;
  13182. /** !#en
  13183. The maximum torque can be applied to rigidbody.
  13184. !#zh
  13185. 可以应用于刚体的最大扭矩值 */
  13186. maxTorque: number;
  13187. /** !#en
  13188. The position correction factor in the range [0,1].
  13189. !#zh
  13190. 位置矫正系数,范围为 [0, 1] */
  13191. correctionFactor: number;
  13192. }
  13193. /** !#en
  13194. A mouse joint is used to make a point on a body track a
  13195. specified world point. This a soft constraint with a maximum
  13196. force. This allows the constraint to stretch and without
  13197. applying huge forces.
  13198. Mouse Joint will auto register the touch event with the mouse region node,
  13199. and move the choosed rigidbody in touch move event.
  13200. Note : generally mouse joint only used in test bed.
  13201. !#zh
  13202. 鼠标关节用于使刚体上的一个点追踪一个指定的世界坐标系下的位置。
  13203. 鼠标关节可以指定一个最大的里来施加一个柔和的约束。
  13204. 鼠标关节会自动使用 mouse region 节点来注册鼠标事件,并且在触摸移动事件中移动选中的刚体。
  13205. 注意:一般鼠标关节只在测试环境中使用。 */
  13206. export class MouseJoint extends Joint {
  13207. /** !#en
  13208. The anchor of the rigidbody.
  13209. !#zh
  13210. 刚体的锚点。 */
  13211. anchor: Vec2;
  13212. /** !#en
  13213. The anchor of the connected rigidbody.
  13214. !#zh
  13215. 关节另一端刚体的锚点。 */
  13216. connectedAnchor: Vec2;
  13217. /** !#en
  13218. The node used to register touch evnet.
  13219. If this is null, it will be the joint's node.
  13220. !#zh
  13221. 用于注册触摸事件的节点。
  13222. 如果没有设置这个值,那么将会使用关节的节点来注册事件。 */
  13223. mouseRegion: Node;
  13224. /** !#en
  13225. The target point.
  13226. The mouse joint will move choosed rigidbody to target point.
  13227. !#zh
  13228. 目标点,鼠标关节将会移动选中的刚体到指定的目标点 */
  13229. target: Vec2;
  13230. /** !#en
  13231. The spring frequency.
  13232. !#zh
  13233. 弹簧系数。 */
  13234. frequency: number;
  13235. /** !#en
  13236. The damping ratio.
  13237. !#zh
  13238. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13239. 0: number;
  13240. /** !#en
  13241. The maximum force
  13242. !#zh
  13243. 最大阻力值 */
  13244. maxForce: number;
  13245. }
  13246. /** !#en
  13247. A prismatic joint. This joint provides one degree of freedom: translation
  13248. along an axis fixed in rigidbody. Relative rotation is prevented. You can
  13249. use a joint limit to restrict the range of motion and a joint motor to
  13250. drive the motion or to model joint friction.
  13251. !#zh
  13252. 移动关节指定了只能在一个方向上移动刚体。
  13253. 你可以开启关节限制来设置刚体运行移动的间距,也可以开启马达来使用关节马达驱动刚体的运行。 */
  13254. export class PrismaticJoint extends Joint {
  13255. /** !#en
  13256. The local joint axis relative to rigidbody.
  13257. !#zh
  13258. 指定刚体可以移动的方向。 */
  13259. localAxisA: Vec2;
  13260. /** !#en
  13261. The reference angle.
  13262. !#zh
  13263. 相对角度 */
  13264. referenceAngle: number;
  13265. /** !#en
  13266. Enable joint distance limit?
  13267. !#zh
  13268. 是否开启关节的距离限制? */
  13269. enableLimit: boolean;
  13270. /** !#en
  13271. Enable joint motor?
  13272. !#zh
  13273. 是否开启关节马达? */
  13274. enableMotor: boolean;
  13275. /** !#en
  13276. The lower joint limit.
  13277. !#zh
  13278. 刚体能够移动的最小值 */
  13279. lowerLimit: number;
  13280. /** !#en
  13281. The upper joint limit.
  13282. !#zh
  13283. 刚体能够移动的最大值 */
  13284. upperLimit: number;
  13285. /** !#en
  13286. The maxium force can be applied to rigidbody to rearch the target motor speed.
  13287. !#zh
  13288. 可以施加到刚体的最大力。 */
  13289. maxMotorForce: number;
  13290. /** !#en
  13291. The expected motor speed.
  13292. !#zh
  13293. 期望的马达速度。 */
  13294. motorSpeed: number;
  13295. }
  13296. /** !#en
  13297. A revolute joint constrains two bodies to share a common point while they
  13298. are free to rotate about the point. The relative rotation about the shared
  13299. point is the joint angle. You can limit the relative rotation with
  13300. a joint limit that specifies a lower and upper angle. You can use a motor
  13301. to drive the relative rotation about the shared point. A maximum motor torque
  13302. is provided so that infinite forces are not generated.
  13303. !#zh
  13304. 旋转关节可以约束两个刚体围绕一个点来进行旋转。
  13305. 你可以通过开启关节限制来限制旋转的最大角度和最小角度。
  13306. 你可以通过开启马达来施加一个扭矩力来驱动这两个刚体在这一点上的相对速度。 */
  13307. export class RevoluteJoint extends Joint {
  13308. /** !#en
  13309. The reference angle.
  13310. An angle between bodies considered to be zero for the joint angle.
  13311. !#zh
  13312. 相对角度。
  13313. 两个物体之间角度为零时可以看作相等于关节角度 */
  13314. referenceAngle: number;
  13315. /** !#en
  13316. The lower angle.
  13317. !#zh
  13318. 角度的最低限制。 */
  13319. lowerAngle: number;
  13320. /** !#en
  13321. The upper angle.
  13322. !#zh
  13323. 角度的最高限制。 */
  13324. upperAngle: number;
  13325. /** !#en
  13326. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13327. !#zh
  13328. 可以施加到刚体的最大扭矩。 */
  13329. maxMotorTorque: number;
  13330. /** !#en
  13331. The expected motor speed.
  13332. !#zh
  13333. 期望的马达速度。 */
  13334. motorSpeed: number;
  13335. /** !#en
  13336. Enable joint limit?
  13337. !#zh
  13338. 是否开启关节的限制? */
  13339. enableLimit: boolean;
  13340. /** !#en
  13341. Enable joint motor?
  13342. !#zh
  13343. 是否开启关节马达? */
  13344. enableMotor: boolean;
  13345. /**
  13346. !#en
  13347. Get the joint angle.
  13348. !#zh
  13349. 获取关节角度。
  13350. */
  13351. getJointAngle(): number;
  13352. }
  13353. /** !#en
  13354. A rope joint enforces a maximum distance between two points
  13355. on two bodies. It has no other effect.
  13356. Warning: if you attempt to change the maximum length during
  13357. the simulation you will get some non-physical behavior.
  13358. !#zh
  13359. 绳子关节只指定两个刚体间的最大距离,没有其他的效果。
  13360. 注意:如果你试图动态修改关节的长度,这有可能会得到一些意外的效果。 */
  13361. export class RopeJoint extends Joint {
  13362. /** !#en
  13363. The max length.
  13364. !#zh
  13365. 最大长度。 */
  13366. maxLength: number;
  13367. }
  13368. /** !#en
  13369. A weld joint essentially glues two bodies together. A weld joint may
  13370. distort somewhat because the island constraint solver is approximate.
  13371. !#zh
  13372. 熔接关节相当于将两个刚体粘在了一起。
  13373. 熔接关节可能会使某些东西失真,因为约束求解器算出的都是近似值。 */
  13374. export class WeldJoint extends Joint {
  13375. /** !#en
  13376. The reference angle.
  13377. !#zh
  13378. 相对角度。 */
  13379. referenceAngle: number;
  13380. /** !#en
  13381. The frequency.
  13382. !#zh
  13383. 弹性系数。 */
  13384. frequency: number;
  13385. /** !#en
  13386. The damping ratio.
  13387. !#zh
  13388. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13389. 0: number;
  13390. }
  13391. /** !#en
  13392. A wheel joint. This joint provides two degrees of freedom: translation
  13393. along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
  13394. the rotation or to model rotational friction.
  13395. This joint is designed for vehicle suspensions.
  13396. !#zh
  13397. 轮子关节提供两个维度的自由度:旋转和沿着指定方向上位置的移动。
  13398. 你可以通过开启关节马达来使用马达驱动刚体的旋转。
  13399. 轮组关节是专门为机动车类型设计的。 */
  13400. export class WheelJoint extends Joint {
  13401. /** !#en
  13402. The local joint axis relative to rigidbody.
  13403. !#zh
  13404. 指定刚体可以移动的方向。 */
  13405. localAxisA: Vec2;
  13406. /** !#en
  13407. The maxium torque can be applied to rigidbody to rearch the target motor speed.
  13408. !#zh
  13409. 可以施加到刚体的最大扭矩。 */
  13410. maxMotorTorque: number;
  13411. /** !#en
  13412. The expected motor speed.
  13413. !#zh
  13414. 期望的马达速度。 */
  13415. motorSpeed: number;
  13416. /** !#en
  13417. Enable joint motor?
  13418. !#zh
  13419. 是否开启关节马达? */
  13420. enableMotor: boolean;
  13421. /** !#en
  13422. The spring frequency.
  13423. !#zh
  13424. 弹性系数。 */
  13425. frequency: number;
  13426. /** !#en
  13427. The damping ratio.
  13428. !#zh
  13429. 阻尼,表示关节变形后,恢复到初始状态受到的阻力。 */
  13430. dampingRatio: number;
  13431. }
  13432. /** undefined */
  13433. export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
  13434. /** !#en Position offset
  13435. !#zh 位置偏移量 */
  13436. offset: Vec2;
  13437. /** !#en Box size
  13438. !#zh 包围盒大小 */
  13439. size: Size;
  13440. }
  13441. /** undefined */
  13442. export class PhysicsChainCollider extends PolygonCollider {
  13443. /** !#en Whether the chain is loop
  13444. !#zh 链条是否首尾相连 */
  13445. loop: boolean;
  13446. /** !#en Chain points
  13447. !#zh 链条顶点数组 */
  13448. points: Vec2[];
  13449. }
  13450. /** undefined */
  13451. export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
  13452. /** !#en Position offset
  13453. !#zh 位置偏移量 */
  13454. offset: Vec2;
  13455. /** !#en Circle radius
  13456. !#zh 圆形半径 */
  13457. radius: number;
  13458. }
  13459. /** undefined */
  13460. export class PhysicsCollider {
  13461. /** !#en
  13462. The density.
  13463. !#zh
  13464. 密度 */
  13465. density: number;
  13466. /** !#en
  13467. A sensor collider collects contact information but never generates a collision response
  13468. !#zh
  13469. 一个传感器类型的碰撞体会产生碰撞回调,但是不会发生物理碰撞效果。 */
  13470. sensor: boolean;
  13471. /** !#en
  13472. The friction coefficient, usually in the range [0,1].
  13473. !#zh
  13474. 摩擦系数,取值一般在 [0, 1] 之间 */
  13475. friction: number;
  13476. /** !#en
  13477. The restitution (elasticity) usually in the range [0,1].
  13478. !#zh
  13479. 弹性系数,取值一般在 [0, 1]之间 */
  13480. restitution: number;
  13481. /** !#en
  13482. Physics collider will find the rigidbody component on the node and set to this property.
  13483. !#zh
  13484. 碰撞体会在初始化时查找节点上是否存在刚体,如果查找成功则赋值到这个属性上。 */
  13485. body: RigidBody;
  13486. /**
  13487. !#en
  13488. Apply current changes to collider, this will regenerate inner box2d fixtures.
  13489. !#zh
  13490. 应用当前 collider 中的修改,调用此函数会重新生成内部 box2d 的夹具。
  13491. */
  13492. apply(): void;
  13493. /**
  13494. !#en
  13495. Get the world aabb of the collider
  13496. !#zh
  13497. 获取碰撞体的世界坐标系下的包围盒
  13498. */
  13499. getAABB(): void;
  13500. }
  13501. /** undefined */
  13502. export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
  13503. /** !#en Position offset
  13504. !#zh 位置偏移量 */
  13505. offset: Vec2;
  13506. /** !#en Polygon points
  13507. !#zh 多边形顶点数组 */
  13508. points: Vec2[];
  13509. }
  13510. /****************************************************
  13511. * Node
  13512. *****************************************************/
  13513. export module Node {
  13514. /** !#en The event type supported by Node
  13515. !#zh Node 支持的事件类型 */
  13516. export class EventType {
  13517. /** !#en The event type for touch start event, you can use its value directly: 'touchstart'
  13518. !#zh 当手指触摸到屏幕时。 */
  13519. static TOUCH_START: string;
  13520. /** !#en The event type for touch move event, you can use its value directly: 'touchmove'
  13521. !#zh 当手指在屏幕上目标节点区域内移动时。 */
  13522. static TOUCH_MOVE: string;
  13523. /** !#en The event type for touch end event, you can use its value directly: 'touchend'
  13524. !#zh 当手指在目标节点区域内离开屏幕时。 */
  13525. static TOUCH_END: string;
  13526. /** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
  13527. !#zh 当手指在目标节点区域外离开屏幕时。 */
  13528. static TOUCH_CANCEL: string;
  13529. /** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
  13530. !#zh 当鼠标按下时触发一次。 */
  13531. static MOUSE_DOWN: string;
  13532. /** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
  13533. !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。 */
  13534. static MOUSE_MOVE: string;
  13535. /** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
  13536. !#zh 当鼠标移入目标节点区域时,不论是否按下。 */
  13537. static MOUSE_ENTER: string;
  13538. /** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
  13539. !#zh 当鼠标移出目标节点区域时,不论是否按下。 */
  13540. static MOUSE_LEAVE: string;
  13541. /** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
  13542. !#zh 当鼠标从按下状态松开时触发一次。 */
  13543. static MOUSE_UP: string;
  13544. /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
  13545. !#zh 当鼠标滚轮滚动时。 */
  13546. static MOUSE_WHEEL: string;
  13547. }
  13548. }
  13549. /****************************************************
  13550. * audioEngine
  13551. *****************************************************/
  13552. export module audioEngine {
  13553. /** !#en Audio state.
  13554. !#zh 声音播放状态 */
  13555. export enum AudioState {
  13556. ERROR = 0,
  13557. INITIALZING = 0,
  13558. PLAYING = 0,
  13559. PAUSED = 0,
  13560. }
  13561. }
  13562. /****************************************************
  13563. * ParticleSystem
  13564. *****************************************************/
  13565. export module ParticleSystem {
  13566. /** !#en Enum for emitter modes
  13567. !#zh 发射模式 */
  13568. export enum EmitterMode {
  13569. GRAVITY = 0,
  13570. RADIUS = 0,
  13571. }
  13572. }
  13573. /****************************************************
  13574. * ParticleSystem
  13575. *****************************************************/
  13576. export module ParticleSystem {
  13577. /** !#en Enum for particles movement type.
  13578. !#zh 粒子位置类型 */
  13579. export enum PositionType {
  13580. FREE = 0,
  13581. RELATIVE = 0,
  13582. GROUPED = 0,
  13583. }
  13584. }
  13585. /****************************************************
  13586. * TiledMap
  13587. *****************************************************/
  13588. export module TiledMap {
  13589. /** !#en The orientation of tiled map.
  13590. !#zh Tiled Map 地图方向。 */
  13591. export enum Orientation {
  13592. ORTHO = 0,
  13593. HEX = 0,
  13594. ISO = 0,
  13595. NONE = 0,
  13596. MAP = 0,
  13597. LAYER = 0,
  13598. OBJECTGROUP = 0,
  13599. OBJECT = 0,
  13600. TILE = 0,
  13601. HORIZONTAL = 0,
  13602. VERTICAL = 0,
  13603. DIAGONAL = 0,
  13604. FLIPPED_ALL = 0,
  13605. FLIPPED_MASK = 0,
  13606. STAGGERAXIS_X = 0,
  13607. STAGGERAXIS_Y = 0,
  13608. STAGGERINDEX_ODD = 0,
  13609. STAGGERINDEX_EVEN = 0,
  13610. }
  13611. }
  13612. /****************************************************
  13613. * Collider
  13614. *****************************************************/
  13615. export module Collider {
  13616. /** !#en Defines a Box Collider .
  13617. !#zh 用来定义包围盒碰撞体 */
  13618. export class Box {
  13619. /** !#en Position offset
  13620. !#zh 位置偏移量 */
  13621. offset: Vec2;
  13622. /** !#en Box size
  13623. !#zh 包围盒大小 */
  13624. size: Size;
  13625. }
  13626. }
  13627. /****************************************************
  13628. * Collider
  13629. *****************************************************/
  13630. export module Collider {
  13631. /** !#en Defines a Circle Collider .
  13632. !#zh 用来定义圆形碰撞体 */
  13633. export class Circle {
  13634. /** !#en Position offset
  13635. !#zh 位置偏移量 */
  13636. offset: Vec2;
  13637. /** !#en Circle radius
  13638. !#zh 圆形半径 */
  13639. radius: number;
  13640. }
  13641. }
  13642. /****************************************************
  13643. * Collider
  13644. *****************************************************/
  13645. export module Collider {
  13646. /** !#en Defines a Polygon Collider .
  13647. !#zh 用来定义多边形碰撞体 */
  13648. export class Polygon {
  13649. /** !#en Position offset
  13650. !#zh 位置偏移量 */
  13651. offset: Vec2;
  13652. /** !#en Polygon points
  13653. !#zh 多边形顶点数组 */
  13654. points: Vec2[];
  13655. }
  13656. }
  13657. /****************************************************
  13658. * Prefab
  13659. *****************************************************/
  13660. export module Prefab {
  13661. /** !#zh
  13662. Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。
  13663. !#en
  13664. An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}}
  13665. to specify how to optimize the instantiate operation. */
  13666. export enum OptimizationPolicy {
  13667. AUTO = 0,
  13668. SINGLE_INSTANCE = 0,
  13669. MULTI_INSTANCE = 0,
  13670. }
  13671. }
  13672. /****************************************************
  13673. * Button
  13674. *****************************************************/
  13675. export module Button {
  13676. /** !#en Enum for transition type.
  13677. !#zh 过渡类型 */
  13678. export enum Transition {
  13679. NONE = 0,
  13680. COLOR = 0,
  13681. SPRITE = 0,
  13682. SCALE = 0,
  13683. }
  13684. }
  13685. /****************************************************
  13686. * Component
  13687. *****************************************************/
  13688. export module Component {
  13689. /** !#en
  13690. Component will register a event to target component's handler.
  13691. And it will trigger the handler when a certain event occurs.
  13692. !@zh
  13693. “EventHandler” 类用来设置场景中的事件回调,
  13694. 该类允许用户设置回调目标节点,目标组件名,组件方法名,
  13695. 并可通过 emit 方法调用目标函数。 */
  13696. export class EventHandler {
  13697. /** !#en Event target
  13698. !#zh 目标节点 */
  13699. target: Node;
  13700. /** !#en Component name
  13701. !#zh 目标组件名 */
  13702. component: string;
  13703. /** !#en Event handler
  13704. !#zh 响应事件函数名 */
  13705. handler: string;
  13706. /** !#en Custom Event Data
  13707. !#zh 自定义事件数据 */
  13708. customEventData: string;
  13709. /**
  13710. @param events events
  13711. @param params params
  13712. */
  13713. static emitEvents(events: Component.EventHandler[], ...params: any[]): void;
  13714. /**
  13715. !#en Emit event with params
  13716. !#zh 触发目标组件上的指定 handler 函数,该参数是回调函数的参数值(可不填)。
  13717. @param params params
  13718. @example
  13719. ```js
  13720. // Call Function
  13721. var eventHandler = new cc.Component.EventHandler();
  13722. eventHandler.target = newTarget;
  13723. eventHandler.component = "MainMenu";
  13724. eventHandler.handler = "OnClick"
  13725. eventHandler.emit(["param1", "param2", ....]);
  13726. ```
  13727. */
  13728. emit(params: any[]): void;
  13729. }
  13730. }
  13731. /****************************************************
  13732. * EditBox
  13733. *****************************************************/
  13734. export module EditBox {
  13735. /** !#en Enum for keyboard return types
  13736. !#zh 键盘的返回键类型 */
  13737. export enum KeyboardReturnType {
  13738. DEFAULT = 0,
  13739. DONE = 0,
  13740. SEND = 0,
  13741. SEARCH = 0,
  13742. GO = 0,
  13743. }
  13744. }
  13745. /****************************************************
  13746. * EditBox
  13747. *****************************************************/
  13748. export module EditBox {
  13749. /** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
  13750. !#zh 输入模式 */
  13751. export enum InputMode {
  13752. ANY = 0,
  13753. EMAIL_ADDR = 0,
  13754. NUMERIC = 0,
  13755. PHONE_NUMBER = 0,
  13756. URL = 0,
  13757. DECIMAL = 0,
  13758. SINGLE_LINE = 0,
  13759. }
  13760. }
  13761. /****************************************************
  13762. * EditBox
  13763. *****************************************************/
  13764. export module EditBox {
  13765. /** !#en Enum for the EditBox's input flags
  13766. !#zh 定义了一些用于设置文本显示和文本格式化的标志位。 */
  13767. export enum InputFlag {
  13768. PASSWORD = 0,
  13769. SENSITIVE = 0,
  13770. INITIAL_CAPS_WORD = 0,
  13771. INITIAL_CAPS_SENTENCE = 0,
  13772. INITIAL_CAPS_ALL_CHARACTERS = 0,
  13773. }
  13774. }
  13775. /****************************************************
  13776. * Label
  13777. *****************************************************/
  13778. export module Label {
  13779. /** !#en Enum for text alignment.
  13780. !#zh 文本横向对齐类型 */
  13781. export enum HorizontalAlign {
  13782. LEFT = 0,
  13783. CENTER = 0,
  13784. RIGHT = 0,
  13785. }
  13786. }
  13787. /****************************************************
  13788. * Label
  13789. *****************************************************/
  13790. export module Label {
  13791. /** !#en Enum for vertical text alignment.
  13792. !#zh 文本垂直对齐类型 */
  13793. export enum VerticalAlign {
  13794. TOP = 0,
  13795. CENTER = 0,
  13796. BOTTOM = 0,
  13797. }
  13798. }
  13799. /****************************************************
  13800. * Label
  13801. *****************************************************/
  13802. export module Label {
  13803. /** !#en Enum for Overflow.
  13804. !#zh Overflow 类型 */
  13805. export enum Overflow {
  13806. NONE = 0,
  13807. CLAMP = 0,
  13808. SHRINK = 0,
  13809. RESIZE_HEIGHT = 0,
  13810. }
  13811. }
  13812. /****************************************************
  13813. * Label
  13814. *****************************************************/
  13815. export module Label {
  13816. /** !#en Enum for font type.
  13817. !#zh Type 类型 */
  13818. export enum Type {
  13819. TTF = 0,
  13820. BMFont = 0,
  13821. SystemFont = 0,
  13822. }
  13823. }
  13824. /****************************************************
  13825. * Layout
  13826. *****************************************************/
  13827. export module Layout {
  13828. /** !#en Enum for Layout type
  13829. !#zh 布局类型 */
  13830. export enum Type {
  13831. NONE = 0,
  13832. HORIZONTAL = 0,
  13833. VERTICAL = 0,
  13834. GRID = 0,
  13835. }
  13836. }
  13837. /****************************************************
  13838. * Layout
  13839. *****************************************************/
  13840. export module Layout {
  13841. /** !#en Enum for Layout Resize Mode
  13842. !#zh 缩放模式 */
  13843. export enum ResizeMode {
  13844. NONE = 0,
  13845. CONTAINER = 0,
  13846. CHILDREN = 0,
  13847. }
  13848. }
  13849. /****************************************************
  13850. * Layout
  13851. *****************************************************/
  13852. export module Layout {
  13853. /** !#en Enum for Grid Layout start axis direction.
  13854. The items in grid layout will be arranged in each axis at first.;
  13855. !#zh 布局轴向,只用于 GRID 布局。 */
  13856. export enum AxisDirection {
  13857. HORIZONTAL = 0,
  13858. VERTICAL = 0,
  13859. }
  13860. }
  13861. /****************************************************
  13862. * Layout
  13863. *****************************************************/
  13864. export module Layout {
  13865. /** !#en Enum for vertical layout direction.
  13866. Used in Grid Layout together with AxisDirection is VERTICAL
  13867. !#zh 垂直方向布局方式 */
  13868. export enum VerticalDirection {
  13869. BOTTOM_TO_TOP = 0,
  13870. TOP_TO_BOTTOM = 0,
  13871. }
  13872. }
  13873. /****************************************************
  13874. * Layout
  13875. *****************************************************/
  13876. export module Layout {
  13877. /** !#en Enum for horizontal layout direction.
  13878. Used in Grid Layout together with AxisDirection is HORIZONTAL
  13879. !#zh 水平方向布局方式 */
  13880. export enum HorizontalDirection {
  13881. LEFT_TO_RIGHT = 0,
  13882. RIGHT_TO_LEFT = 0,
  13883. }
  13884. }
  13885. /****************************************************
  13886. * Mask
  13887. *****************************************************/
  13888. export module Mask {
  13889. /** !#en the type for mask.
  13890. !#zh 遮罩组件类型 */
  13891. export enum Type {
  13892. RECT = 0,
  13893. ELLIPSE = 0,
  13894. IMAGE_STENCIL = 0,
  13895. }
  13896. }
  13897. /****************************************************
  13898. * PageView
  13899. *****************************************************/
  13900. export module PageView {
  13901. /** !#en The Page View Size Mode
  13902. !#zh 页面视图每个页面统一的大小类型 */
  13903. export enum SizeMode {
  13904. Unified = 0,
  13905. Free = 0,
  13906. }
  13907. }
  13908. /****************************************************
  13909. * PageView
  13910. *****************************************************/
  13911. export module PageView {
  13912. /** !#en The Page View Direction
  13913. !#zh 页面视图滚动类型 */
  13914. export enum Direction {
  13915. Horizontal = 0,
  13916. Vertical = 0,
  13917. }
  13918. }
  13919. /****************************************************
  13920. * PageView
  13921. *****************************************************/
  13922. export module PageView {
  13923. /** !#en Enum for ScrollView event type.
  13924. !#zh 滚动视图事件类型 */
  13925. export enum EventType {
  13926. PAGE_TURNING = 0,
  13927. }
  13928. }
  13929. /****************************************************
  13930. * PageViewIndicator
  13931. *****************************************************/
  13932. export module PageViewIndicator {
  13933. /** !#en Enum for PageView Indicator direction
  13934. !#zh 页面视图指示器的摆放方向 */
  13935. export enum Direction {
  13936. HORIZONTAL = 0,
  13937. VERTICAL = 0,
  13938. }
  13939. }
  13940. /****************************************************
  13941. * ProgressBar
  13942. *****************************************************/
  13943. export module ProgressBar {
  13944. /** !#en Enum for ProgressBar mode
  13945. !#zh 进度条模式 */
  13946. export enum Mode {
  13947. HORIZONTAL = 0,
  13948. VERTICAL = 0,
  13949. FILLED = 0,
  13950. }
  13951. }
  13952. /****************************************************
  13953. * Scrollbar
  13954. *****************************************************/
  13955. export module Scrollbar {
  13956. /** Enum for Scrollbar direction */
  13957. export enum Direction {
  13958. HORIZONTAL = 0,
  13959. VERTICAL = 0,
  13960. }
  13961. }
  13962. /****************************************************
  13963. * ScrollView
  13964. *****************************************************/
  13965. export module ScrollView {
  13966. /** !#en Enum for ScrollView event type.
  13967. !#zh 滚动视图事件类型 */
  13968. export enum EventType {
  13969. SCROLL_TO_TOP = 0,
  13970. SCROLL_TO_BOTTOM = 0,
  13971. SCROLL_TO_LEFT = 0,
  13972. SCROLL_TO_RIGHT = 0,
  13973. SCROLLING = 0,
  13974. BOUNCE_TOP = 0,
  13975. BOUNCE_BOTTOM = 0,
  13976. BOUNCE_LEFT = 0,
  13977. BOUNCE_RIGHT = 0,
  13978. SCROLL_ENDED = 0,
  13979. TOUCH_UP = 0,
  13980. AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
  13981. SCROLL_BEGAN = 0,
  13982. }
  13983. }
  13984. /****************************************************
  13985. * Slider
  13986. *****************************************************/
  13987. export module Slider {
  13988. /** !#en The Slider Direction
  13989. !#zh 滑动器方向 */
  13990. export enum Direction {
  13991. Horizontal = 0,
  13992. Vertical = 0,
  13993. }
  13994. }
  13995. /****************************************************
  13996. * Sprite
  13997. *****************************************************/
  13998. export module Sprite {
  13999. /** !#en Enum for sprite type.
  14000. !#zh Sprite 类型 */
  14001. export enum Type {
  14002. SIMPLE = 0,
  14003. SLICED = 0,
  14004. TILED = 0,
  14005. FILLED = 0,
  14006. }
  14007. }
  14008. /****************************************************
  14009. * Sprite
  14010. *****************************************************/
  14011. export module Sprite {
  14012. /** !#en Enum for fill type.
  14013. !#zh 填充类型 */
  14014. export enum FillType {
  14015. HORIZONTAL = 0,
  14016. VERTICAL = 0,
  14017. RADIAL = 0,
  14018. }
  14019. }
  14020. /****************************************************
  14021. * Sprite
  14022. *****************************************************/
  14023. export module Sprite {
  14024. /** !#en Sprite Size can track trimmed size, raw size or none.
  14025. !#zh 精灵尺寸调整模式 */
  14026. export enum SizeMode {
  14027. CUSTOM = 0,
  14028. TRIMMED = 0,
  14029. RAW = 0,
  14030. }
  14031. }
  14032. /****************************************************
  14033. * VideoPlayer
  14034. *****************************************************/
  14035. export module VideoPlayer {
  14036. /** !#en Video event type
  14037. !#zh 视频事件类型 */
  14038. export enum EventType {
  14039. PLAYING = 0,
  14040. PAUSED = 0,
  14041. STOPPED = 0,
  14042. COMPLETED = 0,
  14043. META_LOADED = 0,
  14044. CLICKED = 0,
  14045. READY_TO_PLAY = 0,
  14046. }
  14047. }
  14048. /****************************************************
  14049. * VideoPlayer
  14050. *****************************************************/
  14051. export module VideoPlayer {
  14052. /** !#en Enum for video resouce type type.
  14053. !#zh 视频来源 */
  14054. export enum ResourceType {
  14055. REMOTE = 0,
  14056. LOCAL = 0,
  14057. }
  14058. }
  14059. /****************************************************
  14060. * WebView
  14061. *****************************************************/
  14062. export module WebView {
  14063. /** !#en WebView event type
  14064. !#zh 网页视图事件类型 */
  14065. export enum EventType {
  14066. LOADED = 0,
  14067. LOADING = 0,
  14068. ERROR = 0,
  14069. }
  14070. }
  14071. /****************************************************
  14072. * Widget
  14073. *****************************************************/
  14074. export module Widget {
  14075. /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh.
  14076. !#zh Widget 的对齐模式,表示 Widget 应该何时刷新。 */
  14077. export enum AlignMode {
  14078. ONCE = 0,
  14079. ON_WINDOW_RESIZE = 0,
  14080. ALWAYS = 0,
  14081. }
  14082. }
  14083. /****************************************************
  14084. * Event
  14085. *****************************************************/
  14086. export module Event {
  14087. /** !#en The Custom event
  14088. !#zh 自定义事件 */
  14089. export class EventCustom extends Event {
  14090. /**
  14091. @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
  14092. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  14093. */
  14094. constructor(type: string, bubbles: boolean);
  14095. /** !#en A reference to the detailed data of the event
  14096. !#zh 事件的详细数据 */
  14097. detail: any;
  14098. /**
  14099. !#en Sets user data
  14100. !#zh 设置用户数据
  14101. @param data data
  14102. */
  14103. setUserData(data: any): void;
  14104. /**
  14105. !#en Gets user data
  14106. !#zh 获取用户数据
  14107. */
  14108. getUserData(): any;
  14109. /**
  14110. !#en Gets event name
  14111. !#zh 获取事件名称
  14112. */
  14113. getEventName(): string;
  14114. /** !#en
  14115. The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. </br>
  14116. This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.</br>
  14117. If the key can't be identified, this value is 0.</br>
  14118. !#zh
  14119. keyCode 是只读属性它表示一个系统和依赖于实现的数字代码,可以识别按键的未修改值。</br>
  14120. 这通常是十进制 ASCII (RFC20) 或者 Windows 1252 代码,所对应的密钥。</br>
  14121. 如果无法识别该键,则该值为 0。 */
  14122. keyCode: number;
  14123. }
  14124. }
  14125. /****************************************************
  14126. * SystemEvent
  14127. *****************************************************/
  14128. export module SystemEvent {
  14129. /** !#en The event type supported by SystemEvent
  14130. !#zh SystemEvent 支持的事件类型 */
  14131. export class EventType {
  14132. /** !#en The event type for press the key down event, you can use its value directly: 'keydown'
  14133. !#zh 当按下按键时触发的事件 */
  14134. static KEY_DOWN: string;
  14135. /** !#en The event type for press the key up event, you can use its value directly: 'keyup'
  14136. !#zh 当松开按键时触发的事件 */
  14137. static KEY_UP: string;
  14138. /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
  14139. !#zh 重力感应 */
  14140. static DEVICEMOTION: string;
  14141. }
  14142. }
  14143. /****************************************************
  14144. * Event
  14145. *****************************************************/
  14146. export module Event {
  14147. /** !#en The mouse event
  14148. !#zh 鼠标事件类型 */
  14149. export class EventMouse extends Event {
  14150. /**
  14151. !#en Sets scroll data.
  14152. !#zh 设置鼠标的滚动数据。
  14153. @param scrollX scrollX
  14154. @param scrollY scrollY
  14155. */
  14156. setScrollData(scrollX: number, scrollY: number): void;
  14157. /**
  14158. !#en Returns the x axis scroll value.
  14159. !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
  14160. */
  14161. getScrollX(): number;
  14162. /**
  14163. !#en Returns the y axis scroll value.
  14164. !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
  14165. */
  14166. getScrollY(): number;
  14167. /**
  14168. !#en Sets cursor location.
  14169. !#zh 设置当前鼠标位置。
  14170. @param x x
  14171. @param y y
  14172. */
  14173. setLocation(x: number, y: number): void;
  14174. /**
  14175. !#en Returns cursor location.
  14176. !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
  14177. */
  14178. getLocation(): Vec2;
  14179. /**
  14180. !#en Returns the current cursor location in screen coordinates.
  14181. !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
  14182. */
  14183. getLocationInView(): Vec2;
  14184. /**
  14185. !#en Returns the previous touch location.
  14186. !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
  14187. */
  14188. getPreviousLocation(): Vec2;
  14189. /**
  14190. !#en Returns the delta distance from the previous location to current location.
  14191. !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14192. */
  14193. getDelta(): Vec2;
  14194. /**
  14195. !#en Returns the X axis delta distance from the previous location to current location.
  14196. !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
  14197. */
  14198. getDeltaX(): number;
  14199. /**
  14200. !#en Returns the Y axis delta distance from the previous location to current location.
  14201. !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
  14202. */
  14203. getDeltaY(): number;
  14204. /**
  14205. !#en Sets mouse button.
  14206. !#zh 设置鼠标按键。
  14207. @param button button
  14208. */
  14209. setButton(button: number): void;
  14210. /**
  14211. !#en Returns mouse button.
  14212. !#zh 获取鼠标按键。
  14213. */
  14214. getButton(): number;
  14215. /**
  14216. !#en Returns location X axis data.
  14217. !#zh 获取鼠标当前位置 X 轴。
  14218. */
  14219. getLocationX(): number;
  14220. /**
  14221. !#en Returns location Y axis data.
  14222. !#zh 获取鼠标当前位置 Y 轴。
  14223. */
  14224. getLocationY(): number;
  14225. /** !#en The none event code of mouse event.
  14226. !#zh 无。 */
  14227. static NONE: number;
  14228. /** !#en The event type code of mouse down event.
  14229. !#zh 鼠标按下事件。 */
  14230. static DOWN: number;
  14231. /** !#en The event type code of mouse up event.
  14232. !#zh 鼠标按下后释放事件。 */
  14233. static UP: number;
  14234. /** !#en The event type code of mouse move event.
  14235. !#zh 鼠标移动事件。 */
  14236. static MOVE: number;
  14237. /** !#en The event type code of mouse scroll event.
  14238. !#zh 鼠标滚轮事件。 */
  14239. static SCROLL: number;
  14240. /** !#en The tag of Mouse left button.
  14241. !#zh 鼠标左键的标签。 */
  14242. static BUTTON_LEFT: number;
  14243. /** !#en The tag of Mouse right button (The right button number is 2 on browser).
  14244. !#zh 鼠标右键的标签。 */
  14245. static BUTTON_RIGHT: number;
  14246. /** !#en The tag of Mouse middle button (The right button number is 1 on browser).
  14247. !#zh 鼠标中键的标签。 */
  14248. static BUTTON_MIDDLE: number;
  14249. /** !#en The tag of Mouse button 4.
  14250. !#zh 鼠标按键 4 的标签。 */
  14251. static BUTTON_4: number;
  14252. /** !#en The tag of Mouse button 5.
  14253. !#zh 鼠标按键 5 的标签。 */
  14254. static BUTTON_5: number;
  14255. /** !#en The tag of Mouse button 6.
  14256. !#zh 鼠标按键 6 的标签。 */
  14257. static BUTTON_6: number;
  14258. /** !#en The tag of Mouse button 7.
  14259. !#zh 鼠标按键 7 的标签。 */
  14260. static BUTTON_7: number;
  14261. /** !#en The tag of Mouse button 8.
  14262. !#zh 鼠标按键 8 的标签。 */
  14263. static BUTTON_8: number;
  14264. }
  14265. }
  14266. /****************************************************
  14267. * Event
  14268. *****************************************************/
  14269. export module Event {
  14270. /** !#en The touch event
  14271. !#zh 触摸事件 */
  14272. export class EventTouch extends Event {
  14273. /**
  14274. @param touchArr The array of the touches
  14275. @param bubbles A boolean indicating whether the event bubbles up through the tree or not
  14276. */
  14277. constructor(touchArr: any[], bubbles: boolean);
  14278. /** !#en The current touch object
  14279. !#zh 当前触点对象 */
  14280. touch: Touch;
  14281. /**
  14282. !#en Returns event code.
  14283. !#zh 获取事件类型。
  14284. */
  14285. getEventCode(): number;
  14286. /**
  14287. !#en Returns touches of event.
  14288. !#zh 获取触摸点的列表。
  14289. */
  14290. getTouches(): any[];
  14291. /**
  14292. !#en Sets touch location.
  14293. !#zh 设置当前触点位置
  14294. @param x x
  14295. @param y y
  14296. */
  14297. setLocation(x: number, y: number): void;
  14298. /**
  14299. !#en Returns touch location.
  14300. !#zh 获取触点位置。
  14301. */
  14302. getLocation(): Vec2;
  14303. /**
  14304. !#en Returns the current touch location in screen coordinates.
  14305. !#zh 获取当前触点在游戏窗口中的位置。
  14306. */
  14307. getLocationInView(): Vec2;
  14308. /**
  14309. !#en Returns the previous touch location.
  14310. !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
  14311. */
  14312. getPreviousLocation(): Vec2;
  14313. /**
  14314. !#en Returns the start touch location.
  14315. !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
  14316. */
  14317. getStartLocation(): Vec2;
  14318. /**
  14319. !#en Returns the id of cc.Touch.
  14320. !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
  14321. */
  14322. getID(): number;
  14323. /**
  14324. !#en Returns the delta distance from the previous location to current location.
  14325. !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
  14326. */
  14327. getDelta(): Vec2;
  14328. /**
  14329. !#en Returns the X axis delta distance from the previous location to current location.
  14330. !#zh 获取触点距离上一次事件移动的 x 轴距离。
  14331. */
  14332. getDeltaX(): number;
  14333. /**
  14334. !#en Returns the Y axis delta distance from the previous location to current location.
  14335. !#zh 获取触点距离上一次事件移动的 y 轴距离。
  14336. */
  14337. getDeltaY(): number;
  14338. /**
  14339. !#en Returns location X axis data.
  14340. !#zh 获取当前触点 X 轴位置。
  14341. */
  14342. getLocationX(): number;
  14343. /**
  14344. !#en Returns location Y axis data.
  14345. !#zh 获取当前触点 Y 轴位置。
  14346. */
  14347. getLocationY(): number;
  14348. }
  14349. }
  14350. /****************************************************
  14351. * Event
  14352. *****************************************************/
  14353. export module Event {
  14354. /** !#en The acceleration event
  14355. !#zh 加速度事件 */
  14356. export class EventAcceleration extends Event {
  14357. }
  14358. }
  14359. /****************************************************
  14360. * Event
  14361. *****************************************************/
  14362. export module Event {
  14363. /** !#en The keyboard event
  14364. !#zh 键盘事件 */
  14365. export class EventKeyboard extends Event {
  14366. }
  14367. }
  14368. /****************************************************
  14369. * Pipeline
  14370. *****************************************************/
  14371. export module Pipeline {
  14372. /** The downloader pipe, it can download several types of files:
  14373. 1. Text
  14374. 2. Image
  14375. 3. Script
  14376. 4. Audio
  14377. 5. Assets
  14378. All unknown type will be downloaded as plain text.
  14379. You can pass custom supported types in the constructor. */
  14380. export class Downloader {
  14381. /**
  14382. Constructor of Downloader, you can pass custom supported types.
  14383. @param extMap Custom supported types with corresponded handler
  14384. @example
  14385. ```js
  14386. var downloader = new Downloader({
  14387. // This will match all url with `.scene` extension or all url with `scene` type
  14388. 'scene' : function (url, callback) {}
  14389. });
  14390. ```
  14391. */
  14392. constructor(extMap: any);
  14393. /**
  14394. Add custom supported types handler or modify existing type handler.
  14395. @param extMap Custom supported types with corresponded handler
  14396. */
  14397. addHandlers(extMap: any): void;
  14398. /**
  14399. !#en
  14400. Load subpackage with name.
  14401. !#zh
  14402. 通过子包名加载子包代码。
  14403. @param name Subpackage name
  14404. @param completeCallback Callback invoked when subpackage loaded
  14405. */
  14406. loadSubpackage(name: string, completeCallback?: (error: Error) => void): void;
  14407. }
  14408. }
  14409. /****************************************************
  14410. * Pipeline
  14411. *****************************************************/
  14412. export module Pipeline {
  14413. /** The loader pipe, it can load several types of files:
  14414. 1. Images
  14415. 2. JSON
  14416. 3. Plist
  14417. 4. Audio
  14418. 5. Font
  14419. 6. Cocos Creator scene
  14420. It will not interfere with items of unknown type.
  14421. You can pass custom supported types in the constructor. */
  14422. export class Loader {
  14423. /**
  14424. Constructor of Loader, you can pass custom supported types.
  14425. @param extMap Custom supported types with corresponded handler
  14426. @example
  14427. ```js
  14428. var loader = new Loader({
  14429. // This will match all url with `.scene` extension or all url with `scene` type
  14430. 'scene' : function (url, callback) {}
  14431. });
  14432. ```
  14433. */
  14434. constructor(extMap: any);
  14435. /**
  14436. Add custom supported types handler or modify existing type handler.
  14437. @param extMap Custom supported types with corresponded handler
  14438. */
  14439. addHandlers(extMap: any): void;
  14440. }
  14441. }
  14442. /****************************************************
  14443. * LoadingItems
  14444. *****************************************************/
  14445. export module LoadingItems {
  14446. /** !#en The item states of the LoadingItems, its value could be LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR
  14447. !#zh LoadingItems 队列中的加载项状态,状态的值可能是 LoadingItems.ItemState.WORKING | LoadingItems.ItemState.COMPLETET | LoadingItems.ItemState.ERROR */
  14448. export enum ItemState {
  14449. WORKING = 0,
  14450. COMPLETET = 0,
  14451. ERROR = 0,
  14452. }
  14453. }
  14454. /****************************************************
  14455. * Graphics
  14456. *****************************************************/
  14457. export module Graphics {
  14458. /** !#en Enum for LineCap.
  14459. !#zh 线段末端属性 */
  14460. export enum LineCap {
  14461. BUTT = 0,
  14462. ROUND = 0,
  14463. SQUARE = 0,
  14464. }
  14465. }
  14466. /****************************************************
  14467. * Graphics
  14468. *****************************************************/
  14469. export module Graphics {
  14470. /** !#en Enum for LineJoin.
  14471. !#zh 线段拐角属性 */
  14472. export enum LineJoin {
  14473. BEVEL = 0,
  14474. ROUND = 0,
  14475. MITER = 0,
  14476. }
  14477. }
  14478. /****************************************************
  14479. * Texture2D
  14480. *****************************************************/
  14481. export module Texture2D {
  14482. /** The texture pixel format, default value is RGBA8888 */
  14483. export enum PixelFormat {
  14484. RGB565 = 0,
  14485. RGB5A1 = 0,
  14486. RGBA4444 = 0,
  14487. RGB888 = 0,
  14488. RGBA8888 = 0,
  14489. A8 = 0,
  14490. I8 = 0,
  14491. AI88 = 0,
  14492. }
  14493. }
  14494. /****************************************************
  14495. * Texture2D
  14496. *****************************************************/
  14497. export module Texture2D {
  14498. /** The texture wrap mode */
  14499. export enum WrapMode {
  14500. REPEAT = 0,
  14501. CLAMP_TO_EDGE = 0,
  14502. MIRRORED_REPEAT = 0,
  14503. }
  14504. }
  14505. /****************************************************
  14506. * Texture2D
  14507. *****************************************************/
  14508. export module Texture2D {
  14509. /** The texture filter mode */
  14510. export enum Filter {
  14511. LINEAR = 0,
  14512. NEAREST = 0,
  14513. }
  14514. }
  14515. }
  14516. /** !#en
  14517. 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.
  14518. !#zh
  14519. AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
  14520. 目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。 */
  14521. declare module anysdk {
  14522. /** !#en
  14523. agent manager of plugin
  14524. !#zh
  14525. 插件管理对象 */
  14526. export var agentManager: anysdk.AgentManager;
  14527. /** !#en
  14528. agent manager of plugin
  14529. !#zh
  14530. 插件管理类 */
  14531. export class AgentManager {
  14532. /**
  14533. !#en
  14534. AppKey appSecret and privateKey are the only three parameters generated
  14535. after the packing tool client finishes creating the game.
  14536. The oauthLoginServer parameter is the API address provided by the game service
  14537. to login verification
  14538. !#zh
  14539. appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
  14540. oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
  14541. @param appKey appKey
  14542. @param appSecret appSecret
  14543. @param privateKey privateKey
  14544. @param oauthLoginServer oauthLoginServer
  14545. */
  14546. init(appKey: string, appSecret: string, privateKey: string, oauthLoginServer: string): void;
  14547. /**
  14548. !#en
  14549. load all plugins, the operation includes SDK`s initialization
  14550. !#zh
  14551. 加载所有插件,该操作包含了 SDKs 初始化
  14552. @param callback callback
  14553. @param target The object to bind to.
  14554. */
  14555. loadAllPlugins(callback: Function, target: any): void;
  14556. /**
  14557. !#en
  14558. unload all plugins
  14559. !#zh
  14560. 卸载插件
  14561. */
  14562. unloadAllPlugins(): void;
  14563. /**
  14564. !#en
  14565. get user system plugin
  14566. !#zh
  14567. 获取用户系统插件
  14568. */
  14569. getUserPlugin(): anysdk.ProtocolUser;
  14570. /**
  14571. !#en
  14572. get IAP system plugins
  14573. !#zh
  14574. 获取支付系统插件
  14575. */
  14576. getIAPPlugins(): anysdk.ProtocolIAP[];
  14577. /**
  14578. !#en
  14579. get IAP system plugin
  14580. !#zh
  14581. 获取支付系统插件
  14582. */
  14583. getIAPPlugin(): anysdk.ProtocolIAP;
  14584. /**
  14585. !#en
  14586. get social system plugin
  14587. !#zh
  14588. 获取社交系统插件
  14589. */
  14590. getSocialPlugin(): anysdk.ProtocolSocial;
  14591. /**
  14592. !#en
  14593. get share system plugin
  14594. !#zh
  14595. 获取分享系统插件
  14596. */
  14597. getSharePlugin(): anysdk.ProtocolShare;
  14598. /**
  14599. !#en
  14600. get analytics system plugin
  14601. !#zh
  14602. 获取统计系统插件
  14603. */
  14604. getAnalyticsPlugin(): anysdk.ProtocolAnalytics;
  14605. /**
  14606. !#en
  14607. get ads system plugin
  14608. !#zh
  14609. 获取广告系统插件
  14610. */
  14611. getAdsPlugin(): anysdk.ProtocolAds;
  14612. /**
  14613. !#en
  14614. get push system plugin
  14615. !#zh
  14616. 获取推送系统插件
  14617. */
  14618. getPushPlugin(): anysdk.ProtocolPush;
  14619. /**
  14620. !#en
  14621. get REC system plugin
  14622. !#zh
  14623. 获取录屏系统插件
  14624. */
  14625. getRECPlugin(): anysdk.ProtocolREC;
  14626. /**
  14627. !#en
  14628. get crash system plugin
  14629. !#zh
  14630. 获取崩溃分析系统插件
  14631. */
  14632. getCrashPlugin(): anysdk.ProtocolCrash;
  14633. /**
  14634. !#en
  14635. get ad track system plugin
  14636. !#zh
  14637. 获取广告追踪系统插件
  14638. */
  14639. getAdTrackingPlugin(): anysdk.ProtocolAdTracking;
  14640. /**
  14641. !#en
  14642. get custom system plugin
  14643. !#zh
  14644. 获取自定义系统插件
  14645. */
  14646. getCustomPlugin(): anysdk.ProtocolCustom;
  14647. /**
  14648. !#en
  14649. get custom parameter
  14650. !#zh
  14651. 获取自定义参数
  14652. */
  14653. getCustomParam(): string;
  14654. /**
  14655. !#en
  14656. get channel id
  14657. !#zh
  14658. 获取渠道唯一表示符
  14659. */
  14660. getChannelId(): string;
  14661. /**
  14662. !#en
  14663. get status of analytics
  14664. !#zh
  14665. 获取统计状态
  14666. */
  14667. isAnaylticsEnabled(): boolean;
  14668. /**
  14669. !#en
  14670. set whether to analytics
  14671. !#zh
  14672. 设置是否统计
  14673. @param enabled enabled
  14674. */
  14675. setIsAnaylticsEnabled(enabled: boolean): void;
  14676. /**
  14677. !#en
  14678. destory instance
  14679. !#zh
  14680. 销毁单例
  14681. */
  14682. static end(): void;
  14683. /**
  14684. !#en
  14685. get instance
  14686. !#zh
  14687. 获取单例
  14688. */
  14689. static getInstance(): anysdk.AgentManager;
  14690. }
  14691. /** !#en
  14692. plugin protocol
  14693. !#zh
  14694. 插件协议 */
  14695. export class PluginProtocol {
  14696. /**
  14697. !#en
  14698. Check whether the function is supported
  14699. !#zh
  14700. 判断函数是否支持
  14701. @param functionName functionName
  14702. */
  14703. isFunctionSupported(functionName: string): boolean;
  14704. /**
  14705. !#en
  14706. get plugin name
  14707. !#zh
  14708. 获取插件名称
  14709. */
  14710. getPluginName(): string;
  14711. /**
  14712. !#en
  14713. get plugin version
  14714. !#zh
  14715. 获取插件版本
  14716. */
  14717. getPluginVersion(): string;
  14718. /**
  14719. !#en
  14720. get SDK version
  14721. !#zh
  14722. 获取 SDK 版本
  14723. */
  14724. getSDKVersion(): string;
  14725. /**
  14726. !#en
  14727. void methods for reflections with parameter
  14728. !#zh
  14729. 反射调用带参数的void方法
  14730. @param funName funName
  14731. @param args optional arguments
  14732. */
  14733. callFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): void;
  14734. /**
  14735. !#en
  14736. String methods for reflections with parameter
  14737. !#zh
  14738. 反射调用带参数的 String 方法
  14739. @param funName funName
  14740. @param args optional arguments
  14741. */
  14742. callStringFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): string;
  14743. /**
  14744. !#en
  14745. int methods for reflections with parameter
  14746. !#zh
  14747. 反射调用带参数的 Int 方法
  14748. @param funName funName
  14749. @param args optional arguments
  14750. */
  14751. callIntFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14752. /**
  14753. !#en
  14754. boolean methods for reflections with parameter
  14755. !#zh
  14756. 反射调用带参数的 boolean 方法
  14757. @param funName funName
  14758. @param args optional arguments
  14759. */
  14760. callBoolFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): boolean;
  14761. /**
  14762. !#en
  14763. float methods for reflections with parameter
  14764. !#zh
  14765. 反射调用带参数的 float 方法
  14766. @param funName funName
  14767. @param args optional arguments
  14768. */
  14769. callFloatFuncWithParam(funName: string, ...args: any|anysdk.PluginParam[]): number;
  14770. }
  14771. /** !#en
  14772. user protocol
  14773. !#zh
  14774. 用户系统协议接口 */
  14775. export class ProtocolUser extends PluginProtocol {
  14776. /**
  14777. !#en
  14778. login interface
  14779. !#zh
  14780. 登录接口
  14781. @param args optional arguments
  14782. */
  14783. login(...args: string|any[]): void;
  14784. /**
  14785. !#en
  14786. get status of login
  14787. !#zh
  14788. 获取登录状态
  14789. */
  14790. isLogined(): boolean;
  14791. /**
  14792. !#en
  14793. get user ID
  14794. !#zh
  14795. 获取用户唯一标示符
  14796. */
  14797. getUserID(): string;
  14798. /**
  14799. !#en
  14800. get plugin ID
  14801. !#zh
  14802. 获取插件ID
  14803. */
  14804. getPluginId(): string;
  14805. /**
  14806. !#en
  14807. set listener
  14808. !#zh
  14809. 设置用户系统的监听
  14810. @param listener listener
  14811. @param target target
  14812. */
  14813. setListener(listener: Function, target: any): void;
  14814. /**
  14815. !#en
  14816. get listener
  14817. !#zh
  14818. 获取用户系统的监听
  14819. */
  14820. getListener(): Function;
  14821. /**
  14822. !#en
  14823. logout
  14824. Before to invoke, you need to verdict whether this properties existed
  14825. !#zh
  14826. 登出,调用前需要判断属性是否存在
  14827. */
  14828. logout(): void;
  14829. /**
  14830. !#en
  14831. show toolbar
  14832. Before to invoke, you need to verdict whether this properties existed
  14833. !#zh
  14834. 显示悬浮窗,调用前需要判断属性是否存在
  14835. @param place place
  14836. */
  14837. showToolBar(place: anysdk.ToolBarPlace): void;
  14838. /**
  14839. !#en
  14840. hide toolbar
  14841. Before to invoke, you need to verdict whether this properties existed
  14842. !#zh
  14843. 隐藏悬浮窗,调用前需要判断属性是否存在
  14844. */
  14845. hideToolBar(): void;
  14846. /**
  14847. !#en
  14848. enter platform
  14849. Before to invoke, you need to verdict whether this properties existed
  14850. !#zh
  14851. 显示平台中心,调用前需要判断属性是否存在
  14852. */
  14853. enterPlatform(): void;
  14854. /**
  14855. !#en
  14856. show exit page
  14857. Before to invoke, you need to verdict whether this properties existed
  14858. !#zh
  14859. 显示退出界面,调用前需要判断属性是否存在
  14860. */
  14861. exit(): void;
  14862. /**
  14863. !#en
  14864. show pause page
  14865. Before to invoke, you need to verdict whether this properties existed
  14866. !#zh
  14867. 显示暂停界面,调用前需要判断属性是否存在
  14868. */
  14869. pause(): void;
  14870. /**
  14871. !#en
  14872. Real-name registration
  14873. Before to invoke, you need to verdict whether this properties existed
  14874. !#zh
  14875. 实名注册,调用前需要判断属性是否存在
  14876. */
  14877. realNameRegister(): void;
  14878. /**
  14879. !#en
  14880. Anti-addiction query
  14881. Before to invoke, you need to verdict whether this properties existed
  14882. !#zh
  14883. 防沉迷查询,调用前需要判断属性是否存在
  14884. */
  14885. antiAddictionQuery(): void;
  14886. /**
  14887. !#en
  14888. submit game role information
  14889. Before to invoke, you need to verdict whether this properties existed
  14890. !#zh
  14891. 提交角色信息,调用前需要判断属性是否存在
  14892. @param data data
  14893. */
  14894. submitLoginGameRole(data: any): void;
  14895. /**
  14896. !#en
  14897. get user information
  14898. Before to invoke, you need to verdict whether this properties existed
  14899. !#zh
  14900. 获取用户信息,调用前需要判断属性是否存在
  14901. @param info info
  14902. */
  14903. getUserInfo(info: any): void;
  14904. /**
  14905. !#en
  14906. set login type
  14907. Before to invoke, you need to verdict whether this properties existed
  14908. !#zh
  14909. 设置登录类型,调用前需要判断属性是否存在
  14910. @param info info
  14911. */
  14912. getAvailableLoginType(info: any): void;
  14913. /**
  14914. !#en
  14915. set login type
  14916. Before to invoke, you need to verdict whether this properties existed
  14917. !#zh
  14918. 设置登录类型,调用前需要判断属性是否存在
  14919. @param loginType loginType
  14920. */
  14921. setLoginType(loginType: string): void;
  14922. /**
  14923. !#en
  14924. send to desktop
  14925. Before to invoke, you need to verdict whether this properties existed
  14926. !#zh
  14927. 发送到桌面,调用前需要判断属性是否存在
  14928. */
  14929. sendToDesktop(): void;
  14930. /**
  14931. !#en
  14932. open bbs
  14933. Before to invoke, you need to verdict whether this properties existed
  14934. !#zh
  14935. 打开论坛,调用前需要判断属性是否存在
  14936. */
  14937. openBBS(): void;
  14938. }
  14939. /** !#en
  14940. IAP protocol
  14941. !#zh
  14942. 支付系统协议接口 */
  14943. export class ProtocolIAP extends PluginProtocol {
  14944. /**
  14945. !#en
  14946. pay interface
  14947. !#zh
  14948. 支付接口
  14949. @param info Type:map
  14950. */
  14951. payForProduct(info: any): void;
  14952. /**
  14953. !#en
  14954. get order ID
  14955. !#zh
  14956. 获取订单ID
  14957. */
  14958. getOrderId(): string;
  14959. /**
  14960. !#en
  14961. reset the pay status
  14962. !#zh
  14963. 重置支付状态
  14964. */
  14965. static resetPayState(): void;
  14966. /**
  14967. !#en
  14968. get plugin ID
  14969. !#zh
  14970. 获取插件ID
  14971. */
  14972. getPluginId(): string;
  14973. /**
  14974. !#en
  14975. set listener
  14976. !#zh
  14977. 设置支付系统的监听
  14978. @param listener listener
  14979. @param target target
  14980. */
  14981. setListener(listener: Function, target: any): void;
  14982. /**
  14983. !#en
  14984. get listener
  14985. !#zh
  14986. 获取支付系统的监听
  14987. */
  14988. getListener(): Function;
  14989. }
  14990. /** !#en
  14991. analytics protocol
  14992. !#zh
  14993. 统计系统协议接口 */
  14994. export class ProtocolAnalytics extends PluginProtocol {
  14995. /**
  14996. !#en
  14997. Start a new session.
  14998. !#zh
  14999. 启动会话
  15000. */
  15001. startSession(): void;
  15002. /**
  15003. !#en
  15004. Stop a session.
  15005. !#zh
  15006. 关闭会话
  15007. */
  15008. stopSession(): void;
  15009. /**
  15010. !#en
  15011. Set the timeout for expiring a session.
  15012. !#zh
  15013. 设置会话超时时间
  15014. @param millis Type: long
  15015. */
  15016. setSessionContinueMillis(millis: number): void;
  15017. /**
  15018. !#en
  15019. log an error
  15020. !#zh
  15021. 捕捉异常
  15022. @param errorId errorId
  15023. @param message message
  15024. */
  15025. logError(errorId: string, message: string): void;
  15026. /**
  15027. !#en
  15028. log an event.
  15029. !#zh
  15030. 捕捉事件
  15031. @param errorId errorId
  15032. @param args optional arguments Type: map
  15033. */
  15034. logEvent(errorId: string, ...args: any[]): void;
  15035. /**
  15036. !#en
  15037. Track an event begin.
  15038. !#zh
  15039. 统计事件开始
  15040. @param eventId eventId
  15041. */
  15042. logTimedEventBegin(eventId: string): void;
  15043. /**
  15044. !#en
  15045. Track an event end.
  15046. !#zh
  15047. 统计事件结束
  15048. @param eventId eventId
  15049. */
  15050. logTimedEventEnd(eventId: string): void;
  15051. /**
  15052. !#en
  15053. set Whether to catch uncaught exceptions to server.
  15054. !#zh
  15055. 设置是否开启自动异常捕捉
  15056. @param enabled enabled
  15057. */
  15058. setCaptureUncaughtException(enabled: boolean): void;
  15059. /**
  15060. !#en
  15061. analytics account information
  15062. !#zh
  15063. 统计玩家帐户信息
  15064. @param paramMap Type: map
  15065. */
  15066. setAccount(paramMap: any): void;
  15067. /**
  15068. !#en
  15069. track user to request payment
  15070. !#zh
  15071. 跟踪用户支付请求
  15072. @param paramMap Type: map
  15073. */
  15074. onChargeRequest(paramMap: any): void;
  15075. /**
  15076. !#en
  15077. track Successful payment
  15078. !#zh
  15079. 追踪用户支付成功
  15080. @param orderID orderID
  15081. */
  15082. onChargeSuccess(orderID: string): void;
  15083. /**
  15084. !#en
  15085. track failed payment
  15086. !#zh
  15087. 追踪用户支付失败
  15088. @param paramMap Type: map
  15089. */
  15090. onChargeFail(paramMap: any): void;
  15091. /**
  15092. !#en
  15093. track Successful payment
  15094. !#zh
  15095. 统计玩家支付成功
  15096. @param paramMap Type: map
  15097. */
  15098. onChargeOnlySuccess(paramMap: any): void;
  15099. /**
  15100. !#en
  15101. track user purchase
  15102. !#zh
  15103. 统计玩家消费
  15104. @param paramMap Type: map
  15105. */
  15106. onPurchase(paramMap: any): void;
  15107. /**
  15108. !#en
  15109. track user to use goods
  15110. !#zh
  15111. 统计玩家使用道具
  15112. @param paramMap Type: map
  15113. */
  15114. onUse(paramMap: any): void;
  15115. /**
  15116. !#en
  15117. track user to reward goods
  15118. !#zh
  15119. 统计玩家获取奖励
  15120. @param paramMap Type: map
  15121. */
  15122. onReward(paramMap: any): void;
  15123. /**
  15124. !#en
  15125. start level
  15126. !#zh
  15127. 开始关卡
  15128. @param paramMap Type: map
  15129. */
  15130. startLevel(paramMap: any): void;
  15131. /**
  15132. !#en
  15133. finish level
  15134. !#zh
  15135. 结束关卡
  15136. @param levelID levelID
  15137. */
  15138. finishLevel(levelID: string): void;
  15139. /**
  15140. !#en
  15141. failed level
  15142. !#zh
  15143. 关卡失败
  15144. @param paramMap Type: map
  15145. */
  15146. failLevel(paramMap: any): void;
  15147. /**
  15148. !#en
  15149. start task
  15150. !#zh
  15151. 开始任务
  15152. @param paramMap Type: map
  15153. */
  15154. startTask(paramMap: any): void;
  15155. /**
  15156. !#en
  15157. finish task
  15158. !#zh
  15159. 完成任务
  15160. @param taskID taskID
  15161. */
  15162. finishTask(taskID: string): void;
  15163. /**
  15164. !#en
  15165. failed task
  15166. !#zh
  15167. 任务失败
  15168. @param paramMap Type: map
  15169. */
  15170. failTask(paramMap: any): void;
  15171. }
  15172. /** !#en
  15173. share protocol
  15174. !#zh
  15175. 分享系统协议接口 */
  15176. export class ProtocolShare extends PluginProtocol {
  15177. /**
  15178. !#en
  15179. share interface
  15180. !#zh
  15181. 分享
  15182. @param info Type: map
  15183. */
  15184. share(info: any): void;
  15185. /**
  15186. !#en
  15187. set listener
  15188. !#zh
  15189. 设置分享系统的监听
  15190. @param listener listener
  15191. @param target target
  15192. */
  15193. setListener(listener: Function, target: any): void;
  15194. /**
  15195. !#en
  15196. get listener
  15197. !#zh
  15198. 获取分享系统的监听
  15199. */
  15200. getListener(): Function;
  15201. }
  15202. /** !#en
  15203. ads protocol
  15204. !#zh
  15205. 广告系统协议接口 */
  15206. export class ProtocolAds extends PluginProtocol {
  15207. /**
  15208. !#en
  15209. hide ads view
  15210. !#zh
  15211. 隐藏广告
  15212. @param adstype adstype
  15213. @param idx idx
  15214. */
  15215. hideAds(adstype: anysdk.AdsType, idx: number): void;
  15216. /**
  15217. !#en
  15218. preload ads view
  15219. !#zh
  15220. 预加载广告
  15221. @param adstype adstype
  15222. @param idx idx
  15223. */
  15224. preloadAds(adstype: anysdk.AdsType, idx: number): void;
  15225. /**
  15226. !#en
  15227. query points
  15228. !#zh
  15229. 查询分数
  15230. */
  15231. queryPoints(): number;
  15232. /**
  15233. !#en
  15234. get whether the ads type is supported
  15235. !#zh
  15236. 获取广告类型是否支持
  15237. @param arg0 arg0
  15238. */
  15239. isAdTypeSupported(arg0: anysdk.AdsType): boolean;
  15240. /**
  15241. !#en
  15242. spend point
  15243. !#zh
  15244. 消费分数
  15245. @param points points
  15246. */
  15247. spendPoints(points: number): void;
  15248. /**
  15249. !#en
  15250. set listener
  15251. !#zh
  15252. 设置广告系统的监听
  15253. @param listener listener
  15254. @param target target
  15255. */
  15256. setListener(listener: Function, target: any): void;
  15257. /**
  15258. !#en
  15259. get listener
  15260. !#zh
  15261. 获取广告系统的监听
  15262. */
  15263. getListener(): Function;
  15264. }
  15265. /** !#en
  15266. social protocol
  15267. !#zh
  15268. 社交系统协议接口 */
  15269. export class ProtocolSocial extends PluginProtocol {
  15270. /**
  15271. !#en
  15272. sign in
  15273. !#zh
  15274. 登录
  15275. */
  15276. signIn(): void;
  15277. /**
  15278. !#en
  15279. sign out
  15280. !#zh
  15281. 登出
  15282. */
  15283. signOut(): void;
  15284. /**
  15285. !#en
  15286. submit score
  15287. !#zh
  15288. 提交分数
  15289. @param leadboardID leadboardID
  15290. @param score Type: long
  15291. */
  15292. submitScore(leadboardID: string, score: number): void;
  15293. /**
  15294. !#en
  15295. show the id of Leaderboard page
  15296. !#zh
  15297. 根据唯一标识符显示排行榜
  15298. @param leaderboardID leaderboardID
  15299. */
  15300. showLeaderboard(leaderboardID: string): void;
  15301. /**
  15302. !#en
  15303. show the page of achievements
  15304. !#zh
  15305. 显示成就榜
  15306. */
  15307. showAchievements(): void;
  15308. /**
  15309. !#en
  15310. unlock achievement
  15311. !#zh
  15312. 解锁成就
  15313. @param info Type: map
  15314. */
  15315. share(info: any): void;
  15316. /**
  15317. !#en
  15318. set listener
  15319. !#zh
  15320. 设置社交系统的监听
  15321. @param listener listener
  15322. @param target target
  15323. */
  15324. setListener(listener: Function, target: any): void;
  15325. /**
  15326. !#en
  15327. get listener
  15328. !#zh
  15329. 获取社交系统的监听
  15330. */
  15331. getListener(): Function;
  15332. /**
  15333. !#en
  15334. get friends info
  15335. Before to invoke, you need to verdict whether this properties existed
  15336. !#zh
  15337. 获取好友信息,调用前需要判断属性是否存在
  15338. */
  15339. pauseRecording(): void;
  15340. /**
  15341. !#en
  15342. interact
  15343. Before to invoke, you need to verdict whether this properties existed
  15344. !#zh
  15345. 订阅,调用前需要判断属性是否存在
  15346. */
  15347. interact(): void;
  15348. /**
  15349. !#en
  15350. subscribe
  15351. Before to invoke, you need to verdict whether this properties existed
  15352. !#zh
  15353. 关注,调用前需要判断属性是否存在
  15354. */
  15355. subscribe(): void;
  15356. }
  15357. /** !#en
  15358. push protocol
  15359. !#zh
  15360. 推送系统协议接口 */
  15361. export class ProtocolPush extends PluginProtocol {
  15362. /**
  15363. !#en
  15364. start Push services
  15365. !#zh
  15366. 启动推送服务
  15367. */
  15368. startPush(): void;
  15369. /**
  15370. !#en
  15371. close Push services
  15372. !#zh
  15373. 暂停推送服务
  15374. */
  15375. closePush(): void;
  15376. /**
  15377. !#en
  15378. delete alias
  15379. !#zh
  15380. 删除别名
  15381. @param alias alias
  15382. */
  15383. delAlias(alias: string): void;
  15384. /**
  15385. !#en
  15386. set alias
  15387. !#zh
  15388. 设置别名
  15389. @param alias alias
  15390. */
  15391. setAlias(alias: string): void;
  15392. /**
  15393. !#en
  15394. delete tags
  15395. !#zh
  15396. 删除标签
  15397. @param tags Type: list
  15398. */
  15399. delTags(tags: any): void;
  15400. /**
  15401. !#en
  15402. set tags
  15403. !#zh
  15404. 设置标签
  15405. @param tags Type: list
  15406. */
  15407. setTags(tags: any): void;
  15408. /**
  15409. !#en
  15410. set listener
  15411. !#zh
  15412. 设置推送系统的监听
  15413. @param listener listener
  15414. @param target target
  15415. */
  15416. setListener(listener: Function, target: any): void;
  15417. /**
  15418. !#en
  15419. get listener
  15420. !#zh
  15421. 获取推送系统的监听
  15422. */
  15423. getListener(): Function;
  15424. }
  15425. /** !#en
  15426. crash protocol
  15427. !#zh
  15428. 崩溃分析系统协议接口 */
  15429. export class ProtocolCrash extends PluginProtocol {
  15430. /**
  15431. !#en
  15432. set user identifier
  15433. !#zh
  15434. 统计用户唯一标识符
  15435. @param identifier identifier
  15436. */
  15437. setUserIdentifier(identifier: string): void;
  15438. /**
  15439. !#en
  15440. The uploader captured in exception information
  15441. !#zh
  15442. 上报异常信息
  15443. @param message message
  15444. @param exception exception
  15445. */
  15446. reportException(message: string, exception: string): void;
  15447. /**
  15448. !#en
  15449. customize logging
  15450. !#zh
  15451. 自定义日志记录
  15452. @param breadcrumb breadcrumb
  15453. */
  15454. leaveBreadcrumb(breadcrumb: string): void;
  15455. }
  15456. /** !#en
  15457. REC protocol
  15458. !#zh
  15459. 录屏系统协议接口 */
  15460. export class ProtocolREC extends PluginProtocol {
  15461. /**
  15462. !#en
  15463. share video
  15464. !#zh
  15465. 分享视频
  15466. @param info Type: map
  15467. */
  15468. share(info: any): void;
  15469. /**
  15470. !#en
  15471. Start to record video
  15472. !#zh
  15473. 开始录制视频
  15474. */
  15475. startRecording(): void;
  15476. /**
  15477. !#en
  15478. Start to record video
  15479. !#zh
  15480. 结束录制视频
  15481. */
  15482. stopRecording(): void;
  15483. /**
  15484. !#en
  15485. set listener
  15486. !#zh
  15487. 设置录屏系统的监听
  15488. @param listener listener
  15489. @param target target
  15490. */
  15491. setListener(listener: Function, target: any): void;
  15492. /**
  15493. !#en
  15494. get listener
  15495. !#zh
  15496. 获取录屏系统的监听
  15497. */
  15498. getListener(): Function;
  15499. /**
  15500. !#en
  15501. pause to record video
  15502. Before to invoke, you need to verdict whether this properties existed
  15503. !#zh
  15504. 暂停录制视频,调用前需要判断属性是否存在
  15505. */
  15506. pauseRecording(): void;
  15507. /**
  15508. !#en
  15509. resume to record video
  15510. Before to invoke, you need to verdict whether this properties existed
  15511. !#zh
  15512. 恢复录制视频,调用前需要判断属性是否存在
  15513. */
  15514. resumeRecording(): void;
  15515. /**
  15516. !#en
  15517. get whether the device is isAvailable
  15518. Before to invoke, you need to verdict whether this properties existed
  15519. !#zh
  15520. 获取设备是否可用,调用前需要判断属性是否存在
  15521. */
  15522. isAvailable(): boolean;
  15523. /**
  15524. !#en
  15525. get status of recording
  15526. Before to invoke, you need to verdict whether this properties existed
  15527. !#zh
  15528. 获取录制状态,调用前需要判断属性是否存在
  15529. */
  15530. isRecording(): boolean;
  15531. /**
  15532. !#en
  15533. show toolbar
  15534. Before to invoke, you need to verdict whether this properties existed
  15535. !#zh
  15536. 显示悬浮窗,调用前需要判断属性是否存在
  15537. */
  15538. showToolBar(): void;
  15539. /**
  15540. !#en
  15541. hide toolbar
  15542. Before to invoke, you need to verdict whether this properties existed
  15543. !#zh
  15544. 隐藏悬浮窗,调用前需要判断属性是否存在
  15545. */
  15546. hideToolBar(): void;
  15547. /**
  15548. !#en
  15549. show video center
  15550. Before to invoke, you need to verdict whether this properties existed
  15551. !#zh
  15552. 显示视频中心,调用前需要判断属性是否存在
  15553. */
  15554. showVideoCenter(): void;
  15555. /**
  15556. !#en
  15557. enter platform
  15558. Before to invoke, you need to verdict whether this properties existed
  15559. !#zh
  15560. 显示平台中心,调用前需要判断属性是否存在
  15561. */
  15562. enterPlatform(): void;
  15563. /**
  15564. !#en
  15565. Set the video data, it is recommended to check whether are recorded firstly
  15566. Before to invoke, you need to verdict whether this properties existed
  15567. !#zh
  15568. 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
  15569. @param info Type: map
  15570. */
  15571. setMetaData(info: any): void;
  15572. }
  15573. /** !#en
  15574. ad tracking protocol
  15575. !#zh
  15576. 广告追踪系统协议接口 */
  15577. export class ProtocolAdTracking extends PluginProtocol {
  15578. /**
  15579. !#en
  15580. Call this method if you want to track register events as happening during a section.
  15581. !#zh
  15582. 统计用户注册信息
  15583. @param productInfo Type: map
  15584. */
  15585. onPay(productInfo: any): void;
  15586. /**
  15587. !#en
  15588. Call this method if you want to track register events as happening during a section.
  15589. !#zh
  15590. 统计用户注册信息
  15591. @param userInfo Type: map
  15592. */
  15593. onLogin(userInfo: any): void;
  15594. /**
  15595. !#en
  15596. Call this method if you want to track register events as happening during a section.
  15597. !#zh
  15598. 统计用户注册信息
  15599. @param userId userId
  15600. */
  15601. onRegister(userId: string): void;
  15602. /**
  15603. !#en
  15604. Call this method if you want to track custom events with parameters as happening during a section.
  15605. !#zh
  15606. 统计自定义事件
  15607. @param eventId eventId
  15608. @param paramMap Type: map
  15609. */
  15610. trackEvent(eventId: string, paramMap: any): void;
  15611. /**
  15612. !#en
  15613. Call this method with parameters if you want to create role as happening during a section.
  15614. !#zh
  15615. 统计创建角色事件,调用前需要判断属性是否存在
  15616. @param userInfo Type: map
  15617. */
  15618. onCreateRole(userInfo: any): void;
  15619. /**
  15620. !#en
  15621. Call this method if you want to track levelup events with parameters as happening during a section.
  15622. Before to invoke, you need to verdict whether this properties existed
  15623. !#zh
  15624. 统计角色升级事件,调用前需要判断属性是否存在
  15625. @param info Type: map
  15626. */
  15627. onLevelUp(info: any): void;
  15628. /**
  15629. !#en
  15630. Invoke this method with parameters if you want to start to pay as happening during a section.
  15631. Before to invoke, you need to verdict whether this properties existed
  15632. !#zh
  15633. 统计开始充值事件,调用前需要判断属性是否存在
  15634. @param info Type: map
  15635. */
  15636. onStartToPay(info: any): void;
  15637. }
  15638. /** !#en
  15639. custom protocol
  15640. !#zh
  15641. 自定义系统协议接口 */
  15642. export class ProtocolCustom extends PluginProtocol {
  15643. /**
  15644. !#en
  15645. set listener
  15646. !#zh
  15647. 设置自定义系统的监听
  15648. @param listener listener
  15649. @param target target
  15650. */
  15651. setListener(listener: Function, target: any): void;
  15652. /**
  15653. !#en
  15654. get listener
  15655. !#zh
  15656. 获取自定义系统的监听
  15657. */
  15658. getListener(): Function;
  15659. }
  15660. /** !#en
  15661. Data structure class
  15662. !#zh
  15663. 数据结构类 */
  15664. export class PluginParam {
  15665. /**
  15666. !#en
  15667. create plugin parameters
  15668. !#zh
  15669. 创建对象
  15670. @param parameters parameters
  15671. */
  15672. static create(parameters: number|string|any): anysdk.PluginParam;
  15673. }
  15674. /** !#en The callback of user system
  15675. !#zh 用户系统回调 */
  15676. export enum UserActionResultCode {
  15677. kInitSuccess = 0,
  15678. kInitFail = 0,
  15679. kLoginSuccess = 0,
  15680. kLoginNetworkError = 0,
  15681. kLoginNoNeed = 0,
  15682. kLoginFail = 0,
  15683. kLoginCancel = 0,
  15684. kLogoutSuccess = 0,
  15685. kLogoutFail = 0,
  15686. kPlatformEnter = 0,
  15687. kPlatformBack = 0,
  15688. kPausePage = 0,
  15689. kExitPage = 0,
  15690. kAntiAddictionQuery = 0,
  15691. kRealNameRegister = 0,
  15692. kAccountSwitchSuccess = 0,
  15693. kAccountSwitchFail = 0,
  15694. kOpenShop = 0,
  15695. kAccountSwitchCancel = 0,
  15696. kUserExtension = 0,
  15697. kSendToDesktopSuccess = 0,
  15698. kSendToDesktopFail = 0,
  15699. kGetAvailableLoginTypeSuccess = 0,
  15700. kGetAvailableLoginTypeFail = 0,
  15701. kGetUserInfoSuccess = 0,
  15702. kGetUserInfoFail = 0,
  15703. kOpenBBSSuccess = 0,
  15704. kOpenBBSFail = 0,
  15705. }
  15706. /** !#en The toolbar position of user type
  15707. !#zh 用户系统悬浮窗位置 */
  15708. export enum ToolBarPlace {
  15709. kToolBarTopLeft = 0,
  15710. kToolBarTopRight = 0,
  15711. kToolBarMidLeft = 0,
  15712. kToolBarMidRight = 0,
  15713. kToolBarBottomLeft = 0,
  15714. kToolBarBottomRight = 0,
  15715. }
  15716. /** !#en The callback of requesting reStringge
  15717. !#zh 支付系统支付请求回调 */
  15718. export enum PayResultCode {
  15719. kPaySuccess = 0,
  15720. kPayFail = 0,
  15721. kPayCancel = 0,
  15722. kPayNetworkError = 0,
  15723. kPayProductionInforIncomplete = 0,
  15724. kPayInitSuccess = 0,
  15725. kPayInitFail = 0,
  15726. kPayNowPaying = 0,
  15727. kPayReStringgeSuccess = 0,
  15728. kPayExtension = 0,
  15729. kPayNeedLoginAgain = 0,
  15730. kRequestSuccess = 0,
  15731. kRequestFail = 0,
  15732. }
  15733. /** !#en The enum of account type
  15734. !#zh 统计系统的账号类型 */
  15735. export enum AccountType {
  15736. ANONYMOUS = 0,
  15737. REGISTED = 0,
  15738. SINA_WEIBO = 0,
  15739. TENCENT_WEIBO = 0,
  15740. QQ = 0,
  15741. ND91 = 0,
  15742. }
  15743. /** !#en The enum of account operation
  15744. !#zh 统计系统的账号操作 */
  15745. export enum AccountOperate {
  15746. LOGIN = 0,
  15747. LOGOUT = 0,
  15748. REGISTER = 0,
  15749. }
  15750. /** !#en The enum of gender
  15751. !#zh 统计系统的账号性别 */
  15752. export enum AccountGender {
  15753. MALE = 0,
  15754. FEMALE = 0,
  15755. UNKNOWN = 0,
  15756. }
  15757. /** !#en The enum of task type
  15758. !#zh 统计系统的任务类型 */
  15759. export enum TaskType {
  15760. GUIDE_LINE = 0,
  15761. MAIN_LINE = 0,
  15762. BRANCH_LINE = 0,
  15763. DAILY = 0,
  15764. ACTIVITY = 0,
  15765. OTHER = 0,
  15766. }
  15767. /** !#en The callback of share system
  15768. !#zh 分享系统回调 */
  15769. export enum ShareResultCode {
  15770. kShareSuccess = 0,
  15771. kShareFail = 0,
  15772. kShareCancel = 0,
  15773. kShareNetworkError = 0,
  15774. kShareExtension = 0,
  15775. }
  15776. /** !#en The callback of social system
  15777. !#zh 社交系统回调 */
  15778. export enum SocialRetCode {
  15779. kScoreSubmitSucceed = 0,
  15780. kScoreSubmitfail = 0,
  15781. kAchUnlockSucceed = 0,
  15782. kAchUnlockFail = 0,
  15783. kSocialSignInSucceed = 0,
  15784. kSocialSignInFail = 0,
  15785. kSocialSignOutSucceed = 0,
  15786. kSocialSignOutFail = 0,
  15787. kSocialGetGameFriends = 0,
  15788. kSocialExtensionCode = 0,
  15789. kSocialGetFriendsInfoSuccess = 0,
  15790. kSocialGetFriendsInfoFail = 0,
  15791. kSocialAlreadySubscription = 0,
  15792. kSocialNoSubscription = 0,
  15793. kSocialSubscriptionFail = 0,
  15794. }
  15795. /** !#en The callback of ads system
  15796. !#zh 广告系统回调 */
  15797. export enum AdsResultCode {
  15798. kAdsReceived = 0,
  15799. kAdsShown = 0,
  15800. kAdsDismissed = 0,
  15801. kPointsSpendSucceed = 0,
  15802. kPointsSpendFailed = 0,
  15803. kNetworkError = 0,
  15804. kUnknownError = 0,
  15805. kOfferWallOnPointsChanged = 0,
  15806. kRewardedVideoWithReward = 0,
  15807. kInAppPurchaseFinished = 0,
  15808. kAdsClicked = 0,
  15809. kAdsExtension = 0,
  15810. }
  15811. /** !#en The enum of ads position
  15812. !#zh 广告位置 */
  15813. export enum AdsPos {
  15814. kPosCenter = 0,
  15815. kPosTop = 0,
  15816. kPosTopLeft = 0,
  15817. kPosTopRight = 0,
  15818. kPosBottom = 0,
  15819. kPosBottomLeft = 0,
  15820. kPosBottomRight = 0,
  15821. }
  15822. /** !#en The enum of ads type
  15823. !#zh 广告类型 */
  15824. export enum AdsType {
  15825. AD_TYPE_BANNER = 0,
  15826. AD_TYPE_FULLSCREEN = 0,
  15827. AD_TYPE_MOREAPP = 0,
  15828. AD_TYPE_OFFERWALL = 0,
  15829. AD_TYPE_REWARDEDVIDEO = 0,
  15830. AD_TYPE_NATIVEEXPRESS = 0,
  15831. AD_TYPE_NATIVEADVANCED = 0,
  15832. }
  15833. /** !#en The callback of push system
  15834. !#zh 推送系统回调 */
  15835. export enum PushActionResultCode {
  15836. kPushReceiveMessage = 0,
  15837. kPushExtensionCode = 0,
  15838. }
  15839. /** !#en The callback of custom system
  15840. !#zh 自定义系统回调 */
  15841. export enum CustomResultCode {
  15842. kCustomExtension = 0,
  15843. }
  15844. /** !#en The callback of REC system
  15845. !#zh 录屏系统回调 */
  15846. export enum RECResultCode {
  15847. kRECInitSuccess = 0,
  15848. kRECInitFail = 0,
  15849. kRECStartRecording = 0,
  15850. kRECStopRecording = 0,
  15851. kRECPauseRecording = 0,
  15852. kRECResumeRecording = 0,
  15853. kRECEnterSDKPage = 0,
  15854. kRECQuitSDKPage = 0,
  15855. kRECShareSuccess = 0,
  15856. kRECShareFail = 0,
  15857. kRECExtension = 0,
  15858. }
  15859. }
  15860. /** !#en
  15861. The global main namespace of DragonBones, all classes, functions,
  15862. properties and constants of DragonBones are defined in this namespace
  15863. !#zh
  15864. DragonBones 的全局的命名空间,
  15865. 与 DragonBones 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  15866. declare module dragonBones {
  15867. /** !#en
  15868. The Armature Display of DragonBones <br/>
  15869. <br/>
  15870. (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
  15871. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  15872. Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/>
  15873. !#zh
  15874. DragonBones 骨骼动画 <br/>
  15875. <br/>
  15876. (Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  15877. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  15878. 多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)<br/> */
  15879. export class ArmatureDisplay extends cc._RendererUnderSG {
  15880. /** !#en
  15881. The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
  15882. attachments, skins, etc) and animations but does not hold any state.<br/>
  15883. Multiple ArmatureDisplay can share the same DragonBones data.
  15884. !#zh
  15885. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  15886. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  15887. 多个 ArmatureDisplay 可以共用相同的骨骼数据。 */
  15888. dragonAsset: DragonBonesAsset;
  15889. /** !#en
  15890. The atlas asset for the DragonBones.
  15891. !#zh
  15892. 骨骼数据所需的 Atlas Texture 数据。 */
  15893. dragonAtlasAsset: DragonBonesAtlasAsset;
  15894. /** !#en The name of current armature.
  15895. !#zh 当前的 Armature 名称。 */
  15896. armatureName: string;
  15897. /** !#en The name of current playing animation.
  15898. !#zh 当前播放的动画名称。 */
  15899. animationName: string;
  15900. _defaultArmatureIndex: number;
  15901. /** !#en The time scale of this armature.
  15902. !#zh 当前骨骼中所有动画的时间缩放率。 */
  15903. timeScale: number;
  15904. /** !#en The play times of the default animation.
  15905. -1 means using the value of config file;
  15906. 0 means repeat for ever
  15907. >0 means repeat times
  15908. !#zh 播放默认动画的循环次数
  15909. -1 表示使用配置文件中的默认值;
  15910. 0 表示无限循环
  15911. >0 表示循环次数 */
  15912. playTimes: number;
  15913. /** !#en Indicates whether open debug bones.
  15914. !#zh 是否显示 bone 的 debug 信息。 */
  15915. debugBones: boolean;
  15916. /**
  15917. !#en
  15918. Play the specified animation.
  15919. Parameter animName specify the animation name.
  15920. Parameter playTimes specify the repeat times of the animation.
  15921. -1 means use the value of the config file.
  15922. 0 means play the animation for ever.
  15923. >0 means repeat times.
  15924. !#zh
  15925. 播放指定的动画.
  15926. animName 指定播放动画的名称。
  15927. playTimes 指定播放动画的次数。
  15928. -1 为使用配置文件中的次数。
  15929. 0 为无限循环播放。
  15930. >0 为动画的重复次数。
  15931. @param animName animName
  15932. @param playTimes playTimes
  15933. */
  15934. playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
  15935. /**
  15936. !#en
  15937. Get the all armature names in the DragonBones Data.
  15938. !#zh
  15939. 获取 DragonBones 数据中所有的 armature 名称
  15940. */
  15941. getArmatureNames(): any[];
  15942. /**
  15943. !#en
  15944. Get the all animation names of specified armature.
  15945. !#zh
  15946. 获取指定的 armature 的所有动画名称。
  15947. @param armatureName armatureName
  15948. */
  15949. getAnimationNames(armatureName: string): any[];
  15950. /**
  15951. !#en
  15952. Add event listener for the DragonBones Event.
  15953. !#zh
  15954. 添加 DragonBones 事件监听器。
  15955. @param type A string representing the event type to listen for.
  15956. @param listener The callback that will be invoked when the event is dispatched.
  15957. @param target The target (this object) to invoke the callback, can be null
  15958. */
  15959. addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void;
  15960. /**
  15961. !#en
  15962. Remove the event listener for the DragonBones Event.
  15963. !#zh
  15964. 移除 DragonBones 事件监听器。
  15965. @param type A string representing the event type to listen for.
  15966. @param listener listener
  15967. @param target target
  15968. */
  15969. removeEventListener(type: string, listener?: Function, target?: any): void;
  15970. /**
  15971. !#en
  15972. Build the armature for specified name.
  15973. !#zh
  15974. 构建指定名称的 armature 对象
  15975. @param armatureName armatureName
  15976. */
  15977. buildArmature(armatureName: string): dragonBones.Armature;
  15978. /**
  15979. !#en
  15980. Get the current armature object of the ArmatureDisplay.
  15981. !#zh
  15982. 获取 ArmatureDisplay 当前使用的 Armature 对象
  15983. */
  15984. armature(): any;
  15985. }
  15986. /** !#en The skeleton data of dragonBones.
  15987. !#zh dragonBones 的 骨骼数据。 */
  15988. export class DragonBonesAsset extends cc.Asset {
  15989. /** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
  15990. !#zh 可查看 DragonBones 官方文档 http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
  15991. dragonBonesJson: string;
  15992. }
  15993. /** !#en The skeleton atlas data of dragonBones.
  15994. !#zh dragonBones 的骨骼纹理数据。 */
  15995. export class DragonBonesAtlasAsset extends cc.Asset {
  15996. atlasJson: string;
  15997. texture: cc.Texture2D;
  15998. }
  15999. }
  16000. /** !#en
  16001. The global main namespace of Spine, all classes, functions,
  16002. properties and constants of Spine are defined in this namespace
  16003. !#zh
  16004. Spine 的全局的命名空间,
  16005. 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。 */
  16006. declare module sp {
  16007. /** !#en
  16008. The skeleton of Spine <br/>
  16009. <br/>
  16010. (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
  16011. which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
  16012. Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
  16013. !#zh
  16014. Spine 骨骼动画 <br/>
  16015. <br/>
  16016. (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
  16017. 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
  16018. 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。 */
  16019. export class Skeleton extends cc._RendererUnderSG {
  16020. /** !#en The skeletal animation is paused?
  16021. !#zh 该骨骼动画是否暂停。 */
  16022. paused: boolean;
  16023. /** !#en
  16024. The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
  16025. attachments, skins, etc) and animations but does not hold any state.<br/>
  16026. Multiple skeletons can share the same skeleton data.
  16027. !#zh
  16028. 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
  16029. attachments,皮肤等等)和动画但不持有任何状态。<br/>
  16030. 多个 Skeleton 可以共用相同的骨骼数据。 */
  16031. skeletonData: SkeletonData;
  16032. /** !#en The name of default skin.
  16033. !#zh 默认的皮肤名称。 */
  16034. defaultSkin: string;
  16035. /** !#en The name of default animation.
  16036. !#zh 默认的动画名称。 */
  16037. defaultAnimation: string;
  16038. /** !#en The name of current playing animation.
  16039. !#zh 当前播放的动画名称。 */
  16040. animation: string;
  16041. _defaultSkinIndex: number;
  16042. /** !#en TODO
  16043. !#zh 是否循环播放当前骨骼动画。 */
  16044. loop: boolean;
  16045. /** !#en Indicates whether to enable premultiplied alpha.
  16046. You should disable this option when image's transparent area appears to have opaque pixels,
  16047. or enable this option when image's half transparent area appears to be darken.
  16048. !#zh 是否启用贴图预乘。
  16049. 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
  16050. premultipliedAlpha: boolean;
  16051. /** !#en The time scale of this skeleton.
  16052. !#zh 当前骨骼中所有动画的时间缩放率。 */
  16053. timeScale: number;
  16054. /** !#en Indicates whether open debug slots.
  16055. !#zh 是否显示 slot 的 debug 信息。 */
  16056. debugSlots: boolean;
  16057. /** !#en Indicates whether open debug bones.
  16058. !#zh 是否显示 bone 的 debug 信息。 */
  16059. debugBones: boolean;
  16060. /**
  16061. !#en Computes the world SRT from the local SRT for each bone.
  16062. !#zh 重新更新所有骨骼的世界 Transform,
  16063. 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
  16064. @example
  16065. ```js
  16066. var bone = spine.findBone('head');
  16067. cc.log(bone.worldX); // return 0;
  16068. spine.updateWorldTransform();
  16069. bone = spine.findBone('head');
  16070. cc.log(bone.worldX); // return -23.12;
  16071. ```
  16072. */
  16073. updateWorldTransform(): void;
  16074. /**
  16075. !#en Sets the bones and slots to the setup pose.
  16076. !#zh 还原到起始动作
  16077. */
  16078. setToSetupPose(): void;
  16079. /**
  16080. !#en
  16081. Sets the bones to the setup pose,
  16082. using the values from the `BoneData` list in the `SkeletonData`.
  16083. !#zh
  16084. 设置 bone 到起始动作
  16085. 使用 SkeletonData 中的 BoneData 列表中的值。
  16086. */
  16087. setBonesToSetupPose(): void;
  16088. /**
  16089. !#en
  16090. Sets the slots to the setup pose,
  16091. using the values from the `SlotData` list in the `SkeletonData`.
  16092. !#zh
  16093. 设置 slot 到起始动作。
  16094. 使用 SkeletonData 中的 SlotData 列表中的值。
  16095. */
  16096. setSlotsToSetupPose(): void;
  16097. /**
  16098. !#en
  16099. Finds a bone by name.
  16100. This does a string comparison for every bone.<br>
  16101. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
  16102. !#zh
  16103. 通过名称查找 bone。
  16104. 这里对每个 bone 的名称进行了对比。<br>
  16105. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
  16106. @param boneName boneName
  16107. */
  16108. findBone(boneName: string): sp.spine.Bone;
  16109. /**
  16110. !#en
  16111. Finds a slot by name. This does a string comparison for every slot.<br>
  16112. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
  16113. !#zh
  16114. 通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
  16115. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
  16116. @param slotName slotName
  16117. */
  16118. findSlot(slotName: string): sp.spine.Slot;
  16119. /**
  16120. !#en
  16121. Finds a skin by name and makes it the active skin.
  16122. This does a string comparison for every skin.<br>
  16123. Note that setting the skin does not change which attachments are visible.<br>
  16124. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
  16125. !#zh
  16126. 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
  16127. 注意:设置皮肤不会改变 attachment 的可见性。<br>
  16128. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
  16129. @param skinName skinName
  16130. */
  16131. setSkin(skinName: string): sp.spine.Skin;
  16132. /**
  16133. !#en
  16134. Returns the attachment for the slot and attachment name.
  16135. The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
  16136. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
  16137. !#zh
  16138. 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
  16139. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
  16140. @param slotName slotName
  16141. @param attachmentName attachmentName
  16142. */
  16143. getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
  16144. /**
  16145. !#en
  16146. Sets the attachment for the slot and attachment name.
  16147. The skeleton looks first in its skin, then in the skeleton data’s default skin.
  16148. !#zh
  16149. 通过 slot 和 attachment 的名字来设置 attachment。
  16150. Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
  16151. @param slotName slotName
  16152. @param attachmentName attachmentName
  16153. */
  16154. setAttachment(slotName: string, attachmentName: string): void;
  16155. /**
  16156. !#en
  16157. Sets runtime skeleton data to sp.Skeleton.<br>
  16158. This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator.
  16159. !#zh
  16160. 设置底层运行时用到的 SkeletonData。<br>
  16161. 这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
  16162. @param skeletonData skeletonData
  16163. @param ownsSkeletonData ownsSkeletonData
  16164. */
  16165. setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
  16166. /**
  16167. !#en Sets animation state data.<br>
  16168. The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
  16169. !#zh 设置动画状态数据。<br>
  16170. 参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
  16171. @param stateData stateData
  16172. */
  16173. setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
  16174. /**
  16175. !#en
  16176. Mix applies all keyframe values,
  16177. interpolated for the specified time and mixed with the current values.
  16178. !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
  16179. @param fromAnimation fromAnimation
  16180. @param toAnimation toAnimation
  16181. @param duration duration
  16182. */
  16183. setMix(fromAnimation: string, toAnimation: string, duration: number): void;
  16184. /**
  16185. !#en Sets event listener.
  16186. !#zh 设置动画事件监听器。
  16187. @param target target
  16188. @param callback callback
  16189. */
  16190. setAnimationListener(target: any, callback: Function): void;
  16191. /**
  16192. !#en Set the current animation. Any queued animations are cleared.<br>
  16193. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16194. !#zh 设置当前动画。队列中的任何的动画将被清除。<br>
  16195. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16196. @param trackIndex trackIndex
  16197. @param name name
  16198. @param loop loop
  16199. */
  16200. setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
  16201. /**
  16202. !#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
  16203. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16204. !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
  16205. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16206. @param trackIndex trackIndex
  16207. @param name name
  16208. @param loop loop
  16209. @param delay delay
  16210. */
  16211. addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
  16212. /**
  16213. !#en Find animation with specified name.
  16214. !#zh 查找指定名称的动画
  16215. @param name name
  16216. */
  16217. findAnimation(name: string): sp.spine.Animation;
  16218. /**
  16219. !#en Returns track entry by trackIndex.<br>
  16220. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
  16221. !#zh 通过 track 索引获取 TrackEntry。<br>
  16222. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
  16223. @param trackIndex trackIndex
  16224. */
  16225. getCurrent(trackIndex: void): sp.spine.TrackEntry;
  16226. /**
  16227. !#en Clears all tracks of animation state.
  16228. !#zh 清除所有 track 的动画状态。
  16229. */
  16230. clearTracks(): void;
  16231. /**
  16232. !#en Clears track of animation state by trackIndex.
  16233. !#zh 清除出指定 track 的动画状态。
  16234. @param trackIndex trackIndex
  16235. */
  16236. clearTrack(trackIndex: number): void;
  16237. /**
  16238. !#en Set the start event listener.
  16239. !#zh 用来设置开始播放动画的事件监听。
  16240. @param listener listener
  16241. */
  16242. setStartListener(listener: Function): void;
  16243. /**
  16244. !#en Set the interrupt event listener.
  16245. !#zh 用来设置动画被打断的事件监听。
  16246. @param listener listener
  16247. */
  16248. setInterruptListener(listener: Function): void;
  16249. /**
  16250. !#en Set the end event listener.
  16251. !#zh 用来设置动画播放完后的事件监听。
  16252. @param listener listener
  16253. */
  16254. setEndListener(listener: Function): void;
  16255. /**
  16256. !#en Set the dispose event listener.
  16257. !#zh 用来设置动画将被销毁的事件监听。
  16258. @param listener listener
  16259. */
  16260. setDisposeListener(listener: Function): void;
  16261. /**
  16262. !#en Set the complete event listener.
  16263. !#zh 用来设置动画播放一次循环结束后的事件监听。
  16264. @param listener listener
  16265. */
  16266. setCompleteListener(listener: Function): void;
  16267. /**
  16268. !#en Set the animation event listener.
  16269. !#zh 用来设置动画播放过程中帧事件的监听。
  16270. @param listener listener
  16271. */
  16272. setEventListener(listener: Function): void;
  16273. /**
  16274. !#en Set the start event listener for specified TrackEntry (only supported on Web).
  16275. !#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
  16276. @param entry entry
  16277. @param listener listener
  16278. */
  16279. setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16280. /**
  16281. !#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
  16282. !#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
  16283. @param entry entry
  16284. @param listener listener
  16285. */
  16286. setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16287. /**
  16288. !#en Set the end event listener for specified TrackEntry (only supported on Web).
  16289. !#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
  16290. @param entry entry
  16291. @param listener listener
  16292. */
  16293. setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16294. /**
  16295. !#en Set the dispose event listener for specified TrackEntry (only supported on Web).
  16296. !#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
  16297. @param entry entry
  16298. @param listener listener
  16299. */
  16300. setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16301. /**
  16302. !#en Set the complete event listener for specified TrackEntry (only supported on Web).
  16303. !#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
  16304. @param entry entry
  16305. @param listener listener
  16306. */
  16307. setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16308. /**
  16309. !#en Set the event listener for specified TrackEntry (only supported on Web).
  16310. !#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
  16311. @param entry entry
  16312. @param listener listener
  16313. */
  16314. setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
  16315. }
  16316. /** !#en The skeleton data of spine.
  16317. !#zh Spine 的 骨骼数据。 */
  16318. export class SkeletonData extends cc.Asset {
  16319. /** !#en See http://en.esotericsoftware.com/spine-json-format
  16320. !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format */
  16321. skeletonJson: any;
  16322. atlasText: string;
  16323. textures: cc.Texture2D[];
  16324. /** !#en
  16325. A scale can be specified on the JSON or binary loader which will scale the bone positions,
  16326. image sizes, and animation translations.
  16327. This can be useful when using different sized images than were used when designing the skeleton
  16328. in Spine. For example, if using images that are half the size than were used in Spine,
  16329. a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
  16330. resolution texture atlases.
  16331. see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
  16332. !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
  16333. scale: number;
  16334. /**
  16335. !#en Get the included SkeletonData used in spine runtime.<br>
  16336. Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
  16337. !#zh 获取 Spine Runtime 使用的 SkeletonData。<br>
  16338. 返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData 对象。
  16339. @param quiet quiet
  16340. */
  16341. getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
  16342. }
  16343. /** !#en The event type of spine skeleton animation.
  16344. !#zh 骨骼动画事件类型。 */
  16345. export enum AnimationEventType {
  16346. START = 0,
  16347. END = 0,
  16348. COMPLETE = 0,
  16349. EVENT = 0,
  16350. }
  16351. }
  16352. /** !#en
  16353. `sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
  16354. Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
  16355. !#zh
  16356. sp.spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
  16357. declare module sp.spine {
  16358. }
  16359. /** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
  16360. !#zh 一些 JavaScript 装饰器,目前可以通过 "cc._decorator" 来访问。
  16361. (这些 API 仍不完全稳定,有可能随着 JavaScript 装饰器的标准实现而调整) */
  16362. declare module cc._decorator {
  16363. /**
  16364. !#en
  16365. Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
  16366. as CCClass, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class/) for details.
  16367. !#zh
  16368. 将标准写法的 [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass,具体用法请参阅[类型定义](/docs/creator/scripting/class/)。
  16369. @param name The class name used for serialization.
  16370. @example
  16371. ```js
  16372. const {ccclass} = cc._decorator;
  16373. // define a CCClass, omit the name
  16374. &#64;ccclass
  16375. class NewScript extends cc.Component {
  16376. // ...
  16377. }
  16378. // define a CCClass with a name
  16379. &#64;ccclass('LoginData')
  16380. class LoginData {
  16381. // ...
  16382. }
  16383. ```
  16384. */
  16385. export function ccclass(name?: string): Function;
  16386. export function ccclass(_class?: Function): void;
  16387. /**
  16388. !#en
  16389. Declare property for [CCClass](/docs/editors_and_tools/creator-chapters/scripting/class/).
  16390. !#zh
  16391. 定义 [CCClass](/docs/creator/scripting/class/) 所用的属性。
  16392. @param options an object with some property attributes
  16393. @example
  16394. ```js
  16395. const {ccclass, property} = cc._decorator;
  16396. &#64;ccclass
  16397. class NewScript extends cc.Component {
  16398. &#64;property({
  16399. type: cc.Node
  16400. })
  16401. targetNode1 = null;
  16402. &#64;property(cc.Node)
  16403. targetNode2 = null;
  16404. &#64;property(cc.Button)
  16405. targetButton = null;
  16406. &#64;property
  16407. _width = 100;
  16408. &#64;property
  16409. get width () {
  16410. return this._width;
  16411. }
  16412. &#64;property
  16413. set width (value) {
  16414. this._width = value;
  16415. }
  16416. &#64;property
  16417. offset = new cc.Vec2(100, 100);
  16418. &#64;property(cc.Vec2)
  16419. offsets = [];
  16420. &#64;property(cc.SpriteFrame)
  16421. frame = null;
  16422. }
  16423. // above is equivalent to (上面的代码相当于):
  16424. var NewScript = cc.Class({
  16425. properties: {
  16426. targetNode1: {
  16427. default: null,
  16428. type: cc.Node
  16429. },
  16430. targetNode2: {
  16431. default: null,
  16432. type: cc.Node
  16433. },
  16434. targetButton: {
  16435. default: null,
  16436. type: cc.Button
  16437. },
  16438. _width: 100,
  16439. width: {
  16440. get () {
  16441. return this._width;
  16442. },
  16443. set (value) {
  16444. this._width = value;
  16445. }
  16446. },
  16447. offset: new cc.Vec2(100, 100)
  16448. offsets: {
  16449. default: [],
  16450. type: cc.Vec2
  16451. }
  16452. frame: {
  16453. default: null,
  16454. type: cc.SpriteFrame
  16455. },
  16456. }
  16457. });
  16458. ```
  16459. */
  16460. export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function;
  16461. export function property(_target: Object, _key: any, _desc?: any): void;
  16462. /**
  16463. !#en
  16464. Makes a CCClass that inherit from component execute in edit mode.<br>
  16465. By default, all components are only executed in play mode,
  16466. which means they will not have their callback functions executed while the Editor is in edit mode.
  16467. !#zh
  16468. 允许继承自 Component 的 CCClass 在编辑器里执行。<br>
  16469. 默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。
  16470. @example
  16471. ```js
  16472. const {ccclass, executeInEditMode} = cc._decorator;
  16473. &#64;ccclass
  16474. &#64;executeInEditMode
  16475. class NewScript extends cc.Component {
  16476. // ...
  16477. }
  16478. ```
  16479. */
  16480. export function executeInEditMode(): Function;
  16481. export function executeInEditMode(_class: Function): void;
  16482. /**
  16483. !#en
  16484. Automatically add required component as a dependency for the CCClass that inherit from component.
  16485. !#zh
  16486. 为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。
  16487. @param requiredComponent requiredComponent
  16488. @example
  16489. ```js
  16490. const {ccclass, requireComponent} = cc._decorator;
  16491. &#64;ccclass
  16492. &#64;requireComponent(cc.Sprite)
  16493. class SpriteCtrl extends cc.Component {
  16494. // ...
  16495. }
  16496. ```
  16497. */
  16498. export function requireComponent(requiredComponent: typeof cc.Component): Function;
  16499. /**
  16500. !#en
  16501. The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
  16502. !#zh
  16503. 将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。
  16504. @param path The path is the menu represented like a pathname.
  16505. For example the menu could be "Rendering/CameraCtrl".
  16506. @example
  16507. ```js
  16508. const {ccclass, menu} = cc._decorator;
  16509. &#64;ccclass
  16510. &#64;menu("Rendering/CameraCtrl")
  16511. class NewScript extends cc.Component {
  16512. // ...
  16513. }
  16514. ```
  16515. */
  16516. export function menu(path: string): Function;
  16517. /**
  16518. !#en
  16519. The execution order of lifecycle methods for Component.
  16520. Those less than 0 will execute before while those greater than 0 will execute after.
  16521. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
  16522. !#zh
  16523. 设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。
  16524. @param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after.
  16525. @example
  16526. ```js
  16527. const {ccclass, executionOrder} = cc._decorator;
  16528. &#64;ccclass
  16529. &#64;executionOrder(1)
  16530. class CameraCtrl extends cc.Component {
  16531. // ...
  16532. }
  16533. ```
  16534. */
  16535. export function executionOrder(order: number): Function;
  16536. /**
  16537. !#en
  16538. Prevents Component of the same type (or subtype) to be added more than once to a Node.
  16539. !#zh
  16540. 防止多个相同类型(或子类型)的组件被添加到同一个节点。
  16541. @example
  16542. ```js
  16543. const {ccclass, disallowMultiple} = cc._decorator;
  16544. &#64;ccclass
  16545. &#64;disallowMultiple
  16546. class CameraCtrl extends cc.Component {
  16547. // ...
  16548. }
  16549. ```
  16550. */
  16551. export function disallowMultiple(): Function;
  16552. export function disallowMultiple(_class: Function): void;
  16553. /**
  16554. !#en
  16555. If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.<br>
  16556. This property is only available if executeInEditMode is true.
  16557. !#zh
  16558. 当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。
  16559. @example
  16560. ```js
  16561. const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
  16562. &#64;ccclass
  16563. &#64;executeInEditMode
  16564. &#64;playOnFocus
  16565. class CameraCtrl extends cc.Component {
  16566. // ...
  16567. }
  16568. ```
  16569. */
  16570. export function playOnFocus(): Function;
  16571. export function playOnFocus(_class: Function): void;
  16572. /**
  16573. !#en
  16574. Specifying the url of the custom html to draw the component in **Properties**.
  16575. !#zh
  16576. 自定义当前组件在 **属性检查器** 中渲染时所用的网页 url。
  16577. @param url url
  16578. @example
  16579. ```js
  16580. const {ccclass, inspector} = cc._decorator;
  16581. &#64;ccclass
  16582. &#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
  16583. class NewScript extends cc.Component {
  16584. // ...
  16585. }
  16586. ```
  16587. */
  16588. export function inspector(path: string): Function;
  16589. /**
  16590. !#en
  16591. The custom documentation URL.
  16592. !#zh
  16593. 指定当前组件的帮助文档的 url,设置过后,在 **属性检查器** 中就会出现一个帮助图标,用户点击将打开指定的网页。
  16594. @param url url
  16595. @example
  16596. ```js
  16597. const {ccclass, help} = cc._decorator;
  16598. &#64;ccclass
  16599. &#64;help("app://docs/html/components/spine.html")
  16600. class NewScript extends cc.Component {
  16601. // ...
  16602. }
  16603. ```
  16604. */
  16605. export function help(path: string): Function;
  16606. /**
  16607. NOTE:<br>
  16608. The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
  16609. But since ES6, class constructor can't be function-called and class methods become non-enumerable,
  16610. so we can not mix in ES6 Classes.<br>
  16611. See:<br>
  16612. [https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)<br>
  16613. One possible solution (but IDE unfriendly):<br>
  16614. [http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
  16615. <br>
  16616. NOTE:<br>
  16617. You must manually call mixins constructor, this is different from cc.Class(ES5).
  16618. @param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
  16619. not support ES6 Classes.
  16620. @example
  16621. ```js
  16622. const {ccclass, mixins} = cc._decorator;
  16623. class Animal { ... }
  16624. const Fly = cc.Class({
  16625. constructor () { ... }
  16626. });
  16627. &#64;ccclass
  16628. &#64;mixins(cc.EventTarget, Fly)
  16629. class Bird extends Animal {
  16630. constructor () {
  16631. super();
  16632. // You must manually call mixins constructor, this is different from cc.Class(ES5)
  16633. cc.EventTarget.call(this);
  16634. Fly.call(this);
  16635. }
  16636. // ...
  16637. }
  16638. ```
  16639. */
  16640. export function mixins(ctor: Function, ...rest: Function[]): Function;
  16641. }
  16642. /** This module provides some JavaScript utilities.
  16643. All members can be accessed with "cc.js". */
  16644. declare module cc.js {
  16645. /**
  16646. Check the obj whether is number or not
  16647. If a number is created by using 'new Number(10086)', the typeof it will be "object"...
  16648. Then you can use this function if you care about this case.
  16649. @param obj obj
  16650. */
  16651. export function isNumber(obj: any): boolean;
  16652. /**
  16653. Check the obj whether is string or not.
  16654. If a string is created by using 'new String("blabla")', the typeof it will be "object"...
  16655. Then you can use this function if you care about this case.
  16656. @param obj obj
  16657. */
  16658. export function isString(obj: any): boolean;
  16659. /**
  16660. This method is deprecated, use cc.js.mixin please.<br>
  16661. Copy all properties not defined in obj from arguments[1...n]
  16662. @param obj object to extend its properties
  16663. @param sourceObj source object to copy properties from
  16664. */
  16665. export function addon(obj: any, ...sourceObj: any[]): any;
  16666. /**
  16667. copy all properties from arguments[1...n] to obj
  16668. @param obj obj
  16669. @param sourceObj sourceObj
  16670. */
  16671. export function mixin(obj: any, ...sourceObj: any[]): any;
  16672. /**
  16673. Derive the class from the supplied base class.
  16674. Both classes are just native javascript constructors, not created by cc.Class, so
  16675. usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
  16676. @param cls cls
  16677. @param base the baseclass to inherit
  16678. */
  16679. export function extend(cls: Function, base: Function): Function;
  16680. /**
  16681. Get super class
  16682. @param ctor the constructor of subclass
  16683. */
  16684. export function getSuper(ctor: Function): Function;
  16685. /**
  16686. Removes all enumerable properties from object
  16687. @param obj obj
  16688. */
  16689. export function clear(obj: any): void;
  16690. /**
  16691. Get property descriptor in object and all its ancestors
  16692. @param obj obj
  16693. @param name name
  16694. */
  16695. export function getPropertyDescriptor(obj: any, name: string): any;
  16696. /**
  16697. Define value, just help to call Object.defineProperty.<br>
  16698. The configurable will be true.
  16699. @param obj obj
  16700. @param prop prop
  16701. @param value value
  16702. @param writable writable
  16703. @param enumerable enumerable
  16704. */
  16705. export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
  16706. /**
  16707. Define get set accessor, just help to call Object.defineProperty(...)
  16708. @param obj obj
  16709. @param prop prop
  16710. @param getter getter
  16711. @param setter setter
  16712. @param enumerable enumerable
  16713. */
  16714. export function getset(obj: any, prop: string, getter: Function, setter: Function, enumerable?: boolean): void;
  16715. /**
  16716. Define get accessor, just help to call Object.defineProperty(...)
  16717. @param obj obj
  16718. @param prop prop
  16719. @param getter getter
  16720. @param enumerable enumerable
  16721. @param configurable configurable
  16722. */
  16723. export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
  16724. /**
  16725. Define set accessor, just help to call Object.defineProperty(...)
  16726. @param obj obj
  16727. @param prop prop
  16728. @param setter setter
  16729. @param enumerable enumerable
  16730. @param configurable configurable
  16731. */
  16732. export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
  16733. /**
  16734. Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
  16735. (modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
  16736. @param objOrCtor instance or constructor
  16737. */
  16738. export function getClassName(objOrCtor: any|Function): string;
  16739. /**
  16740. Register the class by specified name manually
  16741. @param className className
  16742. @param constructor constructor
  16743. */
  16744. export function setClassName(className: string, constructor: Function): void;
  16745. /**
  16746. Unregister a class from fireball.
  16747. If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
  16748. Please note that its still your responsibility to free other references to the class.
  16749. @param constructor the class you will want to unregister, any number of classes can be added
  16750. */
  16751. export function unregisterClass(...constructor: Function[]): void;
  16752. /**
  16753. Get the registered class by name
  16754. @param classname classname
  16755. */
  16756. export function getClassByName(classname: string): Function;
  16757. /**
  16758. Defines a polyfill field for obsoleted codes.
  16759. @param obj YourObject or YourClass.prototype
  16760. @param obsoleted "OldParam" or "YourClass.OldParam"
  16761. @param newExpr "NewParam" or "YourClass.NewParam"
  16762. @param writable writable
  16763. */
  16764. export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void;
  16765. /**
  16766. Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
  16767. @param obj YourObject or YourClass.prototype
  16768. @param objName "YourObject" or "YourClass"
  16769. @param props props
  16770. @param writable writable
  16771. */
  16772. export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
  16773. /**
  16774. A string tool to construct a string with format string.
  16775. @param msg A JavaScript string containing zero or more substitution strings (%s).
  16776. @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
  16777. @example
  16778. ```js
  16779. cc.js.formatStr("a: %s, b: %s", a, b);
  16780. cc.js.formatStr(a, b, c);
  16781. ```
  16782. */
  16783. export function formatStr(msg: string|any, ...subst: any[]): string;
  16784. /**
  16785. !#en
  16786. A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary.
  16787. !#zh
  16788. 该方法是对 `Object.create(null)` 的简单封装。`Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断。在需要频繁判断 `hasOwnProperty` 时,使用这个方法性能会比 `{}` 更高。
  16789. @param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape.
  16790. */
  16791. export function createMap(forceDictMode?: boolean): any;
  16792. /** undefined */
  16793. export class array {
  16794. /**
  16795. Removes the array item at the specified index.
  16796. @param array array
  16797. @param index index
  16798. */
  16799. static removeAt(array: any[], index: number): void;
  16800. /**
  16801. Removes the array item at the specified index.
  16802. It's faster but the order of the array will be changed.
  16803. @param array array
  16804. @param index index
  16805. */
  16806. static fastRemoveAt(array: any[], index: number): void;
  16807. /**
  16808. Removes the first occurrence of a specific object from the array.
  16809. @param array array
  16810. @param value value
  16811. */
  16812. static remove(array: any[], value: any): boolean;
  16813. /**
  16814. Removes the first occurrence of a specific object from the array.
  16815. It's faster but the order of the array will be changed.
  16816. @param array array
  16817. @param value value
  16818. */
  16819. static fastRemove(array: any[], value: number): void;
  16820. /**
  16821. Verify array's Type
  16822. @param array array
  16823. @param type type
  16824. */
  16825. static verifyType(array: any[], type: Function): boolean;
  16826. /**
  16827. Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
  16828. @param array Source Array
  16829. @param minusArr minus Array
  16830. */
  16831. static removeArray(array: any[], minusArr: any[]): void;
  16832. /**
  16833. Inserts some objects at index
  16834. @param array array
  16835. @param addObjs addObjs
  16836. @param index index
  16837. */
  16838. static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
  16839. /**
  16840. Exact same function as Array.prototype.indexOf.<br>
  16841. HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop.<br>
  16842. Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf, Seriously!
  16843. @param searchElement Element to locate in the array.
  16844. @param fromIndex The index to start the search at
  16845. */
  16846. static indexOf(searchElement: any, fromIndex?: number): number;
  16847. /**
  16848. Determines whether the array contains a specific value.
  16849. @param array array
  16850. @param value value
  16851. */
  16852. static contains(array: any[], value: any): boolean;
  16853. /**
  16854. Copy an array's item to a new array (its performance is better than Array.slice)
  16855. @param array array
  16856. */
  16857. static copy(array: any[]): any[];
  16858. }
  16859. /** !#en
  16860. A fixed-length object pool designed for general type.<br>
  16861. The implementation of this object pool is very simple,
  16862. it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
  16863. !#zh
  16864. 长度固定的对象缓存池,可以用来缓存各种对象类型。<br/>
  16865. 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。 */
  16866. export class Pool {
  16867. /**
  16868. !#en
  16869. Constructor for creating an object pool for the specific object type.
  16870. You can pass a callback argument for process the cleanup logic when the object is recycled.
  16871. !#zh
  16872. 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
  16873. @param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
  16874. @param size initializes the length of the array
  16875. */
  16876. constructor(cleanupFunc: (obj: any) => void, size: number);
  16877. constructor(size: number);
  16878. /**
  16879. !#en
  16880. Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
  16881. !#zh
  16882. 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
  16883. @param params parameters to used to initialize the object
  16884. */
  16885. get(...params: any[]): any;
  16886. /** !#en
  16887. The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
  16888. the maximum will not exceed the size specified when the constructor is called.
  16889. !#zh
  16890. 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。 */
  16891. count: number;
  16892. /**
  16893. !#en
  16894. Get an object from pool, if no available object in the pool, null will be returned.
  16895. !#zh
  16896. 获取对象池中的对象,如果对象池没有可用对象,则返回空。
  16897. */
  16898. _get(): any;
  16899. /**
  16900. !#en Put an object into the pool.
  16901. !#zh 向对象池返还一个不再需要的对象。
  16902. */
  16903. put(): void;
  16904. /**
  16905. !#en Resize the pool.
  16906. !#zh 设置对象池容量。
  16907. */
  16908. resize(): void;
  16909. }
  16910. }
  16911. declare namespace dragonBones {
  16912. /**
  16913. * @private
  16914. */
  16915. const enum ArmatureType {
  16916. Armature = 0,
  16917. MovieClip = 1,
  16918. Stage = 2,
  16919. }
  16920. /**
  16921. * @private
  16922. */
  16923. const enum DisplayType {
  16924. Image = 0,
  16925. Armature = 1,
  16926. Mesh = 2,
  16927. }
  16928. /**
  16929. * @private
  16930. */
  16931. const enum ExtensionType {
  16932. FFD = 0,
  16933. AdjustColor = 10,
  16934. BevelFilter = 11,
  16935. BlurFilter = 12,
  16936. DropShadowFilter = 13,
  16937. GlowFilter = 14,
  16938. GradientBevelFilter = 15,
  16939. GradientGlowFilter = 16,
  16940. }
  16941. /**
  16942. * @private
  16943. */
  16944. const enum EventType {
  16945. Frame = 10,
  16946. Sound = 11,
  16947. }
  16948. /**
  16949. * @private
  16950. */
  16951. const enum ActionType {
  16952. Play = 0,
  16953. Stop = 1,
  16954. GotoAndPlay = 2,
  16955. GotoAndStop = 3,
  16956. FadeIn = 4,
  16957. FadeOut = 5,
  16958. }
  16959. /**
  16960. * @private
  16961. */
  16962. const enum BlendMode {
  16963. Normal = 0,
  16964. Add = 1,
  16965. Alpha = 2,
  16966. Darken = 3,
  16967. Difference = 4,
  16968. Erase = 5,
  16969. HardLight = 6,
  16970. Invert = 7,
  16971. Layer = 8,
  16972. Lighten = 9,
  16973. Multiply = 10,
  16974. Overlay = 11,
  16975. Screen = 12,
  16976. Subtract = 13,
  16977. }
  16978. /**
  16979. * @private
  16980. */
  16981. interface Map<T> {
  16982. [key: string]: T;
  16983. }
  16984. /**
  16985. * DragonBones
  16986. */
  16987. class DragonBones {
  16988. /**
  16989. * @private
  16990. */
  16991. static PI_D: number;
  16992. /**
  16993. * @private
  16994. */
  16995. static PI_H: number;
  16996. /**
  16997. * @private
  16998. */
  16999. static PI_Q: number;
  17000. /**
  17001. * @private
  17002. */
  17003. static ANGLE_TO_RADIAN: number;
  17004. /**
  17005. * @private
  17006. */
  17007. static RADIAN_TO_ANGLE: number;
  17008. /**
  17009. * @private
  17010. */
  17011. static SECOND_TO_MILLISECOND: number;
  17012. static VERSION: string;
  17013. /**
  17014. * @private
  17015. */
  17016. static debug: boolean;
  17017. /**
  17018. * @private
  17019. */
  17020. static debugDraw: boolean;
  17021. }
  17022. }
  17023. declare namespace dragonBones {
  17024. /**
  17025. * @language zh_CN
  17026. * 基础对象。
  17027. * @version DragonBones 4.5
  17028. */
  17029. abstract class BaseObject {
  17030. private static _hashCode;
  17031. private static _defaultMaxCount;
  17032. private static _maxCountMap;
  17033. private static _poolsMap;
  17034. private static _returnObject(object);
  17035. /**
  17036. * @language zh_CN
  17037. * 设置每种对象池的最大缓存数量。
  17038. * @param objectConstructor 对象类。
  17039. * @param maxCount 最大缓存数量。 (设置为 0 则不缓存)
  17040. * @version DragonBones 4.5
  17041. */
  17042. static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
  17043. /**
  17044. * @language zh_CN
  17045. * 清除对象池缓存的对象。
  17046. * @param objectConstructor 对象类。 (不设置则清除所有缓存)
  17047. * @version DragonBones 4.5
  17048. */
  17049. static clearPool(objectConstructor?: typeof BaseObject): void;
  17050. /**
  17051. * @language zh_CN
  17052. * 从对象池中创建指定对象。
  17053. * @param objectConstructor 对象类。
  17054. * @version DragonBones 4.5
  17055. */
  17056. static borrowObject<T extends BaseObject>(objectConstructor: {
  17057. new (): T;
  17058. }): T;
  17059. /**
  17060. * @language zh_CN
  17061. * 对象的唯一标识。
  17062. * @version DragonBones 4.5
  17063. */
  17064. hashCode: number;
  17065. /**
  17066. * @private
  17067. */
  17068. protected abstract _onClear(): void;
  17069. /**
  17070. * @language zh_CN
  17071. * 清除数据并返还对象池。
  17072. * @version DragonBones 4.5
  17073. */
  17074. returnToPool(): void;
  17075. }
  17076. }
  17077. declare namespace dragonBones {
  17078. }
  17079. declare namespace dragonBones {
  17080. /**
  17081. * @language zh_CN
  17082. * 动画混合时,使用的淡出方式。
  17083. * @see dragonBones.Animation#fadeIn()
  17084. * @version DragonBones 4.5
  17085. */
  17086. const enum AnimationFadeOutMode {
  17087. /**
  17088. * @language zh_CN
  17089. * 不淡出动画。
  17090. * @version DragonBones 4.5
  17091. */
  17092. None = 0,
  17093. /**
  17094. * @language zh_CN
  17095. * 淡出同层的动画。
  17096. * @version DragonBones 4.5
  17097. */
  17098. SameLayer = 1,
  17099. /**
  17100. * @language zh_CN
  17101. * 淡出同组的动画。
  17102. * @version DragonBones 4.5
  17103. */
  17104. SameGroup = 2,
  17105. /**
  17106. * @language zh_CN
  17107. * 淡出同层并且同组的动画。
  17108. * @version DragonBones 4.5
  17109. */
  17110. SameLayerAndGroup = 3,
  17111. /**
  17112. * @language zh_CN
  17113. * 淡出所有动画。
  17114. * @version DragonBones 4.5
  17115. */
  17116. All = 4,
  17117. }
  17118. /**
  17119. * @language zh_CN
  17120. * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口)
  17121. * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。
  17122. * @see dragonBones.WorldClock
  17123. * @see dragonBones.Armature
  17124. * @version DragonBones 3.0
  17125. */
  17126. interface IAnimateble {
  17127. /**
  17128. * @language zh_CN
  17129. * 更新一个指定的时间。
  17130. * @param passedTime 前进的时间。 (以秒为单位)
  17131. * @version DragonBones 3.0
  17132. */
  17133. advanceTime(passedTime: number): void;
  17134. }
  17135. /**
  17136. * @language zh_CN
  17137. * 动画控制器,用来播放动画数据,管理动画状态。
  17138. * @see dragonBones.AnimationData
  17139. * @see dragonBones.AnimationState
  17140. * @version DragonBones 3.0
  17141. */
  17142. class Animation extends BaseObject {
  17143. /**
  17144. * @private
  17145. */
  17146. private static _sortAnimationState(a, b);
  17147. /**
  17148. * @private
  17149. */
  17150. static toString(): string;
  17151. /**
  17152. * @language zh_CN
  17153. * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17154. * @default 1
  17155. * @version DragonBones 3.0
  17156. */
  17157. timeScale: number;
  17158. /**
  17159. * @private
  17160. */
  17161. _armature: Armature;
  17162. private _isPlaying;
  17163. private _time;
  17164. private _duration;
  17165. private _lastAnimationState;
  17166. private _animations;
  17167. private _animationNames;
  17168. private _animationStates;
  17169. /**
  17170. * @inheritDoc
  17171. */
  17172. protected _onClear(): void;
  17173. private _fadeOut(fadeOutTime, layer, group, fadeOutMode, pauseFadeOut);
  17174. /**
  17175. * @language zh_CN
  17176. * 清除所有正在播放的动画状态。
  17177. * @version DragonBones 4.5
  17178. */
  17179. reset(): void;
  17180. /**
  17181. * @language zh_CN
  17182. * 暂停播放动画。
  17183. * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。
  17184. * @see dragonBones.AnimationState
  17185. * @version DragonBones 3.0
  17186. */
  17187. stop(animationName?: string): void;
  17188. /**
  17189. * @language zh_CN
  17190. * 播放动画。
  17191. * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。
  17192. * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17193. * @returns 返回控制这个动画数据的动画状态。
  17194. * @see dragonBones.AnimationState
  17195. * @version DragonBones 3.0
  17196. */
  17197. play(animationName?: string, playTimes?: number): AnimationState;
  17198. /**
  17199. * @language zh_CN
  17200. * 淡入播放指定名称的动画。
  17201. * @param animationName 动画数据的名称。
  17202. * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17203. * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
  17204. * @param layer 混合的图层,图层高会优先获取混合权重。
  17205. * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
  17206. * @param fadeOutMode 淡出的模式。
  17207. * @param additiveBlending 以叠加的形式混合。
  17208. * @param displayControl 是否对显示对象属性可控。
  17209. * @param pauseFadeOut 暂停需要淡出的动画。
  17210. * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
  17211. * @returns 返回控制这个动画数据的动画状态。
  17212. * @see dragonBones.AnimationFadeOutMode
  17213. * @see dragonBones.AnimationState
  17214. * @version DragonBones 4.5
  17215. */
  17216. fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17217. /**
  17218. * @language zh_CN
  17219. * 指定名称的动画从指定时间开始播放。
  17220. * @param animationName 动画数据的名称。
  17221. * @param time 时间。 (以秒为单位)
  17222. * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17223. * @param toTime 播放到指定的时间,如果未设置则播放整个动画。
  17224. * @returns 返回控制这个动画数据的动画状态。
  17225. * @see dragonBones.AnimationState
  17226. * @version DragonBones 4.5
  17227. */
  17228. gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number, toTime?: number): AnimationState;
  17229. /**
  17230. * @language zh_CN
  17231. * 指定名称的动画从指定帧开始播放。
  17232. * @param animationName 动画数据的名称。
  17233. * @param frame 帧。
  17234. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17235. * @param toFrame 播放到指定的帧,如果未设置则播放整个动画。
  17236. * @returns 返回控制这个动画数据的动画状态。
  17237. * @see dragonBones.AnimationState
  17238. * @version DragonBones 4.5
  17239. */
  17240. gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number, toFrame?: number): AnimationState;
  17241. /**
  17242. * @language zh_CN
  17243. * 指定名称的动画从指定进度开始播放。
  17244. * @param animationName 动画数据的名称。
  17245. * @param progress 进度。 [0~1]
  17246. * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
  17247. * @param toProgress 播放到指定的进度,如果未设置则播放整个动画。
  17248. * @returns 返回控制这个动画数据的动画状态。
  17249. * @see dragonBones.AnimationState
  17250. * @version DragonBones 4.5
  17251. */
  17252. gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number, toProgress?: number): AnimationState;
  17253. /**
  17254. * @language zh_CN
  17255. * 播放指定名称的动画到指定的时间并停止。
  17256. * @param animationName 动画数据的名称。
  17257. * @param time 时间。 (以秒为单位)
  17258. * @returns 返回控制这个动画数据的动画状态。
  17259. * @see dragonBones.AnimationState
  17260. * @version DragonBones 4.5
  17261. */
  17262. gotoAndStopByTime(animationName: string, time?: number): AnimationState;
  17263. /**
  17264. * @language zh_CN
  17265. * 播放指定名称的动画到指定的帧并停止。
  17266. * @param animationName 动画数据的名称。
  17267. * @param frame 帧。
  17268. * @returns 返回控制这个动画数据的动画状态。
  17269. * @see dragonBones.AnimationState
  17270. * @version DragonBones 4.5
  17271. */
  17272. gotoAndStopByFrame(animationName: string, frame?: number): AnimationState;
  17273. /**
  17274. * @language zh_CN
  17275. * 播放指定名称的动画到指定的进度并停止。
  17276. * @param animationName 动画数据的名称。
  17277. * @param progress 进度。 [0~1]
  17278. * @returns 返回控制这个动画数据的动画状态。
  17279. * @see dragonBones.AnimationState
  17280. * @version DragonBones 4.5
  17281. */
  17282. gotoAndStopByProgress(animationName: string, progress?: number): AnimationState;
  17283. /**
  17284. * @language zh_CN
  17285. * 获取指定名称的动画状态。
  17286. * @param animationName 动画状态的名称。
  17287. * @see dragonBones.AnimationState
  17288. * @version DragonBones 3.0
  17289. */
  17290. getState(animationName: string): AnimationState;
  17291. /**
  17292. * @language zh_CN
  17293. * 是否包含指定名称的动画数据。
  17294. * @param animationName 动画数据的名称。
  17295. * @see dragonBones.AnimationData
  17296. * @version DragonBones 3.0
  17297. */
  17298. hasAnimation(animationName: string): boolean;
  17299. /**
  17300. * @language zh_CN
  17301. * 动画是否处于播放状态。
  17302. * @version DragonBones 3.0
  17303. */
  17304. isPlaying: boolean;
  17305. /**
  17306. * @language zh_CN
  17307. * 所有动画状态是否均已播放完毕。
  17308. * @see dragonBones.AnimationState
  17309. * @version DragonBones 3.0
  17310. */
  17311. isCompleted: boolean;
  17312. /**
  17313. * @language zh_CN
  17314. * 上一个正在播放的动画状态的名称。
  17315. * @see #lastAnimationState
  17316. * @version DragonBones 3.0
  17317. */
  17318. lastAnimationName: string;
  17319. /**
  17320. * @language zh_CN
  17321. * 上一个正在播放的动画状态。
  17322. * @see dragonBones.AnimationState
  17323. * @version DragonBones 3.0
  17324. */
  17325. lastAnimationState: AnimationState;
  17326. /**
  17327. * @language zh_CN
  17328. * 所有动画数据名称。
  17329. * @see #animations
  17330. * @version DragonBones 4.5
  17331. */
  17332. animationNames: Array<string>;
  17333. /**
  17334. * @language zh_CN
  17335. * 所有的动画数据。
  17336. * @see dragonBones.AnimationData
  17337. * @version DragonBones 4.5
  17338. */
  17339. animations: Map<AnimationData>;
  17340. /**
  17341. * @deprecated
  17342. * @see #play()
  17343. * @see #fadeIn()
  17344. * @see #gotoAndPlayByTime()
  17345. * @see #gotoAndPlayByFrame()
  17346. * @see #gotoAndPlayByProgress()
  17347. */
  17348. gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState;
  17349. /**
  17350. * @deprecated
  17351. * @see #gotoAndStopByTime()
  17352. * @see #gotoAndStopByFrame()
  17353. * @see #gotoAndStopByProgress()
  17354. */
  17355. gotoAndStop(animationName: string, time?: number): AnimationState;
  17356. /**
  17357. * @deprecated
  17358. * @see #animationNames
  17359. * @see #animations
  17360. */
  17361. animationList: Array<string>;
  17362. /**
  17363. * @language zh_CN
  17364. * @deprecated
  17365. * @see #animationNames
  17366. * @see #animations
  17367. */
  17368. animationDataList: Array<AnimationData>;
  17369. }
  17370. }
  17371. declare namespace dragonBones {
  17372. /**
  17373. * @language zh_CN
  17374. * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。
  17375. * @see dragonBones.Animation
  17376. * @see dragonBones.AnimationData
  17377. * @version DragonBones 3.0
  17378. */
  17379. class AnimationState extends BaseObject {
  17380. /**
  17381. * @private
  17382. */
  17383. static stateActionEnabled: boolean;
  17384. /**
  17385. * @private
  17386. */
  17387. static toString(): string;
  17388. /**
  17389. * @language zh_CN
  17390. * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。
  17391. * @see dragonBones.Slot#displayController
  17392. * @version DragonBones 3.0
  17393. */
  17394. displayControl: boolean;
  17395. /**
  17396. * @language zh_CN
  17397. * 是否以叠加的方式混合动画。
  17398. * @version DragonBones 3.0
  17399. */
  17400. additiveBlending: boolean;
  17401. /**
  17402. * @private
  17403. */
  17404. actionEnabled: boolean;
  17405. /**
  17406. * @language zh_CN
  17407. * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  17408. * @version DragonBones 3.0
  17409. */
  17410. playTimes: number;
  17411. /**
  17412. * @language zh_CN
  17413. * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17414. * @default 1
  17415. * @version DragonBones 3.0
  17416. */
  17417. timeScale: number;
  17418. /**
  17419. * @language zh_CN
  17420. * 进行动画混合时的权重。
  17421. * @default 1
  17422. * @version DragonBones 3.0
  17423. */
  17424. weight: number;
  17425. /**
  17426. * @language zh_CN
  17427. * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位)
  17428. * @default -1
  17429. * @version DragonBones 3.0
  17430. */
  17431. autoFadeOutTime: number;
  17432. /**
  17433. * @private
  17434. */
  17435. fadeTotalTime: number;
  17436. /**
  17437. * @private
  17438. */
  17439. private _isPlaying;
  17440. /**
  17441. * @private
  17442. */
  17443. private _isPausePlayhead;
  17444. /**
  17445. * @private
  17446. */
  17447. private _fadeTime;
  17448. /**
  17449. * @private
  17450. */
  17451. private _time;
  17452. /**
  17453. * @private
  17454. */
  17455. private _name;
  17456. /**
  17457. * @private
  17458. */
  17459. private _armature;
  17460. /**
  17461. * @private
  17462. */
  17463. private _animationData;
  17464. /**
  17465. * @private
  17466. */
  17467. private _zOrderTimeline;
  17468. /**
  17469. * @private
  17470. */
  17471. private _boneMask;
  17472. /**
  17473. * @private
  17474. */
  17475. private _boneTimelines;
  17476. /**
  17477. * @private
  17478. */
  17479. private _slotTimelines;
  17480. /**
  17481. * @private
  17482. */
  17483. private _ffdTimelines;
  17484. /**
  17485. * @inheritDoc
  17486. */
  17487. protected _onClear(): void;
  17488. private _updateTimelineStates();
  17489. private _advanceFadeTime(passedTime);
  17490. /**
  17491. * @language zh_CN
  17492. * 继续播放。
  17493. * @version DragonBones 3.0
  17494. */
  17495. play(): void;
  17496. /**
  17497. * @language zh_CN
  17498. * 暂停播放。
  17499. * @version DragonBones 3.0
  17500. */
  17501. stop(): void;
  17502. /**
  17503. * @language zh_CN
  17504. * 淡出动画。
  17505. * @param fadeOutTime 淡出时间。 (以秒为单位)
  17506. * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停]
  17507. * @version DragonBones 3.0
  17508. */
  17509. fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
  17510. /**
  17511. * @language zh_CN
  17512. * 是否包含指定的骨骼遮罩。
  17513. * @param name 指定的骨骼名称。
  17514. * @version DragonBones 3.0
  17515. */
  17516. containsBoneMask(name: string): boolean;
  17517. /**
  17518. * @language zh_CN
  17519. * 添加指定的骨骼遮罩。
  17520. * @param boneName 指定的骨骼名称。
  17521. * @param recursive 是否为该骨骼的子骨骼添加遮罩。
  17522. * @version DragonBones 3.0
  17523. */
  17524. addBoneMask(name: string, recursive?: boolean): void;
  17525. /**
  17526. * @language zh_CN
  17527. * 删除指定的骨骼遮罩。
  17528. * @param boneName 指定的骨骼名称。
  17529. * @param recursive 是否删除该骨骼的子骨骼遮罩。
  17530. * @version DragonBones 3.0
  17531. */
  17532. removeBoneMask(name: string, recursive?: boolean): void;
  17533. /**
  17534. * @language zh_CN
  17535. * 删除所有骨骼遮罩。
  17536. * @version DragonBones 3.0
  17537. */
  17538. removeAllBoneMask(): void;
  17539. /**
  17540. * @language zh_CN
  17541. * 动画图层。
  17542. * @see dragonBones.Animation#fadeIn()
  17543. * @version DragonBones 3.0
  17544. */
  17545. layer: number;
  17546. /**
  17547. * @language zh_CN
  17548. * 动画组。
  17549. * @see dragonBones.Animation#fadeIn()
  17550. * @version DragonBones 3.0
  17551. */
  17552. group: string;
  17553. /**
  17554. * @language zh_CN
  17555. * 动画名称。
  17556. * @see dragonBones.AnimationData#name
  17557. * @version DragonBones 3.0
  17558. */
  17559. name: string;
  17560. /**
  17561. * @language zh_CN
  17562. * 动画数据。
  17563. * @see dragonBones.AnimationData
  17564. * @version DragonBones 3.0
  17565. */
  17566. animationData: AnimationData;
  17567. /**
  17568. * @language zh_CN
  17569. * 是否播放完毕。
  17570. * @version DragonBones 3.0
  17571. */
  17572. isCompleted: boolean;
  17573. /**
  17574. * @language zh_CN
  17575. * 是否正在播放。
  17576. * @version DragonBones 3.0
  17577. */
  17578. isPlaying: boolean;
  17579. /**
  17580. * @language zh_CN
  17581. * 当前动画的播放次数。
  17582. * @version DragonBones 3.0
  17583. */
  17584. currentPlayTimes: number;
  17585. /**
  17586. * @language zh_CN
  17587. * 当前动画的总时间。 (以秒为单位)
  17588. * @version DragonBones 3.0
  17589. */
  17590. totalTime: number;
  17591. /**
  17592. * @language zh_CN
  17593. * 当前动画的播放时间。 (以秒为单位)
  17594. * @version DragonBones 3.0
  17595. */
  17596. currentTime: number;
  17597. /**
  17598. * @deprecated
  17599. */
  17600. autoTween: boolean;
  17601. /**
  17602. * @deprecated
  17603. * @see #animationData
  17604. */
  17605. clip: AnimationData;
  17606. }
  17607. }
  17608. declare namespace dragonBones {
  17609. }
  17610. declare namespace dragonBones {
  17611. /**
  17612. * @language zh_CN
  17613. * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。
  17614. * @see dragonBones.IAnimatable
  17615. * @see dragonBones.Armature
  17616. * @version DragonBones 3.0
  17617. */
  17618. class WorldClock implements IAnimateble {
  17619. private static _clock;
  17620. /**
  17621. * @language zh_CN
  17622. * 一个可以直接使用的全局 WorldClock 实例.
  17623. * @version DragonBones 3.0
  17624. */
  17625. static clock: WorldClock;
  17626. /**
  17627. * @language zh_CN
  17628. * 当前的时间。 (以秒为单位)
  17629. * @version DragonBones 3.0
  17630. */
  17631. time: number;
  17632. /**
  17633. * @language zh_CN
  17634. * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
  17635. * @default 1
  17636. * @version DragonBones 3.0
  17637. */
  17638. timeScale: number;
  17639. private _animatebles;
  17640. /**
  17641. * @language zh_CN
  17642. * 创建一个新的 WorldClock 实例。
  17643. * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。
  17644. * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放)
  17645. * @version DragonBones 3.0
  17646. */
  17647. constructor();
  17648. /**
  17649. * @language zh_CN
  17650. * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用)
  17651. * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差)
  17652. * @version DragonBones 3.0
  17653. */
  17654. advanceTime(passedTime: number): void;
  17655. /**
  17656. * 是否包含指定的 IAnimatable 实例
  17657. * @param value 指定的 IAnimatable 实例。
  17658. * @returns [true: 包含,false: 不包含]。
  17659. * @version DragonBones 3.0
  17660. */
  17661. contains(value: IAnimateble): boolean;
  17662. /**
  17663. * @language zh_CN
  17664. * 添加指定的 IAnimatable 实例。
  17665. * @param value IAnimatable 实例。
  17666. * @version DragonBones 3.0
  17667. */
  17668. add(value: IAnimateble): void;
  17669. /**
  17670. * @language zh_CN
  17671. * 移除指定的 IAnimatable 实例。
  17672. * @param value IAnimatable 实例。
  17673. * @version DragonBones 3.0
  17674. */
  17675. remove(value: IAnimateble): void;
  17676. /**
  17677. * @language zh_CN
  17678. * 清除所有的 IAnimatable 实例。
  17679. * @version DragonBones 3.0
  17680. */
  17681. clear(): void;
  17682. }
  17683. }
  17684. declare namespace dragonBones {
  17685. /**
  17686. * @language zh_CN
  17687. * 基础变换对象。
  17688. * @version DragonBones 4.5
  17689. */
  17690. abstract class TransformObject extends BaseObject {
  17691. /**
  17692. * @language zh_CN
  17693. * 可以用于存储临时数据。
  17694. * @version DragonBones 3.0
  17695. */
  17696. userData: any;
  17697. /**
  17698. * @language zh_CN
  17699. * 对象的名称。
  17700. * @version DragonBones 3.0
  17701. */
  17702. name: string;
  17703. /**
  17704. * @language zh_CN
  17705. * 相对于骨架坐标系的矩阵。
  17706. * @version DragonBones 3.0
  17707. */
  17708. globalTransformMatrix: Matrix;
  17709. /**
  17710. * @language zh_CN
  17711. * 相对于骨架坐标系的变换。
  17712. * @see dragonBones.Transform
  17713. * @version DragonBones 3.0
  17714. */
  17715. global: Transform;
  17716. /**
  17717. * @language zh_CN
  17718. * 相对于骨架或父骨骼坐标系的绑定变换。
  17719. * @see dragonBones.Transform
  17720. * @version DragonBones 3.0
  17721. */
  17722. origin: Transform;
  17723. /**
  17724. * @language zh_CN
  17725. * 相对于骨架或父骨骼坐标系的偏移变换。
  17726. * @see dragonBones.Transform
  17727. * @version DragonBones 3.0
  17728. */
  17729. offset: Transform;
  17730. /**
  17731. * @private
  17732. */
  17733. _armature: Armature;
  17734. /**
  17735. * @private
  17736. */
  17737. _parent: Bone;
  17738. /**
  17739. * @private
  17740. */
  17741. protected _globalTransformMatrix: Matrix;
  17742. /**
  17743. * @inheritDoc
  17744. */
  17745. protected _onClear(): void;
  17746. /**
  17747. * @language zh_CN
  17748. * 所属的骨架。
  17749. * @see dragonBones.Armature
  17750. * @version DragonBones 3.0
  17751. */
  17752. armature: Armature;
  17753. /**
  17754. * @language zh_CN
  17755. * 所属的父骨骼。
  17756. * @see dragonBones.Bone
  17757. * @version DragonBones 3.0
  17758. */
  17759. parent: Bone;
  17760. }
  17761. }
  17762. declare namespace dragonBones {
  17763. /**
  17764. * @language zh_CN
  17765. * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。
  17766. * @see dragonBones.ArmatureData
  17767. * @see dragonBones.Bone
  17768. * @see dragonBones.Slot
  17769. * @see dragonBones.Animation
  17770. * @see dragonBones.IArmatureDisplay
  17771. * @version DragonBones 3.0
  17772. */
  17773. class Armature extends BaseObject implements IAnimateble {
  17774. /**
  17775. * @private
  17776. */
  17777. static toString(): string;
  17778. private static _onSortSlots(a, b);
  17779. /**
  17780. * @language zh_CN
  17781. * 可以用于存储临时数据。
  17782. * @version DragonBones 3.0
  17783. */
  17784. userData: any;
  17785. /**
  17786. * @private
  17787. */
  17788. _cacheFrameIndex: number;
  17789. /**
  17790. * @private
  17791. */
  17792. _armatureData: ArmatureData;
  17793. /**
  17794. * @private
  17795. */
  17796. _skinData: SkinData;
  17797. /**
  17798. * @private
  17799. */
  17800. _animation: Animation;
  17801. /**
  17802. * @private
  17803. */
  17804. _display: IArmatureDisplay;
  17805. /**
  17806. * @private
  17807. */
  17808. _eventManager: IEventDispatcher;
  17809. private _delayDispose;
  17810. private _lockDispose;
  17811. private _slotsDirty;
  17812. private _replacedTexture;
  17813. private _bones;
  17814. private _slots;
  17815. private _actions;
  17816. private _events;
  17817. /**
  17818. * @inheritDoc
  17819. */
  17820. protected _onClear(): void;
  17821. private _sortBones();
  17822. private _sortSlots();
  17823. private _doAction(value);
  17824. /**
  17825. * @private
  17826. */
  17827. _sortZOrder(slotIndices: Array<number>): void;
  17828. /**
  17829. * @private
  17830. */
  17831. _bufferAction(value: ActionData): void;
  17832. /**
  17833. * @language zh_CN
  17834. * 释放骨架。 (会回收到内存池)
  17835. * @version DragonBones 3.0
  17836. */
  17837. dispose(): void;
  17838. /**
  17839. * @language zh_CN
  17840. * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新)
  17841. * @param passedTime 两帧之前的时间间隔。 (以秒为单位)
  17842. * @see dragonBones.IAnimateble
  17843. * @see dragonBones.WorldClock
  17844. * @see dragonBones.IArmatureDisplay
  17845. * @version DragonBones 3.0
  17846. */
  17847. advanceTime(passedTime: number): void;
  17848. /**
  17849. * @language zh_CN
  17850. * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  17851. * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。
  17852. * @param updateSlotDisplay 是否更新插槽的显示对象。
  17853. * @see dragonBones.Bone
  17854. * @see dragonBones.Slot
  17855. * @version DragonBones 3.0
  17856. */
  17857. invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void;
  17858. /**
  17859. * @language zh_CN
  17860. * 获取指定名称的骨骼。
  17861. * @param name 骨骼的名称。
  17862. * @returns 骨骼。
  17863. * @see dragonBones.Bone
  17864. * @version DragonBones 3.0
  17865. */
  17866. getBone(name: string): Bone;
  17867. /**
  17868. * @language zh_CN
  17869. * 通过显示对象获取骨骼。
  17870. * @param display 显示对象。
  17871. * @returns 包含这个显示对象的骨骼。
  17872. * @see dragonBones.Bone
  17873. * @version DragonBones 3.0
  17874. */
  17875. getBoneByDisplay(display: any): Bone;
  17876. /**
  17877. * @language zh_CN
  17878. * 获取指定名称的插槽。
  17879. * @param name 插槽的名称。
  17880. * @returns 插槽。
  17881. * @see dragonBones.Slot
  17882. * @version DragonBones 3.0
  17883. */
  17884. getSlot(name: string): Slot;
  17885. /**
  17886. * @language zh_CN
  17887. * 通过显示对象获取插槽。
  17888. * @param display 显示对象。
  17889. * @returns 包含这个显示对象的插槽。
  17890. * @see dragonBones.Slot
  17891. * @version DragonBones 3.0
  17892. */
  17893. getSlotByDisplay(display: any): Slot;
  17894. /**
  17895. * @language zh_CN
  17896. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17897. * @param texture 贴图。
  17898. * @version DragonBones 4.5
  17899. */
  17900. replaceTexture(texture: any): void;
  17901. /**
  17902. * @language zh_CN
  17903. * 获取所有骨骼。
  17904. * @see dragonBones.Bone
  17905. * @version DragonBones 3.0
  17906. */
  17907. getBones(): Array<Bone>;
  17908. /**
  17909. * @language zh_CN
  17910. * 获取所有插槽。
  17911. * @see dragonBones.Slot
  17912. * @version DragonBones 3.0
  17913. */
  17914. getSlots(): Array<Slot>;
  17915. /**
  17916. * @language zh_CN
  17917. * 骨架名称。
  17918. * @see dragonBones.ArmatureData#name
  17919. * @version DragonBones 3.0
  17920. */
  17921. name: string;
  17922. /**
  17923. * @language zh_CN
  17924. * 获取骨架数据。
  17925. * @see dragonBones.ArmatureData
  17926. * @version DragonBones 4.5
  17927. */
  17928. armatureData: ArmatureData;
  17929. /**
  17930. * @language zh_CN
  17931. * 获得动画控制器。
  17932. * @see dragonBones.Animation
  17933. * @version DragonBones 3.0
  17934. */
  17935. animation: Animation;
  17936. /**
  17937. * @language zh_CN
  17938. * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。
  17939. * @version DragonBones 3.0
  17940. */
  17941. display: IArmatureDisplay | any;
  17942. /**
  17943. * @language zh_CN
  17944. * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系)
  17945. * @see dragonBones.Slot
  17946. * @version DragonBones 4.5
  17947. */
  17948. parent: Slot;
  17949. /**
  17950. * @language zh_CN
  17951. * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。
  17952. * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。
  17953. * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。
  17954. * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。
  17955. * @see dragonBones.DragonBonesData#frameRate
  17956. * @see dragonBones.ArmatureData#frameRate
  17957. * @version DragonBones 4.5
  17958. */
  17959. cacheFrameRate: number;
  17960. /**
  17961. * @language zh_CN
  17962. * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。
  17963. * @version DragonBones 4.5
  17964. */
  17965. replacedTexture: any;
  17966. /**
  17967. * @language zh_CN
  17968. * 开启动画缓存。
  17969. * @param frameRate 动画缓存的帧率
  17970. * @see #cacheFrameRate
  17971. * @version DragonBones 4.5
  17972. */
  17973. enableAnimationCache(frameRate: number): void;
  17974. /**
  17975. * @language zh_CN
  17976. * 是否包含指定类型的事件。
  17977. * @param type 事件类型。
  17978. * @returns [true: 包含, false: 不包含]
  17979. * @version DragonBones 3.0
  17980. */
  17981. hasEventListener(type: EventStringType): void;
  17982. /**
  17983. * @language zh_CN
  17984. * 添加事件。
  17985. * @param type 事件类型。
  17986. * @param listener 事件回调。
  17987. * @version DragonBones 3.0
  17988. */
  17989. addEventListener(type: EventStringType, listener: Function, target: any): void;
  17990. /**
  17991. * @language zh_CN
  17992. * 移除事件。
  17993. * @param type 事件类型。
  17994. * @param listener 事件回调。
  17995. * @version DragonBones 3.0
  17996. */
  17997. removeEventListener(type: EventStringType, listener: Function, target: any): void;
  17998. /**
  17999. * @deprecated
  18000. */
  18001. addBone(value: Bone, parentName?: string): void;
  18002. /**
  18003. * @deprecated
  18004. */
  18005. addSlot(value: Slot, parentName: string): void;
  18006. /**
  18007. * @deprecated
  18008. */
  18009. removeBone(value: Bone): void;
  18010. /**
  18011. * @deprecated
  18012. */
  18013. removeSlot(value: Slot): void;
  18014. /**
  18015. * @deprecated
  18016. * @see #display
  18017. */
  18018. getDisplay(): any;
  18019. /**
  18020. * @deprecated
  18021. * @see #cacheFrameRate
  18022. */
  18023. enableCache: boolean;
  18024. }
  18025. }
  18026. declare namespace dragonBones {
  18027. /**
  18028. * @language zh_CN
  18029. * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。
  18030. * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。
  18031. * @see dragonBones.BoneData
  18032. * @see dragonBones.Armature
  18033. * @see dragonBones.Slot
  18034. * @version DragonBones 3.0
  18035. */
  18036. class Bone extends TransformObject {
  18037. /**
  18038. * @private
  18039. */
  18040. static toString(): string;
  18041. /**
  18042. * @language zh_CN
  18043. * 是否继承父骨骼的平移。 [true: 继承, false: 不继承]
  18044. * @version DragonBones 3.0
  18045. */
  18046. inheritTranslation: boolean;
  18047. /**
  18048. * @language zh_CN
  18049. * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承]
  18050. * @version DragonBones 3.0
  18051. */
  18052. inheritRotation: boolean;
  18053. /**
  18054. * @language zh_CN
  18055. * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承]
  18056. * @version DragonBones 4.5
  18057. */
  18058. inheritScale: boolean;
  18059. /**
  18060. * @language zh_CN
  18061. * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针]
  18062. * @version DragonBones 4.5
  18063. */
  18064. ikBendPositive: boolean;
  18065. /**
  18066. * @language zh_CN
  18067. * IK 约束的权重。
  18068. * @version DragonBones 4.5
  18069. */
  18070. ikWeight: number;
  18071. /**
  18072. * @language zh_CN
  18073. * 骨骼长度。
  18074. * @version DragonBones 4.5
  18075. */
  18076. length: number;
  18077. /**
  18078. * @private
  18079. */
  18080. private _visible;
  18081. /**
  18082. * @private
  18083. */
  18084. private _ikChain;
  18085. /**
  18086. * @private
  18087. */
  18088. private _ikChainIndex;
  18089. /**
  18090. * @private
  18091. */
  18092. private _ik;
  18093. /**
  18094. * @private
  18095. */
  18096. private _bones;
  18097. /**
  18098. * @private
  18099. */
  18100. private _slots;
  18101. /**
  18102. * @inheritDoc
  18103. */
  18104. protected _onClear(): void;
  18105. /**
  18106. * @private
  18107. */
  18108. private _updateGlobalTransformMatrix();
  18109. /**
  18110. * @private
  18111. */
  18112. private _computeIKA();
  18113. /**
  18114. * @private
  18115. */
  18116. private _computeIKB();
  18117. /**
  18118. * @inheritDoc
  18119. */
  18120. _setArmature(value: Armature): void;
  18121. /**
  18122. * @language zh_CN
  18123. * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新)
  18124. * @version DragonBones 3.0
  18125. */
  18126. invalidUpdate(): void;
  18127. /**
  18128. * @language zh_CN
  18129. * 是否包含某个指定的骨骼或插槽。
  18130. * @returns [true: 包含,false: 不包含]
  18131. * @see dragonBones.TransformObject
  18132. * @version DragonBones 3.0
  18133. */
  18134. contains(child: TransformObject): boolean;
  18135. /**
  18136. * @language zh_CN
  18137. * 所有的子骨骼。
  18138. * @version DragonBones 3.0
  18139. */
  18140. getBones(): Array<Bone>;
  18141. /**
  18142. * @language zh_CN
  18143. * 所有的插槽。
  18144. * @see dragonBones.Slot
  18145. * @version DragonBones 3.0
  18146. */
  18147. getSlots(): Array<Slot>;
  18148. /**
  18149. * @private
  18150. */
  18151. ikChain: number;
  18152. /**
  18153. * @private
  18154. */
  18155. ikChainIndex: number;
  18156. /**
  18157. * @language zh_CN
  18158. * 当前的 IK 约束目标。
  18159. * @version DragonBones 4.5
  18160. */
  18161. ik: Bone;
  18162. /**
  18163. * @language zh_CN
  18164. * 控制此骨骼所有插槽的显示。
  18165. * @default true
  18166. * @see dragonBones.Slot
  18167. * @version DragonBones 3.0
  18168. */
  18169. visible: boolean;
  18170. /**
  18171. * @deprecated
  18172. * @see dragonBones.Armature#getSlot()
  18173. */
  18174. slot: Slot;
  18175. }
  18176. }
  18177. declare namespace dragonBones {
  18178. /**
  18179. * @language zh_CN
  18180. * 骨架显示容器和事件的接口。
  18181. * @see dragonBones.Armature#display
  18182. * @version DragonBones 4.5
  18183. */
  18184. interface IArmatureDisplay extends IEventDispatcher {
  18185. /**
  18186. * @language zh_CN
  18187. * 释放显示对象和骨架。
  18188. * @version DragonBones 4.5
  18189. */
  18190. dispose(): void;
  18191. /**
  18192. * @language zh_CN
  18193. * 获取使用这个显示容器的骨架。
  18194. * @readOnly
  18195. * @see dragonBones.Armature
  18196. * @version DragonBones 4.5
  18197. */
  18198. armature: Armature;
  18199. /**
  18200. * @language zh_CN
  18201. * 获取使用骨架的动画控制器。
  18202. * @readOnly
  18203. * @see dragonBones.Animation
  18204. * @version DragonBones 4.5
  18205. */
  18206. animation: Animation;
  18207. /**
  18208. * @language zh_CN
  18209. * 由显示容器来更新骨架和动画。
  18210. * @param on 开启或关闭显示容器对骨架与动画的更新。
  18211. * @version DragonBones 4.5
  18212. */
  18213. advanceTimeBySelf(on: boolean): void;
  18214. }
  18215. }
  18216. declare namespace dragonBones {
  18217. /**
  18218. * @language zh_CN
  18219. * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。
  18220. * 一个骨骼上可以包含多个插槽。
  18221. * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  18222. * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  18223. * @see dragonBones.Armature
  18224. * @see dragonBones.Bone
  18225. * @see dragonBones.SlotData
  18226. * @version DragonBones 3.0
  18227. */
  18228. abstract class Slot extends TransformObject {
  18229. private static _helpPoint;
  18230. private static _helpMatrix;
  18231. /**
  18232. * @language zh_CN
  18233. * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承]
  18234. * @default true
  18235. * @version DragonBones 4.5
  18236. */
  18237. inheritAnimation: boolean;
  18238. /**
  18239. * @language zh_CN
  18240. * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。
  18241. * @default null
  18242. * @see dragonBones.AnimationState#displayControl
  18243. * @see dragonBones.AnimationState#name
  18244. * @see dragonBones.AnimationState#group
  18245. * @version DragonBones 4.5
  18246. */
  18247. displayController: string;
  18248. /**
  18249. * @private
  18250. */
  18251. _zOrder: number;
  18252. /**
  18253. * @private
  18254. */
  18255. _pivotX: number;
  18256. /**
  18257. * @private
  18258. */
  18259. _pivotY: number;
  18260. /**
  18261. * @private
  18262. */
  18263. _displayDataSet: SlotDisplayDataSet;
  18264. /**
  18265. * @private
  18266. */
  18267. _meshData: MeshData;
  18268. /**
  18269. * @private
  18270. */
  18271. _childArmature: Armature;
  18272. /**
  18273. * @private
  18274. */
  18275. _rawDisplay: any;
  18276. /**
  18277. * @private
  18278. */
  18279. _meshDisplay: any;
  18280. /**
  18281. * @private
  18282. */
  18283. _cacheFrames: Array<Matrix>;
  18284. /**
  18285. * @private
  18286. */
  18287. _colorTransform: ColorTransform;
  18288. /**
  18289. * @private
  18290. */
  18291. _ffdVertices: Array<number>;
  18292. /**
  18293. * @private
  18294. */
  18295. _replacedDisplayDataSet: Array<DisplayData>;
  18296. /**
  18297. * @private
  18298. */
  18299. protected _displayDirty: boolean;
  18300. /**
  18301. * @private
  18302. */
  18303. protected _blendModeDirty: boolean;
  18304. /**
  18305. * @private
  18306. */
  18307. protected _originDirty: boolean;
  18308. /**
  18309. * @private
  18310. */
  18311. protected _transformDirty: boolean;
  18312. /**
  18313. * @private
  18314. */
  18315. protected _displayIndex: number;
  18316. /**
  18317. * @private
  18318. */
  18319. protected _blendMode: BlendMode;
  18320. /**
  18321. * @private
  18322. */
  18323. protected _display: any;
  18324. /**
  18325. * @private
  18326. */
  18327. protected _localMatrix: Matrix;
  18328. /**
  18329. * @private
  18330. */
  18331. protected _displayList: Array<any | Armature>;
  18332. /**
  18333. * @private
  18334. */
  18335. protected _meshBones: Array<Bone>;
  18336. /**
  18337. * @inheritDoc
  18338. */
  18339. protected _onClear(): void;
  18340. /**
  18341. * @private
  18342. */
  18343. protected abstract _initDisplay(value: any): void;
  18344. /**
  18345. * @private
  18346. */
  18347. protected abstract _disposeDisplay(value: any): void;
  18348. /**
  18349. * @private
  18350. */
  18351. protected abstract _onUpdateDisplay(): void;
  18352. /**
  18353. * @private
  18354. */
  18355. protected abstract _addDisplay(): void;
  18356. /**
  18357. * @private
  18358. */
  18359. protected abstract _replaceDisplay(value: any): void;
  18360. /**
  18361. * @private
  18362. */
  18363. protected abstract _removeDisplay(): void;
  18364. /**
  18365. * @private
  18366. */
  18367. protected abstract _updateZOrder(): void;
  18368. /**
  18369. * @private
  18370. */
  18371. protected abstract _updateBlendMode(): void;
  18372. /**
  18373. * @private
  18374. */
  18375. protected abstract _updateColor(): void;
  18376. /**
  18377. * @private
  18378. */
  18379. protected abstract _updateFilters(): void;
  18380. /**
  18381. * @private
  18382. */
  18383. protected abstract _updateFrame(): void;
  18384. /**
  18385. * @private
  18386. */
  18387. protected abstract _updateMesh(): void;
  18388. /**
  18389. * @private
  18390. */
  18391. protected abstract _updateTransform(): void;
  18392. private _isMeshBonesUpdate();
  18393. /**
  18394. * @private
  18395. */
  18396. protected _updatePivot(rawDisplayData: DisplayData, currentDisplayData: DisplayData, currentTextureData: TextureData): void;
  18397. /**
  18398. * @private
  18399. */
  18400. protected _updateDisplay(): void;
  18401. /**
  18402. * @private
  18403. */
  18404. protected _updateLocalTransformMatrix(): void;
  18405. /**
  18406. * @private
  18407. */
  18408. protected _updateGlobalTransformMatrix(): void;
  18409. /**
  18410. * @private Factory
  18411. */
  18412. _setDisplayList(value: Array<any>): boolean;
  18413. /**
  18414. * @language zh_CN
  18415. * 在下一帧更新显示对象的状态。
  18416. * @version DragonBones 4.5
  18417. */
  18418. invalidUpdate(): void;
  18419. /**
  18420. * @private
  18421. */
  18422. rawDisplay: any;
  18423. /**
  18424. * @private
  18425. */
  18426. MeshDisplay: any;
  18427. /**
  18428. * @language zh_CN
  18429. * 此时显示的显示对象在显示列表中的索引。
  18430. * @version DragonBones 4.5
  18431. */
  18432. displayIndex: number;
  18433. /**
  18434. * @language zh_CN
  18435. * 包含显示对象或子骨架的显示列表。
  18436. * @version DragonBones 3.0
  18437. */
  18438. displayList: Array<any>;
  18439. /**
  18440. * @language zh_CN
  18441. * 此时显示的显示对象。
  18442. * @version DragonBones 3.0
  18443. */
  18444. display: any;
  18445. /**
  18446. * @language zh_CN
  18447. * 此时显示的子骨架。
  18448. * @see dragonBones.Armature
  18449. * @version DragonBones 3.0
  18450. */
  18451. childArmature: Armature;
  18452. /**
  18453. * @deprecated
  18454. * @see #display
  18455. */
  18456. getDisplay(): any;
  18457. /**
  18458. * @deprecated
  18459. * @see #display
  18460. */
  18461. setDisplay(value: any): void;
  18462. }
  18463. }
  18464. declare namespace dragonBones {
  18465. /**
  18466. * @private
  18467. */
  18468. type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
  18469. /**
  18470. * @language zh_CN
  18471. * 事件接口。
  18472. * @version DragonBones 4.5
  18473. */
  18474. interface IEventDispatcher {
  18475. /**
  18476. * @language zh_CN
  18477. * 是否包含指定类型的事件。
  18478. * @param type 事件类型。
  18479. * @returns [true: 包含, false: 不包含]
  18480. * @version DragonBones 4.5
  18481. */
  18482. hasEvent(type: EventStringType): boolean;
  18483. /**
  18484. * @language zh_CN
  18485. * 添加事件。
  18486. * @param type 事件类型。
  18487. * @param listener 事件回调。
  18488. * @version DragonBones 4.5
  18489. */
  18490. addEvent(type: EventStringType, listener: Function, target: any): void;
  18491. /**
  18492. * @language zh_CN
  18493. * 移除事件。
  18494. * @param type 事件类型。
  18495. * @param listener 事件回调。
  18496. * @version DragonBones 4.5
  18497. */
  18498. removeEvent(type: EventStringType, listener: Function, target: any): void;
  18499. }
  18500. /**
  18501. * @language zh_CN
  18502. * 事件数据。
  18503. * @version DragonBones 4.5
  18504. */
  18505. class EventObject extends BaseObject {
  18506. /**
  18507. * @language zh_CN
  18508. * 动画开始。
  18509. * @version DragonBones 4.5
  18510. */
  18511. static START: string;
  18512. /**
  18513. * @language zh_CN
  18514. * 动画循环播放一次完成。
  18515. * @version DragonBones 4.5
  18516. */
  18517. static LOOP_COMPLETE: string;
  18518. /**
  18519. * @language zh_CN
  18520. * 动画播放完成。
  18521. * @version DragonBones 4.5
  18522. */
  18523. static COMPLETE: string;
  18524. /**
  18525. * @language zh_CN
  18526. * 动画淡入开始。
  18527. * @version DragonBones 4.5
  18528. */
  18529. static FADE_IN: string;
  18530. /**
  18531. * @language zh_CN
  18532. * 动画淡入完成。
  18533. * @version DragonBones 4.5
  18534. */
  18535. static FADE_IN_COMPLETE: string;
  18536. /**
  18537. * @language zh_CN
  18538. * 动画淡出开始。
  18539. * @version DragonBones 4.5
  18540. */
  18541. static FADE_OUT: string;
  18542. /**
  18543. * @language zh_CN
  18544. * 动画淡出完成。
  18545. * @version DragonBones 4.5
  18546. */
  18547. static FADE_OUT_COMPLETE: string;
  18548. /**
  18549. * @language zh_CN
  18550. * 动画帧事件。
  18551. * @version DragonBones 4.5
  18552. */
  18553. static FRAME_EVENT: string;
  18554. /**
  18555. * @language zh_CN
  18556. * 动画声音事件。
  18557. * @version DragonBones 4.5
  18558. */
  18559. static SOUND_EVENT: string;
  18560. /**
  18561. * @private
  18562. */
  18563. static toString(): string;
  18564. /**
  18565. * @language zh_CN
  18566. * 事件类型。
  18567. * @version DragonBones 4.5
  18568. */
  18569. type: EventStringType;
  18570. /**
  18571. * @language zh_CN
  18572. * 事件名称。 (帧标签的名称或声音的名称)
  18573. * @version DragonBones 4.5
  18574. */
  18575. name: string;
  18576. /**
  18577. * @language zh_CN
  18578. * 扩展的数据。
  18579. * @version DragonBones 4.5
  18580. */
  18581. data: any;
  18582. /**
  18583. * @language zh_CN
  18584. * 发出事件的骨架。
  18585. * @version DragonBones 4.5
  18586. */
  18587. armature: Armature;
  18588. /**
  18589. * @language zh_CN
  18590. * 发出事件的骨骼。
  18591. * @version DragonBones 4.5
  18592. */
  18593. bone: Bone;
  18594. /**
  18595. * @language zh_CN
  18596. * 发出事件的插槽。
  18597. * @version DragonBones 4.5
  18598. */
  18599. slot: Slot;
  18600. /**
  18601. * @language zh_CN
  18602. * 发出事件的动画状态。
  18603. * @version DragonBones 4.5
  18604. */
  18605. animationState: AnimationState;
  18606. /**
  18607. * @private
  18608. */
  18609. frame: AnimationFrameData;
  18610. /**
  18611. * @language zh_CN
  18612. * 用户数据。
  18613. * @version DragonBones 4.5
  18614. */
  18615. userData: any;
  18616. /**
  18617. * @inheritDoc
  18618. */
  18619. protected _onClear(): void;
  18620. }
  18621. }
  18622. declare namespace dragonBones {
  18623. /**
  18624. * @private
  18625. */
  18626. class ColorTransform {
  18627. alphaMultiplier: number;
  18628. redMultiplier: number;
  18629. greenMultiplier: number;
  18630. blueMultiplier: number;
  18631. alphaOffset: number;
  18632. redOffset: number;
  18633. greenOffset: number;
  18634. blueOffset: number;
  18635. constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
  18636. copyFrom(value: ColorTransform): void;
  18637. identity(): void;
  18638. }
  18639. }
  18640. declare namespace dragonBones {
  18641. /**
  18642. * @language zh_CN
  18643. * 2D 矩阵。
  18644. * @version DragonBones 3.0
  18645. */
  18646. class Matrix {
  18647. a: number;
  18648. b: number;
  18649. c: number;
  18650. d: number;
  18651. tx: number;
  18652. ty: number;
  18653. constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
  18654. /**
  18655. * @private
  18656. */
  18657. toString(): string;
  18658. /**
  18659. * @language zh_CN
  18660. * 复制矩阵。
  18661. * @param value 需要复制的矩阵。
  18662. * @version DragonBones 3.0
  18663. */
  18664. copyFrom(value: Matrix): void;
  18665. /**
  18666. * @language zh_CN
  18667. * 转换为恒等矩阵。
  18668. * @version DragonBones 3.0
  18669. */
  18670. identity(): void;
  18671. /**
  18672. * @language zh_CN
  18673. * 将当前矩阵与另一个矩阵相乘。
  18674. * @param value 需要相乘的矩阵。
  18675. * @version DragonBones 3.0
  18676. */
  18677. concat(value: Matrix): void;
  18678. /**
  18679. * @language zh_CN
  18680. * 转换为逆矩阵。
  18681. * @version DragonBones 3.0
  18682. */
  18683. invert(): void;
  18684. /**
  18685. * @language zh_CN
  18686. * 将矩阵转换应用于指定点。
  18687. * @param x 横坐标。
  18688. * @param y 纵坐标。
  18689. * @param result 应用转换之后的坐标。
  18690. * @params delta 是否忽略 tx,ty 对坐标的转换。
  18691. * @version DragonBones 3.0
  18692. */
  18693. transformPoint(x: number, y: number, result: {
  18694. x: number;
  18695. y: number;
  18696. }, delta?: boolean): void;
  18697. }
  18698. }
  18699. declare namespace dragonBones {
  18700. /**
  18701. * @private
  18702. */
  18703. class Point {
  18704. x: number;
  18705. y: number;
  18706. constructor(x?: number, y?: number);
  18707. copyFrom(value: Point): void;
  18708. clear(): void;
  18709. }
  18710. }
  18711. declare namespace dragonBones {
  18712. /**
  18713. * @private
  18714. */
  18715. class Rectangle {
  18716. x: number;
  18717. y: number;
  18718. width: number;
  18719. height: number;
  18720. constructor(x?: number, y?: number, width?: number, height?: number);
  18721. copyFrom(value: Rectangle): void;
  18722. clear(): void;
  18723. }
  18724. }
  18725. declare namespace dragonBones {
  18726. /**
  18727. * @language zh_CN
  18728. * 2D 变换。
  18729. * @version DragonBones 3.0
  18730. */
  18731. class Transform {
  18732. /**
  18733. * @language zh_CN
  18734. * 水平位移。
  18735. * @version DragonBones 3.0
  18736. */
  18737. x: number;
  18738. /**
  18739. * @language zh_CN
  18740. * 垂直位移。
  18741. * @version DragonBones 3.0
  18742. */
  18743. y: number;
  18744. /**
  18745. * @language zh_CN
  18746. * 水平倾斜。 (以弧度为单位)
  18747. * @version DragonBones 3.0
  18748. */
  18749. skewX: number;
  18750. /**
  18751. * @language zh_CN
  18752. * 垂直倾斜。 (以弧度为单位)
  18753. * @version DragonBones 3.0
  18754. */
  18755. skewY: number;
  18756. /**
  18757. * @language zh_CN
  18758. * 水平缩放。
  18759. * @version DragonBones 3.0
  18760. */
  18761. scaleX: number;
  18762. /**
  18763. * @language zh_CN
  18764. * 垂直缩放。
  18765. * @version DragonBones 3.0
  18766. */
  18767. scaleY: number;
  18768. /**
  18769. * @private
  18770. */
  18771. static normalizeRadian(value: number): number;
  18772. /**
  18773. * @private
  18774. */
  18775. constructor(
  18776. /**
  18777. * @language zh_CN
  18778. * 水平位移。
  18779. * @version DragonBones 3.0
  18780. */
  18781. x?: number,
  18782. /**
  18783. * @language zh_CN
  18784. * 垂直位移。
  18785. * @version DragonBones 3.0
  18786. */
  18787. y?: number,
  18788. /**
  18789. * @language zh_CN
  18790. * 水平倾斜。 (以弧度为单位)
  18791. * @version DragonBones 3.0
  18792. */
  18793. skewX?: number,
  18794. /**
  18795. * @language zh_CN
  18796. * 垂直倾斜。 (以弧度为单位)
  18797. * @version DragonBones 3.0
  18798. */
  18799. skewY?: number,
  18800. /**
  18801. * @language zh_CN
  18802. * 水平缩放。
  18803. * @version DragonBones 3.0
  18804. */
  18805. scaleX?: number,
  18806. /**
  18807. * @language zh_CN
  18808. * 垂直缩放。
  18809. * @version DragonBones 3.0
  18810. */
  18811. scaleY?: number);
  18812. /**
  18813. * @private
  18814. */
  18815. toString(): string;
  18816. /**
  18817. * @private
  18818. */
  18819. copyFrom(value: Transform): Transform;
  18820. /**
  18821. * @private
  18822. */
  18823. identity(): Transform;
  18824. /**
  18825. * @private
  18826. */
  18827. add(value: Transform): Transform;
  18828. /**
  18829. * @private
  18830. */
  18831. minus(value: Transform): Transform;
  18832. /**
  18833. * @private
  18834. */
  18835. fromMatrix(matrix: Matrix): Transform;
  18836. /**
  18837. * @language zh_CN
  18838. * 转换为矩阵。
  18839. * @param 矩阵。
  18840. * @version DragonBones 3.0
  18841. */
  18842. toMatrix(matrix: Matrix): Transform;
  18843. /**
  18844. * @language zh_CN
  18845. * 旋转。 (以弧度为单位)
  18846. * @version DragonBones 3.0
  18847. */
  18848. rotation: number;
  18849. }
  18850. }
  18851. declare namespace dragonBones {
  18852. /**
  18853. * @private
  18854. */
  18855. abstract class TimelineData<T extends FrameData<T>> extends BaseObject {
  18856. /**
  18857. * @private
  18858. */
  18859. static toString(): string;
  18860. scale: number;
  18861. /**
  18862. * @private
  18863. */
  18864. offset: number;
  18865. /**
  18866. * @private
  18867. */
  18868. frames: Array<T>;
  18869. constructor();
  18870. /**
  18871. * @inheritDoc
  18872. */
  18873. protected _onClear(): void;
  18874. }
  18875. /**
  18876. * @private
  18877. */
  18878. class ZOrderTimelineData extends TimelineData<ZOrderFrameData> {
  18879. static toString(): string;
  18880. }
  18881. /**
  18882. * @private
  18883. */
  18884. class BoneTimelineData extends TimelineData<BoneFrameData> {
  18885. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18886. static toString(): string;
  18887. bone: BoneData;
  18888. originalTransform: Transform;
  18889. cachedFrames: Array<Matrix>;
  18890. constructor();
  18891. /**
  18892. * @inheritDoc
  18893. */
  18894. protected _onClear(): void;
  18895. cacheFrames(cacheFrameCount: number): void;
  18896. }
  18897. /**
  18898. * @private
  18899. */
  18900. class SlotTimelineData extends TimelineData<SlotFrameData> {
  18901. static cacheFrame(cacheFrames: Array<Matrix>, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix;
  18902. static toString(): string;
  18903. slot: SlotData;
  18904. cachedFrames: Array<Matrix>;
  18905. constructor();
  18906. /**
  18907. * @inheritDoc
  18908. */
  18909. protected _onClear(): void;
  18910. cacheFrames(cacheFrameCount: number): void;
  18911. }
  18912. /**
  18913. * @private
  18914. */
  18915. class FFDTimelineData extends TimelineData<ExtensionFrameData> {
  18916. static toString(): string;
  18917. displayIndex: number;
  18918. skin: SkinData;
  18919. slot: SlotDisplayDataSet;
  18920. constructor();
  18921. /**
  18922. * @inheritDoc
  18923. */
  18924. protected _onClear(): void;
  18925. }
  18926. }
  18927. declare namespace dragonBones {
  18928. /**
  18929. * @language zh_CN
  18930. * 动画数据。
  18931. * @version DragonBones 3.0
  18932. */
  18933. class AnimationData extends TimelineData<AnimationFrameData> {
  18934. /**
  18935. * @private
  18936. */
  18937. static toString(): string;
  18938. /**
  18939. * @private
  18940. */
  18941. hasAsynchronyTimeline: boolean;
  18942. /**
  18943. * @language zh_CN
  18944. * 持续的帧数。
  18945. * @version DragonBones 3.0
  18946. */
  18947. frameCount: number;
  18948. /**
  18949. * @language zh_CN
  18950. * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
  18951. * @version DragonBones 3.0
  18952. */
  18953. playTimes: number;
  18954. /**
  18955. * @language zh_CN
  18956. * 开始的时间。 (以秒为单位)
  18957. * @version DragonBones 3.0
  18958. */
  18959. position: number;
  18960. /**
  18961. * @language zh_CN
  18962. * 持续的时间。 (以秒为单位)
  18963. * @version DragonBones 3.0
  18964. */
  18965. duration: number;
  18966. /**
  18967. * @language zh_CN
  18968. * 淡入混合的时间。 (以秒为单位)
  18969. * @version DragonBones 3.0
  18970. */
  18971. fadeInTime: number;
  18972. /**
  18973. * @private
  18974. */
  18975. cacheTimeToFrameScale: number;
  18976. /**
  18977. * @language zh_CN
  18978. * 数据名称。
  18979. * @version DragonBones 3.0
  18980. */
  18981. name: string;
  18982. /**
  18983. * @private
  18984. */
  18985. animation: AnimationData;
  18986. /**
  18987. * @private
  18988. */
  18989. zOrderTimeline: TimelineData<ZOrderFrameData>;
  18990. /**
  18991. * @private
  18992. */
  18993. boneTimelines: Map<BoneTimelineData>;
  18994. /**
  18995. * @private
  18996. */
  18997. slotTimelines: Map<SlotTimelineData>;
  18998. /**
  18999. * @private
  19000. */
  19001. ffdTimelines: Map<Map<Map<FFDTimelineData>>>;
  19002. /**
  19003. * @private
  19004. */
  19005. cachedFrames: Array<boolean>;
  19006. /**
  19007. * @private
  19008. */
  19009. constructor();
  19010. /**
  19011. * @inheritDoc
  19012. */
  19013. protected _onClear(): void;
  19014. /**
  19015. * @private
  19016. */
  19017. cacheFrames(value: number): void;
  19018. /**
  19019. * @private
  19020. */
  19021. addBoneTimeline(value: BoneTimelineData): void;
  19022. /**
  19023. * @private
  19024. */
  19025. addSlotTimeline(value: SlotTimelineData): void;
  19026. /**
  19027. * @private
  19028. */
  19029. addFFDTimeline(value: FFDTimelineData): void;
  19030. /**
  19031. * @private
  19032. */
  19033. getBoneTimeline(name: string): BoneTimelineData;
  19034. /**
  19035. * @private
  19036. */
  19037. getSlotTimeline(name: string): SlotTimelineData;
  19038. /**
  19039. * @private
  19040. */
  19041. getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData;
  19042. }
  19043. }
  19044. declare namespace dragonBones {
  19045. /**
  19046. * @language zh_CN
  19047. * 骨架数据。
  19048. * @see dragonBones.Armature
  19049. * @version DragonBones 3.0
  19050. */
  19051. class ArmatureData extends BaseObject {
  19052. private static _onSortSlots(a, b);
  19053. /**
  19054. * @private
  19055. */
  19056. static toString(): string;
  19057. /**
  19058. * @language zh_CN
  19059. * 动画帧率。
  19060. * @version DragonBones 3.0
  19061. */
  19062. frameRate: number;
  19063. /**
  19064. * @language zh_CN
  19065. * 骨架类型。
  19066. * @see dragonBones.ArmatureType
  19067. * @version DragonBones 3.0
  19068. */
  19069. type: ArmatureType;
  19070. /**
  19071. * @language zh_CN
  19072. * 数据名称。
  19073. * @version DragonBones 3.0
  19074. */
  19075. name: string;
  19076. /**
  19077. * @private
  19078. */
  19079. parent: DragonBonesData;
  19080. /**
  19081. * @private
  19082. */
  19083. userData: any;
  19084. /**
  19085. * @private
  19086. */
  19087. aabb: Rectangle;
  19088. /**
  19089. * @language zh_CN
  19090. * 所有的骨骼数据。
  19091. * @see dragonBones.BoneData
  19092. * @version DragonBones 3.0
  19093. */
  19094. bones: Map<BoneData>;
  19095. /**
  19096. * @language zh_CN
  19097. * 所有的插槽数据。
  19098. * @see dragonBones.SlotData
  19099. * @version DragonBones 3.0
  19100. */
  19101. slots: Map<SlotData>;
  19102. /**
  19103. * @language zh_CN
  19104. * 所有的皮肤数据。
  19105. * @see dragonBones.SkinData
  19106. * @version DragonBones 3.0
  19107. */
  19108. skins: Map<SkinData>;
  19109. /**
  19110. * @language zh_CN
  19111. * 所有的动画数据。
  19112. * @see dragonBones.AnimationData
  19113. * @version DragonBones 3.0
  19114. */
  19115. animations: Map<AnimationData>;
  19116. /**
  19117. * @private
  19118. */
  19119. actions: Array<ActionData>;
  19120. /**
  19121. * @private
  19122. */
  19123. cacheFrameRate: number;
  19124. /**
  19125. * @private
  19126. */
  19127. scale: number;
  19128. private _boneDirty;
  19129. private _slotDirty;
  19130. private _defaultSkin;
  19131. private _defaultAnimation;
  19132. private _sortedBones;
  19133. private _sortedSlots;
  19134. private _bonesChildren;
  19135. /**
  19136. * @private
  19137. */
  19138. constructor();
  19139. /**
  19140. * @inheritDoc
  19141. */
  19142. protected _onClear(): void;
  19143. private _sortBones();
  19144. private _sortSlots();
  19145. /**
  19146. * @private
  19147. */
  19148. cacheFrames(value: number): void;
  19149. /**
  19150. * @private
  19151. */
  19152. addBone(value: BoneData, parentName: string): void;
  19153. /**
  19154. * @private
  19155. */
  19156. addSlot(value: SlotData): void;
  19157. /**
  19158. * @private
  19159. */
  19160. addSkin(value: SkinData): void;
  19161. /**
  19162. * @private
  19163. */
  19164. addAnimation(value: AnimationData): void;
  19165. /**
  19166. * @language zh_CN
  19167. * 获取指定名称的骨骼数据。
  19168. * @param name 骨骼数据名称。
  19169. * @see dragonBones.BoneData
  19170. * @version DragonBones 3.0
  19171. */
  19172. getBone(name: string): BoneData;
  19173. /**
  19174. * @language zh_CN
  19175. * 获取指定名称的插槽数据。
  19176. * @param name 插槽数据名称。
  19177. * @see dragonBones.SlotData
  19178. * @version DragonBones 3.0
  19179. */
  19180. getSlot(name: string): SlotData;
  19181. /**
  19182. * @language zh_CN
  19183. * 获取指定名称的皮肤数据。
  19184. * @param name 皮肤数据名称。
  19185. * @see dragonBones.SkinData
  19186. * @version DragonBones 3.0
  19187. */
  19188. getSkin(name: string): SkinData;
  19189. /**
  19190. * @language zh_CN
  19191. * 获取指定名称的动画数据。
  19192. * @param name 动画数据名称。
  19193. * @see dragonBones.AnimationData
  19194. * @version DragonBones 3.0
  19195. */
  19196. getAnimation(name: string): AnimationData;
  19197. /**
  19198. * @private
  19199. */
  19200. sortedBones: Array<BoneData>;
  19201. /**
  19202. * @private
  19203. */
  19204. sortedSlots: Array<SlotData>;
  19205. /**
  19206. * @language zh_CN
  19207. * 获取默认的皮肤数据。
  19208. * @see dragonBones.SkinData
  19209. * @version DragonBones 4.5
  19210. */
  19211. defaultSkin: SkinData;
  19212. /**
  19213. * @language zh_CN
  19214. * 获取默认的动画数据。
  19215. * @see dragonBones.AnimationData
  19216. * @version DragonBones 4.5
  19217. */
  19218. defaultAnimation: AnimationData;
  19219. }
  19220. /**
  19221. * @language zh_CN
  19222. * 骨骼数据。
  19223. * @see dragonBones.Bone
  19224. * @version DragonBones 3.0
  19225. */
  19226. class BoneData extends BaseObject {
  19227. /**
  19228. * @private
  19229. */
  19230. static toString(): string;
  19231. /**
  19232. * @private
  19233. */
  19234. inheritTranslation: boolean;
  19235. /**
  19236. * @private
  19237. */
  19238. inheritRotation: boolean;
  19239. /**
  19240. * @private
  19241. */
  19242. inheritScale: boolean;
  19243. /**
  19244. * @private
  19245. */
  19246. bendPositive: boolean;
  19247. /**
  19248. * @private
  19249. */
  19250. chain: number;
  19251. /**
  19252. * @private
  19253. */
  19254. chainIndex: number;
  19255. /**
  19256. * @private
  19257. */
  19258. weight: number;
  19259. /**
  19260. * @private
  19261. */
  19262. length: number;
  19263. /**
  19264. * @language zh_CN
  19265. * 数据名称。
  19266. * @version DragonBones 3.0
  19267. */
  19268. name: string;
  19269. /**
  19270. * @language zh_CN
  19271. * 所属的父骨骼数据。
  19272. * @version DragonBones 3.0
  19273. */
  19274. parent: BoneData;
  19275. /**
  19276. * @private
  19277. */
  19278. ik: BoneData;
  19279. /**
  19280. * @private
  19281. */
  19282. transform: Transform;
  19283. /**
  19284. * @private
  19285. */
  19286. constructor();
  19287. /**
  19288. * @inheritDoc
  19289. */
  19290. protected _onClear(): void;
  19291. }
  19292. /**
  19293. * @language zh_CN
  19294. * 插槽数据。
  19295. * @see dragonBones.Slot
  19296. * @version DragonBones 3.0
  19297. */
  19298. class SlotData extends BaseObject {
  19299. /**
  19300. * @private
  19301. */
  19302. static DEFAULT_COLOR: ColorTransform;
  19303. /**
  19304. * @private
  19305. */
  19306. static generateColor(): ColorTransform;
  19307. /**
  19308. * @private
  19309. */
  19310. static toString(): string;
  19311. /**
  19312. * @private
  19313. */
  19314. displayIndex: number;
  19315. /**
  19316. * @private
  19317. */
  19318. zOrder: number;
  19319. /**
  19320. * @private
  19321. */
  19322. blendMode: BlendMode;
  19323. /**
  19324. * @language zh_CN
  19325. * 数据名称。
  19326. * @version DragonBones 3.0
  19327. */
  19328. name: string;
  19329. /**
  19330. * @language zh_CN
  19331. * 所属的父骨骼数据。
  19332. * @see dragonBones.BoneData
  19333. * @version DragonBones 3.0
  19334. */
  19335. parent: BoneData;
  19336. /**
  19337. * @private
  19338. */
  19339. color: ColorTransform;
  19340. /**
  19341. * @private
  19342. */
  19343. actions: Array<ActionData>;
  19344. /**
  19345. * @private
  19346. */
  19347. constructor();
  19348. /**
  19349. * @inheritDoc
  19350. */
  19351. protected _onClear(): void;
  19352. }
  19353. /**
  19354. * @language zh_CN
  19355. * 皮肤数据。
  19356. * @version DragonBones 3.0
  19357. */
  19358. class SkinData extends BaseObject {
  19359. /**
  19360. * @private
  19361. */
  19362. static toString(): string;
  19363. /**
  19364. * @language zh_CN
  19365. * 数据名称。
  19366. * @version DragonBones 3.0
  19367. */
  19368. name: string;
  19369. /**
  19370. * @private
  19371. */
  19372. slots: Map<SlotDisplayDataSet>;
  19373. /**
  19374. * @private
  19375. */
  19376. constructor();
  19377. /**
  19378. * @inheritDoc
  19379. */
  19380. protected _onClear(): void;
  19381. /**
  19382. * @private
  19383. */
  19384. addSlot(value: SlotDisplayDataSet): void;
  19385. /**
  19386. * @private
  19387. */
  19388. getSlot(name: string): SlotDisplayDataSet;
  19389. }
  19390. /**
  19391. * @private
  19392. */
  19393. class SlotDisplayDataSet extends BaseObject {
  19394. static toString(): string;
  19395. slot: SlotData;
  19396. displays: Array<DisplayData>;
  19397. constructor();
  19398. /**
  19399. * @inheritDoc
  19400. */
  19401. protected _onClear(): void;
  19402. }
  19403. /**
  19404. * @private
  19405. */
  19406. class DisplayData extends BaseObject {
  19407. static toString(): string;
  19408. isRelativePivot: boolean;
  19409. type: DisplayType;
  19410. name: string;
  19411. texture: TextureData;
  19412. armature: ArmatureData;
  19413. mesh: MeshData;
  19414. pivot: Point;
  19415. transform: Transform;
  19416. constructor();
  19417. /**
  19418. * @inheritDoc
  19419. */
  19420. protected _onClear(): void;
  19421. }
  19422. /**
  19423. * @private
  19424. */
  19425. class MeshData extends BaseObject {
  19426. static toString(): string;
  19427. skinned: boolean;
  19428. slotPose: Matrix;
  19429. uvs: Array<number>;
  19430. vertices: Array<number>;
  19431. vertexIndices: Array<number>;
  19432. boneIndices: Array<Array<number>>;
  19433. weights: Array<Array<number>>;
  19434. boneVertices: Array<Array<number>>;
  19435. bones: Array<BoneData>;
  19436. inverseBindPose: Array<Matrix>;
  19437. constructor();
  19438. /**
  19439. * @inheritDoc
  19440. */
  19441. protected _onClear(): void;
  19442. }
  19443. }
  19444. declare namespace dragonBones {
  19445. /**
  19446. * @language zh_CN
  19447. * 龙骨数据,包含多个骨架数据。
  19448. * @see dragonBones.ArmatureData
  19449. * @version DragonBones 3.0
  19450. */
  19451. class DragonBonesData extends BaseObject {
  19452. /**
  19453. * @private
  19454. */
  19455. static toString(): string;
  19456. /**
  19457. * @language zh_CN
  19458. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19459. * @default false
  19460. * @see dragonBones.ArmatureData
  19461. * @version DragonBones 4.5
  19462. */
  19463. autoSearch: boolean;
  19464. /**
  19465. * @language zh_CN
  19466. * 动画帧频。
  19467. * @version DragonBones 3.0
  19468. */
  19469. frameRate: number;
  19470. /**
  19471. * @language zh_CN
  19472. * 数据名称。
  19473. * @version DragonBones 3.0
  19474. */
  19475. name: string;
  19476. /**
  19477. * @language zh_CN
  19478. * 所有的骨架数据。
  19479. * @see dragonBones.ArmatureData
  19480. * @version DragonBones 3.0
  19481. */
  19482. armatures: Map<ArmatureData>;
  19483. private _armatureNames;
  19484. /**
  19485. * @inheritDoc
  19486. */
  19487. protected _onClear(): void;
  19488. /**
  19489. * @language zh_CN
  19490. * 获取指定名称的骨架。
  19491. * @param name 骨架数据骨架名称。
  19492. * @see dragonBones.ArmatureData
  19493. * @version DragonBones 3.0
  19494. */
  19495. getArmature(name: string): ArmatureData;
  19496. /**
  19497. * @language zh_CN
  19498. * 所有的骨架数据名称。
  19499. * @see #armatures
  19500. * @version DragonBones 3.0
  19501. */
  19502. armatureNames: Array<string>;
  19503. /**
  19504. * @deprecated
  19505. * @see dragonBones.BaseFactory#removeDragonBonesData()
  19506. */
  19507. dispose(): void;
  19508. }
  19509. }
  19510. declare namespace dragonBones {
  19511. /**
  19512. * @private
  19513. */
  19514. class ActionData extends BaseObject {
  19515. static toString(): string;
  19516. type: ActionType;
  19517. bone: BoneData;
  19518. slot: SlotData;
  19519. data: Array<any>;
  19520. constructor();
  19521. protected _onClear(): void;
  19522. }
  19523. /**
  19524. * @private
  19525. */
  19526. class EventData extends BaseObject {
  19527. static toString(): string;
  19528. type: EventType;
  19529. name: string;
  19530. data: any;
  19531. bone: BoneData;
  19532. slot: SlotData;
  19533. constructor();
  19534. protected _onClear(): void;
  19535. }
  19536. /**
  19537. * @private
  19538. */
  19539. abstract class FrameData<T> extends BaseObject {
  19540. position: number;
  19541. duration: number;
  19542. prev: T;
  19543. next: T;
  19544. constructor();
  19545. /**
  19546. * @inheritDoc
  19547. */
  19548. protected _onClear(): void;
  19549. }
  19550. /**
  19551. * @private
  19552. */
  19553. abstract class TweenFrameData<T> extends FrameData<T> {
  19554. static samplingCurve(curve: Array<number>, frameCount: number): Array<number>;
  19555. tweenEasing: number;
  19556. curve: Array<number>;
  19557. constructor();
  19558. /**
  19559. * @inheritDoc
  19560. */
  19561. protected _onClear(): void;
  19562. }
  19563. /**
  19564. * @private
  19565. */
  19566. class AnimationFrameData extends FrameData<AnimationFrameData> {
  19567. static toString(): string;
  19568. actions: Array<ActionData>;
  19569. events: Array<EventData>;
  19570. constructor();
  19571. /**
  19572. * @inheritDoc
  19573. */
  19574. protected _onClear(): void;
  19575. }
  19576. /**
  19577. * @private
  19578. */
  19579. class ZOrderFrameData extends FrameData<ZOrderFrameData> {
  19580. zOrder: Array<number>;
  19581. constructor();
  19582. /**
  19583. * @inheritDoc
  19584. */
  19585. protected _onClear(): void;
  19586. }
  19587. /**
  19588. * @private
  19589. */
  19590. class BoneFrameData extends TweenFrameData<BoneFrameData> {
  19591. static toString(): string;
  19592. tweenScale: boolean;
  19593. tweenRotate: number;
  19594. guideCurve: Array<number>;
  19595. transform: Transform;
  19596. constructor();
  19597. /**
  19598. * @inheritDoc
  19599. */
  19600. protected _onClear(): void;
  19601. }
  19602. /**
  19603. * @private
  19604. */
  19605. class SlotFrameData extends TweenFrameData<SlotFrameData> {
  19606. static DEFAULT_COLOR: ColorTransform;
  19607. static generateColor(): ColorTransform;
  19608. static toString(): string;
  19609. displayIndex: number;
  19610. color: ColorTransform;
  19611. constructor();
  19612. /**
  19613. * @inheritDoc
  19614. */
  19615. protected _onClear(): void;
  19616. }
  19617. /**
  19618. * @private
  19619. */
  19620. class ExtensionFrameData extends TweenFrameData<ExtensionFrameData> {
  19621. static toString(): string;
  19622. type: ExtensionType;
  19623. tweens: Array<number>;
  19624. keys: Array<number>;
  19625. constructor();
  19626. /**
  19627. * @inheritDoc
  19628. */
  19629. protected _onClear(): void;
  19630. }
  19631. }
  19632. declare namespace dragonBones {
  19633. /**
  19634. * @private
  19635. */
  19636. abstract class DataParser {
  19637. protected static DATA_VERSION_2_3: string;
  19638. protected static DATA_VERSION_3_0: string;
  19639. protected static DATA_VERSION_4_0: string;
  19640. protected static DATA_VERSION: string;
  19641. protected static TEXTURE_ATLAS: string;
  19642. protected static SUB_TEXTURE: string;
  19643. protected static FORMAT: string;
  19644. protected static IMAGE_PATH: string;
  19645. protected static WIDTH: string;
  19646. protected static HEIGHT: string;
  19647. protected static ROTATED: string;
  19648. protected static FRAME_X: string;
  19649. protected static FRAME_Y: string;
  19650. protected static FRAME_WIDTH: string;
  19651. protected static FRAME_HEIGHT: string;
  19652. protected static DRADON_BONES: string;
  19653. protected static ARMATURE: string;
  19654. protected static BONE: string;
  19655. protected static IK: string;
  19656. protected static SLOT: string;
  19657. protected static SKIN: string;
  19658. protected static DISPLAY: string;
  19659. protected static ANIMATION: string;
  19660. protected static Z_ORDER: string;
  19661. protected static FFD: string;
  19662. protected static FRAME: string;
  19663. protected static PIVOT: string;
  19664. protected static TRANSFORM: string;
  19665. protected static AABB: string;
  19666. protected static COLOR: string;
  19667. protected static FILTER: string;
  19668. protected static VERSION: string;
  19669. protected static IS_GLOBAL: string;
  19670. protected static FRAME_RATE: string;
  19671. protected static TYPE: string;
  19672. protected static NAME: string;
  19673. protected static PARENT: string;
  19674. protected static LENGTH: string;
  19675. protected static DATA: string;
  19676. protected static DISPLAY_INDEX: string;
  19677. protected static BLEND_MODE: string;
  19678. protected static INHERIT_TRANSLATION: string;
  19679. protected static INHERIT_ROTATION: string;
  19680. protected static INHERIT_SCALE: string;
  19681. protected static TARGET: string;
  19682. protected static BEND_POSITIVE: string;
  19683. protected static CHAIN: string;
  19684. protected static WEIGHT: string;
  19685. protected static FADE_IN_TIME: string;
  19686. protected static PLAY_TIMES: string;
  19687. protected static SCALE: string;
  19688. protected static OFFSET: string;
  19689. protected static POSITION: string;
  19690. protected static DURATION: string;
  19691. protected static TWEEN_EASING: string;
  19692. protected static TWEEN_ROTATE: string;
  19693. protected static TWEEN_SCALE: string;
  19694. protected static CURVE: string;
  19695. protected static GUIDE_CURVE: string;
  19696. protected static EVENT: string;
  19697. protected static SOUND: string;
  19698. protected static ACTION: string;
  19699. protected static ACTIONS: string;
  19700. protected static DEFAULT_ACTIONS: string;
  19701. protected static X: string;
  19702. protected static Y: string;
  19703. protected static SKEW_X: string;
  19704. protected static SKEW_Y: string;
  19705. protected static SCALE_X: string;
  19706. protected static SCALE_Y: string;
  19707. protected static ALPHA_OFFSET: string;
  19708. protected static RED_OFFSET: string;
  19709. protected static GREEN_OFFSET: string;
  19710. protected static BLUE_OFFSET: string;
  19711. protected static ALPHA_MULTIPLIER: string;
  19712. protected static RED_MULTIPLIER: string;
  19713. protected static GREEN_MULTIPLIER: string;
  19714. protected static BLUE_MULTIPLIER: string;
  19715. protected static UVS: string;
  19716. protected static VERTICES: string;
  19717. protected static TRIANGLES: string;
  19718. protected static WEIGHTS: string;
  19719. protected static SLOT_POSE: string;
  19720. protected static BONE_POSE: string;
  19721. protected static TWEEN: string;
  19722. protected static KEY: string;
  19723. protected static COLOR_TRANSFORM: string;
  19724. protected static TIMELINE: string;
  19725. protected static PIVOT_X: string;
  19726. protected static PIVOT_Y: string;
  19727. protected static Z: string;
  19728. protected static LOOP: string;
  19729. protected static AUTO_TWEEN: string;
  19730. protected static HIDE: string;
  19731. protected static _getArmatureType(value: string): ArmatureType;
  19732. protected static _getDisplayType(value: string): DisplayType;
  19733. protected static _getBlendMode(value: string): BlendMode;
  19734. protected static _getActionType(value: string): ActionType;
  19735. protected _data: DragonBonesData;
  19736. protected _armature: ArmatureData;
  19737. protected _skin: SkinData;
  19738. protected _slotDisplayDataSet: SlotDisplayDataSet;
  19739. protected _mesh: MeshData;
  19740. protected _animation: AnimationData;
  19741. protected _timeline: any;
  19742. protected _isOldData: boolean;
  19743. protected _isGlobalTransform: boolean;
  19744. protected _isAutoTween: boolean;
  19745. protected _animationTweenEasing: number;
  19746. protected _timelinePivot: Point;
  19747. protected _helpPoint: Point;
  19748. protected _helpTransformA: Transform;
  19749. protected _helpTransformB: Transform;
  19750. protected _helpMatrix: Matrix;
  19751. protected _rawBones: Array<BoneData>;
  19752. constructor();
  19753. /**
  19754. * @private
  19755. */
  19756. abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData;
  19757. /**
  19758. * @private
  19759. */
  19760. abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void;
  19761. private _getTimelineFrameMatrix(animation, timeline, position, transform);
  19762. protected _globalToLocal(armature: ArmatureData): void;
  19763. protected _mergeFrameToAnimationTimeline(framePostion: number, actions: Array<ActionData>, events: Array<EventData>): void;
  19764. /**
  19765. * @deprecated
  19766. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19767. */
  19768. static parseDragonBonesData(rawData: any): DragonBonesData;
  19769. /**
  19770. * @deprecated
  19771. * @see dragonBones.BaseFactory#parsetTextureAtlasData()
  19772. */
  19773. static parseTextureAtlasData(rawData: any, scale?: number): any;
  19774. }
  19775. }
  19776. declare namespace dragonBones {
  19777. /**
  19778. * @private
  19779. */
  19780. class ObjectDataParser extends DataParser {
  19781. /**
  19782. * @private
  19783. */
  19784. protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
  19785. /**
  19786. * @private
  19787. */
  19788. protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
  19789. /**
  19790. * @private
  19791. */
  19792. protected static _getString(rawData: any, key: string, defaultValue: string): string;
  19793. /**
  19794. * @private
  19795. */
  19796. protected static _getParameter(rawData: Array<any>, index: number, defaultValue: any): any;
  19797. /**
  19798. * @private
  19799. */
  19800. constructor();
  19801. /**
  19802. * @private
  19803. */
  19804. protected _parseArmature(rawData: any, scale: number): ArmatureData;
  19805. /**
  19806. * @private
  19807. */
  19808. protected _parseBone(rawData: any): BoneData;
  19809. /**
  19810. * @private
  19811. */
  19812. protected _parseIK(rawData: any): void;
  19813. /**
  19814. * @private
  19815. */
  19816. protected _parseSlot(rawData: any, zOrder: number): SlotData;
  19817. /**
  19818. * @private
  19819. */
  19820. protected _parseSkin(rawData: any): SkinData;
  19821. /**
  19822. * @private
  19823. */
  19824. protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet;
  19825. /**
  19826. * @private
  19827. */
  19828. protected _parseDisplay(rawData: any): DisplayData;
  19829. /**
  19830. * @private
  19831. */
  19832. protected _parseMesh(rawData: any): MeshData;
  19833. /**
  19834. * @private
  19835. */
  19836. protected _parseAnimation(rawData: any): AnimationData;
  19837. /**
  19838. * @private
  19839. */
  19840. protected _parseBoneTimeline(rawData: any): BoneTimelineData;
  19841. /**
  19842. * @private
  19843. */
  19844. protected _parseSlotTimeline(rawData: any): SlotTimelineData;
  19845. /**
  19846. * @private
  19847. */
  19848. protected _parseFFDTimeline(rawData: any): FFDTimelineData;
  19849. /**
  19850. * @private
  19851. */
  19852. protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData;
  19853. /**
  19854. * @private
  19855. */
  19856. protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): ZOrderFrameData;
  19857. /**
  19858. * @private
  19859. */
  19860. protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData;
  19861. /**
  19862. * @private
  19863. */
  19864. protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData;
  19865. /**
  19866. * @private
  19867. */
  19868. protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData;
  19869. /**
  19870. * @private
  19871. */
  19872. protected _parseTweenFrame<T extends TweenFrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19873. /**
  19874. * @private
  19875. */
  19876. protected _parseFrame<T extends FrameData<T>>(rawData: any, frame: T, frameStart: number, frameCount: number): void;
  19877. /**
  19878. * @private
  19879. */
  19880. protected _parseTimeline<T extends FrameData<T>>(rawData: Object, timeline: TimelineData<T>, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void;
  19881. /**
  19882. * @private
  19883. */
  19884. protected _parseActionData(rawData: any, actions: Array<ActionData>, bone: BoneData, slot: SlotData): void;
  19885. /**
  19886. * @private
  19887. */
  19888. protected _parseEventData(rawData: any, events: Array<EventData>, bone: BoneData, slot: SlotData): void;
  19889. /**
  19890. * @private
  19891. */
  19892. protected _parseTransform(rawData: Object, transform: Transform): void;
  19893. /**
  19894. * @private
  19895. */
  19896. protected _parseColorTransform(rawData: Object, color: ColorTransform): void;
  19897. /**
  19898. * @inheritDoc
  19899. */
  19900. parseDragonBonesData(rawData: any, scale?: number): DragonBonesData;
  19901. /**
  19902. * @inheritDoc
  19903. */
  19904. parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): void;
  19905. /**
  19906. * @private
  19907. */
  19908. private static _instance;
  19909. /**
  19910. * @deprecated
  19911. * @see dragonBones.BaseFactory#parseDragonBonesData()
  19912. */
  19913. static getInstance(): ObjectDataParser;
  19914. }
  19915. }
  19916. declare namespace dragonBones {
  19917. /**
  19918. * @language zh_CN
  19919. * 贴图集数据。
  19920. * @version DragonBones 3.0
  19921. */
  19922. abstract class TextureAtlasData extends BaseObject {
  19923. /**
  19924. * @language zh_CN
  19925. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19926. * @default false
  19927. * @version DragonBones 4.5
  19928. */
  19929. autoSearch: boolean;
  19930. /**
  19931. * @language zh_CN
  19932. * 贴图集缩放系数。
  19933. * @version DragonBones 3.0
  19934. */
  19935. scale: number;
  19936. /**
  19937. * @language zh_CN
  19938. * 贴图集名称。
  19939. * @version DragonBones 3.0
  19940. */
  19941. name: string;
  19942. /**
  19943. * @language zh_CN
  19944. * 贴图集图片路径。
  19945. * @version DragonBones 3.0
  19946. */
  19947. imagePath: string;
  19948. /**
  19949. * @inheritDoc
  19950. */
  19951. protected _onClear(): void;
  19952. /**
  19953. * @private
  19954. */
  19955. getTexture(name: string): TextureData;
  19956. }
  19957. /**
  19958. * @private
  19959. */
  19960. abstract class TextureData extends BaseObject {
  19961. static generateRectangle(): Rectangle;
  19962. rotated: boolean;
  19963. name: string;
  19964. frame: Rectangle;
  19965. parent: TextureAtlasData;
  19966. region: Rectangle;
  19967. constructor();
  19968. /**
  19969. * @inheritDoc
  19970. */
  19971. protected _onClear(): void;
  19972. }
  19973. }
  19974. declare namespace dragonBones {
  19975. /**
  19976. * @private
  19977. */
  19978. type BuildArmaturePackage = {
  19979. dataName?: string;
  19980. textureAtlasName?: string;
  19981. data?: DragonBonesData;
  19982. armature?: ArmatureData;
  19983. skin?: SkinData;
  19984. };
  19985. /**
  19986. * @language zh_CN
  19987. * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例)
  19988. * @see dragonBones.DragonBonesData
  19989. * @see dragonBones.TextureAtlasData
  19990. * @see dragonBones.ArmatureData
  19991. * @see dragonBones.Armature
  19992. * @version DragonBones 3.0
  19993. */
  19994. abstract class BaseFactory {
  19995. protected static _defaultParser: ObjectDataParser;
  19996. /**
  19997. * @language zh_CN
  19998. * 是否开启共享搜索。 [true: 开启, false: 不开启]
  19999. * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启)
  20000. * @see dragonBones.DragonBonesData#autoSearch
  20001. * @see dragonBones.TextureAtlasData#autoSearch
  20002. * @version DragonBones 4.5
  20003. */
  20004. autoSearch: boolean;
  20005. /**
  20006. * @private
  20007. */
  20008. protected _dataParser: DataParser;
  20009. /**
  20010. * @private
  20011. */
  20012. protected _dragonBonesDataMap: Map<DragonBonesData>;
  20013. /**
  20014. * @private
  20015. */
  20016. protected _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
  20017. /**
  20018. * @private
  20019. */
  20020. constructor(dataParser?: DataParser);
  20021. /**
  20022. * @private
  20023. */
  20024. protected _getTextureData(textureAtlasName: string, textureName: string): TextureData;
  20025. /**
  20026. * @private
  20027. */
  20028. protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
  20029. /**
  20030. * @private
  20031. */
  20032. protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
  20033. /**
  20034. * @private
  20035. */
  20036. protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
  20037. /**
  20038. * @private
  20039. */
  20040. protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void;
  20041. /**
  20042. * @private
  20043. */
  20044. protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData;
  20045. /**
  20046. * @private
  20047. */
  20048. protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature;
  20049. /**
  20050. * @private
  20051. */
  20052. protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet, armature: Armature): Slot;
  20053. /**
  20054. * @language zh_CN
  20055. * 解析并添加龙骨数据。
  20056. * @param rawData 需要解析的原始数据。 (JSON)
  20057. * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20058. * @returns DragonBonesData
  20059. * @see #getDragonBonesData()
  20060. * @see #addDragonBonesData()
  20061. * @see #removeDragonBonesData()
  20062. * @see dragonBones.DragonBonesData
  20063. * @version DragonBones 4.5
  20064. */
  20065. parseDragonBonesData(rawData: any, name?: string, scale?: number): DragonBonesData;
  20066. /**
  20067. * @language zh_CN
  20068. * 解析并添加贴图集数据。
  20069. * @param rawData 需要解析的原始数据。 (JSON)
  20070. * @param textureAtlas 贴图集数据。 (JSON)
  20071. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20072. * @param scale 为贴图集设置一个缩放值。
  20073. * @returns 贴图集数据
  20074. * @see #getTextureAtlasData()
  20075. * @see #addTextureAtlasData()
  20076. * @see #removeTextureAtlasData()
  20077. * @see dragonBones.TextureAtlasData
  20078. * @version DragonBones 4.5
  20079. */
  20080. parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData;
  20081. /**
  20082. * @language zh_CN
  20083. * 获取指定名称的龙骨数据。
  20084. * @param name 数据名称。
  20085. * @returns DragonBonesData
  20086. * @see #parseDragonBonesData()
  20087. * @see #addDragonBonesData()
  20088. * @see #removeDragonBonesData()
  20089. * @see dragonBones.DragonBonesData
  20090. * @version DragonBones 3.0
  20091. */
  20092. getDragonBonesData(name: string): DragonBonesData;
  20093. /**
  20094. * @language zh_CN
  20095. * 添加龙骨数据。
  20096. * @param data 龙骨数据。
  20097. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20098. * @see #parseDragonBonesData()
  20099. * @see #getDragonBonesData()
  20100. * @see #removeDragonBonesData()
  20101. * @see dragonBones.DragonBonesData
  20102. * @version DragonBones 3.0
  20103. */
  20104. addDragonBonesData(data: DragonBonesData, name?: string): void;
  20105. /**
  20106. * @language zh_CN
  20107. * 移除龙骨数据。
  20108. * @param name 数据名称。
  20109. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20110. * @see #parseDragonBonesData()
  20111. * @see #getDragonBonesData()
  20112. * @see #addDragonBonesData()
  20113. * @see dragonBones.DragonBonesData
  20114. * @version DragonBones 3.0
  20115. */
  20116. removeDragonBonesData(name: string, disposeData?: boolean): void;
  20117. /**
  20118. * @language zh_CN
  20119. * 获取指定名称的贴图集数据列表。
  20120. * @param name 数据名称。
  20121. * @returns 贴图集数据列表。
  20122. * @see #parseTextureAtlasData()
  20123. * @see #addTextureAtlasData()
  20124. * @see #removeTextureAtlasData()
  20125. * @see dragonBones.textures.TextureAtlasData
  20126. * @version DragonBones 3.0
  20127. */
  20128. getTextureAtlasData(name: string): Array<TextureAtlasData>;
  20129. /**
  20130. * @language zh_CN
  20131. * 添加贴图集数据。
  20132. * @param data 贴图集数据。
  20133. * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
  20134. * @see #parseTextureAtlasData()
  20135. * @see #getTextureAtlasData()
  20136. * @see #removeTextureAtlasData()
  20137. * @see dragonBones.textures.TextureAtlasData
  20138. * @version DragonBones 3.0
  20139. */
  20140. addTextureAtlasData(data: TextureAtlasData, name?: string): void;
  20141. /**
  20142. * @language zh_CN
  20143. * 移除贴图集数据。
  20144. * @param name 数据名称。
  20145. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20146. * @see #parseTextureAtlasData()
  20147. * @see #getTextureAtlasData()
  20148. * @see #addTextureAtlasData()
  20149. * @see dragonBones.textures.TextureAtlasData
  20150. * @version DragonBones 3.0
  20151. */
  20152. removeTextureAtlasData(name: string, disposeData?: boolean): void;
  20153. /**
  20154. * @language zh_CN
  20155. * 清除所有的数据。
  20156. * @param disposeData 是否释放数据。 [false: 不释放, true: 释放]
  20157. * @version DragonBones 4.5
  20158. */
  20159. clear(disposeData?: boolean): void;
  20160. /**
  20161. * @language zh_CN
  20162. * 创建一个指定名称的骨架。
  20163. * @param armatureName 骨架数据名称。
  20164. * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。
  20165. * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。
  20166. * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。
  20167. * @returns 骨架
  20168. * @see dragonBones.Armature
  20169. * @version DragonBones 3.0
  20170. */
  20171. buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature;
  20172. /**
  20173. * @language zh_CN
  20174. * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构)
  20175. * @param toArmature 指定的骨架。
  20176. * @param fromArmatreName 其他骨架的名称。
  20177. * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。
  20178. * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。
  20179. * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除]
  20180. * @returns 是否替换成功。 [true: 成功, false: 不成功]
  20181. * @see dragonBones.Armature
  20182. * @version DragonBones 4.5
  20183. */
  20184. copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean;
  20185. /**
  20186. * @language zh_CN
  20187. * 将指定插槽的显示对象替换为指定资源创造出的显示对象。
  20188. * @param dragonBonesName 指定的龙骨数据名称。
  20189. * @param armatureName 指定的骨架名称。
  20190. * @param slotName 指定的插槽名称。
  20191. * @param displayName 指定的显示对象名称。
  20192. * @param slot 指定的插槽实例。
  20193. * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
  20194. * @version DragonBones 4.5
  20195. */
  20196. replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void;
  20197. /**
  20198. * @language zh_CN
  20199. * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。
  20200. * @param dragonBonesName 指定的 DragonBonesData 名称。
  20201. * @param armatureName 指定的骨架名称。
  20202. * @param slotName 指定的插槽名称。
  20203. * @param slot 指定的插槽实例。
  20204. * @version DragonBones 4.5
  20205. */
  20206. replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void;
  20207. /**
  20208. * @private
  20209. */
  20210. getAllDragonBonesData(): Map<DragonBonesData>;
  20211. /**
  20212. * @private
  20213. */
  20214. getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
  20215. }
  20216. }
  20217. declare let jsb: any;
  20218. /** Running in the editor. */
  20219. declare let CC_EDITOR: boolean;
  20220. /** Preview in browser or simulator. */
  20221. declare let CC_PREVIEW: boolean;
  20222. /** Running in the editor or preview. */
  20223. declare let CC_DEV: boolean;
  20224. /** Running in the editor or preview, or build in debug mode. */
  20225. declare let CC_DEBUG: boolean;
  20226. /** Running in published project. */
  20227. declare let CC_BUILD: boolean;
  20228. /** Running in native platform (mobile app, desktop app, or simulator). */
  20229. declare let CC_JSB: boolean;
  20230. /** Running in the engine's unit test. */
  20231. declare let CC_TEST: boolean;
  20232. /** Running in the Wechat's mini game. */
  20233. declare let CC_WECHATGAME: boolean;
  20234. /** Running in the bricks. */
  20235. declare let CC_QQPLAY: boolean;