12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844 |
- var cc = cc || {};
- cc._tmp = cc._tmp || {};
- cc._LogInfos = {};
- _p = window;
- _p = Object.prototype;
- delete window._p;
- cc.newElement = function(a) {
- return document.createElement(a)
- };
- cc._addEventListener = function(a, c, d, e) {
- a.addEventListener(c, d, e)
- };
- cc._isNodeJs = "undefined" !== typeof require && require("fs");
- cc.each = function(a, c, d) {
- if (a)
- if (a instanceof Array)
- for (var e = 0, f = a.length; e < f && !1 !== c.call(d, a[e], e); e++);
- else
- for (e in a)
- if (!1 === c.call(d, a[e], e)) break
- };
- cc.isCrossOrigin = function(a) {
- if (!a) return cc.log("invalid URL"), !1;
- var c = a.indexOf("://");
- if (-1 == c) return !1;
- c = a.indexOf("/", c + 3);
- return (-1 == c ? a : a.substring(0, c)) != location.origin
- };
- cc.async = {
- _counterFunc: function(a) {
- var c = this.counter;
- if (!c.err) {
- var d = c.length,
- e = c.results,
- f = c.option,
- g = f.cb,
- h = f.cbTarget,
- k = f.trigger,
- f = f.triggerTarget;
- if (a) {
- if (c.err = a, g) return g.call(h, a)
- } else {
- var m = Array.apply(null, arguments).slice(1),
- n = m.length;
- 0 == n ? m = null : 1 == n && (m = m[0]);
- e[this.index] = m;
- c.count--;
- k && k.call(f, m, d - c.count, d);
- 0 == c.count && g && g.apply(h, [null, e])
- }
- }
- },
- _emptyFunc: function() {},
- parallel: function(a, c, d) {
- var e = cc.async;
- if (void 0 !== d) "function" == typeof c && (c = {
- trigger: c
- }), c.cb = d || c.cb;
- else if (void 0 !== c) "function" == typeof c && (c = {
- cb: c
- });
- else if (void 0 !== a) c = {};
- else throw "arguments error!";
- var f = (d = a instanceof Array) ? a.length : Object.keys(a).length;
- if (0 == f) c.cb && c.cb.call(c.cbTarget, null);
- else {
- var g = {
- length: f,
- count: f,
- option: c,
- results: d ? [] : {}
- };
- cc.each(a, function(a, d) {
- if (g.err) return !1;
- var f = !c.cb && !c.trigger ? e._emptyFunc : e._counterFunc.bind({
- counter: g,
- index: d
- });
- a(f, d)
- })
- }
- },
- map: function(a, c, d) {
- var e = this,
- f = arguments.length;
- "function" == typeof c && (c = {
- iterator: c
- });
- if (3 === f) c.cb = d || c.cb;
- else if (2 > f) throw "arguments error!";
- "function" == typeof c && (c = {
- iterator: c
- });
- if (void 0 !== d) c.cb = d || c.cb;
- else if (void 0 === a) throw "arguments error!";
- var g = (f = a instanceof Array) ? a.length : Object.keys(a).length;
- if (0 === g) c.cb && c.cb.call(c.cbTarget, null);
- else {
- var h = {
- length: g,
- count: g,
- option: c,
- results: f ? [] : {}
- };
- cc.each(a, function(a, d) {
- if (h.err) return !1;
- var f = !c.cb ? e._emptyFunc : e._counterFunc.bind({
- counter: h,
- index: d
- });
- c.iterator.call(c.iteratorTarget, a, d, f)
- })
- }
- }
- };
- cc.path = {
- join: function() {
- for (var a = arguments.length, c = "", d = 0; d < a; d++) c = (c + ("" == c ? "" : "/") + arguments[d]).replace(/(\/|\\\\)$/, "");
- return c
- },
- extname: function(a) {
- return (a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null
- },
- mainFileName: function(a) {
- if (a) {
- var c = a.lastIndexOf(".");
- if (-1 !== c) return a.substring(0, c)
- }
- return a
- },
- basename: function(a, c) {
- var d = a.indexOf("?");
- 0 < d && (a = a.substring(0, d));
- d = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, ""));
- if (!d) return null;
- d = d[2];
- return c && a.substring(a.length - c.length).toLowerCase() == c.toLowerCase() ? d.substring(0, d.length - c.length) : d
- },
- dirname: function(a) {
- return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2")
- },
- changeExtname: function(a, c) {
- c = c || "";
- var d = a.indexOf("?"),
- e = "";
- 0 < d && (e = a.substring(d), a = a.substring(0, d));
- d = a.lastIndexOf(".");
- return 0 > d ? a + c + e : a.substring(0, d) + c + e
- },
- changeBasename: function(a, c, d) {
- if (0 == c.indexOf(".")) return this.changeExtname(a, c);
- var e = a.indexOf("?"),
- f = "";
- d = d ? this.extname(a) : "";
- 0 < e && (f = a.substring(e), a = a.substring(0, e));
- e = a.lastIndexOf("/");
- return a.substring(0, 0 >= e ? 0 : e + 1) + c + d + f
- }
- };
- cc.loader = {
- _jsCache: {},
- _register: {},
- _langPathCache: {},
- _aliases: {},
- resPath: "",
- audioPath: "",
- cache: {},
- getXMLHttpRequest: function() {
- return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP")
- },
- _getArgs4Js: function(a) {
- var c = a[0],
- d = a[1],
- e = a[2],
- f = ["", null, null];
- if (1 === a.length) f[1] = c instanceof Array ? c : [c];
- else if (2 === a.length) "function" == typeof d ? (f[1] = c instanceof Array ? c : [c], f[2] = d) : (f[0] = c || "", f[1] = d instanceof Array ? d : [d]);
- else if (3 === a.length) f[0] = c || "", f[1] = d instanceof Array ? d : [d], f[2] = e;
- else throw "arguments error to load js!";
- return f
- },
- loadJs: function(a, c, d) {
- var e = this,
- f = e._jsCache,
- g = e._getArgs4Js(arguments); - 1 < navigator.userAgent.indexOf("Trident/5") ? e._loadJs4Dependency(g[0], g[1], 0, g[2]) : cc.async.map(g[1], function(a, c, d) {
- a = cc.path.join(g[0], a);
- if (f[a]) return d(null);
- e._createScript(a, !1, d)
- }, g[2])
- },
- loadJsWithImg: function(a, c, d) {
- var e = this._loadJsImg(),
- f = this._getArgs4Js(arguments);
- this.loadJs(f[0], f[1], function(a) {
- if (a) throw a;
- e.parentNode.removeChild(e);
- if (f[2]) f[2]()
- })
- },
- _createScript: function(a, c, d) {
- var e = document,
- f = cc.newElement("script");
- f.async = c;
- f.src = a;
- this._jsCache[a] = !0;
- cc._addEventListener(f, "load", function() {
- this.removeEventListener("load", arguments.callee, !1);
- d()
- }, !1);
- cc._addEventListener(f, "error", function() {
- d("Load " + a + " failed!")
- }, !1);
- e.body.appendChild(f)
- },
- _loadJs4Dependency: function(a, c, d, e) {
- if (d >= c.length) e && e();
- else {
- var f = this;
- f._createScript(cc.path.join(a, c[d]), !1, function(g) {
- if (g) return e(g);
- f._loadJs4Dependency(a, c, d + 1, e)
- })
- }
- },
- _loadJsImg: function() {
- var a = document,
- c = a.getElementById("cocos2d_loadJsImg");
- if (!c) {
- c = cc.newElement("img");
- cc._loadingImage && (c.src = cc._loadingImage);
- a = a.getElementById(cc.game.config.id);
- a.style.backgroundColor = "black";
- a.parentNode.appendChild(c);
- var d = getComputedStyle ? getComputedStyle(a) : a.currentStyle;
- d || (d = {
- width: a.width,
- height: a.height
- });
- c.style.left = a.offsetLeft + (parseFloat(d.width) - c.width) / 2 + "px";
- c.style.top = a.offsetTop + (parseFloat(d.height) - c.height) / 2 + "px";
- c.style.position = "absolute"
- }
- return c
- },
- loadTxt: function(a, c) {
- if (cc._isNodeJs) require("fs").readFile(a, function(a, d) {
- a ? c(a) : c(null, d.toString())
- });
- else {
- var d = this.getXMLHttpRequest(),
- e = "load " + a + " failed!";
- d.open("GET", a, !0);
- /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "utf-8"), d.onreadystatechange = function() {
- 4 == d.readyState && 200 == d.status ? c(null, d.responseText) : c(e)
- }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dutf-8"), d.onload = function() {
- 4 == d.readyState && 200 == d.status ? c(null, d.responseText) : c(e)
- });
- d.send(null)
- }
- },
- _loadTxtSync: function(a) {
- if (cc._isNodeJs) return require("fs").readFileSync(a).toString();
- var c = this.getXMLHttpRequest();
- c.open("GET", a, !1);
- /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? c.setRequestHeader("Accept-Charset", "utf-8") : c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dutf-8");
- c.send(null);
- return 4 == !c.readyState || 200 != c.status ? null : c.responseText
- },
- loadJson: function(a, c) {
- this.loadTxt(a, function(d, e) {
- try {
- d ? c(d) : c(null, JSON.parse(e))
- } catch (f) {
- throw "load json [" + a + "] failed : " + f;
- }
- })
- },
- _checkIsImageURL: function(a) {
- return null != /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)
- },
- loadImg: function(a, c, d) {
- var e = !0;
- void 0 !== d ? e = null == c.isCrossOrigin ? e : c.isCrossOrigin : void 0 !== c && (d = c);
- var f = new Image;
- e && "file://" != location.origin && (f.crossOrigin = "Anonymous");
- cc._addEventListener(f, "load", function() {
- this.removeEventListener("load", arguments.callee, !1);
- this.removeEventListener("error", arguments.callee, !1);
- d && d(null, f)
- });
- cc._addEventListener(f, "error", function() {
- this.removeEventListener("error", arguments.callee, !1);
- d && d("load image failed")
- });
- f.src = a;
- return f
- },
- _loadResIterator: function(a, c, d) {
- var e = this,
- f = null,
- g = a.type;
- g ? (g = "." + g.toLowerCase(), f = a.src ? a.src : a.name + g) : (f = a, g = cc.path.extname(f));
- if (c = e.cache[f]) return d(null, c);
- c = e._register[g.toLowerCase()];
- if (!c) return cc.error("loader for [" + g + "] not exists!"), d();
- g = c.getBasePath ? c.getBasePath() : e.resPath;
- g = e.getUrl(g, f);
- c.load(g, f, a, function(a, c) {
- a ? (cc.log(a), e.cache[f] = null, delete e.cache[f], d()) : (e.cache[f] = c, d(null, c))
- })
- },
- getUrl: function(a, c) {
- var d = this._langPathCache,
- e = cc.path;
- if (void 0 !== a && void 0 === c) {
- c = a;
- var f = e.extname(c),
- f = f ? f.toLowerCase() : "";
- a = (f = this._register[f]) ? f.getBasePath ? f.getBasePath() : this.resPath : this.resPath
- }
- c = cc.path.join(a || "", c);
- if (c.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) {
- if (d[c]) return d[c];
- e = e.extname(c) || "";
- c = d[c] = c.substring(0, c.length - e.length) + "_" + cc.sys.language + e
- }
- return c
- },
- load: function(a, c, d) {
- if (void 0 !== d) "function" == typeof c && (c = {
- trigger: c
- });
- else if (void 0 !== c) "function" == typeof c && (d = c, c = {});
- else if (void 0 !== a) c = {};
- else throw "arguments error!";
- c.cb = function(a, c) {
- a && cc.log(a);
- d && d(c)
- };
- a instanceof Array || (a = [a]);
- c.iterator = this._loadResIterator;
- c.iteratorTarget = this;
- cc.async.map(a, c)
- },
- _handleAliases: function(a, c) {
- var d = this._aliases,
- e = [],
- f;
- for (f in a) {
- var g = a[f];
- d[f] = g;
- e.push(g)
- }
- this.load(e, c)
- },
- loadAliases: function(a, c) {
- var d = this,
- e = d.getRes(a);
- e ? d._handleAliases(e.filenames, c) : d.load(a, function(a) {
- d._handleAliases(a[0].filenames, c)
- })
- },
- register: function(a, c) {
- if (a && c) {
- if ("string" == typeof a) return this._register[a.trim().toLowerCase()] = c;
- for (var d = 0, e = a.length; d < e; d++) this._register["." + a[d].trim().toLowerCase()] = c
- }
- },
- getRes: function(a) {
- return this.cache[a] || this.cache[this._aliases[a]]
- },
- release: function(a) {
- var c = this.cache,
- d = this._aliases;
- delete c[a];
- delete c[d[a]];
- delete d[a]
- },
- releaseAll: function() {
- var a = this.cache,
- c = this._aliases,
- d;
- for (d in a) delete a[d];
- for (d in c) delete c[d]
- }
- };
- (function() {
- var a = window,
- c, d;
- "undefined" !== typeof document.hidden ? (c = "hidden", d = "visibilitychange") : "undefined" !== typeof document.mozHidden ? (c = "mozHidden", d = "mozvisibilitychange") : "undefined" !== typeof document.msHidden ? (c = "msHidden", d = "msvisibilitychange") : "undefined" !== typeof document.webkitHidden && (c = "webkitHidden", d = "webkitvisibilitychange");
- var e = function() {
- cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide)
- },
- f = function() {
- cc.eventManager && cc.game._eventShow && cc.eventManager.dispatchEvent(cc.game._eventShow);
- cc.game._intervalId && (window.cancelAnimationFrame(cc.game._intervalId), cc.game._runMainLoop())
- };
- c ? cc._addEventListener(document, d, function() {
- document[c] ? e() : f()
- }, !1) : (cc._addEventListener(a, "blur", e, !1), cc._addEventListener(a, "focus", f, !1)); - 1 < navigator.userAgent.indexOf("MicroMessenger") && (a.onfocus = function() {
- f()
- });
- "onpageshow" in window && "onpagehide" in window && (cc._addEventListener(a, "pagehide", e, !1), cc._addEventListener(a, "pageshow", f, !1));
- d = a = null
- })();
- cc.log = cc.warn = cc.error = cc.assert = function() {};
- cc.create3DContext = function(a, c) {
- for (var d = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], e = null, f = 0; f < d.length; ++f) {
- try {
- e = a.getContext(d[f], c)
- } catch (g) {}
- if (e) break
- }
- return e
- };
- cc._initSys = function(a, c) {
- cc._RENDER_TYPE_CANVAS = 0;
- cc._RENDER_TYPE_WEBGL = 1;
- cc.sys = {};
- var d = cc.sys;
- d.LANGUAGE_ENGLISH = "en";
- d.LANGUAGE_CHINESE = "zh";
- d.LANGUAGE_FRENCH = "fr";
- d.LANGUAGE_ITALIAN = "it";
- d.LANGUAGE_GERMAN = "de";
- d.LANGUAGE_SPANISH = "es";
- d.LANGUAGE_RUSSIAN = "ru";
- d.LANGUAGE_KOREAN = "ko";
- d.LANGUAGE_JAPANESE = "ja";
- d.LANGUAGE_HUNGARIAN = "hu";
- d.LANGUAGE_PORTUGUESE = "pt";
- d.LANGUAGE_ARABIC = "ar";
- d.LANGUAGE_NORWEGIAN = "no";
- d.LANGUAGE_POLISH = "pl";
- d.OS_WINDOWS = "Windows";
- d.OS_IOS = "iOS";
- d.OS_OSX = "OS X";
- d.OS_UNIX = "UNIX";
- d.OS_LINUX = "Linux";
- d.OS_ANDROID = "Android";
- d.OS_UNKNOWN = "Unknown";
- d.WINDOWS = 0;
- d.LINUX = 1;
- d.MACOS = 2;
- d.ANDROID = 3;
- d.IPHONE = 4;
- d.IPAD = 5;
- d.BLACKBERRY = 6;
- d.NACL = 7;
- d.EMSCRIPTEN = 8;
- d.TIZEN = 9;
- d.WINRT = 10;
- d.WP8 = 11;
- d.MOBILE_BROWSER = 100;
- d.DESKTOP_BROWSER = 101;
- d.BROWSER_TYPE_WECHAT = "wechat";
- d.BROWSER_TYPE_ANDROID = "androidbrowser";
- d.BROWSER_TYPE_IE = "ie";
- d.BROWSER_TYPE_QQ = "qqbrowser";
- d.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
- d.BROWSER_TYPE_UC = "ucbrowser";
- d.BROWSER_TYPE_360 = "360browser";
- d.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
- d.BROWSER_TYPE_BAIDU = "baidubrowser";
- d.BROWSER_TYPE_MAXTHON = "maxthon";
- d.BROWSER_TYPE_OPERA = "opera";
- d.BROWSER_TYPE_MIUI = "miuibrowser";
- d.BROWSER_TYPE_FIREFOX = "firefox";
- d.BROWSER_TYPE_SAFARI = "safari";
- d.BROWSER_TYPE_CHROME = "chrome";
- d.BROWSER_TYPE_UNKNOWN = "unknown";
- d.isNative = !1;
- var e = [d.BROWSER_TYPE_BAIDU, d.BROWSER_TYPE_OPERA, d.BROWSER_TYPE_FIREFOX, d.BROWSER_TYPE_CHROME, d.BROWSER_TYPE_SAFARI],
- f = [d.BROWSER_TYPE_BAIDU, d.BROWSER_TYPE_OPERA, d.BROWSER_TYPE_FIREFOX, d.BROWSER_TYPE_CHROME, d.BROWSER_TYPE_SAFARI, d.BROWSER_TYPE_UC, d.BROWSER_TYPE_QQ, d.BROWSER_TYPE_MOBILE_QQ, d.BROWSER_TYPE_IE],
- g = window,
- h = g.navigator,
- k = document.documentElement,
- m = h.userAgent.toLowerCase();
- d.isMobile = -1 != m.indexOf("mobile") || -1 != m.indexOf("android");
- d.platform = d.isMobile ? d.MOBILE_BROWSER : d.DESKTOP_BROWSER;
- var n = h.language,
- n = (n = n ? n : h.browserLanguage) ? n.split("-")[0] : d.LANGUAGE_ENGLISH;
- d.language = n;
- var n = d.BROWSER_TYPE_UNKNOWN,
- q = m.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i) || m.match(/chrome|safari/i);
- q && 0 < q.length && (n = q[0].toLowerCase(), "micromessenger" == n ? n = d.BROWSER_TYPE_WECHAT : "safari" === n && m.match(/android.*applewebkit/) ? n = d.BROWSER_TYPE_ANDROID : "trident" == n && (n = d.BROWSER_TYPE_IE));
- d.browserType = n;
- d._supportMultipleAudio = -1 < f.indexOf(d.browserType);
- f = parseInt(a[c.renderMode]);
- n = cc._RENDER_TYPE_WEBGL;
- q = cc.newElement("Canvas");
- cc._supportRender = !0;
- e = -1 == e.indexOf(d.browserType);
- if (1 === f || 0 === f && (d.isMobile || e) || "file://" == location.origin) n = cc._RENDER_TYPE_CANVAS;
- d._canUseCanvasNewBlendModes = function() {
- var a = document.createElement("canvas");
- a.width = 1;
- a.height = 1;
- a = a.getContext("2d");
- a.fillStyle = "#000";
- a.fillRect(0, 0, 1, 1);
- a.globalCompositeOperation = "multiply";
- a.fillStyle = "#fff";
- a.fillRect(0, 0, 1, 1);
- return 0 === a.getImageData(0, 0, 1, 1).data[0]
- };
- d._supportCanvasNewBlendModes = d._canUseCanvasNewBlendModes();
- if (n == cc._RENDER_TYPE_WEBGL && (!g.WebGLRenderingContext || !cc.create3DContext(q, {
- stencil: !0,
- preserveDrawingBuffer: !0
- }))) 0 == f ? n = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1;
- if (n == cc._RENDER_TYPE_CANVAS) try {
- q.getContext("2d")
- } catch (r) {
- cc._supportRender = !1
- }
- cc._renderType = n;
- try {
- d._supportWebAudio = !!new(g.AudioContext || g.webkitAudioContext || g.mozAudioContext)
- } catch (t) {
- d._supportWebAudio = !1
- }
- try {
- var s = d.localStorage = g.localStorage;
- s.setItem("storage", "");
- s.removeItem("storage");
- s = null
- } catch (v) {
- ("SECURITY_ERR" === v.name || "QuotaExceededError" === v.name) && cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"), d.localStorage = function() {}
- }
- s = d.capabilities = {
- canvas: !0
- };
- cc._renderType == cc._RENDER_TYPE_WEBGL && (s.opengl = !0);
- void 0 !== k.ontouchstart || h.msPointerEnabled ? s.touches = !0 : void 0 !== k.onmouseup && (s.mouse = !0);
- void 0 !== k.onkeyup && (s.keyboard = !0);
- if (g.DeviceMotionEvent || g.DeviceOrientationEvent) s.accelerometer = !0;
- g = m.match(/(iPad|iPhone|iPod)/i) ? !0 : !1;
- m = m.match(/android/i) || h.platform.match(/android/i) ? !0 : !1;
- k = d.OS_UNKNOWN; - 1 != h.appVersion.indexOf("Win") ? k = d.OS_WINDOWS : g ? k = d.OS_IOS : -1 != h.appVersion.indexOf("Mac") ? k = d.OS_OSX : -1 != h.appVersion.indexOf("X11") ? k = d.OS_UNIX : -1 != h.appVersion.indexOf("Linux") ? k = d.OS_LINUX : m && (k = d.OS_ANDROID);
- d.os = k;
- d.garbageCollect = function() {};
- d.dumpRoot = function() {};
- d.restartVM = function() {};
- d.dump = function() {
- var a;
- a = "" + ("isMobile : " + this.isMobile + "\r\n");
- a += "language : " + this.language + "\r\n";
- a += "browserType : " + this.browserType + "\r\n";
- a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n";
- a += "os : " + this.os + "\r\n";
- a += "platform : " + this.platform + "\r\n";
- cc.log(a)
- }
- };
- cc.ORIENTATION_PORTRAIT = 0;
- cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
- cc.ORIENTATION_LANDSCAPE_LEFT = 2;
- cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
- cc._drawingUtil = null;
- cc._renderContext = null;
- cc._canvas = null;
- cc._gameDiv = null;
- cc._rendererInitialized = !1;
- cc._setupCalled = !1;
- cc._setup = function(a, c, d) {
- if (!cc._setupCalled) {
- cc._setupCalled = !0;
- var e = window,
- f = new Date,
- g = 1E3 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
- e.requestAnimFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function(a) {
- var c = (new Date).getTime(),
- d = Math.max(0, g - (c - f)),
- e = window.setTimeout(function() {
- a()
- }, d);
- f = c + d;
- return e
- };
- e.cancelAnimationFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || function(a) {
- clearTimeout(a)
- };
- var h = cc.$(a) || cc.$("#" + a),
- k;
- "CANVAS" == h.tagName ? (c = c || h.width, d = d || h.height, k = cc.container = cc.newElement("DIV"), a = cc._canvas = h, a.parentNode.insertBefore(k, a), a.appendTo(k), k.setAttribute("id", "Cocos2dGameContainer")) : ("DIV" != h.tagName && cc.log("Warning: target element is not a DIV or CANVAS"), c = c || h.clientWidth, d = d || h.clientHeight, k = cc.container = h, a = cc._canvas = cc.$(cc.newElement("CANVAS")), h.appendChild(a));
- a.addClass("gameCanvas");
- a.setAttribute("width", c || 480);
- a.setAttribute("height", d || 320);
- a.setAttribute("tabindex", 99);
- a.style.outline = "none";
- h = k.style;
- h.width = (c || 480) + "px";
- h.height = (d || 320) + "px";
- h.margin = "0 auto";
- h.position = "relative";
- h.overflow = "hidden";
- k.top = "100%";
- cc._renderType == cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, {
- stencil: !0,
- preserveDrawingBuffer: !0,
- antialias: !cc.sys.isMobile,
- alpha: !1
- }));
- cc._renderContext ? (e.gl = cc._renderContext, cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext), cc._rendererInitialized = !0, cc.textureCache._initializingRenderer(), cc.shaderCache._init()) : (cc._renderContext = a.getContext("2d"), cc._mainRenderContextBackup = cc._renderContext, cc._renderContext.translate(0, a.height), cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(cc._renderContext) : null);
- cc._gameDiv = k;
- cc.log(cc.ENGINE_VERSION);
- cc._setContextMenuEnable(!1);
- cc.sys.isMobile && (c = cc.newElement("style"), c.type = "text/css", document.body.appendChild(c), c.textContent = "body,canvas,div{ -moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;-webkit-tap-highlight-color:rgba(0,0,0,0);}");
- cc.view = cc.EGLView._getInstance();
- cc.inputManager.registerSystemEvent(cc._canvas);
- cc.director = cc.Director._getInstance();
- cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view);
- cc.winSize = cc.director.getWinSize();
- cc.saxParser = new cc.SAXParser;
- cc.plistParser = new cc.PlistParser
- }
- };
- cc._checkWebGLRenderMode = function() {
- if (cc._renderType !== cc._RENDER_TYPE_WEBGL) throw "This feature supports WebGL render mode only.";
- };
- cc._isContextMenuEnable = !1;
- cc._setContextMenuEnable = function(a) {
- cc._isContextMenuEnable = a;
- cc._canvas.oncontextmenu = function() {
- if (!cc._isContextMenuEnable) return !1
- }
- };
- cc.game = {
- DEBUG_MODE_NONE: 0,
- DEBUG_MODE_INFO: 1,
- DEBUG_MODE_WARN: 2,
- DEBUG_MODE_ERROR: 3,
- DEBUG_MODE_INFO_FOR_WEB_PAGE: 4,
- DEBUG_MODE_WARN_FOR_WEB_PAGE: 5,
- DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6,
- EVENT_HIDE: "game_on_hide",
- EVENT_SHOW: "game_on_show",
- _eventHide: null,
- _eventShow: null,
- _onBeforeStartArr: [],
- CONFIG_KEY: {
- engineDir: "engineDir",
- dependencies: "dependencies",
- debugMode: "debugMode",
- showFPS: "showFPS",
- frameRate: "frameRate",
- id: "id",
- renderMode: "renderMode",
- jsList: "jsList",
- classReleaseMode: "classReleaseMode"
- },
- _prepareCalled: !1,
- _prepared: !1,
- _paused: !0,
- _intervalId: null,
- config: null,
- onStart: null,
- onStop: null,
- setFrameRate: function(a) {
- this.config[this.CONFIG_KEY.frameRate] = a;
- this._intervalId && window.cancelAnimationFrame(this._intervalId);
- this._paused = !0;
- this._runMainLoop()
- },
- _runMainLoop: function() {
- var a = this,
- c, d = cc.director;
- d.setDisplayStats(a.config[a.CONFIG_KEY.showFPS]);
- c = function() {
- a._paused || (d.mainLoop(), a._intervalId = window.requestAnimFrame(c))
- };
- window.requestAnimFrame(c);
- a._paused = !1
- },
- run: function(a) {
- var c = this,
- d = function() {
- a && (c.config[c.CONFIG_KEY.id] = a);
- c._prepareCalled ? cc._supportRender && (c._checkPrepare = setInterval(function() {
- c._prepared && (cc._setup(c.config[c.CONFIG_KEY.id]), c._runMainLoop(), c._eventHide = c._eventHide || new cc.EventCustom(c.EVENT_HIDE), c._eventHide.setUserData(c), c._eventShow = c._eventShow || new cc.EventCustom(c.EVENT_SHOW), c._eventShow.setUserData(c), c.onStart(), clearInterval(c._checkPrepare))
- }, 10)) : c.prepare(function() {
- cc._supportRender && (cc._setup(c.config[c.CONFIG_KEY.id]), c._runMainLoop(), c._eventHide = c._eventHide || new cc.EventCustom(c.EVENT_HIDE), c._eventHide.setUserData(c), c._eventShow = c._eventShow || new cc.EventCustom(c.EVENT_SHOW), c._eventShow.setUserData(c), c.onStart())
- })
- };
- document.body ? d() : cc._addEventListener(window, "load", function() {
- this.removeEventListener("load", arguments.callee, !1);
- d()
- }, !1)
- },
- _initConfig: function() {
- var a = this.CONFIG_KEY,
- c = function(c) {
- c[a.engineDir] = c[a.engineDir] || "frameworks/cocos2d-html5";
- null == c[a.debugMode] && (c[a.debugMode] = 0);
- c[a.frameRate] = c[a.frameRate] || 60;
- null == c[a.renderMode] && (c[a.renderMode] = 1);
- return c
- };
- if (document.ccConfig) this.config = c(document.ccConfig);
- else try {
- for (var d = document.getElementsByTagName("script"), e = 0; e < d.length; e++) {
- var f = d[e].getAttribute("cocos");
- if ("" == f || f) break
- }
- var g, h, k;
- if (e < d.length) {
- if (g = d[e].src) k = /(.*)\//.exec(g)[0], cc.loader.resPath = k, g = cc.path.join(k, "project.json");
- h = cc.loader._loadTxtSync(g)
- }
- h || (h = cc.loader._loadTxtSync("project.json"));
- var m = JSON.parse(h);
- this.config = c(m || {})
- } catch (n) {
- cc.log("Failed to read or parse project.json"), this.config = c({})
- }
- cc._initSys(this.config, a)
- },
- _jsAddedCache: {},
- _getJsListOfModule: function(a, c, d) {
- var e = this._jsAddedCache;
- if (e[c]) return null;
- d = d || "";
- var f = [],
- g = a[c];
- if (!g) throw "can not find module [" + c + "]";
- c = cc.path;
- for (var h = 0, k = g.length; h < k; h++) {
- var m = g[h];
- if (!e[m]) {
- var n = c.extname(m);
- n ? ".js" == n.toLowerCase() && f.push(c.join(d, m)) : (n = this._getJsListOfModule(a, m, d)) && (f = f.concat(n));
- e[m] = 1
- }
- }
- return f
- },
- prepare: function(a) {
- var c = this,
- d = c.config,
- e = c.CONFIG_KEY,
- f = d[e.engineDir],
- g = cc.loader;
- if (!cc._supportRender) throw "The renderer doesn't support the renderMode " + d[e.renderMode];
- c._prepareCalled = !0;
- var h = d[e.jsList] || [];
- cc.Class ? g.loadJsWithImg("", h, function(d) {
- if (d) throw d;
- c._prepared = !0;
- a && a()
- }) : (e = cc.path.join(f, "moduleConfig.json"), g.loadJson(e, function(e, g) {
- if (e) throw e;
- var n = d.modules || [],
- q = g.module,
- r = [];
- cc._renderType == cc._RENDER_TYPE_WEBGL ? n.splice(0, 0, "shaders") : 0 > n.indexOf("core") && n.splice(0, 0, "core");
- for (var t = 0, s = n.length; t < s; t++) {
- var v = c._getJsListOfModule(q, n[t], f);
- v && (r = r.concat(v))
- }
- r = r.concat(h);
- cc.loader.loadJsWithImg(r, function(d) {
- if (d) throw d;
- c._prepared = !0;
- a && a()
- })
- }))
- }
- };
- cc.game._initConfig();
- Function.prototype.bind = Function.prototype.bind || function(a) {
- var c = this;
- return function() {
- var d = Array.prototype.slice.call(arguments);
- return c.apply(a || null, d)
- }
- };
- cc._LogInfos = {
- ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null",
- ActionManager_removeAction: "cocos2d: removeAction: Target not found",
- ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag",
- ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null",
- ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag",
- ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag \x3d %s): Action not found",
- configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",
- configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s",
- configuration_loadConfigFile_2: "Please load the resource first : %s",
- Director_resume: "cocos2d: Director: Error in gettimeofday",
- Director_setProjection: "cocos2d: Director: unrecognized projection",
- Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection",
- Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday",
- Director_popScene: "running scene should not null",
- Director_pushScene: "the scene should not null",
- arrayVerifyType: "element type is wrong!",
- Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",
- Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",
- Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",
- Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null",
- Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null",
- Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null",
- Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.",
- Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.",
- Node_getRotation: "RotationX !\x3d RotationY. Don't know which one to return",
- Node_getScale: "ScaleX !\x3d ScaleY. Don't know which one to return",
- Node_addChild: "An Node can't be added as a child of itself.",
- Node_addChild_2: "child already added. It can't be added again",
- Node_addChild_3: "child must be non-null",
- Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead",
- Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead",
- Node_removeChildByTag: "argument tag is an invalid tag",
- Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag \x3d %s): child not found!",
- Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",
- Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag",
- Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag",
- Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.",
- Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.",
- Node__arrayMakeObjectsPerformSelector: "Unknown callback function",
- Node_reorderChild: "child must be non-null",
- Node_runAction: "cc.Node.runAction(): action must be non-null",
- Node_schedule: "callback function must be non-null",
- Node_schedule_2: "interval must be positive",
- Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
- AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",
- AtlasNode_initWithTileFile: "",
- AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
- _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",
- _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",
- _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",
- _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",
- EventListener_create: "Invalid parameter.",
- __getListenerID: "Don't call this method if the event is for touch.",
- eventManager__forceAddEventListener: "Invalid scene graph priority!",
- eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.",
- eventManager_removeListeners: "Invalid listener type!",
- eventManager_setPriority: "Can't set fixed priority with scene graph based listener.",
- eventManager_addListener_2: "Invalid parameters.",
- eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener",
- eventManager_addListener_4: "The listener has been registered, please don't register it again.",
- LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript",
- LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message",
- LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message",
- LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null",
- EGLView_setDesignResolutionSize: "Resolution not valid",
- EGLView_setDesignResolutionSize_2: "should set resolutionPolicy",
- inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s",
- swap: "cc.swap is being modified from original macro, please check usage",
- checkGLErrorDebug: "WebGL error %s",
- animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",
- animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format",
- animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found",
- animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
- animationCache__parseVersion1_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",
- animationCache__parseVersion1_3: "cocos2d: cc.AnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache.",
- animationCache__parseVersion1_4: "cocos2d: cc.AnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.",
- animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
- animationCache__parseVersion2_2: "cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",
- animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name",
- Sprite_reorderChild: "cc.Sprite.reorderChild(): this child is not in children list",
- Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",
- Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",
- Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",
- Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.",
- Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
- Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",
- Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",
- Sprite_initWithSpriteFrameName1: " is null, please check.",
- Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null",
- Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",
- Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null",
- Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",
- Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",
- Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null",
- Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",
- Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
- Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
- Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
- Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",
- Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
- Sprite_setSpriteFrame: "Invalid spriteFrameName",
- Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",
- Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
- Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
- Sprite_addChild_6: "cc.SpriteBatchNode.addChild(): child should be non-null",
- SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",
- SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",
- SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas",
- SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",
- SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",
- SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",
- SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild():child should be non-null",
- spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",
- spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists",
- spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",
- spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found",
- spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s",
- spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",
- spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil",
- CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
- CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
- CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
- CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
- CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null",
- CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName",
- CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",
- CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
- CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
- CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null",
- TextureAtlas_initWithFile: "cocos2d: Could not open file: %s",
- TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads",
- TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null",
- TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null",
- TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index",
- TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index",
- TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount",
- TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",
- TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",
- TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index",
- TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",
- TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",
- TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",
- TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",
- textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5",
- textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5",
- textureCache_addPVRImage: "addPVRImage does not support on HTML5",
- textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache",
- textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id\x3d%s %s x %s",
- textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s",
- textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",
- textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null",
- Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5",
- Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5",
- Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5",
- Texture2D_addImage: "cc.Texture.addImage(): path should be non-null",
- Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",
- Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",
- Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5",
- Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5",
- Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5",
- Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5",
- Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",
- Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",
- Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null",
- Texture2D_initWithData: "NSInternalInconsistencyException",
- MissingFile: "Missing file: %s",
- radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()",
- RectWidth: "Rect width exceeds maximum margin: %s",
- RectHeight: "Rect height exceeds maximum margin: %s",
- EventManager__updateListeners: "If program goes here, there should be event in dispatch.",
- EventManager__updateListeners_2: "_inDispatch should be 1 here."
- };
- cc._logToWebPage = function(a) {
- if (cc._canvas) {
- var c = cc._logList,
- d = document;
- if (!c) {
- var e = d.createElement("Div"),
- c = e.style;
- e.setAttribute("id", "logInfoDiv");
- cc._canvas.parentNode.appendChild(e);
- e.setAttribute("width", "200");
- e.setAttribute("height", cc._canvas.height);
- c.zIndex = "99999";
- c.position = "absolute";
- c.top = "0";
- c.left = "0";
- c = cc._logList = d.createElement("textarea");
- d = c.style;
- c.setAttribute("rows", "20");
- c.setAttribute("cols", "30");
- c.setAttribute("disabled", !0);
- e.appendChild(c);
- d.backgroundColor = "transparent";
- d.borderBottom = "1px solid #cccccc";
- d.borderRightWidth = "0px";
- d.borderLeftWidth = "0px";
- d.borderTopWidth = "0px";
- d.borderTopStyle = "none";
- d.borderRightStyle = "none";
- d.borderLeftStyle = "none";
- d.padding = "0px";
- d.margin = 0
- }
- a = "string" == typeof a ? a : JSON.stringify(a);
- c.value = c.value + a + "\r\n";
- c.scrollTop = c.scrollHeight
- }
- };
- cc._formatString = function(a) {
- if ("object" === typeof a) try {
- return JSON.stringify(a)
- } catch (c) {
- return ""
- } else return a
- };
- (cc.log = function(a) {
- for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
- }, cc.warn = console.warn ? function(a) {
- for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
- console.warn(a)
- } : cc.log, cc.error = console.error ? function(a) {
- for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
- } : cc.log, cc.assert = function(a, c) {
- if (!a && c) {
- for (var d = 2; d < arguments.length; d++) c = c.replace(/(%s)|(%d)/, cc._formatString(arguments[d]));
- throw c;
- }
- });
- var mode = cc.game.config[cc.game.CONFIG_KEY.debugMode],
- ccGame = cc.game;
- mode === ccGame.DEBUG_MODE_INFO || (cc.log = mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE ? cc._logToWebPage.bind(cc) : function() {});
- if (!mode || mode == ccGame.DEBUG_MODE_NONE || mode == ccGame.DEBUG_MODE_ERROR || mode == ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE) cc.warn = function() {};
- if (mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_WARN_FOR_WEB_PAGE || !console.warn) cc.warn = cc._logToWebPage.bind(cc);
- if (!mode || mode == ccGame.DEBUG_MODE_NONE) cc.error = function() {}, cc.assert = function() {};
- else if (mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_WARN_FOR_WEB_PAGE || mode == ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE || !console.error) cc.error = cc._logToWebPage.bind(cc), cc.assert = function(a, c) {
- if (!a && c) {
- for (var d = 2; d < arguments.length; d++) c = c.replace("%s", arguments[d]);
- cc._logToWebPage(c)
- }
- };
- cc.loader.loadBinary = function(a, c) {
- var d = this,
- e = this.getXMLHttpRequest(),
- f = "load " + a + " failed!";
- e.open("GET", a, !0);
- /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (e.setRequestHeader("Accept-Charset", "x-user-defined"), e.onreadystatechange = function() {
- if (4 == e.readyState && 200 == e.status) {
- var a = cc._convertResponseBodyToText(e.responseBody);
- c(null, d._str2Uint8Array(a))
- } else c(f)
- }) : (e.overrideMimeType && e.overrideMimeType("text/plain; charset\x3dx-user-defined"), e.onload = function() {
- 4 == e.readyState && 200 == e.status ? c(null, d._str2Uint8Array(e.responseText)) : c(f)
- });
- e.send(null)
- };
- cc.loader._str2Uint8Array = function(a) {
- if (!a) return null;
- for (var c = new Uint8Array(a.length), d = 0; d < a.length; d++) c[d] = a.charCodeAt(d) & 255;
- return c
- };
- cc.loader.loadBinarySync = function(a) {
- var c = this.getXMLHttpRequest(),
- d = "load " + a + " failed!";
- c.open("GET", a, !1);
- a = null;
- if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
- c.setRequestHeader("Accept-Charset", "x-user-defined");
- c.send(null);
- if (200 != c.status) return cc.log(d), null;
- (c = cc._convertResponseBodyToText(c.responseBody)) && (a = this._str2Uint8Array(c))
- } else {
- c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dx-user-defined");
- c.send(null);
- if (200 != c.status) return cc.log(d), null;
- a = this._str2Uint8Array(c.responseText)
- }
- return a
- };
- var Uint8Array = Uint8Array || Array;
- if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
- var IEBinaryToArray_ByteStr_Script = '\x3c!-- IEBinaryToArray_ByteStr --\x3e\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n IEBinaryToArray_ByteStr \x3d CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n Dim lastIndex\r\n lastIndex \x3d LenB(Binary)\r\n if lastIndex mod 2 Then\r\n IEBinaryToArray_ByteStr_Last \x3d Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n Else\r\n IEBinaryToArray_ByteStr_Last \x3d ""\r\n End If\r\nEnd Function\r\n',
- myVBScript = cc.newElement("script");
- myVBScript.type = "text/vbscript";
- myVBScript.textContent = IEBinaryToArray_ByteStr_Script;
- document.body.appendChild(myVBScript);
- cc._convertResponseBodyToText = function(a) {
- for (var c = {}, d = 0; 256 > d; d++)
- for (var e = 0; 256 > e; e++) c[String.fromCharCode(d + 256 * e)] = String.fromCharCode(d) + String.fromCharCode(e);
- d = IEBinaryToArray_ByteStr(a);
- a = IEBinaryToArray_ByteStr_Last(a);
- return d.replace(/[\s\S]/g, function(a) {
- return c[a]
- }) + a
- }
- };
- ClassManager = {
- id: 0 | 998 * Math.random(),
- instanceId: 0 | 998 * Math.random(),
- compileSuper: function(a, c, d) {
- a = a.toString();
- var e = a.indexOf("("),
- f = a.indexOf(")"),
- e = a.substring(e + 1, f),
- e = e.trim(),
- f = a.indexOf("{"),
- g = a.lastIndexOf("}");
- for (a = a.substring(f + 1, g); - 1 != a.indexOf("this._super");) {
- var f = a.indexOf("this._super"),
- g = a.indexOf("(", f),
- h = a.indexOf(")", g),
- h = a.substring(g + 1, h),
- h = (h = h.trim()) ? "," : "";
- a = a.substring(0, f) + "ClassManager[" + d + "]." + c + ".call(this" + h + a.substring(g + 1)
- }
- return Function(e, a)
- },
- getNewID: function() {
- return this.id++
- },
- getNewInstanceId: function() {
- return this.instanceId++
- }
- };
- ClassManager.compileSuper.ClassManager = ClassManager;
- (function() {
- var a = /\b_super\b/,
- c = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];
- c;
- cc.Class = function() {};
- cc.Class.extend = function(d) {
- function e() {
- this.__instanceId = ClassManager.getNewInstanceId();
- this.ctor && this.ctor.apply(this, arguments)
- }
- var f = this.prototype,
- g = Object.create(f),
- h = ClassManager.getNewID();
- ClassManager[h] = f;
- var k = {
- writable: !0,
- enumerable: !1,
- configurable: !0
- };
- g.__instanceId = null;
- e.id = h;
- k.value = h;
- Object.defineProperty(g, "__pid", k);
- e.prototype = g;
- k.value = e;
- Object.defineProperty(e.prototype, "constructor", k);
- this.__getters__ && (e.__getters__ = cc.clone(this.__getters__));
- this.__setters__ && (e.__setters__ = cc.clone(this.__setters__));
- for (var m = 0, n = arguments.length; m < n; ++m) {
- var q = arguments[m],
- r;
- for (r in q) {
- var t = "function" === typeof q[r],
- s = "function" === typeof f[r],
- v = a.test(q[r]);
- c && t && s && v ? (k.value = ClassManager.compileSuper(q[r], r, h), Object.defineProperty(g, r, k)) : t && s && v ? (k.value = function(a, c) {
- return function() {
- var d = this._super;
- this._super = f[a];
- var e = c.apply(this, arguments);
- this._super = d;
- return e
- }
- }(r, q[r]), Object.defineProperty(g, r, k)) : t ? (k.value = q[r], Object.defineProperty(g, r, k)) : g[r] = q[r];
- if (t) {
- var u, x;
- if (this.__getters__ && this.__getters__[r]) {
- var t = this.__getters__[r],
- A;
- for (A in this.__setters__)
- if (this.__setters__[A] == t) {
- x = A;
- break
- }
- cc.defineGetterSetter(g, t, q[r], q[x] ? q[x] : g[x], r, x)
- }
- if (this.__setters__ && this.__setters__[r]) {
- t = this.__setters__[r];
- for (A in this.__getters__)
- if (this.__getters__[A] == t) {
- u = A;
- break
- }
- cc.defineGetterSetter(g, t, q[u] ? q[u] : g[u], q[r], u, r)
- }
- }
- }
- }
- e.extend = cc.Class.extend;
- e.implement = function(a) {
- for (var c in a) g[c] = a[c]
- };
- return e
- }
- })();
- cc.defineGetterSetter = function(a, c, d, e, f, g) {
- if (a.__defineGetter__) d && a.__defineGetter__(c, d), e && a.__defineSetter__(c, e);
- else if (Object.defineProperty) {
- var h = {
- enumerable: !1,
- configurable: !0
- };
- d && (h.get = d);
- e && (h.set = e);
- Object.defineProperty(a, c, h)
- } else throw Error("browser does not support getters"); if (!f && !g)
- for (var h = null != d, k = void 0 != e, m = Object.getOwnPropertyNames(a), n = 0; n < m.length; n++) {
- var q = m[n];
- if (!((a.__lookupGetter__ ? a.__lookupGetter__(q) : Object.getOwnPropertyDescriptor(a, q)) || "function" !== typeof a[q])) {
- var r = a[q];
- if (h && r === d && (f = q, !k || g)) break;
- if (k && r === e && (g = q, !h || f)) break
- }
- }
- a = a.constructor;
- f && (a.__getters__ || (a.__getters__ = {}), a.__getters__[f] = c);
- g && (a.__setters__ || (a.__setters__ = {}), a.__setters__[g] = c)
- };
- cc.clone = function(a) {
- var c = a.constructor ? new a.constructor : {},
- d;
- for (d in a) {
- var e = a[d];
- c[d] = "object" == typeof e && e && !(e instanceof cc.Node) && !(e instanceof HTMLElement) ? cc.clone(e) : e
- }
- return c
- };
- cc = cc || {};
- cc._tmp = cc._tmp || {};
- cc.associateWithNative = function(a, c) {};
- cc.KEY = {
- backspace: 8,
- tab: 9,
- enter: 13,
- shift: 16,
- ctrl: 17,
- alt: 18,
- pause: 19,
- capslock: 20,
- escape: 27,
- pageup: 33,
- pagedown: 34,
- end: 35,
- home: 36,
- left: 37,
- up: 38,
- right: 39,
- down: 40,
- insert: 45,
- Delete: 46,
- "0": 48,
- 1: 49,
- 2: 50,
- 3: 51,
- 4: 52,
- 5: 53,
- 6: 54,
- 7: 55,
- 8: 56,
- 9: 57,
- a: 65,
- b: 66,
- c: 67,
- d: 68,
- e: 69,
- f: 70,
- g: 71,
- h: 72,
- i: 73,
- j: 74,
- k: 75,
- l: 76,
- m: 77,
- n: 78,
- o: 79,
- p: 80,
- q: 81,
- r: 82,
- s: 83,
- t: 84,
- u: 85,
- v: 86,
- w: 87,
- x: 88,
- y: 89,
- z: 90,
- num0: 96,
- num1: 97,
- num2: 98,
- num3: 99,
- num4: 100,
- num5: 101,
- num6: 102,
- num7: 103,
- num8: 104,
- num9: 105,
- "*": 106,
- "+": 107,
- "-": 109,
- numdel: 110,
- "/": 111,
- f1: 112,
- f2: 113,
- f3: 114,
- f4: 115,
- f5: 116,
- f6: 117,
- f7: 118,
- f8: 119,
- f9: 120,
- f10: 121,
- f11: 122,
- f12: 123,
- numlock: 144,
- scrolllock: 145,
- semicolon: 186,
- ",": 186,
- equal: 187,
- "\x3d": 187,
- ";": 188,
- comma: 188,
- dash: 189,
- ".": 190,
- period: 190,
- forwardslash: 191,
- grave: 192,
- "[": 219,
- openbracket: 219,
- "]": 221,
- closebracket: 221,
- backslash: 220,
- quote: 222,
- space: 32
- };
- cc.FMT_JPG = 0;
- cc.FMT_PNG = 1;
- cc.FMT_TIFF = 2;
- cc.FMT_RAWDATA = 3;
- cc.FMT_WEBP = 4;
- cc.FMT_UNKNOWN = 5;
- cc.getImageFormatByData = function(a) {
- return 8 < a.length && 137 == a[0] && 80 == a[1] && 78 == a[2] && 71 == a[3] && 13 == a[4] && 10 == a[5] && 26 == a[6] && 10 == a[7] ? cc.FMT_PNG : 2 < a.length && (73 == a[0] && 73 == a[1] || 77 == a[0] && 77 == a[1] || 255 == a[0] && 216 == a[1]) ? cc.FMT_TIFF : cc.FMT_UNKNOWN
- };
- cc.inherits = function(a, c) {
- function d() {}
- d.prototype = c.prototype;
- a.superClass_ = c.prototype;
- a.prototype = new d;
- a.prototype.constructor = a
- };
- cc.base = function(a, c, d) {
- var e = arguments.callee.caller;
- if (e.superClass_) return ret = e.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1));
- for (var f = Array.prototype.slice.call(arguments, 2), g = !1, h = a.constructor; h; h = h.superClass_ && h.superClass_.constructor)
- if (h.prototype[c] === e) g = !0;
- else if (g) return h.prototype[c].apply(a, f);
- if (a[c] === e) return a.constructor.prototype[c].apply(a, f);
- throw Error("cc.base called from a method of one name to a method of a different name");
- };
- cc.Point = function(a, c) {
- this.x = a || 0;
- this.y = c || 0
- };
- cc.p = function(a, c) {
- return void 0 == a ? {
- x: 0,
- y: 0
- } : void 0 == c ? {
- x: a.x,
- y: a.y
- } : {
- x: a,
- y: c
- }
- };
- cc.pointEqualToPoint = function(a, c) {
- return a && c && a.x === c.x && a.y === c.y
- };
- cc.Size = function(a, c) {
- this.width = a || 0;
- this.height = c || 0
- };
- cc.size = function(a, c) {
- return void 0 === a ? {
- width: 0,
- height: 0
- } : void 0 === c ? {
- width: a.width,
- height: a.height
- } : {
- width: a,
- height: c
- }
- };
- cc.sizeEqualToSize = function(a, c) {
- return a && c && a.width == c.width && a.height == c.height
- };
- cc.Rect = function(a, c, d, e) {
- this.x = a || 0;
- this.y = c || 0;
- this.width = d || 0;
- this.height = e || 0
- };
- cc.rect = function(a, c, d, e) {
- return void 0 === a ? {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- } : void 0 === c ? {
- x: a.x,
- y: a.y,
- width: a.width,
- height: a.height
- } : {
- x: a,
- y: c,
- width: d,
- height: e
- }
- };
- cc.rectEqualToRect = function(a, c) {
- return a && c && a.x === c.x && a.y === c.y && a.width === c.width && a.height === c.height
- };
- cc._rectEqualToZero = function(a) {
- return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height
- };
- cc.rectContainsRect = function(a, c) {
- return !a || !c ? !1 : !(a.x >= c.x || a.y >= c.y || a.x + a.width <= c.x + c.width || a.y + a.height <= c.y + c.height)
- };
- cc.rectGetMaxX = function(a) {
- return a.x + a.width
- };
- cc.rectGetMidX = function(a) {
- return a.x + a.width / 2
- };
- cc.rectGetMinX = function(a) {
- return a.x
- };
- cc.rectGetMaxY = function(a) {
- return a.y + a.height
- };
- cc.rectGetMidY = function(a) {
- return a.y + a.height / 2
- };
- cc.rectGetMinY = function(a) {
- return a.y
- };
- cc.rectContainsPoint = function(a, c) {
- return c.x >= cc.rectGetMinX(a) && c.x <= cc.rectGetMaxX(a) && c.y >= cc.rectGetMinY(a) && c.y <= cc.rectGetMaxY(a)
- };
- cc.rectIntersectsRect = function(a, c) {
- var d = a.y + a.height,
- e = c.x + c.width,
- f = c.y + c.height;
- return !(a.x + a.width < c.x || e < a.x || d < c.y || f < a.y)
- };
- cc.rectOverlapsRect = function(a, c) {
- return !(a.x + a.width < c.x || c.x + c.width < a.x || a.y + a.height < c.y || c.y + c.height < a.y)
- };
- cc.rectUnion = function(a, c) {
- var d = cc.rect(0, 0, 0, 0);
- d.x = Math.min(a.x, c.x);
- d.y = Math.min(a.y, c.y);
- d.width = Math.max(a.x + a.width, c.x + c.width) - d.x;
- d.height = Math.max(a.y + a.height, c.y + c.height) - d.y;
- return d
- };
- cc.rectIntersection = function(a, c) {
- var d = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(c)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(c)), 0, 0);
- d.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(c)) - cc.rectGetMinX(d);
- d.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(c)) - cc.rectGetMinY(d);
- return d
- };
- cc.SAXParser = cc.Class.extend({
- _parser: null,
- _isSupportDOMParser: null,
- ctor: function() {
- window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1
- },
- parse: function(a) {
- return this._parseXML(a)
- },
- _parseXML: function(a) {
- var c;
- this._isSupportDOMParser ? c = this._parser.parseFromString(a, "text/xml") : (c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(a));
- return c
- }
- });
- cc.PlistParser = cc.SAXParser.extend({
- parse: function(a) {
- a = this._parseXML(a).documentElement;
- if ("plist" != a.tagName) throw "Not a plist file!";
- for (var c = null, d = 0, e = a.childNodes.length; d < e && !(c = a.childNodes[d], 1 == c.nodeType); d++);
- return this._parseNode(c)
- },
- _parseNode: function(a) {
- var c = null,
- d = a.tagName;
- if ("dict" == d) c = this._parseDict(a);
- else if ("array" == d) c = this._parseArray(a);
- else if ("string" == d)
- if (1 == a.childNodes.length) c = a.firstChild.nodeValue;
- else {
- c = "";
- for (d = 0; d < a.childNodes.length; d++) c += a.childNodes[d].nodeValue
- } else "false" == d ? c = !1 : "true" == d ? c = !0 : "real" == d ? c = parseFloat(a.firstChild.nodeValue) : "integer" == d && (c = parseInt(a.firstChild.nodeValue, 10));
- return c
- },
- _parseArray: function(a) {
- for (var c = [], d = 0, e = a.childNodes.length; d < e; d++) {
- var f = a.childNodes[d];
- 1 == f.nodeType && c.push(this._parseNode(f))
- }
- return c
- },
- _parseDict: function(a) {
- for (var c = {}, d = null, e = 0, f = a.childNodes.length; e < f; e++) {
- var g = a.childNodes[e];
- 1 == g.nodeType && ("key" == g.tagName ? d = g.firstChild.nodeValue : c[d] = this._parseNode(g))
- }
- return c
- }
- });
- cc._txtLoader = {
- load: function(a, c, d, e) {
- cc.loader.loadTxt(a, e)
- }
- };
- cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader);
- cc._jsonLoader = {
- load: function(a, c, d, e) {
- cc.loader.loadJson(a, e)
- }
- };
- cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
- cc._imgLoader = {
- load: function(a, c, d, e) {
- cc.loader.cache[c] = cc.loader.loadImg(a, function(a, d) {
- if (a) return e(a);
- cc.textureCache.handleLoadedTexture(c);
- e(null, d)
- })
- }
- };
- cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader);
- cc._serverImgLoader = {
- load: function(a, c, d, e) {
- cc.loader.cache[c] = cc.loader.loadImg(d.src, function(a, d) {
- if (a) return e(a);
- cc.textureCache.handleLoadedTexture(c);
- e(null, d)
- })
- }
- };
- cc.loader.register(["serverImg"], cc._serverImgLoader);
- cc._plistLoader = {
- load: function(a, c, d, e) {
- cc.loader.loadTxt(a, function(a, c) {
- if (a) return e(a);
- e(null, cc.plistParser.parse(c))
- })
- }
- };
- cc.loader.register(["plist"], cc._plistLoader);
- cc._fontLoader = {
- TYPE: {
- ".eot": "embedded-opentype",
- ".ttf": "truetype",
- ".woff": "woff",
- ".svg": "svg"
- },
- _loadFont: function(a, c, d) {
- var e = document,
- f = cc.path,
- g = this.TYPE,
- h = cc.newElement("style");
- h.type = "text/css";
- e.body.appendChild(h);
- var k = "@font-face { font-family:" + a + "; src:";
- if (c instanceof Array)
- for (var m = 0, n = c.length; m < n; m++) d = f.extname(c[m]).toLowerCase(), k += "url('" + c[m] + "') format('" + g[d] + "')", k += m == n - 1 ? ";" : ",";
- else k += "url('" + c + "') format('" + g[d] + "');";
- h.textContent += k + "};";
- c = cc.newElement("div");
- d = c.style;
- d.fontFamily = a;
- c.innerHTML = ".";
- d.position = "absolute";
- d.left = "-100px";
- d.top = "-100px";
- e.body.appendChild(c)
- },
- load: function(a, c, d, e) {
- c = d.type;
- a = d.name;
- c = d.srcs;
- "string" == typeof d ? (c = cc.path.extname(d), a = cc.path.basename(d, c), this._loadFont(a, d, c)) : this._loadFont(a, c);
- e(null, !0)
- }
- };
- cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
- cc._binaryLoader = {
- load: function(a, c, d, e) {
- cc.loader.loadBinary(a, e)
- }
- };
- window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2";
- cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
- cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
- cc.DIRECTOR_FPS_INTERVAL = 0.5;
- cc.COCOSNODE_RENDER_SUBPIXEL = 1;
- cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
- cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
- cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
- cc.TEXTURE_ATLAS_USE_VAO = 0;
- cc.TEXTURE_NPOT_SUPPORT = 0;
- cc.RETINA_DISPLAY_SUPPORT = 1;
- cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
- cc.USE_LA88_LABELS = 1;
- cc.SPRITE_DEBUG_DRAW = 0;
- cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
- cc.LABELBMFONT_DEBUG_DRAW = 0;
- cc.LABELATLAS_DEBUG_DRAW = 0;
- cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
- cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
- cc.ENABLE_STACKABLE_ACTIONS = 1;
- cc.ENABLE_GL_STATE_CACHE = 1;
- cc.$ = function(a) {
- var c = this == cc ? document : this;
- if (a = a instanceof HTMLElement ? a : c.querySelector(a)) a.find = a.find || cc.$, a.hasClass = a.hasClass || function(a) {
- return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)"))
- }, a.addClass = a.addClass || function(a) {
- this.hasClass(a) || (this.className && (this.className += " "), this.className += a);
- return this
- }, a.removeClass = a.removeClass || function(a) {
- this.hasClass(a) && (this.className = this.className.replace(a, ""));
- return this
- }, a.remove = a.remove || function() {
- this.parentNode && this.parentNode.removeChild(this);
- return this
- }, a.appendTo = a.appendTo || function(a) {
- a.appendChild(this);
- return this
- }, a.prependTo = a.prependTo || function(a) {
- a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this);
- return this
- }, a.transforms = a.transforms || function() {
- this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew);
- return this
- }, a.position = a.position || {
- x: 0,
- y: 0
- }, a.rotation = a.rotation || 0, a.scale = a.scale || {
- x: 1,
- y: 1
- }, a.skew = a.skew || {
- x: 0,
- y: 0
- }, a.translates = function(a, c) {
- this.position.x = a;
- this.position.y = c;
- this.transforms();
- return this
- }, a.rotate = function(a) {
- this.rotation = a;
- this.transforms();
- return this
- }, a.resize = function(a, c) {
- this.scale.x = a;
- this.scale.y = c;
- this.transforms();
- return this
- }, a.setSkew = function(a, c) {
- this.skew.x = a;
- this.skew.y = c;
- this.transforms();
- return this
- };
- return a
- };
- switch (cc.sys.browserType) {
- case cc.sys.BROWSER_TYPE_FIREFOX:
- cc.$.pfx = "Moz";
- cc.$.hd = !0;
- break;
- case cc.sys.BROWSER_TYPE_CHROME:
- case cc.sys.BROWSER_TYPE_SAFARI:
- cc.$.pfx = "webkit";
- cc.$.hd = !0;
- break;
- case cc.sys.BROWSER_TYPE_OPERA:
- cc.$.pfx = "O";
- cc.$.hd = !1;
- break;
- case cc.sys.BROWSER_TYPE_IE:
- cc.$.pfx = "ms";
- cc.$.hd = !1;
- break;
- default:
- cc.$.pfx = "webkit", cc.$.hd = !0
- }
- cc.$.trans = cc.$.pfx + "Transform";
- cc.$.translate = cc.$.hd ? function(a) {
- return "translate3d(" + a.x + "px, " + a.y + "px, 0) "
- } : function(a) {
- return "translate(" + a.x + "px, " + a.y + "px) "
- };
- cc.$.rotate = cc.$.hd ? function(a) {
- return "rotateZ(" + a + "deg) "
- } : function(a) {
- return "rotate(" + a + "deg) "
- };
- cc.$.scale = function(a) {
- return "scale(" + a.x + ", " + a.y + ") "
- };
- cc.$.skew = function(a) {
- return "skewX(" + -a.x + "deg) skewY(" + a.y + "deg)"
- };
- cc.$new = function(a) {
- return cc.$(document.createElement(a))
- };
- cc.$.findpos = function(a) {
- var c = 0,
- d = 0;
- do c += a.offsetLeft, d += a.offsetTop; while (a = a.offsetParent);
- return {
- x: c,
- y: d
- }
- };
- cc.INVALID_INDEX = -1;
- cc.PI = Math.PI;
- cc.FLT_MAX = parseFloat("3.402823466e+38F");
- cc.FLT_MIN = parseFloat("1.175494351e-38F");
- cc.RAD = cc.PI / 180;
- cc.DEG = 180 / cc.PI;
- cc.UINT_MAX = 4294967295;
- cc.swap = function(a, c, d) {
- if ("object" == typeof d && "undefined" != typeof d.x && "undefined" != typeof d.y) {
- var e = d[a];
- d[a] = d[c];
- d[c] = e
- } else cc.log(cc._LogInfos.swap)
- };
- cc.lerp = function(a, c, d) {
- return a + (c - a) * d
- };
- cc.rand = function() {
- return 16777215 * Math.random()
- };
- cc.randomMinus1To1 = function() {
- return 2 * (Math.random() - 0.5)
- };
- cc.random0To1 = Math.random;
- cc.degreesToRadians = function(a) {
- return a * cc.RAD
- };
- cc.radiansToDegrees = function(a) {
- return a * cc.DEG
- };
- cc.radiansToDegress = function(a) {
- cc.log(cc._LogInfos.radiansToDegress);
- return a * cc.DEG
- };
- cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
- cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770;
- cc.BLEND_DST = 771;
- cc.nodeDrawSetup = function(a) {
- a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())
- };
- cc.enableDefaultGLStates = function() {};
- cc.disableDefaultGLStates = function() {};
- cc.incrementGLDraws = function(a) {
- cc.g_NumberOfDraws += a
- };
- cc.FLT_EPSILON = 1.192092896E-7;
- cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function() {
- return cc.director.getContentScaleFactor()
- } : function() {
- return 1
- };
- cc.pointPointsToPixels = function(a) {
- var c = cc.contentScaleFactor();
- return cc.p(a.x * c, a.y * c)
- };
- cc.pointPixelsToPoints = function(a) {
- var c = cc.contentScaleFactor();
- return cc.p(a.x / c, a.y / c)
- };
- cc._pointPixelsToPointsOut = function(a, c) {
- var d = cc.contentScaleFactor();
- c.x = a.x / d;
- c.y = a.y / d
- };
- cc.sizePointsToPixels = function(a) {
- var c = cc.contentScaleFactor();
- return cc.size(a.width * c, a.height * c)
- };
- cc.sizePixelsToPoints = function(a) {
- var c = cc.contentScaleFactor();
- return cc.size(a.width / c, a.height / c)
- };
- cc._sizePixelsToPointsOut = function(a, c) {
- var d = cc.contentScaleFactor();
- c.width = a.width / d;
- c.height = a.height / d
- };
- cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
- var c = cc.contentScaleFactor();
- return cc.rect(a.x / c, a.y / c, a.width / c, a.height / c)
- } : function(a) {
- return a
- };
- cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
- var c = cc.contentScaleFactor();
- return cc.rect(a.x * c, a.y * c, a.width * c, a.height * c)
- } : function(a) {
- return a
- };
- cc.ONE = 1;
- cc.ZERO = 0;
- cc.SRC_ALPHA = 770;
- cc.SRC_ALPHA_SATURATE = 776;
- cc.SRC_COLOR = 768;
- cc.DST_ALPHA = 772;
- cc.DST_COLOR = 774;
- cc.ONE_MINUS_SRC_ALPHA = 771;
- cc.ONE_MINUS_SRC_COLOR = 769;
- cc.ONE_MINUS_DST_ALPHA = 773;
- cc.DST_COLOR = 775;
- cc.ONE_MINUS_DST_COLOR = 775;
- cc.ONE_MINUS_CONSTANT_ALPHA = 32772;
- cc.ONE_MINUS_CONSTANT_COLOR = 32770;
- cc.checkGLErrorDebug = function() {
- if (cc.renderMode == cc._RENDER_TYPE_WEBGL) {
- var a = cc._renderContext.getError();
- a && cc.log(cc._LogInfos.checkGLErrorDebug, a)
- }
- };
- cc.DEVICE_ORIENTATION_PORTRAIT = 0;
- cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
- cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
- cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
- cc.DEVICE_MAX_ORIENTATIONS = 2;
- cc.VERTEX_ATTRIB_FLAG_NONE = 0;
- cc.VERTEX_ATTRIB_FLAG_POSITION = 1;
- cc.VERTEX_ATTRIB_FLAG_COLOR = 2;
- cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4;
- cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
- cc.GL_ALL = 0;
- cc.VERTEX_ATTRIB_POSITION = 0;
- cc.VERTEX_ATTRIB_COLOR = 1;
- cc.VERTEX_ATTRIB_TEX_COORDS = 2;
- cc.VERTEX_ATTRIB_MAX = 3;
- cc.UNIFORM_PMATRIX = 0;
- cc.UNIFORM_MVMATRIX = 1;
- cc.UNIFORM_MVPMATRIX = 2;
- cc.UNIFORM_TIME = 3;
- cc.UNIFORM_SINTIME = 4;
- cc.UNIFORM_COSTIME = 5;
- cc.UNIFORM_RANDOM01 = 6;
- cc.UNIFORM_SAMPLER = 7;
- cc.UNIFORM_MAX = 8;
- cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
- cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
- cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
- cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
- cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
- cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
- cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
- cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
- cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
- cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
- cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
- cc.UNIFORM_TIME_S = "CC_Time";
- cc.UNIFORM_SINTIME_S = "CC_SinTime";
- cc.UNIFORM_COSTIME_S = "CC_CosTime";
- cc.UNIFORM_RANDOM01_S = "CC_Random01";
- cc.UNIFORM_SAMPLER_S = "CC_Texture0";
- cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
- cc.ATTRIBUTE_NAME_COLOR = "a_color";
- cc.ATTRIBUTE_NAME_POSITION = "a_position";
- cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
- cc.ITEM_SIZE = 32;
- cc.CURRENT_ITEM = 3233828865;
- cc.ZOOM_ACTION_TAG = 3233828866;
- cc.NORMAL_TAG = 8801;
- cc.SELECTED_TAG = 8802;
- cc.DISABLE_TAG = 8803;
- cc = cc || {};
- cc._tmp = cc._tmp || {};
- cc._tmp.WebGLColor = function() {
- cc.color = function(a, d, e, f, g, h) {
- return void 0 === a ? new cc.Color(0, 0, 0, 255, g, h) : "string" === typeof a ? (a = cc.hexToColor(a), new cc.Color(a.r, a.g, a.b, a.a)) : "object" === typeof a ? new cc.Color(a.r, a.g, a.b, a.a, a.arrayBuffer, a.offset) : new cc.Color(a, d, e, f, g, h)
- };
- cc.Color = function(a, d, e, f, g, h) {
- this._arrayBuffer = g || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT);
- this._offset = h || 0;
- g = this._arrayBuffer;
- h = this._offset;
- var k = Uint8Array.BYTES_PER_ELEMENT;
- this._rU8 = new Uint8Array(g, h, 1);
- this._gU8 = new Uint8Array(g, h + k, 1);
- this._bU8 = new Uint8Array(g, h + 2 * k, 1);
- this._aU8 = new Uint8Array(g, h + 3 * k, 1);
- this._rU8[0] = a || 0;
- this._gU8[0] = d || 0;
- this._bU8[0] = e || 0;
- this._aU8[0] = f || 255;
- void 0 === f && (this.a_undefined = !0)
- };
- cc.Color.BYTES_PER_ELEMENT = 4;
- var a = cc.Color.prototype;
- a._getR = function() {
- return this._rU8[0]
- };
- a._setR = function(a) {
- this._rU8[0] = 0 > a ? 0 : a
- };
- a._getG = function() {
- return this._gU8[0]
- };
- a._setG = function(a) {
- this._gU8[0] = 0 > a ? 0 : a
- };
- a._getB = function() {
- return this._bU8[0]
- };
- a._setB = function(a) {
- this._bU8[0] = 0 > a ? 0 : a
- };
- a._getA = function() {
- return this._aU8[0]
- };
- a._setA = function(a) {
- this._aU8[0] = 0 > a ? 0 : a
- };
- cc.defineGetterSetter(a, "r", a._getR, a._setR);
- cc.defineGetterSetter(a, "g", a._getG, a._setG);
- cc.defineGetterSetter(a, "b", a._getB, a._setB);
- cc.defineGetterSetter(a, "a", a._getA, a._setA);
- cc.Vertex2F = function(a, d, e, f) {
- this._arrayBuffer = e || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
- this._offset = f || 0;
- this._xF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
- this._yF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
- this._xF32[0] = a || 0;
- this._yF32[0] = d || 0
- };
- cc.Vertex2F.BYTES_PER_ELEMENT = 8;
- Object.defineProperties(cc.Vertex2F.prototype, {
- x: {
- get: function() {
- return this._xF32[0]
- },
- set: function(a) {
- this._xF32[0] = a
- },
- enumerable: !0
- },
- y: {
- get: function() {
- return this._yF32[0]
- },
- set: function(a) {
- this._yF32[0] = a
- },
- enumerable: !0
- }
- });
- cc.Vertex3F = function(a, d, e, f, g) {
- this._arrayBuffer = f || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
- this._offset = g || 0;
- f = this._arrayBuffer;
- g = this._offset;
- this._xF32 = new Float32Array(f, g, 1);
- this._xF32[0] = a || 0;
- this._yF32 = new Float32Array(f, g + Float32Array.BYTES_PER_ELEMENT, 1);
- this._yF32[0] = d || 0;
- this._zF32 = new Float32Array(f, g + 2 * Float32Array.BYTES_PER_ELEMENT, 1);
- this._zF32[0] = e || 0
- };
- cc.Vertex3F.BYTES_PER_ELEMENT = 12;
- Object.defineProperties(cc.Vertex3F.prototype, {
- x: {
- get: function() {
- return this._xF32[0]
- },
- set: function(a) {
- this._xF32[0] = a
- },
- enumerable: !0
- },
- y: {
- get: function() {
- return this._yF32[0]
- },
- set: function(a) {
- this._yF32[0] = a
- },
- enumerable: !0
- },
- z: {
- get: function() {
- return this._zF32[0]
- },
- set: function(a) {
- this._zF32[0] = a
- },
- enumerable: !0
- }
- });
- cc.Tex2F = function(a, d, e, f) {
- this._arrayBuffer = e || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);
- this._offset = f || 0;
- this._uF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
- this._vF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
- this._uF32[0] = a || 0;
- this._vF32[0] = d || 0
- };
- cc.Tex2F.BYTES_PER_ELEMENT = 8;
- Object.defineProperties(cc.Tex2F.prototype, {
- u: {
- get: function() {
- return this._uF32[0]
- },
- set: function(a) {
- this._uF32[0] = a
- },
- enumerable: !0
- },
- v: {
- get: function() {
- return this._vF32[0]
- },
- set: function(a) {
- this._vF32[0] = a
- },
- enumerable: !0
- }
- });
- cc.Quad2 = function(a, d, e, f, g, h) {
- this._arrayBuffer = g || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);
- this._offset = h || 0;
- g = this._arrayBuffer;
- h = cc.Vertex2F.BYTES_PER_ELEMENT;
- this._tl = a ? new cc.Vertex2F(a.x, a.y, g, 0) : new cc.Vertex2F(0, 0, g, 0);
- this._tr = d ? new cc.Vertex2F(d.x, d.y, g, h) : new cc.Vertex2F(0, 0, g, h);
- this._bl = e ? new cc.Vertex2F(e.x, e.y, g, 2 * h) : new cc.Vertex2F(0, 0, g, 2 * h);
- this._br = f ? new cc.Vertex2F(f.x, f.y, g, 3 * h) : new cc.Vertex2F(0, 0, g, 3 * h)
- };
- cc.Quad2.BYTES_PER_ELEMENT = 32;
- cc.Quad3 = function(a, d, e, f) {
- this.bl = a || new cc.Vertex3F(0, 0, 0);
- this.br = d || new cc.Vertex3F(0, 0, 0);
- this.tl = e || new cc.Vertex3F(0, 0, 0);
- this.tr = f || new cc.Vertex3F(0, 0, 0)
- };
- Object.defineProperties(cc.Quad2.prototype, {
- tl: {
- get: function() {
- return this._tl
- },
- set: function(a) {
- this._tl.x = a.x;
- this._tl.y = a.y
- },
- enumerable: !0
- },
- tr: {
- get: function() {
- return this._tr
- },
- set: function(a) {
- this._tr.x = a.x;
- this._tr.y = a.y
- },
- enumerable: !0
- },
- bl: {
- get: function() {
- return this._bl
- },
- set: function(a) {
- this._bl.x = a.x;
- this._bl.y = a.y
- },
- enumerable: !0
- },
- br: {
- get: function() {
- return this._br
- },
- set: function(a) {
- this._br.x = a.x;
- this._br.y = a.y
- },
- enumerable: !0
- }
- });
- cc.V3F_C4B_T2F = function(a, d, e, f, g) {
- this._arrayBuffer = f || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
- this._offset = g || 0;
- f = this._arrayBuffer;
- g = this._offset;
- var h = cc.Vertex3F.BYTES_PER_ELEMENT;
- this._vertices = a ? new cc.Vertex3F(a.x, a.y, a.z, f, g) : new cc.Vertex3F(0, 0, 0, f, g);
- this._colors = d ? cc.color(d.r, d.g, d.b, d.a, f, g + h) : cc.color(0, 0, 0, 0, f, g + h);
- this._texCoords = e ? new cc.Tex2F(e.u, e.v, f, g + h + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, f, g + h + cc.Color.BYTES_PER_ELEMENT)
- };
- cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24;
- Object.defineProperties(cc.V3F_C4B_T2F.prototype, {
- vertices: {
- get: function() {
- return this._vertices
- },
- set: function(a) {
- var d = this._vertices;
- d.x = a.x;
- d.y = a.y;
- d.z = a.z
- },
- enumerable: !0
- },
- colors: {
- get: function() {
- return this._colors
- },
- set: function(a) {
- var d = this._colors;
- d.r = a.r;
- d.g = a.g;
- d.b = a.b;
- d.a = a.a
- },
- enumerable: !0
- },
- texCoords: {
- get: function() {
- return this._texCoords
- },
- set: function(a) {
- this._texCoords.u = a.u;
- this._texCoords.v = a.v
- },
- enumerable: !0
- }
- });
- cc.V3F_C4B_T2F_Quad = function(a, d, e, f, g, h) {
- this._arrayBuffer = g || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
- this._offset = h || 0;
- g = this._arrayBuffer;
- h = this._offset;
- var k = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;
- this._tl = a ? new cc.V3F_C4B_T2F(a.vertices, a.colors, a.texCoords, g, h) : new cc.V3F_C4B_T2F(null, null, null, g, h);
- this._bl = d ? new cc.V3F_C4B_T2F(d.vertices, d.colors, d.texCoords, g, h + k) : new cc.V3F_C4B_T2F(null, null, null, g, h + k);
- this._tr = e ? new cc.V3F_C4B_T2F(e.vertices, e.colors, e.texCoords, g, h + 2 * k) : new cc.V3F_C4B_T2F(null, null, null, g, h + 2 * k);
- this._br = f ? new cc.V3F_C4B_T2F(f.vertices, f.colors, f.texCoords, g, h + 3 * k) : new cc.V3F_C4B_T2F(null, null, null, g, h + 3 * k)
- };
- cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96;
- Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype, {
- tl: {
- get: function() {
- return this._tl
- },
- set: function(a) {
- var d = this._tl;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- bl: {
- get: function() {
- return this._bl
- },
- set: function(a) {
- var d = this._bl;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- tr: {
- get: function() {
- return this._tr
- },
- set: function(a) {
- var d = this._tr;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- br: {
- get: function() {
- return this._br
- },
- set: function(a) {
- var d = this._br;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- arrayBuffer: {
- get: function() {
- return this._arrayBuffer
- },
- enumerable: !0
- }
- });
- cc.V3F_C4B_T2F_QuadZero = function() {
- return new cc.V3F_C4B_T2F_Quad
- };
- cc.V3F_C4B_T2F_QuadCopy = function(a) {
- if (!a) return cc.V3F_C4B_T2F_QuadZero();
- var d = a.tl,
- e = a.bl,
- f = a.tr;
- a = a.br;
- return {
- tl: {
- vertices: {
- x: d.vertices.x,
- y: d.vertices.y,
- z: d.vertices.z
- },
- colors: {
- r: d.colors.r,
- g: d.colors.g,
- b: d.colors.b,
- a: d.colors.a
- },
- texCoords: {
- u: d.texCoords.u,
- v: d.texCoords.v
- }
- },
- bl: {
- vertices: {
- x: e.vertices.x,
- y: e.vertices.y,
- z: e.vertices.z
- },
- colors: {
- r: e.colors.r,
- g: e.colors.g,
- b: e.colors.b,
- a: e.colors.a
- },
- texCoords: {
- u: e.texCoords.u,
- v: e.texCoords.v
- }
- },
- tr: {
- vertices: {
- x: f.vertices.x,
- y: f.vertices.y,
- z: f.vertices.z
- },
- colors: {
- r: f.colors.r,
- g: f.colors.g,
- b: f.colors.b,
- a: f.colors.a
- },
- texCoords: {
- u: f.texCoords.u,
- v: f.texCoords.v
- }
- },
- br: {
- vertices: {
- x: a.vertices.x,
- y: a.vertices.y,
- z: a.vertices.z
- },
- colors: {
- r: a.colors.r,
- g: a.colors.g,
- b: a.colors.b,
- a: a.colors.a
- },
- texCoords: {
- u: a.texCoords.u,
- v: a.texCoords.v
- }
- }
- }
- };
- cc.V3F_C4B_T2F_QuadsCopy = function(a) {
- if (!a) return [];
- for (var d = [], e = 0; e < a.length; e++) d.push(cc.V3F_C4B_T2F_QuadCopy(a[e]));
- return d
- };
- cc.V2F_C4B_T2F = function(a, d, e, f, g) {
- this._arrayBuffer = f || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);
- this._offset = g || 0;
- f = this._arrayBuffer;
- g = this._offset;
- var h = cc.Vertex2F.BYTES_PER_ELEMENT;
- this._vertices = a ? new cc.Vertex2F(a.x, a.y, f, g) : new cc.Vertex2F(0, 0, f, g);
- this._colors = d ? cc.color(d.r, d.g, d.b, d.a, f, g + h) : cc.color(0, 0, 0, 0, f, g + h);
- this._texCoords = e ? new cc.Tex2F(e.u, e.v, f, g + h + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, f, g + h + cc.Color.BYTES_PER_ELEMENT)
- };
- cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20;
- Object.defineProperties(cc.V2F_C4B_T2F.prototype, {
- vertices: {
- get: function() {
- return this._vertices
- },
- set: function(a) {
- this._vertices.x = a.x;
- this._vertices.y = a.y
- },
- enumerable: !0
- },
- colors: {
- get: function() {
- return this._colors
- },
- set: function(a) {
- var d = this._colors;
- d.r = a.r;
- d.g = a.g;
- d.b = a.b;
- d.a = a.a
- },
- enumerable: !0
- },
- texCoords: {
- get: function() {
- return this._texCoords
- },
- set: function(a) {
- this._texCoords.u = a.u;
- this._texCoords.v = a.v
- },
- enumerable: !0
- }
- });
- cc.V2F_C4B_T2F_Triangle = function(a, d, e, f, g) {
- this._arrayBuffer = f || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);
- this._offset = g || 0;
- f = this._arrayBuffer;
- g = this._offset;
- var h = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- this._a = a ? new cc.V2F_C4B_T2F(a.vertices, a.colors, a.texCoords, f, g) : new cc.V2F_C4B_T2F(null, null, null, f, g);
- this._b = d ? new cc.V2F_C4B_T2F(d.vertices, d.colors, d.texCoords, f, g + h) : new cc.V2F_C4B_T2F(null, null, null, f, g + h);
- this._c = e ? new cc.V2F_C4B_T2F(e.vertices, e.colors, e.texCoords, f, g + 2 * h) : new cc.V2F_C4B_T2F(null, null, null, f, g + 2 * h)
- };
- cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60;
- Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype, {
- a: {
- get: function() {
- return this._a
- },
- set: function(a) {
- var d = this._a;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- b: {
- get: function() {
- return this._b
- },
- set: function(a) {
- var d = this._b;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- },
- c: {
- get: function() {
- return this._c
- },
- set: function(a) {
- var d = this._c;
- d.vertices = a.vertices;
- d.colors = a.colors;
- d.texCoords = a.texCoords
- },
- enumerable: !0
- }
- })
- };
- cc._tmp.PrototypeColor = function() {
- var a = cc.color;
- a._getWhite = function() {
- return a(255, 255, 255)
- };
- a._getYellow = function() {
- return a(255, 255, 0)
- };
- a._getBlue = function() {
- return a(0, 0, 255)
- };
- a._getGreen = function() {
- return a(0, 255, 0)
- };
- a._getRed = function() {
- return a(255, 0, 0)
- };
- a._getMagenta = function() {
- return a(255, 0, 255)
- };
- a._getBlack = function() {
- return a(0, 0, 0)
- };
- a._getOrange = function() {
- return a(255, 127, 0)
- };
- a._getGray = function() {
- return a(166, 166, 166)
- };
- cc.defineGetterSetter(a, "WHITE", a._getWhite);
- cc.defineGetterSetter(a, "YELLOW", a._getYellow);
- cc.defineGetterSetter(a, "BLUE", a._getBlue);
- cc.defineGetterSetter(a, "GREEN", a._getGreen);
- cc.defineGetterSetter(a, "RED", a._getRed);
- cc.defineGetterSetter(a, "MAGENTA", a._getMagenta);
- cc.defineGetterSetter(a, "BLACK", a._getBlack);
- cc.defineGetterSetter(a, "ORANGE", a._getOrange);
- cc.defineGetterSetter(a, "GRAY", a._getGray);
- cc.BlendFunc._disable = function() {
- return new cc.BlendFunc(cc.ONE, cc.ZERO)
- };
- cc.BlendFunc._alphaPremultiplied = function() {
- return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA)
- };
- cc.BlendFunc._alphaNonPremultiplied = function() {
- return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA)
- };
- cc.BlendFunc._additive = function() {
- return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE)
- };
- cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable);
- cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied);
- cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied);
- cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive)
- };
- cc.Color = function(a, c, d, e) {
- this.r = a || 0;
- this.g = c || 0;
- this.b = d || 0;
- this.a = e || 255
- };
- cc.color = function(a, c, d, e) {
- return void 0 === a ? {
- r: 0,
- g: 0,
- b: 0,
- a: 255
- } : "string" === typeof a ? cc.hexToColor(a) : "object" === typeof a ? {
- r: a.r,
- g: a.g,
- b: a.b,
- a: a.a || 255
- } : {
- r: a,
- g: c,
- b: d,
- a: e || 255
- }
- };
- cc.colorEqual = function(a, c) {
- return a.r === c.r && a.g === c.g && a.b === c.b
- };
- cc.Acceleration = function(a, c, d, e) {
- this.x = a || 0;
- this.y = c || 0;
- this.z = d || 0;
- this.timestamp = e || 0
- };
- cc.Vertex2F = function(a, c) {
- this.x = a || 0;
- this.y = c || 0
- };
- cc.vertex2 = function(a, c) {
- return new cc.Vertex2F(a, c)
- };
- cc.Vertex3F = function(a, c, d) {
- this.x = a || 0;
- this.y = c || 0;
- this.z = d || 0
- };
- cc.vertex3 = function(a, c, d) {
- return new cc.Vertex3F(a, c, d)
- };
- cc.Tex2F = function(a, c) {
- this.u = a || 0;
- this.v = c || 0
- };
- cc.tex2 = function(a, c) {
- return new cc.Tex2F(a, c)
- };
- cc.BlendFunc = function(a, c) {
- this.src = a;
- this.dst = c
- };
- cc.blendFuncDisable = function() {
- return new cc.BlendFunc(cc.ONE, cc.ZERO)
- };
- cc.hexToColor = function(a) {
- a = a.replace(/^#?/, "0x");
- a = parseInt(a);
- return cc.color(a >> 16, (a >> 8) % 256, a % 256)
- };
- cc.colorToHex = function(a) {
- var c = a.r.toString(16),
- d = a.g.toString(16),
- e = a.b.toString(16);
- return "#" + (16 > a.r ? "0" + c : c) + (16 > a.g ? "0" + d : d) + (16 > a.b ? "0" + e : e)
- };
- cc.TEXT_ALIGNMENT_LEFT = 0;
- cc.TEXT_ALIGNMENT_CENTER = 1;
- cc.TEXT_ALIGNMENT_RIGHT = 2;
- cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
- cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
- cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
- cc._Dictionary = cc.Class.extend({
- _keyMapTb: null,
- _valueMapTb: null,
- __currId: 0,
- ctor: function() {
- this._keyMapTb = {};
- this._valueMapTb = {};
- this.__currId = 2 << (0 | 10 * Math.random())
- },
- __getKey: function() {
- this.__currId++;
- return "key_" + this.__currId
- },
- setObject: function(a, c) {
- if (null != c) {
- var d = this.__getKey();
- this._keyMapTb[d] = c;
- this._valueMapTb[d] = a
- }
- },
- objectForKey: function(a) {
- if (null == a) return null;
- var c = this._keyMapTb,
- d;
- for (d in c)
- if (c[d] === a) return this._valueMapTb[d];
- return null
- },
- valueForKey: function(a) {
- return this.objectForKey(a)
- },
- removeObjectForKey: function(a) {
- if (null != a) {
- var c = this._keyMapTb,
- d;
- for (d in c)
- if (c[d] === a) {
- delete this._valueMapTb[d];
- delete c[d];
- break
- }
- }
- },
- removeObjectsForKeys: function(a) {
- if (null != a)
- for (var c = 0; c < a.length; c++) this.removeObjectForKey(a[c])
- },
- allKeys: function() {
- var a = [],
- c = this._keyMapTb,
- d;
- for (d in c) a.push(c[d]);
- return a
- },
- removeAllObjects: function() {
- this._keyMapTb = {};
- this._valueMapTb = {}
- },
- count: function() {
- return this.allKeys().length
- }
- });
- cc.FontDefinition = function() {
- this.fontName = "Arial";
- this.fontSize = 12;
- this.textAlign = cc.TEXT_ALIGNMENT_CENTER;
- this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
- this.fillStyle = cc.color(255, 255, 255, 255);
- this.boundingHeight = this.boundingWidth = 0;
- this.strokeEnabled = !1;
- this.strokeStyle = cc.color(255, 255, 255, 255);
- this.lineWidth = 1;
- this.shadowEnabled = !1;
- this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0;
- this.shadowOpacity = 1
- };
- cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert("function" === typeof cc._tmp.WebGLColor, cc._LogInfos.MissingFile, "CCTypesWebGL.js"), cc._tmp.WebGLColor(), delete cc._tmp.WebGLColor);
- cc.assert("function" === typeof cc._tmp.PrototypeColor, cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js");
- cc._tmp.PrototypeColor();
- delete cc._tmp.PrototypeColor;
- cc.Touches = [];
- cc.TouchesIntergerDict = {};
- cc.EGLView = cc.Class.extend({
- _delegate: null,
- _frameSize: null,
- _designResolutionSize: null,
- _originalDesignResolutionSize: null,
- _viewPortRect: null,
- _visibleRect: null,
- _retinaEnabled: !1,
- _autoFullScreen: !0,
- _devicePixelRatio: 1,
- _viewName: "",
- _resizeCallback: null,
- _scaleX: 1,
- _originalScaleX: 1,
- _scaleY: 1,
- _originalScaleY: 1,
- _indexBitsUsed: 0,
- _maxTouches: 5,
- _resolutionPolicy: null,
- _rpExactFit: null,
- _rpShowAll: null,
- _rpNoBorder: null,
- _rpFixedHeight: null,
- _rpFixedWidth: null,
- _initialized: !1,
- _captured: !1,
- _wnd: null,
- _hDC: null,
- _hRC: null,
- _supportTouch: !1,
- _contentTranslateLeftTop: null,
- _frame: null,
- _frameZoomFactor: 1,
- __resizeWithBrowserSize: !1,
- _isAdjustViewPort: !0,
- ctor: function() {
- var a = document,
- c = cc.ContainerStrategy,
- d = cc.ContentStrategy;
- this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode;
- this._frameSize = cc.size(0, 0);
- this._initFrameSize();
- var a = cc._canvas.width,
- e = cc._canvas.height;
- this._designResolutionSize = cc.size(a, e);
- this._originalDesignResolutionSize = cc.size(a, e);
- this._viewPortRect = cc.rect(0, 0, a, e);
- this._visibleRect = cc.rect(0, 0, a, e);
- this._contentTranslateLeftTop = {
- left: 0,
- top: 0
- };
- this._viewName = "Cocos2dHTML5";
- a = cc.sys;
- this.enableRetina(a.os == a.OS_IOS || a.os == a.OS_OSX);
- cc.visibleRect && cc.visibleRect.init(this._visibleRect);
- this._rpExactFit = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.EXACT_FIT);
- this._rpShowAll = new cc.ResolutionPolicy(c.PROPORTION_TO_FRAME, d.SHOW_ALL);
- this._rpNoBorder = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.NO_BORDER);
- this._rpFixedHeight = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.FIXED_HEIGHT);
- this._rpFixedWidth = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.FIXED_WIDTH);
- this._hDC = cc._canvas;
- this._hRC = cc._renderContext
- },
- _resizeEvent: function() {
- var a = this._originalDesignResolutionSize.width,
- c = this._originalDesignResolutionSize.height;
- this._resizeCallback && (this._initFrameSize(), this._resizeCallback.call());
- 0 < a && this.setDesignResolutionSize(a, c, this._resolutionPolicy)
- },
- resizeWithBrowserSize: function(a) {
- a ? this.__resizeWithBrowserSize || (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this), cc._addEventListener(window, "resize", a, !1)) : this.__resizeWithBrowserSize && (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this), window.removeEventListener("resize", a, !1))
- },
- setResizeCallback: function(a) {
- if ("function" == typeof a || null == a) this._resizeCallback = a
- },
- _initFrameSize: function() {
- var a = this._frameSize;
- a.width = this._frame.clientWidth;
- a.height = this._frame.clientHeight
- },
- _adjustSizeKeepCanvasSize: function() {
- var a = this._originalDesignResolutionSize.width,
- c = this._originalDesignResolutionSize.height;
- 0 < a && this.setDesignResolutionSize(a, c, this._resolutionPolicy)
- },
- _setViewPortMeta: function(a, c) {
- if (this._isAdjustViewPort) {
- var d = {
- "user-scalable": "no",
- "maximum-scale": "1.0",
- "initial-scale": "1.0"
- },
- e = document.getElementsByName("viewport"),
- f;
- 0 == e.length ? (e = cc.newElement("meta"), e.name = "viewport", e.content = "", document.head.appendChild(e)) : e = e[0];
- if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) e.content = "initial-scale:1";
- else {
- f = e.content;
- for (var g in d) RegExp(g).test(f) || (f += ("" == f ? "" : ",") + g + "\x3d" + d[g]);
- e.content = f
- }
- }
- },
- _setScaleXYForRenderTexture: function() {
- var a = cc.contentScaleFactor();
- this._scaleY = this._scaleX = a
- },
- _resetScale: function() {
- this._scaleX = this._originalScaleX;
- this._scaleY = this._originalScaleY
- },
- _adjustSizeToBrowser: function() {},
- initialize: function() {
- this._initialized = !0
- },
- adjustViewPort: function(a) {
- this._isAdjustViewPort = a
- },
- enableRetina: function(a) {
- this._retinaEnabled = a ? !0 : !1
- },
- isRetinaEnabled: function() {
- return this._retinaEnabled
- },
- enableAutoFullScreen: function(a) {
- this._autoFullScreen = a ? !0 : !1
- },
- isAutoFullScreenEnabled: function() {
- return this._autoFullScreen
- },
- end: function() {},
- isOpenGLReady: function() {
- return null != this._hDC && null != this._hRC
- },
- setFrameZoomFactor: function(a) {
- this._frameZoomFactor = a;
- this.centerWindow();
- cc.director.setProjection(cc.director.getProjection())
- },
- swapBuffers: function() {},
- setIMEKeyboardState: function(a) {},
- setContentTranslateLeftTop: function(a, c) {
- this._contentTranslateLeftTop = {
- left: a,
- top: c
- }
- },
- getContentTranslateLeftTop: function() {
- return this._contentTranslateLeftTop
- },
- getFrameSize: function() {
- return cc.size(this._frameSize.width, this._frameSize.height)
- },
- setFrameSize: function(a, c) {
- this._frameSize.width = a;
- this._frameSize.height = c;
- this._frame.style.width = a + "px";
- this._frame.style.height = c + "px";
- this._resizeEvent();
- cc.director.setProjection(cc.director.getProjection())
- },
- centerWindow: function() {},
- getVisibleSize: function() {
- return cc.size(this._visibleRect.width, this._visibleRect.height)
- },
- getVisibleOrigin: function() {
- return cc.p(this._visibleRect.x, this._visibleRect.y)
- },
- canSetContentScaleFactor: function() {
- return !0
- },
- getResolutionPolicy: function() {
- return this._resolutionPolicy
- },
- setResolutionPolicy: function(a) {
- if (a instanceof cc.ResolutionPolicy) this._resolutionPolicy = a;
- else {
- var c = cc.ResolutionPolicy;
- a === c.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit);
- a === c.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll);
- a === c.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder);
- a === c.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight);
- a === c.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth)
- }
- },
- setDesignResolutionSize: function(a, c, d) {
- if (isNaN(a) || 0 == a || isNaN(c) || 0 == c) cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);
- else {
- this.setResolutionPolicy(d);
- var e = this._resolutionPolicy;
- if (e) {
- e.preApply(this);
- var f = this._frameSize.width,
- g = this._frameSize.height;
- cc.sys.isMobile && this._setViewPortMeta(this._frameSize.width, this._frameSize.height);
- this._initFrameSize();
- d == this._resolutionPolicy && a == this._originalDesignResolutionSize.width && c == this._originalDesignResolutionSize.height && f == this._frameSize.width && g == this._frameSize.height || (this._designResolutionSize = cc.size(a, c), this._originalDesignResolutionSize = cc.size(a, c), a = e.apply(this, this._designResolutionSize), a.scale && 2 == a.scale.length && (this._scaleX = a.scale[0], this._scaleY = a.scale[1]), a.viewport && (a = this._viewPortRect = a.viewport, c = this._visibleRect, c.width = cc._canvas.width / this._scaleX, c.height = cc._canvas.height / this._scaleY, c.x = -a.x / this._scaleX, c.y = -a.y / this._scaleY), a = cc.director, cc.winSize.width = a._winSizeInPoints.width = this._visibleRect.width, cc.winSize.height = a._winSizeInPoints.height = this._visibleRect.height, e.postApply(this), cc._renderType == cc._RENDER_TYPE_WEBGL && (a._createStatsLabel(), a.setGLDefaultValues()), this._originalScaleX = this._scaleX, this._originalScaleY = this._scaleY, cc.DOM && cc.DOM._resetEGLViewDiv(), cc.visibleRect && cc.visibleRect.init(this._visibleRect))
- } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2)
- }
- },
- getDesignResolutionSize: function() {
- return cc.size(this._designResolutionSize.width, this._designResolutionSize.height)
- },
- setViewPortInPoints: function(a, c, d, e) {
- var f = this._frameZoomFactor,
- g = this._scaleX,
- h = this._scaleY;
- cc._renderContext.viewport(a * g * f + this._viewPortRect.x * f, c * h * f + this._viewPortRect.y * f, d * g * f, e * h * f)
- },
- setScissorInPoints: function(a, c, d, e) {
- var f = this._frameZoomFactor,
- g = this._scaleX,
- h = this._scaleY;
- cc._renderContext.scissor(a * g * f + this._viewPortRect.x * f, c * h * f + this._viewPortRect.y * f, d * g * f, e * h * f)
- },
- isScissorEnabled: function() {
- var a = cc._renderContext;
- return a.isEnabled(a.SCISSOR_TEST)
- },
- getScissorRect: function() {
- var a = cc._renderContext,
- c = this._scaleX,
- d = this._scaleY,
- a = a.getParameter(a.SCISSOR_BOX);
- return cc.rect((a[0] - this._viewPortRect.x) / c, (a[1] - this._viewPortRect.y) / d, a[2] / c, a[3] / d)
- },
- setViewName: function(a) {
- null != a && 0 < a.length && (this._viewName = a)
- },
- getViewName: function() {
- return this._viewName
- },
- getViewPortRect: function() {
- return this._viewPortRect
- },
- getScaleX: function() {
- return this._scaleX
- },
- getScaleY: function() {
- return this._scaleY
- },
- getDevicePixelRatio: function() {
- return this._devicePixelRatio
- },
- convertToLocationInView: function(a, c, d) {
- return {
- x: this._devicePixelRatio * (a - d.left),
- y: this._devicePixelRatio * (d.top + d.height - c)
- }
- },
- _convertMouseToLocationInView: function(a, c) {
- var d = this._viewPortRect;
- a.x = (this._devicePixelRatio * (a.x - c.left) - d.x) / this._scaleX;
- a.y = (this._devicePixelRatio * (c.top + c.height - a.y) - d.y) / this._scaleY
- },
- _convertTouchesWithScale: function(a) {
- for (var c = this._viewPortRect, d = this._scaleX, e = this._scaleY, f, g, h, k = 0; k < a.length; k++) f = a[k], g = f._point, h = f._prevPoint, f._setPoint((g.x - c.x) / d, (g.y - c.y) / e), f._setPrevPoint((h.x - c.x) / d, (h.y - c.y) / e)
- }
- });
- cc.EGLView._getInstance = function() {
- this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize());
- return this._instance
- };
- cc.ContainerStrategy = cc.Class.extend({
- preApply: function(a) {},
- apply: function(a, c) {},
- postApply: function(a) {},
- _setupContainer: function(a, c, d) {
- var e = a._frame;
- cc.view._autoFullScreen && (cc.sys.isMobile && e == document.documentElement) && cc.screen.autoFullScreen(e);
- var e = cc._canvas,
- f = cc.container;
- f.style.width = e.style.width = c + "px";
- f.style.height = e.style.height = d + "px";
- f = a._devicePixelRatio = 1;
- a.isRetinaEnabled() && (f = a._devicePixelRatio = window.devicePixelRatio || 1);
- e.width = c * f;
- e.height = d * f;
- a = document.body;
- var g;
- if (a && (g = a.style)) g.paddingTop = g.paddingTop || "0px", g.paddingRight = g.paddingRight || "0px", g.paddingBottom = g.paddingBottom || "0px", g.paddingLeft = g.paddingLeft || "0px", g.borderTop = g.borderTop || "0px", g.borderRight = g.borderRight || "0px", g.borderBottom = g.borderBottom || "0px", g.borderLeft = g.borderLeft || "0px", g.marginTop = g.marginTop || "0px", g.marginRight = g.marginRight || "0px", g.marginBottom = g.marginBottom || "0px", g.marginLeft = g.marginLeft || "0px"
- },
- _fixContainer: function() {
- document.body.insertBefore(cc.container, document.body.firstChild);
- var a = document.body.style;
- a.width = window.innerWidth + "px";
- a.height = window.innerHeight + "px";
- a.overflow = "hidden";
- a = cc.container.style;
- a.position = "fixed";
- a.left = a.top = "0px";
- document.body.scrollTop = 0
- }
- });
- cc.ContentStrategy = cc.Class.extend({
- _result: {
- scale: [1, 1],
- viewport: null
- },
- _buildResult: function(a, c, d, e, f, g) {
- 2 > Math.abs(a - d) && (d = a);
- 2 > Math.abs(c - e) && (e = c);
- a = cc.rect(Math.round((a - d) / 2), Math.round((c - e) / 2), d, e);
- cc._renderType == cc._RENDER_TYPE_CANVAS && cc._renderContext.translate(a.x, a.y + e);
- this._result.scale = [f, g];
- this._result.viewport = a;
- return this._result
- },
- preApply: function(a) {},
- apply: function(a, c) {
- return {
- scale: [1, 1]
- }
- },
- postApply: function(a) {}
- });
- (function() {
- var a = cc.ContainerStrategy.extend({
- apply: function(a) {
- this._setupContainer(a, a._frameSize.width, a._frameSize.height)
- }
- }),
- c = cc.ContainerStrategy.extend({
- apply: function(a, c) {
- var d = a._frameSize.width,
- e = a._frameSize.height,
- f = cc.container.style,
- q = c.width,
- r = c.height,
- t = d / q,
- s = e / r,
- v, u;
- t < s ? (v = d, u = r * t) : (v = q * s, u = e);
- q = Math.round((d - v) / 2);
- u = Math.round((e - u) / 2);
- this._setupContainer(a, d - 2 * q, e - 2 * u);
- f.marginLeft = q + "px";
- f.marginRight = q + "px";
- f.marginTop = u + "px";
- f.marginBottom = u + "px"
- }
- });
- a.extend({
- preApply: function(a) {
- this._super(a);
- a._frame = document.documentElement
- },
- apply: function(a) {
- this._super(a);
- this._fixContainer()
- }
- });
- c.extend({
- preApply: function(a) {
- this._super(a);
- a._frame = document.documentElement
- },
- apply: function(a, c) {
- this._super(a, c);
- this._fixContainer()
- }
- });
- var d = cc.ContainerStrategy.extend({
- apply: function(a) {
- this._setupContainer(a, cc._canvas.width, cc._canvas.height)
- }
- });
- cc.ContainerStrategy.EQUAL_TO_FRAME = new a;
- cc.ContainerStrategy.PROPORTION_TO_FRAME = new c;
- cc.ContainerStrategy.ORIGINAL_CONTAINER = new d;
- var a = cc.ContentStrategy.extend({
- apply: function(a, c) {
- var d = cc._canvas.width,
- e = cc._canvas.height;
- return this._buildResult(d, e, d, e, d / c.width, e / c.height)
- }
- }),
- c = cc.ContentStrategy.extend({
- apply: function(a, c) {
- var d = cc._canvas.width,
- e = cc._canvas.height,
- f = c.width,
- q = c.height,
- r = d / f,
- t = e / q,
- s = 0,
- v, u;
- r < t ? (s = r, v = d, u = q * s) : (s = t, v = f * s, u = e);
- return this._buildResult(d, e, v, u, s, s)
- }
- }),
- d = cc.ContentStrategy.extend({
- apply: function(a, c) {
- var d = cc._canvas.width,
- e = cc._canvas.height,
- f = c.width,
- q = c.height,
- r = d / f,
- t = e / q,
- s, v, u;
- r < t ? (s = t, v = f * s, u = e) : (s = r, v = d, u = q * s);
- return this._buildResult(d, e, v, u, s, s)
- }
- }),
- e = cc.ContentStrategy.extend({
- apply: function(a, c) {
- var d = cc._canvas.width,
- e = cc._canvas.height,
- f = e / c.height;
- return this._buildResult(d, e, d, e, f, f)
- },
- postApply: function(a) {
- cc.director._winSizeInPoints = a.getVisibleSize()
- }
- }),
- f = cc.ContentStrategy.extend({
- apply: function(a, c) {
- var d = cc._canvas.width,
- e = cc._canvas.height,
- f = d / c.width;
- return this._buildResult(d, e, d, e, f, f)
- },
- postApply: function(a) {
- cc.director._winSizeInPoints = a.getVisibleSize()
- }
- });
- cc.ContentStrategy.EXACT_FIT = new a;
- cc.ContentStrategy.SHOW_ALL = new c;
- cc.ContentStrategy.NO_BORDER = new d;
- cc.ContentStrategy.FIXED_HEIGHT = new e;
- cc.ContentStrategy.FIXED_WIDTH = new f
- })();
- cc.ResolutionPolicy = cc.Class.extend({
- _containerStrategy: null,
- _contentStrategy: null,
- ctor: function(a, c) {
- this.setContainerStrategy(a);
- this.setContentStrategy(c)
- },
- preApply: function(a) {
- this._containerStrategy.preApply(a);
- this._contentStrategy.preApply(a)
- },
- apply: function(a, c) {
- this._containerStrategy.apply(a, c);
- return this._contentStrategy.apply(a, c)
- },
- postApply: function(a) {
- this._containerStrategy.postApply(a);
- this._contentStrategy.postApply(a)
- },
- setContainerStrategy: function(a) {
- a instanceof cc.ContainerStrategy && (this._containerStrategy = a)
- },
- setContentStrategy: function(a) {
- a instanceof cc.ContentStrategy && (this._contentStrategy = a)
- }
- });
- cc.ResolutionPolicy.EXACT_FIT = 0;
- cc.ResolutionPolicy.NO_BORDER = 1;
- cc.ResolutionPolicy.SHOW_ALL = 2;
- cc.ResolutionPolicy.FIXED_HEIGHT = 3;
- cc.ResolutionPolicy.FIXED_WIDTH = 4;
- cc.ResolutionPolicy.UNKNOWN = 5;
- cc.screen = {
- _supportsFullScreen: !1,
- _preOnFullScreenChange: null,
- _touchEvent: "",
- _fn: null,
- _fnMap: [
- ["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement"],
- ["requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement"],
- ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"],
- ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement"],
- ["msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement"]
- ],
- init: function() {
- this._fn = {};
- var a, c, d = this._fnMap,
- e;
- a = 0;
- for (l = d.length; a < l; a++)
- if ((c = d[a]) && c[1] in document) {
- a = 0;
- for (e = c.length; a < e; a++) this._fn[d[0][a]] = c[a];
- break
- }
- this._supportsFullScreen = void 0 != this._fn.requestFullscreen;
- this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown"
- },
- fullScreen: function() {
- return this._supportsFullScreen && document[this._fn.fullscreenEnabled]
- },
- requestFullScreen: function(a, c) {
- if (this._supportsFullScreen) {
- a = a || document.documentElement;
- a[this._fn.requestFullscreen]();
- if (c) {
- var d = this._fn.fullscreenchange;
- this._preOnFullScreenChange && document.removeEventListener(d, this._preOnFullScreenChange);
- this._preOnFullScreenChange = c;
- cc._addEventListener(document, d, c, !1)
- }
- return a[this._fn.requestFullscreen]()
- }
- },
- exitFullScreen: function() {
- return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : !0
- },
- autoFullScreen: function(a, c) {
- function d() {
- f.requestFullScreen(a, c);
- e.removeEventListener(f._touchEvent, d)
- }
- a = a || document.body;
- var e = cc._canvas || a,
- f = this;
- this.requestFullScreen(a, c);
- cc._addEventListener(e, this._touchEvent, d)
- }
- };
- cc.screen.init();
- cc.visibleRect = {
- topLeft: cc.p(0, 0),
- topRight: cc.p(0, 0),
- top: cc.p(0, 0),
- bottomLeft: cc.p(0, 0),
- bottomRight: cc.p(0, 0),
- bottom: cc.p(0, 0),
- center: cc.p(0, 0),
- left: cc.p(0, 0),
- right: cc.p(0, 0),
- width: 0,
- height: 0,
- init: function(a) {
- var c = this.width = a.width,
- d = this.height = a.height,
- e = a.x;
- a = a.y;
- var f = a + d,
- g = e + c;
- this.topLeft.x = e;
- this.topLeft.y = f;
- this.topRight.x = g;
- this.topRight.y = f;
- this.top.x = e + c / 2;
- this.top.y = f;
- this.bottomLeft.x = e;
- this.bottomLeft.y = a;
- this.bottomRight.x = g;
- this.bottomRight.y = a;
- this.bottom.x = e + c / 2;
- this.bottom.y = a;
- this.center.x = e + c / 2;
- this.center.y = a + d / 2;
- this.left.x = e;
- this.left.y = a + d / 2;
- this.right.x = g;
- this.right.y = a + d / 2
- }
- };
- cc.UIInterfaceOrientationLandscapeLeft = -90;
- cc.UIInterfaceOrientationLandscapeRight = 90;
- cc.UIInterfaceOrientationPortraitUpsideDown = 180;
- cc.UIInterfaceOrientationPortrait = 0;
- cc.inputManager = {
- _mousePressed: !1,
- _isRegisterEvent: !1,
- _preTouchPoint: cc.p(0, 0),
- _prevMousePoint: cc.p(0, 0),
- _preTouchPool: [],
- _preTouchPoolPointer: 0,
- _touches: [],
- _touchesIntegerDict: {},
- _indexBitsUsed: 0,
- _maxTouches: 5,
- _accelEnabled: !1,
- _accelInterval: 1 / 30,
- _accelMinus: 1,
- _accelCurTime: 0,
- _acceleration: null,
- _accelDeviceEvent: null,
- _getUnUsedIndex: function() {
- for (var a = this._indexBitsUsed, c = 0; c < this._maxTouches; c++) {
- if (!(a & 1)) return this._indexBitsUsed |= 1 << c, c;
- a >>= 1
- }
- return -1
- },
- _removeUsedIndexBit: function(a) {
- 0 > a || a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a)
- },
- _glView: null,
- handleTouchesBegin: function(a) {
- for (var c, d, e, f = [], g = this._touchesIntegerDict, h = 0, k = a.length; h < k; h++) c = a[h], e = c.getID(), d = g[e], null == d && (d = this._getUnUsedIndex(), -1 == d ? cc.log(cc._LogInfos.inputManager_handleTouchesBegin, d) : (c = this._touches[d] = c, g[e] = d, f.push(c)));
- 0 < f.length && (this._glView._convertTouchesWithScale(f), a = new cc.EventTouch(f), a._eventCode = cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a))
- },
- handleTouchesMove: function(a) {
- for (var c, d, e = [], f = this._touches, g = 0, h = a.length; g < h; g++) c = a[g], d = c.getID(), d = this._touchesIntegerDict[d], null != d && f[d] && (f[d]._setPoint(c._point), f[d]._setPrevPoint(c._prevPoint), e.push(f[d]));
- 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a))
- },
- handleTouchesEnd: function(a) {
- a = this.getSetOfTouchesEndOrCancel(a);
- 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED, cc.eventManager.dispatchEvent(a))
- },
- handleTouchesCancel: function(a) {
- a = this.getSetOfTouchesEndOrCancel(a);
- 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a))
- },
- getSetOfTouchesEndOrCancel: function(a) {
- for (var c, d, e, f = [], g = this._touches, h = this._touchesIntegerDict, k = 0, m = a.length; k < m; k++) c = a[k], e = c.getID(), d = h[e], null != d && g[d] && (g[d]._setPoint(c._point), g[d]._setPrevPoint(c._prevPoint), f.push(g[d]), this._removeUsedIndexBit(d), delete h[e]);
- return f
- },
- getHTMLElementPosition: function(a) {
- var c = document.documentElement,
- d = window,
- e = null,
- e = "function" === typeof a.getBoundingClientRect ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? {
- left: 0,
- top: 0,
- width: a.width,
- height: a.height
- } : {
- left: 0,
- top: 0,
- width: parseInt(a.style.width),
- height: parseInt(a.style.height)
- };
- return {
- left: e.left + d.pageXOffset - c.clientLeft,
- top: e.top + d.pageYOffset - c.clientTop,
- width: e.width,
- height: e.height
- }
- },
- getPreTouch: function(a) {
- for (var c = null, d = this._preTouchPool, e = a.getId(), f = d.length - 1; 0 <= f; f--)
- if (d[f].getId() == e) {
- c = d[f];
- break
- }
- c || (c = a);
- return c
- },
- setPreTouch: function(a) {
- for (var c = !1, d = this._preTouchPool, e = a.getId(), f = d.length - 1; 0 <= f; f--)
- if (d[f].getId() == e) {
- d[f] = a;
- c = !0;
- break
- }
- c || (50 >= d.length ? d.push(a) : (d[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50))
- },
- getTouchByXY: function(a, c, d) {
- var e = this._preTouchPoint;
- a = this._glView.convertToLocationInView(a, c, d);
- c = new cc.Touch(a.x, a.y);
- c._setPrevPoint(e.x, e.y);
- e.x = a.x;
- e.y = a.y;
- return c
- },
- getMouseEvent: function(a, c, d) {
- var e = this._prevMousePoint;
- this._glView._convertMouseToLocationInView(a, c);
- c = new cc.EventMouse(d);
- c.setLocation(a.x, a.y);
- c._setPrevCursor(e.x, e.y);
- e.x = a.x;
- e.y = a.y;
- return c
- },
- getPointByEvent: function(a, c) {
- if (null != a.pageX) return {
- x: a.pageX,
- y: a.pageY
- };
- c.left -= document.body.scrollLeft;
- c.top -= document.body.scrollTop;
- return {
- x: a.clientX,
- y: a.clientY
- }
- },
- getTouchesByEvent: function(a, c) {
- for (var d = [], e = this._glView, f, g, h = this._preTouchPoint, k = a.changedTouches.length, m = 0; m < k; m++)
- if (f = a.changedTouches[m]) {
- var n;
- n = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? e.convertToLocationInView(f.pageX, f.pageY, c) : e.convertToLocationInView(f.clientX, f.clientY, c);
- null != f.identifier ? (f = new cc.Touch(n.x, n.y, f.identifier), g = this.getPreTouch(f).getLocation(), f._setPrevPoint(g.x, g.y), this.setPreTouch(f)) : (f = new cc.Touch(n.x, n.y), f._setPrevPoint(h.x, h.y));
- h.x = n.x;
- h.y = n.y;
- d.push(f)
- }
- return d
- },
- registerSystemEvent: function(a) {
- if (!this._isRegisterEvent) {
- var c = this._glView = cc.view,
- d = this,
- e = "touches" in cc.sys.capabilities;
- "mouse" in cc.sys.capabilities && (cc._addEventListener(window, "mousedown", function() {
- d._mousePressed = !0
- }, !1), cc._addEventListener(window, "mouseup", function(c) {
- var f = d._mousePressed;
- d._mousePressed = !1;
- if (f) {
- var f = d.getHTMLElementPosition(a),
- g = d.getPointByEvent(c, f);
- cc.rectContainsPoint(new cc.Rect(f.left, f.top, f.width, f.height), g) || (e || d.handleTouchesEnd([d.getTouchByXY(g.x, g.y, f)]), f = d.getMouseEvent(g, f, cc.EventMouse.UP), f.setButton(c.button), cc.eventManager.dispatchEvent(f))
- }
- }, !1), cc._addEventListener(a, "mousedown", function(c) {
- d._mousePressed = !0;
- var f = d.getHTMLElementPosition(a),
- g = d.getPointByEvent(c, f);
- e || d.handleTouchesBegin([d.getTouchByXY(g.x, g.y, f)]);
- f = d.getMouseEvent(g, f, cc.EventMouse.DOWN);
- f.setButton(c.button);
- cc.eventManager.dispatchEvent(f);
- c.stopPropagation();
- c.preventDefault();
- a.focus()
- }, !1), cc._addEventListener(a, "mouseup", function(c) {
- d._mousePressed = !1;
- var f = d.getHTMLElementPosition(a),
- g = d.getPointByEvent(c, f);
- e || d.handleTouchesEnd([d.getTouchByXY(g.x, g.y, f)]);
- f = d.getMouseEvent(g, f, cc.EventMouse.UP);
- f.setButton(c.button);
- cc.eventManager.dispatchEvent(f);
- c.stopPropagation();
- c.preventDefault()
- }, !1), cc._addEventListener(a, "mousemove", function(c) {
- var f = d.getHTMLElementPosition(a),
- g = d.getPointByEvent(c, f);
- e || d.handleTouchesMove([d.getTouchByXY(g.x, g.y, f)]);
- f = d.getMouseEvent(g, f, cc.EventMouse.MOVE);
- d._mousePressed ? f.setButton(c.button) : f.setButton(null);
- cc.eventManager.dispatchEvent(f);
- c.stopPropagation();
- c.preventDefault()
- }, !1), cc._addEventListener(a, "mousewheel", function(c) {
- var e = d.getHTMLElementPosition(a),
- f = d.getPointByEvent(c, e),
- e = d.getMouseEvent(f, e, cc.EventMouse.SCROLL);
- e.setButton(c.button);
- e.setScrollData(0, c.wheelDelta);
- cc.eventManager.dispatchEvent(e);
- c.stopPropagation();
- c.preventDefault()
- }, !1), cc._addEventListener(a, "DOMMouseScroll", function(c) {
- var e = d.getHTMLElementPosition(a),
- f = d.getPointByEvent(c, e),
- e = d.getMouseEvent(f, e, cc.EventMouse.SCROLL);
- e.setButton(c.button);
- e.setScrollData(0, -120 * c.detail);
- cc.eventManager.dispatchEvent(e);
- c.stopPropagation();
- c.preventDefault()
- }, !1));
- if (window.navigator.msPointerEnabled) {
- var f = {
- MSPointerDown: d.handleTouchesBegin,
- MSPointerMove: d.handleTouchesMove,
- MSPointerUp: d.handleTouchesEnd,
- MSPointerCancel: d.handleTouchesCancel
- },
- g;
- for (g in f)(function(c, e) {
- cc._addEventListener(a, c, function(c) {
- var f = d.getHTMLElementPosition(a);
- f.left -= document.documentElement.scrollLeft;
- f.top -= document.documentElement.scrollTop;
- e.call(d, [d.getTouchByXY(c.clientX, c.clientY, f)]);
- c.stopPropagation()
- }, !1)
- })(g, f[g])
- }
- e && (cc._addEventListener(a, "touchstart", function(c) {
- if (c.changedTouches) {
- var e = d.getHTMLElementPosition(a);
- e.left -= document.body.scrollLeft;
- e.top -= document.body.scrollTop;
- d.handleTouchesBegin(d.getTouchesByEvent(c, e));
- c.stopPropagation();
- c.preventDefault();
- a.focus()
- }
- }, !1), cc._addEventListener(a, "touchmove", function(c) {
- if (c.changedTouches) {
- var e = d.getHTMLElementPosition(a);
- e.left -= document.body.scrollLeft;
- e.top -= document.body.scrollTop;
- d.handleTouchesMove(d.getTouchesByEvent(c, e));
- c.stopPropagation();
- c.preventDefault()
- }
- }, !1), cc._addEventListener(a, "touchend", function(c) {
- if (c.changedTouches) {
- var e = d.getHTMLElementPosition(a);
- e.left -= document.body.scrollLeft;
- e.top -= document.body.scrollTop;
- d.handleTouchesEnd(d.getTouchesByEvent(c, e));
- c.stopPropagation();
- c.preventDefault()
- }
- }, !1), cc._addEventListener(a, "touchcancel", function(e) {
- if (e.changedTouches) {
- var f = d.getHTMLElementPosition(a);
- f.left -= document.body.scrollLeft;
- f.top -= document.body.scrollTop;
- c.handleTouchesCancel(d.getTouchesByEvent(e, f));
- e.stopPropagation();
- e.preventDefault()
- }
- }, !1));
- this._registerKeyboardEvent();
- this._registerAccelerometerEvent();
- this._isRegisterEvent = !0
- }
- },
- _registerKeyboardEvent: function() {},
- _registerAccelerometerEvent: function() {},
- update: function(a) {
- this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));
- this._accelCurTime += a
- }
- };
- var _p = cc.inputManager;
- _p.setAccelerometerEnabled = function(a) {
- this._accelEnabled !== a && (this._accelEnabled = a, a = cc.director.getScheduler(), this._accelEnabled ? (this._accelCurTime = 0, a.scheduleUpdateForTarget(this)) : (this._accelCurTime = 0, a.unscheduleUpdateForTarget(this)))
- };
- _p.setAccelerometerInterval = function(a) {
- this._accelInterval !== a && (this._accelInterval = a)
- };
- _p._registerKeyboardEvent = function() {
- cc._addEventListener(cc._canvas, "keydown", function(a) {
- cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !0));
- a.stopPropagation();
- a.preventDefault()
- }, !1);
- cc._addEventListener(cc._canvas, "keyup", function(a) {
- cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !1));
- a.stopPropagation();
- a.preventDefault()
- }, !1)
- };
- _p._registerAccelerometerEvent = function() {
- var a = window;
- this._acceleration = new cc.Acceleration;
- this._accelDeviceEvent = a.DeviceMotionEvent || a.DeviceOrientationEvent;
- cc.sys.browserType == cc.sys.BROWSER_TYPE_MOBILE_QQ && (this._accelDeviceEvent = window.DeviceOrientationEvent);
- var c = this._accelDeviceEvent == a.DeviceMotionEvent ? "devicemotion" : "deviceorientation",
- d = navigator.userAgent;
- if (/Android/.test(d) || /Adr/.test(d) && cc.sys.browserType == cc.BROWSER_TYPE_UC) this._minus = -1;
- cc._addEventListener(a, c, this.didAccelerate.bind(this), !1)
- };
- _p.didAccelerate = function(a) {
- var c = window;
- if (this._accelEnabled) {
- var d = this._acceleration;
- if (this._accelDeviceEvent == window.DeviceMotionEvent) {
- var e = a.accelerationIncludingGravity;
- d.x = 0.1 * this._accelMinus * e.x;
- d.y = 0.1 * this._accelMinus * e.y;
- d.z = 0.1 * e.z
- } else d.x = 0.981 * (a.gamma / 90), d.y = 0.981 * -(a.beta / 90), d.z = 0.981 * (a.alpha / 90);
- d.timestamp = a.timeStamp || Date.now();
- a = d.x;
- c.orientation === cc.UIInterfaceOrientationLandscapeRight ? (d.x = -d.y, d.y = a) : c.orientation === cc.UIInterfaceOrientationLandscapeLeft ? (d.x = d.y, d.y = -a) : c.orientation === cc.UIInterfaceOrientationPortraitUpsideDown && (d.x = -d.x, d.y = -d.y)
- }
- };
- delete _p;
- cc.AffineTransform = function(a, c, d, e, f, g) {
- this.a = a;
- this.b = c;
- this.c = d;
- this.d = e;
- this.tx = f;
- this.ty = g
- };
- cc.affineTransformMake = function(a, c, d, e, f, g) {
- return {
- a: a,
- b: c,
- c: d,
- d: e,
- tx: f,
- ty: g
- }
- };
- cc.pointApplyAffineTransform = function(a, c) {
- return {
- x: c.a * a.x + c.c * a.y + c.tx,
- y: c.b * a.x + c.d * a.y + c.ty
- }
- };
- cc._pointApplyAffineTransform = function(a, c, d) {
- return {
- x: d.a * a + d.c * c + d.tx,
- y: d.b * a + d.d * c + d.ty
- }
- };
- cc.sizeApplyAffineTransform = function(a, c) {
- return {
- width: c.a * a.width + c.c * a.height,
- height: c.b * a.width + c.d * a.height
- }
- };
- cc.affineTransformMakeIdentity = function() {
- return {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- tx: 0,
- ty: 0
- }
- };
- cc.affineTransformIdentity = function() {
- return {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- tx: 0,
- ty: 0
- }
- };
- cc.rectApplyAffineTransform = function(a, c) {
- var d = cc.rectGetMinY(a),
- e = cc.rectGetMinX(a),
- f = cc.rectGetMaxX(a),
- g = cc.rectGetMaxY(a),
- h = cc._pointApplyAffineTransform(e, d, c),
- d = cc._pointApplyAffineTransform(f, d, c),
- e = cc._pointApplyAffineTransform(e, g, c),
- k = cc._pointApplyAffineTransform(f, g, c),
- f = Math.min(h.x, d.x, e.x, k.x),
- g = Math.max(h.x, d.x, e.x, k.x),
- m = Math.min(h.y, d.y, e.y, k.y),
- h = Math.max(h.y, d.y, e.y, k.y);
- return cc.rect(f, m, g - f, h - m)
- };
- cc._rectApplyAffineTransformIn = function(a, c) {
- var d = cc.rectGetMinY(a),
- e = cc.rectGetMinX(a),
- f = cc.rectGetMaxX(a),
- g = cc.rectGetMaxY(a),
- h = cc._pointApplyAffineTransform(e, d, c),
- d = cc._pointApplyAffineTransform(f, d, c),
- e = cc._pointApplyAffineTransform(e, g, c),
- k = cc._pointApplyAffineTransform(f, g, c),
- f = Math.min(h.x, d.x, e.x, k.x),
- g = Math.max(h.x, d.x, e.x, k.x),
- m = Math.min(h.y, d.y, e.y, k.y),
- h = Math.max(h.y, d.y, e.y, k.y);
- a.x = f;
- a.y = m;
- a.width = g - f;
- a.height = h - m;
- return a
- };
- cc.affineTransformTranslate = function(a, c, d) {
- return {
- a: a.a,
- b: a.b,
- c: a.c,
- d: a.d,
- tx: a.tx + a.a * c + a.c * d,
- ty: a.ty + a.b * c + a.d * d
- }
- };
- cc.affineTransformScale = function(a, c, d) {
- return {
- a: a.a * c,
- b: a.b * c,
- c: a.c * d,
- d: a.d * d,
- tx: a.tx,
- ty: a.ty
- }
- };
- cc.affineTransformRotate = function(a, c) {
- var d = Math.sin(c),
- e = Math.cos(c);
- return {
- a: a.a * e + a.c * d,
- b: a.b * e + a.d * d,
- c: a.c * e - a.a * d,
- d: a.d * e - a.b * d,
- tx: a.tx,
- ty: a.ty
- }
- };
- cc.affineTransformConcat = function(a, c) {
- return {
- a: a.a * c.a + a.b * c.c,
- b: a.a * c.b + a.b * c.d,
- c: a.c * c.a + a.d * c.c,
- d: a.c * c.b + a.d * c.d,
- tx: a.tx * c.a + a.ty * c.c + c.tx,
- ty: a.tx * c.b + a.ty * c.d + c.ty
- }
- };
- cc.affineTransformEqualToTransform = function(a, c) {
- return a.a === c.a && a.b === c.b && a.c === c.c && a.d === c.d && a.tx === c.tx && a.ty === c.ty
- };
- cc.affineTransformInvert = function(a) {
- var c = 1 / (a.a * a.d - a.b * a.c);
- return {
- a: c * a.d,
- b: -c * a.b,
- c: -c * a.c,
- d: c * a.a,
- tx: c * (a.c * a.ty - a.d * a.tx),
- ty: c * (a.b * a.tx - a.a * a.ty)
- }
- };
- cc.POINT_EPSILON = parseFloat("1.192092896e-07F");
- cc.pNeg = function(a) {
- return cc.p(-a.x, -a.y)
- };
- cc.pAdd = function(a, c) {
- return cc.p(a.x + c.x, a.y + c.y)
- };
- cc.pSub = function(a, c) {
- return cc.p(a.x - c.x, a.y - c.y)
- };
- cc.pMult = function(a, c) {
- return cc.p(a.x * c, a.y * c)
- };
- cc.pMidpoint = function(a, c) {
- return cc.pMult(cc.pAdd(a, c), 0.5)
- };
- cc.pDot = function(a, c) {
- return a.x * c.x + a.y * c.y
- };
- cc.pCross = function(a, c) {
- return a.x * c.y - a.y * c.x
- };
- cc.pPerp = function(a) {
- return cc.p(-a.y, a.x)
- };
- cc.pRPerp = function(a) {
- return cc.p(a.y, -a.x)
- };
- cc.pProject = function(a, c) {
- return cc.pMult(c, cc.pDot(a, c) / cc.pDot(c, c))
- };
- cc.pRotate = function(a, c) {
- return cc.p(a.x * c.x - a.y * c.y, a.x * c.y + a.y * c.x)
- };
- cc.pUnrotate = function(a, c) {
- return cc.p(a.x * c.x + a.y * c.y, a.y * c.x - a.x * c.y)
- };
- cc.pLengthSQ = function(a) {
- return cc.pDot(a, a)
- };
- cc.pDistanceSQ = function(a, c) {
- return cc.pLengthSQ(cc.pSub(a, c))
- };
- cc.pLength = function(a) {
- return Math.sqrt(cc.pLengthSQ(a))
- };
- cc.pDistance = function(a, c) {
- return cc.pLength(cc.pSub(a, c))
- };
- cc.pNormalize = function(a) {
- return cc.pMult(a, 1 / cc.pLength(a))
- };
- cc.pForAngle = function(a) {
- return cc.p(Math.cos(a), Math.sin(a))
- };
- cc.pToAngle = function(a) {
- return Math.atan2(a.y, a.x)
- };
- cc.clampf = function(a, c, d) {
- if (c > d) {
- var e = c;
- c = d;
- d = e
- }
- return a < c ? c : a < d ? a : d
- };
- cc.pClamp = function(a, c, d) {
- return cc.p(cc.clampf(a.x, c.x, d.x), cc.clampf(a.y, c.y, d.y))
- };
- cc.pFromSize = function(a) {
- return cc.p(a.width, a.height)
- };
- cc.pCompOp = function(a, c) {
- return cc.p(c(a.x), c(a.y))
- };
- cc.pLerp = function(a, c, d) {
- return cc.pAdd(cc.pMult(a, 1 - d), cc.pMult(c, d))
- };
- cc.pFuzzyEqual = function(a, c, d) {
- return a.x - d <= c.x && c.x <= a.x + d && a.y - d <= c.y && c.y <= a.y + d ? !0 : !1
- };
- cc.pCompMult = function(a, c) {
- return cc.p(a.x * c.x, a.y * c.y)
- };
- cc.pAngleSigned = function(a, c) {
- var d = cc.pNormalize(a),
- e = cc.pNormalize(c),
- d = Math.atan2(d.x * e.y - d.y * e.x, cc.pDot(d, e));
- return Math.abs(d) < cc.POINT_EPSILON ? 0 : d
- };
- cc.pAngle = function(a, c) {
- var d = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(c)));
- return Math.abs(d) < cc.POINT_EPSILON ? 0 : d
- };
- cc.pRotateByAngle = function(a, c, d) {
- a = cc.pSub(a, c);
- var e = Math.cos(d);
- d = Math.sin(d);
- var f = a.x;
- a.x = f * e - a.y * d + c.x;
- a.y = f * d + a.y * e + c.y;
- return a
- };
- cc.pLineIntersect = function(a, c, d, e, f) {
- if (a.x == c.x && a.y == c.y || d.x == e.x && d.y == e.y) return !1;
- var g = c.x - a.x;
- c = c.y - a.y;
- var h = e.x - d.x;
- e = e.y - d.y;
- var k = a.x - d.x;
- a = a.y - d.y;
- d = e * g - h * c;
- f.x = h * a - e * k;
- f.y = g * a - c * k;
- if (0 == d) return 0 == f.x || 0 == f.y ? !0 : !1;
- f.x /= d;
- f.y /= d;
- return !0
- };
- cc.pSegmentIntersect = function(a, c, d, e) {
- var f = cc.p(0, 0);
- return cc.pLineIntersect(a, c, d, e, f) && 0 <= f.x && 1 >= f.x && 0 <= f.y && 1 >= f.y ? !0 : !1
- };
- cc.pIntersectPoint = function(a, c, d, e) {
- var f = cc.p(0, 0);
- return cc.pLineIntersect(a, c, d, e, f) ? (d = cc.p(0, 0), d.x = a.x + f.x * (c.x - a.x), d.y = a.y + f.x * (c.y - a.y), d) : cc.p(0, 0)
- };
- cc.pSameAs = function(a, c) {
- return null != a && null != c ? a.x == c.x && a.y == c.y : !1
- };
- cc.pZeroIn = function(a) {
- a.x = 0;
- a.y = 0
- };
- cc.pIn = function(a, c) {
- a.x = c.x;
- a.y = c.y
- };
- cc.pMultIn = function(a, c) {
- a.x *= c;
- a.y *= c
- };
- cc.pSubIn = function(a, c) {
- a.x -= c.x;
- a.y -= c.y
- };
- cc.pAddIn = function(a, c) {
- a.x += c.x;
- a.y += c.y
- };
- cc.pNormalizeIn = function(a) {
- cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y))
- };
- cc.vertexLineToPolygon = function(a, c, d, e, f) {
- f += e;
- if (!(1 >= f)) {
- c *= 0.5;
- for (var g, h = f - 1, k = e; k < f; k++) {
- g = 2 * k;
- var m = cc.p(a[2 * k], a[2 * k + 1]),
- n;
- if (0 === k) n = cc.pPerp(cc.pNormalize(cc.pSub(m, cc.p(a[2 * (k + 1)], a[2 * (k + 1) + 1]))));
- else if (k === h) n = cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2 * (k - 1)], a[2 * (k - 1) + 1]), m)));
- else {
- n = cc.p(a[2 * (k - 1)], a[2 * (k - 1) + 1]);
- var q = cc.p(a[2 * (k + 1)], a[2 * (k + 1) + 1]),
- r = cc.pNormalize(cc.pSub(q, m)),
- t = cc.pNormalize(cc.pSub(n, m)),
- s = Math.acos(cc.pDot(r, t));
- n = s < cc.degreesToRadians(70) ? cc.pPerp(cc.pNormalize(cc.pMidpoint(r, t))) : s < cc.degreesToRadians(170) ? cc.pNormalize(cc.pMidpoint(r, t)) : cc.pPerp(cc.pNormalize(cc.pSub(q, n)))
- }
- n = cc.pMult(n, c);
- d[2 * g] = m.x + n.x;
- d[2 * g + 1] = m.y + n.y;
- d[2 * (g + 1)] = m.x - n.x;
- d[2 * (g + 1) + 1] = m.y - n.y
- }
- for (k = 0 == e ? 0 : e - 1; k < h; k++) {
- g = 2 * k;
- a = g + 2;
- c = cc.vertex2(d[2 * g], d[2 * g + 1]);
- f = cc.vertex2(d[2 * (g + 1)], d[2 * (g + 1) + 1]);
- g = cc.vertex2(d[2 * a], d[2 * a]);
- e = cc.vertex2(d[2 * (a + 1)], d[2 * (a + 1) + 1]);
- c = !cc.vertexLineIntersect(c.x, c.y, e.x, e.y, f.x, f.y, g.x, g.y);
- if (!c.isSuccess && (0 > c.value || 1 < c.value)) c.isSuccess = !0;
- c.isSuccess && (d[2 * a] = e.x, d[2 * a + 1] = e.y, d[2 * (a + 1)] = g.x, d[2 * (a + 1) + 1] = g.y)
- }
- }
- };
- cc.vertexLineIntersect = function(a, c, d, e, f, g, h, k) {
- if (a == d && c == e || f == h && g == k) return {
- isSuccess: !1,
- value: 0
- };
- d -= a;
- e -= c;
- f -= a;
- g -= c;
- h -= a;
- k -= c;
- a = Math.sqrt(d * d + e * e);
- d /= a;
- e /= a;
- c = f * d + g * e;
- g = g * d - f * e;
- f = c;
- c = h * d + k * e;
- k = k * d - h * e;
- h = c;
- return g == k ? {
- isSuccess: !1,
- value: 0
- } : {
- isSuccess: !0,
- value: (h + (f - h) * k / (k - g)) / a
- }
- };
- cc.vertexListIsClockwise = function(a) {
- for (var c = 0, d = a.length; c < d; c++) {
- var e = a[(c + 1) % d],
- f = a[(c + 2) % d];
- if (0 < cc.pCross(cc.pSub(e, a[c]), cc.pSub(f, e))) return !1
- }
- return !0
- };
- cc.CGAffineToGL = function(a, c) {
- c[2] = c[3] = c[6] = c[7] = c[8] = c[9] = c[11] = c[14] = 0;
- c[10] = c[15] = 1;
- c[0] = a.a;
- c[4] = a.c;
- c[12] = a.tx;
- c[1] = a.b;
- c[5] = a.d;
- c[13] = a.ty
- };
- cc.GLToCGAffine = function(a, c) {
- c.a = a[0];
- c.c = a[4];
- c.tx = a[12];
- c.b = a[1];
- c.d = a[5];
- c.ty = a[13]
- };
- cc.Touch = cc.Class.extend({
- _point: null,
- _prevPoint: null,
- _id: 0,
- _startPointCaptured: !1,
- _startPoint: null,
- ctor: function(a, c, d) {
- this._point = cc.p(a || 0, c || 0);
- this._id = d || 0
- },
- getLocation: function() {
- return {
- x: this._point.x,
- y: this._point.y
- }
- },
- getLocationX: function() {
- return this._point.x
- },
- getLocationY: function() {
- return this._point.y
- },
- getPreviousLocation: function() {
- return {
- x: this._prevPoint.x,
- y: this._prevPoint.y
- }
- },
- getStartLocation: function() {
- return {
- x: this._startPoint.x,
- y: this._startPoint.y
- }
- },
- getDelta: function() {
- return cc.pSub(this._point, this._prevPoint)
- },
- getLocationInView: function() {
- return {
- x: this._point.x,
- y: this._point.y
- }
- },
- getPreviousLocationInView: function() {
- return {
- x: this._prevPoint.x,
- y: this._prevPoint.y
- }
- },
- getStartLocationInView: function() {
- return {
- x: this._startPoint.x,
- y: this._startPoint.y
- }
- },
- getID: function() {
- return this._id
- },
- getId: function() {
- return this._id
- },
- setTouchInfo: function(a, c, d) {
- this._prevPoint = this._point;
- this._point = cc.p(c || 0, d || 0);
- this._id = a;
- this._startPointCaptured || (this._startPoint = cc.p(this._point), this._startPointCaptured = !0)
- },
- _setPoint: function(a, c) {
- void 0 === c ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = c)
- },
- _setPrevPoint: function(a, c) {
- this._prevPoint = void 0 === c ? cc.p(a.x, a.y) : cc.p(a || 0, c || 0)
- }
- });
- cc.Event = cc.Class.extend({
- _type: 0,
- _isStopped: !1,
- _currentTarget: null,
- _setCurrentTarget: function(a) {
- this._currentTarget = a
- },
- ctor: function(a) {
- this._type = a
- },
- getType: function() {
- return this._type
- },
- stopPropagation: function() {
- this._isStopped = !0
- },
- isStopped: function() {
- return this._isStopped
- },
- getCurrentTarget: function() {
- return this._currentTarget
- }
- });
- cc.Event.TOUCH = 0;
- cc.Event.KEYBOARD = 1;
- cc.Event.ACCELERATION = 2;
- cc.Event.MOUSE = 3;
- cc.Event.CUSTOM = 4;
- cc.EventCustom = cc.Event.extend({
- _eventName: null,
- _userData: null,
- ctor: function(a) {
- cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM);
- this._eventName = a
- },
- setUserData: function(a) {
- this._userData = a
- },
- getUserData: function() {
- return this._userData
- },
- getEventName: function() {
- return this._eventName
- }
- });
- cc.EventMouse = cc.Event.extend({
- _eventType: 0,
- _button: 0,
- _x: 0,
- _y: 0,
- _prevX: 0,
- _prevY: 0,
- _scrollX: 0,
- _scrollY: 0,
- ctor: function(a) {
- cc.Event.prototype.ctor.call(this, cc.Event.MOUSE);
- this._eventType = a
- },
- setScrollData: function(a, c) {
- this._scrollX = a;
- this._scrollY = c
- },
- getScrollX: function() {
- return this._scrollX
- },
- getScrollY: function() {
- return this._scrollY
- },
- setLocation: function(a, c) {
- this._x = a;
- this._y = c
- },
- getLocation: function() {
- return {
- x: this._x,
- y: this._y
- }
- },
- getLocationInView: function() {
- return {
- x: this._x,
- y: cc.view._designResolutionSize.height - this._y
- }
- },
- _setPrevCursor: function(a, c) {
- this._prevX = a;
- this._prevY = c
- },
- getDelta: function() {
- return {
- x: this._x - this._prevX,
- y: this._y - this._prevY
- }
- },
- getDeltaX: function() {
- return this._x - this._prevX
- },
- getDeltaY: function() {
- return this._y - this._prevY
- },
- setButton: function(a) {
- this._button = a
- },
- getButton: function() {
- return this._button
- },
- getLocationX: function() {
- return this._x
- },
- getLocationY: function() {
- return this._y
- }
- });
- cc.EventMouse.NONE = 0;
- cc.EventMouse.DOWN = 1;
- cc.EventMouse.UP = 2;
- cc.EventMouse.MOVE = 3;
- cc.EventMouse.SCROLL = 4;
- cc.EventMouse.BUTTON_LEFT = 0;
- cc.EventMouse.BUTTON_RIGHT = 2;
- cc.EventMouse.BUTTON_MIDDLE = 1;
- cc.EventMouse.BUTTON_4 = 3;
- cc.EventMouse.BUTTON_5 = 4;
- cc.EventMouse.BUTTON_6 = 5;
- cc.EventMouse.BUTTON_7 = 6;
- cc.EventMouse.BUTTON_8 = 7;
- cc.EventTouch = cc.Event.extend({
- _eventCode: 0,
- _touches: null,
- ctor: function(a) {
- cc.Event.prototype.ctor.call(this, cc.Event.TOUCH);
- this._touches = a || []
- },
- getEventCode: function() {
- return this._eventCode
- },
- getTouches: function() {
- return this._touches
- },
- _setEventCode: function(a) {
- this._eventCode = a
- },
- _setTouches: function(a) {
- this._touches = a
- }
- });
- cc.EventTouch.MAX_TOUCHES = 5;
- cc.EventTouch.EventCode = {
- BEGAN: 0,
- MOVED: 1,
- ENDED: 2,
- CANCELLED: 3
- };
- cc.EventListener = cc.Class.extend({
- _onEvent: null,
- _type: 0,
- _listenerID: null,
- _registered: !1,
- _fixedPriority: 0,
- _node: null,
- _paused: !1,
- _isEnabled: !0,
- ctor: function(a, c, d) {
- this._onEvent = d;
- this._type = a || 0;
- this._listenerID = c || ""
- },
- _setPaused: function(a) {
- this._paused = a
- },
- _isPaused: function() {
- return this._paused
- },
- _setRegistered: function(a) {
- this._registered = a
- },
- _isRegistered: function() {
- return this._registered
- },
- _getType: function() {
- return this._type
- },
- _getListenerID: function() {
- return this._listenerID
- },
- _setFixedPriority: function(a) {
- this._fixedPriority = a
- },
- _getFixedPriority: function() {
- return this._fixedPriority
- },
- _setSceneGraphPriority: function(a) {
- this._node = a
- },
- _getSceneGraphPriority: function() {
- return this._node
- },
- checkAvailable: function() {
- return null != this._onEvent
- },
- clone: function() {
- return null
- },
- setEnabled: function(a) {
- this._isEnabled = a
- },
- isEnabled: function() {
- return this._isEnabled
- },
- retain: function() {},
- release: function() {}
- });
- cc.EventListener.UNKNOWN = 0;
- cc.EventListener.TOUCH_ONE_BY_ONE = 1;
- cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
- cc.EventListener.KEYBOARD = 3;
- cc.EventListener.MOUSE = 4;
- cc.EventListener.ACCELERATION = 5;
- cc.EventListener.CUSTOM = 6;
- cc._EventListenerCustom = cc.EventListener.extend({
- _onCustomEvent: null,
- ctor: function(a, c) {
- this._onCustomEvent = c;
- var d = this;
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a, function(a) {
- null != d._onCustomEvent && d._onCustomEvent(a)
- })
- },
- checkAvailable: function() {
- return cc.EventListener.prototype.checkAvailable.call(this) && null != this._onCustomEvent
- },
- clone: function() {
- return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent)
- }
- });
- cc._EventListenerCustom.create = function(a, c) {
- return new cc._EventListenerCustom(a, c)
- };
- cc._EventListenerMouse = cc.EventListener.extend({
- onMouseDown: null,
- onMouseUp: null,
- onMouseMove: null,
- onMouseScroll: null,
- ctor: function() {
- var a = this;
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID, function(c) {
- var d = cc.EventMouse;
- switch (c._eventType) {
- case d.DOWN:
- if (a.onMouseDown) a.onMouseDown(c);
- break;
- case d.UP:
- if (a.onMouseUp) a.onMouseUp(c);
- break;
- case d.MOVE:
- if (a.onMouseMove) a.onMouseMove(c);
- break;
- case d.SCROLL:
- if (a.onMouseScroll) a.onMouseScroll(c)
- }
- })
- },
- clone: function() {
- var a = new cc._EventListenerMouse;
- a.onMouseDown = this.onMouseDown;
- a.onMouseUp = this.onMouseUp;
- a.onMouseMove = this.onMouseMove;
- a.onMouseScroll = this.onMouseScroll;
- return a
- },
- checkAvailable: function() {
- return !0
- }
- });
- cc._EventListenerMouse.LISTENER_ID = "__cc_mouse";
- cc._EventListenerMouse.create = function() {
- return new cc._EventListenerMouse
- };
- cc._EventListenerTouchOneByOne = cc.EventListener.extend({
- _claimedTouches: null,
- swallowTouches: !1,
- onTouchBegan: null,
- onTouchMoved: null,
- onTouchEnded: null,
- onTouchCancelled: null,
- ctor: function() {
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null);
- this._claimedTouches = []
- },
- setSwallowTouches: function(a) {
- this.swallowTouches = a
- },
- clone: function() {
- var a = new cc._EventListenerTouchOneByOne;
- a.onTouchBegan = this.onTouchBegan;
- a.onTouchMoved = this.onTouchMoved;
- a.onTouchEnded = this.onTouchEnded;
- a.onTouchCancelled = this.onTouchCancelled;
- a.swallowTouches = this.swallowTouches;
- return a
- },
- checkAvailable: function() {
- return !this.onTouchBegan ? (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1) : !0
- }
- });
- cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one";
- cc._EventListenerTouchOneByOne.create = function() {
- return new cc._EventListenerTouchOneByOne
- };
- cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({
- onTouchesBegan: null,
- onTouchesMoved: null,
- onTouchesEnded: null,
- onTouchesCancelled: null,
- ctor: function() {
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null)
- },
- clone: function() {
- var a = new cc._EventListenerTouchAllAtOnce;
- a.onTouchesBegan = this.onTouchesBegan;
- a.onTouchesMoved = this.onTouchesMoved;
- a.onTouchesEnded = this.onTouchesEnded;
- a.onTouchesCancelled = this.onTouchesCancelled;
- return a
- },
- checkAvailable: function() {
- return null == this.onTouchesBegan && null == this.onTouchesMoved && null == this.onTouchesEnded && null == this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0
- }
- });
- cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
- cc._EventListenerTouchAllAtOnce.create = function() {
- return new cc._EventListenerTouchAllAtOnce
- };
- cc.EventListener.create = function(a) {
- cc.assert(a && a.event, cc._LogInfos.EventListener_create);
- var c = a.event;
- delete a.event;
- var d = null;
- c === cc.EventListener.TOUCH_ONE_BY_ONE ? d = new cc._EventListenerTouchOneByOne : c === cc.EventListener.TOUCH_ALL_AT_ONCE ? d = new cc._EventListenerTouchAllAtOnce : c === cc.EventListener.MOUSE ? d = new cc._EventListenerMouse : c === cc.EventListener.CUSTOM ? (d = new cc._EventListenerCustom(a.eventName, a.callback), delete a.eventName, delete a.callback) : c === cc.EventListener.KEYBOARD ? d = new cc._EventListenerKeyboard : c === cc.EventListener.ACCELERATION && (d = new cc._EventListenerAcceleration(a.callback), delete a.callback);
- for (var e in a) d[e] = a[e];
- return d
- };
- cc.copyArray = function(a) {
- var c, d = a.length,
- e = Array(d);
- for (c = 0; c < d; c += 1) e[c] = a[c];
- return e
- };
- cc._EventListenerVector = cc.Class.extend({
- _fixedListeners: null,
- _sceneGraphListeners: null,
- gt0Index: 0,
- ctor: function() {
- this._fixedListeners = [];
- this._sceneGraphListeners = []
- },
- size: function() {
- return this._fixedListeners.length + this._sceneGraphListeners.length
- },
- empty: function() {
- return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length
- },
- push: function(a) {
- 0 == a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a)
- },
- clearSceneGraphListeners: function() {
- this._sceneGraphListeners.length = 0
- },
- clearFixedListeners: function() {
- this._fixedListeners.length = 0
- },
- clear: function() {
- this._sceneGraphListeners.length = 0;
- this._fixedListeners.length = 0
- },
- getFixedPriorityListeners: function() {
- return this._fixedListeners
- },
- getSceneGraphPriorityListeners: function() {
- return this._sceneGraphListeners
- }
- });
- cc.__getListenerID = function(a) {
- var c = cc.Event,
- d = a.getType();
- if (d === c.ACCELERATION) return cc._EventListenerAcceleration.LISTENER_ID;
- if (d === c.CUSTOM) return a.getEventName();
- if (d === c.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID;
- if (d === c.MOUSE) return cc._EventListenerMouse.LISTENER_ID;
- d === c.TOUCH && cc.log(cc._LogInfos.__getListenerID);
- return ""
- };
- cc.eventManager = {
- DIRTY_NONE: 0,
- DIRTY_FIXED_PRIORITY: 1,
- DIRTY_SCENE_GRAPH_PRIORITY: 2,
- DIRTY_ALL: 3,
- _listenersMap: {},
- _priorityDirtyFlagMap: {},
- _nodeListenersMap: {},
- _nodePriorityMap: {},
- _globalZOrderNodeMap: {},
- _toAddedListeners: [],
- _dirtyNodes: [],
- _inDispatch: 0,
- _isEnabled: !1,
- _nodePriorityIndex: 0,
- _internalCustomListenerIDs: [cc.game.EVENT_HIDE, cc.game.EVENT_SHOW],
- _setDirtyForNode: function(a) {
- null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a);
- a = a.getChildren();
- for (var c = 0, d = a.length; c < d; c++) this._setDirtyForNode(a[c])
- },
- pauseTarget: function(a, c) {
- var d = this._nodeListenersMap[a.__instanceId],
- e, f;
- if (d) {
- e = 0;
- for (f = d.length; e < f; e++) d[e]._setPaused(!0)
- }
- if (!0 === c) {
- d = a.getChildren();
- e = 0;
- for (f = d.length; e < f; e++) this.pauseTarget(d[e], !0)
- }
- },
- resumeTarget: function(a, c) {
- var d = this._nodeListenersMap[a.__instanceId],
- e, f;
- if (d) {
- e = 0;
- for (f = d.length; e < f; e++) d[e]._setPaused(!1)
- }
- this._setDirtyForNode(a);
- if (!0 === c) {
- d = a.getChildren();
- e = 0;
- for (f = d.length; e < f; e++) this.resumeTarget(d[e], !0)
- }
- },
- _addListener: function(a) {
- 0 === this._inDispatch ? this._forceAddEventListener(a) : this._toAddedListeners.push(a)
- },
- _forceAddEventListener: function(a) {
- var c = a._getListenerID(),
- d = this._listenersMap[c];
- d || (d = new cc._EventListenerVector, this._listenersMap[c] = d);
- d.push(a);
- 0 == a._getFixedPriority() ? (this._setDirty(c, this.DIRTY_SCENE_GRAPH_PRIORITY), c = a._getSceneGraphPriority(), null == c && cc.log(cc._LogInfos.eventManager__forceAddEventListener), this._associateNodeAndEventListener(c, a), c.isRunning() && this.resumeTarget(c)) : this._setDirty(c, this.DIRTY_FIXED_PRIORITY)
- },
- _getListeners: function(a) {
- return this._listenersMap[a]
- },
- _updateDirtyFlagForSceneGraph: function() {
- if (0 != this._dirtyNodes.length) {
- for (var a = this._dirtyNodes, c, d, e = this._nodeListenersMap, f = 0, g = a.length; f < g; f++)
- if (c = e[a[f].__instanceId])
- for (var h = 0, k = c.length; h < k; h++)(d = c[h]) && this._setDirty(d._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
- this._dirtyNodes.length = 0
- }
- },
- _removeAllListenersInVector: function(a) {
- if (a)
- for (var c, d = 0; d < a.length;) c = a[d], c._setRegistered(!1), null != c._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(c._getSceneGraphPriority(), c), c._setSceneGraphPriority(null)), 0 === this._inDispatch ? cc.arrayRemoveObject(a, c) : ++d
- },
- _removeListenersForListenerID: function(a) {
- var c = this._listenersMap[a];
- if (c) {
- var d = c.getFixedPriorityListeners(),
- e = c.getSceneGraphPriorityListeners();
- this._removeAllListenersInVector(e);
- this._removeAllListenersInVector(d);
- delete this._priorityDirtyFlagMap[a];
- this._inDispatch || (c.clear(), delete this._listenersMap[a])
- }
- d = this._toAddedListeners;
- for (c = 0; c < d.length;)(e = d[c]) && e._getListenerID() == a ? cc.arrayRemoveObject(d, e) : ++c
- },
- _sortEventListeners: function(a) {
- var c = this.DIRTY_NONE,
- d = this._priorityDirtyFlagMap;
- d[a] && (c = d[a]);
- c != this.DIRTY_NONE && (d[a] = this.DIRTY_NONE, c & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(a), c & this.DIRTY_SCENE_GRAPH_PRIORITY && ((c = cc.director.getRunningScene()) ? this._sortListenersOfSceneGraphPriority(a, c) : d[a] = this.DIRTY_SCENE_GRAPH_PRIORITY))
- },
- _sortListenersOfSceneGraphPriority: function(a, c) {
- var d = this._getListeners(a);
- if (d) {
- var e = d.getSceneGraphPriorityListeners();
- e && 0 !== e.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {}, this._visitTarget(c, !0), d.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))
- }
- },
- _sortEventListenersOfSceneGraphPriorityDes: function(a, c) {
- var d = cc.eventManager._nodePriorityMap;
- return d[c._getSceneGraphPriority().__instanceId] - d[a._getSceneGraphPriority().__instanceId]
- },
- _sortListenersOfFixedPriority: function(a) {
- if (a = this._listenersMap[a]) {
- var c = a.getFixedPriorityListeners();
- if (c && 0 !== c.length) {
- c.sort(this._sortListenersOfFixedPriorityAsc);
- for (var d = 0, e = c.length; d < e && !(0 <= c[d]._getFixedPriority());)++d;
- a.gt0Index = d
- }
- }
- },
- _sortListenersOfFixedPriorityAsc: function(a, c) {
- return a._getFixedPriority() - c._getFixedPriority()
- },
- _onUpdateListeners: function(a) {
- if (a = this._listenersMap[a]) {
- var c = a.getFixedPriorityListeners(),
- d = a.getSceneGraphPriorityListeners(),
- e, f;
- if (d)
- for (e = 0; e < d.length;) f = d[e], f._isRegistered() ? ++e : cc.arrayRemoveObject(d, f);
- if (c)
- for (e = 0; e < c.length;) f = c[e], f._isRegistered() ? ++e : cc.arrayRemoveObject(c, f);
- d && 0 === d.length && a.clearSceneGraphListeners();
- c && 0 === c.length && a.clearFixedListeners()
- }
- },
- _updateListeners: function(a) {
- var c = this._inDispatch;
- cc.assert(0 < c, cc._LogInfos.EventManager__updateListeners);
- a.getType() == cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a));
- if (!(1 < c)) {
- cc.assert(1 == c, cc._LogInfos.EventManager__updateListeners_2);
- a = this._listenersMap;
- var c = this._priorityDirtyFlagMap,
- d;
- for (d in a) a[d].empty() && (delete c[d], delete a[d]);
- d = this._toAddedListeners;
- if (0 !== d.length) {
- a = 0;
- for (c = d.length; a < c; a++) this._forceAddEventListener(d[a]);
- this._toAddedListeners.length = 0
- }
- }
- },
- _onTouchEventCallback: function(a, c) {
- if (!a._isRegistered) return !1;
- var d = c.event,
- e = c.selTouch;
- d._setCurrentTarget(a._node);
- var f = !1,
- g, h = d.getEventCode(),
- k = cc.EventTouch.EventCode;
- if (h == k.BEGAN) a.onTouchBegan && (f = a.onTouchBegan(e, d)) && a._registered && a._claimedTouches.push(e);
- else if (0 < a._claimedTouches.length && -1 != (g = a._claimedTouches.indexOf(e)))
- if (f = !0, h === k.MOVED && a.onTouchMoved) a.onTouchMoved(e, d);
- else if (h === k.ENDED) {
- if (a.onTouchEnded) a.onTouchEnded(e, d);
- a._registered && a._claimedTouches.splice(g, 1)
- } else if (h === k.CANCELLED) {
- if (a.onTouchCancelled) a.onTouchCancelled(e, d);
- a._registered && a._claimedTouches.splice(g, 1)
- }
- return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : f && a._registered && a.swallowTouches ? (c.needsMutableSet && c.touches.splice(e, 1), !0) : !1
- },
- _dispatchTouchEvent: function(a) {
- this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);
- this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
- var c = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),
- d = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
- if (!(null == c && null == d)) {
- var e = a.getTouches(),
- f = cc.copyArray(e),
- g = {
- event: a,
- needsMutableSet: c && d,
- touches: f,
- selTouch: null
- };
- if (c)
- for (var h = 0; h < e.length; h++)
- if (g.selTouch = e[h], this._dispatchEventToListeners(c, this._onTouchEventCallback, g), a.isStopped()) return;
- if (d && 0 < f.length && (this._dispatchEventToListeners(d, this._onTouchesEventCallback, {
- event: a,
- touches: f
- }), a.isStopped())) return;
- this._updateListeners(a)
- }
- },
- _onTouchesEventCallback: function(a, c) {
- if (!a._registered) return !1;
- var d = cc.EventTouch.EventCode,
- e = c.event,
- f = c.touches,
- g = e.getEventCode();
- e._setCurrentTarget(a._node);
- if (g == d.BEGAN && a.onTouchesBegan) a.onTouchesBegan(f, e);
- else if (g == d.MOVED && a.onTouchesMoved) a.onTouchesMoved(f, e);
- else if (g == d.ENDED && a.onTouchesEnded) a.onTouchesEnded(f, e);
- else if (g == d.CANCELLED && a.onTouchesCancelled) a.onTouchesCancelled(f, e);
- return e.isStopped() ? (cc.eventManager._updateListeners(e), !0) : !1
- },
- _associateNodeAndEventListener: function(a, c) {
- var d = this._nodeListenersMap[a.__instanceId];
- d || (d = [], this._nodeListenersMap[a.__instanceId] = d);
- d.push(c)
- },
- _dissociateNodeAndEventListener: function(a, c) {
- var d = this._nodeListenersMap[a.__instanceId];
- d && (cc.arrayRemoveObject(d, c), 0 === d.length && delete this._nodeListenersMap[a.__instanceId])
- },
- _dispatchEventToListeners: function(a, c, d) {
- var e = !1,
- f = a.getFixedPriorityListeners(),
- g = a.getSceneGraphPriorityListeners(),
- h = 0,
- k;
- if (f && 0 !== f.length)
- for (; h < a.gt0Index; ++h)
- if (k = f[h], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)) {
- e = !0;
- break
- }
- if (g && !e)
- for (a = 0; a < g.length; a++)
- if (k = g[a], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)) {
- e = !0;
- break
- }
- if (f && !e)
- for (; h < f.length && !(k = f[h], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)); ++h);
- },
- _setDirty: function(a, c) {
- var d = this._priorityDirtyFlagMap;
- d[a] = null == d[a] ? c : c | d[a]
- },
- _visitTarget: function(a, c) {
- var d = a.getChildren(),
- e = 0,
- f = d.length,
- g = this._globalZOrderNodeMap,
- h = this._nodeListenersMap;
- if (0 < f) {
- for (var k; e < f; e++)
- if ((k = d[e]) && 0 > k.getLocalZOrder()) this._visitTarget(k, !1);
- else break;
- null != h[a.__instanceId] && (g[a.getGlobalZOrder()] || (g[a.getGlobalZOrder()] = []), g[a.getGlobalZOrder()].push(a.__instanceId));
- for (; e < f; e++)(k = d[e]) && this._visitTarget(k, !1)
- } else null != h[a.__instanceId] && (g[a.getGlobalZOrder()] || (g[a.getGlobalZOrder()] = []), g[a.getGlobalZOrder()].push(a.__instanceId)); if (c) {
- var d = [],
- m;
- for (m in g) d.push(m);
- d.sort(this._sortNumberAsc);
- m = d.length;
- k = this._nodePriorityMap;
- for (e = 0; e < m; e++) {
- f = g[d[e]];
- for (h = 0; h < f.length; h++) k[f[h]] = ++this._nodePriorityIndex
- }
- this._globalZOrderNodeMap = {}
- }
- },
- _sortNumberAsc: function(a, c) {
- return a - c
- },
- addListener: function(a, c) {
- cc.assert(a && c, cc._LogInfos.eventManager_addListener_2);
- if (a instanceof cc.EventListener) {
- if (a._isRegistered()) {
- cc.log(cc._LogInfos.eventManager_addListener_4);
- return
- }
- } else cc.assert("number" !== typeof c, cc._LogInfos.eventManager_addListener_3), a = cc.EventListener.create(a);
- a.checkAvailable() && ("number" == typeof c ? 0 == c ? cc.log(cc._LogInfos.eventManager_addListener) : (a._setSceneGraphPriority(null), a._setFixedPriority(c), a._setRegistered(!0), a._setPaused(!1), this._addListener(a)) : (a._setSceneGraphPriority(c), a._setFixedPriority(0), a._setRegistered(!0), this._addListener(a)))
- },
- addCustomListener: function(a, c) {
- var d = cc._EventListenerCustom.create(a, c);
- this.addListener(d, 1);
- return d
- },
- removeListener: function(a) {
- if (null != a) {
- var c, d = this._listenersMap,
- e;
- for (e in d) {
- var f = d[e],
- g = f.getFixedPriorityListeners();
- c = f.getSceneGraphPriorityListeners();
- (c = this._removeListenerInVector(c, a)) ? this._setDirty(a._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY): (c = this._removeListenerInVector(g, a)) && this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY);
- f.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete d[e]);
- if (c) break
- }
- if (!c) {
- d = this._toAddedListeners;
- e = 0;
- for (f = d.length; e < f; e++)
- if (g = d[e], g == a) {
- cc.arrayRemoveObject(d, g);
- break
- }
- }
- }
- },
- _removeListenerInVector: function(a, c) {
- if (null == a) return !1;
- for (var d = 0, e = a.length; d < e; d++) {
- var f = a[d];
- if (f == c) return f._setRegistered(!1), null != f._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(f._getSceneGraphPriority(), f), f._setSceneGraphPriority(null)), 0 == this._inDispatch && cc.arrayRemoveObject(a, f), !0
- }
- return !1
- },
- removeListeners: function(a, c) {
- if (a instanceof cc.Node) {
- delete this._nodePriorityMap[a.__instanceId];
- cc.arrayRemoveObject(this._dirtyNodes, a);
- var d = this._nodeListenersMap[a.__instanceId];
- if (d) {
- for (var e = cc.copyArray(d), d = 0; d < e.length; d++) this.removeListener(e[d]);
- e.length = 0;
- e = this._toAddedListeners;
- for (d = 0; d < e.length;) {
- var f = e[d];
- f._getSceneGraphPriority() == a ? (f._setSceneGraphPriority(null), f._setRegistered(!1), e.splice(d, 1)) : ++d
- }
- if (!0 === c) {
- e = a.getChildren();
- d = 0;
- for (f = e.length; d < f; d++) this.removeListeners(e[d], !0)
- }
- }
- } else a == cc.EventListener.TOUCH_ONE_BY_ONE ? this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID) : a == cc.EventListener.TOUCH_ALL_AT_ONCE ? this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID) : a == cc.EventListener.MOUSE ? this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID) : a == cc.EventListener.ACCELERATION ? this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID) : a == cc.EventListener.KEYBOARD ? this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID) : cc.log(cc._LogInfos.eventManager_removeListeners)
- },
- removeCustomListeners: function(a) {
- this._removeListenersForListenerID(a)
- },
- removeAllListeners: function() {
- var a = this._listenersMap,
- c = this._internalCustomListenerIDs,
- d;
- for (d in a) - 1 === c.indexOf(d) && this._removeListenersForListenerID(d)
- },
- setPriority: function(a, c) {
- if (null != a) {
- var d = this._listenersMap,
- e;
- for (e in d) {
- var f = d[e].getFixedPriorityListeners();
- if (f && -1 != f.indexOf(a)) {
- null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority);
- a._getFixedPriority() !== c && (a._setFixedPriority(c), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY));
- break
- }
- }
- }
- },
- setEnabled: function(a) {
- this._isEnabled = a
- },
- isEnabled: function() {
- return this._isEnabled
- },
- dispatchEvent: function(a) {
- if (this._isEnabled) {
- this._updateDirtyFlagForSceneGraph();
- this._inDispatch++;
- if (!a || !a.getType) throw "event is undefined";
- if (a.getType() == cc.Event.TOUCH) this._dispatchTouchEvent(a);
- else {
- var c = cc.__getListenerID(a);
- this._sortEventListeners(c);
- c = this._listenersMap[c];
- null != c && this._dispatchEventToListeners(c, this._onListenerCallback, a);
- this._updateListeners(a)
- }
- this._inDispatch--
- }
- },
- _onListenerCallback: function(a, c) {
- c._setCurrentTarget(a._getSceneGraphPriority());
- a._onEvent(c);
- return c.isStopped()
- },
- dispatchCustomEvent: function(a, c) {
- var d = new cc.EventCustom(a);
- d.setUserData(c);
- this.dispatchEvent(d)
- }
- };
- cc.EventAcceleration = cc.Event.extend({
- _acc: null,
- ctor: function(a) {
- cc.Event.prototype.ctor.call(this, cc.Event.ACCELERATION);
- this._acc = a
- }
- });
- cc.EventKeyboard = cc.Event.extend({
- _keyCode: 0,
- _isPressed: !1,
- ctor: function(a, c) {
- cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD);
- this._keyCode = a;
- this._isPressed = c
- }
- });
- cc._EventListenerAcceleration = cc.EventListener.extend({
- _onAccelerationEvent: null,
- ctor: function(a) {
- this._onAccelerationEvent = a;
- var c = this;
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.ACCELERATION, cc._EventListenerAcceleration.LISTENER_ID, function(a) {
- c._onAccelerationEvent(a._acc, a)
- })
- },
- checkAvailable: function() {
- cc.assert(this._onAccelerationEvent, cc._LogInfos._EventListenerAcceleration_checkAvailable);
- return !0
- },
- clone: function() {
- return new cc._EventListenerAcceleration(this._onAccelerationEvent)
- }
- });
- cc._EventListenerAcceleration.LISTENER_ID = "__cc_acceleration";
- cc._EventListenerAcceleration.create = function(a) {
- return new cc._EventListenerAcceleration(a)
- };
- cc._EventListenerKeyboard = cc.EventListener.extend({
- onKeyPressed: null,
- onKeyReleased: null,
- ctor: function() {
- var a = this;
- cc.EventListener.prototype.ctor.call(this, cc.EventListener.KEYBOARD, cc._EventListenerKeyboard.LISTENER_ID, function(c) {
- if (c._isPressed) {
- if (a.onKeyPressed) a.onKeyPressed(c._keyCode, c)
- } else if (a.onKeyReleased) a.onKeyReleased(c._keyCode, c)
- })
- },
- clone: function() {
- var a = new cc._EventListenerKeyboard;
- a.onKeyPressed = this.onKeyPressed;
- a.onKeyReleased = this.onKeyReleased;
- return a
- },
- checkAvailable: function() {
- return null == this.onKeyPressed && null == this.onKeyReleased ? (cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable), !1) : !0
- }
- });
- cc._EventListenerKeyboard.LISTENER_ID = "__cc_keyboard";
- cc._EventListenerKeyboard.create = function() {
- return new cc._EventListenerKeyboard
- };
- cc._tmp.WebGLCCNode = function() {
- var a = cc.Node.prototype;
- a._transform4x4 = null;
- a._stackMatrix = null;
- a._glServerState = null;
- a._camera = null;
- a.ctor = function() {
- this._initNode();
- var a = new cc.kmMat4;
- a.mat[2] = a.mat[3] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[14] = 0;
- a.mat[10] = a.mat[15] = 1;
- this._transform4x4 = a;
- this._glServerState = 0;
- this._stackMatrix = new cc.kmMat4
- };
- a.setNodeDirty = function() {
- !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
- };
- a.visit = function() {
- if (this._visible) {
- var a = cc._renderContext,
- d, e = cc.current_stack;
- e.stack.push(e.top);
- cc.kmMat4Assign(this._stackMatrix, e.top);
- e.top = this._stackMatrix;
- var f = this.grid;
- f && f._active && f.beforeDraw();
- this.transform();
- var g = this._children;
- if (g && 0 < g.length) {
- var h = g.length;
- this.sortAllChildren();
- for (d = 0; d < h; d++)
- if (g[d] && 0 > g[d]._localZOrder) g[d].visit();
- else break;
- for (this.draw(a); d < h; d++) g[d] && g[d].visit()
- } else this.draw(a);
- this.arrivalOrder = 0;
- f && f._active && f.afterDraw(this);
- e.top = e.stack.pop()
- }
- };
- a.transform = function() {
- var a = this._transform4x4,
- d = cc.current_stack.top,
- e = this.nodeToParentTransform(),
- f = a.mat;
- f[0] = e.a;
- f[4] = e.c;
- f[12] = e.tx;
- f[1] = e.b;
- f[5] = e.d;
- f[13] = e.ty;
- f[14] = this._vertexZ;
- cc.kmMat4Multiply(d, d, a);
- null != this._camera && !(null != this.grid && this.grid.isActive()) && (a = this._anchorPointInPoints.x, d = this._anchorPointInPoints.y, 0 !== a || 0 !== d ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (a |= 0, d |= 0), cc.kmGLTranslatef(a, d, 0), this._camera.locate(), cc.kmGLTranslatef(-a, -d, 0)) : this._camera.locate())
- };
- a.getNodeToParentTransform = a._getNodeToParentTransformForWebGL
- };
- cc._tmp.PrototypeCCNode = function() {
- var a = cc.Node.prototype;
- cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX);
- cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY);
- cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
- cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight);
- cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX);
- cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY);
- cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX);
- cc.defineGetterSetter(a, "skewY", a.getSkewY, a.setSkewY);
- cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder);
- cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ);
- cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation);
- cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX);
- cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY);
- cc.defineGetterSetter(a, "scale", a.getScale, a.setScale);
- cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX);
- cc.defineGetterSetter(a, "scaleY", a.getScaleY, a.setScaleY);
- cc.defineGetterSetter(a, "children", a.getChildren);
- cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount);
- cc.defineGetterSetter(a, "parent", a.getParent, a.setParent);
- cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible);
- cc.defineGetterSetter(a, "running", a.isRunning);
- cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition);
- cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager);
- cc.defineGetterSetter(a, "scheduler", a.getScheduler, a.setScheduler);
- cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram);
- cc.defineGetterSetter(a, "glServerState", a.getGLServerState, a.setGLServerState);
- cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
- cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
- cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
- cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
- cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
- };
- cc.NODE_TAG_INVALID = -1;
- cc.s_globalOrderOfArrival = 1;
- cc.Node = cc.Class.extend({
- _localZOrder: 0,
- _globalZOrder: 0,
- _vertexZ: 0,
- _rotationX: 0,
- _rotationY: 0,
- _scaleX: 1,
- _scaleY: 1,
- _position: null,
- _skewX: 0,
- _skewY: 0,
- _children: null,
- _visible: !0,
- _anchorPoint: null,
- _anchorPointInPoints: null,
- _contentSize: null,
- _running: !1,
- _parent: null,
- _ignoreAnchorPointForPosition: !1,
- tag: cc.NODE_TAG_INVALID,
- userData: null,
- userObject: null,
- _transformDirty: !0,
- _inverseDirty: !0,
- _cacheDirty: !0,
- _cachedParent: null,
- _transformGLDirty: null,
- _transform: null,
- _inverse: null,
- _reorderChildDirty: !1,
- _shaderProgram: null,
- arrivalOrder: 0,
- _actionManager: null,
- _scheduler: null,
- _eventDispatcher: null,
- _initializedNode: !1,
- _additionalTransformDirty: !1,
- _additionalTransform: null,
- _componentContainer: null,
- _isTransitionFinished: !1,
- _rotationRadiansX: 0,
- _rotationRadiansY: 0,
- _className: "Node",
- _showNode: !1,
- _name: "",
- _displayedOpacity: 255,
- _realOpacity: 255,
- _displayedColor: null,
- _realColor: null,
- _cascadeColorEnabled: !1,
- _cascadeOpacityEnabled: !1,
- _usingNormalizedPosition: !1,
- _hashOfName: 0,
- _initNode: function() {
- this._anchorPoint = cc.p(0, 0);
- this._anchorPointInPoints = cc.p(0, 0);
- this._contentSize = cc.size(0, 0);
- this._position = cc.p(0, 0);
- this._children = [];
- this._transform = {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- tx: 0,
- ty: 0
- };
- var a = cc.director;
- this._actionManager = a.getActionManager();
- this._scheduler = a.getScheduler();
- this._initializedNode = !0;
- this._additionalTransform = cc.affineTransformMakeIdentity();
- cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this));
- this._realOpacity = this._displayedOpacity = 255;
- this._displayedColor = cc.color(255, 255, 255, 255);
- this._realColor = cc.color(255, 255, 255, 255);
- this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1
- },
- init: function() {
- !1 === this._initializedNode && this._initNode();
- return !0
- },
- _arrayMakeObjectsPerformSelector: function(a, c) {
- if (a && 0 !== a.length) {
- var d, e = a.length,
- f;
- d = cc.Node.StateCallbackType;
- switch (c) {
- case d.onEnter:
- for (d = 0; d < e; d++)
- if (f = a[d]) f.onEnter();
- break;
- case d.onExit:
- for (d = 0; d < e; d++)
- if (f = a[d]) f.onExit();
- break;
- case d.onEnterTransitionDidFinish:
- for (d = 0; d < e; d++)
- if (f = a[d]) f.onEnterTransitionDidFinish();
- break;
- case d.cleanup:
- for (d = 0; d < e; d++)(f = a[d]) && f.cleanup();
- break;
- case d.updateTransform:
- for (d = 0; d < e; d++)(f = a[d]) && f.updateTransform();
- break;
- case d.onExitTransitionDidStart:
- for (d = 0; d < e; d++)
- if (f = a[d]) f.onExitTransitionDidStart();
- break;
- case d.sortAllChildren:
- for (d = 0; d < e; d++)(f = a[d]) && f.sortAllChildren();
- break;
- default:
- cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector)
- }
- }
- },
- setNodeDirty: null,
- attr: function(a) {
- for (var c in a) this[c] = a[c]
- },
- getSkewX: function() {
- return this._skewX
- },
- setSkewX: function(a) {
- this._skewX = a;
- this.setNodeDirty()
- },
- getSkewY: function() {
- return this._skewY
- },
- setSkewY: function(a) {
- this._skewY = a;
- this.setNodeDirty()
- },
- setLocalZOrder: function(a) {
- this._localZOrder = a;
- this._parent && this._parent.reorderChild(this, a);
- cc.eventManager._setDirtyForNode(this)
- },
- _setLocalZOrder: function(a) {
- this._localZOrder = a
- },
- getLocalZOrder: function() {
- return this._localZOrder
- },
- getZOrder: function() {
- cc.log(cc._LogInfos.Node_getZOrder);
- return this.getLocalZOrder()
- },
- setZOrder: function(a) {
- cc.log(cc._LogInfos.Node_setZOrder);
- this.setLocalZOrder(a)
- },
- setGlobalZOrder: function(a) {
- this._globalZOrder != a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this))
- },
- getGlobalZOrder: function() {
- return this._globalZOrder
- },
- getVertexZ: function() {
- return this._vertexZ
- },
- setVertexZ: function(a) {
- this._vertexZ = a
- },
- getRotation: function() {
- this._rotationX !== this._rotationY && cc.log(cc._LogInfos.Node_getRotation);
- return this._rotationX
- },
- setRotation: function(a) {
- this._rotationX = this._rotationY = a;
- this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
- this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
- this.setNodeDirty()
- },
- getRotationX: function() {
- return this._rotationX
- },
- setRotationX: function(a) {
- this._rotationX = a;
- this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
- this.setNodeDirty()
- },
- getRotationY: function() {
- return this._rotationY
- },
- setRotationY: function(a) {
- this._rotationY = a;
- this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
- this.setNodeDirty()
- },
- getScale: function() {
- this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale);
- return this._scaleX
- },
- setScale: function(a, c) {
- this._scaleX = a;
- this._scaleY = c || 0 === c ? c : a;
- this.setNodeDirty()
- },
- getScaleX: function() {
- return this._scaleX
- },
- setScaleX: function(a) {
- this._scaleX = a;
- this.setNodeDirty()
- },
- getScaleY: function() {
- return this._scaleY
- },
- setScaleY: function(a) {
- this._scaleY = a;
- this.setNodeDirty()
- },
- setPosition: function(a, c) {
- var d = this._position;
- void 0 === c ? (d.x = a.x, d.y = a.y) : (d.x = a, d.y = c);
- this.setNodeDirty()
- },
- getPosition: function() {
- return cc.p(this._position)
- },
- getPositionX: function() {
- return this._position.x
- },
- setPositionX: function(a) {
- this._position.x = a;
- this.setNodeDirty()
- },
- getPositionY: function() {
- return this._position.y
- },
- setPositionY: function(a) {
- this._position.y = a;
- this.setNodeDirty()
- },
- getChildrenCount: function() {
- return this._children.length
- },
- getChildren: function() {
- return this._children
- },
- isVisible: function() {
- return this._visible
- },
- setVisible: function(a) {
- this._visible != a && (this._visible = a) && this.setNodeDirty()
- },
- getAnchorPoint: function() {
- return cc.p(this._anchorPoint)
- },
- setAnchorPoint: function(a, c) {
- var d = this._anchorPoint;
- if (void 0 === c) {
- if (a.x === d.x && a.y === d.y) return;
- d.x = a.x;
- d.y = a.y
- } else {
- if (a === d.x && c === d.y) return;
- d.x = a;
- d.y = c
- }
- var e = this._anchorPointInPoints,
- f = this._contentSize;
- e.x = f.width * d.x;
- e.y = f.height * d.y;
- this.setNodeDirty()
- },
- _getAnchor: function() {
- return this._anchorPoint
- },
- _setAnchor: function(a) {
- var c = a.x;
- a = a.y;
- this._anchorPoint.x !== c && (this._anchorPoint.x = c, this._anchorPointInPoints.x = this._contentSize.width * c);
- this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a);
- this.setNodeDirty()
- },
- _getAnchorX: function() {
- return this._anchorPoint.x
- },
- _setAnchorX: function(a) {
- this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._anchorPointInPoints.x = this._contentSize.width * a, this.setNodeDirty())
- },
- _getAnchorY: function() {
- return this._anchorPoint.y
- },
- _setAnchorY: function(a) {
- this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a, this.setNodeDirty())
- },
- getAnchorPointInPoints: function() {
- return cc.p(this._anchorPointInPoints)
- },
- _getWidth: function() {
- return this._contentSize.width
- },
- _setWidth: function(a) {
- this._contentSize.width = a;
- this._anchorPointInPoints.x = a * this._anchorPoint.x;
- this.setNodeDirty()
- },
- _getHeight: function() {
- return this._contentSize.height
- },
- _setHeight: function(a) {
- this._contentSize.height = a;
- this._anchorPointInPoints.y = a * this._anchorPoint.y;
- this.setNodeDirty()
- },
- getContentSize: function() {
- return cc.size(this._contentSize)
- },
- setContentSize: function(a, c) {
- var d = this._contentSize;
- if (void 0 === c) {
- if (a.width === d.width && a.height === d.height) return;
- d.width = a.width;
- d.height = a.height
- } else {
- if (a === d.width && c === d.height) return;
- d.width = a;
- d.height = c
- }
- var e = this._anchorPointInPoints,
- f = this._anchorPoint;
- e.x = d.width * f.x;
- e.y = d.height * f.y;
- this.setNodeDirty()
- },
- isRunning: function() {
- return this._running
- },
- getParent: function() {
- return this._parent
- },
- setParent: function(a) {
- this._parent = a
- },
- isIgnoreAnchorPointForPosition: function() {
- return this._ignoreAnchorPointForPosition
- },
- ignoreAnchorPointForPosition: function(a) {
- a != this._ignoreAnchorPointForPosition && (this._ignoreAnchorPointForPosition = a, this.setNodeDirty())
- },
- getTag: function() {
- return this.tag
- },
- setTag: function(a) {
- this.tag = a
- },
- setName: function(a) {
- this._name = a
- },
- getName: function() {
- return this._name
- },
- getUserData: function() {
- return this.userData
- },
- setUserData: function(a) {
- this.userData = a
- },
- getUserObject: function() {
- return this.userObject
- },
- setUserObject: function(a) {
- this.userObject != a && (this.userObject = a)
- },
- getOrderOfArrival: function() {
- return this.arrivalOrder
- },
- setOrderOfArrival: function(a) {
- if (NaN == this.arrivalOrder) debugger;
- this.arrivalOrder = a
- },
- getActionManager: function() {
- this._actionManager || (this._actionManager = cc.director.getActionManager());
- return this._actionManager
- },
- setActionManager: function(a) {
- this._actionManager != a && (this.stopAllActions(), this._actionManager = a)
- },
- getScheduler: function() {
- this._scheduler || (this._scheduler = cc.director.getScheduler());
- return this._scheduler
- },
- setScheduler: function(a) {
- this._scheduler != a && (this.unscheduleAllCallbacks(), this._scheduler = a)
- },
- boundingBox: function() {
- cc.log(cc._LogInfos.Node_boundingBox);
- return this.getBoundingBox()
- },
- getBoundingBox: function() {
- var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
- return cc._rectApplyAffineTransformIn(a, this.getNodeToParentTransform())
- },
- cleanup: function() {
- this.stopAllActions();
- this.unscheduleAllCallbacks();
- cc.eventManager.removeListeners(this);
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup)
- },
- getChildByTag: function(a) {
- var c = this._children;
- if (null != c)
- for (var d = 0; d < c.length; d++) {
- var e = c[d];
- if (e && e.tag == a) return e
- }
- return null
- },
- getChildByName: function(a) {
- if (!a) return cc.log("Invalid name"), null;
- for (var c = this._children, d = 0, e = c.length; d < e; d++)
- if (c[d]._name == a) return c[d];
- return null
- },
- addChild: function(a, c, d) {
- c = void 0 === c ? a._localZOrder : c;
- var e, f = !1;
- switch (typeof d) {
- case "undefined":
- d = void 0;
- e = a._name;
- break;
- case "string":
- e = d;
- d = void 0;
- break;
- case "number":
- f = !0, e = ""
- }
- cc.assert(a, cc._LogInfos.Node_addChild_3);
- cc.assert(null === a._parent, "child already added. It can't be added again");
- this.addChildHelper(a, c, d, e, f)
- },
- addChildHelper: function(a, c, d, e, f) {
- this._children || (this._children = []);
- this._insertChild(a, c);
- f ? a.setTag(d) : a.setName(e);
- a.setParent(this);
- a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
- if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
- this._cascadeColorEnabled && this._enableCascadeColor();
- this._cascadeOpacityEnabled && this._enableCascadeOpacity()
- },
- removeFromParent: function(a) {
- this._parent && (null == a && (a = !0), this._parent.removeChild(this, a))
- },
- removeFromParentAndCleanup: function(a) {
- cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
- this.removeFromParent(a)
- },
- removeChild: function(a, c) {
- 0 !== this._children.length && (null == c && (c = !0), -1 < this._children.indexOf(a) && this._detachChild(a, c), this.setNodeDirty())
- },
- removeChildByTag: function(a, c) {
- a === cc.NODE_TAG_INVALID && cc.log(cc._LogInfos.Node_removeChildByTag);
- var d = this.getChildByTag(a);
- null == d ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(d, c)
- },
- removeAllChildrenWithCleanup: function(a) {
- cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup);
- this.removeAllChildren(a)
- },
- removeAllChildren: function(a) {
- var c = this._children;
- if (null != c) {
- null == a && (a = !0);
- for (var d = 0; d < c.length; d++) {
- var e = c[d];
- e && (this._running && (e.onExitTransitionDidStart(), e.onExit()), a && e.cleanup(), e.parent = null)
- }
- this._children.length = 0
- }
- },
- _detachChild: function(a, c) {
- this._running && (a.onExitTransitionDidStart(), a.onExit());
- c && a.cleanup();
- a.parent = null;
- cc.arrayRemoveObject(this._children, a)
- },
- _insertChild: function(a, c) {
- this._reorderChildDirty = !0;
- this._children.push(a);
- a._setLocalZOrder(c)
- },
- reorderChild: function(a, c) {
- cc.assert(a, cc._LogInfos.Node_reorderChild);
- this._reorderChildDirty = !0;
- a.arrivalOrder = cc.s_globalOrderOfArrival;
- cc.s_globalOrderOfArrival++;
- a._setLocalZOrder(c);
- this.setNodeDirty()
- },
- sortAllChildren: function() {
- if (this._reorderChildDirty) {
- var a = this._children,
- c = a.length,
- d, e, f;
- for (d = 1; d < c; d++) {
- f = a[d];
- for (e = d - 1; 0 <= e;) {
- if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
- else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
- else break;
- e--
- }
- a[e + 1] = f
- }
- this._reorderChildDirty = !1
- }
- },
- draw: function(a) {},
- transformAncestors: function() {
- null != this._parent && (this._parent.transformAncestors(), this._parent.transform())
- },
- onEnter: function() {
- this._isTransitionFinished = !1;
- this._running = !0;
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter);
- this.resume()
- },
- onEnterTransitionDidFinish: function() {
- this._isTransitionFinished = !0;
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnterTransitionDidFinish)
- },
- onExitTransitionDidStart: function() {
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExitTransitionDidStart)
- },
- onExit: function() {
- this._running = !1;
- this.pause();
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit)
- },
- runAction: function(a) {
- cc.assert(a, cc._LogInfos.Node_runAction);
- this.actionManager.addAction(a, this, !this._running);
- return a
- },
- stopAllActions: function() {
- this.actionManager && this.actionManager.removeAllActionsFromTarget(this)
- },
- stopAction: function(a) {
- this.actionManager.removeAction(a)
- },
- stopActionByTag: function(a) {
- a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) : this.actionManager.removeActionByTag(a, this)
- },
- getActionByTag: function(a) {
- return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this)
- },
- getNumberOfRunningActions: function() {
- return this.actionManager.numberOfRunningActionsInTarget(this)
- },
- scheduleUpdate: function() {
- this.scheduleUpdateWithPriority(0)
- },
- scheduleUpdateWithPriority: function(a) {
- this.scheduler.scheduleUpdateForTarget(this, a, !this._running)
- },
- unscheduleUpdate: function() {
- this.scheduler.unscheduleUpdateForTarget(this)
- },
- schedule: function(a, c, d, e) {
- c = c || 0;
- cc.assert(a, cc._LogInfos.Node_schedule);
- cc.assert(0 <= c, cc._LogInfos.Node_schedule_2);
- d = null == d ? cc.REPEAT_FOREVER : d;
- this.scheduler.scheduleCallbackForTarget(this, a, c, d, e || 0, !this._running)
- },
- scheduleOnce: function(a, c) {
- this.schedule(a, 0, 0, c)
- },
- unschedule: function(a) {
- a && this.scheduler.unscheduleCallbackForTarget(this, a)
- },
- unscheduleAllCallbacks: function() {
- this.scheduler.unscheduleAllCallbacksForTarget(this)
- },
- resumeSchedulerAndActions: function() {
- cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);
- this.resume()
- },
- resume: function() {
- this.scheduler.resumeTarget(this);
- this.actionManager && this.actionManager.resumeTarget(this);
- cc.eventManager.resumeTarget(this)
- },
- pauseSchedulerAndActions: function() {
- cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
- this.pause()
- },
- pause: function() {
- this.scheduler.pauseTarget(this);
- this.actionManager && this.actionManager.pauseTarget(this);
- cc.eventManager.pauseTarget(this)
- },
- setAdditionalTransform: function(a) {
- this._additionalTransform = a;
- this._additionalTransformDirty = this._transformDirty = !0
- },
- getParentToNodeTransform: function() {
- this._inverseDirty && (this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()), this._inverseDirty = !1);
- return this._inverse
- },
- parentToNodeTransform: function() {
- return this.getParentToNodeTransform()
- },
- getNodeToWorldTransform: function() {
- for (var a = this.getNodeToParentTransform(), c = this._parent; null != c; c = c.parent) a = cc.affineTransformConcat(a, c.getNodeToParentTransform());
- return a
- },
- nodeToWorldTransform: function() {
- return this.getNodeToWorldTransform()
- },
- getWorldToNodeTransform: function() {
- return cc.affineTransformInvert(this.getNodeToWorldTransform())
- },
- worldToNodeTransform: function() {
- return this.getWorldToNodeTransform()
- },
- convertToNodeSpace: function(a) {
- return cc.pointApplyAffineTransform(a, this.getWorldToNodeTransform())
- },
- convertToWorldSpace: function(a) {
- a = a || cc.p(0, 0);
- return cc.pointApplyAffineTransform(a, this.getNodeToWorldTransform())
- },
- convertToNodeSpaceAR: function(a) {
- return cc.pSub(this.convertToNodeSpace(a), this._anchorPointInPoints)
- },
- convertToWorldSpaceAR: function(a) {
- a = a || cc.p(0, 0);
- a = cc.pAdd(a, this._anchorPointInPoints);
- return this.convertToWorldSpace(a)
- },
- _convertToWindowSpace: function(a) {
- a = this.convertToWorldSpace(a);
- return cc.director.convertToUI(a)
- },
- convertTouchToNodeSpace: function(a) {
- a = a.getLocation();
- return this.convertToNodeSpace(a)
- },
- convertTouchToNodeSpaceAR: function(a) {
- a = a.getLocation();
- a = cc.director.convertToGL(a);
- return this.convertToNodeSpaceAR(a)
- },
- update: function(a) {
- this._componentContainer && !this._componentContainer.isEmpty() && this._componentContainer.visit(a)
- },
- updateTransform: function() {
- this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
- },
- retain: function() {},
- release: function() {},
- getComponent: function(a) {
- return this._componentContainer.getComponent(a)
- },
- addComponent: function(a) {
- this._componentContainer.add(a)
- },
- removeComponent: function(a) {
- return this._componentContainer.remove(a)
- },
- removeAllComponents: function() {
- this._componentContainer.removeAll()
- },
- grid: null,
- ctor: null,
- visit: null,
- transform: null,
- nodeToParentTransform: function() {
- return this.getNodeToParentTransform()
- },
- getNodeToParentTransform: null,
- _setNodeDirtyForCache: function() {
- if (!1 === this._cacheDirty) {
- this._cacheDirty = !0;
- var a = this._cachedParent;
- a && a != this && a._setNodeDirtyForCache()
- }
- },
- _setCachedParent: function(a) {
- if (this._cachedParent != a) {
- this._cachedParent = a;
- for (var c = this._children, d = 0, e = c.length; d < e; d++) c[d]._setCachedParent(a)
- }
- },
- getCamera: function() {
- this._camera || (this._camera = new cc.Camera);
- return this._camera
- },
- getGrid: function() {
- return this.grid
- },
- setGrid: function(a) {
- this.grid = a
- },
- getShaderProgram: function() {
- return this._shaderProgram
- },
- setShaderProgram: function(a) {
- this._shaderProgram = a
- },
- getGLServerState: function() {
- return this._glServerState
- },
- setGLServerState: function(a) {
- this._glServerState = a
- },
- getBoundingBoxToWorld: function() {
- var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
- c = this.nodeToWorldTransform(),
- a = cc.rectApplyAffineTransform(a, this.nodeToWorldTransform());
- if (!this._children) return a;
- for (var d = this._children, e = 0; e < d.length; e++) {
- var f = d[e];
- f && f._visible && (f = f._getBoundingBoxToCurrentNode(c)) && (a = cc.rectUnion(a, f))
- }
- return a
- },
- _getBoundingBoxToCurrentNode: function(a) {
- var c = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
- a = null == a ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), a);
- c = cc.rectApplyAffineTransform(c, a);
- if (!this._children) return c;
- for (var d = this._children, e = 0; e < d.length; e++) {
- var f = d[e];
- f && f._visible && (f = f._getBoundingBoxToCurrentNode(a)) && (c = cc.rectUnion(c, f))
- }
- return c
- },
- _getNodeToParentTransformForWebGL: function() {
- if (this._transformDirty) {
- var a = this._position.x,
- c = this._position.y,
- d = this._anchorPointInPoints.x,
- e = -d,
- f = this._anchorPointInPoints.y,
- g = -f,
- h = this._scaleX,
- k = this._scaleY;
- this._ignoreAnchorPointForPosition && (a += d, c += f);
- var m = 1,
- n = 0,
- q = 1,
- r = 0;
- if (0 !== this._rotationX || 0 !== this._rotationY) m = Math.cos(-this._rotationRadiansX), n = Math.sin(-this._rotationRadiansX), q = Math.cos(-this._rotationRadiansY), r = Math.sin(-this._rotationRadiansY);
- var t = this._skewX || this._skewY;
- if (!t && (0 !== d || 0 !== f)) a += q * e * h + -n * g * k, c += r * e * h + m * g * k;
- var s = this._transform;
- s.a = q * h;
- s.b = r * h;
- s.c = -n * k;
- s.d = m * k;
- s.tx = a;
- s.ty = c;
- if (t && (s = cc.affineTransformConcat({
- a: 1,
- b: Math.tan(cc.degreesToRadians(this._skewY)),
- c: Math.tan(cc.degreesToRadians(this._skewX)),
- d: 1,
- tx: 0,
- ty: 0
- }, s), 0 !== d || 0 !== f)) s = cc.affineTransformTranslate(s, e, g);
- this._additionalTransformDirty && (s = cc.affineTransformConcat(s, this._additionalTransform), this._additionalTransformDirty = !1);
- this._transform = s;
- this._transformDirty = !1
- }
- return this._transform
- },
- _updateColor: function() {},
- getOpacity: function() {
- return this._realOpacity
- },
- getDisplayedOpacity: function() {
- return this._displayedOpacity
- },
- setOpacity: function(a) {
- this._displayedOpacity = this._realOpacity = a;
- var c = 255,
- d = this._parent;
- d && d.cascadeOpacity && (c = d.getDisplayedOpacity());
- this.updateDisplayedOpacity(c);
- this._displayedColor.a = this._realColor.a = a
- },
- updateDisplayedOpacity: function(a) {
- this._displayedOpacity = this._realOpacity * a / 255;
- if (this._cascadeOpacityEnabled) {
- a = this._children;
- for (var c = 0; c < a.length; c++) {
- var d = a[c];
- d && d.updateDisplayedOpacity(this._displayedOpacity)
- }
- }
- },
- isCascadeOpacityEnabled: function() {
- return this._cascadeOpacityEnabled
- },
- setCascadeOpacityEnabled: function(a) {
- this._cascadeOpacityEnabled !== a && ((this._cascadeOpacityEnabled = a) ? this._enableCascadeOpacity() : this._disableCascadeOpacity())
- },
- _enableCascadeOpacity: function() {
- var a = 255,
- c = this._parent;
- c && c.cascadeOpacity && (a = c.getDisplayedOpacity());
- this.updateDisplayedOpacity(a)
- },
- _disableCascadeOpacity: function() {
- this._displayedOpacity = this._realOpacity;
- for (var a = this._children, c = 0; c < a.length; c++) {
- var d = a[c];
- d && d.updateDisplayedOpacity(255)
- }
- },
- getColor: function() {
- var a = this._realColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getDisplayedColor: function() {
- var a = this._displayedColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- setColor: function(a) {
- var c = this._displayedColor,
- d = this._realColor;
- c.r = d.r = a.r;
- c.g = d.g = a.g;
- c.b = d.b = a.b;
- a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
- this.updateDisplayedColor(a)
- },
- updateDisplayedColor: function(a) {
- var c = this._displayedColor,
- d = this._realColor;
- c.r = 0 | d.r * a.r / 255;
- c.g = 0 | d.g * a.g / 255;
- c.b = 0 | d.b * a.b / 255;
- if (this._cascadeColorEnabled) {
- a = this._children;
- for (d = 0; d < a.length; d++) {
- var e = a[d];
- e && e.updateDisplayedColor(c)
- }
- }
- },
- isCascadeColorEnabled: function() {
- return this._cascadeColorEnabled
- },
- setCascadeColorEnabled: function(a) {
- this._cascadeColorEnabled !== a && ((this._cascadeColorEnabled = a) ? this._enableCascadeColor() : this._disableCascadeColor())
- },
- _enableCascadeColor: function() {
- var a;
- a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
- this.updateDisplayedColor(a)
- },
- _disableCascadeColor: function() {
- var a = this._displayedColor,
- c = this._realColor;
- a.r = c.r;
- a.g = c.g;
- a.b = c.b;
- for (var a = this._children, c = cc.color.WHITE, d = 0; d < a.length; d++) {
- var e = a[d];
- e && e.updateDisplayedColor(c)
- }
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- }
- });
- cc.Node.create = function() {
- return new cc.Node
- };
- cc.Node.StateCallbackType = {
- onEnter: 1,
- onExit: 2,
- cleanup: 3,
- onEnterTransitionDidFinish: 4,
- updateTransform: 5,
- onExitTransitionDidStart: 6,
- sortAllChildren: 7
- };
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Node.prototype, _p.ctor = function() {
- this._initNode()
- }, _p.setNodeDirty = function() {
- this._setNodeDirtyForCache();
- !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
- }, _p.visit = function(a) {
- if (this._visible) {
- a = a || cc._renderContext;
- var c, d = this._children,
- e;
- a.save();
- this.transform(a);
- var f = d.length;
- if (0 < f) {
- this.sortAllChildren();
- for (c = 0; c < f; c++)
- if (e = d[c], 0 > e._localZOrder) e.visit(a);
- else break;
- for (this.draw(a); c < f; c++) d[c].visit(a)
- } else this.draw(a);
- this._cacheDirty = !1;
- this.arrivalOrder = 0;
- a.restore()
- }
- }, _p.transform = function(a) {
- a = a || cc._renderContext;
- var c = cc.view,
- d = this.getNodeToParentTransform();
- a.transform(d.a, d.c, d.b, d.d, d.tx * c.getScaleX(), -d.ty * c.getScaleY())
- }, _p.getNodeToParentTransform = function() {
- if (this._transformDirty) {
- var a = this._transform;
- a.tx = this._position.x;
- a.ty = this._position.y;
- var c = 1,
- d = 0;
- this._rotationX && (c = Math.cos(this._rotationRadiansX), d = Math.sin(this._rotationRadiansX));
- a.a = a.d = c;
- a.b = -d;
- a.c = d;
- var e = this._scaleX,
- f = this._scaleY,
- g = this._anchorPointInPoints.x,
- h = this._anchorPointInPoints.y,
- k = 1E-6 > e && -1E-6 < e ? 1E-6 : e,
- m = 1E-6 > f && -1E-6 < f ? 1E-6 : f;
- if (this._skewX || this._skewY) {
- var n = Math.tan(-this._skewX * Math.PI / 180),
- q = Math.tan(-this._skewY * Math.PI / 180);
- Infinity === n && (n = 99999999);
- Infinity === q && (q = 99999999);
- var r = h * n * k,
- t = g * q * m;
- a.a = c + -d * q;
- a.b = c * n + -d;
- a.c = d + c * q;
- a.d = d * n + c;
- a.tx += c * r + -d * t;
- a.ty += d * r + c * t
- }
- if (1 !== e || 1 !== f) a.a *= k, a.c *= k, a.b *= m, a.d *= m;
- a.tx += c * -g * k + -d * h * m;
- a.ty -= d * -g * k + c * h * m;
- this._ignoreAnchorPointForPosition && (a.tx += g, a.ty += h);
- this._additionalTransformDirty && (this._transform = cc.affineTransformConcat(a, this._additionalTransform), this._additionalTransformDirty = !1);
- this._transformDirty = !1
- }
- return this._transform
- }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLCCNode, cc._LogInfos.MissingFile, "BaseNodesWebGL.js"), cc._tmp.WebGLCCNode(), delete cc._tmp.WebGLCCNode);
- cc.assert("function" === typeof cc._tmp.PrototypeCCNode, cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
- cc._tmp.PrototypeCCNode();
- delete cc._tmp.PrototypeCCNode;
- cc.Node.ON_ENTER = 0;
- cc.Node.ON_EXIT = 1;
- cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
- cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
- cc.Node.ON_CLEAN_UP = 4;
- cc.AtlasNode = cc.Node.extend({
- textureAtlas: null,
- quadsToDraw: 0,
- _itemsPerRow: 0,
- _itemsPerColumn: 0,
- _itemWidth: 0,
- _itemHeight: 0,
- _colorUnmodified: null,
- _opacityModifyRGB: !1,
- _blendFunc: null,
- _ignoreContentScaleFactor: !1,
- _className: "AtlasNode",
- ctor: function(a, c, d, e) {
- cc.Node.prototype.ctor.call(this);
- this._colorUnmodified = cc.color.WHITE;
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- this._ignoreContentScaleFactor = !1;
- void 0 !== e && this.initWithTileFile(a, c, d, e)
- },
- updateAtlasValues: function() {
- cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)
- },
- getColor: function() {
- return this._opacityModifyRGB ? this._colorUnmodified : cc.Node.prototype.getColor.call(this)
- },
- setOpacityModifyRGB: function(a) {
- var c = this.color;
- this._opacityModifyRGB = a;
- this.color = c
- },
- isOpacityModifyRGB: function() {
- return this._opacityModifyRGB
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendFunc: function(a, c) {
- this._blendFunc = void 0 === c ? a : {
- src: a,
- dst: c
- }
- },
- setTextureAtlas: function(a) {
- this.textureAtlas = a
- },
- getTextureAtlas: function() {
- return this.textureAtlas
- },
- getQuadsToDraw: function() {
- return this.quadsToDraw
- },
- setQuadsToDraw: function(a) {
- this.quadsToDraw = a
- },
- _textureForCanvas: null,
- _originalTexture: null,
- _uniformColor: null,
- _colorF32Array: null,
- initWithTileFile: function(a, c, d, e) {
- if (!a) throw "cc.AtlasNode.initWithTileFile(): title should not be null";
- a = cc.textureCache.addImage(a);
- return this.initWithTexture(a, c, d, e)
- },
- initWithTexture: null,
- _initWithTextureForCanvas: function(a, c, d, e) {
- this._itemWidth = c;
- this._itemHeight = d;
- this._opacityModifyRGB = !0;
- this._originalTexture = a;
- if (!this._originalTexture) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
- this._textureForCanvas = this._originalTexture;
- this._calculateMaxItems();
- this.quadsToDraw = e;
- return !0
- },
- _initWithTextureForWebGL: function(a, c, d, e) {
- this._itemWidth = c;
- this._itemHeight = d;
- this._colorUnmodified = cc.color.WHITE;
- this._opacityModifyRGB = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- c = this._realColor;
- this._colorF32Array = new Float32Array([c.r / 255, c.g / 255, c.b / 255, this._realOpacity / 255]);
- this.textureAtlas = new cc.TextureAtlas;
- this.textureAtlas.initWithTexture(a, e);
- if (!this.textureAtlas) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
- this._updateBlendFunc();
- this._updateOpacityModifyRGB();
- this._calculateMaxItems();
- this.quadsToDraw = e;
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
- this._uniformColor = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), "u_color");
- return !0
- },
- draw: null,
- _drawForWebGL: function(a) {
- a = a || cc._renderContext;
- cc.nodeDrawSetup(this);
- cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
- this._uniformColor && this._colorF32Array && (a.uniform4fv(this._uniformColor, this._colorF32Array), this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0))
- },
- setColor: null,
- _setColorForCanvas: function(a) {
- var c = this._realColor;
- if (!(c.r == a.r && c.g == a.g && c.b == a.b)) {
- c = cc.color(a.r, a.g, a.b);
- this._colorUnmodified = a;
- if (this._opacityModifyRGB) {
- var d = this._displayedOpacity;
- c.r = c.r * d / 255;
- c.g = c.g * d / 255;
- c.b = c.b * d / 255
- }
- cc.Node.prototype.setColor.call(this, a);
- this._changeTextureColor()
- }
- },
- _changeTextureColor: function() {
- var a = this.getTexture();
- if (a && this._originalTexture) {
- var c = this._originalTexture.getHtmlElementObj();
- if (c) {
- var d = a.getHtmlElementObj(),
- a = cc.rect(0, 0, c.width, c.height);
- d instanceof HTMLCanvasElement ? cc.generateTintImageWithMultiply(c, this._displayedColor, a, d) : (d = cc.generateTintImageWithMultiply(c, this._displayedColor, a), a = new cc.Texture2D, a.initWithElement(d), a.handleLoadedTexture(), this.setTexture(a))
- }
- }
- },
- _setColorForWebGL: function(a) {
- var c = cc.color(a.r, a.g, a.b);
- this._colorUnmodified = a;
- var d = this._displayedOpacity;
- this._opacityModifyRGB && (c.r = c.r * d / 255, c.g = c.g * d / 255, c.b = c.b * d / 255);
- cc.Node.prototype.setColor.call(this, a);
- a = this._displayedColor;
- this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, d / 255])
- },
- setOpacity: function(a) {},
- _setOpacityForCanvas: function(a) {
- cc.Node.prototype.setOpacity.call(this, a);
- this._opacityModifyRGB && (this.color = this._colorUnmodified)
- },
- _setOpacityForWebGL: function(a) {
- cc.Node.prototype.setOpacity.call(this, a);
- this._opacityModifyRGB ? this.color = this._colorUnmodified : (a = this._displayedColor, this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, this._displayedOpacity / 255]))
- },
- getTexture: null,
- _getTextureForCanvas: function() {
- return this._textureForCanvas
- },
- _getTextureForWebGL: function() {
- return this.textureAtlas.texture
- },
- setTexture: null,
- _setTextureForCanvas: function(a) {
- this._textureForCanvas = a
- },
- _setTextureForWebGL: function(a) {
- this.textureAtlas.texture = a;
- this._updateBlendFunc();
- this._updateOpacityModifyRGB()
- },
- _calculateMaxItems: null,
- _calculateMaxItemsForCanvas: function() {
- var a = this.texture.getContentSize();
- this._itemsPerColumn = 0 | a.height / this._itemHeight;
- this._itemsPerRow = 0 | a.width / this._itemWidth
- },
- _calculateMaxItemsForWebGL: function() {
- var a = this.texture,
- c = a.getContentSize();
- this._ignoreContentScaleFactor && (c = a.getContentSizeInPixels());
- this._itemsPerColumn = 0 | c.height / this._itemHeight;
- this._itemsPerRow = 0 | c.width / this._itemWidth
- },
- _updateBlendFunc: function() {
- this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
- },
- _updateOpacityModifyRGB: function() {
- this._opacityModifyRGB = this.textureAtlas.texture.hasPremultipliedAlpha()
- },
- _setIgnoreContentScaleFactor: function(a) {
- this._ignoreContentScaleFactor = a
- }
- });
- _p = cc.AtlasNode.prototype;
- cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.initWithTexture = _p._initWithTextureForWebGL, _p.draw = _p._drawForWebGL, _p.setColor = _p._setColorForWebGL, _p.setOpacity = _p._setOpacityForWebGL, _p.getTexture = _p._getTextureForWebGL, _p.setTexture = _p._setTextureForWebGL, _p._calculateMaxItems = _p._calculateMaxItemsForWebGL) : (_p.initWithTexture = _p._initWithTextureForCanvas, _p.draw = cc.Node.prototype.draw, _p.setColor = _p._setColorForCanvas, _p.setOpacity = _p._setOpacityForCanvas, _p.getTexture = _p._getTextureForCanvas, _p.setTexture = _p._setTextureForCanvas, _p._calculateMaxItems = _p._calculateMaxItemsForCanvas, cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function() {
- var a, c = this.getTexture();
- if (c && this._originalTexture && (a = c.getHtmlElementObj())) {
- var d = this._originalTexture.getHtmlElementObj();
- if (c = cc.textureCache.getTextureColors(d)) d = cc.rect(0, 0, d.width, d.height), a instanceof HTMLCanvasElement ? cc.generateTintImage(a, c, this._displayedColor, d, a) : (a = cc.generateTintImage(a, c, this._displayedColor, d), c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.setTexture(c))
- }
- }));
- cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
- cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor);
- cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
- cc.AtlasNode.create = function(a, c, d, e) {
- return new cc.AtlasNode(a, c, d, e)
- };
- cc._tmp.WebGLTexture2D = function() {
- cc.Texture2D = cc.Class.extend({
- _pVRHaveAlphaPremultiplied: !0,
- _pixelFormat: null,
- _pixelsWide: 0,
- _pixelsHigh: 0,
- _name: "",
- _contentSize: null,
- maxS: 0,
- maxT: 0,
- _hasPremultipliedAlpha: !1,
- _hasMipmaps: !1,
- shaderProgram: null,
- _isLoaded: !1,
- _htmlElementObj: null,
- _webTextureObj: null,
- url: null,
- _loadedEventListeners: null,
- ctor: function() {
- this._contentSize = cc.size(0, 0);
- this._pixelFormat = cc.Texture2D.defaultPixelFormat
- },
- releaseTexture: function() {
- this._webTextureObj && cc._renderContext.deleteTexture(this._webTextureObj);
- cc.loader.release(this.url)
- },
- getPixelFormat: function() {
- return this._pixelFormat
- },
- getPixelsWide: function() {
- return this._pixelsWide
- },
- getPixelsHigh: function() {
- return this._pixelsHigh
- },
- getName: function() {
- return this._webTextureObj
- },
- getContentSize: function() {
- return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor())
- },
- _getWidth: function() {
- return this._contentSize.width / cc.contentScaleFactor()
- },
- _getHeight: function() {
- return this._contentSize.height / cc.contentScaleFactor()
- },
- getContentSizeInPixels: function() {
- return this._contentSize
- },
- getMaxS: function() {
- return this.maxS
- },
- setMaxS: function(a) {
- this.maxS = a
- },
- getMaxT: function() {
- return this.maxT
- },
- setMaxT: function(a) {
- this.maxT = a
- },
- getShaderProgram: function() {
- return this.shaderProgram
- },
- setShaderProgram: function(a) {
- this.shaderProgram = a
- },
- hasPremultipliedAlpha: function() {
- return this._hasPremultipliedAlpha
- },
- hasMipmaps: function() {
- return this._hasMipmaps
- },
- description: function() {
- return "\x3ccc.Texture2D | Name \x3d " + this._name + " | Dimensions \x3d " + this._pixelsWide + " x " + this._pixelsHigh + " | Coordinates \x3d (" + this.maxS + ", " + this.maxT + ")\x3e"
- },
- releaseData: function(a) {},
- keepData: function(a, c) {
- return a
- },
- initWithData: function(a, c, d, e, f) {
- var g = cc.Texture2D,
- h = cc._renderContext,
- k = h.RGBA,
- m = h.UNSIGNED_BYTE,
- n = d * cc.Texture2D._B[c] / 8;
- 0 === n % 8 ? h.pixelStorei(h.UNPACK_ALIGNMENT, 8) : 0 === n % 4 ? h.pixelStorei(h.UNPACK_ALIGNMENT, 4) : 0 === n % 2 ? h.pixelStorei(h.UNPACK_ALIGNMENT, 2) : h.pixelStorei(h.UNPACK_ALIGNMENT, 1);
- this._webTextureObj = h.createTexture();
- cc.glBindTexture2D(this);
- h.texParameteri(h.TEXTURE_2D, h.TEXTURE_MIN_FILTER, h.LINEAR);
- h.texParameteri(h.TEXTURE_2D, h.TEXTURE_MAG_FILTER, h.LINEAR);
- h.texParameteri(h.TEXTURE_2D, h.TEXTURE_WRAP_S, h.CLAMP_TO_EDGE);
- h.texParameteri(h.TEXTURE_2D, h.TEXTURE_WRAP_T, h.CLAMP_TO_EDGE);
- switch (c) {
- case g.PIXEL_FORMAT_RGBA8888:
- k = h.RGBA;
- break;
- case g.PIXEL_FORMAT_RGB888:
- k = h.RGB;
- break;
- case g.PIXEL_FORMAT_RGBA4444:
- m = h.UNSIGNED_SHORT_4_4_4_4;
- break;
- case g.PIXEL_FORMAT_RGB5A1:
- m = h.UNSIGNED_SHORT_5_5_5_1;
- break;
- case g.PIXEL_FORMAT_RGB565:
- m = h.UNSIGNED_SHORT_5_6_5;
- break;
- case g.PIXEL_FORMAT_AI88:
- k = h.LUMINANCE_ALPHA;
- break;
- case g.PIXEL_FORMAT_A8:
- k = h.ALPHA;
- break;
- case g.PIXEL_FORMAT_I8:
- k = h.LUMINANCE;
- break;
- default:
- cc.assert(0, cc._LogInfos.Texture2D_initWithData)
- }
- h.texImage2D(h.TEXTURE_2D, 0, k, d, e, 0, k, m, a);
- this._contentSize.width = f.width;
- this._contentSize.height = f.height;
- this._pixelsWide = d;
- this._pixelsHigh = e;
- this._pixelFormat = c;
- this.maxS = f.width / d;
- this.maxT = f.height / e;
- this._hasMipmaps = this._hasPremultipliedAlpha = !1;
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
- return this._isLoaded = !0
- },
- drawAtPoint: function(a) {
- var c = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0],
- d = this._pixelsWide * this.maxS,
- e = this._pixelsHigh * this.maxT;
- a = [a.x, a.y, 0, d + a.x, a.y, 0, a.x, e + a.y, 0, d + a.x, e + a.y, 0];
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
- this._shaderProgram.use();
- this._shaderProgram.setUniformsForBuiltins();
- cc.glBindTexture2D(this);
- d = cc._renderContext;
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, a);
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 0, c);
- d.drawArrays(d.TRIANGLE_STRIP, 0, 4)
- },
- drawInRect: function(a) {
- var c = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0];
- a = [a.x, a.y, a.x + a.width, a.y, a.x, a.y + a.height, a.x + a.width, a.y + a.height];
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
- this._shaderProgram.use();
- this._shaderProgram.setUniformsForBuiltins();
- cc.glBindTexture2D(this);
- var d = cc._renderContext;
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, a);
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 0, c);
- d.drawArrays(d.TRIANGLE_STRIP, 0, 4)
- },
- initWithImage: function(a) {
- if (null == a) return cc.log(cc._LogInfos.Texture2D_initWithImage), !1;
- var c = a.getWidth(),
- d = a.getHeight(),
- e = cc.configuration.getMaxTextureSize();
- if (c > e || d > e) return cc.log(cc._LogInfos.Texture2D_initWithImage_2, c, d, e, e), !1;
- this._isLoaded = !0;
- return this._initPremultipliedATextureWithImage(a, c, d)
- },
- initWithElement: function(a) {
- a && (this._webTextureObj = cc._renderContext.createTexture(), this._htmlElementObj = a)
- },
- getHtmlElementObj: function() {
- return this._htmlElementObj
- },
- isLoaded: function() {
- return this._isLoaded
- },
- handleLoadedTexture: function() {
- if (cc._rendererInitialized) {
- if (!this._htmlElementObj) {
- var a = cc.loader.getRes(this.url);
- if (!a) return;
- this.initWithElement(a)
- }
- this._htmlElementObj.width && this._htmlElementObj.height && (this._isLoaded = !0, a = cc._renderContext, cc.glBindTexture2D(this), a.pixelStorei(a.UNPACK_ALIGNMENT, 4), a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, this._htmlElementObj), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE), cc.glBindTexture2D(null), a = this._htmlElementObj.height, this._pixelsWide = this._contentSize.width = this._htmlElementObj.width, this._pixelsHigh = this._contentSize.height = a, this._pixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.maxT = this.maxS = 1, this._hasMipmaps = this._hasPremultipliedAlpha = !1, this._callLoadedEventCallbacks())
- }
- },
- initWithString: function(a, c, d, e, f, g) {
- cc.log(cc._LogInfos.Texture2D_initWithString);
- return null
- },
- initWithETCFile: function(a) {
- cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
- return !1
- },
- initWithPVRFile: function(a) {
- cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);
- return !1
- },
- initWithPVRTCData: function(a, c, d, e, f, g) {
- cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);
- return !1
- },
- setTexParameters: function(a) {
- var c = cc._renderContext;
- cc.assert(this._pixelsWide == cc.NextPOT(this._pixelsWide) && this._pixelsHigh == cc.NextPOT(this._pixelsHigh) || a.wrapS == c.CLAMP_TO_EDGE && a.wrapT == c.CLAMP_TO_EDGE, "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures");
- cc.glBindTexture2D(this);
- c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MIN_FILTER, a.minFilter);
- c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MAG_FILTER, a.magFilter);
- c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, a.wrapS);
- c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, a.wrapT)
- },
- setAntiAliasTexParameters: function() {
- var a = cc._renderContext;
- cc.glBindTexture2D(this);
- this._hasMipmaps ? a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR_MIPMAP_NEAREST) : a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR);
- a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
- },
- setAliasTexParameters: function() {
- var a = cc._renderContext;
- cc.glBindTexture2D(this);
- this._hasMipmaps ? a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.NEAREST_MIPMAP_NEAREST) : a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.NEAREST);
- a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
- },
- generateMipmap: function() {
- cc.assert(this._pixelsWide == cc.NextPOT(this._pixelsWide) && this._pixelsHigh == cc.NextPOT(this._pixelsHigh), "Mimpap texture only works in POT textures");
- cc.glBindTexture2D(this);
- cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
- this._hasMipmaps = !0
- },
- stringForFormat: function() {
- return cc.Texture2D._M[this._pixelFormat]
- },
- bitsPerPixelForFormat: function(a) {
- a = a || this._pixelFormat;
- var c = cc.Texture2D._B[a];
- if (null != c) return c;
- cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, a);
- return -1
- },
- _initPremultipliedATextureWithImage: function(a, c, d) {
- var e = cc.Texture2D,
- f = a.getData(),
- g = null,
- g = null,
- h = a.hasAlpha(),
- k = cc.size(a.getWidth(), a.getHeight()),
- m = e.defaultPixelFormat,
- n = a.getBitsPerComponent();
- h || (8 <= n ? m = e.PIXEL_FORMAT_RGB888 : (cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage), m = e.PIXEL_FORMAT_RGB565));
- var q = c * d;
- if (m == e.PIXEL_FORMAT_RGB565)
- if (h) {
- f = new Uint16Array(c * d);
- g = a.getData();
- for (n = 0; n < q; ++n) f[n] = (g[n] >> 0 & 255) >> 3 << 11 | (g[n] >> 8 & 255) >> 2 << 5 | (g[n] >> 16 & 255) >> 3 << 0
- } else {
- f = new Uint16Array(c * d);
- g = a.getData();
- for (n = 0; n < q; ++n) f[n] = (g[n] & 255) >> 3 << 11 | (g[n] & 255) >> 2 << 5 | (g[n] & 255) >> 3 << 0
- } else if (m == e.PIXEL_FORMAT_RGBA4444) {
- f = new Uint16Array(c * d);
- g = a.getData();
- for (n = 0; n < q; ++n) f[n] = (g[n] >> 0 & 255) >> 4 << 12 | (g[n] >> 8 & 255) >> 4 << 8 | (g[n] >> 16 & 255) >> 4 << 4 | (g[n] >> 24 & 255) >> 4 << 0
- } else if (m == e.PIXEL_FORMAT_RGB5A1) {
- f = new Uint16Array(c * d);
- g = a.getData();
- for (n = 0; n < q; ++n) f[n] = (g[n] >> 0 & 255) >> 3 << 11 | (g[n] >> 8 & 255) >> 3 << 6 | (g[n] >> 16 & 255) >> 3 << 1 | (g[n] >> 24 & 255) >> 7 << 0
- } else if (m == e.PIXEL_FORMAT_A8) {
- f = new Uint8Array(c * d);
- g = a.getData();
- for (n = 0; n < q; ++n) f[n] = g >> 24 & 255
- }
- if (h && m == e.PIXEL_FORMAT_RGB888) {
- g = a.getData();
- f = new Uint8Array(3 * c * d);
- for (n = 0; n < q; ++n) f[3 * n] = g >> 0 & 255, f[3 * n + 1] = g >> 8 & 255, f[3 * n + 2] = g >> 16 & 255
- }
- this.initWithData(f, m, c, d, k);
- a.getData();
- this._hasPremultipliedAlpha = a.isPremultipliedAlpha();
- return !0
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners || (this._loadedEventListeners = []);
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- removeLoadedEventListener: function(a) {
- if (this._loadedEventListeners)
- for (var c = this._loadedEventListeners, d = 0; d < c.length; d++) c[d].eventTarget == a && c.splice(d, 1)
- },
- _callLoadedEventCallbacks: function() {
- if (this._loadedEventListeners) {
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- }
- })
- };
- cc._tmp.WebGLTextureAtlas = function() {
- var a = cc.TextureAtlas.prototype;
- a._setupVBO = function() {
- var a = cc._renderContext;
- this._buffersVBO[0] = a.createBuffer();
- this._buffersVBO[1] = a.createBuffer();
- this._quadsWebBuffer = a.createBuffer();
- this._mapBuffers()
- };
- a._mapBuffers = function() {
- var a = cc._renderContext;
- a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
- a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
- };
- a.drawNumberOfQuads = function(a, d) {
- d = d || 0;
- if (!(0 === a || !this.texture || !this.texture.isLoaded())) {
- var e = cc._renderContext;
- cc.glBindTexture2D(this.texture);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
- e.bindBuffer(e.ARRAY_BUFFER, this._quadsWebBuffer);
- this.dirty && e.bufferData(e.ARRAY_BUFFER, this._quadsArrayBuffer, e.DYNAMIC_DRAW);
- e.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, e.FLOAT, !1, 24, 0);
- e.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, e.UNSIGNED_BYTE, !0, 24, 12);
- e.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, e.FLOAT, !1, 24, 16);
- this.dirty && (this.dirty = !1);
- e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
- cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? e.drawElements(e.TRIANGLE_STRIP, 6 * a, e.UNSIGNED_SHORT, 6 * d * this._indices.BYTES_PER_ELEMENT) : e.drawElements(e.TRIANGLES, 6 * a, e.UNSIGNED_SHORT, 6 * d * this._indices.BYTES_PER_ELEMENT);
- cc.g_NumberOfDraws++
- }
- }
- };
- cc._tmp.WebGLTextureCache = function() {
- var a = cc.textureCache;
- a.handleLoadedTexture = function(a) {
- var d = this._textures;
- cc._rendererInitialized || (d = this._loadedTexturesBefore);
- var e = d[a];
- e || (e = d[a] = new cc.Texture2D, e.url = a);
- e.handleLoadedTexture()
- };
- a.addImage = function(a, d, e) {
- cc.assert(a, cc._LogInfos.Texture2D_addImage_2);
- var f = this._textures;
- cc._rendererInitialized || (f = this._loadedTexturesBefore);
- var g = f[a] || f[cc.loader._aliases[a]];
- if (g) return d && d.call(e), g;
- cc.loader.getRes(a) || (cc.loader._checkIsImageURL(a) ? cc.loader.load(a, function(a) {
- d && d.call(e)
- }) : cc.loader.cache[a] = cc.loader.loadImg(a, function(e, f) {
- if (e) return d ? d(e) : e;
- cc.textureCache.handleLoadedTexture(a);
- d && d(null, f)
- }));
- g = f[a] = new cc.Texture2D;
- g.url = a;
- return g
- };
- delete a
- };
- cc._tmp.PrototypeTexture2D = function() {
- var a = cc.Texture2D;
- a.PVRImagesHavePremultipliedAlpha = function(a) {
- cc.PVRHaveAlphaPremultiplied_ = a
- };
- a.PIXEL_FORMAT_RGBA8888 = 2;
- a.PIXEL_FORMAT_RGB888 = 3;
- a.PIXEL_FORMAT_RGB565 = 4;
- a.PIXEL_FORMAT_A8 = 5;
- a.PIXEL_FORMAT_I8 = 6;
- a.PIXEL_FORMAT_AI88 = 7;
- a.PIXEL_FORMAT_RGBA4444 = 8;
- a.PIXEL_FORMAT_RGB5A1 = 7;
- a.PIXEL_FORMAT_PVRTC4 = 9;
- a.PIXEL_FORMAT_PVRTC2 = 10;
- a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888;
- var c = cc.Texture2D._M = {};
- c[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888";
- c[a.PIXEL_FORMAT_RGB888] = "RGB888";
- c[a.PIXEL_FORMAT_RGB565] = "RGB565";
- c[a.PIXEL_FORMAT_A8] = "A8";
- c[a.PIXEL_FORMAT_I8] = "I8";
- c[a.PIXEL_FORMAT_AI88] = "AI88";
- c[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444";
- c[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1";
- c[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4";
- c[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2";
- c = cc.Texture2D._B = {};
- c[a.PIXEL_FORMAT_RGBA8888] = 32;
- c[a.PIXEL_FORMAT_RGB888] = 24;
- c[a.PIXEL_FORMAT_RGB565] = 16;
- c[a.PIXEL_FORMAT_A8] = 8;
- c[a.PIXEL_FORMAT_I8] = 8;
- c[a.PIXEL_FORMAT_AI88] = 16;
- c[a.PIXEL_FORMAT_RGBA4444] = 16;
- c[a.PIXEL_FORMAT_RGB5A1] = 16;
- c[a.PIXEL_FORMAT_PVRTC4] = 4;
- c[a.PIXEL_FORMAT_PVRTC2] = 3;
- c = cc.Texture2D.prototype;
- cc.defineGetterSetter(c, "name", c.getName);
- cc.defineGetterSetter(c, "pixelFormat", c.getPixelFormat);
- cc.defineGetterSetter(c, "pixelsWidth", c.getPixelsWide);
- cc.defineGetterSetter(c, "pixelsHeight", c.getPixelsHigh);
- cc.defineGetterSetter(c, "width", c._getWidth);
- cc.defineGetterSetter(c, "height", c._getHeight);
- a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT
- };
- cc._tmp.PrototypeTextureAtlas = function() {
- var a = cc.TextureAtlas.prototype;
- cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads);
- cc.defineGetterSetter(a, "capacity", a.getCapacity);
- cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads)
- };
- cc.ALIGN_CENTER = 51;
- cc.ALIGN_TOP = 19;
- cc.ALIGN_TOP_RIGHT = 18;
- cc.ALIGN_RIGHT = 50;
- cc.ALIGN_BOTTOM_RIGHT = 34;
- cc.ALIGN_BOTTOM = 35;
- cc.ALIGN_BOTTOM_LEFT = 33;
- cc.ALIGN_LEFT = 49;
- cc.ALIGN_TOP_LEFT = 17;
- cc.PVRHaveAlphaPremultiplied_ = !1;
- cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.Texture2D = cc.Class.extend({
- _contentSize: null,
- _isLoaded: !1,
- _htmlElementObj: null,
- _loadedEventListeners: null,
- url: null,
- ctor: function() {
- this._contentSize = cc.size(0, 0);
- this._isLoaded = !1;
- this._htmlElementObj = null
- },
- getPixelsWide: function() {
- return this._contentSize.width
- },
- getPixelsHigh: function() {
- return this._contentSize.height
- },
- getContentSize: function() {
- var a = cc.contentScaleFactor();
- return cc.size(this._contentSize.width / a, this._contentSize.height / a)
- },
- _getWidth: function() {
- return this._contentSize.width / cc.contentScaleFactor()
- },
- _getHeight: function() {
- return this._contentSize.height / cc.contentScaleFactor()
- },
- getContentSizeInPixels: function() {
- return this._contentSize
- },
- initWithElement: function(a) {
- a && (this._htmlElementObj = a)
- },
- getHtmlElementObj: function() {
- return this._htmlElementObj
- },
- isLoaded: function() {
- return this._isLoaded
- },
- handleLoadedTexture: function() {
- if (!this._isLoaded) {
- if (!this._htmlElementObj) {
- var a = cc.loader.getRes(this.url);
- if (!a) return;
- this.initWithElement(a)
- }
- this._isLoaded = !0;
- a = this._htmlElementObj;
- this._contentSize.width = a.width;
- this._contentSize.height = a.height;
- this._callLoadedEventCallbacks()
- }
- },
- description: function() {
- return "\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e"
- },
- initWithData: function(a, c, d, e, f) {
- return !1
- },
- initWithImage: function(a) {
- return !1
- },
- initWithString: function(a, c, d, e, f, g) {
- return !1
- },
- releaseTexture: function() {},
- getName: function() {
- return null
- },
- getMaxS: function() {
- return 1
- },
- setMaxS: function(a) {},
- getMaxT: function() {
- return 1
- },
- setMaxT: function(a) {},
- getPixelFormat: function() {
- return null
- },
- getShaderProgram: function() {
- return null
- },
- setShaderProgram: function(a) {},
- hasPremultipliedAlpha: function() {
- return !1
- },
- hasMipmaps: function() {
- return !1
- },
- releaseData: function(a) {},
- keepData: function(a, c) {
- return a
- },
- drawAtPoint: function(a) {},
- drawInRect: function(a) {},
- initWithETCFile: function(a) {
- cc.log(cc._LogInfos.Texture2D_initWithETCFile);
- return !1
- },
- initWithPVRFile: function(a) {
- cc.log(cc._LogInfos.Texture2D_initWithPVRFile);
- return !1
- },
- initWithPVRTCData: function(a, c, d, e, f, g) {
- cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);
- return !1
- },
- setTexParameters: function(a) {},
- setAntiAliasTexParameters: function() {},
- setAliasTexParameters: function() {},
- generateMipmap: function() {},
- stringForFormat: function() {
- return ""
- },
- bitsPerPixelForFormat: function(a) {
- return -1
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners || (this._loadedEventListeners = []);
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- removeLoadedEventListener: function(a) {
- if (this._loadedEventListeners)
- for (var c = this._loadedEventListeners, d = 0; d < c.length; d++) c[d].eventTarget == a && c.splice(d, 1)
- },
- _callLoadedEventCallbacks: function() {
- if (this._loadedEventListeners) {
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- }
- }) : (cc.assert("function" === typeof cc._tmp.WebGLTexture2D, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D);
- cc.assert("function" === typeof cc._tmp.PrototypeTexture2D, cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
- cc._tmp.PrototypeTexture2D();
- delete cc._tmp.PrototypeTexture2D;
- cc.textureCache = {
- _textures: {},
- _textureColorsCache: {},
- _textureKeySeq: 0 | 1E3 * Math.random(),
- _loadedTexturesBefore: {},
- _initializingRenderer: function() {
- var a, c = this._loadedTexturesBefore,
- d = this._textures;
- for (a in c) {
- var e = c[a];
- e.handleLoadedTexture();
- d[a] = e
- }
- this._loadedTexturesBefore = {}
- },
- addPVRTCImage: function(a) {
- cc.log(cc._LogInfos.textureCache_addPVRTCImage)
- },
- addETCImage: function(a) {
- cc.log(cc._LogInfos.textureCache_addETCImage)
- },
- description: function() {
- return "\x3cTextureCache | Number of textures \x3d " + this._textures.length + "\x3e"
- },
- textureForKey: function(a) {
- return this._textures[a] || this._textures[cc.loader._aliases[a]]
- },
- getKeyByTexture: function(a) {
- for (var c in this._textures)
- if (this._textures[c] == a) return c;
- return null
- },
- _generalTextureKey: function() {
- this._textureKeySeq++;
- return "_textureKey_" + this._textureKeySeq
- },
- getTextureColors: function(a) {
- var c = this.getKeyByTexture(a);
- c || (c = a instanceof HTMLImageElement ? a.src : this._generalTextureKey());
- this._textureColorsCache[c] || (this._textureColorsCache[c] = cc.generateTextureCacheForColor(a));
- return this._textureColorsCache[c]
- },
- addPVRImage: function(a) {
- cc.log(cc._LogInfos.textureCache_addPVRImage)
- },
- removeAllTextures: function() {
- var a = this._textures,
- c;
- for (c in a) a[c] && a[c].releaseTexture();
- this._textures = {}
- },
- removeTexture: function(a) {
- if (a) {
- var c = this._textures,
- d;
- for (d in c) c[d] == a && (c[d].releaseTexture(), delete c[d])
- }
- },
- removeTextureForKey: function(a) {
- null != a && this._textures[a] && delete this._textures[a]
- },
- cacheImage: function(a, c) {
- if (c instanceof cc.Texture2D) this._textures[a] = c;
- else {
- var d = new cc.Texture2D;
- d.initWithElement(c);
- d.handleLoadedTexture();
- this._textures[a] = d
- }
- },
- addUIImage: function(a, c) {
- cc.assert(a, cc._LogInfos.textureCache_addUIImage_2);
- if (c && this._textures[c]) return this._textures[c];
- var d = new cc.Texture2D;
- d.initWithImage(a);
- null != c && null != d ? this._textures[c] = d : cc.log(cc._LogInfos.textureCache_addUIImage);
- return d
- },
- dumpCachedTextureInfo: function() {
- var a = 0,
- c = 0,
- d = this._textures,
- e;
- for (e in d) {
- var f = d[e];
- a++;
- f.getHtmlElementObj() instanceof HTMLImageElement ? cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo, e, f.getHtmlElementObj().src, f.pixelsWidth, f.pixelsHeight) : cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, e, f.pixelsWidth, f.pixelsHeight);
- c += 4 * f.pixelsWidth * f.pixelsHeight
- }
- d = this._textureColorsCache;
- for (e in d) {
- var f = d[e],
- g;
- for (g in f) {
- var h = f[g];
- a++;
- cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, e, h.width, h.height);
- c += 4 * h.width * h.height
- }
- }
- cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, c / 1024, (c / 1048576).toFixed(2))
- },
- _clear: function() {
- this._textures = {};
- this._textureColorsCache = {};
- this._textureKeySeq = 0 | 1E3 * Math.random();
- this._loadedTexturesBefore = {}
- }
- };
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function(a) {
- var c = this._textures,
- d = c[a];
- d || (d = c[a] = new cc.Texture2D, d.url = a);
- d.handleLoadedTexture()
- }, _p.addImage = function(a, c, d) {
- cc.assert(a, cc._LogInfos.Texture2D_addImage);
- var e = this._textures,
- f = e[a] || e[cc.loader._aliases[a]];
- if (f) return c && c.call(d), f;
- f = e[a] = new cc.Texture2D;
- f.url = a;
- cc.loader.getRes(a) ? f.handleLoadedTexture() : cc.loader._checkIsImageURL(a) ? cc.loader.load(a, function(a) {
- c && c.call(d)
- }) : cc.loader.cache[a] = cc.loader.loadImg(a, function(d, e) {
- if (d) return c ? c(d) : d;
- cc.textureCache.handleLoadedTexture(a);
- c && c(null, e)
- });
- return f
- }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLTextureCache, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache);
- cc.TextureAtlas = cc.Class.extend({
- dirty: !1,
- texture: null,
- _indices: null,
- _buffersVBO: null,
- _capacity: 0,
- _quads: null,
- _quadsArrayBuffer: null,
- _quadsWebBuffer: null,
- _quadsReader: null,
- ctor: function(a, c) {
- this._buffersVBO = [];
- "string" == typeof a ? this.initWithFile(a, c) : a instanceof cc.Texture2D && this.initWithTexture(a, c)
- },
- getTotalQuads: function() {
- return this._totalQuads
- },
- getCapacity: function() {
- return this._capacity
- },
- getTexture: function() {
- return this.texture
- },
- setTexture: function(a) {
- this.texture = a
- },
- setDirty: function(a) {
- this.dirty = a
- },
- isDirty: function() {
- return this.dirty
- },
- getQuads: function() {
- return this._quads
- },
- setQuads: function(a) {
- this._quads = a
- },
- _copyQuadsToTextureAtlas: function(a, c) {
- if (a)
- for (var d = 0; d < a.length; d++) this._setQuadToArray(a[d], c + d)
- },
- _setQuadToArray: function(a, c) {
- var d = this._quads;
- d[c] ? (d[c].bl = a.bl, d[c].br = a.br, d[c].tl = a.tl, d[c].tr = a.tr) : d[c] = new cc.V3F_C4B_T2F_Quad(a.tl, a.bl, a.tr, a.br, this._quadsArrayBuffer, c * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT)
- },
- description: function() {
- return "\x3ccc.TextureAtlas | totalQuads \x3d" + this._totalQuads + "\x3e"
- },
- _setupIndices: function() {
- if (0 !== this._capacity)
- for (var a = this._indices, c = this._capacity, d = 0; d < c; d++) cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? (a[6 * d + 0] = 4 * d + 0, a[6 * d + 1] = 4 * d + 0, a[6 * d + 2] = 4 * d + 2, a[6 * d + 3] = 4 * d + 1, a[6 * d + 4] = 4 * d + 3, a[6 * d + 5] = 4 * d + 3) : (a[6 * d + 0] = 4 * d + 0, a[6 * d + 1] = 4 * d + 1, a[6 * d + 2] = 4 * d + 2, a[6 * d + 3] = 4 * d + 3, a[6 * d + 4] = 4 * d + 2, a[6 * d + 5] = 4 * d + 1)
- },
- _setupVBO: function() {
- var a = cc._renderContext;
- this._buffersVBO[0] = a.createBuffer();
- this._buffersVBO[1] = a.createBuffer();
- this._quadsWebBuffer = a.createBuffer();
- this._mapBuffers()
- },
- _mapBuffers: function() {
- var a = cc._renderContext;
- a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
- a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
- },
- initWithFile: function(a, c) {
- var d = cc.textureCache.addImage(a);
- if (d) return this.initWithTexture(d, c);
- cc.log(cc._LogInfos.TextureAtlas_initWithFile, a);
- return !1
- },
- initWithTexture: function(a, c) {
- cc.assert(a, cc._LogInfos.TextureAtlas_initWithTexture);
- this._capacity = c |= 0;
- this._totalQuads = 0;
- this.texture = a;
- this._quads = [];
- this._indices = new Uint16Array(6 * c);
- var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
- this._quadsArrayBuffer = new ArrayBuffer(d * c);
- this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
- if ((!this._quads || !this._indices) && 0 < c) return !1;
- for (var e = this._quads, f = 0; f < c; f++) e[f] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, f * d);
- this._setupIndices();
- this._setupVBO();
- return this.dirty = !0
- },
- updateQuad: function(a, c) {
- cc.assert(a, cc._LogInfos.TextureAtlas_updateQuad);
- cc.assert(0 <= c && c < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2);
- this._totalQuads = Math.max(c + 1, this._totalQuads);
- this._setQuadToArray(a, c);
- this.dirty = !0
- },
- insertQuad: function(a, c) {
- cc.assert(c < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2);
- this._totalQuads++;
- if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
- else {
- var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- e = c * d,
- f = (this._totalQuads - 1 - c) * d;
- this._quads[this._totalQuads - 1] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * d);
- this._quadsReader.set(this._quadsReader.subarray(e, e + f), e + d);
- this._setQuadToArray(a, c);
- this.dirty = !0
- }
- },
- insertQuads: function(a, c, d) {
- d = d || a.length;
- cc.assert(c + d <= this._capacity, cc._LogInfos.TextureAtlas_insertQuads);
- var e = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
- this._totalQuads += d;
- if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
- else {
- var f = c * e,
- g = (this._totalQuads - 1 - c - d) * e,
- h = this._totalQuads - 1 - d,
- k;
- for (k = 0; k < d; k++) this._quads[h + k] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * e);
- this._quadsReader.set(this._quadsReader.subarray(f, f + g), f + e * d);
- for (k = 0; k < d; k++) this._setQuadToArray(a[k], c + k);
- this.dirty = !0
- }
- },
- insertQuadFromIndex: function(a, c) {
- if (a !== c) {
- cc.assert(0 <= c || c < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex);
- cc.assert(0 <= a || a < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex_2);
- var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- e = this._quadsReader,
- f = e.subarray(a * d, d),
- g;
- a > c ? (g = c * d, e.set(e.subarray(g, g + (a - c) * d), g + d), e.set(f, g)) : (g = (a + 1) * d, e.set(e.subarray(g, g + (c - a) * d), g - d), e.set(f, c * d));
- this.dirty = !0
- }
- },
- removeQuadAtIndex: function(a) {
- cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex);
- var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
- this._totalQuads--;
- this._quads.length = this._totalQuads;
- if (a !== this._totalQuads) {
- var d = (a + 1) * c;
- this._quadsReader.set(this._quadsReader.subarray(d, d + (this._totalQuads - a) * c), d - c)
- }
- this.dirty = !0
- },
- removeQuadsAtIndex: function(a, c) {
- cc.assert(a + c <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex);
- this._totalQuads -= c;
- if (a !== this._totalQuads) {
- var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- e = (a + c) * d;
- this._quadsReader.set(this._quadsReader.subarray(e, e + (this._totalQuads - a) * d), a * d)
- }
- this.dirty = !0
- },
- removeAllQuads: function() {
- this._totalQuads = this._quads.length = 0
- },
- _setDirty: function(a) {
- this.dirty = a
- },
- resizeCapacity: function(a) {
- if (a == this._capacity) return !0;
- var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- d = this._capacity;
- this._totalQuads = Math.min(this._totalQuads, a);
- var e = this._capacity = 0 | a,
- f = this._totalQuads;
- if (null == this._quads) {
- this._quads = [];
- this._quadsArrayBuffer = new ArrayBuffer(c * e);
- this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
- for (a = 0; a < e; a++) this._quads = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, a * c)
- } else {
- var g, h, k = this._quads;
- if (e > d) {
- g = [];
- h = new ArrayBuffer(c * e);
- for (a = 0; a < f; a++) g[a] = new cc.V3F_C4B_T2F_Quad(k[a].tl, k[a].bl, k[a].tr, k[a].br, h, a * c);
- for (; a < e; a++) g[a] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, h, a * c)
- } else {
- f = Math.max(f, e);
- g = [];
- h = new ArrayBuffer(c * e);
- for (a = 0; a < f; a++) g[a] = new cc.V3F_C4B_T2F_Quad(k[a].tl, k[a].bl, k[a].tr, k[a].br, h, a * c)
- }
- this._quadsReader = new Uint8Array(h);
- this._quads = g;
- this._quadsArrayBuffer = h
- }
- null == this._indices ? this._indices = new Uint16Array(6 * e) : e > d ? (c = new Uint16Array(6 * e), c.set(this._indices, 0), this._indices = c) : this._indices = this._indices.subarray(0, 6 * e);
- this._setupIndices();
- this._mapBuffers();
- return this.dirty = !0
- },
- increaseTotalQuadsWith: function(a) {
- this._totalQuads += a
- },
- moveQuadsFromIndex: function(a, c, d) {
- if (void 0 === d) {
- if (d = c, c = this._totalQuads - a, cc.assert(d + (this._totalQuads - a) <= this._capacity, cc._LogInfos.TextureAtlas_moveQuadsFromIndex), 0 === c) return
- } else if (cc.assert(d + c <= this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2), cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3), a == d) return;
- var e = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- f = a * e,
- g = c * e,
- h = this._quadsReader,
- k = h.subarray(f, f + g),
- m = d * e;
- d < a ? (c = d * e, h.set(h.subarray(c, c + (a - d) * e), c + g)) : (c = (a + c) * e, h.set(h.subarray(c, c + (d - a) * e), f));
- h.set(k, m);
- this.dirty = !0
- },
- fillWithEmptyQuadsFromIndex: function(a, c) {
- for (var d = c * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, e = new Uint8Array(this._quadsArrayBuffer, a * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d), f = 0; f < d; f++) e[f] = 0
- },
- drawQuads: function() {
- this.drawNumberOfQuads(this._totalQuads, 0)
- },
- _releaseBuffer: function() {
- var a = cc._renderContext;
- this._buffersVBO && (this._buffersVBO[0] && a.deleteBuffer(this._buffersVBO[0]), this._buffersVBO[1] && a.deleteBuffer(this._buffersVBO[1]));
- this._quadsWebBuffer && a.deleteBuffer(this._quadsWebBuffer)
- }
- });
- _p = cc.TextureAtlas.prototype;
- cc.defineGetterSetter(_p, "totalQuads", _p.getTotalQuads);
- cc.defineGetterSetter(_p, "capacity", _p.getCapacity);
- cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads);
- cc.TextureAtlas.create = function(a, c) {
- return new cc.TextureAtlas(a, c)
- };
- cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create;
- cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert("function" === typeof cc._tmp.WebGLTextureAtlas, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureAtlas(), delete cc._tmp.WebGLTextureAtlas);
- cc.assert("function" === typeof cc._tmp.PrototypeTextureAtlas, cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
- cc._tmp.PrototypeTextureAtlas();
- delete cc._tmp.PrototypeTextureAtlas;
- cc.Scene = cc.Node.extend({
- _className: "Scene",
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this._ignoreAnchorPointForPosition = !0;
- this.setAnchorPoint(0.5, 0.5);
- this.setContentSize(cc.director.getWinSize())
- }
- });
- cc.Scene.create = function() {
- return new cc.Scene
- };
- cc.LoaderScene = cc.Scene.extend({
- _interval: null,
- _length: 0,
- _count: 0,
- _label: null,
- _className: "LoaderScene",
- init: function() {
- var a = this,
- c = 200,
- d = a._bgLayer = cc.LayerColor.create(cc.color(32, 32, 32, 255));
- d.setPosition(cc.visibleRect.bottomLeft);
- a.addChild(d, 0);
- var e = 24,
- f = -c / 2 + 100;
- cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, {
- isCrossOrigin: !1
- }, function(d, e) {
- c = e.height;
- a._initStage(e, cc.visibleRect.center)
- }), e = 14, f = -c / 2 - 10);
- e = a._label = cc.LabelTTF.create("Loading... 0%", "Arial", e);
- e.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, f)));
- e.setColor(cc.color(180, 180, 180));
- d.addChild(this._label, 10);
- return !0
- },
- _initStage: function(a, c) {
- var d = this._texture2d = new cc.Texture2D;
- d.initWithElement(a);
- d.handleLoadedTexture();
- d = this._logo = cc.Sprite.create(d);
- d.setScale(cc.contentScaleFactor());
- d.x = c.x;
- d.y = c.y;
- this._bgLayer.addChild(d, 10)
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- this.schedule(this._startLoading, 0.3)
- },
- onExit: function() {
- cc.Node.prototype.onExit.call(this);
- this._label.setString("Loading... 0%")
- },
- initWithResources: function(a, c) {
- "string" == typeof a && (a = [a]);
- this.resources = a || [];
- this.cb = c
- },
- _startLoading: function() {
- var a = this;
- a.unschedule(a._startLoading);
- var c = a.resources;
- a._length = c.length;
- a._count = 0;
- cc.loader.load(c, function(c, e) {
- a._count = e
- }, function() {
- a.cb && a.cb()
- });
- a.schedule(a._updatePercent)
- },
- _updatePercent: function() {
- var a = this._count,
- c = this._length,
- d;
- d = Math.min(100 * (a / c) | 0, 100);
- this._label.setString("Loading... " + d + "%");
- a >= c && this.unschedule(this._updatePercent)
- }
- });
- cc.LoaderScene.preload = function(a, c) {
- var d = cc;
- d.loaderScene || (d.loaderScene = new cc.LoaderScene, d.loaderScene.init());
- d.loaderScene.initWithResources(a, c);
- cc.director.runScene(d.loaderScene);
- return d.loaderScene
- };
- cc._tmp.LayerDefineForWebGL = function() {
- var a = cc.Layer.prototype;
- a.bake = function() {};
- a.unbake = function() {};
- a.visit = cc.Node.prototype.visit
- };
- cc._tmp.WebGLLayerColor = function() {
- var a = cc.LayerColor.prototype;
- a._squareVertices = null;
- a._squareColors = null;
- a._verticesFloat32Buffer = null;
- a._colorsUint8Buffer = null;
- a._squareVerticesAB = null;
- a._squareColorsAB = null;
- a.ctor = function(a, d, e) {
- this._squareVerticesAB = new ArrayBuffer(32);
- this._squareColorsAB = new ArrayBuffer(16);
- var f = this._squareVerticesAB,
- g = this._squareColorsAB,
- h = cc.Vertex2F.BYTES_PER_ELEMENT,
- k = cc.Color.BYTES_PER_ELEMENT;
- this._squareVertices = [new cc.Vertex2F(0, 0, f, 0), new cc.Vertex2F(0, 0, f, h), new cc.Vertex2F(0, 0, f, 2 * h), new cc.Vertex2F(0, 0, f, 3 * h)];
- this._squareColors = [cc.color(0, 0, 0, 255, g, 0), cc.color(0, 0, 0, 255, g, k), cc.color(0, 0, 0, 255, g, 2 * k), cc.color(0, 0, 0, 255, g, 3 * k)];
- this._verticesFloat32Buffer = cc._renderContext.createBuffer();
- this._colorsUint8Buffer = cc._renderContext.createBuffer();
- cc.Layer.prototype.ctor.call(this);
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- cc.LayerColor.prototype.init.call(this, a, d, e)
- };
- a.setContentSize = function(a, d) {
- var e = this._squareVertices;
- void 0 === d ? (e[1].x = a.width, e[2].y = a.height, e[3].x = a.width, e[3].y = a.height) : (e[1].x = a, e[2].y = d, e[3].x = a, e[3].y = d);
- this._bindLayerVerticesBufferData();
- cc.Layer.prototype.setContentSize.call(this, a, d)
- };
- a._setWidth = function(a) {
- var d = this._squareVertices;
- d[1].x = a;
- d[3].x = a;
- this._bindLayerVerticesBufferData();
- cc.Layer.prototype._setWidth.call(this, a)
- };
- a._setHeight = function(a) {
- var d = this._squareVertices;
- d[2].y = a;
- d[3].y = a;
- this._bindLayerVerticesBufferData();
- cc.Layer.prototype._setHeight.call(this, a)
- };
- a._updateColor = function() {
- for (var a = this._displayedColor, d = this._displayedOpacity, e = this._squareColors, f = 0; 4 > f; f++) e[f].r = a.r, e[f].g = a.g, e[f].b = a.b, e[f].a = d;
- this._bindLayerColorsBufferData()
- };
- a.draw = function(a) {
- a = a || cc._renderContext;
- cc.nodeDrawSetup(this);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR);
- a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
- a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0);
- cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
- a.drawArrays(a.TRIANGLE_STRIP, 0, 4)
- };
- a._bindLayerVerticesBufferData = function() {
- var a = cc._renderContext;
- a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
- a.bufferData(a.ARRAY_BUFFER, this._squareVerticesAB, a.STATIC_DRAW)
- };
- a._bindLayerColorsBufferData = function() {
- var a = cc._renderContext;
- a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
- a.bufferData(a.ARRAY_BUFFER, this._squareColorsAB, a.STATIC_DRAW)
- }
- };
- cc._tmp.WebGLLayerGradient = function() {
- var a = cc.LayerGradient.prototype;
- a.draw = cc.LayerColor.prototype.draw;
- a._updateColor = function() {
- var a = this._alongVector,
- d = cc.pLength(a);
- if (0 !== d) {
- var e = Math.sqrt(2),
- a = cc.p(a.x / d, a.y / d);
- this._compressedInterpolation && (d = 1 / (Math.abs(a.x) + Math.abs(a.y)), a = cc.pMult(a, d * e));
- var f = this._displayedOpacity / 255,
- d = this._displayedColor,
- g = this._endColor,
- d = {
- r: d.r,
- g: d.g,
- b: d.b,
- a: this._startOpacity * f
- },
- f = {
- r: g.r,
- g: g.g,
- b: g.b,
- a: this._endOpacity * f
- },
- h = this._squareColors,
- g = h[0],
- k = h[1],
- m = h[2],
- h = h[3];
- g.r = f.r + (d.r - f.r) * ((e + a.x + a.y) / (2 * e));
- g.g = f.g + (d.g - f.g) * ((e + a.x + a.y) / (2 * e));
- g.b = f.b + (d.b - f.b) * ((e + a.x + a.y) / (2 * e));
- g.a = f.a + (d.a - f.a) * ((e + a.x + a.y) / (2 * e));
- k.r = f.r + (d.r - f.r) * ((e - a.x + a.y) / (2 * e));
- k.g = f.g + (d.g - f.g) * ((e - a.x + a.y) / (2 * e));
- k.b = f.b + (d.b - f.b) * ((e - a.x + a.y) / (2 * e));
- k.a = f.a + (d.a - f.a) * ((e - a.x + a.y) / (2 * e));
- m.r = f.r + (d.r - f.r) * ((e + a.x - a.y) / (2 * e));
- m.g = f.g + (d.g - f.g) * ((e + a.x - a.y) / (2 * e));
- m.b = f.b + (d.b - f.b) * ((e + a.x - a.y) / (2 * e));
- m.a = f.a + (d.a - f.a) * ((e + a.x - a.y) / (2 * e));
- h.r = f.r + (d.r - f.r) * ((e - a.x - a.y) / (2 * e));
- h.g = f.g + (d.g - f.g) * ((e - a.x - a.y) / (2 * e));
- h.b = f.b + (d.b - f.b) * ((e - a.x - a.y) / (2 * e));
- h.a = f.a + (d.a - f.a) * ((e - a.x - a.y) / (2 * e));
- this._bindLayerColorsBufferData()
- }
- }
- };
- cc._tmp.PrototypeLayerColor = function() {
- var a = cc.LayerColor.prototype;
- cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
- cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight)
- };
- cc._tmp.PrototypeLayerGradient = function() {
- var a = cc.LayerGradient.prototype;
- cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor);
- cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor);
- cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity);
- cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity);
- cc.defineGetterSetter(a, "vector", a.getVector, a.setVector)
- };
- cc.Layer = cc.Node.extend({
- _isBaked: !1,
- _bakeSprite: null,
- _className: "Layer",
- ctor: function() {
- var a = cc.Node.prototype;
- a.ctor.call(this);
- this._ignoreAnchorPointForPosition = !0;
- a.setAnchorPoint.call(this, 0.5, 0.5);
- a.setContentSize.call(this, cc.winSize)
- },
- init: function() {
- this._ignoreAnchorPointForPosition = !0;
- this.setAnchorPoint(0.5, 0.5);
- this.setContentSize(cc.winSize);
- this.cascadeColor = this.cascadeOpacity = !1;
- return !0
- },
- bake: null,
- unbake: null,
- isBaked: function() {
- return this._isBaked
- },
- visit: null
- });
- cc.Layer.create = function() {
- return new cc.Layer
- };
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
- var p = cc.Layer.prototype;
- p.bake = function() {
- if (!this._isBaked) {
- this._isBaked = this._cacheDirty = !0;
- this._cachedParent = this;
- for (var a = this._children, c = 0, d = a.length; c < d; c++) a[c]._setCachedParent(this);
- this._bakeSprite || (this._bakeSprite = new cc.BakeSprite)
- }
- };
- p.unbake = function() {
- if (this._isBaked) {
- this._isBaked = !1;
- this._cacheDirty = !0;
- this._cachedParent = null;
- for (var a = this._children, c = 0, d = a.length; c < d; c++) a[c]._setCachedParent(null)
- }
- };
- p.visit = function(a) {
- if (this._isBaked) {
- a = a || cc._renderContext;
- var c, d = this._children,
- e = d.length;
- if (this._visible && 0 !== e) {
- var f = this._bakeSprite;
- a.save();
- this.transform(a);
- if (this._cacheDirty) {
- c = this._getBoundingBoxForBake();
- c.width |= 0;
- c.height |= 0;
- var g = f.getCacheContext();
- f.resetCanvasSize(c.width, c.height);
- g.translate(0 - c.x, c.height + c.y);
- var h = f.getAnchorPointInPoints();
- f.setPosition(h.x + c.x, h.y + c.y);
- this.sortAllChildren();
- cc.view._setScaleXYForRenderTexture();
- for (c = 0; c < e; c++) d[c].visit(g);
- cc.view._resetScale();
- this._cacheDirty = !1
- }
- f.visit(a);
- this.arrivalOrder = 0;
- a.restore()
- }
- } else cc.Node.prototype.visit.call(this, a)
- };
- p._getBoundingBoxForBake = function() {
- var a = null;
- if (!this._children || 0 === this._children.length) return cc.rect(0, 0, 10, 10);
- for (var c = this._children, d = 0; d < c.length; d++) {
- var e = c[d];
- e && e._visible && (a ? (e = e._getBoundingBoxToCurrentNode()) && (a = cc.rectUnion(a, e)) : a = e._getBoundingBoxToCurrentNode())
- }
- return a
- };
- p = null
- } else cc.assert("function" === typeof cc._tmp.LayerDefineForWebGL, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.LayerDefineForWebGL(), delete cc._tmp.LayerDefineForWebGL;
- cc.LayerColor = cc.Layer.extend({
- _blendFunc: null,
- _className: "LayerColor",
- getBlendFunc: function() {
- return this._blendFunc
- },
- changeWidthAndHeight: function(a, c) {
- this.width = a;
- this.height = c
- },
- changeWidth: function(a) {
- this.width = a
- },
- changeHeight: function(a) {
- this.height = a
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- },
- setColor: function(a) {
- cc.Layer.prototype.setColor.call(this, a);
- this._updateColor()
- },
- setOpacity: function(a) {
- cc.Layer.prototype.setOpacity.call(this, a);
- this._updateColor()
- },
- _isLighterMode: !1,
- ctor: null,
- init: function(a, c, d) {
- cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));
- var e = cc.director.getWinSize();
- a = a || cc.color(0, 0, 0, 255);
- c = void 0 === c ? e.width : c;
- d = void 0 === d ? e.height : d;
- e = this._displayedColor;
- e.r = a.r;
- e.g = a.g;
- e.b = a.b;
- e = this._realColor;
- e.r = a.r;
- e.g = a.g;
- e.b = a.b;
- this._realOpacity = this._displayedOpacity = a.a;
- a = cc.LayerColor.prototype;
- a.setContentSize.call(this, c, d);
- a._updateColor.call(this);
- return !0
- },
- setBlendFunc: function(a, c) {
- this._blendFunc = void 0 === c ? a : {
- src: a,
- dst: c
- };
- cc._renderType === cc._RENDER_TYPE_CANVAS && (this._isLighterMode = this._blendFunc && 1 == this._blendFunc.src && 771 == this._blendFunc.dst)
- },
- _setWidth: null,
- _setHeight: null,
- _updateColor: null,
- updateDisplayedColor: function(a) {
- cc.Layer.prototype.updateDisplayedColor.call(this, a);
- this._updateColor()
- },
- updateDisplayedOpacity: function(a) {
- cc.Layer.prototype.updateDisplayedOpacity.call(this, a);
- this._updateColor()
- },
- draw: null
- });
- cc.LayerColor.create = function(a, c, d) {
- return new cc.LayerColor(a, c, d)
- };
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerColor.prototype, _p.ctor = function(a, c, d) {
- cc.Layer.prototype.ctor.call(this);
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- cc.LayerColor.prototype.init.call(this, a, c, d)
- }, _p._setWidth = cc.Layer.prototype._setWidth, _p._setHeight = cc.Layer.prototype._setHeight, _p._updateColor = function() {}, _p.draw = function(a) {
- a = a || cc._renderContext;
- var c = cc.view,
- d = this._displayedColor;
- a.fillStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + this._displayedOpacity / 255 + ")";
- a.fillRect(0, 0, this.width * c.getScaleX(), -this.height * c.getScaleY());
- cc.g_NumberOfDraws++
- }, _p.visit = function(a) {
- if (this._isBaked) {
- a = a || cc._renderContext;
- var c, d = this._children,
- e = d.length;
- if (this._visible) {
- var f = this._bakeSprite;
- a.save();
- this.transform(a);
- if (this._cacheDirty) {
- c = this._getBoundingBoxForBake();
- c.width |= 0;
- c.height |= 0;
- var g = f.getCacheContext();
- f.resetCanvasSize(c.width, c.height);
- var h = f.getAnchorPointInPoints(),
- k = this._position;
- if (this._ignoreAnchorPointForPosition) g.translate(0 - c.x + k.x, c.height + c.y - k.y), f.setPosition(h.x + c.x - k.x, h.y + c.y - k.y);
- else {
- var m = this.getAnchorPointInPoints(),
- n = k.x - m.x,
- k = k.y - m.y;
- g.translate(0 - c.x + n, c.height + c.y - k);
- f.setPosition(h.x + c.x - n, h.y + c.y - k)
- }
- cc.view._setScaleXYForRenderTexture();
- if (0 < e) {
- this.sortAllChildren();
- for (c = 0; c < e; c++)
- if (h = d[c], 0 > h._localZOrder) h.visit(g);
- else break;
- for (this.draw(g); c < e; c++) d[c].visit(g)
- } else this.draw(g);
- cc.view._resetScale();
- this._cacheDirty = !1
- }
- f.visit(a);
- this.arrivalOrder = 0;
- a.restore()
- }
- } else cc.Node.prototype.visit.call(this, a)
- }, _p._getBoundingBoxForBake = function() {
- var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
- c = this.nodeToWorldTransform(),
- a = cc.rectApplyAffineTransform(a, this.nodeToWorldTransform());
- if (!this._children || 0 === this._children.length) return a;
- for (var d = this._children, e = 0; e < d.length; e++) {
- var f = d[e];
- f && f._visible && (f = f._getBoundingBoxToCurrentNode(c), a = cc.rectUnion(a, f))
- }
- return a
- }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerColor, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerColor(), delete cc._tmp.WebGLLayerColor);
- cc.assert("function" === typeof cc._tmp.PrototypeLayerColor, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
- cc._tmp.PrototypeLayerColor();
- delete cc._tmp.PrototypeLayerColor;
- cc.LayerGradient = cc.LayerColor.extend({
- _startColor: null,
- _endColor: null,
- _startOpacity: 255,
- _endOpacity: 255,
- _alongVector: null,
- _compressedInterpolation: !1,
- _gradientStartPoint: null,
- _gradientEndPoint: null,
- _className: "LayerGradient",
- ctor: function(a, c, d) {
- cc.LayerColor.prototype.ctor.call(this);
- this._startColor = cc.color(0, 0, 0, 255);
- this._endColor = cc.color(0, 0, 0, 255);
- this._alongVector = cc.p(0, -1);
- this._endOpacity = this._startOpacity = 255;
- this._gradientStartPoint = cc.p(0, 0);
- this._gradientEndPoint = cc.p(0, 0);
- cc.LayerGradient.prototype.init.call(this, a, c, d)
- },
- init: function(a, c, d) {
- a = a || cc.color(0, 0, 0, 255);
- c = c || cc.color(0, 0, 0, 255);
- d = d || cc.p(0, -1);
- var e = this._startColor,
- f = this._endColor;
- e.r = a.r;
- e.g = a.g;
- e.b = a.b;
- this._startOpacity = a.a;
- f.r = c.r;
- f.g = c.g;
- f.b = c.b;
- this._endOpacity = c.a;
- this._alongVector = d;
- this._compressedInterpolation = !0;
- this._gradientStartPoint = cc.p(0, 0);
- this._gradientEndPoint = cc.p(0, 0);
- cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255));
- cc.LayerGradient.prototype._updateColor.call(this);
- return !0
- },
- setContentSize: function(a, c) {
- cc.LayerColor.prototype.setContentSize.call(this, a, c);
- this._updateColor()
- },
- _setWidth: function(a) {
- cc.LayerColor.prototype._setWidth.call(this, a);
- this._updateColor()
- },
- _setHeight: function(a) {
- cc.LayerColor.prototype._setHeight.call(this, a);
- this._updateColor()
- },
- getStartColor: function() {
- return this._realColor
- },
- setStartColor: function(a) {
- this.color = a
- },
- setEndColor: function(a) {
- this._endColor = a;
- this._updateColor()
- },
- getEndColor: function() {
- return this._endColor
- },
- setStartOpacity: function(a) {
- this._startOpacity = a;
- this._updateColor()
- },
- getStartOpacity: function() {
- return this._startOpacity
- },
- setEndOpacity: function(a) {
- this._endOpacity = a;
- this._updateColor()
- },
- getEndOpacity: function() {
- return this._endOpacity
- },
- setVector: function(a) {
- this._alongVector.x = a.x;
- this._alongVector.y = a.y;
- this._updateColor()
- },
- getVector: function() {
- return cc.p(this._alongVector.x, this._alongVector.y)
- },
- isCompressedInterpolation: function() {
- return this._compressedInterpolation
- },
- setCompressedInterpolation: function(a) {
- this._compressedInterpolation = a;
- this._updateColor()
- },
- _draw: null,
- _updateColor: null
- });
- cc.LayerGradient.create = function(a, c, d) {
- return new cc.LayerGradient(a, c, d)
- };
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerGradient.prototype, _p.draw = function(a) {
- a = a || cc._renderContext;
- this._isLighterMode && (a.globalCompositeOperation = "lighter");
- a.save();
- var c = this._displayedOpacity / 255,
- d = cc.view.getScaleX(),
- e = cc.view.getScaleY(),
- f = this.width * d,
- g = this.height * e,
- d = a.createLinearGradient(this._gradientStartPoint.x * d, this._gradientStartPoint.y * e, this._gradientEndPoint.x * d, this._gradientEndPoint.y * e),
- e = this._displayedColor,
- h = this._endColor;
- d.addColorStop(0, "rgba(" + Math.round(e.r) + "," + Math.round(e.g) + "," + Math.round(e.b) + "," + (c * (this._startOpacity / 255)).toFixed(4) + ")");
- d.addColorStop(1, "rgba(" + Math.round(h.r) + "," + Math.round(h.g) + "," + Math.round(h.b) + "," + (c * (this._endOpacity / 255)).toFixed(4) + ")");
- a.fillStyle = d;
- a.fillRect(0, 0, f, -g);
- 0 != this._rotation && a.rotate(this._rotationRadians);
- a.restore();
- cc.g_NumberOfDraws++
- }, _p._updateColor = function() {
- var a = this._alongVector,
- c = 0.5 * this.width,
- d = 0.5 * this.height;
- this._gradientStartPoint.x = c * -a.x + c;
- this._gradientStartPoint.y = d * a.y - d;
- this._gradientEndPoint.x = c * a.x + c;
- this._gradientEndPoint.y = d * -a.y - d
- }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerGradient, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerGradient(), delete cc._tmp.WebGLLayerGradient);
- cc.assert("function" === typeof cc._tmp.PrototypeLayerGradient, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
- cc._tmp.PrototypeLayerGradient();
- delete cc._tmp.PrototypeLayerGradient;
- cc.LayerMultiplex = cc.Layer.extend({
- _enabledLayer: 0,
- _layers: null,
- _className: "LayerMultiplex",
- ctor: function(a) {
- cc.Layer.prototype.ctor.call(this);
- a instanceof Array ? cc.LayerMultiplex.prototype.initWithLayers.call(this, a) : cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments))
- },
- initWithLayers: function(a) {
- 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);
- this._layers = a;
- this._enabledLayer = 0;
- this.addChild(this._layers[this._enabledLayer]);
- return !0
- },
- switchTo: function(a) {
- a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchTo) : (this.removeChild(this._layers[this._enabledLayer], !0), this._enabledLayer = a, this.addChild(this._layers[a]))
- },
- switchToAndReleaseMe: function(a) {
- a >= this._layers.length ? cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe) : (this.removeChild(this._layers[this._enabledLayer], !0), this._layers[this._enabledLayer] = null, this._enabledLayer = a, this.addChild(this._layers[a]))
- },
- addLayer: function(a) {
- a ? this._layers.push(a) : cc.log(cc._LogInfos.LayerMultiplex_addLayer)
- }
- });
- cc.LayerMultiplex.create = function() {
- return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))
- };
- cc._tmp.WebGLSprite = function() {
- var a = cc.Sprite.prototype;
- a._spriteFrameLoadedCallback = function(a) {
- this.setNodeDirty(!0);
- this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
- this._callLoadedEventCallbacks()
- };
- a.setOpacityModifyRGB = function(a) {
- this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.updateColor())
- };
- a.updateDisplayedOpacity = function(a) {
- cc.Node.prototype.updateDisplayedOpacity.call(this, a);
- this.updateColor()
- };
- a.ctor = function(a, d, e) {
- cc.Node.prototype.ctor.call(this);
- this._shouldBeHidden = !1;
- this._offsetPosition = cc.p(0, 0);
- this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- this._rect = cc.rect(0, 0, 0, 0);
- this._quad = new cc.V3F_C4B_T2F_Quad;
- this._quadWebBuffer = cc._renderContext.createBuffer();
- this._textureLoaded = this._quadDirty = !0;
- this._softInit(a, d, e)
- };
- a.setBlendFunc = function(a, d) {
- var e = this._blendFunc;
- void 0 === d ? (e.src = a.src, e.dst = a.dst) : (e.src = a, e.dst = d)
- };
- a.init = function() {
- if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
- cc.Node.prototype.init.call(this);
- this.dirty = this._recursiveDirty = !1;
- this._opacityModifyRGB = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- this.texture = null;
- this._textureLoaded = !0;
- this._flippedX = this._flippedY = !1;
- this.anchorY = this.anchorX = 0.5;
- this._offsetPosition.x = 0;
- this._offsetPosition.y = 0;
- this._hasChildren = !1;
- var a = {
- r: 255,
- g: 255,
- b: 255,
- a: 255
- };
- this._quad.bl.colors = a;
- this._quad.br.colors = a;
- this._quad.tl.colors = a;
- this._quad.tr.colors = a;
- this._quadDirty = !0;
- this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
- return !0
- };
- a.initWithTexture = function(a, d, e) {
- cc.assert(0 != arguments.length, cc._LogInfos.Sprite_initWithTexture);
- e = e || !1;
- if (!cc.Node.prototype.init.call(this)) return !1;
- this._batchNode = null;
- this.dirty = this._recursiveDirty = !1;
- this._opacityModifyRGB = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- this._flippedX = this._flippedY = !1;
- this.anchorY = this.anchorX = 0.5;
- this._offsetPosition.x = 0;
- this._offsetPosition.y = 0;
- this._hasChildren = !1;
- var f = cc.color(255, 255, 255, 255),
- g = this._quad;
- g.bl.colors = f;
- g.br.colors = f;
- g.tl.colors = f;
- g.tr.colors = f;
- this._textureLoaded = f = a.isLoaded();
- if (!f) return this._rectRotated = e || !1, d && (f = this._rect, f.x = d.x, f.y = d.y, f.width = d.width, f.height = d.height), a.addLoadedEventListener(this._textureLoadedCallback, this), !0;
- d || (d = cc.rect(0, 0, a.width, a.height));
- a && a.url && (e ? (f = d.x + d.height, g = d.y + d.width) : (f = d.x + d.width, g = d.y + d.height), f > a.width && cc.error(cc._LogInfos.RectWidth, a.url), g > a.height && cc.error(cc._LogInfos.RectHeight, a.url));
- this.texture = a;
- this.setTextureRect(d, e);
- this.batchNode = null;
- return this._quadDirty = !0
- };
- a._textureLoadedCallback = function(a) {
- if (!this._textureLoaded) {
- this._textureLoaded = !0;
- var d = this._rect;
- d ? cc._rectEqualToZero(d) && (d.width = a.width, d.height = a.height) : d = cc.rect(0, 0, a.width, a.height);
- this.texture = a;
- this.setTextureRect(d, this._rectRotated);
- this.batchNode = this._batchNode;
- this._quadDirty = !0;
- this._callLoadedEventCallbacks()
- }
- };
- a.setTextureRect = function(a, d, e) {
- this._rectRotated = d || !1;
- this.setContentSize(e || a);
- this.setVertexRect(a);
- this._setTextureCoords(a);
- a = this._unflippedOffsetPositionFromCenter;
- this._flippedX && (a.x = -a.x);
- this._flippedY && (a.y = -a.y);
- var f = this._rect;
- this._offsetPosition.x = a.x + (this._contentSize.width - f.width) / 2;
- this._offsetPosition.y = a.y + (this._contentSize.height - f.height) / 2;
- if (this._batchNode) this.dirty = !0;
- else {
- a = 0 + this._offsetPosition.x;
- d = 0 + this._offsetPosition.y;
- e = a + f.width;
- var f = d + f.height,
- g = this._quad;
- g.bl.vertices = {
- x: a,
- y: d,
- z: 0
- };
- g.br.vertices = {
- x: e,
- y: d,
- z: 0
- };
- g.tl.vertices = {
- x: a,
- y: f,
- z: 0
- };
- g.tr.vertices = {
- x: e,
- y: f,
- z: 0
- };
- this._quadDirty = !0
- }
- };
- a.updateTransform = function() {
- if (this.dirty) {
- var a = this._quad,
- d = this._parent;
- if (!this._visible || d && d != this._batchNode && d._shouldBeHidden) a.br.vertices = a.tl.vertices = a.tr.vertices = a.bl.vertices = {
- x: 0,
- y: 0,
- z: 0
- }, this._shouldBeHidden = !0;
- else {
- this._shouldBeHidden = !1;
- var e = this._transformToBatch = !d || d == this._batchNode ? this.nodeToParentTransform() : cc.affineTransformConcat(this.nodeToParentTransform(), d._transformToBatch),
- f = this._rect,
- d = this._offsetPosition.x,
- g = this._offsetPosition.y,
- h = d + f.width,
- k = g + f.height,
- m = e.tx,
- n = e.ty,
- q = e.a,
- r = e.b,
- t = e.d,
- s = -e.c,
- e = d * q - g * s + m,
- f = d * r + g * t + n,
- v = h * q - g * s + m,
- g = h * r + g * t + n,
- u = h * q - k * s + m,
- h = h * r + k * t + n,
- m = d * q - k * s + m,
- d = d * r + k * t + n,
- k = this._vertexZ;
- cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (e |= 0, f |= 0, v |= 0, g |= 0, u |= 0, h |= 0, m |= 0, d |= 0);
- a.bl.vertices = {
- x: e,
- y: f,
- z: k
- };
- a.br.vertices = {
- x: v,
- y: g,
- z: k
- };
- a.tl.vertices = {
- x: m,
- y: d,
- z: k
- };
- a.tr.vertices = {
- x: u,
- y: h,
- z: k
- }
- }
- this.textureAtlas.updateQuad(a, this.atlasIndex);
- this.dirty = this._recursiveDirty = !1
- }
- this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform);
- cc.SPRITE_DEBUG_DRAW && (a = [cc.p(this._quad.bl.vertices.x, this._quad.bl.vertices.y), cc.p(this._quad.br.vertices.x, this._quad.br.vertices.y), cc.p(this._quad.tr.vertices.x, this._quad.tr.vertices.y), cc.p(this._quad.tl.vertices.x, this._quad.tl.vertices.y)], cc._drawingUtil.drawPoly(a, 4, !0))
- };
- a.addChild = function(a, d, e) {
- cc.assert(a, cc._LogInfos.Sprite_addChild_3);
- null == d && (d = a._localZOrder);
- null == e && (e = a.tag);
- if (this._batchNode) {
- if (!(a instanceof cc.Sprite)) {
- cc.log(cc._LogInfos.Sprite_addChild);
- return
- }
- a.texture._webTextureObj !== this.textureAtlas.texture._webTextureObj && cc.log(cc._LogInfos.Sprite_addChild_2);
- this._batchNode.appendChild(a);
- this._reorderChildDirty || this._setReorderChildDirtyRecursively()
- }
- cc.Node.prototype.addChild.call(this, a, d, e);
- this._hasChildren = !0
- };
- a.setOpacity = function(a) {
- cc.Node.prototype.setOpacity.call(this, a);
- this.updateColor()
- };
- a.setColor = function(a) {
- cc.Node.prototype.setColor.call(this, a);
- this.updateColor()
- };
- a.updateDisplayedColor = function(a) {
- cc.Node.prototype.updateDisplayedColor.call(this, a);
- this.updateColor()
- };
- a.setSpriteFrame = function(a) {
- var d = this;
- "string" == typeof a && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.Sprite_setSpriteFrame));
- d.setNodeDirty(!0);
- var e = a.getOffset();
- d._unflippedOffsetPositionFromCenter.x = e.x;
- d._unflippedOffsetPositionFromCenter.y = e.y;
- e = a.getTexture();
- a.textureLoaded() || (d._textureLoaded = !1, a.addLoadedEventListener(function(a) {
- d._textureLoaded = !0;
- var c = a.getTexture();
- c != d._texture && (d.texture = c);
- d.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
- d._callLoadedEventCallbacks()
- }, d));
- e != d._texture && (d.texture = e);
- d._rectRotated = a.isRotated();
- d.setTextureRect(a.getRect(), d._rectRotated, a.getOriginalSize())
- };
- a.isFrameDisplayed = function(a) {
- return cc.rectEqualToRect(a.getRect(), this._rect) && a.getTexture().getName() == this._texture.getName() && cc.pointEqualToPoint(a.getOffset(), this._unflippedOffsetPositionFromCenter)
- };
- a.setBatchNode = function(a) {
- if (this._batchNode = a) this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.textureAtlas;
- else {
- this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED;
- this.textureAtlas = null;
- this.dirty = this._recursiveDirty = !1;
- a = this._offsetPosition.x;
- var d = this._offsetPosition.y,
- e = a + this._rect.width,
- f = d + this._rect.height,
- g = this._quad;
- g.bl.vertices = {
- x: a,
- y: d,
- z: 0
- };
- g.br.vertices = {
- x: e,
- y: d,
- z: 0
- };
- g.tl.vertices = {
- x: a,
- y: f,
- z: 0
- };
- g.tr.vertices = {
- x: e,
- y: f,
- z: 0
- };
- this._quadDirty = !0
- }
- };
- a.setTexture = function(a) {
- a && "string" === typeof a ? (a = cc.textureCache.addImage(a), this.setTexture(a), a = a.getContentSize(), this.setTextureRect(cc.rect(0, 0, a.width, a.height))) : (cc.assert(!a || a instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2), this._batchNode && this._batchNode.texture != a ? cc.log(cc._LogInfos.Sprite_setTexture) : (this.shaderProgram = a ? cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) : cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR), !this._batchNode && this._texture != a && (this._texture = a, this._updateBlendFunc())))
- };
- a.draw = function() {
- if (this._textureLoaded) {
- var a = cc._renderContext,
- d = this._texture;
- d ? d._isLoaded && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2DN(0, d), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.DYNAMIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(0, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(1, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.vertexAttribPointer(2, 2, a.FLOAT, !1, 24, 16), a.drawArrays(a.TRIANGLE_STRIP, 0, 4)) : (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2D(null), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (cc._renderContext.bufferData(cc._renderContext.ARRAY_BUFFER, this._quad.arrayBuffer, cc._renderContext.STATIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4));
- cc.g_NumberOfDraws++;
- if (0 !== cc.SPRITE_DEBUG_DRAW || this._showNode) 1 === cc.SPRITE_DEBUG_DRAW || this._showNode ? (a = this._quad, a = [cc.p(a.tl.vertices.x, a.tl.vertices.y), cc.p(a.bl.vertices.x, a.bl.vertices.y), cc.p(a.br.vertices.x, a.br.vertices.y), cc.p(a.tr.vertices.x, a.tr.vertices.y)], cc._drawingUtil.drawPoly(a, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (a = this.getTextureRect(), d = this.getOffsetPosition(), a = [cc.p(d.x, d.y), cc.p(d.x + a.width, d.y), cc.p(d.x + a.width, d.y + a.height), cc.p(d.x, d.y + a.height)], cc._drawingUtil.drawPoly(a, 4, !0))
- }
- };
- delete a
- };
- cc._tmp.PrototypeSprite = function() {
- var a = cc.Sprite.prototype;
- cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
- cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
- cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
- cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX);
- cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY);
- cc.defineGetterSetter(a, "offsetX", a._getOffsetX);
- cc.defineGetterSetter(a, "offsetY", a._getOffsetY);
- cc.defineGetterSetter(a, "texture", a.getTexture, a.setTexture);
- cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated);
- cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode);
- cc.defineGetterSetter(a, "quad", a.getQuad)
- };
- cc.generateTintImageWithMultiply = function(a, c, d, e) {
- e = e || cc.newElement("canvas");
- d = d || cc.rect(0, 0, a.width, a.height);
- var f = e.getContext("2d");
- e.width != d.width || e.height != d.height ? (e.width = d.width, e.height = d.height) : f.globalCompositeOperation = "source-over";
- f.fillStyle = "rgb(" + c.r + "," + c.g + "," + c.b + ")";
- f.fillRect(0, 0, d.width, d.height);
- f.globalCompositeOperation = "multiply";
- f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
- f.globalCompositeOperation = "destination-atop";
- f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
- return e
- };
- cc.generateTintImage = function(a, c, d, e, f) {
- e || (e = cc.rect(0, 0, a.width, a.height));
- a = d.r / 255;
- var g = d.g / 255;
- d = d.b / 255;
- var h = Math.min(e.width, c[0].width),
- k = Math.min(e.height, c[0].height),
- m;
- f ? (m = f.getContext("2d"), m.clearRect(0, 0, h, k)) : (f = cc.newElement("canvas"), f.width = h, f.height = k, m = f.getContext("2d"));
- m.save();
- m.globalCompositeOperation = "lighter";
- var n = m.globalAlpha;
- 0 < a && (m.globalAlpha = a * n, m.drawImage(c[0], e.x, e.y, h, k, 0, 0, h, k));
- 0 < g && (m.globalAlpha = g * n, m.drawImage(c[1], e.x, e.y, h, k, 0, 0, h, k));
- 0 < d && (m.globalAlpha = d * n, m.drawImage(c[2], e.x, e.y, h, k, 0, 0, h, k));
- 1 > a + g + d && (m.globalAlpha = n, m.drawImage(c[3], e.x, e.y, h, k, 0, 0, h, k));
- m.restore();
- return f
- };
- cc.generateTextureCacheForColor = function(a) {
- function c() {
- var c = cc.generateTextureCacheForColor,
- e = a.width,
- h = a.height;
- d[0].width = e;
- d[0].height = h;
- d[1].width = e;
- d[1].height = h;
- d[2].width = e;
- d[2].height = h;
- d[3].width = e;
- d[3].height = h;
- c.canvas.width = e;
- c.canvas.height = h;
- var k = c.canvas.getContext("2d");
- k.drawImage(a, 0, 0);
- c.tempCanvas.width = e;
- c.tempCanvas.height = h;
- for (var k = k.getImageData(0, 0, e, h).data, m = 0; 4 > m; m++) {
- var n = d[m].getContext("2d");
- n.getImageData(0, 0, e, h).data;
- c.tempCtx.drawImage(a, 0, 0);
- for (var q = c.tempCtx.getImageData(0, 0, e, h), r = q.data, t = 0; t < k.length; t += 4) r[t] = 0 === m ? k[t] : 0, r[t + 1] = 1 === m ? k[t + 1] : 0, r[t + 2] = 2 === m ? k[t + 2] : 0, r[t + 3] = k[t + 3];
- n.putImageData(q, 0, 0)
- }
- a.onload = null
- }
- if (a.channelCache) return a.channelCache;
- var d = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")];
- try {
- c()
- } catch (e) {
- a.onload = c
- }
- return a.channelCache = d
- };
- cc.generateTextureCacheForColor.canvas = cc.newElement("canvas");
- cc.generateTextureCacheForColor.tempCanvas = cc.newElement("canvas");
- cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext("2d");
- cc.cutRotateImageToCanvas = function(a, c) {
- if (!a) return null;
- if (!c) return a;
- var d = cc.newElement("canvas");
- d.width = c.width;
- d.height = c.height;
- var e = d.getContext("2d");
- e.translate(d.width / 2, d.height / 2);
- e.rotate(-1.5707963267948966);
- e.drawImage(a, c.x, c.y, c.height, c.width, -c.height / 2, -c.width / 2, c.height, c.width);
- return d
- };
- cc.Sprite = cc.Node.extend({
- dirty: !1,
- atlasIndex: 0,
- textureAtlas: null,
- _batchNode: null,
- _recursiveDirty: null,
- _hasChildren: null,
- _shouldBeHidden: !1,
- _transformToBatch: null,
- _blendFunc: null,
- _texture: null,
- _rect: null,
- _rectRotated: !1,
- _offsetPosition: null,
- _unflippedOffsetPositionFromCenter: null,
- _opacityModifyRGB: !1,
- _flippedX: !1,
- _flippedY: !1,
- _textureLoaded: !1,
- _loadedEventListeners: null,
- _newTextureWhenChangeColor: null,
- _className: "Sprite",
- _oldDisplayColor: cc.color.WHITE,
- textureLoaded: function() {
- return this._textureLoaded
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners || (this._loadedEventListeners = []);
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- _callLoadedEventCallbacks: function() {
- if (this._loadedEventListeners) {
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- },
- isDirty: function() {
- return this.dirty
- },
- setDirty: function(a) {
- this.dirty = a
- },
- isTextureRectRotated: function() {
- return this._rectRotated
- },
- getAtlasIndex: function() {
- return this.atlasIndex
- },
- setAtlasIndex: function(a) {
- this.atlasIndex = a
- },
- getTextureRect: function() {
- return cc.rect(this._rect.x, this._rect.y, this._rect.width, this._rect.height)
- },
- getTextureAtlas: function() {
- return this.textureAtlas
- },
- setTextureAtlas: function(a) {
- this.textureAtlas = a
- },
- getOffsetPosition: function() {
- return cc.p(this._offsetPosition)
- },
- _getOffsetX: function() {
- return this._offsetPosition.x
- },
- _getOffsetY: function() {
- return this._offsetPosition.y
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- initWithSpriteFrame: function(a) {
- cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrame);
- a.textureLoaded() || (this._textureLoaded = !1, a.addLoadedEventListener(this._spriteFrameLoadedCallback, this));
- var c = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated,
- c = this.initWithTexture(a.getTexture(), a.getRect(), c);
- this.setSpriteFrame(a);
- return c
- },
- _spriteFrameLoadedCallback: null,
- initWithSpriteFrameName: function(a) {
- cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName);
- var c = cc.spriteFrameCache.getSpriteFrame(a);
- cc.assert(c, a + cc._LogInfos.Sprite_initWithSpriteFrameName1);
- return this.initWithSpriteFrame(c)
- },
- useBatchNode: function(a) {
- this.textureAtlas = a.textureAtlas;
- this._batchNode = a
- },
- setVertexRect: function(a) {
- this._rect.x = a.x;
- this._rect.y = a.y;
- this._rect.width = a.width;
- this._rect.height = a.height
- },
- sortAllChildren: function() {
- if (this._reorderChildDirty) {
- var a = this._children,
- c = a.length,
- d, e, f;
- for (d = 1; d < c; d++) {
- f = a[d];
- for (e = d - 1; 0 <= e;) {
- if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
- else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
- else break;
- e--
- }
- a[e + 1] = f
- }
- this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node.StateCallbackType.sortAllChildren);
- this._reorderChildDirty = !1
- }
- },
- reorderChild: function(a, c) {
- cc.assert(a, cc._LogInfos.Sprite_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.Sprite_reorderChild) : c !== a.zIndex && (this._batchNode && !this._reorderChildDirty && (this._setReorderChildDirtyRecursively(), this._batchNode.reorderBatch(!0)), cc.Node.prototype.reorderChild.call(this, a, c))
- },
- removeChild: function(a, c) {
- this._batchNode && this._batchNode.removeSpriteFromAtlas(a);
- cc.Node.prototype.removeChild.call(this, a, c)
- },
- setVisible: function(a) {
- cc.Node.prototype.setVisible.call(this, a);
- this.setDirtyRecursively(!0)
- },
- removeAllChildren: function(a) {
- var c = this._children,
- d = this._batchNode;
- if (d && null != c)
- for (var e = 0, f = c.length; e < f; e++) d.removeSpriteFromAtlas(c[e]);
- cc.Node.prototype.removeAllChildren.call(this, a);
- this._hasChildren = !1
- },
- setDirtyRecursively: function(a) {
- this.dirty = this._recursiveDirty = a;
- a = this._children;
- for (var c, d = a ? a.length : 0, e = 0; e < d; e++) c = a[e], c instanceof cc.Sprite && c.setDirtyRecursively(!0)
- },
- setNodeDirty: function(a) {
- cc.Node.prototype.setNodeDirty.call(this);
- !a && (this._batchNode && !this._recursiveDirty) && (this._hasChildren ? this.setDirtyRecursively(!0) : this.dirty = this._recursiveDirty = !0)
- },
- ignoreAnchorPointForPosition: function(a) {
- this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a)
- },
- setFlippedX: function(a) {
- this._flippedX != a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
- },
- setFlippedY: function(a) {
- this._flippedY != a && (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
- },
- isFlippedX: function() {
- return this._flippedX
- },
- isFlippedY: function() {
- return this._flippedY
- },
- setOpacityModifyRGB: null,
- isOpacityModifyRGB: function() {
- return this._opacityModifyRGB
- },
- updateDisplayedOpacity: null,
- setDisplayFrameWithAnimationName: function(a, c) {
- cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
- var d = cc.animationCache.getAnimation(a);
- d ? (d = d.getFrames()[c]) ? this.setSpriteFrame(d.getSpriteFrame()) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)
- },
- getBatchNode: function() {
- return this._batchNode
- },
- _setReorderChildDirtyRecursively: function() {
- if (!this._reorderChildDirty) {
- this._reorderChildDirty = !0;
- for (var a = this._parent; a && a != this._batchNode;) a._setReorderChildDirtyRecursively(), a = a.parent
- }
- },
- getTexture: function() {
- return this._texture
- },
- _quad: null,
- _quadWebBuffer: null,
- _quadDirty: !1,
- _colorized: !1,
- _isLighterMode: !1,
- _originalTexture: null,
- _textureRect_Canvas: null,
- _drawSize_Canvas: null,
- ctor: null,
- _softInit: function(a, c, d) {
- if (void 0 === a) cc.Sprite.prototype.init.call(this);
- else if ("string" === typeof a) "#" === a[0] ? (a = a.substr(1, a.length - 1), a = cc.spriteFrameCache.getSpriteFrame(a), this.initWithSpriteFrame(a)) : cc.Sprite.prototype.init.call(this, a, c);
- else if ("object" === typeof a)
- if (a instanceof cc.Texture2D) this.initWithTexture(a, c, d);
- else if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a);
- else if (a instanceof HTMLImageElement || a instanceof HTMLCanvasElement) c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.initWithTexture(c)
- },
- getQuad: function() {
- return this._quad
- },
- setBlendFunc: null,
- init: null,
- initWithFile: function(a, c) {
- cc.assert(a, cc._LogInfos.Sprite_initWithFile);
- var d = cc.textureCache.textureForKey(a);
- if (d) {
- if (!c) {
- var e = d.getContentSize();
- c = cc.rect(0, 0, e.width, e.height)
- }
- return this.initWithTexture(d, c)
- }
- d = cc.textureCache.addImage(a);
- return this.initWithTexture(d, c || cc.rect(0, 0, d._contentSize.width, d._contentSize.height))
- },
- initWithTexture: null,
- _textureLoadedCallback: null,
- setTextureRect: null,
- updateTransform: null,
- addChild: null,
- updateColor: function() {
- var a = this._displayedColor,
- c = this._displayedOpacity,
- a = {
- r: a.r,
- g: a.g,
- b: a.b,
- a: c
- };
- this._opacityModifyRGB && (a.r *= c / 255, a.g *= c / 255, a.b *= c / 255);
- c = this._quad;
- c.bl.colors = a;
- c.br.colors = a;
- c.tl.colors = a;
- c.tr.colors = a;
- this._batchNode && (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED ? this.textureAtlas.updateQuad(c, this.atlasIndex) : this.dirty = !0);
- this._quadDirty = !0
- },
- setOpacity: null,
- setColor: null,
- updateDisplayedColor: null,
- setSpriteFrame: null,
- setDisplayFrame: function(a) {
- cc.log(cc._LogInfos.Sprite_setDisplayFrame);
- this.setSpriteFrame(a)
- },
- isFrameDisplayed: null,
- displayFrame: function() {
- return cc.SpriteFrame.create(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize))
- },
- setBatchNode: null,
- setTexture: null,
- _updateBlendFunc: function() {
- this._batchNode ? cc.log(cc._LogInfos.Sprite__updateBlendFunc) : !this._texture || !this._texture.hasPremultipliedAlpha() ? (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA, this.opacityModifyRGB = !1) : (this._blendFunc.src = cc.BLEND_SRC, this._blendFunc.dst = cc.BLEND_DST, this.opacityModifyRGB = !0)
- },
- _changeTextureColor: function() {
- var a, c = this._texture,
- d = this._textureRect_Canvas;
- if (c && (d.validRect && this._originalTexture) && (a = c.getHtmlElementObj())) this._colorized = !0, a instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, d, a) : (a = cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, d), c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.texture = c)
- },
- _setTextureCoords: function(a) {
- a = cc.rectPointsToPixels(a);
- var c = this._batchNode ? this.textureAtlas.texture : this._texture;
- if (c) {
- var d = c.pixelsWidth,
- e = c.pixelsHeight,
- f, g = this._quad;
- this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (c = (2 * a.x + 1) / (2 * d), d = c + (2 * a.height - 2) / (2 * d), f = (2 * a.y + 1) / (2 * e), a = f + (2 * a.width - 2) / (2 * e)) : (c = a.x / d, d = (a.x + a.height) / d, f = a.y / e, a = (a.y + a.width) / e), this._flippedX && (e = f, f = a, a = e), this._flippedY && (e = c, c = d, d = e), g.bl.texCoords.u = c, g.bl.texCoords.v = f, g.br.texCoords.u = c, g.br.texCoords.v = a, g.tl.texCoords.u = d, g.tl.texCoords.v = f, g.tr.texCoords.u = d, g.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (c = (2 * a.x + 1) / (2 * d), d = c + (2 * a.width - 2) / (2 * d), f = (2 * a.y + 1) / (2 * e), a = f + (2 * a.height - 2) / (2 * e)) : (c = a.x / d, d = (a.x + a.width) / d, f = a.y / e, a = (a.y + a.height) / e), this._flippedX && (e = c, c = d, d = e), this._flippedY && (e = f, f = a, a = e), g.bl.texCoords.u = c, g.bl.texCoords.v = a, g.br.texCoords.u = d, g.br.texCoords.v = a, g.tl.texCoords.u = c, g.tl.texCoords.v = f, g.tr.texCoords.u = d, g.tr.texCoords.v = f);
- this._quadDirty = !0
- }
- },
- draw: null
- });
- cc.Sprite.create = function(a, c, d) {
- return new cc.Sprite(a, c, d)
- };
- cc.Sprite.createWithTexture = cc.Sprite.create;
- cc.Sprite.createWithSpriteFrameName = cc.Sprite.create;
- cc.Sprite.createWithSpriteFrame = cc.Sprite.create;
- cc.Sprite.INDEX_NOT_INITIALIZED = -1;
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Sprite.prototype, _p._spriteFrameLoadedCallback = function(a) {
- this.setNodeDirty(!0);
- this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
- a = this.color;
- (255 !== a.r || 255 !== a.g || 255 !== a.b) && this._changeTextureColor();
- this._callLoadedEventCallbacks()
- }, _p.setOpacityModifyRGB = function(a) {
- this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.setNodeDirty(!0))
- }, _p.updateDisplayedOpacity = function(a) {
- cc.Node.prototype.updateDisplayedOpacity.call(this, a);
- this._setNodeDirtyForCache()
- }, _p.ctor = function(a, c, d) {
- cc.Node.prototype.ctor.call(this);
- this._shouldBeHidden = !1;
- this._offsetPosition = cc.p(0, 0);
- this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- this._rect = cc.rect(0, 0, 0, 0);
- this._newTextureWhenChangeColor = !1;
- this._textureLoaded = !0;
- this._textureRect_Canvas = {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- validRect: !1
- };
- this._drawSize_Canvas = cc.size(0, 0);
- this._softInit(a, c, d)
- }, _p.setBlendFunc = function(a, c) {
- var d = this._blendFunc;
- void 0 === c ? (d.src = a.src, d.dst = a.dst) : (d.src = a, d.dst = c);
- this._isLighterMode = d && (d.src == cc.SRC_ALPHA && d.dst == cc.ONE || d.src == cc.ONE && d.dst == cc.ONE)
- }, _p.init = function() {
- if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
- cc.Node.prototype.init.call(this);
- this.dirty = this._recursiveDirty = !1;
- this._opacityModifyRGB = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- this.texture = null;
- this._textureLoaded = !0;
- this._flippedX = this._flippedY = !1;
- this.anchorY = this.anchorX = 0.5;
- this._offsetPosition.x = 0;
- this._offsetPosition.y = 0;
- this._hasChildren = !1;
- this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
- return !0
- }, _p.initWithTexture = function(a, c, d) {
- cc.assert(0 != arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
- if ((d = d || !1) && a.isLoaded()) {
- var e = a.getHtmlElementObj(),
- e = cc.cutRotateImageToCanvas(e, c),
- f = new cc.Texture2D;
- f.initWithElement(e);
- f.handleLoadedTexture();
- a = f;
- this._rect = cc.rect(0, 0, c.width, c.height)
- }
- if (!cc.Node.prototype.init.call(this)) return !1;
- this._batchNode = null;
- this.dirty = this._recursiveDirty = !1;
- this._opacityModifyRGB = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- this._flippedX = this._flippedY = !1;
- this.anchorY = this.anchorX = 0.5;
- this._offsetPosition.x = 0;
- this._offsetPosition.y = 0;
- this._hasChildren = !1;
- this._textureLoaded = e = a.isLoaded();
- if (!e) return this._rectRotated = d, c && (this._rect.x = c.x, this._rect.y = c.y, this._rect.width = c.width, this._rect.height = c.height), a.addLoadedEventListener(this._textureLoadedCallback, this), !0;
- c || (c = cc.rect(0, 0, a.width, a.height));
- a && a.url && (e = c.y + c.height, c.x + c.width > a.width && cc.error(cc._LogInfos.RectWidth, a.url), e > a.height && cc.error(cc._LogInfos.RectHeight, a.url));
- this.texture = this._originalTexture = a;
- this.setTextureRect(c, d);
- this.batchNode = null;
- return !0
- }, _p._textureLoadedCallback = function(a) {
- if (!this._textureLoaded) {
- this._textureLoaded = !0;
- var c = this._rect;
- c ? cc._rectEqualToZero(c) && (c.width = a.width, c.height = a.height) : c = cc.rect(0, 0, a.width, a.height);
- this.texture = this._originalTexture = a;
- this.setTextureRect(c, this._rectRotated);
- a = this._displayedColor;
- (255 != a.r || 255 != a.g || 255 != a.b) && this._changeTextureColor();
- this.batchNode = this._batchNode;
- this._callLoadedEventCallbacks()
- }
- }, _p.setTextureRect = function(a, c, d) {
- this._rectRotated = c || !1;
- this.setContentSize(d || a);
- this.setVertexRect(a);
- c = this._textureRect_Canvas;
- d = cc.contentScaleFactor();
- c.x = 0 | a.x * d;
- c.y = 0 | a.y * d;
- c.width = 0 | a.width * d;
- c.height = 0 | a.height * d;
- c.validRect = !(0 === c.width || 0 === c.height || 0 > c.x || 0 > c.y);
- a = this._unflippedOffsetPositionFromCenter;
- this._flippedX && (a.x = -a.x);
- this._flippedY && (a.y = -a.y);
- this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
- this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
- this._batchNode && (this.dirty = !0)
- }, _p.updateTransform = function() {
- if (this.dirty) {
- var a = this._parent;
- !this._visible || a && a != this._batchNode && a._shouldBeHidden ? this._shouldBeHidden = !0 : (this._shouldBeHidden = !1, this._transformToBatch = !a || a == this._batchNode ? this.nodeToParentTransform() : cc.affineTransformConcat(this.nodeToParentTransform(), a._transformToBatch));
- this.dirty = this._recursiveDirty = !1
- }
- this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
- }, _p.addChild = function(a, c, d) {
- cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2);
- null == c && (c = a._localZOrder);
- null == d && (d = a.tag);
- cc.Node.prototype.addChild.call(this, a, c, d);
- this._hasChildren = !0
- }, _p.setOpacity = function(a) {
- cc.Node.prototype.setOpacity.call(this, a);
- this._setNodeDirtyForCache()
- }, _p.setColor = function(a) {
- var c = this.color;
- this._oldDisplayColor = c;
- c.r === a.r && c.g === a.g && c.b === a.b || cc.Node.prototype.setColor.call(this, a)
- }, _p.updateDisplayedColor = function(a) {
- cc.Node.prototype.updateDisplayedColor.call(this, a);
- a = this._oldDisplayColor;
- var c = this._displayedColor;
- a.r === c.r && a.g === c.g && a.b === c.b || (this._changeTextureColor(), this._setNodeDirtyForCache())
- }, _p.setSpriteFrame = function(a) {
- var c = this;
- "string" == typeof a && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame));
- c.setNodeDirty(!0);
- var d = a.getOffset();
- c._unflippedOffsetPositionFromCenter.x = d.x;
- c._unflippedOffsetPositionFromCenter.y = d.y;
- c._rectRotated = a.isRotated();
- var d = a.getTexture(),
- e = a.textureLoaded();
- e || (c._textureLoaded = !1, a.addLoadedEventListener(function(a) {
- c._textureLoaded = !0;
- var d = a.getTexture();
- d != c._texture && (c.texture = d);
- c.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
- c._callLoadedEventCallbacks()
- }, c));
- d != c._texture && (c.texture = d);
- c._rectRotated && (c._originalTexture = d);
- c.setTextureRect(a.getRect(), c._rectRotated, a.getOriginalSize());
- c._colorized = !1;
- e && (a = c.color, (255 !== a.r || 255 !== a.g || 255 !== a.b) && c._changeTextureColor())
- }, _p.isFrameDisplayed = function(a) {
- return a.getTexture() != this._texture ? !1 : cc.rectEqualToRect(a.getRect(), this._rect)
- }, _p.setBatchNode = function(a) {
- (this._batchNode = a) ? (this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.textureAtlas) : (this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED, this.textureAtlas = null, this.dirty = this._recursiveDirty = !1)
- }, _p.setTexture = function(a) {
- a && "string" === typeof a ? (a = cc.textureCache.addImage(a), this.setTexture(a), a = a.getContentSize(), this.setTextureRect(cc.rect(0, 0, a.width, a.height))) : (cc.assert(!a || a instanceof cc.Texture2D, cc._LogInfos.CCSpriteBatchNode_setTexture), this._texture != a && (a && a.getHtmlElementObj() instanceof HTMLImageElement && (this._originalTexture = a), this._texture = a))
- }, _p.draw = function(a) {
- if (this._textureLoaded) {
- a = a || cc._renderContext;
- this._isLighterMode && (a.globalCompositeOperation = "lighter");
- var c = cc.view.getScaleX(),
- d = cc.view.getScaleY();
- a.globalAlpha = this._displayedOpacity / 255;
- var e = this._rect,
- f = this._contentSize,
- g = this._offsetPosition,
- h = this._drawSize_Canvas,
- k = 0 | g.x,
- m = -g.y - e.height,
- n = this._textureRect_Canvas;
- h.width = e.width * c;
- h.height = e.height * d;
- if (this._flippedX || this._flippedY) a.save(), this._flippedX && (k = -g.x - e.width, a.scale(-1, 1)), this._flippedY && (m = g.y, a.scale(1, -1));
- k *= c;
- m *= d;
- this._texture && n.validRect ? (f = this._texture.getHtmlElementObj(), this._colorized ? a.drawImage(f, 0, 0, n.width, n.height, k, m, h.width, h.height) : a.drawImage(f, n.x, n.y, n.width, n.height, k, m, h.width, h.height)) : !this._texture && n.validRect && (h = this.color, a.fillStyle = "rgba(" + h.r + "," + h.g + "," + h.b + ",1)", a.fillRect(k, m, f.width * c, f.height * d));
- 1 === cc.SPRITE_DEBUG_DRAW || this._showNode ? (a.strokeStyle = "rgba(0,255,0,1)", k /= c, m = -(m / d), k = [cc.p(k, m), cc.p(k + e.width, m), cc.p(k + e.width, m - e.height), cc.p(k, m - e.height)], cc._drawingUtil.drawPoly(k, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (a.strokeStyle = "rgba(0,255,0,1)", c = this._rect, m = -m, k = [cc.p(k, m), cc.p(k + c.width, m), cc.p(k + c.width, m - c.height), cc.p(k, m - c.height)], cc._drawingUtil.drawPoly(k, 4, !0));
- (this._flippedX || this._flippedY) && a.restore();
- cc.g_NumberOfDraws++
- }
- }, cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function() {
- var a, c = this._texture,
- d = this._textureRect_Canvas;
- if (c && (d.validRect && this._originalTexture) && (a = c.getHtmlElementObj()))
- if (c = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())) this._colorized = !0, a instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.generateTintImage(a, c, this._displayedColor, d, a) : (a = cc.generateTintImage(a, c, this._displayedColor, d), c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.texture = c)
- }), delete _p) : (cc.assert("function" === typeof cc._tmp.WebGLSprite, cc._LogInfos.MissingFile, "SpritesWebGL.js"), cc._tmp.WebGLSprite(), delete cc._tmp.WebGLSprite);
- cc.assert("function" === typeof cc._tmp.PrototypeSprite, cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
- cc._tmp.PrototypeSprite();
- delete cc._tmp.PrototypeSprite;
- cc.DEFAULT_SPRITE_BATCH_CAPACITY = 29;
- cc.SpriteBatchNode = cc.Node.extend({
- textureAtlas: null,
- _blendFunc: null,
- _descendants: null,
- _className: "SpriteBatchNode",
- addSpriteWithoutQuad: function(a, c, d) {
- cc.assert(a, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2);
- if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad), null;
- a.atlasIndex = c;
- var e = 0,
- f = this._descendants;
- if (f && 0 < f.length)
- for (var g = 0; g < f.length; g++) {
- var h = f[g];
- h && h.atlasIndex >= c && ++e
- }
- f.splice(e, 0, a);
- cc.Node.prototype.addChild.call(this, a, c, d);
- this.reorderBatch(!1);
- return this
- },
- getTextureAtlas: function() {
- return this.textureAtlas
- },
- setTextureAtlas: function(a) {
- a != this.textureAtlas && (this.textureAtlas = a)
- },
- getDescendants: function() {
- return this._descendants
- },
- initWithFile: function(a, c) {
- var d = cc.textureCache.textureForKey(a);
- d || (d = cc.textureCache.addImage(a));
- return this.initWithTexture(d, c)
- },
- _setNodeDirtyForCache: function() {
- this._cacheDirty = !0
- },
- init: function(a, c) {
- var d = cc.textureCache.textureForKey(a);
- d || (d = cc.textureCache.addImage(a));
- return this.initWithTexture(d, c)
- },
- increaseAtlasCapacity: function() {
- var a = this.textureAtlas.capacity,
- c = Math.floor(4 * (a + 1) / 3);
- cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, a, c);
- this.textureAtlas.resizeCapacity(c) || cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)
- },
- removeChildAtIndex: function(a, c) {
- this.removeChild(this._children[a], c)
- },
- rebuildIndexInOrder: function(a, c) {
- var d = a.children;
- if (d && 0 < d.length)
- for (var e = 0; e < d.length; e++) {
- var f = d[e];
- f && 0 > f.zIndex && (c = this.rebuildIndexInOrder(f, c))
- }!a == this && (a.atlasIndex = c, c++);
- if (d && 0 < d.length)
- for (e = 0; e < d.length; e++)(f = d[e]) && 0 <= f.zIndex && (c = this.rebuildIndexInOrder(f, c));
- return c
- },
- highestAtlasIndexInChild: function(a) {
- var c = a.children;
- return !c || 0 == c.length ? a.atlasIndex : this.highestAtlasIndexInChild(c[c.length - 1])
- },
- lowestAtlasIndexInChild: function(a) {
- var c = a.children;
- return !c || 0 == c.length ? a.atlasIndex : this.lowestAtlasIndexInChild(c[c.length - 1])
- },
- atlasIndexForChild: function(a, c) {
- var d = a.parent,
- e = d.children,
- f = e.indexOf(a),
- g = null;
- 0 < f && f < cc.UINT_MAX && (g = e[f - 1]);
- return d == this ? 0 == f ? 0 : this.highestAtlasIndexInChild(g) + 1 : 0 == f ? 0 > c ? d.atlasIndex : d.atlasIndex + 1 : 0 > g.zIndex && 0 > c || 0 <= g.zIndex && 0 <= c ? this.highestAtlasIndexInChild(g) + 1 : d.atlasIndex + 1
- },
- reorderBatch: function(a) {
- this._reorderChildDirty = a
- },
- setBlendFunc: function(a, c) {
- this._blendFunc = void 0 === c ? a : {
- src: a,
- dst: c
- }
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- reorderChild: function(a, c) {
- cc.assert(a, cc._LogInfos.SpriteBatchNode_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_reorderChild) : c !== a.zIndex && (cc.Node.prototype.reorderChild.call(this, a, c), this.setNodeDirty())
- },
- removeChild: function(a, c) {
- null != a && (-1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_removeChild) : (this.removeSpriteFromAtlas(a), cc.Node.prototype.removeChild.call(this, a, c)))
- },
- _mvpMatrix: null,
- _textureForCanvas: null,
- _useCache: !1,
- _originalTexture: null,
- ctor: null,
- _ctorForCanvas: function(a, c) {
- cc.Node.prototype.ctor.call(this);
- var d;
- c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
- "string" == typeof a ? (d = cc.textureCache.textureForKey(a)) || (d = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (d = a);
- d && this.initWithTexture(d, c)
- },
- _ctorForWebGL: function(a, c) {
- cc.Node.prototype.ctor.call(this);
- this._mvpMatrix = new cc.kmMat4;
- var d;
- c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
- "string" == typeof a ? (d = cc.textureCache.textureForKey(a)) || (d = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (d = a);
- d && this.initWithTexture(d, c)
- },
- updateQuadFromSprite: null,
- _updateQuadFromSpriteForCanvas: function(a, c) {
- cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2);
- a instanceof cc.Sprite ? (a.batchNode = this, a.atlasIndex = c, a.dirty = !0, a.updateTransform()) : cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
- },
- _updateQuadFromSpriteForWebGL: function(a, c) {
- cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite);
- if (a instanceof cc.Sprite) {
- for (var d = this.textureAtlas.capacity; c >= d || d == this.textureAtlas.totalQuads;) this.increaseAtlasCapacity();
- a.batchNode = this;
- a.atlasIndex = c;
- a.dirty = !0;
- a.updateTransform()
- } else cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
- },
- _swap: function(a, c) {
- var d = this._descendants,
- e = this.textureAtlas,
- f = e.quads,
- g = d[a],
- h = cc.V3F_C4B_T2F_QuadCopy(f[a]);
- d[c].atlasIndex = a;
- d[a] = d[c];
- e.updateQuad(f[c], a);
- d[c] = g;
- e.updateQuad(h, c)
- },
- insertQuadFromSprite: null,
- _insertQuadFromSpriteForCanvas: function(a, c) {
- cc.assert(a, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2);
- a instanceof cc.Sprite ? (a.batchNode = this, a.atlasIndex = c, a.dirty = !0, a.updateTransform(), this._children.splice(c, 0, a)) : cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite)
- },
- _insertQuadFromSpriteForWebGL: function(a, c) {
- cc.assert(a, cc._LogInfos.Sprite_insertQuadFromSprite_2);
- if (a instanceof cc.Sprite) {
- for (var d = this.textureAtlas; c >= d.capacity || d.capacity === d.totalQuads;) this.increaseAtlasCapacity();
- a.batchNode = this;
- a.atlasIndex = c;
- d.insertQuad(a.quad, c);
- a.dirty = !0;
- a.updateTransform()
- } else cc.log(cc._LogInfos.Sprite_insertQuadFromSprite)
- },
- _updateAtlasIndex: function(a, c) {
- var d = 0,
- e = a.children;
- e && (d = e.length);
- var f = 0;
- if (0 === d) f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++;
- else {
- f = !0;
- 0 <= e[0].zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++, f = !1);
- for (d = 0; d < e.length; d++) {
- var g = e[d];
- f && 0 <= g.zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++, f = !1);
- c = this._updateAtlasIndex(g, c)
- }
- f && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++)
- }
- return c
- },
- _updateBlendFunc: function() {
- this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
- },
- initWithTexture: null,
- _initWithTextureForCanvas: function(a, c) {
- this._children = [];
- this._descendants = [];
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- this._textureForCanvas = this._originalTexture = a;
- return !0
- },
- _initWithTextureForWebGL: function(a, c) {
- this._children = [];
- this._descendants = [];
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
- this.textureAtlas = new cc.TextureAtlas;
- this.textureAtlas.initWithTexture(a, c);
- this._updateBlendFunc();
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
- return !0
- },
- insertChild: function(a, c) {
- a.batchNode = this;
- a.atlasIndex = c;
- a.dirty = !0;
- var d = this.textureAtlas;
- d.totalQuads >= d.capacity && this.increaseAtlasCapacity();
- d.insertQuad(a.quad, c);
- this._descendants.splice(c, 0, a);
- var d = c + 1,
- e = this._descendants;
- if (e && 0 < e.length)
- for (; d < e.length; d++) e[d].atlasIndex++;
- var e = a.children,
- f;
- if (e) {
- d = 0;
- for (l = e.length || 0; d < l; d++)
- if (f = e[d]) {
- var g = this.atlasIndexForChild(f, f.zIndex);
- this.insertChild(f, g)
- }
- }
- },
- appendChild: null,
- _appendChildForCanvas: function(a) {
- this._reorderChildDirty = !0;
- a.batchNode = this;
- a.dirty = !0;
- this._descendants.push(a);
- a.atlasIndex = this._descendants.length - 1;
- a = a.children;
- for (var c = 0, d = a.length || 0; c < d; c++) this.appendChild(a[c])
- },
- _appendChildForWebGL: function(a) {
- this._reorderChildDirty = !0;
- a.batchNode = this;
- a.dirty = !0;
- this._descendants.push(a);
- var c = this._descendants.length - 1;
- a.atlasIndex = c;
- var d = this.textureAtlas;
- d.totalQuads == d.capacity && this.increaseAtlasCapacity();
- d.insertQuad(a.quad, c);
- a = a.children;
- c = 0;
- for (d = a.length || 0; c < d; c++) this.appendChild(a[c])
- },
- removeSpriteFromAtlas: null,
- _removeSpriteFromAtlasForCanvas: function(a) {
- a.batchNode = null;
- var c = this._descendants,
- d = c.indexOf(a);
- if (-1 != d) {
- c.splice(d, 1);
- for (var e = c.length; d < e; ++d) c[d].atlasIndex--
- }
- if (a = a.children) {
- c = 0;
- for (d = a.length || 0; c < d; c++) a[c] && this.removeSpriteFromAtlas(a[c])
- }
- },
- _removeSpriteFromAtlasForWebGL: function(a) {
- this.textureAtlas.removeQuadAtIndex(a.atlasIndex);
- a.batchNode = null;
- var c = this._descendants,
- d = c.indexOf(a);
- if (-1 != d) {
- c.splice(d, 1);
- for (var e = c.length; d < e; ++d) c[d].atlasIndex--
- }
- if (a = a.children) {
- c = 0;
- for (d = a.length || 0; c < d; c++) a[c] && this.removeSpriteFromAtlas(a[c])
- }
- },
- getTexture: null,
- _getTextureForCanvas: function() {
- return this._textureForCanvas
- },
- _getTextureForWebGL: function() {
- return this.textureAtlas.texture
- },
- setTexture: null,
- _setTextureForCanvas: function(a) {
- this._textureForCanvas = a;
- for (var c = this._children, d = 0; d < c.length; d++) c[d].texture = a
- },
- _setTextureForWebGL: function(a) {
- this.textureAtlas.texture = a;
- this._updateBlendFunc()
- },
- visit: null,
- _visitForCanvas: function(a) {
- var c = a || cc._renderContext;
- if (this._visible) {
- c.save();
- this.transform(a);
- var d = this._children;
- if (d) {
- this.sortAllChildren();
- for (a = 0; a < d.length; a++) d[a] && d[a].visit(c)
- }
- c.restore()
- }
- },
- _visitForWebGL: function(a) {
- a = a || cc._renderContext;
- if (this._visible) {
- cc.kmGLPushMatrix();
- var c = this.grid;
- c && c.isActive() && (c.beforeDraw(), this.transformAncestors());
- this.sortAllChildren();
- this.transform(a);
- this.draw(a);
- c && c.isActive() && c.afterDraw(this);
- cc.kmGLPopMatrix();
- this.arrivalOrder = 0
- }
- },
- addChild: null,
- _addChildForCanvas: function(a, c, d) {
- cc.assert(null != a, cc._LogInfos.CCSpriteBatchNode_addChild_3);
- a instanceof cc.Sprite ? (c = null == c ? a.zIndex : c, d = null == d ? a.tag : d, cc.Node.prototype.addChild.call(this, a, c, d), this.appendChild(a), this.setNodeDirty()) : cc.log(cc._LogInfos.CCSpriteBatchNode_addChild)
- },
- _addChildForWebGL: function(a, c, d) {
- cc.assert(null != a, cc._LogInfos.Sprite_addChild_6);
- a instanceof cc.Sprite ? a.texture != this.textureAtlas.texture ? cc.log(cc._LogInfos.Sprite_addChild_5) : (c = null == c ? a.zIndex : c, d = null == d ? a.tag : d, cc.Node.prototype.addChild.call(this, a, c, d), this.appendChild(a), this.setNodeDirty()) : cc.log(cc._LogInfos.Sprite_addChild_4)
- },
- removeAllChildren: null,
- _removeAllChildrenForCanvas: function(a) {
- var c = this._descendants;
- if (c && 0 < c.length)
- for (var d = 0, e = c.length; d < e; d++) c[d] && (c[d].batchNode = null);
- cc.Node.prototype.removeAllChildren.call(this, a);
- this._descendants.length = 0
- },
- _removeAllChildrenForWebGL: function(a) {
- var c = this._descendants;
- if (c && 0 < c.length)
- for (var d = 0, e = c.length; d < e; d++) c[d] && (c[d].batchNode = null);
- cc.Node.prototype.removeAllChildren.call(this, a);
- this._descendants.length = 0;
- this.textureAtlas.removeAllQuads()
- },
- sortAllChildren: null,
- _sortAllChildrenForCanvas: function() {
- if (this._reorderChildDirty) {
- var a, c = 0,
- d = this._children,
- e = d.length,
- f;
- for (a = 1; a < e; a++) {
- var g = d[a],
- c = a - 1;
- for (f = d[c]; 0 <= c && (g._localZOrder < f._localZOrder || g._localZOrder == f._localZOrder && g.arrivalOrder < f.arrivalOrder);) d[c + 1] = f, c -= 1, f = d[c];
- d[c + 1] = g
- }
- 0 < d.length && this._arrayMakeObjectsPerformSelector(d, cc.Node.StateCallbackType.sortAllChildren);
- this._reorderChildDirty = !1
- }
- },
- _sortAllChildrenForWebGL: function() {
- if (this._reorderChildDirty) {
- var a = this._children,
- c, d = 0,
- e = a.length,
- f;
- for (c = 1; c < e; c++) {
- var g = a[c],
- d = c - 1;
- for (f = a[d]; 0 <= d && (g._localZOrder < f._localZOrder || g._localZOrder == f._localZOrder && g.arrivalOrder < f.arrivalOrder);) a[d + 1] = f, d -= 1, f = a[d];
- a[d + 1] = g
- }
- if (0 < a.length) {
- this._arrayMakeObjectsPerformSelector(a, cc.Node.StateCallbackType.sortAllChildren);
- for (c = d = 0; c < a.length; c++) d = this._updateAtlasIndex(a[c], d)
- }
- this._reorderChildDirty = !1
- }
- },
- draw: null,
- _drawForWebGL: function() {
- 0 !== this.textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), this.textureAtlas.drawQuads())
- }
- });
- _p = cc.SpriteBatchNode.prototype;
- cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.ctor = _p._ctorForWebGL, _p.updateQuadFromSprite = _p._updateQuadFromSpriteForWebGL, _p.insertQuadFromSprite = _p._insertQuadFromSpriteForWebGL, _p.initWithTexture = _p._initWithTextureForWebGL, _p.appendChild = _p._appendChildForWebGL, _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForWebGL, _p.getTexture = _p._getTextureForWebGL, _p.setTexture = _p._setTextureForWebGL, _p.visit = _p._visitForWebGL, _p.addChild = _p._addChildForWebGL, _p.removeAllChildren = _p._removeAllChildrenForWebGL, _p.sortAllChildren = _p._sortAllChildrenForWebGL, _p.draw = _p._drawForWebGL) : (_p.ctor = _p._ctorForCanvas, _p.updateQuadFromSprite = _p._updateQuadFromSpriteForCanvas, _p.insertQuadFromSprite = _p._insertQuadFromSpriteForCanvas, _p.initWithTexture = _p._initWithTextureForCanvas, _p.appendChild = _p._appendChildForCanvas, _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForCanvas, _p.getTexture = _p._getTextureForCanvas, _p.setTexture = _p._setTextureForCanvas, _p.visit = _p._visitForCanvas, _p.removeAllChildren = _p._removeAllChildrenForCanvas, _p.addChild = _p._addChildForCanvas, _p.sortAllChildren = _p._sortAllChildrenForCanvas, _p.draw = cc.Node.prototype.draw);
- cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
- cc.defineGetterSetter(_p, "descendants", _p.getDescendants);
- cc.SpriteBatchNode.create = function(a, c) {
- return new cc.SpriteBatchNode(a, c)
- };
- cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create;
- cc.BakeSprite = cc.Sprite.extend({
- _cacheCanvas: null,
- _cacheContext: null,
- ctor: function() {
- cc.Sprite.prototype.ctor.call(this);
- var a = document.createElement("canvas");
- a.width = a.height = 10;
- this._cacheCanvas = a;
- this._cacheContext = a.getContext("2d");
- var c = new cc.Texture2D;
- c.initWithElement(a);
- c.handleLoadedTexture();
- this.setTexture(c)
- },
- getCacheContext: function() {
- return this._cacheContext
- },
- getCacheCanvas: function() {
- return this._cacheCanvas
- },
- resetCanvasSize: function(a, c) {
- void 0 === c && (c = a.height, a = a.width);
- var d = this._cacheCanvas;
- d.width = a;
- d.height = c;
- this.getTexture().handleLoadedTexture();
- this.setTextureRect(cc.rect(0, 0, a, c), !1)
- }
- });
- cc.AnimationFrame = cc.Class.extend({
- _spriteFrame: null,
- _delayPerUnit: 0,
- _userInfo: null,
- ctor: function(a, c, d) {
- this._spriteFrame = a || null;
- this._delayPerUnit = c || 0;
- this._userInfo = d || null
- },
- clone: function() {
- var a = new cc.AnimationFrame;
- a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
- return a
- },
- copyWithZone: function(a) {
- return cc.clone(this)
- },
- copy: function(a) {
- a = new cc.AnimationFrame;
- a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
- return a
- },
- initWithSpriteFrame: function(a, c, d) {
- this._spriteFrame = a;
- this._delayPerUnit = c;
- this._userInfo = d;
- return !0
- },
- getSpriteFrame: function() {
- return this._spriteFrame
- },
- setSpriteFrame: function(a) {
- this._spriteFrame = a
- },
- getDelayUnits: function() {
- return this._delayPerUnit
- },
- setDelayUnits: function(a) {
- this._delayPerUnit = a
- },
- getUserInfo: function() {
- return this._userInfo
- },
- setUserInfo: function(a) {
- this._userInfo = a
- }
- });
- cc.AnimationFrame.create = function(a, c, d) {
- return new cc.AnimationFrame(a, c, d)
- };
- cc.Animation = cc.Class.extend({
- _frames: null,
- _loops: 0,
- _restoreOriginalFrame: !1,
- _duration: 0,
- _delayPerUnit: 0,
- _totalDelayUnits: 0,
- ctor: function(a, c, d) {
- this._frames = [];
- if (void 0 === a) this.initWithSpriteFrames(null, 0);
- else {
- var e = a[0];
- e && (e instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, c, d) : e instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, c, d))
- }
- },
- getFrames: function() {
- return this._frames
- },
- setFrames: function(a) {
- this._frames = a
- },
- addSpriteFrame: function(a) {
- var c = new cc.AnimationFrame;
- c.initWithSpriteFrame(a, 1, null);
- this._frames.push(c);
- this._totalDelayUnits++
- },
- addSpriteFrameWithFile: function(a) {
- a = cc.textureCache.addImage(a);
- var c = cc.rect(0, 0, 0, 0);
- c.width = a.width;
- c.height = a.height;
- a = cc.SpriteFrame.create(a, c);
- this.addSpriteFrame(a)
- },
- addSpriteFrameWithTexture: function(a, c) {
- var d = cc.SpriteFrame.create(a, c);
- this.addSpriteFrame(d)
- },
- initWithAnimationFrames: function(a, c, d) {
- cc.arrayVerifyType(a, cc.AnimationFrame);
- this._delayPerUnit = c;
- this._loops = void 0 === d ? 1 : d;
- this._totalDelayUnits = 0;
- c = this._frames;
- for (d = c.length = 0; d < a.length; d++) {
- var e = a[d];
- c.push(e);
- this._totalDelayUnits += e.getDelayUnits()
- }
- return !0
- },
- clone: function() {
- var a = new cc.Animation;
- a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
- a.setRestoreOriginalFrame(this._restoreOriginalFrame);
- return a
- },
- copyWithZone: function(a) {
- a = new cc.Animation;
- a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
- a.setRestoreOriginalFrame(this._restoreOriginalFrame);
- return a
- },
- _copyFrames: function() {
- for (var a = [], c = 0; c < this._frames.length; c++) a.push(this._frames[c].clone());
- return a
- },
- copy: function(a) {
- return this.copyWithZone(null)
- },
- getLoops: function() {
- return this._loops
- },
- setLoops: function(a) {
- this._loops = a
- },
- setRestoreOriginalFrame: function(a) {
- this._restoreOriginalFrame = a
- },
- getRestoreOriginalFrame: function() {
- return this._restoreOriginalFrame
- },
- getDuration: function() {
- return this._totalDelayUnits * this._delayPerUnit
- },
- getDelayPerUnit: function() {
- return this._delayPerUnit
- },
- setDelayPerUnit: function(a) {
- this._delayPerUnit = a
- },
- getTotalDelayUnits: function() {
- return this._totalDelayUnits
- },
- initWithSpriteFrames: function(a, c, d) {
- cc.arrayVerifyType(a, cc.SpriteFrame);
- this._loops = void 0 === d ? 1 : d;
- this._delayPerUnit = c || 0;
- this._totalDelayUnits = 0;
- c = this._frames;
- c.length = 0;
- if (a) {
- for (d = 0; d < a.length; d++) {
- var e = a[d],
- f = new cc.AnimationFrame;
- f.initWithSpriteFrame(e, 1, null);
- c.push(f)
- }
- this._totalDelayUnits += a.length
- }
- return !0
- },
- retain: function() {},
- release: function() {}
- });
- cc.Animation.create = function(a, c, d) {
- return new cc.Animation(a, c, d)
- };
- cc.Animation.createWithAnimationFrames = cc.Animation.create;
- cc.animationCache = {
- _animations: {},
- addAnimation: function(a, c) {
- this._animations[c] = a
- },
- removeAnimation: function(a) {
- a && this._animations[a] && delete this._animations[a]
- },
- getAnimation: function(a) {
- return this._animations[a] ? this._animations[a] : null
- },
- _addAnimationsWithDictionary: function(a, c) {
- var d = a.animations;
- if (d) {
- var e = 1,
- f = a.properties;
- if (f)
- for (var e = null != f.format ? parseInt(f.format) : e, f = f.spritesheets, g = cc.spriteFrameCache, h = cc.path, k = 0; k < f.length; k++) g.addSpriteFrames(h.changeBasename(c, f[k]));
- switch (e) {
- case 1:
- this._parseVersion1(d);
- break;
- case 2:
- this._parseVersion2(d);
- break;
- default:
- cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)
- }
- } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)
- },
- addAnimations: function(a) {
- cc.assert(a, cc._LogInfos.animationCache_addAnimations_2);
- var c = cc.loader.getRes(a);
- c ? this._addAnimationsWithDictionary(c, a) : cc.log(cc._LogInfos.animationCache_addAnimations)
- },
- _parseVersion1: function(a) {
- var c = cc.spriteFrameCache,
- d;
- for (d in a) {
- var e = a[d],
- f = e.frames,
- e = parseFloat(e.delay) || 0,
- g = null;
- if (f) {
- for (var g = [], h = 0; h < f.length; h++) {
- var k = c.getSpriteFrame(f[h]);
- if (k) {
- var m = new cc.AnimationFrame;
- m.initWithSpriteFrame(k, 1, null);
- g.push(m)
- } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, d, f[h])
- }
- 0 === g.length ? cc.log(cc._LogInfos.animationCache__parseVersion1_3, d) : (g.length != f.length && cc.log(cc._LogInfos.animationCache__parseVersion1_4, d), g = cc.Animation.create(g, e, 1), cc.animationCache.addAnimation(g, d))
- } else cc.log(cc._LogInfos.animationCache__parseVersion1, d)
- }
- },
- _parseVersion2: function(a) {
- var c = cc.spriteFrameCache,
- d;
- for (d in a) {
- var e = a[d],
- f = e.loop,
- g = parseInt(e.loops),
- f = f ? cc.REPEAT_FOREVER : isNaN(g) ? 1 : g,
- g = e.restoreOriginalFrame && !0 == e.restoreOriginalFrame ? !0 : !1,
- h = e.frames;
- if (h) {
- for (var k = [], m = 0; m < h.length; m++) {
- var n = h[m],
- q = n.spriteframe,
- r = c.getSpriteFrame(q);
- if (r) {
- var q = parseFloat(n.delayUnits) || 0,
- n = n.notification,
- t = new cc.AnimationFrame;
- t.initWithSpriteFrame(r, q, n);
- k.push(t)
- } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, d, q)
- }
- e = parseFloat(e.delayPerUnit) || 0;
- h = new cc.Animation;
- h.initWithAnimationFrames(k, e, f);
- h.setRestoreOriginalFrame(g);
- cc.animationCache.addAnimation(h, d)
- } else cc.log(cc._LogInfos.animationCache__parseVersion2, d)
- }
- },
- _clear: function() {
- this._animations = {}
- }
- };
- cc.SpriteFrame = cc.Class.extend({
- _offset: null,
- _originalSize: null,
- _rectInPixels: null,
- _rotated: !1,
- _rect: null,
- _offsetInPixels: null,
- _originalSizeInPixels: null,
- _texture: null,
- _textureFilename: "",
- _textureLoaded: !1,
- _eventListeners: null,
- ctor: function(a, c, d, e, f) {
- this._offset = cc.p(0, 0);
- this._offsetInPixels = cc.p(0, 0);
- this._originalSize = cc.size(0, 0);
- this._rotated = !1;
- this._originalSizeInPixels = cc.size(0, 0);
- this._textureFilename = "";
- this._texture = null;
- this._textureLoaded = !1;
- void 0 !== a && void 0 !== c && (void 0 === d || void 0 === e || void 0 === f ? this.initWithTexture(a, c) : this.initWithTexture(a, c, d, e, f))
- },
- textureLoaded: function() {
- return this._textureLoaded
- },
- addLoadedEventListener: function(a, c) {
- null == this._eventListeners && (this._eventListeners = []);
- this._eventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- _callLoadedEventCallbacks: function() {
- var a = this._eventListeners;
- if (a) {
- for (var c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- },
- getRectInPixels: function() {
- var a = this._rectInPixels;
- return cc.rect(a.x, a.y, a.width, a.height)
- },
- setRectInPixels: function(a) {
- this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0));
- this._rectInPixels.x = a.x;
- this._rectInPixels.y = a.y;
- this._rectInPixels.width = a.width;
- this._rectInPixels.height = a.height;
- this._rect = cc.rectPixelsToPoints(a)
- },
- isRotated: function() {
- return this._rotated
- },
- setRotated: function(a) {
- this._rotated = a
- },
- getRect: function() {
- var a = this._rect;
- return cc.rect(a.x, a.y, a.width, a.height)
- },
- setRect: function(a) {
- this._rect || (this._rect = cc.rect(0, 0, 0, 0));
- this._rect.x = a.x;
- this._rect.y = a.y;
- this._rect.width = a.width;
- this._rect.height = a.height;
- this._rectInPixels = cc.rectPointsToPixels(this._rect)
- },
- getOffsetInPixels: function() {
- return cc.p(this._offsetInPixels)
- },
- setOffsetInPixels: function(a) {
- this._offsetInPixels.x = a.x;
- this._offsetInPixels.y = a.y;
- cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset)
- },
- getOriginalSizeInPixels: function() {
- return cc.size(this._originalSizeInPixels)
- },
- setOriginalSizeInPixels: function(a) {
- this._originalSizeInPixels.width = a.width;
- this._originalSizeInPixels.height = a.height
- },
- getOriginalSize: function() {
- return cc.size(this._originalSize)
- },
- setOriginalSize: function(a) {
- this._originalSize.width = a.width;
- this._originalSize.height = a.height
- },
- getTexture: function() {
- if (this._texture) return this._texture;
- if ("" !== this._textureFilename) {
- var a = cc.textureCache.addImage(this._textureFilename);
- a && (this._textureLoaded = a.isLoaded());
- return a
- }
- return null
- },
- setTexture: function(a) {
- if (this._texture != a) {
- var c = a.isLoaded();
- this._textureLoaded = c;
- this._texture = a;
- c || a.addLoadedEventListener(function(a) {
- this._textureLoaded = !0;
- if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) {
- var c = a.getHtmlElementObj(),
- c = cc.cutRotateImageToCanvas(c, this.getRect()),
- f = new cc.Texture2D;
- f.initWithElement(c);
- f.handleLoadedTexture();
- this.setTexture(f);
- c = this.getRect();
- this.setRect(cc.rect(0, 0, c.width, c.height))
- }
- c = this._rect;
- 0 === c.width && 0 === c.height && (c = a.width, a = a.height, this._rect.width = c, this._rect.height = a, this._rectInPixels = cc.rectPointsToPixels(this._rect), this._originalSizeInPixels.width = this._rectInPixels.width, this._originalSizeInPixels.height = this._rectInPixels.height, this._originalSize.width = c, this._originalSize.height = a);
- this._callLoadedEventCallbacks()
- }, this)
- }
- },
- getOffset: function() {
- return cc.p(this._offset)
- },
- setOffset: function(a) {
- this._offset.x = a.x;
- this._offset.y = a.y
- },
- clone: function() {
- var a = new cc.SpriteFrame;
- a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
- a.setTexture(this._texture);
- return a
- },
- copyWithZone: function() {
- var a = new cc.SpriteFrame;
- a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
- a.setTexture(this._texture);
- return a
- },
- copy: function() {
- return this.copyWithZone()
- },
- initWithTexture: function(a, c, d, e, f) {
- 2 === arguments.length && (c = cc.rectPointsToPixels(c));
- e = e || cc.p(0, 0);
- f = f || c;
- d = d || !1;
- "string" == typeof a ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a);
- if ((a = this.getTexture()) && a.url) {
- var g, h;
- d ? (g = c.x + c.height, h = c.y + c.width) : (g = c.x + c.width, h = c.y + c.height);
- g > a.width && cc.error(cc._LogInfos.RectWidth, a.url);
- h > a.height && cc.error(cc._LogInfos.RectHeight, a.url)
- }
- this._rectInPixels = c;
- this._rect = cc.rectPixelsToPoints(c);
- this._offsetInPixels.x = e.x;
- this._offsetInPixels.y = e.y;
- cc._pointPixelsToPointsOut(e, this._offset);
- this._originalSizeInPixels.width = f.width;
- this._originalSizeInPixels.height = f.height;
- cc._sizePixelsToPointsOut(f, this._originalSize);
- this._rotated = d;
- return !0
- }
- });
- cc.SpriteFrame.create = function(a, c, d, e, f) {
- return new cc.SpriteFrame(a, c, d, e, f)
- };
- cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create;
- cc.SpriteFrame._frameWithTextureForCanvas = function(a, c, d, e, f) {
- var g = new cc.SpriteFrame;
- g._texture = a;
- g._rectInPixels = c;
- g._rect = cc.rectPixelsToPoints(c);
- g._offsetInPixels.x = e.x;
- g._offsetInPixels.y = e.y;
- cc._pointPixelsToPointsOut(g._offsetInPixels, g._offset);
- g._originalSizeInPixels.width = f.width;
- g._originalSizeInPixels.height = f.height;
- cc._sizePixelsToPointsOut(g._originalSizeInPixels, g._originalSize);
- g._rotated = d;
- return g
- };
- cc.spriteFrameCache = {
- _CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,
- _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,
- _spriteFrames: {},
- _spriteFramesAliases: {},
- _frameConfigCache: {},
- _rectFromString: function(a) {
- a = this._CCNS_REG2.exec(a);
- return !a ? cc.rect(0, 0, 0, 0) : cc.rect(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]), parseFloat(a[4]))
- },
- _pointFromString: function(a) {
- a = this._CCNS_REG1.exec(a);
- return !a ? cc.p(0, 0) : cc.p(parseFloat(a[1]), parseFloat(a[2]))
- },
- _sizeFromString: function(a) {
- a = this._CCNS_REG1.exec(a);
- return !a ? cc.size(0, 0) : cc.size(parseFloat(a[1]), parseFloat(a[2]))
- },
- _getFrameConfig: function(a) {
- var c = cc.loader.getRes(a);
- cc.assert(c, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a);
- cc.loader.release(a);
- if (c._inited) return this._frameConfigCache[a] = c;
- var d = c.frames,
- e = c.metadata || c.meta,
- c = {},
- f = {},
- g = 0;
- e && (g = e.format, g = 1 >= g.length ? parseInt(g) : g, f.image = e.textureFileName || e.textureFileName || e.image);
- for (var h in d) {
- var k = d[h];
- if (k) {
- e = {};
- if (0 == g) {
- e.rect = cc.rect(k.x, k.y, k.width, k.height);
- e.rotated = !1;
- e.offset = cc.p(k.offsetX, k.offsetY);
- var m = k.originalWidth,
- k = k.originalHeight;
- (!m || !k) && cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);
- m = Math.abs(m);
- k = Math.abs(k);
- e.size = cc.size(m, k)
- } else if (1 == g || 2 == g) e.rect = this._rectFromString(k.frame), e.rotated = k.rotated || !1, e.offset = this._pointFromString(k.offset), e.size = this._sizeFromString(k.sourceSize);
- else if (3 == g) {
- var m = this._sizeFromString(k.spriteSize),
- n = this._rectFromString(k.textureRect);
- m && (n = cc.rect(n.x, n.y, m.width, m.height));
- e.rect = n;
- e.rotated = k.textureRotated || !1;
- e.offset = this._pointFromString(k.spriteOffset);
- e.size = this._sizeFromString(k.spriteSourceSize);
- e.aliases = k.aliases
- } else m = k.frame, n = k.sourceSize, h = k.filename || h, e.rect = cc.rect(m.x, m.y, m.w, m.h), e.rotated = k.rotated || !1, e.offset = cc.p(0, 0), e.size = cc.size(n.w, n.h);
- c[h] = e
- }
- }
- return this._frameConfigCache[a] = {
- _inited: !0,
- frames: c,
- meta: f
- }
- },
- addSpriteFrames: function(a, c) {
- cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
- var d = this._frameConfigCache[a] || cc.loader.getRes(a);
- if (d && d.frames) {
- var e = this._frameConfigCache[a] || this._getFrameConfig(a),
- d = e.frames,
- e = e.meta;
- c ? c instanceof cc.Texture2D || ("string" == typeof c ? c = cc.textureCache.addImage(c) : cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3)) : (e = cc.path.changeBasename(a, e.image || ".png"), c = cc.textureCache.addImage(e));
- var e = this._spriteFramesAliases,
- f = this._spriteFrames,
- g;
- for (g in d) {
- var h = d[g],
- k = f[g];
- if (!k) {
- k = cc.SpriteFrame.create(c, h.rect, h.rotated, h.offset, h.size);
- if (h = h.aliases)
- for (var m = 0, n = h.length; m < n; m++) {
- var q = h[m];
- e[q] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, q);
- e[q] = g
- }
- cc._renderType === cc._RENDER_TYPE_CANVAS && k.isRotated() && k.getTexture().isLoaded() && (h = k.getTexture().getHtmlElementObj(), h = cc.cutRotateImageToCanvas(h, k.getRectInPixels()), m = new cc.Texture2D, m.initWithElement(h), m.handleLoadedTexture(), k.setTexture(m), h = k._rect, k.setRect(cc.rect(0, 0, h.width, h.height)));
- f[g] = k
- }
- }
- }
- },
- _checkConflict: function(a) {
- a = a.frames;
- for (var c in a) this._spriteFrames[c] && cc.log(cc._LogInfos.spriteFrameCache__checkConflict, c)
- },
- addSpriteFrame: function(a, c) {
- this._spriteFrames[c] = a
- },
- removeSpriteFrames: function() {
- this._spriteFrames = {};
- this._spriteFramesAliases = {}
- },
- removeSpriteFrameByName: function(a) {
- a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a])
- },
- removeSpriteFramesFromFile: function(a) {
- var c = this._spriteFrames,
- d = this._spriteFramesAliases;
- if (a = this._frameConfigCache[a]) {
- a = a.frames;
- for (var e in a)
- if (c[e]) {
- delete c[e];
- for (var f in d) d[f] == e && delete d[f]
- }
- }
- },
- removeSpriteFramesFromTexture: function(a) {
- var c = this._spriteFrames,
- d = this._spriteFramesAliases,
- e;
- for (e in c) {
- var f = c[e];
- if (f && f.getTexture() == a) {
- delete c[e];
- for (var g in d) d[g] == e && delete d[g]
- }
- }
- },
- getSpriteFrame: function(a) {
- var c = this._spriteFrames[a];
- if (!c) {
- var d = this._spriteFramesAliases[a];
- d && ((c = this._spriteFrames[d.toString()]) || delete this._spriteFramesAliases[a])
- }
- c || cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame, a);
- return c
- },
- _clear: function() {
- this._spriteFrames = {};
- this._spriteFramesAliases = {};
- this._frameConfigCache = {}
- }
- };
- cc.configuration = {
- ERROR: 0,
- STRING: 1,
- INT: 2,
- DOUBLE: 3,
- BOOLEAN: 4,
- _maxTextureSize: 0,
- _maxModelviewStackDepth: 0,
- _supportsPVRTC: !1,
- _supportsNPOT: !1,
- _supportsBGRA8888: !1,
- _supportsDiscardFramebuffer: !1,
- _supportsShareableVAO: !1,
- _maxSamplesAllowed: 0,
- _maxTextureUnits: 0,
- _GlExtensions: "",
- _valueDict: {},
- _inited: !1,
- _init: function() {
- var a = this._valueDict;
- a["cocos2d.x.version"] = cc.ENGINE_VERSION;
- a["cocos2d.x.compiled_with_profiler"] = !1;
- a["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
- this._inited = !0
- },
- getMaxTextureSize: function() {
- return this._maxTextureSize
- },
- getMaxModelviewStackDepth: function() {
- return this._maxModelviewStackDepth
- },
- getMaxTextureUnits: function() {
- return this._maxTextureUnits
- },
- supportsNPOT: function() {
- return this._supportsNPOT
- },
- supportsPVRTC: function() {
- return this._supportsPVRTC
- },
- supportsETC: function() {
- return !1
- },
- supportsS3TC: function() {
- return !1
- },
- supportsATITC: function() {
- return !1
- },
- supportsBGRA8888: function() {
- return this._supportsBGRA8888
- },
- supportsDiscardFramebuffer: function() {
- return this._supportsDiscardFramebuffer
- },
- supportsShareableVAO: function() {
- return this._supportsShareableVAO
- },
- checkForGLExtension: function(a) {
- return -1 < this._GlExtensions.indexOf(a)
- },
- getValue: function(a, c) {
- this._inited || this._init();
- var d = this._valueDict;
- return d[a] ? d[a] : c
- },
- setValue: function(a, c) {
- this._valueDict[a] = c
- },
- dumpInfo: function() {
- 0 === cc.ENABLE_GL_STATE_CACHE && (cc.log(""), cc.log(cc._LogInfos.configuration_dumpInfo), cc.log(""))
- },
- gatherGPUInfo: function() {
- if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
- this._inited || this._init();
- var a = cc._renderContext,
- c = this._valueDict;
- c["gl.vendor"] = a.getParameter(a.VENDOR);
- c["gl.renderer"] = a.getParameter(a.RENDERER);
- c["gl.version"] = a.getParameter(a.VERSION);
- this._GlExtensions = "";
- for (var d = a.getSupportedExtensions(), e = 0; e < d.length; e++) this._GlExtensions += d[e] + " ";
- this._maxTextureSize = a.getParameter(a.MAX_TEXTURE_SIZE);
- c["gl.max_texture_size"] = this._maxTextureSize;
- this._maxTextureUnits = a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- c["gl.max_texture_units"] = this._maxTextureUnits;
- this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
- c["gl.supports_PVRTC"] = this._supportsPVRTC;
- this._supportsNPOT = !1;
- c["gl.supports_NPOT"] = this._supportsNPOT;
- this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888");
- c["gl.supports_BGRA8888"] = this._supportsBGRA8888;
- this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer");
- c["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer;
- this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object");
- c["gl.supports_vertex_array_object"] = this._supportsShareableVAO;
- cc.checkGLErrorDebug()
- }
- },
- loadConfigFile: function(a) {
- this._inited || this._init();
- var c = cc.loader.getRes(a);
- if (!c) throw "Please load the resource first : " + a;
- cc.assert(c, cc._LogInfos.configuration_loadConfigFile_2, a);
- if (c = c.data)
- for (var d in c) this._valueDict[d] = c[d];
- else cc.log(cc._LogInfos.configuration_loadConfigFile, a)
- }
- };
- cc._tmp.DirectorWebGL = function() {
- cc.DirectorDelegate = cc.Class.extend({
- updateProjection: function() {}
- });
- var a = cc.Director.prototype;
- a.setProjection = function(a) {
- var d = this._winSizeInPoints;
- this.setViewport();
- var e = this._openGLView,
- f = e._viewPortRect.x / e._scaleX,
- g = e._viewPortRect.y / e._scaleY;
- switch (a) {
- case cc.Director.PROJECTION_2D:
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLLoadIdentity();
- e = new cc.kmMat4;
- cc.kmMat4OrthographicProjection(e, 0, d.width, 0, d.height, -1024, 1024);
- cc.kmGLMultMatrix(e);
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLLoadIdentity();
- break;
- case cc.Director.PROJECTION_3D:
- var h = this.getZEye(),
- k = new cc.kmMat4,
- e = new cc.kmMat4;
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLLoadIdentity();
- cc.kmMat4PerspectiveProjection(k, 60, d.width / d.height, 0.1, 2 * h);
- cc.kmGLMultMatrix(k);
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLLoadIdentity();
- h = cc.kmVec3Fill(null, -f + d.width / 2, -g + d.height / 2, h);
- d = cc.kmVec3Fill(null, -f + d.width / 2, -g + d.height / 2, 0);
- f = cc.kmVec3Fill(null, 0, 1, 0);
- cc.kmMat4LookAt(e, h, d, f);
- cc.kmGLMultMatrix(e);
- break;
- case cc.Director.PROJECTION_CUSTOM:
- this._projectionDelegate && this._projectionDelegate.updateProjection();
- break;
- default:
- cc.log(cc._LogInfos.Director_setProjection)
- }
- this._projection = a;
- cc.eventManager.dispatchEvent(this._eventProjectionChanged);
- cc.setProjectionMatrixDirty()
- };
- a.setDepthTest = function(a) {
- var d = cc._renderContext;
- a ? (d.clearDepth(1), d.enable(d.DEPTH_TEST), d.depthFunc(d.LEQUAL)) : d.disable(d.DEPTH_TEST)
- };
- a.setOpenGLView = function(a) {
- this._winSizeInPoints.width = cc._canvas.width;
- this._winSizeInPoints.height = cc._canvas.height;
- this._openGLView = a || cc.view;
- a = cc.configuration;
- a.gatherGPUInfo();
- a.dumpInfo();
- this._createStatsLabel();
- this.setGLDefaultValues();
- cc.eventManager && cc.eventManager.setEnabled(!0)
- };
- a._clear = function() {
- var a = cc._renderContext;
- a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
- };
- a._beforeVisitScene = function() {
- cc.kmGLPushMatrix()
- };
- a._afterVisitScene = function() {
- cc.kmGLPopMatrix()
- };
- a._createStatsLabel = function() {
- if (cc.LabelAtlas) {
- if (!(null == cc.Director._fpsImageLoaded || !1 == cc.Director._fpsImageLoaded)) {
- var a = new cc.Texture2D;
- a.initWithElement(cc.Director._fpsImage);
- a.handleLoadedTexture();
- var d = cc.view.getDesignResolutionSize().height / 320;
- 0 === d && (d = this._winSizeInPoints.height / 320);
- var e = new cc.LabelAtlas;
- e._setIgnoreContentScaleFactor(!0);
- e.initWithString("00.0", a, 12, 32, ".");
- e.scale = d;
- this._FPSLabel = e;
- e = new cc.LabelAtlas;
- e._setIgnoreContentScaleFactor(!0);
- e.initWithString("0.000", a, 12, 32, ".");
- e.scale = d;
- this._SPFLabel = e;
- e = new cc.LabelAtlas;
- e._setIgnoreContentScaleFactor(!0);
- e.initWithString("000", a, 12, 32, ".");
- e.scale = d;
- this._drawsLabel = e;
- a = cc.DIRECTOR_STATS_POSITION;
- this._drawsLabel.setPosition(a.x, 34 * d + a.y);
- this._SPFLabel.setPosition(a.x, 17 * d + a.y);
- this._FPSLabel.setPosition(a)
- }
- } else this._createStatsLabelForCanvas()
- };
- a._createStatsLabelForCanvas = function() {
- var a = 0,
- a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | 24 * (this._winSizeInPoints.height / 320) : 0 | 24 * (this._winSizeInPoints.width / 320);
- this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
- this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
- this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
- a = cc.DIRECTOR_STATS_POSITION;
- this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
- this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
- this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
- };
- a.convertToGL = function(a) {
- var d = new cc.kmMat4;
- cc.GLToClipTransform(d);
- var e = new cc.kmMat4;
- cc.kmMat4Inverse(e, d);
- var d = d.mat[14] / d.mat[15],
- f = this._openGLView.getDesignResolutionSize();
- a = new cc.kmVec3(2 * a.x / f.width - 1, 1 - 2 * a.y / f.height, d);
- d = new cc.kmVec3;
- cc.kmVec3TransformCoord(d, a, e);
- return cc.p(d.x, d.y)
- };
- a.convertToUI = function(a) {
- var d = new cc.kmMat4;
- cc.GLToClipTransform(d);
- var e = new cc.kmVec3;
- a = new cc.kmVec3(a.x, a.y, 0);
- cc.kmVec3TransformCoord(e, a, d);
- d = this._openGLView.getDesignResolutionSize();
- return cc.p(d.width * (0.5 * e.x + 0.5), d.height * (0.5 * -e.y + 0.5))
- };
- a.getVisibleSize = function() {
- return this._openGLView.getVisibleSize()
- };
- a.getVisibleOrigin = function() {
- return this._openGLView.getVisibleOrigin()
- };
- a.getZEye = function() {
- return this._winSizeInPoints.height / 1.1566
- };
- a.setViewport = function() {
- var a = this._openGLView;
- if (a) {
- var d = this._winSizeInPoints;
- a.setViewPortInPoints(-a._viewPortRect.x / a._scaleX, -a._viewPortRect.y / a._scaleY, d.width, d.height)
- }
- };
- a.getOpenGLView = function() {
- return this._openGLView
- };
- a.getProjection = function() {
- return this._projection
- };
- a.setAlphaBlending = function(a) {
- a ? cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST) : cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO)
- };
- a.setGLDefaultValues = function() {
- this.setAlphaBlending(!0);
- this.setDepthTest(!1);
- this.setProjection(this._projection);
- cc._renderContext.clearColor(0, 0, 0, 1)
- }
- };
- cc.g_NumberOfDraws = 0;
- cc.GLToClipTransform = function(a) {
- var c = new cc.kmMat4;
- cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, c);
- var d = new cc.kmMat4;
- cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, d);
- cc.kmMat4Multiply(a, c, d)
- };
- cc.Director = cc.Class.extend({
- _landscape: !1,
- _nextDeltaTimeZero: !1,
- _paused: !1,
- _purgeDirectorInNextLoop: !1,
- _sendCleanupToScene: !1,
- _animationInterval: 0,
- _oldAnimationInterval: 0,
- _projection: 0,
- _accumDt: 0,
- _contentScaleFactor: 1,
- _displayStats: !1,
- _deltaTime: 0,
- _frameRate: 0,
- _FPSLabel: null,
- _SPFLabel: null,
- _drawsLabel: null,
- _winSizeInPoints: null,
- _lastUpdate: null,
- _nextScene: null,
- _notificationNode: null,
- _openGLView: null,
- _scenesStack: null,
- _projectionDelegate: null,
- _runningScene: null,
- _frames: 0,
- _totalFrames: 0,
- _secondsPerFrame: 0,
- _dirtyRegion: null,
- _scheduler: null,
- _actionManager: null,
- _eventProjectionChanged: null,
- _eventAfterDraw: null,
- _eventAfterVisit: null,
- _eventAfterUpdate: null,
- ctor: function() {
- var a = this;
- a._lastUpdate = Date.now();
- cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
- a._lastUpdate = Date.now()
- })
- },
- init: function() {
- this._oldAnimationInterval = this._animationInterval = 1 / cc.defaultFPS;
- this._scenesStack = [];
- this._projection = cc.Director.PROJECTION_DEFAULT;
- this._projectionDelegate = null;
- this._frameRate = this._accumDt = 0;
- this._displayStats = !1;
- this._totalFrames = this._frames = 0;
- this._lastUpdate = Date.now();
- this._purgeDirectorInNextLoop = this._paused = !1;
- this._winSizeInPoints = cc.size(0, 0);
- this._openGLView = null;
- this._contentScaleFactor = 1;
- this._scheduler = new cc.Scheduler;
- this._actionManager = cc.ActionManager ? new cc.ActionManager : null;
- this._scheduler.scheduleUpdateForTarget(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
- this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
- this._eventAfterDraw.setUserData(this);
- this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);
- this._eventAfterVisit.setUserData(this);
- this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);
- this._eventAfterUpdate.setUserData(this);
- this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);
- this._eventProjectionChanged.setUserData(this);
- return !0
- },
- calculateDeltaTime: function() {
- var a = Date.now();
- this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime = (a - this._lastUpdate) / 1E3;
- 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60);
- this._lastUpdate = a
- },
- drawScene: function() {
- this.calculateDeltaTime();
- this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate));
- this._clear();
- this._nextScene && this.setNextScene();
- this._beforeVisitScene && this._beforeVisitScene();
- this._runningScene && (this._runningScene.visit(), cc.eventManager.dispatchEvent(this._eventAfterVisit));
- this._notificationNode && this._notificationNode.visit();
- this._displayStats && this._showStats();
- this._afterVisitScene && this._afterVisitScene();
- cc.eventManager.dispatchEvent(this._eventAfterDraw);
- this._totalFrames++;
- this._displayStats && this._calculateMPF()
- },
- _beforeVisitScene: null,
- _afterVisitScene: null,
- end: function() {
- this._purgeDirectorInNextLoop = !0
- },
- getContentScaleFactor: function() {
- return this._contentScaleFactor
- },
- getNotificationNode: function() {
- return this._notificationNode
- },
- getWinSize: function() {
- return cc.size(this._winSizeInPoints)
- },
- getWinSizeInPixels: function() {
- return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor)
- },
- pause: function() {
- this._paused || (this._oldAnimationInterval = this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0)
- },
- popScene: function() {
- cc.assert(this._runningScene, cc._LogInfos.Director_popScene);
- this._scenesStack.pop();
- var a = this._scenesStack.length;
- 0 == a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a - 1])
- },
- purgeCachedData: function() {
- cc.animationCache._clear();
- cc.spriteFrameCache._clear();
- cc.textureCache._clear()
- },
- purgeDirector: function() {
- this.getScheduler().unscheduleAllCallbacks();
- cc.eventManager && cc.eventManager.setEnabled(!1);
- this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup());
- this._nextScene = this._runningScene = null;
- this._scenesStack.length = 0;
- this.stopAnimation();
- this.purgeCachedData();
- cc.checkGLErrorDebug()
- },
- pushScene: function(a) {
- cc.assert(a, cc._LogInfos.Director_pushScene);
- this._sendCleanupToScene = !1;
- this._scenesStack.push(a);
- this._nextScene = a
- },
- runScene: function(a) {
- cc.assert(a, cc._LogInfos.Director_pushScene);
- if (this._runningScene) {
- var c = this._scenesStack.length;
- 0 === c ? (this._sendCleanupToScene = !0, this._scenesStack[c] = a) : (this._sendCleanupToScene = !0, this._scenesStack[c - 1] = a);
- this._nextScene = a
- } else this.pushScene(a), this.startAnimation()
- },
- resume: function() {
- this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate = Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0)
- },
- setContentScaleFactor: function(a) {
- a != this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel())
- },
- setDefaultValues: function() {},
- setNextDeltaTimeZero: function(a) {
- this._nextDeltaTimeZero = a
- },
- setNextScene: function() {
- var a = !1,
- c = !1;
- cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, c = this._nextScene ? this._nextScene instanceof cc.TransitionScene : !1);
- if (!c) {
- if (c = this._runningScene) c.onExitTransitionDidStart(), c.onExit();
- this._sendCleanupToScene && c && c.cleanup()
- }
- this._runningScene = this._nextScene;
- this._nextScene = null;
- !a && null != this._runningScene && (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish())
- },
- setNotificationNode: function(a) {
- this._notificationNode = a
- },
- getDelegate: function() {
- return this._projectionDelegate
- },
- setDelegate: function(a) {
- this._projectionDelegate = a
- },
- _showStats: function() {
- this._frames++;
- this._accumDt += this._deltaTime;
- this._FPSLabel && this._SPFLabel && this._drawsLabel ? (this._accumDt > cc.DIRECTOR_FPS_INTERVAL && (this._SPFLabel.string = this._secondsPerFrame.toFixed(3), this._frameRate = this._frames / this._accumDt, this._accumDt = this._frames = 0, this._FPSLabel.string = this._frameRate.toFixed(1), this._drawsLabel.string = (0 | cc.g_NumberOfDraws).toString()), this._FPSLabel.visit(), this._SPFLabel.visit(), this._drawsLabel.visit()) : this._createStatsLabel();
- cc.g_NumberOfDraws = 0
- },
- isSendCleanupToScene: function() {
- return this._sendCleanupToScene
- },
- getRunningScene: function() {
- return this._runningScene
- },
- getAnimationInterval: function() {
- return this._animationInterval
- },
- isDisplayStats: function() {
- return this._displayStats
- },
- setDisplayStats: function(a) {
- this._displayStats = a
- },
- getSecondsPerFrame: function() {
- return this._secondsPerFrame
- },
- isNextDeltaTimeZero: function() {
- return this._nextDeltaTimeZero
- },
- isPaused: function() {
- return this._paused
- },
- getTotalFrames: function() {
- return this._totalFrames
- },
- popToRootScene: function() {
- this.popToSceneStackLevel(1)
- },
- popToSceneStackLevel: function(a) {
- cc.assert(this._runningScene, cc._LogInfos.Director_popToSceneStackLevel_2);
- var c = this._scenesStack,
- d = c.length;
- if (0 == d) this.end();
- else if (!(a > d)) {
- for (; d > a;) {
- var e = c.pop();
- e.running && (e.onExitTransitionDidStart(), e.onExit());
- e.cleanup();
- d--
- }
- this._nextScene = c[c.length - 1];
- this._sendCleanupToScene = !1
- }
- },
- getScheduler: function() {
- return this._scheduler
- },
- setScheduler: function(a) {
- this._scheduler != a && (this._scheduler = a)
- },
- getActionManager: function() {
- return this._actionManager
- },
- setActionManager: function(a) {
- this._actionManager != a && (this._actionManager = a)
- },
- getDeltaTime: function() {
- return this._deltaTime
- },
- _createStatsLabel: null,
- _calculateMPF: function() {
- this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3
- }
- });
- cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
- cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
- cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
- cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
- cc.DisplayLinkDirector = cc.Director.extend({
- invalid: !1,
- startAnimation: function() {
- this._nextDeltaTimeZero = !0;
- this.invalid = !1
- },
- mainLoop: function() {
- this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene()
- },
- stopAnimation: function() {
- this.invalid = !0
- },
- setAnimationInterval: function(a) {
- this._animationInterval = a;
- this.invalid || (this.stopAnimation(), this.startAnimation())
- }
- });
- cc.Director.sharedDirector = null;
- cc.Director.firstUseDirector = !0;
- cc.Director._getInstance = function() {
- cc.Director.firstUseDirector && (cc.Director.firstUseDirector = !1, cc.Director.sharedDirector = new cc.DisplayLinkDirector, cc.Director.sharedDirector.init());
- return cc.Director.sharedDirector
- };
- cc.defaultFPS = 60;
- cc.Director.PROJECTION_2D = 0;
- cc.Director.PROJECTION_3D = 1;
- cc.Director.PROJECTION_CUSTOM = 3;
- cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Director.prototype, _p.setProjection = function(a) {
- this._projection = a;
- cc.eventManager.dispatchEvent(this._eventProjectionChanged)
- }, _p.setDepthTest = function() {}, _p.setOpenGLView = function(a) {
- this._winSizeInPoints.width = cc._canvas.width;
- this._winSizeInPoints.height = cc._canvas.height;
- this._openGLView = a || cc.view;
- cc.eventManager && cc.eventManager.setEnabled(!0)
- }, _p._clear = function() {
- var a = this._openGLView.getViewPortRect();
- cc._renderContext.clearRect(-a.x, a.y, a.width, -a.height)
- }, _p._createStatsLabel = function() {
- var a = 0,
- a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | 24 * (this._winSizeInPoints.height / 320) : 0 | 24 * (this._winSizeInPoints.width / 320);
- this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
- this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
- this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
- a = cc.DIRECTOR_STATS_POSITION;
- this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
- this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
- this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
- }, _p.getVisibleSize = function() {
- return this.getWinSize()
- }, _p.getVisibleOrigin = function() {
- return cc.p(0, 0)
- }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load", function() {
- cc.Director._fpsImageLoaded = !0
- }), cc._fpsImage && (cc.Director._fpsImage.src = cc._fpsImage), cc.assert("function" === typeof cc._tmp.DirectorWebGL, cc._LogInfos.MissingFile, "CCDirectorWebGL.js"), cc._tmp.DirectorWebGL(), delete cc._tmp.DirectorWebGL);
- cc.Camera = cc.Class.extend({
- _eyeX: null,
- _eyeY: null,
- _eyeZ: null,
- _centerX: null,
- _centerY: null,
- _centerZ: null,
- _upX: null,
- _upY: null,
- _upZ: null,
- _dirty: null,
- _lookupMatrix: null,
- ctor: function() {
- this._lookupMatrix = new cc.kmMat4;
- this.restore()
- },
- description: function() {
- return "\x3cCCCamera | center \x3d(" + this._centerX + "," + this._centerY + "," + this._centerZ + ")\x3e"
- },
- setDirty: function(a) {
- this._dirty = a
- },
- isDirty: function() {
- return this._dirty
- },
- restore: function() {
- this._eyeX = this._eyeY = 0;
- this._eyeZ = cc.Camera.getZEye();
- this._upX = this._centerX = this._centerY = this._centerZ = 0;
- this._upY = 1;
- this._upZ = 0;
- cc.kmMat4Identity(this._lookupMatrix);
- this._dirty = !1
- },
- locate: function() {
- if (this._dirty) {
- var a = new cc.kmVec3,
- c = new cc.kmVec3,
- d = new cc.kmVec3;
- cc.kmVec3Fill(a, this._eyeX, this._eyeY, this._eyeZ);
- cc.kmVec3Fill(c, this._centerX, this._centerY, this._centerZ);
- cc.kmVec3Fill(d, this._upX, this._upY, this._upZ);
- cc.kmMat4LookAt(this._lookupMatrix, a, c, d);
- this._dirty = !1
- }
- cc.kmGLMultMatrix(this._lookupMatrix)
- },
- setEyeXYZ: function(a, c, d) {
- this.setEye(a, c, d)
- },
- setEye: function(a, c, d) {
- this._eyeX = a;
- this._eyeY = c;
- this._eyeZ = d;
- this._dirty = !0
- },
- setCenterXYZ: function(a, c, d) {
- this.setCenter(a, c, d)
- },
- setCenter: function(a, c, d) {
- this._centerX = a;
- this._centerY = c;
- this._centerZ = d;
- this._dirty = !0
- },
- setUpXYZ: function(a, c, d) {
- this.setUp(a, c, d)
- },
- setUp: function(a, c, d) {
- this._upX = a;
- this._upY = c;
- this._upZ = d;
- this._dirty = !0
- },
- getEyeXYZ: function(a, c, d) {
- return {
- x: this._eyeX,
- y: this._eyeY,
- z: this._eyeZ
- }
- },
- getEye: function() {
- return {
- x: this._eyeX,
- y: this._eyeY,
- z: this._eyeZ
- }
- },
- getCenterXYZ: function(a, c, d) {
- return {
- x: this._centerX,
- y: this._centerY,
- z: this._centerZ
- }
- },
- getCenter: function() {
- return {
- x: this._centerX,
- y: this._centerY,
- z: this._centerZ
- }
- },
- getUpXYZ: function(a, c, d) {
- return {
- x: this._upX,
- y: this._upY,
- z: this._upZ
- }
- },
- getUp: function() {
- return {
- x: this._upX,
- y: this._upY,
- z: this._upZ
- }
- },
- _DISALLOW_COPY_AND_ASSIGN: function(a) {}
- });
- cc.Camera.getZEye = function() {
- return cc.FLT_EPSILON
- };
- cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1;
- cc.arrayVerifyType = function(a, c) {
- if (a && 0 < a.length)
- for (var d = 0; d < a.length; d++)
- if (!(a[d] instanceof c)) return cc.log(cc._LogInfos.arrayVerifyType), !1;
- return !0
- };
- cc.arrayRemoveObject = function(a, c) {
- for (var d = 0, e = a.length; d < e; d++)
- if (a[d] == c) {
- a.splice(d, 1);
- break
- }
- };
- cc.arrayRemoveArray = function(a, c) {
- for (var d = 0, e = c.length; d < e; d++) cc.arrayRemoveObject(a, c[d])
- };
- cc.arrayAppendObjectsToIndex = function(a, c, d) {
- a.splice.apply(a, [d, 0].concat(c));
- return a
- };
- cc.ListEntry = function(a, c, d, e, f, g) {
- this.prev = a;
- this.next = c;
- this.target = d;
- this.priority = e;
- this.paused = f;
- this.markedForDeletion = g
- };
- cc.HashUpdateEntry = function(a, c, d, e) {
- this.list = a;
- this.entry = c;
- this.target = d;
- this.hh = e
- };
- cc.HashTimerEntry = function(a, c, d, e, f, g, h) {
- this.timers = a;
- this.target = c;
- this.timerIndex = d;
- this.currentTimer = e;
- this.currentTimerSalvaged = f;
- this.paused = g;
- this.hh = h
- };
- cc.Timer = cc.Class.extend({
- _interval: 0,
- _callback: null,
- _target: null,
- _elapsed: 0,
- _runForever: !1,
- _useDelay: !1,
- _timesExecuted: 0,
- _repeat: 0,
- _delay: 0,
- getInterval: function() {
- return this._interval
- },
- setInterval: function(a) {
- this._interval = a
- },
- getCallback: function() {
- return this._callback
- },
- ctor: function(a, c, d, e, f) {
- this._target = a;
- this._callback = c;
- this._elapsed = -1;
- this._interval = d || 0;
- this._delay = f || 0;
- this._useDelay = 0 < this._delay;
- this._repeat = null == e ? cc.REPEAT_FOREVER : e;
- this._runForever = this._repeat == cc.REPEAT_FOREVER
- },
- _doCallback: function() {
- if ("string" == typeof this._callback) this._target[this._callback](this._elapsed);
- else this._callback.call(this._target, this._elapsed)
- },
- update: function(a) {
- if (-1 == this._elapsed) this._timesExecuted = this._elapsed = 0;
- else {
- var c = this._target,
- d = this._callback;
- this._elapsed += a;
- this._runForever && !this._useDelay ? this._elapsed >= this._interval && (c && d && this._doCallback(), this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (c && d && this._doCallback(), this._elapsed -= this._delay, this._timesExecuted += 1, this._useDelay = !1) : this._elapsed >= this._interval && (c && d && this._doCallback(), this._elapsed = 0, this._timesExecuted += 1), this._timesExecuted > this._repeat && cc.director.getScheduler().unscheduleCallbackForTarget(c, d))
- }
- }
- });
- cc.Scheduler = cc.Class.extend({
- _timeScale: 1,
- _updates: null,
- _hashForUpdates: null,
- _arrayForUpdates: null,
- _hashForTimers: null,
- _arrayForTimes: null,
- _currentTarget: null,
- _currentTargetSalvaged: !1,
- _updateHashLocked: !1,
- ctor: function() {
- this._timeScale = 1;
- this._updates = [
- [],
- [],
- []
- ];
- this._hashForUpdates = {};
- this._arrayForUpdates = [];
- this._hashForTimers = {};
- this._arrayForTimers = [];
- this._currentTarget = null;
- this._updateHashLocked = this._currentTargetSalvaged = !1
- },
- _removeHashElement: function(a) {
- delete this._hashForTimers[a.target.__instanceId];
- cc.arrayRemoveObject(this._arrayForTimers, a);
- a.Timer = null;
- a.target = null
- },
- _removeUpdateFromHash: function(a) {
- if (a = this._hashForUpdates[a.target.__instanceId]) cc.arrayRemoveObject(a.list, a.entry), delete this._hashForUpdates[a.target.__instanceId], cc.arrayRemoveObject(this._arrayForUpdates, a), a.entry = null, a.target = null
- },
- _priorityIn: function(a, c, d, e) {
- e = new cc.ListEntry(null, null, c, d, e, !1);
- if (a) {
- for (var f = a.length - 1, g = 0; g <= f && !(d < a[g].priority); g++);
- a.splice(g, 0, e)
- } else a = [], a.push(e);
- d = new cc.HashUpdateEntry(a, e, c, null);
- this._arrayForUpdates.push(d);
- this._hashForUpdates[c.__instanceId] = d;
- return a
- },
- _appendIn: function(a, c, d) {
- d = new cc.ListEntry(null, null, c, 0, d, !1);
- a.push(d);
- a = new cc.HashUpdateEntry(a, d, c, null);
- this._arrayForUpdates.push(a);
- this._hashForUpdates[c.__instanceId] = a
- },
- setTimeScale: function(a) {
- this._timeScale = a
- },
- getTimeScale: function() {
- return this._timeScale
- },
- update: function(a) {
- var c = this._updates,
- d = this._arrayForTimers,
- e, f, g;
- this._updateHashLocked = !0;
- 1 != this._timeScale && (a *= this._timeScale);
- f = 0;
- for (g = c.length; f < g && 0 <= f; f++)
- for (var h = this._updates[f], k = 0, m = h.length; k < m; k++) e = h[k], !e.paused && !e.markedForDeletion && e.target.update(a);
- f = 0;
- for (g = d.length; f < g; f++) {
- e = d[f];
- if (!e) break;
- this._currentTarget = e;
- this._currentTargetSalvaged = !1;
- if (!e.paused)
- for (e.timerIndex = 0; e.timerIndex < e.timers.length; e.timerIndex++) e.currentTimer = e.timers[e.timerIndex], e.currentTimerSalvaged = !1, e.currentTimer.update(a), e.currentTimer = null;
- this._currentTargetSalvaged && 0 == e.timers.length && (this._removeHashElement(e), f--)
- }
- f = 0;
- for (g = c.length; f < g; f++) {
- h = this._updates[f];
- k = 0;
- for (m = h.length; k < m;) {
- e = h[k];
- if (!e) break;
- e.markedForDeletion ? this._removeUpdateFromHash(e) : k++
- }
- }
- this._updateHashLocked = !1;
- this._currentTarget = null
- },
- scheduleCallbackForTarget: function(a, c, d, e, f, g) {
- cc.assert(c, cc._LogInfos.Scheduler_scheduleCallbackForTarget_2);
- cc.assert(a, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
- d = d || 0;
- e = null == e ? cc.REPEAT_FOREVER : e;
- f = f || 0;
- g = g || !1;
- var h = this._hashForTimers[a.__instanceId];
- h || (h = new cc.HashTimerEntry(null, a, 0, null, null, g, null), this._arrayForTimers.push(h), this._hashForTimers[a.__instanceId] = h);
- if (null == h.timers) h.timers = [];
- else
- for (var k = 0; k < h.timers.length; k++)
- if (g = h.timers[k], c == g._callback) {
- cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, g.getInterval().toFixed(4), d.toFixed(4));
- g._interval = d;
- return
- }
- g = new cc.Timer(a, c, d, e, f);
- h.timers.push(g)
- },
- scheduleUpdateForTarget: function(a, c, d) {
- if (null !== a) {
- var e = this._updates,
- f = this._hashForUpdates[a.__instanceId];
- f ? f.entry.markedForDeletion = !1 : 0 == c ? this._appendIn(e[1], a, d) : 0 > c ? e[0] = this._priorityIn(e[0], a, c, d) : e[2] = this._priorityIn(e[2], a, c, d)
- }
- },
- unscheduleCallbackForTarget: function(a, c) {
- if (!(null == a || null == c)) {
- var d = this._hashForTimers[a.__instanceId];
- if (d)
- for (var e = d.timers, f = 0, g = e.length; f < g; f++) {
- var h = e[f];
- if (c == h._callback) {
- h == d.currentTimer && !d.currentTimerSalvaged && (d.currentTimerSalvaged = !0);
- e.splice(f, 1);
- d.timerIndex >= f && d.timerIndex--;
- 0 == e.length && (this._currentTarget == d ? this._currentTargetSalvaged = !0 : this._removeHashElement(d));
- break
- }
- }
- }
- },
- unscheduleUpdateForTarget: function(a) {
- null != a && (a = this._hashForUpdates[a.__instanceId], null != a && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry)))
- },
- unscheduleAllCallbacksForTarget: function(a) {
- if (null != a) {
- var c = this._hashForTimers[a.__instanceId];
- if (c) {
- var d = c.timers;
- !c.currentTimerSalvaged && 0 <= d.indexOf(c.currentTimer) && (c.currentTimerSalvaged = !0);
- d.length = 0;
- this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c)
- }
- this.unscheduleUpdateForTarget(a)
- }
- },
- unscheduleAllCallbacks: function() {
- this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
- },
- unscheduleAllCallbacksWithMinPriority: function(a) {
- for (var c = this._arrayForTimers, d = this._updates, e = 0, f = c.length; e < f; e++) this.unscheduleAllCallbacksForTarget(c[e].target);
- for (e = 2; 0 <= e; e--)
- if (!(1 == e && 0 < a || 0 == e && 0 <= a))
- for (var c = d[e], f = 0, g = c.length; f < g; f++) this.unscheduleUpdateForTarget(c[f].target)
- },
- pauseAllTargets: function() {
- return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
- },
- pauseAllTargetsWithMinPriority: function(a) {
- a = [];
- for (var c, d = this._arrayForTimers, e = this._updates, f = 0, g = d.length; f < g; f++)
- if (c = d[f]) c.paused = !0, a.push(c.target);
- f = 0;
- for (g = e.length; f < g; f++)
- for (var d = e[f], h = 0, k = d.length; h < k; h++)
- if (c = d[h]) c.paused = !0, a.push(c.target);
- return a
- },
- resumeTargets: function(a) {
- if (a)
- for (var c = 0; c < a.length; c++) this.resumeTarget(a[c])
- },
- pauseTarget: function(a) {
- cc.assert(a, cc._LogInfos.Scheduler_pauseTarget);
- var c = this._hashForTimers[a.__instanceId];
- c && (c.paused = !0);
- (a = this._hashForUpdates[a.__instanceId]) && (a.entry.paused = !0)
- },
- resumeTarget: function(a) {
- cc.assert(a, cc._LogInfos.Scheduler_resumeTarget);
- var c = this._hashForTimers[a.__instanceId];
- c && (c.paused = !1);
- (a = this._hashForUpdates[a.__instanceId]) && (a.entry.paused = !1)
- },
- isTargetPaused: function(a) {
- cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused);
- return (a = this._hashForTimers[a.__instanceId]) ? a.paused : !1
- }
- });
- cc.Scheduler.PRIORITY_SYSTEM = -2147483648;
- cc.PI2 = 2 * Math.PI;
- cc.DrawingPrimitiveCanvas = cc.Class.extend({
- _cacheArray: [],
- _renderContext: null,
- ctor: function(a) {
- this._renderContext = a
- },
- drawPoint: function(a, c) {
- c || (c = 1);
- var d = cc.view.getScaleX(),
- e = cc.view.getScaleY(),
- e = cc.p(a.x * d, a.y * e);
- this._renderContext.beginPath();
- this._renderContext.arc(e.x, -e.y, c * d, 0, 2 * Math.PI, !1);
- this._renderContext.closePath();
- this._renderContext.fill()
- },
- drawPoints: function(a, c, d) {
- if (null != a) {
- d || (d = 1);
- c = this._renderContext;
- var e = cc.view.getScaleX(),
- f = cc.view.getScaleY();
- c.beginPath();
- for (var g = 0, h = a.length; g < h; g++) c.arc(a[g].x * e, -a[g].y * f, d * e, 0, 2 * Math.PI, !1);
- c.closePath();
- c.fill()
- }
- },
- drawLine: function(a, c) {
- var d = this._renderContext,
- e = cc.view.getScaleX(),
- f = cc.view.getScaleY();
- d.beginPath();
- d.moveTo(a.x * e, -a.y * f);
- d.lineTo(c.x * e, -c.y * f);
- d.closePath();
- d.stroke()
- },
- drawRect: function(a, c) {
- this.drawLine(cc.p(a.x, a.y), cc.p(c.x, a.y));
- this.drawLine(cc.p(c.x, a.y), cc.p(c.x, c.y));
- this.drawLine(cc.p(c.x, c.y), cc.p(a.x, c.y));
- this.drawLine(cc.p(a.x, c.y), cc.p(a.x, a.y))
- },
- drawSolidRect: function(a, c, d) {
- a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
- this.drawSolidPoly(a, 4, d)
- },
- drawPoly: function(a, c, d, e) {
- e = e || !1;
- if (null != a) {
- if (3 > a.length) throw Error("Polygon's point must greater than 2");
- var f = a[0];
- c = this._renderContext;
- var g = cc.view.getScaleX(),
- h = cc.view.getScaleY();
- c.beginPath();
- c.moveTo(f.x * g, -f.y * h);
- for (var f = 1, k = a.length; f < k; f++) c.lineTo(a[f].x * g, -a[f].y * h);
- d && c.closePath();
- e ? c.fill() : c.stroke()
- }
- },
- drawSolidPoly: function(a, c, d) {
- this.setDrawColor(d.r, d.g, d.b, d.a);
- this.drawPoly(a, c, !0, !0)
- },
- drawCircle: function(a, c, d, e, f) {
- f = f || !1;
- e = this._renderContext;
- var g = cc.view.getScaleX(),
- h = cc.view.getScaleY();
- e.beginPath();
- e.arc(0 | a.x * g, 0 | -(a.y * h), c * g, -d, -(d - 2 * Math.PI), !1);
- f && e.lineTo(0 | a.x * g, 0 | -(a.y * h));
- e.stroke()
- },
- drawQuadBezier: function(a, c, d, e) {
- for (var f = this._cacheArray, g = f.length = 0, h = 0; h < e; h++) {
- var k = Math.pow(1 - g, 2) * a.x + 2 * (1 - g) * g * c.x + g * g * d.x,
- m = Math.pow(1 - g, 2) * a.y + 2 * (1 - g) * g * c.y + g * g * d.y;
- f.push(cc.p(k, m));
- g += 1 / e
- }
- f.push(cc.p(d.x, d.y));
- this.drawPoly(f, e + 1, !1, !1)
- },
- drawCubicBezier: function(a, c, d, e, f) {
- for (var g = this._cacheArray, h = g.length = 0, k = 0; k < f; k++) {
- var m = Math.pow(1 - h, 3) * a.x + 3 * Math.pow(1 - h, 2) * h * c.x + 3 * (1 - h) * h * h * d.x + h * h * h * e.x,
- n = Math.pow(1 - h, 3) * a.y + 3 * Math.pow(1 - h, 2) * h * c.y + 3 * (1 - h) * h * h * d.y + h * h * h * e.y;
- g.push(cc.p(m, n));
- h += 1 / f
- }
- g.push(cc.p(e.x, e.y));
- this.drawPoly(g, f + 1, !1, !1)
- },
- drawCatmullRom: function(a, c) {
- this.drawCardinalSpline(a, 0.5, c)
- },
- drawCardinalSpline: function(a, c, d) {
- cc._renderContext.strokeStyle = "rgba(255,255,255,1)";
- var e = this._cacheArray;
- e.length = 0;
- for (var f, g, h = 1 / a.length, k = 0; k < d + 1; k++) g = k / d, 1 == g ? (f = a.length - 1, g = 1) : (f = 0 | g / h, g = (g - h * f) / h), f = cc.CardinalSplineAt(cc.getControlPointAt(a, f - 1), cc.getControlPointAt(a, f - 0), cc.getControlPointAt(a, f + 1), cc.getControlPointAt(a, f + 2), c, g), e.push(f);
- this.drawPoly(e, d + 1, !1, !1)
- },
- drawImage: function(a, c, d, e, f) {
- switch (arguments.length) {
- case 2:
- this._renderContext.drawImage(a, c.x, -(c.y + a.height));
- break;
- case 3:
- this._renderContext.drawImage(a, c.x, -(c.y + d.height), d.width, d.height);
- break;
- case 5:
- this._renderContext.drawImage(a, c.x, c.y, d.width, d.height, e.x, -(e.y + f.height), f.width, f.height);
- break;
- default:
- throw Error("Argument must be non-nil");
- }
- },
- drawStar: function(a, c, d) {
- a = a || this._renderContext;
- c *= cc.view.getScaleX();
- d = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b);
- a.fillStyle = d + ",1)";
- var e = c / 10;
- a.beginPath();
- a.moveTo(-c, c);
- a.lineTo(0, e);
- a.lineTo(c, c);
- a.lineTo(e, 0);
- a.lineTo(c, -c);
- a.lineTo(0, -e);
- a.lineTo(-c, -c);
- a.lineTo(-e, 0);
- a.lineTo(-c, c);
- a.closePath();
- a.fill();
- var f = a.createRadialGradient(0, 0, e, 0, 0, c);
- f.addColorStop(0, d + ", 1)");
- f.addColorStop(0.3, d + ", 0.8)");
- f.addColorStop(1, d + ", 0.0)");
- a.fillStyle = f;
- a.beginPath();
- a.arc(0, 0, c - e, 0, cc.PI2, !1);
- a.closePath();
- a.fill()
- },
- drawColorBall: function(a, c, d) {
- a = a || this._renderContext;
- c *= cc.view.getScaleX();
- d = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b);
- var e = a.createRadialGradient(0, 0, c / 10, 0, 0, c);
- e.addColorStop(0, d + ", 1)");
- e.addColorStop(0.3, d + ", 0.8)");
- e.addColorStop(0.6, d + ", 0.4)");
- e.addColorStop(1, d + ", 0.0)");
- a.fillStyle = e;
- a.beginPath();
- a.arc(0, 0, c, 0, cc.PI2, !1);
- a.closePath();
- a.fill()
- },
- fillText: function(a, c, d) {
- this._renderContext.fillText(a, c, -d)
- },
- setDrawColor: function(a, c, d, e) {
- this._renderContext.fillStyle = "rgba(" + a + "," + c + "," + d + "," + e / 255 + ")";
- this._renderContext.strokeStyle = "rgba(" + a + "," + c + "," + d + "," + e / 255 + ")"
- },
- setPointSize: function(a) {},
- setLineWidth: function(a) {
- this._renderContext.lineWidth = a * cc.view.getScaleX()
- }
- });
- cc.DrawingPrimitiveWebGL = cc.Class.extend({
- _renderContext: null,
- _initialized: !1,
- _shader: null,
- _colorLocation: -1,
- _colorArray: null,
- _pointSizeLocation: -1,
- _pointSize: -1,
- ctor: function(a) {
- null == a && (a = cc._renderContext);
- if (!a instanceof WebGLRenderingContext) throw "Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext";
- this._renderContext = a;
- this._colorArray = new Float32Array([1, 1, 1, 1])
- },
- lazy_init: function() {
- this._initialized || (this._shader = cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR), this._colorLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_color"), this._pointSizeLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_pointSize"), this._initialized = !0)
- },
- drawInit: function() {
- this._initialized = !1
- },
- drawPoint: function(a) {
- this.lazy_init();
- var c = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- c.uniform4fv(this._colorLocation, this._colorArray);
- this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
- var d = c.createBuffer();
- c.bindBuffer(c.ARRAY_BUFFER, d);
- c.bufferData(c.ARRAY_BUFFER, new Float32Array([a.x, a.y]), c.STATIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
- c.drawArrays(c.POINTS, 0, 1);
- c.deleteBuffer(d);
- cc.incrementGLDraws(1)
- },
- drawPoints: function(a, c) {
- if (a && 0 != a.length) {
- this.lazy_init();
- var d = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- d.uniform4fv(this._colorLocation, this._colorArray);
- this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
- var e = d.createBuffer();
- d.bindBuffer(d.ARRAY_BUFFER, e);
- d.bufferData(d.ARRAY_BUFFER, this._pointsToTypeArray(a), d.STATIC_DRAW);
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, 0);
- d.drawArrays(d.POINTS, 0, a.length);
- d.deleteBuffer(e);
- cc.incrementGLDraws(1)
- }
- },
- _pointsToTypeArray: function(a) {
- for (var c = new Float32Array(2 * a.length), d = 0; d < a.length; d++) c[2 * d] = a[d].x, c[2 * d + 1] = a[d].y;
- return c
- },
- drawLine: function(a, c) {
- this.lazy_init();
- var d = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- d.uniform4fv(this._colorLocation, this._colorArray);
- var e = d.createBuffer();
- d.bindBuffer(d.ARRAY_BUFFER, e);
- d.bufferData(d.ARRAY_BUFFER, this._pointsToTypeArray([a, c]), d.STATIC_DRAW);
- d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, 0);
- d.drawArrays(d.LINES, 0, 2);
- d.deleteBuffer(e);
- cc.incrementGLDraws(1)
- },
- drawRect: function(a, c) {
- this.drawLine(cc.p(a.x, a.y), cc.p(c.x, a.y));
- this.drawLine(cc.p(c.x, a.y), cc.p(c.x, c.y));
- this.drawLine(cc.p(c.x, c.y), cc.p(a.x, c.y));
- this.drawLine(cc.p(a.x, c.y), cc.p(a.x, a.y))
- },
- drawSolidRect: function(a, c, d) {
- a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
- this.drawSolidPoly(a, 4, d)
- },
- drawPoly: function(a, c, d) {
- this.lazy_init();
- c = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- c.uniform4fv(this._colorLocation, this._colorArray);
- var e = c.createBuffer();
- c.bindBuffer(c.ARRAY_BUFFER, e);
- c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
- d ? c.drawArrays(c.LINE_LOOP, 0, a.length) : c.drawArrays(c.LINE_STRIP, 0, a.length);
- c.deleteBuffer(e);
- cc.incrementGLDraws(1)
- },
- drawSolidPoly: function(a, c, d) {
- this.lazy_init();
- d && this.setDrawColor(d.r, d.g, d.b, d.a);
- c = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- c.uniform4fv(this._colorLocation, this._colorArray);
- d = c.createBuffer();
- c.bindBuffer(c.ARRAY_BUFFER, d);
- c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
- c.drawArrays(c.TRIANGLE_FAN, 0, a.length);
- c.deleteBuffer(d);
- cc.incrementGLDraws(1)
- },
- drawCircle: function(a, c, d, e, f) {
- this.lazy_init();
- var g = 1;
- f && g++;
- var h = 2 * Math.PI / e;
- if (f = new Float32Array(2 * (e + 2))) {
- for (var k = 0; k <= e; k++) {
- var m = k * h,
- n = c * Math.cos(m + d) + a.x,
- m = c * Math.sin(m + d) + a.y;
- f[2 * k] = n;
- f[2 * k + 1] = m
- }
- f[2 * (e + 1)] = a.x;
- f[2 * (e + 1) + 1] = a.y;
- a = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- a.uniform4fv(this._colorLocation, this._colorArray);
- c = a.createBuffer();
- a.bindBuffer(a.ARRAY_BUFFER, c);
- a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
- a.drawArrays(a.LINE_STRIP, 0, e + g);
- a.deleteBuffer(c);
- cc.incrementGLDraws(1)
- }
- },
- drawQuadBezier: function(a, c, d, e) {
- this.lazy_init();
- for (var f = new Float32Array(2 * (e + 1)), g = 0, h = 0; h < e; h++) f[2 * h] = Math.pow(1 - g, 2) * a.x + 2 * (1 - g) * g * c.x + g * g * d.x, f[2 * h + 1] = Math.pow(1 - g, 2) * a.y + 2 * (1 - g) * g * c.y + g * g * d.y, g += 1 / e;
- f[2 * e] = d.x;
- f[2 * e + 1] = d.y;
- a = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- a.uniform4fv(this._colorLocation, this._colorArray);
- c = a.createBuffer();
- a.bindBuffer(a.ARRAY_BUFFER, c);
- a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
- a.drawArrays(a.LINE_STRIP, 0, e + 1);
- a.deleteBuffer(c);
- cc.incrementGLDraws(1)
- },
- drawCubicBezier: function(a, c, d, e, f) {
- this.lazy_init();
- for (var g = new Float32Array(2 * (f + 1)), h = 0, k = 0; k < f; k++) g[2 * k] = Math.pow(1 - h, 3) * a.x + 3 * Math.pow(1 - h, 2) * h * c.x + 3 * (1 - h) * h * h * d.x + h * h * h * e.x, g[2 * k + 1] = Math.pow(1 - h, 3) * a.y + 3 * Math.pow(1 - h, 2) * h * c.y + 3 * (1 - h) * h * h * d.y + h * h * h * e.y, h += 1 / f;
- g[2 * f] = e.x;
- g[2 * f + 1] = e.y;
- a = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- a.uniform4fv(this._colorLocation, this._colorArray);
- c = a.createBuffer();
- a.bindBuffer(a.ARRAY_BUFFER, c);
- a.bufferData(a.ARRAY_BUFFER, g, a.STATIC_DRAW);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
- a.drawArrays(a.LINE_STRIP, 0, f + 1);
- a.deleteBuffer(c);
- cc.incrementGLDraws(1)
- },
- drawCatmullRom: function(a, c) {
- this.drawCardinalSpline(a, 0.5, c)
- },
- drawCardinalSpline: function(a, c, d) {
- this.lazy_init();
- for (var e = new Float32Array(2 * (d + 1)), f, g, h = 1 / a.length, k = 0; k < d + 1; k++) g = k / d, 1 == g ? (f = a.length - 1, g = 1) : (f = 0 | g / h, g = (g - h * f) / h), f = cc.CardinalSplineAt(cc.getControlPointAt(a, f - 1), cc.getControlPointAt(a, f), cc.getControlPointAt(a, f + 1), cc.getControlPointAt(a, f + 2), c, g), e[2 * k] = f.x, e[2 * k + 1] = f.y;
- a = this._renderContext;
- this._shader.use();
- this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
- a.uniform4fv(this._colorLocation, this._colorArray);
- c = a.createBuffer();
- a.bindBuffer(a.ARRAY_BUFFER, c);
- a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
- a.drawArrays(a.LINE_STRIP, 0, d + 1);
- a.deleteBuffer(c);
- cc.incrementGLDraws(1)
- },
- setDrawColor: function(a, c, d, e) {
- this._colorArray[0] = a / 255;
- this._colorArray[1] = c / 255;
- this._colorArray[2] = d / 255;
- this._colorArray[3] = e / 255
- },
- setPointSize: function(a) {
- this._pointSize = a * cc.contentScaleFactor()
- },
- setLineWidth: function(a) {
- this._renderContext.lineWidth && this._renderContext.lineWidth(a)
- }
- });
- cc._tmp.WebGLLabelTTF = function() {
- var a = cc.LabelTTF.prototype;
- a.setColor = cc.Sprite.prototype.setColor;
- a._setColorsString = function() {
- this._needUpdateTexture = !0;
- var a = this._strokeColor,
- d = this._textFillColor;
- this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")";
- this._fillColorStr = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + ", 1)";
- this._strokeColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + ", 1)"
- };
- a.updateDisplayedColor = cc.Sprite.prototype.updateDisplayedColor;
- a.setOpacity = cc.Sprite.prototype.setOpacity;
- a.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity;
- a.initWithStringAndTextDefinition = function(a, d) {
- if (!cc.Sprite.prototype.init.call(this)) return !1;
- this.shaderProgram = cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM);
- this._updateWithTextDefinition(d, !1);
- this.string = a;
- return !0
- };
- a.setFontFillColor = function(a) {
- var d = this._textFillColor;
- if (d.r != a.r || d.g != a.g || d.b != a.b) d.r = a.r, d.g = a.g, d.b = a.b, this._setColorsString(), this._needUpdateTexture = !0
- };
- a.draw = function(a) {
- if (this._string && "" != this._string) {
- a = a || cc._renderContext;
- var d = this._texture;
- d && d._isLoaded && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2D(d), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.STATIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 24, 16), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4));
- if (1 === cc.SPRITE_DEBUG_DRAW) a = this._quad, a = [cc.p(a.tl.vertices.x, a.tl.vertices.y), cc.p(a.bl.vertices.x, a.bl.vertices.y), cc.p(a.br.vertices.x, a.br.vertices.y), cc.p(a.tr.vertices.x, a.tr.vertices.y)], cc._drawingUtil.drawPoly(a, 4, !0);
- else if (2 === cc.SPRITE_DEBUG_DRAW) {
- a = this.getTextureRect();
- var d = this.offsetX,
- e = this.offsetY;
- a = [cc.p(d, e), cc.p(d + a.width, e), cc.p(d + a.width, e + a.height), cc.p(d, e + a.height)];
- cc._drawingUtil.drawPoly(a, 4, !0)
- }
- cc.g_NumberOfDraws++
- }
- };
- a.setTextureRect = cc.Sprite.prototype.setTextureRect
- };
- cc._tmp.PrototypeLabelTTF = function() {
- var a = cc.LabelTTF.prototype;
- cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
- cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
- cc.defineGetterSetter(a, "string", a.getString, a.setString);
- cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment);
- cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment);
- cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize);
- cc.defineGetterSetter(a, "fontName", a.getFontName, a.setFontName);
- cc.defineGetterSetter(a, "font", a._getFont, a._setFont);
- cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth);
- cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight);
- cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor);
- cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle);
- cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth);
- cc.defineGetterSetter(a, "shadowOffsetX", a._getShadowOffsetX, a._setShadowOffsetX);
- cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY);
- cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity);
- cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur)
- };
- cc.LabelTTF = cc.Sprite.extend({
- _dimensions: null,
- _hAlignment: cc.TEXT_ALIGNMENT_CENTER,
- _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP,
- _fontName: null,
- _fontSize: 0,
- _string: "",
- _originalText: null,
- _isMultiLine: !1,
- _fontStyleStr: null,
- _shadowEnabled: !1,
- _shadowOffset: null,
- _shadowOpacity: 0,
- _shadowBlur: 0,
- _shadowColorStr: null,
- _strokeEnabled: !1,
- _strokeColor: null,
- _strokeSize: 0,
- _strokeColorStr: null,
- _textFillColor: null,
- _fillColorStr: null,
- _strokeShadowOffsetX: 0,
- _strokeShadowOffsetY: 0,
- _needUpdateTexture: !1,
- _labelCanvas: null,
- _labelContext: null,
- _lineWidths: null,
- _className: "LabelTTF",
- ctor: function(a, c, d, e, f, g) {
- cc.Sprite.prototype.ctor.call(this);
- this._dimensions = cc.size(0, 0);
- this._hAlignment = cc.TEXT_ALIGNMENT_LEFT;
- this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
- this._opacityModifyRGB = !1;
- this._fontStyleStr = "";
- this._fontName = "Arial";
- this._shadowEnabled = this._isMultiLine = !1;
- this._shadowOffset = cc.p(0, 0);
- this._shadowBlur = this._shadowOpacity = 0;
- this._shadowColorStr = "rgba(128, 128, 128, 0.5)";
- this._strokeEnabled = !1;
- this._strokeColor = cc.color(255, 255, 255, 255);
- this._strokeSize = 0;
- this._strokeColorStr = "";
- this._textFillColor = cc.color(255, 255, 255, 255);
- this._fillColorStr = "rgba(255,255,255,1)";
- this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0;
- this._needUpdateTexture = !1;
- this._lineWidths = [];
- this._setColorsString();
- c && c instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, c) : cc.LabelTTF.prototype.initWithString.call(this, a, c, d, e, f, g)
- },
- init: function() {
- return this.initWithString(" ", this._fontName, this._fontSize)
- },
- _measureConfig: function() {
- this._getLabelContext().font = this._fontStyleStr
- },
- _measure: function(a) {
- return this._getLabelContext().measureText(a).width
- },
- description: function() {
- return "\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) + "\x3e"
- },
- setColor: null,
- _setColorsString: null,
- updateDisplayedColor: null,
- setOpacity: null,
- updateDisplayedOpacity: null,
- updateDisplayedOpacityForCanvas: function(a) {
- cc.Node.prototype.updateDisplayedOpacity.call(this, a);
- this._setColorsString()
- },
- getString: function() {
- return this._string
- },
- getHorizontalAlignment: function() {
- return this._hAlignment
- },
- getVerticalAlignment: function() {
- return this._vAlignment
- },
- getDimensions: function() {
- return cc.size(this._dimensions)
- },
- getFontSize: function() {
- return this._fontSize
- },
- getFontName: function() {
- return this._fontName
- },
- initWithString: function(a, c, d, e, f, g) {
- a = a ? a + "" : "";
- d = d || 16;
- e = e || cc.size(0, d);
- f = f || cc.TEXT_ALIGNMENT_LEFT;
- g = g || cc.VERTICAL_TEXT_ALIGNMENT_TOP;
- this._opacityModifyRGB = !1;
- this._dimensions = cc.size(e.width, e.height);
- this._fontName = c || "Arial";
- this._hAlignment = f;
- this._vAlignment = g;
- this._fontSize = d;
- this._fontStyleStr = this._fontSize + "px '" + c + "'";
- this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(c, this._fontSize);
- this.string = a;
- this._setColorsString();
- this._updateTexture();
- this._needUpdateTexture = !1;
- return !0
- },
- initWithStringAndTextDefinition: null,
- setTextDefinition: function(a) {
- a && this._updateWithTextDefinition(a, !0)
- },
- getTextDefinition: function() {
- return this._prepareTextDefinition(!1)
- },
- enableShadow: function(a, c, d, e) {
- d = d || 0.5;
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- var f = this._shadowOffset;
- if (f && f.x != a || f._y != c) f.x = a, f.y = c;
- this._shadowOpacity != d && (this._shadowOpacity = d);
- this._setColorsString();
- this._shadowBlur != e && (this._shadowBlur = e);
- this._needUpdateTexture = !0
- },
- _getShadowOffsetX: function() {
- return this._shadowOffset.x
- },
- _setShadowOffsetX: function(a) {
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- this._shadowOffset.x != a && (this._shadowOffset.x = a, this._needUpdateTexture = !0)
- },
- _getShadowOffsetY: function() {
- return this._shadowOffset._y
- },
- _setShadowOffsetY: function(a) {
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- this._shadowOffset._y != a && (this._shadowOffset._y = a, this._needUpdateTexture = !0)
- },
- _getShadowOffset: function() {
- return cc.p(this._shadowOffset.x, this._shadowOffset.y)
- },
- _setShadowOffset: function(a) {
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- if (this._shadowOffset.x != a.x || this._shadowOffset.y != a.y) this._shadowOffset.x = a.x, this._shadowOffset.y = a.y, this._needUpdateTexture = !0
- },
- _getShadowOpacity: function() {
- return this._shadowOpacity
- },
- _setShadowOpacity: function(a) {
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- this._shadowOpacity != a && (this._shadowOpacity = a, this._setColorsString(), this._needUpdateTexture = !0)
- },
- _getShadowBlur: function() {
- return this._shadowBlur
- },
- _setShadowBlur: function(a) {
- !1 === this._shadowEnabled && (this._shadowEnabled = !0);
- this._shadowBlur != a && (this._shadowBlur = a, this._needUpdateTexture = !0)
- },
- disableShadow: function() {
- this._shadowEnabled && (this._shadowEnabled = !1, this._needUpdateTexture = !0)
- },
- enableStroke: function(a, c) {
- !1 === this._strokeEnabled && (this._strokeEnabled = !0);
- var d = this._strokeColor;
- if (d.r !== a.r || d.g !== a.g || d.b !== a.b) d.r = a.r, d.g = a.g, d.b = a.b, this._setColorsString();
- this._strokeSize !== c && (this._strokeSize = c || 0);
- this._needUpdateTexture = !0
- },
- _getStrokeStyle: function() {
- return this._strokeColor
- },
- _setStrokeStyle: function(a) {
- !1 === this._strokeEnabled && (this._strokeEnabled = !0);
- var c = this._strokeColor;
- if (c.r !== a.r || c.g !== a.g || c.b !== a.b) c.r = a.r, c.g = a.g, c.b = a.b, this._setColorsString(), this._needUpdateTexture = !0
- },
- _getLineWidth: function() {
- return this._strokeSize
- },
- _setLineWidth: function(a) {
- !1 === this._strokeEnabled && (this._strokeEnabled = !0);
- this._strokeSize !== a && (this._strokeSize = a || 0, this._needUpdateTexture = !0)
- },
- disableStroke: function() {
- this._strokeEnabled && (this._strokeEnabled = !1, this._needUpdateTexture = !0)
- },
- setFontFillColor: null,
- _getFillStyle: function() {
- return this._textFillColor
- },
- _updateWithTextDefinition: function(a, c) {
- a.fontDimensions ? (this._dimensions.width = a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0);
- this._hAlignment = a.textAlign;
- this._vAlignment = a.verticalAlign;
- this._fontName = a.fontName;
- this._fontSize = a.fontSize || 12;
- this._fontStyleStr = this._fontSize + "px '" + this._fontName + "'";
- this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize);
- a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur);
- a.strokeEnabled && this.enableStroke(a.strokeStyle, a.lineWidth);
- this.setFontFillColor(a.fillStyle);
- c && this._updateTexture()
- },
- _prepareTextDefinition: function(a) {
- var c = new cc.FontDefinition;
- a ? (c.fontSize = this._fontSize, c.boundingWidth = cc.contentScaleFactor() * this._dimensions.width, c.boundingHeight = cc.contentScaleFactor() * this._dimensions.height) : (c.fontSize = this._fontSize, c.boundingWidth = this._dimensions.width, c.boundingHeight = this._dimensions.height);
- c.fontName = this._fontName;
- c.textAlign = this._hAlignment;
- c.verticalAlign = this._vAlignment;
- if (this._strokeEnabled) {
- c.strokeEnabled = !0;
- var d = this._strokeColor;
- c.strokeStyle = cc.color(d.r, d.g, d.b);
- c.lineWidth = this._strokeSize
- } else c.strokeEnabled = !1;
- this._shadowEnabled ? (c.shadowEnabled = !0, c.shadowBlur = this._shadowBlur, c.shadowOpacity = this._shadowOpacity, c.shadowOffsetX = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.x, c.shadowOffsetY = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.y) : c._shadowEnabled = !1;
- a = this._textFillColor;
- c.fillStyle = cc.color(a.r, a.g, a.b);
- return c
- },
- _fontClientHeight: 18,
- setString: function(a) {
- a = String(a);
- this._originalText != a && (this._originalText = a + "", this._updateString(), this._needUpdateTexture = !0)
- },
- _updateString: function() {
- this._string = this._originalText
- },
- setHorizontalAlignment: function(a) {
- a !== this._hAlignment && (this._hAlignment = a, this._needUpdateTexture = !0)
- },
- setVerticalAlignment: function(a) {
- a != this._vAlignment && (this._vAlignment = a, this._needUpdateTexture = !0)
- },
- setDimensions: function(a, c) {
- var d;
- void 0 === c ? (d = a.width, c = a.height) : d = a;
- if (d != this._dimensions.width || c != this._dimensions.height) this._dimensions.width = d, this._dimensions.height = c, this._updateString(), this._needUpdateTexture = !0
- },
- _getBoundingWidth: function() {
- return this._dimensions.width
- },
- _setBoundingWidth: function(a) {
- a != this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._needUpdateTexture = !0)
- },
- _getBoundingHeight: function() {
- return this._dimensions.height
- },
- _setBoundingHeight: function(a) {
- a != this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._needUpdateTexture = !0)
- },
- setFontSize: function(a) {
- this._fontSize !== a && (this._fontSize = a, this._fontStyleStr = a + "px '" + this._fontName + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, a), this._needUpdateTexture = !0)
- },
- setFontName: function(a) {
- this._fontName && this._fontName != a && (this._fontName = a, this._fontStyleStr = this._fontSize + "px '" + a + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a, this._fontSize), this._needUpdateTexture = !0)
- },
- _getFont: function() {
- return this._fontStyleStr
- },
- _setFont: function(a) {
- var c = cc.LabelTTF._fontStyleRE.exec(a);
- c && (this._fontSize = parseInt(c[1]), this._fontName = c[2], this._fontStyleStr = a, this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize), this._needUpdateTexture = !0)
- },
- _drawTTFInCanvas: function(a) {
- if (a) {
- var c = this._strokeShadowOffsetX,
- d = this._strokeShadowOffsetY,
- e = this._contentSize.height - d,
- f = this._vAlignment,
- g = this._hAlignment,
- h = this._fontClientHeight,
- k = this._strokeSize;
- a.setTransform(1, 0, 0, 1, 0 + 0.5 * c, e + 0.5 * d);
- a.font != this._fontStyleStr && (a.font = this._fontStyleStr);
- a.fillStyle = this._fillColorStr;
- var m = d = 0,
- n = this._strokeEnabled;
- n && (a.lineWidth = 2 * k, a.strokeStyle = this._strokeColorStr);
- this._shadowEnabled && (k = this._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = k.x, a.shadowOffsetY = -k.y, a.shadowBlur = this._shadowBlur);
- a.textBaseline = cc.LabelTTF._textBaseline[f];
- a.textAlign = cc.LabelTTF._textAlign[g];
- c = this._contentSize.width - c;
- d = g === cc.TEXT_ALIGNMENT_RIGHT ? d + c : g === cc.TEXT_ALIGNMENT_CENTER ? d + c / 2 : d + 0;
- if (this._isMultiLine) {
- g = this._strings.length;
- f === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? m = h + e - h * g : f === cc.VERTICAL_TEXT_ALIGNMENT_CENTER && (m = h / 2 + (e - h * g) / 2);
- for (f = 0; f < g; f++) c = this._strings[f], k = -e + h * f + m, n && a.strokeText(c, d, k), a.fillText(c, d, k)
- } else f !== cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM && (m = f === cc.VERTICAL_TEXT_ALIGNMENT_TOP ? m - e : m - 0.5 * e), n && a.strokeText(this._string, d, m), a.fillText(this._string, d, m)
- }
- },
- _getLabelContext: function() {
- if (this._labelContext) return this._labelContext;
- if (!this._labelCanvas) {
- var a = cc.newElement("canvas"),
- c = new cc.Texture2D;
- c.initWithElement(a);
- this.texture = c;
- this._labelCanvas = a
- }
- return this._labelContext = this._labelCanvas.getContext("2d")
- },
- _checkWarp: function(a, c, d) {
- var e = a[c],
- f = this._measure(e);
- if (f > d && 1 < e.length) {
- for (var g = e.length * (d / f) | 0, h = e.substr(g), k = f - this._measure(h), m, n = 0, q = 0; k > d && 100 > q++;) g *= d / k, g |= 0, h = e.substr(g), k = f - this._measure(h);
- for (q = 0; k < d && 100 > q++;) h && (n = (m = cc.LabelTTF._wordRex.exec(h)) ? m[0].length : 1, m = h), g += n, h = e.substr(g), k = f - this._measure(h);
- g -= n;
- d = e.substr(0, g);
- if (cc.LabelTTF.wrapInspection && cc.LabelTTF._symbolRex.test(m || h)) f = cc.LabelTTF._lastWordRex.exec(d), g -= f ? f[0].length : 0, m = e.substr(g), d = e.substr(0, g);
- if (cc.LabelTTF._firsrEnglish.test(m) && (f = cc.LabelTTF._lastEnglish.exec(d)) && d !== f[0]) g -= f[0].length, m = e.substr(g), d = e.substr(0, g);
- a[c] = m || h;
- a.splice(c, 0, d)
- }
- },
- _updateTTF: function() {
- var a = this._dimensions.width,
- c, d, e = this._lineWidths;
- e.length = 0;
- this._isMultiLine = !1;
- this._measureConfig();
- if (0 !== a) {
- this._strings = this._string.split("\n");
- for (c = 0; c < this._strings.length; c++) this._checkWarp(this._strings, c, a)
- } else {
- this._strings = this._string.split("\n");
- c = 0;
- for (d = this._strings.length; c < d; c++) e.push(this._measure(this._strings[c]))
- }
- 0 < this._strings.length && (this._isMultiLine = !0);
- d = c = 0;
- this._strokeEnabled && (c = d = 2 * this._strokeSize);
- if (this._shadowEnabled) {
- var f = this._shadowOffset;
- c += 2 * Math.abs(f.x);
- d += 2 * Math.abs(f.y)
- }
- a = 0 === a ? this._isMultiLine ? cc.size(0 | Math.max.apply(Math, e) + c, 0 | this._fontClientHeight * this._strings.length + d) : cc.size(0 | this._measure(this._string) + c, 0 | this._fontClientHeight + d) : 0 === this._dimensions.height ? this._isMultiLine ? cc.size(0 | a + c, 0 | this._fontClientHeight * this._strings.length + d) : cc.size(0 | a + c, 0 | this._fontClientHeight + d) : cc.size(0 | a + c, 0 | this._dimensions.height + d);
- this.setContentSize(a);
- this._strokeShadowOffsetX = c;
- this._strokeShadowOffsetY = d;
- e = this._anchorPoint;
- this._anchorPointInPoints.x = 0.5 * c + (a.width - c) * e.x;
- this._anchorPointInPoints.y = 0.5 * d + (a.height - d) * e.y
- },
- getContentSize: function() {
- this._needUpdateTexture && this._updateTTF();
- return cc.Sprite.prototype.getContentSize.call(this)
- },
- _getWidth: function() {
- this._needUpdateTexture && this._updateTTF();
- return cc.Sprite.prototype._getWidth.call(this)
- },
- _getHeight: function() {
- this._needUpdateTexture && this._updateTTF();
- return cc.Sprite.prototype._getHeight.call(this)
- },
- _updateTexture: function() {
- var a = this._getLabelContext(),
- c = this._labelCanvas,
- d = this._contentSize;
- if (0 === this._string.length) return c.width = 1, c.height = d.height || 1, this._texture && this._texture.handleLoadedTexture(), this.setTextureRect(cc.rect(0, 0, 1, d.height)), !0;
- a.font = this._fontStyleStr;
- this._updateTTF();
- var e = d.width,
- d = d.height,
- f = c.width == e && c.height == d;
- c.width = e;
- c.height = d;
- f && a.clearRect(0, 0, e, d);
- this._drawTTFInCanvas(a);
- this._texture && this._texture.handleLoadedTexture();
- this.setTextureRect(cc.rect(0, 0, e, d));
- return !0
- },
- visit: function(a) {
- this._string && "" != this._string && (this._needUpdateTexture && (this._needUpdateTexture = !1, this._updateTexture()), cc.Sprite.prototype.visit.call(this, a || cc._renderContext))
- },
- draw: null,
- _setTextureCoords: function(a) {
- var c = this._batchNode ? this.textureAtlas.texture : this._texture;
- if (c) {
- var d = c.pixelsWidth,
- e = c.pixelsHeight,
- f, g = this._quad;
- this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (c = (2 * a.x + 1) / (2 * d), d = c + (2 * a.height - 2) / (2 * d), f = (2 * a.y + 1) / (2 * e), a = f + (2 * a.width - 2) / (2 * e)) : (c = a.x / d, d = (a.x + a.height) / d, f = a.y / e, a = (a.y + a.width) / e), this._flippedX && (e = f, f = a, a = e), this._flippedY && (e = c, c = d, d = e), g.bl.texCoords.u = c, g.bl.texCoords.v = f, g.br.texCoords.u = c, g.br.texCoords.v = a, g.tl.texCoords.u = d, g.tl.texCoords.v = f, g.tr.texCoords.u = d, g.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (c = (2 * a.x + 1) / (2 * d), d = c + (2 * a.width - 2) / (2 * d), f = (2 * a.y + 1) / (2 * e), a = f + (2 * a.height - 2) / (2 * e)) : (c = a.x / d, d = (a.x + a.width) / d, f = a.y / e, a = (a.y + a.height) / e), this._flippedX && (e = c, c = d, d = e), this._flippedY && (e = f, f = a, a = e), g.bl.texCoords.u = c, g.bl.texCoords.v = a, g.br.texCoords.u = d, g.br.texCoords.v = a, g.tl.texCoords.u = c, g.tl.texCoords.v = f, g.tr.texCoords.u = d, g.tr.texCoords.v = f);
- this._quadDirty = !0
- }
- }
- });
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LabelTTF.prototype, _p.setColor = function(a) {
- cc.Node.prototype.setColor.call(this, a);
- this._setColorsString()
- }, _p._setColorsString = function() {
- this._needUpdateTexture = !0;
- var a = this._displayedColor,
- c = this._displayedOpacity,
- d = this._strokeColor,
- e = this._textFillColor;
- this._shadowColorStr = "rgba(" + (0 | 0.5 * a.r) + "," + (0 | 0.5 * a.g) + "," + (0 | 0.5 * a.b) + "," + this._shadowOpacity + ")";
- this._fillColorStr = "rgba(" + (0 | a.r / 255 * e.r) + "," + (0 | a.g / 255 * e.g) + "," + (0 | a.b / 255 * e.b) + ", " + c / 255 + ")";
- this._strokeColorStr = "rgba(" + (0 | a.r / 255 * d.r) + "," + (0 | a.g / 255 * d.g) + "," + (0 | a.b / 255 * d.b) + ", " + c / 255 + ")"
- }, _p.updateDisplayedColor = function(a) {
- cc.Node.prototype.updateDisplayedColor.call(this, a);
- this._setColorsString()
- }, _p.setOpacity = function(a) {
- this._opacity !== a && (cc.Sprite.prototype.setOpacity.call(this, a), this._setColorsString(), this._needUpdateTexture = !0)
- }, _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity, _p.initWithStringAndTextDefinition = function(a, c) {
- this._updateWithTextDefinition(c, !1);
- this.string = a;
- return !0
- }, _p.setFontFillColor = function(a) {
- var c = this._textFillColor;
- if (c.r != a.r || c.g != a.g || c.b != a.b) c.r = a.r, c.g = a.g, c.b = a.b, this._setColorsString(), this._needUpdateTexture = !0
- }, _p.draw = cc.Sprite.prototype.draw, _p.setTextureRect = function(a, c, d) {
- this._rectRotated = c || !1;
- this.setContentSize(d || a);
- this.setVertexRect(a);
- c = this._textureRect_Canvas;
- c.x = a.x;
- c.y = a.y;
- c.width = a.width;
- c.height = a.height;
- c.validRect = !(0 === c.width || 0 === c.height || 0 > c.x || 0 > c.y);
- a = this._unflippedOffsetPositionFromCenter;
- this._flippedX && (a.x = -a.x);
- this._flippedY && (a.y = -a.y);
- this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
- this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
- this._batchNode && (this.dirty = !0)
- }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLabelTTF, cc._LogInfos.MissingFile, "LabelTTFWebGL.js"), cc._tmp.WebGLLabelTTF(), delete cc._tmp.WebGLLabelTTF);
- cc.assert("function" === typeof cc._tmp.PrototypeLabelTTF, cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js");
- cc._tmp.PrototypeLabelTTF();
- delete cc._tmp.PrototypeLabelTTF;
- cc.LabelTTF._textAlign = ["left", "center", "right"];
- cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
- cc.LabelTTF.wrapInspection = !0;
- cc.LabelTTF._wordRex = /([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)/;
- cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/;
- cc.LabelTTF._lastWordRex = /([a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+|\S)$/;
- cc.LabelTTF._lastEnglish = /[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+$/;
- cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]/;
- cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
- cc.LabelTTF.create = function(a, c, d, e, f, g) {
- return new cc.LabelTTF(a, c, d, e, f, g)
- };
- cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create;
- cc.LabelTTF._SHADER_PROGRAM = cc.USE_LA88_LABELS ? cc.SHADER_POSITION_TEXTURECOLOR : cc.SHADER_POSITION_TEXTUREA8COLOR;
- cc.LabelTTF.__labelHeightDiv = cc.newElement("div");
- cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial";
- cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
- cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
- cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
- cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
- document.body ? document.body.appendChild(cc.LabelTTF.__labelHeightDiv) : cc._addEventListener(window, "load", function() {
- this.removeEventListener("load", arguments.callee, !1);
- document.body.appendChild(cc.LabelTTF.__labelHeightDiv)
- }, !1);
- cc.LabelTTF.__getFontHeightByDiv = function(a, c) {
- var d = cc.LabelTTF.__fontHeightCache[a + "." + c];
- if (0 < d) return d;
- var e = cc.LabelTTF.__labelHeightDiv;
- e.innerHTML = "ajghl~!";
- e.style.fontFamily = a;
- e.style.fontSize = c + "px";
- d = e.clientHeight;
- cc.LabelTTF.__fontHeightCache[a + "." + c] = d;
- e.innerHTML = "";
- return d
- };
- cc.LabelTTF.__fontHeightCache = {};
- cc.HashElement = cc.Class.extend({
- actions: null,
- target: null,
- actionIndex: 0,
- currentAction: null,
- currentActionSalvaged: !1,
- paused: !1,
- hh: null,
- ctor: function() {
- this.actions = [];
- this.target = null;
- this.actionIndex = 0;
- this.currentAction = null;
- this.paused = this.currentActionSalvaged = !1;
- this.hh = null
- }
- });
- cc.ActionManager = cc.Class.extend({
- _hashTargets: null,
- _arrayTargets: null,
- _currentTarget: null,
- _currentTargetSalvaged: !1,
- _searchElementByTarget: function(a, c) {
- for (var d = 0; d < a.length; d++)
- if (c == a[d].target) return a[d];
- return null
- },
- ctor: function() {
- this._hashTargets = {};
- this._arrayTargets = [];
- this._currentTarget = null;
- this._currentTargetSalvaged = !1
- },
- addAction: function(a, c, d) {
- if (!a) throw "cc.ActionManager.addAction(): action must be non-null";
- if (!c) throw "cc.ActionManager.addAction(): action must be non-null";
- var e = this._hashTargets[c.__instanceId];
- e || (e = new cc.HashElement, e.paused = d, e.target = c, this._hashTargets[c.__instanceId] = e, this._arrayTargets.push(e));
- this._actionAllocWithHashElement(e);
- e.actions.push(a);
- a.startWithTarget(c)
- },
- removeAllActions: function() {
- for (var a = this._arrayTargets, c = 0; c < a.length; c++) {
- var d = a[c];
- d && this.removeAllActionsFromTarget(d.target, !0)
- }
- },
- removeAllActionsFromTarget: function(a, c) {
- if (null != a) {
- var d = this._hashTargets[a.__instanceId];
- d && (-1 !== d.actions.indexOf(d.currentAction) && !d.currentActionSalvaged && (d.currentActionSalvaged = !0), d.actions.length = 0, this._currentTarget == d && !c ? this._currentTargetSalvaged = !0 : this._deleteHashElement(d))
- }
- },
- removeAction: function(a) {
- if (null != a) {
- var c = a.getOriginalTarget();
- if (c = this._hashTargets[c.__instanceId])
- for (var d = 0; d < c.actions.length; d++) {
- if (c.actions[d] == a) {
- c.actions.splice(d, 1);
- break
- }
- } else cc.log(cc._LogInfos.ActionManager_removeAction)
- }
- },
- removeActionByTag: function(a, c) {
- a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_addAction);
- cc.assert(c, cc._LogInfos.ActionManager_addAction);
- var d = this._hashTargets[c.__instanceId];
- if (d)
- for (var e = d.actions.length, f = 0; f < e; ++f) {
- var g = d.actions[f];
- if (g && g.getTag() === a && g.getOriginalTarget() == c) {
- this._removeActionAtIndex(f, d);
- break
- }
- }
- },
- getActionByTag: function(a, c) {
- a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_getActionByTag);
- var d = this._hashTargets[c.__instanceId];
- if (d) {
- if (null != d.actions)
- for (var e = 0; e < d.actions.length; ++e) {
- var f = d.actions[e];
- if (f && f.getTag() === a) return f
- }
- cc.log(cc._LogInfos.ActionManager_getActionByTag_2, a)
- }
- return null
- },
- numberOfRunningActionsInTarget: function(a) {
- return (a = this._hashTargets[a.__instanceId]) ? a.actions ? a.actions.length : 0 : 0
- },
- pauseTarget: function(a) {
- (a = this._hashTargets[a.__instanceId]) && (a.paused = !0)
- },
- resumeTarget: function(a) {
- (a = this._hashTargets[a.__instanceId]) && (a.paused = !1)
- },
- pauseAllRunningActions: function() {
- for (var a = [], c = this._arrayTargets, d = 0; d < c.length; d++) {
- var e = c[d];
- e && !e.paused && (e.paused = !0, a.push(e.target))
- }
- return a
- },
- resumeTargets: function(a) {
- if (a)
- for (var c = 0; c < a.length; c++) a[c] && this.resumeTarget(a[c])
- },
- purgeSharedManager: function() {
- cc.director.getScheduler().unscheduleUpdateForTarget(this)
- },
- _removeActionAtIndex: function(a, c) {
- c.actions[a] == c.currentAction && !c.currentActionSalvaged && (c.currentActionSalvaged = !0);
- c.actions.splice(a, 1);
- c.actionIndex >= a && c.actionIndex--;
- 0 == c.actions.length && (this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._deleteHashElement(c))
- },
- _deleteHashElement: function(a) {
- a && (delete this._hashTargets[a.target.__instanceId], cc.arrayRemoveObject(this._arrayTargets, a), a.actions = null, a.target = null)
- },
- _actionAllocWithHashElement: function(a) {
- null == a.actions && (a.actions = [])
- },
- update: function(a) {
- for (var c = this._arrayTargets, d, e = 0; e < c.length; e++) {
- d = this._currentTarget = c[e];
- if (!d.paused)
- for (d.actionIndex = 0; d.actionIndex < d.actions.length; d.actionIndex++)
- if (d.currentAction = d.actions[d.actionIndex], d.currentAction) {
- d.currentActionSalvaged = !1;
- d.currentAction.step(a * (d.currentAction._speedMethod ? d.currentAction._speed : 1));
- if (d.currentActionSalvaged) d.currentAction = null;
- else if (d.currentAction.isDone()) {
- d.currentAction.stop();
- var f = d.currentAction;
- d.currentAction = null;
- this.removeAction(f)
- }
- d.currentAction = null
- }
- this._currentTargetSalvaged && 0 === d.actions.length && this._deleteHashElement(d)
- }
- }
- });
- cc.kmScalar = Number;
- cc.kmBool = Number;
- cc.kmEnum = Number;
- cc.KM_FALSE = 0;
- cc.KM_TRUE = 1;
- cc.kmPI = 3.141592;
- cc.kmPIOver180 = 0.017453;
- cc.kmPIUnder180 = 57.295779;
- cc.kmEpsilon = 0.015625;
- cc.kmSQR = function(a) {
- return a * a
- };
- cc.kmDegreesToRadians = function(a) {
- return a * cc.kmPIOver180
- };
- cc.kmRadiansToDegrees = function(a) {
- return a * cc.kmPIUnder180
- };
- cc.kmMin = function(a, c) {
- return a < c ? a : c
- };
- cc.kmMax = function(a, c) {
- return a > c ? a : c
- };
- cc.kmAlmostEqual = function(a, c) {
- return a + cc.kmEpsilon > c && a - cc.kmEpsilon < c
- };
- cc.kmVec2 = function(a, c) {
- this.x = a || 0;
- this.y = c || 0
- };
- cc.kmVec2Fill = function(a, c, d) {
- a.x = c;
- a.y = d;
- return a
- };
- cc.kmVec2Length = function(a) {
- return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y))
- };
- cc.kmVec2LengthSq = function(a) {
- return cc.kmSQR(a.x) + cc.kmSQR(a.y)
- };
- cc.kmVec2Normalize = function(a, c) {
- var d = 1 / cc.kmVec2Length(c),
- e = new cc.kmVec2;
- e.x = c.x * d;
- e.y = c.y * d;
- a.x = e.x;
- a.y = e.y;
- return a
- };
- cc.kmVec2Add = function(a, c, d) {
- a.x = c.x + d.x;
- a.y = c.y + d.y;
- return a
- };
- cc.kmVec2Dot = function(a, c) {
- return a.x * c.x + a.y * c.y
- };
- cc.kmVec2Subtract = function(a, c, d) {
- a.x = c.x - d.x;
- a.y = c.y - d.y;
- return a
- };
- cc.kmVec2Transform = function(a, c, d) {
- var e = new cc.kmVec2;
- e.x = c.x * d.mat[0] + c.y * d.mat[3] + d.mat[6];
- e.y = c.x * d.mat[1] + c.y * d.mat[4] + d.mat[7];
- a.x = e.x;
- a.y = e.y;
- return a
- };
- cc.kmVec2TransformCoord = function(a, c, d) {
- return null
- };
- cc.kmVec2Scale = function(a, c, d) {
- a.x = c.x * d;
- a.y = c.y * d;
- return a
- };
- cc.kmVec2AreEqual = function(a, c) {
- return a.x < c.x + cc.kmEpsilon && a.x > c.x - cc.kmEpsilon && a.y < c.y + cc.kmEpsilon && a.y > c.y - cc.kmEpsilon
- };
- cc.kmVec3 = function(a, c, d) {
- this.x = a || 0;
- this.y = c || 0;
- this.z = d || 0
- };
- cc.kmVec3Fill = function(a, c, d, e) {
- if (!a) return new cc.kmVec3(c, d, e);
- a.x = c;
- a.y = d;
- a.z = e;
- return a
- };
- cc.kmVec3Length = function(a) {
- return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z))
- };
- cc.kmVec3LengthSq = function(a) {
- return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z)
- };
- cc.kmVec3Normalize = function(a, c) {
- var d = 1 / cc.kmVec3Length(c);
- a.x = c.x * d;
- a.y = c.y * d;
- a.z = c.z * d;
- return a
- };
- cc.kmVec3Cross = function(a, c, d) {
- a.x = c.y * d.z - c.z * d.y;
- a.y = c.z * d.x - c.x * d.z;
- a.z = c.x * d.y - c.y * d.x;
- return a
- };
- cc.kmVec3Dot = function(a, c) {
- return a.x * c.x + a.y * c.y + a.z * c.z
- };
- cc.kmVec3Add = function(a, c, d) {
- a.x = c.x + d.x;
- a.y = c.y + d.y;
- a.z = c.z + d.z;
- return a
- };
- cc.kmVec3Subtract = function(a, c, d) {
- a.x = c.x - d.x;
- a.y = c.y - d.y;
- a.z = c.z - d.z;
- return a
- };
- cc.kmVec3Transform = function(a, c, d) {
- a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8] + d.mat[12];
- a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9] + d.mat[13];
- a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10] + d.mat[14];
- return a
- };
- cc.kmVec3TransformNormal = function(a, c, d) {
- a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8];
- a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9];
- a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10];
- return a
- };
- cc.kmVec3TransformCoord = function(a, c, d) {
- var e = new cc.kmVec4,
- f = new cc.kmVec4;
- cc.kmVec4Fill(f, c.x, c.y, c.z, 1);
- cc.kmVec4Transform(e, f, d);
- a.x = e.x / e.w;
- a.y = e.y / e.w;
- a.z = e.z / e.w;
- return a
- };
- cc.kmVec3Scale = function(a, c, d) {
- a.x = c.x * d;
- a.y = c.y * d;
- a.z = c.z * d;
- return a
- };
- cc.kmVec3AreEqual = function(a, c) {
- return a.x < c.x + cc.kmEpsilon && a.x > c.x - cc.kmEpsilon && a.y < c.y + cc.kmEpsilon && a.y > c.y - cc.kmEpsilon && a.z < c.z + cc.kmEpsilon && a.z > c.z - cc.kmEpsilon ? 1 : 0
- };
- cc.kmVec3InverseTransform = function(a, c, d) {
- c = new cc.kmVec3(c.x - d.mat[12], c.y - d.mat[13], c.z - d.mat[14]);
- a.x = c.x * d.mat[0] + c.y * d.mat[1] + c.z * d.mat[2];
- a.y = c.x * d.mat[4] + c.y * d.mat[5] + c.z * d.mat[6];
- a.z = c.x * d.mat[8] + c.y * d.mat[9] + c.z * d.mat[10];
- return a
- };
- cc.kmVec3InverseTransformNormal = function(a, c, d) {
- a.x = c.x * d.mat[0] + c.y * d.mat[1] + c.z * d.mat[2];
- a.y = c.x * d.mat[4] + c.y * d.mat[5] + c.z * d.mat[6];
- a.z = c.x * d.mat[8] + c.y * d.mat[9] + c.z * d.mat[10];
- return a
- };
- cc.kmVec3Assign = function(a, c) {
- if (a == c) return a;
- a.x = c.x;
- a.y = c.y;
- a.z = c.z;
- return a
- };
- cc.kmVec3Zero = function(a) {
- a.x = 0;
- a.y = 0;
- a.z = 0;
- return a
- };
- cc.kmVec3ToTypeArray = function(a) {
- if (!a) return null;
- var c = new Float32Array(3);
- c[0] = a.x;
- c[1] = a.y;
- c[2] = a.z;
- return c
- };
- cc.kmVec4 = function(a, c, d, e) {
- this.x = a || 0;
- this.y = c || 0;
- this.z = d || 0;
- this.w = e || 0
- };
- cc.kmVec4Fill = function(a, c, d, e, f) {
- a.x = c;
- a.y = d;
- a.z = e;
- a.w = f;
- return a
- };
- cc.kmVec4Add = function(a, c, d) {
- a.x = c.x + d.x;
- a.y = c.y + d.y;
- a.z = c.z + d.z;
- a.w = c.w + d.w;
- return a
- };
- cc.kmVec4Dot = function(a, c) {
- return a.x * c.x + a.y * c.y + a.z * c.z + a.w * c.w
- };
- cc.kmVec4Length = function(a) {
- return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w))
- };
- cc.kmVec4LengthSq = function(a) {
- return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w)
- };
- cc.kmVec4Lerp = function(a, c, d, e) {
- return a
- };
- cc.kmVec4Normalize = function(a, c) {
- var d = 1 / cc.kmVec4Length(c);
- a.x *= d;
- a.y *= d;
- a.z *= d;
- a.w *= d;
- return a
- };
- cc.kmVec4Scale = function(a, c, d) {
- cc.kmVec4Normalize(a, c);
- a.x *= d;
- a.y *= d;
- a.z *= d;
- a.w *= d;
- return a
- };
- cc.kmVec4Subtract = function(a, c, d) {
- a.x = c.x - d.x;
- a.y = c.y - d.y;
- a.z = c.z - d.z;
- a.w = c.w - d.w;
- return a
- };
- cc.kmVec4Transform = function(a, c, d) {
- a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8] + c.w * d.mat[12];
- a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9] + c.w * d.mat[13];
- a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10] + c.w * d.mat[14];
- a.w = c.x * d.mat[3] + c.y * d.mat[7] + c.z * d.mat[11] + c.w * d.mat[15];
- return a
- };
- cc.kmVec4TransformArray = function(a, c, d, e, f, g) {
- for (var h = 0; h < g;) cc.kmVec4Transform(a + h * c, d + h * e, f), ++h;
- return a
- };
- cc.kmVec4AreEqual = function(a, c) {
- return a.x < c.x + cc.kmEpsilon && a.x > c.x - cc.kmEpsilon && a.y < c.y + cc.kmEpsilon && a.y > c.y - cc.kmEpsilon && a.z < c.z + cc.kmEpsilon && a.z > c.z - cc.kmEpsilon && a.w < c.w + cc.kmEpsilon && a.w > c.w - cc.kmEpsilon
- };
- cc.kmVec4Assign = function(a, c) {
- if (a == c) return cc.log("destVec and srcVec are same object"), a;
- a.x = c.x;
- a.y = c.y;
- a.z = c.z;
- a.w = c.w;
- return a
- };
- cc.kmVec4ToTypeArray = function(a) {
- if (!a) return null;
- var c = new Float32Array(4);
- c[0] = a.x;
- c[1] = a.y;
- c[2] = a.z;
- c[3] = a.w;
- return c
- };
- cc.kmRay2 = function(a, c) {
- this.start = a || new cc.kmVec2;
- this.start = a || new cc.kmVec2
- };
- cc.kmRay2Fill = function(a, c, d, e, f) {
- a.start.x = c;
- a.start.y = d;
- a.dir.x = e;
- a.dir.y = f
- };
- cc.kmRay2IntersectLineSegment = function(a, c, d, e) {
- var f = a.start.x,
- g = a.start.y,
- h = a.start.x + a.dir.x;
- a = a.start.y + a.dir.y;
- var k = c.x,
- m = c.y,
- n = d.x,
- q = d.y,
- r = (q - m) * (h - f) - (n - k) * (a - g);
- if (r > -cc.kmEpsilon && r < cc.kmEpsilon) return cc.KM_FALSE;
- m = ((n - k) * (g - m) - (q - m) * (f - k)) / r;
- k = f + m * (h - f);
- m = g + m * (a - g);
- if (k < cc.kmMin(c.x, d.x) - cc.kmEpsilon || k > cc.kmMax(c.x, d.x) + cc.kmEpsilon || m < cc.kmMin(c.y, d.y) - cc.kmEpsilon || m > cc.kmMax(c.y, d.y) + cc.kmEpsilon || k < cc.kmMin(f, h) - cc.kmEpsilon || k > cc.kmMax(f, h) + cc.kmEpsilon || m < cc.kmMin(g, a) - cc.kmEpsilon || m > cc.kmMax(g, a) + cc.kmEpsilon) return cc.KM_FALSE;
- e.x = k;
- e.y = m;
- return cc.KM_TRUE
- };
- cc.calculate_line_normal = function(a, c, d) {
- var e = new cc.kmVec2;
- cc.kmVec2Subtract(e, c, a);
- d.x = -e.y;
- d.y = e.x;
- cc.kmVec2Normalize(d, d)
- };
- cc.kmRay2IntersectTriangle = function(a, c, d, e, f, g) {
- var h = new cc.kmVec2,
- k = new cc.kmVec2,
- m = new cc.kmVec2,
- n = 1E4,
- q = cc.KM_FALSE,
- r;
- cc.kmRay2IntersectLineSegment(a, c, d, h) && (r = new cc.kmVec2, q = cc.KM_TRUE, r = cc.kmVec2Length(cc.kmVec2Subtract(r, h, a.start)), r < n && (k.x = h.x, k.y = h.y, n = r, cc.calculate_line_normal(c, d, m)));
- cc.kmRay2IntersectLineSegment(a, d, e, h) && (r = new cc.kmVec2, q = cc.KM_TRUE, r = cc.kmVec2Length(cc.kmVec2Subtract(r, h, a.start)), r < n && (k.x = h.x, k.y = h.y, n = r, cc.calculate_line_normal(d, e, m)));
- cc.kmRay2IntersectLineSegment(a, e, c, h) && (r = new cc.kmVec2, q = cc.KM_TRUE, r = cc.kmVec2Length(cc.kmVec2Subtract(r, h, a.start)), r < n && (k.x = h.x, k.y = h.y, cc.calculate_line_normal(e, c, m)));
- q && (f.x = k.x, f.y = k.y, g && (g.x = m.x, g.y = m.y));
- return q
- };
- cc.kmRay2IntersectCircle = function(a, c, d, e) {
- cc.log("cc.kmRay2IntersectCircle() has not been implemented.")
- };
- var Float32Array = Float32Array || Array;
- cc.kmMat3 = function() {
- this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0])
- };
- cc.kmMat3Fill = function(a, c) {
- for (var d = 0; 9 > d; d++) a.mat[d] = c;
- return a
- };
- cc.kmMat3Adjugate = function(a, c) {
- a.mat[0] = c.mat[4] * c.mat[8] - c.mat[5] * c.mat[7];
- a.mat[1] = c.mat[2] * c.mat[7] - c.mat[1] * c.mat[8];
- a.mat[2] = c.mat[1] * c.mat[5] - c.mat[2] * c.mat[4];
- a.mat[3] = c.mat[5] * c.mat[6] - c.mat[3] * c.mat[8];
- a.mat[4] = c.mat[0] * c.mat[8] - c.mat[2] * c.mat[6];
- a.mat[5] = c.mat[2] * c.mat[3] - c.mat[0] * c.mat[5];
- a.mat[6] = c.mat[3] * c.mat[7] - c.mat[4] * c.mat[6];
- a.mat[8] = c.mat[0] * c.mat[4] - c.mat[1] * c.mat[3];
- return a
- };
- cc.kmMat3Identity = function(a) {
- a.mat[1] = a.mat[2] = a.mat[3] = a.mat[5] = a.mat[6] = a.mat[7] = 0;
- a.mat[0] = a.mat[4] = a.mat[8] = 1;
- return a
- };
- cc.kmMat3Inverse = function(a, c, d) {
- var e = new cc.kmMat3;
- if (0 === c) return null;
- c = 1 / c;
- cc.kmMat3Adjugate(e, d);
- cc.kmMat3ScalarMultiply(a, e, c);
- return a
- };
- cc.kmMat3._identity = new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
- cc.kmMat3IsIdentity = function(a) {
- for (var c = 0; 9 > c; c++)
- if (cc.kmMat3._identity[c] !== a.mat[c]) return !1;
- return !0
- };
- cc.kmMat3Transpose = function(a, c) {
- var d, e;
- for (d = 0; 3 > d; ++d)
- for (e = 0; 3 > e; ++e) a.mat[3 * d + e] = c.mat[3 * e + d];
- return a
- };
- cc.kmMat3Determinant = function(a) {
- var c;
- c = a.mat[0] * a.mat[4] * a.mat[8] + a.mat[1] * a.mat[5] * a.mat[6] + a.mat[2] * a.mat[3] * a.mat[7];
- return c -= a.mat[2] * a.mat[4] * a.mat[6] + a.mat[0] * a.mat[5] * a.mat[7] + a.mat[1] * a.mat[3] * a.mat[8]
- };
- cc.kmMat3Multiply = function(a, c, d) {
- c = c.mat;
- d = d.mat;
- a.mat[0] = c[0] * d[0] + c[3] * d[1] + c[6] * d[2];
- a.mat[1] = c[1] * d[0] + c[4] * d[1] + c[7] * d[2];
- a.mat[2] = c[2] * d[0] + c[5] * d[1] + c[8] * d[2];
- a.mat[3] = c[0] * d[3] + c[3] * d[4] + c[6] * d[5];
- a.mat[4] = c[1] * d[3] + c[4] * d[4] + c[7] * d[5];
- a.mat[5] = c[2] * d[3] + c[5] * d[4] + c[8] * d[5];
- a.mat[6] = c[0] * d[6] + c[3] * d[7] + c[6] * d[8];
- a.mat[7] = c[1] * d[6] + c[4] * d[7] + c[7] * d[8];
- a.mat[8] = c[2] * d[6] + c[5] * d[7] + c[8] * d[8];
- return a
- };
- cc.kmMat3ScalarMultiply = function(a, c, d) {
- for (var e = 0; 9 > e; e++) a.mat[e] = c.mat[e] * d;
- return a
- };
- cc.kmMat3RotationAxisAngle = function(a, c, d) {
- var e = Math.cos(d);
- d = Math.sin(d);
- a.mat[0] = e + c.x * c.x * (1 - e);
- a.mat[1] = c.z * d + c.y * c.x * (1 - e);
- a.mat[2] = -c.y * d + c.z * c.x * (1 - e);
- a.mat[3] = -c.z * d + c.x * c.y * (1 - e);
- a.mat[4] = e + c.y * c.y * (1 - e);
- a.mat[5] = c.x * d + c.z * c.y * (1 - e);
- a.mat[6] = c.y * d + c.x * c.z * (1 - e);
- a.mat[7] = -c.x * d + c.y * c.z * (1 - e);
- a.mat[8] = e + c.z * c.z * (1 - e);
- return a
- };
- cc.kmMat3Assign = function(a, c) {
- if (a == c) return cc.log("cc.kmMat3Assign(): pOut equals pIn"), a;
- for (var d = 0; 9 > d; d++) a.mat[d] = c.mat[d];
- return a
- };
- cc.kmMat3AreEqual = function(a, c) {
- if (a == c) return !0;
- for (var d = 0; 9 > d; ++d)
- if (!(a.mat[d] + cc.kmEpsilon > c.mat[d] && a.mat[d] - cc.kmEpsilon < c.mat[d])) return !1;
- return !0
- };
- cc.kmMat3RotationX = function(a, c) {
- a.mat[0] = 1;
- a.mat[1] = 0;
- a.mat[2] = 0;
- a.mat[3] = 0;
- a.mat[4] = Math.cos(c);
- a.mat[5] = Math.sin(c);
- a.mat[6] = 0;
- a.mat[7] = -Math.sin(c);
- a.mat[8] = Math.cos(c);
- return a
- };
- cc.kmMat3RotationY = function(a, c) {
- a.mat[0] = Math.cos(c);
- a.mat[1] = 0;
- a.mat[2] = -Math.sin(c);
- a.mat[3] = 0;
- a.mat[4] = 1;
- a.mat[5] = 0;
- a.mat[6] = Math.sin(c);
- a.mat[7] = 0;
- a.mat[8] = Math.cos(c);
- return a
- };
- cc.kmMat3RotationZ = function(a, c) {
- a.mat[0] = Math.cos(c);
- a.mat[1] = -Math.sin(c);
- a.mat[2] = 0;
- a.mat[3] = Math.sin(c);
- a.mat[4] = Math.cos(c);
- a.mat[5] = 0;
- a.mat[6] = 0;
- a.mat[7] = 0;
- a.mat[8] = 1;
- return a
- };
- cc.kmMat3Rotation = function(a, c) {
- a.mat[0] = Math.cos(c);
- a.mat[1] = Math.sin(c);
- a.mat[2] = 0;
- a.mat[3] = -Math.sin(c);
- a.mat[4] = Math.cos(c);
- a.mat[5] = 0;
- a.mat[6] = 0;
- a.mat[7] = 0;
- a.mat[8] = 1;
- return a
- };
- cc.kmMat3Scaling = function(a, c, d) {
- cc.kmMat3Identity(a);
- a.mat[0] = c;
- a.mat[4] = d;
- return a
- };
- cc.kmMat3Translation = function(a, c, d) {
- cc.kmMat3Identity(a);
- a.mat[6] = c;
- a.mat[7] = d;
- return a
- };
- cc.kmMat3RotationQuaternion = function(a, c) {
- if (!c || !a) return null;
- a.mat[0] = 1 - 2 * (c.y * c.y + c.z * c.z);
- a.mat[1] = 2 * (c.x * c.y - c.w * c.z);
- a.mat[2] = 2 * (c.x * c.z + c.w * c.y);
- a.mat[3] = 2 * (c.x * c.y + c.w * c.z);
- a.mat[4] = 1 - 2 * (c.x * c.x + c.z * c.z);
- a.mat[5] = 2 * (c.y * c.z - c.w * c.x);
- a.mat[6] = 2 * (c.x * c.z - c.w * c.y);
- a.mat[7] = 2 * (c.y * c.z + c.w * c.x);
- a.mat[8] = 1 - 2 * (c.x * c.x + c.y * c.y);
- return a
- };
- cc.kmMat3RotationToAxisAngle = function(a, c, d) {
- cc.kmQuaternionRotationMatrix(void 0, d);
- cc.kmQuaternionToAxisAngle(void 0, a, c);
- return a
- };
- cc.kmMat4 = function() {
- this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- };
- cc.kmMat4Fill = function(a, c) {
- a.mat[0] = a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[5] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[10] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = a.mat[15] = c
- };
- cc.kmMat4Identity = function(a) {
- a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = 0;
- a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
- return a
- };
- cc.kmMat4._get = function(a, c, d) {
- return a.mat[c + 4 * d]
- };
- cc.kmMat4._set = function(a, c, d, e) {
- a.mat[c + 4 * d] = e
- };
- cc.kmMat4._swap = function(a, c, d, e, f) {
- var g = cc.kmMat4._get(a, c, d);
- cc.kmMat4._set(a, c, d, cc.kmMat4._get(a, e, f));
- cc.kmMat4._set(a, e, f, g)
- };
- cc.kmMat4._gaussj = function(a, c) {
- var d, e = 0,
- f = 0,
- g, h, k, m = [0, 0, 0, 0],
- n = [0, 0, 0, 0],
- q = [0, 0, 0, 0];
- for (d = 0; 4 > d; d++) {
- for (g = k = 0; 4 > g; g++)
- if (1 != q[g])
- for (h = 0; 4 > h; h++) 0 == q[h] && Math.abs(cc.kmMat4._get(a, g, h)) >= k && (k = Math.abs(cc.kmMat4._get(a, g, h)), f = g, e = h);
- ++q[e];
- if (f != e) {
- for (g = 0; 4 > g; g++) cc.kmMat4._swap(a, f, g, e, g);
- for (g = 0; 4 > g; g++) cc.kmMat4._swap(c, f, g, e, g)
- }
- n[d] = f;
- m[d] = e;
- if (0 == cc.kmMat4._get(a, e, e)) return cc.KM_FALSE;
- h = 1 / cc.kmMat4._get(a, e, e);
- cc.kmMat4._set(a, e, e, 1);
- for (g = 0; 4 > g; g++) cc.kmMat4._set(a, e, g, cc.kmMat4._get(a, e, g) * h);
- for (g = 0; 4 > g; g++) cc.kmMat4._set(c, e, g, cc.kmMat4._get(c, e, g) * h);
- for (h = 0; 4 > h; h++)
- if (h != e) {
- k = cc.kmMat4._get(a, h, e);
- cc.kmMat4._set(a, h, e, 0);
- for (g = 0; 4 > g; g++) cc.kmMat4._set(a, h, g, cc.kmMat4._get(a, h, g) - cc.kmMat4._get(a, e, g) * k);
- for (g = 0; 4 > g; g++) cc.kmMat4._set(c, h, g, cc.kmMat4._get(a, h, g) - cc.kmMat4._get(c, e, g) * k)
- }
- }
- for (g = 3; 0 <= g; g--)
- if (n[g] != m[g])
- for (h = 0; 4 > h; h++) cc.kmMat4._swap(a, h, n[g], h, m[g]);
- return cc.KM_TRUE
- };
- cc.kmMat4._identity = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
- cc.kmMat4Inverse = function(a, c) {
- var d = new cc.kmMat4,
- e = new cc.kmMat4;
- cc.kmMat4Assign(d, c);
- cc.kmMat4Identity(e);
- if (cc.kmMat4._gaussj(d, e) == cc.KM_FALSE) return null;
- cc.kmMat4Assign(a, d);
- return a
- };
- cc.kmMat4IsIdentity = function(a) {
- for (var c = 0; 16 > c; c++)
- if (cc.kmMat4._identity[c] != a.mat[c]) return !1;
- return !0
- };
- cc.kmMat4Transpose = function(a, c) {
- var d, e, f = a.mat,
- g = c.mat;
- for (e = 0; 4 > e; ++e)
- for (d = 0; 4 > d; ++d) f[4 * e + d] = g[4 * d + e];
- return a
- };
- cc.kmMat4Multiply = function(a, c, d) {
- var e = a.mat,
- f = c.mat[0],
- g = c.mat[1],
- h = c.mat[2],
- k = c.mat[3],
- m = c.mat[4],
- n = c.mat[5],
- q = c.mat[6],
- r = c.mat[7],
- t = c.mat[8],
- s = c.mat[9],
- v = c.mat[10],
- u = c.mat[11],
- x = c.mat[12],
- A = c.mat[13],
- D = c.mat[14];
- c = c.mat[15];
- var F = d.mat[0],
- y = d.mat[1],
- z = d.mat[2],
- C = d.mat[3],
- w = d.mat[4],
- B = d.mat[5],
- G = d.mat[6],
- H = d.mat[7],
- E = d.mat[8],
- K = d.mat[9],
- M = d.mat[10],
- L = d.mat[11],
- N = d.mat[12],
- I = d.mat[13],
- J = d.mat[14];
- d = d.mat[15];
- e[0] = F * f + y * m + z * t + C * x;
- e[1] = F * g + y * n + z * s + C * A;
- e[2] = F * h + y * q + z * v + C * D;
- e[3] = F * k + y * r + z * u + C * c;
- e[4] = w * f + B * m + G * t + H * x;
- e[5] = w * g + B * n + G * s + H * A;
- e[6] = w * h + B * q + G * v + H * D;
- e[7] = w * k + B * r + G * u + H * c;
- e[8] = E * f + K * m + M * t + L * x;
- e[9] = E * g + K * n + M * s + L * A;
- e[10] = E * h + K * q + M * v + L * D;
- e[11] = E * k + K * r + M * u + L * c;
- e[12] = N * f + I * m + J * t + d * x;
- e[13] = N * g + I * n + J * s + d * A;
- e[14] = N * h + I * q + J * v + d * D;
- e[15] = N * k + I * r + J * u + d * c;
- return a
- };
- cc.getMat4MultiplyValue = function(a, c) {
- var d = a.mat,
- e = c.mat,
- f = new Float32Array(16);
- f[0] = d[0] * e[0] + d[4] * e[1] + d[8] * e[2] + d[12] * e[3];
- f[1] = d[1] * e[0] + d[5] * e[1] + d[9] * e[2] + d[13] * e[3];
- f[2] = d[2] * e[0] + d[6] * e[1] + d[10] * e[2] + d[14] * e[3];
- f[3] = d[3] * e[0] + d[7] * e[1] + d[11] * e[2] + d[15] * e[3];
- f[4] = d[0] * e[4] + d[4] * e[5] + d[8] * e[6] + d[12] * e[7];
- f[5] = d[1] * e[4] + d[5] * e[5] + d[9] * e[6] + d[13] * e[7];
- f[6] = d[2] * e[4] + d[6] * e[5] + d[10] * e[6] + d[14] * e[7];
- f[7] = d[3] * e[4] + d[7] * e[5] + d[11] * e[6] + d[15] * e[7];
- f[8] = d[0] * e[8] + d[4] * e[9] + d[8] * e[10] + d[12] * e[11];
- f[9] = d[1] * e[8] + d[5] * e[9] + d[9] * e[10] + d[13] * e[11];
- f[10] = d[2] * e[8] + d[6] * e[9] + d[10] * e[10] + d[14] * e[11];
- f[11] = d[3] * e[8] + d[7] * e[9] + d[11] * e[10] + d[15] * e[11];
- f[12] = d[0] * e[12] + d[4] * e[13] + d[8] * e[14] + d[12] * e[15];
- f[13] = d[1] * e[12] + d[5] * e[13] + d[9] * e[14] + d[13] * e[15];
- f[14] = d[2] * e[12] + d[6] * e[13] + d[10] * e[14] + d[14] * e[15];
- f[15] = d[3] * e[12] + d[7] * e[13] + d[11] * e[14] + d[15] * e[15];
- return f
- };
- cc.getMat4MultiplyWithMat4 = function(a, c, d) {
- a = a.mat;
- c = c.mat;
- var e = d.mat;
- e[0] = a[0] * c[0] + a[4] * c[1] + a[8] * c[2] + a[12] * c[3];
- e[1] = a[1] * c[0] + a[5] * c[1] + a[9] * c[2] + a[13] * c[3];
- e[2] = a[2] * c[0] + a[6] * c[1] + a[10] * c[2] + a[14] * c[3];
- e[3] = a[3] * c[0] + a[7] * c[1] + a[11] * c[2] + a[15] * c[3];
- e[4] = a[0] * c[4] + a[4] * c[5] + a[8] * c[6] + a[12] * c[7];
- e[5] = a[1] * c[4] + a[5] * c[5] + a[9] * c[6] + a[13] * c[7];
- e[6] = a[2] * c[4] + a[6] * c[5] + a[10] * c[6] + a[14] * c[7];
- e[7] = a[3] * c[4] + a[7] * c[5] + a[11] * c[6] + a[15] * c[7];
- e[8] = a[0] * c[8] + a[4] * c[9] + a[8] * c[10] + a[12] * c[11];
- e[9] = a[1] * c[8] + a[5] * c[9] + a[9] * c[10] + a[13] * c[11];
- e[10] = a[2] * c[8] + a[6] * c[9] + a[10] * c[10] + a[14] * c[11];
- e[11] = a[3] * c[8] + a[7] * c[9] + a[11] * c[10] + a[15] * c[11];
- e[12] = a[0] * c[12] + a[4] * c[13] + a[8] * c[14] + a[12] * c[15];
- e[13] = a[1] * c[12] + a[5] * c[13] + a[9] * c[14] + a[13] * c[15];
- e[14] = a[2] * c[12] + a[6] * c[13] + a[10] * c[14] + a[14] * c[15];
- e[15] = a[3] * c[12] + a[7] * c[13] + a[11] * c[14] + a[15] * c[15];
- return d.mat
- };
- cc.kmMat4Assign = function(a, c) {
- if (a == c) return cc.log("cc.kmMat4Assign(): pOut equals pIn"), a;
- var d = a.mat,
- e = c.mat;
- d[0] = e[0];
- d[1] = e[1];
- d[2] = e[2];
- d[3] = e[3];
- d[4] = e[4];
- d[5] = e[5];
- d[6] = e[6];
- d[7] = e[7];
- d[8] = e[8];
- d[9] = e[9];
- d[10] = e[10];
- d[11] = e[11];
- d[12] = e[12];
- d[13] = e[13];
- d[14] = e[14];
- d[15] = e[15];
- return a
- };
- cc.kmMat4AreEqual = function(a, c) {
- if (a == c) return cc.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."), !0;
- for (var d = 0; 16 > d; d++)
- if (!(a.mat[d] + cc.kmEpsilon > c.mat[d] && a.mat[d] - cc.kmEpsilon < c.mat[d])) return !1;
- return !0
- };
- cc.kmMat4RotationX = function(a, c) {
- a.mat[0] = 1;
- a.mat[1] = 0;
- a.mat[2] = 0;
- a.mat[3] = 0;
- a.mat[4] = 0;
- a.mat[5] = Math.cos(c);
- a.mat[6] = Math.sin(c);
- a.mat[7] = 0;
- a.mat[8] = 0;
- a.mat[9] = -Math.sin(c);
- a.mat[10] = Math.cos(c);
- a.mat[11] = 0;
- a.mat[12] = 0;
- a.mat[13] = 0;
- a.mat[14] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4RotationY = function(a, c) {
- a.mat[0] = Math.cos(c);
- a.mat[1] = 0;
- a.mat[2] = -Math.sin(c);
- a.mat[3] = 0;
- a.mat[4] = 0;
- a.mat[5] = 1;
- a.mat[6] = 0;
- a.mat[7] = 0;
- a.mat[8] = Math.sin(c);
- a.mat[9] = 0;
- a.mat[10] = Math.cos(c);
- a.mat[11] = 0;
- a.mat[12] = 0;
- a.mat[13] = 0;
- a.mat[14] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4RotationZ = function(a, c) {
- a.mat[0] = Math.cos(c);
- a.mat[1] = Math.sin(c);
- a.mat[2] = 0;
- a.mat[3] = 0;
- a.mat[4] = -Math.sin(c);
- a.mat[5] = Math.cos(c);
- a.mat[6] = 0;
- a.mat[7] = 0;
- a.mat[8] = 0;
- a.mat[9] = 0;
- a.mat[10] = 1;
- a.mat[11] = 0;
- a.mat[12] = 0;
- a.mat[13] = 0;
- a.mat[14] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4RotationPitchYawRoll = function(a, c, d, e) {
- var f = Math.cos(c);
- c = Math.sin(c);
- var g = Math.cos(d);
- d = Math.sin(d);
- var h = Math.cos(e);
- e = Math.sin(e);
- var k = c * d,
- m = f * d;
- a.mat[0] = g * h;
- a.mat[4] = g * e;
- a.mat[8] = -d;
- a.mat[1] = k * h - f * e;
- a.mat[5] = k * e + f * h;
- a.mat[9] = c * g;
- a.mat[2] = m * h + c * e;
- a.mat[6] = m * e - c * h;
- a.mat[10] = f * g;
- a.mat[3] = a.mat[7] = a.mat[11] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4RotationQuaternion = function(a, c) {
- a.mat[0] = 1 - 2 * (c.y * c.y + c.z * c.z);
- a.mat[1] = 2 * (c.x * c.y + c.z * c.w);
- a.mat[2] = 2 * (c.x * c.z - c.y * c.w);
- a.mat[3] = 0;
- a.mat[4] = 2 * (c.x * c.y - c.z * c.w);
- a.mat[5] = 1 - 2 * (c.x * c.x + c.z * c.z);
- a.mat[6] = 2 * (c.z * c.y + c.x * c.w);
- a.mat[7] = 0;
- a.mat[8] = 2 * (c.x * c.z + c.y * c.w);
- a.mat[9] = 2 * (c.y * c.z - c.x * c.w);
- a.mat[10] = 1 - 2 * (c.x * c.x + c.y * c.y);
- a.mat[11] = 0;
- a.mat[12] = 0;
- a.mat[13] = 0;
- a.mat[14] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4RotationTranslation = function(a, c, d) {
- a.mat[0] = c.mat[0];
- a.mat[1] = c.mat[1];
- a.mat[2] = c.mat[2];
- a.mat[3] = 0;
- a.mat[4] = c.mat[3];
- a.mat[5] = c.mat[4];
- a.mat[6] = c.mat[5];
- a.mat[7] = 0;
- a.mat[8] = c.mat[6];
- a.mat[9] = c.mat[7];
- a.mat[10] = c.mat[8];
- a.mat[11] = 0;
- a.mat[12] = d.x;
- a.mat[13] = d.y;
- a.mat[14] = d.z;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4Scaling = function(a, c, d, e) {
- a.mat[0] = c;
- a.mat[5] = d;
- a.mat[10] = e;
- a.mat[15] = 1;
- a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = 0;
- return a
- };
- cc.kmMat4Translation = function(a, c, d, e) {
- a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
- a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = 0;
- a.mat[12] = c;
- a.mat[13] = d;
- a.mat[14] = e;
- return a
- };
- cc.kmMat4GetUpVec3 = function(a, c) {
- a.x = c.mat[4];
- a.y = c.mat[5];
- a.z = c.mat[6];
- cc.kmVec3Normalize(a, a);
- return a
- };
- cc.kmMat4GetRightVec3 = function(a, c) {
- a.x = c.mat[0];
- a.y = c.mat[1];
- a.z = c.mat[2];
- cc.kmVec3Normalize(a, a);
- return a
- };
- cc.kmMat4GetForwardVec3 = function(a, c) {
- a.x = c.mat[8];
- a.y = c.mat[9];
- a.z = c.mat[10];
- cc.kmVec3Normalize(a, a);
- return a
- };
- cc.kmMat4PerspectiveProjection = function(a, c, d, e, f) {
- var g = cc.kmDegreesToRadians(c / 2);
- c = f - e;
- var h = Math.sin(g);
- if (0 == c || 0 == h || 0 == d) return null;
- g = Math.cos(g) / h;
- cc.kmMat4Identity(a);
- a.mat[0] = g / d;
- a.mat[5] = g;
- a.mat[10] = -(f + e) / c;
- a.mat[11] = -1;
- a.mat[14] = -2 * e * f / c;
- a.mat[15] = 0;
- return a
- };
- cc.kmMat4OrthographicProjection = function(a, c, d, e, f, g, h) {
- cc.kmMat4Identity(a);
- a.mat[0] = 2 / (d - c);
- a.mat[5] = 2 / (f - e);
- a.mat[10] = -2 / (h - g);
- a.mat[12] = -((d + c) / (d - c));
- a.mat[13] = -((f + e) / (f - e));
- a.mat[14] = -((h + g) / (h - g));
- return a
- };
- cc.kmMat4LookAt = function(a, c, d, e) {
- var f = new cc.kmVec3,
- g = new cc.kmVec3,
- h = new cc.kmVec3,
- k = new cc.kmVec3,
- m = new cc.kmMat4;
- cc.kmVec3Subtract(f, d, c);
- cc.kmVec3Normalize(f, f);
- cc.kmVec3Assign(g, e);
- cc.kmVec3Normalize(g, g);
- cc.kmVec3Cross(h, f, g);
- cc.kmVec3Normalize(h, h);
- cc.kmVec3Cross(k, h, f);
- cc.kmVec3Normalize(h, h);
- cc.kmMat4Identity(a);
- a.mat[0] = h.x;
- a.mat[4] = h.y;
- a.mat[8] = h.z;
- a.mat[1] = k.x;
- a.mat[5] = k.y;
- a.mat[9] = k.z;
- a.mat[2] = -f.x;
- a.mat[6] = -f.y;
- a.mat[10] = -f.z;
- cc.kmMat4Translation(m, -c.x, -c.y, -c.z);
- cc.kmMat4Multiply(a, a, m);
- return a
- };
- cc.kmMat4RotationAxisAngle = function(a, c, d) {
- var e = Math.cos(d);
- d = Math.sin(d);
- var f = new cc.kmVec3;
- cc.kmVec3Normalize(f, c);
- a.mat[0] = e + f.x * f.x * (1 - e);
- a.mat[1] = f.z * d + f.y * f.x * (1 - e);
- a.mat[2] = -f.y * d + f.z * f.x * (1 - e);
- a.mat[3] = 0;
- a.mat[4] = -f.z * d + f.x * f.y * (1 - e);
- a.mat[5] = e + f.y * f.y * (1 - e);
- a.mat[6] = f.x * d + f.z * f.y * (1 - e);
- a.mat[7] = 0;
- a.mat[8] = f.y * d + f.x * f.z * (1 - e);
- a.mat[9] = -f.x * d + f.y * f.z * (1 - e);
- a.mat[10] = e + f.z * f.z * (1 - e);
- a.mat[11] = 0;
- a.mat[12] = 0;
- a.mat[13] = 0;
- a.mat[14] = 0;
- a.mat[15] = 1;
- return a
- };
- cc.kmMat4ExtractRotation = function(a, c) {
- a.mat[0] = c.mat[0];
- a.mat[1] = c.mat[1];
- a.mat[2] = c.mat[2];
- a.mat[3] = c.mat[4];
- a.mat[4] = c.mat[5];
- a.mat[5] = c.mat[6];
- a.mat[6] = c.mat[8];
- a.mat[7] = c.mat[9];
- a.mat[8] = c.mat[10];
- return a
- };
- cc.kmMat4ExtractPlane = function(a, c, d) {
- switch (d) {
- case cc.KM_PLANE_RIGHT:
- a.a = c.mat[3] - c.mat[0];
- a.b = c.mat[7] - c.mat[4];
- a.c = c.mat[11] - c.mat[8];
- a.d = c.mat[15] - c.mat[12];
- break;
- case cc.KM_PLANE_LEFT:
- a.a = c.mat[3] + c.mat[0];
- a.b = c.mat[7] + c.mat[4];
- a.c = c.mat[11] + c.mat[8];
- a.d = c.mat[15] + c.mat[12];
- break;
- case cc.KM_PLANE_BOTTOM:
- a.a = c.mat[3] + c.mat[1];
- a.b = c.mat[7] + c.mat[5];
- a.c = c.mat[11] + c.mat[9];
- a.d = c.mat[15] + c.mat[13];
- break;
- case cc.KM_PLANE_TOP:
- a.a = c.mat[3] - c.mat[1];
- a.b = c.mat[7] - c.mat[5];
- a.c = c.mat[11] - c.mat[9];
- a.d = c.mat[15] - c.mat[13];
- break;
- case cc.KM_PLANE_FAR:
- a.a = c.mat[3] - c.mat[2];
- a.b = c.mat[7] - c.mat[6];
- a.c = c.mat[11] - c.mat[10];
- a.d = c.mat[15] - c.mat[14];
- break;
- case cc.KM_PLANE_NEAR:
- a.a = c.mat[3] + c.mat[2];
- a.b = c.mat[7] + c.mat[6];
- a.c = c.mat[11] + c.mat[10];
- a.d = c.mat[15] + c.mat[14];
- break;
- default:
- cc.log("cc.kmMat4ExtractPlane(): Invalid plane index")
- }
- c = Math.sqrt(a.a * a.a + a.b * a.b + a.c * a.c);
- a.a /= c;
- a.b /= c;
- a.c /= c;
- a.d /= c;
- return a
- };
- cc.kmMat4RotationToAxisAngle = function(a, c, d) {
- var e = new cc.kmQuaternion,
- f = new cc.kmMat3;
- cc.kmMat4ExtractRotation(f, d);
- cc.kmQuaternionRotationMatrix(e, f);
- cc.kmQuaternionToAxisAngle(e, a, c);
- return a
- };
- cc.KM_PLANE_LEFT = 0;
- cc.KM_PLANE_RIGHT = 1;
- cc.KM_PLANE_BOTTOM = 2;
- cc.KM_PLANE_TOP = 3;
- cc.KM_PLANE_NEAR = 4;
- cc.KM_PLANE_FAR = 5;
- cc.kmPlane = function(a, c, d, e) {
- this.a = a || 0;
- this.b = c || 0;
- this.c = d || 0;
- this.d = e || 0
- };
- cc.POINT_INFRONT_OF_PLANE = 0;
- cc.POINT_BEHIND_PLANE = 1;
- cc.POINT_ON_PLANE = 2;
- cc.kmPlaneDot = function(a, c) {
- return a.a * c.x + a.b * c.y + a.c * c.z + a.d * c.w
- };
- cc.kmPlaneDotCoord = function(a, c) {
- return a.a * c.x + a.b * c.y + a.c * c.z + a.d
- };
- cc.kmPlaneDotNormal = function(a, c) {
- return a.a * c.x + a.b * c.y + a.c * c.z
- };
- cc.kmPlaneFromPointNormal = function(a, c, d) {
- a.a = d.x;
- a.b = d.y;
- a.c = d.z;
- a.d = -cc.kmVec3Dot(d, c);
- return a
- };
- cc.kmPlaneFromPoints = function(a, c, d, e) {
- var f = new cc.kmVec3,
- g = new cc.kmVec3,
- h = new cc.kmVec3;
- cc.kmVec3Subtract(g, d, c);
- cc.kmVec3Subtract(h, e, c);
- cc.kmVec3Cross(f, g, h);
- cc.kmVec3Normalize(f, f);
- a.a = f.x;
- a.b = f.y;
- a.c = f.z;
- a.d = cc.kmVec3Dot(cc.kmVec3Scale(f, f, -1), c);
- return a
- };
- cc.kmPlaneIntersectLine = function(a, c, d, e) {
- throw "cc.kmPlaneIntersectLine() hasn't been implemented.";
- };
- cc.kmPlaneNormalize = function(a, c) {
- var d = new cc.kmVec3;
- d.x = c.a;
- d.y = c.b;
- d.z = c.c;
- var e = 1 / cc.kmVec3Length(d);
- cc.kmVec3Normalize(d, d);
- a.a = d.x;
- a.b = d.y;
- a.c = d.z;
- a.d = c.d * e;
- return a
- };
- cc.kmPlaneScale = function(a, c, d) {
- cc.log("cc.kmPlaneScale() has not been implemented.")
- };
- cc.kmPlaneClassifyPoint = function(a, c) {
- var d = a.a * c.x + a.b * c.y + a.c * c.z + a.d;
- return 0.0010 < d ? cc.POINT_INFRONT_OF_PLANE : -0.0010 > d ? cc.POINT_BEHIND_PLANE : cc.POINT_ON_PLANE
- };
- cc.kmQuaternion = function(a, c, d, e) {
- this.x = a || 0;
- this.y = c || 0;
- this.z = d || 0;
- this.w = e || 0
- };
- cc.kmQuaternionConjugate = function(a, c) {
- a.x = -c.x;
- a.y = -c.y;
- a.z = -c.z;
- a.w = c.w;
- return a
- };
- cc.kmQuaternionDot = function(a, c) {
- return a.w * c.w + a.x * c.x + a.y * c.y + a.z * c.z
- };
- cc.kmQuaternionExp = function(a, c) {
- return a
- };
- cc.kmQuaternionIdentity = function(a) {
- a.x = 0;
- a.y = 0;
- a.z = 0;
- a.w = 1;
- return a
- };
- cc.kmQuaternionInverse = function(a, c) {
- var d = cc.kmQuaternionLength(c),
- e = new cc.kmQuaternion;
- if (Math.abs(d) > cc.kmEpsilon) return a.x = 0, a.y = 0, a.z = 0, a.w = 0, a;
- cc.kmQuaternionScale(a, cc.kmQuaternionConjugate(e, c), 1 / d);
- return a
- };
- cc.kmQuaternionIsIdentity = function(a) {
- return 0 == a.x && 0 == a.y && 0 == a.z && 1 == a.w
- };
- cc.kmQuaternionLength = function(a) {
- return Math.sqrt(cc.kmQuaternionLengthSq(a))
- };
- cc.kmQuaternionLengthSq = function(a) {
- return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w
- };
- cc.kmQuaternionLn = function(a, c) {
- return a
- };
- cc.kmQuaternionMultiply = function(a, c, d) {
- a.w = c.w * d.w - c.x * d.x - c.y * d.y - c.z * d.z;
- a.x = c.w * d.x + c.x * d.w + c.y * d.z - c.z * d.y;
- a.y = c.w * d.y + c.y * d.w + c.z * d.x - c.x * d.z;
- a.z = c.w * d.z + c.z * d.w + c.x * d.y - c.y * d.x;
- return a
- };
- cc.kmQuaternionNormalize = function(a, c) {
- var d = cc.kmQuaternionLength(c);
- if (Math.abs(d) <= cc.kmEpsilon) throw "cc.kmQuaternionNormalize(): pIn is an invalid value";
- cc.kmQuaternionScale(a, c, 1 / d);
- return a
- };
- cc.kmQuaternionRotationAxis = function(a, c, d) {
- d *= 0.5;
- var e = Math.sin(d);
- a.w = Math.cos(d);
- a.x = c.x * e;
- a.y = c.y * e;
- a.z = c.z * e;
- return a
- };
- cc.kmQuaternionRotationMatrix = function(a, c) {
- var d, e, f, g;
- d = [];
- e = g = 0;
- if (!c) return null;
- d[0] = c.mat[0];
- d[1] = c.mat[3];
- d[2] = c.mat[6];
- d[4] = c.mat[1];
- d[5] = c.mat[4];
- d[6] = c.mat[7];
- d[8] = c.mat[2];
- d[9] = c.mat[5];
- d[10] = c.mat[8];
- d[15] = 1;
- var h = d[0];
- e = h[0] + h[5] + h[10] + 1;
- e > cc.kmEpsilon ? (g = 2 * Math.sqrt(e), d = (h[9] - h[6]) / g, e = (h[2] - h[8]) / g, f = (h[4] - h[1]) / g, g *= 0.25) : h[0] > h[5] && h[0] > h[10] ? (g = 2 * Math.sqrt(1 + h[0] - h[5] - h[10]), d = 0.25 * g, e = (h[4] + h[1]) / g, f = (h[2] + h[8]) / g, g = (h[9] - h[6]) / g) : h[5] > h[10] ? (g = 2 * Math.sqrt(1 + h[5] - h[0] - h[10]), d = (h[4] + h[1]) / g, e = 0.25 * g, f = (h[9] + h[6]) / g, g = (h[2] - h[8]) / g) : (g = 2 * Math.sqrt(1 + h[10] - h[0] - h[5]), d = (h[2] + h[8]) / g, e = (h[9] + h[6]) / g, f = 0.25 * g, g = (h[4] - h[1]) / g);
- a.x = d;
- a.y = e;
- a.z = f;
- a.w = g;
- return a
- };
- cc.kmQuaternionRotationYawPitchRoll = function(a, c, d, e) {
- var f, g, h, k, m;
- f = cc.kmDegreesToRadians(d) / 2;
- g = cc.kmDegreesToRadians(c) / 2;
- h = cc.kmDegreesToRadians(e) / 2;
- e = Math.cos(f);
- c = Math.cos(g);
- d = Math.cos(h);
- f = Math.sin(f);
- g = Math.sin(g);
- h = Math.sin(h);
- k = c * d;
- m = g * h;
- a.w = e * k + f * m;
- a.x = f * k - e * m;
- a.y = e * g * d + f * c * h;
- a.z = e * c * h - f * g * d;
- cc.kmQuaternionNormalize(a, a);
- return a
- };
- cc.kmQuaternionSlerp = function(a, c, d, e) {
- if (c.x == d.x && c.y == d.y && c.z == d.z && c.w == d.w) return a.x = c.x, a.y = c.y, a.z = c.z, a.w = c.w, a;
- var f = cc.kmQuaternionDot(c, d),
- g = Math.acos(f),
- h = Math.sqrt(1 - cc.kmSQR(f)),
- f = Math.sin(e * g) / h;
- e = Math.sin((1 - e) * g) / h;
- g = new cc.kmQuaternion;
- h = new cc.kmQuaternion;
- cc.kmQuaternionScale(g, c, e);
- cc.kmQuaternionScale(h, d, f);
- cc.kmQuaternionAdd(a, g, h);
- return a
- };
- cc.kmQuaternionToAxisAngle = function(a, c, d) {
- Math.acos(a.w);
- d = Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z));
- d > -cc.kmEpsilon && d < cc.kmEpsilon || d < 2 * cc.kmPI + cc.kmEpsilon && d > 2 * cc.kmPI - cc.kmEpsilon ? (c.x = 0, c.y = 0, c.z = 1) : (c.x = a.x / d, c.y = a.y / d, c.z = a.z / d, cc.kmVec3Normalize(c, c))
- };
- cc.kmQuaternionScale = function(a, c, d) {
- a.x = c.x * d;
- a.y = c.y * d;
- a.z = c.z * d;
- a.w = c.w * d;
- return a
- };
- cc.kmQuaternionAssign = function(a, c) {
- a.x = c.x;
- a.y = c.y;
- a.z = c.z;
- a.w = c.w;
- return a
- };
- cc.kmQuaternionAdd = function(a, c, d) {
- a.x = c.x + d.x;
- a.y = c.y + d.y;
- a.z = c.z + d.z;
- a.w = c.w + d.w;
- return a
- };
- cc.kmQuaternionRotationBetweenVec3 = function(a, c, d, e) {
- var f = new cc.kmVec3,
- g = new cc.kmVec3;
- cc.kmVec3Assign(f, c);
- cc.kmVec3Assign(g, d);
- cc.kmVec3Normalize(f, f);
- cc.kmVec3Normalize(g, g);
- d = cc.kmVec3Dot(f, g);
- if (1 <= d) return cc.kmQuaternionIdentity(a), a; - 0.999999 > d ? Math.abs(cc.kmVec3LengthSq(e)) < cc.kmEpsilon ? cc.kmQuaternionRotationAxis(a, e, cc.kmPI) : (f = new cc.kmVec3, g = new cc.kmVec3, g.x = 1, g.y = 0, g.z = 0, cc.kmVec3Cross(f, g, c), Math.abs(cc.kmVec3LengthSq(f)) < cc.kmEpsilon && (g = new cc.kmVec3, g.x = 0, g.y = 1, g.z = 0, cc.kmVec3Cross(f, g, c)), cc.kmVec3Normalize(f, f), cc.kmQuaternionRotationAxis(a, f, cc.kmPI)) : (c = Math.sqrt(2 * (1 + d)), e = 1 / c, d = new cc.kmVec3, cc.kmVec3Cross(d, f, g), a.x = d.x * e, a.y = d.y * e, a.z = d.z * e, a.w = 0.5 * c, cc.kmQuaternionNormalize(a, a));
- return a
- };
- cc.kmQuaternionMultiplyVec3 = function(a, c, d) {
- var e = new cc.kmVec3,
- f = new cc.kmVec3,
- g = new cc.kmVec3;
- g.x = c.x;
- g.y = c.y;
- g.z = c.z;
- cc.kmVec3Cross(e, g, d);
- cc.kmVec3Cross(f, g, e);
- cc.kmVec3Scale(e, e, 2 * c.w);
- cc.kmVec3Scale(f, f, 2);
- cc.kmVec3Add(a, d, e);
- cc.kmVec3Add(a, a, f);
- return a
- };
- cc.kmAABB = function(a, c) {
- this.min = a || new cc.kmVec3;
- this.max = c || new cc.kmVec3
- };
- cc.kmAABBContainsPoint = function(a, c) {
- return a.x >= c.min.x && a.x <= c.max.x && a.y >= c.min.y && a.y <= c.max.y && a.z >= c.min.z && a.z <= c.max.z ? cc.KM_TRUE : cc.KM_FALSE
- };
- cc.kmAABBAssign = function(a, c) {
- cc.kmVec3Assign(a.min, c.min);
- cc.kmVec3Assign(a.max, c.max);
- return a
- };
- cc.kmAABBScale = function(a, c, d) {
- cc.log("cc.kmAABBScale hasn't been supported.")
- };
- cc.km_mat4_stack = function(a, c, d, e) {
- this.top = d;
- this.stack = e
- };
- cc.km_mat4_stack.INITIAL_SIZE = 30;
- cc.km_mat4_stack_initialize = function(a) {
- a.stack = [];
- a.top = null
- };
- cc.km_mat4_stack_push = function(a, c) {
- a.stack.push(a.top);
- a.top = new cc.kmMat4;
- cc.kmMat4Assign(a.top, c)
- };
- cc.km_mat4_stack_pop = function(a, c) {
- a.top = a.stack.pop()
- };
- cc.km_mat4_stack_release = function(a) {
- a.stack = null;
- a.top = null
- };
- cc.KM_GL_MODELVIEW = 5888;
- cc.KM_GL_PROJECTION = 5889;
- cc.KM_GL_TEXTURE = 5890;
- cc.modelview_matrix_stack = new cc.km_mat4_stack;
- cc.projection_matrix_stack = new cc.km_mat4_stack;
- cc.texture_matrix_stack = new cc.km_mat4_stack;
- cc.current_stack = null;
- cc.initialized = !1;
- cc.lazyInitialize = function() {
- if (!cc.initialized) {
- var a = new cc.kmMat4;
- cc.km_mat4_stack_initialize(cc.modelview_matrix_stack);
- cc.km_mat4_stack_initialize(cc.projection_matrix_stack);
- cc.km_mat4_stack_initialize(cc.texture_matrix_stack);
- cc.current_stack = cc.modelview_matrix_stack;
- cc.initialized = !0;
- cc.kmMat4Identity(a);
- cc.km_mat4_stack_push(cc.modelview_matrix_stack, a);
- cc.km_mat4_stack_push(cc.projection_matrix_stack, a);
- cc.km_mat4_stack_push(cc.texture_matrix_stack, a)
- }
- };
- cc.lazyInitialize();
- cc.kmGLFreeAll = function() {
- cc.km_mat4_stack_release(cc.modelview_matrix_stack);
- cc.km_mat4_stack_release(cc.projection_matrix_stack);
- cc.km_mat4_stack_release(cc.texture_matrix_stack);
- cc.initialized = !1;
- cc.current_stack = null
- };
- cc.kmGLPushMatrix = function() {
- cc.km_mat4_stack_push(cc.current_stack, cc.current_stack.top)
- };
- cc.kmGLPushMatrixWitMat4 = function(a) {
- cc.current_stack.stack.push(cc.current_stack.top);
- cc.kmMat4Assign(a, cc.current_stack.top);
- cc.current_stack.top = a
- };
- cc.kmGLPopMatrix = function() {
- cc.current_stack.top = cc.current_stack.stack.pop()
- };
- cc.kmGLMatrixMode = function(a) {
- switch (a) {
- case cc.KM_GL_MODELVIEW:
- cc.current_stack = cc.modelview_matrix_stack;
- break;
- case cc.KM_GL_PROJECTION:
- cc.current_stack = cc.projection_matrix_stack;
- break;
- case cc.KM_GL_TEXTURE:
- cc.current_stack = cc.texture_matrix_stack;
- break;
- default:
- throw "Invalid matrix mode specified";
- }
- };
- cc.kmGLLoadIdentity = function() {
- cc.kmMat4Identity(cc.current_stack.top)
- };
- cc.kmGLLoadMatrix = function(a) {
- cc.kmMat4Assign(cc.current_stack.top, a)
- };
- cc.kmGLMultMatrix = function(a) {
- cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, a)
- };
- cc.kmGLTranslatef = function(a, c, d) {
- var e = new cc.kmMat4;
- cc.kmMat4Translation(e, a, c, d);
- cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, e)
- };
- cc.kmGLRotatef = function(a, c, d, e) {
- c = new cc.kmVec3(c, d, e);
- d = new cc.kmMat4;
- cc.kmMat4RotationAxisAngle(d, c, cc.kmDegreesToRadians(a));
- cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, d)
- };
- cc.kmGLScalef = function(a, c, d) {
- var e = new cc.kmMat4;
- cc.kmMat4Scaling(e, a, c, d);
- cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, e)
- };
- cc.kmGLGetMatrix = function(a, c) {
- switch (a) {
- case cc.KM_GL_MODELVIEW:
- cc.kmMat4Assign(c, cc.modelview_matrix_stack.top);
- break;
- case cc.KM_GL_PROJECTION:
- cc.kmMat4Assign(c, cc.projection_matrix_stack.top);
- break;
- case cc.KM_GL_TEXTURE:
- cc.kmMat4Assign(c, cc.texture_matrix_stack.top);
- break;
- default:
- throw "Invalid matrix mode specified";
- }
- };
- cc.SHADER_POSITION_UCOLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n}\n";
- cc.SHADER_POSITION_UCOLOR_VERT = "attribute vec4 a_position;\nuniform vec4 u_color;\nuniform float u_pointSize;\nvarying lowp vec4 v_fragmentColor; \nvoid main(void) \n{\n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n gl_PointSize \x3d u_pointSize; \n v_fragmentColor \x3d u_color; \n}";
- cc.SHADER_POSITION_COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n} ";
- cc.SHADER_POSITION_COLOR_VERT = "attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n}";
- cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG = "// #extension GL_OES_standard_derivatives : enable\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main()\t\n{ \n// #if defined GL_OES_standard_derivatives\t\n// gl_FragColor \x3d v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n// #else\t\ngl_FragColor \x3d v_color * step(0.0, 1.0 - length(v_texcoord)); \n// #endif \n}";
- cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT = "attribute mediump vec4 a_position; \nattribute mediump vec2 a_texcoord; \nattribute mediump vec4 a_color;\t\nvarying mediump vec4 v_color; \nvarying mediump vec2 v_texcoord;\t\nvoid main() \n{ \n v_color \x3d a_color;//vec4(a_color.rgb * a_color.a, a_color.a); \n v_texcoord \x3d a_texcoord; \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n}";
- cc.SHADER_POSITION_TEXTURE_FRAG = "precision lowp float; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord); \n}";
- cc.SHADER_POSITION_TEXTURE_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord \x3d a_texCoord; \n}";
- cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG = "precision lowp float; \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord) * u_color; \n}";
- cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT = "attribute vec4 a_position;\nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord \x3d a_texCoord; \n}";
- cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d vec4( v_fragmentColor.rgb, \n v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a \n ); \n}";
- cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n v_texCoord \x3d a_texCoord; \n}";
- cc.SHADER_POSITION_TEXTURE_COLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}";
- cc.SHADER_POSITION_TEXTURE_COLOR_VERT = "attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position \x3d (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor \x3d a_color; \n v_texCoord \x3d a_texCoord; \n}";
- cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nuniform float CC_alpha_value; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord); \n // mimic: glAlphaFunc(GL_GREATER) \n //pass if ( incoming_pixel \x3e\x3d CC_alpha_value ) \x3d\x3e fail if incoming_pixel \x3c CC_alpha_value \n if ( texColor.a \x3c\x3d CC_alpha_value ) \n discard; \n gl_FragColor \x3d texColor * v_fragmentColor; \n}";
- cc.SHADEREX_SWITCHMASK_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D u_texture; \nuniform sampler2D u_mask; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(u_texture, v_texCoord); \n vec4 maskColor \x3d texture2D(u_mask, v_texCoord); \n vec4 finalColor \x3d vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a); \n gl_FragColor \x3d v_fragmentColor * finalColor; \n}";
- cc.shaderCache = {
- TYPE_POSITION_TEXTURECOLOR: 0,
- TYPE_POSITION_TEXTURECOLOR_ALPHATEST: 1,
- TYPE_POSITION_COLOR: 2,
- TYPE_POSITION_TEXTURE: 3,
- TYPE_POSITION_TEXTURE_UCOLOR: 4,
- TYPE_POSITION_TEXTURE_A8COLOR: 5,
- TYPE_POSITION_UCOLOR: 6,
- TYPE_POSITION_LENGTH_TEXTURECOLOR: 7,
- TYPE_MAX: 8,
- _programs: {},
- _init: function() {
- this.loadDefaultShaders();
- return !0
- },
- _loadDefaultShader: function(a, c) {
- switch (c) {
- case this.TYPE_POSITION_TEXTURECOLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- break;
- case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- break;
- case this.TYPE_POSITION_COLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT, cc.SHADER_POSITION_COLOR_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- break;
- case this.TYPE_POSITION_TEXTURE:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT, cc.SHADER_POSITION_TEXTURE_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- break;
- case this.TYPE_POSITION_TEXTURE_UCOLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT, cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- break;
- case this.TYPE_POSITION_TEXTURE_A8COLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT, cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- break;
- case this.TYPE_POSITION_UCOLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT, cc.SHADER_POSITION_UCOLOR_FRAG);
- a.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION);
- break;
- case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:
- a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT, cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG);
- a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
- a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
- a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
- break;
- default:
- cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type");
- return
- }
- a.link();
- a.updateUniforms()
- },
- loadDefaultShaders: function() {
- var a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
- this._programs[cc.SHADER_POSITION_TEXTURECOLOR] = a;
- this._programs.ShaderPositionTextureColor = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
- this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST] = a;
- this._programs.ShaderPositionTextureColorAlphaTest = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
- this._programs[cc.SHADER_POSITION_COLOR] = a;
- this._programs.ShaderPositionColor = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
- this._programs[cc.SHADER_POSITION_TEXTURE] = a;
- this._programs.ShaderPositionTexture = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
- this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR] = a;
- this._programs.ShaderPositionTextureUColor = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
- this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR] = a;
- this._programs.ShaderPositionTextureA8Color = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR);
- this._programs[cc.SHADER_POSITION_UCOLOR] = a;
- this._programs.ShaderPositionUColor = a;
- a = new cc.GLProgram;
- this._loadDefaultShader(a, this.TYPE_POSITION_LENGTH_TEXTURECOLOR);
- this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR] = a;
- this._programs.ShaderPositionLengthTextureColor = a
- },
- reloadDefaultShaders: function() {
- var a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
- a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
- a = this.programForKey(cc.SHADER_POSITION_COLOR);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
- a = this.programForKey(cc.SHADER_POSITION_TEXTURE);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
- a = this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
- a = this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
- a = this.programForKey(cc.SHADER_POSITION_UCOLOR);
- a.reset();
- this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR)
- },
- programForKey: function(a) {
- return this._programs[a]
- },
- getProgram: function(a) {
- return this._programs[a]
- },
- addProgram: function(a, c) {
- this._programs[c] = a
- }
- };
- cc.HashUniformEntry = function(a, c, d) {
- this.value = a;
- this.location = c;
- this.hh = d || {}
- };
- cc.GLProgram = cc.Class.extend({
- _glContext: null,
- _programObj: null,
- _vertShader: null,
- _fragShader: null,
- _uniforms: null,
- _hashForUniforms: null,
- _usesTime: !1,
- _updateUniformLocation: function(a, c, d) {
- if (null == a) return !1;
- d = !0;
- for (var e = null, f = 0; f < this._hashForUniforms.length; f++) this._hashForUniforms[f].location == a && (e = this._hashForUniforms[f]);
- e ? e.value == c ? d = !1 : e.value = c : (e = new cc.HashUniformEntry, e.location = a, e.value = c, this._hashForUniforms.push(e));
- return d
- },
- _description: function() {
- return "\x3cCCGLProgram \x3d " + this.toString() + " | Program \x3d " + this._programObj.toString() + ", VertexShader \x3d " + this._vertShader.toString() + ", FragmentShader \x3d " + this._fragShader.toString() + "\x3e"
- },
- _compileShader: function(a, c, d) {
- if (!d || !a) return !1;
- this._glContext.shaderSource(a, "precision highp float; \nuniform mat4 CC_PMatrix; \nuniform mat4 CC_MVMatrix; \nuniform mat4 CC_MVPMatrix; \nuniform vec4 CC_Time; \nuniform vec4 CC_SinTime; \nuniform vec4 CC_CosTime; \nuniform vec4 CC_Random01; \n//CC INCLUDES END \n" + d);
- this._glContext.compileShader(a);
- d = this._glContext.getShaderParameter(a, this._glContext.COMPILE_STATUS);
- d || (cc.log("cocos2d: ERROR: Failed to compile shader:\n" + this._glContext.getShaderSource(a)), c == this._glContext.VERTEX_SHADER ? cc.log("cocos2d: \n" + this.vertexShaderLog()) : cc.log("cocos2d: \n" + this.fragmentShaderLog()));
- return 1 == d
- },
- ctor: function(a, c, d) {
- this._uniforms = [];
- this._hashForUniforms = [];
- this._glContext = d || cc._renderContext;
- a && c && this.init(a, c)
- },
- destroyProgram: function() {
- this._hashForUniforms = this._uniforms = this._fragShader = this._vertShader = null;
- this._glContext.deleteProgram(this._programObj)
- },
- initWithVertexShaderByteArray: function(a, c) {
- var d = this._glContext;
- this._programObj = d.createProgram();
- this._fragShader = this._vertShader = null;
- a && (this._vertShader = d.createShader(d.VERTEX_SHADER), this._compileShader(this._vertShader, d.VERTEX_SHADER, a) || cc.log("cocos2d: ERROR: Failed to compile vertex shader"));
- c && (this._fragShader = d.createShader(d.FRAGMENT_SHADER), this._compileShader(this._fragShader, d.FRAGMENT_SHADER, c) || cc.log("cocos2d: ERROR: Failed to compile fragment shader"));
- this._vertShader && d.attachShader(this._programObj, this._vertShader);
- cc.checkGLErrorDebug();
- this._fragShader && d.attachShader(this._programObj, this._fragShader);
- this._hashForUniforms.length = 0;
- cc.checkGLErrorDebug();
- return !0
- },
- initWithString: function(a, c) {
- return this.initWithVertexShaderByteArray(a, c)
- },
- initWithVertexShaderFilename: function(a, c) {
- var d = cc.loader.getRes(a);
- if (!d) throw "Please load the resource firset : " + a;
- var e = cc.loader.getRes(c);
- if (!e) throw "Please load the resource firset : " + c;
- return this.initWithVertexShaderByteArray(d, e)
- },
- init: function(a, c) {
- return this.initWithVertexShaderFilename(a, c)
- },
- addAttribute: function(a, c) {
- this._glContext.bindAttribLocation(this._programObj, c, a)
- },
- link: function() {
- if (!this._programObj) return cc.log("cc.GLProgram.link(): Cannot link invalid program"), !1;
- this._glContext.linkProgram(this._programObj);
- this._vertShader && this._glContext.deleteShader(this._vertShader);
- this._fragShader && this._glContext.deleteShader(this._fragShader);
- this._fragShader = this._vertShader = null;
- return cc.game.config[cc.game.CONFIG_KEY.debugMode] && !this._glContext.getProgramParameter(this._programObj, this._glContext.LINK_STATUS) ? (cc.log("cocos2d: ERROR: Failed to link program: " + this._glContext.getProgramInfoLog(this._programObj)), cc.glDeleteProgram(this._programObj), this._programObj = null, !1) : !0
- },
- use: function() {
- cc.glUseProgram(this._programObj)
- },
- updateUniforms: function() {
- this._uniforms[cc.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S);
- this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S);
- this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S);
- this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S);
- this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S);
- this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S);
- this._usesTime = null != this._uniforms[cc.UNIFORM_TIME] || null != this._uniforms[cc.UNIFORM_SINTIME] || null != this._uniforms[cc.UNIFORM_COSTIME];
- this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S);
- this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S);
- this.use();
- this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER], 0)
- },
- getUniformLocationForName: function(a) {
- if (!a) throw "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null";
- if (!this._programObj) throw "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized";
- return this._glContext.getUniformLocation(this._programObj, a)
- },
- getUniformMVPMatrix: function() {
- return this._uniforms[cc.UNIFORM_MVPMATRIX]
- },
- getUniformSampler: function() {
- return this._uniforms[cc.UNIFORM_SAMPLER]
- },
- setUniformLocationWith1i: function(a, c) {
- this._updateUniformLocation(a, c) && this._glContext.uniform1i(a, c)
- },
- setUniformLocationWith2i: function(a, c, d) {
- this._updateUniformLocation(a, [c, d]) && this._glContext.uniform2i(a, c, d)
- },
- setUniformLocationWith3i: function(a, c, d, e) {
- this._updateUniformLocation(a, [c, d, e]) && this._glContext.uniform3i(a, c, d, e)
- },
- setUniformLocationWith4i: function(a, c, d, e, f) {
- this._updateUniformLocation(a, [c, d, e, f]) && this._glContext.uniform4i(a, c, d, e, f)
- },
- setUniformLocationWith2iv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform2iv(a, c)
- },
- setUniformLocationWith3iv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform3iv(a, c)
- },
- setUniformLocationWith4iv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform4iv(a, c)
- },
- setUniformLocationI32: function(a, c) {
- this.setUniformLocationWith1i(a, c)
- },
- setUniformLocationWith1f: function(a, c) {
- this._updateUniformLocation(a, c) && this._glContext.uniform1f(a, c)
- },
- setUniformLocationWith2f: function(a, c, d) {
- this._updateUniformLocation(a, [c, d]) && this._glContext.uniform2f(a, c, d)
- },
- setUniformLocationWith3f: function(a, c, d, e) {
- this._updateUniformLocation(a, [c, d, e]) && this._glContext.uniform3f(a, c, d, e)
- },
- setUniformLocationWith4f: function(a, c, d, e, f) {
- this._updateUniformLocation(a, [c, d, e, f]) && this._glContext.uniform4f(a, c, d, e, f)
- },
- setUniformLocationWith2fv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform2fv(a, c)
- },
- setUniformLocationWith3fv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform3fv(a, c)
- },
- setUniformLocationWith4fv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniform4fv(a, c)
- },
- setUniformLocationWithMatrix4fv: function(a, c, d) {
- this._updateUniformLocation(a, c) && this._glContext.uniformMatrix4fv(a, !1, c)
- },
- setUniformLocationF32: function() {
- if (!(2 > arguments.length)) switch (arguments.length) {
- case 2:
- this.setUniformLocationWith1f(arguments[0], arguments[1]);
- break;
- case 3:
- this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]);
- break;
- case 4:
- this.setUniformLocationWith3f(arguments[0], arguments[1], arguments[2], arguments[3]);
- break;
- case 5:
- this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
- }
- },
- setUniformsForBuiltins: function() {
- var a = new cc.kmMat4,
- c = new cc.kmMat4,
- d = new cc.kmMat4;
- cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a);
- cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, c);
- cc.kmMat4Multiply(d, a, c);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], a.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], c.mat, 1);
- this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], d.mat, 1);
- this._usesTime && (a = cc.director, a = a.getTotalFrames() * a.getAnimationInterval(), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME], a / 10, a, 2 * a, 4 * a), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME], a / 8, a / 4, a / 2, Math.sin(a)), this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME], a / 8, a / 4, a / 2, Math.cos(a))); - 1 != this._uniforms[cc.UNIFORM_RANDOM01] && this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01], Math.random(), Math.random(), Math.random(), Math.random())
- },
- setUniformForModelViewProjectionMatrix: function() {
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top))
- },
- setUniformForModelViewProjectionMatrixWithMat4: function(a) {
- cc.kmMat4Multiply(a, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top);
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, a.mat)
- },
- setUniformForModelViewAndProjectionMatrixWithMat4: function() {
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, cc.modelview_matrix_stack.top.mat);
- this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat)
- },
- vertexShaderLog: function() {
- return this._glContext.getShaderInfoLog(this._vertShader)
- },
- getVertexShaderLog: function() {
- return this._glContext.getShaderInfoLog(this._vertShader)
- },
- getFragmentShaderLog: function() {
- return this._glContext.getShaderInfoLog(this._vertShader)
- },
- fragmentShaderLog: function() {
- return this._glContext.getShaderInfoLog(this._fragShader)
- },
- programLog: function() {
- return this._glContext.getProgramInfoLog(this._programObj)
- },
- getProgramLog: function() {
- return this._glContext.getProgramInfoLog(this._programObj)
- },
- reset: function() {
- this._fragShader = this._vertShader = null;
- this._uniforms.length = 0;
- this._glContext.deleteProgram(this._programObj);
- this._programObj = null;
- for (var a = 0; a < this._hashForUniforms.length; a++) this._hashForUniforms[a].value = null, this._hashForUniforms[a] = null;
- this._hashForUniforms.length = 0
- },
- getProgram: function() {
- return this._programObj
- },
- retain: function() {},
- release: function() {}
- });
- cc.GLProgram.create = function(a, c) {
- return new cc.GLProgram(a, c)
- };
- cc._currentProjectionMatrix = -1;
- cc._vertexAttribPosition = !1;
- cc._vertexAttribColor = !1;
- cc._vertexAttribTexCoords = !1;
- cc.ENABLE_GL_STATE_CACHE && (cc.MAX_ACTIVETEXTURE = 16, cc._currentShaderProgram = -1, cc._currentBoundTexture = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], cc._blendingSource = -1, cc._blendingDest = -1, cc._GLServerState = 0, cc.TEXTURE_ATLAS_USE_VAO && (cc._uVAO = 0));
- cc.glInvalidateStateCache = function() {
- cc.kmGLFreeAll();
- cc._currentProjectionMatrix = -1;
- cc._vertexAttribPosition = !1;
- cc._vertexAttribColor = !1;
- cc._vertexAttribTexCoords = !1;
- if (cc.ENABLE_GL_STATE_CACHE) {
- cc._currentShaderProgram = -1;
- for (var a = 0; a < cc.MAX_ACTIVETEXTURE; a++) cc._currentBoundTexture[a] = -1;
- cc._blendingSource = -1;
- cc._blendingDest = -1;
- cc._GLServerState = 0
- }
- };
- cc.glUseProgram = function(a) {
- a !== cc._currentShaderProgram && (cc._currentShaderProgram = a, cc._renderContext.useProgram(a))
- };
- cc.ENABLE_GL_STATE_CACHE || (cc.glUseProgram = function(a) {
- cc._renderContext.useProgram(a)
- });
- cc.glDeleteProgram = function(a) {
- cc.ENABLE_GL_STATE_CACHE && a === cc._currentShaderProgram && (cc._currentShaderProgram = -1);
- gl.deleteProgram(a)
- };
- cc.glBlendFunc = function(a, c) {
- if (a !== cc._blendingSource || c !== cc._blendingDest) cc._blendingSource = a, cc._blendingDest = c, cc.setBlending(a, c)
- };
- cc.setBlending = function(a, c) {
- var d = cc._renderContext;
- a === d.ONE && c === d.ZERO ? d.disable(d.BLEND) : (d.enable(d.BLEND), cc._renderContext.blendFunc(a, c))
- };
- cc.glBlendFuncForParticle = function(a, c) {
- if (a !== cc._blendingSource || c !== cc._blendingDest) {
- cc._blendingSource = a;
- cc._blendingDest = c;
- var d = cc._renderContext;
- a === d.ONE && c === d.ZERO ? d.disable(d.BLEND) : (d.enable(d.BLEND), d.blendFuncSeparate(d.SRC_ALPHA, c, a, c))
- }
- };
- cc.ENABLE_GL_STATE_CACHE || (cc.glBlendFunc = cc.setBlending);
- cc.glBlendResetToCache = function() {
- var a = cc._renderContext;
- a.blendEquation(a.FUNC_ADD);
- cc.ENABLE_GL_STATE_CACHE ? cc.setBlending(cc._blendingSource, cc._blendingDest) : cc.setBlending(a.BLEND_SRC, a.BLEND_DST)
- };
- cc.setProjectionMatrixDirty = function() {
- cc._currentProjectionMatrix = -1
- };
- cc.glEnableVertexAttribs = function(a) {
- var c = cc._renderContext,
- d = a & cc.VERTEX_ATTRIB_FLAG_POSITION;
- d !== cc._vertexAttribPosition && (d ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION), cc._vertexAttribPosition = d);
- d = a & cc.VERTEX_ATTRIB_FLAG_COLOR;
- d !== cc._vertexAttribColor && (d ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR), cc._vertexAttribColor = d);
- a &= cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
- a !== cc._vertexAttribTexCoords && (a ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS), cc._vertexAttribTexCoords = a)
- };
- cc.glBindTexture2D = function(a) {
- cc.glBindTexture2DN(0, a)
- };
- cc.glBindTexture2DN = function(a, c) {
- if (cc._currentBoundTexture[a] != c) {
- cc._currentBoundTexture[a] = c;
- var d = cc._renderContext;
- d.activeTexture(d.TEXTURE0 + a);
- c ? d.bindTexture(d.TEXTURE_2D, c._webTextureObj) : d.bindTexture(d.TEXTURE_2D, null)
- }
- };
- cc.ENABLE_GL_STATE_CACHE || (cc.glBindTexture2DN = function(a, c) {
- var d = cc._renderContext;
- d.activeTexture(d.TEXTURE0 + a);
- c ? d.bindTexture(d.TEXTURE_2D, c._webTextureObj) : d.bindTexture(d.TEXTURE_2D, null)
- });
- cc.glDeleteTexture = function(a) {
- cc.glDeleteTextureN(0, a)
- };
- cc.glDeleteTextureN = function(a, c) {
- cc.ENABLE_GL_STATE_CACHE && c == cc._currentBoundTexture[a] && (cc._currentBoundTexture[a] = -1);
- cc._renderContext.deleteTexture(c)
- };
- cc.glBindVAO = function(a) {
- cc.TEXTURE_ATLAS_USE_VAO && (cc.ENABLE_GL_STATE_CACHE && cc._uVAO != a) && (cc._uVAO = a)
- };
- cc.glEnable = function(a) {};
- cc.IMAGE_FORMAT_JPEG = 0;
- cc.IMAGE_FORMAT_PNG = 1;
- cc.IMAGE_FORMAT_RAWDATA = 9;
- cc.NextPOT = function(a) {
- a -= 1;
- a |= a >> 1;
- a |= a >> 2;
- a |= a >> 4;
- a |= a >> 8;
- return (a | a >> 16) + 1
- };
- cc.RenderTexture = cc.Node.extend({
- sprite: null,
- clearFlags: 0,
- clearDepthVal: 0,
- autoDraw: !1,
- _cacheCanvas: null,
- _cacheContext: null,
- _fBO: 0,
- _depthRenderBuffer: 0,
- _oldFBO: 0,
- _texture: null,
- _textureCopy: null,
- _uITextureImage: null,
- _pixelFormat: cc.Texture2D.PIXEL_FORMAT_RGBA8888,
- _clearColor: null,
- clearStencilVal: 0,
- _clearColorStr: null,
- _className: "RenderTexture",
- ctor: null,
- _ctorForCanvas: function(a, c, d, e) {
- cc.Node.prototype.ctor.call(this);
- this._clearColor = cc.color(255, 255, 255, 255);
- this._clearColorStr = "rgba(255,255,255,1)";
- this._cacheCanvas = cc.newElement("canvas");
- this._cacheContext = this._cacheCanvas.getContext("2d");
- this.anchorY = this.anchorX = 0;
- void 0 !== a && void 0 !== c && (d = d || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, c, d, e || 0))
- },
- _ctorForWebGL: function(a, c, d, e) {
- cc.Node.prototype.ctor.call(this);
- this._clearColor = cc.color(0, 0, 0, 0);
- void 0 !== a && void 0 !== c && (d = d || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, c, d, e || 0))
- },
- cleanup: null,
- _cleanupForCanvas: function() {
- cc.Node.prototype.onExit.call(this);
- this._cacheCanvas = this._cacheContext = null
- },
- _cleanupForWebGL: function() {
- cc.Node.prototype.onExit.call(this);
- this._textureCopy = null;
- var a = cc._renderContext;
- a.deleteFramebuffer(this._fBO);
- this._depthRenderBuffer && a.deleteRenderbuffer(this._depthRenderBuffer);
- this._uITextureImage = null
- },
- getSprite: function() {
- return this.sprite
- },
- setSprite: function(a) {
- this.sprite = a
- },
- initWithWidthAndHeight: null,
- _initWithWidthAndHeightForCanvas: function(a, c, d, e) {
- d = this._cacheCanvas;
- e = cc.contentScaleFactor();
- d.width = 0 | a * e;
- d.height = 0 | c * e;
- this._cacheContext.translate(0, d.height);
- a = new cc.Texture2D;
- a.initWithElement(d);
- a.handleLoadedTexture();
- this.sprite = cc.Sprite.create(a);
- return !0
- },
- _initWithWidthAndHeightForWebGL: function(a, c, d, e) {
- d == cc.Texture2D.PIXEL_FORMAT_A8 && cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;");
- var f = cc._renderContext,
- g = cc.contentScaleFactor();
- a = 0 | a * g;
- c = 0 | c * g;
- this._oldFBO = f.getParameter(f.FRAMEBUFFER_BINDING);
- var h;
- cc.configuration.supportsNPOT() ? (g = a, h = c) : (g = cc.NextPOT(a), h = cc.NextPOT(c));
- for (var k = new Uint8Array(4 * g * h), m = 0; m < 4 * g * h; m++) k[m] = 0;
- this._pixelFormat = d;
- this._texture = new cc.Texture2D;
- if (!this._texture) return !1;
- m = this._texture;
- m.initWithData(k, this._pixelFormat, g, h, cc.size(a, c));
- d = f.getParameter(f.RENDERBUFFER_BINDING);
- if (cc.configuration.checkForGLExtension("GL_QCOM")) {
- this._textureCopy = new cc.Texture2D;
- if (!this._textureCopy) return !1;
- this._textureCopy.initWithData(k, this._pixelFormat, g, h, cc.size(a, c))
- }
- this._fBO = f.createFramebuffer();
- f.bindFramebuffer(f.FRAMEBUFFER, this._fBO);
- f.framebufferTexture2D(f.FRAMEBUFFER, f.COLOR_ATTACHMENT0, f.TEXTURE_2D, m._webTextureObj, 0);
- 0 != e && (this._depthRenderBuffer = f.createRenderbuffer(), f.bindRenderbuffer(f.RENDERBUFFER, this._depthRenderBuffer), f.renderbufferStorage(f.RENDERBUFFER, e, g, h), f.framebufferRenderbuffer(f.FRAMEBUFFER, f.DEPTH_ATTACHMENT, f.RENDERBUFFER, this._depthRenderBuffer));
- f.checkFramebufferStatus(f.FRAMEBUFFER) !== f.FRAMEBUFFER_COMPLETE && cc.log("Could not attach texture to the framebuffer");
- m.setAliasTexParameters();
- a = this.sprite = cc.Sprite.create(m);
- a.scaleY = -1;
- a.setBlendFunc(f.ONE, f.ONE_MINUS_SRC_ALPHA);
- f.bindRenderbuffer(f.RENDERBUFFER, d);
- f.bindFramebuffer(f.FRAMEBUFFER, this._oldFBO);
- this.autoDraw = !1;
- this.addChild(a);
- return !0
- },
- begin: null,
- _beginForCanvas: function() {
- cc._renderContext = this._cacheContext;
- cc.view._setScaleXYForRenderTexture()
- },
- _beginForWebGL: function() {
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPushMatrix();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPushMatrix();
- var a = cc.director;
- a.setProjection(a.getProjection());
- var c = this._texture.getContentSizeInPixels(),
- d = cc.director.getWinSizeInPixels(),
- a = d.width / c.width,
- d = d.height / c.height,
- e = cc._renderContext;
- e.viewport(0, 0, c.width, c.height);
- c = new cc.kmMat4;
- cc.kmMat4OrthographicProjection(c, -1 / a, 1 / a, -1 / d, 1 / d, -1, 1);
- cc.kmGLMultMatrix(c);
- this._oldFBO = e.getParameter(e.FRAMEBUFFER_BINDING);
- e.bindFramebuffer(e.FRAMEBUFFER, this._fBO);
- cc.configuration.checkForGLExtension("GL_QCOM") && (e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this._textureCopy._webTextureObj, 0), e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this._texture._webTextureObj, 0))
- },
- beginWithClear: function(a, c, d, e, f, g) {
- var h = cc._renderContext;
- f = f || h.COLOR_BUFFER_BIT;
- g = g || h.COLOR_BUFFER_BIT | h.DEPTH_BUFFER_BIT;
- this._beginWithClear(a / 255, c / 255, d / 255, e / 255, f, g, h.COLOR_BUFFER_BIT | h.DEPTH_BUFFER_BIT | h.STENCIL_BUFFER_BIT)
- },
- _beginWithClear: null,
- _beginWithClearForCanvas: function(a, c, d, e, f, g, h) {
- this.begin();
- a = a || 0;
- c = c || 0;
- d = d || 0;
- e = isNaN(e) ? 1 : e;
- f = this._cacheContext;
- g = this._cacheCanvas;
- f.save();
- f.fillStyle = "rgba(" + (0 | a) + "," + (0 | c) + "," + (0 | d) + "," + e / 255 + ")";
- f.clearRect(0, 0, g.width, -g.height);
- f.fillRect(0, 0, g.width, -g.height);
- f.restore()
- },
- _beginWithClearForWebGL: function(a, c, d, e, f, g, h) {
- this.begin();
- var k = cc._renderContext,
- m = [0, 0, 0, 0],
- n = 0,
- q = 0;
- h & k.COLOR_BUFFER_BIT && (m = k.getParameter(k.COLOR_CLEAR_VALUE), k.clearColor(a, c, d, e));
- h & k.DEPTH_BUFFER_BIT && (n = k.getParameter(k.DEPTH_CLEAR_VALUE), k.clearDepth(f));
- h & k.STENCIL_BUFFER_BIT && (q = k.getParameter(k.STENCIL_CLEAR_VALUE), k.clearStencil(g));
- k.clear(h);
- h & k.COLOR_BUFFER_BIT && k.clearColor(m[0], m[1], m[2], m[3]);
- h & k.DEPTH_BUFFER_BIT && k.clearDepth(n);
- h & k.STENCIL_BUFFER_BIT && k.clearStencil(q)
- },
- end: null,
- _endForCanvas: function() {
- cc._renderContext = cc._mainRenderContextBackup;
- cc.view._resetScale()
- },
- _endForWebGL: function() {
- var a = cc._renderContext,
- c = cc.director;
- a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
- c.setViewport();
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPopMatrix();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPopMatrix()
- },
- clear: function(a, c, d, e) {
- this.beginWithClear(a, c, d, e);
- this.end()
- },
- clearRect: null,
- _clearRectForCanvas: function(a, c, d, e) {
- this._cacheContext.clearRect(a, c, d, -e)
- },
- _clearRectForWebGL: function(a, c, d, e) {},
- clearDepth: null,
- _clearDepthForCanvas: function(a) {
- cc.log("clearDepth isn't supported on Cocos2d-Html5")
- },
- _clearDepthForWebGL: function(a) {
- this.begin();
- var c = cc._renderContext,
- d = c.getParameter(c.DEPTH_CLEAR_VALUE);
- c.clearDepth(a);
- c.clear(c.DEPTH_BUFFER_BIT);
- c.clearDepth(d);
- this.end()
- },
- clearStencil: null,
- _clearStencilForCanvas: function(a) {
- cc.log("clearDepth isn't supported on Cocos2d-Html5")
- },
- _clearStencilForWebGL: function(a) {
- var c = cc._renderContext,
- d = c.getParameter(c.STENCIL_CLEAR_VALUE);
- c.clearStencil(a);
- c.clear(c.STENCIL_BUFFER_BIT);
- c.clearStencil(d)
- },
- visit: null,
- _visitForCanvas: function(a) {
- this._visible && (a = a || cc._renderContext, a.save(), this.draw(a), this.transform(a), this.sprite.visit(), a.restore(), this.arrivalOrder = 0)
- },
- _visitForWebGL: function(a) {
- if (this._visible) {
- cc.kmGLPushMatrix();
- var c = this.grid;
- c && c.isActive() && (c.beforeDraw(), this.transformAncestors());
- this.transform(a);
- this.sprite.visit();
- this.draw(a);
- c && c.isActive() && c.afterDraw(this);
- cc.kmGLPopMatrix();
- this.arrivalOrder = 0
- }
- },
- draw: null,
- _drawForCanvas: function(a) {
- a = a || cc._renderContext;
- if (this.autoDraw) {
- this.begin();
- if (this.clearFlags) {
- var c = this._cacheCanvas;
- a.save();
- a.fillStyle = this._clearColorStr;
- a.clearRect(0, 0, c.width, -c.height);
- a.fillRect(0, 0, c.width, -c.height);
- a.restore()
- }
- this.sortAllChildren();
- a = this._children;
- for (var c = a.length, d = this.sprite, e = 0; e < c; e++) {
- var f = a[e];
- f != d && f.visit()
- }
- this.end()
- }
- },
- _drawForWebGL: function(a) {
- a = cc._renderContext;
- if (this.autoDraw) {
- this.begin();
- var c = this.clearFlags;
- if (c) {
- var d = [0, 0, 0, 0],
- e = 0,
- f = 0;
- c & a.COLOR_BUFFER_BIT && (d = a.getParameter(a.COLOR_CLEAR_VALUE), a.clearColor(this._clearColor.r / 255, this._clearColor.g / 255, this._clearColor.b / 255, this._clearColor.a / 255));
- c & a.DEPTH_BUFFER_BIT && (e = a.getParameter(a.DEPTH_CLEAR_VALUE), a.clearDepth(this.clearDepthVal));
- c & a.STENCIL_BUFFER_BIT && (f = a.getParameter(a.STENCIL_CLEAR_VALUE), a.clearStencil(this.clearStencilVal));
- a.clear(c);
- c & a.COLOR_BUFFER_BIT && a.clearColor(d[0], d[1], d[2], d[3]);
- c & a.DEPTH_BUFFER_BIT && a.clearDepth(e);
- c & a.STENCIL_BUFFER_BIT && a.clearStencil(f)
- }
- this.sortAllChildren();
- a = this._children;
- for (c = 0; c < a.length; c++) d = a[c], d != this.sprite && d.visit();
- this.end()
- }
- },
- newCCImage: function(a) {
- cc.log("saveToFile isn't supported on cocos2d-html5");
- return null
- },
- _memcpy: function(a, c, d, e, f) {
- for (var g = 0; g < f; g++) a[c + g] = d[e + g]
- },
- saveToFile: function(a, c) {
- cc.log("saveToFile isn't supported on Cocos2d-Html5")
- },
- listenToBackground: function(a) {
- cc.log("listenToBackground isn't supported on Cocos2d-Html5")
- },
- listenToForeground: function(a) {
- cc.log("listenToForeground isn't supported on Cocos2d-Html5")
- },
- getClearFlags: function() {
- return this.clearFlags
- },
- setClearFlags: function(a) {
- this.clearFlags = a
- },
- getClearColor: function() {
- return this._clearColor
- },
- setClearColor: null,
- _setClearColorForCanvas: function(a) {
- var c = this._clearColor;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- c.a = a.a;
- this._clearColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + "," + a.a / 255 + ")"
- },
- _setClearColorForWebGL: function(a) {
- var c = this._clearColor;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- c.a = a.a
- },
- getClearDepth: function() {
- return this.clearDepthVal
- },
- setClearDepth: function(a) {
- this.clearDepthVal = a
- },
- getClearStencil: function() {
- return this.clearStencilVal
- },
- setClearStencil: function(a) {
- this.clearStencilVal = a
- },
- isAutoDraw: function() {
- return this.autoDraw
- },
- setAutoDraw: function(a) {
- this.autoDraw = a
- }
- });
- _p = cc.RenderTexture.prototype;
- cc._renderType == cc._RENDER_TYPE_WEBGL ? (_p.ctor = _p._ctorForWebGL, _p.cleanup = _p._cleanupForWebGL, _p.initWithWidthAndHeight = _p._initWithWidthAndHeightForWebGL, _p.begin = _p._beginForWebGL, _p._beginWithClear = _p._beginWithClearForWebGL, _p.end = _p._endForWebGL, _p.clearRect = _p._clearRectForWebGL, _p.clearDepth = _p._clearDepthForWebGL, _p.clearStencil = _p._clearStencilForWebGL, _p.visit = _p._visitForWebGL, _p.draw = _p._drawForWebGL, _p.setClearColor = _p._setClearColorForWebGL) : (_p.ctor = _p._ctorForCanvas, _p.cleanup = _p._cleanupForCanvas, _p.initWithWidthAndHeight = _p._initWithWidthAndHeightForCanvas, _p.begin = _p._beginForCanvas, _p._beginWithClear = _p._beginWithClearForCanvas, _p.end = _p._endForCanvas, _p.clearRect = _p._clearRectForCanvas, _p.clearDepth = _p._clearDepthForCanvas, _p.clearStencil = _p._clearStencilForCanvas, _p.visit = _p._visitForCanvas, _p.draw = _p._drawForCanvas, _p.setClearColor = _p._setClearColorForCanvas);
- cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor);
- cc.RenderTexture.create = function(a, c, d, e) {
- return new cc.RenderTexture(a, c, d, e)
- };
- cc.LabelAtlas = cc.AtlasNode.extend({
- _string: null,
- _mapStartChar: null,
- _textureLoaded: !1,
- _loadedEventListeners: null,
- _className: "LabelAtlas",
- ctor: function(a, c, d, e, f) {
- cc.AtlasNode.prototype.ctor.call(this);
- c && cc.LabelAtlas.prototype.initWithString.call(this, a, c, d, e, f)
- },
- textureLoaded: function() {
- return this._textureLoaded
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners || (this._loadedEventListeners = []);
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- _callLoadedEventCallbacks: function() {
- if (this._loadedEventListeners) {
- this._textureLoaded = !0;
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- },
- initWithString: function(a, c, d, e, f) {
- var g = a + "",
- h, k;
- if (void 0 === d) {
- d = cc.loader.getRes(c);
- if (1 !== parseInt(d.version, 10)) return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"), !1;
- c = cc.path.changeBasename(c, d.textureFilename);
- e = cc.contentScaleFactor();
- h = parseInt(d.itemWidth, 10) / e;
- k = parseInt(d.itemHeight, 10) / e;
- d = String.fromCharCode(parseInt(d.firstChar, 10))
- } else h = d || 0, k = e || 0, d = f || " ";
- var m = null,
- m = c instanceof cc.Texture2D ? c : cc.textureCache.addImage(c);
- (this._textureLoaded = c = m.isLoaded()) || m.addLoadedEventListener(function(a) {
- this.initWithTexture(m, h, k, g.length);
- this.string = g;
- this._callLoadedEventCallbacks()
- }, this);
- return this.initWithTexture(m, h, k, g.length) ? (this._mapStartChar = d, this.string = g, !0) : !1
- },
- setColor: function(a) {
- cc.AtlasNode.prototype.setColor.call(this, a);
- this.updateAtlasValues()
- },
- getString: function() {
- return this._string
- },
- draw: function(a) {
- cc.AtlasNode.prototype.draw.call(this, a);
- cc.LABELATLAS_DEBUG_DRAW && (a = this.size, a = [cc.p(0, 0), cc.p(a.width, 0), cc.p(a.width, a.height), cc.p(0, a.height)], cc._drawingUtil.drawPoly(a, 4, !0))
- },
- _addChildForCanvas: function(a, c, d) {
- a._lateChild = !0;
- cc.Node.prototype.addChild.call(this, a, c, d)
- },
- updateAtlasValues: null,
- _updateAtlasValuesForCanvas: function() {
- for (var a = this._string || "", c = a.length, d = this.texture, e = this._itemWidth, f = this._itemHeight, g = 0; g < c; g++) {
- var h = a.charCodeAt(g) - this._mapStartChar.charCodeAt(0),
- k = parseInt(h % this._itemsPerRow, 10),
- h = parseInt(h / this._itemsPerRow, 10),
- k = cc.rect(k * e, h * f, e, f),
- h = a.charCodeAt(g),
- m = this.getChildByTag(g);
- m ? 32 == h ? (m.init(), m.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : (m.initWithTexture(d, k), m.visible = !0, m.opacity = this._displayedOpacity) : (m = new cc.Sprite, 32 == h ? (m.init(), m.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : m.initWithTexture(d, k), cc.Node.prototype.addChild.call(this, m, 0, g));
- m.setPosition(g * e + e / 2, f / 2)
- }
- },
- _updateAtlasValuesForWebGL: function() {
- var a = this._string,
- c = a.length,
- d = this.textureAtlas,
- e = d.texture,
- f = e.pixelsWidth,
- e = e.pixelsHeight,
- g = this._itemWidth,
- h = this._itemHeight;
- this._ignoreContentScaleFactor || (g = this._itemWidth * cc.contentScaleFactor(), h = this._itemHeight * cc.contentScaleFactor());
- c > d.getCapacity() && cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");
- for (var k = d.quads, m = this._displayedColor, m = {
- r: m.r,
- g: m.g,
- b: m.b,
- a: this._displayedOpacity
- }, n = this._itemWidth, q = 0; q < c; q++) {
- var r = a.charCodeAt(q) - this._mapStartChar.charCodeAt(0),
- t = r % this._itemsPerRow,
- s = 0 | r / this._itemsPerRow,
- v;
- cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (t = (2 * t * g + 1) / (2 * f), r = t + (2 * g - 2) / (2 * f), s = (2 * s * h + 1) / (2 * e), v = s + (2 * h - 2) / (2 * e)) : (t = t * g / f, r = t + g / f, s = s * h / e, v = s + h / e);
- var u = k[q],
- x = u.tl,
- A = u.tr,
- D = u.bl,
- u = u.br;
- x.texCoords.u = t;
- x.texCoords.v = s;
- A.texCoords.u = r;
- A.texCoords.v = s;
- D.texCoords.u = t;
- D.texCoords.v = v;
- u.texCoords.u = r;
- u.texCoords.v = v;
- D.vertices.x = q * n;
- D.vertices.y = 0;
- D.vertices.z = 0;
- u.vertices.x = q * n + n;
- u.vertices.y = 0;
- u.vertices.z = 0;
- x.vertices.x = q * n;
- x.vertices.y = this._itemHeight;
- x.vertices.z = 0;
- A.vertices.x = q * n + n;
- A.vertices.y = this._itemHeight;
- A.vertices.z = 0;
- x.colors = m;
- A.colors = m;
- D.colors = m;
- u.colors = m
- }
- 0 < c && (d.dirty = !0, a = d.totalQuads, c > a && d.increaseTotalQuadsWith(c - a))
- },
- setString: null,
- _setStringForCanvas: function(a) {
- a = String(a);
- var c = a.length;
- this._string = a;
- this.width = c * this._itemWidth;
- this.height = this._itemHeight;
- if (this._children) {
- a = this._children;
- for (var c = a.length, d = 0; d < c; d++) {
- var e = a[d];
- e && !e._lateChild && (e.visible = !1)
- }
- }
- this.updateAtlasValues();
- this.quadsToDraw = c
- },
- _setStringForWebGL: function(a) {
- a = String(a);
- var c = a.length;
- c > this.textureAtlas.totalQuads && this.textureAtlas.resizeCapacity(c);
- this._string = a;
- this.width = c * this._itemWidth;
- this.height = this._itemHeight;
- this.updateAtlasValues();
- this.quadsToDraw = c
- },
- setOpacity: null,
- _setOpacityForCanvas: function(a) {
- if (this._displayedOpacity !== a) {
- cc.AtlasNode.prototype.setOpacity.call(this, a);
- for (var c = this._children, d = 0, e = c.length; d < e; d++) c[d] && (c[d].opacity = a)
- }
- },
- _setOpacityForWebGL: function(a) {
- this._opacity !== a && cc.AtlasNode.prototype.setOpacity.call(this, a)
- }
- });
- _p = cc.LabelAtlas.prototype;
- cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.updateAtlasValues = _p._updateAtlasValuesForWebGL, _p.setString = _p._setStringForWebGL, _p.setOpacity = _p._setOpacityForWebGL) : (_p.updateAtlasValues = _p._updateAtlasValuesForCanvas, _p.setString = _p._setStringForCanvas, _p.setOpacity = _p._setOpacityForCanvas, _p.addChild = _p._addChildForCanvas);
- cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
- cc.LabelAtlas.create = function(a, c, d, e, f) {
- return new cc.LabelAtlas(a, c, d, e, f)
- };
- cc.LABEL_AUTOMATIC_WIDTH = -1;
- cc.LabelBMFont = cc.SpriteBatchNode.extend({
- _opacityModifyRGB: !1,
- _string: "",
- _config: null,
- _fntFile: "",
- _initialString: "",
- _alignment: cc.TEXT_ALIGNMENT_CENTER,
- _width: -1,
- _lineBreakWithoutSpaces: !1,
- _imageOffset: null,
- _reusedChar: null,
- _displayedOpacity: 255,
- _realOpacity: 255,
- _displayedColor: null,
- _realColor: null,
- _cascadeColorEnabled: !0,
- _cascadeOpacityEnabled: !0,
- _textureLoaded: !1,
- _loadedEventListeners: null,
- _className: "LabelBMFont",
- _setString: function(a, c) {
- c ? this._initialString = a : this._string = a;
- var d = this._children;
- if (d)
- for (var e = 0; e < d.length; e++) {
- var f = d[e];
- f && f.setVisible(!1)
- }
- this._textureLoaded && (this.createFontChars(), c && this.updateLabel())
- },
- ctor: function(a, c, d, e, f) {
- cc.SpriteBatchNode.prototype.ctor.call(this);
- this._imageOffset = cc.p(0, 0);
- this._displayedColor = cc.color(255, 255, 255, 255);
- this._realColor = cc.color(255, 255, 255, 255);
- this._reusedChar = [];
- this.initWithString(a, c, d, e, f)
- },
- textureLoaded: function() {
- return this._textureLoaded
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners || (this._loadedEventListeners = []);
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- _callLoadedEventCallbacks: function() {
- if (this._loadedEventListeners) {
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- }
- },
- draw: function(a) {
- cc.SpriteBatchNode.prototype.draw.call(this, a);
- if (cc.LABELBMFONT_DEBUG_DRAW) {
- a = this.getContentSize();
- var c = cc.p(0 | -this._anchorPointInPoints.x, 0 | -this._anchorPointInPoints.y);
- a = [cc.p(c.x, c.y), cc.p(c.x + a.width, c.y), cc.p(c.x + a.width, c.y + a.height), cc.p(c.x, c.y + a.height)];
- cc._drawingUtil.setDrawColor(0, 255, 0, 255);
- cc._drawingUtil.drawPoly(a, 4, !0)
- }
- },
- setColor: function(a) {
- var c = this._displayedColor,
- d = this._realColor;
- d.r == a.r && d.g == a.g && d.b == a.b && d.a == a.a || (c.r = d.r = a.r, c.g = d.g = a.g, c.b = d.b = a.b, this._textureLoaded && this._cascadeColorEnabled && (a = cc.color.WHITE, (c = this._parent) && c.cascadeColor && (a = c.getDisplayedColor()), this.updateDisplayedColor(a)))
- },
- isOpacityModifyRGB: function() {
- return this._opacityModifyRGB
- },
- setOpacityModifyRGB: function(a) {
- this._opacityModifyRGB = a;
- if (a = this._children)
- for (var c = 0; c < a.length; c++) {
- var d = a[c];
- d && (d.opacityModifyRGB = this._opacityModifyRGB)
- }
- },
- getOpacity: function() {
- return this._realOpacity
- },
- getDisplayedOpacity: function() {
- return this._displayedOpacity
- },
- setOpacity: function(a) {
- this._displayedOpacity = this._realOpacity = a;
- if (this._cascadeOpacityEnabled) {
- var c = 255,
- d = this._parent;
- d && d.cascadeOpacity && (c = d.getDisplayedOpacity());
- this.updateDisplayedOpacity(c)
- }
- this._displayedColor.a = this._realColor.a = a
- },
- updateDisplayedOpacity: function(a) {
- this._displayedOpacity = this._realOpacity * a / 255;
- a = this._children;
- for (var c = 0; c < a.length; c++) {
- var d = a[c];
- cc._renderType == cc._RENDER_TYPE_WEBGL ? d.updateDisplayedOpacity(this._displayedOpacity) : (cc.Node.prototype.updateDisplayedOpacity.call(d, this._displayedOpacity), d.setNodeDirty())
- }
- this._changeTextureColor()
- },
- isCascadeOpacityEnabled: function() {
- return !1
- },
- setCascadeOpacityEnabled: function(a) {
- this._cascadeOpacityEnabled = a
- },
- getColor: function() {
- var a = this._realColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getDisplayedColor: function() {
- return this._displayedColor
- },
- updateDisplayedColor: function(a) {
- var c = this._displayedColor,
- d = this._realColor;
- c.r = d.r * a.r / 255;
- c.g = d.g * a.g / 255;
- c.b = d.b * a.b / 255;
- a = this._children;
- for (c = 0; c < a.length; c++) d = a[c], cc._renderType == cc._RENDER_TYPE_WEBGL ? d.updateDisplayedColor(this._displayedColor) : (cc.Node.prototype.updateDisplayedColor.call(d, this._displayedColor), d.setNodeDirty());
- this._changeTextureColor()
- },
- _changeTextureColor: function() {
- if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
- var a = this.getTexture();
- if (a && 0 < a.getContentSize().width) {
- var c = this._originalTexture.getHtmlElementObj();
- if (c) {
- var d = a.getHtmlElementObj(),
- e = cc.rect(0, 0, c.width, c.height);
- d instanceof HTMLCanvasElement && !this._rectRotated ? cc.generateTintImageWithMultiply(c, this._displayedColor, e, d) : (d = cc.generateTintImageWithMultiply(c, this._displayedColor, e), a = new cc.Texture2D, a.initWithElement(d), a.handleLoadedTexture());
- this.setTexture(a)
- }
- }
- }
- },
- isCascadeColorEnabled: function() {
- return !1
- },
- setCascadeColorEnabled: function(a) {
- this._cascadeColorEnabled = a
- },
- init: function() {
- return this.initWithString(null, null, null, null, null)
- },
- initWithString: function(a, c, d, e, f) {
- a = a || "";
- this._config && cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");
- if (c) {
- var g = cc.loader.getRes(c);
- if (!g) return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"), !1;
- this._config = g;
- this._fntFile = c;
- c = cc.textureCache.addImage(g.atlasName);
- (this._textureLoaded = g = c.isLoaded()) || c.addLoadedEventListener(function(a) {
- this._textureLoaded = !0;
- this.initWithTexture(a, this._initialString.length);
- this.setString(this._initialString, !0);
- this._callLoadedEventCallbacks()
- }, this)
- } else c = new cc.Texture2D, g = new Image, c.initWithElement(g), this._textureLoaded = !1;
- return this.initWithTexture(c, a.length) ? (this._alignment = e || cc.TEXT_ALIGNMENT_LEFT, this._imageOffset = f || cc.p(0, 0), this._width = null == d ? -1 : d, this._displayedOpacity = this._realOpacity = 255, this._displayedColor = cc.color(255, 255, 255, 255), this._realColor = cc.color(255, 255, 255, 255), this._cascadeColorEnabled = this._cascadeOpacityEnabled = !0, this._contentSize.width = 0, this._contentSize.height = 0, this.setAnchorPoint(0.5, 0.5), cc._renderType === cc._RENDER_TYPE_WEBGL && (d = this.textureAtlas.texture, this._opacityModifyRGB = d.hasPremultipliedAlpha(), e = this._reusedChar = new cc.Sprite, e.initWithTexture(d, cc.rect(0, 0, 0, 0), !1), e.batchNode = this), this.setString(a, !0), !0) : !1
- },
- createFontChars: function() {
- var a = cc._renderType,
- c = a === cc._RENDER_TYPE_CANVAS ? this.texture : this.textureAtlas.texture,
- d = 0,
- e = cc.size(0, 0),
- f = 0,
- g = 1,
- h = this._string,
- k = h ? h.length : 0;
- if (0 !== k) {
- var m, n = this._config,
- q = n.kerningDict,
- r = n.commonHeight,
- t = n.fontDefDictionary;
- for (m = 0; m < k - 1; m++) 10 == h.charCodeAt(m) && g++;
- var s = r * g,
- g = -(r - r * g),
- v = -1;
- for (m = 0; m < k; m++)
- if (r = h.charCodeAt(m), 0 != r)
- if (10 === r) d = 0, g -= n.commonHeight;
- else {
- var u = q[v << 16 | r & 65535] || 0,
- x = t[r];
- if (x) {
- var A = cc.rect(x.rect.x, x.rect.y, x.rect.width, x.rect.height),
- A = cc.rectPixelsToPoints(A);
- A.x += this._imageOffset.x;
- A.y += this._imageOffset.y;
- (v = this.getChildByTag(m)) ? 32 === r && a === cc._RENDER_TYPE_CANVAS ? v.setTextureRect(A, !1, cc.size(0, 0)) : (v.setTextureRect(A, !1), v.visible = !0): (v = new cc.Sprite, 32 === r && a === cc._RENDER_TYPE_CANVAS && (A = cc.rect(0, 0, 0, 0)), v.initWithTexture(c, A, !1), v._newTextureWhenChangeColor = !0, this.addChild(v, 0, m));
- v.opacityModifyRGB = this._opacityModifyRGB;
- cc._renderType == cc._RENDER_TYPE_WEBGL ? (v.updateDisplayedColor(this._displayedColor), v.updateDisplayedOpacity(this._displayedOpacity)) : (cc.Node.prototype.updateDisplayedColor.call(v, this._displayedColor), cc.Node.prototype.updateDisplayedOpacity.call(v, this._displayedOpacity), v.setNodeDirty());
- A = cc.p(d + x.xOffset + 0.5 * x.rect.width + u, g + (n.commonHeight - x.yOffset) - 0.5 * A.height * cc.contentScaleFactor());
- v.setPosition(cc.pointPixelsToPoints(A));
- d += x.xAdvance + u;
- v = r;
- f < d && (f = d)
- } else cc.log("cocos2d: LabelBMFont: character not found " + h[m])
- }
- e.width = f;
- e.height = s;
- this.setContentSize(cc.sizePixelsToPoints(e))
- }
- },
- updateString: function(a) {
- var c = this._children;
- if (c)
- for (var d = 0, e = c.length; d < e; d++) {
- var f = c[d];
- f && (f.visible = !1)
- }
- this._config && this.createFontChars();
- a || this.updateLabel()
- },
- getString: function() {
- return this._initialString
- },
- setString: function(a, c) {
- a = String(a);
- null == c && (c = !0);
- if (null == a || "string" != typeof a) a += "";
- this._initialString = a;
- this._setString(a, c)
- },
- _setStringForSetter: function(a) {
- this.setString(a, !1)
- },
- setCString: function(a) {
- this.setString(a, !0)
- },
- updateLabel: function() {
- this.string = this._initialString;
- if (0 < this._width) {
- for (var a = this._string.length, c = [], d = [], e = 1, f = 0, g = !1, h = !1, k = -1, m = -1, n = 0, q, r = 0, t = this._children.length; r < t; r++) {
- for (var s = 0; !(q = this.getChildByTag(r + n + s));) s++;
- n += s;
- if (f >= a) break;
- var v = this._string[f];
- h || (m = this._getLetterPosXLeft(q), h = !0);
- g || (k = m, g = !0);
- if (10 == v.charCodeAt(0)) {
- d.push("\n");
- c = c.concat(d);
- d.length = 0;
- g = h = !1;
- k = m = -1;
- r--;
- n -= s;
- e++;
- if (f >= a) break;
- m || (m = this._getLetterPosXLeft(q), h = !0);
- k || (k = m, g = !0);
- f++
- } else if (cc.isspace_unicode(v)) d.push(v), c = c.concat(d), d.length = 0, h = !1, m = -1, f++;
- else if (this._getLetterPosXRight(q) - k > this._width)
- if (this._lineBreakWithoutSpaces) {
- cc.utf8_trim_ws(d);
- d.push("\n");
- c = c.concat(d);
- d.length = 0;
- g = h = !1;
- k = m = -1;
- e++;
- if (f >= a) break;
- m || (m = this._getLetterPosXLeft(q), h = !0);
- k || (k = m, g = !0);
- r--
- } else d.push(v), -1 != c.lastIndexOf(" ") ? cc.utf8_trim_ws(c) : c = [], 0 < c.length && c.push("\n"), e++, g = !1, k = -1, f++;
- else d.push(v), f++
- }
- c = c.concat(d);
- r = c.length;
- q = "";
- for (f = 0; f < r; ++f) q += c[f];
- q += String.fromCharCode(0);
- this._setString(q, !1)
- }
- if (this._alignment != cc.TEXT_ALIGNMENT_LEFT) {
- c = f = 0;
- a = this._string.length;
- d = [];
- for (e = 0; e < a; e++)
- if (10 == this._string[e].charCodeAt(0) || 0 == this._string[e].charCodeAt(0))
- if (r = 0, g = d.length, 0 == g) c++;
- else {
- if (q = f + g - 1 + c, !(0 > q) && (r = this.getChildByTag(q), null != r)) {
- r = r.getPositionX() + r._getWidth() / 2;
- h = 0;
- switch (this._alignment) {
- case cc.TEXT_ALIGNMENT_CENTER:
- h = this.width / 2 - r / 2;
- break;
- case cc.TEXT_ALIGNMENT_RIGHT:
- h = this.width - r
- }
- if (0 != h)
- for (r = 0; r < g; r++)
- if (q = f + r + c, !(0 > q) && (q = this.getChildByTag(q))) q.x += h;
- f += g;
- c++;
- d.length = 0
- }
- } else d.push(this._string[f])
- }
- },
- setAlignment: function(a) {
- this._alignment = a;
- this.updateLabel()
- },
- _getAlignment: function() {
- return this._alignment
- },
- setBoundingWidth: function(a) {
- this._width = a;
- this.updateLabel()
- },
- _getBoundingWidth: function() {
- return this._width
- },
- setLineBreakWithoutSpace: function(a) {
- this._lineBreakWithoutSpaces = a;
- this.updateLabel()
- },
- setScale: function(a, c) {
- cc.Node.prototype.setScale.call(this, a, c);
- this.updateLabel()
- },
- setScaleX: function(a) {
- cc.Node.prototype.setScaleX.call(this, a);
- this.updateLabel()
- },
- setScaleY: function(a) {
- cc.Node.prototype.setScaleY.call(this, a);
- this.updateLabel()
- },
- setFntFile: function(a) {
- if (null != a && a != this._fntFile) {
- var c = cc.loader.getRes(a);
- c ? (this._fntFile = a, this._config = c, a = cc.textureCache.addImage(c.atlasName), this._textureLoaded = c = a.isLoaded(), this.texture = a, cc._renderType === cc._RENDER_TYPE_CANVAS && (this._originalTexture = this.texture), c ? this.createFontChars() : a.addLoadedEventListener(function(a) {
- this._textureLoaded = !0;
- this.texture = a;
- this.createFontChars();
- this._changeTextureColor();
- this.updateLabel();
- this._callLoadedEventCallbacks()
- }, this)) : cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file")
- }
- },
- getFntFile: function() {
- return this._fntFile
- },
- setAnchorPoint: function(a, c) {
- cc.Node.prototype.setAnchorPoint.call(this, a, c);
- this.updateLabel()
- },
- _setAnchor: function(a) {
- cc.Node.prototype._setAnchor.call(this, a);
- this.updateLabel()
- },
- _setAnchorX: function(a) {
- cc.Node.prototype._setAnchorX.call(this, a);
- this.updateLabel()
- },
- _setAnchorY: function(a) {
- cc.Node.prototype._setAnchorY.call(this, a);
- this.updateLabel()
- },
- _atlasNameFromFntFile: function(a) {},
- _kerningAmountForFirst: function(a, c) {
- var d = 0;
- if (this._configuration.kerningDictionary) {
- var e = this._configuration.kerningDictionary[(a << 16 | c & 65535).toString()];
- e && (d = e.amount)
- }
- return d
- },
- _getLetterPosXLeft: function(a) {
- return a.getPositionX() * this._scaleX - a._getWidth() * this._scaleX * a._getAnchorX()
- },
- _getLetterPosXRight: function(a) {
- return a.getPositionX() * this._scaleX + a._getWidth() * this._scaleX * a._getAnchorX()
- }
- });
- _p = cc.LabelBMFont.prototype;
- cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes && (_p._changeTextureColor = function() {
- if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
- var a, c = this.getTexture();
- if (c && 0 < c.getContentSize().width && (a = c.getHtmlElementObj()))
- if (c = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())) a instanceof HTMLCanvasElement && !this._rectRotated ? cc.generateTintImage(a, c, this._displayedColor, null, a) : (a = cc.generateTintImage(a, c, this._displayedColor), c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.setTexture(c))
- }
- });
- cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter);
- cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p.setBoundingWidth);
- cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment);
- cc.LabelBMFont.create = function(a, c, d, e, f) {
- return new cc.LabelBMFont(a, c, d, e, f)
- };
- cc.isspace_unicode = function(a) {
- a = a.charCodeAt(0);
- return 9 <= a && 13 >= a || 32 == a || 133 == a || 160 == a || 5760 == a || 8192 <= a && 8202 >= a || 8232 == a || 8233 == a || 8239 == a || 8287 == a || 12288 == a
- };
- cc.utf8_trim_ws = function(a) {
- var c = a.length;
- if (!(0 >= c) && (c -= 1, cc.isspace_unicode(a[c]))) {
- for (var d = c - 1; 0 <= d; --d)
- if (cc.isspace_unicode(a[d])) c = d;
- else break;
- cc.utf8_trim_from(a, c)
- }
- };
- cc.utf8_trim_from = function(a, c) {
- var d = a.length;
- c >= d || 0 > c || a.splice(c, d)
- };
- cc._fntLoader = {
- INFO_EXP: /info [^\n]*(\n|$)/gi,
- COMMON_EXP: /common [^\n]*(\n|$)/gi,
- PAGE_EXP: /page [^\n]*(\n|$)/gi,
- CHAR_EXP: /char [^\n]*(\n|$)/gi,
- KERNING_EXP: /kerning [^\n]*(\n|$)/gi,
- ITEM_EXP: /\w+=[^ \r\n]+/gi,
- INT_EXP: /^[\-]?\d+$/,
- _parseStrToObj: function(a) {
- a = a.match(this.ITEM_EXP);
- var c = {};
- if (a)
- for (var d = 0, e = a.length; d < e; d++) {
- var f = a[d],
- g = f.indexOf("\x3d"),
- h = f.substring(0, g),
- f = f.substring(g + 1);
- f.match(this.INT_EXP) ? f = parseInt(f) : '"' == f[0] && (f = f.substring(1, f.length - 1));
- c[h] = f
- }
- return c
- },
- parseFnt: function(a, c) {
- var d = {},
- e = this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(",");
- parseInt(e[0]);
- parseInt(e[1]);
- parseInt(e[2]);
- parseInt(e[3]);
- e = this._parseStrToObj(a.match(this.COMMON_EXP)[0]);
- d.commonHeight = e.lineHeight;
- if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
- var f = cc.configuration.getMaxTextureSize();
- (e.scaleW > f.width || e.scaleH > f.height) && cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")
- }
- 1 !== e.pages && cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
- e = this._parseStrToObj(a.match(this.PAGE_EXP)[0]);
- 0 !== e.id && cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
- d.atlasName = cc.path.changeBasename(c, e.file);
- for (var g = a.match(this.CHAR_EXP), h = d.fontDefDictionary = {}, e = 0, f = g.length; e < f; e++) {
- var k = this._parseStrToObj(g[e]);
- h[k.id] = {
- rect: {
- x: k.x,
- y: k.y,
- width: k.width,
- height: k.height
- },
- xOffset: k.xoffset,
- yOffset: k.yoffset,
- xAdvance: k.xadvance
- }
- }
- g = d.kerningDict = {};
- if (h = a.match(this.KERNING_EXP)) {
- e = 0;
- for (f = h.length; e < f; e++) k = this._parseStrToObj(h[e]), g[k.first << 16 | k.second & 65535] = k.amount
- }
- return d
- },
- load: function(a, c, d, e) {
- var f = this;
- cc.loader.loadTxt(a, function(a, d) {
- if (a) return e(a);
- e(null, f.parseFnt(d, c))
- })
- }
- };
- cc.loader.register(["fnt"], cc._fntLoader);
- cc.MotionStreak = cc.Node.extend({
- texture: null,
- fastMode: !1,
- startingPositionInitialized: !1,
- _blendFunc: null,
- _stroke: 0,
- _fadeDelta: 0,
- _minSeg: 0,
- _maxPoints: 0,
- _nuPoints: 0,
- _previousNuPoints: 0,
- _pointVertexes: null,
- _pointState: null,
- _vertices: null,
- _colorPointer: null,
- _texCoords: null,
- _verticesBuffer: null,
- _colorPointerBuffer: null,
- _texCoordsBuffer: null,
- _className: "MotionStreak",
- ctor: function(a, c, d, e, f) {
- cc.Node.prototype.ctor.call(this);
- this._positionR = cc.p(0, 0);
- this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
- this._vertexWebGLBuffer = cc._renderContext.createBuffer();
- this.startingPositionInitialized = this.fastMode = !1;
- this.texture = null;
- this._previousNuPoints = this._nuPoints = this._maxPoints = this._minSeg = this._fadeDelta = this._stroke = 0;
- this._texCoordsBuffer = this._colorPointerBuffer = this._verticesBuffer = this._texCoords = this._colorPointer = this._vertices = this._pointState = this._pointVertexes = null;
- void 0 !== f && this.initWithFade(a, c, d, e, f)
- },
- getTexture: function() {
- return this.texture
- },
- setTexture: function(a) {
- this.texture != a && (this.texture = a)
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendFunc: function(a, c) {
- void 0 === c ? this._blendFunc = a : (this._blendFunc.src = a, this._blendFunc.dst = c)
- },
- getOpacity: function() {
- cc.log("cc.MotionStreak.getOpacity has not been supported.");
- return 0
- },
- setOpacity: function(a) {
- cc.log("cc.MotionStreak.setOpacity has not been supported.")
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- },
- onExit: function() {
- cc.Node.prototype.onExit.call(this);
- this._verticesBuffer && cc._renderContext.deleteBuffer(this._verticesBuffer);
- this._texCoordsBuffer && cc._renderContext.deleteBuffer(this._texCoordsBuffer);
- this._colorPointerBuffer && cc._renderContext.deleteBuffer(this._colorPointerBuffer)
- },
- isFastMode: function() {
- return this.fastMode
- },
- setFastMode: function(a) {
- this.fastMode = a
- },
- isStartingPositionInitialized: function() {
- return this.startingPositionInitialized
- },
- setStartingPositionInitialized: function(a) {
- this.startingPositionInitialized = a
- },
- initWithFade: function(a, c, d, e, f) {
- if (!f) throw "cc.MotionStreak.initWithFade(): Invalid filename or texture";
- "string" === typeof f && (f = cc.textureCache.addImage(f));
- cc.Node.prototype.setPosition.call(this, cc.p(0, 0));
- this.anchorY = this.anchorX = 0;
- this.ignoreAnchor = !0;
- this.startingPositionInitialized = !1;
- this.fastMode = !0;
- this._minSeg = -1 == c ? d / 5 : c;
- this._minSeg *= this._minSeg;
- this._stroke = d;
- this._fadeDelta = 1 / a;
- a = (0 | 60 * a) + 2;
- this._nuPoints = 0;
- this._pointState = new Float32Array(a);
- this._pointVertexes = new Float32Array(2 * a);
- this._vertices = new Float32Array(4 * a);
- this._texCoords = new Float32Array(4 * a);
- this._colorPointer = new Uint8Array(8 * a);
- this._maxPoints = a;
- a = cc._renderContext;
- this._verticesBuffer = a.createBuffer();
- this._texCoordsBuffer = a.createBuffer();
- this._colorPointerBuffer = a.createBuffer();
- this._blendFunc.src = a.SRC_ALPHA;
- this._blendFunc.dst = a.ONE_MINUS_SRC_ALPHA;
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
- this.texture = f;
- this.color = e;
- this.scheduleUpdate();
- a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ARRAY_BUFFER, this._texCoordsBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._texCoords, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ARRAY_BUFFER, this._colorPointerBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._colorPointer, a.DYNAMIC_DRAW);
- return !0
- },
- tintWithColor: function(a) {
- this.color = a;
- for (var c = this._colorPointer, d = 0, e = 2 * this._nuPoints; d < e; d++) c[4 * d] = a.r, c[4 * d + 1] = a.g, c[4 * d + 2] = a.b
- },
- reset: function() {
- this._nuPoints = 0
- },
- setPosition: function(a, c) {
- this.startingPositionInitialized = !0;
- void 0 === c ? (this._positionR.x = a.x, this._positionR.y = a.y) : (this._positionR.x = a, this._positionR.y = c)
- },
- getPositionX: function() {
- return this._positionR.x
- },
- setPositionX: function(a) {
- this._positionR.x = a;
- this.startingPositionInitialized || (this.startingPositionInitialized = !0)
- },
- getPositionY: function() {
- return this._positionR.y
- },
- setPositionY: function(a) {
- this._positionR.y = a;
- this.startingPositionInitialized || (this.startingPositionInitialized = !0)
- },
- draw: function(a) {
- !(1 >= this._nuPoints) && (this.texture && this.texture.isLoaded()) && (a = a || cc._renderContext, cc.nodeDrawSetup(this), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2D(this.texture), a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer), a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, this._texCoordsBuffer), a.bufferData(a.ARRAY_BUFFER, this._texCoords, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, this._colorPointerBuffer), a.bufferData(a.ARRAY_BUFFER, this._colorPointer, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0), a.drawArrays(a.TRIANGLE_STRIP, 0, 2 * this._nuPoints), cc.g_NumberOfDraws++)
- },
- update: function(a) {
- if (this.startingPositionInitialized) {
- a *= this._fadeDelta;
- var c, d, e, f, g = 0,
- h = this._nuPoints,
- k = this._pointState,
- m = this._pointVertexes,
- n = this._vertices,
- q = this._colorPointer;
- for (e = 0; e < h; e++) k[e] -= a, 0 >= k[e] ? g++ : (c = e - g, 0 < g ? (k[c] = k[e], m[2 * c] = m[2 * e], m[2 * c + 1] = m[2 * e + 1], f = 2 * e, d = 2 * c, n[2 * d] = n[2 * f], n[2 * d + 1] = n[2 * f + 1], n[2 * (d + 1)] = n[2 * (f + 1)], n[2 * (d + 1) + 1] = n[2 * (f + 1) + 1], f *= 4, d *= 4, q[d + 0] = q[f + 0], q[d + 1] = q[f + 1], q[d + 2] = q[f + 2], q[d + 4] = q[f + 4], q[d + 5] = q[f + 5], q[d + 6] = q[f + 6]) : d = 8 * c, c = 255 * k[c], q[d + 3] = c, q[d + 7] = c);
- h -= g;
- e = !0;
- if (h >= this._maxPoints) e = !1;
- else if (0 < h && (a = cc.pDistanceSQ(cc.p(m[2 * (h - 1)], m[2 * (h - 1) + 1]), this._positionR) < this._minSeg, d = 1 == h ? !1 : cc.pDistanceSQ(cc.p(m[2 * (h - 2)], m[2 * (h - 2) + 1]), this._positionR) < 2 * this._minSeg, a || d)) e = !1;
- e && (m[2 * h] = this._positionR.x, m[2 * h + 1] = this._positionR.y, k[h] = 1, k = 8 * h, e = this._displayedColor, q[k] = e.r, q[k + 1] = e.g, q[k + 2] = e.b, q[k + 4] = e.r, q[k + 5] = e.g, q[k + 6] = e.b, q[k + 3] = 255, q[k + 7] = 255, 0 < h && this.fastMode && (1 < h ? cc.vertexLineToPolygon(m, this._stroke, this._vertices, h, 1) : cc.vertexLineToPolygon(m, this._stroke, this._vertices, 0, 2)), h++);
- this.fastMode || cc.vertexLineToPolygon(m, this._stroke, this._vertices, 0, h);
- if (h && this._previousNuPoints != h) {
- m = 1 / h;
- q = this._texCoords;
- for (e = 0; e < h; e++) q[4 * e] = 0, q[4 * e + 1] = m * e, q[2 * (2 * e + 1)] = 1, q[2 * (2 * e + 1) + 1] = m * e;
- this._previousNuPoints = h
- }
- this._nuPoints = h
- }
- }
- });
- cc.MotionStreak.create = function(a, c, d, e, f) {
- return new cc.MotionStreak(a, c, d, e, f)
- };
- cc.NodeGrid = cc.Node.extend({
- grid: null,
- _target: null,
- getGrid: function() {
- return this.grid
- },
- setGrid: function(a) {
- this.grid = a
- },
- setTarget: function(a) {
- this._target = a
- },
- addChild: function(a, c, d) {
- cc.Node.prototype.addChild.call(this, a, c, d);
- a && !this._target && (this._target = a)
- },
- visit: function() {
- if (this._visible) {
- var a = cc._renderType == cc._RENDER_TYPE_WEBGL,
- c = this.grid;
- a && (c && c._active) && c.beforeDraw();
- this.transform();
- var d = this._children;
- if (d && 0 < d.length) {
- var e = d.length;
- this.sortAllChildren();
- for (i = 0; i < e; i++) {
- var f = d[i];
- f && f.visit()
- }
- }
- a && (c && c._active) && c.afterDraw(this._target)
- }
- },
- _transformForWebGL: function() {
- var a = this._transform4x4,
- c = cc.current_stack.top,
- d = this.nodeToParentTransform(),
- e = a.mat;
- e[0] = d.a;
- e[4] = d.c;
- e[12] = d.tx;
- e[1] = d.b;
- e[5] = d.d;
- e[13] = d.ty;
- e[14] = this._vertexZ;
- cc.kmMat4Multiply(c, c, a);
- if (null != this._camera && (!this.grid || !this.grid.isActive())) a = this._anchorPointInPoints.x, c = this._anchorPointInPoints.y, 0 !== a || 0 !== c ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (a |= 0, c |= 0), cc.kmGLTranslatef(a, c, 0), this._camera.locate(), cc.kmGLTranslatef(-a, -c, 0)) : this._camera.locate()
- }
- });
- _p = cc.NodeGrid.prototype;
- cc._renderType === cc._RENDER_TYPE_WEBGL && (_p.transform = _p._transformForWebGL);
- cc.defineGetterSetter(_p, "target", null, _p.setTarget);
- cc.NodeGrid.create = function() {
- return new cc.NodeGrid
- };
- cc.v2fzero = function() {
- return {
- x: 0,
- y: 0
- }
- };
- cc.v2f = function(a, c) {
- return {
- x: a,
- y: c
- }
- };
- cc.v2fadd = function(a, c) {
- return cc.v2f(a.x + c.x, a.y + c.y)
- };
- cc.v2fsub = function(a, c) {
- return cc.v2f(a.x - c.x, a.y - c.y)
- };
- cc.v2fmult = function(a, c) {
- return cc.v2f(a.x * c, a.y * c)
- };
- cc.v2fperp = function(a) {
- return cc.v2f(-a.y, a.x)
- };
- cc.v2fneg = function(a) {
- return cc.v2f(-a.x, -a.y)
- };
- cc.v2fdot = function(a, c) {
- return a.x * c.x + a.y * c.y
- };
- cc.v2fforangle = function(a) {
- return cc.v2f(Math.cos(a), Math.sin(a))
- };
- cc.v2fnormalize = function(a) {
- a = cc.pNormalize(cc.p(a.x, a.y));
- return cc.v2f(a.x, a.y)
- };
- cc.__v2f = function(a) {
- return cc.v2f(a.x, a.y)
- };
- cc.__t = function(a) {
- return {
- u: a.x,
- v: a.y
- }
- };
- cc.DrawNodeCanvas = cc.Node.extend({
- _buffer: null,
- _blendFunc: null,
- _lineWidth: 1,
- _drawColor: null,
- _className: "DrawNodeCanvas",
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this._buffer = [];
- this._drawColor = cc.color(255, 255, 255, 255);
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- this.init()
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendFunc: function(a, c) {
- void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = c)
- },
- setLineWidth: function(a) {
- this._lineWidth = a
- },
- getLineWidth: function() {
- return this._lineWidth
- },
- setDrawColor: function(a) {
- var c = this._drawColor;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- c.a = null == a.a ? 255 : a.a
- },
- getDrawColor: function() {
- return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a)
- },
- drawRect: function(a, c, d, e, f) {
- e = e || this._lineWidth;
- f = f || this.getDrawColor();
- null == f.a && (f.a = 255);
- a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
- c = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- c.verts = a;
- c.lineWidth = e;
- c.lineColor = f;
- c.isClosePolygon = !0;
- c.isStroke = !0;
- c.lineCap = "butt";
- if (c.fillColor = d) null == d.a && (d.a = 255), c.isFill = !0;
- this._buffer.push(c)
- },
- drawCircle: function(a, c, d, e, f, g, h) {
- g = g || this._lineWidth;
- h = h || this.getDrawColor();
- null == h.a && (h.a = 255);
- for (var k = 2 * Math.PI / e, m = [], n = 0; n <= e; n++) {
- var q = n * k,
- r = c * Math.cos(q + d) + a.x,
- q = c * Math.sin(q + d) + a.y;
- m.push(cc.p(r, q))
- }
- f && m.push(cc.p(a.x, a.y));
- a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- a.verts = m;
- a.lineWidth = g;
- a.lineColor = h;
- a.isClosePolygon = !0;
- a.isStroke = !0;
- this._buffer.push(a)
- },
- drawQuadBezier: function(a, c, d, e, f, g) {
- f = f || this._lineWidth;
- g = g || this.getDrawColor();
- null == g.a && (g.a = 255);
- for (var h = [], k = 0, m = 0; m < e; m++) {
- var n = Math.pow(1 - k, 2) * a.x + 2 * (1 - k) * k * c.x + k * k * d.x,
- q = Math.pow(1 - k, 2) * a.y + 2 * (1 - k) * k * c.y + k * k * d.y;
- h.push(cc.p(n, q));
- k += 1 / e
- }
- h.push(cc.p(d.x, d.y));
- a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- a.verts = h;
- a.lineWidth = f;
- a.lineColor = g;
- a.isStroke = !0;
- a.lineCap = "round";
- this._buffer.push(a)
- },
- drawCubicBezier: function(a, c, d, e, f, g, h) {
- g = g || this._lineWidth;
- h = h || this.getDrawColor();
- null == h.a && (h.a = 255);
- for (var k = [], m = 0, n = 0; n < f; n++) {
- var q = Math.pow(1 - m, 3) * a.x + 3 * Math.pow(1 - m, 2) * m * c.x + 3 * (1 - m) * m * m * d.x + m * m * m * e.x,
- r = Math.pow(1 - m, 3) * a.y + 3 * Math.pow(1 - m, 2) * m * c.y + 3 * (1 - m) * m * m * d.y + m * m * m * e.y;
- k.push(cc.p(q, r));
- m += 1 / f
- }
- k.push(cc.p(e.x, e.y));
- a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- a.verts = k;
- a.lineWidth = g;
- a.lineColor = h;
- a.isStroke = !0;
- a.lineCap = "round";
- this._buffer.push(a)
- },
- drawCatmullRom: function(a, c, d, e) {
- this.drawCardinalSpline(a, 0.5, c, d, e)
- },
- drawCardinalSpline: function(a, c, d, e, f) {
- e = e || this._lineWidth;
- f = f || this.getDrawColor();
- null == f.a && (f.a = 255);
- for (var g = [], h, k, m = 1 / a.length, n = 0; n < d + 1; n++) k = n / d, 1 == k ? (h = a.length - 1, k = 1) : (h = 0 | k / m, k = (k - m * h) / m), h = cc.cardinalSplineAt(cc.getControlPointAt(a, h - 1), cc.getControlPointAt(a, h - 0), cc.getControlPointAt(a, h + 1), cc.getControlPointAt(a, h + 2), c, k), g.push(h);
- a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- a.verts = g;
- a.lineWidth = e;
- a.lineColor = f;
- a.isStroke = !0;
- a.lineCap = "round";
- this._buffer.push(a)
- },
- drawDot: function(a, c, d) {
- d = d || this.getDrawColor();
- null == d.a && (d.a = 255);
- var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);
- e.verts = [a];
- e.lineWidth = c;
- e.fillColor = d;
- this._buffer.push(e)
- },
- drawDots: function(a, c, d) {
- if (a && 0 != a.length) {
- d = d || this.getDrawColor();
- null == d.a && (d.a = 255);
- for (var e = 0, f = a.length; e < f; e++) this.drawDot(a[e], c, d)
- }
- },
- drawSegment: function(a, c, d, e) {
- d = d || this._lineWidth;
- e = e || this.getDrawColor();
- null == e.a && (e.a = 255);
- var f = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- f.verts = [a, c];
- f.lineWidth = 2 * d;
- f.lineColor = e;
- f.isStroke = !0;
- f.lineCap = "round";
- this._buffer.push(f)
- },
- drawPoly_: function(a, c, d, e) {
- d = d || this._lineWidth;
- e = e || this.getDrawColor();
- null == e.a && (e.a = 255);
- var f = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
- f.verts = a;
- f.fillColor = c;
- f.lineWidth = d;
- f.lineColor = e;
- f.isClosePolygon = !0;
- f.isStroke = !0;
- f.lineCap = "round";
- c && (f.isFill = !0);
- this._buffer.push(f)
- },
- drawPoly: function(a, c, d, e) {
- for (var f = [], g = 0; g < a.length; g++) f.push(cc.p(a[g].x, a[g].y));
- return this.drawPoly_(f, c, d, e)
- },
- draw: function(a) {
- a = a || cc._renderContext;
- this._blendFunc && (this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE) && (a.globalCompositeOperation = "lighter");
- for (var c = 0; c < this._buffer.length; c++) {
- var d = this._buffer[c];
- switch (d.type) {
- case cc.DrawNode.TYPE_DOT:
- this._drawDot(a, d);
- break;
- case cc.DrawNode.TYPE_SEGMENT:
- this._drawSegment(a, d);
- break;
- case cc.DrawNode.TYPE_POLY:
- this._drawPoly(a, d)
- }
- }
- },
- _drawDot: function(a, c) {
- var d = c.fillColor,
- e = c.verts[0],
- f = c.lineWidth,
- g = cc.view.getScaleX(),
- h = cc.view.getScaleY();
- a.fillStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + d.a / 255 + ")";
- a.beginPath();
- a.arc(e.x * g, -e.y * h, f * g, 0, 2 * Math.PI, !1);
- a.closePath();
- a.fill()
- },
- _drawSegment: function(a, c) {
- var d = c.lineColor,
- e = c.verts[0],
- f = c.verts[1],
- g = c.lineWidth,
- h = c.lineCap,
- k = cc.view.getScaleX(),
- m = cc.view.getScaleY();
- a.strokeStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + d.a / 255 + ")";
- a.lineWidth = g * k;
- a.beginPath();
- a.lineCap = h;
- a.moveTo(e.x * k, -e.y * m);
- a.lineTo(f.x * k, -f.y * m);
- a.stroke()
- },
- _drawPoly: function(a, c) {
- var d = c.verts,
- e = c.lineCap,
- f = c.fillColor,
- g = c.lineWidth,
- h = c.lineColor,
- k = c.isClosePolygon,
- m = c.isFill,
- n = c.isStroke;
- if (null != d) {
- var q = d[0],
- r = cc.view.getScaleX(),
- t = cc.view.getScaleY();
- a.lineCap = e;
- f && (a.fillStyle = "rgba(" + (0 | f.r) + "," + (0 | f.g) + "," + (0 | f.b) + "," + f.a / 255 + ")");
- g && (a.lineWidth = g * r);
- h && (a.strokeStyle = "rgba(" + (0 | h.r) + "," + (0 | h.g) + "," + (0 | h.b) + "," + h.a / 255 + ")");
- a.beginPath();
- a.moveTo(q.x * r, -q.y * t);
- e = 1;
- for (f = d.length; e < f; e++) a.lineTo(d[e].x * r, -d[e].y * t);
- k && a.closePath();
- m && a.fill();
- n && a.stroke()
- }
- },
- clear: function() {
- this._buffer.length = 0
- }
- });
- cc.DrawNodeWebGL = cc.Node.extend({
- _bufferCapacity: 0,
- _buffer: null,
- _trianglesArrayBuffer: null,
- _trianglesWebBuffer: null,
- _trianglesReader: null,
- _lineWidth: 1,
- _drawColor: null,
- _blendFunc: null,
- _dirty: !1,
- _className: "DrawNodeWebGL",
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendFunc: function(a, c) {
- void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = c)
- },
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this._buffer = [];
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- this._drawColor = cc.color(255, 255, 255, 255);
- this.init()
- },
- init: function() {
- return cc.Node.prototype.init.call(this) ? (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_LENGTHTEXTURECOLOR), this._ensureCapacity(64), this._trianglesWebBuffer = cc._renderContext.createBuffer(), this._dirty = !0) : !1
- },
- setLineWidth: function(a) {
- this._lineWidth = a
- },
- getLineWidth: function() {
- return this._lineWidth
- },
- setDrawColor: function(a) {
- var c = this._drawColor;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- c.a = a.a
- },
- getDrawColor: function() {
- return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a)
- },
- drawRect: function(a, c, d, e, f) {
- e = e || this._lineWidth;
- f = f || this.getDrawColor();
- null == f.a && (f.a = 255);
- a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
- null == d ? this._drawSegments(a, e, f, !0) : this.drawPoly(a, d, e, f)
- },
- drawCircle: function(a, c, d, e, f, g, h) {
- g = g || this._lineWidth;
- h = h || this.getDrawColor();
- null == h.a && (h.a = 255);
- var k = 2 * Math.PI / e,
- m = [],
- n;
- for (n = 0; n <= e; n++) {
- var q = n * k,
- r = c * Math.cos(q + d) + a.x,
- q = c * Math.sin(q + d) + a.y;
- m.push(cc.p(r, q))
- }
- f && m.push(cc.p(a.x, a.y));
- g *= 0.5;
- n = 0;
- for (a = m.length; n < a - 1; n++) this.drawSegment(m[n], m[n + 1], g, h)
- },
- drawQuadBezier: function(a, c, d, e, f, g) {
- f = f || this._lineWidth;
- g = g || this.getDrawColor();
- null == g.a && (g.a = 255);
- for (var h = [], k = 0, m = 0; m < e; m++) {
- var n = Math.pow(1 - k, 2) * a.x + 2 * (1 - k) * k * c.x + k * k * d.x,
- q = Math.pow(1 - k, 2) * a.y + 2 * (1 - k) * k * c.y + k * k * d.y;
- h.push(cc.p(n, q));
- k += 1 / e
- }
- h.push(cc.p(d.x, d.y));
- this._drawSegments(h, f, g, !1)
- },
- drawCubicBezier: function(a, c, d, e, f, g, h) {
- g = g || this._lineWidth;
- h = h || this.getDrawColor();
- null == h.a && (h.a = 255);
- for (var k = [], m = 0, n = 0; n < f; n++) {
- var q = Math.pow(1 - m, 3) * a.x + 3 * Math.pow(1 - m, 2) * m * c.x + 3 * (1 - m) * m * m * d.x + m * m * m * e.x,
- r = Math.pow(1 - m, 3) * a.y + 3 * Math.pow(1 - m, 2) * m * c.y + 3 * (1 - m) * m * m * d.y + m * m * m * e.y;
- k.push(cc.p(q, r));
- m += 1 / f
- }
- k.push(cc.p(e.x, e.y));
- this._drawSegments(k, g, h, !1)
- },
- drawCatmullRom: function(a, c, d, e) {
- this.drawCardinalSpline(a, 0.5, c, d, e)
- },
- drawCardinalSpline: function(a, c, d, e, f) {
- e = e || this._lineWidth;
- f = f || this.getDrawColor();
- null == f.a && (f.a = 255);
- for (var g = [], h, k, m = 1 / a.length, n = 0; n < d + 1; n++) k = n / d, 1 == k ? (h = a.length - 1, k = 1) : (h = 0 | k / m, k = (k - m * h) / m), h = cc.cardinalSplineAt(cc.getControlPointAt(a, h - 1), cc.getControlPointAt(a, h - 0), cc.getControlPointAt(a, h + 1), cc.getControlPointAt(a, h + 2), c, k), g.push(h);
- e *= 0.5;
- a = 0;
- for (c = g.length; a < c - 1; a++) this.drawSegment(g[a], g[a + 1], e, f)
- },
- _render: function() {
- var a = cc._renderContext;
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
- a.bindBuffer(a.ARRAY_BUFFER, this._trianglesWebBuffer);
- this._dirty && (a.bufferData(a.ARRAY_BUFFER, this._trianglesArrayBuffer, a.STREAM_DRAW), this._dirty = !1);
- var c = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, c, 0);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, c, 8);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, c, 12);
- a.drawArrays(a.TRIANGLES, 0, 3 * this._buffer.length);
- cc.incrementGLDraws(1)
- },
- _ensureCapacity: function(a) {
- var c = this._buffer;
- if (c.length + a > this._bufferCapacity) {
- var d = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
- this._bufferCapacity += Math.max(this._bufferCapacity, a);
- if (null == c || 0 === c.length) this._buffer = [], this._trianglesArrayBuffer = new ArrayBuffer(d * this._bufferCapacity), this._trianglesReader = new Uint8Array(this._trianglesArrayBuffer);
- else {
- a = [];
- for (var e = new ArrayBuffer(d * this._bufferCapacity), f = 0; f < c.length; f++) a[f] = new cc.V2F_C4B_T2F_Triangle(c[f].a, c[f].b, c[f].c, e, f * d);
- this._trianglesReader = new Uint8Array(e);
- this._trianglesArrayBuffer = e;
- this._buffer = a
- }
- }
- },
- draw: function() {
- cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
- this._shaderProgram.use();
- this._shaderProgram.setUniformsForBuiltins();
- this._render()
- },
- drawDot: function(a, c, d) {
- d = d || this.getDrawColor();
- null == d.a && (d.a = 255);
- var e = {
- r: 0 | d.r,
- g: 0 | d.g,
- b: 0 | d.b,
- a: 0 | d.a
- };
- d = {
- vertices: {
- x: a.x - c,
- y: a.y - c
- },
- colors: e,
- texCoords: {
- u: -1,
- v: -1
- }
- };
- var f = {
- vertices: {
- x: a.x - c,
- y: a.y + c
- },
- colors: e,
- texCoords: {
- u: -1,
- v: 1
- }
- },
- g = {
- vertices: {
- x: a.x + c,
- y: a.y + c
- },
- colors: e,
- texCoords: {
- u: 1,
- v: 1
- }
- };
- a = {
- vertices: {
- x: a.x + c,
- y: a.y - c
- },
- colors: e,
- texCoords: {
- u: 1,
- v: -1
- }
- };
- this._ensureCapacity(6);
- this._buffer.push(new cc.V2F_C4B_T2F_Triangle(d, f, g, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));
- this._buffer.push(new cc.V2F_C4B_T2F_Triangle(d, g, a, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));
- this._dirty = !0
- },
- drawDots: function(a, c, d) {
- if (a && 0 != a.length) {
- d = d || this.getDrawColor();
- null == d.a && (d.a = 255);
- for (var e = 0, f = a.length; e < f; e++) this.drawDot(a[e], c, d)
- }
- },
- drawSegment: function(a, c, d, e) {
- e = e || this.getDrawColor();
- null == e.a && (e.a = 255);
- d = d || 0.5 * this._lineWidth;
- this._ensureCapacity(18);
- e = {
- r: 0 | e.r,
- g: 0 | e.g,
- b: 0 | e.b,
- a: 0 | e.a
- };
- var f = cc.__v2f(a),
- g = cc.__v2f(c);
- c = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g, f)));
- a = cc.v2fperp(c);
- var h = cc.v2fmult(c, d),
- k = cc.v2fmult(a, d);
- d = cc.v2fsub(g, cc.v2fadd(h, k));
- var m = cc.v2fadd(g, cc.v2fsub(h, k)),
- n = cc.v2fsub(g, h),
- g = cc.v2fadd(g, h),
- q = cc.v2fsub(f, h),
- r = cc.v2fadd(f, h),
- t = cc.v2fsub(f, cc.v2fsub(h, k)),
- f = cc.v2fadd(f, cc.v2fadd(h, k)),
- h = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
- k = this._trianglesArrayBuffer,
- s = this._buffer;
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: d,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(cc.v2fadd(c, a)))
- }, {
- vertices: m,
- colors: e,
- texCoords: cc.__t(cc.v2fsub(c, a))
- }, {
- vertices: n,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, k, s.length * h));
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: g,
- colors: e,
- texCoords: cc.__t(c)
- }, {
- vertices: m,
- colors: e,
- texCoords: cc.__t(cc.v2fsub(c, a))
- }, {
- vertices: n,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, k, s.length * h));
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: g,
- colors: e,
- texCoords: cc.__t(c)
- }, {
- vertices: q,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, {
- vertices: n,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, k, s.length * h));
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: g,
- colors: e,
- texCoords: cc.__t(c)
- }, {
- vertices: q,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, {
- vertices: r,
- colors: e,
- texCoords: cc.__t(c)
- }, k, s.length * h));
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: t,
- colors: e,
- texCoords: cc.__t(cc.v2fsub(a, c))
- }, {
- vertices: q,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(c))
- }, {
- vertices: r,
- colors: e,
- texCoords: cc.__t(c)
- }, k, s.length * h));
- s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: t,
- colors: e,
- texCoords: cc.__t(cc.v2fsub(a, c))
- }, {
- vertices: f,
- colors: e,
- texCoords: cc.__t(cc.v2fadd(c, a))
- }, {
- vertices: r,
- colors: e,
- texCoords: cc.__t(c)
- }, k, s.length * h));
- this._dirty = !0
- },
- drawPoly: function(a, c, d, e) {
- if (null == c) this._drawSegments(a, d, e, !0);
- else {
- null == c.a && (c.a = 255);
- null == e.a && (e.a = 255);
- d = d || this._lineWidth;
- d *= 0.5;
- c = {
- r: 0 | c.r,
- g: 0 | c.g,
- b: 0 | c.b,
- a: 0 | c.a
- };
- e = {
- r: 0 | e.r,
- g: 0 | e.g,
- b: 0 | e.b,
- a: 0 | e.a
- };
- var f = [],
- g, h, k, m, n = a.length;
- for (g = 0; g < n; g++) {
- h = cc.__v2f(a[(g - 1 + n) % n]);
- k = cc.__v2f(a[g]);
- m = cc.__v2f(a[(g + 1) % n]);
- var q = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
- k = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(m, k)));
- q = cc.v2fmult(cc.v2fadd(q, k), 1 / (cc.v2fdot(q, k) + 1));
- f[g] = {
- offset: q,
- n: k
- }
- }
- q = 0 < d;
- this._ensureCapacity(3 * (3 * n - 2));
- var r = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
- t = this._trianglesArrayBuffer,
- s = this._buffer,
- v = !1 == q ? 0.5 : 0;
- for (g = 0; g < n - 2; g++) h = cc.v2fsub(cc.__v2f(a[0]), cc.v2fmult(f[0].offset, v)), k = cc.v2fsub(cc.__v2f(a[g + 1]), cc.v2fmult(f[g + 1].offset, v)), m = cc.v2fsub(cc.__v2f(a[g + 2]), cc.v2fmult(f[g + 2].offset, v)), s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: h,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, {
- vertices: k,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, {
- vertices: m,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, t, s.length * r));
- for (g = 0; g < n; g++) {
- v = (g + 1) % n;
- h = cc.__v2f(a[g]);
- k = cc.__v2f(a[v]);
- m = f[g].n;
- var u = f[g].offset,
- x = f[v].offset,
- v = q ? cc.v2fsub(h, cc.v2fmult(u, d)) : cc.v2fsub(h, cc.v2fmult(u, 0.5)),
- A = q ? cc.v2fsub(k, cc.v2fmult(x, d)) : cc.v2fsub(k, cc.v2fmult(x, 0.5));
- h = q ? cc.v2fadd(h, cc.v2fmult(u, d)) : cc.v2fadd(h, cc.v2fmult(u, 0.5));
- k = q ? cc.v2fadd(k, cc.v2fmult(x, d)) : cc.v2fadd(k, cc.v2fmult(x, 0.5));
- q ? (s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: v,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(m))
- }, {
- vertices: A,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(m))
- }, {
- vertices: k,
- colors: e,
- texCoords: cc.__t(m)
- }, t, s.length * r)), s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: v,
- colors: e,
- texCoords: cc.__t(cc.v2fneg(m))
- }, {
- vertices: h,
- colors: e,
- texCoords: cc.__t(m)
- }, {
- vertices: k,
- colors: e,
- texCoords: cc.__t(m)
- }, t, s.length * r))) : (s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: v,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, {
- vertices: A,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, {
- vertices: k,
- colors: c,
- texCoords: cc.__t(m)
- }, t, s.length * r)), s.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: v,
- colors: c,
- texCoords: cc.__t(cc.v2fzero())
- }, {
- vertices: h,
- colors: c,
- texCoords: cc.__t(m)
- }, {
- vertices: k,
- colors: c,
- texCoords: cc.__t(m)
- }, t, s.length * r)))
- }
- this._dirty = !0
- }
- },
- _drawSegments: function(a, c, d, e) {
- c = c || this._lineWidth;
- d = d || this._drawColor;
- null == d.a && (d.a = 255);
- c *= 0.5;
- if (!(0 >= c)) {
- d = {
- r: 0 | d.r,
- g: 0 | d.g,
- b: 0 | d.b,
- a: 0 | d.a
- };
- var f = [],
- g, h, k, m, n = a.length;
- for (g = 0; g < n; g++) {
- h = cc.__v2f(a[(g - 1 + n) % n]);
- k = cc.__v2f(a[g]);
- m = cc.__v2f(a[(g + 1) % n]);
- var q = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
- k = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(m, k)));
- m = cc.v2fmult(cc.v2fadd(q, k), 1 / (cc.v2fdot(q, k) + 1));
- f[g] = {
- offset: m,
- n: k
- }
- }
- this._ensureCapacity(3 * (3 * n - 2));
- m = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
- var q = this._trianglesArrayBuffer,
- r = this._buffer;
- e = e ? n : n - 1;
- for (g = 0; g < e; g++) {
- var t = (g + 1) % n;
- h = cc.__v2f(a[g]);
- k = cc.__v2f(a[t]);
- var s = f[g].n,
- v = f[g].offset,
- u = f[t].offset,
- t = cc.v2fsub(h, cc.v2fmult(v, c)),
- x = cc.v2fsub(k, cc.v2fmult(u, c));
- h = cc.v2fadd(h, cc.v2fmult(v, c));
- k = cc.v2fadd(k, cc.v2fmult(u, c));
- r.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: t,
- colors: d,
- texCoords: cc.__t(cc.v2fneg(s))
- }, {
- vertices: x,
- colors: d,
- texCoords: cc.__t(cc.v2fneg(s))
- }, {
- vertices: k,
- colors: d,
- texCoords: cc.__t(s)
- }, q, r.length * m));
- r.push(new cc.V2F_C4B_T2F_Triangle({
- vertices: t,
- colors: d,
- texCoords: cc.__t(cc.v2fneg(s))
- }, {
- vertices: h,
- colors: d,
- texCoords: cc.__t(s)
- }, {
- vertices: k,
- colors: d,
- texCoords: cc.__t(s)
- }, q, r.length * m))
- }
- this._dirty = !0
- }
- },
- clear: function() {
- this._buffer.length = 0;
- this._dirty = !0
- }
- });
- cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas;
- cc.DrawNode.create = function() {
- return new cc.DrawNode
- };
- cc._DrawNodeElement = function(a, c, d, e, f, g, h, k, m) {
- this.type = a;
- this.verts = c || null;
- this.fillColor = d || null;
- this.lineWidth = e || 0;
- this.lineColor = f || null;
- this.lineCap = g || "butt";
- this.isClosePolygon = h || !1;
- this.isFill = k || !1;
- this.isStroke = m || !1
- };
- cc.DrawNode.TYPE_DOT = 0;
- cc.DrawNode.TYPE_SEGMENT = 1;
- cc.DrawNode.TYPE_POLY = 2;
- cc.stencilBits = -1;
- cc.setProgram = function(a, c) {
- a.shaderProgram = c;
- var d = a.children;
- if (d)
- for (var e = 0; e < d.length; e++) cc.setProgram(d[e], c)
- };
- cc.ClippingNode = cc.Node.extend({
- alphaThreshold: 0,
- inverted: !1,
- _stencil: null,
- _godhelpme: !1,
- ctor: function(a) {
- cc.Node.prototype.ctor.call(this);
- this._stencil = null;
- this.alphaThreshold = 0;
- this.inverted = !1;
- cc.ClippingNode.prototype.init.call(this, a || null)
- },
- init: null,
- _className: "ClippingNode",
- _initForWebGL: function(a) {
- this._stencil = a;
- this.alphaThreshold = 1;
- this.inverted = !1;
- cc.ClippingNode._init_once = !0;
- cc.ClippingNode._init_once && (cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS), 0 >= cc.stencilBits && cc.log("Stencil buffer is not enabled."), cc.ClippingNode._init_once = !1);
- return !0
- },
- _initForCanvas: function(a) {
- this._stencil = a;
- this.alphaThreshold = 1;
- this.inverted = !1
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- this._stencil.onEnter()
- },
- onEnterTransitionDidFinish: function() {
- cc.Node.prototype.onEnterTransitionDidFinish.call(this);
- this._stencil.onEnterTransitionDidFinish()
- },
- onExitTransitionDidStart: function() {
- this._stencil.onExitTransitionDidStart();
- cc.Node.prototype.onExitTransitionDidStart.call(this)
- },
- onExit: function() {
- this._stencil.onExit();
- cc.Node.prototype.onExit.call(this)
- },
- visit: null,
- _visitForWebGL: function(a) {
- var c = a || cc._renderContext;
- if (1 > cc.stencilBits) cc.Node.prototype.visit.call(this, a);
- else if (!this._stencil || !this._stencil.visible) this.inverted && cc.Node.prototype.visit.call(this, a);
- else if (cc.ClippingNode._layer + 1 == cc.stencilBits) cc.ClippingNode._visit_once = !0, cc.ClippingNode._visit_once && (cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."), cc.ClippingNode._visit_once = !1), cc.Node.prototype.visit.call(this, a);
- else {
- cc.ClippingNode._layer++;
- var d = 1 << cc.ClippingNode._layer,
- e = d | d - 1,
- f = c.isEnabled(c.STENCIL_TEST),
- g = c.getParameter(c.STENCIL_WRITEMASK),
- h = c.getParameter(c.STENCIL_FUNC),
- k = c.getParameter(c.STENCIL_REF),
- m = c.getParameter(c.STENCIL_VALUE_MASK),
- n = c.getParameter(c.STENCIL_FAIL),
- q = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL),
- r = c.getParameter(c.STENCIL_PASS_DEPTH_PASS);
- c.enable(c.STENCIL_TEST);
- c.stencilMask(d);
- var t = c.getParameter(c.DEPTH_WRITEMASK);
- c.depthMask(!1);
- c.stencilFunc(c.NEVER, d, d);
- c.stencilOp(!this.inverted ? c.ZERO : c.REPLACE, c.KEEP, c.KEEP);
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPushMatrix();
- cc.kmGLLoadIdentity();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPushMatrix();
- cc.kmGLLoadIdentity();
- cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255));
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPopMatrix();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPopMatrix();
- c.stencilFunc(c.NEVER, d, d);
- c.stencilOp(!this.inverted ? c.REPLACE : c.ZERO, c.KEEP, c.KEEP);
- if (1 > this.alphaThreshold) {
- var d = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),
- s = c.getUniformLocation(d.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
- cc.glUseProgram(d.getProgram());
- d.setUniformLocationWith1f(s, this.alphaThreshold);
- cc.setProgram(this._stencil, d)
- }
- cc.kmGLPushMatrix();
- this.transform();
- this._stencil.visit();
- cc.kmGLPopMatrix();
- c.depthMask(t);
- c.stencilFunc(c.EQUAL, e, e);
- c.stencilOp(c.KEEP, c.KEEP, c.KEEP);
- cc.Node.prototype.visit.call(this, a);
- c.stencilFunc(h, k, m);
- c.stencilOp(n, q, r);
- c.stencilMask(g);
- f || c.disable(c.STENCIL_TEST);
- cc.ClippingNode._layer--
- }
- },
- _visitForCanvas: function(a) {
- if (!this._stencil || !this._stencil.visible) this.inverted && cc.Node.prototype.visit.call(this, a);
- else {
- a = a || cc._renderContext;
- var c = a.canvas;
- if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) {
- var d = cc.ClippingNode._getSharedCache();
- d.width = c.width;
- d.height = c.height;
- d.getContext("2d").drawImage(c, 0, 0);
- a.save();
- cc.Node.prototype.visit.call(this, a);
- a.globalCompositeOperation = this.inverted ? "destination-out" : "destination-in";
- this.transform(a);
- this._stencil.visit();
- a.restore();
- a.save();
- a.setTransform(1, 0, 0, 1, 0, 0);
- a.globalCompositeOperation = "destination-over";
- a.drawImage(d, 0, 0)
- } else {
- var d = this._children,
- e;
- a.save();
- this.transform(a);
- this._stencil.visit(a);
- this.inverted && (a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.moveTo(0, 0), a.lineTo(0, c.height), a.lineTo(c.width, c.height), a.lineTo(c.width, 0), a.lineTo(0, 0), a.restore());
- a.clip();
- this._cangodhelpme(!0);
- var f = d.length;
- if (0 < f) {
- this.sortAllChildren();
- for (c = 0; c < f; c++)
- if (e = d[c], 0 > e._localZOrder) e.visit(a);
- else break;
- for (this.draw(a); c < f; c++) d[c].visit(a)
- } else this.draw(a);
- this._cangodhelpme(!1)
- }
- a.restore()
- }
- },
- getStencil: function() {
- return this._stencil
- },
- setStencil: null,
- _setStencilForWebGL: function(a) {
- this._stencil = a
- },
- _setStencilForCanvas: function(a) {
- this._stencil = a;
- var c = cc._renderContext;
- !(a instanceof cc.Sprite) && a instanceof cc.DrawNode && (a.draw = function() {
- var d = cc.view.getScaleX(),
- e = cc.view.getScaleY();
- c.beginPath();
- for (var f = 0; f < a._buffer.length; f++) {
- var g = a._buffer[f].verts,
- h = g[0];
- c.moveTo(h.x * d, -h.y * e);
- for (var h = 1, k = g.length; h < k; h++) c.lineTo(g[h].x * d, -g[h].y * e)
- }
- })
- },
- getAlphaThreshold: function() {
- return this.alphaThreshold
- },
- setAlphaThreshold: function(a) {
- this.alphaThreshold = a
- },
- isInverted: function() {
- return this.inverted
- },
- setInverted: function(a) {
- this.inverted = a
- },
- _cangodhelpme: function(a) {
- if (!0 === a || !1 === a) cc.ClippingNode.prototype._godhelpme = a;
- return cc.ClippingNode.prototype._godhelpme
- }
- });
- _p = cc.ClippingNode.prototype;
- cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.init = _p._initForWebGL, _p.visit = _p._visitForWebGL, _p.setStencil = _p._setStencilForWebGL) : (_p.init = _p._initForCanvas, _p.visit = _p._visitForCanvas, _p.setStencil = _p._setStencilForCanvas);
- cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil);
- cc.ClippingNode._init_once = null;
- cc.ClippingNode._visit_once = null;
- cc.ClippingNode._layer = -1;
- cc.ClippingNode._sharedCache = null;
- cc.ClippingNode._getSharedCache = function() {
- return cc.ClippingNode._sharedCache || (cc.ClippingNode._sharedCache = document.createElement("canvas"))
- };
- cc.ClippingNode.create = function(a) {
- return new cc.ClippingNode(a)
- };
- cc.GridBase = cc.Class.extend({
- _active: !1,
- _reuseGrid: 0,
- _gridSize: null,
- _texture: null,
- _step: null,
- _grabber: null,
- _isTextureFlipped: !1,
- _shaderProgram: null,
- _directorProjection: 0,
- _dirty: !1,
- ctor: function(a, c, d) {
- cc._checkWebGLRenderMode();
- this._active = !1;
- this._reuseGrid = 0;
- this._texture = this._gridSize = null;
- this._step = cc.p(0, 0);
- this._grabber = null;
- this._isTextureFlipped = !1;
- this._shaderProgram = null;
- this._directorProjection = 0;
- this._dirty = !1;
- void 0 !== a && this.initWithSize(a, c, d)
- },
- isActive: function() {
- return this._active
- },
- setActive: function(a) {
- this._active = a;
- if (!a) {
- a = cc.director;
- var c = a.getProjection();
- a.setProjection(c)
- }
- },
- getReuseGrid: function() {
- return this._reuseGrid
- },
- setReuseGrid: function(a) {
- this._reuseGrid = a
- },
- getGridSize: function() {
- return cc.size(this._gridSize.width, this._gridSize.height)
- },
- setGridSize: function(a) {
- this._gridSize.width = parseInt(a.width);
- this._gridSize.height = parseInt(a.height)
- },
- getStep: function() {
- return cc.p(this._step.x, this._step.y)
- },
- setStep: function(a) {
- this._step.x = a.x;
- this._step.y = a.y
- },
- isTextureFlipped: function() {
- return this._isTextureFlipped
- },
- setTextureFlipped: function(a) {
- this._isTextureFlipped != a && (this._isTextureFlipped = a, this.calculateVertexPoints())
- },
- initWithSize: function(a, c, d) {
- if (!c) {
- var e = cc.director.getWinSizeInPixels(),
- f = cc.NextPOT(e.width),
- g = cc.NextPOT(e.height),
- h = new Uint8Array(4 * f * g);
- if (!h) return cc.log("cocos2d: CCGrid: not enough memory."), !1;
- c = new cc.Texture2D;
- c.initWithData(h, cc.Texture2D.PIXEL_FORMAT_RGBA8888, f, g, e);
- if (!c) return cc.log("cocos2d: CCGrid: error creating texture"), !1
- }
- this._active = !1;
- this._reuseGrid = 0;
- this._gridSize = a;
- this._texture = c;
- this._isTextureFlipped = d || !1;
- this._step.x = this._texture.width / a.width;
- this._step.y = this._texture.height / a.height;
- this._grabber = new cc.Grabber;
- if (!this._grabber) return !1;
- this._grabber.grab(this._texture);
- this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
- this.calculateVertexPoints();
- return !0
- },
- beforeDraw: function() {
- this._directorProjection = cc.director.getProjection();
- this.set2DProjection();
- this._grabber.beforeRender(this._texture)
- },
- afterDraw: function(a) {
- this._grabber.afterRender(this._texture);
- cc.director.setProjection(this._directorProjection);
- if (a.getCamera().isDirty()) {
- var c = a.getAnchorPointInPoints();
- cc.kmGLTranslatef(c.x, c.y, 0);
- a.getCamera().locate();
- cc.kmGLTranslatef(-c.x, -c.y, 0)
- }
- cc.glBindTexture2D(this._texture);
- this.blit()
- },
- blit: function() {
- cc.log("cc.GridBase.blit(): Shall be overridden in subclass.")
- },
- reuse: function() {
- cc.log("cc.GridBase.reuse(): Shall be overridden in subclass.")
- },
- calculateVertexPoints: function() {
- cc.log("cc.GridBase.calculateVertexPoints(): Shall be overridden in subclass.")
- },
- set2DProjection: function() {
- var a = cc.director.getWinSizeInPixels();
- cc._renderContext.viewport(0, 0, a.width, a.height);
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLLoadIdentity();
- var c = new cc.kmMat4;
- cc.kmMat4OrthographicProjection(c, 0, a.width, 0, a.height, -1, 1);
- cc.kmGLMultMatrix(c);
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLLoadIdentity();
- cc.setProjectionMatrixDirty()
- }
- });
- cc.GridBase.create = function(a, c, d) {
- return new cc.GridBase(a, c, d)
- };
- cc.Grid3D = cc.GridBase.extend({
- _texCoordinates: null,
- _vertices: null,
- _originalVertices: null,
- _indices: null,
- _texCoordinateBuffer: null,
- _verticesBuffer: null,
- _indicesBuffer: null,
- ctor: function(a, c, d) {
- cc.GridBase.prototype.ctor.call(this);
- this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
- void 0 !== a && this.initWithSize(a, c, d)
- },
- vertex: function(a) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.vertex() : Numbers must be integers");
- a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
- var c = this._vertices;
- return new cc.Vertex3F(c[a], c[a + 1], c[a + 2])
- },
- originalVertex: function(a) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.originalVertex() : Numbers must be integers");
- a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
- var c = this._originalVertices;
- return new cc.Vertex3F(c[a], c[a + 1], c[a + 2])
- },
- setVertex: function(a, c) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.setVertex() : Numbers must be integers");
- var d = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y),
- e = this._vertices;
- e[d] = c.x;
- e[d + 1] = c.y;
- e[d + 2] = c.z;
- this._dirty = !0
- },
- blit: function() {
- var a = this._gridSize.width * this._gridSize.height;
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
- this._shaderProgram.use();
- this._shaderProgram.setUniformsForBuiltins();
- var c = cc._renderContext,
- d = this._dirty;
- c.bindBuffer(c.ARRAY_BUFFER, this._verticesBuffer);
- d && c.bufferData(c.ARRAY_BUFFER, this._vertices, c.DYNAMIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, c.FLOAT, !1, 0, 0);
- c.bindBuffer(c.ARRAY_BUFFER, this._texCoordinateBuffer);
- d && c.bufferData(c.ARRAY_BUFFER, this._texCoordinates, c.DYNAMIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, 0);
- c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
- d && c.bufferData(c.ELEMENT_ARRAY_BUFFER, this._indices, c.STATIC_DRAW);
- c.drawElements(c.TRIANGLES, 6 * a, c.UNSIGNED_SHORT, 0);
- d && (this._dirty = !1);
- cc.incrementGLDraws(1)
- },
- reuse: function() {
- if (0 < this._reuseGrid) {
- for (var a = this._originalVertices, c = this._vertices, d = 0, e = this._vertices.length; d < e; d++) a[d] = c[d];
- --this._reuseGrid
- }
- },
- calculateVertexPoints: function() {
- var a = cc._renderContext,
- c = this._texture.pixelsWidth,
- d = this._texture.pixelsHeight,
- e = this._texture.getContentSizeInPixels().height,
- f = this._gridSize,
- g = (f.width + 1) * (f.height + 1);
- this._vertices = new Float32Array(3 * g);
- this._texCoordinates = new Float32Array(2 * g);
- this._indices = new Uint16Array(6 * f.width * f.height);
- this._verticesBuffer && a.deleteBuffer(this._verticesBuffer);
- this._verticesBuffer = a.createBuffer();
- this._texCoordinateBuffer && a.deleteBuffer(this._texCoordinateBuffer);
- this._texCoordinateBuffer = a.createBuffer();
- this._indicesBuffer && a.deleteBuffer(this._indicesBuffer);
- this._indicesBuffer = a.createBuffer();
- for (var h, k, m = this._indices, n = this._texCoordinates, q = this._isTextureFlipped, r = this._vertices, g = 0; g < f.width; ++g)
- for (h = 0; h < f.height; ++h) {
- var t = h * f.width + g;
- k = g * this._step.x;
- var s = k + this._step.x,
- v = h * this._step.y,
- u = v + this._step.y,
- x = g * (f.height + 1) + h,
- A = (g + 1) * (f.height + 1) + h,
- D = (g + 1) * (f.height + 1) + (h + 1),
- F = g * (f.height + 1) + (h + 1);
- m[6 * t] = x;
- m[6 * t + 1] = A;
- m[6 * t + 2] = F;
- m[6 * t + 3] = A;
- m[6 * t + 4] = D;
- m[6 * t + 5] = F;
- var t = [3 * x, 3 * A, 3 * D, 3 * F],
- y = [{
- x: k,
- y: v,
- z: 0
- }, {
- x: s,
- y: v,
- z: 0
- }, {
- x: s,
- y: u,
- z: 0
- }, {
- x: k,
- y: u,
- z: 0
- }],
- x = [2 * x, 2 * A, 2 * D, 2 * F],
- s = [cc.p(k, v), cc.p(s, v), cc.p(s, u), cc.p(k, u)];
- for (k = 0; 4 > k; ++k) r[t[k]] = y[k].x, r[t[k] + 1] = y[k].y, r[t[k] + 2] = y[k].z, n[x[k]] = s[k].x / c, n[x[k] + 1] = q ? (e - s[k].y) / d : s[k].y / d
- }
- this._originalVertices = new Float32Array(this._vertices);
- a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer);
- a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW);
- a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
- a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW);
- this._dirty = !0
- }
- });
- cc.Grid3D.create = function(a, c, d) {
- return new cc.Grid3D(a, c, d)
- };
- cc.TiledGrid3D = cc.GridBase.extend({
- _texCoordinates: null,
- _vertices: null,
- _originalVertices: null,
- _indices: null,
- _texCoordinateBuffer: null,
- _verticesBuffer: null,
- _indicesBuffer: null,
- ctor: function(a, c, d) {
- cc.GridBase.prototype.ctor.call(this);
- this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
- void 0 !== a && this.initWithSize(a, c, d)
- },
- tile: function(a) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.tile() : Numbers must be integers");
- a = 12 * (this._gridSize.height * a.x + a.y);
- var c = this._vertices;
- return new cc.Quad3(new cc.Vertex3F(c[a], c[a + 1], c[a + 2]), new cc.Vertex3F(c[a + 3], c[a + 4], c[a + 5]), new cc.Vertex3F(c[a + 6], c[a + 7], c[a + 8]), new cc.Vertex3F(c[a + 9], c[a + 10], c[a + 11]))
- },
- originalTile: function(a) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers");
- a = 12 * (this._gridSize.height * a.x + a.y);
- var c = this._originalVertices;
- return new cc.Quad3(new cc.Vertex3F(c[a], c[a + 1], c[a + 2]), new cc.Vertex3F(c[a + 3], c[a + 4], c[a + 5]), new cc.Vertex3F(c[a + 6], c[a + 7], c[a + 8]), new cc.Vertex3F(c[a + 9], c[a + 10], c[a + 11]))
- },
- setTile: function(a, c) {
- (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers");
- var d = 12 * (this._gridSize.height * a.x + a.y),
- e = this._vertices;
- e[d] = c.bl.x;
- e[d + 1] = c.bl.y;
- e[d + 2] = c.bl.z;
- e[d + 3] = c.br.x;
- e[d + 4] = c.br.y;
- e[d + 5] = c.br.z;
- e[d + 6] = c.tl.x;
- e[d + 7] = c.tl.y;
- e[d + 8] = c.tl.z;
- e[d + 9] = c.tr.x;
- e[d + 10] = c.tr.y;
- e[d + 11] = c.tr.z;
- this._dirty = !0
- },
- blit: function() {
- var a = this._gridSize.width * this._gridSize.height;
- this._shaderProgram.use();
- this._shaderProgram.setUniformsForBuiltins();
- var c = cc._renderContext,
- d = this._dirty;
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
- c.bindBuffer(c.ARRAY_BUFFER, this._verticesBuffer);
- d && c.bufferData(c.ARRAY_BUFFER, this._vertices, c.DYNAMIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, c.FLOAT, !1, 0, this._vertices);
- c.bindBuffer(c.ARRAY_BUFFER, this._texCoordinateBuffer);
- d && c.bufferData(c.ARRAY_BUFFER, this._texCoordinates, c.DYNAMIC_DRAW);
- c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, this._texCoordinates);
- c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
- d && c.bufferData(c.ELEMENT_ARRAY_BUFFER, this._indices, c.STATIC_DRAW);
- c.drawElements(c.TRIANGLES, 6 * a, c.UNSIGNED_SHORT, 0);
- d && (this._dirty = !1);
- cc.incrementGLDraws(1)
- },
- reuse: function() {
- if (0 < this._reuseGrid) {
- for (var a = this._vertices, c = this._originalVertices, d = 0; d < a.length; d++) c[d] = a[d];
- --this._reuseGrid
- }
- },
- calculateVertexPoints: function() {
- var a = this._texture.pixelsWidth,
- c = this._texture.pixelsHeight,
- d = this._texture.getContentSizeInPixels().height,
- e = this._gridSize,
- f = e.width * e.height;
- this._vertices = new Float32Array(12 * f);
- this._texCoordinates = new Float32Array(8 * f);
- this._indices = new Uint16Array(6 * f);
- var g = cc._renderContext;
- this._verticesBuffer && g.deleteBuffer(this._verticesBuffer);
- this._verticesBuffer = g.createBuffer();
- this._texCoordinateBuffer && g.deleteBuffer(this._texCoordinateBuffer);
- this._texCoordinateBuffer = g.createBuffer();
- this._indicesBuffer && g.deleteBuffer(this._indicesBuffer);
- this._indicesBuffer = g.createBuffer();
- var h, k, m = 0,
- n = this._step,
- q = this._vertices,
- r = this._texCoordinates,
- t = this._isTextureFlipped;
- for (h = 0; h < e.width; h++)
- for (k = 0; k < e.height; k++) {
- var s = h * n.x,
- v = s + n.x,
- u = k * n.y,
- x = u + n.y;
- q[12 * m] = s;
- q[12 * m + 1] = u;
- q[12 * m + 2] = 0;
- q[12 * m + 3] = v;
- q[12 * m + 4] = u;
- q[12 * m + 5] = 0;
- q[12 * m + 6] = s;
- q[12 * m + 7] = x;
- q[12 * m + 8] = 0;
- q[12 * m + 9] = v;
- q[12 * m + 10] = x;
- q[12 * m + 11] = 0;
- var A = u,
- D = x;
- t && (A = d - u, D = d - x);
- r[8 * m] = s / a;
- r[8 * m + 1] = A / c;
- r[8 * m + 2] = v / a;
- r[8 * m + 3] = A / c;
- r[8 * m + 4] = s / a;
- r[8 * m + 5] = D / c;
- r[8 * m + 6] = v / a;
- r[8 * m + 7] = D / c;
- m++
- }
- a = this._indices;
- for (h = 0; h < f; h++) a[6 * h + 0] = 4 * h + 0, a[6 * h + 1] = 4 * h + 1, a[6 * h + 2] = 4 * h + 2, a[6 * h + 3] = 4 * h + 1, a[6 * h + 4] = 4 * h + 2, a[6 * h + 5] = 4 * h + 3;
- this._originalVertices = new Float32Array(this._vertices);
- g.bindBuffer(g.ARRAY_BUFFER, this._verticesBuffer);
- g.bufferData(g.ARRAY_BUFFER, this._vertices, g.DYNAMIC_DRAW);
- g.bindBuffer(g.ARRAY_BUFFER, this._texCoordinateBuffer);
- g.bufferData(g.ARRAY_BUFFER, this._texCoordinates, g.DYNAMIC_DRAW);
- g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
- g.bufferData(g.ELEMENT_ARRAY_BUFFER, this._indices, g.DYNAMIC_DRAW);
- this._dirty = !0
- }
- });
- cc.TiledGrid3D.create = function(a, c, d) {
- return new cc.TiledGrid3D(a, c, d)
- };
- cc.Grabber = cc.Class.extend({
- _FBO: null,
- _oldFBO: null,
- _oldClearColor: null,
- _gl: null,
- ctor: function() {
- cc._checkWebGLRenderMode();
- this._gl = cc._renderContext;
- this._oldClearColor = [0, 0, 0, 0];
- this._oldFBO = null;
- this._FBO = this._gl.createFramebuffer()
- },
- grab: function(a) {
- var c = this._gl;
- this._oldFBO = c.getParameter(c.FRAMEBUFFER_BINDING);
- c.bindFramebuffer(c.FRAMEBUFFER, this._FBO);
- c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, a._webTextureObj, 0);
- c.checkFramebufferStatus(c.FRAMEBUFFER) != c.FRAMEBUFFER_COMPLETE && cc.log("Frame Grabber: could not attach texture to frmaebuffer");
- c.bindFramebuffer(c.FRAMEBUFFER, this._oldFBO)
- },
- beforeRender: function(a) {
- a = this._gl;
- this._oldFBO = a.getParameter(a.FRAMEBUFFER_BINDING);
- a.bindFramebuffer(a.FRAMEBUFFER, this._FBO);
- this._oldClearColor = a.getParameter(a.COLOR_CLEAR_VALUE);
- a.clearColor(0, 0, 0, 0);
- a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
- },
- afterRender: function(a) {
- a = this._gl;
- a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
- a.colorMask(!0, !0, !0, !0)
- },
- destroy: function() {
- this._gl.deleteFramebuffer(this._FBO)
- }
- });
- cc.ACTION_TAG_INVALID = -1;
- cc.Action = cc.Class.extend({
- originalTarget: null,
- target: null,
- tag: cc.ACTION_TAG_INVALID,
- ctor: function() {
- this.target = this.originalTarget = null;
- this.tag = cc.ACTION_TAG_INVALID
- },
- copy: function() {
- cc.log("copy is deprecated. Please use clone instead.");
- return this.clone()
- },
- clone: function() {
- var a = new cc.Action;
- a.originalTarget = null;
- a.target = null;
- a.tag = this.tag;
- return a
- },
- isDone: function() {
- return !0
- },
- startWithTarget: function(a) {
- this.target = this.originalTarget = a
- },
- stop: function() {
- this.target = null
- },
- step: function(a) {
- cc.log("[Action step]. override me")
- },
- update: function(a) {
- cc.log("[Action update]. override me")
- },
- getTarget: function() {
- return this.target
- },
- setTarget: function(a) {
- this.target = a
- },
- getOriginalTarget: function() {
- return this.originalTarget
- },
- setOriginalTarget: function(a) {
- this.originalTarget = a
- },
- getTag: function() {
- return this.tag
- },
- setTag: function(a) {
- this.tag = a
- },
- retain: function() {},
- release: function() {}
- });
- cc.action = function() {
- return new cc.Action
- };
- cc.Action.create = cc.action;
- cc.FiniteTimeAction = cc.Action.extend({
- _duration: 0,
- ctor: function() {
- cc.Action.prototype.ctor.call(this);
- this._duration = 0
- },
- getDuration: function() {
- return this._duration * (this._times || 1)
- },
- setDuration: function(a) {
- this._duration = a
- },
- reverse: function() {
- cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");
- return null
- },
- clone: function() {
- return new cc.FiniteTimeAction
- }
- });
- cc.Speed = cc.Action.extend({
- _speed: 0,
- _innerAction: null,
- ctor: function(a, c) {
- cc.Action.prototype.ctor.call(this);
- this._speed = 0;
- this._innerAction = null;
- a && this.initWithAction(a, c)
- },
- getSpeed: function() {
- return this._speed
- },
- setSpeed: function(a) {
- this._speed = a
- },
- initWithAction: function(a, c) {
- if (!a) throw "cc.Speed.initWithAction(): action must be non nil";
- this._innerAction = a;
- this._speed = c;
- return !0
- },
- clone: function() {
- var a = new cc.Speed;
- a.initWithAction(this._innerAction.clone(), this._speed);
- return a
- },
- startWithTarget: function(a) {
- cc.Action.prototype.startWithTarget.call(this, a);
- this._innerAction.startWithTarget(a)
- },
- stop: function() {
- this._innerAction.stop();
- cc.Action.prototype.stop.call(this)
- },
- step: function(a) {
- this._innerAction.step(a * this._speed)
- },
- isDone: function() {
- return this._innerAction.isDone()
- },
- reverse: function() {
- return cc.Speed.create(this._innerAction.reverse(), this._speed)
- },
- setInnerAction: function(a) {
- this._innerAction != a && (this._innerAction = a)
- },
- getInnerAction: function() {
- return this._innerAction
- }
- });
- cc.speed = function(a, c) {
- return new cc.Speed(a, c)
- };
- cc.Speed.create = cc.speed;
- cc.Follow = cc.Action.extend({
- _followedNode: null,
- _boundarySet: !1,
- _boundaryFullyCovered: !1,
- _halfScreenSize: null,
- _fullScreenSize: null,
- leftBoundary: 0,
- rightBoundary: 0,
- topBoundary: 0,
- bottomBoundary: 0,
- _worldRect: null,
- ctor: function(a, c) {
- cc.Action.prototype.ctor.call(this);
- this._followedNode = null;
- this._boundaryFullyCovered = this._boundarySet = !1;
- this._fullScreenSize = this._halfScreenSize = null;
- this.bottomBoundary = this.topBoundary = this.rightBoundary = this.leftBoundary = 0;
- this._worldRect = cc.rect(0, 0, 0, 0);
- a && (c ? this.initWithTarget(a, c) : this.initWithTarget(a))
- },
- clone: function() {
- var a = new cc.Follow,
- c = this._worldRect,
- c = new cc.Rect(c.x, c.y, c.width, c.height);
- a.initWithTarget(this._followedNode, c);
- return a
- },
- isBoundarySet: function() {
- return this._boundarySet
- },
- setBoudarySet: function(a) {
- this._boundarySet = a
- },
- initWithTarget: function(a, c) {
- if (!a) throw "cc.Follow.initWithAction(): followedNode must be non nil";
- c = c || cc.rect(0, 0, 0, 0);
- this._followedNode = a;
- this._worldRect = c;
- this._boundarySet = !cc._rectEqualToZero(c);
- this._boundaryFullyCovered = !1;
- var d = cc.director.getWinSize();
- this._fullScreenSize = cc.p(d.width, d.height);
- this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5);
- this._boundarySet && (this.leftBoundary = -(c.x + c.width - this._fullScreenSize.x), this.rightBoundary = -c.x, this.topBoundary = -c.y, this.bottomBoundary = -(c.y + c.height - this._fullScreenSize.y), this.rightBoundary < this.leftBoundary && (this.rightBoundary = this.leftBoundary = (this.leftBoundary + this.rightBoundary) / 2), this.topBoundary < this.bottomBoundary && (this.topBoundary = this.bottomBoundary = (this.topBoundary + this.bottomBoundary) / 2), this.topBoundary == this.bottomBoundary && this.leftBoundary == this.rightBoundary && (this._boundaryFullyCovered = !0));
- return !0
- },
- step: function(a) {
- a = this._followedNode.x;
- var c = this._followedNode.y;
- a = this._halfScreenSize.x - a;
- c = this._halfScreenSize.y - c;
- this._boundarySet ? this._boundaryFullyCovered || this.target.setPosition(cc.clampf(a, this.leftBoundary, this.rightBoundary), cc.clampf(c, this.bottomBoundary, this.topBoundary)) : this.target.setPosition(a, c)
- },
- isDone: function() {
- return !this._followedNode.running
- },
- stop: function() {
- this.target = null;
- cc.Action.prototype.stop.call(this)
- }
- });
- cc.follow = function(a, c) {
- return new cc.Follow(a, c)
- };
- cc.Follow.create = cc.follow;
- cc.ActionInterval = cc.FiniteTimeAction.extend({
- _elapsed: 0,
- _firstTick: !1,
- _easeList: null,
- _times: 1,
- _repeatForever: !1,
- _repeatMethod: !1,
- _speed: 1,
- _speedMethod: !1,
- ctor: function(a) {
- this._times = this._speed = 1;
- this._repeatForever = !1;
- this.MAX_VALUE = 2;
- this._speedMethod = this._repeatMethod = !1;
- cc.FiniteTimeAction.prototype.ctor.call(this);
- void 0 !== a && this.initWithDuration(a)
- },
- getElapsed: function() {
- return this._elapsed
- },
- initWithDuration: function(a) {
- this._duration = 0 === a ? cc.FLT_EPSILON : a;
- this._elapsed = 0;
- return this._firstTick = !0
- },
- isDone: function() {
- return this._elapsed >= this._duration
- },
- _cloneDecoration: function(a) {
- a._repeatForever = this._repeatForever;
- a._speed = this._speed;
- a._times = this._times;
- a._easeList = this._easeList;
- a._speedMethod = this._speedMethod;
- a._repeatMethod = this._repeatMethod
- },
- _reverseEaseList: function(a) {
- if (this._easeList) {
- a._easeList = [];
- for (var c = 0; c < this._easeList.length; c++) a._easeList.push(this._easeList[c].reverse())
- }
- },
- clone: function() {
- var a = new cc.ActionInterval(this._duration);
- this._cloneDecoration(a);
- return a
- },
- easing: function(a) {
- this._easeList ? this._easeList.length = 0 : this._easeList = [];
- for (var c = 0; c < arguments.length; c++) this._easeList.push(arguments[c]);
- return this
- },
- _computeEaseTime: function(a) {
- var c = this._easeList;
- if (!c || 0 === c.length) return a;
- for (var d = 0, e = c.length; d < e; d++) a = c[d].easing(a);
- return a
- },
- step: function(a) {
- this._firstTick ? (this._firstTick = !1, this._elapsed = 0) : this._elapsed += a;
- a = this._elapsed / (1.192092896E-7 < this._duration ? this._duration : 1.192092896E-7);
- a = 1 > a ? a : 1;
- this.update(0 < a ? a : 0);
- this._repeatMethod && (1 < this._times && this.isDone()) && (this._repeatForever || this._times--, this.startWithTarget(this.target), this.step(this._elapsed - this._duration))
- },
- startWithTarget: function(a) {
- cc.Action.prototype.startWithTarget.call(this, a);
- this._elapsed = 0;
- this._firstTick = !0
- },
- reverse: function() {
- cc.log("cc.IntervalAction: reverse not implemented.");
- return null
- },
- setAmplitudeRate: function(a) {
- cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")
- },
- getAmplitudeRate: function() {
- cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
- return 0
- },
- speed: function(a) {
- if (0 >= a) return cc.log("The speed parameter error"), this;
- this._speedMethod = !0;
- this._speed *= a;
- return this
- },
- getSpeed: function() {
- return this._speed
- },
- setSpeed: function(a) {
- this._speed = a;
- return this
- },
- repeat: function(a) {
- a = Math.round(a);
- if (isNaN(a) || 1 > a) return cc.log("The repeat parameter error"), this;
- this._repeatMethod = !0;
- this._times *= a;
- return this
- },
- repeatForever: function() {
- this._repeatMethod = !0;
- this._times = this.MAX_VALUE;
- this._repeatForever = !0;
- return this
- }
- });
- cc.actionInterval = function(a) {
- return new cc.ActionInterval(a)
- };
- cc.ActionInterval.create = cc.actionInterval;
- cc.Sequence = cc.ActionInterval.extend({
- _actions: null,
- _split: null,
- _last: 0,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._actions = [];
- var c = a instanceof Array ? a : arguments,
- d = c.length - 1;
- 0 <= d && null == c[d] && cc.log("parameters should not be ending with null in Javascript");
- if (0 <= d) {
- for (var e = c[0], f = 1; f < d; f++) c[f] && (e = cc.Sequence._actionOneTwo(e, c[f]));
- this.initWithTwoActions(e, c[d])
- }
- },
- initWithTwoActions: function(a, c) {
- if (!a || !c) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil";
- this.initWithDuration(a._duration + c._duration);
- this._actions[0] = a;
- this._actions[1] = c;
- return !0
- },
- clone: function() {
- var a = new cc.Sequence;
- this._cloneDecoration(a);
- a.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._split = this._actions[0]._duration / this._duration;
- this._last = -1
- },
- stop: function() {
- -1 !== this._last && this._actions[this._last].stop();
- cc.Action.prototype.stop.call(this)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c = 0,
- d = this._split,
- e = this._actions,
- f = this._last;
- a < d ? (a = 0 !== d ? a / d : 1, 0 === c && 1 === f && (e[1].update(0), e[1].stop())) : (c = 1, a = 1 === d ? 1 : (a - d) / (1 - d), -1 === f && (e[0].startWithTarget(this.target), e[0].update(1), e[0].stop()), f || (e[0].update(1), e[0].stop()));
- f === c && e[c].isDone() || (f !== c && e[c].startWithTarget(this.target), e[c].update(a), this._last = c)
- },
- reverse: function() {
- var a = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.sequence = function(a) {
- var c = a instanceof Array ? a : arguments;
- 0 < c.length && null == c[c.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- for (var d = c[0], e = 1; e < c.length; e++) c[e] && (d = cc.Sequence._actionOneTwo(d, c[e]));
- return d
- };
- cc.Sequence.create = cc.sequence;
- cc.Sequence._actionOneTwo = function(a, c) {
- var d = new cc.Sequence;
- d.initWithTwoActions(a, c);
- return d
- };
- cc.Repeat = cc.ActionInterval.extend({
- _times: 0,
- _total: 0,
- _nextDt: 0,
- _actionInstant: !1,
- _innerAction: null,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithAction(a, c)
- },
- initWithAction: function(a, c) {
- return this.initWithDuration(a._duration * c) ? (this._times = c, this._innerAction = a, a instanceof cc.ActionInstant && (this._actionInstant = !0, this._times -= 1), this._total = 0, !0) : !1
- },
- clone: function() {
- var a = new cc.Repeat;
- this._cloneDecoration(a);
- a.initWithAction(this._innerAction.clone(), this._times);
- return a
- },
- startWithTarget: function(a) {
- this._total = 0;
- this._nextDt = this._innerAction._duration / this._duration;
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._innerAction.startWithTarget(a)
- },
- stop: function() {
- this._innerAction.stop();
- cc.Action.prototype.stop.call(this)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c = this._innerAction,
- d = this._duration,
- e = this._times,
- f = this._nextDt;
- if (a >= f) {
- for (; a > f && this._total < e;) c.update(1), this._total++, c.stop(), c.startWithTarget(this.target), this._nextDt = f += c._duration / d;
- 1 <= a && this._total < e && this._total++;
- this._actionInstant || (this._total === e ? (c.update(1), c.stop()) : c.update(a - (f - c._duration / d)))
- } else c.update(a * e % 1)
- },
- isDone: function() {
- return this._total == this._times
- },
- reverse: function() {
- var a = cc.repeat(this._innerAction.reverse(), this._times);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- setInnerAction: function(a) {
- this._innerAction != a && (this._innerAction = a)
- },
- getInnerAction: function() {
- return this._innerAction
- }
- });
- cc.repeat = function(a, c) {
- return new cc.Repeat(a, c)
- };
- cc.Repeat.create = cc.repeat;
- cc.RepeatForever = cc.ActionInterval.extend({
- _innerAction: null,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._innerAction = null;
- a && this.initWithAction(a)
- },
- initWithAction: function(a) {
- if (!a) throw "cc.RepeatForever.initWithAction(): action must be non null";
- this._innerAction = a;
- return !0
- },
- clone: function() {
- var a = new cc.RepeatForever;
- this._cloneDecoration(a);
- a.initWithAction(this._innerAction.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._innerAction.startWithTarget(a)
- },
- step: function(a) {
- var c = this._innerAction;
- c.step(a);
- c.isDone() && (c.startWithTarget(this.target), c.step(c.getElapsed() - c._duration))
- },
- isDone: function() {
- return !1
- },
- reverse: function() {
- var a = cc.repeatForever(this._innerAction.reverse());
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- setInnerAction: function(a) {
- this._innerAction != a && (this._innerAction = a)
- },
- getInnerAction: function() {
- return this._innerAction
- }
- });
- cc.repeatForever = function(a) {
- return new cc.RepeatForever(a)
- };
- cc.RepeatForever.create = cc.repeatForever;
- cc.Spawn = cc.ActionInterval.extend({
- _one: null,
- _two: null,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._two = this._one = null;
- var c = a instanceof Array ? a : arguments,
- d = c.length - 1;
- 0 <= d && null == c[d] && cc.log("parameters should not be ending with null in Javascript");
- if (0 <= d) {
- for (var e = c[0], f = 1; f < d; f++) c[f] && (e = cc.Spawn._actionOneTwo(e, c[f]));
- this.initWithTwoActions(e, c[d])
- }
- },
- initWithTwoActions: function(a, c) {
- if (!a || !c) throw "cc.Spawn.initWithTwoActions(): arguments must all be non null";
- var d = !1,
- e = a._duration,
- f = c._duration;
- this.initWithDuration(Math.max(e, f)) && (this._one = a, this._two = c, e > f ? this._two = cc.Sequence._actionOneTwo(c, cc.delayTime(e - f)) : e < f && (this._one = cc.Sequence._actionOneTwo(a, cc.delayTime(f - e))), d = !0);
- return d
- },
- clone: function() {
- var a = new cc.Spawn;
- this._cloneDecoration(a);
- a.initWithTwoActions(this._one.clone(), this._two.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._one.startWithTarget(a);
- this._two.startWithTarget(a)
- },
- stop: function() {
- this._one.stop();
- this._two.stop();
- cc.Action.prototype.stop.call(this)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this._one && this._one.update(a);
- this._two && this._two.update(a)
- },
- reverse: function() {
- var a = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.spawn = function(a) {
- var c = a instanceof Array ? a : arguments;
- 0 < c.length && null == c[c.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- for (var d = c[0], e = 1; e < c.length; e++) null != c[e] && (d = cc.Spawn._actionOneTwo(d, c[e]));
- return d
- };
- cc.Spawn.create = cc.spawn;
- cc.Spawn._actionOneTwo = function(a, c) {
- var d = new cc.Spawn;
- d.initWithTwoActions(a, c);
- return d
- };
- cc.RotateTo = cc.ActionInterval.extend({
- _dstAngleX: 0,
- _startAngleX: 0,
- _diffAngleX: 0,
- _dstAngleY: 0,
- _startAngleY: 0,
- _diffAngleY: 0,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._dstAngleX = c || 0, this._dstAngleY = d || this._dstAngleX, !0) : !1
- },
- clone: function() {
- var a = new cc.RotateTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- var c = a.rotationX % 360,
- d = this._dstAngleX - c;
- 180 < d && (d -= 360); - 180 > d && (d += 360);
- this._startAngleX = c;
- this._diffAngleX = d;
- this._startAngleY = a.rotationY % 360;
- a = this._dstAngleY - this._startAngleY;
- 180 < a && (a -= 360); - 180 > a && (a += 360);
- this._diffAngleY = a
- },
- reverse: function() {
- cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this.target && (this.target.rotationX = this._startAngleX + this._diffAngleX * a, this.target.rotationY = this._startAngleY + this._diffAngleY * a)
- }
- });
- cc.rotateTo = function(a, c, d) {
- return new cc.RotateTo(a, c, d)
- };
- cc.RotateTo.create = cc.rotateTo;
- cc.RotateBy = cc.ActionInterval.extend({
- _angleX: 0,
- _startAngleX: 0,
- _angleY: 0,
- _startAngleY: 0,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._angleX = c || 0, this._angleY = d || this._angleX, !0) : !1
- },
- clone: function() {
- var a = new cc.RotateBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._angleX, this._angleY);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._startAngleX = a.rotationX;
- this._startAngleY = a.rotationY
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this.target && (this.target.rotationX = this._startAngleX + this._angleX * a, this.target.rotationY = this._startAngleY + this._angleY * a)
- },
- reverse: function() {
- var a = cc.rotateBy(this._duration, -this._angleX, -this._angleY);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.rotateBy = function(a, c, d) {
- return new cc.RotateBy(a, c, d)
- };
- cc.RotateBy.create = cc.rotateBy;
- cc.MoveBy = cc.ActionInterval.extend({
- _positionDelta: null,
- _startPosition: null,
- _previousPosition: null,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._positionDelta = cc.p(0, 0);
- this._startPosition = cc.p(0, 0);
- this._previousPosition = cc.p(0, 0);
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 !== c.x && (d = c.y, c = c.x), this._positionDelta.x = c, this._positionDelta.y = d, !0) : !1
- },
- clone: function() {
- var a = new cc.MoveBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._positionDelta);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- var c = a.getPositionX();
- a = a.getPositionY();
- this._previousPosition.x = c;
- this._previousPosition.y = a;
- this._startPosition.x = c;
- this._startPosition.y = a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- if (this.target) {
- var c = this._positionDelta.x * a;
- a *= this._positionDelta.y;
- var d = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
- var e = this.target.getPositionX(),
- f = this.target.getPositionY(),
- g = this._previousPosition;
- d.x = d.x + e - g.x;
- d.y = d.y + f - g.y;
- c += d.x;
- a += d.y;
- g.x = c;
- g.y = a;
- this.target.setPosition(c, a)
- } else this.target.setPosition(d.x + c, d.y + a)
- }
- },
- reverse: function() {
- var a = cc.moveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.moveBy = function(a, c, d) {
- return new cc.MoveBy(a, c, d)
- };
- cc.MoveBy.create = cc.moveBy;
- cc.MoveTo = cc.MoveBy.extend({
- _endPosition: null,
- ctor: function(a, c, d) {
- cc.MoveBy.prototype.ctor.call(this);
- this._endPosition = cc.p(0, 0);
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.MoveBy.prototype.initWithDuration.call(this, a, c, d) ? (void 0 !== c.x && (d = c.y, c = c.x), this._endPosition.x = c, this._endPosition.y = d, !0) : !1
- },
- clone: function() {
- var a = new cc.MoveTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._endPosition);
- return a
- },
- startWithTarget: function(a) {
- cc.MoveBy.prototype.startWithTarget.call(this, a);
- this._positionDelta.x = this._endPosition.x - a.getPositionX();
- this._positionDelta.y = this._endPosition.y - a.getPositionY()
- }
- });
- cc.moveTo = function(a, c, d) {
- return new cc.MoveTo(a, c, d)
- };
- cc.MoveTo.create = cc.moveTo;
- cc.SkewTo = cc.ActionInterval.extend({
- _skewX: 0,
- _skewY: 0,
- _startSkewX: 0,
- _startSkewY: 0,
- _endSkewX: 0,
- _endSkewY: 0,
- _deltaX: 0,
- _deltaY: 0,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- var e = !1;
- cc.ActionInterval.prototype.initWithDuration.call(this, a) && (this._endSkewX = c, this._endSkewY = d, e = !0);
- return e
- },
- clone: function() {
- var a = new cc.SkewTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._startSkewX = a.skewX % 180;
- this._deltaX = this._endSkewX - this._startSkewX;
- 180 < this._deltaX && (this._deltaX -= 360); - 180 > this._deltaX && (this._deltaX += 360);
- this._startSkewY = a.skewY % 360;
- this._deltaY = this._endSkewY - this._startSkewY;
- 180 < this._deltaY && (this._deltaY -= 360); - 180 > this._deltaY && (this._deltaY += 360)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this.target.skewX = this._startSkewX + this._deltaX * a;
- this.target.skewY = this._startSkewY + this._deltaY * a
- }
- });
- cc.skewTo = function(a, c, d) {
- return new cc.SkewTo(a, c, d)
- };
- cc.SkewTo.create = cc.skewTo;
- cc.SkewBy = cc.SkewTo.extend({
- ctor: function(a, c, d) {
- cc.SkewTo.prototype.ctor.call(this);
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- var e = !1;
- cc.SkewTo.prototype.initWithDuration.call(this, a, c, d) && (this._skewX = c, this._skewY = d, e = !0);
- return e
- },
- clone: function() {
- var a = new cc.SkewBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._skewX, this._skewY);
- return a
- },
- startWithTarget: function(a) {
- cc.SkewTo.prototype.startWithTarget.call(this, a);
- this._deltaX = this._skewX;
- this._deltaY = this._skewY;
- this._endSkewX = this._startSkewX + this._deltaX;
- this._endSkewY = this._startSkewY + this._deltaY
- },
- reverse: function() {
- var a = cc.skewBy(this._duration, -this._skewX, -this._skewY);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.skewBy = function(a, c, d) {
- return new cc.SkewBy(a, c, d)
- };
- cc.SkewBy.create = cc.skewBy;
- cc.JumpBy = cc.ActionInterval.extend({
- _startPosition: null,
- _delta: null,
- _height: 0,
- _jumps: 0,
- _previousPosition: null,
- ctor: function(a, c, d, e, f) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._startPosition = cc.p(0, 0);
- this._previousPosition = cc.p(0, 0);
- this._delta = cc.p(0, 0);
- void 0 !== e && this.initWithDuration(a, c, d, e, f)
- },
- initWithDuration: function(a, c, d, e, f) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 === f && (f = e, e = d, d = c.y, c = c.x), this._delta.x = c, this._delta.y = d, this._height = e, this._jumps = f, !0) : !1
- },
- clone: function() {
- var a = new cc.JumpBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._delta, this._height, this._jumps);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- var c = a.getPositionX();
- a = a.getPositionY();
- this._previousPosition.x = c;
- this._previousPosition.y = a;
- this._startPosition.x = c;
- this._startPosition.y = a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- if (this.target) {
- var c = a * this._jumps % 1,
- c = 4 * this._height * c * (1 - c),
- c = c + this._delta.y * a;
- a *= this._delta.x;
- var d = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
- var e = this.target.getPositionX(),
- f = this.target.getPositionY(),
- g = this._previousPosition;
- d.x = d.x + e - g.x;
- d.y = d.y + f - g.y;
- a += d.x;
- c += d.y;
- g.x = a;
- g.y = c;
- this.target.setPosition(a, c)
- } else this.target.setPosition(d.x + a, d.y + c)
- }
- },
- reverse: function() {
- var a = cc.jumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.jumpBy = function(a, c, d, e, f) {
- return new cc.JumpBy(a, c, d, e, f)
- };
- cc.JumpBy.create = cc.jumpBy;
- cc.JumpTo = cc.JumpBy.extend({
- _endPosition: null,
- ctor: function(a, c, d, e, f) {
- cc.JumpBy.prototype.ctor.call(this);
- this._endPosition = cc.p(0, 0);
- void 0 !== e && this.initWithDuration(a, c, d, e, f)
- },
- initWithDuration: function(a, c, d, e, f) {
- return cc.JumpBy.prototype.initWithDuration.call(this, a, c, d, e, f) ? (void 0 === f && (d = c.y, c = c.x), this._endPosition.x = c, this._endPosition.y = d, !0) : !1
- },
- startWithTarget: function(a) {
- cc.JumpBy.prototype.startWithTarget.call(this, a);
- this._delta.x = this._endPosition.x - this._startPosition.x;
- this._delta.y = this._endPosition.y - this._startPosition.y
- },
- clone: function() {
- var a = new cc.JumpTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
- return a
- }
- });
- cc.jumpTo = function(a, c, d, e, f) {
- return new cc.JumpTo(a, c, d, e, f)
- };
- cc.JumpTo.create = cc.jumpTo;
- cc.bezierAt = function(a, c, d, e, f) {
- return Math.pow(1 - f, 3) * a + 3 * f * Math.pow(1 - f, 2) * c + 3 * Math.pow(f, 2) * (1 - f) * d + Math.pow(f, 3) * e
- };
- cc.BezierBy = cc.ActionInterval.extend({
- _config: null,
- _startPosition: null,
- _previousPosition: null,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._config = [];
- this._startPosition = cc.p(0, 0);
- this._previousPosition = cc.p(0, 0);
- c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._config = c, !0) : !1
- },
- clone: function() {
- var a = new cc.BezierBy;
- this._cloneDecoration(a);
- for (var c = [], d = 0; d < this._config.length; d++) {
- var e = this._config[d];
- c.push(cc.p(e.x, e.y))
- }
- a.initWithDuration(this._duration, c);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- var c = a.getPositionX();
- a = a.getPositionY();
- this._previousPosition.x = c;
- this._previousPosition.y = a;
- this._startPosition.x = c;
- this._startPosition.y = a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- if (this.target) {
- var c = this._config,
- d = c[0].y,
- e = c[1].y,
- f = c[2].y,
- c = cc.bezierAt(0, c[0].x, c[1].x, c[2].x, a);
- a = cc.bezierAt(0, d, e, f, a);
- d = this._startPosition;
- if (cc.ENABLE_STACKABLE_ACTIONS) {
- var e = this.target.getPositionX(),
- f = this.target.getPositionY(),
- g = this._previousPosition;
- d.x = d.x + e - g.x;
- d.y = d.y + f - g.y;
- c += d.x;
- a += d.y;
- g.x = c;
- g.y = a;
- this.target.setPosition(c, a)
- } else this.target.setPosition(d.x + c, d.y + a)
- }
- },
- reverse: function() {
- var a = this._config,
- a = [cc.pAdd(a[1], cc.pNeg(a[2])), cc.pAdd(a[0], cc.pNeg(a[2])), cc.pNeg(a[2])],
- a = cc.bezierBy(this._duration, a);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.bezierBy = function(a, c) {
- return new cc.BezierBy(a, c)
- };
- cc.BezierBy.create = cc.bezierBy;
- cc.BezierTo = cc.BezierBy.extend({
- _toConfig: null,
- ctor: function(a, c) {
- cc.BezierBy.prototype.ctor.call(this);
- this._toConfig = [];
- c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toConfig = c, !0) : !1
- },
- clone: function() {
- var a = new cc.BezierTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._toConfig);
- return a
- },
- startWithTarget: function(a) {
- cc.BezierBy.prototype.startWithTarget.call(this, a);
- a = this._startPosition;
- var c = this._toConfig,
- d = this._config;
- d[0] = cc.pSub(c[0], a);
- d[1] = cc.pSub(c[1], a);
- d[2] = cc.pSub(c[2], a)
- }
- });
- cc.bezierTo = function(a, c) {
- return new cc.BezierTo(a, c)
- };
- cc.BezierTo.create = cc.bezierTo;
- cc.ScaleTo = cc.ActionInterval.extend({
- _scaleX: 1,
- _scaleY: 1,
- _startScaleX: 1,
- _startScaleY: 1,
- _endScaleX: 0,
- _endScaleY: 0,
- _deltaX: 0,
- _deltaY: 0,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._endScaleX = c, this._endScaleY = null != d ? d : c, !0) : !1
- },
- clone: function() {
- var a = new cc.ScaleTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._startScaleX = a.scaleX;
- this._startScaleY = a.scaleY;
- this._deltaX = this._endScaleX - this._startScaleX;
- this._deltaY = this._endScaleY - this._startScaleY
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this.target && (this.target.scaleX = this._startScaleX + this._deltaX * a, this.target.scaleY = this._startScaleY + this._deltaY * a)
- }
- });
- cc.scaleTo = function(a, c, d) {
- return new cc.ScaleTo(a, c, d)
- };
- cc.ScaleTo.create = cc.scaleTo;
- cc.ScaleBy = cc.ScaleTo.extend({
- startWithTarget: function(a) {
- cc.ScaleTo.prototype.startWithTarget.call(this, a);
- this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
- this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY
- },
- reverse: function() {
- var a = cc.scaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- clone: function() {
- var a = new cc.ScaleBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
- return a
- }
- });
- cc.scaleBy = function(a, c, d) {
- return new cc.ScaleBy(a, c, d)
- };
- cc.ScaleBy.create = cc.scaleBy;
- cc.Blink = cc.ActionInterval.extend({
- _times: 0,
- _originalState: !1,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._times = c, !0) : !1
- },
- clone: function() {
- var a = new cc.Blink;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._times);
- return a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- if (this.target && !this.isDone()) {
- var c = 1 / this._times;
- this.target.visible = a % c > c / 2
- }
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._originalState = a.visible
- },
- stop: function() {
- this.target.visible = this._originalState;
- cc.ActionInterval.prototype.stop.call(this)
- },
- reverse: function() {
- var a = cc.blink(this._duration, this._times);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.blink = function(a, c) {
- return new cc.Blink(a, c)
- };
- cc.Blink.create = cc.blink;
- cc.FadeTo = cc.ActionInterval.extend({
- _toOpacity: 0,
- _fromOpacity: 0,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toOpacity = c, !0) : !1
- },
- clone: function() {
- var a = new cc.FadeTo;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._toOpacity);
- return a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c = void 0 !== this._fromOpacity ? this._fromOpacity : 255;
- this.target.opacity = c + (this._toOpacity - c) * a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._fromOpacity = a.opacity
- }
- });
- cc.fadeTo = function(a, c) {
- return new cc.FadeTo(a, c)
- };
- cc.FadeTo.create = cc.fadeTo;
- cc.FadeIn = cc.FadeTo.extend({
- _reverseAction: null,
- ctor: function(a) {
- cc.FadeTo.prototype.ctor.call(this);
- a && this.initWithDuration(a, 255)
- },
- reverse: function() {
- var a = new cc.FadeOut;
- a.initWithDuration(this._duration, 0);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- clone: function() {
- var a = new cc.FadeIn;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._toOpacity);
- return a
- },
- startWithTarget: function(a) {
- this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity);
- cc.FadeTo.prototype.startWithTarget.call(this, a)
- }
- });
- cc.fadeIn = function(a) {
- return new cc.FadeIn(a)
- };
- cc.FadeIn.create = cc.fadeIn;
- cc.FadeOut = cc.FadeTo.extend({
- ctor: function(a) {
- cc.FadeTo.prototype.ctor.call(this);
- a && this.initWithDuration(a, 0)
- },
- reverse: function() {
- var a = new cc.FadeIn;
- a._reverseAction = this;
- a.initWithDuration(this._duration, 255);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- clone: function() {
- var a = new cc.FadeOut;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._toOpacity);
- return a
- }
- });
- cc.fadeOut = function(a) {
- return new cc.FadeOut(a)
- };
- cc.FadeOut.create = cc.fadeOut;
- cc.TintTo = cc.ActionInterval.extend({
- _to: null,
- _from: null,
- ctor: function(a, c, d, e) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._to = cc.color(0, 0, 0);
- this._from = cc.color(0, 0, 0);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = cc.color(c, d, e), !0) : !1
- },
- clone: function() {
- var a = new cc.TintTo;
- this._cloneDecoration(a);
- var c = this._to;
- a.initWithDuration(this._duration, c.r, c.g, c.b);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._from = this.target.color
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c = this._from,
- d = this._to;
- c && (this.target.color = cc.color(c.r + (d.r - c.r) * a, c.g + (d.g - c.g) * a, c.b + (d.b - c.b) * a))
- }
- });
- cc.tintTo = function(a, c, d, e) {
- return new cc.TintTo(a, c, d, e)
- };
- cc.TintTo.create = cc.tintTo;
- cc.TintBy = cc.ActionInterval.extend({
- _deltaR: 0,
- _deltaG: 0,
- _deltaB: 0,
- _fromR: 0,
- _fromG: 0,
- _fromB: 0,
- ctor: function(a, c, d, e) {
- cc.ActionInterval.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._deltaR = c, this._deltaG = d, this._deltaB = e, !0) : !1
- },
- clone: function() {
- var a = new cc.TintBy;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- a = a.color;
- this._fromR = a.r;
- this._fromG = a.g;
- this._fromB = a.b
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this.target.color = cc.color(this._fromR + this._deltaR * a, this._fromG + this._deltaG * a, this._fromB + this._deltaB * a)
- },
- reverse: function() {
- var a = cc.tintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- }
- });
- cc.tintBy = function(a, c, d, e) {
- return new cc.TintBy(a, c, d, e)
- };
- cc.TintBy.create = cc.tintBy;
- cc.DelayTime = cc.ActionInterval.extend({
- update: function(a) {},
- reverse: function() {
- var a = cc.delayTime(this._duration);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- clone: function() {
- var a = new cc.DelayTime;
- this._cloneDecoration(a);
- a.initWithDuration(this._duration);
- return a
- }
- });
- cc.delayTime = function(a) {
- return new cc.DelayTime(a)
- };
- cc.DelayTime.create = cc.delayTime;
- cc.ReverseTime = cc.ActionInterval.extend({
- _other: null,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._other = null;
- a && this.initWithAction(a)
- },
- initWithAction: function(a) {
- if (!a) throw "cc.ReverseTime.initWithAction(): action must be non null";
- if (a == this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
- return cc.ActionInterval.prototype.initWithDuration.call(this, a._duration) ? (this._other = a, !0) : !1
- },
- clone: function() {
- var a = new cc.ReverseTime;
- this._cloneDecoration(a);
- a.initWithAction(this._other.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._other.startWithTarget(a)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this._other && this._other.update(1 - a)
- },
- reverse: function() {
- return this._other.clone()
- },
- stop: function() {
- this._other.stop();
- cc.Action.prototype.stop.call(this)
- }
- });
- cc.reverseTime = function(a) {
- return new cc.ReverseTime(a)
- };
- cc.ReverseTime.create = cc.reverseTime;
- cc.Animate = cc.ActionInterval.extend({
- _animation: null,
- _nextFrame: 0,
- _origFrame: null,
- _executedLoops: 0,
- _splitTimes: null,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._splitTimes = [];
- a && this.initWithAnimation(a)
- },
- getAnimation: function() {
- return this._animation
- },
- setAnimation: function(a) {
- this._animation = a
- },
- initWithAnimation: function(a) {
- if (!a) throw "cc.Animate.initWithAnimation(): animation must be non-NULL";
- var c = a.getDuration();
- if (this.initWithDuration(c * a.getLoops())) {
- this._nextFrame = 0;
- this.setAnimation(a);
- this._origFrame = null;
- this._executedLoops = 0;
- var d = this._splitTimes,
- e = d.length = 0,
- f = c / a.getTotalDelayUnits();
- a = a.getFrames();
- cc.arrayVerifyType(a, cc.AnimationFrame);
- for (var g = 0; g < a.length; g++) {
- var h = e * f / c,
- e = e + a[g].getDelayUnits();
- d.push(h)
- }
- return !0
- }
- return !1
- },
- clone: function() {
- var a = new cc.Animate;
- this._cloneDecoration(a);
- a.initWithAnimation(this._animation.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._animation.getRestoreOriginalFrame() && (this._origFrame = a.displayFrame());
- this._executedLoops = this._nextFrame = 0
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- 1 > a && (a *= this._animation.getLoops(), (0 | a) > this._executedLoops && (this._nextFrame = 0, this._executedLoops++), a %= 1);
- for (var c = this._animation.getFrames(), d = c.length, e = this._splitTimes, f = this._nextFrame; f < d; f++)
- if (e[f] <= a) this.target.setSpriteFrame(c[f].getSpriteFrame()), this._nextFrame = f + 1;
- else break
- },
- reverse: function() {
- var a = this._animation,
- c = a.getFrames(),
- d = [];
- cc.arrayVerifyType(c, cc.AnimationFrame);
- if (0 < c.length)
- for (var e = c.length - 1; 0 <= e; e--) {
- var f = c[e];
- if (!f) break;
- d.push(f.clone())
- }
- c = cc.Animation.create(d, a.getDelayPerUnit(), a.getLoops());
- c.setRestoreOriginalFrame(a.getRestoreOriginalFrame());
- a = cc.animate(c);
- this._cloneDecoration(a);
- this._reverseEaseList(a);
- return a
- },
- stop: function() {
- this._animation.getRestoreOriginalFrame() && this.target && this.target.setSpriteFrame(this._origFrame);
- cc.Action.prototype.stop.call(this)
- }
- });
- cc.animate = function(a) {
- return new cc.Animate(a)
- };
- cc.Animate.create = cc.animate;
- cc.TargetedAction = cc.ActionInterval.extend({
- _action: null,
- _forcedTarget: null,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- c && this.initWithTarget(a, c)
- },
- initWithTarget: function(a, c) {
- return this.initWithDuration(c._duration) ? (this._forcedTarget = a, this._action = c, !0) : !1
- },
- clone: function() {
- var a = new cc.TargetedAction;
- this._cloneDecoration(a);
- a.initWithTarget(this._forcedTarget, this._action.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._action.startWithTarget(this._forcedTarget)
- },
- stop: function() {
- this._action.stop()
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- this._action.update(a)
- },
- getForcedTarget: function() {
- return this._forcedTarget
- },
- setForcedTarget: function(a) {
- this._forcedTarget != a && (this._forcedTarget = a)
- }
- });
- cc.targetedAction = function(a, c) {
- return new cc.TargetedAction(a, c)
- };
- cc.TargetedAction.create = cc.targetedAction;
- cc.ActionInstant = cc.FiniteTimeAction.extend({
- isDone: function() {
- return !0
- },
- step: function(a) {
- this.update(1)
- },
- update: function(a) {},
- reverse: function() {
- return this.clone()
- },
- clone: function() {
- return new cc.ActionInstant
- }
- });
- cc.Show = cc.ActionInstant.extend({
- update: function(a) {
- this.target.visible = !0
- },
- reverse: function() {
- return cc.Hide.create()
- },
- clone: function() {
- return new cc.Show
- }
- });
- cc.show = function() {
- return new cc.Show
- };
- cc.Show.create = cc.show;
- cc.Hide = cc.ActionInstant.extend({
- update: function(a) {
- this.target.visible = !1
- },
- reverse: function() {
- return cc.Show.create()
- },
- clone: function() {
- return new cc.Hide
- }
- });
- cc.hide = function() {
- return new cc.Hide
- };
- cc.Hide.create = cc.hide;
- cc.ToggleVisibility = cc.ActionInstant.extend({
- update: function(a) {
- this.target.visible = !this.target.visible
- },
- reverse: function() {
- return new cc.ToggleVisibility
- },
- clone: function() {
- return new cc.ToggleVisibility
- }
- });
- cc.toggleVisibility = function() {
- return new cc.ToggleVisibility
- };
- cc.ToggleVisibility.create = cc.toggleVisibility;
- cc.RemoveSelf = cc.ActionInstant.extend({
- _isNeedCleanUp: !0,
- ctor: function(a) {
- cc.FiniteTimeAction.prototype.ctor.call(this);
- void 0 !== a && this.init(a)
- },
- update: function(a) {
- this.target.removeFromParent(this._isNeedCleanUp)
- },
- init: function(a) {
- this._isNeedCleanUp = a;
- return !0
- },
- reverse: function() {
- return new cc.RemoveSelf(this._isNeedCleanUp)
- },
- clone: function() {
- return new cc.RemoveSelf(this._isNeedCleanUp)
- }
- });
- cc.removeSelf = function(a) {
- return new cc.RemoveSelf(a)
- };
- cc.RemoveSelf.create = cc.removeSelf;
- cc.FlipX = cc.ActionInstant.extend({
- _flippedX: !1,
- ctor: function(a) {
- cc.FiniteTimeAction.prototype.ctor.call(this);
- this._flippedX = !1;
- void 0 !== a && this.initWithFlipX(a)
- },
- initWithFlipX: function(a) {
- this._flippedX = a;
- return !0
- },
- update: function(a) {
- this.target.flippedX = this._flippedX
- },
- reverse: function() {
- return cc.FlipX.create(!this._flippedX)
- },
- clone: function() {
- var a = new cc.FlipX;
- a.initWithFlipX(this._flippedX);
- return a
- }
- });
- cc.flipX = function(a) {
- return new cc.FlipX(a)
- };
- cc.FlipX.create = cc.flipX;
- cc.FlipY = cc.ActionInstant.extend({
- _flippedY: !1,
- ctor: function(a) {
- cc.FiniteTimeAction.prototype.ctor.call(this);
- this._flippedY = !1;
- void 0 !== a && this.initWithFlipY(a)
- },
- initWithFlipY: function(a) {
- this._flippedY = a;
- return !0
- },
- update: function(a) {
- this.target.flippedY = this._flippedY
- },
- reverse: function() {
- return cc.FlipY.create(!this._flippedY)
- },
- clone: function() {
- var a = new cc.FlipY;
- a.initWithFlipY(this._flippedY);
- return a
- }
- });
- cc.flipY = function(a) {
- return new cc.FlipY(a)
- };
- cc.FlipY.create = cc.flipY;
- cc.Place = cc.ActionInstant.extend({
- _x: 0,
- _y: 0,
- ctor: function(a, c) {
- cc.FiniteTimeAction.prototype.ctor.call(this);
- this._y = this._x = 0;
- void 0 !== a && (void 0 !== a.x && (c = a.y, a = a.x), this.initWithPosition(a, c))
- },
- initWithPosition: function(a, c) {
- this._x = a;
- this._y = c;
- return !0
- },
- update: function(a) {
- this.target.setPosition(this._x, this._y)
- },
- clone: function() {
- var a = new cc.Place;
- a.initWithPosition(this._x, this._y);
- return a
- }
- });
- cc.place = function(a, c) {
- return new cc.Place(a, c)
- };
- cc.Place.create = cc.place;
- cc.CallFunc = cc.ActionInstant.extend({
- _selectorTarget: null,
- _callFunc: null,
- _function: null,
- _data: null,
- ctor: function(a, c, d) {
- cc.FiniteTimeAction.prototype.ctor.call(this);
- void 0 !== a && (void 0 === c ? this.initWithFunction(a) : this.initWithFunction(a, c, d))
- },
- initWithFunction: function(a, c, d) {
- c ? (this._data = d, this._callFunc = a, this._selectorTarget = c) : a && (this._function = a);
- return !0
- },
- execute: function() {
- null != this._callFunc ? this._callFunc.call(this._selectorTarget, this.target, this._data) : this._function && this._function.call(null, this.target)
- },
- update: function(a) {
- this.execute()
- },
- getTargetCallback: function() {
- return this._selectorTarget
- },
- setTargetCallback: function(a) {
- a != this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), this._selectorTarget = a)
- },
- clone: function() {
- var a = new cc.CallFunc;
- this._selectorTarget ? a.initWithFunction(this._callFunc, this._selectorTarget, this._data) : this._function && a.initWithFunction(this._function);
- return a
- }
- });
- cc.callFunc = function(a, c, d) {
- return new cc.CallFunc(a, c, d)
- };
- cc.CallFunc.create = cc.callFunc;
- cc.ActionCamera = cc.ActionInterval.extend({
- _centerXOrig: 0,
- _centerYOrig: 0,
- _centerZOrig: 0,
- _eyeXOrig: 0,
- _eyeYOrig: 0,
- _eyeZOrig: 0,
- _upXOrig: 0,
- _upYOrig: 0,
- _upZOrig: 0,
- ctor: function() {
- cc.ActionInterval.prototype.ctor.call(this);
- this._upZOrig = this._upYOrig = this._upXOrig = this._eyeZOrig = this._eyeYOrig = this._eyeXOrig = this._centerZOrig = this._centerYOrig = this._centerXOrig = 0
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- a = a.getCamera();
- var c = a.getCenter();
- this._centerXOrig = c.x;
- this._centerYOrig = c.y;
- this._centerZOrig = c.z;
- c = a.getEye();
- this._eyeXOrig = c.x;
- this._eyeYOrig = c.y;
- this._eyeZOrig = c.z;
- a = a.getUp();
- this._upXOrig = a.x;
- this._upYOrig = a.y;
- this._upZOrig = a.z
- },
- clone: function() {
- return new cc.ActionCamera
- },
- reverse: function() {
- return cc.reverseTime(this)
- }
- });
- cc.OrbitCamera = cc.ActionCamera.extend({
- _radius: 0,
- _deltaRadius: 0,
- _angleZ: 0,
- _deltaAngleZ: 0,
- _angleX: 0,
- _deltaAngleX: 0,
- _radZ: 0,
- _radDeltaZ: 0,
- _radX: 0,
- _radDeltaX: 0,
- ctor: function(a, c, d, e, f, g, h) {
- cc.ActionCamera.prototype.ctor.call(this);
- void 0 !== h && this.initWithDuration(a, c, d, e, f, g, h)
- },
- initWithDuration: function(a, c, d, e, f, g, h) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._radius = c, this._deltaRadius = d, this._angleZ = e, this._deltaAngleZ = f, this._angleX = g, this._deltaAngleX = h, this._radDeltaZ = cc.degreesToRadians(f), this._radDeltaX = cc.degreesToRadians(h), !0) : !1
- },
- sphericalRadius: function() {
- var a, c;
- c = this.target.getCamera();
- var d = c.getEye();
- a = c.getCenter();
- c = d.x - a.x;
- var e = d.y - a.y;
- a = d.z - a.z;
- var d = Math.sqrt(Math.pow(c, 2) + Math.pow(e, 2) + Math.pow(a, 2)),
- f = Math.sqrt(Math.pow(c, 2) + Math.pow(e, 2));
- 0 === f && (f = cc.FLT_EPSILON);
- 0 === d && (d = cc.FLT_EPSILON);
- a = Math.acos(a / d);
- c = 0 > c ? Math.PI - Math.asin(e / f) : Math.asin(e / f);
- return {
- newRadius: d / cc.Camera.getZEye(),
- zenith: a,
- azimuth: c
- }
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- a = this.sphericalRadius();
- isNaN(this._radius) && (this._radius = a.newRadius);
- isNaN(this._angleZ) && (this._angleZ = cc.radiansToDegrees(a.zenith));
- isNaN(this._angleX) && (this._angleX = cc.radiansToDegrees(a.azimuth));
- this._radZ = cc.degreesToRadians(this._angleZ);
- this._radX = cc.degreesToRadians(this._angleX)
- },
- clone: function() {
- var a = new cc.OrbitCamera;
- a.initWithDuration(this._duration, this._radius, this._deltaRadius, this._angleZ, this._deltaAngleZ, this._angleX, this._deltaAngleX);
- return a
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c = (this._radius + this._deltaRadius * a) * cc.Camera.getZEye(),
- d = this._radZ + this._radDeltaZ * a,
- e = this._radX + this._radDeltaX * a;
- a = Math.sin(d) * Math.cos(e) * c + this._centerXOrig;
- e = Math.sin(d) * Math.sin(e) * c + this._centerYOrig;
- c = Math.cos(d) * c + this._centerZOrig;
- this.target.getCamera().setEye(a, e, c)
- }
- });
- cc.orbitCamera = function(a, c, d, e, f, g, h) {
- return new cc.OrbitCamera(a, c, d, e, f, g, h)
- };
- cc.OrbitCamera.create = cc.orbitCamera;
- cc.ActionEase = cc.ActionInterval.extend({
- _inner: null,
- ctor: function(a) {
- cc.ActionInterval.prototype.ctor.call(this);
- a && this.initWithAction(a)
- },
- initWithAction: function(a) {
- if (!a) throw "cc.ActionEase.initWithAction(): action must be non nil";
- return this.initWithDuration(a.getDuration()) ? (this._inner = a, !0) : !1
- },
- clone: function() {
- var a = new cc.ActionEase;
- a.initWithAction(this._inner.clone());
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._inner.startWithTarget(this.target)
- },
- stop: function() {
- this._inner.stop();
- cc.ActionInterval.prototype.stop.call(this)
- },
- update: function(a) {
- this._inner.update(a)
- },
- reverse: function() {
- return cc.ActionEase.create(this._inner.reverse())
- },
- getInnerAction: function() {
- return this._inner
- }
- });
- cc.actionEase = function(a) {
- return new cc.ActionEase(a)
- };
- cc.ActionEase.create = cc.actionEase;
- cc.EaseRateAction = cc.ActionEase.extend({
- _rate: 0,
- ctor: function(a, c) {
- cc.ActionEase.prototype.ctor.call(this);
- void 0 !== c && this.initWithAction(a, c)
- },
- setRate: function(a) {
- this._rate = a
- },
- getRate: function() {
- return this._rate
- },
- initWithAction: function(a, c) {
- return cc.ActionEase.prototype.initWithAction.call(this, a) ? (this._rate = c, !0) : !1
- },
- clone: function() {
- var a = new cc.EaseRateAction;
- a.initWithAction(this._inner.clone(), this._rate);
- return a
- },
- reverse: function() {
- return cc.EaseRateAction.create(this._inner.reverse(), 1 / this._rate)
- }
- });
- cc.easeRateAction = function(a, c) {
- return new cc.EaseRateAction(a, c)
- };
- cc.EaseRateAction.create = cc.easeRateAction;
- cc.EaseIn = cc.EaseRateAction.extend({
- update: function(a) {
- this._inner.update(Math.pow(a, this._rate))
- },
- reverse: function() {
- return cc.EaseIn.create(this._inner.reverse(), 1 / this._rate)
- },
- clone: function() {
- var a = new cc.EaseIn;
- a.initWithAction(this._inner.clone(), this._rate);
- return a
- }
- });
- cc.EaseIn.create = function(a, c) {
- return new cc.EaseIn(a, c)
- };
- cc.easeIn = function(a) {
- return {
- _rate: a,
- easing: function(a) {
- return Math.pow(a, this._rate)
- },
- reverse: function() {
- return cc.easeIn(1 / this._rate)
- }
- }
- };
- cc.EaseOut = cc.EaseRateAction.extend({
- update: function(a) {
- this._inner.update(Math.pow(a, 1 / this._rate))
- },
- reverse: function() {
- return cc.EaseOut.create(this._inner.reverse(), 1 / this._rate)
- },
- clone: function() {
- var a = new cc.EaseOut;
- a.initWithAction(this._inner.clone(), this._rate);
- return a
- }
- });
- cc.EaseOut.create = function(a, c) {
- return new cc.EaseOut(a, c)
- };
- cc.easeOut = function(a) {
- return {
- _rate: a,
- easing: function(a) {
- return Math.pow(a, 1 / this._rate)
- },
- reverse: function() {
- return cc.easeOut(1 / this._rate)
- }
- }
- };
- cc.EaseInOut = cc.EaseRateAction.extend({
- update: function(a) {
- a *= 2;
- 1 > a ? this._inner.update(0.5 * Math.pow(a, this._rate)) : this._inner.update(1 - 0.5 * Math.pow(2 - a, this._rate))
- },
- clone: function() {
- var a = new cc.EaseInOut;
- a.initWithAction(this._inner.clone(), this._rate);
- return a
- },
- reverse: function() {
- return cc.EaseInOut.create(this._inner.reverse(), this._rate)
- }
- });
- cc.EaseInOut.create = function(a, c) {
- return new cc.EaseInOut(a, c)
- };
- cc.easeInOut = function(a) {
- return {
- _rate: a,
- easing: function(a) {
- a *= 2;
- return 1 > a ? 0.5 * Math.pow(a, this._rate) : 1 - 0.5 * Math.pow(2 - a, this._rate)
- },
- reverse: function() {
- return cc.easeInOut(this._rate)
- }
- }
- };
- cc.EaseExponentialIn = cc.ActionEase.extend({
- update: function(a) {
- this._inner.update(0 === a ? 0 : Math.pow(2, 10 * (a - 1)))
- },
- reverse: function() {
- return cc.EaseExponentialOut.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseExponentialIn;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseExponentialIn.create = function(a) {
- return new cc.EaseExponentialIn(a)
- };
- cc._easeExponentialInObj = {
- easing: function(a) {
- return 0 === a ? 0 : Math.pow(2, 10 * (a - 1))
- },
- reverse: function() {
- return cc._easeExponentialOutObj
- }
- };
- cc.easeExponentialIn = function() {
- return cc._easeExponentialInObj
- };
- cc.EaseExponentialOut = cc.ActionEase.extend({
- update: function(a) {
- this._inner.update(1 == a ? 1 : -Math.pow(2, -10 * a) + 1)
- },
- reverse: function() {
- return cc.EaseExponentialIn.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseExponentialOut;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseExponentialOut.create = function(a) {
- return new cc.EaseExponentialOut(a)
- };
- cc._easeExponentialOutObj = {
- easing: function(a) {
- return 1 == a ? 1 : -Math.pow(2, -10 * a) + 1
- },
- reverse: function() {
- return cc._easeExponentialInObj
- }
- };
- cc.easeExponentialOut = function() {
- return cc._easeExponentialOutObj
- };
- cc.EaseExponentialInOut = cc.ActionEase.extend({
- update: function(a) {
- 1 != a && 0 !== a && (a *= 2, a = 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2));
- this._inner.update(a)
- },
- reverse: function() {
- return cc.EaseExponentialInOut.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseExponentialInOut;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseExponentialInOut.create = function(a) {
- return new cc.EaseExponentialInOut(a)
- };
- cc._easeExponentialInOutObj = {
- easing: function(a) {
- return 1 !== a && 0 !== a ? (a *= 2, 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)) : a
- },
- reverse: function() {
- return cc._easeExponentialInOutObj
- }
- };
- cc.easeExponentialInOut = function() {
- return cc._easeExponentialInOutObj
- };
- cc.EaseSineIn = cc.ActionEase.extend({
- update: function(a) {
- a = 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1;
- this._inner.update(a)
- },
- reverse: function() {
- return cc.EaseSineOut.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseSineIn;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseSineIn.create = function(a) {
- return new cc.EaseSineIn(a)
- };
- cc._easeSineInObj = {
- easing: function(a) {
- return 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1
- },
- reverse: function() {
- return cc._easeSineOutObj
- }
- };
- cc.easeSineIn = function() {
- return cc._easeSineInObj
- };
- cc.EaseSineOut = cc.ActionEase.extend({
- update: function(a) {
- a = 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2);
- this._inner.update(a)
- },
- reverse: function() {
- return cc.EaseSineIn.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseSineOut;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseSineOut.create = function(a) {
- return new cc.EaseSineOut(a)
- };
- cc._easeSineOutObj = {
- easing: function(a) {
- return 0 === a || 1 == a ? a : Math.sin(a * Math.PI / 2)
- },
- reverse: function() {
- return cc._easeSineInObj
- }
- };
- cc.easeSineOut = function() {
- return cc._easeSineOutObj
- };
- cc.EaseSineInOut = cc.ActionEase.extend({
- update: function(a) {
- a = 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1);
- this._inner.update(a)
- },
- clone: function() {
- var a = new cc.EaseSineInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseSineInOut.create(this._inner.reverse())
- }
- });
- cc.EaseSineInOut.create = function(a) {
- return new cc.EaseSineInOut(a)
- };
- cc._easeSineInOutObj = {
- easing: function(a) {
- return 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1)
- },
- reverse: function() {
- return cc._easeSineInOutObj
- }
- };
- cc.easeSineInOut = function() {
- return cc._easeSineInOutObj
- };
- cc.EaseElastic = cc.ActionEase.extend({
- _period: 0.3,
- ctor: function(a, c) {
- cc.ActionEase.prototype.ctor.call(this);
- a && this.initWithAction(a, c)
- },
- getPeriod: function() {
- return this._period
- },
- setPeriod: function(a) {
- this._period = a
- },
- initWithAction: function(a, c) {
- cc.ActionEase.prototype.initWithAction.call(this, a);
- this._period = null == c ? 0.3 : c;
- return !0
- },
- reverse: function() {
- cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
- return null
- },
- clone: function() {
- var a = new cc.EaseElastic;
- a.initWithAction(this._inner.clone(), this._period);
- return a
- }
- });
- cc.EaseElastic.create = function(a, c) {
- return new cc.EaseElastic(a, c)
- };
- cc.EaseElasticIn = cc.EaseElastic.extend({
- update: function(a) {
- var c = 0;
- 0 === a || 1 === a ? c = a : (c = this._period / 4, a -= 1, c = -Math.pow(2, 10 * a) * Math.sin(2 * (a - c) * Math.PI / this._period));
- this._inner.update(c)
- },
- reverse: function() {
- return cc.EaseElasticOut.create(this._inner.reverse(), this._period)
- },
- clone: function() {
- var a = new cc.EaseElasticIn;
- a.initWithAction(this._inner.clone(), this._period);
- return a
- }
- });
- cc.EaseElasticIn.create = function(a, c) {
- return new cc.EaseElasticIn(a, c)
- };
- cc._easeElasticInObj = {
- easing: function(a) {
- if (0 === a || 1 === a) return a;
- a -= 1;
- return -Math.pow(2, 10 * a) * Math.sin(2 * (a - 0.075) * Math.PI / 0.3)
- },
- reverse: function() {
- return cc._easeElasticOutObj
- }
- };
- cc.easeElasticIn = function(a) {
- return a && 0.3 !== a ? {
- _period: a,
- easing: function(a) {
- if (0 === a || 1 === a) return a;
- a -= 1;
- return -Math.pow(2, 10 * a) * Math.sin(2 * (a - this._period / 4) * Math.PI / this._period)
- },
- reverse: function() {
- return cc.easeElasticOut(this._period)
- }
- } : cc._easeElasticInObj
- };
- cc.EaseElasticOut = cc.EaseElastic.extend({
- update: function(a) {
- var c = 0;
- 0 === a || 1 == a ? c = a : (c = this._period / 4, c = Math.pow(2, -10 * a) * Math.sin(2 * (a - c) * Math.PI / this._period) + 1);
- this._inner.update(c)
- },
- reverse: function() {
- return cc.EaseElasticIn.create(this._inner.reverse(), this._period)
- },
- clone: function() {
- var a = new cc.EaseElasticOut;
- a.initWithAction(this._inner.clone(), this._period);
- return a
- }
- });
- cc.EaseElasticOut.create = function(a, c) {
- return new cc.EaseElasticOut(a, c)
- };
- cc._easeElasticOutObj = {
- easing: function(a) {
- return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin(2 * (a - 0.075) * Math.PI / 0.3) + 1
- },
- reverse: function() {
- return cc._easeElasticInObj
- }
- };
- cc.easeElasticOut = function(a) {
- return a && 0.3 !== a ? {
- _period: a,
- easing: function(a) {
- return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin(2 * (a - this._period / 4) * Math.PI / this._period) + 1
- },
- reverse: function() {
- return cc.easeElasticIn(this._period)
- }
- } : cc._easeElasticOutObj
- };
- cc.EaseElasticInOut = cc.EaseElastic.extend({
- update: function(a) {
- var c = 0,
- c = this._period;
- if (0 === a || 1 == a) c = a;
- else {
- c || (c = this._period = 0.3 * 1.5);
- var d = c / 4;
- a = 2 * a - 1;
- c = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin(2 * (a - d) * Math.PI / c) : 0.5 * Math.pow(2, -10 * a) * Math.sin(2 * (a - d) * Math.PI / c) + 1
- }
- this._inner.update(c)
- },
- reverse: function() {
- return cc.EaseElasticInOut.create(this._inner.reverse(), this._period)
- },
- clone: function() {
- var a = new cc.EaseElasticInOut;
- a.initWithAction(this._inner.clone(), this._period);
- return a
- }
- });
- cc.EaseElasticInOut.create = function(a, c) {
- return new cc.EaseElasticInOut(a, c)
- };
- cc.easeElasticInOut = function(a) {
- return {
- _period: a || 0.3,
- easing: function(a) {
- var d = 0,
- d = this._period;
- if (0 === a || 1 === a) d = a;
- else {
- d || (d = this._period = 0.3 * 1.5);
- var e = d / 4;
- a = 2 * a - 1;
- d = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin(2 * (a - e) * Math.PI / d) : 0.5 * Math.pow(2, -10 * a) * Math.sin(2 * (a - e) * Math.PI / d) + 1
- }
- return d
- },
- reverse: function() {
- return cc.easeElasticInOut(this._period)
- }
- }
- };
- cc.EaseBounce = cc.ActionEase.extend({
- bounceTime: function(a) {
- if (a < 1 / 2.75) return 7.5625 * a * a;
- if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
- if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
- a -= 2.625 / 2.75;
- return 7.5625 * a * a + 0.984375
- },
- clone: function() {
- var a = new cc.EaseBounce;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseBounce.create(this._inner.reverse())
- }
- });
- cc.EaseBounce.create = function(a) {
- return new cc.EaseBounce(a)
- };
- cc.EaseBounceIn = cc.EaseBounce.extend({
- update: function(a) {
- a = 1 - this.bounceTime(1 - a);
- this._inner.update(a)
- },
- reverse: function() {
- return cc.EaseBounceOut.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseBounceIn;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseBounceIn.create = function(a) {
- return new cc.EaseBounceIn(a)
- };
- cc._bounceTime = function(a) {
- if (a < 1 / 2.75) return 7.5625 * a * a;
- if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
- if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
- a -= 2.625 / 2.75;
- return 7.5625 * a * a + 0.984375
- };
- cc._easeBounceInObj = {
- easing: function(a) {
- return 1 - cc._bounceTime(1 - a)
- },
- reverse: function() {
- return cc._easeBounceOutObj
- }
- };
- cc.easeBounceIn = function() {
- return cc._easeBounceInObj
- };
- cc.EaseBounceOut = cc.EaseBounce.extend({
- update: function(a) {
- a = this.bounceTime(a);
- this._inner.update(a)
- },
- reverse: function() {
- return cc.EaseBounceIn.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseBounceOut;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseBounceOut.create = function(a) {
- return new cc.EaseBounceOut(a)
- };
- cc._easeBounceOutObj = {
- easing: function(a) {
- return cc._bounceTime(a)
- },
- reverse: function() {
- return cc._easeBounceInObj
- }
- };
- cc.easeBounceOut = function() {
- return cc._easeBounceOutObj
- };
- cc.EaseBounceInOut = cc.EaseBounce.extend({
- update: function(a) {
- var c = 0,
- c = 0.5 > a ? 0.5 * (1 - this.bounceTime(1 - 2 * a)) : 0.5 * this.bounceTime(2 * a - 1) + 0.5;
- this._inner.update(c)
- },
- clone: function() {
- var a = new cc.EaseBounceInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseBounceInOut.create(this._inner.reverse())
- }
- });
- cc.EaseBounceInOut.create = function(a) {
- return new cc.EaseBounceInOut(a)
- };
- cc._easeBounceInOutObj = {
- easing: function(a) {
- return a = 0.5 > a ? 0.5 * (1 - cc._bounceTime(1 - 2 * a)) : 0.5 * cc._bounceTime(2 * a - 1) + 0.5
- },
- reverse: function() {
- return cc._easeBounceInOutObj
- }
- };
- cc.easeBounceInOut = function() {
- return cc._easeBounceInOutObj
- };
- cc.EaseBackIn = cc.ActionEase.extend({
- update: function(a) {
- this._inner.update(0 === a || 1 == a ? a : a * a * (2.70158 * a - 1.70158))
- },
- reverse: function() {
- return cc.EaseBackOut.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseBackIn;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseBackIn.create = function(a) {
- return new cc.EaseBackIn(a)
- };
- cc._easeBackInObj = {
- easing: function(a) {
- return 0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158)
- },
- reverse: function() {
- return cc._easeBackOutObj
- }
- };
- cc.easeBackIn = function() {
- return cc._easeBackInObj
- };
- cc.EaseBackOut = cc.ActionEase.extend({
- update: function(a) {
- a -= 1;
- this._inner.update(a * a * (2.70158 * a + 1.70158) + 1)
- },
- reverse: function() {
- return cc.EaseBackIn.create(this._inner.reverse())
- },
- clone: function() {
- var a = new cc.EaseBackOut;
- a.initWithAction(this._inner.clone());
- return a
- }
- });
- cc.EaseBackOut.create = function(a) {
- return new cc.EaseBackOut(a)
- };
- cc._easeBackOutObj = {
- easing: function(a) {
- a -= 1;
- return a * a * (2.70158 * a + 1.70158) + 1
- },
- reverse: function() {
- return cc._easeBackInObj
- }
- };
- cc.easeBackOut = function() {
- return cc._easeBackOutObj
- };
- cc.EaseBackInOut = cc.ActionEase.extend({
- update: function(a) {
- a *= 2;
- 1 > a ? this._inner.update(a * a * (3.5949095 * a - 2.5949095) / 2) : (a -= 2, this._inner.update(a * a * (3.5949095 * a + 2.5949095) / 2 + 1))
- },
- clone: function() {
- var a = new cc.EaseBackInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseBackInOut.create(this._inner.reverse())
- }
- });
- cc.EaseBackInOut.create = function(a) {
- return new cc.EaseBackInOut(a)
- };
- cc._easeBackInOutObj = {
- easing: function(a) {
- a *= 2;
- if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
- a -= 2;
- return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
- },
- reverse: function() {
- return cc._easeBackInOutObj
- }
- };
- cc.easeBackInOut = function() {
- return cc._easeBackInOutObj
- };
- cc.EaseBezierAction = cc.ActionEase.extend({
- _p0: null,
- _p1: null,
- _p2: null,
- _p3: null,
- ctor: function(a) {
- cc.ActionEase.prototype.ctor.call(this, a)
- },
- _updateTime: function(a, c, d, e, f) {
- return Math.pow(1 - f, 3) * a + 3 * f * Math.pow(1 - f, 2) * c + 3 * Math.pow(f, 2) * (1 - f) * d + Math.pow(f, 3) * e
- },
- update: function(a) {
- a = this._updateTime(this._p0, this._p1, this._p2, this._p3, a);
- this._inner.update(a)
- },
- clone: function() {
- var a = new cc.EaseBezierAction;
- a.initWithAction(this._inner.clone());
- a.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
- return a
- },
- reverse: function() {
- var a = cc.EaseBezierAction.create(this._inner.reverse());
- a.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
- return a
- },
- setBezierParamer: function(a, c, d, e) {
- this._p0 = a || 0;
- this._p1 = c || 0;
- this._p2 = d || 0;
- this._p3 = e || 0
- }
- });
- cc.EaseBezierAction.create = function(a) {
- return new cc.EaseBezierAction(a)
- };
- cc.easeBezierAction = function(a, c, d, e) {
- return {
- easing: function(f) {
- return cc.EaseBezierAction.prototype._updateTime(a, c, d, e, f)
- },
- reverse: function() {
- return cc.easeBezierAction(e, d, c, a)
- }
- }
- };
- cc.EaseQuadraticActionIn = cc.ActionEase.extend({
- _updateTime: function(a) {
- return Math.pow(a, 2)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuadraticActionIn;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuadraticActionIn.create(this._inner.reverse())
- }
- });
- cc.EaseQuadraticActionIn.create = function(a) {
- return new cc.EaseQuadraticActionIn(a)
- };
- cc._easeQuadraticActionIn = {
- easing: cc.EaseQuadraticActionIn.prototype._updateTime,
- reverse: function() {
- return cc._easeQuadraticActionIn
- }
- };
- cc.easeQuadraticActionIn = function() {
- return cc._easeQuadraticActionIn
- };
- cc.EaseQuadraticActionOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- return -a * (a - 2)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuadraticActionOut;
- a.initWithAction();
- return a
- },
- reverse: function() {
- return cc.EaseQuadraticActionOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuadraticActionOut.create = function(a) {
- return new cc.EaseQuadraticActionOut(a)
- };
- cc._easeQuadraticActionOut = {
- easing: cc.EaseQuadraticActionOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuadraticActionOut
- }
- };
- cc.easeQuadraticActionOut = function() {
- return cc._easeQuadraticActionOut
- };
- cc.EaseQuadraticActionInOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- var c = a;
- a *= 2;
- 1 > a ? c = 0.5 * a * a : (--a, c = -0.5 * (a * (a - 2) - 1));
- return c
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuadraticActionInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuadraticActionInOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuadraticActionInOut.create = function(a) {
- return new cc.EaseQuadraticActionInOut(a)
- };
- cc._easeQuadraticActionInOut = {
- easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuadraticActionInOut
- }
- };
- cc.easeQuadraticActionInOut = function() {
- return cc._easeQuadraticActionInOut
- };
- cc.EaseQuarticActionIn = cc.ActionEase.extend({
- _updateTime: function(a) {
- return a * a * a * a
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuarticActionIn;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuarticActionIn.create(this._inner.reverse())
- }
- });
- cc.EaseQuarticActionIn.create = function(a) {
- return new cc.EaseQuarticActionIn(a)
- };
- cc._easeQuarticActionIn = {
- easing: cc.EaseQuarticActionIn.prototype._updateTime,
- reverse: function() {
- return cc._easeQuarticActionIn
- }
- };
- cc.easeQuarticActionIn = function() {
- return cc._easeQuarticActionIn
- };
- cc.EaseQuarticActionOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a -= 1;
- return -(a * a * a * a - 1)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuarticActionOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuarticActionOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuarticActionOut.create = function(a) {
- return new cc.EaseQuarticActionOut(a)
- };
- cc._easeQuarticActionOut = {
- easing: cc.EaseQuarticActionOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuarticActionOut
- }
- };
- cc.easeQuarticActionOut = function() {
- return cc._easeQuarticActionOut
- };
- cc.EaseQuarticActionInOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a * a;
- a -= 2;
- return -0.5 * (a * a * a * a - 2)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuarticActionInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuarticActionInOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuarticActionInOut.create = function(a) {
- return new cc.EaseQuarticActionInOut(a)
- };
- cc._easeQuarticActionInOut = {
- easing: cc.EaseQuarticActionInOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuarticActionInOut
- }
- };
- cc.easeQuarticActionInOut = function() {
- return cc._easeQuarticActionInOut
- };
- cc.EaseQuinticActionIn = cc.ActionEase.extend({
- _updateTime: function(a) {
- return a * a * a * a * a
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuinticActionIn;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuinticActionIn.create(this._inner.reverse())
- }
- });
- cc.EaseQuinticActionIn.create = function(a) {
- return new cc.EaseQuinticActionIn(a)
- };
- cc._easeQuinticActionIn = {
- easing: cc.EaseQuinticActionIn.prototype._updateTime,
- reverse: function() {
- return cc._easeQuinticActionIn
- }
- };
- cc.easeQuinticActionIn = function() {
- return cc._easeQuinticActionIn
- };
- cc.EaseQuinticActionOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a -= 1;
- return a * a * a * a * a + 1
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuinticActionOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuinticActionOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuinticActionOut.create = function(a) {
- return new cc.EaseQuinticActionOut(a)
- };
- cc._easeQuinticActionOut = {
- easing: cc.EaseQuinticActionOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuinticActionOut
- }
- };
- cc.easeQuinticActionOut = function() {
- return cc._easeQuinticActionOut
- };
- cc.EaseQuinticActionInOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a * a * a;
- a -= 2;
- return 0.5 * (a * a * a * a * a + 2)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseQuinticActionInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseQuinticActionInOut.create(this._inner.reverse())
- }
- });
- cc.EaseQuinticActionInOut.create = function(a) {
- return new cc.EaseQuinticActionInOut(a)
- };
- cc._easeQuinticActionInOut = {
- easing: cc.EaseQuinticActionInOut.prototype._updateTime,
- reverse: function() {
- return cc._easeQuinticActionInOut
- }
- };
- cc.easeQuinticActionInOut = function() {
- return cc._easeQuinticActionInOut
- };
- cc.EaseCircleActionIn = cc.ActionEase.extend({
- _updateTime: function(a) {
- return -1 * (Math.sqrt(1 - a * a) - 1)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCircleActionIn;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCircleActionIn.create(this._inner.reverse())
- }
- });
- cc.EaseCircleActionIn.create = function(a) {
- return new cc.EaseCircleActionIn(a)
- };
- cc._easeCircleActionIn = {
- easing: cc.EaseCircleActionIn.prototype._updateTime,
- reverse: function() {
- return cc._easeCircleActionIn
- }
- };
- cc.easeCircleActionIn = function() {
- return cc._easeCircleActionIn
- };
- cc.EaseCircleActionOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a -= 1;
- return Math.sqrt(1 - a * a)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCircleActionOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCircleActionOut.create(this._inner.reverse())
- }
- });
- cc.EaseCircleActionOut.create = function(a) {
- return new cc.EaseCircleActionOut(a)
- };
- cc._easeCircleActionOut = {
- easing: cc.EaseCircleActionOut.prototype._updateTime,
- reverse: function() {
- return cc._easeCircleActionOut
- }
- };
- cc.easeCircleActionOut = function() {
- return cc._easeCircleActionOut
- };
- cc.EaseCircleActionInOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a *= 2;
- if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
- a -= 2;
- return 0.5 * (Math.sqrt(1 - a * a) + 1)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCircleActionInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCircleActionInOut.create(this._inner.reverse())
- }
- });
- cc.EaseCircleActionInOut.create = function(a) {
- return new cc.EaseCircleActionInOut(a)
- };
- cc._easeCircleActionInOut = {
- easing: cc.EaseCircleActionInOut.prototype._updateTime,
- reverse: function() {
- return cc._easeCircleActionInOut
- }
- };
- cc.easeCircleActionInOut = function() {
- return cc._easeCircleActionInOut
- };
- cc.EaseCubicActionIn = cc.ActionEase.extend({
- _updateTime: function(a) {
- return a * a * a
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCubicActionIn;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCubicActionIn.create(this._inner.reverse())
- }
- });
- cc.EaseCubicActionIn.create = function(a) {
- return new cc.EaseCubicActionIn(a)
- };
- cc._easeCubicActionIn = {
- easing: cc.EaseCubicActionIn.prototype._updateTime,
- reverse: function() {
- return cc._easeCubicActionIn
- }
- };
- cc.easeCubicActionIn = function() {
- return cc._easeCubicActionIn
- };
- cc.EaseCubicActionOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a -= 1;
- return a * a * a + 1
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCubicActionOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCubicActionOut.create(this._inner.reverse())
- }
- });
- cc.EaseCubicActionOut.create = function(a) {
- return new cc.EaseCubicActionOut(a)
- };
- cc._easeCubicActionOut = {
- easing: cc.EaseCubicActionOut.prototype._updateTime,
- reverse: function() {
- return cc._easeCubicActionOut
- }
- };
- cc.easeCubicActionOut = function() {
- return cc._easeCubicActionOut
- };
- cc.EaseCubicActionInOut = cc.ActionEase.extend({
- _updateTime: function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a;
- a -= 2;
- return 0.5 * (a * a * a + 2)
- },
- update: function(a) {
- this._inner.update(this._updateTime(a))
- },
- clone: function() {
- var a = new cc.EaseCubicActionInOut;
- a.initWithAction(this._inner.clone());
- return a
- },
- reverse: function() {
- return cc.EaseCubicActionInOut.create(this._inner.reverse())
- }
- });
- cc.EaseCubicActionInOut.create = function(a) {
- return new cc.EaseCubicActionInOut(a)
- };
- cc._easeCubicActionInOut = {
- easing: cc.EaseCubicActionInOut.prototype._updateTime,
- reverse: function() {
- return cc._easeCubicActionInOut
- }
- };
- cc.easeCubicActionInOut = function() {
- return cc._easeCubicActionInOut
- };
- cc.cardinalSplineAt = function(a, c, d, e, f, g) {
- var h = g * g,
- k = h * g,
- m = (1 - f) / 2;
- f = m * (-k + 2 * h - g);
- var n = m * (-k + h) + (2 * k - 3 * h + 1);
- g = m * (k - 2 * h + g) + (-2 * k + 3 * h);
- h = m * (k - h);
- return cc.p(a.x * f + c.x * n + d.x * g + e.x * h, a.y * f + c.y * n + d.y * g + e.y * h)
- };
- cc.reverseControlPoints = function(a) {
- for (var c = [], d = a.length - 1; 0 <= d; d--) c.push(cc.p(a[d].x, a[d].y));
- return c
- };
- cc.copyControlPoints = function(a) {
- for (var c = [], d = 0; d < a.length; d++) c.push(cc.p(a[d].x, a[d].y));
- return c
- };
- cc.getControlPointAt = function(a, c) {
- var d = Math.min(a.length - 1, Math.max(c, 0));
- return a[d]
- };
- cc.reverseControlPointsInline = function(a) {
- for (var c = a.length, d = 0 | c / 2, e = 0; e < d; ++e) {
- var f = a[e];
- a[e] = a[c - e - 1];
- a[c - e - 1] = f
- }
- };
- cc.CardinalSplineTo = cc.ActionInterval.extend({
- _points: null,
- _deltaT: 0,
- _tension: 0,
- _previousPosition: null,
- _accumulatedDiff: null,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._points = [];
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- if (!c || 0 == c.length) throw "Invalid configuration. It must at least have one control point";
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.setPoints(c), this._tension = d, !0) : !1
- },
- clone: function() {
- var a = new cc.CardinalSplineTo;
- a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._deltaT = 1 / (this._points.length - 1);
- this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
- this._accumulatedDiff = cc.p(0, 0)
- },
- update: function(a) {
- a = this._computeEaseTime(a);
- var c, d = this._points;
- if (1 == a) c = d.length - 1, a = 1;
- else {
- var e = this._deltaT;
- c = 0 | a / e;
- a = (a - e * c) / e
- }
- c = cc.cardinalSplineAt(cc.getControlPointAt(d, c - 1), cc.getControlPointAt(d, c - 0), cc.getControlPointAt(d, c + 1), cc.getControlPointAt(d, c + 2), this._tension, a);
- if (cc.ENABLE_STACKABLE_ACTIONS && (d = this.target.getPositionX() - this._previousPosition.x, a = this.target.getPositionY() - this._previousPosition.y, 0 != d || 0 != a)) e = this._accumulatedDiff, d = e.x + d, a = e.y + a, e.x = d, e.y = a, c.x += d, c.y += a;
- this.updatePosition(c)
- },
- reverse: function() {
- var a = cc.reverseControlPoints(this._points);
- return cc.cardinalSplineTo(this._duration, a, this._tension)
- },
- updatePosition: function(a) {
- this.target.setPosition(a);
- this._previousPosition = a
- },
- getPoints: function() {
- return this._points
- },
- setPoints: function(a) {
- this._points = a
- }
- });
- cc.cardinalSplineTo = function(a, c, d) {
- return new cc.CardinalSplineTo(a, c, d)
- };
- cc.CardinalSplineTo.create = cc.cardinalSplineTo;
- cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
- _startPosition: null,
- ctor: function(a, c, d) {
- cc.CardinalSplineTo.prototype.ctor.call(this);
- this._startPosition = cc.p(0, 0);
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- startWithTarget: function(a) {
- cc.CardinalSplineTo.prototype.startWithTarget.call(this, a);
- this._startPosition.x = a.getPositionX();
- this._startPosition.y = a.getPositionY()
- },
- reverse: function() {
- for (var a = this._points.slice(), c, d = a[0], e = 1; e < a.length; ++e) c = a[e], a[e] = cc.pSub(c, d), d = c;
- a = cc.reverseControlPoints(a);
- d = a[a.length - 1];
- a.pop();
- d.x = -d.x;
- d.y = -d.y;
- a.unshift(d);
- for (e = 1; e < a.length; ++e) c = a[e], c.x = -c.x, c.y = -c.y, c.x += d.x, c.y += d.y, d = a[e] = c;
- return cc.cardinalSplineBy(this._duration, a, this._tension)
- },
- updatePosition: function(a) {
- var c = this._startPosition,
- d = a.x + c.x;
- a = a.y + c.y;
- this._previousPosition.x = d;
- this._previousPosition.y = a;
- this.target.setPosition(d, a)
- },
- clone: function() {
- var a = new cc.CardinalSplineBy;
- a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
- return a
- }
- });
- cc.cardinalSplineBy = function(a, c, d) {
- return new cc.CardinalSplineBy(a, c, d)
- };
- cc.CardinalSplineBy.create = cc.cardinalSplineBy;
- cc.CatmullRomTo = cc.CardinalSplineTo.extend({
- ctor: function(a, c) {
- c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, c, 0.5)
- },
- clone: function() {
- var a = new cc.CatmullRomTo;
- a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
- return a
- }
- });
- cc.catmullRomTo = function(a, c) {
- return new cc.CatmullRomTo(a, c)
- };
- cc.CatmullRomTo.create = cc.catmullRomTo;
- cc.CatmullRomBy = cc.CardinalSplineBy.extend({
- ctor: function(a, c) {
- cc.CardinalSplineBy.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, c, 0.5)
- },
- clone: function() {
- var a = new cc.CatmullRomBy;
- a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
- return a
- }
- });
- cc.catmullRomBy = function(a, c) {
- return new cc.CatmullRomBy(a, c)
- };
- cc.CatmullRomBy.create = cc.catmullRomBy;
- cc.ActionTweenDelegate = cc.Class.extend({
- updateTweenAction: function(a, c) {}
- });
- cc.ActionTween = cc.ActionInterval.extend({
- key: "",
- from: 0,
- to: 0,
- delta: 0,
- ctor: function(a, c, d, e) {
- cc.ActionInterval.prototype.ctor.call(this);
- this.key = "";
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.key = c, this.to = e, this.from = d, !0) : !1
- },
- startWithTarget: function(a) {
- if (!a || !a.updateTweenAction) throw "cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this.delta = this.to - this.from
- },
- update: function(a) {
- this.target.updateTweenAction(this.to - this.delta * (1 - a), this.key)
- },
- reverse: function() {
- return cc.actionTween(this.duration, this.key, this.to, this.from)
- },
- clone: function() {
- var a = new cc.ActionTween;
- a.initWithDuration(this._duration, this.key, this.from, this.to);
- return a
- }
- });
- cc.actionTween = function(a, c, d, e) {
- return new cc.ActionTween(a, c, d, e)
- };
- cc.ActionTween.create = cc.actionTween;
- cc.GridAction = cc.ActionInterval.extend({
- _gridSize: null,
- ctor: function(a, c) {
- cc._checkWebGLRenderMode();
- cc.ActionInterval.prototype.ctor.call(this);
- this._gridSize = cc.size(0, 0);
- c && this.initWithDuration(a, c)
- },
- clone: function() {
- var a = new cc.GridAction,
- c = this._gridSize;
- a.initWithDuration(this._duration, cc.size(c.width, c.height));
- return a
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- var c = this.getGrid(),
- d = this.target;
- (a = d.grid) && 0 < a.getReuseGrid() ? (c = a.getGridSize(), a.isActive() && (c.width == this._gridSize.width && c.height == this._gridSize.height) && a.reuse()) : (a && a.isActive() && a.setActive(!1), d.grid = c, d.grid.setActive(!0))
- },
- reverse: function() {
- return cc.ReverseTime.create(this)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._gridSize.width = c.width, this._gridSize.height = c.height, !0) : !1
- },
- getGrid: function() {
- cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.")
- }
- });
- cc.gridAction = function(a, c) {
- return new cc.GridAction(a, c)
- };
- cc.GridAction.create = cc.gridAction;
- cc.Grid3DAction = cc.GridAction.extend({
- getGrid: function() {
- return cc.Grid3D.create(this._gridSize)
- },
- vertex: function(a) {
- return this.target.grid.vertex(a)
- },
- originalVertex: function(a) {
- return this.target.grid.originalVertex(a)
- },
- setVertex: function(a, c) {
- this.target.grid.setVertex(a, c)
- }
- });
- cc.grid3DAction = function(a, c) {
- return new cc.Grid3DAction(a, c)
- };
- cc.Grid3DAction.create = cc.grid3DAction;
- cc.TiledGrid3DAction = cc.GridAction.extend({
- tile: function(a) {
- return this.target.grid.tile(a)
- },
- originalTile: function(a) {
- return this.target.grid.originalTile(a)
- },
- setTile: function(a, c) {
- this.target.grid.setTile(a, c)
- },
- getGrid: function() {
- return cc.TiledGrid3D.create(this._gridSize)
- }
- });
- cc.tiledGrid3DAction = function(a, c) {
- return new cc.TiledGrid3DAction(a, c)
- };
- cc.TiledGrid3DAction.create = cc.tiledGrid3DAction;
- cc.StopGrid = cc.ActionInstant.extend({
- startWithTarget: function(a) {
- cc.ActionInstant.prototype.startWithTarget.call(this, a);
- (a = this.target.grid) && a.isActive() && a.setActive(!1)
- }
- });
- cc.stopGrid = function() {
- return new cc.StopGrid
- };
- cc.StopGrid.create = cc.stopGrid;
- cc.ReuseGrid = cc.ActionInstant.extend({
- _times: null,
- ctor: function(a) {
- cc.ActionInstant.prototype.ctor.call(this);
- void 0 !== a && this.initWithTimes(a)
- },
- initWithTimes: function(a) {
- this._times = a;
- return !0
- },
- startWithTarget: function(a) {
- cc.ActionInstant.prototype.startWithTarget.call(this, a);
- this.target.grid && this.target.grid.isActive() && this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times)
- }
- });
- cc.reuseGrid = function(a) {
- return new cc.ReuseGrid(a)
- };
- cc.ReuseGrid.create = cc.reuseGrid;
- cc.Waves3D = cc.Grid3DAction.extend({
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- for (var c = this._gridSize, d = this._amplitude, e = cc.p(0, 0), f = this._amplitudeRate, g = this._waves, h = 0; h < c.width + 1; ++h)
- for (var k = 0; k < c.height + 1; ++k) {
- e.x = h;
- e.y = k;
- var m = this.originalVertex(e);
- m.z += Math.sin(2 * Math.PI * a * g + 0.01 * (m.y + m.x)) * d * f;
- this.setVertex(e, m)
- }
- }
- });
- cc.waves3D = function(a, c, d, e) {
- return new cc.Waves3D(a, c, d, e)
- };
- cc.Waves3D.create = cc.waves3D;
- cc.FlipX3D = cc.Grid3DAction.extend({
- ctor: function(a) {
- void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
- },
- initWithDuration: function(a) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, 1))
- },
- initWithSize: function(a, c) {
- return 1 != a.width || 1 != a.height ? (cc.log("Grid size must be (1,1)"), !1) : cc.Grid3DAction.prototype.initWithDuration.call(this, c, a)
- },
- update: function(a) {
- var c = Math.PI * a;
- a = Math.sin(c);
- var d = Math.cos(c / 2),
- c = new cc.Vertex3F,
- e = cc.p(0, 0);
- e.x = e.y = 1;
- var f = this.originalVertex(e);
- e.x = e.y = 0;
- var e = this.originalVertex(e),
- g = f.x,
- h = e.x,
- k, m;
- g > h ? (f = cc.p(0, 0), e = cc.p(0, 1), k = cc.p(1, 0), m = cc.p(1, 1)) : (k = cc.p(0, 0), m = cc.p(0, 1), f = cc.p(1, 0), e = cc.p(1, 1), g = h);
- c.x = g - g * d;
- c.z = Math.abs(parseFloat(g * a / 4));
- a = this.originalVertex(f);
- a.x = c.x;
- a.z += c.z;
- this.setVertex(f, a);
- a = this.originalVertex(e);
- a.x = c.x;
- a.z += c.z;
- this.setVertex(e, a);
- a = this.originalVertex(k);
- a.x -= c.x;
- a.z -= c.z;
- this.setVertex(k, a);
- a = this.originalVertex(m);
- a.x -= c.x;
- a.z -= c.z;
- this.setVertex(m, a)
- }
- });
- cc.flipX3D = function(a) {
- return new cc.FlipX3D(a)
- };
- cc.FlipX3D.create = cc.flipX3D;
- cc.FlipY3D = cc.FlipX3D.extend({
- ctor: function(a) {
- void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
- },
- update: function(a) {
- var c = Math.PI * a;
- a = Math.sin(c);
- var d = Math.cos(c / 2),
- c = new cc.Vertex3F,
- e = cc.p(0, 0);
- e.x = e.y = 1;
- var f = this.originalVertex(e);
- e.x = e.y = 0;
- var e = this.originalVertex(e),
- g = f.y,
- h = e.y,
- k, m;
- g > h ? (f = cc.p(0, 0), e = cc.p(0, 1), k = cc.p(1, 0), m = cc.p(1, 1)) : (e = cc.p(0, 0), f = cc.p(0, 1), m = cc.p(1, 0), k = cc.p(1, 1), g = h);
- c.y = g - g * d;
- c.z = Math.abs(parseFloat(g * a) / 4);
- a = this.originalVertex(f);
- a.y = c.y;
- a.z += c.z;
- this.setVertex(f, a);
- a = this.originalVertex(e);
- a.y -= c.y;
- a.z -= c.z;
- this.setVertex(e, a);
- a = this.originalVertex(k);
- a.y = c.y;
- a.z += c.z;
- this.setVertex(k, a);
- a = this.originalVertex(m);
- a.y -= c.y;
- a.z -= c.z;
- this.setVertex(m, a)
- }
- });
- cc.flipY3D = function(a) {
- return new cc.FlipY3D(a)
- };
- cc.FlipY3D.create = cc.flipY3D;
- cc.Lens3D = cc.Grid3DAction.extend({
- _position: null,
- _radius: 0,
- _lensEffect: 0,
- _concave: !1,
- _dirty: !1,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- this._position = cc.p(0, 0);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- getLensEffect: function() {
- return this._lensEffect
- },
- setLensEffect: function(a) {
- this._lensEffect = a
- },
- setConcave: function(a) {
- this._concave = a
- },
- getPosition: function() {
- return this._position
- },
- setPosition: function(a) {
- cc.pointEqualToPoint(a, this._position) || (this._position.x = a.x, this._position.y = a.y, this._dirty = !0)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this.setPosition(d), this._radius = e, this._lensEffect = 0.7, this._dirty = !0) : !1
- },
- update: function(a) {
- if (this._dirty) {
- a = this._gridSize.width;
- for (var c = this._gridSize.height, d = this._radius, e = this._lensEffect, f = cc.p(0, 0), g = cc.p(0, 0), h, k, m, n = 0; n < a + 1; ++n)
- for (var q = 0; q < c + 1; ++q) f.x = n, f.y = q, h = this.originalVertex(f), g.x = this._position.x - h.x, g.y = this._position.y - h.y, k = cc.pLength(g), k < d && (k = d - k, k /= d, 0 == k && (k = 0.0010), k = Math.log(k) * e, m = Math.exp(k) * d, k = cc.pLength(g), 0 < k && (g.x /= k, g.y /= k, g.x *= m, g.y *= m, h.z += cc.pLength(g) * e)), this.setVertex(f, h);
- this._dirty = !1
- }
- }
- });
- cc.lens3D = function(a, c, d, e) {
- return new cc.Lens3D(a, c, d, e)
- };
- cc.Lens3D.create = cc.lens3D;
- cc.Ripple3D = cc.Grid3DAction.extend({
- _position: null,
- _radius: 0,
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e, f, g) {
- cc.GridAction.prototype.ctor.call(this);
- this._position = cc.p(0, 0);
- void 0 !== g && this.initWithDuration(a, c, d, e, f, g)
- },
- getPosition: function() {
- return this._position
- },
- setPosition: function(a) {
- this._position.x = a.x;
- this._position.y = a.y
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e, f, g) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this.setPosition(d), this._radius = e, this._waves = f, this._amplitude = g, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- for (var c = this._gridSize.width, d = this._gridSize.height, e = cc.p(0, 0), f = this._radius, g = this._waves, h = this._amplitude, k = this._amplitudeRate, m, n, q = cc.p(0, 0), r = 0; r < c + 1; ++r)
- for (var t = 0; t < d + 1; ++t) {
- e.x = r;
- e.y = t;
- m = this.originalVertex(e);
- q.x = this._position.x - m.x;
- q.y = this._position.y - m.y;
- n = cc.pLength(q);
- if (n < f) {
- n = f - n;
- var s = Math.pow(n / f, 2);
- m.z += Math.sin(2 * a * Math.PI * g + 0.1 * n) * h * k * s
- }
- this.setVertex(e, m)
- }
- }
- });
- cc.ripple3D = function(a, c, d, e, f, g) {
- return new cc.Ripple3D(a, c, d, e, f, g)
- };
- cc.Ripple3D.create = cc.ripple3D;
- cc.Shaky3D = cc.Grid3DAction.extend({
- _randRange: 0,
- _shakeZ: !1,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._randRange = d, this._shakeZ = e, !0) : !1
- },
- update: function(a) {
- a = this._gridSize.width;
- for (var c = this._gridSize.height, d = this._randRange, e = this._shakeZ, f = cc.p(0, 0), g, h = 0; h < a + 1; ++h)
- for (var k = 0; k < c + 1; ++k) f.x = h, f.y = k, g = this.originalVertex(f), g.x += cc.rand() % (2 * d) - d, g.y += cc.rand() % (2 * d) - d, e && (g.z += cc.rand() % (2 * d) - d), this.setVertex(f, g)
- }
- });
- cc.shaky3D = function(a, c, d, e) {
- return new cc.Shaky3D(a, c, d, e)
- };
- cc.Shaky3D.create = cc.shaky3D;
- cc.Liquid = cc.Grid3DAction.extend({
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- for (var c = this._gridSize.width, d = this._gridSize.height, e = cc.p(0, 0), f = this._waves, g = this._amplitude, h = this._amplitudeRate, k, m = 1; m < c; ++m)
- for (var n = 1; n < d; ++n) e.x = m, e.y = n, k = this.originalVertex(e), k.x += Math.sin(2 * a * Math.PI * f + 0.01 * k.x) * g * h, k.y += Math.sin(2 * a * Math.PI * f + 0.01 * k.y) * g * h, this.setVertex(e, k)
- }
- });
- cc.liquid = function(a, c, d, e) {
- return new cc.Liquid(a, c, d, e)
- };
- cc.Liquid.create = cc.liquid;
- cc.Waves = cc.Grid3DAction.extend({
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- _vertical: !1,
- _horizontal: !1,
- ctor: function(a, c, d, e, f, g) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== g && this.initWithDuration(a, c, d, e, f, g)
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e, f, g) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, this._horizontal = f, this._vertical = g, !0) : !1
- },
- update: function(a) {
- for (var c = this._gridSize.width, d = this._gridSize.height, e = cc.p(0, 0), f = this._vertical, g = this._horizontal, h = this._waves, k = this._amplitude, m = this._amplitudeRate, n, q = 0; q < c + 1; ++q)
- for (var r = 0; r < d + 1; ++r) e.x = q, e.y = r, n = this.originalVertex(e), f && (n.x += Math.sin(2 * a * Math.PI * h + 0.01 * n.y) * k * m), g && (n.y += Math.sin(2 * a * Math.PI * h + 0.01 * n.x) * k * m), this.setVertex(e, n)
- }
- });
- cc.waves = function(a, c, d, e, f, g) {
- return new cc.Waves(a, c, d, e, f, g)
- };
- cc.Waves.create = cc.waves;
- cc.Twirl = cc.Grid3DAction.extend({
- _position: null,
- _twirls: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e, f) {
- cc.GridAction.prototype.ctor.call(this);
- this._position = cc.p(0, 0);
- void 0 !== f && this.initWithDuration(a, c, d, e, f)
- },
- getPosition: function() {
- return this._position
- },
- setPosition: function(a) {
- this._position.x = a.x;
- this._position.y = a.y
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e, f) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this.setPosition(d), this._twirls = e, this._amplitude = f, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- for (var c = this._position, d = this._gridSize.width, e = this._gridSize.height, f = cc.p(0, 0), g = 0.1 * this._amplitude * this._amplitudeRate, h = this._twirls, k, m, n, q = cc.p(0, 0), r = 0; r < d + 1; ++r)
- for (var t = 0; t < e + 1; ++t) f.x = r, f.y = t, k = this.originalVertex(f), q.x = r - d / 2, q.y = t - e / 2, m = cc.pLength(q) * Math.cos(Math.PI / 2 + 2 * a * Math.PI * h) * g, n = Math.sin(m) * (k.y - c.y) + Math.cos(m) * (k.x - c.x), m = Math.cos(m) * (k.y - c.y) - Math.sin(m) * (k.x - c.x), k.x = c.x + n, k.y = c.y + m, this.setVertex(f, k)
- }
- });
- cc.twirl = function(a, c, d, e, f) {
- return new cc.Twirl(a, c, d, e, f)
- };
- cc.Twirl.create = cc.twirl;
- cc.ShakyTiles3D = cc.TiledGrid3DAction.extend({
- _randRange: 0,
- _shakeZ: !1,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._randRange = d, this._shakeZ = e, !0) : !1
- },
- update: function(a) {
- a = this._gridSize;
- for (var c = this._randRange, d = cc.p(0, 0), e = 0; e < a.width; ++e)
- for (var f = 0; f < a.height; ++f) {
- d.x = e;
- d.y = f;
- var g = this.originalTile(d);
- g.bl.x += cc.rand() % (2 * c) - c;
- g.br.x += cc.rand() % (2 * c) - c;
- g.tl.x += cc.rand() % (2 * c) - c;
- g.tr.x += cc.rand() % (2 * c) - c;
- g.bl.y += cc.rand() % (2 * c) - c;
- g.br.y += cc.rand() % (2 * c) - c;
- g.tl.y += cc.rand() % (2 * c) - c;
- g.tr.y += cc.rand() % (2 * c) - c;
- this._shakeZ && (g.bl.z += cc.rand() % (2 * c) - c, g.br.z += cc.rand() % (2 * c) - c, g.tl.z += cc.rand() % (2 * c) - c, g.tr.z += cc.rand() % (2 * c) - c);
- this.setTile(d, g)
- }
- }
- });
- cc.shakyTiles3D = function(a, c, d, e) {
- return new cc.ShakyTiles3D(a, c, d, e)
- };
- cc.ShakyTiles3D.create = cc.shakyTiles3D;
- cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend({
- _randRange: 0,
- _once: !1,
- _shatterZ: !1,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- initWithDuration: function(a, c, d, e) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._once = !1, this._randRange = d, this._shatterZ = e, !0) : !1
- },
- update: function(a) {
- if (!1 === this._once) {
- a = this._gridSize;
- for (var c = this._randRange, d, e = cc.p(0, 0), f = 0; f < a.width; ++f)
- for (var g = 0; g < a.height; ++g) e.x = f, e.y = g, d = this.originalTile(e), d.bl.x += cc.rand() % (2 * c) - c, d.br.x += cc.rand() % (2 * c) - c, d.tl.x += cc.rand() % (2 * c) - c, d.tr.x += cc.rand() % (2 * c) - c, d.bl.y += cc.rand() % (2 * c) - c, d.br.y += cc.rand() % (2 * c) - c, d.tl.y += cc.rand() % (2 * c) - c, d.tr.y += cc.rand() % (2 * c) - c, this._shatterZ && (d.bl.z += cc.rand() % (2 * c) - c, d.br.z += cc.rand() % (2 * c) - c, d.tl.z += cc.rand() % (2 * c) - c, d.tr.z += cc.rand() % (2 * c) - c), this.setTile(e, d);
- this._once = !0
- }
- }
- });
- cc.shatteredTiles3D = function(a, c, d, e) {
- return new cc.ShatteredTiles3D(a, c, d, e)
- };
- cc.ShatteredTiles3D.create = cc.shatteredTiles3D;
- cc.Tile = function(a, c, d) {
- this.position = a || cc.p(0, 0);
- this.startPosition = c || cc.p(0, 0);
- this.delta = d || cc.p(0, 0)
- };
- cc.ShuffleTiles = cc.TiledGrid3DAction.extend({
- _seed: 0,
- _tilesCount: 0,
- _tilesOrder: null,
- _tiles: null,
- ctor: function(a, c, d) {
- cc.GridAction.prototype.ctor.call(this);
- this._tilesOrder = [];
- this._tiles = [];
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._seed = d, this._tilesOrder.length = 0, this._tiles.length = 0, !0) : !1
- },
- shuffle: function(a, c) {
- for (var d = c - 1; 0 <= d; d--) {
- var e = 0 | cc.rand() % (d + 1),
- f = a[d];
- a[d] = a[e];
- a[e] = f
- }
- },
- getDelta: function(a) {
- var c = this._gridSize,
- d = a.width * c.height + a.height;
- return cc.size(this._tilesOrder[d] / c.height - a.width, this._tilesOrder[d] % c.height - a.height)
- },
- placeTile: function(a, c) {
- var d = this.originalTile(a),
- e = this.target.grid.getStep(),
- f = c.position;
- d.bl.x += f.x * e.x;
- d.bl.y += f.y * e.y;
- d.br.x += f.x * e.x;
- d.br.y += f.y * e.y;
- d.tl.x += f.x * e.x;
- d.tl.y += f.y * e.y;
- d.tr.x += f.x * e.x;
- d.tr.y += f.y * e.y;
- this.setTile(a, d)
- },
- startWithTarget: function(a) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
- a = this._gridSize;
- this._tilesCount = a.width * a.height;
- for (var c = this._tilesOrder, d = c.length = 0; d < this._tilesCount; ++d) c[d] = d;
- this.shuffle(c, this._tilesCount);
- for (var c = this._tiles, d = c.length = 0, e = cc.size(0, 0), f = 0; f < a.width; ++f)
- for (var g = 0; g < a.height; ++g) c[d] = new cc.Tile, c[d].position = cc.p(f, g), c[d].startPosition = cc.p(f, g), e.width = f, e.height = g, c[d].delta = this.getDelta(e), ++d
- },
- update: function(a) {
- for (var c = 0, d = this._gridSize, e = this._tiles, f, g = cc.p(0, 0), h = 0; h < d.width; ++h)
- for (var k = 0; k < d.height; ++k) g.x = h, g.y = k, f = e[c], f.position.x = f.delta.width * a, f.position.y = f.delta.height * a, this.placeTile(g, f), ++c
- }
- });
- cc.shuffleTiles = function(a, c, d) {
- return new cc.ShuffleTiles(a, c, d)
- };
- cc.ShuffleTiles.create = cc.shuffleTiles;
- cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend({
- testFunc: function(a, c) {
- var d = this._gridSize.width * c,
- e = this._gridSize.height * c;
- return 0 == d + e ? 1 : Math.pow((a.width + a.height) / (d + e), 6)
- },
- turnOnTile: function(a) {
- this.setTile(a, this.originalTile(a))
- },
- turnOffTile: function(a) {
- this.setTile(a, new cc.Quad3)
- },
- transformTile: function(a, c) {
- var d = this.originalTile(a),
- e = this.target.grid.getStep();
- d.bl.x += e.x / 2 * (1 - c);
- d.bl.y += e.y / 2 * (1 - c);
- d.br.x -= e.x / 2 * (1 - c);
- d.br.y += e.y / 2 * (1 - c);
- d.tl.x += e.x / 2 * (1 - c);
- d.tl.y -= e.y / 2 * (1 - c);
- d.tr.x -= e.x / 2 * (1 - c);
- d.tr.y -= e.y / 2 * (1 - c);
- this.setTile(a, d)
- },
- update: function(a) {
- for (var c = this._gridSize, d = cc.p(0, 0), e = cc.size(0, 0), f, g = 0; g < c.width; ++g)
- for (var h = 0; h < c.height; ++h) d.x = g, d.y = h, e.width = g, e.height = h, f = this.testFunc(e, a), 0 == f ? this.turnOffTile(d) : 1 > f ? this.transformTile(d, f) : this.turnOnTile(d)
- }
- });
- cc.fadeOutTRTiles = function(a, c) {
- return new cc.FadeOutTRTiles(a, c)
- };
- cc.FadeOutTRTiles.create = cc.fadeOutTRTiles;
- cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend({
- testFunc: function(a, c) {
- return 0 == a.width + a.height ? 1 : Math.pow((this._gridSize.width * (1 - c) + this._gridSize.height * (1 - c)) / (a.width + a.height), 6)
- }
- });
- cc.fadeOutBLTiles = function(a, c) {
- return new cc.FadeOutBLTiles(a, c)
- };
- cc.FadeOutBLTiles.create = cc.fadeOutBLTiles;
- cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend({
- testFunc: function(a, c) {
- var d = this._gridSize.height * c;
- return 0 == d ? 1 : Math.pow(a.height / d, 6)
- },
- transformTile: function(a, c) {
- var d = this.originalTile(a),
- e = this.target.grid.getStep();
- d.bl.y += e.y / 2 * (1 - c);
- d.br.y += e.y / 2 * (1 - c);
- d.tl.y -= e.y / 2 * (1 - c);
- d.tr.y -= e.y / 2 * (1 - c);
- this.setTile(a, d)
- }
- });
- cc.fadeOutUpTiles = function(a, c) {
- return new cc.FadeOutUpTiles(a, c)
- };
- cc.FadeOutUpTiles.create = cc.fadeOutUpTiles;
- cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend({
- testFunc: function(a, c) {
- return 0 == a.height ? 1 : Math.pow(this._gridSize.height * (1 - c) / a.height, 6)
- }
- });
- cc.fadeOutDownTiles = function(a, c) {
- return new cc.FadeOutDownTiles(a, c)
- };
- cc.FadeOutDownTiles.create = cc.fadeOutDownTiles;
- cc.TurnOffTiles = cc.TiledGrid3DAction.extend({
- _seed: null,
- _tilesCount: 0,
- _tilesOrder: null,
- ctor: function(a, c, d) {
- cc.GridAction.prototype.ctor.call(this);
- this._tilesOrder = [];
- void 0 !== c && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._seed = d || 0, this._tilesOrder.length = 0, !0) : !1
- },
- shuffle: function(a, c) {
- for (var d = c - 1; 0 <= d; d--) {
- var e = 0 | cc.rand() % (d + 1),
- f = a[d];
- a[d] = a[e];
- a[e] = f
- }
- },
- turnOnTile: function(a) {
- this.setTile(a, this.originalTile(a))
- },
- turnOffTile: function(a) {
- this.setTile(a, new cc.Quad3)
- },
- startWithTarget: function(a) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
- this._tilesCount = this._gridSize.width * this._gridSize.height;
- a = this._tilesOrder;
- for (var c = a.length = 0; c < this._tilesCount; ++c) a[c] = c;
- this.shuffle(a, this._tilesCount)
- },
- update: function(a) {
- a = 0 | a * this._tilesCount;
- for (var c = this._gridSize, d, e = cc.p(0, 0), f = this._tilesOrder, g = 0; g < this._tilesCount; g++) d = f[g], e.x = 0 | d / c.height, e.y = d % (0 | c.height), g < a ? this.turnOffTile(e) : this.turnOnTile(e)
- }
- });
- cc.turnOffTiles = function(a, c, d) {
- return new cc.TurnOffTiles(a, c, d)
- };
- cc.TurnOffTiles.create = cc.turnOffTiles;
- cc.WavesTiles3D = cc.TiledGrid3DAction.extend({
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- for (var c = this._gridSize, d = this._waves, e = this._amplitude, f = this._amplitudeRate, g = cc.p(0, 0), h, k = 0; k < c.width; k++)
- for (var m = 0; m < c.height; m++) g.x = k, g.y = m, h = this.originalTile(g), h.bl.z = Math.sin(2 * a * Math.PI * d + 0.01 * (h.bl.y + h.bl.x)) * e * f, h.br.z = h.bl.z, h.tl.z = h.bl.z, h.tr.z = h.bl.z, this.setTile(g, h)
- }
- });
- cc.wavesTiles3D = function(a, c, d, e) {
- return new cc.WavesTiles3D(a, c, d, e)
- };
- cc.WavesTiles3D.create = cc.wavesTiles3D;
- cc.JumpTiles3D = cc.TiledGrid3DAction.extend({
- _jumps: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- ctor: function(a, c, d, e) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== e && this.initWithDuration(a, c, d, e)
- },
- getAmplitude: function() {
- return this._amplitude
- },
- setAmplitude: function(a) {
- this._amplitude = a
- },
- getAmplitudeRate: function() {
- return this._amplitudeRate
- },
- setAmplitudeRate: function(a) {
- this._amplitudeRate = a
- },
- initWithDuration: function(a, c, d, e) {
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._jumps = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
- },
- update: function(a) {
- var c = Math.sin(2 * Math.PI * a * this._jumps) * this._amplitude * this._amplitudeRate;
- a = Math.sin(Math.PI * (2 * a * this._jumps + 1)) * this._amplitude * this._amplitudeRate;
- for (var d = this._gridSize, e = this.target.grid, f, g = cc.p(0, 0), h = 0; h < d.width; h++)
- for (var k = 0; k < d.height; k++) g.x = h, g.y = k, f = e.originalTile(g), 0 == (h + k) % 2 ? (f.bl.z += c, f.br.z += c, f.tl.z += c, f.tr.z += c) : (f.bl.z += a, f.br.z += a, f.tl.z += a, f.tr.z += a), e.setTile(g, f)
- }
- });
- cc.jumpTiles3D = function(a, c, d, e) {
- return new cc.JumpTiles3D(a, c, d, e)
- };
- cc.JumpTiles3D.create = cc.jumpTiles3D;
- cc.SplitRows = cc.TiledGrid3DAction.extend({
- _rows: 0,
- _winSize: null,
- ctor: function(a, c) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- this._rows = c;
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, c))
- },
- update: function(a) {
- for (var c = this._gridSize, d = this._winSize.width, e, f, g = cc.p(0, 0), h = 0; h < c.height; ++h) g.y = h, e = this.originalTile(g), f = 1, 0 == h % 2 && (f = -1), e.bl.x += f * d * a, e.br.x += f * d * a, e.tl.x += f * d * a, e.tr.x += f * d * a, this.setTile(g, e)
- },
- startWithTarget: function(a) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
- this._winSize = cc.director.getWinSizeInPixels()
- }
- });
- cc.splitRows = function(a, c) {
- return new cc.SplitRows(a, c)
- };
- cc.SplitRows.create = cc.splitRows;
- cc.SplitCols = cc.TiledGrid3DAction.extend({
- _cols: 0,
- _winSize: null,
- ctor: function(a, c) {
- cc.GridAction.prototype.ctor.call(this);
- void 0 !== c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- this._cols = c;
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(c, 1))
- },
- update: function(a) {
- for (var c = this._gridSize.width, d = this._winSize.height, e, f, g = cc.p(0, 0), h = 0; h < c; ++h) g.x = h, e = this.originalTile(g), f = 1, 0 == h % 2 && (f = -1), e.bl.y += f * d * a, e.br.y += f * d * a, e.tl.y += f * d * a, e.tr.y += f * d * a, this.setTile(g, e)
- },
- startWithTarget: function(a) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
- this._winSize = cc.director.getWinSizeInPixels()
- }
- });
- cc.splitCols = function(a, c) {
- return new cc.SplitCols(a, c)
- };
- cc.SplitCols.create = cc.splitCols;
- cc.PageTurn3D = cc.Grid3DAction.extend({
- update: function(a) {
- var c = Math.max(0, a - 0.25),
- c = -100 - 500 * c * c;
- a = -Math.PI / 2 * Math.sqrt(a);
- var d = +Math.PI / 2 + a;
- a = Math.sin(d);
- for (var d = Math.cos(d), e = this._gridSize, f = cc.p(0, 0), g = 0; g <= e.width; ++g)
- for (var h = 0; h <= e.height; ++h) {
- f.x = g;
- f.y = h;
- var k = this.originalVertex(f),
- m = Math.sqrt(k.x * k.x + (k.y - c) * (k.y - c)),
- n = m * a,
- q = Math.asin(k.x / m) / a,
- r = Math.cos(q);
- k.x = q <= Math.PI ? n * Math.sin(q) : 0;
- k.y = m + c - n * (1 - r) * a;
- k.z = n * (1 - r) * d / 7;
- 0.5 > k.z && (k.z = 0.5);
- this.setVertex(f, k)
- }
- }
- });
- cc.pageTurn3D = function(a, c) {
- return new cc.PageTurn3D(a, c)
- };
- cc.PageTurn3D.create = cc.pageTurn3D;
- cc.ProgressTimer = cc.Node.extend({
- _type: null,
- _percentage: 0,
- _sprite: null,
- _midPoint: null,
- _barChangeRate: null,
- _reverseDirection: !1,
- _className: "ProgressTimer",
- getMidpoint: function() {
- return cc.p(this._midPoint.x, this._midPoint.y)
- },
- setMidpoint: function(a) {
- this._midPoint = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
- },
- getBarChangeRate: function() {
- return cc.p(this._barChangeRate.x, this._barChangeRate.y)
- },
- setBarChangeRate: function(a) {
- this._barChangeRate = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
- },
- getType: function() {
- return this._type
- },
- getPercentage: function() {
- return this._percentage
- },
- getSprite: function() {
- return this._sprite
- },
- setPercentage: function(a) {
- this._percentage != a && (this._percentage = cc.clampf(a, 0, 100), this._updateProgress())
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- },
- isReverseDirection: function() {
- return this._reverseDirection
- },
- _boundaryTexCoord: function(a) {
- if (a < cc.ProgressTimer.TEXTURE_COORDS_COUNT) {
- var c = cc.ProgressTimer.TEXTURE_COORDS;
- return this._reverseDirection ? cc.p(c >> 7 - (a << 1) & 1, c >> 7 - ((a << 1) + 1) & 1) : cc.p(c >> (a << 1) + 1 & 1, c >> (a << 1) & 1)
- }
- return cc.p(0, 0)
- },
- _origin: null,
- _startAngle: 270,
- _endAngle: 270,
- _radius: 0,
- _counterClockWise: !1,
- _barRect: null,
- _vertexDataCount: 0,
- _vertexData: null,
- _vertexArrayBuffer: null,
- _vertexWebGLBuffer: null,
- _vertexDataDirty: !1,
- ctor: null,
- _ctorForCanvas: function(a) {
- cc.Node.prototype.ctor.call(this);
- this._type = cc.ProgressTimer.TYPE_RADIAL;
- this._percentage = 0;
- this._midPoint = cc.p(0, 0);
- this._barChangeRate = cc.p(0, 0);
- this._reverseDirection = !1;
- this._sprite = null;
- this._origin = cc.p(0, 0);
- this._endAngle = this._startAngle = 270;
- this._radius = 0;
- this._counterClockWise = !1;
- this._barRect = cc.rect(0, 0, 0, 0);
- a && this._initWithSpriteForCanvas(a)
- },
- _ctorForWebGL: function(a) {
- cc.Node.prototype.ctor.call(this);
- this._type = cc.ProgressTimer.TYPE_RADIAL;
- this._percentage = 0;
- this._midPoint = cc.p(0, 0);
- this._barChangeRate = cc.p(0, 0);
- this._reverseDirection = !1;
- this._sprite = null;
- this._vertexWebGLBuffer = cc._renderContext.createBuffer();
- this._vertexDataCount = 0;
- this._vertexArrayBuffer = this._vertexData = null;
- this._vertexDataDirty = !1;
- a && this._initWithSpriteForWebGL(a)
- },
- setColor: function(a) {
- this._sprite.color = a;
- this._updateColor()
- },
- setOpacity: function(a) {
- this._sprite.opacity = a;
- this._updateColor()
- },
- getColor: function() {
- return this._sprite.color
- },
- getOpacity: function() {
- return this._sprite.opacity
- },
- setReverseProgress: null,
- _setReverseProgressForCanvas: function(a) {
- this._reverseDirection !== a && (this._reverseDirection = a)
- },
- _setReverseProgressForWebGL: function(a) {
- this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
- },
- setSprite: null,
- _setSpriteForCanvas: function(a) {
- this._sprite != a && (this._sprite = a, this.width = this._sprite.width, this.height = this._sprite.height)
- },
- _setSpriteForWebGL: function(a) {
- a && this._sprite != a && (this._sprite = a, this.width = a.width, this.height = a.height, this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0))
- },
- setType: null,
- _setTypeForCanvas: function(a) {
- a !== this._type && (this._type = a)
- },
- _setTypeForWebGL: function(a) {
- a !== this._type && (this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0), this._type = a)
- },
- setReverseDirection: null,
- _setReverseDirectionForCanvas: function(a) {
- this._reverseDirection !== a && (this._reverseDirection = a)
- },
- _setReverseDirectionForWebGL: function(a) {
- this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
- },
- _textureCoordFromAlphaPoint: function(a) {
- var c = this._sprite;
- if (!c) return {
- u: 0,
- v: 0
- };
- var d = c.quad,
- e = cc.p(d.bl.texCoords.u, d.bl.texCoords.v),
- d = cc.p(d.tr.texCoords.u, d.tr.texCoords.v);
- c.textureRectRotated && (c = a.x, a.x = a.y, a.y = c);
- return {
- u: e.x * (1 - a.x) + d.x * a.x,
- v: e.y * (1 - a.y) + d.y * a.y
- }
- },
- _vertexFromAlphaPoint: function(a) {
- if (!this._sprite) return {
- x: 0,
- y: 0
- };
- var c = this._sprite.quad,
- d = cc.p(c.bl.vertices.x, c.bl.vertices.y),
- c = cc.p(c.tr.vertices.x, c.tr.vertices.y);
- return {
- x: d.x * (1 - a.x) + c.x * a.x,
- y: d.y * (1 - a.y) + c.y * a.y
- }
- },
- initWithSprite: null,
- _initWithSpriteForCanvas: function(a) {
- this.percentage = 0;
- this.anchorY = this.anchorX = 0.5;
- this._type = cc.ProgressTimer.TYPE_RADIAL;
- this._reverseDirection = !1;
- this.midPoint = cc.p(0.5, 0.5);
- this.barChangeRate = cc.p(1, 1);
- this.sprite = a;
- return !0
- },
- _initWithSpriteForWebGL: function(a) {
- this.percentage = 0;
- this._vertexArrayBuffer = this._vertexData = null;
- this._vertexDataCount = 0;
- this.anchorY = this.anchorX = 0.5;
- this._type = cc.ProgressTimer.TYPE_RADIAL;
- this._reverseDirection = !1;
- this.midPoint = cc.p(0.5, 0.5);
- this.barChangeRate = cc.p(1, 1);
- this.sprite = a;
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
- return !0
- },
- draw: null,
- _drawForCanvas: function(a) {
- a = a || cc._renderContext;
- var c = this._sprite;
- c._isLighterMode && (a.globalCompositeOperation = "lighter");
- var d = cc.view.getScaleX(),
- e = cc.view.getScaleY();
- a.globalAlpha = c._displayedOpacity / 255;
- var f = c._rect,
- g = c._contentSize,
- h = c._offsetPosition,
- k = c._drawSize_Canvas,
- m = 0 | h.x,
- n = -h.y - f.height,
- q = c._textureRect_Canvas;
- k.width = f.width * d;
- k.height = f.height * e;
- a.save();
- c._flippedX && (m = -h.x - f.width, a.scale(-1, 1));
- c._flippedY && (n = h.y, a.scale(1, -1));
- m *= d;
- n *= e;
- this._type == cc.ProgressTimer.TYPE_BAR ? (f = this._barRect, a.beginPath(), a.rect(f.x * d, f.y * e, f.width * d, f.height * e), a.clip(), a.closePath()) : this._type == cc.ProgressTimer.TYPE_RADIAL && (f = this._origin.x * d, h = this._origin.y * e, a.beginPath(), a.arc(f, h, this._radius * e, Math.PI / 180 * this._startAngle, Math.PI / 180 * this._endAngle, this._counterClockWise), a.lineTo(f, h), a.clip(), a.closePath());
- c._texture && q.validRect ? (d = c._texture.getHtmlElementObj(), this._colorized ? a.drawImage(d, 0, 0, q.width, q.height, m, n, k.width, k.height) : a.drawImage(d, q.x, q.y, q.width, q.height, m, n, k.width, k.height)) : 0 !== g.width && (k = this.color, a.fillStyle = "rgba(" + k.r + "," + k.g + "," + k.b + ",1)", a.fillRect(m, n, g.width * d, g.height * e));
- a.restore();
- cc.incrementGLDraws(1)
- },
- _drawForWebGL: function(a) {
- a = a || cc._renderContext;
- if (this._vertexData && this._sprite) {
- cc.nodeDrawSetup(this);
- var c = this._sprite.getBlendFunc();
- cc.glBlendFunc(c.src, c.dst);
- cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
- cc.glBindTexture2D(this._sprite.texture);
- a.bindBuffer(a.ARRAY_BUFFER, this._vertexWebGLBuffer);
- this._vertexDataDirty && (a.bufferData(a.ARRAY_BUFFER, this._vertexArrayBuffer, a.DYNAMIC_DRAW), this._vertexDataDirty = !1);
- c = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, c, 0);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, c, 8);
- a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, c, 12);
- this._type === cc.ProgressTimer.TYPE_RADIAL ? a.drawArrays(a.TRIANGLE_FAN, 0, this._vertexDataCount) : this._type == cc.ProgressTimer.TYPE_BAR && (this._reverseDirection ? (a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount / 2), a.drawArrays(a.TRIANGLE_STRIP, 4, this._vertexDataCount / 2), cc.g_NumberOfDraws++) : a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount));
- cc.g_NumberOfDraws++
- }
- },
- _updateRadial: function() {
- if (this._sprite) {
- var a, c = this._midPoint;
- a = this._percentage / 100;
- var d = 2 * cc.PI * (this._reverseDirection ? a : 1 - a),
- e = cc.p(c.x, 1),
- f = cc.pRotateByAngle(e, c, d),
- d = 0;
- if (0 == a) f = e, d = 0;
- else if (1 == a) f = e, d = 4;
- else {
- var g = cc.FLT_MAX,
- h = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
- for (a = 0; a <= h; ++a) {
- var k = (a + (h - 1)) % h,
- m = this._boundaryTexCoord(a % h),
- k = this._boundaryTexCoord(k);
- 0 == a ? k = cc.pLerp(m, k, 1 - c.x) : 4 == a && (m = cc.pLerp(m, k, 1 - c.x));
- var n = cc.p(0, 0);
- if (cc.pLineIntersect(m, k, c, f, n) && (!(0 == a || 4 == a) || 0 <= n.x && 1 >= n.x) && 0 <= n.y && n.y < g) g = n.y, d = a
- }
- f = cc.pAdd(c, cc.pMult(cc.pSub(f, c), g))
- }
- g = !0;
- this._vertexDataCount != d + 3 && (g = !1, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0);
- if (!this._vertexData) {
- h = this._vertexDataCount = d + 3;
- m = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- this._vertexArrayBuffer = new ArrayBuffer(h * m);
- k = [];
- for (a = 0; a < h; a++) k[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * m);
- this._vertexData = k;
- if (!this._vertexData) {
- cc.log("cc.ProgressTimer._updateRadial() : Not enough memory");
- return
- }
- }
- this._updateColor();
- h = this._vertexData;
- if (!g) {
- h[0].texCoords = this._textureCoordFromAlphaPoint(c);
- h[0].vertices = this._vertexFromAlphaPoint(c);
- h[1].texCoords = this._textureCoordFromAlphaPoint(e);
- h[1].vertices = this._vertexFromAlphaPoint(e);
- for (a = 0; a < d; a++) c = this._boundaryTexCoord(a), h[a + 2].texCoords = this._textureCoordFromAlphaPoint(c), h[a + 2].vertices = this._vertexFromAlphaPoint(c)
- }
- h[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(f);
- h[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(f)
- }
- },
- _updateBar: function() {
- if (this._sprite) {
- var a, c = this._percentage / 100,
- d = this._barChangeRate,
- d = cc.pMult(cc.p(1 - d.x + c * d.x, 1 - d.y + c * d.y), 0.5),
- c = cc.pSub(this._midPoint, d),
- d = cc.pAdd(this._midPoint, d);
- 0 > c.x && (d.x += -c.x, c.x = 0);
- 1 < d.x && (c.x -= d.x - 1, d.x = 1);
- 0 > c.y && (d.y += -c.y, c.y = 0);
- 1 < d.y && (c.y -= d.y - 1, d.y = 1);
- if (this._reverseDirection) {
- if (!this._vertexData) {
- this._vertexDataCount = 8;
- var e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- this._vertexArrayBuffer = new ArrayBuffer(8 * e);
- var f = [];
- for (a = 0; 8 > a; a++) f[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * e);
- f[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1));
- f[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1));
- f[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0));
- f[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0));
- f[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1));
- f[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1));
- f[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0));
- f[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0));
- this._vertexData = f
- }
- a = this._vertexData;
- a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, d.y));
- a[2].vertices = this._vertexFromAlphaPoint(cc.p(c.x, d.y));
- a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
- a[3].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
- a[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
- a[4].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
- a[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, c.y));
- a[5].vertices = this._vertexFromAlphaPoint(cc.p(d.x, c.y))
- } else {
- if (!this._vertexData) {
- this._vertexDataCount = 4;
- e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
- this._vertexArrayBuffer = new ArrayBuffer(4 * e);
- this._vertexData = [];
- for (a = 0; 4 > a; a++) this._vertexData[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * e)
- }
- a = this._vertexData;
- a[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, d.y));
- a[0].vertices = this._vertexFromAlphaPoint(cc.p(c.x, d.y));
- a[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
- a[1].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
- a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
- a[2].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
- a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, c.y));
- a[3].vertices = this._vertexFromAlphaPoint(cc.p(d.x, c.y))
- }
- this._updateColor()
- }
- },
- _updateColor: function() {
- if (this._sprite && this._vertexData) {
- for (var a = this._sprite.quad.tl.colors, c = this._vertexData, d = 0, e = this._vertexDataCount; d < e; ++d) c[d].colors = a;
- this._vertexDataDirty = !0
- }
- },
- _updateProgress: null,
- _updateProgressForCanvas: function() {
- var a = this._sprite,
- c = a.width,
- d = a.height,
- e = this._midPoint;
- if (this._type == cc.ProgressTimer.TYPE_RADIAL) {
- this._radius = Math.round(Math.sqrt(c * c + d * d));
- var f, g = !1,
- h = this._origin;
- h.x = c * e.x;
- h.y = -d * e.y;
- this._reverseDirection ? (f = 270, e = 270 - 3.6 * this._percentage) : (e = -90, f = -90 + 3.6 * this._percentage);
- a._flippedX && (h.x -= c * 2 * this._midPoint.x, e = -e - 180, f = -f - 180, g = !g);
- a._flippedY && (h.y += d * 2 * this._midPoint.y, g = !g, e = -e, f = -f);
- this._startAngle = e;
- this._endAngle = f;
- this._counterClockWise = g
- } else {
- f = this._barChangeRate;
- h = this._percentage / 100;
- g = this._barRect;
- f = cc.size(c * (1 - f.x), d * (1 - f.y));
- var h = cc.size((c - f.width) * h, (d - f.height) * h),
- h = cc.size(f.width + h.width, f.height + h.height),
- k = cc.p(c * e.x, d * e.y);
- f = k.x - h.width / 2;
- 0.5 < e.x && h.width / 2 >= c - k.x && (f = c - h.width);
- c = k.y - h.height / 2;
- 0.5 < e.y && h.height / 2 >= d - k.y && (c = d - h.height);
- g.x = 0;
- d = 1;
- a._flippedX && (g.x -= h.width, d = -1);
- 0 < f && (g.x += f * d);
- g.y = 0;
- d = 1;
- a._flippedY && (g.y += h.height, d = -1);
- 0 < c && (g.y -= c * d);
- g.width = h.width;
- g.height = -h.height
- }
- },
- _updateProgressForWebGL: function() {
- var a = this._type;
- a === cc.ProgressTimer.TYPE_RADIAL ? this._updateRadial() : a === cc.ProgressTimer.TYPE_BAR && this._updateBar();
- this._vertexDataDirty = !0
- }
- });
- _p = cc.ProgressTimer.prototype;
- cc._renderType == cc._RENDER_TYPE_WEBGL ? (_p.ctor = _p._ctorForWebGL, _p.setReverseProgress = _p._setReverseProgressForWebGL, _p.setSprite = _p._setSpriteForWebGL, _p.setType = _p._setTypeForWebGL, _p.setReverseDirection = _p._setReverseDirectionForWebGL, _p.initWithSprite = _p._initWithSpriteForWebGL, _p.draw = _p._drawForWebGL, _p._updateProgress = _p._updateProgressForWebGL) : (_p.ctor = _p._ctorForCanvas, _p.setReverseProgress = _p._setReverseProgressForCanvas, _p.setSprite = _p._setSpriteForCanvas, _p.setType = _p._setTypeForCanvas, _p.setReverseDirection = _p._setReverseDirectionForCanvas, _p.initWithSprite = _p._initWithSpriteForCanvas, _p.draw = _p._drawForCanvas, _p._updateProgress = cc.ProgressTimer.prototype._updateProgressForCanvas);
- cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint);
- cc.defineGetterSetter(_p, "barChangeRate", _p.getBarChangeRate, _p.setBarChangeRate);
- cc.defineGetterSetter(_p, "type", _p.getType, _p.setType);
- cc.defineGetterSetter(_p, "percentage", _p.getPercentage, _p.setPercentage);
- cc.defineGetterSetter(_p, "sprite", _p.getSprite, _p.setSprite);
- cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDirection);
- cc.ProgressTimer.create = function(a) {
- return new cc.ProgressTimer(a)
- };
- cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4;
- cc.ProgressTimer.TEXTURE_COORDS = 75;
- cc.ProgressTimer.TYPE_RADIAL = 0;
- cc.ProgressTimer.TYPE_BAR = 1;
- cc.ProgressTo = cc.ActionInterval.extend({
- _to: 0,
- _from: 0,
- ctor: function(a, c) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._from = this._to = 0;
- void 0 !== c && this.initWithDuration(a, c)
- },
- initWithDuration: function(a, c) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = c, !0) : !1
- },
- clone: function() {
- var a = new cc.ProgressTo;
- a.initWithDuration(this._duration, this._to);
- return a
- },
- reverse: function() {
- cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported.");
- return null
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a);
- this._from = a.percentage;
- 100 == this._from && (this._from = 0)
- },
- update: function(a) {
- this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
- }
- });
- cc.progressTo = function(a, c) {
- return new cc.ProgressTo(a, c)
- };
- cc.ProgressTo.create = cc.progressTo;
- cc.ProgressFromTo = cc.ActionInterval.extend({
- _to: 0,
- _from: 0,
- ctor: function(a, c, d) {
- cc.ActionInterval.prototype.ctor.call(this);
- this._from = this._to = 0;
- void 0 !== d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = d, this._from = c, !0) : !1
- },
- clone: function() {
- var a = new cc.ProgressFromTo;
- a.initWithDuration(this._duration, this._from, this._to);
- return a
- },
- reverse: function() {
- return cc.ProgressFromTo.create(this._duration, this._to, this._from)
- },
- startWithTarget: function(a) {
- cc.ActionInterval.prototype.startWithTarget.call(this, a)
- },
- update: function(a) {
- this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
- }
- });
- cc.progressFromTo = function(a, c, d) {
- return new cc.ProgressFromTo(a, c, d)
- };
- cc.ProgressFromTo.create = cc.progressFromTo;
- cc.SCENE_FADE = 4208917214;
- cc.TRANSITION_ORIENTATION_LEFT_OVER = 0;
- cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1;
- cc.TRANSITION_ORIENTATION_UP_OVER = 0;
- cc.TRANSITION_ORIENTATION_DOWN_OVER = 1;
- cc.TransitionScene = cc.Scene.extend({
- _inScene: null,
- _outScene: null,
- _duration: null,
- _isInSceneOnTop: !1,
- _isSendCleanupToScene: !1,
- _className: "TransitionScene",
- ctor: function(a, c) {
- cc.Scene.prototype.ctor.call(this);
- void 0 !== a && void 0 !== c && this.initWithDuration(a, c)
- },
- _setNewScene: function(a) {
- this.unschedule(this._setNewScene);
- a = cc.director;
- this._isSendCleanupToScene = a.isSendCleanupToScene();
- a.runScene(this._inScene);
- cc.eventManager.setEnabled(!0);
- this._outScene.visible = !0
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !0
- },
- draw: function() {
- this._isInSceneOnTop ? (this._outScene.visit(), this._inScene.visit()) : (this._inScene.visit(), this._outScene.visit())
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- cc.eventManager.setEnabled(!1);
- this._outScene.onExitTransitionDidStart();
- this._inScene.onEnter()
- },
- onExit: function() {
- cc.Node.prototype.onExit.call(this);
- cc.eventManager.setEnabled(!0);
- this._outScene.onExit();
- this._inScene.onEnterTransitionDidFinish()
- },
- cleanup: function() {
- cc.Node.prototype.cleanup.call(this);
- this._isSendCleanupToScene && this._outScene.cleanup()
- },
- initWithDuration: function(a, c) {
- if (!c) throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";
- if (this.init()) {
- this._duration = a;
- this.attr({
- x: 0,
- y: 0,
- anchorX: 0,
- anchorY: 0
- });
- this._inScene = c;
- this._outScene = cc.director.getRunningScene();
- this._outScene || (this._outScene = cc.Scene.create(), this._outScene.init());
- if (this._inScene == this._outScene) throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
- this._sceneOrder();
- return !0
- }
- return !1
- },
- finish: function() {
- this._inScene.attr({
- visible: !0,
- x: 0,
- y: 0,
- scale: 1,
- rotation: 0
- });
- cc._renderType === cc._RENDER_TYPE_WEBGL && this._inScene.getCamera().restore();
- this._outScene.attr({
- visible: !1,
- x: 0,
- y: 0,
- scale: 1,
- rotation: 0
- });
- cc._renderType === cc._RENDER_TYPE_WEBGL && this._outScene.getCamera().restore();
- this.schedule(this._setNewScene, 0)
- },
- hideOutShowIn: function() {
- this._inScene.visible = !0;
- this._outScene.visible = !1
- }
- });
- cc.TransitionScene.create = function(a, c) {
- return new cc.TransitionScene(a, c)
- };
- cc.TransitionSceneOriented = cc.TransitionScene.extend({
- _orientation: 0,
- ctor: function(a, c, d) {
- cc.TransitionScene.prototype.ctor.call(this);
- void 0 != d && this.initWithDuration(a, c, d)
- },
- initWithDuration: function(a, c, d) {
- cc.TransitionScene.prototype.initWithDuration.call(this, a, c) && (this._orientation = d);
- return !0
- }
- });
- cc.TransitionSceneOriented.create = function(a, c, d) {
- return new cc.TransitionSceneOriented(a, c, d)
- };
- cc.TransitionRotoZoom = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.attr({
- scale: 0.0010,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this._outScene.attr({
- scale: 1,
- anchorX: 0.5,
- anchorY: 0.5
- });
- var a = cc.Sequence.create(cc.Spawn.create(cc.ScaleBy.create(this._duration / 2, 0.0010), cc.RotateBy.create(this._duration / 2, 720)), cc.DelayTime.create(this._duration / 2));
- this._outScene.runAction(a);
- this._inScene.runAction(cc.Sequence.create(a.reverse(), cc.CallFunc.create(this.finish, this)))
- }
- });
- cc.TransitionRotoZoom.create = function(a, c) {
- return new cc.TransitionRotoZoom(a, c)
- };
- cc.TransitionJumpZoom = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.director.getWinSize();
- this._inScene.attr({
- scale: 0.5,
- x: a.width,
- y: 0,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this._outScene.anchorX = 0.5;
- this._outScene.anchorY = 0.5;
- var c = cc.JumpBy.create(this._duration / 4, cc.p(-a.width, 0), a.width / 4, 2),
- d = cc.ScaleTo.create(this._duration / 4, 1),
- a = cc.ScaleTo.create(this._duration / 4, 0.5),
- a = cc.Sequence.create(a, c),
- c = cc.Sequence.create(c, d),
- d = cc.DelayTime.create(this._duration / 2);
- this._outScene.runAction(a);
- this._inScene.runAction(cc.Sequence.create(d, c, cc.CallFunc.create(this.finish, this)))
- }
- });
- cc.TransitionJumpZoom.create = function(a, c) {
- return new cc.TransitionJumpZoom(a, c)
- };
- cc.TransitionMoveInL = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this.initScenes();
- var a = this.action();
- this._inScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this)))
- },
- initScenes: function() {
- this._inScene.setPosition(-cc.director.getWinSize().width, 0)
- },
- action: function() {
- return cc.MoveTo.create(this._duration, cc.p(0, 0))
- },
- easeActionWithAction: function(a) {
- return cc.EaseOut.create(a, 2)
- }
- });
- cc.TransitionMoveInL.create = function(a, c) {
- return new cc.TransitionMoveInL(a, c)
- };
- cc.TransitionMoveInR = cc.TransitionMoveInL.extend({
- ctor: function(a, c) {
- cc.TransitionMoveInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- initScenes: function() {
- this._inScene.setPosition(cc.director.getWinSize().width, 0)
- }
- });
- cc.TransitionMoveInR.create = function(a, c) {
- return new cc.TransitionMoveInR(a, c)
- };
- cc.TransitionMoveInT = cc.TransitionMoveInL.extend({
- ctor: function(a, c) {
- cc.TransitionMoveInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- initScenes: function() {
- this._inScene.setPosition(0, cc.director.getWinSize().height)
- }
- });
- cc.TransitionMoveInT.create = function(a, c) {
- return new cc.TransitionMoveInT(a, c)
- };
- cc.TransitionMoveInB = cc.TransitionMoveInL.extend({
- ctor: function(a, c) {
- cc.TransitionMoveInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- initScenes: function() {
- this._inScene.setPosition(0, -cc.director.getWinSize().height)
- }
- });
- cc.TransitionMoveInB.create = function(a, c) {
- return new cc.TransitionMoveInB(a, c)
- };
- cc.ADJUST_FACTOR = 0.5;
- cc.TransitionSlideInL = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this.initScenes();
- var a = this.action(),
- c = this.action(),
- a = this.easeActionWithAction(a),
- c = cc.Sequence.create(this.easeActionWithAction(c), cc.CallFunc.create(this.finish, this));
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- },
- initScenes: function() {
- this._inScene.setPosition(-cc.director.getWinSize().width + cc.ADJUST_FACTOR, 0)
- },
- action: function() {
- return cc.MoveBy.create(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0))
- },
- easeActionWithAction: function(a) {
- return cc.EaseOut.create(a, 2)
- }
- });
- cc.TransitionSlideInL.create = function(a, c) {
- return new cc.TransitionSlideInL(a, c)
- };
- cc.TransitionSlideInR = cc.TransitionSlideInL.extend({
- ctor: function(a, c) {
- cc.TransitionSlideInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !0
- },
- initScenes: function() {
- this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)
- },
- action: function() {
- return cc.MoveBy.create(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0))
- }
- });
- cc.TransitionSlideInR.create = function(a, c) {
- return new cc.TransitionSlideInR(a, c)
- };
- cc.TransitionSlideInB = cc.TransitionSlideInL.extend({
- ctor: function(a, c) {
- cc.TransitionSlideInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- },
- initScenes: function() {
- this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))
- },
- action: function() {
- return cc.MoveBy.create(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR))
- }
- });
- cc.TransitionSlideInB.create = function(a, c) {
- return new cc.TransitionSlideInB(a, c)
- };
- cc.TransitionSlideInT = cc.TransitionSlideInL.extend({
- ctor: function(a, c) {
- cc.TransitionSlideInL.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !0
- },
- initScenes: function() {
- this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)
- },
- action: function() {
- return cc.MoveBy.create(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)))
- }
- });
- cc.TransitionSlideInT.create = function(a, c) {
- return new cc.TransitionSlideInT(a, c)
- };
- cc.TransitionShrinkGrow = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.attr({
- scale: 0.0010,
- anchorX: 2 / 3,
- anchorY: 0.5
- });
- this._outScene.attr({
- scale: 1,
- anchorX: 1 / 3,
- anchorY: 0.5
- });
- var a = cc.ScaleTo.create(this._duration, 0.01),
- c = cc.ScaleTo.create(this._duration, 1);
- this._inScene.runAction(this.easeActionWithAction(c));
- this._outScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this)))
- },
- easeActionWithAction: function(a) {
- return cc.EaseOut.create(a, 2)
- }
- });
- cc.TransitionShrinkGrow.create = function(a, c) {
- return new cc.TransitionShrinkGrow(a, c)
- };
- cc.TransitionFlipX = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Show.create(), cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, 0, 0), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 0, 0), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionFlipX.create = function(a, c, d) {
- return new cc.TransitionFlipX(a, c, d)
- };
- cc.TransitionFlipY = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_UP_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Show.create(), cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, 90, 0), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 90, 0), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionFlipY.create = function(a, c, d) {
- return new cc.TransitionFlipY(a, c, d)
- };
- cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Show.create(), cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, -45, 0), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 45, 0), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionFlipAngular.create = function(a, c, d) {
- return new cc.TransitionFlipAngular(a, c, d)
- };
- cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, 0, 0), cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 0, 0), cc.ScaleTo.create(this._duration / 2, 0.5)), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.scale = 0.5;
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionZoomFlipX.create = function(a, c, d) {
- return new cc.TransitionZoomFlipX(a, c, d)
- };
- cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_UP_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, 90, 0), cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 90, 0), cc.ScaleTo.create(this._duration / 2, 0.5)), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.scale = 0.5;
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionZoomFlipY.create = function(a, c, d) {
- return new cc.TransitionZoomFlipY(a, c, d)
- };
- cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend({
- ctor: function(a, c, d) {
- cc.TransitionSceneOriented.prototype.ctor.call(this);
- d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a, c;
- this._inScene.visible = !1;
- var d;
- this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
- a = cc.Sequence.create(cc.DelayTime.create(this._duration / 2), cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, d, a, -45, 0), cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()), cc.Show.create(), cc.CallFunc.create(this.finish, this));
- c = cc.Sequence.create(cc.Spawn.create(cc.OrbitCamera.create(this._duration / 2, 1, 0, 0, c, 45, 0), cc.ScaleTo.create(this._duration / 2, 0.5)), cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.scale = 0.5;
- this._inScene.runAction(a);
- this._outScene.runAction(c)
- }
- });
- cc.TransitionZoomFlipAngular.create = function(a, c, d) {
- return new cc.TransitionZoomFlipAngular(a, c, d)
- };
- cc.TransitionFade = cc.TransitionScene.extend({
- _color: null,
- ctor: function(a, c, d) {
- cc.TransitionScene.prototype.ctor.call(this);
- this._color = cc.color();
- c && this.initWithDuration(a, c, d)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.LayerColor.create(this._color);
- this._inScene.visible = !1;
- this.addChild(a, 2, cc.SCENE_FADE);
- var a = this.getChildByTag(cc.SCENE_FADE),
- c = cc.Sequence.create(cc.FadeIn.create(this._duration / 2), cc.CallFunc.create(this.hideOutShowIn, this), cc.FadeOut.create(this._duration / 2), cc.CallFunc.create(this.finish, this));
- a.runAction(c)
- },
- onExit: function() {
- cc.TransitionScene.prototype.onExit.call(this);
- this.removeChildByTag(cc.SCENE_FADE, !1)
- },
- initWithDuration: function(a, c, d) {
- d = d || cc.color.BLACK;
- cc.TransitionScene.prototype.initWithDuration.call(this, a, c) && (this._color.r = d.r, this._color.g = d.g, this._color.b = d.b, this._color.a = 0);
- return !0
- }
- });
- cc.TransitionFade.create = function(a, c, d) {
- return new cc.TransitionFade(a, c, d)
- };
- cc.TransitionCrossFade = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.color(0, 0, 0, 0),
- c = cc.director.getWinSize(),
- a = cc.LayerColor.create(a),
- d = cc.RenderTexture.create(c.width, c.height);
- if (null != d) {
- d.sprite.anchorX = 0.5;
- d.sprite.anchorY = 0.5;
- d.attr({
- x: c.width / 2,
- y: c.height / 2,
- anchorX: 0.5,
- anchorY: 0.5
- });
- d.begin();
- this._inScene.visit();
- d.end();
- var e = cc.RenderTexture.create(c.width, c.height);
- e.setPosition(c.width / 2, c.height / 2);
- e.sprite.anchorX = e.anchorX = 0.5;
- e.sprite.anchorY = e.anchorY = 0.5;
- e.begin();
- this._outScene.visit();
- e.end();
- d.sprite.setBlendFunc(cc.ONE, cc.ONE);
- e.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
- a.addChild(d);
- a.addChild(e);
- d.sprite.opacity = 255;
- e.sprite.opacity = 255;
- c = cc.Sequence.create(cc.FadeTo.create(this._duration, 0), cc.CallFunc.create(this.hideOutShowIn, this), cc.CallFunc.create(this.finish, this));
- e.sprite.runAction(c);
- this.addChild(a, 2, cc.SCENE_FADE)
- }
- },
- onExit: function() {
- this.removeChildByTag(cc.SCENE_FADE, !1);
- cc.TransitionScene.prototype.onExit.call(this)
- },
- draw: function() {}
- });
- cc.TransitionCrossFade.create = function(a, c) {
- return new cc.TransitionCrossFade(a, c)
- };
- cc.TransitionTurnOffTiles = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.director.getWinSize(),
- a = cc.TurnOffTiles.create(this._duration, cc.size(0 | 12 * (a.width / a.height), 12)),
- a = this.easeActionWithAction(a);
- this._outScene.runAction(cc.Sequence.create(a, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
- },
- easeActionWithAction: function(a) {
- return a
- }
- });
- cc.TransitionTurnOffTiles.create = function(a, c) {
- return new cc.TransitionTurnOffTiles(a, c)
- };
- cc.TransitionSplitCols = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.visible = !1;
- var a = this.action(),
- a = cc.Sequence.create(a, cc.CallFunc.create(this.hideOutShowIn, this), a.reverse());
- this.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
- },
- easeActionWithAction: function(a) {
- return cc.EaseInOut.create(a, 3)
- },
- action: function() {
- return cc.SplitCols.create(this._duration / 2, 3)
- }
- });
- cc.TransitionSplitCols.create = function(a, c) {
- return new cc.TransitionSplitCols(a, c)
- };
- cc.TransitionSplitRows = cc.TransitionSplitCols.extend({
- ctor: function(a, c) {
- cc.TransitionSplitCols.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- action: function() {
- return cc.SplitRows.create(this._duration / 2, 3)
- }
- });
- cc.TransitionSplitRows.create = function(a, c) {
- return new cc.TransitionSplitRows(a, c)
- };
- cc.TransitionFadeTR = cc.TransitionScene.extend({
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.director.getWinSize(),
- a = this.actionWithSize(cc.size(0 | 12 * (a.width / a.height), 12));
- this._outScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
- },
- easeActionWithAction: function(a) {
- return a
- },
- actionWithSize: function(a) {
- return cc.FadeOutTRTiles.create(this._duration, a)
- }
- });
- cc.TransitionFadeTR.create = function(a, c) {
- return new cc.TransitionFadeTR(a, c)
- };
- cc.TransitionFadeBL = cc.TransitionFadeTR.extend({
- ctor: function(a, c) {
- cc.TransitionFadeTR.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- actionWithSize: function(a) {
- return cc.FadeOutBLTiles.create(this._duration, a)
- }
- });
- cc.TransitionFadeBL.create = function(a, c) {
- return new cc.TransitionFadeBL(a, c)
- };
- cc.TransitionFadeUp = cc.TransitionFadeTR.extend({
- ctor: function(a, c) {
- cc.TransitionFadeTR.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- actionWithSize: function(a) {
- return cc.FadeOutUpTiles.create(this._duration, a)
- }
- });
- cc.TransitionFadeUp.create = function(a, c) {
- return new cc.TransitionFadeUp(a, c)
- };
- cc.TransitionFadeDown = cc.TransitionFadeTR.extend({
- ctor: function(a, c) {
- cc.TransitionFadeTR.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- actionWithSize: function(a) {
- return cc.FadeOutDownTiles.create(this._duration, a)
- }
- });
- cc.TransitionFadeDown.create = function(a, c) {
- return new cc.TransitionFadeDown(a, c)
- };
- cc.SCENE_RADIAL = 49153;
- cc.TransitionProgress = cc.TransitionScene.extend({
- _to: 0,
- _from: 0,
- _sceneToBeModified: null,
- _className: "TransitionProgress",
- ctor: function(a, c) {
- cc.TransitionScene.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _setAttrs: function(a, c, d) {
- a.attr({
- x: c,
- y: d,
- anchorX: 0.5,
- anchorY: 0.5
- })
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._setupTransition();
- var a = cc.director.getWinSize(),
- c = cc.RenderTexture.create(a.width, a.height);
- c.sprite.anchorX = 0.5;
- c.sprite.anchorY = 0.5;
- this._setAttrs(c, a.width / 2, a.height / 2);
- c.clear(0, 0, 0, 1);
- c.begin();
- this._sceneToBeModified.visit();
- c.end();
- this._sceneToBeModified == this._outScene && this.hideOutShowIn();
- a = this._progressTimerNodeWithRenderTexture(c);
- c = cc.sequence(cc.progressFromTo(this._duration, this._from, this._to), cc.callFunc(this.finish, this));
- a.runAction(c);
- this.addChild(a, 2, cc.SCENE_RADIAL)
- },
- onExit: function() {
- this.removeChildByTag(cc.SCENE_RADIAL, !0);
- cc.TransitionScene.prototype.onExit.call(this)
- },
- _setupTransition: function() {
- this._sceneToBeModified = this._outScene;
- this._from = 100;
- this._to = 0
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass");
- return null
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- }
- });
- cc.TransitionProgress.create = function(a, c) {
- return new cc.TransitionProgress(a, c)
- };
- cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_RADIAL;
- a.reverseDir = !1;
- a.percentage = 100;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- }
- });
- cc.TransitionProgressRadialCCW.create = function(a, c) {
- return new cc.TransitionProgressRadialCCW(a, c)
- };
- cc.TransitionProgressRadialCW = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_RADIAL;
- a.reverseDir = !0;
- a.percentage = 100;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- }
- });
- cc.TransitionProgressRadialCW.create = function(a, c) {
- var d = new cc.TransitionProgressRadialCW;
- return null != d && d.initWithDuration(a, c) ? d : new cc.TransitionProgressRadialCW(a, c)
- };
- cc.TransitionProgressHorizontal = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_BAR;
- a.midPoint = cc.p(1, 0);
- a.barChangeRate = cc.p(1, 0);
- a.percentage = 100;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- }
- });
- cc.TransitionProgressHorizontal.create = function(a, c) {
- return new cc.TransitionProgressHorizontal(a, c)
- };
- cc.TransitionProgressVertical = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_BAR;
- a.midPoint = cc.p(0, 0);
- a.barChangeRate = cc.p(0, 1);
- a.percentage = 100;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- }
- });
- cc.TransitionProgressVertical.create = function(a, c) {
- return new cc.TransitionProgressVertical(a, c)
- };
- cc.TransitionProgressInOut = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_BAR;
- a.midPoint = cc.p(0.5, 0.5);
- a.barChangeRate = cc.p(1, 1);
- a.percentage = 0;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = !1
- },
- _setupTransition: function() {
- this._sceneToBeModified = this._inScene;
- this._from = 0;
- this._to = 100
- }
- });
- cc.TransitionProgressInOut.create = function(a, c) {
- return new cc.TransitionProgressInOut(a, c)
- };
- cc.TransitionProgressOutIn = cc.TransitionProgress.extend({
- ctor: function(a, c) {
- cc.TransitionProgress.prototype.ctor.call(this);
- c && this.initWithDuration(a, c)
- },
- _progressTimerNodeWithRenderTexture: function(a) {
- var c = cc.director.getWinSize();
- a = cc.ProgressTimer.create(a.sprite);
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
- a.type = cc.ProgressTimer.TYPE_BAR;
- a.midPoint = cc.p(0.5, 0.5);
- a.barChangeRate = cc.p(1, 1);
- a.percentage = 100;
- this._setAttrs(a, c.width / 2, c.height / 2);
- return a
- }
- });
- cc.TransitionProgressOutIn.create = function(a, c) {
- return new cc.TransitionProgressOutIn(a, c)
- };
- cc.TransitionPageTurn = cc.TransitionScene.extend({
- ctor: function(a, c, d) {
- cc.TransitionScene.prototype.ctor.call(this);
- this.initWithDuration(a, c, d)
- },
- _back: !0,
- _className: "TransitionPageTurn",
- initWithDuration: function(a, c, d) {
- this._back = d;
- cc.TransitionScene.prototype.initWithDuration.call(this, a, c);
- return !0
- },
- actionWithSize: function(a) {
- return this._back ? cc.ReverseTime.create(cc.PageTurn3D.create(this._duration, a)) : cc.PageTurn3D.create(this._duration, a)
- },
- onEnter: function() {
- cc.TransitionScene.prototype.onEnter.call(this);
- var a = cc.director.getWinSize(),
- c;
- a.width > a.height ? (a = 16, c = 12) : (a = 12, c = 16);
- a = this.actionWithSize(cc.size(a, c));
- this._back ? (this._inScene.visible = !1, this._inScene.runAction(cc.Sequence.create(cc.Show.create(), a, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))) : this._outScene.runAction(cc.Sequence.create(a, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
- },
- _sceneOrder: function() {
- this._isInSceneOnTop = this._back
- }
- });
- cc.TransitionPageTurn.create = function(a, c, d) {
- return new cc.TransitionPageTurn(a, c, d)
- };
- cc.Codec = {
- name: "Jacob__Codec"
- };
- cc.unzip = function() {
- return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, arguments)
- };
- cc.unzipBase64 = function() {
- var a = cc.Codec.Base64.decode.apply(cc.Codec.Base64, arguments);
- return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, [a])
- };
- cc.unzipBase64AsArray = function(a, c) {
- c = c || 1;
- var d = this.unzipBase64(a),
- e = [],
- f, g, h;
- f = 0;
- for (h = d.length / c; f < h; f++) {
- e[f] = 0;
- for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
- }
- return e
- };
- cc.unzipAsArray = function(a, c) {
- c = c || 1;
- var d = this.unzip(a),
- e = [],
- f, g, h;
- f = 0;
- for (h = d.length / c; f < h; f++) {
- e[f] = 0;
- for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
- }
- return e
- };
- cc.StringToArray = function(a) {
- a = a.split(",");
- var c = [],
- d;
- for (d = 0; d < a.length; d++) c.push(parseInt(a[d]));
- return c
- };
- cc.Codec.Base64 = {
- name: "Jacob__Codec__Base64"
- };
- cc.Codec.Base64._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d";
- cc.Codec.Base64.decode = function(a) {
- var c = [],
- d, e, f, g, h, k = 0;
- for (a = a.replace(/[^A-Za-z0-9\+\/\=]/g, ""); k < a.length;) d = this._keyStr.indexOf(a.charAt(k++)), e = this._keyStr.indexOf(a.charAt(k++)), g = this._keyStr.indexOf(a.charAt(k++)), h = this._keyStr.indexOf(a.charAt(k++)), d = d << 2 | e >> 4, e = (e & 15) << 4 | g >> 2, f = (g & 3) << 6 | h, c.push(String.fromCharCode(d)), 64 != g && c.push(String.fromCharCode(e)), 64 != h && c.push(String.fromCharCode(f));
- return c = c.join("")
- };
- cc.Codec.Base64.decodeAsArray = function(a, c) {
- var d = this.decode(a),
- e = [],
- f, g, h;
- f = 0;
- for (h = d.length / c; f < h; f++) {
- e[f] = 0;
- for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
- }
- return e
- };
- cc.uint8ArrayToUint32Array = function(a) {
- if (0 != a.length % 4) return null;
- for (var c = a.length / 4, d = window.Uint32Array ? new Uint32Array(c) : [], e = 0; e < c; e++) {
- var f = 4 * e;
- d[e] = a[f] + 256 * a[f + 1] + 65536 * a[f + 2] + 16777216 * a[f + 3]
- }
- return d
- };
- cc.Codec.GZip = function(a) {
- this.data = a;
- this.debug = !1;
- this.gpflags = void 0;
- this.files = 0;
- this.unzipped = [];
- this.buf32k = Array(32768);
- this.bIdx = 0;
- this.modeZIP = !1;
- this.bytepos = 0;
- this.bb = 1;
- this.bits = 0;
- this.nameBuf = [];
- this.fileout = void 0;
- this.literalTree = Array(cc.Codec.GZip.LITERALS);
- this.distanceTree = Array(32);
- this.treepos = 0;
- this.Places = null;
- this.len = 0;
- this.fpos = Array(17);
- this.fpos[0] = 0;
- this.fmax = this.flens = void 0
- };
- cc.Codec.GZip.gunzip = function(a) {
- return (new cc.Codec.GZip(a)).gunzip()[0][0]
- };
- cc.Codec.GZip.HufNode = function() {
- this.b1 = this.b0 = 0;
- this.jump = null;
- this.jumppos = -1
- };
- cc.Codec.GZip.LITERALS = 288;
- cc.Codec.GZip.NAMEMAX = 256;
- cc.Codec.GZip.bitReverse = [0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255];
- cc.Codec.GZip.cplens = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
- cc.Codec.GZip.cplext = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99];
- cc.Codec.GZip.cpdist = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];
- cc.Codec.GZip.cpdext = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
- cc.Codec.GZip.border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
- cc.Codec.GZip.prototype.gunzip = function() {
- this.outputArr = [];
- this.nextFile();
- return this.unzipped
- };
- cc.Codec.GZip.prototype.readByte = function() {
- this.bits += 8;
- return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1
- };
- cc.Codec.GZip.prototype.byteAlign = function() {
- this.bb = 1
- };
- cc.Codec.GZip.prototype.readBit = function() {
- var a;
- this.bits++;
- a = this.bb & 1;
- this.bb >>= 1;
- 0 == this.bb && (this.bb = this.readByte(), a = this.bb & 1, this.bb = this.bb >> 1 | 128);
- return a
- };
- cc.Codec.GZip.prototype.readBits = function(a) {
- for (var c = 0, d = a; d--;) c = c << 1 | this.readBit();
- a && (c = cc.Codec.GZip.bitReverse[c] >> 8 - a);
- return c
- };
- cc.Codec.GZip.prototype.flushBuffer = function() {
- this.bIdx = 0
- };
- cc.Codec.GZip.prototype.addBuffer = function(a) {
- this.buf32k[this.bIdx++] = a;
- this.outputArr.push(String.fromCharCode(a));
- 32768 == this.bIdx && (this.bIdx = 0)
- };
- cc.Codec.GZip.prototype.IsPat = function() {
- for (;;) {
- if (this.fpos[this.len] >= this.fmax) return -1;
- if (this.flens[this.fpos[this.len]] == this.len) return this.fpos[this.len]++;
- this.fpos[this.len]++
- }
- };
- cc.Codec.GZip.prototype.Rec = function() {
- var a = this.Places[this.treepos],
- c;
- if (17 == this.len) return -1;
- this.treepos++;
- this.len++;
- c = this.IsPat();
- if (0 <= c) a.b0 = c;
- else if (a.b0 = 32768, this.Rec()) return -1;
- c = this.IsPat();
- if (0 <= c) a.b1 = c, a.jump = null;
- else if (a.b1 = 32768, a.jump = this.Places[this.treepos], a.jumppos = this.treepos, this.Rec()) return -1;
- this.len--;
- return 0
- };
- cc.Codec.GZip.prototype.CreateTree = function(a, c, d, e) {
- this.Places = a;
- this.treepos = 0;
- this.flens = d;
- this.fmax = c;
- for (a = 0; 17 > a; a++) this.fpos[a] = 0;
- this.len = 0;
- return this.Rec() ? -1 : 0
- };
- cc.Codec.GZip.prototype.DecodeValue = function(a) {
- for (var c, d, e = 0, f = a[e];;)
- if (c = this.readBit()) {
- if (!(f.b1 & 32768)) return f.b1;
- f = f.jump;
- c = a.length;
- for (d = 0; d < c; d++)
- if (a[d] === f) {
- e = d;
- break
- }
- } else {
- if (!(f.b0 & 32768)) return f.b0;
- e++;
- f = a[e]
- }
- return -1
- };
- cc.Codec.GZip.prototype.DeflateLoop = function() {
- var a, c, d, e, f;
- do
- if (a = this.readBit(), d = this.readBits(2), 0 == d) {
- this.byteAlign();
- d = this.readByte();
- d |= this.readByte() << 8;
- c = this.readByte();
- c |= this.readByte() << 8;
- for ((d ^ ~c) & 65535 && document.write("BlockLen checksum mismatch\n"); d--;) c = this.readByte(), this.addBuffer(c)
- } else if (1 == d)
- for (;;)
- if (d = cc.Codec.GZip.bitReverse[this.readBits(7)] >> 1, 23 < d ? (d = d << 1 | this.readBit(), 199 < d ? (d -= 128, d = d << 1 | this.readBit()) : (d -= 48, 143 < d && (d += 136))) : d += 256, 256 > d) this.addBuffer(d);
- else if (256 == d) break;
- else {
- var g;
- d -= 257;
- f = this.readBits(cc.Codec.GZip.cplext[d]) + cc.Codec.GZip.cplens[d];
- d = cc.Codec.GZip.bitReverse[this.readBits(5)] >> 3;
- 8 < cc.Codec.GZip.cpdext[d] ? (g = this.readBits(8), g |= this.readBits(cc.Codec.GZip.cpdext[d] - 8) << 8) : g = this.readBits(cc.Codec.GZip.cpdext[d]);
- g += cc.Codec.GZip.cpdist[d];
- for (d = 0; d < f; d++) c = this.buf32k[this.bIdx - g & 32767], this.addBuffer(c)
- } else if (2 == d) {
- var h = Array(320);
- c = 257 + this.readBits(5);
- g = 1 + this.readBits(5);
- e = 4 + this.readBits(4);
- for (d = 0; 19 > d; d++) h[d] = 0;
- for (d = 0; d < e; d++) h[cc.Codec.GZip.border[d]] = this.readBits(3);
- f = this.distanceTree.length;
- for (e = 0; e < f; e++) this.distanceTree[e] = new cc.Codec.GZip.HufNode;
- if (this.CreateTree(this.distanceTree, 19, h, 0)) return this.flushBuffer(), 1;
- f = c + g;
- e = 0;
- for (var k = -1; e < f;)
- if (k++, d = this.DecodeValue(this.distanceTree), 16 > d) h[e++] = d;
- else if (16 == d) {
- var m;
- d = 3 + this.readBits(2);
- if (e + d > f) return this.flushBuffer(), 1;
- for (m = e ? h[e - 1] : 0; d--;) h[e++] = m
- } else {
- d = 17 == d ? 3 + this.readBits(3) : 11 + this.readBits(7);
- if (e + d > f) return this.flushBuffer(), 1;
- for (; d--;) h[e++] = 0
- }
- f = this.literalTree.length;
- for (e = 0; e < f; e++) this.literalTree[e] = new cc.Codec.GZip.HufNode;
- if (this.CreateTree(this.literalTree, c, h, 0)) return this.flushBuffer(), 1;
- f = this.literalTree.length;
- for (e = 0; e < f; e++) this.distanceTree[e] = new cc.Codec.GZip.HufNode;
- d = [];
- for (e = c; e < h.length; e++) d[e - c] = h[e];
- if (this.CreateTree(this.distanceTree, g, d, 0)) return this.flushBuffer(), 1;
- for (;;)
- if (d = this.DecodeValue(this.literalTree), 256 <= d) {
- d -= 256;
- if (0 == d) break;
- d--;
- f = this.readBits(cc.Codec.GZip.cplext[d]) + cc.Codec.GZip.cplens[d];
- d = this.DecodeValue(this.distanceTree);
- 8 < cc.Codec.GZip.cpdext[d] ? (g = this.readBits(8), g |= this.readBits(cc.Codec.GZip.cpdext[d] - 8) << 8) : g = this.readBits(cc.Codec.GZip.cpdext[d]);
- for (g += cc.Codec.GZip.cpdist[d]; f--;) c = this.buf32k[this.bIdx - g & 32767], this.addBuffer(c)
- } else this.addBuffer(d)
- }
- while (!a);
- this.flushBuffer();
- this.byteAlign();
- return 0
- };
- cc.Codec.GZip.prototype.unzipFile = function(a) {
- var c;
- this.gunzip();
- for (c = 0; c < this.unzipped.length; c++)
- if (this.unzipped[c][1] == a) return this.unzipped[c][0]
- };
- cc.Codec.GZip.prototype.nextFile = function() {
- this.outputArr = [];
- this.modeZIP = !1;
- var a = [];
- a[0] = this.readByte();
- a[1] = this.readByte();
- 120 == a[0] && 218 == a[1] && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), "geonext.gxt"], this.files++);
- 31 == a[0] && 139 == a[1] && (this.skipdir(), this.unzipped[this.files] = [this.outputArr.join(""), "file"], this.files++);
- if (80 == a[0] && 75 == a[1] && (this.modeZIP = !0, a[2] = this.readByte(), a[3] = this.readByte(), 3 == a[2] && 4 == a[3])) {
- a[0] = this.readByte();
- a[1] = this.readByte();
- this.gpflags = this.readByte();
- this.gpflags |= this.readByte() << 8;
- a = this.readByte();
- a |= this.readByte() << 8;
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- var c = this.readByte(),
- c = c | this.readByte() << 8,
- d = this.readByte(),
- d = d | this.readByte() << 8,
- e = 0;
- for (this.nameBuf = []; c--;) {
- var f = this.readByte();
- "/" == f | ":" == f ? e = 0 : e < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[e++] = String.fromCharCode(f))
- }
- this.fileout || (this.fileout = this.nameBuf);
- for (var e = 0; e < d;) this.readByte(), e++;
- 8 == a && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), this.nameBuf.join("")], this.files++);
- this.skipdir()
- }
- };
- cc.Codec.GZip.prototype.skipdir = function() {
- var a = [],
- c;
- this.gpflags & 8 && (a[0] = this.readByte(), a[1] = this.readByte(), a[2] = this.readByte(), a[3] = this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte(), this.readByte());
- this.modeZIP && this.nextFile();
- a[0] = this.readByte();
- if (8 != a[0]) return 0;
- this.gpflags = this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- if (this.gpflags & 4) {
- a[0] = this.readByte();
- a[2] = this.readByte();
- this.len = a[0] + 256 * a[1];
- for (a = 0; a < this.len; a++) this.readByte()
- }
- if (this.gpflags & 8) {
- a = 0;
- for (this.nameBuf = []; c = this.readByte();) {
- if ("7" == c || ":" == c) a = 0;
- a < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[a++] = c)
- }
- }
- if (this.gpflags & 16)
- for (; this.readByte(););
- this.gpflags & 2 && (this.readByte(), this.readByte());
- this.DeflateLoop();
- this.readByte();
- this.readByte();
- this.readByte();
- this.readByte();
- this.modeZIP && this.nextFile()
- };
- (function() {
- function a(a) {
- throw a;
- }
- function c(a, c) {
- var d = a.split("."),
- e = y;
- !(d[0] in e) && e.execScript && e.execScript("var " + d[0]);
- for (var f; d.length && (f = d.shift());)!d.length && c !== D ? e[f] = c : e = e[f] ? e[f] : e[f] = {}
- }
- function d(a) {
- if ("string" === typeof a) {
- a = a.split("");
- var c, d;
- c = 0;
- for (d = a.length; c < d; c++) a[c] = (a[c].charCodeAt(0) & 255) >>> 0
- }
- c = 1;
- d = 0;
- for (var e = a.length, f, g = 0; 0 < e;) {
- f = 1024 < e ? 1024 : e;
- e -= f;
- do c += a[g++], d += c; while (--f);
- c %= 65521;
- d %= 65521
- }
- return (d << 16 | c) >>> 0
- }
- function e(c, d) {
- this.index = "number" === typeof d ? d : 0;
- this.i = 0;
- this.buffer = c instanceof(z ? Uint8Array : Array) ? c : new(z ? Uint8Array : Array)(32768);
- 2 * this.buffer.length <= this.index && a(Error("invalid index"));
- this.buffer.length <= this.index && this.f()
- }
- function f(a) {
- this.buffer = new(z ? Uint16Array : Array)(2 * a);
- this.length = 0
- }
- function g(a) {
- var c = a.length,
- d = 0,
- e = Number.POSITIVE_INFINITY,
- f, g, h, k, m, n, q, r, s;
- for (r = 0; r < c; ++r) a[r] > d && (d = a[r]), a[r] < e && (e = a[r]);
- f = 1 << d;
- g = new(z ? Uint32Array : Array)(f);
- h = 1;
- k = 0;
- for (m = 2; h <= d;) {
- for (r = 0; r < c; ++r)
- if (a[r] === h) {
- n = 0;
- q = k;
- for (s = 0; s < h; ++s) n = n << 1 | q & 1, q >>= 1;
- for (s = n; s < f; s += m) g[s] = h << 16 | r;
- ++k
- }++h;
- k <<= 1;
- m <<= 1
- }
- return [g, d, e]
- }
- function h(a, c) {
- this.h = K;
- this.w = 0;
- this.input = a;
- this.b = 0;
- c && (c.lazy && (this.w = c.lazy), "number" === typeof c.compressionType && (this.h = c.compressionType), c.outputBuffer && (this.a = z && c.outputBuffer instanceof Array ? new Uint8Array(c.outputBuffer) : c.outputBuffer), "number" === typeof c.outputIndex && (this.b = c.outputIndex));
- this.a || (this.a = new(z ? Uint8Array : Array)(32768))
- }
- function k(a, c) {
- this.length = a;
- this.G = c
- }
- function m() {
- var c = L;
- switch (F) {
- case 3 === c:
- return [257, c - 3, 0];
- case 4 === c:
- return [258, c - 4, 0];
- case 5 === c:
- return [259, c - 5, 0];
- case 6 === c:
- return [260, c - 6, 0];
- case 7 === c:
- return [261, c - 7, 0];
- case 8 === c:
- return [262, c - 8, 0];
- case 9 === c:
- return [263, c - 9, 0];
- case 10 === c:
- return [264, c - 10, 0];
- case 12 >= c:
- return [265, c - 11, 1];
- case 14 >= c:
- return [266, c - 13, 1];
- case 16 >= c:
- return [267, c - 15, 1];
- case 18 >= c:
- return [268, c - 17, 1];
- case 22 >= c:
- return [269, c - 19, 2];
- case 26 >= c:
- return [270, c - 23, 2];
- case 30 >= c:
- return [271, c - 27, 2];
- case 34 >= c:
- return [272, c - 31, 2];
- case 42 >= c:
- return [273, c - 35, 3];
- case 50 >= c:
- return [274, c - 43, 3];
- case 58 >= c:
- return [275, c - 51, 3];
- case 66 >= c:
- return [276, c - 59, 3];
- case 82 >= c:
- return [277, c - 67, 4];
- case 98 >= c:
- return [278, c - 83, 4];
- case 114 >= c:
- return [279, c - 99, 4];
- case 130 >= c:
- return [280, c - 115, 4];
- case 162 >= c:
- return [281, c - 131, 5];
- case 194 >= c:
- return [282, c - 163, 5];
- case 226 >= c:
- return [283, c - 195, 5];
- case 257 >= c:
- return [284, c - 227, 5];
- case 258 === c:
- return [285, c - 258, 0];
- default:
- a("invalid length: " + c)
- }
- }
- function n(c, d) {
- function e(c, d) {
- var f = c.G,
- g = [],
- h = 0,
- k;
- k = N[c.length];
- g[h++] = k & 65535;
- g[h++] = k >> 16 & 255;
- g[h++] = k >> 24;
- var m;
- switch (F) {
- case 1 === f:
- m = [0, f - 1, 0];
- break;
- case 2 === f:
- m = [1, f - 2, 0];
- break;
- case 3 === f:
- m = [2, f - 3, 0];
- break;
- case 4 === f:
- m = [3, f - 4, 0];
- break;
- case 6 >= f:
- m = [4, f - 5, 1];
- break;
- case 8 >= f:
- m = [5, f - 7, 1];
- break;
- case 12 >= f:
- m = [6, f - 9, 2];
- break;
- case 16 >= f:
- m = [7, f - 13, 2];
- break;
- case 24 >= f:
- m = [8, f - 17, 3];
- break;
- case 32 >= f:
- m = [9, f - 25, 3];
- break;
- case 48 >= f:
- m = [10, f - 33, 4];
- break;
- case 64 >= f:
- m = [11, f - 49, 4];
- break;
- case 96 >= f:
- m = [12, f - 65, 5];
- break;
- case 128 >= f:
- m = [13, f - 97, 5];
- break;
- case 192 >= f:
- m = [14, f - 129, 6];
- break;
- case 256 >= f:
- m = [15, f - 193, 6];
- break;
- case 384 >= f:
- m = [16, f - 257, 7];
- break;
- case 512 >= f:
- m = [17, f - 385, 7];
- break;
- case 768 >= f:
- m = [18, f - 513, 8];
- break;
- case 1024 >= f:
- m = [19, f - 769, 8];
- break;
- case 1536 >= f:
- m = [20, f - 1025, 9];
- break;
- case 2048 >= f:
- m = [21, f - 1537, 9];
- break;
- case 3072 >= f:
- m = [22, f - 2049, 10];
- break;
- case 4096 >= f:
- m = [23, f - 3073, 10];
- break;
- case 6144 >= f:
- m = [24, f - 4097, 11];
- break;
- case 8192 >= f:
- m = [25, f - 6145, 11];
- break;
- case 12288 >= f:
- m = [26, f - 8193, 12];
- break;
- case 16384 >= f:
- m = [27, f - 12289, 12];
- break;
- case 24576 >= f:
- m = [28, f - 16385, 13];
- break;
- case 32768 >= f:
- m = [29, f - 24577, 13];
- break;
- default:
- a("invalid distance")
- }
- k = m;
- g[h++] = k[0];
- g[h++] = k[1];
- g[h++] = k[2];
- f = 0;
- for (h = g.length; f < h; ++f) s[t++] = g[f];
- u[g[0]]++;
- x[g[3]]++;
- v = c.length + d - 1;
- r = null
- }
- var f, g, h, m, n, q = {},
- r, s = z ? new Uint16Array(2 * d.length) : [],
- t = 0,
- v = 0,
- u = new(z ? Uint32Array : Array)(286),
- x = new(z ? Uint32Array : Array)(30),
- A = c.w,
- w;
- if (!z) {
- for (h = 0; 285 >= h;) u[h++] = 0;
- for (h = 0; 29 >= h;) x[h++] = 0
- }
- u[256] = 1;
- f = 0;
- for (g = d.length; f < g; ++f) {
- h = n = 0;
- for (m = 3; h < m && f + h !== g; ++h) n = n << 8 | d[f + h];
- q[n] === D && (q[n] = []);
- h = q[n];
- if (!(0 < v--)) {
- for (; 0 < h.length && 32768 < f - h[0];) h.shift();
- if (f + 3 >= g) {
- r && e(r, -1);
- h = 0;
- for (m = g - f; h < m; ++h) w = d[f + h], s[t++] = w, ++u[w];
- break
- }
- if (0 < h.length) {
- n = m = D;
- var C = 0,
- B = D,
- y = D,
- E = B = D,
- I = d.length,
- y = 0,
- E = h.length;
- a: for (; y < E; y++) {
- m = h[E - y - 1];
- B = 3;
- if (3 < C) {
- for (B = C; 3 < B; B--)
- if (d[m + B - 1] !== d[f + B - 1]) continue a;
- B = C
- }
- for (; 258 > B && f + B < I && d[m + B] === d[f + B];)++B;
- B > C && (n = m, C = B);
- if (258 === B) break
- }
- m = new k(C, f - n);
- r ? r.length < m.length ? (w = d[f - 1], s[t++] = w, ++u[w], e(m, 0)) : e(r, -1) : m.length < A ? r = m : e(m, 0)
- } else r ? e(r, -1) : (w = d[f], s[t++] = w, ++u[w])
- }
- h.push(f)
- }
- s[t++] = 256;
- u[256]++;
- c.L = u;
- c.K = x;
- return z ? s.subarray(0, t) : s
- }
- function q(a, c) {
- function d(a) {
- var c = s[a][t[a]];
- c === q ? (d(a + 1), d(a + 1)) : --r[c];
- ++t[a]
- }
- var e = a.length,
- g = new f(572),
- h = new(z ? Uint8Array : Array)(e),
- k, m, n;
- if (!z)
- for (m = 0; m < e; m++) h[m] = 0;
- for (m = 0; m < e; ++m) 0 < a[m] && g.push(m, a[m]);
- e = Array(g.length / 2);
- k = new(z ? Uint32Array : Array)(g.length / 2);
- if (1 === e.length) return h[g.pop().index] = 1, h;
- m = 0;
- for (n = g.length / 2; m < n; ++m) e[m] = g.pop(), k[m] = e[m].value;
- var q = k.length;
- m = new(z ? Uint16Array : Array)(c);
- var g = new(z ? Uint8Array : Array)(c),
- r = new(z ? Uint8Array : Array)(q);
- n = Array(c);
- var s = Array(c),
- t = Array(c),
- u = (1 << c) - q,
- v = 1 << c - 1,
- w, x, A;
- m[c - 1] = q;
- for (w = 0; w < c; ++w) u < v ? g[w] = 0 : (g[w] = 1, u -= v), u <<= 1, m[c - 2 - w] = (m[c - 1 - w] / 2 | 0) + q;
- m[0] = g[0];
- n[0] = Array(m[0]);
- s[0] = Array(m[0]);
- for (w = 1; w < c; ++w) m[w] > 2 * m[w - 1] + g[w] && (m[w] = 2 * m[w - 1] + g[w]), n[w] = Array(m[w]), s[w] = Array(m[w]);
- for (u = 0; u < q; ++u) r[u] = c;
- for (v = 0; v < m[c - 1]; ++v) n[c - 1][v] = k[v], s[c - 1][v] = v;
- for (u = 0; u < c; ++u) t[u] = 0;
- 1 === g[c - 1] && (--r[0], ++t[c - 1]);
- for (w = c - 2; 0 <= w; --w) {
- x = u = 0;
- A = t[w + 1];
- for (v = 0; v < m[w]; v++) x = n[w + 1][A] + n[w + 1][A + 1], x > k[u] ? (n[w][v] = x, s[w][v] = q, A += 2) : (n[w][v] = k[u], s[w][v] = u, ++u);
- t[w] = 0;
- 1 === g[w] && d(w)
- }
- k = r;
- m = 0;
- for (n = e.length; m < n; ++m) h[e[m].index] = k[m];
- return h
- }
- function r(c) {
- var d = new(z ? Uint16Array : Array)(c.length),
- e = [],
- f = [],
- g = 0,
- h, k, m;
- h = 0;
- for (k = c.length; h < k; h++) e[c[h]] = (e[c[h]] | 0) + 1;
- h = 1;
- for (k = 16; h <= k; h++) f[h] = g, g += e[h] | 0, g > 1 << h && a("overcommitted"), g <<= 1;
- 65536 > g && a("undercommitted");
- h = 0;
- for (k = c.length; h < k; h++) {
- g = f[c[h]];
- f[c[h]] += 1;
- e = d[h] = 0;
- for (m = c[h]; e < m; e++) d[h] = d[h] << 1 | g & 1, g >>>= 1
- }
- return d
- }
- function t(a, c) {
- this.input = a;
- this.a = new(z ? Uint8Array : Array)(32768);
- this.h = I.j;
- var d = {},
- e;
- if ((c || !(c = {})) && "number" === typeof c.compressionType) this.h = c.compressionType;
- for (e in c) d[e] = c[e];
- d.outputBuffer = this.a;
- this.z = new h(this.input, d)
- }
- function s(c, d) {
- this.k = [];
- this.l = 32768;
- this.e = this.g = this.c = this.q = 0;
- this.input = z ? new Uint8Array(c) : c;
- this.s = !1;
- this.m = P;
- this.B = !1;
- if (d || !(d = {})) d.index && (this.c = d.index), d.bufferSize && (this.l = d.bufferSize), d.bufferType && (this.m = d.bufferType), d.resize && (this.B = d.resize);
- switch (this.m) {
- case J:
- this.b = 32768;
- this.a = new(z ? Uint8Array : Array)(32768 + this.l + 258);
- break;
- case P:
- this.b = 0;
- this.a = new(z ? Uint8Array : Array)(this.l);
- this.f = this.J;
- this.t = this.H;
- this.o = this.I;
- break;
- default:
- a(Error("invalid inflate mode"))
- }
- }
- function v(c, d) {
- for (var e = c.g, f = c.e, g = c.input, h = c.c, k; f < d;) k = g[h++], k === D && a(Error("input buffer is broken")), e |= k << f, f += 8;
- c.g = e >>> d;
- c.e = f - d;
- c.c = h;
- return e & (1 << d) - 1
- }
- function u(c, d) {
- for (var e = c.g, f = c.e, g = c.input, h = c.c, k = d[0], m = d[1], n; f < m;) n = g[h++], n === D && a(Error("input buffer is broken")), e |= n << f, f += 8;
- g = k[e & (1 << m) - 1];
- k = g >>> 16;
- c.g = e >> k;
- c.e = f - k;
- c.c = h;
- return g & 65535
- }
- function x(a) {
- function c(a, d, e) {
- var f, g, h, k;
- for (k = 0; k < a;) switch (f = u(this, d), f) {
- case 16:
- for (h = 3 + v(this, 2); h--;) e[k++] = g;
- break;
- case 17:
- for (h = 3 + v(this, 3); h--;) e[k++] = 0;
- g = 0;
- break;
- case 18:
- for (h = 11 + v(this, 7); h--;) e[k++] = 0;
- g = 0;
- break;
- default:
- g = e[k++] = f
- }
- return e
- }
- var d = v(a, 5) + 257,
- e = v(a, 5) + 1,
- f = v(a, 4) + 4,
- h = new(z ? Uint8Array : Array)(S.length),
- k;
- for (k = 0; k < f; ++k) h[S[k]] = v(a, 3);
- f = g(h);
- h = new(z ? Uint8Array : Array)(d);
- k = new(z ? Uint8Array : Array)(e);
- a.o(g(c.call(a, d, f, h)), g(c.call(a, e, f, k)))
- }
- function A(c, d) {
- var e, f;
- this.input = c;
- this.c = 0;
- if (d || !(d = {})) d.index && (this.c = d.index), d.verify && (this.M = d.verify);
- e = c[this.c++];
- f = c[this.c++];
- switch (e & 15) {
- case O:
- this.method = O;
- break;
- default:
- a(Error("unsupported compression method"))
- }
- 0 !== ((e << 8) + f) % 31 && a(Error("invalid fcheck flag:" + ((e << 8) + f) % 31));
- f & 32 && a(Error("fdict flag is not supported"));
- this.A = new s(c, {
- index: this.c,
- bufferSize: d.bufferSize,
- bufferType: d.bufferType,
- resize: d.resize
- })
- }
- var D = void 0,
- F = !0,
- y = this,
- z = "undefined" !== typeof Uint8Array && "undefined" !== typeof Uint16Array && "undefined" !== typeof Uint32Array;
- e.prototype.f = function() {
- var a = this.buffer,
- c, d = a.length,
- e = new(z ? Uint8Array : Array)(d << 1);
- if (z) e.set(a);
- else
- for (c = 0; c < d; ++c) e[c] = a[c];
- return this.buffer = e
- };
- e.prototype.d = function(a, c, d) {
- var e = this.buffer,
- f = this.index,
- g = this.i,
- h = e[f];
- d && 1 < c && (a = 8 < c ? (E[a & 255] << 24 | E[a >>> 8 & 255] << 16 | E[a >>> 16 & 255] << 8 | E[a >>> 24 & 255]) >> 32 - c : E[a] >> 8 - c);
- if (8 > c + g) h = h << c | a, g += c;
- else
- for (d = 0; d < c; ++d) h = h << 1 | a >> c - d - 1 & 1, 8 === ++g && (g = 0, e[f++] = E[h], h = 0, f === e.length && (e = this.f()));
- e[f] = h;
- this.buffer = e;
- this.i = g;
- this.index = f
- };
- e.prototype.finish = function() {
- var a = this.buffer,
- c = this.index,
- d;
- 0 < this.i && (a[c] <<= 8 - this.i, a[c] = E[a[c]], c++);
- z ? d = a.subarray(0, c) : (a.length = c, d = a);
- return d
- };
- var C = new(z ? Uint8Array : Array)(256),
- w;
- for (w = 0; 256 > w; ++w) {
- for (var B = w, G = B, H = 7, B = B >>> 1; B; B >>>= 1) G <<= 1, G |= B & 1, --H;
- C[w] = (G << H & 255) >>> 0
- }
- var E = C,
- C = [0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918E3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117];
- z && new Uint32Array(C);
- f.prototype.getParent = function(a) {
- return 2 * ((a - 2) / 4 | 0)
- };
- f.prototype.push = function(a, c) {
- var d, e, f = this.buffer,
- g;
- d = this.length;
- f[this.length++] = c;
- for (f[this.length++] = a; 0 < d;)
- if (e = this.getParent(d), f[d] > f[e]) g = f[d], f[d] = f[e], f[e] = g, g = f[d + 1], f[d + 1] = f[e + 1], f[e + 1] = g, d = e;
- else break;
- return this.length
- };
- f.prototype.pop = function() {
- var a, c, d = this.buffer,
- e, f, g;
- c = d[0];
- a = d[1];
- this.length -= 2;
- d[0] = d[this.length];
- d[1] = d[this.length + 1];
- for (g = 0;;) {
- f = 2 * g + 2;
- if (f >= this.length) break;
- f + 2 < this.length && d[f + 2] > d[f] && (f += 2);
- if (d[f] > d[g]) e = d[g], d[g] = d[f], d[f] = e, e = d[g + 1], d[g + 1] = d[f + 1], d[f + 1] = e;
- else break;
- g = f
- }
- return {
- index: a,
- value: c,
- length: this.length
- }
- };
- var K = 2,
- C = {
- NONE: 0,
- r: 1,
- j: K,
- N: 3
- },
- M = [];
- for (w = 0; 288 > w; w++) switch (F) {
- case 143 >= w:
- M.push([w + 48, 8]);
- break;
- case 255 >= w:
- M.push([w - 144 + 400, 9]);
- break;
- case 279 >= w:
- M.push([w - 256 + 0, 7]);
- break;
- case 287 >= w:
- M.push([w - 280 + 192, 8]);
- break;
- default:
- a("invalid literal: " + w)
- }
- h.prototype.n = function() {
- var c, d, f, g, h = this.input;
- switch (this.h) {
- case 0:
- f = 0;
- for (g = h.length; f < g;) {
- d = z ? h.subarray(f, f + 65535) : h.slice(f, f + 65535);
- f += d.length;
- var k = f === g,
- m = D,
- s = m = D,
- s = m = D,
- t = this.a,
- u = this.b;
- if (z) {
- for (t = new Uint8Array(this.a.buffer); t.length <= u + d.length + 5;) t = new Uint8Array(t.length << 1);
- t.set(this.a)
- }
- m = k ? 1 : 0;
- t[u++] = m | 0;
- m = d.length;
- s = ~m + 65536 & 65535;
- t[u++] = m & 255;
- t[u++] = m >>> 8 & 255;
- t[u++] = s & 255;
- t[u++] = s >>> 8 & 255;
- if (z) t.set(d, u), u += d.length, t = t.subarray(0, u);
- else {
- m = 0;
- for (s = d.length; m < s; ++m) t[u++] = d[m];
- t.length = u
- }
- this.b = u;
- this.a = t
- }
- break;
- case 1:
- f = new e(new Uint8Array(this.a.buffer), this.b);
- f.d(1, 1, F);
- f.d(1, 2, F);
- h = n(this, h);
- d = 0;
- for (k = h.length; d < k; d++)
- if (g = h[d], e.prototype.d.apply(f, M[g]), 256 < g) f.d(h[++d], h[++d], F), f.d(h[++d], 5), f.d(h[++d], h[++d], F);
- else if (256 === g) break;
- this.a = f.finish();
- this.b = this.a.length;
- break;
- case K:
- g = new e(new Uint8Array(this.a), this.b);
- var v, w, x, A = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15],
- C, B, m = Array(19),
- y, t = K;
- g.d(1, 1, F);
- g.d(t, 2, F);
- h = n(this, h);
- s = q(this.L, 15);
- C = r(s);
- t = q(this.K, 7);
- u = r(t);
- for (v = 286; 257 < v && 0 === s[v - 1]; v--);
- for (w = 30; 1 < w && 0 === t[w - 1]; w--);
- var E = v,
- I = w;
- c = new(z ? Uint32Array : Array)(E + I);
- var G = new(z ? Uint32Array : Array)(316),
- H, J;
- B = new(z ? Uint8Array : Array)(19);
- for (y = x = 0; y < E; y++) c[x++] = s[y];
- for (y = 0; y < I; y++) c[x++] = t[y];
- if (!z) {
- y = 0;
- for (I = B.length; y < I; ++y) B[y] = 0
- }
- y = H = 0;
- for (I = c.length; y < I; y += x) {
- for (x = 1; y + x < I && c[y + x] === c[y]; ++x);
- E = x;
- if (0 === c[y])
- if (3 > E)
- for (; 0 < E--;) G[H++] = 0, B[0]++;
- else
- for (; 0 < E;) J = 138 > E ? E : 138, J > E - 3 && J < E && (J = E - 3), 10 >= J ? (G[H++] = 17, G[H++] = J - 3, B[17]++) : (G[H++] = 18, G[H++] = J - 11, B[18]++), E -= J;
- else if (G[H++] = c[y], B[c[y]]++, E--, 3 > E)
- for (; 0 < E--;) G[H++] = c[y], B[c[y]]++;
- else
- for (; 0 < E;) J = 6 > E ? E : 6, J > E - 3 && J < E && (J = E - 3), G[H++] = 16, G[H++] = J - 3, B[16]++, E -= J
- }
- c = z ? G.subarray(0, H) : G.slice(0, H);
- B = q(B, 7);
- for (y = 0; 19 > y; y++) m[y] = B[A[y]];
- for (x = 19; 4 < x && 0 === m[x - 1]; x--);
- A = r(B);
- g.d(v - 257, 5, F);
- g.d(w - 1, 5, F);
- g.d(x - 4, 4, F);
- for (y = 0; y < x; y++) g.d(m[y], 3, F);
- y = 0;
- for (m = c.length; y < m; y++)
- if (d = c[y], g.d(A[d], B[d], F), 16 <= d) {
- y++;
- switch (d) {
- case 16:
- k = 2;
- break;
- case 17:
- k = 3;
- break;
- case 18:
- k = 7;
- break;
- default:
- a("invalid code: " + d)
- }
- g.d(c[y], k, F)
- }
- k = [C, s];
- u = [u, t];
- d = k[0];
- k = k[1];
- t = u[0];
- C = u[1];
- u = 0;
- for (m = h.length; u < m; ++u)
- if (f = h[u], g.d(d[f], k[f], F), 256 < f) g.d(h[++u], h[++u], F), s = h[++u], g.d(t[s], C[s], F), g.d(h[++u], h[++u], F);
- else if (256 === f) break;
- this.a = g.finish();
- this.b = this.a.length;
- break;
- default:
- a("invalid compression type")
- }
- return this.a
- };
- w = [];
- var L;
- for (L = 3; 258 >= L; L++) B = m(), w[L] = B[2] << 24 | B[1] << 16 | B[0];
- var N = z ? new Uint32Array(w) : w,
- I = C;
- t.prototype.n = function() {
- var c, e, f, g, h = 0;
- g = this.a;
- c = O;
- switch (c) {
- case O:
- e = Math.LOG2E * Math.log(32768) - 8;
- break;
- default:
- a(Error("invalid compression method"))
- }
- e = e << 4 | c;
- g[h++] = e;
- switch (c) {
- case O:
- switch (this.h) {
- case I.NONE:
- f = 0;
- break;
- case I.r:
- f = 1;
- break;
- case I.j:
- f = 2;
- break;
- default:
- a(Error("unsupported compression type"))
- }
- break;
- default:
- a(Error("invalid compression method"))
- }
- c = f << 6 | 0;
- g[h++] = c | 31 - (256 * e + c) % 31;
- c = d(this.input);
- this.z.b = h;
- g = this.z.n();
- h = g.length;
- z && (g = new Uint8Array(g.buffer), g.length <= h + 4 && (this.a = new Uint8Array(g.length + 4), this.a.set(g), g = this.a), g = g.subarray(0, h + 4));
- g[h++] = c >> 24 & 255;
- g[h++] = c >> 16 & 255;
- g[h++] = c >> 8 & 255;
- g[h++] = c & 255;
- return g
- };
- c("Zlib.Deflate", t);
- c("Zlib.Deflate.compress", function(a, c) {
- return (new t(a, c)).n()
- });
- c("Zlib.Deflate.CompressionType", I);
- c("Zlib.Deflate.CompressionType.NONE", I.NONE);
- c("Zlib.Deflate.CompressionType.FIXED", I.r);
- c("Zlib.Deflate.CompressionType.DYNAMIC", I.j);
- var J = 0,
- P = 1,
- C = {
- D: J,
- C: P
- };
- s.prototype.p = function() {
- for (; !this.s;) {
- var c = v(this, 3);
- c & 1 && (this.s = F);
- c >>>= 1;
- switch (c) {
- case 0:
- var c = this.input,
- d = this.c,
- e = this.a,
- f = this.b,
- g = D,
- h = D,
- k = D,
- m = e.length,
- g = D;
- this.e = this.g = 0;
- g = c[d++];
- g === D && a(Error("invalid uncompressed block header: LEN (first byte)"));
- h = g;
- g = c[d++];
- g === D && a(Error("invalid uncompressed block header: LEN (second byte)"));
- h |= g << 8;
- g = c[d++];
- g === D && a(Error("invalid uncompressed block header: NLEN (first byte)"));
- k = g;
- g = c[d++];
- g === D && a(Error("invalid uncompressed block header: NLEN (second byte)"));
- k |= g << 8;
- h === ~k && a(Error("invalid uncompressed block header: length verify"));
- d + h > c.length && a(Error("input buffer is broken"));
- switch (this.m) {
- case J:
- for (; f + h > e.length;) {
- g = m - f;
- h -= g;
- if (z) e.set(c.subarray(d, d + g), f), f += g, d += g;
- else
- for (; g--;) e[f++] = c[d++];
- this.b = f;
- e = this.f();
- f = this.b
- }
- break;
- case P:
- for (; f + h > e.length;) e = this.f({
- v: 2
- });
- break;
- default:
- a(Error("invalid inflate mode"))
- }
- if (z) e.set(c.subarray(d, d + h), f), f += h, d += h;
- else
- for (; h--;) e[f++] = c[d++];
- this.c = d;
- this.b = f;
- this.a = e;
- break;
- case 1:
- this.o(V, W);
- break;
- case 2:
- x(this);
- break;
- default:
- a(Error("unknown BTYPE: " + c))
- }
- }
- return this.t()
- };
- w = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
- var S = z ? new Uint16Array(w) : w;
- w = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258];
- var T = z ? new Uint16Array(w) : w;
- w = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0];
- var Q = z ? new Uint8Array(w) : w;
- w = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];
- var U = z ? new Uint16Array(w) : w;
- w = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
- var R = z ? new Uint8Array(w) : w;
- w = new(z ? Uint8Array : Array)(288);
- B = 0;
- for (G = w.length; B < G; ++B) w[B] = 143 >= B ? 8 : 255 >= B ? 9 : 279 >= B ? 7 : 8;
- var V = g(w);
- w = new(z ? Uint8Array : Array)(30);
- B = 0;
- for (G = w.length; B < G; ++B) w[B] = 5;
- var W = g(w);
- s.prototype.o = function(a, c) {
- var d = this.a,
- e = this.b;
- this.u = a;
- for (var f = d.length - 258, g, h, k; 256 !== (g = u(this, a));)
- if (256 > g) e >= f && (this.b = e, d = this.f(), e = this.b), d[e++] = g;
- else {
- g -= 257;
- k = T[g];
- 0 < Q[g] && (k += v(this, Q[g]));
- g = u(this, c);
- h = U[g];
- 0 < R[g] && (h += v(this, R[g]));
- for (e >= f && (this.b = e, d = this.f(), e = this.b); k--;) d[e] = d[e++-h]
- }
- for (; 8 <= this.e;) this.e -= 8, this.c--;
- this.b = e
- };
- s.prototype.I = function(a, c) {
- var d = this.a,
- e = this.b;
- this.u = a;
- for (var f = d.length, g, h, k; 256 !== (g = u(this, a));)
- if (256 > g) e >= f && (d = this.f(), f = d.length), d[e++] = g;
- else {
- g -= 257;
- k = T[g];
- 0 < Q[g] && (k += v(this, Q[g]));
- g = u(this, c);
- h = U[g];
- 0 < R[g] && (h += v(this, R[g]));
- for (e + k > f && (d = this.f(), f = d.length); k--;) d[e] = d[e++-h]
- }
- for (; 8 <= this.e;) this.e -= 8, this.c--;
- this.b = e
- };
- s.prototype.f = function() {
- var a = new(z ? Uint8Array : Array)(this.b - 32768),
- c = this.b - 32768,
- d, e, f = this.a;
- if (z) a.set(f.subarray(32768, a.length));
- else {
- d = 0;
- for (e = a.length; d < e; ++d) a[d] = f[d + 32768]
- }
- this.k.push(a);
- this.q += a.length;
- if (z) f.set(f.subarray(c, c + 32768));
- else
- for (d = 0; 32768 > d; ++d) f[d] = f[c + d];
- this.b = 32768;
- return f
- };
- s.prototype.J = function(a) {
- var c, d = this.input.length / this.c + 1 | 0,
- e, f, g, h = this.input,
- k = this.a;
- a && ("number" === typeof a.v && (d = a.v), "number" === typeof a.F && (d += a.F));
- 2 > d ? (e = (h.length - this.c) / this.u[2], g = 258 * (e / 2) | 0, f = g < k.length ? k.length + g : k.length << 1) : f = k.length * d;
- z ? (c = new Uint8Array(f), c.set(k)) : c = k;
- return this.a = c
- };
- s.prototype.t = function() {
- var a = 0,
- c = this.a,
- d = this.k,
- e, f = new(z ? Uint8Array : Array)(this.q + (this.b - 32768)),
- g, h, k, m;
- if (0 === d.length) return z ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b);
- g = 0;
- for (h = d.length; g < h; ++g) {
- e = d[g];
- k = 0;
- for (m = e.length; k < m; ++k) f[a++] = e[k]
- }
- g = 32768;
- for (h = this.b; g < h; ++g) f[a++] = c[g];
- this.k = [];
- return this.buffer = f
- };
- s.prototype.H = function() {
- var a, c = this.b;
- z ? this.B ? (a = new Uint8Array(c), a.set(this.a.subarray(0, c))) : a = this.a.subarray(0, c) : (this.a.length > c && (this.a.length = c), a = this.a);
- return this.buffer = a
- };
- A.prototype.p = function() {
- var c = this.input,
- e, f;
- e = this.A.p();
- this.c = this.A.c;
- this.M && (f = (c[this.c++] << 24 | c[this.c++] << 16 | c[this.c++] << 8 | c[this.c++]) >>> 0, f !== d(e) && a(Error("invalid adler-32 checksum")));
- return e
- };
- c("Zlib.Inflate", A);
- c("Zlib.Inflate.BufferType", C);
- C.ADAPTIVE = C.C;
- C.BLOCK = C.D;
- c("Zlib.Inflate.prototype.decompress", A.prototype.p);
- C = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
- z && new Uint16Array(C);
- C = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 258, 258];
- z && new Uint16Array(C);
- C = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0];
- z && new Uint8Array(C);
- C = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577];
- z && new Uint16Array(C);
- C = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
- z && new Uint8Array(C);
- C = new(z ? Uint8Array : Array)(288);
- w = 0;
- for (B = C.length; w < B; ++w) C[w] = 143 >= w ? 8 : 255 >= w ? 9 : 279 >= w ? 7 : 8;
- g(C);
- C = new(z ? Uint8Array : Array)(30);
- w = 0;
- for (B = C.length; w < B; ++w) C[w] = 5;
- g(C);
- var O = 8
- }).call(this);
- _p = window;
- _p = _p.Zlib = _p.Zlib;
- _p.Deflate = _p.Deflate;
- _p.Deflate.compress = _p.Deflate.compress;
- _p.Inflate = _p.Inflate;
- _p.Inflate.BufferType = _p.Inflate.BufferType;
- _p.Inflate.prototype.decompress = _p.Inflate.prototype.decompress;
- cc.PNGReader = cc.Class.extend({
- ctor: function(a) {
- var c, d, e, f;
- this.data = a;
- this.pos = 8;
- this.palette = [];
- this.imgData = [];
- this.transparency = {};
- this.animation = null;
- this.text = {};
- for (e = null;;) {
- c = this.readUInt32();
- f = a = void 0;
- f = [];
- for (a = 0; 4 > a; ++a) f.push(String.fromCharCode(this.data[this.pos++]));
- a = f.join("");
- switch (a) {
- case "IHDR":
- this.width = this.readUInt32();
- this.height = this.readUInt32();
- this.bits = this.data[this.pos++];
- this.colorType = this.data[this.pos++];
- this.compressionMethod = this.data[this.pos++];
- this.filterMethod = this.data[this.pos++];
- this.interlaceMethod = this.data[this.pos++];
- break;
- case "acTL":
- this.animation = {
- numFrames: this.readUInt32(),
- numPlays: this.readUInt32() || Infinity,
- frames: []
- };
- break;
- case "PLTE":
- this.palette = this.read(c);
- break;
- case "fcTL":
- e && this.animation.frames.push(e);
- this.pos += 4;
- e = {
- width: this.readUInt32(),
- height: this.readUInt32(),
- xOffset: this.readUInt32(),
- yOffset: this.readUInt32()
- };
- a = this.readUInt16();
- c = this.readUInt16() || 100;
- e.delay = 1E3 * a / c;
- e.disposeOp = this.data[this.pos++];
- e.blendOp = this.data[this.pos++];
- e.data = [];
- break;
- case "IDAT":
- case "fdAT":
- "fdAT" === a && (this.pos += 4, c -= 4);
- a = (null != e ? e.data : void 0) || this.imgData;
- for (f = 0; 0 <= c ? f < c : f > c; 0 <= c ? ++f : --f) a.push(this.data[this.pos++]);
- break;
- case "tRNS":
- this.transparency = {};
- switch (this.colorType) {
- case 3:
- this.transparency.indexed = this.read(c);
- c = 255 - this.transparency.indexed.length;
- if (0 < c)
- for (a = 0; 0 <= c ? a < c : a > c; 0 <= c ? ++a : --a) this.transparency.indexed.push(255);
- break;
- case 0:
- this.transparency.grayscale = this.read(c)[0];
- break;
- case 2:
- this.transparency.rgb = this.read(c)
- }
- break;
- case "tEXt":
- f = this.read(c);
- c = f.indexOf(0);
- a = String.fromCharCode.apply(String, f.slice(0, c));
- this.text[a] = String.fromCharCode.apply(String, f.slice(c + 1));
- break;
- case "IEND":
- e && this.animation.frames.push(e);
- a: {
- switch (this.colorType) {
- case 0:
- case 3:
- case 4:
- e = 1;
- break a;
- case 2:
- case 6:
- e = 3;
- break a
- }
- e = void 0
- }
- this.colors = e;
- this.hasAlphaChannel = 4 === (d = this.colorType) || 6 === d;
- d = this.colors + (this.hasAlphaChannel ? 1 : 0);
- this.pixelBitlength = this.bits * d;
- a: {
- switch (this.colors) {
- case 1:
- d = "DeviceGray";
- break a;
- case 3:
- d = "DeviceRGB";
- break a
- }
- d = void 0
- }
- this.colorSpace = d;
- Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData));
- return;
- default:
- this.pos += c
- }
- this.pos += 4;
- if (this.pos > this.data.length) throw Error("Incomplete or corrupt PNG file");
- }
- },
- read: function(a) {
- var c, d;
- d = [];
- for (c = 0; 0 <= a ? c < a : c > a; 0 <= a ? ++c : --c) d.push(this.data[this.pos++]);
- return d
- },
- readUInt32: function() {
- var a, c, d, e;
- a = this.data[this.pos++] << 24;
- c = this.data[this.pos++] << 16;
- d = this.data[this.pos++] << 8;
- e = this.data[this.pos++];
- return a | c | d | e
- },
- readUInt16: function() {
- var a, c;
- a = this.data[this.pos++] << 8;
- c = this.data[this.pos++];
- return a | c
- },
- decodePixels: function(a) {
- var c, d, e, f, g, h, k, m, n, q, r, t, s, v, u;
- null == a && (a = this.imgData);
- if (0 === a.length) return new Uint8Array(0);
- a = (new Zlib.Inflate(a, {
- index: 0,
- verify: !1
- })).decompress();
- m = this.pixelBitlength / 8;
- t = m * this.width;
- n = new Uint8Array(t * this.height);
- h = a.length;
- for (d = q = r = 0; q < h;) {
- switch (a[q++]) {
- case 0:
- for (c = 0; c < t; c += 1) n[d++] = a[q++];
- break;
- case 1:
- for (f = s = 0; s < t; f = s += 1) c = a[q++], g = f < m ? 0 : n[d - m], n[d++] = (c + g) % 256;
- break;
- case 2:
- for (f = g = 0; g < t; f = g += 1) c = a[q++], e = (f - f % m) / m, s = r && n[(r - 1) * t + e * m + f % m], n[d++] = (s + c) % 256;
- break;
- case 3:
- for (f = u = 0; u < t; f = u += 1) c = a[q++], e = (f - f % m) / m, g = f < m ? 0 : n[d - m], s = r && n[(r - 1) * t + e * m + f % m], n[d++] = (c + Math.floor((g + s) / 2)) % 256;
- break;
- case 4:
- for (f = u = 0; u < t; f = u += 1) c = a[q++], e = (f - f % m) / m, g = f < m ? 0 : n[d - m], 0 === r ? s = v = 0 : (s = n[(r - 1) * t + e * m + f % m], v = e && n[(r - 1) * t + (e - 1) * m + f % m]), k = g + s - v, f = Math.abs(k - g), e = Math.abs(k - s), k = Math.abs(k - v), g = f <= e && f <= k ? g : e <= k ? s : v, n[d++] = (c + g) % 256;
- break;
- default:
- throw Error("Invalid filter algorithm: " + a[q - 1]);
- }
- r++
- }
- return n
- },
- copyToImageData: function(a, c) {
- var d, e, f, g, h, k, m, n;
- e = this.colors;
- n = null;
- d = this.hasAlphaChannel;
- this.palette.length && (n = null != (f = this._decodedPalette) ? f : this._decodedPalette = this.decodePalette(), e = 4, d = !0);
- f = a.data || a;
- m = f.length;
- h = n || c;
- g = k = 0;
- if (1 === e)
- for (; g < m;) e = n ? 4 * c[g / 4] : k, k = h[e++], f[g++] = k, f[g++] = k, f[g++] = k, f[g++] = d ? h[e++] : 255, k = e;
- else
- for (; g < m;) e = n ? 4 * c[g / 4] : k, f[g++] = h[e++], f[g++] = h[e++], f[g++] = h[e++], f[g++] = d ? h[e++] : 255, k = e
- },
- decodePalette: function() {
- var a, c, d, e, f, g, h, k, m;
- d = this.palette;
- g = this.transparency.indexed || [];
- f = new Uint8Array((g.length || 0) + d.length);
- c = h = a = e = 0;
- for (k = d.length; h < k; c = h += 3) f[e++] = d[c], f[e++] = d[c + 1], f[e++] = d[c + 2], f[e++] = null != (m = g[a++]) ? m : 255;
- return f
- },
- render: function(a) {
- var c;
- a.width = this.width;
- a.height = this.height;
- a = a.getContext("2d");
- c = a.createImageData(this.width, this.height);
- this.copyToImageData(c, this.decodePixels());
- return a.putImageData(c, 0, 0)
- }
- });
- cc.tiffReader = {
- _littleEndian: !1,
- _tiffData: null,
- _fileDirectories: [],
- getUint8: function(a) {
- return this._tiffData[a]
- },
- getUint16: function(a) {
- return this._littleEndian ? this._tiffData[a + 1] << 8 | this._tiffData[a] : this._tiffData[a] << 8 | this._tiffData[a + 1]
- },
- getUint32: function(a) {
- var c = this._tiffData;
- return this._littleEndian ? c[a + 3] << 24 | c[a + 2] << 16 | c[a + 1] << 8 | c[a] : c[a] << 24 | c[a + 1] << 16 | c[a + 2] << 8 | c[a + 3]
- },
- checkLittleEndian: function() {
- var a = this.getUint16(0);
- if (18761 === a) this.littleEndian = !0;
- else if (19789 === a) this.littleEndian = !1;
- else throw TypeError("Invalid byte order value.");
- return this.littleEndian
- },
- hasTowel: function() {
- if (42 !== this.getUint16(2)) throw RangeError("You forgot your towel!");
- return !0
- },
- getFieldTypeName: function(a) {
- var c = this.fieldTypeNames;
- return a in c ? c[a] : null
- },
- getFieldTagName: function(a) {
- var c = this.fieldTagNames;
- if (a in c) return c[a];
- return "Tag" + a
- },
- getFieldTypeLength: function(a) {
- return -1 !== ["BYTE", "ASCII", "SBYTE", "UNDEFINED"].indexOf(a) ? 1 : -1 !== ["SHORT", "SSHORT"].indexOf(a) ? 2 : -1 !== ["LONG", "SLONG", "FLOAT"].indexOf(a) ? 4 : -1 !== ["RATIONAL", "SRATIONAL", "DOUBLE"].indexOf(a) ? 8 : null
- },
- getFieldValues: function(a, c, d, e) {
- a = [];
- var f = this.getFieldTypeLength(c);
- if (4 >= f * d)!1 === this.littleEndian ? a.push(e >>> 8 * (4 - f)) : a.push(e);
- else
- for (var g = 0; g < d; g++) {
- var h = f * g;
- 8 <= f ? -1 !== ["RATIONAL", "SRATIONAL"].indexOf(c) ? (a.push(this.getUint32(e + h)), a.push(this.getUint32(e + h + 4))) : cc.log("Can't handle this field type or size") : a.push(this.getBytes(f, e + h))
- }
- "ASCII" === c && a.forEach(function(a, c, d) {
- d[c] = String.fromCharCode(a)
- });
- return a
- },
- getBytes: function(a, c) {
- if (0 >= a) cc.log("No bytes requested");
- else {
- if (1 >= a) return this.getUint8(c);
- if (2 >= a) return this.getUint16(c);
- if (3 >= a) return this.getUint32(c) >>> 8;
- if (4 >= a) return this.getUint32(c);
- cc.log("Too many bytes requested")
- }
- },
- getBits: function(a, c, d) {
- d = d || 0;
- c += Math.floor(d / 8);
- var e = d + a;
- a = 32 - a;
- var f, g;
- 0 >= e ? console.log("No bits requested") : 8 >= e ? (f = 24 + d, g = this.getUint8(c)) : 16 >= e ? (f = 16 + d, g = this.getUint16(c)) : 32 >= e ? (f = d, g = this.getUint32(c)) : console.log("Too many bits requested");
- return {
- bits: g << f >>> a,
- byteOffset: c + Math.floor(e / 8),
- bitOffset: e % 8
- }
- },
- parseFileDirectory: function(a) {
- var c = this.getUint16(a),
- d = [];
- a += 2;
- for (var e = 0; e < c; a += 12, e++) {
- var f = this.getUint16(a),
- g = this.getUint16(a + 2),
- h = this.getUint32(a + 4),
- k = this.getUint32(a + 8),
- f = this.getFieldTagName(f),
- g = this.getFieldTypeName(g),
- h = this.getFieldValues(f, g, h, k);
- d[f] = {
- type: g,
- values: h
- }
- }
- this._fileDirectories.push(d);
- c = this.getUint32(a);
- 0 !== c && this.parseFileDirectory(c)
- },
- clampColorSample: function(a, c) {
- var d = Math.pow(2, 8 - c);
- return Math.floor(a * d + (d - 1))
- },
- parseTIFF: function(a, c) {
- c = c || cc.newElement("canvas");
- this._tiffData = a;
- this.canvas = c;
- this.checkLittleEndian();
- if (this.hasTowel()) {
- var d = this.getUint32(4);
- this._fileDirectories.length = 0;
- this.parseFileDirectory(d);
- var e = this._fileDirectories[0],
- d = e.ImageWidth.values[0],
- f = e.ImageLength.values[0];
- this.canvas.width = d;
- this.canvas.height = f;
- var g = [],
- h = e.Compression ? e.Compression.values[0] : 1,
- k = e.SamplesPerPixel.values[0],
- m = [],
- n = 0,
- q = !1;
- e.BitsPerSample.values.forEach(function(a, c, d) {
- m[c] = {
- bitsPerSample: a,
- hasBytesPerSample: !1,
- bytesPerSample: void 0
- };
- 0 === a % 8 && (m[c].hasBytesPerSample = !0, m[c].bytesPerSample = a / 8);
- n += a
- }, this);
- if (0 === n % 8) var q = !0,
- r = n / 8;
- var t = e.StripOffsets.values,
- s = t.length;
- if (e.StripByteCounts) var v = e.StripByteCounts.values;
- else if (cc.log("Missing StripByteCounts!"), 1 === s) v = [Math.ceil(d * f * n / 8)];
- else throw Error("Cannot recover from missing StripByteCounts");
- for (var u = 0; u < s; u++) {
- var x = t[u];
- g[u] = [];
- for (var A = v[u], D = 0, F = 0, y = 1, z = !0, C = [], w = 0, B = 0, G = 0; D < A; D += y) switch (h) {
- case 1:
- y = 0;
- for (C = []; y < k; y++)
- if (m[y].hasBytesPerSample) C.push(this.getBytes(m[y].bytesPerSample, x + D + m[y].bytesPerSample * y));
- else {
- var H = this.getBits(m[y].bitsPerSample, x + D, F);
- C.push(H.bits);
- D = H.byteOffset - x;
- F = H.bitOffset;
- throw RangeError("Cannot handle sub-byte bits per sample");
- }
- g[u].push(C);
- if (q) y = r;
- else throw y = 0, RangeError("Cannot handle sub-byte bits per pixel");
- break;
- case 32773:
- if (z) {
- var z = !1,
- E = 1,
- K = 1,
- y = this.getInt8(x + D);
- 0 <= y && 127 >= y ? E = y + 1 : -127 <= y && -1 >= y ? K = -y + 1 : z = !0
- } else {
- for (var M = this.getUint8(x + D), y = 0; y < K; y++) {
- if (m[B].hasBytesPerSample) G = G << 8 * w | M, w++, w === m[B].bytesPerSample && (C.push(G), G = w = 0, B++);
- else throw RangeError("Cannot handle sub-byte bits per sample");
- B === k && (g[u].push(C), C = [], B = 0)
- }
- E--;
- 0 === E && (z = !0)
- }
- y = 1
- }
- }
- if (c.getContext) {
- r = this.canvas.getContext("2d");
- r.fillStyle = "rgba(255, 255, 255, 0)";
- u = e.RowsPerStrip ? e.RowsPerStrip.values[0] : f;
- x = g.length;
- f %= u;
- f = 0 === f ? u : f;
- D = u;
- h = 0;
- C = e.PhotometricInterpretation.values[0];
- E = [];
- K = 0;
- e.ExtraSamples && (E = e.ExtraSamples.values, K = E.length);
- if (e.ColorMap) var H = e.ColorMap.values,
- L = Math.pow(2, m[0].bitsPerSample);
- for (u = 0; u < x; u++) {
- u + 1 === x && (D = f);
- e = g[u].length;
- h *= u;
- for (q = k = 0; k < D, q < e; k++)
- for (t = 0; t < d; t++, q++) {
- v = g[u][q];
- z = F = A = 0;
- s = 1;
- if (0 < K)
- for (A = 0; A < K; A++)
- if (1 === E[A] || 2 === E[A]) {
- s = v[3 + A] / 256;
- break
- }
- switch (C) {
- case 0:
- if (m[0].hasBytesPerSample) var N = Math.pow(16, 2 * m[0].bytesPerSample);
- v.forEach(function(a, c, d) {
- d[c] = N - a
- });
- case 1:
- A = F = z = this.clampColorSample(v[0], m[0].bitsPerSample);
- break;
- case 2:
- A = this.clampColorSample(v[0], m[0].bitsPerSample);
- F = this.clampColorSample(v[1], m[1].bitsPerSample);
- z = this.clampColorSample(v[2], m[2].bitsPerSample);
- break;
- case 3:
- if (void 0 === H) throw Error("Palette image missing color map");
- v = v[0];
- A = this.clampColorSample(H[v], 16);
- F = this.clampColorSample(H[L + v], 16);
- z = this.clampColorSample(H[2 * L + v], 16);
- break;
- default:
- throw RangeError("Unknown Photometric Interpretation:", C);
- }
- r.fillStyle = "rgba(" + A + ", " + F + ", " + z + ", " + s + ")";
- r.fillRect(t, h + k, 1, 1)
- }
- h = D
- }
- }
- return this.canvas
- }
- },
- fieldTagNames: {
- 315: "Artist",
- 258: "BitsPerSample",
- 265: "CellLength",
- 264: "CellWidth",
- 320: "ColorMap",
- 259: "Compression",
- 33432: "Copyright",
- 306: "DateTime",
- 338: "ExtraSamples",
- 266: "FillOrder",
- 289: "FreeByteCounts",
- 288: "FreeOffsets",
- 291: "GrayResponseCurve",
- 290: "GrayResponseUnit",
- 316: "HostComputer",
- 270: "ImageDescription",
- 257: "ImageLength",
- 256: "ImageWidth",
- 271: "Make",
- 281: "MaxSampleValue",
- 280: "MinSampleValue",
- 272: "Model",
- 254: "NewSubfileType",
- 274: "Orientation",
- 262: "PhotometricInterpretation",
- 284: "PlanarConfiguration",
- 296: "ResolutionUnit",
- 278: "RowsPerStrip",
- 277: "SamplesPerPixel",
- 305: "Software",
- 279: "StripByteCounts",
- 273: "StripOffsets",
- 255: "SubfileType",
- 263: "Threshholding",
- 282: "XResolution",
- 283: "YResolution",
- 326: "BadFaxLines",
- 327: "CleanFaxData",
- 343: "ClipPath",
- 328: "ConsecutiveBadFaxLines",
- 433: "Decode",
- 434: "DefaultImageColor",
- 269: "DocumentName",
- 336: "DotRange",
- 321: "HalftoneHints",
- 346: "Indexed",
- 347: "JPEGTables",
- 285: "PageName",
- 297: "PageNumber",
- 317: "Predictor",
- 319: "PrimaryChromaticities",
- 532: "ReferenceBlackWhite",
- 339: "SampleFormat",
- 559: "StripRowCounts",
- 330: "SubIFDs",
- 292: "T4Options",
- 293: "T6Options",
- 325: "TileByteCounts",
- 323: "TileLength",
- 324: "TileOffsets",
- 322: "TileWidth",
- 301: "TransferFunction",
- 318: "WhitePoint",
- 344: "XClipPathUnits",
- 286: "XPosition",
- 529: "YCbCrCoefficients",
- 531: "YCbCrPositioning",
- 530: "YCbCrSubSampling",
- 345: "YClipPathUnits",
- 287: "YPosition",
- 37378: "ApertureValue",
- 40961: "ColorSpace",
- 36868: "DateTimeDigitized",
- 36867: "DateTimeOriginal",
- 34665: "Exif IFD",
- 36864: "ExifVersion",
- 33434: "ExposureTime",
- 41728: "FileSource",
- 37385: "Flash",
- 40960: "FlashpixVersion",
- 33437: "FNumber",
- 42016: "ImageUniqueID",
- 37384: "LightSource",
- 37500: "MakerNote",
- 37377: "ShutterSpeedValue",
- 37510: "UserComment",
- 33723: "IPTC",
- 34675: "ICC Profile",
- 700: "XMP",
- 42112: "GDAL_METADATA",
- 42113: "GDAL_NODATA",
- 34377: "Photoshop"
- },
- fieldTypeNames: {
- 1: "BYTE",
- 2: "ASCII",
- 3: "SHORT",
- 4: "LONG",
- 5: "RATIONAL",
- 6: "SBYTE",
- 7: "UNDEFINED",
- 8: "SSHORT",
- 9: "SLONG",
- 10: "SRATIONAL",
- 11: "FLOAT",
- 12: "DOUBLE"
- }
- };
- cc.Particle = function(a, c, d, e, f, g, h, k, m, n, q, r) {
- this.pos = a ? a : cc.p(0, 0);
- this.startPos = c ? c : cc.p(0, 0);
- this.color = d ? d : {
- r: 0,
- g: 0,
- b: 0,
- a: 255
- };
- this.deltaColor = e ? e : {
- r: 0,
- g: 0,
- b: 0,
- a: 255
- };
- this.size = f || 0;
- this.deltaSize = g || 0;
- this.rotation = h || 0;
- this.deltaRotation = k || 0;
- this.timeToLive = m || 0;
- this.atlasIndex = n || 0;
- this.modeA = q ? q : new cc.Particle.ModeA;
- this.modeB = r ? r : new cc.Particle.ModeB;
- this.isChangeColor = !1;
- this.drawPos = cc.p(0, 0)
- };
- cc.Particle.ModeA = function(a, c, d) {
- this.dir = a ? a : cc.p(0, 0);
- this.radialAccel = c || 0;
- this.tangentialAccel = d || 0
- };
- cc.Particle.ModeB = function(a, c, d, e) {
- this.angle = a || 0;
- this.degreesPerSecond = c || 0;
- this.radius = d || 0;
- this.deltaRadius = e || 0
- };
- cc.Particle.TemporaryPoints = [cc.p(), cc.p(), cc.p(), cc.p()];
- cc.ParticleSystem = cc.Node.extend({
- _plistFile: "",
- _elapsed: 0,
- _dontTint: !1,
- modeA: null,
- modeB: null,
- _className: "ParticleSystem",
- _pointZeroForParticle: cc.p(0, 0),
- _particles: null,
- _emitCounter: 0,
- _particleIdx: 0,
- _batchNode: null,
- atlasIndex: 0,
- _transformSystemDirty: !1,
- _allocatedParticles: 0,
- drawMode: null,
- shapeType: null,
- _isActive: !1,
- particleCount: 0,
- duration: 0,
- _sourcePosition: null,
- _posVar: null,
- life: 0,
- lifeVar: 0,
- angle: 0,
- angleVar: 0,
- startSize: 0,
- startSizeVar: 0,
- endSize: 0,
- endSizeVar: 0,
- _startColor: null,
- _startColorVar: null,
- _endColor: null,
- _endColorVar: null,
- startSpin: 0,
- startSpinVar: 0,
- endSpin: 0,
- endSpinVar: 0,
- emissionRate: 0,
- _totalParticles: 0,
- _texture: null,
- _blendFunc: null,
- _opacityModifyRGB: !1,
- positionType: null,
- autoRemoveOnFinish: !1,
- emitterMode: 0,
- _quads: null,
- _indices: null,
- _buffersVBO: null,
- _pointRect: null,
- _textureLoaded: null,
- _quadsArrayBuffer: null,
- ctor: function(a) {
- cc.Node.prototype.ctor.call(this);
- this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
- this.modeA = new cc.ParticleSystem.ModeA;
- this.modeB = new cc.ParticleSystem.ModeB;
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- this._particles = [];
- this._sourcePosition = cc.p(0, 0);
- this._posVar = cc.p(0, 0);
- this._startColor = cc.color(255, 255, 255, 255);
- this._startColorVar = cc.color(255, 255, 255, 255);
- this._endColor = cc.color(255, 255, 255, 255);
- this._endColorVar = cc.color(255, 255, 255, 255);
- this._plistFile = "";
- this._elapsed = 0;
- this._dontTint = !1;
- this._pointZeroForParticle = cc.p(0, 0);
- this._particleIdx = this._emitCounter = 0;
- this._batchNode = null;
- this.atlasIndex = 0;
- this._transformSystemDirty = !1;
- this._allocatedParticles = 0;
- this.drawMode = cc.ParticleSystem.SHAPE_MODE;
- this.shapeType = cc.ParticleSystem.BALL_SHAPE;
- this._isActive = !1;
- this._totalParticles = this.emissionRate = this.endSpinVar = this.endSpin = this.startSpinVar = this.startSpin = this.endSizeVar = this.endSize = this.startSizeVar = this.startSize = this.angleVar = this.angle = this.lifeVar = this.life = this.duration = this.particleCount = 0;
- this._texture = null;
- this._opacityModifyRGB = !1;
- this.positionType = cc.ParticleSystem.TYPE_FREE;
- this.autoRemoveOnFinish = !1;
- this._buffersVBO = [0, 0];
- this._quads = [];
- this._indices = [];
- this._pointRect = cc.rect(0, 0, 0, 0);
- this._textureLoaded = !0;
- cc._renderType === cc._RENDER_TYPE_WEBGL && (this._quadsArrayBuffer = null);
- !a || "number" === typeof a ? (a = a || 100, this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE), this.initWithTotalParticles(a)) : a && this.initWithFile(a)
- },
- initIndices: function() {
- for (var a = this._indices, c = 0, d = this._totalParticles; c < d; ++c) {
- var e = 6 * c,
- f = 4 * c;
- a[e + 0] = f + 0;
- a[e + 1] = f + 1;
- a[e + 2] = f + 2;
- a[e + 5] = f + 1;
- a[e + 4] = f + 2;
- a[e + 3] = f + 3
- }
- },
- initTexCoordsWithRect: function(a) {
- var c = cc.contentScaleFactor(),
- d = cc.rect(a.x * c, a.y * c, a.width * c, a.height * c),
- e = a.width,
- f = a.height;
- this._texture && (e = this._texture.pixelsWidth, f = this._texture.pixelsHeight);
- if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
- cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (a = (2 * d.x + 1) / (2 * e), c = (2 * d.y + 1) / (2 * f), e = a + (2 * d.width - 2) / (2 * e), d = c + (2 * d.height - 2) / (2 * f)) : (a = d.x / e, c = d.y / f, e = a + d.width / e, d = c + d.height / f);
- var f = d,
- d = c,
- c = f,
- g = 0,
- h = 0;
- this._batchNode ? (f = this._batchNode.textureAtlas.quads, g = this.atlasIndex, h = this.atlasIndex + this._totalParticles) : (f = this._quads, g = 0, h = this._totalParticles);
- for (; g < h; g++) {
- f[g] || (f[g] = cc.V3F_C4B_T2F_QuadZero());
- var k = f[g];
- k.bl.texCoords.u = a;
- k.bl.texCoords.v = c;
- k.br.texCoords.u = e;
- k.br.texCoords.v = c;
- k.tl.texCoords.u = a;
- k.tl.texCoords.v = d;
- k.tr.texCoords.u = e;
- k.tr.texCoords.v = d
- }
- }
- },
- getBatchNode: function() {
- return this._batchNode
- },
- setBatchNode: function(a) {
- if (this._batchNode != a) {
- var c = this._batchNode;
- if (this._batchNode = a)
- for (var d = this._particles, e = 0; e < this._totalParticles; e++) d[e].atlasIndex = e;
- a ? c || (this._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads, this.atlasIndex), cc._renderContext.deleteBuffer(this._buffersVBO[1])) : (this._allocMemory(), this.initIndices(), this.setTexture(c.getTexture()), this._setupVBO())
- }
- },
- getAtlasIndex: function() {
- return this.atlasIndex
- },
- setAtlasIndex: function(a) {
- this.atlasIndex = a
- },
- getDrawMode: function() {
- return this.drawMode
- },
- setDrawMode: function(a) {
- this.drawMode = a
- },
- getShapeType: function() {
- return this.shapeType
- },
- setShapeType: function(a) {
- this.shapeType = a
- },
- isActive: function() {
- return this._isActive
- },
- getParticleCount: function() {
- return this.particleCount
- },
- setParticleCount: function(a) {
- this.particleCount = a
- },
- getDuration: function() {
- return this.duration
- },
- setDuration: function(a) {
- this.duration = a
- },
- getSourcePosition: function() {
- return {
- x: this._sourcePosition.x,
- y: this._sourcePosition.y
- }
- },
- setSourcePosition: function(a) {
- this._sourcePosition = a
- },
- getPosVar: function() {
- return {
- x: this._posVar.x,
- y: this._posVar.y
- }
- },
- setPosVar: function(a) {
- this._posVar = a
- },
- getLife: function() {
- return this.life
- },
- setLife: function(a) {
- this.life = a
- },
- getLifeVar: function() {
- return this.lifeVar
- },
- setLifeVar: function(a) {
- this.lifeVar = a
- },
- getAngle: function() {
- return this.angle
- },
- setAngle: function(a) {
- this.angle = a
- },
- getAngleVar: function() {
- return this.angleVar
- },
- setAngleVar: function(a) {
- this.angleVar = a
- },
- getGravity: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");
- var a = this.modeA.gravity;
- return cc.p(a.x, a.y)
- },
- setGravity: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");
- this.modeA.gravity = a
- },
- getSpeed: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");
- return this.modeA.speed
- },
- setSpeed: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");
- this.modeA.speed = a
- },
- getSpeedVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");
- return this.modeA.speedVar
- },
- setSpeedVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
- this.modeA.speedVar = a
- },
- getTangentialAccel: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");
- return this.modeA.tangentialAccel
- },
- setTangentialAccel: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");
- this.modeA.tangentialAccel = a
- },
- getTangentialAccelVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");
- return this.modeA.tangentialAccelVar
- },
- setTangentialAccelVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");
- this.modeA.tangentialAccelVar = a
- },
- getRadialAccel: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");
- return this.modeA.radialAccel
- },
- setRadialAccel: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");
- this.modeA.radialAccel = a
- },
- getRadialAccelVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");
- return this.modeA.radialAccelVar
- },
- setRadialAccelVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
- this.modeA.radialAccelVar = a
- },
- getRotationIsDir: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");
- return this.modeA.rotationIsDir
- },
- setRotationIsDir: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");
- this.modeA.rotationIsDir = a
- },
- getStartRadius: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
- return this.modeB.startRadius
- },
- setStartRadius: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");
- this.modeB.startRadius = a
- },
- getStartRadiusVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");
- return this.modeB.startRadiusVar
- },
- setStartRadiusVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
- this.modeB.startRadiusVar = a
- },
- getEndRadius: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");
- return this.modeB.endRadius
- },
- setEndRadius: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");
- this.modeB.endRadius = a
- },
- getEndRadiusVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
- return this.modeB.endRadiusVar
- },
- setEndRadiusVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");
- this.modeB.endRadiusVar = a
- },
- getRotatePerSecond: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");
- return this.modeB.rotatePerSecond
- },
- setRotatePerSecond: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
- this.modeB.rotatePerSecond = a
- },
- getRotatePerSecondVar: function() {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");
- return this.modeB.rotatePerSecondVar
- },
- setRotatePerSecondVar: function(a) {
- this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");
- this.modeB.rotatePerSecondVar = a
- },
- setScale: function(a, c) {
- this._transformSystemDirty = !0;
- cc.Node.prototype.setScale.call(this, a, c)
- },
- setRotation: function(a) {
- this._transformSystemDirty = !0;
- cc.Node.prototype.setRotation.call(this, a)
- },
- setScaleX: function(a) {
- this._transformSystemDirty = !0;
- cc.Node.prototype.setScaleX.call(this, a)
- },
- setScaleY: function(a) {
- this._transformSystemDirty = !0;
- cc.Node.prototype.setScaleY.call(this, a)
- },
- getStartSize: function() {
- return this.startSize
- },
- setStartSize: function(a) {
- this.startSize = a
- },
- getStartSizeVar: function() {
- return this.startSizeVar
- },
- setStartSizeVar: function(a) {
- this.startSizeVar = a
- },
- getEndSize: function() {
- return this.endSize
- },
- setEndSize: function(a) {
- this.endSize = a
- },
- getEndSizeVar: function() {
- return this.endSizeVar
- },
- setEndSizeVar: function(a) {
- this.endSizeVar = a
- },
- getStartColor: function() {
- return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a)
- },
- setStartColor: function(a) {
- this._startColor = cc.color(a)
- },
- getStartColorVar: function() {
- return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a)
- },
- setStartColorVar: function(a) {
- this._startColorVar = cc.color(a)
- },
- getEndColor: function() {
- return cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a)
- },
- setEndColor: function(a) {
- this._endColor = cc.color(a)
- },
- getEndColorVar: function() {
- return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a)
- },
- setEndColorVar: function(a) {
- this._endColorVar = cc.color(a)
- },
- getStartSpin: function() {
- return this.startSpin
- },
- setStartSpin: function(a) {
- this.startSpin = a
- },
- getStartSpinVar: function() {
- return this.startSpinVar
- },
- setStartSpinVar: function(a) {
- this.startSpinVar = a
- },
- getEndSpin: function() {
- return this.endSpin
- },
- setEndSpin: function(a) {
- this.endSpin = a
- },
- getEndSpinVar: function() {
- return this.endSpinVar
- },
- setEndSpinVar: function(a) {
- this.endSpinVar = a
- },
- getEmissionRate: function() {
- return this.emissionRate
- },
- setEmissionRate: function(a) {
- this.emissionRate = a
- },
- getTotalParticles: function() {
- return this._totalParticles
- },
- setTotalParticles: function(a) {
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) this._totalParticles = 200 > a ? a : 200;
- else {
- if (a > this._allocatedParticles) {
- var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
- this._indices = new Uint16Array(6 * a);
- var d = new ArrayBuffer(a * c),
- e = this._particles;
- e.length = 0;
- for (var f = this._quads, g = f.length = 0; g < a; g++) e[g] = new cc.Particle, f[g] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, d, g * c);
- this._totalParticles = this._allocatedParticles = a;
- if (this._batchNode)
- for (c = 0; c < a; c++) e[c].atlasIndex = c;
- this._quadsArrayBuffer = d;
- this.initIndices();
- this._setupVBO();
- this._texture && this.initTexCoordsWithRect(cc.rect(0, 0, this._texture.width, this._texture.height))
- } else this._totalParticles = a;
- this.resetSystem()
- }
- },
- getTexture: function() {
- return this._texture
- },
- setTexture: function(a) {
- a.isLoaded() ? this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height)) : (this._textureLoaded = !1, a.addLoadedEventListener(function(a) {
- this._textureLoaded = !0;
- this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height))
- }, this))
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendFunc: function(a, c) {
- if (void 0 === c) this._blendFunc != a && (this._blendFunc = a, this._updateBlendFunc());
- else if (this._blendFunc.src != a || this._blendFunc.dst != c) this._blendFunc = {
- src: a,
- dst: c
- }, this._updateBlendFunc()
- },
- isOpacityModifyRGB: function() {
- return this._opacityModifyRGB
- },
- setOpacityModifyRGB: function(a) {
- this._opacityModifyRGB = a
- },
- isBlendAdditive: function() {
- return this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE || this._blendFunc.src == cc.ONE && this._blendFunc.dst == cc.ONE
- },
- setBlendAdditive: function(a) {
- var c = this._blendFunc;
- a ? (c.src = cc.SRC_ALPHA, c.dst = cc.ONE) : cc._renderType === cc._RENDER_TYPE_WEBGL ? this._texture && !this._texture.hasPremultipliedAlpha() ? (c.src = cc.SRC_ALPHA, c.dst = cc.ONE_MINUS_SRC_ALPHA) : (c.src = cc.BLEND_SRC, c.dst = cc.BLEND_DST) : (c.src = cc.BLEND_SRC, c.dst = cc.BLEND_DST)
- },
- getPositionType: function() {
- return this.positionType
- },
- setPositionType: function(a) {
- this.positionType = a
- },
- isAutoRemoveOnFinish: function() {
- return this.autoRemoveOnFinish
- },
- setAutoRemoveOnFinish: function(a) {
- this.autoRemoveOnFinish = a
- },
- getEmitterMode: function() {
- return this.emitterMode
- },
- setEmitterMode: function(a) {
- this.emitterMode = a
- },
- init: function() {
- return this.initWithTotalParticles(150)
- },
- initWithFile: function(a) {
- this._plistFile = a;
- a = cc.loader.getRes(a);
- return !a ? (cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"), !1) : this.initWithDictionary(a, "")
- },
- getBoundingBoxToWorld: function() {
- return cc.rect(0, 0, cc._canvas.width, cc._canvas.height)
- },
- initWithDictionary: function(a, c) {
- var d = !1,
- e = null,
- e = this._valueForKey,
- f = parseInt(e("maxParticles", a));
- if (this.initWithTotalParticles(f)) {
- this.angle = parseFloat(e("angle", a));
- this.angleVar = parseFloat(e("angleVariance", a));
- this.duration = parseFloat(e("duration", a));
- this._blendFunc.src = parseInt(e("blendFuncSource", a));
- this._blendFunc.dst = parseInt(e("blendFuncDestination", a));
- d = this._startColor;
- d.r = 255 * parseFloat(e("startColorRed", a));
- d.g = 255 * parseFloat(e("startColorGreen", a));
- d.b = 255 * parseFloat(e("startColorBlue", a));
- d.a = 255 * parseFloat(e("startColorAlpha", a));
- d = this._startColorVar;
- d.r = 255 * parseFloat(e("startColorVarianceRed", a));
- d.g = 255 * parseFloat(e("startColorVarianceGreen", a));
- d.b = 255 * parseFloat(e("startColorVarianceBlue", a));
- d.a = 255 * parseFloat(e("startColorVarianceAlpha", a));
- d = this._endColor;
- d.r = 255 * parseFloat(e("finishColorRed", a));
- d.g = 255 * parseFloat(e("finishColorGreen", a));
- d.b = 255 * parseFloat(e("finishColorBlue", a));
- d.a = 255 * parseFloat(e("finishColorAlpha", a));
- d = this._endColorVar;
- d.r = 255 * parseFloat(e("finishColorVarianceRed", a));
- d.g = 255 * parseFloat(e("finishColorVarianceGreen", a));
- d.b = 255 * parseFloat(e("finishColorVarianceBlue", a));
- d.a = 255 * parseFloat(e("finishColorVarianceAlpha", a));
- this.startSize = parseFloat(e("startParticleSize", a));
- this.startSizeVar = parseFloat(e("startParticleSizeVariance", a));
- this.endSize = parseFloat(e("finishParticleSize", a));
- this.endSizeVar = parseFloat(e("finishParticleSizeVariance", a));
- this.setPosition(parseFloat(e("sourcePositionx", a)), parseFloat(e("sourcePositiony", a)));
- this._posVar.x = parseFloat(e("sourcePositionVariancex", a));
- this._posVar.y = parseFloat(e("sourcePositionVariancey", a));
- this.startSpin = parseFloat(e("rotationStart", a));
- this.startSpinVar = parseFloat(e("rotationStartVariance", a));
- this.endSpin = parseFloat(e("rotationEnd", a));
- this.endSpinVar = parseFloat(e("rotationEndVariance", a));
- this.emitterMode = parseInt(e("emitterType", a));
- if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) d = this.modeA, d.gravity.x = parseFloat(e("gravityx", a)), d.gravity.y = parseFloat(e("gravityy", a)), d.speed = parseFloat(e("speed", a)), d.speedVar = parseFloat(e("speedVariance", a)), f = e("radialAcceleration", a), d.radialAccel = f ? parseFloat(f) : 0, f = e("radialAccelVariance", a), d.radialAccelVar = f ? parseFloat(f) : 0, f = e("tangentialAcceleration", a), d.tangentialAccel = f ? parseFloat(f) : 0, f = e("tangentialAccelVariance", a), d.tangentialAccelVar = f ? parseFloat(f) : 0, f = e("rotationIsDir", a).toLowerCase(), d.rotationIsDir = null != f && ("true" === f || "1" === f);
- else if (this.emitterMode == cc.ParticleSystem.MODE_RADIUS) d = this.modeB, d.startRadius = parseFloat(e("maxRadius", a)), d.startRadiusVar = parseFloat(e("maxRadiusVariance", a)), d.endRadius = parseFloat(e("minRadius", a)), d.endRadiusVar = 0, d.rotatePerSecond = parseFloat(e("rotatePerSecond", a)), d.rotatePerSecondVar = parseFloat(e("rotatePerSecondVariance", a));
- else return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"), !1;
- this.life = parseFloat(e("particleLifespan", a));
- this.lifeVar = parseFloat(e("particleLifespanVariance", a));
- this.emissionRate = this._totalParticles / this.life;
- if (!this._batchNode)
- if (this._opacityModifyRGB = !1, d = e("textureFileName", a), d = cc.path.changeBasename(this._plistFile, d), f = cc.textureCache.textureForKey(d)) this.setTexture(f);
- else if (e = e("textureImageData", a), !e || 0 === e.length) {
- f = cc.textureCache.addImage(d);
- if (!f) return !1;
- this.setTexture(f)
- } else {
- e = cc.unzipBase64AsArray(e, 1);
- if (!e) return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"), !1;
- f = cc.getImageFormatByData(e);
- if (f !== cc.FMT_TIFF && f !== cc.FMT_PNG) return cc.log("cc.ParticleSystem: unknown image format with Data"), !1;
- var g = cc.newElement("canvas");
- f === cc.FMT_PNG ? (new cc.PNGReader(e)).render(g) : cc.tiffReader.parseTIFF(e, g);
- cc.textureCache.cacheImage(d, g);
- (e = cc.textureCache.textureForKey(d)) || cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture");
- this.setTexture(e)
- }
- d = !0
- }
- return d
- },
- initWithTotalParticles: function(a) {
- this._totalParticles = a;
- var c, d = this._particles;
- for (c = d.length = 0; c < a; c++) d[c] = new cc.Particle;
- if (!d) return cc.log("Particle system: not enough memory"), !1;
- this._allocatedParticles = a;
- if (this._batchNode)
- for (c = 0; c < this._totalParticles; c++) d[c].atlasIndex = c;
- this._isActive = !0;
- this._blendFunc.src = cc.BLEND_SRC;
- this._blendFunc.dst = cc.BLEND_DST;
- this.positionType = cc.ParticleSystem.TYPE_FREE;
- this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
- this._transformSystemDirty = this.autoRemoveOnFinish = !1;
- this.scheduleUpdateWithPriority(1);
- if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
- if (!this._allocMemory()) return !1;
- this.initIndices();
- this._setupVBO();
- this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
- }
- return !0
- },
- destroyParticleSystem: function() {
- this.unscheduleUpdate()
- },
- addParticle: function() {
- if (this.isFull()) return !1;
- var a, c = this._particles;
- cc._renderType === cc._RENDER_TYPE_CANVAS ? this.particleCount < c.length ? a = c[this.particleCount] : (a = new cc.Particle, c.push(a)) : a = c[this.particleCount];
- this.initParticle(a);
- ++this.particleCount;
- return !0
- },
- initParticle: function(a) {
- var c = cc.randomMinus1To1;
- a.timeToLive = this.life + this.lifeVar * c();
- a.timeToLive = Math.max(0, a.timeToLive);
- a.pos.x = this._sourcePosition.x + this._posVar.x * c();
- a.pos.y = this._sourcePosition.y + this._posVar.y * c();
- var d, e;
- d = this._startColor;
- var f = this._startColorVar,
- g = this._endColor;
- e = this._endColorVar;
- cc._renderType === cc._RENDER_TYPE_CANVAS ? (d = cc.color(cc.clampf(d.r + f.r * c(), 0, 255), cc.clampf(d.g + f.g * c(), 0, 255), cc.clampf(d.b + f.b * c(), 0, 255), cc.clampf(d.a + f.a * c(), 0, 255)), e = cc.color(cc.clampf(g.r + e.r * c(), 0, 255), cc.clampf(g.g + e.g * c(), 0, 255), cc.clampf(g.b + e.b * c(), 0, 255), cc.clampf(g.a + e.a * c(), 0, 255))) : (d = {
- r: cc.clampf(d.r + f.r * c(), 0, 255),
- g: cc.clampf(d.g + f.g * c(), 0, 255),
- b: cc.clampf(d.b + f.b * c(), 0, 255),
- a: cc.clampf(d.a + f.a * c(), 0, 255)
- }, e = {
- r: cc.clampf(g.r + e.r * c(), 0, 255),
- g: cc.clampf(g.g + e.g * c(), 0, 255),
- b: cc.clampf(g.b + e.b * c(), 0, 255),
- a: cc.clampf(g.a + e.a * c(), 0, 255)
- });
- a.color = d;
- f = a.deltaColor;
- g = a.timeToLive;
- f.r = (e.r - d.r) / g;
- f.g = (e.g - d.g) / g;
- f.b = (e.b - d.b) / g;
- f.a = (e.a - d.a) / g;
- d = this.startSize + this.startSizeVar * c();
- d = Math.max(0, d);
- a.size = d;
- this.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE ? a.deltaSize = 0 : (e = this.endSize + this.endSizeVar * c(), e = Math.max(0, e), a.deltaSize = (e - d) / g);
- d = this.startSpin + this.startSpinVar * c();
- e = this.endSpin + this.endSpinVar * c();
- a.rotation = d;
- a.deltaRotation = (e - d) / g;
- this.positionType == cc.ParticleSystem.TYPE_FREE ? a.startPos = this.convertToWorldSpace(this._pointZeroForParticle) : this.positionType == cc.ParticleSystem.TYPE_RELATIVE && (a.startPos.x = this._position.x, a.startPos.y = this._position.y);
- d = cc.degreesToRadians(this.angle + this.angleVar * c());
- if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) g = this.modeA, e = a.modeA, f = g.speed + g.speedVar * c(), e.dir.x = Math.cos(d), e.dir.y = Math.sin(d), cc.pMultIn(e.dir, f), e.radialAccel = g.radialAccel + g.radialAccelVar * c(), e.tangentialAccel = g.tangentialAccel + g.tangentialAccelVar * c(), g.rotationIsDir && (a.rotation = -cc.radiansToDegrees(cc.pToAngle(e.dir)));
- else {
- e = this.modeB;
- a = a.modeB;
- var f = e.startRadius + e.startRadiusVar * c(),
- h = e.endRadius + e.endRadiusVar * c();
- a.radius = f;
- a.deltaRadius = e.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (h - f) / g;
- a.angle = d;
- a.degreesPerSecond = cc.degreesToRadians(e.rotatePerSecond + e.rotatePerSecondVar * c())
- }
- },
- stopSystem: function() {
- this._isActive = !1;
- this._elapsed = this.duration;
- this._emitCounter = 0
- },
- resetSystem: function() {
- this._isActive = !0;
- this._elapsed = 0;
- var a = this._particles;
- for (this._particleIdx = 0; this._particleIdx < this.particleCount; ++this._particleIdx) a[this._particleIdx].timeToLive = 0
- },
- isFull: function() {
- return this.particleCount >= this._totalParticles
- },
- updateQuadWithParticle: function(a, c) {
- var d = null;
- this._batchNode ? (d = this._batchNode.textureAtlas.quads[this.atlasIndex + a.atlasIndex], this._batchNode.textureAtlas.dirty = !0) : d = this._quads[this._particleIdx];
- var e, f, g, h;
- this._opacityModifyRGB ? (e = 0 | a.color.r * a.color.a / 255, f = 0 | a.color.g * a.color.a / 255, g = 0 | a.color.b * a.color.a / 255) : (e = 0 | a.color.r, f = 0 | a.color.g, g = 0 | a.color.b);
- h = 0 | a.color.a;
- var k = d.bl.colors;
- k.r = e;
- k.g = f;
- k.b = g;
- k.a = h;
- k = d.br.colors;
- k.r = e;
- k.g = f;
- k.b = g;
- k.a = h;
- k = d.tl.colors;
- k.r = e;
- k.g = f;
- k.b = g;
- k.a = h;
- k = d.tr.colors;
- k.r = e;
- k.g = f;
- k.b = g;
- k.a = h;
- e = a.size / 2;
- if (a.rotation) {
- f = -e;
- g = -e;
- h = c.x;
- var k = c.y,
- m = -cc.degreesToRadians(a.rotation),
- n = Math.cos(m),
- m = Math.sin(m);
- d.bl.vertices.x = f * n - g * m + h;
- d.bl.vertices.y = f * m + g * n + k;
- d.br.vertices.x = e * n - g * m + h;
- d.br.vertices.y = e * m + g * n + k;
- d.tl.vertices.x = f * n - e * m + h;
- d.tl.vertices.y = f * m + e * n + k;
- d.tr.vertices.x = e * n - e * m + h;
- d.tr.vertices.y = e * m + e * n + k
- } else d.bl.vertices.x = c.x - e, d.bl.vertices.y = c.y - e, d.br.vertices.x = c.x + e, d.br.vertices.y = c.y - e, d.tl.vertices.x = c.x - e, d.tl.vertices.y = c.y + e, d.tr.vertices.x = c.x + e, d.tr.vertices.y = c.y + e
- },
- postStep: function() {
- if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
- var a = cc._renderContext;
- a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
- a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW)
- }
- },
- update: function(a) {
- if (this._isActive && this.emissionRate) {
- var c = 1 / this.emissionRate;
- this.particleCount < this._totalParticles && (this._emitCounter += a);
- for (; this.particleCount < this._totalParticles && this._emitCounter > c;) this.addParticle(), this._emitCounter -= c;
- this._elapsed += a; - 1 != this.duration && this.duration < this._elapsed && this.stopSystem()
- }
- this._particleIdx = 0;
- c = cc.Particle.TemporaryPoints[0];
- this.positionType == cc.ParticleSystem.TYPE_FREE ? cc.pIn(c, this.convertToWorldSpace(this._pointZeroForParticle)) : this.positionType == cc.ParticleSystem.TYPE_RELATIVE && (c.x = this._position.x, c.y = this._position.y);
- if (this._visible) {
- for (var d = cc.Particle.TemporaryPoints[1], e = cc.Particle.TemporaryPoints[2], f = cc.Particle.TemporaryPoints[3], g = this._particles; this._particleIdx < this.particleCount;) {
- cc.pZeroIn(d);
- cc.pZeroIn(e);
- cc.pZeroIn(f);
- var h = g[this._particleIdx];
- h.timeToLive -= a;
- if (0 < h.timeToLive) {
- if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
- var k = f,
- m = d,
- n = e;
- h.pos.x || h.pos.y ? (cc.pIn(m, h.pos), cc.pNormalizeIn(m)) : cc.pZeroIn(m);
- cc.pIn(n, m);
- cc.pMultIn(m, h.modeA.radialAccel);
- var q = n.x;
- n.x = -n.y;
- n.y = q;
- cc.pMultIn(n, h.modeA.tangentialAccel);
- cc.pIn(k, m);
- cc.pAddIn(k, n);
- cc.pAddIn(k, this.modeA.gravity);
- cc.pMultIn(k, a);
- cc.pAddIn(h.modeA.dir, k);
- cc.pIn(k, h.modeA.dir);
- cc.pMultIn(k, a);
- cc.pAddIn(h.pos, k)
- } else k = h.modeB, k.angle += k.degreesPerSecond * a, k.radius += k.deltaRadius * a, h.pos.x = -Math.cos(k.angle) * k.radius, h.pos.y = -Math.sin(k.angle) * k.radius; if (!this._dontTint || cc._renderType === cc._RENDER_TYPE_WEBGL) h.color.r += 0 | h.deltaColor.r * a, h.color.g += 0 | h.deltaColor.g * a, h.color.b += 0 | h.deltaColor.b * a, h.color.a += 0 | h.deltaColor.a * a, h.isChangeColor = !0;
- h.size += h.deltaSize * a;
- h.size = Math.max(0, h.size);
- h.rotation += h.deltaRotation * a;
- k = d;
- this.positionType == cc.ParticleSystem.TYPE_FREE || this.positionType == cc.ParticleSystem.TYPE_RELATIVE ? (m = e, cc.pIn(m, c), cc.pSubIn(m, h.startPos), cc.pIn(k, h.pos), cc.pSubIn(k, m)) : cc.pIn(k, h.pos);
- this._batchNode && (k.x += this._position.x, k.y += this._position.y);
- cc._renderType == cc._RENDER_TYPE_WEBGL ? this.updateQuadWithParticle(h, k) : cc.pIn(h.drawPos, k);
- ++this._particleIdx
- } else if (h = h.atlasIndex, this._particleIdx !== this.particleCount - 1 && (k = g[this._particleIdx], g[this._particleIdx] = g[this.particleCount - 1], g[this.particleCount - 1] = k), this._batchNode && (this._batchNode.disableParticle(this.atlasIndex + h), g[this.particleCount - 1].atlasIndex = h), --this.particleCount, 0 == this.particleCount && this.autoRemoveOnFinish) {
- this.unscheduleUpdate();
- this._parent.removeChild(this, !0);
- return
- }
- }
- this._transformSystemDirty = !1
- }
- this._batchNode || this.postStep()
- },
- updateWithNoTime: function() {
- this.update(0)
- },
- _valueForKey: function(a, c) {
- if (c) {
- var d = c[a];
- return null != d ? d : ""
- }
- return ""
- },
- _updateBlendFunc: function() {
- if (this._batchNode) cc.log("Can't change blending functions when the particle is being batched");
- else {
- var a = this._texture;
- if (a && a instanceof cc.Texture2D) {
- this._opacityModifyRGB = !1;
- var c = this._blendFunc;
- c.src == cc.BLEND_SRC && c.dst == cc.BLEND_DST && (a.hasPremultipliedAlpha() ? this._opacityModifyRGB = !0 : (c.src = cc.SRC_ALPHA, c.dst = cc.ONE_MINUS_SRC_ALPHA))
- }
- }
- },
- clone: function() {
- var a = new cc.ParticleSystem;
- if (a.initWithTotalParticles(this.getTotalParticles())) {
- a.setAngle(this.getAngle());
- a.setAngleVar(this.getAngleVar());
- a.setDuration(this.getDuration());
- var c = this.getBlendFunc();
- a.setBlendFunc(c.src, c.dst);
- a.setStartColor(this.getStartColor());
- a.setStartColorVar(this.getStartColorVar());
- a.setEndColor(this.getEndColor());
- a.setEndColorVar(this.getEndColorVar());
- a.setStartSize(this.getStartSize());
- a.setStartSizeVar(this.getStartSizeVar());
- a.setEndSize(this.getEndSize());
- a.setEndSizeVar(this.getEndSizeVar());
- a.setPosition(cc.p(this.x, this.y));
- a.setPosVar(cc.p(this.getPosVar().x, this.getPosVar().y));
- a.setStartSpin(this.getStartSpin() || 0);
- a.setStartSpinVar(this.getStartSpinVar() || 0);
- a.setEndSpin(this.getEndSpin() || 0);
- a.setEndSpinVar(this.getEndSpinVar() || 0);
- a.setEmitterMode(this.getEmitterMode());
- this.getEmitterMode() == cc.ParticleSystem.MODE_GRAVITY ? (c = this.getGravity(), a.setGravity(cc.p(c.x, c.y)), a.setSpeed(this.getSpeed()), a.setSpeedVar(this.getSpeedVar()), a.setRadialAccel(this.getRadialAccel()), a.setRadialAccelVar(this.getRadialAccelVar()), a.setTangentialAccel(this.getTangentialAccel()), a.setTangentialAccelVar(this.getTangentialAccelVar())) : this.getEmitterMode() == cc.ParticleSystem.MODE_RADIUS && (a.setStartRadius(this.getStartRadius()), a.setStartRadiusVar(this.getStartRadiusVar()), a.setEndRadius(this.getEndRadius()), a.setEndRadiusVar(this.getEndRadiusVar()), a.setRotatePerSecond(this.getRotatePerSecond()), a.setRotatePerSecondVar(this.getRotatePerSecondVar()));
- a.setLife(this.getLife());
- a.setLifeVar(this.getLifeVar());
- a.setEmissionRate(this.getEmissionRate());
- if (!this.getBatchNode() && (a.setOpacityModifyRGB(this.isOpacityModifyRGB()), c = this.getTexture())) {
- var d = c.getContentSize();
- a.setTextureWithRect(c, cc.rect(0, 0, d.width, d.height))
- }
- }
- return a
- },
- setDisplayFrame: function(a) {
- var c = a.getOffsetInPixels();
- (0 != c.x || 0 != c.y) && cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");
- cc._renderType === cc._RENDER_TYPE_WEBGL && (!this._texture || a.getTexture()._webTextureObj != this._texture._webTextureObj) && this.setTexture(a.getTexture())
- },
- setTextureWithRect: function(a, c) {
- var d = this._texture;
- if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
- if ((!d || a._webTextureObj != d._webTextureObj) && d != a) this._texture = a, this._updateBlendFunc()
- } else if ((!d || a != d) && d != a) this._texture = a, this._updateBlendFunc();
- this._pointRect = c;
- this.initTexCoordsWithRect(c)
- },
- draw: function(a) {
- this._textureLoaded && !this._batchNode && (cc._renderType === cc._RENDER_TYPE_CANVAS ? this._drawForCanvas(a) : this._drawForWebGL(a), cc.g_NumberOfDraws++)
- },
- _drawForCanvas: function(a) {
- a = a || cc._renderContext;
- a.save();
- this.isBlendAdditive() ? a.globalCompositeOperation = "lighter" : a.globalCompositeOperation = "source-over";
- for (var c = this._texture.getHtmlElementObj(), d = 0; d < this.particleCount; d++) {
- var e = this._particles[d],
- f = 0 | 0.5 * e.size;
- if (this.drawMode == cc.ParticleSystem.TEXTURE_MODE) {
- if (c.width && c.height) {
- a.save();
- a.globalAlpha = e.color.a / 255;
- a.translate(0 | e.drawPos.x, -(0 | e.drawPos.y));
- var f = 4 * Math.floor(e.size / 4),
- g = this._pointRect.width,
- h = this._pointRect.height;
- a.scale(Math.max(1 / g * f, 1E-6), Math.max(1 / h * f, 1E-6));
- e.rotation && a.rotate(cc.degreesToRadians(e.rotation));
- a.translate(-(0 | g / 2), -(0 | h / 2));
- (e = e.isChangeColor ? this._changeTextureColor(c, e.color, this._pointRect) : c) && a.drawImage(e, 0, 0);
- a.restore()
- }
- } else a.save(), a.globalAlpha = e.color.a / 255, a.translate(0 | e.drawPos.x, -(0 | e.drawPos.y)), this.shapeType == cc.ParticleSystem.STAR_SHAPE ? (e.rotation && a.rotate(cc.degreesToRadians(e.rotation)), cc._drawingUtil.drawStar(a, f, e.color)) : cc._drawingUtil.drawColorBall(a, f, e.color), a.restore()
- }
- a.restore()
- },
- _changeTextureColor: function(a, c, d) {
- c.r |= 0;
- c.g |= 0;
- c.b |= 0;
- a.tintCache || (a.tintCache = document.createElement("canvas"), a.tintCache.width = a.width, a.tintCache.height = a.height);
- return cc.generateTintImageWithMultiply(a, c, d, a.tintCache)
- },
- _drawForWebGL: function(a) {
- this._texture && (a = a || cc._renderContext, this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBindTexture2D(this._texture), cc.glBlendFuncForParticle(this._blendFunc.src, this._blendFunc.dst), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 24, 16), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]), a.drawElements(a.TRIANGLES, 6 * this._particleIdx, a.UNSIGNED_SHORT, 0))
- },
- listenBackToForeground: function(a) {
- cc.TEXTURE_ATLAS_USE_VAO ? this._setupVBOandVAO() : this._setupVBO()
- },
- _setupVBOandVAO: function() {},
- _setupVBO: function() {
- if (cc._renderType != cc._RENDER_TYPE_CANVAS) {
- var a = cc._renderContext;
- this._buffersVBO[0] = a.createBuffer();
- a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
- a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
- this._buffersVBO[1] = a.createBuffer();
- a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
- a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
- }
- },
- _allocMemory: function() {
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) return !0;
- if (this._batchNode) return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"), !1;
- var a = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
- c = this._totalParticles,
- d = this._quads;
- d.length = 0;
- this._indices = new Uint16Array(6 * c);
- for (var e = new ArrayBuffer(a * c), f = 0; f < c; f++) d[f] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, e, f * a);
- if (!d || !this._indices) return cc.log("cocos2d: Particle system: not enough memory"), !1;
- this._quadsArrayBuffer = e;
- return !0
- }
- });
- _p = cc.ParticleSystem.prototype;
- cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes && (_p._changeTextureColor = function(a, c, d) {
- var e = cc.textureCache.getTextureColors(a);
- return e ? (e.tintCache || (e.tintCache = document.createElement("canvas"), e.tintCache.width = a.width, e.tintCache.height = a.height), cc.generateTintImage(a, e, c, d, e.tintCache), e.tintCache) : null
- });
- cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB);
- cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode);
- cc.defineGetterSetter(_p, "active", _p.isActive);
- cc.defineGetterSetter(_p, "sourcePos", _p.getSourcePosition, _p.setSourcePosition);
- cc.defineGetterSetter(_p, "posVar", _p.getPosVar, _p.setPosVar);
- cc.defineGetterSetter(_p, "gravity", _p.getGravity, _p.setGravity);
- cc.defineGetterSetter(_p, "speed", _p.getSpeed, _p.setSpeed);
- cc.defineGetterSetter(_p, "speedVar", _p.getSpeedVar, _p.setSpeedVar);
- cc.defineGetterSetter(_p, "tangentialAccel", _p.getTangentialAccel, _p.setTangentialAccel);
- cc.defineGetterSetter(_p, "tangentialAccelVar", _p.getTangentialAccelVar, _p.setTangentialAccelVar);
- cc.defineGetterSetter(_p, "radialAccel", _p.getRadialAccel, _p.setRadialAccel);
- cc.defineGetterSetter(_p, "radialAccelVar", _p.getRadialAccelVar, _p.setRadialAccelVar);
- cc.defineGetterSetter(_p, "rotationIsDir", _p.getRotationIsDir, _p.setRotationIsDir);
- cc.defineGetterSetter(_p, "startRadius", _p.getStartRadius, _p.setStartRadius);
- cc.defineGetterSetter(_p, "startRadiusVar", _p.getStartRadiusVar, _p.setStartRadiusVar);
- cc.defineGetterSetter(_p, "endRadius", _p.getEndRadius, _p.setEndRadius);
- cc.defineGetterSetter(_p, "endRadiusVar", _p.getEndRadiusVar, _p.setEndRadiusVar);
- cc.defineGetterSetter(_p, "rotatePerS", _p.getRotatePerSecond, _p.setRotatePerSecond);
- cc.defineGetterSetter(_p, "rotatePerSVar", _p.getRotatePerSecondVar, _p.setRotatePerSecondVar);
- cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor);
- cc.defineGetterSetter(_p, "startColorVar", _p.getStartColorVar, _p.setStartColorVar);
- cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor);
- cc.defineGetterSetter(_p, "endColorVar", _p.getEndColorVar, _p.setEndColorVar);
- cc.defineGetterSetter(_p, "totalParticles", _p.getTotalParticles, _p.setTotalParticles);
- cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
- cc.ParticleSystem.create = function(a) {
- return new cc.ParticleSystem(a)
- };
- cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create;
- cc.ParticleSystem.ModeA = function(a, c, d, e, f, g, h, k) {
- this.gravity = a ? a : cc.p(0, 0);
- this.speed = c || 0;
- this.speedVar = d || 0;
- this.tangentialAccel = e || 0;
- this.tangentialAccelVar = f || 0;
- this.radialAccel = g || 0;
- this.radialAccelVar = h || 0;
- this.rotationIsDir = k || !1
- };
- cc.ParticleSystem.ModeB = function(a, c, d, e, f, g) {
- this.startRadius = a || 0;
- this.startRadiusVar = c || 0;
- this.endRadius = d || 0;
- this.endRadiusVar = e || 0;
- this.rotatePerSecond = f || 0;
- this.rotatePerSecondVar = g || 0
- };
- cc.ParticleSystem.SHAPE_MODE = 0;
- cc.ParticleSystem.TEXTURE_MODE = 1;
- cc.ParticleSystem.STAR_SHAPE = 0;
- cc.ParticleSystem.BALL_SHAPE = 1;
- cc.ParticleSystem.DURATION_INFINITY = -1;
- cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
- cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
- cc.ParticleSystem.MODE_GRAVITY = 0;
- cc.ParticleSystem.MODE_RADIUS = 1;
- cc.ParticleSystem.TYPE_FREE = 0;
- cc.ParticleSystem.TYPE_RELATIVE = 1;
- cc.ParticleSystem.TYPE_GROUPED = 2;
- cc.ParticleFire = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 300 : 150)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(60), this.setSpeedVar(20), this.setAngle(90), this.setAngleVar(10), a = cc.director.getWinSize(), this.setPosition(a.width / 2, 60), this.setPosVar(cc.p(40, 20)), this.setLife(3), this.setLifeVar(0.25), this.setStartSize(54), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(194, 64, 31, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
- }
- });
- cc.ParticleFire.create = function() {
- return new cc.ParticleFire
- };
- cc.ParticleFireworks = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1500 : 150)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, -90)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(180), this.setSpeedVar(50), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setAngle(90), this.setAngleVar(20), this.setLife(3.5), this.setLifeVar(1), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 255)), this.setEndColor(cc.color(26, 26, 26, 51)), this.setEndColorVar(cc.color(26, 26, 26, 51)), this.setStartSize(8), this.setStartSizeVar(2), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleFireworks.create = function() {
- return new cc.ParticleFireworks
- };
- cc.ParticleSun = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 350 : 150)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setBlendAdditive(!0), this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(20), this.setSpeedVar(5), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(1), this.setLifeVar(0.5), this.setStartSize(30), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(194, 64, 31, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), !0) : !1
- }
- });
- cc.ParticleSun.create = function() {
- return new cc.ParticleSun
- };
- cc.ParticleGalaxy = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(60), this.setSpeedVar(10), this.setRadialAccel(-80), this.setRadialAccelVar(0), this.setTangentialAccel(80), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(37), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(31, 64, 194, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
- }
- });
- cc.ParticleGalaxy.create = function() {
- return new cc.ParticleGalaxy
- };
- cc.ParticleFlower = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 250 : 100)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(80), this.setSpeedVar(10), this.setRadialAccel(-60), this.setRadialAccelVar(0), this.setTangentialAccel(15), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(30), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 128)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
- }
- });
- cc.ParticleFlower.create = function() {
- return new cc.ParticleFlower
- };
- cc.ParticleMeteor = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 150 : 100)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(-200, 200)), this.setSpeed(15), this.setSpeedVar(5), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setTangentialAccel(0), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(2), this.setLifeVar(1), this.setStartSize(60), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(51, 102, 179)), this.setStartColorVar(cc.color(0, 0, 51, 26)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
- }
- });
- cc.ParticleMeteor.create = function() {
- return new cc.ParticleMeteor
- };
- cc.ParticleSpiral = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 500 : 100)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(150), this.setSpeedVar(0), this.setRadialAccel(-380), this.setRadialAccelVar(0), this.setTangentialAccel(45), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(0), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(12), this.setLifeVar(0), this.setStartSize(20), this.setStartSizeVar(0), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(128, 128, 128, 255)), this.setStartColorVar(cc.color(128, 128, 128, 0)), this.setEndColor(cc.color(128, 128, 128, 255)), this.setEndColorVar(cc.color(128, 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleSpiral.create = function() {
- return new cc.ParticleSpiral
- };
- cc.ParticleExplosion = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 300)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(0.1), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setSpeed(70), this.setSpeedVar(40), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setTangentialAccel(0), this.setTangentialAccelVar(0), this.setAngle(90), this.setAngleVar(360), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height / 2), this.setPosVar(cc.p(0, 0)), this.setLife(5), this.setLifeVar(2), this.setStartSize(15), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getDuration()), this.setStartColor(cc.color(179, 26, 51, 255)), this.setStartColorVar(cc.color(128, 128, 128, 0)), this.setEndColor(cc.color(128, 128, 128, 0)), this.setEndColorVar(cc.color(128, 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleExplosion.create = function() {
- return new cc.ParticleExplosion
- };
- cc.ParticleSmoke = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, 0)), this.setRadialAccel(0), this.setRadialAccelVar(0), this.setSpeed(25), this.setSpeedVar(10), this.setAngle(90), this.setAngleVar(5), a = cc.director.getWinSize(), this.setPosition(a.width / 2, 0), this.setPosVar(cc.p(20, 0)), this.setLife(4), this.setLifeVar(1), this.setStartSize(60), this.setStartSizeVar(10), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(this.getTotalParticles() / this.getLife()), this.setStartColor(cc.color(204, 204, 204, 255)), this.setStartColorVar(cc.color(5, 5, 5, 0)), this.setEndColor(cc.color(0, 0, 0, 255)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleSmoke.create = function() {
- return new cc.ParticleSmoke
- };
- cc.ParticleSnow = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 250)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(0, -1)), this.setSpeed(5), this.setSpeedVar(1), this.setRadialAccel(0), this.setRadialAccelVar(1), this.setTangentialAccel(0), this.setTangentialAccelVar(1), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height + 10), this.setPosVar(cc.p(a.width / 2, 0)), this.setAngle(-90), this.setAngleVar(5), this.setLife(45), this.setLifeVar(15), this.setStartSize(10), this.setStartSizeVar(5), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(10), this.setStartColor(cc.color(255, 255, 255, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(255, 255, 255, 0)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleSnow.create = function() {
- return new cc.ParticleSnow
- };
- cc.ParticleRain = cc.ParticleSystem.extend({
- ctor: function() {
- cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1E3 : 300)
- },
- initWithTotalParticles: function(a) {
- return cc.ParticleSystem.prototype.initWithTotalParticles.call(this, a) ? (this.setDuration(cc.ParticleSystem.DURATION_INFINITY), this.setEmitterMode(cc.ParticleSystem.MODE_GRAVITY), this.setGravity(cc.p(10, -10)), this.setRadialAccel(0), this.setRadialAccelVar(1), this.setTangentialAccel(0), this.setTangentialAccelVar(1), this.setSpeed(130), this.setSpeedVar(30), this.setAngle(-90), this.setAngleVar(5), a = cc.director.getWinSize(), this.setPosition(a.width / 2, a.height), this.setPosVar(cc.p(a.width / 2, 0)), this.setLife(4.5), this.setLifeVar(0), this.setStartSize(4), this.setStartSizeVar(2), this.setEndSize(cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE), this.setEmissionRate(20), this.setStartColor(cc.color(179, 204, 255, 255)), this.setStartColorVar(cc.color(0, 0, 0, 0)), this.setEndColor(cc.color(179, 204, 255, 128)), this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1
- }
- });
- cc.ParticleRain.create = function() {
- return new cc.ParticleRain
- };
- cc.PARTICLE_DEFAULT_CAPACITY = 500;
- cc.ParticleBatchNode = cc.Node.extend({
- textureAtlas: null,
- TextureProtocol: !0,
- _blendFunc: null,
- _className: "ParticleBatchNode",
- ctor: function(a, c) {
- cc.Node.prototype.ctor.call(this);
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- "string" == typeof a ? this.init(a, c) : a instanceof cc.Texture2D && this.initWithTexture(a, c)
- },
- initWithTexture: function(a, c) {
- this.textureAtlas = new cc.TextureAtlas;
- this.textureAtlas.initWithTexture(a, c);
- this._children.length = 0;
- cc._renderType === cc._RENDER_TYPE_WEBGL && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
- return !0
- },
- initWithFile: function(a, c) {
- var d = cc.textureCache.addImage(a);
- return this.initWithTexture(d, c)
- },
- init: function(a, c) {
- var d = cc.TextureCache.getInstance().addImage(a);
- return this.initWithTexture(d, c)
- },
- addChild: function(a, c, d) {
- if (!a) throw "cc.ParticleBatchNode.addChild() : child should be non-null";
- if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children";
- c = null == c ? a.zIndex : c;
- d = null == d ? a.tag : d;
- if (a.getTexture() != this.textureAtlas.texture) throw "cc.ParticleSystem.addChild() : the child is not using the same texture id";
- var e = a.getBlendFunc();
- if (0 === this._children.length) this.setBlendFunc(e);
- else if (e.src != this._blendFunc.src || e.dst != this._blendFunc.dst) {
- cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function");
- return
- }
- c = this._addChildHelper(a, c, d);
- d = 0;
- 0 != c ? (c = this._children[c - 1], d = c.getAtlasIndex() + c.getTotalParticles()) : d = 0;
- this.insertChild(a, d);
- a.setBatchNode(this)
- },
- insertChild: function(a, c) {
- var d = a.getTotalParticles(),
- e = this.textureAtlas,
- f = e.totalQuads;
- a.setAtlasIndex(c);
- f + d > e.getCapacity() && (this._increaseAtlasCapacityTo(f + d), e.fillWithEmptyQuadsFromIndex(e.getCapacity() - d, d));
- a.getAtlasIndex() + d != f && e.moveQuadsFromIndex(c, c + d);
- e.increaseTotalQuadsWith(d);
- this._updateAllAtlasIndexes()
- },
- removeChild: function(a, c) {
- if (null != a) {
- if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children";
- if (-1 == this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");
- else {
- cc.Node.prototype.removeChild.call(this, a, c);
- var d = this.textureAtlas;
- d.removeQuadsAtIndex(a.getAtlasIndex(), a.getTotalParticles());
- d.fillWithEmptyQuadsFromIndex(d.totalQuads, a.getTotalParticles());
- a.setBatchNode(null);
- this._updateAllAtlasIndexes()
- }
- }
- },
- reorderChild: function(a, c) {
- if (!a) throw "cc.ParticleBatchNode.reorderChild(): child should be non-null";
- if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children";
- if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");
- else if (c != a.zIndex) {
- if (1 < this._children.length) {
- var d = this._getCurrentIndex(a, c);
- if (d.oldIndex != d.newIndex) {
- this._children.splice(d.oldIndex, 1);
- this._children.splice(d.newIndex, 0, a);
- d = a.getAtlasIndex();
- this._updateAllAtlasIndexes();
- for (var e = 0, f = this._children, g = 0; g < f.length; g++)
- if (f[g] == a) {
- e = a.getAtlasIndex();
- break
- }
- this.textureAtlas.moveQuadsFromIndex(d, a.getTotalParticles(), e);
- a.updateWithNoTime()
- }
- }
- a._setLocalZOrder(c)
- }
- },
- removeChildAtIndex: function(a, c) {
- this.removeChild(this._children[i], c)
- },
- removeAllChildren: function(a) {
- for (var c = this._children, d = 0; d < c.length; d++) c[d].setBatchNode(null);
- cc.Node.prototype.removeAllChildren.call(this, a);
- this.textureAtlas.removeAllQuads()
- },
- disableParticle: function(a) {
- a = this.textureAtlas.quads[a];
- a.br.vertices.x = a.br.vertices.y = a.tr.vertices.x = a.tr.vertices.y = a.tl.vertices.x = a.tl.vertices.y = a.bl.vertices.x = a.bl.vertices.y = 0;
- this.textureAtlas._setDirty(!0)
- },
- draw: function(a) {
- cc._renderType !== cc._RENDER_TYPE_CANVAS && 0 != this.textureAtlas.totalQuads && (cc.nodeDrawSetup(this), cc.glBlendFuncForParticle(this._blendFunc.src, this._blendFunc.dst), this.textureAtlas.drawQuads())
- },
- getTexture: function() {
- return this.textureAtlas.texture
- },
- setTexture: function(a) {
- this.textureAtlas.texture = a;
- var c = this._blendFunc;
- a && (!a.hasPremultipliedAlpha() && c.src == cc.BLEND_SRC && c.dst == cc.BLEND_DST) && (c.src = cc.SRC_ALPHA, c.dst = cc.ONE_MINUS_SRC_ALPHA)
- },
- setBlendFunc: function(a, c) {
- void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.src = c)
- },
- getBlendFunc: function() {
- return {
- src: this._blendFunc.src,
- dst: this._blendFunc.dst
- }
- },
- visit: function(a) {
- cc._renderType !== cc._RENDER_TYPE_CANVAS && this._visible && (cc.kmGLPushMatrix(), this.grid && this.grid.isActive() && (this.grid.beforeDraw(), this.transformAncestors()), this.transform(a), this.draw(a), this.grid && this.grid.isActive() && this.grid.afterDraw(this), cc.kmGLPopMatrix())
- },
- _updateAllAtlasIndexes: function() {
- for (var a = 0, c = this._children, d = 0; d < c.length; d++) {
- var e = c[d];
- e.setAtlasIndex(a);
- a += e.getTotalParticles()
- }
- },
- _increaseAtlasCapacityTo: function(a) {
- cc.log("cocos2d: cc.ParticleBatchNode: resizing TextureAtlas capacity from [" + this.textureAtlas.getCapacity() + "] to [" + a + "].");
- this.textureAtlas.resizeCapacity(a) || cc.log("cc.ParticleBatchNode._increaseAtlasCapacityTo() : WARNING: Not enough memory to resize the atlas")
- },
- _searchNewPositionInChildrenForZ: function(a) {
- for (var c = this._children, d = c.length, e = 0; e < d; e++)
- if (c[e].zIndex > a) return e;
- return d
- },
- _getCurrentIndex: function(a, c) {
- for (var d = !1, e = !1, f = 0, g = 0, h = 0, k = this._children, m = k.length, n = 0; n < m; n++) {
- var q = k[n];
- if (q.zIndex > c && !e && (f = n, e = !0, d && e)) break;
- if (a == q && (g = n, d = !0, e || (h = -1), d && e)) break
- }
- e || (f = m);
- return {
- newIndex: f + h,
- oldIndex: g
- }
- },
- _addChildHelper: function(a, c, d) {
- if (!a) throw "cc.ParticleBatchNode._addChildHelper(): child should be non-null";
- if (a.parent) return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"), null;
- this._children || (this._children = []);
- var e = this._searchNewPositionInChildrenForZ(c);
- this._children.splice(e, 0, a);
- a.tag = d;
- a._setLocalZOrder(c);
- a.parent = this;
- this._running && (a.onEnter(), a.onEnterTransitionDidFinish());
- return e
- },
- _updateBlendFunc: function() {
- this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
- },
- getTextureAtlas: function() {
- return this.textureAtlas
- },
- setTextureAtlas: function(a) {
- this.textureAtlas = a
- }
- });
- _p = cc.ParticleBatchNode.prototype;
- cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
- cc.ParticleBatchNode.create = function(a, c) {
- return new cc.ParticleBatchNode(a, c)
- };
- cc.IMEKeyboardNotificationInfo = function(a, c, d) {
- this.begin = a || cc.rect(0, 0, 0, 0);
- this.end = c || cc.rect(0, 0, 0, 0);
- this.duration = d || 0
- };
- cc.IMEDelegate = cc.Class.extend({
- ctor: function() {
- cc.imeDispatcher.addDelegate(this)
- },
- removeDelegate: function() {
- cc.imeDispatcher.removeDelegate(this)
- },
- attachWithIME: function() {
- return cc.imeDispatcher.attachDelegateWithIME(this)
- },
- detachWithIME: function() {
- return cc.imeDispatcher.detachDelegateWithIME(this)
- },
- canAttachWithIME: function() {
- return !1
- },
- didAttachWithIME: function() {},
- canDetachWithIME: function() {
- return !1
- },
- didDetachWithIME: function() {},
- insertText: function(a, c) {},
- deleteBackward: function() {},
- getContentText: function() {
- return ""
- },
- keyboardWillShow: function(a) {},
- keyboardDidShow: function(a) {},
- keyboardWillHide: function(a) {},
- keyboardDidHide: function(a) {}
- });
- cc.IMEDispatcher = cc.Class.extend({
- _domInputControl: null,
- impl: null,
- _currentInputString: "",
- _lastClickPosition: null,
- ctor: function() {
- this.impl = new cc.IMEDispatcher.Impl;
- this._lastClickPosition = cc.p(0, 0)
- },
- init: function() {
- if (!cc.sys.isMobile) {
- this._domInputControl = cc.$("#imeDispatcherInput");
- this._domInputControl || (this._domInputControl = cc.$new("input"), this._domInputControl.setAttribute("type", "text"), this._domInputControl.setAttribute("id", "imeDispatcherInput"), this._domInputControl.resize(0, 0), this._domInputControl.translates(0, 0), this._domInputControl.style.opacity = "0", this._domInputControl.style.fontSize = "1px", this._domInputControl.setAttribute("tabindex", 2), this._domInputControl.style.position = "absolute", this._domInputControl.style.top = 0, this._domInputControl.style.left = 0, document.body.appendChild(this._domInputControl));
- var a = this;
- cc._addEventListener(this._domInputControl, "input", function() {
- a._processDomInputString(a._domInputControl.value)
- }, !1);
- cc._addEventListener(this._domInputControl, "keydown", function(c) {
- c.keyCode === cc.KEY.tab ? (c.stopPropagation(), c.preventDefault()) : c.keyCode == cc.KEY.enter && (a.dispatchInsertText("\n", 1), c.stopPropagation(), c.preventDefault())
- }, !1);
- /msie/i.test(navigator.userAgent) && cc._addEventListener(this._domInputControl, "keyup", function(c) {
- c.keyCode == cc.KEY.backspace && a._processDomInputString(a._domInputControl.value)
- }, !1);
- cc._addEventListener(window, "mousedown", function(c) {
- var d = c.pageY || 0;
- a._lastClickPosition.x = c.pageX || 0;
- a._lastClickPosition.y = d
- }, !1)
- }
- },
- _processDomInputString: function(a) {
- var c, d;
- c = this._currentInputString.length < a.length ? this._currentInputString.length : a.length;
- for (d = 0; d < c && a[d] === this._currentInputString[d]; d++);
- var e = this._currentInputString.length - d,
- f = a.length - d;
- for (c = 0; c < e; c++) this.dispatchDeleteBackward();
- for (c = 0; c < f; c++) this.dispatchInsertText(a[d + c], 1);
- this._currentInputString = a
- },
- dispatchInsertText: function(a, c) {
- this.impl && a && !(0 >= c) && this.impl._delegateWithIme && this.impl._delegateWithIme.insertText(a, c)
- },
- dispatchDeleteBackward: function() {
- this.impl && this.impl._delegateWithIme && this.impl._delegateWithIme.deleteBackward()
- },
- getContentText: function() {
- if (this.impl && this.impl._delegateWithIme) {
- var a = this.impl._delegateWithIme.getContentText();
- return a ? a : ""
- }
- return ""
- },
- dispatchKeyboardWillShow: function(a) {
- if (this.impl)
- for (var c = 0; c < this.impl._delegateList.length; c++) {
- var d = this.impl._delegateList[c];
- d && d.keyboardWillShow(a)
- }
- },
- dispatchKeyboardDidShow: function(a) {
- if (this.impl)
- for (var c = 0; c < this.impl._delegateList.length; c++) {
- var d = this.impl._delegateList[c];
- d && d.keyboardDidShow(a)
- }
- },
- dispatchKeyboardWillHide: function(a) {
- if (this.impl)
- for (var c = 0; c < this.impl._delegateList.length; c++) {
- var d = this.impl._delegateList[c];
- d && d.keyboardWillHide(a)
- }
- },
- dispatchKeyboardDidHide: function(a) {
- if (this.impl)
- for (var c = 0; c < this.impl._delegateList.length; c++) {
- var d = this.impl._delegateList[c];
- d && d.keyboardDidHide(a)
- }
- },
- addDelegate: function(a) {
- a && this.impl && (-1 < this.impl._delegateList.indexOf(a) || this.impl._delegateList.splice(0, 0, a))
- },
- attachDelegateWithIME: function(a) {
- if (!this.impl || !a || -1 == this.impl._delegateList.indexOf(a)) return !1;
- if (this.impl._delegateWithIme) {
- if (!this.impl._delegateWithIme.canDetachWithIME() || !a.canAttachWithIME()) return !1;
- var c = this.impl._delegateWithIme;
- this.impl._delegateWithIme = null;
- c.didDetachWithIME();
- this._focusDomInput(a);
- return !0
- }
- if (!a.canAttachWithIME()) return !1;
- this._focusDomInput(a);
- return !0
- },
- _focusDomInput: function(a) {
- cc.sys.isMobile ? (this.impl._delegateWithIme = a, a.didAttachWithIME(), this._currentInputString = a.string || "", a = prompt("please enter your word:", this._currentInputString), null != a && this._processDomInputString(a), this.dispatchInsertText("\n", 1)) : (this.impl._delegateWithIme = a, this._currentInputString = a.string || "", a.didAttachWithIME(), this._domInputControl.focus(), this._domInputControl.value = this._currentInputString, this._domInputControlTranslate())
- },
- _domInputControlTranslate: function() {
- /msie/i.test(navigator.userAgent) ? (this._domInputControl.style.left = this._lastClickPosition.x + "px", this._domInputControl.style.top = this._lastClickPosition.y + "px") : this._domInputControl.translates(this._lastClickPosition.x, this._lastClickPosition.y)
- },
- detachDelegateWithIME: function(a) {
- if (!this.impl || !a || this.impl._delegateWithIme != a || !a.canDetachWithIME()) return !1;
- this.impl._delegateWithIme = null;
- a.didDetachWithIME();
- cc._canvas.focus();
- return !0
- },
- removeDelegate: function(a) {
- this.impl && a && -1 != this.impl._delegateList.indexOf(a) && (this.impl._delegateWithIme && a == this.impl._delegateWithIme && (this.impl._delegateWithIme = null), cc.arrayRemoveObject(this.impl._delegateList, a))
- },
- processKeycode: function(a) {
- 32 > a ? a == cc.KEY.backspace ? this.dispatchDeleteBackward() : a == cc.KEY.enter && this.dispatchInsertText("\n", 1) : 255 > a && this.dispatchInsertText(String.fromCharCode(a), 1)
- }
- });
- cc.IMEDispatcher.Impl = cc.Class.extend({
- _delegateWithIme: null,
- _delegateList: null,
- ctor: function() {
- this._delegateList = []
- },
- findDelegate: function(a) {
- for (var c = 0; c < this._delegateList.length; c++)
- if (this._delegateList[c] == a) return c;
- return null
- }
- });
- cc.imeDispatcher = new cc.IMEDispatcher;
- document.body ? cc.imeDispatcher.init() : cc._addEventListener(window, "load", function() {
- cc.imeDispatcher.init()
- }, !1);
- cc.TextFieldDelegate = cc.Class.extend({
- onTextFieldAttachWithIME: function(a) {
- return !1
- },
- onTextFieldDetachWithIME: function(a) {
- return !1
- },
- onTextFieldInsertText: function(a, c, d) {
- return !1
- },
- onTextFieldDeleteBackward: function(a, c, d) {
- return !1
- },
- onDraw: function(a) {
- return !1
- }
- });
- cc.TextFieldTTF = cc.LabelTTF.extend({
- delegate: null,
- colorSpaceHolder: null,
- _lens: null,
- _inputText: "",
- _placeHolder: "",
- _charCount: 0,
- _className: "TextFieldTTF",
- ctor: function(a, c, d, e, f) {
- this.colorSpaceHolder = cc.color(127, 127, 127);
- cc.imeDispatcher.addDelegate(this);
- cc.LabelTTF.prototype.ctor.call(this);
- void 0 !== f ? (this.initWithPlaceHolder("", c, d, e, f), a && this.setPlaceHolder(a)) : void 0 === e && void 0 !== d && (this.initWithString("", c, d), a && this.setPlaceHolder(a))
- },
- getDelegate: function() {
- return this.delegate
- },
- setDelegate: function(a) {
- this.delegate = a
- },
- getCharCount: function() {
- return this._charCount
- },
- getColorSpaceHolder: function() {
- return this.colorSpaceHolder
- },
- setColorSpaceHolder: function(a) {
- this.colorSpaceHolder = a
- },
- initWithPlaceHolder: function(a, c, d, e, f) {
- switch (arguments.length) {
- case 5:
- return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, e, f, c, d);
- case 3:
- return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, arguments[1], arguments[2]);
- default:
- throw "Argument must be non-nil ";
- }
- },
- setString: function(a) {
- this._inputText = (a = String(a)) || "";
- this._inputText.length ? cc.LabelTTF.prototype.setString.call(this, this._inputText) : cc.LabelTTF.prototype.setString.call(this, this._placeHolder);
- this._charCount = this._inputText.length
- },
- getString: function() {
- return this._inputText
- },
- setPlaceHolder: function(a) {
- this._placeHolder = a || "";
- this._inputText.length || cc.LabelTTF.prototype.setString.call(this, this._placeHolder)
- },
- getPlaceHolder: function() {
- return this._placeHolder
- },
- draw: function(a) {
- a = a || cc._renderContext;
- if (!this.delegate || !this.delegate.onDraw(this))
- if (this._inputText && 0 < this._inputText.length) cc.LabelTTF.prototype.draw.call(this, a);
- else {
- var c = this.color;
- this.color = this.colorSpaceHolder;
- cc._renderType === cc._RENDER_TYPE_CANVAS && this._updateTexture();
- cc.LabelTTF.prototype.draw.call(this, a);
- this.color = c
- }
- },
- visit: function(a) {
- this._super(a)
- },
- attachWithIME: function() {
- return cc.imeDispatcher.attachDelegateWithIME(this)
- },
- detachWithIME: function() {
- return cc.imeDispatcher.detachDelegateWithIME(this)
- },
- canAttachWithIME: function() {
- return this.delegate ? !this.delegate.onTextFieldAttachWithIME(this) : !0
- },
- didAttachWithIME: function() {},
- canDetachWithIME: function() {
- return this.delegate ? !this.delegate.onTextFieldDetachWithIME(this) : !0
- },
- didDetachWithIME: function() {},
- deleteBackward: function() {
- var a = this._inputText.length;
- if (0 != a && (!this.delegate || !this.delegate.onTextFieldDeleteBackward(this, this._inputText[a - 1], 1))) 1 >= a ? (this._inputText = "", this._charCount = 0, cc.LabelTTF.prototype.setString.call(this, this._placeHolder)) : this.string = this._inputText.substring(0, a - 1)
- },
- removeDelegate: function() {
- cc.imeDispatcher.removeDelegate(this)
- },
- insertText: function(a, c) {
- var d = a,
- e = d.indexOf("\n"); - 1 < e && (d = d.substring(0, e));
- if (0 < d.length) {
- if (this.delegate && this.delegate.onTextFieldInsertText(this, d, d.length)) return;
- d = this._inputText + d;
- this._charCount = d.length;
- this.string = d
- } - 1 != e && (!this.delegate || !this.delegate.onTextFieldInsertText(this, "\n", 1)) && this.detachWithIME()
- },
- getContentText: function() {
- return this._inputText
- },
- keyboardWillShow: function(a) {},
- keyboardDidShow: function(a) {},
- keyboardWillHide: function(a) {},
- keyboardDidHide: function(a) {}
- });
- _p = cc.TextFieldTTF.prototype;
- cc.defineGetterSetter(_p, "charCount", _p.getCharCount);
- cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
- cc.TextFieldTTF.create = function(a, c, d, e, f) {
- return new cc.TextFieldTTF(a, c, d, e, f)
- };
- cc._globalFontSize = cc.ITEM_SIZE;
- cc._globalFontName = "Arial";
- cc._globalFontNameRelease = !1;
- cc.MenuItem = cc.Node.extend({
- _enabled: !1,
- _target: null,
- _callback: null,
- _isSelected: !1,
- _className: "MenuItem",
- ctor: function(a, c) {
- var d = cc.Node.prototype;
- d.ctor.call(this);
- this._callback = this._target = null;
- this._enabled = this._isSelected = !1;
- d.setAnchorPoint.call(this, 0.5, 0.5);
- this._target = c || null;
- if (this._callback = a || null) this._enabled = !0
- },
- isSelected: function() {
- return this._isSelected
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- },
- setTarget: function(a, c) {
- this._target = c;
- this._callback = a
- },
- isEnabled: function() {
- return this._enabled
- },
- setEnabled: function(a) {
- this._enabled = a
- },
- initWithCallback: function(a, c) {
- this.anchorY = this.anchorX = 0.5;
- this._target = c;
- this._callback = a;
- this._enabled = !0;
- this._isSelected = !1;
- return !0
- },
- rect: function() {
- var a = this._position,
- c = this._contentSize,
- d = this._anchorPoint;
- return cc.rect(a.x - c.width * d.x, a.y - c.height * d.y, c.width, c.height)
- },
- selected: function() {
- this._isSelected = !0
- },
- unselected: function() {
- this._isSelected = !1
- },
- setCallback: function(a, c) {
- this._target = c;
- this._callback = a
- },
- activate: function() {
- if (this._enabled) {
- var a = this._target,
- c = this._callback;
- if (c)
- if (a && "string" == typeof c) a[c](this);
- else a && "function" == typeof c ? c.call(a, this) : c(this)
- }
- }
- });
- _p = cc.MenuItem.prototype;
- cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
- cc.MenuItem.create = function(a, c) {
- return new cc.MenuItem(a, c)
- };
- cc.MenuItemLabel = cc.MenuItem.extend({
- _disabledColor: null,
- _label: null,
- _orginalScale: 0,
- _colorBackup: null,
- ctor: function(a, c, d) {
- cc.MenuItem.prototype.ctor.call(this, c, d);
- this._label = this._disabledColor = null;
- this._orginalScale = 0;
- this._colorBackup = null;
- a && (this._originalScale = 1, this._colorBackup = cc.color.WHITE, this._disabledColor = cc.color(126, 126, 126), this.setLabel(a), this.cascadeOpacity = this.cascadeColor = !0)
- },
- getDisabledColor: function() {
- return this._disabledColor
- },
- setDisabledColor: function(a) {
- this._disabledColor = a
- },
- getLabel: function() {
- return this._label
- },
- setLabel: function(a) {
- a && (this.addChild(a), a.anchorX = 0, a.anchorY = 0, this.width = a.width, this.height = a.height);
- this._label && this.removeChild(this._label, !0);
- this._label = a
- },
- setEnabled: function(a) {
- if (this._enabled != a) {
- var c = this._label;
- a ? c.color = this._colorBackup : (this._colorBackup = c.color, c.color = this._disabledColor)
- }
- cc.MenuItem.prototype.setEnabled.call(this, a)
- },
- setOpacity: function(a) {
- this._label.opacity = a
- },
- getOpacity: function() {
- return this._label.opacity
- },
- setColor: function(a) {
- this._label.color = a
- },
- getColor: function() {
- return this._label.color
- },
- initWithLabel: function(a, c, d) {
- this.initWithCallback(c, d);
- this._originalScale = 1;
- this._colorBackup = cc.color.WHITE;
- this._disabledColor = cc.color(126, 126, 126);
- this.setLabel(a);
- return this.cascadeOpacity = this.cascadeColor = !0
- },
- setString: function(a) {
- this._label.string = a;
- this.width = this._label.width;
- this.height = this._label.height
- },
- getString: function() {
- return this._label.string
- },
- activate: function() {
- this._enabled && (this.stopAllActions(), this.scale = this._originalScale, cc.MenuItem.prototype.activate.call(this))
- },
- selected: function() {
- if (this._enabled) {
- cc.MenuItem.prototype.selected.call(this);
- var a = this.getActionByTag(cc.ZOOM_ACTION_TAG);
- a ? this.stopAction(a) : this._originalScale = this.scale;
- a = cc.ScaleTo.create(0.1, 1.2 * this._originalScale);
- a.setTag(cc.ZOOM_ACTION_TAG);
- this.runAction(a)
- }
- },
- unselected: function() {
- if (this._enabled) {
- cc.MenuItem.prototype.unselected.call(this);
- this.stopActionByTag(cc.ZOOM_ACTION_TAG);
- var a = cc.ScaleTo.create(0.1, this._originalScale);
- a.setTag(cc.ZOOM_ACTION_TAG);
- this.runAction(a)
- }
- }
- });
- _p = cc.MenuItemLabel.prototype;
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
- cc.defineGetterSetter(_p, "disabledColor", _p.getDisabledColor, _p.setDisabledColor);
- cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel);
- cc.MenuItemLabel.create = function(a, c, d) {
- return new cc.MenuItemLabel(a, c, d)
- };
- cc.MenuItemAtlasFont = cc.MenuItemLabel.extend({
- ctor: function(a, c, d, e, f, g, h) {
- var k;
- a && 0 < a.length && (k = cc.LabelAtlas.create(a, c, d, e, f));
- cc.MenuItemLabel.prototype.ctor.call(this, k, g, h)
- },
- initWithString: function(a, c, d, e, f, g, h) {
- if (!a || 0 == a.length) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0";
- var k = new cc.LabelAtlas;
- k.initWithString(a, c, d, e, f);
- this.initWithLabel(k, g, h);
- return !0
- }
- });
- cc.MenuItemAtlasFont.create = function(a, c, d, e, f, g, h) {
- return new cc.MenuItemAtlasFont(a, c, d, e, f, g, h)
- };
- cc.MenuItemFont = cc.MenuItemLabel.extend({
- _fontSize: null,
- _fontName: null,
- ctor: function(a, c, d) {
- var e;
- a && 0 < a.length ? (this._fontName = cc._globalFontName, this._fontSize = cc._globalFontSize, e = cc.LabelTTF.create(a, this._fontName, this._fontSize)) : (this._fontSize = 0, this._fontName = "");
- cc.MenuItemLabel.prototype.ctor.call(this, e, c, d)
- },
- initWithString: function(a, c, d) {
- if (!a || 0 == a.length) throw "Value should be non-null and its length should be greater than 0";
- this._fontName = cc._globalFontName;
- this._fontSize = cc._globalFontSize;
- a = cc.LabelTTF.create(a, this._fontName, this._fontSize);
- this.initWithLabel(a, c, d);
- return !0
- },
- setFontSize: function(a) {
- this._fontSize = a;
- this._recreateLabel()
- },
- getFontSize: function() {
- return this._fontSize
- },
- setFontName: function(a) {
- this._fontName = a;
- this._recreateLabel()
- },
- getFontName: function() {
- return this._fontName
- },
- _recreateLabel: function() {
- var a = cc.LabelTTF.create(this._label.string, this._fontName, this._fontSize);
- this.setLabel(a)
- }
- });
- cc.MenuItemFont.setFontSize = function(a) {
- cc._globalFontSize = a
- };
- cc.MenuItemFont.fontSize = function() {
- return cc._globalFontSize
- };
- cc.MenuItemFont.setFontName = function(a) {
- cc._globalFontNameRelease && (cc._globalFontName = "");
- cc._globalFontName = a;
- cc._globalFontNameRelease = !0
- };
- _p = cc.MenuItemFont.prototype;
- cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
- cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
- cc.MenuItemFont.fontName = function() {
- return cc._globalFontName
- };
- cc.MenuItemFont.create = function(a, c, d) {
- return new cc.MenuItemFont(a, c, d)
- };
- cc.MenuItemSprite = cc.MenuItem.extend({
- _normalImage: null,
- _selectedImage: null,
- _disabledImage: null,
- ctor: function(a, c, d, e, f) {
- cc.MenuItem.prototype.ctor.call(this);
- this._disabledImage = this._selectedImage = this._normalImage = null;
- if (void 0 !== c) {
- var g, h, k;
- void 0 !== f ? (g = d, k = e, h = f) : void 0 !== e && "function" === typeof e ? (g = d, k = e) : void 0 !== e && "function" === typeof d ? (h = e, k = d, g = cc.Sprite.create(c)) : void 0 === d && (g = cc.Sprite.create(c));
- this.initWithNormalSprite(a, c, g, k, h)
- }
- },
- getNormalImage: function() {
- return this._normalImage
- },
- setNormalImage: function(a) {
- this._normalImage != a && (a && (this.addChild(a, 0, cc.NORMAL_TAG), a.anchorX = 0, a.anchorY = 0), this._normalImage && this.removeChild(this._normalImage, !0), this._normalImage = a, this.width = this._normalImage.width, this.height = this._normalImage.height, this._updateImagesVisibility(), a.textureLoaded && !a.textureLoaded() && a.addLoadedEventListener(function(a) {
- this.width = a.width;
- this.height = a.height
- }, this))
- },
- getSelectedImage: function() {
- return this._selectedImage
- },
- setSelectedImage: function(a) {
- this._selectedImage != a && (a && (this.addChild(a, 0, cc.SELECTED_TAG), a.anchorX = 0, a.anchorY = 0), this._selectedImage && this.removeChild(this._selectedImage, !0), this._selectedImage = a, this._updateImagesVisibility())
- },
- getDisabledImage: function() {
- return this._disabledImage
- },
- setDisabledImage: function(a) {
- this._disabledImage != a && (a && (this.addChild(a, 0, cc.DISABLE_TAG), a.anchorX = 0, a.anchorY = 0), this._disabledImage && this.removeChild(this._disabledImage, !0), this._disabledImage = a, this._updateImagesVisibility())
- },
- initWithNormalSprite: function(a, c, d, e, f) {
- this.initWithCallback(e, f);
- this.setNormalImage(a);
- this.setSelectedImage(c);
- this.setDisabledImage(d);
- if (a = this._normalImage) this.width = a.width, this.height = a.height, a.textureLoaded && !a.textureLoaded() && a.addLoadedEventListener(function(a) {
- this.width = a.width;
- this.height = a.height;
- this.cascadeOpacity = this.cascadeColor = !0
- }, this);
- return this.cascadeOpacity = this.cascadeColor = !0
- },
- setColor: function(a) {
- this._normalImage.color = a;
- this._selectedImage && (this._selectedImage.color = a);
- this._disabledImage && (this._disabledImage.color = a)
- },
- getColor: function() {
- return this._normalImage.color
- },
- setOpacity: function(a) {
- this._normalImage.opacity = a;
- this._selectedImage && (this._selectedImage.opacity = a);
- this._disabledImage && (this._disabledImage.opacity = a)
- },
- getOpacity: function() {
- return this._normalImage.opacity
- },
- selected: function() {
- cc.MenuItem.prototype.selected.call(this);
- this._normalImage && (this._disabledImage && (this._disabledImage.visible = !1), this._selectedImage ? (this._normalImage.visible = !1, this._selectedImage.visible = !0) : this._normalImage.visible = !0)
- },
- unselected: function() {
- cc.MenuItem.prototype.unselected.call(this);
- this._normalImage && (this._normalImage.visible = !0, this._selectedImage && (this._selectedImage.visible = !1), this._disabledImage && (this._disabledImage.visible = !1))
- },
- setEnabled: function(a) {
- this._enabled != a && (cc.MenuItem.prototype.setEnabled.call(this, a), this._updateImagesVisibility())
- },
- _updateImagesVisibility: function() {
- var a = this._normalImage,
- c = this._selectedImage,
- d = this._disabledImage;
- this._enabled ? (a && (a.visible = !0), c && (c.visible = !1), d && (d.visible = !1)) : d ? (a && (a.visible = !1), c && (c.visible = !1), d && (d.visible = !0)) : (a && (a.visible = !0), c && (c.visible = !1))
- }
- });
- _p = cc.MenuItemSprite.prototype;
- cc.defineGetterSetter(_p, "normalImage", _p.getNormalImage, _p.setNormalImage);
- cc.defineGetterSetter(_p, "selectedImage", _p.getSelectedImage, _p.setSelectedImage);
- cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledImage);
- cc.MenuItemSprite.create = function(a, c, d, e, f) {
- return new cc.MenuItemSprite(a, c, d, e, f || void 0)
- };
- cc.MenuItemImage = cc.MenuItemSprite.extend({
- ctor: function(a, c, d, e, f) {
- var g = null,
- h = null,
- k = null,
- m = null,
- n = null;
- void 0 === a ? cc.MenuItemSprite.prototype.ctor.call(this) : (g = cc.Sprite.create(a), c && (h = cc.Sprite.create(c)), void 0 === e ? m = d : void 0 === f ? (m = d, n = e) : f && (k = cc.Sprite.create(d), m = e, n = f), cc.MenuItemSprite.prototype.ctor.call(this, g, h, k, m, n))
- },
- setNormalSpriteFrame: function(a) {
- this.setNormalImage(cc.Sprite.create(a))
- },
- setSelectedSpriteFrame: function(a) {
- this.setSelectedImage(cc.Sprite.create(a))
- },
- setDisabledSpriteFrame: function(a) {
- this.setDisabledImage(cc.Sprite.create(a))
- },
- initWithNormalImage: function(a, c, d, e, f) {
- var g = null,
- h = null,
- k = null;
- a && (g = cc.Sprite.create(a));
- c && (h = cc.Sprite.create(c));
- d && (k = cc.Sprite.create(d));
- return this.initWithNormalSprite(g, h, k, e, f)
- }
- });
- cc.MenuItemImage.create = function(a, c, d, e, f) {
- return new cc.MenuItemImage(a, c, d, e, f)
- };
- cc.MenuItemToggle = cc.MenuItem.extend({
- subItems: null,
- _selectedIndex: 0,
- _opacity: null,
- _color: null,
- ctor: function() {
- cc.MenuItem.prototype.ctor.call(this);
- this._selectedIndex = 0;
- this.subItems = [];
- this._opacity = 0;
- this._color = cc.color.WHITE;
- 0 < arguments.length && this.initWithItems(Array.prototype.slice.apply(arguments))
- },
- getOpacity: function() {
- return this._opacity
- },
- setOpacity: function(a) {
- this._opacity = a;
- if (this.subItems && 0 < this.subItems.length)
- for (var c = 0; c < this.subItems.length; c++) this.subItems[c].opacity = a;
- this._color.a = a
- },
- getColor: function() {
- var a = this._color;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- setColor: function(a) {
- var c = this._color;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- if (this.subItems && 0 < this.subItems.length)
- for (c = 0; c < this.subItems.length; c++) this.subItems[c].setColor(a);
- void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
- },
- getSelectedIndex: function() {
- return this._selectedIndex
- },
- setSelectedIndex: function(a) {
- if (a != this._selectedIndex) {
- this._selectedIndex = a;
- (a = this.getChildByTag(cc.CURRENT_ITEM)) && a.removeFromParent(!1);
- a = this.subItems[this._selectedIndex];
- this.addChild(a, 0, cc.CURRENT_ITEM);
- var c = a.width,
- d = a.height;
- this.width = c;
- this.height = d;
- a.setPosition(c / 2, d / 2)
- }
- },
- getSubItems: function() {
- return this.subItems
- },
- setSubItems: function(a) {
- this.subItems = a
- },
- initWithItems: function(a) {
- var c = a.length;
- "function" === typeof a[a.length - 2] ? (this.initWithCallback(a[a.length - 2], a[a.length - 1]), c -= 2) : "function" === typeof a[a.length - 1] ? (this.initWithCallback(a[a.length - 1], null), c -= 1) : this.initWithCallback(null, null);
- for (var d = this.subItems, e = d.length = 0; e < c; e++) a[e] && d.push(a[e]);
- this._selectedIndex = cc.UINT_MAX;
- this.setSelectedIndex(0);
- return this.cascadeOpacity = this.cascadeColor = !0
- },
- addSubItem: function(a) {
- this.subItems.push(a)
- },
- activate: function() {
- this._enabled && this.setSelectedIndex((this._selectedIndex + 1) % this.subItems.length);
- cc.MenuItem.prototype.activate.call(this)
- },
- selected: function() {
- cc.MenuItem.prototype.selected.call(this);
- this.subItems[this._selectedIndex].selected()
- },
- unselected: function() {
- cc.MenuItem.prototype.unselected.call(this);
- this.subItems[this._selectedIndex].unselected()
- },
- setEnabled: function(a) {
- if (this._enabled != a) {
- cc.MenuItem.prototype.setEnabled.call(this, a);
- var c = this.subItems;
- if (c && 0 < c.length)
- for (var d = 0; d < c.length; d++) c[d].enabled = a
- }
- },
- selectedItem: function() {
- return this.subItems[this._selectedIndex]
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- this.setSelectedIndex(this._selectedIndex)
- }
- });
- _p = cc.MenuItemToggle.prototype;
- cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIndex);
- cc.MenuItemToggle.create = function() {
- 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- var a = new cc.MenuItemToggle;
- a.initWithItems(Array.prototype.slice.apply(arguments));
- return a
- };
- cc.MENU_STATE_WAITING = 0;
- cc.MENU_STATE_TRACKING_TOUCH = 1;
- cc.MENU_HANDLER_PRIORITY = -128;
- cc.DEFAULT_PADDING = 5;
- cc.Menu = cc.Layer.extend({
- enabled: !1,
- _color: null,
- _opacity: 0,
- _selectedItem: null,
- _state: -1,
- _touchListener: null,
- _className: "Menu",
- ctor: function(a) {
- cc.Layer.prototype.ctor.call(this);
- this._color = cc.color.WHITE;
- this.enabled = !1;
- this._opacity = 255;
- this._selectedItem = null;
- this._state = -1;
- this._touchListener = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: !0,
- onTouchBegan: this._onTouchBegan,
- onTouchMoved: this._onTouchMoved,
- onTouchEnded: this._onTouchEnded,
- onTouchCancelled: this._onTouchCancelled
- });
- 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- var c = arguments.length,
- d;
- if (0 == c) d = [];
- else if (1 == c) d = a instanceof Array ? a : [a];
- else if (1 < c) {
- d = [];
- for (var e = 0; e < c; e++) arguments[e] && d.push(arguments[e])
- }
- this.initWithArray(d)
- },
- onEnter: function() {
- var a = this._touchListener;
- a._isRegistered() || cc.eventManager.addListener(a, this);
- cc.Node.prototype.onEnter.call(this)
- },
- getColor: function() {
- var a = this._color;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- setColor: function(a) {
- var c = this._color;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- if ((c = this._children) && 0 < c.length)
- for (var d = 0; d < c.length; d++) c[d].setColor(a);
- void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
- },
- getOpacity: function() {
- return this._opacity
- },
- setOpacity: function(a) {
- this._opacity = a;
- var c = this._children;
- if (c && 0 < c.length)
- for (var d = 0; d < c.length; d++) c[d].setOpacity(a);
- this._color.a = a
- },
- isEnabled: function() {
- return this.enabled
- },
- setEnabled: function(a) {
- this.enabled = a
- },
- initWithItems: function(a) {
- var c = [];
- if (a)
- for (var d = 0; d < a.length; d++) a[d] && c.push(a[d]);
- return this.initWithArray(c)
- },
- initWithArray: function(a) {
- if (cc.Layer.prototype.init.call(this)) {
- this.enabled = !0;
- var c = cc.winSize;
- this.setPosition(c.width / 2, c.height / 2);
- this.setContentSize(c);
- this.setAnchorPoint(0.5, 0.5);
- this.ignoreAnchorPointForPosition(!0);
- if (a)
- for (c = 0; c < a.length; c++) this.addChild(a[c], c);
- this._selectedItem = null;
- this._state = cc.MENU_STATE_WAITING;
- return this.cascadeOpacity = this.cascadeColor = !0
- }
- return !1
- },
- addChild: function(a, c, d) {
- if (!(a instanceof cc.MenuItem)) throw "cc.Menu.addChild() : Menu only supports MenuItem objects as children";
- cc.Layer.prototype.addChild.call(this, a, c, d)
- },
- alignItemsVertically: function() {
- this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
- },
- alignItemsVerticallyWithPadding: function(a) {
- var c = -a,
- d = this._children,
- e, f, g, h;
- if (d && 0 < d.length) {
- f = 0;
- for (e = d.length; f < e; f++) c += d[f].height * d[f].scaleY + a;
- var k = c / 2;
- f = 0;
- for (e = d.length; f < e; f++) h = d[f], g = h.height, c = h.scaleY, h.setPosition(0, k - g * c / 2), k -= g * c + a
- }
- },
- alignItemsHorizontally: function() {
- this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
- },
- alignItemsHorizontallyWithPadding: function(a) {
- var c = -a,
- d = this._children,
- e, f, g, h;
- if (d && 0 < d.length) {
- e = 0;
- for (f = d.length; e < f; e++) c += d[e].width * d[e].scaleX + a;
- var k = -c / 2;
- e = 0;
- for (f = d.length; e < f; e++) h = d[e], c = h.scaleX, g = d[e].width, h.setPosition(k + g * c / 2, 0), k += g * c + a
- }
- },
- alignItemsInColumns: function() {
- 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- for (var a = [], c = 0; c < arguments.length; c++) a.push(arguments[c]);
- var d = -5,
- e = 0,
- f = 0,
- g = 0,
- h, k, m, n = this._children;
- if (n && 0 < n.length) {
- c = 0;
- for (m = n.length; c < m; c++)
- if (!(e >= a.length) && (h = a[e])) k = n[c].height, f = f >= k || isNaN(k) ? f : k, ++g, g >= h && (d += f + 5, f = g = 0, ++e)
- }
- var q = cc.director.getWinSize(),
- r = h = f = e = 0,
- t = 0,
- d = d / 2;
- if (n && 0 < n.length) {
- c = 0;
- for (m = n.length; c < m; c++) {
- var s = n[c];
- 0 == h && (h = a[e], t = r = q.width / (1 + h));
- k = s._getHeight();
- f = f >= k || isNaN(k) ? f : k;
- s.setPosition(t - q.width / 2, d - k / 2);
- t += r;
- ++g;
- g >= h && (d -= f + 5, f = h = g = 0, ++e)
- }
- }
- },
- alignItemsInRows: function() {
- 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
- var a = [],
- c;
- for (c = 0; c < arguments.length; c++) a.push(arguments[c]);
- var d = [],
- e = [],
- f = -10,
- g = -5,
- h = 0,
- k = 0,
- m = 0,
- n, q, r, t, s = this._children;
- if (s && 0 < s.length) {
- c = 0;
- for (r = s.length; c < r; c++)
- if (q = s[c], !(h >= a.length) && (n = a[h])) t = q.width, k = k >= t || isNaN(t) ? k : t, g += q.height + 5, ++m, m >= n && (d.push(k), e.push(g), f += k + 10, k = m = 0, g = -5, ++h)
- }
- g = cc.director.getWinSize();
- n = k = h = 0;
- var f = -f / 2,
- v = 0;
- if (s && 0 < s.length) {
- c = 0;
- for (r = s.length; c < r; c++) q = s[c], 0 == n && (n = a[h], v = e[h]), t = q._getWidth(), k = k >= t || isNaN(t) ? k : t, q.setPosition(f + d[h] / 2, v - g.height / 2), v -= q.height + 10, ++m, m >= n && (f += k + 5, k = n = m = 0, ++h)
- }
- },
- removeChild: function(a, c) {
- null != a && (a instanceof cc.MenuItem ? (this._selectedItem == a && (this._selectedItem = null), cc.Node.prototype.removeChild.call(this, a, c)) : cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children"))
- },
- _onTouchBegan: function(a, c) {
- var d = c.getCurrentTarget();
- if (d._state != cc.MENU_STATE_WAITING || !d._visible || !d.enabled) return !1;
- for (var e = d.parent; null != e; e = e.parent)
- if (!e.isVisible()) return !1;
- d._selectedItem = d._itemForTouch(a);
- return d._selectedItem ? (d._state = cc.MENU_STATE_TRACKING_TOUCH, d._selectedItem.selected(), !0) : !1
- },
- _onTouchEnded: function(a, c) {
- var d = c.getCurrentTarget();
- d._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchEnded(): invalid state") : (d._selectedItem && (d._selectedItem.unselected(), d._selectedItem.activate()), d._state = cc.MENU_STATE_WAITING)
- },
- _onTouchCancelled: function(a, c) {
- var d = c.getCurrentTarget();
- d._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchCancelled(): invalid state") : (this._selectedItem && d._selectedItem.unselected(), d._state = cc.MENU_STATE_WAITING)
- },
- _onTouchMoved: function(a, c) {
- var d = c.getCurrentTarget();
- if (d._state !== cc.MENU_STATE_TRACKING_TOUCH) cc.log("cc.Menu.onTouchMoved(): invalid state");
- else {
- var e = d._itemForTouch(a);
- e != d._selectedItem && (d._selectedItem && d._selectedItem.unselected(), d._selectedItem = e, d._selectedItem && d._selectedItem.selected())
- }
- },
- onExit: function() {
- this._state == cc.MENU_STATE_TRACKING_TOUCH && (this._selectedItem && (this._selectedItem.unselected(), this._selectedItem = null), this._state = cc.MENU_STATE_WAITING);
- cc.Node.prototype.onExit.call(this)
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- },
- _itemForTouch: function(a) {
- a = a.getLocation();
- var c = this._children,
- d;
- if (c && 0 < c.length)
- for (var e = 0; e < c.length; e++)
- if (d = c[e], d.isVisible() && d.isEnabled()) {
- var f = d.convertToNodeSpace(a),
- g = d.rect();
- g.x = 0;
- g.y = 0;
- if (cc.rectContainsPoint(g, f)) return d
- }
- return null
- }
- });
- _p = cc.Menu.prototype;
- cc.Menu.create = function(a) {
- var c = arguments.length;
- 0 < c && null == arguments[c - 1] && cc.log("parameters should not be ending with null in Javascript");
- return 0 == c ? new cc.Menu : 1 == c ? new cc.Menu(a) : new cc.Menu(Array.prototype.slice.call(arguments, 0))
- };
- cc.TGA_OK = 0;
- cc.TGA_ERROR_FILE_OPEN = 1;
- cc.TGA_ERROR_READING_FILE = 2;
- cc.TGA_ERROR_INDEXED_COLOR = 3;
- cc.TGA_ERROR_MEMORY = 4;
- cc.TGA_ERROR_COMPRESSED_FILE = 5;
- cc.ImageTGA = function(a, c, d, e, f, g, h) {
- this.status = a || 0;
- this.type = c || 0;
- this.pixelDepth = d || 0;
- this.width = e || 0;
- this.height = f || 0;
- this.imageData = g || [];
- this.flipped = h || 0
- };
- cc.tgaLoadHeader = function(a, c, d) {
- var e = 2;
- if (e + 1 > c) return !1;
- a = new cc.BinaryStreamReader(a);
- a.setOffset(e);
- d.type = a.readByte();
- e += 10;
- if (e + 4 + 1 > c) return !1;
- a.setOffset(e);
- d.width = a.readUnsignedShort();
- d.height = a.readUnsignedInteger();
- d.pixelDepth = a.readByte();
- if (e + 5 + 1 > c) return !1;
- c = a.readByte();
- d.flipped = 0;
- c & 32 && (d.flipped = 1);
- return !0
- };
- cc.tgaLoadImageData = function(a, c, d) {
- var e, f;
- e = 0 | d.pixelDepth / 2;
- f = d.height * d.width * e;
- if (18 + f > c) return !1;
- d.imageData = cc.__getSubArray(a, 18, 18 + f);
- if (3 <= e)
- for (a = 0; a < f; a += e) c = d.imageData[a], d.imageData[a] = d.imageData[a + 2], d.imageData[a + 2] = c;
- return !0
- };
- cc.tgaRGBtogreyscale = function(a) {
- var c, d;
- if (8 !== a.pixelDepth) {
- var e = a.pixelDepth / 8,
- f = new Uint8Array(a.height * a.width);
- if (null !== f) {
- for (d = c = 0; d < a.width * a.height; c += e, d++) f[d] = 0.3 * a.imageData[c] + 0.59 * a.imageData[c + 1] + 0.11 * a.imageData[c + 2];
- a.pixelDepth = 8;
- a.type = 3;
- a.imageData = f
- }
- }
- };
- cc.tgaDestroy = function(a) {
- a && (a.imageData = null)
- };
- cc.tgaLoadRLEImageData = function(a, c, d) {
- var e, f, g, h = 0,
- k = 0,
- m = 0,
- n = [],
- q = 0,
- r = 18;
- e = d.pixelDepth / 8;
- f = d.height * d.width;
- for (g = 0; g < f; g++) {
- if (0 != q) q--, k = 0 != m;
- else {
- if (r + 1 > c) break;
- q = a[r];
- r += 1;
- (m = q & 128) && (q -= 128);
- k = 0
- } if (!k) {
- if (r + e > c) break;
- n = cc.__getSubArray(a, r, r + e);
- r += e;
- 3 <= e && (k = n[0], n[0] = n[2], n[2] = k)
- }
- for (k = 0; k < e; k++) d.imageData[h + k] = n[k];
- h += e
- }
- return !0
- };
- cc.tgaFlipImage = function(a) {
- for (var c = a.width * (a.pixelDepth / 8), d = 0; d < a.height / 2; d++) {
- var e = cc.__getSubArray(a.imageData, d * c, d * c + c);
- cc.__setDataToArray(cc.__getSubArray(a.imageData, (a.height - (d + 1)) * c, c), a.imageData, d * c);
- cc.__setDataToArray(e, a.imageData, (a.height - (d + 1)) * c)
- }
- a.flipped = 0
- };
- cc.__getSubArray = function(a, c, d) {
- return a instanceof Array ? a.slice(c, d) : a.subarray(c, d)
- };
- cc.__setDataToArray = function(a, c, d) {
- for (var e = 0; e < a.length; e++) c[d + e] = a[e]
- };
- cc.BinaryStreamReader = cc.Class.extend({
- _binaryData: null,
- _offset: 0,
- ctor: function(a) {
- this._binaryData = a
- },
- setBinaryData: function(a) {
- this._binaryData = a;
- this._offset = 0
- },
- getBinaryData: function() {
- return this._binaryData
- },
- _checkSize: function(a) {
- if (!(this._offset + Math.ceil(a / 8) < this._data.length)) throw Error("Index out of bound");
- },
- _decodeFloat: function(a, c) {
- var d = a + c + 1,
- e = d >> 3;
- this._checkSize(d);
- var d = Math.pow(2, c - 1) - 1,
- f = this._readBits(a + c, 1, e),
- g = this._readBits(a, c, e),
- h = 0,
- k = 2,
- m = 0;
- do
- for (var n = this._readByte(++m, e), q = a % 8 || 8, r = 1 << q; r >>= 1;) n & r && (h += 1 / k), k *= 2; while (a -= q);
- this._offset += e;
- return g == (d << 1) + 1 ? h ? NaN : f ? -Infinity : Infinity : (1 + -2 * f) * (g || h ? !g ? Math.pow(2, -d + 1) * h : Math.pow(2, g - d) * (1 + h) : 0)
- },
- _readByte: function(a, c) {
- return this._data[this._offset + c - a - 1]
- },
- _decodeInt: function(a, c) {
- var d = this._readBits(0, a, a / 8),
- e = Math.pow(2, a);
- this._offset += a / 8;
- return c && d >= e / 2 ? d - e : d
- },
- _shl: function(a, c) {
- for (++c; --c; a = 1073741824 == ((a %= 2147483648) & 1073741824) ? 2 * a : 2 * (a - 1073741824) + 2147483648);
- return a
- },
- _readBits: function(a, c, d) {
- var e = (a + c) % 8,
- f = a % 8,
- g = d - (a >> 3) - 1;
- a = d + (-(a + c) >> 3);
- var h = g - a;
- c = this._readByte(g, d) >> f & (1 << (h ? 8 - f : c)) - 1;
- for (h && e && (c += (this._readByte(a++, d) & (1 << e) - 1) << (h-- << 3) - f); h;) c += this._shl(this._readByte(a++, d), (h-- << 3) - f);
- return c
- },
- readInteger: function() {
- return this._decodeInt(32, !0)
- },
- readUnsignedInteger: function() {
- return this._decodeInt(32, !1)
- },
- readSingle: function() {
- return this._decodeFloat(23, 8)
- },
- readShort: function() {
- return this._decodeInt(16, !0)
- },
- readUnsignedShort: function() {
- return this._decodeInt(16, !1)
- },
- readByte: function() {
- var a = this._data[this._offset];
- this._offset += 1;
- return a
- },
- readData: function(a, c) {
- return this._binaryData instanceof Array ? this._binaryData.slice(a, c) : this._binaryData.subarray(a, c)
- },
- setOffset: function(a) {
- this._offset = a
- },
- getOffset: function() {
- return this._offset
- }
- });
- cc.TMX_ORIENTATION_ORTHO = 0;
- cc.TMX_ORIENTATION_HEX = 1;
- cc.TMX_ORIENTATION_ISO = 2;
- cc.TMXTiledMap = cc.Node.extend({
- properties: null,
- mapOrientation: null,
- objectGroups: null,
- _mapSize: null,
- _tileSize: null,
- _tileProperties: null,
- _className: "TMXTiledMap",
- ctor: function(a, c) {
- cc.Node.prototype.ctor.call(this);
- this._mapSize = cc.size(0, 0);
- this._tileSize = cc.size(0, 0);
- void 0 !== c ? this.initWithXML(a, c) : void 0 !== a && this.initWithTMXFile(a)
- },
- getMapSize: function() {
- return cc.size(this._mapSize.width, this._mapSize.height)
- },
- setMapSize: function(a) {
- this._mapSize.width = a.width;
- this._mapSize.height = a.height
- },
- _getMapWidth: function() {
- return this._mapSize.width
- },
- _setMapWidth: function(a) {
- this._mapSize.width = a
- },
- _getMapHeight: function() {
- return this._mapSize.height
- },
- _setMapHeight: function(a) {
- this._mapSize.height = a
- },
- getTileSize: function() {
- return cc.size(this._tileSize.width, this._tileSize.height)
- },
- setTileSize: function(a) {
- this._tileSize.width = a.width;
- this._tileSize.height = a.height
- },
- _getTileWidth: function() {
- return this._tileSize.width
- },
- _setTileWidth: function(a) {
- this._tileSize.width = a
- },
- _getTileHeight: function() {
- return this._tileSize.height
- },
- _setTileHeight: function(a) {
- this._tileSize.height = a
- },
- getMapOrientation: function() {
- return this.mapOrientation
- },
- setMapOrientation: function(a) {
- this.mapOrientation = a
- },
- getObjectGroups: function() {
- return this.objectGroups
- },
- setObjectGroups: function(a) {
- this.objectGroups = a
- },
- getProperties: function() {
- return this.properties
- },
- setProperties: function(a) {
- this.properties = a
- },
- initWithTMXFile: function(a) {
- if (!a || 0 == a.length) throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string.";
- this.height = this.width = 0;
- a = cc.TMXMapInfo.create(a);
- if (!a) return !1;
- var c = a.getTilesets();
- (!c || 0 === c.length) && cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename.");
- this._buildWithMapInfo(a);
- return !0
- },
- initWithXML: function(a, c) {
- this.height = this.width = 0;
- var d = cc.TMXMapInfo.create(a, c),
- e = d.getTilesets();
- (!e || 0 === e.length) && cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename.");
- this._buildWithMapInfo(d);
- return !0
- },
- _buildWithMapInfo: function(a) {
- this._mapSize = a.getMapSize();
- this._tileSize = a.getTileSize();
- this.mapOrientation = a.orientation;
- this.objectGroups = a.getObjectGroups();
- this.properties = a.properties;
- this._tileProperties = a.getTileProperties();
- var c = 0,
- d = a.getLayers();
- if (d)
- for (var e = null, f = 0, g = d.length; f < g; f++)
- if ((e = d[f]) && e.visible) e = this._parseLayer(e, a), this.addChild(e, c, c), this.width = Math.max(this.width, e.width), this.height = Math.max(this.height, e.height), c++
- },
- allLayers: function() {
- for (var a = [], c = this._children, d = 0, e = c.length; d < e; d++) {
- var f = c[d];
- f && f instanceof cc.TMXLayer && a.push(f)
- }
- return a
- },
- getLayer: function(a) {
- if (!a || 0 === a.length) throw "cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.";
- for (var c = this._children, d = 0; d < c.length; d++) {
- var e = c[d];
- if (e && e.layerName == a) return e
- }
- return null
- },
- getObjectGroup: function(a) {
- if (!a || 0 === a.length) throw "cc.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string.";
- if (this.objectGroups)
- for (var c = 0; c < this.objectGroups.length; c++) {
- var d = this.objectGroups[c];
- if (d && d.groupName == a) return d
- }
- return null
- },
- getProperty: function(a) {
- return this.properties[a.toString()]
- },
- propertiesForGID: function(a) {
- return this._tileProperties[a]
- },
- _parseLayer: function(a, c) {
- var d = this._tilesetForLayer(a, c),
- d = cc.TMXLayer.create(d, a, c);
- a.ownTiles = !1;
- d.setupTiles();
- return d
- },
- _tilesetForLayer: function(a, c) {
- var d = a._layerSize,
- e = c.getTilesets();
- if (e)
- for (var f = e.length - 1; 0 <= f; f--) {
- var g = e[f];
- if (g)
- for (var h = 0; h < d.height; h++)
- for (var k = 0; k < d.width; k++) {
- var m = a._tiles[k + d.width * h];
- if (0 != m && (m & cc.TMX_TILE_FLIPPED_MASK) >>> 0 >= g.firstGid) return g
- }
- }
- cc.log("cocos2d: Warning: TMX Layer " + a.name + " has no tiles");
- return null
- }
- });
- _p = cc.TMXTiledMap.prototype;
- cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
- cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
- cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
- cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
- cc.TMXTiledMap.create = function(a, c) {
- return new cc.TMXTiledMap(a, c)
- };
- cc.TMX_PROPERTY_NONE = 0;
- cc.TMX_PROPERTY_MAP = 1;
- cc.TMX_PROPERTY_LAYER = 2;
- cc.TMX_PROPERTY_OBJECTGROUP = 3;
- cc.TMX_PROPERTY_OBJECT = 4;
- cc.TMX_PROPERTY_TILE = 5;
- cc.TMX_TILE_HORIZONTAL_FLAG = 2147483648;
- cc.TMX_TILE_VERTICAL_FLAG = 1073741824;
- cc.TMX_TILE_DIAGONAL_FLAG = 536870912;
- cc.TMX_TILE_FLIPPED_ALL = (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_DIAGONAL_FLAG) >>> 0;
- cc.TMX_TILE_FLIPPED_MASK = ~cc.TMX_TILE_FLIPPED_ALL >>> 0;
- cc.TMXLayerInfo = cc.Class.extend({
- properties: null,
- name: "",
- _layerSize: null,
- _tiles: null,
- visible: null,
- _opacity: null,
- ownTiles: !0,
- _minGID: 1E5,
- _maxGID: 0,
- offset: null,
- ctor: function() {
- this.properties = [];
- this.name = "";
- this._layerSize = null;
- this._tiles = [];
- this.visible = !0;
- this._opacity = 0;
- this.ownTiles = !0;
- this._minGID = 1E5;
- this._maxGID = 0;
- this.offset = cc.p(0, 0)
- },
- getProperties: function() {
- return this.properties
- },
- setProperties: function(a) {
- this.properties = a
- }
- });
- cc.TMXTilesetInfo = cc.Class.extend({
- name: "",
- firstGid: 0,
- _tileSize: null,
- spacing: 0,
- margin: 0,
- sourceImage: "",
- imageSize: null,
- ctor: function() {
- this._tileSize = cc.size(0, 0);
- this.imageSize = cc.size(0, 0)
- },
- rectForGID: function(a) {
- var c = cc.rect(0, 0, 0, 0);
- c.width = this._tileSize.width;
- c.height = this._tileSize.height;
- a &= cc.TMX_TILE_FLIPPED_MASK;
- a -= parseInt(this.firstGid, 10);
- var d = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10);
- c.x = parseInt(a % d * (this._tileSize.width + this.spacing) + this.margin, 10);
- c.y = parseInt(parseInt(a / d, 10) * (this._tileSize.height + this.spacing) + this.margin, 10);
- return c
- }
- });
- cc.TMXMapInfo = cc.SAXParser.extend({
- properties: null,
- orientation: null,
- parentElement: null,
- parentGID: null,
- layerAttrs: 0,
- storingCharacters: !1,
- tmxFileName: null,
- currentString: null,
- _objectGroups: null,
- _mapSize: null,
- _tileSize: null,
- _layers: null,
- _tilesets: null,
- _tileProperties: null,
- _resources: "",
- _currentFirstGID: 0,
- ctor: function(a, c) {
- cc.SAXParser.prototype.ctor.apply(this);
- this._mapSize = cc.size(0, 0);
- this._tileSize = cc.size(0, 0);
- this._layers = [];
- this._tilesets = [];
- this._objectGroups = [];
- this.properties = [];
- this._tileProperties = {};
- this._currentFirstGID = 0;
- void 0 !== c ? this.initWithXML(a, c) : void 0 !== a && this.initWithTMXFile(a)
- },
- getOrientation: function() {
- return this.orientation
- },
- setOrientation: function(a) {
- this.orientation = a
- },
- getMapSize: function() {
- return cc.size(this._mapSize.width, this._mapSize.height)
- },
- setMapSize: function(a) {
- this._mapSize.width = a.width;
- this._mapSize.height = a.height
- },
- _getMapWidth: function() {
- return this._mapSize.width
- },
- _setMapWidth: function(a) {
- this._mapSize.width = a
- },
- _getMapHeight: function() {
- return this._mapSize.height
- },
- _setMapHeight: function(a) {
- this._mapSize.height = a
- },
- getTileSize: function() {
- return cc.size(this._tileSize.width, this._tileSize.height)
- },
- setTileSize: function(a) {
- this._tileSize.width = a.width;
- this._tileSize.height = a.height
- },
- _getTileWidth: function() {
- return this._tileSize.width
- },
- _setTileWidth: function(a) {
- this._tileSize.width = a
- },
- _getTileHeight: function() {
- return this._tileSize.height
- },
- _setTileHeight: function(a) {
- this._tileSize.height = a
- },
- getLayers: function() {
- return this._layers
- },
- setLayers: function(a) {
- this._layers.push(a)
- },
- getTilesets: function() {
- return this._tilesets
- },
- setTilesets: function(a) {
- this._tilesets.push(a)
- },
- getObjectGroups: function() {
- return this._objectGroups
- },
- setObjectGroups: function(a) {
- this._objectGroups.push(a)
- },
- getParentElement: function() {
- return this.parentElement
- },
- setParentElement: function(a) {
- this.parentElement = a
- },
- getParentGID: function() {
- return this.parentGID
- },
- setParentGID: function(a) {
- this.parentGID = a
- },
- getLayerAttribs: function() {
- return this.layerAttrs
- },
- setLayerAttribs: function(a) {
- this.layerAttrs = a
- },
- getStoringCharacters: function() {
- return this.storingCharacters
- },
- setStoringCharacters: function(a) {
- this.storingCharacters = a
- },
- getProperties: function() {
- return this.properties
- },
- setProperties: function(a) {
- this.properties = a
- },
- initWithTMXFile: function(a) {
- this._internalInit(a, null);
- return this.parseXMLFile(a)
- },
- initWithXML: function(a, c) {
- this._internalInit(null, c);
- return this.parseXMLString(a)
- },
- parseXMLFile: function(a, c) {
- var d = (c = c || !1) ? a : cc.loader.getRes(a);
- if (!d) throw "Please load the resource first : " + a;
- var e, f, d = this._parseXML(d).documentElement;
- e = d.getAttribute("version");
- f = d.getAttribute("orientation");
- if ("map" == d.nodeName && ("1.0" != e && null !== e && cc.log("cocos2d: TMXFormat: Unsupported TMX version:" + e), "orthogonal" == f ? this.orientation = cc.TMX_ORIENTATION_ORTHO : "isometric" == f ? this.orientation = cc.TMX_ORIENTATION_ISO : "hexagonal" == f ? this.orientation = cc.TMX_ORIENTATION_HEX : null !== f && cc.log("cocos2d: TMXFomat: Unsupported orientation:" + f), e = cc.size(0, 0), e.width = parseFloat(d.getAttribute("width")), e.height = parseFloat(d.getAttribute("height")), this.setMapSize(e), e = cc.size(0, 0), e.width = parseFloat(d.getAttribute("tilewidth")), e.height = parseFloat(d.getAttribute("tileheight")), this.setTileSize(e), f = d.querySelectorAll("map \x3e properties \x3e property"))) {
- var g = {};
- for (e = 0; e < f.length; e++) g[f[e].getAttribute("name")] = f[e].getAttribute("value");
- this.properties = g
- }
- g = d.getElementsByTagName("tileset");
- "map" !== d.nodeName && (g = [], g.push(d));
- for (e = 0; e < g.length; e++) {
- f = g[e];
- var h = f.getAttribute("source");
- if (h) f = c ? cc.path.join(this._resources, h) : cc.path.changeBasename(a, h), this.parseXMLFile(f);
- else {
- h = new cc.TMXTilesetInfo;
- h.name = f.getAttribute("name") || "";
- h.firstGid = parseInt(f.getAttribute("firstgid")) || 0;
- h.spacing = parseInt(f.getAttribute("spacing")) || 0;
- h.margin = parseInt(f.getAttribute("margin")) || 0;
- var k = cc.size(0, 0);
- k.width = parseFloat(f.getAttribute("tilewidth"));
- k.height = parseFloat(f.getAttribute("tileheight"));
- h._tileSize = k;
- var k = f.getElementsByTagName("image")[0].getAttribute("source"),
- m = -1;
- this.tmxFileName && (m = this.tmxFileName.lastIndexOf("/")); - 1 !== m ? (m = this.tmxFileName.substr(0, m + 1), h.sourceImage = m + k) : h.sourceImage = this._resources + (this._resources ? "/" : "") + k;
- this.setTilesets(h);
- if (k = f.getElementsByTagName("tile"))
- for (m = 0; m < k.length; m++) {
- f = k[m];
- this.parentGID = parseInt(h.firstGid) + parseInt(f.getAttribute("id") || 0);
- var n = f.querySelectorAll("properties \x3e property");
- if (n) {
- var q = {};
- for (f = 0; f < n.length; f++) {
- var r = n[f].getAttribute("name");
- q[r] = n[f].getAttribute("value")
- }
- this._tileProperties[this.parentGID] = q
- }
- }
- }
- }
- if (g = d.getElementsByTagName("layer"))
- for (e = 0; e < g.length; e++) {
- k = g[e];
- m = k.getElementsByTagName("data")[0];
- h = new cc.TMXLayerInfo;
- h.name = k.getAttribute("name");
- f = cc.size(0, 0);
- f.width = parseFloat(k.getAttribute("width"));
- f.height = parseFloat(k.getAttribute("height"));
- h._layerSize = f;
- f = k.getAttribute("visible");
- h.visible = "0" != f;
- f = k.getAttribute("opacity") || 1;
- h._opacity = f ? parseInt(255 * parseFloat(f)) : 255;
- h.offset = cc.p(parseFloat(k.getAttribute("x")) || 0, parseFloat(k.getAttribute("y")) || 0);
- n = "";
- for (f = 0; f < m.childNodes.length; f++) n += m.childNodes[f].nodeValue;
- n = n.trim();
- f = m.getAttribute("compression");
- q = m.getAttribute("encoding");
- if (f && "gzip" !== f && "zlib" !== f) return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"), null;
- switch (f) {
- case "gzip":
- h._tiles = cc.unzipBase64AsArray(n, 4);
- break;
- case "zlib":
- f = new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(n, 1));
- h._tiles = cc.uint8ArrayToUint32Array(f.decompress());
- break;
- case null:
- case "":
- if ("base64" == q) h._tiles = cc.Codec.Base64.decodeAsArray(n, 4);
- else if ("csv" === q) {
- h._tiles = [];
- f = n.split(",");
- for (m = 0; m < f.length; m++) h._tiles.push(parseInt(f[m]))
- } else {
- f = m.getElementsByTagName("tile");
- h._tiles = [];
- for (m = 0; m < f.length; m++) h._tiles.push(parseInt(f[m].getAttribute("gid")))
- }
- break;
- default:
- this.layerAttrs == cc.TMXLayerInfo.ATTRIB_NONE && cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported")
- }
- if (k = k.querySelectorAll("properties \x3e property")) {
- m = {};
- for (f = 0; f < k.length; f++) m[k[f].getAttribute("name")] = k[f].getAttribute("value");
- h.properties = m
- }
- this.setLayers(h)
- }
- if (g = d.getElementsByTagName("objectgroup"))
- for (e = 0; e < g.length; e++) {
- k = g[e];
- h = new cc.TMXObjectGroup;
- h.groupName = k.getAttribute("name");
- h.setPositionOffset(cc.p(parseFloat(k.getAttribute("x")) * this.getTileSize().width || 0, parseFloat(k.getAttribute("y")) * this.getTileSize().height || 0));
- if (m = k.querySelectorAll("objectgroup \x3e properties \x3e property"))
- for (f = 0; f < m.length; f++) n = {}, n[m[f].getAttribute("name")] = m[f].getAttribute("value"), h.properties = n;
- if (k = k.querySelectorAll("object"))
- for (f = 0; f < k.length; f++) {
- n = k[f];
- m = {};
- m.name = n.getAttribute("name") || "";
- m.type = n.getAttribute("type") || "";
- m.x = parseInt(n.getAttribute("x") || 0) + h.getPositionOffset().x;
- q = parseInt(n.getAttribute("y") || 0) + h.getPositionOffset().y;
- m.width = parseInt(n.getAttribute("width")) || 0;
- m.height = parseInt(n.getAttribute("height")) || 0;
- m.y = parseInt(this.getMapSize().height * this.getTileSize().height) - q - m.height;
- if (q = n.querySelectorAll("properties \x3e property"))
- for (r = 0; r < q.length; r++) m[q[r].getAttribute("name")] = q[r].getAttribute("value");
- if ((q = n.querySelectorAll("polygon")) && 0 < q.length)(q = q[0].getAttribute("points")) && (m.polygonPoints = this._parsePointsString(q));
- if ((n = n.querySelectorAll("polyline")) && 0 < n.length)(n = n[0].getAttribute("points")) && (m.polylinePoints = this._parsePointsString(n));
- h.setObjects(m)
- }
- this.setObjectGroups(h)
- }
- return d
- },
- _parsePointsString: function(a) {
- if (!a) return null;
- var c = [];
- a = a.split(" ");
- for (var d = 0; d < a.length; d++) {
- var e = a[d].split(",");
- c.push({
- x: e[0],
- y: e[1]
- })
- }
- return c
- },
- parseXMLString: function(a) {
- return this.parseXMLFile(a, !0)
- },
- getTileProperties: function() {
- return this._tileProperties
- },
- setTileProperties: function(a) {
- this._tileProperties.push(a)
- },
- getCurrentString: function() {
- return this.currentString
- },
- setCurrentString: function(a) {
- this.currentString = a
- },
- getTMXFileName: function() {
- return this.tmxFileName
- },
- setTMXFileName: function(a) {
- this.tmxFileName = a
- },
- _internalInit: function(a, c) {
- this._tilesets.length = 0;
- this._layers.length = 0;
- this.tmxFileName = a;
- c && (this._resources = c);
- this._objectGroups.length = 0;
- this.properties.length = 0;
- this._tileProperties.length = 0;
- this.currentString = "";
- this.storingCharacters = !1;
- this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
- this.parentElement = cc.TMX_PROPERTY_NONE;
- this._currentFirstGID = 0
- }
- });
- _p = cc.TMXMapInfo.prototype;
- cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
- cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
- cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
- cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
- cc.TMXMapInfo.create = function(a, c) {
- return new cc.TMXMapInfo(a, c)
- };
- cc.loader.register(["tmx", "tsx"], cc._txtLoader);
- cc.TMXLayerInfo.ATTRIB_NONE = 1;
- cc.TMXLayerInfo.ATTRIB_BASE64 = 2;
- cc.TMXLayerInfo.ATTRIB_GZIP = 4;
- cc.TMXLayerInfo.ATTRIB_ZLIB = 8;
- cc.TMXObjectGroup = cc.Class.extend({
- properties: null,
- groupName: "",
- _positionOffset: null,
- _objects: null,
- ctor: function() {
- this.groupName = "";
- this._positionOffset = cc.p(0, 0);
- this.properties = [];
- this._objects = []
- },
- getPositionOffset: function() {
- return cc.p(this._positionOffset)
- },
- setPositionOffset: function(a) {
- this._positionOffset.x = a.x;
- this._positionOffset.y = a.y
- },
- getProperties: function() {
- return this.properties
- },
- setProperties: function(a) {
- this.properties.push(a)
- },
- getGroupName: function() {
- return this.groupName.toString()
- },
- setGroupName: function(a) {
- this.groupName = a
- },
- propertyNamed: function(a) {
- return this.properties[a]
- },
- objectNamed: function(a) {
- if (this._objects && 0 < this._objects.length)
- for (var c = this._objects, d = 0, e = c.length; d < e; d++) {
- var f = c[d].name;
- if (f && f == a) return c[d]
- }
- return null
- },
- getObjects: function() {
- return this._objects
- },
- setObjects: function(a) {
- this._objects.push(a)
- }
- });
- cc.TMXLayer = cc.SpriteBatchNode.extend({
- tiles: null,
- tileset: null,
- layerOrientation: null,
- properties: null,
- layerName: "",
- _layerSize: null,
- _mapTileSize: null,
- _opacity: 255,
- _minGID: null,
- _maxGID: null,
- _vertexZvalue: null,
- _useAutomaticVertexZ: null,
- _alphaFuncValue: null,
- _reusedTile: null,
- _atlasIndexArray: null,
- _contentScaleFactor: null,
- _cacheCanvas: null,
- _cacheContext: null,
- _cacheTexture: null,
- _subCacheCanvas: null,
- _subCacheContext: null,
- _subCacheCount: 0,
- _subCacheWidth: 0,
- _maxCachePixel: 1E7,
- _className: "TMXLayer",
- ctor: function(a, c, d) {
- cc.SpriteBatchNode.prototype.ctor.call(this);
- this._descendants = [];
- this._layerSize = cc.size(0, 0);
- this._mapTileSize = cc.size(0, 0);
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
- var e = cc._canvas,
- f = cc.newElement("canvas");
- f.width = e.width;
- f.height = e.height;
- this._cacheCanvas = f;
- this._cacheContext = this._cacheCanvas.getContext("2d");
- var g = new cc.Texture2D;
- g.initWithElement(f);
- g.handleLoadedTexture();
- this._cacheTexture = g;
- this.width = e.width;
- this.height = e.height;
- this._cachedParent = this
- }
- void 0 !== d && this.initWithTilesetInfo(a, c, d)
- },
- setContentSize: function(a, c) {
- var d = this._contentSize;
- cc.Node.prototype.setContentSize.call(this, a, c);
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
- var e = this._cacheCanvas,
- f = cc.contentScaleFactor();
- e.width = 0 | 1.5 * d.width * f;
- e.height = 0 | 1.5 * d.height * f;
- this.layerOrientation === cc.TMX_ORIENTATION_HEX ? this._cacheContext.translate(0, e.height - 0.5 * this._mapTileSize.height) : this._cacheContext.translate(0, e.height);
- d = this._cacheTexture._contentSize;
- d.width = e.width;
- d.height = e.height;
- d = e.width * e.height;
- if (d > this._maxCachePixel) {
- this._subCacheCanvas || (this._subCacheCanvas = []);
- this._subCacheContext || (this._subCacheContext = []);
- this._subCacheCount = Math.ceil(d / this._maxCachePixel);
- d = this._subCacheCanvas;
- for (f = 0; f < this._subCacheCount; f++) {
- d[f] || (d[f] = document.createElement("canvas"), this._subCacheContext[f] = d[f].getContext("2d"));
- var g = d[f];
- g.width = this._subCacheWidth = Math.round(e.width / this._subCacheCount);
- g.height = e.height
- }
- for (f = this._subCacheCount; f < d.length; f++) g.width = 0, g.height = 0
- } else this._subCacheCount = 0
- }
- },
- getTexture: null,
- _getTextureForCanvas: function() {
- return this._cacheTexture
- },
- visit: null,
- _visitForCanvas: function(a) {
- var c = a || cc._renderContext;
- if (this._visible) {
- c.save();
- this.transform(a);
- var d, e = this._children;
- if (this._cacheDirty) {
- var f = cc.view;
- f._setScaleXYForRenderTexture();
- var g = this._cacheContext,
- h = this._cacheCanvas;
- g.clearRect(0, 0, h.width, -h.height);
- g.save();
- g.translate(this._anchorPointInPoints.x, -this._anchorPointInPoints.y);
- if (e) {
- this.sortAllChildren();
- for (d = 0; d < e.length; d++) e[d] && e[d].visit(g)
- }
- g.restore();
- if (0 < this._subCacheCount) {
- e = this._subCacheWidth;
- g = h.height;
- for (d = 0; d < this._subCacheCount; d++) this._subCacheContext[d].drawImage(h, d * e, 0, e, g, 0, 0, e, g)
- }
- f._resetScale();
- this._cacheDirty = !1
- }
- this.draw(a);
- c.restore()
- }
- },
- draw: null,
- _drawForCanvas: function(a) {
- a = a || cc._renderContext;
- var c = 0 | -this._anchorPointInPoints.x,
- d = 0 | -this._anchorPointInPoints.y,
- e = cc.view,
- f = this._cacheCanvas;
- if (f) {
- var g = this._subCacheCount,
- h = f.height * e._scaleY,
- k = 0.5 * this._mapTileSize.height * e._scaleY;
- if (0 < g)
- for (var f = this._subCacheCanvas, m = 0; m < g; m++) {
- var n = f[m];
- this.layerOrientation === cc.TMX_ORIENTATION_HEX ? a.drawImage(f[m], 0, 0, n.width, n.height, c + m * this._subCacheWidth, -(d + h) + k, n.width * e._scaleX, h) : a.drawImage(f[m], 0, 0, n.width, n.height, c + m * this._subCacheWidth, -(d + h), n.width * e._scaleX, h)
- } else this.layerOrientation === cc.TMX_ORIENTATION_HEX ? a.drawImage(f, 0, 0, f.width, f.height, c, -(d + h) + k, f.width * e._scaleX, h) : a.drawImage(f, 0, 0, f.width, f.height, c, -(d + h), f.width * e._scaleX, h)
- }
- },
- getLayerSize: function() {
- return cc.size(this._layerSize.width, this._layerSize.height)
- },
- setLayerSize: function(a) {
- this._layerSize.width = a.width;
- this._layerSize.height = a.height
- },
- _getLayerWidth: function() {
- return this._layerSize.width
- },
- _setLayerWidth: function(a) {
- this._layerSize.width = a
- },
- _getLayerHeight: function() {
- return this._layerSize.height
- },
- _setLayerHeight: function(a) {
- this._layerSize.height = a
- },
- getMapTileSize: function() {
- return cc.size(this._mapTileSize.width, this._mapTileSize.height)
- },
- setMapTileSize: function(a) {
- this._mapTileSize.width = a.width;
- this._mapTileSize.height = a.height
- },
- _getTileWidth: function() {
- return this._mapTileSize.width
- },
- _setTileWidth: function(a) {
- this._mapTileSize.width = a
- },
- _getTileHeight: function() {
- return this._mapTileSize.height
- },
- _setTileHeight: function(a) {
- this._mapTileSize.height = a
- },
- getTiles: function() {
- return this.tiles
- },
- setTiles: function(a) {
- this.tiles = a
- },
- getTileset: function() {
- return this.tileset
- },
- setTileset: function(a) {
- this.tileset = a
- },
- getLayerOrientation: function() {
- return this.layerOrientation
- },
- setLayerOrientation: function(a) {
- this.layerOrientation = a
- },
- getProperties: function() {
- return this.properties
- },
- setProperties: function(a) {
- this.properties = a
- },
- initWithTilesetInfo: function(a, c, d) {
- var e = c._layerSize,
- f = 0.35 * parseInt(e.width * e.height) + 1,
- g;
- a && (g = cc.textureCache.addImage(a.sourceImage));
- return this.initWithTexture(g, f) ? (this.layerName = c.name, this._layerSize = e, this.tiles = c._tiles, this._minGID = c._minGID, this._maxGID = c._maxGID, this._opacity = c._opacity, this.properties = c.properties, this._contentScaleFactor = cc.director.getContentScaleFactor(), this.tileset = a, this._mapTileSize = d.getTileSize(), this.layerOrientation = d.orientation, a = this._calculateLayerOffset(c.offset), this.setPosition(cc.pointPixelsToPoints(a)), this._atlasIndexArray = [], this.setContentSize(cc.sizePixelsToPoints(cc.size(this._layerSize.width * this._mapTileSize.width, this._layerSize.height * this._mapTileSize.height))), this._useAutomaticVertexZ = !1, this._vertexZvalue = 0, !0) : !1
- },
- releaseMap: function() {
- this.tiles && (this.tiles = null);
- this._atlasIndexArray && (this._atlasIndexArray = null)
- },
- getTileAt: function(a, c) {
- if (!a) throw "cc.TMXLayer.getTileAt(): pos should be non-null";
- void 0 !== c && (a = cc.p(a, c));
- if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileAt(): invalid position";
- if (!this.tiles || !this._atlasIndexArray) return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"), null;
- var d = null,
- e = this.getTileGIDAt(a);
- if (0 === e) return d;
- var f = 0 | a.x + a.y * this._layerSize.width,
- d = this.getChildByTag(f);
- d || (e = this.tileset.rectForGID(e), e = cc.rectPixelsToPoints(e), d = new cc.Sprite, d.initWithTexture(this.texture, e), d.batchNode = this, d.setPosition(this.getPositionAt(a)), d.vertexZ = this._vertexZForPos(a), d.anchorX = 0, d.anchorY = 0, d.opacity = this._opacity, e = this._atlasIndexForExistantZ(f), this.addSpriteWithoutQuad(d, e, f));
- return d
- },
- getTileGIDAt: function(a, c) {
- if (!a) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null";
- void 0 !== c && (a = cc.p(a, c));
- if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileGIDAt(): invalid position";
- return !this.tiles || !this._atlasIndexArray ? (cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"), null) : (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_MASK) >>> 0
- },
- getTileFlagsAt: function(a, c) {
- if (!a) throw "cc.TMXLayer.getTileFlagsAt(): pos should be non-null";
- void 0 !== c && (a = cc.p(a, c));
- if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileFlagsAt(): invalid position";
- return !this.tiles || !this._atlasIndexArray ? (cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"), null) : (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_ALL) >>> 0
- },
- setTileGID: function(a, c, d, e) {
- if (!c) throw "cc.TMXLayer.setTileGID(): pos should be non-null";
- void 0 !== e ? c = cc.p(c, d) : e = d;
- if (c.x >= this._layerSize.width || c.y >= this._layerSize.height || 0 > c.x || 0 > c.y) throw "cc.TMXLayer.setTileGID(): invalid position";
- if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released");
- else if (0 !== a && a < this.tileset.firstGid) cc.log("cc.TMXLayer.setTileGID(): invalid gid:" + a);
- else {
- e = e || 0;
- this._setNodeDirtyForCache();
- d = this.getTileFlagsAt(c);
- var f = this.getTileGIDAt(c);
- if (f != a || d != e)
- if (d = (a | e) >>> 0, 0 === a) this.removeTileAt(c);
- else if (0 === f) this._insertTileForGID(d, c);
- else {
- var f = c.x + c.y * this._layerSize.width,
- g = this.getChildByTag(f);
- g ? (a = this.tileset.rectForGID(a), a = cc.rectPixelsToPoints(a), g.setTextureRect(a, !1), null != e && this._setupTileSprite(g, c, d), this.tiles[f] = d) : this._updateTileForGID(d, c)
- }
- }
- },
- removeTileAt: function(a, c) {
- if (!a) throw "cc.TMXLayer.removeTileAt(): pos should be non-null";
- void 0 !== c && (a = cc.p(a, c));
- if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.removeTileAt(): invalid position";
- if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");
- else if (0 !== this.getTileGIDAt(a)) {
- cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
- var d = 0 | a.x + a.y * this._layerSize.width,
- e = this._atlasIndexForExistantZ(d);
- this.tiles[d] = 0;
- this._atlasIndexArray.splice(e, 1);
- if (d = this.getChildByTag(d)) cc.SpriteBatchNode.prototype.removeChild.call(this, d, !0);
- else if (cc._renderType === cc._RENDER_TYPE_WEBGL && this.textureAtlas.removeQuadAtIndex(e), this._children)
- for (var d = this._children, f = 0, g = d.length; f < g; f++) {
- var h = d[f];
- if (h) {
- var k = h.atlasIndex;
- k >= e && (h.atlasIndex = k - 1)
- }
- }
- }
- },
- getPositionAt: function(a, c) {
- void 0 !== c && (a = cc.p(a, c));
- var d = cc.p(0, 0);
- switch (this.layerOrientation) {
- case cc.TMX_ORIENTATION_ORTHO:
- d = this._positionForOrthoAt(a);
- break;
- case cc.TMX_ORIENTATION_ISO:
- d = this._positionForIsoAt(a);
- break;
- case cc.TMX_ORIENTATION_HEX:
- d = this._positionForHexAt(a)
- }
- return cc.pointPixelsToPoints(d)
- },
- getProperty: function(a) {
- return this.properties[a]
- },
- setupTiles: function() {
- cc._renderType === cc._RENDER_TYPE_CANVAS ? this.tileset.imageSize = this._originalTexture.getContentSizeInPixels() : (this.tileset.imageSize = this.textureAtlas.texture.getContentSizeInPixels(), this.textureAtlas.texture.setAliasTexParameters());
- this._parseInternalProperties();
- cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
- for (var a = this._layerSize.height, c = this._layerSize.width, d = 0; d < a; d++)
- for (var e = 0; e < c; e++) {
- var f = this.tiles[e + c * d];
- 0 !== f && (this._appendTileForGID(f, cc.p(e, d)), this._minGID = Math.min(f, this._minGID), this._maxGID = Math.max(f, this._maxGID))
- }
- this._maxGID >= this.tileset.firstGid && this._minGID >= this.tileset.firstGid || cc.log("cocos2d:TMX: Only 1 tileset per layer is supported")
- },
- addChild: function(a, c, d) {
- cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.")
- },
- removeChild: function(a, c) {
- if (a)
- if (-1 === this._children.indexOf(a)) cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer");
- else {
- cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
- var d = a.atlasIndex;
- this.tiles[this._atlasIndexArray[d]] = 0;
- this._atlasIndexArray.splice(d, 1);
- cc.SpriteBatchNode.prototype.removeChild.call(this, a, c)
- }
- },
- getLayerName: function() {
- return this.layerName
- },
- setLayerName: function(a) {
- this.layerName = a
- },
- _positionForIsoAt: function(a) {
- return cc.p(this._mapTileSize.width / 2 * (this._layerSize.width + a.x - a.y - 1), this._mapTileSize.height / 2 * (2 * this._layerSize.height - a.x - a.y - 2))
- },
- _positionForOrthoAt: function(a) {
- return cc.p(a.x * this._mapTileSize.width, (this._layerSize.height - a.y - 1) * this._mapTileSize.height)
- },
- _positionForHexAt: function(a) {
- return cc.p(3 * a.x * this._mapTileSize.width / 4, (this._layerSize.height - a.y - 1) * this._mapTileSize.height + (1 == a.x % 2 ? -this._mapTileSize.height / 2 : 0))
- },
- _calculateLayerOffset: function(a) {
- var c = cc.p(0, 0);
- switch (this.layerOrientation) {
- case cc.TMX_ORIENTATION_ORTHO:
- c = cc.p(a.x * this._mapTileSize.width, -a.y * this._mapTileSize.height);
- break;
- case cc.TMX_ORIENTATION_ISO:
- c = cc.p(this._mapTileSize.width / 2 * (a.x - a.y), this._mapTileSize.height / 2 * (-a.x - a.y));
- break;
- case cc.TMX_ORIENTATION_HEX:
- (0 !== a.x || 0 !== a.y) && cc.log("offset for hexagonal map not implemented yet")
- }
- return c
- },
- _appendTileForGID: function(a, c) {
- var d = this.tileset.rectForGID(a),
- d = cc.rectPixelsToPoints(d),
- e = 0 | c.x + c.y * this._layerSize.width,
- d = this._reusedTileWithRect(d);
- this._setupTileSprite(d, c, a);
- var f = this._atlasIndexArray.length;
- this.insertQuadFromSprite(d, f);
- this._atlasIndexArray.splice(f, 0, e);
- return d
- },
- _insertTileForGID: function(a, c) {
- var d = this.tileset.rectForGID(a),
- d = cc.rectPixelsToPoints(d),
- e = 0 | c.x + c.y * this._layerSize.width,
- d = this._reusedTileWithRect(d);
- this._setupTileSprite(d, c, a);
- var f = this._atlasIndexForNewZ(e);
- this.insertQuadFromSprite(d, f);
- this._atlasIndexArray.splice(f, 0, e);
- if (this._children)
- for (var g = this._children, h = 0, k = g.length; h < k; h++) {
- var m = g[h];
- if (m) {
- var n = m.atlasIndex;
- n >= f && (m.atlasIndex = n + 1)
- }
- }
- this.tiles[e] = a;
- return d
- },
- _updateTileForGID: function(a, c) {
- var d = this.tileset.rectForGID(a),
- e = this._contentScaleFactor,
- d = cc.rect(d.x / e, d.y / e, d.width / e, d.height / e),
- e = c.x + c.y * this._layerSize.width,
- d = this._reusedTileWithRect(d);
- this._setupTileSprite(d, c, a);
- d.atlasIndex = this._atlasIndexForExistantZ(e);
- d.dirty = !0;
- d.updateTransform();
- this.tiles[e] = a;
- return d
- },
- _parseInternalProperties: function() {
- var a = this.getProperty("cc_vertexz");
- if (a)
- if ("automatic" == a) {
- this._useAutomaticVertexZ = !0;
- var c = this.getProperty("cc_alpha_func"),
- a = 0;
- c && (a = parseFloat(c));
- cc._renderType === cc._RENDER_TYPE_WEBGL && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST), c = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S), this.shaderProgram.use(), this.shaderProgram.setUniformLocationWith1f(c, a))
- } else this._vertexZvalue = parseInt(a, 10)
- },
- _setupTileSprite: function(a, c, d) {
- var e = c.x + c.y * this._layerSize.width;
- a.setPosition(this.getPositionAt(c));
- cc._renderType === cc._RENDER_TYPE_WEBGL ? a.vertexZ = this._vertexZForPos(c) : a.tag = e;
- a.anchorX = 0;
- a.anchorY = 0;
- a.opacity = this._opacity;
- cc._renderType === cc._RENDER_TYPE_WEBGL && (a.rotation = 0);
- a.setFlippedX(!1);
- a.setFlippedY(!1);
- (d & cc.TMX_TILE_DIAGONAL_FLAG) >>> 0 ? (a.anchorX = 0.5, a.anchorY = 0.5, a.x = this.getPositionAt(c).x + a.width / 2, a.y = this.getPositionAt(c).y + a.height / 2, c = (d & (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG) >>> 0) >>> 0, c == cc.TMX_TILE_HORIZONTAL_FLAG ? a.rotation = 90 : c == cc.TMX_TILE_VERTICAL_FLAG ? a.rotation = 270 : (a.rotation = c == (cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 ? 90 : 270, a.setFlippedX(!0))) : ((d & cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 && a.setFlippedX(!0), (d & cc.TMX_TILE_VERTICAL_FLAG) >>> 0 && a.setFlippedY(!0))
- },
- _reusedTileWithRect: function(a) {
- cc._renderType === cc._RENDER_TYPE_WEBGL ? (this._reusedTile ? (this._reusedTile.batchNode = null, this._reusedTile.setTextureRect(a, !1)) : (this._reusedTile = new cc.Sprite, this._reusedTile.initWithTexture(this.texture, a, !1)), this._reusedTile.batchNode = this) : (this._reusedTile = new cc.Sprite, this._reusedTile.initWithTexture(this._textureForCanvas, a, !1), this._reusedTile.batchNode = this, this._reusedTile.parent = this);
- return this._reusedTile
- },
- _vertexZForPos: function(a) {
- var c = 0,
- d = 0;
- if (this._useAutomaticVertexZ) switch (this.layerOrientation) {
- case cc.TMX_ORIENTATION_ISO:
- d = this._layerSize.width + this._layerSize.height;
- c = -(d - (a.x + a.y));
- break;
- case cc.TMX_ORIENTATION_ORTHO:
- c = -(this._layerSize.height - a.y);
- break;
- case cc.TMX_ORIENTATION_HEX:
- cc.log("TMX Hexa zOrder not supported");
- break;
- default:
- cc.log("TMX invalid value")
- } else c = this._vertexZvalue;
- return c
- },
- _atlasIndexForExistantZ: function(a) {
- var c;
- if (this._atlasIndexArray)
- for (var d = this._atlasIndexArray, e = 0, f = d.length; e < f && !(c = d[e], c == a); e++);
- "number" != typeof c && cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen");
- return e
- },
- _atlasIndexForNewZ: function(a) {
- for (var c = this._atlasIndexArray, d = 0, e = c.length; d < e && !(a < c[d]); d++);
- return d
- }
- });
- _p = cc.TMXLayer.prototype;
- cc._renderType == cc._RENDER_TYPE_WEBGL ? (_p.draw = cc.SpriteBatchNode.prototype.draw, _p.visit = cc.SpriteBatchNode.prototype.visit, _p.getTexture = cc.SpriteBatchNode.prototype.getTexture) : (_p.draw = _p._drawForCanvas, _p.visit = _p._visitForCanvas, _p.getTexture = _p._getTextureForCanvas);
- cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
- cc.defineGetterSetter(_p, "layerWidth", _p._getLayerWidth, _p._setLayerWidth);
- cc.defineGetterSetter(_p, "layerHeight", _p._getLayerHeight, _p._setLayerHeight);
- cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
- cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
- cc.TMXLayer.create = function(a, c, d) {
- return new cc.TMXLayer(a, c, d)
- };
- cc.PointObject = cc.Class.extend({
- _ratio: null,
- _offset: null,
- _child: null,
- getRatio: function() {
- return this._ratio
- },
- setRatio: function(a) {
- this._ratio = a
- },
- getOffset: function() {
- return this._offset
- },
- setOffset: function(a) {
- this._offset = a
- },
- getChild: function() {
- return this._child
- },
- setChild: function(a) {
- this._child = a
- },
- initWithCCPoint: function(a, c) {
- this._ratio = a;
- this._offset = c;
- this._child = null;
- return !0
- }
- });
- cc.PointObject.create = function(a, c) {
- var d = new cc.PointObject;
- d.initWithCCPoint(a, c);
- return d
- };
- cc.ParallaxNode = cc.Node.extend({
- parallaxArray: null,
- _lastPosition: null,
- _className: "ParallaxNode",
- getParallaxArray: function() {
- return this.parallaxArray
- },
- setParallaxArray: function(a) {
- this.parallaxArray = a
- },
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this.parallaxArray = [];
- this._lastPosition = cc.p(-100, -100)
- },
- addChild: function(a, c, d, e) {
- if (3 === arguments.length) cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");
- else {
- if (!a) throw "cc.ParallaxNode.addChild(): child should be non-null";
- var f = cc.PointObject.create(d, e);
- f.setChild(a);
- this.parallaxArray.push(f);
- a.setPosition(this._position.x * d.x + e.x, this._position.y * d.y + e.y);
- cc.Node.prototype.addChild.call(this, a, c, a.tag)
- }
- },
- removeChild: function(a, c) {
- for (var d = this.parallaxArray, e = 0; e < d.length; e++)
- if (d[e].getChild() == a) {
- d.splice(e, 1);
- break
- }
- cc.Node.prototype.removeChild.call(this, a, c)
- },
- removeAllChildren: function(a) {
- this.parallaxArray.length = 0;
- cc.Node.prototype.removeAllChildren.call(this, a)
- },
- visit: function() {
- var a = this._absolutePosition();
- if (!cc.pointEqualToPoint(a, this._lastPosition)) {
- for (var c = this.parallaxArray, d = 0, e = c.length; d < e; d++) {
- var f = c[d];
- f.getChild().setPosition(-a.x + a.x * f.getRatio().x + f.getOffset().x, -a.y + a.y * f.getRatio().y + f.getOffset().y)
- }
- this._lastPosition = a
- }
- cc.Node.prototype.visit.call(this)
- },
- _absolutePosition: function() {
- for (var a = this._position, c = this; null != c.parent;) c = c.parent, a = cc.pAdd(a, c.getPosition());
- return a
- }
- });
- cc.ParallaxNode.create = function() {
- return new cc.ParallaxNode
- };
- if (cc.sys._supportWebAudio) {
- var _ctx = cc.webAudioContext = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext);
- cc.WebAudio = cc.Class.extend({
- _events: null,
- _buffer: null,
- _sourceNode: null,
- _volumeNode: null,
- src: null,
- preload: null,
- autoplay: null,
- controls: null,
- mediagroup: null,
- currentTime: 0,
- startTime: 0,
- duration: 0,
- _loop: null,
- _volume: 1,
- _pauseTime: 0,
- _paused: !1,
- _stopped: !0,
- _loadState: -1,
- ctor: function(a) {
- this._events = {};
- this.src = a;
- this._volumeNode = _ctx.createGain ? _ctx.createGain() : _ctx.createGainNode();
- this._onSuccess1 = this._onSuccess.bind(this);
- this._onError1 = this._onError.bind(this)
- },
- _play: function(a) {
- var c = this,
- d = c._sourceNode = _ctx.createBufferSource(),
- e = c._volumeNode;
- a = a || 0;
- d.buffer = c._buffer;
- e.gain.value = c._volume;
- d.connect(e);
- e.connect(_ctx.destination);
- d.loop = c._loop;
- d.onended = function() {
- c._stopped = !0
- };
- c._paused = !1;
- c._stopped = !1;
- d.start ? d.start(0, a) : d.noteGrainOn ? (e = d.buffer.duration, c.loop ? d.noteGrainOn(0, a, e) : d.noteGrainOn(0, a, e - a)) : d.noteOn(0);
- c._pauseTime = 0
- },
- _stop: function() {
- var a = this._sourceNode;
- this._stopped || (a.stop ? a.stop(0) : a.noteOff(0), this._stopped = !0)
- },
- play: function() {
- if (-1 == this._loadState) this._loadState = 0;
- else if (1 == this._loadState) {
- var a = this._sourceNode;
- if (this._stopped || !(a && 2 == a.playbackState)) this.startTime = _ctx.currentTime, this._play(0)
- }
- },
- pause: function() {
- this._pauseTime = _ctx.currentTime;
- this._paused = !0;
- this._stop()
- },
- resume: function() {
- this._paused && this._play(this._buffer ? (this._pauseTime - this.startTime) % this._buffer.duration : 0)
- },
- stop: function() {
- this._pauseTime = 0;
- this._paused = !1;
- this._stop()
- },
- load: function() {
- var a = this;
- if (1 != a._loadState) {
- a._loadState = -1;
- a.played = !1;
- a.ended = !0;
- var c = new XMLHttpRequest;
- c.open("GET", a.src, !0);
- c.responseType = "arraybuffer";
- c.onload = function() {
- _ctx.decodeAudioData(c.response, a._onSuccess1, a._onError1)
- };
- c.send()
- }
- },
- addEventListener: function(a, c) {
- this._events[a] = c.bind(this)
- },
- removeEventListener: function(a) {
- delete this._events[a]
- },
- canplay: function() {
- return cc.sys._supportWebAudio
- },
- _onSuccess: function(a) {
- this._buffer = a;
- a = this._events.success;
- var c = this._events.canplaythrough;
- a && a();
- c && c();
- (0 == this._loadState || "autoplay" == this.autoplay || !0 == this.autoplay) && this._play();
- this._loadState = 1
- },
- _onError: function() {
- var a = this._events.error;
- a && a();
- this._loadState = -2
- },
- cloneNode: function() {
- var a = new cc.WebAudio(this.src);
- a.volume = this.volume;
- a._loadState = this._loadState;
- a._buffer = this._buffer;
- (0 == a._loadState || -1 == a._loadState) && a.load();
- return a
- }
- });
- _p = cc.WebAudio.prototype;
- cc.defineGetterSetter(_p, "loop", function() {
- return this._loop
- }, function(a) {
- this._loop = a;
- this._sourceNode && (this._sourceNode.loop = a)
- });
- cc.defineGetterSetter(_p, "volume", function() {
- return this._volume
- }, function(a) {
- this._volume = a;
- this._volumeNode.gain.value = a
- });
- cc.defineGetterSetter(_p, "paused", function() {
- return this._paused
- });
- cc.defineGetterSetter(_p, "ended", function() {
- var a = this._sourceNode;
- return !this._paused && (this._stopped || !a || 3 == a.playbackState)
- });
- cc.defineGetterSetter(_p, "played", function() {
- var a = this._sourceNode;
- return a && 2 == a.playbackState
- })
- }
- cc.AudioEngine = cc.Class.extend({
- _soundSupported: !1,
- _currMusic: null,
- _currMusicPath: null,
- _musicPlayState: 0,
- _audioID: 0,
- _effects: {},
- _audioPool: {},
- _effectsVolume: 1,
- _maxAudioInstance: 5,
- _effectPauseCb: null,
- _playings: [],
- ctor: function() {
- this._soundSupported = 0 < cc._audioLoader._supportedAudioTypes.length;
- this._effectPauseCb && (this._effectPauseCb = this._effectPauseCb.bind(this))
- },
- willPlayMusic: function() {
- return !1
- },
- getEffectsVolume: function() {
- return this._effectsVolume
- },
- playMusic: function(a, c) {
- if (this._soundSupported) {
- var d = this._currMusic;
- d && this._stopAudio(d);
- a != this._currMusicPath && (this._currMusic = d = this._getAudioByUrl(a), this._currMusicPath = a);
- d && (d.loop = c || !1, this._playMusic(d))
- }
- },
- _getAudioByUrl: function(a) {
- var c = cc.loader,
- d = c.getRes(a);
- d || (c.load(a), d = c.getRes(a));
- return d
- },
- _playMusic: function(a) {
- a.ended || (a.stop ? a.stop() : (a.pause(), a.currentTime = 0));
- this._musicPlayState = 2;
- a.play()
- },
- stopMusic: function(a) {
- if (0 < this._musicPlayState) {
- var c = this._currMusic;
- c && this._stopAudio(c) && (a && cc.loader.release(this._currMusicPath), this._currMusicPath = this._currMusic = null, this._musicPlayState = 0)
- }
- },
- _stopAudio: function(a) {
- return a && !a.ended ? (a.stop ? a.stop() : a.duration && Infinity != a.duration ? a.currentTime = a.duration : a.pause(), !0) : !1
- },
- pauseMusic: function() {
- 2 == this._musicPlayState && (this._currMusic.pause(), this._musicPlayState = 1)
- },
- resumeMusic: function() {
- 1 == this._musicPlayState && (this._resumeAudio(this._currMusic), this._musicPlayState = 2)
- },
- _resumeAudio: function(a) {
- a && !a.ended && (a.resume ? a.resume() : a.play())
- },
- rewindMusic: function() {
- this._currMusic && this._playMusic(this._currMusic)
- },
- getMusicVolume: function() {
- return 0 == this._musicPlayState ? 0 : this._currMusic.volume
- },
- setMusicVolume: function(a) {
- 0 < this._musicPlayState && (this._currMusic.volume = Math.min(Math.max(a, 0), 1))
- },
- isMusicPlaying: function() {
- return 2 == this._musicPlayState && this._currMusic && !this._currMusic.ended
- },
- _getEffectList: function(a) {
- var c = this._audioPool[a];
- c || (c = this._audioPool[a] = []);
- return c
- },
- _getEffect: function(a) {
- var c;
- if (!this._soundSupported) return null;
- for (var d = this._getEffectList(a), e = 0, f = d.length; e < f; e++) {
- var g = d[e];
- if (g.ended) {
- c = g;
- c.currentTime = 0;
- window.chrome && c.load();
- break
- }
- }
- if (!c) {
- if (d.length >= this._maxAudioInstance) return cc.log("Error: " + a + " greater than " + this._maxAudioInstance), null;
- c = this._getAudioByUrl(a);
- if (!c) return null;
- c = c.cloneNode(!0);
- this._effectPauseCb && cc._addEventListener(c, "pause", this._effectPauseCb);
- c.volume = this._effectsVolume;
- d.push(c)
- }
- return c
- },
- playEffect: function(a, c) {
- var d = this._getEffect(a);
- if (!d) return null;
- d.loop = c || !1;
- d.play();
- var e = this._audioID++;
- this._effects[e] = d;
- return e
- },
- setEffectsVolume: function(a) {
- a = this._effectsVolume = Math.min(Math.max(a, 0), 1);
- var c = this._effects,
- d;
- for (d in c) c[d].volume = a
- },
- pauseEffect: function(a) {
- (a = this._effects[a]) && !a.ended && a.pause()
- },
- pauseAllEffects: function() {
- var a = this._effects,
- c;
- for (c in a) {
- var d = a[c];
- d.ended || d.pause()
- }
- },
- resumeEffect: function(a) {
- this._resumeAudio(this._effects[a])
- },
- resumeAllEffects: function() {
- var a = this._effects,
- c;
- for (c in a) this._resumeAudio(a[c])
- },
- stopEffect: function(a) {
- this._stopAudio(this._effects[a]);
- delete this._effects[a]
- },
- stopAllEffects: function() {
- var a = this._effects,
- c;
- for (c in a) this._stopAudio(a[c]), delete a[c]
- },
- unloadEffect: function(a) {
- var c = cc.loader,
- d = this._effects,
- e = this._getEffectList(a);
- c.release(a);
- if (0 != e.length) {
- c = e[0].src;
- delete this._audioPool[a];
- for (var f in d) d[f].src == c && (this._stopAudio(d[f]), delete d[f])
- }
- },
- end: function() {
- this.stopMusic();
- this.stopAllEffects()
- },
- _pausePlaying: function() {
- var a = this._effects,
- c, d;
- for (d in a)
- if ((c = a[d]) && !c.ended && !c.paused) this._playings.push(c), c.pause();
- this.isMusicPlaying() && (this._playings.push(this._currMusic), this._currMusic.pause())
- },
- _resumePlaying: function() {
- for (var a = this._playings, c = 0, d = a.length; c < d; c++) this._resumeAudio(a[c]);
- a.length = 0
- }
- });
- !cc.sys._supportWebAudio && 0 > cc.sys._supportMultipleAudio && (cc.AudioEngineForSingle = cc.AudioEngine.extend({
- _waitingEffIds: [],
- _pausedEffIds: [],
- _currEffect: null,
- _maxAudioInstance: 2,
- _effectCache4Single: {},
- _needToResumeMusic: !1,
- _expendTime4Music: 0,
- _isHiddenMode: !1,
- _playMusic: function(a) {
- this._stopAllEffects();
- this._super(a)
- },
- resumeMusic: function() {
- 1 == this._musicPlayState && (this._stopAllEffects(), this._needToResumeMusic = !1, this._expendTime4Music = 0, this._super())
- },
- playEffect: function(a, c) {
- var d = this._currEffect,
- e = c ? this._getEffect(a) : this._getSingleEffect(a);
- if (!e) return null;
- e.loop = c || !1;
- var f = this._audioID++;
- this._effects[f] = e;
- this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
- d ? (d != e && this._waitingEffIds.push(this._currEffectId), this._waitingEffIds.push(f), d.pause()) : (this._currEffect = e, this._currEffectId = f, e.play());
- return f
- },
- pauseEffect: function(a) {
- cc.log("pauseEffect not supported in single audio mode!")
- },
- pauseAllEffects: function() {
- var a = this._waitingEffIds,
- c = this._pausedEffIds,
- d = this._currEffect;
- if (d) {
- for (var e = 0, f = a.length; e < f; e++) c.push(a[e]);
- a.length = 0;
- c.push(this._currEffectId);
- d.pause()
- }
- },
- resumeEffect: function(a) {
- cc.log("resumeEffect not supported in single audio mode!")
- },
- resumeAllEffects: function() {
- var a = this._waitingEffIds,
- c = this._pausedEffIds;
- this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
- for (var d = 0, e = c.length; d < e; d++) a.push(c[d]);
- c.length = 0;
- if (!this._currEffect && 0 <= a.length && (a = a.pop(), c = this._effects[a])) this._currEffectId = a, this._currEffect = c, this._resumeAudio(c)
- },
- stopEffect: function(a) {
- var c = this._currEffect,
- d = this._waitingEffIds,
- e = this._pausedEffIds;
- c && this._currEffectId == a ? this._stopAudio(c) : (c = d.indexOf(a), 0 <= c ? d.splice(c, 1) : (c = e.indexOf(a), 0 <= c && e.splice(c, 1)))
- },
- stopAllEffects: function() {
- this._stopAllEffects();
- !this._currEffect && this._needToResumeMusic && (this._resumeAudio(this._currMusic), this._musicPlayState = 2, this._needToResumeMusic = !1, this._expendTime4Music = 0)
- },
- unloadEffect: function(a) {
- var c = cc.loader,
- d = this._effects,
- e = this._effectCache4Single,
- f = this._getEffectList(a),
- g = this._currEffect;
- c.release(a);
- if (0 != f.length || e[a]) {
- c = 0 < f.length ? f[0].src : e[a].src;
- delete this._audioPool[a];
- delete e[a];
- for (var h in d) d[h].src == c && delete d[h];
- g && g.src == c && this._stopAudio(g)
- }
- },
- _getSingleEffect: function(a) {
- var c = this._effectCache4Single[a],
- d = this._waitingEffIds,
- e = this._pausedEffIds,
- f = this._effects;
- if (c) c.currentTime = 0;
- else {
- c = this._getAudioByUrl(a);
- if (!c) return null;
- c = c.cloneNode(!0);
- this._effectPauseCb && cc._addEventListener(c, "pause", this._effectPauseCb);
- c.volume = this._effectsVolume;
- this._effectCache4Single[a] = c
- }
- a = 0;
- for (var g = d.length; a < g;) f[d[a]] == c ? d.splice(a, 1) : a++;
- a = 0;
- for (g = e.length; a < g;) f[e[a]] == c ? e.splice(a, 1) : a++;
- c._isToPlay = !0;
- return c
- },
- _stopAllEffects: function() {
- var a = this._currEffect,
- c = this._audioPool,
- d = this._effectCache4Single,
- e = this._waitingEffIds,
- f = this._pausedEffIds;
- if (a || !(0 == e.length && 0 == f.length)) {
- for (var g in d) {
- var h = d[g];
- h.duration && Infinity != h.duration && (h.currentTime = h.duration)
- }
- e.length = 0;
- f.length = 0;
- for (g in c) {
- d = c[g];
- e = 0;
- for (f = d.length; e < f; e++) h = d[e], h.loop = !1, h.duration && Infinity != h.duration && (h.currentTime = h.duration)
- }
- a && this._stopAudio(a)
- }
- },
- _effectPauseCb: function() {
- if (!this._isHiddenMode) {
- var a = this._getWaitingEffToPlay();
- if (a) a._isToPlay ? (delete a._isToPlay, a.play()) : this._resumeAudio(a);
- else if (this._needToResumeMusic) {
- a = this._currMusic;
- if (a.duration && Infinity != a.duration) {
- var c = a.currentTime + this._expendTime4Music,
- c = c - a.duration * (c / a.duration | 0);
- a.currentTime = c
- }
- this._expendTime4Music = 0;
- this._resumeAudio(a);
- this._musicPlayState = 2;
- this._needToResumeMusic = !1
- }
- }
- },
- _getWaitingEffToPlay: function() {
- var a = this._waitingEffIds,
- c = this._effects,
- d = this._currEffect,
- e = d ? d.currentTime - (d.startTime || 0) : 0;
- for (this._expendTime4Music += e; 0 != a.length;) {
- var f = a.pop();
- if (d = c[f]) {
- if (d._isToPlay || d.loop || d.duration && d.currentTime + e < d.duration) return this._currEffectId = f, this._currEffect = d, !d._isToPlay && (d.duration && Infinity != d.duration) && (a = d.currentTime + e, a -= d.duration * (a / d.duration | 0), d.currentTime = a), d._isToPlay = !1, d;
- d.duration && Infinity != d.duration && (d.currentTime = d.duration)
- }
- }
- return this._currEffect = this._currEffectId = null
- },
- _pausePlaying: function() {
- var a = this._currEffect;
- this._isHiddenMode = !0;
- if (a = 2 == this._musicPlayState ? this._currMusic : a) this._playings.push(a), a.pause()
- },
- _resumePlaying: function() {
- var a = this._playings;
- this._isHiddenMode = !1;
- 0 < a.length && (this._resumeAudio(a[0]), a.length = 0)
- }
- }));
- cc._audioLoader = {
- _supportedAudioTypes: null,
- getBasePath: function() {
- return cc.loader.audioPath
- },
- _load: function(a, c, d, e, f, g, h) {
- var k = this,
- m = cc.loader,
- n = cc.path,
- q = this._supportedAudioTypes,
- r = "";
- if (0 == q.length) return h("can not support audio!");
- if (-1 == e) r = (n.extname(a) || "").toLowerCase(), k.audioTypeSupported(r) || (r = q[0], e = 0);
- else if (e < q.length) r = q[e];
- else return h("can not found the resource of audio! Last match url is : " + a); if (0 <= f.indexOf(r)) return k._load(a, c, d, e + 1, f, g, h);
- a = n.changeExtname(a, r);
- f.push(r);
- g = k._loadAudio(a, g, function(m) {
- if (m) return k._load(a, c, d, e + 1, f, g, h);
- h(null, g)
- }, e == q.length - 1);
- m.cache[c] = g
- },
- audioTypeSupported: function(a) {
- return !a ? !1 : 0 <= this._supportedAudioTypes.indexOf(a.toLowerCase())
- },
- _loadAudio: function(a, c, d, e) {
- var f = "file://" == location.origin ? Audio : cc.WebAudio || Audio;
- 2 == arguments.length ? (d = c, c = new f) : 3 < arguments.length && !c && (c = new f);
- c.src = a;
- c.preload = "auto";
- f = navigator.userAgent;
- /Mobile/.test(f) && (/iPhone OS/.test(f) || /iPad/.test(f) || /Firefox/.test(f)) || /MSIE/.test(f) ? (c.load(), d(null, c)) : (cc._addEventListener(c, "canplaythrough", function() {
- d(null, c);
- this.removeEventListener("canplaythrough", arguments.callee, !1);
- this.removeEventListener("error", arguments.callee, !1)
- }, !1), cc._addEventListener(c, "error", function() {
- d("load " + a + " failed");
- e && (this.removeEventListener("canplaythrough", arguments.callee, !1), this.removeEventListener("error", arguments.callee, !1))
- }, !1), c.load());
- return c
- },
- load: function(a, c, d, e) {
- this._load(a, c, d, -1, [], null, e)
- }
- };
- cc._audioLoader._supportedAudioTypes = function() {
- var a = cc.newElement("audio"),
- c = [];
- if (a.canPlayType) {
- var d = function(c) {
- c = a.canPlayType(c);
- return "no" != c && "" != c
- };
- d('audio/ogg; codecs\x3d"vorbis"') && c.push(".ogg");
- d("audio/mpeg") && c.push(".mp3");
- d('audio/wav; codecs\x3d"1"') && c.push(".wav");
- d("audio/mp4") && c.push(".mp4");
- (d("audio/x-m4a") || d("audio/aac")) && c.push(".m4a")
- }
- return c
- }();
- cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader);
- cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle : new cc.AudioEngine;
- cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function() {
- cc.audioEngine._pausePlaying()
- });
- cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
- cc.audioEngine._resumePlaying()
- });
- cc.CONTROL_EVENT_TOTAL_NUMBER = 9;
- cc.CONTROL_EVENT_TOUCH_DOWN = 1;
- cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE = 2;
- cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE = 4;
- cc.CONTROL_EVENT_TOUCH_DRAG_ENTER = 8;
- cc.CONTROL_EVENT_TOUCH_DRAG_EXIT = 16;
- cc.CONTROL_EVENT_TOUCH_UP_INSIDE = 32;
- cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE = 64;
- cc.CONTROL_EVENT_TOUCH_CANCEL = 128;
- cc.CONTROL_EVENT_VALUECHANGED = 256;
- cc.CONTROL_STATE_NORMAL = 1;
- cc.CONTROL_STATE_HIGHLIGHTED = 2;
- cc.CONTROL_STATE_DISABLED = 4;
- cc.CONTROL_STATE_SELECTED = 8;
- cc.CONTROL_STATE_INITIAL = 8;
- cc.Control = cc.Layer.extend({
- _isOpacityModifyRGB: !1,
- _hasVisibleParents: !1,
- _touchListener: null,
- _className: "Control",
- isOpacityModifyRGB: function() {
- return this._isOpacityModifyRGB
- },
- setOpacityModifyRGB: function(a) {
- this._isOpacityModifyRGB = a;
- for (var c = this.getChildren(), d = 0, e = c.length; d < e; d++) {
- var f = c[d];
- f && f.setOpacityModifyRGB(a)
- }
- },
- _state: cc.CONTROL_STATE_NORMAL,
- getState: function() {
- return this._state
- },
- _enabled: !1,
- _selected: !1,
- _highlighted: !1,
- _dispatchTable: null,
- setEnabled: function(a) {
- this._state = (this._enabled = a) ? cc.CONTROL_STATE_NORMAL : cc.CONTROL_STATE_DISABLED;
- this.needsLayout()
- },
- isEnabled: function() {
- return this._enabled
- },
- setSelected: function(a) {
- this._selected = a;
- this.needsLayout()
- },
- isSelected: function() {
- return this._selected
- },
- setHighlighted: function(a) {
- this._highlighted = a;
- this.needsLayout()
- },
- isHighlighted: function() {
- return this._highlighted
- },
- hasVisibleParents: function() {
- for (var a = this.getParent(); null != a; a = a.getParent())
- if (!a.isVisible()) return !1;
- return !0
- },
- ctor: function() {
- cc.Layer.prototype.ctor.call(this);
- this._dispatchTable = {};
- this._color = cc.color.WHITE
- },
- init: function() {
- if (cc.Layer.prototype.init.call(this)) {
- this._state = cc.CONTROL_STATE_NORMAL;
- this._enabled = !0;
- this._highlighted = this._selected = !1;
- var a = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE
- });
- this.onTouchBegan && (a.onTouchBegan = this.onTouchBegan.bind(this));
- this.onTouchMoved && (a.onTouchMoved = this.onTouchMoved.bind(this));
- this.onTouchEnded && (a.onTouchEnded = this.onTouchEnded.bind(this));
- this.onTouchCancelled && (a.onTouchCancelled = this.onTouchCancelled.bind(this));
- this._touchListener = a;
- return !0
- }
- return !1
- },
- onEnter: function() {
- var a = this._touchListener;
- a._isRegistered() || cc.eventManager.addListener(a, this);
- cc.Node.prototype.onEnter.call(this)
- },
- sendActionsForControlEvents: function(a) {
- for (var c = 0, d = cc.CONTROL_EVENT_TOTAL_NUMBER; c < d; c++)
- if (a & 1 << c)
- for (var e = this._dispatchListforControlEvent(1 << c), f = 0, g = e.length; f < g; f++) e[f].invoke(this)
- },
- addTargetWithActionForControlEvents: function(a, c, d) {
- for (var e = 0, f = cc.CONTROL_EVENT_TOTAL_NUMBER; e < f; e++) d & 1 << e && this._addTargetWithActionForControlEvent(a, c, 1 << e)
- },
- removeTargetWithActionForControlEvents: function(a, c, d) {
- for (var e = 0, f = cc.CONTROL_EVENT_TOTAL_NUMBER; e < f; e++) d & 1 << e && this._removeTargetWithActionForControlEvent(a, c, 1 << e)
- },
- getTouchLocation: function(a) {
- a = a.getLocation();
- return this.convertToNodeSpace(a)
- },
- isTouchInside: function(a) {
- a = a.getLocation();
- a = this.getParent().convertToNodeSpace(a);
- return cc.rectContainsPoint(this.getBoundingBox(), a)
- },
- _invocationWithTargetAndActionForControlEvent: function(a, c, d) {
- return null
- },
- _dispatchListforControlEvent: function(a) {
- a = a.toString();
- this._dispatchTable[a] || (this._dispatchTable[a] = []);
- return this._dispatchTable[a]
- },
- _addTargetWithActionForControlEvent: function(a, c, d) {
- a = new cc.Invocation(a, c, d);
- this._dispatchListforControlEvent(d).push(a)
- },
- _removeTargetWithActionForControlEvent: function(a, c, d) {
- d = this._dispatchListforControlEvent(d);
- if (!a && !c) d.length = 0;
- else
- for (var e = 0; e < d.length;) {
- var f = d[e],
- g = !0;
- a && (g = a == f.getTarget());
- c && (g = g && c == f.getAction());
- g ? cc.arrayRemoveObject(d, f) : e++
- }
- },
- needsLayout: function() {}
- });
- _p = cc.Control.prototype;
- cc.defineGetterSetter(_p, "state", _p.getState);
- cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
- cc.defineGetterSetter(_p, "selected", _p.isSelected, _p.setSelected);
- cc.defineGetterSetter(_p, "highlighted", _p.isHighlighted, _p.setHighlighted);
- _p = null;
- cc.Control.create = function() {
- var a = new cc.Control;
- return a && a.init() ? a : null
- };
- cc.CONTROL_ZOOM_ACTION_TAG = 3435855873;
- cc.ControlButton = cc.Control.extend({
- _doesAdjustBackgroundImage: !1,
- zoomOnTouchDown: !1,
- _preferredSize: null,
- _labelAnchorPoint: null,
- _currentTitle: null,
- _currentTitleColor: null,
- _titleLabel: null,
- _backgroundSprite: null,
- _opacity: 0,
- _isPushed: !1,
- _titleDispatchTable: null,
- _titleColorDispatchTable: null,
- _titleLabelDispatchTable: null,
- _backgroundSpriteDispatchTable: null,
- _parentInited: !1,
- _marginV: 0,
- _marginH: 0,
- _className: "ControlButton",
- ctor: function(a, c, d) {
- cc.Control.prototype.ctor.call(this);
- this._preferredSize = cc.size(0, 0);
- this._labelAnchorPoint = cc.p(0, 0);
- this._currentTitle = "";
- this._currentTitleColor = cc.color.WHITE;
- this._titleDispatchTable = {};
- this._titleColorDispatchTable = {};
- this._titleLabelDispatchTable = {};
- this._backgroundSpriteDispatchTable = {};
- void 0 != d ? this.initWithTitleAndFontNameAndFontSize(a, c, d) : void 0 != c ? this.initWithLabelAndBackgroundSprite(a, c) : void 0 != a ? this.initWithBackgroundSprite(a) : this.init()
- },
- init: function() {
- return this.initWithLabelAndBackgroundSprite(cc.LabelTTF.create("", "Arial", 12), cc.Scale9Sprite.create())
- },
- needsLayout: function() {
- if (this._parentInited) {
- this._titleLabel && this._titleLabel.setVisible(!1);
- this._backgroundSprite && this._backgroundSprite.setVisible(!1);
- this.setLabelAnchorPoint(this._labelAnchorPoint);
- var a = this._state;
- this._currentTitle = this.getTitleForState(a);
- this._currentTitleColor = this.getTitleColorForState(a);
- var c = this._titleLabel = this.getTitleLabelForState(a);
- c && c.setString && c.setString(this._currentTitle);
- c && c.setColor(this._currentTitleColor);
- var d = this.getContentSize();
- c && c.setPosition(d.width / 2, d.height / 2);
- (a = this._backgroundSprite = this.getBackgroundSpriteForState(a)) && a.setPosition(d.width / 2, d.height / 2);
- d = cc.size(0, 0);
- if (c) {
- var e = c.getBoundingBox();
- d.width = e.width;
- d.height = e.height
- }
- this._doesAdjustBackgroundImage ? a && a.setContentSize(d.width + 2 * this._marginH, d.height + 2 * this._marginV) : a && (e = a.getPreferredSize(), e = cc.size(e.width, e.height), 0 >= e.width && (e.width = d.width), 0 >= e.height && (e.height = d.height), a.setContentSize(e));
- d = c ? c.getBoundingBox() : cc.rect(0, 0, 0, 0);
- e = a ? a.getBoundingBox() : cc.rect(0, 0, 0, 0);
- d = cc.rectUnion(d, e);
- this.setContentSize(d.width, d.height);
- d = this.getContentSize();
- c && (c.setPosition(d.width / 2, d.height / 2), c.setVisible(!0));
- a && (a.setPosition(d.width / 2, d.height / 2), a.setVisible(!0))
- }
- },
- initWithLabelAndBackgroundSprite: function(a, c) {
- if (!a) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null";
- if (!c) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): backgroundSprite should be non-null";
- if (cc.Control.prototype.init.call(this, !0)) {
- this._parentInited = !0;
- this._titleDispatchTable = {};
- this._titleColorDispatchTable = {};
- this._titleLabelDispatchTable = {};
- this._backgroundSpriteDispatchTable = {};
- this._isPushed = !1;
- this.zoomOnTouchDown = !0;
- this._currentTitle = null;
- this.setAdjustBackgroundImage(!0);
- this.setPreferredSize(cc.size(0, 0));
- this.zoomOnTouchDown = !0;
- this.ignoreAnchorPointForPosition(!1);
- this.setAnchorPoint(0.5, 0.5);
- this._titleLabel = a;
- this._backgroundSprite = c;
- this.setOpacity(255);
- this.setOpacityModifyRGB(!0);
- var d = a.getString();
- this.setTitleForState(d, cc.CONTROL_STATE_NORMAL);
- this.setTitleColorForState(a.getColor(), cc.CONTROL_STATE_NORMAL);
- this.setTitleLabelForState(a, cc.CONTROL_STATE_NORMAL);
- this.setBackgroundSpriteForState(c, cc.CONTROL_STATE_NORMAL);
- this._state = cc.CONTROL_STATE_NORMAL;
- this._marginH = 24;
- this._marginV = 12;
- this._labelAnchorPoint = cc.p(0.5, 0.5);
- this.setPreferredSize(cc.size(0, 0));
- this.needsLayout();
- return !0
- }
- return !1
- },
- initWithTitleAndFontNameAndFontSize: function(a, c, d) {
- a = cc.LabelTTF.create(a, c, d);
- return this.initWithLabelAndBackgroundSprite(a, cc.Scale9Sprite.create())
- },
- initWithBackgroundSprite: function(a) {
- var c = cc.LabelTTF.create("", "Arial", 30);
- return this.initWithLabelAndBackgroundSprite(c, a)
- },
- doesAdjustBackgroundImage: function() {
- return this._doesAdjustBackgroundImage
- },
- setAdjustBackgroundImage: function(a) {
- this._doesAdjustBackgroundImage = a;
- this.needsLayout()
- },
- getZoomOnTouchDown: function() {
- return this.zoomOnTouchDown
- },
- setZoomOnTouchDown: function(a) {
- return this.zoomOnTouchDown = a
- },
- getPreferredSize: function() {
- return this._preferredSize
- },
- setPreferredSize: function(a) {
- if (0 === a.width && 0 === a.height) this._doesAdjustBackgroundImage = !0;
- else {
- this._doesAdjustBackgroundImage = !1;
- var c = this._backgroundSpriteDispatchTable,
- d;
- for (d in c) c[d].setPreferredSize(a)
- }
- this._preferredSize = a;
- this.needsLayout()
- },
- getLabelAnchorPoint: function() {
- return this._labelAnchorPoint
- },
- setLabelAnchorPoint: function(a) {
- this._labelAnchorPoint = a;
- this._titleLabel && this._titleLabel.setAnchorPoint(a)
- },
- _getCurrentTitle: function() {
- return this._currentTitle
- },
- _getCurrentTitleColor: function() {
- return this._currentTitleColor
- },
- getOpacity: function() {
- return this._opacity
- },
- setOpacity: function(a) {
- cc.Control.prototype.setOpacity.call(this, a);
- var c = this._backgroundSpriteDispatchTable,
- d;
- for (d in c) c[d].setOpacity(a)
- },
- setColor: function(a) {
- cc.Control.prototype.setColor.call(this, a);
- var c = this._backgroundSpriteDispatchTable,
- d;
- for (d in c) c[d].setColor(a)
- },
- getColor: function() {
- var a = this._realColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- isPushed: function() {
- return this._isPushed
- },
- _getVerticalMargin: function() {
- return this._marginV
- },
- _getHorizontalOrigin: function() {
- return this._marginH
- },
- setMargins: function(a, c) {
- this._marginV = c;
- this._marginH = a;
- this.needsLayout()
- },
- setEnabled: function(a) {
- cc.Control.prototype.setEnabled.call(this, a);
- this.needsLayout()
- },
- setSelected: function(a) {
- cc.Control.prototype.setSelected.call(this, a);
- this.needsLayout()
- },
- setHighlighted: function(a) {
- this._state = a ? cc.CONTROL_STATE_HIGHLIGHTED : cc.CONTROL_STATE_NORMAL;
- cc.Control.prototype.setHighlighted.call(this, a);
- (a = this.getActionByTag(cc.CONTROL_ZOOM_ACTION_TAG)) && this.stopAction(a);
- this.needsLayout();
- this.zoomOnTouchDown && (a = this.isHighlighted() && this.isEnabled() && !this.isSelected() ? 1.1 : 1, a = cc.ScaleTo.create(0.05, a), a.setTag(cc.CONTROL_ZOOM_ACTION_TAG), this.runAction(a))
- },
- onTouchBegan: function(a, c) {
- if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible() || !this.hasVisibleParents()) return !1;
- this._isPushed = !0;
- this.setHighlighted(!0);
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DOWN);
- return !0
- },
- onTouchMoved: function(a, c) {
- if (!this._enabled || !this._isPushed || this._selected) this._highlighted && this.setHighlighted(!1);
- else {
- var d = this.isTouchInside(a);
- d && !this._highlighted ? (this.setHighlighted(!0), this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_ENTER)) : d && this._highlighted ? this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE) : !d && this._highlighted ? (this.setHighlighted(!1), this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_EXIT)) : !d && !this._highlighted && this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE)
- }
- },
- onTouchEnded: function(a, c) {
- this._isPushed = !1;
- this.setHighlighted(!1);
- this.isTouchInside(a) ? this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_UP_INSIDE) : this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE)
- },
- onTouchCancelled: function(a, c) {
- this._isPushed = !1;
- this.setHighlighted(!1);
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_CANCEL)
- },
- getTitleForState: function(a) {
- var c = this._titleDispatchTable;
- return c ? c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL] : ""
- },
- setTitleForState: function(a, c) {
- this._titleDispatchTable[c] = a || "";
- this.getState() == c && this.needsLayout()
- },
- getTitleColorForState: function(a) {
- return (a = this._titleColorDispatchTable[a]) ? a : (a = this._titleColorDispatchTable[cc.CONTROL_STATE_NORMAL]) ? a : cc.color.WHITE
- },
- setTitleColorForState: function(a, c) {
- this._titleColorDispatchTable[c] = a;
- this.getState() == c && this.needsLayout()
- },
- getTitleLabelForState: function(a) {
- var c = this._titleLabelDispatchTable;
- return c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL]
- },
- setTitleLabelForState: function(a, c) {
- var d = this._titleLabelDispatchTable;
- if (d[c]) {
- var e = d[c];
- e && this.removeChild(e, !0)
- }
- d[c] = a;
- a.setVisible(!1);
- a.setAnchorPoint(0.5, 0.5);
- this.addChild(a, 1);
- this.getState() == c && this.needsLayout()
- },
- setTitleTTFForState: function(a, c) {
- var d = this.getTitleForState(c);
- d || (d = "");
- this.setTitleLabelForState(cc.LabelTTF.create(d, a, 12), c)
- },
- getTitleTTFForState: function(a) {
- a = this.getTitleLabelForState(a);
- return null != a && a instanceof cc.LabelTTF ? a.getFontName() : ""
- },
- setTitleTTFSizeForState: function(a, c) {
- var d = this.getTitleLabelForState(c);
- null != d && d instanceof cc.LabelTTF && d.setFontSize(a)
- },
- getTitleTTFSizeForState: function(a) {
- a = this.getTitleLabelForState(a);
- return null != a && a instanceof cc.LabelTTF ? a.getFontSize() : 0
- },
- setTitleBMFontForState: function(a, c) {
- var d = this.getTitleForState(c);
- d || (d = "");
- this.setTitleLabelForState(cc.LabelBMFont.create(d, a), c)
- },
- getTitleBMFontForState: function(a) {
- a = this.getTitleLabelForState(a);
- return null != a && a instanceof cc.LabelBMFont ? a.getFntFile() : ""
- },
- getBackgroundSpriteForState: function(a) {
- var c = this._backgroundSpriteDispatchTable;
- return c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL]
- },
- setBackgroundSpriteForState: function(a, c) {
- var d = this._backgroundSpriteDispatchTable;
- if (d[c]) {
- var e = d[c];
- e && this.removeChild(e, !0)
- }
- d[c] = a;
- a.setVisible(!1);
- a.setAnchorPoint(0.5, 0.5);
- this.addChild(a);
- d = this._preferredSize;
- (0 !== d.width || 0 !== d.height) && a.setPreferredSize(d);
- this._state === c && this.needsLayout()
- },
- setBackgroundSpriteFrameForState: function(a, c) {
- var d = cc.Scale9Sprite.createWithSpriteFrame(a);
- this.setBackgroundSpriteForState(d, c)
- }
- });
- _p = cc.ControlButton.prototype;
- cc.defineGetterSetter(_p, "adjustBackground", _p.getAdjustBackgroundImage, _p.setAdjustBackgroundImage);
- cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize);
- cc.defineGetterSetter(_p, "labelAnchor", _p.getLabelAnchorPoint, _p.setLabelAnchorPoint);
- _p = null;
- cc.ControlButton.create = function(a, c, d) {
- return new cc.ControlButton(a, c, d)
- };
- cc.RGBA = function(a, c, d, e) {
- this.r = a;
- this.g = c;
- this.b = d;
- this.a = e
- };
- cc.HSV = function(a, c, d) {
- this.h = a;
- this.s = c;
- this.v = d
- };
- cc.ControlUtils = {};
- cc.ControlUtils.addSpriteToTargetWithPosAndAnchor = function(a, c, d, e) {
- a = cc.Sprite.create("#" + a);
- if (!a) return null;
- a.setPosition(d);
- a.setAnchorPoint(e);
- c.addChild(a);
- return a
- };
- cc.ControlUtils.HSVfromRGB = function(a) {
- var c = new cc.HSV,
- d, e;
- d = a.r < a.g ? a.r : a.g;
- d = d < a.b ? d : a.b;
- e = a.r > a.g ? a.r : a.g;
- e = e > a.b ? e : a.b;
- c.v = e;
- d = e - d;
- if (0 < e) c.s = d / e;
- else return c.s = 0, c.h = -1, c;
- c.h = a.r >= e ? (a.g - a.b) / d : a.g >= e ? 2 + (a.b - a.r) / d : 4 + (a.r - a.g) / d;
- c.h *= 60;
- 0 > c.h && (c.h += 360);
- return c
- };
- cc.ControlUtils.RGBfromHSV = function(a) {
- var c, d, e, f, g = new cc.RGBA;
- g.a = 1;
- if (0 >= a.s) {
- if (!a.h) return g.r = a.v, g.g = a.v, g.b = a.v, g;
- g.r = 0;
- g.g = 0;
- g.b = 0;
- return g
- }
- c = a.h;
- 360 <= c && (c = 0);
- c /= 60;
- f = 0 | c;
- e = c - f;
- c = a.v * (1 - a.s);
- d = a.v * (1 - a.s * e);
- e = a.v * (1 - a.s * (1 - e));
- switch (f) {
- case 0:
- g.r = a.v;
- g.g = e;
- g.b = c;
- break;
- case 1:
- g.r = d;
- g.g = a.v;
- g.b = c;
- break;
- case 2:
- g.r = c;
- g.g = a.v;
- g.b = e;
- break;
- case 3:
- g.r = c;
- g.g = d;
- g.b = a.v;
- break;
- case 4:
- g.r = e;
- g.g = c;
- g.b = a.v;
- break;
- default:
- g.r = a.v, g.g = c, g.b = d
- }
- return g
- };
- cc.ControlUtils.CCRectUnion = function(a, c) {
- return cc.rectUnion(a, c)
- };
- cc.Invocation = cc.Class.extend({
- _action: null,
- _target: null,
- _controlEvent: null,
- ctor: function(a, c, d) {
- this._target = a;
- this._action = c;
- this._controlEvent = d
- },
- getAction: function() {
- return this._action
- },
- getTarget: function() {
- return this._target
- },
- getControlEvent: function() {
- return this._controlEvent
- },
- invoke: function(a) {
- if (this._target && this._action)
- if ("string" == typeof this._action) this._target[this._action](a, this._controlEvent);
- else this._action.call(this._target, a, this._controlEvent)
- }
- });
- cc.Scale9Sprite = cc.Node.extend({
- _spriteRect: null,
- _capInsetsInternal: null,
- _positionsAreDirty: !1,
- _scale9Image: null,
- _topLeft: null,
- _top: null,
- _topRight: null,
- _left: null,
- _centre: null,
- _right: null,
- _bottomLeft: null,
- _bottom: null,
- _bottomRight: null,
- _opacityModifyRGB: !1,
- _originalSize: null,
- _preferredSize: null,
- _opacity: 0,
- _color: null,
- _capInsets: null,
- _insetLeft: 0,
- _insetTop: 0,
- _insetRight: 0,
- _insetBottom: 0,
- _spritesGenerated: !1,
- _spriteFrameRotated: !1,
- _textureLoaded: !1,
- _loadedEventListeners: null,
- _className: "Scale9Sprite",
- textureLoaded: function() {
- return this._textureLoaded
- },
- addLoadedEventListener: function(a, c) {
- this._loadedEventListeners.push({
- eventCallback: a,
- eventTarget: c
- })
- },
- _callLoadedEventCallbacks: function() {
- this._textureLoaded = !0;
- for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e.eventCallback.call(e.eventTarget, this)
- }
- a.length = 0
- },
- _updateCapInset: function() {
- var a;
- a = this._insetLeft;
- var c = this._insetTop,
- d = this._insetRight,
- e = this._spriteRect,
- f = this._insetBottom;
- a = 0 === a && 0 === c && 0 === d && 0 === f ? cc.rect(0, 0, 0, 0) : this._spriteFrameRotated ? cc.rect(f, a, e.width - d - a, e.height - c - f) : cc.rect(a, c, e.width - a - d, e.height - c - f);
- this.setCapInsets(a)
- },
- _updatePositions: function() {
- if (this._topLeft && this._topRight && this._bottomRight && this._bottomLeft && this._centre) {
- var a = this._contentSize,
- c = this._topLeft,
- d = this._topRight,
- e = this._bottomRight,
- f = this._bottomLeft,
- g = this._centre,
- h = this._centre.getContentSize(),
- k = c.getContentSize(),
- m = f.getContentSize(),
- n = a.width - k.width - d.getContentSize().width,
- a = a.height - k.height - e.getContentSize().height,
- n = n / h.width,
- a = a / h.height,
- k = h.width * n,
- q = h.height * a,
- r = m.width,
- m = m.height;
- if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
- var t = Math.round(k);
- k != t && (k = t, n = k / h.width);
- t = Math.round(q);
- q != t && (q = t, a = q / h.height)
- }
- g.setScaleX(n);
- g.setScaleY(a);
- var h = this._left,
- t = this._right,
- s = this._top,
- v = this._bottom,
- u = cc.p(0, 0);
- f.setAnchorPoint(u);
- e.setAnchorPoint(u);
- c.setAnchorPoint(u);
- d.setAnchorPoint(u);
- h.setAnchorPoint(u);
- t.setAnchorPoint(u);
- s.setAnchorPoint(u);
- v.setAnchorPoint(u);
- g.setAnchorPoint(u);
- f.setPosition(0, 0);
- e.setPosition(r + k, 0);
- c.setPosition(0, m + q);
- d.setPosition(r + k, m + q);
- h.setPosition(0, m);
- h.setScaleY(a);
- t.setPosition(r + k, m);
- t.setScaleY(a);
- v.setPosition(r, 0);
- v.setScaleX(n);
- s.setPosition(r, m + q);
- s.setScaleX(n);
- g.setPosition(r, m)
- }
- },
- ctor: function(a, c, d) {
- cc.Node.prototype.ctor.call(this);
- this._spriteRect = cc.rect(0, 0, 0, 0);
- this._capInsetsInternal = cc.rect(0, 0, 0, 0);
- this._originalSize = cc.size(0, 0);
- this._preferredSize = cc.size(0, 0);
- this._capInsets = cc.rect(0, 0, 0, 0);
- this._loadedEventListeners = [];
- if (void 0 != a)
- if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a, c);
- else {
- var e = cc.spriteFrameCache.getSpriteFrame(a);
- null != e ? this.initWithSpriteFrame(e, c) : this.initWithFile(a, c, d)
- } else this.init()
- },
- getOriginalSize: function() {
- return this._originalSize
- },
- getPreferredSize: function() {
- return this._preferredSize
- },
- _getPreferredWidth: function() {
- return this._preferredSize.width
- },
- _getPreferredHeight: function() {
- return this._preferredSize.height
- },
- setPreferredSize: function(a) {
- this.setContentSize(a);
- this._preferredSize = a
- },
- _setPreferredWidth: function(a) {
- this._setWidth(a);
- this._preferredSize.width = a
- },
- _setPreferredHeight: function(a) {
- this._setHeight(a);
- this._preferredSize.height = a
- },
- setOpacity: function(a) {
- if (this._scale9Image) {
- cc.Node.prototype.setOpacity.call(this, a);
- for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
- var e = c[d];
- e && e.setOpacity(a)
- }
- }
- },
- updateDisplayedOpacity: function(a) {
- if (this._scale9Image) {
- cc.Node.prototype.updateDisplayedOpacity.call(this, a);
- for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
- var e = c[d];
- e && e.updateDisplayedOpacity(a)
- }
- }
- },
- setColor: function(a) {
- if (this._scale9Image) {
- cc.Node.prototype.setColor.call(this, a);
- for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
- var e = c[d];
- e && e.setColor(a)
- }
- }
- },
- updateDisplayedColor: function(a) {
- if (this._scale9Image) {
- cc.Node.prototype.updateDisplayedColor.call(this, a);
- for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
- var e = c[d];
- if (e && (cc.Node.prototype.updateDisplayedColor.call(e, a), cc._renderType === cc._RENDER_TYPE_CANVAS && (255 !== a.r || 255 !== a.g || 255 !== a.b))) e._changeTextureColor(), e._setNodeDirtyForCache()
- }
- }
- },
- getCapInsets: function() {
- return this._capInsets
- },
- setCapInsets: function(a) {
- if (this._scale9Image) {
- var c = this._contentSize,
- d = c.width,
- c = c.height;
- this.updateWithBatchNode(this._scale9Image, this._spriteRect, this._spriteFrameRotated, a);
- this.setContentSize(d, c)
- }
- },
- getInsetLeft: function() {
- return this._insetLeft
- },
- setInsetLeft: function(a) {
- this._insetLeft = a;
- this._updateCapInset()
- },
- getInsetTop: function() {
- return this._insetTop
- },
- setInsetTop: function(a) {
- this._insetTop = a;
- this._updateCapInset()
- },
- getInsetRight: function() {
- return this._insetRight
- },
- setInsetRight: function(a) {
- this._insetRight = a;
- this._updateCapInset()
- },
- getInsetBottom: function() {
- return this._insetBottom
- },
- setInsetBottom: function(a) {
- this._insetBottom = a;
- this._updateCapInset()
- },
- setContentSize: function(a, c) {
- cc.Node.prototype.setContentSize.call(this, a, c);
- this._positionsAreDirty = !0
- },
- _setWidth: function(a) {
- cc.Node.prototype._setWidth.call(this, a);
- this._positionsAreDirty = !0
- },
- _setHeight: function(a) {
- cc.Node.prototype._setHeight.call(this, a);
- this._positionsAreDirty = !0
- },
- visit: function(a) {
- this._positionsAreDirty && (this._updatePositions(), this._positionsAreDirty = !1);
- cc.Node.prototype.visit.call(this, a)
- },
- init: function() {
- return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), !1, cc.rect(0, 0, 0, 0))
- },
- initWithBatchNode: function(a, c, d, e) {
- void 0 === e && (e = d, d = !1);
- a && this.updateWithBatchNode(a, c, d, e);
- this.setCascadeColorEnabled(!0);
- this.setCascadeOpacityEnabled(!0);
- this.setAnchorPoint(0.5, 0.5);
- return this._positionsAreDirty = !0
- },
- initWithFile: function(a, c, d) {
- a instanceof cc.Rect ? (d = a = c, c = cc.rect(0, 0, 0, 0)) : (c = c || cc.rect(0, 0, 0, 0), d = d || cc.rect(0, 0, 0, 0));
- if (!a) throw "cc.Scale9Sprite.initWithFile(): file should be non-null";
- var e = cc.textureCache.textureForKey(a);
- if (!e) {
- var e = cc.textureCache.addImage(a),
- f = e.isLoaded();
- (this._textureLoaded = f) || e.addLoadedEventListener(function(a) {
- var c = this._preferredSize,
- c = cc.size(c.width, c.height);
- a = a.getContentSize();
- this.updateWithBatchNode(this._scale9Image, cc.rect(0, 0, a.width, a.height), !1, this._capInsets);
- this.setPreferredSize(c);
- this._positionsAreDirty = !0;
- this._callLoadedEventCallbacks()
- }, this)
- }
- return this.initWithBatchNode(cc.SpriteBatchNode.create(a, 9), c, !1, d)
- },
- initWithSpriteFrame: function(a, c) {
- if (!a || !a.getTexture()) throw "cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null";
- c = c || cc.rect(0, 0, 0, 0);
- var d = a.textureLoaded();
- (this._textureLoaded = d) || a.addLoadedEventListener(function(a) {
- var c = this._preferredSize,
- c = cc.size(c.width, c.height);
- this.updateWithBatchNode(this._scale9Image, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), this._capInsets);
- this.setPreferredSize(c);
- this._positionsAreDirty = !0;
- this._callLoadedEventCallbacks()
- }, this);
- d = cc.SpriteBatchNode.create(a.getTexture(), 9);
- return this.initWithBatchNode(d, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), c)
- },
- initWithSpriteFrameName: function(a, c) {
- if (!a) throw "cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null";
- c = c || cc.rect(0, 0, 0, 0);
- var d = cc.spriteFrameCache.getSpriteFrame(a);
- return null == d ? (cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"), !1) : this.initWithSpriteFrame(d, c)
- },
- resizableSpriteWithCapInsets: function(a) {
- var c = new cc.Scale9Sprite;
- return c && c.initWithBatchNode(this._scale9Image, this._spriteRect, !1, a) ? c : null
- },
- setOpacityModifyRGB: function(a) {
- if (this._scale9Image) {
- this._opacityModifyRGB = a;
- var c = this._scale9Image.getChildren();
- if (c)
- for (var d = 0, e = c.length; d < e; d++) c[d].setOpacityModifyRGB(a)
- }
- },
- isOpacityModifyRGB: function() {
- return this._opacityModifyRGB
- },
- updateWithBatchNode: function(a, c, d, e) {
- var f = this.getOpacity(),
- g = this.getColor();
- c = cc.rect(c.x, c.y, c.width, c.height);
- this.removeAllChildren(!0);
- this._scale9Image != a && (this._scale9Image = a);
- if (!this._scale9Image) return !1;
- a = a.getTexture();
- var h = a.isLoaded();
- this._textureLoaded = h;
- if (!h) return a.addLoadedEventListener(function(a) {
- this._positionsAreDirty = !0;
- this._callLoadedEventCallbacks()
- }, this), !0;
- a = this._scale9Image;
- a.removeAllChildren(!0);
- h = this._capInsets;
- h.x = e.x;
- h.y = e.y;
- h.width = e.width;
- h.height = e.height;
- this._spriteFrameRotated = d;
- h = a.getTexture();
- cc._rectEqualToZero(c) && (c = h.getContentSize(), c = cc.rect(0, 0, c.width, c.height));
- var k = this._spriteRect = c;
- k.x = c.x;
- k.y = c.y;
- k.width = c.width;
- k.height = c.height;
- this._originalSize.width = c.width;
- this._originalSize.height = c.height;
- k = this._preferredSize;
- 0 === k.width && 0 === k.height && (k.width = c.width, k.height = c.height);
- k = this._capInsetsInternal;
- e && (k.x = e.x, k.y = e.y, k.width = e.width, k.height = e.height);
- var m = c.width;
- e = c.height;
- cc._rectEqualToZero(k) && (k.x = m / 3, k.y = e / 3, k.width = m / 3, k.height = e / 3);
- var n = k.x,
- q = k.width,
- r = m - (n + q),
- t = k.y,
- s = k.height,
- v = e - (t + s),
- u = 0,
- x = 0;
- e = cc.rect(u, x, n, t);
- var u = u + n,
- k = cc.rect(u, x, q, t),
- m = cc.rect(u + q, x, r, t),
- u = 0,
- x = 0 + t,
- A = cc.rect(u, x, n, s),
- u = u + n,
- D = cc.rect(u, x, q, s),
- u = u + q,
- F = cc.rect(u, x, r, s),
- u = 0,
- x = 0 + t + s,
- t = cc.rect(u, x, n, v),
- u = u + n,
- n = cc.rect(u, x, q, v),
- u = u + q,
- q = cc.rect(u, x, r, v),
- r = cc.affineTransformMakeIdentity();
- if (d) {
- d = D;
- var v = q,
- u = t,
- x = m,
- s = e,
- y = F,
- z = A,
- C = n,
- w = k,
- r = cc.affineTransformTranslate(r, c.height + c.x, c.y),
- r = cc.affineTransformRotate(r, 1.57079633),
- D = cc.rectApplyAffineTransform(D, r),
- q = cc.rectApplyAffineTransform(q, r),
- t = cc.rectApplyAffineTransform(t, r),
- m = cc.rectApplyAffineTransform(m, r);
- e = cc.rectApplyAffineTransform(e, r);
- F = cc.rectApplyAffineTransform(F, r);
- A = cc.rectApplyAffineTransform(A, r);
- n = cc.rectApplyAffineTransform(n, r);
- k = cc.rectApplyAffineTransform(k, r);
- d.x = D.x;
- d.y = D.y;
- v.x = q.x;
- v.y = q.y;
- u.x = t.x;
- u.y = t.y;
- x.x = m.x;
- x.y = m.y;
- s.x = e.x;
- s.y = e.y;
- y.x = F.x;
- y.y = F.y;
- z.x = A.x;
- z.y = A.y;
- C.x = n.x;
- C.y = n.y;
- w.x = k.x;
- w.y = k.y;
- this._centre = new cc.Sprite;
- this._centre.initWithTexture(h, d, !0);
- a.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
- this._top = new cc.Sprite;
- this._top.initWithTexture(h, w, !0);
- a.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
- this._bottom = new cc.Sprite;
- this._bottom.initWithTexture(h, C, !0);
- a.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
- this._left = new cc.Sprite;
- this._left.initWithTexture(h, z, !0);
- a.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
- this._right = new cc.Sprite;
- this._right.initWithTexture(h, y, !0);
- a.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
- this._topLeft = new cc.Sprite;
- this._topLeft.initWithTexture(h, s, !0);
- a.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
- this._topRight = new cc.Sprite;
- this._topRight.initWithTexture(h, x, !0);
- a.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
- this._bottomLeft = new cc.Sprite;
- this._bottomLeft.initWithTexture(h, u, !0);
- a.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
- this._bottomRight = new cc.Sprite;
- this._bottomRight.initWithTexture(h, v, !0)
- } else r = cc.affineTransformTranslate(r, c.x, c.y), cc._rectApplyAffineTransformIn(D, r), cc._rectApplyAffineTransformIn(q, r), cc._rectApplyAffineTransformIn(t, r), cc._rectApplyAffineTransformIn(m, r), cc._rectApplyAffineTransformIn(e, r), cc._rectApplyAffineTransformIn(F, r), cc._rectApplyAffineTransformIn(A, r), cc._rectApplyAffineTransformIn(n, r), cc._rectApplyAffineTransformIn(k, r), this._centre = new cc.Sprite, this._centre.initWithTexture(h, D), a.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE), this._top = new cc.Sprite, this._top.initWithTexture(h, k), a.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP), this._bottom = new cc.Sprite, this._bottom.initWithTexture(h, n), a.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM), this._left = new cc.Sprite, this._left.initWithTexture(h, A), a.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT), this._right = new cc.Sprite, this._right.initWithTexture(h, F), a.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT), this._topLeft = new cc.Sprite, this._topLeft.initWithTexture(h, e), a.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT), this._topRight = new cc.Sprite, this._topRight.initWithTexture(h, m), a.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT), this._bottomLeft = new cc.Sprite, this._bottomLeft.initWithTexture(h, t), a.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT), this._bottomRight = new cc.Sprite, this._bottomRight.initWithTexture(h, q);
- a.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
- this.setContentSize(c.width, c.height);
- this.addChild(a);
- this._spritesGenerated && (this.setOpacity(f), this.setColor(g));
- return this._spritesGenerated = !0
- },
- setSpriteFrame: function(a) {
- var c = cc.SpriteBatchNode.create(a.getTexture(), 9),
- d = a.textureLoaded();
- (this._textureLoaded = d) || a.addLoadedEventListener(function(a) {
- var c = this._preferredSize,
- c = cc.size(c.width, c.height);
- this.updateWithBatchNode(this._scale9Image, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), this._capInsets);
- this.setPreferredSize(c);
- this._positionsAreDirty = !0;
- this._callLoadedEventCallbacks()
- }, this);
- this.updateWithBatchNode(c, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), cc.rect(0, 0, 0, 0));
- this._insetBottom = this._insetRight = this._insetTop = this._insetLeft = 0
- }
- });
- _p = cc.Scale9Sprite.prototype;
- cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize);
- cc.defineGetterSetter(_p, "capInsets", _p.getCapInsets, _p.setCapInsets);
- cc.defineGetterSetter(_p, "insetLeft", _p.getInsetLeft, _p.setInsetLeft);
- cc.defineGetterSetter(_p, "insetTop", _p.getInsetTop, _p.setInsetTop);
- cc.defineGetterSetter(_p, "insetRight", _p.getInsetRight, _p.setInsetRight);
- cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom);
- _p = null;
- cc.Scale9Sprite.create = function(a, c, d) {
- return new cc.Scale9Sprite(a, c, d)
- };
- cc.Scale9Sprite.createWithSpriteFrame = function(a, c) {
- return new cc.Scale9Sprite(a, c)
- };
- cc.Scale9Sprite.createWithSpriteFrameName = function(a, c) {
- return new cc.Scale9Sprite(a, c)
- };
- cc.Scale9Sprite.POSITIONS_CENTRE = 0;
- cc.Scale9Sprite.POSITIONS_TOP = 1;
- cc.Scale9Sprite.POSITIONS_LEFT = 2;
- cc.Scale9Sprite.POSITIONS_RIGHT = 3;
- cc.Scale9Sprite.POSITIONS_BOTTOM = 4;
- cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5;
- cc.Scale9Sprite.POSITIONS_TOPLEFT = 6;
- cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7;
- cc.Spacer = cc.Layer.extend({});
- cc.Spacer.verticalSpacer = function(a) {
- var c = new cc.Spacer;
- c.init();
- c.setContentSize(0, a);
- return c
- };
- cc.Spacer.horizontalSpacer = function(a) {
- var c = new cc.Spacer;
- c.init();
- c.setContentSize(a, 0);
- return c
- };
- cc.MenuPassive = cc.Layer.extend({
- _color: null,
- _opacity: 0,
- _className: "MenuPassive",
- ctor: function() {},
- getColor: function() {
- var a = this._color;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- setColor: function(a) {
- var c = this._color;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b;
- if (this._children && 0 < this._children.length)
- for (c = 0; c < this._children.length; c++) this._children[c] && this._children[c].setColor(a);
- void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
- },
- getOpacity: function() {
- return this._opacity
- },
- setOpacity: function(a) {
- this._opacity = a;
- if (this._children && 0 < this._children.length)
- for (var c = 0; c < this._children.length; c++) this._children[c] && this._children[c].setOpacity(a);
- this._color.a = a
- },
- initWithItems: function(a, c) {
- if (this.init()) {
- var d = cc.director.getWinSize();
- this.ignoreAnchorPointForPosition(!0);
- this.setAnchorPoint(0.5, 0.5);
- this.setContentSize(d);
- this.setPosition(d.width / 2, d.height / 2);
- d = 0;
- if (a) {
- this.addChild(a, d);
- for (var e = 0; e < c.length; e++) c[e] && (d++, this.addChild(c[e], d))
- }
- return !0
- }
- return !1
- },
- alignItemsVertically: function() {
- this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
- },
- alignItemsVerticallyWithPadding: function(a) {
- var c = -a,
- d;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (c += this._children[d].getContentSize().height * this._children[d].getScaleY() + a);
- var e = 0,
- f = c / 2;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (e = Math.max(e, this._children[d].getContentSize().width), this._children[d].setPosition(0, f - this._children[d].getContentSize().height * this._children[d].getScaleY() / 2), f -= this._children[d].getContentSize().height * this._children[d].getScaleY() + a);
- this.setContentSize(e, c)
- },
- alignItemsHorizontally: function() {
- this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
- },
- alignItemsHorizontallyWithPadding: function(a) {
- var c = -a,
- d;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (c += this._children[d].getContentSize().width * this._children[d].getScaleX() + a);
- var e = 0,
- f = -c / 2;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (e = Math.max(e, this._children[d].getContentSize().height), this._children[d].setPosition(f + this._children[d].getContentSize().width * this._children[d].getScaleX() / 2, 0), f += this._children[d].getContentSize().width * this._children[d].getScaleX() + a);
- this.setContentSize(c, e)
- },
- alignItemsInColumns: function(a) {
- var c = [],
- d;
- for (d = 1; d < arguments.length; d++) c.push(arguments[d]);
- var e = -5,
- f = 0,
- g = 0,
- h = 0,
- k, m;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (f >= c.length ? cc.log("cc.MenuPassive.alignItemsInColumns(): invalid row index") : (k = c[f]) ? (m = this._children[d].getContentSize().height, g = 0 | (g >= m || null == m ? g : m), ++h, h >= k && (e += g + 5, g = h = 0, ++f)) : cc.log("cc.MenuPassive.alignItemsInColumns(): can not have zero columns on a row"));
- var n = cc.director.getWinSize(),
- q = k = g = f = 0,
- r = 0,
- e = e / 2;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (0 == k && (k = c[f], r = q = n.width / (1 + k)), m = this._children[d].getContentSize().height, g = 0 | (g >= m || null == m ? g : m), this._children[d].setPosition(r - n.width / 2, e - this._children[d].getContentSize().height / 2), r += q, ++h, h >= k && (e -= g + 5, g = k = h = 0, ++f))
- },
- alignItemsInRows: function(a) {
- var c = [],
- d;
- for (d = 1; d < arguments.length; d++) c.push(arguments[d]);
- var e = [],
- f = [],
- g = -10,
- h = -5,
- k = 0,
- m = 0,
- n = 0,
- q, r;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (k >= c.length ? cc.log("cc.MenuPassive.alignItemsInRows(): invalid row index") : (q = c[k]) ? (r = this._children[d].getContentSize().width, m = 0 | (m >= r || null == r ? m : r), h += 0 | this._children[d].getContentSize().height + 5, ++n, n >= q && (e.push(m), f.push(h), g += m + 10, m = n = 0, h = -5, ++k)) : cc.log("cc.MenuPassive.alignItemsInColumns(): can't have zero rows on a column"));
- h = cc.director.getWinSize();
- m = k = 0;
- q = null;
- var g = -g / 2,
- t = 0;
- if (this._children && 0 < this._children.length)
- for (d = 0; d < this._children.length; d++) this._children[d] && (null == q && (q = c[k], t = f[k]), r = this._children[d].getContentSize().width, m = 0 | (m >= r || null == r ? m : r), this._children[d].setPosition(g + e[k] / 2, t - h.height / 2), t -= this._children[d].getContentSize().height + 10, ++n, n >= q && (g += m + 5, m = q = n = 0, ++k))
- },
- setOpacityModifyRGB: function(a) {},
- isOpacityModifyRGB: function() {
- return !1
- }
- });
- cc.MenuPassive.create = function(a) {
- a || (a = null);
- for (var c = [], d = 1; d < arguments.length; d++) c.push(arguments[d]);
- return (d = new cc.MenuPassive) && d.initWithItems(a, c) ? d : null
- };
- cc.MenuPassive.createWithItem = function(a) {
- return cc.MenuPassive.create(a, null)
- };
- cc.ControlSaturationBrightnessPicker = cc.Control.extend({
- _saturation: 0,
- _brightness: 0,
- _background: null,
- _overlay: null,
- _shadow: null,
- _slider: null,
- _startPos: null,
- _boxPos: 0,
- _boxSize: 0,
- _className: "ControlSaturationBrightnessPicker",
- ctor: function(a, c) {
- cc.Control.prototype.ctor.call(this);
- c && this.initWithTargetAndPos(a, c)
- },
- getSaturation: function() {
- return this._saturation
- },
- getBrightness: function() {
- return this._brightness
- },
- getBackground: function() {
- return this._background
- },
- getOverlay: function() {
- return this._brightness
- },
- getShadow: function() {
- return this._shadow
- },
- getSlider: function() {
- return this._slider
- },
- getStartPos: function() {
- return this._startPos
- },
- initWithTargetAndPos: function(a, c) {
- return cc.Control.prototype.init.call(this) ? (this._background = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", a, c, cc.p(0, 0)), this._overlay = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", a, c, cc.p(0, 0)), this._shadow = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", a, c, cc.p(0, 0)), this._slider = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png", a, c, cc.p(0.5, 0.5)), this._startPos = c, this._boxPos = 35, this._boxSize = this._background.getContentSize().width / 2, !0) : !1
- },
- setEnabled: function(a) {
- cc.Control.prototype.setEnabled.call(this, a);
- this._slider && this._slider.setOpacity(a ? 255 : 128)
- },
- updateWithHSV: function(a) {
- var c = new cc.HSV;
- c.s = 1;
- c.h = a.h;
- c.v = 1;
- a = cc.ControlUtils.RGBfromHSV(c);
- this._background.setColor(cc.color(0 | 255 * a.r, 0 | 255 * a.g, 0 | 255 * a.b))
- },
- updateDraggerWithHSV: function(a) {
- a = cc.p(this._startPos.x + this._boxPos + this._boxSize * (1 - a.s), this._startPos.y + this._boxPos + this._boxSize * a.v);
- this._updateSliderPosition(a)
- },
- _updateSliderPosition: function(a) {
- var c = this._startPos.x + 0.5 * this._background.getBoundingBox().width,
- d = this._startPos.y + 0.5 * this._background.getBoundingBox().height,
- e = a.x - c,
- f = a.y - d,
- g = Math.sqrt(e * e + f * f),
- e = Math.atan2(f, e),
- f = 0.5 * this._background.getBoundingBox().width;
- g > f && (a.x = c + f * Math.cos(e), a.y = d + f * Math.sin(e));
- this._slider.setPosition(a);
- a.x < this._startPos.x + this._boxPos ? a.x = this._startPos.x + this._boxPos : a.x > this._startPos.x + this._boxPos + this._boxSize - 1 && (a.x = this._startPos.x + this._boxPos + this._boxSize - 1);
- a.y < this._startPos.y + this._boxPos ? a.y = this._startPos.y + this._boxPos : a.y > this._startPos.y + this._boxPos + this._boxSize && (a.y = this._startPos.y + this._boxPos + this._boxSize);
- this._saturation = 1 - Math.abs((this._startPos.x + this._boxPos - a.x) / this._boxSize);
- this._brightness = Math.abs((this._startPos.y + this._boxPos - a.y) / this._boxSize)
- },
- _checkSliderPosition: function(a) {
- var c = this._startPos.x + 0.5 * this._background.getBoundingBox().width,
- d = this._startPos.y + 0.5 * this._background.getBoundingBox().height,
- c = a.x - c,
- d = a.y - d;
- return Math.sqrt(c * c + d * d) <= 0.5 * this._background.getBoundingBox().width ? (this._updateSliderPosition(a), this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED), !0) : !1
- },
- onTouchBegan: function(a, c) {
- if (!this.isEnabled() || !this.isVisible()) return !1;
- var d = this.getTouchLocation(a);
- return this._checkSliderPosition(d)
- },
- onTouchMoved: function(a, c) {
- var d = this.getTouchLocation(a);
- this._checkSliderPosition(d)
- }
- });
- _p = cc.ControlSaturationBrightnessPicker.prototype;
- cc.defineGetterSetter(_p, "saturation", _p.getSaturation);
- cc.defineGetterSetter(_p, "brightness", _p.getBrightness);
- cc.defineGetterSetter(_p, "background", _p.getBackground);
- cc.defineGetterSetter(_p, "overlay", _p.getOverlay);
- cc.defineGetterSetter(_p, "shadow", _p.getShadow);
- cc.defineGetterSetter(_p, "slider", _p.getSlider);
- cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
- _p = null;
- cc.ControlSaturationBrightnessPicker.create = function(a, c) {
- return new cc.ControlSaturationBrightnessPicker(a, c)
- };
- cc.ControlHuePicker = cc.Control.extend({
- _hue: 0,
- _huePercentage: 0,
- _background: null,
- _slider: null,
- _startPos: null,
- _className: "ControlHuePicker",
- ctor: function(a, c) {
- cc.Control.prototype.ctor.call(this);
- c && this.initWithTargetAndPos(a, c)
- },
- getHue: function() {
- return this._hue
- },
- setHue: function(a) {
- this._hue = a;
- this.setHuePercentage(this._hue / 360)
- },
- getHuePercentage: function() {
- return this._huePercentage
- },
- setHuePercentage: function(a) {
- this._huePercentage = a;
- this._hue = 360 * this._huePercentage;
- var c = this._background.getBoundingBox(),
- d = this._startPos.x + 0.5 * c.width;
- a = this._startPos.y + 0.5 * c.height;
- var c = 0.5 * c.width - 15,
- e = cc.degreesToRadians(360 * this._huePercentage - 180),
- d = d + c * Math.cos(e);
- a += c * Math.sin(e);
- this._slider.setPosition(d, a)
- },
- setEnabled: function(a) {
- cc.Control.prototype.setEnabled.call(this, a);
- this._slider && this._slider.setOpacity(a ? 255 : 128)
- },
- getBackground: function() {
- return this._background
- },
- getSlider: function() {
- return this._slider
- },
- getStartPos: function() {
- return this._startPos
- },
- initWithTargetAndPos: function(a, c) {
- return cc.Control.prototype.init.call(this) ? (this._background = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", a, c, cc.p(0, 0)), this._slider = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png", a, c, cc.p(0.5, 0.5)), this._slider.setPosition(c.x, c.y + 0.5 * this._background.getBoundingBox().height), this._startPos = c, this._huePercentage = this._hue = 0, !0) : !1
- },
- _updateSliderPosition: function(a) {
- var c = this._background.getBoundingBox();
- a = Math.atan2(a.y - (this._startPos.y + 0.5 * c.height), a.x - (this._startPos.x + 0.5 * c.width));
- a = cc.radiansToDegrees(a) + 180;
- this.setHue(a);
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- _checkSliderPosition: function(a) {
- var c = Math.sqrt(Math.pow(a.x + 10, 2) + Math.pow(a.y, 2));
- return 80 > c && 59 < c ? (this._updateSliderPosition(a), !0) : !1
- },
- onTouchBegan: function(a, c) {
- if (!this.isEnabled() || !this.isVisible()) return !1;
- var d = this.getTouchLocation(a);
- return this._checkSliderPosition(d)
- },
- onTouchMoved: function(a, c) {
- var d = this.getTouchLocation(a);
- this._checkSliderPosition(d)
- }
- });
- _p = cc.ControlHuePicker.prototype;
- cc.defineGetterSetter(_p, "hue", _p.getHue, _p.setHue);
- cc.defineGetterSetter(_p, "huePercent", _p.getHuePercentage, _p.setHuePercentage);
- cc.defineGetterSetter(_p, "background", _p.getBackground);
- cc.defineGetterSetter(_p, "slider", _p.getSlider);
- cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
- _p = null;
- cc.ControlHuePicker.create = function(a, c) {
- return new cc.ControlHuePicker(a, c)
- };
- cc.ControlColourPicker = cc.Control.extend({
- _hsv: null,
- _colourPicker: null,
- _huePicker: null,
- _background: null,
- _className: "ControlColourPicker",
- ctor: function() {
- cc.Control.prototype.ctor.call(this);
- this.init()
- },
- hueSliderValueChanged: function(a, c) {
- this._hsv.h = a.getHue();
- var d = cc.ControlUtils.RGBfromHSV(this._hsv);
- cc.Control.prototype.setColor.call(this, cc.color(0 | 255 * d.r, 0 | 255 * d.g, 0 | 255 * d.b));
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED);
- this._updateControlPicker()
- },
- colourSliderValueChanged: function(a, c) {
- this._hsv.s = a.getSaturation();
- this._hsv.v = a.getBrightness();
- var d = cc.ControlUtils.RGBfromHSV(this._hsv);
- cc.Control.prototype.setColor.call(this, cc.color(0 | 255 * d.r, 0 | 255 * d.g, 0 | 255 * d.b));
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- setColor: function(a) {
- cc.Control.prototype.setColor.call(this, a);
- var c = new cc.RGBA;
- c.r = a.r / 255;
- c.g = a.g / 255;
- c.b = a.b / 255;
- c.a = 1;
- this._hsv = cc.ControlUtils.HSVfromRGB(c);
- this._updateHueAndControlPicker()
- },
- getBackground: function() {
- return this._background
- },
- init: function() {
- if (cc.Control.prototype.init.call(this)) {
- cc.spriteFrameCache.addSpriteFrames(res.CCControlColourPickerSpriteSheet_plist);
- var a = cc.SpriteBatchNode.create(res.CCControlColourPickerSpriteSheet_png);
- this.addChild(a);
- this._hsv = new cc.HSV(0, 0, 0);
- this._background = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", a, cc.p(0, 0), cc.p(0.5, 0.5));
- var c = cc.pSub(this._background.getPosition(), cc.p(this._background.getContentSize().width / 2, this._background.getContentSize().height / 2));
- this._huePicker = cc.ControlHuePicker.create(a, cc.p(c.x + 8, c.y + 8));
- this._colourPicker = cc.ControlSaturationBrightnessPicker.create(a, cc.p(c.x + 28, c.y + 28));
- this._huePicker.addTargetWithActionForControlEvents(this, this.hueSliderValueChanged, cc.CONTROL_EVENT_VALUECHANGED);
- this._colourPicker.addTargetWithActionForControlEvents(this, this.colourSliderValueChanged, cc.CONTROL_EVENT_VALUECHANGED);
- this._updateHueAndControlPicker();
- this.addChild(this._huePicker);
- this.addChild(this._colourPicker);
- this.setContentSize(this._background.getContentSize());
- return !0
- }
- return !1
- },
- _updateControlPicker: function() {
- this._huePicker.setHue(this._hsv.h);
- this._colourPicker.updateWithHSV(this._hsv)
- },
- _updateHueAndControlPicker: function() {
- this._huePicker.setHue(this._hsv.h);
- this._colourPicker.updateWithHSV(this._hsv);
- this._colourPicker.updateDraggerWithHSV(this._hsv)
- },
- setEnabled: function(a) {
- cc.Control.prototype.setEnabled.call(this, a);
- null != this._huePicker && this._huePicker.setEnabled(a);
- this._colourPicker && this._colourPicker.setEnabled(a)
- },
- onTouchBegan: function() {
- return !1
- }
- });
- _p = cc.ControlColourPicker.prototype;
- cc.defineGetterSetter(_p, "background", _p.getBackground);
- _p = null;
- cc.ControlColourPicker.create = function() {
- return new cc.ControlColourPicker
- };
- var res = res || {};
- res.CCControlColourPickerSpriteSheet_plist = res.CCControlColourPickerSpriteSheet_plist || "res/extensions/CCControlColourPickerSpriteSheet.plist";
- res.CCControlColourPickerSpriteSheet_png = res.CCControlColourPickerSpriteSheet_png || "res/extensions/CCControlColourPickerSpriteSheet.png";
- cc.SLIDER_MARGIN_H = 24;
- cc.SLIDER_MARGIN_V = 8;
- cc.ControlSlider = cc.Control.extend({
- _value: 0,
- _minimumValue: 0,
- _maximumValue: 0,
- _minimumAllowedValue: 0,
- _maximumAllowedValue: 0,
- _thumbSprite: null,
- _progressSprite: null,
- _backgroundSprite: null,
- _className: "ControlSlider",
- ctor: function(a, c, d) {
- cc.Control.prototype.ctor.call(this);
- void 0 != d && (bgSprite = cc.Sprite.create(a), progressSprite = cc.Sprite.create(c), thumbSprite = cc.Sprite.create(d), this.initWithSprites(bgSprite, progressSprite, thumbSprite))
- },
- getValue: function() {
- return this._value
- },
- setValue: function(a) {
- a = Math.max(a, this._minimumValue);
- this._value = a = Math.min(a, this._maximumValue);
- this.needsLayout();
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- getMinimumValue: function() {
- return this._minimumValue
- },
- setMinimumValue: function(a) {
- this._minimumAllowedValue = this._minimumValue = a;
- this._minimumValue >= this._maximumValue && (this._maximumValue = this._minimumValue + 1);
- this.setValue(this._value)
- },
- getMaximumValue: function() {
- return this._maximumValue
- },
- setMaximumValue: function(a) {
- this._maximumAllowedValue = this._maximumValue = a;
- this._maximumValue <= this._minimumValue && (this._minimumValue = this._maximumValue - 1);
- this.setValue(this._value)
- },
- isTouchInside: function(a) {
- a = a.getLocation();
- a = this.getParent().convertToNodeSpace(a);
- var c = this.getBoundingBox();
- c.width += this._thumbSprite.getContentSize().width;
- c.x -= this._thumbSprite.getContentSize().width / 2;
- return cc.rectContainsPoint(c, a)
- },
- locationFromTouch: function(a) {
- a = a.getLocation();
- a = this.convertToNodeSpace(a);
- 0 > a.x ? a.x = 0 : a.x > this._backgroundSprite.getContentSize().width && (a.x = this._backgroundSprite.getContentSize().width);
- return a
- },
- getMinimumAllowedValue: function() {
- return this._minimumAllowedValue
- },
- setMinimumAllowedValue: function(a) {
- this._minimumAllowedValue = a
- },
- getMaximumAllowedValue: function() {
- return this._maximumAllowedValue
- },
- setMaximumAllowedValue: function(a) {
- this._maximumAllowedValue = a
- },
- getThumbSprite: function() {
- return this._thumbSprite
- },
- getProgressSprite: function() {
- return this._progressSprite
- },
- getBackgroundSprite: function() {
- return this._backgroundSprite
- },
- initWithSprites: function(a, c, d) {
- return cc.Control.prototype.init.call(this) ? (this.ignoreAnchorPointForPosition(!1), this._backgroundSprite = a, this._progressSprite = c, this._thumbSprite = d, a = cc.ControlUtils.CCRectUnion(a.getBoundingBox(), d.getBoundingBox()), this.setContentSize(a.width, a.height), this._backgroundSprite.setAnchorPoint(0.5, 0.5), this._backgroundSprite.setPosition(a.width / 2, a.height / 2), this.addChild(this._backgroundSprite), this._progressSprite.setAnchorPoint(0, 0.5), this._progressSprite.setPosition(0, a.height / 2), this.addChild(this._progressSprite), this._thumbSprite.setPosition(0, a.height / 2), this.addChild(this._thumbSprite), this._minimumValue = 0, this._maximumValue = 1, this.setValue(this._minimumValue), !0) : !1
- },
- setEnabled: function(a) {
- cc.Control.prototype.setEnabled.call(this, a);
- this._thumbSprite && this._thumbSprite.setOpacity(a ? 255 : 128)
- },
- sliderBegan: function(a) {
- this.setSelected(!0);
- this.getThumbSprite().setColor(cc.color.GRAY);
- this.setValue(this.valueForLocation(a))
- },
- sliderMoved: function(a) {
- this.setValue(this.valueForLocation(a))
- },
- sliderEnded: function(a) {
- this.isSelected() && this.setValue(this.valueForLocation(this._thumbSprite.getPosition()));
- this._thumbSprite.setColor(cc.color.WHITE);
- this.setSelected(!1)
- },
- getTouchLocationInControl: function(a) {
- a = a.getLocation();
- a = this.convertToNodeSpace(a);
- 0 > a.x ? a.x = 0 : a.x > this._backgroundSprite.getContentSize().width + cc.SLIDER_MARGIN_H && (a.x = this._backgroundSprite.getContentSize().width + cc.SLIDER_MARGIN_H);
- return a
- },
- onTouchBegan: function(a, c) {
- if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
- var d = this.locationFromTouch(a);
- this.sliderBegan(d);
- return !0
- },
- onTouchMoved: function(a, c) {
- var d = this.locationFromTouch(a);
- this.sliderMoved(d)
- },
- onTouchEnded: function(a, c) {
- this.sliderEnded(cc.p(0, 0))
- },
- needsLayout: function() {
- this._thumbSprite.setPositionX((this._value - this._minimumValue) / (this._maximumValue - this._minimumValue) * this._backgroundSprite.getContentSize().width);
- var a = this._progressSprite.getTextureRect(),
- a = cc.rect(a.x, a.y, this._thumbSprite.getPositionX(), a.height);
- this._progressSprite.setTextureRect(a, this._progressSprite.isTextureRectRotated())
- },
- valueForLocation: function(a) {
- a = a.x / this._backgroundSprite.getContentSize().width;
- return Math.max(Math.min(this._minimumValue + a * (this._maximumValue - this._minimumValue), this._maximumAllowedValue), this._minimumAllowedValue)
- }
- });
- _p = cc.ControlSlider.prototype;
- cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
- cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
- cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
- cc.defineGetterSetter(_p, "minAllowedValue", _p.getMinimumAllowedValue, _p.setMinimumAllowedValue);
- cc.defineGetterSetter(_p, "maxAllowedValue", _p.getMaximumAllowedValue, _p.setMaximumAllowedValue);
- cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite);
- cc.defineGetterSetter(_p, "progressSprite", _p.getProgressSprite);
- cc.defineGetterSetter(_p, "backgroundSprite", _p.getBackgroundSprite);
- _p = null;
- cc.ControlSlider.create = function(a, c, d) {
- return new cc.ControlSlider(a, c, d)
- };
- cc.ControlSwitch = cc.Control.extend({
- _switchSprite: null,
- _initialTouchXPosition: 0,
- _moved: !1,
- _on: !1,
- _className: "ControlSwitch",
- ctor: function(a, c, d, e, f, g) {
- cc.Control.prototype.ctor.call(this);
- g && this.initWithMaskSprite(a, c, d, e, f, g)
- },
- initWithMaskSprite: function(a, c, d, e, f, g) {
- if (!a) throw "cc.ControlSwitch.initWithMaskSprite(): maskSprite should be non-null.";
- if (!c) throw "cc.ControlSwitch.initWithMaskSprite(): onSprite should be non-null.";
- if (!d) throw "cc.ControlSwitch.initWithMaskSprite(): offSprite should be non-null.";
- if (!e) throw "cc.ControlSwitch.initWithMaskSprite(): thumbSprite should be non-null.";
- return this.init() ? (this._on = !0, this._switchSprite = new cc.ControlSwitchSprite, this._switchSprite.initWithMaskSprite(a, c, d, e, f, g), this._switchSprite.setPosition(this._switchSprite.getContentSize().width / 2, this._switchSprite.getContentSize().height / 2), this.addChild(this._switchSprite), this.ignoreAnchorPointForPosition(!1), this.setAnchorPoint(0.5, 0.5), this.setContentSize(this._switchSprite.getContentSize()), !0) : !1
- },
- setOn: function(a, c) {
- c = c || !1;
- var d = (this._on = a) ? this._switchSprite.getOnPosition() : this._switchSprite.getOffPosition();
- c ? this._switchSprite.runAction(cc.ActionTween.create(0.2, "sliderXPosition", this._switchSprite.getSliderXPosition(), d)) : this._switchSprite.setSliderXPosition(d);
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- isOn: function() {
- return this._on
- },
- hasMoved: function() {
- return this._moved
- },
- setEnabled: function(a) {
- this._enabled = a;
- this._switchSprite.setOpacity(a ? 255 : 128)
- },
- locationFromTouch: function(a) {
- a = a.getLocation();
- return a = this.convertToNodeSpace(a)
- },
- onTouchBegan: function(a, c) {
- if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
- this._moved = !1;
- this._initialTouchXPosition = this.locationFromTouch(a).x - this._switchSprite.getSliderXPosition();
- this._switchSprite.getThumbSprite().setColor(cc.color.GRAY);
- this._switchSprite.needsLayout();
- return !0
- },
- onTouchMoved: function(a, c) {
- var d = this.locationFromTouch(a),
- d = cc.p(d.x - this._initialTouchXPosition, 0);
- this._moved = !0;
- this._switchSprite.setSliderXPosition(d.x)
- },
- onTouchEnded: function(a, c) {
- var d = this.locationFromTouch(a);
- this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);
- this.hasMoved() ? this.setOn(!(d.x < this._switchSprite.getContentSize().width / 2), !0) : this.setOn(!this._on, !0)
- },
- onTouchCancelled: function(a, c) {
- var d = this.locationFromTouch(a);
- this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);
- this.hasMoved() ? this.setOn(!(d.x < this._switchSprite.getContentSize().width / 2), !0) : this.setOn(!this._on, !0)
- }
- });
- cc.ControlSwitch.create = function(a, c, d, e, f, g) {
- return new cc.ControlSwitch(a, c, d, e, f, g)
- };
- cc.ControlSwitchSprite = cc.Sprite.extend({
- _sliderXPosition: 0,
- _onPosition: 0,
- _offPosition: 0,
- _textureLocation: 0,
- _maskLocation: 0,
- _maskSize: null,
- _onSprite: null,
- _offSprite: null,
- _thumbSprite: null,
- _onLabel: null,
- _offLabel: null,
- _clipper: null,
- _stencil: null,
- _backRT: null,
- ctor: function() {
- cc.Sprite.prototype.ctor.call(this);
- this._maskLocation = this._offPosition = this._onPosition = this._sliderXPosition = 0;
- this._maskSize = cc.size(0, 0);
- this._offLabel = this._onLabel = this._thumbSprite = this._offSprite = this._onSprite = null
- },
- initWithMaskSprite: function(a, c, d, e, f, g) {
- return cc.Sprite.prototype.initWithTexture.call(this, a.getTexture()) ? (this._onPosition = 0, this._offPosition = -c.getContentSize().width + e.getContentSize().width / 2, this._sliderXPosition = this._onPosition, this.setOnSprite(c), this.setOffSprite(d), this.setThumbSprite(e), this.setOnLabel(f), this.setOffLabel(g), this._stencil = a, a = this._maskSize = this._stencil.getContentSize(), this._stencil.setPosition(0, 0), this._clipper = cc.ClippingNode.create(), this._clipper.setAnchorPoint(0.5, 0.5), this._clipper.setPosition(a.width / 2, a.height / 2), this._clipper.setStencil(this._stencil), this.addChild(this._clipper), this._clipper.addChild(c), this._clipper.addChild(d), this._clipper.addChild(f), this._clipper.addChild(g), this.addChild(this._thumbSprite), this.needsLayout(), !0) : !1
- },
- needsLayout: function() {
- var a = this._maskSize;
- this._onSprite.setPosition(this._onSprite.getContentSize().width / 2 + this._sliderXPosition - a.width / 2, this._onSprite.getContentSize().height / 2 - a.height / 2);
- this._offSprite.setPosition(this._onSprite.getContentSize().width + this._offSprite.getContentSize().width / 2 + this._sliderXPosition - a.width / 2, this._offSprite.getContentSize().height / 2 - a.height / 2);
- this._onLabel && this._onLabel.setPosition(this._onSprite.getPositionX() - this._thumbSprite.getContentSize().width / 6, this._onSprite.getContentSize().height / 2 - a.height / 2);
- this._offLabel && this._offLabel.setPosition(this._offSprite.getPositionX() + this._thumbSprite.getContentSize().width / 6, this._offSprite.getContentSize().height / 2 - a.height / 2);
- this._thumbSprite.setPosition(this._onSprite.getContentSize().width + this._sliderXPosition, this._maskSize.height / 2)
- },
- setSliderXPosition: function(a) {
- a <= this._offPosition ? a = this._offPosition : a >= this._onPosition && (a = this._onPosition);
- this._sliderXPosition = a;
- this.needsLayout()
- },
- getSliderXPosition: function() {
- return this._sliderXPosition
- },
- _getOnSideWidth: function() {
- return this._onSprite.getContentSize().width
- },
- _getOffSideWidth: function() {
- return this._offSprite.getContentSize().height
- },
- updateTweenAction: function(a, c) {
- cc.log("key \x3d " + c + ", value \x3d " + a);
- this.setSliderXPosition(a)
- },
- setOnPosition: function(a) {
- this._onPosition = a
- },
- getOnPosition: function() {
- return this._onPosition
- },
- setOffPosition: function(a) {
- this._offPosition = a
- },
- getOffPosition: function() {
- return this._offPosition
- },
- setMaskTexture: function(a) {
- this._stencil.setTexture(a)
- },
- getMaskTexture: function() {
- return this._stencil.getTexture()
- },
- setTextureLocation: function(a) {
- this._textureLocation = a
- },
- getTextureLocation: function() {
- return this._textureLocation
- },
- setMaskLocation: function(a) {
- this._maskLocation = a
- },
- getMaskLocation: function() {
- return this._maskLocation
- },
- setOnSprite: function(a) {
- this._onSprite = a
- },
- getOnSprite: function() {
- return this._onSprite
- },
- setOffSprite: function(a) {
- this._offSprite = a
- },
- getOffSprite: function() {
- return this._offSprite
- },
- setThumbSprite: function(a) {
- this._thumbSprite = a
- },
- getThumbSprite: function() {
- return this._thumbSprite
- },
- setOnLabel: function(a) {
- this._onLabel = a
- },
- getOnLabel: function() {
- return this._onLabel
- },
- setOffLabel: function(a) {
- this._offLabel = a
- },
- getOffLabel: function() {
- return this._offLabel
- }
- });
- _p = cc.ControlSwitchSprite.prototype;
- cc.defineGetterSetter(_p, "sliderX", _p.getSliderXPosition, _p.setSliderXPosition);
- cc.defineGetterSetter(_p, "onPos", _p.getOnPosition, _p.setOnPosition);
- cc.defineGetterSetter(_p, "offPos", _p.getOffPosition, _p.setOffPosition);
- cc.defineGetterSetter(_p, "maskTexture", _p.getMaskTexture, _p.setMaskTexture);
- cc.defineGetterSetter(_p, "maskPos", _p.getMaskLocation, _p.setMaskLocation);
- cc.defineGetterSetter(_p, "onSprite", _p.getOnSprite, _p.setOnSprite);
- cc.defineGetterSetter(_p, "offSprite", _p.getOffSprite, _p.setOffSprite);
- cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite, _p.setThumbSprite);
- cc.defineGetterSetter(_p, "onLabel", _p.getOnLabel, _p.setOnLabel);
- cc.defineGetterSetter(_p, "offLabel", _p.getOffLabel, _p.setOffLabel);
- cc.defineGetterSetter(_p, "onSideWidth", _p._getOnSideWidth);
- cc.defineGetterSetter(_p, "offSideWidth", _p._getOffSideWidth);
- _p = null;
- cc.CONTROL_STEPPER_PARTMINUS = 0;
- cc.CONTROL_STEPPER_PARTPLUS = 1;
- cc.CONTROL_STEPPER_PARTNONE = 2;
- cc.CONTROL_STEPPER_LABELCOLOR_ENABLED = cc.color(55, 55, 55);
- cc.CONTROL_STEPPER_LABELCOLOR_DISABLED = cc.color(147, 147, 147);
- cc.CONTROL_STEPPER_LABELFONT = "CourierNewPSMT";
- cc.AUTOREPEAT_DELTATIME = 0.15;
- cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12;
- cc.ControlStepper = cc.Control.extend({
- _minusSprite: null,
- _plusSprite: null,
- _minusLabel: null,
- _plusLabel: null,
- _value: 0,
- _continuous: !1,
- _autorepeat: !1,
- _wraps: !1,
- _minimumValue: 0,
- _maximumValue: 0,
- _stepValue: 0,
- _touchInsideFlag: !1,
- _touchedPart: cc.CONTROL_STEPPER_PARTNONE,
- _autorepeatCount: 0,
- _className: "ControlStepper",
- ctor: function(a, c) {
- cc.Control.prototype.ctor.call(this);
- this._plusLabel = this._minusLabel = this._plusSprite = this._minusSprite = null;
- this._value = 0;
- this._wraps = this._autorepeat = this._continuous = !1;
- this._stepValue = this._maximumValue = this._minimumValue = 0;
- this._touchInsideFlag = !1;
- this._touchedPart = cc.CONTROL_STEPPER_PARTNONE;
- this._autorepeatCount = 0;
- c && this.initWithMinusSpriteAndPlusSprite(a, c)
- },
- initWithMinusSpriteAndPlusSprite: function(a, c) {
- if (!a) throw "cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Minus sprite should be non-null.";
- if (!c) throw "cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Plus sprite should be non-null.";
- if (this.init()) {
- this._continuous = this._autorepeat = !0;
- this._minimumValue = 0;
- this._maximumValue = 100;
- this._value = 0;
- this._stepValue = 1;
- this._wraps = !1;
- this.ignoreAnchorPointForPosition(!1);
- this.setMinusSprite(a);
- this._minusSprite.setPosition(a.getContentSize().width / 2, a.getContentSize().height / 2);
- this.addChild(this._minusSprite);
- this.setMinusLabel(cc.LabelTTF.create("-", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER));
- this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_DISABLED);
- this._minusLabel.setPosition(this._minusSprite.getContentSize().width / 2, this._minusSprite.getContentSize().height / 2);
- this._minusSprite.addChild(this._minusLabel);
- this.setPlusSprite(c);
- this._plusSprite.setPosition(a.getContentSize().width + c.getContentSize().width / 2, a.getContentSize().height / 2);
- this.addChild(this._plusSprite);
- this.setPlusLabel(cc.LabelTTF.create("+", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER));
- this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED);
- this._plusLabel.setPosition(this._plusSprite.getContentSize().width / 2, this._plusSprite.getContentSize().height / 2);
- this._plusSprite.addChild(this._plusLabel);
- var d = cc.ControlUtils.CCRectUnion(this._minusSprite.getBoundingBox(), this._plusSprite.getBoundingBox());
- this.setContentSize(this._minusSprite.getContentSize().width + this._plusSprite.getContentSize().height, d.height);
- return !0
- }
- return !1
- },
- setWraps: function(a) {
- if (this._wraps = a) this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED), this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED);
- this.setValue(this._value)
- },
- getWraps: function() {
- return this._wraps
- },
- setMinimumValue: function(a) {
- if (a >= this._maximumValue) throw "cc.ControlStepper.setMinimumValue(): minimumValue should be numerically less than maximumValue.";
- this._minimumValue = a;
- this.setValue(this._value)
- },
- getMinimumValue: function() {
- return this._minimumValue
- },
- setMaximumValue: function(a) {
- if (a <= this._minimumValue) throw "cc.ControlStepper.setMaximumValue(): maximumValue should be numerically less than maximumValue.";
- this._maximumValue = a;
- this.setValue(this._value)
- },
- getMaximumValue: function() {
- return this._maximumValue
- },
- setValue: function(a) {
- this.setValueWithSendingEvent(a, !0)
- },
- getValue: function() {
- return this._value
- },
- setStepValue: function(a) {
- if (0 >= a) throw "cc.ControlStepper.setMaximumValue(): stepValue should be numerically greater than 0.";
- this._stepValue = a
- },
- getStepValue: function() {
- return this._stepValue
- },
- isContinuous: function() {
- return this._continuous
- },
- setValueWithSendingEvent: function(a, c) {
- a < this._minimumValue ? a = this._wraps ? this._maximumValue : this._minimumValue : a > this._maximumValue && (a = this._wraps ? this._minimumValue : this._maximumValue);
- this._value = a;
- this._wraps || (this._minusLabel.setColor(a == this._minimumValue ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED), this._plusLabel.setColor(a == this._maximumValue ? cc.CONTROL_STEPPER_LABELCOLOR_DISABLED : cc.CONTROL_STEPPER_LABELCOLOR_ENABLED));
- c && this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- startAutorepeat: function() {
- this._autorepeatCount = -1;
- this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.REPEAT_FOREVER, 3 * cc.AUTOREPEAT_DELTATIME)
- },
- stopAutorepeat: function() {
- this.unschedule(this.update)
- },
- update: function(a) {
- this._autorepeatCount++;
- this._autorepeatCount < cc.AUTOREPEAT_INCREASETIME_INCREMENT && 0 != this._autorepeatCount % 3 || (this._touchedPart == cc.CONTROL_STEPPER_PARTMINUS ? this.setValueWithSendingEvent(this._value - this._stepValue, this._continuous) : this._touchedPart == cc.CONTROL_STEPPER_PARTPLUS && this.setValueWithSendingEvent(this._value + this._stepValue, this._continuous))
- },
- updateLayoutUsingTouchLocation: function(a) {
- a.x < this._minusSprite.getContentSize().width && this._value > this._minimumValue ? (this._touchedPart = cc.CONTROL_STEPPER_PARTMINUS, this._minusSprite.setColor(cc.color.GRAY), this._plusSprite.setColor(cc.color.WHITE)) : a.x >= this._minusSprite.getContentSize().width && this._value < this._maximumValue ? (this._touchedPart = cc.CONTROL_STEPPER_PARTPLUS, this._minusSprite.setColor(cc.color.WHITE), this._plusSprite.setColor(cc.color.GRAY)) : (this._touchedPart = cc.CONTROL_STEPPER_PARTNONE, this._minusSprite.setColor(cc.color.WHITE), this._plusSprite.setColor(cc.color.WHITE))
- },
- onTouchBegan: function(a, c) {
- if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
- var d = this.getTouchLocation(a);
- this.updateLayoutUsingTouchLocation(d);
- this._touchInsideFlag = !0;
- this._autorepeat && this.startAutorepeat();
- return !0
- },
- onTouchMoved: function(a, c) {
- if (this.isTouchInside(a)) {
- var d = this.getTouchLocation(a);
- this.updateLayoutUsingTouchLocation(d);
- this._touchInsideFlag || (this._touchInsideFlag = !0, this._autorepeat && this.startAutorepeat())
- } else this._touchInsideFlag = !1, this._touchedPart = cc.CONTROL_STEPPER_PARTNONE, this._minusSprite.setColor(cc.color.WHITE), this._plusSprite.setColor(cc.color.WHITE), this._autorepeat && this.stopAutorepeat()
- },
- onTouchEnded: function(a, c) {
- this._minusSprite.setColor(cc.color.WHITE);
- this._plusSprite.setColor(cc.color.WHITE);
- this._autorepeat && this.stopAutorepeat();
- if (this.isTouchInside(a)) {
- var d = this.getTouchLocation(a);
- this.setValue(this._value + (d.x < this._minusSprite.getContentSize().width ? 0 - this._stepValue : this._stepValue))
- }
- },
- setMinusSprite: function(a) {
- this._minusSprite = a
- },
- getMinusSprite: function() {
- return this._minusSprite
- },
- setPlusSprite: function(a) {
- this._plusSprite = a
- },
- getPlusSprite: function() {
- return this._plusSprite
- },
- setMinusLabel: function(a) {
- this._minusLabel = a
- },
- getMinusLabel: function() {
- return this._minusLabel
- },
- setPlusLabel: function(a) {
- this._plusLabel = a
- },
- getPlusLabel: function() {
- return this._plusLabel
- }
- });
- _p = cc.ControlStepper.prototype;
- cc.defineGetterSetter(_p, "wraps", _p.getWraps, _p.setWraps);
- cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
- cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
- cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
- cc.defineGetterSetter(_p, "stepValue", _p.getStepValue, _p.setStepValue);
- cc.defineGetterSetter(_p, "continuous", _p.isContinuous);
- cc.defineGetterSetter(_p, "minusSprite", _p.getMinusSprite, _p.setMinusSprite);
- cc.defineGetterSetter(_p, "plusSprite", _p.getPlusSprite, _p.setPlusSprite);
- cc.defineGetterSetter(_p, "minusLabel", _p.getMinusLabel, _p.setMinusLabel);
- cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel);
- _p = null;
- cc.ControlStepper.create = function(a, c) {
- return new cc.ControlStepper(a, c)
- };
- cc.ControlPotentiometer = cc.Control.extend({
- _thumbSprite: null,
- _progressTimer: null,
- _previousLocation: null,
- _value: 0,
- _minimumValue: 0,
- _maximumValue: 1,
- _className: "ControlPotentiometer",
- ctor: function(a, c, d) {
- cc.Control.prototype.ctor.call(this);
- void 0 != d && (a = cc.Sprite.create(a), d = cc.Sprite.create(d), c = cc.ProgressTimer.create(cc.Sprite.create(c)), this.initWithTrackSprite_ProgressTimer_ThumbSprite(a, c, d))
- },
- initWithTrackSprite_ProgressTimer_ThumbSprite: function(a, c, d) {
- return this.init() ? (this.setProgressTimer(c), this.setThumbSprite(d), this._thumbSprite.setPosition(c.getPosition()), this.addChild(d, 2), this.addChild(c, 1), this.addChild(a), this.setContentSize(a.getContentSize()), this._minimumValue = 0, this._maximumValue = 1, this.setValue(this._minimumValue), !0) : !1
- },
- setEnabled: function(a) {
- this.setEnabled(a);
- this._thumbSprite != NULL && this._thumbSprite.setOpacity(a ? 255 : 128)
- },
- setValue: function(a) {
- a < this._minimumValue && (a = this._minimumValue);
- a > this._maximumValue && (a = this._maximumValue);
- this._value = a;
- a = (a - this._minimumValue) / (this._maximumValue - this._minimumValue);
- this._progressTimer.setPercentage(100 * a);
- this._thumbSprite.setRotation(360 * a);
- this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
- },
- getValue: function() {
- return this._value
- },
- setMinimumValue: function(a) {
- this._minimumValue = a;
- this._minimumValue >= this._maximumValue && (this._maximumValue = this._minimumValue + 1);
- this.setValue(this._maximumValue)
- },
- getMinimumValue: function() {
- return this._minimumValue
- },
- setMaximumValue: function(a) {
- this._maximumValue = a;
- this._maximumValue <= this._minimumValue && (this._minimumValue = this._maximumValue - 1);
- this.setValue(this._minimumValue)
- },
- getMaximumValue: function() {
- return this._maximumValue
- },
- isTouchInside: function(a) {
- a = this.getTouchLocation(a);
- return this.distanceBetweenPointAndPoint(this._progressTimer.getPosition(), a) < Math.min(this.getContentSize().width / 2, this.getContentSize().height / 2)
- },
- onTouchBegan: function(a, c) {
- if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
- this._previousLocation = this.getTouchLocation(a);
- this.potentiometerBegan(this._previousLocation);
- return !0
- },
- onTouchMoved: function(a, c) {
- var d = this.getTouchLocation(a);
- this.potentiometerMoved(d)
- },
- onTouchEnded: function(a, c) {
- this.potentiometerEnded(cc.p(0, 0))
- },
- distanceBetweenPointAndPoint: function(a, c) {
- var d = a.x - c.x,
- e = a.y - c.y;
- return Math.sqrt(d * d + e * e)
- },
- angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint: function(a, c, d, e) {
- var f = e.x - d.x;
- d = e.y - d.y;
- a = Math.atan2(c.x - a.x, c.y - a.y);
- f = Math.atan2(f, d);
- return 180 * (a - f) / Math.PI
- },
- potentiometerBegan: function(a) {
- this.setSelected(!0);
- this.getThumbSprite().setColor(cc.color.GRAY)
- },
- potentiometerMoved: function(a) {
- var c = this.angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(this._progressTimer.getPosition(), a, this._progressTimer.getPosition(), this._previousLocation);
- 180 < c ? c -= 360 : -180 > c && (c += 360);
- this.setValue(this._value + c / 360 * (this._maximumValue - this._minimumValue));
- this._previousLocation = a
- },
- potentiometerEnded: function(a) {
- this.getThumbSprite().setColor(cc.color.WHITE);
- this.setSelected(!1)
- },
- setThumbSprite: function(a) {
- this._thumbSprite = a
- },
- getThumbSprite: function() {
- return this._thumbSprite
- },
- setProgressTimer: function(a) {
- this._progressTimer = a
- },
- getProgressTimer: function() {
- return this._progressTimer
- },
- setPreviousLocation: function(a) {
- this._previousLocation = a
- },
- getPreviousLocation: function() {
- return this._previousLocation
- }
- });
- _p = cc.ControlPotentiometer.prototype;
- cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
- cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
- cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
- cc.defineGetterSetter(_p, "progressTimer", _p.getProgressTimer, _p.setProgressTimer);
- cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite, _p.setThumbSprite);
- cc.defineGetterSetter(_p, "prevLocation", _p.getPreviousLocation, _p.setPreviousLocation);
- _p = null;
- cc.ControlPotentiometer.create = function(a, c, d) {
- return new cc.ControlPotentiometer(a, c, d)
- };
- cc.SCROLLVIEW_DIRECTION_NONE = -1;
- cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0;
- cc.SCROLLVIEW_DIRECTION_VERTICAL = 1;
- cc.SCROLLVIEW_DIRECTION_BOTH = 2;
- var SCROLL_DEACCEL_RATE = 0.95,
- SCROLL_DEACCEL_DIST = 1,
- BOUNCE_DURATION = 0.15,
- INSET_RATIO = 0.2,
- MOVE_INCH = 0.04375,
- BOUNCE_BACK_FACTOR = 0.35;
- cc.convertDistanceFromPointToInch = function(a) {
- var c = cc.view,
- c = (c.getScaleX() + c.getScaleY()) / 2;
- return a * c / 160
- };
- cc.ScrollViewDelegate = cc.Class.extend({
- scrollViewDidScroll: function(a) {},
- scrollViewDidZoom: function(a) {}
- });
- cc.ScrollView = cc.Layer.extend({
- _zoomScale: 0,
- _minZoomScale: 0,
- _maxZoomScale: 0,
- _delegate: null,
- _direction: cc.SCROLLVIEW_DIRECTION_BOTH,
- _dragging: !1,
- _contentOffset: null,
- _container: null,
- _touchMoved: !1,
- _maxInset: null,
- _minInset: null,
- _bounceable: !1,
- _clippingToBounds: !1,
- _scrollDistance: null,
- _touchPoint: null,
- _touchLength: 0,
- _touches: null,
- _viewSize: null,
- _minScale: 0,
- _maxScale: 0,
- _parentScissorRect: null,
- _scissorRestored: !1,
- _tmpViewRect: null,
- _touchListener: null,
- _className: "ScrollView",
- ctor: function(a, c) {
- cc.Layer.prototype.ctor.call(this);
- this._contentOffset = cc.p(0, 0);
- this._maxInset = cc.p(0, 0);
- this._minInset = cc.p(0, 0);
- this._scrollDistance = cc.p(0, 0);
- this._touchPoint = cc.p(0, 0);
- this._touches = [];
- this._viewSize = cc.size(0, 0);
- this._parentScissorRect = new cc.Rect(0, 0, 0, 0);
- this._tmpViewRect = new cc.Rect(0, 0, 0, 0);
- void 0 != c ? this.initWithViewSize(a, c) : this.initWithViewSize(cc.size(200, 200), null)
- },
- init: function() {
- return this.initWithViewSize(cc.size(200, 200), null)
- },
- initWithViewSize: function(a, c) {
- var d = cc.p(0, 0);
- return cc.Layer.prototype.init.call(this) ? (this._container = c, this._container || (this._container = cc.Layer.create(), this._container.ignoreAnchorPointForPosition(!1), this._container.setAnchorPoint(d)), this.setViewSize(a), this.setTouchEnabled(!0), this._touches.length = 0, this._delegate = null, this._clippingToBounds = this._bounceable = !0, this._direction = cc.SCROLLVIEW_DIRECTION_BOTH, this._container.setPosition(d), this._touchLength = 0, this.addChild(this._container), this._minScale = this._maxScale = 1, !0) : !1
- },
- setContentOffset: function(a, c) {
- if (c) this.setContentOffsetInDuration(a, BOUNCE_DURATION);
- else {
- if (!this._bounceable) {
- var d = this.minContainerOffset(),
- e = this.maxContainerOffset();
- a.x = Math.max(d.x, Math.min(e.x, a.x));
- a.y = Math.max(d.y, Math.min(e.y, a.y))
- }
- this._container.setPosition(a);
- d = this._delegate;
- null != d && d.scrollViewDidScroll && d.scrollViewDidScroll(this)
- }
- },
- getContentOffset: function() {
- var a = this._container.getPosition();
- return cc.p(a.x, a.y)
- },
- setContentOffsetInDuration: function(a, c) {
- var d = cc.MoveTo.create(c, a),
- e = cc.CallFunc.create(this._stoppedAnimatedScroll, this);
- this._container.runAction(cc.Sequence.create(d, e));
- this.schedule(this._performedAnimatedScroll)
- },
- setZoomScale: function(a, c) {
- if (c) this.setZoomScaleInDuration(a, BOUNCE_DURATION);
- else {
- var d = this._container;
- if (d.getScale() != a) {
- var e, f;
- 0 == this._touchLength ? (f = this._viewSize, f = cc.p(0.5 * f.width, 0.5 * f.height), f = this.convertToWorldSpace(f)) : f = this._touchPoint;
- e = d.convertToNodeSpace(f);
- d.setScale(Math.max(this._minScale, Math.min(this._maxScale, a)));
- e = d.convertToWorldSpace(e);
- f = cc.pSub(f, e);
- this._delegate && this._delegate.scrollViewDidZoom && this._delegate.scrollViewDidZoom(this);
- this.setContentOffset(cc.pAdd(d.getPosition(), f))
- }
- }
- },
- getZoomScale: function() {
- return this._container.getScale()
- },
- setZoomScaleInDuration: function(a, c) {
- if (0 < c) {
- var d = this._container.getScale();
- d != a && (d = cc.ActionTween.create(c, "zoomScale", d, a), this.runAction(d))
- } else this.setZoomScale(a)
- },
- minContainerOffset: function() {
- var a = this._container,
- c = a.getContentSize(),
- d = this._viewSize;
- return cc.p(d.width - c.width * a.getScaleX(), d.height - c.height * a.getScaleY())
- },
- maxContainerOffset: function() {
- return cc.p(0, 0)
- },
- isNodeVisible: function(a) {
- var c = this.getContentOffset(),
- d = this.getViewSize(),
- e = this.getZoomScale(),
- c = cc.rect(-c.x / e, -c.y / e, d.width / e, d.height / e);
- return cc.rectIntersectsRect(c, a.getBoundingBox())
- },
- pause: function(a) {
- this._container.pause();
- a = this._container.getChildren();
- for (var c = 0; c < a.length; c++) a[c].pause();
- this._super()
- },
- resume: function(a) {
- a = this._container.getChildren();
- for (var c = 0, d = a.length; c < d; c++) a[c].resume();
- this._container.resume();
- this._super()
- },
- isDragging: function() {
- return this._dragging
- },
- isTouchMoved: function() {
- return this._touchMoved
- },
- isBounceable: function() {
- return this._bounceable
- },
- setBounceable: function(a) {
- this._bounceable = a
- },
- getViewSize: function() {
- return this._viewSize
- },
- setViewSize: function(a) {
- this._viewSize = a;
- cc.Node.prototype.setContentSize.call(this, a)
- },
- getContainer: function() {
- return this._container
- },
- setContainer: function(a) {
- a && (this.removeAllChildren(!0), this._container = a, a.ignoreAnchorPointForPosition(!1), a.setAnchorPoint(0, 0), this.addChild(a), this.setViewSize(this._viewSize))
- },
- getDirection: function() {
- return this._direction
- },
- setDirection: function(a) {
- this._direction = a
- },
- getDelegate: function() {
- return this._delegate
- },
- setDelegate: function(a) {
- this._delegate = a
- },
- onTouchBegan: function(a, c) {
- if (!this.isVisible()) return !1;
- var d = this._getViewRect(),
- e = this._container,
- f = e.convertToWorldSpace(e.convertTouchToNodeSpace(a)),
- g = this._touches;
- if (2 < g.length || this._touchMoved || !cc.rectContainsPoint(d, f)) return !1;
- g.push(a);
- 1 === g.length ? (this._touchPoint = this.convertTouchToNodeSpace(a), this._touchMoved = !1, this._dragging = !0, this._scrollDistance.x = 0, this._touchLength = this._scrollDistance.y = 0) : 2 == g.length && (this._touchPoint = cc.pMidpoint(this.convertTouchToNodeSpace(g[0]), this.convertTouchToNodeSpace(g[1])), this._touchLength = cc.pDistance(e.convertTouchToNodeSpace(g[0]), e.convertTouchToNodeSpace(g[1])), this._dragging = !1);
- return !0
- },
- onTouchMoved: function(a, c) {
- if (this.isVisible())
- if (1 === this._touches.length && this._dragging) {
- this._touchMoved = !0;
- this._getViewRect();
- var d = this.convertTouchToNodeSpace(a),
- e = cc.pSub(d, this._touchPoint),
- f = 0,
- g = this._direction,
- h;
- if (g === cc.SCROLLVIEW_DIRECTION_VERTICAL) f = e.y, h = this._container.getPositionY(), this.minContainerOffset().y <= h && h <= this.maxContainerOffset().y || (e.y *= BOUNCE_BACK_FACTOR);
- else if (g === cc.SCROLLVIEW_DIRECTION_HORIZONTAL) f = e.x, h = this._container.getPositionX(), this.minContainerOffset().x <= h && h <= this.maxContainerOffset().x || (e.x *= BOUNCE_BACK_FACTOR);
- else {
- f = Math.sqrt(e.x * e.x + e.y * e.y);
- h = this._container.getPositionY();
- var k = this.minContainerOffset(),
- m = this.maxContainerOffset();
- k.y <= h && h <= m.y || (e.y *= BOUNCE_BACK_FACTOR);
- h = this._container.getPositionX();
- k.x <= h && h <= m.x || (e.x *= BOUNCE_BACK_FACTOR)
- } if (this._touchMoved || !(Math.abs(cc.convertDistanceFromPointToInch(f)) < MOVE_INCH))
- if (this._touchMoved || (e.x = 0, e.y = 0), this._touchPoint = d, this._touchMoved = !0, this._dragging) {
- switch (g) {
- case cc.SCROLLVIEW_DIRECTION_VERTICAL:
- e.x = 0;
- break;
- case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
- e.y = 0
- }
- f = this._container.getPosition();
- d = f.x + e.x;
- f = f.y + e.y;
- this._scrollDistance = e;
- this.setContentOffset(cc.p(d, f))
- }
- } else 2 === this._touches.length && !this._dragging && (e = cc.pDistance(this._container.convertTouchToNodeSpace(this._touches[0]), this._container.convertTouchToNodeSpace(this._touches[1])), this.setZoomScale(this.getZoomScale() * e / this._touchLength))
- },
- onTouchEnded: function(a, c) {
- this.isVisible() && (1 == this._touches.length && this._touchMoved && this.schedule(this._deaccelerateScrolling), this._touches.length = 0, this._touchMoved = this._dragging = !1)
- },
- onTouchCancelled: function(a, c) {
- this.isVisible() && (this._touches.length = 0, this._touchMoved = this._dragging = !1)
- },
- setContentSize: function(a, c) {
- null != this.getContainer() && (void 0 === c ? this.getContainer().setContentSize(a) : this.getContainer().setContentSize(a, c), this.updateInset())
- },
- _setWidth: function(a) {
- var c = this.getContainer();
- null != c && (c._setWidth(a), this.updateInset())
- },
- _setHeight: function(a) {
- var c = this.getContainer();
- null != c && (c._setHeight(a), this.updateInset())
- },
- getContentSize: function() {
- return this._container.getContentSize()
- },
- updateInset: function() {
- if (null != this.getContainer()) {
- var a = this._viewSize,
- c = this.maxContainerOffset();
- this._maxInset.x = c.x + a.width * INSET_RATIO;
- this._maxInset.y = c.y + a.height * INSET_RATIO;
- c = this.minContainerOffset();
- this._minInset.x = c.x - a.width * INSET_RATIO;
- this._minInset.y = c.y - a.height * INSET_RATIO
- }
- },
- isClippingToBounds: function() {
- return this._clippingToBounds
- },
- setClippingToBounds: function(a) {
- this._clippingToBounds = a
- },
- visit: function(a) {
- if (this.isVisible()) {
- a = a || cc._renderContext;
- var c, d = this._children,
- e, f;
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
- a.save();
- this.transform(a);
- this._beforeDraw(a);
- if (d && 0 < d.length) {
- f = d.length;
- this.sortAllChildren();
- for (c = 0; c < f; c++)
- if ((e = d[c]) && 0 > e._localZOrder) e.visit(a);
- else break;
- for (this.draw(a); c < f; c++) d[c].visit(a)
- } else this.draw(a);
- this._afterDraw();
- a.restore()
- } else {
- cc.kmGLPushMatrix();
- var g = this.grid;
- g && g.isActive() && (g.beforeDraw(), this.transformAncestors());
- this.transform(a);
- this._beforeDraw(a);
- if (d && 0 < d.length) {
- f = d.length;
- for (c = 0; c < f; c++)
- if ((e = d[c]) && 0 > e._localZOrder) e.visit();
- else break;
- for (this.draw(a); c < f; c++) d[c].visit()
- } else this.draw(a);
- this._afterDraw(a);
- g && g.isActive() && g.afterDraw(this);
- cc.kmGLPopMatrix()
- }
- }
- },
- addChild: function(a, c, d) {
- if (!a) throw Error("child must not nil!");
- c = c || a.getLocalZOrder();
- d = d || a.getTag();
- this._container != a ? this._container.addChild(a, c, d) : cc.Layer.prototype.addChild.call(this, a, c, d)
- },
- isTouchEnabled: function() {
- return null != this._touchListener
- },
- setTouchEnabled: function(a) {
- this._touchListener && cc.eventManager.removeListener(this._touchListener);
- this._touchListener = null;
- a ? (a = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE
- }), this.onTouchBegan && (a.onTouchBegan = this.onTouchBegan.bind(this)), this.onTouchMoved && (a.onTouchMoved = this.onTouchMoved.bind(this)), this.onTouchEnded && (a.onTouchEnded = this.onTouchEnded.bind(this)), this.onTouchCancelled && (a.onTouchCancelled = this.onTouchCancelled.bind(this)), this._touchListener = a, cc.eventManager.addListener(a, this)) : (this._touchMoved = this._dragging = !1, this._touches.length = 0)
- },
- _initWithViewSize: function(a) {
- return null
- },
- _relocateContainer: function(a) {
- var c = this.minContainerOffset(),
- d = this.maxContainerOffset(),
- e = this._direction,
- f = this._container.getPosition(),
- g = f.x,
- h = f.y;
- if (e === cc.SCROLLVIEW_DIRECTION_BOTH || e === cc.SCROLLVIEW_DIRECTION_HORIZONTAL) g = Math.max(g, c.x), g = Math.min(g, d.x);
- if (e == cc.SCROLLVIEW_DIRECTION_BOTH || e == cc.SCROLLVIEW_DIRECTION_VERTICAL) h = Math.min(h, d.y), h = Math.max(h, c.y);
- (h != f.y || g != f.x) && this.setContentOffset(cc.p(g, h), a)
- },
- _deaccelerateScrolling: function(a) {
- if (this._dragging) this.unschedule(this._deaccelerateScrolling);
- else {
- var c, d;
- c = this._container.getPosition();
- a = this._scrollDistance;
- this._container.setPosition(c.x + a.x, c.y + a.y);
- this._bounceable ? (c = this._maxInset, d = this._minInset) : (c = this.maxContainerOffset(), d = this.minContainerOffset());
- var e = this._container.getPositionX(),
- f = this._container.getPositionY();
- a.x *= SCROLL_DEACCEL_RATE;
- a.y *= SCROLL_DEACCEL_RATE;
- this.setContentOffset(cc.p(e, f));
- if (Math.abs(a.x) <= SCROLL_DEACCEL_DIST && Math.abs(a.y) <= SCROLL_DEACCEL_DIST || f > c.y || f < d.y || e > c.x || e < d.x || e == c.x || e == d.x || f == c.y || f == d.y) this.unschedule(this._deaccelerateScrolling), this._relocateContainer(!0)
- }
- },
- _performedAnimatedScroll: function(a) {
- this._dragging ? this.unschedule(this._performedAnimatedScroll) : this._delegate && this._delegate.scrollViewDidScroll && this._delegate.scrollViewDidScroll(this)
- },
- _stoppedAnimatedScroll: function(a) {
- this.unschedule(this._performedAnimatedScroll);
- this._delegate && this._delegate.scrollViewDidScroll && this._delegate.scrollViewDidScroll(this)
- },
- _beforeDraw: function(a) {
- if (this._clippingToBounds) {
- this._scissorRestored = !1;
- var c = this._getViewRect(),
- d = cc.view,
- e = this.getScaleX(),
- f = this.getScaleY();
- a = a || cc._renderContext;
- if (cc._renderType === cc._RENDER_TYPE_CANVAS) c = this._viewSize.width * e * d.getScaleX(), d = this._viewSize.height * f * d.getScaleY(), a.beginPath(), a.rect(0, 0, c, -d), a.clip(), a.closePath();
- else if (d = cc.view, d.isScissorEnabled()) {
- if (this._scissorRestored = !0, this._parentScissorRect = d.getScissorRect(), cc.rectIntersection(c, this._parentScissorRect)) {
- var g = this._parentScissorRect;
- a = Math.max(c.x, g.x);
- f = Math.max(c.y, g.y);
- e = Math.min(c.x + c.width, g.x + g.width);
- c = Math.min(c.y + c.height, g.y + g.height);
- d.setScissorInPoints(a, f, e - a, c - f)
- }
- } else a.enable(a.SCISSOR_TEST), d.setScissorInPoints(c.x, c.y, c.width, c.height)
- }
- },
- _afterDraw: function(a) {
- this._clippingToBounds && cc._renderType === cc._RENDER_TYPE_WEBGL && (this._scissorRestored ? (a = this._parentScissorRect, cc.view.setScissorInPoints(a.x, a.y, a.width, a.height)) : (a = a || cc._renderContext, a.disable(a.SCISSOR_TEST)))
- },
- _handleZoom: function() {},
- _getViewRect: function() {
- for (var a = this.convertToWorldSpace(cc.p(0, 0)), c = this._viewSize, d = this.getScaleX(), e = this.getScaleY(), f = this._parent; null != f; f = f.getParent()) d *= f.getScaleX(), e *= f.getScaleY();
- 0 > d && (a.x += c.width * d, d = -d);
- 0 > e && (a.y += c.height * e, e = -e);
- f = this._tmpViewRect;
- f.x = a.x;
- f.y = a.y;
- f.width = c.width * d;
- f.height = c.height * e;
- return f
- }
- });
- _p = cc.ScrollView.prototype;
- cc.defineGetterSetter(_p, "minOffset", _p.minContainerOffset);
- cc.defineGetterSetter(_p, "maxOffset", _p.maxContainerOffset);
- cc.defineGetterSetter(_p, "bounceable", _p.isBounceable, _p.setBounceable);
- cc.defineGetterSetter(_p, "viewSize", _p.getViewSize, _p.setViewSize);
- cc.defineGetterSetter(_p, "container", _p.getContainer, _p.setContainer);
- cc.defineGetterSetter(_p, "direction", _p.getDirection, _p.setDirection);
- cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
- cc.defineGetterSetter(_p, "clippingToBounds", _p.isClippingToBounds, _p.setClippingToBounds);
- _p = null;
- cc.ScrollView.create = function(a, c) {
- return new cc.ScrollView(a, c)
- };
- cc.SortableObject = cc.Class.extend({
- setObjectID: function(a) {},
- getObjectID: function() {
- return 0
- }
- });
- cc.SortedObject = cc.SortableObject.extend({
- _objectID: 0,
- ctor: function() {
- this._objectID = 0
- },
- setObjectID: function(a) {
- this._objectID = a
- },
- getObjectID: function() {
- return this._objectID
- }
- });
- var _compareObject = function(a, c) {
- return a.getObjectID() - c.getObjectID()
- };
- cc.ArrayForObjectSorting = cc.Class.extend({
- _saveObjectArr: null,
- ctor: function() {
- this._saveObjectArr = []
- },
- insertSortedObject: function(a) {
- if (!a) throw "cc.ArrayForObjectSorting.insertSortedObject(): addObject should be non-null.";
- var c = this.indexOfSortedObject(a);
- this.insertObject(a, c)
- },
- removeSortedObject: function(a) {
- if (0 != this.count()) {
- var c = this.indexOfSortedObject(a);
- c < this.count() && c != cc.INVALID_INDEX && this.objectAtIndex(c).getObjectID() == a.getObjectID() && this.removeObjectAtIndex(c)
- }
- },
- setObjectID_ofSortedObject: function(a, c) {
- var d = this.indexOfSortedObject(c);
- if (d < this.count() && d != cc.INVALID_INDEX) {
- var e = this.objectAtIndex(d);
- e.getObjectID() == c.getObjectID() && (this.removeObjectAtIndex(d), e.setObjectID(a), this.insertSortedObject(e))
- }
- },
- objectWithObjectID: function(a) {
- if (0 == this.count()) return null;
- var c = new cc.SortedObject;
- c.setObjectID(a);
- var d = this.indexOfSortedObject(c);
- d < this.count() && d != cc.INVALID_INDEX && (c = this.objectAtIndex(d), c.getObjectID() != a && (c = null));
- return c
- },
- getObjectWithObjectID: function(a) {
- return null
- },
- indexOfSortedObject: function(a) {
- var c = 0;
- if (a) {
- var d = 0;
- a = a.getObjectID();
- for (var e = this._saveObjectArr, f = 0; f < e.length; f++) {
- var g = e[f].getObjectID();
- if (a == g || a >= d && a < g) break;
- d = g;
- c++
- }
- } else c = cc.INVALID_INDEX;
- return c
- },
- count: function() {
- return this._saveObjectArr.length
- },
- lastObject: function() {
- var a = this._saveObjectArr;
- return 0 == a.length ? null : a[a.length - 1]
- },
- objectAtIndex: function(a) {
- return this._saveObjectArr[a]
- },
- addObject: function(a) {
- this._saveObjectArr.push(a);
- this._saveObjectArr.sort(_compareObject)
- },
- removeObjectAtIndex: function(a) {
- this._saveObjectArr.splice(a, 1);
- this._saveObjectArr.sort(_compareObject)
- },
- insertObject: function(a, c) {
- this._saveObjectArr.splice(c, 0, a);
- this._saveObjectArr.sort(_compareObject)
- }
- });
- cc.TABLEVIEW_FILL_TOPDOWN = 0;
- cc.TABLEVIEW_FILL_BOTTOMUP = 1;
- cc.TableViewCell = cc.Node.extend({
- _idx: 0,
- _className: "TableViewCell",
- getIdx: function() {
- return this._idx
- },
- setIdx: function(a) {
- this._idx = a
- },
- reset: function() {
- this._idx = cc.INVALID_INDEX
- },
- setObjectID: function(a) {
- this._idx = a
- },
- getObjectID: function() {
- return this._idx
- }
- });
- _p = cc.TableViewCell.prototype;
- cc.defineGetterSetter(_p, "objectId", _p.getObjectID, _p.setObjectID);
- _p = null;
- cc.TableViewDelegate = cc.ScrollViewDelegate.extend({
- tableCellTouched: function(a, c) {},
- tableCellHighlight: function(a, c) {},
- tableCellUnhighlight: function(a, c) {},
- tableCellWillRecycle: function(a, c) {}
- });
- cc.TableViewDataSource = cc.Class.extend({
- tableCellSizeForIndex: function(a, c) {
- return this.cellSizeForTable(a)
- },
- cellSizeForTable: function(a) {
- return cc.size(0, 0)
- },
- tableCellAtIndex: function(a, c) {
- return null
- },
- numberOfCellsInTableView: function(a) {
- return 0
- }
- });
- cc.TableView = cc.ScrollView.extend({
- _vOrdering: null,
- _indices: null,
- _cellsFreed: null,
- _dataSource: null,
- _tableViewDelegate: null,
- _oldDirection: null,
- _cellsPositions: null,
- _touchedCell: null,
- ctor: function(a, c, d) {
- cc.ScrollView.prototype.ctor.call(this);
- this._oldDirection = cc.SCROLLVIEW_DIRECTION_NONE;
- this._cellsPositions = [];
- this.initWithViewSize(c, d);
- this.setDataSource(a);
- this._updateCellPositions();
- this._updateContentSize()
- },
- __indexFromOffset: function(a) {
- var c = 0,
- d = this._dataSource.numberOfCellsInTableView(this) - 1;
- switch (this.getDirection()) {
- case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
- a = a.x;
- break;
- default:
- a = a.y
- }
- for (var e = this._cellsPositions; d >= c;) {
- var f = 0 | c + (d - c) / 2,
- g = e[f],
- h = e[f + 1];
- if (a >= g && a <= h) return f;
- a < g ? d = f - 1 : c = f + 1
- }
- return 0 >= c ? 0 : -1
- },
- _indexFromOffset: function(a) {
- var c = {
- x: a.x,
- y: a.y
- };
- a = this._dataSource.numberOfCellsInTableView(this) - 1;
- this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (c.y = this.getContainer().getContentSize().height - c.y);
- c = this.__indexFromOffset(c); - 1 != c && (c = Math.max(0, c), c > a && (c = cc.INVALID_INDEX));
- return c
- },
- __offsetFromIndex: function(a) {
- switch (this.getDirection()) {
- case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
- a = cc.p(this._cellsPositions[a], 0);
- break;
- default:
- a = cc.p(0, this._cellsPositions[a])
- }
- return a
- },
- _offsetFromIndex: function(a) {
- var c = this.__offsetFromIndex(a);
- a = this._dataSource.tableCellSizeForIndex(this, a);
- this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (c.y = this.getContainer().getContentSize().height - c.y - a.height);
- return c
- },
- _updateCellPositions: function() {
- var a = this._dataSource.numberOfCellsInTableView(this),
- c = this._cellsPositions;
- if (0 < a) {
- for (var d = 0, e, f = this._dataSource, g = 0; g < a; g++) switch (c[g] = d, e = f.tableCellSizeForIndex(this, g), this.getDirection()) {
- case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
- d += e.width;
- break;
- default:
- d += e.height
- }
- this._cellsPositions[a] = d
- }
- },
- _updateContentSize: function() {
- var a = cc.size(0, 0),
- c = this._dataSource.numberOfCellsInTableView(this);
- if (0 < c) switch (a = this._cellsPositions[c], this.getDirection()) {
- case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
- a = cc.size(a, this._viewSize.height);
- break;
- default:
- a = cc.size(this._viewSize.width, a)
- }
- this.setContentSize(a);
- this._oldDirection != this._direction && (this._direction == cc.SCROLLVIEW_DIRECTION_HORIZONTAL ? this.setContentOffset(cc.p(0, 0)) : this.setContentOffset(cc.p(0, this.minContainerOffset().y)), this._oldDirection = this._direction)
- },
- _moveCellOutOfSight: function(a) {
- this._tableViewDelegate && this._tableViewDelegate.tableCellWillRecycle && this._tableViewDelegate.tableCellWillRecycle(this, a);
- this._cellsFreed.addObject(a);
- this._cellsUsed.removeSortedObject(a);
- cc.arrayRemoveObject(this._indices, a.getIdx());
- a.reset();
- a.getParent() == this.getContainer() && this.getContainer().removeChild(a, !0)
- },
- _setIndexForCell: function(a, c) {
- c.setAnchorPoint(0, 0);
- c.setPosition(this._offsetFromIndex(a));
- c.setIdx(a)
- },
- _addCellIfNecessary: function(a) {
- a.getParent() != this.getContainer() && this.getContainer().addChild(a);
- this._cellsUsed.insertSortedObject(a);
- var c = this._indices;
- a = a.getIdx(); - 1 == c.indexOf(a) && (c.push(a), c.sort(function(a, c) {
- return a - c
- }))
- },
- getDataSource: function() {
- return this._dataSource
- },
- setDataSource: function(a) {
- this._dataSource = a
- },
- getDelegate: function() {
- return this._tableViewDelegate
- },
- setDelegate: function(a) {
- this._tableViewDelegate = a
- },
- setVerticalFillOrder: function(a) {
- this._vOrdering != a && (this._vOrdering = a, 0 < this._cellsUsed.count() && this.reloadData())
- },
- getVerticalFillOrder: function() {
- return this._vOrdering
- },
- initWithViewSize: function(a, c) {
- return cc.ScrollView.prototype.initWithViewSize.call(this, a, c) ? (this._cellsUsed = new cc.ArrayForObjectSorting, this._cellsFreed = new cc.ArrayForObjectSorting, this._indices = [], this._tableViewDelegate = null, this._vOrdering = cc.TABLEVIEW_FILL_BOTTOMUP, this.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL), cc.ScrollView.prototype.setDelegate.call(this, this), !0) : !1
- },
- updateCellAtIndex: function(a) {
- if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
- var c = this.cellAtIndex(a);
- c && this._moveCellOutOfSight(c);
- c = this._dataSource.tableCellAtIndex(this, a);
- this._setIndexForCell(a, c);
- this._addCellIfNecessary(c)
- }
- },
- insertCellAtIndex: function(a) {
- if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
- var c, d = this._cellsUsed;
- if (c = d.objectWithObjectID(a))
- for (var e = c = d.indexOfSortedObject(c); e < d.count(); e++) c = d.objectAtIndex(e), this._setIndexForCell(c.getIdx() + 1, c);
- c = this._dataSource.tableCellAtIndex(this, a);
- this._setIndexForCell(a, c);
- this._addCellIfNecessary(c);
- this._updateCellPositions();
- this._updateContentSize()
- }
- },
- removeCellAtIndex: function(a) {
- if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
- var c = this.cellAtIndex(a);
- if (c) {
- var d = this._cellsUsed,
- e = d.indexOfSortedObject(c);
- this._moveCellOutOfSight(c);
- cc.arrayRemoveObject(this._indices, a);
- this._updateCellPositions();
- for (a = d.count() - 1; a > e; a--) c = d.objectAtIndex(a), this._setIndexForCell(c.getIdx() - 1, c)
- }
- }
- },
- reloadData: function() {
- this._oldDirection = cc.SCROLLVIEW_DIRECTION_NONE;
- for (var a = this._cellsUsed, c = this._cellsFreed, d = this.getContainer(), e = 0, f = a.count(); e < f; e++) {
- var g = a.objectAtIndex(e);
- this._tableViewDelegate && this._tableViewDelegate.tableCellWillRecycle && this._tableViewDelegate.tableCellWillRecycle(this, g);
- c.addObject(g);
- g.reset();
- g.getParent() == d && d.removeChild(g, !0)
- }
- this._indices = [];
- this._cellsUsed = new cc.ArrayForObjectSorting;
- this._updateCellPositions();
- this._updateContentSize();
- 0 < this._dataSource.numberOfCellsInTableView(this) && this.scrollViewDidScroll(this)
- },
- dequeueCell: function() {
- if (0 === this._cellsFreed.count()) return null;
- var a = this._cellsFreed.objectAtIndex(0);
- this._cellsFreed.removeObjectAtIndex(0);
- return a
- },
- cellAtIndex: function(a) {
- return -1 == this._indices.indexOf(a) ? null : this._cellsUsed.objectWithObjectID(a)
- },
- scrollViewDidScroll: function(a) {
- var c = this._dataSource.numberOfCellsInTableView(this);
- if (0 !== c) {
- null != this._tableViewDelegate && this._tableViewDelegate.scrollViewDidScroll && this._tableViewDelegate.scrollViewDidScroll(this);
- var d = 0,
- e = this._viewSize,
- d = this.getContainer(),
- f = this.getContentOffset();
- f.x *= -1;
- f.y *= -1;
- var g = Math.max(c - 1, 0);
- this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (f.y += e.height / d.getScaleY());
- a = this._indexFromOffset(f);
- a === cc.INVALID_INDEX && (a = c - 1);
- f.y = this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN ? f.y - e.height / d.getScaleY() : f.y + e.height / d.getScaleY();
- f.x += e.width / d.getScaleX();
- e = this._indexFromOffset(f);
- e === cc.INVALID_INDEX && (e = c - 1);
- f = this._cellsUsed;
- if (0 < f.count()) {
- c = f.objectAtIndex(0);
- for (d = c.getIdx(); d < a;)
- if (this._moveCellOutOfSight(c), 0 < f.count()) c = f.objectAtIndex(0), d = c.getIdx();
- else break
- }
- if (0 < f.count()) {
- c = f.lastObject();
- for (d = c.getIdx(); d <= g && d > e;)
- if (this._moveCellOutOfSight(c), 0 < f.count()) c = f.lastObject(), d = c.getIdx();
- else break
- }
- for (g = this._indices; a <= e; a++) - 1 == g.indexOf(a) && this.updateCellAtIndex(a)
- }
- },
- scrollViewDidZoom: function(a) {},
- onTouchEnded: function(a, c) {
- if (this.isVisible()) {
- if (this._touchedCell) {
- var d = this.getBoundingBox(),
- e = cc.p(d.x, d.y),
- e = this._parent.convertToWorldSpace(e);
- d.x = e.x;
- d.y = e.y;
- e = this._tableViewDelegate;
- cc.rectContainsPoint(d, a.getLocation()) && null != e && (e.tableCellUnhighlight && e.tableCellUnhighlight(this, this._touchedCell), e.tableCellTouched && e.tableCellTouched(this, this._touchedCell));
- this._touchedCell = null
- }
- cc.ScrollView.prototype.onTouchEnded.call(this, a, c)
- }
- },
- onTouchBegan: function(a, c) {
- if (!this.isVisible()) return !1;
- var d = cc.ScrollView.prototype.onTouchBegan.call(this, a, c);
- if (1 === this._touches.length) {
- var e;
- e = this.getContainer().convertTouchToNodeSpace(a);
- e = this._indexFromOffset(e);
- (this._touchedCell = e === cc.INVALID_INDEX ? null : this.cellAtIndex(e)) && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellHighlight) && this._tableViewDelegate.tableCellHighlight(this, this._touchedCell)
- } else this._touchedCell && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null);
- return d
- },
- onTouchMoved: function(a, c) {
- cc.ScrollView.prototype.onTouchMoved.call(this, a, c);
- this._touchedCell && this.isTouchMoved() && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null)
- },
- onTouchCancelled: function(a, c) {
- cc.ScrollView.prototype.onTouchCancelled.call(this, a, c);
- this._touchedCell && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null)
- }
- });
- _p = cc.TableView.prototype;
- cc.defineGetterSetter(_p, "dataSource", _p.getDataSource, _p.setDataSource);
- cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
- cc.defineGetterSetter(_p, "verticalFillOrder", _p.getVerticalFillOrder, _p.setVerticalFillOrder);
- _p = null;
- cc.TableView.create = function(a, c, d) {
- return cc.TableView(a, c, d)
- };
- cc.ProtectedNode = cc.Node.extend({
- _protectedChildren: null,
- _reorderProtectedChildDirty: !1,
- _insertProtectedChild: function(a, c) {
- this._reorderProtectedChildDirty = !0;
- this._protectedChildren.push(a);
- a._setLocalZOrder(c)
- },
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this._protectedChildren = []
- },
- addProtectedChild: function(a, c, d) {
- cc.assert(null != a, "child must be non-nil");
- cc.assert(!a.parent, "child already added. It can't be added again");
- c = c || a.getLocalZOrder();
- d && a.setTag(d);
- this._insertProtectedChild(a, c);
- a.setParent(this);
- a.setOrderOfArrival(cc.s_globalOrderOfArrival);
- if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
- this._cascadeColorEnabled && this._enableCascadeColor();
- this._cascadeOpacityEnabled && this._enableCascadeOpacity()
- },
- getProtectedChildByTag: function(a) {
- cc.assert(a != cc.NODE_TAG_INVALID, "Invalid tag");
- for (var c = this._protectedChildren, d = 0, e = c.length; d < e; d++)
- if (c.getTag() == a) return c[d];
- return null
- },
- removeProtectedChild: function(a, c) {
- null == c && (c = !0);
- var d = this._protectedChildren;
- if (0 !== d.length) {
- var e = d.indexOf(a); - 1 < e && (this._running && (a.onExitTransitionDidStart(), a.onExit()), c && a.cleanup(), a.setParent(null), d.splice(e, 1))
- }
- },
- removeProtectedChildByTag: function(a, c) {
- cc.assert(a != cc.NODE_TAG_INVALID, "Invalid tag");
- null == c && (c = !0);
- var d = this.getProtectedChildByTag(a);
- null == d ? cc.log("cocos2d: removeChildByTag(tag \x3d %d): child not found!", a) : this.removeProtectedChild(d, c)
- },
- removeAllProtectedChildren: function() {
- this.removeAllProtectedChildrenWithCleanup(!0)
- },
- removeAllProtectedChildrenWithCleanup: function(a) {
- null == a && (a = !0);
- for (var c = this._protectedChildren, d = 0, e = c.length; d < e; d++) {
- var f = c[d];
- this._running && (f.onExitTransitionDidStart(), f.onExit());
- a && f.cleanup();
- f.setParent(null)
- }
- c.length = 0
- },
- reorderProtectedChild: function(a, c) {
- cc.assert(null != a, "Child must be non-nil");
- this._reorderProtectedChildDirty = !0;
- a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
- a._setLocalZOrder(c)
- },
- sortAllProtectedChildren: function() {
- if (this._reorderProtectedChildDirty) {
- var a = this._protectedChildren,
- c = a.length,
- d, e, f;
- for (d = 1; d < c; d++) {
- f = a[d];
- for (e = d - 1; 0 <= e;) {
- if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
- else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
- else break;
- e--
- }
- a[e + 1] = f
- }
- this._reorderProtectedChildDirty = !1
- }
- },
- visit: null,
- _visitForCanvas: function(a) {
- if (this._visible) {
- a = a || cc._renderContext;
- var c, d, e = this._children,
- f, g = this._protectedChildren,
- h = this._children.length,
- k = g.length;
- a.save();
- this.transform(a);
- this.sortAllChildren();
- this.sortAllProtectedChildren();
- for (c = 0; c < h; c++)
- if (f = e[c], 0 > f._localZOrder) f.visit(a);
- else break;
- for (d = 0; d < k; d++)
- if (f = g[d], 0 > f._localZOrder) f.visit(a);
- else break;
- for (this.draw(a); c < h; c++) e[c] && e[c].visit(a);
- for (; d < k; d++) g[d] && g[d].visit(a);
- this._cacheDirty = !1;
- this.arrivalOrder = 0;
- a.restore()
- }
- },
- _visitForWebGL: function() {
- if (this._visible) {
- var a = cc._renderContext,
- c, d = cc.current_stack,
- e;
- d.stack.push(d.top);
- cc.kmMat4Assign(this._stackMatrix, d.top);
- d.top = this._stackMatrix;
- var f = this.grid;
- f && f._active && f.beforeDraw();
- this.transform();
- var g = this._children,
- h = this._protectedChildren,
- k = g.length,
- m = h.length;
- this.sortAllChildren();
- this.sortAllProtectedChildren();
- for (c = 0; c < k; c++)
- if (g[c] && 0 > g[c]._localZOrder) g[c].visit();
- else break;
- for (e = 0; e < m; e++)
- if (h[e] && 0 > h[e]._localZOrder) h[e].visit();
- else break;
- for (this.draw(a); c < k; c++) g[c] && g[c].visit();
- for (; e < m; e++) h[e] && h[e].visit();
- this.arrivalOrder = 0;
- f && f._active && f.afterDraw(this);
- d.top = d.stack.pop()
- }
- },
- cleanup: function() {
- cc.Node.prototype.cleanup.call(this);
- for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].cleanup()
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onEnter()
- },
- onEnterTransitionDidFinish: function() {
- cc.Node.prototype.onEnterTransitionDidFinish.call(this);
- for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onEnterTransitionDidFinish()
- },
- onExit: function() {
- cc.Node.prototype.onExit.call(this);
- for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onExit()
- },
- onExitTransitionDidStart: function() {
- cc.Node.prototype.onExitTransitionDidStart.call(this);
- for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onExitTransitionDidStart()
- },
- updateDisplayedOpacity: function(a) {
- this._displayedOpacity = this._realOpacity * a / 255;
- this._updateColor();
- var c, d, e = this._displayedOpacity;
- if (this._cascadeOpacityEnabled) {
- d = this._children;
- a = 0;
- for (c = d.length; a < c; a++) d[a].updateDisplayedOpacity && d[a].updateDisplayedOpacity(e)
- }
- d = this._protectedChildren;
- a = 0;
- for (c = d.length; a < c; a++) d[a] && d[a].updateDisplayedOpacity(e)
- },
- updateDisplayedColor: function(a) {
- var c = this._displayedColor,
- d = this._realColor;
- c.r = d.r * a.r / 255;
- c.g = d.g * a.g / 255;
- c.b = d.b * a.b / 255;
- this._updateColor();
- var e;
- if (this._cascadeColorEnabled) {
- e = this._children;
- a = 0;
- for (d = e.length; a < d; a++) e[a].updateDisplayedColor && e[a].updateDisplayedColor(c)
- }
- e = this._protectedChildren;
- a = 0;
- for (d = e.length; a < d; a++) e[a] && e[a].updateDisplayedColor(c)
- },
- disableCascadeColor: function() {
- var a = cc.color.WHITE,
- c, d, e = this._children;
- c = 0;
- for (d = e.length; c < d; c++) e[c].updateDisplayedColor(a);
- e = this._protectedChildren;
- c = 0;
- for (d = e.length; c < d; c++) e[c].setColor(a)
- }
- });
- cc.ProtectedNode.prototype.visit = cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.ProtectedNode.prototype._visitForCanvas : cc.ProtectedNode.prototype._visitForWebGL;
- cc.ProtectedNode.create = function() {
- return new cc.ProtectedNode
- };
- var ccui = ccui || {};
- ccui.Class = ccui.Class || cc.Class;
- ccui.Class.extend = ccui.Class.extend || cc.Class.extend;
- ccui.Node = ccui.Node || cc.Node;
- ccui.Node.extend = ccui.Node.extend || cc.Node.extend;
- ccui.ProtectedNode = ccui.ProtectedNode || cc.ProtectedNode;
- ccui.ProtectedNode.extend = ccui.ProtectedNode.extend || cc.ProtectedNode.extend;
- ccui.cocosGUIVersion = "CocosGUI v1.0.0.0";
- ccui.Widget = ccui.ProtectedNode.extend({
- _enabled: !0,
- _bright: !0,
- _touchEnabled: !1,
- _brightStyle: null,
- _touchBeganPosition: null,
- _touchMovePosition: null,
- _touchEndPosition: null,
- _touchEventListener: null,
- _touchEventSelector: null,
- _name: "default",
- _widgetType: null,
- _actionTag: 0,
- _customSize: null,
- _layoutParameterDictionary: null,
- _layoutParameterType: 0,
- _focused: !1,
- _focusEnabled: !0,
- _ignoreSize: !1,
- _affectByClipping: !1,
- _sizeType: null,
- _sizePercent: null,
- _positionType: null,
- _positionPercent: null,
- _reorderWidgetChildDirty: !1,
- _hit: !1,
- _nodes: null,
- _touchListener: null,
- _className: "Widget",
- _flippedX: !1,
- _flippedY: !1,
- _opacity: 255,
- _highlight: !1,
- _touchEventCallback: null,
- ctor: function() {
- cc.ProtectedNode.prototype.ctor.call(this);
- this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE;
- this._touchBeganPosition = cc.p(0, 0);
- this._touchMovePosition = cc.p(0, 0);
- this._touchEndPosition = cc.p(0, 0);
- this._widgetType = ccui.Widget.TYPE_WIDGET;
- this._customSize = cc.size(0, 0);
- this._layoutParameterDictionary = {};
- this._sizeType = ccui.Widget.SIZE_ABSOLUTE;
- this._sizePercent = cc.p(0, 0);
- this._positionType = ccui.Widget.POSITION_ABSOLUTE;
- this._positionPercent = cc.p(0, 0);
- this._nodes = [];
- this._layoutParameterType = ccui.LayoutParameter.NONE;
- this.init()
- },
- init: function() {
- return cc.ProtectedNode.prototype.init.call(this) ? (this._layoutParameterDictionary = {}, this._initRenderer(), this.setBright(!0), this.onFocusChanged = this.onFocusChange.bind(this), this.onNextFocusedWidget = null, this.setAnchorPoint(cc.p(0.5, 0.5)), this.ignoreContentAdaptWithSize(!0), !0) : !1
- },
- onEnter: function() {
- this.updateSizeAndPosition();
- cc.ProtectedNode.prototype.onEnter.call(this)
- },
- onExit: function() {
- this.unscheduleUpdate();
- cc.ProtectedNode.prototype.onExit.call(this)
- },
- visit: function(a) {
- this._visible && (this._adaptRenderers(), cc.ProtectedNode.prototype.visit.call(this, a))
- },
- getWidgetParent: function() {
- var a = this.getParent();
- return a instanceof ccui.Widget ? a : null
- },
- _updateContentSizeWithTextureSize: function(a) {
- this.setContentSize(this._ignoreSize ? a : this._customSize)
- },
- _isAncestorsEnabled: function() {
- var a = this._getAncensterWidget(this);
- return null == a ? !0 : a && !a.isEnabled() ? !1 : a._isAncestorsEnabled()
- },
- _getAncensterWidget: function(a) {
- if (null == a) return null;
- a = a.getParent();
- return null == a ? null : a instanceof ccui.Widget ? a : this._getAncensterWidget(a.getParent())
- },
- _isAncestorsVisible: function(a) {
- return null == a ? !0 : (a = a.getParent()) && !a.isVisible() ? !1 : this._isAncestorsVisible(a)
- },
- _cleanupWidget: function() {
- this._eventDispatcher.removeEventListener(this._touchListener);
- ccui.Widget._focusedWidget == this && (ccui.Widget._focusedWidget = null)
- },
- setEnabled: function(a) {
- this._enabled = a
- },
- _initRenderer: function() {},
- setContentSize: function(a, c) {
- var d = void 0 === c ? a.width : a,
- e = void 0 === c ? a.height : c;
- cc.Node.prototype.setContentSize.call(this, d, e);
- this._customSize.width = d;
- this._customSize.height = e;
- this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
- if (this._running) {
- var f = this.getWidgetParent(),
- f = f ? f.getContentSize() : this._parent.getContentSize();
- this._sizePercent.x = 0 < f.width ? d / f.width : 0;
- this._sizePercent.y = 0 < f.height ? e / f.height : 0
- }
- this._onSizeChanged()
- },
- _setWidth: function(a) {
- cc.Node.prototype._setWidth.call(this, a);
- this._customSize.width = a;
- this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
- this._running && (a = (a = this.getWidgetParent()) ? a.width : this._parent.width, this._sizePercent.x = 0 < a ? this._customSize.width / a : 0);
- this._onSizeChanged()
- },
- _setHeight: function(a) {
- cc.Node.prototype._setHeight.call(this, a);
- this._customSize.height = a;
- this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
- this._running && (a = (a = this.getWidgetParent()) ? a.height : this._parent.height, this._sizePercent.y = 0 < a ? this._customSize.height / a : 0);
- this._onSizeChanged()
- },
- setSizePercent: function(a) {
- this._sizePercent.x = a.x;
- this._sizePercent.y = a.y;
- var c = this._customSize.width,
- d = this._customSize.height;
- this._running && ((d = this.getWidgetParent()) ? (c = d.width * a.x, d = d.height * a.y) : (c = this._parent.width * a.x, d = this._parent.height * a.y));
- this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(c, d);
- this._customSize.width = c;
- this._customSize.height = d
- },
- _setWidthPercent: function(a) {
- this._sizePercent.x = a;
- var c = this._customSize.width;
- this._running && (c = this.getWidgetParent(), c = (c ? c.width : this._parent.width) * a);
- this._ignoreSize ? this._setWidth(this.getVirtualRendererSize().width) : this._setWidth(c);
- this._customSize.width = c
- },
- _setHeightPercent: function(a) {
- this._sizePercent.y = a;
- var c = this._customSize.height;
- this._running && (c = this.getWidgetParent(), c = (c ? c.height : this._parent.height) * a);
- this._ignoreSize ? this._setHeight(this.getVirtualRendererSize().height) : this._setHeight(c);
- this._customSize.height = c
- },
- updateSizeAndPosition: function(a) {
- a || (a = (a = this.getWidgetParent()) ? a.getLayoutSize() : this._parent.getContentSize());
- switch (this._sizeType) {
- case ccui.Widget.SIZE_ABSOLUTE:
- this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(this._customSize);
- this._sizePercent.x = 0 < a.width ? this._customSize.width / a.width : 0;
- this._sizePercent.y = 0 < a.height ? this._customSize.height / a.height : 0;
- break;
- case ccui.Widget.SIZE_PERCENT:
- var c = cc.size(a.width * this._sizePercent.x, a.height * this._sizePercent.y);
- this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(c);
- this._customSize.width = c.width;
- this._customSize.height = c.height
- }
- this._onSizeChanged();
- c = this.getPosition();
- switch (this._positionType) {
- case ccui.Widget.POSITION_ABSOLUTE:
- 0 >= a.width || 0 >= a.height ? this._positionPercent.x = this._positionPercent.y = 0 : (this._positionPercent.x = c.x / a.width, this._positionPercent.y = c.y / a.height);
- break;
- case ccui.Widget.POSITION_PERCENT:
- c = cc.p(a.width * this._positionPercent.x, a.height * this._positionPercent.y)
- }
- if (this._parent instanceof ccui.ImageView && (a = this._parent._imageRenderer) && !a._textureLoaded) return;
- this.setPosition(c)
- },
- setSizeType: function(a) {
- this._sizeType = a
- },
- getSizeType: function() {
- return this._sizeType
- },
- ignoreContentAdaptWithSize: function(a) {
- this._ignoreSize != a && (this._ignoreSize = a, this.setContentSize(a ? this.getVirtualRendererSize() : this._customSize), this._onSizeChanged())
- },
- isIgnoreContentAdaptWithSize: function() {
- return this._ignoreSize
- },
- getCustomSize: function() {
- return cc.size(this._customSize)
- },
- getLayoutSize: function() {
- return cc.size(this._contentSize)
- },
- getSizePercent: function() {
- return cc.p(this._sizePercent)
- },
- _getWidthPercent: function() {
- return this._sizePercent.x
- },
- _getHeightPercent: function() {
- return this._sizePercent.y
- },
- getWorldPosition: function() {
- return this.convertToWorldSpace(cc.p(this._anchorPoint.x * this._contentSize.width, this._anchorPoint.y * this._contentSize.height))
- },
- getVirtualRenderer: function() {
- return this
- },
- getVirtualRendererSize: function() {
- return cc.size(this._contentSize)
- },
- _onSizeChanged: function() {
- for (var a = this.getChildren(), c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- e instanceof ccui.Widget && e.updateSizeAndPosition()
- }
- },
- setTouchEnabled: function(a) {
- this._touchEnabled !== a && ((this._touchEnabled = a) ? (this._touchListener = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: !0,
- onTouchBegan: this.onTouchBegan.bind(this),
- onTouchMoved: this.onTouchMoved.bind(this),
- onTouchEnded: this.onTouchEnded.bind(this)
- }), cc.eventManager.addListener(this._touchListener, this)) : cc.eventManager.removeListener(this._touchListener))
- },
- isTouchEnabled: function() {
- return this._touchEnabled
- },
- isHighlighted: function() {
- return this._highlight
- },
- setHighlighted: function(a) {
- if (a != this._highlight)
- if (this._highlight = a, this._bright) this._highlight ? this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT) : this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL);
- else this.onPressStateChangedToDisabled()
- },
- isFocused: function() {
- return this._focused
- },
- setFocused: function(a) {
- if (this._focused = a) ccui.Widget._focusedWidget = this
- },
- isFocusEnabled: function() {
- return this._focusEnabled
- },
- setFocusEnabled: function(a) {
- this._focused = a
- },
- findNextFocusedWidget: function(a, c) {
- if (null == this.onNextFocusedWidget || null == this.onNextFocusedWidget(a)) {
- var d = c instanceof ccui.Layout;
- if (this.isFocused() || d) {
- var e = this.getParent();
- return null == e ? d ? c.findNextFocusedWidget(a, c) : c : e.findNextFocusedWidget(a, c)
- }
- return c
- }
- d = this.onNextFocusedWidget(a);
- this.dispatchFocusEvent(this, d);
- return d
- },
- requestFocus: function() {
- this != ccui.Widget._focusedWidget && this.dispatchFocusEvent(ccui.Widget._focusedWidget, this)
- },
- getCurrentFocusedWidget: function() {
- return ccui.Widget._focusedWidget
- },
- enableDpadNavigation: function(a) {},
- onFocusChanged: null,
- onNextFocusedWidget: null,
- interceptTouchEvent: function(a, c, d) {
- var e = this.getWidgetParent();
- e && e.interceptTouchEvent(a, c, d)
- },
- onFocusChange: function(a, c) {
- a && a.setFocused(!1);
- c && c.setFocused(!0)
- },
- dispatchFocusEvent: function(a, c) {
- a && !a.isFocused() && (a = ccui.Widget._focusedWidget);
- if (c != a) {
- if (c && c.onFocusChanged) c.onFocusChanged(a, c);
- if (a && c.onFocusChanged) a.onFocusChanged(a, c);
- cc.eventManager.dispatchEvent(new cc.EventFocus(a, c))
- }
- },
- setBright: function(a) {
- if (this._bright = a) this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE, this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL);
- else this.onPressStateChangedToDisabled()
- },
- setBrightStyle: function(a) {
- if (this._brightStyle != a) switch (this._brightStyle = a = a || ccui.Widget.BRIGHT_STYLE_NORMAL, this._brightStyle) {
- case ccui.Widget.BRIGHT_STYLE_NORMAL:
- this.onPressStateChangedToNormal();
- break;
- case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:
- this.onPressStateChangedToPressed()
- }
- },
- onPressStateChangedToNormal: function() {},
- onPressStateChangedToPressed: function() {},
- onPressStateChangedToDisabled: function() {},
- didNotSelectSelf: function() {},
- onTouchBegan: function(a, c) {
- this._hit = !1;
- if (this.isVisible() && this.isEnabled() && this._isAncestorsEnabled() && this._isAncestorsVisible(this)) {
- var d = a.getLocation();
- this._touchBeganPosition.x = d.x;
- this._touchBeganPosition.y = d.y;
- this.hitTest(this._touchBeganPosition) && this.isClippingParentContainsPoint(this._touchBeganPosition) && (this._hit = !0)
- }
- if (!this._hit) return !1;
- this.setHighlighted(!0);
- (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_BEGAN, this, a);
- this._pushDownEvent();
- return !0
- },
- onTouchMoved: function(a, c) {
- var d = a.getLocation();
- this._touchMovePosition.x = d.x;
- this._touchMovePosition.y = d.y;
- this.setHighlighted(this.hitTest(d));
- (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, a);
- this._moveEvent()
- },
- onTouchEnded: function(a, c) {
- var d = a.getLocation();
- this._touchEndPosition.x = d.x;
- this._touchEndPosition.y = d.y;
- (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_ENDED, this, a);
- d = this._highlight;
- this.setHighlighted(!1);
- d ? this._releaseUpEvent() : this._cancelUpEvent()
- },
- onTouchCancelled: function(a) {
- this.setHighlighted(!1);
- this._cancelUpEvent()
- },
- onTouchLongClicked: function(a) {
- this.longClickEvent()
- },
- _pushDownEvent: function() {
- this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_BEGAN);
- this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN)
- },
- _moveEvent: function() {
- this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_MOVED);
- this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED)
- },
- _releaseUpEvent: function() {
- this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED);
- this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED)
- },
- _cancelUpEvent: function() {
- this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_CANCELED);
- this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED)
- },
- longClickEvent: function() {},
- addTouchEventListener: function(a, c) {
- void 0 === c ? this._touchEventCallback = a : (this._touchEventSelector = a, this._touchEventListener = c)
- },
- hitTest: function(a) {
- var c = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
- return cc.rectContainsPoint(c, this.convertToNodeSpace(a))
- },
- isClippingParentContainsPoint: function(a) {
- this._affectByClipping = !1;
- for (var c = this.getParent(), d = null; c;) {
- if (c instanceof ccui.Layout && c.isClippingEnabled()) {
- this._affectByClipping = !0;
- d = c;
- break
- }
- c = c.getParent()
- }
- return !this._affectByClipping ? !0 : d ? d.hitTest(a) ? d.isClippingParentContainsPoint(a) : !1 : !0
- },
- checkChildInfo: function(a, c, d) {
- var e = this.getWidgetParent();
- e && e.checkChildInfo(a, c, d)
- },
- setPosition: function(a, c) {
- if (this._running) {
- var d = this.getWidgetParent();
- d && (d = d.getContentSize(), 0 >= d.width || 0 >= d.height ? (this._positionPercent.x = 0, this._positionPercent.y = 0) : c ? (this._positionPercent.x = a / d.width, this._positionPercent.y = c / d.height) : (this._positionPercent.x = a.x / d.width, this._positionPercent.y = a.y / d.height))
- }
- cc.Node.prototype.setPosition.call(this, a, c)
- },
- setPositionX: function(a) {
- if (this._running) {
- var c = this.getWidgetParent();
- c && (c = c.width, this._positionPercent.x = 0 >= c ? 0 : a / c)
- }
- cc.Node.prototype.setPositionX.call(this, a)
- },
- setPositionY: function(a) {
- if (this._running) {
- var c = this.getWidgetParent();
- c && (c = c.height, this._positionPercent.y = 0 >= c ? 0 : a / c)
- }
- cc.Node.prototype.setPositionY.call(this, a)
- },
- setPositionPercent: function(a) {
- this._positionPercent = a;
- if (this._running && (a = this.getWidgetParent())) a = a.getSize(), this.setPosition(a.width * this._positionPercent.x, a.height * this._positionPercent.y)
- },
- _setXPercent: function(a) {
- this._positionPercent.x = a;
- if (this._running) {
- var c = this.getWidgetParent();
- c && this.setPositionX(c.width * a)
- }
- },
- _setYPercent: function(a) {
- this._positionPercent.y = a;
- if (this._running) {
- var c = this.getWidgetParent();
- c && this.setPositionY(c.height * a)
- }
- },
- getPositionPercent: function() {
- return cc.p(this._positionPercent)
- },
- _getXPercent: function() {
- return this._positionPercent.x
- },
- _getYPercent: function() {
- return this._positionPercent.y
- },
- setPositionType: function(a) {
- this._positionType = a
- },
- getPositionType: function() {
- return this._positionType
- },
- setFlippedX: function(a) {
- this._flippedX = a;
- this._updateFlippedX()
- },
- isFlippedX: function() {
- return this._flippedX
- },
- setFlippedY: function(a) {
- this._flippedY = a;
- this._updateFlippedY()
- },
- isFlippedY: function() {
- return this._flippedY
- },
- _updateFlippedX: function() {},
- _updateFlippedY: function() {},
- _adaptRenderers: function() {},
- isBright: function() {
- return this._bright
- },
- isEnabled: function() {
- return this._enabled
- },
- getLeftBoundary: function() {
- return this.getPositionX() - this._getAnchorX() * this._contentSize.width
- },
- getBottomBoundary: function() {
- return this.getPositionY() - this._getAnchorY() * this._contentSize.height
- },
- getRightBoundary: function() {
- return this.getLeftBoundary() + this._contentSize.width
- },
- getTopBoundary: function() {
- return this.getBottomBoundary() + this._contentSize.height
- },
- getTouchBeganPosition: function() {
- return cc.p(this._touchBeganPosition)
- },
- getTouchMovePosition: function() {
- return cc.p(this._touchMovePosition)
- },
- getTouchEndPosition: function() {
- return cc.p(this._touchEndPosition)
- },
- setName: function(a) {
- this._name = a
- },
- getName: function() {
- return this._name
- },
- getWidgetType: function() {
- return this._widgetType
- },
- setLayoutParameter: function(a) {
- a && (this._layoutParameterDictionary[a.getLayoutType()] = a, this._layoutParameterType = a.getLayoutType())
- },
- getLayoutParameter: function(a) {
- a = a || this._layoutParameterType;
- return this._layoutParameterDictionary[a]
- },
- getDescription: function() {
- return "Widget"
- },
- clone: function() {
- var a = this._createCloneInstance();
- a._copyProperties(this);
- a._copyClonedWidgetChildren(this);
- return a
- },
- _createCloneInstance: function() {
- return ccui.Widget.create()
- },
- _copyClonedWidgetChildren: function(a) {
- a = a.getChildren();
- for (var c = 0; c < a.length; c++) {
- var d = a[c];
- d instanceof ccui.Widget && this.addChild(d.clone())
- }
- },
- _copySpecialProperties: function(a) {},
- _copyProperties: function(a) {
- this.setEnabled(a.isEnabled());
- this.setVisible(a.isVisible());
- this.setBright(a.isBright());
- this.setTouchEnabled(a.isTouchEnabled());
- this.setLocalZOrder(a.getLocalZOrder());
- this.setTag(a.getTag());
- this.setName(a.getName());
- this.setActionTag(a.getActionTag());
- this._ignoreSize = a._ignoreSize;
- this.setContentSize(a._contentSize);
- this._customSize.width = a._customSize.width;
- this._customSize.height = a._customSize.height;
- this._copySpecialProperties(a);
- this._sizeType = a.getSizeType();
- this._sizePercent.x = a._sizePercent.x;
- this._sizePercent.y = a._sizePercent.y;
- this._positionType = a._positionType;
- this._positionPercent.x = a._positionPercent.x;
- this._positionPercent.y = a._positionPercent.y;
- this.setPosition(a.getPosition());
- this.setAnchorPoint(a.getAnchorPoint());
- this.setScaleX(a.getScaleX());
- this.setScaleY(a.getScaleY());
- this.setRotation(a.getRotation());
- this.setRotationX(a.getRotationX());
- this.setRotationY(a.getRotationY());
- this.setFlippedX(a.isFlippedX());
- this.setFlippedY(a.isFlippedY());
- this.setColor(a.getColor());
- this.setOpacity(a.getOpacity());
- this._touchEventCallback = a._touchEventCallback;
- this._touchEventListener = a._touchEventListener;
- this._touchEventSelector = a._touchEventSelector;
- this._focused = a._focused;
- this._focusEnabled = a._focusEnabled;
- for (var c in a._layoutParameterDictionary) {
- var d = a._layoutParameterDictionary[c];
- d && this.setLayoutParameter(d.clone())
- }
- this._onSizeChanged()
- },
- setActionTag: function(a) {
- this._actionTag = a
- },
- getActionTag: function() {
- return this._actionTag
- },
- getLeftInParent: function() {
- cc.log("getLeftInParent is deprecated. Please use getLeftBoundary instead.");
- return this.getLeftBoundary()
- },
- getBottomInParent: function() {
- cc.log("getBottomInParent is deprecated. Please use getBottomBoundary instead.");
- return this.getBottomBoundary()
- },
- getRightInParent: function() {
- cc.log("getRightInParent is deprecated. Please use getRightBoundary instead.");
- return this.getRightBoundary()
- },
- getTopInParent: function() {
- cc.log("getTopInParent is deprecated. Please use getTopBoundary instead.");
- return this.getTopBoundary()
- },
- getTouchEndPos: function() {
- cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead.");
- return this.getTouchEndPosition()
- },
- getTouchMovePos: function() {
- cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead.");
- return this.getTouchMovePosition()
- },
- clippingParentAreaContainPoint: function(a) {
- cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead.");
- this.isClippingParentContainsPoint(a)
- },
- getTouchStartPos: function() {
- cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead.");
- return this.getTouchBeganPosition()
- },
- setSize: function(a) {
- this.setContentSize(a)
- },
- getSize: function() {
- return this.getContentSize()
- },
- addNode: function(a, c, d) {
- a instanceof ccui.Widget ? cc.log("Please use addChild to add a Widget.") : (cc.Node.prototype.addChild.call(this, a, c, d), this._nodes.push(a))
- },
- getNodeByTag: function(a) {
- for (var c = this._nodes, d = 0; d < c.length; d++) {
- var e = c[d];
- if (e && e.getTag() == a) return e
- }
- return null
- },
- getNodes: function() {
- return this._nodes
- },
- removeNode: function(a, c) {
- cc.Node.prototype.removeChild.call(this, a);
- cc.arrayRemoveObject(this._nodes, a)
- },
- removeNodeByTag: function(a, c) {
- var d = this.getNodeByTag(a);
- d ? this.removeNode(d) : cc.log("cocos2d: removeNodeByTag(tag \x3d %d): child not found!", a)
- },
- removeAllNodes: function() {
- for (var a = 0; a < this._nodes.length; a++) cc.Node.prototype.removeChild.call(this, this._nodes[a]);
- this._nodes.length = 0
- },
- _findLayout: function() {
- for (var a = this._parent; a;)
- if (a._doLayout) {
- a._doLayoutDirty = !0;
- break
- } else a = a._parent
- },
- _updateChildrenDisplayedRGBA: function() {
- this.setColor(this.getColor());
- this.setOpacity(this.getOpacity())
- }
- });
- _p = ccui.Widget.prototype;
- cc.defineGetterSetter(_p, "xPercent", _p._getXPercent, _p._setXPercent);
- cc.defineGetterSetter(_p, "yPercent", _p._getYPercent, _p._setYPercent);
- cc.defineGetterSetter(_p, "widthPercent", _p._getWidthPercent, _p._setWidthPercent);
- cc.defineGetterSetter(_p, "heightPercent", _p._getHeightPercent, _p._setHeightPercent);
- cc.defineGetterSetter(_p, "widgetParent", _p.getWidgetParent);
- cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
- cc.defineGetterSetter(_p, "focused", _p.isFocused, _p.setFocused);
- cc.defineGetterSetter(_p, "sizeType", _p.getSizeType, _p.setSizeType);
- cc.defineGetterSetter(_p, "widgetType", _p.getWidgetType);
- cc.defineGetterSetter(_p, "touchEnabled", _p.isTouchEnabled, _p.setTouchEnabled);
- cc.defineGetterSetter(_p, "updateEnabled", _p.isUpdateEnabled, _p.setUpdateEnabled);
- cc.defineGetterSetter(_p, "bright", _p.isBright, _p.setBright);
- cc.defineGetterSetter(_p, "name", _p.getName, _p.setName);
- cc.defineGetterSetter(_p, "actionTag", _p.getActionTag, _p.setActionTag);
- cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
- _p = null;
- ccui.Widget.create = function() {
- return new ccui.Widget
- };
- ccui.Widget._focusedWidget = null;
- ccui.Widget.getCurrentFocusedWidget = function() {
- return ccui.Widget._focusedWidget
- };
- ccui.Widget.BRIGHT_STYLE_NONE = -1;
- ccui.Widget.BRIGHT_STYLE_NORMAL = 0;
- ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT = 1;
- ccui.Widget.TYPE_WIDGET = 0;
- ccui.Widget.TYPE_CONTAINER = 1;
- ccui.Widget.LEFT = 0;
- ccui.Widget.RIGHT = 1;
- ccui.Widget.UP = 0;
- ccui.Widget.DOWN = 1;
- ccui.Widget.LOCAL_TEXTURE = 0;
- ccui.Widget.PLIST_TEXTURE = 1;
- ccui.Widget.TOUCH_BEGAN = 0;
- ccui.Widget.TOUCH_MOVED = 1;
- ccui.Widget.TOUCH_ENDED = 2;
- ccui.Widget.TOUCH_CANCELED = 3;
- ccui.Widget.SIZE_ABSOLUTE = 0;
- ccui.Widget.SIZE_PERCENT = 1;
- ccui.Widget.POSITION_ABSOLUTE = 0;
- ccui.Widget.POSITION_PERCENT = 1;
- cc.EventFocus = cc.Event.extend({
- _widgetGetFocus: null,
- _widgetLoseFocus: null,
- ctor: function(a, c) {
- this._widgetGetFocus = c;
- this._widgetLoseFocus = a
- }
- });
- ccui.Layout = ccui.Widget.extend({
- _clippingEnabled: !1,
- _backGroundScale9Enabled: null,
- _backGroundImage: null,
- _backGroundImageFileName: null,
- _backGroundImageCapInsets: null,
- _colorType: null,
- _bgImageTexType: ccui.Widget.LOCAL_TEXTURE,
- _colorRender: null,
- _gradientRender: null,
- _color: null,
- _startColor: null,
- _endColor: null,
- _alongVector: null,
- _opacity: 255,
- _backGroundImageTextureSize: null,
- _layoutType: null,
- _doLayoutDirty: !0,
- _clippingRectDirty: !0,
- _clippingType: null,
- _clippingStencil: null,
- _handleScissor: !1,
- _scissorRectDirty: !1,
- _clippingRect: null,
- _clippingParent: null,
- _className: "Layout",
- _backGroundImageColor: null,
- _finalPositionX: 0,
- _finalPositionY: 0,
- _currentStencilEnabled: 0,
- _currentStencilWriteMask: 0,
- _currentStencilFunc: 0,
- _currentStencilRef: 0,
- _currentStencilValueMask: 0,
- _currentStencilFail: 0,
- _currentStencilPassDepthFail: 0,
- _currentStencilPassDepthPass: 0,
- _currentDepthWriteMask: 0,
- _currentAlphaTestEnabled: 0,
- _currentAlphaTestFunc: 0,
- _currentAlphaTestRef: 0,
- _backGroundImageOpacity: 0,
- _mask_layer_le: 0,
- _loopFocus: !1,
- __passFocusToChild: !1,
- _isFocusPassing: !1,
- ctor: function() {
- this._layoutType = ccui.Layout.ABSOLUTE;
- this._widgetType = ccui.Widget.TYPE_CONTAINER;
- this._clippingType = ccui.Layout.CLIPPING_STENCIL;
- this._colorType = ccui.Layout.BG_COLOR_NONE;
- ccui.Widget.prototype.ctor.call(this);
- this._backGroundImageCapInsets = cc.rect(0, 0, 0, 0);
- this._color = cc.color(255, 255, 255, 255);
- this._startColor = cc.color(255, 255, 255, 255);
- this._endColor = cc.color(255, 255, 255, 255);
- this._alongVector = cc.p(0, -1);
- this._backGroundImageTextureSize = cc.size(0, 0);
- this._clippingRect = cc.rect(0, 0, 0, 0);
- this._backGroundImageColor = cc.color(255, 255, 255, 255)
- },
- onEnter: function() {
- ccui.Widget.prototype.onEnter.call(this);
- if (this._clippingStencil) this._clippingStencil.onEnter();
- this._clippingRectDirty = this._doLayoutDirty = !0
- },
- onExit: function() {
- ccui.Widget.prototype.onExit.call(this);
- if (this._clippingStencil) this._clippingStencil.onExit()
- },
- setLoopFocus: function(a) {
- this._loopFocus = a
- },
- isLoopFocus: function() {
- return this._loopFocus
- },
- setPassFocusToChild: function(a) {
- this.__passFocusToChild = a
- },
- isPassFocusToChild: function() {
- return this.__passFocusToChild
- },
- findNextFocusedWidget: function(a, c) {
- if (this._isFocusPassing || this.isFocused()) {
- var d = this.getParent();
- this._isFocusPassing = !1;
- if (this.__passFocusToChild) {
- var e = this._passFocusToChild(a, c);
- return e instanceof ccui.Layout && d ? (d._isFocusPassing = !0, d.findNextFocusedWidget(a, this)) : e
- }
- if (null == d) return this;
- d._isFocusPassing = !0;
- return d.findNextFocusedWidget(a, this)
- }
- if (c.isFocused() || c instanceof ccui.Layout)
- if (this._layoutType == ccui.Layout.LINEAR_HORIZONTAL) switch (a) {
- case ccui.Widget.LEFT:
- return this._getPreviousFocusedWidget(a, c);
- case ccui.Widget.RIGHT:
- return this._getNextFocusedWidget(a, c);
- case ccui.Widget.DOWN:
- case ccui.Widget.UP:
- return this._isLastWidgetInContainer(this, a) ? this._isWidgetAncestorSupportLoopFocus(c, a) ? this.findNextFocusedWidget(a, this) : c : this.findNextFocusedWidget(a, this);
- default:
- return cc.assert(0, "Invalid Focus Direction"), c
- } else if (this._layoutType == ccui.Layout.LINEAR_VERTICAL) switch (a) {
- case ccui.Widget.LEFT:
- case ccui.Widget.RIGHT:
- return this._isLastWidgetInContainer(this, a) ? this._isWidgetAncestorSupportLoopFocus(c, a) ? this.findNextFocusedWidget(a, this) : c : this.findNextFocusedWidget(a, this);
- case ccui.Widget.DOWN:
- return this._getNextFocusedWidget(a, c);
- case ccui.Widget.UP:
- return this._getPreviousFocusedWidget(a, c);
- default:
- return cc.assert(0, "Invalid Focus Direction"), c
- } else return cc.assert(0, "Un Supported Layout type, please use VBox and HBox instead!!!"), c;
- else return c
- },
- onPassFocusToChild: null,
- init: function() {
- return ccui.Widget.prototype.init.call(this) ? (this.ignoreContentAdaptWithSize(!1), this.setContentSize(cc.size(0, 0)), this.setAnchorPoint(0, 0), this.onPassFocusToChild = this._findNearestChildWidgetIndex.bind(this), !0) : !1
- },
- __stencilDraw: function(a) {
- a = a || cc._renderContext;
- for (var c = this._clippingStencil, d = cc.view.getScaleX(), e = cc.view.getScaleY(), f = 0; f < c._buffer.length; f++) {
- var g = c._buffer[f].verts,
- h = g[0];
- a.beginPath();
- a.moveTo(h.x * d, -h.y * e);
- for (var h = 1, k = g.length; h < k; h++) a.lineTo(g[h].x * d, -g[h].y * e)
- }
- },
- addChild: function(a, c, d) {
- a instanceof ccui.Widget && this._supplyTheLayoutParameterLackToChild(a);
- ccui.Widget.prototype.addChild.call(this, a, c, d);
- this._doLayoutDirty = !0
- },
- removeChild: function(a, c) {
- ccui.Widget.prototype.removeChild.call(this, a, c);
- this._doLayoutDirty = !0
- },
- removeAllChildren: function(a) {
- ccui.Widget.prototype.removeAllChildren.call(this, a);
- this._doLayoutDirty = !0
- },
- removeAllChildrenWithCleanup: function(a) {
- ccui.Widget.prototype.removeAllChildrenWithCleanup.call(this, a);
- this._doLayoutDirty = !0
- },
- isClippingEnabled: function() {
- return this._clippingEnabled
- },
- visit: function(a) {
- if (this._visible)
- if (this._adaptRenderers(), this._doLayout(), this._clippingEnabled) switch (this._clippingType) {
- case ccui.Layout.CLIPPING_STENCIL:
- this._stencilClippingVisit(a);
- break;
- case ccui.Layout.CLIPPING_SCISSOR:
- this._scissorClippingVisit(a)
- } else ccui.Widget.prototype.visit.call(this, a)
- },
- _stencilClippingVisit: null,
- _stencilClippingVisitForWebGL: function(a) {
- var c = a || cc._renderContext;
- if (this._clippingStencil && this._clippingStencil.isVisible())
- if (ccui.Layout._layer + 1 == cc.stencilBits) ccui.Layout._visit_once = !0, ccui.Layout._visit_once && (cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its childs."), ccui.Layout._visit_once = !1), cc.Node.prototype.visit.call(this, a);
- else {
- ccui.Layout._layer++;
- var d = 1 << ccui.Layout._layer,
- e = d | d - 1;
- a = c.isEnabled(c.STENCIL_TEST);
- var f = c.getParameter(c.STENCIL_WRITEMASK),
- g = c.getParameter(c.STENCIL_FUNC),
- h = c.getParameter(c.STENCIL_REF),
- k = c.getParameter(c.STENCIL_VALUE_MASK),
- m = c.getParameter(c.STENCIL_FAIL),
- n = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL),
- q = c.getParameter(c.STENCIL_PASS_DEPTH_PASS);
- c.enable(c.STENCIL_TEST);
- c.stencilMask(d);
- var r = c.getParameter(c.DEPTH_WRITEMASK);
- c.depthMask(!1);
- c.stencilFunc(c.NEVER, d, d);
- c.stencilOp(c.ZERO, c.KEEP, c.KEEP);
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPushMatrix();
- cc.kmGLLoadIdentity();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPushMatrix();
- cc.kmGLLoadIdentity();
- cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255));
- cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
- cc.kmGLPopMatrix();
- cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
- cc.kmGLPopMatrix();
- c.stencilFunc(c.NEVER, d, d);
- c.stencilOp(c.REPLACE, c.KEEP, c.KEEP);
- cc.kmGLPushMatrix();
- this.transform();
- this._clippingStencil.visit();
- c.depthMask(r);
- c.stencilFunc(c.EQUAL, e, e);
- c.stencilOp(c.KEEP, c.KEEP, c.KEEP);
- e = d = 0;
- this.sortAllChildren();
- this.sortAllProtectedChildren();
- for (var r = this._children, t = this._protectedChildren, s = r.length, v = t.length, u; d < s; d++)
- if ((u = r[d]) && 0 > u.getLocalZOrder()) u.visit();
- else break;
- for (; e < v; e++)
- if ((u = t[e]) && 0 > u.getLocalZOrder()) u.visit();
- else break;
- for (this.draw(); d < s; d++) r[d].visit();
- for (; e < v; e++) t[e].visit();
- c.stencilFunc(g, h, k);
- c.stencilOp(m, n, q);
- c.stencilMask(f);
- a || c.disable(c.STENCIL_TEST);
- ccui.Layout._layer--;
- cc.kmGLPopMatrix()
- }
- },
- _stencilClippingVisitForCanvas: function(a) {
- if (this._clippingStencil && this._clippingStencil.isVisible()) {
- a = a || cc._renderContext;
- if (this._clippingStencil instanceof cc.Sprite) {
- var c = a.canvas,
- d = ccui.Layout._getSharedCache();
- d.width = c.width;
- d.height = c.height;
- d.getContext("2d").drawImage(c, 0, 0);
- a.save();
- cc.ProtectedNode.prototype.visit.call(this, a);
- a.globalCompositeOperation = "destination-in";
- this.transform(a);
- this._clippingStencil.visit();
- a.restore();
- a.save();
- a.setTransform(1, 0, 0, 1, 0, 0);
- a.globalCompositeOperation = "destination-over";
- a.drawImage(d, 0, 0)
- } else {
- var d = this._children,
- e;
- a.save();
- this.transform(a);
- this._clippingStencil.visit(a);
- a.clip();
- this.sortAllChildren();
- this.sortAllProtectedChildren();
- for (var f, g = this._protectedChildren, h = d.length, k = g.length, c = 0; c < h; c++)
- if ((e = d[c]) && 0 > e._localZOrder) e.visit(a);
- else break;
- for (f = 0; f < k; f++)
- if ((e = g[f]) && 0 > e._localZOrder) e.visit(a);
- else break;
- for (; c < h; c++) d[c].visit(a);
- for (; f < k; f++) g[f].visit(a)
- }
- a.restore()
- }
- },
- _scissorClippingVisit: null,
- _scissorClippingVisitForWebGL: function(a) {
- var c = this._getClippingRect();
- a = a || cc._renderContext;
- this._handleScissor && a.enable(a.SCISSOR_TEST);
- cc.view.setScissorInPoints(c.x, c.y, c.width, c.height);
- cc.Node.prototype.visit.call(this);
- this._handleScissor && a.disable(a.SCISSOR_TEST)
- },
- setClippingEnabled: function(a) {
- if (a != this._clippingEnabled) switch (this._clippingEnabled = a, this._clippingType) {
- case ccui.Layout.CLIPPING_STENCIL:
- if (a) {
- this._clippingStencil = cc.DrawNode.create();
- cc._renderType === cc._RENDER_TYPE_CANVAS && (this._clippingStencil.draw = this.__stencilDraw.bind(this));
- if (this._running) this._clippingStencil.onEnter();
- this._setStencilClippingSize(this._contentSize)
- } else {
- if (this._running && this._clippingStencil) this._clippingStencil.onExit();
- this._clippingStencil = null
- }
- }
- },
- setClippingType: function(a) {
- if (a != this._clippingType) {
- var c = this.isClippingEnabled();
- this.setClippingEnabled(!1);
- this._clippingType = a;
- this.setClippingEnabled(c)
- }
- },
- getClippingType: function() {
- return this._clippingType
- },
- _setStencilClippingSize: function(a) {
- if (this._clippingEnabled && this._clippingType == ccui.Layout.CLIPPING_STENCIL) {
- var c = [];
- c[0] = cc.p(0, 0);
- c[1] = cc.p(a.width, 0);
- c[2] = cc.p(a.width, a.height);
- c[3] = cc.p(0, a.height);
- a = cc.color.GREEN;
- this._clippingStencil.clear();
- this._clippingStencil.drawPoly(c, 4, a, 0, a)
- }
- },
- rendererVisitCallBack: function() {
- this._doLayout()
- },
- _getClippingRect: function() {
- if (this._clippingRectDirty) {
- for (var a = this.convertToWorldSpace(cc.p(0, 0)), c = this.nodeToWorldTransform(), d = this._contentSize.width * c.a, e = this._contentSize.height * c.d, c = this; c;)
- if ((c = c.getParent()) && c instanceof ccui.Layout && c.isClippingEnabled()) {
- this._clippingParent = c;
- break
- }
- if (this._clippingParent) {
- var c = this._clippingParent._getClippingRect(),
- f = a.x - d * this._anchorPoint.x,
- g = a.y - e * this._anchorPoint.y,
- h = d,
- k = e,
- m = a.x - c.x;
- 0 > m && (f = c.x, h += m);
- d = a.x + d - (c.x + c.width);
- 0 < d && (h -= d);
- d = a.y + e - (c.y + c.height);
- 0 < d && (k -= d);
- a = a.y - c.y;
- 0 > a && (g = c.x, k += a);
- 0 > h && (h = 0);
- 0 > k && (k = 0);
- this._clippingRect.x = f;
- this._clippingRect.y = g;
- this._clippingRect.width = h;
- this._clippingRect.height = k
- } else this._clippingRect.x = a.x - d * this._anchorPoint.x, this._clippingRect.y = a.y - e * this._anchorPoint.y, this._clippingRect.width = d, this._clippingRect.height = e;
- this._clippingRectDirty = !1
- }
- return this._clippingRect
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- var a = this._contentSize;
- this._setStencilClippingSize(a);
- this._clippingRectDirty = this._doLayoutDirty = !0;
- this._backGroundImage && (this._backGroundImage.setPosition(0.5 * a.width, 0.5 * a.height), this._backGroundScale9Enabled && this._backGroundImage instanceof cc.Scale9Sprite && this._backGroundImage.setPreferredSize(a));
- this._colorRender && this._colorRender.setContentSize(a);
- this._gradientRender && this._gradientRender.setContentSize(a)
- },
- setBackGroundImageScale9Enabled: function(a) {
- this._backGroundScale9Enabled != a && (this.removeProtectedChild(this._backGroundImage), this._backGroundImage = null, this._backGroundScale9Enabled = a, this._addBackGroundImage(), this.setBackGroundImage(this._backGroundImageFileName, this._bgImageTexType), this.setBackGroundImageCapInsets(this._backGroundImageCapInsets))
- },
- isBackGroundImageScale9Enabled: function() {
- return this._backGroundScale9Enabled
- },
- setBackGroundImage: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- null == this._backGroundImage && this._addBackGroundImage();
- this._backGroundImageFileName = a;
- this._bgImageTexType = c;
- var d = this._backGroundImage;
- if (this._backGroundScale9Enabled) {
- switch (this._bgImageTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d.initWithSpriteFrameName(a)
- }
- d.setPreferredSize(this._contentSize)
- } else switch (this._bgImageTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d.initWithSpriteFrameName(a)
- }
- this._backGroundImageTextureSize = d.getContentSize();
- d.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height);
- this._updateBackGroundImageColor()
- }
- },
- setBackGroundImageCapInsets: function(a) {
- this._backGroundImageCapInsets = a;
- this._backGroundScale9Enabled && this._backGroundImage.setCapInsets(a)
- },
- getBackGroundImageCapInsets: function() {
- return this._backGroundImageCapInsets
- },
- _supplyTheLayoutParameterLackToChild: function(a) {
- if (a) switch (this._layoutType) {
- case ccui.Layout.LINEAR_HORIZONTAL:
- case ccui.Layout.LINEAR_VERTICAL:
- var c = a.getLayoutParameter(ccui.LayoutParameter.LINEAR);
- c || a.setLayoutParameter(ccui.LinearLayoutParameter.create());
- break;
- case ccui.Layout.RELATIVE:
- (c = a.getLayoutParameter(ccui.LayoutParameter.RELATIVE)) || a.setLayoutParameter(ccui.RelativeLayoutParameter.create())
- }
- },
- _addBackGroundImage: function() {
- this._backGroundScale9Enabled ? (this._backGroundImage = cc.Scale9Sprite.create(), this._backGroundImage.setPreferredSize(this._contentSize)) : this._backGroundImage = cc.Sprite.create();
- this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1);
- this._backGroundImage.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- removeBackGroundImage: function() {
- this._backGroundImage && (this.removeProtectedChild(this._backGroundImage), this._backGroundImage = null, this._backGroundImageFileName = "", this._backGroundImageTextureSize.width = 0, this._backGroundImageTextureSize.height = 0)
- },
- setBackGroundColorType: function(a) {
- if (this._colorType != a) {
- switch (this._colorType) {
- case ccui.Layout.BG_COLOR_NONE:
- this._colorRender && (this.removeProtectedChild(this._colorRender), this._colorRender = null);
- this._gradientRender && (this.removeProtectedChild(this._gradientRender), this._gradientRender = null);
- break;
- case ccui.Layout.BG_COLOR_SOLID:
- this._colorRender && (this.removeProtectedChild(this._colorRender), this._colorRender = null);
- break;
- case ccui.Layout.BG_COLOR_GRADIENT:
- this._gradientRender && (this.removeProtectedChild(this._gradientRender), this._gradientRender = null)
- }
- this._colorType = a;
- switch (this._colorType) {
- case ccui.Layout.BG_COLOR_SOLID:
- this._colorRender = cc.LayerColor.create();
- this._colorRender.setContentSize(this._contentSize);
- this._colorRender.setOpacity(this._opacity);
- this._colorRender.setColor(this._color);
- this.addProtectedChild(this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1);
- break;
- case ccui.Layout.BG_COLOR_GRADIENT:
- this._gradientRender = cc.LayerGradient.create(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255)), this._gradientRender.setContentSize(this._contentSize), this._gradientRender.setOpacity(this._opacity), this._gradientRender.setStartColor(this._startColor), this._gradientRender.setEndColor(this._endColor), this._gradientRender.setVector(this._alongVector), this.addProtectedChild(this._gradientRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1)
- }
- }
- },
- getBackGroundColorType: function() {
- return this._colorType
- },
- setBackGroundColor: function(a, c) {
- c ? (this._startColor.r = a.r, this._startColor.g = a.g, this._startColor.b = a.b, this._gradientRender && this._gradientRender.setStartColor(a), this._endColor.r = c.r, this._endColor.g = c.g, this._endColor.b = c.b, this._gradientRender && this._gradientRender.setEndColor(c)) : (this._color.r = a.r, this._color.g = a.g, this._color.b = a.b, this._colorRender && this._colorRender.setColor(a))
- },
- getBackGroundColor: function() {
- var a = this._color;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getBackGroundStartColor: function() {
- var a = this._startColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getBackGroundEndColor: function() {
- var a = this._endColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- setBackGroundColorOpacity: function(a) {
- this._opacity = a;
- switch (this._colorType) {
- case ccui.Layout.BG_COLOR_SOLID:
- this._colorRender.setOpacity(a);
- break;
- case ccui.Layout.BG_COLOR_GRADIENT:
- this._gradientRender.setOpacity(a)
- }
- },
- getBackGroundColorOpacity: function() {
- return this._opacity
- },
- setBackGroundColorVector: function(a) {
- this._alongVector.x = a.x;
- this._alongVector.y = a.y;
- this._gradientRender && this._gradientRender.setVector(a)
- },
- getBackGroundColorVector: function() {
- return this._alongVector
- },
- setBackGroundImageColor: function(a) {
- this._backGroundImageColor.r = a.r;
- this._backGroundImageColor.g = a.g;
- this._backGroundImageColor.b = a.b;
- this._updateBackGroundImageColor()
- },
- setBackGroundImageOpacity: function(a) {
- this._backGroundImageColor.a = a;
- this.getBackGroundImageColor()
- },
- getBackGroundImageColor: function() {
- var a = this._backGroundImageColor;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getBackGroundImageOpacity: function() {
- return this._backGroundImageColor.a
- },
- _updateBackGroundImageColor: function() {
- this._backGroundImage && this._backGroundImage.setColor(this._backGroundImageColor)
- },
- getBackGroundImageTextureSize: function() {
- return this._backGroundImageTextureSize
- },
- setLayoutType: function(a) {
- this._layoutType = a;
- a = this._children;
- for (var c = null, d = 0; d < a.length; d++) c = a[d], c instanceof ccui.Widget && this._supplyTheLayoutParameterLackToChild(c);
- this._doLayoutDirty = !0
- },
- getLayoutType: function() {
- return this._layoutType
- },
- requestDoLayout: function() {
- this._doLayoutDirty = !0
- },
- _doLayout: function() {
- if (this._doLayoutDirty) {
- this.sortAllChildren();
- var a = ccui.getLayoutManager(this._layoutType);
- a && a._doLayout(this);
- this._doLayoutDirty = !1
- }
- },
- _getLayoutContentSize: function() {
- return this.getContentSize()
- },
- _getLayoutElements: function() {
- return this.getChildren()
- },
- _onBeforeVisitStencil: function() {},
- _drawFullScreenQuadClearStencil: function() {},
- _onAfterDrawStencil: function() {},
- _onAfterVisitStencil: function() {},
- _onAfterVisitScissor: function() {},
- _onAfterVisitScissor: function() {},
- _updateBackGroundImageOpacity: function() {
- this._backGroundImage && this._backGroundImage.setOpacity(this._backGroundImageOpacity)
- },
- _updateBackGroundImageRGBA: function() {
- this._backGroundImage && (this._backGroundImage.setColor(this._backGroundImageColor), this._backGroundImage.setOpacity(this._backGroundImageOpacity))
- },
- _getLayoutAccumulatedSize: function() {
- for (var a = this.getChildren(), c = cc.size(0, 0), d = 0, e, f = 0, g = a.length; f < g; f++)
- if (e = a[f], null != e && e instanceof ccui.Layout) e = e._getLayoutAccumulatedSize(), c.width += e.width, c.height += e.height;
- else if (e instanceof ccui.Widget) {
- d++;
- var h = e.getLayoutParameter().getMargin();
- e = e.getContentSize();
- c.width += e.width + 0.5 * (h.right + h.left);
- c.height += e.height + 0.5 * (h.top + h.bottom)
- }
- a = this.getLayoutType();
- a == ccui.Layout.LINEAR_HORIZONTAL && (c.height -= c.height / d * (d - 1));
- a == ccui.Layout.LINEAR_VERTICAL && (c.width -= c.width / d * (d - 1));
- return c
- },
- _findNearestChildWidgetIndex: function(a, c) {
- if (null == c || c == this) return this._findFirstFocusEnabledWidgetIndex();
- var d = 0,
- e = this.getChildren(),
- f = e.length,
- g, h = cc.FLT_MAX,
- k = 0;
- if (a == ccui.Widget.LEFT || a == ccui.Widget.RIGHT || a == ccui.Widget.DOWN || a == ccui.Widget.UP) {
- for (g = this._getWorldCenterPoint(c); d < f;) {
- var m = e[d];
- m && (m instanceof ccui.Widget && m.isFocusEnabled()) && (m = m instanceof ccui.Layout ? m._calculateNearestDistance(c) : cc.pLength(cc.pSub(this._getWorldCenterPoint(m), g)), m < h && (k = d, h = m));
- d++
- }
- return k
- }
- cc.log("invalid focus direction!");
- return 0
- },
- _findFarthestChildWidgetIndex: function(a, c) {
- if (null == c || c == this) return this._findFirstFocusEnabledWidgetIndex();
- var d = 0,
- e = this.getChildren(),
- f = e.length,
- g = -cc.FLT_MAX,
- h = 0;
- if (a == ccui.Widget.LEFT || a == ccui.Widget.RIGHT || a == ccui.Widget.DOWN || a == ccui.Widget.UP) {
- for (var k = this._getWorldCenterPoint(c); d < f;) {
- var m = e[d];
- m && (m instanceof ccui.Widget && m.isFocusEnabled()) && (m = m instanceof ccui.Layout ? m._calculateFarthestDistance(c) : cc.pLength(cc.pSub(this._getWorldCenterPoint(m), k)), m > g && (h = d, g = m));
- d++
- }
- return h
- }
- cc.log("invalid focus direction!!!");
- return 0
- },
- _calculateNearestDistance: function(a) {
- for (var c = cc.FLT_MAX, d = this._getWorldCenterPoint(a), e = this._children, f = 0, g = e.length; f < g; f++) {
- var h = e[f];
- if (h instanceof ccui.Layout) h = h._calculateNearestDistance(a);
- else if (h instanceof ccui.Widget && h.isFocusEnabled()) h = cc.pLength(cc.pSub(this._getWorldCenterPoint(h), d));
- else continue;
- h < c && (c = h)
- }
- return c
- },
- _calculateFarthestDistance: function(a) {
- for (var c = -cc.FLT_MAX, d = this._getWorldCenterPoint(a), e = this._children, f = 0, g = e.length; f < g; f++) {
- var h = e[f];
- if (h instanceof ccui.Layout) h = h._calculateFarthestDistance(a);
- else if (h instanceof ccui.Widget && h.isFocusEnabled()) h = this._getWorldCenterPoint(h), h = cc.pLength(cc.pSub(h, d));
- else continue;
- h > c && (c = h)
- }
- return c
- },
- _findProperSearchingFunctor: function(a, c) {
- if (null != c) {
- var d = this._getWorldCenterPoint(c),
- e = this._getWorldCenterPoint(this._findFirstNonLayoutWidget());
- a == ccui.Widget.LEFT ? this.onPassFocusToChild = d.x > e.x ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this) : a == ccui.Widget.RIGHT ? this.onPassFocusToChild = d.x > e.x ? this._findFarthestChildWidgetIndex.bind(this) : this._findNearestChildWidgetIndex.bind(this) : a == ccui.Widget.DOWN ? this.onPassFocusToChild = d.y > e.y ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this) : a == ccui.Widget.UP ? this.onPassFocusToChild = d.y < e.y ? this._findNearestChildWidgetIndex.bind(this) : this._findFarthestChildWidgetIndex.bind(this) : cc.log("invalid direction!")
- }
- },
- _findFirstNonLayoutWidget: function() {
- for (var a = this._children, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- if (e instanceof ccui.Layout) {
- if (e = e._findFirstNonLayoutWidget()) return e
- } else if (e instanceof cc.Widget) return e
- }
- return null
- },
- _findFirstFocusEnabledWidgetIndex: function() {
- for (var a = 0, c = this.getChildren(), d = c.length; a < d;) {
- var e = c[a];
- if (e && e instanceof ccui.Widget && e.isFocusEnabled()) return a;
- a++
- }
- return 0
- },
- _findFocusEnabledChildWidgetByIndex: function(a) {
- var c = this._getChildWidgetByIndex(a);
- return c ? c.isFocusEnabled() ? c : this._findFocusEnabledChildWidgetByIndex(a + 1) : null
- },
- _getWorldCenterPoint: function(a) {
- var c = a instanceof ccui.Layout ? a._getLayoutAccumulatedSize() : a.getContentSize();
- return a.convertToWorldSpace(cc.p(c.width / 2, c.height / 2))
- },
- _getNextFocusedWidget: function(a, c) {
- var d = null,
- d = this._children,
- e = d.indexOf(c),
- e = e + 1;
- if (e < d.length) {
- if (d = this._getChildWidgetByIndex(e)) {
- if (d.isFocusEnabled()) {
- if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
- this.dispatchFocusEvent(c, d);
- return d
- }
- return this._getNextFocusedWidget(a, d)
- }
- return c
- }
- if (this._loopFocus) {
- if (this._checkFocusEnabledChild()) {
- d = this._getChildWidgetByIndex(0);
- if (d.isFocusEnabled()) {
- if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
- this.dispatchFocusEvent(c, d);
- return d
- }
- return this._getNextFocusedWidget(a, d)
- }
- return c instanceof ccui.Layout ? c : this._focusedWidget
- }
- return this._isLastWidgetInContainer(c, a) ? this._isWidgetAncestorSupportLoopFocus(this, a) ? this.findNextFocusedWidget(a, this) : c instanceof ccui.Layout ? c : this._focusedWidget : this.findNextFocusedWidget(a, this)
- },
- _getPreviousFocusedWidget: function(a, c) {
- var d = null,
- d = this._children,
- e = d.indexOf(c),
- e = e - 1;
- if (0 <= e) {
- d = this._getChildWidgetByIndex(e);
- if (d.isFocusEnabled()) {
- if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
- this.dispatchFocusEvent(c, d);
- return d
- }
- return this._getPreviousFocusedWidget(a, d)
- }
- if (this._loopFocus) {
- if (this._checkFocusEnabledChild()) {
- e = d.length - 1;
- d = this._getChildWidgetByIndex(e);
- if (d.isFocusEnabled()) {
- if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
- this.dispatchFocusEvent(c, d);
- return d
- }
- return this._getPreviousFocusedWidget(a, d)
- }
- return c instanceof ccui.Layout ? c : this._focusedWidget
- }
- return this._isLastWidgetInContainer(c, a) ? this._isWidgetAncestorSupportLoopFocus(this, a) ? this.findNextFocusedWidget(a, this) : c instanceof ccui.Layout ? c : this._focusedWidget : this.findNextFocusedWidget(a, this)
- },
- _getChildWidgetByIndex: function(a) {
- for (var c = this._children, d = c.length, e = 0, f = a; a < d;) {
- var g = c[a];
- if (g && g instanceof ccui.Widget) return g;
- e++;
- a++
- }
- for (a = 0; a < f;) {
- if ((d = c[a]) && d instanceof ccui.Widget) return d;
- e++;
- a++
- }
- return null
- },
- _isLastWidgetInContainer: function(a, c) {
- var d = a.getParent();
- if (d instanceof ccui.Layout) return !0;
- var e = d.getChildren(),
- f = e.indexOf(a);
- if (d.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) {
- if (c == ccui.Widget.LEFT) return 0 == f ? this._isLastWidgetInContainer(d, c) : !1;
- if (c == ccui.Widget.RIGHT) return f == e.length - 1 ? this._isLastWidgetInContainer(d, c) : !1;
- if (c == ccui.Widget.DOWN || c == ccui.Widget.UP) return this._isLastWidgetInContainer(d, c)
- } else if (d.getLayoutType() == ccui.Layout.LINEAR_VERTICAL) {
- if (c == ccui.Widget.UP) return 0 == f ? this._isLastWidgetInContainer(d, c) : !1;
- if (c == ccui.Widget.DOWN) return f == e.length - 1 ? this._isLastWidgetInContainer(d, c) : !1;
- if (c == ccui.Widget.LEFT || c == ccui.Widget.RIGHT) return this._isLastWidgetInContainer(d, c)
- } else return cc.log("invalid layout Type"), !1
- },
- _isWidgetAncestorSupportLoopFocus: function(a, c) {
- var d = a.getParent();
- if (null == d) return !1;
- if (d.isLoopFocus()) {
- var e = d.getLayoutType();
- if (e == ccui.Layout.LINEAR_HORIZONTAL) return c == ccui.Widget.LEFT || c == ccui.Widget.RIGHT ? !0 : this._isWidgetAncestorSupportLoopFocus(d, c);
- if (e == ccui.Layout.LINEAR_VERTICAL) return c == ccui.Widget.DOWN || c == ccui.Widget.UP ? !0 : this._isWidgetAncestorSupportLoopFocus(d, c);
- cc.assert(0, "invalid layout type")
- } else return this._isWidgetAncestorSupportLoopFocus(d, c)
- },
- _passFocusToChild: function(a, c) {
- if (this._checkFocusEnabledChild()) {
- var d = ccui.Widget.getCurrentFocusedWidget();
- this._findProperSearchingFunctor(a, d);
- d = this.onPassFocusToChild(a, d);
- d = this._getChildWidgetByIndex(d);
- if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
- this.dispatchFocusEvent(c, d);
- return d
- }
- return this
- },
- _checkFocusEnabledChild: function() {
- for (var a = this._children, c = 0, d = a.length; c < d; c++) {
- var e = a[c];
- if (e && e instanceof ccui.Widget && e.isFocusEnabled()) return !0
- }
- return !1
- },
- getDescription: function() {
- return "Layout"
- },
- _createCloneInstance: function() {
- return ccui.Layout.create()
- },
- _copyClonedWidgetChildren: function(a) {
- ccui.Widget.prototype._copyClonedWidgetChildren.call(this, a)
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.Layout && (this.setBackGroundImageScale9Enabled(a._backGroundScale9Enabled), this.setBackGroundImage(a._backGroundImageFileName, a._bgImageTexType), this.setBackGroundImageCapInsets(a._backGroundImageCapInsets), this.setBackGroundColorType(a._colorType), this.setBackGroundColor(a._color), this.setBackGroundColor(a._startColor, a._endColor), this.setBackGroundColorOpacity(a._opacity), this.setBackGroundColorVector(a._alongVector), this.setLayoutType(a._layoutType), this.setClippingEnabled(a._clippingEnabled), this.setClippingType(a._clippingType), this._loopFocus = a._loopFocus, this.__passFocusToChild = a.__passFocusToChild)
- }
- });
- ccui.Layout._init_once = null;
- ccui.Layout._visit_once = null;
- ccui.Layout._layer = -1;
- ccui.Layout._sharedCache = null;
- cc._renderType == cc._RENDER_TYPE_WEBGL ? (ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForWebGL, ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._scissorClippingVisitForWebGL) : (ccui.Layout.prototype._stencilClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas, ccui.Layout.prototype._scissorClippingVisit = ccui.Layout.prototype._stencilClippingVisitForCanvas);
- ccui.Layout._getSharedCache = function() {
- return cc.ClippingNode._sharedCache || (cc.ClippingNode._sharedCache = cc.newElement("canvas"))
- };
- _p = ccui.Layout.prototype;
- cc.defineGetterSetter(_p, "clippingEnabled", _p.isClippingEnabled, _p.setClippingEnabled);
- cc.defineGetterSetter(_p, "clippingType", null, _p.setClippingType);
- cc.defineGetterSetter(_p, "layoutType", _p.getLayoutType, _p.setLayoutType);
- _p = null;
- ccui.Layout.create = function() {
- return new ccui.Layout
- };
- ccui.Layout.BG_COLOR_NONE = 0;
- ccui.Layout.BG_COLOR_SOLID = 1;
- ccui.Layout.BG_COLOR_GRADIENT = 2;
- ccui.Layout.ABSOLUTE = 0;
- ccui.Layout.LINEAR_VERTICAL = 1;
- ccui.Layout.LINEAR_HORIZONTAL = 2;
- ccui.Layout.RELATIVE = 3;
- ccui.Layout.CLIPPING_STENCIL = 0;
- ccui.Layout.CLIPPING_SCISSOR = 1;
- ccui.Layout.BACKGROUND_IMAGE_ZORDER = -2;
- ccui.Layout.BACKGROUND_RENDERER_ZORDER = -2;
- ccui.Margin = ccui.Class.extend({
- left: 0,
- top: 0,
- right: 0,
- bottom: 0,
- ctor: function(a, c, d, e) {
- a && void 0 === c && (this.left = a.left, this.top = a.top, this.right = a.right, this.bottom = a.bottom);
- void 0 !== e && (this.left = a, this.top = c, this.right = d, this.bottom = e)
- },
- setMargin: function(a, c, d, e) {
- this.left = a;
- this.top = c;
- this.right = d;
- this.bottom = e
- },
- equals: function(a) {
- return this.left == a.left && this.top == a.top && this.right == a.right && this.bottom == a.bottom
- }
- });
- ccui.MarginZero = function() {
- return new ccui.Margin(0, 0, 0, 0)
- };
- ccui.LayoutParameter = ccui.Class.extend({
- _margin: null,
- _layoutParameterType: null,
- ctor: function() {
- this._margin = new ccui.Margin;
- this._layoutParameterType = ccui.LayoutParameter.NONE
- },
- setMargin: function(a, c, d, e) {
- "object" === typeof a ? (this._margin.left = a.left, this._margin.top = a.top, this._margin.right = a.right, this._margin.bottom = a.bottom) : (this._margin.left = a, this._margin.top = c, this._margin.right = d, this._margin.bottom = e)
- },
- getMargin: function() {
- return this._margin
- },
- getLayoutType: function() {
- return this._layoutParameterType
- },
- clone: function() {
- var a = this._createCloneInstance();
- a._copyProperties(this);
- return a
- },
- _createCloneInstance: function() {
- return ccui.LayoutParameter.create()
- },
- _copyProperties: function(a) {
- this._margin.bottom = a._margin.bottom;
- this._margin.left = a._margin.left;
- this._margin.right = a._margin.right;
- this._margin.top = a._margin.top
- }
- });
- ccui.LayoutParameter.create = function() {
- return new ccui.LayoutParameter
- };
- ccui.LayoutParameter.NONE = 0;
- ccui.LayoutParameter.LINEAR = 1;
- ccui.LayoutParameter.RELATIVE = 2;
- ccui.LinearLayoutParameter = ccui.LayoutParameter.extend({
- _linearGravity: null,
- ctor: function() {
- ccui.LayoutParameter.prototype.ctor.call(this);
- this._linearGravity = ccui.LinearLayoutParameter.NONE;
- this._layoutParameterType = ccui.LayoutParameter.LINEAR
- },
- setGravity: function(a) {
- this._linearGravity = a
- },
- getGravity: function() {
- return this._linearGravity
- },
- _createCloneInstance: function() {
- return ccui.LinearLayoutParameter.create()
- },
- _copyProperties: function(a) {
- ccui.LayoutParameter.prototype._copyProperties.call(this, a);
- a instanceof ccui.LinearLayoutParameter && this.setGravity(a._linearGravity)
- }
- });
- ccui.LinearLayoutParameter.create = function() {
- return new ccui.LinearLayoutParameter
- };
- ccui.LinearLayoutParameter.NONE = 0;
- ccui.LinearLayoutParameter.LEFT = 1;
- ccui.LinearLayoutParameter.TOP = 2;
- ccui.LinearLayoutParameter.RIGHT = 3;
- ccui.LinearLayoutParameter.BOTTOM = 4;
- ccui.LinearLayoutParameter.CENTER_VERTICAL = 5;
- ccui.LinearLayoutParameter.CENTER_HORIZONTAL = 6;
- ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend({
- _relativeAlign: null,
- _relativeWidgetName: "",
- _relativeLayoutName: "",
- _put: !1,
- ctor: function() {
- ccui.LayoutParameter.prototype.ctor.call(this);
- this._relativeAlign = ccui.RelativeLayoutParameter.NONE;
- this._relativeLayoutName = this._relativeWidgetName = "";
- this._put = !1;
- this._layoutParameterType = ccui.LayoutParameter.RELATIVE
- },
- setAlign: function(a) {
- this._relativeAlign = a
- },
- getAlign: function() {
- return this._relativeAlign
- },
- setRelativeToWidgetName: function(a) {
- this._relativeWidgetName = a
- },
- getRelativeToWidgetName: function() {
- return this._relativeWidgetName
- },
- setRelativeName: function(a) {
- this._relativeLayoutName = a
- },
- getRelativeName: function() {
- return this._relativeLayoutName
- },
- _createCloneInstance: function() {
- return ccui.RelativeLayoutParameter.create()
- },
- _copyProperties: function(a) {
- ccui.LayoutParameter.prototype._copyProperties.call(this, a);
- a instanceof ccui.RelativeLayoutParameter && (this.setAlign(a._relativeAlign), this.setRelativeToWidgetName(a._relativeWidgetName), this.setRelativeName(a._relativeLayoutName))
- }
- });
- ccui.RelativeLayoutParameter.create = function() {
- return new ccui.RelativeLayoutParameter
- };
- ccui.RelativeLayoutParameter.NONE = 0;
- ccui.RelativeLayoutParameter.PARENT_TOP_LEFT = 1;
- ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL = 2;
- ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT = 3;
- ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL = 4;
- ccui.RelativeLayoutParameter.CENTER_IN_PARENT = 5;
- ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL = 6;
- ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM = 7;
- ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL = 8;
- ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM = 9;
- ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN = 10;
- ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER = 11;
- ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN = 12;
- ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN = 13;
- ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER = 14;
- ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN = 15;
- ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN = 16;
- ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17;
- ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18;
- ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19;
- ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20;
- ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21;
- ccui.LINEAR_GRAVITY_NONE = 0;
- ccui.LINEAR_GRAVITY_LEFT = 1;
- ccui.LINEAR_GRAVITY_TOP = 2;
- ccui.LINEAR_GRAVITY_RIGHT = 3;
- ccui.LINEAR_GRAVITY_BOTTOM = 4;
- ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5;
- ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6;
- ccui.RELATIVE_ALIGN_NONE = 0;
- ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1;
- ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2;
- ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3;
- ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4;
- ccui.RELATIVE_ALIGN_PARENT_CENTER = 5;
- ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6;
- ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7;
- ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8;
- ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9;
- ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10;
- ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11;
- ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12;
- ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13;
- ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14;
- ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15;
- ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16;
- ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17;
- ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18;
- ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19;
- ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20;
- ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21;
- ccui.getLayoutManager = function(a) {
- switch (a) {
- case ccui.Layout.LINEAR_VERTICAL:
- return ccui.linearVerticalLayoutManager;
- case ccui.Layout.LINEAR_HORIZONTAL:
- return ccui.linearHorizontalLayoutManager;
- case ccui.Layout.RELATIVE:
- return ccui.relativeLayoutManager
- }
- return null
- };
- ccui.linearVerticalLayoutManager = {
- _doLayout: function(a) {
- var c = a._getLayoutContentSize();
- a = a._getLayoutElements();
- for (var d = c.height, e = 0, f = a.length; e < f; e++) {
- var g = a[e];
- if (g) {
- var h = g.getLayoutParameter();
- if (h) {
- var k = h.getGravity(),
- m = g.getAnchorPoint(),
- n = g.getContentSize(),
- q = m.x * n.width,
- d = d - (1 - m.y) * n.height;
- switch (k) {
- case ccui.LinearLayoutParameter.RIGHT:
- q = c.width - (1 - m.x) * n.width;
- break;
- case ccui.LinearLayoutParameter.CENTER_HORIZONTAL:
- q = c.width / 2 - n.width * (0.5 - m.x)
- }
- h = h.getMargin();
- q += h.left;
- d -= h.top;
- g.setPosition(q, d);
- d = g.getPositionY() - g.getAnchorPoint().y * g.getContentSize().height - h.bottom
- }
- }
- }
- }
- };
- ccui.linearHorizontalLayoutManager = {
- _doLayout: function(a) {
- var c = a._getLayoutContentSize();
- a = a._getLayoutElements();
- for (var d = 0, e = 0, f = a.length; e < f; e++) {
- var g = a[e];
- if (g) {
- var h = g.getLayoutParameter();
- if (h) {
- var k = h.getGravity(),
- m = g.getAnchorPoint(),
- n = g.getSize(),
- d = d + m.x * n.width,
- q = c.height - (1 - m.y) * n.height;
- switch (k) {
- case ccui.LinearLayoutParameter.BOTTOM:
- q = m.y * n.height;
- break;
- case ccui.LinearLayoutParameter.CENTER_VERTICAL:
- q = c.height / 2 - n.height * (0.5 - m.y)
- }
- h = h.getMargin();
- d += h.left;
- q -= h.top;
- g.setPosition(d, q);
- d = g.getRightBoundary() + h.right
- }
- }
- }
- }
- };
- ccui.relativeLayoutManager = {
- _unlayoutChildCount: 0,
- _widgetChildren: [],
- _widget: null,
- _finalPositionX: 0,
- _finalPositionY: 0,
- _relativeWidgetLP: null,
- _doLayout: function(a) {
- for (var c = this._widgetChildren = this._getAllWidgets(a); 0 < this._unlayoutChildCount;) {
- for (var d = 0, e = c.length; d < e; d++) {
- this._widget = c[d];
- var f = this._widget.getLayoutParameter();
- f && !f._put && this._calculateFinalPositionWithRelativeWidget(a) && (this._calculateFinalPositionWithRelativeAlign(), this._widget.setPosition(this._finalPositionX, this._finalPositionY), f._put = !0)
- }
- this._unlayoutChildCount--
- }
- this._widgetChildren.length = 0
- },
- _getAllWidgets: function(a) {
- a = a._getLayoutElements();
- for (var c = this._widgetChildren, d = c.length = 0, e = a.length; d < e; d++) {
- var f = a[d];
- f && (f.getLayoutParameter()._put = !1, this._unlayoutChildCount++, c.push(f))
- }
- return c
- },
- _getRelativeWidget: function(a) {
- var c = null;
- if ((a = a.getLayoutParameter().getRelativeToWidgetName()) && 0 != a.length)
- for (var d = this._widgetChildren, e = 0, f = d.length; e < f; e++) {
- var g = d[e];
- if (g) {
- var h = g.getLayoutParameter();
- if (h && h.getRelativeName() == a) {
- c = g;
- this._relativeWidgetLP = h;
- break
- }
- }
- }
- return c
- },
- _calculateFinalPositionWithRelativeWidget: function(a) {
- var c = this._widget,
- d = c.getAnchorPoint(),
- e = c.getContentSize();
- this._finalPositionY = this._finalPositionX = 0;
- var f = this._getRelativeWidget(c),
- c = c.getLayoutParameter().getAlign();
- a = a._getLayoutContentSize();
- switch (c) {
- case ccui.RelativeLayoutParameter.NONE:
- case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:
- this._finalPositionX = d.x * e.width;
- this._finalPositionY = a.height - (1 - d.y) * e.height;
- break;
- case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:
- this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
- this._finalPositionY = a.height - (1 - d.y) * e.height;
- break;
- case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:
- this._finalPositionX = a.width - (1 - d.x) * e.width;
- this._finalPositionY = a.height - (1 - d.y) * e.height;
- break;
- case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:
- this._finalPositionX = d.x * e.width;
- this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
- break;
- case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:
- this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
- this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
- break;
- case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:
- this._finalPositionX = a.width - (1 - d.x) * e.width;
- this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
- break;
- case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:
- this._finalPositionX = d.x * e.width;
- this._finalPositionY = d.y * e.height;
- break;
- case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:
- this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
- this._finalPositionY = d.y * e.height;
- break;
- case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:
- this._finalPositionX = a.width - (1 - d.x) * e.width;
- this._finalPositionY = d.y * e.height;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getTopBoundary() + d.y * e.height;
- this._finalPositionX = f.getLeftBoundary() + d.x * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- a = f.getContentSize();
- this._finalPositionY = f.getTopBoundary() + d.y * e.height;
- this._finalPositionX = f.getLeftBoundary() + 0.5 * a.width + d.x * e.width - 0.5 * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getTopBoundary() + d.y * e.height;
- this._finalPositionX = f.getRightBoundary() - (1 - d.x) * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getTopBoundary() - (1 - d.y) * e.height;
- this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- a = f.getContentSize();
- this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width;
- this._finalPositionY = f.getBottomBoundary() + 0.5 * a.height + d.y * e.height - 0.5 * e.height
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getBottomBoundary() + d.y * e.height;
- this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getTopBoundary() - (1 - d.y) * e.height;
- this._finalPositionX = f.getRightBoundary() + d.x * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- a = f.getContentSize();
- this._finalPositionX = f.getRightBoundary() + d.x * e.width;
- this._finalPositionY = f.getBottomBoundary() + 0.5 * a.height + d.y * e.height - 0.5 * e.height
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getBottomBoundary() + d.y * e.height;
- this._finalPositionX = f.getRightBoundary() + d.x * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
- this._finalPositionX = f.getLeftBoundary() + d.x * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- a = f.getContentSize();
- this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
- this._finalPositionX = f.getLeftBoundary() + 0.5 * a.width + d.x * e.width - 0.5 * e.width
- }
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:
- if (f) {
- if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
- this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
- this._finalPositionX = f.getRightBoundary() - (1 - d.x) * e.width
- }
- }
- return !0
- },
- _calculateFinalPositionWithRelativeAlign: function() {
- var a = this._widget.getLayoutParameter(),
- c = a.getMargin();
- switch (a.getAlign()) {
- case ccui.RelativeLayoutParameter.NONE:
- case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:
- this._finalPositionX += c.left;
- this._finalPositionY -= c.top;
- break;
- case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:
- this._finalPositionY -= c.top;
- break;
- case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:
- this._finalPositionX -= c.right;
- this._finalPositionY -= c.top;
- break;
- case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:
- this._finalPositionX += c.left;
- break;
- case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:
- this._finalPositionX -= c.right;
- break;
- case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:
- this._finalPositionX += c.left;
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:
- this._finalPositionX -= c.right;
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:
- this._finalPositionY += c.bottom;
- this._finalPositionX += c.left;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:
- this._finalPositionY += c.bottom;
- this._finalPositionX -= c.right;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:
- this._finalPositionX -= c.right;
- this._finalPositionY -= c.top;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:
- this._finalPositionX -= c.right;
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:
- this._finalPositionX -= c.right;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:
- this._finalPositionX += c.left;
- this._finalPositionY -= c.top;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:
- this._finalPositionX += c.left;
- this._finalPositionY += c.bottom;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:
- this._finalPositionX += c.left;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:
- this._finalPositionY -= c.top;
- this._finalPositionX += c.left;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:
- this._finalPositionY -= c.top;
- this._finalPositionX -= c.right;
- break;
- case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:
- this._finalPositionY -= c.top
- }
- }
- };
- ccui.HBox = ccui.Layout.extend({
- init: function() {
- return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL), !0) : !1
- },
- initWithSize: function(a) {
- return this.init() ? (this.setContentSize(a), !0) : !1
- }
- });
- ccui.HBox.create = function(a) {
- var c = new ccui.HBox;
- if (a) {
- if (c.initWithSize(a)) return c
- } else if (c.init()) return c;
- return null
- };
- ccui.RelativeBox = ccui.Layout.extend({
- init: function() {
- return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.RELATIVE), !0) : !1
- },
- initWithSize: function(a) {
- return this.init() ? (this.setContentSize(a), !0) : !1
- }
- });
- ccui.RelativeBox.create = function(a) {
- var c = new ccui.RelativeBox;
- if (a) {
- if (c.initWithSize(a)) return c
- } else if (c.init()) return c;
- return null
- };
- ccui.VBox = ccui.Layout.extend({
- init: function() {
- return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_VERTICAL), !0) : !1
- },
- initWithSize: function(a) {
- return this.init() ? (this.setContentSize(a), !0) : !1
- }
- });
- ccui.VBox.create = function(a) {
- var c = new ccui.VBox;
- if (a) {
- if (c.initWithSize(a)) return c
- } else if (c.init()) return c;
- return null
- };
- ccui.helper = {
- seekWidgetByTag: function(a, c) {
- if (!a) return null;
- if (a.getTag() == c) return a;
- for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
- var g = ccui.helper.seekWidgetByTag(d[f], c);
- if (null != g) return g
- }
- return null
- },
- seekWidgetByName: function(a, c) {
- if (!a) return null;
- if (a.getName() == c) return a;
- for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
- var g = ccui.helper.seekWidgetByName(d[f], c);
- if (null != g) return g
- }
- return null
- },
- seekWidgetByRelativeName: function(a, c) {
- if (!a) return null;
- for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
- var g = d[f],
- h = g.getLayoutParameter(ccui.LayoutParameter.RELATIVE);
- if (h && h.getRelativeName() == c) return g
- }
- return null
- },
- seekActionWidgetByActionTag: function(a, c) {
- if (!a) return null;
- if (a.getActionTag() == c) return a;
- for (var d = a.getChildren(), e = 0; e < d.length; e++) {
- var f = ccui.helper.seekActionWidgetByActionTag(d[e], c);
- if (null != f) return f
- }
- return null
- }
- };
- ccui.Button = ccui.Widget.extend({
- _buttonNormalRenderer: null,
- _buttonClickedRenderer: null,
- _buttonDisableRenderer: null,
- _titleRenderer: null,
- _normalFileName: "",
- _clickedFileName: "",
- _disabledFileName: "",
- _prevIgnoreSize: !0,
- _scale9Enabled: !1,
- _capInsetsNormal: null,
- _capInsetsPressed: null,
- _capInsetsDisabled: null,
- _normalTexType: ccui.Widget.LOCAL_TEXTURE,
- _pressedTexType: ccui.Widget.LOCAL_TEXTURE,
- _disabledTexType: ccui.Widget.LOCAL_TEXTURE,
- _normalTextureSize: null,
- _pressedTextureSize: null,
- _disabledTextureSize: null,
- pressedActionEnabled: !1,
- _titleColor: null,
- _normalTextureScaleXInSize: 1,
- _normalTextureScaleYInSize: 1,
- _pressedTextureScaleXInSize: 1,
- _pressedTextureScaleYInSize: 1,
- _normalTextureLoaded: !1,
- _pressedTextureLoaded: !1,
- _disabledTextureLoaded: !1,
- _className: "Button",
- _normalTextureAdaptDirty: !0,
- _pressedTextureAdaptDirty: !0,
- _disabledTextureAdaptDirty: !0,
- _fontName: "Thonburi",
- _fontSize: 12,
- _type: 0,
- ctor: function(a, c, d, e) {
- this._capInsetsNormal = cc.rect(0, 0, 0, 0);
- this._capInsetsPressed = cc.rect(0, 0, 0, 0);
- this._capInsetsDisabled = cc.rect(0, 0, 0, 0);
- this._normalTextureSize = cc.size(0, 0);
- this._pressedTextureSize = cc.size(0, 0);
- this._disabledTextureSize = cc.size(0, 0);
- this._titleColor = cc.color.WHITE;
- ccui.Widget.prototype.ctor.call(this);
- this.setTouchEnabled(!0);
- e && this.init(a, c, d, e)
- },
- init: function(a, c, d, e) {
- if (ccui.Widget.prototype.init.call(this)) {
- if (void 0 === a) return !0;
- this.loadTextures(a, c, d, e)
- }
- return !1
- },
- _initRenderer: function() {
- this._buttonNormalRenderer = cc.Sprite.create();
- this._buttonClickedRenderer = cc.Sprite.create();
- this._buttonDisableRenderer = cc.Sprite.create();
- this._titleRenderer = cc.LabelTTF.create("");
- this._titleRenderer.setAnchorPoint(0.5, 0.5);
- this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._titleRenderer, ccui.Button.TITLE_RENDERER_ZORDER, -1)
- },
- setScale9Enabled: function(a) {
- this._scale9Enabled != a && (this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE, this._scale9Enabled = a, this.removeProtectedChild(this._buttonNormalRenderer), this.removeProtectedChild(this._buttonClickedRenderer), this.removeProtectedChild(this._buttonDisableRenderer), this._scale9Enabled ? (this._buttonNormalRenderer = cc.Scale9Sprite.create(), this._buttonClickedRenderer = cc.Scale9Sprite.create(), this._buttonDisableRenderer = cc.Scale9Sprite.create()) : (this._buttonNormalRenderer = cc.Sprite.create(), this._buttonClickedRenderer = cc.Sprite.create(), this._buttonDisableRenderer = cc.Sprite.create()), this.loadTextureNormal(this._normalFileName, this._normalTexType), this.loadTexturePressed(this._clickedFileName, this._pressedTexType), this.loadTextureDisabled(this._disabledFileName, this._disabledTexType), this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1), this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1), this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1), this._scale9Enabled ? (a = this._ignoreSize, this.ignoreContentAdaptWithSize(!1), this._prevIgnoreSize = a) : this.ignoreContentAdaptWithSize(this._prevIgnoreSize), this.setCapInsetsNormalRenderer(this._capInsetsNormal), this.setCapInsetsPressedRenderer(this._capInsetsPressed), this.setCapInsetsDisabledRenderer(this._capInsetsDisabled), this.setBright(this._bright))
- },
- isScale9Enabled: function() {
- return this._scale9Enabled
- },
- ignoreContentAdaptWithSize: function(a) {
- if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
- },
- getVirtualRendererSize: function() {
- return cc.size(this._normalTextureSize)
- },
- loadTextures: function(a, c, d, e) {
- this.loadTextureNormal(a, e);
- this.loadTexturePressed(c, e);
- this.loadTextureDisabled(d, e)
- },
- loadTextureNormal: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._normalFileName = a;
- this._normalTexType = c;
- var d = this;
- (!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()) && this._buttonNormalRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._normalTextureSize = d._buttonNormalRenderer.getContentSize();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._buttonNormalRenderer.setColor(d.getColor());
- d._buttonNormalRenderer.setOpacity(d.getOpacity());
- d._updateContentSizeWithTextureSize(d._normalTextureSize);
- d._normalTextureLoaded = !0;
- d._normalTextureAdaptDirty = !0
- });
- if (this._scale9Enabled) {
- var e = this._buttonNormalRenderer;
- switch (this._normalTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- e.setCapInsets(this._capInsetsNormal)
- } else switch (e = this._buttonNormalRenderer, this._normalTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- this._normalTextureSize = this._buttonNormalRenderer.getContentSize();
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._updateContentSizeWithTextureSize(this._normalTextureSize);
- this._normalTextureAdaptDirty = this._normalTextureLoaded = !0
- }
- },
- loadTexturePressed: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._clickedFileName = a;
- this._pressedTexType = c;
- var d = this;
- (!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()) && this._buttonClickedRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._pressedTextureSize = d._buttonClickedRenderer.getContentSize();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._pressedTextureLoaded = !0;
- d._pressedTextureAdaptDirty = !0
- });
- if (this._scale9Enabled) {
- var e = this._buttonClickedRenderer;
- switch (this._pressedTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- e.setCapInsets(this._capInsetsPressed)
- } else switch (e = this._buttonClickedRenderer, this._pressedTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- this._pressedTextureSize = this._buttonClickedRenderer.getContentSize();
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._pressedTextureAdaptDirty = this._pressedTextureLoaded = !0
- }
- },
- loadTextureDisabled: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._disabledFileName = a;
- this._disabledTexType = c;
- var d = this;
- (!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()) && this._buttonDisableRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._disabledTextureSize = d._buttonDisableRenderer.getContentSize();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._disabledTextureLoaded = !0;
- d._disabledTextureAdaptDirty = !0
- });
- if (this._scale9Enabled) {
- var e = this._buttonDisableRenderer;
- switch (this._disabledTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- e.setCapInsets(this._capInsetsDisabled)
- } else switch (e = this._buttonDisableRenderer, this._disabledTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- e.initWithSpriteFrameName(a)
- }
- this._disabledTextureSize = this._buttonDisableRenderer.getContentSize();
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._disabledTextureAdaptDirty = this._disabledTextureLoaded = !0
- }
- },
- setCapInsets: function(a) {
- this.setCapInsetsNormalRenderer(a);
- this.setCapInsetsPressedRenderer(a);
- this.setCapInsetsDisabledRenderer(a)
- },
- setCapInsetsNormalRenderer: function(a) {
- this._capInsetsNormal = a;
- this._scale9Enabled && this._buttonNormalRenderer.setCapInsets(a)
- },
- getCapInsetsNormalRenderer: function() {
- return this._capInsetsNormal
- },
- setCapInsetsPressedRenderer: function(a) {
- this._capInsetsPressed = a;
- this._scale9Enabled && this._buttonClickedRenderer.setCapInsets(a)
- },
- getCapInsetsPressedRenderer: function() {
- return this._capInsetsPressed
- },
- setCapInsetsDisabledRenderer: function(a) {
- this._capInsetsDisabled = a;
- this._scale9Enabled && this._buttonDisableRenderer.setCapInsets(a)
- },
- getCapInsetsDisabledRenderer: function() {
- return this._capInsetsDisabled
- },
- onPressStateChangedToNormal: function() {
- this._buttonNormalRenderer.setVisible(!0);
- this._buttonClickedRenderer.setVisible(!1);
- this._buttonDisableRenderer.setVisible(!1);
- if (this._pressedTextureLoaded) {
- if (this.pressedActionEnabled) {
- this._buttonNormalRenderer.stopAllActions();
- this._buttonClickedRenderer.stopAllActions();
- var a = cc.ScaleTo.create(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
- this._buttonNormalRenderer.runAction(a);
- this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize)
- }
- } else this._scale9Enabled ? this._updateTexturesRGBA() : (this._buttonNormalRenderer.stopAllActions(), this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize))
- },
- onPressStateChangedToPressed: function() {
- var a = this._buttonNormalRenderer;
- if (this._pressedTextureLoaded) {
- if (a.setVisible(!1), this._buttonClickedRenderer.setVisible(!0), this._buttonDisableRenderer.setVisible(!1), this.pressedActionEnabled) {
- a.stopAllActions();
- this._buttonClickedRenderer.stopAllActions();
- var c = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1);
- this._buttonClickedRenderer.runAction(c);
- a.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1)
- }
- } else a.setVisible(!0), this._buttonClickedRenderer.setVisible(!0), this._buttonDisableRenderer.setVisible(!1), this._scale9Enabled ? a.setColor(cc.Color.GRAY) : (a.stopAllActions(), a.setScale(this._normalTextureScaleXInSize + 0.1, this._normalTextureScaleYInSize + 0.1))
- },
- onPressStateChangedToDisabled: function() {
- this._buttonNormalRenderer.setVisible(!1);
- this._buttonClickedRenderer.setVisible(!1);
- this._buttonDisableRenderer.setVisible(!0);
- this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
- this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize)
- },
- _updateFlippedX: function() {
- var a = this._flippedX ? -1 : 1;
- this._titleRenderer.setScaleX(a);
- this._scale9Enabled ? (this._buttonNormalRenderer.setScaleX(a), this._buttonClickedRenderer.setScaleX(a), this._buttonDisableRenderer.setScaleX(a)) : (this._buttonNormalRenderer.setFlippedX(this._flippedX), this._buttonClickedRenderer.setFlippedX(this._flippedX), this._buttonDisableRenderer.setFlippedX(this._flippedX))
- },
- _updateFlippedY: function() {
- var a = this._flippedY ? -1 : 1;
- this._titleRenderer.setScaleY(a);
- this._scale9Enabled ? (this._buttonNormalRenderer.setScaleY(a), this._buttonClickedRenderer.setScaleY(a), this._buttonDisableRenderer.setScaleY(a)) : (this._buttonNormalRenderer.setFlippedY(this._flippedY), this._buttonClickedRenderer.setFlippedY(this._flippedY), this._buttonDisableRenderer.setFlippedY(this._flippedY))
- },
- _updateTexturesRGBA: function() {
- this._buttonNormalRenderer.setColor(this.getColor());
- this._buttonClickedRenderer.setColor(this.getColor());
- this._buttonDisableRenderer.setColor(this.getColor());
- this._buttonNormalRenderer.setOpacity(this.getOpacity());
- this._buttonClickedRenderer.setOpacity(this.getOpacity());
- this._buttonDisableRenderer.setOpacity(this.getOpacity())
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._updateTitleLocation();
- this._disabledTextureAdaptDirty = this._pressedTextureAdaptDirty = this._normalTextureAdaptDirty = !0
- },
- getVirtualRenderer: function() {
- if (this._bright) switch (this._brightStyle) {
- case ccui.Widget.BRIGHT_STYLE_NORMAL:
- return this._buttonNormalRenderer;
- case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:
- return this._buttonClickedRenderer;
- default:
- return null
- } else return this._buttonDisableRenderer
- },
- _normalTextureScaleChangedWithSize: function() {
- if (this._ignoreSize) this._scale9Enabled || (this._buttonNormalRenderer.setScale(1), this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1);
- else if (this._scale9Enabled) this._buttonNormalRenderer.setPreferredSize(this._contentSize), this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1;
- else {
- var a = this._normalTextureSize;
- if (0 >= a.width || 0 >= a.height) {
- this._buttonNormalRenderer.setScale(1);
- return
- }
- var c = this._contentSize.width / a.width,
- a = this._contentSize.height / a.height;
- this._buttonNormalRenderer.setScaleX(c);
- this._buttonNormalRenderer.setScaleY(a);
- this._normalTextureScaleXInSize = c;
- this._normalTextureScaleYInSize = a
- }
- this._buttonNormalRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- _pressedTextureScaleChangedWithSize: function() {
- if (this._ignoreSize) this._scale9Enabled || (this._buttonClickedRenderer.setScale(1), this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1);
- else if (this._scale9Enabled) this._buttonClickedRenderer.setPreferredSize(this._contentSize), this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1;
- else {
- var a = this._pressedTextureSize;
- if (0 >= a.width || 0 >= a.height) {
- this._buttonClickedRenderer.setScale(1);
- return
- }
- var c = this._contentSize.width / a.width,
- a = this._contentSize.height / a.height;
- this._buttonClickedRenderer.setScaleX(c);
- this._buttonClickedRenderer.setScaleY(a);
- this._pressedTextureScaleXInSize = c;
- this._pressedTextureScaleYInSize = a
- }
- this._buttonClickedRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- _disabledTextureScaleChangedWithSize: function() {
- if (this._ignoreSize) this._scale9Enabled || this._buttonDisableRenderer.setScale(1);
- else if (this._scale9Enabled) this._buttonDisableRenderer.setPreferredSize(this._contentSize);
- else {
- var a = this._disabledTextureSize;
- if (0 >= a.width || 0 >= a.height) {
- this._buttonDisableRenderer.setScale(1);
- return
- }
- var c = this._contentSize.height / a.height;
- this._buttonDisableRenderer.setScaleX(this._contentSize.width / a.width);
- this._buttonDisableRenderer.setScaleY(c)
- }
- this._buttonDisableRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- _adaptRenderers: function() {
- this._normalTextureAdaptDirty && (this._normalTextureScaleChangedWithSize(), this._normalTextureAdaptDirty = !1);
- this._pressedTextureAdaptDirty && (this._pressedTextureScaleChangedWithSize(), this._pressedTextureAdaptDirty = !1);
- this._disabledTextureAdaptDirty && (this._disabledTextureScaleChangedWithSize(), this._disabledTextureAdaptDirty = !1)
- },
- _updateTitleLocation: function() {
- this._titleRenderer.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height)
- },
- setPressedActionEnabled: function(a) {
- this.pressedActionEnabled = a
- },
- setTitleText: function(a) {
- this._titleRenderer.setString(a)
- },
- getTitleText: function() {
- return this._titleRenderer.getString()
- },
- setTitleColor: function(a) {
- this._titleColor.r = a.r;
- this._titleColor.g = a.g;
- this._titleColor.b = a.b;
- this._titleRenderer.updateDisplayedColor(a)
- },
- getTitleColor: function() {
- return this._titleRenderer.getColor()
- },
- setTitleFontSize: function(a) {
- this._titleRenderer.setFontSize(a)
- },
- getTitleFontSize: function() {
- return this._titleRenderer.getFontSize()
- },
- setTitleFontName: function(a) {
- this._titleRenderer.setFontName(a);
- this._fontName = a
- },
- getTitleFontName: function() {
- return this._titleRenderer.getFontName()
- },
- _setTitleFont: function(a) {
- this._titleRenderer.font = a
- },
- _getTitleFont: function() {
- return this._titleRenderer.font
- },
- getDescription: function() {
- return "Button"
- },
- _createCloneInstance: function() {
- return ccui.Button.create()
- },
- _copySpecialProperties: function(a) {
- this._prevIgnoreSize = a._prevIgnoreSize;
- this.setScale9Enabled(a._scale9Enabled);
- this.loadTextureNormal(a._normalFileName, a._normalTexType);
- this.loadTexturePressed(a._clickedFileName, a._pressedTexType);
- this.loadTextureDisabled(a._disabledFileName, a._disabledTexType);
- this.setCapInsetsNormalRenderer(a._capInsetsNormal);
- this.setCapInsetsPressedRenderer(a._capInsetsPressed);
- this.setCapInsetsDisabledRenderer(a._capInsetsDisabled);
- this.setTitleText(a.getTitleText());
- this.setTitleFontName(a.getTitleFontName());
- this.setTitleFontSize(a.getTitleFontSize());
- this.setTitleColor(a.getTitleColor());
- this.setPressedActionEnabled(a.pressedActionEnabled)
- }
- });
- _p = ccui.Button.prototype;
- cc.defineGetterSetter(_p, "titleText", _p.getTitleText, _p.setTitleText);
- cc.defineGetterSetter(_p, "titleFont", _p._getTitleFont, _p._setTitleFont);
- cc.defineGetterSetter(_p, "titleFontSize", _p.getTitleFontSize, _p.setTitleFontSize);
- cc.defineGetterSetter(_p, "titleFontName", _p.getTitleFontName, _p.setTitleFontName);
- cc.defineGetterSetter(_p, "titleColor", _p.getTitleColor, _p.setTitleColor);
- _p = null;
- ccui.Button.create = function(a, c, d, e) {
- return new ccui.Button(a, c, d, e)
- };
- ccui.Button.NORMAL_RENDERER_ZORDER = -2;
- ccui.Button.PRESSED_RENDERER_ZORDER = -2;
- ccui.Button.DISABLED_RENDERER_ZORDER = -2;
- ccui.Button.TITLE_RENDERER_ZORDER = -1;
- ccui.Button.SYSTEM = 0;
- ccui.Button.TTF = 1;
- ccui.CheckBox = ccui.Widget.extend({
- _backGroundBoxRenderer: null,
- _backGroundSelectedBoxRenderer: null,
- _frontCrossRenderer: null,
- _backGroundBoxDisabledRenderer: null,
- _frontCrossDisabledRenderer: null,
- _isSelected: !0,
- _checkBoxEventListener: null,
- _checkBoxEventSelector: null,
- _checkBoxEventCallback: null,
- _backGroundTexType: ccui.Widget.LOCAL_TEXTURE,
- _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE,
- _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE,
- _backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
- _frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
- _backGroundFileName: "",
- _backGroundSelectedFileName: "",
- _frontCrossFileName: "",
- _backGroundDisabledFileName: "",
- _frontCrossDisabledFileName: "",
- _className: "CheckBox",
- _backGroundBoxRendererAdaptDirty: !0,
- _backGroundSelectedBoxRendererAdaptDirty: !0,
- _frontCrossRendererAdaptDirty: !0,
- _backGroundBoxDisabledRendererAdaptDirty: !0,
- _frontCrossDisabledRendererAdaptDirty: !0,
- ctor: function(a, c, d, e, f, g) {
- ccui.Widget.prototype.ctor.call(this);
- this.setTouchEnabled(!0);
- g && this.init(a, c, d, e, f, g)
- },
- init: function(a, c, d, e, f, g) {
- return ccui.Widget.prototype.init.call(this) ? (this._isSelected = !0, this.setSelectedState(!1), void 0 === a && this.loadTextures(a, c, d, e, f, g), !0) : !1
- },
- _initRenderer: function() {
- this._backGroundBoxRenderer = cc.Sprite.create();
- this._backGroundSelectedBoxRenderer = cc.Sprite.create();
- this._frontCrossRenderer = cc.Sprite.create();
- this._backGroundBoxDisabledRenderer = cc.Sprite.create();
- this._frontCrossDisabledRenderer = cc.Sprite.create();
- this.addProtectedChild(this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1)
- },
- loadTextures: function(a, c, d, e, f, g) {
- this.loadTextureBackGround(a, g);
- this.loadTextureBackGroundSelected(c, g);
- this.loadTextureFrontCross(d, g);
- this.loadTextureBackGroundDisabled(e, g);
- this.loadTextureFrontCrossDisabled(f, g)
- },
- loadTextureBackGround: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._backGroundFileName = a;
- this._backGroundTexType = c;
- var d = this._backGroundBoxRenderer,
- e = this;
- (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
- e._findLayout();
- e._updateFlippedX();
- e._updateFlippedY();
- e._updateChildrenDisplayedRGBA();
- e._updateContentSizeWithTextureSize(e._backGroundBoxRenderer.getContentSize());
- e._backGroundBoxRendererAdaptDirty = !0
- });
- switch (this._backGroundTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d.initWithSpriteFrameName(a)
- }
- d.textureLoaded() || (this._backGroundBoxRenderer.setContentSize(this._customSize), d.addLoadedEventListener(function() {
- this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize())
- }, this));
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize());
- this._backGroundBoxRendererAdaptDirty = !0
- }
- },
- loadTextureBackGroundSelected: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._backGroundSelectedFileName = a;
- this._backGroundSelectedTexType = c;
- var d = this;
- (!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()) && this._backGroundSelectedBoxRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._backGroundSelectedBoxRendererAdaptDirty = !0
- });
- switch (this._backGroundSelectedTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._backGroundSelectedBoxRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(a)
- }
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._backGroundSelectedBoxRendererAdaptDirty = !0
- }
- },
- loadTextureFrontCross: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._frontCrossFileName = a;
- this._frontCrossTexType = c;
- var d = this;
- (!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()) && this._frontCrossRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._frontCrossRendererAdaptDirty = !0
- });
- switch (this._frontCrossTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._frontCrossRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._frontCrossRenderer.initWithSpriteFrameName(a)
- }
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._frontCrossRendererAdaptDirty = !0
- }
- },
- loadTextureBackGroundDisabled: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._backGroundDisabledFileName = a;
- this._backGroundDisabledTexType = c;
- var d = this;
- (!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()) && this._backGroundBoxDisabledRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._backGroundBoxDisabledRendererAdaptDirty = !0
- });
- switch (this._backGroundDisabledTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._backGroundBoxDisabledRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(a)
- }
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._backGroundBoxDisabledRendererAdaptDirty = !0
- }
- },
- loadTextureFrontCrossDisabled: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._frontCrossDisabledFileName = a;
- this._frontCrossDisabledTexType = c;
- var d = this;
- (!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()) && this._frontCrossDisabledRenderer.addLoadedEventListener(function() {
- d._findLayout();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._frontCrossDisabledRendererAdaptDirty = !0
- });
- switch (this._frontCrossDisabledTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._frontCrossDisabledRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._frontCrossDisabledRenderer.initWithSpriteFrameName(a)
- }
- this._updateFlippedX();
- this._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- this._frontCrossDisabledRendererAdaptDirty = !0
- }
- },
- onPressStateChangedToNormal: function() {
- this._backGroundBoxRenderer.setVisible(!0);
- this._backGroundSelectedBoxRenderer.setVisible(!1);
- this._backGroundBoxDisabledRenderer.setVisible(!1);
- this._frontCrossDisabledRenderer.setVisible(!1)
- },
- onPressStateChangedToPressed: function() {
- this._backGroundBoxRenderer.setVisible(!1);
- this._backGroundSelectedBoxRenderer.setVisible(!0);
- this._backGroundBoxDisabledRenderer.setVisible(!1);
- this._frontCrossDisabledRenderer.setVisible(!1)
- },
- onPressStateChangedToDisabled: function() {
- this._backGroundBoxRenderer.setVisible(!1);
- this._backGroundSelectedBoxRenderer.setVisible(!1);
- this._backGroundBoxDisabledRenderer.setVisible(!0);
- this._frontCrossRenderer.setVisible(!1);
- this._isSelected && this._frontCrossDisabledRenderer.setVisible(!0)
- },
- setSelectedState: function(a) {
- a != this._isSelected && (this._isSelected = a, this._frontCrossRenderer.setVisible(this._isSelected))
- },
- getSelectedState: function() {
- return this._isSelected
- },
- _selectedEvent: function() {
- this._checkBoxEventCallback && this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_SELECTED);
- this._checkBoxEventListener && this._checkBoxEventSelector && this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED)
- },
- _unSelectedEvent: function() {
- this._checkBoxEventCallback && this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_UNSELECTED);
- this._checkBoxEventListener && this._checkBoxEventSelector && this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED)
- },
- _releaseUpEvent: function() {
- ccui.Widget.prototype._releaseUpEvent.call(this);
- this._isSelected ? (this.setSelectedState(!1), this._unSelectedEvent()) : (this.setSelectedState(!0), this._selectedEvent())
- },
- addEventListenerCheckBox: function(a, c) {
- this._checkBoxEventSelector = a;
- this._checkBoxEventListener = c
- },
- addEventListener: function(a) {
- this._checkBoxEventCallback = a
- },
- getVirtualRendererSize: function() {
- return this._backGroundBoxRenderer.getContentSize()
- },
- _updateFlippedX: function() {
- this._backGroundBoxRenderer.setFlippedX(this._flippedX);
- this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX);
- this._frontCrossRenderer.setFlippedX(this._flippedX);
- this._backGroundBoxDisabledRenderer.setFlippedX(this._flippedX);
- this._frontCrossDisabledRenderer.setFlippedX(this._flippedX)
- },
- _updateFlippedY: function() {
- this._backGroundBoxRenderer.setFlippedY(this._flippedY);
- this._backGroundSelectedBoxRenderer.setFlippedY(this._flippedY);
- this._frontCrossRenderer.setFlippedY(this._flippedY);
- this._backGroundBoxDisabledRenderer.setFlippedY(this._flippedY);
- this._frontCrossDisabledRenderer.setFlippedY(this._flippedY)
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._frontCrossDisabledRendererAdaptDirty = this._backGroundBoxDisabledRendererAdaptDirty = this._frontCrossRendererAdaptDirty = this._backGroundSelectedBoxRendererAdaptDirty = this._backGroundBoxRendererAdaptDirty = !0
- },
- getVirtualRenderer: function() {
- return this._backGroundBoxRenderer
- },
- _backGroundTextureScaleChangedWithSize: function() {
- var a = this._backGroundBoxRenderer,
- c = this._contentSize;
- if (this._ignoreSize) a.setScale(1);
- else {
- var d = a.getContentSize();
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- a.setPosition(0.5 * c.width, 0.5 * c.height)
- },
- _backGroundSelectedTextureScaleChangedWithSize: function() {
- var a = this._backGroundSelectedBoxRenderer,
- c = this._contentSize;
- if (this._ignoreSize) a.setScale(1);
- else {
- var d = a.getContentSize();
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- a.setPosition(0.5 * c.width, 0.5 * c.height)
- },
- _frontCrossTextureScaleChangedWithSize: function() {
- var a = this._frontCrossRenderer,
- c = this._contentSize;
- if (this._ignoreSize) a.setScale(1);
- else {
- var d = a.getContentSize();
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- a.setPosition(0.5 * c.width, 0.5 * c.height)
- },
- _backGroundDisabledTextureScaleChangedWithSize: function() {
- var a = this._backGroundBoxDisabledRenderer,
- c = this._contentSize;
- if (this._ignoreSize) a.setScale(1);
- else {
- var d = a.getContentSize();
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- a.setPosition(0.5 * c.width, 0.5 * c.height)
- },
- _frontCrossDisabledTextureScaleChangedWithSize: function() {
- var a = this._frontCrossDisabledRenderer,
- c = this._contentSize;
- if (this._ignoreSize) a.setScale(1);
- else {
- var d = a.getContentSize();
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- a.setPosition(0.5 * c.width, 0.5 * c.height)
- },
- getDescription: function() {
- return "CheckBox"
- },
- _createCloneInstance: function() {
- return ccui.CheckBox.create()
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.CheckBox && (this.loadTextureBackGround(a._backGroundFileName, a._backGroundTexType), this.loadTextureBackGroundSelected(a._backGroundSelectedFileName, a._backGroundSelectedTexType), this.loadTextureFrontCross(a._frontCrossFileName, a._frontCrossTexType), this.loadTextureBackGroundDisabled(a._backGroundDisabledFileName, a._backGroundDisabledTexType), this.loadTextureFrontCrossDisabled(a._frontCrossDisabledFileName, a._frontCrossDisabledTexType), this.setSelectedState(a._isSelected), this._checkBoxEventListener = a._checkBoxEventListener, this._checkBoxEventSelector = a._checkBoxEventSelector, this._checkBoxEventCallback = a._checkBoxEventCallback)
- },
- _adaptRenderers: function() {
- this._backGroundBoxRendererAdaptDirty && (this._backGroundTextureScaleChangedWithSize(), this._backGroundBoxRendererAdaptDirty = !1);
- this._backGroundSelectedBoxRendererAdaptDirty && (this._backGroundSelectedTextureScaleChangedWithSize(), this._backGroundSelectedBoxRendererAdaptDirty = !1);
- this._frontCrossRendererAdaptDirty && (this._frontCrossTextureScaleChangedWithSize(), this._frontCrossRendererAdaptDirty = !1);
- this._backGroundBoxDisabledRendererAdaptDirty && (this._backGroundDisabledTextureScaleChangedWithSize(), this._backGroundBoxDisabledRendererAdaptDirty = !1);
- this._frontCrossDisabledRendererAdaptDirty && (this._frontCrossDisabledTextureScaleChangedWithSize(), this._frontCrossDisabledRendererAdaptDirty = !1)
- }
- });
- _p = ccui.CheckBox.prototype;
- cc.defineGetterSetter(_p, "selected", _p.getSelectedState, _p.setSelectedState);
- _p = null;
- ccui.CheckBox.create = function(a, c, d, e, f, g) {
- return new ccui.CheckBox(a, c, d, e, f, g)
- };
- ccui.CheckBox.EVENT_SELECTED = 0;
- ccui.CheckBox.EVENT_UNSELECTED = 1;
- ccui.CheckBox.BOX_RENDERER_ZORDER = -1;
- ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER = -1;
- ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER = -1;
- ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER = -1;
- ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER = -1;
- ccui.ImageView = ccui.Widget.extend({
- _scale9Enabled: !1,
- _prevIgnoreSize: !0,
- _capInsets: null,
- _imageRenderer: null,
- _textureFile: "",
- _imageTexType: ccui.Widget.LOCAL_TEXTURE,
- _imageTextureSize: null,
- _className: "ImageView",
- _imageRendererAdaptDirty: !0,
- ctor: function(a, c) {
- this._capInsets = cc.rect(0, 0, 0, 0);
- this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height);
- ccui.Widget.prototype.ctor.call(this);
- c && this.init(a, c)
- },
- init: function(a, c) {
- return ccui.Widget.prototype.init.call(this) ? (void 0 === a ? this._imageTexType = ccui.Widget.LOCAL_TEXTURE : this.loadTexture(a, c), !0) : !1
- },
- _initRenderer: function() {
- this._imageRenderer = cc.Sprite.create();
- this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1)
- },
- loadTexture: function(a, c) {
- if (a) {
- var d = this;
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._textureFile = a;
- this._imageTexType = c;
- var e = d._imageRenderer;
- switch (d._imageTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d._scale9Enabled ? (e.initWithFile(a), e.setCapInsets(d._capInsets)) : e.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d._scale9Enabled ? (e.initWithSpriteFrameName(a), e.setCapInsets(d._capInsets)) : e.initWithSpriteFrameName(a)
- }(!e.texture || !e.texture.isLoaded()) && e.addLoadedEventListener(function() {
- d._findLayout();
- d._imageTextureSize = e.getContentSize();
- d._updateFlippedX();
- d._updateFlippedY();
- d._updateChildrenDisplayedRGBA();
- d._updateContentSizeWithTextureSize(d._imageTextureSize);
- d._imageRendererAdaptDirty = !0
- });
- d._imageTextureSize = e.getContentSize();
- d._updateFlippedX();
- d._updateFlippedY();
- this._updateChildrenDisplayedRGBA();
- d._updateContentSizeWithTextureSize(d._imageTextureSize);
- d._imageRendererAdaptDirty = !0
- }
- },
- setTextureRect: function(a) {
- this._scale9Enabled || this._imageRenderer.setTextureRect(a)
- },
- _updateFlippedX: function() {
- this._scale9Enabled ? this._imageRenderer.setScaleX(this._flippedX ? -1 : 1) : this._imageRenderer.setFlippedX(this._flippedX)
- },
- _updateFlippedY: function() {
- this._scale9Enabled ? this._imageRenderer.setScaleY(this._flippedY ? -1 : 1) : this._imageRenderer.setFlippedY(this._flippedY)
- },
- setScale9Enabled: function(a) {
- this._scale9Enabled != a && (this._scale9Enabled = a, this.removeProtectedChild(this._imageRenderer), this._imageRenderer = null, this._imageRenderer = this._scale9Enabled ? cc.Scale9Sprite.create() : cc.Sprite.create(), this.loadTexture(this._textureFile, this._imageTexType), this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1), this._scale9Enabled ? (a = this._ignoreSize, this.ignoreContentAdaptWithSize(!1), this._prevIgnoreSize = a) : this.ignoreContentAdaptWithSize(this._prevIgnoreSize), this.setCapInsets(this._capInsets))
- },
- isScale9Enabled: function() {
- return this._scale9Enabled
- },
- ignoreContentAdaptWithSize: function(a) {
- if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
- },
- setCapInsets: function(a) {
- this._capInsets = a;
- this._scale9Enabled && this._imageRenderer.setCapInsets(a)
- },
- getCapInsets: function() {
- return this._capInsets
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._imageRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._imageRendererAdaptDirty && (this._imageTextureScaleChangedWithSize(), this._imageRendererAdaptDirty = !1)
- },
- getVirtualRendererSize: function() {
- return cc.size(this._imageTextureSize)
- },
- getVirtualRenderer: function() {
- return this._imageRenderer
- },
- _imageTextureScaleChangedWithSize: function() {
- if (this._ignoreSize) this._scale9Enabled || this._imageRenderer.setScale(1);
- else if (this._scale9Enabled) this._imageRenderer.setPreferredSize(this._contentSize);
- else {
- var a = this._imageRenderer.getContentSize();
- if (0 >= a.width || 0 >= a.height) {
- this._imageRenderer.setScale(1);
- return
- }
- this._imageRenderer.setScaleX(this._contentSize.width / a.width);
- this._imageRenderer.setScaleY(this._contentSize.height / a.height)
- }
- this._imageRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- getDescription: function() {
- return "ImageView"
- },
- _createCloneInstance: function() {
- return ccui.ImageView.create()
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.ImageView && (this._prevIgnoreSize = a._prevIgnoreSize, this.setScale9Enabled(a._scale9Enabled), this.loadTexture(a._textureFile, a._imageTexType), this.setCapInsets(a._capInsets))
- }
- });
- ccui.ImageView.create = function(a, c) {
- return new ccui.ImageView(a, c)
- };
- ccui.ImageView.RENDERER_ZORDER = -1;
- ccui.LoadingBar = ccui.Widget.extend({
- _direction: null,
- _percent: 100,
- _totalLength: 0,
- _barRenderer: null,
- _renderBarTexType: ccui.Widget.LOCAL_TEXTURE,
- _barRendererTextureSize: null,
- _scale9Enabled: !1,
- _prevIgnoreSize: !0,
- _capInsets: null,
- _textureFile: "",
- _isTextureLoaded: !1,
- _className: "LoadingBar",
- _barRendererAdaptDirty: !0,
- ctor: function(a, c) {
- this._direction = ccui.LoadingBar.TYPE_LEFT;
- this._barRendererTextureSize = cc.size(0, 0);
- this._capInsets = cc.rect(0, 0, 0, 0);
- ccui.Widget.prototype.ctor.call(this);
- void 0 !== a && this.loadTexture(a);
- void 0 !== c && this.setPercent(c)
- },
- _initRenderer: function() {
- this._barRenderer = cc.Sprite.create();
- cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1);
- this._barRenderer.setAnchorPoint(0, 0.5)
- },
- setDirection: function(a) {
- if (this._direction != a) switch (this._direction = a, this._direction) {
- case ccui.LoadingBar.TYPE_LEFT:
- this._barRenderer.setAnchorPoint(0, 0.5);
- this._barRenderer.setPosition(0.5 * -this._totalLength, 0);
- this._scale9Enabled || this._barRenderer.setFlippedX(!1);
- break;
- case ccui.LoadingBar.TYPE_RIGHT:
- this._barRenderer.setAnchorPoint(1, 0.5), this._barRenderer.setPosition(0.5 * this._totalLength, 0), this._scale9Enabled || this._barRenderer.setFlippedX(!0)
- }
- },
- getDirection: function() {
- return this._direction
- },
- loadTexture: function(a, c) {
- if (a) {
- this._renderBarTexType = c = c || ccui.Widget.LOCAL_TEXTURE;
- this._textureFile = a;
- var d = this._barRenderer,
- e = this;
- (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
- e._findLayout();
- var a = d.getContentSize();
- e._barRendererTextureSize.width = a.width;
- e._barRendererTextureSize.height = a.height;
- switch (e._direction) {
- case ccui.LoadingBar.TYPE_LEFT:
- d.setAnchorPoint(0, 0.5);
- e._scale9Enabled || d.setFlippedX(!1);
- break;
- case ccui.LoadingBar.TYPE_RIGHT:
- d.setAnchorPoint(1, 0.5), e._scale9Enabled || d.setFlippedX(!0)
- }
- e._updateChildrenDisplayedRGBA();
- e._barRendererScaleChangedWithSize();
- e._updateContentSizeWithTextureSize(e._barRendererTextureSize);
- e._barRendererAdaptDirty = !0
- });
- switch (this._renderBarTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._scale9Enabled ? (d.initWithFile(a), d.setCapInsets(this._capInsets)) : d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._scale9Enabled ? (d.initWithSpriteFrameName(a), d.setCapInsets(this._capInsets)) : d.initWithSpriteFrameName(a)
- }
- var f = d.getContentSize();
- this._barRendererTextureSize.width = f.width;
- this._barRendererTextureSize.height = f.height;
- switch (this._direction) {
- case ccui.LoadingBar.TYPE_LEFT:
- d.setAnchorPoint(0, 0.5);
- this._scale9Enabled || d.setFlippedX(!1);
- break;
- case ccui.LoadingBar.TYPE_RIGHT:
- d.setAnchorPoint(1, 0.5), this._scale9Enabled || d.setFlippedX(!0)
- }
- this._updateChildrenDisplayedRGBA();
- this._barRendererScaleChangedWithSize();
- this._updateContentSizeWithTextureSize(this._barRendererTextureSize);
- this._barRendererAdaptDirty = !0
- }
- },
- setScale9Enabled: function(a) {
- this._scale9Enabled != a && (this._scale9Enabled = a, this.removeProtectedChild(this._barRenderer), this._barRenderer = this._scale9Enabled ? cc.Scale9Sprite.create() : cc.Sprite.create(), this.loadTexture(this._textureFile, this._renderBarTexType), this.addProtectedChild(this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1), this._scale9Enabled ? (a = this._ignoreSize, this.ignoreContentAdaptWithSize(!1), this._prevIgnoreSize = a) : this.ignoreContentAdaptWithSize(this._prevIgnoreSize), this.setCapInsets(this._capInsets), this.setPercent(this._percent))
- },
- isScale9Enabled: function() {
- return this._scale9Enabled
- },
- setCapInsets: function(a) {
- this._capInsets = a;
- this._scale9Enabled && this._barRenderer.setCapInsets(a)
- },
- getCapInsets: function() {
- return this._capInsets
- },
- setPercent: function(a) {
- if (!(0 > a || 100 < a) && !(0 >= this._totalLength))
- if (this._percent = a, a = this._percent / 100, this._scale9Enabled) this._setScale9Scale();
- else {
- var c = this._barRenderer.getTextureRect();
- c.width = this._barRendererTextureSize.width * a;
- this._barRenderer.setTextureRect(cc.rect(c.x, c.y, this._barRendererTextureSize.width * a, this._barRendererTextureSize.height))
- }
- },
- getPercent: function() {
- return this._percent
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._barRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._barRendererAdaptDirty && (this._barRendererScaleChangedWithSize(), this._barRendererAdaptDirty = !1)
- },
- ignoreContentAdaptWithSize: function(a) {
- if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
- },
- getVirtualRendererSize: function() {
- return cc.size(this._barRendererTextureSize)
- },
- getVirtualRenderer: function() {
- return this._barRenderer
- },
- _barRendererScaleChangedWithSize: function() {
- var a = this._barRenderer,
- c = this._contentSize;
- if (this._ignoreSize) this._scale9Enabled || (this._totalLength = this._barRendererTextureSize.width, a.setScale(1));
- else if (this._totalLength = c.width, this._scale9Enabled) this._setScale9Scale();
- else {
- var d = this._barRendererTextureSize;
- if (0 >= d.width || 0 >= d.height) {
- a.setScale(1);
- return
- }
- var e = c.height / d.height;
- a.setScaleX(c.width / d.width);
- a.setScaleY(e)
- }
- switch (this._direction) {
- case ccui.LoadingBar.TYPE_LEFT:
- a.setPosition(0, 0.5 * c.height);
- break;
- case ccui.LoadingBar.TYPE_RIGHT:
- a.setPosition(this._totalLength, 0.5 * c.height)
- }
- },
- _setScale9Scale: function() {
- this._barRenderer.setPreferredSize(cc.size(this._percent / 100 * this._totalLength, this._contentSize.height))
- },
- getDescription: function() {
- return "LoadingBar"
- },
- _createCloneInstance: function() {
- return ccui.LoadingBar.create()
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.LoadingBar && (this._prevIgnoreSize = a._prevIgnoreSize, this.setScale9Enabled(a._scale9Enabled), this.loadTexture(a._textureFile, a._renderBarTexType), this.setCapInsets(a._capInsets), this.setPercent(a._percent), this.setDirection(a._direction))
- }
- });
- _p = ccui.LoadingBar.prototype;
- cc.defineGetterSetter(_p, "direction", _p.getDirection, _p.setDirection);
- cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
- _p = null;
- ccui.LoadingBar.create = function(a, c) {
- return new ccui.LoadingBar(a, c)
- };
- ccui.LoadingBar.TYPE_LEFT = 0;
- ccui.LoadingBar.TYPE_RIGHT = 1;
- ccui.LoadingBar.RENDERER_ZORDER = -1;
- ccui.Slider = ccui.Widget.extend({
- _barRenderer: null,
- _progressBarRenderer: null,
- _progressBarTextureSize: null,
- _slidBallNormalRenderer: null,
- _slidBallPressedRenderer: null,
- _slidBallDisabledRenderer: null,
- _slidBallRenderer: null,
- _barLength: 0,
- _percent: 0,
- _scale9Enabled: !1,
- _prevIgnoreSize: !0,
- _textureFile: "",
- _progressBarTextureFile: "",
- _slidBallNormalTextureFile: "",
- _slidBallPressedTextureFile: "",
- _slidBallDisabledTextureFile: "",
- _capInsetsBarRenderer: null,
- _capInsetsProgressBarRenderer: null,
- _sliderEventListener: null,
- _sliderEventSelector: null,
- _barTexType: ccui.Widget.LOCAL_TEXTURE,
- _progressBarTexType: ccui.Widget.LOCAL_TEXTURE,
- _ballNTexType: ccui.Widget.LOCAL_TEXTURE,
- _ballPTexType: ccui.Widget.LOCAL_TEXTURE,
- _ballDTexType: ccui.Widget.LOCAL_TEXTURE,
- _isTextureLoaded: !1,
- _className: "Slider",
- _barRendererAdaptDirty: !0,
- _progressBarRendererDirty: !0,
- ctor: function() {
- this._progressBarTextureSize = cc.size(0, 0);
- this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0);
- this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0);
- ccui.Widget.prototype.ctor.call(this)
- },
- init: function() {
- return ccui.Widget.prototype.init.call(this) ? !0 : !1
- },
- _initRenderer: function() {
- this._barRenderer = cc.Sprite.create();
- this._progressBarRenderer = cc.Sprite.create();
- this._progressBarRenderer.setAnchorPoint(0, 0.5);
- this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1);
- this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1);
- this._slidBallNormalRenderer = cc.Sprite.create();
- this._slidBallPressedRenderer = cc.Sprite.create();
- this._slidBallPressedRenderer.setVisible(!1);
- this._slidBallDisabledRenderer = cc.Sprite.create();
- this._slidBallDisabledRenderer.setVisible(!1);
- this._slidBallRenderer = cc.Node.create();
- this._slidBallRenderer.addChild(this._slidBallNormalRenderer);
- this._slidBallRenderer.addChild(this._slidBallPressedRenderer);
- this._slidBallRenderer.addChild(this._slidBallDisabledRenderer);
- this.addProtectedChild(this._slidBallRenderer, ccui.Slider.BALL_RENDERER_ZORDER, -1)
- },
- loadBarTexture: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._textureFile = a;
- this._barTexType = c;
- var d = this._barRenderer,
- e = this;
- (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
- e._findLayout();
- e._updateChildrenDisplayedRGBA();
- e._barRendererAdaptDirty = !0;
- e._progressBarRendererDirty = !0;
- e._updateContentSizeWithTextureSize(e._barRenderer.getContentSize())
- });
- switch (this._barTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d.initWithSpriteFrameName(a)
- }
- this._updateChildrenDisplayedRGBA();
- this._progressBarRendererDirty = this._barRendererAdaptDirty = !0;
- this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize())
- }
- },
- loadProgressBarTexture: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._progressBarTextureFile = a;
- this._progressBarTexType = c;
- var d = this._progressBarRenderer,
- e = this;
- (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
- e._findLayout();
- e._updateChildrenDisplayedRGBA();
- e._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5));
- var a = e._progressBarRenderer.getContentSize();
- e._progressBarTextureSize = {
- width: a.width,
- height: a.height
- };
- e._progressBarRendererDirty = !0
- });
- switch (this._progressBarTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- d.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- d.initWithSpriteFrameName(a)
- }
- this._updateChildrenDisplayedRGBA();
- this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5));
- d = this._progressBarRenderer.getContentSize();
- this._progressBarTextureSize = {
- width: d.width,
- height: d.height
- };
- this._progressBarRendererDirty = !0
- }
- },
- setScale9Enabled: function(a) {
- this._scale9Enabled != a && (this._scale9Enabled = a, this.removeProtectedChild(this._barRenderer, !0), this.removeProtectedChild(this._progressBarRenderer, !0), this._progressBarRenderer = this._barRenderer = null, this._scale9Enabled ? (this._barRenderer = cc.Scale9Sprite.create(), this._progressBarRenderer = cc.Scale9Sprite.create()) : (this._barRenderer = cc.Sprite.create(), this._progressBarRenderer = cc.Sprite.create()), this.loadBarTexture(this._textureFile, this._barTexType), this.loadProgressBarTexture(this._progressBarTextureFile, this._progressBarTexType), this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1), this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1), this._scale9Enabled ? (a = this._ignoreSize, this.ignoreContentAdaptWithSize(!1), this._prevIgnoreSize = a) : this.ignoreContentAdaptWithSize(this._prevIgnoreSize), this.setCapInsetsBarRenderer(this._capInsetsBarRenderer), this.setCapInsetProgressBarRenderer(this._capInsetsProgressBarRenderer))
- },
- isScale9Enabled: function() {
- return this._scale9Enabled
- },
- ignoreContentAdaptWithSize: function(a) {
- if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
- },
- setCapInsets: function(a) {
- this.setCapInsetsBarRenderer(a);
- this.setCapInsetProgressBarRenderer(a)
- },
- setCapInsetsBarRenderer: function(a) {
- this._capInsetsBarRenderer = a;
- this._scale9Enabled && this._barRenderer.setCapInsets(a)
- },
- getCapInsetsBarRenderer: function() {
- return this._capInsetsBarRenderer
- },
- setCapInsetProgressBarRebderer: function(a) {
- this._capInsetsProgressBarRenderer = a;
- this._scale9Enabled && this._progressBarRenderer.setCapInsets(a)
- },
- setCapInsetProgressBarRenderer: function(a) {
- this._capInsetsProgressBarRenderer = a;
- this._scale9Enabled && this._progressBarRenderer.setCapInsets(a)
- },
- getCapInsetsProgressBarRebderer: function() {
- return this._capInsetsProgressBarRenderer
- },
- loadSlidBallTextures: function(a, c, d, e) {
- this.loadSlidBallTextureNormal(a, e);
- this.loadSlidBallTexturePressed(c, e);
- this.loadSlidBallTextureDisabled(d, e)
- },
- loadSlidBallTextureNormal: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._slidBallNormalTextureFile = a;
- this._ballNTexType = c;
- var d = this;
- (!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()) && this._slidBallNormalRenderer.addLoadedEventListener(function() {
- d._updateChildrenDisplayedRGBA()
- });
- switch (this._ballNTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._slidBallNormalRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._slidBallNormalRenderer.initWithSpriteFrameName(a)
- }
- this._updateChildrenDisplayedRGBA()
- }
- },
- loadSlidBallTexturePressed: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._slidBallPressedTextureFile = a;
- this._ballPTexType = c;
- var d = this;
- (!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()) && this._slidBallPressedRenderer.addLoadedEventListener(function() {
- d._updateChildrenDisplayedRGBA()
- });
- switch (this._ballPTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._slidBallPressedRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._slidBallPressedRenderer.initWithSpriteFrameName(a)
- }
- this._updateChildrenDisplayedRGBA()
- }
- },
- loadSlidBallTextureDisabled: function(a, c) {
- if (a) {
- c = c || ccui.Widget.LOCAL_TEXTURE;
- this._slidBallDisabledTextureFile = a;
- this._ballDTexType = c;
- var d = this;
- (!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()) && this._slidBallDisabledRenderer.addLoadedEventListener(function() {
- d._updateChildrenDisplayedRGBA()
- });
- switch (this._ballDTexType) {
- case ccui.Widget.LOCAL_TEXTURE:
- this._slidBallDisabledRenderer.initWithFile(a);
- break;
- case ccui.Widget.PLIST_TEXTURE:
- this._slidBallDisabledRenderer.initWithSpriteFrameName(a)
- }
- this._updateChildrenDisplayedRGBA()
- }
- },
- setPercent: function(a) {
- 100 < a && (a = 100);
- 0 > a && (a = 0);
- this._percent = a;
- a = this._barLength * (a / 100);
- this._slidBallRenderer.setPosition(cc.p(a, this._contentSize.height / 2));
- if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(cc.size(a, this._progressBarTextureSize.height));
- else {
- var c = this._progressBarRenderer,
- d = c.getTextureRect();
- c.setTextureRect(cc.rect(d.x, d.y, a, d.height), c.isTextureRectRotated())
- }
- },
- hitTest: function(a) {
- a = this._slidBallNormalRenderer.convertToNodeSpace(a);
- var c = this._slidBallNormalRenderer.getContentSize(),
- c = cc.rect(0, 0, c.width, c.height);
- return a.x >= c.x && a.x <= c.x + c.width && a.y >= c.y && a.y <= c.y + c.height ? !0 : !1
- },
- onTouchBegan: function(a, c) {
- var d = ccui.Widget.prototype.onTouchBegan.call(this, a, c);
- if (this._hit) {
- var e = this.convertToNodeSpace(this._touchBeganPosition);
- this.setPercent(this._getPercentWithBallPos(e.x));
- this._percentChangedEvent()
- }
- return d
- },
- onTouchMoved: function(a, c) {
- var d = a.getLocation(),
- d = this.convertToNodeSpace(d);
- this.setPercent(this._getPercentWithBallPos(d.x));
- this._percentChangedEvent()
- },
- onTouchEnded: function(a, c) {
- ccui.Widget.prototype.onTouchEnded.call(this, a, c)
- },
- onTouchCancelled: function(a, c) {
- ccui.Widget.prototype.onTouchCancelled.call(this, a, c)
- },
- _getPercentWithBallPos: function(a) {
- return 100 * (a / this._barLength)
- },
- addEventListenerSlider: function(a, c) {
- this._sliderEventSelector = a;
- this._sliderEventListener = c
- },
- addEventListener: function(a) {
- this._eventCallback = a
- },
- _percentChangedEvent: function() {
- this._sliderEventListener && this._sliderEventSelector && this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED);
- this._eventCallback && this._eventCallback(ccui.Slider.EVENT_PERCENT_CHANGED)
- },
- getPercent: function() {
- return this._percent
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._progressBarRendererDirty = this._barRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._barRendererAdaptDirty && (this._barRendererScaleChangedWithSize(), this._barRendererAdaptDirty = !1);
- this._progressBarRendererDirty && (this._progressBarRendererScaleChangedWithSize(), this._progressBarRendererDirty = !1)
- },
- getVirtualRendererSize: function() {
- return this._barRenderer.getContentSize()
- },
- getVirtualRenderer: function() {
- return this._barRenderer
- },
- _barRendererScaleChangedWithSize: function() {
- if (this._ignoreSize) this._barRenderer.setScale(1), this._barLength = this._contentSize.width;
- else if (this._barLength = this._contentSize.width, this._scale9Enabled) this._barRenderer.setPreferredSize(this._contentSize);
- else {
- var a = this._barRenderer.getContentSize();
- if (0 >= a.width || 0 >= a.height) {
- this._barRenderer.setScale(1);
- return
- }
- var c = this._contentSize.height / a.height;
- this._barRenderer.setScaleX(this._contentSize.width / a.width);
- this._barRenderer.setScaleY(c)
- }
- this._barRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2);
- this.setPercent(this._percent)
- },
- _progressBarRendererScaleChangedWithSize: function() {
- if (this._ignoreSize) {
- if (!this._scale9Enabled) {
- var a = this._progressBarTextureSize,
- c = this._contentSize.width / a.width,
- a = this._contentSize.height / a.height;
- this._progressBarRenderer.setScaleX(c);
- this._progressBarRenderer.setScaleY(a)
- }
- } else if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(this._contentSize), this._progressBarTextureSize = this._progressBarRenderer.getContentSize();
- else {
- a = this._progressBarTextureSize;
- if (0 >= a.width || 0 >= a.height) {
- this._progressBarRenderer.setScale(1);
- return
- }
- c = this._contentSize.width / a.width;
- a = this._contentSize.height / a.height;
- this._progressBarRenderer.setScaleX(c);
- this._progressBarRenderer.setScaleY(a)
- }
- this._progressBarRenderer.setPosition(0, this._contentSize.height / 2);
- this.setPercent(this._percent)
- },
- _onPressStateChangedToNormal: function() {
- this._slidBallNormalRenderer.setVisible(!0);
- this._slidBallPressedRenderer.setVisible(!1);
- this._slidBallDisabledRenderer.setVisible(!1)
- },
- _onPressStateChangedToPressed: function() {
- this._slidBallNormalRenderer.setVisible(!1);
- this._slidBallPressedRenderer.setVisible(!0);
- this._slidBallDisabledRenderer.setVisible(!1)
- },
- _onPressStateChangedToDisabled: function() {
- this._slidBallNormalRenderer.setVisible(!1);
- this._slidBallPressedRenderer.setVisible(!1);
- this._slidBallDisabledRenderer.setVisible(!0)
- },
- getDescription: function() {
- return "Slider"
- },
- _createCloneInstance: function() {
- return ccui.Slider.create()
- },
- _copySpecialProperties: function(a) {
- this._prevIgnoreSize = a._prevIgnoreSize;
- this.setScale9Enabled(a._scale9Enabled);
- this.loadBarTexture(a._textureFile, a._barTexType);
- this.loadProgressBarTexture(a._progressBarTextureFile, a._progressBarTexType);
- this.loadSlidBallTextureNormal(a._slidBallNormalTextureFile, a._ballNTexType);
- this.loadSlidBallTexturePressed(a._slidBallPressedTextureFile, a._ballPTexType);
- this.loadSlidBallTextureDisabled(a._slidBallDisabledTextureFile, a._ballDTexType);
- this.setPercent(a.getPercent());
- this._sliderEventListener = a._sliderEventListener;
- this._sliderEventSelector = a._sliderEventSelector;
- this._eventCallback = a._eventCallback
- }
- });
- _p = ccui.Slider.prototype;
- cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
- _p = null;
- ccui.Slider.create = function() {
- return new ccui.Slider
- };
- ccui.Slider.EVENT_PERCENT_CHANGED = 0;
- ccui.Slider.BASEBAR_RENDERER_ZORDER = -3;
- ccui.Slider.PROGRESSBAR_RENDERER_ZORDER = -2;
- ccui.Slider.BALL_RENDERER_ZORDER = -1;
- ccui.Text = ccui.Widget.extend({
- _touchScaleChangeEnabled: !1,
- _normalScaleValueX: 1,
- _normalScaleValueY: 1,
- _fontName: "Thonburi",
- _fontSize: 10,
- _onSelectedScaleOffset: 0.5,
- _labelRenderer: "",
- _textAreaSize: null,
- _textVerticalAlignment: 0,
- _textHorizontalAlignment: 0,
- _className: "Text",
- _type: null,
- _labelRendererAdaptDirty: !0,
- ctor: function(a, c, d) {
- this._type = ccui.Text.Type.SYSTEM;
- this._textAreaSize = cc.size(0, 0);
- ccui.Widget.prototype.ctor.call(this);
- d && this.init(a, c, d)
- },
- init: function(a, c, d) {
- return ccui.Widget.prototype.init.call(this) ? (0 < arguments.length && (this.setString(a), this.setFontName(c), this.setFontSize(d)), !0) : !1
- },
- _initRenderer: function() {
- this._labelRenderer = new cc.LabelTTF;
- this.addProtectedChild(this._labelRenderer, ccui.Text.RENDERER_ZORDER, -1)
- },
- setText: function(a) {
- cc.log("Please use the setString");
- this.setString(a)
- },
- setString: function(a) {
- this._labelRenderer.setString(a);
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getStringValue: function() {
- cc.log("Please use the getString");
- return this._labelRenderer.getString()
- },
- getString: function() {
- return this._labelRenderer.getString()
- },
- getStringLength: function() {
- return this._labelRenderer.getStringLength()
- },
- setFontSize: function(a) {
- this._labelRenderer.setFontSize(a);
- this._fontSize = a;
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getFontSize: function() {
- return this._fontSize
- },
- setFontName: function(a) {
- this._fontName = a;
- this._labelRenderer.setFontName(a);
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getFontName: function() {
- return this._fontName
- },
- _setFont: function(a) {
- var c = cc.LabelTTF._fontStyleRE.exec(a);
- c && (this._fontSize = parseInt(c[1]), this._fontName = c[2], this._labelRenderer._setFont(a), this._labelScaleChangedWithSize())
- },
- _getFont: function() {
- return this._labelRenderer._getFont()
- },
- getType: function() {
- return this._type
- },
- setTextAreaSize: function(a) {
- this._labelRenderer.setDimensions(a);
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getTextAreaSize: function() {
- return this._labelRenderer.getDimensions()
- },
- setTextHorizontalAlignment: function(a) {
- this._labelRenderer.setHorizontalAlignment(a);
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getTextHorizontalAlignment: function() {
- return this._labelRenderer.getHorizontalAlignment()
- },
- setTextVerticalAlignment: function(a) {
- this._labelRenderer.setVerticalAlignment(a);
- this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
- this._labelRendererAdaptDirty = !0
- },
- getTextVerticalAlignment: function() {
- return this._labelRenderer.getVerticalAlignment()
- },
- setTouchScaleChangeEnabled: function(a) {
- this._touchScaleChangeEnabled = a
- },
- isTouchScaleChangeEnabled: function() {
- return this._touchScaleChangeEnabled
- },
- _onPressStateChangedToNormal: function() {
- this._touchScaleChangeEnabled && (this._labelRenderer.setScaleX(this._normalScaleValueX), this._labelRenderer.setScaleY(this._normalScaleValueY))
- },
- _onPressStateChangedToPressed: function() {
- this._touchScaleChangeEnabled && (this._labelRenderer.setScaleX(this._normalScaleValueX + this._onSelectedScaleOffset), this._labelRenderer.setScaleY(this._normalScaleValueY + this._onSelectedScaleOffset))
- },
- _onPressStateChangedToDisabled: function() {},
- _updateFlippedX: function() {
- this._flippedX ? this._labelRenderer.setScaleX(-1) : this._labelRenderer.setScaleX(1)
- },
- _updateFlippedY: function() {
- this._flippedY ? this._labelRenderer.setScaleY(-1) : this._labelRenderer.setScaleY(1)
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._labelRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._labelRendererAdaptDirty && (this._labelScaleChangedWithSize(), this._labelRendererAdaptDirty = !1)
- },
- getVirtualRendererSize: function() {
- return this._labelRenderer.getContentSize()
- },
- getVirtualRenderer: function() {
- return this._labelRenderer
- },
- _labelScaleChangedWithSize: function() {
- var a = this._contentSize;
- if (this._ignoreSize) this._labelRenderer.setScale(1), this._normalScaleValueX = this._normalScaleValueY = 1;
- else {
- this._labelRenderer.setDimensions(cc.size(a.width, a.height));
- var c = this._labelRenderer.getContentSize();
- if (0 >= c.width || 0 >= c.height) {
- this._labelRenderer.setScale(1);
- return
- }
- var d = a.width / c.width,
- c = a.height / c.height;
- this._labelRenderer.setScaleX(d);
- this._labelRenderer.setScaleY(c);
- this._normalScaleValueX = d;
- this._normalScaleValueY = c
- }
- this._labelRenderer.setPosition(a.width / 2, a.height / 2)
- },
- getDescription: function() {
- return "Label"
- },
- enableShadow: function(a, c, d) {
- this._labelRenderer.enableShadow(a, c, d)
- },
- enableOutline: function(a, c) {
- this._labelRenderer.enableOutline(a, c)
- },
- enableGlow: function(a) {
- this._type == ccui.Text.Type.TTF && this._labelRenderer.enableGlow(a)
- },
- disableEffect: function() {
- this._labelRenderer.disableEffect()
- },
- _createCloneInstance: function() {
- return ccui.Text.create()
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.Text && (this.setFontName(a._fontName), this.setFontSize(a.getFontSize()), this.setString(a.getString()), this.setTouchScaleChangeEnabled(a.touchScaleEnabled), this.setTextAreaSize(a._textAreaSize), this.setTextHorizontalAlignment(a._labelRenderer.getHorizontalAlignment()), this.setTextVerticalAlignment(a._labelRenderer.getVerticalAlignment()))
- },
- _setBoundingWidth: function(a) {
- this._textAreaSize.width = a;
- this._labelRenderer._setBoundingWidth(a);
- this._labelScaleChangedWithSize()
- },
- _setBoundingHeight: function(a) {
- this._textAreaSize.height = a;
- this._labelRenderer._setBoundingHeight(a);
- this._labelScaleChangedWithSize()
- },
- _getBoundingWidth: function() {
- return this._textAreaSize.width
- },
- _getBoundingHeight: function() {
- return this._textAreaSize.height
- }
- });
- _p = ccui.Text.prototype;
- cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p._setBoundingWidth);
- cc.defineGetterSetter(_p, "boundingHeight", _p._getBoundingHeight, _p._setBoundingHeight);
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
- cc.defineGetterSetter(_p, "stringLength", _p.getStringLength);
- cc.defineGetterSetter(_p, "font", _p._getFont, _p._setFont);
- cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
- cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
- cc.defineGetterSetter(_p, "textAlign", _p.getTextHorizontalAlignment, _p.setTextHorizontalAlignment);
- cc.defineGetterSetter(_p, "verticalAlign", _p.getTextVerticalAlignment, _p.setTextVerticalAlignment);
- _p = null;
- ccui.Label = ccui.Text.create = function(a, c, d) {
- return new ccui.Text(a, c, d)
- };
- ccui.Text.RENDERER_ZORDER = -1;
- ccui.Text.Type = {
- SYSTEM: 0,
- TTF: 1
- };
- ccui.TextAtlas = ccui.Widget.extend({
- _labelAtlasRenderer: null,
- _stringValue: "",
- _charMapFileName: "",
- _itemWidth: 0,
- _itemHeight: 0,
- _startCharMap: "",
- _className: "TextAtlas",
- _labelAtlasRendererAdaptDirty: null,
- ctor: function(a, c, d, e, f) {
- ccui.Widget.prototype.ctor.call(this);
- f && this.setProperty(a, c, d, e, f)
- },
- _initRenderer: function() {
- this._labelAtlasRenderer = new cc.LabelAtlas;
- this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5));
- this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1)
- },
- setProperty: function(a, c, d, e, f) {
- this._stringValue = a;
- this._charMapFileName = c;
- this._itemWidth = d;
- this._itemHeight = e;
- this._startCharMap = f;
- this._labelAtlasRenderer.initWithString(a, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]);
- this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());
- this._labelAtlasRendererAdaptDirty = !0
- },
- setString: function(a) {
- this._stringValue = a;
- this._labelAtlasRenderer.setString(a);
- this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());
- this._labelAtlasRendererAdaptDirty = !0
- },
- setStringValue: function(a) {
- cc.log("Please use the setString");
- this.setString(a)
- },
- getStringValue: function() {
- cc.log("Please use the getString");
- return this.getString()
- },
- getString: function() {
- return this._labelAtlasRenderer.getString()
- },
- getStringLength: function() {
- return this._labelAtlasRenderer.getStringLength()
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._labelAtlasRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._labelAtlasRendererAdaptDirty && (this._labelAtlasScaleChangedWithSize(), this._labelAtlasRendererAdaptDirty = !1)
- },
- getVirtualRendererSize: function() {
- return this._labelAtlasRenderer.getContentSize()
- },
- getVirtualRenderer: function() {
- return this._labelAtlasRenderer
- },
- _labelAtlasScaleChangedWithSize: function() {
- var a = this._labelAtlasRenderer;
- if (this._ignoreSize) a.setScale(1);
- else {
- var c = a.getContentSize();
- if (0 >= c.width || 0 >= c.height) {
- a.setScale(1);
- return
- }
- a.setScaleX(this._contentSize.width / c.width);
- a.setScaleY(this._contentSize.height / c.height)
- }
- a.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- getDescription: function() {
- return "LabelAtlas"
- },
- _copySpecialProperties: function(a) {
- a && this.setProperty(a._stringValue, a._charMapFileName, a._itemWidth, a._itemHeight, a._startCharMap)
- },
- _createCloneInstance: function() {
- return ccui.TextAtlas.create()
- }
- });
- _p = ccui.TextAtlas.prototype;
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
- _p = null;
- ccui.TextAtlas.create = function(a, c, d, e, f) {
- return new ccui.TextAtlas(a, c, d, e, f)
- };
- ccui.TextAtlas.RENDERER_ZORDER = -1;
- ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend({
- _labelBMFontRenderer: null,
- _fntFileHasInit: !1,
- _fntFileName: "",
- _stringValue: "",
- _className: "TextBMFont",
- _labelBMFontRendererAdaptDirty: !0,
- ctor: function(a, c) {
- ccui.Widget.prototype.ctor.call(this);
- void 0 != c && (this.setFntFile(c), this.setString(a))
- },
- _initRenderer: function() {
- this._labelBMFontRenderer = cc.LabelBMFont.create();
- this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1)
- },
- setFntFile: function(a) {
- if (a) {
- var c = this;
- c._fntFileName = a;
- c._fntFileHasInit = !0;
- c._labelBMFontRenderer.initWithString(this._stringValue, a);
- a = c._labelBMFontRenderer;
- a._textureLoaded || a.addLoadedEventListener(function() {
- c.updateSizeAndPosition()
- })
- }
- },
- setText: function(a) {
- cc.log("Please use the setString");
- this.setString(a)
- },
- setString: function(a) {
- this._stringValue = a;
- this._fntFileHasInit && (this._labelBMFontRenderer.setString(a), this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()), this._labelBMFontRendererAdaptDirty = !0)
- },
- getString: function() {
- return this._stringValue
- },
- getStringLength: function() {
- return this._labelBMFontRenderer.getStringLength()
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._labelBMFontRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._labelBMFontRendererAdaptDirty && (this._labelBMFontScaleChangedWithSize(), this._labelBMFontRendererAdaptDirty = !1)
- },
- getVirtualRendererSize: function() {
- return this._labelBMFontRenderer.getContentSize()
- },
- getVirtualRenderer: function() {
- return this._labelBMFontRenderer
- },
- _labelBMFontScaleChangedWithSize: function() {
- var a = this._labelBMFontRenderer;
- if (this._ignoreSize) a.setScale(1);
- else {
- var c = a.getContentSize();
- if (0 >= c.width || 0 >= c.height) {
- a.setScale(1);
- return
- }
- a.setScaleX(this._contentSize.width / c.width);
- a.setScaleY(this._contentSize.height / c.height)
- }
- a.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- getDescription: function() {
- return "LabelBMFont"
- },
- createCloneInstance: function() {
- return ccui.TextBMFont.create()
- },
- copySpecialProperties: function(a) {
- this.setFntFile(a._fntFileName);
- this.setString(a._stringValue)
- }
- });
- _p = ccui.TextBMFont.prototype;
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue);
- _p = null;
- ccui.TextBMFont.create = function(a, c) {
- return new ccui.ccui.TextBMFont(a, c)
- };
- ccui.TextBMFont.RENDERER_ZORDER = -1;
- ccui.UICCTextField = cc.TextFieldTTF.extend({
- _maxLengthEnabled: !1,
- _maxLength: 0,
- _passwordEnabled: !1,
- _passwordStyleText: "",
- _attachWithIME: !1,
- _detachWithIME: !1,
- _insertText: !1,
- _deleteBackward: !1,
- _className: "UICCTextField",
- _textFieldRendererAdaptDirty: !0,
- ctor: function() {
- cc.TextFieldTTF.prototype.ctor.call(this);
- this._maxLengthEnabled = !1;
- this._maxLength = 0;
- this._passwordEnabled = !1;
- this._passwordStyleText = "*";
- this._deleteBackward = this._insertText = this._detachWithIME = this._attachWithIME = !1
- },
- onEnter: function() {
- cc.TextFieldTTF.prototype.onEnter.call(this);
- cc.TextFieldTTF.prototype.setDelegate.call(this, this)
- },
- onTextFieldAttachWithIME: function(a) {
- this.setAttachWithIME(!0);
- return !1
- },
- onTextFieldInsertText: function(a, c, d) {
- if (1 == d && "\n" == c) return !1;
- this.setInsertText(!0);
- return this._maxLengthEnabled && cc.TextFieldTTF.prototype.getCharCount.call(this) >= this._maxLength
- },
- onTextFieldDeleteBackward: function(a, c, d) {
- this.setDeleteBackward(!0);
- return !1
- },
- onTextFieldDetachWithIME: function(a) {
- this.setDetachWithIME(!0);
- return !1
- },
- insertText: function(a, c) {
- "\n" != a && this._maxLengthEnabled && this.getString().length >= this._maxLength ? this._passwordEnabled && this.setPasswordText(this.getString()) : (cc.TextFieldTTF.prototype.insertText.call(this, a, c), this._passwordEnabled && 0 < cc.TextFieldTTF.prototype.getCharCount.call(this) && this.setPasswordText(this.getString()))
- },
- deleteBackward: function() {
- cc.TextFieldTTF.prototype.deleteBackward.call(this);
- 0 < cc.TextFieldTTF.prototype.getCharCount.call(this) && this._passwordEnabled && this.setPasswordText(this._inputText)
- },
- openIME: function() {
- cc.TextFieldTTF.prototype.attachWithIME.call(this)
- },
- closeIME: function() {
- cc.TextFieldTTF.prototype.detachWithIME.call(this)
- },
- setMaxLengthEnabled: function(a) {
- this._maxLengthEnabled = a
- },
- isMaxLengthEnabled: function() {
- return this._maxLengthEnabled
- },
- setMaxLength: function(a) {
- this._maxLength = a
- },
- getMaxLength: function() {
- return this._maxLength
- },
- getCharCount: function() {
- return cc.TextFieldTTF.prototype.getCharCount.call(this)
- },
- setPasswordEnabled: function(a) {
- this._passwordEnabled = a
- },
- isPasswordEnabled: function() {
- return this._passwordEnabled
- },
- setPasswordStyleText: function(a) {
- if (!(1 < a.length)) {
- var c = a.charCodeAt(0);
- 33 > c || 126 < c || (this._passwordStyleText = a)
- }
- },
- setPasswordText: function(a) {
- var c = "",
- d = a.length;
- a = d;
- this._maxLengthEnabled && d > this._maxLength && (a = this._maxLength);
- for (d = 0; d < a; ++d) c += this._passwordStyleText;
- cc.LabelTTF.prototype.setString.call(this, c)
- },
- setAttachWithIME: function(a) {
- this._attachWithIME = a
- },
- getAttachWithIME: function() {
- return this._attachWithIME
- },
- setDetachWithIME: function(a) {
- this._detachWithIME = a
- },
- getDetachWithIME: function() {
- return this._detachWithIME
- },
- setInsertText: function(a) {
- this._insertText = a
- },
- getInsertText: function() {
- return this._insertText
- },
- setDeleteBackward: function(a) {
- this._deleteBackward = a
- },
- getDeleteBackward: function() {
- return this._deleteBackward
- },
- init: function() {
- return ccui.Widget.prototype.init.call(this) ? (this.setTouchEnabled(!0), !0) : !1
- },
- onDraw: function(a) {
- return !1
- }
- });
- ccui.UICCTextField.create = function(a, c, d) {
- var e = new ccui.UICCTextField;
- return e && e.initWithString("", c, d) ? (a && e.setPlaceHolder(a), e) : null
- };
- ccui.TextField = ccui.Widget.extend({
- _textFieldRenderer: null,
- _touchWidth: 0,
- _touchHeight: 0,
- _useTouchArea: !1,
- _textFieldEventListener: null,
- _textFieldEventSelector: null,
- _passwordStyleText: "",
- _textFieldRendererAdaptDirty: !0,
- _fontName: "",
- _fontSize: 12,
- ctor: function() {
- ccui.Widget.prototype.ctor.call(this)
- },
- init: function() {
- return ccui.Widget.prototype.init.call(this) ? (this.setTouchEnabled(!0), !0) : !1
- },
- onEnter: function() {
- ccui.Widget.prototype.onEnter.call(this);
- this.scheduleUpdate()
- },
- _initRenderer: function() {
- this._textFieldRenderer = ccui.UICCTextField.create("input words here", "Thonburi", 20);
- this.addProtectedChild(this._textFieldRenderer, ccui.TextField.RENDERER_ZORDER, -1)
- },
- setTouchSize: function(a) {
- this._touchWidth = a.width;
- this._touchHeight = a.height
- },
- setTouchAreaEnabled: function(a) {
- this._useTouchArea = a
- },
- hitTest: function(a) {
- if (this._useTouchArea) {
- a = this.convertToNodeSpace(a);
- var c = cc.rect(-this._touchWidth * this._anchorPoint.x, -this._touchHeight * this._anchorPoint.y, this._touchWidth, this._touchHeight);
- return a.x >= c.x && a.x <= c.x + c.width && a.y >= c.y && a.y <= c.y + c.height
- }
- return ccui.Widget.prototype.hitTest.call(this, a)
- },
- getTouchSize: function() {
- return cc.size(this._touchWidth, this._touchHeight)
- },
- setText: function(a) {
- cc.log("Please use the setString");
- this.setString(a)
- },
- setString: function(a) {
- a && (a = String(a), this.isMaxLengthEnabled() && (a = a.substr(0, this.getMaxLength())), this.isPasswordEnabled() ? (this._textFieldRenderer.setPasswordText(a), this._textFieldRenderer.setString(""), this._textFieldRenderer.insertText(a, a.length)) : this._textFieldRenderer.setString(a), this._textFieldRendererAdaptDirty = !0, this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()))
- },
- setPlaceHolder: function(a) {
- this._textFieldRenderer.setPlaceHolder(a);
- this._textFieldRendererAdaptDirty = !0;
- this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
- },
- getPlaceHolder: function() {
- return this._textFieldRenderer.getPlaceHolder()
- },
- setFontSize: function(a) {
- this._textFieldRenderer.setFontSize(a);
- this._fontSize = a;
- this._textFieldRendererAdaptDirty = !0;
- this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
- },
- getFontSize: function() {
- return this._fontSize
- },
- setFontName: function(a) {
- this._textFieldRenderer.setFontName(a);
- this._fontName = a;
- this._textFieldRendererAdaptDirty = !0;
- this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
- },
- getFontName: function() {
- return this._fontName
- },
- didNotSelectSelf: function() {
- this._textFieldRenderer.detachWithIME()
- },
- getStringValue: function() {
- cc.log("Please use the getString");
- return this.getString()
- },
- getString: function() {
- return this._textFieldRenderer.getString()
- },
- getStringLength: function() {
- return this._textFieldRenderer.getStringLength()
- },
- onTouchBegan: function(a, c) {
- var d = this,
- e = ccui.Widget.prototype.onTouchBegan.call(d, a, c);
- d._hit && setTimeout(function() {
- d._textFieldRenderer.attachWithIME()
- }, 0);
- return e
- },
- setMaxLengthEnabled: function(a) {
- this._textFieldRenderer.setMaxLengthEnabled(a)
- },
- isMaxLengthEnabled: function() {
- return this._textFieldRenderer.isMaxLengthEnabled()
- },
- setMaxLength: function(a) {
- this._textFieldRenderer.setMaxLength(a);
- this.setString(this.getString())
- },
- getMaxLength: function() {
- return this._textFieldRenderer.getMaxLength()
- },
- setPasswordEnabled: function(a) {
- this._textFieldRenderer.setPasswordEnabled(a)
- },
- isPasswordEnabled: function() {
- return this._textFieldRenderer.isPasswordEnabled()
- },
- setPasswordStyleText: function(a) {
- this._textFieldRenderer.setPasswordStyleText(a);
- this._passwordStyleText = a;
- this.setString(this.getString())
- },
- getPasswordStyleText: function() {
- return this._passwordStyleText
- },
- update: function(a) {
- this.getAttachWithIME() && (this._attachWithIMEEvent(), this.setAttachWithIME(!1));
- this.getDetachWithIME() && (this._detachWithIMEEvent(), this.setDetachWithIME(!1));
- this.getInsertText() && (this._insertTextEvent(), this.setInsertText(!1), this._textFieldRendererAdaptDirty = !0, this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()));
- this.getDeleteBackward() && (this._deleteBackwardEvent(), this.setDeleteBackward(!1), this._textFieldRendererAdaptDirty = !0, this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()))
- },
- getAttachWithIME: function() {
- return this._textFieldRenderer.getAttachWithIME()
- },
- setAttachWithIME: function(a) {
- this._textFieldRenderer.setAttachWithIME(a)
- },
- getDetachWithIME: function() {
- return this._textFieldRenderer.getDetachWithIME()
- },
- setDetachWithIME: function(a) {
- this._textFieldRenderer.setDetachWithIME(a)
- },
- getInsertText: function() {
- return this._textFieldRenderer.getInsertText()
- },
- setInsertText: function(a) {
- this._textFieldRenderer.setInsertText(a)
- },
- getDeleteBackward: function() {
- return this._textFieldRenderer.getDeleteBackward()
- },
- setDeleteBackward: function(a) {
- this._textFieldRenderer.setDeleteBackward(a)
- },
- _attachWithIMEEvent: function() {
- this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_IME);
- this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_ATTACH_WITH_IME)
- },
- _detachWithIMEEvent: function() {
- this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_IME);
- this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_DETACH_WITH_IME)
- },
- _insertTextEvent: function() {
- this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT);
- this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_INSERT_TEXT)
- },
- _deleteBackwardEvent: function() {
- this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD);
- this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_DELETE_BACKWARD)
- },
- addEventListenerTextField: function(a, c) {
- this._textFieldEventSelector = a;
- this._textFieldEventListener = c
- },
- addEventListener: function(a) {
- this._eventCallback = a
- },
- _onSizeChanged: function() {
- ccui.Widget.prototype._onSizeChanged.call(this);
- this._textFieldRendererAdaptDirty = !0
- },
- _adaptRenderers: function() {
- this._textFieldRendererAdaptDirty && (this._textfieldRendererScaleChangedWithSize(), this._textFieldRendererAdaptDirty = !1)
- },
- _textfieldRendererScaleChangedWithSize: function() {
- this._ignoreSize || this._textFieldRenderer.setDimensions(this._contentSize);
- this._textFieldRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
- },
- getVirtualRendererSize: function() {
- return this._textFieldRenderer.getContentSize()
- },
- getVirtualRenderer: function() {
- return this._textFieldRenderer
- },
- getDescription: function() {
- return "TextField"
- },
- attachWithIME: function() {
- this._textFieldRenderer.attachWithIME()
- },
- _createCloneInstance: function() {
- return ccui.TextField.create()
- },
- _copySpecialProperties: function(a) {
- this.setString(a._textFieldRenderer.getString());
- this.setPlaceHolder(a.getString());
- this.setFontSize(a._textFieldRenderer.getFontSize());
- this.setFontName(a._textFieldRenderer.getFontName());
- this.setMaxLengthEnabled(a.isMaxLengthEnabled());
- this.setMaxLength(a.getMaxLength());
- this.setPasswordEnabled(a.isPasswordEnabled());
- this.setPasswordStyleText(a._passwordStyleText);
- this.setAttachWithIME(a.getAttachWithIME());
- this.setDetachWithIME(a.getDetachWithIME());
- this.setInsertText(a.getInsertText());
- this.setDeleteBackward(a.getDeleteBackward())
- },
- setTextAreaSize: function(a) {
- this.setContentSize(a)
- },
- setTextHorizontalAlignment: function(a) {
- this._textFieldRenderer.setHorizontalAlignment(a)
- },
- setTextVerticalAlignment: function(a) {
- this._textFieldRenderer.setVerticalAlignment(a)
- },
- _setFont: function(a) {
- this._textFieldRender._setFont(a);
- this._textFieldRendererAdaptDirty = !0
- },
- _getFont: function() {
- return this._textFieldRender._getFont()
- }
- });
- ccui.TextField.create = function(a, c, d) {
- var e = new ccui.TextField;
- return e && e.init() ? (a && (c && d) && (e.setPlaceHolder(a), e.setFontName(c), e.setFontSize(d)), e) : null
- };
- _p = ccui.TextField.prototype;
- cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
- cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
- cc.defineGetterSetter(_p, "font", _p._getFont, _p._setFont);
- cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
- cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
- cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled);
- cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength);
- cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled);
- _p = null;
- ccui.TextField.create = function() {
- return new ccui.TextField
- };
- ccui.TextField.EVENT_ATTACH_WITH_IME = 0;
- ccui.TextField.EVENT_DETACH_WITH_IME = 1;
- ccui.TextField.EVENT_INSERT_TEXT = 2;
- ccui.TextField.EVENT_DELETE_BACKWARD = 3;
- ccui.TextField.RENDERER_ZORDER = -1;
- ccui.RichElement = ccui.Class.extend({
- _type: 0,
- _tag: 0,
- _color: null,
- _opacity: 0,
- ctor: function() {
- this._tag = this._type = 0;
- this._color = cc.color(255, 255, 255, 255)
- },
- init: function(a, c, d) {
- this._tag = a;
- this._color.r = c.r;
- this._color.g = c.g;
- this._color.b = c.b;
- this._opacity = d;
- this._color.a = void 0 === d ? c.a : d
- }
- });
- ccui.RichElementText = ccui.RichElement.extend({
- _text: "",
- _fontName: "",
- _fontSize: 0,
- ctor: function(a, c, d, e, f, g) {
- ccui.RichElement.prototype.ctor.call(this);
- this._type = ccui.RichElement.TEXT;
- this._fontName = this._text = "";
- this._fontSize = 0;
- g && this.init(a, c, d, e, f, g)
- },
- init: function(a, c, d, e, f, g) {
- ccui.RichElement.prototype.init.call(this, a, c, d);
- this._text = e;
- this._fontName = f;
- this._fontSize = g
- }
- });
- ccui.RichElementText.create = function(a, c, d, e, f, g) {
- return new ccui.RichElementText(a, c, d, e, f, g)
- };
- ccui.RichElementImage = ccui.RichElement.extend({
- _filePath: "",
- _textureRect: null,
- _textureType: 0,
- ctor: function(a, c, d, e) {
- ccui.RichElement.prototype.ctor.call(this);
- this._type = ccui.RichElement.IMAGE;
- this._filePath = "";
- this._textureRect = cc.rect(0, 0, 0, 0);
- this._textureType = 0;
- e && this.init(a, c, d, e)
- },
- init: function(a, c, d, e) {
- ccui.RichElement.prototype.init.call(this, a, c, d);
- this._filePath = e
- }
- });
- ccui.RichElementImage.create = function(a, c, d, e) {
- return new ccui.RichElementImage(a, c, d, e)
- };
- ccui.RichElementCustomNode = ccui.RichElement.extend({
- _customNode: null,
- ctor: function(a, c, d, e) {
- ccui.RichElement.prototype.ctor.call(this);
- this._type = ccui.RichElement.CUSTOM;
- this._customNode = null;
- e && this.init(a, c, d, e)
- },
- init: function(a, c, d, e) {
- ccui.RichElement.prototype.init.call(this, a, c, d);
- this._customNode = e
- }
- });
- ccui.RichElementCustomNode.create = function(a, c, d, e) {
- return new ccui.RichElementCustomNode(a, c, d, e)
- };
- ccui.RichText = ccui.Widget.extend({
- _formatTextDirty: !1,
- _richElements: null,
- _elementRenders: null,
- _leftSpaceWidth: 0,
- _verticalSpace: 0,
- _elementRenderersContainer: null,
- ctor: function() {
- ccui.Widget.prototype.ctor.call(this);
- this._formatTextDirty = !1;
- this._richElements = [];
- this._elementRenders = [];
- this._verticalSpace = this._leftSpaceWidth = 0
- },
- _initRenderer: function() {
- this._elementRenderersContainer = cc.Node.create();
- this._elementRenderersContainer.setAnchorPoint(0.5, 0.5);
- this.addProtectedChild(this._elementRenderersContainer, 0, -1)
- },
- insertElement: function(a, c) {
- this._richElements.splice(c, 0, a);
- this._formatTextDirty = !0
- },
- pushBackElement: function(a) {
- this._richElements.push(a);
- this._formatTextDirty = !0
- },
- removeElement: function(a) {
- "number" === typeof a ? this._richElements.splice(a, 1) : cc.arrayRemoveObject(this._richElements, a);
- this._formatTextDirty = !0
- },
- formatText: function() {
- if (this._formatTextDirty) {
- this._elementRenderersContainer.removeAllChildren();
- this._elementRenders.length = 0;
- var a, c, d = this._richElements;
- if (this._ignoreSize) {
- this._addNewLine();
- for (a = 0; a < d.length; a++) {
- c = d[a];
- var e = null;
- switch (c._type) {
- case ccui.RichElement.TEXT:
- e = cc.LabelTTF.create(c._text, c._fontName, c._fontSize);
- break;
- case ccui.RichElement.IMAGE:
- e = cc.Sprite.create(c._filePath);
- break;
- case ccui.RichElement.CUSTOM:
- e = c._customNode
- }
- e.setColor(c._color);
- e.setOpacity(c._color.a);
- this._pushToContainer(e)
- }
- } else {
- this._addNewLine();
- for (a = 0; a < d.length; a++) switch (c = d[a], c._type) {
- case ccui.RichElement.TEXT:
- this._handleTextRenderer(c._text, c._fontName, c._fontSize, c._color);
- break;
- case ccui.RichElement.IMAGE:
- this._handleImageRenderer(c._filePath, c._color, c._color.a);
- break;
- case ccui.RichElement.CUSTOM:
- this._handleCustomRenderer(c._customNode)
- }
- }
- this.formatRenderers();
- this._formatTextDirty = !1
- }
- },
- _handleTextRenderer: function(a, c, d, e) {
- var f = cc.LabelTTF.create(a, c, d),
- g = f.getContentSize().width;
- this._leftSpaceWidth -= g;
- 0 > this._leftSpaceWidth ? (f = a.length * (1 - -this._leftSpaceWidth / g), g = a.substr(0, f), a = a.substr(f, a.length - 1), 0 < f && (f = cc.LabelTTF.create(g.substr(0, f), c, d), f.setColor(e), f.setOpacity(e.a), this._pushToContainer(f)), this._addNewLine(), this._handleTextRenderer(a, c, d, e)) : (f.setColor(e), f.setOpacity(e.a), this._pushToContainer(f))
- },
- _handleImageRenderer: function(a, c, d) {
- a = cc.Sprite.create(a);
- this._handleCustomRenderer(a)
- },
- _formarRenderers: function() {},
- _handleCustomRenderer: function(a) {
- var c = a.getContentSize();
- this._leftSpaceWidth -= c.width;
- 0 > this._leftSpaceWidth ? (this._addNewLine(), this._pushToContainer(a), this._leftSpaceWidth -= c.width) : this._pushToContainer(a)
- },
- _addNewLine: function() {
- this._leftSpaceWidth = this._customSize.width;
- this._elementRenders.push([])
- },
- formatRenderers: function() {
- var a = 0,
- c = this._elementRenderersContainer,
- d = this._elementRenders,
- e, f, g, h, k;
- if (this._ignoreSize) {
- e = 0;
- g = d[0];
- for (f = h = 0; f < g.length; f++) k = g[f], k.setAnchorPoint(cc.p(0, 0)), k.setPosition(cc.p(h, 0)), c.addChild(k, 1, f), k = k.getContentSize(), e += k.width, a = Math.max(a, k.height), h += k.width;
- c.setContentSize(cc.size(e, a))
- } else {
- var m = [];
- for (e = 0; e < d.length; e++) {
- g = d[e];
- for (f = h = 0; f < g.length; f++) k = g[f], h = Math.max(k.getContentSize().height, h);
- m[e] = h;
- a += m[e]
- }
- a = this._customSize.height;
- for (e = 0; e < d.length; e++) {
- g = d[e];
- h = 0;
- a -= m[e] + this._verticalSpace;
- for (f = 0; f < g.length; f++) k = g[f], k.setAnchorPoint(cc.p(0, 0)), k.setPosition(cc.p(h, a)), c.addChild(k, 1), h += k.getContentSize().width
- }
- c.setContentSize(this._contentSize)
- }
- f = d.length;
- for (e = 0; e < f; e++) d[e].length = 0;
- this._elementRenders.length = 0;
- this.setContentSize(this._ignoreSize ? this.getVirtualRendererSize() : this._customSize);
- this._updateContentSizeWithTextureSize(this._contentSize);
- c.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height)
- },
- _pushToContainer: function(a) {
- 0 >= this._elementRenders.length || this._elementRenders[this._elementRenders.length - 1].push(a)
- },
- visit: function(a, c, d) {
- this._enabled && (this.formatText(), ccui.Widget.prototype.visit.call(this, a, c, d))
- },
- setVerticalSpace: function(a) {
- this._verticalSpace = a
- },
- setAnchorPoint: function(a) {
- ccui.Widget.prototype.setAnchorPoint.call(this, a);
- this._elementRenderersContainer.setAnchorPoint(a)
- },
- getVirtualRendererSize: function() {
- return this._elementRenderersContainer.getContentSize()
- },
- ignoreContentAdaptWithSize: function(a) {
- this._ignoreSize != a && (this._formatTextDirty = !0, ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a))
- },
- getDescription: function() {
- return "RichText"
- }
- });
- ccui.RichText.create = function() {
- return new ccui.RichText
- };
- ccui.RichElement.TEXT = 0;
- ccui.RichElement.IMAGE = 1;
- ccui.RichElement.CUSTOM = 2;
- ccui.ScrollView = ccui.Layout.extend({
- _innerContainer: null,
- direction: null,
- _autoScrollDir: null,
- _topBoundary: 0,
- _bottomBoundary: 0,
- _leftBoundary: 0,
- _rightBoundary: 0,
- _bounceTopBoundary: 0,
- _bounceBottomBoundary: 0,
- _bounceLeftBoundary: 0,
- _bounceRightBoundary: 0,
- _autoScroll: !1,
- _autoScrollAddUpTime: 0,
- _autoScrollOriginalSpeed: 0,
- _autoScrollAcceleration: 0,
- _isAutoScrollSpeedAttenuated: !1,
- _needCheckAutoScrollDestination: !1,
- _autoScrollDestination: null,
- _bePressed: !1,
- _slidTime: 0,
- _moveChildPoint: null,
- _childFocusCancelOffset: 0,
- _leftBounceNeeded: !1,
- _topBounceNeeded: !1,
- _rightBounceNeeded: !1,
- _bottomBounceNeeded: !1,
- bounceEnabled: !1,
- _bouncing: !1,
- _bounceDir: null,
- _bounceOriginalSpeed: 0,
- inertiaScrollEnabled: !1,
- _scrollViewEventListener: null,
- _scrollViewEventSelector: null,
- _className: "ScrollView",
- _eventCallback: null,
- ctor: function() {
- ccui.Layout.prototype.ctor.call(this);
- this.direction = ccui.ScrollView.DIR_NONE;
- this._autoScrollDir = cc.p(0, 0);
- this._autoScrollAcceleration = -1E3;
- this._autoScrollDestination = cc.p(0, 0);
- this._slidTime = 0;
- this._moveChildPoint = cc.p(0, 0);
- this._childFocusCancelOffset = 5;
- this._bounceDir = cc.p(0, 0);
- this._bounceOriginalSpeed = 0;
- this.inertiaScrollEnabled = !0;
- this.setTouchEnabled(!0)
- },
- init: function() {
- return ccui.Layout.prototype.init.call(this) ? (this.setClippingEnabled(!0), this._innerContainer.setTouchEnabled(!1), !0) : !1
- },
- onEnter: function() {
- ccui.Layout.prototype.onEnter.call(this);
- this.scheduleUpdate(!0)
- },
- findNextFocusedWidget: function(a, c) {
- return this.getLayoutType() == ccui.Layout.LINEAR_VERTICAL || this.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL ? this._innerContainer.findNextFocusedWidget(a, c) : ccui.Widget.prototype.findNextFocusedWidget.call(this, a, c)
- },
- _initRenderer: function() {
- ccui.Layout.prototype._initRenderer.call(this);
- this._innerContainer = ccui.Layout.create();
- this.addProtectedChild(this._innerContainer, 1, 1)
- },
- _onSizeChanged: function() {
- ccui.Layout.prototype._onSizeChanged.call(this);
- var a = this._contentSize;
- this._topBoundary = a.height;
- this._rightBoundary = a.width;
- var c = a.width / 3,
- d = a.height / 3;
- this._bounceTopBoundary = a.height - d;
- this._bounceBottomBoundary = d;
- this._bounceLeftBoundary = c;
- this._bounceRightBoundary = a.width - c;
- c = this._innerContainer.getContentSize();
- this._innerContainer.setContentSize(cc.size(Math.max(c.width, a.width), Math.max(c.height, a.height)));
- this._innerContainer.setPosition(0, a.height - this._innerContainer.getContentSize().height)
- },
- setInnerContainerSize: function(a) {
- var c = this._innerContainer,
- d = this._contentSize,
- e = d.width,
- f = d.height,
- g = c.getContentSize();
- a.width < d.width ? cc.log("Inner width \x3c\x3d ScrollView width, it will be force sized!") : e = a.width;
- a.height < d.height ? cc.log("Inner height \x3c\x3d ScrollView height, it will be force sized!") : f = a.height;
- c.setContentSize(cc.size(e, f));
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- e = c.getContentSize();
- g = g.height - e.height;
- this._scrollChildren(0, g);
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- c.getRightBoundary() <= d.width && (e = c.getContentSize(), g = g.width - e.width, this._scrollChildren(g, 0));
- break;
- case ccui.ScrollView.DIR_BOTH:
- e = c.getContentSize(), a = g.height - e.height, g = c.getRightBoundary() <= d.width ? g.width - e.width : 0, this._scrollChildren(g, a)
- }
- g = c.getContentSize();
- a = c.getPosition();
- e = c.getAnchorPoint();
- 0 < c.getLeftBoundary() && c.setPosition(e.x * g.width, a.y);
- c.getRightBoundary() < d.width && c.setPosition(d.width - (1 - e.x) * g.width, a.y);
- 0 < a.y && c.setPosition(a.x, e.y * g.height);
- c.getTopBoundary() < d.height && c.setPosition(a.x, d.height - (1 - e.y) * g.height)
- },
- _setInnerWidth: function(a) {
- var c = this._contentSize.width,
- d = c,
- e = this._innerContainer,
- f = e.width;
- a < c ? cc.log("Inner width \x3c\x3d scrollview width, it will be force sized!") : d = a;
- e.width = d;
- switch (this.direction) {
- case ccui.ScrollView.DIR_HORIZONTAL:
- case ccui.ScrollView.DIR_BOTH:
- e.getRightBoundary() <= c && this._scrollChildren(f - e.width, 0)
- }
- a = e.anchorX;
- 0 < e.getLeftBoundary() && (e.x = a * d);
- e.getRightBoundary() < c && (e.x = c - (1 - a) * d)
- },
- _setInnerHeight: function(a) {
- var c = this._contentSize.height,
- d = c,
- e = this._innerContainer,
- f = e.height;
- a < c ? cc.log("Inner height \x3c\x3d scrollview height, it will be force sized!") : d = a;
- e.height = d;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- case ccui.ScrollView.DIR_BOTH:
- this._scrollChildren(0, f - d)
- }
- a = e.anchorY;
- 0 < e.getLeftBoundary() && (e.y = a * d);
- e.getRightBoundary() < c && (e.y = c - (1 - a) * d)
- },
- getInnerContainerSize: function() {
- return this._innerContainer.getContentSize()
- },
- _getInnerWidth: function() {
- return this._innerContainer.width
- },
- _getInnerHeight: function() {
- return this._innerContainer.height
- },
- addChild: function(a, c, d) {
- if (!a) return !1;
- c = c || a.getLocalZOrder();
- d = d || a.getTag();
- return this._innerContainer.addChild(a, c, d)
- },
- removeAllChildren: function() {
- this.removeAllChildrenWithCleanup(!0)
- },
- removeAllChildrenWithCleanup: function(a) {
- this._innerContainer.removeAllChildrenWithCleanup(a)
- },
- removeChild: function(a, c) {
- return this._innerContainer.removeChild(a, c)
- },
- getChildren: function() {
- return this._innerContainer.getChildren()
- },
- getChildrenCount: function() {
- return this._innerContainer.getChildrenCount()
- },
- getChildByTag: function(a) {
- return this._innerContainer.getChildByTag(a)
- },
- getChildByName: function(a) {
- return this._innerContainer.getChildByName(a)
- },
- _moveChildren: function(a, c) {
- var d = this._innerContainer;
- this._moveChildPoint.x = d.x + a;
- this._moveChildPoint.y = d.y + c;
- this._innerContainer.setPosition(this._moveChildPoint)
- },
- _autoScrollChildren: function(a) {
- var c = this._autoScrollAddUpTime;
- this._autoScrollAddUpTime += a;
- if (this._isAutoScrollSpeedAttenuated) 0 >= this._autoScrollOriginalSpeed + this._autoScrollAcceleration * this._autoScrollAddUpTime ? (this._stopAutoScrollChildren(), this._checkNeedBounce()) : (c = (this._autoScrollOriginalSpeed + 0.5 * this._autoScrollAcceleration * (2 * c + a)) * a, this._scrollChildren(c * this._autoScrollDir.x, c * this._autoScrollDir.y) || (this._stopAutoScrollChildren(), this._checkNeedBounce()));
- else if (this._needCheckAutoScrollDestination) {
- var c = this._autoScrollDir.x * a * this._autoScrollOriginalSpeed,
- d = this._autoScrollDir.y * a * this._autoScrollOriginalSpeed;
- a = this._checkCustomScrollDestination(c, d);
- c = this._scrollChildren(c, d);
- if (!a || !c) this._stopAutoScrollChildren(), this._checkNeedBounce()
- } else this._scrollChildren(this._autoScrollDir.x * a * this._autoScrollOriginalSpeed, this._autoScrollDir.y * a * this._autoScrollOriginalSpeed) || (this._stopAutoScrollChildren(), this._checkNeedBounce())
- },
- _bounceChildren: function(a) {
- var c = this._bounceOriginalSpeed,
- d = this._bounceDir;
- 0 >= c && this._stopBounceChildren();
- this._bounceScrollChildren(d.x * a * c, d.y * a * c) || this._stopBounceChildren()
- },
- _checkNeedBounce: function() {
- if (!this.bounceEnabled) return !1;
- this._checkBounceBoundary();
- var a = this._topBounceNeeded,
- c = this._bottomBounceNeeded,
- d = this._leftBounceNeeded,
- e = this._rightBounceNeeded;
- if (a || c || d || e) {
- var f = this._contentSize,
- g = this._innerContainer;
- a && d ? (a = cc.pSub(cc.p(0, f.height), cc.p(g.getLeftBoundary(), g.getTopBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : a && e ? (a = cc.pSub(cc.p(f.width, f.height), cc.p(g.getRightBoundary(), g.getTopBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : c && d ? (a = cc.pSub(cc.p(0, 0), cc.p(g.getLeftBoundary(), g.getBottomBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : c && e ? (a = cc.pSub(cc.p(f.width, 0), cc.p(g.getRightBoundary(), g.getBottomBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : a ? (a = cc.pSub(cc.p(0, f.height), cc.p(0, g.getTopBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : c ? (a = cc.pSub(cc.p(0, 0), cc.p(0, g.getBottomBoundary())), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : d ? (a = cc.pSub(cc.p(0, 0), cc.p(g.getLeftBoundary(), 0)), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c)) : e && (a = cc.pSub(cc.p(f.width, 0), cc.p(g.getRightBoundary(), 0)), c = cc.pLength(a) / 0.2, this._bounceDir = cc.pNormalize(a), this._startBounceChildren(c));
- return !0
- }
- return !1
- },
- _checkBounceBoundary: function() {
- var a = this._innerContainer;
- a.getBottomBoundary() > this._bottomBoundary ? (this._scrollToBottomEvent(), this._bottomBounceNeeded = !0) : this._bottomBounceNeeded = !1;
- a.getTopBoundary() < this._topBoundary ? (this._scrollToTopEvent(), this._topBounceNeeded = !0) : this._topBounceNeeded = !1;
- a.getRightBoundary() < this._rightBoundary ? (this._scrollToRightEvent(), this._rightBounceNeeded = !0) : this._rightBounceNeeded = !1;
- a.getLeftBoundary() > this._leftBoundary ? (this._scrollToLeftEvent(), this._leftBounceNeeded = !0) : this._leftBounceNeeded = !1
- },
- _startBounceChildren: function(a) {
- this._bounceOriginalSpeed = a;
- this._bouncing = !0
- },
- _stopBounceChildren: function() {
- this._bouncing = !1;
- this._bounceOriginalSpeed = 0;
- this._bottomBounceNeeded = this._topBounceNeeded = this._rightBounceNeeded = this._leftBounceNeeded = !1
- },
- _startAutoScrollChildrenWithOriginalSpeed: function(a, c, d, e) {
- this._stopAutoScrollChildren();
- this._autoScrollDir = a;
- this._isAutoScrollSpeedAttenuated = d;
- this._autoScrollOriginalSpeed = c;
- this._autoScroll = !0;
- this._autoScrollAcceleration = e
- },
- _startAutoScrollChildrenWithDestination: function(a, c, d) {
- this._needCheckAutoScrollDestination = !1;
- this._autoScrollDestination = a;
- var e = cc.pSub(a, this._innerContainer.getPosition());
- a = cc.pNormalize(e);
- var f = 0,
- g = -1E3,
- e = cc.pLength(e);
- d ? (g = -(2 * e) / (c * c), f = 2 * e / c) : (this._needCheckAutoScrollDestination = !0, f = e / c);
- this._startAutoScrollChildrenWithOriginalSpeed(a, f, d, g)
- },
- _jumpToDestination: function(a, c) {
- void 0 !== a.x && (c = a.y, a = a.x);
- var d = a,
- e = c;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- 0 >= c && (e = Math.max(c, this._contentSize.height - this._innerContainer.getContentSize().height));
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- 0 >= a && (d = Math.max(a, this._contentSize.width - this._innerContainer.getContentSize().width));
- break;
- case ccui.ScrollView.DIR_BOTH:
- 0 >= c && (e = Math.max(c, this._contentSize.height - this._innerContainer.getContentSize().height)), 0 >= a && (d = Math.max(a, this._contentSize.width - this._innerContainer.getContentSize().width))
- }
- this._innerContainer.setPosition(d, e)
- },
- _stopAutoScrollChildren: function() {
- this._autoScroll = !1;
- this._autoScrollAddUpTime = this._autoScrollOriginalSpeed = 0
- },
- _bounceScrollChildren: function(a, c) {
- var d = !0,
- e, f, g, h;
- h = this._innerContainer;
- 0 < a && 0 < c ? (e = a, f = c, g = h.getRightBoundary(), g + e >= this._rightBoundary && (e = this._rightBoundary - g, this._bounceRightEvent(), d = !1), h = h.getTopBoundary(), h + c >= this._topBoundary && (f = this._topBoundary - h, this._bounceTopEvent(), d = !1), this._moveChildren(e, f)) : 0 > a && 0 < c ? (e = a, f = c, g = h.getLeftBoundary(), g + e <= this._leftBoundary && (e = this._leftBoundary - g, this._bounceLeftEvent(), d = !1), h = h.getTopBoundary(), h + c >= this._topBoundary && (f = this._topBoundary - h, this._bounceTopEvent(), d = !1), this._moveChildren(e, f)) : 0 > a && 0 > c ? (e = a, f = c, g = h.getLeftBoundary(), g + e <= this._leftBoundary && (e = this._leftBoundary - g, this._bounceLeftEvent(), d = !1), h = h.getBottomBoundary(), h + c <= this._bottomBoundary && (f = this._bottomBoundary - h, this._bounceBottomEvent(), d = !1), this._moveChildren(e, f)) : 0 < a && 0 > c ? (e = a, f = c, g = h.getRightBoundary(), g + e >= this._rightBoundary && (e = this._rightBoundary - g, this._bounceRightEvent(), d = !1), h = h.getBottomBoundary(), h + c <= this._bottomBoundary && (f = this._bottomBoundary - h, this._bounceBottomEvent(), d = !1), this._moveChildren(e, f)) : 0 == a && 0 < c ? (f = c, h = h.getTopBoundary(), h + c >= this._topBoundary && (f = this._topBoundary - h, this._bounceTopEvent(), d = !1), this._moveChildren(0, f)) : 0 == a && 0 > c ? (f = c, h = h.getBottomBoundary(), h + c <= this._bottomBoundary && (f = this._bottomBoundary - h, this._bounceBottomEvent(), d = !1), this._moveChildren(0, f)) : 0 < a && 0 == c ? (e = a, g = h.getRightBoundary(), g + e >= this._rightBoundary && (e = this._rightBoundary - g, this._bounceRightEvent(), d = !1), this._moveChildren(e, 0)) : 0 > a && 0 == c && (e = a, f = h.getLeftBoundary(), f + e <= this._leftBoundary && (e = this._leftBoundary - f, this._bounceLeftEvent(), d = !1), this._moveChildren(e, 0));
- return d
- },
- _checkCustomScrollDestination: function(a, c) {
- var d = !0,
- e, f;
- e = this._innerContainer;
- var g = this._autoScrollDestination;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- 0 < this._autoScrollDir.y ? (e = e.getBottomBoundary(), e + c >= g.y && (d = !1)) : (e = e.getBottomBoundary(), e + c <= g.y && (d = !1));
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- 0 < this._autoScrollDir.x ? (f = e.getLeftBoundary(), f + a >= g.x && (d = !1)) : (f = e.getLeftBoundary(), f + a <= g.x && (d = !1));
- break;
- case ccui.ScrollView.DIR_BOTH:
- 0 < a && 0 < c ? (f = e.getLeftBoundary(), f + a >= g.x && (d = !1), e = e.getBottomBoundary(), e + c >= g.y && (d = !1)) : 0 > a && 0 < c ? (f = e.getRightBoundary(), f + a <= g.x && (d = !1), e = e.getBottomBoundary(), e + c >= g.y && (d = !1)) : 0 > a && 0 > c ? (f = e.getRightBoundary(), f + a <= g.x && (d = !1), e = e.getTopBoundary(), e + c <= g.y && (d = !1)) : 0 < a && 0 > c ? (f = e.getLeftBoundary(), f + a >= g.x && (d = !1), e = e.getTopBoundary(), e + c <= g.y && (d = !1)) : 0 == a && 0 < c ? (e = e.getBottomBoundary(), e + c >= g.y && (d = !1)) : 0 > a && 0 == c ? (f = e.getRightBoundary(), f + a <= g.x && (d = !1)) : 0 == a && 0 > c ? (e = e.getTopBoundary(), e + c <= g.y && (d = !1)) : 0 < a && 0 == c && (f = e.getLeftBoundary(), f + a >= g.x && (d = !1))
- }
- return d
- },
- getCurAutoScrollDistance: function(a) {
- this._autoScrollOriginalSpeed -= this._autoScrollAcceleration * a;
- return this._autoScrollOriginalSpeed * a
- },
- _scrollChildren: function(a, c) {
- var d = !0;
- this._scrollingEvent();
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- d = this._scrollChildrenVertical(a, c);
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- d = this._scrollChildrenHorizontal(a, c);
- break;
- case ccui.ScrollView.DIR_BOTH:
- d = this._scrollChildrenBoth(a, c)
- }
- return d
- },
- _scrollChildrenVertical: function(a, c) {
- var d = c,
- e = !0,
- f, g = this._innerContainer;
- this.bounceEnabled ? (f = g.getBottomBoundary(), f + c >= this._bounceBottomBoundary && (d = this._bounceBottomBoundary - f, this._scrollToBottomEvent(), e = !1), f = g.getTopBoundary(), f + c <= this._bounceTopBoundary && (d = this._bounceTopBoundary - f, this._scrollToTopEvent(), e = !1)) : (f = g.getBottomBoundary(), f + c >= this._bottomBoundary && (d = this._bottomBoundary - f, this._scrollToBottomEvent(), e = !1), f = g.getTopBoundary(), f + c <= this._topBoundary && (d = this._topBoundary - f, this._scrollToTopEvent(), e = !1));
- this._moveChildren(0, d);
- return e
- },
- _scrollChildrenHorizontal: function(a, c) {
- var d = !0,
- e = a,
- f, g = this._innerContainer;
- this.bounceEnabled ? (f = g.getRightBoundary(), f + a <= this._bounceRightBoundary && (e = this._bounceRightBoundary - f, this._scrollToRightEvent(), d = !1), f = g.getLeftBoundary(), f + a >= this._bounceLeftBoundary && (e = this._bounceLeftBoundary - f, this._scrollToLeftEvent(), d = !1)) : (f = g.getRightBoundary(), f + a <= this._rightBoundary && (e = this._rightBoundary - f, this._scrollToRightEvent(), d = !1), f = g.getLeftBoundary(), f + a >= this._leftBoundary && (e = this._leftBoundary - f, this._scrollToLeftEvent(), d = !1));
- this._moveChildren(e, 0);
- return d
- },
- _scrollChildrenBoth: function(a, c) {
- var d = !0,
- e = a,
- f = c,
- g, h;
- h = this._innerContainer;
- this.bounceEnabled ? 0 < a && 0 < c ? (g = h.getLeftBoundary(), g + a >= this._bounceLeftBoundary && (e = this._bounceLeftBoundary - g, this._scrollToLeftEvent(), d = !1), h = h.getBottomBoundary(), h + c >= this._bounceBottomBoundary && (f = this._bounceBottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 < c ? (g = h.getRightBoundary(), g + a <= this._bounceRightBoundary && (e = this._bounceRightBoundary - g, this._scrollToRightEvent(), d = !1), h = h.getBottomBoundary(), h + c >= this._bounceBottomBoundary && (f = this._bounceBottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 > c ? (g = h.getRightBoundary(), g + a <= this._bounceRightBoundary && (e = this._bounceRightBoundary - g, this._scrollToRightEvent(), d = !1), h = h.getTopBoundary(), h + c <= this._bounceTopBoundary && (f = this._bounceTopBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 < a && 0 > c ? (g = h.getLeftBoundary(), g + a >= this._bounceLeftBoundary && (e = this._bounceLeftBoundary - g, this._scrollToLeftEvent(), d = !1), h = h.getTopBoundary(), h + c <= this._bounceTopBoundary && (f = this._bounceTopBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 == a && 0 < c ? (h = h.getBottomBoundary(), h + c >= this._bounceBottomBoundary && (f = this._bounceBottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 == c ? (g = h.getRightBoundary(), g + a <= this._bounceRightBoundary && (e = this._bounceRightBoundary - g, this._scrollToRightEvent(), d = !1)) : 0 == a && 0 > c ? (h = h.getTopBoundary(), h + c <= this._bounceTopBoundary && (f = this._bounceTopBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 < a && 0 == c && (g = h.getLeftBoundary(), g + a >= this._bounceLeftBoundary && (e = this._bounceLeftBoundary - g, this._scrollToLeftEvent(), d = !1)) : 0 < a && 0 < c ? (g = h.getLeftBoundary(), g + a >= this._leftBoundary && (e = this._leftBoundary - g, this._scrollToLeftEvent(), d = !1), h = h.getBottomBoundary(), h + c >= this._bottomBoundary && (f = this._bottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 < c ? (g = h.getRightBoundary(), g + a <= this._rightBoundary && (e = this._rightBoundary - g, this._scrollToRightEvent(), d = !1), h = h.getBottomBoundary(), h + c >= this._bottomBoundary && (f = this._bottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 > c ? (g = h.getRightBoundary(), g + a <= this._rightBoundary && (e = this._rightBoundary - g, this._scrollToRightEvent(), d = !1), h = h.getTopBoundary(), h + c <= this._topBoundary && (f = this._topBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 < a && 0 > c ? (g = h.getLeftBoundary(), g + a >= this._leftBoundary && (e = this._leftBoundary - g, this._scrollToLeftEvent(), d = !1), h = this._innerContainer.getTopBoundary(), h + c <= this._topBoundary && (f = this._topBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 == a && 0 < c ? (h = this._innerContainer.getBottomBoundary(), h + c >= this._bottomBoundary && (f = this._bottomBoundary - h, this._scrollToBottomEvent(), d = !1)) : 0 > a && 0 == c ? (g = this._innerContainer.getRightBoundary(), g + a <= this._rightBoundary && (e = this._rightBoundary - g, this._scrollToRightEvent(), d = !1)) : 0 == a && 0 > c ? (h = this._innerContainer.getTopBoundary(), h + c <= this._topBoundary && (f = this._topBoundary - h, this._scrollToTopEvent(), d = !1)) : 0 < a && 0 == c && (g = this._innerContainer.getLeftBoundary(), g + a >= this._leftBoundary && (e = this._leftBoundary - g, this._scrollToLeftEvent(), d = !1));
- this._moveChildren(e, f);
- return d
- },
- scrollToBottom: function(a, c) {
- this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), a, c)
- },
- scrollToTop: function(a, c) {
- this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height), a, c)
- },
- scrollToLeft: function(a, c) {
- this._startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), a, c)
- },
- scrollToRight: function(a, c) {
- this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()), a, c)
- },
- scrollToTopLeft: function(a, c) {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._startAutoScrollChildrenWithDestination(cc.p(0, this._contentSize.height - this._innerContainer.getContentSize().height), a, c)
- },
- scrollToTopRight: function(a, c) {
- if (this.direction != ccui.ScrollView.DIR_BOTH) cc.log("Scroll direction is not both!");
- else {
- var d = this._innerContainer.getContentSize();
- this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - d.width, this._contentSize.height - d.height), a, c)
- }
- },
- scrollToBottomLeft: function(a, c) {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._startAutoScrollChildrenWithDestination(cc.p(0, 0), a, c)
- },
- scrollToBottomRight: function(a, c) {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, 0), a, c)
- },
- scrollToPercentVertical: function(a, c, d) {
- var e = this._contentSize.height - this._innerContainer.getContentSize().height,
- f = -e;
- this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), e + a * f / 100), c, d)
- },
- scrollToPercentHorizontal: function(a, c, d) {
- var e = this._innerContainer.getContentSize().width - this._contentSize.width;
- this._startAutoScrollChildrenWithDestination(cc.p(-(a * e / 100), this._innerContainer.getPositionY()), c, d)
- },
- scrollToPercentBothDirection: function(a, c, d) {
- if (this.direction == ccui.ScrollView.DIR_BOTH) {
- var e = this._contentSize.height - this._innerContainer.getContentSize().height,
- f = -e,
- g = this._innerContainer.getContentSize().width - this._contentSize.width;
- this._startAutoScrollChildrenWithDestination(cc.p(-(a.x * g / 100), e + a.y * f / 100), c, d)
- }
- },
- jumpToBottom: function() {
- this._jumpToDestination(this._innerContainer.getPositionX(), 0)
- },
- jumpToTop: function() {
- this._jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height)
- },
- jumpToLeft: function() {
- this._jumpToDestination(0, this._innerContainer.getPositionY())
- },
- jumpToRight: function() {
- this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY())
- },
- jumpToTopLeft: function() {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height)
- },
- jumpToTopRight: function() {
- if (this.direction != ccui.ScrollView.DIR_BOTH) cc.log("Scroll direction is not both!");
- else {
- var a = this._innerContainer.getContentSize();
- this._jumpToDestination(this._contentSize.width - a.width, this._contentSize.height - a.height)
- }
- },
- jumpToBottomLeft: function() {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(0, 0)
- },
- jumpToBottomRight: function() {
- this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0)
- },
- jumpToPercentVertical: function(a) {
- var c = this._contentSize.height - this._innerContainer.getContentSize().height,
- d = -c;
- this._jumpToDestination(this._innerContainer.getPositionX(), c + a * d / 100)
- },
- jumpToPercentHorizontal: function(a) {
- var c = this._innerContainer.getContentSize().width - this._contentSize.width;
- this._jumpToDestination(-(a * c / 100), this._innerContainer.getPositionY())
- },
- jumpToPercentBothDirection: function(a) {
- if (this.direction == ccui.ScrollView.DIR_BOTH) {
- var c = this._innerContainer.getContentSize(),
- d = this._contentSize.height - c.height;
- this._jumpToDestination(-(a.x * (c.width - this._contentSize.width) / 100), d + a.y * -d / 100)
- }
- },
- _startRecordSlidAction: function() {
- this._autoScroll && this._stopAutoScrollChildren();
- this._bouncing && this._stopBounceChildren();
- this._slidTime = 0
- },
- _endRecordSlidAction: function() {
- if (!this._checkNeedBounce() && this.inertiaScrollEnabled && !(0.016 >= this._slidTime)) {
- var a = 0,
- c;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- a = this._touchEndPosition.y - this._touchBeganPosition.y;
- c = 0 > a ? ccui.ScrollView.SCROLLDIR_DOWN : ccui.ScrollView.SCROLLDIR_UP;
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- a = this._touchEndPosition.x - this._touchBeganPosition.x;
- c = 0 > a ? ccui.ScrollView.SCROLLDIR_LEFT : ccui.ScrollView.SCROLLDIR_RIGHT;
- break;
- case ccui.ScrollView.DIR_BOTH:
- c = cc.pSub(this._touchEndPosition, this._touchBeganPosition), a = cc.pLength(c), c = cc.pNormalize(c)
- }
- a = Math.min(Math.abs(a) / this._slidTime, ccui.ScrollView.AUTO_SCROLL_MAX_SPEED);
- this._startAutoScrollChildrenWithOriginalSpeed(c, a, !0, -1E3);
- this._slidTime = 0
- }
- },
- _handlePressLogic: function(a) {
- this._startRecordSlidAction();
- this._bePressed = !0
- },
- _handleMoveLogic: function(a) {
- a = cc.pSub(a.getLocation(), a.getPreviousLocation());
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- this._scrollChildren(0, a.y);
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- this._scrollChildren(a.x, 0);
- break;
- case ccui.ScrollView.DIR_BOTH:
- this._scrollChildren(a.x, a.y)
- }
- },
- _handleReleaseLogic: function(a) {
- this._endRecordSlidAction();
- this._bePressed = !1
- },
- onTouchBegan: function(a, c) {
- var d = ccui.Layout.prototype.onTouchBegan.call(this, a, c);
- this._hit && this._handlePressLogic(a);
- return d
- },
- onTouchMoved: function(a, c) {
- ccui.Layout.prototype.onTouchMoved.call(this, a, c);
- this._handleMoveLogic(a)
- },
- onTouchEnded: function(a, c) {
- ccui.Layout.prototype.onTouchEnded.call(this, a, c);
- this._handleReleaseLogic(a)
- },
- onTouchCancelled: function(a, c) {
- ccui.Layout.prototype.onTouchCancelled.call(this, a, c)
- },
- update: function(a) {
- this._autoScroll && this._autoScrollChildren(a);
- this._bouncing && this._bounceChildren(a);
- this._recordSlidTime(a)
- },
- _recordSlidTime: function(a) {
- this._bePressed && (this._slidTime += a)
- },
- interceptTouchEvent: function(a, c, d) {
- var e = d.getLocation();
- switch (a) {
- case ccui.Widget.TOUCH_BEGAN:
- this._touchBeganPosition.x = e.x;
- this._touchBeganPosition.y = e.y;
- this._handlePressLogic(d);
- break;
- case ccui.Widget.TOUCH_MOVED:
- cc.pLength(cc.pSub(c.getTouchBeganPosition(), e)) > this._childFocusCancelOffset && (c.setHighlighted(!1), this._touchMovePosition.x = e.x, this._touchMovePosition.y = e.y, this._handleMoveLogic(d));
- break;
- case ccui.Widget.TOUCH_CANCELED:
- case ccui.Widget.TOUCH_ENDED:
- this._touchEndPosition.x = e.x, this._touchEndPosition.y = e.y, this._handleReleaseLogic(d)
- }
- },
- _scrollToTopEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP)
- },
- _scrollToBottomEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM)
- },
- _scrollToLeftEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT)
- },
- _scrollToRightEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT)
- },
- _scrollingEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLLING)
- },
- _bounceTopEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_TOP)
- },
- _bounceBottomEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM)
- },
- _bounceLeftEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT)
- },
- _bounceRightEvent: function() {
- this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT);
- this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT)
- },
- addEventListenerScrollView: function(a, c) {
- this._scrollViewEventSelector = a;
- this._scrollViewEventListener = c
- },
- addEventListener: function(a) {
- this._eventCallback = a
- },
- setDirection: function(a) {
- this.direction = a
- },
- getDirection: function() {
- return this.direction
- },
- setBounceEnabled: function(a) {
- this.bounceEnabled = a
- },
- isBounceEnabled: function() {
- return this.bounceEnabled
- },
- setInertiaScrollEnabled: function(a) {
- this.inertiaScrollEnabled = a
- },
- isInertiaScrollEnabled: function() {
- return this.inertiaScrollEnabled
- },
- getInnerContainer: function() {
- return this._innerContainer
- },
- setLayoutType: function(a) {
- this._innerContainer.setLayoutType(a)
- },
- getLayoutType: function() {
- return this._innerContainer.getLayoutType()
- },
- _doLayout: function() {
- this._doLayoutDirty && (this._doLayoutDirty = !1)
- },
- getDescription: function() {
- return "ScrollView"
- },
- _createCloneInstance: function() {
- return ccui.ScrollView.create()
- },
- _copyClonedWidgetChildren: function(a) {
- ccui.Layout.prototype._copyClonedWidgetChildren.call(this, a)
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.ScrollView && (ccui.Layout.prototype._copySpecialProperties.call(this, a), this.setInnerContainerSize(a.getInnerContainerSize()), this.setDirection(a.direction), this.setBounceEnabled(a.bounceEnabled), this.setInertiaScrollEnabled(a.inertiaScrollEnabled), this._scrollViewEventListener = a._scrollViewEventListener, this._scrollViewEventSelector = a._scrollViewEventSelector, this._eventCallback = a._eventCallback)
- },
- getNodeByTag: function(a) {
- return this._innerContainer.getNodeByTag(a)
- },
- getNodes: function() {
- return this._innerContainer.getNodes()
- },
- removeNode: function(a) {
- this._innerContainer.removeNode(a)
- },
- removeNodeByTag: function(a) {
- this._innerContainer.removeNodeByTag(a)
- },
- removeAllNodes: function() {
- this._innerContainer.removeAllNodes()
- },
- addNode: function(a, c, d) {
- this._innerContainer.addNode(a, c, d)
- }
- });
- _p = ccui.ScrollView.prototype;
- cc.defineGetterSetter(_p, "innerWidth", _p._getInnerWidth, _p._setInnerWidth);
- cc.defineGetterSetter(_p, "innerHeight", _p._getInnerHeight, _p._setInnerHeight);
- _p = null;
- ccui.ScrollView.create = function() {
- return new ccui.ScrollView
- };
- ccui.ScrollView.DIR_NONE = 0;
- ccui.ScrollView.DIR_VERTICAL = 1;
- ccui.ScrollView.DIR_HORIZONTAL = 2;
- ccui.ScrollView.DIR_BOTH = 3;
- ccui.ScrollView.EVENT_SCROLL_TO_TOP = 0;
- ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM = 1;
- ccui.ScrollView.EVENT_SCROLL_TO_LEFT = 2;
- ccui.ScrollView.EVENT_SCROLL_TO_RIGHT = 3;
- ccui.ScrollView.EVENT_SCROLLING = 4;
- ccui.ScrollView.EVENT_BOUNCE_TOP = 5;
- ccui.ScrollView.EVENT_BOUNCE_BOTTOM = 6;
- ccui.ScrollView.EVENT_BOUNCE_LEFT = 7;
- ccui.ScrollView.EVENT_BOUNCE_RIGHT = 8;
- ccui.ScrollView.AUTO_SCROLL_MAX_SPEED = 1E3;
- ccui.ScrollView.SCROLLDIR_UP = cc.p(0, 1);
- ccui.ScrollView.SCROLLDIR_DOWN = cc.p(0, -1);
- ccui.ScrollView.SCROLLDIR_LEFT = cc.p(-1, 0);
- ccui.ScrollView.SCROLLDIR_RIGHT = cc.p(1, 0);
- ccui.ListView = ccui.ScrollView.extend({
- _model: null,
- _items: null,
- _gravity: null,
- _itemsMargin: 0,
- _curSelectedIndex: 0,
- _refreshViewDirty: !0,
- _listViewEventListener: null,
- _listViewEventSelector: null,
- _eventCallback: null,
- ctor: function() {
- ccui.ScrollView.prototype.ctor.call(this);
- this._items = [];
- this._gravity = ccui.ListView.GRAVITY_CENTER_HORIZONTAL;
- this.setTouchEnabled(!0);
- this.init()
- },
- init: function() {
- return ccui.ScrollView.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_VERTICAL), !0) : !1
- },
- setItemModel: function(a) {
- a && (this._model = a)
- },
- _updateInnerContainerSize: function() {
- var a = this._items,
- c, d;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- c = a.length;
- var e = (c - 1) * this._itemsMargin;
- for (d = 0; d < c; d++) e += a[d].getContentSize().height;
- this.setInnerContainerSize(cc.size(this._contentSize.width, e));
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- c = a.length;
- e = (c - 1) * this._itemsMargin;
- for (d = 0; d < c; d++) e += a[d].getContentSize().width;
- this.setInnerContainerSize(cc.size(e, this._contentSize.height))
- }
- },
- _remedyLayoutParameter: function(a) {
- if (a) {
- var c;
- switch (this.direction) {
- case ccui.ScrollView.DIR_VERTICAL:
- if (c = a.getLayoutParameter()) switch (0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(0, this._itemsMargin, 0, 0)), this._gravity) {
- case ccui.ListView.GRAVITY_LEFT:
- c.setGravity(ccui.LinearLayoutParameter.LEFT);
- break;
- case ccui.ListView.GRAVITY_RIGHT:
- c.setGravity(ccui.LinearLayoutParameter.RIGHT);
- break;
- case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:
- c.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)
- } else {
- c = ccui.LinearLayoutParameter.create();
- switch (this._gravity) {
- case ccui.ListView.GRAVITY_LEFT:
- c.setGravity(ccui.LinearLayoutParameter.LEFT);
- break;
- case ccui.ListView.GRAVITY_RIGHT:
- c.setGravity(ccui.LinearLayoutParameter.RIGHT);
- break;
- case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:
- c.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)
- }
- 0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(0, this._itemsMargin, 0, 0));
- a.setLayoutParameter(c)
- }
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- if (c = a.getLayoutParameter()) switch (0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(this._itemsMargin, 0, 0, 0)), this._gravity) {
- case ccui.ListView.GRAVITY_TOP:
- c.setGravity(ccui.LinearLayoutParameter.TOP);
- break;
- case ccui.ListView.GRAVITY_BOTTOM:
- c.setGravity(ccui.LinearLayoutParameter.BOTTOM);
- break;
- case ccui.ListView.GRAVITY_CENTER_VERTICAL:
- c.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)
- } else {
- c = ccui.LinearLayoutParameter.create();
- switch (this._gravity) {
- case ccui.ListView.GRAVITY_TOP:
- c.setGravity(ccui.LinearLayoutParameter.TOP);
- break;
- case ccui.ListView.GRAVITY_BOTTOM:
- c.setGravity(ccui.LinearLayoutParameter.BOTTOM);
- break;
- case ccui.ListView.GRAVITY_CENTER_VERTICAL:
- c.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)
- }
- 0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(this._itemsMargin, 0, 0, 0));
- a.setLayoutParameter(c)
- }
- }
- }
- },
- pushBackDefaultItem: function() {
- if (this._model) {
- var a = this._model.clone();
- this._remedyLayoutParameter(a);
- this.addChild(a);
- this._refreshViewDirty = !0
- }
- },
- insertDefaultItem: function(a) {
- if (this._model) {
- var c = this._model.clone();
- this._items.splice(a, 0, c);
- ccui.ScrollView.prototype.addChild.call(this, c);
- this._remedyLayoutParameter(c);
- this._refreshViewDirty = !0
- }
- },
- pushBackCustomItem: function(a) {
- this._remedyLayoutParameter(a);
- this.addChild(a);
- this._refreshViewDirty = !0
- },
- addChild: function(a, c, d) {
- a && (c = c || a.getLocalZOrder(), d = d || a.getName(), ccui.ScrollView.prototype.addChild.call(this, a, c, d), a instanceof ccui.Widget && this._items.push(a))
- },
- removeChild: function(a, c) {
- if (a) {
- var d = this._items.indexOf(a); - 1 < d && this._items.splice(d, 1);
- ccui.ScrollView.prototype.removeChild.call(this, a, c)
- }
- },
- removeAllChildren: function() {
- this.removeAllChildrenWithCleanup(!0)
- },
- removeAllChildrenWithCleanup: function(a) {
- ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this, a);
- this._items = []
- },
- insertCustomItem: function(a, c) {
- this._items.splice(c, 0, a);
- ccui.ScrollView.prototype.addChild.call(this, a);
- this._remedyLayoutParameter(a);
- this._refreshViewDirty = !0
- },
- removeItem: function(a) {
- if (a = this.getItem(a)) this.removeChild(a, !0), this._refreshViewDirty = !0
- },
- removeLastItem: function() {
- this.removeItem(this._items.length - 1)
- },
- removeAllItems: function() {
- this.removeAllChildren()
- },
- getItem: function(a) {
- return 0 > a || a >= this._items.length ? null : this._items[a]
- },
- getItems: function() {
- return this._items
- },
- getIndex: function(a) {
- return this._items.indexOf(a)
- },
- setGravity: function(a) {
- this._gravity != a && (this._gravity = a, this._refreshViewDirty = !0)
- },
- setItemsMargin: function(a) {
- this._itemsMargin != a && (this._itemsMargin = a, this._refreshViewDirty = !0)
- },
- getItemsMargin: function() {
- return this._itemsMargin
- },
- setDirection: function(a) {
- switch (a) {
- case ccui.ScrollView.DIR_VERTICAL:
- this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);
- break;
- case ccui.ScrollView.DIR_HORIZONTAL:
- this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);
- break;
- case ccui.ScrollView.DIR_BOTH:
- return;
- default:
- return
- }
- ccui.ScrollView.prototype.setDirection.call(this, a)
- },
- requestRefreshView: function() {
- this._refreshViewDirty = !0
- },
- refreshView: function() {
- for (var a = this._items, c = 0; c < a.length; c++) {
- var d = a[c];
- d.setLocalZOrder(c);
- this._remedyLayoutParameter(d)
- }
- this._updateInnerContainerSize()
- },
- doLayout: function() {
- this._doLayout()
- },
- _doLayout: function() {
- ccui.Layout.prototype._doLayout.call(this);
- this._refreshViewDirty && (this.refreshView(), this._refreshViewDirty = !1)
- },
- addEventListenerListView: function(a, c) {
- this._listViewEventListener = c;
- this._listViewEventSelector = a
- },
- addEventListener: function(a) {
- this._eventCallback = a
- },
- _selectedItemEvent: function(a) {
- a = a == ccui.Widget.TOUCH_BEGAN ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END;
- this._listViewEventListener && this._listViewEventSelector && this._listViewEventSelector.call(this._listViewEventListener, this, a);
- this._eventCallback && this._eventCallback(this, a)
- },
- interceptTouchEvent: function(a, c, d) {
- ccui.ScrollView.prototype.interceptTouchEvent.call(this, a, c, d);
- if (a != ccui.Widget.TOUCH_MOVED) {
- for (d = c; d;) {
- if (d && d.getParent() == this._innerContainer) {
- this._curSelectedIndex = this.getIndex(d);
- break
- }
- d = d.getParent()
- }
- c.isHighlighted() && this._selectedItemEvent(a)
- }
- },
- getCurSelectedIndex: function() {
- return this._curSelectedIndex
- },
- _onSizeChanged: function() {
- ccui.ScrollView.prototype._onSizeChanged.call(this);
- this._refreshViewDirty = !0
- },
- getDescription: function() {
- return "ListView"
- },
- _createCloneInstance: function() {
- return ccui.ListView.create()
- },
- _copyClonedWidgetChildren: function(a) {
- a = a.getItems();
- for (var c = 0; c < a.length; c++) this.pushBackCustomItem(a[c].clone())
- },
- _copySpecialProperties: function(a) {
- a instanceof ccui.ListView && (ccui.ScrollView.prototype._copySpecialProperties.call(this, a), this.setItemModel(a._model), this.setItemsMargin(a._itemsMargin), this.setGravity(a._gravity), this._listViewEventListener = a._listViewEventListener, this._listViewEventSelector = a._listViewEventSelector, this._eventCallback = a._eventCallback)
- }
- });
- ccui.ListView.create = function() {
- return new ccui.ListView
- };
- ccui.ListView.EVENT_SELECTED_ITEM = 0;
- ccui.ListView.ON_SELECTED_ITEM_START = 0;
- ccui.ListView.ON_SELECTED_ITEM_END = 1;
- ccui.ListView.GRAVITY_LEFT = 0;
- ccui.ListView.GRAVITY_RIGHT = 1;
- ccui.ListView.GRAVITY_CENTER_HORIZONTAL = 2;
- ccui.ListView.GRAVITY_TOP = 3;
- ccui.ListView.GRAVITY_BOTTOM = 4;
- ccui.ListView.GRAVITY_CENTER_VERTICAL = 5;
- ccui.PageView = ccui.Layout.extend({
- _curPageIdx: 0,
- _pages: null,
- _touchMoveDirection: null,
- _touchStartLocation: 0,
- _touchMoveStartLocation: 0,
- _movePagePoint: null,
- _leftBoundaryChild: null,
- _rightBoundaryChild: null,
- _leftBoundary: 0,
- _rightBoundary: 0,
- _isAutoScrolling: !1,
- _autoScrollDistance: 0,
- _autoScrollSpeed: 0,
- _autoScrollDirection: 0,
- _childFocusCancelOffset: 0,
- _pageViewEventListener: null,
- _pageViewEventSelector: null,
- _className: "PageView",
- _eventCallback: null,
- ctor: function() {
- ccui.Layout.prototype.ctor.call(this);
- this._pages = [];
- this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT;
- this._rightBoundaryChild = this._leftBoundaryChild = this._movePagePoint = null;
- this._childFocusCancelOffset = 5;
- this._pageViewEventSelector = this._pageViewEventListener = null;
- this.setTouchEnabled(!0)
- },
- init: function() {
- return ccui.Layout.prototype.init.call(this) ? (this.setClippingEnabled(!0), !0) : !1
- },
- onEnter: function() {
- ccui.Layout.prototype.onEnter.call(this);
- this.scheduleUpdate(!0)
- },
- addWidgetToPage: function(a, c, d) {
- if (a && !(0 > c)) {
- var e = this._getPageCount();
- 0 > c || c >= e ? d && (c > e && cc.log("pageIdx is %d, it will be added as page id [%d]", c, e), c = this._createPage(), c.addChild(a), this.addPage(c)) : (c = this._pages[c]) && c.addChild(a)
- }
- },
- _createPage: function() {
- var a = ccui.Layout.create();
- a.setContentSize(this.getContentSize());
- return a
- },
- addPage: function(a) {
- a && -1 == this._pages.indexOf(a) && (this.addChild(a), this._pages.push(a), this._doLayoutDirty = !0)
- },
- insertPage: function(a, c) {
- if (!(0 > c || !a || -1 != this._pages.indexOf(a))) {
- var d = this._getPageCount();
- c >= d ? this.addPage(a) : (this._pages[c] = a, this.addChild(a));
- this._doLayoutDirty = !0
- }
- },
- removePage: function(a) {
- a && (this.removeChild(a), a = this._pages.indexOf(a), -1 < a && this._pages.splice(a, 1), this._doLayoutDirty = !0)
- },
- removePageAtIndex: function(a) {
- 0 > a || a >= this._pages.length || (a = this._pages[a]) && this.removePage(a)
- },
- removeAllPages: function() {
- for (var a = this._pages, c = 0, d = a.length; c < d; c++) this.removeChild(a[c]);
- this._pages.length = 0
- },
- _updateBoundaryPages: function() {
- var a = this._pages;
- 0 >= a.length ? this._rightBoundaryChild = this._leftBoundaryChild = null : (this._leftBoundaryChild = a[0], this._rightBoundaryChild = a[a.length - 1])
- },
- _getPageCount: function() {
- return this._pages.length
- },
- _getPositionXByIndex: function(a) {
- return this.getContentSize().width * (a - this._curPageIdx)
- },
- _onSizeChanged: function() {
- ccui.Layout.prototype._onSizeChanged.call(this);
- this._rightBoundary = this.getContentSize().width;
- this._doLayoutDirty = !0
- },
- _updateAllPagesSize: function() {
- for (var a = this.getContentSize(), c = this._pages, d = 0, e = c.length; d < e; d++) c[d].setContentSize(a)
- },
- _updateAllPagesPosition: function() {
- var a = this._getPageCount();
- if (0 >= a) this._curPageIdx = 0;
- else {
- this._curPageIdx >= a && (this._curPageIdx = a - 1);
- for (var c = this.getContentSize().width, d = this._pages, e = 0; e < a; e++) d[e].setPosition(cc.p((e - this._curPageIdx) * c, 0))
- }
- },
- scrollToPage: function(a) {
- 0 > a || a >= this._pages.length || (this._curPageIdx = a, this._autoScrollDistance = -this._pages[a].getPosition().x, this._autoScrollSpeed = Math.abs(this._autoScrollDistance) / 0.2, this._autoScrollDirection = 0 < this._autoScrollDistance ? ccui.PageView.DIRECTION_RIGHT : ccui.PageView.DIRECTION_LEFT, this._isAutoScrolling = !0)
- },
- update: function(a) {
- this._isAutoScrolling && this._autoScroll(a)
- },
- setLayoutType: function(a) {},
- getLayoutType: function() {
- return ccui.Layout.ABSOLUTE
- },
- _autoScroll: function(a) {
- switch (this._autoScrollDirection) {
- case ccui.PageView.DIRECTION_LEFT:
- a *= this._autoScrollSpeed;
- 0 <= this._autoScrollDistance + a ? (a = -this._autoScrollDistance, this._autoScrollDistance = 0, this._isAutoScrolling = !1) : this._autoScrollDistance += a;
- this._scrollPages(-a);
- this._isAutoScrolling || this._pageTurningEvent();
- break;
- case ccui.PageView.DIRECTION_RIGHT:
- a *= this._autoScrollSpeed, 0 >= this._autoScrollDistance - a ? (a = this._autoScrollDistance, this._autoScrollDistance = 0, this._isAutoScrolling = !1) : this._autoScrollDistance -= a, this._scrollPages(a), this._isAutoScrolling || this._pageTurningEvent()
- }
- },
- onTouchMoved: function(a, c) {
- this._handleMoveLogic(a);
- var d = this.getWidgetParent();
- d && d.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, a);
- this._moveEvent()
- },
- onTouchEnded: function(a, c) {
- ccui.Layout.prototype.onTouchEnded.call(this, a, c);
- this._handleReleaseLogic(a)
- },
- onTouchCancelled: function(a, c) {
- ccui.Layout.prototype.onTouchCancelled.call(this, a, c);
- this._handleReleaseLogic(a)
- },
- _doLayout: function() {
- this._doLayoutDirty && (this._updateAllPagesPosition(), this._updateAllPagesSize(), this._updateBoundaryPages(), this._doLayoutDirty = !1)
- },
- _movePages: function(a) {
- for (var c = this._pages, d = c.length, e = 0; e < d; e++) {
- var f = c[e];
- f.setPositionX(f.getPositionX() + a)
- }
- },
- _scrollPages: function(a) {
- if (0 >= this._pages.length || !this._leftBoundaryChild || !this._rightBoundaryChild) return !1;
- var c = a;
- switch (this._touchMoveDirection) {
- case ccui.PageView.TOUCH_DIR_LEFT:
- var d = this._rightBoundaryChild.getRightBoundary();
- if (d + a <= this._rightBoundary) return c = this._rightBoundary - d, this._movePages(c), !1;
- break;
- case ccui.PageView.TOUCH_DIR_RIGHT:
- if (d = this._leftBoundaryChild.getLeftBoundary(), d + a >= this._leftBoundary) return c = this._leftBoundary - d, this._movePages(c), !1
- }
- this._movePages(c);
- return !0
- },
- _handleMoveLogic: function(a) {
- a = a.getLocation().x - a.getPreviousLocation().x;
- 0 > a ? this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT : 0 < a && (this._touchMoveDirection = ccui.PageView.TOUCH_DIR_RIGHT);
- this._scrollPages(a)
- },
- _handleReleaseLogic: function(a) {
- if (!(0 >= this._pages.length) && (a = this._pages[this._curPageIdx])) {
- var c = a.getPosition();
- a = this._pages.length;
- var c = c.x,
- d = this.getSize().width / 2;
- c <= -d ? this._curPageIdx >= a - 1 ? this._scrollPages(-c) : this.scrollToPage(this._curPageIdx + 1) : c >= d ? 0 >= this._curPageIdx ? this._scrollPages(-c) : this.scrollToPage(this._curPageIdx - 1) : this.scrollToPage(this._curPageIdx)
- }
- },
- interceptTouchEvent: function(a, c, d) {
- var e = d.getLocation();
- switch (a) {
- case ccui.Widget.TOUCH_MOVED:
- a = 0;
- a = Math.abs(c.getTouchBeganPosition().x - e.x);
- a > this._childFocusCancelOffset && (c.setFocused(!1), this._handleMoveLogic(d));
- break;
- case ccui.Widget.TOUCH_ENDED:
- case ccui.Widget.TOUCH_CANCELED:
- this._handleReleaseLogic(d)
- }
- },
- _pageTurningEvent: function() {
- this._pageViewEventListener && this._pageViewEventSelector && this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING);
- this._eventCallback && this._eventCallback(this, ccui.PageView.EVENT_TURNING)
- },
- addEventListenerPageView: function(a, c) {
- this._pageViewEventSelector = a;
- this._pageViewEventListener = c
- },
- addEventListener: function(a) {
- this._eventCallback = a
- },
- getCurPageIndex: function() {
- return this._curPageIdx
- },
- getPages: function() {
- return this._pages
- },
- getPage: function(a) {
- return 0 > a || a >= this.getPages().size() ? null : this._pages[a]
- },
- getDescription: function() {
- return "PageView"
- },
- _createCloneInstance: function() {
- return ccui.PageView.create()
- },
- _copyClonedWidgetChildren: function(a) {
- a = a.getPages();
- for (var c = 0; c < a.length; c++) this.addPage(a[c].clone())
- },
- _copySpecialProperties: function(a) {
- ccui.Layout.prototype._copySpecialProperties.call(this, a);
- this._eventCallback = a._eventCallback;
- this._pageViewEventListener = a._pageViewEventListener;
- this._pageViewEventSelector = a._pageViewEventSelector
- }
- });
- ccui.PageView.create = function() {
- return new ccui.PageView
- };
- ccui.PageView.EVENT_TURNING = 0;
- ccui.PageView.TOUCH_DIR_LEFT = 0;
- ccui.PageView.TOUCH_DIR_RIGHT = 1;
- ccui.PageView.DIRECTION_LEFT = 0;
- ccui.PageView.DIRECTION_RIGHT = 1;
- cc.Component = cc.Class.extend({
- _owner: null,
- _name: "",
- _enabled: !0,
- ctor: function() {
- this._owner = null;
- this._name = "";
- this._enabled = !0
- },
- init: function() {
- return !0
- },
- onEnter: function() {},
- onExit: function() {},
- update: function(a) {},
- serialize: function(a) {},
- isEnabled: function() {
- return this._enabled
- },
- setEnabled: function(a) {
- this._enabled = a
- },
- getName: function() {
- return this._name
- },
- setName: function(a) {
- this._name = a
- },
- setOwner: function(a) {
- this._owner = a
- },
- getOwner: function() {
- return this._owner
- }
- });
- cc.Component.create = function() {
- return new cc.Component
- };
- cc.ComponentContainer = cc.Class.extend({
- _components: null,
- _owner: null,
- ctor: function(a) {
- this._components = null;
- this._owner = a
- },
- getComponent: function(a) {
- if (!a) throw "cc.ComponentContainer.getComponent(): name should be non-null";
- a = a.trim();
- return this._components[a]
- },
- add: function(a) {
- if (!a) throw "cc.ComponentContainer.add(): component should be non-null";
- if (a.getOwner()) return cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"), !1;
- null == this._components && (this._components = {}, this._owner.scheduleUpdate());
- if (this._components[a.getName()]) return cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"), !1;
- a.setOwner(this._owner);
- this._components[a.getName()] = a;
- a.onEnter();
- return !0
- },
- remove: function(a) {
- if (!a) throw "cc.ComponentContainer.remove(): name should be non-null";
- if (!this._components) return !1;
- if (a instanceof cc.Component) return this._removeByComponent(a);
- a = a.trim();
- return this._removeByComponent(this._components[a])
- },
- _removeByComponent: function(a) {
- if (a) return !1;
- a.onExit();
- a.setOwner(null);
- delete this._components[a.getName()];
- return !0
- },
- removeAll: function() {
- if (this._components) {
- var a = this._components,
- c;
- for (c in a) {
- var d = a[c];
- d.onExit();
- d.setOwner(null);
- delete a[c]
- }
- this._owner.unscheduleUpdate();
- this._components = null
- }
- },
- _alloc: function() {
- this._components = {}
- },
- visit: function(a) {
- if (this._components) {
- var c = this._components,
- d;
- for (d in c) c[d].update(a)
- }
- },
- isEmpty: function() {
- if (!this._components) return !0;
- for (var a in this._components) return !1;
- return !0
- }
- });
- var ccs = ccs || {};
- ccs.Class = ccs.Class || cc.Class;
- ccs.Class.extend = ccs.Class.extend || cc.Class.extend;
- ccs.Node = ccs.Node || cc.Node;
- ccs.Node.extend = ccs.Node.extend || cc.Node.extend;
- ccs.Sprite = ccs.Sprite || cc.Sprite;
- ccs.Sprite.extend = ccs.Sprite.extend || cc.Sprite.extend;
- ccs.Component = ccs.Component || cc.Component;
- ccs.Component.extend = ccs.Component.extend || cc.Component.extend;
- ccs.cocostudioVersion = "v1.3.0.0";
- ccs.VERSION_COMBINED = 0.3;
- ccs.VERSION_CHANGE_ROTATION_RANGE = 1;
- ccs.VERSION_COLOR_READING = 1.1;
- ccs.MAX_VERTEXZ_VALUE = 5E6;
- ccs.ARMATURE_MAX_CHILD = 50;
- ccs.ARMATURE_MAX_ZORDER = 100;
- ccs.ARMATURE_MAX_COUNT = ccs.MAX_VERTEXZ_VALUE / ccs.ARMATURE_MAX_CHILD / ccs.ARMATURE_MAX_ZORDER;
- ccs.AUTO_ADD_SPRITE_FRAME_NAME_PREFIX = !1;
- ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT = !1;
- ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX = !1;
- ccs.armatureVersion = function() {
- return "v1.1.0.0"
- };
- ccs.CONST_VERSION = "version";
- ccs.CONST_VERSION_2_0 = 2;
- ccs.CONST_VERSION_COMBINED = 0.3;
- ccs.CONST_ARMATURES = "armatures";
- ccs.CONST_ARMATURE = "armature";
- ccs.CONST_BONE = "b";
- ccs.CONST_DISPLAY = "d";
- ccs.CONST_ANIMATIONS = "animations";
- ccs.CONST_ANIMATION = "animation";
- ccs.CONST_MOVEMENT = "mov";
- ccs.CONST_FRAME = "f";
- ccs.CONST_TEXTURE_ATLAS = "TextureAtlas";
- ccs.CONST_SUB_TEXTURE = "SubTexture";
- ccs.CONST_SKELETON = "skeleton";
- ccs.CONST_A_NAME = "name";
- ccs.CONST_A_DURATION = "dr";
- ccs.CONST_A_FRAME_INDEX = "fi";
- ccs.CONST_A_DURATION_TO = "to";
- ccs.CONST_A_DURATION_TWEEN = "drTW";
- ccs.CONST_A_LOOP = "lp";
- ccs.CONST_A_MOVEMENT_SCALE = "sc";
- ccs.CONST_A_MOVEMENT_DELAY = "dl";
- ccs.CONST_A_DISPLAY_INDEX = "dI";
- ccs.CONST_A_PLIST = "plist";
- ccs.CONST_A_PARENT = "parent";
- ccs.CONST_A_SKEW_X = "kX";
- ccs.CONST_A_SKEW_Y = "kY";
- ccs.CONST_A_SCALE_X = "cX";
- ccs.CONST_A_SCALE_Y = "cY";
- ccs.CONST_A_Z = "z";
- ccs.CONST_A_EVENT = "evt";
- ccs.CONST_A_SOUND = "sd";
- ccs.CONST_A_SOUND_EFFECT = "sdE";
- ccs.CONST_A_TWEEN_EASING = "twE";
- ccs.CONST_A_EASING_PARAM = "twEP";
- ccs.CONST_A_TWEEN_ROTATE = "twR";
- ccs.CONST_A_IS_ARMATURE = "isArmature";
- ccs.CONST_A_DISPLAY_TYPE = "displayType";
- ccs.CONST_A_MOVEMENT = "mov";
- ccs.CONST_A_X = "x";
- ccs.CONST_A_Y = "y";
- ccs.CONST_A_COCOS2DX_X = "cocos2d_x";
- ccs.CONST_A_COCOS2DX_Y = "cocos2d_y";
- ccs.CONST_A_WIDTH = "width";
- ccs.CONST_A_HEIGHT = "height";
- ccs.CONST_A_PIVOT_X = "pX";
- ccs.CONST_A_PIVOT_Y = "pY";
- ccs.CONST_A_COCOS2D_PIVOT_X = "cocos2d_pX";
- ccs.CONST_A_COCOS2D_PIVOT_Y = "cocos2d_pY";
- ccs.CONST_A_BLEND_TYPE = "bd";
- ccs.CONST_A_BLEND_SRC = "bd_src";
- ccs.CONST_A_BLEND_DST = "bd_dst";
- ccs.CONST_A_ALPHA = "a";
- ccs.CONST_A_RED = "r";
- ccs.CONST_A_GREEN = "g";
- ccs.CONST_A_BLUE = "b";
- ccs.CONST_A_ALPHA_OFFSET = "aM";
- ccs.CONST_A_RED_OFFSET = "rM";
- ccs.CONST_A_GREEN_OFFSET = "gM";
- ccs.CONST_A_BLUE_OFFSET = "bM";
- ccs.CONST_A_COLOR_TRANSFORM = "colorTransform";
- ccs.CONST_A_TWEEN_FRAME = "tweenFrame";
- ccs.CONST_CONTOUR = "con";
- ccs.CONST_CONTOUR_VERTEX = "con_vt";
- ccs.CONST_FL_NAN = "NaN";
- ccs.CONST_FRAME_DATA = "frame_data";
- ccs.CONST_MOVEMENT_BONE_DATA = "mov_bone_data";
- ccs.CONST_MOVEMENT_DATA = "mov_data";
- ccs.CONST_ANIMATION_DATA = "animation_data";
- ccs.CONST_DISPLAY_DATA = "display_data";
- ccs.CONST_SKIN_DATA = "skin_data";
- ccs.CONST_BONE_DATA = "bone_data";
- ccs.CONST_ARMATURE_DATA = "armature_data";
- ccs.CONST_CONTOUR_DATA = "contour_data";
- ccs.CONST_TEXTURE_DATA = "texture_data";
- ccs.CONST_VERTEX_POINT = "vertex";
- ccs.CONST_COLOR_INFO = "color";
- ccs.CONST_CONFIG_FILE_PATH = "config_file_path";
- ccs.CONST_CONTENT_SCALE = "content_scale";
- ccs.DataInfo = function() {
- this.asyncStruct = null;
- this.configFileQueue = [];
- this.contentScale = 1;
- this.baseFilePath = this.filename = "";
- this.cocoStudioVersion = this.flashToolVersion = 0
- };
- ccs.dataReaderHelper = {
- ConfigType: {
- DragonBone_XML: 0,
- CocoStudio_JSON: 1,
- CocoStudio_Binary: 2
- },
- _configFileList: [],
- _flashToolVersion: ccs.CONST_VERSION_2_0,
- _positionReadScale: 1,
- _asyncRefCount: 0,
- _asyncRefTotalCount: 0,
- _dataQueue: null,
- setPositionReadScale: function(a) {
- this._positionReadScale = a
- },
- getPositionReadScale: function() {
- return this._positionReadScale
- },
- addDataFromFile: function(a) {
- if (-1 == this._configFileList.indexOf(a)) {
- this._configFileList.push(a);
- var c = this._initBaseFilePath(a),
- d = cc.path.extname(a).toLowerCase(),
- e = new ccs.DataInfo;
- e.filename = a;
- e.basefilePath = c;
- ".xml" == d ? ccs.dataReaderHelper.addDataFromXML(a, e) : ".json" == d || ".exportjson" == d ? ccs.dataReaderHelper.addDataFromJson(a, e) : ".csb" == d && ccs.dataReaderHelper.addDataFromBinaryCache(a, e)
- }
- },
- addDataFromFileAsync: function(a, c, d, e, f) {
- if (-1 != this._configFileList.indexOf(d)) f && e && (0 == this._asyncRefTotalCount && 0 == this._asyncRefCount ? this._asyncCallBack(e, f, 1) : this._asyncCallBack(e, f, (this._asyncRefTotalCount - this._asyncRefCount) / this._asyncRefTotalCount));
- else {
- this._asyncRefTotalCount++;
- this._asyncRefCount++;
- var g = this;
- cc.director.getScheduler().scheduleCallbackForTarget(this, function() {
- g.addDataFromFile(d);
- g._asyncRefCount--;
- g._asyncCallBack(e, f, (g._asyncRefTotalCount - g._asyncRefCount) / g._asyncRefTotalCount)
- }, 0.1, !1)
- }
- },
- removeConfigFile: function(a) {
- for (var c = this._configFileList, d = c.length, e = c[d], f = 0; f < d; f++) c[f] == a && (e = f);
- e != c[d] && cc.arrayRemoveObject(c, a)
- },
- addDataFromCache: function(a, c) {
- if (a) {
- c.flashToolVersion = parseFloat(a.getAttribute(ccs.CONST_VERSION));
- var d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_ARMATURES + " \x3e " + ccs.CONST_ARMATURE + ""),
- e = ccs.armatureDataManager,
- f;
- for (f = 0; f < d.length; f++) {
- var g = this.decodeArmature(d[f], c);
- e.addArmatureData(g.name, g, c.filename)
- }
- d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_ANIMATIONS + " \x3e " + ccs.CONST_ANIMATION + "");
- for (f = 0; f < d.length; f++) g = this.decodeAnimation(d[f], c), e.addAnimationData(g.name, g, c.filename);
- d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_TEXTURE_ATLAS + " \x3e " + ccs.CONST_SUB_TEXTURE + "");
- for (f = 0; f < d.length; f++) g = this.decodeTexture(d[f], c), e.addTextureData(g.name, g, c.filename)
- } else cc.log("XML error or XML is empty.")
- },
- decodeArmature: function(a, c) {
- var d = new ccs.ArmatureData;
- d.init();
- d.name = a.getAttribute(ccs.CONST_A_NAME);
- for (var e = a.querySelectorAll(ccs.CONST_ARMATURE + " \x3e " + ccs.CONST_BONE), f = 0; f < e.length; f++) {
- var g = e[f],
- h = g.getAttribute(ccs.CONST_A_PARENT),
- k = null;
- if (h)
- for (var m = 0; m < e.length && !(k = e[m], h == e[m].getAttribute(ccs.CONST_A_NAME)); m++);
- g = this.decodeBone(g, k, c);
- d.addBoneData(g)
- }
- return d
- },
- decodeArmatureFromJSON: function(a, c) {
- var d = new ccs.ArmatureData;
- d.init();
- var e = a[ccs.CONST_A_NAME];
- e && (d.name = e);
- c.cocoStudioVersion = d.dataVersion = a[ccs.CONST_VERSION] || 0.1;
- for (var e = a[ccs.CONST_BONE_DATA], f = 0; f < e.length; f++) {
- var g = this.decodeBoneFromJson(e[f], c);
- d.addBoneData(g)
- }
- return d
- },
- decodeBone: function(a, c, d) {
- c = new ccs.BoneData;
- c.init();
- c.name = a.getAttribute(ccs.CONST_A_NAME);
- c.parentName = a.getAttribute(ccs.CONST_A_PARENT) || "";
- c.zOrder = parseInt(a.getAttribute(ccs.CONST_A_Z)) || 0;
- a = a.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_DISPLAY);
- for (var e = 0; e < a.length; e++) {
- var f = this.decodeBoneDisplay(a[e], d);
- c.addDisplayData(f)
- }
- return c
- },
- decodeBoneFromJson: function(a, c) {
- var d = new ccs.BoneData;
- d.init();
- this.decodeNodeFromJson(d, a, c);
- d.name = a[ccs.CONST_A_NAME] || "";
- d.parentName = a[ccs.CONST_A_PARENT] || "";
- for (var e = a[ccs.CONST_DISPLAY_DATA] || [], f = 0; f < e.length; f++) {
- var g = this.decodeBoneDisplayFromJson(e[f], c);
- d.addDisplayData(g)
- }
- return d
- },
- decodeBoneDisplay: function(a, c) {
- var d = null;
- 1 == (parseFloat(a.getAttribute(ccs.CONST_A_IS_ARMATURE)) || 0) ? (d = new ccs.ArmatureDisplayData, d.displayType = ccs.DISPLAY_TYPE_ARMATURE) : (d = new ccs.SpriteDisplayData, d.displayType = ccs.DISPLAY_TYPE_SPRITE);
- var e = a.getAttribute(ccs.CONST_A_NAME) || "";
- e && (d.displayName = e);
- return d
- },
- decodeBoneDisplayFromJson: function(a, c) {
- var d = a[ccs.CONST_A_DISPLAY_TYPE] || ccs.DISPLAY_TYPE_SPRITE,
- e = null;
- switch (d) {
- case ccs.DISPLAY_TYPE_SPRITE:
- var e = new ccs.SpriteDisplayData,
- f = a[ccs.CONST_A_NAME];
- null != f && (e.displayName = f);
- if (f = (a[ccs.CONST_SKIN_DATA] || [])[0]) {
- var g = e.skinData;
- g.x = f[ccs.CONST_A_X] * this._positionReadScale;
- g.y = f[ccs.CONST_A_Y] * this._positionReadScale;
- g.scaleX = null == f[ccs.CONST_A_SCALE_X] ? 1 : f[ccs.CONST_A_SCALE_X];
- g.scaleY = null == f[ccs.CONST_A_SCALE_Y] ? 1 : f[ccs.CONST_A_SCALE_Y];
- g.skewX = null == f[ccs.CONST_A_SKEW_X] ? 1 : f[ccs.CONST_A_SKEW_X];
- g.skewY = null == f[ccs.CONST_A_SKEW_Y] ? 1 : f[ccs.CONST_A_SKEW_Y];
- g.x *= c.contentScale;
- g.y *= c.contentScale
- }
- break;
- case ccs.DISPLAY_TYPE_ARMATURE:
- e = new ccs.ArmatureDisplayData;
- f = a[ccs.CONST_A_NAME];
- null != f && (e.displayName = a[ccs.CONST_A_NAME]);
- break;
- case ccs.DISPLAY_TYPE_PARTICLE:
- e = new ccs.ParticleDisplayData;
- f = a[ccs.CONST_A_PLIST];
- null != f && (e.displayName = c.asyncStruct ? c.asyncStruct.basefilePath + f : c.basefilePath + f);
- break;
- default:
- e = new ccs.SpriteDisplayData
- }
- e.displayType = d;
- return e
- },
- decodeAnimation: function(a, c) {
- var d = new ccs.AnimationData,
- e = a.getAttribute(ccs.CONST_A_NAME),
- f = ccs.armatureDataManager.getArmatureData(e);
- d.name = e;
- for (var e = a.querySelectorAll(ccs.CONST_ANIMATION + " \x3e " + ccs.CONST_MOVEMENT), g = null, h = 0; h < e.length; h++) g = e[h], g = this.decodeMovement(g, f, c), d.addMovement(g);
- return d
- },
- decodeAnimationFromJson: function(a, c) {
- var d = new ccs.AnimationData;
- a[ccs.CONST_A_NAME] && (d.name = a[ccs.CONST_A_NAME]);
- for (var e = a[ccs.CONST_MOVEMENT_DATA] || [], f = 0; f < e.length; f++) {
- var g = this.decodeMovementFromJson(e[f], c);
- d.addMovement(g)
- }
- return d
- },
- decodeMovement: function(a, c, d) {
- var e = new ccs.MovementData;
- e.name = a.getAttribute(ccs.CONST_A_NAME);
- var f;
- f = 0;
- f = a.getAttribute(ccs.CONST_A_DURATION);
- e.duration = null == f ? 0 : parseFloat(f);
- f = a.getAttribute(ccs.CONST_A_DURATION_TO);
- e.durationTo = null == f ? 0 : parseFloat(f);
- f = a.getAttribute(ccs.CONST_A_DURATION_TWEEN);
- e.durationTween = null == f ? 0 : parseFloat(f);
- f = a.getAttribute(ccs.CONST_A_LOOP);
- e.loop = f ? Boolean(parseFloat(f)) : !0;
- if (f = a.getAttribute(ccs.CONST_A_TWEEN_EASING)) f != ccs.CONST_FL_NAN ? (f = null == f ? 0 : parseFloat(f), e.tweenEasing = 2 == f ? ccs.TweenType.sineEaseInOut : f) : e.tweenEasing = ccs.TweenType.linear;
- a = a.querySelectorAll(ccs.CONST_MOVEMENT + " \x3e " + ccs.CONST_BONE);
- var g = null;
- for (f = 0; f < a.length; f++) {
- var g = a[f],
- h = g.getAttribute(ccs.CONST_A_NAME);
- if (!e.getMovementBoneData(h)) {
- var h = c.getBoneData(h),
- k = h.parentName,
- m = null;
- if ("" != k)
- for (var n = 0; n < a.length && !(m = a[n], k == m.getAttribute(ccs.CONST_A_NAME)); n++);
- g = this.decodeMovementBone(g, m, h, d);
- e.addMovementBoneData(g)
- }
- }
- return e
- },
- decodeMovementFromJson: function(a, c) {
- var d = new ccs.MovementData;
- d.loop = null == a[ccs.CONST_A_LOOP] ? !1 : a[ccs.CONST_A_LOOP];
- d.durationTween = a[ccs.CONST_A_DURATION_TWEEN] || 0;
- d.durationTo = a[ccs.CONST_A_DURATION_TO] || 0;
- d.duration = a[ccs.CONST_A_DURATION] || 0;
- d.scale = null == a[ccs.CONST_A_DURATION] ? 1 : null == a[ccs.CONST_A_MOVEMENT_SCALE] ? 1 : a[ccs.CONST_A_MOVEMENT_SCALE];
- d.tweenEasing = null == a[ccs.CONST_A_TWEEN_EASING] ? ccs.TweenType.linear : a[ccs.CONST_A_TWEEN_EASING];
- var e = a[ccs.CONST_A_NAME];
- e && (d.name = e);
- for (var e = a[ccs.CONST_MOVEMENT_BONE_DATA] || [], f = 0; f < e.length; f++) {
- var g = this.decodeMovementBoneFromJson(e[f], c);
- d.addMovementBoneData(g)
- }
- return d
- },
- decodeMovementBone: function(a, c, d, e) {
- var f = new ccs.MovementBoneData;
- f.init();
- var g;
- a && (g = parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_SCALE)) || 0, f.scale = g, g = parseFloat(a.getAttribute(ccs.CONST_A_MOVEMENT_DELAY)) || 0, 0 < g && (g -= 1), f.delay = g);
- var h = 0,
- k = g = 0,
- m = null,
- n = [];
- if (null != c) {
- for (var q = c.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_FRAME), h = 0; h < q.length; h++) n.push(q[h]);
- h = n.length
- }
- f.name = a.getAttribute(ccs.CONST_A_NAME);
- a = a.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_FRAME);
- for (var r = q = 0, t = 0; t < a.length; t++) {
- var s = a[t];
- if (c)
- for (; q < h && (m ? r < g || r >= g + k : 1);) m = n[q], g += k, k = parseFloat(m.getAttribute(ccs.CONST_A_DURATION)), q++;
- s = this.decodeFrame(s, m, d, e);
- f.addFrameData(s);
- s.frameID = r;
- r += s.duration;
- f.duration = r
- }
- c = f.frameList;
- d = Math.PI;
- for (h = c.length - 1; 0 <= h; h--)
- if (0 < h) {
- e = c[h].skewX - c[h - 1].skewX;
- g = c[h].skewY - c[h - 1].skewY;
- if (e < -d || e > d) c[h - 1].skewX = 0 > e ? c[h - 1].skewX - 2 * d : c[h - 1].skewX + 2 * d;
- if (g < -d || g > d) c[h - 1].skewY = 0 > g ? c[h - 1].skewY - 2 * d : c[h - 1].skewY + 2 * d
- }
- c = new ccs.FrameData;
- c.copy(f.frameList[f.frameList.length - 1]);
- c.frameID = f.duration;
- f.addFrameData(c);
- return f
- },
- decodeMovementBoneFromJson: function(a, c) {
- var d = new ccs.MovementBoneData;
- d.init();
- d.delay = a[ccs.CONST_A_MOVEMENT_DELAY] || 0;
- var e = a[ccs.CONST_A_NAME];
- e && (d.name = e);
- for (var f = (a[ccs.CONST_FRAME_DATA] || []).length, e = 0; e < f; e++) {
- var g = this.decodeFrameFromJson(a[ccs.CONST_FRAME_DATA][e], c);
- d.addFrameData(g);
- c.cocoStudioVersion < ccs.CONST_VERSION_COMBINED && (g.frameID = d.duration, d.duration += g.duration)
- }
- if (c.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) {
- f = d.frameList;
- g = Math.PI;
- for (e = f.length - 1; 0 <= e; e--)
- if (0 < e) {
- var h = f[e].skewX - f[e - 1].skewX,
- k = f[e].skewY - f[e - 1].skewY;
- if (h < -g || h > g) f[e - 1].skewX = 0 > h ? f[e - 1].skewX - 2 * g : f[e - 1].skewX + 2 * g;
- if (k < -g || k > g) f[e - 1].skewY = 0 > k ? f[e - 1].skewY - 2 * g : f[e - 1].skewY + 2 * g
- }
- }
- c.cocoStudioVersion < ccs.CONST_VERSION_COMBINED && 0 < d.frameList.length && (g = new ccs.FrameData, g.copy(d.frameList[d.frameList.length - 1]), d.addFrameData(g), g.frameID = d.duration);
- return d
- },
- decodeFrame: function(a, c, d, e) {
- var f = 0,
- f = f = f = f = f = f = f = f = f = f = f = 0;
- d = new ccs.FrameData;
- d.strMovement = a.getAttribute(ccs.CONST_A_MOVEMENT) || "";
- d.movement = d.strMovement;
- d.strEvent = a.getAttribute(ccs.CONST_A_EVENT) || "";
- d.event = d.strEvent;
- d.strSound = a.getAttribute(ccs.CONST_A_SOUND) || "";
- d.sound = d.strSound;
- d.strSoundEffect = a.getAttribute(ccs.CONST_A_SOUND_EFFECT) || "";
- d.soundEffect = d.strSoundEffect;
- f = a.getAttribute(ccs.CONST_A_TWEEN_FRAME);
- d.isTween = void 0 == f ? !0 : Boolean(f);
- if (e.flashToolVersion >= ccs.CONST_VERSION_2_0) {
- if (f = a.getAttribute(ccs.CONST_A_COCOS2DX_X)) d.x = parseFloat(f), d.x *= this._positionReadScale;
- f = a.getAttribute(ccs.CONST_A_COCOS2DX_Y)
- } else {
- if (f = a.getAttribute(ccs.CONST_A_X)) d.x = parseFloat(f), d.x *= this._positionReadScale;
- f = a.getAttribute(ccs.CONST_A_Y)
- }
- f && (d.y = -parseFloat(f), d.y *= this._positionReadScale);
- f = a.getAttribute(ccs.CONST_A_SCALE_X);
- null != f && (d.scaleX = parseFloat(f));
- f = a.getAttribute(ccs.CONST_A_SCALE_Y);
- null != f && (d.scaleY = parseFloat(f));
- f = a.getAttribute(ccs.CONST_A_SKEW_X);
- null != f && (d.skewX = cc.degreesToRadians(parseFloat(f)));
- f = a.getAttribute(ccs.CONST_A_SKEW_Y);
- null != f && (d.skewY = cc.degreesToRadians(-parseFloat(f)));
- f = a.getAttribute(ccs.CONST_A_DURATION);
- null != f && (d.duration = parseFloat(f));
- f = a.getAttribute(ccs.CONST_A_DISPLAY_INDEX);
- null != f && (d.displayIndex = parseFloat(f));
- f = a.getAttribute(ccs.CONST_A_Z);
- null != f && (d.zOrder = parseInt(f));
- f = a.getAttribute(ccs.CONST_A_TWEEN_ROTATE);
- null != f && (d.tweenRotate = parseFloat(f));
- f = a.getAttribute(ccs.CONST_A_BLEND_TYPE);
- if (null != f) {
- var g = d.blendFunc;
- switch (f) {
- case ccs.BLEND_TYPE_NORMAL:
- g.src = cc.BLEND_SRC;
- g.dst = cc.BLEND_DST;
- break;
- case ccs.BLEND_TYPE_ADD:
- g.src = cc.SRC_ALPHA;
- g.dst = cc.ONE;
- break;
- case ccs.BLEND_TYPE_MULTIPLY:
- g.src = cc.DST_COLOR;
- g.dst = cc.ONE_MINUS_SRC_ALPHA;
- break;
- case ccs.BLEND_TYPE_SCREEN:
- g.src = cc.ONE;
- g.dst = cc.ONE_MINUS_DST_COLOR;
- break;
- default:
- d.blendFunc.src = cc.BLEND_SRC, d.blendFunc.dst = cc.BLEND_DST
- }
- }
- var h = a.querySelectorAll(ccs.CONST_FRAME + " \x3e " + ccs.CONST_A_COLOR_TRANSFORM);
- if (h && 0 < h.length) {
- var h = h[0],
- k, m, n, q, r, f = h.getAttribute(ccs.CONST_A_ALPHA) || 0,
- g = h.getAttribute(ccs.CONST_A_RED) || 0;
- k = h.getAttribute(ccs.CONST_A_GREEN) || 0;
- m = h.getAttribute(ccs.CONST_A_BLUE) || 0;
- n = h.getAttribute(ccs.CONST_A_ALPHA_OFFSET) || 0;
- q = h.getAttribute(ccs.CONST_A_RED_OFFSET) || 0;
- r = h.getAttribute(ccs.CONST_A_GREEN_OFFSET) || 0;
- h = h.getAttribute(ccs.CONST_A_BLUE_OFFSET) || 0;
- d.a = 2.55 * n + f;
- d.r = 2.55 * q + g;
- d.g = 2.55 * r + k;
- d.b = 2.55 * h + m;
- d.isUseColorInfo = !0
- }
- f = a.getAttribute(ccs.CONST_A_TWEEN_EASING);
- null != f && (f != ccs.CONST_FL_NAN ? (f = a.getAttribute(ccs.CONST_A_TWEEN_EASING)) && (d.tweenEasing = 2 == f ? ccs.TweenType.sineEaseInOut : f) : d.tweenEasing = ccs.TweenType.linear);
- c && (a = new ccs.BaseData, e.flashToolVersion >= ccs.CONST_VERSION_2_0 ? (a.x = parseFloat(c.getAttribute(ccs.CONST_A_COCOS2DX_X)), a.y = parseFloat(c.getAttribute(ccs.CONST_A_COCOS2DX_Y))) : (a.x = parseFloat(c.getAttribute(ccs.CONST_A_X)), a.y = parseFloat(c.getAttribute(ccs.CONST_A_Y))), a.skewX = parseFloat(c.getAttribute(ccs.CONST_A_SKEW_X)), a.skewY = parseFloat(c.getAttribute(ccs.CONST_A_SKEW_Y)), a.y = -a.y, a.skewX = cc.degreesToRadians(a.skewX), a.skewY = cc.degreesToRadians(-a.skewY), ccs.TransformHelp.transformFromParent(d, a));
- return d
- },
- decodeFrameFromJson: function(a, c) {
- var d = new ccs.FrameData;
- this.decodeNodeFromJson(d, a, c);
- d.tweenEasing = a[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear;
- d.displayIndex = a[ccs.CONST_A_DISPLAY_INDEX];
- var e = null == a[ccs.CONST_A_BLEND_DST] ? cc.BLEND_DST : a[ccs.CONST_A_BLEND_DST];
- d.blendFunc.src = null == a[ccs.CONST_A_BLEND_SRC] ? cc.BLEND_SRC : a[ccs.CONST_A_BLEND_SRC];
- d.blendFunc.dst = e;
- d.isTween = null == a[ccs.CONST_A_TWEEN_FRAME] ? !0 : a[ccs.CONST_A_TWEEN_FRAME];
- e = a[ccs.CONST_A_EVENT];
- null != e && (d.strEvent = e, d.event = e);
- c.cocoStudioVersion < ccs.CONST_VERSION_COMBINED ? d.duration = null == a[ccs.CONST_A_DURATION] ? 1 : a[ccs.CONST_A_DURATION] : d.frameID = a[ccs.CONST_A_FRAME_INDEX];
- for (var e = a[ccs.CONST_A_EASING_PARAM] || [], f = 0; f < e.length; f++) d.easingParams[f] = e[f];
- return d
- },
- decodeTexture: function(a, c) {
- var d = new ccs.TextureData;
- d.init();
- a.getAttribute(ccs.CONST_A_NAME) && (d.name = a.getAttribute(ccs.CONST_A_NAME));
- var e, f;
- c.flashToolVersion >= ccs.CONST_VERSION_2_0 ? (e = parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_X)) || 0, f = parseFloat(a.getAttribute(ccs.CONST_A_COCOS2D_PIVOT_Y)) || 0) : (e = parseFloat(a.getAttribute(ccs.CONST_A_PIVOT_X)) || 0, f = parseFloat(a.getAttribute(ccs.CONST_A_PIVOT_Y)) || 0);
- var g = parseFloat(a.getAttribute(ccs.CONST_A_WIDTH)) || 0,
- h = parseFloat(a.getAttribute(ccs.CONST_A_HEIGHT)) || 0;
- d.pivotX = e / g;
- d.pivotY = (h - f) / h;
- e = a.querySelectorAll(ccs.CONST_SUB_TEXTURE + " \x3e " + ccs.CONST_CONTOUR);
- for (f = 0; f < e.length; f++) d.addContourData(this.decodeContour(e[f], c));
- return d
- },
- decodeTextureFromJson: function(a) {
- var c = new ccs.TextureData;
- c.init();
- var d = a[ccs.CONST_A_NAME];
- null != d && (c.name = d);
- c.width = a[ccs.CONST_A_WIDTH] || 0;
- c.height = a[ccs.CONST_A_HEIGHT] || 0;
- c.pivotX = a[ccs.CONST_A_PIVOT_X] || 0;
- c.pivotY = a[ccs.CONST_A_PIVOT_Y] || 0;
- a = a[ccs.CONST_CONTOUR_DATA] || [];
- for (d = 0; d < a.length; d++) c.contourDataList.push(this.decodeContourFromJson(a[d]));
- return c
- },
- decodeContour: function(a, c) {
- var d = new ccs.ContourData;
- d.init();
- for (var e = a.querySelectorAll(ccs.CONST_CONTOUR + " \x3e " + ccs.CONST_CONTOUR_VERTEX), f, g = 0; g < e.length; g++) {
- f = e[g];
- var h = cc.p(0, 0);
- h.x = parseFloat(f.getAttribute(ccs.CONST_A_X)) || 0;
- h.y = parseFloat(f.getAttribute(ccs.CONST_A_Y)) || 0;
- h.y = -h.y;
- d.vertexList.push(h)
- }
- return d
- },
- decodeContourFromJson: function(a) {
- var c = new ccs.ContourData;
- c.init();
- a = a[ccs.CONST_VERTEX_POINT] || [];
- for (var d = a.length, e = 0; e < d; e++) {
- var f = a[e],
- g = cc.p(0, 0);
- g.x = f[ccs.CONST_A_X] || 0;
- g.y = f[ccs.CONST_A_Y] || 0;
- c.vertexList.push(g)
- }
- return c
- },
- addDataFromJsonCache: function(a, c) {
- c.contentScale = null == a[ccs.CONST_CONTENT_SCALE] ? 1 : a[ccs.CONST_CONTENT_SCALE];
- var d = a[ccs.CONST_ARMATURE_DATA] || [],
- e, f;
- for (e = 0; e < d.length; e++) f = this.decodeArmatureFromJSON(d[e], c), ccs.armatureDataManager.addArmatureData(f.name, f, c.filename);
- d = a[ccs.CONST_ANIMATION_DATA] || [];
- for (e = 0; e < d.length; e++) f = this.decodeAnimationFromJson(d[e], c), ccs.armatureDataManager.addAnimationData(f.name, f, c.filename);
- d = a[ccs.CONST_TEXTURE_DATA] || [];
- for (e = 0; e < d.length; e++) f = this.decodeTextureFromJson(d[e], c), ccs.armatureDataManager.addTextureData(f.name, f, c.filename);
- if (null == c.asyncStruct ? ccs.armatureDataManager.isAutoLoadSpriteFile() : c.asyncStruct.autoLoadSpriteFile) {
- var d = a[ccs.CONST_CONFIG_FILE_PATH] || [],
- g;
- for (e = 0; e < d.length; e++) f = d[e], g = f.lastIndexOf("."), f = f.substring(0, g), g = c.basefilePath + f + ".plist", f = c.basefilePath + f + ".png", ccs.armatureDataManager.addSpriteFrameFromFile(g, f, c.filename)
- }
- },
- decodeNodeFromJson: function(a, c, d) {
- a.x = c[ccs.CONST_A_X] * this._positionReadScale;
- a.y = c[ccs.CONST_A_Y] * this._positionReadScale;
- a.x *= d.contentScale;
- a.y *= d.contentScale;
- a.zOrder = c[ccs.CONST_A_Z];
- a.skewX = c[ccs.CONST_A_SKEW_X] || 0;
- a.skewY = c[ccs.CONST_A_SKEW_Y] || 0;
- a.scaleX = null == c[ccs.CONST_A_SCALE_X] ? 1 : c[ccs.CONST_A_SCALE_X];
- a.scaleY = null == c[ccs.CONST_A_SCALE_Y] ? 1 : c[ccs.CONST_A_SCALE_Y];
- if (c = d.cocoStudioVersion < ccs.VERSION_COLOR_READING ? c[0] : c[ccs.CONST_COLOR_INFO] || null) a.a = null == c[ccs.CONST_A_ALPHA] ? 255 : c[ccs.CONST_A_ALPHA], a.r = null == c[ccs.CONST_A_RED] ? 255 : c[ccs.CONST_A_RED], a.g = null == c[ccs.CONST_A_GREEN] ? 255 : c[ccs.CONST_A_GREEN], a.b = null == c[ccs.CONST_A_BLUE] ? 255 : c[ccs.CONST_A_BLUE], a.isUseColorInfo = !0
- },
- clear: function() {
- this._configFileList = [];
- this._asyncRefTotalCount = this._asyncRefCount = 0
- },
- _asyncCallBack: function(a, c, d) {
- a && "function" === typeof a && a.call(c, d);
- if (c && a && "string" === typeof a) c[a](d)
- },
- _initBaseFilePath: function(a) {
- var c = a.lastIndexOf("/");
- return a = -1 < c ? a.substr(0, c + 1) : ""
- },
- addDataFromXML: function(a, c) {
- var d = cc.loader.getRes(a);
- if (!d) throw "Please load the resource first : " + a;
- (d = cc.saxParser.parse(d).documentElement) && this.addDataFromCache(d, c)
- },
- addDataFromJson: function(a, c) {
- var d = cc.loader.getRes(a);
- this.addDataFromJsonCache(d, c)
- }
- };
- ccs.spriteFrameCacheHelper = {
- _textureAtlasDic: {},
- _imagePaths: [],
- addSpriteFrameFromFile: function(a, c) {
- cc.spriteFrameCache.addSpriteFrames(a, c)
- },
- getTexureAtlasWithTexture: function(a) {
- return null
- },
- clear: function() {
- this._textureAtlasDic = {};
- this._imagePaths = []
- }
- };
- ccs.TransformHelp = ccs.TransformHelp || ccs.Class.extend({});
- ccs.TransformHelp.helpMatrix1 = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
- ccs.TransformHelp.helpMatrix2 = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
- ccs.TransformHelp.helpPoint1 = cc.p(0, 0);
- ccs.TransformHelp.helpPoint2 = cc.p(0, 0);
- ccs.TransformHelp.helpParentNode = {};
- ccs.TransformHelp.transformFromParent = function(a, c) {
- this.nodeToMatrix(a, this.helpMatrix1);
- this.nodeToMatrix(c, this.helpMatrix2);
- this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2);
- this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
- this.matrixToNode(this.helpMatrix1, a)
- };
- ccs.TransformHelp.transformToParent = function(a, c) {
- this.nodeToMatrix(a, this.helpMatrix1);
- this.nodeToMatrix(c, this.helpMatrix2);
- this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
- this.matrixToNode(this.helpMatrix1, a)
- };
- ccs.TransformHelp.transformFromParentWithoutScale = function(a, c) {
- for (var d in c) this.helpParentNode[d] = c[d];
- this.helpParentNode.scaleX = 1;
- this.helpParentNode.scaleY = 1;
- this.nodeToMatrix(a, this.helpMatrix1);
- this.nodeToMatrix(this.helpParentNode, this.helpMatrix2);
- this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2);
- this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
- this.matrixToNode(this.helpMatrix1, a)
- };
- ccs.TransformHelp.transformToParentWithoutScale = function(a, c) {
- for (var d in c) this.helpParentNode[d] = c[d];
- this.helpParentNode.scaleX = 1;
- this.helpParentNode.scaleY = 1;
- this.nodeToMatrix(a, this.helpMatrix1);
- this.nodeToMatrix(this.helpParentNode, this.helpMatrix2);
- this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
- this.matrixToNode(this.helpMatrix1, a)
- };
- ccs.TransformHelp.nodeToMatrix = function(a, c) {
- if (a.skewX == -a.skewY) {
- var d = Math.sin(a.skewX),
- e = Math.cos(a.skewX);
- c.a = a.scaleX * e;
- c.b = a.scaleX * -d;
- c.c = a.scaleY * d;
- c.d = a.scaleY * e
- } else c.a = a.scaleX * Math.cos(a.skewY), c.b = a.scaleX * Math.sin(a.skewY), c.c = a.scaleY * Math.sin(a.skewX), c.d = a.scaleY * Math.cos(a.skewX);
- c.tx = a.x;
- c.ty = a.y
- };
- ccs.TransformHelp.matrixToNode = function(a, c) {
- this.helpPoint1.x = 0;
- this.helpPoint1.y = 1;
- this.helpPoint1 = cc.pointApplyAffineTransform(this.helpPoint1, a);
- this.helpPoint1.x -= a.tx;
- this.helpPoint1.y -= a.ty;
- this.helpPoint2.x = 1;
- this.helpPoint2.y = 0;
- this.helpPoint2 = cc.pointApplyAffineTransform(this.helpPoint2, a);
- this.helpPoint2.x -= a.tx;
- this.helpPoint2.y -= a.ty;
- c.skewX = -(Math.atan2(this.helpPoint1.y, this.helpPoint1.x) - 1.5707964);
- c.skewY = Math.atan2(this.helpPoint2.y, this.helpPoint2.x);
- c.scaleX = Math.sqrt(a.a * a.a + a.b * a.b);
- c.scaleY = Math.sqrt(a.c * a.c + a.d * a.d);
- c.x = a.tx;
- c.y = a.ty
- };
- ccs.TransformHelp.nodeConcat = function(a, c) {
- a.x += c.x;
- a.y += c.y;
- a.skewX += c.skewX;
- a.skewY += c.skewY;
- a.scaleX += c.scaleX;
- a.scaleY += c.scaleY
- };
- ccs.TransformHelp.nodeSub = function(a, c) {
- a.x -= c.x;
- a.y -= c.y;
- a.skewX -= c.skewX;
- a.skewY -= c.skewY;
- a.scaleX -= c.scaleX;
- a.scaleY -= c.scaleY
- };
- ccs.TweenType = {
- customEasing: -1,
- linear: 0,
- sineEaseIn: 1,
- sineEaseOut: 2,
- sineEaseInOut: 3,
- quadEaseIn: 4,
- quadEaseOut: 5,
- quadEaseInOut: 6,
- cubicEaseIn: 7,
- cubicEaseOut: 8,
- cubicEaseInOut: 9,
- quartEaseIn: 10,
- quartEaseOut: 11,
- quartEaseInOut: 12,
- quintEaseIn: 13,
- quintEaseOut: 14,
- quintEaseInOut: 15,
- expoEaseIn: 16,
- expoEaseOut: 17,
- expoEaseInOut: 18,
- circEaseIn: 19,
- eircEaseOut: 20,
- circEaseInOut: 21,
- elasticEaseIn: 22,
- elasticEaseOut: 23,
- elasticEaseInOut: 24,
- backEaseIn: 25,
- backEaseOut: 26,
- backEaseInOut: 27,
- bounceEaseIn: 28,
- bounceEaseOut: 29,
- bounceEaseInOut: 30,
- tweenEasingMax: 1E4
- };
- ccs.TweenFunction = ccs.TweenFunction || ccs.Class.extend({});
- ccs.DOUBLE_PI = ccs.M_PI_X_2 = 2 * Math.PI;
- ccs.HALF_PI = ccs.M_PI_2 = Math.PI / 2;
- ccs.M_PI = Math.PI;
- ccs.TweenFunction.tweenTo = function(a, c, d) {
- var e = 0;
- switch (c) {
- case ccs.TweenType.customEasing:
- e = this.customEase(a, d);
- break;
- case ccs.TweenType.linear:
- e = this.linear(a);
- break;
- case ccs.TweenType.sineEaseIn:
- e = this.sineEaseIn(a);
- break;
- case ccs.TweenType.sineEaseOut:
- e = this.sineEaseOut(a);
- break;
- case ccs.TweenType.sineEaseInOut:
- e = this.sineEaseInOut(a);
- break;
- case ccs.TweenType.quadEaseIn:
- e = this.quadEaseIn(a);
- break;
- case ccs.TweenType.quadEaseOut:
- e = this.quadEaseOut(a);
- break;
- case ccs.TweenType.quadEaseInOut:
- e = this.quadEaseInOut(a);
- break;
- case ccs.TweenType.cubicEaseIn:
- e = this.cubicEaseIn(a);
- break;
- case ccs.TweenType.cubicEaseOut:
- e = this.cubicEaseOut(a);
- break;
- case ccs.TweenType.cubicEaseInOut:
- e = this.cubicEaseInOut(a);
- break;
- case ccs.TweenType.quartEaseIn:
- e = this.quartEaseIn(a);
- break;
- case ccs.TweenType.quartEaseOut:
- e = this.quartEaseOut(a);
- break;
- case ccs.TweenType.quartEaseInOut:
- e = this.quartEaseInOut(a);
- break;
- case ccs.TweenType.quintEaseIn:
- e = this.quintEaseIn(a);
- break;
- case ccs.TweenType.quintEaseOut:
- e = this.quintEaseOut(a);
- break;
- case ccs.TweenType.quintEaseInOut:
- e = this.quintEaseInOut(a);
- break;
- case ccs.TweenType.expoEaseIn:
- e = this.expoEaseIn(a);
- break;
- case ccs.TweenType.expoEaseOut:
- e = this.expoEaseOut(a);
- break;
- case ccs.TweenType.expoEaseInOut:
- e = this.expoEaseInOut(a);
- break;
- case ccs.TweenType.circEaseIn:
- e = this.circEaseIn(a);
- break;
- case ccs.TweenType.eircEaseOut:
- e = this.circEaseOut(a);
- break;
- case ccs.TweenType.circEaseInOut:
- e = this.circEaseInOut(a);
- break;
- case ccs.TweenType.elasticEaseIn:
- c = 0.3;
- null != d && (c = d[0]);
- e = this.elasticEaseIn(a, c);
- break;
- case ccs.TweenType.elasticEaseOut:
- c = 0.3;
- null != d && (c = d[0]);
- e = this.elasticEaseOut(a, c);
- break;
- case ccs.TweenType.elasticEaseInOut:
- c = 0.3;
- null != d && (c = d[0]);
- e = this.elasticEaseInOut(a, c);
- break;
- case ccs.TweenType.backEaseIn:
- e = this.backEaseIn(a);
- break;
- case ccs.TweenType.backEaseOut:
- e = this.backEaseOut(a);
- break;
- case ccs.TweenType.backEaseInOut:
- e = this.backEaseInOut(a);
- break;
- case ccs.TweenType.bounceEaseIn:
- e = this.bounceEaseIn(a);
- break;
- case ccs.TweenType.bounceEaseOut:
- e = this.bounceEaseOut(a);
- break;
- case ccs.TweenType.bounceEaseInOut:
- e = this.bounceEaseInOut(a);
- break;
- default:
- e = this.sineEaseInOut(a)
- }
- return e
- };
- ccs.TweenFunction.linear = function(a) {
- return a
- };
- ccs.TweenFunction.sineEaseIn = function(a) {
- return -1 * Math.cos(a * ccs.HALF_PI) + 1
- };
- ccs.TweenFunction.sineEaseOut = function(a) {
- return Math.sin(a * ccs.HALF_PI)
- };
- ccs.TweenFunction.sineEaseInOut = function(a) {
- return -0.5 * (Math.cos(ccs.M_PI * a) - 1)
- };
- ccs.TweenFunction.quadEaseIn = function(a) {
- return a * a
- };
- ccs.TweenFunction.quadEaseOut = function(a) {
- return -1 * a * (a - 2)
- };
- ccs.TweenFunction.quadEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a;
- --a;
- return -0.5 * (a * (a - 2) - 1)
- };
- ccs.TweenFunction.cubicEaseIn = function(a) {
- return a * a * a
- };
- ccs.TweenFunction.cubicEaseOut = function(a) {
- a -= 1;
- return a * a * a + 1
- };
- ccs.TweenFunction.cubicEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a;
- a -= 2;
- return 0.5 * (a * a * a + 2)
- };
- ccs.TweenFunction.quartEaseIn = function(a) {
- return a * a * a * a
- };
- ccs.TweenFunction.quartEaseOut = function(a) {
- a -= 1;
- return -(a * a * a * a - 1)
- };
- ccs.TweenFunction.quartEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a * a;
- a -= 2;
- return -0.5 * (a * a * a * a - 2)
- };
- ccs.TweenFunction.quintEaseIn = function(a) {
- return a * a * a * a * a
- };
- ccs.TweenFunction.quintEaseOut = function(a) {
- a -= 1;
- return a * a * a * a * a + 1
- };
- ccs.TweenFunction.quintEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return 0.5 * a * a * a * a * a;
- a -= 2;
- return 0.5 * (a * a * a * a * a + 2)
- };
- ccs.TweenFunction.expoEaseIn = function(a) {
- return 0 == a ? 0 : Math.pow(2, 10 * (a - 1)) - 0.0010
- };
- ccs.TweenFunction.expoEaseOut = function(a) {
- return 1 == a ? 1 : -Math.pow(2, -10 * a) + 1
- };
- ccs.TweenFunction.expoEaseInOut = function(a) {
- a /= 0.5;
- return a = 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)
- };
- ccs.TweenFunction.circEaseIn = function(a) {
- return -1 * (Math.sqrt(1 - a * a) - 1)
- };
- ccs.TweenFunction.circEaseOut = function(a) {
- a -= 1;
- return Math.sqrt(1 - a * a)
- };
- ccs.TweenFunction.circEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
- a -= 2;
- return 0.5 * (Math.sqrt(1 - a * a) + 1)
- };
- ccs.TweenFunction.elasticEaseIn = function(a, c) {
- var d = 0.3;
- 0 < c.length && (d = c[0]);
- var e = 0;
- 0 == a || 1 == a ? e = a : (e = d / 4, a -= 1, e = -Math.pow(2, 10 * a) * Math.sin((a - e) * ccs.DOUBLE_PI / d));
- return e
- };
- ccs.TweenFunction.elasticEaseOut = function(a, c) {
- var d = 0.3;
- 0 < c.length && (d = c[0]);
- var e = 0;
- 0 == a || 1 == a ? e = a : (e = d / 4, e = Math.pow(2, -10 * a) * Math.sin((a - e) * ccs.DOUBLE_PI / d) + 1);
- return e
- };
- ccs.TweenFunction.elasticEaseInOut = function(a, c) {
- var d = 0.3;
- 0 < c.length && (d = c[0]);
- var e = 0;
- 0 == a || 1 == a ? e = a : (d || (d = 0.3 * 1.5), e = d / 4, a = 2 * a - 1, e = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin((a - e) * ccs.DOUBLE_PI / d) : 0.5 * Math.pow(2, -10 * a) * Math.sin((a - e) * ccs.DOUBLE_PI / d) + 1);
- return e
- };
- ccs.TweenFunction.backEaseIn = function(a) {
- return a * a * (2.70158 * a - 1.70158)
- };
- ccs.TweenFunction.backEaseOut = function(a) {
- a -= 1;
- return a * a * (2.70158 * a + 1.70158) + 1
- };
- ccs.TweenFunction.backEaseInOut = function(a) {
- a *= 2;
- if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
- a -= 2;
- return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
- };
- ccs.bounceTime = function(a) {
- if (a < 1 / 2.75) return 7.5625 * a * a;
- if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
- if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
- a -= 2.625 / 2.75;
- return 7.5625 * a * a + 0.984375
- };
- ccs.TweenFunction.bounceEaseIn = function(a) {
- return 1 - ccs.bounceTime(1 - a)
- };
- ccs.TweenFunction.bounceEaseOut = function(a) {
- return ccs.bounceTime(a)
- };
- ccs.TweenFunction.bounceEaseInOut = function(a) {
- var c = 0;
- return c = 0.5 > a ? 0.5 * (1 - ccs.bounceTime(1 - 2 * a)) : 0.5 * ccs.bounceTime(2 * a - 1) + 0.5
- };
- ccs.TweenFunction.customEase = function(a, c) {
- if (0 < c.length) {
- var d = 1 - a;
- return c[1] * d * d * d + 3 * c[3] * a * d * d + 3 * c[5] * a * a * d + c[7] * a * a * a
- }
- return a
- };
- ccs.TweenFunction.easeIn = function(a, c) {
- return Math.pow(a, c)
- };
- ccs.TweenFunction.easeOut = function(a, c) {
- return Math.pow(a, 1 / c)
- };
- ccs.TweenFunction.easeInOut = function(a, c) {
- a *= 2;
- return 1 > a ? 0.5 * Math.pow(a, c) : 1 - 0.5 * Math.pow(2 - a, c)
- };
- ccs.TweenFunction.quadraticIn = function(a) {
- return Math.pow(a, 2)
- };
- ccs.TweenFunction.quadraticOut = function(a) {
- return -a * (a - 2)
- };
- ccs.TweenFunction.bezieratFunction = function(a, c, d, e, f) {
- return Math.pow(1 - f, 3) * a + 3 * f * Math.pow(1 - f, 2) * c + 3 * Math.pow(f, 2) * (1 - f) * d + Math.pow(f, 3) * e
- };
- var ENABLE_PHYSICS_DETECT = !1;
- ccs.fmodf = function(a, c) {
- for (; a > c;) a -= c;
- return a
- };
- var CC_SAFE_RELEASE = function(a) {
- a && a.release && a.release()
- };
- ccs.isSpriteContainPoint = function(a, c, d) {
- c = a.convertToNodeSpace(c);
- d && (d.x = c.x, d.y = c.y);
- a = a.getContentSize();
- return cc.rectContainsPoint(cc.rect(0, 0, a.width, a.height), c)
- };
- ccs.SPRITE_CONTAIN_POINT = ccs.isSpriteContainPoint;
- ccs.SPRITE_CONTAIN_POINT_WITH_RETURN = ccs.isSpriteContainPoint;
- ccs.extBezierTo = function(a, c, d, e, f) {
- var g = cc.p(0, 0);
- e && !f && (g.x = Math.pow(1 - a, 2) * c.x + 2 * a * (1 - a) * d.x + Math.pow(a, 2) * e.x, g.y = Math.pow(1 - a, 2) * c.y + 2 * a * (1 - a) * d.y + Math.pow(a, 2) * e.y);
- f && (g.x = c.x * Math.pow(1 - a, 3) + 3 * a * d.x * Math.pow(1 - a, 2) + 3 * e.x * Math.pow(a, 2) * (1 - a) + f.x * Math.pow(a, 3), g.y = c.y * Math.pow(1 - a, 3) + 3 * a * d.y * Math.pow(1 - a, 2) + 3 * e.y * Math.pow(a, 2) * (1 - a) + f.y * Math.pow(a, 3));
- return g
- };
- ccs.extCircleTo = function(a, c, d, e, f) {
- var g = cc.p(0, 0);
- g.x = c.x + d * Math.cos(e + f * a);
- g.y = c.y + d * Math.sin(e + f * a);
- return g
- };
- ccs.RelativeData = function() {
- this.plistFiles = [];
- this.armatures = [];
- this.animations = [];
- this.textures = []
- };
- ccs.armatureDataManager = {
- _animationDatas: {},
- _armarureDatas: {},
- _textureDatas: {},
- _autoLoadSpriteFile: !1,
- _relativeDatas: {},
- s_sharedArmatureDataManager: null,
- removeArmatureFileInfo: function(a) {
- var c = this.getRelativeData(a);
- if (c) {
- for (var d = 0; d < c.armatures.length; d++) {
- var e = c.armatures[d];
- this.removeArmatureData(e)
- }
- for (d = 0; d < c.animations.length; d++) e = c.animations[d], this.removeAnimationData(e);
- for (d = 0; d < c.textures.length; d++) e = c.textures[d], this.removeTextureData(e);
- for (d = 0; d < c.plistFiles.length; d++) e = c.plistFiles[d], cc.spriteFrameCache.removeSpriteFramesFromFile(e);
- delete this._relativeDatas[a];
- ccs.dataReaderHelper.removeConfigFile(a)
- }
- },
- addArmatureData: function(a, c, d) {
- (d = this.getRelativeData(d)) && d.armatures.push(a);
- this._armarureDatas[a] = c
- },
- getArmatureData: function(a) {
- var c = null;
- this._armarureDatas && (c = this._armarureDatas[a]);
- return c
- },
- removeArmatureData: function(a) {
- this._armarureDatas[a] && delete this._armarureDatas[a]
- },
- addAnimationData: function(a, c, d) {
- (d = this.getRelativeData(d)) && d.animations.push(a);
- this._animationDatas[a] = c
- },
- getAnimationData: function(a) {
- var c = null;
- this._animationDatas[a] && (c = this._animationDatas[a]);
- return c
- },
- removeAnimationData: function(a) {
- this._animationDatas[a] && delete this._animationDatas[a]
- },
- addTextureData: function(a, c, d) {
- (d = this.getRelativeData(d)) && d.textures.push(a);
- this._textureDatas[a] = c
- },
- getTextureData: function(a) {
- var c = null;
- this._textureDatas && (c = this._textureDatas[a]);
- return c
- },
- removeTextureData: function(a) {
- this._textureDatas[a] && delete this._textureDatas[a]
- },
- addArmatureFileInfo: function() {
- var a, c, d;
- switch (arguments.length) {
- case 1:
- d = arguments[0];
- this.addRelativeData(d);
- this._autoLoadSpriteFile = !0;
- ccs.dataReaderHelper.addDataFromFile(d);
- break;
- case 3:
- a = arguments[0], c = arguments[1], d = arguments[2], this.addRelativeData(d), this._autoLoadSpriteFile = !1, ccs.dataReaderHelper.addDataFromFile(d), this.addSpriteFrameFromFile(c, a)
- }
- },
- addArmatureFileInfoAsync: function() {
- var a, c, d, e, f;
- switch (arguments.length) {
- case 3:
- d = arguments[0];
- e = arguments[2];
- f = arguments[1];
- this.addRelativeData(d);
- this._autoLoadSpriteFile = !0;
- ccs.dataReaderHelper.addDataFromFileAsync("", "", d, f, e);
- break;
- case 5:
- a = arguments[0], c = arguments[1], d = arguments[2], e = arguments[4], f = arguments[3], this.addRelativeData(d), this._autoLoadSpriteFile = !1, ccs.dataReaderHelper.addDataFromFileAsync(a, c, d, f, e), this.addSpriteFrameFromFile(c, a)
- }
- },
- addSpriteFrameFromFile: function(a, c, d) {
- (d = this.getRelativeData(d)) && d.plistFiles.push(a);
- ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(a, c)
- },
- isAutoLoadSpriteFile: function() {
- return this._autoLoadSpriteFile
- },
- getArmatureDatas: function() {
- return this._armarureDatas
- },
- getAnimationDatas: function() {
- return this._animationDatas
- },
- getTextureDatas: function() {
- return this._textureDatas
- },
- addRelativeData: function(a) {
- this._relativeDatas[a] || (this._relativeDatas[a] = new ccs.RelativeData)
- },
- getRelativeData: function(a) {
- return this._relativeDatas[a]
- },
- clear: function() {
- this._animationDatas = {};
- this._armarureDatas = {};
- this._textureDatas = {};
- ccs.spriteFrameCacheHelper.clear();
- ccs.dataReaderHelper.clear()
- }
- };
- ccs.BLEND_TYPE_NORMAL = 0;
- ccs.BLEND_TYPE_LAYER = 1;
- ccs.BLEND_TYPE_DARKEN = 2;
- ccs.BLEND_TYPE_MULTIPLY = 3;
- ccs.BLEND_TYPE_LIGHTEN = 4;
- ccs.BLEND_TYPE_SCREEN = 5;
- ccs.BLEND_TYPE_OVERLAY = 6;
- ccs.BLEND_TYPE_HIGHLIGHT = 7;
- ccs.BLEND_TYPE_ADD = 8;
- ccs.BLEND_TYPE_SUBTRACT = 9;
- ccs.BLEND_TYPE_DIFFERENCE = 10;
- ccs.BLEND_TYPE_INVERT = 11;
- ccs.BLEND_TYPE_ALPHA = 12;
- ccs.BLEND_TYPE_ERASE = 13;
- ccs.DISPLAY_TYPE_SPRITE = 0;
- ccs.DISPLAY_TYPE_ARMATURE = 1;
- ccs.DISPLAY_TYPE_PARTICLE = 2;
- ccs.DISPLAY_TYPE_MAX = 3;
- ccs.BaseData = ccs.Class.extend({
- x: 0,
- y: 0,
- zOrder: 0,
- skewX: 0,
- skewY: 0,
- scaleX: 1,
- scaleY: 1,
- tweenRotate: 0,
- isUseColorInfo: !1,
- r: 255,
- g: 255,
- b: 255,
- a: 255,
- ctor: function() {
- this.skewY = this.skewX = this.zOrder = this.y = this.x = 0;
- this.scaleY = this.scaleX = 1;
- this.tweenRotate = 0;
- this.isUseColorInfo = !1;
- this.a = this.b = this.g = this.r = 255
- },
- copy: function(a) {
- this.x = a.x;
- this.y = a.y;
- this.zOrder = a.zOrder;
- this.scaleX = a.scaleX;
- this.scaleY = a.scaleY;
- this.skewX = a.skewX;
- this.skewY = a.skewY;
- this.tweenRotate = a.tweenRotate;
- this.isUseColorInfo = a.isUseColorInfo;
- this.r = a.r;
- this.g = a.g;
- this.b = a.b;
- this.a = a.a
- },
- setColor: function(a) {
- this.r = a.r;
- this.g = a.g;
- this.b = a.b;
- this.a = a.a
- },
- getColor: function() {
- return cc.color(this.r, this.g, this.b, this.a)
- },
- subtract: function(a, c, d) {
- this.x = c.x - a.x;
- this.y = c.y - a.y;
- this.scaleX = c.scaleX - a.scaleX;
- this.scaleY = c.scaleY - a.scaleY;
- this.skewX = c.skewX - a.skewX;
- this.skewY = c.skewY - a.skewY;
- this.isUseColorInfo || a.isUseColorInfo || c.isUseColorInfo ? (this.a = c.a - a.a, this.r = c.r - a.r, this.g = c.g - a.g, this.b = c.b - a.b, this.isUseColorInfo = !0) : (this.a = this.r = this.g = this.b = 0, this.isUseColorInfo = !1);
- d && (this.skewX > ccs.M_PI && (this.skewX -= ccs.DOUBLE_PI), this.skewX < -ccs.M_PI && (this.skewX += ccs.DOUBLE_PI), this.skewY > ccs.M_PI && (this.skewY -= ccs.DOUBLE_PI), this.skewY < -ccs.M_PI && (this.skewY += ccs.DOUBLE_PI));
- c.tweenRotate && (this.skewX += 2 * c.tweenRotate * ccs.PI, this.skewY -= 2 * c.tweenRotate * ccs.PI)
- }
- });
- ccs.DisplayData = ccs.Class.extend({
- displayType: ccs.DISPLAY_TYPE_MAX,
- displayName: "",
- ctor: function() {
- this.displayType = ccs.DISPLAY_TYPE_MAX
- },
- changeDisplayToTexture: function(a) {
- var c = a.lastIndexOf("."); - 1 != c && (a = a.substring(0, c));
- return a
- },
- copy: function(a) {
- this.displayName = a.displayName;
- this.displayType = a.displayType
- }
- });
- ccs.SpriteDisplayData = ccs.DisplayData.extend({
- skinData: null,
- ctor: function() {
- this.skinData = new ccs.BaseData;
- this.displayType = ccs.DISPLAY_TYPE_SPRITE
- },
- copy: function(a) {
- ccs.DisplayData.prototype.copy.call(this, a);
- this.skinData = a.skinData
- },
- SpriteDisplayData: function() {
- this.displayType = ccs.DISPLAY_TYPE_SPRITE
- }
- });
- ccs.ArmatureDisplayData = ccs.DisplayData.extend({
- displayName: "",
- ctor: function() {
- this.displayName = "";
- this.displayType = ccs.DISPLAY_TYPE_ARMATURE
- }
- });
- ccs.ParticleDisplayData = ccs.DisplayData.extend({
- ctor: function() {
- this.displayType = ccs.DISPLAY_TYPE_PARTICLE
- }
- });
- ccs.BoneData = ccs.BaseData.extend({
- displayDataList: null,
- name: "",
- parentName: "",
- boneDataTransform: null,
- ctor: function() {
- this.displayDataList = [];
- this.parentName = this.name = "";
- this.boneDataTransform = null
- },
- init: function() {
- this.displayDataList.length = 0;
- return !0
- },
- addDisplayData: function(a) {
- this.displayDataList.push(a)
- },
- getDisplayData: function(a) {
- return this.displayDataList[a]
- }
- });
- ccs.ArmatureData = ccs.Class.extend({
- boneDataDic: null,
- name: "",
- dataVersion: 0.1,
- ctor: function() {
- this.boneDataDic = {};
- this.name = "";
- this.dataVersion = 0.1
- },
- init: function() {
- return !0
- },
- addBoneData: function(a) {
- this.boneDataDic[a.name] = a
- },
- getBoneDataDic: function() {
- return this.boneDataDic
- },
- getBoneData: function(a) {
- return this.boneDataDic[a]
- }
- });
- ccs.FrameData = ccs.BaseData.extend({
- duration: 0,
- tweenEasing: 0,
- easingParamNumber: 0,
- easingParams: null,
- displayIndex: -1,
- movement: "",
- event: "",
- sound: "",
- soundEffect: "",
- blendFunc: 0,
- frameID: 0,
- isTween: !0,
- ctor: function() {
- ccs.BaseData.prototype.ctor.call(this);
- this.duration = 1;
- this.tweenEasing = ccs.TweenType.linear;
- this.easingParamNumber = 0;
- this.easingParams = [];
- this.displayIndex = 0;
- this.soundEffect = this.sound = this.event = this.movement = "";
- this.blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- this.frameID = 0;
- this.isTween = !0
- },
- copy: function(a) {
- ccs.BaseData.prototype.copy.call(this, a);
- this.duration = a.duration;
- this.displayIndex = a.displayIndex;
- this.tweenEasing = a.tweenEasing;
- this.easingParamNumber = a.easingParamNumber;
- if (0 != this.easingParamNumber)
- for (var c = 0; c < this.easingParamNumber; c++) this.easingParams[c] = a.easingParams[c];
- this.blendFunc = a.blendFunc;
- this.isTween = a.isTween
- }
- });
- ccs.MovementBoneData = ccs.Class.extend({
- delay: 0,
- scale: 1,
- duration: 0,
- frameList: null,
- name: "",
- ctor: function() {
- this.delay = 0;
- this.scale = 1;
- this.duration = 0;
- this.frameList = [];
- this.name = ""
- },
- init: function() {
- return !0
- },
- addFrameData: function(a) {
- this.frameList.push(a)
- },
- getFrameData: function(a) {
- return this.frameList[a]
- }
- });
- ccs.MovementData = function() {
- this.name = "";
- this.duration = 0;
- this.scale = 1;
- this.durationTween = this.durationTo = 0;
- this.loop = !0;
- this.tweenEasing = ccs.TweenType.linear;
- this.movBoneDataDic = {}
- };
- ccs.MovementData.prototype.addMovementBoneData = function(a) {
- this.movBoneDataDic[a.name] = a
- };
- ccs.MovementData.prototype.getMovementBoneData = function(a) {
- return this.movBoneDataDic[a]
- };
- ccs.AnimationData = function() {
- this.movementDataDic = {};
- this.movementNames = [];
- this.name = ""
- };
- ccs.AnimationData.prototype.addMovement = function(a) {
- this.movementDataDic[a.name] = a;
- this.movementNames.push(a.name)
- };
- ccs.AnimationData.prototype.getMovement = function(a) {
- return this.movementDataDic[a]
- };
- ccs.AnimationData.prototype.getMovementCount = function() {
- return Object.keys(this.movementDataDic).length
- };
- ccs.ContourVertex2 = function(a, c) {
- this.x = a || 0;
- this.y = c || 0
- };
- ccs.ContourData = function() {
- this.vertexList = []
- };
- ccs.ContourData.prototype.init = function() {
- this.vertexList.length = 0;
- return !0
- };
- ccs.ContourData.prototype.addVertex = function(a) {
- this.vertexList.push(a)
- };
- ccs.TextureData = function() {
- this.width = this.height = 0;
- this.pivotY = this.pivotX = 0.5;
- this.name = "";
- this.contourDataList = []
- };
- ccs.TextureData.prototype.init = function() {
- this.contourDataList.length = 0
- };
- ccs.TextureData.prototype.addContourData = function(a) {
- this.contourDataList.push(a)
- };
- ccs.TextureData.prototype.getContourData = function(a) {
- return this.contourDataList[a]
- };
- ccs.DecorativeDisplay = ccs.Class.extend({
- _display: null,
- _colliderDetector: null,
- _displayData: null,
- ctor: function() {
- this._displayData = this._colliderDetector = this._display = null
- },
- init: function() {
- return !0
- },
- setDisplay: function(a) {
- this._display = a
- },
- getDisplay: function() {
- return this._display
- },
- setColliderDetector: function(a) {
- this._colliderDetector = a
- },
- getColliderDetector: function() {
- return this._colliderDetector
- },
- setDisplayData: function(a) {
- this._displayData = a
- },
- getDisplayData: function() {
- return this._displayData
- },
- release: function() {
- this._colliderDetector = this._displayData = this._display = null
- }
- });
- ccs.DecorativeDisplay.create = function() {
- var a = new ccs.DecorativeDisplay;
- return a && a.init() ? a : null
- };
- ccs.displayFactory = {
- addDisplay: function(a, c, d) {
- switch (d.displayType) {
- case ccs.DISPLAY_TYPE_SPRITE:
- this.addSpriteDisplay(a, c, d);
- break;
- case ccs.DISPLAY_TYPE_PARTICLE:
- this.addParticleDisplay(a, c, d);
- break;
- case ccs.DISPLAY_TYPE_ARMATURE:
- this.addArmatureDisplay(a, c, d)
- }
- },
- createDisplay: function(a, c) {
- switch (c.getDisplayData().displayType) {
- case ccs.DISPLAY_TYPE_SPRITE:
- this.createSpriteDisplay(a, c);
- break;
- case ccs.DISPLAY_TYPE_PARTICLE:
- this.createParticleDisplay(a, c);
- break;
- case ccs.DISPLAY_TYPE_ARMATURE:
- this.createArmatureDisplay(a, c)
- }
- },
- _helpTransform: {
- a: 1,
- b: 0,
- c: 0,
- d: 1,
- tx: 0,
- ty: 0
- },
- updateDisplay: function(a, c, d) {
- var e = a.getDisplayRenderNode();
- if (e) {
- switch (a.getDisplayRenderNodeType()) {
- case ccs.DISPLAY_TYPE_SPRITE:
- d && e.updateArmatureTransform();
- break;
- case ccs.DISPLAY_TYPE_PARTICLE:
- this.updateParticleDisplay(a, e, c);
- break;
- case ccs.DISPLAY_TYPE_ARMATURE:
- this.updateArmatureDisplay(a, e, c);
- break;
- default:
- c = a.getNodeToArmatureTransform(), e.setAdditionalTransform(c)
- }
- if ((ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && d)
- if (e = a.getDisplayManager().getCurrentDecorativeDisplay(), d = e.getColliderDetector()) {
- c = e.getDisplay();
- var f = c.nodeToParentTransform(),
- e = this._helpTransform;
- e.a = f.a;
- e.b = f.b;
- e.c = f.c;
- e.d = f.d;
- e.tx = f.tx;
- e.ty = f.ty;
- c = cc.pointApplyAffineTransform(c.getAnchorPointInPoints(), e);
- e.tx = c.x;
- e.ty = c.y;
- a = cc.affineTransformConcat(e, a.getArmature().nodeToParentTransform());
- d.updateTransform(a)
- }
- }
- },
- addSpriteDisplay: function(a, c, d) {
- var e = new ccs.SpriteDisplayData;
- e.copy(d);
- c.setDisplayData(e);
- this.createSpriteDisplay(a, c)
- },
- createSpriteDisplay: function(a, c) {
- var d = null,
- e = c.getDisplayData(),
- d = e.displayName,
- f = d.lastIndexOf("."); - 1 != f && (d = d.substring(0, f));
- d = "" == d ? ccs.Skin.create() : ccs.Skin.createWithSpriteFrameName(d + ".png");
- c.setDisplay(d);
- null != d && (d.setBone(a), this.initSpriteDisplay(a, c, e.displayName, d), (f = a.getArmature()) && (f.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED ? d.setSkinData(e.skinData) : d.setSkinData(a.boneData)))
- },
- initSpriteDisplay: function(a, c, d, e) {
- var f = d.lastIndexOf("."); - 1 != f && (d = d.substring(0, f));
- (d = ccs.armatureDataManager.getTextureData(d)) && e.setAnchorPoint(cc.p(d.pivotX, d.pivotY));
- if ((ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && d && 0 < d.contourDataList.length) a = ccs.ColliderDetector.create(a), a.addContourDataList(d.contourDataList), c.setColliderDetector(a)
- },
- addArmatureDisplay: function(a, c, d) {
- var e = new ccs.ArmatureDisplayData;
- e.copy(d);
- c.setDisplayData(e);
- this.createArmatureDisplay(a, c)
- },
- createArmatureDisplay: function(a, c) {
- var d = c.getDisplayData(),
- d = ccs.Armature.create(d.displayName, a);
- c.setDisplay(d)
- },
- updateArmatureDisplay: function(a, c, d) {
- c && (c.sortAllChildren(), c.update(d))
- },
- addParticleDisplay: function(a, c, d) {
- var e = new ccs.ParticleDisplayData;
- e.copy(d);
- c.setDisplayData(e);
- this.createParticleDisplay(a, c)
- },
- createParticleDisplay: function(a, c) {
- var d = c.getDisplayData(),
- d = cc.ParticleSystem.create(d.displayName);
- d.removeFromParent();
- d.cleanup();
- a.getArmature() && d.setParent(a.getArmature());
- c.setDisplay(d)
- },
- updateParticleDisplay: function(a, c, d) {
- var e = new ccs.BaseData;
- ccs.TransformHelp.matrixToNode(a.nodeToArmatureTransform(), e);
- c.setPosition(e.x, e.y);
- c.setScaleX(e.scaleX);
- c.setScaleY(e.scaleY);
- c.update(d)
- }
- };
- ccs.DisplayManager = ccs.Class.extend({
- _decoDisplayList: null,
- _currentDecoDisplay: null,
- _displayRenderNode: null,
- _displayIndex: null,
- _forceChangeDisplay: !1,
- _bone: null,
- _visible: !0,
- _displayType: null,
- ctor: function() {
- this._decoDisplayList = [];
- this._displayIndex = this._displayRenderNode = this._currentDecoDisplay = null;
- this._forceChangeDisplay = !1;
- this._bone = null;
- this._visible = !0;
- this._displayType = ccs.DISPLAY_TYPE_MAX
- },
- init: function(a) {
- this._bone = a;
- this.initDisplayList(a.getBoneData());
- return !0
- },
- addDisplay: function(a, c) {
- var d, e = this._decoDisplayList;
- 0 <= c && c < e.length ? d = e[c] : (d = ccs.DecorativeDisplay.create(), e.push(d));
- if (a instanceof ccs.DisplayData) cc.displayFactory.addDisplay(this._bone, d, a);
- else {
- var f = null;
- if (a instanceof ccs.Skin) {
- a.setBone(this._bone);
- f = new ccs.SpriteDisplayData;
- ccs.displayFactory.initSpriteDisplay(this._bone, d, a.getDisplayName(), a);
- var g = d.getDisplayData();
- if (g instanceof ccs.SpriteDisplayData) a.setSkinData(g.skinData), f.skinData = g.skinData;
- else {
- for (var g = !1, h = e.length - 2; 0 <= h; h--) {
- var k = e[h].getDisplayData();
- if (k instanceof ccs.SpriteDisplayData) {
- g = !0;
- a.setSkinData(k.skinData);
- f.skinData = k.skinData;
- break
- }
- }
- g || a.setSkinData(new ccs.BaseData)
- }
- } else a instanceof cc.ParticleSystem ? (f = new ccs.ParticleDisplayData, a.removeFromParent(), a.cleanup(), (e = this._bone.getArmature()) && a.setParent(e)) : a instanceof ccs.Armature ? (f = new ccs.ArmatureDisplayData, f.displayName = a.getName(), a.setParentBone(this._bone)) : f = new ccs.DisplayData;
- d.setDisplay(a);
- d.setDisplayData(f)
- }
- c == this._displayIndex && (this._displayIndex = -1, this.changeDisplayWithIndex(c, !1))
- },
- _addDisplayOther: function(a, c) {
- var d = null;
- if (c instanceof ccs.Skin) {
- c.setBone(this._bone);
- d = new ccs.SpriteDisplayData;
- d.displayName = c.getDisplayName();
- ccs.displayFactory.initSpriteDisplay(this._bone, a, c.getDisplayName(), c);
- var e = a.getDisplayData();
- if (e instanceof ccs.SpriteDisplayData) c.setSkinData(e.skinData);
- else {
- for (var e = !1, f = this._decoDisplayList.length - 2; 0 <= f; f--) {
- var g = this._decoDisplayList[f].getDisplayData();
- if (g) {
- e = !0;
- c.setSkinData(g.skinData);
- d.skinData = g.skinData;
- break
- }
- }
- e || c.setSkinData(new ccs.BaseData);
- c.setSkinData(new ccs.BaseData)
- }
- } else c instanceof cc.ParticleSystem ? (d = new ccs.ParticleDisplayData, d.displayName = c._plistFile) : c instanceof ccs.Armature ? (d = new ccs.ArmatureDisplayData, d.displayName = c.getName(), c.setParentBone(this._bone)) : d = new ccs.DisplayData;
- a.setDisplay(c);
- a.setDisplayData(d)
- },
- removeDisplay: function(a) {
- this._decoDisplayList.splice(a, 1);
- a === this._displayIndex && (this.setCurrentDecorativeDisplay(null), this._displayIndex = -1)
- },
- getDecorativeDisplayList: function() {
- return this._decoDisplayList
- },
- changeDisplayWithIndex: function(a, c) {
- a >= this._decoDisplayList.length ? cc.log("the index value is out of range") : (this._forceChangeDisplay = c, this._displayIndex != a && (this._displayIndex = a, 0 > a ? this._displayRenderNode && (this._displayRenderNode.removeFromParent(!0), this.setCurrentDecorativeDisplay(null)) : this.setCurrentDecorativeDisplay(this._decoDisplayList[a])))
- },
- changeDisplayWithName: function(a, c) {
- for (var d = this._decoDisplayList, e = 0; e < d.length; e++)
- if (d[e].getDisplayData().displayName == a) {
- this.changeDisplayWithIndex(e, c);
- break
- }
- },
- setCurrentDecorativeDisplay: function(a) {
- var c = this._currentDecoDisplay;
- (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && c && c.getColliderDetector() && c.getColliderDetector().setActive(!1);
- c = this._currentDecoDisplay = a;
- (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && c && c.getColliderDetector() && c.getColliderDetector().setActive(!0);
- a = !c ? null : c.getDisplay();
- var c = this._displayRenderNode,
- d = this._bone;
- c && (c instanceof ccs.Armature && d.setChildArmature(null), c.removeFromParent(!0));
- (this._displayRenderNode = a) ? (a instanceof ccs.Armature ? (this._bone.setChildArmature(a), a.setParentBone(this._bone)) : a instanceof cc.ParticleSystem && (a instanceof ccs.Armature ? (d.setChildArmature(a), a.setParentBone(d)) : a instanceof cc.ParticleSystem && a.resetSystem()), a.setColor(d.getDisplayedColor()), a.setOpacity(d.getDisplayedOpacity()), this._displayRenderNode.setVisible(this._visible), this._displayType = this._currentDecoDisplay.getDisplayData().displayType) : this._displayType = ccs.DISPLAY_TYPE_MAX
- },
- getDisplayRenderNode: function() {
- return this._displayRenderNode
- },
- getDisplayRenderNodeType: function() {
- return this._displayType
- },
- getCurrentDisplayIndex: function() {
- return this._displayIndex
- },
- getCurrentDecorativeDisplay: function() {
- return this._currentDecoDisplay
- },
- getDecorativeDisplayByIndex: function(a) {
- return this._decoDisplayList[a]
- },
- initDisplayList: function(a) {
- this._decoDisplayList.length = 0;
- if (a) {
- a = a.displayDataList;
- for (var c = this._decoDisplayList, d = this._bone, e = 0; e < a.length; e++) {
- var f = a[e],
- g = ccs.DecorativeDisplay.create();
- g.setDisplayData(f);
- ccs.displayFactory.createDisplay(d, g);
- c.push(g)
- }
- }
- },
- containPoint: function(a, c) {
- if (!this._visible || 0 > this._displayIndex) return !1;
- void 0 !== c && (a = cc.p(a, c));
- if (this._currentDecoDisplay.getDisplayData().displayType == ccs.DISPLAY_TYPE_SPRITE) {
- var d = this._currentDecoDisplay.getDisplay(),
- d = d.getChildByTag(0);
- return ccs.SPRITE_CONTAIN_POINT_WITH_RETURN(d, a)
- }
- return !1
- },
- setVisible: function(a) {
- this._displayRenderNode && (this._visible = a, this._displayRenderNode.setVisible(a))
- },
- isVisible: function() {
- return this._visible
- },
- getContentSize: function() {
- return !this._displayRenderNode ? cc.size(0, 0) : this._displayRenderNode.getContentSize()
- },
- getBoundingBox: function() {
- return !this._displayRenderNode ? cc.rect(0, 0, 0, 0) : this._displayRenderNode.getBoundingBox()
- },
- getAnchorPoint: function() {
- return !this._displayRenderNode ? cc.p(0, 0) : this._displayRenderNode.getAnchorPoint()
- },
- getAnchorPointInPoints: function() {
- return !this._displayRenderNode ? cc.p(0, 0) : this._displayRenderNode.getAnchorPointInPoints()
- },
- getForceChangeDisplay: function() {
- return this._forceChangeDisplay
- },
- release: function() {
- this._decoDisplayList = null;
- this._displayRenderNode && (this._displayRenderNode.removeFromParent(!0), this._displayRenderNode = null)
- }
- });
- ccs.DisplayManager.create = function(a) {
- var c = new ccs.DisplayManager;
- return c && c.init(a) ? c : null
- };
- ccs.Skin = ccs.Sprite.extend({
- _skinData: null,
- bone: null,
- _skinTransform: null,
- _displayName: "",
- _armature: null,
- _className: "Skin",
- ctor: function() {
- cc.Sprite.prototype.ctor.call(this);
- this.bone = this._skinData = null;
- this._displayName = "";
- this._skinTransform = cc.affineTransformIdentity();
- this._armature = null
- },
- initWithSpriteFrameName: function(a) {
- if ("" == a) return !1;
- var c = cc.spriteFrameCache.getSpriteFrame(a),
- d = !0;
- c ? this.initWithSpriteFrame(c) : (cc.log("Can't find CCSpriteFrame with %s. Please check your .plist file", a), d = !1);
- this._displayName = a;
- return d
- },
- initWithFile: function(a) {
- var c = cc.Sprite.prototype.initWithFile.call(this, a);
- this._displayName = a;
- return c
- },
- setSkinData: function(a) {
- this._skinData = a;
- this.setScaleX(a.scaleX);
- this.setScaleY(a.scaleY);
- this.setRotationX(cc.radiansToDegrees(a.skewX));
- this.setRotationY(cc.radiansToDegrees(-a.skewY));
- this.setPosition(a.x, a.y);
- a = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform();
- var c = this._skinTransform;
- c.a = a.a;
- c.b = a.b;
- c.c = a.c;
- c.d = a.d;
- c.tx = a.tx;
- c.ty = a.ty;
- this.updateArmatureTransform()
- },
- getSkinData: function() {
- return this._skinData
- },
- updateArmatureTransform: function() {
- this._transform = cc.affineTransformConcat(this._skinTransform, this.bone.getNodeToArmatureTransform())
- },
- _updateTransformForWebGL: function() {
- var a = this._quad;
- if (this._visible) {
- var c = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(),
- d = this._rect,
- e = this._offsetPosition.x,
- f = this._offsetPosition.y,
- g = e + d.width,
- h = f + d.height,
- k = c.tx,
- m = c.ty,
- n = c.a,
- q = c.b,
- r = c.d,
- t = -c.c,
- c = e * n - f * t + k,
- d = e * q + f * r + m,
- s = g * n - f * t + k,
- f = g * q + f * r + m,
- v = g * n - h * t + k,
- g = g * q + h * r + m,
- k = e * n - h * t + k,
- e = e * q + h * r + m,
- h = this._vertexZ;
- cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (c |= 0, d |= 0, s |= 0, f |= 0, v |= 0, g |= 0, k |= 0, e |= 0);
- this.SET_VERTEX3F(a.bl.vertices, c, d, h);
- this.SET_VERTEX3F(a.br.vertices, s, f, h);
- this.SET_VERTEX3F(a.tl.vertices, k, e, h);
- this.SET_VERTEX3F(a.tr.vertices, v, g, h)
- } else a.br.vertices = a.tl.vertices = a.tr.vertices = a.bl.vertices = {
- x: 0,
- y: 0,
- z: 0
- };
- this._textureAtlas && this._textureAtlas.updateQuad(a, this._textureAtlas.getTotalQuads());
- this._quadDirty = !0
- },
- SET_VERTEX3F: function(a, c, d, e) {
- a.x = c;
- a.y = d;
- a.z = e
- },
- RENDER_IN_SUBPIXEL: function(a) {
- return cc.SPRITEBATCHNODE_RENDER_SUBPIXEL ? a : Math.ceil(a)
- },
- getNodeToWorldTransform: function() {
- return cc.affineTransformConcat(this._transform, this.bone.getArmature().getNodeToWorldTransform())
- },
- getNodeToWorldTransformAR: function() {
- var a = this._transform;
- this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, a);
- a.tx = this._anchorPointInPoints.x;
- a.ty = this._anchorPointInPoints.y;
- return cc.affineTransformConcat(a, this.bone.getArmature().nodeToWorldTransform())
- },
- setBone: function(a) {
- this.bone = a;
- if (a = this.bone.getArmature()) this._armature = a
- },
- getBone: function() {
- return this.bone
- },
- getDisplayName: function() {
- return this._displayName
- }
- });
- cc._renderType == cc._RENDER_TYPE_WEBGL && (ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL);
- _p = ccs.Skin.prototype;
- cc.defineGetterSetter(_p, "skinData", _p.getSkinData, _p.setSkinData);
- cc.defineGetterSetter(_p, "displayName", _p.getDisplayName);
- _p = null;
- ccs.Skin.create = function(a, c) {
- var d = arguments.length,
- e = new ccs.Skin;
- if (0 === d || null == a || "" == a) {
- if (e.init()) return e
- } else if ("#" == a[0]) {
- if (e && e.initWithSpriteFrameName(a)) return e
- } else if (e && e.initWithFile(a, c)) return e;
- return null
- };
- ccs.Skin.createWithSpriteFrameName = function(a) {
- var c = new ccs.Skin;
- return c && c.initWithSpriteFrameName(a) ? c : null
- };
- ccs.ANIMATION_TYPE_SINGLE_FRAME = -4;
- ccs.ANIMATION_TYPE_NO_LOOP = -3;
- ccs.ANIMATION_TYPE_TO_LOOP_FRONT = -2;
- ccs.ANIMATION_TYPE_TO_LOOP_BACK = -1;
- ccs.ANIMATION_TYPE_LOOP_FRONT = 0;
- ccs.ANIMATION_TYPE_LOOP_BACK = 1;
- ccs.ANIMATION_TYPE_MAX = 2;
- ccs.ProcessBase = ccs.Class.extend({
- _processScale: 1,
- _isComplete: !0,
- _isPause: !0,
- _isPlaying: !1,
- _currentPercent: 0,
- _rawDuration: 0,
- _loopType: 0,
- _tweenEasing: 0,
- animationInternal: null,
- _currentFrame: 0,
- _durationTween: 0,
- _nextFrameIndex: 0,
- _curFrameIndex: null,
- _isLoopBack: !1,
- ctor: function() {
- this._processScale = 1;
- this._isPause = this._isComplete = !0;
- this._isPlaying = !1;
- this._rawDuration = this._durationTween = this._currentPercent = this._currentFrame = 0;
- this._loopType = ccs.ANIMATION_TYPE_LOOP_BACK;
- this._tweenEasing = ccs.TweenType.linear;
- this.animationInternal = 1 / 60;
- this._durationTween = this._curFrameIndex = 0;
- this._isLoopBack = !1
- },
- pause: function() {
- this._isPause = !0;
- this._isPlaying = !1
- },
- resume: function() {
- this._isPause = !1;
- this._isPlaying = !0
- },
- stop: function() {
- this._isComplete = !0;
- this._isPlaying = !1
- },
- play: function(a, c, d, e) {
- this._isPause = this._isComplete = !1;
- this._isPlaying = !0;
- this._currentFrame = 0;
- this._nextFrameIndex = a;
- this._tweenEasing = e
- },
- update: function(a) {
- if (!this._isComplete && !this._isPause && !(0 >= this._rawDuration || 1 < a)) {
- var c = void 0 === this._nextFrameIndex ? 0 : this._nextFrameIndex,
- d = this._currentFrame;
- 0 >= c ? (this._currentPercent = 1, d = 0) : (d += this._processScale * (a / this.animationInternal), this._currentPercent = d / c, d = ccs.fmodf(d, c));
- this._currentFrame = d;
- this.updateHandler()
- }
- },
- gotoFrame: function(a) {
- var c = this._loopType;
- c == ccs.ANIMATION_TYPE_NO_LOOP ? c = ccs.ANIMATION_TYPE_MAX : c == ccs.ANIMATION_TYPE_TO_LOOP_FRONT && (c = ccs.ANIMATION_TYPE_LOOP_FRONT);
- this._loopType = c;
- this._curFrameIndex = a;
- this._nextFrameIndex = this._durationTween
- },
- getCurrentFrameIndex: function() {
- return this._curFrameIndex = (this._rawDuration - 1) * this._currentPercent
- },
- updateHandler: function() {},
- isPause: function() {
- return this._isPause
- },
- isComplete: function() {
- return this._isComplete
- },
- getCurrentPercent: function() {
- return this._currentPercent
- },
- getRawDuration: function() {
- return this._rawDuration
- },
- getLoop: function() {
- return this._loopType
- },
- getTweenEasing: function() {
- return this._tweenEasing
- },
- getAnimationInternal: function() {
- return this.animationInternal
- },
- setAnimationInternal: function(a) {
- this.animationInternal = a
- },
- getProcessScale: function() {
- return this._processScale
- },
- setProcessScale: function(a) {
- this._processScale = a
- },
- isPlaying: function() {
- return this._isPlaying
- }
- });
- _p = ccs.ProcessBase.prototype;
- cc.defineGetterSetter(_p, "currentFrameIndex", _p.getCurrentFrameIndex);
- cc.defineGetterSetter(_p, "paused", _p.isPause);
- cc.defineGetterSetter(_p, "completed", _p.isComplete);
- cc.defineGetterSetter(_p, "currentPercent", _p.getCurrentPercent);
- cc.defineGetterSetter(_p, "rawDuration", _p.getRawDuration);
- cc.defineGetterSetter(_p, "loop", _p.getLoop);
- cc.defineGetterSetter(_p, "tweenEasing", _p.getTweenEasing);
- cc.defineGetterSetter(_p, "playing", _p.isPlaying);
- _p = null;
- ccs.MovementEventType = {
- start: 0,
- complete: 1,
- loopComplete: 2
- };
- ccs.AnimationEvent = ccs.Class.extend({
- _arguments: null,
- _callFunc: null,
- _selectorTarget: null,
- ctor: function(a, c, d) {
- this._data = d;
- this._callFunc = a;
- this._selectorTarget = c
- },
- call: function() {
- this._callFunc && this._callFunc.apply(this._selectorTarget, this._arguments)
- },
- setArguments: function(a) {
- this._arguments = a
- }
- });
- ccs.MovementEvent = function() {
- this.armature = null;
- this.movementID = this.movementType = ""
- };
- ccs.FrameEvent = function() {
- this.bone = null;
- this.frameEventName = "";
- this.currentFrameIndex = this.originFrameIndex = 0
- };
- ccs.ArmatureAnimation = ccs.ProcessBase.extend({
- _animationData: null,
- _movementData: null,
- _armature: null,
- _movementID: "",
- _toIndex: 0,
- _tweenList: null,
- _speedScale: 1,
- _ignoreFrameEvent: !1,
- _frameEventQueue: null,
- _movementEventQueue: null,
- _movementList: null,
- _onMovementList: !1,
- _movementListLoop: !1,
- _movementIndex: 0,
- _movementListDurationTo: -1,
- _movementEventCallFunc: null,
- _frameEventCallFunc: null,
- _movementEventTarget: null,
- _frameEventTarget: null,
- _movementEventListener: null,
- _frameEventListener: null,
- ctor: function() {
- ccs.ProcessBase.prototype.ctor.call(this);
- this._tweenList = [];
- this._movementList = [];
- this._frameEventQueue = [];
- this._movementEventQueue = []
- },
- init: function(a) {
- this._armature = a;
- this._tweenList.length = 0;
- return !0
- },
- pause: function() {
- for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].pause();
- ccs.ProcessBase.prototype.pause.call(this)
- },
- resume: function() {
- for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].resume();
- ccs.ProcessBase.prototype.resume.call(this)
- },
- stop: function() {
- for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].stop();
- a.length = 0;
- ccs.ProcessBase.prototype.stop.call(this)
- },
- setAnimationScale: function(a) {
- return this.setSpeedScale(a)
- },
- getAnimationScale: function() {
- return this.getSpeedScale()
- },
- setSpeedScale: function(a) {
- if (a != this._speedScale) {
- this._speedScale = a;
- this._processScale = !this._movementData ? this._speedScale : this._speedScale * this._movementData.scale;
- a = this._armature.getBoneDic();
- for (var c in a) {
- var d = a[c];
- d.getTween().setProcessScale(this._processScale);
- d.getChildArmature() && d.getChildArmature().getAnimation().setProcessScale(this._processScale)
- }
- }
- },
- getSpeedScale: function() {
- return this._speedScale
- },
- play: function(a, c, d) {
- cc.assert(this._animationData, "this.animationData can not be null");
- this._movementData = this._animationData.getMovement(a);
- cc.assert(this._movementData, "this._movementData can not be null");
- c = void 0 === c ? -1 : c;
- d = void 0 === d ? -1 : d;
- this._rawDuration = this._movementData.duration;
- this._movementID = a;
- this._processScale = this._speedScale * this._movementData.scale;
- c = -1 == c ? this._movementData.durationTo : c;
- a = 0 == this._movementData.durationTween ? this._rawDuration : this._movementData.durationTween;
- var e = this._movementData.tweenEasing;
- d = !d || 0 > d ? this._movementData.loop : d;
- this._onMovementList = !1;
- ccs.ProcessBase.prototype.play.call(this, c, a, d, e);
- 0 == this._rawDuration ? this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME : (this._loopType = d ? ccs.ANIMATION_TYPE_TO_LOOP_FRONT : ccs.ANIMATION_TYPE_NO_LOOP, this._durationTween = a);
- var f;
- this._tweenList = [];
- var g = this._armature.getBoneDic(),
- h;
- for (h in g) {
- var k = g[h];
- f = this._movementData.movBoneDataDic[k.getName()];
- var m = k.getTween();
- f && 0 < f.frameList.length ? (this._tweenList.push(m), f.duration = this._movementData.duration, m.play(f, c, a, d, e), m.setProcessScale(this._processScale), k.getChildArmature() && k.getChildArmature().getAnimation().setProcessScale(this._processScale)) : k.isIgnoreMovementBoneData() || (k.getDisplayManager().changeDisplayWithIndex(-1, !1), m.stop())
- }
- this._armature.update(0)
- },
- playByIndex: function(a, c, d, e, f) {
- cc.log("playByIndex is deprecated. Use playWithIndex instead.");
- this.playWithIndex(a, c, e)
- },
- playWithIndex: function(a, c, d) {
- var e = this._animationData.movementNames;
- cc.assert(-1 < a && a < e.length);
- this.play(e[a], c, d)
- },
- playWithNames: function(a, c, d) {
- this._movementListLoop = void 0 === d ? !0 : d;
- this._movementListDurationTo = void 0 === c ? -1 : c;
- this._onMovementList = !0;
- this._movementIndex = 0;
- a instanceof Array ? this._movementList = a : this._movementList.length = 0;
- this.updateMovementList()
- },
- playWithIndexes: function(a, c, d) {
- this._movementList.length = 0;
- this._movementListLoop = void 0 === d ? !0 : d;
- this._movementListDurationTo = void 0 === c ? -1 : c;
- this._onMovementList = !0;
- this._movementIndex = 0;
- c = this._animationData.movementNames;
- for (d = 0; d < a.length; d++) this._movementList.push(c[a[d]]);
- this.updateMovementList()
- },
- gotoAndPlay: function(a) {
- if (!this._movementData || 0 > a || a >= this._movementData.duration) cc.log("Please ensure you have played a movement, and the frameIndex is in the range.");
- else {
- var c = this._ignoreFrameEvent;
- this._isPlaying = this._ignoreFrameEvent = !0;
- this._isComplete = this._isPause = !1;
- ccs.ProcessBase.prototype.gotoFrame.call(this, a);
- this._currentPercent = this._curFrameIndex / (this._movementData.duration - 1);
- this._currentFrame = this._nextFrameIndex * this._currentPercent;
- for (var d = this._tweenList, e = 0; e < d.length; e++) d[e].gotoAndPlay(a);
- this._armature.update(0);
- this._ignoreFrameEvent = c
- }
- },
- gotoAndPause: function(a) {
- this.gotoAndPlay(a);
- this.pause()
- },
- getMovementCount: function() {
- return this._animationData.getMovementCount()
- },
- update: function(a) {
- ccs.ProcessBase.prototype.update.call(this, a);
- for (var c = this._tweenList, d = 0; d < c.length; d++) c[d].update(a);
- for (c = this._frameEventQueue; 0 < c.length;) a = c.shift(), this._ignoreFrameEvent = !0, this._frameEventCallFunc && this._frameEventCallFunc.call(this._frameEventTarget, a.bone, a.frameEventName, a.originFrameIndex, a.currentFrameIndex), this._frameEventListener && this._frameEventListener(a.bone, a.frameEventName, a.originFrameIndex, a.currentFrameIndex), this._ignoreFrameEvent = !1;
- for (c = this._movementEventQueue; 0 < c.length;) a = c.shift(), this._movementEventCallFunc && this._movementEventCallFunc.call(this._movementEventTarget, a.armature, a.movementType, a.movementID), this._movementEventListener && this._movementEventListener(a.armature, a.movementType, a.movementID)
- },
- updateHandler: function() {
- var a = this._currentPercent;
- if (1 <= a) {
- switch (this._loopType) {
- case ccs.ANIMATION_TYPE_NO_LOOP:
- this._loopType = ccs.ANIMATION_TYPE_MAX;
- this._currentFrame = (a - 1) * this._nextFrameIndex;
- a = this._currentFrame / this._durationTween;
- if (1 > a) {
- this._nextFrameIndex = this._durationTween;
- this.movementEvent(this._armature, ccs.MovementEventType.start, this._movementID);
- break
- }
- break;
- case ccs.ANIMATION_TYPE_MAX:
- case ccs.ANIMATION_TYPE_SINGLE_FRAME:
- a = 1;
- this._isComplete = !0;
- this._isPlaying = !1;
- this.movementEvent(this._armature, ccs.MovementEventType.complete, this._movementID);
- this.updateMovementList();
- break;
- case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:
- this._loopType = ccs.ANIMATION_TYPE_LOOP_FRONT;
- a = ccs.fmodf(a, 1);
- this._currentFrame = 0 == this._nextFrameIndex ? 0 : ccs.fmodf(this._currentFrame, this._nextFrameIndex);
- this._nextFrameIndex = 0 < this._durationTween ? this._durationTween : 1;
- this.movementEvent(this, ccs.MovementEventType.start, this._movementID);
- break;
- default:
- this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex), this._toIndex = 0, this.movementEvent(this._armature, ccs.MovementEventType.loopComplete, this._movementID)
- }
- this._currentPercent = a
- }
- },
- getCurrentMovementID: function() {
- return this._isComplete ? "" : this._movementID
- },
- setMovementEventCallFunc: function(a, c) {
- 1 == arguments.length ? this._frameEventListener = c : 2 == arguments.length && (this._movementEventTarget = c, this._movementEventCallFunc = a)
- },
- setFrameEventCallFunc: function(a, c) {
- 1 == arguments.length ? this._frameEventListener = c : 2 == arguments.length && (this._frameEventTarget = c, this._frameEventCallFunc = a)
- },
- setUserObject: function(a) {
- this._userObject = a
- },
- frameEvent: function(a, c, d, e) {
- if (this._frameEventTarget && this._frameEventCallFunc || this._frameEventListener) {
- var f = new ccs.FrameEvent;
- f.bone = a;
- f.frameEventName = c;
- f.originFrameIndex = d;
- f.currentFrameIndex = e;
- this._frameEventQueue.push(f)
- }
- },
- movementEvent: function(a, c, d) {
- if (this._movementEventTarget && this._movementEventCallFunc || this._movementEventListener) {
- var e = new ccs.MovementEvent;
- e.armature = a;
- e.movementType = c;
- e.movementID = d;
- this._movementEventQueue.push(e)
- }
- },
- updateMovementList: function() {
- if (this._onMovementList) {
- var a, c = this._movementList;
- this._movementListLoop ? (a = c[this._movementIndex], this.play(a, a.durationTo, 0), this._movementIndex++, this._movementIndex >= c.length && (this._movementIndex = 0)) : this._movementIndex < c.length ? (a = c[this._movementIndex], this.play(a, a.durationTo, 0), this._movementIndex++) : this._onMovementList = !1;
- this._onMovementList = !0
- }
- },
- setAnimationData: function(a) {
- this._animationData != a && (this._animationData = a)
- },
- getAnimationData: function() {
- return this._animationData
- },
- getUserObject: function() {
- return this._userObject
- },
- isIgnoreFrameEvent: function() {
- return this._ignoreFrameEvent
- }
- });
- _p = ccs.ArmatureAnimation.prototype;
- cc.defineGetterSetter(_p, "speedScale", _p.getSpeedScale, _p.setSpeedScale);
- cc.defineGetterSetter(_p, "animationScale", _p.getAnimationScale, _p.setAnimationScale);
- _p = null;
- ccs.ArmatureAnimation.create = function(a) {
- var c = new ccs.ArmatureAnimation;
- return c && c.init(a) ? c : null
- };
- ccs.Tween = ccs.ProcessBase.extend({
- _tweenData: null,
- _to: null,
- _from: null,
- _between: null,
- _movementBoneData: null,
- _bone: null,
- _frameTweenEasing: 0,
- _betweenDuration: 0,
- _totalDuration: 0,
- _toIndex: 0,
- _fromIndex: 0,
- _animation: null,
- _passLastFrame: !1,
- ctor: function() {
- ccs.ProcessBase.prototype.ctor.call(this);
- this._frameTweenEasing = ccs.TweenType.linear
- },
- init: function(a) {
- this._from = new ccs.FrameData;
- this._between = new ccs.FrameData;
- this._bone = a;
- this._tweenData = this._bone.getTweenData();
- this._tweenData.displayIndex = -1;
- this._animation = null != this._bone.getArmature() ? this._bone.getArmature().getAnimation() : null;
- return !0
- },
- play: function(a, c, d, e, f) {
- ccs.ProcessBase.prototype.play.call(this, c, d, e, f);
- this._loopType = e ? ccs.ANIMATION_TYPE_TO_LOOP_FRONT : ccs.ANIMATION_TYPE_NO_LOOP;
- this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
- f = a != this._movementBoneData;
- this.setMovementBoneData(a);
- this._rawDuration = this._movementBoneData.duration;
- a = this._movementBoneData.getFrameData(0);
- this._tweenData.displayIndex = a.displayIndex;
- this._bone.getArmature().getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED && (ccs.TransformHelp.nodeSub(this._tweenData, this._bone.getBoneData()), this._tweenData.scaleX += 1, this._tweenData.scaleY += 1);
- 0 == this._rawDuration ? (this._loopType = ccs.ANIMATION_TYPE_SINGLE_FRAME, 0 == c ? this.setBetween(a, a) : this.setBetween(this._tweenData, a), this._frameTweenEasing = ccs.TweenType.linear) : 1 < this._movementBoneData.frameList.length && (this._durationTween = d * this._movementBoneData.scale, e && 0 != this._movementBoneData.delay ? this.setBetween(this._tweenData, this.tweenNodeTo(this.updateFrameData(1 - this._movementBoneData.delay), this._between)) : !f || 0 == c ? this.setBetween(a, a) : this.setBetween(this._tweenData, a));
- this.tweenNodeTo(0)
- },
- gotoAndPlay: function(a) {
- ccs.ProcessBase.prototype.gotoFrame.call(this, a);
- this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
- this._isPlaying = !0;
- this._isComplete = this._isPause = !1;
- this._currentPercent = this._curFrameIndex / (this._rawDuration - 1);
- this._currentFrame = this._nextFrameIndex * this._currentPercent
- },
- gotoAndPause: function(a) {
- this.gotoAndPlay(a);
- this.pause()
- },
- updateHandler: function() {
- var a = this._currentPercent || 1,
- c = this._loopType;
- if (1 <= a) switch (c) {
- case ccs.ANIMATION_TYPE_SINGLE_FRAME:
- a = 1;
- this._isComplete = !0;
- this._isPlaying = !1;
- break;
- case ccs.ANIMATION_TYPE_NO_LOOP:
- c = ccs.ANIMATION_TYPE_MAX;
- a = 0 >= this._durationTween ? 1 : (a - 1) * this._nextFrameIndex / this._durationTween;
- 1 <= a ? (a = 1, this._isComplete = !0, this._isPlaying = !1) : (this._nextFrameIndex = this._durationTween, this._currentFrame = a * this._nextFrameIndex, this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0);
- break;
- case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:
- c = ccs.ANIMATION_TYPE_LOOP_FRONT;
- this._nextFrameIndex = 0 < this._durationTween ? this._durationTween : 1;
- 0 != this._movementBoneData.delay ? (this._currentFrame = (1 - this._movementBoneData.delay) * this._nextFrameIndex, a = this._currentFrame / this._nextFrameIndex) : this._currentFrame = a = 0;
- this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
- break;
- case ccs.ANIMATION_TYPE_MAX:
- a = 1;
- this._isComplete = !0;
- this._isPlaying = !1;
- break;
- default:
- this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex)
- }
- 1 > a && c < ccs.ANIMATION_TYPE_TO_LOOP_BACK && (a = Math.sin(a * cc.PI / 2));
- this._currentPercent = a;
- this._loopType = c;
- c > ccs.ANIMATION_TYPE_TO_LOOP_BACK && (a = this.updateFrameData(a));
- this._frameTweenEasing != ccs.TweenType.tweenEasingMax && this.tweenNodeTo(a)
- },
- setBetween: function(a, c, d) {
- void 0 === d && (d = !0);
- 0 > a.displayIndex && 0 <= c.displayIndex ? (this._from.copy(c), this._between.subtract(c, c, d)) : 0 > c.displayIndex && 0 <= a.displayIndex ? (this._from.copy(a), this._between.subtract(c, c, d)) : (this._from.copy(a), this._between.subtract(a, c, d));
- a.isTween || (this._tweenData.copy(a), this._tweenData.isTween = !0);
- this.arriveKeyFrame(a)
- },
- arriveKeyFrame: function(a) {
- if (a) {
- var c = this._bone,
- d = c.getDisplayManager(),
- e = a.displayIndex;
- d.getForceChangeDisplay() || d.changeDisplayWithIndex(e, !1);
- this._tweenData.zOrder = a.zOrder;
- c.updateZOrder();
- this._bone.setBlendFunc(a.blendFunc);
- (c = c.getChildArmature()) && "" != a.movement && c.getAnimation().play(a.movement)
- }
- },
- tweenNodeTo: function(a, c) {
- c || (c = this._tweenData);
- var d = this._from,
- e = this._between;
- d.isTween || (a = 0);
- c.x = d.x + a * e.x;
- c.y = d.y + a * e.y;
- c.scaleX = d.scaleX + a * e.scaleX;
- c.scaleY = d.scaleY + a * e.scaleY;
- c.skewX = d.skewX + a * e.skewX;
- c.skewY = d.skewY + a * e.skewY;
- this._bone.setTransformDirty(!0);
- c && e.isUseColorInfo && this.tweenColorTo(a, c);
- return c
- },
- tweenColorTo: function(a, c) {
- var d = this._from,
- e = this._between;
- c.a = d.a + a * e.a;
- c.r = d.r + a * e.r;
- c.g = d.g + a * e.g;
- c.b = d.b + a * e.b;
- this._bone.updateColor()
- },
- updateFrameData: function(a) {
- 1 < a && 0 != this._movementBoneData.delay && (a = ccs.fmodf(a, 1));
- a *= this._rawDuration - 1;
- var c, d, e = this._totalDuration,
- f = this._betweenDuration,
- g = this._toIndex;
- if (a < e || a >= e + f) {
- var f = this._movementBoneData.frameList,
- h = f.length;
- if (a < f[0].frameID) return c = d = f[0], this.setBetween(c, d), this._currentPercent;
- if (a >= f[h - 1].frameID) {
- if (this._passLastFrame) return c = d = f[h - 1], this.setBetween(c, d), this._currentPercent;
- this._passLastFrame = !0
- } else this._passLastFrame = !1;
- do
- if (this._fromIndex = g, c = f[this._fromIndex], e = c.frameID, g = this._fromIndex + 1, g >= h && (g = 0), d = f[g], c.strEvent && !this._animation.isIgnoreFrameEvent() && this._animation.frameEvent(this._bone, c.strEvent, c.frameID, a), a == c.frameID || this._passLastFrame && this._fromIndex == h - 1) break;
- while (a < c.frameID || a >= d.frameID);
- f = d.frameID - c.frameID;
- this._frameTweenEasing = c.tweenEasing;
- this.setBetween(c, d, !1);
- this._totalDuration = e;
- this._betweenDuration = f;
- this._toIndex = g
- }
- a = 0 == f ? 0 : (a - this._totalDuration) / this._betweenDuration;
- c = this._frameTweenEasing != ccs.TweenType.linear ? this._frameTweenEasing : this._tweenEasing;
- c != ccs.TweenType.tweenEasingMax && (c != ccs.TweenType.linear && !this._passLastFrame) && (a = ccs.TweenFunction.tweenTo(a, c, this._from.easingParams));
- return a
- },
- setAnimation: function(a) {
- this._animation = a
- },
- getAnimation: function() {
- return this._animation
- },
- setMovementBoneData: function(a) {
- this._movementBoneData = a
- }
- });
- _p = ccs.Tween.prototype;
- cc.defineGetterSetter(_p, "animation", _p.getAnimation, _p.setAnimation);
- _p = null;
- ccs.Tween.create = function(a) {
- var c = new ccs.Tween;
- return c && c.init(a) ? c : null
- };
- ccs.PT_RATIO = 32;
- ccs.ColliderFilter = ccs.Class.extend({
- _collisionType: 0,
- _group: 0,
- _categoryBits: 0,
- _groupIndex: 0,
- _maskBits: 0,
- ctor: function(a, c) {
- this._collisionType = a || 0;
- this._group = c || 0
- },
- updateShape: function(a) {
- if (a instanceof cp.Shape) a.collision_type = this._collisionType, a.group = this._group;
- else if (a instanceof Box2D.b2FilterData) {
- var c = new Box2D.b2FilterData;
- c.categoryBits = this._categoryBits;
- c.groupIndex = this._groupIndex;
- c.maskBits = this._maskBits;
- a.SetFilterData(c)
- }
- }
- });
- ccs.ColliderBody = ccs.Class.extend({
- shape: null,
- coutourData: null,
- colliderFilter: null,
- _calculatedVertexList: null,
- ctor: function(a) {
- this.shape = null;
- this.coutourData = a;
- this.colliderFilter = new ccs.ColliderFilter;
- ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX && (this._calculatedVertexList = [])
- },
- getContourData: function() {
- return this.coutourData
- },
- setColliderFilter: function(a) {
- this.colliderFilter = a
- },
- getCalculatedVertexList: function() {
- return this._calculatedVertexList
- },
- setB2Fixture: function(a) {
- this._fixture = a
- },
- getB2Fixture: function() {
- return this._fixture
- },
- setShape: function(a) {
- this.shape = a
- },
- getShape: function() {
- return this.shape
- },
- setContourData: function(a) {
- this.coutourData = a
- },
- getColliderFilter: function() {
- return this.colliderFilter
- }
- });
- ccs.ColliderDetector = ccs.Class.extend({
- _colliderBodyList: null,
- _bone: null,
- _body: null,
- _active: !1,
- _filter: null,
- helpPoint: cc.p(0, 0),
- ctor: function() {
- this._colliderBodyList = [];
- this._body = this._bone = null;
- this._active = !1;
- this._filter = null
- },
- init: function(a) {
- this._colliderBodyList.length = 0;
- a && (this._bone = a);
- this._filter = new ccs.ColliderFilter;
- return !0
- },
- addContourData: function(a) {
- var c = new ccs.ColliderBody(a);
- this._colliderBodyList.push(c);
- if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
- c = c.getCalculatedVertexList();
- a = a.vertexList;
- for (var d = 0; d < a.length; d++) {
- var e = new ccs.ContourVertex2(0, 0);
- c.push(e)
- }
- }
- },
- addContourDataList: function(a) {
- for (var c = 0; c < a.length; c++) this.addContourData(a[c])
- },
- removeContourData: function(a) {
- var c = [],
- d, e = this._colliderBodyList;
- for (d = 0; d < e.length; d++) {
- var f = e[d];
- f && f.getContourData() == a && c.push(f)
- }
- for (d = 0; d < c.length; d++) cc.arrayRemoveObject(e, c[d])
- },
- removeAll: function() {
- this._colliderBodyList.length = 0
- },
- setActive: function(a) {
- if (this._active != a) {
- this._active = a;
- a = this._body;
- var c;
- if (a)
- if (c = null, this._active)
- for (var d = 0; d < this._colliderBodyList.length; d++) c = this._colliderBodyList[d], c = c.getShape(), a.space.addShape(c);
- else
- for (d = 0; d < this._colliderBodyList.length; d++) c = this._colliderBodyList[d], c = c.getShape(), a.space.removeShape(c)
- }
- },
- getActive: function() {
- return this._active
- },
- getColliderBodyList: function() {
- return this._colliderBodyList
- },
- setColliderFilter: function(a) {
- this._filter = a;
- for (var c = this._colliderBodyList, d = 0; d < c.length; d++) {
- var e = c[d];
- e.setColliderFilter(a);
- e.getShape() && e.getColliderFilter().updateShape(e.getShape())
- }
- },
- getColliderFilter: function() {
- return this._filter
- },
- updateTransform: function(a) {
- if (this._active)
- for (var c = null, d = this._body, e = this.helpPoint, f = 0; f < this._colliderBodyList.length; f++) {
- var c = this._colliderBodyList[f],
- g = c.getContourData(),
- h = null;
- d && (h = c.getShape());
- for (var g = g.vertexList, k = c.getCalculatedVertexList(), c = 0; c < g.length; c++) {
- e.x = g[c].x;
- e.y = g[c].y;
- e = cc.pointApplyAffineTransform(e, a);
- if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
- var m = cc.p(0, 0);
- m.x = e.x;
- m.y = e.y;
- k[c] = m
- }
- h && (h.verts[2 * c] = e.x, h.verts[2 * c + 1] = e.y)
- }
- if (h)
- for (c = 0; c < g.length; c++) k = cp.v.normalize(cp.v.perp(cp.v.sub(h.verts[(c + 1) % h.verts.length], h.verts[c]))), h.axes[c].n = k, h.axes[c].d = cp.v.dot(k, h.verts[c])
- }
- },
- setBody: function(a) {
- this._body = a;
- for (var c = this._colliderBodyList, d = 0; d < c.length; d++) {
- a = c[d];
- for (var e = [], f = a.getContourData().vertexList, g = 0; g < f.length; g++) {
- var h = f[g];
- e.push(h.x);
- e.push(h.y)
- }
- e = new cp.PolyShape(this._body, e, cp.vzero);
- e.sensor = !0;
- e.data = this._bone;
- this._active && this._body.space.addShape(e);
- a.setShape(e);
- a.getColliderFilter().updateShape(e)
- }
- },
- getBody: function() {
- return this._body
- }
- });
- _p = ccs.ColliderDetector.prototype;
- cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setColliderFilter);
- cc.defineGetterSetter(_p, "active", _p.getActive, _p.setActive);
- cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
- _p = null;
- ccs.ColliderDetector.create = function(a) {
- var c = new ccs.ColliderDetector;
- return c && c.init(a) ? c : null
- };
- ccs.Armature = ccs.Node.extend({
- animation: null,
- armatureData: null,
- batchNode: null,
- _textureAtlas: null,
- _parentBone: null,
- _boneDic: null,
- _topBoneList: null,
- _armatureIndexDic: null,
- _offsetPoint: null,
- version: 0,
- _armatureTransformDirty: !0,
- _body: null,
- _blendFunc: null,
- _className: "Armature",
- _realAnchorPointInPoints: null,
- ctor: function(a, c) {
- cc.Node.prototype.ctor.call(this);
- this._name = "";
- this._topBoneList = [];
- this._armatureIndexDic = {};
- this._offsetPoint = cc.p(0, 0);
- this._armatureTransformDirty = !0;
- this._realAnchorPointInPoints = cc.p(0, 0);
- a && ccs.Armature.prototype.init.call(this, a, c)
- },
- init: function(a, c) {
- cc.Node.prototype.init.call(this);
- c && (this._parentBone = c);
- this.removeAllChildren();
- this.animation = new ccs.ArmatureAnimation;
- this.animation.init(this);
- this._boneDic = {};
- this._topBoneList.length = 0;
- this._blendFunc = {
- src: cc.BLEND_SRC,
- dst: cc.BLEND_DST
- };
- this._name = a || "";
- var d = ccs.armatureDataManager,
- e;
- if ("" != a) {
- e = d.getAnimationData(a);
- cc.assert(e, "AnimationData not exist!");
- this.animation.setAnimationData(e);
- d = d.getArmatureData(a);
- cc.assert(d, "ArmatureData not exist!");
- this.armatureData = d;
- var d = d.getBoneDataDic(),
- f;
- for (f in d) {
- var d = this.createBone(String(f)),
- g = e.getMovement(e.movementNames[0]);
- if (g && (g = g.getMovementBoneData(d.getName())) && !(0 >= g.frameList.length))
- if (g = g.getFrameData(0)) d.getTweenData().copy(g), d.changeDisplayWithIndex(g.displayIndex, !1)
- }
- this.update(0);
- this.updateOffsetPoint()
- } else this._name = "new_armature", this.armatureData = ccs.ArmatureData.create(), this.armatureData.name = this._name, e = ccs.AnimationData.create(), e.name = this._name, d.addArmatureData(this._name, this.armatureData), d.addAnimationData(this._name, e), this.animation.setAnimationData(e);
- cc._renderType === cc._RENDER_TYPE_WEBGL && this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR));
- this.setCascadeOpacityEnabled(!0);
- this.setCascadeColorEnabled(!0);
- return !0
- },
- createBone: function(a) {
- var c = this.getBone(a);
- if (c) return c;
- var c = this.armatureData.getBoneData(a),
- d = c.parentName,
- e = null;
- d ? (this.createBone(d), e = ccs.Bone.create(a), this.addBone(e, d)) : (e = ccs.Bone.create(a), this.addBone(e, ""));
- e.setBoneData(c);
- e.getDisplayManager().changeDisplayWithIndex(-1, !1);
- return e
- },
- addBone: function(a, c) {
- cc.assert(a, "Argument must be non-nil");
- var d = this._boneDic;
- a.getName() && cc.assert(!d[a.getName()], "bone already added. It can't be added again");
- if (c) {
- var e = d[c];
- e ? e.addChildBone(a) : this._topBoneList.push(a)
- } else this._topBoneList.push(a);
- a.setArmature(this);
- d[a.getName()] = a;
- this.addChild(a)
- },
- removeBone: function(a, c) {
- cc.assert(a, "bone must be added to the bone dictionary!");
- a.setArmature(null);
- a.removeFromParent(c);
- cc.arrayRemoveObject(this._topBoneList, a);
- delete this._boneDic[a.getName()];
- this.removeChild(a, !0)
- },
- getBone: function(a) {
- return this._boneDic[a]
- },
- changeBoneParent: function(a, c) {
- cc.assert(a, "bone must be added to the bone dictionary!");
- var d = a.getParentBone();
- d && (cc.arrayRemoveObject(d.getChildren(), a), a.setParentBone(null));
- c && ((d = this._boneDic[c]) ? (d.addChildBone(a), cc.arrayRemoveObject(this._topBoneList, a)) : this._topBoneList.push(a))
- },
- getBoneDic: function() {
- return this._boneDic
- },
- updateOffsetPoint: function() {
- var a = this.getBoundingBox();
- this.setContentSize(a);
- var c = this._offsetPoint;
- c.x = -a.x;
- c.y = -a.y;
- 0 != a.width && 0 != a.height && this.setAnchorPoint(c.x / a.width, c.y / a.height)
- },
- setAnchorPoint: function(a, c) {
- var d, e;
- void 0 !== c ? (d = a, e = c) : (d = a.x, e = a.y);
- var f = this._anchorPoint;
- if (d != f.x || e != f.y) {
- var g = this._contentSize;
- f.x = d;
- f.y = e;
- this._anchorPointInPoints.x = g.width * f.x - this._offsetPoint.x;
- this._anchorPointInPoints.y = g.height * f.y - this._offsetPoint.y;
- this._realAnchorPointInPoints.x = g.width * f.x;
- this._realAnchorPointInPoints.y = g.height * f.y;
- this.setNodeDirty()
- }
- },
- _setAnchorX: function(a) {
- this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._anchorPointInPoints.x = this._contentSize.width * a - this._offsetPoint.x, this._realAnchorPointInPoints.x = this._contentSize.width * a, this.setNodeDirty())
- },
- _setAnchorY: function(a) {
- this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a - this._offsetPoint.y, this._realAnchorPointInPoints.y = this._contentSize.height * a, this.setNodeDirty())
- },
- getAnchorPointInPoints: function() {
- return this._realAnchorPointInPoints
- },
- setAnimation: function(a) {
- this.animation = a
- },
- getAnimation: function() {
- return this.animation
- },
- getArmatureTransformDirty: function() {
- return this._armatureTransformDirty
- },
- update: function(a) {
- this.animation.update(a);
- for (var c = this._topBoneList, d = 0; d < c.length; d++) c[d].update(a);
- this._armatureTransformDirty = !1
- },
- draw: function(a) {
- for (var c = this._children, d = cc.BlendFunc.ALPHA_PREMULTIPLIED, e = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED, f = 0, g = c.length; f < g; f++) {
- var h = c[f];
- if (h) {
- var k = h.getDisplayRenderNode();
- if (null != k) switch (h.getDisplayRenderNodeType()) {
- case ccs.DISPLAY_TYPE_SPRITE:
- if (k instanceof ccs.Skin)
- if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
- k.updateTransform();
- var m = h.getBlendFunc();
- m.src != d.src || m.dst != d.dst ? k.setBlendFunc(h.getBlendFunc()) : this._blendFunc.src == d.src && this._blendFunc.dst == d.dst && !k.getTexture().hasPremultipliedAlpha() ? k.setBlendFunc(e) : k.setBlendFunc(this._blendFunc);
- k.draw(a)
- } else k.visit(a);
- break;
- case ccs.DISPLAY_TYPE_ARMATURE:
- k.draw(a);
- break;
- default:
- k.visit(a)
- }
- } else h instanceof cc.Node && h.visit(a)
- }
- },
- onEnter: function() {
- cc.Node.prototype.onEnter.call(this);
- this.scheduleUpdate()
- },
- onExit: function() {
- cc.Node.prototype.onExit.call(this);
- this.unscheduleUpdate()
- },
- visit: null,
- _visitForCanvas: function(a) {
- var c = a || cc._renderContext;
- this._visible && (c.save(), this.transform(c), this.sortAllChildren(), this.draw(a), this._cacheDirty = !1, this.arrivalOrder = 0, c.restore())
- },
- _visitForWebGL: function() {
- if (this._visible) {
- var a = cc._renderContext,
- c = cc.current_stack;
- c.stack.push(c.top);
- cc.kmMat4Assign(this._stackMatrix, c.top);
- c.top = this._stackMatrix;
- this.transform();
- this.sortAllChildren();
- this.draw(a);
- this.arrivalOrder = 0;
- c.top = c.stack.pop()
- }
- },
- getBoundingBox: function() {
- for (var a, c, d, e = 0, f = !0, g = cc.rect(0, 0, 0, 0), h = this._children, k = h.length, m = 0; m < k; m++)
- if (a = h[m]) e = a.getDisplayManager().getBoundingBox(), 0 == e.x && 0 == e.y && 0 == e.width && 0 == e.height || (f ? (a = e.x, c = e.y, d = e.x + e.width, e = e.y + e.height, f = !1) : (a = e.x < g.x ? e.x : g.x, c = e.y < g.y ? e.y : g.y, d = e.x + e.width > g.x + g.width ? e.x + e.width : g.x + g.width, e = e.y + e.height > g.y + g.height ? e.y + e.height : g.y + g.height), g.x = a, g.y = c, g.width = d - a, g.height = e - c);
- return cc.rectApplyAffineTransform(g, this.getNodeToParentTransform())
- },
- getBoneAtPoint: function(a, c) {
- for (var d = this._children, e = d.length - 1; 0 <= e; e--) {
- var f = d[e];
- if (f instanceof ccs.Bone && f.getDisplayManager().containPoint(a, c)) return f
- }
- return null
- },
- setParentBone: function(a) {
- this._parentBone = a;
- a = this._boneDic;
- for (var c in a) a[c].setArmature(this)
- },
- getParentBone: function() {
- return this._parentBone
- },
- drawContour: function() {
- cc._drawingUtil.setDrawColor(255, 255, 255, 255);
- cc._drawingUtil.setLineWidth(1);
- var a = this._boneDic,
- c;
- for (c in a) {
- var d = a[c].getColliderDetector();
- if (d)
- for (var d = d.getColliderBodyList(), e = 0; e < d.length; e++) {
- var f = d[e].getCalculatedVertexList();
- cc._drawingUtil.drawPoly(f, f.length, !0)
- }
- }
- },
- setBody: function(a) {
- if (this._body != a) {
- this._body = a;
- this._body.data = this;
- var c, d;
- a = this._children;
- for (var e = 0; e < a.length; e++)
- if (c = a[e], c instanceof ccs.Bone) {
- c = c.getDisplayManager().getDecorativeDisplayList();
- for (var f = 0; f < c.length; f++) d = c[f], (d = d.getColliderDetector()) && d.setBody(this._body)
- }
- }
- },
- getShapeList: function() {
- return this._body ? this._body.shapeList : null
- },
- getBody: function() {
- return this._body
- },
- setBlendFunc: function(a) {
- this._blendFunc = a
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setColliderFilter: function(a) {
- var c = this._boneDic,
- d;
- for (d in c) c[d].setColliderFilter(a)
- },
- getArmatureData: function() {
- return this.armatureData
- },
- setArmatureData: function(a) {
- this.armatureData = a
- },
- getBatchNode: function() {
- return this.batchNode
- },
- setBatchNode: function(a) {
- this.batchNode = a
- },
- getVersion: function() {
- return this.version
- },
- setVersion: function(a) {
- this.version = a
- }
- });
- ccs.Armature.prototype.visit = cc._renderType == cc._RENDER_TYPE_WEBGL ? ccs.Armature.prototype._visitForWebGL : ccs.Armature.prototype._visitForCanvas;
- _p = ccs.Armature.prototype;
- cc.defineGetterSetter(_p, "parentBone", _p.getParentBone, _p.setParentBone);
- cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
- cc.defineGetterSetter(_p, "colliderFilter", null, _p.setColliderFilter);
- _p = null;
- ccs.Armature.create = function(a, c) {
- var d = new ccs.Armature;
- return d.init(a, c) ? d : null
- };
- ccs.Bone = ccs.Node.extend({
- _boneData: null,
- _armature: null,
- _childArmature: null,
- _displayManager: null,
- ignoreMovementBoneData: !1,
- _tween: null,
- _tweenData: null,
- _parentBone: null,
- _boneTransformDirty: !1,
- _worldTransform: null,
- _blendFunc: 0,
- blendDirty: !1,
- _worldInfo: null,
- _armatureParentBone: null,
- _dataVersion: 0,
- _className: "Bone",
- ctor: function() {
- cc.Node.prototype.ctor.call(this);
- this._displayManager = this._tween = this._boneData = this._childArmature = this._armature = this._parentBone = this._tweenData = null;
- this.ignoreMovementBoneData = !1;
- this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
- this._boneTransformDirty = !0;
- this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
- this.blendDirty = !1;
- this._armatureParentBone = this._worldInfo = null;
- this._dataVersion = 0
- },
- init: function(a) {
- a && (this._name = a);
- this._tweenData = new ccs.FrameData;
- this._tween = new ccs.Tween;
- this._tween.init(this);
- this._displayManager = new ccs.DisplayManager;
- this._displayManager.init(this);
- this._worldInfo = new ccs.BaseData;
- this._boneData = new ccs.BaseData;
- return !0
- },
- setBoneData: function(a) {
- cc.assert(a, "_boneData must not be null");
- this._boneData != a && (this._boneData = a);
- this.setName(this._boneData.name);
- this._localZOrder = this._boneData.zOrder;
- this._displayManager.initDisplayList(a)
- },
- getBoneData: function() {
- return this._boneData
- },
- setArmature: function(a) {
- (this._armature = a) ? (this._tween.setAnimation(this._armature.getAnimation()), this._dataVersion = this._armature.getArmatureData().dataVersion, this._armatureParentBone = this._armature.getParentBone()) : this._armatureParentBone = null
- },
- getArmature: function() {
- return this._armature
- },
- update: function(a) {
- this._parentBone && (this._boneTransformDirty = this._boneTransformDirty || this._parentBone.isTransformDirty());
- this._armatureParentBone && !this._boneTransformDirty && (this._boneTransformDirty = this._armatureParentBone.isTransformDirty());
- if (this._boneTransformDirty) {
- var c = this._tweenData;
- this._dataVersion >= ccs.CONST_VERSION_COMBINED && (ccs.TransformHelp.nodeConcat(c, this._boneData), c.scaleX -= 1, c.scaleY -= 1);
- var d = this._worldInfo;
- d.copy(c);
- d.x = c.x + this._position.x;
- d.y = c.y + this._position.y;
- d.scaleX = c.scaleX * this._scaleX;
- d.scaleY = c.scaleY * this._scaleY;
- d.skewX = c.skewX + this._skewX + this._rotationX;
- d.skewY = c.skewY + this._skewY - this._rotationY;
- this._parentBone ? this.applyParentTransform(this._parentBone) : this._armatureParentBone && this.applyParentTransform(this._armatureParentBone);
- ccs.TransformHelp.nodeToMatrix(d, this._worldTransform);
- this._armatureParentBone && (this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()))
- }
- ccs.displayFactory.updateDisplay(this, a, this._boneTransformDirty || this._armature.getArmatureTransformDirty());
- for (c = 0; c < this._children.length; c++) this._children[c].update(a);
- this._boneTransformDirty = !1
- },
- applyParentTransform: function(a) {
- var c = this._worldInfo,
- d = a._worldTransform;
- a = a._worldInfo;
- var e = c.x,
- f = c.y;
- c.x = e * d.a + f * d.c + a.x;
- c.y = e * d.b + f * d.d + a.y;
- c.scaleX *= a.scaleX;
- c.scaleY *= a.scaleY;
- c.skewX += a.skewX;
- c.skewY += a.skewY
- },
- setBlendFunc: function(a) {
- if (this._blendFunc.src != a.src || this._blendFunc.dst != a.dst) this._blendFunc = a, this.blendDirty = !0
- },
- updateDisplayedColor: function(a) {
- this._realColor = cc.color(255, 255, 255);
- cc.Node.prototype.updateDisplayedColor.call(this, a)
- },
- updateDisplayedOpacity: function(a) {
- this._realOpacity = 255;
- cc.Node.prototype.updateDisplayedOpacity.call(this, a)
- },
- updateColor: function() {
- var a = this._displayManager.getDisplayRenderNode();
- null != a && (a.setColor(cc.color(this._displayedColor.r * this._tweenData.r / 255, this._displayedColor.g * this._tweenData.g / 255, this._displayedColor.b * this._tweenData.b / 255)), a.setOpacity(this._displayedOpacity * this._tweenData.a / 255))
- },
- updateZOrder: function() {
- this._armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED ? this.setLocalZOrder(this._tweenData.zOrder + this._boneData.zOrder) : this.setLocalZOrder(this._tweenData.zOrder)
- },
- addChildBone: function(a) {
- cc.assert(a, "Argument must be non-nil");
- cc.assert(!a.parentBone, "child already added. It can't be added again");
- 0 > this._children.indexOf(a) && (this._children.push(a), a.setParentBone(this))
- },
- removeChildBone: function(a, c) {
- if (0 < this._children.length && -1 != this._children.getIndex(a)) {
- if (c)
- for (var d = a._children, e = 0; e < d.length; e++) a.removeChildBone(d[e], c);
- a.setParentBone(null);
- a.getDisplayManager().setCurrentDecorativeDisplay(null);
- cc.arrayRemoveObject(this._children, a)
- }
- },
- removeFromParent: function(a) {
- this._parentBone && this._parentBone.removeChildBone(this, a)
- },
- setParentBone: function(a) {
- this._parentBone = a
- },
- getParentBone: function() {
- return this._parentBone
- },
- setChildArmature: function(a) {
- this._childArmature != a && (null == a && this._childArmature && this._childArmature.setParentBone(null), this._childArmature = a)
- },
- getChildArmature: function() {
- return this._childArmature
- },
- getTween: function() {
- return this._tween
- },
- setLocalZOrder: function(a) {
- this._localZOrder != a && cc.Node.prototype.setLocalZOrder.call(this, a)
- },
- getNodeToArmatureTransform: function() {
- return this._worldTransform
- },
- getNodeToWorldTransform: function() {
- return cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToWorldTransform())
- },
- getDisplayRenderNode: function() {
- return this._displayManager.getDisplayRenderNode()
- },
- getDisplayRenderNodeType: function() {
- return this._displayManager.getDisplayRenderNodeType()
- },
- addDisplay: function(a, c) {
- return this._displayManager.addDisplay(a, c || 0)
- },
- removeDisplay: function(a) {
- this._displayManager.removeDisplay(a)
- },
- changeDisplayByIndex: function(a, c) {
- cc.log("changeDisplayByIndex is deprecated. Use changeDisplayWithIndex instead.");
- this.changeDisplayWithIndex(a, c)
- },
- changeDisplayByName: function(a, c) {
- this.changeDisplayWithName(a, c)
- },
- changeDisplayWithIndex: function(a, c) {
- this._displayManager.changeDisplayWithIndex(a, c)
- },
- changeDisplayWithName: function(a, c) {
- this._displayManager.changeDisplayWithName(a, c)
- },
- getColliderDetector: function() {
- var a = this._displayManager.getCurrentDecorativeDisplay();
- return a && (a = a.getColliderDetector()) ? a : null
- },
- setColliderFilter: function(a) {
- for (var c = this._displayManager.getDecorativeDisplayList(), d = 0; d < c.length; d++) {
- var e = c[d].getColliderDetector();
- e && e.setColliderFilter(a)
- }
- },
- getColliderFilter: function() {
- var a = this.displayManager.getCurrentDecorativeDisplay();
- return a && (a = a.getColliderDetector()) ? a.getColliderFilter() : null
- },
- setTransformDirty: function(a) {
- this._boneTransformDirty = a
- },
- isTransformDirty: function() {
- return this._boneTransformDirty
- },
- getDisplayManager: function() {
- return this._displayManager
- },
- setIgnoreMovementBoneData: function(a) {
- this._ignoreMovementBoneData = a
- },
- isIgnoreMovementBoneData: function() {
- return this._ignoreMovementBoneData
- },
- getBlendFunc: function() {
- return this._blendFunc
- },
- setBlendDirty: function(a) {
- this._blendDirty = a
- },
- isBlendDirty: function() {
- return this._blendDirty
- },
- getTweenData: function() {
- return this._tweenData
- },
- getWorldInfo: function() {
- return this._worldInfo
- },
- getChildrenBone: function() {
- return this._children
- },
- nodeToArmatureTransform: function() {
- return this.getNodeToArmatureTransform()
- },
- nodeToWorldTransform: function() {
- return this.getNodeToWorldTransform()
- },
- getColliderBodyList: function() {
- var a = this.getColliderDetector();
- return a ? a.getColliderBodyList() : null
- },
- getIgnoreMovementBoneData: function() {
- return this.isIgnoreMovementBoneData()
- }
- });
- _p = ccs.Bone.prototype;
- cc.defineGetterSetter(_p, "boneData", _p.getBoneData, _p.setBoneData);
- cc.defineGetterSetter(_p, "armature", _p.getArmature, _p.setArmature);
- cc.defineGetterSetter(_p, "childArmature", _p.getChildArmature, _p.setChildArmature);
- cc.defineGetterSetter(_p, "childrenBone", _p.getChildrenBone);
- cc.defineGetterSetter(_p, "tween", _p.getTween);
- cc.defineGetterSetter(_p, "tweenData", _p.getTweenData);
- cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setColliderFilter);
- _p = null;
- ccs.Bone.create = function(a) {
- var c = new ccs.Bone;
- return c && c.init(a) ? c : null
- };
- ccs.FRAME_TYPE_MOVE = 0;
- ccs.FRAME_TYPE_SCALE = 1;
- ccs.FRAME_TYPE_ROTATE = 2;
- ccs.FRAME_TYPE_TINT = 3;
- ccs.FRAME_TYPE_FADE = 4;
- ccs.FRAME_TYPE_MAX = 5;
- ccs.FrameEaseType = {
- Custom: -1,
- Linear: 0,
- Sine_EaseIn: 1,
- Sine_EaseOut: 2,
- Sine_EaseInOut: 3,
- Quad_EaseIn: 4,
- Quad_EaseOut: 5,
- Quad_EaseInOut: 6,
- Cubic_EaseIn: 7,
- Cubic_EaseOut: 8,
- Cubic_EaseInOut: 9,
- Quart_EaseIn: 10,
- Quart_EaseOut: 11,
- Quart_EaseInOut: 12,
- Quint_EaseIn: 13,
- Quint_EaseOut: 14,
- Quint_EaseInOut: 15,
- Expo_EaseIn: 16,
- Expo_EaseOut: 17,
- Expo_EaseInOut: 18,
- Circ_EaseIn: 19,
- Circ_EaseOut: 20,
- Circ_EaseInOut: 21,
- Elastic_EaesIn: 22,
- Elastic_EaesOut: 23,
- Elastic_EaesInOut: 24,
- Back_EaseIn: 25,
- Back_EaseOut: 26,
- Back_EaseInOut: 27,
- Bounce_EaseIn: 28,
- Bounce_EaseOut: 29,
- Bounce_EaseInOut: 30
- };
- ccs.ActionFrame = ccs.Class.extend({
- frameType: 0,
- easingType: 0,
- frameIndex: 0,
- frameTweenParameter: null,
- time: 0,
- ctor: function() {
- this.time = this.frameIndex = this.easingType = this.frameType = 0
- },
- getAction: function(a) {
- return null
- },
- _getEasingAction: function(a) {
- if (null === a) return console.error("Action cannot be null!"), null;
- var c;
- switch (this.easingType) {
- case ccs.FrameEaseType.Linear:
- c = a;
- break;
- case ccs.FrameEaseType.Sine_EaseIn:
- c = a.easing(cc.easeSineIn());
- break;
- case ccs.FrameEaseType.Sine_EaseOut:
- c = a.easing(cc.easeSineOut());
- break;
- case ccs.FrameEaseType.Sine_EaseInOut:
- c = a.easing(cc.easeSineInOut());
- break;
- case ccs.FrameEaseType.Quad_EaseIn:
- c = a.easing(cc.easeQuadraticActionIn());
- break;
- case ccs.FrameEaseType.Quad_EaseOut:
- c = a.easing(cc.easeQuadraticActionOut());
- break;
- case ccs.FrameEaseType.Quad_EaseInOut:
- c = a.easing(cc.easeQuadraticActionInOut());
- break;
- case ccs.FrameEaseType.Cubic_EaseIn:
- c = a.easing(cc.easeCubicActionIn());
- break;
- case ccs.FrameEaseType.Cubic_EaseOut:
- c = a.easing(cc.easeCubicActionOut());
- break;
- case ccs.FrameEaseType.Cubic_EaseInOut:
- c = a.easing(cc.easeCubicActionInOut());
- break;
- case ccs.FrameEaseType.Quart_EaseIn:
- c = a.easing(cc.easeQuarticActionIn());
- break;
- case ccs.FrameEaseType.Quart_EaseOut:
- c = a.easing(cc.easeQuarticActionOut());
- break;
- case ccs.FrameEaseType.Quart_EaseInOut:
- c = a.easing(cc.easeQuarticActionInOut());
- break;
- case ccs.FrameEaseType.Quint_EaseIn:
- c = a.easing(cc.easeQuinticActionIn());
- break;
- case ccs.FrameEaseType.Quint_EaseOut:
- c = a.easing(cc.easeQuinticActionOut());
- break;
- case ccs.FrameEaseType.Quint_EaseInOut:
- c = a.easing(cc.easeQuinticActionInOut());
- break;
- case ccs.FrameEaseType.Expo_EaseIn:
- c = a.easing(cc.easeExponentialIn());
- break;
- case ccs.FrameEaseType.Expo_EaseOut:
- c = a.easing(cc.easeExponentialOut());
- break;
- case ccs.FrameEaseType.Expo_EaseInOut:
- c = a.easing(cc.easeExponentialInOut());
- break;
- case ccs.FrameEaseType.Circ_EaseIn:
- c = a.easing(cc.easeCircleActionIn());
- break;
- case ccs.FrameEaseType.Circ_EaseOut:
- c = a.easing(cc.easeCircleActionOut());
- break;
- case ccs.FrameEaseType.Circ_EaseInOut:
- c = a.easing(cc.easeCircleActionInOut());
- break;
- case ccs.FrameEaseType.Elastic_EaesIn:
- c = a.easing(cc.easeElasticIn());
- break;
- case ccs.FrameEaseType.Elastic_EaesOut:
- c = a.easing(cc.easeElasticOut());
- break;
- case ccs.FrameEaseType.Elastic_EaesInOut:
- c = a.easing(cc.easeElasticInOut());
- break;
- case ccs.FrameEaseType.Back_EaseIn:
- c = a.easing(cc.easeBackIn());
- break;
- case ccs.FrameEaseType.Back_EaseOut:
- c = a.easing(cc.easeBackOut());
- break;
- case ccs.FrameEaseType.Back_EaseInOut:
- c = a.easing(cc.easeBackInOut());
- break;
- case ccs.FrameEaseType.Bounce_EaseIn:
- c = a.easing(cc.easeBounceIn());
- break;
- case ccs.FrameEaseType.Bounce_EaseOut:
- c = a.easing(cc.easeBounceOut());
- break;
- case ccs.FrameEaseType.Bounce_EaseInOut:
- c = a.easing(cc.easeBounceInOut())
- }
- return c
- },
- setEasingParameter: function(a) {
- this._Parameter = [];
- for (var c = 0; c < a.length; c++) this._Parameter.push(a[c])
- },
- setEasingType: function(a) {
- this._easingType = a
- }
- });
- ccs.ActionMoveFrame = ccs.ActionFrame.extend({
- _position: null,
- ctor: function() {
- ccs.ActionFrame.prototype.ctor.call(this);
- this._position = cc.p(0, 0);
- this.frameType = ccs.FRAME_TYPE_MOVE
- },
- setPosition: function(a, c) {
- void 0 === c ? (this._position.x = a.x, this._position.y = a.y) : (this._position.x = a, this._position.y = c)
- },
- getPosition: function() {
- return this._position
- },
- getAction: function(a) {
- a = cc.MoveTo.create(a, this._position);
- a.easingType = this.easingType || ccs.FrameEaseType.Linear;
- return this._getEasingAction(a)
- }
- });
- ccs.ActionScaleFrame = ccs.ActionFrame.extend({
- _scaleX: 1,
- _scaleY: 1,
- ctor: function() {
- ccs.ActionFrame.prototype.ctor.call(this);
- this._scaleY = this._scaleX = 1;
- this.frameType = ccs.FRAME_TYPE_SCALE
- },
- setScaleX: function(a) {
- this._scaleX = a
- },
- getScaleX: function() {
- return this._scaleX
- },
- setScaleY: function(a) {
- this._scaleY = a
- },
- getScaleY: function() {
- return this._scaleY
- },
- getAction: function(a) {
- a = cc.ScaleTo.create(a, this._scaleX, this._scaleY);
- a.easingType = this.easingType || ccs.FrameEaseType.Linear;
- return this._getEasingAction(a)
- }
- });
- ccs.ActionRotationFrame = ccs.ActionFrame.extend({
- _rotation: 0,
- ctor: function() {
- ccs.ActionFrame.prototype.ctor.call(this);
- this._rotation = 0;
- this.frameType = ccs.FRAME_TYPE_ROTATE
- },
- setRotation: function(a) {
- this._rotation = a
- },
- getRotation: function() {
- return this._rotation
- },
- getAction: function(a) {
- a = cc.RotateTo.create(a, this._rotation);
- a.easingType = this.easingType || ccs.FrameEaseType.Linear;
- return this._getEasingAction(a)
- }
- });
- ccs.ActionFadeFrame = ccs.ActionFrame.extend({
- _opacity: 255,
- ctor: function() {
- ccs.ActionFrame.prototype.ctor.call(this);
- this._opacity = 255;
- this.frameType = ccs.FRAME_TYPE_FADE
- },
- setOpacity: function(a) {
- this._opacity = a
- },
- getOpacity: function() {
- return this._opacity
- },
- getAction: function(a) {
- a = cc.FadeTo.create(a, this._opacity);
- a.easingType = this.easingType || ccs.FrameEaseType.Linear;
- return this._getEasingAction(a)
- }
- });
- ccs.ActionTintFrame = ccs.ActionFrame.extend({
- _color: null,
- ctor: function() {
- ccs.ActionFrame.prototype.ctor.call(this);
- this._color = cc.color(255, 255, 255, 255);
- this.frameType = ccs.FRAME_TYPE_TINT
- },
- setColor: function(a) {
- var c = this._color;
- c.r = a.r;
- c.g = a.g;
- c.b = a.b
- },
- getColor: function() {
- var a = this._color;
- return cc.color(a.r, a.g, a.b, a.a)
- },
- getAction: function(a) {
- a = cc.TintTo.create(a, this._color.r, this._color.g, this._color.b);
- a.easingType = this.easingType || ccs.FrameEaseType.Linear;
- return this._getEasingAction(a)
- }
- });
- ccs.actionManager = {
- _actionDic: {},
- initWithDictionary: function(a, c, d) {
- var e = a.lastIndexOf("/");
- a = a.substr(e + 1, a.length);
- c = c.actionlist;
- for (var e = [], f = 0; f < c.length; f++) {
- var g = new ccs.ActionObject;
- g.initWithDictionary(c[f], d);
- e.push(g)
- }
- this._actionDic[a] = e
- },
- getActionByName: function(a, c) {
- var d = this._actionDic[a];
- if (!d) return null;
- for (var e = 0; e < d.length; e++) {
- var f = d[e];
- if (c == f.getName()) return f
- }
- return null
- },
- playActionByName: function(a, c, d) {
- (a = this.getActionByName(a, c)) && a.play(d)
- },
- releaseActions: function() {
- this._actionDic = {}
- },
- clear: function() {
- this._actionDic = {}
- }
- };
- ccs.ActionNode = ccs.Class.extend({
- _currentFrameIndex: 0,
- _destFrameIndex: 0,
- _unitTime: 0,
- _actionTag: 0,
- _bject: null,
- _actionSpawn: null,
- _action: null,
- _frameArray: null,
- _frameArrayNum: 0,
- ctor: function() {
- this._destFrameIndex = this._currentFrameIndex = 0;
- this._unitTime = 0.1;
- this._actionTag = 0;
- this._action = this._actionSpawn = this._bject = null;
- this._frameArray = [];
- this._frameArrayNum = ccs.FRAME_TYPE_MAX;
- for (var a = 0; a < this._frameArrayNum; a++) this._frameArray.push([])
- },
- initWithDictionary: function(a, c) {
- this.setActionTag(a.ActionTag);
- for (var d = a.actionframelist, e = 0; e < d.length; e++) {
- for (var f = d[e], g = f.tweenType, h = f.tweenParameter, k = [], m = 0; m < h; m++) k.push(f.tweenParameter[m]);
- if (void 0 !== f.positionx) {
- var m = f.positionx,
- n = f.positiony,
- h = new ccs.ActionMoveFrame;
- h.setEasingType(g);
- h.setEasingParameter(k);
- h.setPosition(m, n);
- m = this._frameArray[ccs.FRAME_TYPE_MOVE];
- m.push(h)
- }
- void 0 !== f.scalex && (m = f.scalex, n = f.scaley, h = new ccs.ActionScaleFrame, h.setEasingType(g), h.setEasingParameter(k), h.setScaleX(m), h.setScaleY(n), m = this._frameArray[ccs.FRAME_TYPE_SCALE], m.push(h));
- void 0 !== f.rotation && (m = f.rotation, h = new ccs.ActionRotationFrame, h.setEasingType(g), h.setEasingParameter(k), h.setRotation(m), m = this._frameArray[ccs.FRAME_TYPE_ROTATE], m.push(h));
- void 0 !== f.opacity && (m = f.opacity, h = new ccs.ActionFadeFrame, h.setEasingType(g), h.setEasingParameter(k), h.setOpacity(m), m = this._frameArray[ccs.FRAME_TYPE_FADE], m.push(h));
- void 0 !== f.colorr && (m = f.colorr, n = f.colorg, f = f.colorb, h = new ccs.ActionTintFrame, h.setEasingType(g), h.setEasingParameter(k), h.setColor(cc.color(m, n, f)), m = this._frameArray[ccs.FRAME_TYPE_TINT], m.push(h))
- }
- this.initActionNodeFromRoot(c)
- },
- initActionNodeFromRoot: function(a) {
- a instanceof ccui.Widget && (a = ccui.helper.seekActionWidgetByActionTag(a, this.getActionTag())) && this.setObject(a)
- },
- setUnitTime: function(a) {
- this._unitTime = a;
- this.refreshActionProperty()
- },
- getUnitTime: function() {
- return this._unitTime
- },
- setActionTag: function(a) {
- this._actionTag = a
- },
- getActionTag: function() {
- return this._actionTag
- },
- setObject: function(a) {
- this._object = a
- },
- getObject: function() {
- return this._object
- },
- getActionNode: function() {
- return this._object instanceof cc.Node || this._object instanceof ccui.Widget ? this._object : null
- },
- insertFrame: function(a, c) {
- null != c && this._frameArray[c.frameType].splice(a, 0, c)
- },
- addFrame: function(a) {
- a && this._frameArray[a.frameType].push(a)
- },
- deleteFrame: function(a) {
- null != a && cc.arrayRemoveObject(this._frameArray[a.frameType], a)
- },
- clearAllFrame: function() {
- for (var a = 0; a < this._frameArrayNum; a++) this._frameArray[a] = []
- },
- refreshActionProperty: function() {
- if (null == this._object) return null;
- for (var a = [], c = 0; c < this._frameArrayNum; c++) {
- var d = this._frameArray[c];
- if (!(0 >= d.length)) {
- for (var e = [], f = 0; f < d.length; f++) {
- var g = d[f];
- if (0 != f) {
- var h = (g.frameIndex - d[f - 1].frameIndex) * this.getUnitTime();
- (g = g.getAction(h)) && e.push(g)
- }
- }
- e && (d = cc.Sequence.create(e), null != d && a.push(d))
- }
- }
- this._action = null;
- return this._actionSpawn = cc.Spawn.create(a)
- },
- playAction: function(a) {
- null == this._object || null == this._actionSpawn || (this._action = a ? cc.Sequence.create(this._actionSpawn, a) : cc.Sequence.create(this._actionSpawn), this.runAction())
- },
- runAction: function() {
- var a = this.getActionNode();
- null != a && null != this._action && a.runAction(this._action)
- },
- stopAction: function() {
- var a = this.getActionNode();
- null != a && null != this._action && (this._action.isDone() || a.stopAction(this._action))
- },
- getFirstFrameIndex: function() {
- for (var a = 99999, c = !1, d = 0; d < this._frameArrayNum; d++) {
- var e = this._frameArray[d];
- 0 >= e.length || (c = !0, e = e[0].frameIndex, a = a > e ? e : a)
- }
- c || (a = 0);
- return a
- },
- getLastFrameIndex: function() {
- for (var a = -1, c = !1, d = 0; d < this._frameArrayNum; d++) {
- var e = this._frameArray[d];
- 0 >= e.length || (c = !0, e = e[e.length - 1].frameIndex, a = a < e ? e : a)
- }
- c || (a = 0);
- return a
- },
- updateActionToTimeLine: function(a) {
- for (var c = !1, d = this.getUnitTime(), e = 0; e < this._frameArrayNum; e++) {
- var f = this._frameArray[e];
- if (null != f)
- for (var g = 0; g < f.length; g++) {
- var h = f[g];
- if (h.frameIndex * d == a) {
- this.easingToFrame(1, 1, h);
- c = !0;
- break
- } else if (h.frameIndex * d > a) {
- 0 == g ? (this.easingToFrame(1, 1, h), c = !1) : (c = f[g - 1], f = (h.frameIndex - c.frameIndex) * d, g = a - c.frameIndex * d, this.easingToFrame(f, 1, c), this.easingToFrame(f, g / f, h), c = !0);
- break
- }
- }
- }
- return c
- },
- easingToFrame: function(a, c, d) {
- a = d.getAction(a);
- d = this.getActionNode();
- null == a || null == d || (a.startWithTarget(d), a.update(c))
- },
- isActionDoneOnce: function() {
- return null == this._action ? !0 : this._action.isDone()
- }
- });
- ccs.ActionObject = ccs.Class.extend({
- _actionNodeList: null,
- _name: "",
- _loop: !1,
- _pause: !1,
- _playing: !1,
- _unitTime: 0,
- _currentTime: 0,
- _scheduler: null,
- _fTotalTime: 0,
- ctor: function() {
- this._actionNodeList = [];
- this._name = "";
- this._playing = this._pause = this._loop = !1;
- this._unitTime = 0.1;
- this._fTotalTime = this._currentTime = 0;
- this._scheduler = new cc.Scheduler;
- cc.director.getScheduler().scheduleUpdateForTarget(this._scheduler, 0, !1)
- },
- setName: function(a) {
- this._name = a
- },
- getName: function() {
- return this._name
- },
- setLoop: function(a) {
- this._loop = a
- },
- getLoop: function() {
- return this._loop
- },
- setUnitTime: function(a) {
- this._unitTime = a;
- a = this._actionNodeList.length;
- for (var c = 0; c < a; c++) this._actionNodeList[c].setUnitTime(this._unitTime)
- },
- getUnitTime: function() {
- return this._unitTime
- },
- getCurrentTime: function() {
- return this._currentTime
- },
- setCurrentTime: function(a) {
- this._currentTime = a
- },
- getTotalTime: function() {
- return this._fTotalTime
- },
- isPlaying: function() {
- return this._playing
- },
- initWithDictionary: function(a, c) {
- this.setName(a.name);
- this.setLoop(a.loop);
- this.setUnitTime(a.unittime);
- for (var d = a.actionnodelist, e = 0, f = 0; f < d.length; f++) {
- var g = new ccs.ActionNode;
- g.initWithDictionary(d[f], c);
- g.setUnitTime(this.getUnitTime());
- this._actionNodeList.push(g);
- g = g.getLastFrameIndex() - g.getFirstFrameIndex();
- g > e && (e = g)
- }
- this._fTotalTime = e * this._unitTime
- },
- addActionNode: function(a) {
- a && (this._actionNodeList.push(a), a.setUnitTime(this._unitTime))
- },
- removeActionNode: function(a) {
- null != a && cc.arrayRemoveObject(this._actionNodeList, a)
- },
- play: function(a) {
- this.stop();
- this.updateToFrameByTime(0);
- for (var c = this._actionNodeList.length, d = 0; d < c; d++) this._actionNodeList[d].playAction(a);
- this._loop && this._scheduler.scheduleCallbackForTarget(this, this.simulationActionUpdate, 0, cc.REPEAT_FOREVER, 0, !1)
- },
- pause: function() {
- this._pause = !0
- },
- stop: function() {
- for (var a = 0; a < this._actionNodeList.length; a++) this._actionNodeList[a].stopAction();
- this._scheduler.unscheduleCallbackForTarget(this, this.simulationActionUpdate);
- this._pause = !1
- },
- updateToFrameByTime: function(a) {
- this._currentTime = a;
- for (var c = 0; c < this._actionNodeList.length; c++) this._actionNodeList[c].updateActionToTimeLine(a)
- },
- simulationActionUpdate: function(a) {
- if (this._loop) {
- a = !0;
- for (var c = this._actionNodeList, d = 0; d < c.length; d++)
- if (!1 == c[d].isActionDoneOnce()) {
- a = !1;
- break
- }
- a && this.play()
- }
- }
- });
- ccs.ComAttribute = ccs.Component.extend({
- _jsonDict: null,
- _filePath: "",
- ctor: function() {
- cc.Component.prototype.ctor.call(this);
- this._jsonDict = {};
- this._filePath = "";
- this._name = "CCComAttribute"
- },
- init: function() {
- this._jsonDict = {};
- return !0
- },
- setInt: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- setDouble: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- setFloat: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- setBool: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- setString: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- setObject: function(a, c) {
- a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
- },
- getInt: function(a) {
- return parseInt(this._jsonDict[a] || 0)
- },
- getDouble: function(a) {
- return parseFloat(this._jsonDict[a] || 0)
- },
- getFloat: function(a) {
- return parseFloat(this._jsonDict[a] || 0)
- },
- getBool: function(a) {
- return Boolean(this._jsonDict[a] || !1)
- },
- getString: function(a) {
- return this._jsonDict[a] || ""
- },
- getObject: function(a) {
- return this._jsonDict[a]
- },
- parse: function(a) {
- this._jsonDict = cc.loader.getRes(a)
- }
- });
- ccs.ComAttribute.create = function() {
- var a = new ccs.ComAttribute;
- return a && a.init() ? a : null
- };
- ccs.ComAudio = ccs.Component.extend({
- _filePath: "",
- _loop: !1,
- ctor: function() {
- cc.Component.prototype.ctor.call(this);
- this._name = "Audio"
- },
- init: function() {
- return !0
- },
- onEnter: function() {},
- onExit: function() {
- this.stopBackgroundMusic(!0);
- this.stopAllEffects()
- },
- end: function() {
- cc.audioEngine.end()
- },
- preloadBackgroundMusic: function(a) {
- cc.loader.load(a)
- },
- playBackgroundMusic: function(a, c) {
- a ? cc.audioEngine.playMusic(a, c) : cc.audioEngine.playMusic(this._filePath, this._loop)
- },
- stopBackgroundMusic: function(a) {
- cc.audioEngine.stopMusic(a)
- },
- pauseBackgroundMusic: function() {
- cc.audioEngine.pauseMusic()
- },
- resumeBackgroundMusic: function() {
- cc.audioEngine.resumeMusic()
- },
- rewindBackgroundMusic: function() {
- cc.audioEngine.rewindMusic()
- },
- willPlayBackgroundMusic: function() {
- return cc.audioEngine.willPlayMusic()
- },
- isBackgroundMusicPlaying: function() {
- return cc.audioEngine.isMusicPlaying()
- },
- getBackgroundMusicVolume: function() {
- return cc.audioEngine.getMusicVolume()
- },
- setBackgroundMusicVolume: function(a) {
- cc.audioEngine.setMusicVolume(a)
- },
- getEffectsVolume: function() {
- return cc.audioEngine.getEffectsVolume()
- },
- setEffectsVolume: function(a) {
- cc.audioEngine.setEffectsVolume(a)
- },
- playEffect: function(a, c) {
- return a ? cc.audioEngine.playEffect(a, c) : cc.audioEngine.playEffect(this._filePath, this._loop)
- },
- pauseEffect: function(a) {
- cc.audioEngine.pauseEffect(a)
- },
- pauseAllEffects: function() {
- cc.audioEngine.pauseAllEffects()
- },
- resumeEffect: function(a) {
- cc.audioEngine.resumeEffect(a)
- },
- resumeAllEffects: function() {
- cc.audioEngine.resumeAllEffects()
- },
- stopEffect: function(a) {
- cc.audioEngine.stopEffect(a)
- },
- stopAllEffects: function() {
- cc.audioEngine.stopAllEffects()
- },
- preloadEffect: function(a) {
- cc.loader.getRes(a);
- this.setFile(a);
- this.setLoop(!1)
- },
- unloadEffect: function(a) {
- cc.audioEngine.unloadEffect(a)
- },
- setFile: function(a) {
- this._filePath = a
- },
- setLoop: function(a) {
- this._loop = a
- },
- getFile: function() {
- return this._filePath
- },
- isLoop: function() {
- return this._loop
- }
- });
- ccs.ComAudio.create = function() {
- var a = new ccs.ComAudio;
- return a && a.init() ? a : null
- };
- ccs.ComController = ccs.Component.extend({
- ctor: function() {
- cc.Component.prototype.ctor.call(this);
- this._name = "ComController"
- },
- init: function() {
- return !0
- },
- onEnter: function() {
- null != this._owner && this._owner.scheduleUpdate()
- },
- onExit: function() {},
- update: function(a) {},
- isEnabled: function() {
- return this._enabled
- },
- setEnabled: function(a) {
- this._enabled = b
- }
- });
- ccs.ComController.create = function() {
- var a = new ccs.ComController;
- return a && a.init() ? a : null
- };
- ccs.ComRender = ccs.Component.extend({
- _render: null,
- ctor: function(a, c) {
- cc.Component.prototype.ctor.call(this);
- this._render = a;
- this._name = c;
- this.isRenderer = !0
- },
- onEnter: function() {
- this._owner && this._owner.addChild(this._render)
- },
- onExit: function() {
- this._owner && (this._owner.removeChild(this._render, !0), this._render = null)
- },
- getNode: function() {
- return this._render
- },
- setNode: function(a) {
- this._render = a
- }
- });
- ccs.ComRender.create = function(a, c) {
- var d = new ccs.ComRender(a, c);
- return d && d.init() ? d : null
- };
- ccs.objectFactory = {
- _typeMap: {},
- destroyInstance: function() {
- this._instance = null
- },
- createObject: function(a) {
- var c = null;
- (a = this._typeMap[a]) && (c = "function" == typeof a._fun ? new a._fun : a._fun);
- return c
- },
- registerType: function(a) {
- this._typeMap[a._className] = a
- },
- createGUI: function(a) {
- var c = null;
- "Panel" === a ? a = "Layout" : "TextArea" === a ? a = "Label" : "TextButton" === a && (a = "Button");
- if ((a = this._typeMap[a]) && a._fun) c = a._fun;
- return c
- },
- createWidgetReaderProtocol: function(a) {
- var c = null;
- if ((a = this._typeMap[a]) && a._fun) c = a._fun;
- return c
- }
- };
- ccs.TInfo = ccs.Class.extend({
- _className: "",
- _fun: null,
- ctor: function(a, c) {
- c ? (this._className = a, this._fun = c) : (this._className = a._className, this._fun = a._fun);
- ccs.objectFactory.registerType(this)
- }
- });
- ccs.sendEvent = function(a) {
- a = ccs.triggerManager.get(a);
- if (null != a)
- for (var c = 0; c < a.length; c++) {
- var d = a[c];
- null != d && d.detect() && d.done()
- }
- };
- ccs.registerTriggerClass = function(a, c) {
- new ccs.TInfo(a, c)
- };
- ccs.triggerManager = {
- _eventTriggers: {},
- _triggerObjs: {},
- _movementDispatches: [],
- destroyInstance: function() {
- this.removeAll();
- this._instance = null
- },
- parse: function(a) {
- for (var c = 0; c < a.length; ++c) {
- var d = a[c],
- e = ccs.TriggerObj.create();
- e.serialize(d);
- for (var d = e.getEvents(), f = 0; f < d.length; f++) this.add(d[f], e);
- this._triggerObjs[e.getId()] = e
- }
- },
- get: function(a) {
- return this._eventTriggers[a]
- },
- getTriggerObj: function(a) {
- return this._triggerObjs[a]
- },
- add: function(a, c) {
- var d = this._eventTriggers[a];
- d || (d = []); - 1 == d.indexOf(c) && (d.push(c), this._eventTriggers[a] = d)
- },
- removeAll: function() {
- for (var a in this._eventTriggers)
- for (var c = this._eventTriggers[a], d = 0; d < c.length; d++) c[d].removeAll();
- this._eventTriggers = {}
- },
- remove: function(a, c) {
- if (c) return this._removeObj(a, c);
- var d = !1,
- e = this._eventTriggers[a];
- if (e) {
- for (d = 0; d < e.length; d++) {
- var f = e[d];
- f && f.removeAll()
- }
- delete this._eventTriggers[a];
- d = !0
- }
- return d
- },
- _removeObj: function(a, c) {
- var d = !1;
- do {
- var e = this._eventTriggers[a];
- if (e) {
- for (d = 0; d < e.length; d++) {
- var f = e[d];
- if (f && f == c) {
- f.removeAll();
- e.splice(d, 1);
- break
- }
- }
- d = !0
- }
- } while (0);
- return d
- },
- removeTriggerObj: function(a) {
- a = this.getTriggerObj(a);
- if (!a) return !1;
- for (var c = a.getEvents(), d = 0; d < c.length; d++) this.remove(c[d], a);
- return !0
- },
- isEmpty: function() {
- return !this._eventTriggers || 0 >= this._eventTriggers.length
- },
- addArmatureMovementCallBack: function(a, c, d) {
- if (!(null == a || null == d || null == c)) {
- for (var e, f = !1, g = 0; g < this._movementDispatches.length; g++)
- if ((e = this._movementDispatches[g]) && e[0] == a) e.addAnimationEventCallBack(c, d), f = !0;
- f || (e = new ccs.ArmatureMovementDispatcher, a.getAnimation().setMovementEventCallFunc(e.animationEvent, e), e.addAnimationEventCallBack(c, d), this._movementDispatches.push([a, e]))
- }
- },
- removeArmatureMovementCallBack: function(a, c, d) {
- if (!(null == a || null == c || null == d))
- for (var e, f = 0; f < this._movementDispatches.length; f++)(e = this._movementDispatches[f]) && e[0] == a && e.removeAnimationEventCallBack(d, c)
- },
- removeArmatureAllMovementCallBack: function(a) {
- if (null != a)
- for (var c, d = 0; d < this._movementDispatches.length; d++)
- if ((c = this._movementDispatches[d]) && c[0] == a) {
- this._movementDispatches.splice(d, 1);
- break
- }
- },
- removeAllArmatureMovementCallBack: function() {
- this._movementDispatches = []
- },
- version: function() {
- return "1.2.0.0"
- }
- };
- ccs.ArmatureMovementDispatcher = ccs.Class.extend({
- _mapEventAnimation: null,
- ctor: function() {
- this._mapEventAnimation = []
- },
- animationEvent: function(a, c, d) {
- for (var e, f, g = 0; g < this._mapEventAnimation.length; g++) e = this._mapEventAnimation[g], f = e[0], (e = e[1]) && e.call(f, a, c, d)
- },
- addAnimationEventCallBack: function(a, c) {
- this._mapEventAnimation.push([c, a])
- },
- removeAnimationEventCallBack: function(a, c) {
- for (var d, e = 0; e < this._mapEventAnimation.length; e++) d = this._mapEventAnimation[e], d[0] == c && this._mapEventAnimation.splice(e, 1)
- }
- });
- ccs.BaseTriggerCondition = ccs.Class.extend({
- ctor: function() {},
- init: function() {
- return !0
- },
- detect: function() {
- return !0
- },
- serialize: function(a) {},
- removeAll: function() {}
- });
- ccs.BaseTriggerAction = ccs.Class.extend({
- ctor: function() {},
- init: function() {
- return !0
- },
- done: function() {},
- serialize: function(a) {},
- removeAll: function() {}
- });
- ccs.TriggerObj = ccs.Class.extend({
- _cons: null,
- _acts: null,
- _id: 0,
- _enable: !0,
- _vInt: null,
- ctor: function() {
- this._id = 0;
- this._enable = !0
- },
- init: function() {
- this._cons = [];
- this._acts = [];
- this._vInt = [];
- return !0
- },
- detect: function() {
- if (!this._enable || 0 == this._cons.length) return !0;
- for (var a = !0, c = null, d = 0; d < this._cons.length; d++)(c = this._cons[d]) && c.detect && (a = a && c.detect());
- return a
- },
- done: function() {
- if (this._enable && 0 != this._acts.length)
- for (var a, c = 0; c < this._acts.length; c++)(a = this._acts[c]) && a.done && a.done()
- },
- removeAll: function() {
- for (var a = null, c = 0; c < this._cons.length; c++)(a = this._cons[c]) && a.removeAll();
- this._cons = [];
- for (c = 0; c < this._acts.length; c++)(a = this._acts[c]) && a.removeAll();
- this._acts = []
- },
- serialize: function(a) {
- this._id = a.id || 0;
- for (var c = a.conditions || [], d = 0; d < c.length; d++) {
- var e = c[d],
- f = e.classname,
- g = ccs.objectFactory.createObject(f);
- g ? (g.serialize(e), g.init(), this._cons.push(g)) : cc.log("class named classname(" + f + ") can not implement!")
- }
- c = a.actions || [];
- for (d = 0; d < c.length; d++) e = c[d], f = e.classname, (g = ccs.objectFactory.createObject(f)) ? (g.serialize(e), g.init(), this._acts.push(g)) : cc.log("class named classname(" + f + ") can not implement!");
- a = a.events || [];
- for (d = 0; d < a.length; d++) e = a[d], e = e.id, 0 > e || this._vInt.push(e)
- },
- getId: function() {
- return this._id
- },
- setEnable: function(a) {
- this._enable = a
- },
- getEvents: function() {
- return this._vInt
- }
- });
- ccs.TriggerObj.create = function() {
- var a = new ccs.TriggerObj;
- return a.init() ? a : null
- };
- ccs.ButtonReader = {
- getInstance: function() {
- return ccs.ButtonReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.scale9Enable;
- a.setScale9Enabled(e);
- var f = c.normalData;
- switch (f.resourceType) {
- case 0:
- f = f.path;
- a.loadTextureNormal(f && "" !== f ? d + f : null);
- break;
- case 1:
- f = f.path, a.loadTextureNormal(f, 1)
- }
- f = c.pressedData;
- switch (f.resourceType) {
- case 0:
- f = f.path;
- a.loadTexturePressed(f && "" !== f ? d + f : null);
- break;
- case 1:
- f = f.path, a.loadTexturePressed(f, 1)
- }
- f = c.disabledData;
- switch (f.resourceType) {
- case 0:
- f = f.path;
- a.loadTextureDisabled(f && "" !== f ? d + f : null);
- break;
- case 1:
- f = f.path, a.loadTextureDisabled(f, 1)
- }
- e && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), d = c.scale9Width, e = c.scale9Height, null != d && null != e && a.setSize(cc.size(d, e)));
- d = c.text;
- null != d && a.setTitleText(d);
- a.setTitleColor(cc.color(c.textColorR ? c.textColorR : 255, c.textColorG ? c.textColorG : 255, c.textColorB ? c.textColorB : 255));
- null != c.fontSize && a.setTitleFontSize(c.fontSize);
- c.fontName && a.setTitleFontName(c.fontName);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.CheckBoxReader = {
- getInstance: function() {
- return ccs.CheckBoxReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = c.backGroundBoxData,
- e = d.resourceType,
- d = ccs.WidgetReader.getResourcePath(d, "path", e);
- a.loadTextureBackGround(d, e);
- var f = c.backGroundBoxSelectedData,
- g = f.resourceType,
- f = ccs.WidgetReader.getResourcePath(f, "path", g);
- f || (g = e, f = d);
- a.loadTextureBackGroundSelected(f, g);
- d = c.frontCrossData;
- e = d.resourceType;
- d = ccs.WidgetReader.getResourcePath(d, "path", e);
- a.loadTextureFrontCross(d, e);
- f = c.backGroundBoxDisabledData;
- g = f.resourceType;
- f = ccs.WidgetReader.getResourcePath(f, "path", g);
- f || (g = e, f = d);
- a.loadTextureBackGroundDisabled(f, g);
- d = c.frontCrossDisabledData;
- e = d.resourceType;
- d = ccs.WidgetReader.getResourcePath(d, "path", e);
- a.loadTextureFrontCrossDisabled(d, e);
- c.selectedState && a.setSelectedState(c.selectedState);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.ImageViewReader = {
- getInstance: function() {
- return ccs.ImageViewReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.fileNameData;
- switch (e.resourceType) {
- case 0:
- (e = e.path) && "" !== e && a.loadTexture(d + e);
- break;
- case 1:
- e = e.path, a.loadTexture(e, 1)
- }
- d = !1;
- c.scale9Enable && (d = c.scale9Enable);
- a.setScale9Enabled(d);
- d && (d = c.scale9Height, c.scale9Width && d && a.setSize(cc.size(c.scale9Width, c.scale9Height)), a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)));
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.LabelAtlasReader = {
- getInstance: function() {
- return ccs.LabelAtlasReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.charMapFileData || c.charMapFile,
- f = c.itemWidth,
- g = c.itemHeight,
- h = c.startCharMap;
- if (null != c.stringValue && e && null != f && null != g && null != h) switch (e = c.charMapFileData, e.resourceType) {
- case 0:
- a.setProperty(c.stringValue, d + e.path, c.itemWidth, c.itemHeight, c.startCharMap);
- break;
- case 1:
- cc.log("Wrong res type of LabelAtlas!")
- }
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.LabelBMFontReader = {
- getInstance: function() {
- return ccs.LabelBMFontReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.fileNameData;
- switch (e.resourceType) {
- case 0:
- a.setFntFile(d + e.path);
- break;
- case 1:
- cc.log("Wrong res type of LabelAtlas!")
- }
- a.setString(c.text);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.LabelReader = {
- getInstance: function() {
- return ccs.LabelReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- a.setTouchScaleChangeEnabled(c.touchScaleEnable);
- a.setString(c.text);
- null != c.fontSize && a.setFontSize(c.fontSize);
- null != c.fontName && a.setFontName(c.fontName);
- var d = c.areaHeight;
- null != c.areaWidth && null != d && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
- null != c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
- null != c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.LayoutReader = {
- getInstance: function() {
- return ccs.LayoutReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = 0,
- f = 0;
- c.adaptScreen ? (f = cc.director.getWinSize(), e = f.width, f = f.height) : (e = c.width, f = c.height);
- a.setSize(cc.size(e, f));
- a.setClippingEnabled(c.clipAble);
- e = c.backGroundScale9Enable;
- a.setBackGroundImageScale9Enabled(e);
- var f = c.bgColorR,
- g = c.bgColorG,
- h = c.bgColorB,
- k = c.bgStartColorR,
- m = c.bgStartColorG,
- n = c.bgStartColorB,
- q = c.bgEndColorR,
- r = c.bgEndColorG,
- t = c.bgEndColorB;
- a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
- var s = c.bgColorOpacity;
- a.setBackGroundColorType(c.colorType);
- a.setBackGroundColor(cc.color(k, m, n), cc.color(q, r, t));
- a.setBackGroundColor(cc.color(f, g, h));
- a.setBackGroundColorOpacity(s);
- if (f = c.backGroundImageData) switch (f.resourceType) {
- case 0:
- f = f.path;
- a.setBackGroundImage(f && "" !== f ? d + f : null);
- break;
- case 1:
- f = f.path, a.setBackGroundImage(f, 1)
- }
- e && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
- a.setLayoutType(c.layoutType);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.ScrollViewReader = {
- getInstance: function() {
- return ccs.ScrollViewReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.LayoutReader.setPropsFromJsonDictionary.call(this, a, c);
- a.setInnerContainerSize(cc.size(c.innerWidth || 200, c.innerHeight || 200));
- a.setDirection(c.direction || 1);
- a.setBounceEnabled(c.bounceEnable);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.ListViewReader = {
- getInstance: function() {
- return ccs.ListViewReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.ScrollViewReader.setPropsFromJsonDictionary.call(this, a, c);
- a.setDirection(c.direction);
- a.setGravity(c.gravity);
- a.setItemsMargin(c.itemMargin)
- }
- };
- ccs.LoadingBarReader = {
- getInstance: function() {
- return ccs.LoadingBarReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.textureData;
- switch (e.resourceType) {
- case 0:
- (e = e.path) && "" !== e && a.loadTexture(d + e);
- break;
- case 1:
- e = e.path, a.loadTexture(e, 1)
- }
- d = c.scale9Enable;
- a.setScale9Enabled(d);
- d && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), a.setSize(cc.size(c.width, c.height)));
- a.setDirection(c.direction);
- a.setPercent(c.percent);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.PageViewReader = {
- instancePageViewReader: null,
- getInstance: function() {
- return ccs.PageViewReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.LayoutReader.setPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.SliderReader = {
- getInstance: function() {
- return ccs.SliderReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = ccs.uiReader.getFilePath(),
- e = c.scale9Enable;
- a.setScale9Enabled(e);
- var f = c.length,
- g = c.barFileNameData,
- h = g.resourceType,
- g = g.path;
- if (null != c.barFileName) {
- if (e) {
- switch (h) {
- case 0:
- a.loadBarTexture(g ? d + g : null);
- break;
- case 1:
- a.loadBarTexture(g, 1)
- }
- a.setSize(cc.size(f, a.getContentSize().height))
- }
- } else switch (h) {
- case 0:
- a.loadBarTexture(g ? d + g : null);
- break;
- case 1:
- a.loadBarTexture(g, 1)
- }
- f = c.ballNormalData;
- e = f.resourceType;
- f = f.path;
- switch (e) {
- case 0:
- a.loadSlidBallTextureNormal(f ? d + f : null);
- break;
- case 1:
- a.loadSlidBallTextureNormal(f, 1)
- }
- g = c.ballPressedData;
- h = g.resourceType;
- g = g.path;
- null === g && (h = e, g = f);
- switch (h) {
- case 0:
- a.loadSlidBallTexturePressed(g ? d + g : null);
- break;
- case 1:
- a.loadSlidBallTexturePressed(g, 1)
- }
- e = c.ballDisabledData;
- f = e.path;
- switch (e.resourceType) {
- case 0:
- a.loadSlidBallTextureDisabled(f ? d + f : null);
- break;
- case 1:
- a.loadSlidBallTextureDisabled(f, 1)
- }
- e = c.progressBarData;
- f = e.path;
- switch (e.resourceType) {
- case 0:
- a.loadProgressBarTexture(f ? d + f : null);
- break;
- case 1:
- a.loadProgressBarTexture(f, 1)
- }
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.TextFieldReader = {
- getInstance: function() {
- return ccs.TextFieldReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
- var d = c.placeHolder;
- d && a.setPlaceHolder(d);
- a.setString(c.text);
- (d = c.fontSize1) && a.setFontSize(d);
- (d = c.fontName) && a.setFontName(d);
- var d = c.touchSizeWidth,
- e = c.touchSizeHeight;
- d && e && a.setTouchSize(d, e);
- d = c.maxLengthEnable;
- a.setMaxLengthEnabled(d);
- d && a.setMaxLength(c.maxLength);
- d = c.passwordEnable;
- a.setPasswordEnabled(d);
- d && a.setPasswordStyleText(c.passwordStyleText);
- d = c.areaWidth;
- e = c.areaHeight;
- d && e && (d = cc.size(d, e), a.setTextAreaSize(d));
- (d = c.hAlignment) && a.setTextHorizontalAlignment(d);
- (d = c.vAlignment) && a.setTextVerticalAlignment(d);
- ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
- }
- };
- ccs.WidgetReaderProtocol = ccs.Class.extend({
- setPropsFromJsonDictionary: function(a, c) {}
- });
- ccs.WidgetReader = {
- getInstance: function() {
- return ccs.WidgetReader
- },
- setPropsFromJsonDictionary: function(a, c) {
- var d = c.ignoreSize;
- null != d && a.ignoreContentAdaptWithSize(d);
- a.setSizeType(c.sizeType);
- a.setPositionType(c.positionType);
- a.setSizePercent(cc.p(c.sizePercentX, c.sizePercentY));
- a.setPositionPercent(cc.p(c.positionPercentX, c.positionPercentY));
- var e = d = 0;
- c.adaptScreen ? (e = cc.director.getWinSize(), d = e.width, e = e.height) : (d = c.width, e = c.height);
- a.setContentSize(d, e);
- a.setTag(c.tag);
- a.setActionTag(c.actiontag);
- a.setTouchEnabled(c.touchAble);
- d = c.name;
- a.setName(d ? d : "default");
- a.setPosition(c.x, c.y);
- a.setScaleX(c.scaleX || 1);
- a.setScaleY(c.scaleY || 1);
- a.setRotation(c.rotation || 0);
- d = c.visible || !1;
- null != d && a.setVisible(d);
- a.setLocalZOrder(c.ZOrder);
- if (null != c.layoutParameter) {
- d = c.layoutParameter;
- e = null;
- switch (d.type) {
- case 1:
- e = new ccui.LinearLayoutParameter;
- e.setGravity(d.gravity);
- break;
- case 2:
- var f = e = new ccui.RelativeLayoutParameter;
- f.setRelativeName(d.relativeName);
- f.setRelativeToWidgetName(d.relativeToName);
- f.setAlign(d.align)
- }
- null != e && (e.setMargin(d.marginLeft || 0, d.marginTop || 0, d.marginRight || 0, d.marginDown || 0), a.setLayoutParameter(e))
- }
- },
- setColorPropsFromJsonDictionary: function(a, c) {
- var d = c.opacity;
- null != d && a.setOpacity(d);
- var d = c.colorR,
- e = c.colorG,
- f = c.colorB;
- a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
- ccs.WidgetReader.setAnchorPointForWidget(a, c);
- a.setFlippedX(c.flipX);
- a.setFlippedY(c.flipY)
- },
- setAnchorPointForWidget: function(a, c) {
- var d = c.anchorPointX,
- e;
- e = null != d ? c.anchorPointX : a.getAnchorPoint().x;
- var f = c.anchorPointY,
- g;
- g = null != f ? c.anchorPointY : a.getAnchorPoint().y;
- (null != d || null != f) && a.setAnchorPoint(cc.p(e, g))
- },
- getResourcePath: function(a, c, d) {
- a = a[c];
- var e;
- null != a && (0 == d ? e = ccs.uiReader.getFilePath() + a : 1 == d ? e = a : cc.assert(0, "invalid TextureResType!!!"));
- return e
- }
- };
- (function() {
- var a = ccs.objectFactory;
- a.registerType({
- _className: "ButtonReader",
- _fun: ccs.ButtonReader
- });
- a.registerType({
- _className: "CheckBoxReader",
- _fun: ccs.CheckBoxReader
- });
- a.registerType({
- _className: "SliderReader",
- _fun: ccs.SliderReader
- });
- a.registerType({
- _className: "ImageViewReader",
- _fun: ccs.ImageViewReader
- });
- a.registerType({
- _className: "LoadingBarReader",
- _fun: ccs.LoadingBarReader
- });
- a.registerType({
- _className: "TextAtlasReader",
- _fun: ccs.LabelAtlasReader
- });
- a.registerType({
- _className: "TextReader",
- _fun: ccs.LabelReader
- });
- a.registerType({
- _className: "TextBMFontReader",
- _fun: ccs.LabelBMFontReader
- });
- a.registerType({
- _className: "TextFieldReader",
- _fun: ccs.TextFieldReader
- });
- a.registerType({
- _className: "LayoutReader",
- _fun: ccs.LayoutReader
- });
- a.registerType({
- _className: "PageViewReader",
- _fun: ccs.PageViewReader
- });
- a.registerType({
- _className: "ScrollViewReader",
- _fun: ccs.ScrollViewReader
- });
- a.registerType({
- _className: "ListViewReader",
- _fun: ccs.ListViewReader
- });
- a.registerType({
- _className: "WidgetReader",
- _fun: ccs.WidgetReader
- });
- a.registerType({
- _className: "Button",
- _fun: ccui.Button
- });
- a.registerType({
- _className: "CheckBox",
- _fun: ccui.CheckBox
- });
- a.registerType({
- _className: "ImageView",
- _fun: ccui.ImageView
- });
- a.registerType({
- _className: "Text",
- _fun: ccui.Text
- });
- a.registerType({
- _className: "TextAtlas",
- _fun: ccui.TextAtlas
- });
- a.registerType({
- _className: "TextBMFont",
- _fun: ccui.TextBMFont
- });
- a.registerType({
- _className: "LoadingBar",
- _fun: ccui.LoadingBar
- });
- a.registerType({
- _className: "Slider",
- _fun: ccui.Slider
- });
- a.registerType({
- _className: "TextField",
- _fun: ccui.TextField
- });
- a.registerType({
- _className: "Layout",
- _fun: ccui.Layout
- });
- a.registerType({
- _className: "ListView",
- _fun: ccui.ListView
- });
- a.registerType({
- _className: "PageView",
- _fun: ccui.PageView
- });
- a.registerType({
- _className: "ScrollView",
- _fun: ccui.ScrollView
- })
- })();
- ccs.uiReader = {
- _filePath: "",
- _olderVersion: !1,
- _fileDesignSizes: {},
- _mapObject: {},
- _mapParseSelector: {},
- getVersionInteger: function(a) {
- if (!a) return 0;
- var c = a,
- d = c.length;
- if (7 > d) return 0;
- var e = c.indexOf("."),
- f = c.substr(0, e),
- c = c.substr(e + 1, d - 1),
- e = c.indexOf("."),
- g = c.substr(0, e),
- c = c.substr(e + 1, d - 1),
- e = c.indexOf(".");
- a = c.substr(0, e);
- c = c.substr(e + 1, d - 1);
- e = c.indexOf(".");
- c = -1 == e ? c : c.substr(0, e);
- f = parseInt(f);
- g = parseInt(g);
- a = parseInt(a);
- c = parseInt(c);
- return 1E3 * f + 100 * g + 10 * a + c
- },
- storeFileDesignSize: function(a, c) {
- this._fileDesignSizes[a] = c
- },
- getFileDesignSize: function(a) {
- return this._fileDesignSizes[a]
- },
- widgetFromJsonFile: function(a) {
- var c = cc.loader.getRes(a);
- if (!c) throw "Please load the resource first : " + a;
- var d = cc.path.dirname(a);
- this._filePath = "" == d ? d : d + "/";
- var d = c.version,
- e = this.getVersionInteger(d);
- a = (d ? 250 > e ? new ccs.WidgetPropertiesReader0250 : new ccs.WidgetPropertiesReader0300 : new ccs.WidgetPropertiesReader0250).createWidget(c, this._filePath, a);
- if (!d || 250 > e) this._olderVersion = !0;
- return a
- },
- clear: function() {
- this._filePath = "";
- this._olderVersion = !1;
- this._fileDesignSizes = {}
- },
- registerTypeAndCallBack: function(a, c, d, e) {
- var f = ccs.objectFactory;
- c = new ccs.TInfo(a, c);
- f.registerType(c);
- d && (this._mapObject[a] = d);
- e && (this._mapParseSelector[a] = e)
- },
- getFilePath: function() {
- return this._filePath
- },
- getParseObjectMap: function() {
- return this._mapObject
- },
- getParseCallBackMap: function() {
- return this._mapParseSelector
- }
- };
- ccs.WidgetPropertiesReader = ccs.Class.extend({
- _filePath: "",
- createWidget: function(a, c, d) {},
- widgetFromJsonDictionary: function(a) {},
- createGUI: function(a) {
- a = this.getGUIClassName(a);
- return ccs.objectFactory.createObject(a)
- },
- getGUIClassName: function(a) {
- var c = a;
- "Panel" == a ? c = "Layout" : "TextArea" == a ? c = "Text" : "TextButton" == a ? c = "Button" : "Label" == a ? c = "Text" : "LabelAtlas" == a ? c = "TextAtlas" : "LabelBMFont" == a && (c = "TextBMFont");
- return c
- },
- getWidgetReaderClassName: function(a) {
- "Panel" == a ? a = "Layout" : "TextArea" == a ? a = "Text" : "TextButton" == a ? a = "Button" : "Label" == a ? a = "Text" : "LabelAtlas" == a ? a = "TextAtlas" : "LabelBMFont" == a && (a = "TextBMFont");
- return a + "Reader"
- },
- getWidgetReaderClassNameFromWidget: function(a) {
- var c;
- a instanceof ccui.Button ? c = "ButtonReader" : a instanceof ccui.CheckBox ? c = "CheckBoxReader" : a instanceof ccui.ImageView ? c = "ImageViewReader" : a instanceof ccui.TextAtlas ? c = "TextAtlasReader" : a instanceof ccui.TextBMFont ? c = "TextBMFontReader" : a instanceof ccui.Text ? c = "TextReader" : a instanceof ccui.LoadingBar ? c = "LoadingBarReader" : a instanceof ccui.Slider ? c = "SliderReader" : a instanceof ccui.TextField ? c = "TextFieldReader" : a instanceof ccui.ListView ? c = "ListViewReader" : a instanceof ccui.PageView ? c = "PageViewReader" : a instanceof ccui.ScrollView ? c = "ScrollViewReader" : a instanceof ccui.Layout ? c = "LayoutReader" : a instanceof ccui.Widget && (c = "WidgetReader");
- return c
- },
- createWidgetReaderProtocol: function(a) {
- return ccs.objectFactory.createObject(a)
- }
- });
- ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({
- createWidget: function(a, c, d) {
- this._filePath = "" == c ? c : cc.path.join(c, "/");
- for (var e = a.textures, f = 0; f < e.length; f++) {
- var g = c,
- g = g + e[f];
- cc.spriteFrameCache.addSpriteFrames(g)
- }
- c = a.designWidth;
- e = a.designHeight;
- 0 >= c || 0 >= e ? (cc.log("Read design size error!"), f = cc.director.getWinSize(), ccs.uiReader.storeFileDesignSize(d, f)) : ccs.uiReader.storeFileDesignSize(d, cc.size(c, e));
- f = this.widgetFromJsonDictionary(a.widgetTree);
- g = f.getContentSize();
- 0 == g.width && 0 == g.height && f.setSize(cc.size(c, e));
- ccs.actionManager.initWithDictionary(d, a.animation, f);
- return f
- },
- widgetFromJsonDictionary: function(a) {
- var c = null,
- d = a.classname,
- e = a.options;
- "Button" == d ? (c = ccui.Button.create(), this.setPropsForButtonFromJsonDictionary(c, e)) : "CheckBox" == d ? (c = ccui.CheckBox.create(), this.setPropsForCheckBoxFromJsonDictionary(c, e)) : "Label" == d ? (c = ccui.Text.create(), this.setPropsForLabelFromJsonDictionary(c, e)) : "LabelAtlas" == d ? (c = ccui.TextAtlas.create(), this.setPropsForLabelAtlasFromJsonDictionary(c, e)) : "LoadingBar" == d ? (c = ccui.LoadingBar.create(), this.setPropsForLoadingBarFromJsonDictionary(c, e)) : "ScrollView" == d ? (c = ccui.ScrollView.create(), this.setPropsForScrollViewFromJsonDictionary(c, e)) : "TextArea" == d ? (c = ccui.Text.create(), this.setPropsForLabelFromJsonDictionary(c, e)) : "TextButton" == d ? (c = ccui.Button.create(), this.setPropsForButtonFromJsonDictionary(c, e)) : "TextField" == d ? (c = ccui.TextField.create(), this.setPropsForTextFieldFromJsonDictionary(c, e)) : "ImageView" == d ? (c = ccui.ImageView.create(), this.setPropsForImageViewFromJsonDictionary(c, e)) : "Panel" == d ? (c = ccui.Layout.create(), this.setPropsForLayoutFromJsonDictionary(c, e)) : "Slider" == d ? (c = ccui.Slider.create(), this.setPropsForSliderFromJsonDictionary(c, e)) : "LabelBMFont" == d ? (c = ccui.TextBMFont.create(), this.setPropsForLabelBMFontFromJsonDictionary(c, e)) : "DragPanel" == d && (c = ccui.ScrollView.create(), this.setPropsForScrollViewFromJsonDictionary(c, e));
- a = a.children;
- for (d = 0; d < a.length; d++)(e = this.widgetFromJsonDictionary(a[d])) && c.addChild(e);
- return c
- },
- setPropsForWidgetFromJsonDictionary: function(a, c) {
- void 0 !== c.ignoreSize && a.ignoreContentAdaptWithSize(c.ignoreSize);
- a.setSize(cc.size(c.width, c.height));
- a.setTag(c.tag);
- a.setActionTag(c.actiontag);
- a.setTouchEnabled(c.touchAble);
- var d = c.name;
- a.setName(d ? d : "default");
- a.setPosition(cc.p(c.x, c.y));
- void 0 !== c.scaleX && a.setScaleX(c.scaleX);
- void 0 !== c.scaleY && a.setScaleY(c.scaleY);
- void 0 !== c.rotation && a.setRotation(c.rotation);
- void 0 !== c.visible && a.setVisible(c.visible);
- a.setLocalZOrder(c.ZOrder)
- },
- setPropsForAllWidgetFromJsonDictionary: function() {},
- setPropsForAllCustomWidgetFromJsonDictionary: function() {},
- setColorPropsForWidgetFromJsonDictionary: function(a, c) {
- void 0 !== c.opacity && a.setOpacity(c.opacity);
- a.setColor(cc.color(void 0 !== c.colorR ? c.colorR : 255, void 0 !== c.colorG ? c.colorG : 255, void 0 !== c.colorB ? c.colorB : 255));
- var d = void 0 !== c.anchorPointX ? c.anchorPointX : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0,
- e = void 0 !== c.anchorPointY ? c.anchorPointY : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0;
- a.setAnchorPoint(d, e);
- d = c.flipY;
- a.setFlippedX(c.flipX);
- a.setFlippedY(d)
- },
- setPropsForButtonFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.scale9Enable;
- a.setScale9Enabled(d);
- var e = c.normal,
- f = c.pressed,
- g = c.disabled,
- h = e ? this._filePath + e : null,
- k = f ? this._filePath + f : null,
- m = g ? this._filePath + g : null,
- n = c.useMergedTexture;
- d ? (n ? a.loadTextures(e, f, g, ccui.Widget.PLIST_TEXTURE) : a.loadTextures(h, k, m), void 0 !== c.scale9Width && void 0 !== c.scale9Height && a.setSize(cc.size(c.scale9Width, c.scale9Height))) : n ? a.loadTextures(e, f, g, ccui.Widget.PLIST_TEXTURE) : a.loadTextures(h, k, m);
- void 0 !== c.text && (d = c.text || "") && a.setTitleText(d);
- void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
- void 0 !== c.fontName && a.setTitleFontName(c.fontName);
- d = cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255);
- a.setTitleColor(d);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForCheckBoxFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.backGroundBox,
- e = c.backGroundBoxSelected,
- f = c.frontCross,
- g = c.backGroundBoxDisabled,
- h = c.frontCrossDisabled,
- k = this._filePath,
- m = d ? k + d : null,
- n = e ? k + e : null,
- q = f ? k + f : null,
- r = g ? k + g : null,
- k = h ? k + h : null;
- c.useMergedTexture ? a.loadTextures(d, e, f, g, h, ccui.Widget.PLIST_TEXTURE) : a.loadTextures(m, n, q, r, k);
- a.setSelectedState(c.selectedState || !1);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForImageViewFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.fileName,
- e = c.scale9Enable || !1;
- a.setScale9Enabled(e);
- var f = this._filePath,
- g = null;
- d && (g = f + d);
- f = c.useMergedTexture;
- e ? (f ? a.loadTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadTexture(g), void 0 !== c.scale9Width && void 0 !== c.scale9Height && a.setSize(cc.size(c.scale9Width, c.scale9Height)), a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight))) : f ? a.loadTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadTexture(g);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLabelFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- a.setTouchScaleChangeEnabled(c.touchScaleEnable);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- void 0 !== c.fontName && a.setFontName(c.fontName);
- if (void 0 !== c.areaWidth && void 0 !== c.areaHeight) {
- var d = cc.size(c.areaWidth, c.areaHeight);
- a.setTextAreaSize(d)
- }
- c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
- c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLabelAtlasFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = void 0 !== c.charMapFile,
- e = void 0 !== c.itemWidth,
- f = void 0 !== c.itemHeight,
- g = void 0 !== c.startCharMap;
- void 0 !== c.stringValue && (d && e && f && g && c.charMapFile) && a.setProperty(c.stringValue, this._filePath + c.charMapFile, c.itemWidth, c.itemHeight, c.startCharMap);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLayoutFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- !(a instanceof ccui.ScrollView) && !(a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
- var d = c.backGroundScale9Enable;
- a.setBackGroundImageScale9Enabled(d);
- var e = c.bgColorR,
- f = c.bgColorG,
- g = c.bgColorB,
- h = c.bgStartColorR,
- k = c.bgStartColorG,
- m = c.bgStartColorB,
- n = c.bgEndColorR,
- q = c.bgEndColorG,
- r = c.bgEndColorB;
- a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
- var t = c.bgColorOpacity;
- a.setBackGroundColorType(c.colorType);
- a.setBackGroundColor(cc.color(h, k, m), cc.color(n, q, r));
- a.setBackGroundColor(cc.color(e, f, g));
- a.setBackGroundColorOpacity(t);
- f = (e = c.backGroundImage) ? this._filePath + e : null;
- c.useMergedTexture ? a.setBackGroundImage(e, ccui.Widget.PLIST_TEXTURE) : a.setBackGroundImage(f);
- d && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForScrollViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c);
- a.setInnerContainerSize(cc.size(c.innerWidth, c.innerHeight));
- a.setDirection(c.direction);
- a.setBounceEnabled(c.bounceEnable);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForContainerWidgetFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- (a instanceof ccui.ScrollView || a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForSliderFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.barTextureScale9Enable || !1;
- a.setScale9Enabled(d);
- var e = c.length,
- f = c.useMergedTexture;
- if (void 0 !== c.barFileName)
- if (d) {
- var g = (d = c.barFileName) ? this._filePath + d : null;
- f ? a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadBarTexture(g);
- a.setSize(cc.size(e, a.getContentSize().height))
- } else g = (d = c.barFileName) ? this._filePath + d : null, f ? a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadBarTexture(g);
- var e = c.ballNormal,
- d = c.ballPressed,
- g = c.ballDisabled,
- h = e ? this._filePath + e : null,
- k = d ? this._filePath + d : null,
- m = g ? this._filePath + g : null;
- f ? a.loadSlidBallTextures(e, d, g, ccui.Widget.PLIST_TEXTURE) : a.loadSlidBallTextures(h, k, m);
- a.setPercent(c.percent);
- g = (d = c.progressBarFileName) ? this._filePath + d : null;
- f ? a.loadProgressBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadProgressBarTexture(g);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForTextAreaFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- var d = c.colorR,
- e = c.colorG,
- f = c.colorB;
- a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
- a.setFontName(c.fontName);
- void 0 !== c.areaWidth && void 0 !== c.areaHeight && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
- c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
- c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForTextButtonFromJsonDictionary: function(a, c) {
- this.setPropsForButtonFromJsonDictionary(a, c);
- a.setTitleText(c.text || "");
- a.setTitleColor(cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255));
- void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
- void 0 !== c.fontName && a.setTitleFontName(c.fontName);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForTextFieldFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- void 0 !== c.placeHolder && a.setPlaceHolder(c.placeHolder);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- void 0 !== c.fontName && a.setFontName(c.fontName);
- void 0 !== c.touchSizeWidth && void 0 !== c.touchSizeHeight && a.setTouchSize(cc.size(c.touchSizeWidth, c.touchSizeHeight));
- var d = c.maxLengthEnable;
- a.setMaxLengthEnabled(d);
- d && a.setMaxLength(c.maxLength);
- d = c.passwordEnable;
- a.setPasswordEnabled(d);
- d && a.setPasswordStyleText(c.passwordStyleText);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLoadingBarFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.texture,
- e = d ? this._filePath + d : null;
- c.useMergedTexture ? a.loadTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadTexture(e);
- a.setDirection(c.direction);
- a.setPercent(c.percent);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForListViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c)
- },
- setPropsForPageViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c)
- },
- setPropsForLabelBMFontFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- a.setFntFile(this._filePath + c.fileName);
- a.setString(c.text);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- }
- });
- ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({
- createWidget: function(a, c, d) {
- this._filePath = "" == c ? c : cc.path.join(c, "/");
- for (var e = a.textures, f = 0; f < e.length; f++) {
- var g = c,
- g = g + e[f];
- cc.spriteFrameCache.addSpriteFrames(g)
- }
- c = a.designWidth;
- e = a.designHeight;
- 0 >= c || 0 >= e ? (cc.log("Read design size error!"), f = cc.director.getWinSize(), ccs.uiReader.storeFileDesignSize(d, f)) : ccs.uiReader.storeFileDesignSize(d, cc.size(c, e));
- f = this.widgetFromJsonDictionary(a.widgetTree);
- g = f.getContentSize();
- 0 == g.width && 0 == g.height && f.setSize(cc.size(c, e));
- ccs.actionManager.initWithDictionary(d, a.animation, f);
- return f
- },
- setPropsForAllWidgetFromJsonDictionary: function(a, c, d) {
- a && a.setPropsFromJsonDictionary && a.setPropsFromJsonDictionary(c, d)
- },
- setPropsForAllCustomWidgetFromJsonDictionary: function(a, c, d) {
- var e = ccs.uiReader,
- f = e.getParseObjectMap()[a],
- e = e.getParseCallBackMap()[a];
- f && e && e(a, c, d)
- },
- widgetFromJsonDictionary: function(a) {
- var c = a.classname,
- d = a.options,
- e = this.createGUI(c),
- f = this.getWidgetReaderClassName(c);
- (f = this.createWidgetReaderProtocol(f)) ? this.setPropsForAllWidgetFromJsonDictionary(f, e, d): (f = this.getWidgetReaderClassNameFromWidget(e), (f = ccs.objectFactory.createObject(f)) && e ? (this.setPropsForAllWidgetFromJsonDictionary(f, e, d), d = JSON.parse(d.customProperty), this.setPropsForAllCustomWidgetFromJsonDictionary(c, e, d)) : cc.log("Widget or WidgetReader doesn't exists!!! Please check your json file."));
- a = a.children;
- for (c = 0; c < a.length; c++)
- if (d = this.widgetFromJsonDictionary(a[c]))
- if (e instanceof ccui.PageView) e.addPage(d);
- else if (e instanceof ccui.ListView) e.pushBackCustomItem(d);
- else {
- if (!(e instanceof ccui.Layout)) {
- if (d.getPositionType() == ccui.Widget.POSITION_PERCENT) {
- var f = d.getPositionPercent(),
- g = e.getAnchorPoint();
- d.setPositionPercent(cc.p(f.x + g.x, f.y + g.y))
- }
- f = e.getAnchorPointInPoints();
- d.setPosition(cc.p(d.getPositionX() + f.x, d.getPositionY() + f.y))
- }
- e.addChild(d)
- }
- return e
- },
- setPropsForWidgetFromJsonDictionary: function(a, c) {
- var d = c.name;
- a.setName(d ? d : "default");
- void 0 !== c.ignoreSize && a.ignoreContentAdaptWithSize(c.ignoreSize);
- a.setSizeType(c.sizeType);
- a.setPositionType(c.positionType);
- a.setSizePercent(cc.p(c.sizePercentX, c.sizePercentY));
- a.setPositionPercent(cc.p(c.positionPercentX, c.positionPercentY));
- a.setSize(cc.size(c.width, c.height));
- a.setTag(c.tag);
- a.setActionTag(c.actiontag);
- a.setTouchEnabled(c.touchAble);
- a.setPosition(cc.p(c.x, c.y));
- void 0 !== c.scaleX && a.setScaleX(c.scaleX);
- void 0 !== c.scaleY && a.setScaleY(c.scaleY);
- void 0 !== c.rotation && a.setRotation(c.rotation);
- void 0 !== c.visible && a.setVisible(c.visible);
- a.setLocalZOrder(c.ZOrder);
- if (d = c.layoutParameter) {
- var e;
- switch (d.type) {
- case 1:
- e = ccui.LinearLayoutParameter.create();
- e.setGravity(d.gravity);
- break;
- case 2:
- e = ccui.RelativeLayoutParameter.create(), e.setRelativeName(d.relativeName), e.setRelativeToWidgetName(d.relativeToName), e.setAlign(d.align)
- }
- e.setMargin(new ccui.Margin(d.marginLeft, d.marginTop, d.marginRight, d.marginDown));
- a.setLayoutParameter(e)
- }
- },
- setColorPropsForWidgetFromJsonDictionary: function(a, c) {
- void 0 !== c.opacity && a.setOpacity(c.opacity);
- a.setColor(cc.color(void 0 !== c.colorR ? c.colorR : 255, void 0 !== c.colorG ? c.colorG : 255, void 0 !== c.colorB ? c.colorB : 255));
- var d = void 0 !== c.anchorPointX ? c.anchorPointX : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0,
- e = void 0 !== c.anchorPointY ? c.anchorPointY : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0;
- a.setAnchorPoint(d, e);
- d = c.flipY;
- a.setFlippedX(c.flipX);
- a.setFlippedY(d)
- },
- setPropsForButtonFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.scale9Enable;
- a.setScale9Enabled(d);
- var e = c.normalData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadTextureNormal(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadTextureNormal(e, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.pressedData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadTexturePressed(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadTexturePressed(e, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.disabledData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadTextureDisabled(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadTextureDisabled(e, ccui.Widget.PLIST_TEXTURE)
- }
- d && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), void 0 !== c.scale9Width && void 0 !== c.scale9Height && a.setSize(cc.size(c.scale9Width, c.scale9Height)));
- void 0 !== c.text && (d = c.text || "") && a.setTitleText(d);
- void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
- void 0 !== c.fontName && a.setTitleFontName(c.fontName);
- d = cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255);
- a.setTitleColor(d);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForCheckBoxFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.backGroundBoxData;
- switch (d.resourceType) {
- case 0:
- d = d.path;
- a.loadTextureBackGround(d ? this._filePath + d : null);
- break;
- case 1:
- d = d.path, a.loadTextureBackGround(d, ccui.Widget.PLIST_TEXTURE)
- }
- d = c.backGroundBoxSelectedData;
- switch (d.resourceType) {
- case 0:
- d = d.path;
- a.loadTextureBackGroundSelected(d ? this._filePath + d : null);
- break;
- case 1:
- d = d.path, a.loadTextureBackGroundSelected(d, ccui.Widget.PLIST_TEXTURE)
- }
- d = c.frontCrossData;
- switch (d.resourceType) {
- case 0:
- d = d.path;
- a.loadTextureFrontCross(d ? this._filePath + d : null);
- break;
- case 1:
- d = d.path, a.loadTextureFrontCross(d, ccui.Widget.PLIST_TEXTURE)
- }
- d = c.backGroundBoxDisabledData;
- switch (d.resourceType) {
- case 0:
- d = d.path;
- a.loadTextureBackGroundDisabled(d ? this._filePath + d : null);
- break;
- case 1:
- d = d.path, a.loadTextureBackGroundDisabled(d, ccui.Widget.PLIST_TEXTURE)
- }
- switch (c.frontCrossDisabledData.resourceType) {
- case 0:
- d = c.path;
- a.loadTextureFrontCrossDisabled(d ? this._filePath + d : null);
- break;
- case 1:
- d = c.path, a.loadTextureFrontCrossDisabled(d, ccui.Widget.PLIST_TEXTURE)
- }
- a.setSelectedState(c.selectedState || !1);
- a.setSelectedState(c, "selectedState");
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForImageViewFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.fileNameData;
- switch (d.resourceType) {
- case 0:
- var e = this._filePath;
- (d = d.path) && a.loadTexture(e + d);
- break;
- case 1:
- d = d.path, a.loadTexture(d, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.scale9Enable || !1;
- a.setScale9Enabled(e);
- e && (void 0 !== c.scale9Width && void 0 !== c.scale9Height && a.setSize(cc.size(c.scale9Width, c.scale9Height)), a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)));
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLabelFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- a.setTouchScaleChangeEnabled(c.touchScaleEnable);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- void 0 !== c.fontName && a.setFontName(c.fontName);
- if (void 0 !== c.areaWidth && void 0 !== c.areaHeight) {
- var d = cc.size(c.areaWidth, c.areaHeight);
- a.setTextAreaSize(d)
- }
- c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
- c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLabelAtlasFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = void 0 !== c.charMapFile,
- e = void 0 !== c.itemWidth,
- f = void 0 !== c.itemHeight,
- g = void 0 !== c.startCharMap;
- if (void 0 !== c.stringValue && d && e && f && g) switch (d = c.charMapFileData, d.resourceType) {
- case 0:
- a.setProperty(c.stringValue, this._filePath + d.path, c.itemWidth, c.itemHeight, c.startCharMap);
- break;
- case 1:
- cc.log("Wrong res type of LabelAtlas!")
- }
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLayoutFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- !(a instanceof ccui.ScrollView) && !(a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
- var d = c.backGroundScale9Enable;
- a.setBackGroundImageScale9Enabled(d);
- var e = c.bgColorR,
- f = c.bgColorG,
- g = c.bgColorB,
- h = c.bgStartColorR,
- k = c.bgStartColorG,
- m = c.bgStartColorB,
- n = c.bgEndColorR,
- q = c.bgEndColorG,
- r = c.bgEndColorB;
- a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
- var t = c.bgColorOpacity;
- a.setBackGroundColorType(c.colorType);
- a.setBackGroundColor(cc.color(h, k, m), cc.color(n, q, r));
- a.setBackGroundColor(cc.color(e, f, g));
- a.setBackGroundColorOpacity(t);
- e = c.backGroundImageData || {};
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.setBackGroundImage(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.setBackGroundImage(e, ccui.Widget.PLIST_TEXTURE)
- }
- d && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
- a.setLayoutType(c.layoutType);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForScrollViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c);
- a.setInnerContainerSize(cc.size(c.innerWidth, c.innerHeight));
- a.setDirection(c.direction);
- a.setBounceEnabled(c.bounceEnable);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForSliderFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.barTextureScale9Enable || !1;
- a.setScale9Enabled(d);
- var e = c.length;
- if (void 0 !== c.barFileName)
- if (d) {
- var d = c.barFileNameData,
- f = d.resourceType;
- switch (f) {
- case 0:
- d = (d = d.path) ? this._filePath + d : null;
- a.loadBarTexture(d);
- break;
- case 1:
- d = d.path, a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE)
- }
- a.setSize(cc.size(e, a.getContentSize().height))
- } else switch (d = c.barFileNameData, f = d.resourceType, f) {
- case 0:
- d = (d = d.path) ? this._filePath + d : null;
- a.loadBarTexture(d);
- break;
- case 1:
- d = d.path, a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.ballNormalData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadSlidBallTextureNormal(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadSlidBallTextureNormal(e, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.ballPressedData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadSlidBallTexturePressed(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadSlidBallTexturePressed(e, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.ballDisabledData;
- switch (e.resourceType) {
- case 0:
- e = e.path;
- a.loadSlidBallTextureDisabled(e ? this._filePath + e : null);
- break;
- case 1:
- e = e.path, a.loadSlidBallTextureDisabled(e, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.progressBarData;
- switch (e.resourceType) {
- case 0:
- d = (d = e.path) ? this._filePath + d : null;
- a.loadProgressBarTexture(d);
- break;
- case 1:
- d = e.path, a.loadProgressBarTexture(d, ccui.Widget.PLIST_TEXTURE)
- }
- this.setColorPropsForWidgetFromJsonDictionary(a, c);
- a.setPercent(c.percent)
- },
- setPropsForTextAreaFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- var d = c.colorR,
- e = c.colorG,
- f = c.colorB;
- a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
- a.setFontName(c.fontName);
- void 0 !== c.areaWidth && void 0 !== c.areaHeight && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
- c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
- c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForTextButtonFromJsonDictionary: function(a, c) {
- this.setPropsForButtonFromJsonDictionary(a, c);
- a.setTitleText(c.text || "");
- a.setTitleColor(cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255));
- void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
- void 0 !== c.fontName && a.setTitleFontName(c.fontName);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForTextFieldFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- void 0 !== c.placeHolder && a.setPlaceHolder(c.placeHolder);
- a.setString(c.text);
- void 0 !== c.fontSize && a.setFontSize(c.fontSize);
- void 0 !== c.fontName && a.setFontName(c.fontName);
- void 0 !== c.touchSizeWidth && void 0 !== c.touchSizeHeight && a.setTouchSize(cc.size(c.touchSizeWidth, c.touchSizeHeight));
- var d = c.maxLengthEnable;
- a.setMaxLengthEnabled(d);
- d && a.setMaxLength(c.maxLength);
- d = c.passwordEnable;
- a.setPasswordEnabled(d);
- d && a.setPasswordStyleText(c.passwordStyleText);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForLoadingBarFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.textureData;
- switch (d.resourceType) {
- case 0:
- var e = this._filePath;
- (d = d.path) && a.loadTexture(e + d);
- break;
- case 1:
- d = d.path, a.loadTexture(d, ccui.Widget.PLIST_TEXTURE)
- }
- e = c.scale9Enable;
- a.setScale9Enabled(e);
- e && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), a.setSize(cc.size(c.width, c.height)));
- a.setDirection(c.direction);
- a.setPercent(c.percent);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- },
- setPropsForListViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c);
- a.setInnerContainerSize(cc.size(c.innerWidth || 0, c.innerHeight || 0));
- a.setDirection(c.direction || 0);
- a.setGravity(c.gravity || 0);
- a.setItemsMargin(c.itemMargin || 0)
- },
- setPropsForPageViewFromJsonDictionary: function(a, c) {
- this.setPropsForLayoutFromJsonDictionary(a, c)
- },
- setPropsForLabelBMFontFromJsonDictionary: function(a, c) {
- this.setPropsForWidgetFromJsonDictionary(a, c);
- var d = c.fileNameData;
- switch (d.resourceType) {
- case 0:
- a.setFntFile(this._filePath + d.path);
- break;
- case 1:
- cc.log("Wrong res type of LabelAtlas!")
- }
- a.setString(c.text);
- this.setColorPropsForWidgetFromJsonDictionary(a, c)
- }
- });
- ccs.sceneReader = {
- _baseBath: "",
- _listener: null,
- _selector: null,
- _node: null,
- createNodeWithSceneFile: function(a) {
- this._node = null;
- this._baseBath = cc.path.dirname(a);
- var c = cc.loader.getRes(a);
- if (!c) throw "Please load the resource first : " + a;
- this._node = this.createObject(c, null);
- ccs.triggerManager.parse(c.Triggers || []);
- return this._node
- },
- createObject: function(a, c) {
- var d = a.classname;
- if ("CCNode" == d) {
- var e = null;
- c ? (e = cc.Node.create(), c.addChild(e)) : e = cc.Node.create();
- this.setPropertyFromJsonDict(e, a);
- for (var f = a.components, g = 0; g < f.length; g++) {
- var h = f[g];
- if (!h) break;
- var d = h.classname,
- k = h.name,
- m = h.fileData,
- n = "",
- q = "",
- r = 0;
- null != m && (r = void 0 !== m.resourceType ? m.resourceType : -1, n = cc.path.join(this._baseBath, m.path), q = m.plistFile);
- var t = cc.path.extname(n);
- if ("CCSprite" == d) {
- d = null;
- if (0 == r) {
- if (".png" != t) continue;
- d = cc.Sprite.create(n)
- } else if (1 == r) {
- if (".plist" != t) continue;
- q = cc.path.join(this._baseBath, q);
- n = cc.path.changeExtname(q, ".png");
- cc.spriteFrameCache.addSpriteFrames(q, n);
- d = cc.Sprite.create("#" + m.path)
- } else continue;
- n = ccs.ComRender.create(d, "CCSprite");
- null != k && n.setName(k);
- e.addComponent(n);
- this._callSelector(d, h)
- } else if ("CCTMXTiledMap" == d) m = null, 0 == r && ".tmx" == t && (m = cc.TMXTiledMap.create(n), n = ccs.ComRender.create(m, "CCTMXTiledMap"), null != k && n.setName(k), e.addComponent(n), this._callSelector(m, h));
- else if ("CCParticleSystemQuad" == d) ".plist" == t && (m = null, 0 == r ? (m = cc.ParticleSystem.create(n), m.setPosition(0, 0), n = ccs.ComRender.create(m, "CCParticleSystemQuad"), null != k && n.setName(k), e.addComponent(n), this._callSelector(m, h)) : cc.log("unknown resourcetype on CCParticleSystemQuad!"));
- else if ("CCArmature" == d) 0 == r && ((r = cc.loader.getRes(n)) || cc.log("Please load the resource [%s] first!", n), r = r.armature_data[0].name, ccs.armatureDataManager.addArmatureFileInfo(n), r = ccs.Armature.create(r), n = ccs.ComRender.create(r, "CCArmature"), null != k && n.setName(k), e.addComponent(n), (k = h.selectedactionname) && r.getAnimation() && r.getAnimation().play(k), this._callSelector(r, h));
- else if ("CCComAudio" == d) {
- var s = null;
- 0 == r && (s = ccs.ComAudio.create(), s.preloadEffect(n), k && s.setName(k), e.addComponent(s), this._callSelector(s, h))
- } else "CCComAttribute" == d ? (m = null, 0 == r ? (m = ccs.ComAttribute.create(), "" != n && m.parse(n), k && m.setName(k), e.addComponent(m), this._callSelector(m, h)) : cc.log("unknown resourcetype on CCComAttribute!")) : "CCBackgroundAudio" == d ? t && 0 == r && (s = ccs.ComAudio.create(), s.preloadBackgroundMusic(n), s.setFile(n), r = Boolean(h.loop || 0), s.setLoop(r), k && s.setName(k), e.addComponent(s), s.playBackgroundMusic(n, r), this._callSelector(s, h)) : "GUIComponent" == d && (n = ccs.uiReader.widgetFromJsonFile(n), n = ccs.ComRender.create(n, "GUIComponent"), null != k && n.setName(k), e.addComponent(n), this._callSelector(s, h))
- }
- f = a.gameobjects;
- for (g = 0; g < f.length; g++) {
- h = f[g];
- if (!h) break;
- this.createObject(h, e)
- }
- return e
- }
- return null
- },
- nodeByTag: function(a, c) {
- if (null == a) return null;
- for (var d = null, e = a.getChildren(), f = 0; f < e.length && !((d = e[f]) && d.getTag() == c) && !(d = this.nodeByTag(d, c)); f++);
- return d
- },
- getNodeByTag: function(a) {
- return null == this._node ? null : this._node.getTag() == a ? this._node : this.nodeByTag(this._node, a)
- },
- setPropertyFromJsonDict: function(a, c) {
- a.setPosition("undefined" === typeof c.x ? 0 : c.x, "undefined" === typeof c.y ? 0 : c.y);
- a.setVisible(Boolean("undefined" === typeof c.visible ? 1 : c.visible));
- a.setTag("undefined" === typeof c.objecttag ? -1 : c.objecttag);
- a.setLocalZOrder("undefined" === typeof c.zorder ? 0 : c.zorder);
- var d = "undefined" === typeof c.scaley ? 1 : c.scaley;
- a.setScaleX("undefined" === typeof c.scalex ? 1 : c.scalex);
- a.setScaleY(d);
- a.setRotation("undefined" === typeof c.rotation ? 0 : c.rotation)
- },
- setTarget: function(a, c) {
- this._listener = c;
- this._selector = a
- },
- _callSelector: function(a, c) {
- this._selector && this._selector.call(this._listener, a, c)
- },
- version: function() {
- return "1.2.0.0"
- },
- clear: function() {
- ccs.triggerManager.removeAll();
- cc.audioEngine.end()
- }
- };
- var baseURL = "./images/",
- res = {
- background_png: baseURL + "background.png",
- time_png: baseURL + "time.png",
- wordBg_png: baseURL + "xinxi.png",
- buttomBg_png: baseURL + "buttomBg.png",
- wrongMark_png: baseURL + "wrongMark.png",
- s_jin: baseURL + "01.png",
- dialogBg: baseURL + "dialogBg.png",
- dibanzi: baseURL + "diban.png",
- wordBg: baseURL + "wordBg.png",
- toumingdi: baseURL + "toumingdi.png",
- banzi: baseURL + "banzi.png",
- ready_png: baseURL + "ready.png",
- go_png: baseURL + "go.png",
- login_figure: baseURL + "login_ice.png",
- s_overfigure: baseURL + "renwu/role3.png",
- s_guide_png: baseURL + "guide.png",
- s_share: baseURL + "share.png",
- s_paopao: baseURL + "paopao.png",
- s_fenxiangzi: baseURL + "zi.png",
- s_fenxiang: baseURL + "fenxiang.png",
- s_fnt: baseURL + "font.fnt",
- s_fntpng: baseURL + "fontpng.png",
- s_role1: baseURL + "renwu/role1.png",
- s_role2: baseURL + "renwu/role2.png",
- s_role3: baseURL + "renwu/role3.png",
- cakeRed_png: baseURL + "cakeRed.png",
- cakeGreen_png: baseURL + "cakeGreen.png",
- cakeBlue_png: baseURL + "cakeBlue.png",
- cakeButtom_png: baseURL + "cakeButtom.png",
- macaronsBule_png: baseURL + "macaronsBule.png",
- macaronsButtom_png: baseURL + "macaronsButtom.png",
- macaronsGreen_png: baseURL + "macaronsGreen.png",
- macaronsMiddle_png: baseURL + "macaronsMiddle.png",
- macaronsRed_png: baseURL + "macaronsRed.png",
- macaronsTop_png: baseURL + "macaronsTop.png",
- iceButtom_png: baseURL + "iceBottom.png",
- iceBule_png: baseURL + "iceBule.png",
- iceGreen_png: baseURL + "iceGreen.png",
- iceRed_png: baseURL + "iceRed.png",
- btnNewGame_png: baseURL + "btnNewGame.png",
- btnAgain_png: baseURL + "btnAgain.png",
- btnShare_png: baseURL + "btnShare.png",
- progressBarBg_png: baseURL + "progressBarBg.png",
- progressBar_png: baseURL + "progressBar.png",
- gameLogo_png: baseURL + "gameLogo.png",
- btnShare1: baseURL + "btnShare1.png",
- btnKnown: baseURL + "btnKnown.png"
- };
- var music = {
- readyGo: baseURL + "music/readygo01.mp3",
- last10sec: baseURL + "music/10sec01.mp3",
- gameBg: baseURL + "music/gameBG101.mp3",
- result: baseURL + "music/jiesuan01.mp3",
- hits1: baseURL + "music/lianji101.mp3",
- hits2: baseURL + "music/lianji102.mp3",
- hits3: baseURL + "music/lianji103.mp3",
- hits4: baseURL + "music/lianji104.mp3",
- hitsOver: baseURL + "music/lianjiover101.mp3",
- wrong: baseURL + "music/wrong01.mp3"
- },
- g_resources = [],
- i;
- for (i in res) g_resources.push(res[i]);
- for (var j in music) g_resources.push(music[j]);
- var Config = {
- ice: null,
- cake: null,
- macarons: null,
- typeIce: "typeice",
- typecake: "typecake",
- progressBarConfig: null,
- vision: 10
- };
- Config.ice = [res.iceBule_png, res.iceGreen_png, res.iceRed_png];
- Config.ice.buttom = res.iceButtom_png;
- Config.ice.bheight = 80;
- Config.ice.foodtype = "ice";
- Config.ice.itemHeight = 35;
- Config.cake = [res.cakeRed_png, res.cakeGreen_png, res.cakeBlue_png];
- Config.cake.buttom = res.cakeButtom_png;
- Config.cake.bheight = 0;
- Config.cake.foodtype = "cake";
- Config.cake.itemHeight = 50;
- Config.macarons = [res.macaronsBule_png, res.macaronsGreen_png, res.macaronsRed_png];
- Config.macarons.top = res.macaronsTop_png;
- Config.macarons.buttom = res.macaronsButtom_png;
- Config.macarons.middle = res.macaronsMiddle_png;
- Config.macarons.middleHeight = 55;
- Config.macarons.bheight = 20;
- Config.macarons.foodtype = "macarons";
- Config.macarons.itemHeight = 50;
- Config.progressBarConfig = {
- limit: 6E4,
- now: 6E4
- };
- Config.alreadyGoTime = 60;
- var lead = null,
- GameLayer = cc.LayerColor.extend({
- ctor: function() {
- this._super()
- },
- init: function() {
- this._super();
- GameL = this;
- Func.ice_random();
- Func.res_random(Data.victoryNum);
- var a = cc.Sprite.create(res.background_png);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- a.x = gameSize.width / 2;
- a.y = gameSize.height / 2;
- this.addChild(a, 0);
- a = ccui.ImageView.create();
- a.loadTexture(res.toumingdi);
- a.setScale9Enabled(!0);
- a.setContentSize(cc.size(592, 616));
- a.setTextureRect(cc.rect(23, 73, 1, 1));
- a.x = gameSize.width / 2;
- a.y = gameSize.height / 2 - 10;
- this.addChild(a, 2);
- a = ccui.ImageView.create();
- a.loadTexture(res.wordBg);
- a.setScale9Enabled(!0);
- a.setContentSize(cc.size(275, 400));
- a.setTextureRect(cc.rect(117, 50, 1, 1));
- a.x = gameSize.width / 2 - 143;
- a.y = gameSize.height / 2 - 100;
- this.addChild(a, 2);
- var c = ccui.ImageView.create();
- c.loadTexture(res.dibanzi);
- c.x = 140;
- c.y = 10;
- a.addChild(c, 2);
- a = ccui.ImageView.create();
- a.loadTexture(res.wordBg);
- a.setScale9Enabled(!0);
- a.setContentSize(cc.size(275, 400));
- a.setTextureRect(cc.rect(117, 50, 1, 1));
- a.x = gameSize.width / 2 + 140;
- a.y = gameSize.height / 2 - 100;
- this.addChild(a, 2);
- c = ccui.ImageView.create();
- c.loadTexture(res.dibanzi);
- c.x = 140;
- c.y = 10;
- a.addChild(c, 2);
- a = ccui.ImageView.create();
- a.loadTexture(res.banzi);
- a.setScale9Enabled(!0);
- a.setContentSize(cc.size(617, 111));
- a.setTextureRect(cc.rect(80, 37, 1, 1));
- a.x = gameSize.width / 2;
- a.y = gameSize.height / 2 + 185;
- this.addChild(a, 2);
- GameL.ready = cc.Sprite.create(res.ready_png);
- GameL.ready.setAnchorPoint(cc.p(0.5, 0.5));
- GameL.ready.x = gameSize.width / 2;
- GameL.ready.y = gameSize.height / 2 + 150;
- GameL.ready.visible = !1;
- this.addChild(GameL.ready, 100);
- GameL.go = cc.Sprite.create(res.go_png);
- GameL.go.setAnchorPoint(cc.p(0.5, 0.5));
- GameL.go.x = gameSize.width / 2;
- GameL.go.y = gameSize.height / 2;
- GameL.go.visible = !1;
- this.addChild(GameL.go, 100);
- lead = cc.Sprite.create(res.s_role1);
- lead.setAnchorPoint(cc.p(0.5, 0.5));
- lead.x = gameSize.width / 2 - 130;
- lead.y = gameSize.height / 2 + 364;
- this.addChild(lead, 10);
- GameL.victoryNum = new cc.LabelBMFont("0", res.s_fnt);
- GameL.victoryNum.x = gameSize.width / 2 + 70;
- GameL.victoryNum.y = gameSize.height / 2 + 305;
- GameL.victoryNum.setScale(2);
- this.addChild(GameL.victoryNum, 15);
- a = cc.Sprite.create(res.buttomBg_png);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- a.x = gameSize.width / 2;
- a.y = gameSize.height / 2 - 375;
- a.scaleY = 0.95;
- this.addChild(a, 5);
- c = cc.Sprite.create(res.s_jin);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- c.x = gameSize.width / 2 + 130;
- c.y = gameSize.height / 2 + 305;
- a.scaleX = 0.95;
- a.scaleY = 0.95;
- this.addChild(c, 15);
- a = cc.Sprite.create(res.wordBg_png);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- a.x = gameSize.width / 2 + 100;
- a.y = gameSize.height / 2 + 300;
- a.scaleX = 0.9;
- a.scaleY = 0.9;
- this.addChild(a, 10);
- a = cc.Sprite.create(res.progressBarBg_png);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- a.x = gameSize.width / 2 + 10;
- a.y = gameSize.height / 2 + 160;
- a.scaleX = 1;
- a.scaleY = 0.93;
- this.addChild(a, 1);
- GameL.timeBar = new ccui.LoadingBar;
- GameL.timeBar.setName("TimeBar");
- GameL.timeBar.loadTexture(res.progressBar_png);
- GameL.timeBar.setDirection(ccui.LoadingBar.TYPE_LEFT);
- GameL.timeBar.setPercent(100);
- GameL.timeBar.x = gameSize.width / 2;
- GameL.timeBar.y = gameSize.height / 2 + 160;
- this.addChild(GameL.timeBar, 3);
- Func.barReset = function() {
- GameL.timeBar.setPercent(100)
- };
- a = cc.Sprite.create(res.time_png);
- a.setAnchorPoint(cc.p(0.5, 0.5));
- a.x = gameSize.width / 2 - 231;
- a.y = gameSize.height / 2 + 160;
- a.scaleX = 0.93;
- a.scaleY = 0.93;
- this.addChild(a, 4);
- this.wrongMark = cc.Sprite.create(res.wrongMark_png);
- this.wrongMark.x = gameSize.width / 2 + 145;
- this.wrongMark.y = gameSize.height / 2 - 210;
- this.wrongMark.visible = !1;
- this.addChild(this.wrongMark, 14);
- GameL.listener = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: !0,
- onTouchBegan: function(a, c) {
- var d = c.getCurrentTarget();
- if (Data.touchAble && 0 >= Data.wrongMarkTime && d.type && "food" == d.type && d.x > a._point.x && d.x < a._point.x + d.width * d.scaleX && d.y > a._point.y && d.y < a._point.y + d.height * d.scaleY) {
- Data.buttonContinue++;
- if (Data.buttonContinue > Data.res_num.length) {
- Data.buttonContinue = Data.foodHeapArray.length;
- return
- }
- Func.makeFoodHeap(d.foodName)
- }
- return !1
- },
- onTouchMoved: function(a, c) {},
- onTouchEnded: function(a, c) {
- c.getCurrentTarget().setOpacity(255);
- this.judgeEvent(c.getCurrentTarget().name)
- }
- });
- for (a = 0; a < Data.res_button.length; a++) c = cc.Sprite.create(res.cakeButtom_png), c.x = 200 * a + gameSize.width / 2 - 125, c.y = 90 + (gameSize.height / 2 - 523), c.setAnchorPoint(cc.p(1, 1)), this.addChild(c, 3), cc.log("Itme :cakeButtom_png" + JSON.stringify(c.getPosition()));
- for (a = 0; a < Data.res_button.length; a++) c = cc.Sprite.create(Data.res_button[a]), c.x = 200 * a + gameSize.width / 2 - 140 - (142 - c.width) / 2, c.y = 90 + gameSize.height / 2 - 433 - (105 - c.height), c.type = "food", c.setAnchorPoint(cc.p(1, 1)), c.foodName = Data.res_button[a], this.addChild(c, 10), Data.foodArray.push(c), cc.eventManager.addListener(GameL.listener.clone(), c);
- cc.log("Data.res fuzhi \x3d ");
- cc.log(Data.res_num);
- Func.makeFoodModel(Data.res_num, this);
- Func.makeRightButtom(Data.res_num, this);
- Func.reloadGame = function() {
- Data.releadTimes = 0;
- Data.releadNeedCount = Data.modelFoodArray.length - 1;
- switch (Data.victoryNum) {
- case 10:
- lead.setTexture(res.s_role2);
- break;
- case 20:
- lead.setTexture(res.s_role3)
- }
- Func.finish_down(Data.modelFoodArray, 100, -100, function() {
- if (Data.releadTimes >= Data.releadNeedCount) {
- Data.modelFoodArray.top && Data.modelFoodArray.top.removeFromParent();
- Data.modelFoodArray.buttom && Data.modelFoodArray.buttom.removeFromParent();
- if (Data.modelFoodArray.middle)
- for (var a = 0; a < Data.modelFoodArray.middle.length; a++) Data.modelFoodArray.middle[a].removeFromParent();
- Data.foodHeapArray = Func.removeSpirtArray(Data.foodHeapArray);
- Data.point = 0;
- Data.res_button = [];
- Data.res_num = [];
- Func.ice_random();
- Func.res_random(Data.victoryNum);
- Func.res_ra = Data.res_num.foodtype;
- for (a = 0; a < Data.res_button.length; a++) {
- Data.foodArray[a].type = "food";
- Data.foodArray[a].setAnchorPoint(cc.p(1, 1));
- var c = Data.res_button[a];
- Data.foodArray[a].foodName = c;
- Data.foodArray[a].setTexture(c);
- Data.foodArray[a].x = 200 * a + gameSize.width / 2 - 140 - (142 - Data.foodArray[a].width) / 2;
- Data.foodArray[a].y = 90 + gameSize.height / 2 - 433 - (105 - Data.foodArray[a].height)
- }
- Func.makeFoodModel(Data.res_num, this);
- Func.makeRightButtom(Data.res_num, this)
- } else Data.releadTimes++
- })
- };
- var d = function(a, c) {
- setTimeout(function() {
- a();
- d(a, c)
- }, c)
- };
- d(function() {
- if (!Data.gameStop)
- if (Data.alreadyGoTime == Config.alreadyGoTime && (Data.touchAble = !1), 0 < Data.alreadyGoTime) GameL.ready.visible = !0, 15 > Data.alreadyGoTime && (GameL.go.visible = !0), Data.alreadyGoTime--;
- else {
- 0 == Data.alreadyGoTime && (Data.music.bgMusicId = cc.audioEngine.playMusic(music.gameBg, !0), Data.touchAble = !0, GameL.ready.visible = !1, GameL.go.visible = !1, Data.alreadyGoTime--, Data.startTime = (new Date).getTime(), Data.beforeTime = Data.startTime, Data.deltaTime = 0, Data.music.last10sec = !0);
- GameL.timeBar.setPercent(100 * Data.lastTime / Config.progressBarConfig.limit);
- var a = (new Date).getTime();
- a < Data.beforeTime && (Data.startTime = a - Data.deltaTime, alert("\u6539\u65f6\u95f4\u4e5f\u6ca1\u7528\u6492"));
- Data.beforeTime = a;
- Data.deltaTime = a - Data.startTime;
- Data.lastTime = Config.progressBarConfig.now - Data.deltaTime;
- 11E3 >= Data.lastTime && Data.music.last10sec && (Data.music.last10sec = !1, cc.audioEngine.stopMusic(!0), Data.music.last10MusicId = cc.audioEngine.playEffect(music.last10sec));
- 0 < Data.wrongMarkTime ? (GameL.wrongMark.visible = !0, Data.wrongMarkTime--, 2 == Data.wrongMarkTime && (Data.foodHeapArray = Func.removeSpirtArray(Data.foodHeapArray), Func.makeRightButtom(Data.res_num), cc.audioEngine.playEffect(music.wrong), Data.music.hits = 0, Data.point = 0)) : GameL.wrongMark.visible = !1;
- 0 > Data.lastTime && (Data.lastTime = 0, Data.gameStop = !0, cc.audioEngine.stopMusic(!0), cc.audioEngine.stopEffect(Data.music.last10MusicId), Func.result(Data.victoryNum))
- }
- }, 10);
- return !0
- }
- }),
- GameL = null;
- var gameScene = null,
- layerLogin = null,
- gameSize = null,
- layerGame = null,
- gameOver = null,
- b_guide_bu = null,
- b_begin = null,
- b_guide = null,
- loginScene = cc.Scene.extend({
- onEnter: function() {
- this._super();
- layerLogin = new login;
- this.addChild(layerLogin);
- layerGame = new GameLayer;
- gameOver = new layerOver;
- gameOver.setVisible(!1);
- this.addChild(gameOver, 100)
- }
- }),
- login = cc.Layer.extend({
- beganNum: 0,
- ctor: function() {
- this._super();
- gameSize = cc.winSize;
- cc.log("game" + gameSize);
- this.init()
- },
- init: function() {
- var a = new cc.Sprite(res.background_png);
- a.attr({
- x: gameSize.width / 2,
- y: gameSize.height / 2,
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 2.3,
- scaleY: 2.6
- });
- this.addChild(a, 2);
- a = new cc.Sprite(res.gameLogo_png);
- a.attr({
- x: gameSize.width / 2,
- y: gameSize.height / 2 + 400,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.addChild(a, 2);
- a = new cc.Sprite(res.login_figure);
- a.attr({
- x: gameSize.width / 2,
- y: gameSize.height / 2,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.addChild(a, 2);
- b_begin = new ccui.Button;
- b_begin.loadTextures(res.btnNewGame_png, "", "");
- b_begin.x = gameSize.width / 2;
- b_begin.y = gameSize.height / 2 - 300;
- b_begin.addTouchEventListener(this.beginEvent, this);
- this.addChild(b_begin, 2);
- b_guide_bu = new ccui.Button;
- b_guide_bu.loadTextures(res.s_guide_png, res.s_guide_png, "");
- b_guide_bu.x = gameSize.width / 2;
- b_guide_bu.y = gameSize.height / 2 + 30;
- b_guide_bu.addTouchEventListener(this.guide_buEvent, this);
- b_guide_bu.setTouchEnabled(!1);
- b_guide_bu.setVisible(!1);
- this.addChild(b_guide_bu, 10)
- },
- beginEvent: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- cc.log("\u5f00\u59cb"), b_guide_bu.setVisible(!0), b_guide_bu.setTouchEnabled(!0);
- }
- },
- guide_buEvent: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- 0 == this.beganNum && (b_guide_bu.setVisible(!1), b_guide_bu.setTouchEnabled(!1), layerLogin.removeFromParent(), null != gameScene.getChildByTag(153) && layerGame.removeFromParent(), gameScene.addChild(layerGame, 3, 153), layerGame.init(), this.beganNum = 1)
- }
- }
- });
- var Data = {
- res_button: [],
- res_num: [],
- foodArray: [],
- foodHeapArray: [],
- point: 0,
- iceType: null,
- victoryNum: 1,
- gameStop: !1,
- touchAble: !0,
- wrongMarkTime: 0,
- buttonCountinue: 0,
- alreadyGoTime: Config.alreadyGoTime,
- music: {
- bgMusicId: 0,
- hits: 0,
- last10sec: !1,
- last10MusicId: 0
- },
- modelFoodArray: [],
- startTime: 0,
- beforeTime: 0,
- deltaTime: 0,
- lastTime: Config.progressBarConfig.now,
- reloadTimes: 0,
- reloadNeedCount: 0
- };
- var Func = {
- ice_random: function() {
- var a = Math.ceil(3 * Math.random());
- cc.log("this_randomCuot" + a);
- if (4 > Data.victoryNum) Func.ice_Event(Config.ice), Data.res_num.buttom = Config.ice.buttom, Data.res_num.foodtype = Config.ice.foodtype, Data.res_num.itemHeight = Config.ice.itemHeight, Data.res_num.bheight = Config.ice.bheight;
- else switch (a) {
- case 1:
- Func.ice_Event(Config.ice);
- Config.ice.buttom ? (Data.res_num.buttom = Config.ice.buttom, Data.res_num.foodtype = Config.ice.foodtype, Data.res_num.itemHeight = Config.ice.itemHeight, Data.res_num.bheight = Config.ice.bheight) : cc.log("Config.ice.buttom is null");
- break;
- case 2:
- Func.ice_Event(Config.cake);
- Config.cake.buttom ? (Data.res_num.buttom = Config.cake.buttom, Data.res_num.foodtype = Config.cake.foodtype, Data.res_num.itemHeight = Config.cake.itemHeight, Data.res_num.bheight = Config.cake.bheight) : cc.log("Config.cake.buttom is null");
- break;
- case 3:
- Func.ice_Event(Config.macarons), Config.macarons.buttom ? (Data.res_num.buttom = Config.macarons.buttom, Data.res_num.top = Config.macarons.top, Data.res_num.foodtype = Config.macarons.foodtype, Data.res_num.itemHeight = Config.macarons.itemHeight, Data.res_num.bheight = Config.macarons.bheight, Data.res_num.middle = Config.macarons.middle, Data.res_num.middleHeight = Config.macarons.middleHeight) : cc.log("Config.macarons.buttom is nulbheightl")
- }
- cc.log("return Res-Button");
- cc.log(Data.res_button);
- cc.log(Data.res_button.bheight);
- a = Math.ceil(3 * Math.random());
- Data.res_num.splice(a - 1, 1, Data.res_num[2]);
- return Data.res_button
- },
- ice_Event: function(a) {
- Data.res_num || (Data.res_num = []);
- Data.res_button || (Data.res_button = []);
- for (var c = 0; c < a.length; c++) Data.res_num.push(a[c]), Data.res_button.push(a[c])
- },
- res_random: function(a) {
- cc.log("cishu \x3d " + a);
- cc.log("all_cout0" + a);
- if (2 >= a) cc.log("all_cout2" + a), cc.log("di 1 2ci "), cc.log(Data.res_button), cc.log(Data.res_num), a = Math.ceil(3 * Math.random()), cc.log("random + res_cout \x3d " + a), Data.res_num.splice(a - 1, 1), cc.log("this.length" + Data.res_num.length);
- else {
- if (3 == a) cc.log("all_cout3" + a), cc.log("di san ci data "), cc.log(Data.res_button), cc.log(Data.res_num), a = Math.ceil(3 * Math.random()), Data.res_num.splice(a - 1, 1, Data.res_num[2]);
- else if (13 > a) cc.log("all count 13 " + a), cc.log("di 13 ci data"), cc.log(Data.res_button), cc.log(Data.res_num), a = Math.ceil(3 * Math.random()), 2 == Math.ceil(2 * Math.random()) ? Data.res_num.splice(a - 1, 1, Data.res_num[2]) : Data.res_num.splice(a - 1, 1), cc.log("xiaoyu 13 de ");
- else if (16 > a) {
- cc.log("all count 16 " + a);
- cc.log("di 16 ci data");
- cc.log(Data.res_button);
- cc.log(Data.res_num);
- a = Math.ceil(3 * Math.random());
- switch (Math.ceil(3 * Math.random())) {
- case 1:
- Data.res_num.splice(a - 1, 1);
- break;
- case 2:
- a = Data.res_num[a - 1];
- Data.res_num.push(a);
- break;
- case 3:
- Data.res_num.splice(a - 1, 1, Data.res_num[0])
- }
- cc.log("xiaoyu 16 de ")
- } else if (25 > a) {
- cc.log("all count 25 " + a);
- cc.log("di 25 ci data");
- cc.log(Data.res_button);
- cc.log(Data.res_num);
- a = Math.ceil(3 * Math.random());
- switch (Math.ceil(4 * Math.random())) {
- case 1:
- Data.res_num.splice(a - 1, 1);
- break;
- case 2:
- a = Data.res_num[a - 1];
- Data.res_num.push(a);
- break;
- case 3:
- a = Data.res_num[a - 1];
- var c = Data.res_num[2];
- Data.res_num.push(c);
- Data.res_num.push(a);
- break;
- case 4:
- Data.res_num.splice(a - 1, 1, Data.res_num[1])
- }
- cc.log("xiaoyu 25 de ")
- } else {
- cc.log("all count 28 " + a);
- cc.log("di 28 ci data");
- cc.log(Data.res_button);
- cc.log(Data.res_num);
- a = Math.ceil(3 * Math.random());
- switch (Math.ceil(3 * Math.random())) {
- case 1:
- a = Data.res_num[a - 1];
- Data.res_num.push(a);
- break;
- case 2:
- a = Data.res_num[a - 1];
- c = Data.res_num[2];
- Data.res_num.push(c);
- Data.res_num.push(a);
- break;
- case 3:
- Data.res_num.splice(a - 1, 1, Data.res_num[0])
- }
- cc.log("dayu 25 de ")
- }
- cc.log(Data.res_num)
- }
- return Data.res_num
- },
- makeRightButtom: function(a) {
- if (null != a) {
- null == Data.foodHeapArray && (Data.foodHeapArray = []);
- a.buttom && (Data.foodHeapArray.buttom = cc.Sprite.create(a.buttom), Data.foodHeapArray.buttom.scaleX = 1, Data.foodHeapArray.buttom.scaleY = 1, GameL.addChild(Data.foodHeapArray.buttom, 9), Data.foodHeapArray.buttom.x = gameSize.width / 2 + 142, Data.foodHeapArray.buttom.y = gameSize.height / 2 - 242, a.buttom == res.cakeButtom_png && (Data.foodHeapArray.buttom.y = gameSize.height / 2 - 270), Data.foodHeapArray.buttom.bheight = a.bheight);
- var c = Data.foodHeapArray.buttom.y + Data.foodHeapArray.buttom.bheight + 30;
- if (a.middle) {
- Data.foodHeapArray.middle = [];
- Data.foodHeapArray.middleHeight = a.middleHeight;
- for (var d = a.length - 1, e = 0; e < d; e++) {
- var f = cc.Sprite.create(a.middle);
- f.scaleX = 1;
- f.scaleY = 1;
- GameL.addChild(f, 9);
- f.x = gameSize.width / 2 + 142;
- f.y = c;
- Data.foodHeapArray.middle.push(f);
- c += Data.foodHeapArray.middleHeight
- }
- }
- a.top && (Data.foodHeapArray.top = cc.Sprite.create(a.top), Data.foodHeapArray.top.scaleX = 1, Data.foodHeapArray.top.scaleY = 1, GameL.addChild(Data.foodHeapArray.top, 9), Data.foodHeapArray.top.x = gameSize.width / 2 + 142, Data.foodHeapArray.top.y = c, Data.foodHeapArray.top.theight = 0);
- a.itemHeight && (Data.foodHeapArray.itemHeight = a.itemHeight);
- a.foodtype && (Data.foodHeapArray.foodtype = a.foodtype)
- }
- },
- makeFoodHeap: function(a) {
- if (null != a && (null == Data.foodHeapArray && (Data.foodHeapArray = []), !(Data.foodHeapArray.length >= Data.modelFoodArray.length))) {
- var c = cc.Sprite.create(a);
- c.foodImg = a;
- Data.foodHeapArray.push(c);
- var d = Data.foodHeapArray.length - 1;
- c.scaleX = 1;
- c.scaleY = 1;
- c.x = gameSize.width / 2 + 142;
- c.y = 1E3 + 50 * d;
- c.foodtype = Data.foodHeapArray.foodtype;
- GameL.addChild(c, 10);
- var e = null;
- switch (Data.music.hits) {
- case 0:
- e = music.hits1;
- break;
- case 1:
- e = music.hits2;
- break;
- case 2:
- e = music.hits3;
- break;
- case 3:
- e = music.hits4;
- break;
- default:
- e = music.hits4
- };
- cc.audioEngine.playEffect(e);
- Func.item_down(c, gameSize.width / 2 + 142, Data.modelFoodArray.buttom.bheight + d * Data.modelFoodArray.itemHeight + gameSize.height / 2 - 280, function() {
- Func.isRight(a) ? (Data.music.hits++, Func.isAllOk() && (Data.music.hits = 0, Data.buttonContinue = 0, cc.audioEngine.playEffect(music.hitsOver), Data.victoryNum++, GameL.victoryNum.setString(Data.victoryNum - 1 + "\u65a4"), Func.reloadGame())) : (Data.buttonContinue = 0, Data.wrongMarkTime = 10)
- })
- }
- },
- makeFoodModel: function(a) {
- if (null != a) {
- null == Data.modelFoodArray && (Data.modelFoodArray = []);
- Data.modelFoodArray.foodtype = a.foodtype;
- a.itemHeight && (Data.modelFoodArray.itemHeight = a.itemHeight);
- Data.modelFoodArray.buttom = null;
- Data.modelFoodArray.top = null;
- a.buttom && (Data.modelFoodArray.buttom = cc.Sprite.create(a.buttom), Data.modelFoodArray.buttom.scaleX = 1, Data.modelFoodArray.buttom.scaleY = 1, GameL.addChild(Data.modelFoodArray.buttom, 5), Data.modelFoodArray.buttom.x = gameSize.width / 2 - 132, Data.modelFoodArray.buttom.y = gameSize.height / 2 - 242, a.buttom == res.cakeButtom_png && (Data.modelFoodArray.buttom.y = gameSize.height / 2 - 270), Data.modelFoodArray.buttom.bheight = a.bheight);
- var c = Data.modelFoodArray.buttom.y + Data.modelFoodArray.buttom.bheight + 30;
- if (a.middle) {
- Data.modelFoodArray.middle = [];
- Data.modelFoodArray.middleHeight = a.middleHeight;
- for (var d = a.length - 1, e = 0; e < d; e++) {
- var f = cc.Sprite.create(a.middle);
- f.scaleX = 1;
- f.scaleY = 1;
- GameL.addChild(f, 9);
- f.x = gameSize.width / 2 - 132;
- f.y = c;
- Data.modelFoodArray.middle.push(f);
- c += Data.modelFoodArray.middleHeight
- }
- }
- for (e = 0; e < Data.modelFoodArray.length; e++) Data.modelFoodArray[e].visible = !1;
- d = Data.modelFoodArray.buttom.bheight + Data.modelFoodArray.itemHeight + gameSize.height / 2 - 280;
- for (e = 0; e < a.length; e++) Data.modelFoodArray[e] || (f = cc.Sprite.create(res.HelloWorld_png), f.scaleX = 1, f.scaleY = 1, GameL.addChild(f, 10), Data.modelFoodArray.push(f)), Data.modelFoodArray[e].x = gameSize.width / 2 - 132, Data.modelFoodArray[e].y = d, d += Data.modelFoodArray.itemHeight, Data.modelFoodArray[e].setTexture(a[e]), Data.modelFoodArray[e].visible = !0, Data.modelFoodArray[e].foodtype = a.foodtype;
- a.top && (Data.modelFoodArray.top = cc.Sprite.create(a.top), Data.modelFoodArray.top.scaleX = 1, Data.modelFoodArray.top.scaleY = 1, GameL.addChild(Data.modelFoodArray.top, 5), Data.modelFoodArray.top.x = gameSize.width / 2 - 132, Data.modelFoodArray.top.y = c)
- }
- },
- isRight: function(a) {
- return !(Data.point >= Data.res_num.length) && Data.res_num[Data.point] == a ? (Data.point++, !0) : !1
- },
- isAllOk: function() {
- if (Data.foodHeapArray.length == Data.res_num.length) {
- for (var a = !0, c = 0; c < Data.foodHeapArray.length; c++) Data.foodHeapArray[c].foodImg != Data.res_num[c] && (a = !1);
- !1 == a && (Data.buttonContinue = 0, Data.wrongMarkTime = 10);
- return a
- }
- return !1
- },
- removeSpirtArray: function(a) {
- cc.log("begin remove");
- a.top && a.top.removeFromParent();
- a.buttom && a.buttom.removeFromParent();
- if (a.middle)
- for (var c = 0; c < a.middle.length; c++) a.middle[c].removeFromParent();
- for (c = 0; c < a.length; c++) console.log(a[c]), a[c].removeFromParent();
- cc.log(a);
- cc.log("end");
- return []
- },
- reloadGame: null,
- item_down: function(a, c, d, e) {
- cc.log("sheng create");
- cc.log(a.foodtype);
- switch (a.foodtype) {
- case "ice":
- Func.iceAction(a, c, d, e);
- break;
- case "cake":
- Func.cakeAction(a, c, d, e);
- break;
- case "macarons":
- Func.macarons(a, c, d, e)
- }
- },
- iceAction: function(a, c, d, e) {
- c = new cc.MoveTo(0.3, cc.p(c, d - 24));
- d = new cc.ScaleTo(0.1, 1, 1.4);
- var f = new cc.ScaleTo(0.1, 1, 1),
- g = new cc.ScaleTo(0.1, 1, 1.3),
- h = new cc.ScaleTo(0.1, 1, 1),
- k = new cc.ScaleTo(0.1, 1, 1.2),
- m = new cc.ScaleTo(0.1, 1, 1),
- n = new cc.ScaleTo(0.1, 1, 1.1),
- q = new cc.ScaleTo(0.1, 1, 1);
- e = new cc.Sequence(c, d, f, g, h, k, m, n, q, new cc.CallFunc(e, this, !0));
- a.setAnchorPoint(cc.p(0.5, 0));
- a.runAction(e)
- },
- macarons: function(a, c, d, e) {
- c = new cc.MoveTo(0.3, cc.p(c, d + 35));
- d = new cc.RotateTo(0.1, -10);
- var f = new cc.RotateTo(0.1, 0),
- g = new cc.RotateTo(0.1, 10),
- h = new cc.RotateTo(0.1, 0),
- k = new cc.RotateTo(0.1, 5),
- m = new cc.RotateTo(0.1, 0);
- e = new cc.Sequence(c, d, f, g, h, k, m, new cc.CallFunc(e, this, !0));
- a.runAction(e)
- },
- cakeAction: function(a, c, d, e) {
- cc.log("zhixing cakeAction");
- c = new cc.MoveTo(0.2, cc.p(c, d + 35));
- d = new cc.ScaleTo(0.1, 1, 1);
- var f = new cc.ScaleTo(0.1, 1, 0.8),
- g = new cc.ScaleTo(0.1, 1, 1.1),
- h = new cc.ScaleTo(0.1, 1, 0.9),
- k = new cc.ScaleTo(0.1, 1, 1),
- m = new cc.ScaleTo(0.1, 1, 0.95),
- n = new cc.ScaleTo(0.1, 1, 1.02),
- q = new cc.ScaleTo(0.1, 1, 1);
- cc.log("wupin diao luo");
- cc.log(a);
- e = new cc.Sequence(c, d, f, g, h, k, m, n, q, new cc.CallFunc(e, this, !0));
- a.setAnchorPoint(cc.p(0.5, 0.3));
- cc.log("\u6389\u843d\u5b8c\u6210");
- a.runAction(e)
- },
- finish_down: function(a, c, d, e) {
- for (var f = 0; f < a.length; f++) {
- var g = new cc.MoveTo(0.1, cc.p(c, d)),
- g = new cc.Sequence(g, new cc.CallFunc(e, this, !0));
- a[f].runAction(g)
- }
- a.buttom && (g = new cc.MoveTo(0.1, cc.p(c, d)), g = new cc.Sequence(g), a.buttom.runAction(g));
- a.top && (g = new cc.MoveTo(0.1, cc.p(c, d)), g = new cc.Sequence(g), a.top.runAction(g));
- if (a.middle)
- for (f = 0; f < a.middle.length; f++) g = new cc.MoveTo(0.1, cc.p(c, d)), g = new cc.Sequence(g), a.middle[f].runAction(g)
- },
- overfunc: null,
- result: function(a) {
- cc.log("gameOver");
- GameL.visible = !1;
- dp_submitScore(a - 1);
- window.scroe = a - 1;
- // updateShare(a - 1);
- // Play68.setRankingScoreDesc(a - 1);
- document.getElementById("toolbar").style.display = "block";
- Func.overfunc(a);
- cc.audioEngine.playEffect(music.result)
- },
- barReset: null,
- reStart: function() {
- Data.foodHeapArray = Func.removeSpirtArray(Data.foodHeapArray);
- GameL.visible = !0;
- Data.res_button = [];
- Data.res_num = [];
- Data.foodHeapArray = [];
- Data.point = 0;
- Data.iceType = null;
- Data.victoryNum = 1;
- GameL.victoryNum.setString(Data.victoryNum - 1 + "\u65a4");
- Data.gameStop = !1;
- Data.touchAble = !0;
- Data.wrongMarkTime = 0;
- Data.music.hits = 0;
- Data.alreadyGoTime = Config.alreadyGoTime;
- Data.lastTime = Config.progressBarConfig.now;
- Func.barReset();
- Func.reloadGame()
- },
- createNumSprite: function(a) {
- new cc.Sprite("")
- }
- };
- Func.overfunc = function(a) {
- cc.log("gameOver begin");
- b_share.setTouchEnabled(!0);
- cc.log("get cunt \x3d" + a);
- fin_cunt = a - 1;
- gameOver.setVisible(!0);
- cc.log(gameOver.overrole);
- 10 > fin_cunt ? gameOver.overrole.loadTexture(res.s_role1) : 20 > fin_cunt ? gameOver.overrole.loadTexture(res.s_role2) : gameOver.overrole.loadTexture(res.s_role3);
- gameOver.num.setString(fin_cunt);
- gameOver.numJin.setString(fin_cunt);
- return !0
- };
- var fin_cunt = null,
- b_again = null,
- b_share = null,
- b_share_l = null,
- layerOver = cc.Layer.extend({
- overrole: null,
- paopao: null,
- fenxiangzi: null,
- fenxiang: null,
- num: null,
- numJin: null,
- overfigure: null,
- b_share1: null,
- ctor: function() {
- this._super();
- this.init()
- },
- init: function() {
- this.backsprite = new cc.Sprite(res.background_png);
- this.backsprite.attr({
- x: gameSize.width / 2,
- y: gameSize.height / 2,
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 2.1,
- scaleY: 2
- });
- this.addChild(this.backsprite, 2);
- cc.log("fin_cunt\x3d" + fin_cunt);
- this.overfigure = new cc.Sprite(res.dialogBg);
- this.overfigure.attr({
- x: gameSize.width / 2,
- y: gameSize.height / 2 - 200,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.addChild(this.overfigure, 2);
- this.num = new cc.LabelBMFont("0", res.s_fnt);
- this.num.x = gameSize.width / 2 + 135;
- this.num.y = gameSize.height / 2 - 175;
- this.addChild(this.num, 3);
- this.numJin = new cc.LabelBMFont("0", res.s_fnt);
- this.numJin.x = gameSize.width / 2 - 50;
- this.numJin.y = gameSize.height / 2 - 175;
- this.addChild(this.numJin, 3);
- this.overrole = new ccui.ImageView;
- this.overrole.x = gameSize.width / 2;
- this.overrole.y = gameSize.height / 2 + 30;
- this.overrole.loadTexture(res.s_role1);
- this.addChild(this.overrole, 2);
- b_again = new ccui.Button;
- b_again.loadTextures(res.btnShare_png, "", "");
- b_again.x = gameSize.width / 2 - 130;
- b_again.y = gameSize.height / 2 - 360;
- b_again.addTouchEventListener(this.shareTips, this);
- b_again.setTouchEnabled(!1);
- b_again.setVisible(!1);
- this.addChild(b_again, 11);
- b_again2 = new ccui.Button;
- b_again2.loadTextures(res.btnAgain_png, "", "");
- b_again2.x = gameSize.width / 2 - 130;
- b_again2.y = gameSize.height / 2 - 360;
- b_again2.addTouchEventListener(this.againEvent, this);
- this.addChild(b_again2, 2);
- b_share = new ccui.Button;
- b_share.loadTextures(res.btnKnown, "", "");
- b_share.x = gameSize.width / 2 + 130;
- b_share.y = gameSize.height / 2 - 360;
- b_share.addTouchEventListener(this.shareEvent, this);
- this.addChild(b_share, 2);
- this.b_share1 = new ccui.Button;
- this.b_share1.loadTextures(res.btnShare1, "", "");
- this.b_share1.x = gameSize.width / 2 + 130;
- this.b_share1.y = gameSize.height / 2 - 360;
- this.b_share1.addTouchEventListener(this.jumpurl, this);
- this.b_share1.setTouchEnabled(!1);
- this.b_share1.setVisible(!1);
- this.addChild(this.b_share1, 11);
- b_share_l = new ccui.Button;
- b_share_l.loadTextures(res.s_share, "", "");
- b_share_l.x = gameSize.width / 2;
- b_share_l.y = gameSize.height / 2 + 30;
- b_share_l.addTouchEventListener(this.shareLayerEvent, this);
- b_share_l.setTouchEnabled(!1);
- b_share_l.setVisible(!1);
- this.addChild(b_share_l, 10);
- this.paopao = new cc.Sprite(res.s_paopao);
- this.paopao.attr({
- x: gameSize.width / 2 + 90,
- y: gameSize.height - 80,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.paopao.setVisible(!1);
- this.addChild(this.paopao, 12);
- this.fenxiangzi = new cc.Sprite(res.s_fenxiangzi);
- this.fenxiangzi.attr({
- x: gameSize.width / 2,
- y: gameSize.height - 920,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.fenxiangzi.setVisible(!1);
- this.addChild(this.fenxiangzi, 12);
- this.fenxiang = new cc.Sprite(res.s_fenxiang);
- this.fenxiang.attr({
- x: gameSize.width / 2 + 80,
- y: gameSize.height - 100,
- anchorX: 0.5,
- anchorY: 0.5
- });
- this.fenxiang.setVisible(!1);
- this.addChild(this.fenxiang, 22)
- },
- againEvent: function(a, c) {
- document.getElementById("toolbar").style.display = "none";
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- gameOver.setVisible(!1), b_again.setTouchEnabled(!1), b_share.setTouchEnabled(!1), Func.reStart();
- }
- },
- shareTips: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- gameOver.fenxiang.setVisible(!0), gameOver.fenxiangzi.setVisible(!0), gameOver.paopao.setVisible(!0), b_share_l.setTouchEnabled(!0), b_share_l.setVisible(!0), this.backsprite.setColor(cc.color(75, 75, 75)), this.overfigure.setColor(cc.color(75, 75, 75))
- }
- },
- shareEvent: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- dp_share();
- return;
- cc.log("\u5206\u4eab"), this.overfigure.setVisible(!1), b_share.setTouchEnabled(!1), b_share.setVisible(!1), b_again2.setTouchEnabled(!1), b_again2.setVisible(!1), b_share_l.setTouchEnabled(!0), b_share_l.setVisible(!0), this.b_share1.setVisible(!1), this.b_share1.setTouchEnabled(!0), b_again.setTouchEnabled(!0), b_again.setVisible(!0)
- }
- },
- shareLayerEvent: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- cc.log("\u5206\u4eab\u754c\u9762"), gameOver.setVisible(!1), b_again.setTouchEnabled(!1), b_share.setTouchEnabled(!1), document.getElementById("toolbar").style.display = "none", Func.reStart()
- }
- },
- jumpurl: function(a, c) {
- switch (c) {
- case ccui.Widget.TOUCH_ENDED:
- jump()
- }
- }
- });
- cc.game.onStart = function() {
- cc.view.adjustViewPort(!0);
- var a = cc.view.getFrameSize();
- factorX = a.width / 640;
- factorY = a.height / 960;
- cc.view.setDesignResolutionSize(640, 960, cc.ResolutionPolicy.SHOW_ALL);
- cc.LoaderScene.preload(g_resources, function() {
- gameScene = new loginScene;
- cc.director.runScene(gameScene)
- }, this)
- };
- cc.game.run();
|