game.min.js 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844
  1. var cc = cc || {};
  2. cc._tmp = cc._tmp || {};
  3. cc._LogInfos = {};
  4. _p = window;
  5. _p = Object.prototype;
  6. delete window._p;
  7. cc.newElement = function(a) {
  8. return document.createElement(a)
  9. };
  10. cc._addEventListener = function(a, c, d, e) {
  11. a.addEventListener(c, d, e)
  12. };
  13. cc._isNodeJs = "undefined" !== typeof require && require("fs");
  14. cc.each = function(a, c, d) {
  15. if (a)
  16. if (a instanceof Array)
  17. for (var e = 0, f = a.length; e < f && !1 !== c.call(d, a[e], e); e++);
  18. else
  19. for (e in a)
  20. if (!1 === c.call(d, a[e], e)) break
  21. };
  22. cc.isCrossOrigin = function(a) {
  23. if (!a) return cc.log("invalid URL"), !1;
  24. var c = a.indexOf("://");
  25. if (-1 == c) return !1;
  26. c = a.indexOf("/", c + 3);
  27. return (-1 == c ? a : a.substring(0, c)) != location.origin
  28. };
  29. cc.async = {
  30. _counterFunc: function(a) {
  31. var c = this.counter;
  32. if (!c.err) {
  33. var d = c.length,
  34. e = c.results,
  35. f = c.option,
  36. g = f.cb,
  37. h = f.cbTarget,
  38. k = f.trigger,
  39. f = f.triggerTarget;
  40. if (a) {
  41. if (c.err = a, g) return g.call(h, a)
  42. } else {
  43. var m = Array.apply(null, arguments).slice(1),
  44. n = m.length;
  45. 0 == n ? m = null : 1 == n && (m = m[0]);
  46. e[this.index] = m;
  47. c.count--;
  48. k && k.call(f, m, d - c.count, d);
  49. 0 == c.count && g && g.apply(h, [null, e])
  50. }
  51. }
  52. },
  53. _emptyFunc: function() {},
  54. parallel: function(a, c, d) {
  55. var e = cc.async;
  56. if (void 0 !== d) "function" == typeof c && (c = {
  57. trigger: c
  58. }), c.cb = d || c.cb;
  59. else if (void 0 !== c) "function" == typeof c && (c = {
  60. cb: c
  61. });
  62. else if (void 0 !== a) c = {};
  63. else throw "arguments error!";
  64. var f = (d = a instanceof Array) ? a.length : Object.keys(a).length;
  65. if (0 == f) c.cb && c.cb.call(c.cbTarget, null);
  66. else {
  67. var g = {
  68. length: f,
  69. count: f,
  70. option: c,
  71. results: d ? [] : {}
  72. };
  73. cc.each(a, function(a, d) {
  74. if (g.err) return !1;
  75. var f = !c.cb && !c.trigger ? e._emptyFunc : e._counterFunc.bind({
  76. counter: g,
  77. index: d
  78. });
  79. a(f, d)
  80. })
  81. }
  82. },
  83. map: function(a, c, d) {
  84. var e = this,
  85. f = arguments.length;
  86. "function" == typeof c && (c = {
  87. iterator: c
  88. });
  89. if (3 === f) c.cb = d || c.cb;
  90. else if (2 > f) throw "arguments error!";
  91. "function" == typeof c && (c = {
  92. iterator: c
  93. });
  94. if (void 0 !== d) c.cb = d || c.cb;
  95. else if (void 0 === a) throw "arguments error!";
  96. var g = (f = a instanceof Array) ? a.length : Object.keys(a).length;
  97. if (0 === g) c.cb && c.cb.call(c.cbTarget, null);
  98. else {
  99. var h = {
  100. length: g,
  101. count: g,
  102. option: c,
  103. results: f ? [] : {}
  104. };
  105. cc.each(a, function(a, d) {
  106. if (h.err) return !1;
  107. var f = !c.cb ? e._emptyFunc : e._counterFunc.bind({
  108. counter: h,
  109. index: d
  110. });
  111. c.iterator.call(c.iteratorTarget, a, d, f)
  112. })
  113. }
  114. }
  115. };
  116. cc.path = {
  117. join: function() {
  118. for (var a = arguments.length, c = "", d = 0; d < a; d++) c = (c + ("" == c ? "" : "/") + arguments[d]).replace(/(\/|\\\\)$/, "");
  119. return c
  120. },
  121. extname: function(a) {
  122. return (a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null
  123. },
  124. mainFileName: function(a) {
  125. if (a) {
  126. var c = a.lastIndexOf(".");
  127. if (-1 !== c) return a.substring(0, c)
  128. }
  129. return a
  130. },
  131. basename: function(a, c) {
  132. var d = a.indexOf("?");
  133. 0 < d && (a = a.substring(0, d));
  134. d = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, ""));
  135. if (!d) return null;
  136. d = d[2];
  137. return c && a.substring(a.length - c.length).toLowerCase() == c.toLowerCase() ? d.substring(0, d.length - c.length) : d
  138. },
  139. dirname: function(a) {
  140. return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2")
  141. },
  142. changeExtname: function(a, c) {
  143. c = c || "";
  144. var d = a.indexOf("?"),
  145. e = "";
  146. 0 < d && (e = a.substring(d), a = a.substring(0, d));
  147. d = a.lastIndexOf(".");
  148. return 0 > d ? a + c + e : a.substring(0, d) + c + e
  149. },
  150. changeBasename: function(a, c, d) {
  151. if (0 == c.indexOf(".")) return this.changeExtname(a, c);
  152. var e = a.indexOf("?"),
  153. f = "";
  154. d = d ? this.extname(a) : "";
  155. 0 < e && (f = a.substring(e), a = a.substring(0, e));
  156. e = a.lastIndexOf("/");
  157. return a.substring(0, 0 >= e ? 0 : e + 1) + c + d + f
  158. }
  159. };
  160. cc.loader = {
  161. _jsCache: {},
  162. _register: {},
  163. _langPathCache: {},
  164. _aliases: {},
  165. resPath: "",
  166. audioPath: "",
  167. cache: {},
  168. getXMLHttpRequest: function() {
  169. return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP")
  170. },
  171. _getArgs4Js: function(a) {
  172. var c = a[0],
  173. d = a[1],
  174. e = a[2],
  175. f = ["", null, null];
  176. if (1 === a.length) f[1] = c instanceof Array ? c : [c];
  177. 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]);
  178. else if (3 === a.length) f[0] = c || "", f[1] = d instanceof Array ? d : [d], f[2] = e;
  179. else throw "arguments error to load js!";
  180. return f
  181. },
  182. loadJs: function(a, c, d) {
  183. var e = this,
  184. f = e._jsCache,
  185. 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) {
  186. a = cc.path.join(g[0], a);
  187. if (f[a]) return d(null);
  188. e._createScript(a, !1, d)
  189. }, g[2])
  190. },
  191. loadJsWithImg: function(a, c, d) {
  192. var e = this._loadJsImg(),
  193. f = this._getArgs4Js(arguments);
  194. this.loadJs(f[0], f[1], function(a) {
  195. if (a) throw a;
  196. e.parentNode.removeChild(e);
  197. if (f[2]) f[2]()
  198. })
  199. },
  200. _createScript: function(a, c, d) {
  201. var e = document,
  202. f = cc.newElement("script");
  203. f.async = c;
  204. f.src = a;
  205. this._jsCache[a] = !0;
  206. cc._addEventListener(f, "load", function() {
  207. this.removeEventListener("load", arguments.callee, !1);
  208. d()
  209. }, !1);
  210. cc._addEventListener(f, "error", function() {
  211. d("Load " + a + " failed!")
  212. }, !1);
  213. e.body.appendChild(f)
  214. },
  215. _loadJs4Dependency: function(a, c, d, e) {
  216. if (d >= c.length) e && e();
  217. else {
  218. var f = this;
  219. f._createScript(cc.path.join(a, c[d]), !1, function(g) {
  220. if (g) return e(g);
  221. f._loadJs4Dependency(a, c, d + 1, e)
  222. })
  223. }
  224. },
  225. _loadJsImg: function() {
  226. var a = document,
  227. c = a.getElementById("cocos2d_loadJsImg");
  228. if (!c) {
  229. c = cc.newElement("img");
  230. cc._loadingImage && (c.src = cc._loadingImage);
  231. a = a.getElementById(cc.game.config.id);
  232. a.style.backgroundColor = "black";
  233. a.parentNode.appendChild(c);
  234. var d = getComputedStyle ? getComputedStyle(a) : a.currentStyle;
  235. d || (d = {
  236. width: a.width,
  237. height: a.height
  238. });
  239. c.style.left = a.offsetLeft + (parseFloat(d.width) - c.width) / 2 + "px";
  240. c.style.top = a.offsetTop + (parseFloat(d.height) - c.height) / 2 + "px";
  241. c.style.position = "absolute"
  242. }
  243. return c
  244. },
  245. loadTxt: function(a, c) {
  246. if (cc._isNodeJs) require("fs").readFile(a, function(a, d) {
  247. a ? c(a) : c(null, d.toString())
  248. });
  249. else {
  250. var d = this.getXMLHttpRequest(),
  251. e = "load " + a + " failed!";
  252. d.open("GET", a, !0);
  253. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "utf-8"), d.onreadystatechange = function() {
  254. 4 == d.readyState && 200 == d.status ? c(null, d.responseText) : c(e)
  255. }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dutf-8"), d.onload = function() {
  256. 4 == d.readyState && 200 == d.status ? c(null, d.responseText) : c(e)
  257. });
  258. d.send(null)
  259. }
  260. },
  261. _loadTxtSync: function(a) {
  262. if (cc._isNodeJs) return require("fs").readFileSync(a).toString();
  263. var c = this.getXMLHttpRequest();
  264. c.open("GET", a, !1);
  265. /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");
  266. c.send(null);
  267. return 4 == !c.readyState || 200 != c.status ? null : c.responseText
  268. },
  269. loadJson: function(a, c) {
  270. this.loadTxt(a, function(d, e) {
  271. try {
  272. d ? c(d) : c(null, JSON.parse(e))
  273. } catch (f) {
  274. throw "load json [" + a + "] failed : " + f;
  275. }
  276. })
  277. },
  278. _checkIsImageURL: function(a) {
  279. return null != /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)
  280. },
  281. loadImg: function(a, c, d) {
  282. var e = !0;
  283. void 0 !== d ? e = null == c.isCrossOrigin ? e : c.isCrossOrigin : void 0 !== c && (d = c);
  284. var f = new Image;
  285. e && "file://" != location.origin && (f.crossOrigin = "Anonymous");
  286. cc._addEventListener(f, "load", function() {
  287. this.removeEventListener("load", arguments.callee, !1);
  288. this.removeEventListener("error", arguments.callee, !1);
  289. d && d(null, f)
  290. });
  291. cc._addEventListener(f, "error", function() {
  292. this.removeEventListener("error", arguments.callee, !1);
  293. d && d("load image failed")
  294. });
  295. f.src = a;
  296. return f
  297. },
  298. _loadResIterator: function(a, c, d) {
  299. var e = this,
  300. f = null,
  301. g = a.type;
  302. g ? (g = "." + g.toLowerCase(), f = a.src ? a.src : a.name + g) : (f = a, g = cc.path.extname(f));
  303. if (c = e.cache[f]) return d(null, c);
  304. c = e._register[g.toLowerCase()];
  305. if (!c) return cc.error("loader for [" + g + "] not exists!"), d();
  306. g = c.getBasePath ? c.getBasePath() : e.resPath;
  307. g = e.getUrl(g, f);
  308. c.load(g, f, a, function(a, c) {
  309. a ? (cc.log(a), e.cache[f] = null, delete e.cache[f], d()) : (e.cache[f] = c, d(null, c))
  310. })
  311. },
  312. getUrl: function(a, c) {
  313. var d = this._langPathCache,
  314. e = cc.path;
  315. if (void 0 !== a && void 0 === c) {
  316. c = a;
  317. var f = e.extname(c),
  318. f = f ? f.toLowerCase() : "";
  319. a = (f = this._register[f]) ? f.getBasePath ? f.getBasePath() : this.resPath : this.resPath
  320. }
  321. c = cc.path.join(a || "", c);
  322. if (c.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) {
  323. if (d[c]) return d[c];
  324. e = e.extname(c) || "";
  325. c = d[c] = c.substring(0, c.length - e.length) + "_" + cc.sys.language + e
  326. }
  327. return c
  328. },
  329. load: function(a, c, d) {
  330. if (void 0 !== d) "function" == typeof c && (c = {
  331. trigger: c
  332. });
  333. else if (void 0 !== c) "function" == typeof c && (d = c, c = {});
  334. else if (void 0 !== a) c = {};
  335. else throw "arguments error!";
  336. c.cb = function(a, c) {
  337. a && cc.log(a);
  338. d && d(c)
  339. };
  340. a instanceof Array || (a = [a]);
  341. c.iterator = this._loadResIterator;
  342. c.iteratorTarget = this;
  343. cc.async.map(a, c)
  344. },
  345. _handleAliases: function(a, c) {
  346. var d = this._aliases,
  347. e = [],
  348. f;
  349. for (f in a) {
  350. var g = a[f];
  351. d[f] = g;
  352. e.push(g)
  353. }
  354. this.load(e, c)
  355. },
  356. loadAliases: function(a, c) {
  357. var d = this,
  358. e = d.getRes(a);
  359. e ? d._handleAliases(e.filenames, c) : d.load(a, function(a) {
  360. d._handleAliases(a[0].filenames, c)
  361. })
  362. },
  363. register: function(a, c) {
  364. if (a && c) {
  365. if ("string" == typeof a) return this._register[a.trim().toLowerCase()] = c;
  366. for (var d = 0, e = a.length; d < e; d++) this._register["." + a[d].trim().toLowerCase()] = c
  367. }
  368. },
  369. getRes: function(a) {
  370. return this.cache[a] || this.cache[this._aliases[a]]
  371. },
  372. release: function(a) {
  373. var c = this.cache,
  374. d = this._aliases;
  375. delete c[a];
  376. delete c[d[a]];
  377. delete d[a]
  378. },
  379. releaseAll: function() {
  380. var a = this.cache,
  381. c = this._aliases,
  382. d;
  383. for (d in a) delete a[d];
  384. for (d in c) delete c[d]
  385. }
  386. };
  387. (function() {
  388. var a = window,
  389. c, d;
  390. "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");
  391. var e = function() {
  392. cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide)
  393. },
  394. f = function() {
  395. cc.eventManager && cc.game._eventShow && cc.eventManager.dispatchEvent(cc.game._eventShow);
  396. cc.game._intervalId && (window.cancelAnimationFrame(cc.game._intervalId), cc.game._runMainLoop())
  397. };
  398. c ? cc._addEventListener(document, d, function() {
  399. document[c] ? e() : f()
  400. }, !1) : (cc._addEventListener(a, "blur", e, !1), cc._addEventListener(a, "focus", f, !1)); - 1 < navigator.userAgent.indexOf("MicroMessenger") && (a.onfocus = function() {
  401. f()
  402. });
  403. "onpageshow" in window && "onpagehide" in window && (cc._addEventListener(a, "pagehide", e, !1), cc._addEventListener(a, "pageshow", f, !1));
  404. d = a = null
  405. })();
  406. cc.log = cc.warn = cc.error = cc.assert = function() {};
  407. cc.create3DContext = function(a, c) {
  408. for (var d = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], e = null, f = 0; f < d.length; ++f) {
  409. try {
  410. e = a.getContext(d[f], c)
  411. } catch (g) {}
  412. if (e) break
  413. }
  414. return e
  415. };
  416. cc._initSys = function(a, c) {
  417. cc._RENDER_TYPE_CANVAS = 0;
  418. cc._RENDER_TYPE_WEBGL = 1;
  419. cc.sys = {};
  420. var d = cc.sys;
  421. d.LANGUAGE_ENGLISH = "en";
  422. d.LANGUAGE_CHINESE = "zh";
  423. d.LANGUAGE_FRENCH = "fr";
  424. d.LANGUAGE_ITALIAN = "it";
  425. d.LANGUAGE_GERMAN = "de";
  426. d.LANGUAGE_SPANISH = "es";
  427. d.LANGUAGE_RUSSIAN = "ru";
  428. d.LANGUAGE_KOREAN = "ko";
  429. d.LANGUAGE_JAPANESE = "ja";
  430. d.LANGUAGE_HUNGARIAN = "hu";
  431. d.LANGUAGE_PORTUGUESE = "pt";
  432. d.LANGUAGE_ARABIC = "ar";
  433. d.LANGUAGE_NORWEGIAN = "no";
  434. d.LANGUAGE_POLISH = "pl";
  435. d.OS_WINDOWS = "Windows";
  436. d.OS_IOS = "iOS";
  437. d.OS_OSX = "OS X";
  438. d.OS_UNIX = "UNIX";
  439. d.OS_LINUX = "Linux";
  440. d.OS_ANDROID = "Android";
  441. d.OS_UNKNOWN = "Unknown";
  442. d.WINDOWS = 0;
  443. d.LINUX = 1;
  444. d.MACOS = 2;
  445. d.ANDROID = 3;
  446. d.IPHONE = 4;
  447. d.IPAD = 5;
  448. d.BLACKBERRY = 6;
  449. d.NACL = 7;
  450. d.EMSCRIPTEN = 8;
  451. d.TIZEN = 9;
  452. d.WINRT = 10;
  453. d.WP8 = 11;
  454. d.MOBILE_BROWSER = 100;
  455. d.DESKTOP_BROWSER = 101;
  456. d.BROWSER_TYPE_WECHAT = "wechat";
  457. d.BROWSER_TYPE_ANDROID = "androidbrowser";
  458. d.BROWSER_TYPE_IE = "ie";
  459. d.BROWSER_TYPE_QQ = "qqbrowser";
  460. d.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
  461. d.BROWSER_TYPE_UC = "ucbrowser";
  462. d.BROWSER_TYPE_360 = "360browser";
  463. d.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
  464. d.BROWSER_TYPE_BAIDU = "baidubrowser";
  465. d.BROWSER_TYPE_MAXTHON = "maxthon";
  466. d.BROWSER_TYPE_OPERA = "opera";
  467. d.BROWSER_TYPE_MIUI = "miuibrowser";
  468. d.BROWSER_TYPE_FIREFOX = "firefox";
  469. d.BROWSER_TYPE_SAFARI = "safari";
  470. d.BROWSER_TYPE_CHROME = "chrome";
  471. d.BROWSER_TYPE_UNKNOWN = "unknown";
  472. d.isNative = !1;
  473. var e = [d.BROWSER_TYPE_BAIDU, d.BROWSER_TYPE_OPERA, d.BROWSER_TYPE_FIREFOX, d.BROWSER_TYPE_CHROME, d.BROWSER_TYPE_SAFARI],
  474. 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],
  475. g = window,
  476. h = g.navigator,
  477. k = document.documentElement,
  478. m = h.userAgent.toLowerCase();
  479. d.isMobile = -1 != m.indexOf("mobile") || -1 != m.indexOf("android");
  480. d.platform = d.isMobile ? d.MOBILE_BROWSER : d.DESKTOP_BROWSER;
  481. var n = h.language,
  482. n = (n = n ? n : h.browserLanguage) ? n.split("-")[0] : d.LANGUAGE_ENGLISH;
  483. d.language = n;
  484. var n = d.BROWSER_TYPE_UNKNOWN,
  485. q = m.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|opera|miuibrowser|firefox/i) || m.match(/chrome|safari/i);
  486. 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));
  487. d.browserType = n;
  488. d._supportMultipleAudio = -1 < f.indexOf(d.browserType);
  489. f = parseInt(a[c.renderMode]);
  490. n = cc._RENDER_TYPE_WEBGL;
  491. q = cc.newElement("Canvas");
  492. cc._supportRender = !0;
  493. e = -1 == e.indexOf(d.browserType);
  494. if (1 === f || 0 === f && (d.isMobile || e) || "file://" == location.origin) n = cc._RENDER_TYPE_CANVAS;
  495. d._canUseCanvasNewBlendModes = function() {
  496. var a = document.createElement("canvas");
  497. a.width = 1;
  498. a.height = 1;
  499. a = a.getContext("2d");
  500. a.fillStyle = "#000";
  501. a.fillRect(0, 0, 1, 1);
  502. a.globalCompositeOperation = "multiply";
  503. a.fillStyle = "#fff";
  504. a.fillRect(0, 0, 1, 1);
  505. return 0 === a.getImageData(0, 0, 1, 1).data[0]
  506. };
  507. d._supportCanvasNewBlendModes = d._canUseCanvasNewBlendModes();
  508. if (n == cc._RENDER_TYPE_WEBGL && (!g.WebGLRenderingContext || !cc.create3DContext(q, {
  509. stencil: !0,
  510. preserveDrawingBuffer: !0
  511. }))) 0 == f ? n = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1;
  512. if (n == cc._RENDER_TYPE_CANVAS) try {
  513. q.getContext("2d")
  514. } catch (r) {
  515. cc._supportRender = !1
  516. }
  517. cc._renderType = n;
  518. try {
  519. d._supportWebAudio = !!new(g.AudioContext || g.webkitAudioContext || g.mozAudioContext)
  520. } catch (t) {
  521. d._supportWebAudio = !1
  522. }
  523. try {
  524. var s = d.localStorage = g.localStorage;
  525. s.setItem("storage", "");
  526. s.removeItem("storage");
  527. s = null
  528. } catch (v) {
  529. ("SECURITY_ERR" === v.name || "QuotaExceededError" === v.name) && cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"), d.localStorage = function() {}
  530. }
  531. s = d.capabilities = {
  532. canvas: !0
  533. };
  534. cc._renderType == cc._RENDER_TYPE_WEBGL && (s.opengl = !0);
  535. void 0 !== k.ontouchstart || h.msPointerEnabled ? s.touches = !0 : void 0 !== k.onmouseup && (s.mouse = !0);
  536. void 0 !== k.onkeyup && (s.keyboard = !0);
  537. if (g.DeviceMotionEvent || g.DeviceOrientationEvent) s.accelerometer = !0;
  538. g = m.match(/(iPad|iPhone|iPod)/i) ? !0 : !1;
  539. m = m.match(/android/i) || h.platform.match(/android/i) ? !0 : !1;
  540. 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);
  541. d.os = k;
  542. d.garbageCollect = function() {};
  543. d.dumpRoot = function() {};
  544. d.restartVM = function() {};
  545. d.dump = function() {
  546. var a;
  547. a = "" + ("isMobile : " + this.isMobile + "\r\n");
  548. a += "language : " + this.language + "\r\n";
  549. a += "browserType : " + this.browserType + "\r\n";
  550. a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n";
  551. a += "os : " + this.os + "\r\n";
  552. a += "platform : " + this.platform + "\r\n";
  553. cc.log(a)
  554. }
  555. };
  556. cc.ORIENTATION_PORTRAIT = 0;
  557. cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
  558. cc.ORIENTATION_LANDSCAPE_LEFT = 2;
  559. cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
  560. cc._drawingUtil = null;
  561. cc._renderContext = null;
  562. cc._canvas = null;
  563. cc._gameDiv = null;
  564. cc._rendererInitialized = !1;
  565. cc._setupCalled = !1;
  566. cc._setup = function(a, c, d) {
  567. if (!cc._setupCalled) {
  568. cc._setupCalled = !0;
  569. var e = window,
  570. f = new Date,
  571. g = 1E3 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
  572. e.requestAnimFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function(a) {
  573. var c = (new Date).getTime(),
  574. d = Math.max(0, g - (c - f)),
  575. e = window.setTimeout(function() {
  576. a()
  577. }, d);
  578. f = c + d;
  579. return e
  580. };
  581. e.cancelAnimationFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || function(a) {
  582. clearTimeout(a)
  583. };
  584. var h = cc.$(a) || cc.$("#" + a),
  585. k;
  586. "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));
  587. a.addClass("gameCanvas");
  588. a.setAttribute("width", c || 480);
  589. a.setAttribute("height", d || 320);
  590. a.setAttribute("tabindex", 99);
  591. a.style.outline = "none";
  592. h = k.style;
  593. h.width = (c || 480) + "px";
  594. h.height = (d || 320) + "px";
  595. h.margin = "0 auto";
  596. h.position = "relative";
  597. h.overflow = "hidden";
  598. k.top = "100%";
  599. cc._renderType == cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, {
  600. stencil: !0,
  601. preserveDrawingBuffer: !0,
  602. antialias: !cc.sys.isMobile,
  603. alpha: !1
  604. }));
  605. 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);
  606. cc._gameDiv = k;
  607. cc.log(cc.ENGINE_VERSION);
  608. cc._setContextMenuEnable(!1);
  609. 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);}");
  610. cc.view = cc.EGLView._getInstance();
  611. cc.inputManager.registerSystemEvent(cc._canvas);
  612. cc.director = cc.Director._getInstance();
  613. cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view);
  614. cc.winSize = cc.director.getWinSize();
  615. cc.saxParser = new cc.SAXParser;
  616. cc.plistParser = new cc.PlistParser
  617. }
  618. };
  619. cc._checkWebGLRenderMode = function() {
  620. if (cc._renderType !== cc._RENDER_TYPE_WEBGL) throw "This feature supports WebGL render mode only.";
  621. };
  622. cc._isContextMenuEnable = !1;
  623. cc._setContextMenuEnable = function(a) {
  624. cc._isContextMenuEnable = a;
  625. cc._canvas.oncontextmenu = function() {
  626. if (!cc._isContextMenuEnable) return !1
  627. }
  628. };
  629. cc.game = {
  630. DEBUG_MODE_NONE: 0,
  631. DEBUG_MODE_INFO: 1,
  632. DEBUG_MODE_WARN: 2,
  633. DEBUG_MODE_ERROR: 3,
  634. DEBUG_MODE_INFO_FOR_WEB_PAGE: 4,
  635. DEBUG_MODE_WARN_FOR_WEB_PAGE: 5,
  636. DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6,
  637. EVENT_HIDE: "game_on_hide",
  638. EVENT_SHOW: "game_on_show",
  639. _eventHide: null,
  640. _eventShow: null,
  641. _onBeforeStartArr: [],
  642. CONFIG_KEY: {
  643. engineDir: "engineDir",
  644. dependencies: "dependencies",
  645. debugMode: "debugMode",
  646. showFPS: "showFPS",
  647. frameRate: "frameRate",
  648. id: "id",
  649. renderMode: "renderMode",
  650. jsList: "jsList",
  651. classReleaseMode: "classReleaseMode"
  652. },
  653. _prepareCalled: !1,
  654. _prepared: !1,
  655. _paused: !0,
  656. _intervalId: null,
  657. config: null,
  658. onStart: null,
  659. onStop: null,
  660. setFrameRate: function(a) {
  661. this.config[this.CONFIG_KEY.frameRate] = a;
  662. this._intervalId && window.cancelAnimationFrame(this._intervalId);
  663. this._paused = !0;
  664. this._runMainLoop()
  665. },
  666. _runMainLoop: function() {
  667. var a = this,
  668. c, d = cc.director;
  669. d.setDisplayStats(a.config[a.CONFIG_KEY.showFPS]);
  670. c = function() {
  671. a._paused || (d.mainLoop(), a._intervalId = window.requestAnimFrame(c))
  672. };
  673. window.requestAnimFrame(c);
  674. a._paused = !1
  675. },
  676. run: function(a) {
  677. var c = this,
  678. d = function() {
  679. a && (c.config[c.CONFIG_KEY.id] = a);
  680. c._prepareCalled ? cc._supportRender && (c._checkPrepare = setInterval(function() {
  681. 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))
  682. }, 10)) : c.prepare(function() {
  683. 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())
  684. })
  685. };
  686. document.body ? d() : cc._addEventListener(window, "load", function() {
  687. this.removeEventListener("load", arguments.callee, !1);
  688. d()
  689. }, !1)
  690. },
  691. _initConfig: function() {
  692. var a = this.CONFIG_KEY,
  693. c = function(c) {
  694. c[a.engineDir] = c[a.engineDir] || "frameworks/cocos2d-html5";
  695. null == c[a.debugMode] && (c[a.debugMode] = 0);
  696. c[a.frameRate] = c[a.frameRate] || 60;
  697. null == c[a.renderMode] && (c[a.renderMode] = 1);
  698. return c
  699. };
  700. if (document.ccConfig) this.config = c(document.ccConfig);
  701. else try {
  702. for (var d = document.getElementsByTagName("script"), e = 0; e < d.length; e++) {
  703. var f = d[e].getAttribute("cocos");
  704. if ("" == f || f) break
  705. }
  706. var g, h, k;
  707. if (e < d.length) {
  708. if (g = d[e].src) k = /(.*)\//.exec(g)[0], cc.loader.resPath = k, g = cc.path.join(k, "project.json");
  709. h = cc.loader._loadTxtSync(g)
  710. }
  711. h || (h = cc.loader._loadTxtSync("project.json"));
  712. var m = JSON.parse(h);
  713. this.config = c(m || {})
  714. } catch (n) {
  715. cc.log("Failed to read or parse project.json"), this.config = c({})
  716. }
  717. cc._initSys(this.config, a)
  718. },
  719. _jsAddedCache: {},
  720. _getJsListOfModule: function(a, c, d) {
  721. var e = this._jsAddedCache;
  722. if (e[c]) return null;
  723. d = d || "";
  724. var f = [],
  725. g = a[c];
  726. if (!g) throw "can not find module [" + c + "]";
  727. c = cc.path;
  728. for (var h = 0, k = g.length; h < k; h++) {
  729. var m = g[h];
  730. if (!e[m]) {
  731. var n = c.extname(m);
  732. n ? ".js" == n.toLowerCase() && f.push(c.join(d, m)) : (n = this._getJsListOfModule(a, m, d)) && (f = f.concat(n));
  733. e[m] = 1
  734. }
  735. }
  736. return f
  737. },
  738. prepare: function(a) {
  739. var c = this,
  740. d = c.config,
  741. e = c.CONFIG_KEY,
  742. f = d[e.engineDir],
  743. g = cc.loader;
  744. if (!cc._supportRender) throw "The renderer doesn't support the renderMode " + d[e.renderMode];
  745. c._prepareCalled = !0;
  746. var h = d[e.jsList] || [];
  747. cc.Class ? g.loadJsWithImg("", h, function(d) {
  748. if (d) throw d;
  749. c._prepared = !0;
  750. a && a()
  751. }) : (e = cc.path.join(f, "moduleConfig.json"), g.loadJson(e, function(e, g) {
  752. if (e) throw e;
  753. var n = d.modules || [],
  754. q = g.module,
  755. r = [];
  756. cc._renderType == cc._RENDER_TYPE_WEBGL ? n.splice(0, 0, "shaders") : 0 > n.indexOf("core") && n.splice(0, 0, "core");
  757. for (var t = 0, s = n.length; t < s; t++) {
  758. var v = c._getJsListOfModule(q, n[t], f);
  759. v && (r = r.concat(v))
  760. }
  761. r = r.concat(h);
  762. cc.loader.loadJsWithImg(r, function(d) {
  763. if (d) throw d;
  764. c._prepared = !0;
  765. a && a()
  766. })
  767. }))
  768. }
  769. };
  770. cc.game._initConfig();
  771. Function.prototype.bind = Function.prototype.bind || function(a) {
  772. var c = this;
  773. return function() {
  774. var d = Array.prototype.slice.call(arguments);
  775. return c.apply(a || null, d)
  776. }
  777. };
  778. cc._LogInfos = {
  779. ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null",
  780. ActionManager_removeAction: "cocos2d: removeAction: Target not found",
  781. ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag",
  782. ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null",
  783. ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag",
  784. ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag \x3d %s): Action not found",
  785. configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",
  786. configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s",
  787. configuration_loadConfigFile_2: "Please load the resource first : %s",
  788. Director_resume: "cocos2d: Director: Error in gettimeofday",
  789. Director_setProjection: "cocos2d: Director: unrecognized projection",
  790. Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection",
  791. Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday",
  792. Director_popScene: "running scene should not null",
  793. Director_pushScene: "the scene should not null",
  794. arrayVerifyType: "element type is wrong!",
  795. Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",
  796. Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",
  797. Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",
  798. Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null",
  799. Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null",
  800. Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null",
  801. Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.",
  802. Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.",
  803. Node_getRotation: "RotationX !\x3d RotationY. Don't know which one to return",
  804. Node_getScale: "ScaleX !\x3d ScaleY. Don't know which one to return",
  805. Node_addChild: "An Node can't be added as a child of itself.",
  806. Node_addChild_2: "child already added. It can't be added again",
  807. Node_addChild_3: "child must be non-null",
  808. Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead",
  809. Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead",
  810. Node_removeChildByTag: "argument tag is an invalid tag",
  811. Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag \x3d %s): child not found!",
  812. Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",
  813. Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag",
  814. Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag",
  815. Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.",
  816. Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.",
  817. Node__arrayMakeObjectsPerformSelector: "Unknown callback function",
  818. Node_reorderChild: "child must be non-null",
  819. Node_runAction: "cc.Node.runAction(): action must be non-null",
  820. Node_schedule: "callback function must be non-null",
  821. Node_schedule_2: "interval must be positive",
  822. Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  823. AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",
  824. AtlasNode_initWithTileFile: "",
  825. AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  826. _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",
  827. _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",
  828. _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",
  829. _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",
  830. EventListener_create: "Invalid parameter.",
  831. __getListenerID: "Don't call this method if the event is for touch.",
  832. eventManager__forceAddEventListener: "Invalid scene graph priority!",
  833. eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.",
  834. eventManager_removeListeners: "Invalid listener type!",
  835. eventManager_setPriority: "Can't set fixed priority with scene graph based listener.",
  836. eventManager_addListener_2: "Invalid parameters.",
  837. eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener",
  838. eventManager_addListener_4: "The listener has been registered, please don't register it again.",
  839. LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript",
  840. LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message",
  841. LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message",
  842. LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null",
  843. EGLView_setDesignResolutionSize: "Resolution not valid",
  844. EGLView_setDesignResolutionSize_2: "should set resolutionPolicy",
  845. inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s",
  846. swap: "cc.swap is being modified from original macro, please check usage",
  847. checkGLErrorDebug: "WebGL error %s",
  848. animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",
  849. animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format",
  850. animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found",
  851. animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  852. 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.",
  853. 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.",
  854. 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.",
  855. animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  856. 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.",
  857. animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name",
  858. Sprite_reorderChild: "cc.Sprite.reorderChild(): this child is not in children list",
  859. Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",
  860. Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",
  861. Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",
  862. Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.",
  863. Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
  864. Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",
  865. Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",
  866. Sprite_initWithSpriteFrameName1: " is null, please check.",
  867. Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null",
  868. Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",
  869. Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null",
  870. Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",
  871. Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",
  872. Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null",
  873. Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",
  874. Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  875. Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  876. Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  877. Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",
  878. Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  879. Sprite_setSpriteFrame: "Invalid spriteFrameName",
  880. Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",
  881. Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  882. Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  883. Sprite_addChild_6: "cc.SpriteBatchNode.addChild(): child should be non-null",
  884. SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",
  885. SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",
  886. SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas",
  887. SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",
  888. SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",
  889. SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",
  890. SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild():child should be non-null",
  891. spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",
  892. spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists",
  893. spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",
  894. spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found",
  895. spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s",
  896. spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",
  897. spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil",
  898. CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  899. CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  900. CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  901. CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  902. CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null",
  903. CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName",
  904. CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",
  905. CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  906. CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  907. CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null",
  908. TextureAtlas_initWithFile: "cocos2d: Could not open file: %s",
  909. TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads",
  910. TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null",
  911. TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null",
  912. TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index",
  913. TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index",
  914. TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount",
  915. TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",
  916. TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",
  917. TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index",
  918. TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",
  919. TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",
  920. TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",
  921. TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",
  922. textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  923. textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  924. textureCache_addPVRImage: "addPVRImage does not support on HTML5",
  925. textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache",
  926. textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id\x3d%s %s x %s",
  927. textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s",
  928. textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",
  929. textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null",
  930. Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5",
  931. Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5",
  932. Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5",
  933. Texture2D_addImage: "cc.Texture.addImage(): path should be non-null",
  934. Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",
  935. Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",
  936. Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5",
  937. Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5",
  938. Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5",
  939. Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5",
  940. Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",
  941. Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",
  942. Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null",
  943. Texture2D_initWithData: "NSInternalInconsistencyException",
  944. MissingFile: "Missing file: %s",
  945. radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()",
  946. RectWidth: "Rect width exceeds maximum margin: %s",
  947. RectHeight: "Rect height exceeds maximum margin: %s",
  948. EventManager__updateListeners: "If program goes here, there should be event in dispatch.",
  949. EventManager__updateListeners_2: "_inDispatch should be 1 here."
  950. };
  951. cc._logToWebPage = function(a) {
  952. if (cc._canvas) {
  953. var c = cc._logList,
  954. d = document;
  955. if (!c) {
  956. var e = d.createElement("Div"),
  957. c = e.style;
  958. e.setAttribute("id", "logInfoDiv");
  959. cc._canvas.parentNode.appendChild(e);
  960. e.setAttribute("width", "200");
  961. e.setAttribute("height", cc._canvas.height);
  962. c.zIndex = "99999";
  963. c.position = "absolute";
  964. c.top = "0";
  965. c.left = "0";
  966. c = cc._logList = d.createElement("textarea");
  967. d = c.style;
  968. c.setAttribute("rows", "20");
  969. c.setAttribute("cols", "30");
  970. c.setAttribute("disabled", !0);
  971. e.appendChild(c);
  972. d.backgroundColor = "transparent";
  973. d.borderBottom = "1px solid #cccccc";
  974. d.borderRightWidth = "0px";
  975. d.borderLeftWidth = "0px";
  976. d.borderTopWidth = "0px";
  977. d.borderTopStyle = "none";
  978. d.borderRightStyle = "none";
  979. d.borderLeftStyle = "none";
  980. d.padding = "0px";
  981. d.margin = 0
  982. }
  983. a = "string" == typeof a ? a : JSON.stringify(a);
  984. c.value = c.value + a + "\r\n";
  985. c.scrollTop = c.scrollHeight
  986. }
  987. };
  988. cc._formatString = function(a) {
  989. if ("object" === typeof a) try {
  990. return JSON.stringify(a)
  991. } catch (c) {
  992. return ""
  993. } else return a
  994. };
  995. (cc.log = function(a) {
  996. for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
  997. }, cc.warn = console.warn ? function(a) {
  998. for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
  999. console.warn(a)
  1000. } : cc.log, cc.error = console.error ? function(a) {
  1001. for (var c = 1; c < arguments.length; c++) a = a.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
  1002. } : cc.log, cc.assert = function(a, c) {
  1003. if (!a && c) {
  1004. for (var d = 2; d < arguments.length; d++) c = c.replace(/(%s)|(%d)/, cc._formatString(arguments[d]));
  1005. throw c;
  1006. }
  1007. });
  1008. var mode = cc.game.config[cc.game.CONFIG_KEY.debugMode],
  1009. ccGame = cc.game;
  1010. mode === ccGame.DEBUG_MODE_INFO || (cc.log = mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE ? cc._logToWebPage.bind(cc) : function() {});
  1011. if (!mode || mode == ccGame.DEBUG_MODE_NONE || mode == ccGame.DEBUG_MODE_ERROR || mode == ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE) cc.warn = function() {};
  1012. 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);
  1013. if (!mode || mode == ccGame.DEBUG_MODE_NONE) cc.error = function() {}, cc.assert = function() {};
  1014. 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) {
  1015. if (!a && c) {
  1016. for (var d = 2; d < arguments.length; d++) c = c.replace("%s", arguments[d]);
  1017. cc._logToWebPage(c)
  1018. }
  1019. };
  1020. cc.loader.loadBinary = function(a, c) {
  1021. var d = this,
  1022. e = this.getXMLHttpRequest(),
  1023. f = "load " + a + " failed!";
  1024. e.open("GET", a, !0);
  1025. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (e.setRequestHeader("Accept-Charset", "x-user-defined"), e.onreadystatechange = function() {
  1026. if (4 == e.readyState && 200 == e.status) {
  1027. var a = cc._convertResponseBodyToText(e.responseBody);
  1028. c(null, d._str2Uint8Array(a))
  1029. } else c(f)
  1030. }) : (e.overrideMimeType && e.overrideMimeType("text/plain; charset\x3dx-user-defined"), e.onload = function() {
  1031. 4 == e.readyState && 200 == e.status ? c(null, d._str2Uint8Array(e.responseText)) : c(f)
  1032. });
  1033. e.send(null)
  1034. };
  1035. cc.loader._str2Uint8Array = function(a) {
  1036. if (!a) return null;
  1037. for (var c = new Uint8Array(a.length), d = 0; d < a.length; d++) c[d] = a.charCodeAt(d) & 255;
  1038. return c
  1039. };
  1040. cc.loader.loadBinarySync = function(a) {
  1041. var c = this.getXMLHttpRequest(),
  1042. d = "load " + a + " failed!";
  1043. c.open("GET", a, !1);
  1044. a = null;
  1045. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1046. c.setRequestHeader("Accept-Charset", "x-user-defined");
  1047. c.send(null);
  1048. if (200 != c.status) return cc.log(d), null;
  1049. (c = cc._convertResponseBodyToText(c.responseBody)) && (a = this._str2Uint8Array(c))
  1050. } else {
  1051. c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dx-user-defined");
  1052. c.send(null);
  1053. if (200 != c.status) return cc.log(d), null;
  1054. a = this._str2Uint8Array(c.responseText)
  1055. }
  1056. return a
  1057. };
  1058. var Uint8Array = Uint8Array || Array;
  1059. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1060. 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',
  1061. myVBScript = cc.newElement("script");
  1062. myVBScript.type = "text/vbscript";
  1063. myVBScript.textContent = IEBinaryToArray_ByteStr_Script;
  1064. document.body.appendChild(myVBScript);
  1065. cc._convertResponseBodyToText = function(a) {
  1066. for (var c = {}, d = 0; 256 > d; d++)
  1067. for (var e = 0; 256 > e; e++) c[String.fromCharCode(d + 256 * e)] = String.fromCharCode(d) + String.fromCharCode(e);
  1068. d = IEBinaryToArray_ByteStr(a);
  1069. a = IEBinaryToArray_ByteStr_Last(a);
  1070. return d.replace(/[\s\S]/g, function(a) {
  1071. return c[a]
  1072. }) + a
  1073. }
  1074. };
  1075. ClassManager = {
  1076. id: 0 | 998 * Math.random(),
  1077. instanceId: 0 | 998 * Math.random(),
  1078. compileSuper: function(a, c, d) {
  1079. a = a.toString();
  1080. var e = a.indexOf("("),
  1081. f = a.indexOf(")"),
  1082. e = a.substring(e + 1, f),
  1083. e = e.trim(),
  1084. f = a.indexOf("{"),
  1085. g = a.lastIndexOf("}");
  1086. for (a = a.substring(f + 1, g); - 1 != a.indexOf("this._super");) {
  1087. var f = a.indexOf("this._super"),
  1088. g = a.indexOf("(", f),
  1089. h = a.indexOf(")", g),
  1090. h = a.substring(g + 1, h),
  1091. h = (h = h.trim()) ? "," : "";
  1092. a = a.substring(0, f) + "ClassManager[" + d + "]." + c + ".call(this" + h + a.substring(g + 1)
  1093. }
  1094. return Function(e, a)
  1095. },
  1096. getNewID: function() {
  1097. return this.id++
  1098. },
  1099. getNewInstanceId: function() {
  1100. return this.instanceId++
  1101. }
  1102. };
  1103. ClassManager.compileSuper.ClassManager = ClassManager;
  1104. (function() {
  1105. var a = /\b_super\b/,
  1106. c = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];
  1107. c;
  1108. cc.Class = function() {};
  1109. cc.Class.extend = function(d) {
  1110. function e() {
  1111. this.__instanceId = ClassManager.getNewInstanceId();
  1112. this.ctor && this.ctor.apply(this, arguments)
  1113. }
  1114. var f = this.prototype,
  1115. g = Object.create(f),
  1116. h = ClassManager.getNewID();
  1117. ClassManager[h] = f;
  1118. var k = {
  1119. writable: !0,
  1120. enumerable: !1,
  1121. configurable: !0
  1122. };
  1123. g.__instanceId = null;
  1124. e.id = h;
  1125. k.value = h;
  1126. Object.defineProperty(g, "__pid", k);
  1127. e.prototype = g;
  1128. k.value = e;
  1129. Object.defineProperty(e.prototype, "constructor", k);
  1130. this.__getters__ && (e.__getters__ = cc.clone(this.__getters__));
  1131. this.__setters__ && (e.__setters__ = cc.clone(this.__setters__));
  1132. for (var m = 0, n = arguments.length; m < n; ++m) {
  1133. var q = arguments[m],
  1134. r;
  1135. for (r in q) {
  1136. var t = "function" === typeof q[r],
  1137. s = "function" === typeof f[r],
  1138. v = a.test(q[r]);
  1139. 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) {
  1140. return function() {
  1141. var d = this._super;
  1142. this._super = f[a];
  1143. var e = c.apply(this, arguments);
  1144. this._super = d;
  1145. return e
  1146. }
  1147. }(r, q[r]), Object.defineProperty(g, r, k)) : t ? (k.value = q[r], Object.defineProperty(g, r, k)) : g[r] = q[r];
  1148. if (t) {
  1149. var u, x;
  1150. if (this.__getters__ && this.__getters__[r]) {
  1151. var t = this.__getters__[r],
  1152. A;
  1153. for (A in this.__setters__)
  1154. if (this.__setters__[A] == t) {
  1155. x = A;
  1156. break
  1157. }
  1158. cc.defineGetterSetter(g, t, q[r], q[x] ? q[x] : g[x], r, x)
  1159. }
  1160. if (this.__setters__ && this.__setters__[r]) {
  1161. t = this.__setters__[r];
  1162. for (A in this.__getters__)
  1163. if (this.__getters__[A] == t) {
  1164. u = A;
  1165. break
  1166. }
  1167. cc.defineGetterSetter(g, t, q[u] ? q[u] : g[u], q[r], u, r)
  1168. }
  1169. }
  1170. }
  1171. }
  1172. e.extend = cc.Class.extend;
  1173. e.implement = function(a) {
  1174. for (var c in a) g[c] = a[c]
  1175. };
  1176. return e
  1177. }
  1178. })();
  1179. cc.defineGetterSetter = function(a, c, d, e, f, g) {
  1180. if (a.__defineGetter__) d && a.__defineGetter__(c, d), e && a.__defineSetter__(c, e);
  1181. else if (Object.defineProperty) {
  1182. var h = {
  1183. enumerable: !1,
  1184. configurable: !0
  1185. };
  1186. d && (h.get = d);
  1187. e && (h.set = e);
  1188. Object.defineProperty(a, c, h)
  1189. } else throw Error("browser does not support getters"); if (!f && !g)
  1190. for (var h = null != d, k = void 0 != e, m = Object.getOwnPropertyNames(a), n = 0; n < m.length; n++) {
  1191. var q = m[n];
  1192. if (!((a.__lookupGetter__ ? a.__lookupGetter__(q) : Object.getOwnPropertyDescriptor(a, q)) || "function" !== typeof a[q])) {
  1193. var r = a[q];
  1194. if (h && r === d && (f = q, !k || g)) break;
  1195. if (k && r === e && (g = q, !h || f)) break
  1196. }
  1197. }
  1198. a = a.constructor;
  1199. f && (a.__getters__ || (a.__getters__ = {}), a.__getters__[f] = c);
  1200. g && (a.__setters__ || (a.__setters__ = {}), a.__setters__[g] = c)
  1201. };
  1202. cc.clone = function(a) {
  1203. var c = a.constructor ? new a.constructor : {},
  1204. d;
  1205. for (d in a) {
  1206. var e = a[d];
  1207. c[d] = "object" == typeof e && e && !(e instanceof cc.Node) && !(e instanceof HTMLElement) ? cc.clone(e) : e
  1208. }
  1209. return c
  1210. };
  1211. cc = cc || {};
  1212. cc._tmp = cc._tmp || {};
  1213. cc.associateWithNative = function(a, c) {};
  1214. cc.KEY = {
  1215. backspace: 8,
  1216. tab: 9,
  1217. enter: 13,
  1218. shift: 16,
  1219. ctrl: 17,
  1220. alt: 18,
  1221. pause: 19,
  1222. capslock: 20,
  1223. escape: 27,
  1224. pageup: 33,
  1225. pagedown: 34,
  1226. end: 35,
  1227. home: 36,
  1228. left: 37,
  1229. up: 38,
  1230. right: 39,
  1231. down: 40,
  1232. insert: 45,
  1233. Delete: 46,
  1234. "0": 48,
  1235. 1: 49,
  1236. 2: 50,
  1237. 3: 51,
  1238. 4: 52,
  1239. 5: 53,
  1240. 6: 54,
  1241. 7: 55,
  1242. 8: 56,
  1243. 9: 57,
  1244. a: 65,
  1245. b: 66,
  1246. c: 67,
  1247. d: 68,
  1248. e: 69,
  1249. f: 70,
  1250. g: 71,
  1251. h: 72,
  1252. i: 73,
  1253. j: 74,
  1254. k: 75,
  1255. l: 76,
  1256. m: 77,
  1257. n: 78,
  1258. o: 79,
  1259. p: 80,
  1260. q: 81,
  1261. r: 82,
  1262. s: 83,
  1263. t: 84,
  1264. u: 85,
  1265. v: 86,
  1266. w: 87,
  1267. x: 88,
  1268. y: 89,
  1269. z: 90,
  1270. num0: 96,
  1271. num1: 97,
  1272. num2: 98,
  1273. num3: 99,
  1274. num4: 100,
  1275. num5: 101,
  1276. num6: 102,
  1277. num7: 103,
  1278. num8: 104,
  1279. num9: 105,
  1280. "*": 106,
  1281. "+": 107,
  1282. "-": 109,
  1283. numdel: 110,
  1284. "/": 111,
  1285. f1: 112,
  1286. f2: 113,
  1287. f3: 114,
  1288. f4: 115,
  1289. f5: 116,
  1290. f6: 117,
  1291. f7: 118,
  1292. f8: 119,
  1293. f9: 120,
  1294. f10: 121,
  1295. f11: 122,
  1296. f12: 123,
  1297. numlock: 144,
  1298. scrolllock: 145,
  1299. semicolon: 186,
  1300. ",": 186,
  1301. equal: 187,
  1302. "\x3d": 187,
  1303. ";": 188,
  1304. comma: 188,
  1305. dash: 189,
  1306. ".": 190,
  1307. period: 190,
  1308. forwardslash: 191,
  1309. grave: 192,
  1310. "[": 219,
  1311. openbracket: 219,
  1312. "]": 221,
  1313. closebracket: 221,
  1314. backslash: 220,
  1315. quote: 222,
  1316. space: 32
  1317. };
  1318. cc.FMT_JPG = 0;
  1319. cc.FMT_PNG = 1;
  1320. cc.FMT_TIFF = 2;
  1321. cc.FMT_RAWDATA = 3;
  1322. cc.FMT_WEBP = 4;
  1323. cc.FMT_UNKNOWN = 5;
  1324. cc.getImageFormatByData = function(a) {
  1325. 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
  1326. };
  1327. cc.inherits = function(a, c) {
  1328. function d() {}
  1329. d.prototype = c.prototype;
  1330. a.superClass_ = c.prototype;
  1331. a.prototype = new d;
  1332. a.prototype.constructor = a
  1333. };
  1334. cc.base = function(a, c, d) {
  1335. var e = arguments.callee.caller;
  1336. if (e.superClass_) return ret = e.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1));
  1337. for (var f = Array.prototype.slice.call(arguments, 2), g = !1, h = a.constructor; h; h = h.superClass_ && h.superClass_.constructor)
  1338. if (h.prototype[c] === e) g = !0;
  1339. else if (g) return h.prototype[c].apply(a, f);
  1340. if (a[c] === e) return a.constructor.prototype[c].apply(a, f);
  1341. throw Error("cc.base called from a method of one name to a method of a different name");
  1342. };
  1343. cc.Point = function(a, c) {
  1344. this.x = a || 0;
  1345. this.y = c || 0
  1346. };
  1347. cc.p = function(a, c) {
  1348. return void 0 == a ? {
  1349. x: 0,
  1350. y: 0
  1351. } : void 0 == c ? {
  1352. x: a.x,
  1353. y: a.y
  1354. } : {
  1355. x: a,
  1356. y: c
  1357. }
  1358. };
  1359. cc.pointEqualToPoint = function(a, c) {
  1360. return a && c && a.x === c.x && a.y === c.y
  1361. };
  1362. cc.Size = function(a, c) {
  1363. this.width = a || 0;
  1364. this.height = c || 0
  1365. };
  1366. cc.size = function(a, c) {
  1367. return void 0 === a ? {
  1368. width: 0,
  1369. height: 0
  1370. } : void 0 === c ? {
  1371. width: a.width,
  1372. height: a.height
  1373. } : {
  1374. width: a,
  1375. height: c
  1376. }
  1377. };
  1378. cc.sizeEqualToSize = function(a, c) {
  1379. return a && c && a.width == c.width && a.height == c.height
  1380. };
  1381. cc.Rect = function(a, c, d, e) {
  1382. this.x = a || 0;
  1383. this.y = c || 0;
  1384. this.width = d || 0;
  1385. this.height = e || 0
  1386. };
  1387. cc.rect = function(a, c, d, e) {
  1388. return void 0 === a ? {
  1389. x: 0,
  1390. y: 0,
  1391. width: 0,
  1392. height: 0
  1393. } : void 0 === c ? {
  1394. x: a.x,
  1395. y: a.y,
  1396. width: a.width,
  1397. height: a.height
  1398. } : {
  1399. x: a,
  1400. y: c,
  1401. width: d,
  1402. height: e
  1403. }
  1404. };
  1405. cc.rectEqualToRect = function(a, c) {
  1406. return a && c && a.x === c.x && a.y === c.y && a.width === c.width && a.height === c.height
  1407. };
  1408. cc._rectEqualToZero = function(a) {
  1409. return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height
  1410. };
  1411. cc.rectContainsRect = function(a, c) {
  1412. 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)
  1413. };
  1414. cc.rectGetMaxX = function(a) {
  1415. return a.x + a.width
  1416. };
  1417. cc.rectGetMidX = function(a) {
  1418. return a.x + a.width / 2
  1419. };
  1420. cc.rectGetMinX = function(a) {
  1421. return a.x
  1422. };
  1423. cc.rectGetMaxY = function(a) {
  1424. return a.y + a.height
  1425. };
  1426. cc.rectGetMidY = function(a) {
  1427. return a.y + a.height / 2
  1428. };
  1429. cc.rectGetMinY = function(a) {
  1430. return a.y
  1431. };
  1432. cc.rectContainsPoint = function(a, c) {
  1433. return c.x >= cc.rectGetMinX(a) && c.x <= cc.rectGetMaxX(a) && c.y >= cc.rectGetMinY(a) && c.y <= cc.rectGetMaxY(a)
  1434. };
  1435. cc.rectIntersectsRect = function(a, c) {
  1436. var d = a.y + a.height,
  1437. e = c.x + c.width,
  1438. f = c.y + c.height;
  1439. return !(a.x + a.width < c.x || e < a.x || d < c.y || f < a.y)
  1440. };
  1441. cc.rectOverlapsRect = function(a, c) {
  1442. 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)
  1443. };
  1444. cc.rectUnion = function(a, c) {
  1445. var d = cc.rect(0, 0, 0, 0);
  1446. d.x = Math.min(a.x, c.x);
  1447. d.y = Math.min(a.y, c.y);
  1448. d.width = Math.max(a.x + a.width, c.x + c.width) - d.x;
  1449. d.height = Math.max(a.y + a.height, c.y + c.height) - d.y;
  1450. return d
  1451. };
  1452. cc.rectIntersection = function(a, c) {
  1453. var d = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(c)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(c)), 0, 0);
  1454. d.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(c)) - cc.rectGetMinX(d);
  1455. d.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(c)) - cc.rectGetMinY(d);
  1456. return d
  1457. };
  1458. cc.SAXParser = cc.Class.extend({
  1459. _parser: null,
  1460. _isSupportDOMParser: null,
  1461. ctor: function() {
  1462. window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1
  1463. },
  1464. parse: function(a) {
  1465. return this._parseXML(a)
  1466. },
  1467. _parseXML: function(a) {
  1468. var c;
  1469. this._isSupportDOMParser ? c = this._parser.parseFromString(a, "text/xml") : (c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(a));
  1470. return c
  1471. }
  1472. });
  1473. cc.PlistParser = cc.SAXParser.extend({
  1474. parse: function(a) {
  1475. a = this._parseXML(a).documentElement;
  1476. if ("plist" != a.tagName) throw "Not a plist file!";
  1477. for (var c = null, d = 0, e = a.childNodes.length; d < e && !(c = a.childNodes[d], 1 == c.nodeType); d++);
  1478. return this._parseNode(c)
  1479. },
  1480. _parseNode: function(a) {
  1481. var c = null,
  1482. d = a.tagName;
  1483. if ("dict" == d) c = this._parseDict(a);
  1484. else if ("array" == d) c = this._parseArray(a);
  1485. else if ("string" == d)
  1486. if (1 == a.childNodes.length) c = a.firstChild.nodeValue;
  1487. else {
  1488. c = "";
  1489. for (d = 0; d < a.childNodes.length; d++) c += a.childNodes[d].nodeValue
  1490. } else "false" == d ? c = !1 : "true" == d ? c = !0 : "real" == d ? c = parseFloat(a.firstChild.nodeValue) : "integer" == d && (c = parseInt(a.firstChild.nodeValue, 10));
  1491. return c
  1492. },
  1493. _parseArray: function(a) {
  1494. for (var c = [], d = 0, e = a.childNodes.length; d < e; d++) {
  1495. var f = a.childNodes[d];
  1496. 1 == f.nodeType && c.push(this._parseNode(f))
  1497. }
  1498. return c
  1499. },
  1500. _parseDict: function(a) {
  1501. for (var c = {}, d = null, e = 0, f = a.childNodes.length; e < f; e++) {
  1502. var g = a.childNodes[e];
  1503. 1 == g.nodeType && ("key" == g.tagName ? d = g.firstChild.nodeValue : c[d] = this._parseNode(g))
  1504. }
  1505. return c
  1506. }
  1507. });
  1508. cc._txtLoader = {
  1509. load: function(a, c, d, e) {
  1510. cc.loader.loadTxt(a, e)
  1511. }
  1512. };
  1513. cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader);
  1514. cc._jsonLoader = {
  1515. load: function(a, c, d, e) {
  1516. cc.loader.loadJson(a, e)
  1517. }
  1518. };
  1519. cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
  1520. cc._imgLoader = {
  1521. load: function(a, c, d, e) {
  1522. cc.loader.cache[c] = cc.loader.loadImg(a, function(a, d) {
  1523. if (a) return e(a);
  1524. cc.textureCache.handleLoadedTexture(c);
  1525. e(null, d)
  1526. })
  1527. }
  1528. };
  1529. cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader);
  1530. cc._serverImgLoader = {
  1531. load: function(a, c, d, e) {
  1532. cc.loader.cache[c] = cc.loader.loadImg(d.src, function(a, d) {
  1533. if (a) return e(a);
  1534. cc.textureCache.handleLoadedTexture(c);
  1535. e(null, d)
  1536. })
  1537. }
  1538. };
  1539. cc.loader.register(["serverImg"], cc._serverImgLoader);
  1540. cc._plistLoader = {
  1541. load: function(a, c, d, e) {
  1542. cc.loader.loadTxt(a, function(a, c) {
  1543. if (a) return e(a);
  1544. e(null, cc.plistParser.parse(c))
  1545. })
  1546. }
  1547. };
  1548. cc.loader.register(["plist"], cc._plistLoader);
  1549. cc._fontLoader = {
  1550. TYPE: {
  1551. ".eot": "embedded-opentype",
  1552. ".ttf": "truetype",
  1553. ".woff": "woff",
  1554. ".svg": "svg"
  1555. },
  1556. _loadFont: function(a, c, d) {
  1557. var e = document,
  1558. f = cc.path,
  1559. g = this.TYPE,
  1560. h = cc.newElement("style");
  1561. h.type = "text/css";
  1562. e.body.appendChild(h);
  1563. var k = "@font-face { font-family:" + a + "; src:";
  1564. if (c instanceof Array)
  1565. 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 ? ";" : ",";
  1566. else k += "url('" + c + "') format('" + g[d] + "');";
  1567. h.textContent += k + "};";
  1568. c = cc.newElement("div");
  1569. d = c.style;
  1570. d.fontFamily = a;
  1571. c.innerHTML = ".";
  1572. d.position = "absolute";
  1573. d.left = "-100px";
  1574. d.top = "-100px";
  1575. e.body.appendChild(c)
  1576. },
  1577. load: function(a, c, d, e) {
  1578. c = d.type;
  1579. a = d.name;
  1580. c = d.srcs;
  1581. "string" == typeof d ? (c = cc.path.extname(d), a = cc.path.basename(d, c), this._loadFont(a, d, c)) : this._loadFont(a, c);
  1582. e(null, !0)
  1583. }
  1584. };
  1585. cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
  1586. cc._binaryLoader = {
  1587. load: function(a, c, d, e) {
  1588. cc.loader.loadBinary(a, e)
  1589. }
  1590. };
  1591. window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 RC2";
  1592. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
  1593. cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
  1594. cc.DIRECTOR_FPS_INTERVAL = 0.5;
  1595. cc.COCOSNODE_RENDER_SUBPIXEL = 1;
  1596. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
  1597. cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
  1598. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
  1599. cc.TEXTURE_ATLAS_USE_VAO = 0;
  1600. cc.TEXTURE_NPOT_SUPPORT = 0;
  1601. cc.RETINA_DISPLAY_SUPPORT = 1;
  1602. cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
  1603. cc.USE_LA88_LABELS = 1;
  1604. cc.SPRITE_DEBUG_DRAW = 0;
  1605. cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
  1606. cc.LABELBMFONT_DEBUG_DRAW = 0;
  1607. cc.LABELATLAS_DEBUG_DRAW = 0;
  1608. cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
  1609. cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
  1610. cc.ENABLE_STACKABLE_ACTIONS = 1;
  1611. cc.ENABLE_GL_STATE_CACHE = 1;
  1612. cc.$ = function(a) {
  1613. var c = this == cc ? document : this;
  1614. if (a = a instanceof HTMLElement ? a : c.querySelector(a)) a.find = a.find || cc.$, a.hasClass = a.hasClass || function(a) {
  1615. return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)"))
  1616. }, a.addClass = a.addClass || function(a) {
  1617. this.hasClass(a) || (this.className && (this.className += " "), this.className += a);
  1618. return this
  1619. }, a.removeClass = a.removeClass || function(a) {
  1620. this.hasClass(a) && (this.className = this.className.replace(a, ""));
  1621. return this
  1622. }, a.remove = a.remove || function() {
  1623. this.parentNode && this.parentNode.removeChild(this);
  1624. return this
  1625. }, a.appendTo = a.appendTo || function(a) {
  1626. a.appendChild(this);
  1627. return this
  1628. }, a.prependTo = a.prependTo || function(a) {
  1629. a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this);
  1630. return this
  1631. }, a.transforms = a.transforms || function() {
  1632. this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew);
  1633. return this
  1634. }, a.position = a.position || {
  1635. x: 0,
  1636. y: 0
  1637. }, a.rotation = a.rotation || 0, a.scale = a.scale || {
  1638. x: 1,
  1639. y: 1
  1640. }, a.skew = a.skew || {
  1641. x: 0,
  1642. y: 0
  1643. }, a.translates = function(a, c) {
  1644. this.position.x = a;
  1645. this.position.y = c;
  1646. this.transforms();
  1647. return this
  1648. }, a.rotate = function(a) {
  1649. this.rotation = a;
  1650. this.transforms();
  1651. return this
  1652. }, a.resize = function(a, c) {
  1653. this.scale.x = a;
  1654. this.scale.y = c;
  1655. this.transforms();
  1656. return this
  1657. }, a.setSkew = function(a, c) {
  1658. this.skew.x = a;
  1659. this.skew.y = c;
  1660. this.transforms();
  1661. return this
  1662. };
  1663. return a
  1664. };
  1665. switch (cc.sys.browserType) {
  1666. case cc.sys.BROWSER_TYPE_FIREFOX:
  1667. cc.$.pfx = "Moz";
  1668. cc.$.hd = !0;
  1669. break;
  1670. case cc.sys.BROWSER_TYPE_CHROME:
  1671. case cc.sys.BROWSER_TYPE_SAFARI:
  1672. cc.$.pfx = "webkit";
  1673. cc.$.hd = !0;
  1674. break;
  1675. case cc.sys.BROWSER_TYPE_OPERA:
  1676. cc.$.pfx = "O";
  1677. cc.$.hd = !1;
  1678. break;
  1679. case cc.sys.BROWSER_TYPE_IE:
  1680. cc.$.pfx = "ms";
  1681. cc.$.hd = !1;
  1682. break;
  1683. default:
  1684. cc.$.pfx = "webkit", cc.$.hd = !0
  1685. }
  1686. cc.$.trans = cc.$.pfx + "Transform";
  1687. cc.$.translate = cc.$.hd ? function(a) {
  1688. return "translate3d(" + a.x + "px, " + a.y + "px, 0) "
  1689. } : function(a) {
  1690. return "translate(" + a.x + "px, " + a.y + "px) "
  1691. };
  1692. cc.$.rotate = cc.$.hd ? function(a) {
  1693. return "rotateZ(" + a + "deg) "
  1694. } : function(a) {
  1695. return "rotate(" + a + "deg) "
  1696. };
  1697. cc.$.scale = function(a) {
  1698. return "scale(" + a.x + ", " + a.y + ") "
  1699. };
  1700. cc.$.skew = function(a) {
  1701. return "skewX(" + -a.x + "deg) skewY(" + a.y + "deg)"
  1702. };
  1703. cc.$new = function(a) {
  1704. return cc.$(document.createElement(a))
  1705. };
  1706. cc.$.findpos = function(a) {
  1707. var c = 0,
  1708. d = 0;
  1709. do c += a.offsetLeft, d += a.offsetTop; while (a = a.offsetParent);
  1710. return {
  1711. x: c,
  1712. y: d
  1713. }
  1714. };
  1715. cc.INVALID_INDEX = -1;
  1716. cc.PI = Math.PI;
  1717. cc.FLT_MAX = parseFloat("3.402823466e+38F");
  1718. cc.FLT_MIN = parseFloat("1.175494351e-38F");
  1719. cc.RAD = cc.PI / 180;
  1720. cc.DEG = 180 / cc.PI;
  1721. cc.UINT_MAX = 4294967295;
  1722. cc.swap = function(a, c, d) {
  1723. if ("object" == typeof d && "undefined" != typeof d.x && "undefined" != typeof d.y) {
  1724. var e = d[a];
  1725. d[a] = d[c];
  1726. d[c] = e
  1727. } else cc.log(cc._LogInfos.swap)
  1728. };
  1729. cc.lerp = function(a, c, d) {
  1730. return a + (c - a) * d
  1731. };
  1732. cc.rand = function() {
  1733. return 16777215 * Math.random()
  1734. };
  1735. cc.randomMinus1To1 = function() {
  1736. return 2 * (Math.random() - 0.5)
  1737. };
  1738. cc.random0To1 = Math.random;
  1739. cc.degreesToRadians = function(a) {
  1740. return a * cc.RAD
  1741. };
  1742. cc.radiansToDegrees = function(a) {
  1743. return a * cc.DEG
  1744. };
  1745. cc.radiansToDegress = function(a) {
  1746. cc.log(cc._LogInfos.radiansToDegress);
  1747. return a * cc.DEG
  1748. };
  1749. cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
  1750. cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770;
  1751. cc.BLEND_DST = 771;
  1752. cc.nodeDrawSetup = function(a) {
  1753. a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())
  1754. };
  1755. cc.enableDefaultGLStates = function() {};
  1756. cc.disableDefaultGLStates = function() {};
  1757. cc.incrementGLDraws = function(a) {
  1758. cc.g_NumberOfDraws += a
  1759. };
  1760. cc.FLT_EPSILON = 1.192092896E-7;
  1761. cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function() {
  1762. return cc.director.getContentScaleFactor()
  1763. } : function() {
  1764. return 1
  1765. };
  1766. cc.pointPointsToPixels = function(a) {
  1767. var c = cc.contentScaleFactor();
  1768. return cc.p(a.x * c, a.y * c)
  1769. };
  1770. cc.pointPixelsToPoints = function(a) {
  1771. var c = cc.contentScaleFactor();
  1772. return cc.p(a.x / c, a.y / c)
  1773. };
  1774. cc._pointPixelsToPointsOut = function(a, c) {
  1775. var d = cc.contentScaleFactor();
  1776. c.x = a.x / d;
  1777. c.y = a.y / d
  1778. };
  1779. cc.sizePointsToPixels = function(a) {
  1780. var c = cc.contentScaleFactor();
  1781. return cc.size(a.width * c, a.height * c)
  1782. };
  1783. cc.sizePixelsToPoints = function(a) {
  1784. var c = cc.contentScaleFactor();
  1785. return cc.size(a.width / c, a.height / c)
  1786. };
  1787. cc._sizePixelsToPointsOut = function(a, c) {
  1788. var d = cc.contentScaleFactor();
  1789. c.width = a.width / d;
  1790. c.height = a.height / d
  1791. };
  1792. cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
  1793. var c = cc.contentScaleFactor();
  1794. return cc.rect(a.x / c, a.y / c, a.width / c, a.height / c)
  1795. } : function(a) {
  1796. return a
  1797. };
  1798. cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
  1799. var c = cc.contentScaleFactor();
  1800. return cc.rect(a.x * c, a.y * c, a.width * c, a.height * c)
  1801. } : function(a) {
  1802. return a
  1803. };
  1804. cc.ONE = 1;
  1805. cc.ZERO = 0;
  1806. cc.SRC_ALPHA = 770;
  1807. cc.SRC_ALPHA_SATURATE = 776;
  1808. cc.SRC_COLOR = 768;
  1809. cc.DST_ALPHA = 772;
  1810. cc.DST_COLOR = 774;
  1811. cc.ONE_MINUS_SRC_ALPHA = 771;
  1812. cc.ONE_MINUS_SRC_COLOR = 769;
  1813. cc.ONE_MINUS_DST_ALPHA = 773;
  1814. cc.DST_COLOR = 775;
  1815. cc.ONE_MINUS_DST_COLOR = 775;
  1816. cc.ONE_MINUS_CONSTANT_ALPHA = 32772;
  1817. cc.ONE_MINUS_CONSTANT_COLOR = 32770;
  1818. cc.checkGLErrorDebug = function() {
  1819. if (cc.renderMode == cc._RENDER_TYPE_WEBGL) {
  1820. var a = cc._renderContext.getError();
  1821. a && cc.log(cc._LogInfos.checkGLErrorDebug, a)
  1822. }
  1823. };
  1824. cc.DEVICE_ORIENTATION_PORTRAIT = 0;
  1825. cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
  1826. cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
  1827. cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
  1828. cc.DEVICE_MAX_ORIENTATIONS = 2;
  1829. cc.VERTEX_ATTRIB_FLAG_NONE = 0;
  1830. cc.VERTEX_ATTRIB_FLAG_POSITION = 1;
  1831. cc.VERTEX_ATTRIB_FLAG_COLOR = 2;
  1832. cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4;
  1833. cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  1834. cc.GL_ALL = 0;
  1835. cc.VERTEX_ATTRIB_POSITION = 0;
  1836. cc.VERTEX_ATTRIB_COLOR = 1;
  1837. cc.VERTEX_ATTRIB_TEX_COORDS = 2;
  1838. cc.VERTEX_ATTRIB_MAX = 3;
  1839. cc.UNIFORM_PMATRIX = 0;
  1840. cc.UNIFORM_MVMATRIX = 1;
  1841. cc.UNIFORM_MVPMATRIX = 2;
  1842. cc.UNIFORM_TIME = 3;
  1843. cc.UNIFORM_SINTIME = 4;
  1844. cc.UNIFORM_COSTIME = 5;
  1845. cc.UNIFORM_RANDOM01 = 6;
  1846. cc.UNIFORM_SAMPLER = 7;
  1847. cc.UNIFORM_MAX = 8;
  1848. cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
  1849. cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
  1850. cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
  1851. cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
  1852. cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
  1853. cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
  1854. cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
  1855. cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
  1856. cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
  1857. cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
  1858. cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
  1859. cc.UNIFORM_TIME_S = "CC_Time";
  1860. cc.UNIFORM_SINTIME_S = "CC_SinTime";
  1861. cc.UNIFORM_COSTIME_S = "CC_CosTime";
  1862. cc.UNIFORM_RANDOM01_S = "CC_Random01";
  1863. cc.UNIFORM_SAMPLER_S = "CC_Texture0";
  1864. cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
  1865. cc.ATTRIBUTE_NAME_COLOR = "a_color";
  1866. cc.ATTRIBUTE_NAME_POSITION = "a_position";
  1867. cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
  1868. cc.ITEM_SIZE = 32;
  1869. cc.CURRENT_ITEM = 3233828865;
  1870. cc.ZOOM_ACTION_TAG = 3233828866;
  1871. cc.NORMAL_TAG = 8801;
  1872. cc.SELECTED_TAG = 8802;
  1873. cc.DISABLE_TAG = 8803;
  1874. cc = cc || {};
  1875. cc._tmp = cc._tmp || {};
  1876. cc._tmp.WebGLColor = function() {
  1877. cc.color = function(a, d, e, f, g, h) {
  1878. 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)
  1879. };
  1880. cc.Color = function(a, d, e, f, g, h) {
  1881. this._arrayBuffer = g || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT);
  1882. this._offset = h || 0;
  1883. g = this._arrayBuffer;
  1884. h = this._offset;
  1885. var k = Uint8Array.BYTES_PER_ELEMENT;
  1886. this._rU8 = new Uint8Array(g, h, 1);
  1887. this._gU8 = new Uint8Array(g, h + k, 1);
  1888. this._bU8 = new Uint8Array(g, h + 2 * k, 1);
  1889. this._aU8 = new Uint8Array(g, h + 3 * k, 1);
  1890. this._rU8[0] = a || 0;
  1891. this._gU8[0] = d || 0;
  1892. this._bU8[0] = e || 0;
  1893. this._aU8[0] = f || 255;
  1894. void 0 === f && (this.a_undefined = !0)
  1895. };
  1896. cc.Color.BYTES_PER_ELEMENT = 4;
  1897. var a = cc.Color.prototype;
  1898. a._getR = function() {
  1899. return this._rU8[0]
  1900. };
  1901. a._setR = function(a) {
  1902. this._rU8[0] = 0 > a ? 0 : a
  1903. };
  1904. a._getG = function() {
  1905. return this._gU8[0]
  1906. };
  1907. a._setG = function(a) {
  1908. this._gU8[0] = 0 > a ? 0 : a
  1909. };
  1910. a._getB = function() {
  1911. return this._bU8[0]
  1912. };
  1913. a._setB = function(a) {
  1914. this._bU8[0] = 0 > a ? 0 : a
  1915. };
  1916. a._getA = function() {
  1917. return this._aU8[0]
  1918. };
  1919. a._setA = function(a) {
  1920. this._aU8[0] = 0 > a ? 0 : a
  1921. };
  1922. cc.defineGetterSetter(a, "r", a._getR, a._setR);
  1923. cc.defineGetterSetter(a, "g", a._getG, a._setG);
  1924. cc.defineGetterSetter(a, "b", a._getB, a._setB);
  1925. cc.defineGetterSetter(a, "a", a._getA, a._setA);
  1926. cc.Vertex2F = function(a, d, e, f) {
  1927. this._arrayBuffer = e || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
  1928. this._offset = f || 0;
  1929. this._xF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  1930. this._yF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  1931. this._xF32[0] = a || 0;
  1932. this._yF32[0] = d || 0
  1933. };
  1934. cc.Vertex2F.BYTES_PER_ELEMENT = 8;
  1935. Object.defineProperties(cc.Vertex2F.prototype, {
  1936. x: {
  1937. get: function() {
  1938. return this._xF32[0]
  1939. },
  1940. set: function(a) {
  1941. this._xF32[0] = a
  1942. },
  1943. enumerable: !0
  1944. },
  1945. y: {
  1946. get: function() {
  1947. return this._yF32[0]
  1948. },
  1949. set: function(a) {
  1950. this._yF32[0] = a
  1951. },
  1952. enumerable: !0
  1953. }
  1954. });
  1955. cc.Vertex3F = function(a, d, e, f, g) {
  1956. this._arrayBuffer = f || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
  1957. this._offset = g || 0;
  1958. f = this._arrayBuffer;
  1959. g = this._offset;
  1960. this._xF32 = new Float32Array(f, g, 1);
  1961. this._xF32[0] = a || 0;
  1962. this._yF32 = new Float32Array(f, g + Float32Array.BYTES_PER_ELEMENT, 1);
  1963. this._yF32[0] = d || 0;
  1964. this._zF32 = new Float32Array(f, g + 2 * Float32Array.BYTES_PER_ELEMENT, 1);
  1965. this._zF32[0] = e || 0
  1966. };
  1967. cc.Vertex3F.BYTES_PER_ELEMENT = 12;
  1968. Object.defineProperties(cc.Vertex3F.prototype, {
  1969. x: {
  1970. get: function() {
  1971. return this._xF32[0]
  1972. },
  1973. set: function(a) {
  1974. this._xF32[0] = a
  1975. },
  1976. enumerable: !0
  1977. },
  1978. y: {
  1979. get: function() {
  1980. return this._yF32[0]
  1981. },
  1982. set: function(a) {
  1983. this._yF32[0] = a
  1984. },
  1985. enumerable: !0
  1986. },
  1987. z: {
  1988. get: function() {
  1989. return this._zF32[0]
  1990. },
  1991. set: function(a) {
  1992. this._zF32[0] = a
  1993. },
  1994. enumerable: !0
  1995. }
  1996. });
  1997. cc.Tex2F = function(a, d, e, f) {
  1998. this._arrayBuffer = e || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);
  1999. this._offset = f || 0;
  2000. this._uF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  2001. this._vF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  2002. this._uF32[0] = a || 0;
  2003. this._vF32[0] = d || 0
  2004. };
  2005. cc.Tex2F.BYTES_PER_ELEMENT = 8;
  2006. Object.defineProperties(cc.Tex2F.prototype, {
  2007. u: {
  2008. get: function() {
  2009. return this._uF32[0]
  2010. },
  2011. set: function(a) {
  2012. this._uF32[0] = a
  2013. },
  2014. enumerable: !0
  2015. },
  2016. v: {
  2017. get: function() {
  2018. return this._vF32[0]
  2019. },
  2020. set: function(a) {
  2021. this._vF32[0] = a
  2022. },
  2023. enumerable: !0
  2024. }
  2025. });
  2026. cc.Quad2 = function(a, d, e, f, g, h) {
  2027. this._arrayBuffer = g || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);
  2028. this._offset = h || 0;
  2029. g = this._arrayBuffer;
  2030. h = cc.Vertex2F.BYTES_PER_ELEMENT;
  2031. this._tl = a ? new cc.Vertex2F(a.x, a.y, g, 0) : new cc.Vertex2F(0, 0, g, 0);
  2032. this._tr = d ? new cc.Vertex2F(d.x, d.y, g, h) : new cc.Vertex2F(0, 0, g, h);
  2033. this._bl = e ? new cc.Vertex2F(e.x, e.y, g, 2 * h) : new cc.Vertex2F(0, 0, g, 2 * h);
  2034. this._br = f ? new cc.Vertex2F(f.x, f.y, g, 3 * h) : new cc.Vertex2F(0, 0, g, 3 * h)
  2035. };
  2036. cc.Quad2.BYTES_PER_ELEMENT = 32;
  2037. cc.Quad3 = function(a, d, e, f) {
  2038. this.bl = a || new cc.Vertex3F(0, 0, 0);
  2039. this.br = d || new cc.Vertex3F(0, 0, 0);
  2040. this.tl = e || new cc.Vertex3F(0, 0, 0);
  2041. this.tr = f || new cc.Vertex3F(0, 0, 0)
  2042. };
  2043. Object.defineProperties(cc.Quad2.prototype, {
  2044. tl: {
  2045. get: function() {
  2046. return this._tl
  2047. },
  2048. set: function(a) {
  2049. this._tl.x = a.x;
  2050. this._tl.y = a.y
  2051. },
  2052. enumerable: !0
  2053. },
  2054. tr: {
  2055. get: function() {
  2056. return this._tr
  2057. },
  2058. set: function(a) {
  2059. this._tr.x = a.x;
  2060. this._tr.y = a.y
  2061. },
  2062. enumerable: !0
  2063. },
  2064. bl: {
  2065. get: function() {
  2066. return this._bl
  2067. },
  2068. set: function(a) {
  2069. this._bl.x = a.x;
  2070. this._bl.y = a.y
  2071. },
  2072. enumerable: !0
  2073. },
  2074. br: {
  2075. get: function() {
  2076. return this._br
  2077. },
  2078. set: function(a) {
  2079. this._br.x = a.x;
  2080. this._br.y = a.y
  2081. },
  2082. enumerable: !0
  2083. }
  2084. });
  2085. cc.V3F_C4B_T2F = function(a, d, e, f, g) {
  2086. this._arrayBuffer = f || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
  2087. this._offset = g || 0;
  2088. f = this._arrayBuffer;
  2089. g = this._offset;
  2090. var h = cc.Vertex3F.BYTES_PER_ELEMENT;
  2091. this._vertices = a ? new cc.Vertex3F(a.x, a.y, a.z, f, g) : new cc.Vertex3F(0, 0, 0, f, g);
  2092. 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);
  2093. 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)
  2094. };
  2095. cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24;
  2096. Object.defineProperties(cc.V3F_C4B_T2F.prototype, {
  2097. vertices: {
  2098. get: function() {
  2099. return this._vertices
  2100. },
  2101. set: function(a) {
  2102. var d = this._vertices;
  2103. d.x = a.x;
  2104. d.y = a.y;
  2105. d.z = a.z
  2106. },
  2107. enumerable: !0
  2108. },
  2109. colors: {
  2110. get: function() {
  2111. return this._colors
  2112. },
  2113. set: function(a) {
  2114. var d = this._colors;
  2115. d.r = a.r;
  2116. d.g = a.g;
  2117. d.b = a.b;
  2118. d.a = a.a
  2119. },
  2120. enumerable: !0
  2121. },
  2122. texCoords: {
  2123. get: function() {
  2124. return this._texCoords
  2125. },
  2126. set: function(a) {
  2127. this._texCoords.u = a.u;
  2128. this._texCoords.v = a.v
  2129. },
  2130. enumerable: !0
  2131. }
  2132. });
  2133. cc.V3F_C4B_T2F_Quad = function(a, d, e, f, g, h) {
  2134. this._arrayBuffer = g || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
  2135. this._offset = h || 0;
  2136. g = this._arrayBuffer;
  2137. h = this._offset;
  2138. var k = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;
  2139. 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);
  2140. 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);
  2141. 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);
  2142. 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)
  2143. };
  2144. cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96;
  2145. Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype, {
  2146. tl: {
  2147. get: function() {
  2148. return this._tl
  2149. },
  2150. set: function(a) {
  2151. var d = this._tl;
  2152. d.vertices = a.vertices;
  2153. d.colors = a.colors;
  2154. d.texCoords = a.texCoords
  2155. },
  2156. enumerable: !0
  2157. },
  2158. bl: {
  2159. get: function() {
  2160. return this._bl
  2161. },
  2162. set: function(a) {
  2163. var d = this._bl;
  2164. d.vertices = a.vertices;
  2165. d.colors = a.colors;
  2166. d.texCoords = a.texCoords
  2167. },
  2168. enumerable: !0
  2169. },
  2170. tr: {
  2171. get: function() {
  2172. return this._tr
  2173. },
  2174. set: function(a) {
  2175. var d = this._tr;
  2176. d.vertices = a.vertices;
  2177. d.colors = a.colors;
  2178. d.texCoords = a.texCoords
  2179. },
  2180. enumerable: !0
  2181. },
  2182. br: {
  2183. get: function() {
  2184. return this._br
  2185. },
  2186. set: function(a) {
  2187. var d = this._br;
  2188. d.vertices = a.vertices;
  2189. d.colors = a.colors;
  2190. d.texCoords = a.texCoords
  2191. },
  2192. enumerable: !0
  2193. },
  2194. arrayBuffer: {
  2195. get: function() {
  2196. return this._arrayBuffer
  2197. },
  2198. enumerable: !0
  2199. }
  2200. });
  2201. cc.V3F_C4B_T2F_QuadZero = function() {
  2202. return new cc.V3F_C4B_T2F_Quad
  2203. };
  2204. cc.V3F_C4B_T2F_QuadCopy = function(a) {
  2205. if (!a) return cc.V3F_C4B_T2F_QuadZero();
  2206. var d = a.tl,
  2207. e = a.bl,
  2208. f = a.tr;
  2209. a = a.br;
  2210. return {
  2211. tl: {
  2212. vertices: {
  2213. x: d.vertices.x,
  2214. y: d.vertices.y,
  2215. z: d.vertices.z
  2216. },
  2217. colors: {
  2218. r: d.colors.r,
  2219. g: d.colors.g,
  2220. b: d.colors.b,
  2221. a: d.colors.a
  2222. },
  2223. texCoords: {
  2224. u: d.texCoords.u,
  2225. v: d.texCoords.v
  2226. }
  2227. },
  2228. bl: {
  2229. vertices: {
  2230. x: e.vertices.x,
  2231. y: e.vertices.y,
  2232. z: e.vertices.z
  2233. },
  2234. colors: {
  2235. r: e.colors.r,
  2236. g: e.colors.g,
  2237. b: e.colors.b,
  2238. a: e.colors.a
  2239. },
  2240. texCoords: {
  2241. u: e.texCoords.u,
  2242. v: e.texCoords.v
  2243. }
  2244. },
  2245. tr: {
  2246. vertices: {
  2247. x: f.vertices.x,
  2248. y: f.vertices.y,
  2249. z: f.vertices.z
  2250. },
  2251. colors: {
  2252. r: f.colors.r,
  2253. g: f.colors.g,
  2254. b: f.colors.b,
  2255. a: f.colors.a
  2256. },
  2257. texCoords: {
  2258. u: f.texCoords.u,
  2259. v: f.texCoords.v
  2260. }
  2261. },
  2262. br: {
  2263. vertices: {
  2264. x: a.vertices.x,
  2265. y: a.vertices.y,
  2266. z: a.vertices.z
  2267. },
  2268. colors: {
  2269. r: a.colors.r,
  2270. g: a.colors.g,
  2271. b: a.colors.b,
  2272. a: a.colors.a
  2273. },
  2274. texCoords: {
  2275. u: a.texCoords.u,
  2276. v: a.texCoords.v
  2277. }
  2278. }
  2279. }
  2280. };
  2281. cc.V3F_C4B_T2F_QuadsCopy = function(a) {
  2282. if (!a) return [];
  2283. for (var d = [], e = 0; e < a.length; e++) d.push(cc.V3F_C4B_T2F_QuadCopy(a[e]));
  2284. return d
  2285. };
  2286. cc.V2F_C4B_T2F = function(a, d, e, f, g) {
  2287. this._arrayBuffer = f || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);
  2288. this._offset = g || 0;
  2289. f = this._arrayBuffer;
  2290. g = this._offset;
  2291. var h = cc.Vertex2F.BYTES_PER_ELEMENT;
  2292. this._vertices = a ? new cc.Vertex2F(a.x, a.y, f, g) : new cc.Vertex2F(0, 0, f, g);
  2293. 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);
  2294. 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)
  2295. };
  2296. cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20;
  2297. Object.defineProperties(cc.V2F_C4B_T2F.prototype, {
  2298. vertices: {
  2299. get: function() {
  2300. return this._vertices
  2301. },
  2302. set: function(a) {
  2303. this._vertices.x = a.x;
  2304. this._vertices.y = a.y
  2305. },
  2306. enumerable: !0
  2307. },
  2308. colors: {
  2309. get: function() {
  2310. return this._colors
  2311. },
  2312. set: function(a) {
  2313. var d = this._colors;
  2314. d.r = a.r;
  2315. d.g = a.g;
  2316. d.b = a.b;
  2317. d.a = a.a
  2318. },
  2319. enumerable: !0
  2320. },
  2321. texCoords: {
  2322. get: function() {
  2323. return this._texCoords
  2324. },
  2325. set: function(a) {
  2326. this._texCoords.u = a.u;
  2327. this._texCoords.v = a.v
  2328. },
  2329. enumerable: !0
  2330. }
  2331. });
  2332. cc.V2F_C4B_T2F_Triangle = function(a, d, e, f, g) {
  2333. this._arrayBuffer = f || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);
  2334. this._offset = g || 0;
  2335. f = this._arrayBuffer;
  2336. g = this._offset;
  2337. var h = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  2338. 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);
  2339. 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);
  2340. 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)
  2341. };
  2342. cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60;
  2343. Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype, {
  2344. a: {
  2345. get: function() {
  2346. return this._a
  2347. },
  2348. set: function(a) {
  2349. var d = this._a;
  2350. d.vertices = a.vertices;
  2351. d.colors = a.colors;
  2352. d.texCoords = a.texCoords
  2353. },
  2354. enumerable: !0
  2355. },
  2356. b: {
  2357. get: function() {
  2358. return this._b
  2359. },
  2360. set: function(a) {
  2361. var d = this._b;
  2362. d.vertices = a.vertices;
  2363. d.colors = a.colors;
  2364. d.texCoords = a.texCoords
  2365. },
  2366. enumerable: !0
  2367. },
  2368. c: {
  2369. get: function() {
  2370. return this._c
  2371. },
  2372. set: function(a) {
  2373. var d = this._c;
  2374. d.vertices = a.vertices;
  2375. d.colors = a.colors;
  2376. d.texCoords = a.texCoords
  2377. },
  2378. enumerable: !0
  2379. }
  2380. })
  2381. };
  2382. cc._tmp.PrototypeColor = function() {
  2383. var a = cc.color;
  2384. a._getWhite = function() {
  2385. return a(255, 255, 255)
  2386. };
  2387. a._getYellow = function() {
  2388. return a(255, 255, 0)
  2389. };
  2390. a._getBlue = function() {
  2391. return a(0, 0, 255)
  2392. };
  2393. a._getGreen = function() {
  2394. return a(0, 255, 0)
  2395. };
  2396. a._getRed = function() {
  2397. return a(255, 0, 0)
  2398. };
  2399. a._getMagenta = function() {
  2400. return a(255, 0, 255)
  2401. };
  2402. a._getBlack = function() {
  2403. return a(0, 0, 0)
  2404. };
  2405. a._getOrange = function() {
  2406. return a(255, 127, 0)
  2407. };
  2408. a._getGray = function() {
  2409. return a(166, 166, 166)
  2410. };
  2411. cc.defineGetterSetter(a, "WHITE", a._getWhite);
  2412. cc.defineGetterSetter(a, "YELLOW", a._getYellow);
  2413. cc.defineGetterSetter(a, "BLUE", a._getBlue);
  2414. cc.defineGetterSetter(a, "GREEN", a._getGreen);
  2415. cc.defineGetterSetter(a, "RED", a._getRed);
  2416. cc.defineGetterSetter(a, "MAGENTA", a._getMagenta);
  2417. cc.defineGetterSetter(a, "BLACK", a._getBlack);
  2418. cc.defineGetterSetter(a, "ORANGE", a._getOrange);
  2419. cc.defineGetterSetter(a, "GRAY", a._getGray);
  2420. cc.BlendFunc._disable = function() {
  2421. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2422. };
  2423. cc.BlendFunc._alphaPremultiplied = function() {
  2424. return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA)
  2425. };
  2426. cc.BlendFunc._alphaNonPremultiplied = function() {
  2427. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA)
  2428. };
  2429. cc.BlendFunc._additive = function() {
  2430. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE)
  2431. };
  2432. cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable);
  2433. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied);
  2434. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied);
  2435. cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive)
  2436. };
  2437. cc.Color = function(a, c, d, e) {
  2438. this.r = a || 0;
  2439. this.g = c || 0;
  2440. this.b = d || 0;
  2441. this.a = e || 255
  2442. };
  2443. cc.color = function(a, c, d, e) {
  2444. return void 0 === a ? {
  2445. r: 0,
  2446. g: 0,
  2447. b: 0,
  2448. a: 255
  2449. } : "string" === typeof a ? cc.hexToColor(a) : "object" === typeof a ? {
  2450. r: a.r,
  2451. g: a.g,
  2452. b: a.b,
  2453. a: a.a || 255
  2454. } : {
  2455. r: a,
  2456. g: c,
  2457. b: d,
  2458. a: e || 255
  2459. }
  2460. };
  2461. cc.colorEqual = function(a, c) {
  2462. return a.r === c.r && a.g === c.g && a.b === c.b
  2463. };
  2464. cc.Acceleration = function(a, c, d, e) {
  2465. this.x = a || 0;
  2466. this.y = c || 0;
  2467. this.z = d || 0;
  2468. this.timestamp = e || 0
  2469. };
  2470. cc.Vertex2F = function(a, c) {
  2471. this.x = a || 0;
  2472. this.y = c || 0
  2473. };
  2474. cc.vertex2 = function(a, c) {
  2475. return new cc.Vertex2F(a, c)
  2476. };
  2477. cc.Vertex3F = function(a, c, d) {
  2478. this.x = a || 0;
  2479. this.y = c || 0;
  2480. this.z = d || 0
  2481. };
  2482. cc.vertex3 = function(a, c, d) {
  2483. return new cc.Vertex3F(a, c, d)
  2484. };
  2485. cc.Tex2F = function(a, c) {
  2486. this.u = a || 0;
  2487. this.v = c || 0
  2488. };
  2489. cc.tex2 = function(a, c) {
  2490. return new cc.Tex2F(a, c)
  2491. };
  2492. cc.BlendFunc = function(a, c) {
  2493. this.src = a;
  2494. this.dst = c
  2495. };
  2496. cc.blendFuncDisable = function() {
  2497. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2498. };
  2499. cc.hexToColor = function(a) {
  2500. a = a.replace(/^#?/, "0x");
  2501. a = parseInt(a);
  2502. return cc.color(a >> 16, (a >> 8) % 256, a % 256)
  2503. };
  2504. cc.colorToHex = function(a) {
  2505. var c = a.r.toString(16),
  2506. d = a.g.toString(16),
  2507. e = a.b.toString(16);
  2508. return "#" + (16 > a.r ? "0" + c : c) + (16 > a.g ? "0" + d : d) + (16 > a.b ? "0" + e : e)
  2509. };
  2510. cc.TEXT_ALIGNMENT_LEFT = 0;
  2511. cc.TEXT_ALIGNMENT_CENTER = 1;
  2512. cc.TEXT_ALIGNMENT_RIGHT = 2;
  2513. cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
  2514. cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
  2515. cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
  2516. cc._Dictionary = cc.Class.extend({
  2517. _keyMapTb: null,
  2518. _valueMapTb: null,
  2519. __currId: 0,
  2520. ctor: function() {
  2521. this._keyMapTb = {};
  2522. this._valueMapTb = {};
  2523. this.__currId = 2 << (0 | 10 * Math.random())
  2524. },
  2525. __getKey: function() {
  2526. this.__currId++;
  2527. return "key_" + this.__currId
  2528. },
  2529. setObject: function(a, c) {
  2530. if (null != c) {
  2531. var d = this.__getKey();
  2532. this._keyMapTb[d] = c;
  2533. this._valueMapTb[d] = a
  2534. }
  2535. },
  2536. objectForKey: function(a) {
  2537. if (null == a) return null;
  2538. var c = this._keyMapTb,
  2539. d;
  2540. for (d in c)
  2541. if (c[d] === a) return this._valueMapTb[d];
  2542. return null
  2543. },
  2544. valueForKey: function(a) {
  2545. return this.objectForKey(a)
  2546. },
  2547. removeObjectForKey: function(a) {
  2548. if (null != a) {
  2549. var c = this._keyMapTb,
  2550. d;
  2551. for (d in c)
  2552. if (c[d] === a) {
  2553. delete this._valueMapTb[d];
  2554. delete c[d];
  2555. break
  2556. }
  2557. }
  2558. },
  2559. removeObjectsForKeys: function(a) {
  2560. if (null != a)
  2561. for (var c = 0; c < a.length; c++) this.removeObjectForKey(a[c])
  2562. },
  2563. allKeys: function() {
  2564. var a = [],
  2565. c = this._keyMapTb,
  2566. d;
  2567. for (d in c) a.push(c[d]);
  2568. return a
  2569. },
  2570. removeAllObjects: function() {
  2571. this._keyMapTb = {};
  2572. this._valueMapTb = {}
  2573. },
  2574. count: function() {
  2575. return this.allKeys().length
  2576. }
  2577. });
  2578. cc.FontDefinition = function() {
  2579. this.fontName = "Arial";
  2580. this.fontSize = 12;
  2581. this.textAlign = cc.TEXT_ALIGNMENT_CENTER;
  2582. this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  2583. this.fillStyle = cc.color(255, 255, 255, 255);
  2584. this.boundingHeight = this.boundingWidth = 0;
  2585. this.strokeEnabled = !1;
  2586. this.strokeStyle = cc.color(255, 255, 255, 255);
  2587. this.lineWidth = 1;
  2588. this.shadowEnabled = !1;
  2589. this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0;
  2590. this.shadowOpacity = 1
  2591. };
  2592. 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);
  2593. cc.assert("function" === typeof cc._tmp.PrototypeColor, cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js");
  2594. cc._tmp.PrototypeColor();
  2595. delete cc._tmp.PrototypeColor;
  2596. cc.Touches = [];
  2597. cc.TouchesIntergerDict = {};
  2598. cc.EGLView = cc.Class.extend({
  2599. _delegate: null,
  2600. _frameSize: null,
  2601. _designResolutionSize: null,
  2602. _originalDesignResolutionSize: null,
  2603. _viewPortRect: null,
  2604. _visibleRect: null,
  2605. _retinaEnabled: !1,
  2606. _autoFullScreen: !0,
  2607. _devicePixelRatio: 1,
  2608. _viewName: "",
  2609. _resizeCallback: null,
  2610. _scaleX: 1,
  2611. _originalScaleX: 1,
  2612. _scaleY: 1,
  2613. _originalScaleY: 1,
  2614. _indexBitsUsed: 0,
  2615. _maxTouches: 5,
  2616. _resolutionPolicy: null,
  2617. _rpExactFit: null,
  2618. _rpShowAll: null,
  2619. _rpNoBorder: null,
  2620. _rpFixedHeight: null,
  2621. _rpFixedWidth: null,
  2622. _initialized: !1,
  2623. _captured: !1,
  2624. _wnd: null,
  2625. _hDC: null,
  2626. _hRC: null,
  2627. _supportTouch: !1,
  2628. _contentTranslateLeftTop: null,
  2629. _frame: null,
  2630. _frameZoomFactor: 1,
  2631. __resizeWithBrowserSize: !1,
  2632. _isAdjustViewPort: !0,
  2633. ctor: function() {
  2634. var a = document,
  2635. c = cc.ContainerStrategy,
  2636. d = cc.ContentStrategy;
  2637. this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode;
  2638. this._frameSize = cc.size(0, 0);
  2639. this._initFrameSize();
  2640. var a = cc._canvas.width,
  2641. e = cc._canvas.height;
  2642. this._designResolutionSize = cc.size(a, e);
  2643. this._originalDesignResolutionSize = cc.size(a, e);
  2644. this._viewPortRect = cc.rect(0, 0, a, e);
  2645. this._visibleRect = cc.rect(0, 0, a, e);
  2646. this._contentTranslateLeftTop = {
  2647. left: 0,
  2648. top: 0
  2649. };
  2650. this._viewName = "Cocos2dHTML5";
  2651. a = cc.sys;
  2652. this.enableRetina(a.os == a.OS_IOS || a.os == a.OS_OSX);
  2653. cc.visibleRect && cc.visibleRect.init(this._visibleRect);
  2654. this._rpExactFit = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.EXACT_FIT);
  2655. this._rpShowAll = new cc.ResolutionPolicy(c.PROPORTION_TO_FRAME, d.SHOW_ALL);
  2656. this._rpNoBorder = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.NO_BORDER);
  2657. this._rpFixedHeight = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.FIXED_HEIGHT);
  2658. this._rpFixedWidth = new cc.ResolutionPolicy(c.EQUAL_TO_FRAME, d.FIXED_WIDTH);
  2659. this._hDC = cc._canvas;
  2660. this._hRC = cc._renderContext
  2661. },
  2662. _resizeEvent: function() {
  2663. var a = this._originalDesignResolutionSize.width,
  2664. c = this._originalDesignResolutionSize.height;
  2665. this._resizeCallback && (this._initFrameSize(), this._resizeCallback.call());
  2666. 0 < a && this.setDesignResolutionSize(a, c, this._resolutionPolicy)
  2667. },
  2668. resizeWithBrowserSize: function(a) {
  2669. 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))
  2670. },
  2671. setResizeCallback: function(a) {
  2672. if ("function" == typeof a || null == a) this._resizeCallback = a
  2673. },
  2674. _initFrameSize: function() {
  2675. var a = this._frameSize;
  2676. a.width = this._frame.clientWidth;
  2677. a.height = this._frame.clientHeight
  2678. },
  2679. _adjustSizeKeepCanvasSize: function() {
  2680. var a = this._originalDesignResolutionSize.width,
  2681. c = this._originalDesignResolutionSize.height;
  2682. 0 < a && this.setDesignResolutionSize(a, c, this._resolutionPolicy)
  2683. },
  2684. _setViewPortMeta: function(a, c) {
  2685. if (this._isAdjustViewPort) {
  2686. var d = {
  2687. "user-scalable": "no",
  2688. "maximum-scale": "1.0",
  2689. "initial-scale": "1.0"
  2690. },
  2691. e = document.getElementsByName("viewport"),
  2692. f;
  2693. 0 == e.length ? (e = cc.newElement("meta"), e.name = "viewport", e.content = "", document.head.appendChild(e)) : e = e[0];
  2694. if (cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX) e.content = "initial-scale:1";
  2695. else {
  2696. f = e.content;
  2697. for (var g in d) RegExp(g).test(f) || (f += ("" == f ? "" : ",") + g + "\x3d" + d[g]);
  2698. e.content = f
  2699. }
  2700. }
  2701. },
  2702. _setScaleXYForRenderTexture: function() {
  2703. var a = cc.contentScaleFactor();
  2704. this._scaleY = this._scaleX = a
  2705. },
  2706. _resetScale: function() {
  2707. this._scaleX = this._originalScaleX;
  2708. this._scaleY = this._originalScaleY
  2709. },
  2710. _adjustSizeToBrowser: function() {},
  2711. initialize: function() {
  2712. this._initialized = !0
  2713. },
  2714. adjustViewPort: function(a) {
  2715. this._isAdjustViewPort = a
  2716. },
  2717. enableRetina: function(a) {
  2718. this._retinaEnabled = a ? !0 : !1
  2719. },
  2720. isRetinaEnabled: function() {
  2721. return this._retinaEnabled
  2722. },
  2723. enableAutoFullScreen: function(a) {
  2724. this._autoFullScreen = a ? !0 : !1
  2725. },
  2726. isAutoFullScreenEnabled: function() {
  2727. return this._autoFullScreen
  2728. },
  2729. end: function() {},
  2730. isOpenGLReady: function() {
  2731. return null != this._hDC && null != this._hRC
  2732. },
  2733. setFrameZoomFactor: function(a) {
  2734. this._frameZoomFactor = a;
  2735. this.centerWindow();
  2736. cc.director.setProjection(cc.director.getProjection())
  2737. },
  2738. swapBuffers: function() {},
  2739. setIMEKeyboardState: function(a) {},
  2740. setContentTranslateLeftTop: function(a, c) {
  2741. this._contentTranslateLeftTop = {
  2742. left: a,
  2743. top: c
  2744. }
  2745. },
  2746. getContentTranslateLeftTop: function() {
  2747. return this._contentTranslateLeftTop
  2748. },
  2749. getFrameSize: function() {
  2750. return cc.size(this._frameSize.width, this._frameSize.height)
  2751. },
  2752. setFrameSize: function(a, c) {
  2753. this._frameSize.width = a;
  2754. this._frameSize.height = c;
  2755. this._frame.style.width = a + "px";
  2756. this._frame.style.height = c + "px";
  2757. this._resizeEvent();
  2758. cc.director.setProjection(cc.director.getProjection())
  2759. },
  2760. centerWindow: function() {},
  2761. getVisibleSize: function() {
  2762. return cc.size(this._visibleRect.width, this._visibleRect.height)
  2763. },
  2764. getVisibleOrigin: function() {
  2765. return cc.p(this._visibleRect.x, this._visibleRect.y)
  2766. },
  2767. canSetContentScaleFactor: function() {
  2768. return !0
  2769. },
  2770. getResolutionPolicy: function() {
  2771. return this._resolutionPolicy
  2772. },
  2773. setResolutionPolicy: function(a) {
  2774. if (a instanceof cc.ResolutionPolicy) this._resolutionPolicy = a;
  2775. else {
  2776. var c = cc.ResolutionPolicy;
  2777. a === c.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit);
  2778. a === c.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll);
  2779. a === c.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder);
  2780. a === c.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight);
  2781. a === c.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth)
  2782. }
  2783. },
  2784. setDesignResolutionSize: function(a, c, d) {
  2785. if (isNaN(a) || 0 == a || isNaN(c) || 0 == c) cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);
  2786. else {
  2787. this.setResolutionPolicy(d);
  2788. var e = this._resolutionPolicy;
  2789. if (e) {
  2790. e.preApply(this);
  2791. var f = this._frameSize.width,
  2792. g = this._frameSize.height;
  2793. cc.sys.isMobile && this._setViewPortMeta(this._frameSize.width, this._frameSize.height);
  2794. this._initFrameSize();
  2795. 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))
  2796. } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2)
  2797. }
  2798. },
  2799. getDesignResolutionSize: function() {
  2800. return cc.size(this._designResolutionSize.width, this._designResolutionSize.height)
  2801. },
  2802. setViewPortInPoints: function(a, c, d, e) {
  2803. var f = this._frameZoomFactor,
  2804. g = this._scaleX,
  2805. h = this._scaleY;
  2806. cc._renderContext.viewport(a * g * f + this._viewPortRect.x * f, c * h * f + this._viewPortRect.y * f, d * g * f, e * h * f)
  2807. },
  2808. setScissorInPoints: function(a, c, d, e) {
  2809. var f = this._frameZoomFactor,
  2810. g = this._scaleX,
  2811. h = this._scaleY;
  2812. cc._renderContext.scissor(a * g * f + this._viewPortRect.x * f, c * h * f + this._viewPortRect.y * f, d * g * f, e * h * f)
  2813. },
  2814. isScissorEnabled: function() {
  2815. var a = cc._renderContext;
  2816. return a.isEnabled(a.SCISSOR_TEST)
  2817. },
  2818. getScissorRect: function() {
  2819. var a = cc._renderContext,
  2820. c = this._scaleX,
  2821. d = this._scaleY,
  2822. a = a.getParameter(a.SCISSOR_BOX);
  2823. return cc.rect((a[0] - this._viewPortRect.x) / c, (a[1] - this._viewPortRect.y) / d, a[2] / c, a[3] / d)
  2824. },
  2825. setViewName: function(a) {
  2826. null != a && 0 < a.length && (this._viewName = a)
  2827. },
  2828. getViewName: function() {
  2829. return this._viewName
  2830. },
  2831. getViewPortRect: function() {
  2832. return this._viewPortRect
  2833. },
  2834. getScaleX: function() {
  2835. return this._scaleX
  2836. },
  2837. getScaleY: function() {
  2838. return this._scaleY
  2839. },
  2840. getDevicePixelRatio: function() {
  2841. return this._devicePixelRatio
  2842. },
  2843. convertToLocationInView: function(a, c, d) {
  2844. return {
  2845. x: this._devicePixelRatio * (a - d.left),
  2846. y: this._devicePixelRatio * (d.top + d.height - c)
  2847. }
  2848. },
  2849. _convertMouseToLocationInView: function(a, c) {
  2850. var d = this._viewPortRect;
  2851. a.x = (this._devicePixelRatio * (a.x - c.left) - d.x) / this._scaleX;
  2852. a.y = (this._devicePixelRatio * (c.top + c.height - a.y) - d.y) / this._scaleY
  2853. },
  2854. _convertTouchesWithScale: function(a) {
  2855. 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)
  2856. }
  2857. });
  2858. cc.EGLView._getInstance = function() {
  2859. this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize());
  2860. return this._instance
  2861. };
  2862. cc.ContainerStrategy = cc.Class.extend({
  2863. preApply: function(a) {},
  2864. apply: function(a, c) {},
  2865. postApply: function(a) {},
  2866. _setupContainer: function(a, c, d) {
  2867. var e = a._frame;
  2868. cc.view._autoFullScreen && (cc.sys.isMobile && e == document.documentElement) && cc.screen.autoFullScreen(e);
  2869. var e = cc._canvas,
  2870. f = cc.container;
  2871. f.style.width = e.style.width = c + "px";
  2872. f.style.height = e.style.height = d + "px";
  2873. f = a._devicePixelRatio = 1;
  2874. a.isRetinaEnabled() && (f = a._devicePixelRatio = window.devicePixelRatio || 1);
  2875. e.width = c * f;
  2876. e.height = d * f;
  2877. a = document.body;
  2878. var g;
  2879. 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"
  2880. },
  2881. _fixContainer: function() {
  2882. document.body.insertBefore(cc.container, document.body.firstChild);
  2883. var a = document.body.style;
  2884. a.width = window.innerWidth + "px";
  2885. a.height = window.innerHeight + "px";
  2886. a.overflow = "hidden";
  2887. a = cc.container.style;
  2888. a.position = "fixed";
  2889. a.left = a.top = "0px";
  2890. document.body.scrollTop = 0
  2891. }
  2892. });
  2893. cc.ContentStrategy = cc.Class.extend({
  2894. _result: {
  2895. scale: [1, 1],
  2896. viewport: null
  2897. },
  2898. _buildResult: function(a, c, d, e, f, g) {
  2899. 2 > Math.abs(a - d) && (d = a);
  2900. 2 > Math.abs(c - e) && (e = c);
  2901. a = cc.rect(Math.round((a - d) / 2), Math.round((c - e) / 2), d, e);
  2902. cc._renderType == cc._RENDER_TYPE_CANVAS && cc._renderContext.translate(a.x, a.y + e);
  2903. this._result.scale = [f, g];
  2904. this._result.viewport = a;
  2905. return this._result
  2906. },
  2907. preApply: function(a) {},
  2908. apply: function(a, c) {
  2909. return {
  2910. scale: [1, 1]
  2911. }
  2912. },
  2913. postApply: function(a) {}
  2914. });
  2915. (function() {
  2916. var a = cc.ContainerStrategy.extend({
  2917. apply: function(a) {
  2918. this._setupContainer(a, a._frameSize.width, a._frameSize.height)
  2919. }
  2920. }),
  2921. c = cc.ContainerStrategy.extend({
  2922. apply: function(a, c) {
  2923. var d = a._frameSize.width,
  2924. e = a._frameSize.height,
  2925. f = cc.container.style,
  2926. q = c.width,
  2927. r = c.height,
  2928. t = d / q,
  2929. s = e / r,
  2930. v, u;
  2931. t < s ? (v = d, u = r * t) : (v = q * s, u = e);
  2932. q = Math.round((d - v) / 2);
  2933. u = Math.round((e - u) / 2);
  2934. this._setupContainer(a, d - 2 * q, e - 2 * u);
  2935. f.marginLeft = q + "px";
  2936. f.marginRight = q + "px";
  2937. f.marginTop = u + "px";
  2938. f.marginBottom = u + "px"
  2939. }
  2940. });
  2941. a.extend({
  2942. preApply: function(a) {
  2943. this._super(a);
  2944. a._frame = document.documentElement
  2945. },
  2946. apply: function(a) {
  2947. this._super(a);
  2948. this._fixContainer()
  2949. }
  2950. });
  2951. c.extend({
  2952. preApply: function(a) {
  2953. this._super(a);
  2954. a._frame = document.documentElement
  2955. },
  2956. apply: function(a, c) {
  2957. this._super(a, c);
  2958. this._fixContainer()
  2959. }
  2960. });
  2961. var d = cc.ContainerStrategy.extend({
  2962. apply: function(a) {
  2963. this._setupContainer(a, cc._canvas.width, cc._canvas.height)
  2964. }
  2965. });
  2966. cc.ContainerStrategy.EQUAL_TO_FRAME = new a;
  2967. cc.ContainerStrategy.PROPORTION_TO_FRAME = new c;
  2968. cc.ContainerStrategy.ORIGINAL_CONTAINER = new d;
  2969. var a = cc.ContentStrategy.extend({
  2970. apply: function(a, c) {
  2971. var d = cc._canvas.width,
  2972. e = cc._canvas.height;
  2973. return this._buildResult(d, e, d, e, d / c.width, e / c.height)
  2974. }
  2975. }),
  2976. c = cc.ContentStrategy.extend({
  2977. apply: function(a, c) {
  2978. var d = cc._canvas.width,
  2979. e = cc._canvas.height,
  2980. f = c.width,
  2981. q = c.height,
  2982. r = d / f,
  2983. t = e / q,
  2984. s = 0,
  2985. v, u;
  2986. r < t ? (s = r, v = d, u = q * s) : (s = t, v = f * s, u = e);
  2987. return this._buildResult(d, e, v, u, s, s)
  2988. }
  2989. }),
  2990. d = cc.ContentStrategy.extend({
  2991. apply: function(a, c) {
  2992. var d = cc._canvas.width,
  2993. e = cc._canvas.height,
  2994. f = c.width,
  2995. q = c.height,
  2996. r = d / f,
  2997. t = e / q,
  2998. s, v, u;
  2999. r < t ? (s = t, v = f * s, u = e) : (s = r, v = d, u = q * s);
  3000. return this._buildResult(d, e, v, u, s, s)
  3001. }
  3002. }),
  3003. e = cc.ContentStrategy.extend({
  3004. apply: function(a, c) {
  3005. var d = cc._canvas.width,
  3006. e = cc._canvas.height,
  3007. f = e / c.height;
  3008. return this._buildResult(d, e, d, e, f, f)
  3009. },
  3010. postApply: function(a) {
  3011. cc.director._winSizeInPoints = a.getVisibleSize()
  3012. }
  3013. }),
  3014. f = cc.ContentStrategy.extend({
  3015. apply: function(a, c) {
  3016. var d = cc._canvas.width,
  3017. e = cc._canvas.height,
  3018. f = d / c.width;
  3019. return this._buildResult(d, e, d, e, f, f)
  3020. },
  3021. postApply: function(a) {
  3022. cc.director._winSizeInPoints = a.getVisibleSize()
  3023. }
  3024. });
  3025. cc.ContentStrategy.EXACT_FIT = new a;
  3026. cc.ContentStrategy.SHOW_ALL = new c;
  3027. cc.ContentStrategy.NO_BORDER = new d;
  3028. cc.ContentStrategy.FIXED_HEIGHT = new e;
  3029. cc.ContentStrategy.FIXED_WIDTH = new f
  3030. })();
  3031. cc.ResolutionPolicy = cc.Class.extend({
  3032. _containerStrategy: null,
  3033. _contentStrategy: null,
  3034. ctor: function(a, c) {
  3035. this.setContainerStrategy(a);
  3036. this.setContentStrategy(c)
  3037. },
  3038. preApply: function(a) {
  3039. this._containerStrategy.preApply(a);
  3040. this._contentStrategy.preApply(a)
  3041. },
  3042. apply: function(a, c) {
  3043. this._containerStrategy.apply(a, c);
  3044. return this._contentStrategy.apply(a, c)
  3045. },
  3046. postApply: function(a) {
  3047. this._containerStrategy.postApply(a);
  3048. this._contentStrategy.postApply(a)
  3049. },
  3050. setContainerStrategy: function(a) {
  3051. a instanceof cc.ContainerStrategy && (this._containerStrategy = a)
  3052. },
  3053. setContentStrategy: function(a) {
  3054. a instanceof cc.ContentStrategy && (this._contentStrategy = a)
  3055. }
  3056. });
  3057. cc.ResolutionPolicy.EXACT_FIT = 0;
  3058. cc.ResolutionPolicy.NO_BORDER = 1;
  3059. cc.ResolutionPolicy.SHOW_ALL = 2;
  3060. cc.ResolutionPolicy.FIXED_HEIGHT = 3;
  3061. cc.ResolutionPolicy.FIXED_WIDTH = 4;
  3062. cc.ResolutionPolicy.UNKNOWN = 5;
  3063. cc.screen = {
  3064. _supportsFullScreen: !1,
  3065. _preOnFullScreenChange: null,
  3066. _touchEvent: "",
  3067. _fn: null,
  3068. _fnMap: [
  3069. ["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement"],
  3070. ["requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement"],
  3071. ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"],
  3072. ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement"],
  3073. ["msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement"]
  3074. ],
  3075. init: function() {
  3076. this._fn = {};
  3077. var a, c, d = this._fnMap,
  3078. e;
  3079. a = 0;
  3080. for (l = d.length; a < l; a++)
  3081. if ((c = d[a]) && c[1] in document) {
  3082. a = 0;
  3083. for (e = c.length; a < e; a++) this._fn[d[0][a]] = c[a];
  3084. break
  3085. }
  3086. this._supportsFullScreen = void 0 != this._fn.requestFullscreen;
  3087. this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown"
  3088. },
  3089. fullScreen: function() {
  3090. return this._supportsFullScreen && document[this._fn.fullscreenEnabled]
  3091. },
  3092. requestFullScreen: function(a, c) {
  3093. if (this._supportsFullScreen) {
  3094. a = a || document.documentElement;
  3095. a[this._fn.requestFullscreen]();
  3096. if (c) {
  3097. var d = this._fn.fullscreenchange;
  3098. this._preOnFullScreenChange && document.removeEventListener(d, this._preOnFullScreenChange);
  3099. this._preOnFullScreenChange = c;
  3100. cc._addEventListener(document, d, c, !1)
  3101. }
  3102. return a[this._fn.requestFullscreen]()
  3103. }
  3104. },
  3105. exitFullScreen: function() {
  3106. return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : !0
  3107. },
  3108. autoFullScreen: function(a, c) {
  3109. function d() {
  3110. f.requestFullScreen(a, c);
  3111. e.removeEventListener(f._touchEvent, d)
  3112. }
  3113. a = a || document.body;
  3114. var e = cc._canvas || a,
  3115. f = this;
  3116. this.requestFullScreen(a, c);
  3117. cc._addEventListener(e, this._touchEvent, d)
  3118. }
  3119. };
  3120. cc.screen.init();
  3121. cc.visibleRect = {
  3122. topLeft: cc.p(0, 0),
  3123. topRight: cc.p(0, 0),
  3124. top: cc.p(0, 0),
  3125. bottomLeft: cc.p(0, 0),
  3126. bottomRight: cc.p(0, 0),
  3127. bottom: cc.p(0, 0),
  3128. center: cc.p(0, 0),
  3129. left: cc.p(0, 0),
  3130. right: cc.p(0, 0),
  3131. width: 0,
  3132. height: 0,
  3133. init: function(a) {
  3134. var c = this.width = a.width,
  3135. d = this.height = a.height,
  3136. e = a.x;
  3137. a = a.y;
  3138. var f = a + d,
  3139. g = e + c;
  3140. this.topLeft.x = e;
  3141. this.topLeft.y = f;
  3142. this.topRight.x = g;
  3143. this.topRight.y = f;
  3144. this.top.x = e + c / 2;
  3145. this.top.y = f;
  3146. this.bottomLeft.x = e;
  3147. this.bottomLeft.y = a;
  3148. this.bottomRight.x = g;
  3149. this.bottomRight.y = a;
  3150. this.bottom.x = e + c / 2;
  3151. this.bottom.y = a;
  3152. this.center.x = e + c / 2;
  3153. this.center.y = a + d / 2;
  3154. this.left.x = e;
  3155. this.left.y = a + d / 2;
  3156. this.right.x = g;
  3157. this.right.y = a + d / 2
  3158. }
  3159. };
  3160. cc.UIInterfaceOrientationLandscapeLeft = -90;
  3161. cc.UIInterfaceOrientationLandscapeRight = 90;
  3162. cc.UIInterfaceOrientationPortraitUpsideDown = 180;
  3163. cc.UIInterfaceOrientationPortrait = 0;
  3164. cc.inputManager = {
  3165. _mousePressed: !1,
  3166. _isRegisterEvent: !1,
  3167. _preTouchPoint: cc.p(0, 0),
  3168. _prevMousePoint: cc.p(0, 0),
  3169. _preTouchPool: [],
  3170. _preTouchPoolPointer: 0,
  3171. _touches: [],
  3172. _touchesIntegerDict: {},
  3173. _indexBitsUsed: 0,
  3174. _maxTouches: 5,
  3175. _accelEnabled: !1,
  3176. _accelInterval: 1 / 30,
  3177. _accelMinus: 1,
  3178. _accelCurTime: 0,
  3179. _acceleration: null,
  3180. _accelDeviceEvent: null,
  3181. _getUnUsedIndex: function() {
  3182. for (var a = this._indexBitsUsed, c = 0; c < this._maxTouches; c++) {
  3183. if (!(a & 1)) return this._indexBitsUsed |= 1 << c, c;
  3184. a >>= 1
  3185. }
  3186. return -1
  3187. },
  3188. _removeUsedIndexBit: function(a) {
  3189. 0 > a || a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a)
  3190. },
  3191. _glView: null,
  3192. handleTouchesBegin: function(a) {
  3193. 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)));
  3194. 0 < f.length && (this._glView._convertTouchesWithScale(f), a = new cc.EventTouch(f), a._eventCode = cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a))
  3195. },
  3196. handleTouchesMove: function(a) {
  3197. 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]));
  3198. 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a))
  3199. },
  3200. handleTouchesEnd: function(a) {
  3201. a = this.getSetOfTouchesEndOrCancel(a);
  3202. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED, cc.eventManager.dispatchEvent(a))
  3203. },
  3204. handleTouchesCancel: function(a) {
  3205. a = this.getSetOfTouchesEndOrCancel(a);
  3206. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a))
  3207. },
  3208. getSetOfTouchesEndOrCancel: function(a) {
  3209. 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]);
  3210. return f
  3211. },
  3212. getHTMLElementPosition: function(a) {
  3213. var c = document.documentElement,
  3214. d = window,
  3215. e = null,
  3216. e = "function" === typeof a.getBoundingClientRect ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? {
  3217. left: 0,
  3218. top: 0,
  3219. width: a.width,
  3220. height: a.height
  3221. } : {
  3222. left: 0,
  3223. top: 0,
  3224. width: parseInt(a.style.width),
  3225. height: parseInt(a.style.height)
  3226. };
  3227. return {
  3228. left: e.left + d.pageXOffset - c.clientLeft,
  3229. top: e.top + d.pageYOffset - c.clientTop,
  3230. width: e.width,
  3231. height: e.height
  3232. }
  3233. },
  3234. getPreTouch: function(a) {
  3235. for (var c = null, d = this._preTouchPool, e = a.getId(), f = d.length - 1; 0 <= f; f--)
  3236. if (d[f].getId() == e) {
  3237. c = d[f];
  3238. break
  3239. }
  3240. c || (c = a);
  3241. return c
  3242. },
  3243. setPreTouch: function(a) {
  3244. for (var c = !1, d = this._preTouchPool, e = a.getId(), f = d.length - 1; 0 <= f; f--)
  3245. if (d[f].getId() == e) {
  3246. d[f] = a;
  3247. c = !0;
  3248. break
  3249. }
  3250. c || (50 >= d.length ? d.push(a) : (d[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50))
  3251. },
  3252. getTouchByXY: function(a, c, d) {
  3253. var e = this._preTouchPoint;
  3254. a = this._glView.convertToLocationInView(a, c, d);
  3255. c = new cc.Touch(a.x, a.y);
  3256. c._setPrevPoint(e.x, e.y);
  3257. e.x = a.x;
  3258. e.y = a.y;
  3259. return c
  3260. },
  3261. getMouseEvent: function(a, c, d) {
  3262. var e = this._prevMousePoint;
  3263. this._glView._convertMouseToLocationInView(a, c);
  3264. c = new cc.EventMouse(d);
  3265. c.setLocation(a.x, a.y);
  3266. c._setPrevCursor(e.x, e.y);
  3267. e.x = a.x;
  3268. e.y = a.y;
  3269. return c
  3270. },
  3271. getPointByEvent: function(a, c) {
  3272. if (null != a.pageX) return {
  3273. x: a.pageX,
  3274. y: a.pageY
  3275. };
  3276. c.left -= document.body.scrollLeft;
  3277. c.top -= document.body.scrollTop;
  3278. return {
  3279. x: a.clientX,
  3280. y: a.clientY
  3281. }
  3282. },
  3283. getTouchesByEvent: function(a, c) {
  3284. for (var d = [], e = this._glView, f, g, h = this._preTouchPoint, k = a.changedTouches.length, m = 0; m < k; m++)
  3285. if (f = a.changedTouches[m]) {
  3286. var n;
  3287. n = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? e.convertToLocationInView(f.pageX, f.pageY, c) : e.convertToLocationInView(f.clientX, f.clientY, c);
  3288. 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));
  3289. h.x = n.x;
  3290. h.y = n.y;
  3291. d.push(f)
  3292. }
  3293. return d
  3294. },
  3295. registerSystemEvent: function(a) {
  3296. if (!this._isRegisterEvent) {
  3297. var c = this._glView = cc.view,
  3298. d = this,
  3299. e = "touches" in cc.sys.capabilities;
  3300. "mouse" in cc.sys.capabilities && (cc._addEventListener(window, "mousedown", function() {
  3301. d._mousePressed = !0
  3302. }, !1), cc._addEventListener(window, "mouseup", function(c) {
  3303. var f = d._mousePressed;
  3304. d._mousePressed = !1;
  3305. if (f) {
  3306. var f = d.getHTMLElementPosition(a),
  3307. g = d.getPointByEvent(c, f);
  3308. 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))
  3309. }
  3310. }, !1), cc._addEventListener(a, "mousedown", function(c) {
  3311. d._mousePressed = !0;
  3312. var f = d.getHTMLElementPosition(a),
  3313. g = d.getPointByEvent(c, f);
  3314. e || d.handleTouchesBegin([d.getTouchByXY(g.x, g.y, f)]);
  3315. f = d.getMouseEvent(g, f, cc.EventMouse.DOWN);
  3316. f.setButton(c.button);
  3317. cc.eventManager.dispatchEvent(f);
  3318. c.stopPropagation();
  3319. c.preventDefault();
  3320. a.focus()
  3321. }, !1), cc._addEventListener(a, "mouseup", function(c) {
  3322. d._mousePressed = !1;
  3323. var f = d.getHTMLElementPosition(a),
  3324. g = d.getPointByEvent(c, f);
  3325. e || d.handleTouchesEnd([d.getTouchByXY(g.x, g.y, f)]);
  3326. f = d.getMouseEvent(g, f, cc.EventMouse.UP);
  3327. f.setButton(c.button);
  3328. cc.eventManager.dispatchEvent(f);
  3329. c.stopPropagation();
  3330. c.preventDefault()
  3331. }, !1), cc._addEventListener(a, "mousemove", function(c) {
  3332. var f = d.getHTMLElementPosition(a),
  3333. g = d.getPointByEvent(c, f);
  3334. e || d.handleTouchesMove([d.getTouchByXY(g.x, g.y, f)]);
  3335. f = d.getMouseEvent(g, f, cc.EventMouse.MOVE);
  3336. d._mousePressed ? f.setButton(c.button) : f.setButton(null);
  3337. cc.eventManager.dispatchEvent(f);
  3338. c.stopPropagation();
  3339. c.preventDefault()
  3340. }, !1), cc._addEventListener(a, "mousewheel", function(c) {
  3341. var e = d.getHTMLElementPosition(a),
  3342. f = d.getPointByEvent(c, e),
  3343. e = d.getMouseEvent(f, e, cc.EventMouse.SCROLL);
  3344. e.setButton(c.button);
  3345. e.setScrollData(0, c.wheelDelta);
  3346. cc.eventManager.dispatchEvent(e);
  3347. c.stopPropagation();
  3348. c.preventDefault()
  3349. }, !1), cc._addEventListener(a, "DOMMouseScroll", function(c) {
  3350. var e = d.getHTMLElementPosition(a),
  3351. f = d.getPointByEvent(c, e),
  3352. e = d.getMouseEvent(f, e, cc.EventMouse.SCROLL);
  3353. e.setButton(c.button);
  3354. e.setScrollData(0, -120 * c.detail);
  3355. cc.eventManager.dispatchEvent(e);
  3356. c.stopPropagation();
  3357. c.preventDefault()
  3358. }, !1));
  3359. if (window.navigator.msPointerEnabled) {
  3360. var f = {
  3361. MSPointerDown: d.handleTouchesBegin,
  3362. MSPointerMove: d.handleTouchesMove,
  3363. MSPointerUp: d.handleTouchesEnd,
  3364. MSPointerCancel: d.handleTouchesCancel
  3365. },
  3366. g;
  3367. for (g in f)(function(c, e) {
  3368. cc._addEventListener(a, c, function(c) {
  3369. var f = d.getHTMLElementPosition(a);
  3370. f.left -= document.documentElement.scrollLeft;
  3371. f.top -= document.documentElement.scrollTop;
  3372. e.call(d, [d.getTouchByXY(c.clientX, c.clientY, f)]);
  3373. c.stopPropagation()
  3374. }, !1)
  3375. })(g, f[g])
  3376. }
  3377. e && (cc._addEventListener(a, "touchstart", function(c) {
  3378. if (c.changedTouches) {
  3379. var e = d.getHTMLElementPosition(a);
  3380. e.left -= document.body.scrollLeft;
  3381. e.top -= document.body.scrollTop;
  3382. d.handleTouchesBegin(d.getTouchesByEvent(c, e));
  3383. c.stopPropagation();
  3384. c.preventDefault();
  3385. a.focus()
  3386. }
  3387. }, !1), cc._addEventListener(a, "touchmove", function(c) {
  3388. if (c.changedTouches) {
  3389. var e = d.getHTMLElementPosition(a);
  3390. e.left -= document.body.scrollLeft;
  3391. e.top -= document.body.scrollTop;
  3392. d.handleTouchesMove(d.getTouchesByEvent(c, e));
  3393. c.stopPropagation();
  3394. c.preventDefault()
  3395. }
  3396. }, !1), cc._addEventListener(a, "touchend", function(c) {
  3397. if (c.changedTouches) {
  3398. var e = d.getHTMLElementPosition(a);
  3399. e.left -= document.body.scrollLeft;
  3400. e.top -= document.body.scrollTop;
  3401. d.handleTouchesEnd(d.getTouchesByEvent(c, e));
  3402. c.stopPropagation();
  3403. c.preventDefault()
  3404. }
  3405. }, !1), cc._addEventListener(a, "touchcancel", function(e) {
  3406. if (e.changedTouches) {
  3407. var f = d.getHTMLElementPosition(a);
  3408. f.left -= document.body.scrollLeft;
  3409. f.top -= document.body.scrollTop;
  3410. c.handleTouchesCancel(d.getTouchesByEvent(e, f));
  3411. e.stopPropagation();
  3412. e.preventDefault()
  3413. }
  3414. }, !1));
  3415. this._registerKeyboardEvent();
  3416. this._registerAccelerometerEvent();
  3417. this._isRegisterEvent = !0
  3418. }
  3419. },
  3420. _registerKeyboardEvent: function() {},
  3421. _registerAccelerometerEvent: function() {},
  3422. update: function(a) {
  3423. this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));
  3424. this._accelCurTime += a
  3425. }
  3426. };
  3427. var _p = cc.inputManager;
  3428. _p.setAccelerometerEnabled = function(a) {
  3429. this._accelEnabled !== a && (this._accelEnabled = a, a = cc.director.getScheduler(), this._accelEnabled ? (this._accelCurTime = 0, a.scheduleUpdateForTarget(this)) : (this._accelCurTime = 0, a.unscheduleUpdateForTarget(this)))
  3430. };
  3431. _p.setAccelerometerInterval = function(a) {
  3432. this._accelInterval !== a && (this._accelInterval = a)
  3433. };
  3434. _p._registerKeyboardEvent = function() {
  3435. cc._addEventListener(cc._canvas, "keydown", function(a) {
  3436. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !0));
  3437. a.stopPropagation();
  3438. a.preventDefault()
  3439. }, !1);
  3440. cc._addEventListener(cc._canvas, "keyup", function(a) {
  3441. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !1));
  3442. a.stopPropagation();
  3443. a.preventDefault()
  3444. }, !1)
  3445. };
  3446. _p._registerAccelerometerEvent = function() {
  3447. var a = window;
  3448. this._acceleration = new cc.Acceleration;
  3449. this._accelDeviceEvent = a.DeviceMotionEvent || a.DeviceOrientationEvent;
  3450. cc.sys.browserType == cc.sys.BROWSER_TYPE_MOBILE_QQ && (this._accelDeviceEvent = window.DeviceOrientationEvent);
  3451. var c = this._accelDeviceEvent == a.DeviceMotionEvent ? "devicemotion" : "deviceorientation",
  3452. d = navigator.userAgent;
  3453. if (/Android/.test(d) || /Adr/.test(d) && cc.sys.browserType == cc.BROWSER_TYPE_UC) this._minus = -1;
  3454. cc._addEventListener(a, c, this.didAccelerate.bind(this), !1)
  3455. };
  3456. _p.didAccelerate = function(a) {
  3457. var c = window;
  3458. if (this._accelEnabled) {
  3459. var d = this._acceleration;
  3460. if (this._accelDeviceEvent == window.DeviceMotionEvent) {
  3461. var e = a.accelerationIncludingGravity;
  3462. d.x = 0.1 * this._accelMinus * e.x;
  3463. d.y = 0.1 * this._accelMinus * e.y;
  3464. d.z = 0.1 * e.z
  3465. } else d.x = 0.981 * (a.gamma / 90), d.y = 0.981 * -(a.beta / 90), d.z = 0.981 * (a.alpha / 90);
  3466. d.timestamp = a.timeStamp || Date.now();
  3467. a = d.x;
  3468. 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)
  3469. }
  3470. };
  3471. delete _p;
  3472. cc.AffineTransform = function(a, c, d, e, f, g) {
  3473. this.a = a;
  3474. this.b = c;
  3475. this.c = d;
  3476. this.d = e;
  3477. this.tx = f;
  3478. this.ty = g
  3479. };
  3480. cc.affineTransformMake = function(a, c, d, e, f, g) {
  3481. return {
  3482. a: a,
  3483. b: c,
  3484. c: d,
  3485. d: e,
  3486. tx: f,
  3487. ty: g
  3488. }
  3489. };
  3490. cc.pointApplyAffineTransform = function(a, c) {
  3491. return {
  3492. x: c.a * a.x + c.c * a.y + c.tx,
  3493. y: c.b * a.x + c.d * a.y + c.ty
  3494. }
  3495. };
  3496. cc._pointApplyAffineTransform = function(a, c, d) {
  3497. return {
  3498. x: d.a * a + d.c * c + d.tx,
  3499. y: d.b * a + d.d * c + d.ty
  3500. }
  3501. };
  3502. cc.sizeApplyAffineTransform = function(a, c) {
  3503. return {
  3504. width: c.a * a.width + c.c * a.height,
  3505. height: c.b * a.width + c.d * a.height
  3506. }
  3507. };
  3508. cc.affineTransformMakeIdentity = function() {
  3509. return {
  3510. a: 1,
  3511. b: 0,
  3512. c: 0,
  3513. d: 1,
  3514. tx: 0,
  3515. ty: 0
  3516. }
  3517. };
  3518. cc.affineTransformIdentity = function() {
  3519. return {
  3520. a: 1,
  3521. b: 0,
  3522. c: 0,
  3523. d: 1,
  3524. tx: 0,
  3525. ty: 0
  3526. }
  3527. };
  3528. cc.rectApplyAffineTransform = function(a, c) {
  3529. var d = cc.rectGetMinY(a),
  3530. e = cc.rectGetMinX(a),
  3531. f = cc.rectGetMaxX(a),
  3532. g = cc.rectGetMaxY(a),
  3533. h = cc._pointApplyAffineTransform(e, d, c),
  3534. d = cc._pointApplyAffineTransform(f, d, c),
  3535. e = cc._pointApplyAffineTransform(e, g, c),
  3536. k = cc._pointApplyAffineTransform(f, g, c),
  3537. f = Math.min(h.x, d.x, e.x, k.x),
  3538. g = Math.max(h.x, d.x, e.x, k.x),
  3539. m = Math.min(h.y, d.y, e.y, k.y),
  3540. h = Math.max(h.y, d.y, e.y, k.y);
  3541. return cc.rect(f, m, g - f, h - m)
  3542. };
  3543. cc._rectApplyAffineTransformIn = function(a, c) {
  3544. var d = cc.rectGetMinY(a),
  3545. e = cc.rectGetMinX(a),
  3546. f = cc.rectGetMaxX(a),
  3547. g = cc.rectGetMaxY(a),
  3548. h = cc._pointApplyAffineTransform(e, d, c),
  3549. d = cc._pointApplyAffineTransform(f, d, c),
  3550. e = cc._pointApplyAffineTransform(e, g, c),
  3551. k = cc._pointApplyAffineTransform(f, g, c),
  3552. f = Math.min(h.x, d.x, e.x, k.x),
  3553. g = Math.max(h.x, d.x, e.x, k.x),
  3554. m = Math.min(h.y, d.y, e.y, k.y),
  3555. h = Math.max(h.y, d.y, e.y, k.y);
  3556. a.x = f;
  3557. a.y = m;
  3558. a.width = g - f;
  3559. a.height = h - m;
  3560. return a
  3561. };
  3562. cc.affineTransformTranslate = function(a, c, d) {
  3563. return {
  3564. a: a.a,
  3565. b: a.b,
  3566. c: a.c,
  3567. d: a.d,
  3568. tx: a.tx + a.a * c + a.c * d,
  3569. ty: a.ty + a.b * c + a.d * d
  3570. }
  3571. };
  3572. cc.affineTransformScale = function(a, c, d) {
  3573. return {
  3574. a: a.a * c,
  3575. b: a.b * c,
  3576. c: a.c * d,
  3577. d: a.d * d,
  3578. tx: a.tx,
  3579. ty: a.ty
  3580. }
  3581. };
  3582. cc.affineTransformRotate = function(a, c) {
  3583. var d = Math.sin(c),
  3584. e = Math.cos(c);
  3585. return {
  3586. a: a.a * e + a.c * d,
  3587. b: a.b * e + a.d * d,
  3588. c: a.c * e - a.a * d,
  3589. d: a.d * e - a.b * d,
  3590. tx: a.tx,
  3591. ty: a.ty
  3592. }
  3593. };
  3594. cc.affineTransformConcat = function(a, c) {
  3595. return {
  3596. a: a.a * c.a + a.b * c.c,
  3597. b: a.a * c.b + a.b * c.d,
  3598. c: a.c * c.a + a.d * c.c,
  3599. d: a.c * c.b + a.d * c.d,
  3600. tx: a.tx * c.a + a.ty * c.c + c.tx,
  3601. ty: a.tx * c.b + a.ty * c.d + c.ty
  3602. }
  3603. };
  3604. cc.affineTransformEqualToTransform = function(a, c) {
  3605. 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
  3606. };
  3607. cc.affineTransformInvert = function(a) {
  3608. var c = 1 / (a.a * a.d - a.b * a.c);
  3609. return {
  3610. a: c * a.d,
  3611. b: -c * a.b,
  3612. c: -c * a.c,
  3613. d: c * a.a,
  3614. tx: c * (a.c * a.ty - a.d * a.tx),
  3615. ty: c * (a.b * a.tx - a.a * a.ty)
  3616. }
  3617. };
  3618. cc.POINT_EPSILON = parseFloat("1.192092896e-07F");
  3619. cc.pNeg = function(a) {
  3620. return cc.p(-a.x, -a.y)
  3621. };
  3622. cc.pAdd = function(a, c) {
  3623. return cc.p(a.x + c.x, a.y + c.y)
  3624. };
  3625. cc.pSub = function(a, c) {
  3626. return cc.p(a.x - c.x, a.y - c.y)
  3627. };
  3628. cc.pMult = function(a, c) {
  3629. return cc.p(a.x * c, a.y * c)
  3630. };
  3631. cc.pMidpoint = function(a, c) {
  3632. return cc.pMult(cc.pAdd(a, c), 0.5)
  3633. };
  3634. cc.pDot = function(a, c) {
  3635. return a.x * c.x + a.y * c.y
  3636. };
  3637. cc.pCross = function(a, c) {
  3638. return a.x * c.y - a.y * c.x
  3639. };
  3640. cc.pPerp = function(a) {
  3641. return cc.p(-a.y, a.x)
  3642. };
  3643. cc.pRPerp = function(a) {
  3644. return cc.p(a.y, -a.x)
  3645. };
  3646. cc.pProject = function(a, c) {
  3647. return cc.pMult(c, cc.pDot(a, c) / cc.pDot(c, c))
  3648. };
  3649. cc.pRotate = function(a, c) {
  3650. return cc.p(a.x * c.x - a.y * c.y, a.x * c.y + a.y * c.x)
  3651. };
  3652. cc.pUnrotate = function(a, c) {
  3653. return cc.p(a.x * c.x + a.y * c.y, a.y * c.x - a.x * c.y)
  3654. };
  3655. cc.pLengthSQ = function(a) {
  3656. return cc.pDot(a, a)
  3657. };
  3658. cc.pDistanceSQ = function(a, c) {
  3659. return cc.pLengthSQ(cc.pSub(a, c))
  3660. };
  3661. cc.pLength = function(a) {
  3662. return Math.sqrt(cc.pLengthSQ(a))
  3663. };
  3664. cc.pDistance = function(a, c) {
  3665. return cc.pLength(cc.pSub(a, c))
  3666. };
  3667. cc.pNormalize = function(a) {
  3668. return cc.pMult(a, 1 / cc.pLength(a))
  3669. };
  3670. cc.pForAngle = function(a) {
  3671. return cc.p(Math.cos(a), Math.sin(a))
  3672. };
  3673. cc.pToAngle = function(a) {
  3674. return Math.atan2(a.y, a.x)
  3675. };
  3676. cc.clampf = function(a, c, d) {
  3677. if (c > d) {
  3678. var e = c;
  3679. c = d;
  3680. d = e
  3681. }
  3682. return a < c ? c : a < d ? a : d
  3683. };
  3684. cc.pClamp = function(a, c, d) {
  3685. return cc.p(cc.clampf(a.x, c.x, d.x), cc.clampf(a.y, c.y, d.y))
  3686. };
  3687. cc.pFromSize = function(a) {
  3688. return cc.p(a.width, a.height)
  3689. };
  3690. cc.pCompOp = function(a, c) {
  3691. return cc.p(c(a.x), c(a.y))
  3692. };
  3693. cc.pLerp = function(a, c, d) {
  3694. return cc.pAdd(cc.pMult(a, 1 - d), cc.pMult(c, d))
  3695. };
  3696. cc.pFuzzyEqual = function(a, c, d) {
  3697. return a.x - d <= c.x && c.x <= a.x + d && a.y - d <= c.y && c.y <= a.y + d ? !0 : !1
  3698. };
  3699. cc.pCompMult = function(a, c) {
  3700. return cc.p(a.x * c.x, a.y * c.y)
  3701. };
  3702. cc.pAngleSigned = function(a, c) {
  3703. var d = cc.pNormalize(a),
  3704. e = cc.pNormalize(c),
  3705. d = Math.atan2(d.x * e.y - d.y * e.x, cc.pDot(d, e));
  3706. return Math.abs(d) < cc.POINT_EPSILON ? 0 : d
  3707. };
  3708. cc.pAngle = function(a, c) {
  3709. var d = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(c)));
  3710. return Math.abs(d) < cc.POINT_EPSILON ? 0 : d
  3711. };
  3712. cc.pRotateByAngle = function(a, c, d) {
  3713. a = cc.pSub(a, c);
  3714. var e = Math.cos(d);
  3715. d = Math.sin(d);
  3716. var f = a.x;
  3717. a.x = f * e - a.y * d + c.x;
  3718. a.y = f * d + a.y * e + c.y;
  3719. return a
  3720. };
  3721. cc.pLineIntersect = function(a, c, d, e, f) {
  3722. if (a.x == c.x && a.y == c.y || d.x == e.x && d.y == e.y) return !1;
  3723. var g = c.x - a.x;
  3724. c = c.y - a.y;
  3725. var h = e.x - d.x;
  3726. e = e.y - d.y;
  3727. var k = a.x - d.x;
  3728. a = a.y - d.y;
  3729. d = e * g - h * c;
  3730. f.x = h * a - e * k;
  3731. f.y = g * a - c * k;
  3732. if (0 == d) return 0 == f.x || 0 == f.y ? !0 : !1;
  3733. f.x /= d;
  3734. f.y /= d;
  3735. return !0
  3736. };
  3737. cc.pSegmentIntersect = function(a, c, d, e) {
  3738. var f = cc.p(0, 0);
  3739. return cc.pLineIntersect(a, c, d, e, f) && 0 <= f.x && 1 >= f.x && 0 <= f.y && 1 >= f.y ? !0 : !1
  3740. };
  3741. cc.pIntersectPoint = function(a, c, d, e) {
  3742. var f = cc.p(0, 0);
  3743. 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)
  3744. };
  3745. cc.pSameAs = function(a, c) {
  3746. return null != a && null != c ? a.x == c.x && a.y == c.y : !1
  3747. };
  3748. cc.pZeroIn = function(a) {
  3749. a.x = 0;
  3750. a.y = 0
  3751. };
  3752. cc.pIn = function(a, c) {
  3753. a.x = c.x;
  3754. a.y = c.y
  3755. };
  3756. cc.pMultIn = function(a, c) {
  3757. a.x *= c;
  3758. a.y *= c
  3759. };
  3760. cc.pSubIn = function(a, c) {
  3761. a.x -= c.x;
  3762. a.y -= c.y
  3763. };
  3764. cc.pAddIn = function(a, c) {
  3765. a.x += c.x;
  3766. a.y += c.y
  3767. };
  3768. cc.pNormalizeIn = function(a) {
  3769. cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y))
  3770. };
  3771. cc.vertexLineToPolygon = function(a, c, d, e, f) {
  3772. f += e;
  3773. if (!(1 >= f)) {
  3774. c *= 0.5;
  3775. for (var g, h = f - 1, k = e; k < f; k++) {
  3776. g = 2 * k;
  3777. var m = cc.p(a[2 * k], a[2 * k + 1]),
  3778. n;
  3779. if (0 === k) n = cc.pPerp(cc.pNormalize(cc.pSub(m, cc.p(a[2 * (k + 1)], a[2 * (k + 1) + 1]))));
  3780. else if (k === h) n = cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2 * (k - 1)], a[2 * (k - 1) + 1]), m)));
  3781. else {
  3782. n = cc.p(a[2 * (k - 1)], a[2 * (k - 1) + 1]);
  3783. var q = cc.p(a[2 * (k + 1)], a[2 * (k + 1) + 1]),
  3784. r = cc.pNormalize(cc.pSub(q, m)),
  3785. t = cc.pNormalize(cc.pSub(n, m)),
  3786. s = Math.acos(cc.pDot(r, t));
  3787. 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)))
  3788. }
  3789. n = cc.pMult(n, c);
  3790. d[2 * g] = m.x + n.x;
  3791. d[2 * g + 1] = m.y + n.y;
  3792. d[2 * (g + 1)] = m.x - n.x;
  3793. d[2 * (g + 1) + 1] = m.y - n.y
  3794. }
  3795. for (k = 0 == e ? 0 : e - 1; k < h; k++) {
  3796. g = 2 * k;
  3797. a = g + 2;
  3798. c = cc.vertex2(d[2 * g], d[2 * g + 1]);
  3799. f = cc.vertex2(d[2 * (g + 1)], d[2 * (g + 1) + 1]);
  3800. g = cc.vertex2(d[2 * a], d[2 * a]);
  3801. e = cc.vertex2(d[2 * (a + 1)], d[2 * (a + 1) + 1]);
  3802. c = !cc.vertexLineIntersect(c.x, c.y, e.x, e.y, f.x, f.y, g.x, g.y);
  3803. if (!c.isSuccess && (0 > c.value || 1 < c.value)) c.isSuccess = !0;
  3804. 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)
  3805. }
  3806. }
  3807. };
  3808. cc.vertexLineIntersect = function(a, c, d, e, f, g, h, k) {
  3809. if (a == d && c == e || f == h && g == k) return {
  3810. isSuccess: !1,
  3811. value: 0
  3812. };
  3813. d -= a;
  3814. e -= c;
  3815. f -= a;
  3816. g -= c;
  3817. h -= a;
  3818. k -= c;
  3819. a = Math.sqrt(d * d + e * e);
  3820. d /= a;
  3821. e /= a;
  3822. c = f * d + g * e;
  3823. g = g * d - f * e;
  3824. f = c;
  3825. c = h * d + k * e;
  3826. k = k * d - h * e;
  3827. h = c;
  3828. return g == k ? {
  3829. isSuccess: !1,
  3830. value: 0
  3831. } : {
  3832. isSuccess: !0,
  3833. value: (h + (f - h) * k / (k - g)) / a
  3834. }
  3835. };
  3836. cc.vertexListIsClockwise = function(a) {
  3837. for (var c = 0, d = a.length; c < d; c++) {
  3838. var e = a[(c + 1) % d],
  3839. f = a[(c + 2) % d];
  3840. if (0 < cc.pCross(cc.pSub(e, a[c]), cc.pSub(f, e))) return !1
  3841. }
  3842. return !0
  3843. };
  3844. cc.CGAffineToGL = function(a, c) {
  3845. c[2] = c[3] = c[6] = c[7] = c[8] = c[9] = c[11] = c[14] = 0;
  3846. c[10] = c[15] = 1;
  3847. c[0] = a.a;
  3848. c[4] = a.c;
  3849. c[12] = a.tx;
  3850. c[1] = a.b;
  3851. c[5] = a.d;
  3852. c[13] = a.ty
  3853. };
  3854. cc.GLToCGAffine = function(a, c) {
  3855. c.a = a[0];
  3856. c.c = a[4];
  3857. c.tx = a[12];
  3858. c.b = a[1];
  3859. c.d = a[5];
  3860. c.ty = a[13]
  3861. };
  3862. cc.Touch = cc.Class.extend({
  3863. _point: null,
  3864. _prevPoint: null,
  3865. _id: 0,
  3866. _startPointCaptured: !1,
  3867. _startPoint: null,
  3868. ctor: function(a, c, d) {
  3869. this._point = cc.p(a || 0, c || 0);
  3870. this._id = d || 0
  3871. },
  3872. getLocation: function() {
  3873. return {
  3874. x: this._point.x,
  3875. y: this._point.y
  3876. }
  3877. },
  3878. getLocationX: function() {
  3879. return this._point.x
  3880. },
  3881. getLocationY: function() {
  3882. return this._point.y
  3883. },
  3884. getPreviousLocation: function() {
  3885. return {
  3886. x: this._prevPoint.x,
  3887. y: this._prevPoint.y
  3888. }
  3889. },
  3890. getStartLocation: function() {
  3891. return {
  3892. x: this._startPoint.x,
  3893. y: this._startPoint.y
  3894. }
  3895. },
  3896. getDelta: function() {
  3897. return cc.pSub(this._point, this._prevPoint)
  3898. },
  3899. getLocationInView: function() {
  3900. return {
  3901. x: this._point.x,
  3902. y: this._point.y
  3903. }
  3904. },
  3905. getPreviousLocationInView: function() {
  3906. return {
  3907. x: this._prevPoint.x,
  3908. y: this._prevPoint.y
  3909. }
  3910. },
  3911. getStartLocationInView: function() {
  3912. return {
  3913. x: this._startPoint.x,
  3914. y: this._startPoint.y
  3915. }
  3916. },
  3917. getID: function() {
  3918. return this._id
  3919. },
  3920. getId: function() {
  3921. return this._id
  3922. },
  3923. setTouchInfo: function(a, c, d) {
  3924. this._prevPoint = this._point;
  3925. this._point = cc.p(c || 0, d || 0);
  3926. this._id = a;
  3927. this._startPointCaptured || (this._startPoint = cc.p(this._point), this._startPointCaptured = !0)
  3928. },
  3929. _setPoint: function(a, c) {
  3930. void 0 === c ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = c)
  3931. },
  3932. _setPrevPoint: function(a, c) {
  3933. this._prevPoint = void 0 === c ? cc.p(a.x, a.y) : cc.p(a || 0, c || 0)
  3934. }
  3935. });
  3936. cc.Event = cc.Class.extend({
  3937. _type: 0,
  3938. _isStopped: !1,
  3939. _currentTarget: null,
  3940. _setCurrentTarget: function(a) {
  3941. this._currentTarget = a
  3942. },
  3943. ctor: function(a) {
  3944. this._type = a
  3945. },
  3946. getType: function() {
  3947. return this._type
  3948. },
  3949. stopPropagation: function() {
  3950. this._isStopped = !0
  3951. },
  3952. isStopped: function() {
  3953. return this._isStopped
  3954. },
  3955. getCurrentTarget: function() {
  3956. return this._currentTarget
  3957. }
  3958. });
  3959. cc.Event.TOUCH = 0;
  3960. cc.Event.KEYBOARD = 1;
  3961. cc.Event.ACCELERATION = 2;
  3962. cc.Event.MOUSE = 3;
  3963. cc.Event.CUSTOM = 4;
  3964. cc.EventCustom = cc.Event.extend({
  3965. _eventName: null,
  3966. _userData: null,
  3967. ctor: function(a) {
  3968. cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM);
  3969. this._eventName = a
  3970. },
  3971. setUserData: function(a) {
  3972. this._userData = a
  3973. },
  3974. getUserData: function() {
  3975. return this._userData
  3976. },
  3977. getEventName: function() {
  3978. return this._eventName
  3979. }
  3980. });
  3981. cc.EventMouse = cc.Event.extend({
  3982. _eventType: 0,
  3983. _button: 0,
  3984. _x: 0,
  3985. _y: 0,
  3986. _prevX: 0,
  3987. _prevY: 0,
  3988. _scrollX: 0,
  3989. _scrollY: 0,
  3990. ctor: function(a) {
  3991. cc.Event.prototype.ctor.call(this, cc.Event.MOUSE);
  3992. this._eventType = a
  3993. },
  3994. setScrollData: function(a, c) {
  3995. this._scrollX = a;
  3996. this._scrollY = c
  3997. },
  3998. getScrollX: function() {
  3999. return this._scrollX
  4000. },
  4001. getScrollY: function() {
  4002. return this._scrollY
  4003. },
  4004. setLocation: function(a, c) {
  4005. this._x = a;
  4006. this._y = c
  4007. },
  4008. getLocation: function() {
  4009. return {
  4010. x: this._x,
  4011. y: this._y
  4012. }
  4013. },
  4014. getLocationInView: function() {
  4015. return {
  4016. x: this._x,
  4017. y: cc.view._designResolutionSize.height - this._y
  4018. }
  4019. },
  4020. _setPrevCursor: function(a, c) {
  4021. this._prevX = a;
  4022. this._prevY = c
  4023. },
  4024. getDelta: function() {
  4025. return {
  4026. x: this._x - this._prevX,
  4027. y: this._y - this._prevY
  4028. }
  4029. },
  4030. getDeltaX: function() {
  4031. return this._x - this._prevX
  4032. },
  4033. getDeltaY: function() {
  4034. return this._y - this._prevY
  4035. },
  4036. setButton: function(a) {
  4037. this._button = a
  4038. },
  4039. getButton: function() {
  4040. return this._button
  4041. },
  4042. getLocationX: function() {
  4043. return this._x
  4044. },
  4045. getLocationY: function() {
  4046. return this._y
  4047. }
  4048. });
  4049. cc.EventMouse.NONE = 0;
  4050. cc.EventMouse.DOWN = 1;
  4051. cc.EventMouse.UP = 2;
  4052. cc.EventMouse.MOVE = 3;
  4053. cc.EventMouse.SCROLL = 4;
  4054. cc.EventMouse.BUTTON_LEFT = 0;
  4055. cc.EventMouse.BUTTON_RIGHT = 2;
  4056. cc.EventMouse.BUTTON_MIDDLE = 1;
  4057. cc.EventMouse.BUTTON_4 = 3;
  4058. cc.EventMouse.BUTTON_5 = 4;
  4059. cc.EventMouse.BUTTON_6 = 5;
  4060. cc.EventMouse.BUTTON_7 = 6;
  4061. cc.EventMouse.BUTTON_8 = 7;
  4062. cc.EventTouch = cc.Event.extend({
  4063. _eventCode: 0,
  4064. _touches: null,
  4065. ctor: function(a) {
  4066. cc.Event.prototype.ctor.call(this, cc.Event.TOUCH);
  4067. this._touches = a || []
  4068. },
  4069. getEventCode: function() {
  4070. return this._eventCode
  4071. },
  4072. getTouches: function() {
  4073. return this._touches
  4074. },
  4075. _setEventCode: function(a) {
  4076. this._eventCode = a
  4077. },
  4078. _setTouches: function(a) {
  4079. this._touches = a
  4080. }
  4081. });
  4082. cc.EventTouch.MAX_TOUCHES = 5;
  4083. cc.EventTouch.EventCode = {
  4084. BEGAN: 0,
  4085. MOVED: 1,
  4086. ENDED: 2,
  4087. CANCELLED: 3
  4088. };
  4089. cc.EventListener = cc.Class.extend({
  4090. _onEvent: null,
  4091. _type: 0,
  4092. _listenerID: null,
  4093. _registered: !1,
  4094. _fixedPriority: 0,
  4095. _node: null,
  4096. _paused: !1,
  4097. _isEnabled: !0,
  4098. ctor: function(a, c, d) {
  4099. this._onEvent = d;
  4100. this._type = a || 0;
  4101. this._listenerID = c || ""
  4102. },
  4103. _setPaused: function(a) {
  4104. this._paused = a
  4105. },
  4106. _isPaused: function() {
  4107. return this._paused
  4108. },
  4109. _setRegistered: function(a) {
  4110. this._registered = a
  4111. },
  4112. _isRegistered: function() {
  4113. return this._registered
  4114. },
  4115. _getType: function() {
  4116. return this._type
  4117. },
  4118. _getListenerID: function() {
  4119. return this._listenerID
  4120. },
  4121. _setFixedPriority: function(a) {
  4122. this._fixedPriority = a
  4123. },
  4124. _getFixedPriority: function() {
  4125. return this._fixedPriority
  4126. },
  4127. _setSceneGraphPriority: function(a) {
  4128. this._node = a
  4129. },
  4130. _getSceneGraphPriority: function() {
  4131. return this._node
  4132. },
  4133. checkAvailable: function() {
  4134. return null != this._onEvent
  4135. },
  4136. clone: function() {
  4137. return null
  4138. },
  4139. setEnabled: function(a) {
  4140. this._isEnabled = a
  4141. },
  4142. isEnabled: function() {
  4143. return this._isEnabled
  4144. },
  4145. retain: function() {},
  4146. release: function() {}
  4147. });
  4148. cc.EventListener.UNKNOWN = 0;
  4149. cc.EventListener.TOUCH_ONE_BY_ONE = 1;
  4150. cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
  4151. cc.EventListener.KEYBOARD = 3;
  4152. cc.EventListener.MOUSE = 4;
  4153. cc.EventListener.ACCELERATION = 5;
  4154. cc.EventListener.CUSTOM = 6;
  4155. cc._EventListenerCustom = cc.EventListener.extend({
  4156. _onCustomEvent: null,
  4157. ctor: function(a, c) {
  4158. this._onCustomEvent = c;
  4159. var d = this;
  4160. cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a, function(a) {
  4161. null != d._onCustomEvent && d._onCustomEvent(a)
  4162. })
  4163. },
  4164. checkAvailable: function() {
  4165. return cc.EventListener.prototype.checkAvailable.call(this) && null != this._onCustomEvent
  4166. },
  4167. clone: function() {
  4168. return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent)
  4169. }
  4170. });
  4171. cc._EventListenerCustom.create = function(a, c) {
  4172. return new cc._EventListenerCustom(a, c)
  4173. };
  4174. cc._EventListenerMouse = cc.EventListener.extend({
  4175. onMouseDown: null,
  4176. onMouseUp: null,
  4177. onMouseMove: null,
  4178. onMouseScroll: null,
  4179. ctor: function() {
  4180. var a = this;
  4181. cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID, function(c) {
  4182. var d = cc.EventMouse;
  4183. switch (c._eventType) {
  4184. case d.DOWN:
  4185. if (a.onMouseDown) a.onMouseDown(c);
  4186. break;
  4187. case d.UP:
  4188. if (a.onMouseUp) a.onMouseUp(c);
  4189. break;
  4190. case d.MOVE:
  4191. if (a.onMouseMove) a.onMouseMove(c);
  4192. break;
  4193. case d.SCROLL:
  4194. if (a.onMouseScroll) a.onMouseScroll(c)
  4195. }
  4196. })
  4197. },
  4198. clone: function() {
  4199. var a = new cc._EventListenerMouse;
  4200. a.onMouseDown = this.onMouseDown;
  4201. a.onMouseUp = this.onMouseUp;
  4202. a.onMouseMove = this.onMouseMove;
  4203. a.onMouseScroll = this.onMouseScroll;
  4204. return a
  4205. },
  4206. checkAvailable: function() {
  4207. return !0
  4208. }
  4209. });
  4210. cc._EventListenerMouse.LISTENER_ID = "__cc_mouse";
  4211. cc._EventListenerMouse.create = function() {
  4212. return new cc._EventListenerMouse
  4213. };
  4214. cc._EventListenerTouchOneByOne = cc.EventListener.extend({
  4215. _claimedTouches: null,
  4216. swallowTouches: !1,
  4217. onTouchBegan: null,
  4218. onTouchMoved: null,
  4219. onTouchEnded: null,
  4220. onTouchCancelled: null,
  4221. ctor: function() {
  4222. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null);
  4223. this._claimedTouches = []
  4224. },
  4225. setSwallowTouches: function(a) {
  4226. this.swallowTouches = a
  4227. },
  4228. clone: function() {
  4229. var a = new cc._EventListenerTouchOneByOne;
  4230. a.onTouchBegan = this.onTouchBegan;
  4231. a.onTouchMoved = this.onTouchMoved;
  4232. a.onTouchEnded = this.onTouchEnded;
  4233. a.onTouchCancelled = this.onTouchCancelled;
  4234. a.swallowTouches = this.swallowTouches;
  4235. return a
  4236. },
  4237. checkAvailable: function() {
  4238. return !this.onTouchBegan ? (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1) : !0
  4239. }
  4240. });
  4241. cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one";
  4242. cc._EventListenerTouchOneByOne.create = function() {
  4243. return new cc._EventListenerTouchOneByOne
  4244. };
  4245. cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({
  4246. onTouchesBegan: null,
  4247. onTouchesMoved: null,
  4248. onTouchesEnded: null,
  4249. onTouchesCancelled: null,
  4250. ctor: function() {
  4251. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null)
  4252. },
  4253. clone: function() {
  4254. var a = new cc._EventListenerTouchAllAtOnce;
  4255. a.onTouchesBegan = this.onTouchesBegan;
  4256. a.onTouchesMoved = this.onTouchesMoved;
  4257. a.onTouchesEnded = this.onTouchesEnded;
  4258. a.onTouchesCancelled = this.onTouchesCancelled;
  4259. return a
  4260. },
  4261. checkAvailable: function() {
  4262. return null == this.onTouchesBegan && null == this.onTouchesMoved && null == this.onTouchesEnded && null == this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0
  4263. }
  4264. });
  4265. cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
  4266. cc._EventListenerTouchAllAtOnce.create = function() {
  4267. return new cc._EventListenerTouchAllAtOnce
  4268. };
  4269. cc.EventListener.create = function(a) {
  4270. cc.assert(a && a.event, cc._LogInfos.EventListener_create);
  4271. var c = a.event;
  4272. delete a.event;
  4273. var d = null;
  4274. 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);
  4275. for (var e in a) d[e] = a[e];
  4276. return d
  4277. };
  4278. cc.copyArray = function(a) {
  4279. var c, d = a.length,
  4280. e = Array(d);
  4281. for (c = 0; c < d; c += 1) e[c] = a[c];
  4282. return e
  4283. };
  4284. cc._EventListenerVector = cc.Class.extend({
  4285. _fixedListeners: null,
  4286. _sceneGraphListeners: null,
  4287. gt0Index: 0,
  4288. ctor: function() {
  4289. this._fixedListeners = [];
  4290. this._sceneGraphListeners = []
  4291. },
  4292. size: function() {
  4293. return this._fixedListeners.length + this._sceneGraphListeners.length
  4294. },
  4295. empty: function() {
  4296. return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length
  4297. },
  4298. push: function(a) {
  4299. 0 == a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a)
  4300. },
  4301. clearSceneGraphListeners: function() {
  4302. this._sceneGraphListeners.length = 0
  4303. },
  4304. clearFixedListeners: function() {
  4305. this._fixedListeners.length = 0
  4306. },
  4307. clear: function() {
  4308. this._sceneGraphListeners.length = 0;
  4309. this._fixedListeners.length = 0
  4310. },
  4311. getFixedPriorityListeners: function() {
  4312. return this._fixedListeners
  4313. },
  4314. getSceneGraphPriorityListeners: function() {
  4315. return this._sceneGraphListeners
  4316. }
  4317. });
  4318. cc.__getListenerID = function(a) {
  4319. var c = cc.Event,
  4320. d = a.getType();
  4321. if (d === c.ACCELERATION) return cc._EventListenerAcceleration.LISTENER_ID;
  4322. if (d === c.CUSTOM) return a.getEventName();
  4323. if (d === c.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID;
  4324. if (d === c.MOUSE) return cc._EventListenerMouse.LISTENER_ID;
  4325. d === c.TOUCH && cc.log(cc._LogInfos.__getListenerID);
  4326. return ""
  4327. };
  4328. cc.eventManager = {
  4329. DIRTY_NONE: 0,
  4330. DIRTY_FIXED_PRIORITY: 1,
  4331. DIRTY_SCENE_GRAPH_PRIORITY: 2,
  4332. DIRTY_ALL: 3,
  4333. _listenersMap: {},
  4334. _priorityDirtyFlagMap: {},
  4335. _nodeListenersMap: {},
  4336. _nodePriorityMap: {},
  4337. _globalZOrderNodeMap: {},
  4338. _toAddedListeners: [],
  4339. _dirtyNodes: [],
  4340. _inDispatch: 0,
  4341. _isEnabled: !1,
  4342. _nodePriorityIndex: 0,
  4343. _internalCustomListenerIDs: [cc.game.EVENT_HIDE, cc.game.EVENT_SHOW],
  4344. _setDirtyForNode: function(a) {
  4345. null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a);
  4346. a = a.getChildren();
  4347. for (var c = 0, d = a.length; c < d; c++) this._setDirtyForNode(a[c])
  4348. },
  4349. pauseTarget: function(a, c) {
  4350. var d = this._nodeListenersMap[a.__instanceId],
  4351. e, f;
  4352. if (d) {
  4353. e = 0;
  4354. for (f = d.length; e < f; e++) d[e]._setPaused(!0)
  4355. }
  4356. if (!0 === c) {
  4357. d = a.getChildren();
  4358. e = 0;
  4359. for (f = d.length; e < f; e++) this.pauseTarget(d[e], !0)
  4360. }
  4361. },
  4362. resumeTarget: function(a, c) {
  4363. var d = this._nodeListenersMap[a.__instanceId],
  4364. e, f;
  4365. if (d) {
  4366. e = 0;
  4367. for (f = d.length; e < f; e++) d[e]._setPaused(!1)
  4368. }
  4369. this._setDirtyForNode(a);
  4370. if (!0 === c) {
  4371. d = a.getChildren();
  4372. e = 0;
  4373. for (f = d.length; e < f; e++) this.resumeTarget(d[e], !0)
  4374. }
  4375. },
  4376. _addListener: function(a) {
  4377. 0 === this._inDispatch ? this._forceAddEventListener(a) : this._toAddedListeners.push(a)
  4378. },
  4379. _forceAddEventListener: function(a) {
  4380. var c = a._getListenerID(),
  4381. d = this._listenersMap[c];
  4382. d || (d = new cc._EventListenerVector, this._listenersMap[c] = d);
  4383. d.push(a);
  4384. 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)
  4385. },
  4386. _getListeners: function(a) {
  4387. return this._listenersMap[a]
  4388. },
  4389. _updateDirtyFlagForSceneGraph: function() {
  4390. if (0 != this._dirtyNodes.length) {
  4391. for (var a = this._dirtyNodes, c, d, e = this._nodeListenersMap, f = 0, g = a.length; f < g; f++)
  4392. if (c = e[a[f].__instanceId])
  4393. for (var h = 0, k = c.length; h < k; h++)(d = c[h]) && this._setDirty(d._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
  4394. this._dirtyNodes.length = 0
  4395. }
  4396. },
  4397. _removeAllListenersInVector: function(a) {
  4398. if (a)
  4399. 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
  4400. },
  4401. _removeListenersForListenerID: function(a) {
  4402. var c = this._listenersMap[a];
  4403. if (c) {
  4404. var d = c.getFixedPriorityListeners(),
  4405. e = c.getSceneGraphPriorityListeners();
  4406. this._removeAllListenersInVector(e);
  4407. this._removeAllListenersInVector(d);
  4408. delete this._priorityDirtyFlagMap[a];
  4409. this._inDispatch || (c.clear(), delete this._listenersMap[a])
  4410. }
  4411. d = this._toAddedListeners;
  4412. for (c = 0; c < d.length;)(e = d[c]) && e._getListenerID() == a ? cc.arrayRemoveObject(d, e) : ++c
  4413. },
  4414. _sortEventListeners: function(a) {
  4415. var c = this.DIRTY_NONE,
  4416. d = this._priorityDirtyFlagMap;
  4417. d[a] && (c = d[a]);
  4418. 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))
  4419. },
  4420. _sortListenersOfSceneGraphPriority: function(a, c) {
  4421. var d = this._getListeners(a);
  4422. if (d) {
  4423. var e = d.getSceneGraphPriorityListeners();
  4424. e && 0 !== e.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {}, this._visitTarget(c, !0), d.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))
  4425. }
  4426. },
  4427. _sortEventListenersOfSceneGraphPriorityDes: function(a, c) {
  4428. var d = cc.eventManager._nodePriorityMap;
  4429. return d[c._getSceneGraphPriority().__instanceId] - d[a._getSceneGraphPriority().__instanceId]
  4430. },
  4431. _sortListenersOfFixedPriority: function(a) {
  4432. if (a = this._listenersMap[a]) {
  4433. var c = a.getFixedPriorityListeners();
  4434. if (c && 0 !== c.length) {
  4435. c.sort(this._sortListenersOfFixedPriorityAsc);
  4436. for (var d = 0, e = c.length; d < e && !(0 <= c[d]._getFixedPriority());)++d;
  4437. a.gt0Index = d
  4438. }
  4439. }
  4440. },
  4441. _sortListenersOfFixedPriorityAsc: function(a, c) {
  4442. return a._getFixedPriority() - c._getFixedPriority()
  4443. },
  4444. _onUpdateListeners: function(a) {
  4445. if (a = this._listenersMap[a]) {
  4446. var c = a.getFixedPriorityListeners(),
  4447. d = a.getSceneGraphPriorityListeners(),
  4448. e, f;
  4449. if (d)
  4450. for (e = 0; e < d.length;) f = d[e], f._isRegistered() ? ++e : cc.arrayRemoveObject(d, f);
  4451. if (c)
  4452. for (e = 0; e < c.length;) f = c[e], f._isRegistered() ? ++e : cc.arrayRemoveObject(c, f);
  4453. d && 0 === d.length && a.clearSceneGraphListeners();
  4454. c && 0 === c.length && a.clearFixedListeners()
  4455. }
  4456. },
  4457. _updateListeners: function(a) {
  4458. var c = this._inDispatch;
  4459. cc.assert(0 < c, cc._LogInfos.EventManager__updateListeners);
  4460. a.getType() == cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a));
  4461. if (!(1 < c)) {
  4462. cc.assert(1 == c, cc._LogInfos.EventManager__updateListeners_2);
  4463. a = this._listenersMap;
  4464. var c = this._priorityDirtyFlagMap,
  4465. d;
  4466. for (d in a) a[d].empty() && (delete c[d], delete a[d]);
  4467. d = this._toAddedListeners;
  4468. if (0 !== d.length) {
  4469. a = 0;
  4470. for (c = d.length; a < c; a++) this._forceAddEventListener(d[a]);
  4471. this._toAddedListeners.length = 0
  4472. }
  4473. }
  4474. },
  4475. _onTouchEventCallback: function(a, c) {
  4476. if (!a._isRegistered) return !1;
  4477. var d = c.event,
  4478. e = c.selTouch;
  4479. d._setCurrentTarget(a._node);
  4480. var f = !1,
  4481. g, h = d.getEventCode(),
  4482. k = cc.EventTouch.EventCode;
  4483. if (h == k.BEGAN) a.onTouchBegan && (f = a.onTouchBegan(e, d)) && a._registered && a._claimedTouches.push(e);
  4484. else if (0 < a._claimedTouches.length && -1 != (g = a._claimedTouches.indexOf(e)))
  4485. if (f = !0, h === k.MOVED && a.onTouchMoved) a.onTouchMoved(e, d);
  4486. else if (h === k.ENDED) {
  4487. if (a.onTouchEnded) a.onTouchEnded(e, d);
  4488. a._registered && a._claimedTouches.splice(g, 1)
  4489. } else if (h === k.CANCELLED) {
  4490. if (a.onTouchCancelled) a.onTouchCancelled(e, d);
  4491. a._registered && a._claimedTouches.splice(g, 1)
  4492. }
  4493. return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : f && a._registered && a.swallowTouches ? (c.needsMutableSet && c.touches.splice(e, 1), !0) : !1
  4494. },
  4495. _dispatchTouchEvent: function(a) {
  4496. this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);
  4497. this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4498. var c = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),
  4499. d = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4500. if (!(null == c && null == d)) {
  4501. var e = a.getTouches(),
  4502. f = cc.copyArray(e),
  4503. g = {
  4504. event: a,
  4505. needsMutableSet: c && d,
  4506. touches: f,
  4507. selTouch: null
  4508. };
  4509. if (c)
  4510. for (var h = 0; h < e.length; h++)
  4511. if (g.selTouch = e[h], this._dispatchEventToListeners(c, this._onTouchEventCallback, g), a.isStopped()) return;
  4512. if (d && 0 < f.length && (this._dispatchEventToListeners(d, this._onTouchesEventCallback, {
  4513. event: a,
  4514. touches: f
  4515. }), a.isStopped())) return;
  4516. this._updateListeners(a)
  4517. }
  4518. },
  4519. _onTouchesEventCallback: function(a, c) {
  4520. if (!a._registered) return !1;
  4521. var d = cc.EventTouch.EventCode,
  4522. e = c.event,
  4523. f = c.touches,
  4524. g = e.getEventCode();
  4525. e._setCurrentTarget(a._node);
  4526. if (g == d.BEGAN && a.onTouchesBegan) a.onTouchesBegan(f, e);
  4527. else if (g == d.MOVED && a.onTouchesMoved) a.onTouchesMoved(f, e);
  4528. else if (g == d.ENDED && a.onTouchesEnded) a.onTouchesEnded(f, e);
  4529. else if (g == d.CANCELLED && a.onTouchesCancelled) a.onTouchesCancelled(f, e);
  4530. return e.isStopped() ? (cc.eventManager._updateListeners(e), !0) : !1
  4531. },
  4532. _associateNodeAndEventListener: function(a, c) {
  4533. var d = this._nodeListenersMap[a.__instanceId];
  4534. d || (d = [], this._nodeListenersMap[a.__instanceId] = d);
  4535. d.push(c)
  4536. },
  4537. _dissociateNodeAndEventListener: function(a, c) {
  4538. var d = this._nodeListenersMap[a.__instanceId];
  4539. d && (cc.arrayRemoveObject(d, c), 0 === d.length && delete this._nodeListenersMap[a.__instanceId])
  4540. },
  4541. _dispatchEventToListeners: function(a, c, d) {
  4542. var e = !1,
  4543. f = a.getFixedPriorityListeners(),
  4544. g = a.getSceneGraphPriorityListeners(),
  4545. h = 0,
  4546. k;
  4547. if (f && 0 !== f.length)
  4548. for (; h < a.gt0Index; ++h)
  4549. if (k = f[h], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)) {
  4550. e = !0;
  4551. break
  4552. }
  4553. if (g && !e)
  4554. for (a = 0; a < g.length; a++)
  4555. if (k = g[a], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)) {
  4556. e = !0;
  4557. break
  4558. }
  4559. if (f && !e)
  4560. for (; h < f.length && !(k = f[h], k.isEnabled() && !k._isPaused() && k._isRegistered() && c(k, d)); ++h);
  4561. },
  4562. _setDirty: function(a, c) {
  4563. var d = this._priorityDirtyFlagMap;
  4564. d[a] = null == d[a] ? c : c | d[a]
  4565. },
  4566. _visitTarget: function(a, c) {
  4567. var d = a.getChildren(),
  4568. e = 0,
  4569. f = d.length,
  4570. g = this._globalZOrderNodeMap,
  4571. h = this._nodeListenersMap;
  4572. if (0 < f) {
  4573. for (var k; e < f; e++)
  4574. if ((k = d[e]) && 0 > k.getLocalZOrder()) this._visitTarget(k, !1);
  4575. else break;
  4576. null != h[a.__instanceId] && (g[a.getGlobalZOrder()] || (g[a.getGlobalZOrder()] = []), g[a.getGlobalZOrder()].push(a.__instanceId));
  4577. for (; e < f; e++)(k = d[e]) && this._visitTarget(k, !1)
  4578. } else null != h[a.__instanceId] && (g[a.getGlobalZOrder()] || (g[a.getGlobalZOrder()] = []), g[a.getGlobalZOrder()].push(a.__instanceId)); if (c) {
  4579. var d = [],
  4580. m;
  4581. for (m in g) d.push(m);
  4582. d.sort(this._sortNumberAsc);
  4583. m = d.length;
  4584. k = this._nodePriorityMap;
  4585. for (e = 0; e < m; e++) {
  4586. f = g[d[e]];
  4587. for (h = 0; h < f.length; h++) k[f[h]] = ++this._nodePriorityIndex
  4588. }
  4589. this._globalZOrderNodeMap = {}
  4590. }
  4591. },
  4592. _sortNumberAsc: function(a, c) {
  4593. return a - c
  4594. },
  4595. addListener: function(a, c) {
  4596. cc.assert(a && c, cc._LogInfos.eventManager_addListener_2);
  4597. if (a instanceof cc.EventListener) {
  4598. if (a._isRegistered()) {
  4599. cc.log(cc._LogInfos.eventManager_addListener_4);
  4600. return
  4601. }
  4602. } else cc.assert("number" !== typeof c, cc._LogInfos.eventManager_addListener_3), a = cc.EventListener.create(a);
  4603. 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)))
  4604. },
  4605. addCustomListener: function(a, c) {
  4606. var d = cc._EventListenerCustom.create(a, c);
  4607. this.addListener(d, 1);
  4608. return d
  4609. },
  4610. removeListener: function(a) {
  4611. if (null != a) {
  4612. var c, d = this._listenersMap,
  4613. e;
  4614. for (e in d) {
  4615. var f = d[e],
  4616. g = f.getFixedPriorityListeners();
  4617. c = f.getSceneGraphPriorityListeners();
  4618. (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);
  4619. f.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete d[e]);
  4620. if (c) break
  4621. }
  4622. if (!c) {
  4623. d = this._toAddedListeners;
  4624. e = 0;
  4625. for (f = d.length; e < f; e++)
  4626. if (g = d[e], g == a) {
  4627. cc.arrayRemoveObject(d, g);
  4628. break
  4629. }
  4630. }
  4631. }
  4632. },
  4633. _removeListenerInVector: function(a, c) {
  4634. if (null == a) return !1;
  4635. for (var d = 0, e = a.length; d < e; d++) {
  4636. var f = a[d];
  4637. 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
  4638. }
  4639. return !1
  4640. },
  4641. removeListeners: function(a, c) {
  4642. if (a instanceof cc.Node) {
  4643. delete this._nodePriorityMap[a.__instanceId];
  4644. cc.arrayRemoveObject(this._dirtyNodes, a);
  4645. var d = this._nodeListenersMap[a.__instanceId];
  4646. if (d) {
  4647. for (var e = cc.copyArray(d), d = 0; d < e.length; d++) this.removeListener(e[d]);
  4648. e.length = 0;
  4649. e = this._toAddedListeners;
  4650. for (d = 0; d < e.length;) {
  4651. var f = e[d];
  4652. f._getSceneGraphPriority() == a ? (f._setSceneGraphPriority(null), f._setRegistered(!1), e.splice(d, 1)) : ++d
  4653. }
  4654. if (!0 === c) {
  4655. e = a.getChildren();
  4656. d = 0;
  4657. for (f = e.length; d < f; d++) this.removeListeners(e[d], !0)
  4658. }
  4659. }
  4660. } 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)
  4661. },
  4662. removeCustomListeners: function(a) {
  4663. this._removeListenersForListenerID(a)
  4664. },
  4665. removeAllListeners: function() {
  4666. var a = this._listenersMap,
  4667. c = this._internalCustomListenerIDs,
  4668. d;
  4669. for (d in a) - 1 === c.indexOf(d) && this._removeListenersForListenerID(d)
  4670. },
  4671. setPriority: function(a, c) {
  4672. if (null != a) {
  4673. var d = this._listenersMap,
  4674. e;
  4675. for (e in d) {
  4676. var f = d[e].getFixedPriorityListeners();
  4677. if (f && -1 != f.indexOf(a)) {
  4678. null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority);
  4679. a._getFixedPriority() !== c && (a._setFixedPriority(c), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY));
  4680. break
  4681. }
  4682. }
  4683. }
  4684. },
  4685. setEnabled: function(a) {
  4686. this._isEnabled = a
  4687. },
  4688. isEnabled: function() {
  4689. return this._isEnabled
  4690. },
  4691. dispatchEvent: function(a) {
  4692. if (this._isEnabled) {
  4693. this._updateDirtyFlagForSceneGraph();
  4694. this._inDispatch++;
  4695. if (!a || !a.getType) throw "event is undefined";
  4696. if (a.getType() == cc.Event.TOUCH) this._dispatchTouchEvent(a);
  4697. else {
  4698. var c = cc.__getListenerID(a);
  4699. this._sortEventListeners(c);
  4700. c = this._listenersMap[c];
  4701. null != c && this._dispatchEventToListeners(c, this._onListenerCallback, a);
  4702. this._updateListeners(a)
  4703. }
  4704. this._inDispatch--
  4705. }
  4706. },
  4707. _onListenerCallback: function(a, c) {
  4708. c._setCurrentTarget(a._getSceneGraphPriority());
  4709. a._onEvent(c);
  4710. return c.isStopped()
  4711. },
  4712. dispatchCustomEvent: function(a, c) {
  4713. var d = new cc.EventCustom(a);
  4714. d.setUserData(c);
  4715. this.dispatchEvent(d)
  4716. }
  4717. };
  4718. cc.EventAcceleration = cc.Event.extend({
  4719. _acc: null,
  4720. ctor: function(a) {
  4721. cc.Event.prototype.ctor.call(this, cc.Event.ACCELERATION);
  4722. this._acc = a
  4723. }
  4724. });
  4725. cc.EventKeyboard = cc.Event.extend({
  4726. _keyCode: 0,
  4727. _isPressed: !1,
  4728. ctor: function(a, c) {
  4729. cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD);
  4730. this._keyCode = a;
  4731. this._isPressed = c
  4732. }
  4733. });
  4734. cc._EventListenerAcceleration = cc.EventListener.extend({
  4735. _onAccelerationEvent: null,
  4736. ctor: function(a) {
  4737. this._onAccelerationEvent = a;
  4738. var c = this;
  4739. cc.EventListener.prototype.ctor.call(this, cc.EventListener.ACCELERATION, cc._EventListenerAcceleration.LISTENER_ID, function(a) {
  4740. c._onAccelerationEvent(a._acc, a)
  4741. })
  4742. },
  4743. checkAvailable: function() {
  4744. cc.assert(this._onAccelerationEvent, cc._LogInfos._EventListenerAcceleration_checkAvailable);
  4745. return !0
  4746. },
  4747. clone: function() {
  4748. return new cc._EventListenerAcceleration(this._onAccelerationEvent)
  4749. }
  4750. });
  4751. cc._EventListenerAcceleration.LISTENER_ID = "__cc_acceleration";
  4752. cc._EventListenerAcceleration.create = function(a) {
  4753. return new cc._EventListenerAcceleration(a)
  4754. };
  4755. cc._EventListenerKeyboard = cc.EventListener.extend({
  4756. onKeyPressed: null,
  4757. onKeyReleased: null,
  4758. ctor: function() {
  4759. var a = this;
  4760. cc.EventListener.prototype.ctor.call(this, cc.EventListener.KEYBOARD, cc._EventListenerKeyboard.LISTENER_ID, function(c) {
  4761. if (c._isPressed) {
  4762. if (a.onKeyPressed) a.onKeyPressed(c._keyCode, c)
  4763. } else if (a.onKeyReleased) a.onKeyReleased(c._keyCode, c)
  4764. })
  4765. },
  4766. clone: function() {
  4767. var a = new cc._EventListenerKeyboard;
  4768. a.onKeyPressed = this.onKeyPressed;
  4769. a.onKeyReleased = this.onKeyReleased;
  4770. return a
  4771. },
  4772. checkAvailable: function() {
  4773. return null == this.onKeyPressed && null == this.onKeyReleased ? (cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable), !1) : !0
  4774. }
  4775. });
  4776. cc._EventListenerKeyboard.LISTENER_ID = "__cc_keyboard";
  4777. cc._EventListenerKeyboard.create = function() {
  4778. return new cc._EventListenerKeyboard
  4779. };
  4780. cc._tmp.WebGLCCNode = function() {
  4781. var a = cc.Node.prototype;
  4782. a._transform4x4 = null;
  4783. a._stackMatrix = null;
  4784. a._glServerState = null;
  4785. a._camera = null;
  4786. a.ctor = function() {
  4787. this._initNode();
  4788. var a = new cc.kmMat4;
  4789. 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;
  4790. a.mat[10] = a.mat[15] = 1;
  4791. this._transform4x4 = a;
  4792. this._glServerState = 0;
  4793. this._stackMatrix = new cc.kmMat4
  4794. };
  4795. a.setNodeDirty = function() {
  4796. !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
  4797. };
  4798. a.visit = function() {
  4799. if (this._visible) {
  4800. var a = cc._renderContext,
  4801. d, e = cc.current_stack;
  4802. e.stack.push(e.top);
  4803. cc.kmMat4Assign(this._stackMatrix, e.top);
  4804. e.top = this._stackMatrix;
  4805. var f = this.grid;
  4806. f && f._active && f.beforeDraw();
  4807. this.transform();
  4808. var g = this._children;
  4809. if (g && 0 < g.length) {
  4810. var h = g.length;
  4811. this.sortAllChildren();
  4812. for (d = 0; d < h; d++)
  4813. if (g[d] && 0 > g[d]._localZOrder) g[d].visit();
  4814. else break;
  4815. for (this.draw(a); d < h; d++) g[d] && g[d].visit()
  4816. } else this.draw(a);
  4817. this.arrivalOrder = 0;
  4818. f && f._active && f.afterDraw(this);
  4819. e.top = e.stack.pop()
  4820. }
  4821. };
  4822. a.transform = function() {
  4823. var a = this._transform4x4,
  4824. d = cc.current_stack.top,
  4825. e = this.nodeToParentTransform(),
  4826. f = a.mat;
  4827. f[0] = e.a;
  4828. f[4] = e.c;
  4829. f[12] = e.tx;
  4830. f[1] = e.b;
  4831. f[5] = e.d;
  4832. f[13] = e.ty;
  4833. f[14] = this._vertexZ;
  4834. cc.kmMat4Multiply(d, d, a);
  4835. 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())
  4836. };
  4837. a.getNodeToParentTransform = a._getNodeToParentTransformForWebGL
  4838. };
  4839. cc._tmp.PrototypeCCNode = function() {
  4840. var a = cc.Node.prototype;
  4841. cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX);
  4842. cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY);
  4843. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  4844. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight);
  4845. cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX);
  4846. cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY);
  4847. cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX);
  4848. cc.defineGetterSetter(a, "skewY", a.getSkewY, a.setSkewY);
  4849. cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder);
  4850. cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ);
  4851. cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation);
  4852. cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX);
  4853. cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY);
  4854. cc.defineGetterSetter(a, "scale", a.getScale, a.setScale);
  4855. cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX);
  4856. cc.defineGetterSetter(a, "scaleY", a.getScaleY, a.setScaleY);
  4857. cc.defineGetterSetter(a, "children", a.getChildren);
  4858. cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount);
  4859. cc.defineGetterSetter(a, "parent", a.getParent, a.setParent);
  4860. cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible);
  4861. cc.defineGetterSetter(a, "running", a.isRunning);
  4862. cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition);
  4863. cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager);
  4864. cc.defineGetterSetter(a, "scheduler", a.getScheduler, a.setScheduler);
  4865. cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram);
  4866. cc.defineGetterSetter(a, "glServerState", a.getGLServerState, a.setGLServerState);
  4867. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  4868. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  4869. cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
  4870. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  4871. cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
  4872. };
  4873. cc.NODE_TAG_INVALID = -1;
  4874. cc.s_globalOrderOfArrival = 1;
  4875. cc.Node = cc.Class.extend({
  4876. _localZOrder: 0,
  4877. _globalZOrder: 0,
  4878. _vertexZ: 0,
  4879. _rotationX: 0,
  4880. _rotationY: 0,
  4881. _scaleX: 1,
  4882. _scaleY: 1,
  4883. _position: null,
  4884. _skewX: 0,
  4885. _skewY: 0,
  4886. _children: null,
  4887. _visible: !0,
  4888. _anchorPoint: null,
  4889. _anchorPointInPoints: null,
  4890. _contentSize: null,
  4891. _running: !1,
  4892. _parent: null,
  4893. _ignoreAnchorPointForPosition: !1,
  4894. tag: cc.NODE_TAG_INVALID,
  4895. userData: null,
  4896. userObject: null,
  4897. _transformDirty: !0,
  4898. _inverseDirty: !0,
  4899. _cacheDirty: !0,
  4900. _cachedParent: null,
  4901. _transformGLDirty: null,
  4902. _transform: null,
  4903. _inverse: null,
  4904. _reorderChildDirty: !1,
  4905. _shaderProgram: null,
  4906. arrivalOrder: 0,
  4907. _actionManager: null,
  4908. _scheduler: null,
  4909. _eventDispatcher: null,
  4910. _initializedNode: !1,
  4911. _additionalTransformDirty: !1,
  4912. _additionalTransform: null,
  4913. _componentContainer: null,
  4914. _isTransitionFinished: !1,
  4915. _rotationRadiansX: 0,
  4916. _rotationRadiansY: 0,
  4917. _className: "Node",
  4918. _showNode: !1,
  4919. _name: "",
  4920. _displayedOpacity: 255,
  4921. _realOpacity: 255,
  4922. _displayedColor: null,
  4923. _realColor: null,
  4924. _cascadeColorEnabled: !1,
  4925. _cascadeOpacityEnabled: !1,
  4926. _usingNormalizedPosition: !1,
  4927. _hashOfName: 0,
  4928. _initNode: function() {
  4929. this._anchorPoint = cc.p(0, 0);
  4930. this._anchorPointInPoints = cc.p(0, 0);
  4931. this._contentSize = cc.size(0, 0);
  4932. this._position = cc.p(0, 0);
  4933. this._children = [];
  4934. this._transform = {
  4935. a: 1,
  4936. b: 0,
  4937. c: 0,
  4938. d: 1,
  4939. tx: 0,
  4940. ty: 0
  4941. };
  4942. var a = cc.director;
  4943. this._actionManager = a.getActionManager();
  4944. this._scheduler = a.getScheduler();
  4945. this._initializedNode = !0;
  4946. this._additionalTransform = cc.affineTransformMakeIdentity();
  4947. cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this));
  4948. this._realOpacity = this._displayedOpacity = 255;
  4949. this._displayedColor = cc.color(255, 255, 255, 255);
  4950. this._realColor = cc.color(255, 255, 255, 255);
  4951. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1
  4952. },
  4953. init: function() {
  4954. !1 === this._initializedNode && this._initNode();
  4955. return !0
  4956. },
  4957. _arrayMakeObjectsPerformSelector: function(a, c) {
  4958. if (a && 0 !== a.length) {
  4959. var d, e = a.length,
  4960. f;
  4961. d = cc.Node.StateCallbackType;
  4962. switch (c) {
  4963. case d.onEnter:
  4964. for (d = 0; d < e; d++)
  4965. if (f = a[d]) f.onEnter();
  4966. break;
  4967. case d.onExit:
  4968. for (d = 0; d < e; d++)
  4969. if (f = a[d]) f.onExit();
  4970. break;
  4971. case d.onEnterTransitionDidFinish:
  4972. for (d = 0; d < e; d++)
  4973. if (f = a[d]) f.onEnterTransitionDidFinish();
  4974. break;
  4975. case d.cleanup:
  4976. for (d = 0; d < e; d++)(f = a[d]) && f.cleanup();
  4977. break;
  4978. case d.updateTransform:
  4979. for (d = 0; d < e; d++)(f = a[d]) && f.updateTransform();
  4980. break;
  4981. case d.onExitTransitionDidStart:
  4982. for (d = 0; d < e; d++)
  4983. if (f = a[d]) f.onExitTransitionDidStart();
  4984. break;
  4985. case d.sortAllChildren:
  4986. for (d = 0; d < e; d++)(f = a[d]) && f.sortAllChildren();
  4987. break;
  4988. default:
  4989. cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector)
  4990. }
  4991. }
  4992. },
  4993. setNodeDirty: null,
  4994. attr: function(a) {
  4995. for (var c in a) this[c] = a[c]
  4996. },
  4997. getSkewX: function() {
  4998. return this._skewX
  4999. },
  5000. setSkewX: function(a) {
  5001. this._skewX = a;
  5002. this.setNodeDirty()
  5003. },
  5004. getSkewY: function() {
  5005. return this._skewY
  5006. },
  5007. setSkewY: function(a) {
  5008. this._skewY = a;
  5009. this.setNodeDirty()
  5010. },
  5011. setLocalZOrder: function(a) {
  5012. this._localZOrder = a;
  5013. this._parent && this._parent.reorderChild(this, a);
  5014. cc.eventManager._setDirtyForNode(this)
  5015. },
  5016. _setLocalZOrder: function(a) {
  5017. this._localZOrder = a
  5018. },
  5019. getLocalZOrder: function() {
  5020. return this._localZOrder
  5021. },
  5022. getZOrder: function() {
  5023. cc.log(cc._LogInfos.Node_getZOrder);
  5024. return this.getLocalZOrder()
  5025. },
  5026. setZOrder: function(a) {
  5027. cc.log(cc._LogInfos.Node_setZOrder);
  5028. this.setLocalZOrder(a)
  5029. },
  5030. setGlobalZOrder: function(a) {
  5031. this._globalZOrder != a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this))
  5032. },
  5033. getGlobalZOrder: function() {
  5034. return this._globalZOrder
  5035. },
  5036. getVertexZ: function() {
  5037. return this._vertexZ
  5038. },
  5039. setVertexZ: function(a) {
  5040. this._vertexZ = a
  5041. },
  5042. getRotation: function() {
  5043. this._rotationX !== this._rotationY && cc.log(cc._LogInfos.Node_getRotation);
  5044. return this._rotationX
  5045. },
  5046. setRotation: function(a) {
  5047. this._rotationX = this._rotationY = a;
  5048. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  5049. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  5050. this.setNodeDirty()
  5051. },
  5052. getRotationX: function() {
  5053. return this._rotationX
  5054. },
  5055. setRotationX: function(a) {
  5056. this._rotationX = a;
  5057. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  5058. this.setNodeDirty()
  5059. },
  5060. getRotationY: function() {
  5061. return this._rotationY
  5062. },
  5063. setRotationY: function(a) {
  5064. this._rotationY = a;
  5065. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  5066. this.setNodeDirty()
  5067. },
  5068. getScale: function() {
  5069. this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale);
  5070. return this._scaleX
  5071. },
  5072. setScale: function(a, c) {
  5073. this._scaleX = a;
  5074. this._scaleY = c || 0 === c ? c : a;
  5075. this.setNodeDirty()
  5076. },
  5077. getScaleX: function() {
  5078. return this._scaleX
  5079. },
  5080. setScaleX: function(a) {
  5081. this._scaleX = a;
  5082. this.setNodeDirty()
  5083. },
  5084. getScaleY: function() {
  5085. return this._scaleY
  5086. },
  5087. setScaleY: function(a) {
  5088. this._scaleY = a;
  5089. this.setNodeDirty()
  5090. },
  5091. setPosition: function(a, c) {
  5092. var d = this._position;
  5093. void 0 === c ? (d.x = a.x, d.y = a.y) : (d.x = a, d.y = c);
  5094. this.setNodeDirty()
  5095. },
  5096. getPosition: function() {
  5097. return cc.p(this._position)
  5098. },
  5099. getPositionX: function() {
  5100. return this._position.x
  5101. },
  5102. setPositionX: function(a) {
  5103. this._position.x = a;
  5104. this.setNodeDirty()
  5105. },
  5106. getPositionY: function() {
  5107. return this._position.y
  5108. },
  5109. setPositionY: function(a) {
  5110. this._position.y = a;
  5111. this.setNodeDirty()
  5112. },
  5113. getChildrenCount: function() {
  5114. return this._children.length
  5115. },
  5116. getChildren: function() {
  5117. return this._children
  5118. },
  5119. isVisible: function() {
  5120. return this._visible
  5121. },
  5122. setVisible: function(a) {
  5123. this._visible != a && (this._visible = a) && this.setNodeDirty()
  5124. },
  5125. getAnchorPoint: function() {
  5126. return cc.p(this._anchorPoint)
  5127. },
  5128. setAnchorPoint: function(a, c) {
  5129. var d = this._anchorPoint;
  5130. if (void 0 === c) {
  5131. if (a.x === d.x && a.y === d.y) return;
  5132. d.x = a.x;
  5133. d.y = a.y
  5134. } else {
  5135. if (a === d.x && c === d.y) return;
  5136. d.x = a;
  5137. d.y = c
  5138. }
  5139. var e = this._anchorPointInPoints,
  5140. f = this._contentSize;
  5141. e.x = f.width * d.x;
  5142. e.y = f.height * d.y;
  5143. this.setNodeDirty()
  5144. },
  5145. _getAnchor: function() {
  5146. return this._anchorPoint
  5147. },
  5148. _setAnchor: function(a) {
  5149. var c = a.x;
  5150. a = a.y;
  5151. this._anchorPoint.x !== c && (this._anchorPoint.x = c, this._anchorPointInPoints.x = this._contentSize.width * c);
  5152. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a);
  5153. this.setNodeDirty()
  5154. },
  5155. _getAnchorX: function() {
  5156. return this._anchorPoint.x
  5157. },
  5158. _setAnchorX: function(a) {
  5159. this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._anchorPointInPoints.x = this._contentSize.width * a, this.setNodeDirty())
  5160. },
  5161. _getAnchorY: function() {
  5162. return this._anchorPoint.y
  5163. },
  5164. _setAnchorY: function(a) {
  5165. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a, this.setNodeDirty())
  5166. },
  5167. getAnchorPointInPoints: function() {
  5168. return cc.p(this._anchorPointInPoints)
  5169. },
  5170. _getWidth: function() {
  5171. return this._contentSize.width
  5172. },
  5173. _setWidth: function(a) {
  5174. this._contentSize.width = a;
  5175. this._anchorPointInPoints.x = a * this._anchorPoint.x;
  5176. this.setNodeDirty()
  5177. },
  5178. _getHeight: function() {
  5179. return this._contentSize.height
  5180. },
  5181. _setHeight: function(a) {
  5182. this._contentSize.height = a;
  5183. this._anchorPointInPoints.y = a * this._anchorPoint.y;
  5184. this.setNodeDirty()
  5185. },
  5186. getContentSize: function() {
  5187. return cc.size(this._contentSize)
  5188. },
  5189. setContentSize: function(a, c) {
  5190. var d = this._contentSize;
  5191. if (void 0 === c) {
  5192. if (a.width === d.width && a.height === d.height) return;
  5193. d.width = a.width;
  5194. d.height = a.height
  5195. } else {
  5196. if (a === d.width && c === d.height) return;
  5197. d.width = a;
  5198. d.height = c
  5199. }
  5200. var e = this._anchorPointInPoints,
  5201. f = this._anchorPoint;
  5202. e.x = d.width * f.x;
  5203. e.y = d.height * f.y;
  5204. this.setNodeDirty()
  5205. },
  5206. isRunning: function() {
  5207. return this._running
  5208. },
  5209. getParent: function() {
  5210. return this._parent
  5211. },
  5212. setParent: function(a) {
  5213. this._parent = a
  5214. },
  5215. isIgnoreAnchorPointForPosition: function() {
  5216. return this._ignoreAnchorPointForPosition
  5217. },
  5218. ignoreAnchorPointForPosition: function(a) {
  5219. a != this._ignoreAnchorPointForPosition && (this._ignoreAnchorPointForPosition = a, this.setNodeDirty())
  5220. },
  5221. getTag: function() {
  5222. return this.tag
  5223. },
  5224. setTag: function(a) {
  5225. this.tag = a
  5226. },
  5227. setName: function(a) {
  5228. this._name = a
  5229. },
  5230. getName: function() {
  5231. return this._name
  5232. },
  5233. getUserData: function() {
  5234. return this.userData
  5235. },
  5236. setUserData: function(a) {
  5237. this.userData = a
  5238. },
  5239. getUserObject: function() {
  5240. return this.userObject
  5241. },
  5242. setUserObject: function(a) {
  5243. this.userObject != a && (this.userObject = a)
  5244. },
  5245. getOrderOfArrival: function() {
  5246. return this.arrivalOrder
  5247. },
  5248. setOrderOfArrival: function(a) {
  5249. if (NaN == this.arrivalOrder) debugger;
  5250. this.arrivalOrder = a
  5251. },
  5252. getActionManager: function() {
  5253. this._actionManager || (this._actionManager = cc.director.getActionManager());
  5254. return this._actionManager
  5255. },
  5256. setActionManager: function(a) {
  5257. this._actionManager != a && (this.stopAllActions(), this._actionManager = a)
  5258. },
  5259. getScheduler: function() {
  5260. this._scheduler || (this._scheduler = cc.director.getScheduler());
  5261. return this._scheduler
  5262. },
  5263. setScheduler: function(a) {
  5264. this._scheduler != a && (this.unscheduleAllCallbacks(), this._scheduler = a)
  5265. },
  5266. boundingBox: function() {
  5267. cc.log(cc._LogInfos.Node_boundingBox);
  5268. return this.getBoundingBox()
  5269. },
  5270. getBoundingBox: function() {
  5271. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  5272. return cc._rectApplyAffineTransformIn(a, this.getNodeToParentTransform())
  5273. },
  5274. cleanup: function() {
  5275. this.stopAllActions();
  5276. this.unscheduleAllCallbacks();
  5277. cc.eventManager.removeListeners(this);
  5278. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup)
  5279. },
  5280. getChildByTag: function(a) {
  5281. var c = this._children;
  5282. if (null != c)
  5283. for (var d = 0; d < c.length; d++) {
  5284. var e = c[d];
  5285. if (e && e.tag == a) return e
  5286. }
  5287. return null
  5288. },
  5289. getChildByName: function(a) {
  5290. if (!a) return cc.log("Invalid name"), null;
  5291. for (var c = this._children, d = 0, e = c.length; d < e; d++)
  5292. if (c[d]._name == a) return c[d];
  5293. return null
  5294. },
  5295. addChild: function(a, c, d) {
  5296. c = void 0 === c ? a._localZOrder : c;
  5297. var e, f = !1;
  5298. switch (typeof d) {
  5299. case "undefined":
  5300. d = void 0;
  5301. e = a._name;
  5302. break;
  5303. case "string":
  5304. e = d;
  5305. d = void 0;
  5306. break;
  5307. case "number":
  5308. f = !0, e = ""
  5309. }
  5310. cc.assert(a, cc._LogInfos.Node_addChild_3);
  5311. cc.assert(null === a._parent, "child already added. It can't be added again");
  5312. this.addChildHelper(a, c, d, e, f)
  5313. },
  5314. addChildHelper: function(a, c, d, e, f) {
  5315. this._children || (this._children = []);
  5316. this._insertChild(a, c);
  5317. f ? a.setTag(d) : a.setName(e);
  5318. a.setParent(this);
  5319. a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
  5320. if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
  5321. this._cascadeColorEnabled && this._enableCascadeColor();
  5322. this._cascadeOpacityEnabled && this._enableCascadeOpacity()
  5323. },
  5324. removeFromParent: function(a) {
  5325. this._parent && (null == a && (a = !0), this._parent.removeChild(this, a))
  5326. },
  5327. removeFromParentAndCleanup: function(a) {
  5328. cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
  5329. this.removeFromParent(a)
  5330. },
  5331. removeChild: function(a, c) {
  5332. 0 !== this._children.length && (null == c && (c = !0), -1 < this._children.indexOf(a) && this._detachChild(a, c), this.setNodeDirty())
  5333. },
  5334. removeChildByTag: function(a, c) {
  5335. a === cc.NODE_TAG_INVALID && cc.log(cc._LogInfos.Node_removeChildByTag);
  5336. var d = this.getChildByTag(a);
  5337. null == d ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(d, c)
  5338. },
  5339. removeAllChildrenWithCleanup: function(a) {
  5340. cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup);
  5341. this.removeAllChildren(a)
  5342. },
  5343. removeAllChildren: function(a) {
  5344. var c = this._children;
  5345. if (null != c) {
  5346. null == a && (a = !0);
  5347. for (var d = 0; d < c.length; d++) {
  5348. var e = c[d];
  5349. e && (this._running && (e.onExitTransitionDidStart(), e.onExit()), a && e.cleanup(), e.parent = null)
  5350. }
  5351. this._children.length = 0
  5352. }
  5353. },
  5354. _detachChild: function(a, c) {
  5355. this._running && (a.onExitTransitionDidStart(), a.onExit());
  5356. c && a.cleanup();
  5357. a.parent = null;
  5358. cc.arrayRemoveObject(this._children, a)
  5359. },
  5360. _insertChild: function(a, c) {
  5361. this._reorderChildDirty = !0;
  5362. this._children.push(a);
  5363. a._setLocalZOrder(c)
  5364. },
  5365. reorderChild: function(a, c) {
  5366. cc.assert(a, cc._LogInfos.Node_reorderChild);
  5367. this._reorderChildDirty = !0;
  5368. a.arrivalOrder = cc.s_globalOrderOfArrival;
  5369. cc.s_globalOrderOfArrival++;
  5370. a._setLocalZOrder(c);
  5371. this.setNodeDirty()
  5372. },
  5373. sortAllChildren: function() {
  5374. if (this._reorderChildDirty) {
  5375. var a = this._children,
  5376. c = a.length,
  5377. d, e, f;
  5378. for (d = 1; d < c; d++) {
  5379. f = a[d];
  5380. for (e = d - 1; 0 <= e;) {
  5381. if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
  5382. else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
  5383. else break;
  5384. e--
  5385. }
  5386. a[e + 1] = f
  5387. }
  5388. this._reorderChildDirty = !1
  5389. }
  5390. },
  5391. draw: function(a) {},
  5392. transformAncestors: function() {
  5393. null != this._parent && (this._parent.transformAncestors(), this._parent.transform())
  5394. },
  5395. onEnter: function() {
  5396. this._isTransitionFinished = !1;
  5397. this._running = !0;
  5398. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter);
  5399. this.resume()
  5400. },
  5401. onEnterTransitionDidFinish: function() {
  5402. this._isTransitionFinished = !0;
  5403. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnterTransitionDidFinish)
  5404. },
  5405. onExitTransitionDidStart: function() {
  5406. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExitTransitionDidStart)
  5407. },
  5408. onExit: function() {
  5409. this._running = !1;
  5410. this.pause();
  5411. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit)
  5412. },
  5413. runAction: function(a) {
  5414. cc.assert(a, cc._LogInfos.Node_runAction);
  5415. this.actionManager.addAction(a, this, !this._running);
  5416. return a
  5417. },
  5418. stopAllActions: function() {
  5419. this.actionManager && this.actionManager.removeAllActionsFromTarget(this)
  5420. },
  5421. stopAction: function(a) {
  5422. this.actionManager.removeAction(a)
  5423. },
  5424. stopActionByTag: function(a) {
  5425. a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) : this.actionManager.removeActionByTag(a, this)
  5426. },
  5427. getActionByTag: function(a) {
  5428. return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this)
  5429. },
  5430. getNumberOfRunningActions: function() {
  5431. return this.actionManager.numberOfRunningActionsInTarget(this)
  5432. },
  5433. scheduleUpdate: function() {
  5434. this.scheduleUpdateWithPriority(0)
  5435. },
  5436. scheduleUpdateWithPriority: function(a) {
  5437. this.scheduler.scheduleUpdateForTarget(this, a, !this._running)
  5438. },
  5439. unscheduleUpdate: function() {
  5440. this.scheduler.unscheduleUpdateForTarget(this)
  5441. },
  5442. schedule: function(a, c, d, e) {
  5443. c = c || 0;
  5444. cc.assert(a, cc._LogInfos.Node_schedule);
  5445. cc.assert(0 <= c, cc._LogInfos.Node_schedule_2);
  5446. d = null == d ? cc.REPEAT_FOREVER : d;
  5447. this.scheduler.scheduleCallbackForTarget(this, a, c, d, e || 0, !this._running)
  5448. },
  5449. scheduleOnce: function(a, c) {
  5450. this.schedule(a, 0, 0, c)
  5451. },
  5452. unschedule: function(a) {
  5453. a && this.scheduler.unscheduleCallbackForTarget(this, a)
  5454. },
  5455. unscheduleAllCallbacks: function() {
  5456. this.scheduler.unscheduleAllCallbacksForTarget(this)
  5457. },
  5458. resumeSchedulerAndActions: function() {
  5459. cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);
  5460. this.resume()
  5461. },
  5462. resume: function() {
  5463. this.scheduler.resumeTarget(this);
  5464. this.actionManager && this.actionManager.resumeTarget(this);
  5465. cc.eventManager.resumeTarget(this)
  5466. },
  5467. pauseSchedulerAndActions: function() {
  5468. cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
  5469. this.pause()
  5470. },
  5471. pause: function() {
  5472. this.scheduler.pauseTarget(this);
  5473. this.actionManager && this.actionManager.pauseTarget(this);
  5474. cc.eventManager.pauseTarget(this)
  5475. },
  5476. setAdditionalTransform: function(a) {
  5477. this._additionalTransform = a;
  5478. this._additionalTransformDirty = this._transformDirty = !0
  5479. },
  5480. getParentToNodeTransform: function() {
  5481. this._inverseDirty && (this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()), this._inverseDirty = !1);
  5482. return this._inverse
  5483. },
  5484. parentToNodeTransform: function() {
  5485. return this.getParentToNodeTransform()
  5486. },
  5487. getNodeToWorldTransform: function() {
  5488. for (var a = this.getNodeToParentTransform(), c = this._parent; null != c; c = c.parent) a = cc.affineTransformConcat(a, c.getNodeToParentTransform());
  5489. return a
  5490. },
  5491. nodeToWorldTransform: function() {
  5492. return this.getNodeToWorldTransform()
  5493. },
  5494. getWorldToNodeTransform: function() {
  5495. return cc.affineTransformInvert(this.getNodeToWorldTransform())
  5496. },
  5497. worldToNodeTransform: function() {
  5498. return this.getWorldToNodeTransform()
  5499. },
  5500. convertToNodeSpace: function(a) {
  5501. return cc.pointApplyAffineTransform(a, this.getWorldToNodeTransform())
  5502. },
  5503. convertToWorldSpace: function(a) {
  5504. a = a || cc.p(0, 0);
  5505. return cc.pointApplyAffineTransform(a, this.getNodeToWorldTransform())
  5506. },
  5507. convertToNodeSpaceAR: function(a) {
  5508. return cc.pSub(this.convertToNodeSpace(a), this._anchorPointInPoints)
  5509. },
  5510. convertToWorldSpaceAR: function(a) {
  5511. a = a || cc.p(0, 0);
  5512. a = cc.pAdd(a, this._anchorPointInPoints);
  5513. return this.convertToWorldSpace(a)
  5514. },
  5515. _convertToWindowSpace: function(a) {
  5516. a = this.convertToWorldSpace(a);
  5517. return cc.director.convertToUI(a)
  5518. },
  5519. convertTouchToNodeSpace: function(a) {
  5520. a = a.getLocation();
  5521. return this.convertToNodeSpace(a)
  5522. },
  5523. convertTouchToNodeSpaceAR: function(a) {
  5524. a = a.getLocation();
  5525. a = cc.director.convertToGL(a);
  5526. return this.convertToNodeSpaceAR(a)
  5527. },
  5528. update: function(a) {
  5529. this._componentContainer && !this._componentContainer.isEmpty() && this._componentContainer.visit(a)
  5530. },
  5531. updateTransform: function() {
  5532. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
  5533. },
  5534. retain: function() {},
  5535. release: function() {},
  5536. getComponent: function(a) {
  5537. return this._componentContainer.getComponent(a)
  5538. },
  5539. addComponent: function(a) {
  5540. this._componentContainer.add(a)
  5541. },
  5542. removeComponent: function(a) {
  5543. return this._componentContainer.remove(a)
  5544. },
  5545. removeAllComponents: function() {
  5546. this._componentContainer.removeAll()
  5547. },
  5548. grid: null,
  5549. ctor: null,
  5550. visit: null,
  5551. transform: null,
  5552. nodeToParentTransform: function() {
  5553. return this.getNodeToParentTransform()
  5554. },
  5555. getNodeToParentTransform: null,
  5556. _setNodeDirtyForCache: function() {
  5557. if (!1 === this._cacheDirty) {
  5558. this._cacheDirty = !0;
  5559. var a = this._cachedParent;
  5560. a && a != this && a._setNodeDirtyForCache()
  5561. }
  5562. },
  5563. _setCachedParent: function(a) {
  5564. if (this._cachedParent != a) {
  5565. this._cachedParent = a;
  5566. for (var c = this._children, d = 0, e = c.length; d < e; d++) c[d]._setCachedParent(a)
  5567. }
  5568. },
  5569. getCamera: function() {
  5570. this._camera || (this._camera = new cc.Camera);
  5571. return this._camera
  5572. },
  5573. getGrid: function() {
  5574. return this.grid
  5575. },
  5576. setGrid: function(a) {
  5577. this.grid = a
  5578. },
  5579. getShaderProgram: function() {
  5580. return this._shaderProgram
  5581. },
  5582. setShaderProgram: function(a) {
  5583. this._shaderProgram = a
  5584. },
  5585. getGLServerState: function() {
  5586. return this._glServerState
  5587. },
  5588. setGLServerState: function(a) {
  5589. this._glServerState = a
  5590. },
  5591. getBoundingBoxToWorld: function() {
  5592. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
  5593. c = this.nodeToWorldTransform(),
  5594. a = cc.rectApplyAffineTransform(a, this.nodeToWorldTransform());
  5595. if (!this._children) return a;
  5596. for (var d = this._children, e = 0; e < d.length; e++) {
  5597. var f = d[e];
  5598. f && f._visible && (f = f._getBoundingBoxToCurrentNode(c)) && (a = cc.rectUnion(a, f))
  5599. }
  5600. return a
  5601. },
  5602. _getBoundingBoxToCurrentNode: function(a) {
  5603. var c = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  5604. a = null == a ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), a);
  5605. c = cc.rectApplyAffineTransform(c, a);
  5606. if (!this._children) return c;
  5607. for (var d = this._children, e = 0; e < d.length; e++) {
  5608. var f = d[e];
  5609. f && f._visible && (f = f._getBoundingBoxToCurrentNode(a)) && (c = cc.rectUnion(c, f))
  5610. }
  5611. return c
  5612. },
  5613. _getNodeToParentTransformForWebGL: function() {
  5614. if (this._transformDirty) {
  5615. var a = this._position.x,
  5616. c = this._position.y,
  5617. d = this._anchorPointInPoints.x,
  5618. e = -d,
  5619. f = this._anchorPointInPoints.y,
  5620. g = -f,
  5621. h = this._scaleX,
  5622. k = this._scaleY;
  5623. this._ignoreAnchorPointForPosition && (a += d, c += f);
  5624. var m = 1,
  5625. n = 0,
  5626. q = 1,
  5627. r = 0;
  5628. 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);
  5629. var t = this._skewX || this._skewY;
  5630. if (!t && (0 !== d || 0 !== f)) a += q * e * h + -n * g * k, c += r * e * h + m * g * k;
  5631. var s = this._transform;
  5632. s.a = q * h;
  5633. s.b = r * h;
  5634. s.c = -n * k;
  5635. s.d = m * k;
  5636. s.tx = a;
  5637. s.ty = c;
  5638. if (t && (s = cc.affineTransformConcat({
  5639. a: 1,
  5640. b: Math.tan(cc.degreesToRadians(this._skewY)),
  5641. c: Math.tan(cc.degreesToRadians(this._skewX)),
  5642. d: 1,
  5643. tx: 0,
  5644. ty: 0
  5645. }, s), 0 !== d || 0 !== f)) s = cc.affineTransformTranslate(s, e, g);
  5646. this._additionalTransformDirty && (s = cc.affineTransformConcat(s, this._additionalTransform), this._additionalTransformDirty = !1);
  5647. this._transform = s;
  5648. this._transformDirty = !1
  5649. }
  5650. return this._transform
  5651. },
  5652. _updateColor: function() {},
  5653. getOpacity: function() {
  5654. return this._realOpacity
  5655. },
  5656. getDisplayedOpacity: function() {
  5657. return this._displayedOpacity
  5658. },
  5659. setOpacity: function(a) {
  5660. this._displayedOpacity = this._realOpacity = a;
  5661. var c = 255,
  5662. d = this._parent;
  5663. d && d.cascadeOpacity && (c = d.getDisplayedOpacity());
  5664. this.updateDisplayedOpacity(c);
  5665. this._displayedColor.a = this._realColor.a = a
  5666. },
  5667. updateDisplayedOpacity: function(a) {
  5668. this._displayedOpacity = this._realOpacity * a / 255;
  5669. if (this._cascadeOpacityEnabled) {
  5670. a = this._children;
  5671. for (var c = 0; c < a.length; c++) {
  5672. var d = a[c];
  5673. d && d.updateDisplayedOpacity(this._displayedOpacity)
  5674. }
  5675. }
  5676. },
  5677. isCascadeOpacityEnabled: function() {
  5678. return this._cascadeOpacityEnabled
  5679. },
  5680. setCascadeOpacityEnabled: function(a) {
  5681. this._cascadeOpacityEnabled !== a && ((this._cascadeOpacityEnabled = a) ? this._enableCascadeOpacity() : this._disableCascadeOpacity())
  5682. },
  5683. _enableCascadeOpacity: function() {
  5684. var a = 255,
  5685. c = this._parent;
  5686. c && c.cascadeOpacity && (a = c.getDisplayedOpacity());
  5687. this.updateDisplayedOpacity(a)
  5688. },
  5689. _disableCascadeOpacity: function() {
  5690. this._displayedOpacity = this._realOpacity;
  5691. for (var a = this._children, c = 0; c < a.length; c++) {
  5692. var d = a[c];
  5693. d && d.updateDisplayedOpacity(255)
  5694. }
  5695. },
  5696. getColor: function() {
  5697. var a = this._realColor;
  5698. return cc.color(a.r, a.g, a.b, a.a)
  5699. },
  5700. getDisplayedColor: function() {
  5701. var a = this._displayedColor;
  5702. return cc.color(a.r, a.g, a.b, a.a)
  5703. },
  5704. setColor: function(a) {
  5705. var c = this._displayedColor,
  5706. d = this._realColor;
  5707. c.r = d.r = a.r;
  5708. c.g = d.g = a.g;
  5709. c.b = d.b = a.b;
  5710. a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
  5711. this.updateDisplayedColor(a)
  5712. },
  5713. updateDisplayedColor: function(a) {
  5714. var c = this._displayedColor,
  5715. d = this._realColor;
  5716. c.r = 0 | d.r * a.r / 255;
  5717. c.g = 0 | d.g * a.g / 255;
  5718. c.b = 0 | d.b * a.b / 255;
  5719. if (this._cascadeColorEnabled) {
  5720. a = this._children;
  5721. for (d = 0; d < a.length; d++) {
  5722. var e = a[d];
  5723. e && e.updateDisplayedColor(c)
  5724. }
  5725. }
  5726. },
  5727. isCascadeColorEnabled: function() {
  5728. return this._cascadeColorEnabled
  5729. },
  5730. setCascadeColorEnabled: function(a) {
  5731. this._cascadeColorEnabled !== a && ((this._cascadeColorEnabled = a) ? this._enableCascadeColor() : this._disableCascadeColor())
  5732. },
  5733. _enableCascadeColor: function() {
  5734. var a;
  5735. a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
  5736. this.updateDisplayedColor(a)
  5737. },
  5738. _disableCascadeColor: function() {
  5739. var a = this._displayedColor,
  5740. c = this._realColor;
  5741. a.r = c.r;
  5742. a.g = c.g;
  5743. a.b = c.b;
  5744. for (var a = this._children, c = cc.color.WHITE, d = 0; d < a.length; d++) {
  5745. var e = a[d];
  5746. e && e.updateDisplayedColor(c)
  5747. }
  5748. },
  5749. setOpacityModifyRGB: function(a) {},
  5750. isOpacityModifyRGB: function() {
  5751. return !1
  5752. }
  5753. });
  5754. cc.Node.create = function() {
  5755. return new cc.Node
  5756. };
  5757. cc.Node.StateCallbackType = {
  5758. onEnter: 1,
  5759. onExit: 2,
  5760. cleanup: 3,
  5761. onEnterTransitionDidFinish: 4,
  5762. updateTransform: 5,
  5763. onExitTransitionDidStart: 6,
  5764. sortAllChildren: 7
  5765. };
  5766. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Node.prototype, _p.ctor = function() {
  5767. this._initNode()
  5768. }, _p.setNodeDirty = function() {
  5769. this._setNodeDirtyForCache();
  5770. !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
  5771. }, _p.visit = function(a) {
  5772. if (this._visible) {
  5773. a = a || cc._renderContext;
  5774. var c, d = this._children,
  5775. e;
  5776. a.save();
  5777. this.transform(a);
  5778. var f = d.length;
  5779. if (0 < f) {
  5780. this.sortAllChildren();
  5781. for (c = 0; c < f; c++)
  5782. if (e = d[c], 0 > e._localZOrder) e.visit(a);
  5783. else break;
  5784. for (this.draw(a); c < f; c++) d[c].visit(a)
  5785. } else this.draw(a);
  5786. this._cacheDirty = !1;
  5787. this.arrivalOrder = 0;
  5788. a.restore()
  5789. }
  5790. }, _p.transform = function(a) {
  5791. a = a || cc._renderContext;
  5792. var c = cc.view,
  5793. d = this.getNodeToParentTransform();
  5794. a.transform(d.a, d.c, d.b, d.d, d.tx * c.getScaleX(), -d.ty * c.getScaleY())
  5795. }, _p.getNodeToParentTransform = function() {
  5796. if (this._transformDirty) {
  5797. var a = this._transform;
  5798. a.tx = this._position.x;
  5799. a.ty = this._position.y;
  5800. var c = 1,
  5801. d = 0;
  5802. this._rotationX && (c = Math.cos(this._rotationRadiansX), d = Math.sin(this._rotationRadiansX));
  5803. a.a = a.d = c;
  5804. a.b = -d;
  5805. a.c = d;
  5806. var e = this._scaleX,
  5807. f = this._scaleY,
  5808. g = this._anchorPointInPoints.x,
  5809. h = this._anchorPointInPoints.y,
  5810. k = 1E-6 > e && -1E-6 < e ? 1E-6 : e,
  5811. m = 1E-6 > f && -1E-6 < f ? 1E-6 : f;
  5812. if (this._skewX || this._skewY) {
  5813. var n = Math.tan(-this._skewX * Math.PI / 180),
  5814. q = Math.tan(-this._skewY * Math.PI / 180);
  5815. Infinity === n && (n = 99999999);
  5816. Infinity === q && (q = 99999999);
  5817. var r = h * n * k,
  5818. t = g * q * m;
  5819. a.a = c + -d * q;
  5820. a.b = c * n + -d;
  5821. a.c = d + c * q;
  5822. a.d = d * n + c;
  5823. a.tx += c * r + -d * t;
  5824. a.ty += d * r + c * t
  5825. }
  5826. if (1 !== e || 1 !== f) a.a *= k, a.c *= k, a.b *= m, a.d *= m;
  5827. a.tx += c * -g * k + -d * h * m;
  5828. a.ty -= d * -g * k + c * h * m;
  5829. this._ignoreAnchorPointForPosition && (a.tx += g, a.ty += h);
  5830. this._additionalTransformDirty && (this._transform = cc.affineTransformConcat(a, this._additionalTransform), this._additionalTransformDirty = !1);
  5831. this._transformDirty = !1
  5832. }
  5833. return this._transform
  5834. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLCCNode, cc._LogInfos.MissingFile, "BaseNodesWebGL.js"), cc._tmp.WebGLCCNode(), delete cc._tmp.WebGLCCNode);
  5835. cc.assert("function" === typeof cc._tmp.PrototypeCCNode, cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
  5836. cc._tmp.PrototypeCCNode();
  5837. delete cc._tmp.PrototypeCCNode;
  5838. cc.Node.ON_ENTER = 0;
  5839. cc.Node.ON_EXIT = 1;
  5840. cc.Node.ON_ENTER_TRANSITION_DID_FINISH = 2;
  5841. cc.Node.ON_EXIT_TRANSITOIN_DID_START = 3;
  5842. cc.Node.ON_CLEAN_UP = 4;
  5843. cc.AtlasNode = cc.Node.extend({
  5844. textureAtlas: null,
  5845. quadsToDraw: 0,
  5846. _itemsPerRow: 0,
  5847. _itemsPerColumn: 0,
  5848. _itemWidth: 0,
  5849. _itemHeight: 0,
  5850. _colorUnmodified: null,
  5851. _opacityModifyRGB: !1,
  5852. _blendFunc: null,
  5853. _ignoreContentScaleFactor: !1,
  5854. _className: "AtlasNode",
  5855. ctor: function(a, c, d, e) {
  5856. cc.Node.prototype.ctor.call(this);
  5857. this._colorUnmodified = cc.color.WHITE;
  5858. this._blendFunc = {
  5859. src: cc.BLEND_SRC,
  5860. dst: cc.BLEND_DST
  5861. };
  5862. this._ignoreContentScaleFactor = !1;
  5863. void 0 !== e && this.initWithTileFile(a, c, d, e)
  5864. },
  5865. updateAtlasValues: function() {
  5866. cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)
  5867. },
  5868. getColor: function() {
  5869. return this._opacityModifyRGB ? this._colorUnmodified : cc.Node.prototype.getColor.call(this)
  5870. },
  5871. setOpacityModifyRGB: function(a) {
  5872. var c = this.color;
  5873. this._opacityModifyRGB = a;
  5874. this.color = c
  5875. },
  5876. isOpacityModifyRGB: function() {
  5877. return this._opacityModifyRGB
  5878. },
  5879. getBlendFunc: function() {
  5880. return this._blendFunc
  5881. },
  5882. setBlendFunc: function(a, c) {
  5883. this._blendFunc = void 0 === c ? a : {
  5884. src: a,
  5885. dst: c
  5886. }
  5887. },
  5888. setTextureAtlas: function(a) {
  5889. this.textureAtlas = a
  5890. },
  5891. getTextureAtlas: function() {
  5892. return this.textureAtlas
  5893. },
  5894. getQuadsToDraw: function() {
  5895. return this.quadsToDraw
  5896. },
  5897. setQuadsToDraw: function(a) {
  5898. this.quadsToDraw = a
  5899. },
  5900. _textureForCanvas: null,
  5901. _originalTexture: null,
  5902. _uniformColor: null,
  5903. _colorF32Array: null,
  5904. initWithTileFile: function(a, c, d, e) {
  5905. if (!a) throw "cc.AtlasNode.initWithTileFile(): title should not be null";
  5906. a = cc.textureCache.addImage(a);
  5907. return this.initWithTexture(a, c, d, e)
  5908. },
  5909. initWithTexture: null,
  5910. _initWithTextureForCanvas: function(a, c, d, e) {
  5911. this._itemWidth = c;
  5912. this._itemHeight = d;
  5913. this._opacityModifyRGB = !0;
  5914. this._originalTexture = a;
  5915. if (!this._originalTexture) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
  5916. this._textureForCanvas = this._originalTexture;
  5917. this._calculateMaxItems();
  5918. this.quadsToDraw = e;
  5919. return !0
  5920. },
  5921. _initWithTextureForWebGL: function(a, c, d, e) {
  5922. this._itemWidth = c;
  5923. this._itemHeight = d;
  5924. this._colorUnmodified = cc.color.WHITE;
  5925. this._opacityModifyRGB = !0;
  5926. this._blendFunc.src = cc.BLEND_SRC;
  5927. this._blendFunc.dst = cc.BLEND_DST;
  5928. c = this._realColor;
  5929. this._colorF32Array = new Float32Array([c.r / 255, c.g / 255, c.b / 255, this._realOpacity / 255]);
  5930. this.textureAtlas = new cc.TextureAtlas;
  5931. this.textureAtlas.initWithTexture(a, e);
  5932. if (!this.textureAtlas) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
  5933. this._updateBlendFunc();
  5934. this._updateOpacityModifyRGB();
  5935. this._calculateMaxItems();
  5936. this.quadsToDraw = e;
  5937. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  5938. this._uniformColor = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), "u_color");
  5939. return !0
  5940. },
  5941. draw: null,
  5942. _drawForWebGL: function(a) {
  5943. a = a || cc._renderContext;
  5944. cc.nodeDrawSetup(this);
  5945. cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
  5946. this._uniformColor && this._colorF32Array && (a.uniform4fv(this._uniformColor, this._colorF32Array), this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0))
  5947. },
  5948. setColor: null,
  5949. _setColorForCanvas: function(a) {
  5950. var c = this._realColor;
  5951. if (!(c.r == a.r && c.g == a.g && c.b == a.b)) {
  5952. c = cc.color(a.r, a.g, a.b);
  5953. this._colorUnmodified = a;
  5954. if (this._opacityModifyRGB) {
  5955. var d = this._displayedOpacity;
  5956. c.r = c.r * d / 255;
  5957. c.g = c.g * d / 255;
  5958. c.b = c.b * d / 255
  5959. }
  5960. cc.Node.prototype.setColor.call(this, a);
  5961. this._changeTextureColor()
  5962. }
  5963. },
  5964. _changeTextureColor: function() {
  5965. var a = this.getTexture();
  5966. if (a && this._originalTexture) {
  5967. var c = this._originalTexture.getHtmlElementObj();
  5968. if (c) {
  5969. var d = a.getHtmlElementObj(),
  5970. a = cc.rect(0, 0, c.width, c.height);
  5971. 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))
  5972. }
  5973. }
  5974. },
  5975. _setColorForWebGL: function(a) {
  5976. var c = cc.color(a.r, a.g, a.b);
  5977. this._colorUnmodified = a;
  5978. var d = this._displayedOpacity;
  5979. this._opacityModifyRGB && (c.r = c.r * d / 255, c.g = c.g * d / 255, c.b = c.b * d / 255);
  5980. cc.Node.prototype.setColor.call(this, a);
  5981. a = this._displayedColor;
  5982. this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, d / 255])
  5983. },
  5984. setOpacity: function(a) {},
  5985. _setOpacityForCanvas: function(a) {
  5986. cc.Node.prototype.setOpacity.call(this, a);
  5987. this._opacityModifyRGB && (this.color = this._colorUnmodified)
  5988. },
  5989. _setOpacityForWebGL: function(a) {
  5990. cc.Node.prototype.setOpacity.call(this, a);
  5991. 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]))
  5992. },
  5993. getTexture: null,
  5994. _getTextureForCanvas: function() {
  5995. return this._textureForCanvas
  5996. },
  5997. _getTextureForWebGL: function() {
  5998. return this.textureAtlas.texture
  5999. },
  6000. setTexture: null,
  6001. _setTextureForCanvas: function(a) {
  6002. this._textureForCanvas = a
  6003. },
  6004. _setTextureForWebGL: function(a) {
  6005. this.textureAtlas.texture = a;
  6006. this._updateBlendFunc();
  6007. this._updateOpacityModifyRGB()
  6008. },
  6009. _calculateMaxItems: null,
  6010. _calculateMaxItemsForCanvas: function() {
  6011. var a = this.texture.getContentSize();
  6012. this._itemsPerColumn = 0 | a.height / this._itemHeight;
  6013. this._itemsPerRow = 0 | a.width / this._itemWidth
  6014. },
  6015. _calculateMaxItemsForWebGL: function() {
  6016. var a = this.texture,
  6017. c = a.getContentSize();
  6018. this._ignoreContentScaleFactor && (c = a.getContentSizeInPixels());
  6019. this._itemsPerColumn = 0 | c.height / this._itemHeight;
  6020. this._itemsPerRow = 0 | c.width / this._itemWidth
  6021. },
  6022. _updateBlendFunc: function() {
  6023. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  6024. },
  6025. _updateOpacityModifyRGB: function() {
  6026. this._opacityModifyRGB = this.textureAtlas.texture.hasPremultipliedAlpha()
  6027. },
  6028. _setIgnoreContentScaleFactor: function(a) {
  6029. this._ignoreContentScaleFactor = a
  6030. }
  6031. });
  6032. _p = cc.AtlasNode.prototype;
  6033. 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() {
  6034. var a, c = this.getTexture();
  6035. if (c && this._originalTexture && (a = c.getHtmlElementObj())) {
  6036. var d = this._originalTexture.getHtmlElementObj();
  6037. 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))
  6038. }
  6039. }));
  6040. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  6041. cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor);
  6042. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  6043. cc.AtlasNode.create = function(a, c, d, e) {
  6044. return new cc.AtlasNode(a, c, d, e)
  6045. };
  6046. cc._tmp.WebGLTexture2D = function() {
  6047. cc.Texture2D = cc.Class.extend({
  6048. _pVRHaveAlphaPremultiplied: !0,
  6049. _pixelFormat: null,
  6050. _pixelsWide: 0,
  6051. _pixelsHigh: 0,
  6052. _name: "",
  6053. _contentSize: null,
  6054. maxS: 0,
  6055. maxT: 0,
  6056. _hasPremultipliedAlpha: !1,
  6057. _hasMipmaps: !1,
  6058. shaderProgram: null,
  6059. _isLoaded: !1,
  6060. _htmlElementObj: null,
  6061. _webTextureObj: null,
  6062. url: null,
  6063. _loadedEventListeners: null,
  6064. ctor: function() {
  6065. this._contentSize = cc.size(0, 0);
  6066. this._pixelFormat = cc.Texture2D.defaultPixelFormat
  6067. },
  6068. releaseTexture: function() {
  6069. this._webTextureObj && cc._renderContext.deleteTexture(this._webTextureObj);
  6070. cc.loader.release(this.url)
  6071. },
  6072. getPixelFormat: function() {
  6073. return this._pixelFormat
  6074. },
  6075. getPixelsWide: function() {
  6076. return this._pixelsWide
  6077. },
  6078. getPixelsHigh: function() {
  6079. return this._pixelsHigh
  6080. },
  6081. getName: function() {
  6082. return this._webTextureObj
  6083. },
  6084. getContentSize: function() {
  6085. return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor())
  6086. },
  6087. _getWidth: function() {
  6088. return this._contentSize.width / cc.contentScaleFactor()
  6089. },
  6090. _getHeight: function() {
  6091. return this._contentSize.height / cc.contentScaleFactor()
  6092. },
  6093. getContentSizeInPixels: function() {
  6094. return this._contentSize
  6095. },
  6096. getMaxS: function() {
  6097. return this.maxS
  6098. },
  6099. setMaxS: function(a) {
  6100. this.maxS = a
  6101. },
  6102. getMaxT: function() {
  6103. return this.maxT
  6104. },
  6105. setMaxT: function(a) {
  6106. this.maxT = a
  6107. },
  6108. getShaderProgram: function() {
  6109. return this.shaderProgram
  6110. },
  6111. setShaderProgram: function(a) {
  6112. this.shaderProgram = a
  6113. },
  6114. hasPremultipliedAlpha: function() {
  6115. return this._hasPremultipliedAlpha
  6116. },
  6117. hasMipmaps: function() {
  6118. return this._hasMipmaps
  6119. },
  6120. description: function() {
  6121. return "\x3ccc.Texture2D | Name \x3d " + this._name + " | Dimensions \x3d " + this._pixelsWide + " x " + this._pixelsHigh + " | Coordinates \x3d (" + this.maxS + ", " + this.maxT + ")\x3e"
  6122. },
  6123. releaseData: function(a) {},
  6124. keepData: function(a, c) {
  6125. return a
  6126. },
  6127. initWithData: function(a, c, d, e, f) {
  6128. var g = cc.Texture2D,
  6129. h = cc._renderContext,
  6130. k = h.RGBA,
  6131. m = h.UNSIGNED_BYTE,
  6132. n = d * cc.Texture2D._B[c] / 8;
  6133. 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);
  6134. this._webTextureObj = h.createTexture();
  6135. cc.glBindTexture2D(this);
  6136. h.texParameteri(h.TEXTURE_2D, h.TEXTURE_MIN_FILTER, h.LINEAR);
  6137. h.texParameteri(h.TEXTURE_2D, h.TEXTURE_MAG_FILTER, h.LINEAR);
  6138. h.texParameteri(h.TEXTURE_2D, h.TEXTURE_WRAP_S, h.CLAMP_TO_EDGE);
  6139. h.texParameteri(h.TEXTURE_2D, h.TEXTURE_WRAP_T, h.CLAMP_TO_EDGE);
  6140. switch (c) {
  6141. case g.PIXEL_FORMAT_RGBA8888:
  6142. k = h.RGBA;
  6143. break;
  6144. case g.PIXEL_FORMAT_RGB888:
  6145. k = h.RGB;
  6146. break;
  6147. case g.PIXEL_FORMAT_RGBA4444:
  6148. m = h.UNSIGNED_SHORT_4_4_4_4;
  6149. break;
  6150. case g.PIXEL_FORMAT_RGB5A1:
  6151. m = h.UNSIGNED_SHORT_5_5_5_1;
  6152. break;
  6153. case g.PIXEL_FORMAT_RGB565:
  6154. m = h.UNSIGNED_SHORT_5_6_5;
  6155. break;
  6156. case g.PIXEL_FORMAT_AI88:
  6157. k = h.LUMINANCE_ALPHA;
  6158. break;
  6159. case g.PIXEL_FORMAT_A8:
  6160. k = h.ALPHA;
  6161. break;
  6162. case g.PIXEL_FORMAT_I8:
  6163. k = h.LUMINANCE;
  6164. break;
  6165. default:
  6166. cc.assert(0, cc._LogInfos.Texture2D_initWithData)
  6167. }
  6168. h.texImage2D(h.TEXTURE_2D, 0, k, d, e, 0, k, m, a);
  6169. this._contentSize.width = f.width;
  6170. this._contentSize.height = f.height;
  6171. this._pixelsWide = d;
  6172. this._pixelsHigh = e;
  6173. this._pixelFormat = c;
  6174. this.maxS = f.width / d;
  6175. this.maxT = f.height / e;
  6176. this._hasMipmaps = this._hasPremultipliedAlpha = !1;
  6177. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
  6178. return this._isLoaded = !0
  6179. },
  6180. drawAtPoint: function(a) {
  6181. var c = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0],
  6182. d = this._pixelsWide * this.maxS,
  6183. e = this._pixelsHigh * this.maxT;
  6184. 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];
  6185. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  6186. this._shaderProgram.use();
  6187. this._shaderProgram.setUniformsForBuiltins();
  6188. cc.glBindTexture2D(this);
  6189. d = cc._renderContext;
  6190. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, a);
  6191. d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 0, c);
  6192. d.drawArrays(d.TRIANGLE_STRIP, 0, 4)
  6193. },
  6194. drawInRect: function(a) {
  6195. var c = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0];
  6196. 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];
  6197. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  6198. this._shaderProgram.use();
  6199. this._shaderProgram.setUniformsForBuiltins();
  6200. cc.glBindTexture2D(this);
  6201. var d = cc._renderContext;
  6202. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, a);
  6203. d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 0, c);
  6204. d.drawArrays(d.TRIANGLE_STRIP, 0, 4)
  6205. },
  6206. initWithImage: function(a) {
  6207. if (null == a) return cc.log(cc._LogInfos.Texture2D_initWithImage), !1;
  6208. var c = a.getWidth(),
  6209. d = a.getHeight(),
  6210. e = cc.configuration.getMaxTextureSize();
  6211. if (c > e || d > e) return cc.log(cc._LogInfos.Texture2D_initWithImage_2, c, d, e, e), !1;
  6212. this._isLoaded = !0;
  6213. return this._initPremultipliedATextureWithImage(a, c, d)
  6214. },
  6215. initWithElement: function(a) {
  6216. a && (this._webTextureObj = cc._renderContext.createTexture(), this._htmlElementObj = a)
  6217. },
  6218. getHtmlElementObj: function() {
  6219. return this._htmlElementObj
  6220. },
  6221. isLoaded: function() {
  6222. return this._isLoaded
  6223. },
  6224. handleLoadedTexture: function() {
  6225. if (cc._rendererInitialized) {
  6226. if (!this._htmlElementObj) {
  6227. var a = cc.loader.getRes(this.url);
  6228. if (!a) return;
  6229. this.initWithElement(a)
  6230. }
  6231. 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())
  6232. }
  6233. },
  6234. initWithString: function(a, c, d, e, f, g) {
  6235. cc.log(cc._LogInfos.Texture2D_initWithString);
  6236. return null
  6237. },
  6238. initWithETCFile: function(a) {
  6239. cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
  6240. return !1
  6241. },
  6242. initWithPVRFile: function(a) {
  6243. cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);
  6244. return !1
  6245. },
  6246. initWithPVRTCData: function(a, c, d, e, f, g) {
  6247. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);
  6248. return !1
  6249. },
  6250. setTexParameters: function(a) {
  6251. var c = cc._renderContext;
  6252. 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");
  6253. cc.glBindTexture2D(this);
  6254. c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MIN_FILTER, a.minFilter);
  6255. c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MAG_FILTER, a.magFilter);
  6256. c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, a.wrapS);
  6257. c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, a.wrapT)
  6258. },
  6259. setAntiAliasTexParameters: function() {
  6260. var a = cc._renderContext;
  6261. cc.glBindTexture2D(this);
  6262. 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);
  6263. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
  6264. },
  6265. setAliasTexParameters: function() {
  6266. var a = cc._renderContext;
  6267. cc.glBindTexture2D(this);
  6268. 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);
  6269. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
  6270. },
  6271. generateMipmap: function() {
  6272. cc.assert(this._pixelsWide == cc.NextPOT(this._pixelsWide) && this._pixelsHigh == cc.NextPOT(this._pixelsHigh), "Mimpap texture only works in POT textures");
  6273. cc.glBindTexture2D(this);
  6274. cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
  6275. this._hasMipmaps = !0
  6276. },
  6277. stringForFormat: function() {
  6278. return cc.Texture2D._M[this._pixelFormat]
  6279. },
  6280. bitsPerPixelForFormat: function(a) {
  6281. a = a || this._pixelFormat;
  6282. var c = cc.Texture2D._B[a];
  6283. if (null != c) return c;
  6284. cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, a);
  6285. return -1
  6286. },
  6287. _initPremultipliedATextureWithImage: function(a, c, d) {
  6288. var e = cc.Texture2D,
  6289. f = a.getData(),
  6290. g = null,
  6291. g = null,
  6292. h = a.hasAlpha(),
  6293. k = cc.size(a.getWidth(), a.getHeight()),
  6294. m = e.defaultPixelFormat,
  6295. n = a.getBitsPerComponent();
  6296. h || (8 <= n ? m = e.PIXEL_FORMAT_RGB888 : (cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage), m = e.PIXEL_FORMAT_RGB565));
  6297. var q = c * d;
  6298. if (m == e.PIXEL_FORMAT_RGB565)
  6299. if (h) {
  6300. f = new Uint16Array(c * d);
  6301. g = a.getData();
  6302. 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
  6303. } else {
  6304. f = new Uint16Array(c * d);
  6305. g = a.getData();
  6306. for (n = 0; n < q; ++n) f[n] = (g[n] & 255) >> 3 << 11 | (g[n] & 255) >> 2 << 5 | (g[n] & 255) >> 3 << 0
  6307. } else if (m == e.PIXEL_FORMAT_RGBA4444) {
  6308. f = new Uint16Array(c * d);
  6309. g = a.getData();
  6310. 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
  6311. } else if (m == e.PIXEL_FORMAT_RGB5A1) {
  6312. f = new Uint16Array(c * d);
  6313. g = a.getData();
  6314. 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
  6315. } else if (m == e.PIXEL_FORMAT_A8) {
  6316. f = new Uint8Array(c * d);
  6317. g = a.getData();
  6318. for (n = 0; n < q; ++n) f[n] = g >> 24 & 255
  6319. }
  6320. if (h && m == e.PIXEL_FORMAT_RGB888) {
  6321. g = a.getData();
  6322. f = new Uint8Array(3 * c * d);
  6323. 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
  6324. }
  6325. this.initWithData(f, m, c, d, k);
  6326. a.getData();
  6327. this._hasPremultipliedAlpha = a.isPremultipliedAlpha();
  6328. return !0
  6329. },
  6330. addLoadedEventListener: function(a, c) {
  6331. this._loadedEventListeners || (this._loadedEventListeners = []);
  6332. this._loadedEventListeners.push({
  6333. eventCallback: a,
  6334. eventTarget: c
  6335. })
  6336. },
  6337. removeLoadedEventListener: function(a) {
  6338. if (this._loadedEventListeners)
  6339. for (var c = this._loadedEventListeners, d = 0; d < c.length; d++) c[d].eventTarget == a && c.splice(d, 1)
  6340. },
  6341. _callLoadedEventCallbacks: function() {
  6342. if (this._loadedEventListeners) {
  6343. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  6344. var e = a[c];
  6345. e.eventCallback.call(e.eventTarget, this)
  6346. }
  6347. a.length = 0
  6348. }
  6349. }
  6350. })
  6351. };
  6352. cc._tmp.WebGLTextureAtlas = function() {
  6353. var a = cc.TextureAtlas.prototype;
  6354. a._setupVBO = function() {
  6355. var a = cc._renderContext;
  6356. this._buffersVBO[0] = a.createBuffer();
  6357. this._buffersVBO[1] = a.createBuffer();
  6358. this._quadsWebBuffer = a.createBuffer();
  6359. this._mapBuffers()
  6360. };
  6361. a._mapBuffers = function() {
  6362. var a = cc._renderContext;
  6363. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  6364. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  6365. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  6366. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  6367. };
  6368. a.drawNumberOfQuads = function(a, d) {
  6369. d = d || 0;
  6370. if (!(0 === a || !this.texture || !this.texture.isLoaded())) {
  6371. var e = cc._renderContext;
  6372. cc.glBindTexture2D(this.texture);
  6373. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  6374. e.bindBuffer(e.ARRAY_BUFFER, this._quadsWebBuffer);
  6375. this.dirty && e.bufferData(e.ARRAY_BUFFER, this._quadsArrayBuffer, e.DYNAMIC_DRAW);
  6376. e.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, e.FLOAT, !1, 24, 0);
  6377. e.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, e.UNSIGNED_BYTE, !0, 24, 12);
  6378. e.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, e.FLOAT, !1, 24, 16);
  6379. this.dirty && (this.dirty = !1);
  6380. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  6381. 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);
  6382. cc.g_NumberOfDraws++
  6383. }
  6384. }
  6385. };
  6386. cc._tmp.WebGLTextureCache = function() {
  6387. var a = cc.textureCache;
  6388. a.handleLoadedTexture = function(a) {
  6389. var d = this._textures;
  6390. cc._rendererInitialized || (d = this._loadedTexturesBefore);
  6391. var e = d[a];
  6392. e || (e = d[a] = new cc.Texture2D, e.url = a);
  6393. e.handleLoadedTexture()
  6394. };
  6395. a.addImage = function(a, d, e) {
  6396. cc.assert(a, cc._LogInfos.Texture2D_addImage_2);
  6397. var f = this._textures;
  6398. cc._rendererInitialized || (f = this._loadedTexturesBefore);
  6399. var g = f[a] || f[cc.loader._aliases[a]];
  6400. if (g) return d && d.call(e), g;
  6401. cc.loader.getRes(a) || (cc.loader._checkIsImageURL(a) ? cc.loader.load(a, function(a) {
  6402. d && d.call(e)
  6403. }) : cc.loader.cache[a] = cc.loader.loadImg(a, function(e, f) {
  6404. if (e) return d ? d(e) : e;
  6405. cc.textureCache.handleLoadedTexture(a);
  6406. d && d(null, f)
  6407. }));
  6408. g = f[a] = new cc.Texture2D;
  6409. g.url = a;
  6410. return g
  6411. };
  6412. delete a
  6413. };
  6414. cc._tmp.PrototypeTexture2D = function() {
  6415. var a = cc.Texture2D;
  6416. a.PVRImagesHavePremultipliedAlpha = function(a) {
  6417. cc.PVRHaveAlphaPremultiplied_ = a
  6418. };
  6419. a.PIXEL_FORMAT_RGBA8888 = 2;
  6420. a.PIXEL_FORMAT_RGB888 = 3;
  6421. a.PIXEL_FORMAT_RGB565 = 4;
  6422. a.PIXEL_FORMAT_A8 = 5;
  6423. a.PIXEL_FORMAT_I8 = 6;
  6424. a.PIXEL_FORMAT_AI88 = 7;
  6425. a.PIXEL_FORMAT_RGBA4444 = 8;
  6426. a.PIXEL_FORMAT_RGB5A1 = 7;
  6427. a.PIXEL_FORMAT_PVRTC4 = 9;
  6428. a.PIXEL_FORMAT_PVRTC2 = 10;
  6429. a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888;
  6430. var c = cc.Texture2D._M = {};
  6431. c[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888";
  6432. c[a.PIXEL_FORMAT_RGB888] = "RGB888";
  6433. c[a.PIXEL_FORMAT_RGB565] = "RGB565";
  6434. c[a.PIXEL_FORMAT_A8] = "A8";
  6435. c[a.PIXEL_FORMAT_I8] = "I8";
  6436. c[a.PIXEL_FORMAT_AI88] = "AI88";
  6437. c[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444";
  6438. c[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1";
  6439. c[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4";
  6440. c[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2";
  6441. c = cc.Texture2D._B = {};
  6442. c[a.PIXEL_FORMAT_RGBA8888] = 32;
  6443. c[a.PIXEL_FORMAT_RGB888] = 24;
  6444. c[a.PIXEL_FORMAT_RGB565] = 16;
  6445. c[a.PIXEL_FORMAT_A8] = 8;
  6446. c[a.PIXEL_FORMAT_I8] = 8;
  6447. c[a.PIXEL_FORMAT_AI88] = 16;
  6448. c[a.PIXEL_FORMAT_RGBA4444] = 16;
  6449. c[a.PIXEL_FORMAT_RGB5A1] = 16;
  6450. c[a.PIXEL_FORMAT_PVRTC4] = 4;
  6451. c[a.PIXEL_FORMAT_PVRTC2] = 3;
  6452. c = cc.Texture2D.prototype;
  6453. cc.defineGetterSetter(c, "name", c.getName);
  6454. cc.defineGetterSetter(c, "pixelFormat", c.getPixelFormat);
  6455. cc.defineGetterSetter(c, "pixelsWidth", c.getPixelsWide);
  6456. cc.defineGetterSetter(c, "pixelsHeight", c.getPixelsHigh);
  6457. cc.defineGetterSetter(c, "width", c._getWidth);
  6458. cc.defineGetterSetter(c, "height", c._getHeight);
  6459. a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT
  6460. };
  6461. cc._tmp.PrototypeTextureAtlas = function() {
  6462. var a = cc.TextureAtlas.prototype;
  6463. cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads);
  6464. cc.defineGetterSetter(a, "capacity", a.getCapacity);
  6465. cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads)
  6466. };
  6467. cc.ALIGN_CENTER = 51;
  6468. cc.ALIGN_TOP = 19;
  6469. cc.ALIGN_TOP_RIGHT = 18;
  6470. cc.ALIGN_RIGHT = 50;
  6471. cc.ALIGN_BOTTOM_RIGHT = 34;
  6472. cc.ALIGN_BOTTOM = 35;
  6473. cc.ALIGN_BOTTOM_LEFT = 33;
  6474. cc.ALIGN_LEFT = 49;
  6475. cc.ALIGN_TOP_LEFT = 17;
  6476. cc.PVRHaveAlphaPremultiplied_ = !1;
  6477. cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.Texture2D = cc.Class.extend({
  6478. _contentSize: null,
  6479. _isLoaded: !1,
  6480. _htmlElementObj: null,
  6481. _loadedEventListeners: null,
  6482. url: null,
  6483. ctor: function() {
  6484. this._contentSize = cc.size(0, 0);
  6485. this._isLoaded = !1;
  6486. this._htmlElementObj = null
  6487. },
  6488. getPixelsWide: function() {
  6489. return this._contentSize.width
  6490. },
  6491. getPixelsHigh: function() {
  6492. return this._contentSize.height
  6493. },
  6494. getContentSize: function() {
  6495. var a = cc.contentScaleFactor();
  6496. return cc.size(this._contentSize.width / a, this._contentSize.height / a)
  6497. },
  6498. _getWidth: function() {
  6499. return this._contentSize.width / cc.contentScaleFactor()
  6500. },
  6501. _getHeight: function() {
  6502. return this._contentSize.height / cc.contentScaleFactor()
  6503. },
  6504. getContentSizeInPixels: function() {
  6505. return this._contentSize
  6506. },
  6507. initWithElement: function(a) {
  6508. a && (this._htmlElementObj = a)
  6509. },
  6510. getHtmlElementObj: function() {
  6511. return this._htmlElementObj
  6512. },
  6513. isLoaded: function() {
  6514. return this._isLoaded
  6515. },
  6516. handleLoadedTexture: function() {
  6517. if (!this._isLoaded) {
  6518. if (!this._htmlElementObj) {
  6519. var a = cc.loader.getRes(this.url);
  6520. if (!a) return;
  6521. this.initWithElement(a)
  6522. }
  6523. this._isLoaded = !0;
  6524. a = this._htmlElementObj;
  6525. this._contentSize.width = a.width;
  6526. this._contentSize.height = a.height;
  6527. this._callLoadedEventCallbacks()
  6528. }
  6529. },
  6530. description: function() {
  6531. return "\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e"
  6532. },
  6533. initWithData: function(a, c, d, e, f) {
  6534. return !1
  6535. },
  6536. initWithImage: function(a) {
  6537. return !1
  6538. },
  6539. initWithString: function(a, c, d, e, f, g) {
  6540. return !1
  6541. },
  6542. releaseTexture: function() {},
  6543. getName: function() {
  6544. return null
  6545. },
  6546. getMaxS: function() {
  6547. return 1
  6548. },
  6549. setMaxS: function(a) {},
  6550. getMaxT: function() {
  6551. return 1
  6552. },
  6553. setMaxT: function(a) {},
  6554. getPixelFormat: function() {
  6555. return null
  6556. },
  6557. getShaderProgram: function() {
  6558. return null
  6559. },
  6560. setShaderProgram: function(a) {},
  6561. hasPremultipliedAlpha: function() {
  6562. return !1
  6563. },
  6564. hasMipmaps: function() {
  6565. return !1
  6566. },
  6567. releaseData: function(a) {},
  6568. keepData: function(a, c) {
  6569. return a
  6570. },
  6571. drawAtPoint: function(a) {},
  6572. drawInRect: function(a) {},
  6573. initWithETCFile: function(a) {
  6574. cc.log(cc._LogInfos.Texture2D_initWithETCFile);
  6575. return !1
  6576. },
  6577. initWithPVRFile: function(a) {
  6578. cc.log(cc._LogInfos.Texture2D_initWithPVRFile);
  6579. return !1
  6580. },
  6581. initWithPVRTCData: function(a, c, d, e, f, g) {
  6582. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);
  6583. return !1
  6584. },
  6585. setTexParameters: function(a) {},
  6586. setAntiAliasTexParameters: function() {},
  6587. setAliasTexParameters: function() {},
  6588. generateMipmap: function() {},
  6589. stringForFormat: function() {
  6590. return ""
  6591. },
  6592. bitsPerPixelForFormat: function(a) {
  6593. return -1
  6594. },
  6595. addLoadedEventListener: function(a, c) {
  6596. this._loadedEventListeners || (this._loadedEventListeners = []);
  6597. this._loadedEventListeners.push({
  6598. eventCallback: a,
  6599. eventTarget: c
  6600. })
  6601. },
  6602. removeLoadedEventListener: function(a) {
  6603. if (this._loadedEventListeners)
  6604. for (var c = this._loadedEventListeners, d = 0; d < c.length; d++) c[d].eventTarget == a && c.splice(d, 1)
  6605. },
  6606. _callLoadedEventCallbacks: function() {
  6607. if (this._loadedEventListeners) {
  6608. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  6609. var e = a[c];
  6610. e.eventCallback.call(e.eventTarget, this)
  6611. }
  6612. a.length = 0
  6613. }
  6614. }
  6615. }) : (cc.assert("function" === typeof cc._tmp.WebGLTexture2D, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D);
  6616. cc.assert("function" === typeof cc._tmp.PrototypeTexture2D, cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  6617. cc._tmp.PrototypeTexture2D();
  6618. delete cc._tmp.PrototypeTexture2D;
  6619. cc.textureCache = {
  6620. _textures: {},
  6621. _textureColorsCache: {},
  6622. _textureKeySeq: 0 | 1E3 * Math.random(),
  6623. _loadedTexturesBefore: {},
  6624. _initializingRenderer: function() {
  6625. var a, c = this._loadedTexturesBefore,
  6626. d = this._textures;
  6627. for (a in c) {
  6628. var e = c[a];
  6629. e.handleLoadedTexture();
  6630. d[a] = e
  6631. }
  6632. this._loadedTexturesBefore = {}
  6633. },
  6634. addPVRTCImage: function(a) {
  6635. cc.log(cc._LogInfos.textureCache_addPVRTCImage)
  6636. },
  6637. addETCImage: function(a) {
  6638. cc.log(cc._LogInfos.textureCache_addETCImage)
  6639. },
  6640. description: function() {
  6641. return "\x3cTextureCache | Number of textures \x3d " + this._textures.length + "\x3e"
  6642. },
  6643. textureForKey: function(a) {
  6644. return this._textures[a] || this._textures[cc.loader._aliases[a]]
  6645. },
  6646. getKeyByTexture: function(a) {
  6647. for (var c in this._textures)
  6648. if (this._textures[c] == a) return c;
  6649. return null
  6650. },
  6651. _generalTextureKey: function() {
  6652. this._textureKeySeq++;
  6653. return "_textureKey_" + this._textureKeySeq
  6654. },
  6655. getTextureColors: function(a) {
  6656. var c = this.getKeyByTexture(a);
  6657. c || (c = a instanceof HTMLImageElement ? a.src : this._generalTextureKey());
  6658. this._textureColorsCache[c] || (this._textureColorsCache[c] = cc.generateTextureCacheForColor(a));
  6659. return this._textureColorsCache[c]
  6660. },
  6661. addPVRImage: function(a) {
  6662. cc.log(cc._LogInfos.textureCache_addPVRImage)
  6663. },
  6664. removeAllTextures: function() {
  6665. var a = this._textures,
  6666. c;
  6667. for (c in a) a[c] && a[c].releaseTexture();
  6668. this._textures = {}
  6669. },
  6670. removeTexture: function(a) {
  6671. if (a) {
  6672. var c = this._textures,
  6673. d;
  6674. for (d in c) c[d] == a && (c[d].releaseTexture(), delete c[d])
  6675. }
  6676. },
  6677. removeTextureForKey: function(a) {
  6678. null != a && this._textures[a] && delete this._textures[a]
  6679. },
  6680. cacheImage: function(a, c) {
  6681. if (c instanceof cc.Texture2D) this._textures[a] = c;
  6682. else {
  6683. var d = new cc.Texture2D;
  6684. d.initWithElement(c);
  6685. d.handleLoadedTexture();
  6686. this._textures[a] = d
  6687. }
  6688. },
  6689. addUIImage: function(a, c) {
  6690. cc.assert(a, cc._LogInfos.textureCache_addUIImage_2);
  6691. if (c && this._textures[c]) return this._textures[c];
  6692. var d = new cc.Texture2D;
  6693. d.initWithImage(a);
  6694. null != c && null != d ? this._textures[c] = d : cc.log(cc._LogInfos.textureCache_addUIImage);
  6695. return d
  6696. },
  6697. dumpCachedTextureInfo: function() {
  6698. var a = 0,
  6699. c = 0,
  6700. d = this._textures,
  6701. e;
  6702. for (e in d) {
  6703. var f = d[e];
  6704. a++;
  6705. 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);
  6706. c += 4 * f.pixelsWidth * f.pixelsHeight
  6707. }
  6708. d = this._textureColorsCache;
  6709. for (e in d) {
  6710. var f = d[e],
  6711. g;
  6712. for (g in f) {
  6713. var h = f[g];
  6714. a++;
  6715. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, e, h.width, h.height);
  6716. c += 4 * h.width * h.height
  6717. }
  6718. }
  6719. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, c / 1024, (c / 1048576).toFixed(2))
  6720. },
  6721. _clear: function() {
  6722. this._textures = {};
  6723. this._textureColorsCache = {};
  6724. this._textureKeySeq = 0 | 1E3 * Math.random();
  6725. this._loadedTexturesBefore = {}
  6726. }
  6727. };
  6728. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function(a) {
  6729. var c = this._textures,
  6730. d = c[a];
  6731. d || (d = c[a] = new cc.Texture2D, d.url = a);
  6732. d.handleLoadedTexture()
  6733. }, _p.addImage = function(a, c, d) {
  6734. cc.assert(a, cc._LogInfos.Texture2D_addImage);
  6735. var e = this._textures,
  6736. f = e[a] || e[cc.loader._aliases[a]];
  6737. if (f) return c && c.call(d), f;
  6738. f = e[a] = new cc.Texture2D;
  6739. f.url = a;
  6740. cc.loader.getRes(a) ? f.handleLoadedTexture() : cc.loader._checkIsImageURL(a) ? cc.loader.load(a, function(a) {
  6741. c && c.call(d)
  6742. }) : cc.loader.cache[a] = cc.loader.loadImg(a, function(d, e) {
  6743. if (d) return c ? c(d) : d;
  6744. cc.textureCache.handleLoadedTexture(a);
  6745. c && c(null, e)
  6746. });
  6747. return f
  6748. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLTextureCache, cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache);
  6749. cc.TextureAtlas = cc.Class.extend({
  6750. dirty: !1,
  6751. texture: null,
  6752. _indices: null,
  6753. _buffersVBO: null,
  6754. _capacity: 0,
  6755. _quads: null,
  6756. _quadsArrayBuffer: null,
  6757. _quadsWebBuffer: null,
  6758. _quadsReader: null,
  6759. ctor: function(a, c) {
  6760. this._buffersVBO = [];
  6761. "string" == typeof a ? this.initWithFile(a, c) : a instanceof cc.Texture2D && this.initWithTexture(a, c)
  6762. },
  6763. getTotalQuads: function() {
  6764. return this._totalQuads
  6765. },
  6766. getCapacity: function() {
  6767. return this._capacity
  6768. },
  6769. getTexture: function() {
  6770. return this.texture
  6771. },
  6772. setTexture: function(a) {
  6773. this.texture = a
  6774. },
  6775. setDirty: function(a) {
  6776. this.dirty = a
  6777. },
  6778. isDirty: function() {
  6779. return this.dirty
  6780. },
  6781. getQuads: function() {
  6782. return this._quads
  6783. },
  6784. setQuads: function(a) {
  6785. this._quads = a
  6786. },
  6787. _copyQuadsToTextureAtlas: function(a, c) {
  6788. if (a)
  6789. for (var d = 0; d < a.length; d++) this._setQuadToArray(a[d], c + d)
  6790. },
  6791. _setQuadToArray: function(a, c) {
  6792. var d = this._quads;
  6793. 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)
  6794. },
  6795. description: function() {
  6796. return "\x3ccc.TextureAtlas | totalQuads \x3d" + this._totalQuads + "\x3e"
  6797. },
  6798. _setupIndices: function() {
  6799. if (0 !== this._capacity)
  6800. 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)
  6801. },
  6802. _setupVBO: function() {
  6803. var a = cc._renderContext;
  6804. this._buffersVBO[0] = a.createBuffer();
  6805. this._buffersVBO[1] = a.createBuffer();
  6806. this._quadsWebBuffer = a.createBuffer();
  6807. this._mapBuffers()
  6808. },
  6809. _mapBuffers: function() {
  6810. var a = cc._renderContext;
  6811. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  6812. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  6813. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  6814. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  6815. },
  6816. initWithFile: function(a, c) {
  6817. var d = cc.textureCache.addImage(a);
  6818. if (d) return this.initWithTexture(d, c);
  6819. cc.log(cc._LogInfos.TextureAtlas_initWithFile, a);
  6820. return !1
  6821. },
  6822. initWithTexture: function(a, c) {
  6823. cc.assert(a, cc._LogInfos.TextureAtlas_initWithTexture);
  6824. this._capacity = c |= 0;
  6825. this._totalQuads = 0;
  6826. this.texture = a;
  6827. this._quads = [];
  6828. this._indices = new Uint16Array(6 * c);
  6829. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  6830. this._quadsArrayBuffer = new ArrayBuffer(d * c);
  6831. this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
  6832. if ((!this._quads || !this._indices) && 0 < c) return !1;
  6833. 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);
  6834. this._setupIndices();
  6835. this._setupVBO();
  6836. return this.dirty = !0
  6837. },
  6838. updateQuad: function(a, c) {
  6839. cc.assert(a, cc._LogInfos.TextureAtlas_updateQuad);
  6840. cc.assert(0 <= c && c < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2);
  6841. this._totalQuads = Math.max(c + 1, this._totalQuads);
  6842. this._setQuadToArray(a, c);
  6843. this.dirty = !0
  6844. },
  6845. insertQuad: function(a, c) {
  6846. cc.assert(c < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2);
  6847. this._totalQuads++;
  6848. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  6849. else {
  6850. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  6851. e = c * d,
  6852. f = (this._totalQuads - 1 - c) * d;
  6853. this._quads[this._totalQuads - 1] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * d);
  6854. this._quadsReader.set(this._quadsReader.subarray(e, e + f), e + d);
  6855. this._setQuadToArray(a, c);
  6856. this.dirty = !0
  6857. }
  6858. },
  6859. insertQuads: function(a, c, d) {
  6860. d = d || a.length;
  6861. cc.assert(c + d <= this._capacity, cc._LogInfos.TextureAtlas_insertQuads);
  6862. var e = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  6863. this._totalQuads += d;
  6864. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  6865. else {
  6866. var f = c * e,
  6867. g = (this._totalQuads - 1 - c - d) * e,
  6868. h = this._totalQuads - 1 - d,
  6869. k;
  6870. 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);
  6871. this._quadsReader.set(this._quadsReader.subarray(f, f + g), f + e * d);
  6872. for (k = 0; k < d; k++) this._setQuadToArray(a[k], c + k);
  6873. this.dirty = !0
  6874. }
  6875. },
  6876. insertQuadFromIndex: function(a, c) {
  6877. if (a !== c) {
  6878. cc.assert(0 <= c || c < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex);
  6879. cc.assert(0 <= a || a < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex_2);
  6880. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  6881. e = this._quadsReader,
  6882. f = e.subarray(a * d, d),
  6883. g;
  6884. 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));
  6885. this.dirty = !0
  6886. }
  6887. },
  6888. removeQuadAtIndex: function(a) {
  6889. cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex);
  6890. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  6891. this._totalQuads--;
  6892. this._quads.length = this._totalQuads;
  6893. if (a !== this._totalQuads) {
  6894. var d = (a + 1) * c;
  6895. this._quadsReader.set(this._quadsReader.subarray(d, d + (this._totalQuads - a) * c), d - c)
  6896. }
  6897. this.dirty = !0
  6898. },
  6899. removeQuadsAtIndex: function(a, c) {
  6900. cc.assert(a + c <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex);
  6901. this._totalQuads -= c;
  6902. if (a !== this._totalQuads) {
  6903. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  6904. e = (a + c) * d;
  6905. this._quadsReader.set(this._quadsReader.subarray(e, e + (this._totalQuads - a) * d), a * d)
  6906. }
  6907. this.dirty = !0
  6908. },
  6909. removeAllQuads: function() {
  6910. this._totalQuads = this._quads.length = 0
  6911. },
  6912. _setDirty: function(a) {
  6913. this.dirty = a
  6914. },
  6915. resizeCapacity: function(a) {
  6916. if (a == this._capacity) return !0;
  6917. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  6918. d = this._capacity;
  6919. this._totalQuads = Math.min(this._totalQuads, a);
  6920. var e = this._capacity = 0 | a,
  6921. f = this._totalQuads;
  6922. if (null == this._quads) {
  6923. this._quads = [];
  6924. this._quadsArrayBuffer = new ArrayBuffer(c * e);
  6925. this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
  6926. for (a = 0; a < e; a++) this._quads = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, a * c)
  6927. } else {
  6928. var g, h, k = this._quads;
  6929. if (e > d) {
  6930. g = [];
  6931. h = new ArrayBuffer(c * e);
  6932. 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);
  6933. for (; a < e; a++) g[a] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, h, a * c)
  6934. } else {
  6935. f = Math.max(f, e);
  6936. g = [];
  6937. h = new ArrayBuffer(c * e);
  6938. 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)
  6939. }
  6940. this._quadsReader = new Uint8Array(h);
  6941. this._quads = g;
  6942. this._quadsArrayBuffer = h
  6943. }
  6944. 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);
  6945. this._setupIndices();
  6946. this._mapBuffers();
  6947. return this.dirty = !0
  6948. },
  6949. increaseTotalQuadsWith: function(a) {
  6950. this._totalQuads += a
  6951. },
  6952. moveQuadsFromIndex: function(a, c, d) {
  6953. if (void 0 === d) {
  6954. if (d = c, c = this._totalQuads - a, cc.assert(d + (this._totalQuads - a) <= this._capacity, cc._LogInfos.TextureAtlas_moveQuadsFromIndex), 0 === c) return
  6955. } 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;
  6956. var e = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  6957. f = a * e,
  6958. g = c * e,
  6959. h = this._quadsReader,
  6960. k = h.subarray(f, f + g),
  6961. m = d * e;
  6962. 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));
  6963. h.set(k, m);
  6964. this.dirty = !0
  6965. },
  6966. fillWithEmptyQuadsFromIndex: function(a, c) {
  6967. 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
  6968. },
  6969. drawQuads: function() {
  6970. this.drawNumberOfQuads(this._totalQuads, 0)
  6971. },
  6972. _releaseBuffer: function() {
  6973. var a = cc._renderContext;
  6974. this._buffersVBO && (this._buffersVBO[0] && a.deleteBuffer(this._buffersVBO[0]), this._buffersVBO[1] && a.deleteBuffer(this._buffersVBO[1]));
  6975. this._quadsWebBuffer && a.deleteBuffer(this._quadsWebBuffer)
  6976. }
  6977. });
  6978. _p = cc.TextureAtlas.prototype;
  6979. cc.defineGetterSetter(_p, "totalQuads", _p.getTotalQuads);
  6980. cc.defineGetterSetter(_p, "capacity", _p.getCapacity);
  6981. cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads);
  6982. cc.TextureAtlas.create = function(a, c) {
  6983. return new cc.TextureAtlas(a, c)
  6984. };
  6985. cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create;
  6986. 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);
  6987. cc.assert("function" === typeof cc._tmp.PrototypeTextureAtlas, cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  6988. cc._tmp.PrototypeTextureAtlas();
  6989. delete cc._tmp.PrototypeTextureAtlas;
  6990. cc.Scene = cc.Node.extend({
  6991. _className: "Scene",
  6992. ctor: function() {
  6993. cc.Node.prototype.ctor.call(this);
  6994. this._ignoreAnchorPointForPosition = !0;
  6995. this.setAnchorPoint(0.5, 0.5);
  6996. this.setContentSize(cc.director.getWinSize())
  6997. }
  6998. });
  6999. cc.Scene.create = function() {
  7000. return new cc.Scene
  7001. };
  7002. cc.LoaderScene = cc.Scene.extend({
  7003. _interval: null,
  7004. _length: 0,
  7005. _count: 0,
  7006. _label: null,
  7007. _className: "LoaderScene",
  7008. init: function() {
  7009. var a = this,
  7010. c = 200,
  7011. d = a._bgLayer = cc.LayerColor.create(cc.color(32, 32, 32, 255));
  7012. d.setPosition(cc.visibleRect.bottomLeft);
  7013. a.addChild(d, 0);
  7014. var e = 24,
  7015. f = -c / 2 + 100;
  7016. cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, {
  7017. isCrossOrigin: !1
  7018. }, function(d, e) {
  7019. c = e.height;
  7020. a._initStage(e, cc.visibleRect.center)
  7021. }), e = 14, f = -c / 2 - 10);
  7022. e = a._label = cc.LabelTTF.create("Loading... 0%", "Arial", e);
  7023. e.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, f)));
  7024. e.setColor(cc.color(180, 180, 180));
  7025. d.addChild(this._label, 10);
  7026. return !0
  7027. },
  7028. _initStage: function(a, c) {
  7029. var d = this._texture2d = new cc.Texture2D;
  7030. d.initWithElement(a);
  7031. d.handleLoadedTexture();
  7032. d = this._logo = cc.Sprite.create(d);
  7033. d.setScale(cc.contentScaleFactor());
  7034. d.x = c.x;
  7035. d.y = c.y;
  7036. this._bgLayer.addChild(d, 10)
  7037. },
  7038. onEnter: function() {
  7039. cc.Node.prototype.onEnter.call(this);
  7040. this.schedule(this._startLoading, 0.3)
  7041. },
  7042. onExit: function() {
  7043. cc.Node.prototype.onExit.call(this);
  7044. this._label.setString("Loading... 0%")
  7045. },
  7046. initWithResources: function(a, c) {
  7047. "string" == typeof a && (a = [a]);
  7048. this.resources = a || [];
  7049. this.cb = c
  7050. },
  7051. _startLoading: function() {
  7052. var a = this;
  7053. a.unschedule(a._startLoading);
  7054. var c = a.resources;
  7055. a._length = c.length;
  7056. a._count = 0;
  7057. cc.loader.load(c, function(c, e) {
  7058. a._count = e
  7059. }, function() {
  7060. a.cb && a.cb()
  7061. });
  7062. a.schedule(a._updatePercent)
  7063. },
  7064. _updatePercent: function() {
  7065. var a = this._count,
  7066. c = this._length,
  7067. d;
  7068. d = Math.min(100 * (a / c) | 0, 100);
  7069. this._label.setString("Loading... " + d + "%");
  7070. a >= c && this.unschedule(this._updatePercent)
  7071. }
  7072. });
  7073. cc.LoaderScene.preload = function(a, c) {
  7074. var d = cc;
  7075. d.loaderScene || (d.loaderScene = new cc.LoaderScene, d.loaderScene.init());
  7076. d.loaderScene.initWithResources(a, c);
  7077. cc.director.runScene(d.loaderScene);
  7078. return d.loaderScene
  7079. };
  7080. cc._tmp.LayerDefineForWebGL = function() {
  7081. var a = cc.Layer.prototype;
  7082. a.bake = function() {};
  7083. a.unbake = function() {};
  7084. a.visit = cc.Node.prototype.visit
  7085. };
  7086. cc._tmp.WebGLLayerColor = function() {
  7087. var a = cc.LayerColor.prototype;
  7088. a._squareVertices = null;
  7089. a._squareColors = null;
  7090. a._verticesFloat32Buffer = null;
  7091. a._colorsUint8Buffer = null;
  7092. a._squareVerticesAB = null;
  7093. a._squareColorsAB = null;
  7094. a.ctor = function(a, d, e) {
  7095. this._squareVerticesAB = new ArrayBuffer(32);
  7096. this._squareColorsAB = new ArrayBuffer(16);
  7097. var f = this._squareVerticesAB,
  7098. g = this._squareColorsAB,
  7099. h = cc.Vertex2F.BYTES_PER_ELEMENT,
  7100. k = cc.Color.BYTES_PER_ELEMENT;
  7101. 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)];
  7102. 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)];
  7103. this._verticesFloat32Buffer = cc._renderContext.createBuffer();
  7104. this._colorsUint8Buffer = cc._renderContext.createBuffer();
  7105. cc.Layer.prototype.ctor.call(this);
  7106. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  7107. cc.LayerColor.prototype.init.call(this, a, d, e)
  7108. };
  7109. a.setContentSize = function(a, d) {
  7110. var e = this._squareVertices;
  7111. 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);
  7112. this._bindLayerVerticesBufferData();
  7113. cc.Layer.prototype.setContentSize.call(this, a, d)
  7114. };
  7115. a._setWidth = function(a) {
  7116. var d = this._squareVertices;
  7117. d[1].x = a;
  7118. d[3].x = a;
  7119. this._bindLayerVerticesBufferData();
  7120. cc.Layer.prototype._setWidth.call(this, a)
  7121. };
  7122. a._setHeight = function(a) {
  7123. var d = this._squareVertices;
  7124. d[2].y = a;
  7125. d[3].y = a;
  7126. this._bindLayerVerticesBufferData();
  7127. cc.Layer.prototype._setHeight.call(this, a)
  7128. };
  7129. a._updateColor = function() {
  7130. 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;
  7131. this._bindLayerColorsBufferData()
  7132. };
  7133. a.draw = function(a) {
  7134. a = a || cc._renderContext;
  7135. cc.nodeDrawSetup(this);
  7136. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR);
  7137. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  7138. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  7139. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  7140. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0);
  7141. cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
  7142. a.drawArrays(a.TRIANGLE_STRIP, 0, 4)
  7143. };
  7144. a._bindLayerVerticesBufferData = function() {
  7145. var a = cc._renderContext;
  7146. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  7147. a.bufferData(a.ARRAY_BUFFER, this._squareVerticesAB, a.STATIC_DRAW)
  7148. };
  7149. a._bindLayerColorsBufferData = function() {
  7150. var a = cc._renderContext;
  7151. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  7152. a.bufferData(a.ARRAY_BUFFER, this._squareColorsAB, a.STATIC_DRAW)
  7153. }
  7154. };
  7155. cc._tmp.WebGLLayerGradient = function() {
  7156. var a = cc.LayerGradient.prototype;
  7157. a.draw = cc.LayerColor.prototype.draw;
  7158. a._updateColor = function() {
  7159. var a = this._alongVector,
  7160. d = cc.pLength(a);
  7161. if (0 !== d) {
  7162. var e = Math.sqrt(2),
  7163. a = cc.p(a.x / d, a.y / d);
  7164. this._compressedInterpolation && (d = 1 / (Math.abs(a.x) + Math.abs(a.y)), a = cc.pMult(a, d * e));
  7165. var f = this._displayedOpacity / 255,
  7166. d = this._displayedColor,
  7167. g = this._endColor,
  7168. d = {
  7169. r: d.r,
  7170. g: d.g,
  7171. b: d.b,
  7172. a: this._startOpacity * f
  7173. },
  7174. f = {
  7175. r: g.r,
  7176. g: g.g,
  7177. b: g.b,
  7178. a: this._endOpacity * f
  7179. },
  7180. h = this._squareColors,
  7181. g = h[0],
  7182. k = h[1],
  7183. m = h[2],
  7184. h = h[3];
  7185. g.r = f.r + (d.r - f.r) * ((e + a.x + a.y) / (2 * e));
  7186. g.g = f.g + (d.g - f.g) * ((e + a.x + a.y) / (2 * e));
  7187. g.b = f.b + (d.b - f.b) * ((e + a.x + a.y) / (2 * e));
  7188. g.a = f.a + (d.a - f.a) * ((e + a.x + a.y) / (2 * e));
  7189. k.r = f.r + (d.r - f.r) * ((e - a.x + a.y) / (2 * e));
  7190. k.g = f.g + (d.g - f.g) * ((e - a.x + a.y) / (2 * e));
  7191. k.b = f.b + (d.b - f.b) * ((e - a.x + a.y) / (2 * e));
  7192. k.a = f.a + (d.a - f.a) * ((e - a.x + a.y) / (2 * e));
  7193. m.r = f.r + (d.r - f.r) * ((e + a.x - a.y) / (2 * e));
  7194. m.g = f.g + (d.g - f.g) * ((e + a.x - a.y) / (2 * e));
  7195. m.b = f.b + (d.b - f.b) * ((e + a.x - a.y) / (2 * e));
  7196. m.a = f.a + (d.a - f.a) * ((e + a.x - a.y) / (2 * e));
  7197. h.r = f.r + (d.r - f.r) * ((e - a.x - a.y) / (2 * e));
  7198. h.g = f.g + (d.g - f.g) * ((e - a.x - a.y) / (2 * e));
  7199. h.b = f.b + (d.b - f.b) * ((e - a.x - a.y) / (2 * e));
  7200. h.a = f.a + (d.a - f.a) * ((e - a.x - a.y) / (2 * e));
  7201. this._bindLayerColorsBufferData()
  7202. }
  7203. }
  7204. };
  7205. cc._tmp.PrototypeLayerColor = function() {
  7206. var a = cc.LayerColor.prototype;
  7207. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  7208. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight)
  7209. };
  7210. cc._tmp.PrototypeLayerGradient = function() {
  7211. var a = cc.LayerGradient.prototype;
  7212. cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor);
  7213. cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor);
  7214. cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity);
  7215. cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity);
  7216. cc.defineGetterSetter(a, "vector", a.getVector, a.setVector)
  7217. };
  7218. cc.Layer = cc.Node.extend({
  7219. _isBaked: !1,
  7220. _bakeSprite: null,
  7221. _className: "Layer",
  7222. ctor: function() {
  7223. var a = cc.Node.prototype;
  7224. a.ctor.call(this);
  7225. this._ignoreAnchorPointForPosition = !0;
  7226. a.setAnchorPoint.call(this, 0.5, 0.5);
  7227. a.setContentSize.call(this, cc.winSize)
  7228. },
  7229. init: function() {
  7230. this._ignoreAnchorPointForPosition = !0;
  7231. this.setAnchorPoint(0.5, 0.5);
  7232. this.setContentSize(cc.winSize);
  7233. this.cascadeColor = this.cascadeOpacity = !1;
  7234. return !0
  7235. },
  7236. bake: null,
  7237. unbake: null,
  7238. isBaked: function() {
  7239. return this._isBaked
  7240. },
  7241. visit: null
  7242. });
  7243. cc.Layer.create = function() {
  7244. return new cc.Layer
  7245. };
  7246. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  7247. var p = cc.Layer.prototype;
  7248. p.bake = function() {
  7249. if (!this._isBaked) {
  7250. this._isBaked = this._cacheDirty = !0;
  7251. this._cachedParent = this;
  7252. for (var a = this._children, c = 0, d = a.length; c < d; c++) a[c]._setCachedParent(this);
  7253. this._bakeSprite || (this._bakeSprite = new cc.BakeSprite)
  7254. }
  7255. };
  7256. p.unbake = function() {
  7257. if (this._isBaked) {
  7258. this._isBaked = !1;
  7259. this._cacheDirty = !0;
  7260. this._cachedParent = null;
  7261. for (var a = this._children, c = 0, d = a.length; c < d; c++) a[c]._setCachedParent(null)
  7262. }
  7263. };
  7264. p.visit = function(a) {
  7265. if (this._isBaked) {
  7266. a = a || cc._renderContext;
  7267. var c, d = this._children,
  7268. e = d.length;
  7269. if (this._visible && 0 !== e) {
  7270. var f = this._bakeSprite;
  7271. a.save();
  7272. this.transform(a);
  7273. if (this._cacheDirty) {
  7274. c = this._getBoundingBoxForBake();
  7275. c.width |= 0;
  7276. c.height |= 0;
  7277. var g = f.getCacheContext();
  7278. f.resetCanvasSize(c.width, c.height);
  7279. g.translate(0 - c.x, c.height + c.y);
  7280. var h = f.getAnchorPointInPoints();
  7281. f.setPosition(h.x + c.x, h.y + c.y);
  7282. this.sortAllChildren();
  7283. cc.view._setScaleXYForRenderTexture();
  7284. for (c = 0; c < e; c++) d[c].visit(g);
  7285. cc.view._resetScale();
  7286. this._cacheDirty = !1
  7287. }
  7288. f.visit(a);
  7289. this.arrivalOrder = 0;
  7290. a.restore()
  7291. }
  7292. } else cc.Node.prototype.visit.call(this, a)
  7293. };
  7294. p._getBoundingBoxForBake = function() {
  7295. var a = null;
  7296. if (!this._children || 0 === this._children.length) return cc.rect(0, 0, 10, 10);
  7297. for (var c = this._children, d = 0; d < c.length; d++) {
  7298. var e = c[d];
  7299. e && e._visible && (a ? (e = e._getBoundingBoxToCurrentNode()) && (a = cc.rectUnion(a, e)) : a = e._getBoundingBoxToCurrentNode())
  7300. }
  7301. return a
  7302. };
  7303. p = null
  7304. } else cc.assert("function" === typeof cc._tmp.LayerDefineForWebGL, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.LayerDefineForWebGL(), delete cc._tmp.LayerDefineForWebGL;
  7305. cc.LayerColor = cc.Layer.extend({
  7306. _blendFunc: null,
  7307. _className: "LayerColor",
  7308. getBlendFunc: function() {
  7309. return this._blendFunc
  7310. },
  7311. changeWidthAndHeight: function(a, c) {
  7312. this.width = a;
  7313. this.height = c
  7314. },
  7315. changeWidth: function(a) {
  7316. this.width = a
  7317. },
  7318. changeHeight: function(a) {
  7319. this.height = a
  7320. },
  7321. setOpacityModifyRGB: function(a) {},
  7322. isOpacityModifyRGB: function() {
  7323. return !1
  7324. },
  7325. setColor: function(a) {
  7326. cc.Layer.prototype.setColor.call(this, a);
  7327. this._updateColor()
  7328. },
  7329. setOpacity: function(a) {
  7330. cc.Layer.prototype.setOpacity.call(this, a);
  7331. this._updateColor()
  7332. },
  7333. _isLighterMode: !1,
  7334. ctor: null,
  7335. init: function(a, c, d) {
  7336. cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));
  7337. var e = cc.director.getWinSize();
  7338. a = a || cc.color(0, 0, 0, 255);
  7339. c = void 0 === c ? e.width : c;
  7340. d = void 0 === d ? e.height : d;
  7341. e = this._displayedColor;
  7342. e.r = a.r;
  7343. e.g = a.g;
  7344. e.b = a.b;
  7345. e = this._realColor;
  7346. e.r = a.r;
  7347. e.g = a.g;
  7348. e.b = a.b;
  7349. this._realOpacity = this._displayedOpacity = a.a;
  7350. a = cc.LayerColor.prototype;
  7351. a.setContentSize.call(this, c, d);
  7352. a._updateColor.call(this);
  7353. return !0
  7354. },
  7355. setBlendFunc: function(a, c) {
  7356. this._blendFunc = void 0 === c ? a : {
  7357. src: a,
  7358. dst: c
  7359. };
  7360. cc._renderType === cc._RENDER_TYPE_CANVAS && (this._isLighterMode = this._blendFunc && 1 == this._blendFunc.src && 771 == this._blendFunc.dst)
  7361. },
  7362. _setWidth: null,
  7363. _setHeight: null,
  7364. _updateColor: null,
  7365. updateDisplayedColor: function(a) {
  7366. cc.Layer.prototype.updateDisplayedColor.call(this, a);
  7367. this._updateColor()
  7368. },
  7369. updateDisplayedOpacity: function(a) {
  7370. cc.Layer.prototype.updateDisplayedOpacity.call(this, a);
  7371. this._updateColor()
  7372. },
  7373. draw: null
  7374. });
  7375. cc.LayerColor.create = function(a, c, d) {
  7376. return new cc.LayerColor(a, c, d)
  7377. };
  7378. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerColor.prototype, _p.ctor = function(a, c, d) {
  7379. cc.Layer.prototype.ctor.call(this);
  7380. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  7381. cc.LayerColor.prototype.init.call(this, a, c, d)
  7382. }, _p._setWidth = cc.Layer.prototype._setWidth, _p._setHeight = cc.Layer.prototype._setHeight, _p._updateColor = function() {}, _p.draw = function(a) {
  7383. a = a || cc._renderContext;
  7384. var c = cc.view,
  7385. d = this._displayedColor;
  7386. a.fillStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + this._displayedOpacity / 255 + ")";
  7387. a.fillRect(0, 0, this.width * c.getScaleX(), -this.height * c.getScaleY());
  7388. cc.g_NumberOfDraws++
  7389. }, _p.visit = function(a) {
  7390. if (this._isBaked) {
  7391. a = a || cc._renderContext;
  7392. var c, d = this._children,
  7393. e = d.length;
  7394. if (this._visible) {
  7395. var f = this._bakeSprite;
  7396. a.save();
  7397. this.transform(a);
  7398. if (this._cacheDirty) {
  7399. c = this._getBoundingBoxForBake();
  7400. c.width |= 0;
  7401. c.height |= 0;
  7402. var g = f.getCacheContext();
  7403. f.resetCanvasSize(c.width, c.height);
  7404. var h = f.getAnchorPointInPoints(),
  7405. k = this._position;
  7406. 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);
  7407. else {
  7408. var m = this.getAnchorPointInPoints(),
  7409. n = k.x - m.x,
  7410. k = k.y - m.y;
  7411. g.translate(0 - c.x + n, c.height + c.y - k);
  7412. f.setPosition(h.x + c.x - n, h.y + c.y - k)
  7413. }
  7414. cc.view._setScaleXYForRenderTexture();
  7415. if (0 < e) {
  7416. this.sortAllChildren();
  7417. for (c = 0; c < e; c++)
  7418. if (h = d[c], 0 > h._localZOrder) h.visit(g);
  7419. else break;
  7420. for (this.draw(g); c < e; c++) d[c].visit(g)
  7421. } else this.draw(g);
  7422. cc.view._resetScale();
  7423. this._cacheDirty = !1
  7424. }
  7425. f.visit(a);
  7426. this.arrivalOrder = 0;
  7427. a.restore()
  7428. }
  7429. } else cc.Node.prototype.visit.call(this, a)
  7430. }, _p._getBoundingBoxForBake = function() {
  7431. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
  7432. c = this.nodeToWorldTransform(),
  7433. a = cc.rectApplyAffineTransform(a, this.nodeToWorldTransform());
  7434. if (!this._children || 0 === this._children.length) return a;
  7435. for (var d = this._children, e = 0; e < d.length; e++) {
  7436. var f = d[e];
  7437. f && f._visible && (f = f._getBoundingBoxToCurrentNode(c), a = cc.rectUnion(a, f))
  7438. }
  7439. return a
  7440. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerColor, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerColor(), delete cc._tmp.WebGLLayerColor);
  7441. cc.assert("function" === typeof cc._tmp.PrototypeLayerColor, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  7442. cc._tmp.PrototypeLayerColor();
  7443. delete cc._tmp.PrototypeLayerColor;
  7444. cc.LayerGradient = cc.LayerColor.extend({
  7445. _startColor: null,
  7446. _endColor: null,
  7447. _startOpacity: 255,
  7448. _endOpacity: 255,
  7449. _alongVector: null,
  7450. _compressedInterpolation: !1,
  7451. _gradientStartPoint: null,
  7452. _gradientEndPoint: null,
  7453. _className: "LayerGradient",
  7454. ctor: function(a, c, d) {
  7455. cc.LayerColor.prototype.ctor.call(this);
  7456. this._startColor = cc.color(0, 0, 0, 255);
  7457. this._endColor = cc.color(0, 0, 0, 255);
  7458. this._alongVector = cc.p(0, -1);
  7459. this._endOpacity = this._startOpacity = 255;
  7460. this._gradientStartPoint = cc.p(0, 0);
  7461. this._gradientEndPoint = cc.p(0, 0);
  7462. cc.LayerGradient.prototype.init.call(this, a, c, d)
  7463. },
  7464. init: function(a, c, d) {
  7465. a = a || cc.color(0, 0, 0, 255);
  7466. c = c || cc.color(0, 0, 0, 255);
  7467. d = d || cc.p(0, -1);
  7468. var e = this._startColor,
  7469. f = this._endColor;
  7470. e.r = a.r;
  7471. e.g = a.g;
  7472. e.b = a.b;
  7473. this._startOpacity = a.a;
  7474. f.r = c.r;
  7475. f.g = c.g;
  7476. f.b = c.b;
  7477. this._endOpacity = c.a;
  7478. this._alongVector = d;
  7479. this._compressedInterpolation = !0;
  7480. this._gradientStartPoint = cc.p(0, 0);
  7481. this._gradientEndPoint = cc.p(0, 0);
  7482. cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255));
  7483. cc.LayerGradient.prototype._updateColor.call(this);
  7484. return !0
  7485. },
  7486. setContentSize: function(a, c) {
  7487. cc.LayerColor.prototype.setContentSize.call(this, a, c);
  7488. this._updateColor()
  7489. },
  7490. _setWidth: function(a) {
  7491. cc.LayerColor.prototype._setWidth.call(this, a);
  7492. this._updateColor()
  7493. },
  7494. _setHeight: function(a) {
  7495. cc.LayerColor.prototype._setHeight.call(this, a);
  7496. this._updateColor()
  7497. },
  7498. getStartColor: function() {
  7499. return this._realColor
  7500. },
  7501. setStartColor: function(a) {
  7502. this.color = a
  7503. },
  7504. setEndColor: function(a) {
  7505. this._endColor = a;
  7506. this._updateColor()
  7507. },
  7508. getEndColor: function() {
  7509. return this._endColor
  7510. },
  7511. setStartOpacity: function(a) {
  7512. this._startOpacity = a;
  7513. this._updateColor()
  7514. },
  7515. getStartOpacity: function() {
  7516. return this._startOpacity
  7517. },
  7518. setEndOpacity: function(a) {
  7519. this._endOpacity = a;
  7520. this._updateColor()
  7521. },
  7522. getEndOpacity: function() {
  7523. return this._endOpacity
  7524. },
  7525. setVector: function(a) {
  7526. this._alongVector.x = a.x;
  7527. this._alongVector.y = a.y;
  7528. this._updateColor()
  7529. },
  7530. getVector: function() {
  7531. return cc.p(this._alongVector.x, this._alongVector.y)
  7532. },
  7533. isCompressedInterpolation: function() {
  7534. return this._compressedInterpolation
  7535. },
  7536. setCompressedInterpolation: function(a) {
  7537. this._compressedInterpolation = a;
  7538. this._updateColor()
  7539. },
  7540. _draw: null,
  7541. _updateColor: null
  7542. });
  7543. cc.LayerGradient.create = function(a, c, d) {
  7544. return new cc.LayerGradient(a, c, d)
  7545. };
  7546. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerGradient.prototype, _p.draw = function(a) {
  7547. a = a || cc._renderContext;
  7548. this._isLighterMode && (a.globalCompositeOperation = "lighter");
  7549. a.save();
  7550. var c = this._displayedOpacity / 255,
  7551. d = cc.view.getScaleX(),
  7552. e = cc.view.getScaleY(),
  7553. f = this.width * d,
  7554. g = this.height * e,
  7555. d = a.createLinearGradient(this._gradientStartPoint.x * d, this._gradientStartPoint.y * e, this._gradientEndPoint.x * d, this._gradientEndPoint.y * e),
  7556. e = this._displayedColor,
  7557. h = this._endColor;
  7558. d.addColorStop(0, "rgba(" + Math.round(e.r) + "," + Math.round(e.g) + "," + Math.round(e.b) + "," + (c * (this._startOpacity / 255)).toFixed(4) + ")");
  7559. d.addColorStop(1, "rgba(" + Math.round(h.r) + "," + Math.round(h.g) + "," + Math.round(h.b) + "," + (c * (this._endOpacity / 255)).toFixed(4) + ")");
  7560. a.fillStyle = d;
  7561. a.fillRect(0, 0, f, -g);
  7562. 0 != this._rotation && a.rotate(this._rotationRadians);
  7563. a.restore();
  7564. cc.g_NumberOfDraws++
  7565. }, _p._updateColor = function() {
  7566. var a = this._alongVector,
  7567. c = 0.5 * this.width,
  7568. d = 0.5 * this.height;
  7569. this._gradientStartPoint.x = c * -a.x + c;
  7570. this._gradientStartPoint.y = d * a.y - d;
  7571. this._gradientEndPoint.x = c * a.x + c;
  7572. this._gradientEndPoint.y = d * -a.y - d
  7573. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLayerGradient, cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerGradient(), delete cc._tmp.WebGLLayerGradient);
  7574. cc.assert("function" === typeof cc._tmp.PrototypeLayerGradient, cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  7575. cc._tmp.PrototypeLayerGradient();
  7576. delete cc._tmp.PrototypeLayerGradient;
  7577. cc.LayerMultiplex = cc.Layer.extend({
  7578. _enabledLayer: 0,
  7579. _layers: null,
  7580. _className: "LayerMultiplex",
  7581. ctor: function(a) {
  7582. cc.Layer.prototype.ctor.call(this);
  7583. a instanceof Array ? cc.LayerMultiplex.prototype.initWithLayers.call(this, a) : cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments))
  7584. },
  7585. initWithLayers: function(a) {
  7586. 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);
  7587. this._layers = a;
  7588. this._enabledLayer = 0;
  7589. this.addChild(this._layers[this._enabledLayer]);
  7590. return !0
  7591. },
  7592. switchTo: function(a) {
  7593. 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]))
  7594. },
  7595. switchToAndReleaseMe: function(a) {
  7596. 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]))
  7597. },
  7598. addLayer: function(a) {
  7599. a ? this._layers.push(a) : cc.log(cc._LogInfos.LayerMultiplex_addLayer)
  7600. }
  7601. });
  7602. cc.LayerMultiplex.create = function() {
  7603. return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))
  7604. };
  7605. cc._tmp.WebGLSprite = function() {
  7606. var a = cc.Sprite.prototype;
  7607. a._spriteFrameLoadedCallback = function(a) {
  7608. this.setNodeDirty(!0);
  7609. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  7610. this._callLoadedEventCallbacks()
  7611. };
  7612. a.setOpacityModifyRGB = function(a) {
  7613. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.updateColor())
  7614. };
  7615. a.updateDisplayedOpacity = function(a) {
  7616. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  7617. this.updateColor()
  7618. };
  7619. a.ctor = function(a, d, e) {
  7620. cc.Node.prototype.ctor.call(this);
  7621. this._shouldBeHidden = !1;
  7622. this._offsetPosition = cc.p(0, 0);
  7623. this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
  7624. this._blendFunc = {
  7625. src: cc.BLEND_SRC,
  7626. dst: cc.BLEND_DST
  7627. };
  7628. this._rect = cc.rect(0, 0, 0, 0);
  7629. this._quad = new cc.V3F_C4B_T2F_Quad;
  7630. this._quadWebBuffer = cc._renderContext.createBuffer();
  7631. this._textureLoaded = this._quadDirty = !0;
  7632. this._softInit(a, d, e)
  7633. };
  7634. a.setBlendFunc = function(a, d) {
  7635. var e = this._blendFunc;
  7636. void 0 === d ? (e.src = a.src, e.dst = a.dst) : (e.src = a, e.dst = d)
  7637. };
  7638. a.init = function() {
  7639. if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
  7640. cc.Node.prototype.init.call(this);
  7641. this.dirty = this._recursiveDirty = !1;
  7642. this._opacityModifyRGB = !0;
  7643. this._blendFunc.src = cc.BLEND_SRC;
  7644. this._blendFunc.dst = cc.BLEND_DST;
  7645. this.texture = null;
  7646. this._textureLoaded = !0;
  7647. this._flippedX = this._flippedY = !1;
  7648. this.anchorY = this.anchorX = 0.5;
  7649. this._offsetPosition.x = 0;
  7650. this._offsetPosition.y = 0;
  7651. this._hasChildren = !1;
  7652. var a = {
  7653. r: 255,
  7654. g: 255,
  7655. b: 255,
  7656. a: 255
  7657. };
  7658. this._quad.bl.colors = a;
  7659. this._quad.br.colors = a;
  7660. this._quad.tl.colors = a;
  7661. this._quad.tr.colors = a;
  7662. this._quadDirty = !0;
  7663. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  7664. return !0
  7665. };
  7666. a.initWithTexture = function(a, d, e) {
  7667. cc.assert(0 != arguments.length, cc._LogInfos.Sprite_initWithTexture);
  7668. e = e || !1;
  7669. if (!cc.Node.prototype.init.call(this)) return !1;
  7670. this._batchNode = null;
  7671. this.dirty = this._recursiveDirty = !1;
  7672. this._opacityModifyRGB = !0;
  7673. this._blendFunc.src = cc.BLEND_SRC;
  7674. this._blendFunc.dst = cc.BLEND_DST;
  7675. this._flippedX = this._flippedY = !1;
  7676. this.anchorY = this.anchorX = 0.5;
  7677. this._offsetPosition.x = 0;
  7678. this._offsetPosition.y = 0;
  7679. this._hasChildren = !1;
  7680. var f = cc.color(255, 255, 255, 255),
  7681. g = this._quad;
  7682. g.bl.colors = f;
  7683. g.br.colors = f;
  7684. g.tl.colors = f;
  7685. g.tr.colors = f;
  7686. this._textureLoaded = f = a.isLoaded();
  7687. 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;
  7688. d || (d = cc.rect(0, 0, a.width, a.height));
  7689. 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));
  7690. this.texture = a;
  7691. this.setTextureRect(d, e);
  7692. this.batchNode = null;
  7693. return this._quadDirty = !0
  7694. };
  7695. a._textureLoadedCallback = function(a) {
  7696. if (!this._textureLoaded) {
  7697. this._textureLoaded = !0;
  7698. var d = this._rect;
  7699. d ? cc._rectEqualToZero(d) && (d.width = a.width, d.height = a.height) : d = cc.rect(0, 0, a.width, a.height);
  7700. this.texture = a;
  7701. this.setTextureRect(d, this._rectRotated);
  7702. this.batchNode = this._batchNode;
  7703. this._quadDirty = !0;
  7704. this._callLoadedEventCallbacks()
  7705. }
  7706. };
  7707. a.setTextureRect = function(a, d, e) {
  7708. this._rectRotated = d || !1;
  7709. this.setContentSize(e || a);
  7710. this.setVertexRect(a);
  7711. this._setTextureCoords(a);
  7712. a = this._unflippedOffsetPositionFromCenter;
  7713. this._flippedX && (a.x = -a.x);
  7714. this._flippedY && (a.y = -a.y);
  7715. var f = this._rect;
  7716. this._offsetPosition.x = a.x + (this._contentSize.width - f.width) / 2;
  7717. this._offsetPosition.y = a.y + (this._contentSize.height - f.height) / 2;
  7718. if (this._batchNode) this.dirty = !0;
  7719. else {
  7720. a = 0 + this._offsetPosition.x;
  7721. d = 0 + this._offsetPosition.y;
  7722. e = a + f.width;
  7723. var f = d + f.height,
  7724. g = this._quad;
  7725. g.bl.vertices = {
  7726. x: a,
  7727. y: d,
  7728. z: 0
  7729. };
  7730. g.br.vertices = {
  7731. x: e,
  7732. y: d,
  7733. z: 0
  7734. };
  7735. g.tl.vertices = {
  7736. x: a,
  7737. y: f,
  7738. z: 0
  7739. };
  7740. g.tr.vertices = {
  7741. x: e,
  7742. y: f,
  7743. z: 0
  7744. };
  7745. this._quadDirty = !0
  7746. }
  7747. };
  7748. a.updateTransform = function() {
  7749. if (this.dirty) {
  7750. var a = this._quad,
  7751. d = this._parent;
  7752. if (!this._visible || d && d != this._batchNode && d._shouldBeHidden) a.br.vertices = a.tl.vertices = a.tr.vertices = a.bl.vertices = {
  7753. x: 0,
  7754. y: 0,
  7755. z: 0
  7756. }, this._shouldBeHidden = !0;
  7757. else {
  7758. this._shouldBeHidden = !1;
  7759. var e = this._transformToBatch = !d || d == this._batchNode ? this.nodeToParentTransform() : cc.affineTransformConcat(this.nodeToParentTransform(), d._transformToBatch),
  7760. f = this._rect,
  7761. d = this._offsetPosition.x,
  7762. g = this._offsetPosition.y,
  7763. h = d + f.width,
  7764. k = g + f.height,
  7765. m = e.tx,
  7766. n = e.ty,
  7767. q = e.a,
  7768. r = e.b,
  7769. t = e.d,
  7770. s = -e.c,
  7771. e = d * q - g * s + m,
  7772. f = d * r + g * t + n,
  7773. v = h * q - g * s + m,
  7774. g = h * r + g * t + n,
  7775. u = h * q - k * s + m,
  7776. h = h * r + k * t + n,
  7777. m = d * q - k * s + m,
  7778. d = d * r + k * t + n,
  7779. k = this._vertexZ;
  7780. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (e |= 0, f |= 0, v |= 0, g |= 0, u |= 0, h |= 0, m |= 0, d |= 0);
  7781. a.bl.vertices = {
  7782. x: e,
  7783. y: f,
  7784. z: k
  7785. };
  7786. a.br.vertices = {
  7787. x: v,
  7788. y: g,
  7789. z: k
  7790. };
  7791. a.tl.vertices = {
  7792. x: m,
  7793. y: d,
  7794. z: k
  7795. };
  7796. a.tr.vertices = {
  7797. x: u,
  7798. y: h,
  7799. z: k
  7800. }
  7801. }
  7802. this.textureAtlas.updateQuad(a, this.atlasIndex);
  7803. this.dirty = this._recursiveDirty = !1
  7804. }
  7805. this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform);
  7806. 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))
  7807. };
  7808. a.addChild = function(a, d, e) {
  7809. cc.assert(a, cc._LogInfos.Sprite_addChild_3);
  7810. null == d && (d = a._localZOrder);
  7811. null == e && (e = a.tag);
  7812. if (this._batchNode) {
  7813. if (!(a instanceof cc.Sprite)) {
  7814. cc.log(cc._LogInfos.Sprite_addChild);
  7815. return
  7816. }
  7817. a.texture._webTextureObj !== this.textureAtlas.texture._webTextureObj && cc.log(cc._LogInfos.Sprite_addChild_2);
  7818. this._batchNode.appendChild(a);
  7819. this._reorderChildDirty || this._setReorderChildDirtyRecursively()
  7820. }
  7821. cc.Node.prototype.addChild.call(this, a, d, e);
  7822. this._hasChildren = !0
  7823. };
  7824. a.setOpacity = function(a) {
  7825. cc.Node.prototype.setOpacity.call(this, a);
  7826. this.updateColor()
  7827. };
  7828. a.setColor = function(a) {
  7829. cc.Node.prototype.setColor.call(this, a);
  7830. this.updateColor()
  7831. };
  7832. a.updateDisplayedColor = function(a) {
  7833. cc.Node.prototype.updateDisplayedColor.call(this, a);
  7834. this.updateColor()
  7835. };
  7836. a.setSpriteFrame = function(a) {
  7837. var d = this;
  7838. "string" == typeof a && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.Sprite_setSpriteFrame));
  7839. d.setNodeDirty(!0);
  7840. var e = a.getOffset();
  7841. d._unflippedOffsetPositionFromCenter.x = e.x;
  7842. d._unflippedOffsetPositionFromCenter.y = e.y;
  7843. e = a.getTexture();
  7844. a.textureLoaded() || (d._textureLoaded = !1, a.addLoadedEventListener(function(a) {
  7845. d._textureLoaded = !0;
  7846. var c = a.getTexture();
  7847. c != d._texture && (d.texture = c);
  7848. d.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  7849. d._callLoadedEventCallbacks()
  7850. }, d));
  7851. e != d._texture && (d.texture = e);
  7852. d._rectRotated = a.isRotated();
  7853. d.setTextureRect(a.getRect(), d._rectRotated, a.getOriginalSize())
  7854. };
  7855. a.isFrameDisplayed = function(a) {
  7856. return cc.rectEqualToRect(a.getRect(), this._rect) && a.getTexture().getName() == this._texture.getName() && cc.pointEqualToPoint(a.getOffset(), this._unflippedOffsetPositionFromCenter)
  7857. };
  7858. a.setBatchNode = function(a) {
  7859. if (this._batchNode = a) this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.textureAtlas;
  7860. else {
  7861. this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED;
  7862. this.textureAtlas = null;
  7863. this.dirty = this._recursiveDirty = !1;
  7864. a = this._offsetPosition.x;
  7865. var d = this._offsetPosition.y,
  7866. e = a + this._rect.width,
  7867. f = d + this._rect.height,
  7868. g = this._quad;
  7869. g.bl.vertices = {
  7870. x: a,
  7871. y: d,
  7872. z: 0
  7873. };
  7874. g.br.vertices = {
  7875. x: e,
  7876. y: d,
  7877. z: 0
  7878. };
  7879. g.tl.vertices = {
  7880. x: a,
  7881. y: f,
  7882. z: 0
  7883. };
  7884. g.tr.vertices = {
  7885. x: e,
  7886. y: f,
  7887. z: 0
  7888. };
  7889. this._quadDirty = !0
  7890. }
  7891. };
  7892. a.setTexture = function(a) {
  7893. 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())))
  7894. };
  7895. a.draw = function() {
  7896. if (this._textureLoaded) {
  7897. var a = cc._renderContext,
  7898. d = this._texture;
  7899. 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));
  7900. cc.g_NumberOfDraws++;
  7901. 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))
  7902. }
  7903. };
  7904. delete a
  7905. };
  7906. cc._tmp.PrototypeSprite = function() {
  7907. var a = cc.Sprite.prototype;
  7908. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  7909. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  7910. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  7911. cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX);
  7912. cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY);
  7913. cc.defineGetterSetter(a, "offsetX", a._getOffsetX);
  7914. cc.defineGetterSetter(a, "offsetY", a._getOffsetY);
  7915. cc.defineGetterSetter(a, "texture", a.getTexture, a.setTexture);
  7916. cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated);
  7917. cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode);
  7918. cc.defineGetterSetter(a, "quad", a.getQuad)
  7919. };
  7920. cc.generateTintImageWithMultiply = function(a, c, d, e) {
  7921. e = e || cc.newElement("canvas");
  7922. d = d || cc.rect(0, 0, a.width, a.height);
  7923. var f = e.getContext("2d");
  7924. e.width != d.width || e.height != d.height ? (e.width = d.width, e.height = d.height) : f.globalCompositeOperation = "source-over";
  7925. f.fillStyle = "rgb(" + c.r + "," + c.g + "," + c.b + ")";
  7926. f.fillRect(0, 0, d.width, d.height);
  7927. f.globalCompositeOperation = "multiply";
  7928. f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
  7929. f.globalCompositeOperation = "destination-atop";
  7930. f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
  7931. return e
  7932. };
  7933. cc.generateTintImage = function(a, c, d, e, f) {
  7934. e || (e = cc.rect(0, 0, a.width, a.height));
  7935. a = d.r / 255;
  7936. var g = d.g / 255;
  7937. d = d.b / 255;
  7938. var h = Math.min(e.width, c[0].width),
  7939. k = Math.min(e.height, c[0].height),
  7940. m;
  7941. 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"));
  7942. m.save();
  7943. m.globalCompositeOperation = "lighter";
  7944. var n = m.globalAlpha;
  7945. 0 < a && (m.globalAlpha = a * n, m.drawImage(c[0], e.x, e.y, h, k, 0, 0, h, k));
  7946. 0 < g && (m.globalAlpha = g * n, m.drawImage(c[1], e.x, e.y, h, k, 0, 0, h, k));
  7947. 0 < d && (m.globalAlpha = d * n, m.drawImage(c[2], e.x, e.y, h, k, 0, 0, h, k));
  7948. 1 > a + g + d && (m.globalAlpha = n, m.drawImage(c[3], e.x, e.y, h, k, 0, 0, h, k));
  7949. m.restore();
  7950. return f
  7951. };
  7952. cc.generateTextureCacheForColor = function(a) {
  7953. function c() {
  7954. var c = cc.generateTextureCacheForColor,
  7955. e = a.width,
  7956. h = a.height;
  7957. d[0].width = e;
  7958. d[0].height = h;
  7959. d[1].width = e;
  7960. d[1].height = h;
  7961. d[2].width = e;
  7962. d[2].height = h;
  7963. d[3].width = e;
  7964. d[3].height = h;
  7965. c.canvas.width = e;
  7966. c.canvas.height = h;
  7967. var k = c.canvas.getContext("2d");
  7968. k.drawImage(a, 0, 0);
  7969. c.tempCanvas.width = e;
  7970. c.tempCanvas.height = h;
  7971. for (var k = k.getImageData(0, 0, e, h).data, m = 0; 4 > m; m++) {
  7972. var n = d[m].getContext("2d");
  7973. n.getImageData(0, 0, e, h).data;
  7974. c.tempCtx.drawImage(a, 0, 0);
  7975. 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];
  7976. n.putImageData(q, 0, 0)
  7977. }
  7978. a.onload = null
  7979. }
  7980. if (a.channelCache) return a.channelCache;
  7981. var d = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")];
  7982. try {
  7983. c()
  7984. } catch (e) {
  7985. a.onload = c
  7986. }
  7987. return a.channelCache = d
  7988. };
  7989. cc.generateTextureCacheForColor.canvas = cc.newElement("canvas");
  7990. cc.generateTextureCacheForColor.tempCanvas = cc.newElement("canvas");
  7991. cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext("2d");
  7992. cc.cutRotateImageToCanvas = function(a, c) {
  7993. if (!a) return null;
  7994. if (!c) return a;
  7995. var d = cc.newElement("canvas");
  7996. d.width = c.width;
  7997. d.height = c.height;
  7998. var e = d.getContext("2d");
  7999. e.translate(d.width / 2, d.height / 2);
  8000. e.rotate(-1.5707963267948966);
  8001. e.drawImage(a, c.x, c.y, c.height, c.width, -c.height / 2, -c.width / 2, c.height, c.width);
  8002. return d
  8003. };
  8004. cc.Sprite = cc.Node.extend({
  8005. dirty: !1,
  8006. atlasIndex: 0,
  8007. textureAtlas: null,
  8008. _batchNode: null,
  8009. _recursiveDirty: null,
  8010. _hasChildren: null,
  8011. _shouldBeHidden: !1,
  8012. _transformToBatch: null,
  8013. _blendFunc: null,
  8014. _texture: null,
  8015. _rect: null,
  8016. _rectRotated: !1,
  8017. _offsetPosition: null,
  8018. _unflippedOffsetPositionFromCenter: null,
  8019. _opacityModifyRGB: !1,
  8020. _flippedX: !1,
  8021. _flippedY: !1,
  8022. _textureLoaded: !1,
  8023. _loadedEventListeners: null,
  8024. _newTextureWhenChangeColor: null,
  8025. _className: "Sprite",
  8026. _oldDisplayColor: cc.color.WHITE,
  8027. textureLoaded: function() {
  8028. return this._textureLoaded
  8029. },
  8030. addLoadedEventListener: function(a, c) {
  8031. this._loadedEventListeners || (this._loadedEventListeners = []);
  8032. this._loadedEventListeners.push({
  8033. eventCallback: a,
  8034. eventTarget: c
  8035. })
  8036. },
  8037. _callLoadedEventCallbacks: function() {
  8038. if (this._loadedEventListeners) {
  8039. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  8040. var e = a[c];
  8041. e.eventCallback.call(e.eventTarget, this)
  8042. }
  8043. a.length = 0
  8044. }
  8045. },
  8046. isDirty: function() {
  8047. return this.dirty
  8048. },
  8049. setDirty: function(a) {
  8050. this.dirty = a
  8051. },
  8052. isTextureRectRotated: function() {
  8053. return this._rectRotated
  8054. },
  8055. getAtlasIndex: function() {
  8056. return this.atlasIndex
  8057. },
  8058. setAtlasIndex: function(a) {
  8059. this.atlasIndex = a
  8060. },
  8061. getTextureRect: function() {
  8062. return cc.rect(this._rect.x, this._rect.y, this._rect.width, this._rect.height)
  8063. },
  8064. getTextureAtlas: function() {
  8065. return this.textureAtlas
  8066. },
  8067. setTextureAtlas: function(a) {
  8068. this.textureAtlas = a
  8069. },
  8070. getOffsetPosition: function() {
  8071. return cc.p(this._offsetPosition)
  8072. },
  8073. _getOffsetX: function() {
  8074. return this._offsetPosition.x
  8075. },
  8076. _getOffsetY: function() {
  8077. return this._offsetPosition.y
  8078. },
  8079. getBlendFunc: function() {
  8080. return this._blendFunc
  8081. },
  8082. initWithSpriteFrame: function(a) {
  8083. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrame);
  8084. a.textureLoaded() || (this._textureLoaded = !1, a.addLoadedEventListener(this._spriteFrameLoadedCallback, this));
  8085. var c = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated,
  8086. c = this.initWithTexture(a.getTexture(), a.getRect(), c);
  8087. this.setSpriteFrame(a);
  8088. return c
  8089. },
  8090. _spriteFrameLoadedCallback: null,
  8091. initWithSpriteFrameName: function(a) {
  8092. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName);
  8093. var c = cc.spriteFrameCache.getSpriteFrame(a);
  8094. cc.assert(c, a + cc._LogInfos.Sprite_initWithSpriteFrameName1);
  8095. return this.initWithSpriteFrame(c)
  8096. },
  8097. useBatchNode: function(a) {
  8098. this.textureAtlas = a.textureAtlas;
  8099. this._batchNode = a
  8100. },
  8101. setVertexRect: function(a) {
  8102. this._rect.x = a.x;
  8103. this._rect.y = a.y;
  8104. this._rect.width = a.width;
  8105. this._rect.height = a.height
  8106. },
  8107. sortAllChildren: function() {
  8108. if (this._reorderChildDirty) {
  8109. var a = this._children,
  8110. c = a.length,
  8111. d, e, f;
  8112. for (d = 1; d < c; d++) {
  8113. f = a[d];
  8114. for (e = d - 1; 0 <= e;) {
  8115. if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
  8116. else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
  8117. else break;
  8118. e--
  8119. }
  8120. a[e + 1] = f
  8121. }
  8122. this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node.StateCallbackType.sortAllChildren);
  8123. this._reorderChildDirty = !1
  8124. }
  8125. },
  8126. reorderChild: function(a, c) {
  8127. 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))
  8128. },
  8129. removeChild: function(a, c) {
  8130. this._batchNode && this._batchNode.removeSpriteFromAtlas(a);
  8131. cc.Node.prototype.removeChild.call(this, a, c)
  8132. },
  8133. setVisible: function(a) {
  8134. cc.Node.prototype.setVisible.call(this, a);
  8135. this.setDirtyRecursively(!0)
  8136. },
  8137. removeAllChildren: function(a) {
  8138. var c = this._children,
  8139. d = this._batchNode;
  8140. if (d && null != c)
  8141. for (var e = 0, f = c.length; e < f; e++) d.removeSpriteFromAtlas(c[e]);
  8142. cc.Node.prototype.removeAllChildren.call(this, a);
  8143. this._hasChildren = !1
  8144. },
  8145. setDirtyRecursively: function(a) {
  8146. this.dirty = this._recursiveDirty = a;
  8147. a = this._children;
  8148. for (var c, d = a ? a.length : 0, e = 0; e < d; e++) c = a[e], c instanceof cc.Sprite && c.setDirtyRecursively(!0)
  8149. },
  8150. setNodeDirty: function(a) {
  8151. cc.Node.prototype.setNodeDirty.call(this);
  8152. !a && (this._batchNode && !this._recursiveDirty) && (this._hasChildren ? this.setDirtyRecursively(!0) : this.dirty = this._recursiveDirty = !0)
  8153. },
  8154. ignoreAnchorPointForPosition: function(a) {
  8155. this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a)
  8156. },
  8157. setFlippedX: function(a) {
  8158. this._flippedX != a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  8159. },
  8160. setFlippedY: function(a) {
  8161. this._flippedY != a && (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  8162. },
  8163. isFlippedX: function() {
  8164. return this._flippedX
  8165. },
  8166. isFlippedY: function() {
  8167. return this._flippedY
  8168. },
  8169. setOpacityModifyRGB: null,
  8170. isOpacityModifyRGB: function() {
  8171. return this._opacityModifyRGB
  8172. },
  8173. updateDisplayedOpacity: null,
  8174. setDisplayFrameWithAnimationName: function(a, c) {
  8175. cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
  8176. var d = cc.animationCache.getAnimation(a);
  8177. d ? (d = d.getFrames()[c]) ? this.setSpriteFrame(d.getSpriteFrame()) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)
  8178. },
  8179. getBatchNode: function() {
  8180. return this._batchNode
  8181. },
  8182. _setReorderChildDirtyRecursively: function() {
  8183. if (!this._reorderChildDirty) {
  8184. this._reorderChildDirty = !0;
  8185. for (var a = this._parent; a && a != this._batchNode;) a._setReorderChildDirtyRecursively(), a = a.parent
  8186. }
  8187. },
  8188. getTexture: function() {
  8189. return this._texture
  8190. },
  8191. _quad: null,
  8192. _quadWebBuffer: null,
  8193. _quadDirty: !1,
  8194. _colorized: !1,
  8195. _isLighterMode: !1,
  8196. _originalTexture: null,
  8197. _textureRect_Canvas: null,
  8198. _drawSize_Canvas: null,
  8199. ctor: null,
  8200. _softInit: function(a, c, d) {
  8201. if (void 0 === a) cc.Sprite.prototype.init.call(this);
  8202. 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);
  8203. else if ("object" === typeof a)
  8204. if (a instanceof cc.Texture2D) this.initWithTexture(a, c, d);
  8205. else if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a);
  8206. else if (a instanceof HTMLImageElement || a instanceof HTMLCanvasElement) c = new cc.Texture2D, c.initWithElement(a), c.handleLoadedTexture(), this.initWithTexture(c)
  8207. },
  8208. getQuad: function() {
  8209. return this._quad
  8210. },
  8211. setBlendFunc: null,
  8212. init: null,
  8213. initWithFile: function(a, c) {
  8214. cc.assert(a, cc._LogInfos.Sprite_initWithFile);
  8215. var d = cc.textureCache.textureForKey(a);
  8216. if (d) {
  8217. if (!c) {
  8218. var e = d.getContentSize();
  8219. c = cc.rect(0, 0, e.width, e.height)
  8220. }
  8221. return this.initWithTexture(d, c)
  8222. }
  8223. d = cc.textureCache.addImage(a);
  8224. return this.initWithTexture(d, c || cc.rect(0, 0, d._contentSize.width, d._contentSize.height))
  8225. },
  8226. initWithTexture: null,
  8227. _textureLoadedCallback: null,
  8228. setTextureRect: null,
  8229. updateTransform: null,
  8230. addChild: null,
  8231. updateColor: function() {
  8232. var a = this._displayedColor,
  8233. c = this._displayedOpacity,
  8234. a = {
  8235. r: a.r,
  8236. g: a.g,
  8237. b: a.b,
  8238. a: c
  8239. };
  8240. this._opacityModifyRGB && (a.r *= c / 255, a.g *= c / 255, a.b *= c / 255);
  8241. c = this._quad;
  8242. c.bl.colors = a;
  8243. c.br.colors = a;
  8244. c.tl.colors = a;
  8245. c.tr.colors = a;
  8246. this._batchNode && (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED ? this.textureAtlas.updateQuad(c, this.atlasIndex) : this.dirty = !0);
  8247. this._quadDirty = !0
  8248. },
  8249. setOpacity: null,
  8250. setColor: null,
  8251. updateDisplayedColor: null,
  8252. setSpriteFrame: null,
  8253. setDisplayFrame: function(a) {
  8254. cc.log(cc._LogInfos.Sprite_setDisplayFrame);
  8255. this.setSpriteFrame(a)
  8256. },
  8257. isFrameDisplayed: null,
  8258. displayFrame: function() {
  8259. return cc.SpriteFrame.create(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize))
  8260. },
  8261. setBatchNode: null,
  8262. setTexture: null,
  8263. _updateBlendFunc: function() {
  8264. 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)
  8265. },
  8266. _changeTextureColor: function() {
  8267. var a, c = this._texture,
  8268. d = this._textureRect_Canvas;
  8269. 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)
  8270. },
  8271. _setTextureCoords: function(a) {
  8272. a = cc.rectPointsToPixels(a);
  8273. var c = this._batchNode ? this.textureAtlas.texture : this._texture;
  8274. if (c) {
  8275. var d = c.pixelsWidth,
  8276. e = c.pixelsHeight,
  8277. f, g = this._quad;
  8278. 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);
  8279. this._quadDirty = !0
  8280. }
  8281. },
  8282. draw: null
  8283. });
  8284. cc.Sprite.create = function(a, c, d) {
  8285. return new cc.Sprite(a, c, d)
  8286. };
  8287. cc.Sprite.createWithTexture = cc.Sprite.create;
  8288. cc.Sprite.createWithSpriteFrameName = cc.Sprite.create;
  8289. cc.Sprite.createWithSpriteFrame = cc.Sprite.create;
  8290. cc.Sprite.INDEX_NOT_INITIALIZED = -1;
  8291. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Sprite.prototype, _p._spriteFrameLoadedCallback = function(a) {
  8292. this.setNodeDirty(!0);
  8293. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8294. a = this.color;
  8295. (255 !== a.r || 255 !== a.g || 255 !== a.b) && this._changeTextureColor();
  8296. this._callLoadedEventCallbacks()
  8297. }, _p.setOpacityModifyRGB = function(a) {
  8298. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.setNodeDirty(!0))
  8299. }, _p.updateDisplayedOpacity = function(a) {
  8300. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  8301. this._setNodeDirtyForCache()
  8302. }, _p.ctor = function(a, c, d) {
  8303. cc.Node.prototype.ctor.call(this);
  8304. this._shouldBeHidden = !1;
  8305. this._offsetPosition = cc.p(0, 0);
  8306. this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
  8307. this._blendFunc = {
  8308. src: cc.BLEND_SRC,
  8309. dst: cc.BLEND_DST
  8310. };
  8311. this._rect = cc.rect(0, 0, 0, 0);
  8312. this._newTextureWhenChangeColor = !1;
  8313. this._textureLoaded = !0;
  8314. this._textureRect_Canvas = {
  8315. x: 0,
  8316. y: 0,
  8317. width: 0,
  8318. height: 0,
  8319. validRect: !1
  8320. };
  8321. this._drawSize_Canvas = cc.size(0, 0);
  8322. this._softInit(a, c, d)
  8323. }, _p.setBlendFunc = function(a, c) {
  8324. var d = this._blendFunc;
  8325. void 0 === c ? (d.src = a.src, d.dst = a.dst) : (d.src = a, d.dst = c);
  8326. this._isLighterMode = d && (d.src == cc.SRC_ALPHA && d.dst == cc.ONE || d.src == cc.ONE && d.dst == cc.ONE)
  8327. }, _p.init = function() {
  8328. if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
  8329. cc.Node.prototype.init.call(this);
  8330. this.dirty = this._recursiveDirty = !1;
  8331. this._opacityModifyRGB = !0;
  8332. this._blendFunc.src = cc.BLEND_SRC;
  8333. this._blendFunc.dst = cc.BLEND_DST;
  8334. this.texture = null;
  8335. this._textureLoaded = !0;
  8336. this._flippedX = this._flippedY = !1;
  8337. this.anchorY = this.anchorX = 0.5;
  8338. this._offsetPosition.x = 0;
  8339. this._offsetPosition.y = 0;
  8340. this._hasChildren = !1;
  8341. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  8342. return !0
  8343. }, _p.initWithTexture = function(a, c, d) {
  8344. cc.assert(0 != arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
  8345. if ((d = d || !1) && a.isLoaded()) {
  8346. var e = a.getHtmlElementObj(),
  8347. e = cc.cutRotateImageToCanvas(e, c),
  8348. f = new cc.Texture2D;
  8349. f.initWithElement(e);
  8350. f.handleLoadedTexture();
  8351. a = f;
  8352. this._rect = cc.rect(0, 0, c.width, c.height)
  8353. }
  8354. if (!cc.Node.prototype.init.call(this)) return !1;
  8355. this._batchNode = null;
  8356. this.dirty = this._recursiveDirty = !1;
  8357. this._opacityModifyRGB = !0;
  8358. this._blendFunc.src = cc.BLEND_SRC;
  8359. this._blendFunc.dst = cc.BLEND_DST;
  8360. this._flippedX = this._flippedY = !1;
  8361. this.anchorY = this.anchorX = 0.5;
  8362. this._offsetPosition.x = 0;
  8363. this._offsetPosition.y = 0;
  8364. this._hasChildren = !1;
  8365. this._textureLoaded = e = a.isLoaded();
  8366. 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;
  8367. c || (c = cc.rect(0, 0, a.width, a.height));
  8368. 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));
  8369. this.texture = this._originalTexture = a;
  8370. this.setTextureRect(c, d);
  8371. this.batchNode = null;
  8372. return !0
  8373. }, _p._textureLoadedCallback = function(a) {
  8374. if (!this._textureLoaded) {
  8375. this._textureLoaded = !0;
  8376. var c = this._rect;
  8377. c ? cc._rectEqualToZero(c) && (c.width = a.width, c.height = a.height) : c = cc.rect(0, 0, a.width, a.height);
  8378. this.texture = this._originalTexture = a;
  8379. this.setTextureRect(c, this._rectRotated);
  8380. a = this._displayedColor;
  8381. (255 != a.r || 255 != a.g || 255 != a.b) && this._changeTextureColor();
  8382. this.batchNode = this._batchNode;
  8383. this._callLoadedEventCallbacks()
  8384. }
  8385. }, _p.setTextureRect = function(a, c, d) {
  8386. this._rectRotated = c || !1;
  8387. this.setContentSize(d || a);
  8388. this.setVertexRect(a);
  8389. c = this._textureRect_Canvas;
  8390. d = cc.contentScaleFactor();
  8391. c.x = 0 | a.x * d;
  8392. c.y = 0 | a.y * d;
  8393. c.width = 0 | a.width * d;
  8394. c.height = 0 | a.height * d;
  8395. c.validRect = !(0 === c.width || 0 === c.height || 0 > c.x || 0 > c.y);
  8396. a = this._unflippedOffsetPositionFromCenter;
  8397. this._flippedX && (a.x = -a.x);
  8398. this._flippedY && (a.y = -a.y);
  8399. this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
  8400. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  8401. this._batchNode && (this.dirty = !0)
  8402. }, _p.updateTransform = function() {
  8403. if (this.dirty) {
  8404. var a = this._parent;
  8405. !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));
  8406. this.dirty = this._recursiveDirty = !1
  8407. }
  8408. this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform)
  8409. }, _p.addChild = function(a, c, d) {
  8410. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2);
  8411. null == c && (c = a._localZOrder);
  8412. null == d && (d = a.tag);
  8413. cc.Node.prototype.addChild.call(this, a, c, d);
  8414. this._hasChildren = !0
  8415. }, _p.setOpacity = function(a) {
  8416. cc.Node.prototype.setOpacity.call(this, a);
  8417. this._setNodeDirtyForCache()
  8418. }, _p.setColor = function(a) {
  8419. var c = this.color;
  8420. this._oldDisplayColor = c;
  8421. c.r === a.r && c.g === a.g && c.b === a.b || cc.Node.prototype.setColor.call(this, a)
  8422. }, _p.updateDisplayedColor = function(a) {
  8423. cc.Node.prototype.updateDisplayedColor.call(this, a);
  8424. a = this._oldDisplayColor;
  8425. var c = this._displayedColor;
  8426. a.r === c.r && a.g === c.g && a.b === c.b || (this._changeTextureColor(), this._setNodeDirtyForCache())
  8427. }, _p.setSpriteFrame = function(a) {
  8428. var c = this;
  8429. "string" == typeof a && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame));
  8430. c.setNodeDirty(!0);
  8431. var d = a.getOffset();
  8432. c._unflippedOffsetPositionFromCenter.x = d.x;
  8433. c._unflippedOffsetPositionFromCenter.y = d.y;
  8434. c._rectRotated = a.isRotated();
  8435. var d = a.getTexture(),
  8436. e = a.textureLoaded();
  8437. e || (c._textureLoaded = !1, a.addLoadedEventListener(function(a) {
  8438. c._textureLoaded = !0;
  8439. var d = a.getTexture();
  8440. d != c._texture && (c.texture = d);
  8441. c.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8442. c._callLoadedEventCallbacks()
  8443. }, c));
  8444. d != c._texture && (c.texture = d);
  8445. c._rectRotated && (c._originalTexture = d);
  8446. c.setTextureRect(a.getRect(), c._rectRotated, a.getOriginalSize());
  8447. c._colorized = !1;
  8448. e && (a = c.color, (255 !== a.r || 255 !== a.g || 255 !== a.b) && c._changeTextureColor())
  8449. }, _p.isFrameDisplayed = function(a) {
  8450. return a.getTexture() != this._texture ? !1 : cc.rectEqualToRect(a.getRect(), this._rect)
  8451. }, _p.setBatchNode = function(a) {
  8452. (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)
  8453. }, _p.setTexture = function(a) {
  8454. 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))
  8455. }, _p.draw = function(a) {
  8456. if (this._textureLoaded) {
  8457. a = a || cc._renderContext;
  8458. this._isLighterMode && (a.globalCompositeOperation = "lighter");
  8459. var c = cc.view.getScaleX(),
  8460. d = cc.view.getScaleY();
  8461. a.globalAlpha = this._displayedOpacity / 255;
  8462. var e = this._rect,
  8463. f = this._contentSize,
  8464. g = this._offsetPosition,
  8465. h = this._drawSize_Canvas,
  8466. k = 0 | g.x,
  8467. m = -g.y - e.height,
  8468. n = this._textureRect_Canvas;
  8469. h.width = e.width * c;
  8470. h.height = e.height * d;
  8471. 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));
  8472. k *= c;
  8473. m *= d;
  8474. 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));
  8475. 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));
  8476. (this._flippedX || this._flippedY) && a.restore();
  8477. cc.g_NumberOfDraws++
  8478. }
  8479. }, cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function() {
  8480. var a, c = this._texture,
  8481. d = this._textureRect_Canvas;
  8482. if (c && (d.validRect && this._originalTexture) && (a = c.getHtmlElementObj()))
  8483. 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)
  8484. }), delete _p) : (cc.assert("function" === typeof cc._tmp.WebGLSprite, cc._LogInfos.MissingFile, "SpritesWebGL.js"), cc._tmp.WebGLSprite(), delete cc._tmp.WebGLSprite);
  8485. cc.assert("function" === typeof cc._tmp.PrototypeSprite, cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
  8486. cc._tmp.PrototypeSprite();
  8487. delete cc._tmp.PrototypeSprite;
  8488. cc.DEFAULT_SPRITE_BATCH_CAPACITY = 29;
  8489. cc.SpriteBatchNode = cc.Node.extend({
  8490. textureAtlas: null,
  8491. _blendFunc: null,
  8492. _descendants: null,
  8493. _className: "SpriteBatchNode",
  8494. addSpriteWithoutQuad: function(a, c, d) {
  8495. cc.assert(a, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2);
  8496. if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad), null;
  8497. a.atlasIndex = c;
  8498. var e = 0,
  8499. f = this._descendants;
  8500. if (f && 0 < f.length)
  8501. for (var g = 0; g < f.length; g++) {
  8502. var h = f[g];
  8503. h && h.atlasIndex >= c && ++e
  8504. }
  8505. f.splice(e, 0, a);
  8506. cc.Node.prototype.addChild.call(this, a, c, d);
  8507. this.reorderBatch(!1);
  8508. return this
  8509. },
  8510. getTextureAtlas: function() {
  8511. return this.textureAtlas
  8512. },
  8513. setTextureAtlas: function(a) {
  8514. a != this.textureAtlas && (this.textureAtlas = a)
  8515. },
  8516. getDescendants: function() {
  8517. return this._descendants
  8518. },
  8519. initWithFile: function(a, c) {
  8520. var d = cc.textureCache.textureForKey(a);
  8521. d || (d = cc.textureCache.addImage(a));
  8522. return this.initWithTexture(d, c)
  8523. },
  8524. _setNodeDirtyForCache: function() {
  8525. this._cacheDirty = !0
  8526. },
  8527. init: function(a, c) {
  8528. var d = cc.textureCache.textureForKey(a);
  8529. d || (d = cc.textureCache.addImage(a));
  8530. return this.initWithTexture(d, c)
  8531. },
  8532. increaseAtlasCapacity: function() {
  8533. var a = this.textureAtlas.capacity,
  8534. c = Math.floor(4 * (a + 1) / 3);
  8535. cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, a, c);
  8536. this.textureAtlas.resizeCapacity(c) || cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)
  8537. },
  8538. removeChildAtIndex: function(a, c) {
  8539. this.removeChild(this._children[a], c)
  8540. },
  8541. rebuildIndexInOrder: function(a, c) {
  8542. var d = a.children;
  8543. if (d && 0 < d.length)
  8544. for (var e = 0; e < d.length; e++) {
  8545. var f = d[e];
  8546. f && 0 > f.zIndex && (c = this.rebuildIndexInOrder(f, c))
  8547. }!a == this && (a.atlasIndex = c, c++);
  8548. if (d && 0 < d.length)
  8549. for (e = 0; e < d.length; e++)(f = d[e]) && 0 <= f.zIndex && (c = this.rebuildIndexInOrder(f, c));
  8550. return c
  8551. },
  8552. highestAtlasIndexInChild: function(a) {
  8553. var c = a.children;
  8554. return !c || 0 == c.length ? a.atlasIndex : this.highestAtlasIndexInChild(c[c.length - 1])
  8555. },
  8556. lowestAtlasIndexInChild: function(a) {
  8557. var c = a.children;
  8558. return !c || 0 == c.length ? a.atlasIndex : this.lowestAtlasIndexInChild(c[c.length - 1])
  8559. },
  8560. atlasIndexForChild: function(a, c) {
  8561. var d = a.parent,
  8562. e = d.children,
  8563. f = e.indexOf(a),
  8564. g = null;
  8565. 0 < f && f < cc.UINT_MAX && (g = e[f - 1]);
  8566. 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
  8567. },
  8568. reorderBatch: function(a) {
  8569. this._reorderChildDirty = a
  8570. },
  8571. setBlendFunc: function(a, c) {
  8572. this._blendFunc = void 0 === c ? a : {
  8573. src: a,
  8574. dst: c
  8575. }
  8576. },
  8577. getBlendFunc: function() {
  8578. return this._blendFunc
  8579. },
  8580. reorderChild: function(a, c) {
  8581. 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())
  8582. },
  8583. removeChild: function(a, c) {
  8584. null != a && (-1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_removeChild) : (this.removeSpriteFromAtlas(a), cc.Node.prototype.removeChild.call(this, a, c)))
  8585. },
  8586. _mvpMatrix: null,
  8587. _textureForCanvas: null,
  8588. _useCache: !1,
  8589. _originalTexture: null,
  8590. ctor: null,
  8591. _ctorForCanvas: function(a, c) {
  8592. cc.Node.prototype.ctor.call(this);
  8593. var d;
  8594. c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8595. "string" == typeof a ? (d = cc.textureCache.textureForKey(a)) || (d = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (d = a);
  8596. d && this.initWithTexture(d, c)
  8597. },
  8598. _ctorForWebGL: function(a, c) {
  8599. cc.Node.prototype.ctor.call(this);
  8600. this._mvpMatrix = new cc.kmMat4;
  8601. var d;
  8602. c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8603. "string" == typeof a ? (d = cc.textureCache.textureForKey(a)) || (d = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (d = a);
  8604. d && this.initWithTexture(d, c)
  8605. },
  8606. updateQuadFromSprite: null,
  8607. _updateQuadFromSpriteForCanvas: function(a, c) {
  8608. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2);
  8609. a instanceof cc.Sprite ? (a.batchNode = this, a.atlasIndex = c, a.dirty = !0, a.updateTransform()) : cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
  8610. },
  8611. _updateQuadFromSpriteForWebGL: function(a, c) {
  8612. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite);
  8613. if (a instanceof cc.Sprite) {
  8614. for (var d = this.textureAtlas.capacity; c >= d || d == this.textureAtlas.totalQuads;) this.increaseAtlasCapacity();
  8615. a.batchNode = this;
  8616. a.atlasIndex = c;
  8617. a.dirty = !0;
  8618. a.updateTransform()
  8619. } else cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
  8620. },
  8621. _swap: function(a, c) {
  8622. var d = this._descendants,
  8623. e = this.textureAtlas,
  8624. f = e.quads,
  8625. g = d[a],
  8626. h = cc.V3F_C4B_T2F_QuadCopy(f[a]);
  8627. d[c].atlasIndex = a;
  8628. d[a] = d[c];
  8629. e.updateQuad(f[c], a);
  8630. d[c] = g;
  8631. e.updateQuad(h, c)
  8632. },
  8633. insertQuadFromSprite: null,
  8634. _insertQuadFromSpriteForCanvas: function(a, c) {
  8635. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2);
  8636. 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)
  8637. },
  8638. _insertQuadFromSpriteForWebGL: function(a, c) {
  8639. cc.assert(a, cc._LogInfos.Sprite_insertQuadFromSprite_2);
  8640. if (a instanceof cc.Sprite) {
  8641. for (var d = this.textureAtlas; c >= d.capacity || d.capacity === d.totalQuads;) this.increaseAtlasCapacity();
  8642. a.batchNode = this;
  8643. a.atlasIndex = c;
  8644. d.insertQuad(a.quad, c);
  8645. a.dirty = !0;
  8646. a.updateTransform()
  8647. } else cc.log(cc._LogInfos.Sprite_insertQuadFromSprite)
  8648. },
  8649. _updateAtlasIndex: function(a, c) {
  8650. var d = 0,
  8651. e = a.children;
  8652. e && (d = e.length);
  8653. var f = 0;
  8654. if (0 === d) f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++;
  8655. else {
  8656. f = !0;
  8657. 0 <= e[0].zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++, f = !1);
  8658. for (d = 0; d < e.length; d++) {
  8659. var g = e[d];
  8660. f && 0 <= g.zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++, f = !1);
  8661. c = this._updateAtlasIndex(g, c)
  8662. }
  8663. f && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f != c && this._swap(f, c), c++)
  8664. }
  8665. return c
  8666. },
  8667. _updateBlendFunc: function() {
  8668. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  8669. },
  8670. initWithTexture: null,
  8671. _initWithTextureForCanvas: function(a, c) {
  8672. this._children = [];
  8673. this._descendants = [];
  8674. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  8675. this._textureForCanvas = this._originalTexture = a;
  8676. return !0
  8677. },
  8678. _initWithTextureForWebGL: function(a, c) {
  8679. this._children = [];
  8680. this._descendants = [];
  8681. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  8682. c = c || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8683. this.textureAtlas = new cc.TextureAtlas;
  8684. this.textureAtlas.initWithTexture(a, c);
  8685. this._updateBlendFunc();
  8686. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  8687. return !0
  8688. },
  8689. insertChild: function(a, c) {
  8690. a.batchNode = this;
  8691. a.atlasIndex = c;
  8692. a.dirty = !0;
  8693. var d = this.textureAtlas;
  8694. d.totalQuads >= d.capacity && this.increaseAtlasCapacity();
  8695. d.insertQuad(a.quad, c);
  8696. this._descendants.splice(c, 0, a);
  8697. var d = c + 1,
  8698. e = this._descendants;
  8699. if (e && 0 < e.length)
  8700. for (; d < e.length; d++) e[d].atlasIndex++;
  8701. var e = a.children,
  8702. f;
  8703. if (e) {
  8704. d = 0;
  8705. for (l = e.length || 0; d < l; d++)
  8706. if (f = e[d]) {
  8707. var g = this.atlasIndexForChild(f, f.zIndex);
  8708. this.insertChild(f, g)
  8709. }
  8710. }
  8711. },
  8712. appendChild: null,
  8713. _appendChildForCanvas: function(a) {
  8714. this._reorderChildDirty = !0;
  8715. a.batchNode = this;
  8716. a.dirty = !0;
  8717. this._descendants.push(a);
  8718. a.atlasIndex = this._descendants.length - 1;
  8719. a = a.children;
  8720. for (var c = 0, d = a.length || 0; c < d; c++) this.appendChild(a[c])
  8721. },
  8722. _appendChildForWebGL: function(a) {
  8723. this._reorderChildDirty = !0;
  8724. a.batchNode = this;
  8725. a.dirty = !0;
  8726. this._descendants.push(a);
  8727. var c = this._descendants.length - 1;
  8728. a.atlasIndex = c;
  8729. var d = this.textureAtlas;
  8730. d.totalQuads == d.capacity && this.increaseAtlasCapacity();
  8731. d.insertQuad(a.quad, c);
  8732. a = a.children;
  8733. c = 0;
  8734. for (d = a.length || 0; c < d; c++) this.appendChild(a[c])
  8735. },
  8736. removeSpriteFromAtlas: null,
  8737. _removeSpriteFromAtlasForCanvas: function(a) {
  8738. a.batchNode = null;
  8739. var c = this._descendants,
  8740. d = c.indexOf(a);
  8741. if (-1 != d) {
  8742. c.splice(d, 1);
  8743. for (var e = c.length; d < e; ++d) c[d].atlasIndex--
  8744. }
  8745. if (a = a.children) {
  8746. c = 0;
  8747. for (d = a.length || 0; c < d; c++) a[c] && this.removeSpriteFromAtlas(a[c])
  8748. }
  8749. },
  8750. _removeSpriteFromAtlasForWebGL: function(a) {
  8751. this.textureAtlas.removeQuadAtIndex(a.atlasIndex);
  8752. a.batchNode = null;
  8753. var c = this._descendants,
  8754. d = c.indexOf(a);
  8755. if (-1 != d) {
  8756. c.splice(d, 1);
  8757. for (var e = c.length; d < e; ++d) c[d].atlasIndex--
  8758. }
  8759. if (a = a.children) {
  8760. c = 0;
  8761. for (d = a.length || 0; c < d; c++) a[c] && this.removeSpriteFromAtlas(a[c])
  8762. }
  8763. },
  8764. getTexture: null,
  8765. _getTextureForCanvas: function() {
  8766. return this._textureForCanvas
  8767. },
  8768. _getTextureForWebGL: function() {
  8769. return this.textureAtlas.texture
  8770. },
  8771. setTexture: null,
  8772. _setTextureForCanvas: function(a) {
  8773. this._textureForCanvas = a;
  8774. for (var c = this._children, d = 0; d < c.length; d++) c[d].texture = a
  8775. },
  8776. _setTextureForWebGL: function(a) {
  8777. this.textureAtlas.texture = a;
  8778. this._updateBlendFunc()
  8779. },
  8780. visit: null,
  8781. _visitForCanvas: function(a) {
  8782. var c = a || cc._renderContext;
  8783. if (this._visible) {
  8784. c.save();
  8785. this.transform(a);
  8786. var d = this._children;
  8787. if (d) {
  8788. this.sortAllChildren();
  8789. for (a = 0; a < d.length; a++) d[a] && d[a].visit(c)
  8790. }
  8791. c.restore()
  8792. }
  8793. },
  8794. _visitForWebGL: function(a) {
  8795. a = a || cc._renderContext;
  8796. if (this._visible) {
  8797. cc.kmGLPushMatrix();
  8798. var c = this.grid;
  8799. c && c.isActive() && (c.beforeDraw(), this.transformAncestors());
  8800. this.sortAllChildren();
  8801. this.transform(a);
  8802. this.draw(a);
  8803. c && c.isActive() && c.afterDraw(this);
  8804. cc.kmGLPopMatrix();
  8805. this.arrivalOrder = 0
  8806. }
  8807. },
  8808. addChild: null,
  8809. _addChildForCanvas: function(a, c, d) {
  8810. cc.assert(null != a, cc._LogInfos.CCSpriteBatchNode_addChild_3);
  8811. 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)
  8812. },
  8813. _addChildForWebGL: function(a, c, d) {
  8814. cc.assert(null != a, cc._LogInfos.Sprite_addChild_6);
  8815. 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)
  8816. },
  8817. removeAllChildren: null,
  8818. _removeAllChildrenForCanvas: function(a) {
  8819. var c = this._descendants;
  8820. if (c && 0 < c.length)
  8821. for (var d = 0, e = c.length; d < e; d++) c[d] && (c[d].batchNode = null);
  8822. cc.Node.prototype.removeAllChildren.call(this, a);
  8823. this._descendants.length = 0
  8824. },
  8825. _removeAllChildrenForWebGL: function(a) {
  8826. var c = this._descendants;
  8827. if (c && 0 < c.length)
  8828. for (var d = 0, e = c.length; d < e; d++) c[d] && (c[d].batchNode = null);
  8829. cc.Node.prototype.removeAllChildren.call(this, a);
  8830. this._descendants.length = 0;
  8831. this.textureAtlas.removeAllQuads()
  8832. },
  8833. sortAllChildren: null,
  8834. _sortAllChildrenForCanvas: function() {
  8835. if (this._reorderChildDirty) {
  8836. var a, c = 0,
  8837. d = this._children,
  8838. e = d.length,
  8839. f;
  8840. for (a = 1; a < e; a++) {
  8841. var g = d[a],
  8842. c = a - 1;
  8843. 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];
  8844. d[c + 1] = g
  8845. }
  8846. 0 < d.length && this._arrayMakeObjectsPerformSelector(d, cc.Node.StateCallbackType.sortAllChildren);
  8847. this._reorderChildDirty = !1
  8848. }
  8849. },
  8850. _sortAllChildrenForWebGL: function() {
  8851. if (this._reorderChildDirty) {
  8852. var a = this._children,
  8853. c, d = 0,
  8854. e = a.length,
  8855. f;
  8856. for (c = 1; c < e; c++) {
  8857. var g = a[c],
  8858. d = c - 1;
  8859. 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];
  8860. a[d + 1] = g
  8861. }
  8862. if (0 < a.length) {
  8863. this._arrayMakeObjectsPerformSelector(a, cc.Node.StateCallbackType.sortAllChildren);
  8864. for (c = d = 0; c < a.length; c++) d = this._updateAtlasIndex(a[c], d)
  8865. }
  8866. this._reorderChildDirty = !1
  8867. }
  8868. },
  8869. draw: null,
  8870. _drawForWebGL: function() {
  8871. 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())
  8872. }
  8873. });
  8874. _p = cc.SpriteBatchNode.prototype;
  8875. 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);
  8876. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  8877. cc.defineGetterSetter(_p, "descendants", _p.getDescendants);
  8878. cc.SpriteBatchNode.create = function(a, c) {
  8879. return new cc.SpriteBatchNode(a, c)
  8880. };
  8881. cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create;
  8882. cc.BakeSprite = cc.Sprite.extend({
  8883. _cacheCanvas: null,
  8884. _cacheContext: null,
  8885. ctor: function() {
  8886. cc.Sprite.prototype.ctor.call(this);
  8887. var a = document.createElement("canvas");
  8888. a.width = a.height = 10;
  8889. this._cacheCanvas = a;
  8890. this._cacheContext = a.getContext("2d");
  8891. var c = new cc.Texture2D;
  8892. c.initWithElement(a);
  8893. c.handleLoadedTexture();
  8894. this.setTexture(c)
  8895. },
  8896. getCacheContext: function() {
  8897. return this._cacheContext
  8898. },
  8899. getCacheCanvas: function() {
  8900. return this._cacheCanvas
  8901. },
  8902. resetCanvasSize: function(a, c) {
  8903. void 0 === c && (c = a.height, a = a.width);
  8904. var d = this._cacheCanvas;
  8905. d.width = a;
  8906. d.height = c;
  8907. this.getTexture().handleLoadedTexture();
  8908. this.setTextureRect(cc.rect(0, 0, a, c), !1)
  8909. }
  8910. });
  8911. cc.AnimationFrame = cc.Class.extend({
  8912. _spriteFrame: null,
  8913. _delayPerUnit: 0,
  8914. _userInfo: null,
  8915. ctor: function(a, c, d) {
  8916. this._spriteFrame = a || null;
  8917. this._delayPerUnit = c || 0;
  8918. this._userInfo = d || null
  8919. },
  8920. clone: function() {
  8921. var a = new cc.AnimationFrame;
  8922. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  8923. return a
  8924. },
  8925. copyWithZone: function(a) {
  8926. return cc.clone(this)
  8927. },
  8928. copy: function(a) {
  8929. a = new cc.AnimationFrame;
  8930. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  8931. return a
  8932. },
  8933. initWithSpriteFrame: function(a, c, d) {
  8934. this._spriteFrame = a;
  8935. this._delayPerUnit = c;
  8936. this._userInfo = d;
  8937. return !0
  8938. },
  8939. getSpriteFrame: function() {
  8940. return this._spriteFrame
  8941. },
  8942. setSpriteFrame: function(a) {
  8943. this._spriteFrame = a
  8944. },
  8945. getDelayUnits: function() {
  8946. return this._delayPerUnit
  8947. },
  8948. setDelayUnits: function(a) {
  8949. this._delayPerUnit = a
  8950. },
  8951. getUserInfo: function() {
  8952. return this._userInfo
  8953. },
  8954. setUserInfo: function(a) {
  8955. this._userInfo = a
  8956. }
  8957. });
  8958. cc.AnimationFrame.create = function(a, c, d) {
  8959. return new cc.AnimationFrame(a, c, d)
  8960. };
  8961. cc.Animation = cc.Class.extend({
  8962. _frames: null,
  8963. _loops: 0,
  8964. _restoreOriginalFrame: !1,
  8965. _duration: 0,
  8966. _delayPerUnit: 0,
  8967. _totalDelayUnits: 0,
  8968. ctor: function(a, c, d) {
  8969. this._frames = [];
  8970. if (void 0 === a) this.initWithSpriteFrames(null, 0);
  8971. else {
  8972. var e = a[0];
  8973. e && (e instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, c, d) : e instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, c, d))
  8974. }
  8975. },
  8976. getFrames: function() {
  8977. return this._frames
  8978. },
  8979. setFrames: function(a) {
  8980. this._frames = a
  8981. },
  8982. addSpriteFrame: function(a) {
  8983. var c = new cc.AnimationFrame;
  8984. c.initWithSpriteFrame(a, 1, null);
  8985. this._frames.push(c);
  8986. this._totalDelayUnits++
  8987. },
  8988. addSpriteFrameWithFile: function(a) {
  8989. a = cc.textureCache.addImage(a);
  8990. var c = cc.rect(0, 0, 0, 0);
  8991. c.width = a.width;
  8992. c.height = a.height;
  8993. a = cc.SpriteFrame.create(a, c);
  8994. this.addSpriteFrame(a)
  8995. },
  8996. addSpriteFrameWithTexture: function(a, c) {
  8997. var d = cc.SpriteFrame.create(a, c);
  8998. this.addSpriteFrame(d)
  8999. },
  9000. initWithAnimationFrames: function(a, c, d) {
  9001. cc.arrayVerifyType(a, cc.AnimationFrame);
  9002. this._delayPerUnit = c;
  9003. this._loops = void 0 === d ? 1 : d;
  9004. this._totalDelayUnits = 0;
  9005. c = this._frames;
  9006. for (d = c.length = 0; d < a.length; d++) {
  9007. var e = a[d];
  9008. c.push(e);
  9009. this._totalDelayUnits += e.getDelayUnits()
  9010. }
  9011. return !0
  9012. },
  9013. clone: function() {
  9014. var a = new cc.Animation;
  9015. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9016. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9017. return a
  9018. },
  9019. copyWithZone: function(a) {
  9020. a = new cc.Animation;
  9021. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9022. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9023. return a
  9024. },
  9025. _copyFrames: function() {
  9026. for (var a = [], c = 0; c < this._frames.length; c++) a.push(this._frames[c].clone());
  9027. return a
  9028. },
  9029. copy: function(a) {
  9030. return this.copyWithZone(null)
  9031. },
  9032. getLoops: function() {
  9033. return this._loops
  9034. },
  9035. setLoops: function(a) {
  9036. this._loops = a
  9037. },
  9038. setRestoreOriginalFrame: function(a) {
  9039. this._restoreOriginalFrame = a
  9040. },
  9041. getRestoreOriginalFrame: function() {
  9042. return this._restoreOriginalFrame
  9043. },
  9044. getDuration: function() {
  9045. return this._totalDelayUnits * this._delayPerUnit
  9046. },
  9047. getDelayPerUnit: function() {
  9048. return this._delayPerUnit
  9049. },
  9050. setDelayPerUnit: function(a) {
  9051. this._delayPerUnit = a
  9052. },
  9053. getTotalDelayUnits: function() {
  9054. return this._totalDelayUnits
  9055. },
  9056. initWithSpriteFrames: function(a, c, d) {
  9057. cc.arrayVerifyType(a, cc.SpriteFrame);
  9058. this._loops = void 0 === d ? 1 : d;
  9059. this._delayPerUnit = c || 0;
  9060. this._totalDelayUnits = 0;
  9061. c = this._frames;
  9062. c.length = 0;
  9063. if (a) {
  9064. for (d = 0; d < a.length; d++) {
  9065. var e = a[d],
  9066. f = new cc.AnimationFrame;
  9067. f.initWithSpriteFrame(e, 1, null);
  9068. c.push(f)
  9069. }
  9070. this._totalDelayUnits += a.length
  9071. }
  9072. return !0
  9073. },
  9074. retain: function() {},
  9075. release: function() {}
  9076. });
  9077. cc.Animation.create = function(a, c, d) {
  9078. return new cc.Animation(a, c, d)
  9079. };
  9080. cc.Animation.createWithAnimationFrames = cc.Animation.create;
  9081. cc.animationCache = {
  9082. _animations: {},
  9083. addAnimation: function(a, c) {
  9084. this._animations[c] = a
  9085. },
  9086. removeAnimation: function(a) {
  9087. a && this._animations[a] && delete this._animations[a]
  9088. },
  9089. getAnimation: function(a) {
  9090. return this._animations[a] ? this._animations[a] : null
  9091. },
  9092. _addAnimationsWithDictionary: function(a, c) {
  9093. var d = a.animations;
  9094. if (d) {
  9095. var e = 1,
  9096. f = a.properties;
  9097. if (f)
  9098. 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]));
  9099. switch (e) {
  9100. case 1:
  9101. this._parseVersion1(d);
  9102. break;
  9103. case 2:
  9104. this._parseVersion2(d);
  9105. break;
  9106. default:
  9107. cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)
  9108. }
  9109. } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)
  9110. },
  9111. addAnimations: function(a) {
  9112. cc.assert(a, cc._LogInfos.animationCache_addAnimations_2);
  9113. var c = cc.loader.getRes(a);
  9114. c ? this._addAnimationsWithDictionary(c, a) : cc.log(cc._LogInfos.animationCache_addAnimations)
  9115. },
  9116. _parseVersion1: function(a) {
  9117. var c = cc.spriteFrameCache,
  9118. d;
  9119. for (d in a) {
  9120. var e = a[d],
  9121. f = e.frames,
  9122. e = parseFloat(e.delay) || 0,
  9123. g = null;
  9124. if (f) {
  9125. for (var g = [], h = 0; h < f.length; h++) {
  9126. var k = c.getSpriteFrame(f[h]);
  9127. if (k) {
  9128. var m = new cc.AnimationFrame;
  9129. m.initWithSpriteFrame(k, 1, null);
  9130. g.push(m)
  9131. } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, d, f[h])
  9132. }
  9133. 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))
  9134. } else cc.log(cc._LogInfos.animationCache__parseVersion1, d)
  9135. }
  9136. },
  9137. _parseVersion2: function(a) {
  9138. var c = cc.spriteFrameCache,
  9139. d;
  9140. for (d in a) {
  9141. var e = a[d],
  9142. f = e.loop,
  9143. g = parseInt(e.loops),
  9144. f = f ? cc.REPEAT_FOREVER : isNaN(g) ? 1 : g,
  9145. g = e.restoreOriginalFrame && !0 == e.restoreOriginalFrame ? !0 : !1,
  9146. h = e.frames;
  9147. if (h) {
  9148. for (var k = [], m = 0; m < h.length; m++) {
  9149. var n = h[m],
  9150. q = n.spriteframe,
  9151. r = c.getSpriteFrame(q);
  9152. if (r) {
  9153. var q = parseFloat(n.delayUnits) || 0,
  9154. n = n.notification,
  9155. t = new cc.AnimationFrame;
  9156. t.initWithSpriteFrame(r, q, n);
  9157. k.push(t)
  9158. } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, d, q)
  9159. }
  9160. e = parseFloat(e.delayPerUnit) || 0;
  9161. h = new cc.Animation;
  9162. h.initWithAnimationFrames(k, e, f);
  9163. h.setRestoreOriginalFrame(g);
  9164. cc.animationCache.addAnimation(h, d)
  9165. } else cc.log(cc._LogInfos.animationCache__parseVersion2, d)
  9166. }
  9167. },
  9168. _clear: function() {
  9169. this._animations = {}
  9170. }
  9171. };
  9172. cc.SpriteFrame = cc.Class.extend({
  9173. _offset: null,
  9174. _originalSize: null,
  9175. _rectInPixels: null,
  9176. _rotated: !1,
  9177. _rect: null,
  9178. _offsetInPixels: null,
  9179. _originalSizeInPixels: null,
  9180. _texture: null,
  9181. _textureFilename: "",
  9182. _textureLoaded: !1,
  9183. _eventListeners: null,
  9184. ctor: function(a, c, d, e, f) {
  9185. this._offset = cc.p(0, 0);
  9186. this._offsetInPixels = cc.p(0, 0);
  9187. this._originalSize = cc.size(0, 0);
  9188. this._rotated = !1;
  9189. this._originalSizeInPixels = cc.size(0, 0);
  9190. this._textureFilename = "";
  9191. this._texture = null;
  9192. this._textureLoaded = !1;
  9193. 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))
  9194. },
  9195. textureLoaded: function() {
  9196. return this._textureLoaded
  9197. },
  9198. addLoadedEventListener: function(a, c) {
  9199. null == this._eventListeners && (this._eventListeners = []);
  9200. this._eventListeners.push({
  9201. eventCallback: a,
  9202. eventTarget: c
  9203. })
  9204. },
  9205. _callLoadedEventCallbacks: function() {
  9206. var a = this._eventListeners;
  9207. if (a) {
  9208. for (var c = 0, d = a.length; c < d; c++) {
  9209. var e = a[c];
  9210. e.eventCallback.call(e.eventTarget, this)
  9211. }
  9212. a.length = 0
  9213. }
  9214. },
  9215. getRectInPixels: function() {
  9216. var a = this._rectInPixels;
  9217. return cc.rect(a.x, a.y, a.width, a.height)
  9218. },
  9219. setRectInPixels: function(a) {
  9220. this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0));
  9221. this._rectInPixels.x = a.x;
  9222. this._rectInPixels.y = a.y;
  9223. this._rectInPixels.width = a.width;
  9224. this._rectInPixels.height = a.height;
  9225. this._rect = cc.rectPixelsToPoints(a)
  9226. },
  9227. isRotated: function() {
  9228. return this._rotated
  9229. },
  9230. setRotated: function(a) {
  9231. this._rotated = a
  9232. },
  9233. getRect: function() {
  9234. var a = this._rect;
  9235. return cc.rect(a.x, a.y, a.width, a.height)
  9236. },
  9237. setRect: function(a) {
  9238. this._rect || (this._rect = cc.rect(0, 0, 0, 0));
  9239. this._rect.x = a.x;
  9240. this._rect.y = a.y;
  9241. this._rect.width = a.width;
  9242. this._rect.height = a.height;
  9243. this._rectInPixels = cc.rectPointsToPixels(this._rect)
  9244. },
  9245. getOffsetInPixels: function() {
  9246. return cc.p(this._offsetInPixels)
  9247. },
  9248. setOffsetInPixels: function(a) {
  9249. this._offsetInPixels.x = a.x;
  9250. this._offsetInPixels.y = a.y;
  9251. cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset)
  9252. },
  9253. getOriginalSizeInPixels: function() {
  9254. return cc.size(this._originalSizeInPixels)
  9255. },
  9256. setOriginalSizeInPixels: function(a) {
  9257. this._originalSizeInPixels.width = a.width;
  9258. this._originalSizeInPixels.height = a.height
  9259. },
  9260. getOriginalSize: function() {
  9261. return cc.size(this._originalSize)
  9262. },
  9263. setOriginalSize: function(a) {
  9264. this._originalSize.width = a.width;
  9265. this._originalSize.height = a.height
  9266. },
  9267. getTexture: function() {
  9268. if (this._texture) return this._texture;
  9269. if ("" !== this._textureFilename) {
  9270. var a = cc.textureCache.addImage(this._textureFilename);
  9271. a && (this._textureLoaded = a.isLoaded());
  9272. return a
  9273. }
  9274. return null
  9275. },
  9276. setTexture: function(a) {
  9277. if (this._texture != a) {
  9278. var c = a.isLoaded();
  9279. this._textureLoaded = c;
  9280. this._texture = a;
  9281. c || a.addLoadedEventListener(function(a) {
  9282. this._textureLoaded = !0;
  9283. if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) {
  9284. var c = a.getHtmlElementObj(),
  9285. c = cc.cutRotateImageToCanvas(c, this.getRect()),
  9286. f = new cc.Texture2D;
  9287. f.initWithElement(c);
  9288. f.handleLoadedTexture();
  9289. this.setTexture(f);
  9290. c = this.getRect();
  9291. this.setRect(cc.rect(0, 0, c.width, c.height))
  9292. }
  9293. c = this._rect;
  9294. 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);
  9295. this._callLoadedEventCallbacks()
  9296. }, this)
  9297. }
  9298. },
  9299. getOffset: function() {
  9300. return cc.p(this._offset)
  9301. },
  9302. setOffset: function(a) {
  9303. this._offset.x = a.x;
  9304. this._offset.y = a.y
  9305. },
  9306. clone: function() {
  9307. var a = new cc.SpriteFrame;
  9308. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  9309. a.setTexture(this._texture);
  9310. return a
  9311. },
  9312. copyWithZone: function() {
  9313. var a = new cc.SpriteFrame;
  9314. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  9315. a.setTexture(this._texture);
  9316. return a
  9317. },
  9318. copy: function() {
  9319. return this.copyWithZone()
  9320. },
  9321. initWithTexture: function(a, c, d, e, f) {
  9322. 2 === arguments.length && (c = cc.rectPointsToPixels(c));
  9323. e = e || cc.p(0, 0);
  9324. f = f || c;
  9325. d = d || !1;
  9326. "string" == typeof a ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a);
  9327. if ((a = this.getTexture()) && a.url) {
  9328. var g, h;
  9329. d ? (g = c.x + c.height, h = c.y + c.width) : (g = c.x + c.width, h = c.y + c.height);
  9330. g > a.width && cc.error(cc._LogInfos.RectWidth, a.url);
  9331. h > a.height && cc.error(cc._LogInfos.RectHeight, a.url)
  9332. }
  9333. this._rectInPixels = c;
  9334. this._rect = cc.rectPixelsToPoints(c);
  9335. this._offsetInPixels.x = e.x;
  9336. this._offsetInPixels.y = e.y;
  9337. cc._pointPixelsToPointsOut(e, this._offset);
  9338. this._originalSizeInPixels.width = f.width;
  9339. this._originalSizeInPixels.height = f.height;
  9340. cc._sizePixelsToPointsOut(f, this._originalSize);
  9341. this._rotated = d;
  9342. return !0
  9343. }
  9344. });
  9345. cc.SpriteFrame.create = function(a, c, d, e, f) {
  9346. return new cc.SpriteFrame(a, c, d, e, f)
  9347. };
  9348. cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create;
  9349. cc.SpriteFrame._frameWithTextureForCanvas = function(a, c, d, e, f) {
  9350. var g = new cc.SpriteFrame;
  9351. g._texture = a;
  9352. g._rectInPixels = c;
  9353. g._rect = cc.rectPixelsToPoints(c);
  9354. g._offsetInPixels.x = e.x;
  9355. g._offsetInPixels.y = e.y;
  9356. cc._pointPixelsToPointsOut(g._offsetInPixels, g._offset);
  9357. g._originalSizeInPixels.width = f.width;
  9358. g._originalSizeInPixels.height = f.height;
  9359. cc._sizePixelsToPointsOut(g._originalSizeInPixels, g._originalSize);
  9360. g._rotated = d;
  9361. return g
  9362. };
  9363. cc.spriteFrameCache = {
  9364. _CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,
  9365. _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,
  9366. _spriteFrames: {},
  9367. _spriteFramesAliases: {},
  9368. _frameConfigCache: {},
  9369. _rectFromString: function(a) {
  9370. a = this._CCNS_REG2.exec(a);
  9371. return !a ? cc.rect(0, 0, 0, 0) : cc.rect(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]), parseFloat(a[4]))
  9372. },
  9373. _pointFromString: function(a) {
  9374. a = this._CCNS_REG1.exec(a);
  9375. return !a ? cc.p(0, 0) : cc.p(parseFloat(a[1]), parseFloat(a[2]))
  9376. },
  9377. _sizeFromString: function(a) {
  9378. a = this._CCNS_REG1.exec(a);
  9379. return !a ? cc.size(0, 0) : cc.size(parseFloat(a[1]), parseFloat(a[2]))
  9380. },
  9381. _getFrameConfig: function(a) {
  9382. var c = cc.loader.getRes(a);
  9383. cc.assert(c, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a);
  9384. cc.loader.release(a);
  9385. if (c._inited) return this._frameConfigCache[a] = c;
  9386. var d = c.frames,
  9387. e = c.metadata || c.meta,
  9388. c = {},
  9389. f = {},
  9390. g = 0;
  9391. e && (g = e.format, g = 1 >= g.length ? parseInt(g) : g, f.image = e.textureFileName || e.textureFileName || e.image);
  9392. for (var h in d) {
  9393. var k = d[h];
  9394. if (k) {
  9395. e = {};
  9396. if (0 == g) {
  9397. e.rect = cc.rect(k.x, k.y, k.width, k.height);
  9398. e.rotated = !1;
  9399. e.offset = cc.p(k.offsetX, k.offsetY);
  9400. var m = k.originalWidth,
  9401. k = k.originalHeight;
  9402. (!m || !k) && cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);
  9403. m = Math.abs(m);
  9404. k = Math.abs(k);
  9405. e.size = cc.size(m, k)
  9406. } 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);
  9407. else if (3 == g) {
  9408. var m = this._sizeFromString(k.spriteSize),
  9409. n = this._rectFromString(k.textureRect);
  9410. m && (n = cc.rect(n.x, n.y, m.width, m.height));
  9411. e.rect = n;
  9412. e.rotated = k.textureRotated || !1;
  9413. e.offset = this._pointFromString(k.spriteOffset);
  9414. e.size = this._sizeFromString(k.spriteSourceSize);
  9415. e.aliases = k.aliases
  9416. } 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);
  9417. c[h] = e
  9418. }
  9419. }
  9420. return this._frameConfigCache[a] = {
  9421. _inited: !0,
  9422. frames: c,
  9423. meta: f
  9424. }
  9425. },
  9426. addSpriteFrames: function(a, c) {
  9427. cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
  9428. var d = this._frameConfigCache[a] || cc.loader.getRes(a);
  9429. if (d && d.frames) {
  9430. var e = this._frameConfigCache[a] || this._getFrameConfig(a),
  9431. d = e.frames,
  9432. e = e.meta;
  9433. 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));
  9434. var e = this._spriteFramesAliases,
  9435. f = this._spriteFrames,
  9436. g;
  9437. for (g in d) {
  9438. var h = d[g],
  9439. k = f[g];
  9440. if (!k) {
  9441. k = cc.SpriteFrame.create(c, h.rect, h.rotated, h.offset, h.size);
  9442. if (h = h.aliases)
  9443. for (var m = 0, n = h.length; m < n; m++) {
  9444. var q = h[m];
  9445. e[q] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, q);
  9446. e[q] = g
  9447. }
  9448. 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)));
  9449. f[g] = k
  9450. }
  9451. }
  9452. }
  9453. },
  9454. _checkConflict: function(a) {
  9455. a = a.frames;
  9456. for (var c in a) this._spriteFrames[c] && cc.log(cc._LogInfos.spriteFrameCache__checkConflict, c)
  9457. },
  9458. addSpriteFrame: function(a, c) {
  9459. this._spriteFrames[c] = a
  9460. },
  9461. removeSpriteFrames: function() {
  9462. this._spriteFrames = {};
  9463. this._spriteFramesAliases = {}
  9464. },
  9465. removeSpriteFrameByName: function(a) {
  9466. a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a])
  9467. },
  9468. removeSpriteFramesFromFile: function(a) {
  9469. var c = this._spriteFrames,
  9470. d = this._spriteFramesAliases;
  9471. if (a = this._frameConfigCache[a]) {
  9472. a = a.frames;
  9473. for (var e in a)
  9474. if (c[e]) {
  9475. delete c[e];
  9476. for (var f in d) d[f] == e && delete d[f]
  9477. }
  9478. }
  9479. },
  9480. removeSpriteFramesFromTexture: function(a) {
  9481. var c = this._spriteFrames,
  9482. d = this._spriteFramesAliases,
  9483. e;
  9484. for (e in c) {
  9485. var f = c[e];
  9486. if (f && f.getTexture() == a) {
  9487. delete c[e];
  9488. for (var g in d) d[g] == e && delete d[g]
  9489. }
  9490. }
  9491. },
  9492. getSpriteFrame: function(a) {
  9493. var c = this._spriteFrames[a];
  9494. if (!c) {
  9495. var d = this._spriteFramesAliases[a];
  9496. d && ((c = this._spriteFrames[d.toString()]) || delete this._spriteFramesAliases[a])
  9497. }
  9498. c || cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame, a);
  9499. return c
  9500. },
  9501. _clear: function() {
  9502. this._spriteFrames = {};
  9503. this._spriteFramesAliases = {};
  9504. this._frameConfigCache = {}
  9505. }
  9506. };
  9507. cc.configuration = {
  9508. ERROR: 0,
  9509. STRING: 1,
  9510. INT: 2,
  9511. DOUBLE: 3,
  9512. BOOLEAN: 4,
  9513. _maxTextureSize: 0,
  9514. _maxModelviewStackDepth: 0,
  9515. _supportsPVRTC: !1,
  9516. _supportsNPOT: !1,
  9517. _supportsBGRA8888: !1,
  9518. _supportsDiscardFramebuffer: !1,
  9519. _supportsShareableVAO: !1,
  9520. _maxSamplesAllowed: 0,
  9521. _maxTextureUnits: 0,
  9522. _GlExtensions: "",
  9523. _valueDict: {},
  9524. _inited: !1,
  9525. _init: function() {
  9526. var a = this._valueDict;
  9527. a["cocos2d.x.version"] = cc.ENGINE_VERSION;
  9528. a["cocos2d.x.compiled_with_profiler"] = !1;
  9529. a["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
  9530. this._inited = !0
  9531. },
  9532. getMaxTextureSize: function() {
  9533. return this._maxTextureSize
  9534. },
  9535. getMaxModelviewStackDepth: function() {
  9536. return this._maxModelviewStackDepth
  9537. },
  9538. getMaxTextureUnits: function() {
  9539. return this._maxTextureUnits
  9540. },
  9541. supportsNPOT: function() {
  9542. return this._supportsNPOT
  9543. },
  9544. supportsPVRTC: function() {
  9545. return this._supportsPVRTC
  9546. },
  9547. supportsETC: function() {
  9548. return !1
  9549. },
  9550. supportsS3TC: function() {
  9551. return !1
  9552. },
  9553. supportsATITC: function() {
  9554. return !1
  9555. },
  9556. supportsBGRA8888: function() {
  9557. return this._supportsBGRA8888
  9558. },
  9559. supportsDiscardFramebuffer: function() {
  9560. return this._supportsDiscardFramebuffer
  9561. },
  9562. supportsShareableVAO: function() {
  9563. return this._supportsShareableVAO
  9564. },
  9565. checkForGLExtension: function(a) {
  9566. return -1 < this._GlExtensions.indexOf(a)
  9567. },
  9568. getValue: function(a, c) {
  9569. this._inited || this._init();
  9570. var d = this._valueDict;
  9571. return d[a] ? d[a] : c
  9572. },
  9573. setValue: function(a, c) {
  9574. this._valueDict[a] = c
  9575. },
  9576. dumpInfo: function() {
  9577. 0 === cc.ENABLE_GL_STATE_CACHE && (cc.log(""), cc.log(cc._LogInfos.configuration_dumpInfo), cc.log(""))
  9578. },
  9579. gatherGPUInfo: function() {
  9580. if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
  9581. this._inited || this._init();
  9582. var a = cc._renderContext,
  9583. c = this._valueDict;
  9584. c["gl.vendor"] = a.getParameter(a.VENDOR);
  9585. c["gl.renderer"] = a.getParameter(a.RENDERER);
  9586. c["gl.version"] = a.getParameter(a.VERSION);
  9587. this._GlExtensions = "";
  9588. for (var d = a.getSupportedExtensions(), e = 0; e < d.length; e++) this._GlExtensions += d[e] + " ";
  9589. this._maxTextureSize = a.getParameter(a.MAX_TEXTURE_SIZE);
  9590. c["gl.max_texture_size"] = this._maxTextureSize;
  9591. this._maxTextureUnits = a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  9592. c["gl.max_texture_units"] = this._maxTextureUnits;
  9593. this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
  9594. c["gl.supports_PVRTC"] = this._supportsPVRTC;
  9595. this._supportsNPOT = !1;
  9596. c["gl.supports_NPOT"] = this._supportsNPOT;
  9597. this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888");
  9598. c["gl.supports_BGRA8888"] = this._supportsBGRA8888;
  9599. this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer");
  9600. c["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer;
  9601. this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object");
  9602. c["gl.supports_vertex_array_object"] = this._supportsShareableVAO;
  9603. cc.checkGLErrorDebug()
  9604. }
  9605. },
  9606. loadConfigFile: function(a) {
  9607. this._inited || this._init();
  9608. var c = cc.loader.getRes(a);
  9609. if (!c) throw "Please load the resource first : " + a;
  9610. cc.assert(c, cc._LogInfos.configuration_loadConfigFile_2, a);
  9611. if (c = c.data)
  9612. for (var d in c) this._valueDict[d] = c[d];
  9613. else cc.log(cc._LogInfos.configuration_loadConfigFile, a)
  9614. }
  9615. };
  9616. cc._tmp.DirectorWebGL = function() {
  9617. cc.DirectorDelegate = cc.Class.extend({
  9618. updateProjection: function() {}
  9619. });
  9620. var a = cc.Director.prototype;
  9621. a.setProjection = function(a) {
  9622. var d = this._winSizeInPoints;
  9623. this.setViewport();
  9624. var e = this._openGLView,
  9625. f = e._viewPortRect.x / e._scaleX,
  9626. g = e._viewPortRect.y / e._scaleY;
  9627. switch (a) {
  9628. case cc.Director.PROJECTION_2D:
  9629. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  9630. cc.kmGLLoadIdentity();
  9631. e = new cc.kmMat4;
  9632. cc.kmMat4OrthographicProjection(e, 0, d.width, 0, d.height, -1024, 1024);
  9633. cc.kmGLMultMatrix(e);
  9634. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  9635. cc.kmGLLoadIdentity();
  9636. break;
  9637. case cc.Director.PROJECTION_3D:
  9638. var h = this.getZEye(),
  9639. k = new cc.kmMat4,
  9640. e = new cc.kmMat4;
  9641. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  9642. cc.kmGLLoadIdentity();
  9643. cc.kmMat4PerspectiveProjection(k, 60, d.width / d.height, 0.1, 2 * h);
  9644. cc.kmGLMultMatrix(k);
  9645. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  9646. cc.kmGLLoadIdentity();
  9647. h = cc.kmVec3Fill(null, -f + d.width / 2, -g + d.height / 2, h);
  9648. d = cc.kmVec3Fill(null, -f + d.width / 2, -g + d.height / 2, 0);
  9649. f = cc.kmVec3Fill(null, 0, 1, 0);
  9650. cc.kmMat4LookAt(e, h, d, f);
  9651. cc.kmGLMultMatrix(e);
  9652. break;
  9653. case cc.Director.PROJECTION_CUSTOM:
  9654. this._projectionDelegate && this._projectionDelegate.updateProjection();
  9655. break;
  9656. default:
  9657. cc.log(cc._LogInfos.Director_setProjection)
  9658. }
  9659. this._projection = a;
  9660. cc.eventManager.dispatchEvent(this._eventProjectionChanged);
  9661. cc.setProjectionMatrixDirty()
  9662. };
  9663. a.setDepthTest = function(a) {
  9664. var d = cc._renderContext;
  9665. a ? (d.clearDepth(1), d.enable(d.DEPTH_TEST), d.depthFunc(d.LEQUAL)) : d.disable(d.DEPTH_TEST)
  9666. };
  9667. a.setOpenGLView = function(a) {
  9668. this._winSizeInPoints.width = cc._canvas.width;
  9669. this._winSizeInPoints.height = cc._canvas.height;
  9670. this._openGLView = a || cc.view;
  9671. a = cc.configuration;
  9672. a.gatherGPUInfo();
  9673. a.dumpInfo();
  9674. this._createStatsLabel();
  9675. this.setGLDefaultValues();
  9676. cc.eventManager && cc.eventManager.setEnabled(!0)
  9677. };
  9678. a._clear = function() {
  9679. var a = cc._renderContext;
  9680. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
  9681. };
  9682. a._beforeVisitScene = function() {
  9683. cc.kmGLPushMatrix()
  9684. };
  9685. a._afterVisitScene = function() {
  9686. cc.kmGLPopMatrix()
  9687. };
  9688. a._createStatsLabel = function() {
  9689. if (cc.LabelAtlas) {
  9690. if (!(null == cc.Director._fpsImageLoaded || !1 == cc.Director._fpsImageLoaded)) {
  9691. var a = new cc.Texture2D;
  9692. a.initWithElement(cc.Director._fpsImage);
  9693. a.handleLoadedTexture();
  9694. var d = cc.view.getDesignResolutionSize().height / 320;
  9695. 0 === d && (d = this._winSizeInPoints.height / 320);
  9696. var e = new cc.LabelAtlas;
  9697. e._setIgnoreContentScaleFactor(!0);
  9698. e.initWithString("00.0", a, 12, 32, ".");
  9699. e.scale = d;
  9700. this._FPSLabel = e;
  9701. e = new cc.LabelAtlas;
  9702. e._setIgnoreContentScaleFactor(!0);
  9703. e.initWithString("0.000", a, 12, 32, ".");
  9704. e.scale = d;
  9705. this._SPFLabel = e;
  9706. e = new cc.LabelAtlas;
  9707. e._setIgnoreContentScaleFactor(!0);
  9708. e.initWithString("000", a, 12, 32, ".");
  9709. e.scale = d;
  9710. this._drawsLabel = e;
  9711. a = cc.DIRECTOR_STATS_POSITION;
  9712. this._drawsLabel.setPosition(a.x, 34 * d + a.y);
  9713. this._SPFLabel.setPosition(a.x, 17 * d + a.y);
  9714. this._FPSLabel.setPosition(a)
  9715. }
  9716. } else this._createStatsLabelForCanvas()
  9717. };
  9718. a._createStatsLabelForCanvas = function() {
  9719. var a = 0,
  9720. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | 24 * (this._winSizeInPoints.height / 320) : 0 | 24 * (this._winSizeInPoints.width / 320);
  9721. this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
  9722. this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
  9723. this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
  9724. a = cc.DIRECTOR_STATS_POSITION;
  9725. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  9726. this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  9727. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  9728. };
  9729. a.convertToGL = function(a) {
  9730. var d = new cc.kmMat4;
  9731. cc.GLToClipTransform(d);
  9732. var e = new cc.kmMat4;
  9733. cc.kmMat4Inverse(e, d);
  9734. var d = d.mat[14] / d.mat[15],
  9735. f = this._openGLView.getDesignResolutionSize();
  9736. a = new cc.kmVec3(2 * a.x / f.width - 1, 1 - 2 * a.y / f.height, d);
  9737. d = new cc.kmVec3;
  9738. cc.kmVec3TransformCoord(d, a, e);
  9739. return cc.p(d.x, d.y)
  9740. };
  9741. a.convertToUI = function(a) {
  9742. var d = new cc.kmMat4;
  9743. cc.GLToClipTransform(d);
  9744. var e = new cc.kmVec3;
  9745. a = new cc.kmVec3(a.x, a.y, 0);
  9746. cc.kmVec3TransformCoord(e, a, d);
  9747. d = this._openGLView.getDesignResolutionSize();
  9748. return cc.p(d.width * (0.5 * e.x + 0.5), d.height * (0.5 * -e.y + 0.5))
  9749. };
  9750. a.getVisibleSize = function() {
  9751. return this._openGLView.getVisibleSize()
  9752. };
  9753. a.getVisibleOrigin = function() {
  9754. return this._openGLView.getVisibleOrigin()
  9755. };
  9756. a.getZEye = function() {
  9757. return this._winSizeInPoints.height / 1.1566
  9758. };
  9759. a.setViewport = function() {
  9760. var a = this._openGLView;
  9761. if (a) {
  9762. var d = this._winSizeInPoints;
  9763. a.setViewPortInPoints(-a._viewPortRect.x / a._scaleX, -a._viewPortRect.y / a._scaleY, d.width, d.height)
  9764. }
  9765. };
  9766. a.getOpenGLView = function() {
  9767. return this._openGLView
  9768. };
  9769. a.getProjection = function() {
  9770. return this._projection
  9771. };
  9772. a.setAlphaBlending = function(a) {
  9773. a ? cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST) : cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO)
  9774. };
  9775. a.setGLDefaultValues = function() {
  9776. this.setAlphaBlending(!0);
  9777. this.setDepthTest(!1);
  9778. this.setProjection(this._projection);
  9779. cc._renderContext.clearColor(0, 0, 0, 1)
  9780. }
  9781. };
  9782. cc.g_NumberOfDraws = 0;
  9783. cc.GLToClipTransform = function(a) {
  9784. var c = new cc.kmMat4;
  9785. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, c);
  9786. var d = new cc.kmMat4;
  9787. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, d);
  9788. cc.kmMat4Multiply(a, c, d)
  9789. };
  9790. cc.Director = cc.Class.extend({
  9791. _landscape: !1,
  9792. _nextDeltaTimeZero: !1,
  9793. _paused: !1,
  9794. _purgeDirectorInNextLoop: !1,
  9795. _sendCleanupToScene: !1,
  9796. _animationInterval: 0,
  9797. _oldAnimationInterval: 0,
  9798. _projection: 0,
  9799. _accumDt: 0,
  9800. _contentScaleFactor: 1,
  9801. _displayStats: !1,
  9802. _deltaTime: 0,
  9803. _frameRate: 0,
  9804. _FPSLabel: null,
  9805. _SPFLabel: null,
  9806. _drawsLabel: null,
  9807. _winSizeInPoints: null,
  9808. _lastUpdate: null,
  9809. _nextScene: null,
  9810. _notificationNode: null,
  9811. _openGLView: null,
  9812. _scenesStack: null,
  9813. _projectionDelegate: null,
  9814. _runningScene: null,
  9815. _frames: 0,
  9816. _totalFrames: 0,
  9817. _secondsPerFrame: 0,
  9818. _dirtyRegion: null,
  9819. _scheduler: null,
  9820. _actionManager: null,
  9821. _eventProjectionChanged: null,
  9822. _eventAfterDraw: null,
  9823. _eventAfterVisit: null,
  9824. _eventAfterUpdate: null,
  9825. ctor: function() {
  9826. var a = this;
  9827. a._lastUpdate = Date.now();
  9828. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
  9829. a._lastUpdate = Date.now()
  9830. })
  9831. },
  9832. init: function() {
  9833. this._oldAnimationInterval = this._animationInterval = 1 / cc.defaultFPS;
  9834. this._scenesStack = [];
  9835. this._projection = cc.Director.PROJECTION_DEFAULT;
  9836. this._projectionDelegate = null;
  9837. this._frameRate = this._accumDt = 0;
  9838. this._displayStats = !1;
  9839. this._totalFrames = this._frames = 0;
  9840. this._lastUpdate = Date.now();
  9841. this._purgeDirectorInNextLoop = this._paused = !1;
  9842. this._winSizeInPoints = cc.size(0, 0);
  9843. this._openGLView = null;
  9844. this._contentScaleFactor = 1;
  9845. this._scheduler = new cc.Scheduler;
  9846. this._actionManager = cc.ActionManager ? new cc.ActionManager : null;
  9847. this._scheduler.scheduleUpdateForTarget(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
  9848. this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
  9849. this._eventAfterDraw.setUserData(this);
  9850. this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);
  9851. this._eventAfterVisit.setUserData(this);
  9852. this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);
  9853. this._eventAfterUpdate.setUserData(this);
  9854. this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);
  9855. this._eventProjectionChanged.setUserData(this);
  9856. return !0
  9857. },
  9858. calculateDeltaTime: function() {
  9859. var a = Date.now();
  9860. this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime = (a - this._lastUpdate) / 1E3;
  9861. 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60);
  9862. this._lastUpdate = a
  9863. },
  9864. drawScene: function() {
  9865. this.calculateDeltaTime();
  9866. this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate));
  9867. this._clear();
  9868. this._nextScene && this.setNextScene();
  9869. this._beforeVisitScene && this._beforeVisitScene();
  9870. this._runningScene && (this._runningScene.visit(), cc.eventManager.dispatchEvent(this._eventAfterVisit));
  9871. this._notificationNode && this._notificationNode.visit();
  9872. this._displayStats && this._showStats();
  9873. this._afterVisitScene && this._afterVisitScene();
  9874. cc.eventManager.dispatchEvent(this._eventAfterDraw);
  9875. this._totalFrames++;
  9876. this._displayStats && this._calculateMPF()
  9877. },
  9878. _beforeVisitScene: null,
  9879. _afterVisitScene: null,
  9880. end: function() {
  9881. this._purgeDirectorInNextLoop = !0
  9882. },
  9883. getContentScaleFactor: function() {
  9884. return this._contentScaleFactor
  9885. },
  9886. getNotificationNode: function() {
  9887. return this._notificationNode
  9888. },
  9889. getWinSize: function() {
  9890. return cc.size(this._winSizeInPoints)
  9891. },
  9892. getWinSizeInPixels: function() {
  9893. return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor)
  9894. },
  9895. pause: function() {
  9896. this._paused || (this._oldAnimationInterval = this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0)
  9897. },
  9898. popScene: function() {
  9899. cc.assert(this._runningScene, cc._LogInfos.Director_popScene);
  9900. this._scenesStack.pop();
  9901. var a = this._scenesStack.length;
  9902. 0 == a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a - 1])
  9903. },
  9904. purgeCachedData: function() {
  9905. cc.animationCache._clear();
  9906. cc.spriteFrameCache._clear();
  9907. cc.textureCache._clear()
  9908. },
  9909. purgeDirector: function() {
  9910. this.getScheduler().unscheduleAllCallbacks();
  9911. cc.eventManager && cc.eventManager.setEnabled(!1);
  9912. this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup());
  9913. this._nextScene = this._runningScene = null;
  9914. this._scenesStack.length = 0;
  9915. this.stopAnimation();
  9916. this.purgeCachedData();
  9917. cc.checkGLErrorDebug()
  9918. },
  9919. pushScene: function(a) {
  9920. cc.assert(a, cc._LogInfos.Director_pushScene);
  9921. this._sendCleanupToScene = !1;
  9922. this._scenesStack.push(a);
  9923. this._nextScene = a
  9924. },
  9925. runScene: function(a) {
  9926. cc.assert(a, cc._LogInfos.Director_pushScene);
  9927. if (this._runningScene) {
  9928. var c = this._scenesStack.length;
  9929. 0 === c ? (this._sendCleanupToScene = !0, this._scenesStack[c] = a) : (this._sendCleanupToScene = !0, this._scenesStack[c - 1] = a);
  9930. this._nextScene = a
  9931. } else this.pushScene(a), this.startAnimation()
  9932. },
  9933. resume: function() {
  9934. this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate = Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0)
  9935. },
  9936. setContentScaleFactor: function(a) {
  9937. a != this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel())
  9938. },
  9939. setDefaultValues: function() {},
  9940. setNextDeltaTimeZero: function(a) {
  9941. this._nextDeltaTimeZero = a
  9942. },
  9943. setNextScene: function() {
  9944. var a = !1,
  9945. c = !1;
  9946. cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, c = this._nextScene ? this._nextScene instanceof cc.TransitionScene : !1);
  9947. if (!c) {
  9948. if (c = this._runningScene) c.onExitTransitionDidStart(), c.onExit();
  9949. this._sendCleanupToScene && c && c.cleanup()
  9950. }
  9951. this._runningScene = this._nextScene;
  9952. this._nextScene = null;
  9953. !a && null != this._runningScene && (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish())
  9954. },
  9955. setNotificationNode: function(a) {
  9956. this._notificationNode = a
  9957. },
  9958. getDelegate: function() {
  9959. return this._projectionDelegate
  9960. },
  9961. setDelegate: function(a) {
  9962. this._projectionDelegate = a
  9963. },
  9964. _showStats: function() {
  9965. this._frames++;
  9966. this._accumDt += this._deltaTime;
  9967. 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();
  9968. cc.g_NumberOfDraws = 0
  9969. },
  9970. isSendCleanupToScene: function() {
  9971. return this._sendCleanupToScene
  9972. },
  9973. getRunningScene: function() {
  9974. return this._runningScene
  9975. },
  9976. getAnimationInterval: function() {
  9977. return this._animationInterval
  9978. },
  9979. isDisplayStats: function() {
  9980. return this._displayStats
  9981. },
  9982. setDisplayStats: function(a) {
  9983. this._displayStats = a
  9984. },
  9985. getSecondsPerFrame: function() {
  9986. return this._secondsPerFrame
  9987. },
  9988. isNextDeltaTimeZero: function() {
  9989. return this._nextDeltaTimeZero
  9990. },
  9991. isPaused: function() {
  9992. return this._paused
  9993. },
  9994. getTotalFrames: function() {
  9995. return this._totalFrames
  9996. },
  9997. popToRootScene: function() {
  9998. this.popToSceneStackLevel(1)
  9999. },
  10000. popToSceneStackLevel: function(a) {
  10001. cc.assert(this._runningScene, cc._LogInfos.Director_popToSceneStackLevel_2);
  10002. var c = this._scenesStack,
  10003. d = c.length;
  10004. if (0 == d) this.end();
  10005. else if (!(a > d)) {
  10006. for (; d > a;) {
  10007. var e = c.pop();
  10008. e.running && (e.onExitTransitionDidStart(), e.onExit());
  10009. e.cleanup();
  10010. d--
  10011. }
  10012. this._nextScene = c[c.length - 1];
  10013. this._sendCleanupToScene = !1
  10014. }
  10015. },
  10016. getScheduler: function() {
  10017. return this._scheduler
  10018. },
  10019. setScheduler: function(a) {
  10020. this._scheduler != a && (this._scheduler = a)
  10021. },
  10022. getActionManager: function() {
  10023. return this._actionManager
  10024. },
  10025. setActionManager: function(a) {
  10026. this._actionManager != a && (this._actionManager = a)
  10027. },
  10028. getDeltaTime: function() {
  10029. return this._deltaTime
  10030. },
  10031. _createStatsLabel: null,
  10032. _calculateMPF: function() {
  10033. this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3
  10034. }
  10035. });
  10036. cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
  10037. cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
  10038. cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
  10039. cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
  10040. cc.DisplayLinkDirector = cc.Director.extend({
  10041. invalid: !1,
  10042. startAnimation: function() {
  10043. this._nextDeltaTimeZero = !0;
  10044. this.invalid = !1
  10045. },
  10046. mainLoop: function() {
  10047. this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene()
  10048. },
  10049. stopAnimation: function() {
  10050. this.invalid = !0
  10051. },
  10052. setAnimationInterval: function(a) {
  10053. this._animationInterval = a;
  10054. this.invalid || (this.stopAnimation(), this.startAnimation())
  10055. }
  10056. });
  10057. cc.Director.sharedDirector = null;
  10058. cc.Director.firstUseDirector = !0;
  10059. cc.Director._getInstance = function() {
  10060. cc.Director.firstUseDirector && (cc.Director.firstUseDirector = !1, cc.Director.sharedDirector = new cc.DisplayLinkDirector, cc.Director.sharedDirector.init());
  10061. return cc.Director.sharedDirector
  10062. };
  10063. cc.defaultFPS = 60;
  10064. cc.Director.PROJECTION_2D = 0;
  10065. cc.Director.PROJECTION_3D = 1;
  10066. cc.Director.PROJECTION_CUSTOM = 3;
  10067. cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
  10068. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Director.prototype, _p.setProjection = function(a) {
  10069. this._projection = a;
  10070. cc.eventManager.dispatchEvent(this._eventProjectionChanged)
  10071. }, _p.setDepthTest = function() {}, _p.setOpenGLView = function(a) {
  10072. this._winSizeInPoints.width = cc._canvas.width;
  10073. this._winSizeInPoints.height = cc._canvas.height;
  10074. this._openGLView = a || cc.view;
  10075. cc.eventManager && cc.eventManager.setEnabled(!0)
  10076. }, _p._clear = function() {
  10077. var a = this._openGLView.getViewPortRect();
  10078. cc._renderContext.clearRect(-a.x, a.y, a.width, -a.height)
  10079. }, _p._createStatsLabel = function() {
  10080. var a = 0,
  10081. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | 24 * (this._winSizeInPoints.height / 320) : 0 | 24 * (this._winSizeInPoints.width / 320);
  10082. this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
  10083. this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
  10084. this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
  10085. a = cc.DIRECTOR_STATS_POSITION;
  10086. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  10087. this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  10088. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  10089. }, _p.getVisibleSize = function() {
  10090. return this.getWinSize()
  10091. }, _p.getVisibleOrigin = function() {
  10092. return cc.p(0, 0)
  10093. }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load", function() {
  10094. cc.Director._fpsImageLoaded = !0
  10095. }), 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);
  10096. cc.Camera = cc.Class.extend({
  10097. _eyeX: null,
  10098. _eyeY: null,
  10099. _eyeZ: null,
  10100. _centerX: null,
  10101. _centerY: null,
  10102. _centerZ: null,
  10103. _upX: null,
  10104. _upY: null,
  10105. _upZ: null,
  10106. _dirty: null,
  10107. _lookupMatrix: null,
  10108. ctor: function() {
  10109. this._lookupMatrix = new cc.kmMat4;
  10110. this.restore()
  10111. },
  10112. description: function() {
  10113. return "\x3cCCCamera | center \x3d(" + this._centerX + "," + this._centerY + "," + this._centerZ + ")\x3e"
  10114. },
  10115. setDirty: function(a) {
  10116. this._dirty = a
  10117. },
  10118. isDirty: function() {
  10119. return this._dirty
  10120. },
  10121. restore: function() {
  10122. this._eyeX = this._eyeY = 0;
  10123. this._eyeZ = cc.Camera.getZEye();
  10124. this._upX = this._centerX = this._centerY = this._centerZ = 0;
  10125. this._upY = 1;
  10126. this._upZ = 0;
  10127. cc.kmMat4Identity(this._lookupMatrix);
  10128. this._dirty = !1
  10129. },
  10130. locate: function() {
  10131. if (this._dirty) {
  10132. var a = new cc.kmVec3,
  10133. c = new cc.kmVec3,
  10134. d = new cc.kmVec3;
  10135. cc.kmVec3Fill(a, this._eyeX, this._eyeY, this._eyeZ);
  10136. cc.kmVec3Fill(c, this._centerX, this._centerY, this._centerZ);
  10137. cc.kmVec3Fill(d, this._upX, this._upY, this._upZ);
  10138. cc.kmMat4LookAt(this._lookupMatrix, a, c, d);
  10139. this._dirty = !1
  10140. }
  10141. cc.kmGLMultMatrix(this._lookupMatrix)
  10142. },
  10143. setEyeXYZ: function(a, c, d) {
  10144. this.setEye(a, c, d)
  10145. },
  10146. setEye: function(a, c, d) {
  10147. this._eyeX = a;
  10148. this._eyeY = c;
  10149. this._eyeZ = d;
  10150. this._dirty = !0
  10151. },
  10152. setCenterXYZ: function(a, c, d) {
  10153. this.setCenter(a, c, d)
  10154. },
  10155. setCenter: function(a, c, d) {
  10156. this._centerX = a;
  10157. this._centerY = c;
  10158. this._centerZ = d;
  10159. this._dirty = !0
  10160. },
  10161. setUpXYZ: function(a, c, d) {
  10162. this.setUp(a, c, d)
  10163. },
  10164. setUp: function(a, c, d) {
  10165. this._upX = a;
  10166. this._upY = c;
  10167. this._upZ = d;
  10168. this._dirty = !0
  10169. },
  10170. getEyeXYZ: function(a, c, d) {
  10171. return {
  10172. x: this._eyeX,
  10173. y: this._eyeY,
  10174. z: this._eyeZ
  10175. }
  10176. },
  10177. getEye: function() {
  10178. return {
  10179. x: this._eyeX,
  10180. y: this._eyeY,
  10181. z: this._eyeZ
  10182. }
  10183. },
  10184. getCenterXYZ: function(a, c, d) {
  10185. return {
  10186. x: this._centerX,
  10187. y: this._centerY,
  10188. z: this._centerZ
  10189. }
  10190. },
  10191. getCenter: function() {
  10192. return {
  10193. x: this._centerX,
  10194. y: this._centerY,
  10195. z: this._centerZ
  10196. }
  10197. },
  10198. getUpXYZ: function(a, c, d) {
  10199. return {
  10200. x: this._upX,
  10201. y: this._upY,
  10202. z: this._upZ
  10203. }
  10204. },
  10205. getUp: function() {
  10206. return {
  10207. x: this._upX,
  10208. y: this._upY,
  10209. z: this._upZ
  10210. }
  10211. },
  10212. _DISALLOW_COPY_AND_ASSIGN: function(a) {}
  10213. });
  10214. cc.Camera.getZEye = function() {
  10215. return cc.FLT_EPSILON
  10216. };
  10217. cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1;
  10218. cc.arrayVerifyType = function(a, c) {
  10219. if (a && 0 < a.length)
  10220. for (var d = 0; d < a.length; d++)
  10221. if (!(a[d] instanceof c)) return cc.log(cc._LogInfos.arrayVerifyType), !1;
  10222. return !0
  10223. };
  10224. cc.arrayRemoveObject = function(a, c) {
  10225. for (var d = 0, e = a.length; d < e; d++)
  10226. if (a[d] == c) {
  10227. a.splice(d, 1);
  10228. break
  10229. }
  10230. };
  10231. cc.arrayRemoveArray = function(a, c) {
  10232. for (var d = 0, e = c.length; d < e; d++) cc.arrayRemoveObject(a, c[d])
  10233. };
  10234. cc.arrayAppendObjectsToIndex = function(a, c, d) {
  10235. a.splice.apply(a, [d, 0].concat(c));
  10236. return a
  10237. };
  10238. cc.ListEntry = function(a, c, d, e, f, g) {
  10239. this.prev = a;
  10240. this.next = c;
  10241. this.target = d;
  10242. this.priority = e;
  10243. this.paused = f;
  10244. this.markedForDeletion = g
  10245. };
  10246. cc.HashUpdateEntry = function(a, c, d, e) {
  10247. this.list = a;
  10248. this.entry = c;
  10249. this.target = d;
  10250. this.hh = e
  10251. };
  10252. cc.HashTimerEntry = function(a, c, d, e, f, g, h) {
  10253. this.timers = a;
  10254. this.target = c;
  10255. this.timerIndex = d;
  10256. this.currentTimer = e;
  10257. this.currentTimerSalvaged = f;
  10258. this.paused = g;
  10259. this.hh = h
  10260. };
  10261. cc.Timer = cc.Class.extend({
  10262. _interval: 0,
  10263. _callback: null,
  10264. _target: null,
  10265. _elapsed: 0,
  10266. _runForever: !1,
  10267. _useDelay: !1,
  10268. _timesExecuted: 0,
  10269. _repeat: 0,
  10270. _delay: 0,
  10271. getInterval: function() {
  10272. return this._interval
  10273. },
  10274. setInterval: function(a) {
  10275. this._interval = a
  10276. },
  10277. getCallback: function() {
  10278. return this._callback
  10279. },
  10280. ctor: function(a, c, d, e, f) {
  10281. this._target = a;
  10282. this._callback = c;
  10283. this._elapsed = -1;
  10284. this._interval = d || 0;
  10285. this._delay = f || 0;
  10286. this._useDelay = 0 < this._delay;
  10287. this._repeat = null == e ? cc.REPEAT_FOREVER : e;
  10288. this._runForever = this._repeat == cc.REPEAT_FOREVER
  10289. },
  10290. _doCallback: function() {
  10291. if ("string" == typeof this._callback) this._target[this._callback](this._elapsed);
  10292. else this._callback.call(this._target, this._elapsed)
  10293. },
  10294. update: function(a) {
  10295. if (-1 == this._elapsed) this._timesExecuted = this._elapsed = 0;
  10296. else {
  10297. var c = this._target,
  10298. d = this._callback;
  10299. this._elapsed += a;
  10300. 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))
  10301. }
  10302. }
  10303. });
  10304. cc.Scheduler = cc.Class.extend({
  10305. _timeScale: 1,
  10306. _updates: null,
  10307. _hashForUpdates: null,
  10308. _arrayForUpdates: null,
  10309. _hashForTimers: null,
  10310. _arrayForTimes: null,
  10311. _currentTarget: null,
  10312. _currentTargetSalvaged: !1,
  10313. _updateHashLocked: !1,
  10314. ctor: function() {
  10315. this._timeScale = 1;
  10316. this._updates = [
  10317. [],
  10318. [],
  10319. []
  10320. ];
  10321. this._hashForUpdates = {};
  10322. this._arrayForUpdates = [];
  10323. this._hashForTimers = {};
  10324. this._arrayForTimers = [];
  10325. this._currentTarget = null;
  10326. this._updateHashLocked = this._currentTargetSalvaged = !1
  10327. },
  10328. _removeHashElement: function(a) {
  10329. delete this._hashForTimers[a.target.__instanceId];
  10330. cc.arrayRemoveObject(this._arrayForTimers, a);
  10331. a.Timer = null;
  10332. a.target = null
  10333. },
  10334. _removeUpdateFromHash: function(a) {
  10335. 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
  10336. },
  10337. _priorityIn: function(a, c, d, e) {
  10338. e = new cc.ListEntry(null, null, c, d, e, !1);
  10339. if (a) {
  10340. for (var f = a.length - 1, g = 0; g <= f && !(d < a[g].priority); g++);
  10341. a.splice(g, 0, e)
  10342. } else a = [], a.push(e);
  10343. d = new cc.HashUpdateEntry(a, e, c, null);
  10344. this._arrayForUpdates.push(d);
  10345. this._hashForUpdates[c.__instanceId] = d;
  10346. return a
  10347. },
  10348. _appendIn: function(a, c, d) {
  10349. d = new cc.ListEntry(null, null, c, 0, d, !1);
  10350. a.push(d);
  10351. a = new cc.HashUpdateEntry(a, d, c, null);
  10352. this._arrayForUpdates.push(a);
  10353. this._hashForUpdates[c.__instanceId] = a
  10354. },
  10355. setTimeScale: function(a) {
  10356. this._timeScale = a
  10357. },
  10358. getTimeScale: function() {
  10359. return this._timeScale
  10360. },
  10361. update: function(a) {
  10362. var c = this._updates,
  10363. d = this._arrayForTimers,
  10364. e, f, g;
  10365. this._updateHashLocked = !0;
  10366. 1 != this._timeScale && (a *= this._timeScale);
  10367. f = 0;
  10368. for (g = c.length; f < g && 0 <= f; f++)
  10369. 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);
  10370. f = 0;
  10371. for (g = d.length; f < g; f++) {
  10372. e = d[f];
  10373. if (!e) break;
  10374. this._currentTarget = e;
  10375. this._currentTargetSalvaged = !1;
  10376. if (!e.paused)
  10377. 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;
  10378. this._currentTargetSalvaged && 0 == e.timers.length && (this._removeHashElement(e), f--)
  10379. }
  10380. f = 0;
  10381. for (g = c.length; f < g; f++) {
  10382. h = this._updates[f];
  10383. k = 0;
  10384. for (m = h.length; k < m;) {
  10385. e = h[k];
  10386. if (!e) break;
  10387. e.markedForDeletion ? this._removeUpdateFromHash(e) : k++
  10388. }
  10389. }
  10390. this._updateHashLocked = !1;
  10391. this._currentTarget = null
  10392. },
  10393. scheduleCallbackForTarget: function(a, c, d, e, f, g) {
  10394. cc.assert(c, cc._LogInfos.Scheduler_scheduleCallbackForTarget_2);
  10395. cc.assert(a, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
  10396. d = d || 0;
  10397. e = null == e ? cc.REPEAT_FOREVER : e;
  10398. f = f || 0;
  10399. g = g || !1;
  10400. var h = this._hashForTimers[a.__instanceId];
  10401. h || (h = new cc.HashTimerEntry(null, a, 0, null, null, g, null), this._arrayForTimers.push(h), this._hashForTimers[a.__instanceId] = h);
  10402. if (null == h.timers) h.timers = [];
  10403. else
  10404. for (var k = 0; k < h.timers.length; k++)
  10405. if (g = h.timers[k], c == g._callback) {
  10406. cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, g.getInterval().toFixed(4), d.toFixed(4));
  10407. g._interval = d;
  10408. return
  10409. }
  10410. g = new cc.Timer(a, c, d, e, f);
  10411. h.timers.push(g)
  10412. },
  10413. scheduleUpdateForTarget: function(a, c, d) {
  10414. if (null !== a) {
  10415. var e = this._updates,
  10416. f = this._hashForUpdates[a.__instanceId];
  10417. 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)
  10418. }
  10419. },
  10420. unscheduleCallbackForTarget: function(a, c) {
  10421. if (!(null == a || null == c)) {
  10422. var d = this._hashForTimers[a.__instanceId];
  10423. if (d)
  10424. for (var e = d.timers, f = 0, g = e.length; f < g; f++) {
  10425. var h = e[f];
  10426. if (c == h._callback) {
  10427. h == d.currentTimer && !d.currentTimerSalvaged && (d.currentTimerSalvaged = !0);
  10428. e.splice(f, 1);
  10429. d.timerIndex >= f && d.timerIndex--;
  10430. 0 == e.length && (this._currentTarget == d ? this._currentTargetSalvaged = !0 : this._removeHashElement(d));
  10431. break
  10432. }
  10433. }
  10434. }
  10435. },
  10436. unscheduleUpdateForTarget: function(a) {
  10437. null != a && (a = this._hashForUpdates[a.__instanceId], null != a && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry)))
  10438. },
  10439. unscheduleAllCallbacksForTarget: function(a) {
  10440. if (null != a) {
  10441. var c = this._hashForTimers[a.__instanceId];
  10442. if (c) {
  10443. var d = c.timers;
  10444. !c.currentTimerSalvaged && 0 <= d.indexOf(c.currentTimer) && (c.currentTimerSalvaged = !0);
  10445. d.length = 0;
  10446. this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c)
  10447. }
  10448. this.unscheduleUpdateForTarget(a)
  10449. }
  10450. },
  10451. unscheduleAllCallbacks: function() {
  10452. this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  10453. },
  10454. unscheduleAllCallbacksWithMinPriority: function(a) {
  10455. for (var c = this._arrayForTimers, d = this._updates, e = 0, f = c.length; e < f; e++) this.unscheduleAllCallbacksForTarget(c[e].target);
  10456. for (e = 2; 0 <= e; e--)
  10457. if (!(1 == e && 0 < a || 0 == e && 0 <= a))
  10458. for (var c = d[e], f = 0, g = c.length; f < g; f++) this.unscheduleUpdateForTarget(c[f].target)
  10459. },
  10460. pauseAllTargets: function() {
  10461. return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  10462. },
  10463. pauseAllTargetsWithMinPriority: function(a) {
  10464. a = [];
  10465. for (var c, d = this._arrayForTimers, e = this._updates, f = 0, g = d.length; f < g; f++)
  10466. if (c = d[f]) c.paused = !0, a.push(c.target);
  10467. f = 0;
  10468. for (g = e.length; f < g; f++)
  10469. for (var d = e[f], h = 0, k = d.length; h < k; h++)
  10470. if (c = d[h]) c.paused = !0, a.push(c.target);
  10471. return a
  10472. },
  10473. resumeTargets: function(a) {
  10474. if (a)
  10475. for (var c = 0; c < a.length; c++) this.resumeTarget(a[c])
  10476. },
  10477. pauseTarget: function(a) {
  10478. cc.assert(a, cc._LogInfos.Scheduler_pauseTarget);
  10479. var c = this._hashForTimers[a.__instanceId];
  10480. c && (c.paused = !0);
  10481. (a = this._hashForUpdates[a.__instanceId]) && (a.entry.paused = !0)
  10482. },
  10483. resumeTarget: function(a) {
  10484. cc.assert(a, cc._LogInfos.Scheduler_resumeTarget);
  10485. var c = this._hashForTimers[a.__instanceId];
  10486. c && (c.paused = !1);
  10487. (a = this._hashForUpdates[a.__instanceId]) && (a.entry.paused = !1)
  10488. },
  10489. isTargetPaused: function(a) {
  10490. cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused);
  10491. return (a = this._hashForTimers[a.__instanceId]) ? a.paused : !1
  10492. }
  10493. });
  10494. cc.Scheduler.PRIORITY_SYSTEM = -2147483648;
  10495. cc.PI2 = 2 * Math.PI;
  10496. cc.DrawingPrimitiveCanvas = cc.Class.extend({
  10497. _cacheArray: [],
  10498. _renderContext: null,
  10499. ctor: function(a) {
  10500. this._renderContext = a
  10501. },
  10502. drawPoint: function(a, c) {
  10503. c || (c = 1);
  10504. var d = cc.view.getScaleX(),
  10505. e = cc.view.getScaleY(),
  10506. e = cc.p(a.x * d, a.y * e);
  10507. this._renderContext.beginPath();
  10508. this._renderContext.arc(e.x, -e.y, c * d, 0, 2 * Math.PI, !1);
  10509. this._renderContext.closePath();
  10510. this._renderContext.fill()
  10511. },
  10512. drawPoints: function(a, c, d) {
  10513. if (null != a) {
  10514. d || (d = 1);
  10515. c = this._renderContext;
  10516. var e = cc.view.getScaleX(),
  10517. f = cc.view.getScaleY();
  10518. c.beginPath();
  10519. 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);
  10520. c.closePath();
  10521. c.fill()
  10522. }
  10523. },
  10524. drawLine: function(a, c) {
  10525. var d = this._renderContext,
  10526. e = cc.view.getScaleX(),
  10527. f = cc.view.getScaleY();
  10528. d.beginPath();
  10529. d.moveTo(a.x * e, -a.y * f);
  10530. d.lineTo(c.x * e, -c.y * f);
  10531. d.closePath();
  10532. d.stroke()
  10533. },
  10534. drawRect: function(a, c) {
  10535. this.drawLine(cc.p(a.x, a.y), cc.p(c.x, a.y));
  10536. this.drawLine(cc.p(c.x, a.y), cc.p(c.x, c.y));
  10537. this.drawLine(cc.p(c.x, c.y), cc.p(a.x, c.y));
  10538. this.drawLine(cc.p(a.x, c.y), cc.p(a.x, a.y))
  10539. },
  10540. drawSolidRect: function(a, c, d) {
  10541. a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
  10542. this.drawSolidPoly(a, 4, d)
  10543. },
  10544. drawPoly: function(a, c, d, e) {
  10545. e = e || !1;
  10546. if (null != a) {
  10547. if (3 > a.length) throw Error("Polygon's point must greater than 2");
  10548. var f = a[0];
  10549. c = this._renderContext;
  10550. var g = cc.view.getScaleX(),
  10551. h = cc.view.getScaleY();
  10552. c.beginPath();
  10553. c.moveTo(f.x * g, -f.y * h);
  10554. for (var f = 1, k = a.length; f < k; f++) c.lineTo(a[f].x * g, -a[f].y * h);
  10555. d && c.closePath();
  10556. e ? c.fill() : c.stroke()
  10557. }
  10558. },
  10559. drawSolidPoly: function(a, c, d) {
  10560. this.setDrawColor(d.r, d.g, d.b, d.a);
  10561. this.drawPoly(a, c, !0, !0)
  10562. },
  10563. drawCircle: function(a, c, d, e, f) {
  10564. f = f || !1;
  10565. e = this._renderContext;
  10566. var g = cc.view.getScaleX(),
  10567. h = cc.view.getScaleY();
  10568. e.beginPath();
  10569. e.arc(0 | a.x * g, 0 | -(a.y * h), c * g, -d, -(d - 2 * Math.PI), !1);
  10570. f && e.lineTo(0 | a.x * g, 0 | -(a.y * h));
  10571. e.stroke()
  10572. },
  10573. drawQuadBezier: function(a, c, d, e) {
  10574. for (var f = this._cacheArray, g = f.length = 0, h = 0; h < e; h++) {
  10575. var k = Math.pow(1 - g, 2) * a.x + 2 * (1 - g) * g * c.x + g * g * d.x,
  10576. m = Math.pow(1 - g, 2) * a.y + 2 * (1 - g) * g * c.y + g * g * d.y;
  10577. f.push(cc.p(k, m));
  10578. g += 1 / e
  10579. }
  10580. f.push(cc.p(d.x, d.y));
  10581. this.drawPoly(f, e + 1, !1, !1)
  10582. },
  10583. drawCubicBezier: function(a, c, d, e, f) {
  10584. for (var g = this._cacheArray, h = g.length = 0, k = 0; k < f; k++) {
  10585. 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,
  10586. 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;
  10587. g.push(cc.p(m, n));
  10588. h += 1 / f
  10589. }
  10590. g.push(cc.p(e.x, e.y));
  10591. this.drawPoly(g, f + 1, !1, !1)
  10592. },
  10593. drawCatmullRom: function(a, c) {
  10594. this.drawCardinalSpline(a, 0.5, c)
  10595. },
  10596. drawCardinalSpline: function(a, c, d) {
  10597. cc._renderContext.strokeStyle = "rgba(255,255,255,1)";
  10598. var e = this._cacheArray;
  10599. e.length = 0;
  10600. 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);
  10601. this.drawPoly(e, d + 1, !1, !1)
  10602. },
  10603. drawImage: function(a, c, d, e, f) {
  10604. switch (arguments.length) {
  10605. case 2:
  10606. this._renderContext.drawImage(a, c.x, -(c.y + a.height));
  10607. break;
  10608. case 3:
  10609. this._renderContext.drawImage(a, c.x, -(c.y + d.height), d.width, d.height);
  10610. break;
  10611. case 5:
  10612. this._renderContext.drawImage(a, c.x, c.y, d.width, d.height, e.x, -(e.y + f.height), f.width, f.height);
  10613. break;
  10614. default:
  10615. throw Error("Argument must be non-nil");
  10616. }
  10617. },
  10618. drawStar: function(a, c, d) {
  10619. a = a || this._renderContext;
  10620. c *= cc.view.getScaleX();
  10621. d = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b);
  10622. a.fillStyle = d + ",1)";
  10623. var e = c / 10;
  10624. a.beginPath();
  10625. a.moveTo(-c, c);
  10626. a.lineTo(0, e);
  10627. a.lineTo(c, c);
  10628. a.lineTo(e, 0);
  10629. a.lineTo(c, -c);
  10630. a.lineTo(0, -e);
  10631. a.lineTo(-c, -c);
  10632. a.lineTo(-e, 0);
  10633. a.lineTo(-c, c);
  10634. a.closePath();
  10635. a.fill();
  10636. var f = a.createRadialGradient(0, 0, e, 0, 0, c);
  10637. f.addColorStop(0, d + ", 1)");
  10638. f.addColorStop(0.3, d + ", 0.8)");
  10639. f.addColorStop(1, d + ", 0.0)");
  10640. a.fillStyle = f;
  10641. a.beginPath();
  10642. a.arc(0, 0, c - e, 0, cc.PI2, !1);
  10643. a.closePath();
  10644. a.fill()
  10645. },
  10646. drawColorBall: function(a, c, d) {
  10647. a = a || this._renderContext;
  10648. c *= cc.view.getScaleX();
  10649. d = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b);
  10650. var e = a.createRadialGradient(0, 0, c / 10, 0, 0, c);
  10651. e.addColorStop(0, d + ", 1)");
  10652. e.addColorStop(0.3, d + ", 0.8)");
  10653. e.addColorStop(0.6, d + ", 0.4)");
  10654. e.addColorStop(1, d + ", 0.0)");
  10655. a.fillStyle = e;
  10656. a.beginPath();
  10657. a.arc(0, 0, c, 0, cc.PI2, !1);
  10658. a.closePath();
  10659. a.fill()
  10660. },
  10661. fillText: function(a, c, d) {
  10662. this._renderContext.fillText(a, c, -d)
  10663. },
  10664. setDrawColor: function(a, c, d, e) {
  10665. this._renderContext.fillStyle = "rgba(" + a + "," + c + "," + d + "," + e / 255 + ")";
  10666. this._renderContext.strokeStyle = "rgba(" + a + "," + c + "," + d + "," + e / 255 + ")"
  10667. },
  10668. setPointSize: function(a) {},
  10669. setLineWidth: function(a) {
  10670. this._renderContext.lineWidth = a * cc.view.getScaleX()
  10671. }
  10672. });
  10673. cc.DrawingPrimitiveWebGL = cc.Class.extend({
  10674. _renderContext: null,
  10675. _initialized: !1,
  10676. _shader: null,
  10677. _colorLocation: -1,
  10678. _colorArray: null,
  10679. _pointSizeLocation: -1,
  10680. _pointSize: -1,
  10681. ctor: function(a) {
  10682. null == a && (a = cc._renderContext);
  10683. if (!a instanceof WebGLRenderingContext) throw "Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext";
  10684. this._renderContext = a;
  10685. this._colorArray = new Float32Array([1, 1, 1, 1])
  10686. },
  10687. lazy_init: function() {
  10688. 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)
  10689. },
  10690. drawInit: function() {
  10691. this._initialized = !1
  10692. },
  10693. drawPoint: function(a) {
  10694. this.lazy_init();
  10695. var c = this._renderContext;
  10696. this._shader.use();
  10697. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10698. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10699. c.uniform4fv(this._colorLocation, this._colorArray);
  10700. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  10701. var d = c.createBuffer();
  10702. c.bindBuffer(c.ARRAY_BUFFER, d);
  10703. c.bufferData(c.ARRAY_BUFFER, new Float32Array([a.x, a.y]), c.STATIC_DRAW);
  10704. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  10705. c.drawArrays(c.POINTS, 0, 1);
  10706. c.deleteBuffer(d);
  10707. cc.incrementGLDraws(1)
  10708. },
  10709. drawPoints: function(a, c) {
  10710. if (a && 0 != a.length) {
  10711. this.lazy_init();
  10712. var d = this._renderContext;
  10713. this._shader.use();
  10714. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10715. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10716. d.uniform4fv(this._colorLocation, this._colorArray);
  10717. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  10718. var e = d.createBuffer();
  10719. d.bindBuffer(d.ARRAY_BUFFER, e);
  10720. d.bufferData(d.ARRAY_BUFFER, this._pointsToTypeArray(a), d.STATIC_DRAW);
  10721. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, 0);
  10722. d.drawArrays(d.POINTS, 0, a.length);
  10723. d.deleteBuffer(e);
  10724. cc.incrementGLDraws(1)
  10725. }
  10726. },
  10727. _pointsToTypeArray: function(a) {
  10728. 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;
  10729. return c
  10730. },
  10731. drawLine: function(a, c) {
  10732. this.lazy_init();
  10733. var d = this._renderContext;
  10734. this._shader.use();
  10735. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10736. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10737. d.uniform4fv(this._colorLocation, this._colorArray);
  10738. var e = d.createBuffer();
  10739. d.bindBuffer(d.ARRAY_BUFFER, e);
  10740. d.bufferData(d.ARRAY_BUFFER, this._pointsToTypeArray([a, c]), d.STATIC_DRAW);
  10741. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, d.FLOAT, !1, 0, 0);
  10742. d.drawArrays(d.LINES, 0, 2);
  10743. d.deleteBuffer(e);
  10744. cc.incrementGLDraws(1)
  10745. },
  10746. drawRect: function(a, c) {
  10747. this.drawLine(cc.p(a.x, a.y), cc.p(c.x, a.y));
  10748. this.drawLine(cc.p(c.x, a.y), cc.p(c.x, c.y));
  10749. this.drawLine(cc.p(c.x, c.y), cc.p(a.x, c.y));
  10750. this.drawLine(cc.p(a.x, c.y), cc.p(a.x, a.y))
  10751. },
  10752. drawSolidRect: function(a, c, d) {
  10753. a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
  10754. this.drawSolidPoly(a, 4, d)
  10755. },
  10756. drawPoly: function(a, c, d) {
  10757. this.lazy_init();
  10758. c = this._renderContext;
  10759. this._shader.use();
  10760. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10761. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10762. c.uniform4fv(this._colorLocation, this._colorArray);
  10763. var e = c.createBuffer();
  10764. c.bindBuffer(c.ARRAY_BUFFER, e);
  10765. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
  10766. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  10767. d ? c.drawArrays(c.LINE_LOOP, 0, a.length) : c.drawArrays(c.LINE_STRIP, 0, a.length);
  10768. c.deleteBuffer(e);
  10769. cc.incrementGLDraws(1)
  10770. },
  10771. drawSolidPoly: function(a, c, d) {
  10772. this.lazy_init();
  10773. d && this.setDrawColor(d.r, d.g, d.b, d.a);
  10774. c = this._renderContext;
  10775. this._shader.use();
  10776. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10777. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10778. c.uniform4fv(this._colorLocation, this._colorArray);
  10779. d = c.createBuffer();
  10780. c.bindBuffer(c.ARRAY_BUFFER, d);
  10781. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
  10782. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  10783. c.drawArrays(c.TRIANGLE_FAN, 0, a.length);
  10784. c.deleteBuffer(d);
  10785. cc.incrementGLDraws(1)
  10786. },
  10787. drawCircle: function(a, c, d, e, f) {
  10788. this.lazy_init();
  10789. var g = 1;
  10790. f && g++;
  10791. var h = 2 * Math.PI / e;
  10792. if (f = new Float32Array(2 * (e + 2))) {
  10793. for (var k = 0; k <= e; k++) {
  10794. var m = k * h,
  10795. n = c * Math.cos(m + d) + a.x,
  10796. m = c * Math.sin(m + d) + a.y;
  10797. f[2 * k] = n;
  10798. f[2 * k + 1] = m
  10799. }
  10800. f[2 * (e + 1)] = a.x;
  10801. f[2 * (e + 1) + 1] = a.y;
  10802. a = this._renderContext;
  10803. this._shader.use();
  10804. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10805. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10806. a.uniform4fv(this._colorLocation, this._colorArray);
  10807. c = a.createBuffer();
  10808. a.bindBuffer(a.ARRAY_BUFFER, c);
  10809. a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
  10810. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  10811. a.drawArrays(a.LINE_STRIP, 0, e + g);
  10812. a.deleteBuffer(c);
  10813. cc.incrementGLDraws(1)
  10814. }
  10815. },
  10816. drawQuadBezier: function(a, c, d, e) {
  10817. this.lazy_init();
  10818. 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;
  10819. f[2 * e] = d.x;
  10820. f[2 * e + 1] = d.y;
  10821. a = this._renderContext;
  10822. this._shader.use();
  10823. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10824. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10825. a.uniform4fv(this._colorLocation, this._colorArray);
  10826. c = a.createBuffer();
  10827. a.bindBuffer(a.ARRAY_BUFFER, c);
  10828. a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
  10829. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  10830. a.drawArrays(a.LINE_STRIP, 0, e + 1);
  10831. a.deleteBuffer(c);
  10832. cc.incrementGLDraws(1)
  10833. },
  10834. drawCubicBezier: function(a, c, d, e, f) {
  10835. this.lazy_init();
  10836. 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;
  10837. g[2 * f] = e.x;
  10838. g[2 * f + 1] = e.y;
  10839. a = this._renderContext;
  10840. this._shader.use();
  10841. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10842. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10843. a.uniform4fv(this._colorLocation, this._colorArray);
  10844. c = a.createBuffer();
  10845. a.bindBuffer(a.ARRAY_BUFFER, c);
  10846. a.bufferData(a.ARRAY_BUFFER, g, a.STATIC_DRAW);
  10847. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  10848. a.drawArrays(a.LINE_STRIP, 0, f + 1);
  10849. a.deleteBuffer(c);
  10850. cc.incrementGLDraws(1)
  10851. },
  10852. drawCatmullRom: function(a, c) {
  10853. this.drawCardinalSpline(a, 0.5, c)
  10854. },
  10855. drawCardinalSpline: function(a, c, d) {
  10856. this.lazy_init();
  10857. 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;
  10858. a = this._renderContext;
  10859. this._shader.use();
  10860. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10861. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10862. a.uniform4fv(this._colorLocation, this._colorArray);
  10863. c = a.createBuffer();
  10864. a.bindBuffer(a.ARRAY_BUFFER, c);
  10865. a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW);
  10866. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  10867. a.drawArrays(a.LINE_STRIP, 0, d + 1);
  10868. a.deleteBuffer(c);
  10869. cc.incrementGLDraws(1)
  10870. },
  10871. setDrawColor: function(a, c, d, e) {
  10872. this._colorArray[0] = a / 255;
  10873. this._colorArray[1] = c / 255;
  10874. this._colorArray[2] = d / 255;
  10875. this._colorArray[3] = e / 255
  10876. },
  10877. setPointSize: function(a) {
  10878. this._pointSize = a * cc.contentScaleFactor()
  10879. },
  10880. setLineWidth: function(a) {
  10881. this._renderContext.lineWidth && this._renderContext.lineWidth(a)
  10882. }
  10883. });
  10884. cc._tmp.WebGLLabelTTF = function() {
  10885. var a = cc.LabelTTF.prototype;
  10886. a.setColor = cc.Sprite.prototype.setColor;
  10887. a._setColorsString = function() {
  10888. this._needUpdateTexture = !0;
  10889. var a = this._strokeColor,
  10890. d = this._textFillColor;
  10891. this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")";
  10892. this._fillColorStr = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + ", 1)";
  10893. this._strokeColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + ", 1)"
  10894. };
  10895. a.updateDisplayedColor = cc.Sprite.prototype.updateDisplayedColor;
  10896. a.setOpacity = cc.Sprite.prototype.setOpacity;
  10897. a.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity;
  10898. a.initWithStringAndTextDefinition = function(a, d) {
  10899. if (!cc.Sprite.prototype.init.call(this)) return !1;
  10900. this.shaderProgram = cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM);
  10901. this._updateWithTextDefinition(d, !1);
  10902. this.string = a;
  10903. return !0
  10904. };
  10905. a.setFontFillColor = function(a) {
  10906. var d = this._textFillColor;
  10907. 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
  10908. };
  10909. a.draw = function(a) {
  10910. if (this._string && "" != this._string) {
  10911. a = a || cc._renderContext;
  10912. var d = this._texture;
  10913. 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));
  10914. 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);
  10915. else if (2 === cc.SPRITE_DEBUG_DRAW) {
  10916. a = this.getTextureRect();
  10917. var d = this.offsetX,
  10918. e = this.offsetY;
  10919. 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)];
  10920. cc._drawingUtil.drawPoly(a, 4, !0)
  10921. }
  10922. cc.g_NumberOfDraws++
  10923. }
  10924. };
  10925. a.setTextureRect = cc.Sprite.prototype.setTextureRect
  10926. };
  10927. cc._tmp.PrototypeLabelTTF = function() {
  10928. var a = cc.LabelTTF.prototype;
  10929. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  10930. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  10931. cc.defineGetterSetter(a, "string", a.getString, a.setString);
  10932. cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment);
  10933. cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment);
  10934. cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize);
  10935. cc.defineGetterSetter(a, "fontName", a.getFontName, a.setFontName);
  10936. cc.defineGetterSetter(a, "font", a._getFont, a._setFont);
  10937. cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth);
  10938. cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight);
  10939. cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor);
  10940. cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle);
  10941. cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth);
  10942. cc.defineGetterSetter(a, "shadowOffsetX", a._getShadowOffsetX, a._setShadowOffsetX);
  10943. cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY);
  10944. cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity);
  10945. cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur)
  10946. };
  10947. cc.LabelTTF = cc.Sprite.extend({
  10948. _dimensions: null,
  10949. _hAlignment: cc.TEXT_ALIGNMENT_CENTER,
  10950. _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP,
  10951. _fontName: null,
  10952. _fontSize: 0,
  10953. _string: "",
  10954. _originalText: null,
  10955. _isMultiLine: !1,
  10956. _fontStyleStr: null,
  10957. _shadowEnabled: !1,
  10958. _shadowOffset: null,
  10959. _shadowOpacity: 0,
  10960. _shadowBlur: 0,
  10961. _shadowColorStr: null,
  10962. _strokeEnabled: !1,
  10963. _strokeColor: null,
  10964. _strokeSize: 0,
  10965. _strokeColorStr: null,
  10966. _textFillColor: null,
  10967. _fillColorStr: null,
  10968. _strokeShadowOffsetX: 0,
  10969. _strokeShadowOffsetY: 0,
  10970. _needUpdateTexture: !1,
  10971. _labelCanvas: null,
  10972. _labelContext: null,
  10973. _lineWidths: null,
  10974. _className: "LabelTTF",
  10975. ctor: function(a, c, d, e, f, g) {
  10976. cc.Sprite.prototype.ctor.call(this);
  10977. this._dimensions = cc.size(0, 0);
  10978. this._hAlignment = cc.TEXT_ALIGNMENT_LEFT;
  10979. this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  10980. this._opacityModifyRGB = !1;
  10981. this._fontStyleStr = "";
  10982. this._fontName = "Arial";
  10983. this._shadowEnabled = this._isMultiLine = !1;
  10984. this._shadowOffset = cc.p(0, 0);
  10985. this._shadowBlur = this._shadowOpacity = 0;
  10986. this._shadowColorStr = "rgba(128, 128, 128, 0.5)";
  10987. this._strokeEnabled = !1;
  10988. this._strokeColor = cc.color(255, 255, 255, 255);
  10989. this._strokeSize = 0;
  10990. this._strokeColorStr = "";
  10991. this._textFillColor = cc.color(255, 255, 255, 255);
  10992. this._fillColorStr = "rgba(255,255,255,1)";
  10993. this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0;
  10994. this._needUpdateTexture = !1;
  10995. this._lineWidths = [];
  10996. this._setColorsString();
  10997. c && c instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, c) : cc.LabelTTF.prototype.initWithString.call(this, a, c, d, e, f, g)
  10998. },
  10999. init: function() {
  11000. return this.initWithString(" ", this._fontName, this._fontSize)
  11001. },
  11002. _measureConfig: function() {
  11003. this._getLabelContext().font = this._fontStyleStr
  11004. },
  11005. _measure: function(a) {
  11006. return this._getLabelContext().measureText(a).width
  11007. },
  11008. description: function() {
  11009. return "\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) + "\x3e"
  11010. },
  11011. setColor: null,
  11012. _setColorsString: null,
  11013. updateDisplayedColor: null,
  11014. setOpacity: null,
  11015. updateDisplayedOpacity: null,
  11016. updateDisplayedOpacityForCanvas: function(a) {
  11017. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  11018. this._setColorsString()
  11019. },
  11020. getString: function() {
  11021. return this._string
  11022. },
  11023. getHorizontalAlignment: function() {
  11024. return this._hAlignment
  11025. },
  11026. getVerticalAlignment: function() {
  11027. return this._vAlignment
  11028. },
  11029. getDimensions: function() {
  11030. return cc.size(this._dimensions)
  11031. },
  11032. getFontSize: function() {
  11033. return this._fontSize
  11034. },
  11035. getFontName: function() {
  11036. return this._fontName
  11037. },
  11038. initWithString: function(a, c, d, e, f, g) {
  11039. a = a ? a + "" : "";
  11040. d = d || 16;
  11041. e = e || cc.size(0, d);
  11042. f = f || cc.TEXT_ALIGNMENT_LEFT;
  11043. g = g || cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  11044. this._opacityModifyRGB = !1;
  11045. this._dimensions = cc.size(e.width, e.height);
  11046. this._fontName = c || "Arial";
  11047. this._hAlignment = f;
  11048. this._vAlignment = g;
  11049. this._fontSize = d;
  11050. this._fontStyleStr = this._fontSize + "px '" + c + "'";
  11051. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(c, this._fontSize);
  11052. this.string = a;
  11053. this._setColorsString();
  11054. this._updateTexture();
  11055. this._needUpdateTexture = !1;
  11056. return !0
  11057. },
  11058. initWithStringAndTextDefinition: null,
  11059. setTextDefinition: function(a) {
  11060. a && this._updateWithTextDefinition(a, !0)
  11061. },
  11062. getTextDefinition: function() {
  11063. return this._prepareTextDefinition(!1)
  11064. },
  11065. enableShadow: function(a, c, d, e) {
  11066. d = d || 0.5;
  11067. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11068. var f = this._shadowOffset;
  11069. if (f && f.x != a || f._y != c) f.x = a, f.y = c;
  11070. this._shadowOpacity != d && (this._shadowOpacity = d);
  11071. this._setColorsString();
  11072. this._shadowBlur != e && (this._shadowBlur = e);
  11073. this._needUpdateTexture = !0
  11074. },
  11075. _getShadowOffsetX: function() {
  11076. return this._shadowOffset.x
  11077. },
  11078. _setShadowOffsetX: function(a) {
  11079. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11080. this._shadowOffset.x != a && (this._shadowOffset.x = a, this._needUpdateTexture = !0)
  11081. },
  11082. _getShadowOffsetY: function() {
  11083. return this._shadowOffset._y
  11084. },
  11085. _setShadowOffsetY: function(a) {
  11086. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11087. this._shadowOffset._y != a && (this._shadowOffset._y = a, this._needUpdateTexture = !0)
  11088. },
  11089. _getShadowOffset: function() {
  11090. return cc.p(this._shadowOffset.x, this._shadowOffset.y)
  11091. },
  11092. _setShadowOffset: function(a) {
  11093. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11094. if (this._shadowOffset.x != a.x || this._shadowOffset.y != a.y) this._shadowOffset.x = a.x, this._shadowOffset.y = a.y, this._needUpdateTexture = !0
  11095. },
  11096. _getShadowOpacity: function() {
  11097. return this._shadowOpacity
  11098. },
  11099. _setShadowOpacity: function(a) {
  11100. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11101. this._shadowOpacity != a && (this._shadowOpacity = a, this._setColorsString(), this._needUpdateTexture = !0)
  11102. },
  11103. _getShadowBlur: function() {
  11104. return this._shadowBlur
  11105. },
  11106. _setShadowBlur: function(a) {
  11107. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11108. this._shadowBlur != a && (this._shadowBlur = a, this._needUpdateTexture = !0)
  11109. },
  11110. disableShadow: function() {
  11111. this._shadowEnabled && (this._shadowEnabled = !1, this._needUpdateTexture = !0)
  11112. },
  11113. enableStroke: function(a, c) {
  11114. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11115. var d = this._strokeColor;
  11116. 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();
  11117. this._strokeSize !== c && (this._strokeSize = c || 0);
  11118. this._needUpdateTexture = !0
  11119. },
  11120. _getStrokeStyle: function() {
  11121. return this._strokeColor
  11122. },
  11123. _setStrokeStyle: function(a) {
  11124. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11125. var c = this._strokeColor;
  11126. 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
  11127. },
  11128. _getLineWidth: function() {
  11129. return this._strokeSize
  11130. },
  11131. _setLineWidth: function(a) {
  11132. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11133. this._strokeSize !== a && (this._strokeSize = a || 0, this._needUpdateTexture = !0)
  11134. },
  11135. disableStroke: function() {
  11136. this._strokeEnabled && (this._strokeEnabled = !1, this._needUpdateTexture = !0)
  11137. },
  11138. setFontFillColor: null,
  11139. _getFillStyle: function() {
  11140. return this._textFillColor
  11141. },
  11142. _updateWithTextDefinition: function(a, c) {
  11143. a.fontDimensions ? (this._dimensions.width = a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0);
  11144. this._hAlignment = a.textAlign;
  11145. this._vAlignment = a.verticalAlign;
  11146. this._fontName = a.fontName;
  11147. this._fontSize = a.fontSize || 12;
  11148. this._fontStyleStr = this._fontSize + "px '" + this._fontName + "'";
  11149. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize);
  11150. a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur);
  11151. a.strokeEnabled && this.enableStroke(a.strokeStyle, a.lineWidth);
  11152. this.setFontFillColor(a.fillStyle);
  11153. c && this._updateTexture()
  11154. },
  11155. _prepareTextDefinition: function(a) {
  11156. var c = new cc.FontDefinition;
  11157. 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);
  11158. c.fontName = this._fontName;
  11159. c.textAlign = this._hAlignment;
  11160. c.verticalAlign = this._vAlignment;
  11161. if (this._strokeEnabled) {
  11162. c.strokeEnabled = !0;
  11163. var d = this._strokeColor;
  11164. c.strokeStyle = cc.color(d.r, d.g, d.b);
  11165. c.lineWidth = this._strokeSize
  11166. } else c.strokeEnabled = !1;
  11167. 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;
  11168. a = this._textFillColor;
  11169. c.fillStyle = cc.color(a.r, a.g, a.b);
  11170. return c
  11171. },
  11172. _fontClientHeight: 18,
  11173. setString: function(a) {
  11174. a = String(a);
  11175. this._originalText != a && (this._originalText = a + "", this._updateString(), this._needUpdateTexture = !0)
  11176. },
  11177. _updateString: function() {
  11178. this._string = this._originalText
  11179. },
  11180. setHorizontalAlignment: function(a) {
  11181. a !== this._hAlignment && (this._hAlignment = a, this._needUpdateTexture = !0)
  11182. },
  11183. setVerticalAlignment: function(a) {
  11184. a != this._vAlignment && (this._vAlignment = a, this._needUpdateTexture = !0)
  11185. },
  11186. setDimensions: function(a, c) {
  11187. var d;
  11188. void 0 === c ? (d = a.width, c = a.height) : d = a;
  11189. if (d != this._dimensions.width || c != this._dimensions.height) this._dimensions.width = d, this._dimensions.height = c, this._updateString(), this._needUpdateTexture = !0
  11190. },
  11191. _getBoundingWidth: function() {
  11192. return this._dimensions.width
  11193. },
  11194. _setBoundingWidth: function(a) {
  11195. a != this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._needUpdateTexture = !0)
  11196. },
  11197. _getBoundingHeight: function() {
  11198. return this._dimensions.height
  11199. },
  11200. _setBoundingHeight: function(a) {
  11201. a != this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._needUpdateTexture = !0)
  11202. },
  11203. setFontSize: function(a) {
  11204. this._fontSize !== a && (this._fontSize = a, this._fontStyleStr = a + "px '" + this._fontName + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, a), this._needUpdateTexture = !0)
  11205. },
  11206. setFontName: function(a) {
  11207. 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)
  11208. },
  11209. _getFont: function() {
  11210. return this._fontStyleStr
  11211. },
  11212. _setFont: function(a) {
  11213. var c = cc.LabelTTF._fontStyleRE.exec(a);
  11214. 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)
  11215. },
  11216. _drawTTFInCanvas: function(a) {
  11217. if (a) {
  11218. var c = this._strokeShadowOffsetX,
  11219. d = this._strokeShadowOffsetY,
  11220. e = this._contentSize.height - d,
  11221. f = this._vAlignment,
  11222. g = this._hAlignment,
  11223. h = this._fontClientHeight,
  11224. k = this._strokeSize;
  11225. a.setTransform(1, 0, 0, 1, 0 + 0.5 * c, e + 0.5 * d);
  11226. a.font != this._fontStyleStr && (a.font = this._fontStyleStr);
  11227. a.fillStyle = this._fillColorStr;
  11228. var m = d = 0,
  11229. n = this._strokeEnabled;
  11230. n && (a.lineWidth = 2 * k, a.strokeStyle = this._strokeColorStr);
  11231. this._shadowEnabled && (k = this._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = k.x, a.shadowOffsetY = -k.y, a.shadowBlur = this._shadowBlur);
  11232. a.textBaseline = cc.LabelTTF._textBaseline[f];
  11233. a.textAlign = cc.LabelTTF._textAlign[g];
  11234. c = this._contentSize.width - c;
  11235. d = g === cc.TEXT_ALIGNMENT_RIGHT ? d + c : g === cc.TEXT_ALIGNMENT_CENTER ? d + c / 2 : d + 0;
  11236. if (this._isMultiLine) {
  11237. g = this._strings.length;
  11238. f === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? m = h + e - h * g : f === cc.VERTICAL_TEXT_ALIGNMENT_CENTER && (m = h / 2 + (e - h * g) / 2);
  11239. 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)
  11240. } 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)
  11241. }
  11242. },
  11243. _getLabelContext: function() {
  11244. if (this._labelContext) return this._labelContext;
  11245. if (!this._labelCanvas) {
  11246. var a = cc.newElement("canvas"),
  11247. c = new cc.Texture2D;
  11248. c.initWithElement(a);
  11249. this.texture = c;
  11250. this._labelCanvas = a
  11251. }
  11252. return this._labelContext = this._labelCanvas.getContext("2d")
  11253. },
  11254. _checkWarp: function(a, c, d) {
  11255. var e = a[c],
  11256. f = this._measure(e);
  11257. if (f > d && 1 < e.length) {
  11258. 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);
  11259. 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);
  11260. g -= n;
  11261. d = e.substr(0, g);
  11262. 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);
  11263. 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);
  11264. a[c] = m || h;
  11265. a.splice(c, 0, d)
  11266. }
  11267. },
  11268. _updateTTF: function() {
  11269. var a = this._dimensions.width,
  11270. c, d, e = this._lineWidths;
  11271. e.length = 0;
  11272. this._isMultiLine = !1;
  11273. this._measureConfig();
  11274. if (0 !== a) {
  11275. this._strings = this._string.split("\n");
  11276. for (c = 0; c < this._strings.length; c++) this._checkWarp(this._strings, c, a)
  11277. } else {
  11278. this._strings = this._string.split("\n");
  11279. c = 0;
  11280. for (d = this._strings.length; c < d; c++) e.push(this._measure(this._strings[c]))
  11281. }
  11282. 0 < this._strings.length && (this._isMultiLine = !0);
  11283. d = c = 0;
  11284. this._strokeEnabled && (c = d = 2 * this._strokeSize);
  11285. if (this._shadowEnabled) {
  11286. var f = this._shadowOffset;
  11287. c += 2 * Math.abs(f.x);
  11288. d += 2 * Math.abs(f.y)
  11289. }
  11290. 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);
  11291. this.setContentSize(a);
  11292. this._strokeShadowOffsetX = c;
  11293. this._strokeShadowOffsetY = d;
  11294. e = this._anchorPoint;
  11295. this._anchorPointInPoints.x = 0.5 * c + (a.width - c) * e.x;
  11296. this._anchorPointInPoints.y = 0.5 * d + (a.height - d) * e.y
  11297. },
  11298. getContentSize: function() {
  11299. this._needUpdateTexture && this._updateTTF();
  11300. return cc.Sprite.prototype.getContentSize.call(this)
  11301. },
  11302. _getWidth: function() {
  11303. this._needUpdateTexture && this._updateTTF();
  11304. return cc.Sprite.prototype._getWidth.call(this)
  11305. },
  11306. _getHeight: function() {
  11307. this._needUpdateTexture && this._updateTTF();
  11308. return cc.Sprite.prototype._getHeight.call(this)
  11309. },
  11310. _updateTexture: function() {
  11311. var a = this._getLabelContext(),
  11312. c = this._labelCanvas,
  11313. d = this._contentSize;
  11314. 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;
  11315. a.font = this._fontStyleStr;
  11316. this._updateTTF();
  11317. var e = d.width,
  11318. d = d.height,
  11319. f = c.width == e && c.height == d;
  11320. c.width = e;
  11321. c.height = d;
  11322. f && a.clearRect(0, 0, e, d);
  11323. this._drawTTFInCanvas(a);
  11324. this._texture && this._texture.handleLoadedTexture();
  11325. this.setTextureRect(cc.rect(0, 0, e, d));
  11326. return !0
  11327. },
  11328. visit: function(a) {
  11329. this._string && "" != this._string && (this._needUpdateTexture && (this._needUpdateTexture = !1, this._updateTexture()), cc.Sprite.prototype.visit.call(this, a || cc._renderContext))
  11330. },
  11331. draw: null,
  11332. _setTextureCoords: function(a) {
  11333. var c = this._batchNode ? this.textureAtlas.texture : this._texture;
  11334. if (c) {
  11335. var d = c.pixelsWidth,
  11336. e = c.pixelsHeight,
  11337. f, g = this._quad;
  11338. 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);
  11339. this._quadDirty = !0
  11340. }
  11341. }
  11342. });
  11343. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LabelTTF.prototype, _p.setColor = function(a) {
  11344. cc.Node.prototype.setColor.call(this, a);
  11345. this._setColorsString()
  11346. }, _p._setColorsString = function() {
  11347. this._needUpdateTexture = !0;
  11348. var a = this._displayedColor,
  11349. c = this._displayedOpacity,
  11350. d = this._strokeColor,
  11351. e = this._textFillColor;
  11352. this._shadowColorStr = "rgba(" + (0 | 0.5 * a.r) + "," + (0 | 0.5 * a.g) + "," + (0 | 0.5 * a.b) + "," + this._shadowOpacity + ")";
  11353. this._fillColorStr = "rgba(" + (0 | a.r / 255 * e.r) + "," + (0 | a.g / 255 * e.g) + "," + (0 | a.b / 255 * e.b) + ", " + c / 255 + ")";
  11354. this._strokeColorStr = "rgba(" + (0 | a.r / 255 * d.r) + "," + (0 | a.g / 255 * d.g) + "," + (0 | a.b / 255 * d.b) + ", " + c / 255 + ")"
  11355. }, _p.updateDisplayedColor = function(a) {
  11356. cc.Node.prototype.updateDisplayedColor.call(this, a);
  11357. this._setColorsString()
  11358. }, _p.setOpacity = function(a) {
  11359. this._opacity !== a && (cc.Sprite.prototype.setOpacity.call(this, a), this._setColorsString(), this._needUpdateTexture = !0)
  11360. }, _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity, _p.initWithStringAndTextDefinition = function(a, c) {
  11361. this._updateWithTextDefinition(c, !1);
  11362. this.string = a;
  11363. return !0
  11364. }, _p.setFontFillColor = function(a) {
  11365. var c = this._textFillColor;
  11366. 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
  11367. }, _p.draw = cc.Sprite.prototype.draw, _p.setTextureRect = function(a, c, d) {
  11368. this._rectRotated = c || !1;
  11369. this.setContentSize(d || a);
  11370. this.setVertexRect(a);
  11371. c = this._textureRect_Canvas;
  11372. c.x = a.x;
  11373. c.y = a.y;
  11374. c.width = a.width;
  11375. c.height = a.height;
  11376. c.validRect = !(0 === c.width || 0 === c.height || 0 > c.x || 0 > c.y);
  11377. a = this._unflippedOffsetPositionFromCenter;
  11378. this._flippedX && (a.x = -a.x);
  11379. this._flippedY && (a.y = -a.y);
  11380. this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
  11381. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  11382. this._batchNode && (this.dirty = !0)
  11383. }, _p = null) : (cc.assert("function" === typeof cc._tmp.WebGLLabelTTF, cc._LogInfos.MissingFile, "LabelTTFWebGL.js"), cc._tmp.WebGLLabelTTF(), delete cc._tmp.WebGLLabelTTF);
  11384. cc.assert("function" === typeof cc._tmp.PrototypeLabelTTF, cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js");
  11385. cc._tmp.PrototypeLabelTTF();
  11386. delete cc._tmp.PrototypeLabelTTF;
  11387. cc.LabelTTF._textAlign = ["left", "center", "right"];
  11388. cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
  11389. cc.LabelTTF.wrapInspection = !0;
  11390. 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)/;
  11391. cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/;
  11392. 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)$/;
  11393. cc.LabelTTF._lastEnglish = /[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+$/;
  11394. cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]/;
  11395. cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
  11396. cc.LabelTTF.create = function(a, c, d, e, f, g) {
  11397. return new cc.LabelTTF(a, c, d, e, f, g)
  11398. };
  11399. cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create;
  11400. cc.LabelTTF._SHADER_PROGRAM = cc.USE_LA88_LABELS ? cc.SHADER_POSITION_TEXTURECOLOR : cc.SHADER_POSITION_TEXTUREA8COLOR;
  11401. cc.LabelTTF.__labelHeightDiv = cc.newElement("div");
  11402. cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial";
  11403. cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
  11404. cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
  11405. cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
  11406. cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
  11407. document.body ? document.body.appendChild(cc.LabelTTF.__labelHeightDiv) : cc._addEventListener(window, "load", function() {
  11408. this.removeEventListener("load", arguments.callee, !1);
  11409. document.body.appendChild(cc.LabelTTF.__labelHeightDiv)
  11410. }, !1);
  11411. cc.LabelTTF.__getFontHeightByDiv = function(a, c) {
  11412. var d = cc.LabelTTF.__fontHeightCache[a + "." + c];
  11413. if (0 < d) return d;
  11414. var e = cc.LabelTTF.__labelHeightDiv;
  11415. e.innerHTML = "ajghl~!";
  11416. e.style.fontFamily = a;
  11417. e.style.fontSize = c + "px";
  11418. d = e.clientHeight;
  11419. cc.LabelTTF.__fontHeightCache[a + "." + c] = d;
  11420. e.innerHTML = "";
  11421. return d
  11422. };
  11423. cc.LabelTTF.__fontHeightCache = {};
  11424. cc.HashElement = cc.Class.extend({
  11425. actions: null,
  11426. target: null,
  11427. actionIndex: 0,
  11428. currentAction: null,
  11429. currentActionSalvaged: !1,
  11430. paused: !1,
  11431. hh: null,
  11432. ctor: function() {
  11433. this.actions = [];
  11434. this.target = null;
  11435. this.actionIndex = 0;
  11436. this.currentAction = null;
  11437. this.paused = this.currentActionSalvaged = !1;
  11438. this.hh = null
  11439. }
  11440. });
  11441. cc.ActionManager = cc.Class.extend({
  11442. _hashTargets: null,
  11443. _arrayTargets: null,
  11444. _currentTarget: null,
  11445. _currentTargetSalvaged: !1,
  11446. _searchElementByTarget: function(a, c) {
  11447. for (var d = 0; d < a.length; d++)
  11448. if (c == a[d].target) return a[d];
  11449. return null
  11450. },
  11451. ctor: function() {
  11452. this._hashTargets = {};
  11453. this._arrayTargets = [];
  11454. this._currentTarget = null;
  11455. this._currentTargetSalvaged = !1
  11456. },
  11457. addAction: function(a, c, d) {
  11458. if (!a) throw "cc.ActionManager.addAction(): action must be non-null";
  11459. if (!c) throw "cc.ActionManager.addAction(): action must be non-null";
  11460. var e = this._hashTargets[c.__instanceId];
  11461. e || (e = new cc.HashElement, e.paused = d, e.target = c, this._hashTargets[c.__instanceId] = e, this._arrayTargets.push(e));
  11462. this._actionAllocWithHashElement(e);
  11463. e.actions.push(a);
  11464. a.startWithTarget(c)
  11465. },
  11466. removeAllActions: function() {
  11467. for (var a = this._arrayTargets, c = 0; c < a.length; c++) {
  11468. var d = a[c];
  11469. d && this.removeAllActionsFromTarget(d.target, !0)
  11470. }
  11471. },
  11472. removeAllActionsFromTarget: function(a, c) {
  11473. if (null != a) {
  11474. var d = this._hashTargets[a.__instanceId];
  11475. 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))
  11476. }
  11477. },
  11478. removeAction: function(a) {
  11479. if (null != a) {
  11480. var c = a.getOriginalTarget();
  11481. if (c = this._hashTargets[c.__instanceId])
  11482. for (var d = 0; d < c.actions.length; d++) {
  11483. if (c.actions[d] == a) {
  11484. c.actions.splice(d, 1);
  11485. break
  11486. }
  11487. } else cc.log(cc._LogInfos.ActionManager_removeAction)
  11488. }
  11489. },
  11490. removeActionByTag: function(a, c) {
  11491. a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_addAction);
  11492. cc.assert(c, cc._LogInfos.ActionManager_addAction);
  11493. var d = this._hashTargets[c.__instanceId];
  11494. if (d)
  11495. for (var e = d.actions.length, f = 0; f < e; ++f) {
  11496. var g = d.actions[f];
  11497. if (g && g.getTag() === a && g.getOriginalTarget() == c) {
  11498. this._removeActionAtIndex(f, d);
  11499. break
  11500. }
  11501. }
  11502. },
  11503. getActionByTag: function(a, c) {
  11504. a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_getActionByTag);
  11505. var d = this._hashTargets[c.__instanceId];
  11506. if (d) {
  11507. if (null != d.actions)
  11508. for (var e = 0; e < d.actions.length; ++e) {
  11509. var f = d.actions[e];
  11510. if (f && f.getTag() === a) return f
  11511. }
  11512. cc.log(cc._LogInfos.ActionManager_getActionByTag_2, a)
  11513. }
  11514. return null
  11515. },
  11516. numberOfRunningActionsInTarget: function(a) {
  11517. return (a = this._hashTargets[a.__instanceId]) ? a.actions ? a.actions.length : 0 : 0
  11518. },
  11519. pauseTarget: function(a) {
  11520. (a = this._hashTargets[a.__instanceId]) && (a.paused = !0)
  11521. },
  11522. resumeTarget: function(a) {
  11523. (a = this._hashTargets[a.__instanceId]) && (a.paused = !1)
  11524. },
  11525. pauseAllRunningActions: function() {
  11526. for (var a = [], c = this._arrayTargets, d = 0; d < c.length; d++) {
  11527. var e = c[d];
  11528. e && !e.paused && (e.paused = !0, a.push(e.target))
  11529. }
  11530. return a
  11531. },
  11532. resumeTargets: function(a) {
  11533. if (a)
  11534. for (var c = 0; c < a.length; c++) a[c] && this.resumeTarget(a[c])
  11535. },
  11536. purgeSharedManager: function() {
  11537. cc.director.getScheduler().unscheduleUpdateForTarget(this)
  11538. },
  11539. _removeActionAtIndex: function(a, c) {
  11540. c.actions[a] == c.currentAction && !c.currentActionSalvaged && (c.currentActionSalvaged = !0);
  11541. c.actions.splice(a, 1);
  11542. c.actionIndex >= a && c.actionIndex--;
  11543. 0 == c.actions.length && (this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._deleteHashElement(c))
  11544. },
  11545. _deleteHashElement: function(a) {
  11546. a && (delete this._hashTargets[a.target.__instanceId], cc.arrayRemoveObject(this._arrayTargets, a), a.actions = null, a.target = null)
  11547. },
  11548. _actionAllocWithHashElement: function(a) {
  11549. null == a.actions && (a.actions = [])
  11550. },
  11551. update: function(a) {
  11552. for (var c = this._arrayTargets, d, e = 0; e < c.length; e++) {
  11553. d = this._currentTarget = c[e];
  11554. if (!d.paused)
  11555. for (d.actionIndex = 0; d.actionIndex < d.actions.length; d.actionIndex++)
  11556. if (d.currentAction = d.actions[d.actionIndex], d.currentAction) {
  11557. d.currentActionSalvaged = !1;
  11558. d.currentAction.step(a * (d.currentAction._speedMethod ? d.currentAction._speed : 1));
  11559. if (d.currentActionSalvaged) d.currentAction = null;
  11560. else if (d.currentAction.isDone()) {
  11561. d.currentAction.stop();
  11562. var f = d.currentAction;
  11563. d.currentAction = null;
  11564. this.removeAction(f)
  11565. }
  11566. d.currentAction = null
  11567. }
  11568. this._currentTargetSalvaged && 0 === d.actions.length && this._deleteHashElement(d)
  11569. }
  11570. }
  11571. });
  11572. cc.kmScalar = Number;
  11573. cc.kmBool = Number;
  11574. cc.kmEnum = Number;
  11575. cc.KM_FALSE = 0;
  11576. cc.KM_TRUE = 1;
  11577. cc.kmPI = 3.141592;
  11578. cc.kmPIOver180 = 0.017453;
  11579. cc.kmPIUnder180 = 57.295779;
  11580. cc.kmEpsilon = 0.015625;
  11581. cc.kmSQR = function(a) {
  11582. return a * a
  11583. };
  11584. cc.kmDegreesToRadians = function(a) {
  11585. return a * cc.kmPIOver180
  11586. };
  11587. cc.kmRadiansToDegrees = function(a) {
  11588. return a * cc.kmPIUnder180
  11589. };
  11590. cc.kmMin = function(a, c) {
  11591. return a < c ? a : c
  11592. };
  11593. cc.kmMax = function(a, c) {
  11594. return a > c ? a : c
  11595. };
  11596. cc.kmAlmostEqual = function(a, c) {
  11597. return a + cc.kmEpsilon > c && a - cc.kmEpsilon < c
  11598. };
  11599. cc.kmVec2 = function(a, c) {
  11600. this.x = a || 0;
  11601. this.y = c || 0
  11602. };
  11603. cc.kmVec2Fill = function(a, c, d) {
  11604. a.x = c;
  11605. a.y = d;
  11606. return a
  11607. };
  11608. cc.kmVec2Length = function(a) {
  11609. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y))
  11610. };
  11611. cc.kmVec2LengthSq = function(a) {
  11612. return cc.kmSQR(a.x) + cc.kmSQR(a.y)
  11613. };
  11614. cc.kmVec2Normalize = function(a, c) {
  11615. var d = 1 / cc.kmVec2Length(c),
  11616. e = new cc.kmVec2;
  11617. e.x = c.x * d;
  11618. e.y = c.y * d;
  11619. a.x = e.x;
  11620. a.y = e.y;
  11621. return a
  11622. };
  11623. cc.kmVec2Add = function(a, c, d) {
  11624. a.x = c.x + d.x;
  11625. a.y = c.y + d.y;
  11626. return a
  11627. };
  11628. cc.kmVec2Dot = function(a, c) {
  11629. return a.x * c.x + a.y * c.y
  11630. };
  11631. cc.kmVec2Subtract = function(a, c, d) {
  11632. a.x = c.x - d.x;
  11633. a.y = c.y - d.y;
  11634. return a
  11635. };
  11636. cc.kmVec2Transform = function(a, c, d) {
  11637. var e = new cc.kmVec2;
  11638. e.x = c.x * d.mat[0] + c.y * d.mat[3] + d.mat[6];
  11639. e.y = c.x * d.mat[1] + c.y * d.mat[4] + d.mat[7];
  11640. a.x = e.x;
  11641. a.y = e.y;
  11642. return a
  11643. };
  11644. cc.kmVec2TransformCoord = function(a, c, d) {
  11645. return null
  11646. };
  11647. cc.kmVec2Scale = function(a, c, d) {
  11648. a.x = c.x * d;
  11649. a.y = c.y * d;
  11650. return a
  11651. };
  11652. cc.kmVec2AreEqual = function(a, c) {
  11653. 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
  11654. };
  11655. cc.kmVec3 = function(a, c, d) {
  11656. this.x = a || 0;
  11657. this.y = c || 0;
  11658. this.z = d || 0
  11659. };
  11660. cc.kmVec3Fill = function(a, c, d, e) {
  11661. if (!a) return new cc.kmVec3(c, d, e);
  11662. a.x = c;
  11663. a.y = d;
  11664. a.z = e;
  11665. return a
  11666. };
  11667. cc.kmVec3Length = function(a) {
  11668. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z))
  11669. };
  11670. cc.kmVec3LengthSq = function(a) {
  11671. return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z)
  11672. };
  11673. cc.kmVec3Normalize = function(a, c) {
  11674. var d = 1 / cc.kmVec3Length(c);
  11675. a.x = c.x * d;
  11676. a.y = c.y * d;
  11677. a.z = c.z * d;
  11678. return a
  11679. };
  11680. cc.kmVec3Cross = function(a, c, d) {
  11681. a.x = c.y * d.z - c.z * d.y;
  11682. a.y = c.z * d.x - c.x * d.z;
  11683. a.z = c.x * d.y - c.y * d.x;
  11684. return a
  11685. };
  11686. cc.kmVec3Dot = function(a, c) {
  11687. return a.x * c.x + a.y * c.y + a.z * c.z
  11688. };
  11689. cc.kmVec3Add = function(a, c, d) {
  11690. a.x = c.x + d.x;
  11691. a.y = c.y + d.y;
  11692. a.z = c.z + d.z;
  11693. return a
  11694. };
  11695. cc.kmVec3Subtract = function(a, c, d) {
  11696. a.x = c.x - d.x;
  11697. a.y = c.y - d.y;
  11698. a.z = c.z - d.z;
  11699. return a
  11700. };
  11701. cc.kmVec3Transform = function(a, c, d) {
  11702. a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8] + d.mat[12];
  11703. a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9] + d.mat[13];
  11704. a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10] + d.mat[14];
  11705. return a
  11706. };
  11707. cc.kmVec3TransformNormal = function(a, c, d) {
  11708. a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8];
  11709. a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9];
  11710. a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10];
  11711. return a
  11712. };
  11713. cc.kmVec3TransformCoord = function(a, c, d) {
  11714. var e = new cc.kmVec4,
  11715. f = new cc.kmVec4;
  11716. cc.kmVec4Fill(f, c.x, c.y, c.z, 1);
  11717. cc.kmVec4Transform(e, f, d);
  11718. a.x = e.x / e.w;
  11719. a.y = e.y / e.w;
  11720. a.z = e.z / e.w;
  11721. return a
  11722. };
  11723. cc.kmVec3Scale = function(a, c, d) {
  11724. a.x = c.x * d;
  11725. a.y = c.y * d;
  11726. a.z = c.z * d;
  11727. return a
  11728. };
  11729. cc.kmVec3AreEqual = function(a, c) {
  11730. 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
  11731. };
  11732. cc.kmVec3InverseTransform = function(a, c, d) {
  11733. c = new cc.kmVec3(c.x - d.mat[12], c.y - d.mat[13], c.z - d.mat[14]);
  11734. a.x = c.x * d.mat[0] + c.y * d.mat[1] + c.z * d.mat[2];
  11735. a.y = c.x * d.mat[4] + c.y * d.mat[5] + c.z * d.mat[6];
  11736. a.z = c.x * d.mat[8] + c.y * d.mat[9] + c.z * d.mat[10];
  11737. return a
  11738. };
  11739. cc.kmVec3InverseTransformNormal = function(a, c, d) {
  11740. a.x = c.x * d.mat[0] + c.y * d.mat[1] + c.z * d.mat[2];
  11741. a.y = c.x * d.mat[4] + c.y * d.mat[5] + c.z * d.mat[6];
  11742. a.z = c.x * d.mat[8] + c.y * d.mat[9] + c.z * d.mat[10];
  11743. return a
  11744. };
  11745. cc.kmVec3Assign = function(a, c) {
  11746. if (a == c) return a;
  11747. a.x = c.x;
  11748. a.y = c.y;
  11749. a.z = c.z;
  11750. return a
  11751. };
  11752. cc.kmVec3Zero = function(a) {
  11753. a.x = 0;
  11754. a.y = 0;
  11755. a.z = 0;
  11756. return a
  11757. };
  11758. cc.kmVec3ToTypeArray = function(a) {
  11759. if (!a) return null;
  11760. var c = new Float32Array(3);
  11761. c[0] = a.x;
  11762. c[1] = a.y;
  11763. c[2] = a.z;
  11764. return c
  11765. };
  11766. cc.kmVec4 = function(a, c, d, e) {
  11767. this.x = a || 0;
  11768. this.y = c || 0;
  11769. this.z = d || 0;
  11770. this.w = e || 0
  11771. };
  11772. cc.kmVec4Fill = function(a, c, d, e, f) {
  11773. a.x = c;
  11774. a.y = d;
  11775. a.z = e;
  11776. a.w = f;
  11777. return a
  11778. };
  11779. cc.kmVec4Add = function(a, c, d) {
  11780. a.x = c.x + d.x;
  11781. a.y = c.y + d.y;
  11782. a.z = c.z + d.z;
  11783. a.w = c.w + d.w;
  11784. return a
  11785. };
  11786. cc.kmVec4Dot = function(a, c) {
  11787. return a.x * c.x + a.y * c.y + a.z * c.z + a.w * c.w
  11788. };
  11789. cc.kmVec4Length = function(a) {
  11790. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w))
  11791. };
  11792. cc.kmVec4LengthSq = function(a) {
  11793. return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w)
  11794. };
  11795. cc.kmVec4Lerp = function(a, c, d, e) {
  11796. return a
  11797. };
  11798. cc.kmVec4Normalize = function(a, c) {
  11799. var d = 1 / cc.kmVec4Length(c);
  11800. a.x *= d;
  11801. a.y *= d;
  11802. a.z *= d;
  11803. a.w *= d;
  11804. return a
  11805. };
  11806. cc.kmVec4Scale = function(a, c, d) {
  11807. cc.kmVec4Normalize(a, c);
  11808. a.x *= d;
  11809. a.y *= d;
  11810. a.z *= d;
  11811. a.w *= d;
  11812. return a
  11813. };
  11814. cc.kmVec4Subtract = function(a, c, d) {
  11815. a.x = c.x - d.x;
  11816. a.y = c.y - d.y;
  11817. a.z = c.z - d.z;
  11818. a.w = c.w - d.w;
  11819. return a
  11820. };
  11821. cc.kmVec4Transform = function(a, c, d) {
  11822. a.x = c.x * d.mat[0] + c.y * d.mat[4] + c.z * d.mat[8] + c.w * d.mat[12];
  11823. a.y = c.x * d.mat[1] + c.y * d.mat[5] + c.z * d.mat[9] + c.w * d.mat[13];
  11824. a.z = c.x * d.mat[2] + c.y * d.mat[6] + c.z * d.mat[10] + c.w * d.mat[14];
  11825. a.w = c.x * d.mat[3] + c.y * d.mat[7] + c.z * d.mat[11] + c.w * d.mat[15];
  11826. return a
  11827. };
  11828. cc.kmVec4TransformArray = function(a, c, d, e, f, g) {
  11829. for (var h = 0; h < g;) cc.kmVec4Transform(a + h * c, d + h * e, f), ++h;
  11830. return a
  11831. };
  11832. cc.kmVec4AreEqual = function(a, c) {
  11833. 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
  11834. };
  11835. cc.kmVec4Assign = function(a, c) {
  11836. if (a == c) return cc.log("destVec and srcVec are same object"), a;
  11837. a.x = c.x;
  11838. a.y = c.y;
  11839. a.z = c.z;
  11840. a.w = c.w;
  11841. return a
  11842. };
  11843. cc.kmVec4ToTypeArray = function(a) {
  11844. if (!a) return null;
  11845. var c = new Float32Array(4);
  11846. c[0] = a.x;
  11847. c[1] = a.y;
  11848. c[2] = a.z;
  11849. c[3] = a.w;
  11850. return c
  11851. };
  11852. cc.kmRay2 = function(a, c) {
  11853. this.start = a || new cc.kmVec2;
  11854. this.start = a || new cc.kmVec2
  11855. };
  11856. cc.kmRay2Fill = function(a, c, d, e, f) {
  11857. a.start.x = c;
  11858. a.start.y = d;
  11859. a.dir.x = e;
  11860. a.dir.y = f
  11861. };
  11862. cc.kmRay2IntersectLineSegment = function(a, c, d, e) {
  11863. var f = a.start.x,
  11864. g = a.start.y,
  11865. h = a.start.x + a.dir.x;
  11866. a = a.start.y + a.dir.y;
  11867. var k = c.x,
  11868. m = c.y,
  11869. n = d.x,
  11870. q = d.y,
  11871. r = (q - m) * (h - f) - (n - k) * (a - g);
  11872. if (r > -cc.kmEpsilon && r < cc.kmEpsilon) return cc.KM_FALSE;
  11873. m = ((n - k) * (g - m) - (q - m) * (f - k)) / r;
  11874. k = f + m * (h - f);
  11875. m = g + m * (a - g);
  11876. 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;
  11877. e.x = k;
  11878. e.y = m;
  11879. return cc.KM_TRUE
  11880. };
  11881. cc.calculate_line_normal = function(a, c, d) {
  11882. var e = new cc.kmVec2;
  11883. cc.kmVec2Subtract(e, c, a);
  11884. d.x = -e.y;
  11885. d.y = e.x;
  11886. cc.kmVec2Normalize(d, d)
  11887. };
  11888. cc.kmRay2IntersectTriangle = function(a, c, d, e, f, g) {
  11889. var h = new cc.kmVec2,
  11890. k = new cc.kmVec2,
  11891. m = new cc.kmVec2,
  11892. n = 1E4,
  11893. q = cc.KM_FALSE,
  11894. r;
  11895. 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)));
  11896. 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)));
  11897. 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)));
  11898. q && (f.x = k.x, f.y = k.y, g && (g.x = m.x, g.y = m.y));
  11899. return q
  11900. };
  11901. cc.kmRay2IntersectCircle = function(a, c, d, e) {
  11902. cc.log("cc.kmRay2IntersectCircle() has not been implemented.")
  11903. };
  11904. var Float32Array = Float32Array || Array;
  11905. cc.kmMat3 = function() {
  11906. this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0])
  11907. };
  11908. cc.kmMat3Fill = function(a, c) {
  11909. for (var d = 0; 9 > d; d++) a.mat[d] = c;
  11910. return a
  11911. };
  11912. cc.kmMat3Adjugate = function(a, c) {
  11913. a.mat[0] = c.mat[4] * c.mat[8] - c.mat[5] * c.mat[7];
  11914. a.mat[1] = c.mat[2] * c.mat[7] - c.mat[1] * c.mat[8];
  11915. a.mat[2] = c.mat[1] * c.mat[5] - c.mat[2] * c.mat[4];
  11916. a.mat[3] = c.mat[5] * c.mat[6] - c.mat[3] * c.mat[8];
  11917. a.mat[4] = c.mat[0] * c.mat[8] - c.mat[2] * c.mat[6];
  11918. a.mat[5] = c.mat[2] * c.mat[3] - c.mat[0] * c.mat[5];
  11919. a.mat[6] = c.mat[3] * c.mat[7] - c.mat[4] * c.mat[6];
  11920. a.mat[8] = c.mat[0] * c.mat[4] - c.mat[1] * c.mat[3];
  11921. return a
  11922. };
  11923. cc.kmMat3Identity = function(a) {
  11924. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[5] = a.mat[6] = a.mat[7] = 0;
  11925. a.mat[0] = a.mat[4] = a.mat[8] = 1;
  11926. return a
  11927. };
  11928. cc.kmMat3Inverse = function(a, c, d) {
  11929. var e = new cc.kmMat3;
  11930. if (0 === c) return null;
  11931. c = 1 / c;
  11932. cc.kmMat3Adjugate(e, d);
  11933. cc.kmMat3ScalarMultiply(a, e, c);
  11934. return a
  11935. };
  11936. cc.kmMat3._identity = new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  11937. cc.kmMat3IsIdentity = function(a) {
  11938. for (var c = 0; 9 > c; c++)
  11939. if (cc.kmMat3._identity[c] !== a.mat[c]) return !1;
  11940. return !0
  11941. };
  11942. cc.kmMat3Transpose = function(a, c) {
  11943. var d, e;
  11944. for (d = 0; 3 > d; ++d)
  11945. for (e = 0; 3 > e; ++e) a.mat[3 * d + e] = c.mat[3 * e + d];
  11946. return a
  11947. };
  11948. cc.kmMat3Determinant = function(a) {
  11949. var c;
  11950. 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];
  11951. 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]
  11952. };
  11953. cc.kmMat3Multiply = function(a, c, d) {
  11954. c = c.mat;
  11955. d = d.mat;
  11956. a.mat[0] = c[0] * d[0] + c[3] * d[1] + c[6] * d[2];
  11957. a.mat[1] = c[1] * d[0] + c[4] * d[1] + c[7] * d[2];
  11958. a.mat[2] = c[2] * d[0] + c[5] * d[1] + c[8] * d[2];
  11959. a.mat[3] = c[0] * d[3] + c[3] * d[4] + c[6] * d[5];
  11960. a.mat[4] = c[1] * d[3] + c[4] * d[4] + c[7] * d[5];
  11961. a.mat[5] = c[2] * d[3] + c[5] * d[4] + c[8] * d[5];
  11962. a.mat[6] = c[0] * d[6] + c[3] * d[7] + c[6] * d[8];
  11963. a.mat[7] = c[1] * d[6] + c[4] * d[7] + c[7] * d[8];
  11964. a.mat[8] = c[2] * d[6] + c[5] * d[7] + c[8] * d[8];
  11965. return a
  11966. };
  11967. cc.kmMat3ScalarMultiply = function(a, c, d) {
  11968. for (var e = 0; 9 > e; e++) a.mat[e] = c.mat[e] * d;
  11969. return a
  11970. };
  11971. cc.kmMat3RotationAxisAngle = function(a, c, d) {
  11972. var e = Math.cos(d);
  11973. d = Math.sin(d);
  11974. a.mat[0] = e + c.x * c.x * (1 - e);
  11975. a.mat[1] = c.z * d + c.y * c.x * (1 - e);
  11976. a.mat[2] = -c.y * d + c.z * c.x * (1 - e);
  11977. a.mat[3] = -c.z * d + c.x * c.y * (1 - e);
  11978. a.mat[4] = e + c.y * c.y * (1 - e);
  11979. a.mat[5] = c.x * d + c.z * c.y * (1 - e);
  11980. a.mat[6] = c.y * d + c.x * c.z * (1 - e);
  11981. a.mat[7] = -c.x * d + c.y * c.z * (1 - e);
  11982. a.mat[8] = e + c.z * c.z * (1 - e);
  11983. return a
  11984. };
  11985. cc.kmMat3Assign = function(a, c) {
  11986. if (a == c) return cc.log("cc.kmMat3Assign(): pOut equals pIn"), a;
  11987. for (var d = 0; 9 > d; d++) a.mat[d] = c.mat[d];
  11988. return a
  11989. };
  11990. cc.kmMat3AreEqual = function(a, c) {
  11991. if (a == c) return !0;
  11992. for (var d = 0; 9 > d; ++d)
  11993. if (!(a.mat[d] + cc.kmEpsilon > c.mat[d] && a.mat[d] - cc.kmEpsilon < c.mat[d])) return !1;
  11994. return !0
  11995. };
  11996. cc.kmMat3RotationX = function(a, c) {
  11997. a.mat[0] = 1;
  11998. a.mat[1] = 0;
  11999. a.mat[2] = 0;
  12000. a.mat[3] = 0;
  12001. a.mat[4] = Math.cos(c);
  12002. a.mat[5] = Math.sin(c);
  12003. a.mat[6] = 0;
  12004. a.mat[7] = -Math.sin(c);
  12005. a.mat[8] = Math.cos(c);
  12006. return a
  12007. };
  12008. cc.kmMat3RotationY = function(a, c) {
  12009. a.mat[0] = Math.cos(c);
  12010. a.mat[1] = 0;
  12011. a.mat[2] = -Math.sin(c);
  12012. a.mat[3] = 0;
  12013. a.mat[4] = 1;
  12014. a.mat[5] = 0;
  12015. a.mat[6] = Math.sin(c);
  12016. a.mat[7] = 0;
  12017. a.mat[8] = Math.cos(c);
  12018. return a
  12019. };
  12020. cc.kmMat3RotationZ = function(a, c) {
  12021. a.mat[0] = Math.cos(c);
  12022. a.mat[1] = -Math.sin(c);
  12023. a.mat[2] = 0;
  12024. a.mat[3] = Math.sin(c);
  12025. a.mat[4] = Math.cos(c);
  12026. a.mat[5] = 0;
  12027. a.mat[6] = 0;
  12028. a.mat[7] = 0;
  12029. a.mat[8] = 1;
  12030. return a
  12031. };
  12032. cc.kmMat3Rotation = function(a, c) {
  12033. a.mat[0] = Math.cos(c);
  12034. a.mat[1] = Math.sin(c);
  12035. a.mat[2] = 0;
  12036. a.mat[3] = -Math.sin(c);
  12037. a.mat[4] = Math.cos(c);
  12038. a.mat[5] = 0;
  12039. a.mat[6] = 0;
  12040. a.mat[7] = 0;
  12041. a.mat[8] = 1;
  12042. return a
  12043. };
  12044. cc.kmMat3Scaling = function(a, c, d) {
  12045. cc.kmMat3Identity(a);
  12046. a.mat[0] = c;
  12047. a.mat[4] = d;
  12048. return a
  12049. };
  12050. cc.kmMat3Translation = function(a, c, d) {
  12051. cc.kmMat3Identity(a);
  12052. a.mat[6] = c;
  12053. a.mat[7] = d;
  12054. return a
  12055. };
  12056. cc.kmMat3RotationQuaternion = function(a, c) {
  12057. if (!c || !a) return null;
  12058. a.mat[0] = 1 - 2 * (c.y * c.y + c.z * c.z);
  12059. a.mat[1] = 2 * (c.x * c.y - c.w * c.z);
  12060. a.mat[2] = 2 * (c.x * c.z + c.w * c.y);
  12061. a.mat[3] = 2 * (c.x * c.y + c.w * c.z);
  12062. a.mat[4] = 1 - 2 * (c.x * c.x + c.z * c.z);
  12063. a.mat[5] = 2 * (c.y * c.z - c.w * c.x);
  12064. a.mat[6] = 2 * (c.x * c.z - c.w * c.y);
  12065. a.mat[7] = 2 * (c.y * c.z + c.w * c.x);
  12066. a.mat[8] = 1 - 2 * (c.x * c.x + c.y * c.y);
  12067. return a
  12068. };
  12069. cc.kmMat3RotationToAxisAngle = function(a, c, d) {
  12070. cc.kmQuaternionRotationMatrix(void 0, d);
  12071. cc.kmQuaternionToAxisAngle(void 0, a, c);
  12072. return a
  12073. };
  12074. cc.kmMat4 = function() {
  12075. this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
  12076. };
  12077. cc.kmMat4Fill = function(a, c) {
  12078. 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
  12079. };
  12080. cc.kmMat4Identity = function(a) {
  12081. 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;
  12082. a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
  12083. return a
  12084. };
  12085. cc.kmMat4._get = function(a, c, d) {
  12086. return a.mat[c + 4 * d]
  12087. };
  12088. cc.kmMat4._set = function(a, c, d, e) {
  12089. a.mat[c + 4 * d] = e
  12090. };
  12091. cc.kmMat4._swap = function(a, c, d, e, f) {
  12092. var g = cc.kmMat4._get(a, c, d);
  12093. cc.kmMat4._set(a, c, d, cc.kmMat4._get(a, e, f));
  12094. cc.kmMat4._set(a, e, f, g)
  12095. };
  12096. cc.kmMat4._gaussj = function(a, c) {
  12097. var d, e = 0,
  12098. f = 0,
  12099. g, h, k, m = [0, 0, 0, 0],
  12100. n = [0, 0, 0, 0],
  12101. q = [0, 0, 0, 0];
  12102. for (d = 0; 4 > d; d++) {
  12103. for (g = k = 0; 4 > g; g++)
  12104. if (1 != q[g])
  12105. 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);
  12106. ++q[e];
  12107. if (f != e) {
  12108. for (g = 0; 4 > g; g++) cc.kmMat4._swap(a, f, g, e, g);
  12109. for (g = 0; 4 > g; g++) cc.kmMat4._swap(c, f, g, e, g)
  12110. }
  12111. n[d] = f;
  12112. m[d] = e;
  12113. if (0 == cc.kmMat4._get(a, e, e)) return cc.KM_FALSE;
  12114. h = 1 / cc.kmMat4._get(a, e, e);
  12115. cc.kmMat4._set(a, e, e, 1);
  12116. for (g = 0; 4 > g; g++) cc.kmMat4._set(a, e, g, cc.kmMat4._get(a, e, g) * h);
  12117. for (g = 0; 4 > g; g++) cc.kmMat4._set(c, e, g, cc.kmMat4._get(c, e, g) * h);
  12118. for (h = 0; 4 > h; h++)
  12119. if (h != e) {
  12120. k = cc.kmMat4._get(a, h, e);
  12121. cc.kmMat4._set(a, h, e, 0);
  12122. 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);
  12123. 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)
  12124. }
  12125. }
  12126. for (g = 3; 0 <= g; g--)
  12127. if (n[g] != m[g])
  12128. for (h = 0; 4 > h; h++) cc.kmMat4._swap(a, h, n[g], h, m[g]);
  12129. return cc.KM_TRUE
  12130. };
  12131. cc.kmMat4._identity = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
  12132. cc.kmMat4Inverse = function(a, c) {
  12133. var d = new cc.kmMat4,
  12134. e = new cc.kmMat4;
  12135. cc.kmMat4Assign(d, c);
  12136. cc.kmMat4Identity(e);
  12137. if (cc.kmMat4._gaussj(d, e) == cc.KM_FALSE) return null;
  12138. cc.kmMat4Assign(a, d);
  12139. return a
  12140. };
  12141. cc.kmMat4IsIdentity = function(a) {
  12142. for (var c = 0; 16 > c; c++)
  12143. if (cc.kmMat4._identity[c] != a.mat[c]) return !1;
  12144. return !0
  12145. };
  12146. cc.kmMat4Transpose = function(a, c) {
  12147. var d, e, f = a.mat,
  12148. g = c.mat;
  12149. for (e = 0; 4 > e; ++e)
  12150. for (d = 0; 4 > d; ++d) f[4 * e + d] = g[4 * d + e];
  12151. return a
  12152. };
  12153. cc.kmMat4Multiply = function(a, c, d) {
  12154. var e = a.mat,
  12155. f = c.mat[0],
  12156. g = c.mat[1],
  12157. h = c.mat[2],
  12158. k = c.mat[3],
  12159. m = c.mat[4],
  12160. n = c.mat[5],
  12161. q = c.mat[6],
  12162. r = c.mat[7],
  12163. t = c.mat[8],
  12164. s = c.mat[9],
  12165. v = c.mat[10],
  12166. u = c.mat[11],
  12167. x = c.mat[12],
  12168. A = c.mat[13],
  12169. D = c.mat[14];
  12170. c = c.mat[15];
  12171. var F = d.mat[0],
  12172. y = d.mat[1],
  12173. z = d.mat[2],
  12174. C = d.mat[3],
  12175. w = d.mat[4],
  12176. B = d.mat[5],
  12177. G = d.mat[6],
  12178. H = d.mat[7],
  12179. E = d.mat[8],
  12180. K = d.mat[9],
  12181. M = d.mat[10],
  12182. L = d.mat[11],
  12183. N = d.mat[12],
  12184. I = d.mat[13],
  12185. J = d.mat[14];
  12186. d = d.mat[15];
  12187. e[0] = F * f + y * m + z * t + C * x;
  12188. e[1] = F * g + y * n + z * s + C * A;
  12189. e[2] = F * h + y * q + z * v + C * D;
  12190. e[3] = F * k + y * r + z * u + C * c;
  12191. e[4] = w * f + B * m + G * t + H * x;
  12192. e[5] = w * g + B * n + G * s + H * A;
  12193. e[6] = w * h + B * q + G * v + H * D;
  12194. e[7] = w * k + B * r + G * u + H * c;
  12195. e[8] = E * f + K * m + M * t + L * x;
  12196. e[9] = E * g + K * n + M * s + L * A;
  12197. e[10] = E * h + K * q + M * v + L * D;
  12198. e[11] = E * k + K * r + M * u + L * c;
  12199. e[12] = N * f + I * m + J * t + d * x;
  12200. e[13] = N * g + I * n + J * s + d * A;
  12201. e[14] = N * h + I * q + J * v + d * D;
  12202. e[15] = N * k + I * r + J * u + d * c;
  12203. return a
  12204. };
  12205. cc.getMat4MultiplyValue = function(a, c) {
  12206. var d = a.mat,
  12207. e = c.mat,
  12208. f = new Float32Array(16);
  12209. f[0] = d[0] * e[0] + d[4] * e[1] + d[8] * e[2] + d[12] * e[3];
  12210. f[1] = d[1] * e[0] + d[5] * e[1] + d[9] * e[2] + d[13] * e[3];
  12211. f[2] = d[2] * e[0] + d[6] * e[1] + d[10] * e[2] + d[14] * e[3];
  12212. f[3] = d[3] * e[0] + d[7] * e[1] + d[11] * e[2] + d[15] * e[3];
  12213. f[4] = d[0] * e[4] + d[4] * e[5] + d[8] * e[6] + d[12] * e[7];
  12214. f[5] = d[1] * e[4] + d[5] * e[5] + d[9] * e[6] + d[13] * e[7];
  12215. f[6] = d[2] * e[4] + d[6] * e[5] + d[10] * e[6] + d[14] * e[7];
  12216. f[7] = d[3] * e[4] + d[7] * e[5] + d[11] * e[6] + d[15] * e[7];
  12217. f[8] = d[0] * e[8] + d[4] * e[9] + d[8] * e[10] + d[12] * e[11];
  12218. f[9] = d[1] * e[8] + d[5] * e[9] + d[9] * e[10] + d[13] * e[11];
  12219. f[10] = d[2] * e[8] + d[6] * e[9] + d[10] * e[10] + d[14] * e[11];
  12220. f[11] = d[3] * e[8] + d[7] * e[9] + d[11] * e[10] + d[15] * e[11];
  12221. f[12] = d[0] * e[12] + d[4] * e[13] + d[8] * e[14] + d[12] * e[15];
  12222. f[13] = d[1] * e[12] + d[5] * e[13] + d[9] * e[14] + d[13] * e[15];
  12223. f[14] = d[2] * e[12] + d[6] * e[13] + d[10] * e[14] + d[14] * e[15];
  12224. f[15] = d[3] * e[12] + d[7] * e[13] + d[11] * e[14] + d[15] * e[15];
  12225. return f
  12226. };
  12227. cc.getMat4MultiplyWithMat4 = function(a, c, d) {
  12228. a = a.mat;
  12229. c = c.mat;
  12230. var e = d.mat;
  12231. e[0] = a[0] * c[0] + a[4] * c[1] + a[8] * c[2] + a[12] * c[3];
  12232. e[1] = a[1] * c[0] + a[5] * c[1] + a[9] * c[2] + a[13] * c[3];
  12233. e[2] = a[2] * c[0] + a[6] * c[1] + a[10] * c[2] + a[14] * c[3];
  12234. e[3] = a[3] * c[0] + a[7] * c[1] + a[11] * c[2] + a[15] * c[3];
  12235. e[4] = a[0] * c[4] + a[4] * c[5] + a[8] * c[6] + a[12] * c[7];
  12236. e[5] = a[1] * c[4] + a[5] * c[5] + a[9] * c[6] + a[13] * c[7];
  12237. e[6] = a[2] * c[4] + a[6] * c[5] + a[10] * c[6] + a[14] * c[7];
  12238. e[7] = a[3] * c[4] + a[7] * c[5] + a[11] * c[6] + a[15] * c[7];
  12239. e[8] = a[0] * c[8] + a[4] * c[9] + a[8] * c[10] + a[12] * c[11];
  12240. e[9] = a[1] * c[8] + a[5] * c[9] + a[9] * c[10] + a[13] * c[11];
  12241. e[10] = a[2] * c[8] + a[6] * c[9] + a[10] * c[10] + a[14] * c[11];
  12242. e[11] = a[3] * c[8] + a[7] * c[9] + a[11] * c[10] + a[15] * c[11];
  12243. e[12] = a[0] * c[12] + a[4] * c[13] + a[8] * c[14] + a[12] * c[15];
  12244. e[13] = a[1] * c[12] + a[5] * c[13] + a[9] * c[14] + a[13] * c[15];
  12245. e[14] = a[2] * c[12] + a[6] * c[13] + a[10] * c[14] + a[14] * c[15];
  12246. e[15] = a[3] * c[12] + a[7] * c[13] + a[11] * c[14] + a[15] * c[15];
  12247. return d.mat
  12248. };
  12249. cc.kmMat4Assign = function(a, c) {
  12250. if (a == c) return cc.log("cc.kmMat4Assign(): pOut equals pIn"), a;
  12251. var d = a.mat,
  12252. e = c.mat;
  12253. d[0] = e[0];
  12254. d[1] = e[1];
  12255. d[2] = e[2];
  12256. d[3] = e[3];
  12257. d[4] = e[4];
  12258. d[5] = e[5];
  12259. d[6] = e[6];
  12260. d[7] = e[7];
  12261. d[8] = e[8];
  12262. d[9] = e[9];
  12263. d[10] = e[10];
  12264. d[11] = e[11];
  12265. d[12] = e[12];
  12266. d[13] = e[13];
  12267. d[14] = e[14];
  12268. d[15] = e[15];
  12269. return a
  12270. };
  12271. cc.kmMat4AreEqual = function(a, c) {
  12272. if (a == c) return cc.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."), !0;
  12273. for (var d = 0; 16 > d; d++)
  12274. if (!(a.mat[d] + cc.kmEpsilon > c.mat[d] && a.mat[d] - cc.kmEpsilon < c.mat[d])) return !1;
  12275. return !0
  12276. };
  12277. cc.kmMat4RotationX = function(a, c) {
  12278. a.mat[0] = 1;
  12279. a.mat[1] = 0;
  12280. a.mat[2] = 0;
  12281. a.mat[3] = 0;
  12282. a.mat[4] = 0;
  12283. a.mat[5] = Math.cos(c);
  12284. a.mat[6] = Math.sin(c);
  12285. a.mat[7] = 0;
  12286. a.mat[8] = 0;
  12287. a.mat[9] = -Math.sin(c);
  12288. a.mat[10] = Math.cos(c);
  12289. a.mat[11] = 0;
  12290. a.mat[12] = 0;
  12291. a.mat[13] = 0;
  12292. a.mat[14] = 0;
  12293. a.mat[15] = 1;
  12294. return a
  12295. };
  12296. cc.kmMat4RotationY = function(a, c) {
  12297. a.mat[0] = Math.cos(c);
  12298. a.mat[1] = 0;
  12299. a.mat[2] = -Math.sin(c);
  12300. a.mat[3] = 0;
  12301. a.mat[4] = 0;
  12302. a.mat[5] = 1;
  12303. a.mat[6] = 0;
  12304. a.mat[7] = 0;
  12305. a.mat[8] = Math.sin(c);
  12306. a.mat[9] = 0;
  12307. a.mat[10] = Math.cos(c);
  12308. a.mat[11] = 0;
  12309. a.mat[12] = 0;
  12310. a.mat[13] = 0;
  12311. a.mat[14] = 0;
  12312. a.mat[15] = 1;
  12313. return a
  12314. };
  12315. cc.kmMat4RotationZ = function(a, c) {
  12316. a.mat[0] = Math.cos(c);
  12317. a.mat[1] = Math.sin(c);
  12318. a.mat[2] = 0;
  12319. a.mat[3] = 0;
  12320. a.mat[4] = -Math.sin(c);
  12321. a.mat[5] = Math.cos(c);
  12322. a.mat[6] = 0;
  12323. a.mat[7] = 0;
  12324. a.mat[8] = 0;
  12325. a.mat[9] = 0;
  12326. a.mat[10] = 1;
  12327. a.mat[11] = 0;
  12328. a.mat[12] = 0;
  12329. a.mat[13] = 0;
  12330. a.mat[14] = 0;
  12331. a.mat[15] = 1;
  12332. return a
  12333. };
  12334. cc.kmMat4RotationPitchYawRoll = function(a, c, d, e) {
  12335. var f = Math.cos(c);
  12336. c = Math.sin(c);
  12337. var g = Math.cos(d);
  12338. d = Math.sin(d);
  12339. var h = Math.cos(e);
  12340. e = Math.sin(e);
  12341. var k = c * d,
  12342. m = f * d;
  12343. a.mat[0] = g * h;
  12344. a.mat[4] = g * e;
  12345. a.mat[8] = -d;
  12346. a.mat[1] = k * h - f * e;
  12347. a.mat[5] = k * e + f * h;
  12348. a.mat[9] = c * g;
  12349. a.mat[2] = m * h + c * e;
  12350. a.mat[6] = m * e - c * h;
  12351. a.mat[10] = f * g;
  12352. a.mat[3] = a.mat[7] = a.mat[11] = 0;
  12353. a.mat[15] = 1;
  12354. return a
  12355. };
  12356. cc.kmMat4RotationQuaternion = function(a, c) {
  12357. a.mat[0] = 1 - 2 * (c.y * c.y + c.z * c.z);
  12358. a.mat[1] = 2 * (c.x * c.y + c.z * c.w);
  12359. a.mat[2] = 2 * (c.x * c.z - c.y * c.w);
  12360. a.mat[3] = 0;
  12361. a.mat[4] = 2 * (c.x * c.y - c.z * c.w);
  12362. a.mat[5] = 1 - 2 * (c.x * c.x + c.z * c.z);
  12363. a.mat[6] = 2 * (c.z * c.y + c.x * c.w);
  12364. a.mat[7] = 0;
  12365. a.mat[8] = 2 * (c.x * c.z + c.y * c.w);
  12366. a.mat[9] = 2 * (c.y * c.z - c.x * c.w);
  12367. a.mat[10] = 1 - 2 * (c.x * c.x + c.y * c.y);
  12368. a.mat[11] = 0;
  12369. a.mat[12] = 0;
  12370. a.mat[13] = 0;
  12371. a.mat[14] = 0;
  12372. a.mat[15] = 1;
  12373. return a
  12374. };
  12375. cc.kmMat4RotationTranslation = function(a, c, d) {
  12376. a.mat[0] = c.mat[0];
  12377. a.mat[1] = c.mat[1];
  12378. a.mat[2] = c.mat[2];
  12379. a.mat[3] = 0;
  12380. a.mat[4] = c.mat[3];
  12381. a.mat[5] = c.mat[4];
  12382. a.mat[6] = c.mat[5];
  12383. a.mat[7] = 0;
  12384. a.mat[8] = c.mat[6];
  12385. a.mat[9] = c.mat[7];
  12386. a.mat[10] = c.mat[8];
  12387. a.mat[11] = 0;
  12388. a.mat[12] = d.x;
  12389. a.mat[13] = d.y;
  12390. a.mat[14] = d.z;
  12391. a.mat[15] = 1;
  12392. return a
  12393. };
  12394. cc.kmMat4Scaling = function(a, c, d, e) {
  12395. a.mat[0] = c;
  12396. a.mat[5] = d;
  12397. a.mat[10] = e;
  12398. a.mat[15] = 1;
  12399. 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;
  12400. return a
  12401. };
  12402. cc.kmMat4Translation = function(a, c, d, e) {
  12403. a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
  12404. 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;
  12405. a.mat[12] = c;
  12406. a.mat[13] = d;
  12407. a.mat[14] = e;
  12408. return a
  12409. };
  12410. cc.kmMat4GetUpVec3 = function(a, c) {
  12411. a.x = c.mat[4];
  12412. a.y = c.mat[5];
  12413. a.z = c.mat[6];
  12414. cc.kmVec3Normalize(a, a);
  12415. return a
  12416. };
  12417. cc.kmMat4GetRightVec3 = function(a, c) {
  12418. a.x = c.mat[0];
  12419. a.y = c.mat[1];
  12420. a.z = c.mat[2];
  12421. cc.kmVec3Normalize(a, a);
  12422. return a
  12423. };
  12424. cc.kmMat4GetForwardVec3 = function(a, c) {
  12425. a.x = c.mat[8];
  12426. a.y = c.mat[9];
  12427. a.z = c.mat[10];
  12428. cc.kmVec3Normalize(a, a);
  12429. return a
  12430. };
  12431. cc.kmMat4PerspectiveProjection = function(a, c, d, e, f) {
  12432. var g = cc.kmDegreesToRadians(c / 2);
  12433. c = f - e;
  12434. var h = Math.sin(g);
  12435. if (0 == c || 0 == h || 0 == d) return null;
  12436. g = Math.cos(g) / h;
  12437. cc.kmMat4Identity(a);
  12438. a.mat[0] = g / d;
  12439. a.mat[5] = g;
  12440. a.mat[10] = -(f + e) / c;
  12441. a.mat[11] = -1;
  12442. a.mat[14] = -2 * e * f / c;
  12443. a.mat[15] = 0;
  12444. return a
  12445. };
  12446. cc.kmMat4OrthographicProjection = function(a, c, d, e, f, g, h) {
  12447. cc.kmMat4Identity(a);
  12448. a.mat[0] = 2 / (d - c);
  12449. a.mat[5] = 2 / (f - e);
  12450. a.mat[10] = -2 / (h - g);
  12451. a.mat[12] = -((d + c) / (d - c));
  12452. a.mat[13] = -((f + e) / (f - e));
  12453. a.mat[14] = -((h + g) / (h - g));
  12454. return a
  12455. };
  12456. cc.kmMat4LookAt = function(a, c, d, e) {
  12457. var f = new cc.kmVec3,
  12458. g = new cc.kmVec3,
  12459. h = new cc.kmVec3,
  12460. k = new cc.kmVec3,
  12461. m = new cc.kmMat4;
  12462. cc.kmVec3Subtract(f, d, c);
  12463. cc.kmVec3Normalize(f, f);
  12464. cc.kmVec3Assign(g, e);
  12465. cc.kmVec3Normalize(g, g);
  12466. cc.kmVec3Cross(h, f, g);
  12467. cc.kmVec3Normalize(h, h);
  12468. cc.kmVec3Cross(k, h, f);
  12469. cc.kmVec3Normalize(h, h);
  12470. cc.kmMat4Identity(a);
  12471. a.mat[0] = h.x;
  12472. a.mat[4] = h.y;
  12473. a.mat[8] = h.z;
  12474. a.mat[1] = k.x;
  12475. a.mat[5] = k.y;
  12476. a.mat[9] = k.z;
  12477. a.mat[2] = -f.x;
  12478. a.mat[6] = -f.y;
  12479. a.mat[10] = -f.z;
  12480. cc.kmMat4Translation(m, -c.x, -c.y, -c.z);
  12481. cc.kmMat4Multiply(a, a, m);
  12482. return a
  12483. };
  12484. cc.kmMat4RotationAxisAngle = function(a, c, d) {
  12485. var e = Math.cos(d);
  12486. d = Math.sin(d);
  12487. var f = new cc.kmVec3;
  12488. cc.kmVec3Normalize(f, c);
  12489. a.mat[0] = e + f.x * f.x * (1 - e);
  12490. a.mat[1] = f.z * d + f.y * f.x * (1 - e);
  12491. a.mat[2] = -f.y * d + f.z * f.x * (1 - e);
  12492. a.mat[3] = 0;
  12493. a.mat[4] = -f.z * d + f.x * f.y * (1 - e);
  12494. a.mat[5] = e + f.y * f.y * (1 - e);
  12495. a.mat[6] = f.x * d + f.z * f.y * (1 - e);
  12496. a.mat[7] = 0;
  12497. a.mat[8] = f.y * d + f.x * f.z * (1 - e);
  12498. a.mat[9] = -f.x * d + f.y * f.z * (1 - e);
  12499. a.mat[10] = e + f.z * f.z * (1 - e);
  12500. a.mat[11] = 0;
  12501. a.mat[12] = 0;
  12502. a.mat[13] = 0;
  12503. a.mat[14] = 0;
  12504. a.mat[15] = 1;
  12505. return a
  12506. };
  12507. cc.kmMat4ExtractRotation = function(a, c) {
  12508. a.mat[0] = c.mat[0];
  12509. a.mat[1] = c.mat[1];
  12510. a.mat[2] = c.mat[2];
  12511. a.mat[3] = c.mat[4];
  12512. a.mat[4] = c.mat[5];
  12513. a.mat[5] = c.mat[6];
  12514. a.mat[6] = c.mat[8];
  12515. a.mat[7] = c.mat[9];
  12516. a.mat[8] = c.mat[10];
  12517. return a
  12518. };
  12519. cc.kmMat4ExtractPlane = function(a, c, d) {
  12520. switch (d) {
  12521. case cc.KM_PLANE_RIGHT:
  12522. a.a = c.mat[3] - c.mat[0];
  12523. a.b = c.mat[7] - c.mat[4];
  12524. a.c = c.mat[11] - c.mat[8];
  12525. a.d = c.mat[15] - c.mat[12];
  12526. break;
  12527. case cc.KM_PLANE_LEFT:
  12528. a.a = c.mat[3] + c.mat[0];
  12529. a.b = c.mat[7] + c.mat[4];
  12530. a.c = c.mat[11] + c.mat[8];
  12531. a.d = c.mat[15] + c.mat[12];
  12532. break;
  12533. case cc.KM_PLANE_BOTTOM:
  12534. a.a = c.mat[3] + c.mat[1];
  12535. a.b = c.mat[7] + c.mat[5];
  12536. a.c = c.mat[11] + c.mat[9];
  12537. a.d = c.mat[15] + c.mat[13];
  12538. break;
  12539. case cc.KM_PLANE_TOP:
  12540. a.a = c.mat[3] - c.mat[1];
  12541. a.b = c.mat[7] - c.mat[5];
  12542. a.c = c.mat[11] - c.mat[9];
  12543. a.d = c.mat[15] - c.mat[13];
  12544. break;
  12545. case cc.KM_PLANE_FAR:
  12546. a.a = c.mat[3] - c.mat[2];
  12547. a.b = c.mat[7] - c.mat[6];
  12548. a.c = c.mat[11] - c.mat[10];
  12549. a.d = c.mat[15] - c.mat[14];
  12550. break;
  12551. case cc.KM_PLANE_NEAR:
  12552. a.a = c.mat[3] + c.mat[2];
  12553. a.b = c.mat[7] + c.mat[6];
  12554. a.c = c.mat[11] + c.mat[10];
  12555. a.d = c.mat[15] + c.mat[14];
  12556. break;
  12557. default:
  12558. cc.log("cc.kmMat4ExtractPlane(): Invalid plane index")
  12559. }
  12560. c = Math.sqrt(a.a * a.a + a.b * a.b + a.c * a.c);
  12561. a.a /= c;
  12562. a.b /= c;
  12563. a.c /= c;
  12564. a.d /= c;
  12565. return a
  12566. };
  12567. cc.kmMat4RotationToAxisAngle = function(a, c, d) {
  12568. var e = new cc.kmQuaternion,
  12569. f = new cc.kmMat3;
  12570. cc.kmMat4ExtractRotation(f, d);
  12571. cc.kmQuaternionRotationMatrix(e, f);
  12572. cc.kmQuaternionToAxisAngle(e, a, c);
  12573. return a
  12574. };
  12575. cc.KM_PLANE_LEFT = 0;
  12576. cc.KM_PLANE_RIGHT = 1;
  12577. cc.KM_PLANE_BOTTOM = 2;
  12578. cc.KM_PLANE_TOP = 3;
  12579. cc.KM_PLANE_NEAR = 4;
  12580. cc.KM_PLANE_FAR = 5;
  12581. cc.kmPlane = function(a, c, d, e) {
  12582. this.a = a || 0;
  12583. this.b = c || 0;
  12584. this.c = d || 0;
  12585. this.d = e || 0
  12586. };
  12587. cc.POINT_INFRONT_OF_PLANE = 0;
  12588. cc.POINT_BEHIND_PLANE = 1;
  12589. cc.POINT_ON_PLANE = 2;
  12590. cc.kmPlaneDot = function(a, c) {
  12591. return a.a * c.x + a.b * c.y + a.c * c.z + a.d * c.w
  12592. };
  12593. cc.kmPlaneDotCoord = function(a, c) {
  12594. return a.a * c.x + a.b * c.y + a.c * c.z + a.d
  12595. };
  12596. cc.kmPlaneDotNormal = function(a, c) {
  12597. return a.a * c.x + a.b * c.y + a.c * c.z
  12598. };
  12599. cc.kmPlaneFromPointNormal = function(a, c, d) {
  12600. a.a = d.x;
  12601. a.b = d.y;
  12602. a.c = d.z;
  12603. a.d = -cc.kmVec3Dot(d, c);
  12604. return a
  12605. };
  12606. cc.kmPlaneFromPoints = function(a, c, d, e) {
  12607. var f = new cc.kmVec3,
  12608. g = new cc.kmVec3,
  12609. h = new cc.kmVec3;
  12610. cc.kmVec3Subtract(g, d, c);
  12611. cc.kmVec3Subtract(h, e, c);
  12612. cc.kmVec3Cross(f, g, h);
  12613. cc.kmVec3Normalize(f, f);
  12614. a.a = f.x;
  12615. a.b = f.y;
  12616. a.c = f.z;
  12617. a.d = cc.kmVec3Dot(cc.kmVec3Scale(f, f, -1), c);
  12618. return a
  12619. };
  12620. cc.kmPlaneIntersectLine = function(a, c, d, e) {
  12621. throw "cc.kmPlaneIntersectLine() hasn't been implemented.";
  12622. };
  12623. cc.kmPlaneNormalize = function(a, c) {
  12624. var d = new cc.kmVec3;
  12625. d.x = c.a;
  12626. d.y = c.b;
  12627. d.z = c.c;
  12628. var e = 1 / cc.kmVec3Length(d);
  12629. cc.kmVec3Normalize(d, d);
  12630. a.a = d.x;
  12631. a.b = d.y;
  12632. a.c = d.z;
  12633. a.d = c.d * e;
  12634. return a
  12635. };
  12636. cc.kmPlaneScale = function(a, c, d) {
  12637. cc.log("cc.kmPlaneScale() has not been implemented.")
  12638. };
  12639. cc.kmPlaneClassifyPoint = function(a, c) {
  12640. var d = a.a * c.x + a.b * c.y + a.c * c.z + a.d;
  12641. return 0.0010 < d ? cc.POINT_INFRONT_OF_PLANE : -0.0010 > d ? cc.POINT_BEHIND_PLANE : cc.POINT_ON_PLANE
  12642. };
  12643. cc.kmQuaternion = function(a, c, d, e) {
  12644. this.x = a || 0;
  12645. this.y = c || 0;
  12646. this.z = d || 0;
  12647. this.w = e || 0
  12648. };
  12649. cc.kmQuaternionConjugate = function(a, c) {
  12650. a.x = -c.x;
  12651. a.y = -c.y;
  12652. a.z = -c.z;
  12653. a.w = c.w;
  12654. return a
  12655. };
  12656. cc.kmQuaternionDot = function(a, c) {
  12657. return a.w * c.w + a.x * c.x + a.y * c.y + a.z * c.z
  12658. };
  12659. cc.kmQuaternionExp = function(a, c) {
  12660. return a
  12661. };
  12662. cc.kmQuaternionIdentity = function(a) {
  12663. a.x = 0;
  12664. a.y = 0;
  12665. a.z = 0;
  12666. a.w = 1;
  12667. return a
  12668. };
  12669. cc.kmQuaternionInverse = function(a, c) {
  12670. var d = cc.kmQuaternionLength(c),
  12671. e = new cc.kmQuaternion;
  12672. if (Math.abs(d) > cc.kmEpsilon) return a.x = 0, a.y = 0, a.z = 0, a.w = 0, a;
  12673. cc.kmQuaternionScale(a, cc.kmQuaternionConjugate(e, c), 1 / d);
  12674. return a
  12675. };
  12676. cc.kmQuaternionIsIdentity = function(a) {
  12677. return 0 == a.x && 0 == a.y && 0 == a.z && 1 == a.w
  12678. };
  12679. cc.kmQuaternionLength = function(a) {
  12680. return Math.sqrt(cc.kmQuaternionLengthSq(a))
  12681. };
  12682. cc.kmQuaternionLengthSq = function(a) {
  12683. return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w
  12684. };
  12685. cc.kmQuaternionLn = function(a, c) {
  12686. return a
  12687. };
  12688. cc.kmQuaternionMultiply = function(a, c, d) {
  12689. a.w = c.w * d.w - c.x * d.x - c.y * d.y - c.z * d.z;
  12690. a.x = c.w * d.x + c.x * d.w + c.y * d.z - c.z * d.y;
  12691. a.y = c.w * d.y + c.y * d.w + c.z * d.x - c.x * d.z;
  12692. a.z = c.w * d.z + c.z * d.w + c.x * d.y - c.y * d.x;
  12693. return a
  12694. };
  12695. cc.kmQuaternionNormalize = function(a, c) {
  12696. var d = cc.kmQuaternionLength(c);
  12697. if (Math.abs(d) <= cc.kmEpsilon) throw "cc.kmQuaternionNormalize(): pIn is an invalid value";
  12698. cc.kmQuaternionScale(a, c, 1 / d);
  12699. return a
  12700. };
  12701. cc.kmQuaternionRotationAxis = function(a, c, d) {
  12702. d *= 0.5;
  12703. var e = Math.sin(d);
  12704. a.w = Math.cos(d);
  12705. a.x = c.x * e;
  12706. a.y = c.y * e;
  12707. a.z = c.z * e;
  12708. return a
  12709. };
  12710. cc.kmQuaternionRotationMatrix = function(a, c) {
  12711. var d, e, f, g;
  12712. d = [];
  12713. e = g = 0;
  12714. if (!c) return null;
  12715. d[0] = c.mat[0];
  12716. d[1] = c.mat[3];
  12717. d[2] = c.mat[6];
  12718. d[4] = c.mat[1];
  12719. d[5] = c.mat[4];
  12720. d[6] = c.mat[7];
  12721. d[8] = c.mat[2];
  12722. d[9] = c.mat[5];
  12723. d[10] = c.mat[8];
  12724. d[15] = 1;
  12725. var h = d[0];
  12726. e = h[0] + h[5] + h[10] + 1;
  12727. 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);
  12728. a.x = d;
  12729. a.y = e;
  12730. a.z = f;
  12731. a.w = g;
  12732. return a
  12733. };
  12734. cc.kmQuaternionRotationYawPitchRoll = function(a, c, d, e) {
  12735. var f, g, h, k, m;
  12736. f = cc.kmDegreesToRadians(d) / 2;
  12737. g = cc.kmDegreesToRadians(c) / 2;
  12738. h = cc.kmDegreesToRadians(e) / 2;
  12739. e = Math.cos(f);
  12740. c = Math.cos(g);
  12741. d = Math.cos(h);
  12742. f = Math.sin(f);
  12743. g = Math.sin(g);
  12744. h = Math.sin(h);
  12745. k = c * d;
  12746. m = g * h;
  12747. a.w = e * k + f * m;
  12748. a.x = f * k - e * m;
  12749. a.y = e * g * d + f * c * h;
  12750. a.z = e * c * h - f * g * d;
  12751. cc.kmQuaternionNormalize(a, a);
  12752. return a
  12753. };
  12754. cc.kmQuaternionSlerp = function(a, c, d, e) {
  12755. 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;
  12756. var f = cc.kmQuaternionDot(c, d),
  12757. g = Math.acos(f),
  12758. h = Math.sqrt(1 - cc.kmSQR(f)),
  12759. f = Math.sin(e * g) / h;
  12760. e = Math.sin((1 - e) * g) / h;
  12761. g = new cc.kmQuaternion;
  12762. h = new cc.kmQuaternion;
  12763. cc.kmQuaternionScale(g, c, e);
  12764. cc.kmQuaternionScale(h, d, f);
  12765. cc.kmQuaternionAdd(a, g, h);
  12766. return a
  12767. };
  12768. cc.kmQuaternionToAxisAngle = function(a, c, d) {
  12769. Math.acos(a.w);
  12770. d = Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z));
  12771. 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))
  12772. };
  12773. cc.kmQuaternionScale = function(a, c, d) {
  12774. a.x = c.x * d;
  12775. a.y = c.y * d;
  12776. a.z = c.z * d;
  12777. a.w = c.w * d;
  12778. return a
  12779. };
  12780. cc.kmQuaternionAssign = function(a, c) {
  12781. a.x = c.x;
  12782. a.y = c.y;
  12783. a.z = c.z;
  12784. a.w = c.w;
  12785. return a
  12786. };
  12787. cc.kmQuaternionAdd = function(a, c, d) {
  12788. a.x = c.x + d.x;
  12789. a.y = c.y + d.y;
  12790. a.z = c.z + d.z;
  12791. a.w = c.w + d.w;
  12792. return a
  12793. };
  12794. cc.kmQuaternionRotationBetweenVec3 = function(a, c, d, e) {
  12795. var f = new cc.kmVec3,
  12796. g = new cc.kmVec3;
  12797. cc.kmVec3Assign(f, c);
  12798. cc.kmVec3Assign(g, d);
  12799. cc.kmVec3Normalize(f, f);
  12800. cc.kmVec3Normalize(g, g);
  12801. d = cc.kmVec3Dot(f, g);
  12802. 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));
  12803. return a
  12804. };
  12805. cc.kmQuaternionMultiplyVec3 = function(a, c, d) {
  12806. var e = new cc.kmVec3,
  12807. f = new cc.kmVec3,
  12808. g = new cc.kmVec3;
  12809. g.x = c.x;
  12810. g.y = c.y;
  12811. g.z = c.z;
  12812. cc.kmVec3Cross(e, g, d);
  12813. cc.kmVec3Cross(f, g, e);
  12814. cc.kmVec3Scale(e, e, 2 * c.w);
  12815. cc.kmVec3Scale(f, f, 2);
  12816. cc.kmVec3Add(a, d, e);
  12817. cc.kmVec3Add(a, a, f);
  12818. return a
  12819. };
  12820. cc.kmAABB = function(a, c) {
  12821. this.min = a || new cc.kmVec3;
  12822. this.max = c || new cc.kmVec3
  12823. };
  12824. cc.kmAABBContainsPoint = function(a, c) {
  12825. 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
  12826. };
  12827. cc.kmAABBAssign = function(a, c) {
  12828. cc.kmVec3Assign(a.min, c.min);
  12829. cc.kmVec3Assign(a.max, c.max);
  12830. return a
  12831. };
  12832. cc.kmAABBScale = function(a, c, d) {
  12833. cc.log("cc.kmAABBScale hasn't been supported.")
  12834. };
  12835. cc.km_mat4_stack = function(a, c, d, e) {
  12836. this.top = d;
  12837. this.stack = e
  12838. };
  12839. cc.km_mat4_stack.INITIAL_SIZE = 30;
  12840. cc.km_mat4_stack_initialize = function(a) {
  12841. a.stack = [];
  12842. a.top = null
  12843. };
  12844. cc.km_mat4_stack_push = function(a, c) {
  12845. a.stack.push(a.top);
  12846. a.top = new cc.kmMat4;
  12847. cc.kmMat4Assign(a.top, c)
  12848. };
  12849. cc.km_mat4_stack_pop = function(a, c) {
  12850. a.top = a.stack.pop()
  12851. };
  12852. cc.km_mat4_stack_release = function(a) {
  12853. a.stack = null;
  12854. a.top = null
  12855. };
  12856. cc.KM_GL_MODELVIEW = 5888;
  12857. cc.KM_GL_PROJECTION = 5889;
  12858. cc.KM_GL_TEXTURE = 5890;
  12859. cc.modelview_matrix_stack = new cc.km_mat4_stack;
  12860. cc.projection_matrix_stack = new cc.km_mat4_stack;
  12861. cc.texture_matrix_stack = new cc.km_mat4_stack;
  12862. cc.current_stack = null;
  12863. cc.initialized = !1;
  12864. cc.lazyInitialize = function() {
  12865. if (!cc.initialized) {
  12866. var a = new cc.kmMat4;
  12867. cc.km_mat4_stack_initialize(cc.modelview_matrix_stack);
  12868. cc.km_mat4_stack_initialize(cc.projection_matrix_stack);
  12869. cc.km_mat4_stack_initialize(cc.texture_matrix_stack);
  12870. cc.current_stack = cc.modelview_matrix_stack;
  12871. cc.initialized = !0;
  12872. cc.kmMat4Identity(a);
  12873. cc.km_mat4_stack_push(cc.modelview_matrix_stack, a);
  12874. cc.km_mat4_stack_push(cc.projection_matrix_stack, a);
  12875. cc.km_mat4_stack_push(cc.texture_matrix_stack, a)
  12876. }
  12877. };
  12878. cc.lazyInitialize();
  12879. cc.kmGLFreeAll = function() {
  12880. cc.km_mat4_stack_release(cc.modelview_matrix_stack);
  12881. cc.km_mat4_stack_release(cc.projection_matrix_stack);
  12882. cc.km_mat4_stack_release(cc.texture_matrix_stack);
  12883. cc.initialized = !1;
  12884. cc.current_stack = null
  12885. };
  12886. cc.kmGLPushMatrix = function() {
  12887. cc.km_mat4_stack_push(cc.current_stack, cc.current_stack.top)
  12888. };
  12889. cc.kmGLPushMatrixWitMat4 = function(a) {
  12890. cc.current_stack.stack.push(cc.current_stack.top);
  12891. cc.kmMat4Assign(a, cc.current_stack.top);
  12892. cc.current_stack.top = a
  12893. };
  12894. cc.kmGLPopMatrix = function() {
  12895. cc.current_stack.top = cc.current_stack.stack.pop()
  12896. };
  12897. cc.kmGLMatrixMode = function(a) {
  12898. switch (a) {
  12899. case cc.KM_GL_MODELVIEW:
  12900. cc.current_stack = cc.modelview_matrix_stack;
  12901. break;
  12902. case cc.KM_GL_PROJECTION:
  12903. cc.current_stack = cc.projection_matrix_stack;
  12904. break;
  12905. case cc.KM_GL_TEXTURE:
  12906. cc.current_stack = cc.texture_matrix_stack;
  12907. break;
  12908. default:
  12909. throw "Invalid matrix mode specified";
  12910. }
  12911. };
  12912. cc.kmGLLoadIdentity = function() {
  12913. cc.kmMat4Identity(cc.current_stack.top)
  12914. };
  12915. cc.kmGLLoadMatrix = function(a) {
  12916. cc.kmMat4Assign(cc.current_stack.top, a)
  12917. };
  12918. cc.kmGLMultMatrix = function(a) {
  12919. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, a)
  12920. };
  12921. cc.kmGLTranslatef = function(a, c, d) {
  12922. var e = new cc.kmMat4;
  12923. cc.kmMat4Translation(e, a, c, d);
  12924. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, e)
  12925. };
  12926. cc.kmGLRotatef = function(a, c, d, e) {
  12927. c = new cc.kmVec3(c, d, e);
  12928. d = new cc.kmMat4;
  12929. cc.kmMat4RotationAxisAngle(d, c, cc.kmDegreesToRadians(a));
  12930. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, d)
  12931. };
  12932. cc.kmGLScalef = function(a, c, d) {
  12933. var e = new cc.kmMat4;
  12934. cc.kmMat4Scaling(e, a, c, d);
  12935. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, e)
  12936. };
  12937. cc.kmGLGetMatrix = function(a, c) {
  12938. switch (a) {
  12939. case cc.KM_GL_MODELVIEW:
  12940. cc.kmMat4Assign(c, cc.modelview_matrix_stack.top);
  12941. break;
  12942. case cc.KM_GL_PROJECTION:
  12943. cc.kmMat4Assign(c, cc.projection_matrix_stack.top);
  12944. break;
  12945. case cc.KM_GL_TEXTURE:
  12946. cc.kmMat4Assign(c, cc.texture_matrix_stack.top);
  12947. break;
  12948. default:
  12949. throw "Invalid matrix mode specified";
  12950. }
  12951. };
  12952. cc.SHADER_POSITION_UCOLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n}\n";
  12953. 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}";
  12954. cc.SHADER_POSITION_COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n} ";
  12955. 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}";
  12956. 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}";
  12957. 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}";
  12958. 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}";
  12959. 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}";
  12960. 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}";
  12961. 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}";
  12962. 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}";
  12963. 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}";
  12964. 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}";
  12965. 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}";
  12966. 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}";
  12967. 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}";
  12968. cc.shaderCache = {
  12969. TYPE_POSITION_TEXTURECOLOR: 0,
  12970. TYPE_POSITION_TEXTURECOLOR_ALPHATEST: 1,
  12971. TYPE_POSITION_COLOR: 2,
  12972. TYPE_POSITION_TEXTURE: 3,
  12973. TYPE_POSITION_TEXTURE_UCOLOR: 4,
  12974. TYPE_POSITION_TEXTURE_A8COLOR: 5,
  12975. TYPE_POSITION_UCOLOR: 6,
  12976. TYPE_POSITION_LENGTH_TEXTURECOLOR: 7,
  12977. TYPE_MAX: 8,
  12978. _programs: {},
  12979. _init: function() {
  12980. this.loadDefaultShaders();
  12981. return !0
  12982. },
  12983. _loadDefaultShader: function(a, c) {
  12984. switch (c) {
  12985. case this.TYPE_POSITION_TEXTURECOLOR:
  12986. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_FRAG);
  12987. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  12988. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  12989. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  12990. break;
  12991. case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:
  12992. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG);
  12993. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  12994. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  12995. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  12996. break;
  12997. case this.TYPE_POSITION_COLOR:
  12998. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT, cc.SHADER_POSITION_COLOR_FRAG);
  12999. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13000. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13001. break;
  13002. case this.TYPE_POSITION_TEXTURE:
  13003. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT, cc.SHADER_POSITION_TEXTURE_FRAG);
  13004. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13005. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13006. break;
  13007. case this.TYPE_POSITION_TEXTURE_UCOLOR:
  13008. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT, cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG);
  13009. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13010. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13011. break;
  13012. case this.TYPE_POSITION_TEXTURE_A8COLOR:
  13013. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT, cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG);
  13014. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13015. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13016. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13017. break;
  13018. case this.TYPE_POSITION_UCOLOR:
  13019. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT, cc.SHADER_POSITION_UCOLOR_FRAG);
  13020. a.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION);
  13021. break;
  13022. case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:
  13023. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT, cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG);
  13024. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13025. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13026. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13027. break;
  13028. default:
  13029. cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type");
  13030. return
  13031. }
  13032. a.link();
  13033. a.updateUniforms()
  13034. },
  13035. loadDefaultShaders: function() {
  13036. var a = new cc.GLProgram;
  13037. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  13038. this._programs[cc.SHADER_POSITION_TEXTURECOLOR] = a;
  13039. this._programs.ShaderPositionTextureColor = a;
  13040. a = new cc.GLProgram;
  13041. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  13042. this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST] = a;
  13043. this._programs.ShaderPositionTextureColorAlphaTest = a;
  13044. a = new cc.GLProgram;
  13045. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  13046. this._programs[cc.SHADER_POSITION_COLOR] = a;
  13047. this._programs.ShaderPositionColor = a;
  13048. a = new cc.GLProgram;
  13049. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  13050. this._programs[cc.SHADER_POSITION_TEXTURE] = a;
  13051. this._programs.ShaderPositionTexture = a;
  13052. a = new cc.GLProgram;
  13053. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  13054. this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR] = a;
  13055. this._programs.ShaderPositionTextureUColor = a;
  13056. a = new cc.GLProgram;
  13057. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  13058. this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR] = a;
  13059. this._programs.ShaderPositionTextureA8Color = a;
  13060. a = new cc.GLProgram;
  13061. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR);
  13062. this._programs[cc.SHADER_POSITION_UCOLOR] = a;
  13063. this._programs.ShaderPositionUColor = a;
  13064. a = new cc.GLProgram;
  13065. this._loadDefaultShader(a, this.TYPE_POSITION_LENGTH_TEXTURECOLOR);
  13066. this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR] = a;
  13067. this._programs.ShaderPositionLengthTextureColor = a
  13068. },
  13069. reloadDefaultShaders: function() {
  13070. var a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  13071. a.reset();
  13072. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  13073. a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
  13074. a.reset();
  13075. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  13076. a = this.programForKey(cc.SHADER_POSITION_COLOR);
  13077. a.reset();
  13078. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  13079. a = this.programForKey(cc.SHADER_POSITION_TEXTURE);
  13080. a.reset();
  13081. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  13082. a = this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  13083. a.reset();
  13084. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  13085. a = this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);
  13086. a.reset();
  13087. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  13088. a = this.programForKey(cc.SHADER_POSITION_UCOLOR);
  13089. a.reset();
  13090. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR)
  13091. },
  13092. programForKey: function(a) {
  13093. return this._programs[a]
  13094. },
  13095. getProgram: function(a) {
  13096. return this._programs[a]
  13097. },
  13098. addProgram: function(a, c) {
  13099. this._programs[c] = a
  13100. }
  13101. };
  13102. cc.HashUniformEntry = function(a, c, d) {
  13103. this.value = a;
  13104. this.location = c;
  13105. this.hh = d || {}
  13106. };
  13107. cc.GLProgram = cc.Class.extend({
  13108. _glContext: null,
  13109. _programObj: null,
  13110. _vertShader: null,
  13111. _fragShader: null,
  13112. _uniforms: null,
  13113. _hashForUniforms: null,
  13114. _usesTime: !1,
  13115. _updateUniformLocation: function(a, c, d) {
  13116. if (null == a) return !1;
  13117. d = !0;
  13118. for (var e = null, f = 0; f < this._hashForUniforms.length; f++) this._hashForUniforms[f].location == a && (e = this._hashForUniforms[f]);
  13119. e ? e.value == c ? d = !1 : e.value = c : (e = new cc.HashUniformEntry, e.location = a, e.value = c, this._hashForUniforms.push(e));
  13120. return d
  13121. },
  13122. _description: function() {
  13123. return "\x3cCCGLProgram \x3d " + this.toString() + " | Program \x3d " + this._programObj.toString() + ", VertexShader \x3d " + this._vertShader.toString() + ", FragmentShader \x3d " + this._fragShader.toString() + "\x3e"
  13124. },
  13125. _compileShader: function(a, c, d) {
  13126. if (!d || !a) return !1;
  13127. 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);
  13128. this._glContext.compileShader(a);
  13129. d = this._glContext.getShaderParameter(a, this._glContext.COMPILE_STATUS);
  13130. 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()));
  13131. return 1 == d
  13132. },
  13133. ctor: function(a, c, d) {
  13134. this._uniforms = [];
  13135. this._hashForUniforms = [];
  13136. this._glContext = d || cc._renderContext;
  13137. a && c && this.init(a, c)
  13138. },
  13139. destroyProgram: function() {
  13140. this._hashForUniforms = this._uniforms = this._fragShader = this._vertShader = null;
  13141. this._glContext.deleteProgram(this._programObj)
  13142. },
  13143. initWithVertexShaderByteArray: function(a, c) {
  13144. var d = this._glContext;
  13145. this._programObj = d.createProgram();
  13146. this._fragShader = this._vertShader = null;
  13147. 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"));
  13148. 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"));
  13149. this._vertShader && d.attachShader(this._programObj, this._vertShader);
  13150. cc.checkGLErrorDebug();
  13151. this._fragShader && d.attachShader(this._programObj, this._fragShader);
  13152. this._hashForUniforms.length = 0;
  13153. cc.checkGLErrorDebug();
  13154. return !0
  13155. },
  13156. initWithString: function(a, c) {
  13157. return this.initWithVertexShaderByteArray(a, c)
  13158. },
  13159. initWithVertexShaderFilename: function(a, c) {
  13160. var d = cc.loader.getRes(a);
  13161. if (!d) throw "Please load the resource firset : " + a;
  13162. var e = cc.loader.getRes(c);
  13163. if (!e) throw "Please load the resource firset : " + c;
  13164. return this.initWithVertexShaderByteArray(d, e)
  13165. },
  13166. init: function(a, c) {
  13167. return this.initWithVertexShaderFilename(a, c)
  13168. },
  13169. addAttribute: function(a, c) {
  13170. this._glContext.bindAttribLocation(this._programObj, c, a)
  13171. },
  13172. link: function() {
  13173. if (!this._programObj) return cc.log("cc.GLProgram.link(): Cannot link invalid program"), !1;
  13174. this._glContext.linkProgram(this._programObj);
  13175. this._vertShader && this._glContext.deleteShader(this._vertShader);
  13176. this._fragShader && this._glContext.deleteShader(this._fragShader);
  13177. this._fragShader = this._vertShader = null;
  13178. 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
  13179. },
  13180. use: function() {
  13181. cc.glUseProgram(this._programObj)
  13182. },
  13183. updateUniforms: function() {
  13184. this._uniforms[cc.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S);
  13185. this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S);
  13186. this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S);
  13187. this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S);
  13188. this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S);
  13189. this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S);
  13190. this._usesTime = null != this._uniforms[cc.UNIFORM_TIME] || null != this._uniforms[cc.UNIFORM_SINTIME] || null != this._uniforms[cc.UNIFORM_COSTIME];
  13191. this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S);
  13192. this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S);
  13193. this.use();
  13194. this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER], 0)
  13195. },
  13196. getUniformLocationForName: function(a) {
  13197. if (!a) throw "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null";
  13198. if (!this._programObj) throw "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized";
  13199. return this._glContext.getUniformLocation(this._programObj, a)
  13200. },
  13201. getUniformMVPMatrix: function() {
  13202. return this._uniforms[cc.UNIFORM_MVPMATRIX]
  13203. },
  13204. getUniformSampler: function() {
  13205. return this._uniforms[cc.UNIFORM_SAMPLER]
  13206. },
  13207. setUniformLocationWith1i: function(a, c) {
  13208. this._updateUniformLocation(a, c) && this._glContext.uniform1i(a, c)
  13209. },
  13210. setUniformLocationWith2i: function(a, c, d) {
  13211. this._updateUniformLocation(a, [c, d]) && this._glContext.uniform2i(a, c, d)
  13212. },
  13213. setUniformLocationWith3i: function(a, c, d, e) {
  13214. this._updateUniformLocation(a, [c, d, e]) && this._glContext.uniform3i(a, c, d, e)
  13215. },
  13216. setUniformLocationWith4i: function(a, c, d, e, f) {
  13217. this._updateUniformLocation(a, [c, d, e, f]) && this._glContext.uniform4i(a, c, d, e, f)
  13218. },
  13219. setUniformLocationWith2iv: function(a, c, d) {
  13220. this._updateUniformLocation(a, c) && this._glContext.uniform2iv(a, c)
  13221. },
  13222. setUniformLocationWith3iv: function(a, c, d) {
  13223. this._updateUniformLocation(a, c) && this._glContext.uniform3iv(a, c)
  13224. },
  13225. setUniformLocationWith4iv: function(a, c, d) {
  13226. this._updateUniformLocation(a, c) && this._glContext.uniform4iv(a, c)
  13227. },
  13228. setUniformLocationI32: function(a, c) {
  13229. this.setUniformLocationWith1i(a, c)
  13230. },
  13231. setUniformLocationWith1f: function(a, c) {
  13232. this._updateUniformLocation(a, c) && this._glContext.uniform1f(a, c)
  13233. },
  13234. setUniformLocationWith2f: function(a, c, d) {
  13235. this._updateUniformLocation(a, [c, d]) && this._glContext.uniform2f(a, c, d)
  13236. },
  13237. setUniformLocationWith3f: function(a, c, d, e) {
  13238. this._updateUniformLocation(a, [c, d, e]) && this._glContext.uniform3f(a, c, d, e)
  13239. },
  13240. setUniformLocationWith4f: function(a, c, d, e, f) {
  13241. this._updateUniformLocation(a, [c, d, e, f]) && this._glContext.uniform4f(a, c, d, e, f)
  13242. },
  13243. setUniformLocationWith2fv: function(a, c, d) {
  13244. this._updateUniformLocation(a, c) && this._glContext.uniform2fv(a, c)
  13245. },
  13246. setUniformLocationWith3fv: function(a, c, d) {
  13247. this._updateUniformLocation(a, c) && this._glContext.uniform3fv(a, c)
  13248. },
  13249. setUniformLocationWith4fv: function(a, c, d) {
  13250. this._updateUniformLocation(a, c) && this._glContext.uniform4fv(a, c)
  13251. },
  13252. setUniformLocationWithMatrix4fv: function(a, c, d) {
  13253. this._updateUniformLocation(a, c) && this._glContext.uniformMatrix4fv(a, !1, c)
  13254. },
  13255. setUniformLocationF32: function() {
  13256. if (!(2 > arguments.length)) switch (arguments.length) {
  13257. case 2:
  13258. this.setUniformLocationWith1f(arguments[0], arguments[1]);
  13259. break;
  13260. case 3:
  13261. this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]);
  13262. break;
  13263. case 4:
  13264. this.setUniformLocationWith3f(arguments[0], arguments[1], arguments[2], arguments[3]);
  13265. break;
  13266. case 5:
  13267. this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
  13268. }
  13269. },
  13270. setUniformsForBuiltins: function() {
  13271. var a = new cc.kmMat4,
  13272. c = new cc.kmMat4,
  13273. d = new cc.kmMat4;
  13274. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a);
  13275. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, c);
  13276. cc.kmMat4Multiply(d, a, c);
  13277. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], a.mat, 1);
  13278. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], c.mat, 1);
  13279. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], d.mat, 1);
  13280. 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())
  13281. },
  13282. setUniformForModelViewProjectionMatrix: function() {
  13283. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top))
  13284. },
  13285. setUniformForModelViewProjectionMatrixWithMat4: function(a) {
  13286. cc.kmMat4Multiply(a, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top);
  13287. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, a.mat)
  13288. },
  13289. setUniformForModelViewAndProjectionMatrixWithMat4: function() {
  13290. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, cc.modelview_matrix_stack.top.mat);
  13291. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat)
  13292. },
  13293. vertexShaderLog: function() {
  13294. return this._glContext.getShaderInfoLog(this._vertShader)
  13295. },
  13296. getVertexShaderLog: function() {
  13297. return this._glContext.getShaderInfoLog(this._vertShader)
  13298. },
  13299. getFragmentShaderLog: function() {
  13300. return this._glContext.getShaderInfoLog(this._vertShader)
  13301. },
  13302. fragmentShaderLog: function() {
  13303. return this._glContext.getShaderInfoLog(this._fragShader)
  13304. },
  13305. programLog: function() {
  13306. return this._glContext.getProgramInfoLog(this._programObj)
  13307. },
  13308. getProgramLog: function() {
  13309. return this._glContext.getProgramInfoLog(this._programObj)
  13310. },
  13311. reset: function() {
  13312. this._fragShader = this._vertShader = null;
  13313. this._uniforms.length = 0;
  13314. this._glContext.deleteProgram(this._programObj);
  13315. this._programObj = null;
  13316. for (var a = 0; a < this._hashForUniforms.length; a++) this._hashForUniforms[a].value = null, this._hashForUniforms[a] = null;
  13317. this._hashForUniforms.length = 0
  13318. },
  13319. getProgram: function() {
  13320. return this._programObj
  13321. },
  13322. retain: function() {},
  13323. release: function() {}
  13324. });
  13325. cc.GLProgram.create = function(a, c) {
  13326. return new cc.GLProgram(a, c)
  13327. };
  13328. cc._currentProjectionMatrix = -1;
  13329. cc._vertexAttribPosition = !1;
  13330. cc._vertexAttribColor = !1;
  13331. cc._vertexAttribTexCoords = !1;
  13332. 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));
  13333. cc.glInvalidateStateCache = function() {
  13334. cc.kmGLFreeAll();
  13335. cc._currentProjectionMatrix = -1;
  13336. cc._vertexAttribPosition = !1;
  13337. cc._vertexAttribColor = !1;
  13338. cc._vertexAttribTexCoords = !1;
  13339. if (cc.ENABLE_GL_STATE_CACHE) {
  13340. cc._currentShaderProgram = -1;
  13341. for (var a = 0; a < cc.MAX_ACTIVETEXTURE; a++) cc._currentBoundTexture[a] = -1;
  13342. cc._blendingSource = -1;
  13343. cc._blendingDest = -1;
  13344. cc._GLServerState = 0
  13345. }
  13346. };
  13347. cc.glUseProgram = function(a) {
  13348. a !== cc._currentShaderProgram && (cc._currentShaderProgram = a, cc._renderContext.useProgram(a))
  13349. };
  13350. cc.ENABLE_GL_STATE_CACHE || (cc.glUseProgram = function(a) {
  13351. cc._renderContext.useProgram(a)
  13352. });
  13353. cc.glDeleteProgram = function(a) {
  13354. cc.ENABLE_GL_STATE_CACHE && a === cc._currentShaderProgram && (cc._currentShaderProgram = -1);
  13355. gl.deleteProgram(a)
  13356. };
  13357. cc.glBlendFunc = function(a, c) {
  13358. if (a !== cc._blendingSource || c !== cc._blendingDest) cc._blendingSource = a, cc._blendingDest = c, cc.setBlending(a, c)
  13359. };
  13360. cc.setBlending = function(a, c) {
  13361. var d = cc._renderContext;
  13362. a === d.ONE && c === d.ZERO ? d.disable(d.BLEND) : (d.enable(d.BLEND), cc._renderContext.blendFunc(a, c))
  13363. };
  13364. cc.glBlendFuncForParticle = function(a, c) {
  13365. if (a !== cc._blendingSource || c !== cc._blendingDest) {
  13366. cc._blendingSource = a;
  13367. cc._blendingDest = c;
  13368. var d = cc._renderContext;
  13369. a === d.ONE && c === d.ZERO ? d.disable(d.BLEND) : (d.enable(d.BLEND), d.blendFuncSeparate(d.SRC_ALPHA, c, a, c))
  13370. }
  13371. };
  13372. cc.ENABLE_GL_STATE_CACHE || (cc.glBlendFunc = cc.setBlending);
  13373. cc.glBlendResetToCache = function() {
  13374. var a = cc._renderContext;
  13375. a.blendEquation(a.FUNC_ADD);
  13376. cc.ENABLE_GL_STATE_CACHE ? cc.setBlending(cc._blendingSource, cc._blendingDest) : cc.setBlending(a.BLEND_SRC, a.BLEND_DST)
  13377. };
  13378. cc.setProjectionMatrixDirty = function() {
  13379. cc._currentProjectionMatrix = -1
  13380. };
  13381. cc.glEnableVertexAttribs = function(a) {
  13382. var c = cc._renderContext,
  13383. d = a & cc.VERTEX_ATTRIB_FLAG_POSITION;
  13384. d !== cc._vertexAttribPosition && (d ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION), cc._vertexAttribPosition = d);
  13385. d = a & cc.VERTEX_ATTRIB_FLAG_COLOR;
  13386. d !== cc._vertexAttribColor && (d ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR), cc._vertexAttribColor = d);
  13387. a &= cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  13388. a !== cc._vertexAttribTexCoords && (a ? c.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS) : c.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS), cc._vertexAttribTexCoords = a)
  13389. };
  13390. cc.glBindTexture2D = function(a) {
  13391. cc.glBindTexture2DN(0, a)
  13392. };
  13393. cc.glBindTexture2DN = function(a, c) {
  13394. if (cc._currentBoundTexture[a] != c) {
  13395. cc._currentBoundTexture[a] = c;
  13396. var d = cc._renderContext;
  13397. d.activeTexture(d.TEXTURE0 + a);
  13398. c ? d.bindTexture(d.TEXTURE_2D, c._webTextureObj) : d.bindTexture(d.TEXTURE_2D, null)
  13399. }
  13400. };
  13401. cc.ENABLE_GL_STATE_CACHE || (cc.glBindTexture2DN = function(a, c) {
  13402. var d = cc._renderContext;
  13403. d.activeTexture(d.TEXTURE0 + a);
  13404. c ? d.bindTexture(d.TEXTURE_2D, c._webTextureObj) : d.bindTexture(d.TEXTURE_2D, null)
  13405. });
  13406. cc.glDeleteTexture = function(a) {
  13407. cc.glDeleteTextureN(0, a)
  13408. };
  13409. cc.glDeleteTextureN = function(a, c) {
  13410. cc.ENABLE_GL_STATE_CACHE && c == cc._currentBoundTexture[a] && (cc._currentBoundTexture[a] = -1);
  13411. cc._renderContext.deleteTexture(c)
  13412. };
  13413. cc.glBindVAO = function(a) {
  13414. cc.TEXTURE_ATLAS_USE_VAO && (cc.ENABLE_GL_STATE_CACHE && cc._uVAO != a) && (cc._uVAO = a)
  13415. };
  13416. cc.glEnable = function(a) {};
  13417. cc.IMAGE_FORMAT_JPEG = 0;
  13418. cc.IMAGE_FORMAT_PNG = 1;
  13419. cc.IMAGE_FORMAT_RAWDATA = 9;
  13420. cc.NextPOT = function(a) {
  13421. a -= 1;
  13422. a |= a >> 1;
  13423. a |= a >> 2;
  13424. a |= a >> 4;
  13425. a |= a >> 8;
  13426. return (a | a >> 16) + 1
  13427. };
  13428. cc.RenderTexture = cc.Node.extend({
  13429. sprite: null,
  13430. clearFlags: 0,
  13431. clearDepthVal: 0,
  13432. autoDraw: !1,
  13433. _cacheCanvas: null,
  13434. _cacheContext: null,
  13435. _fBO: 0,
  13436. _depthRenderBuffer: 0,
  13437. _oldFBO: 0,
  13438. _texture: null,
  13439. _textureCopy: null,
  13440. _uITextureImage: null,
  13441. _pixelFormat: cc.Texture2D.PIXEL_FORMAT_RGBA8888,
  13442. _clearColor: null,
  13443. clearStencilVal: 0,
  13444. _clearColorStr: null,
  13445. _className: "RenderTexture",
  13446. ctor: null,
  13447. _ctorForCanvas: function(a, c, d, e) {
  13448. cc.Node.prototype.ctor.call(this);
  13449. this._clearColor = cc.color(255, 255, 255, 255);
  13450. this._clearColorStr = "rgba(255,255,255,1)";
  13451. this._cacheCanvas = cc.newElement("canvas");
  13452. this._cacheContext = this._cacheCanvas.getContext("2d");
  13453. this.anchorY = this.anchorX = 0;
  13454. void 0 !== a && void 0 !== c && (d = d || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, c, d, e || 0))
  13455. },
  13456. _ctorForWebGL: function(a, c, d, e) {
  13457. cc.Node.prototype.ctor.call(this);
  13458. this._clearColor = cc.color(0, 0, 0, 0);
  13459. void 0 !== a && void 0 !== c && (d = d || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, c, d, e || 0))
  13460. },
  13461. cleanup: null,
  13462. _cleanupForCanvas: function() {
  13463. cc.Node.prototype.onExit.call(this);
  13464. this._cacheCanvas = this._cacheContext = null
  13465. },
  13466. _cleanupForWebGL: function() {
  13467. cc.Node.prototype.onExit.call(this);
  13468. this._textureCopy = null;
  13469. var a = cc._renderContext;
  13470. a.deleteFramebuffer(this._fBO);
  13471. this._depthRenderBuffer && a.deleteRenderbuffer(this._depthRenderBuffer);
  13472. this._uITextureImage = null
  13473. },
  13474. getSprite: function() {
  13475. return this.sprite
  13476. },
  13477. setSprite: function(a) {
  13478. this.sprite = a
  13479. },
  13480. initWithWidthAndHeight: null,
  13481. _initWithWidthAndHeightForCanvas: function(a, c, d, e) {
  13482. d = this._cacheCanvas;
  13483. e = cc.contentScaleFactor();
  13484. d.width = 0 | a * e;
  13485. d.height = 0 | c * e;
  13486. this._cacheContext.translate(0, d.height);
  13487. a = new cc.Texture2D;
  13488. a.initWithElement(d);
  13489. a.handleLoadedTexture();
  13490. this.sprite = cc.Sprite.create(a);
  13491. return !0
  13492. },
  13493. _initWithWidthAndHeightForWebGL: function(a, c, d, e) {
  13494. d == cc.Texture2D.PIXEL_FORMAT_A8 && cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;");
  13495. var f = cc._renderContext,
  13496. g = cc.contentScaleFactor();
  13497. a = 0 | a * g;
  13498. c = 0 | c * g;
  13499. this._oldFBO = f.getParameter(f.FRAMEBUFFER_BINDING);
  13500. var h;
  13501. cc.configuration.supportsNPOT() ? (g = a, h = c) : (g = cc.NextPOT(a), h = cc.NextPOT(c));
  13502. for (var k = new Uint8Array(4 * g * h), m = 0; m < 4 * g * h; m++) k[m] = 0;
  13503. this._pixelFormat = d;
  13504. this._texture = new cc.Texture2D;
  13505. if (!this._texture) return !1;
  13506. m = this._texture;
  13507. m.initWithData(k, this._pixelFormat, g, h, cc.size(a, c));
  13508. d = f.getParameter(f.RENDERBUFFER_BINDING);
  13509. if (cc.configuration.checkForGLExtension("GL_QCOM")) {
  13510. this._textureCopy = new cc.Texture2D;
  13511. if (!this._textureCopy) return !1;
  13512. this._textureCopy.initWithData(k, this._pixelFormat, g, h, cc.size(a, c))
  13513. }
  13514. this._fBO = f.createFramebuffer();
  13515. f.bindFramebuffer(f.FRAMEBUFFER, this._fBO);
  13516. f.framebufferTexture2D(f.FRAMEBUFFER, f.COLOR_ATTACHMENT0, f.TEXTURE_2D, m._webTextureObj, 0);
  13517. 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));
  13518. f.checkFramebufferStatus(f.FRAMEBUFFER) !== f.FRAMEBUFFER_COMPLETE && cc.log("Could not attach texture to the framebuffer");
  13519. m.setAliasTexParameters();
  13520. a = this.sprite = cc.Sprite.create(m);
  13521. a.scaleY = -1;
  13522. a.setBlendFunc(f.ONE, f.ONE_MINUS_SRC_ALPHA);
  13523. f.bindRenderbuffer(f.RENDERBUFFER, d);
  13524. f.bindFramebuffer(f.FRAMEBUFFER, this._oldFBO);
  13525. this.autoDraw = !1;
  13526. this.addChild(a);
  13527. return !0
  13528. },
  13529. begin: null,
  13530. _beginForCanvas: function() {
  13531. cc._renderContext = this._cacheContext;
  13532. cc.view._setScaleXYForRenderTexture()
  13533. },
  13534. _beginForWebGL: function() {
  13535. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  13536. cc.kmGLPushMatrix();
  13537. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  13538. cc.kmGLPushMatrix();
  13539. var a = cc.director;
  13540. a.setProjection(a.getProjection());
  13541. var c = this._texture.getContentSizeInPixels(),
  13542. d = cc.director.getWinSizeInPixels(),
  13543. a = d.width / c.width,
  13544. d = d.height / c.height,
  13545. e = cc._renderContext;
  13546. e.viewport(0, 0, c.width, c.height);
  13547. c = new cc.kmMat4;
  13548. cc.kmMat4OrthographicProjection(c, -1 / a, 1 / a, -1 / d, 1 / d, -1, 1);
  13549. cc.kmGLMultMatrix(c);
  13550. this._oldFBO = e.getParameter(e.FRAMEBUFFER_BINDING);
  13551. e.bindFramebuffer(e.FRAMEBUFFER, this._fBO);
  13552. 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))
  13553. },
  13554. beginWithClear: function(a, c, d, e, f, g) {
  13555. var h = cc._renderContext;
  13556. f = f || h.COLOR_BUFFER_BIT;
  13557. g = g || h.COLOR_BUFFER_BIT | h.DEPTH_BUFFER_BIT;
  13558. this._beginWithClear(a / 255, c / 255, d / 255, e / 255, f, g, h.COLOR_BUFFER_BIT | h.DEPTH_BUFFER_BIT | h.STENCIL_BUFFER_BIT)
  13559. },
  13560. _beginWithClear: null,
  13561. _beginWithClearForCanvas: function(a, c, d, e, f, g, h) {
  13562. this.begin();
  13563. a = a || 0;
  13564. c = c || 0;
  13565. d = d || 0;
  13566. e = isNaN(e) ? 1 : e;
  13567. f = this._cacheContext;
  13568. g = this._cacheCanvas;
  13569. f.save();
  13570. f.fillStyle = "rgba(" + (0 | a) + "," + (0 | c) + "," + (0 | d) + "," + e / 255 + ")";
  13571. f.clearRect(0, 0, g.width, -g.height);
  13572. f.fillRect(0, 0, g.width, -g.height);
  13573. f.restore()
  13574. },
  13575. _beginWithClearForWebGL: function(a, c, d, e, f, g, h) {
  13576. this.begin();
  13577. var k = cc._renderContext,
  13578. m = [0, 0, 0, 0],
  13579. n = 0,
  13580. q = 0;
  13581. h & k.COLOR_BUFFER_BIT && (m = k.getParameter(k.COLOR_CLEAR_VALUE), k.clearColor(a, c, d, e));
  13582. h & k.DEPTH_BUFFER_BIT && (n = k.getParameter(k.DEPTH_CLEAR_VALUE), k.clearDepth(f));
  13583. h & k.STENCIL_BUFFER_BIT && (q = k.getParameter(k.STENCIL_CLEAR_VALUE), k.clearStencil(g));
  13584. k.clear(h);
  13585. h & k.COLOR_BUFFER_BIT && k.clearColor(m[0], m[1], m[2], m[3]);
  13586. h & k.DEPTH_BUFFER_BIT && k.clearDepth(n);
  13587. h & k.STENCIL_BUFFER_BIT && k.clearStencil(q)
  13588. },
  13589. end: null,
  13590. _endForCanvas: function() {
  13591. cc._renderContext = cc._mainRenderContextBackup;
  13592. cc.view._resetScale()
  13593. },
  13594. _endForWebGL: function() {
  13595. var a = cc._renderContext,
  13596. c = cc.director;
  13597. a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
  13598. c.setViewport();
  13599. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  13600. cc.kmGLPopMatrix();
  13601. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  13602. cc.kmGLPopMatrix()
  13603. },
  13604. clear: function(a, c, d, e) {
  13605. this.beginWithClear(a, c, d, e);
  13606. this.end()
  13607. },
  13608. clearRect: null,
  13609. _clearRectForCanvas: function(a, c, d, e) {
  13610. this._cacheContext.clearRect(a, c, d, -e)
  13611. },
  13612. _clearRectForWebGL: function(a, c, d, e) {},
  13613. clearDepth: null,
  13614. _clearDepthForCanvas: function(a) {
  13615. cc.log("clearDepth isn't supported on Cocos2d-Html5")
  13616. },
  13617. _clearDepthForWebGL: function(a) {
  13618. this.begin();
  13619. var c = cc._renderContext,
  13620. d = c.getParameter(c.DEPTH_CLEAR_VALUE);
  13621. c.clearDepth(a);
  13622. c.clear(c.DEPTH_BUFFER_BIT);
  13623. c.clearDepth(d);
  13624. this.end()
  13625. },
  13626. clearStencil: null,
  13627. _clearStencilForCanvas: function(a) {
  13628. cc.log("clearDepth isn't supported on Cocos2d-Html5")
  13629. },
  13630. _clearStencilForWebGL: function(a) {
  13631. var c = cc._renderContext,
  13632. d = c.getParameter(c.STENCIL_CLEAR_VALUE);
  13633. c.clearStencil(a);
  13634. c.clear(c.STENCIL_BUFFER_BIT);
  13635. c.clearStencil(d)
  13636. },
  13637. visit: null,
  13638. _visitForCanvas: function(a) {
  13639. this._visible && (a = a || cc._renderContext, a.save(), this.draw(a), this.transform(a), this.sprite.visit(), a.restore(), this.arrivalOrder = 0)
  13640. },
  13641. _visitForWebGL: function(a) {
  13642. if (this._visible) {
  13643. cc.kmGLPushMatrix();
  13644. var c = this.grid;
  13645. c && c.isActive() && (c.beforeDraw(), this.transformAncestors());
  13646. this.transform(a);
  13647. this.sprite.visit();
  13648. this.draw(a);
  13649. c && c.isActive() && c.afterDraw(this);
  13650. cc.kmGLPopMatrix();
  13651. this.arrivalOrder = 0
  13652. }
  13653. },
  13654. draw: null,
  13655. _drawForCanvas: function(a) {
  13656. a = a || cc._renderContext;
  13657. if (this.autoDraw) {
  13658. this.begin();
  13659. if (this.clearFlags) {
  13660. var c = this._cacheCanvas;
  13661. a.save();
  13662. a.fillStyle = this._clearColorStr;
  13663. a.clearRect(0, 0, c.width, -c.height);
  13664. a.fillRect(0, 0, c.width, -c.height);
  13665. a.restore()
  13666. }
  13667. this.sortAllChildren();
  13668. a = this._children;
  13669. for (var c = a.length, d = this.sprite, e = 0; e < c; e++) {
  13670. var f = a[e];
  13671. f != d && f.visit()
  13672. }
  13673. this.end()
  13674. }
  13675. },
  13676. _drawForWebGL: function(a) {
  13677. a = cc._renderContext;
  13678. if (this.autoDraw) {
  13679. this.begin();
  13680. var c = this.clearFlags;
  13681. if (c) {
  13682. var d = [0, 0, 0, 0],
  13683. e = 0,
  13684. f = 0;
  13685. 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));
  13686. c & a.DEPTH_BUFFER_BIT && (e = a.getParameter(a.DEPTH_CLEAR_VALUE), a.clearDepth(this.clearDepthVal));
  13687. c & a.STENCIL_BUFFER_BIT && (f = a.getParameter(a.STENCIL_CLEAR_VALUE), a.clearStencil(this.clearStencilVal));
  13688. a.clear(c);
  13689. c & a.COLOR_BUFFER_BIT && a.clearColor(d[0], d[1], d[2], d[3]);
  13690. c & a.DEPTH_BUFFER_BIT && a.clearDepth(e);
  13691. c & a.STENCIL_BUFFER_BIT && a.clearStencil(f)
  13692. }
  13693. this.sortAllChildren();
  13694. a = this._children;
  13695. for (c = 0; c < a.length; c++) d = a[c], d != this.sprite && d.visit();
  13696. this.end()
  13697. }
  13698. },
  13699. newCCImage: function(a) {
  13700. cc.log("saveToFile isn't supported on cocos2d-html5");
  13701. return null
  13702. },
  13703. _memcpy: function(a, c, d, e, f) {
  13704. for (var g = 0; g < f; g++) a[c + g] = d[e + g]
  13705. },
  13706. saveToFile: function(a, c) {
  13707. cc.log("saveToFile isn't supported on Cocos2d-Html5")
  13708. },
  13709. listenToBackground: function(a) {
  13710. cc.log("listenToBackground isn't supported on Cocos2d-Html5")
  13711. },
  13712. listenToForeground: function(a) {
  13713. cc.log("listenToForeground isn't supported on Cocos2d-Html5")
  13714. },
  13715. getClearFlags: function() {
  13716. return this.clearFlags
  13717. },
  13718. setClearFlags: function(a) {
  13719. this.clearFlags = a
  13720. },
  13721. getClearColor: function() {
  13722. return this._clearColor
  13723. },
  13724. setClearColor: null,
  13725. _setClearColorForCanvas: function(a) {
  13726. var c = this._clearColor;
  13727. c.r = a.r;
  13728. c.g = a.g;
  13729. c.b = a.b;
  13730. c.a = a.a;
  13731. this._clearColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + "," + a.a / 255 + ")"
  13732. },
  13733. _setClearColorForWebGL: function(a) {
  13734. var c = this._clearColor;
  13735. c.r = a.r;
  13736. c.g = a.g;
  13737. c.b = a.b;
  13738. c.a = a.a
  13739. },
  13740. getClearDepth: function() {
  13741. return this.clearDepthVal
  13742. },
  13743. setClearDepth: function(a) {
  13744. this.clearDepthVal = a
  13745. },
  13746. getClearStencil: function() {
  13747. return this.clearStencilVal
  13748. },
  13749. setClearStencil: function(a) {
  13750. this.clearStencilVal = a
  13751. },
  13752. isAutoDraw: function() {
  13753. return this.autoDraw
  13754. },
  13755. setAutoDraw: function(a) {
  13756. this.autoDraw = a
  13757. }
  13758. });
  13759. _p = cc.RenderTexture.prototype;
  13760. 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);
  13761. cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor);
  13762. cc.RenderTexture.create = function(a, c, d, e) {
  13763. return new cc.RenderTexture(a, c, d, e)
  13764. };
  13765. cc.LabelAtlas = cc.AtlasNode.extend({
  13766. _string: null,
  13767. _mapStartChar: null,
  13768. _textureLoaded: !1,
  13769. _loadedEventListeners: null,
  13770. _className: "LabelAtlas",
  13771. ctor: function(a, c, d, e, f) {
  13772. cc.AtlasNode.prototype.ctor.call(this);
  13773. c && cc.LabelAtlas.prototype.initWithString.call(this, a, c, d, e, f)
  13774. },
  13775. textureLoaded: function() {
  13776. return this._textureLoaded
  13777. },
  13778. addLoadedEventListener: function(a, c) {
  13779. this._loadedEventListeners || (this._loadedEventListeners = []);
  13780. this._loadedEventListeners.push({
  13781. eventCallback: a,
  13782. eventTarget: c
  13783. })
  13784. },
  13785. _callLoadedEventCallbacks: function() {
  13786. if (this._loadedEventListeners) {
  13787. this._textureLoaded = !0;
  13788. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  13789. var e = a[c];
  13790. e.eventCallback.call(e.eventTarget, this)
  13791. }
  13792. a.length = 0
  13793. }
  13794. },
  13795. initWithString: function(a, c, d, e, f) {
  13796. var g = a + "",
  13797. h, k;
  13798. if (void 0 === d) {
  13799. d = cc.loader.getRes(c);
  13800. if (1 !== parseInt(d.version, 10)) return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"), !1;
  13801. c = cc.path.changeBasename(c, d.textureFilename);
  13802. e = cc.contentScaleFactor();
  13803. h = parseInt(d.itemWidth, 10) / e;
  13804. k = parseInt(d.itemHeight, 10) / e;
  13805. d = String.fromCharCode(parseInt(d.firstChar, 10))
  13806. } else h = d || 0, k = e || 0, d = f || " ";
  13807. var m = null,
  13808. m = c instanceof cc.Texture2D ? c : cc.textureCache.addImage(c);
  13809. (this._textureLoaded = c = m.isLoaded()) || m.addLoadedEventListener(function(a) {
  13810. this.initWithTexture(m, h, k, g.length);
  13811. this.string = g;
  13812. this._callLoadedEventCallbacks()
  13813. }, this);
  13814. return this.initWithTexture(m, h, k, g.length) ? (this._mapStartChar = d, this.string = g, !0) : !1
  13815. },
  13816. setColor: function(a) {
  13817. cc.AtlasNode.prototype.setColor.call(this, a);
  13818. this.updateAtlasValues()
  13819. },
  13820. getString: function() {
  13821. return this._string
  13822. },
  13823. draw: function(a) {
  13824. cc.AtlasNode.prototype.draw.call(this, a);
  13825. 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))
  13826. },
  13827. _addChildForCanvas: function(a, c, d) {
  13828. a._lateChild = !0;
  13829. cc.Node.prototype.addChild.call(this, a, c, d)
  13830. },
  13831. updateAtlasValues: null,
  13832. _updateAtlasValuesForCanvas: function() {
  13833. for (var a = this._string || "", c = a.length, d = this.texture, e = this._itemWidth, f = this._itemHeight, g = 0; g < c; g++) {
  13834. var h = a.charCodeAt(g) - this._mapStartChar.charCodeAt(0),
  13835. k = parseInt(h % this._itemsPerRow, 10),
  13836. h = parseInt(h / this._itemsPerRow, 10),
  13837. k = cc.rect(k * e, h * f, e, f),
  13838. h = a.charCodeAt(g),
  13839. m = this.getChildByTag(g);
  13840. 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));
  13841. m.setPosition(g * e + e / 2, f / 2)
  13842. }
  13843. },
  13844. _updateAtlasValuesForWebGL: function() {
  13845. var a = this._string,
  13846. c = a.length,
  13847. d = this.textureAtlas,
  13848. e = d.texture,
  13849. f = e.pixelsWidth,
  13850. e = e.pixelsHeight,
  13851. g = this._itemWidth,
  13852. h = this._itemHeight;
  13853. this._ignoreContentScaleFactor || (g = this._itemWidth * cc.contentScaleFactor(), h = this._itemHeight * cc.contentScaleFactor());
  13854. c > d.getCapacity() && cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");
  13855. for (var k = d.quads, m = this._displayedColor, m = {
  13856. r: m.r,
  13857. g: m.g,
  13858. b: m.b,
  13859. a: this._displayedOpacity
  13860. }, n = this._itemWidth, q = 0; q < c; q++) {
  13861. var r = a.charCodeAt(q) - this._mapStartChar.charCodeAt(0),
  13862. t = r % this._itemsPerRow,
  13863. s = 0 | r / this._itemsPerRow,
  13864. v;
  13865. 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);
  13866. var u = k[q],
  13867. x = u.tl,
  13868. A = u.tr,
  13869. D = u.bl,
  13870. u = u.br;
  13871. x.texCoords.u = t;
  13872. x.texCoords.v = s;
  13873. A.texCoords.u = r;
  13874. A.texCoords.v = s;
  13875. D.texCoords.u = t;
  13876. D.texCoords.v = v;
  13877. u.texCoords.u = r;
  13878. u.texCoords.v = v;
  13879. D.vertices.x = q * n;
  13880. D.vertices.y = 0;
  13881. D.vertices.z = 0;
  13882. u.vertices.x = q * n + n;
  13883. u.vertices.y = 0;
  13884. u.vertices.z = 0;
  13885. x.vertices.x = q * n;
  13886. x.vertices.y = this._itemHeight;
  13887. x.vertices.z = 0;
  13888. A.vertices.x = q * n + n;
  13889. A.vertices.y = this._itemHeight;
  13890. A.vertices.z = 0;
  13891. x.colors = m;
  13892. A.colors = m;
  13893. D.colors = m;
  13894. u.colors = m
  13895. }
  13896. 0 < c && (d.dirty = !0, a = d.totalQuads, c > a && d.increaseTotalQuadsWith(c - a))
  13897. },
  13898. setString: null,
  13899. _setStringForCanvas: function(a) {
  13900. a = String(a);
  13901. var c = a.length;
  13902. this._string = a;
  13903. this.width = c * this._itemWidth;
  13904. this.height = this._itemHeight;
  13905. if (this._children) {
  13906. a = this._children;
  13907. for (var c = a.length, d = 0; d < c; d++) {
  13908. var e = a[d];
  13909. e && !e._lateChild && (e.visible = !1)
  13910. }
  13911. }
  13912. this.updateAtlasValues();
  13913. this.quadsToDraw = c
  13914. },
  13915. _setStringForWebGL: function(a) {
  13916. a = String(a);
  13917. var c = a.length;
  13918. c > this.textureAtlas.totalQuads && this.textureAtlas.resizeCapacity(c);
  13919. this._string = a;
  13920. this.width = c * this._itemWidth;
  13921. this.height = this._itemHeight;
  13922. this.updateAtlasValues();
  13923. this.quadsToDraw = c
  13924. },
  13925. setOpacity: null,
  13926. _setOpacityForCanvas: function(a) {
  13927. if (this._displayedOpacity !== a) {
  13928. cc.AtlasNode.prototype.setOpacity.call(this, a);
  13929. for (var c = this._children, d = 0, e = c.length; d < e; d++) c[d] && (c[d].opacity = a)
  13930. }
  13931. },
  13932. _setOpacityForWebGL: function(a) {
  13933. this._opacity !== a && cc.AtlasNode.prototype.setOpacity.call(this, a)
  13934. }
  13935. });
  13936. _p = cc.LabelAtlas.prototype;
  13937. 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);
  13938. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  13939. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  13940. cc.LabelAtlas.create = function(a, c, d, e, f) {
  13941. return new cc.LabelAtlas(a, c, d, e, f)
  13942. };
  13943. cc.LABEL_AUTOMATIC_WIDTH = -1;
  13944. cc.LabelBMFont = cc.SpriteBatchNode.extend({
  13945. _opacityModifyRGB: !1,
  13946. _string: "",
  13947. _config: null,
  13948. _fntFile: "",
  13949. _initialString: "",
  13950. _alignment: cc.TEXT_ALIGNMENT_CENTER,
  13951. _width: -1,
  13952. _lineBreakWithoutSpaces: !1,
  13953. _imageOffset: null,
  13954. _reusedChar: null,
  13955. _displayedOpacity: 255,
  13956. _realOpacity: 255,
  13957. _displayedColor: null,
  13958. _realColor: null,
  13959. _cascadeColorEnabled: !0,
  13960. _cascadeOpacityEnabled: !0,
  13961. _textureLoaded: !1,
  13962. _loadedEventListeners: null,
  13963. _className: "LabelBMFont",
  13964. _setString: function(a, c) {
  13965. c ? this._initialString = a : this._string = a;
  13966. var d = this._children;
  13967. if (d)
  13968. for (var e = 0; e < d.length; e++) {
  13969. var f = d[e];
  13970. f && f.setVisible(!1)
  13971. }
  13972. this._textureLoaded && (this.createFontChars(), c && this.updateLabel())
  13973. },
  13974. ctor: function(a, c, d, e, f) {
  13975. cc.SpriteBatchNode.prototype.ctor.call(this);
  13976. this._imageOffset = cc.p(0, 0);
  13977. this._displayedColor = cc.color(255, 255, 255, 255);
  13978. this._realColor = cc.color(255, 255, 255, 255);
  13979. this._reusedChar = [];
  13980. this.initWithString(a, c, d, e, f)
  13981. },
  13982. textureLoaded: function() {
  13983. return this._textureLoaded
  13984. },
  13985. addLoadedEventListener: function(a, c) {
  13986. this._loadedEventListeners || (this._loadedEventListeners = []);
  13987. this._loadedEventListeners.push({
  13988. eventCallback: a,
  13989. eventTarget: c
  13990. })
  13991. },
  13992. _callLoadedEventCallbacks: function() {
  13993. if (this._loadedEventListeners) {
  13994. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  13995. var e = a[c];
  13996. e.eventCallback.call(e.eventTarget, this)
  13997. }
  13998. a.length = 0
  13999. }
  14000. },
  14001. draw: function(a) {
  14002. cc.SpriteBatchNode.prototype.draw.call(this, a);
  14003. if (cc.LABELBMFONT_DEBUG_DRAW) {
  14004. a = this.getContentSize();
  14005. var c = cc.p(0 | -this._anchorPointInPoints.x, 0 | -this._anchorPointInPoints.y);
  14006. 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)];
  14007. cc._drawingUtil.setDrawColor(0, 255, 0, 255);
  14008. cc._drawingUtil.drawPoly(a, 4, !0)
  14009. }
  14010. },
  14011. setColor: function(a) {
  14012. var c = this._displayedColor,
  14013. d = this._realColor;
  14014. 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)))
  14015. },
  14016. isOpacityModifyRGB: function() {
  14017. return this._opacityModifyRGB
  14018. },
  14019. setOpacityModifyRGB: function(a) {
  14020. this._opacityModifyRGB = a;
  14021. if (a = this._children)
  14022. for (var c = 0; c < a.length; c++) {
  14023. var d = a[c];
  14024. d && (d.opacityModifyRGB = this._opacityModifyRGB)
  14025. }
  14026. },
  14027. getOpacity: function() {
  14028. return this._realOpacity
  14029. },
  14030. getDisplayedOpacity: function() {
  14031. return this._displayedOpacity
  14032. },
  14033. setOpacity: function(a) {
  14034. this._displayedOpacity = this._realOpacity = a;
  14035. if (this._cascadeOpacityEnabled) {
  14036. var c = 255,
  14037. d = this._parent;
  14038. d && d.cascadeOpacity && (c = d.getDisplayedOpacity());
  14039. this.updateDisplayedOpacity(c)
  14040. }
  14041. this._displayedColor.a = this._realColor.a = a
  14042. },
  14043. updateDisplayedOpacity: function(a) {
  14044. this._displayedOpacity = this._realOpacity * a / 255;
  14045. a = this._children;
  14046. for (var c = 0; c < a.length; c++) {
  14047. var d = a[c];
  14048. cc._renderType == cc._RENDER_TYPE_WEBGL ? d.updateDisplayedOpacity(this._displayedOpacity) : (cc.Node.prototype.updateDisplayedOpacity.call(d, this._displayedOpacity), d.setNodeDirty())
  14049. }
  14050. this._changeTextureColor()
  14051. },
  14052. isCascadeOpacityEnabled: function() {
  14053. return !1
  14054. },
  14055. setCascadeOpacityEnabled: function(a) {
  14056. this._cascadeOpacityEnabled = a
  14057. },
  14058. getColor: function() {
  14059. var a = this._realColor;
  14060. return cc.color(a.r, a.g, a.b, a.a)
  14061. },
  14062. getDisplayedColor: function() {
  14063. return this._displayedColor
  14064. },
  14065. updateDisplayedColor: function(a) {
  14066. var c = this._displayedColor,
  14067. d = this._realColor;
  14068. c.r = d.r * a.r / 255;
  14069. c.g = d.g * a.g / 255;
  14070. c.b = d.b * a.b / 255;
  14071. a = this._children;
  14072. 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());
  14073. this._changeTextureColor()
  14074. },
  14075. _changeTextureColor: function() {
  14076. if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
  14077. var a = this.getTexture();
  14078. if (a && 0 < a.getContentSize().width) {
  14079. var c = this._originalTexture.getHtmlElementObj();
  14080. if (c) {
  14081. var d = a.getHtmlElementObj(),
  14082. e = cc.rect(0, 0, c.width, c.height);
  14083. 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());
  14084. this.setTexture(a)
  14085. }
  14086. }
  14087. }
  14088. },
  14089. isCascadeColorEnabled: function() {
  14090. return !1
  14091. },
  14092. setCascadeColorEnabled: function(a) {
  14093. this._cascadeColorEnabled = a
  14094. },
  14095. init: function() {
  14096. return this.initWithString(null, null, null, null, null)
  14097. },
  14098. initWithString: function(a, c, d, e, f) {
  14099. a = a || "";
  14100. this._config && cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");
  14101. if (c) {
  14102. var g = cc.loader.getRes(c);
  14103. if (!g) return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"), !1;
  14104. this._config = g;
  14105. this._fntFile = c;
  14106. c = cc.textureCache.addImage(g.atlasName);
  14107. (this._textureLoaded = g = c.isLoaded()) || c.addLoadedEventListener(function(a) {
  14108. this._textureLoaded = !0;
  14109. this.initWithTexture(a, this._initialString.length);
  14110. this.setString(this._initialString, !0);
  14111. this._callLoadedEventCallbacks()
  14112. }, this)
  14113. } else c = new cc.Texture2D, g = new Image, c.initWithElement(g), this._textureLoaded = !1;
  14114. 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
  14115. },
  14116. createFontChars: function() {
  14117. var a = cc._renderType,
  14118. c = a === cc._RENDER_TYPE_CANVAS ? this.texture : this.textureAtlas.texture,
  14119. d = 0,
  14120. e = cc.size(0, 0),
  14121. f = 0,
  14122. g = 1,
  14123. h = this._string,
  14124. k = h ? h.length : 0;
  14125. if (0 !== k) {
  14126. var m, n = this._config,
  14127. q = n.kerningDict,
  14128. r = n.commonHeight,
  14129. t = n.fontDefDictionary;
  14130. for (m = 0; m < k - 1; m++) 10 == h.charCodeAt(m) && g++;
  14131. var s = r * g,
  14132. g = -(r - r * g),
  14133. v = -1;
  14134. for (m = 0; m < k; m++)
  14135. if (r = h.charCodeAt(m), 0 != r)
  14136. if (10 === r) d = 0, g -= n.commonHeight;
  14137. else {
  14138. var u = q[v << 16 | r & 65535] || 0,
  14139. x = t[r];
  14140. if (x) {
  14141. var A = cc.rect(x.rect.x, x.rect.y, x.rect.width, x.rect.height),
  14142. A = cc.rectPixelsToPoints(A);
  14143. A.x += this._imageOffset.x;
  14144. A.y += this._imageOffset.y;
  14145. (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));
  14146. v.opacityModifyRGB = this._opacityModifyRGB;
  14147. 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());
  14148. A = cc.p(d + x.xOffset + 0.5 * x.rect.width + u, g + (n.commonHeight - x.yOffset) - 0.5 * A.height * cc.contentScaleFactor());
  14149. v.setPosition(cc.pointPixelsToPoints(A));
  14150. d += x.xAdvance + u;
  14151. v = r;
  14152. f < d && (f = d)
  14153. } else cc.log("cocos2d: LabelBMFont: character not found " + h[m])
  14154. }
  14155. e.width = f;
  14156. e.height = s;
  14157. this.setContentSize(cc.sizePixelsToPoints(e))
  14158. }
  14159. },
  14160. updateString: function(a) {
  14161. var c = this._children;
  14162. if (c)
  14163. for (var d = 0, e = c.length; d < e; d++) {
  14164. var f = c[d];
  14165. f && (f.visible = !1)
  14166. }
  14167. this._config && this.createFontChars();
  14168. a || this.updateLabel()
  14169. },
  14170. getString: function() {
  14171. return this._initialString
  14172. },
  14173. setString: function(a, c) {
  14174. a = String(a);
  14175. null == c && (c = !0);
  14176. if (null == a || "string" != typeof a) a += "";
  14177. this._initialString = a;
  14178. this._setString(a, c)
  14179. },
  14180. _setStringForSetter: function(a) {
  14181. this.setString(a, !1)
  14182. },
  14183. setCString: function(a) {
  14184. this.setString(a, !0)
  14185. },
  14186. updateLabel: function() {
  14187. this.string = this._initialString;
  14188. if (0 < this._width) {
  14189. 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++) {
  14190. for (var s = 0; !(q = this.getChildByTag(r + n + s));) s++;
  14191. n += s;
  14192. if (f >= a) break;
  14193. var v = this._string[f];
  14194. h || (m = this._getLetterPosXLeft(q), h = !0);
  14195. g || (k = m, g = !0);
  14196. if (10 == v.charCodeAt(0)) {
  14197. d.push("\n");
  14198. c = c.concat(d);
  14199. d.length = 0;
  14200. g = h = !1;
  14201. k = m = -1;
  14202. r--;
  14203. n -= s;
  14204. e++;
  14205. if (f >= a) break;
  14206. m || (m = this._getLetterPosXLeft(q), h = !0);
  14207. k || (k = m, g = !0);
  14208. f++
  14209. } else if (cc.isspace_unicode(v)) d.push(v), c = c.concat(d), d.length = 0, h = !1, m = -1, f++;
  14210. else if (this._getLetterPosXRight(q) - k > this._width)
  14211. if (this._lineBreakWithoutSpaces) {
  14212. cc.utf8_trim_ws(d);
  14213. d.push("\n");
  14214. c = c.concat(d);
  14215. d.length = 0;
  14216. g = h = !1;
  14217. k = m = -1;
  14218. e++;
  14219. if (f >= a) break;
  14220. m || (m = this._getLetterPosXLeft(q), h = !0);
  14221. k || (k = m, g = !0);
  14222. r--
  14223. } 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++;
  14224. else d.push(v), f++
  14225. }
  14226. c = c.concat(d);
  14227. r = c.length;
  14228. q = "";
  14229. for (f = 0; f < r; ++f) q += c[f];
  14230. q += String.fromCharCode(0);
  14231. this._setString(q, !1)
  14232. }
  14233. if (this._alignment != cc.TEXT_ALIGNMENT_LEFT) {
  14234. c = f = 0;
  14235. a = this._string.length;
  14236. d = [];
  14237. for (e = 0; e < a; e++)
  14238. if (10 == this._string[e].charCodeAt(0) || 0 == this._string[e].charCodeAt(0))
  14239. if (r = 0, g = d.length, 0 == g) c++;
  14240. else {
  14241. if (q = f + g - 1 + c, !(0 > q) && (r = this.getChildByTag(q), null != r)) {
  14242. r = r.getPositionX() + r._getWidth() / 2;
  14243. h = 0;
  14244. switch (this._alignment) {
  14245. case cc.TEXT_ALIGNMENT_CENTER:
  14246. h = this.width / 2 - r / 2;
  14247. break;
  14248. case cc.TEXT_ALIGNMENT_RIGHT:
  14249. h = this.width - r
  14250. }
  14251. if (0 != h)
  14252. for (r = 0; r < g; r++)
  14253. if (q = f + r + c, !(0 > q) && (q = this.getChildByTag(q))) q.x += h;
  14254. f += g;
  14255. c++;
  14256. d.length = 0
  14257. }
  14258. } else d.push(this._string[f])
  14259. }
  14260. },
  14261. setAlignment: function(a) {
  14262. this._alignment = a;
  14263. this.updateLabel()
  14264. },
  14265. _getAlignment: function() {
  14266. return this._alignment
  14267. },
  14268. setBoundingWidth: function(a) {
  14269. this._width = a;
  14270. this.updateLabel()
  14271. },
  14272. _getBoundingWidth: function() {
  14273. return this._width
  14274. },
  14275. setLineBreakWithoutSpace: function(a) {
  14276. this._lineBreakWithoutSpaces = a;
  14277. this.updateLabel()
  14278. },
  14279. setScale: function(a, c) {
  14280. cc.Node.prototype.setScale.call(this, a, c);
  14281. this.updateLabel()
  14282. },
  14283. setScaleX: function(a) {
  14284. cc.Node.prototype.setScaleX.call(this, a);
  14285. this.updateLabel()
  14286. },
  14287. setScaleY: function(a) {
  14288. cc.Node.prototype.setScaleY.call(this, a);
  14289. this.updateLabel()
  14290. },
  14291. setFntFile: function(a) {
  14292. if (null != a && a != this._fntFile) {
  14293. var c = cc.loader.getRes(a);
  14294. 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) {
  14295. this._textureLoaded = !0;
  14296. this.texture = a;
  14297. this.createFontChars();
  14298. this._changeTextureColor();
  14299. this.updateLabel();
  14300. this._callLoadedEventCallbacks()
  14301. }, this)) : cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file")
  14302. }
  14303. },
  14304. getFntFile: function() {
  14305. return this._fntFile
  14306. },
  14307. setAnchorPoint: function(a, c) {
  14308. cc.Node.prototype.setAnchorPoint.call(this, a, c);
  14309. this.updateLabel()
  14310. },
  14311. _setAnchor: function(a) {
  14312. cc.Node.prototype._setAnchor.call(this, a);
  14313. this.updateLabel()
  14314. },
  14315. _setAnchorX: function(a) {
  14316. cc.Node.prototype._setAnchorX.call(this, a);
  14317. this.updateLabel()
  14318. },
  14319. _setAnchorY: function(a) {
  14320. cc.Node.prototype._setAnchorY.call(this, a);
  14321. this.updateLabel()
  14322. },
  14323. _atlasNameFromFntFile: function(a) {},
  14324. _kerningAmountForFirst: function(a, c) {
  14325. var d = 0;
  14326. if (this._configuration.kerningDictionary) {
  14327. var e = this._configuration.kerningDictionary[(a << 16 | c & 65535).toString()];
  14328. e && (d = e.amount)
  14329. }
  14330. return d
  14331. },
  14332. _getLetterPosXLeft: function(a) {
  14333. return a.getPositionX() * this._scaleX - a._getWidth() * this._scaleX * a._getAnchorX()
  14334. },
  14335. _getLetterPosXRight: function(a) {
  14336. return a.getPositionX() * this._scaleX + a._getWidth() * this._scaleX * a._getAnchorX()
  14337. }
  14338. });
  14339. _p = cc.LabelBMFont.prototype;
  14340. cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes && (_p._changeTextureColor = function() {
  14341. if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
  14342. var a, c = this.getTexture();
  14343. if (c && 0 < c.getContentSize().width && (a = c.getHtmlElementObj()))
  14344. 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))
  14345. }
  14346. });
  14347. cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter);
  14348. cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p.setBoundingWidth);
  14349. cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment);
  14350. cc.LabelBMFont.create = function(a, c, d, e, f) {
  14351. return new cc.LabelBMFont(a, c, d, e, f)
  14352. };
  14353. cc.isspace_unicode = function(a) {
  14354. a = a.charCodeAt(0);
  14355. 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
  14356. };
  14357. cc.utf8_trim_ws = function(a) {
  14358. var c = a.length;
  14359. if (!(0 >= c) && (c -= 1, cc.isspace_unicode(a[c]))) {
  14360. for (var d = c - 1; 0 <= d; --d)
  14361. if (cc.isspace_unicode(a[d])) c = d;
  14362. else break;
  14363. cc.utf8_trim_from(a, c)
  14364. }
  14365. };
  14366. cc.utf8_trim_from = function(a, c) {
  14367. var d = a.length;
  14368. c >= d || 0 > c || a.splice(c, d)
  14369. };
  14370. cc._fntLoader = {
  14371. INFO_EXP: /info [^\n]*(\n|$)/gi,
  14372. COMMON_EXP: /common [^\n]*(\n|$)/gi,
  14373. PAGE_EXP: /page [^\n]*(\n|$)/gi,
  14374. CHAR_EXP: /char [^\n]*(\n|$)/gi,
  14375. KERNING_EXP: /kerning [^\n]*(\n|$)/gi,
  14376. ITEM_EXP: /\w+=[^ \r\n]+/gi,
  14377. INT_EXP: /^[\-]?\d+$/,
  14378. _parseStrToObj: function(a) {
  14379. a = a.match(this.ITEM_EXP);
  14380. var c = {};
  14381. if (a)
  14382. for (var d = 0, e = a.length; d < e; d++) {
  14383. var f = a[d],
  14384. g = f.indexOf("\x3d"),
  14385. h = f.substring(0, g),
  14386. f = f.substring(g + 1);
  14387. f.match(this.INT_EXP) ? f = parseInt(f) : '"' == f[0] && (f = f.substring(1, f.length - 1));
  14388. c[h] = f
  14389. }
  14390. return c
  14391. },
  14392. parseFnt: function(a, c) {
  14393. var d = {},
  14394. e = this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(",");
  14395. parseInt(e[0]);
  14396. parseInt(e[1]);
  14397. parseInt(e[2]);
  14398. parseInt(e[3]);
  14399. e = this._parseStrToObj(a.match(this.COMMON_EXP)[0]);
  14400. d.commonHeight = e.lineHeight;
  14401. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  14402. var f = cc.configuration.getMaxTextureSize();
  14403. (e.scaleW > f.width || e.scaleH > f.height) && cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")
  14404. }
  14405. 1 !== e.pages && cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
  14406. e = this._parseStrToObj(a.match(this.PAGE_EXP)[0]);
  14407. 0 !== e.id && cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
  14408. d.atlasName = cc.path.changeBasename(c, e.file);
  14409. for (var g = a.match(this.CHAR_EXP), h = d.fontDefDictionary = {}, e = 0, f = g.length; e < f; e++) {
  14410. var k = this._parseStrToObj(g[e]);
  14411. h[k.id] = {
  14412. rect: {
  14413. x: k.x,
  14414. y: k.y,
  14415. width: k.width,
  14416. height: k.height
  14417. },
  14418. xOffset: k.xoffset,
  14419. yOffset: k.yoffset,
  14420. xAdvance: k.xadvance
  14421. }
  14422. }
  14423. g = d.kerningDict = {};
  14424. if (h = a.match(this.KERNING_EXP)) {
  14425. e = 0;
  14426. for (f = h.length; e < f; e++) k = this._parseStrToObj(h[e]), g[k.first << 16 | k.second & 65535] = k.amount
  14427. }
  14428. return d
  14429. },
  14430. load: function(a, c, d, e) {
  14431. var f = this;
  14432. cc.loader.loadTxt(a, function(a, d) {
  14433. if (a) return e(a);
  14434. e(null, f.parseFnt(d, c))
  14435. })
  14436. }
  14437. };
  14438. cc.loader.register(["fnt"], cc._fntLoader);
  14439. cc.MotionStreak = cc.Node.extend({
  14440. texture: null,
  14441. fastMode: !1,
  14442. startingPositionInitialized: !1,
  14443. _blendFunc: null,
  14444. _stroke: 0,
  14445. _fadeDelta: 0,
  14446. _minSeg: 0,
  14447. _maxPoints: 0,
  14448. _nuPoints: 0,
  14449. _previousNuPoints: 0,
  14450. _pointVertexes: null,
  14451. _pointState: null,
  14452. _vertices: null,
  14453. _colorPointer: null,
  14454. _texCoords: null,
  14455. _verticesBuffer: null,
  14456. _colorPointerBuffer: null,
  14457. _texCoordsBuffer: null,
  14458. _className: "MotionStreak",
  14459. ctor: function(a, c, d, e, f) {
  14460. cc.Node.prototype.ctor.call(this);
  14461. this._positionR = cc.p(0, 0);
  14462. this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
  14463. this._vertexWebGLBuffer = cc._renderContext.createBuffer();
  14464. this.startingPositionInitialized = this.fastMode = !1;
  14465. this.texture = null;
  14466. this._previousNuPoints = this._nuPoints = this._maxPoints = this._minSeg = this._fadeDelta = this._stroke = 0;
  14467. this._texCoordsBuffer = this._colorPointerBuffer = this._verticesBuffer = this._texCoords = this._colorPointer = this._vertices = this._pointState = this._pointVertexes = null;
  14468. void 0 !== f && this.initWithFade(a, c, d, e, f)
  14469. },
  14470. getTexture: function() {
  14471. return this.texture
  14472. },
  14473. setTexture: function(a) {
  14474. this.texture != a && (this.texture = a)
  14475. },
  14476. getBlendFunc: function() {
  14477. return this._blendFunc
  14478. },
  14479. setBlendFunc: function(a, c) {
  14480. void 0 === c ? this._blendFunc = a : (this._blendFunc.src = a, this._blendFunc.dst = c)
  14481. },
  14482. getOpacity: function() {
  14483. cc.log("cc.MotionStreak.getOpacity has not been supported.");
  14484. return 0
  14485. },
  14486. setOpacity: function(a) {
  14487. cc.log("cc.MotionStreak.setOpacity has not been supported.")
  14488. },
  14489. setOpacityModifyRGB: function(a) {},
  14490. isOpacityModifyRGB: function() {
  14491. return !1
  14492. },
  14493. onExit: function() {
  14494. cc.Node.prototype.onExit.call(this);
  14495. this._verticesBuffer && cc._renderContext.deleteBuffer(this._verticesBuffer);
  14496. this._texCoordsBuffer && cc._renderContext.deleteBuffer(this._texCoordsBuffer);
  14497. this._colorPointerBuffer && cc._renderContext.deleteBuffer(this._colorPointerBuffer)
  14498. },
  14499. isFastMode: function() {
  14500. return this.fastMode
  14501. },
  14502. setFastMode: function(a) {
  14503. this.fastMode = a
  14504. },
  14505. isStartingPositionInitialized: function() {
  14506. return this.startingPositionInitialized
  14507. },
  14508. setStartingPositionInitialized: function(a) {
  14509. this.startingPositionInitialized = a
  14510. },
  14511. initWithFade: function(a, c, d, e, f) {
  14512. if (!f) throw "cc.MotionStreak.initWithFade(): Invalid filename or texture";
  14513. "string" === typeof f && (f = cc.textureCache.addImage(f));
  14514. cc.Node.prototype.setPosition.call(this, cc.p(0, 0));
  14515. this.anchorY = this.anchorX = 0;
  14516. this.ignoreAnchor = !0;
  14517. this.startingPositionInitialized = !1;
  14518. this.fastMode = !0;
  14519. this._minSeg = -1 == c ? d / 5 : c;
  14520. this._minSeg *= this._minSeg;
  14521. this._stroke = d;
  14522. this._fadeDelta = 1 / a;
  14523. a = (0 | 60 * a) + 2;
  14524. this._nuPoints = 0;
  14525. this._pointState = new Float32Array(a);
  14526. this._pointVertexes = new Float32Array(2 * a);
  14527. this._vertices = new Float32Array(4 * a);
  14528. this._texCoords = new Float32Array(4 * a);
  14529. this._colorPointer = new Uint8Array(8 * a);
  14530. this._maxPoints = a;
  14531. a = cc._renderContext;
  14532. this._verticesBuffer = a.createBuffer();
  14533. this._texCoordsBuffer = a.createBuffer();
  14534. this._colorPointerBuffer = a.createBuffer();
  14535. this._blendFunc.src = a.SRC_ALPHA;
  14536. this._blendFunc.dst = a.ONE_MINUS_SRC_ALPHA;
  14537. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  14538. this.texture = f;
  14539. this.color = e;
  14540. this.scheduleUpdate();
  14541. a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
  14542. a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
  14543. a.bindBuffer(a.ARRAY_BUFFER, this._texCoordsBuffer);
  14544. a.bufferData(a.ARRAY_BUFFER, this._texCoords, a.DYNAMIC_DRAW);
  14545. a.bindBuffer(a.ARRAY_BUFFER, this._colorPointerBuffer);
  14546. a.bufferData(a.ARRAY_BUFFER, this._colorPointer, a.DYNAMIC_DRAW);
  14547. return !0
  14548. },
  14549. tintWithColor: function(a) {
  14550. this.color = a;
  14551. 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
  14552. },
  14553. reset: function() {
  14554. this._nuPoints = 0
  14555. },
  14556. setPosition: function(a, c) {
  14557. this.startingPositionInitialized = !0;
  14558. void 0 === c ? (this._positionR.x = a.x, this._positionR.y = a.y) : (this._positionR.x = a, this._positionR.y = c)
  14559. },
  14560. getPositionX: function() {
  14561. return this._positionR.x
  14562. },
  14563. setPositionX: function(a) {
  14564. this._positionR.x = a;
  14565. this.startingPositionInitialized || (this.startingPositionInitialized = !0)
  14566. },
  14567. getPositionY: function() {
  14568. return this._positionR.y
  14569. },
  14570. setPositionY: function(a) {
  14571. this._positionR.y = a;
  14572. this.startingPositionInitialized || (this.startingPositionInitialized = !0)
  14573. },
  14574. draw: function(a) {
  14575. !(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++)
  14576. },
  14577. update: function(a) {
  14578. if (this.startingPositionInitialized) {
  14579. a *= this._fadeDelta;
  14580. var c, d, e, f, g = 0,
  14581. h = this._nuPoints,
  14582. k = this._pointState,
  14583. m = this._pointVertexes,
  14584. n = this._vertices,
  14585. q = this._colorPointer;
  14586. 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);
  14587. h -= g;
  14588. e = !0;
  14589. if (h >= this._maxPoints) e = !1;
  14590. 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;
  14591. 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++);
  14592. this.fastMode || cc.vertexLineToPolygon(m, this._stroke, this._vertices, 0, h);
  14593. if (h && this._previousNuPoints != h) {
  14594. m = 1 / h;
  14595. q = this._texCoords;
  14596. 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;
  14597. this._previousNuPoints = h
  14598. }
  14599. this._nuPoints = h
  14600. }
  14601. }
  14602. });
  14603. cc.MotionStreak.create = function(a, c, d, e, f) {
  14604. return new cc.MotionStreak(a, c, d, e, f)
  14605. };
  14606. cc.NodeGrid = cc.Node.extend({
  14607. grid: null,
  14608. _target: null,
  14609. getGrid: function() {
  14610. return this.grid
  14611. },
  14612. setGrid: function(a) {
  14613. this.grid = a
  14614. },
  14615. setTarget: function(a) {
  14616. this._target = a
  14617. },
  14618. addChild: function(a, c, d) {
  14619. cc.Node.prototype.addChild.call(this, a, c, d);
  14620. a && !this._target && (this._target = a)
  14621. },
  14622. visit: function() {
  14623. if (this._visible) {
  14624. var a = cc._renderType == cc._RENDER_TYPE_WEBGL,
  14625. c = this.grid;
  14626. a && (c && c._active) && c.beforeDraw();
  14627. this.transform();
  14628. var d = this._children;
  14629. if (d && 0 < d.length) {
  14630. var e = d.length;
  14631. this.sortAllChildren();
  14632. for (i = 0; i < e; i++) {
  14633. var f = d[i];
  14634. f && f.visit()
  14635. }
  14636. }
  14637. a && (c && c._active) && c.afterDraw(this._target)
  14638. }
  14639. },
  14640. _transformForWebGL: function() {
  14641. var a = this._transform4x4,
  14642. c = cc.current_stack.top,
  14643. d = this.nodeToParentTransform(),
  14644. e = a.mat;
  14645. e[0] = d.a;
  14646. e[4] = d.c;
  14647. e[12] = d.tx;
  14648. e[1] = d.b;
  14649. e[5] = d.d;
  14650. e[13] = d.ty;
  14651. e[14] = this._vertexZ;
  14652. cc.kmMat4Multiply(c, c, a);
  14653. 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()
  14654. }
  14655. });
  14656. _p = cc.NodeGrid.prototype;
  14657. cc._renderType === cc._RENDER_TYPE_WEBGL && (_p.transform = _p._transformForWebGL);
  14658. cc.defineGetterSetter(_p, "target", null, _p.setTarget);
  14659. cc.NodeGrid.create = function() {
  14660. return new cc.NodeGrid
  14661. };
  14662. cc.v2fzero = function() {
  14663. return {
  14664. x: 0,
  14665. y: 0
  14666. }
  14667. };
  14668. cc.v2f = function(a, c) {
  14669. return {
  14670. x: a,
  14671. y: c
  14672. }
  14673. };
  14674. cc.v2fadd = function(a, c) {
  14675. return cc.v2f(a.x + c.x, a.y + c.y)
  14676. };
  14677. cc.v2fsub = function(a, c) {
  14678. return cc.v2f(a.x - c.x, a.y - c.y)
  14679. };
  14680. cc.v2fmult = function(a, c) {
  14681. return cc.v2f(a.x * c, a.y * c)
  14682. };
  14683. cc.v2fperp = function(a) {
  14684. return cc.v2f(-a.y, a.x)
  14685. };
  14686. cc.v2fneg = function(a) {
  14687. return cc.v2f(-a.x, -a.y)
  14688. };
  14689. cc.v2fdot = function(a, c) {
  14690. return a.x * c.x + a.y * c.y
  14691. };
  14692. cc.v2fforangle = function(a) {
  14693. return cc.v2f(Math.cos(a), Math.sin(a))
  14694. };
  14695. cc.v2fnormalize = function(a) {
  14696. a = cc.pNormalize(cc.p(a.x, a.y));
  14697. return cc.v2f(a.x, a.y)
  14698. };
  14699. cc.__v2f = function(a) {
  14700. return cc.v2f(a.x, a.y)
  14701. };
  14702. cc.__t = function(a) {
  14703. return {
  14704. u: a.x,
  14705. v: a.y
  14706. }
  14707. };
  14708. cc.DrawNodeCanvas = cc.Node.extend({
  14709. _buffer: null,
  14710. _blendFunc: null,
  14711. _lineWidth: 1,
  14712. _drawColor: null,
  14713. _className: "DrawNodeCanvas",
  14714. ctor: function() {
  14715. cc.Node.prototype.ctor.call(this);
  14716. this._buffer = [];
  14717. this._drawColor = cc.color(255, 255, 255, 255);
  14718. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  14719. this.init()
  14720. },
  14721. getBlendFunc: function() {
  14722. return this._blendFunc
  14723. },
  14724. setBlendFunc: function(a, c) {
  14725. void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = c)
  14726. },
  14727. setLineWidth: function(a) {
  14728. this._lineWidth = a
  14729. },
  14730. getLineWidth: function() {
  14731. return this._lineWidth
  14732. },
  14733. setDrawColor: function(a) {
  14734. var c = this._drawColor;
  14735. c.r = a.r;
  14736. c.g = a.g;
  14737. c.b = a.b;
  14738. c.a = null == a.a ? 255 : a.a
  14739. },
  14740. getDrawColor: function() {
  14741. return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a)
  14742. },
  14743. drawRect: function(a, c, d, e, f) {
  14744. e = e || this._lineWidth;
  14745. f = f || this.getDrawColor();
  14746. null == f.a && (f.a = 255);
  14747. a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
  14748. c = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14749. c.verts = a;
  14750. c.lineWidth = e;
  14751. c.lineColor = f;
  14752. c.isClosePolygon = !0;
  14753. c.isStroke = !0;
  14754. c.lineCap = "butt";
  14755. if (c.fillColor = d) null == d.a && (d.a = 255), c.isFill = !0;
  14756. this._buffer.push(c)
  14757. },
  14758. drawCircle: function(a, c, d, e, f, g, h) {
  14759. g = g || this._lineWidth;
  14760. h = h || this.getDrawColor();
  14761. null == h.a && (h.a = 255);
  14762. for (var k = 2 * Math.PI / e, m = [], n = 0; n <= e; n++) {
  14763. var q = n * k,
  14764. r = c * Math.cos(q + d) + a.x,
  14765. q = c * Math.sin(q + d) + a.y;
  14766. m.push(cc.p(r, q))
  14767. }
  14768. f && m.push(cc.p(a.x, a.y));
  14769. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14770. a.verts = m;
  14771. a.lineWidth = g;
  14772. a.lineColor = h;
  14773. a.isClosePolygon = !0;
  14774. a.isStroke = !0;
  14775. this._buffer.push(a)
  14776. },
  14777. drawQuadBezier: function(a, c, d, e, f, g) {
  14778. f = f || this._lineWidth;
  14779. g = g || this.getDrawColor();
  14780. null == g.a && (g.a = 255);
  14781. for (var h = [], k = 0, m = 0; m < e; m++) {
  14782. var n = Math.pow(1 - k, 2) * a.x + 2 * (1 - k) * k * c.x + k * k * d.x,
  14783. q = Math.pow(1 - k, 2) * a.y + 2 * (1 - k) * k * c.y + k * k * d.y;
  14784. h.push(cc.p(n, q));
  14785. k += 1 / e
  14786. }
  14787. h.push(cc.p(d.x, d.y));
  14788. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14789. a.verts = h;
  14790. a.lineWidth = f;
  14791. a.lineColor = g;
  14792. a.isStroke = !0;
  14793. a.lineCap = "round";
  14794. this._buffer.push(a)
  14795. },
  14796. drawCubicBezier: function(a, c, d, e, f, g, h) {
  14797. g = g || this._lineWidth;
  14798. h = h || this.getDrawColor();
  14799. null == h.a && (h.a = 255);
  14800. for (var k = [], m = 0, n = 0; n < f; n++) {
  14801. 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,
  14802. 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;
  14803. k.push(cc.p(q, r));
  14804. m += 1 / f
  14805. }
  14806. k.push(cc.p(e.x, e.y));
  14807. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14808. a.verts = k;
  14809. a.lineWidth = g;
  14810. a.lineColor = h;
  14811. a.isStroke = !0;
  14812. a.lineCap = "round";
  14813. this._buffer.push(a)
  14814. },
  14815. drawCatmullRom: function(a, c, d, e) {
  14816. this.drawCardinalSpline(a, 0.5, c, d, e)
  14817. },
  14818. drawCardinalSpline: function(a, c, d, e, f) {
  14819. e = e || this._lineWidth;
  14820. f = f || this.getDrawColor();
  14821. null == f.a && (f.a = 255);
  14822. 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);
  14823. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14824. a.verts = g;
  14825. a.lineWidth = e;
  14826. a.lineColor = f;
  14827. a.isStroke = !0;
  14828. a.lineCap = "round";
  14829. this._buffer.push(a)
  14830. },
  14831. drawDot: function(a, c, d) {
  14832. d = d || this.getDrawColor();
  14833. null == d.a && (d.a = 255);
  14834. var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);
  14835. e.verts = [a];
  14836. e.lineWidth = c;
  14837. e.fillColor = d;
  14838. this._buffer.push(e)
  14839. },
  14840. drawDots: function(a, c, d) {
  14841. if (a && 0 != a.length) {
  14842. d = d || this.getDrawColor();
  14843. null == d.a && (d.a = 255);
  14844. for (var e = 0, f = a.length; e < f; e++) this.drawDot(a[e], c, d)
  14845. }
  14846. },
  14847. drawSegment: function(a, c, d, e) {
  14848. d = d || this._lineWidth;
  14849. e = e || this.getDrawColor();
  14850. null == e.a && (e.a = 255);
  14851. var f = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14852. f.verts = [a, c];
  14853. f.lineWidth = 2 * d;
  14854. f.lineColor = e;
  14855. f.isStroke = !0;
  14856. f.lineCap = "round";
  14857. this._buffer.push(f)
  14858. },
  14859. drawPoly_: function(a, c, d, e) {
  14860. d = d || this._lineWidth;
  14861. e = e || this.getDrawColor();
  14862. null == e.a && (e.a = 255);
  14863. var f = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  14864. f.verts = a;
  14865. f.fillColor = c;
  14866. f.lineWidth = d;
  14867. f.lineColor = e;
  14868. f.isClosePolygon = !0;
  14869. f.isStroke = !0;
  14870. f.lineCap = "round";
  14871. c && (f.isFill = !0);
  14872. this._buffer.push(f)
  14873. },
  14874. drawPoly: function(a, c, d, e) {
  14875. for (var f = [], g = 0; g < a.length; g++) f.push(cc.p(a[g].x, a[g].y));
  14876. return this.drawPoly_(f, c, d, e)
  14877. },
  14878. draw: function(a) {
  14879. a = a || cc._renderContext;
  14880. this._blendFunc && (this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE) && (a.globalCompositeOperation = "lighter");
  14881. for (var c = 0; c < this._buffer.length; c++) {
  14882. var d = this._buffer[c];
  14883. switch (d.type) {
  14884. case cc.DrawNode.TYPE_DOT:
  14885. this._drawDot(a, d);
  14886. break;
  14887. case cc.DrawNode.TYPE_SEGMENT:
  14888. this._drawSegment(a, d);
  14889. break;
  14890. case cc.DrawNode.TYPE_POLY:
  14891. this._drawPoly(a, d)
  14892. }
  14893. }
  14894. },
  14895. _drawDot: function(a, c) {
  14896. var d = c.fillColor,
  14897. e = c.verts[0],
  14898. f = c.lineWidth,
  14899. g = cc.view.getScaleX(),
  14900. h = cc.view.getScaleY();
  14901. a.fillStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + d.a / 255 + ")";
  14902. a.beginPath();
  14903. a.arc(e.x * g, -e.y * h, f * g, 0, 2 * Math.PI, !1);
  14904. a.closePath();
  14905. a.fill()
  14906. },
  14907. _drawSegment: function(a, c) {
  14908. var d = c.lineColor,
  14909. e = c.verts[0],
  14910. f = c.verts[1],
  14911. g = c.lineWidth,
  14912. h = c.lineCap,
  14913. k = cc.view.getScaleX(),
  14914. m = cc.view.getScaleY();
  14915. a.strokeStyle = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + "," + d.a / 255 + ")";
  14916. a.lineWidth = g * k;
  14917. a.beginPath();
  14918. a.lineCap = h;
  14919. a.moveTo(e.x * k, -e.y * m);
  14920. a.lineTo(f.x * k, -f.y * m);
  14921. a.stroke()
  14922. },
  14923. _drawPoly: function(a, c) {
  14924. var d = c.verts,
  14925. e = c.lineCap,
  14926. f = c.fillColor,
  14927. g = c.lineWidth,
  14928. h = c.lineColor,
  14929. k = c.isClosePolygon,
  14930. m = c.isFill,
  14931. n = c.isStroke;
  14932. if (null != d) {
  14933. var q = d[0],
  14934. r = cc.view.getScaleX(),
  14935. t = cc.view.getScaleY();
  14936. a.lineCap = e;
  14937. f && (a.fillStyle = "rgba(" + (0 | f.r) + "," + (0 | f.g) + "," + (0 | f.b) + "," + f.a / 255 + ")");
  14938. g && (a.lineWidth = g * r);
  14939. h && (a.strokeStyle = "rgba(" + (0 | h.r) + "," + (0 | h.g) + "," + (0 | h.b) + "," + h.a / 255 + ")");
  14940. a.beginPath();
  14941. a.moveTo(q.x * r, -q.y * t);
  14942. e = 1;
  14943. for (f = d.length; e < f; e++) a.lineTo(d[e].x * r, -d[e].y * t);
  14944. k && a.closePath();
  14945. m && a.fill();
  14946. n && a.stroke()
  14947. }
  14948. },
  14949. clear: function() {
  14950. this._buffer.length = 0
  14951. }
  14952. });
  14953. cc.DrawNodeWebGL = cc.Node.extend({
  14954. _bufferCapacity: 0,
  14955. _buffer: null,
  14956. _trianglesArrayBuffer: null,
  14957. _trianglesWebBuffer: null,
  14958. _trianglesReader: null,
  14959. _lineWidth: 1,
  14960. _drawColor: null,
  14961. _blendFunc: null,
  14962. _dirty: !1,
  14963. _className: "DrawNodeWebGL",
  14964. getBlendFunc: function() {
  14965. return this._blendFunc
  14966. },
  14967. setBlendFunc: function(a, c) {
  14968. void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = c)
  14969. },
  14970. ctor: function() {
  14971. cc.Node.prototype.ctor.call(this);
  14972. this._buffer = [];
  14973. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  14974. this._drawColor = cc.color(255, 255, 255, 255);
  14975. this.init()
  14976. },
  14977. init: function() {
  14978. 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
  14979. },
  14980. setLineWidth: function(a) {
  14981. this._lineWidth = a
  14982. },
  14983. getLineWidth: function() {
  14984. return this._lineWidth
  14985. },
  14986. setDrawColor: function(a) {
  14987. var c = this._drawColor;
  14988. c.r = a.r;
  14989. c.g = a.g;
  14990. c.b = a.b;
  14991. c.a = a.a
  14992. },
  14993. getDrawColor: function() {
  14994. return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a)
  14995. },
  14996. drawRect: function(a, c, d, e, f) {
  14997. e = e || this._lineWidth;
  14998. f = f || this.getDrawColor();
  14999. null == f.a && (f.a = 255);
  15000. a = [a, cc.p(c.x, a.y), c, cc.p(a.x, c.y)];
  15001. null == d ? this._drawSegments(a, e, f, !0) : this.drawPoly(a, d, e, f)
  15002. },
  15003. drawCircle: function(a, c, d, e, f, g, h) {
  15004. g = g || this._lineWidth;
  15005. h = h || this.getDrawColor();
  15006. null == h.a && (h.a = 255);
  15007. var k = 2 * Math.PI / e,
  15008. m = [],
  15009. n;
  15010. for (n = 0; n <= e; n++) {
  15011. var q = n * k,
  15012. r = c * Math.cos(q + d) + a.x,
  15013. q = c * Math.sin(q + d) + a.y;
  15014. m.push(cc.p(r, q))
  15015. }
  15016. f && m.push(cc.p(a.x, a.y));
  15017. g *= 0.5;
  15018. n = 0;
  15019. for (a = m.length; n < a - 1; n++) this.drawSegment(m[n], m[n + 1], g, h)
  15020. },
  15021. drawQuadBezier: function(a, c, d, e, f, g) {
  15022. f = f || this._lineWidth;
  15023. g = g || this.getDrawColor();
  15024. null == g.a && (g.a = 255);
  15025. for (var h = [], k = 0, m = 0; m < e; m++) {
  15026. var n = Math.pow(1 - k, 2) * a.x + 2 * (1 - k) * k * c.x + k * k * d.x,
  15027. q = Math.pow(1 - k, 2) * a.y + 2 * (1 - k) * k * c.y + k * k * d.y;
  15028. h.push(cc.p(n, q));
  15029. k += 1 / e
  15030. }
  15031. h.push(cc.p(d.x, d.y));
  15032. this._drawSegments(h, f, g, !1)
  15033. },
  15034. drawCubicBezier: function(a, c, d, e, f, g, h) {
  15035. g = g || this._lineWidth;
  15036. h = h || this.getDrawColor();
  15037. null == h.a && (h.a = 255);
  15038. for (var k = [], m = 0, n = 0; n < f; n++) {
  15039. 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,
  15040. 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;
  15041. k.push(cc.p(q, r));
  15042. m += 1 / f
  15043. }
  15044. k.push(cc.p(e.x, e.y));
  15045. this._drawSegments(k, g, h, !1)
  15046. },
  15047. drawCatmullRom: function(a, c, d, e) {
  15048. this.drawCardinalSpline(a, 0.5, c, d, e)
  15049. },
  15050. drawCardinalSpline: function(a, c, d, e, f) {
  15051. e = e || this._lineWidth;
  15052. f = f || this.getDrawColor();
  15053. null == f.a && (f.a = 255);
  15054. 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);
  15055. e *= 0.5;
  15056. a = 0;
  15057. for (c = g.length; a < c - 1; a++) this.drawSegment(g[a], g[a + 1], e, f)
  15058. },
  15059. _render: function() {
  15060. var a = cc._renderContext;
  15061. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  15062. a.bindBuffer(a.ARRAY_BUFFER, this._trianglesWebBuffer);
  15063. this._dirty && (a.bufferData(a.ARRAY_BUFFER, this._trianglesArrayBuffer, a.STREAM_DRAW), this._dirty = !1);
  15064. var c = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  15065. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, c, 0);
  15066. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, c, 8);
  15067. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, c, 12);
  15068. a.drawArrays(a.TRIANGLES, 0, 3 * this._buffer.length);
  15069. cc.incrementGLDraws(1)
  15070. },
  15071. _ensureCapacity: function(a) {
  15072. var c = this._buffer;
  15073. if (c.length + a > this._bufferCapacity) {
  15074. var d = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
  15075. this._bufferCapacity += Math.max(this._bufferCapacity, a);
  15076. if (null == c || 0 === c.length) this._buffer = [], this._trianglesArrayBuffer = new ArrayBuffer(d * this._bufferCapacity), this._trianglesReader = new Uint8Array(this._trianglesArrayBuffer);
  15077. else {
  15078. a = [];
  15079. 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);
  15080. this._trianglesReader = new Uint8Array(e);
  15081. this._trianglesArrayBuffer = e;
  15082. this._buffer = a
  15083. }
  15084. }
  15085. },
  15086. draw: function() {
  15087. cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
  15088. this._shaderProgram.use();
  15089. this._shaderProgram.setUniformsForBuiltins();
  15090. this._render()
  15091. },
  15092. drawDot: function(a, c, d) {
  15093. d = d || this.getDrawColor();
  15094. null == d.a && (d.a = 255);
  15095. var e = {
  15096. r: 0 | d.r,
  15097. g: 0 | d.g,
  15098. b: 0 | d.b,
  15099. a: 0 | d.a
  15100. };
  15101. d = {
  15102. vertices: {
  15103. x: a.x - c,
  15104. y: a.y - c
  15105. },
  15106. colors: e,
  15107. texCoords: {
  15108. u: -1,
  15109. v: -1
  15110. }
  15111. };
  15112. var f = {
  15113. vertices: {
  15114. x: a.x - c,
  15115. y: a.y + c
  15116. },
  15117. colors: e,
  15118. texCoords: {
  15119. u: -1,
  15120. v: 1
  15121. }
  15122. },
  15123. g = {
  15124. vertices: {
  15125. x: a.x + c,
  15126. y: a.y + c
  15127. },
  15128. colors: e,
  15129. texCoords: {
  15130. u: 1,
  15131. v: 1
  15132. }
  15133. };
  15134. a = {
  15135. vertices: {
  15136. x: a.x + c,
  15137. y: a.y - c
  15138. },
  15139. colors: e,
  15140. texCoords: {
  15141. u: 1,
  15142. v: -1
  15143. }
  15144. };
  15145. this._ensureCapacity(6);
  15146. 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));
  15147. 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));
  15148. this._dirty = !0
  15149. },
  15150. drawDots: function(a, c, d) {
  15151. if (a && 0 != a.length) {
  15152. d = d || this.getDrawColor();
  15153. null == d.a && (d.a = 255);
  15154. for (var e = 0, f = a.length; e < f; e++) this.drawDot(a[e], c, d)
  15155. }
  15156. },
  15157. drawSegment: function(a, c, d, e) {
  15158. e = e || this.getDrawColor();
  15159. null == e.a && (e.a = 255);
  15160. d = d || 0.5 * this._lineWidth;
  15161. this._ensureCapacity(18);
  15162. e = {
  15163. r: 0 | e.r,
  15164. g: 0 | e.g,
  15165. b: 0 | e.b,
  15166. a: 0 | e.a
  15167. };
  15168. var f = cc.__v2f(a),
  15169. g = cc.__v2f(c);
  15170. c = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g, f)));
  15171. a = cc.v2fperp(c);
  15172. var h = cc.v2fmult(c, d),
  15173. k = cc.v2fmult(a, d);
  15174. d = cc.v2fsub(g, cc.v2fadd(h, k));
  15175. var m = cc.v2fadd(g, cc.v2fsub(h, k)),
  15176. n = cc.v2fsub(g, h),
  15177. g = cc.v2fadd(g, h),
  15178. q = cc.v2fsub(f, h),
  15179. r = cc.v2fadd(f, h),
  15180. t = cc.v2fsub(f, cc.v2fsub(h, k)),
  15181. f = cc.v2fadd(f, cc.v2fadd(h, k)),
  15182. h = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
  15183. k = this._trianglesArrayBuffer,
  15184. s = this._buffer;
  15185. s.push(new cc.V2F_C4B_T2F_Triangle({
  15186. vertices: d,
  15187. colors: e,
  15188. texCoords: cc.__t(cc.v2fneg(cc.v2fadd(c, a)))
  15189. }, {
  15190. vertices: m,
  15191. colors: e,
  15192. texCoords: cc.__t(cc.v2fsub(c, a))
  15193. }, {
  15194. vertices: n,
  15195. colors: e,
  15196. texCoords: cc.__t(cc.v2fneg(c))
  15197. }, k, s.length * h));
  15198. s.push(new cc.V2F_C4B_T2F_Triangle({
  15199. vertices: g,
  15200. colors: e,
  15201. texCoords: cc.__t(c)
  15202. }, {
  15203. vertices: m,
  15204. colors: e,
  15205. texCoords: cc.__t(cc.v2fsub(c, a))
  15206. }, {
  15207. vertices: n,
  15208. colors: e,
  15209. texCoords: cc.__t(cc.v2fneg(c))
  15210. }, k, s.length * h));
  15211. s.push(new cc.V2F_C4B_T2F_Triangle({
  15212. vertices: g,
  15213. colors: e,
  15214. texCoords: cc.__t(c)
  15215. }, {
  15216. vertices: q,
  15217. colors: e,
  15218. texCoords: cc.__t(cc.v2fneg(c))
  15219. }, {
  15220. vertices: n,
  15221. colors: e,
  15222. texCoords: cc.__t(cc.v2fneg(c))
  15223. }, k, s.length * h));
  15224. s.push(new cc.V2F_C4B_T2F_Triangle({
  15225. vertices: g,
  15226. colors: e,
  15227. texCoords: cc.__t(c)
  15228. }, {
  15229. vertices: q,
  15230. colors: e,
  15231. texCoords: cc.__t(cc.v2fneg(c))
  15232. }, {
  15233. vertices: r,
  15234. colors: e,
  15235. texCoords: cc.__t(c)
  15236. }, k, s.length * h));
  15237. s.push(new cc.V2F_C4B_T2F_Triangle({
  15238. vertices: t,
  15239. colors: e,
  15240. texCoords: cc.__t(cc.v2fsub(a, c))
  15241. }, {
  15242. vertices: q,
  15243. colors: e,
  15244. texCoords: cc.__t(cc.v2fneg(c))
  15245. }, {
  15246. vertices: r,
  15247. colors: e,
  15248. texCoords: cc.__t(c)
  15249. }, k, s.length * h));
  15250. s.push(new cc.V2F_C4B_T2F_Triangle({
  15251. vertices: t,
  15252. colors: e,
  15253. texCoords: cc.__t(cc.v2fsub(a, c))
  15254. }, {
  15255. vertices: f,
  15256. colors: e,
  15257. texCoords: cc.__t(cc.v2fadd(c, a))
  15258. }, {
  15259. vertices: r,
  15260. colors: e,
  15261. texCoords: cc.__t(c)
  15262. }, k, s.length * h));
  15263. this._dirty = !0
  15264. },
  15265. drawPoly: function(a, c, d, e) {
  15266. if (null == c) this._drawSegments(a, d, e, !0);
  15267. else {
  15268. null == c.a && (c.a = 255);
  15269. null == e.a && (e.a = 255);
  15270. d = d || this._lineWidth;
  15271. d *= 0.5;
  15272. c = {
  15273. r: 0 | c.r,
  15274. g: 0 | c.g,
  15275. b: 0 | c.b,
  15276. a: 0 | c.a
  15277. };
  15278. e = {
  15279. r: 0 | e.r,
  15280. g: 0 | e.g,
  15281. b: 0 | e.b,
  15282. a: 0 | e.a
  15283. };
  15284. var f = [],
  15285. g, h, k, m, n = a.length;
  15286. for (g = 0; g < n; g++) {
  15287. h = cc.__v2f(a[(g - 1 + n) % n]);
  15288. k = cc.__v2f(a[g]);
  15289. m = cc.__v2f(a[(g + 1) % n]);
  15290. var q = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
  15291. k = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(m, k)));
  15292. q = cc.v2fmult(cc.v2fadd(q, k), 1 / (cc.v2fdot(q, k) + 1));
  15293. f[g] = {
  15294. offset: q,
  15295. n: k
  15296. }
  15297. }
  15298. q = 0 < d;
  15299. this._ensureCapacity(3 * (3 * n - 2));
  15300. var r = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
  15301. t = this._trianglesArrayBuffer,
  15302. s = this._buffer,
  15303. v = !1 == q ? 0.5 : 0;
  15304. 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({
  15305. vertices: h,
  15306. colors: c,
  15307. texCoords: cc.__t(cc.v2fzero())
  15308. }, {
  15309. vertices: k,
  15310. colors: c,
  15311. texCoords: cc.__t(cc.v2fzero())
  15312. }, {
  15313. vertices: m,
  15314. colors: c,
  15315. texCoords: cc.__t(cc.v2fzero())
  15316. }, t, s.length * r));
  15317. for (g = 0; g < n; g++) {
  15318. v = (g + 1) % n;
  15319. h = cc.__v2f(a[g]);
  15320. k = cc.__v2f(a[v]);
  15321. m = f[g].n;
  15322. var u = f[g].offset,
  15323. x = f[v].offset,
  15324. v = q ? cc.v2fsub(h, cc.v2fmult(u, d)) : cc.v2fsub(h, cc.v2fmult(u, 0.5)),
  15325. A = q ? cc.v2fsub(k, cc.v2fmult(x, d)) : cc.v2fsub(k, cc.v2fmult(x, 0.5));
  15326. h = q ? cc.v2fadd(h, cc.v2fmult(u, d)) : cc.v2fadd(h, cc.v2fmult(u, 0.5));
  15327. k = q ? cc.v2fadd(k, cc.v2fmult(x, d)) : cc.v2fadd(k, cc.v2fmult(x, 0.5));
  15328. q ? (s.push(new cc.V2F_C4B_T2F_Triangle({
  15329. vertices: v,
  15330. colors: e,
  15331. texCoords: cc.__t(cc.v2fneg(m))
  15332. }, {
  15333. vertices: A,
  15334. colors: e,
  15335. texCoords: cc.__t(cc.v2fneg(m))
  15336. }, {
  15337. vertices: k,
  15338. colors: e,
  15339. texCoords: cc.__t(m)
  15340. }, t, s.length * r)), s.push(new cc.V2F_C4B_T2F_Triangle({
  15341. vertices: v,
  15342. colors: e,
  15343. texCoords: cc.__t(cc.v2fneg(m))
  15344. }, {
  15345. vertices: h,
  15346. colors: e,
  15347. texCoords: cc.__t(m)
  15348. }, {
  15349. vertices: k,
  15350. colors: e,
  15351. texCoords: cc.__t(m)
  15352. }, t, s.length * r))) : (s.push(new cc.V2F_C4B_T2F_Triangle({
  15353. vertices: v,
  15354. colors: c,
  15355. texCoords: cc.__t(cc.v2fzero())
  15356. }, {
  15357. vertices: A,
  15358. colors: c,
  15359. texCoords: cc.__t(cc.v2fzero())
  15360. }, {
  15361. vertices: k,
  15362. colors: c,
  15363. texCoords: cc.__t(m)
  15364. }, t, s.length * r)), s.push(new cc.V2F_C4B_T2F_Triangle({
  15365. vertices: v,
  15366. colors: c,
  15367. texCoords: cc.__t(cc.v2fzero())
  15368. }, {
  15369. vertices: h,
  15370. colors: c,
  15371. texCoords: cc.__t(m)
  15372. }, {
  15373. vertices: k,
  15374. colors: c,
  15375. texCoords: cc.__t(m)
  15376. }, t, s.length * r)))
  15377. }
  15378. this._dirty = !0
  15379. }
  15380. },
  15381. _drawSegments: function(a, c, d, e) {
  15382. c = c || this._lineWidth;
  15383. d = d || this._drawColor;
  15384. null == d.a && (d.a = 255);
  15385. c *= 0.5;
  15386. if (!(0 >= c)) {
  15387. d = {
  15388. r: 0 | d.r,
  15389. g: 0 | d.g,
  15390. b: 0 | d.b,
  15391. a: 0 | d.a
  15392. };
  15393. var f = [],
  15394. g, h, k, m, n = a.length;
  15395. for (g = 0; g < n; g++) {
  15396. h = cc.__v2f(a[(g - 1 + n) % n]);
  15397. k = cc.__v2f(a[g]);
  15398. m = cc.__v2f(a[(g + 1) % n]);
  15399. var q = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
  15400. k = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(m, k)));
  15401. m = cc.v2fmult(cc.v2fadd(q, k), 1 / (cc.v2fdot(q, k) + 1));
  15402. f[g] = {
  15403. offset: m,
  15404. n: k
  15405. }
  15406. }
  15407. this._ensureCapacity(3 * (3 * n - 2));
  15408. m = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
  15409. var q = this._trianglesArrayBuffer,
  15410. r = this._buffer;
  15411. e = e ? n : n - 1;
  15412. for (g = 0; g < e; g++) {
  15413. var t = (g + 1) % n;
  15414. h = cc.__v2f(a[g]);
  15415. k = cc.__v2f(a[t]);
  15416. var s = f[g].n,
  15417. v = f[g].offset,
  15418. u = f[t].offset,
  15419. t = cc.v2fsub(h, cc.v2fmult(v, c)),
  15420. x = cc.v2fsub(k, cc.v2fmult(u, c));
  15421. h = cc.v2fadd(h, cc.v2fmult(v, c));
  15422. k = cc.v2fadd(k, cc.v2fmult(u, c));
  15423. r.push(new cc.V2F_C4B_T2F_Triangle({
  15424. vertices: t,
  15425. colors: d,
  15426. texCoords: cc.__t(cc.v2fneg(s))
  15427. }, {
  15428. vertices: x,
  15429. colors: d,
  15430. texCoords: cc.__t(cc.v2fneg(s))
  15431. }, {
  15432. vertices: k,
  15433. colors: d,
  15434. texCoords: cc.__t(s)
  15435. }, q, r.length * m));
  15436. r.push(new cc.V2F_C4B_T2F_Triangle({
  15437. vertices: t,
  15438. colors: d,
  15439. texCoords: cc.__t(cc.v2fneg(s))
  15440. }, {
  15441. vertices: h,
  15442. colors: d,
  15443. texCoords: cc.__t(s)
  15444. }, {
  15445. vertices: k,
  15446. colors: d,
  15447. texCoords: cc.__t(s)
  15448. }, q, r.length * m))
  15449. }
  15450. this._dirty = !0
  15451. }
  15452. },
  15453. clear: function() {
  15454. this._buffer.length = 0;
  15455. this._dirty = !0
  15456. }
  15457. });
  15458. cc.DrawNode = cc._renderType == cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas;
  15459. cc.DrawNode.create = function() {
  15460. return new cc.DrawNode
  15461. };
  15462. cc._DrawNodeElement = function(a, c, d, e, f, g, h, k, m) {
  15463. this.type = a;
  15464. this.verts = c || null;
  15465. this.fillColor = d || null;
  15466. this.lineWidth = e || 0;
  15467. this.lineColor = f || null;
  15468. this.lineCap = g || "butt";
  15469. this.isClosePolygon = h || !1;
  15470. this.isFill = k || !1;
  15471. this.isStroke = m || !1
  15472. };
  15473. cc.DrawNode.TYPE_DOT = 0;
  15474. cc.DrawNode.TYPE_SEGMENT = 1;
  15475. cc.DrawNode.TYPE_POLY = 2;
  15476. cc.stencilBits = -1;
  15477. cc.setProgram = function(a, c) {
  15478. a.shaderProgram = c;
  15479. var d = a.children;
  15480. if (d)
  15481. for (var e = 0; e < d.length; e++) cc.setProgram(d[e], c)
  15482. };
  15483. cc.ClippingNode = cc.Node.extend({
  15484. alphaThreshold: 0,
  15485. inverted: !1,
  15486. _stencil: null,
  15487. _godhelpme: !1,
  15488. ctor: function(a) {
  15489. cc.Node.prototype.ctor.call(this);
  15490. this._stencil = null;
  15491. this.alphaThreshold = 0;
  15492. this.inverted = !1;
  15493. cc.ClippingNode.prototype.init.call(this, a || null)
  15494. },
  15495. init: null,
  15496. _className: "ClippingNode",
  15497. _initForWebGL: function(a) {
  15498. this._stencil = a;
  15499. this.alphaThreshold = 1;
  15500. this.inverted = !1;
  15501. cc.ClippingNode._init_once = !0;
  15502. 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);
  15503. return !0
  15504. },
  15505. _initForCanvas: function(a) {
  15506. this._stencil = a;
  15507. this.alphaThreshold = 1;
  15508. this.inverted = !1
  15509. },
  15510. onEnter: function() {
  15511. cc.Node.prototype.onEnter.call(this);
  15512. this._stencil.onEnter()
  15513. },
  15514. onEnterTransitionDidFinish: function() {
  15515. cc.Node.prototype.onEnterTransitionDidFinish.call(this);
  15516. this._stencil.onEnterTransitionDidFinish()
  15517. },
  15518. onExitTransitionDidStart: function() {
  15519. this._stencil.onExitTransitionDidStart();
  15520. cc.Node.prototype.onExitTransitionDidStart.call(this)
  15521. },
  15522. onExit: function() {
  15523. this._stencil.onExit();
  15524. cc.Node.prototype.onExit.call(this)
  15525. },
  15526. visit: null,
  15527. _visitForWebGL: function(a) {
  15528. var c = a || cc._renderContext;
  15529. if (1 > cc.stencilBits) cc.Node.prototype.visit.call(this, a);
  15530. else if (!this._stencil || !this._stencil.visible) this.inverted && cc.Node.prototype.visit.call(this, a);
  15531. 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);
  15532. else {
  15533. cc.ClippingNode._layer++;
  15534. var d = 1 << cc.ClippingNode._layer,
  15535. e = d | d - 1,
  15536. f = c.isEnabled(c.STENCIL_TEST),
  15537. g = c.getParameter(c.STENCIL_WRITEMASK),
  15538. h = c.getParameter(c.STENCIL_FUNC),
  15539. k = c.getParameter(c.STENCIL_REF),
  15540. m = c.getParameter(c.STENCIL_VALUE_MASK),
  15541. n = c.getParameter(c.STENCIL_FAIL),
  15542. q = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL),
  15543. r = c.getParameter(c.STENCIL_PASS_DEPTH_PASS);
  15544. c.enable(c.STENCIL_TEST);
  15545. c.stencilMask(d);
  15546. var t = c.getParameter(c.DEPTH_WRITEMASK);
  15547. c.depthMask(!1);
  15548. c.stencilFunc(c.NEVER, d, d);
  15549. c.stencilOp(!this.inverted ? c.ZERO : c.REPLACE, c.KEEP, c.KEEP);
  15550. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  15551. cc.kmGLPushMatrix();
  15552. cc.kmGLLoadIdentity();
  15553. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  15554. cc.kmGLPushMatrix();
  15555. cc.kmGLLoadIdentity();
  15556. cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255));
  15557. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  15558. cc.kmGLPopMatrix();
  15559. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  15560. cc.kmGLPopMatrix();
  15561. c.stencilFunc(c.NEVER, d, d);
  15562. c.stencilOp(!this.inverted ? c.REPLACE : c.ZERO, c.KEEP, c.KEEP);
  15563. if (1 > this.alphaThreshold) {
  15564. var d = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),
  15565. s = c.getUniformLocation(d.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S);
  15566. cc.glUseProgram(d.getProgram());
  15567. d.setUniformLocationWith1f(s, this.alphaThreshold);
  15568. cc.setProgram(this._stencil, d)
  15569. }
  15570. cc.kmGLPushMatrix();
  15571. this.transform();
  15572. this._stencil.visit();
  15573. cc.kmGLPopMatrix();
  15574. c.depthMask(t);
  15575. c.stencilFunc(c.EQUAL, e, e);
  15576. c.stencilOp(c.KEEP, c.KEEP, c.KEEP);
  15577. cc.Node.prototype.visit.call(this, a);
  15578. c.stencilFunc(h, k, m);
  15579. c.stencilOp(n, q, r);
  15580. c.stencilMask(g);
  15581. f || c.disable(c.STENCIL_TEST);
  15582. cc.ClippingNode._layer--
  15583. }
  15584. },
  15585. _visitForCanvas: function(a) {
  15586. if (!this._stencil || !this._stencil.visible) this.inverted && cc.Node.prototype.visit.call(this, a);
  15587. else {
  15588. a = a || cc._renderContext;
  15589. var c = a.canvas;
  15590. if (this._cangodhelpme() || this._stencil instanceof cc.Sprite) {
  15591. var d = cc.ClippingNode._getSharedCache();
  15592. d.width = c.width;
  15593. d.height = c.height;
  15594. d.getContext("2d").drawImage(c, 0, 0);
  15595. a.save();
  15596. cc.Node.prototype.visit.call(this, a);
  15597. a.globalCompositeOperation = this.inverted ? "destination-out" : "destination-in";
  15598. this.transform(a);
  15599. this._stencil.visit();
  15600. a.restore();
  15601. a.save();
  15602. a.setTransform(1, 0, 0, 1, 0, 0);
  15603. a.globalCompositeOperation = "destination-over";
  15604. a.drawImage(d, 0, 0)
  15605. } else {
  15606. var d = this._children,
  15607. e;
  15608. a.save();
  15609. this.transform(a);
  15610. this._stencil.visit(a);
  15611. 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());
  15612. a.clip();
  15613. this._cangodhelpme(!0);
  15614. var f = d.length;
  15615. if (0 < f) {
  15616. this.sortAllChildren();
  15617. for (c = 0; c < f; c++)
  15618. if (e = d[c], 0 > e._localZOrder) e.visit(a);
  15619. else break;
  15620. for (this.draw(a); c < f; c++) d[c].visit(a)
  15621. } else this.draw(a);
  15622. this._cangodhelpme(!1)
  15623. }
  15624. a.restore()
  15625. }
  15626. },
  15627. getStencil: function() {
  15628. return this._stencil
  15629. },
  15630. setStencil: null,
  15631. _setStencilForWebGL: function(a) {
  15632. this._stencil = a
  15633. },
  15634. _setStencilForCanvas: function(a) {
  15635. this._stencil = a;
  15636. var c = cc._renderContext;
  15637. !(a instanceof cc.Sprite) && a instanceof cc.DrawNode && (a.draw = function() {
  15638. var d = cc.view.getScaleX(),
  15639. e = cc.view.getScaleY();
  15640. c.beginPath();
  15641. for (var f = 0; f < a._buffer.length; f++) {
  15642. var g = a._buffer[f].verts,
  15643. h = g[0];
  15644. c.moveTo(h.x * d, -h.y * e);
  15645. for (var h = 1, k = g.length; h < k; h++) c.lineTo(g[h].x * d, -g[h].y * e)
  15646. }
  15647. })
  15648. },
  15649. getAlphaThreshold: function() {
  15650. return this.alphaThreshold
  15651. },
  15652. setAlphaThreshold: function(a) {
  15653. this.alphaThreshold = a
  15654. },
  15655. isInverted: function() {
  15656. return this.inverted
  15657. },
  15658. setInverted: function(a) {
  15659. this.inverted = a
  15660. },
  15661. _cangodhelpme: function(a) {
  15662. if (!0 === a || !1 === a) cc.ClippingNode.prototype._godhelpme = a;
  15663. return cc.ClippingNode.prototype._godhelpme
  15664. }
  15665. });
  15666. _p = cc.ClippingNode.prototype;
  15667. 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);
  15668. cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil);
  15669. cc.ClippingNode._init_once = null;
  15670. cc.ClippingNode._visit_once = null;
  15671. cc.ClippingNode._layer = -1;
  15672. cc.ClippingNode._sharedCache = null;
  15673. cc.ClippingNode._getSharedCache = function() {
  15674. return cc.ClippingNode._sharedCache || (cc.ClippingNode._sharedCache = document.createElement("canvas"))
  15675. };
  15676. cc.ClippingNode.create = function(a) {
  15677. return new cc.ClippingNode(a)
  15678. };
  15679. cc.GridBase = cc.Class.extend({
  15680. _active: !1,
  15681. _reuseGrid: 0,
  15682. _gridSize: null,
  15683. _texture: null,
  15684. _step: null,
  15685. _grabber: null,
  15686. _isTextureFlipped: !1,
  15687. _shaderProgram: null,
  15688. _directorProjection: 0,
  15689. _dirty: !1,
  15690. ctor: function(a, c, d) {
  15691. cc._checkWebGLRenderMode();
  15692. this._active = !1;
  15693. this._reuseGrid = 0;
  15694. this._texture = this._gridSize = null;
  15695. this._step = cc.p(0, 0);
  15696. this._grabber = null;
  15697. this._isTextureFlipped = !1;
  15698. this._shaderProgram = null;
  15699. this._directorProjection = 0;
  15700. this._dirty = !1;
  15701. void 0 !== a && this.initWithSize(a, c, d)
  15702. },
  15703. isActive: function() {
  15704. return this._active
  15705. },
  15706. setActive: function(a) {
  15707. this._active = a;
  15708. if (!a) {
  15709. a = cc.director;
  15710. var c = a.getProjection();
  15711. a.setProjection(c)
  15712. }
  15713. },
  15714. getReuseGrid: function() {
  15715. return this._reuseGrid
  15716. },
  15717. setReuseGrid: function(a) {
  15718. this._reuseGrid = a
  15719. },
  15720. getGridSize: function() {
  15721. return cc.size(this._gridSize.width, this._gridSize.height)
  15722. },
  15723. setGridSize: function(a) {
  15724. this._gridSize.width = parseInt(a.width);
  15725. this._gridSize.height = parseInt(a.height)
  15726. },
  15727. getStep: function() {
  15728. return cc.p(this._step.x, this._step.y)
  15729. },
  15730. setStep: function(a) {
  15731. this._step.x = a.x;
  15732. this._step.y = a.y
  15733. },
  15734. isTextureFlipped: function() {
  15735. return this._isTextureFlipped
  15736. },
  15737. setTextureFlipped: function(a) {
  15738. this._isTextureFlipped != a && (this._isTextureFlipped = a, this.calculateVertexPoints())
  15739. },
  15740. initWithSize: function(a, c, d) {
  15741. if (!c) {
  15742. var e = cc.director.getWinSizeInPixels(),
  15743. f = cc.NextPOT(e.width),
  15744. g = cc.NextPOT(e.height),
  15745. h = new Uint8Array(4 * f * g);
  15746. if (!h) return cc.log("cocos2d: CCGrid: not enough memory."), !1;
  15747. c = new cc.Texture2D;
  15748. c.initWithData(h, cc.Texture2D.PIXEL_FORMAT_RGBA8888, f, g, e);
  15749. if (!c) return cc.log("cocos2d: CCGrid: error creating texture"), !1
  15750. }
  15751. this._active = !1;
  15752. this._reuseGrid = 0;
  15753. this._gridSize = a;
  15754. this._texture = c;
  15755. this._isTextureFlipped = d || !1;
  15756. this._step.x = this._texture.width / a.width;
  15757. this._step.y = this._texture.height / a.height;
  15758. this._grabber = new cc.Grabber;
  15759. if (!this._grabber) return !1;
  15760. this._grabber.grab(this._texture);
  15761. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
  15762. this.calculateVertexPoints();
  15763. return !0
  15764. },
  15765. beforeDraw: function() {
  15766. this._directorProjection = cc.director.getProjection();
  15767. this.set2DProjection();
  15768. this._grabber.beforeRender(this._texture)
  15769. },
  15770. afterDraw: function(a) {
  15771. this._grabber.afterRender(this._texture);
  15772. cc.director.setProjection(this._directorProjection);
  15773. if (a.getCamera().isDirty()) {
  15774. var c = a.getAnchorPointInPoints();
  15775. cc.kmGLTranslatef(c.x, c.y, 0);
  15776. a.getCamera().locate();
  15777. cc.kmGLTranslatef(-c.x, -c.y, 0)
  15778. }
  15779. cc.glBindTexture2D(this._texture);
  15780. this.blit()
  15781. },
  15782. blit: function() {
  15783. cc.log("cc.GridBase.blit(): Shall be overridden in subclass.")
  15784. },
  15785. reuse: function() {
  15786. cc.log("cc.GridBase.reuse(): Shall be overridden in subclass.")
  15787. },
  15788. calculateVertexPoints: function() {
  15789. cc.log("cc.GridBase.calculateVertexPoints(): Shall be overridden in subclass.")
  15790. },
  15791. set2DProjection: function() {
  15792. var a = cc.director.getWinSizeInPixels();
  15793. cc._renderContext.viewport(0, 0, a.width, a.height);
  15794. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  15795. cc.kmGLLoadIdentity();
  15796. var c = new cc.kmMat4;
  15797. cc.kmMat4OrthographicProjection(c, 0, a.width, 0, a.height, -1, 1);
  15798. cc.kmGLMultMatrix(c);
  15799. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  15800. cc.kmGLLoadIdentity();
  15801. cc.setProjectionMatrixDirty()
  15802. }
  15803. });
  15804. cc.GridBase.create = function(a, c, d) {
  15805. return new cc.GridBase(a, c, d)
  15806. };
  15807. cc.Grid3D = cc.GridBase.extend({
  15808. _texCoordinates: null,
  15809. _vertices: null,
  15810. _originalVertices: null,
  15811. _indices: null,
  15812. _texCoordinateBuffer: null,
  15813. _verticesBuffer: null,
  15814. _indicesBuffer: null,
  15815. ctor: function(a, c, d) {
  15816. cc.GridBase.prototype.ctor.call(this);
  15817. this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
  15818. void 0 !== a && this.initWithSize(a, c, d)
  15819. },
  15820. vertex: function(a) {
  15821. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.vertex() : Numbers must be integers");
  15822. a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
  15823. var c = this._vertices;
  15824. return new cc.Vertex3F(c[a], c[a + 1], c[a + 2])
  15825. },
  15826. originalVertex: function(a) {
  15827. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.originalVertex() : Numbers must be integers");
  15828. a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
  15829. var c = this._originalVertices;
  15830. return new cc.Vertex3F(c[a], c[a + 1], c[a + 2])
  15831. },
  15832. setVertex: function(a, c) {
  15833. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.Grid3D.setVertex() : Numbers must be integers");
  15834. var d = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y),
  15835. e = this._vertices;
  15836. e[d] = c.x;
  15837. e[d + 1] = c.y;
  15838. e[d + 2] = c.z;
  15839. this._dirty = !0
  15840. },
  15841. blit: function() {
  15842. var a = this._gridSize.width * this._gridSize.height;
  15843. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  15844. this._shaderProgram.use();
  15845. this._shaderProgram.setUniformsForBuiltins();
  15846. var c = cc._renderContext,
  15847. d = this._dirty;
  15848. c.bindBuffer(c.ARRAY_BUFFER, this._verticesBuffer);
  15849. d && c.bufferData(c.ARRAY_BUFFER, this._vertices, c.DYNAMIC_DRAW);
  15850. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, c.FLOAT, !1, 0, 0);
  15851. c.bindBuffer(c.ARRAY_BUFFER, this._texCoordinateBuffer);
  15852. d && c.bufferData(c.ARRAY_BUFFER, this._texCoordinates, c.DYNAMIC_DRAW);
  15853. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, 0);
  15854. c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  15855. d && c.bufferData(c.ELEMENT_ARRAY_BUFFER, this._indices, c.STATIC_DRAW);
  15856. c.drawElements(c.TRIANGLES, 6 * a, c.UNSIGNED_SHORT, 0);
  15857. d && (this._dirty = !1);
  15858. cc.incrementGLDraws(1)
  15859. },
  15860. reuse: function() {
  15861. if (0 < this._reuseGrid) {
  15862. for (var a = this._originalVertices, c = this._vertices, d = 0, e = this._vertices.length; d < e; d++) a[d] = c[d];
  15863. --this._reuseGrid
  15864. }
  15865. },
  15866. calculateVertexPoints: function() {
  15867. var a = cc._renderContext,
  15868. c = this._texture.pixelsWidth,
  15869. d = this._texture.pixelsHeight,
  15870. e = this._texture.getContentSizeInPixels().height,
  15871. f = this._gridSize,
  15872. g = (f.width + 1) * (f.height + 1);
  15873. this._vertices = new Float32Array(3 * g);
  15874. this._texCoordinates = new Float32Array(2 * g);
  15875. this._indices = new Uint16Array(6 * f.width * f.height);
  15876. this._verticesBuffer && a.deleteBuffer(this._verticesBuffer);
  15877. this._verticesBuffer = a.createBuffer();
  15878. this._texCoordinateBuffer && a.deleteBuffer(this._texCoordinateBuffer);
  15879. this._texCoordinateBuffer = a.createBuffer();
  15880. this._indicesBuffer && a.deleteBuffer(this._indicesBuffer);
  15881. this._indicesBuffer = a.createBuffer();
  15882. for (var h, k, m = this._indices, n = this._texCoordinates, q = this._isTextureFlipped, r = this._vertices, g = 0; g < f.width; ++g)
  15883. for (h = 0; h < f.height; ++h) {
  15884. var t = h * f.width + g;
  15885. k = g * this._step.x;
  15886. var s = k + this._step.x,
  15887. v = h * this._step.y,
  15888. u = v + this._step.y,
  15889. x = g * (f.height + 1) + h,
  15890. A = (g + 1) * (f.height + 1) + h,
  15891. D = (g + 1) * (f.height + 1) + (h + 1),
  15892. F = g * (f.height + 1) + (h + 1);
  15893. m[6 * t] = x;
  15894. m[6 * t + 1] = A;
  15895. m[6 * t + 2] = F;
  15896. m[6 * t + 3] = A;
  15897. m[6 * t + 4] = D;
  15898. m[6 * t + 5] = F;
  15899. var t = [3 * x, 3 * A, 3 * D, 3 * F],
  15900. y = [{
  15901. x: k,
  15902. y: v,
  15903. z: 0
  15904. }, {
  15905. x: s,
  15906. y: v,
  15907. z: 0
  15908. }, {
  15909. x: s,
  15910. y: u,
  15911. z: 0
  15912. }, {
  15913. x: k,
  15914. y: u,
  15915. z: 0
  15916. }],
  15917. x = [2 * x, 2 * A, 2 * D, 2 * F],
  15918. s = [cc.p(k, v), cc.p(s, v), cc.p(s, u), cc.p(k, u)];
  15919. 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
  15920. }
  15921. this._originalVertices = new Float32Array(this._vertices);
  15922. a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
  15923. a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
  15924. a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer);
  15925. a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW);
  15926. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  15927. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW);
  15928. this._dirty = !0
  15929. }
  15930. });
  15931. cc.Grid3D.create = function(a, c, d) {
  15932. return new cc.Grid3D(a, c, d)
  15933. };
  15934. cc.TiledGrid3D = cc.GridBase.extend({
  15935. _texCoordinates: null,
  15936. _vertices: null,
  15937. _originalVertices: null,
  15938. _indices: null,
  15939. _texCoordinateBuffer: null,
  15940. _verticesBuffer: null,
  15941. _indicesBuffer: null,
  15942. ctor: function(a, c, d) {
  15943. cc.GridBase.prototype.ctor.call(this);
  15944. this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
  15945. void 0 !== a && this.initWithSize(a, c, d)
  15946. },
  15947. tile: function(a) {
  15948. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.tile() : Numbers must be integers");
  15949. a = 12 * (this._gridSize.height * a.x + a.y);
  15950. var c = this._vertices;
  15951. 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]))
  15952. },
  15953. originalTile: function(a) {
  15954. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers");
  15955. a = 12 * (this._gridSize.height * a.x + a.y);
  15956. var c = this._originalVertices;
  15957. 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]))
  15958. },
  15959. setTile: function(a, c) {
  15960. (a.x !== (0 | a.x) || a.y !== (0 | a.y)) && cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers");
  15961. var d = 12 * (this._gridSize.height * a.x + a.y),
  15962. e = this._vertices;
  15963. e[d] = c.bl.x;
  15964. e[d + 1] = c.bl.y;
  15965. e[d + 2] = c.bl.z;
  15966. e[d + 3] = c.br.x;
  15967. e[d + 4] = c.br.y;
  15968. e[d + 5] = c.br.z;
  15969. e[d + 6] = c.tl.x;
  15970. e[d + 7] = c.tl.y;
  15971. e[d + 8] = c.tl.z;
  15972. e[d + 9] = c.tr.x;
  15973. e[d + 10] = c.tr.y;
  15974. e[d + 11] = c.tr.z;
  15975. this._dirty = !0
  15976. },
  15977. blit: function() {
  15978. var a = this._gridSize.width * this._gridSize.height;
  15979. this._shaderProgram.use();
  15980. this._shaderProgram.setUniformsForBuiltins();
  15981. var c = cc._renderContext,
  15982. d = this._dirty;
  15983. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  15984. c.bindBuffer(c.ARRAY_BUFFER, this._verticesBuffer);
  15985. d && c.bufferData(c.ARRAY_BUFFER, this._vertices, c.DYNAMIC_DRAW);
  15986. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, c.FLOAT, !1, 0, this._vertices);
  15987. c.bindBuffer(c.ARRAY_BUFFER, this._texCoordinateBuffer);
  15988. d && c.bufferData(c.ARRAY_BUFFER, this._texCoordinates, c.DYNAMIC_DRAW);
  15989. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, this._texCoordinates);
  15990. c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  15991. d && c.bufferData(c.ELEMENT_ARRAY_BUFFER, this._indices, c.STATIC_DRAW);
  15992. c.drawElements(c.TRIANGLES, 6 * a, c.UNSIGNED_SHORT, 0);
  15993. d && (this._dirty = !1);
  15994. cc.incrementGLDraws(1)
  15995. },
  15996. reuse: function() {
  15997. if (0 < this._reuseGrid) {
  15998. for (var a = this._vertices, c = this._originalVertices, d = 0; d < a.length; d++) c[d] = a[d];
  15999. --this._reuseGrid
  16000. }
  16001. },
  16002. calculateVertexPoints: function() {
  16003. var a = this._texture.pixelsWidth,
  16004. c = this._texture.pixelsHeight,
  16005. d = this._texture.getContentSizeInPixels().height,
  16006. e = this._gridSize,
  16007. f = e.width * e.height;
  16008. this._vertices = new Float32Array(12 * f);
  16009. this._texCoordinates = new Float32Array(8 * f);
  16010. this._indices = new Uint16Array(6 * f);
  16011. var g = cc._renderContext;
  16012. this._verticesBuffer && g.deleteBuffer(this._verticesBuffer);
  16013. this._verticesBuffer = g.createBuffer();
  16014. this._texCoordinateBuffer && g.deleteBuffer(this._texCoordinateBuffer);
  16015. this._texCoordinateBuffer = g.createBuffer();
  16016. this._indicesBuffer && g.deleteBuffer(this._indicesBuffer);
  16017. this._indicesBuffer = g.createBuffer();
  16018. var h, k, m = 0,
  16019. n = this._step,
  16020. q = this._vertices,
  16021. r = this._texCoordinates,
  16022. t = this._isTextureFlipped;
  16023. for (h = 0; h < e.width; h++)
  16024. for (k = 0; k < e.height; k++) {
  16025. var s = h * n.x,
  16026. v = s + n.x,
  16027. u = k * n.y,
  16028. x = u + n.y;
  16029. q[12 * m] = s;
  16030. q[12 * m + 1] = u;
  16031. q[12 * m + 2] = 0;
  16032. q[12 * m + 3] = v;
  16033. q[12 * m + 4] = u;
  16034. q[12 * m + 5] = 0;
  16035. q[12 * m + 6] = s;
  16036. q[12 * m + 7] = x;
  16037. q[12 * m + 8] = 0;
  16038. q[12 * m + 9] = v;
  16039. q[12 * m + 10] = x;
  16040. q[12 * m + 11] = 0;
  16041. var A = u,
  16042. D = x;
  16043. t && (A = d - u, D = d - x);
  16044. r[8 * m] = s / a;
  16045. r[8 * m + 1] = A / c;
  16046. r[8 * m + 2] = v / a;
  16047. r[8 * m + 3] = A / c;
  16048. r[8 * m + 4] = s / a;
  16049. r[8 * m + 5] = D / c;
  16050. r[8 * m + 6] = v / a;
  16051. r[8 * m + 7] = D / c;
  16052. m++
  16053. }
  16054. a = this._indices;
  16055. 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;
  16056. this._originalVertices = new Float32Array(this._vertices);
  16057. g.bindBuffer(g.ARRAY_BUFFER, this._verticesBuffer);
  16058. g.bufferData(g.ARRAY_BUFFER, this._vertices, g.DYNAMIC_DRAW);
  16059. g.bindBuffer(g.ARRAY_BUFFER, this._texCoordinateBuffer);
  16060. g.bufferData(g.ARRAY_BUFFER, this._texCoordinates, g.DYNAMIC_DRAW);
  16061. g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  16062. g.bufferData(g.ELEMENT_ARRAY_BUFFER, this._indices, g.DYNAMIC_DRAW);
  16063. this._dirty = !0
  16064. }
  16065. });
  16066. cc.TiledGrid3D.create = function(a, c, d) {
  16067. return new cc.TiledGrid3D(a, c, d)
  16068. };
  16069. cc.Grabber = cc.Class.extend({
  16070. _FBO: null,
  16071. _oldFBO: null,
  16072. _oldClearColor: null,
  16073. _gl: null,
  16074. ctor: function() {
  16075. cc._checkWebGLRenderMode();
  16076. this._gl = cc._renderContext;
  16077. this._oldClearColor = [0, 0, 0, 0];
  16078. this._oldFBO = null;
  16079. this._FBO = this._gl.createFramebuffer()
  16080. },
  16081. grab: function(a) {
  16082. var c = this._gl;
  16083. this._oldFBO = c.getParameter(c.FRAMEBUFFER_BINDING);
  16084. c.bindFramebuffer(c.FRAMEBUFFER, this._FBO);
  16085. c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, a._webTextureObj, 0);
  16086. c.checkFramebufferStatus(c.FRAMEBUFFER) != c.FRAMEBUFFER_COMPLETE && cc.log("Frame Grabber: could not attach texture to frmaebuffer");
  16087. c.bindFramebuffer(c.FRAMEBUFFER, this._oldFBO)
  16088. },
  16089. beforeRender: function(a) {
  16090. a = this._gl;
  16091. this._oldFBO = a.getParameter(a.FRAMEBUFFER_BINDING);
  16092. a.bindFramebuffer(a.FRAMEBUFFER, this._FBO);
  16093. this._oldClearColor = a.getParameter(a.COLOR_CLEAR_VALUE);
  16094. a.clearColor(0, 0, 0, 0);
  16095. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
  16096. },
  16097. afterRender: function(a) {
  16098. a = this._gl;
  16099. a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
  16100. a.colorMask(!0, !0, !0, !0)
  16101. },
  16102. destroy: function() {
  16103. this._gl.deleteFramebuffer(this._FBO)
  16104. }
  16105. });
  16106. cc.ACTION_TAG_INVALID = -1;
  16107. cc.Action = cc.Class.extend({
  16108. originalTarget: null,
  16109. target: null,
  16110. tag: cc.ACTION_TAG_INVALID,
  16111. ctor: function() {
  16112. this.target = this.originalTarget = null;
  16113. this.tag = cc.ACTION_TAG_INVALID
  16114. },
  16115. copy: function() {
  16116. cc.log("copy is deprecated. Please use clone instead.");
  16117. return this.clone()
  16118. },
  16119. clone: function() {
  16120. var a = new cc.Action;
  16121. a.originalTarget = null;
  16122. a.target = null;
  16123. a.tag = this.tag;
  16124. return a
  16125. },
  16126. isDone: function() {
  16127. return !0
  16128. },
  16129. startWithTarget: function(a) {
  16130. this.target = this.originalTarget = a
  16131. },
  16132. stop: function() {
  16133. this.target = null
  16134. },
  16135. step: function(a) {
  16136. cc.log("[Action step]. override me")
  16137. },
  16138. update: function(a) {
  16139. cc.log("[Action update]. override me")
  16140. },
  16141. getTarget: function() {
  16142. return this.target
  16143. },
  16144. setTarget: function(a) {
  16145. this.target = a
  16146. },
  16147. getOriginalTarget: function() {
  16148. return this.originalTarget
  16149. },
  16150. setOriginalTarget: function(a) {
  16151. this.originalTarget = a
  16152. },
  16153. getTag: function() {
  16154. return this.tag
  16155. },
  16156. setTag: function(a) {
  16157. this.tag = a
  16158. },
  16159. retain: function() {},
  16160. release: function() {}
  16161. });
  16162. cc.action = function() {
  16163. return new cc.Action
  16164. };
  16165. cc.Action.create = cc.action;
  16166. cc.FiniteTimeAction = cc.Action.extend({
  16167. _duration: 0,
  16168. ctor: function() {
  16169. cc.Action.prototype.ctor.call(this);
  16170. this._duration = 0
  16171. },
  16172. getDuration: function() {
  16173. return this._duration * (this._times || 1)
  16174. },
  16175. setDuration: function(a) {
  16176. this._duration = a
  16177. },
  16178. reverse: function() {
  16179. cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");
  16180. return null
  16181. },
  16182. clone: function() {
  16183. return new cc.FiniteTimeAction
  16184. }
  16185. });
  16186. cc.Speed = cc.Action.extend({
  16187. _speed: 0,
  16188. _innerAction: null,
  16189. ctor: function(a, c) {
  16190. cc.Action.prototype.ctor.call(this);
  16191. this._speed = 0;
  16192. this._innerAction = null;
  16193. a && this.initWithAction(a, c)
  16194. },
  16195. getSpeed: function() {
  16196. return this._speed
  16197. },
  16198. setSpeed: function(a) {
  16199. this._speed = a
  16200. },
  16201. initWithAction: function(a, c) {
  16202. if (!a) throw "cc.Speed.initWithAction(): action must be non nil";
  16203. this._innerAction = a;
  16204. this._speed = c;
  16205. return !0
  16206. },
  16207. clone: function() {
  16208. var a = new cc.Speed;
  16209. a.initWithAction(this._innerAction.clone(), this._speed);
  16210. return a
  16211. },
  16212. startWithTarget: function(a) {
  16213. cc.Action.prototype.startWithTarget.call(this, a);
  16214. this._innerAction.startWithTarget(a)
  16215. },
  16216. stop: function() {
  16217. this._innerAction.stop();
  16218. cc.Action.prototype.stop.call(this)
  16219. },
  16220. step: function(a) {
  16221. this._innerAction.step(a * this._speed)
  16222. },
  16223. isDone: function() {
  16224. return this._innerAction.isDone()
  16225. },
  16226. reverse: function() {
  16227. return cc.Speed.create(this._innerAction.reverse(), this._speed)
  16228. },
  16229. setInnerAction: function(a) {
  16230. this._innerAction != a && (this._innerAction = a)
  16231. },
  16232. getInnerAction: function() {
  16233. return this._innerAction
  16234. }
  16235. });
  16236. cc.speed = function(a, c) {
  16237. return new cc.Speed(a, c)
  16238. };
  16239. cc.Speed.create = cc.speed;
  16240. cc.Follow = cc.Action.extend({
  16241. _followedNode: null,
  16242. _boundarySet: !1,
  16243. _boundaryFullyCovered: !1,
  16244. _halfScreenSize: null,
  16245. _fullScreenSize: null,
  16246. leftBoundary: 0,
  16247. rightBoundary: 0,
  16248. topBoundary: 0,
  16249. bottomBoundary: 0,
  16250. _worldRect: null,
  16251. ctor: function(a, c) {
  16252. cc.Action.prototype.ctor.call(this);
  16253. this._followedNode = null;
  16254. this._boundaryFullyCovered = this._boundarySet = !1;
  16255. this._fullScreenSize = this._halfScreenSize = null;
  16256. this.bottomBoundary = this.topBoundary = this.rightBoundary = this.leftBoundary = 0;
  16257. this._worldRect = cc.rect(0, 0, 0, 0);
  16258. a && (c ? this.initWithTarget(a, c) : this.initWithTarget(a))
  16259. },
  16260. clone: function() {
  16261. var a = new cc.Follow,
  16262. c = this._worldRect,
  16263. c = new cc.Rect(c.x, c.y, c.width, c.height);
  16264. a.initWithTarget(this._followedNode, c);
  16265. return a
  16266. },
  16267. isBoundarySet: function() {
  16268. return this._boundarySet
  16269. },
  16270. setBoudarySet: function(a) {
  16271. this._boundarySet = a
  16272. },
  16273. initWithTarget: function(a, c) {
  16274. if (!a) throw "cc.Follow.initWithAction(): followedNode must be non nil";
  16275. c = c || cc.rect(0, 0, 0, 0);
  16276. this._followedNode = a;
  16277. this._worldRect = c;
  16278. this._boundarySet = !cc._rectEqualToZero(c);
  16279. this._boundaryFullyCovered = !1;
  16280. var d = cc.director.getWinSize();
  16281. this._fullScreenSize = cc.p(d.width, d.height);
  16282. this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5);
  16283. 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));
  16284. return !0
  16285. },
  16286. step: function(a) {
  16287. a = this._followedNode.x;
  16288. var c = this._followedNode.y;
  16289. a = this._halfScreenSize.x - a;
  16290. c = this._halfScreenSize.y - c;
  16291. 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)
  16292. },
  16293. isDone: function() {
  16294. return !this._followedNode.running
  16295. },
  16296. stop: function() {
  16297. this.target = null;
  16298. cc.Action.prototype.stop.call(this)
  16299. }
  16300. });
  16301. cc.follow = function(a, c) {
  16302. return new cc.Follow(a, c)
  16303. };
  16304. cc.Follow.create = cc.follow;
  16305. cc.ActionInterval = cc.FiniteTimeAction.extend({
  16306. _elapsed: 0,
  16307. _firstTick: !1,
  16308. _easeList: null,
  16309. _times: 1,
  16310. _repeatForever: !1,
  16311. _repeatMethod: !1,
  16312. _speed: 1,
  16313. _speedMethod: !1,
  16314. ctor: function(a) {
  16315. this._times = this._speed = 1;
  16316. this._repeatForever = !1;
  16317. this.MAX_VALUE = 2;
  16318. this._speedMethod = this._repeatMethod = !1;
  16319. cc.FiniteTimeAction.prototype.ctor.call(this);
  16320. void 0 !== a && this.initWithDuration(a)
  16321. },
  16322. getElapsed: function() {
  16323. return this._elapsed
  16324. },
  16325. initWithDuration: function(a) {
  16326. this._duration = 0 === a ? cc.FLT_EPSILON : a;
  16327. this._elapsed = 0;
  16328. return this._firstTick = !0
  16329. },
  16330. isDone: function() {
  16331. return this._elapsed >= this._duration
  16332. },
  16333. _cloneDecoration: function(a) {
  16334. a._repeatForever = this._repeatForever;
  16335. a._speed = this._speed;
  16336. a._times = this._times;
  16337. a._easeList = this._easeList;
  16338. a._speedMethod = this._speedMethod;
  16339. a._repeatMethod = this._repeatMethod
  16340. },
  16341. _reverseEaseList: function(a) {
  16342. if (this._easeList) {
  16343. a._easeList = [];
  16344. for (var c = 0; c < this._easeList.length; c++) a._easeList.push(this._easeList[c].reverse())
  16345. }
  16346. },
  16347. clone: function() {
  16348. var a = new cc.ActionInterval(this._duration);
  16349. this._cloneDecoration(a);
  16350. return a
  16351. },
  16352. easing: function(a) {
  16353. this._easeList ? this._easeList.length = 0 : this._easeList = [];
  16354. for (var c = 0; c < arguments.length; c++) this._easeList.push(arguments[c]);
  16355. return this
  16356. },
  16357. _computeEaseTime: function(a) {
  16358. var c = this._easeList;
  16359. if (!c || 0 === c.length) return a;
  16360. for (var d = 0, e = c.length; d < e; d++) a = c[d].easing(a);
  16361. return a
  16362. },
  16363. step: function(a) {
  16364. this._firstTick ? (this._firstTick = !1, this._elapsed = 0) : this._elapsed += a;
  16365. a = this._elapsed / (1.192092896E-7 < this._duration ? this._duration : 1.192092896E-7);
  16366. a = 1 > a ? a : 1;
  16367. this.update(0 < a ? a : 0);
  16368. this._repeatMethod && (1 < this._times && this.isDone()) && (this._repeatForever || this._times--, this.startWithTarget(this.target), this.step(this._elapsed - this._duration))
  16369. },
  16370. startWithTarget: function(a) {
  16371. cc.Action.prototype.startWithTarget.call(this, a);
  16372. this._elapsed = 0;
  16373. this._firstTick = !0
  16374. },
  16375. reverse: function() {
  16376. cc.log("cc.IntervalAction: reverse not implemented.");
  16377. return null
  16378. },
  16379. setAmplitudeRate: function(a) {
  16380. cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")
  16381. },
  16382. getAmplitudeRate: function() {
  16383. cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
  16384. return 0
  16385. },
  16386. speed: function(a) {
  16387. if (0 >= a) return cc.log("The speed parameter error"), this;
  16388. this._speedMethod = !0;
  16389. this._speed *= a;
  16390. return this
  16391. },
  16392. getSpeed: function() {
  16393. return this._speed
  16394. },
  16395. setSpeed: function(a) {
  16396. this._speed = a;
  16397. return this
  16398. },
  16399. repeat: function(a) {
  16400. a = Math.round(a);
  16401. if (isNaN(a) || 1 > a) return cc.log("The repeat parameter error"), this;
  16402. this._repeatMethod = !0;
  16403. this._times *= a;
  16404. return this
  16405. },
  16406. repeatForever: function() {
  16407. this._repeatMethod = !0;
  16408. this._times = this.MAX_VALUE;
  16409. this._repeatForever = !0;
  16410. return this
  16411. }
  16412. });
  16413. cc.actionInterval = function(a) {
  16414. return new cc.ActionInterval(a)
  16415. };
  16416. cc.ActionInterval.create = cc.actionInterval;
  16417. cc.Sequence = cc.ActionInterval.extend({
  16418. _actions: null,
  16419. _split: null,
  16420. _last: 0,
  16421. ctor: function(a) {
  16422. cc.ActionInterval.prototype.ctor.call(this);
  16423. this._actions = [];
  16424. var c = a instanceof Array ? a : arguments,
  16425. d = c.length - 1;
  16426. 0 <= d && null == c[d] && cc.log("parameters should not be ending with null in Javascript");
  16427. if (0 <= d) {
  16428. for (var e = c[0], f = 1; f < d; f++) c[f] && (e = cc.Sequence._actionOneTwo(e, c[f]));
  16429. this.initWithTwoActions(e, c[d])
  16430. }
  16431. },
  16432. initWithTwoActions: function(a, c) {
  16433. if (!a || !c) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil";
  16434. this.initWithDuration(a._duration + c._duration);
  16435. this._actions[0] = a;
  16436. this._actions[1] = c;
  16437. return !0
  16438. },
  16439. clone: function() {
  16440. var a = new cc.Sequence;
  16441. this._cloneDecoration(a);
  16442. a.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
  16443. return a
  16444. },
  16445. startWithTarget: function(a) {
  16446. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16447. this._split = this._actions[0]._duration / this._duration;
  16448. this._last = -1
  16449. },
  16450. stop: function() {
  16451. -1 !== this._last && this._actions[this._last].stop();
  16452. cc.Action.prototype.stop.call(this)
  16453. },
  16454. update: function(a) {
  16455. a = this._computeEaseTime(a);
  16456. var c = 0,
  16457. d = this._split,
  16458. e = this._actions,
  16459. f = this._last;
  16460. 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()));
  16461. f === c && e[c].isDone() || (f !== c && e[c].startWithTarget(this.target), e[c].update(a), this._last = c)
  16462. },
  16463. reverse: function() {
  16464. var a = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
  16465. this._cloneDecoration(a);
  16466. this._reverseEaseList(a);
  16467. return a
  16468. }
  16469. });
  16470. cc.sequence = function(a) {
  16471. var c = a instanceof Array ? a : arguments;
  16472. 0 < c.length && null == c[c.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  16473. for (var d = c[0], e = 1; e < c.length; e++) c[e] && (d = cc.Sequence._actionOneTwo(d, c[e]));
  16474. return d
  16475. };
  16476. cc.Sequence.create = cc.sequence;
  16477. cc.Sequence._actionOneTwo = function(a, c) {
  16478. var d = new cc.Sequence;
  16479. d.initWithTwoActions(a, c);
  16480. return d
  16481. };
  16482. cc.Repeat = cc.ActionInterval.extend({
  16483. _times: 0,
  16484. _total: 0,
  16485. _nextDt: 0,
  16486. _actionInstant: !1,
  16487. _innerAction: null,
  16488. ctor: function(a, c) {
  16489. cc.ActionInterval.prototype.ctor.call(this);
  16490. void 0 !== c && this.initWithAction(a, c)
  16491. },
  16492. initWithAction: function(a, c) {
  16493. 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
  16494. },
  16495. clone: function() {
  16496. var a = new cc.Repeat;
  16497. this._cloneDecoration(a);
  16498. a.initWithAction(this._innerAction.clone(), this._times);
  16499. return a
  16500. },
  16501. startWithTarget: function(a) {
  16502. this._total = 0;
  16503. this._nextDt = this._innerAction._duration / this._duration;
  16504. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16505. this._innerAction.startWithTarget(a)
  16506. },
  16507. stop: function() {
  16508. this._innerAction.stop();
  16509. cc.Action.prototype.stop.call(this)
  16510. },
  16511. update: function(a) {
  16512. a = this._computeEaseTime(a);
  16513. var c = this._innerAction,
  16514. d = this._duration,
  16515. e = this._times,
  16516. f = this._nextDt;
  16517. if (a >= f) {
  16518. for (; a > f && this._total < e;) c.update(1), this._total++, c.stop(), c.startWithTarget(this.target), this._nextDt = f += c._duration / d;
  16519. 1 <= a && this._total < e && this._total++;
  16520. this._actionInstant || (this._total === e ? (c.update(1), c.stop()) : c.update(a - (f - c._duration / d)))
  16521. } else c.update(a * e % 1)
  16522. },
  16523. isDone: function() {
  16524. return this._total == this._times
  16525. },
  16526. reverse: function() {
  16527. var a = cc.repeat(this._innerAction.reverse(), this._times);
  16528. this._cloneDecoration(a);
  16529. this._reverseEaseList(a);
  16530. return a
  16531. },
  16532. setInnerAction: function(a) {
  16533. this._innerAction != a && (this._innerAction = a)
  16534. },
  16535. getInnerAction: function() {
  16536. return this._innerAction
  16537. }
  16538. });
  16539. cc.repeat = function(a, c) {
  16540. return new cc.Repeat(a, c)
  16541. };
  16542. cc.Repeat.create = cc.repeat;
  16543. cc.RepeatForever = cc.ActionInterval.extend({
  16544. _innerAction: null,
  16545. ctor: function(a) {
  16546. cc.ActionInterval.prototype.ctor.call(this);
  16547. this._innerAction = null;
  16548. a && this.initWithAction(a)
  16549. },
  16550. initWithAction: function(a) {
  16551. if (!a) throw "cc.RepeatForever.initWithAction(): action must be non null";
  16552. this._innerAction = a;
  16553. return !0
  16554. },
  16555. clone: function() {
  16556. var a = new cc.RepeatForever;
  16557. this._cloneDecoration(a);
  16558. a.initWithAction(this._innerAction.clone());
  16559. return a
  16560. },
  16561. startWithTarget: function(a) {
  16562. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16563. this._innerAction.startWithTarget(a)
  16564. },
  16565. step: function(a) {
  16566. var c = this._innerAction;
  16567. c.step(a);
  16568. c.isDone() && (c.startWithTarget(this.target), c.step(c.getElapsed() - c._duration))
  16569. },
  16570. isDone: function() {
  16571. return !1
  16572. },
  16573. reverse: function() {
  16574. var a = cc.repeatForever(this._innerAction.reverse());
  16575. this._cloneDecoration(a);
  16576. this._reverseEaseList(a);
  16577. return a
  16578. },
  16579. setInnerAction: function(a) {
  16580. this._innerAction != a && (this._innerAction = a)
  16581. },
  16582. getInnerAction: function() {
  16583. return this._innerAction
  16584. }
  16585. });
  16586. cc.repeatForever = function(a) {
  16587. return new cc.RepeatForever(a)
  16588. };
  16589. cc.RepeatForever.create = cc.repeatForever;
  16590. cc.Spawn = cc.ActionInterval.extend({
  16591. _one: null,
  16592. _two: null,
  16593. ctor: function(a) {
  16594. cc.ActionInterval.prototype.ctor.call(this);
  16595. this._two = this._one = null;
  16596. var c = a instanceof Array ? a : arguments,
  16597. d = c.length - 1;
  16598. 0 <= d && null == c[d] && cc.log("parameters should not be ending with null in Javascript");
  16599. if (0 <= d) {
  16600. for (var e = c[0], f = 1; f < d; f++) c[f] && (e = cc.Spawn._actionOneTwo(e, c[f]));
  16601. this.initWithTwoActions(e, c[d])
  16602. }
  16603. },
  16604. initWithTwoActions: function(a, c) {
  16605. if (!a || !c) throw "cc.Spawn.initWithTwoActions(): arguments must all be non null";
  16606. var d = !1,
  16607. e = a._duration,
  16608. f = c._duration;
  16609. 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);
  16610. return d
  16611. },
  16612. clone: function() {
  16613. var a = new cc.Spawn;
  16614. this._cloneDecoration(a);
  16615. a.initWithTwoActions(this._one.clone(), this._two.clone());
  16616. return a
  16617. },
  16618. startWithTarget: function(a) {
  16619. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16620. this._one.startWithTarget(a);
  16621. this._two.startWithTarget(a)
  16622. },
  16623. stop: function() {
  16624. this._one.stop();
  16625. this._two.stop();
  16626. cc.Action.prototype.stop.call(this)
  16627. },
  16628. update: function(a) {
  16629. a = this._computeEaseTime(a);
  16630. this._one && this._one.update(a);
  16631. this._two && this._two.update(a)
  16632. },
  16633. reverse: function() {
  16634. var a = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
  16635. this._cloneDecoration(a);
  16636. this._reverseEaseList(a);
  16637. return a
  16638. }
  16639. });
  16640. cc.spawn = function(a) {
  16641. var c = a instanceof Array ? a : arguments;
  16642. 0 < c.length && null == c[c.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  16643. for (var d = c[0], e = 1; e < c.length; e++) null != c[e] && (d = cc.Spawn._actionOneTwo(d, c[e]));
  16644. return d
  16645. };
  16646. cc.Spawn.create = cc.spawn;
  16647. cc.Spawn._actionOneTwo = function(a, c) {
  16648. var d = new cc.Spawn;
  16649. d.initWithTwoActions(a, c);
  16650. return d
  16651. };
  16652. cc.RotateTo = cc.ActionInterval.extend({
  16653. _dstAngleX: 0,
  16654. _startAngleX: 0,
  16655. _diffAngleX: 0,
  16656. _dstAngleY: 0,
  16657. _startAngleY: 0,
  16658. _diffAngleY: 0,
  16659. ctor: function(a, c, d) {
  16660. cc.ActionInterval.prototype.ctor.call(this);
  16661. void 0 !== c && this.initWithDuration(a, c, d)
  16662. },
  16663. initWithDuration: function(a, c, d) {
  16664. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._dstAngleX = c || 0, this._dstAngleY = d || this._dstAngleX, !0) : !1
  16665. },
  16666. clone: function() {
  16667. var a = new cc.RotateTo;
  16668. this._cloneDecoration(a);
  16669. a.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
  16670. return a
  16671. },
  16672. startWithTarget: function(a) {
  16673. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16674. var c = a.rotationX % 360,
  16675. d = this._dstAngleX - c;
  16676. 180 < d && (d -= 360); - 180 > d && (d += 360);
  16677. this._startAngleX = c;
  16678. this._diffAngleX = d;
  16679. this._startAngleY = a.rotationY % 360;
  16680. a = this._dstAngleY - this._startAngleY;
  16681. 180 < a && (a -= 360); - 180 > a && (a += 360);
  16682. this._diffAngleY = a
  16683. },
  16684. reverse: function() {
  16685. cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")
  16686. },
  16687. update: function(a) {
  16688. a = this._computeEaseTime(a);
  16689. this.target && (this.target.rotationX = this._startAngleX + this._diffAngleX * a, this.target.rotationY = this._startAngleY + this._diffAngleY * a)
  16690. }
  16691. });
  16692. cc.rotateTo = function(a, c, d) {
  16693. return new cc.RotateTo(a, c, d)
  16694. };
  16695. cc.RotateTo.create = cc.rotateTo;
  16696. cc.RotateBy = cc.ActionInterval.extend({
  16697. _angleX: 0,
  16698. _startAngleX: 0,
  16699. _angleY: 0,
  16700. _startAngleY: 0,
  16701. ctor: function(a, c, d) {
  16702. cc.ActionInterval.prototype.ctor.call(this);
  16703. void 0 !== c && this.initWithDuration(a, c, d)
  16704. },
  16705. initWithDuration: function(a, c, d) {
  16706. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._angleX = c || 0, this._angleY = d || this._angleX, !0) : !1
  16707. },
  16708. clone: function() {
  16709. var a = new cc.RotateBy;
  16710. this._cloneDecoration(a);
  16711. a.initWithDuration(this._duration, this._angleX, this._angleY);
  16712. return a
  16713. },
  16714. startWithTarget: function(a) {
  16715. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16716. this._startAngleX = a.rotationX;
  16717. this._startAngleY = a.rotationY
  16718. },
  16719. update: function(a) {
  16720. a = this._computeEaseTime(a);
  16721. this.target && (this.target.rotationX = this._startAngleX + this._angleX * a, this.target.rotationY = this._startAngleY + this._angleY * a)
  16722. },
  16723. reverse: function() {
  16724. var a = cc.rotateBy(this._duration, -this._angleX, -this._angleY);
  16725. this._cloneDecoration(a);
  16726. this._reverseEaseList(a);
  16727. return a
  16728. }
  16729. });
  16730. cc.rotateBy = function(a, c, d) {
  16731. return new cc.RotateBy(a, c, d)
  16732. };
  16733. cc.RotateBy.create = cc.rotateBy;
  16734. cc.MoveBy = cc.ActionInterval.extend({
  16735. _positionDelta: null,
  16736. _startPosition: null,
  16737. _previousPosition: null,
  16738. ctor: function(a, c, d) {
  16739. cc.ActionInterval.prototype.ctor.call(this);
  16740. this._positionDelta = cc.p(0, 0);
  16741. this._startPosition = cc.p(0, 0);
  16742. this._previousPosition = cc.p(0, 0);
  16743. void 0 !== c && this.initWithDuration(a, c, d)
  16744. },
  16745. initWithDuration: function(a, c, d) {
  16746. 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
  16747. },
  16748. clone: function() {
  16749. var a = new cc.MoveBy;
  16750. this._cloneDecoration(a);
  16751. a.initWithDuration(this._duration, this._positionDelta);
  16752. return a
  16753. },
  16754. startWithTarget: function(a) {
  16755. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16756. var c = a.getPositionX();
  16757. a = a.getPositionY();
  16758. this._previousPosition.x = c;
  16759. this._previousPosition.y = a;
  16760. this._startPosition.x = c;
  16761. this._startPosition.y = a
  16762. },
  16763. update: function(a) {
  16764. a = this._computeEaseTime(a);
  16765. if (this.target) {
  16766. var c = this._positionDelta.x * a;
  16767. a *= this._positionDelta.y;
  16768. var d = this._startPosition;
  16769. if (cc.ENABLE_STACKABLE_ACTIONS) {
  16770. var e = this.target.getPositionX(),
  16771. f = this.target.getPositionY(),
  16772. g = this._previousPosition;
  16773. d.x = d.x + e - g.x;
  16774. d.y = d.y + f - g.y;
  16775. c += d.x;
  16776. a += d.y;
  16777. g.x = c;
  16778. g.y = a;
  16779. this.target.setPosition(c, a)
  16780. } else this.target.setPosition(d.x + c, d.y + a)
  16781. }
  16782. },
  16783. reverse: function() {
  16784. var a = cc.moveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
  16785. this._cloneDecoration(a);
  16786. this._reverseEaseList(a);
  16787. return a
  16788. }
  16789. });
  16790. cc.moveBy = function(a, c, d) {
  16791. return new cc.MoveBy(a, c, d)
  16792. };
  16793. cc.MoveBy.create = cc.moveBy;
  16794. cc.MoveTo = cc.MoveBy.extend({
  16795. _endPosition: null,
  16796. ctor: function(a, c, d) {
  16797. cc.MoveBy.prototype.ctor.call(this);
  16798. this._endPosition = cc.p(0, 0);
  16799. void 0 !== c && this.initWithDuration(a, c, d)
  16800. },
  16801. initWithDuration: function(a, c, d) {
  16802. 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
  16803. },
  16804. clone: function() {
  16805. var a = new cc.MoveTo;
  16806. this._cloneDecoration(a);
  16807. a.initWithDuration(this._duration, this._endPosition);
  16808. return a
  16809. },
  16810. startWithTarget: function(a) {
  16811. cc.MoveBy.prototype.startWithTarget.call(this, a);
  16812. this._positionDelta.x = this._endPosition.x - a.getPositionX();
  16813. this._positionDelta.y = this._endPosition.y - a.getPositionY()
  16814. }
  16815. });
  16816. cc.moveTo = function(a, c, d) {
  16817. return new cc.MoveTo(a, c, d)
  16818. };
  16819. cc.MoveTo.create = cc.moveTo;
  16820. cc.SkewTo = cc.ActionInterval.extend({
  16821. _skewX: 0,
  16822. _skewY: 0,
  16823. _startSkewX: 0,
  16824. _startSkewY: 0,
  16825. _endSkewX: 0,
  16826. _endSkewY: 0,
  16827. _deltaX: 0,
  16828. _deltaY: 0,
  16829. ctor: function(a, c, d) {
  16830. cc.ActionInterval.prototype.ctor.call(this);
  16831. void 0 !== d && this.initWithDuration(a, c, d)
  16832. },
  16833. initWithDuration: function(a, c, d) {
  16834. var e = !1;
  16835. cc.ActionInterval.prototype.initWithDuration.call(this, a) && (this._endSkewX = c, this._endSkewY = d, e = !0);
  16836. return e
  16837. },
  16838. clone: function() {
  16839. var a = new cc.SkewTo;
  16840. this._cloneDecoration(a);
  16841. a.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
  16842. return a
  16843. },
  16844. startWithTarget: function(a) {
  16845. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16846. this._startSkewX = a.skewX % 180;
  16847. this._deltaX = this._endSkewX - this._startSkewX;
  16848. 180 < this._deltaX && (this._deltaX -= 360); - 180 > this._deltaX && (this._deltaX += 360);
  16849. this._startSkewY = a.skewY % 360;
  16850. this._deltaY = this._endSkewY - this._startSkewY;
  16851. 180 < this._deltaY && (this._deltaY -= 360); - 180 > this._deltaY && (this._deltaY += 360)
  16852. },
  16853. update: function(a) {
  16854. a = this._computeEaseTime(a);
  16855. this.target.skewX = this._startSkewX + this._deltaX * a;
  16856. this.target.skewY = this._startSkewY + this._deltaY * a
  16857. }
  16858. });
  16859. cc.skewTo = function(a, c, d) {
  16860. return new cc.SkewTo(a, c, d)
  16861. };
  16862. cc.SkewTo.create = cc.skewTo;
  16863. cc.SkewBy = cc.SkewTo.extend({
  16864. ctor: function(a, c, d) {
  16865. cc.SkewTo.prototype.ctor.call(this);
  16866. void 0 !== d && this.initWithDuration(a, c, d)
  16867. },
  16868. initWithDuration: function(a, c, d) {
  16869. var e = !1;
  16870. cc.SkewTo.prototype.initWithDuration.call(this, a, c, d) && (this._skewX = c, this._skewY = d, e = !0);
  16871. return e
  16872. },
  16873. clone: function() {
  16874. var a = new cc.SkewBy;
  16875. this._cloneDecoration(a);
  16876. a.initWithDuration(this._duration, this._skewX, this._skewY);
  16877. return a
  16878. },
  16879. startWithTarget: function(a) {
  16880. cc.SkewTo.prototype.startWithTarget.call(this, a);
  16881. this._deltaX = this._skewX;
  16882. this._deltaY = this._skewY;
  16883. this._endSkewX = this._startSkewX + this._deltaX;
  16884. this._endSkewY = this._startSkewY + this._deltaY
  16885. },
  16886. reverse: function() {
  16887. var a = cc.skewBy(this._duration, -this._skewX, -this._skewY);
  16888. this._cloneDecoration(a);
  16889. this._reverseEaseList(a);
  16890. return a
  16891. }
  16892. });
  16893. cc.skewBy = function(a, c, d) {
  16894. return new cc.SkewBy(a, c, d)
  16895. };
  16896. cc.SkewBy.create = cc.skewBy;
  16897. cc.JumpBy = cc.ActionInterval.extend({
  16898. _startPosition: null,
  16899. _delta: null,
  16900. _height: 0,
  16901. _jumps: 0,
  16902. _previousPosition: null,
  16903. ctor: function(a, c, d, e, f) {
  16904. cc.ActionInterval.prototype.ctor.call(this);
  16905. this._startPosition = cc.p(0, 0);
  16906. this._previousPosition = cc.p(0, 0);
  16907. this._delta = cc.p(0, 0);
  16908. void 0 !== e && this.initWithDuration(a, c, d, e, f)
  16909. },
  16910. initWithDuration: function(a, c, d, e, f) {
  16911. 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
  16912. },
  16913. clone: function() {
  16914. var a = new cc.JumpBy;
  16915. this._cloneDecoration(a);
  16916. a.initWithDuration(this._duration, this._delta, this._height, this._jumps);
  16917. return a
  16918. },
  16919. startWithTarget: function(a) {
  16920. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16921. var c = a.getPositionX();
  16922. a = a.getPositionY();
  16923. this._previousPosition.x = c;
  16924. this._previousPosition.y = a;
  16925. this._startPosition.x = c;
  16926. this._startPosition.y = a
  16927. },
  16928. update: function(a) {
  16929. a = this._computeEaseTime(a);
  16930. if (this.target) {
  16931. var c = a * this._jumps % 1,
  16932. c = 4 * this._height * c * (1 - c),
  16933. c = c + this._delta.y * a;
  16934. a *= this._delta.x;
  16935. var d = this._startPosition;
  16936. if (cc.ENABLE_STACKABLE_ACTIONS) {
  16937. var e = this.target.getPositionX(),
  16938. f = this.target.getPositionY(),
  16939. g = this._previousPosition;
  16940. d.x = d.x + e - g.x;
  16941. d.y = d.y + f - g.y;
  16942. a += d.x;
  16943. c += d.y;
  16944. g.x = a;
  16945. g.y = c;
  16946. this.target.setPosition(a, c)
  16947. } else this.target.setPosition(d.x + a, d.y + c)
  16948. }
  16949. },
  16950. reverse: function() {
  16951. var a = cc.jumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
  16952. this._cloneDecoration(a);
  16953. this._reverseEaseList(a);
  16954. return a
  16955. }
  16956. });
  16957. cc.jumpBy = function(a, c, d, e, f) {
  16958. return new cc.JumpBy(a, c, d, e, f)
  16959. };
  16960. cc.JumpBy.create = cc.jumpBy;
  16961. cc.JumpTo = cc.JumpBy.extend({
  16962. _endPosition: null,
  16963. ctor: function(a, c, d, e, f) {
  16964. cc.JumpBy.prototype.ctor.call(this);
  16965. this._endPosition = cc.p(0, 0);
  16966. void 0 !== e && this.initWithDuration(a, c, d, e, f)
  16967. },
  16968. initWithDuration: function(a, c, d, e, f) {
  16969. 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
  16970. },
  16971. startWithTarget: function(a) {
  16972. cc.JumpBy.prototype.startWithTarget.call(this, a);
  16973. this._delta.x = this._endPosition.x - this._startPosition.x;
  16974. this._delta.y = this._endPosition.y - this._startPosition.y
  16975. },
  16976. clone: function() {
  16977. var a = new cc.JumpTo;
  16978. this._cloneDecoration(a);
  16979. a.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
  16980. return a
  16981. }
  16982. });
  16983. cc.jumpTo = function(a, c, d, e, f) {
  16984. return new cc.JumpTo(a, c, d, e, f)
  16985. };
  16986. cc.JumpTo.create = cc.jumpTo;
  16987. cc.bezierAt = function(a, c, d, e, f) {
  16988. 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
  16989. };
  16990. cc.BezierBy = cc.ActionInterval.extend({
  16991. _config: null,
  16992. _startPosition: null,
  16993. _previousPosition: null,
  16994. ctor: function(a, c) {
  16995. cc.ActionInterval.prototype.ctor.call(this);
  16996. this._config = [];
  16997. this._startPosition = cc.p(0, 0);
  16998. this._previousPosition = cc.p(0, 0);
  16999. c && this.initWithDuration(a, c)
  17000. },
  17001. initWithDuration: function(a, c) {
  17002. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._config = c, !0) : !1
  17003. },
  17004. clone: function() {
  17005. var a = new cc.BezierBy;
  17006. this._cloneDecoration(a);
  17007. for (var c = [], d = 0; d < this._config.length; d++) {
  17008. var e = this._config[d];
  17009. c.push(cc.p(e.x, e.y))
  17010. }
  17011. a.initWithDuration(this._duration, c);
  17012. return a
  17013. },
  17014. startWithTarget: function(a) {
  17015. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17016. var c = a.getPositionX();
  17017. a = a.getPositionY();
  17018. this._previousPosition.x = c;
  17019. this._previousPosition.y = a;
  17020. this._startPosition.x = c;
  17021. this._startPosition.y = a
  17022. },
  17023. update: function(a) {
  17024. a = this._computeEaseTime(a);
  17025. if (this.target) {
  17026. var c = this._config,
  17027. d = c[0].y,
  17028. e = c[1].y,
  17029. f = c[2].y,
  17030. c = cc.bezierAt(0, c[0].x, c[1].x, c[2].x, a);
  17031. a = cc.bezierAt(0, d, e, f, a);
  17032. d = this._startPosition;
  17033. if (cc.ENABLE_STACKABLE_ACTIONS) {
  17034. var e = this.target.getPositionX(),
  17035. f = this.target.getPositionY(),
  17036. g = this._previousPosition;
  17037. d.x = d.x + e - g.x;
  17038. d.y = d.y + f - g.y;
  17039. c += d.x;
  17040. a += d.y;
  17041. g.x = c;
  17042. g.y = a;
  17043. this.target.setPosition(c, a)
  17044. } else this.target.setPosition(d.x + c, d.y + a)
  17045. }
  17046. },
  17047. reverse: function() {
  17048. var a = this._config,
  17049. a = [cc.pAdd(a[1], cc.pNeg(a[2])), cc.pAdd(a[0], cc.pNeg(a[2])), cc.pNeg(a[2])],
  17050. a = cc.bezierBy(this._duration, a);
  17051. this._cloneDecoration(a);
  17052. this._reverseEaseList(a);
  17053. return a
  17054. }
  17055. });
  17056. cc.bezierBy = function(a, c) {
  17057. return new cc.BezierBy(a, c)
  17058. };
  17059. cc.BezierBy.create = cc.bezierBy;
  17060. cc.BezierTo = cc.BezierBy.extend({
  17061. _toConfig: null,
  17062. ctor: function(a, c) {
  17063. cc.BezierBy.prototype.ctor.call(this);
  17064. this._toConfig = [];
  17065. c && this.initWithDuration(a, c)
  17066. },
  17067. initWithDuration: function(a, c) {
  17068. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toConfig = c, !0) : !1
  17069. },
  17070. clone: function() {
  17071. var a = new cc.BezierTo;
  17072. this._cloneDecoration(a);
  17073. a.initWithDuration(this._duration, this._toConfig);
  17074. return a
  17075. },
  17076. startWithTarget: function(a) {
  17077. cc.BezierBy.prototype.startWithTarget.call(this, a);
  17078. a = this._startPosition;
  17079. var c = this._toConfig,
  17080. d = this._config;
  17081. d[0] = cc.pSub(c[0], a);
  17082. d[1] = cc.pSub(c[1], a);
  17083. d[2] = cc.pSub(c[2], a)
  17084. }
  17085. });
  17086. cc.bezierTo = function(a, c) {
  17087. return new cc.BezierTo(a, c)
  17088. };
  17089. cc.BezierTo.create = cc.bezierTo;
  17090. cc.ScaleTo = cc.ActionInterval.extend({
  17091. _scaleX: 1,
  17092. _scaleY: 1,
  17093. _startScaleX: 1,
  17094. _startScaleY: 1,
  17095. _endScaleX: 0,
  17096. _endScaleY: 0,
  17097. _deltaX: 0,
  17098. _deltaY: 0,
  17099. ctor: function(a, c, d) {
  17100. cc.ActionInterval.prototype.ctor.call(this);
  17101. void 0 !== c && this.initWithDuration(a, c, d)
  17102. },
  17103. initWithDuration: function(a, c, d) {
  17104. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._endScaleX = c, this._endScaleY = null != d ? d : c, !0) : !1
  17105. },
  17106. clone: function() {
  17107. var a = new cc.ScaleTo;
  17108. this._cloneDecoration(a);
  17109. a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
  17110. return a
  17111. },
  17112. startWithTarget: function(a) {
  17113. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17114. this._startScaleX = a.scaleX;
  17115. this._startScaleY = a.scaleY;
  17116. this._deltaX = this._endScaleX - this._startScaleX;
  17117. this._deltaY = this._endScaleY - this._startScaleY
  17118. },
  17119. update: function(a) {
  17120. a = this._computeEaseTime(a);
  17121. this.target && (this.target.scaleX = this._startScaleX + this._deltaX * a, this.target.scaleY = this._startScaleY + this._deltaY * a)
  17122. }
  17123. });
  17124. cc.scaleTo = function(a, c, d) {
  17125. return new cc.ScaleTo(a, c, d)
  17126. };
  17127. cc.ScaleTo.create = cc.scaleTo;
  17128. cc.ScaleBy = cc.ScaleTo.extend({
  17129. startWithTarget: function(a) {
  17130. cc.ScaleTo.prototype.startWithTarget.call(this, a);
  17131. this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
  17132. this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY
  17133. },
  17134. reverse: function() {
  17135. var a = cc.scaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
  17136. this._cloneDecoration(a);
  17137. this._reverseEaseList(a);
  17138. return a
  17139. },
  17140. clone: function() {
  17141. var a = new cc.ScaleBy;
  17142. this._cloneDecoration(a);
  17143. a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
  17144. return a
  17145. }
  17146. });
  17147. cc.scaleBy = function(a, c, d) {
  17148. return new cc.ScaleBy(a, c, d)
  17149. };
  17150. cc.ScaleBy.create = cc.scaleBy;
  17151. cc.Blink = cc.ActionInterval.extend({
  17152. _times: 0,
  17153. _originalState: !1,
  17154. ctor: function(a, c) {
  17155. cc.ActionInterval.prototype.ctor.call(this);
  17156. void 0 !== c && this.initWithDuration(a, c)
  17157. },
  17158. initWithDuration: function(a, c) {
  17159. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._times = c, !0) : !1
  17160. },
  17161. clone: function() {
  17162. var a = new cc.Blink;
  17163. this._cloneDecoration(a);
  17164. a.initWithDuration(this._duration, this._times);
  17165. return a
  17166. },
  17167. update: function(a) {
  17168. a = this._computeEaseTime(a);
  17169. if (this.target && !this.isDone()) {
  17170. var c = 1 / this._times;
  17171. this.target.visible = a % c > c / 2
  17172. }
  17173. },
  17174. startWithTarget: function(a) {
  17175. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17176. this._originalState = a.visible
  17177. },
  17178. stop: function() {
  17179. this.target.visible = this._originalState;
  17180. cc.ActionInterval.prototype.stop.call(this)
  17181. },
  17182. reverse: function() {
  17183. var a = cc.blink(this._duration, this._times);
  17184. this._cloneDecoration(a);
  17185. this._reverseEaseList(a);
  17186. return a
  17187. }
  17188. });
  17189. cc.blink = function(a, c) {
  17190. return new cc.Blink(a, c)
  17191. };
  17192. cc.Blink.create = cc.blink;
  17193. cc.FadeTo = cc.ActionInterval.extend({
  17194. _toOpacity: 0,
  17195. _fromOpacity: 0,
  17196. ctor: function(a, c) {
  17197. cc.ActionInterval.prototype.ctor.call(this);
  17198. void 0 !== c && this.initWithDuration(a, c)
  17199. },
  17200. initWithDuration: function(a, c) {
  17201. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toOpacity = c, !0) : !1
  17202. },
  17203. clone: function() {
  17204. var a = new cc.FadeTo;
  17205. this._cloneDecoration(a);
  17206. a.initWithDuration(this._duration, this._toOpacity);
  17207. return a
  17208. },
  17209. update: function(a) {
  17210. a = this._computeEaseTime(a);
  17211. var c = void 0 !== this._fromOpacity ? this._fromOpacity : 255;
  17212. this.target.opacity = c + (this._toOpacity - c) * a
  17213. },
  17214. startWithTarget: function(a) {
  17215. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17216. this._fromOpacity = a.opacity
  17217. }
  17218. });
  17219. cc.fadeTo = function(a, c) {
  17220. return new cc.FadeTo(a, c)
  17221. };
  17222. cc.FadeTo.create = cc.fadeTo;
  17223. cc.FadeIn = cc.FadeTo.extend({
  17224. _reverseAction: null,
  17225. ctor: function(a) {
  17226. cc.FadeTo.prototype.ctor.call(this);
  17227. a && this.initWithDuration(a, 255)
  17228. },
  17229. reverse: function() {
  17230. var a = new cc.FadeOut;
  17231. a.initWithDuration(this._duration, 0);
  17232. this._cloneDecoration(a);
  17233. this._reverseEaseList(a);
  17234. return a
  17235. },
  17236. clone: function() {
  17237. var a = new cc.FadeIn;
  17238. this._cloneDecoration(a);
  17239. a.initWithDuration(this._duration, this._toOpacity);
  17240. return a
  17241. },
  17242. startWithTarget: function(a) {
  17243. this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity);
  17244. cc.FadeTo.prototype.startWithTarget.call(this, a)
  17245. }
  17246. });
  17247. cc.fadeIn = function(a) {
  17248. return new cc.FadeIn(a)
  17249. };
  17250. cc.FadeIn.create = cc.fadeIn;
  17251. cc.FadeOut = cc.FadeTo.extend({
  17252. ctor: function(a) {
  17253. cc.FadeTo.prototype.ctor.call(this);
  17254. a && this.initWithDuration(a, 0)
  17255. },
  17256. reverse: function() {
  17257. var a = new cc.FadeIn;
  17258. a._reverseAction = this;
  17259. a.initWithDuration(this._duration, 255);
  17260. this._cloneDecoration(a);
  17261. this._reverseEaseList(a);
  17262. return a
  17263. },
  17264. clone: function() {
  17265. var a = new cc.FadeOut;
  17266. this._cloneDecoration(a);
  17267. a.initWithDuration(this._duration, this._toOpacity);
  17268. return a
  17269. }
  17270. });
  17271. cc.fadeOut = function(a) {
  17272. return new cc.FadeOut(a)
  17273. };
  17274. cc.FadeOut.create = cc.fadeOut;
  17275. cc.TintTo = cc.ActionInterval.extend({
  17276. _to: null,
  17277. _from: null,
  17278. ctor: function(a, c, d, e) {
  17279. cc.ActionInterval.prototype.ctor.call(this);
  17280. this._to = cc.color(0, 0, 0);
  17281. this._from = cc.color(0, 0, 0);
  17282. void 0 !== e && this.initWithDuration(a, c, d, e)
  17283. },
  17284. initWithDuration: function(a, c, d, e) {
  17285. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = cc.color(c, d, e), !0) : !1
  17286. },
  17287. clone: function() {
  17288. var a = new cc.TintTo;
  17289. this._cloneDecoration(a);
  17290. var c = this._to;
  17291. a.initWithDuration(this._duration, c.r, c.g, c.b);
  17292. return a
  17293. },
  17294. startWithTarget: function(a) {
  17295. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17296. this._from = this.target.color
  17297. },
  17298. update: function(a) {
  17299. a = this._computeEaseTime(a);
  17300. var c = this._from,
  17301. d = this._to;
  17302. 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))
  17303. }
  17304. });
  17305. cc.tintTo = function(a, c, d, e) {
  17306. return new cc.TintTo(a, c, d, e)
  17307. };
  17308. cc.TintTo.create = cc.tintTo;
  17309. cc.TintBy = cc.ActionInterval.extend({
  17310. _deltaR: 0,
  17311. _deltaG: 0,
  17312. _deltaB: 0,
  17313. _fromR: 0,
  17314. _fromG: 0,
  17315. _fromB: 0,
  17316. ctor: function(a, c, d, e) {
  17317. cc.ActionInterval.prototype.ctor.call(this);
  17318. void 0 !== e && this.initWithDuration(a, c, d, e)
  17319. },
  17320. initWithDuration: function(a, c, d, e) {
  17321. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._deltaR = c, this._deltaG = d, this._deltaB = e, !0) : !1
  17322. },
  17323. clone: function() {
  17324. var a = new cc.TintBy;
  17325. this._cloneDecoration(a);
  17326. a.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
  17327. return a
  17328. },
  17329. startWithTarget: function(a) {
  17330. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17331. a = a.color;
  17332. this._fromR = a.r;
  17333. this._fromG = a.g;
  17334. this._fromB = a.b
  17335. },
  17336. update: function(a) {
  17337. a = this._computeEaseTime(a);
  17338. this.target.color = cc.color(this._fromR + this._deltaR * a, this._fromG + this._deltaG * a, this._fromB + this._deltaB * a)
  17339. },
  17340. reverse: function() {
  17341. var a = cc.tintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
  17342. this._cloneDecoration(a);
  17343. this._reverseEaseList(a);
  17344. return a
  17345. }
  17346. });
  17347. cc.tintBy = function(a, c, d, e) {
  17348. return new cc.TintBy(a, c, d, e)
  17349. };
  17350. cc.TintBy.create = cc.tintBy;
  17351. cc.DelayTime = cc.ActionInterval.extend({
  17352. update: function(a) {},
  17353. reverse: function() {
  17354. var a = cc.delayTime(this._duration);
  17355. this._cloneDecoration(a);
  17356. this._reverseEaseList(a);
  17357. return a
  17358. },
  17359. clone: function() {
  17360. var a = new cc.DelayTime;
  17361. this._cloneDecoration(a);
  17362. a.initWithDuration(this._duration);
  17363. return a
  17364. }
  17365. });
  17366. cc.delayTime = function(a) {
  17367. return new cc.DelayTime(a)
  17368. };
  17369. cc.DelayTime.create = cc.delayTime;
  17370. cc.ReverseTime = cc.ActionInterval.extend({
  17371. _other: null,
  17372. ctor: function(a) {
  17373. cc.ActionInterval.prototype.ctor.call(this);
  17374. this._other = null;
  17375. a && this.initWithAction(a)
  17376. },
  17377. initWithAction: function(a) {
  17378. if (!a) throw "cc.ReverseTime.initWithAction(): action must be non null";
  17379. if (a == this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
  17380. return cc.ActionInterval.prototype.initWithDuration.call(this, a._duration) ? (this._other = a, !0) : !1
  17381. },
  17382. clone: function() {
  17383. var a = new cc.ReverseTime;
  17384. this._cloneDecoration(a);
  17385. a.initWithAction(this._other.clone());
  17386. return a
  17387. },
  17388. startWithTarget: function(a) {
  17389. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17390. this._other.startWithTarget(a)
  17391. },
  17392. update: function(a) {
  17393. a = this._computeEaseTime(a);
  17394. this._other && this._other.update(1 - a)
  17395. },
  17396. reverse: function() {
  17397. return this._other.clone()
  17398. },
  17399. stop: function() {
  17400. this._other.stop();
  17401. cc.Action.prototype.stop.call(this)
  17402. }
  17403. });
  17404. cc.reverseTime = function(a) {
  17405. return new cc.ReverseTime(a)
  17406. };
  17407. cc.ReverseTime.create = cc.reverseTime;
  17408. cc.Animate = cc.ActionInterval.extend({
  17409. _animation: null,
  17410. _nextFrame: 0,
  17411. _origFrame: null,
  17412. _executedLoops: 0,
  17413. _splitTimes: null,
  17414. ctor: function(a) {
  17415. cc.ActionInterval.prototype.ctor.call(this);
  17416. this._splitTimes = [];
  17417. a && this.initWithAnimation(a)
  17418. },
  17419. getAnimation: function() {
  17420. return this._animation
  17421. },
  17422. setAnimation: function(a) {
  17423. this._animation = a
  17424. },
  17425. initWithAnimation: function(a) {
  17426. if (!a) throw "cc.Animate.initWithAnimation(): animation must be non-NULL";
  17427. var c = a.getDuration();
  17428. if (this.initWithDuration(c * a.getLoops())) {
  17429. this._nextFrame = 0;
  17430. this.setAnimation(a);
  17431. this._origFrame = null;
  17432. this._executedLoops = 0;
  17433. var d = this._splitTimes,
  17434. e = d.length = 0,
  17435. f = c / a.getTotalDelayUnits();
  17436. a = a.getFrames();
  17437. cc.arrayVerifyType(a, cc.AnimationFrame);
  17438. for (var g = 0; g < a.length; g++) {
  17439. var h = e * f / c,
  17440. e = e + a[g].getDelayUnits();
  17441. d.push(h)
  17442. }
  17443. return !0
  17444. }
  17445. return !1
  17446. },
  17447. clone: function() {
  17448. var a = new cc.Animate;
  17449. this._cloneDecoration(a);
  17450. a.initWithAnimation(this._animation.clone());
  17451. return a
  17452. },
  17453. startWithTarget: function(a) {
  17454. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17455. this._animation.getRestoreOriginalFrame() && (this._origFrame = a.displayFrame());
  17456. this._executedLoops = this._nextFrame = 0
  17457. },
  17458. update: function(a) {
  17459. a = this._computeEaseTime(a);
  17460. 1 > a && (a *= this._animation.getLoops(), (0 | a) > this._executedLoops && (this._nextFrame = 0, this._executedLoops++), a %= 1);
  17461. for (var c = this._animation.getFrames(), d = c.length, e = this._splitTimes, f = this._nextFrame; f < d; f++)
  17462. if (e[f] <= a) this.target.setSpriteFrame(c[f].getSpriteFrame()), this._nextFrame = f + 1;
  17463. else break
  17464. },
  17465. reverse: function() {
  17466. var a = this._animation,
  17467. c = a.getFrames(),
  17468. d = [];
  17469. cc.arrayVerifyType(c, cc.AnimationFrame);
  17470. if (0 < c.length)
  17471. for (var e = c.length - 1; 0 <= e; e--) {
  17472. var f = c[e];
  17473. if (!f) break;
  17474. d.push(f.clone())
  17475. }
  17476. c = cc.Animation.create(d, a.getDelayPerUnit(), a.getLoops());
  17477. c.setRestoreOriginalFrame(a.getRestoreOriginalFrame());
  17478. a = cc.animate(c);
  17479. this._cloneDecoration(a);
  17480. this._reverseEaseList(a);
  17481. return a
  17482. },
  17483. stop: function() {
  17484. this._animation.getRestoreOriginalFrame() && this.target && this.target.setSpriteFrame(this._origFrame);
  17485. cc.Action.prototype.stop.call(this)
  17486. }
  17487. });
  17488. cc.animate = function(a) {
  17489. return new cc.Animate(a)
  17490. };
  17491. cc.Animate.create = cc.animate;
  17492. cc.TargetedAction = cc.ActionInterval.extend({
  17493. _action: null,
  17494. _forcedTarget: null,
  17495. ctor: function(a, c) {
  17496. cc.ActionInterval.prototype.ctor.call(this);
  17497. c && this.initWithTarget(a, c)
  17498. },
  17499. initWithTarget: function(a, c) {
  17500. return this.initWithDuration(c._duration) ? (this._forcedTarget = a, this._action = c, !0) : !1
  17501. },
  17502. clone: function() {
  17503. var a = new cc.TargetedAction;
  17504. this._cloneDecoration(a);
  17505. a.initWithTarget(this._forcedTarget, this._action.clone());
  17506. return a
  17507. },
  17508. startWithTarget: function(a) {
  17509. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17510. this._action.startWithTarget(this._forcedTarget)
  17511. },
  17512. stop: function() {
  17513. this._action.stop()
  17514. },
  17515. update: function(a) {
  17516. a = this._computeEaseTime(a);
  17517. this._action.update(a)
  17518. },
  17519. getForcedTarget: function() {
  17520. return this._forcedTarget
  17521. },
  17522. setForcedTarget: function(a) {
  17523. this._forcedTarget != a && (this._forcedTarget = a)
  17524. }
  17525. });
  17526. cc.targetedAction = function(a, c) {
  17527. return new cc.TargetedAction(a, c)
  17528. };
  17529. cc.TargetedAction.create = cc.targetedAction;
  17530. cc.ActionInstant = cc.FiniteTimeAction.extend({
  17531. isDone: function() {
  17532. return !0
  17533. },
  17534. step: function(a) {
  17535. this.update(1)
  17536. },
  17537. update: function(a) {},
  17538. reverse: function() {
  17539. return this.clone()
  17540. },
  17541. clone: function() {
  17542. return new cc.ActionInstant
  17543. }
  17544. });
  17545. cc.Show = cc.ActionInstant.extend({
  17546. update: function(a) {
  17547. this.target.visible = !0
  17548. },
  17549. reverse: function() {
  17550. return cc.Hide.create()
  17551. },
  17552. clone: function() {
  17553. return new cc.Show
  17554. }
  17555. });
  17556. cc.show = function() {
  17557. return new cc.Show
  17558. };
  17559. cc.Show.create = cc.show;
  17560. cc.Hide = cc.ActionInstant.extend({
  17561. update: function(a) {
  17562. this.target.visible = !1
  17563. },
  17564. reverse: function() {
  17565. return cc.Show.create()
  17566. },
  17567. clone: function() {
  17568. return new cc.Hide
  17569. }
  17570. });
  17571. cc.hide = function() {
  17572. return new cc.Hide
  17573. };
  17574. cc.Hide.create = cc.hide;
  17575. cc.ToggleVisibility = cc.ActionInstant.extend({
  17576. update: function(a) {
  17577. this.target.visible = !this.target.visible
  17578. },
  17579. reverse: function() {
  17580. return new cc.ToggleVisibility
  17581. },
  17582. clone: function() {
  17583. return new cc.ToggleVisibility
  17584. }
  17585. });
  17586. cc.toggleVisibility = function() {
  17587. return new cc.ToggleVisibility
  17588. };
  17589. cc.ToggleVisibility.create = cc.toggleVisibility;
  17590. cc.RemoveSelf = cc.ActionInstant.extend({
  17591. _isNeedCleanUp: !0,
  17592. ctor: function(a) {
  17593. cc.FiniteTimeAction.prototype.ctor.call(this);
  17594. void 0 !== a && this.init(a)
  17595. },
  17596. update: function(a) {
  17597. this.target.removeFromParent(this._isNeedCleanUp)
  17598. },
  17599. init: function(a) {
  17600. this._isNeedCleanUp = a;
  17601. return !0
  17602. },
  17603. reverse: function() {
  17604. return new cc.RemoveSelf(this._isNeedCleanUp)
  17605. },
  17606. clone: function() {
  17607. return new cc.RemoveSelf(this._isNeedCleanUp)
  17608. }
  17609. });
  17610. cc.removeSelf = function(a) {
  17611. return new cc.RemoveSelf(a)
  17612. };
  17613. cc.RemoveSelf.create = cc.removeSelf;
  17614. cc.FlipX = cc.ActionInstant.extend({
  17615. _flippedX: !1,
  17616. ctor: function(a) {
  17617. cc.FiniteTimeAction.prototype.ctor.call(this);
  17618. this._flippedX = !1;
  17619. void 0 !== a && this.initWithFlipX(a)
  17620. },
  17621. initWithFlipX: function(a) {
  17622. this._flippedX = a;
  17623. return !0
  17624. },
  17625. update: function(a) {
  17626. this.target.flippedX = this._flippedX
  17627. },
  17628. reverse: function() {
  17629. return cc.FlipX.create(!this._flippedX)
  17630. },
  17631. clone: function() {
  17632. var a = new cc.FlipX;
  17633. a.initWithFlipX(this._flippedX);
  17634. return a
  17635. }
  17636. });
  17637. cc.flipX = function(a) {
  17638. return new cc.FlipX(a)
  17639. };
  17640. cc.FlipX.create = cc.flipX;
  17641. cc.FlipY = cc.ActionInstant.extend({
  17642. _flippedY: !1,
  17643. ctor: function(a) {
  17644. cc.FiniteTimeAction.prototype.ctor.call(this);
  17645. this._flippedY = !1;
  17646. void 0 !== a && this.initWithFlipY(a)
  17647. },
  17648. initWithFlipY: function(a) {
  17649. this._flippedY = a;
  17650. return !0
  17651. },
  17652. update: function(a) {
  17653. this.target.flippedY = this._flippedY
  17654. },
  17655. reverse: function() {
  17656. return cc.FlipY.create(!this._flippedY)
  17657. },
  17658. clone: function() {
  17659. var a = new cc.FlipY;
  17660. a.initWithFlipY(this._flippedY);
  17661. return a
  17662. }
  17663. });
  17664. cc.flipY = function(a) {
  17665. return new cc.FlipY(a)
  17666. };
  17667. cc.FlipY.create = cc.flipY;
  17668. cc.Place = cc.ActionInstant.extend({
  17669. _x: 0,
  17670. _y: 0,
  17671. ctor: function(a, c) {
  17672. cc.FiniteTimeAction.prototype.ctor.call(this);
  17673. this._y = this._x = 0;
  17674. void 0 !== a && (void 0 !== a.x && (c = a.y, a = a.x), this.initWithPosition(a, c))
  17675. },
  17676. initWithPosition: function(a, c) {
  17677. this._x = a;
  17678. this._y = c;
  17679. return !0
  17680. },
  17681. update: function(a) {
  17682. this.target.setPosition(this._x, this._y)
  17683. },
  17684. clone: function() {
  17685. var a = new cc.Place;
  17686. a.initWithPosition(this._x, this._y);
  17687. return a
  17688. }
  17689. });
  17690. cc.place = function(a, c) {
  17691. return new cc.Place(a, c)
  17692. };
  17693. cc.Place.create = cc.place;
  17694. cc.CallFunc = cc.ActionInstant.extend({
  17695. _selectorTarget: null,
  17696. _callFunc: null,
  17697. _function: null,
  17698. _data: null,
  17699. ctor: function(a, c, d) {
  17700. cc.FiniteTimeAction.prototype.ctor.call(this);
  17701. void 0 !== a && (void 0 === c ? this.initWithFunction(a) : this.initWithFunction(a, c, d))
  17702. },
  17703. initWithFunction: function(a, c, d) {
  17704. c ? (this._data = d, this._callFunc = a, this._selectorTarget = c) : a && (this._function = a);
  17705. return !0
  17706. },
  17707. execute: function() {
  17708. null != this._callFunc ? this._callFunc.call(this._selectorTarget, this.target, this._data) : this._function && this._function.call(null, this.target)
  17709. },
  17710. update: function(a) {
  17711. this.execute()
  17712. },
  17713. getTargetCallback: function() {
  17714. return this._selectorTarget
  17715. },
  17716. setTargetCallback: function(a) {
  17717. a != this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), this._selectorTarget = a)
  17718. },
  17719. clone: function() {
  17720. var a = new cc.CallFunc;
  17721. this._selectorTarget ? a.initWithFunction(this._callFunc, this._selectorTarget, this._data) : this._function && a.initWithFunction(this._function);
  17722. return a
  17723. }
  17724. });
  17725. cc.callFunc = function(a, c, d) {
  17726. return new cc.CallFunc(a, c, d)
  17727. };
  17728. cc.CallFunc.create = cc.callFunc;
  17729. cc.ActionCamera = cc.ActionInterval.extend({
  17730. _centerXOrig: 0,
  17731. _centerYOrig: 0,
  17732. _centerZOrig: 0,
  17733. _eyeXOrig: 0,
  17734. _eyeYOrig: 0,
  17735. _eyeZOrig: 0,
  17736. _upXOrig: 0,
  17737. _upYOrig: 0,
  17738. _upZOrig: 0,
  17739. ctor: function() {
  17740. cc.ActionInterval.prototype.ctor.call(this);
  17741. this._upZOrig = this._upYOrig = this._upXOrig = this._eyeZOrig = this._eyeYOrig = this._eyeXOrig = this._centerZOrig = this._centerYOrig = this._centerXOrig = 0
  17742. },
  17743. startWithTarget: function(a) {
  17744. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17745. a = a.getCamera();
  17746. var c = a.getCenter();
  17747. this._centerXOrig = c.x;
  17748. this._centerYOrig = c.y;
  17749. this._centerZOrig = c.z;
  17750. c = a.getEye();
  17751. this._eyeXOrig = c.x;
  17752. this._eyeYOrig = c.y;
  17753. this._eyeZOrig = c.z;
  17754. a = a.getUp();
  17755. this._upXOrig = a.x;
  17756. this._upYOrig = a.y;
  17757. this._upZOrig = a.z
  17758. },
  17759. clone: function() {
  17760. return new cc.ActionCamera
  17761. },
  17762. reverse: function() {
  17763. return cc.reverseTime(this)
  17764. }
  17765. });
  17766. cc.OrbitCamera = cc.ActionCamera.extend({
  17767. _radius: 0,
  17768. _deltaRadius: 0,
  17769. _angleZ: 0,
  17770. _deltaAngleZ: 0,
  17771. _angleX: 0,
  17772. _deltaAngleX: 0,
  17773. _radZ: 0,
  17774. _radDeltaZ: 0,
  17775. _radX: 0,
  17776. _radDeltaX: 0,
  17777. ctor: function(a, c, d, e, f, g, h) {
  17778. cc.ActionCamera.prototype.ctor.call(this);
  17779. void 0 !== h && this.initWithDuration(a, c, d, e, f, g, h)
  17780. },
  17781. initWithDuration: function(a, c, d, e, f, g, h) {
  17782. 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
  17783. },
  17784. sphericalRadius: function() {
  17785. var a, c;
  17786. c = this.target.getCamera();
  17787. var d = c.getEye();
  17788. a = c.getCenter();
  17789. c = d.x - a.x;
  17790. var e = d.y - a.y;
  17791. a = d.z - a.z;
  17792. var d = Math.sqrt(Math.pow(c, 2) + Math.pow(e, 2) + Math.pow(a, 2)),
  17793. f = Math.sqrt(Math.pow(c, 2) + Math.pow(e, 2));
  17794. 0 === f && (f = cc.FLT_EPSILON);
  17795. 0 === d && (d = cc.FLT_EPSILON);
  17796. a = Math.acos(a / d);
  17797. c = 0 > c ? Math.PI - Math.asin(e / f) : Math.asin(e / f);
  17798. return {
  17799. newRadius: d / cc.Camera.getZEye(),
  17800. zenith: a,
  17801. azimuth: c
  17802. }
  17803. },
  17804. startWithTarget: function(a) {
  17805. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17806. a = this.sphericalRadius();
  17807. isNaN(this._radius) && (this._radius = a.newRadius);
  17808. isNaN(this._angleZ) && (this._angleZ = cc.radiansToDegrees(a.zenith));
  17809. isNaN(this._angleX) && (this._angleX = cc.radiansToDegrees(a.azimuth));
  17810. this._radZ = cc.degreesToRadians(this._angleZ);
  17811. this._radX = cc.degreesToRadians(this._angleX)
  17812. },
  17813. clone: function() {
  17814. var a = new cc.OrbitCamera;
  17815. a.initWithDuration(this._duration, this._radius, this._deltaRadius, this._angleZ, this._deltaAngleZ, this._angleX, this._deltaAngleX);
  17816. return a
  17817. },
  17818. update: function(a) {
  17819. a = this._computeEaseTime(a);
  17820. var c = (this._radius + this._deltaRadius * a) * cc.Camera.getZEye(),
  17821. d = this._radZ + this._radDeltaZ * a,
  17822. e = this._radX + this._radDeltaX * a;
  17823. a = Math.sin(d) * Math.cos(e) * c + this._centerXOrig;
  17824. e = Math.sin(d) * Math.sin(e) * c + this._centerYOrig;
  17825. c = Math.cos(d) * c + this._centerZOrig;
  17826. this.target.getCamera().setEye(a, e, c)
  17827. }
  17828. });
  17829. cc.orbitCamera = function(a, c, d, e, f, g, h) {
  17830. return new cc.OrbitCamera(a, c, d, e, f, g, h)
  17831. };
  17832. cc.OrbitCamera.create = cc.orbitCamera;
  17833. cc.ActionEase = cc.ActionInterval.extend({
  17834. _inner: null,
  17835. ctor: function(a) {
  17836. cc.ActionInterval.prototype.ctor.call(this);
  17837. a && this.initWithAction(a)
  17838. },
  17839. initWithAction: function(a) {
  17840. if (!a) throw "cc.ActionEase.initWithAction(): action must be non nil";
  17841. return this.initWithDuration(a.getDuration()) ? (this._inner = a, !0) : !1
  17842. },
  17843. clone: function() {
  17844. var a = new cc.ActionEase;
  17845. a.initWithAction(this._inner.clone());
  17846. return a
  17847. },
  17848. startWithTarget: function(a) {
  17849. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17850. this._inner.startWithTarget(this.target)
  17851. },
  17852. stop: function() {
  17853. this._inner.stop();
  17854. cc.ActionInterval.prototype.stop.call(this)
  17855. },
  17856. update: function(a) {
  17857. this._inner.update(a)
  17858. },
  17859. reverse: function() {
  17860. return cc.ActionEase.create(this._inner.reverse())
  17861. },
  17862. getInnerAction: function() {
  17863. return this._inner
  17864. }
  17865. });
  17866. cc.actionEase = function(a) {
  17867. return new cc.ActionEase(a)
  17868. };
  17869. cc.ActionEase.create = cc.actionEase;
  17870. cc.EaseRateAction = cc.ActionEase.extend({
  17871. _rate: 0,
  17872. ctor: function(a, c) {
  17873. cc.ActionEase.prototype.ctor.call(this);
  17874. void 0 !== c && this.initWithAction(a, c)
  17875. },
  17876. setRate: function(a) {
  17877. this._rate = a
  17878. },
  17879. getRate: function() {
  17880. return this._rate
  17881. },
  17882. initWithAction: function(a, c) {
  17883. return cc.ActionEase.prototype.initWithAction.call(this, a) ? (this._rate = c, !0) : !1
  17884. },
  17885. clone: function() {
  17886. var a = new cc.EaseRateAction;
  17887. a.initWithAction(this._inner.clone(), this._rate);
  17888. return a
  17889. },
  17890. reverse: function() {
  17891. return cc.EaseRateAction.create(this._inner.reverse(), 1 / this._rate)
  17892. }
  17893. });
  17894. cc.easeRateAction = function(a, c) {
  17895. return new cc.EaseRateAction(a, c)
  17896. };
  17897. cc.EaseRateAction.create = cc.easeRateAction;
  17898. cc.EaseIn = cc.EaseRateAction.extend({
  17899. update: function(a) {
  17900. this._inner.update(Math.pow(a, this._rate))
  17901. },
  17902. reverse: function() {
  17903. return cc.EaseIn.create(this._inner.reverse(), 1 / this._rate)
  17904. },
  17905. clone: function() {
  17906. var a = new cc.EaseIn;
  17907. a.initWithAction(this._inner.clone(), this._rate);
  17908. return a
  17909. }
  17910. });
  17911. cc.EaseIn.create = function(a, c) {
  17912. return new cc.EaseIn(a, c)
  17913. };
  17914. cc.easeIn = function(a) {
  17915. return {
  17916. _rate: a,
  17917. easing: function(a) {
  17918. return Math.pow(a, this._rate)
  17919. },
  17920. reverse: function() {
  17921. return cc.easeIn(1 / this._rate)
  17922. }
  17923. }
  17924. };
  17925. cc.EaseOut = cc.EaseRateAction.extend({
  17926. update: function(a) {
  17927. this._inner.update(Math.pow(a, 1 / this._rate))
  17928. },
  17929. reverse: function() {
  17930. return cc.EaseOut.create(this._inner.reverse(), 1 / this._rate)
  17931. },
  17932. clone: function() {
  17933. var a = new cc.EaseOut;
  17934. a.initWithAction(this._inner.clone(), this._rate);
  17935. return a
  17936. }
  17937. });
  17938. cc.EaseOut.create = function(a, c) {
  17939. return new cc.EaseOut(a, c)
  17940. };
  17941. cc.easeOut = function(a) {
  17942. return {
  17943. _rate: a,
  17944. easing: function(a) {
  17945. return Math.pow(a, 1 / this._rate)
  17946. },
  17947. reverse: function() {
  17948. return cc.easeOut(1 / this._rate)
  17949. }
  17950. }
  17951. };
  17952. cc.EaseInOut = cc.EaseRateAction.extend({
  17953. update: function(a) {
  17954. a *= 2;
  17955. 1 > a ? this._inner.update(0.5 * Math.pow(a, this._rate)) : this._inner.update(1 - 0.5 * Math.pow(2 - a, this._rate))
  17956. },
  17957. clone: function() {
  17958. var a = new cc.EaseInOut;
  17959. a.initWithAction(this._inner.clone(), this._rate);
  17960. return a
  17961. },
  17962. reverse: function() {
  17963. return cc.EaseInOut.create(this._inner.reverse(), this._rate)
  17964. }
  17965. });
  17966. cc.EaseInOut.create = function(a, c) {
  17967. return new cc.EaseInOut(a, c)
  17968. };
  17969. cc.easeInOut = function(a) {
  17970. return {
  17971. _rate: a,
  17972. easing: function(a) {
  17973. a *= 2;
  17974. return 1 > a ? 0.5 * Math.pow(a, this._rate) : 1 - 0.5 * Math.pow(2 - a, this._rate)
  17975. },
  17976. reverse: function() {
  17977. return cc.easeInOut(this._rate)
  17978. }
  17979. }
  17980. };
  17981. cc.EaseExponentialIn = cc.ActionEase.extend({
  17982. update: function(a) {
  17983. this._inner.update(0 === a ? 0 : Math.pow(2, 10 * (a - 1)))
  17984. },
  17985. reverse: function() {
  17986. return cc.EaseExponentialOut.create(this._inner.reverse())
  17987. },
  17988. clone: function() {
  17989. var a = new cc.EaseExponentialIn;
  17990. a.initWithAction(this._inner.clone());
  17991. return a
  17992. }
  17993. });
  17994. cc.EaseExponentialIn.create = function(a) {
  17995. return new cc.EaseExponentialIn(a)
  17996. };
  17997. cc._easeExponentialInObj = {
  17998. easing: function(a) {
  17999. return 0 === a ? 0 : Math.pow(2, 10 * (a - 1))
  18000. },
  18001. reverse: function() {
  18002. return cc._easeExponentialOutObj
  18003. }
  18004. };
  18005. cc.easeExponentialIn = function() {
  18006. return cc._easeExponentialInObj
  18007. };
  18008. cc.EaseExponentialOut = cc.ActionEase.extend({
  18009. update: function(a) {
  18010. this._inner.update(1 == a ? 1 : -Math.pow(2, -10 * a) + 1)
  18011. },
  18012. reverse: function() {
  18013. return cc.EaseExponentialIn.create(this._inner.reverse())
  18014. },
  18015. clone: function() {
  18016. var a = new cc.EaseExponentialOut;
  18017. a.initWithAction(this._inner.clone());
  18018. return a
  18019. }
  18020. });
  18021. cc.EaseExponentialOut.create = function(a) {
  18022. return new cc.EaseExponentialOut(a)
  18023. };
  18024. cc._easeExponentialOutObj = {
  18025. easing: function(a) {
  18026. return 1 == a ? 1 : -Math.pow(2, -10 * a) + 1
  18027. },
  18028. reverse: function() {
  18029. return cc._easeExponentialInObj
  18030. }
  18031. };
  18032. cc.easeExponentialOut = function() {
  18033. return cc._easeExponentialOutObj
  18034. };
  18035. cc.EaseExponentialInOut = cc.ActionEase.extend({
  18036. update: function(a) {
  18037. 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));
  18038. this._inner.update(a)
  18039. },
  18040. reverse: function() {
  18041. return cc.EaseExponentialInOut.create(this._inner.reverse())
  18042. },
  18043. clone: function() {
  18044. var a = new cc.EaseExponentialInOut;
  18045. a.initWithAction(this._inner.clone());
  18046. return a
  18047. }
  18048. });
  18049. cc.EaseExponentialInOut.create = function(a) {
  18050. return new cc.EaseExponentialInOut(a)
  18051. };
  18052. cc._easeExponentialInOutObj = {
  18053. easing: function(a) {
  18054. 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
  18055. },
  18056. reverse: function() {
  18057. return cc._easeExponentialInOutObj
  18058. }
  18059. };
  18060. cc.easeExponentialInOut = function() {
  18061. return cc._easeExponentialInOutObj
  18062. };
  18063. cc.EaseSineIn = cc.ActionEase.extend({
  18064. update: function(a) {
  18065. a = 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1;
  18066. this._inner.update(a)
  18067. },
  18068. reverse: function() {
  18069. return cc.EaseSineOut.create(this._inner.reverse())
  18070. },
  18071. clone: function() {
  18072. var a = new cc.EaseSineIn;
  18073. a.initWithAction(this._inner.clone());
  18074. return a
  18075. }
  18076. });
  18077. cc.EaseSineIn.create = function(a) {
  18078. return new cc.EaseSineIn(a)
  18079. };
  18080. cc._easeSineInObj = {
  18081. easing: function(a) {
  18082. return 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1
  18083. },
  18084. reverse: function() {
  18085. return cc._easeSineOutObj
  18086. }
  18087. };
  18088. cc.easeSineIn = function() {
  18089. return cc._easeSineInObj
  18090. };
  18091. cc.EaseSineOut = cc.ActionEase.extend({
  18092. update: function(a) {
  18093. a = 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2);
  18094. this._inner.update(a)
  18095. },
  18096. reverse: function() {
  18097. return cc.EaseSineIn.create(this._inner.reverse())
  18098. },
  18099. clone: function() {
  18100. var a = new cc.EaseSineOut;
  18101. a.initWithAction(this._inner.clone());
  18102. return a
  18103. }
  18104. });
  18105. cc.EaseSineOut.create = function(a) {
  18106. return new cc.EaseSineOut(a)
  18107. };
  18108. cc._easeSineOutObj = {
  18109. easing: function(a) {
  18110. return 0 === a || 1 == a ? a : Math.sin(a * Math.PI / 2)
  18111. },
  18112. reverse: function() {
  18113. return cc._easeSineInObj
  18114. }
  18115. };
  18116. cc.easeSineOut = function() {
  18117. return cc._easeSineOutObj
  18118. };
  18119. cc.EaseSineInOut = cc.ActionEase.extend({
  18120. update: function(a) {
  18121. a = 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1);
  18122. this._inner.update(a)
  18123. },
  18124. clone: function() {
  18125. var a = new cc.EaseSineInOut;
  18126. a.initWithAction(this._inner.clone());
  18127. return a
  18128. },
  18129. reverse: function() {
  18130. return cc.EaseSineInOut.create(this._inner.reverse())
  18131. }
  18132. });
  18133. cc.EaseSineInOut.create = function(a) {
  18134. return new cc.EaseSineInOut(a)
  18135. };
  18136. cc._easeSineInOutObj = {
  18137. easing: function(a) {
  18138. return 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1)
  18139. },
  18140. reverse: function() {
  18141. return cc._easeSineInOutObj
  18142. }
  18143. };
  18144. cc.easeSineInOut = function() {
  18145. return cc._easeSineInOutObj
  18146. };
  18147. cc.EaseElastic = cc.ActionEase.extend({
  18148. _period: 0.3,
  18149. ctor: function(a, c) {
  18150. cc.ActionEase.prototype.ctor.call(this);
  18151. a && this.initWithAction(a, c)
  18152. },
  18153. getPeriod: function() {
  18154. return this._period
  18155. },
  18156. setPeriod: function(a) {
  18157. this._period = a
  18158. },
  18159. initWithAction: function(a, c) {
  18160. cc.ActionEase.prototype.initWithAction.call(this, a);
  18161. this._period = null == c ? 0.3 : c;
  18162. return !0
  18163. },
  18164. reverse: function() {
  18165. cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
  18166. return null
  18167. },
  18168. clone: function() {
  18169. var a = new cc.EaseElastic;
  18170. a.initWithAction(this._inner.clone(), this._period);
  18171. return a
  18172. }
  18173. });
  18174. cc.EaseElastic.create = function(a, c) {
  18175. return new cc.EaseElastic(a, c)
  18176. };
  18177. cc.EaseElasticIn = cc.EaseElastic.extend({
  18178. update: function(a) {
  18179. var c = 0;
  18180. 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));
  18181. this._inner.update(c)
  18182. },
  18183. reverse: function() {
  18184. return cc.EaseElasticOut.create(this._inner.reverse(), this._period)
  18185. },
  18186. clone: function() {
  18187. var a = new cc.EaseElasticIn;
  18188. a.initWithAction(this._inner.clone(), this._period);
  18189. return a
  18190. }
  18191. });
  18192. cc.EaseElasticIn.create = function(a, c) {
  18193. return new cc.EaseElasticIn(a, c)
  18194. };
  18195. cc._easeElasticInObj = {
  18196. easing: function(a) {
  18197. if (0 === a || 1 === a) return a;
  18198. a -= 1;
  18199. return -Math.pow(2, 10 * a) * Math.sin(2 * (a - 0.075) * Math.PI / 0.3)
  18200. },
  18201. reverse: function() {
  18202. return cc._easeElasticOutObj
  18203. }
  18204. };
  18205. cc.easeElasticIn = function(a) {
  18206. return a && 0.3 !== a ? {
  18207. _period: a,
  18208. easing: function(a) {
  18209. if (0 === a || 1 === a) return a;
  18210. a -= 1;
  18211. return -Math.pow(2, 10 * a) * Math.sin(2 * (a - this._period / 4) * Math.PI / this._period)
  18212. },
  18213. reverse: function() {
  18214. return cc.easeElasticOut(this._period)
  18215. }
  18216. } : cc._easeElasticInObj
  18217. };
  18218. cc.EaseElasticOut = cc.EaseElastic.extend({
  18219. update: function(a) {
  18220. var c = 0;
  18221. 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);
  18222. this._inner.update(c)
  18223. },
  18224. reverse: function() {
  18225. return cc.EaseElasticIn.create(this._inner.reverse(), this._period)
  18226. },
  18227. clone: function() {
  18228. var a = new cc.EaseElasticOut;
  18229. a.initWithAction(this._inner.clone(), this._period);
  18230. return a
  18231. }
  18232. });
  18233. cc.EaseElasticOut.create = function(a, c) {
  18234. return new cc.EaseElasticOut(a, c)
  18235. };
  18236. cc._easeElasticOutObj = {
  18237. easing: function(a) {
  18238. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin(2 * (a - 0.075) * Math.PI / 0.3) + 1
  18239. },
  18240. reverse: function() {
  18241. return cc._easeElasticInObj
  18242. }
  18243. };
  18244. cc.easeElasticOut = function(a) {
  18245. return a && 0.3 !== a ? {
  18246. _period: a,
  18247. easing: function(a) {
  18248. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin(2 * (a - this._period / 4) * Math.PI / this._period) + 1
  18249. },
  18250. reverse: function() {
  18251. return cc.easeElasticIn(this._period)
  18252. }
  18253. } : cc._easeElasticOutObj
  18254. };
  18255. cc.EaseElasticInOut = cc.EaseElastic.extend({
  18256. update: function(a) {
  18257. var c = 0,
  18258. c = this._period;
  18259. if (0 === a || 1 == a) c = a;
  18260. else {
  18261. c || (c = this._period = 0.3 * 1.5);
  18262. var d = c / 4;
  18263. a = 2 * a - 1;
  18264. 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
  18265. }
  18266. this._inner.update(c)
  18267. },
  18268. reverse: function() {
  18269. return cc.EaseElasticInOut.create(this._inner.reverse(), this._period)
  18270. },
  18271. clone: function() {
  18272. var a = new cc.EaseElasticInOut;
  18273. a.initWithAction(this._inner.clone(), this._period);
  18274. return a
  18275. }
  18276. });
  18277. cc.EaseElasticInOut.create = function(a, c) {
  18278. return new cc.EaseElasticInOut(a, c)
  18279. };
  18280. cc.easeElasticInOut = function(a) {
  18281. return {
  18282. _period: a || 0.3,
  18283. easing: function(a) {
  18284. var d = 0,
  18285. d = this._period;
  18286. if (0 === a || 1 === a) d = a;
  18287. else {
  18288. d || (d = this._period = 0.3 * 1.5);
  18289. var e = d / 4;
  18290. a = 2 * a - 1;
  18291. 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
  18292. }
  18293. return d
  18294. },
  18295. reverse: function() {
  18296. return cc.easeElasticInOut(this._period)
  18297. }
  18298. }
  18299. };
  18300. cc.EaseBounce = cc.ActionEase.extend({
  18301. bounceTime: function(a) {
  18302. if (a < 1 / 2.75) return 7.5625 * a * a;
  18303. if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
  18304. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
  18305. a -= 2.625 / 2.75;
  18306. return 7.5625 * a * a + 0.984375
  18307. },
  18308. clone: function() {
  18309. var a = new cc.EaseBounce;
  18310. a.initWithAction(this._inner.clone());
  18311. return a
  18312. },
  18313. reverse: function() {
  18314. return cc.EaseBounce.create(this._inner.reverse())
  18315. }
  18316. });
  18317. cc.EaseBounce.create = function(a) {
  18318. return new cc.EaseBounce(a)
  18319. };
  18320. cc.EaseBounceIn = cc.EaseBounce.extend({
  18321. update: function(a) {
  18322. a = 1 - this.bounceTime(1 - a);
  18323. this._inner.update(a)
  18324. },
  18325. reverse: function() {
  18326. return cc.EaseBounceOut.create(this._inner.reverse())
  18327. },
  18328. clone: function() {
  18329. var a = new cc.EaseBounceIn;
  18330. a.initWithAction(this._inner.clone());
  18331. return a
  18332. }
  18333. });
  18334. cc.EaseBounceIn.create = function(a) {
  18335. return new cc.EaseBounceIn(a)
  18336. };
  18337. cc._bounceTime = function(a) {
  18338. if (a < 1 / 2.75) return 7.5625 * a * a;
  18339. if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
  18340. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
  18341. a -= 2.625 / 2.75;
  18342. return 7.5625 * a * a + 0.984375
  18343. };
  18344. cc._easeBounceInObj = {
  18345. easing: function(a) {
  18346. return 1 - cc._bounceTime(1 - a)
  18347. },
  18348. reverse: function() {
  18349. return cc._easeBounceOutObj
  18350. }
  18351. };
  18352. cc.easeBounceIn = function() {
  18353. return cc._easeBounceInObj
  18354. };
  18355. cc.EaseBounceOut = cc.EaseBounce.extend({
  18356. update: function(a) {
  18357. a = this.bounceTime(a);
  18358. this._inner.update(a)
  18359. },
  18360. reverse: function() {
  18361. return cc.EaseBounceIn.create(this._inner.reverse())
  18362. },
  18363. clone: function() {
  18364. var a = new cc.EaseBounceOut;
  18365. a.initWithAction(this._inner.clone());
  18366. return a
  18367. }
  18368. });
  18369. cc.EaseBounceOut.create = function(a) {
  18370. return new cc.EaseBounceOut(a)
  18371. };
  18372. cc._easeBounceOutObj = {
  18373. easing: function(a) {
  18374. return cc._bounceTime(a)
  18375. },
  18376. reverse: function() {
  18377. return cc._easeBounceInObj
  18378. }
  18379. };
  18380. cc.easeBounceOut = function() {
  18381. return cc._easeBounceOutObj
  18382. };
  18383. cc.EaseBounceInOut = cc.EaseBounce.extend({
  18384. update: function(a) {
  18385. var c = 0,
  18386. c = 0.5 > a ? 0.5 * (1 - this.bounceTime(1 - 2 * a)) : 0.5 * this.bounceTime(2 * a - 1) + 0.5;
  18387. this._inner.update(c)
  18388. },
  18389. clone: function() {
  18390. var a = new cc.EaseBounceInOut;
  18391. a.initWithAction(this._inner.clone());
  18392. return a
  18393. },
  18394. reverse: function() {
  18395. return cc.EaseBounceInOut.create(this._inner.reverse())
  18396. }
  18397. });
  18398. cc.EaseBounceInOut.create = function(a) {
  18399. return new cc.EaseBounceInOut(a)
  18400. };
  18401. cc._easeBounceInOutObj = {
  18402. easing: function(a) {
  18403. return a = 0.5 > a ? 0.5 * (1 - cc._bounceTime(1 - 2 * a)) : 0.5 * cc._bounceTime(2 * a - 1) + 0.5
  18404. },
  18405. reverse: function() {
  18406. return cc._easeBounceInOutObj
  18407. }
  18408. };
  18409. cc.easeBounceInOut = function() {
  18410. return cc._easeBounceInOutObj
  18411. };
  18412. cc.EaseBackIn = cc.ActionEase.extend({
  18413. update: function(a) {
  18414. this._inner.update(0 === a || 1 == a ? a : a * a * (2.70158 * a - 1.70158))
  18415. },
  18416. reverse: function() {
  18417. return cc.EaseBackOut.create(this._inner.reverse())
  18418. },
  18419. clone: function() {
  18420. var a = new cc.EaseBackIn;
  18421. a.initWithAction(this._inner.clone());
  18422. return a
  18423. }
  18424. });
  18425. cc.EaseBackIn.create = function(a) {
  18426. return new cc.EaseBackIn(a)
  18427. };
  18428. cc._easeBackInObj = {
  18429. easing: function(a) {
  18430. return 0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158)
  18431. },
  18432. reverse: function() {
  18433. return cc._easeBackOutObj
  18434. }
  18435. };
  18436. cc.easeBackIn = function() {
  18437. return cc._easeBackInObj
  18438. };
  18439. cc.EaseBackOut = cc.ActionEase.extend({
  18440. update: function(a) {
  18441. a -= 1;
  18442. this._inner.update(a * a * (2.70158 * a + 1.70158) + 1)
  18443. },
  18444. reverse: function() {
  18445. return cc.EaseBackIn.create(this._inner.reverse())
  18446. },
  18447. clone: function() {
  18448. var a = new cc.EaseBackOut;
  18449. a.initWithAction(this._inner.clone());
  18450. return a
  18451. }
  18452. });
  18453. cc.EaseBackOut.create = function(a) {
  18454. return new cc.EaseBackOut(a)
  18455. };
  18456. cc._easeBackOutObj = {
  18457. easing: function(a) {
  18458. a -= 1;
  18459. return a * a * (2.70158 * a + 1.70158) + 1
  18460. },
  18461. reverse: function() {
  18462. return cc._easeBackInObj
  18463. }
  18464. };
  18465. cc.easeBackOut = function() {
  18466. return cc._easeBackOutObj
  18467. };
  18468. cc.EaseBackInOut = cc.ActionEase.extend({
  18469. update: function(a) {
  18470. a *= 2;
  18471. 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))
  18472. },
  18473. clone: function() {
  18474. var a = new cc.EaseBackInOut;
  18475. a.initWithAction(this._inner.clone());
  18476. return a
  18477. },
  18478. reverse: function() {
  18479. return cc.EaseBackInOut.create(this._inner.reverse())
  18480. }
  18481. });
  18482. cc.EaseBackInOut.create = function(a) {
  18483. return new cc.EaseBackInOut(a)
  18484. };
  18485. cc._easeBackInOutObj = {
  18486. easing: function(a) {
  18487. a *= 2;
  18488. if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
  18489. a -= 2;
  18490. return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
  18491. },
  18492. reverse: function() {
  18493. return cc._easeBackInOutObj
  18494. }
  18495. };
  18496. cc.easeBackInOut = function() {
  18497. return cc._easeBackInOutObj
  18498. };
  18499. cc.EaseBezierAction = cc.ActionEase.extend({
  18500. _p0: null,
  18501. _p1: null,
  18502. _p2: null,
  18503. _p3: null,
  18504. ctor: function(a) {
  18505. cc.ActionEase.prototype.ctor.call(this, a)
  18506. },
  18507. _updateTime: function(a, c, d, e, f) {
  18508. 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
  18509. },
  18510. update: function(a) {
  18511. a = this._updateTime(this._p0, this._p1, this._p2, this._p3, a);
  18512. this._inner.update(a)
  18513. },
  18514. clone: function() {
  18515. var a = new cc.EaseBezierAction;
  18516. a.initWithAction(this._inner.clone());
  18517. a.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
  18518. return a
  18519. },
  18520. reverse: function() {
  18521. var a = cc.EaseBezierAction.create(this._inner.reverse());
  18522. a.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
  18523. return a
  18524. },
  18525. setBezierParamer: function(a, c, d, e) {
  18526. this._p0 = a || 0;
  18527. this._p1 = c || 0;
  18528. this._p2 = d || 0;
  18529. this._p3 = e || 0
  18530. }
  18531. });
  18532. cc.EaseBezierAction.create = function(a) {
  18533. return new cc.EaseBezierAction(a)
  18534. };
  18535. cc.easeBezierAction = function(a, c, d, e) {
  18536. return {
  18537. easing: function(f) {
  18538. return cc.EaseBezierAction.prototype._updateTime(a, c, d, e, f)
  18539. },
  18540. reverse: function() {
  18541. return cc.easeBezierAction(e, d, c, a)
  18542. }
  18543. }
  18544. };
  18545. cc.EaseQuadraticActionIn = cc.ActionEase.extend({
  18546. _updateTime: function(a) {
  18547. return Math.pow(a, 2)
  18548. },
  18549. update: function(a) {
  18550. this._inner.update(this._updateTime(a))
  18551. },
  18552. clone: function() {
  18553. var a = new cc.EaseQuadraticActionIn;
  18554. a.initWithAction(this._inner.clone());
  18555. return a
  18556. },
  18557. reverse: function() {
  18558. return cc.EaseQuadraticActionIn.create(this._inner.reverse())
  18559. }
  18560. });
  18561. cc.EaseQuadraticActionIn.create = function(a) {
  18562. return new cc.EaseQuadraticActionIn(a)
  18563. };
  18564. cc._easeQuadraticActionIn = {
  18565. easing: cc.EaseQuadraticActionIn.prototype._updateTime,
  18566. reverse: function() {
  18567. return cc._easeQuadraticActionIn
  18568. }
  18569. };
  18570. cc.easeQuadraticActionIn = function() {
  18571. return cc._easeQuadraticActionIn
  18572. };
  18573. cc.EaseQuadraticActionOut = cc.ActionEase.extend({
  18574. _updateTime: function(a) {
  18575. return -a * (a - 2)
  18576. },
  18577. update: function(a) {
  18578. this._inner.update(this._updateTime(a))
  18579. },
  18580. clone: function() {
  18581. var a = new cc.EaseQuadraticActionOut;
  18582. a.initWithAction();
  18583. return a
  18584. },
  18585. reverse: function() {
  18586. return cc.EaseQuadraticActionOut.create(this._inner.reverse())
  18587. }
  18588. });
  18589. cc.EaseQuadraticActionOut.create = function(a) {
  18590. return new cc.EaseQuadraticActionOut(a)
  18591. };
  18592. cc._easeQuadraticActionOut = {
  18593. easing: cc.EaseQuadraticActionOut.prototype._updateTime,
  18594. reverse: function() {
  18595. return cc._easeQuadraticActionOut
  18596. }
  18597. };
  18598. cc.easeQuadraticActionOut = function() {
  18599. return cc._easeQuadraticActionOut
  18600. };
  18601. cc.EaseQuadraticActionInOut = cc.ActionEase.extend({
  18602. _updateTime: function(a) {
  18603. var c = a;
  18604. a *= 2;
  18605. 1 > a ? c = 0.5 * a * a : (--a, c = -0.5 * (a * (a - 2) - 1));
  18606. return c
  18607. },
  18608. update: function(a) {
  18609. this._inner.update(this._updateTime(a))
  18610. },
  18611. clone: function() {
  18612. var a = new cc.EaseQuadraticActionInOut;
  18613. a.initWithAction(this._inner.clone());
  18614. return a
  18615. },
  18616. reverse: function() {
  18617. return cc.EaseQuadraticActionInOut.create(this._inner.reverse())
  18618. }
  18619. });
  18620. cc.EaseQuadraticActionInOut.create = function(a) {
  18621. return new cc.EaseQuadraticActionInOut(a)
  18622. };
  18623. cc._easeQuadraticActionInOut = {
  18624. easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
  18625. reverse: function() {
  18626. return cc._easeQuadraticActionInOut
  18627. }
  18628. };
  18629. cc.easeQuadraticActionInOut = function() {
  18630. return cc._easeQuadraticActionInOut
  18631. };
  18632. cc.EaseQuarticActionIn = cc.ActionEase.extend({
  18633. _updateTime: function(a) {
  18634. return a * a * a * a
  18635. },
  18636. update: function(a) {
  18637. this._inner.update(this._updateTime(a))
  18638. },
  18639. clone: function() {
  18640. var a = new cc.EaseQuarticActionIn;
  18641. a.initWithAction(this._inner.clone());
  18642. return a
  18643. },
  18644. reverse: function() {
  18645. return cc.EaseQuarticActionIn.create(this._inner.reverse())
  18646. }
  18647. });
  18648. cc.EaseQuarticActionIn.create = function(a) {
  18649. return new cc.EaseQuarticActionIn(a)
  18650. };
  18651. cc._easeQuarticActionIn = {
  18652. easing: cc.EaseQuarticActionIn.prototype._updateTime,
  18653. reverse: function() {
  18654. return cc._easeQuarticActionIn
  18655. }
  18656. };
  18657. cc.easeQuarticActionIn = function() {
  18658. return cc._easeQuarticActionIn
  18659. };
  18660. cc.EaseQuarticActionOut = cc.ActionEase.extend({
  18661. _updateTime: function(a) {
  18662. a -= 1;
  18663. return -(a * a * a * a - 1)
  18664. },
  18665. update: function(a) {
  18666. this._inner.update(this._updateTime(a))
  18667. },
  18668. clone: function() {
  18669. var a = new cc.EaseQuarticActionOut;
  18670. a.initWithAction(this._inner.clone());
  18671. return a
  18672. },
  18673. reverse: function() {
  18674. return cc.EaseQuarticActionOut.create(this._inner.reverse())
  18675. }
  18676. });
  18677. cc.EaseQuarticActionOut.create = function(a) {
  18678. return new cc.EaseQuarticActionOut(a)
  18679. };
  18680. cc._easeQuarticActionOut = {
  18681. easing: cc.EaseQuarticActionOut.prototype._updateTime,
  18682. reverse: function() {
  18683. return cc._easeQuarticActionOut
  18684. }
  18685. };
  18686. cc.easeQuarticActionOut = function() {
  18687. return cc._easeQuarticActionOut
  18688. };
  18689. cc.EaseQuarticActionInOut = cc.ActionEase.extend({
  18690. _updateTime: function(a) {
  18691. a *= 2;
  18692. if (1 > a) return 0.5 * a * a * a * a;
  18693. a -= 2;
  18694. return -0.5 * (a * a * a * a - 2)
  18695. },
  18696. update: function(a) {
  18697. this._inner.update(this._updateTime(a))
  18698. },
  18699. clone: function() {
  18700. var a = new cc.EaseQuarticActionInOut;
  18701. a.initWithAction(this._inner.clone());
  18702. return a
  18703. },
  18704. reverse: function() {
  18705. return cc.EaseQuarticActionInOut.create(this._inner.reverse())
  18706. }
  18707. });
  18708. cc.EaseQuarticActionInOut.create = function(a) {
  18709. return new cc.EaseQuarticActionInOut(a)
  18710. };
  18711. cc._easeQuarticActionInOut = {
  18712. easing: cc.EaseQuarticActionInOut.prototype._updateTime,
  18713. reverse: function() {
  18714. return cc._easeQuarticActionInOut
  18715. }
  18716. };
  18717. cc.easeQuarticActionInOut = function() {
  18718. return cc._easeQuarticActionInOut
  18719. };
  18720. cc.EaseQuinticActionIn = cc.ActionEase.extend({
  18721. _updateTime: function(a) {
  18722. return a * a * a * a * a
  18723. },
  18724. update: function(a) {
  18725. this._inner.update(this._updateTime(a))
  18726. },
  18727. clone: function() {
  18728. var a = new cc.EaseQuinticActionIn;
  18729. a.initWithAction(this._inner.clone());
  18730. return a
  18731. },
  18732. reverse: function() {
  18733. return cc.EaseQuinticActionIn.create(this._inner.reverse())
  18734. }
  18735. });
  18736. cc.EaseQuinticActionIn.create = function(a) {
  18737. return new cc.EaseQuinticActionIn(a)
  18738. };
  18739. cc._easeQuinticActionIn = {
  18740. easing: cc.EaseQuinticActionIn.prototype._updateTime,
  18741. reverse: function() {
  18742. return cc._easeQuinticActionIn
  18743. }
  18744. };
  18745. cc.easeQuinticActionIn = function() {
  18746. return cc._easeQuinticActionIn
  18747. };
  18748. cc.EaseQuinticActionOut = cc.ActionEase.extend({
  18749. _updateTime: function(a) {
  18750. a -= 1;
  18751. return a * a * a * a * a + 1
  18752. },
  18753. update: function(a) {
  18754. this._inner.update(this._updateTime(a))
  18755. },
  18756. clone: function() {
  18757. var a = new cc.EaseQuinticActionOut;
  18758. a.initWithAction(this._inner.clone());
  18759. return a
  18760. },
  18761. reverse: function() {
  18762. return cc.EaseQuinticActionOut.create(this._inner.reverse())
  18763. }
  18764. });
  18765. cc.EaseQuinticActionOut.create = function(a) {
  18766. return new cc.EaseQuinticActionOut(a)
  18767. };
  18768. cc._easeQuinticActionOut = {
  18769. easing: cc.EaseQuinticActionOut.prototype._updateTime,
  18770. reverse: function() {
  18771. return cc._easeQuinticActionOut
  18772. }
  18773. };
  18774. cc.easeQuinticActionOut = function() {
  18775. return cc._easeQuinticActionOut
  18776. };
  18777. cc.EaseQuinticActionInOut = cc.ActionEase.extend({
  18778. _updateTime: function(a) {
  18779. a *= 2;
  18780. if (1 > a) return 0.5 * a * a * a * a * a;
  18781. a -= 2;
  18782. return 0.5 * (a * a * a * a * a + 2)
  18783. },
  18784. update: function(a) {
  18785. this._inner.update(this._updateTime(a))
  18786. },
  18787. clone: function() {
  18788. var a = new cc.EaseQuinticActionInOut;
  18789. a.initWithAction(this._inner.clone());
  18790. return a
  18791. },
  18792. reverse: function() {
  18793. return cc.EaseQuinticActionInOut.create(this._inner.reverse())
  18794. }
  18795. });
  18796. cc.EaseQuinticActionInOut.create = function(a) {
  18797. return new cc.EaseQuinticActionInOut(a)
  18798. };
  18799. cc._easeQuinticActionInOut = {
  18800. easing: cc.EaseQuinticActionInOut.prototype._updateTime,
  18801. reverse: function() {
  18802. return cc._easeQuinticActionInOut
  18803. }
  18804. };
  18805. cc.easeQuinticActionInOut = function() {
  18806. return cc._easeQuinticActionInOut
  18807. };
  18808. cc.EaseCircleActionIn = cc.ActionEase.extend({
  18809. _updateTime: function(a) {
  18810. return -1 * (Math.sqrt(1 - a * a) - 1)
  18811. },
  18812. update: function(a) {
  18813. this._inner.update(this._updateTime(a))
  18814. },
  18815. clone: function() {
  18816. var a = new cc.EaseCircleActionIn;
  18817. a.initWithAction(this._inner.clone());
  18818. return a
  18819. },
  18820. reverse: function() {
  18821. return cc.EaseCircleActionIn.create(this._inner.reverse())
  18822. }
  18823. });
  18824. cc.EaseCircleActionIn.create = function(a) {
  18825. return new cc.EaseCircleActionIn(a)
  18826. };
  18827. cc._easeCircleActionIn = {
  18828. easing: cc.EaseCircleActionIn.prototype._updateTime,
  18829. reverse: function() {
  18830. return cc._easeCircleActionIn
  18831. }
  18832. };
  18833. cc.easeCircleActionIn = function() {
  18834. return cc._easeCircleActionIn
  18835. };
  18836. cc.EaseCircleActionOut = cc.ActionEase.extend({
  18837. _updateTime: function(a) {
  18838. a -= 1;
  18839. return Math.sqrt(1 - a * a)
  18840. },
  18841. update: function(a) {
  18842. this._inner.update(this._updateTime(a))
  18843. },
  18844. clone: function() {
  18845. var a = new cc.EaseCircleActionOut;
  18846. a.initWithAction(this._inner.clone());
  18847. return a
  18848. },
  18849. reverse: function() {
  18850. return cc.EaseCircleActionOut.create(this._inner.reverse())
  18851. }
  18852. });
  18853. cc.EaseCircleActionOut.create = function(a) {
  18854. return new cc.EaseCircleActionOut(a)
  18855. };
  18856. cc._easeCircleActionOut = {
  18857. easing: cc.EaseCircleActionOut.prototype._updateTime,
  18858. reverse: function() {
  18859. return cc._easeCircleActionOut
  18860. }
  18861. };
  18862. cc.easeCircleActionOut = function() {
  18863. return cc._easeCircleActionOut
  18864. };
  18865. cc.EaseCircleActionInOut = cc.ActionEase.extend({
  18866. _updateTime: function(a) {
  18867. a *= 2;
  18868. if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
  18869. a -= 2;
  18870. return 0.5 * (Math.sqrt(1 - a * a) + 1)
  18871. },
  18872. update: function(a) {
  18873. this._inner.update(this._updateTime(a))
  18874. },
  18875. clone: function() {
  18876. var a = new cc.EaseCircleActionInOut;
  18877. a.initWithAction(this._inner.clone());
  18878. return a
  18879. },
  18880. reverse: function() {
  18881. return cc.EaseCircleActionInOut.create(this._inner.reverse())
  18882. }
  18883. });
  18884. cc.EaseCircleActionInOut.create = function(a) {
  18885. return new cc.EaseCircleActionInOut(a)
  18886. };
  18887. cc._easeCircleActionInOut = {
  18888. easing: cc.EaseCircleActionInOut.prototype._updateTime,
  18889. reverse: function() {
  18890. return cc._easeCircleActionInOut
  18891. }
  18892. };
  18893. cc.easeCircleActionInOut = function() {
  18894. return cc._easeCircleActionInOut
  18895. };
  18896. cc.EaseCubicActionIn = cc.ActionEase.extend({
  18897. _updateTime: function(a) {
  18898. return a * a * a
  18899. },
  18900. update: function(a) {
  18901. this._inner.update(this._updateTime(a))
  18902. },
  18903. clone: function() {
  18904. var a = new cc.EaseCubicActionIn;
  18905. a.initWithAction(this._inner.clone());
  18906. return a
  18907. },
  18908. reverse: function() {
  18909. return cc.EaseCubicActionIn.create(this._inner.reverse())
  18910. }
  18911. });
  18912. cc.EaseCubicActionIn.create = function(a) {
  18913. return new cc.EaseCubicActionIn(a)
  18914. };
  18915. cc._easeCubicActionIn = {
  18916. easing: cc.EaseCubicActionIn.prototype._updateTime,
  18917. reverse: function() {
  18918. return cc._easeCubicActionIn
  18919. }
  18920. };
  18921. cc.easeCubicActionIn = function() {
  18922. return cc._easeCubicActionIn
  18923. };
  18924. cc.EaseCubicActionOut = cc.ActionEase.extend({
  18925. _updateTime: function(a) {
  18926. a -= 1;
  18927. return a * a * a + 1
  18928. },
  18929. update: function(a) {
  18930. this._inner.update(this._updateTime(a))
  18931. },
  18932. clone: function() {
  18933. var a = new cc.EaseCubicActionOut;
  18934. a.initWithAction(this._inner.clone());
  18935. return a
  18936. },
  18937. reverse: function() {
  18938. return cc.EaseCubicActionOut.create(this._inner.reverse())
  18939. }
  18940. });
  18941. cc.EaseCubicActionOut.create = function(a) {
  18942. return new cc.EaseCubicActionOut(a)
  18943. };
  18944. cc._easeCubicActionOut = {
  18945. easing: cc.EaseCubicActionOut.prototype._updateTime,
  18946. reverse: function() {
  18947. return cc._easeCubicActionOut
  18948. }
  18949. };
  18950. cc.easeCubicActionOut = function() {
  18951. return cc._easeCubicActionOut
  18952. };
  18953. cc.EaseCubicActionInOut = cc.ActionEase.extend({
  18954. _updateTime: function(a) {
  18955. a *= 2;
  18956. if (1 > a) return 0.5 * a * a * a;
  18957. a -= 2;
  18958. return 0.5 * (a * a * a + 2)
  18959. },
  18960. update: function(a) {
  18961. this._inner.update(this._updateTime(a))
  18962. },
  18963. clone: function() {
  18964. var a = new cc.EaseCubicActionInOut;
  18965. a.initWithAction(this._inner.clone());
  18966. return a
  18967. },
  18968. reverse: function() {
  18969. return cc.EaseCubicActionInOut.create(this._inner.reverse())
  18970. }
  18971. });
  18972. cc.EaseCubicActionInOut.create = function(a) {
  18973. return new cc.EaseCubicActionInOut(a)
  18974. };
  18975. cc._easeCubicActionInOut = {
  18976. easing: cc.EaseCubicActionInOut.prototype._updateTime,
  18977. reverse: function() {
  18978. return cc._easeCubicActionInOut
  18979. }
  18980. };
  18981. cc.easeCubicActionInOut = function() {
  18982. return cc._easeCubicActionInOut
  18983. };
  18984. cc.cardinalSplineAt = function(a, c, d, e, f, g) {
  18985. var h = g * g,
  18986. k = h * g,
  18987. m = (1 - f) / 2;
  18988. f = m * (-k + 2 * h - g);
  18989. var n = m * (-k + h) + (2 * k - 3 * h + 1);
  18990. g = m * (k - 2 * h + g) + (-2 * k + 3 * h);
  18991. h = m * (k - h);
  18992. 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)
  18993. };
  18994. cc.reverseControlPoints = function(a) {
  18995. for (var c = [], d = a.length - 1; 0 <= d; d--) c.push(cc.p(a[d].x, a[d].y));
  18996. return c
  18997. };
  18998. cc.copyControlPoints = function(a) {
  18999. for (var c = [], d = 0; d < a.length; d++) c.push(cc.p(a[d].x, a[d].y));
  19000. return c
  19001. };
  19002. cc.getControlPointAt = function(a, c) {
  19003. var d = Math.min(a.length - 1, Math.max(c, 0));
  19004. return a[d]
  19005. };
  19006. cc.reverseControlPointsInline = function(a) {
  19007. for (var c = a.length, d = 0 | c / 2, e = 0; e < d; ++e) {
  19008. var f = a[e];
  19009. a[e] = a[c - e - 1];
  19010. a[c - e - 1] = f
  19011. }
  19012. };
  19013. cc.CardinalSplineTo = cc.ActionInterval.extend({
  19014. _points: null,
  19015. _deltaT: 0,
  19016. _tension: 0,
  19017. _previousPosition: null,
  19018. _accumulatedDiff: null,
  19019. ctor: function(a, c, d) {
  19020. cc.ActionInterval.prototype.ctor.call(this);
  19021. this._points = [];
  19022. void 0 !== d && this.initWithDuration(a, c, d)
  19023. },
  19024. initWithDuration: function(a, c, d) {
  19025. if (!c || 0 == c.length) throw "Invalid configuration. It must at least have one control point";
  19026. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.setPoints(c), this._tension = d, !0) : !1
  19027. },
  19028. clone: function() {
  19029. var a = new cc.CardinalSplineTo;
  19030. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  19031. return a
  19032. },
  19033. startWithTarget: function(a) {
  19034. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19035. this._deltaT = 1 / (this._points.length - 1);
  19036. this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
  19037. this._accumulatedDiff = cc.p(0, 0)
  19038. },
  19039. update: function(a) {
  19040. a = this._computeEaseTime(a);
  19041. var c, d = this._points;
  19042. if (1 == a) c = d.length - 1, a = 1;
  19043. else {
  19044. var e = this._deltaT;
  19045. c = 0 | a / e;
  19046. a = (a - e * c) / e
  19047. }
  19048. 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);
  19049. 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;
  19050. this.updatePosition(c)
  19051. },
  19052. reverse: function() {
  19053. var a = cc.reverseControlPoints(this._points);
  19054. return cc.cardinalSplineTo(this._duration, a, this._tension)
  19055. },
  19056. updatePosition: function(a) {
  19057. this.target.setPosition(a);
  19058. this._previousPosition = a
  19059. },
  19060. getPoints: function() {
  19061. return this._points
  19062. },
  19063. setPoints: function(a) {
  19064. this._points = a
  19065. }
  19066. });
  19067. cc.cardinalSplineTo = function(a, c, d) {
  19068. return new cc.CardinalSplineTo(a, c, d)
  19069. };
  19070. cc.CardinalSplineTo.create = cc.cardinalSplineTo;
  19071. cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
  19072. _startPosition: null,
  19073. ctor: function(a, c, d) {
  19074. cc.CardinalSplineTo.prototype.ctor.call(this);
  19075. this._startPosition = cc.p(0, 0);
  19076. void 0 !== d && this.initWithDuration(a, c, d)
  19077. },
  19078. startWithTarget: function(a) {
  19079. cc.CardinalSplineTo.prototype.startWithTarget.call(this, a);
  19080. this._startPosition.x = a.getPositionX();
  19081. this._startPosition.y = a.getPositionY()
  19082. },
  19083. reverse: function() {
  19084. 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;
  19085. a = cc.reverseControlPoints(a);
  19086. d = a[a.length - 1];
  19087. a.pop();
  19088. d.x = -d.x;
  19089. d.y = -d.y;
  19090. a.unshift(d);
  19091. 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;
  19092. return cc.cardinalSplineBy(this._duration, a, this._tension)
  19093. },
  19094. updatePosition: function(a) {
  19095. var c = this._startPosition,
  19096. d = a.x + c.x;
  19097. a = a.y + c.y;
  19098. this._previousPosition.x = d;
  19099. this._previousPosition.y = a;
  19100. this.target.setPosition(d, a)
  19101. },
  19102. clone: function() {
  19103. var a = new cc.CardinalSplineBy;
  19104. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  19105. return a
  19106. }
  19107. });
  19108. cc.cardinalSplineBy = function(a, c, d) {
  19109. return new cc.CardinalSplineBy(a, c, d)
  19110. };
  19111. cc.CardinalSplineBy.create = cc.cardinalSplineBy;
  19112. cc.CatmullRomTo = cc.CardinalSplineTo.extend({
  19113. ctor: function(a, c) {
  19114. c && this.initWithDuration(a, c)
  19115. },
  19116. initWithDuration: function(a, c) {
  19117. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, c, 0.5)
  19118. },
  19119. clone: function() {
  19120. var a = new cc.CatmullRomTo;
  19121. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  19122. return a
  19123. }
  19124. });
  19125. cc.catmullRomTo = function(a, c) {
  19126. return new cc.CatmullRomTo(a, c)
  19127. };
  19128. cc.CatmullRomTo.create = cc.catmullRomTo;
  19129. cc.CatmullRomBy = cc.CardinalSplineBy.extend({
  19130. ctor: function(a, c) {
  19131. cc.CardinalSplineBy.prototype.ctor.call(this);
  19132. c && this.initWithDuration(a, c)
  19133. },
  19134. initWithDuration: function(a, c) {
  19135. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, c, 0.5)
  19136. },
  19137. clone: function() {
  19138. var a = new cc.CatmullRomBy;
  19139. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  19140. return a
  19141. }
  19142. });
  19143. cc.catmullRomBy = function(a, c) {
  19144. return new cc.CatmullRomBy(a, c)
  19145. };
  19146. cc.CatmullRomBy.create = cc.catmullRomBy;
  19147. cc.ActionTweenDelegate = cc.Class.extend({
  19148. updateTweenAction: function(a, c) {}
  19149. });
  19150. cc.ActionTween = cc.ActionInterval.extend({
  19151. key: "",
  19152. from: 0,
  19153. to: 0,
  19154. delta: 0,
  19155. ctor: function(a, c, d, e) {
  19156. cc.ActionInterval.prototype.ctor.call(this);
  19157. this.key = "";
  19158. void 0 !== e && this.initWithDuration(a, c, d, e)
  19159. },
  19160. initWithDuration: function(a, c, d, e) {
  19161. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.key = c, this.to = e, this.from = d, !0) : !1
  19162. },
  19163. startWithTarget: function(a) {
  19164. if (!a || !a.updateTweenAction) throw "cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
  19165. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19166. this.delta = this.to - this.from
  19167. },
  19168. update: function(a) {
  19169. this.target.updateTweenAction(this.to - this.delta * (1 - a), this.key)
  19170. },
  19171. reverse: function() {
  19172. return cc.actionTween(this.duration, this.key, this.to, this.from)
  19173. },
  19174. clone: function() {
  19175. var a = new cc.ActionTween;
  19176. a.initWithDuration(this._duration, this.key, this.from, this.to);
  19177. return a
  19178. }
  19179. });
  19180. cc.actionTween = function(a, c, d, e) {
  19181. return new cc.ActionTween(a, c, d, e)
  19182. };
  19183. cc.ActionTween.create = cc.actionTween;
  19184. cc.GridAction = cc.ActionInterval.extend({
  19185. _gridSize: null,
  19186. ctor: function(a, c) {
  19187. cc._checkWebGLRenderMode();
  19188. cc.ActionInterval.prototype.ctor.call(this);
  19189. this._gridSize = cc.size(0, 0);
  19190. c && this.initWithDuration(a, c)
  19191. },
  19192. clone: function() {
  19193. var a = new cc.GridAction,
  19194. c = this._gridSize;
  19195. a.initWithDuration(this._duration, cc.size(c.width, c.height));
  19196. return a
  19197. },
  19198. startWithTarget: function(a) {
  19199. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19200. var c = this.getGrid(),
  19201. d = this.target;
  19202. (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))
  19203. },
  19204. reverse: function() {
  19205. return cc.ReverseTime.create(this)
  19206. },
  19207. initWithDuration: function(a, c) {
  19208. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._gridSize.width = c.width, this._gridSize.height = c.height, !0) : !1
  19209. },
  19210. getGrid: function() {
  19211. cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.")
  19212. }
  19213. });
  19214. cc.gridAction = function(a, c) {
  19215. return new cc.GridAction(a, c)
  19216. };
  19217. cc.GridAction.create = cc.gridAction;
  19218. cc.Grid3DAction = cc.GridAction.extend({
  19219. getGrid: function() {
  19220. return cc.Grid3D.create(this._gridSize)
  19221. },
  19222. vertex: function(a) {
  19223. return this.target.grid.vertex(a)
  19224. },
  19225. originalVertex: function(a) {
  19226. return this.target.grid.originalVertex(a)
  19227. },
  19228. setVertex: function(a, c) {
  19229. this.target.grid.setVertex(a, c)
  19230. }
  19231. });
  19232. cc.grid3DAction = function(a, c) {
  19233. return new cc.Grid3DAction(a, c)
  19234. };
  19235. cc.Grid3DAction.create = cc.grid3DAction;
  19236. cc.TiledGrid3DAction = cc.GridAction.extend({
  19237. tile: function(a) {
  19238. return this.target.grid.tile(a)
  19239. },
  19240. originalTile: function(a) {
  19241. return this.target.grid.originalTile(a)
  19242. },
  19243. setTile: function(a, c) {
  19244. this.target.grid.setTile(a, c)
  19245. },
  19246. getGrid: function() {
  19247. return cc.TiledGrid3D.create(this._gridSize)
  19248. }
  19249. });
  19250. cc.tiledGrid3DAction = function(a, c) {
  19251. return new cc.TiledGrid3DAction(a, c)
  19252. };
  19253. cc.TiledGrid3DAction.create = cc.tiledGrid3DAction;
  19254. cc.StopGrid = cc.ActionInstant.extend({
  19255. startWithTarget: function(a) {
  19256. cc.ActionInstant.prototype.startWithTarget.call(this, a);
  19257. (a = this.target.grid) && a.isActive() && a.setActive(!1)
  19258. }
  19259. });
  19260. cc.stopGrid = function() {
  19261. return new cc.StopGrid
  19262. };
  19263. cc.StopGrid.create = cc.stopGrid;
  19264. cc.ReuseGrid = cc.ActionInstant.extend({
  19265. _times: null,
  19266. ctor: function(a) {
  19267. cc.ActionInstant.prototype.ctor.call(this);
  19268. void 0 !== a && this.initWithTimes(a)
  19269. },
  19270. initWithTimes: function(a) {
  19271. this._times = a;
  19272. return !0
  19273. },
  19274. startWithTarget: function(a) {
  19275. cc.ActionInstant.prototype.startWithTarget.call(this, a);
  19276. this.target.grid && this.target.grid.isActive() && this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times)
  19277. }
  19278. });
  19279. cc.reuseGrid = function(a) {
  19280. return new cc.ReuseGrid(a)
  19281. };
  19282. cc.ReuseGrid.create = cc.reuseGrid;
  19283. cc.Waves3D = cc.Grid3DAction.extend({
  19284. _waves: 0,
  19285. _amplitude: 0,
  19286. _amplitudeRate: 0,
  19287. ctor: function(a, c, d, e) {
  19288. cc.GridAction.prototype.ctor.call(this);
  19289. void 0 !== e && this.initWithDuration(a, c, d, e)
  19290. },
  19291. getAmplitude: function() {
  19292. return this._amplitude
  19293. },
  19294. setAmplitude: function(a) {
  19295. this._amplitude = a
  19296. },
  19297. getAmplitudeRate: function() {
  19298. return this._amplitudeRate
  19299. },
  19300. setAmplitudeRate: function(a) {
  19301. this._amplitudeRate = a
  19302. },
  19303. initWithDuration: function(a, c, d, e) {
  19304. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
  19305. },
  19306. update: function(a) {
  19307. 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)
  19308. for (var k = 0; k < c.height + 1; ++k) {
  19309. e.x = h;
  19310. e.y = k;
  19311. var m = this.originalVertex(e);
  19312. m.z += Math.sin(2 * Math.PI * a * g + 0.01 * (m.y + m.x)) * d * f;
  19313. this.setVertex(e, m)
  19314. }
  19315. }
  19316. });
  19317. cc.waves3D = function(a, c, d, e) {
  19318. return new cc.Waves3D(a, c, d, e)
  19319. };
  19320. cc.Waves3D.create = cc.waves3D;
  19321. cc.FlipX3D = cc.Grid3DAction.extend({
  19322. ctor: function(a) {
  19323. void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
  19324. },
  19325. initWithDuration: function(a) {
  19326. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, 1))
  19327. },
  19328. initWithSize: function(a, c) {
  19329. return 1 != a.width || 1 != a.height ? (cc.log("Grid size must be (1,1)"), !1) : cc.Grid3DAction.prototype.initWithDuration.call(this, c, a)
  19330. },
  19331. update: function(a) {
  19332. var c = Math.PI * a;
  19333. a = Math.sin(c);
  19334. var d = Math.cos(c / 2),
  19335. c = new cc.Vertex3F,
  19336. e = cc.p(0, 0);
  19337. e.x = e.y = 1;
  19338. var f = this.originalVertex(e);
  19339. e.x = e.y = 0;
  19340. var e = this.originalVertex(e),
  19341. g = f.x,
  19342. h = e.x,
  19343. k, m;
  19344. 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);
  19345. c.x = g - g * d;
  19346. c.z = Math.abs(parseFloat(g * a / 4));
  19347. a = this.originalVertex(f);
  19348. a.x = c.x;
  19349. a.z += c.z;
  19350. this.setVertex(f, a);
  19351. a = this.originalVertex(e);
  19352. a.x = c.x;
  19353. a.z += c.z;
  19354. this.setVertex(e, a);
  19355. a = this.originalVertex(k);
  19356. a.x -= c.x;
  19357. a.z -= c.z;
  19358. this.setVertex(k, a);
  19359. a = this.originalVertex(m);
  19360. a.x -= c.x;
  19361. a.z -= c.z;
  19362. this.setVertex(m, a)
  19363. }
  19364. });
  19365. cc.flipX3D = function(a) {
  19366. return new cc.FlipX3D(a)
  19367. };
  19368. cc.FlipX3D.create = cc.flipX3D;
  19369. cc.FlipY3D = cc.FlipX3D.extend({
  19370. ctor: function(a) {
  19371. void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
  19372. },
  19373. update: function(a) {
  19374. var c = Math.PI * a;
  19375. a = Math.sin(c);
  19376. var d = Math.cos(c / 2),
  19377. c = new cc.Vertex3F,
  19378. e = cc.p(0, 0);
  19379. e.x = e.y = 1;
  19380. var f = this.originalVertex(e);
  19381. e.x = e.y = 0;
  19382. var e = this.originalVertex(e),
  19383. g = f.y,
  19384. h = e.y,
  19385. k, m;
  19386. 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);
  19387. c.y = g - g * d;
  19388. c.z = Math.abs(parseFloat(g * a) / 4);
  19389. a = this.originalVertex(f);
  19390. a.y = c.y;
  19391. a.z += c.z;
  19392. this.setVertex(f, a);
  19393. a = this.originalVertex(e);
  19394. a.y -= c.y;
  19395. a.z -= c.z;
  19396. this.setVertex(e, a);
  19397. a = this.originalVertex(k);
  19398. a.y = c.y;
  19399. a.z += c.z;
  19400. this.setVertex(k, a);
  19401. a = this.originalVertex(m);
  19402. a.y -= c.y;
  19403. a.z -= c.z;
  19404. this.setVertex(m, a)
  19405. }
  19406. });
  19407. cc.flipY3D = function(a) {
  19408. return new cc.FlipY3D(a)
  19409. };
  19410. cc.FlipY3D.create = cc.flipY3D;
  19411. cc.Lens3D = cc.Grid3DAction.extend({
  19412. _position: null,
  19413. _radius: 0,
  19414. _lensEffect: 0,
  19415. _concave: !1,
  19416. _dirty: !1,
  19417. ctor: function(a, c, d, e) {
  19418. cc.GridAction.prototype.ctor.call(this);
  19419. this._position = cc.p(0, 0);
  19420. void 0 !== e && this.initWithDuration(a, c, d, e)
  19421. },
  19422. getLensEffect: function() {
  19423. return this._lensEffect
  19424. },
  19425. setLensEffect: function(a) {
  19426. this._lensEffect = a
  19427. },
  19428. setConcave: function(a) {
  19429. this._concave = a
  19430. },
  19431. getPosition: function() {
  19432. return this._position
  19433. },
  19434. setPosition: function(a) {
  19435. cc.pointEqualToPoint(a, this._position) || (this._position.x = a.x, this._position.y = a.y, this._dirty = !0)
  19436. },
  19437. initWithDuration: function(a, c, d, e) {
  19438. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this.setPosition(d), this._radius = e, this._lensEffect = 0.7, this._dirty = !0) : !1
  19439. },
  19440. update: function(a) {
  19441. if (this._dirty) {
  19442. a = this._gridSize.width;
  19443. 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)
  19444. 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);
  19445. this._dirty = !1
  19446. }
  19447. }
  19448. });
  19449. cc.lens3D = function(a, c, d, e) {
  19450. return new cc.Lens3D(a, c, d, e)
  19451. };
  19452. cc.Lens3D.create = cc.lens3D;
  19453. cc.Ripple3D = cc.Grid3DAction.extend({
  19454. _position: null,
  19455. _radius: 0,
  19456. _waves: 0,
  19457. _amplitude: 0,
  19458. _amplitudeRate: 0,
  19459. ctor: function(a, c, d, e, f, g) {
  19460. cc.GridAction.prototype.ctor.call(this);
  19461. this._position = cc.p(0, 0);
  19462. void 0 !== g && this.initWithDuration(a, c, d, e, f, g)
  19463. },
  19464. getPosition: function() {
  19465. return this._position
  19466. },
  19467. setPosition: function(a) {
  19468. this._position.x = a.x;
  19469. this._position.y = a.y
  19470. },
  19471. getAmplitude: function() {
  19472. return this._amplitude
  19473. },
  19474. setAmplitude: function(a) {
  19475. this._amplitude = a
  19476. },
  19477. getAmplitudeRate: function() {
  19478. return this._amplitudeRate
  19479. },
  19480. setAmplitudeRate: function(a) {
  19481. this._amplitudeRate = a
  19482. },
  19483. initWithDuration: function(a, c, d, e, f, g) {
  19484. 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
  19485. },
  19486. update: function(a) {
  19487. 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)
  19488. for (var t = 0; t < d + 1; ++t) {
  19489. e.x = r;
  19490. e.y = t;
  19491. m = this.originalVertex(e);
  19492. q.x = this._position.x - m.x;
  19493. q.y = this._position.y - m.y;
  19494. n = cc.pLength(q);
  19495. if (n < f) {
  19496. n = f - n;
  19497. var s = Math.pow(n / f, 2);
  19498. m.z += Math.sin(2 * a * Math.PI * g + 0.1 * n) * h * k * s
  19499. }
  19500. this.setVertex(e, m)
  19501. }
  19502. }
  19503. });
  19504. cc.ripple3D = function(a, c, d, e, f, g) {
  19505. return new cc.Ripple3D(a, c, d, e, f, g)
  19506. };
  19507. cc.Ripple3D.create = cc.ripple3D;
  19508. cc.Shaky3D = cc.Grid3DAction.extend({
  19509. _randRange: 0,
  19510. _shakeZ: !1,
  19511. ctor: function(a, c, d, e) {
  19512. cc.GridAction.prototype.ctor.call(this);
  19513. void 0 !== e && this.initWithDuration(a, c, d, e)
  19514. },
  19515. initWithDuration: function(a, c, d, e) {
  19516. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._randRange = d, this._shakeZ = e, !0) : !1
  19517. },
  19518. update: function(a) {
  19519. a = this._gridSize.width;
  19520. for (var c = this._gridSize.height, d = this._randRange, e = this._shakeZ, f = cc.p(0, 0), g, h = 0; h < a + 1; ++h)
  19521. 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)
  19522. }
  19523. });
  19524. cc.shaky3D = function(a, c, d, e) {
  19525. return new cc.Shaky3D(a, c, d, e)
  19526. };
  19527. cc.Shaky3D.create = cc.shaky3D;
  19528. cc.Liquid = cc.Grid3DAction.extend({
  19529. _waves: 0,
  19530. _amplitude: 0,
  19531. _amplitudeRate: 0,
  19532. ctor: function(a, c, d, e) {
  19533. cc.GridAction.prototype.ctor.call(this);
  19534. void 0 !== e && this.initWithDuration(a, c, d, e)
  19535. },
  19536. getAmplitude: function() {
  19537. return this._amplitude
  19538. },
  19539. setAmplitude: function(a) {
  19540. this._amplitude = a
  19541. },
  19542. getAmplitudeRate: function() {
  19543. return this._amplitudeRate
  19544. },
  19545. setAmplitudeRate: function(a) {
  19546. this._amplitudeRate = a
  19547. },
  19548. initWithDuration: function(a, c, d, e) {
  19549. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
  19550. },
  19551. update: function(a) {
  19552. 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)
  19553. 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)
  19554. }
  19555. });
  19556. cc.liquid = function(a, c, d, e) {
  19557. return new cc.Liquid(a, c, d, e)
  19558. };
  19559. cc.Liquid.create = cc.liquid;
  19560. cc.Waves = cc.Grid3DAction.extend({
  19561. _waves: 0,
  19562. _amplitude: 0,
  19563. _amplitudeRate: 0,
  19564. _vertical: !1,
  19565. _horizontal: !1,
  19566. ctor: function(a, c, d, e, f, g) {
  19567. cc.GridAction.prototype.ctor.call(this);
  19568. void 0 !== g && this.initWithDuration(a, c, d, e, f, g)
  19569. },
  19570. getAmplitude: function() {
  19571. return this._amplitude
  19572. },
  19573. setAmplitude: function(a) {
  19574. this._amplitude = a
  19575. },
  19576. getAmplitudeRate: function() {
  19577. return this._amplitudeRate
  19578. },
  19579. setAmplitudeRate: function(a) {
  19580. this._amplitudeRate = a
  19581. },
  19582. initWithDuration: function(a, c, d, e, f, g) {
  19583. 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
  19584. },
  19585. update: function(a) {
  19586. 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)
  19587. 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)
  19588. }
  19589. });
  19590. cc.waves = function(a, c, d, e, f, g) {
  19591. return new cc.Waves(a, c, d, e, f, g)
  19592. };
  19593. cc.Waves.create = cc.waves;
  19594. cc.Twirl = cc.Grid3DAction.extend({
  19595. _position: null,
  19596. _twirls: 0,
  19597. _amplitude: 0,
  19598. _amplitudeRate: 0,
  19599. ctor: function(a, c, d, e, f) {
  19600. cc.GridAction.prototype.ctor.call(this);
  19601. this._position = cc.p(0, 0);
  19602. void 0 !== f && this.initWithDuration(a, c, d, e, f)
  19603. },
  19604. getPosition: function() {
  19605. return this._position
  19606. },
  19607. setPosition: function(a) {
  19608. this._position.x = a.x;
  19609. this._position.y = a.y
  19610. },
  19611. getAmplitude: function() {
  19612. return this._amplitude
  19613. },
  19614. setAmplitude: function(a) {
  19615. this._amplitude = a
  19616. },
  19617. getAmplitudeRate: function() {
  19618. return this._amplitudeRate
  19619. },
  19620. setAmplitudeRate: function(a) {
  19621. this._amplitudeRate = a
  19622. },
  19623. initWithDuration: function(a, c, d, e, f) {
  19624. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, c) ? (this.setPosition(d), this._twirls = e, this._amplitude = f, this._amplitudeRate = 1, !0) : !1
  19625. },
  19626. update: function(a) {
  19627. 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)
  19628. 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)
  19629. }
  19630. });
  19631. cc.twirl = function(a, c, d, e, f) {
  19632. return new cc.Twirl(a, c, d, e, f)
  19633. };
  19634. cc.Twirl.create = cc.twirl;
  19635. cc.ShakyTiles3D = cc.TiledGrid3DAction.extend({
  19636. _randRange: 0,
  19637. _shakeZ: !1,
  19638. ctor: function(a, c, d, e) {
  19639. cc.GridAction.prototype.ctor.call(this);
  19640. void 0 !== e && this.initWithDuration(a, c, d, e)
  19641. },
  19642. initWithDuration: function(a, c, d, e) {
  19643. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._randRange = d, this._shakeZ = e, !0) : !1
  19644. },
  19645. update: function(a) {
  19646. a = this._gridSize;
  19647. for (var c = this._randRange, d = cc.p(0, 0), e = 0; e < a.width; ++e)
  19648. for (var f = 0; f < a.height; ++f) {
  19649. d.x = e;
  19650. d.y = f;
  19651. var g = this.originalTile(d);
  19652. g.bl.x += cc.rand() % (2 * c) - c;
  19653. g.br.x += cc.rand() % (2 * c) - c;
  19654. g.tl.x += cc.rand() % (2 * c) - c;
  19655. g.tr.x += cc.rand() % (2 * c) - c;
  19656. g.bl.y += cc.rand() % (2 * c) - c;
  19657. g.br.y += cc.rand() % (2 * c) - c;
  19658. g.tl.y += cc.rand() % (2 * c) - c;
  19659. g.tr.y += cc.rand() % (2 * c) - c;
  19660. 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);
  19661. this.setTile(d, g)
  19662. }
  19663. }
  19664. });
  19665. cc.shakyTiles3D = function(a, c, d, e) {
  19666. return new cc.ShakyTiles3D(a, c, d, e)
  19667. };
  19668. cc.ShakyTiles3D.create = cc.shakyTiles3D;
  19669. cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend({
  19670. _randRange: 0,
  19671. _once: !1,
  19672. _shatterZ: !1,
  19673. ctor: function(a, c, d, e) {
  19674. cc.GridAction.prototype.ctor.call(this);
  19675. void 0 !== e && this.initWithDuration(a, c, d, e)
  19676. },
  19677. initWithDuration: function(a, c, d, e) {
  19678. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._once = !1, this._randRange = d, this._shatterZ = e, !0) : !1
  19679. },
  19680. update: function(a) {
  19681. if (!1 === this._once) {
  19682. a = this._gridSize;
  19683. for (var c = this._randRange, d, e = cc.p(0, 0), f = 0; f < a.width; ++f)
  19684. 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);
  19685. this._once = !0
  19686. }
  19687. }
  19688. });
  19689. cc.shatteredTiles3D = function(a, c, d, e) {
  19690. return new cc.ShatteredTiles3D(a, c, d, e)
  19691. };
  19692. cc.ShatteredTiles3D.create = cc.shatteredTiles3D;
  19693. cc.Tile = function(a, c, d) {
  19694. this.position = a || cc.p(0, 0);
  19695. this.startPosition = c || cc.p(0, 0);
  19696. this.delta = d || cc.p(0, 0)
  19697. };
  19698. cc.ShuffleTiles = cc.TiledGrid3DAction.extend({
  19699. _seed: 0,
  19700. _tilesCount: 0,
  19701. _tilesOrder: null,
  19702. _tiles: null,
  19703. ctor: function(a, c, d) {
  19704. cc.GridAction.prototype.ctor.call(this);
  19705. this._tilesOrder = [];
  19706. this._tiles = [];
  19707. void 0 !== d && this.initWithDuration(a, c, d)
  19708. },
  19709. initWithDuration: function(a, c, d) {
  19710. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._seed = d, this._tilesOrder.length = 0, this._tiles.length = 0, !0) : !1
  19711. },
  19712. shuffle: function(a, c) {
  19713. for (var d = c - 1; 0 <= d; d--) {
  19714. var e = 0 | cc.rand() % (d + 1),
  19715. f = a[d];
  19716. a[d] = a[e];
  19717. a[e] = f
  19718. }
  19719. },
  19720. getDelta: function(a) {
  19721. var c = this._gridSize,
  19722. d = a.width * c.height + a.height;
  19723. return cc.size(this._tilesOrder[d] / c.height - a.width, this._tilesOrder[d] % c.height - a.height)
  19724. },
  19725. placeTile: function(a, c) {
  19726. var d = this.originalTile(a),
  19727. e = this.target.grid.getStep(),
  19728. f = c.position;
  19729. d.bl.x += f.x * e.x;
  19730. d.bl.y += f.y * e.y;
  19731. d.br.x += f.x * e.x;
  19732. d.br.y += f.y * e.y;
  19733. d.tl.x += f.x * e.x;
  19734. d.tl.y += f.y * e.y;
  19735. d.tr.x += f.x * e.x;
  19736. d.tr.y += f.y * e.y;
  19737. this.setTile(a, d)
  19738. },
  19739. startWithTarget: function(a) {
  19740. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  19741. a = this._gridSize;
  19742. this._tilesCount = a.width * a.height;
  19743. for (var c = this._tilesOrder, d = c.length = 0; d < this._tilesCount; ++d) c[d] = d;
  19744. this.shuffle(c, this._tilesCount);
  19745. for (var c = this._tiles, d = c.length = 0, e = cc.size(0, 0), f = 0; f < a.width; ++f)
  19746. 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
  19747. },
  19748. update: function(a) {
  19749. for (var c = 0, d = this._gridSize, e = this._tiles, f, g = cc.p(0, 0), h = 0; h < d.width; ++h)
  19750. 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
  19751. }
  19752. });
  19753. cc.shuffleTiles = function(a, c, d) {
  19754. return new cc.ShuffleTiles(a, c, d)
  19755. };
  19756. cc.ShuffleTiles.create = cc.shuffleTiles;
  19757. cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend({
  19758. testFunc: function(a, c) {
  19759. var d = this._gridSize.width * c,
  19760. e = this._gridSize.height * c;
  19761. return 0 == d + e ? 1 : Math.pow((a.width + a.height) / (d + e), 6)
  19762. },
  19763. turnOnTile: function(a) {
  19764. this.setTile(a, this.originalTile(a))
  19765. },
  19766. turnOffTile: function(a) {
  19767. this.setTile(a, new cc.Quad3)
  19768. },
  19769. transformTile: function(a, c) {
  19770. var d = this.originalTile(a),
  19771. e = this.target.grid.getStep();
  19772. d.bl.x += e.x / 2 * (1 - c);
  19773. d.bl.y += e.y / 2 * (1 - c);
  19774. d.br.x -= e.x / 2 * (1 - c);
  19775. d.br.y += e.y / 2 * (1 - c);
  19776. d.tl.x += e.x / 2 * (1 - c);
  19777. d.tl.y -= e.y / 2 * (1 - c);
  19778. d.tr.x -= e.x / 2 * (1 - c);
  19779. d.tr.y -= e.y / 2 * (1 - c);
  19780. this.setTile(a, d)
  19781. },
  19782. update: function(a) {
  19783. for (var c = this._gridSize, d = cc.p(0, 0), e = cc.size(0, 0), f, g = 0; g < c.width; ++g)
  19784. 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)
  19785. }
  19786. });
  19787. cc.fadeOutTRTiles = function(a, c) {
  19788. return new cc.FadeOutTRTiles(a, c)
  19789. };
  19790. cc.FadeOutTRTiles.create = cc.fadeOutTRTiles;
  19791. cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend({
  19792. testFunc: function(a, c) {
  19793. return 0 == a.width + a.height ? 1 : Math.pow((this._gridSize.width * (1 - c) + this._gridSize.height * (1 - c)) / (a.width + a.height), 6)
  19794. }
  19795. });
  19796. cc.fadeOutBLTiles = function(a, c) {
  19797. return new cc.FadeOutBLTiles(a, c)
  19798. };
  19799. cc.FadeOutBLTiles.create = cc.fadeOutBLTiles;
  19800. cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend({
  19801. testFunc: function(a, c) {
  19802. var d = this._gridSize.height * c;
  19803. return 0 == d ? 1 : Math.pow(a.height / d, 6)
  19804. },
  19805. transformTile: function(a, c) {
  19806. var d = this.originalTile(a),
  19807. e = this.target.grid.getStep();
  19808. d.bl.y += e.y / 2 * (1 - c);
  19809. d.br.y += e.y / 2 * (1 - c);
  19810. d.tl.y -= e.y / 2 * (1 - c);
  19811. d.tr.y -= e.y / 2 * (1 - c);
  19812. this.setTile(a, d)
  19813. }
  19814. });
  19815. cc.fadeOutUpTiles = function(a, c) {
  19816. return new cc.FadeOutUpTiles(a, c)
  19817. };
  19818. cc.FadeOutUpTiles.create = cc.fadeOutUpTiles;
  19819. cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend({
  19820. testFunc: function(a, c) {
  19821. return 0 == a.height ? 1 : Math.pow(this._gridSize.height * (1 - c) / a.height, 6)
  19822. }
  19823. });
  19824. cc.fadeOutDownTiles = function(a, c) {
  19825. return new cc.FadeOutDownTiles(a, c)
  19826. };
  19827. cc.FadeOutDownTiles.create = cc.fadeOutDownTiles;
  19828. cc.TurnOffTiles = cc.TiledGrid3DAction.extend({
  19829. _seed: null,
  19830. _tilesCount: 0,
  19831. _tilesOrder: null,
  19832. ctor: function(a, c, d) {
  19833. cc.GridAction.prototype.ctor.call(this);
  19834. this._tilesOrder = [];
  19835. void 0 !== c && this.initWithDuration(a, c, d)
  19836. },
  19837. initWithDuration: function(a, c, d) {
  19838. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._seed = d || 0, this._tilesOrder.length = 0, !0) : !1
  19839. },
  19840. shuffle: function(a, c) {
  19841. for (var d = c - 1; 0 <= d; d--) {
  19842. var e = 0 | cc.rand() % (d + 1),
  19843. f = a[d];
  19844. a[d] = a[e];
  19845. a[e] = f
  19846. }
  19847. },
  19848. turnOnTile: function(a) {
  19849. this.setTile(a, this.originalTile(a))
  19850. },
  19851. turnOffTile: function(a) {
  19852. this.setTile(a, new cc.Quad3)
  19853. },
  19854. startWithTarget: function(a) {
  19855. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  19856. this._tilesCount = this._gridSize.width * this._gridSize.height;
  19857. a = this._tilesOrder;
  19858. for (var c = a.length = 0; c < this._tilesCount; ++c) a[c] = c;
  19859. this.shuffle(a, this._tilesCount)
  19860. },
  19861. update: function(a) {
  19862. a = 0 | a * this._tilesCount;
  19863. 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)
  19864. }
  19865. });
  19866. cc.turnOffTiles = function(a, c, d) {
  19867. return new cc.TurnOffTiles(a, c, d)
  19868. };
  19869. cc.TurnOffTiles.create = cc.turnOffTiles;
  19870. cc.WavesTiles3D = cc.TiledGrid3DAction.extend({
  19871. _waves: 0,
  19872. _amplitude: 0,
  19873. _amplitudeRate: 0,
  19874. ctor: function(a, c, d, e) {
  19875. cc.GridAction.prototype.ctor.call(this);
  19876. void 0 !== e && this.initWithDuration(a, c, d, e)
  19877. },
  19878. getAmplitude: function() {
  19879. return this._amplitude
  19880. },
  19881. setAmplitude: function(a) {
  19882. this._amplitude = a
  19883. },
  19884. getAmplitudeRate: function() {
  19885. return this._amplitudeRate
  19886. },
  19887. setAmplitudeRate: function(a) {
  19888. this._amplitudeRate = a
  19889. },
  19890. initWithDuration: function(a, c, d, e) {
  19891. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._waves = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
  19892. },
  19893. update: function(a) {
  19894. 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++)
  19895. 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)
  19896. }
  19897. });
  19898. cc.wavesTiles3D = function(a, c, d, e) {
  19899. return new cc.WavesTiles3D(a, c, d, e)
  19900. };
  19901. cc.WavesTiles3D.create = cc.wavesTiles3D;
  19902. cc.JumpTiles3D = cc.TiledGrid3DAction.extend({
  19903. _jumps: 0,
  19904. _amplitude: 0,
  19905. _amplitudeRate: 0,
  19906. ctor: function(a, c, d, e) {
  19907. cc.GridAction.prototype.ctor.call(this);
  19908. void 0 !== e && this.initWithDuration(a, c, d, e)
  19909. },
  19910. getAmplitude: function() {
  19911. return this._amplitude
  19912. },
  19913. setAmplitude: function(a) {
  19914. this._amplitude = a
  19915. },
  19916. getAmplitudeRate: function() {
  19917. return this._amplitudeRate
  19918. },
  19919. setAmplitudeRate: function(a) {
  19920. this._amplitudeRate = a
  19921. },
  19922. initWithDuration: function(a, c, d, e) {
  19923. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, c) ? (this._jumps = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
  19924. },
  19925. update: function(a) {
  19926. var c = Math.sin(2 * Math.PI * a * this._jumps) * this._amplitude * this._amplitudeRate;
  19927. a = Math.sin(Math.PI * (2 * a * this._jumps + 1)) * this._amplitude * this._amplitudeRate;
  19928. for (var d = this._gridSize, e = this.target.grid, f, g = cc.p(0, 0), h = 0; h < d.width; h++)
  19929. 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)
  19930. }
  19931. });
  19932. cc.jumpTiles3D = function(a, c, d, e) {
  19933. return new cc.JumpTiles3D(a, c, d, e)
  19934. };
  19935. cc.JumpTiles3D.create = cc.jumpTiles3D;
  19936. cc.SplitRows = cc.TiledGrid3DAction.extend({
  19937. _rows: 0,
  19938. _winSize: null,
  19939. ctor: function(a, c) {
  19940. cc.GridAction.prototype.ctor.call(this);
  19941. void 0 !== c && this.initWithDuration(a, c)
  19942. },
  19943. initWithDuration: function(a, c) {
  19944. this._rows = c;
  19945. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, c))
  19946. },
  19947. update: function(a) {
  19948. 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)
  19949. },
  19950. startWithTarget: function(a) {
  19951. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  19952. this._winSize = cc.director.getWinSizeInPixels()
  19953. }
  19954. });
  19955. cc.splitRows = function(a, c) {
  19956. return new cc.SplitRows(a, c)
  19957. };
  19958. cc.SplitRows.create = cc.splitRows;
  19959. cc.SplitCols = cc.TiledGrid3DAction.extend({
  19960. _cols: 0,
  19961. _winSize: null,
  19962. ctor: function(a, c) {
  19963. cc.GridAction.prototype.ctor.call(this);
  19964. void 0 !== c && this.initWithDuration(a, c)
  19965. },
  19966. initWithDuration: function(a, c) {
  19967. this._cols = c;
  19968. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(c, 1))
  19969. },
  19970. update: function(a) {
  19971. 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)
  19972. },
  19973. startWithTarget: function(a) {
  19974. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  19975. this._winSize = cc.director.getWinSizeInPixels()
  19976. }
  19977. });
  19978. cc.splitCols = function(a, c) {
  19979. return new cc.SplitCols(a, c)
  19980. };
  19981. cc.SplitCols.create = cc.splitCols;
  19982. cc.PageTurn3D = cc.Grid3DAction.extend({
  19983. update: function(a) {
  19984. var c = Math.max(0, a - 0.25),
  19985. c = -100 - 500 * c * c;
  19986. a = -Math.PI / 2 * Math.sqrt(a);
  19987. var d = +Math.PI / 2 + a;
  19988. a = Math.sin(d);
  19989. for (var d = Math.cos(d), e = this._gridSize, f = cc.p(0, 0), g = 0; g <= e.width; ++g)
  19990. for (var h = 0; h <= e.height; ++h) {
  19991. f.x = g;
  19992. f.y = h;
  19993. var k = this.originalVertex(f),
  19994. m = Math.sqrt(k.x * k.x + (k.y - c) * (k.y - c)),
  19995. n = m * a,
  19996. q = Math.asin(k.x / m) / a,
  19997. r = Math.cos(q);
  19998. k.x = q <= Math.PI ? n * Math.sin(q) : 0;
  19999. k.y = m + c - n * (1 - r) * a;
  20000. k.z = n * (1 - r) * d / 7;
  20001. 0.5 > k.z && (k.z = 0.5);
  20002. this.setVertex(f, k)
  20003. }
  20004. }
  20005. });
  20006. cc.pageTurn3D = function(a, c) {
  20007. return new cc.PageTurn3D(a, c)
  20008. };
  20009. cc.PageTurn3D.create = cc.pageTurn3D;
  20010. cc.ProgressTimer = cc.Node.extend({
  20011. _type: null,
  20012. _percentage: 0,
  20013. _sprite: null,
  20014. _midPoint: null,
  20015. _barChangeRate: null,
  20016. _reverseDirection: !1,
  20017. _className: "ProgressTimer",
  20018. getMidpoint: function() {
  20019. return cc.p(this._midPoint.x, this._midPoint.y)
  20020. },
  20021. setMidpoint: function(a) {
  20022. this._midPoint = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
  20023. },
  20024. getBarChangeRate: function() {
  20025. return cc.p(this._barChangeRate.x, this._barChangeRate.y)
  20026. },
  20027. setBarChangeRate: function(a) {
  20028. this._barChangeRate = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
  20029. },
  20030. getType: function() {
  20031. return this._type
  20032. },
  20033. getPercentage: function() {
  20034. return this._percentage
  20035. },
  20036. getSprite: function() {
  20037. return this._sprite
  20038. },
  20039. setPercentage: function(a) {
  20040. this._percentage != a && (this._percentage = cc.clampf(a, 0, 100), this._updateProgress())
  20041. },
  20042. setOpacityModifyRGB: function(a) {},
  20043. isOpacityModifyRGB: function() {
  20044. return !1
  20045. },
  20046. isReverseDirection: function() {
  20047. return this._reverseDirection
  20048. },
  20049. _boundaryTexCoord: function(a) {
  20050. if (a < cc.ProgressTimer.TEXTURE_COORDS_COUNT) {
  20051. var c = cc.ProgressTimer.TEXTURE_COORDS;
  20052. 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)
  20053. }
  20054. return cc.p(0, 0)
  20055. },
  20056. _origin: null,
  20057. _startAngle: 270,
  20058. _endAngle: 270,
  20059. _radius: 0,
  20060. _counterClockWise: !1,
  20061. _barRect: null,
  20062. _vertexDataCount: 0,
  20063. _vertexData: null,
  20064. _vertexArrayBuffer: null,
  20065. _vertexWebGLBuffer: null,
  20066. _vertexDataDirty: !1,
  20067. ctor: null,
  20068. _ctorForCanvas: function(a) {
  20069. cc.Node.prototype.ctor.call(this);
  20070. this._type = cc.ProgressTimer.TYPE_RADIAL;
  20071. this._percentage = 0;
  20072. this._midPoint = cc.p(0, 0);
  20073. this._barChangeRate = cc.p(0, 0);
  20074. this._reverseDirection = !1;
  20075. this._sprite = null;
  20076. this._origin = cc.p(0, 0);
  20077. this._endAngle = this._startAngle = 270;
  20078. this._radius = 0;
  20079. this._counterClockWise = !1;
  20080. this._barRect = cc.rect(0, 0, 0, 0);
  20081. a && this._initWithSpriteForCanvas(a)
  20082. },
  20083. _ctorForWebGL: function(a) {
  20084. cc.Node.prototype.ctor.call(this);
  20085. this._type = cc.ProgressTimer.TYPE_RADIAL;
  20086. this._percentage = 0;
  20087. this._midPoint = cc.p(0, 0);
  20088. this._barChangeRate = cc.p(0, 0);
  20089. this._reverseDirection = !1;
  20090. this._sprite = null;
  20091. this._vertexWebGLBuffer = cc._renderContext.createBuffer();
  20092. this._vertexDataCount = 0;
  20093. this._vertexArrayBuffer = this._vertexData = null;
  20094. this._vertexDataDirty = !1;
  20095. a && this._initWithSpriteForWebGL(a)
  20096. },
  20097. setColor: function(a) {
  20098. this._sprite.color = a;
  20099. this._updateColor()
  20100. },
  20101. setOpacity: function(a) {
  20102. this._sprite.opacity = a;
  20103. this._updateColor()
  20104. },
  20105. getColor: function() {
  20106. return this._sprite.color
  20107. },
  20108. getOpacity: function() {
  20109. return this._sprite.opacity
  20110. },
  20111. setReverseProgress: null,
  20112. _setReverseProgressForCanvas: function(a) {
  20113. this._reverseDirection !== a && (this._reverseDirection = a)
  20114. },
  20115. _setReverseProgressForWebGL: function(a) {
  20116. this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
  20117. },
  20118. setSprite: null,
  20119. _setSpriteForCanvas: function(a) {
  20120. this._sprite != a && (this._sprite = a, this.width = this._sprite.width, this.height = this._sprite.height)
  20121. },
  20122. _setSpriteForWebGL: function(a) {
  20123. 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))
  20124. },
  20125. setType: null,
  20126. _setTypeForCanvas: function(a) {
  20127. a !== this._type && (this._type = a)
  20128. },
  20129. _setTypeForWebGL: function(a) {
  20130. a !== this._type && (this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0), this._type = a)
  20131. },
  20132. setReverseDirection: null,
  20133. _setReverseDirectionForCanvas: function(a) {
  20134. this._reverseDirection !== a && (this._reverseDirection = a)
  20135. },
  20136. _setReverseDirectionForWebGL: function(a) {
  20137. this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
  20138. },
  20139. _textureCoordFromAlphaPoint: function(a) {
  20140. var c = this._sprite;
  20141. if (!c) return {
  20142. u: 0,
  20143. v: 0
  20144. };
  20145. var d = c.quad,
  20146. e = cc.p(d.bl.texCoords.u, d.bl.texCoords.v),
  20147. d = cc.p(d.tr.texCoords.u, d.tr.texCoords.v);
  20148. c.textureRectRotated && (c = a.x, a.x = a.y, a.y = c);
  20149. return {
  20150. u: e.x * (1 - a.x) + d.x * a.x,
  20151. v: e.y * (1 - a.y) + d.y * a.y
  20152. }
  20153. },
  20154. _vertexFromAlphaPoint: function(a) {
  20155. if (!this._sprite) return {
  20156. x: 0,
  20157. y: 0
  20158. };
  20159. var c = this._sprite.quad,
  20160. d = cc.p(c.bl.vertices.x, c.bl.vertices.y),
  20161. c = cc.p(c.tr.vertices.x, c.tr.vertices.y);
  20162. return {
  20163. x: d.x * (1 - a.x) + c.x * a.x,
  20164. y: d.y * (1 - a.y) + c.y * a.y
  20165. }
  20166. },
  20167. initWithSprite: null,
  20168. _initWithSpriteForCanvas: function(a) {
  20169. this.percentage = 0;
  20170. this.anchorY = this.anchorX = 0.5;
  20171. this._type = cc.ProgressTimer.TYPE_RADIAL;
  20172. this._reverseDirection = !1;
  20173. this.midPoint = cc.p(0.5, 0.5);
  20174. this.barChangeRate = cc.p(1, 1);
  20175. this.sprite = a;
  20176. return !0
  20177. },
  20178. _initWithSpriteForWebGL: function(a) {
  20179. this.percentage = 0;
  20180. this._vertexArrayBuffer = this._vertexData = null;
  20181. this._vertexDataCount = 0;
  20182. this.anchorY = this.anchorX = 0.5;
  20183. this._type = cc.ProgressTimer.TYPE_RADIAL;
  20184. this._reverseDirection = !1;
  20185. this.midPoint = cc.p(0.5, 0.5);
  20186. this.barChangeRate = cc.p(1, 1);
  20187. this.sprite = a;
  20188. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  20189. return !0
  20190. },
  20191. draw: null,
  20192. _drawForCanvas: function(a) {
  20193. a = a || cc._renderContext;
  20194. var c = this._sprite;
  20195. c._isLighterMode && (a.globalCompositeOperation = "lighter");
  20196. var d = cc.view.getScaleX(),
  20197. e = cc.view.getScaleY();
  20198. a.globalAlpha = c._displayedOpacity / 255;
  20199. var f = c._rect,
  20200. g = c._contentSize,
  20201. h = c._offsetPosition,
  20202. k = c._drawSize_Canvas,
  20203. m = 0 | h.x,
  20204. n = -h.y - f.height,
  20205. q = c._textureRect_Canvas;
  20206. k.width = f.width * d;
  20207. k.height = f.height * e;
  20208. a.save();
  20209. c._flippedX && (m = -h.x - f.width, a.scale(-1, 1));
  20210. c._flippedY && (n = h.y, a.scale(1, -1));
  20211. m *= d;
  20212. n *= e;
  20213. 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());
  20214. 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));
  20215. a.restore();
  20216. cc.incrementGLDraws(1)
  20217. },
  20218. _drawForWebGL: function(a) {
  20219. a = a || cc._renderContext;
  20220. if (this._vertexData && this._sprite) {
  20221. cc.nodeDrawSetup(this);
  20222. var c = this._sprite.getBlendFunc();
  20223. cc.glBlendFunc(c.src, c.dst);
  20224. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  20225. cc.glBindTexture2D(this._sprite.texture);
  20226. a.bindBuffer(a.ARRAY_BUFFER, this._vertexWebGLBuffer);
  20227. this._vertexDataDirty && (a.bufferData(a.ARRAY_BUFFER, this._vertexArrayBuffer, a.DYNAMIC_DRAW), this._vertexDataDirty = !1);
  20228. c = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  20229. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, c, 0);
  20230. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, c, 8);
  20231. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, c, 12);
  20232. 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));
  20233. cc.g_NumberOfDraws++
  20234. }
  20235. },
  20236. _updateRadial: function() {
  20237. if (this._sprite) {
  20238. var a, c = this._midPoint;
  20239. a = this._percentage / 100;
  20240. var d = 2 * cc.PI * (this._reverseDirection ? a : 1 - a),
  20241. e = cc.p(c.x, 1),
  20242. f = cc.pRotateByAngle(e, c, d),
  20243. d = 0;
  20244. if (0 == a) f = e, d = 0;
  20245. else if (1 == a) f = e, d = 4;
  20246. else {
  20247. var g = cc.FLT_MAX,
  20248. h = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
  20249. for (a = 0; a <= h; ++a) {
  20250. var k = (a + (h - 1)) % h,
  20251. m = this._boundaryTexCoord(a % h),
  20252. k = this._boundaryTexCoord(k);
  20253. 0 == a ? k = cc.pLerp(m, k, 1 - c.x) : 4 == a && (m = cc.pLerp(m, k, 1 - c.x));
  20254. var n = cc.p(0, 0);
  20255. 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
  20256. }
  20257. f = cc.pAdd(c, cc.pMult(cc.pSub(f, c), g))
  20258. }
  20259. g = !0;
  20260. this._vertexDataCount != d + 3 && (g = !1, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0);
  20261. if (!this._vertexData) {
  20262. h = this._vertexDataCount = d + 3;
  20263. m = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  20264. this._vertexArrayBuffer = new ArrayBuffer(h * m);
  20265. k = [];
  20266. for (a = 0; a < h; a++) k[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * m);
  20267. this._vertexData = k;
  20268. if (!this._vertexData) {
  20269. cc.log("cc.ProgressTimer._updateRadial() : Not enough memory");
  20270. return
  20271. }
  20272. }
  20273. this._updateColor();
  20274. h = this._vertexData;
  20275. if (!g) {
  20276. h[0].texCoords = this._textureCoordFromAlphaPoint(c);
  20277. h[0].vertices = this._vertexFromAlphaPoint(c);
  20278. h[1].texCoords = this._textureCoordFromAlphaPoint(e);
  20279. h[1].vertices = this._vertexFromAlphaPoint(e);
  20280. for (a = 0; a < d; a++) c = this._boundaryTexCoord(a), h[a + 2].texCoords = this._textureCoordFromAlphaPoint(c), h[a + 2].vertices = this._vertexFromAlphaPoint(c)
  20281. }
  20282. h[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(f);
  20283. h[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(f)
  20284. }
  20285. },
  20286. _updateBar: function() {
  20287. if (this._sprite) {
  20288. var a, c = this._percentage / 100,
  20289. d = this._barChangeRate,
  20290. d = cc.pMult(cc.p(1 - d.x + c * d.x, 1 - d.y + c * d.y), 0.5),
  20291. c = cc.pSub(this._midPoint, d),
  20292. d = cc.pAdd(this._midPoint, d);
  20293. 0 > c.x && (d.x += -c.x, c.x = 0);
  20294. 1 < d.x && (c.x -= d.x - 1, d.x = 1);
  20295. 0 > c.y && (d.y += -c.y, c.y = 0);
  20296. 1 < d.y && (c.y -= d.y - 1, d.y = 1);
  20297. if (this._reverseDirection) {
  20298. if (!this._vertexData) {
  20299. this._vertexDataCount = 8;
  20300. var e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  20301. this._vertexArrayBuffer = new ArrayBuffer(8 * e);
  20302. var f = [];
  20303. for (a = 0; 8 > a; a++) f[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * e);
  20304. f[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1));
  20305. f[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1));
  20306. f[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0));
  20307. f[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0));
  20308. f[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1));
  20309. f[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1));
  20310. f[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0));
  20311. f[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0));
  20312. this._vertexData = f
  20313. }
  20314. a = this._vertexData;
  20315. a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, d.y));
  20316. a[2].vertices = this._vertexFromAlphaPoint(cc.p(c.x, d.y));
  20317. a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
  20318. a[3].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
  20319. a[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
  20320. a[4].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
  20321. a[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, c.y));
  20322. a[5].vertices = this._vertexFromAlphaPoint(cc.p(d.x, c.y))
  20323. } else {
  20324. if (!this._vertexData) {
  20325. this._vertexDataCount = 4;
  20326. e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  20327. this._vertexArrayBuffer = new ArrayBuffer(4 * e);
  20328. this._vertexData = [];
  20329. for (a = 0; 4 > a; a++) this._vertexData[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * e)
  20330. }
  20331. a = this._vertexData;
  20332. a[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, d.y));
  20333. a[0].vertices = this._vertexFromAlphaPoint(cc.p(c.x, d.y));
  20334. a[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
  20335. a[1].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
  20336. a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
  20337. a[2].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
  20338. a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, c.y));
  20339. a[3].vertices = this._vertexFromAlphaPoint(cc.p(d.x, c.y))
  20340. }
  20341. this._updateColor()
  20342. }
  20343. },
  20344. _updateColor: function() {
  20345. if (this._sprite && this._vertexData) {
  20346. for (var a = this._sprite.quad.tl.colors, c = this._vertexData, d = 0, e = this._vertexDataCount; d < e; ++d) c[d].colors = a;
  20347. this._vertexDataDirty = !0
  20348. }
  20349. },
  20350. _updateProgress: null,
  20351. _updateProgressForCanvas: function() {
  20352. var a = this._sprite,
  20353. c = a.width,
  20354. d = a.height,
  20355. e = this._midPoint;
  20356. if (this._type == cc.ProgressTimer.TYPE_RADIAL) {
  20357. this._radius = Math.round(Math.sqrt(c * c + d * d));
  20358. var f, g = !1,
  20359. h = this._origin;
  20360. h.x = c * e.x;
  20361. h.y = -d * e.y;
  20362. this._reverseDirection ? (f = 270, e = 270 - 3.6 * this._percentage) : (e = -90, f = -90 + 3.6 * this._percentage);
  20363. a._flippedX && (h.x -= c * 2 * this._midPoint.x, e = -e - 180, f = -f - 180, g = !g);
  20364. a._flippedY && (h.y += d * 2 * this._midPoint.y, g = !g, e = -e, f = -f);
  20365. this._startAngle = e;
  20366. this._endAngle = f;
  20367. this._counterClockWise = g
  20368. } else {
  20369. f = this._barChangeRate;
  20370. h = this._percentage / 100;
  20371. g = this._barRect;
  20372. f = cc.size(c * (1 - f.x), d * (1 - f.y));
  20373. var h = cc.size((c - f.width) * h, (d - f.height) * h),
  20374. h = cc.size(f.width + h.width, f.height + h.height),
  20375. k = cc.p(c * e.x, d * e.y);
  20376. f = k.x - h.width / 2;
  20377. 0.5 < e.x && h.width / 2 >= c - k.x && (f = c - h.width);
  20378. c = k.y - h.height / 2;
  20379. 0.5 < e.y && h.height / 2 >= d - k.y && (c = d - h.height);
  20380. g.x = 0;
  20381. d = 1;
  20382. a._flippedX && (g.x -= h.width, d = -1);
  20383. 0 < f && (g.x += f * d);
  20384. g.y = 0;
  20385. d = 1;
  20386. a._flippedY && (g.y += h.height, d = -1);
  20387. 0 < c && (g.y -= c * d);
  20388. g.width = h.width;
  20389. g.height = -h.height
  20390. }
  20391. },
  20392. _updateProgressForWebGL: function() {
  20393. var a = this._type;
  20394. a === cc.ProgressTimer.TYPE_RADIAL ? this._updateRadial() : a === cc.ProgressTimer.TYPE_BAR && this._updateBar();
  20395. this._vertexDataDirty = !0
  20396. }
  20397. });
  20398. _p = cc.ProgressTimer.prototype;
  20399. 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);
  20400. cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint);
  20401. cc.defineGetterSetter(_p, "barChangeRate", _p.getBarChangeRate, _p.setBarChangeRate);
  20402. cc.defineGetterSetter(_p, "type", _p.getType, _p.setType);
  20403. cc.defineGetterSetter(_p, "percentage", _p.getPercentage, _p.setPercentage);
  20404. cc.defineGetterSetter(_p, "sprite", _p.getSprite, _p.setSprite);
  20405. cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDirection);
  20406. cc.ProgressTimer.create = function(a) {
  20407. return new cc.ProgressTimer(a)
  20408. };
  20409. cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4;
  20410. cc.ProgressTimer.TEXTURE_COORDS = 75;
  20411. cc.ProgressTimer.TYPE_RADIAL = 0;
  20412. cc.ProgressTimer.TYPE_BAR = 1;
  20413. cc.ProgressTo = cc.ActionInterval.extend({
  20414. _to: 0,
  20415. _from: 0,
  20416. ctor: function(a, c) {
  20417. cc.ActionInterval.prototype.ctor.call(this);
  20418. this._from = this._to = 0;
  20419. void 0 !== c && this.initWithDuration(a, c)
  20420. },
  20421. initWithDuration: function(a, c) {
  20422. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = c, !0) : !1
  20423. },
  20424. clone: function() {
  20425. var a = new cc.ProgressTo;
  20426. a.initWithDuration(this._duration, this._to);
  20427. return a
  20428. },
  20429. reverse: function() {
  20430. cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported.");
  20431. return null
  20432. },
  20433. startWithTarget: function(a) {
  20434. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  20435. this._from = a.percentage;
  20436. 100 == this._from && (this._from = 0)
  20437. },
  20438. update: function(a) {
  20439. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  20440. }
  20441. });
  20442. cc.progressTo = function(a, c) {
  20443. return new cc.ProgressTo(a, c)
  20444. };
  20445. cc.ProgressTo.create = cc.progressTo;
  20446. cc.ProgressFromTo = cc.ActionInterval.extend({
  20447. _to: 0,
  20448. _from: 0,
  20449. ctor: function(a, c, d) {
  20450. cc.ActionInterval.prototype.ctor.call(this);
  20451. this._from = this._to = 0;
  20452. void 0 !== d && this.initWithDuration(a, c, d)
  20453. },
  20454. initWithDuration: function(a, c, d) {
  20455. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = d, this._from = c, !0) : !1
  20456. },
  20457. clone: function() {
  20458. var a = new cc.ProgressFromTo;
  20459. a.initWithDuration(this._duration, this._from, this._to);
  20460. return a
  20461. },
  20462. reverse: function() {
  20463. return cc.ProgressFromTo.create(this._duration, this._to, this._from)
  20464. },
  20465. startWithTarget: function(a) {
  20466. cc.ActionInterval.prototype.startWithTarget.call(this, a)
  20467. },
  20468. update: function(a) {
  20469. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  20470. }
  20471. });
  20472. cc.progressFromTo = function(a, c, d) {
  20473. return new cc.ProgressFromTo(a, c, d)
  20474. };
  20475. cc.ProgressFromTo.create = cc.progressFromTo;
  20476. cc.SCENE_FADE = 4208917214;
  20477. cc.TRANSITION_ORIENTATION_LEFT_OVER = 0;
  20478. cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1;
  20479. cc.TRANSITION_ORIENTATION_UP_OVER = 0;
  20480. cc.TRANSITION_ORIENTATION_DOWN_OVER = 1;
  20481. cc.TransitionScene = cc.Scene.extend({
  20482. _inScene: null,
  20483. _outScene: null,
  20484. _duration: null,
  20485. _isInSceneOnTop: !1,
  20486. _isSendCleanupToScene: !1,
  20487. _className: "TransitionScene",
  20488. ctor: function(a, c) {
  20489. cc.Scene.prototype.ctor.call(this);
  20490. void 0 !== a && void 0 !== c && this.initWithDuration(a, c)
  20491. },
  20492. _setNewScene: function(a) {
  20493. this.unschedule(this._setNewScene);
  20494. a = cc.director;
  20495. this._isSendCleanupToScene = a.isSendCleanupToScene();
  20496. a.runScene(this._inScene);
  20497. cc.eventManager.setEnabled(!0);
  20498. this._outScene.visible = !0
  20499. },
  20500. _sceneOrder: function() {
  20501. this._isInSceneOnTop = !0
  20502. },
  20503. draw: function() {
  20504. this._isInSceneOnTop ? (this._outScene.visit(), this._inScene.visit()) : (this._inScene.visit(), this._outScene.visit())
  20505. },
  20506. onEnter: function() {
  20507. cc.Node.prototype.onEnter.call(this);
  20508. cc.eventManager.setEnabled(!1);
  20509. this._outScene.onExitTransitionDidStart();
  20510. this._inScene.onEnter()
  20511. },
  20512. onExit: function() {
  20513. cc.Node.prototype.onExit.call(this);
  20514. cc.eventManager.setEnabled(!0);
  20515. this._outScene.onExit();
  20516. this._inScene.onEnterTransitionDidFinish()
  20517. },
  20518. cleanup: function() {
  20519. cc.Node.prototype.cleanup.call(this);
  20520. this._isSendCleanupToScene && this._outScene.cleanup()
  20521. },
  20522. initWithDuration: function(a, c) {
  20523. if (!c) throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";
  20524. if (this.init()) {
  20525. this._duration = a;
  20526. this.attr({
  20527. x: 0,
  20528. y: 0,
  20529. anchorX: 0,
  20530. anchorY: 0
  20531. });
  20532. this._inScene = c;
  20533. this._outScene = cc.director.getRunningScene();
  20534. this._outScene || (this._outScene = cc.Scene.create(), this._outScene.init());
  20535. if (this._inScene == this._outScene) throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
  20536. this._sceneOrder();
  20537. return !0
  20538. }
  20539. return !1
  20540. },
  20541. finish: function() {
  20542. this._inScene.attr({
  20543. visible: !0,
  20544. x: 0,
  20545. y: 0,
  20546. scale: 1,
  20547. rotation: 0
  20548. });
  20549. cc._renderType === cc._RENDER_TYPE_WEBGL && this._inScene.getCamera().restore();
  20550. this._outScene.attr({
  20551. visible: !1,
  20552. x: 0,
  20553. y: 0,
  20554. scale: 1,
  20555. rotation: 0
  20556. });
  20557. cc._renderType === cc._RENDER_TYPE_WEBGL && this._outScene.getCamera().restore();
  20558. this.schedule(this._setNewScene, 0)
  20559. },
  20560. hideOutShowIn: function() {
  20561. this._inScene.visible = !0;
  20562. this._outScene.visible = !1
  20563. }
  20564. });
  20565. cc.TransitionScene.create = function(a, c) {
  20566. return new cc.TransitionScene(a, c)
  20567. };
  20568. cc.TransitionSceneOriented = cc.TransitionScene.extend({
  20569. _orientation: 0,
  20570. ctor: function(a, c, d) {
  20571. cc.TransitionScene.prototype.ctor.call(this);
  20572. void 0 != d && this.initWithDuration(a, c, d)
  20573. },
  20574. initWithDuration: function(a, c, d) {
  20575. cc.TransitionScene.prototype.initWithDuration.call(this, a, c) && (this._orientation = d);
  20576. return !0
  20577. }
  20578. });
  20579. cc.TransitionSceneOriented.create = function(a, c, d) {
  20580. return new cc.TransitionSceneOriented(a, c, d)
  20581. };
  20582. cc.TransitionRotoZoom = cc.TransitionScene.extend({
  20583. ctor: function(a, c) {
  20584. cc.TransitionScene.prototype.ctor.call(this);
  20585. c && this.initWithDuration(a, c)
  20586. },
  20587. onEnter: function() {
  20588. cc.TransitionScene.prototype.onEnter.call(this);
  20589. this._inScene.attr({
  20590. scale: 0.0010,
  20591. anchorX: 0.5,
  20592. anchorY: 0.5
  20593. });
  20594. this._outScene.attr({
  20595. scale: 1,
  20596. anchorX: 0.5,
  20597. anchorY: 0.5
  20598. });
  20599. 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));
  20600. this._outScene.runAction(a);
  20601. this._inScene.runAction(cc.Sequence.create(a.reverse(), cc.CallFunc.create(this.finish, this)))
  20602. }
  20603. });
  20604. cc.TransitionRotoZoom.create = function(a, c) {
  20605. return new cc.TransitionRotoZoom(a, c)
  20606. };
  20607. cc.TransitionJumpZoom = cc.TransitionScene.extend({
  20608. ctor: function(a, c) {
  20609. cc.TransitionScene.prototype.ctor.call(this);
  20610. c && this.initWithDuration(a, c)
  20611. },
  20612. onEnter: function() {
  20613. cc.TransitionScene.prototype.onEnter.call(this);
  20614. var a = cc.director.getWinSize();
  20615. this._inScene.attr({
  20616. scale: 0.5,
  20617. x: a.width,
  20618. y: 0,
  20619. anchorX: 0.5,
  20620. anchorY: 0.5
  20621. });
  20622. this._outScene.anchorX = 0.5;
  20623. this._outScene.anchorY = 0.5;
  20624. var c = cc.JumpBy.create(this._duration / 4, cc.p(-a.width, 0), a.width / 4, 2),
  20625. d = cc.ScaleTo.create(this._duration / 4, 1),
  20626. a = cc.ScaleTo.create(this._duration / 4, 0.5),
  20627. a = cc.Sequence.create(a, c),
  20628. c = cc.Sequence.create(c, d),
  20629. d = cc.DelayTime.create(this._duration / 2);
  20630. this._outScene.runAction(a);
  20631. this._inScene.runAction(cc.Sequence.create(d, c, cc.CallFunc.create(this.finish, this)))
  20632. }
  20633. });
  20634. cc.TransitionJumpZoom.create = function(a, c) {
  20635. return new cc.TransitionJumpZoom(a, c)
  20636. };
  20637. cc.TransitionMoveInL = cc.TransitionScene.extend({
  20638. ctor: function(a, c) {
  20639. cc.TransitionScene.prototype.ctor.call(this);
  20640. c && this.initWithDuration(a, c)
  20641. },
  20642. onEnter: function() {
  20643. cc.TransitionScene.prototype.onEnter.call(this);
  20644. this.initScenes();
  20645. var a = this.action();
  20646. this._inScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this)))
  20647. },
  20648. initScenes: function() {
  20649. this._inScene.setPosition(-cc.director.getWinSize().width, 0)
  20650. },
  20651. action: function() {
  20652. return cc.MoveTo.create(this._duration, cc.p(0, 0))
  20653. },
  20654. easeActionWithAction: function(a) {
  20655. return cc.EaseOut.create(a, 2)
  20656. }
  20657. });
  20658. cc.TransitionMoveInL.create = function(a, c) {
  20659. return new cc.TransitionMoveInL(a, c)
  20660. };
  20661. cc.TransitionMoveInR = cc.TransitionMoveInL.extend({
  20662. ctor: function(a, c) {
  20663. cc.TransitionMoveInL.prototype.ctor.call(this);
  20664. c && this.initWithDuration(a, c)
  20665. },
  20666. initScenes: function() {
  20667. this._inScene.setPosition(cc.director.getWinSize().width, 0)
  20668. }
  20669. });
  20670. cc.TransitionMoveInR.create = function(a, c) {
  20671. return new cc.TransitionMoveInR(a, c)
  20672. };
  20673. cc.TransitionMoveInT = cc.TransitionMoveInL.extend({
  20674. ctor: function(a, c) {
  20675. cc.TransitionMoveInL.prototype.ctor.call(this);
  20676. c && this.initWithDuration(a, c)
  20677. },
  20678. initScenes: function() {
  20679. this._inScene.setPosition(0, cc.director.getWinSize().height)
  20680. }
  20681. });
  20682. cc.TransitionMoveInT.create = function(a, c) {
  20683. return new cc.TransitionMoveInT(a, c)
  20684. };
  20685. cc.TransitionMoveInB = cc.TransitionMoveInL.extend({
  20686. ctor: function(a, c) {
  20687. cc.TransitionMoveInL.prototype.ctor.call(this);
  20688. c && this.initWithDuration(a, c)
  20689. },
  20690. initScenes: function() {
  20691. this._inScene.setPosition(0, -cc.director.getWinSize().height)
  20692. }
  20693. });
  20694. cc.TransitionMoveInB.create = function(a, c) {
  20695. return new cc.TransitionMoveInB(a, c)
  20696. };
  20697. cc.ADJUST_FACTOR = 0.5;
  20698. cc.TransitionSlideInL = cc.TransitionScene.extend({
  20699. ctor: function(a, c) {
  20700. cc.TransitionScene.prototype.ctor.call(this);
  20701. c && this.initWithDuration(a, c)
  20702. },
  20703. _sceneOrder: function() {
  20704. this._isInSceneOnTop = !1
  20705. },
  20706. onEnter: function() {
  20707. cc.TransitionScene.prototype.onEnter.call(this);
  20708. this.initScenes();
  20709. var a = this.action(),
  20710. c = this.action(),
  20711. a = this.easeActionWithAction(a),
  20712. c = cc.Sequence.create(this.easeActionWithAction(c), cc.CallFunc.create(this.finish, this));
  20713. this._inScene.runAction(a);
  20714. this._outScene.runAction(c)
  20715. },
  20716. initScenes: function() {
  20717. this._inScene.setPosition(-cc.director.getWinSize().width + cc.ADJUST_FACTOR, 0)
  20718. },
  20719. action: function() {
  20720. return cc.MoveBy.create(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0))
  20721. },
  20722. easeActionWithAction: function(a) {
  20723. return cc.EaseOut.create(a, 2)
  20724. }
  20725. });
  20726. cc.TransitionSlideInL.create = function(a, c) {
  20727. return new cc.TransitionSlideInL(a, c)
  20728. };
  20729. cc.TransitionSlideInR = cc.TransitionSlideInL.extend({
  20730. ctor: function(a, c) {
  20731. cc.TransitionSlideInL.prototype.ctor.call(this);
  20732. c && this.initWithDuration(a, c)
  20733. },
  20734. _sceneOrder: function() {
  20735. this._isInSceneOnTop = !0
  20736. },
  20737. initScenes: function() {
  20738. this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)
  20739. },
  20740. action: function() {
  20741. return cc.MoveBy.create(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0))
  20742. }
  20743. });
  20744. cc.TransitionSlideInR.create = function(a, c) {
  20745. return new cc.TransitionSlideInR(a, c)
  20746. };
  20747. cc.TransitionSlideInB = cc.TransitionSlideInL.extend({
  20748. ctor: function(a, c) {
  20749. cc.TransitionSlideInL.prototype.ctor.call(this);
  20750. c && this.initWithDuration(a, c)
  20751. },
  20752. _sceneOrder: function() {
  20753. this._isInSceneOnTop = !1
  20754. },
  20755. initScenes: function() {
  20756. this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))
  20757. },
  20758. action: function() {
  20759. return cc.MoveBy.create(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR))
  20760. }
  20761. });
  20762. cc.TransitionSlideInB.create = function(a, c) {
  20763. return new cc.TransitionSlideInB(a, c)
  20764. };
  20765. cc.TransitionSlideInT = cc.TransitionSlideInL.extend({
  20766. ctor: function(a, c) {
  20767. cc.TransitionSlideInL.prototype.ctor.call(this);
  20768. c && this.initWithDuration(a, c)
  20769. },
  20770. _sceneOrder: function() {
  20771. this._isInSceneOnTop = !0
  20772. },
  20773. initScenes: function() {
  20774. this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)
  20775. },
  20776. action: function() {
  20777. return cc.MoveBy.create(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)))
  20778. }
  20779. });
  20780. cc.TransitionSlideInT.create = function(a, c) {
  20781. return new cc.TransitionSlideInT(a, c)
  20782. };
  20783. cc.TransitionShrinkGrow = cc.TransitionScene.extend({
  20784. ctor: function(a, c) {
  20785. cc.TransitionScene.prototype.ctor.call(this);
  20786. c && this.initWithDuration(a, c)
  20787. },
  20788. onEnter: function() {
  20789. cc.TransitionScene.prototype.onEnter.call(this);
  20790. this._inScene.attr({
  20791. scale: 0.0010,
  20792. anchorX: 2 / 3,
  20793. anchorY: 0.5
  20794. });
  20795. this._outScene.attr({
  20796. scale: 1,
  20797. anchorX: 1 / 3,
  20798. anchorY: 0.5
  20799. });
  20800. var a = cc.ScaleTo.create(this._duration, 0.01),
  20801. c = cc.ScaleTo.create(this._duration, 1);
  20802. this._inScene.runAction(this.easeActionWithAction(c));
  20803. this._outScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this)))
  20804. },
  20805. easeActionWithAction: function(a) {
  20806. return cc.EaseOut.create(a, 2)
  20807. }
  20808. });
  20809. cc.TransitionShrinkGrow.create = function(a, c) {
  20810. return new cc.TransitionShrinkGrow(a, c)
  20811. };
  20812. cc.TransitionFlipX = cc.TransitionSceneOriented.extend({
  20813. ctor: function(a, c, d) {
  20814. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20815. d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  20816. c && this.initWithDuration(a, c, d)
  20817. },
  20818. onEnter: function() {
  20819. cc.TransitionScene.prototype.onEnter.call(this);
  20820. var a, c;
  20821. this._inScene.visible = !1;
  20822. var d;
  20823. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20824. 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));
  20825. 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));
  20826. this._inScene.runAction(a);
  20827. this._outScene.runAction(c)
  20828. }
  20829. });
  20830. cc.TransitionFlipX.create = function(a, c, d) {
  20831. return new cc.TransitionFlipX(a, c, d)
  20832. };
  20833. cc.TransitionFlipY = cc.TransitionSceneOriented.extend({
  20834. ctor: function(a, c, d) {
  20835. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20836. d = d || cc.TRANSITION_ORIENTATION_UP_OVER;
  20837. c && this.initWithDuration(a, c, d)
  20838. },
  20839. onEnter: function() {
  20840. cc.TransitionScene.prototype.onEnter.call(this);
  20841. var a, c;
  20842. this._inScene.visible = !1;
  20843. var d;
  20844. this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20845. 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));
  20846. 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));
  20847. this._inScene.runAction(a);
  20848. this._outScene.runAction(c)
  20849. }
  20850. });
  20851. cc.TransitionFlipY.create = function(a, c, d) {
  20852. return new cc.TransitionFlipY(a, c, d)
  20853. };
  20854. cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend({
  20855. ctor: function(a, c, d) {
  20856. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20857. d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  20858. c && this.initWithDuration(a, c, d)
  20859. },
  20860. onEnter: function() {
  20861. cc.TransitionScene.prototype.onEnter.call(this);
  20862. var a, c;
  20863. this._inScene.visible = !1;
  20864. var d;
  20865. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20866. 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));
  20867. 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));
  20868. this._inScene.runAction(a);
  20869. this._outScene.runAction(c)
  20870. }
  20871. });
  20872. cc.TransitionFlipAngular.create = function(a, c, d) {
  20873. return new cc.TransitionFlipAngular(a, c, d)
  20874. };
  20875. cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend({
  20876. ctor: function(a, c, d) {
  20877. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20878. d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  20879. c && this.initWithDuration(a, c, d)
  20880. },
  20881. onEnter: function() {
  20882. cc.TransitionScene.prototype.onEnter.call(this);
  20883. var a, c;
  20884. this._inScene.visible = !1;
  20885. var d;
  20886. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20887. 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));
  20888. 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));
  20889. this._inScene.scale = 0.5;
  20890. this._inScene.runAction(a);
  20891. this._outScene.runAction(c)
  20892. }
  20893. });
  20894. cc.TransitionZoomFlipX.create = function(a, c, d) {
  20895. return new cc.TransitionZoomFlipX(a, c, d)
  20896. };
  20897. cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend({
  20898. ctor: function(a, c, d) {
  20899. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20900. d = d || cc.TRANSITION_ORIENTATION_UP_OVER;
  20901. c && this.initWithDuration(a, c, d)
  20902. },
  20903. onEnter: function() {
  20904. cc.TransitionScene.prototype.onEnter.call(this);
  20905. var a, c;
  20906. this._inScene.visible = !1;
  20907. var d;
  20908. this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20909. 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));
  20910. 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));
  20911. this._inScene.scale = 0.5;
  20912. this._inScene.runAction(a);
  20913. this._outScene.runAction(c)
  20914. }
  20915. });
  20916. cc.TransitionZoomFlipY.create = function(a, c, d) {
  20917. return new cc.TransitionZoomFlipY(a, c, d)
  20918. };
  20919. cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend({
  20920. ctor: function(a, c, d) {
  20921. cc.TransitionSceneOriented.prototype.ctor.call(this);
  20922. d = d || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  20923. c && this.initWithDuration(a, c, d)
  20924. },
  20925. onEnter: function() {
  20926. cc.TransitionScene.prototype.onEnter.call(this);
  20927. var a, c;
  20928. this._inScene.visible = !1;
  20929. var d;
  20930. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, d = 270, c = 90) : (a = -90, d = 90, c = -90);
  20931. 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));
  20932. 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));
  20933. this._inScene.scale = 0.5;
  20934. this._inScene.runAction(a);
  20935. this._outScene.runAction(c)
  20936. }
  20937. });
  20938. cc.TransitionZoomFlipAngular.create = function(a, c, d) {
  20939. return new cc.TransitionZoomFlipAngular(a, c, d)
  20940. };
  20941. cc.TransitionFade = cc.TransitionScene.extend({
  20942. _color: null,
  20943. ctor: function(a, c, d) {
  20944. cc.TransitionScene.prototype.ctor.call(this);
  20945. this._color = cc.color();
  20946. c && this.initWithDuration(a, c, d)
  20947. },
  20948. onEnter: function() {
  20949. cc.TransitionScene.prototype.onEnter.call(this);
  20950. var a = cc.LayerColor.create(this._color);
  20951. this._inScene.visible = !1;
  20952. this.addChild(a, 2, cc.SCENE_FADE);
  20953. var a = this.getChildByTag(cc.SCENE_FADE),
  20954. 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));
  20955. a.runAction(c)
  20956. },
  20957. onExit: function() {
  20958. cc.TransitionScene.prototype.onExit.call(this);
  20959. this.removeChildByTag(cc.SCENE_FADE, !1)
  20960. },
  20961. initWithDuration: function(a, c, d) {
  20962. d = d || cc.color.BLACK;
  20963. 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);
  20964. return !0
  20965. }
  20966. });
  20967. cc.TransitionFade.create = function(a, c, d) {
  20968. return new cc.TransitionFade(a, c, d)
  20969. };
  20970. cc.TransitionCrossFade = cc.TransitionScene.extend({
  20971. ctor: function(a, c) {
  20972. cc.TransitionScene.prototype.ctor.call(this);
  20973. c && this.initWithDuration(a, c)
  20974. },
  20975. onEnter: function() {
  20976. cc.TransitionScene.prototype.onEnter.call(this);
  20977. var a = cc.color(0, 0, 0, 0),
  20978. c = cc.director.getWinSize(),
  20979. a = cc.LayerColor.create(a),
  20980. d = cc.RenderTexture.create(c.width, c.height);
  20981. if (null != d) {
  20982. d.sprite.anchorX = 0.5;
  20983. d.sprite.anchorY = 0.5;
  20984. d.attr({
  20985. x: c.width / 2,
  20986. y: c.height / 2,
  20987. anchorX: 0.5,
  20988. anchorY: 0.5
  20989. });
  20990. d.begin();
  20991. this._inScene.visit();
  20992. d.end();
  20993. var e = cc.RenderTexture.create(c.width, c.height);
  20994. e.setPosition(c.width / 2, c.height / 2);
  20995. e.sprite.anchorX = e.anchorX = 0.5;
  20996. e.sprite.anchorY = e.anchorY = 0.5;
  20997. e.begin();
  20998. this._outScene.visit();
  20999. e.end();
  21000. d.sprite.setBlendFunc(cc.ONE, cc.ONE);
  21001. e.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
  21002. a.addChild(d);
  21003. a.addChild(e);
  21004. d.sprite.opacity = 255;
  21005. e.sprite.opacity = 255;
  21006. c = cc.Sequence.create(cc.FadeTo.create(this._duration, 0), cc.CallFunc.create(this.hideOutShowIn, this), cc.CallFunc.create(this.finish, this));
  21007. e.sprite.runAction(c);
  21008. this.addChild(a, 2, cc.SCENE_FADE)
  21009. }
  21010. },
  21011. onExit: function() {
  21012. this.removeChildByTag(cc.SCENE_FADE, !1);
  21013. cc.TransitionScene.prototype.onExit.call(this)
  21014. },
  21015. draw: function() {}
  21016. });
  21017. cc.TransitionCrossFade.create = function(a, c) {
  21018. return new cc.TransitionCrossFade(a, c)
  21019. };
  21020. cc.TransitionTurnOffTiles = cc.TransitionScene.extend({
  21021. ctor: function(a, c) {
  21022. cc.TransitionScene.prototype.ctor.call(this);
  21023. c && this.initWithDuration(a, c)
  21024. },
  21025. _sceneOrder: function() {
  21026. this._isInSceneOnTop = !1
  21027. },
  21028. onEnter: function() {
  21029. cc.TransitionScene.prototype.onEnter.call(this);
  21030. var a = cc.director.getWinSize(),
  21031. a = cc.TurnOffTiles.create(this._duration, cc.size(0 | 12 * (a.width / a.height), 12)),
  21032. a = this.easeActionWithAction(a);
  21033. this._outScene.runAction(cc.Sequence.create(a, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
  21034. },
  21035. easeActionWithAction: function(a) {
  21036. return a
  21037. }
  21038. });
  21039. cc.TransitionTurnOffTiles.create = function(a, c) {
  21040. return new cc.TransitionTurnOffTiles(a, c)
  21041. };
  21042. cc.TransitionSplitCols = cc.TransitionScene.extend({
  21043. ctor: function(a, c) {
  21044. cc.TransitionScene.prototype.ctor.call(this);
  21045. c && this.initWithDuration(a, c)
  21046. },
  21047. onEnter: function() {
  21048. cc.TransitionScene.prototype.onEnter.call(this);
  21049. this._inScene.visible = !1;
  21050. var a = this.action(),
  21051. a = cc.Sequence.create(a, cc.CallFunc.create(this.hideOutShowIn, this), a.reverse());
  21052. this.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
  21053. },
  21054. easeActionWithAction: function(a) {
  21055. return cc.EaseInOut.create(a, 3)
  21056. },
  21057. action: function() {
  21058. return cc.SplitCols.create(this._duration / 2, 3)
  21059. }
  21060. });
  21061. cc.TransitionSplitCols.create = function(a, c) {
  21062. return new cc.TransitionSplitCols(a, c)
  21063. };
  21064. cc.TransitionSplitRows = cc.TransitionSplitCols.extend({
  21065. ctor: function(a, c) {
  21066. cc.TransitionSplitCols.prototype.ctor.call(this);
  21067. c && this.initWithDuration(a, c)
  21068. },
  21069. action: function() {
  21070. return cc.SplitRows.create(this._duration / 2, 3)
  21071. }
  21072. });
  21073. cc.TransitionSplitRows.create = function(a, c) {
  21074. return new cc.TransitionSplitRows(a, c)
  21075. };
  21076. cc.TransitionFadeTR = cc.TransitionScene.extend({
  21077. ctor: function(a, c) {
  21078. cc.TransitionScene.prototype.ctor.call(this);
  21079. c && this.initWithDuration(a, c)
  21080. },
  21081. _sceneOrder: function() {
  21082. this._isInSceneOnTop = !1
  21083. },
  21084. onEnter: function() {
  21085. cc.TransitionScene.prototype.onEnter.call(this);
  21086. var a = cc.director.getWinSize(),
  21087. a = this.actionWithSize(cc.size(0 | 12 * (a.width / a.height), 12));
  21088. this._outScene.runAction(cc.Sequence.create(this.easeActionWithAction(a), cc.CallFunc.create(this.finish, this), cc.StopGrid.create()))
  21089. },
  21090. easeActionWithAction: function(a) {
  21091. return a
  21092. },
  21093. actionWithSize: function(a) {
  21094. return cc.FadeOutTRTiles.create(this._duration, a)
  21095. }
  21096. });
  21097. cc.TransitionFadeTR.create = function(a, c) {
  21098. return new cc.TransitionFadeTR(a, c)
  21099. };
  21100. cc.TransitionFadeBL = cc.TransitionFadeTR.extend({
  21101. ctor: function(a, c) {
  21102. cc.TransitionFadeTR.prototype.ctor.call(this);
  21103. c && this.initWithDuration(a, c)
  21104. },
  21105. actionWithSize: function(a) {
  21106. return cc.FadeOutBLTiles.create(this._duration, a)
  21107. }
  21108. });
  21109. cc.TransitionFadeBL.create = function(a, c) {
  21110. return new cc.TransitionFadeBL(a, c)
  21111. };
  21112. cc.TransitionFadeUp = cc.TransitionFadeTR.extend({
  21113. ctor: function(a, c) {
  21114. cc.TransitionFadeTR.prototype.ctor.call(this);
  21115. c && this.initWithDuration(a, c)
  21116. },
  21117. actionWithSize: function(a) {
  21118. return cc.FadeOutUpTiles.create(this._duration, a)
  21119. }
  21120. });
  21121. cc.TransitionFadeUp.create = function(a, c) {
  21122. return new cc.TransitionFadeUp(a, c)
  21123. };
  21124. cc.TransitionFadeDown = cc.TransitionFadeTR.extend({
  21125. ctor: function(a, c) {
  21126. cc.TransitionFadeTR.prototype.ctor.call(this);
  21127. c && this.initWithDuration(a, c)
  21128. },
  21129. actionWithSize: function(a) {
  21130. return cc.FadeOutDownTiles.create(this._duration, a)
  21131. }
  21132. });
  21133. cc.TransitionFadeDown.create = function(a, c) {
  21134. return new cc.TransitionFadeDown(a, c)
  21135. };
  21136. cc.SCENE_RADIAL = 49153;
  21137. cc.TransitionProgress = cc.TransitionScene.extend({
  21138. _to: 0,
  21139. _from: 0,
  21140. _sceneToBeModified: null,
  21141. _className: "TransitionProgress",
  21142. ctor: function(a, c) {
  21143. cc.TransitionScene.prototype.ctor.call(this);
  21144. c && this.initWithDuration(a, c)
  21145. },
  21146. _setAttrs: function(a, c, d) {
  21147. a.attr({
  21148. x: c,
  21149. y: d,
  21150. anchorX: 0.5,
  21151. anchorY: 0.5
  21152. })
  21153. },
  21154. onEnter: function() {
  21155. cc.TransitionScene.prototype.onEnter.call(this);
  21156. this._setupTransition();
  21157. var a = cc.director.getWinSize(),
  21158. c = cc.RenderTexture.create(a.width, a.height);
  21159. c.sprite.anchorX = 0.5;
  21160. c.sprite.anchorY = 0.5;
  21161. this._setAttrs(c, a.width / 2, a.height / 2);
  21162. c.clear(0, 0, 0, 1);
  21163. c.begin();
  21164. this._sceneToBeModified.visit();
  21165. c.end();
  21166. this._sceneToBeModified == this._outScene && this.hideOutShowIn();
  21167. a = this._progressTimerNodeWithRenderTexture(c);
  21168. c = cc.sequence(cc.progressFromTo(this._duration, this._from, this._to), cc.callFunc(this.finish, this));
  21169. a.runAction(c);
  21170. this.addChild(a, 2, cc.SCENE_RADIAL)
  21171. },
  21172. onExit: function() {
  21173. this.removeChildByTag(cc.SCENE_RADIAL, !0);
  21174. cc.TransitionScene.prototype.onExit.call(this)
  21175. },
  21176. _setupTransition: function() {
  21177. this._sceneToBeModified = this._outScene;
  21178. this._from = 100;
  21179. this._to = 0
  21180. },
  21181. _progressTimerNodeWithRenderTexture: function(a) {
  21182. cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass");
  21183. return null
  21184. },
  21185. _sceneOrder: function() {
  21186. this._isInSceneOnTop = !1
  21187. }
  21188. });
  21189. cc.TransitionProgress.create = function(a, c) {
  21190. return new cc.TransitionProgress(a, c)
  21191. };
  21192. cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend({
  21193. ctor: function(a, c) {
  21194. cc.TransitionProgress.prototype.ctor.call(this);
  21195. c && this.initWithDuration(a, c)
  21196. },
  21197. _progressTimerNodeWithRenderTexture: function(a) {
  21198. var c = cc.director.getWinSize();
  21199. a = cc.ProgressTimer.create(a.sprite);
  21200. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21201. a.type = cc.ProgressTimer.TYPE_RADIAL;
  21202. a.reverseDir = !1;
  21203. a.percentage = 100;
  21204. this._setAttrs(a, c.width / 2, c.height / 2);
  21205. return a
  21206. }
  21207. });
  21208. cc.TransitionProgressRadialCCW.create = function(a, c) {
  21209. return new cc.TransitionProgressRadialCCW(a, c)
  21210. };
  21211. cc.TransitionProgressRadialCW = cc.TransitionProgress.extend({
  21212. ctor: function(a, c) {
  21213. cc.TransitionProgress.prototype.ctor.call(this);
  21214. c && this.initWithDuration(a, c)
  21215. },
  21216. _progressTimerNodeWithRenderTexture: function(a) {
  21217. var c = cc.director.getWinSize();
  21218. a = cc.ProgressTimer.create(a.sprite);
  21219. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21220. a.type = cc.ProgressTimer.TYPE_RADIAL;
  21221. a.reverseDir = !0;
  21222. a.percentage = 100;
  21223. this._setAttrs(a, c.width / 2, c.height / 2);
  21224. return a
  21225. }
  21226. });
  21227. cc.TransitionProgressRadialCW.create = function(a, c) {
  21228. var d = new cc.TransitionProgressRadialCW;
  21229. return null != d && d.initWithDuration(a, c) ? d : new cc.TransitionProgressRadialCW(a, c)
  21230. };
  21231. cc.TransitionProgressHorizontal = cc.TransitionProgress.extend({
  21232. ctor: function(a, c) {
  21233. cc.TransitionProgress.prototype.ctor.call(this);
  21234. c && this.initWithDuration(a, c)
  21235. },
  21236. _progressTimerNodeWithRenderTexture: function(a) {
  21237. var c = cc.director.getWinSize();
  21238. a = cc.ProgressTimer.create(a.sprite);
  21239. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21240. a.type = cc.ProgressTimer.TYPE_BAR;
  21241. a.midPoint = cc.p(1, 0);
  21242. a.barChangeRate = cc.p(1, 0);
  21243. a.percentage = 100;
  21244. this._setAttrs(a, c.width / 2, c.height / 2);
  21245. return a
  21246. }
  21247. });
  21248. cc.TransitionProgressHorizontal.create = function(a, c) {
  21249. return new cc.TransitionProgressHorizontal(a, c)
  21250. };
  21251. cc.TransitionProgressVertical = cc.TransitionProgress.extend({
  21252. ctor: function(a, c) {
  21253. cc.TransitionProgress.prototype.ctor.call(this);
  21254. c && this.initWithDuration(a, c)
  21255. },
  21256. _progressTimerNodeWithRenderTexture: function(a) {
  21257. var c = cc.director.getWinSize();
  21258. a = cc.ProgressTimer.create(a.sprite);
  21259. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21260. a.type = cc.ProgressTimer.TYPE_BAR;
  21261. a.midPoint = cc.p(0, 0);
  21262. a.barChangeRate = cc.p(0, 1);
  21263. a.percentage = 100;
  21264. this._setAttrs(a, c.width / 2, c.height / 2);
  21265. return a
  21266. }
  21267. });
  21268. cc.TransitionProgressVertical.create = function(a, c) {
  21269. return new cc.TransitionProgressVertical(a, c)
  21270. };
  21271. cc.TransitionProgressInOut = cc.TransitionProgress.extend({
  21272. ctor: function(a, c) {
  21273. cc.TransitionProgress.prototype.ctor.call(this);
  21274. c && this.initWithDuration(a, c)
  21275. },
  21276. _progressTimerNodeWithRenderTexture: function(a) {
  21277. var c = cc.director.getWinSize();
  21278. a = cc.ProgressTimer.create(a.sprite);
  21279. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21280. a.type = cc.ProgressTimer.TYPE_BAR;
  21281. a.midPoint = cc.p(0.5, 0.5);
  21282. a.barChangeRate = cc.p(1, 1);
  21283. a.percentage = 0;
  21284. this._setAttrs(a, c.width / 2, c.height / 2);
  21285. return a
  21286. },
  21287. _sceneOrder: function() {
  21288. this._isInSceneOnTop = !1
  21289. },
  21290. _setupTransition: function() {
  21291. this._sceneToBeModified = this._inScene;
  21292. this._from = 0;
  21293. this._to = 100
  21294. }
  21295. });
  21296. cc.TransitionProgressInOut.create = function(a, c) {
  21297. return new cc.TransitionProgressInOut(a, c)
  21298. };
  21299. cc.TransitionProgressOutIn = cc.TransitionProgress.extend({
  21300. ctor: function(a, c) {
  21301. cc.TransitionProgress.prototype.ctor.call(this);
  21302. c && this.initWithDuration(a, c)
  21303. },
  21304. _progressTimerNodeWithRenderTexture: function(a) {
  21305. var c = cc.director.getWinSize();
  21306. a = cc.ProgressTimer.create(a.sprite);
  21307. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  21308. a.type = cc.ProgressTimer.TYPE_BAR;
  21309. a.midPoint = cc.p(0.5, 0.5);
  21310. a.barChangeRate = cc.p(1, 1);
  21311. a.percentage = 100;
  21312. this._setAttrs(a, c.width / 2, c.height / 2);
  21313. return a
  21314. }
  21315. });
  21316. cc.TransitionProgressOutIn.create = function(a, c) {
  21317. return new cc.TransitionProgressOutIn(a, c)
  21318. };
  21319. cc.TransitionPageTurn = cc.TransitionScene.extend({
  21320. ctor: function(a, c, d) {
  21321. cc.TransitionScene.prototype.ctor.call(this);
  21322. this.initWithDuration(a, c, d)
  21323. },
  21324. _back: !0,
  21325. _className: "TransitionPageTurn",
  21326. initWithDuration: function(a, c, d) {
  21327. this._back = d;
  21328. cc.TransitionScene.prototype.initWithDuration.call(this, a, c);
  21329. return !0
  21330. },
  21331. actionWithSize: function(a) {
  21332. return this._back ? cc.ReverseTime.create(cc.PageTurn3D.create(this._duration, a)) : cc.PageTurn3D.create(this._duration, a)
  21333. },
  21334. onEnter: function() {
  21335. cc.TransitionScene.prototype.onEnter.call(this);
  21336. var a = cc.director.getWinSize(),
  21337. c;
  21338. a.width > a.height ? (a = 16, c = 12) : (a = 12, c = 16);
  21339. a = this.actionWithSize(cc.size(a, c));
  21340. 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()))
  21341. },
  21342. _sceneOrder: function() {
  21343. this._isInSceneOnTop = this._back
  21344. }
  21345. });
  21346. cc.TransitionPageTurn.create = function(a, c, d) {
  21347. return new cc.TransitionPageTurn(a, c, d)
  21348. };
  21349. cc.Codec = {
  21350. name: "Jacob__Codec"
  21351. };
  21352. cc.unzip = function() {
  21353. return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, arguments)
  21354. };
  21355. cc.unzipBase64 = function() {
  21356. var a = cc.Codec.Base64.decode.apply(cc.Codec.Base64, arguments);
  21357. return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, [a])
  21358. };
  21359. cc.unzipBase64AsArray = function(a, c) {
  21360. c = c || 1;
  21361. var d = this.unzipBase64(a),
  21362. e = [],
  21363. f, g, h;
  21364. f = 0;
  21365. for (h = d.length / c; f < h; f++) {
  21366. e[f] = 0;
  21367. for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
  21368. }
  21369. return e
  21370. };
  21371. cc.unzipAsArray = function(a, c) {
  21372. c = c || 1;
  21373. var d = this.unzip(a),
  21374. e = [],
  21375. f, g, h;
  21376. f = 0;
  21377. for (h = d.length / c; f < h; f++) {
  21378. e[f] = 0;
  21379. for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
  21380. }
  21381. return e
  21382. };
  21383. cc.StringToArray = function(a) {
  21384. a = a.split(",");
  21385. var c = [],
  21386. d;
  21387. for (d = 0; d < a.length; d++) c.push(parseInt(a[d]));
  21388. return c
  21389. };
  21390. cc.Codec.Base64 = {
  21391. name: "Jacob__Codec__Base64"
  21392. };
  21393. cc.Codec.Base64._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d";
  21394. cc.Codec.Base64.decode = function(a) {
  21395. var c = [],
  21396. d, e, f, g, h, k = 0;
  21397. 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));
  21398. return c = c.join("")
  21399. };
  21400. cc.Codec.Base64.decodeAsArray = function(a, c) {
  21401. var d = this.decode(a),
  21402. e = [],
  21403. f, g, h;
  21404. f = 0;
  21405. for (h = d.length / c; f < h; f++) {
  21406. e[f] = 0;
  21407. for (g = c - 1; 0 <= g; --g) e[f] += d.charCodeAt(f * c + g) << 8 * g
  21408. }
  21409. return e
  21410. };
  21411. cc.uint8ArrayToUint32Array = function(a) {
  21412. if (0 != a.length % 4) return null;
  21413. for (var c = a.length / 4, d = window.Uint32Array ? new Uint32Array(c) : [], e = 0; e < c; e++) {
  21414. var f = 4 * e;
  21415. d[e] = a[f] + 256 * a[f + 1] + 65536 * a[f + 2] + 16777216 * a[f + 3]
  21416. }
  21417. return d
  21418. };
  21419. cc.Codec.GZip = function(a) {
  21420. this.data = a;
  21421. this.debug = !1;
  21422. this.gpflags = void 0;
  21423. this.files = 0;
  21424. this.unzipped = [];
  21425. this.buf32k = Array(32768);
  21426. this.bIdx = 0;
  21427. this.modeZIP = !1;
  21428. this.bytepos = 0;
  21429. this.bb = 1;
  21430. this.bits = 0;
  21431. this.nameBuf = [];
  21432. this.fileout = void 0;
  21433. this.literalTree = Array(cc.Codec.GZip.LITERALS);
  21434. this.distanceTree = Array(32);
  21435. this.treepos = 0;
  21436. this.Places = null;
  21437. this.len = 0;
  21438. this.fpos = Array(17);
  21439. this.fpos[0] = 0;
  21440. this.fmax = this.flens = void 0
  21441. };
  21442. cc.Codec.GZip.gunzip = function(a) {
  21443. return (new cc.Codec.GZip(a)).gunzip()[0][0]
  21444. };
  21445. cc.Codec.GZip.HufNode = function() {
  21446. this.b1 = this.b0 = 0;
  21447. this.jump = null;
  21448. this.jumppos = -1
  21449. };
  21450. cc.Codec.GZip.LITERALS = 288;
  21451. cc.Codec.GZip.NAMEMAX = 256;
  21452. 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];
  21453. 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];
  21454. 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];
  21455. 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];
  21456. 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];
  21457. cc.Codec.GZip.border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  21458. cc.Codec.GZip.prototype.gunzip = function() {
  21459. this.outputArr = [];
  21460. this.nextFile();
  21461. return this.unzipped
  21462. };
  21463. cc.Codec.GZip.prototype.readByte = function() {
  21464. this.bits += 8;
  21465. return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1
  21466. };
  21467. cc.Codec.GZip.prototype.byteAlign = function() {
  21468. this.bb = 1
  21469. };
  21470. cc.Codec.GZip.prototype.readBit = function() {
  21471. var a;
  21472. this.bits++;
  21473. a = this.bb & 1;
  21474. this.bb >>= 1;
  21475. 0 == this.bb && (this.bb = this.readByte(), a = this.bb & 1, this.bb = this.bb >> 1 | 128);
  21476. return a
  21477. };
  21478. cc.Codec.GZip.prototype.readBits = function(a) {
  21479. for (var c = 0, d = a; d--;) c = c << 1 | this.readBit();
  21480. a && (c = cc.Codec.GZip.bitReverse[c] >> 8 - a);
  21481. return c
  21482. };
  21483. cc.Codec.GZip.prototype.flushBuffer = function() {
  21484. this.bIdx = 0
  21485. };
  21486. cc.Codec.GZip.prototype.addBuffer = function(a) {
  21487. this.buf32k[this.bIdx++] = a;
  21488. this.outputArr.push(String.fromCharCode(a));
  21489. 32768 == this.bIdx && (this.bIdx = 0)
  21490. };
  21491. cc.Codec.GZip.prototype.IsPat = function() {
  21492. for (;;) {
  21493. if (this.fpos[this.len] >= this.fmax) return -1;
  21494. if (this.flens[this.fpos[this.len]] == this.len) return this.fpos[this.len]++;
  21495. this.fpos[this.len]++
  21496. }
  21497. };
  21498. cc.Codec.GZip.prototype.Rec = function() {
  21499. var a = this.Places[this.treepos],
  21500. c;
  21501. if (17 == this.len) return -1;
  21502. this.treepos++;
  21503. this.len++;
  21504. c = this.IsPat();
  21505. if (0 <= c) a.b0 = c;
  21506. else if (a.b0 = 32768, this.Rec()) return -1;
  21507. c = this.IsPat();
  21508. if (0 <= c) a.b1 = c, a.jump = null;
  21509. else if (a.b1 = 32768, a.jump = this.Places[this.treepos], a.jumppos = this.treepos, this.Rec()) return -1;
  21510. this.len--;
  21511. return 0
  21512. };
  21513. cc.Codec.GZip.prototype.CreateTree = function(a, c, d, e) {
  21514. this.Places = a;
  21515. this.treepos = 0;
  21516. this.flens = d;
  21517. this.fmax = c;
  21518. for (a = 0; 17 > a; a++) this.fpos[a] = 0;
  21519. this.len = 0;
  21520. return this.Rec() ? -1 : 0
  21521. };
  21522. cc.Codec.GZip.prototype.DecodeValue = function(a) {
  21523. for (var c, d, e = 0, f = a[e];;)
  21524. if (c = this.readBit()) {
  21525. if (!(f.b1 & 32768)) return f.b1;
  21526. f = f.jump;
  21527. c = a.length;
  21528. for (d = 0; d < c; d++)
  21529. if (a[d] === f) {
  21530. e = d;
  21531. break
  21532. }
  21533. } else {
  21534. if (!(f.b0 & 32768)) return f.b0;
  21535. e++;
  21536. f = a[e]
  21537. }
  21538. return -1
  21539. };
  21540. cc.Codec.GZip.prototype.DeflateLoop = function() {
  21541. var a, c, d, e, f;
  21542. do
  21543. if (a = this.readBit(), d = this.readBits(2), 0 == d) {
  21544. this.byteAlign();
  21545. d = this.readByte();
  21546. d |= this.readByte() << 8;
  21547. c = this.readByte();
  21548. c |= this.readByte() << 8;
  21549. for ((d ^ ~c) & 65535 && document.write("BlockLen checksum mismatch\n"); d--;) c = this.readByte(), this.addBuffer(c)
  21550. } else if (1 == d)
  21551. for (;;)
  21552. 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);
  21553. else if (256 == d) break;
  21554. else {
  21555. var g;
  21556. d -= 257;
  21557. f = this.readBits(cc.Codec.GZip.cplext[d]) + cc.Codec.GZip.cplens[d];
  21558. d = cc.Codec.GZip.bitReverse[this.readBits(5)] >> 3;
  21559. 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]);
  21560. g += cc.Codec.GZip.cpdist[d];
  21561. for (d = 0; d < f; d++) c = this.buf32k[this.bIdx - g & 32767], this.addBuffer(c)
  21562. } else if (2 == d) {
  21563. var h = Array(320);
  21564. c = 257 + this.readBits(5);
  21565. g = 1 + this.readBits(5);
  21566. e = 4 + this.readBits(4);
  21567. for (d = 0; 19 > d; d++) h[d] = 0;
  21568. for (d = 0; d < e; d++) h[cc.Codec.GZip.border[d]] = this.readBits(3);
  21569. f = this.distanceTree.length;
  21570. for (e = 0; e < f; e++) this.distanceTree[e] = new cc.Codec.GZip.HufNode;
  21571. if (this.CreateTree(this.distanceTree, 19, h, 0)) return this.flushBuffer(), 1;
  21572. f = c + g;
  21573. e = 0;
  21574. for (var k = -1; e < f;)
  21575. if (k++, d = this.DecodeValue(this.distanceTree), 16 > d) h[e++] = d;
  21576. else if (16 == d) {
  21577. var m;
  21578. d = 3 + this.readBits(2);
  21579. if (e + d > f) return this.flushBuffer(), 1;
  21580. for (m = e ? h[e - 1] : 0; d--;) h[e++] = m
  21581. } else {
  21582. d = 17 == d ? 3 + this.readBits(3) : 11 + this.readBits(7);
  21583. if (e + d > f) return this.flushBuffer(), 1;
  21584. for (; d--;) h[e++] = 0
  21585. }
  21586. f = this.literalTree.length;
  21587. for (e = 0; e < f; e++) this.literalTree[e] = new cc.Codec.GZip.HufNode;
  21588. if (this.CreateTree(this.literalTree, c, h, 0)) return this.flushBuffer(), 1;
  21589. f = this.literalTree.length;
  21590. for (e = 0; e < f; e++) this.distanceTree[e] = new cc.Codec.GZip.HufNode;
  21591. d = [];
  21592. for (e = c; e < h.length; e++) d[e - c] = h[e];
  21593. if (this.CreateTree(this.distanceTree, g, d, 0)) return this.flushBuffer(), 1;
  21594. for (;;)
  21595. if (d = this.DecodeValue(this.literalTree), 256 <= d) {
  21596. d -= 256;
  21597. if (0 == d) break;
  21598. d--;
  21599. f = this.readBits(cc.Codec.GZip.cplext[d]) + cc.Codec.GZip.cplens[d];
  21600. d = this.DecodeValue(this.distanceTree);
  21601. 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]);
  21602. for (g += cc.Codec.GZip.cpdist[d]; f--;) c = this.buf32k[this.bIdx - g & 32767], this.addBuffer(c)
  21603. } else this.addBuffer(d)
  21604. }
  21605. while (!a);
  21606. this.flushBuffer();
  21607. this.byteAlign();
  21608. return 0
  21609. };
  21610. cc.Codec.GZip.prototype.unzipFile = function(a) {
  21611. var c;
  21612. this.gunzip();
  21613. for (c = 0; c < this.unzipped.length; c++)
  21614. if (this.unzipped[c][1] == a) return this.unzipped[c][0]
  21615. };
  21616. cc.Codec.GZip.prototype.nextFile = function() {
  21617. this.outputArr = [];
  21618. this.modeZIP = !1;
  21619. var a = [];
  21620. a[0] = this.readByte();
  21621. a[1] = this.readByte();
  21622. 120 == a[0] && 218 == a[1] && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), "geonext.gxt"], this.files++);
  21623. 31 == a[0] && 139 == a[1] && (this.skipdir(), this.unzipped[this.files] = [this.outputArr.join(""), "file"], this.files++);
  21624. if (80 == a[0] && 75 == a[1] && (this.modeZIP = !0, a[2] = this.readByte(), a[3] = this.readByte(), 3 == a[2] && 4 == a[3])) {
  21625. a[0] = this.readByte();
  21626. a[1] = this.readByte();
  21627. this.gpflags = this.readByte();
  21628. this.gpflags |= this.readByte() << 8;
  21629. a = this.readByte();
  21630. a |= this.readByte() << 8;
  21631. this.readByte();
  21632. this.readByte();
  21633. this.readByte();
  21634. this.readByte();
  21635. this.readByte();
  21636. this.readByte();
  21637. this.readByte();
  21638. this.readByte();
  21639. this.readByte();
  21640. this.readByte();
  21641. this.readByte();
  21642. this.readByte();
  21643. var c = this.readByte(),
  21644. c = c | this.readByte() << 8,
  21645. d = this.readByte(),
  21646. d = d | this.readByte() << 8,
  21647. e = 0;
  21648. for (this.nameBuf = []; c--;) {
  21649. var f = this.readByte();
  21650. "/" == f | ":" == f ? e = 0 : e < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[e++] = String.fromCharCode(f))
  21651. }
  21652. this.fileout || (this.fileout = this.nameBuf);
  21653. for (var e = 0; e < d;) this.readByte(), e++;
  21654. 8 == a && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), this.nameBuf.join("")], this.files++);
  21655. this.skipdir()
  21656. }
  21657. };
  21658. cc.Codec.GZip.prototype.skipdir = function() {
  21659. var a = [],
  21660. c;
  21661. 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());
  21662. this.modeZIP && this.nextFile();
  21663. a[0] = this.readByte();
  21664. if (8 != a[0]) return 0;
  21665. this.gpflags = this.readByte();
  21666. this.readByte();
  21667. this.readByte();
  21668. this.readByte();
  21669. this.readByte();
  21670. this.readByte();
  21671. this.readByte();
  21672. if (this.gpflags & 4) {
  21673. a[0] = this.readByte();
  21674. a[2] = this.readByte();
  21675. this.len = a[0] + 256 * a[1];
  21676. for (a = 0; a < this.len; a++) this.readByte()
  21677. }
  21678. if (this.gpflags & 8) {
  21679. a = 0;
  21680. for (this.nameBuf = []; c = this.readByte();) {
  21681. if ("7" == c || ":" == c) a = 0;
  21682. a < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[a++] = c)
  21683. }
  21684. }
  21685. if (this.gpflags & 16)
  21686. for (; this.readByte(););
  21687. this.gpflags & 2 && (this.readByte(), this.readByte());
  21688. this.DeflateLoop();
  21689. this.readByte();
  21690. this.readByte();
  21691. this.readByte();
  21692. this.readByte();
  21693. this.modeZIP && this.nextFile()
  21694. };
  21695. (function() {
  21696. function a(a) {
  21697. throw a;
  21698. }
  21699. function c(a, c) {
  21700. var d = a.split("."),
  21701. e = y;
  21702. !(d[0] in e) && e.execScript && e.execScript("var " + d[0]);
  21703. for (var f; d.length && (f = d.shift());)!d.length && c !== D ? e[f] = c : e = e[f] ? e[f] : e[f] = {}
  21704. }
  21705. function d(a) {
  21706. if ("string" === typeof a) {
  21707. a = a.split("");
  21708. var c, d;
  21709. c = 0;
  21710. for (d = a.length; c < d; c++) a[c] = (a[c].charCodeAt(0) & 255) >>> 0
  21711. }
  21712. c = 1;
  21713. d = 0;
  21714. for (var e = a.length, f, g = 0; 0 < e;) {
  21715. f = 1024 < e ? 1024 : e;
  21716. e -= f;
  21717. do c += a[g++], d += c; while (--f);
  21718. c %= 65521;
  21719. d %= 65521
  21720. }
  21721. return (d << 16 | c) >>> 0
  21722. }
  21723. function e(c, d) {
  21724. this.index = "number" === typeof d ? d : 0;
  21725. this.i = 0;
  21726. this.buffer = c instanceof(z ? Uint8Array : Array) ? c : new(z ? Uint8Array : Array)(32768);
  21727. 2 * this.buffer.length <= this.index && a(Error("invalid index"));
  21728. this.buffer.length <= this.index && this.f()
  21729. }
  21730. function f(a) {
  21731. this.buffer = new(z ? Uint16Array : Array)(2 * a);
  21732. this.length = 0
  21733. }
  21734. function g(a) {
  21735. var c = a.length,
  21736. d = 0,
  21737. e = Number.POSITIVE_INFINITY,
  21738. f, g, h, k, m, n, q, r, s;
  21739. for (r = 0; r < c; ++r) a[r] > d && (d = a[r]), a[r] < e && (e = a[r]);
  21740. f = 1 << d;
  21741. g = new(z ? Uint32Array : Array)(f);
  21742. h = 1;
  21743. k = 0;
  21744. for (m = 2; h <= d;) {
  21745. for (r = 0; r < c; ++r)
  21746. if (a[r] === h) {
  21747. n = 0;
  21748. q = k;
  21749. for (s = 0; s < h; ++s) n = n << 1 | q & 1, q >>= 1;
  21750. for (s = n; s < f; s += m) g[s] = h << 16 | r;
  21751. ++k
  21752. }++h;
  21753. k <<= 1;
  21754. m <<= 1
  21755. }
  21756. return [g, d, e]
  21757. }
  21758. function h(a, c) {
  21759. this.h = K;
  21760. this.w = 0;
  21761. this.input = a;
  21762. this.b = 0;
  21763. 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));
  21764. this.a || (this.a = new(z ? Uint8Array : Array)(32768))
  21765. }
  21766. function k(a, c) {
  21767. this.length = a;
  21768. this.G = c
  21769. }
  21770. function m() {
  21771. var c = L;
  21772. switch (F) {
  21773. case 3 === c:
  21774. return [257, c - 3, 0];
  21775. case 4 === c:
  21776. return [258, c - 4, 0];
  21777. case 5 === c:
  21778. return [259, c - 5, 0];
  21779. case 6 === c:
  21780. return [260, c - 6, 0];
  21781. case 7 === c:
  21782. return [261, c - 7, 0];
  21783. case 8 === c:
  21784. return [262, c - 8, 0];
  21785. case 9 === c:
  21786. return [263, c - 9, 0];
  21787. case 10 === c:
  21788. return [264, c - 10, 0];
  21789. case 12 >= c:
  21790. return [265, c - 11, 1];
  21791. case 14 >= c:
  21792. return [266, c - 13, 1];
  21793. case 16 >= c:
  21794. return [267, c - 15, 1];
  21795. case 18 >= c:
  21796. return [268, c - 17, 1];
  21797. case 22 >= c:
  21798. return [269, c - 19, 2];
  21799. case 26 >= c:
  21800. return [270, c - 23, 2];
  21801. case 30 >= c:
  21802. return [271, c - 27, 2];
  21803. case 34 >= c:
  21804. return [272, c - 31, 2];
  21805. case 42 >= c:
  21806. return [273, c - 35, 3];
  21807. case 50 >= c:
  21808. return [274, c - 43, 3];
  21809. case 58 >= c:
  21810. return [275, c - 51, 3];
  21811. case 66 >= c:
  21812. return [276, c - 59, 3];
  21813. case 82 >= c:
  21814. return [277, c - 67, 4];
  21815. case 98 >= c:
  21816. return [278, c - 83, 4];
  21817. case 114 >= c:
  21818. return [279, c - 99, 4];
  21819. case 130 >= c:
  21820. return [280, c - 115, 4];
  21821. case 162 >= c:
  21822. return [281, c - 131, 5];
  21823. case 194 >= c:
  21824. return [282, c - 163, 5];
  21825. case 226 >= c:
  21826. return [283, c - 195, 5];
  21827. case 257 >= c:
  21828. return [284, c - 227, 5];
  21829. case 258 === c:
  21830. return [285, c - 258, 0];
  21831. default:
  21832. a("invalid length: " + c)
  21833. }
  21834. }
  21835. function n(c, d) {
  21836. function e(c, d) {
  21837. var f = c.G,
  21838. g = [],
  21839. h = 0,
  21840. k;
  21841. k = N[c.length];
  21842. g[h++] = k & 65535;
  21843. g[h++] = k >> 16 & 255;
  21844. g[h++] = k >> 24;
  21845. var m;
  21846. switch (F) {
  21847. case 1 === f:
  21848. m = [0, f - 1, 0];
  21849. break;
  21850. case 2 === f:
  21851. m = [1, f - 2, 0];
  21852. break;
  21853. case 3 === f:
  21854. m = [2, f - 3, 0];
  21855. break;
  21856. case 4 === f:
  21857. m = [3, f - 4, 0];
  21858. break;
  21859. case 6 >= f:
  21860. m = [4, f - 5, 1];
  21861. break;
  21862. case 8 >= f:
  21863. m = [5, f - 7, 1];
  21864. break;
  21865. case 12 >= f:
  21866. m = [6, f - 9, 2];
  21867. break;
  21868. case 16 >= f:
  21869. m = [7, f - 13, 2];
  21870. break;
  21871. case 24 >= f:
  21872. m = [8, f - 17, 3];
  21873. break;
  21874. case 32 >= f:
  21875. m = [9, f - 25, 3];
  21876. break;
  21877. case 48 >= f:
  21878. m = [10, f - 33, 4];
  21879. break;
  21880. case 64 >= f:
  21881. m = [11, f - 49, 4];
  21882. break;
  21883. case 96 >= f:
  21884. m = [12, f - 65, 5];
  21885. break;
  21886. case 128 >= f:
  21887. m = [13, f - 97, 5];
  21888. break;
  21889. case 192 >= f:
  21890. m = [14, f - 129, 6];
  21891. break;
  21892. case 256 >= f:
  21893. m = [15, f - 193, 6];
  21894. break;
  21895. case 384 >= f:
  21896. m = [16, f - 257, 7];
  21897. break;
  21898. case 512 >= f:
  21899. m = [17, f - 385, 7];
  21900. break;
  21901. case 768 >= f:
  21902. m = [18, f - 513, 8];
  21903. break;
  21904. case 1024 >= f:
  21905. m = [19, f - 769, 8];
  21906. break;
  21907. case 1536 >= f:
  21908. m = [20, f - 1025, 9];
  21909. break;
  21910. case 2048 >= f:
  21911. m = [21, f - 1537, 9];
  21912. break;
  21913. case 3072 >= f:
  21914. m = [22, f - 2049, 10];
  21915. break;
  21916. case 4096 >= f:
  21917. m = [23, f - 3073, 10];
  21918. break;
  21919. case 6144 >= f:
  21920. m = [24, f - 4097, 11];
  21921. break;
  21922. case 8192 >= f:
  21923. m = [25, f - 6145, 11];
  21924. break;
  21925. case 12288 >= f:
  21926. m = [26, f - 8193, 12];
  21927. break;
  21928. case 16384 >= f:
  21929. m = [27, f - 12289, 12];
  21930. break;
  21931. case 24576 >= f:
  21932. m = [28, f - 16385, 13];
  21933. break;
  21934. case 32768 >= f:
  21935. m = [29, f - 24577, 13];
  21936. break;
  21937. default:
  21938. a("invalid distance")
  21939. }
  21940. k = m;
  21941. g[h++] = k[0];
  21942. g[h++] = k[1];
  21943. g[h++] = k[2];
  21944. f = 0;
  21945. for (h = g.length; f < h; ++f) s[t++] = g[f];
  21946. u[g[0]]++;
  21947. x[g[3]]++;
  21948. v = c.length + d - 1;
  21949. r = null
  21950. }
  21951. var f, g, h, m, n, q = {},
  21952. r, s = z ? new Uint16Array(2 * d.length) : [],
  21953. t = 0,
  21954. v = 0,
  21955. u = new(z ? Uint32Array : Array)(286),
  21956. x = new(z ? Uint32Array : Array)(30),
  21957. A = c.w,
  21958. w;
  21959. if (!z) {
  21960. for (h = 0; 285 >= h;) u[h++] = 0;
  21961. for (h = 0; 29 >= h;) x[h++] = 0
  21962. }
  21963. u[256] = 1;
  21964. f = 0;
  21965. for (g = d.length; f < g; ++f) {
  21966. h = n = 0;
  21967. for (m = 3; h < m && f + h !== g; ++h) n = n << 8 | d[f + h];
  21968. q[n] === D && (q[n] = []);
  21969. h = q[n];
  21970. if (!(0 < v--)) {
  21971. for (; 0 < h.length && 32768 < f - h[0];) h.shift();
  21972. if (f + 3 >= g) {
  21973. r && e(r, -1);
  21974. h = 0;
  21975. for (m = g - f; h < m; ++h) w = d[f + h], s[t++] = w, ++u[w];
  21976. break
  21977. }
  21978. if (0 < h.length) {
  21979. n = m = D;
  21980. var C = 0,
  21981. B = D,
  21982. y = D,
  21983. E = B = D,
  21984. I = d.length,
  21985. y = 0,
  21986. E = h.length;
  21987. a: for (; y < E; y++) {
  21988. m = h[E - y - 1];
  21989. B = 3;
  21990. if (3 < C) {
  21991. for (B = C; 3 < B; B--)
  21992. if (d[m + B - 1] !== d[f + B - 1]) continue a;
  21993. B = C
  21994. }
  21995. for (; 258 > B && f + B < I && d[m + B] === d[f + B];)++B;
  21996. B > C && (n = m, C = B);
  21997. if (258 === B) break
  21998. }
  21999. m = new k(C, f - n);
  22000. 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)
  22001. } else r ? e(r, -1) : (w = d[f], s[t++] = w, ++u[w])
  22002. }
  22003. h.push(f)
  22004. }
  22005. s[t++] = 256;
  22006. u[256]++;
  22007. c.L = u;
  22008. c.K = x;
  22009. return z ? s.subarray(0, t) : s
  22010. }
  22011. function q(a, c) {
  22012. function d(a) {
  22013. var c = s[a][t[a]];
  22014. c === q ? (d(a + 1), d(a + 1)) : --r[c];
  22015. ++t[a]
  22016. }
  22017. var e = a.length,
  22018. g = new f(572),
  22019. h = new(z ? Uint8Array : Array)(e),
  22020. k, m, n;
  22021. if (!z)
  22022. for (m = 0; m < e; m++) h[m] = 0;
  22023. for (m = 0; m < e; ++m) 0 < a[m] && g.push(m, a[m]);
  22024. e = Array(g.length / 2);
  22025. k = new(z ? Uint32Array : Array)(g.length / 2);
  22026. if (1 === e.length) return h[g.pop().index] = 1, h;
  22027. m = 0;
  22028. for (n = g.length / 2; m < n; ++m) e[m] = g.pop(), k[m] = e[m].value;
  22029. var q = k.length;
  22030. m = new(z ? Uint16Array : Array)(c);
  22031. var g = new(z ? Uint8Array : Array)(c),
  22032. r = new(z ? Uint8Array : Array)(q);
  22033. n = Array(c);
  22034. var s = Array(c),
  22035. t = Array(c),
  22036. u = (1 << c) - q,
  22037. v = 1 << c - 1,
  22038. w, x, A;
  22039. m[c - 1] = q;
  22040. 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;
  22041. m[0] = g[0];
  22042. n[0] = Array(m[0]);
  22043. s[0] = Array(m[0]);
  22044. 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]);
  22045. for (u = 0; u < q; ++u) r[u] = c;
  22046. for (v = 0; v < m[c - 1]; ++v) n[c - 1][v] = k[v], s[c - 1][v] = v;
  22047. for (u = 0; u < c; ++u) t[u] = 0;
  22048. 1 === g[c - 1] && (--r[0], ++t[c - 1]);
  22049. for (w = c - 2; 0 <= w; --w) {
  22050. x = u = 0;
  22051. A = t[w + 1];
  22052. 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);
  22053. t[w] = 0;
  22054. 1 === g[w] && d(w)
  22055. }
  22056. k = r;
  22057. m = 0;
  22058. for (n = e.length; m < n; ++m) h[e[m].index] = k[m];
  22059. return h
  22060. }
  22061. function r(c) {
  22062. var d = new(z ? Uint16Array : Array)(c.length),
  22063. e = [],
  22064. f = [],
  22065. g = 0,
  22066. h, k, m;
  22067. h = 0;
  22068. for (k = c.length; h < k; h++) e[c[h]] = (e[c[h]] | 0) + 1;
  22069. h = 1;
  22070. for (k = 16; h <= k; h++) f[h] = g, g += e[h] | 0, g > 1 << h && a("overcommitted"), g <<= 1;
  22071. 65536 > g && a("undercommitted");
  22072. h = 0;
  22073. for (k = c.length; h < k; h++) {
  22074. g = f[c[h]];
  22075. f[c[h]] += 1;
  22076. e = d[h] = 0;
  22077. for (m = c[h]; e < m; e++) d[h] = d[h] << 1 | g & 1, g >>>= 1
  22078. }
  22079. return d
  22080. }
  22081. function t(a, c) {
  22082. this.input = a;
  22083. this.a = new(z ? Uint8Array : Array)(32768);
  22084. this.h = I.j;
  22085. var d = {},
  22086. e;
  22087. if ((c || !(c = {})) && "number" === typeof c.compressionType) this.h = c.compressionType;
  22088. for (e in c) d[e] = c[e];
  22089. d.outputBuffer = this.a;
  22090. this.z = new h(this.input, d)
  22091. }
  22092. function s(c, d) {
  22093. this.k = [];
  22094. this.l = 32768;
  22095. this.e = this.g = this.c = this.q = 0;
  22096. this.input = z ? new Uint8Array(c) : c;
  22097. this.s = !1;
  22098. this.m = P;
  22099. this.B = !1;
  22100. 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);
  22101. switch (this.m) {
  22102. case J:
  22103. this.b = 32768;
  22104. this.a = new(z ? Uint8Array : Array)(32768 + this.l + 258);
  22105. break;
  22106. case P:
  22107. this.b = 0;
  22108. this.a = new(z ? Uint8Array : Array)(this.l);
  22109. this.f = this.J;
  22110. this.t = this.H;
  22111. this.o = this.I;
  22112. break;
  22113. default:
  22114. a(Error("invalid inflate mode"))
  22115. }
  22116. }
  22117. function v(c, d) {
  22118. 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;
  22119. c.g = e >>> d;
  22120. c.e = f - d;
  22121. c.c = h;
  22122. return e & (1 << d) - 1
  22123. }
  22124. function u(c, d) {
  22125. 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;
  22126. g = k[e & (1 << m) - 1];
  22127. k = g >>> 16;
  22128. c.g = e >> k;
  22129. c.e = f - k;
  22130. c.c = h;
  22131. return g & 65535
  22132. }
  22133. function x(a) {
  22134. function c(a, d, e) {
  22135. var f, g, h, k;
  22136. for (k = 0; k < a;) switch (f = u(this, d), f) {
  22137. case 16:
  22138. for (h = 3 + v(this, 2); h--;) e[k++] = g;
  22139. break;
  22140. case 17:
  22141. for (h = 3 + v(this, 3); h--;) e[k++] = 0;
  22142. g = 0;
  22143. break;
  22144. case 18:
  22145. for (h = 11 + v(this, 7); h--;) e[k++] = 0;
  22146. g = 0;
  22147. break;
  22148. default:
  22149. g = e[k++] = f
  22150. }
  22151. return e
  22152. }
  22153. var d = v(a, 5) + 257,
  22154. e = v(a, 5) + 1,
  22155. f = v(a, 4) + 4,
  22156. h = new(z ? Uint8Array : Array)(S.length),
  22157. k;
  22158. for (k = 0; k < f; ++k) h[S[k]] = v(a, 3);
  22159. f = g(h);
  22160. h = new(z ? Uint8Array : Array)(d);
  22161. k = new(z ? Uint8Array : Array)(e);
  22162. a.o(g(c.call(a, d, f, h)), g(c.call(a, e, f, k)))
  22163. }
  22164. function A(c, d) {
  22165. var e, f;
  22166. this.input = c;
  22167. this.c = 0;
  22168. if (d || !(d = {})) d.index && (this.c = d.index), d.verify && (this.M = d.verify);
  22169. e = c[this.c++];
  22170. f = c[this.c++];
  22171. switch (e & 15) {
  22172. case O:
  22173. this.method = O;
  22174. break;
  22175. default:
  22176. a(Error("unsupported compression method"))
  22177. }
  22178. 0 !== ((e << 8) + f) % 31 && a(Error("invalid fcheck flag:" + ((e << 8) + f) % 31));
  22179. f & 32 && a(Error("fdict flag is not supported"));
  22180. this.A = new s(c, {
  22181. index: this.c,
  22182. bufferSize: d.bufferSize,
  22183. bufferType: d.bufferType,
  22184. resize: d.resize
  22185. })
  22186. }
  22187. var D = void 0,
  22188. F = !0,
  22189. y = this,
  22190. z = "undefined" !== typeof Uint8Array && "undefined" !== typeof Uint16Array && "undefined" !== typeof Uint32Array;
  22191. e.prototype.f = function() {
  22192. var a = this.buffer,
  22193. c, d = a.length,
  22194. e = new(z ? Uint8Array : Array)(d << 1);
  22195. if (z) e.set(a);
  22196. else
  22197. for (c = 0; c < d; ++c) e[c] = a[c];
  22198. return this.buffer = e
  22199. };
  22200. e.prototype.d = function(a, c, d) {
  22201. var e = this.buffer,
  22202. f = this.index,
  22203. g = this.i,
  22204. h = e[f];
  22205. 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);
  22206. if (8 > c + g) h = h << c | a, g += c;
  22207. else
  22208. 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()));
  22209. e[f] = h;
  22210. this.buffer = e;
  22211. this.i = g;
  22212. this.index = f
  22213. };
  22214. e.prototype.finish = function() {
  22215. var a = this.buffer,
  22216. c = this.index,
  22217. d;
  22218. 0 < this.i && (a[c] <<= 8 - this.i, a[c] = E[a[c]], c++);
  22219. z ? d = a.subarray(0, c) : (a.length = c, d = a);
  22220. return d
  22221. };
  22222. var C = new(z ? Uint8Array : Array)(256),
  22223. w;
  22224. for (w = 0; 256 > w; ++w) {
  22225. for (var B = w, G = B, H = 7, B = B >>> 1; B; B >>>= 1) G <<= 1, G |= B & 1, --H;
  22226. C[w] = (G << H & 255) >>> 0
  22227. }
  22228. var E = C,
  22229. 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];
  22230. z && new Uint32Array(C);
  22231. f.prototype.getParent = function(a) {
  22232. return 2 * ((a - 2) / 4 | 0)
  22233. };
  22234. f.prototype.push = function(a, c) {
  22235. var d, e, f = this.buffer,
  22236. g;
  22237. d = this.length;
  22238. f[this.length++] = c;
  22239. for (f[this.length++] = a; 0 < d;)
  22240. 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;
  22241. else break;
  22242. return this.length
  22243. };
  22244. f.prototype.pop = function() {
  22245. var a, c, d = this.buffer,
  22246. e, f, g;
  22247. c = d[0];
  22248. a = d[1];
  22249. this.length -= 2;
  22250. d[0] = d[this.length];
  22251. d[1] = d[this.length + 1];
  22252. for (g = 0;;) {
  22253. f = 2 * g + 2;
  22254. if (f >= this.length) break;
  22255. f + 2 < this.length && d[f + 2] > d[f] && (f += 2);
  22256. 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;
  22257. else break;
  22258. g = f
  22259. }
  22260. return {
  22261. index: a,
  22262. value: c,
  22263. length: this.length
  22264. }
  22265. };
  22266. var K = 2,
  22267. C = {
  22268. NONE: 0,
  22269. r: 1,
  22270. j: K,
  22271. N: 3
  22272. },
  22273. M = [];
  22274. for (w = 0; 288 > w; w++) switch (F) {
  22275. case 143 >= w:
  22276. M.push([w + 48, 8]);
  22277. break;
  22278. case 255 >= w:
  22279. M.push([w - 144 + 400, 9]);
  22280. break;
  22281. case 279 >= w:
  22282. M.push([w - 256 + 0, 7]);
  22283. break;
  22284. case 287 >= w:
  22285. M.push([w - 280 + 192, 8]);
  22286. break;
  22287. default:
  22288. a("invalid literal: " + w)
  22289. }
  22290. h.prototype.n = function() {
  22291. var c, d, f, g, h = this.input;
  22292. switch (this.h) {
  22293. case 0:
  22294. f = 0;
  22295. for (g = h.length; f < g;) {
  22296. d = z ? h.subarray(f, f + 65535) : h.slice(f, f + 65535);
  22297. f += d.length;
  22298. var k = f === g,
  22299. m = D,
  22300. s = m = D,
  22301. s = m = D,
  22302. t = this.a,
  22303. u = this.b;
  22304. if (z) {
  22305. for (t = new Uint8Array(this.a.buffer); t.length <= u + d.length + 5;) t = new Uint8Array(t.length << 1);
  22306. t.set(this.a)
  22307. }
  22308. m = k ? 1 : 0;
  22309. t[u++] = m | 0;
  22310. m = d.length;
  22311. s = ~m + 65536 & 65535;
  22312. t[u++] = m & 255;
  22313. t[u++] = m >>> 8 & 255;
  22314. t[u++] = s & 255;
  22315. t[u++] = s >>> 8 & 255;
  22316. if (z) t.set(d, u), u += d.length, t = t.subarray(0, u);
  22317. else {
  22318. m = 0;
  22319. for (s = d.length; m < s; ++m) t[u++] = d[m];
  22320. t.length = u
  22321. }
  22322. this.b = u;
  22323. this.a = t
  22324. }
  22325. break;
  22326. case 1:
  22327. f = new e(new Uint8Array(this.a.buffer), this.b);
  22328. f.d(1, 1, F);
  22329. f.d(1, 2, F);
  22330. h = n(this, h);
  22331. d = 0;
  22332. for (k = h.length; d < k; d++)
  22333. 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);
  22334. else if (256 === g) break;
  22335. this.a = f.finish();
  22336. this.b = this.a.length;
  22337. break;
  22338. case K:
  22339. g = new e(new Uint8Array(this.a), this.b);
  22340. var v, w, x, A = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15],
  22341. C, B, m = Array(19),
  22342. y, t = K;
  22343. g.d(1, 1, F);
  22344. g.d(t, 2, F);
  22345. h = n(this, h);
  22346. s = q(this.L, 15);
  22347. C = r(s);
  22348. t = q(this.K, 7);
  22349. u = r(t);
  22350. for (v = 286; 257 < v && 0 === s[v - 1]; v--);
  22351. for (w = 30; 1 < w && 0 === t[w - 1]; w--);
  22352. var E = v,
  22353. I = w;
  22354. c = new(z ? Uint32Array : Array)(E + I);
  22355. var G = new(z ? Uint32Array : Array)(316),
  22356. H, J;
  22357. B = new(z ? Uint8Array : Array)(19);
  22358. for (y = x = 0; y < E; y++) c[x++] = s[y];
  22359. for (y = 0; y < I; y++) c[x++] = t[y];
  22360. if (!z) {
  22361. y = 0;
  22362. for (I = B.length; y < I; ++y) B[y] = 0
  22363. }
  22364. y = H = 0;
  22365. for (I = c.length; y < I; y += x) {
  22366. for (x = 1; y + x < I && c[y + x] === c[y]; ++x);
  22367. E = x;
  22368. if (0 === c[y])
  22369. if (3 > E)
  22370. for (; 0 < E--;) G[H++] = 0, B[0]++;
  22371. else
  22372. 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;
  22373. else if (G[H++] = c[y], B[c[y]]++, E--, 3 > E)
  22374. for (; 0 < E--;) G[H++] = c[y], B[c[y]]++;
  22375. else
  22376. 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
  22377. }
  22378. c = z ? G.subarray(0, H) : G.slice(0, H);
  22379. B = q(B, 7);
  22380. for (y = 0; 19 > y; y++) m[y] = B[A[y]];
  22381. for (x = 19; 4 < x && 0 === m[x - 1]; x--);
  22382. A = r(B);
  22383. g.d(v - 257, 5, F);
  22384. g.d(w - 1, 5, F);
  22385. g.d(x - 4, 4, F);
  22386. for (y = 0; y < x; y++) g.d(m[y], 3, F);
  22387. y = 0;
  22388. for (m = c.length; y < m; y++)
  22389. if (d = c[y], g.d(A[d], B[d], F), 16 <= d) {
  22390. y++;
  22391. switch (d) {
  22392. case 16:
  22393. k = 2;
  22394. break;
  22395. case 17:
  22396. k = 3;
  22397. break;
  22398. case 18:
  22399. k = 7;
  22400. break;
  22401. default:
  22402. a("invalid code: " + d)
  22403. }
  22404. g.d(c[y], k, F)
  22405. }
  22406. k = [C, s];
  22407. u = [u, t];
  22408. d = k[0];
  22409. k = k[1];
  22410. t = u[0];
  22411. C = u[1];
  22412. u = 0;
  22413. for (m = h.length; u < m; ++u)
  22414. 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);
  22415. else if (256 === f) break;
  22416. this.a = g.finish();
  22417. this.b = this.a.length;
  22418. break;
  22419. default:
  22420. a("invalid compression type")
  22421. }
  22422. return this.a
  22423. };
  22424. w = [];
  22425. var L;
  22426. for (L = 3; 258 >= L; L++) B = m(), w[L] = B[2] << 24 | B[1] << 16 | B[0];
  22427. var N = z ? new Uint32Array(w) : w,
  22428. I = C;
  22429. t.prototype.n = function() {
  22430. var c, e, f, g, h = 0;
  22431. g = this.a;
  22432. c = O;
  22433. switch (c) {
  22434. case O:
  22435. e = Math.LOG2E * Math.log(32768) - 8;
  22436. break;
  22437. default:
  22438. a(Error("invalid compression method"))
  22439. }
  22440. e = e << 4 | c;
  22441. g[h++] = e;
  22442. switch (c) {
  22443. case O:
  22444. switch (this.h) {
  22445. case I.NONE:
  22446. f = 0;
  22447. break;
  22448. case I.r:
  22449. f = 1;
  22450. break;
  22451. case I.j:
  22452. f = 2;
  22453. break;
  22454. default:
  22455. a(Error("unsupported compression type"))
  22456. }
  22457. break;
  22458. default:
  22459. a(Error("invalid compression method"))
  22460. }
  22461. c = f << 6 | 0;
  22462. g[h++] = c | 31 - (256 * e + c) % 31;
  22463. c = d(this.input);
  22464. this.z.b = h;
  22465. g = this.z.n();
  22466. h = g.length;
  22467. 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));
  22468. g[h++] = c >> 24 & 255;
  22469. g[h++] = c >> 16 & 255;
  22470. g[h++] = c >> 8 & 255;
  22471. g[h++] = c & 255;
  22472. return g
  22473. };
  22474. c("Zlib.Deflate", t);
  22475. c("Zlib.Deflate.compress", function(a, c) {
  22476. return (new t(a, c)).n()
  22477. });
  22478. c("Zlib.Deflate.CompressionType", I);
  22479. c("Zlib.Deflate.CompressionType.NONE", I.NONE);
  22480. c("Zlib.Deflate.CompressionType.FIXED", I.r);
  22481. c("Zlib.Deflate.CompressionType.DYNAMIC", I.j);
  22482. var J = 0,
  22483. P = 1,
  22484. C = {
  22485. D: J,
  22486. C: P
  22487. };
  22488. s.prototype.p = function() {
  22489. for (; !this.s;) {
  22490. var c = v(this, 3);
  22491. c & 1 && (this.s = F);
  22492. c >>>= 1;
  22493. switch (c) {
  22494. case 0:
  22495. var c = this.input,
  22496. d = this.c,
  22497. e = this.a,
  22498. f = this.b,
  22499. g = D,
  22500. h = D,
  22501. k = D,
  22502. m = e.length,
  22503. g = D;
  22504. this.e = this.g = 0;
  22505. g = c[d++];
  22506. g === D && a(Error("invalid uncompressed block header: LEN (first byte)"));
  22507. h = g;
  22508. g = c[d++];
  22509. g === D && a(Error("invalid uncompressed block header: LEN (second byte)"));
  22510. h |= g << 8;
  22511. g = c[d++];
  22512. g === D && a(Error("invalid uncompressed block header: NLEN (first byte)"));
  22513. k = g;
  22514. g = c[d++];
  22515. g === D && a(Error("invalid uncompressed block header: NLEN (second byte)"));
  22516. k |= g << 8;
  22517. h === ~k && a(Error("invalid uncompressed block header: length verify"));
  22518. d + h > c.length && a(Error("input buffer is broken"));
  22519. switch (this.m) {
  22520. case J:
  22521. for (; f + h > e.length;) {
  22522. g = m - f;
  22523. h -= g;
  22524. if (z) e.set(c.subarray(d, d + g), f), f += g, d += g;
  22525. else
  22526. for (; g--;) e[f++] = c[d++];
  22527. this.b = f;
  22528. e = this.f();
  22529. f = this.b
  22530. }
  22531. break;
  22532. case P:
  22533. for (; f + h > e.length;) e = this.f({
  22534. v: 2
  22535. });
  22536. break;
  22537. default:
  22538. a(Error("invalid inflate mode"))
  22539. }
  22540. if (z) e.set(c.subarray(d, d + h), f), f += h, d += h;
  22541. else
  22542. for (; h--;) e[f++] = c[d++];
  22543. this.c = d;
  22544. this.b = f;
  22545. this.a = e;
  22546. break;
  22547. case 1:
  22548. this.o(V, W);
  22549. break;
  22550. case 2:
  22551. x(this);
  22552. break;
  22553. default:
  22554. a(Error("unknown BTYPE: " + c))
  22555. }
  22556. }
  22557. return this.t()
  22558. };
  22559. w = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  22560. var S = z ? new Uint16Array(w) : w;
  22561. 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];
  22562. var T = z ? new Uint16Array(w) : w;
  22563. 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];
  22564. var Q = z ? new Uint8Array(w) : w;
  22565. 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];
  22566. var U = z ? new Uint16Array(w) : w;
  22567. 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];
  22568. var R = z ? new Uint8Array(w) : w;
  22569. w = new(z ? Uint8Array : Array)(288);
  22570. B = 0;
  22571. for (G = w.length; B < G; ++B) w[B] = 143 >= B ? 8 : 255 >= B ? 9 : 279 >= B ? 7 : 8;
  22572. var V = g(w);
  22573. w = new(z ? Uint8Array : Array)(30);
  22574. B = 0;
  22575. for (G = w.length; B < G; ++B) w[B] = 5;
  22576. var W = g(w);
  22577. s.prototype.o = function(a, c) {
  22578. var d = this.a,
  22579. e = this.b;
  22580. this.u = a;
  22581. for (var f = d.length - 258, g, h, k; 256 !== (g = u(this, a));)
  22582. if (256 > g) e >= f && (this.b = e, d = this.f(), e = this.b), d[e++] = g;
  22583. else {
  22584. g -= 257;
  22585. k = T[g];
  22586. 0 < Q[g] && (k += v(this, Q[g]));
  22587. g = u(this, c);
  22588. h = U[g];
  22589. 0 < R[g] && (h += v(this, R[g]));
  22590. for (e >= f && (this.b = e, d = this.f(), e = this.b); k--;) d[e] = d[e++-h]
  22591. }
  22592. for (; 8 <= this.e;) this.e -= 8, this.c--;
  22593. this.b = e
  22594. };
  22595. s.prototype.I = function(a, c) {
  22596. var d = this.a,
  22597. e = this.b;
  22598. this.u = a;
  22599. for (var f = d.length, g, h, k; 256 !== (g = u(this, a));)
  22600. if (256 > g) e >= f && (d = this.f(), f = d.length), d[e++] = g;
  22601. else {
  22602. g -= 257;
  22603. k = T[g];
  22604. 0 < Q[g] && (k += v(this, Q[g]));
  22605. g = u(this, c);
  22606. h = U[g];
  22607. 0 < R[g] && (h += v(this, R[g]));
  22608. for (e + k > f && (d = this.f(), f = d.length); k--;) d[e] = d[e++-h]
  22609. }
  22610. for (; 8 <= this.e;) this.e -= 8, this.c--;
  22611. this.b = e
  22612. };
  22613. s.prototype.f = function() {
  22614. var a = new(z ? Uint8Array : Array)(this.b - 32768),
  22615. c = this.b - 32768,
  22616. d, e, f = this.a;
  22617. if (z) a.set(f.subarray(32768, a.length));
  22618. else {
  22619. d = 0;
  22620. for (e = a.length; d < e; ++d) a[d] = f[d + 32768]
  22621. }
  22622. this.k.push(a);
  22623. this.q += a.length;
  22624. if (z) f.set(f.subarray(c, c + 32768));
  22625. else
  22626. for (d = 0; 32768 > d; ++d) f[d] = f[c + d];
  22627. this.b = 32768;
  22628. return f
  22629. };
  22630. s.prototype.J = function(a) {
  22631. var c, d = this.input.length / this.c + 1 | 0,
  22632. e, f, g, h = this.input,
  22633. k = this.a;
  22634. a && ("number" === typeof a.v && (d = a.v), "number" === typeof a.F && (d += a.F));
  22635. 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;
  22636. z ? (c = new Uint8Array(f), c.set(k)) : c = k;
  22637. return this.a = c
  22638. };
  22639. s.prototype.t = function() {
  22640. var a = 0,
  22641. c = this.a,
  22642. d = this.k,
  22643. e, f = new(z ? Uint8Array : Array)(this.q + (this.b - 32768)),
  22644. g, h, k, m;
  22645. if (0 === d.length) return z ? this.a.subarray(32768, this.b) : this.a.slice(32768, this.b);
  22646. g = 0;
  22647. for (h = d.length; g < h; ++g) {
  22648. e = d[g];
  22649. k = 0;
  22650. for (m = e.length; k < m; ++k) f[a++] = e[k]
  22651. }
  22652. g = 32768;
  22653. for (h = this.b; g < h; ++g) f[a++] = c[g];
  22654. this.k = [];
  22655. return this.buffer = f
  22656. };
  22657. s.prototype.H = function() {
  22658. var a, c = this.b;
  22659. 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);
  22660. return this.buffer = a
  22661. };
  22662. A.prototype.p = function() {
  22663. var c = this.input,
  22664. e, f;
  22665. e = this.A.p();
  22666. this.c = this.A.c;
  22667. 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")));
  22668. return e
  22669. };
  22670. c("Zlib.Inflate", A);
  22671. c("Zlib.Inflate.BufferType", C);
  22672. C.ADAPTIVE = C.C;
  22673. C.BLOCK = C.D;
  22674. c("Zlib.Inflate.prototype.decompress", A.prototype.p);
  22675. C = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  22676. z && new Uint16Array(C);
  22677. 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];
  22678. z && new Uint16Array(C);
  22679. 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];
  22680. z && new Uint8Array(C);
  22681. 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];
  22682. z && new Uint16Array(C);
  22683. 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];
  22684. z && new Uint8Array(C);
  22685. C = new(z ? Uint8Array : Array)(288);
  22686. w = 0;
  22687. for (B = C.length; w < B; ++w) C[w] = 143 >= w ? 8 : 255 >= w ? 9 : 279 >= w ? 7 : 8;
  22688. g(C);
  22689. C = new(z ? Uint8Array : Array)(30);
  22690. w = 0;
  22691. for (B = C.length; w < B; ++w) C[w] = 5;
  22692. g(C);
  22693. var O = 8
  22694. }).call(this);
  22695. _p = window;
  22696. _p = _p.Zlib = _p.Zlib;
  22697. _p.Deflate = _p.Deflate;
  22698. _p.Deflate.compress = _p.Deflate.compress;
  22699. _p.Inflate = _p.Inflate;
  22700. _p.Inflate.BufferType = _p.Inflate.BufferType;
  22701. _p.Inflate.prototype.decompress = _p.Inflate.prototype.decompress;
  22702. cc.PNGReader = cc.Class.extend({
  22703. ctor: function(a) {
  22704. var c, d, e, f;
  22705. this.data = a;
  22706. this.pos = 8;
  22707. this.palette = [];
  22708. this.imgData = [];
  22709. this.transparency = {};
  22710. this.animation = null;
  22711. this.text = {};
  22712. for (e = null;;) {
  22713. c = this.readUInt32();
  22714. f = a = void 0;
  22715. f = [];
  22716. for (a = 0; 4 > a; ++a) f.push(String.fromCharCode(this.data[this.pos++]));
  22717. a = f.join("");
  22718. switch (a) {
  22719. case "IHDR":
  22720. this.width = this.readUInt32();
  22721. this.height = this.readUInt32();
  22722. this.bits = this.data[this.pos++];
  22723. this.colorType = this.data[this.pos++];
  22724. this.compressionMethod = this.data[this.pos++];
  22725. this.filterMethod = this.data[this.pos++];
  22726. this.interlaceMethod = this.data[this.pos++];
  22727. break;
  22728. case "acTL":
  22729. this.animation = {
  22730. numFrames: this.readUInt32(),
  22731. numPlays: this.readUInt32() || Infinity,
  22732. frames: []
  22733. };
  22734. break;
  22735. case "PLTE":
  22736. this.palette = this.read(c);
  22737. break;
  22738. case "fcTL":
  22739. e && this.animation.frames.push(e);
  22740. this.pos += 4;
  22741. e = {
  22742. width: this.readUInt32(),
  22743. height: this.readUInt32(),
  22744. xOffset: this.readUInt32(),
  22745. yOffset: this.readUInt32()
  22746. };
  22747. a = this.readUInt16();
  22748. c = this.readUInt16() || 100;
  22749. e.delay = 1E3 * a / c;
  22750. e.disposeOp = this.data[this.pos++];
  22751. e.blendOp = this.data[this.pos++];
  22752. e.data = [];
  22753. break;
  22754. case "IDAT":
  22755. case "fdAT":
  22756. "fdAT" === a && (this.pos += 4, c -= 4);
  22757. a = (null != e ? e.data : void 0) || this.imgData;
  22758. for (f = 0; 0 <= c ? f < c : f > c; 0 <= c ? ++f : --f) a.push(this.data[this.pos++]);
  22759. break;
  22760. case "tRNS":
  22761. this.transparency = {};
  22762. switch (this.colorType) {
  22763. case 3:
  22764. this.transparency.indexed = this.read(c);
  22765. c = 255 - this.transparency.indexed.length;
  22766. if (0 < c)
  22767. for (a = 0; 0 <= c ? a < c : a > c; 0 <= c ? ++a : --a) this.transparency.indexed.push(255);
  22768. break;
  22769. case 0:
  22770. this.transparency.grayscale = this.read(c)[0];
  22771. break;
  22772. case 2:
  22773. this.transparency.rgb = this.read(c)
  22774. }
  22775. break;
  22776. case "tEXt":
  22777. f = this.read(c);
  22778. c = f.indexOf(0);
  22779. a = String.fromCharCode.apply(String, f.slice(0, c));
  22780. this.text[a] = String.fromCharCode.apply(String, f.slice(c + 1));
  22781. break;
  22782. case "IEND":
  22783. e && this.animation.frames.push(e);
  22784. a: {
  22785. switch (this.colorType) {
  22786. case 0:
  22787. case 3:
  22788. case 4:
  22789. e = 1;
  22790. break a;
  22791. case 2:
  22792. case 6:
  22793. e = 3;
  22794. break a
  22795. }
  22796. e = void 0
  22797. }
  22798. this.colors = e;
  22799. this.hasAlphaChannel = 4 === (d = this.colorType) || 6 === d;
  22800. d = this.colors + (this.hasAlphaChannel ? 1 : 0);
  22801. this.pixelBitlength = this.bits * d;
  22802. a: {
  22803. switch (this.colors) {
  22804. case 1:
  22805. d = "DeviceGray";
  22806. break a;
  22807. case 3:
  22808. d = "DeviceRGB";
  22809. break a
  22810. }
  22811. d = void 0
  22812. }
  22813. this.colorSpace = d;
  22814. Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData));
  22815. return;
  22816. default:
  22817. this.pos += c
  22818. }
  22819. this.pos += 4;
  22820. if (this.pos > this.data.length) throw Error("Incomplete or corrupt PNG file");
  22821. }
  22822. },
  22823. read: function(a) {
  22824. var c, d;
  22825. d = [];
  22826. for (c = 0; 0 <= a ? c < a : c > a; 0 <= a ? ++c : --c) d.push(this.data[this.pos++]);
  22827. return d
  22828. },
  22829. readUInt32: function() {
  22830. var a, c, d, e;
  22831. a = this.data[this.pos++] << 24;
  22832. c = this.data[this.pos++] << 16;
  22833. d = this.data[this.pos++] << 8;
  22834. e = this.data[this.pos++];
  22835. return a | c | d | e
  22836. },
  22837. readUInt16: function() {
  22838. var a, c;
  22839. a = this.data[this.pos++] << 8;
  22840. c = this.data[this.pos++];
  22841. return a | c
  22842. },
  22843. decodePixels: function(a) {
  22844. var c, d, e, f, g, h, k, m, n, q, r, t, s, v, u;
  22845. null == a && (a = this.imgData);
  22846. if (0 === a.length) return new Uint8Array(0);
  22847. a = (new Zlib.Inflate(a, {
  22848. index: 0,
  22849. verify: !1
  22850. })).decompress();
  22851. m = this.pixelBitlength / 8;
  22852. t = m * this.width;
  22853. n = new Uint8Array(t * this.height);
  22854. h = a.length;
  22855. for (d = q = r = 0; q < h;) {
  22856. switch (a[q++]) {
  22857. case 0:
  22858. for (c = 0; c < t; c += 1) n[d++] = a[q++];
  22859. break;
  22860. case 1:
  22861. for (f = s = 0; s < t; f = s += 1) c = a[q++], g = f < m ? 0 : n[d - m], n[d++] = (c + g) % 256;
  22862. break;
  22863. case 2:
  22864. 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;
  22865. break;
  22866. case 3:
  22867. 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;
  22868. break;
  22869. case 4:
  22870. 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;
  22871. break;
  22872. default:
  22873. throw Error("Invalid filter algorithm: " + a[q - 1]);
  22874. }
  22875. r++
  22876. }
  22877. return n
  22878. },
  22879. copyToImageData: function(a, c) {
  22880. var d, e, f, g, h, k, m, n;
  22881. e = this.colors;
  22882. n = null;
  22883. d = this.hasAlphaChannel;
  22884. this.palette.length && (n = null != (f = this._decodedPalette) ? f : this._decodedPalette = this.decodePalette(), e = 4, d = !0);
  22885. f = a.data || a;
  22886. m = f.length;
  22887. h = n || c;
  22888. g = k = 0;
  22889. if (1 === e)
  22890. 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;
  22891. else
  22892. 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
  22893. },
  22894. decodePalette: function() {
  22895. var a, c, d, e, f, g, h, k, m;
  22896. d = this.palette;
  22897. g = this.transparency.indexed || [];
  22898. f = new Uint8Array((g.length || 0) + d.length);
  22899. c = h = a = e = 0;
  22900. 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;
  22901. return f
  22902. },
  22903. render: function(a) {
  22904. var c;
  22905. a.width = this.width;
  22906. a.height = this.height;
  22907. a = a.getContext("2d");
  22908. c = a.createImageData(this.width, this.height);
  22909. this.copyToImageData(c, this.decodePixels());
  22910. return a.putImageData(c, 0, 0)
  22911. }
  22912. });
  22913. cc.tiffReader = {
  22914. _littleEndian: !1,
  22915. _tiffData: null,
  22916. _fileDirectories: [],
  22917. getUint8: function(a) {
  22918. return this._tiffData[a]
  22919. },
  22920. getUint16: function(a) {
  22921. return this._littleEndian ? this._tiffData[a + 1] << 8 | this._tiffData[a] : this._tiffData[a] << 8 | this._tiffData[a + 1]
  22922. },
  22923. getUint32: function(a) {
  22924. var c = this._tiffData;
  22925. 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]
  22926. },
  22927. checkLittleEndian: function() {
  22928. var a = this.getUint16(0);
  22929. if (18761 === a) this.littleEndian = !0;
  22930. else if (19789 === a) this.littleEndian = !1;
  22931. else throw TypeError("Invalid byte order value.");
  22932. return this.littleEndian
  22933. },
  22934. hasTowel: function() {
  22935. if (42 !== this.getUint16(2)) throw RangeError("You forgot your towel!");
  22936. return !0
  22937. },
  22938. getFieldTypeName: function(a) {
  22939. var c = this.fieldTypeNames;
  22940. return a in c ? c[a] : null
  22941. },
  22942. getFieldTagName: function(a) {
  22943. var c = this.fieldTagNames;
  22944. if (a in c) return c[a];
  22945. return "Tag" + a
  22946. },
  22947. getFieldTypeLength: function(a) {
  22948. 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
  22949. },
  22950. getFieldValues: function(a, c, d, e) {
  22951. a = [];
  22952. var f = this.getFieldTypeLength(c);
  22953. if (4 >= f * d)!1 === this.littleEndian ? a.push(e >>> 8 * (4 - f)) : a.push(e);
  22954. else
  22955. for (var g = 0; g < d; g++) {
  22956. var h = f * g;
  22957. 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))
  22958. }
  22959. "ASCII" === c && a.forEach(function(a, c, d) {
  22960. d[c] = String.fromCharCode(a)
  22961. });
  22962. return a
  22963. },
  22964. getBytes: function(a, c) {
  22965. if (0 >= a) cc.log("No bytes requested");
  22966. else {
  22967. if (1 >= a) return this.getUint8(c);
  22968. if (2 >= a) return this.getUint16(c);
  22969. if (3 >= a) return this.getUint32(c) >>> 8;
  22970. if (4 >= a) return this.getUint32(c);
  22971. cc.log("Too many bytes requested")
  22972. }
  22973. },
  22974. getBits: function(a, c, d) {
  22975. d = d || 0;
  22976. c += Math.floor(d / 8);
  22977. var e = d + a;
  22978. a = 32 - a;
  22979. var f, g;
  22980. 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");
  22981. return {
  22982. bits: g << f >>> a,
  22983. byteOffset: c + Math.floor(e / 8),
  22984. bitOffset: e % 8
  22985. }
  22986. },
  22987. parseFileDirectory: function(a) {
  22988. var c = this.getUint16(a),
  22989. d = [];
  22990. a += 2;
  22991. for (var e = 0; e < c; a += 12, e++) {
  22992. var f = this.getUint16(a),
  22993. g = this.getUint16(a + 2),
  22994. h = this.getUint32(a + 4),
  22995. k = this.getUint32(a + 8),
  22996. f = this.getFieldTagName(f),
  22997. g = this.getFieldTypeName(g),
  22998. h = this.getFieldValues(f, g, h, k);
  22999. d[f] = {
  23000. type: g,
  23001. values: h
  23002. }
  23003. }
  23004. this._fileDirectories.push(d);
  23005. c = this.getUint32(a);
  23006. 0 !== c && this.parseFileDirectory(c)
  23007. },
  23008. clampColorSample: function(a, c) {
  23009. var d = Math.pow(2, 8 - c);
  23010. return Math.floor(a * d + (d - 1))
  23011. },
  23012. parseTIFF: function(a, c) {
  23013. c = c || cc.newElement("canvas");
  23014. this._tiffData = a;
  23015. this.canvas = c;
  23016. this.checkLittleEndian();
  23017. if (this.hasTowel()) {
  23018. var d = this.getUint32(4);
  23019. this._fileDirectories.length = 0;
  23020. this.parseFileDirectory(d);
  23021. var e = this._fileDirectories[0],
  23022. d = e.ImageWidth.values[0],
  23023. f = e.ImageLength.values[0];
  23024. this.canvas.width = d;
  23025. this.canvas.height = f;
  23026. var g = [],
  23027. h = e.Compression ? e.Compression.values[0] : 1,
  23028. k = e.SamplesPerPixel.values[0],
  23029. m = [],
  23030. n = 0,
  23031. q = !1;
  23032. e.BitsPerSample.values.forEach(function(a, c, d) {
  23033. m[c] = {
  23034. bitsPerSample: a,
  23035. hasBytesPerSample: !1,
  23036. bytesPerSample: void 0
  23037. };
  23038. 0 === a % 8 && (m[c].hasBytesPerSample = !0, m[c].bytesPerSample = a / 8);
  23039. n += a
  23040. }, this);
  23041. if (0 === n % 8) var q = !0,
  23042. r = n / 8;
  23043. var t = e.StripOffsets.values,
  23044. s = t.length;
  23045. if (e.StripByteCounts) var v = e.StripByteCounts.values;
  23046. else if (cc.log("Missing StripByteCounts!"), 1 === s) v = [Math.ceil(d * f * n / 8)];
  23047. else throw Error("Cannot recover from missing StripByteCounts");
  23048. for (var u = 0; u < s; u++) {
  23049. var x = t[u];
  23050. g[u] = [];
  23051. 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) {
  23052. case 1:
  23053. y = 0;
  23054. for (C = []; y < k; y++)
  23055. if (m[y].hasBytesPerSample) C.push(this.getBytes(m[y].bytesPerSample, x + D + m[y].bytesPerSample * y));
  23056. else {
  23057. var H = this.getBits(m[y].bitsPerSample, x + D, F);
  23058. C.push(H.bits);
  23059. D = H.byteOffset - x;
  23060. F = H.bitOffset;
  23061. throw RangeError("Cannot handle sub-byte bits per sample");
  23062. }
  23063. g[u].push(C);
  23064. if (q) y = r;
  23065. else throw y = 0, RangeError("Cannot handle sub-byte bits per pixel");
  23066. break;
  23067. case 32773:
  23068. if (z) {
  23069. var z = !1,
  23070. E = 1,
  23071. K = 1,
  23072. y = this.getInt8(x + D);
  23073. 0 <= y && 127 >= y ? E = y + 1 : -127 <= y && -1 >= y ? K = -y + 1 : z = !0
  23074. } else {
  23075. for (var M = this.getUint8(x + D), y = 0; y < K; y++) {
  23076. if (m[B].hasBytesPerSample) G = G << 8 * w | M, w++, w === m[B].bytesPerSample && (C.push(G), G = w = 0, B++);
  23077. else throw RangeError("Cannot handle sub-byte bits per sample");
  23078. B === k && (g[u].push(C), C = [], B = 0)
  23079. }
  23080. E--;
  23081. 0 === E && (z = !0)
  23082. }
  23083. y = 1
  23084. }
  23085. }
  23086. if (c.getContext) {
  23087. r = this.canvas.getContext("2d");
  23088. r.fillStyle = "rgba(255, 255, 255, 0)";
  23089. u = e.RowsPerStrip ? e.RowsPerStrip.values[0] : f;
  23090. x = g.length;
  23091. f %= u;
  23092. f = 0 === f ? u : f;
  23093. D = u;
  23094. h = 0;
  23095. C = e.PhotometricInterpretation.values[0];
  23096. E = [];
  23097. K = 0;
  23098. e.ExtraSamples && (E = e.ExtraSamples.values, K = E.length);
  23099. if (e.ColorMap) var H = e.ColorMap.values,
  23100. L = Math.pow(2, m[0].bitsPerSample);
  23101. for (u = 0; u < x; u++) {
  23102. u + 1 === x && (D = f);
  23103. e = g[u].length;
  23104. h *= u;
  23105. for (q = k = 0; k < D, q < e; k++)
  23106. for (t = 0; t < d; t++, q++) {
  23107. v = g[u][q];
  23108. z = F = A = 0;
  23109. s = 1;
  23110. if (0 < K)
  23111. for (A = 0; A < K; A++)
  23112. if (1 === E[A] || 2 === E[A]) {
  23113. s = v[3 + A] / 256;
  23114. break
  23115. }
  23116. switch (C) {
  23117. case 0:
  23118. if (m[0].hasBytesPerSample) var N = Math.pow(16, 2 * m[0].bytesPerSample);
  23119. v.forEach(function(a, c, d) {
  23120. d[c] = N - a
  23121. });
  23122. case 1:
  23123. A = F = z = this.clampColorSample(v[0], m[0].bitsPerSample);
  23124. break;
  23125. case 2:
  23126. A = this.clampColorSample(v[0], m[0].bitsPerSample);
  23127. F = this.clampColorSample(v[1], m[1].bitsPerSample);
  23128. z = this.clampColorSample(v[2], m[2].bitsPerSample);
  23129. break;
  23130. case 3:
  23131. if (void 0 === H) throw Error("Palette image missing color map");
  23132. v = v[0];
  23133. A = this.clampColorSample(H[v], 16);
  23134. F = this.clampColorSample(H[L + v], 16);
  23135. z = this.clampColorSample(H[2 * L + v], 16);
  23136. break;
  23137. default:
  23138. throw RangeError("Unknown Photometric Interpretation:", C);
  23139. }
  23140. r.fillStyle = "rgba(" + A + ", " + F + ", " + z + ", " + s + ")";
  23141. r.fillRect(t, h + k, 1, 1)
  23142. }
  23143. h = D
  23144. }
  23145. }
  23146. return this.canvas
  23147. }
  23148. },
  23149. fieldTagNames: {
  23150. 315: "Artist",
  23151. 258: "BitsPerSample",
  23152. 265: "CellLength",
  23153. 264: "CellWidth",
  23154. 320: "ColorMap",
  23155. 259: "Compression",
  23156. 33432: "Copyright",
  23157. 306: "DateTime",
  23158. 338: "ExtraSamples",
  23159. 266: "FillOrder",
  23160. 289: "FreeByteCounts",
  23161. 288: "FreeOffsets",
  23162. 291: "GrayResponseCurve",
  23163. 290: "GrayResponseUnit",
  23164. 316: "HostComputer",
  23165. 270: "ImageDescription",
  23166. 257: "ImageLength",
  23167. 256: "ImageWidth",
  23168. 271: "Make",
  23169. 281: "MaxSampleValue",
  23170. 280: "MinSampleValue",
  23171. 272: "Model",
  23172. 254: "NewSubfileType",
  23173. 274: "Orientation",
  23174. 262: "PhotometricInterpretation",
  23175. 284: "PlanarConfiguration",
  23176. 296: "ResolutionUnit",
  23177. 278: "RowsPerStrip",
  23178. 277: "SamplesPerPixel",
  23179. 305: "Software",
  23180. 279: "StripByteCounts",
  23181. 273: "StripOffsets",
  23182. 255: "SubfileType",
  23183. 263: "Threshholding",
  23184. 282: "XResolution",
  23185. 283: "YResolution",
  23186. 326: "BadFaxLines",
  23187. 327: "CleanFaxData",
  23188. 343: "ClipPath",
  23189. 328: "ConsecutiveBadFaxLines",
  23190. 433: "Decode",
  23191. 434: "DefaultImageColor",
  23192. 269: "DocumentName",
  23193. 336: "DotRange",
  23194. 321: "HalftoneHints",
  23195. 346: "Indexed",
  23196. 347: "JPEGTables",
  23197. 285: "PageName",
  23198. 297: "PageNumber",
  23199. 317: "Predictor",
  23200. 319: "PrimaryChromaticities",
  23201. 532: "ReferenceBlackWhite",
  23202. 339: "SampleFormat",
  23203. 559: "StripRowCounts",
  23204. 330: "SubIFDs",
  23205. 292: "T4Options",
  23206. 293: "T6Options",
  23207. 325: "TileByteCounts",
  23208. 323: "TileLength",
  23209. 324: "TileOffsets",
  23210. 322: "TileWidth",
  23211. 301: "TransferFunction",
  23212. 318: "WhitePoint",
  23213. 344: "XClipPathUnits",
  23214. 286: "XPosition",
  23215. 529: "YCbCrCoefficients",
  23216. 531: "YCbCrPositioning",
  23217. 530: "YCbCrSubSampling",
  23218. 345: "YClipPathUnits",
  23219. 287: "YPosition",
  23220. 37378: "ApertureValue",
  23221. 40961: "ColorSpace",
  23222. 36868: "DateTimeDigitized",
  23223. 36867: "DateTimeOriginal",
  23224. 34665: "Exif IFD",
  23225. 36864: "ExifVersion",
  23226. 33434: "ExposureTime",
  23227. 41728: "FileSource",
  23228. 37385: "Flash",
  23229. 40960: "FlashpixVersion",
  23230. 33437: "FNumber",
  23231. 42016: "ImageUniqueID",
  23232. 37384: "LightSource",
  23233. 37500: "MakerNote",
  23234. 37377: "ShutterSpeedValue",
  23235. 37510: "UserComment",
  23236. 33723: "IPTC",
  23237. 34675: "ICC Profile",
  23238. 700: "XMP",
  23239. 42112: "GDAL_METADATA",
  23240. 42113: "GDAL_NODATA",
  23241. 34377: "Photoshop"
  23242. },
  23243. fieldTypeNames: {
  23244. 1: "BYTE",
  23245. 2: "ASCII",
  23246. 3: "SHORT",
  23247. 4: "LONG",
  23248. 5: "RATIONAL",
  23249. 6: "SBYTE",
  23250. 7: "UNDEFINED",
  23251. 8: "SSHORT",
  23252. 9: "SLONG",
  23253. 10: "SRATIONAL",
  23254. 11: "FLOAT",
  23255. 12: "DOUBLE"
  23256. }
  23257. };
  23258. cc.Particle = function(a, c, d, e, f, g, h, k, m, n, q, r) {
  23259. this.pos = a ? a : cc.p(0, 0);
  23260. this.startPos = c ? c : cc.p(0, 0);
  23261. this.color = d ? d : {
  23262. r: 0,
  23263. g: 0,
  23264. b: 0,
  23265. a: 255
  23266. };
  23267. this.deltaColor = e ? e : {
  23268. r: 0,
  23269. g: 0,
  23270. b: 0,
  23271. a: 255
  23272. };
  23273. this.size = f || 0;
  23274. this.deltaSize = g || 0;
  23275. this.rotation = h || 0;
  23276. this.deltaRotation = k || 0;
  23277. this.timeToLive = m || 0;
  23278. this.atlasIndex = n || 0;
  23279. this.modeA = q ? q : new cc.Particle.ModeA;
  23280. this.modeB = r ? r : new cc.Particle.ModeB;
  23281. this.isChangeColor = !1;
  23282. this.drawPos = cc.p(0, 0)
  23283. };
  23284. cc.Particle.ModeA = function(a, c, d) {
  23285. this.dir = a ? a : cc.p(0, 0);
  23286. this.radialAccel = c || 0;
  23287. this.tangentialAccel = d || 0
  23288. };
  23289. cc.Particle.ModeB = function(a, c, d, e) {
  23290. this.angle = a || 0;
  23291. this.degreesPerSecond = c || 0;
  23292. this.radius = d || 0;
  23293. this.deltaRadius = e || 0
  23294. };
  23295. cc.Particle.TemporaryPoints = [cc.p(), cc.p(), cc.p(), cc.p()];
  23296. cc.ParticleSystem = cc.Node.extend({
  23297. _plistFile: "",
  23298. _elapsed: 0,
  23299. _dontTint: !1,
  23300. modeA: null,
  23301. modeB: null,
  23302. _className: "ParticleSystem",
  23303. _pointZeroForParticle: cc.p(0, 0),
  23304. _particles: null,
  23305. _emitCounter: 0,
  23306. _particleIdx: 0,
  23307. _batchNode: null,
  23308. atlasIndex: 0,
  23309. _transformSystemDirty: !1,
  23310. _allocatedParticles: 0,
  23311. drawMode: null,
  23312. shapeType: null,
  23313. _isActive: !1,
  23314. particleCount: 0,
  23315. duration: 0,
  23316. _sourcePosition: null,
  23317. _posVar: null,
  23318. life: 0,
  23319. lifeVar: 0,
  23320. angle: 0,
  23321. angleVar: 0,
  23322. startSize: 0,
  23323. startSizeVar: 0,
  23324. endSize: 0,
  23325. endSizeVar: 0,
  23326. _startColor: null,
  23327. _startColorVar: null,
  23328. _endColor: null,
  23329. _endColorVar: null,
  23330. startSpin: 0,
  23331. startSpinVar: 0,
  23332. endSpin: 0,
  23333. endSpinVar: 0,
  23334. emissionRate: 0,
  23335. _totalParticles: 0,
  23336. _texture: null,
  23337. _blendFunc: null,
  23338. _opacityModifyRGB: !1,
  23339. positionType: null,
  23340. autoRemoveOnFinish: !1,
  23341. emitterMode: 0,
  23342. _quads: null,
  23343. _indices: null,
  23344. _buffersVBO: null,
  23345. _pointRect: null,
  23346. _textureLoaded: null,
  23347. _quadsArrayBuffer: null,
  23348. ctor: function(a) {
  23349. cc.Node.prototype.ctor.call(this);
  23350. this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
  23351. this.modeA = new cc.ParticleSystem.ModeA;
  23352. this.modeB = new cc.ParticleSystem.ModeB;
  23353. this._blendFunc = {
  23354. src: cc.BLEND_SRC,
  23355. dst: cc.BLEND_DST
  23356. };
  23357. this._particles = [];
  23358. this._sourcePosition = cc.p(0, 0);
  23359. this._posVar = cc.p(0, 0);
  23360. this._startColor = cc.color(255, 255, 255, 255);
  23361. this._startColorVar = cc.color(255, 255, 255, 255);
  23362. this._endColor = cc.color(255, 255, 255, 255);
  23363. this._endColorVar = cc.color(255, 255, 255, 255);
  23364. this._plistFile = "";
  23365. this._elapsed = 0;
  23366. this._dontTint = !1;
  23367. this._pointZeroForParticle = cc.p(0, 0);
  23368. this._particleIdx = this._emitCounter = 0;
  23369. this._batchNode = null;
  23370. this.atlasIndex = 0;
  23371. this._transformSystemDirty = !1;
  23372. this._allocatedParticles = 0;
  23373. this.drawMode = cc.ParticleSystem.SHAPE_MODE;
  23374. this.shapeType = cc.ParticleSystem.BALL_SHAPE;
  23375. this._isActive = !1;
  23376. 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;
  23377. this._texture = null;
  23378. this._opacityModifyRGB = !1;
  23379. this.positionType = cc.ParticleSystem.TYPE_FREE;
  23380. this.autoRemoveOnFinish = !1;
  23381. this._buffersVBO = [0, 0];
  23382. this._quads = [];
  23383. this._indices = [];
  23384. this._pointRect = cc.rect(0, 0, 0, 0);
  23385. this._textureLoaded = !0;
  23386. cc._renderType === cc._RENDER_TYPE_WEBGL && (this._quadsArrayBuffer = null);
  23387. !a || "number" === typeof a ? (a = a || 100, this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE), this.initWithTotalParticles(a)) : a && this.initWithFile(a)
  23388. },
  23389. initIndices: function() {
  23390. for (var a = this._indices, c = 0, d = this._totalParticles; c < d; ++c) {
  23391. var e = 6 * c,
  23392. f = 4 * c;
  23393. a[e + 0] = f + 0;
  23394. a[e + 1] = f + 1;
  23395. a[e + 2] = f + 2;
  23396. a[e + 5] = f + 1;
  23397. a[e + 4] = f + 2;
  23398. a[e + 3] = f + 3
  23399. }
  23400. },
  23401. initTexCoordsWithRect: function(a) {
  23402. var c = cc.contentScaleFactor(),
  23403. d = cc.rect(a.x * c, a.y * c, a.width * c, a.height * c),
  23404. e = a.width,
  23405. f = a.height;
  23406. this._texture && (e = this._texture.pixelsWidth, f = this._texture.pixelsHeight);
  23407. if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
  23408. 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);
  23409. var f = d,
  23410. d = c,
  23411. c = f,
  23412. g = 0,
  23413. h = 0;
  23414. this._batchNode ? (f = this._batchNode.textureAtlas.quads, g = this.atlasIndex, h = this.atlasIndex + this._totalParticles) : (f = this._quads, g = 0, h = this._totalParticles);
  23415. for (; g < h; g++) {
  23416. f[g] || (f[g] = cc.V3F_C4B_T2F_QuadZero());
  23417. var k = f[g];
  23418. k.bl.texCoords.u = a;
  23419. k.bl.texCoords.v = c;
  23420. k.br.texCoords.u = e;
  23421. k.br.texCoords.v = c;
  23422. k.tl.texCoords.u = a;
  23423. k.tl.texCoords.v = d;
  23424. k.tr.texCoords.u = e;
  23425. k.tr.texCoords.v = d
  23426. }
  23427. }
  23428. },
  23429. getBatchNode: function() {
  23430. return this._batchNode
  23431. },
  23432. setBatchNode: function(a) {
  23433. if (this._batchNode != a) {
  23434. var c = this._batchNode;
  23435. if (this._batchNode = a)
  23436. for (var d = this._particles, e = 0; e < this._totalParticles; e++) d[e].atlasIndex = e;
  23437. 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())
  23438. }
  23439. },
  23440. getAtlasIndex: function() {
  23441. return this.atlasIndex
  23442. },
  23443. setAtlasIndex: function(a) {
  23444. this.atlasIndex = a
  23445. },
  23446. getDrawMode: function() {
  23447. return this.drawMode
  23448. },
  23449. setDrawMode: function(a) {
  23450. this.drawMode = a
  23451. },
  23452. getShapeType: function() {
  23453. return this.shapeType
  23454. },
  23455. setShapeType: function(a) {
  23456. this.shapeType = a
  23457. },
  23458. isActive: function() {
  23459. return this._isActive
  23460. },
  23461. getParticleCount: function() {
  23462. return this.particleCount
  23463. },
  23464. setParticleCount: function(a) {
  23465. this.particleCount = a
  23466. },
  23467. getDuration: function() {
  23468. return this.duration
  23469. },
  23470. setDuration: function(a) {
  23471. this.duration = a
  23472. },
  23473. getSourcePosition: function() {
  23474. return {
  23475. x: this._sourcePosition.x,
  23476. y: this._sourcePosition.y
  23477. }
  23478. },
  23479. setSourcePosition: function(a) {
  23480. this._sourcePosition = a
  23481. },
  23482. getPosVar: function() {
  23483. return {
  23484. x: this._posVar.x,
  23485. y: this._posVar.y
  23486. }
  23487. },
  23488. setPosVar: function(a) {
  23489. this._posVar = a
  23490. },
  23491. getLife: function() {
  23492. return this.life
  23493. },
  23494. setLife: function(a) {
  23495. this.life = a
  23496. },
  23497. getLifeVar: function() {
  23498. return this.lifeVar
  23499. },
  23500. setLifeVar: function(a) {
  23501. this.lifeVar = a
  23502. },
  23503. getAngle: function() {
  23504. return this.angle
  23505. },
  23506. setAngle: function(a) {
  23507. this.angle = a
  23508. },
  23509. getAngleVar: function() {
  23510. return this.angleVar
  23511. },
  23512. setAngleVar: function(a) {
  23513. this.angleVar = a
  23514. },
  23515. getGravity: function() {
  23516. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");
  23517. var a = this.modeA.gravity;
  23518. return cc.p(a.x, a.y)
  23519. },
  23520. setGravity: function(a) {
  23521. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");
  23522. this.modeA.gravity = a
  23523. },
  23524. getSpeed: function() {
  23525. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");
  23526. return this.modeA.speed
  23527. },
  23528. setSpeed: function(a) {
  23529. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");
  23530. this.modeA.speed = a
  23531. },
  23532. getSpeedVar: function() {
  23533. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");
  23534. return this.modeA.speedVar
  23535. },
  23536. setSpeedVar: function(a) {
  23537. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
  23538. this.modeA.speedVar = a
  23539. },
  23540. getTangentialAccel: function() {
  23541. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");
  23542. return this.modeA.tangentialAccel
  23543. },
  23544. setTangentialAccel: function(a) {
  23545. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");
  23546. this.modeA.tangentialAccel = a
  23547. },
  23548. getTangentialAccelVar: function() {
  23549. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");
  23550. return this.modeA.tangentialAccelVar
  23551. },
  23552. setTangentialAccelVar: function(a) {
  23553. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");
  23554. this.modeA.tangentialAccelVar = a
  23555. },
  23556. getRadialAccel: function() {
  23557. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");
  23558. return this.modeA.radialAccel
  23559. },
  23560. setRadialAccel: function(a) {
  23561. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");
  23562. this.modeA.radialAccel = a
  23563. },
  23564. getRadialAccelVar: function() {
  23565. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");
  23566. return this.modeA.radialAccelVar
  23567. },
  23568. setRadialAccelVar: function(a) {
  23569. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
  23570. this.modeA.radialAccelVar = a
  23571. },
  23572. getRotationIsDir: function() {
  23573. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");
  23574. return this.modeA.rotationIsDir
  23575. },
  23576. setRotationIsDir: function(a) {
  23577. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");
  23578. this.modeA.rotationIsDir = a
  23579. },
  23580. getStartRadius: function() {
  23581. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
  23582. return this.modeB.startRadius
  23583. },
  23584. setStartRadius: function(a) {
  23585. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");
  23586. this.modeB.startRadius = a
  23587. },
  23588. getStartRadiusVar: function() {
  23589. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");
  23590. return this.modeB.startRadiusVar
  23591. },
  23592. setStartRadiusVar: function(a) {
  23593. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
  23594. this.modeB.startRadiusVar = a
  23595. },
  23596. getEndRadius: function() {
  23597. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");
  23598. return this.modeB.endRadius
  23599. },
  23600. setEndRadius: function(a) {
  23601. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");
  23602. this.modeB.endRadius = a
  23603. },
  23604. getEndRadiusVar: function() {
  23605. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
  23606. return this.modeB.endRadiusVar
  23607. },
  23608. setEndRadiusVar: function(a) {
  23609. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");
  23610. this.modeB.endRadiusVar = a
  23611. },
  23612. getRotatePerSecond: function() {
  23613. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");
  23614. return this.modeB.rotatePerSecond
  23615. },
  23616. setRotatePerSecond: function(a) {
  23617. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
  23618. this.modeB.rotatePerSecond = a
  23619. },
  23620. getRotatePerSecondVar: function() {
  23621. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");
  23622. return this.modeB.rotatePerSecondVar
  23623. },
  23624. setRotatePerSecondVar: function(a) {
  23625. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");
  23626. this.modeB.rotatePerSecondVar = a
  23627. },
  23628. setScale: function(a, c) {
  23629. this._transformSystemDirty = !0;
  23630. cc.Node.prototype.setScale.call(this, a, c)
  23631. },
  23632. setRotation: function(a) {
  23633. this._transformSystemDirty = !0;
  23634. cc.Node.prototype.setRotation.call(this, a)
  23635. },
  23636. setScaleX: function(a) {
  23637. this._transformSystemDirty = !0;
  23638. cc.Node.prototype.setScaleX.call(this, a)
  23639. },
  23640. setScaleY: function(a) {
  23641. this._transformSystemDirty = !0;
  23642. cc.Node.prototype.setScaleY.call(this, a)
  23643. },
  23644. getStartSize: function() {
  23645. return this.startSize
  23646. },
  23647. setStartSize: function(a) {
  23648. this.startSize = a
  23649. },
  23650. getStartSizeVar: function() {
  23651. return this.startSizeVar
  23652. },
  23653. setStartSizeVar: function(a) {
  23654. this.startSizeVar = a
  23655. },
  23656. getEndSize: function() {
  23657. return this.endSize
  23658. },
  23659. setEndSize: function(a) {
  23660. this.endSize = a
  23661. },
  23662. getEndSizeVar: function() {
  23663. return this.endSizeVar
  23664. },
  23665. setEndSizeVar: function(a) {
  23666. this.endSizeVar = a
  23667. },
  23668. getStartColor: function() {
  23669. return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a)
  23670. },
  23671. setStartColor: function(a) {
  23672. this._startColor = cc.color(a)
  23673. },
  23674. getStartColorVar: function() {
  23675. return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a)
  23676. },
  23677. setStartColorVar: function(a) {
  23678. this._startColorVar = cc.color(a)
  23679. },
  23680. getEndColor: function() {
  23681. return cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a)
  23682. },
  23683. setEndColor: function(a) {
  23684. this._endColor = cc.color(a)
  23685. },
  23686. getEndColorVar: function() {
  23687. return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a)
  23688. },
  23689. setEndColorVar: function(a) {
  23690. this._endColorVar = cc.color(a)
  23691. },
  23692. getStartSpin: function() {
  23693. return this.startSpin
  23694. },
  23695. setStartSpin: function(a) {
  23696. this.startSpin = a
  23697. },
  23698. getStartSpinVar: function() {
  23699. return this.startSpinVar
  23700. },
  23701. setStartSpinVar: function(a) {
  23702. this.startSpinVar = a
  23703. },
  23704. getEndSpin: function() {
  23705. return this.endSpin
  23706. },
  23707. setEndSpin: function(a) {
  23708. this.endSpin = a
  23709. },
  23710. getEndSpinVar: function() {
  23711. return this.endSpinVar
  23712. },
  23713. setEndSpinVar: function(a) {
  23714. this.endSpinVar = a
  23715. },
  23716. getEmissionRate: function() {
  23717. return this.emissionRate
  23718. },
  23719. setEmissionRate: function(a) {
  23720. this.emissionRate = a
  23721. },
  23722. getTotalParticles: function() {
  23723. return this._totalParticles
  23724. },
  23725. setTotalParticles: function(a) {
  23726. if (cc._renderType === cc._RENDER_TYPE_CANVAS) this._totalParticles = 200 > a ? a : 200;
  23727. else {
  23728. if (a > this._allocatedParticles) {
  23729. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  23730. this._indices = new Uint16Array(6 * a);
  23731. var d = new ArrayBuffer(a * c),
  23732. e = this._particles;
  23733. e.length = 0;
  23734. 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);
  23735. this._totalParticles = this._allocatedParticles = a;
  23736. if (this._batchNode)
  23737. for (c = 0; c < a; c++) e[c].atlasIndex = c;
  23738. this._quadsArrayBuffer = d;
  23739. this.initIndices();
  23740. this._setupVBO();
  23741. this._texture && this.initTexCoordsWithRect(cc.rect(0, 0, this._texture.width, this._texture.height))
  23742. } else this._totalParticles = a;
  23743. this.resetSystem()
  23744. }
  23745. },
  23746. getTexture: function() {
  23747. return this._texture
  23748. },
  23749. setTexture: function(a) {
  23750. a.isLoaded() ? this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height)) : (this._textureLoaded = !1, a.addLoadedEventListener(function(a) {
  23751. this._textureLoaded = !0;
  23752. this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height))
  23753. }, this))
  23754. },
  23755. getBlendFunc: function() {
  23756. return this._blendFunc
  23757. },
  23758. setBlendFunc: function(a, c) {
  23759. if (void 0 === c) this._blendFunc != a && (this._blendFunc = a, this._updateBlendFunc());
  23760. else if (this._blendFunc.src != a || this._blendFunc.dst != c) this._blendFunc = {
  23761. src: a,
  23762. dst: c
  23763. }, this._updateBlendFunc()
  23764. },
  23765. isOpacityModifyRGB: function() {
  23766. return this._opacityModifyRGB
  23767. },
  23768. setOpacityModifyRGB: function(a) {
  23769. this._opacityModifyRGB = a
  23770. },
  23771. isBlendAdditive: function() {
  23772. return this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE || this._blendFunc.src == cc.ONE && this._blendFunc.dst == cc.ONE
  23773. },
  23774. setBlendAdditive: function(a) {
  23775. var c = this._blendFunc;
  23776. 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)
  23777. },
  23778. getPositionType: function() {
  23779. return this.positionType
  23780. },
  23781. setPositionType: function(a) {
  23782. this.positionType = a
  23783. },
  23784. isAutoRemoveOnFinish: function() {
  23785. return this.autoRemoveOnFinish
  23786. },
  23787. setAutoRemoveOnFinish: function(a) {
  23788. this.autoRemoveOnFinish = a
  23789. },
  23790. getEmitterMode: function() {
  23791. return this.emitterMode
  23792. },
  23793. setEmitterMode: function(a) {
  23794. this.emitterMode = a
  23795. },
  23796. init: function() {
  23797. return this.initWithTotalParticles(150)
  23798. },
  23799. initWithFile: function(a) {
  23800. this._plistFile = a;
  23801. a = cc.loader.getRes(a);
  23802. return !a ? (cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"), !1) : this.initWithDictionary(a, "")
  23803. },
  23804. getBoundingBoxToWorld: function() {
  23805. return cc.rect(0, 0, cc._canvas.width, cc._canvas.height)
  23806. },
  23807. initWithDictionary: function(a, c) {
  23808. var d = !1,
  23809. e = null,
  23810. e = this._valueForKey,
  23811. f = parseInt(e("maxParticles", a));
  23812. if (this.initWithTotalParticles(f)) {
  23813. this.angle = parseFloat(e("angle", a));
  23814. this.angleVar = parseFloat(e("angleVariance", a));
  23815. this.duration = parseFloat(e("duration", a));
  23816. this._blendFunc.src = parseInt(e("blendFuncSource", a));
  23817. this._blendFunc.dst = parseInt(e("blendFuncDestination", a));
  23818. d = this._startColor;
  23819. d.r = 255 * parseFloat(e("startColorRed", a));
  23820. d.g = 255 * parseFloat(e("startColorGreen", a));
  23821. d.b = 255 * parseFloat(e("startColorBlue", a));
  23822. d.a = 255 * parseFloat(e("startColorAlpha", a));
  23823. d = this._startColorVar;
  23824. d.r = 255 * parseFloat(e("startColorVarianceRed", a));
  23825. d.g = 255 * parseFloat(e("startColorVarianceGreen", a));
  23826. d.b = 255 * parseFloat(e("startColorVarianceBlue", a));
  23827. d.a = 255 * parseFloat(e("startColorVarianceAlpha", a));
  23828. d = this._endColor;
  23829. d.r = 255 * parseFloat(e("finishColorRed", a));
  23830. d.g = 255 * parseFloat(e("finishColorGreen", a));
  23831. d.b = 255 * parseFloat(e("finishColorBlue", a));
  23832. d.a = 255 * parseFloat(e("finishColorAlpha", a));
  23833. d = this._endColorVar;
  23834. d.r = 255 * parseFloat(e("finishColorVarianceRed", a));
  23835. d.g = 255 * parseFloat(e("finishColorVarianceGreen", a));
  23836. d.b = 255 * parseFloat(e("finishColorVarianceBlue", a));
  23837. d.a = 255 * parseFloat(e("finishColorVarianceAlpha", a));
  23838. this.startSize = parseFloat(e("startParticleSize", a));
  23839. this.startSizeVar = parseFloat(e("startParticleSizeVariance", a));
  23840. this.endSize = parseFloat(e("finishParticleSize", a));
  23841. this.endSizeVar = parseFloat(e("finishParticleSizeVariance", a));
  23842. this.setPosition(parseFloat(e("sourcePositionx", a)), parseFloat(e("sourcePositiony", a)));
  23843. this._posVar.x = parseFloat(e("sourcePositionVariancex", a));
  23844. this._posVar.y = parseFloat(e("sourcePositionVariancey", a));
  23845. this.startSpin = parseFloat(e("rotationStart", a));
  23846. this.startSpinVar = parseFloat(e("rotationStartVariance", a));
  23847. this.endSpin = parseFloat(e("rotationEnd", a));
  23848. this.endSpinVar = parseFloat(e("rotationEndVariance", a));
  23849. this.emitterMode = parseInt(e("emitterType", a));
  23850. 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);
  23851. 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));
  23852. else return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"), !1;
  23853. this.life = parseFloat(e("particleLifespan", a));
  23854. this.lifeVar = parseFloat(e("particleLifespanVariance", a));
  23855. this.emissionRate = this._totalParticles / this.life;
  23856. if (!this._batchNode)
  23857. if (this._opacityModifyRGB = !1, d = e("textureFileName", a), d = cc.path.changeBasename(this._plistFile, d), f = cc.textureCache.textureForKey(d)) this.setTexture(f);
  23858. else if (e = e("textureImageData", a), !e || 0 === e.length) {
  23859. f = cc.textureCache.addImage(d);
  23860. if (!f) return !1;
  23861. this.setTexture(f)
  23862. } else {
  23863. e = cc.unzipBase64AsArray(e, 1);
  23864. if (!e) return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"), !1;
  23865. f = cc.getImageFormatByData(e);
  23866. if (f !== cc.FMT_TIFF && f !== cc.FMT_PNG) return cc.log("cc.ParticleSystem: unknown image format with Data"), !1;
  23867. var g = cc.newElement("canvas");
  23868. f === cc.FMT_PNG ? (new cc.PNGReader(e)).render(g) : cc.tiffReader.parseTIFF(e, g);
  23869. cc.textureCache.cacheImage(d, g);
  23870. (e = cc.textureCache.textureForKey(d)) || cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture");
  23871. this.setTexture(e)
  23872. }
  23873. d = !0
  23874. }
  23875. return d
  23876. },
  23877. initWithTotalParticles: function(a) {
  23878. this._totalParticles = a;
  23879. var c, d = this._particles;
  23880. for (c = d.length = 0; c < a; c++) d[c] = new cc.Particle;
  23881. if (!d) return cc.log("Particle system: not enough memory"), !1;
  23882. this._allocatedParticles = a;
  23883. if (this._batchNode)
  23884. for (c = 0; c < this._totalParticles; c++) d[c].atlasIndex = c;
  23885. this._isActive = !0;
  23886. this._blendFunc.src = cc.BLEND_SRC;
  23887. this._blendFunc.dst = cc.BLEND_DST;
  23888. this.positionType = cc.ParticleSystem.TYPE_FREE;
  23889. this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
  23890. this._transformSystemDirty = this.autoRemoveOnFinish = !1;
  23891. this.scheduleUpdateWithPriority(1);
  23892. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  23893. if (!this._allocMemory()) return !1;
  23894. this.initIndices();
  23895. this._setupVBO();
  23896. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  23897. }
  23898. return !0
  23899. },
  23900. destroyParticleSystem: function() {
  23901. this.unscheduleUpdate()
  23902. },
  23903. addParticle: function() {
  23904. if (this.isFull()) return !1;
  23905. var a, c = this._particles;
  23906. 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];
  23907. this.initParticle(a);
  23908. ++this.particleCount;
  23909. return !0
  23910. },
  23911. initParticle: function(a) {
  23912. var c = cc.randomMinus1To1;
  23913. a.timeToLive = this.life + this.lifeVar * c();
  23914. a.timeToLive = Math.max(0, a.timeToLive);
  23915. a.pos.x = this._sourcePosition.x + this._posVar.x * c();
  23916. a.pos.y = this._sourcePosition.y + this._posVar.y * c();
  23917. var d, e;
  23918. d = this._startColor;
  23919. var f = this._startColorVar,
  23920. g = this._endColor;
  23921. e = this._endColorVar;
  23922. 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 = {
  23923. r: cc.clampf(d.r + f.r * c(), 0, 255),
  23924. g: cc.clampf(d.g + f.g * c(), 0, 255),
  23925. b: cc.clampf(d.b + f.b * c(), 0, 255),
  23926. a: cc.clampf(d.a + f.a * c(), 0, 255)
  23927. }, e = {
  23928. r: cc.clampf(g.r + e.r * c(), 0, 255),
  23929. g: cc.clampf(g.g + e.g * c(), 0, 255),
  23930. b: cc.clampf(g.b + e.b * c(), 0, 255),
  23931. a: cc.clampf(g.a + e.a * c(), 0, 255)
  23932. });
  23933. a.color = d;
  23934. f = a.deltaColor;
  23935. g = a.timeToLive;
  23936. f.r = (e.r - d.r) / g;
  23937. f.g = (e.g - d.g) / g;
  23938. f.b = (e.b - d.b) / g;
  23939. f.a = (e.a - d.a) / g;
  23940. d = this.startSize + this.startSizeVar * c();
  23941. d = Math.max(0, d);
  23942. a.size = d;
  23943. 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);
  23944. d = this.startSpin + this.startSpinVar * c();
  23945. e = this.endSpin + this.endSpinVar * c();
  23946. a.rotation = d;
  23947. a.deltaRotation = (e - d) / g;
  23948. 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);
  23949. d = cc.degreesToRadians(this.angle + this.angleVar * c());
  23950. 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)));
  23951. else {
  23952. e = this.modeB;
  23953. a = a.modeB;
  23954. var f = e.startRadius + e.startRadiusVar * c(),
  23955. h = e.endRadius + e.endRadiusVar * c();
  23956. a.radius = f;
  23957. a.deltaRadius = e.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (h - f) / g;
  23958. a.angle = d;
  23959. a.degreesPerSecond = cc.degreesToRadians(e.rotatePerSecond + e.rotatePerSecondVar * c())
  23960. }
  23961. },
  23962. stopSystem: function() {
  23963. this._isActive = !1;
  23964. this._elapsed = this.duration;
  23965. this._emitCounter = 0
  23966. },
  23967. resetSystem: function() {
  23968. this._isActive = !0;
  23969. this._elapsed = 0;
  23970. var a = this._particles;
  23971. for (this._particleIdx = 0; this._particleIdx < this.particleCount; ++this._particleIdx) a[this._particleIdx].timeToLive = 0
  23972. },
  23973. isFull: function() {
  23974. return this.particleCount >= this._totalParticles
  23975. },
  23976. updateQuadWithParticle: function(a, c) {
  23977. var d = null;
  23978. this._batchNode ? (d = this._batchNode.textureAtlas.quads[this.atlasIndex + a.atlasIndex], this._batchNode.textureAtlas.dirty = !0) : d = this._quads[this._particleIdx];
  23979. var e, f, g, h;
  23980. 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);
  23981. h = 0 | a.color.a;
  23982. var k = d.bl.colors;
  23983. k.r = e;
  23984. k.g = f;
  23985. k.b = g;
  23986. k.a = h;
  23987. k = d.br.colors;
  23988. k.r = e;
  23989. k.g = f;
  23990. k.b = g;
  23991. k.a = h;
  23992. k = d.tl.colors;
  23993. k.r = e;
  23994. k.g = f;
  23995. k.b = g;
  23996. k.a = h;
  23997. k = d.tr.colors;
  23998. k.r = e;
  23999. k.g = f;
  24000. k.b = g;
  24001. k.a = h;
  24002. e = a.size / 2;
  24003. if (a.rotation) {
  24004. f = -e;
  24005. g = -e;
  24006. h = c.x;
  24007. var k = c.y,
  24008. m = -cc.degreesToRadians(a.rotation),
  24009. n = Math.cos(m),
  24010. m = Math.sin(m);
  24011. d.bl.vertices.x = f * n - g * m + h;
  24012. d.bl.vertices.y = f * m + g * n + k;
  24013. d.br.vertices.x = e * n - g * m + h;
  24014. d.br.vertices.y = e * m + g * n + k;
  24015. d.tl.vertices.x = f * n - e * m + h;
  24016. d.tl.vertices.y = f * m + e * n + k;
  24017. d.tr.vertices.x = e * n - e * m + h;
  24018. d.tr.vertices.y = e * m + e * n + k
  24019. } 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
  24020. },
  24021. postStep: function() {
  24022. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  24023. var a = cc._renderContext;
  24024. a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
  24025. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW)
  24026. }
  24027. },
  24028. update: function(a) {
  24029. if (this._isActive && this.emissionRate) {
  24030. var c = 1 / this.emissionRate;
  24031. this.particleCount < this._totalParticles && (this._emitCounter += a);
  24032. for (; this.particleCount < this._totalParticles && this._emitCounter > c;) this.addParticle(), this._emitCounter -= c;
  24033. this._elapsed += a; - 1 != this.duration && this.duration < this._elapsed && this.stopSystem()
  24034. }
  24035. this._particleIdx = 0;
  24036. c = cc.Particle.TemporaryPoints[0];
  24037. 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);
  24038. if (this._visible) {
  24039. for (var d = cc.Particle.TemporaryPoints[1], e = cc.Particle.TemporaryPoints[2], f = cc.Particle.TemporaryPoints[3], g = this._particles; this._particleIdx < this.particleCount;) {
  24040. cc.pZeroIn(d);
  24041. cc.pZeroIn(e);
  24042. cc.pZeroIn(f);
  24043. var h = g[this._particleIdx];
  24044. h.timeToLive -= a;
  24045. if (0 < h.timeToLive) {
  24046. if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
  24047. var k = f,
  24048. m = d,
  24049. n = e;
  24050. h.pos.x || h.pos.y ? (cc.pIn(m, h.pos), cc.pNormalizeIn(m)) : cc.pZeroIn(m);
  24051. cc.pIn(n, m);
  24052. cc.pMultIn(m, h.modeA.radialAccel);
  24053. var q = n.x;
  24054. n.x = -n.y;
  24055. n.y = q;
  24056. cc.pMultIn(n, h.modeA.tangentialAccel);
  24057. cc.pIn(k, m);
  24058. cc.pAddIn(k, n);
  24059. cc.pAddIn(k, this.modeA.gravity);
  24060. cc.pMultIn(k, a);
  24061. cc.pAddIn(h.modeA.dir, k);
  24062. cc.pIn(k, h.modeA.dir);
  24063. cc.pMultIn(k, a);
  24064. cc.pAddIn(h.pos, k)
  24065. } 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;
  24066. h.size += h.deltaSize * a;
  24067. h.size = Math.max(0, h.size);
  24068. h.rotation += h.deltaRotation * a;
  24069. k = d;
  24070. 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);
  24071. this._batchNode && (k.x += this._position.x, k.y += this._position.y);
  24072. cc._renderType == cc._RENDER_TYPE_WEBGL ? this.updateQuadWithParticle(h, k) : cc.pIn(h.drawPos, k);
  24073. ++this._particleIdx
  24074. } 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) {
  24075. this.unscheduleUpdate();
  24076. this._parent.removeChild(this, !0);
  24077. return
  24078. }
  24079. }
  24080. this._transformSystemDirty = !1
  24081. }
  24082. this._batchNode || this.postStep()
  24083. },
  24084. updateWithNoTime: function() {
  24085. this.update(0)
  24086. },
  24087. _valueForKey: function(a, c) {
  24088. if (c) {
  24089. var d = c[a];
  24090. return null != d ? d : ""
  24091. }
  24092. return ""
  24093. },
  24094. _updateBlendFunc: function() {
  24095. if (this._batchNode) cc.log("Can't change blending functions when the particle is being batched");
  24096. else {
  24097. var a = this._texture;
  24098. if (a && a instanceof cc.Texture2D) {
  24099. this._opacityModifyRGB = !1;
  24100. var c = this._blendFunc;
  24101. 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))
  24102. }
  24103. }
  24104. },
  24105. clone: function() {
  24106. var a = new cc.ParticleSystem;
  24107. if (a.initWithTotalParticles(this.getTotalParticles())) {
  24108. a.setAngle(this.getAngle());
  24109. a.setAngleVar(this.getAngleVar());
  24110. a.setDuration(this.getDuration());
  24111. var c = this.getBlendFunc();
  24112. a.setBlendFunc(c.src, c.dst);
  24113. a.setStartColor(this.getStartColor());
  24114. a.setStartColorVar(this.getStartColorVar());
  24115. a.setEndColor(this.getEndColor());
  24116. a.setEndColorVar(this.getEndColorVar());
  24117. a.setStartSize(this.getStartSize());
  24118. a.setStartSizeVar(this.getStartSizeVar());
  24119. a.setEndSize(this.getEndSize());
  24120. a.setEndSizeVar(this.getEndSizeVar());
  24121. a.setPosition(cc.p(this.x, this.y));
  24122. a.setPosVar(cc.p(this.getPosVar().x, this.getPosVar().y));
  24123. a.setStartSpin(this.getStartSpin() || 0);
  24124. a.setStartSpinVar(this.getStartSpinVar() || 0);
  24125. a.setEndSpin(this.getEndSpin() || 0);
  24126. a.setEndSpinVar(this.getEndSpinVar() || 0);
  24127. a.setEmitterMode(this.getEmitterMode());
  24128. 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()));
  24129. a.setLife(this.getLife());
  24130. a.setLifeVar(this.getLifeVar());
  24131. a.setEmissionRate(this.getEmissionRate());
  24132. if (!this.getBatchNode() && (a.setOpacityModifyRGB(this.isOpacityModifyRGB()), c = this.getTexture())) {
  24133. var d = c.getContentSize();
  24134. a.setTextureWithRect(c, cc.rect(0, 0, d.width, d.height))
  24135. }
  24136. }
  24137. return a
  24138. },
  24139. setDisplayFrame: function(a) {
  24140. var c = a.getOffsetInPixels();
  24141. (0 != c.x || 0 != c.y) && cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");
  24142. cc._renderType === cc._RENDER_TYPE_WEBGL && (!this._texture || a.getTexture()._webTextureObj != this._texture._webTextureObj) && this.setTexture(a.getTexture())
  24143. },
  24144. setTextureWithRect: function(a, c) {
  24145. var d = this._texture;
  24146. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  24147. if ((!d || a._webTextureObj != d._webTextureObj) && d != a) this._texture = a, this._updateBlendFunc()
  24148. } else if ((!d || a != d) && d != a) this._texture = a, this._updateBlendFunc();
  24149. this._pointRect = c;
  24150. this.initTexCoordsWithRect(c)
  24151. },
  24152. draw: function(a) {
  24153. this._textureLoaded && !this._batchNode && (cc._renderType === cc._RENDER_TYPE_CANVAS ? this._drawForCanvas(a) : this._drawForWebGL(a), cc.g_NumberOfDraws++)
  24154. },
  24155. _drawForCanvas: function(a) {
  24156. a = a || cc._renderContext;
  24157. a.save();
  24158. this.isBlendAdditive() ? a.globalCompositeOperation = "lighter" : a.globalCompositeOperation = "source-over";
  24159. for (var c = this._texture.getHtmlElementObj(), d = 0; d < this.particleCount; d++) {
  24160. var e = this._particles[d],
  24161. f = 0 | 0.5 * e.size;
  24162. if (this.drawMode == cc.ParticleSystem.TEXTURE_MODE) {
  24163. if (c.width && c.height) {
  24164. a.save();
  24165. a.globalAlpha = e.color.a / 255;
  24166. a.translate(0 | e.drawPos.x, -(0 | e.drawPos.y));
  24167. var f = 4 * Math.floor(e.size / 4),
  24168. g = this._pointRect.width,
  24169. h = this._pointRect.height;
  24170. a.scale(Math.max(1 / g * f, 1E-6), Math.max(1 / h * f, 1E-6));
  24171. e.rotation && a.rotate(cc.degreesToRadians(e.rotation));
  24172. a.translate(-(0 | g / 2), -(0 | h / 2));
  24173. (e = e.isChangeColor ? this._changeTextureColor(c, e.color, this._pointRect) : c) && a.drawImage(e, 0, 0);
  24174. a.restore()
  24175. }
  24176. } 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()
  24177. }
  24178. a.restore()
  24179. },
  24180. _changeTextureColor: function(a, c, d) {
  24181. c.r |= 0;
  24182. c.g |= 0;
  24183. c.b |= 0;
  24184. a.tintCache || (a.tintCache = document.createElement("canvas"), a.tintCache.width = a.width, a.tintCache.height = a.height);
  24185. return cc.generateTintImageWithMultiply(a, c, d, a.tintCache)
  24186. },
  24187. _drawForWebGL: function(a) {
  24188. 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))
  24189. },
  24190. listenBackToForeground: function(a) {
  24191. cc.TEXTURE_ATLAS_USE_VAO ? this._setupVBOandVAO() : this._setupVBO()
  24192. },
  24193. _setupVBOandVAO: function() {},
  24194. _setupVBO: function() {
  24195. if (cc._renderType != cc._RENDER_TYPE_CANVAS) {
  24196. var a = cc._renderContext;
  24197. this._buffersVBO[0] = a.createBuffer();
  24198. a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
  24199. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  24200. this._buffersVBO[1] = a.createBuffer();
  24201. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  24202. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  24203. }
  24204. },
  24205. _allocMemory: function() {
  24206. if (cc._renderType === cc._RENDER_TYPE_CANVAS) return !0;
  24207. if (this._batchNode) return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"), !1;
  24208. var a = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  24209. c = this._totalParticles,
  24210. d = this._quads;
  24211. d.length = 0;
  24212. this._indices = new Uint16Array(6 * c);
  24213. 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);
  24214. if (!d || !this._indices) return cc.log("cocos2d: Particle system: not enough memory"), !1;
  24215. this._quadsArrayBuffer = e;
  24216. return !0
  24217. }
  24218. });
  24219. _p = cc.ParticleSystem.prototype;
  24220. cc._renderType === cc._RENDER_TYPE_CANVAS && !cc.sys._supportCanvasNewBlendModes && (_p._changeTextureColor = function(a, c, d) {
  24221. var e = cc.textureCache.getTextureColors(a);
  24222. 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
  24223. });
  24224. cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB);
  24225. cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode);
  24226. cc.defineGetterSetter(_p, "active", _p.isActive);
  24227. cc.defineGetterSetter(_p, "sourcePos", _p.getSourcePosition, _p.setSourcePosition);
  24228. cc.defineGetterSetter(_p, "posVar", _p.getPosVar, _p.setPosVar);
  24229. cc.defineGetterSetter(_p, "gravity", _p.getGravity, _p.setGravity);
  24230. cc.defineGetterSetter(_p, "speed", _p.getSpeed, _p.setSpeed);
  24231. cc.defineGetterSetter(_p, "speedVar", _p.getSpeedVar, _p.setSpeedVar);
  24232. cc.defineGetterSetter(_p, "tangentialAccel", _p.getTangentialAccel, _p.setTangentialAccel);
  24233. cc.defineGetterSetter(_p, "tangentialAccelVar", _p.getTangentialAccelVar, _p.setTangentialAccelVar);
  24234. cc.defineGetterSetter(_p, "radialAccel", _p.getRadialAccel, _p.setRadialAccel);
  24235. cc.defineGetterSetter(_p, "radialAccelVar", _p.getRadialAccelVar, _p.setRadialAccelVar);
  24236. cc.defineGetterSetter(_p, "rotationIsDir", _p.getRotationIsDir, _p.setRotationIsDir);
  24237. cc.defineGetterSetter(_p, "startRadius", _p.getStartRadius, _p.setStartRadius);
  24238. cc.defineGetterSetter(_p, "startRadiusVar", _p.getStartRadiusVar, _p.setStartRadiusVar);
  24239. cc.defineGetterSetter(_p, "endRadius", _p.getEndRadius, _p.setEndRadius);
  24240. cc.defineGetterSetter(_p, "endRadiusVar", _p.getEndRadiusVar, _p.setEndRadiusVar);
  24241. cc.defineGetterSetter(_p, "rotatePerS", _p.getRotatePerSecond, _p.setRotatePerSecond);
  24242. cc.defineGetterSetter(_p, "rotatePerSVar", _p.getRotatePerSecondVar, _p.setRotatePerSecondVar);
  24243. cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor);
  24244. cc.defineGetterSetter(_p, "startColorVar", _p.getStartColorVar, _p.setStartColorVar);
  24245. cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor);
  24246. cc.defineGetterSetter(_p, "endColorVar", _p.getEndColorVar, _p.setEndColorVar);
  24247. cc.defineGetterSetter(_p, "totalParticles", _p.getTotalParticles, _p.setTotalParticles);
  24248. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  24249. cc.ParticleSystem.create = function(a) {
  24250. return new cc.ParticleSystem(a)
  24251. };
  24252. cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create;
  24253. cc.ParticleSystem.ModeA = function(a, c, d, e, f, g, h, k) {
  24254. this.gravity = a ? a : cc.p(0, 0);
  24255. this.speed = c || 0;
  24256. this.speedVar = d || 0;
  24257. this.tangentialAccel = e || 0;
  24258. this.tangentialAccelVar = f || 0;
  24259. this.radialAccel = g || 0;
  24260. this.radialAccelVar = h || 0;
  24261. this.rotationIsDir = k || !1
  24262. };
  24263. cc.ParticleSystem.ModeB = function(a, c, d, e, f, g) {
  24264. this.startRadius = a || 0;
  24265. this.startRadiusVar = c || 0;
  24266. this.endRadius = d || 0;
  24267. this.endRadiusVar = e || 0;
  24268. this.rotatePerSecond = f || 0;
  24269. this.rotatePerSecondVar = g || 0
  24270. };
  24271. cc.ParticleSystem.SHAPE_MODE = 0;
  24272. cc.ParticleSystem.TEXTURE_MODE = 1;
  24273. cc.ParticleSystem.STAR_SHAPE = 0;
  24274. cc.ParticleSystem.BALL_SHAPE = 1;
  24275. cc.ParticleSystem.DURATION_INFINITY = -1;
  24276. cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
  24277. cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
  24278. cc.ParticleSystem.MODE_GRAVITY = 0;
  24279. cc.ParticleSystem.MODE_RADIUS = 1;
  24280. cc.ParticleSystem.TYPE_FREE = 0;
  24281. cc.ParticleSystem.TYPE_RELATIVE = 1;
  24282. cc.ParticleSystem.TYPE_GROUPED = 2;
  24283. cc.ParticleFire = cc.ParticleSystem.extend({
  24284. ctor: function() {
  24285. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 300 : 150)
  24286. },
  24287. initWithTotalParticles: function(a) {
  24288. 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
  24289. }
  24290. });
  24291. cc.ParticleFire.create = function() {
  24292. return new cc.ParticleFire
  24293. };
  24294. cc.ParticleFireworks = cc.ParticleSystem.extend({
  24295. ctor: function() {
  24296. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1500 : 150)
  24297. },
  24298. initWithTotalParticles: function(a) {
  24299. 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
  24300. }
  24301. });
  24302. cc.ParticleFireworks.create = function() {
  24303. return new cc.ParticleFireworks
  24304. };
  24305. cc.ParticleSun = cc.ParticleSystem.extend({
  24306. ctor: function() {
  24307. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 350 : 150)
  24308. },
  24309. initWithTotalParticles: function(a) {
  24310. 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
  24311. }
  24312. });
  24313. cc.ParticleSun.create = function() {
  24314. return new cc.ParticleSun
  24315. };
  24316. cc.ParticleGalaxy = cc.ParticleSystem.extend({
  24317. ctor: function() {
  24318. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
  24319. },
  24320. initWithTotalParticles: function(a) {
  24321. 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
  24322. }
  24323. });
  24324. cc.ParticleGalaxy.create = function() {
  24325. return new cc.ParticleGalaxy
  24326. };
  24327. cc.ParticleFlower = cc.ParticleSystem.extend({
  24328. ctor: function() {
  24329. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 250 : 100)
  24330. },
  24331. initWithTotalParticles: function(a) {
  24332. 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
  24333. }
  24334. });
  24335. cc.ParticleFlower.create = function() {
  24336. return new cc.ParticleFlower
  24337. };
  24338. cc.ParticleMeteor = cc.ParticleSystem.extend({
  24339. ctor: function() {
  24340. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 150 : 100)
  24341. },
  24342. initWithTotalParticles: function(a) {
  24343. 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
  24344. }
  24345. });
  24346. cc.ParticleMeteor.create = function() {
  24347. return new cc.ParticleMeteor
  24348. };
  24349. cc.ParticleSpiral = cc.ParticleSystem.extend({
  24350. ctor: function() {
  24351. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 500 : 100)
  24352. },
  24353. initWithTotalParticles: function(a) {
  24354. 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
  24355. }
  24356. });
  24357. cc.ParticleSpiral.create = function() {
  24358. return new cc.ParticleSpiral
  24359. };
  24360. cc.ParticleExplosion = cc.ParticleSystem.extend({
  24361. ctor: function() {
  24362. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 300)
  24363. },
  24364. initWithTotalParticles: function(a) {
  24365. 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
  24366. }
  24367. });
  24368. cc.ParticleExplosion.create = function() {
  24369. return new cc.ParticleExplosion
  24370. };
  24371. cc.ParticleSmoke = cc.ParticleSystem.extend({
  24372. ctor: function() {
  24373. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
  24374. },
  24375. initWithTotalParticles: function(a) {
  24376. 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
  24377. }
  24378. });
  24379. cc.ParticleSmoke.create = function() {
  24380. return new cc.ParticleSmoke
  24381. };
  24382. cc.ParticleSnow = cc.ParticleSystem.extend({
  24383. ctor: function() {
  24384. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 250)
  24385. },
  24386. initWithTotalParticles: function(a) {
  24387. 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
  24388. }
  24389. });
  24390. cc.ParticleSnow.create = function() {
  24391. return new cc.ParticleSnow
  24392. };
  24393. cc.ParticleRain = cc.ParticleSystem.extend({
  24394. ctor: function() {
  24395. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1E3 : 300)
  24396. },
  24397. initWithTotalParticles: function(a) {
  24398. 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
  24399. }
  24400. });
  24401. cc.ParticleRain.create = function() {
  24402. return new cc.ParticleRain
  24403. };
  24404. cc.PARTICLE_DEFAULT_CAPACITY = 500;
  24405. cc.ParticleBatchNode = cc.Node.extend({
  24406. textureAtlas: null,
  24407. TextureProtocol: !0,
  24408. _blendFunc: null,
  24409. _className: "ParticleBatchNode",
  24410. ctor: function(a, c) {
  24411. cc.Node.prototype.ctor.call(this);
  24412. this._blendFunc = {
  24413. src: cc.BLEND_SRC,
  24414. dst: cc.BLEND_DST
  24415. };
  24416. "string" == typeof a ? this.init(a, c) : a instanceof cc.Texture2D && this.initWithTexture(a, c)
  24417. },
  24418. initWithTexture: function(a, c) {
  24419. this.textureAtlas = new cc.TextureAtlas;
  24420. this.textureAtlas.initWithTexture(a, c);
  24421. this._children.length = 0;
  24422. cc._renderType === cc._RENDER_TYPE_WEBGL && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
  24423. return !0
  24424. },
  24425. initWithFile: function(a, c) {
  24426. var d = cc.textureCache.addImage(a);
  24427. return this.initWithTexture(d, c)
  24428. },
  24429. init: function(a, c) {
  24430. var d = cc.TextureCache.getInstance().addImage(a);
  24431. return this.initWithTexture(d, c)
  24432. },
  24433. addChild: function(a, c, d) {
  24434. if (!a) throw "cc.ParticleBatchNode.addChild() : child should be non-null";
  24435. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children";
  24436. c = null == c ? a.zIndex : c;
  24437. d = null == d ? a.tag : d;
  24438. if (a.getTexture() != this.textureAtlas.texture) throw "cc.ParticleSystem.addChild() : the child is not using the same texture id";
  24439. var e = a.getBlendFunc();
  24440. if (0 === this._children.length) this.setBlendFunc(e);
  24441. else if (e.src != this._blendFunc.src || e.dst != this._blendFunc.dst) {
  24442. cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function");
  24443. return
  24444. }
  24445. c = this._addChildHelper(a, c, d);
  24446. d = 0;
  24447. 0 != c ? (c = this._children[c - 1], d = c.getAtlasIndex() + c.getTotalParticles()) : d = 0;
  24448. this.insertChild(a, d);
  24449. a.setBatchNode(this)
  24450. },
  24451. insertChild: function(a, c) {
  24452. var d = a.getTotalParticles(),
  24453. e = this.textureAtlas,
  24454. f = e.totalQuads;
  24455. a.setAtlasIndex(c);
  24456. f + d > e.getCapacity() && (this._increaseAtlasCapacityTo(f + d), e.fillWithEmptyQuadsFromIndex(e.getCapacity() - d, d));
  24457. a.getAtlasIndex() + d != f && e.moveQuadsFromIndex(c, c + d);
  24458. e.increaseTotalQuadsWith(d);
  24459. this._updateAllAtlasIndexes()
  24460. },
  24461. removeChild: function(a, c) {
  24462. if (null != a) {
  24463. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children";
  24464. if (-1 == this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");
  24465. else {
  24466. cc.Node.prototype.removeChild.call(this, a, c);
  24467. var d = this.textureAtlas;
  24468. d.removeQuadsAtIndex(a.getAtlasIndex(), a.getTotalParticles());
  24469. d.fillWithEmptyQuadsFromIndex(d.totalQuads, a.getTotalParticles());
  24470. a.setBatchNode(null);
  24471. this._updateAllAtlasIndexes()
  24472. }
  24473. }
  24474. },
  24475. reorderChild: function(a, c) {
  24476. if (!a) throw "cc.ParticleBatchNode.reorderChild(): child should be non-null";
  24477. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children";
  24478. if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");
  24479. else if (c != a.zIndex) {
  24480. if (1 < this._children.length) {
  24481. var d = this._getCurrentIndex(a, c);
  24482. if (d.oldIndex != d.newIndex) {
  24483. this._children.splice(d.oldIndex, 1);
  24484. this._children.splice(d.newIndex, 0, a);
  24485. d = a.getAtlasIndex();
  24486. this._updateAllAtlasIndexes();
  24487. for (var e = 0, f = this._children, g = 0; g < f.length; g++)
  24488. if (f[g] == a) {
  24489. e = a.getAtlasIndex();
  24490. break
  24491. }
  24492. this.textureAtlas.moveQuadsFromIndex(d, a.getTotalParticles(), e);
  24493. a.updateWithNoTime()
  24494. }
  24495. }
  24496. a._setLocalZOrder(c)
  24497. }
  24498. },
  24499. removeChildAtIndex: function(a, c) {
  24500. this.removeChild(this._children[i], c)
  24501. },
  24502. removeAllChildren: function(a) {
  24503. for (var c = this._children, d = 0; d < c.length; d++) c[d].setBatchNode(null);
  24504. cc.Node.prototype.removeAllChildren.call(this, a);
  24505. this.textureAtlas.removeAllQuads()
  24506. },
  24507. disableParticle: function(a) {
  24508. a = this.textureAtlas.quads[a];
  24509. 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;
  24510. this.textureAtlas._setDirty(!0)
  24511. },
  24512. draw: function(a) {
  24513. cc._renderType !== cc._RENDER_TYPE_CANVAS && 0 != this.textureAtlas.totalQuads && (cc.nodeDrawSetup(this), cc.glBlendFuncForParticle(this._blendFunc.src, this._blendFunc.dst), this.textureAtlas.drawQuads())
  24514. },
  24515. getTexture: function() {
  24516. return this.textureAtlas.texture
  24517. },
  24518. setTexture: function(a) {
  24519. this.textureAtlas.texture = a;
  24520. var c = this._blendFunc;
  24521. 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)
  24522. },
  24523. setBlendFunc: function(a, c) {
  24524. void 0 === c ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.src = c)
  24525. },
  24526. getBlendFunc: function() {
  24527. return {
  24528. src: this._blendFunc.src,
  24529. dst: this._blendFunc.dst
  24530. }
  24531. },
  24532. visit: function(a) {
  24533. 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())
  24534. },
  24535. _updateAllAtlasIndexes: function() {
  24536. for (var a = 0, c = this._children, d = 0; d < c.length; d++) {
  24537. var e = c[d];
  24538. e.setAtlasIndex(a);
  24539. a += e.getTotalParticles()
  24540. }
  24541. },
  24542. _increaseAtlasCapacityTo: function(a) {
  24543. cc.log("cocos2d: cc.ParticleBatchNode: resizing TextureAtlas capacity from [" + this.textureAtlas.getCapacity() + "] to [" + a + "].");
  24544. this.textureAtlas.resizeCapacity(a) || cc.log("cc.ParticleBatchNode._increaseAtlasCapacityTo() : WARNING: Not enough memory to resize the atlas")
  24545. },
  24546. _searchNewPositionInChildrenForZ: function(a) {
  24547. for (var c = this._children, d = c.length, e = 0; e < d; e++)
  24548. if (c[e].zIndex > a) return e;
  24549. return d
  24550. },
  24551. _getCurrentIndex: function(a, c) {
  24552. for (var d = !1, e = !1, f = 0, g = 0, h = 0, k = this._children, m = k.length, n = 0; n < m; n++) {
  24553. var q = k[n];
  24554. if (q.zIndex > c && !e && (f = n, e = !0, d && e)) break;
  24555. if (a == q && (g = n, d = !0, e || (h = -1), d && e)) break
  24556. }
  24557. e || (f = m);
  24558. return {
  24559. newIndex: f + h,
  24560. oldIndex: g
  24561. }
  24562. },
  24563. _addChildHelper: function(a, c, d) {
  24564. if (!a) throw "cc.ParticleBatchNode._addChildHelper(): child should be non-null";
  24565. if (a.parent) return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"), null;
  24566. this._children || (this._children = []);
  24567. var e = this._searchNewPositionInChildrenForZ(c);
  24568. this._children.splice(e, 0, a);
  24569. a.tag = d;
  24570. a._setLocalZOrder(c);
  24571. a.parent = this;
  24572. this._running && (a.onEnter(), a.onEnterTransitionDidFinish());
  24573. return e
  24574. },
  24575. _updateBlendFunc: function() {
  24576. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  24577. },
  24578. getTextureAtlas: function() {
  24579. return this.textureAtlas
  24580. },
  24581. setTextureAtlas: function(a) {
  24582. this.textureAtlas = a
  24583. }
  24584. });
  24585. _p = cc.ParticleBatchNode.prototype;
  24586. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  24587. cc.ParticleBatchNode.create = function(a, c) {
  24588. return new cc.ParticleBatchNode(a, c)
  24589. };
  24590. cc.IMEKeyboardNotificationInfo = function(a, c, d) {
  24591. this.begin = a || cc.rect(0, 0, 0, 0);
  24592. this.end = c || cc.rect(0, 0, 0, 0);
  24593. this.duration = d || 0
  24594. };
  24595. cc.IMEDelegate = cc.Class.extend({
  24596. ctor: function() {
  24597. cc.imeDispatcher.addDelegate(this)
  24598. },
  24599. removeDelegate: function() {
  24600. cc.imeDispatcher.removeDelegate(this)
  24601. },
  24602. attachWithIME: function() {
  24603. return cc.imeDispatcher.attachDelegateWithIME(this)
  24604. },
  24605. detachWithIME: function() {
  24606. return cc.imeDispatcher.detachDelegateWithIME(this)
  24607. },
  24608. canAttachWithIME: function() {
  24609. return !1
  24610. },
  24611. didAttachWithIME: function() {},
  24612. canDetachWithIME: function() {
  24613. return !1
  24614. },
  24615. didDetachWithIME: function() {},
  24616. insertText: function(a, c) {},
  24617. deleteBackward: function() {},
  24618. getContentText: function() {
  24619. return ""
  24620. },
  24621. keyboardWillShow: function(a) {},
  24622. keyboardDidShow: function(a) {},
  24623. keyboardWillHide: function(a) {},
  24624. keyboardDidHide: function(a) {}
  24625. });
  24626. cc.IMEDispatcher = cc.Class.extend({
  24627. _domInputControl: null,
  24628. impl: null,
  24629. _currentInputString: "",
  24630. _lastClickPosition: null,
  24631. ctor: function() {
  24632. this.impl = new cc.IMEDispatcher.Impl;
  24633. this._lastClickPosition = cc.p(0, 0)
  24634. },
  24635. init: function() {
  24636. if (!cc.sys.isMobile) {
  24637. this._domInputControl = cc.$("#imeDispatcherInput");
  24638. 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));
  24639. var a = this;
  24640. cc._addEventListener(this._domInputControl, "input", function() {
  24641. a._processDomInputString(a._domInputControl.value)
  24642. }, !1);
  24643. cc._addEventListener(this._domInputControl, "keydown", function(c) {
  24644. c.keyCode === cc.KEY.tab ? (c.stopPropagation(), c.preventDefault()) : c.keyCode == cc.KEY.enter && (a.dispatchInsertText("\n", 1), c.stopPropagation(), c.preventDefault())
  24645. }, !1);
  24646. /msie/i.test(navigator.userAgent) && cc._addEventListener(this._domInputControl, "keyup", function(c) {
  24647. c.keyCode == cc.KEY.backspace && a._processDomInputString(a._domInputControl.value)
  24648. }, !1);
  24649. cc._addEventListener(window, "mousedown", function(c) {
  24650. var d = c.pageY || 0;
  24651. a._lastClickPosition.x = c.pageX || 0;
  24652. a._lastClickPosition.y = d
  24653. }, !1)
  24654. }
  24655. },
  24656. _processDomInputString: function(a) {
  24657. var c, d;
  24658. c = this._currentInputString.length < a.length ? this._currentInputString.length : a.length;
  24659. for (d = 0; d < c && a[d] === this._currentInputString[d]; d++);
  24660. var e = this._currentInputString.length - d,
  24661. f = a.length - d;
  24662. for (c = 0; c < e; c++) this.dispatchDeleteBackward();
  24663. for (c = 0; c < f; c++) this.dispatchInsertText(a[d + c], 1);
  24664. this._currentInputString = a
  24665. },
  24666. dispatchInsertText: function(a, c) {
  24667. this.impl && a && !(0 >= c) && this.impl._delegateWithIme && this.impl._delegateWithIme.insertText(a, c)
  24668. },
  24669. dispatchDeleteBackward: function() {
  24670. this.impl && this.impl._delegateWithIme && this.impl._delegateWithIme.deleteBackward()
  24671. },
  24672. getContentText: function() {
  24673. if (this.impl && this.impl._delegateWithIme) {
  24674. var a = this.impl._delegateWithIme.getContentText();
  24675. return a ? a : ""
  24676. }
  24677. return ""
  24678. },
  24679. dispatchKeyboardWillShow: function(a) {
  24680. if (this.impl)
  24681. for (var c = 0; c < this.impl._delegateList.length; c++) {
  24682. var d = this.impl._delegateList[c];
  24683. d && d.keyboardWillShow(a)
  24684. }
  24685. },
  24686. dispatchKeyboardDidShow: function(a) {
  24687. if (this.impl)
  24688. for (var c = 0; c < this.impl._delegateList.length; c++) {
  24689. var d = this.impl._delegateList[c];
  24690. d && d.keyboardDidShow(a)
  24691. }
  24692. },
  24693. dispatchKeyboardWillHide: function(a) {
  24694. if (this.impl)
  24695. for (var c = 0; c < this.impl._delegateList.length; c++) {
  24696. var d = this.impl._delegateList[c];
  24697. d && d.keyboardWillHide(a)
  24698. }
  24699. },
  24700. dispatchKeyboardDidHide: function(a) {
  24701. if (this.impl)
  24702. for (var c = 0; c < this.impl._delegateList.length; c++) {
  24703. var d = this.impl._delegateList[c];
  24704. d && d.keyboardDidHide(a)
  24705. }
  24706. },
  24707. addDelegate: function(a) {
  24708. a && this.impl && (-1 < this.impl._delegateList.indexOf(a) || this.impl._delegateList.splice(0, 0, a))
  24709. },
  24710. attachDelegateWithIME: function(a) {
  24711. if (!this.impl || !a || -1 == this.impl._delegateList.indexOf(a)) return !1;
  24712. if (this.impl._delegateWithIme) {
  24713. if (!this.impl._delegateWithIme.canDetachWithIME() || !a.canAttachWithIME()) return !1;
  24714. var c = this.impl._delegateWithIme;
  24715. this.impl._delegateWithIme = null;
  24716. c.didDetachWithIME();
  24717. this._focusDomInput(a);
  24718. return !0
  24719. }
  24720. if (!a.canAttachWithIME()) return !1;
  24721. this._focusDomInput(a);
  24722. return !0
  24723. },
  24724. _focusDomInput: function(a) {
  24725. 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())
  24726. },
  24727. _domInputControlTranslate: function() {
  24728. /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)
  24729. },
  24730. detachDelegateWithIME: function(a) {
  24731. if (!this.impl || !a || this.impl._delegateWithIme != a || !a.canDetachWithIME()) return !1;
  24732. this.impl._delegateWithIme = null;
  24733. a.didDetachWithIME();
  24734. cc._canvas.focus();
  24735. return !0
  24736. },
  24737. removeDelegate: function(a) {
  24738. 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))
  24739. },
  24740. processKeycode: function(a) {
  24741. 32 > a ? a == cc.KEY.backspace ? this.dispatchDeleteBackward() : a == cc.KEY.enter && this.dispatchInsertText("\n", 1) : 255 > a && this.dispatchInsertText(String.fromCharCode(a), 1)
  24742. }
  24743. });
  24744. cc.IMEDispatcher.Impl = cc.Class.extend({
  24745. _delegateWithIme: null,
  24746. _delegateList: null,
  24747. ctor: function() {
  24748. this._delegateList = []
  24749. },
  24750. findDelegate: function(a) {
  24751. for (var c = 0; c < this._delegateList.length; c++)
  24752. if (this._delegateList[c] == a) return c;
  24753. return null
  24754. }
  24755. });
  24756. cc.imeDispatcher = new cc.IMEDispatcher;
  24757. document.body ? cc.imeDispatcher.init() : cc._addEventListener(window, "load", function() {
  24758. cc.imeDispatcher.init()
  24759. }, !1);
  24760. cc.TextFieldDelegate = cc.Class.extend({
  24761. onTextFieldAttachWithIME: function(a) {
  24762. return !1
  24763. },
  24764. onTextFieldDetachWithIME: function(a) {
  24765. return !1
  24766. },
  24767. onTextFieldInsertText: function(a, c, d) {
  24768. return !1
  24769. },
  24770. onTextFieldDeleteBackward: function(a, c, d) {
  24771. return !1
  24772. },
  24773. onDraw: function(a) {
  24774. return !1
  24775. }
  24776. });
  24777. cc.TextFieldTTF = cc.LabelTTF.extend({
  24778. delegate: null,
  24779. colorSpaceHolder: null,
  24780. _lens: null,
  24781. _inputText: "",
  24782. _placeHolder: "",
  24783. _charCount: 0,
  24784. _className: "TextFieldTTF",
  24785. ctor: function(a, c, d, e, f) {
  24786. this.colorSpaceHolder = cc.color(127, 127, 127);
  24787. cc.imeDispatcher.addDelegate(this);
  24788. cc.LabelTTF.prototype.ctor.call(this);
  24789. 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))
  24790. },
  24791. getDelegate: function() {
  24792. return this.delegate
  24793. },
  24794. setDelegate: function(a) {
  24795. this.delegate = a
  24796. },
  24797. getCharCount: function() {
  24798. return this._charCount
  24799. },
  24800. getColorSpaceHolder: function() {
  24801. return this.colorSpaceHolder
  24802. },
  24803. setColorSpaceHolder: function(a) {
  24804. this.colorSpaceHolder = a
  24805. },
  24806. initWithPlaceHolder: function(a, c, d, e, f) {
  24807. switch (arguments.length) {
  24808. case 5:
  24809. return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, e, f, c, d);
  24810. case 3:
  24811. return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, arguments[1], arguments[2]);
  24812. default:
  24813. throw "Argument must be non-nil ";
  24814. }
  24815. },
  24816. setString: function(a) {
  24817. this._inputText = (a = String(a)) || "";
  24818. this._inputText.length ? cc.LabelTTF.prototype.setString.call(this, this._inputText) : cc.LabelTTF.prototype.setString.call(this, this._placeHolder);
  24819. this._charCount = this._inputText.length
  24820. },
  24821. getString: function() {
  24822. return this._inputText
  24823. },
  24824. setPlaceHolder: function(a) {
  24825. this._placeHolder = a || "";
  24826. this._inputText.length || cc.LabelTTF.prototype.setString.call(this, this._placeHolder)
  24827. },
  24828. getPlaceHolder: function() {
  24829. return this._placeHolder
  24830. },
  24831. draw: function(a) {
  24832. a = a || cc._renderContext;
  24833. if (!this.delegate || !this.delegate.onDraw(this))
  24834. if (this._inputText && 0 < this._inputText.length) cc.LabelTTF.prototype.draw.call(this, a);
  24835. else {
  24836. var c = this.color;
  24837. this.color = this.colorSpaceHolder;
  24838. cc._renderType === cc._RENDER_TYPE_CANVAS && this._updateTexture();
  24839. cc.LabelTTF.prototype.draw.call(this, a);
  24840. this.color = c
  24841. }
  24842. },
  24843. visit: function(a) {
  24844. this._super(a)
  24845. },
  24846. attachWithIME: function() {
  24847. return cc.imeDispatcher.attachDelegateWithIME(this)
  24848. },
  24849. detachWithIME: function() {
  24850. return cc.imeDispatcher.detachDelegateWithIME(this)
  24851. },
  24852. canAttachWithIME: function() {
  24853. return this.delegate ? !this.delegate.onTextFieldAttachWithIME(this) : !0
  24854. },
  24855. didAttachWithIME: function() {},
  24856. canDetachWithIME: function() {
  24857. return this.delegate ? !this.delegate.onTextFieldDetachWithIME(this) : !0
  24858. },
  24859. didDetachWithIME: function() {},
  24860. deleteBackward: function() {
  24861. var a = this._inputText.length;
  24862. 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)
  24863. },
  24864. removeDelegate: function() {
  24865. cc.imeDispatcher.removeDelegate(this)
  24866. },
  24867. insertText: function(a, c) {
  24868. var d = a,
  24869. e = d.indexOf("\n"); - 1 < e && (d = d.substring(0, e));
  24870. if (0 < d.length) {
  24871. if (this.delegate && this.delegate.onTextFieldInsertText(this, d, d.length)) return;
  24872. d = this._inputText + d;
  24873. this._charCount = d.length;
  24874. this.string = d
  24875. } - 1 != e && (!this.delegate || !this.delegate.onTextFieldInsertText(this, "\n", 1)) && this.detachWithIME()
  24876. },
  24877. getContentText: function() {
  24878. return this._inputText
  24879. },
  24880. keyboardWillShow: function(a) {},
  24881. keyboardDidShow: function(a) {},
  24882. keyboardWillHide: function(a) {},
  24883. keyboardDidHide: function(a) {}
  24884. });
  24885. _p = cc.TextFieldTTF.prototype;
  24886. cc.defineGetterSetter(_p, "charCount", _p.getCharCount);
  24887. cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
  24888. cc.TextFieldTTF.create = function(a, c, d, e, f) {
  24889. return new cc.TextFieldTTF(a, c, d, e, f)
  24890. };
  24891. cc._globalFontSize = cc.ITEM_SIZE;
  24892. cc._globalFontName = "Arial";
  24893. cc._globalFontNameRelease = !1;
  24894. cc.MenuItem = cc.Node.extend({
  24895. _enabled: !1,
  24896. _target: null,
  24897. _callback: null,
  24898. _isSelected: !1,
  24899. _className: "MenuItem",
  24900. ctor: function(a, c) {
  24901. var d = cc.Node.prototype;
  24902. d.ctor.call(this);
  24903. this._callback = this._target = null;
  24904. this._enabled = this._isSelected = !1;
  24905. d.setAnchorPoint.call(this, 0.5, 0.5);
  24906. this._target = c || null;
  24907. if (this._callback = a || null) this._enabled = !0
  24908. },
  24909. isSelected: function() {
  24910. return this._isSelected
  24911. },
  24912. setOpacityModifyRGB: function(a) {},
  24913. isOpacityModifyRGB: function() {
  24914. return !1
  24915. },
  24916. setTarget: function(a, c) {
  24917. this._target = c;
  24918. this._callback = a
  24919. },
  24920. isEnabled: function() {
  24921. return this._enabled
  24922. },
  24923. setEnabled: function(a) {
  24924. this._enabled = a
  24925. },
  24926. initWithCallback: function(a, c) {
  24927. this.anchorY = this.anchorX = 0.5;
  24928. this._target = c;
  24929. this._callback = a;
  24930. this._enabled = !0;
  24931. this._isSelected = !1;
  24932. return !0
  24933. },
  24934. rect: function() {
  24935. var a = this._position,
  24936. c = this._contentSize,
  24937. d = this._anchorPoint;
  24938. return cc.rect(a.x - c.width * d.x, a.y - c.height * d.y, c.width, c.height)
  24939. },
  24940. selected: function() {
  24941. this._isSelected = !0
  24942. },
  24943. unselected: function() {
  24944. this._isSelected = !1
  24945. },
  24946. setCallback: function(a, c) {
  24947. this._target = c;
  24948. this._callback = a
  24949. },
  24950. activate: function() {
  24951. if (this._enabled) {
  24952. var a = this._target,
  24953. c = this._callback;
  24954. if (c)
  24955. if (a && "string" == typeof c) a[c](this);
  24956. else a && "function" == typeof c ? c.call(a, this) : c(this)
  24957. }
  24958. }
  24959. });
  24960. _p = cc.MenuItem.prototype;
  24961. cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
  24962. cc.MenuItem.create = function(a, c) {
  24963. return new cc.MenuItem(a, c)
  24964. };
  24965. cc.MenuItemLabel = cc.MenuItem.extend({
  24966. _disabledColor: null,
  24967. _label: null,
  24968. _orginalScale: 0,
  24969. _colorBackup: null,
  24970. ctor: function(a, c, d) {
  24971. cc.MenuItem.prototype.ctor.call(this, c, d);
  24972. this._label = this._disabledColor = null;
  24973. this._orginalScale = 0;
  24974. this._colorBackup = null;
  24975. a && (this._originalScale = 1, this._colorBackup = cc.color.WHITE, this._disabledColor = cc.color(126, 126, 126), this.setLabel(a), this.cascadeOpacity = this.cascadeColor = !0)
  24976. },
  24977. getDisabledColor: function() {
  24978. return this._disabledColor
  24979. },
  24980. setDisabledColor: function(a) {
  24981. this._disabledColor = a
  24982. },
  24983. getLabel: function() {
  24984. return this._label
  24985. },
  24986. setLabel: function(a) {
  24987. a && (this.addChild(a), a.anchorX = 0, a.anchorY = 0, this.width = a.width, this.height = a.height);
  24988. this._label && this.removeChild(this._label, !0);
  24989. this._label = a
  24990. },
  24991. setEnabled: function(a) {
  24992. if (this._enabled != a) {
  24993. var c = this._label;
  24994. a ? c.color = this._colorBackup : (this._colorBackup = c.color, c.color = this._disabledColor)
  24995. }
  24996. cc.MenuItem.prototype.setEnabled.call(this, a)
  24997. },
  24998. setOpacity: function(a) {
  24999. this._label.opacity = a
  25000. },
  25001. getOpacity: function() {
  25002. return this._label.opacity
  25003. },
  25004. setColor: function(a) {
  25005. this._label.color = a
  25006. },
  25007. getColor: function() {
  25008. return this._label.color
  25009. },
  25010. initWithLabel: function(a, c, d) {
  25011. this.initWithCallback(c, d);
  25012. this._originalScale = 1;
  25013. this._colorBackup = cc.color.WHITE;
  25014. this._disabledColor = cc.color(126, 126, 126);
  25015. this.setLabel(a);
  25016. return this.cascadeOpacity = this.cascadeColor = !0
  25017. },
  25018. setString: function(a) {
  25019. this._label.string = a;
  25020. this.width = this._label.width;
  25021. this.height = this._label.height
  25022. },
  25023. getString: function() {
  25024. return this._label.string
  25025. },
  25026. activate: function() {
  25027. this._enabled && (this.stopAllActions(), this.scale = this._originalScale, cc.MenuItem.prototype.activate.call(this))
  25028. },
  25029. selected: function() {
  25030. if (this._enabled) {
  25031. cc.MenuItem.prototype.selected.call(this);
  25032. var a = this.getActionByTag(cc.ZOOM_ACTION_TAG);
  25033. a ? this.stopAction(a) : this._originalScale = this.scale;
  25034. a = cc.ScaleTo.create(0.1, 1.2 * this._originalScale);
  25035. a.setTag(cc.ZOOM_ACTION_TAG);
  25036. this.runAction(a)
  25037. }
  25038. },
  25039. unselected: function() {
  25040. if (this._enabled) {
  25041. cc.MenuItem.prototype.unselected.call(this);
  25042. this.stopActionByTag(cc.ZOOM_ACTION_TAG);
  25043. var a = cc.ScaleTo.create(0.1, this._originalScale);
  25044. a.setTag(cc.ZOOM_ACTION_TAG);
  25045. this.runAction(a)
  25046. }
  25047. }
  25048. });
  25049. _p = cc.MenuItemLabel.prototype;
  25050. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  25051. cc.defineGetterSetter(_p, "disabledColor", _p.getDisabledColor, _p.setDisabledColor);
  25052. cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel);
  25053. cc.MenuItemLabel.create = function(a, c, d) {
  25054. return new cc.MenuItemLabel(a, c, d)
  25055. };
  25056. cc.MenuItemAtlasFont = cc.MenuItemLabel.extend({
  25057. ctor: function(a, c, d, e, f, g, h) {
  25058. var k;
  25059. a && 0 < a.length && (k = cc.LabelAtlas.create(a, c, d, e, f));
  25060. cc.MenuItemLabel.prototype.ctor.call(this, k, g, h)
  25061. },
  25062. initWithString: function(a, c, d, e, f, g, h) {
  25063. if (!a || 0 == a.length) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0";
  25064. var k = new cc.LabelAtlas;
  25065. k.initWithString(a, c, d, e, f);
  25066. this.initWithLabel(k, g, h);
  25067. return !0
  25068. }
  25069. });
  25070. cc.MenuItemAtlasFont.create = function(a, c, d, e, f, g, h) {
  25071. return new cc.MenuItemAtlasFont(a, c, d, e, f, g, h)
  25072. };
  25073. cc.MenuItemFont = cc.MenuItemLabel.extend({
  25074. _fontSize: null,
  25075. _fontName: null,
  25076. ctor: function(a, c, d) {
  25077. var e;
  25078. 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 = "");
  25079. cc.MenuItemLabel.prototype.ctor.call(this, e, c, d)
  25080. },
  25081. initWithString: function(a, c, d) {
  25082. if (!a || 0 == a.length) throw "Value should be non-null and its length should be greater than 0";
  25083. this._fontName = cc._globalFontName;
  25084. this._fontSize = cc._globalFontSize;
  25085. a = cc.LabelTTF.create(a, this._fontName, this._fontSize);
  25086. this.initWithLabel(a, c, d);
  25087. return !0
  25088. },
  25089. setFontSize: function(a) {
  25090. this._fontSize = a;
  25091. this._recreateLabel()
  25092. },
  25093. getFontSize: function() {
  25094. return this._fontSize
  25095. },
  25096. setFontName: function(a) {
  25097. this._fontName = a;
  25098. this._recreateLabel()
  25099. },
  25100. getFontName: function() {
  25101. return this._fontName
  25102. },
  25103. _recreateLabel: function() {
  25104. var a = cc.LabelTTF.create(this._label.string, this._fontName, this._fontSize);
  25105. this.setLabel(a)
  25106. }
  25107. });
  25108. cc.MenuItemFont.setFontSize = function(a) {
  25109. cc._globalFontSize = a
  25110. };
  25111. cc.MenuItemFont.fontSize = function() {
  25112. return cc._globalFontSize
  25113. };
  25114. cc.MenuItemFont.setFontName = function(a) {
  25115. cc._globalFontNameRelease && (cc._globalFontName = "");
  25116. cc._globalFontName = a;
  25117. cc._globalFontNameRelease = !0
  25118. };
  25119. _p = cc.MenuItemFont.prototype;
  25120. cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
  25121. cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
  25122. cc.MenuItemFont.fontName = function() {
  25123. return cc._globalFontName
  25124. };
  25125. cc.MenuItemFont.create = function(a, c, d) {
  25126. return new cc.MenuItemFont(a, c, d)
  25127. };
  25128. cc.MenuItemSprite = cc.MenuItem.extend({
  25129. _normalImage: null,
  25130. _selectedImage: null,
  25131. _disabledImage: null,
  25132. ctor: function(a, c, d, e, f) {
  25133. cc.MenuItem.prototype.ctor.call(this);
  25134. this._disabledImage = this._selectedImage = this._normalImage = null;
  25135. if (void 0 !== c) {
  25136. var g, h, k;
  25137. 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));
  25138. this.initWithNormalSprite(a, c, g, k, h)
  25139. }
  25140. },
  25141. getNormalImage: function() {
  25142. return this._normalImage
  25143. },
  25144. setNormalImage: function(a) {
  25145. 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) {
  25146. this.width = a.width;
  25147. this.height = a.height
  25148. }, this))
  25149. },
  25150. getSelectedImage: function() {
  25151. return this._selectedImage
  25152. },
  25153. setSelectedImage: function(a) {
  25154. 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())
  25155. },
  25156. getDisabledImage: function() {
  25157. return this._disabledImage
  25158. },
  25159. setDisabledImage: function(a) {
  25160. 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())
  25161. },
  25162. initWithNormalSprite: function(a, c, d, e, f) {
  25163. this.initWithCallback(e, f);
  25164. this.setNormalImage(a);
  25165. this.setSelectedImage(c);
  25166. this.setDisabledImage(d);
  25167. if (a = this._normalImage) this.width = a.width, this.height = a.height, a.textureLoaded && !a.textureLoaded() && a.addLoadedEventListener(function(a) {
  25168. this.width = a.width;
  25169. this.height = a.height;
  25170. this.cascadeOpacity = this.cascadeColor = !0
  25171. }, this);
  25172. return this.cascadeOpacity = this.cascadeColor = !0
  25173. },
  25174. setColor: function(a) {
  25175. this._normalImage.color = a;
  25176. this._selectedImage && (this._selectedImage.color = a);
  25177. this._disabledImage && (this._disabledImage.color = a)
  25178. },
  25179. getColor: function() {
  25180. return this._normalImage.color
  25181. },
  25182. setOpacity: function(a) {
  25183. this._normalImage.opacity = a;
  25184. this._selectedImage && (this._selectedImage.opacity = a);
  25185. this._disabledImage && (this._disabledImage.opacity = a)
  25186. },
  25187. getOpacity: function() {
  25188. return this._normalImage.opacity
  25189. },
  25190. selected: function() {
  25191. cc.MenuItem.prototype.selected.call(this);
  25192. this._normalImage && (this._disabledImage && (this._disabledImage.visible = !1), this._selectedImage ? (this._normalImage.visible = !1, this._selectedImage.visible = !0) : this._normalImage.visible = !0)
  25193. },
  25194. unselected: function() {
  25195. cc.MenuItem.prototype.unselected.call(this);
  25196. this._normalImage && (this._normalImage.visible = !0, this._selectedImage && (this._selectedImage.visible = !1), this._disabledImage && (this._disabledImage.visible = !1))
  25197. },
  25198. setEnabled: function(a) {
  25199. this._enabled != a && (cc.MenuItem.prototype.setEnabled.call(this, a), this._updateImagesVisibility())
  25200. },
  25201. _updateImagesVisibility: function() {
  25202. var a = this._normalImage,
  25203. c = this._selectedImage,
  25204. d = this._disabledImage;
  25205. 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))
  25206. }
  25207. });
  25208. _p = cc.MenuItemSprite.prototype;
  25209. cc.defineGetterSetter(_p, "normalImage", _p.getNormalImage, _p.setNormalImage);
  25210. cc.defineGetterSetter(_p, "selectedImage", _p.getSelectedImage, _p.setSelectedImage);
  25211. cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledImage);
  25212. cc.MenuItemSprite.create = function(a, c, d, e, f) {
  25213. return new cc.MenuItemSprite(a, c, d, e, f || void 0)
  25214. };
  25215. cc.MenuItemImage = cc.MenuItemSprite.extend({
  25216. ctor: function(a, c, d, e, f) {
  25217. var g = null,
  25218. h = null,
  25219. k = null,
  25220. m = null,
  25221. n = null;
  25222. 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))
  25223. },
  25224. setNormalSpriteFrame: function(a) {
  25225. this.setNormalImage(cc.Sprite.create(a))
  25226. },
  25227. setSelectedSpriteFrame: function(a) {
  25228. this.setSelectedImage(cc.Sprite.create(a))
  25229. },
  25230. setDisabledSpriteFrame: function(a) {
  25231. this.setDisabledImage(cc.Sprite.create(a))
  25232. },
  25233. initWithNormalImage: function(a, c, d, e, f) {
  25234. var g = null,
  25235. h = null,
  25236. k = null;
  25237. a && (g = cc.Sprite.create(a));
  25238. c && (h = cc.Sprite.create(c));
  25239. d && (k = cc.Sprite.create(d));
  25240. return this.initWithNormalSprite(g, h, k, e, f)
  25241. }
  25242. });
  25243. cc.MenuItemImage.create = function(a, c, d, e, f) {
  25244. return new cc.MenuItemImage(a, c, d, e, f)
  25245. };
  25246. cc.MenuItemToggle = cc.MenuItem.extend({
  25247. subItems: null,
  25248. _selectedIndex: 0,
  25249. _opacity: null,
  25250. _color: null,
  25251. ctor: function() {
  25252. cc.MenuItem.prototype.ctor.call(this);
  25253. this._selectedIndex = 0;
  25254. this.subItems = [];
  25255. this._opacity = 0;
  25256. this._color = cc.color.WHITE;
  25257. 0 < arguments.length && this.initWithItems(Array.prototype.slice.apply(arguments))
  25258. },
  25259. getOpacity: function() {
  25260. return this._opacity
  25261. },
  25262. setOpacity: function(a) {
  25263. this._opacity = a;
  25264. if (this.subItems && 0 < this.subItems.length)
  25265. for (var c = 0; c < this.subItems.length; c++) this.subItems[c].opacity = a;
  25266. this._color.a = a
  25267. },
  25268. getColor: function() {
  25269. var a = this._color;
  25270. return cc.color(a.r, a.g, a.b, a.a)
  25271. },
  25272. setColor: function(a) {
  25273. var c = this._color;
  25274. c.r = a.r;
  25275. c.g = a.g;
  25276. c.b = a.b;
  25277. if (this.subItems && 0 < this.subItems.length)
  25278. for (c = 0; c < this.subItems.length; c++) this.subItems[c].setColor(a);
  25279. void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
  25280. },
  25281. getSelectedIndex: function() {
  25282. return this._selectedIndex
  25283. },
  25284. setSelectedIndex: function(a) {
  25285. if (a != this._selectedIndex) {
  25286. this._selectedIndex = a;
  25287. (a = this.getChildByTag(cc.CURRENT_ITEM)) && a.removeFromParent(!1);
  25288. a = this.subItems[this._selectedIndex];
  25289. this.addChild(a, 0, cc.CURRENT_ITEM);
  25290. var c = a.width,
  25291. d = a.height;
  25292. this.width = c;
  25293. this.height = d;
  25294. a.setPosition(c / 2, d / 2)
  25295. }
  25296. },
  25297. getSubItems: function() {
  25298. return this.subItems
  25299. },
  25300. setSubItems: function(a) {
  25301. this.subItems = a
  25302. },
  25303. initWithItems: function(a) {
  25304. var c = a.length;
  25305. "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);
  25306. for (var d = this.subItems, e = d.length = 0; e < c; e++) a[e] && d.push(a[e]);
  25307. this._selectedIndex = cc.UINT_MAX;
  25308. this.setSelectedIndex(0);
  25309. return this.cascadeOpacity = this.cascadeColor = !0
  25310. },
  25311. addSubItem: function(a) {
  25312. this.subItems.push(a)
  25313. },
  25314. activate: function() {
  25315. this._enabled && this.setSelectedIndex((this._selectedIndex + 1) % this.subItems.length);
  25316. cc.MenuItem.prototype.activate.call(this)
  25317. },
  25318. selected: function() {
  25319. cc.MenuItem.prototype.selected.call(this);
  25320. this.subItems[this._selectedIndex].selected()
  25321. },
  25322. unselected: function() {
  25323. cc.MenuItem.prototype.unselected.call(this);
  25324. this.subItems[this._selectedIndex].unselected()
  25325. },
  25326. setEnabled: function(a) {
  25327. if (this._enabled != a) {
  25328. cc.MenuItem.prototype.setEnabled.call(this, a);
  25329. var c = this.subItems;
  25330. if (c && 0 < c.length)
  25331. for (var d = 0; d < c.length; d++) c[d].enabled = a
  25332. }
  25333. },
  25334. selectedItem: function() {
  25335. return this.subItems[this._selectedIndex]
  25336. },
  25337. onEnter: function() {
  25338. cc.Node.prototype.onEnter.call(this);
  25339. this.setSelectedIndex(this._selectedIndex)
  25340. }
  25341. });
  25342. _p = cc.MenuItemToggle.prototype;
  25343. cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIndex);
  25344. cc.MenuItemToggle.create = function() {
  25345. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  25346. var a = new cc.MenuItemToggle;
  25347. a.initWithItems(Array.prototype.slice.apply(arguments));
  25348. return a
  25349. };
  25350. cc.MENU_STATE_WAITING = 0;
  25351. cc.MENU_STATE_TRACKING_TOUCH = 1;
  25352. cc.MENU_HANDLER_PRIORITY = -128;
  25353. cc.DEFAULT_PADDING = 5;
  25354. cc.Menu = cc.Layer.extend({
  25355. enabled: !1,
  25356. _color: null,
  25357. _opacity: 0,
  25358. _selectedItem: null,
  25359. _state: -1,
  25360. _touchListener: null,
  25361. _className: "Menu",
  25362. ctor: function(a) {
  25363. cc.Layer.prototype.ctor.call(this);
  25364. this._color = cc.color.WHITE;
  25365. this.enabled = !1;
  25366. this._opacity = 255;
  25367. this._selectedItem = null;
  25368. this._state = -1;
  25369. this._touchListener = cc.EventListener.create({
  25370. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  25371. swallowTouches: !0,
  25372. onTouchBegan: this._onTouchBegan,
  25373. onTouchMoved: this._onTouchMoved,
  25374. onTouchEnded: this._onTouchEnded,
  25375. onTouchCancelled: this._onTouchCancelled
  25376. });
  25377. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  25378. var c = arguments.length,
  25379. d;
  25380. if (0 == c) d = [];
  25381. else if (1 == c) d = a instanceof Array ? a : [a];
  25382. else if (1 < c) {
  25383. d = [];
  25384. for (var e = 0; e < c; e++) arguments[e] && d.push(arguments[e])
  25385. }
  25386. this.initWithArray(d)
  25387. },
  25388. onEnter: function() {
  25389. var a = this._touchListener;
  25390. a._isRegistered() || cc.eventManager.addListener(a, this);
  25391. cc.Node.prototype.onEnter.call(this)
  25392. },
  25393. getColor: function() {
  25394. var a = this._color;
  25395. return cc.color(a.r, a.g, a.b, a.a)
  25396. },
  25397. setColor: function(a) {
  25398. var c = this._color;
  25399. c.r = a.r;
  25400. c.g = a.g;
  25401. c.b = a.b;
  25402. if ((c = this._children) && 0 < c.length)
  25403. for (var d = 0; d < c.length; d++) c[d].setColor(a);
  25404. void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
  25405. },
  25406. getOpacity: function() {
  25407. return this._opacity
  25408. },
  25409. setOpacity: function(a) {
  25410. this._opacity = a;
  25411. var c = this._children;
  25412. if (c && 0 < c.length)
  25413. for (var d = 0; d < c.length; d++) c[d].setOpacity(a);
  25414. this._color.a = a
  25415. },
  25416. isEnabled: function() {
  25417. return this.enabled
  25418. },
  25419. setEnabled: function(a) {
  25420. this.enabled = a
  25421. },
  25422. initWithItems: function(a) {
  25423. var c = [];
  25424. if (a)
  25425. for (var d = 0; d < a.length; d++) a[d] && c.push(a[d]);
  25426. return this.initWithArray(c)
  25427. },
  25428. initWithArray: function(a) {
  25429. if (cc.Layer.prototype.init.call(this)) {
  25430. this.enabled = !0;
  25431. var c = cc.winSize;
  25432. this.setPosition(c.width / 2, c.height / 2);
  25433. this.setContentSize(c);
  25434. this.setAnchorPoint(0.5, 0.5);
  25435. this.ignoreAnchorPointForPosition(!0);
  25436. if (a)
  25437. for (c = 0; c < a.length; c++) this.addChild(a[c], c);
  25438. this._selectedItem = null;
  25439. this._state = cc.MENU_STATE_WAITING;
  25440. return this.cascadeOpacity = this.cascadeColor = !0
  25441. }
  25442. return !1
  25443. },
  25444. addChild: function(a, c, d) {
  25445. if (!(a instanceof cc.MenuItem)) throw "cc.Menu.addChild() : Menu only supports MenuItem objects as children";
  25446. cc.Layer.prototype.addChild.call(this, a, c, d)
  25447. },
  25448. alignItemsVertically: function() {
  25449. this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
  25450. },
  25451. alignItemsVerticallyWithPadding: function(a) {
  25452. var c = -a,
  25453. d = this._children,
  25454. e, f, g, h;
  25455. if (d && 0 < d.length) {
  25456. f = 0;
  25457. for (e = d.length; f < e; f++) c += d[f].height * d[f].scaleY + a;
  25458. var k = c / 2;
  25459. f = 0;
  25460. 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
  25461. }
  25462. },
  25463. alignItemsHorizontally: function() {
  25464. this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
  25465. },
  25466. alignItemsHorizontallyWithPadding: function(a) {
  25467. var c = -a,
  25468. d = this._children,
  25469. e, f, g, h;
  25470. if (d && 0 < d.length) {
  25471. e = 0;
  25472. for (f = d.length; e < f; e++) c += d[e].width * d[e].scaleX + a;
  25473. var k = -c / 2;
  25474. e = 0;
  25475. 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
  25476. }
  25477. },
  25478. alignItemsInColumns: function() {
  25479. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  25480. for (var a = [], c = 0; c < arguments.length; c++) a.push(arguments[c]);
  25481. var d = -5,
  25482. e = 0,
  25483. f = 0,
  25484. g = 0,
  25485. h, k, m, n = this._children;
  25486. if (n && 0 < n.length) {
  25487. c = 0;
  25488. for (m = n.length; c < m; c++)
  25489. 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)
  25490. }
  25491. var q = cc.director.getWinSize(),
  25492. r = h = f = e = 0,
  25493. t = 0,
  25494. d = d / 2;
  25495. if (n && 0 < n.length) {
  25496. c = 0;
  25497. for (m = n.length; c < m; c++) {
  25498. var s = n[c];
  25499. 0 == h && (h = a[e], t = r = q.width / (1 + h));
  25500. k = s._getHeight();
  25501. f = f >= k || isNaN(k) ? f : k;
  25502. s.setPosition(t - q.width / 2, d - k / 2);
  25503. t += r;
  25504. ++g;
  25505. g >= h && (d -= f + 5, f = h = g = 0, ++e)
  25506. }
  25507. }
  25508. },
  25509. alignItemsInRows: function() {
  25510. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  25511. var a = [],
  25512. c;
  25513. for (c = 0; c < arguments.length; c++) a.push(arguments[c]);
  25514. var d = [],
  25515. e = [],
  25516. f = -10,
  25517. g = -5,
  25518. h = 0,
  25519. k = 0,
  25520. m = 0,
  25521. n, q, r, t, s = this._children;
  25522. if (s && 0 < s.length) {
  25523. c = 0;
  25524. for (r = s.length; c < r; c++)
  25525. 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)
  25526. }
  25527. g = cc.director.getWinSize();
  25528. n = k = h = 0;
  25529. var f = -f / 2,
  25530. v = 0;
  25531. if (s && 0 < s.length) {
  25532. c = 0;
  25533. 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)
  25534. }
  25535. },
  25536. removeChild: function(a, c) {
  25537. 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"))
  25538. },
  25539. _onTouchBegan: function(a, c) {
  25540. var d = c.getCurrentTarget();
  25541. if (d._state != cc.MENU_STATE_WAITING || !d._visible || !d.enabled) return !1;
  25542. for (var e = d.parent; null != e; e = e.parent)
  25543. if (!e.isVisible()) return !1;
  25544. d._selectedItem = d._itemForTouch(a);
  25545. return d._selectedItem ? (d._state = cc.MENU_STATE_TRACKING_TOUCH, d._selectedItem.selected(), !0) : !1
  25546. },
  25547. _onTouchEnded: function(a, c) {
  25548. var d = c.getCurrentTarget();
  25549. 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)
  25550. },
  25551. _onTouchCancelled: function(a, c) {
  25552. var d = c.getCurrentTarget();
  25553. 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)
  25554. },
  25555. _onTouchMoved: function(a, c) {
  25556. var d = c.getCurrentTarget();
  25557. if (d._state !== cc.MENU_STATE_TRACKING_TOUCH) cc.log("cc.Menu.onTouchMoved(): invalid state");
  25558. else {
  25559. var e = d._itemForTouch(a);
  25560. e != d._selectedItem && (d._selectedItem && d._selectedItem.unselected(), d._selectedItem = e, d._selectedItem && d._selectedItem.selected())
  25561. }
  25562. },
  25563. onExit: function() {
  25564. this._state == cc.MENU_STATE_TRACKING_TOUCH && (this._selectedItem && (this._selectedItem.unselected(), this._selectedItem = null), this._state = cc.MENU_STATE_WAITING);
  25565. cc.Node.prototype.onExit.call(this)
  25566. },
  25567. setOpacityModifyRGB: function(a) {},
  25568. isOpacityModifyRGB: function() {
  25569. return !1
  25570. },
  25571. _itemForTouch: function(a) {
  25572. a = a.getLocation();
  25573. var c = this._children,
  25574. d;
  25575. if (c && 0 < c.length)
  25576. for (var e = 0; e < c.length; e++)
  25577. if (d = c[e], d.isVisible() && d.isEnabled()) {
  25578. var f = d.convertToNodeSpace(a),
  25579. g = d.rect();
  25580. g.x = 0;
  25581. g.y = 0;
  25582. if (cc.rectContainsPoint(g, f)) return d
  25583. }
  25584. return null
  25585. }
  25586. });
  25587. _p = cc.Menu.prototype;
  25588. cc.Menu.create = function(a) {
  25589. var c = arguments.length;
  25590. 0 < c && null == arguments[c - 1] && cc.log("parameters should not be ending with null in Javascript");
  25591. return 0 == c ? new cc.Menu : 1 == c ? new cc.Menu(a) : new cc.Menu(Array.prototype.slice.call(arguments, 0))
  25592. };
  25593. cc.TGA_OK = 0;
  25594. cc.TGA_ERROR_FILE_OPEN = 1;
  25595. cc.TGA_ERROR_READING_FILE = 2;
  25596. cc.TGA_ERROR_INDEXED_COLOR = 3;
  25597. cc.TGA_ERROR_MEMORY = 4;
  25598. cc.TGA_ERROR_COMPRESSED_FILE = 5;
  25599. cc.ImageTGA = function(a, c, d, e, f, g, h) {
  25600. this.status = a || 0;
  25601. this.type = c || 0;
  25602. this.pixelDepth = d || 0;
  25603. this.width = e || 0;
  25604. this.height = f || 0;
  25605. this.imageData = g || [];
  25606. this.flipped = h || 0
  25607. };
  25608. cc.tgaLoadHeader = function(a, c, d) {
  25609. var e = 2;
  25610. if (e + 1 > c) return !1;
  25611. a = new cc.BinaryStreamReader(a);
  25612. a.setOffset(e);
  25613. d.type = a.readByte();
  25614. e += 10;
  25615. if (e + 4 + 1 > c) return !1;
  25616. a.setOffset(e);
  25617. d.width = a.readUnsignedShort();
  25618. d.height = a.readUnsignedInteger();
  25619. d.pixelDepth = a.readByte();
  25620. if (e + 5 + 1 > c) return !1;
  25621. c = a.readByte();
  25622. d.flipped = 0;
  25623. c & 32 && (d.flipped = 1);
  25624. return !0
  25625. };
  25626. cc.tgaLoadImageData = function(a, c, d) {
  25627. var e, f;
  25628. e = 0 | d.pixelDepth / 2;
  25629. f = d.height * d.width * e;
  25630. if (18 + f > c) return !1;
  25631. d.imageData = cc.__getSubArray(a, 18, 18 + f);
  25632. if (3 <= e)
  25633. for (a = 0; a < f; a += e) c = d.imageData[a], d.imageData[a] = d.imageData[a + 2], d.imageData[a + 2] = c;
  25634. return !0
  25635. };
  25636. cc.tgaRGBtogreyscale = function(a) {
  25637. var c, d;
  25638. if (8 !== a.pixelDepth) {
  25639. var e = a.pixelDepth / 8,
  25640. f = new Uint8Array(a.height * a.width);
  25641. if (null !== f) {
  25642. 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];
  25643. a.pixelDepth = 8;
  25644. a.type = 3;
  25645. a.imageData = f
  25646. }
  25647. }
  25648. };
  25649. cc.tgaDestroy = function(a) {
  25650. a && (a.imageData = null)
  25651. };
  25652. cc.tgaLoadRLEImageData = function(a, c, d) {
  25653. var e, f, g, h = 0,
  25654. k = 0,
  25655. m = 0,
  25656. n = [],
  25657. q = 0,
  25658. r = 18;
  25659. e = d.pixelDepth / 8;
  25660. f = d.height * d.width;
  25661. for (g = 0; g < f; g++) {
  25662. if (0 != q) q--, k = 0 != m;
  25663. else {
  25664. if (r + 1 > c) break;
  25665. q = a[r];
  25666. r += 1;
  25667. (m = q & 128) && (q -= 128);
  25668. k = 0
  25669. } if (!k) {
  25670. if (r + e > c) break;
  25671. n = cc.__getSubArray(a, r, r + e);
  25672. r += e;
  25673. 3 <= e && (k = n[0], n[0] = n[2], n[2] = k)
  25674. }
  25675. for (k = 0; k < e; k++) d.imageData[h + k] = n[k];
  25676. h += e
  25677. }
  25678. return !0
  25679. };
  25680. cc.tgaFlipImage = function(a) {
  25681. for (var c = a.width * (a.pixelDepth / 8), d = 0; d < a.height / 2; d++) {
  25682. var e = cc.__getSubArray(a.imageData, d * c, d * c + c);
  25683. cc.__setDataToArray(cc.__getSubArray(a.imageData, (a.height - (d + 1)) * c, c), a.imageData, d * c);
  25684. cc.__setDataToArray(e, a.imageData, (a.height - (d + 1)) * c)
  25685. }
  25686. a.flipped = 0
  25687. };
  25688. cc.__getSubArray = function(a, c, d) {
  25689. return a instanceof Array ? a.slice(c, d) : a.subarray(c, d)
  25690. };
  25691. cc.__setDataToArray = function(a, c, d) {
  25692. for (var e = 0; e < a.length; e++) c[d + e] = a[e]
  25693. };
  25694. cc.BinaryStreamReader = cc.Class.extend({
  25695. _binaryData: null,
  25696. _offset: 0,
  25697. ctor: function(a) {
  25698. this._binaryData = a
  25699. },
  25700. setBinaryData: function(a) {
  25701. this._binaryData = a;
  25702. this._offset = 0
  25703. },
  25704. getBinaryData: function() {
  25705. return this._binaryData
  25706. },
  25707. _checkSize: function(a) {
  25708. if (!(this._offset + Math.ceil(a / 8) < this._data.length)) throw Error("Index out of bound");
  25709. },
  25710. _decodeFloat: function(a, c) {
  25711. var d = a + c + 1,
  25712. e = d >> 3;
  25713. this._checkSize(d);
  25714. var d = Math.pow(2, c - 1) - 1,
  25715. f = this._readBits(a + c, 1, e),
  25716. g = this._readBits(a, c, e),
  25717. h = 0,
  25718. k = 2,
  25719. m = 0;
  25720. do
  25721. 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);
  25722. this._offset += e;
  25723. 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)
  25724. },
  25725. _readByte: function(a, c) {
  25726. return this._data[this._offset + c - a - 1]
  25727. },
  25728. _decodeInt: function(a, c) {
  25729. var d = this._readBits(0, a, a / 8),
  25730. e = Math.pow(2, a);
  25731. this._offset += a / 8;
  25732. return c && d >= e / 2 ? d - e : d
  25733. },
  25734. _shl: function(a, c) {
  25735. for (++c; --c; a = 1073741824 == ((a %= 2147483648) & 1073741824) ? 2 * a : 2 * (a - 1073741824) + 2147483648);
  25736. return a
  25737. },
  25738. _readBits: function(a, c, d) {
  25739. var e = (a + c) % 8,
  25740. f = a % 8,
  25741. g = d - (a >> 3) - 1;
  25742. a = d + (-(a + c) >> 3);
  25743. var h = g - a;
  25744. c = this._readByte(g, d) >> f & (1 << (h ? 8 - f : c)) - 1;
  25745. 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);
  25746. return c
  25747. },
  25748. readInteger: function() {
  25749. return this._decodeInt(32, !0)
  25750. },
  25751. readUnsignedInteger: function() {
  25752. return this._decodeInt(32, !1)
  25753. },
  25754. readSingle: function() {
  25755. return this._decodeFloat(23, 8)
  25756. },
  25757. readShort: function() {
  25758. return this._decodeInt(16, !0)
  25759. },
  25760. readUnsignedShort: function() {
  25761. return this._decodeInt(16, !1)
  25762. },
  25763. readByte: function() {
  25764. var a = this._data[this._offset];
  25765. this._offset += 1;
  25766. return a
  25767. },
  25768. readData: function(a, c) {
  25769. return this._binaryData instanceof Array ? this._binaryData.slice(a, c) : this._binaryData.subarray(a, c)
  25770. },
  25771. setOffset: function(a) {
  25772. this._offset = a
  25773. },
  25774. getOffset: function() {
  25775. return this._offset
  25776. }
  25777. });
  25778. cc.TMX_ORIENTATION_ORTHO = 0;
  25779. cc.TMX_ORIENTATION_HEX = 1;
  25780. cc.TMX_ORIENTATION_ISO = 2;
  25781. cc.TMXTiledMap = cc.Node.extend({
  25782. properties: null,
  25783. mapOrientation: null,
  25784. objectGroups: null,
  25785. _mapSize: null,
  25786. _tileSize: null,
  25787. _tileProperties: null,
  25788. _className: "TMXTiledMap",
  25789. ctor: function(a, c) {
  25790. cc.Node.prototype.ctor.call(this);
  25791. this._mapSize = cc.size(0, 0);
  25792. this._tileSize = cc.size(0, 0);
  25793. void 0 !== c ? this.initWithXML(a, c) : void 0 !== a && this.initWithTMXFile(a)
  25794. },
  25795. getMapSize: function() {
  25796. return cc.size(this._mapSize.width, this._mapSize.height)
  25797. },
  25798. setMapSize: function(a) {
  25799. this._mapSize.width = a.width;
  25800. this._mapSize.height = a.height
  25801. },
  25802. _getMapWidth: function() {
  25803. return this._mapSize.width
  25804. },
  25805. _setMapWidth: function(a) {
  25806. this._mapSize.width = a
  25807. },
  25808. _getMapHeight: function() {
  25809. return this._mapSize.height
  25810. },
  25811. _setMapHeight: function(a) {
  25812. this._mapSize.height = a
  25813. },
  25814. getTileSize: function() {
  25815. return cc.size(this._tileSize.width, this._tileSize.height)
  25816. },
  25817. setTileSize: function(a) {
  25818. this._tileSize.width = a.width;
  25819. this._tileSize.height = a.height
  25820. },
  25821. _getTileWidth: function() {
  25822. return this._tileSize.width
  25823. },
  25824. _setTileWidth: function(a) {
  25825. this._tileSize.width = a
  25826. },
  25827. _getTileHeight: function() {
  25828. return this._tileSize.height
  25829. },
  25830. _setTileHeight: function(a) {
  25831. this._tileSize.height = a
  25832. },
  25833. getMapOrientation: function() {
  25834. return this.mapOrientation
  25835. },
  25836. setMapOrientation: function(a) {
  25837. this.mapOrientation = a
  25838. },
  25839. getObjectGroups: function() {
  25840. return this.objectGroups
  25841. },
  25842. setObjectGroups: function(a) {
  25843. this.objectGroups = a
  25844. },
  25845. getProperties: function() {
  25846. return this.properties
  25847. },
  25848. setProperties: function(a) {
  25849. this.properties = a
  25850. },
  25851. initWithTMXFile: function(a) {
  25852. if (!a || 0 == a.length) throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string.";
  25853. this.height = this.width = 0;
  25854. a = cc.TMXMapInfo.create(a);
  25855. if (!a) return !1;
  25856. var c = a.getTilesets();
  25857. (!c || 0 === c.length) && cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename.");
  25858. this._buildWithMapInfo(a);
  25859. return !0
  25860. },
  25861. initWithXML: function(a, c) {
  25862. this.height = this.width = 0;
  25863. var d = cc.TMXMapInfo.create(a, c),
  25864. e = d.getTilesets();
  25865. (!e || 0 === e.length) && cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename.");
  25866. this._buildWithMapInfo(d);
  25867. return !0
  25868. },
  25869. _buildWithMapInfo: function(a) {
  25870. this._mapSize = a.getMapSize();
  25871. this._tileSize = a.getTileSize();
  25872. this.mapOrientation = a.orientation;
  25873. this.objectGroups = a.getObjectGroups();
  25874. this.properties = a.properties;
  25875. this._tileProperties = a.getTileProperties();
  25876. var c = 0,
  25877. d = a.getLayers();
  25878. if (d)
  25879. for (var e = null, f = 0, g = d.length; f < g; f++)
  25880. 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++
  25881. },
  25882. allLayers: function() {
  25883. for (var a = [], c = this._children, d = 0, e = c.length; d < e; d++) {
  25884. var f = c[d];
  25885. f && f instanceof cc.TMXLayer && a.push(f)
  25886. }
  25887. return a
  25888. },
  25889. getLayer: function(a) {
  25890. if (!a || 0 === a.length) throw "cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.";
  25891. for (var c = this._children, d = 0; d < c.length; d++) {
  25892. var e = c[d];
  25893. if (e && e.layerName == a) return e
  25894. }
  25895. return null
  25896. },
  25897. getObjectGroup: function(a) {
  25898. if (!a || 0 === a.length) throw "cc.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string.";
  25899. if (this.objectGroups)
  25900. for (var c = 0; c < this.objectGroups.length; c++) {
  25901. var d = this.objectGroups[c];
  25902. if (d && d.groupName == a) return d
  25903. }
  25904. return null
  25905. },
  25906. getProperty: function(a) {
  25907. return this.properties[a.toString()]
  25908. },
  25909. propertiesForGID: function(a) {
  25910. return this._tileProperties[a]
  25911. },
  25912. _parseLayer: function(a, c) {
  25913. var d = this._tilesetForLayer(a, c),
  25914. d = cc.TMXLayer.create(d, a, c);
  25915. a.ownTiles = !1;
  25916. d.setupTiles();
  25917. return d
  25918. },
  25919. _tilesetForLayer: function(a, c) {
  25920. var d = a._layerSize,
  25921. e = c.getTilesets();
  25922. if (e)
  25923. for (var f = e.length - 1; 0 <= f; f--) {
  25924. var g = e[f];
  25925. if (g)
  25926. for (var h = 0; h < d.height; h++)
  25927. for (var k = 0; k < d.width; k++) {
  25928. var m = a._tiles[k + d.width * h];
  25929. if (0 != m && (m & cc.TMX_TILE_FLIPPED_MASK) >>> 0 >= g.firstGid) return g
  25930. }
  25931. }
  25932. cc.log("cocos2d: Warning: TMX Layer " + a.name + " has no tiles");
  25933. return null
  25934. }
  25935. });
  25936. _p = cc.TMXTiledMap.prototype;
  25937. cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
  25938. cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
  25939. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  25940. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  25941. cc.TMXTiledMap.create = function(a, c) {
  25942. return new cc.TMXTiledMap(a, c)
  25943. };
  25944. cc.TMX_PROPERTY_NONE = 0;
  25945. cc.TMX_PROPERTY_MAP = 1;
  25946. cc.TMX_PROPERTY_LAYER = 2;
  25947. cc.TMX_PROPERTY_OBJECTGROUP = 3;
  25948. cc.TMX_PROPERTY_OBJECT = 4;
  25949. cc.TMX_PROPERTY_TILE = 5;
  25950. cc.TMX_TILE_HORIZONTAL_FLAG = 2147483648;
  25951. cc.TMX_TILE_VERTICAL_FLAG = 1073741824;
  25952. cc.TMX_TILE_DIAGONAL_FLAG = 536870912;
  25953. cc.TMX_TILE_FLIPPED_ALL = (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_DIAGONAL_FLAG) >>> 0;
  25954. cc.TMX_TILE_FLIPPED_MASK = ~cc.TMX_TILE_FLIPPED_ALL >>> 0;
  25955. cc.TMXLayerInfo = cc.Class.extend({
  25956. properties: null,
  25957. name: "",
  25958. _layerSize: null,
  25959. _tiles: null,
  25960. visible: null,
  25961. _opacity: null,
  25962. ownTiles: !0,
  25963. _minGID: 1E5,
  25964. _maxGID: 0,
  25965. offset: null,
  25966. ctor: function() {
  25967. this.properties = [];
  25968. this.name = "";
  25969. this._layerSize = null;
  25970. this._tiles = [];
  25971. this.visible = !0;
  25972. this._opacity = 0;
  25973. this.ownTiles = !0;
  25974. this._minGID = 1E5;
  25975. this._maxGID = 0;
  25976. this.offset = cc.p(0, 0)
  25977. },
  25978. getProperties: function() {
  25979. return this.properties
  25980. },
  25981. setProperties: function(a) {
  25982. this.properties = a
  25983. }
  25984. });
  25985. cc.TMXTilesetInfo = cc.Class.extend({
  25986. name: "",
  25987. firstGid: 0,
  25988. _tileSize: null,
  25989. spacing: 0,
  25990. margin: 0,
  25991. sourceImage: "",
  25992. imageSize: null,
  25993. ctor: function() {
  25994. this._tileSize = cc.size(0, 0);
  25995. this.imageSize = cc.size(0, 0)
  25996. },
  25997. rectForGID: function(a) {
  25998. var c = cc.rect(0, 0, 0, 0);
  25999. c.width = this._tileSize.width;
  26000. c.height = this._tileSize.height;
  26001. a &= cc.TMX_TILE_FLIPPED_MASK;
  26002. a -= parseInt(this.firstGid, 10);
  26003. var d = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10);
  26004. c.x = parseInt(a % d * (this._tileSize.width + this.spacing) + this.margin, 10);
  26005. c.y = parseInt(parseInt(a / d, 10) * (this._tileSize.height + this.spacing) + this.margin, 10);
  26006. return c
  26007. }
  26008. });
  26009. cc.TMXMapInfo = cc.SAXParser.extend({
  26010. properties: null,
  26011. orientation: null,
  26012. parentElement: null,
  26013. parentGID: null,
  26014. layerAttrs: 0,
  26015. storingCharacters: !1,
  26016. tmxFileName: null,
  26017. currentString: null,
  26018. _objectGroups: null,
  26019. _mapSize: null,
  26020. _tileSize: null,
  26021. _layers: null,
  26022. _tilesets: null,
  26023. _tileProperties: null,
  26024. _resources: "",
  26025. _currentFirstGID: 0,
  26026. ctor: function(a, c) {
  26027. cc.SAXParser.prototype.ctor.apply(this);
  26028. this._mapSize = cc.size(0, 0);
  26029. this._tileSize = cc.size(0, 0);
  26030. this._layers = [];
  26031. this._tilesets = [];
  26032. this._objectGroups = [];
  26033. this.properties = [];
  26034. this._tileProperties = {};
  26035. this._currentFirstGID = 0;
  26036. void 0 !== c ? this.initWithXML(a, c) : void 0 !== a && this.initWithTMXFile(a)
  26037. },
  26038. getOrientation: function() {
  26039. return this.orientation
  26040. },
  26041. setOrientation: function(a) {
  26042. this.orientation = a
  26043. },
  26044. getMapSize: function() {
  26045. return cc.size(this._mapSize.width, this._mapSize.height)
  26046. },
  26047. setMapSize: function(a) {
  26048. this._mapSize.width = a.width;
  26049. this._mapSize.height = a.height
  26050. },
  26051. _getMapWidth: function() {
  26052. return this._mapSize.width
  26053. },
  26054. _setMapWidth: function(a) {
  26055. this._mapSize.width = a
  26056. },
  26057. _getMapHeight: function() {
  26058. return this._mapSize.height
  26059. },
  26060. _setMapHeight: function(a) {
  26061. this._mapSize.height = a
  26062. },
  26063. getTileSize: function() {
  26064. return cc.size(this._tileSize.width, this._tileSize.height)
  26065. },
  26066. setTileSize: function(a) {
  26067. this._tileSize.width = a.width;
  26068. this._tileSize.height = a.height
  26069. },
  26070. _getTileWidth: function() {
  26071. return this._tileSize.width
  26072. },
  26073. _setTileWidth: function(a) {
  26074. this._tileSize.width = a
  26075. },
  26076. _getTileHeight: function() {
  26077. return this._tileSize.height
  26078. },
  26079. _setTileHeight: function(a) {
  26080. this._tileSize.height = a
  26081. },
  26082. getLayers: function() {
  26083. return this._layers
  26084. },
  26085. setLayers: function(a) {
  26086. this._layers.push(a)
  26087. },
  26088. getTilesets: function() {
  26089. return this._tilesets
  26090. },
  26091. setTilesets: function(a) {
  26092. this._tilesets.push(a)
  26093. },
  26094. getObjectGroups: function() {
  26095. return this._objectGroups
  26096. },
  26097. setObjectGroups: function(a) {
  26098. this._objectGroups.push(a)
  26099. },
  26100. getParentElement: function() {
  26101. return this.parentElement
  26102. },
  26103. setParentElement: function(a) {
  26104. this.parentElement = a
  26105. },
  26106. getParentGID: function() {
  26107. return this.parentGID
  26108. },
  26109. setParentGID: function(a) {
  26110. this.parentGID = a
  26111. },
  26112. getLayerAttribs: function() {
  26113. return this.layerAttrs
  26114. },
  26115. setLayerAttribs: function(a) {
  26116. this.layerAttrs = a
  26117. },
  26118. getStoringCharacters: function() {
  26119. return this.storingCharacters
  26120. },
  26121. setStoringCharacters: function(a) {
  26122. this.storingCharacters = a
  26123. },
  26124. getProperties: function() {
  26125. return this.properties
  26126. },
  26127. setProperties: function(a) {
  26128. this.properties = a
  26129. },
  26130. initWithTMXFile: function(a) {
  26131. this._internalInit(a, null);
  26132. return this.parseXMLFile(a)
  26133. },
  26134. initWithXML: function(a, c) {
  26135. this._internalInit(null, c);
  26136. return this.parseXMLString(a)
  26137. },
  26138. parseXMLFile: function(a, c) {
  26139. var d = (c = c || !1) ? a : cc.loader.getRes(a);
  26140. if (!d) throw "Please load the resource first : " + a;
  26141. var e, f, d = this._parseXML(d).documentElement;
  26142. e = d.getAttribute("version");
  26143. f = d.getAttribute("orientation");
  26144. 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"))) {
  26145. var g = {};
  26146. for (e = 0; e < f.length; e++) g[f[e].getAttribute("name")] = f[e].getAttribute("value");
  26147. this.properties = g
  26148. }
  26149. g = d.getElementsByTagName("tileset");
  26150. "map" !== d.nodeName && (g = [], g.push(d));
  26151. for (e = 0; e < g.length; e++) {
  26152. f = g[e];
  26153. var h = f.getAttribute("source");
  26154. if (h) f = c ? cc.path.join(this._resources, h) : cc.path.changeBasename(a, h), this.parseXMLFile(f);
  26155. else {
  26156. h = new cc.TMXTilesetInfo;
  26157. h.name = f.getAttribute("name") || "";
  26158. h.firstGid = parseInt(f.getAttribute("firstgid")) || 0;
  26159. h.spacing = parseInt(f.getAttribute("spacing")) || 0;
  26160. h.margin = parseInt(f.getAttribute("margin")) || 0;
  26161. var k = cc.size(0, 0);
  26162. k.width = parseFloat(f.getAttribute("tilewidth"));
  26163. k.height = parseFloat(f.getAttribute("tileheight"));
  26164. h._tileSize = k;
  26165. var k = f.getElementsByTagName("image")[0].getAttribute("source"),
  26166. m = -1;
  26167. 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;
  26168. this.setTilesets(h);
  26169. if (k = f.getElementsByTagName("tile"))
  26170. for (m = 0; m < k.length; m++) {
  26171. f = k[m];
  26172. this.parentGID = parseInt(h.firstGid) + parseInt(f.getAttribute("id") || 0);
  26173. var n = f.querySelectorAll("properties \x3e property");
  26174. if (n) {
  26175. var q = {};
  26176. for (f = 0; f < n.length; f++) {
  26177. var r = n[f].getAttribute("name");
  26178. q[r] = n[f].getAttribute("value")
  26179. }
  26180. this._tileProperties[this.parentGID] = q
  26181. }
  26182. }
  26183. }
  26184. }
  26185. if (g = d.getElementsByTagName("layer"))
  26186. for (e = 0; e < g.length; e++) {
  26187. k = g[e];
  26188. m = k.getElementsByTagName("data")[0];
  26189. h = new cc.TMXLayerInfo;
  26190. h.name = k.getAttribute("name");
  26191. f = cc.size(0, 0);
  26192. f.width = parseFloat(k.getAttribute("width"));
  26193. f.height = parseFloat(k.getAttribute("height"));
  26194. h._layerSize = f;
  26195. f = k.getAttribute("visible");
  26196. h.visible = "0" != f;
  26197. f = k.getAttribute("opacity") || 1;
  26198. h._opacity = f ? parseInt(255 * parseFloat(f)) : 255;
  26199. h.offset = cc.p(parseFloat(k.getAttribute("x")) || 0, parseFloat(k.getAttribute("y")) || 0);
  26200. n = "";
  26201. for (f = 0; f < m.childNodes.length; f++) n += m.childNodes[f].nodeValue;
  26202. n = n.trim();
  26203. f = m.getAttribute("compression");
  26204. q = m.getAttribute("encoding");
  26205. if (f && "gzip" !== f && "zlib" !== f) return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"), null;
  26206. switch (f) {
  26207. case "gzip":
  26208. h._tiles = cc.unzipBase64AsArray(n, 4);
  26209. break;
  26210. case "zlib":
  26211. f = new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(n, 1));
  26212. h._tiles = cc.uint8ArrayToUint32Array(f.decompress());
  26213. break;
  26214. case null:
  26215. case "":
  26216. if ("base64" == q) h._tiles = cc.Codec.Base64.decodeAsArray(n, 4);
  26217. else if ("csv" === q) {
  26218. h._tiles = [];
  26219. f = n.split(",");
  26220. for (m = 0; m < f.length; m++) h._tiles.push(parseInt(f[m]))
  26221. } else {
  26222. f = m.getElementsByTagName("tile");
  26223. h._tiles = [];
  26224. for (m = 0; m < f.length; m++) h._tiles.push(parseInt(f[m].getAttribute("gid")))
  26225. }
  26226. break;
  26227. default:
  26228. this.layerAttrs == cc.TMXLayerInfo.ATTRIB_NONE && cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported")
  26229. }
  26230. if (k = k.querySelectorAll("properties \x3e property")) {
  26231. m = {};
  26232. for (f = 0; f < k.length; f++) m[k[f].getAttribute("name")] = k[f].getAttribute("value");
  26233. h.properties = m
  26234. }
  26235. this.setLayers(h)
  26236. }
  26237. if (g = d.getElementsByTagName("objectgroup"))
  26238. for (e = 0; e < g.length; e++) {
  26239. k = g[e];
  26240. h = new cc.TMXObjectGroup;
  26241. h.groupName = k.getAttribute("name");
  26242. h.setPositionOffset(cc.p(parseFloat(k.getAttribute("x")) * this.getTileSize().width || 0, parseFloat(k.getAttribute("y")) * this.getTileSize().height || 0));
  26243. if (m = k.querySelectorAll("objectgroup \x3e properties \x3e property"))
  26244. for (f = 0; f < m.length; f++) n = {}, n[m[f].getAttribute("name")] = m[f].getAttribute("value"), h.properties = n;
  26245. if (k = k.querySelectorAll("object"))
  26246. for (f = 0; f < k.length; f++) {
  26247. n = k[f];
  26248. m = {};
  26249. m.name = n.getAttribute("name") || "";
  26250. m.type = n.getAttribute("type") || "";
  26251. m.x = parseInt(n.getAttribute("x") || 0) + h.getPositionOffset().x;
  26252. q = parseInt(n.getAttribute("y") || 0) + h.getPositionOffset().y;
  26253. m.width = parseInt(n.getAttribute("width")) || 0;
  26254. m.height = parseInt(n.getAttribute("height")) || 0;
  26255. m.y = parseInt(this.getMapSize().height * this.getTileSize().height) - q - m.height;
  26256. if (q = n.querySelectorAll("properties \x3e property"))
  26257. for (r = 0; r < q.length; r++) m[q[r].getAttribute("name")] = q[r].getAttribute("value");
  26258. if ((q = n.querySelectorAll("polygon")) && 0 < q.length)(q = q[0].getAttribute("points")) && (m.polygonPoints = this._parsePointsString(q));
  26259. if ((n = n.querySelectorAll("polyline")) && 0 < n.length)(n = n[0].getAttribute("points")) && (m.polylinePoints = this._parsePointsString(n));
  26260. h.setObjects(m)
  26261. }
  26262. this.setObjectGroups(h)
  26263. }
  26264. return d
  26265. },
  26266. _parsePointsString: function(a) {
  26267. if (!a) return null;
  26268. var c = [];
  26269. a = a.split(" ");
  26270. for (var d = 0; d < a.length; d++) {
  26271. var e = a[d].split(",");
  26272. c.push({
  26273. x: e[0],
  26274. y: e[1]
  26275. })
  26276. }
  26277. return c
  26278. },
  26279. parseXMLString: function(a) {
  26280. return this.parseXMLFile(a, !0)
  26281. },
  26282. getTileProperties: function() {
  26283. return this._tileProperties
  26284. },
  26285. setTileProperties: function(a) {
  26286. this._tileProperties.push(a)
  26287. },
  26288. getCurrentString: function() {
  26289. return this.currentString
  26290. },
  26291. setCurrentString: function(a) {
  26292. this.currentString = a
  26293. },
  26294. getTMXFileName: function() {
  26295. return this.tmxFileName
  26296. },
  26297. setTMXFileName: function(a) {
  26298. this.tmxFileName = a
  26299. },
  26300. _internalInit: function(a, c) {
  26301. this._tilesets.length = 0;
  26302. this._layers.length = 0;
  26303. this.tmxFileName = a;
  26304. c && (this._resources = c);
  26305. this._objectGroups.length = 0;
  26306. this.properties.length = 0;
  26307. this._tileProperties.length = 0;
  26308. this.currentString = "";
  26309. this.storingCharacters = !1;
  26310. this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
  26311. this.parentElement = cc.TMX_PROPERTY_NONE;
  26312. this._currentFirstGID = 0
  26313. }
  26314. });
  26315. _p = cc.TMXMapInfo.prototype;
  26316. cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
  26317. cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
  26318. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  26319. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  26320. cc.TMXMapInfo.create = function(a, c) {
  26321. return new cc.TMXMapInfo(a, c)
  26322. };
  26323. cc.loader.register(["tmx", "tsx"], cc._txtLoader);
  26324. cc.TMXLayerInfo.ATTRIB_NONE = 1;
  26325. cc.TMXLayerInfo.ATTRIB_BASE64 = 2;
  26326. cc.TMXLayerInfo.ATTRIB_GZIP = 4;
  26327. cc.TMXLayerInfo.ATTRIB_ZLIB = 8;
  26328. cc.TMXObjectGroup = cc.Class.extend({
  26329. properties: null,
  26330. groupName: "",
  26331. _positionOffset: null,
  26332. _objects: null,
  26333. ctor: function() {
  26334. this.groupName = "";
  26335. this._positionOffset = cc.p(0, 0);
  26336. this.properties = [];
  26337. this._objects = []
  26338. },
  26339. getPositionOffset: function() {
  26340. return cc.p(this._positionOffset)
  26341. },
  26342. setPositionOffset: function(a) {
  26343. this._positionOffset.x = a.x;
  26344. this._positionOffset.y = a.y
  26345. },
  26346. getProperties: function() {
  26347. return this.properties
  26348. },
  26349. setProperties: function(a) {
  26350. this.properties.push(a)
  26351. },
  26352. getGroupName: function() {
  26353. return this.groupName.toString()
  26354. },
  26355. setGroupName: function(a) {
  26356. this.groupName = a
  26357. },
  26358. propertyNamed: function(a) {
  26359. return this.properties[a]
  26360. },
  26361. objectNamed: function(a) {
  26362. if (this._objects && 0 < this._objects.length)
  26363. for (var c = this._objects, d = 0, e = c.length; d < e; d++) {
  26364. var f = c[d].name;
  26365. if (f && f == a) return c[d]
  26366. }
  26367. return null
  26368. },
  26369. getObjects: function() {
  26370. return this._objects
  26371. },
  26372. setObjects: function(a) {
  26373. this._objects.push(a)
  26374. }
  26375. });
  26376. cc.TMXLayer = cc.SpriteBatchNode.extend({
  26377. tiles: null,
  26378. tileset: null,
  26379. layerOrientation: null,
  26380. properties: null,
  26381. layerName: "",
  26382. _layerSize: null,
  26383. _mapTileSize: null,
  26384. _opacity: 255,
  26385. _minGID: null,
  26386. _maxGID: null,
  26387. _vertexZvalue: null,
  26388. _useAutomaticVertexZ: null,
  26389. _alphaFuncValue: null,
  26390. _reusedTile: null,
  26391. _atlasIndexArray: null,
  26392. _contentScaleFactor: null,
  26393. _cacheCanvas: null,
  26394. _cacheContext: null,
  26395. _cacheTexture: null,
  26396. _subCacheCanvas: null,
  26397. _subCacheContext: null,
  26398. _subCacheCount: 0,
  26399. _subCacheWidth: 0,
  26400. _maxCachePixel: 1E7,
  26401. _className: "TMXLayer",
  26402. ctor: function(a, c, d) {
  26403. cc.SpriteBatchNode.prototype.ctor.call(this);
  26404. this._descendants = [];
  26405. this._layerSize = cc.size(0, 0);
  26406. this._mapTileSize = cc.size(0, 0);
  26407. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  26408. var e = cc._canvas,
  26409. f = cc.newElement("canvas");
  26410. f.width = e.width;
  26411. f.height = e.height;
  26412. this._cacheCanvas = f;
  26413. this._cacheContext = this._cacheCanvas.getContext("2d");
  26414. var g = new cc.Texture2D;
  26415. g.initWithElement(f);
  26416. g.handleLoadedTexture();
  26417. this._cacheTexture = g;
  26418. this.width = e.width;
  26419. this.height = e.height;
  26420. this._cachedParent = this
  26421. }
  26422. void 0 !== d && this.initWithTilesetInfo(a, c, d)
  26423. },
  26424. setContentSize: function(a, c) {
  26425. var d = this._contentSize;
  26426. cc.Node.prototype.setContentSize.call(this, a, c);
  26427. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  26428. var e = this._cacheCanvas,
  26429. f = cc.contentScaleFactor();
  26430. e.width = 0 | 1.5 * d.width * f;
  26431. e.height = 0 | 1.5 * d.height * f;
  26432. this.layerOrientation === cc.TMX_ORIENTATION_HEX ? this._cacheContext.translate(0, e.height - 0.5 * this._mapTileSize.height) : this._cacheContext.translate(0, e.height);
  26433. d = this._cacheTexture._contentSize;
  26434. d.width = e.width;
  26435. d.height = e.height;
  26436. d = e.width * e.height;
  26437. if (d > this._maxCachePixel) {
  26438. this._subCacheCanvas || (this._subCacheCanvas = []);
  26439. this._subCacheContext || (this._subCacheContext = []);
  26440. this._subCacheCount = Math.ceil(d / this._maxCachePixel);
  26441. d = this._subCacheCanvas;
  26442. for (f = 0; f < this._subCacheCount; f++) {
  26443. d[f] || (d[f] = document.createElement("canvas"), this._subCacheContext[f] = d[f].getContext("2d"));
  26444. var g = d[f];
  26445. g.width = this._subCacheWidth = Math.round(e.width / this._subCacheCount);
  26446. g.height = e.height
  26447. }
  26448. for (f = this._subCacheCount; f < d.length; f++) g.width = 0, g.height = 0
  26449. } else this._subCacheCount = 0
  26450. }
  26451. },
  26452. getTexture: null,
  26453. _getTextureForCanvas: function() {
  26454. return this._cacheTexture
  26455. },
  26456. visit: null,
  26457. _visitForCanvas: function(a) {
  26458. var c = a || cc._renderContext;
  26459. if (this._visible) {
  26460. c.save();
  26461. this.transform(a);
  26462. var d, e = this._children;
  26463. if (this._cacheDirty) {
  26464. var f = cc.view;
  26465. f._setScaleXYForRenderTexture();
  26466. var g = this._cacheContext,
  26467. h = this._cacheCanvas;
  26468. g.clearRect(0, 0, h.width, -h.height);
  26469. g.save();
  26470. g.translate(this._anchorPointInPoints.x, -this._anchorPointInPoints.y);
  26471. if (e) {
  26472. this.sortAllChildren();
  26473. for (d = 0; d < e.length; d++) e[d] && e[d].visit(g)
  26474. }
  26475. g.restore();
  26476. if (0 < this._subCacheCount) {
  26477. e = this._subCacheWidth;
  26478. g = h.height;
  26479. for (d = 0; d < this._subCacheCount; d++) this._subCacheContext[d].drawImage(h, d * e, 0, e, g, 0, 0, e, g)
  26480. }
  26481. f._resetScale();
  26482. this._cacheDirty = !1
  26483. }
  26484. this.draw(a);
  26485. c.restore()
  26486. }
  26487. },
  26488. draw: null,
  26489. _drawForCanvas: function(a) {
  26490. a = a || cc._renderContext;
  26491. var c = 0 | -this._anchorPointInPoints.x,
  26492. d = 0 | -this._anchorPointInPoints.y,
  26493. e = cc.view,
  26494. f = this._cacheCanvas;
  26495. if (f) {
  26496. var g = this._subCacheCount,
  26497. h = f.height * e._scaleY,
  26498. k = 0.5 * this._mapTileSize.height * e._scaleY;
  26499. if (0 < g)
  26500. for (var f = this._subCacheCanvas, m = 0; m < g; m++) {
  26501. var n = f[m];
  26502. 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)
  26503. } 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)
  26504. }
  26505. },
  26506. getLayerSize: function() {
  26507. return cc.size(this._layerSize.width, this._layerSize.height)
  26508. },
  26509. setLayerSize: function(a) {
  26510. this._layerSize.width = a.width;
  26511. this._layerSize.height = a.height
  26512. },
  26513. _getLayerWidth: function() {
  26514. return this._layerSize.width
  26515. },
  26516. _setLayerWidth: function(a) {
  26517. this._layerSize.width = a
  26518. },
  26519. _getLayerHeight: function() {
  26520. return this._layerSize.height
  26521. },
  26522. _setLayerHeight: function(a) {
  26523. this._layerSize.height = a
  26524. },
  26525. getMapTileSize: function() {
  26526. return cc.size(this._mapTileSize.width, this._mapTileSize.height)
  26527. },
  26528. setMapTileSize: function(a) {
  26529. this._mapTileSize.width = a.width;
  26530. this._mapTileSize.height = a.height
  26531. },
  26532. _getTileWidth: function() {
  26533. return this._mapTileSize.width
  26534. },
  26535. _setTileWidth: function(a) {
  26536. this._mapTileSize.width = a
  26537. },
  26538. _getTileHeight: function() {
  26539. return this._mapTileSize.height
  26540. },
  26541. _setTileHeight: function(a) {
  26542. this._mapTileSize.height = a
  26543. },
  26544. getTiles: function() {
  26545. return this.tiles
  26546. },
  26547. setTiles: function(a) {
  26548. this.tiles = a
  26549. },
  26550. getTileset: function() {
  26551. return this.tileset
  26552. },
  26553. setTileset: function(a) {
  26554. this.tileset = a
  26555. },
  26556. getLayerOrientation: function() {
  26557. return this.layerOrientation
  26558. },
  26559. setLayerOrientation: function(a) {
  26560. this.layerOrientation = a
  26561. },
  26562. getProperties: function() {
  26563. return this.properties
  26564. },
  26565. setProperties: function(a) {
  26566. this.properties = a
  26567. },
  26568. initWithTilesetInfo: function(a, c, d) {
  26569. var e = c._layerSize,
  26570. f = 0.35 * parseInt(e.width * e.height) + 1,
  26571. g;
  26572. a && (g = cc.textureCache.addImage(a.sourceImage));
  26573. 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
  26574. },
  26575. releaseMap: function() {
  26576. this.tiles && (this.tiles = null);
  26577. this._atlasIndexArray && (this._atlasIndexArray = null)
  26578. },
  26579. getTileAt: function(a, c) {
  26580. if (!a) throw "cc.TMXLayer.getTileAt(): pos should be non-null";
  26581. void 0 !== c && (a = cc.p(a, c));
  26582. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileAt(): invalid position";
  26583. if (!this.tiles || !this._atlasIndexArray) return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"), null;
  26584. var d = null,
  26585. e = this.getTileGIDAt(a);
  26586. if (0 === e) return d;
  26587. var f = 0 | a.x + a.y * this._layerSize.width,
  26588. d = this.getChildByTag(f);
  26589. 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));
  26590. return d
  26591. },
  26592. getTileGIDAt: function(a, c) {
  26593. if (!a) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null";
  26594. void 0 !== c && (a = cc.p(a, c));
  26595. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileGIDAt(): invalid position";
  26596. 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
  26597. },
  26598. getTileFlagsAt: function(a, c) {
  26599. if (!a) throw "cc.TMXLayer.getTileFlagsAt(): pos should be non-null";
  26600. void 0 !== c && (a = cc.p(a, c));
  26601. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileFlagsAt(): invalid position";
  26602. 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
  26603. },
  26604. setTileGID: function(a, c, d, e) {
  26605. if (!c) throw "cc.TMXLayer.setTileGID(): pos should be non-null";
  26606. void 0 !== e ? c = cc.p(c, d) : e = d;
  26607. if (c.x >= this._layerSize.width || c.y >= this._layerSize.height || 0 > c.x || 0 > c.y) throw "cc.TMXLayer.setTileGID(): invalid position";
  26608. if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released");
  26609. else if (0 !== a && a < this.tileset.firstGid) cc.log("cc.TMXLayer.setTileGID(): invalid gid:" + a);
  26610. else {
  26611. e = e || 0;
  26612. this._setNodeDirtyForCache();
  26613. d = this.getTileFlagsAt(c);
  26614. var f = this.getTileGIDAt(c);
  26615. if (f != a || d != e)
  26616. if (d = (a | e) >>> 0, 0 === a) this.removeTileAt(c);
  26617. else if (0 === f) this._insertTileForGID(d, c);
  26618. else {
  26619. var f = c.x + c.y * this._layerSize.width,
  26620. g = this.getChildByTag(f);
  26621. 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)
  26622. }
  26623. }
  26624. },
  26625. removeTileAt: function(a, c) {
  26626. if (!a) throw "cc.TMXLayer.removeTileAt(): pos should be non-null";
  26627. void 0 !== c && (a = cc.p(a, c));
  26628. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.removeTileAt(): invalid position";
  26629. if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");
  26630. else if (0 !== this.getTileGIDAt(a)) {
  26631. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  26632. var d = 0 | a.x + a.y * this._layerSize.width,
  26633. e = this._atlasIndexForExistantZ(d);
  26634. this.tiles[d] = 0;
  26635. this._atlasIndexArray.splice(e, 1);
  26636. if (d = this.getChildByTag(d)) cc.SpriteBatchNode.prototype.removeChild.call(this, d, !0);
  26637. else if (cc._renderType === cc._RENDER_TYPE_WEBGL && this.textureAtlas.removeQuadAtIndex(e), this._children)
  26638. for (var d = this._children, f = 0, g = d.length; f < g; f++) {
  26639. var h = d[f];
  26640. if (h) {
  26641. var k = h.atlasIndex;
  26642. k >= e && (h.atlasIndex = k - 1)
  26643. }
  26644. }
  26645. }
  26646. },
  26647. getPositionAt: function(a, c) {
  26648. void 0 !== c && (a = cc.p(a, c));
  26649. var d = cc.p(0, 0);
  26650. switch (this.layerOrientation) {
  26651. case cc.TMX_ORIENTATION_ORTHO:
  26652. d = this._positionForOrthoAt(a);
  26653. break;
  26654. case cc.TMX_ORIENTATION_ISO:
  26655. d = this._positionForIsoAt(a);
  26656. break;
  26657. case cc.TMX_ORIENTATION_HEX:
  26658. d = this._positionForHexAt(a)
  26659. }
  26660. return cc.pointPixelsToPoints(d)
  26661. },
  26662. getProperty: function(a) {
  26663. return this.properties[a]
  26664. },
  26665. setupTiles: function() {
  26666. cc._renderType === cc._RENDER_TYPE_CANVAS ? this.tileset.imageSize = this._originalTexture.getContentSizeInPixels() : (this.tileset.imageSize = this.textureAtlas.texture.getContentSizeInPixels(), this.textureAtlas.texture.setAliasTexParameters());
  26667. this._parseInternalProperties();
  26668. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  26669. for (var a = this._layerSize.height, c = this._layerSize.width, d = 0; d < a; d++)
  26670. for (var e = 0; e < c; e++) {
  26671. var f = this.tiles[e + c * d];
  26672. 0 !== f && (this._appendTileForGID(f, cc.p(e, d)), this._minGID = Math.min(f, this._minGID), this._maxGID = Math.max(f, this._maxGID))
  26673. }
  26674. this._maxGID >= this.tileset.firstGid && this._minGID >= this.tileset.firstGid || cc.log("cocos2d:TMX: Only 1 tileset per layer is supported")
  26675. },
  26676. addChild: function(a, c, d) {
  26677. cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.")
  26678. },
  26679. removeChild: function(a, c) {
  26680. if (a)
  26681. if (-1 === this._children.indexOf(a)) cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer");
  26682. else {
  26683. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  26684. var d = a.atlasIndex;
  26685. this.tiles[this._atlasIndexArray[d]] = 0;
  26686. this._atlasIndexArray.splice(d, 1);
  26687. cc.SpriteBatchNode.prototype.removeChild.call(this, a, c)
  26688. }
  26689. },
  26690. getLayerName: function() {
  26691. return this.layerName
  26692. },
  26693. setLayerName: function(a) {
  26694. this.layerName = a
  26695. },
  26696. _positionForIsoAt: function(a) {
  26697. 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))
  26698. },
  26699. _positionForOrthoAt: function(a) {
  26700. return cc.p(a.x * this._mapTileSize.width, (this._layerSize.height - a.y - 1) * this._mapTileSize.height)
  26701. },
  26702. _positionForHexAt: function(a) {
  26703. 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))
  26704. },
  26705. _calculateLayerOffset: function(a) {
  26706. var c = cc.p(0, 0);
  26707. switch (this.layerOrientation) {
  26708. case cc.TMX_ORIENTATION_ORTHO:
  26709. c = cc.p(a.x * this._mapTileSize.width, -a.y * this._mapTileSize.height);
  26710. break;
  26711. case cc.TMX_ORIENTATION_ISO:
  26712. c = cc.p(this._mapTileSize.width / 2 * (a.x - a.y), this._mapTileSize.height / 2 * (-a.x - a.y));
  26713. break;
  26714. case cc.TMX_ORIENTATION_HEX:
  26715. (0 !== a.x || 0 !== a.y) && cc.log("offset for hexagonal map not implemented yet")
  26716. }
  26717. return c
  26718. },
  26719. _appendTileForGID: function(a, c) {
  26720. var d = this.tileset.rectForGID(a),
  26721. d = cc.rectPixelsToPoints(d),
  26722. e = 0 | c.x + c.y * this._layerSize.width,
  26723. d = this._reusedTileWithRect(d);
  26724. this._setupTileSprite(d, c, a);
  26725. var f = this._atlasIndexArray.length;
  26726. this.insertQuadFromSprite(d, f);
  26727. this._atlasIndexArray.splice(f, 0, e);
  26728. return d
  26729. },
  26730. _insertTileForGID: function(a, c) {
  26731. var d = this.tileset.rectForGID(a),
  26732. d = cc.rectPixelsToPoints(d),
  26733. e = 0 | c.x + c.y * this._layerSize.width,
  26734. d = this._reusedTileWithRect(d);
  26735. this._setupTileSprite(d, c, a);
  26736. var f = this._atlasIndexForNewZ(e);
  26737. this.insertQuadFromSprite(d, f);
  26738. this._atlasIndexArray.splice(f, 0, e);
  26739. if (this._children)
  26740. for (var g = this._children, h = 0, k = g.length; h < k; h++) {
  26741. var m = g[h];
  26742. if (m) {
  26743. var n = m.atlasIndex;
  26744. n >= f && (m.atlasIndex = n + 1)
  26745. }
  26746. }
  26747. this.tiles[e] = a;
  26748. return d
  26749. },
  26750. _updateTileForGID: function(a, c) {
  26751. var d = this.tileset.rectForGID(a),
  26752. e = this._contentScaleFactor,
  26753. d = cc.rect(d.x / e, d.y / e, d.width / e, d.height / e),
  26754. e = c.x + c.y * this._layerSize.width,
  26755. d = this._reusedTileWithRect(d);
  26756. this._setupTileSprite(d, c, a);
  26757. d.atlasIndex = this._atlasIndexForExistantZ(e);
  26758. d.dirty = !0;
  26759. d.updateTransform();
  26760. this.tiles[e] = a;
  26761. return d
  26762. },
  26763. _parseInternalProperties: function() {
  26764. var a = this.getProperty("cc_vertexz");
  26765. if (a)
  26766. if ("automatic" == a) {
  26767. this._useAutomaticVertexZ = !0;
  26768. var c = this.getProperty("cc_alpha_func"),
  26769. a = 0;
  26770. c && (a = parseFloat(c));
  26771. 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))
  26772. } else this._vertexZvalue = parseInt(a, 10)
  26773. },
  26774. _setupTileSprite: function(a, c, d) {
  26775. var e = c.x + c.y * this._layerSize.width;
  26776. a.setPosition(this.getPositionAt(c));
  26777. cc._renderType === cc._RENDER_TYPE_WEBGL ? a.vertexZ = this._vertexZForPos(c) : a.tag = e;
  26778. a.anchorX = 0;
  26779. a.anchorY = 0;
  26780. a.opacity = this._opacity;
  26781. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.rotation = 0);
  26782. a.setFlippedX(!1);
  26783. a.setFlippedY(!1);
  26784. (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))
  26785. },
  26786. _reusedTileWithRect: function(a) {
  26787. 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);
  26788. return this._reusedTile
  26789. },
  26790. _vertexZForPos: function(a) {
  26791. var c = 0,
  26792. d = 0;
  26793. if (this._useAutomaticVertexZ) switch (this.layerOrientation) {
  26794. case cc.TMX_ORIENTATION_ISO:
  26795. d = this._layerSize.width + this._layerSize.height;
  26796. c = -(d - (a.x + a.y));
  26797. break;
  26798. case cc.TMX_ORIENTATION_ORTHO:
  26799. c = -(this._layerSize.height - a.y);
  26800. break;
  26801. case cc.TMX_ORIENTATION_HEX:
  26802. cc.log("TMX Hexa zOrder not supported");
  26803. break;
  26804. default:
  26805. cc.log("TMX invalid value")
  26806. } else c = this._vertexZvalue;
  26807. return c
  26808. },
  26809. _atlasIndexForExistantZ: function(a) {
  26810. var c;
  26811. if (this._atlasIndexArray)
  26812. for (var d = this._atlasIndexArray, e = 0, f = d.length; e < f && !(c = d[e], c == a); e++);
  26813. "number" != typeof c && cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen");
  26814. return e
  26815. },
  26816. _atlasIndexForNewZ: function(a) {
  26817. for (var c = this._atlasIndexArray, d = 0, e = c.length; d < e && !(a < c[d]); d++);
  26818. return d
  26819. }
  26820. });
  26821. _p = cc.TMXLayer.prototype;
  26822. 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);
  26823. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  26824. cc.defineGetterSetter(_p, "layerWidth", _p._getLayerWidth, _p._setLayerWidth);
  26825. cc.defineGetterSetter(_p, "layerHeight", _p._getLayerHeight, _p._setLayerHeight);
  26826. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  26827. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  26828. cc.TMXLayer.create = function(a, c, d) {
  26829. return new cc.TMXLayer(a, c, d)
  26830. };
  26831. cc.PointObject = cc.Class.extend({
  26832. _ratio: null,
  26833. _offset: null,
  26834. _child: null,
  26835. getRatio: function() {
  26836. return this._ratio
  26837. },
  26838. setRatio: function(a) {
  26839. this._ratio = a
  26840. },
  26841. getOffset: function() {
  26842. return this._offset
  26843. },
  26844. setOffset: function(a) {
  26845. this._offset = a
  26846. },
  26847. getChild: function() {
  26848. return this._child
  26849. },
  26850. setChild: function(a) {
  26851. this._child = a
  26852. },
  26853. initWithCCPoint: function(a, c) {
  26854. this._ratio = a;
  26855. this._offset = c;
  26856. this._child = null;
  26857. return !0
  26858. }
  26859. });
  26860. cc.PointObject.create = function(a, c) {
  26861. var d = new cc.PointObject;
  26862. d.initWithCCPoint(a, c);
  26863. return d
  26864. };
  26865. cc.ParallaxNode = cc.Node.extend({
  26866. parallaxArray: null,
  26867. _lastPosition: null,
  26868. _className: "ParallaxNode",
  26869. getParallaxArray: function() {
  26870. return this.parallaxArray
  26871. },
  26872. setParallaxArray: function(a) {
  26873. this.parallaxArray = a
  26874. },
  26875. ctor: function() {
  26876. cc.Node.prototype.ctor.call(this);
  26877. this.parallaxArray = [];
  26878. this._lastPosition = cc.p(-100, -100)
  26879. },
  26880. addChild: function(a, c, d, e) {
  26881. if (3 === arguments.length) cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");
  26882. else {
  26883. if (!a) throw "cc.ParallaxNode.addChild(): child should be non-null";
  26884. var f = cc.PointObject.create(d, e);
  26885. f.setChild(a);
  26886. this.parallaxArray.push(f);
  26887. a.setPosition(this._position.x * d.x + e.x, this._position.y * d.y + e.y);
  26888. cc.Node.prototype.addChild.call(this, a, c, a.tag)
  26889. }
  26890. },
  26891. removeChild: function(a, c) {
  26892. for (var d = this.parallaxArray, e = 0; e < d.length; e++)
  26893. if (d[e].getChild() == a) {
  26894. d.splice(e, 1);
  26895. break
  26896. }
  26897. cc.Node.prototype.removeChild.call(this, a, c)
  26898. },
  26899. removeAllChildren: function(a) {
  26900. this.parallaxArray.length = 0;
  26901. cc.Node.prototype.removeAllChildren.call(this, a)
  26902. },
  26903. visit: function() {
  26904. var a = this._absolutePosition();
  26905. if (!cc.pointEqualToPoint(a, this._lastPosition)) {
  26906. for (var c = this.parallaxArray, d = 0, e = c.length; d < e; d++) {
  26907. var f = c[d];
  26908. f.getChild().setPosition(-a.x + a.x * f.getRatio().x + f.getOffset().x, -a.y + a.y * f.getRatio().y + f.getOffset().y)
  26909. }
  26910. this._lastPosition = a
  26911. }
  26912. cc.Node.prototype.visit.call(this)
  26913. },
  26914. _absolutePosition: function() {
  26915. for (var a = this._position, c = this; null != c.parent;) c = c.parent, a = cc.pAdd(a, c.getPosition());
  26916. return a
  26917. }
  26918. });
  26919. cc.ParallaxNode.create = function() {
  26920. return new cc.ParallaxNode
  26921. };
  26922. if (cc.sys._supportWebAudio) {
  26923. var _ctx = cc.webAudioContext = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext);
  26924. cc.WebAudio = cc.Class.extend({
  26925. _events: null,
  26926. _buffer: null,
  26927. _sourceNode: null,
  26928. _volumeNode: null,
  26929. src: null,
  26930. preload: null,
  26931. autoplay: null,
  26932. controls: null,
  26933. mediagroup: null,
  26934. currentTime: 0,
  26935. startTime: 0,
  26936. duration: 0,
  26937. _loop: null,
  26938. _volume: 1,
  26939. _pauseTime: 0,
  26940. _paused: !1,
  26941. _stopped: !0,
  26942. _loadState: -1,
  26943. ctor: function(a) {
  26944. this._events = {};
  26945. this.src = a;
  26946. this._volumeNode = _ctx.createGain ? _ctx.createGain() : _ctx.createGainNode();
  26947. this._onSuccess1 = this._onSuccess.bind(this);
  26948. this._onError1 = this._onError.bind(this)
  26949. },
  26950. _play: function(a) {
  26951. var c = this,
  26952. d = c._sourceNode = _ctx.createBufferSource(),
  26953. e = c._volumeNode;
  26954. a = a || 0;
  26955. d.buffer = c._buffer;
  26956. e.gain.value = c._volume;
  26957. d.connect(e);
  26958. e.connect(_ctx.destination);
  26959. d.loop = c._loop;
  26960. d.onended = function() {
  26961. c._stopped = !0
  26962. };
  26963. c._paused = !1;
  26964. c._stopped = !1;
  26965. 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);
  26966. c._pauseTime = 0
  26967. },
  26968. _stop: function() {
  26969. var a = this._sourceNode;
  26970. this._stopped || (a.stop ? a.stop(0) : a.noteOff(0), this._stopped = !0)
  26971. },
  26972. play: function() {
  26973. if (-1 == this._loadState) this._loadState = 0;
  26974. else if (1 == this._loadState) {
  26975. var a = this._sourceNode;
  26976. if (this._stopped || !(a && 2 == a.playbackState)) this.startTime = _ctx.currentTime, this._play(0)
  26977. }
  26978. },
  26979. pause: function() {
  26980. this._pauseTime = _ctx.currentTime;
  26981. this._paused = !0;
  26982. this._stop()
  26983. },
  26984. resume: function() {
  26985. this._paused && this._play(this._buffer ? (this._pauseTime - this.startTime) % this._buffer.duration : 0)
  26986. },
  26987. stop: function() {
  26988. this._pauseTime = 0;
  26989. this._paused = !1;
  26990. this._stop()
  26991. },
  26992. load: function() {
  26993. var a = this;
  26994. if (1 != a._loadState) {
  26995. a._loadState = -1;
  26996. a.played = !1;
  26997. a.ended = !0;
  26998. var c = new XMLHttpRequest;
  26999. c.open("GET", a.src, !0);
  27000. c.responseType = "arraybuffer";
  27001. c.onload = function() {
  27002. _ctx.decodeAudioData(c.response, a._onSuccess1, a._onError1)
  27003. };
  27004. c.send()
  27005. }
  27006. },
  27007. addEventListener: function(a, c) {
  27008. this._events[a] = c.bind(this)
  27009. },
  27010. removeEventListener: function(a) {
  27011. delete this._events[a]
  27012. },
  27013. canplay: function() {
  27014. return cc.sys._supportWebAudio
  27015. },
  27016. _onSuccess: function(a) {
  27017. this._buffer = a;
  27018. a = this._events.success;
  27019. var c = this._events.canplaythrough;
  27020. a && a();
  27021. c && c();
  27022. (0 == this._loadState || "autoplay" == this.autoplay || !0 == this.autoplay) && this._play();
  27023. this._loadState = 1
  27024. },
  27025. _onError: function() {
  27026. var a = this._events.error;
  27027. a && a();
  27028. this._loadState = -2
  27029. },
  27030. cloneNode: function() {
  27031. var a = new cc.WebAudio(this.src);
  27032. a.volume = this.volume;
  27033. a._loadState = this._loadState;
  27034. a._buffer = this._buffer;
  27035. (0 == a._loadState || -1 == a._loadState) && a.load();
  27036. return a
  27037. }
  27038. });
  27039. _p = cc.WebAudio.prototype;
  27040. cc.defineGetterSetter(_p, "loop", function() {
  27041. return this._loop
  27042. }, function(a) {
  27043. this._loop = a;
  27044. this._sourceNode && (this._sourceNode.loop = a)
  27045. });
  27046. cc.defineGetterSetter(_p, "volume", function() {
  27047. return this._volume
  27048. }, function(a) {
  27049. this._volume = a;
  27050. this._volumeNode.gain.value = a
  27051. });
  27052. cc.defineGetterSetter(_p, "paused", function() {
  27053. return this._paused
  27054. });
  27055. cc.defineGetterSetter(_p, "ended", function() {
  27056. var a = this._sourceNode;
  27057. return !this._paused && (this._stopped || !a || 3 == a.playbackState)
  27058. });
  27059. cc.defineGetterSetter(_p, "played", function() {
  27060. var a = this._sourceNode;
  27061. return a && 2 == a.playbackState
  27062. })
  27063. }
  27064. cc.AudioEngine = cc.Class.extend({
  27065. _soundSupported: !1,
  27066. _currMusic: null,
  27067. _currMusicPath: null,
  27068. _musicPlayState: 0,
  27069. _audioID: 0,
  27070. _effects: {},
  27071. _audioPool: {},
  27072. _effectsVolume: 1,
  27073. _maxAudioInstance: 5,
  27074. _effectPauseCb: null,
  27075. _playings: [],
  27076. ctor: function() {
  27077. this._soundSupported = 0 < cc._audioLoader._supportedAudioTypes.length;
  27078. this._effectPauseCb && (this._effectPauseCb = this._effectPauseCb.bind(this))
  27079. },
  27080. willPlayMusic: function() {
  27081. return !1
  27082. },
  27083. getEffectsVolume: function() {
  27084. return this._effectsVolume
  27085. },
  27086. playMusic: function(a, c) {
  27087. if (this._soundSupported) {
  27088. var d = this._currMusic;
  27089. d && this._stopAudio(d);
  27090. a != this._currMusicPath && (this._currMusic = d = this._getAudioByUrl(a), this._currMusicPath = a);
  27091. d && (d.loop = c || !1, this._playMusic(d))
  27092. }
  27093. },
  27094. _getAudioByUrl: function(a) {
  27095. var c = cc.loader,
  27096. d = c.getRes(a);
  27097. d || (c.load(a), d = c.getRes(a));
  27098. return d
  27099. },
  27100. _playMusic: function(a) {
  27101. a.ended || (a.stop ? a.stop() : (a.pause(), a.currentTime = 0));
  27102. this._musicPlayState = 2;
  27103. a.play()
  27104. },
  27105. stopMusic: function(a) {
  27106. if (0 < this._musicPlayState) {
  27107. var c = this._currMusic;
  27108. c && this._stopAudio(c) && (a && cc.loader.release(this._currMusicPath), this._currMusicPath = this._currMusic = null, this._musicPlayState = 0)
  27109. }
  27110. },
  27111. _stopAudio: function(a) {
  27112. return a && !a.ended ? (a.stop ? a.stop() : a.duration && Infinity != a.duration ? a.currentTime = a.duration : a.pause(), !0) : !1
  27113. },
  27114. pauseMusic: function() {
  27115. 2 == this._musicPlayState && (this._currMusic.pause(), this._musicPlayState = 1)
  27116. },
  27117. resumeMusic: function() {
  27118. 1 == this._musicPlayState && (this._resumeAudio(this._currMusic), this._musicPlayState = 2)
  27119. },
  27120. _resumeAudio: function(a) {
  27121. a && !a.ended && (a.resume ? a.resume() : a.play())
  27122. },
  27123. rewindMusic: function() {
  27124. this._currMusic && this._playMusic(this._currMusic)
  27125. },
  27126. getMusicVolume: function() {
  27127. return 0 == this._musicPlayState ? 0 : this._currMusic.volume
  27128. },
  27129. setMusicVolume: function(a) {
  27130. 0 < this._musicPlayState && (this._currMusic.volume = Math.min(Math.max(a, 0), 1))
  27131. },
  27132. isMusicPlaying: function() {
  27133. return 2 == this._musicPlayState && this._currMusic && !this._currMusic.ended
  27134. },
  27135. _getEffectList: function(a) {
  27136. var c = this._audioPool[a];
  27137. c || (c = this._audioPool[a] = []);
  27138. return c
  27139. },
  27140. _getEffect: function(a) {
  27141. var c;
  27142. if (!this._soundSupported) return null;
  27143. for (var d = this._getEffectList(a), e = 0, f = d.length; e < f; e++) {
  27144. var g = d[e];
  27145. if (g.ended) {
  27146. c = g;
  27147. c.currentTime = 0;
  27148. window.chrome && c.load();
  27149. break
  27150. }
  27151. }
  27152. if (!c) {
  27153. if (d.length >= this._maxAudioInstance) return cc.log("Error: " + a + " greater than " + this._maxAudioInstance), null;
  27154. c = this._getAudioByUrl(a);
  27155. if (!c) return null;
  27156. c = c.cloneNode(!0);
  27157. this._effectPauseCb && cc._addEventListener(c, "pause", this._effectPauseCb);
  27158. c.volume = this._effectsVolume;
  27159. d.push(c)
  27160. }
  27161. return c
  27162. },
  27163. playEffect: function(a, c) {
  27164. var d = this._getEffect(a);
  27165. if (!d) return null;
  27166. d.loop = c || !1;
  27167. d.play();
  27168. var e = this._audioID++;
  27169. this._effects[e] = d;
  27170. return e
  27171. },
  27172. setEffectsVolume: function(a) {
  27173. a = this._effectsVolume = Math.min(Math.max(a, 0), 1);
  27174. var c = this._effects,
  27175. d;
  27176. for (d in c) c[d].volume = a
  27177. },
  27178. pauseEffect: function(a) {
  27179. (a = this._effects[a]) && !a.ended && a.pause()
  27180. },
  27181. pauseAllEffects: function() {
  27182. var a = this._effects,
  27183. c;
  27184. for (c in a) {
  27185. var d = a[c];
  27186. d.ended || d.pause()
  27187. }
  27188. },
  27189. resumeEffect: function(a) {
  27190. this._resumeAudio(this._effects[a])
  27191. },
  27192. resumeAllEffects: function() {
  27193. var a = this._effects,
  27194. c;
  27195. for (c in a) this._resumeAudio(a[c])
  27196. },
  27197. stopEffect: function(a) {
  27198. this._stopAudio(this._effects[a]);
  27199. delete this._effects[a]
  27200. },
  27201. stopAllEffects: function() {
  27202. var a = this._effects,
  27203. c;
  27204. for (c in a) this._stopAudio(a[c]), delete a[c]
  27205. },
  27206. unloadEffect: function(a) {
  27207. var c = cc.loader,
  27208. d = this._effects,
  27209. e = this._getEffectList(a);
  27210. c.release(a);
  27211. if (0 != e.length) {
  27212. c = e[0].src;
  27213. delete this._audioPool[a];
  27214. for (var f in d) d[f].src == c && (this._stopAudio(d[f]), delete d[f])
  27215. }
  27216. },
  27217. end: function() {
  27218. this.stopMusic();
  27219. this.stopAllEffects()
  27220. },
  27221. _pausePlaying: function() {
  27222. var a = this._effects,
  27223. c, d;
  27224. for (d in a)
  27225. if ((c = a[d]) && !c.ended && !c.paused) this._playings.push(c), c.pause();
  27226. this.isMusicPlaying() && (this._playings.push(this._currMusic), this._currMusic.pause())
  27227. },
  27228. _resumePlaying: function() {
  27229. for (var a = this._playings, c = 0, d = a.length; c < d; c++) this._resumeAudio(a[c]);
  27230. a.length = 0
  27231. }
  27232. });
  27233. !cc.sys._supportWebAudio && 0 > cc.sys._supportMultipleAudio && (cc.AudioEngineForSingle = cc.AudioEngine.extend({
  27234. _waitingEffIds: [],
  27235. _pausedEffIds: [],
  27236. _currEffect: null,
  27237. _maxAudioInstance: 2,
  27238. _effectCache4Single: {},
  27239. _needToResumeMusic: !1,
  27240. _expendTime4Music: 0,
  27241. _isHiddenMode: !1,
  27242. _playMusic: function(a) {
  27243. this._stopAllEffects();
  27244. this._super(a)
  27245. },
  27246. resumeMusic: function() {
  27247. 1 == this._musicPlayState && (this._stopAllEffects(), this._needToResumeMusic = !1, this._expendTime4Music = 0, this._super())
  27248. },
  27249. playEffect: function(a, c) {
  27250. var d = this._currEffect,
  27251. e = c ? this._getEffect(a) : this._getSingleEffect(a);
  27252. if (!e) return null;
  27253. e.loop = c || !1;
  27254. var f = this._audioID++;
  27255. this._effects[f] = e;
  27256. this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
  27257. d ? (d != e && this._waitingEffIds.push(this._currEffectId), this._waitingEffIds.push(f), d.pause()) : (this._currEffect = e, this._currEffectId = f, e.play());
  27258. return f
  27259. },
  27260. pauseEffect: function(a) {
  27261. cc.log("pauseEffect not supported in single audio mode!")
  27262. },
  27263. pauseAllEffects: function() {
  27264. var a = this._waitingEffIds,
  27265. c = this._pausedEffIds,
  27266. d = this._currEffect;
  27267. if (d) {
  27268. for (var e = 0, f = a.length; e < f; e++) c.push(a[e]);
  27269. a.length = 0;
  27270. c.push(this._currEffectId);
  27271. d.pause()
  27272. }
  27273. },
  27274. resumeEffect: function(a) {
  27275. cc.log("resumeEffect not supported in single audio mode!")
  27276. },
  27277. resumeAllEffects: function() {
  27278. var a = this._waitingEffIds,
  27279. c = this._pausedEffIds;
  27280. this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
  27281. for (var d = 0, e = c.length; d < e; d++) a.push(c[d]);
  27282. c.length = 0;
  27283. if (!this._currEffect && 0 <= a.length && (a = a.pop(), c = this._effects[a])) this._currEffectId = a, this._currEffect = c, this._resumeAudio(c)
  27284. },
  27285. stopEffect: function(a) {
  27286. var c = this._currEffect,
  27287. d = this._waitingEffIds,
  27288. e = this._pausedEffIds;
  27289. 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)))
  27290. },
  27291. stopAllEffects: function() {
  27292. this._stopAllEffects();
  27293. !this._currEffect && this._needToResumeMusic && (this._resumeAudio(this._currMusic), this._musicPlayState = 2, this._needToResumeMusic = !1, this._expendTime4Music = 0)
  27294. },
  27295. unloadEffect: function(a) {
  27296. var c = cc.loader,
  27297. d = this._effects,
  27298. e = this._effectCache4Single,
  27299. f = this._getEffectList(a),
  27300. g = this._currEffect;
  27301. c.release(a);
  27302. if (0 != f.length || e[a]) {
  27303. c = 0 < f.length ? f[0].src : e[a].src;
  27304. delete this._audioPool[a];
  27305. delete e[a];
  27306. for (var h in d) d[h].src == c && delete d[h];
  27307. g && g.src == c && this._stopAudio(g)
  27308. }
  27309. },
  27310. _getSingleEffect: function(a) {
  27311. var c = this._effectCache4Single[a],
  27312. d = this._waitingEffIds,
  27313. e = this._pausedEffIds,
  27314. f = this._effects;
  27315. if (c) c.currentTime = 0;
  27316. else {
  27317. c = this._getAudioByUrl(a);
  27318. if (!c) return null;
  27319. c = c.cloneNode(!0);
  27320. this._effectPauseCb && cc._addEventListener(c, "pause", this._effectPauseCb);
  27321. c.volume = this._effectsVolume;
  27322. this._effectCache4Single[a] = c
  27323. }
  27324. a = 0;
  27325. for (var g = d.length; a < g;) f[d[a]] == c ? d.splice(a, 1) : a++;
  27326. a = 0;
  27327. for (g = e.length; a < g;) f[e[a]] == c ? e.splice(a, 1) : a++;
  27328. c._isToPlay = !0;
  27329. return c
  27330. },
  27331. _stopAllEffects: function() {
  27332. var a = this._currEffect,
  27333. c = this._audioPool,
  27334. d = this._effectCache4Single,
  27335. e = this._waitingEffIds,
  27336. f = this._pausedEffIds;
  27337. if (a || !(0 == e.length && 0 == f.length)) {
  27338. for (var g in d) {
  27339. var h = d[g];
  27340. h.duration && Infinity != h.duration && (h.currentTime = h.duration)
  27341. }
  27342. e.length = 0;
  27343. f.length = 0;
  27344. for (g in c) {
  27345. d = c[g];
  27346. e = 0;
  27347. for (f = d.length; e < f; e++) h = d[e], h.loop = !1, h.duration && Infinity != h.duration && (h.currentTime = h.duration)
  27348. }
  27349. a && this._stopAudio(a)
  27350. }
  27351. },
  27352. _effectPauseCb: function() {
  27353. if (!this._isHiddenMode) {
  27354. var a = this._getWaitingEffToPlay();
  27355. if (a) a._isToPlay ? (delete a._isToPlay, a.play()) : this._resumeAudio(a);
  27356. else if (this._needToResumeMusic) {
  27357. a = this._currMusic;
  27358. if (a.duration && Infinity != a.duration) {
  27359. var c = a.currentTime + this._expendTime4Music,
  27360. c = c - a.duration * (c / a.duration | 0);
  27361. a.currentTime = c
  27362. }
  27363. this._expendTime4Music = 0;
  27364. this._resumeAudio(a);
  27365. this._musicPlayState = 2;
  27366. this._needToResumeMusic = !1
  27367. }
  27368. }
  27369. },
  27370. _getWaitingEffToPlay: function() {
  27371. var a = this._waitingEffIds,
  27372. c = this._effects,
  27373. d = this._currEffect,
  27374. e = d ? d.currentTime - (d.startTime || 0) : 0;
  27375. for (this._expendTime4Music += e; 0 != a.length;) {
  27376. var f = a.pop();
  27377. if (d = c[f]) {
  27378. 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;
  27379. d.duration && Infinity != d.duration && (d.currentTime = d.duration)
  27380. }
  27381. }
  27382. return this._currEffect = this._currEffectId = null
  27383. },
  27384. _pausePlaying: function() {
  27385. var a = this._currEffect;
  27386. this._isHiddenMode = !0;
  27387. if (a = 2 == this._musicPlayState ? this._currMusic : a) this._playings.push(a), a.pause()
  27388. },
  27389. _resumePlaying: function() {
  27390. var a = this._playings;
  27391. this._isHiddenMode = !1;
  27392. 0 < a.length && (this._resumeAudio(a[0]), a.length = 0)
  27393. }
  27394. }));
  27395. cc._audioLoader = {
  27396. _supportedAudioTypes: null,
  27397. getBasePath: function() {
  27398. return cc.loader.audioPath
  27399. },
  27400. _load: function(a, c, d, e, f, g, h) {
  27401. var k = this,
  27402. m = cc.loader,
  27403. n = cc.path,
  27404. q = this._supportedAudioTypes,
  27405. r = "";
  27406. if (0 == q.length) return h("can not support audio!");
  27407. if (-1 == e) r = (n.extname(a) || "").toLowerCase(), k.audioTypeSupported(r) || (r = q[0], e = 0);
  27408. else if (e < q.length) r = q[e];
  27409. 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);
  27410. a = n.changeExtname(a, r);
  27411. f.push(r);
  27412. g = k._loadAudio(a, g, function(m) {
  27413. if (m) return k._load(a, c, d, e + 1, f, g, h);
  27414. h(null, g)
  27415. }, e == q.length - 1);
  27416. m.cache[c] = g
  27417. },
  27418. audioTypeSupported: function(a) {
  27419. return !a ? !1 : 0 <= this._supportedAudioTypes.indexOf(a.toLowerCase())
  27420. },
  27421. _loadAudio: function(a, c, d, e) {
  27422. var f = "file://" == location.origin ? Audio : cc.WebAudio || Audio;
  27423. 2 == arguments.length ? (d = c, c = new f) : 3 < arguments.length && !c && (c = new f);
  27424. c.src = a;
  27425. c.preload = "auto";
  27426. f = navigator.userAgent;
  27427. /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() {
  27428. d(null, c);
  27429. this.removeEventListener("canplaythrough", arguments.callee, !1);
  27430. this.removeEventListener("error", arguments.callee, !1)
  27431. }, !1), cc._addEventListener(c, "error", function() {
  27432. d("load " + a + " failed");
  27433. e && (this.removeEventListener("canplaythrough", arguments.callee, !1), this.removeEventListener("error", arguments.callee, !1))
  27434. }, !1), c.load());
  27435. return c
  27436. },
  27437. load: function(a, c, d, e) {
  27438. this._load(a, c, d, -1, [], null, e)
  27439. }
  27440. };
  27441. cc._audioLoader._supportedAudioTypes = function() {
  27442. var a = cc.newElement("audio"),
  27443. c = [];
  27444. if (a.canPlayType) {
  27445. var d = function(c) {
  27446. c = a.canPlayType(c);
  27447. return "no" != c && "" != c
  27448. };
  27449. d('audio/ogg; codecs\x3d"vorbis"') && c.push(".ogg");
  27450. d("audio/mpeg") && c.push(".mp3");
  27451. d('audio/wav; codecs\x3d"1"') && c.push(".wav");
  27452. d("audio/mp4") && c.push(".mp4");
  27453. (d("audio/x-m4a") || d("audio/aac")) && c.push(".m4a")
  27454. }
  27455. return c
  27456. }();
  27457. cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader);
  27458. cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle : new cc.AudioEngine;
  27459. cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function() {
  27460. cc.audioEngine._pausePlaying()
  27461. });
  27462. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
  27463. cc.audioEngine._resumePlaying()
  27464. });
  27465. cc.CONTROL_EVENT_TOTAL_NUMBER = 9;
  27466. cc.CONTROL_EVENT_TOUCH_DOWN = 1;
  27467. cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE = 2;
  27468. cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE = 4;
  27469. cc.CONTROL_EVENT_TOUCH_DRAG_ENTER = 8;
  27470. cc.CONTROL_EVENT_TOUCH_DRAG_EXIT = 16;
  27471. cc.CONTROL_EVENT_TOUCH_UP_INSIDE = 32;
  27472. cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE = 64;
  27473. cc.CONTROL_EVENT_TOUCH_CANCEL = 128;
  27474. cc.CONTROL_EVENT_VALUECHANGED = 256;
  27475. cc.CONTROL_STATE_NORMAL = 1;
  27476. cc.CONTROL_STATE_HIGHLIGHTED = 2;
  27477. cc.CONTROL_STATE_DISABLED = 4;
  27478. cc.CONTROL_STATE_SELECTED = 8;
  27479. cc.CONTROL_STATE_INITIAL = 8;
  27480. cc.Control = cc.Layer.extend({
  27481. _isOpacityModifyRGB: !1,
  27482. _hasVisibleParents: !1,
  27483. _touchListener: null,
  27484. _className: "Control",
  27485. isOpacityModifyRGB: function() {
  27486. return this._isOpacityModifyRGB
  27487. },
  27488. setOpacityModifyRGB: function(a) {
  27489. this._isOpacityModifyRGB = a;
  27490. for (var c = this.getChildren(), d = 0, e = c.length; d < e; d++) {
  27491. var f = c[d];
  27492. f && f.setOpacityModifyRGB(a)
  27493. }
  27494. },
  27495. _state: cc.CONTROL_STATE_NORMAL,
  27496. getState: function() {
  27497. return this._state
  27498. },
  27499. _enabled: !1,
  27500. _selected: !1,
  27501. _highlighted: !1,
  27502. _dispatchTable: null,
  27503. setEnabled: function(a) {
  27504. this._state = (this._enabled = a) ? cc.CONTROL_STATE_NORMAL : cc.CONTROL_STATE_DISABLED;
  27505. this.needsLayout()
  27506. },
  27507. isEnabled: function() {
  27508. return this._enabled
  27509. },
  27510. setSelected: function(a) {
  27511. this._selected = a;
  27512. this.needsLayout()
  27513. },
  27514. isSelected: function() {
  27515. return this._selected
  27516. },
  27517. setHighlighted: function(a) {
  27518. this._highlighted = a;
  27519. this.needsLayout()
  27520. },
  27521. isHighlighted: function() {
  27522. return this._highlighted
  27523. },
  27524. hasVisibleParents: function() {
  27525. for (var a = this.getParent(); null != a; a = a.getParent())
  27526. if (!a.isVisible()) return !1;
  27527. return !0
  27528. },
  27529. ctor: function() {
  27530. cc.Layer.prototype.ctor.call(this);
  27531. this._dispatchTable = {};
  27532. this._color = cc.color.WHITE
  27533. },
  27534. init: function() {
  27535. if (cc.Layer.prototype.init.call(this)) {
  27536. this._state = cc.CONTROL_STATE_NORMAL;
  27537. this._enabled = !0;
  27538. this._highlighted = this._selected = !1;
  27539. var a = cc.EventListener.create({
  27540. event: cc.EventListener.TOUCH_ONE_BY_ONE
  27541. });
  27542. this.onTouchBegan && (a.onTouchBegan = this.onTouchBegan.bind(this));
  27543. this.onTouchMoved && (a.onTouchMoved = this.onTouchMoved.bind(this));
  27544. this.onTouchEnded && (a.onTouchEnded = this.onTouchEnded.bind(this));
  27545. this.onTouchCancelled && (a.onTouchCancelled = this.onTouchCancelled.bind(this));
  27546. this._touchListener = a;
  27547. return !0
  27548. }
  27549. return !1
  27550. },
  27551. onEnter: function() {
  27552. var a = this._touchListener;
  27553. a._isRegistered() || cc.eventManager.addListener(a, this);
  27554. cc.Node.prototype.onEnter.call(this)
  27555. },
  27556. sendActionsForControlEvents: function(a) {
  27557. for (var c = 0, d = cc.CONTROL_EVENT_TOTAL_NUMBER; c < d; c++)
  27558. if (a & 1 << c)
  27559. for (var e = this._dispatchListforControlEvent(1 << c), f = 0, g = e.length; f < g; f++) e[f].invoke(this)
  27560. },
  27561. addTargetWithActionForControlEvents: function(a, c, d) {
  27562. for (var e = 0, f = cc.CONTROL_EVENT_TOTAL_NUMBER; e < f; e++) d & 1 << e && this._addTargetWithActionForControlEvent(a, c, 1 << e)
  27563. },
  27564. removeTargetWithActionForControlEvents: function(a, c, d) {
  27565. for (var e = 0, f = cc.CONTROL_EVENT_TOTAL_NUMBER; e < f; e++) d & 1 << e && this._removeTargetWithActionForControlEvent(a, c, 1 << e)
  27566. },
  27567. getTouchLocation: function(a) {
  27568. a = a.getLocation();
  27569. return this.convertToNodeSpace(a)
  27570. },
  27571. isTouchInside: function(a) {
  27572. a = a.getLocation();
  27573. a = this.getParent().convertToNodeSpace(a);
  27574. return cc.rectContainsPoint(this.getBoundingBox(), a)
  27575. },
  27576. _invocationWithTargetAndActionForControlEvent: function(a, c, d) {
  27577. return null
  27578. },
  27579. _dispatchListforControlEvent: function(a) {
  27580. a = a.toString();
  27581. this._dispatchTable[a] || (this._dispatchTable[a] = []);
  27582. return this._dispatchTable[a]
  27583. },
  27584. _addTargetWithActionForControlEvent: function(a, c, d) {
  27585. a = new cc.Invocation(a, c, d);
  27586. this._dispatchListforControlEvent(d).push(a)
  27587. },
  27588. _removeTargetWithActionForControlEvent: function(a, c, d) {
  27589. d = this._dispatchListforControlEvent(d);
  27590. if (!a && !c) d.length = 0;
  27591. else
  27592. for (var e = 0; e < d.length;) {
  27593. var f = d[e],
  27594. g = !0;
  27595. a && (g = a == f.getTarget());
  27596. c && (g = g && c == f.getAction());
  27597. g ? cc.arrayRemoveObject(d, f) : e++
  27598. }
  27599. },
  27600. needsLayout: function() {}
  27601. });
  27602. _p = cc.Control.prototype;
  27603. cc.defineGetterSetter(_p, "state", _p.getState);
  27604. cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
  27605. cc.defineGetterSetter(_p, "selected", _p.isSelected, _p.setSelected);
  27606. cc.defineGetterSetter(_p, "highlighted", _p.isHighlighted, _p.setHighlighted);
  27607. _p = null;
  27608. cc.Control.create = function() {
  27609. var a = new cc.Control;
  27610. return a && a.init() ? a : null
  27611. };
  27612. cc.CONTROL_ZOOM_ACTION_TAG = 3435855873;
  27613. cc.ControlButton = cc.Control.extend({
  27614. _doesAdjustBackgroundImage: !1,
  27615. zoomOnTouchDown: !1,
  27616. _preferredSize: null,
  27617. _labelAnchorPoint: null,
  27618. _currentTitle: null,
  27619. _currentTitleColor: null,
  27620. _titleLabel: null,
  27621. _backgroundSprite: null,
  27622. _opacity: 0,
  27623. _isPushed: !1,
  27624. _titleDispatchTable: null,
  27625. _titleColorDispatchTable: null,
  27626. _titleLabelDispatchTable: null,
  27627. _backgroundSpriteDispatchTable: null,
  27628. _parentInited: !1,
  27629. _marginV: 0,
  27630. _marginH: 0,
  27631. _className: "ControlButton",
  27632. ctor: function(a, c, d) {
  27633. cc.Control.prototype.ctor.call(this);
  27634. this._preferredSize = cc.size(0, 0);
  27635. this._labelAnchorPoint = cc.p(0, 0);
  27636. this._currentTitle = "";
  27637. this._currentTitleColor = cc.color.WHITE;
  27638. this._titleDispatchTable = {};
  27639. this._titleColorDispatchTable = {};
  27640. this._titleLabelDispatchTable = {};
  27641. this._backgroundSpriteDispatchTable = {};
  27642. void 0 != d ? this.initWithTitleAndFontNameAndFontSize(a, c, d) : void 0 != c ? this.initWithLabelAndBackgroundSprite(a, c) : void 0 != a ? this.initWithBackgroundSprite(a) : this.init()
  27643. },
  27644. init: function() {
  27645. return this.initWithLabelAndBackgroundSprite(cc.LabelTTF.create("", "Arial", 12), cc.Scale9Sprite.create())
  27646. },
  27647. needsLayout: function() {
  27648. if (this._parentInited) {
  27649. this._titleLabel && this._titleLabel.setVisible(!1);
  27650. this._backgroundSprite && this._backgroundSprite.setVisible(!1);
  27651. this.setLabelAnchorPoint(this._labelAnchorPoint);
  27652. var a = this._state;
  27653. this._currentTitle = this.getTitleForState(a);
  27654. this._currentTitleColor = this.getTitleColorForState(a);
  27655. var c = this._titleLabel = this.getTitleLabelForState(a);
  27656. c && c.setString && c.setString(this._currentTitle);
  27657. c && c.setColor(this._currentTitleColor);
  27658. var d = this.getContentSize();
  27659. c && c.setPosition(d.width / 2, d.height / 2);
  27660. (a = this._backgroundSprite = this.getBackgroundSpriteForState(a)) && a.setPosition(d.width / 2, d.height / 2);
  27661. d = cc.size(0, 0);
  27662. if (c) {
  27663. var e = c.getBoundingBox();
  27664. d.width = e.width;
  27665. d.height = e.height
  27666. }
  27667. 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));
  27668. d = c ? c.getBoundingBox() : cc.rect(0, 0, 0, 0);
  27669. e = a ? a.getBoundingBox() : cc.rect(0, 0, 0, 0);
  27670. d = cc.rectUnion(d, e);
  27671. this.setContentSize(d.width, d.height);
  27672. d = this.getContentSize();
  27673. c && (c.setPosition(d.width / 2, d.height / 2), c.setVisible(!0));
  27674. a && (a.setPosition(d.width / 2, d.height / 2), a.setVisible(!0))
  27675. }
  27676. },
  27677. initWithLabelAndBackgroundSprite: function(a, c) {
  27678. if (!a) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): label should be non-null";
  27679. if (!c) throw "cc.ControlButton.initWithLabelAndBackgroundSprite(): backgroundSprite should be non-null";
  27680. if (cc.Control.prototype.init.call(this, !0)) {
  27681. this._parentInited = !0;
  27682. this._titleDispatchTable = {};
  27683. this._titleColorDispatchTable = {};
  27684. this._titleLabelDispatchTable = {};
  27685. this._backgroundSpriteDispatchTable = {};
  27686. this._isPushed = !1;
  27687. this.zoomOnTouchDown = !0;
  27688. this._currentTitle = null;
  27689. this.setAdjustBackgroundImage(!0);
  27690. this.setPreferredSize(cc.size(0, 0));
  27691. this.zoomOnTouchDown = !0;
  27692. this.ignoreAnchorPointForPosition(!1);
  27693. this.setAnchorPoint(0.5, 0.5);
  27694. this._titleLabel = a;
  27695. this._backgroundSprite = c;
  27696. this.setOpacity(255);
  27697. this.setOpacityModifyRGB(!0);
  27698. var d = a.getString();
  27699. this.setTitleForState(d, cc.CONTROL_STATE_NORMAL);
  27700. this.setTitleColorForState(a.getColor(), cc.CONTROL_STATE_NORMAL);
  27701. this.setTitleLabelForState(a, cc.CONTROL_STATE_NORMAL);
  27702. this.setBackgroundSpriteForState(c, cc.CONTROL_STATE_NORMAL);
  27703. this._state = cc.CONTROL_STATE_NORMAL;
  27704. this._marginH = 24;
  27705. this._marginV = 12;
  27706. this._labelAnchorPoint = cc.p(0.5, 0.5);
  27707. this.setPreferredSize(cc.size(0, 0));
  27708. this.needsLayout();
  27709. return !0
  27710. }
  27711. return !1
  27712. },
  27713. initWithTitleAndFontNameAndFontSize: function(a, c, d) {
  27714. a = cc.LabelTTF.create(a, c, d);
  27715. return this.initWithLabelAndBackgroundSprite(a, cc.Scale9Sprite.create())
  27716. },
  27717. initWithBackgroundSprite: function(a) {
  27718. var c = cc.LabelTTF.create("", "Arial", 30);
  27719. return this.initWithLabelAndBackgroundSprite(c, a)
  27720. },
  27721. doesAdjustBackgroundImage: function() {
  27722. return this._doesAdjustBackgroundImage
  27723. },
  27724. setAdjustBackgroundImage: function(a) {
  27725. this._doesAdjustBackgroundImage = a;
  27726. this.needsLayout()
  27727. },
  27728. getZoomOnTouchDown: function() {
  27729. return this.zoomOnTouchDown
  27730. },
  27731. setZoomOnTouchDown: function(a) {
  27732. return this.zoomOnTouchDown = a
  27733. },
  27734. getPreferredSize: function() {
  27735. return this._preferredSize
  27736. },
  27737. setPreferredSize: function(a) {
  27738. if (0 === a.width && 0 === a.height) this._doesAdjustBackgroundImage = !0;
  27739. else {
  27740. this._doesAdjustBackgroundImage = !1;
  27741. var c = this._backgroundSpriteDispatchTable,
  27742. d;
  27743. for (d in c) c[d].setPreferredSize(a)
  27744. }
  27745. this._preferredSize = a;
  27746. this.needsLayout()
  27747. },
  27748. getLabelAnchorPoint: function() {
  27749. return this._labelAnchorPoint
  27750. },
  27751. setLabelAnchorPoint: function(a) {
  27752. this._labelAnchorPoint = a;
  27753. this._titleLabel && this._titleLabel.setAnchorPoint(a)
  27754. },
  27755. _getCurrentTitle: function() {
  27756. return this._currentTitle
  27757. },
  27758. _getCurrentTitleColor: function() {
  27759. return this._currentTitleColor
  27760. },
  27761. getOpacity: function() {
  27762. return this._opacity
  27763. },
  27764. setOpacity: function(a) {
  27765. cc.Control.prototype.setOpacity.call(this, a);
  27766. var c = this._backgroundSpriteDispatchTable,
  27767. d;
  27768. for (d in c) c[d].setOpacity(a)
  27769. },
  27770. setColor: function(a) {
  27771. cc.Control.prototype.setColor.call(this, a);
  27772. var c = this._backgroundSpriteDispatchTable,
  27773. d;
  27774. for (d in c) c[d].setColor(a)
  27775. },
  27776. getColor: function() {
  27777. var a = this._realColor;
  27778. return cc.color(a.r, a.g, a.b, a.a)
  27779. },
  27780. isPushed: function() {
  27781. return this._isPushed
  27782. },
  27783. _getVerticalMargin: function() {
  27784. return this._marginV
  27785. },
  27786. _getHorizontalOrigin: function() {
  27787. return this._marginH
  27788. },
  27789. setMargins: function(a, c) {
  27790. this._marginV = c;
  27791. this._marginH = a;
  27792. this.needsLayout()
  27793. },
  27794. setEnabled: function(a) {
  27795. cc.Control.prototype.setEnabled.call(this, a);
  27796. this.needsLayout()
  27797. },
  27798. setSelected: function(a) {
  27799. cc.Control.prototype.setSelected.call(this, a);
  27800. this.needsLayout()
  27801. },
  27802. setHighlighted: function(a) {
  27803. this._state = a ? cc.CONTROL_STATE_HIGHLIGHTED : cc.CONTROL_STATE_NORMAL;
  27804. cc.Control.prototype.setHighlighted.call(this, a);
  27805. (a = this.getActionByTag(cc.CONTROL_ZOOM_ACTION_TAG)) && this.stopAction(a);
  27806. this.needsLayout();
  27807. 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))
  27808. },
  27809. onTouchBegan: function(a, c) {
  27810. if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible() || !this.hasVisibleParents()) return !1;
  27811. this._isPushed = !0;
  27812. this.setHighlighted(!0);
  27813. this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_DOWN);
  27814. return !0
  27815. },
  27816. onTouchMoved: function(a, c) {
  27817. if (!this._enabled || !this._isPushed || this._selected) this._highlighted && this.setHighlighted(!1);
  27818. else {
  27819. var d = this.isTouchInside(a);
  27820. 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)
  27821. }
  27822. },
  27823. onTouchEnded: function(a, c) {
  27824. this._isPushed = !1;
  27825. this.setHighlighted(!1);
  27826. this.isTouchInside(a) ? this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_UP_INSIDE) : this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE)
  27827. },
  27828. onTouchCancelled: function(a, c) {
  27829. this._isPushed = !1;
  27830. this.setHighlighted(!1);
  27831. this.sendActionsForControlEvents(cc.CONTROL_EVENT_TOUCH_CANCEL)
  27832. },
  27833. getTitleForState: function(a) {
  27834. var c = this._titleDispatchTable;
  27835. return c ? c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL] : ""
  27836. },
  27837. setTitleForState: function(a, c) {
  27838. this._titleDispatchTable[c] = a || "";
  27839. this.getState() == c && this.needsLayout()
  27840. },
  27841. getTitleColorForState: function(a) {
  27842. return (a = this._titleColorDispatchTable[a]) ? a : (a = this._titleColorDispatchTable[cc.CONTROL_STATE_NORMAL]) ? a : cc.color.WHITE
  27843. },
  27844. setTitleColorForState: function(a, c) {
  27845. this._titleColorDispatchTable[c] = a;
  27846. this.getState() == c && this.needsLayout()
  27847. },
  27848. getTitleLabelForState: function(a) {
  27849. var c = this._titleLabelDispatchTable;
  27850. return c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL]
  27851. },
  27852. setTitleLabelForState: function(a, c) {
  27853. var d = this._titleLabelDispatchTable;
  27854. if (d[c]) {
  27855. var e = d[c];
  27856. e && this.removeChild(e, !0)
  27857. }
  27858. d[c] = a;
  27859. a.setVisible(!1);
  27860. a.setAnchorPoint(0.5, 0.5);
  27861. this.addChild(a, 1);
  27862. this.getState() == c && this.needsLayout()
  27863. },
  27864. setTitleTTFForState: function(a, c) {
  27865. var d = this.getTitleForState(c);
  27866. d || (d = "");
  27867. this.setTitleLabelForState(cc.LabelTTF.create(d, a, 12), c)
  27868. },
  27869. getTitleTTFForState: function(a) {
  27870. a = this.getTitleLabelForState(a);
  27871. return null != a && a instanceof cc.LabelTTF ? a.getFontName() : ""
  27872. },
  27873. setTitleTTFSizeForState: function(a, c) {
  27874. var d = this.getTitleLabelForState(c);
  27875. null != d && d instanceof cc.LabelTTF && d.setFontSize(a)
  27876. },
  27877. getTitleTTFSizeForState: function(a) {
  27878. a = this.getTitleLabelForState(a);
  27879. return null != a && a instanceof cc.LabelTTF ? a.getFontSize() : 0
  27880. },
  27881. setTitleBMFontForState: function(a, c) {
  27882. var d = this.getTitleForState(c);
  27883. d || (d = "");
  27884. this.setTitleLabelForState(cc.LabelBMFont.create(d, a), c)
  27885. },
  27886. getTitleBMFontForState: function(a) {
  27887. a = this.getTitleLabelForState(a);
  27888. return null != a && a instanceof cc.LabelBMFont ? a.getFntFile() : ""
  27889. },
  27890. getBackgroundSpriteForState: function(a) {
  27891. var c = this._backgroundSpriteDispatchTable;
  27892. return c[a] ? c[a] : c[cc.CONTROL_STATE_NORMAL]
  27893. },
  27894. setBackgroundSpriteForState: function(a, c) {
  27895. var d = this._backgroundSpriteDispatchTable;
  27896. if (d[c]) {
  27897. var e = d[c];
  27898. e && this.removeChild(e, !0)
  27899. }
  27900. d[c] = a;
  27901. a.setVisible(!1);
  27902. a.setAnchorPoint(0.5, 0.5);
  27903. this.addChild(a);
  27904. d = this._preferredSize;
  27905. (0 !== d.width || 0 !== d.height) && a.setPreferredSize(d);
  27906. this._state === c && this.needsLayout()
  27907. },
  27908. setBackgroundSpriteFrameForState: function(a, c) {
  27909. var d = cc.Scale9Sprite.createWithSpriteFrame(a);
  27910. this.setBackgroundSpriteForState(d, c)
  27911. }
  27912. });
  27913. _p = cc.ControlButton.prototype;
  27914. cc.defineGetterSetter(_p, "adjustBackground", _p.getAdjustBackgroundImage, _p.setAdjustBackgroundImage);
  27915. cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize);
  27916. cc.defineGetterSetter(_p, "labelAnchor", _p.getLabelAnchorPoint, _p.setLabelAnchorPoint);
  27917. _p = null;
  27918. cc.ControlButton.create = function(a, c, d) {
  27919. return new cc.ControlButton(a, c, d)
  27920. };
  27921. cc.RGBA = function(a, c, d, e) {
  27922. this.r = a;
  27923. this.g = c;
  27924. this.b = d;
  27925. this.a = e
  27926. };
  27927. cc.HSV = function(a, c, d) {
  27928. this.h = a;
  27929. this.s = c;
  27930. this.v = d
  27931. };
  27932. cc.ControlUtils = {};
  27933. cc.ControlUtils.addSpriteToTargetWithPosAndAnchor = function(a, c, d, e) {
  27934. a = cc.Sprite.create("#" + a);
  27935. if (!a) return null;
  27936. a.setPosition(d);
  27937. a.setAnchorPoint(e);
  27938. c.addChild(a);
  27939. return a
  27940. };
  27941. cc.ControlUtils.HSVfromRGB = function(a) {
  27942. var c = new cc.HSV,
  27943. d, e;
  27944. d = a.r < a.g ? a.r : a.g;
  27945. d = d < a.b ? d : a.b;
  27946. e = a.r > a.g ? a.r : a.g;
  27947. e = e > a.b ? e : a.b;
  27948. c.v = e;
  27949. d = e - d;
  27950. if (0 < e) c.s = d / e;
  27951. else return c.s = 0, c.h = -1, c;
  27952. 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;
  27953. c.h *= 60;
  27954. 0 > c.h && (c.h += 360);
  27955. return c
  27956. };
  27957. cc.ControlUtils.RGBfromHSV = function(a) {
  27958. var c, d, e, f, g = new cc.RGBA;
  27959. g.a = 1;
  27960. if (0 >= a.s) {
  27961. if (!a.h) return g.r = a.v, g.g = a.v, g.b = a.v, g;
  27962. g.r = 0;
  27963. g.g = 0;
  27964. g.b = 0;
  27965. return g
  27966. }
  27967. c = a.h;
  27968. 360 <= c && (c = 0);
  27969. c /= 60;
  27970. f = 0 | c;
  27971. e = c - f;
  27972. c = a.v * (1 - a.s);
  27973. d = a.v * (1 - a.s * e);
  27974. e = a.v * (1 - a.s * (1 - e));
  27975. switch (f) {
  27976. case 0:
  27977. g.r = a.v;
  27978. g.g = e;
  27979. g.b = c;
  27980. break;
  27981. case 1:
  27982. g.r = d;
  27983. g.g = a.v;
  27984. g.b = c;
  27985. break;
  27986. case 2:
  27987. g.r = c;
  27988. g.g = a.v;
  27989. g.b = e;
  27990. break;
  27991. case 3:
  27992. g.r = c;
  27993. g.g = d;
  27994. g.b = a.v;
  27995. break;
  27996. case 4:
  27997. g.r = e;
  27998. g.g = c;
  27999. g.b = a.v;
  28000. break;
  28001. default:
  28002. g.r = a.v, g.g = c, g.b = d
  28003. }
  28004. return g
  28005. };
  28006. cc.ControlUtils.CCRectUnion = function(a, c) {
  28007. return cc.rectUnion(a, c)
  28008. };
  28009. cc.Invocation = cc.Class.extend({
  28010. _action: null,
  28011. _target: null,
  28012. _controlEvent: null,
  28013. ctor: function(a, c, d) {
  28014. this._target = a;
  28015. this._action = c;
  28016. this._controlEvent = d
  28017. },
  28018. getAction: function() {
  28019. return this._action
  28020. },
  28021. getTarget: function() {
  28022. return this._target
  28023. },
  28024. getControlEvent: function() {
  28025. return this._controlEvent
  28026. },
  28027. invoke: function(a) {
  28028. if (this._target && this._action)
  28029. if ("string" == typeof this._action) this._target[this._action](a, this._controlEvent);
  28030. else this._action.call(this._target, a, this._controlEvent)
  28031. }
  28032. });
  28033. cc.Scale9Sprite = cc.Node.extend({
  28034. _spriteRect: null,
  28035. _capInsetsInternal: null,
  28036. _positionsAreDirty: !1,
  28037. _scale9Image: null,
  28038. _topLeft: null,
  28039. _top: null,
  28040. _topRight: null,
  28041. _left: null,
  28042. _centre: null,
  28043. _right: null,
  28044. _bottomLeft: null,
  28045. _bottom: null,
  28046. _bottomRight: null,
  28047. _opacityModifyRGB: !1,
  28048. _originalSize: null,
  28049. _preferredSize: null,
  28050. _opacity: 0,
  28051. _color: null,
  28052. _capInsets: null,
  28053. _insetLeft: 0,
  28054. _insetTop: 0,
  28055. _insetRight: 0,
  28056. _insetBottom: 0,
  28057. _spritesGenerated: !1,
  28058. _spriteFrameRotated: !1,
  28059. _textureLoaded: !1,
  28060. _loadedEventListeners: null,
  28061. _className: "Scale9Sprite",
  28062. textureLoaded: function() {
  28063. return this._textureLoaded
  28064. },
  28065. addLoadedEventListener: function(a, c) {
  28066. this._loadedEventListeners.push({
  28067. eventCallback: a,
  28068. eventTarget: c
  28069. })
  28070. },
  28071. _callLoadedEventCallbacks: function() {
  28072. this._textureLoaded = !0;
  28073. for (var a = this._loadedEventListeners, c = 0, d = a.length; c < d; c++) {
  28074. var e = a[c];
  28075. e.eventCallback.call(e.eventTarget, this)
  28076. }
  28077. a.length = 0
  28078. },
  28079. _updateCapInset: function() {
  28080. var a;
  28081. a = this._insetLeft;
  28082. var c = this._insetTop,
  28083. d = this._insetRight,
  28084. e = this._spriteRect,
  28085. f = this._insetBottom;
  28086. 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);
  28087. this.setCapInsets(a)
  28088. },
  28089. _updatePositions: function() {
  28090. if (this._topLeft && this._topRight && this._bottomRight && this._bottomLeft && this._centre) {
  28091. var a = this._contentSize,
  28092. c = this._topLeft,
  28093. d = this._topRight,
  28094. e = this._bottomRight,
  28095. f = this._bottomLeft,
  28096. g = this._centre,
  28097. h = this._centre.getContentSize(),
  28098. k = c.getContentSize(),
  28099. m = f.getContentSize(),
  28100. n = a.width - k.width - d.getContentSize().width,
  28101. a = a.height - k.height - e.getContentSize().height,
  28102. n = n / h.width,
  28103. a = a / h.height,
  28104. k = h.width * n,
  28105. q = h.height * a,
  28106. r = m.width,
  28107. m = m.height;
  28108. if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
  28109. var t = Math.round(k);
  28110. k != t && (k = t, n = k / h.width);
  28111. t = Math.round(q);
  28112. q != t && (q = t, a = q / h.height)
  28113. }
  28114. g.setScaleX(n);
  28115. g.setScaleY(a);
  28116. var h = this._left,
  28117. t = this._right,
  28118. s = this._top,
  28119. v = this._bottom,
  28120. u = cc.p(0, 0);
  28121. f.setAnchorPoint(u);
  28122. e.setAnchorPoint(u);
  28123. c.setAnchorPoint(u);
  28124. d.setAnchorPoint(u);
  28125. h.setAnchorPoint(u);
  28126. t.setAnchorPoint(u);
  28127. s.setAnchorPoint(u);
  28128. v.setAnchorPoint(u);
  28129. g.setAnchorPoint(u);
  28130. f.setPosition(0, 0);
  28131. e.setPosition(r + k, 0);
  28132. c.setPosition(0, m + q);
  28133. d.setPosition(r + k, m + q);
  28134. h.setPosition(0, m);
  28135. h.setScaleY(a);
  28136. t.setPosition(r + k, m);
  28137. t.setScaleY(a);
  28138. v.setPosition(r, 0);
  28139. v.setScaleX(n);
  28140. s.setPosition(r, m + q);
  28141. s.setScaleX(n);
  28142. g.setPosition(r, m)
  28143. }
  28144. },
  28145. ctor: function(a, c, d) {
  28146. cc.Node.prototype.ctor.call(this);
  28147. this._spriteRect = cc.rect(0, 0, 0, 0);
  28148. this._capInsetsInternal = cc.rect(0, 0, 0, 0);
  28149. this._originalSize = cc.size(0, 0);
  28150. this._preferredSize = cc.size(0, 0);
  28151. this._capInsets = cc.rect(0, 0, 0, 0);
  28152. this._loadedEventListeners = [];
  28153. if (void 0 != a)
  28154. if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a, c);
  28155. else {
  28156. var e = cc.spriteFrameCache.getSpriteFrame(a);
  28157. null != e ? this.initWithSpriteFrame(e, c) : this.initWithFile(a, c, d)
  28158. } else this.init()
  28159. },
  28160. getOriginalSize: function() {
  28161. return this._originalSize
  28162. },
  28163. getPreferredSize: function() {
  28164. return this._preferredSize
  28165. },
  28166. _getPreferredWidth: function() {
  28167. return this._preferredSize.width
  28168. },
  28169. _getPreferredHeight: function() {
  28170. return this._preferredSize.height
  28171. },
  28172. setPreferredSize: function(a) {
  28173. this.setContentSize(a);
  28174. this._preferredSize = a
  28175. },
  28176. _setPreferredWidth: function(a) {
  28177. this._setWidth(a);
  28178. this._preferredSize.width = a
  28179. },
  28180. _setPreferredHeight: function(a) {
  28181. this._setHeight(a);
  28182. this._preferredSize.height = a
  28183. },
  28184. setOpacity: function(a) {
  28185. if (this._scale9Image) {
  28186. cc.Node.prototype.setOpacity.call(this, a);
  28187. for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
  28188. var e = c[d];
  28189. e && e.setOpacity(a)
  28190. }
  28191. }
  28192. },
  28193. updateDisplayedOpacity: function(a) {
  28194. if (this._scale9Image) {
  28195. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  28196. for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
  28197. var e = c[d];
  28198. e && e.updateDisplayedOpacity(a)
  28199. }
  28200. }
  28201. },
  28202. setColor: function(a) {
  28203. if (this._scale9Image) {
  28204. cc.Node.prototype.setColor.call(this, a);
  28205. for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
  28206. var e = c[d];
  28207. e && e.setColor(a)
  28208. }
  28209. }
  28210. },
  28211. updateDisplayedColor: function(a) {
  28212. if (this._scale9Image) {
  28213. cc.Node.prototype.updateDisplayedColor.call(this, a);
  28214. for (var c = this._scale9Image.getChildren(), d = 0; d < c.length; d++) {
  28215. var e = c[d];
  28216. 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()
  28217. }
  28218. }
  28219. },
  28220. getCapInsets: function() {
  28221. return this._capInsets
  28222. },
  28223. setCapInsets: function(a) {
  28224. if (this._scale9Image) {
  28225. var c = this._contentSize,
  28226. d = c.width,
  28227. c = c.height;
  28228. this.updateWithBatchNode(this._scale9Image, this._spriteRect, this._spriteFrameRotated, a);
  28229. this.setContentSize(d, c)
  28230. }
  28231. },
  28232. getInsetLeft: function() {
  28233. return this._insetLeft
  28234. },
  28235. setInsetLeft: function(a) {
  28236. this._insetLeft = a;
  28237. this._updateCapInset()
  28238. },
  28239. getInsetTop: function() {
  28240. return this._insetTop
  28241. },
  28242. setInsetTop: function(a) {
  28243. this._insetTop = a;
  28244. this._updateCapInset()
  28245. },
  28246. getInsetRight: function() {
  28247. return this._insetRight
  28248. },
  28249. setInsetRight: function(a) {
  28250. this._insetRight = a;
  28251. this._updateCapInset()
  28252. },
  28253. getInsetBottom: function() {
  28254. return this._insetBottom
  28255. },
  28256. setInsetBottom: function(a) {
  28257. this._insetBottom = a;
  28258. this._updateCapInset()
  28259. },
  28260. setContentSize: function(a, c) {
  28261. cc.Node.prototype.setContentSize.call(this, a, c);
  28262. this._positionsAreDirty = !0
  28263. },
  28264. _setWidth: function(a) {
  28265. cc.Node.prototype._setWidth.call(this, a);
  28266. this._positionsAreDirty = !0
  28267. },
  28268. _setHeight: function(a) {
  28269. cc.Node.prototype._setHeight.call(this, a);
  28270. this._positionsAreDirty = !0
  28271. },
  28272. visit: function(a) {
  28273. this._positionsAreDirty && (this._updatePositions(), this._positionsAreDirty = !1);
  28274. cc.Node.prototype.visit.call(this, a)
  28275. },
  28276. init: function() {
  28277. return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), !1, cc.rect(0, 0, 0, 0))
  28278. },
  28279. initWithBatchNode: function(a, c, d, e) {
  28280. void 0 === e && (e = d, d = !1);
  28281. a && this.updateWithBatchNode(a, c, d, e);
  28282. this.setCascadeColorEnabled(!0);
  28283. this.setCascadeOpacityEnabled(!0);
  28284. this.setAnchorPoint(0.5, 0.5);
  28285. return this._positionsAreDirty = !0
  28286. },
  28287. initWithFile: function(a, c, d) {
  28288. 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));
  28289. if (!a) throw "cc.Scale9Sprite.initWithFile(): file should be non-null";
  28290. var e = cc.textureCache.textureForKey(a);
  28291. if (!e) {
  28292. var e = cc.textureCache.addImage(a),
  28293. f = e.isLoaded();
  28294. (this._textureLoaded = f) || e.addLoadedEventListener(function(a) {
  28295. var c = this._preferredSize,
  28296. c = cc.size(c.width, c.height);
  28297. a = a.getContentSize();
  28298. this.updateWithBatchNode(this._scale9Image, cc.rect(0, 0, a.width, a.height), !1, this._capInsets);
  28299. this.setPreferredSize(c);
  28300. this._positionsAreDirty = !0;
  28301. this._callLoadedEventCallbacks()
  28302. }, this)
  28303. }
  28304. return this.initWithBatchNode(cc.SpriteBatchNode.create(a, 9), c, !1, d)
  28305. },
  28306. initWithSpriteFrame: function(a, c) {
  28307. if (!a || !a.getTexture()) throw "cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null";
  28308. c = c || cc.rect(0, 0, 0, 0);
  28309. var d = a.textureLoaded();
  28310. (this._textureLoaded = d) || a.addLoadedEventListener(function(a) {
  28311. var c = this._preferredSize,
  28312. c = cc.size(c.width, c.height);
  28313. this.updateWithBatchNode(this._scale9Image, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), this._capInsets);
  28314. this.setPreferredSize(c);
  28315. this._positionsAreDirty = !0;
  28316. this._callLoadedEventCallbacks()
  28317. }, this);
  28318. d = cc.SpriteBatchNode.create(a.getTexture(), 9);
  28319. return this.initWithBatchNode(d, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), c)
  28320. },
  28321. initWithSpriteFrameName: function(a, c) {
  28322. if (!a) throw "cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null";
  28323. c = c || cc.rect(0, 0, 0, 0);
  28324. var d = cc.spriteFrameCache.getSpriteFrame(a);
  28325. return null == d ? (cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName"), !1) : this.initWithSpriteFrame(d, c)
  28326. },
  28327. resizableSpriteWithCapInsets: function(a) {
  28328. var c = new cc.Scale9Sprite;
  28329. return c && c.initWithBatchNode(this._scale9Image, this._spriteRect, !1, a) ? c : null
  28330. },
  28331. setOpacityModifyRGB: function(a) {
  28332. if (this._scale9Image) {
  28333. this._opacityModifyRGB = a;
  28334. var c = this._scale9Image.getChildren();
  28335. if (c)
  28336. for (var d = 0, e = c.length; d < e; d++) c[d].setOpacityModifyRGB(a)
  28337. }
  28338. },
  28339. isOpacityModifyRGB: function() {
  28340. return this._opacityModifyRGB
  28341. },
  28342. updateWithBatchNode: function(a, c, d, e) {
  28343. var f = this.getOpacity(),
  28344. g = this.getColor();
  28345. c = cc.rect(c.x, c.y, c.width, c.height);
  28346. this.removeAllChildren(!0);
  28347. this._scale9Image != a && (this._scale9Image = a);
  28348. if (!this._scale9Image) return !1;
  28349. a = a.getTexture();
  28350. var h = a.isLoaded();
  28351. this._textureLoaded = h;
  28352. if (!h) return a.addLoadedEventListener(function(a) {
  28353. this._positionsAreDirty = !0;
  28354. this._callLoadedEventCallbacks()
  28355. }, this), !0;
  28356. a = this._scale9Image;
  28357. a.removeAllChildren(!0);
  28358. h = this._capInsets;
  28359. h.x = e.x;
  28360. h.y = e.y;
  28361. h.width = e.width;
  28362. h.height = e.height;
  28363. this._spriteFrameRotated = d;
  28364. h = a.getTexture();
  28365. cc._rectEqualToZero(c) && (c = h.getContentSize(), c = cc.rect(0, 0, c.width, c.height));
  28366. var k = this._spriteRect = c;
  28367. k.x = c.x;
  28368. k.y = c.y;
  28369. k.width = c.width;
  28370. k.height = c.height;
  28371. this._originalSize.width = c.width;
  28372. this._originalSize.height = c.height;
  28373. k = this._preferredSize;
  28374. 0 === k.width && 0 === k.height && (k.width = c.width, k.height = c.height);
  28375. k = this._capInsetsInternal;
  28376. e && (k.x = e.x, k.y = e.y, k.width = e.width, k.height = e.height);
  28377. var m = c.width;
  28378. e = c.height;
  28379. cc._rectEqualToZero(k) && (k.x = m / 3, k.y = e / 3, k.width = m / 3, k.height = e / 3);
  28380. var n = k.x,
  28381. q = k.width,
  28382. r = m - (n + q),
  28383. t = k.y,
  28384. s = k.height,
  28385. v = e - (t + s),
  28386. u = 0,
  28387. x = 0;
  28388. e = cc.rect(u, x, n, t);
  28389. var u = u + n,
  28390. k = cc.rect(u, x, q, t),
  28391. m = cc.rect(u + q, x, r, t),
  28392. u = 0,
  28393. x = 0 + t,
  28394. A = cc.rect(u, x, n, s),
  28395. u = u + n,
  28396. D = cc.rect(u, x, q, s),
  28397. u = u + q,
  28398. F = cc.rect(u, x, r, s),
  28399. u = 0,
  28400. x = 0 + t + s,
  28401. t = cc.rect(u, x, n, v),
  28402. u = u + n,
  28403. n = cc.rect(u, x, q, v),
  28404. u = u + q,
  28405. q = cc.rect(u, x, r, v),
  28406. r = cc.affineTransformMakeIdentity();
  28407. if (d) {
  28408. d = D;
  28409. var v = q,
  28410. u = t,
  28411. x = m,
  28412. s = e,
  28413. y = F,
  28414. z = A,
  28415. C = n,
  28416. w = k,
  28417. r = cc.affineTransformTranslate(r, c.height + c.x, c.y),
  28418. r = cc.affineTransformRotate(r, 1.57079633),
  28419. D = cc.rectApplyAffineTransform(D, r),
  28420. q = cc.rectApplyAffineTransform(q, r),
  28421. t = cc.rectApplyAffineTransform(t, r),
  28422. m = cc.rectApplyAffineTransform(m, r);
  28423. e = cc.rectApplyAffineTransform(e, r);
  28424. F = cc.rectApplyAffineTransform(F, r);
  28425. A = cc.rectApplyAffineTransform(A, r);
  28426. n = cc.rectApplyAffineTransform(n, r);
  28427. k = cc.rectApplyAffineTransform(k, r);
  28428. d.x = D.x;
  28429. d.y = D.y;
  28430. v.x = q.x;
  28431. v.y = q.y;
  28432. u.x = t.x;
  28433. u.y = t.y;
  28434. x.x = m.x;
  28435. x.y = m.y;
  28436. s.x = e.x;
  28437. s.y = e.y;
  28438. y.x = F.x;
  28439. y.y = F.y;
  28440. z.x = A.x;
  28441. z.y = A.y;
  28442. C.x = n.x;
  28443. C.y = n.y;
  28444. w.x = k.x;
  28445. w.y = k.y;
  28446. this._centre = new cc.Sprite;
  28447. this._centre.initWithTexture(h, d, !0);
  28448. a.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
  28449. this._top = new cc.Sprite;
  28450. this._top.initWithTexture(h, w, !0);
  28451. a.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
  28452. this._bottom = new cc.Sprite;
  28453. this._bottom.initWithTexture(h, C, !0);
  28454. a.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
  28455. this._left = new cc.Sprite;
  28456. this._left.initWithTexture(h, z, !0);
  28457. a.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
  28458. this._right = new cc.Sprite;
  28459. this._right.initWithTexture(h, y, !0);
  28460. a.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
  28461. this._topLeft = new cc.Sprite;
  28462. this._topLeft.initWithTexture(h, s, !0);
  28463. a.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
  28464. this._topRight = new cc.Sprite;
  28465. this._topRight.initWithTexture(h, x, !0);
  28466. a.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
  28467. this._bottomLeft = new cc.Sprite;
  28468. this._bottomLeft.initWithTexture(h, u, !0);
  28469. a.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
  28470. this._bottomRight = new cc.Sprite;
  28471. this._bottomRight.initWithTexture(h, v, !0)
  28472. } 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);
  28473. a.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
  28474. this.setContentSize(c.width, c.height);
  28475. this.addChild(a);
  28476. this._spritesGenerated && (this.setOpacity(f), this.setColor(g));
  28477. return this._spritesGenerated = !0
  28478. },
  28479. setSpriteFrame: function(a) {
  28480. var c = cc.SpriteBatchNode.create(a.getTexture(), 9),
  28481. d = a.textureLoaded();
  28482. (this._textureLoaded = d) || a.addLoadedEventListener(function(a) {
  28483. var c = this._preferredSize,
  28484. c = cc.size(c.width, c.height);
  28485. this.updateWithBatchNode(this._scale9Image, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), this._capInsets);
  28486. this.setPreferredSize(c);
  28487. this._positionsAreDirty = !0;
  28488. this._callLoadedEventCallbacks()
  28489. }, this);
  28490. this.updateWithBatchNode(c, a.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && a.isRotated(), cc.rect(0, 0, 0, 0));
  28491. this._insetBottom = this._insetRight = this._insetTop = this._insetLeft = 0
  28492. }
  28493. });
  28494. _p = cc.Scale9Sprite.prototype;
  28495. cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize);
  28496. cc.defineGetterSetter(_p, "capInsets", _p.getCapInsets, _p.setCapInsets);
  28497. cc.defineGetterSetter(_p, "insetLeft", _p.getInsetLeft, _p.setInsetLeft);
  28498. cc.defineGetterSetter(_p, "insetTop", _p.getInsetTop, _p.setInsetTop);
  28499. cc.defineGetterSetter(_p, "insetRight", _p.getInsetRight, _p.setInsetRight);
  28500. cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom);
  28501. _p = null;
  28502. cc.Scale9Sprite.create = function(a, c, d) {
  28503. return new cc.Scale9Sprite(a, c, d)
  28504. };
  28505. cc.Scale9Sprite.createWithSpriteFrame = function(a, c) {
  28506. return new cc.Scale9Sprite(a, c)
  28507. };
  28508. cc.Scale9Sprite.createWithSpriteFrameName = function(a, c) {
  28509. return new cc.Scale9Sprite(a, c)
  28510. };
  28511. cc.Scale9Sprite.POSITIONS_CENTRE = 0;
  28512. cc.Scale9Sprite.POSITIONS_TOP = 1;
  28513. cc.Scale9Sprite.POSITIONS_LEFT = 2;
  28514. cc.Scale9Sprite.POSITIONS_RIGHT = 3;
  28515. cc.Scale9Sprite.POSITIONS_BOTTOM = 4;
  28516. cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5;
  28517. cc.Scale9Sprite.POSITIONS_TOPLEFT = 6;
  28518. cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7;
  28519. cc.Spacer = cc.Layer.extend({});
  28520. cc.Spacer.verticalSpacer = function(a) {
  28521. var c = new cc.Spacer;
  28522. c.init();
  28523. c.setContentSize(0, a);
  28524. return c
  28525. };
  28526. cc.Spacer.horizontalSpacer = function(a) {
  28527. var c = new cc.Spacer;
  28528. c.init();
  28529. c.setContentSize(a, 0);
  28530. return c
  28531. };
  28532. cc.MenuPassive = cc.Layer.extend({
  28533. _color: null,
  28534. _opacity: 0,
  28535. _className: "MenuPassive",
  28536. ctor: function() {},
  28537. getColor: function() {
  28538. var a = this._color;
  28539. return cc.color(a.r, a.g, a.b, a.a)
  28540. },
  28541. setColor: function(a) {
  28542. var c = this._color;
  28543. c.r = a.r;
  28544. c.g = a.g;
  28545. c.b = a.b;
  28546. if (this._children && 0 < this._children.length)
  28547. for (c = 0; c < this._children.length; c++) this._children[c] && this._children[c].setColor(a);
  28548. void 0 !== a.a && !a.a_undefined && this.setOpacity(a.a)
  28549. },
  28550. getOpacity: function() {
  28551. return this._opacity
  28552. },
  28553. setOpacity: function(a) {
  28554. this._opacity = a;
  28555. if (this._children && 0 < this._children.length)
  28556. for (var c = 0; c < this._children.length; c++) this._children[c] && this._children[c].setOpacity(a);
  28557. this._color.a = a
  28558. },
  28559. initWithItems: function(a, c) {
  28560. if (this.init()) {
  28561. var d = cc.director.getWinSize();
  28562. this.ignoreAnchorPointForPosition(!0);
  28563. this.setAnchorPoint(0.5, 0.5);
  28564. this.setContentSize(d);
  28565. this.setPosition(d.width / 2, d.height / 2);
  28566. d = 0;
  28567. if (a) {
  28568. this.addChild(a, d);
  28569. for (var e = 0; e < c.length; e++) c[e] && (d++, this.addChild(c[e], d))
  28570. }
  28571. return !0
  28572. }
  28573. return !1
  28574. },
  28575. alignItemsVertically: function() {
  28576. this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
  28577. },
  28578. alignItemsVerticallyWithPadding: function(a) {
  28579. var c = -a,
  28580. d;
  28581. if (this._children && 0 < this._children.length)
  28582. for (d = 0; d < this._children.length; d++) this._children[d] && (c += this._children[d].getContentSize().height * this._children[d].getScaleY() + a);
  28583. var e = 0,
  28584. f = c / 2;
  28585. if (this._children && 0 < this._children.length)
  28586. 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);
  28587. this.setContentSize(e, c)
  28588. },
  28589. alignItemsHorizontally: function() {
  28590. this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
  28591. },
  28592. alignItemsHorizontallyWithPadding: function(a) {
  28593. var c = -a,
  28594. d;
  28595. if (this._children && 0 < this._children.length)
  28596. for (d = 0; d < this._children.length; d++) this._children[d] && (c += this._children[d].getContentSize().width * this._children[d].getScaleX() + a);
  28597. var e = 0,
  28598. f = -c / 2;
  28599. if (this._children && 0 < this._children.length)
  28600. 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);
  28601. this.setContentSize(c, e)
  28602. },
  28603. alignItemsInColumns: function(a) {
  28604. var c = [],
  28605. d;
  28606. for (d = 1; d < arguments.length; d++) c.push(arguments[d]);
  28607. var e = -5,
  28608. f = 0,
  28609. g = 0,
  28610. h = 0,
  28611. k, m;
  28612. if (this._children && 0 < this._children.length)
  28613. 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"));
  28614. var n = cc.director.getWinSize(),
  28615. q = k = g = f = 0,
  28616. r = 0,
  28617. e = e / 2;
  28618. if (this._children && 0 < this._children.length)
  28619. 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))
  28620. },
  28621. alignItemsInRows: function(a) {
  28622. var c = [],
  28623. d;
  28624. for (d = 1; d < arguments.length; d++) c.push(arguments[d]);
  28625. var e = [],
  28626. f = [],
  28627. g = -10,
  28628. h = -5,
  28629. k = 0,
  28630. m = 0,
  28631. n = 0,
  28632. q, r;
  28633. if (this._children && 0 < this._children.length)
  28634. 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"));
  28635. h = cc.director.getWinSize();
  28636. m = k = 0;
  28637. q = null;
  28638. var g = -g / 2,
  28639. t = 0;
  28640. if (this._children && 0 < this._children.length)
  28641. 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))
  28642. },
  28643. setOpacityModifyRGB: function(a) {},
  28644. isOpacityModifyRGB: function() {
  28645. return !1
  28646. }
  28647. });
  28648. cc.MenuPassive.create = function(a) {
  28649. a || (a = null);
  28650. for (var c = [], d = 1; d < arguments.length; d++) c.push(arguments[d]);
  28651. return (d = new cc.MenuPassive) && d.initWithItems(a, c) ? d : null
  28652. };
  28653. cc.MenuPassive.createWithItem = function(a) {
  28654. return cc.MenuPassive.create(a, null)
  28655. };
  28656. cc.ControlSaturationBrightnessPicker = cc.Control.extend({
  28657. _saturation: 0,
  28658. _brightness: 0,
  28659. _background: null,
  28660. _overlay: null,
  28661. _shadow: null,
  28662. _slider: null,
  28663. _startPos: null,
  28664. _boxPos: 0,
  28665. _boxSize: 0,
  28666. _className: "ControlSaturationBrightnessPicker",
  28667. ctor: function(a, c) {
  28668. cc.Control.prototype.ctor.call(this);
  28669. c && this.initWithTargetAndPos(a, c)
  28670. },
  28671. getSaturation: function() {
  28672. return this._saturation
  28673. },
  28674. getBrightness: function() {
  28675. return this._brightness
  28676. },
  28677. getBackground: function() {
  28678. return this._background
  28679. },
  28680. getOverlay: function() {
  28681. return this._brightness
  28682. },
  28683. getShadow: function() {
  28684. return this._shadow
  28685. },
  28686. getSlider: function() {
  28687. return this._slider
  28688. },
  28689. getStartPos: function() {
  28690. return this._startPos
  28691. },
  28692. initWithTargetAndPos: function(a, c) {
  28693. 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
  28694. },
  28695. setEnabled: function(a) {
  28696. cc.Control.prototype.setEnabled.call(this, a);
  28697. this._slider && this._slider.setOpacity(a ? 255 : 128)
  28698. },
  28699. updateWithHSV: function(a) {
  28700. var c = new cc.HSV;
  28701. c.s = 1;
  28702. c.h = a.h;
  28703. c.v = 1;
  28704. a = cc.ControlUtils.RGBfromHSV(c);
  28705. this._background.setColor(cc.color(0 | 255 * a.r, 0 | 255 * a.g, 0 | 255 * a.b))
  28706. },
  28707. updateDraggerWithHSV: function(a) {
  28708. a = cc.p(this._startPos.x + this._boxPos + this._boxSize * (1 - a.s), this._startPos.y + this._boxPos + this._boxSize * a.v);
  28709. this._updateSliderPosition(a)
  28710. },
  28711. _updateSliderPosition: function(a) {
  28712. var c = this._startPos.x + 0.5 * this._background.getBoundingBox().width,
  28713. d = this._startPos.y + 0.5 * this._background.getBoundingBox().height,
  28714. e = a.x - c,
  28715. f = a.y - d,
  28716. g = Math.sqrt(e * e + f * f),
  28717. e = Math.atan2(f, e),
  28718. f = 0.5 * this._background.getBoundingBox().width;
  28719. g > f && (a.x = c + f * Math.cos(e), a.y = d + f * Math.sin(e));
  28720. this._slider.setPosition(a);
  28721. 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);
  28722. 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);
  28723. this._saturation = 1 - Math.abs((this._startPos.x + this._boxPos - a.x) / this._boxSize);
  28724. this._brightness = Math.abs((this._startPos.y + this._boxPos - a.y) / this._boxSize)
  28725. },
  28726. _checkSliderPosition: function(a) {
  28727. var c = this._startPos.x + 0.5 * this._background.getBoundingBox().width,
  28728. d = this._startPos.y + 0.5 * this._background.getBoundingBox().height,
  28729. c = a.x - c,
  28730. d = a.y - d;
  28731. return Math.sqrt(c * c + d * d) <= 0.5 * this._background.getBoundingBox().width ? (this._updateSliderPosition(a), this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED), !0) : !1
  28732. },
  28733. onTouchBegan: function(a, c) {
  28734. if (!this.isEnabled() || !this.isVisible()) return !1;
  28735. var d = this.getTouchLocation(a);
  28736. return this._checkSliderPosition(d)
  28737. },
  28738. onTouchMoved: function(a, c) {
  28739. var d = this.getTouchLocation(a);
  28740. this._checkSliderPosition(d)
  28741. }
  28742. });
  28743. _p = cc.ControlSaturationBrightnessPicker.prototype;
  28744. cc.defineGetterSetter(_p, "saturation", _p.getSaturation);
  28745. cc.defineGetterSetter(_p, "brightness", _p.getBrightness);
  28746. cc.defineGetterSetter(_p, "background", _p.getBackground);
  28747. cc.defineGetterSetter(_p, "overlay", _p.getOverlay);
  28748. cc.defineGetterSetter(_p, "shadow", _p.getShadow);
  28749. cc.defineGetterSetter(_p, "slider", _p.getSlider);
  28750. cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
  28751. _p = null;
  28752. cc.ControlSaturationBrightnessPicker.create = function(a, c) {
  28753. return new cc.ControlSaturationBrightnessPicker(a, c)
  28754. };
  28755. cc.ControlHuePicker = cc.Control.extend({
  28756. _hue: 0,
  28757. _huePercentage: 0,
  28758. _background: null,
  28759. _slider: null,
  28760. _startPos: null,
  28761. _className: "ControlHuePicker",
  28762. ctor: function(a, c) {
  28763. cc.Control.prototype.ctor.call(this);
  28764. c && this.initWithTargetAndPos(a, c)
  28765. },
  28766. getHue: function() {
  28767. return this._hue
  28768. },
  28769. setHue: function(a) {
  28770. this._hue = a;
  28771. this.setHuePercentage(this._hue / 360)
  28772. },
  28773. getHuePercentage: function() {
  28774. return this._huePercentage
  28775. },
  28776. setHuePercentage: function(a) {
  28777. this._huePercentage = a;
  28778. this._hue = 360 * this._huePercentage;
  28779. var c = this._background.getBoundingBox(),
  28780. d = this._startPos.x + 0.5 * c.width;
  28781. a = this._startPos.y + 0.5 * c.height;
  28782. var c = 0.5 * c.width - 15,
  28783. e = cc.degreesToRadians(360 * this._huePercentage - 180),
  28784. d = d + c * Math.cos(e);
  28785. a += c * Math.sin(e);
  28786. this._slider.setPosition(d, a)
  28787. },
  28788. setEnabled: function(a) {
  28789. cc.Control.prototype.setEnabled.call(this, a);
  28790. this._slider && this._slider.setOpacity(a ? 255 : 128)
  28791. },
  28792. getBackground: function() {
  28793. return this._background
  28794. },
  28795. getSlider: function() {
  28796. return this._slider
  28797. },
  28798. getStartPos: function() {
  28799. return this._startPos
  28800. },
  28801. initWithTargetAndPos: function(a, c) {
  28802. 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
  28803. },
  28804. _updateSliderPosition: function(a) {
  28805. var c = this._background.getBoundingBox();
  28806. a = Math.atan2(a.y - (this._startPos.y + 0.5 * c.height), a.x - (this._startPos.x + 0.5 * c.width));
  28807. a = cc.radiansToDegrees(a) + 180;
  28808. this.setHue(a);
  28809. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  28810. },
  28811. _checkSliderPosition: function(a) {
  28812. var c = Math.sqrt(Math.pow(a.x + 10, 2) + Math.pow(a.y, 2));
  28813. return 80 > c && 59 < c ? (this._updateSliderPosition(a), !0) : !1
  28814. },
  28815. onTouchBegan: function(a, c) {
  28816. if (!this.isEnabled() || !this.isVisible()) return !1;
  28817. var d = this.getTouchLocation(a);
  28818. return this._checkSliderPosition(d)
  28819. },
  28820. onTouchMoved: function(a, c) {
  28821. var d = this.getTouchLocation(a);
  28822. this._checkSliderPosition(d)
  28823. }
  28824. });
  28825. _p = cc.ControlHuePicker.prototype;
  28826. cc.defineGetterSetter(_p, "hue", _p.getHue, _p.setHue);
  28827. cc.defineGetterSetter(_p, "huePercent", _p.getHuePercentage, _p.setHuePercentage);
  28828. cc.defineGetterSetter(_p, "background", _p.getBackground);
  28829. cc.defineGetterSetter(_p, "slider", _p.getSlider);
  28830. cc.defineGetterSetter(_p, "startPos", _p.getStartPos);
  28831. _p = null;
  28832. cc.ControlHuePicker.create = function(a, c) {
  28833. return new cc.ControlHuePicker(a, c)
  28834. };
  28835. cc.ControlColourPicker = cc.Control.extend({
  28836. _hsv: null,
  28837. _colourPicker: null,
  28838. _huePicker: null,
  28839. _background: null,
  28840. _className: "ControlColourPicker",
  28841. ctor: function() {
  28842. cc.Control.prototype.ctor.call(this);
  28843. this.init()
  28844. },
  28845. hueSliderValueChanged: function(a, c) {
  28846. this._hsv.h = a.getHue();
  28847. var d = cc.ControlUtils.RGBfromHSV(this._hsv);
  28848. cc.Control.prototype.setColor.call(this, cc.color(0 | 255 * d.r, 0 | 255 * d.g, 0 | 255 * d.b));
  28849. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED);
  28850. this._updateControlPicker()
  28851. },
  28852. colourSliderValueChanged: function(a, c) {
  28853. this._hsv.s = a.getSaturation();
  28854. this._hsv.v = a.getBrightness();
  28855. var d = cc.ControlUtils.RGBfromHSV(this._hsv);
  28856. cc.Control.prototype.setColor.call(this, cc.color(0 | 255 * d.r, 0 | 255 * d.g, 0 | 255 * d.b));
  28857. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  28858. },
  28859. setColor: function(a) {
  28860. cc.Control.prototype.setColor.call(this, a);
  28861. var c = new cc.RGBA;
  28862. c.r = a.r / 255;
  28863. c.g = a.g / 255;
  28864. c.b = a.b / 255;
  28865. c.a = 1;
  28866. this._hsv = cc.ControlUtils.HSVfromRGB(c);
  28867. this._updateHueAndControlPicker()
  28868. },
  28869. getBackground: function() {
  28870. return this._background
  28871. },
  28872. init: function() {
  28873. if (cc.Control.prototype.init.call(this)) {
  28874. cc.spriteFrameCache.addSpriteFrames(res.CCControlColourPickerSpriteSheet_plist);
  28875. var a = cc.SpriteBatchNode.create(res.CCControlColourPickerSpriteSheet_png);
  28876. this.addChild(a);
  28877. this._hsv = new cc.HSV(0, 0, 0);
  28878. this._background = cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", a, cc.p(0, 0), cc.p(0.5, 0.5));
  28879. var c = cc.pSub(this._background.getPosition(), cc.p(this._background.getContentSize().width / 2, this._background.getContentSize().height / 2));
  28880. this._huePicker = cc.ControlHuePicker.create(a, cc.p(c.x + 8, c.y + 8));
  28881. this._colourPicker = cc.ControlSaturationBrightnessPicker.create(a, cc.p(c.x + 28, c.y + 28));
  28882. this._huePicker.addTargetWithActionForControlEvents(this, this.hueSliderValueChanged, cc.CONTROL_EVENT_VALUECHANGED);
  28883. this._colourPicker.addTargetWithActionForControlEvents(this, this.colourSliderValueChanged, cc.CONTROL_EVENT_VALUECHANGED);
  28884. this._updateHueAndControlPicker();
  28885. this.addChild(this._huePicker);
  28886. this.addChild(this._colourPicker);
  28887. this.setContentSize(this._background.getContentSize());
  28888. return !0
  28889. }
  28890. return !1
  28891. },
  28892. _updateControlPicker: function() {
  28893. this._huePicker.setHue(this._hsv.h);
  28894. this._colourPicker.updateWithHSV(this._hsv)
  28895. },
  28896. _updateHueAndControlPicker: function() {
  28897. this._huePicker.setHue(this._hsv.h);
  28898. this._colourPicker.updateWithHSV(this._hsv);
  28899. this._colourPicker.updateDraggerWithHSV(this._hsv)
  28900. },
  28901. setEnabled: function(a) {
  28902. cc.Control.prototype.setEnabled.call(this, a);
  28903. null != this._huePicker && this._huePicker.setEnabled(a);
  28904. this._colourPicker && this._colourPicker.setEnabled(a)
  28905. },
  28906. onTouchBegan: function() {
  28907. return !1
  28908. }
  28909. });
  28910. _p = cc.ControlColourPicker.prototype;
  28911. cc.defineGetterSetter(_p, "background", _p.getBackground);
  28912. _p = null;
  28913. cc.ControlColourPicker.create = function() {
  28914. return new cc.ControlColourPicker
  28915. };
  28916. var res = res || {};
  28917. res.CCControlColourPickerSpriteSheet_plist = res.CCControlColourPickerSpriteSheet_plist || "res/extensions/CCControlColourPickerSpriteSheet.plist";
  28918. res.CCControlColourPickerSpriteSheet_png = res.CCControlColourPickerSpriteSheet_png || "res/extensions/CCControlColourPickerSpriteSheet.png";
  28919. cc.SLIDER_MARGIN_H = 24;
  28920. cc.SLIDER_MARGIN_V = 8;
  28921. cc.ControlSlider = cc.Control.extend({
  28922. _value: 0,
  28923. _minimumValue: 0,
  28924. _maximumValue: 0,
  28925. _minimumAllowedValue: 0,
  28926. _maximumAllowedValue: 0,
  28927. _thumbSprite: null,
  28928. _progressSprite: null,
  28929. _backgroundSprite: null,
  28930. _className: "ControlSlider",
  28931. ctor: function(a, c, d) {
  28932. cc.Control.prototype.ctor.call(this);
  28933. void 0 != d && (bgSprite = cc.Sprite.create(a), progressSprite = cc.Sprite.create(c), thumbSprite = cc.Sprite.create(d), this.initWithSprites(bgSprite, progressSprite, thumbSprite))
  28934. },
  28935. getValue: function() {
  28936. return this._value
  28937. },
  28938. setValue: function(a) {
  28939. a = Math.max(a, this._minimumValue);
  28940. this._value = a = Math.min(a, this._maximumValue);
  28941. this.needsLayout();
  28942. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  28943. },
  28944. getMinimumValue: function() {
  28945. return this._minimumValue
  28946. },
  28947. setMinimumValue: function(a) {
  28948. this._minimumAllowedValue = this._minimumValue = a;
  28949. this._minimumValue >= this._maximumValue && (this._maximumValue = this._minimumValue + 1);
  28950. this.setValue(this._value)
  28951. },
  28952. getMaximumValue: function() {
  28953. return this._maximumValue
  28954. },
  28955. setMaximumValue: function(a) {
  28956. this._maximumAllowedValue = this._maximumValue = a;
  28957. this._maximumValue <= this._minimumValue && (this._minimumValue = this._maximumValue - 1);
  28958. this.setValue(this._value)
  28959. },
  28960. isTouchInside: function(a) {
  28961. a = a.getLocation();
  28962. a = this.getParent().convertToNodeSpace(a);
  28963. var c = this.getBoundingBox();
  28964. c.width += this._thumbSprite.getContentSize().width;
  28965. c.x -= this._thumbSprite.getContentSize().width / 2;
  28966. return cc.rectContainsPoint(c, a)
  28967. },
  28968. locationFromTouch: function(a) {
  28969. a = a.getLocation();
  28970. a = this.convertToNodeSpace(a);
  28971. 0 > a.x ? a.x = 0 : a.x > this._backgroundSprite.getContentSize().width && (a.x = this._backgroundSprite.getContentSize().width);
  28972. return a
  28973. },
  28974. getMinimumAllowedValue: function() {
  28975. return this._minimumAllowedValue
  28976. },
  28977. setMinimumAllowedValue: function(a) {
  28978. this._minimumAllowedValue = a
  28979. },
  28980. getMaximumAllowedValue: function() {
  28981. return this._maximumAllowedValue
  28982. },
  28983. setMaximumAllowedValue: function(a) {
  28984. this._maximumAllowedValue = a
  28985. },
  28986. getThumbSprite: function() {
  28987. return this._thumbSprite
  28988. },
  28989. getProgressSprite: function() {
  28990. return this._progressSprite
  28991. },
  28992. getBackgroundSprite: function() {
  28993. return this._backgroundSprite
  28994. },
  28995. initWithSprites: function(a, c, d) {
  28996. 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
  28997. },
  28998. setEnabled: function(a) {
  28999. cc.Control.prototype.setEnabled.call(this, a);
  29000. this._thumbSprite && this._thumbSprite.setOpacity(a ? 255 : 128)
  29001. },
  29002. sliderBegan: function(a) {
  29003. this.setSelected(!0);
  29004. this.getThumbSprite().setColor(cc.color.GRAY);
  29005. this.setValue(this.valueForLocation(a))
  29006. },
  29007. sliderMoved: function(a) {
  29008. this.setValue(this.valueForLocation(a))
  29009. },
  29010. sliderEnded: function(a) {
  29011. this.isSelected() && this.setValue(this.valueForLocation(this._thumbSprite.getPosition()));
  29012. this._thumbSprite.setColor(cc.color.WHITE);
  29013. this.setSelected(!1)
  29014. },
  29015. getTouchLocationInControl: function(a) {
  29016. a = a.getLocation();
  29017. a = this.convertToNodeSpace(a);
  29018. 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);
  29019. return a
  29020. },
  29021. onTouchBegan: function(a, c) {
  29022. if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
  29023. var d = this.locationFromTouch(a);
  29024. this.sliderBegan(d);
  29025. return !0
  29026. },
  29027. onTouchMoved: function(a, c) {
  29028. var d = this.locationFromTouch(a);
  29029. this.sliderMoved(d)
  29030. },
  29031. onTouchEnded: function(a, c) {
  29032. this.sliderEnded(cc.p(0, 0))
  29033. },
  29034. needsLayout: function() {
  29035. this._thumbSprite.setPositionX((this._value - this._minimumValue) / (this._maximumValue - this._minimumValue) * this._backgroundSprite.getContentSize().width);
  29036. var a = this._progressSprite.getTextureRect(),
  29037. a = cc.rect(a.x, a.y, this._thumbSprite.getPositionX(), a.height);
  29038. this._progressSprite.setTextureRect(a, this._progressSprite.isTextureRectRotated())
  29039. },
  29040. valueForLocation: function(a) {
  29041. a = a.x / this._backgroundSprite.getContentSize().width;
  29042. return Math.max(Math.min(this._minimumValue + a * (this._maximumValue - this._minimumValue), this._maximumAllowedValue), this._minimumAllowedValue)
  29043. }
  29044. });
  29045. _p = cc.ControlSlider.prototype;
  29046. cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
  29047. cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
  29048. cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
  29049. cc.defineGetterSetter(_p, "minAllowedValue", _p.getMinimumAllowedValue, _p.setMinimumAllowedValue);
  29050. cc.defineGetterSetter(_p, "maxAllowedValue", _p.getMaximumAllowedValue, _p.setMaximumAllowedValue);
  29051. cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite);
  29052. cc.defineGetterSetter(_p, "progressSprite", _p.getProgressSprite);
  29053. cc.defineGetterSetter(_p, "backgroundSprite", _p.getBackgroundSprite);
  29054. _p = null;
  29055. cc.ControlSlider.create = function(a, c, d) {
  29056. return new cc.ControlSlider(a, c, d)
  29057. };
  29058. cc.ControlSwitch = cc.Control.extend({
  29059. _switchSprite: null,
  29060. _initialTouchXPosition: 0,
  29061. _moved: !1,
  29062. _on: !1,
  29063. _className: "ControlSwitch",
  29064. ctor: function(a, c, d, e, f, g) {
  29065. cc.Control.prototype.ctor.call(this);
  29066. g && this.initWithMaskSprite(a, c, d, e, f, g)
  29067. },
  29068. initWithMaskSprite: function(a, c, d, e, f, g) {
  29069. if (!a) throw "cc.ControlSwitch.initWithMaskSprite(): maskSprite should be non-null.";
  29070. if (!c) throw "cc.ControlSwitch.initWithMaskSprite(): onSprite should be non-null.";
  29071. if (!d) throw "cc.ControlSwitch.initWithMaskSprite(): offSprite should be non-null.";
  29072. if (!e) throw "cc.ControlSwitch.initWithMaskSprite(): thumbSprite should be non-null.";
  29073. 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
  29074. },
  29075. setOn: function(a, c) {
  29076. c = c || !1;
  29077. var d = (this._on = a) ? this._switchSprite.getOnPosition() : this._switchSprite.getOffPosition();
  29078. c ? this._switchSprite.runAction(cc.ActionTween.create(0.2, "sliderXPosition", this._switchSprite.getSliderXPosition(), d)) : this._switchSprite.setSliderXPosition(d);
  29079. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  29080. },
  29081. isOn: function() {
  29082. return this._on
  29083. },
  29084. hasMoved: function() {
  29085. return this._moved
  29086. },
  29087. setEnabled: function(a) {
  29088. this._enabled = a;
  29089. this._switchSprite.setOpacity(a ? 255 : 128)
  29090. },
  29091. locationFromTouch: function(a) {
  29092. a = a.getLocation();
  29093. return a = this.convertToNodeSpace(a)
  29094. },
  29095. onTouchBegan: function(a, c) {
  29096. if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
  29097. this._moved = !1;
  29098. this._initialTouchXPosition = this.locationFromTouch(a).x - this._switchSprite.getSliderXPosition();
  29099. this._switchSprite.getThumbSprite().setColor(cc.color.GRAY);
  29100. this._switchSprite.needsLayout();
  29101. return !0
  29102. },
  29103. onTouchMoved: function(a, c) {
  29104. var d = this.locationFromTouch(a),
  29105. d = cc.p(d.x - this._initialTouchXPosition, 0);
  29106. this._moved = !0;
  29107. this._switchSprite.setSliderXPosition(d.x)
  29108. },
  29109. onTouchEnded: function(a, c) {
  29110. var d = this.locationFromTouch(a);
  29111. this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);
  29112. this.hasMoved() ? this.setOn(!(d.x < this._switchSprite.getContentSize().width / 2), !0) : this.setOn(!this._on, !0)
  29113. },
  29114. onTouchCancelled: function(a, c) {
  29115. var d = this.locationFromTouch(a);
  29116. this._switchSprite.getThumbSprite().setColor(cc.color.WHITE);
  29117. this.hasMoved() ? this.setOn(!(d.x < this._switchSprite.getContentSize().width / 2), !0) : this.setOn(!this._on, !0)
  29118. }
  29119. });
  29120. cc.ControlSwitch.create = function(a, c, d, e, f, g) {
  29121. return new cc.ControlSwitch(a, c, d, e, f, g)
  29122. };
  29123. cc.ControlSwitchSprite = cc.Sprite.extend({
  29124. _sliderXPosition: 0,
  29125. _onPosition: 0,
  29126. _offPosition: 0,
  29127. _textureLocation: 0,
  29128. _maskLocation: 0,
  29129. _maskSize: null,
  29130. _onSprite: null,
  29131. _offSprite: null,
  29132. _thumbSprite: null,
  29133. _onLabel: null,
  29134. _offLabel: null,
  29135. _clipper: null,
  29136. _stencil: null,
  29137. _backRT: null,
  29138. ctor: function() {
  29139. cc.Sprite.prototype.ctor.call(this);
  29140. this._maskLocation = this._offPosition = this._onPosition = this._sliderXPosition = 0;
  29141. this._maskSize = cc.size(0, 0);
  29142. this._offLabel = this._onLabel = this._thumbSprite = this._offSprite = this._onSprite = null
  29143. },
  29144. initWithMaskSprite: function(a, c, d, e, f, g) {
  29145. 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
  29146. },
  29147. needsLayout: function() {
  29148. var a = this._maskSize;
  29149. this._onSprite.setPosition(this._onSprite.getContentSize().width / 2 + this._sliderXPosition - a.width / 2, this._onSprite.getContentSize().height / 2 - a.height / 2);
  29150. 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);
  29151. this._onLabel && this._onLabel.setPosition(this._onSprite.getPositionX() - this._thumbSprite.getContentSize().width / 6, this._onSprite.getContentSize().height / 2 - a.height / 2);
  29152. this._offLabel && this._offLabel.setPosition(this._offSprite.getPositionX() + this._thumbSprite.getContentSize().width / 6, this._offSprite.getContentSize().height / 2 - a.height / 2);
  29153. this._thumbSprite.setPosition(this._onSprite.getContentSize().width + this._sliderXPosition, this._maskSize.height / 2)
  29154. },
  29155. setSliderXPosition: function(a) {
  29156. a <= this._offPosition ? a = this._offPosition : a >= this._onPosition && (a = this._onPosition);
  29157. this._sliderXPosition = a;
  29158. this.needsLayout()
  29159. },
  29160. getSliderXPosition: function() {
  29161. return this._sliderXPosition
  29162. },
  29163. _getOnSideWidth: function() {
  29164. return this._onSprite.getContentSize().width
  29165. },
  29166. _getOffSideWidth: function() {
  29167. return this._offSprite.getContentSize().height
  29168. },
  29169. updateTweenAction: function(a, c) {
  29170. cc.log("key \x3d " + c + ", value \x3d " + a);
  29171. this.setSliderXPosition(a)
  29172. },
  29173. setOnPosition: function(a) {
  29174. this._onPosition = a
  29175. },
  29176. getOnPosition: function() {
  29177. return this._onPosition
  29178. },
  29179. setOffPosition: function(a) {
  29180. this._offPosition = a
  29181. },
  29182. getOffPosition: function() {
  29183. return this._offPosition
  29184. },
  29185. setMaskTexture: function(a) {
  29186. this._stencil.setTexture(a)
  29187. },
  29188. getMaskTexture: function() {
  29189. return this._stencil.getTexture()
  29190. },
  29191. setTextureLocation: function(a) {
  29192. this._textureLocation = a
  29193. },
  29194. getTextureLocation: function() {
  29195. return this._textureLocation
  29196. },
  29197. setMaskLocation: function(a) {
  29198. this._maskLocation = a
  29199. },
  29200. getMaskLocation: function() {
  29201. return this._maskLocation
  29202. },
  29203. setOnSprite: function(a) {
  29204. this._onSprite = a
  29205. },
  29206. getOnSprite: function() {
  29207. return this._onSprite
  29208. },
  29209. setOffSprite: function(a) {
  29210. this._offSprite = a
  29211. },
  29212. getOffSprite: function() {
  29213. return this._offSprite
  29214. },
  29215. setThumbSprite: function(a) {
  29216. this._thumbSprite = a
  29217. },
  29218. getThumbSprite: function() {
  29219. return this._thumbSprite
  29220. },
  29221. setOnLabel: function(a) {
  29222. this._onLabel = a
  29223. },
  29224. getOnLabel: function() {
  29225. return this._onLabel
  29226. },
  29227. setOffLabel: function(a) {
  29228. this._offLabel = a
  29229. },
  29230. getOffLabel: function() {
  29231. return this._offLabel
  29232. }
  29233. });
  29234. _p = cc.ControlSwitchSprite.prototype;
  29235. cc.defineGetterSetter(_p, "sliderX", _p.getSliderXPosition, _p.setSliderXPosition);
  29236. cc.defineGetterSetter(_p, "onPos", _p.getOnPosition, _p.setOnPosition);
  29237. cc.defineGetterSetter(_p, "offPos", _p.getOffPosition, _p.setOffPosition);
  29238. cc.defineGetterSetter(_p, "maskTexture", _p.getMaskTexture, _p.setMaskTexture);
  29239. cc.defineGetterSetter(_p, "maskPos", _p.getMaskLocation, _p.setMaskLocation);
  29240. cc.defineGetterSetter(_p, "onSprite", _p.getOnSprite, _p.setOnSprite);
  29241. cc.defineGetterSetter(_p, "offSprite", _p.getOffSprite, _p.setOffSprite);
  29242. cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite, _p.setThumbSprite);
  29243. cc.defineGetterSetter(_p, "onLabel", _p.getOnLabel, _p.setOnLabel);
  29244. cc.defineGetterSetter(_p, "offLabel", _p.getOffLabel, _p.setOffLabel);
  29245. cc.defineGetterSetter(_p, "onSideWidth", _p._getOnSideWidth);
  29246. cc.defineGetterSetter(_p, "offSideWidth", _p._getOffSideWidth);
  29247. _p = null;
  29248. cc.CONTROL_STEPPER_PARTMINUS = 0;
  29249. cc.CONTROL_STEPPER_PARTPLUS = 1;
  29250. cc.CONTROL_STEPPER_PARTNONE = 2;
  29251. cc.CONTROL_STEPPER_LABELCOLOR_ENABLED = cc.color(55, 55, 55);
  29252. cc.CONTROL_STEPPER_LABELCOLOR_DISABLED = cc.color(147, 147, 147);
  29253. cc.CONTROL_STEPPER_LABELFONT = "CourierNewPSMT";
  29254. cc.AUTOREPEAT_DELTATIME = 0.15;
  29255. cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12;
  29256. cc.ControlStepper = cc.Control.extend({
  29257. _minusSprite: null,
  29258. _plusSprite: null,
  29259. _minusLabel: null,
  29260. _plusLabel: null,
  29261. _value: 0,
  29262. _continuous: !1,
  29263. _autorepeat: !1,
  29264. _wraps: !1,
  29265. _minimumValue: 0,
  29266. _maximumValue: 0,
  29267. _stepValue: 0,
  29268. _touchInsideFlag: !1,
  29269. _touchedPart: cc.CONTROL_STEPPER_PARTNONE,
  29270. _autorepeatCount: 0,
  29271. _className: "ControlStepper",
  29272. ctor: function(a, c) {
  29273. cc.Control.prototype.ctor.call(this);
  29274. this._plusLabel = this._minusLabel = this._plusSprite = this._minusSprite = null;
  29275. this._value = 0;
  29276. this._wraps = this._autorepeat = this._continuous = !1;
  29277. this._stepValue = this._maximumValue = this._minimumValue = 0;
  29278. this._touchInsideFlag = !1;
  29279. this._touchedPart = cc.CONTROL_STEPPER_PARTNONE;
  29280. this._autorepeatCount = 0;
  29281. c && this.initWithMinusSpriteAndPlusSprite(a, c)
  29282. },
  29283. initWithMinusSpriteAndPlusSprite: function(a, c) {
  29284. if (!a) throw "cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Minus sprite should be non-null.";
  29285. if (!c) throw "cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Plus sprite should be non-null.";
  29286. if (this.init()) {
  29287. this._continuous = this._autorepeat = !0;
  29288. this._minimumValue = 0;
  29289. this._maximumValue = 100;
  29290. this._value = 0;
  29291. this._stepValue = 1;
  29292. this._wraps = !1;
  29293. this.ignoreAnchorPointForPosition(!1);
  29294. this.setMinusSprite(a);
  29295. this._minusSprite.setPosition(a.getContentSize().width / 2, a.getContentSize().height / 2);
  29296. this.addChild(this._minusSprite);
  29297. this.setMinusLabel(cc.LabelTTF.create("-", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER));
  29298. this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_DISABLED);
  29299. this._minusLabel.setPosition(this._minusSprite.getContentSize().width / 2, this._minusSprite.getContentSize().height / 2);
  29300. this._minusSprite.addChild(this._minusLabel);
  29301. this.setPlusSprite(c);
  29302. this._plusSprite.setPosition(a.getContentSize().width + c.getContentSize().width / 2, a.getContentSize().height / 2);
  29303. this.addChild(this._plusSprite);
  29304. this.setPlusLabel(cc.LabelTTF.create("+", cc.CONTROL_STEPPER_LABELFONT, 40, cc.size(40, 40), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_CENTER));
  29305. this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED);
  29306. this._plusLabel.setPosition(this._plusSprite.getContentSize().width / 2, this._plusSprite.getContentSize().height / 2);
  29307. this._plusSprite.addChild(this._plusLabel);
  29308. var d = cc.ControlUtils.CCRectUnion(this._minusSprite.getBoundingBox(), this._plusSprite.getBoundingBox());
  29309. this.setContentSize(this._minusSprite.getContentSize().width + this._plusSprite.getContentSize().height, d.height);
  29310. return !0
  29311. }
  29312. return !1
  29313. },
  29314. setWraps: function(a) {
  29315. if (this._wraps = a) this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED), this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED);
  29316. this.setValue(this._value)
  29317. },
  29318. getWraps: function() {
  29319. return this._wraps
  29320. },
  29321. setMinimumValue: function(a) {
  29322. if (a >= this._maximumValue) throw "cc.ControlStepper.setMinimumValue(): minimumValue should be numerically less than maximumValue.";
  29323. this._minimumValue = a;
  29324. this.setValue(this._value)
  29325. },
  29326. getMinimumValue: function() {
  29327. return this._minimumValue
  29328. },
  29329. setMaximumValue: function(a) {
  29330. if (a <= this._minimumValue) throw "cc.ControlStepper.setMaximumValue(): maximumValue should be numerically less than maximumValue.";
  29331. this._maximumValue = a;
  29332. this.setValue(this._value)
  29333. },
  29334. getMaximumValue: function() {
  29335. return this._maximumValue
  29336. },
  29337. setValue: function(a) {
  29338. this.setValueWithSendingEvent(a, !0)
  29339. },
  29340. getValue: function() {
  29341. return this._value
  29342. },
  29343. setStepValue: function(a) {
  29344. if (0 >= a) throw "cc.ControlStepper.setMaximumValue(): stepValue should be numerically greater than 0.";
  29345. this._stepValue = a
  29346. },
  29347. getStepValue: function() {
  29348. return this._stepValue
  29349. },
  29350. isContinuous: function() {
  29351. return this._continuous
  29352. },
  29353. setValueWithSendingEvent: function(a, c) {
  29354. a < this._minimumValue ? a = this._wraps ? this._maximumValue : this._minimumValue : a > this._maximumValue && (a = this._wraps ? this._minimumValue : this._maximumValue);
  29355. this._value = a;
  29356. 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));
  29357. c && this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  29358. },
  29359. startAutorepeat: function() {
  29360. this._autorepeatCount = -1;
  29361. this.schedule(this.update, cc.AUTOREPEAT_DELTATIME, cc.REPEAT_FOREVER, 3 * cc.AUTOREPEAT_DELTATIME)
  29362. },
  29363. stopAutorepeat: function() {
  29364. this.unschedule(this.update)
  29365. },
  29366. update: function(a) {
  29367. this._autorepeatCount++;
  29368. 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))
  29369. },
  29370. updateLayoutUsingTouchLocation: function(a) {
  29371. 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))
  29372. },
  29373. onTouchBegan: function(a, c) {
  29374. if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
  29375. var d = this.getTouchLocation(a);
  29376. this.updateLayoutUsingTouchLocation(d);
  29377. this._touchInsideFlag = !0;
  29378. this._autorepeat && this.startAutorepeat();
  29379. return !0
  29380. },
  29381. onTouchMoved: function(a, c) {
  29382. if (this.isTouchInside(a)) {
  29383. var d = this.getTouchLocation(a);
  29384. this.updateLayoutUsingTouchLocation(d);
  29385. this._touchInsideFlag || (this._touchInsideFlag = !0, this._autorepeat && this.startAutorepeat())
  29386. } 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()
  29387. },
  29388. onTouchEnded: function(a, c) {
  29389. this._minusSprite.setColor(cc.color.WHITE);
  29390. this._plusSprite.setColor(cc.color.WHITE);
  29391. this._autorepeat && this.stopAutorepeat();
  29392. if (this.isTouchInside(a)) {
  29393. var d = this.getTouchLocation(a);
  29394. this.setValue(this._value + (d.x < this._minusSprite.getContentSize().width ? 0 - this._stepValue : this._stepValue))
  29395. }
  29396. },
  29397. setMinusSprite: function(a) {
  29398. this._minusSprite = a
  29399. },
  29400. getMinusSprite: function() {
  29401. return this._minusSprite
  29402. },
  29403. setPlusSprite: function(a) {
  29404. this._plusSprite = a
  29405. },
  29406. getPlusSprite: function() {
  29407. return this._plusSprite
  29408. },
  29409. setMinusLabel: function(a) {
  29410. this._minusLabel = a
  29411. },
  29412. getMinusLabel: function() {
  29413. return this._minusLabel
  29414. },
  29415. setPlusLabel: function(a) {
  29416. this._plusLabel = a
  29417. },
  29418. getPlusLabel: function() {
  29419. return this._plusLabel
  29420. }
  29421. });
  29422. _p = cc.ControlStepper.prototype;
  29423. cc.defineGetterSetter(_p, "wraps", _p.getWraps, _p.setWraps);
  29424. cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
  29425. cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
  29426. cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
  29427. cc.defineGetterSetter(_p, "stepValue", _p.getStepValue, _p.setStepValue);
  29428. cc.defineGetterSetter(_p, "continuous", _p.isContinuous);
  29429. cc.defineGetterSetter(_p, "minusSprite", _p.getMinusSprite, _p.setMinusSprite);
  29430. cc.defineGetterSetter(_p, "plusSprite", _p.getPlusSprite, _p.setPlusSprite);
  29431. cc.defineGetterSetter(_p, "minusLabel", _p.getMinusLabel, _p.setMinusLabel);
  29432. cc.defineGetterSetter(_p, "plusLabel", _p.getPlusLabel, _p.setPlusLabel);
  29433. _p = null;
  29434. cc.ControlStepper.create = function(a, c) {
  29435. return new cc.ControlStepper(a, c)
  29436. };
  29437. cc.ControlPotentiometer = cc.Control.extend({
  29438. _thumbSprite: null,
  29439. _progressTimer: null,
  29440. _previousLocation: null,
  29441. _value: 0,
  29442. _minimumValue: 0,
  29443. _maximumValue: 1,
  29444. _className: "ControlPotentiometer",
  29445. ctor: function(a, c, d) {
  29446. cc.Control.prototype.ctor.call(this);
  29447. 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))
  29448. },
  29449. initWithTrackSprite_ProgressTimer_ThumbSprite: function(a, c, d) {
  29450. 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
  29451. },
  29452. setEnabled: function(a) {
  29453. this.setEnabled(a);
  29454. this._thumbSprite != NULL && this._thumbSprite.setOpacity(a ? 255 : 128)
  29455. },
  29456. setValue: function(a) {
  29457. a < this._minimumValue && (a = this._minimumValue);
  29458. a > this._maximumValue && (a = this._maximumValue);
  29459. this._value = a;
  29460. a = (a - this._minimumValue) / (this._maximumValue - this._minimumValue);
  29461. this._progressTimer.setPercentage(100 * a);
  29462. this._thumbSprite.setRotation(360 * a);
  29463. this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)
  29464. },
  29465. getValue: function() {
  29466. return this._value
  29467. },
  29468. setMinimumValue: function(a) {
  29469. this._minimumValue = a;
  29470. this._minimumValue >= this._maximumValue && (this._maximumValue = this._minimumValue + 1);
  29471. this.setValue(this._maximumValue)
  29472. },
  29473. getMinimumValue: function() {
  29474. return this._minimumValue
  29475. },
  29476. setMaximumValue: function(a) {
  29477. this._maximumValue = a;
  29478. this._maximumValue <= this._minimumValue && (this._minimumValue = this._maximumValue - 1);
  29479. this.setValue(this._minimumValue)
  29480. },
  29481. getMaximumValue: function() {
  29482. return this._maximumValue
  29483. },
  29484. isTouchInside: function(a) {
  29485. a = this.getTouchLocation(a);
  29486. return this.distanceBetweenPointAndPoint(this._progressTimer.getPosition(), a) < Math.min(this.getContentSize().width / 2, this.getContentSize().height / 2)
  29487. },
  29488. onTouchBegan: function(a, c) {
  29489. if (!this.isTouchInside(a) || !this.isEnabled() || !this.isVisible()) return !1;
  29490. this._previousLocation = this.getTouchLocation(a);
  29491. this.potentiometerBegan(this._previousLocation);
  29492. return !0
  29493. },
  29494. onTouchMoved: function(a, c) {
  29495. var d = this.getTouchLocation(a);
  29496. this.potentiometerMoved(d)
  29497. },
  29498. onTouchEnded: function(a, c) {
  29499. this.potentiometerEnded(cc.p(0, 0))
  29500. },
  29501. distanceBetweenPointAndPoint: function(a, c) {
  29502. var d = a.x - c.x,
  29503. e = a.y - c.y;
  29504. return Math.sqrt(d * d + e * e)
  29505. },
  29506. angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint: function(a, c, d, e) {
  29507. var f = e.x - d.x;
  29508. d = e.y - d.y;
  29509. a = Math.atan2(c.x - a.x, c.y - a.y);
  29510. f = Math.atan2(f, d);
  29511. return 180 * (a - f) / Math.PI
  29512. },
  29513. potentiometerBegan: function(a) {
  29514. this.setSelected(!0);
  29515. this.getThumbSprite().setColor(cc.color.GRAY)
  29516. },
  29517. potentiometerMoved: function(a) {
  29518. var c = this.angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(this._progressTimer.getPosition(), a, this._progressTimer.getPosition(), this._previousLocation);
  29519. 180 < c ? c -= 360 : -180 > c && (c += 360);
  29520. this.setValue(this._value + c / 360 * (this._maximumValue - this._minimumValue));
  29521. this._previousLocation = a
  29522. },
  29523. potentiometerEnded: function(a) {
  29524. this.getThumbSprite().setColor(cc.color.WHITE);
  29525. this.setSelected(!1)
  29526. },
  29527. setThumbSprite: function(a) {
  29528. this._thumbSprite = a
  29529. },
  29530. getThumbSprite: function() {
  29531. return this._thumbSprite
  29532. },
  29533. setProgressTimer: function(a) {
  29534. this._progressTimer = a
  29535. },
  29536. getProgressTimer: function() {
  29537. return this._progressTimer
  29538. },
  29539. setPreviousLocation: function(a) {
  29540. this._previousLocation = a
  29541. },
  29542. getPreviousLocation: function() {
  29543. return this._previousLocation
  29544. }
  29545. });
  29546. _p = cc.ControlPotentiometer.prototype;
  29547. cc.defineGetterSetter(_p, "value", _p.getValue, _p.setValue);
  29548. cc.defineGetterSetter(_p, "minValue", _p.getMinimumValue, _p.setMinimumValue);
  29549. cc.defineGetterSetter(_p, "maxValue", _p.getMaximumValue, _p.setMaximumValue);
  29550. cc.defineGetterSetter(_p, "progressTimer", _p.getProgressTimer, _p.setProgressTimer);
  29551. cc.defineGetterSetter(_p, "thumbSprite", _p.getThumbSprite, _p.setThumbSprite);
  29552. cc.defineGetterSetter(_p, "prevLocation", _p.getPreviousLocation, _p.setPreviousLocation);
  29553. _p = null;
  29554. cc.ControlPotentiometer.create = function(a, c, d) {
  29555. return new cc.ControlPotentiometer(a, c, d)
  29556. };
  29557. cc.SCROLLVIEW_DIRECTION_NONE = -1;
  29558. cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0;
  29559. cc.SCROLLVIEW_DIRECTION_VERTICAL = 1;
  29560. cc.SCROLLVIEW_DIRECTION_BOTH = 2;
  29561. var SCROLL_DEACCEL_RATE = 0.95,
  29562. SCROLL_DEACCEL_DIST = 1,
  29563. BOUNCE_DURATION = 0.15,
  29564. INSET_RATIO = 0.2,
  29565. MOVE_INCH = 0.04375,
  29566. BOUNCE_BACK_FACTOR = 0.35;
  29567. cc.convertDistanceFromPointToInch = function(a) {
  29568. var c = cc.view,
  29569. c = (c.getScaleX() + c.getScaleY()) / 2;
  29570. return a * c / 160
  29571. };
  29572. cc.ScrollViewDelegate = cc.Class.extend({
  29573. scrollViewDidScroll: function(a) {},
  29574. scrollViewDidZoom: function(a) {}
  29575. });
  29576. cc.ScrollView = cc.Layer.extend({
  29577. _zoomScale: 0,
  29578. _minZoomScale: 0,
  29579. _maxZoomScale: 0,
  29580. _delegate: null,
  29581. _direction: cc.SCROLLVIEW_DIRECTION_BOTH,
  29582. _dragging: !1,
  29583. _contentOffset: null,
  29584. _container: null,
  29585. _touchMoved: !1,
  29586. _maxInset: null,
  29587. _minInset: null,
  29588. _bounceable: !1,
  29589. _clippingToBounds: !1,
  29590. _scrollDistance: null,
  29591. _touchPoint: null,
  29592. _touchLength: 0,
  29593. _touches: null,
  29594. _viewSize: null,
  29595. _minScale: 0,
  29596. _maxScale: 0,
  29597. _parentScissorRect: null,
  29598. _scissorRestored: !1,
  29599. _tmpViewRect: null,
  29600. _touchListener: null,
  29601. _className: "ScrollView",
  29602. ctor: function(a, c) {
  29603. cc.Layer.prototype.ctor.call(this);
  29604. this._contentOffset = cc.p(0, 0);
  29605. this._maxInset = cc.p(0, 0);
  29606. this._minInset = cc.p(0, 0);
  29607. this._scrollDistance = cc.p(0, 0);
  29608. this._touchPoint = cc.p(0, 0);
  29609. this._touches = [];
  29610. this._viewSize = cc.size(0, 0);
  29611. this._parentScissorRect = new cc.Rect(0, 0, 0, 0);
  29612. this._tmpViewRect = new cc.Rect(0, 0, 0, 0);
  29613. void 0 != c ? this.initWithViewSize(a, c) : this.initWithViewSize(cc.size(200, 200), null)
  29614. },
  29615. init: function() {
  29616. return this.initWithViewSize(cc.size(200, 200), null)
  29617. },
  29618. initWithViewSize: function(a, c) {
  29619. var d = cc.p(0, 0);
  29620. 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
  29621. },
  29622. setContentOffset: function(a, c) {
  29623. if (c) this.setContentOffsetInDuration(a, BOUNCE_DURATION);
  29624. else {
  29625. if (!this._bounceable) {
  29626. var d = this.minContainerOffset(),
  29627. e = this.maxContainerOffset();
  29628. a.x = Math.max(d.x, Math.min(e.x, a.x));
  29629. a.y = Math.max(d.y, Math.min(e.y, a.y))
  29630. }
  29631. this._container.setPosition(a);
  29632. d = this._delegate;
  29633. null != d && d.scrollViewDidScroll && d.scrollViewDidScroll(this)
  29634. }
  29635. },
  29636. getContentOffset: function() {
  29637. var a = this._container.getPosition();
  29638. return cc.p(a.x, a.y)
  29639. },
  29640. setContentOffsetInDuration: function(a, c) {
  29641. var d = cc.MoveTo.create(c, a),
  29642. e = cc.CallFunc.create(this._stoppedAnimatedScroll, this);
  29643. this._container.runAction(cc.Sequence.create(d, e));
  29644. this.schedule(this._performedAnimatedScroll)
  29645. },
  29646. setZoomScale: function(a, c) {
  29647. if (c) this.setZoomScaleInDuration(a, BOUNCE_DURATION);
  29648. else {
  29649. var d = this._container;
  29650. if (d.getScale() != a) {
  29651. var e, f;
  29652. 0 == this._touchLength ? (f = this._viewSize, f = cc.p(0.5 * f.width, 0.5 * f.height), f = this.convertToWorldSpace(f)) : f = this._touchPoint;
  29653. e = d.convertToNodeSpace(f);
  29654. d.setScale(Math.max(this._minScale, Math.min(this._maxScale, a)));
  29655. e = d.convertToWorldSpace(e);
  29656. f = cc.pSub(f, e);
  29657. this._delegate && this._delegate.scrollViewDidZoom && this._delegate.scrollViewDidZoom(this);
  29658. this.setContentOffset(cc.pAdd(d.getPosition(), f))
  29659. }
  29660. }
  29661. },
  29662. getZoomScale: function() {
  29663. return this._container.getScale()
  29664. },
  29665. setZoomScaleInDuration: function(a, c) {
  29666. if (0 < c) {
  29667. var d = this._container.getScale();
  29668. d != a && (d = cc.ActionTween.create(c, "zoomScale", d, a), this.runAction(d))
  29669. } else this.setZoomScale(a)
  29670. },
  29671. minContainerOffset: function() {
  29672. var a = this._container,
  29673. c = a.getContentSize(),
  29674. d = this._viewSize;
  29675. return cc.p(d.width - c.width * a.getScaleX(), d.height - c.height * a.getScaleY())
  29676. },
  29677. maxContainerOffset: function() {
  29678. return cc.p(0, 0)
  29679. },
  29680. isNodeVisible: function(a) {
  29681. var c = this.getContentOffset(),
  29682. d = this.getViewSize(),
  29683. e = this.getZoomScale(),
  29684. c = cc.rect(-c.x / e, -c.y / e, d.width / e, d.height / e);
  29685. return cc.rectIntersectsRect(c, a.getBoundingBox())
  29686. },
  29687. pause: function(a) {
  29688. this._container.pause();
  29689. a = this._container.getChildren();
  29690. for (var c = 0; c < a.length; c++) a[c].pause();
  29691. this._super()
  29692. },
  29693. resume: function(a) {
  29694. a = this._container.getChildren();
  29695. for (var c = 0, d = a.length; c < d; c++) a[c].resume();
  29696. this._container.resume();
  29697. this._super()
  29698. },
  29699. isDragging: function() {
  29700. return this._dragging
  29701. },
  29702. isTouchMoved: function() {
  29703. return this._touchMoved
  29704. },
  29705. isBounceable: function() {
  29706. return this._bounceable
  29707. },
  29708. setBounceable: function(a) {
  29709. this._bounceable = a
  29710. },
  29711. getViewSize: function() {
  29712. return this._viewSize
  29713. },
  29714. setViewSize: function(a) {
  29715. this._viewSize = a;
  29716. cc.Node.prototype.setContentSize.call(this, a)
  29717. },
  29718. getContainer: function() {
  29719. return this._container
  29720. },
  29721. setContainer: function(a) {
  29722. a && (this.removeAllChildren(!0), this._container = a, a.ignoreAnchorPointForPosition(!1), a.setAnchorPoint(0, 0), this.addChild(a), this.setViewSize(this._viewSize))
  29723. },
  29724. getDirection: function() {
  29725. return this._direction
  29726. },
  29727. setDirection: function(a) {
  29728. this._direction = a
  29729. },
  29730. getDelegate: function() {
  29731. return this._delegate
  29732. },
  29733. setDelegate: function(a) {
  29734. this._delegate = a
  29735. },
  29736. onTouchBegan: function(a, c) {
  29737. if (!this.isVisible()) return !1;
  29738. var d = this._getViewRect(),
  29739. e = this._container,
  29740. f = e.convertToWorldSpace(e.convertTouchToNodeSpace(a)),
  29741. g = this._touches;
  29742. if (2 < g.length || this._touchMoved || !cc.rectContainsPoint(d, f)) return !1;
  29743. g.push(a);
  29744. 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);
  29745. return !0
  29746. },
  29747. onTouchMoved: function(a, c) {
  29748. if (this.isVisible())
  29749. if (1 === this._touches.length && this._dragging) {
  29750. this._touchMoved = !0;
  29751. this._getViewRect();
  29752. var d = this.convertTouchToNodeSpace(a),
  29753. e = cc.pSub(d, this._touchPoint),
  29754. f = 0,
  29755. g = this._direction,
  29756. h;
  29757. 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);
  29758. 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);
  29759. else {
  29760. f = Math.sqrt(e.x * e.x + e.y * e.y);
  29761. h = this._container.getPositionY();
  29762. var k = this.minContainerOffset(),
  29763. m = this.maxContainerOffset();
  29764. k.y <= h && h <= m.y || (e.y *= BOUNCE_BACK_FACTOR);
  29765. h = this._container.getPositionX();
  29766. k.x <= h && h <= m.x || (e.x *= BOUNCE_BACK_FACTOR)
  29767. } if (this._touchMoved || !(Math.abs(cc.convertDistanceFromPointToInch(f)) < MOVE_INCH))
  29768. if (this._touchMoved || (e.x = 0, e.y = 0), this._touchPoint = d, this._touchMoved = !0, this._dragging) {
  29769. switch (g) {
  29770. case cc.SCROLLVIEW_DIRECTION_VERTICAL:
  29771. e.x = 0;
  29772. break;
  29773. case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
  29774. e.y = 0
  29775. }
  29776. f = this._container.getPosition();
  29777. d = f.x + e.x;
  29778. f = f.y + e.y;
  29779. this._scrollDistance = e;
  29780. this.setContentOffset(cc.p(d, f))
  29781. }
  29782. } 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))
  29783. },
  29784. onTouchEnded: function(a, c) {
  29785. this.isVisible() && (1 == this._touches.length && this._touchMoved && this.schedule(this._deaccelerateScrolling), this._touches.length = 0, this._touchMoved = this._dragging = !1)
  29786. },
  29787. onTouchCancelled: function(a, c) {
  29788. this.isVisible() && (this._touches.length = 0, this._touchMoved = this._dragging = !1)
  29789. },
  29790. setContentSize: function(a, c) {
  29791. null != this.getContainer() && (void 0 === c ? this.getContainer().setContentSize(a) : this.getContainer().setContentSize(a, c), this.updateInset())
  29792. },
  29793. _setWidth: function(a) {
  29794. var c = this.getContainer();
  29795. null != c && (c._setWidth(a), this.updateInset())
  29796. },
  29797. _setHeight: function(a) {
  29798. var c = this.getContainer();
  29799. null != c && (c._setHeight(a), this.updateInset())
  29800. },
  29801. getContentSize: function() {
  29802. return this._container.getContentSize()
  29803. },
  29804. updateInset: function() {
  29805. if (null != this.getContainer()) {
  29806. var a = this._viewSize,
  29807. c = this.maxContainerOffset();
  29808. this._maxInset.x = c.x + a.width * INSET_RATIO;
  29809. this._maxInset.y = c.y + a.height * INSET_RATIO;
  29810. c = this.minContainerOffset();
  29811. this._minInset.x = c.x - a.width * INSET_RATIO;
  29812. this._minInset.y = c.y - a.height * INSET_RATIO
  29813. }
  29814. },
  29815. isClippingToBounds: function() {
  29816. return this._clippingToBounds
  29817. },
  29818. setClippingToBounds: function(a) {
  29819. this._clippingToBounds = a
  29820. },
  29821. visit: function(a) {
  29822. if (this.isVisible()) {
  29823. a = a || cc._renderContext;
  29824. var c, d = this._children,
  29825. e, f;
  29826. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  29827. a.save();
  29828. this.transform(a);
  29829. this._beforeDraw(a);
  29830. if (d && 0 < d.length) {
  29831. f = d.length;
  29832. this.sortAllChildren();
  29833. for (c = 0; c < f; c++)
  29834. if ((e = d[c]) && 0 > e._localZOrder) e.visit(a);
  29835. else break;
  29836. for (this.draw(a); c < f; c++) d[c].visit(a)
  29837. } else this.draw(a);
  29838. this._afterDraw();
  29839. a.restore()
  29840. } else {
  29841. cc.kmGLPushMatrix();
  29842. var g = this.grid;
  29843. g && g.isActive() && (g.beforeDraw(), this.transformAncestors());
  29844. this.transform(a);
  29845. this._beforeDraw(a);
  29846. if (d && 0 < d.length) {
  29847. f = d.length;
  29848. for (c = 0; c < f; c++)
  29849. if ((e = d[c]) && 0 > e._localZOrder) e.visit();
  29850. else break;
  29851. for (this.draw(a); c < f; c++) d[c].visit()
  29852. } else this.draw(a);
  29853. this._afterDraw(a);
  29854. g && g.isActive() && g.afterDraw(this);
  29855. cc.kmGLPopMatrix()
  29856. }
  29857. }
  29858. },
  29859. addChild: function(a, c, d) {
  29860. if (!a) throw Error("child must not nil!");
  29861. c = c || a.getLocalZOrder();
  29862. d = d || a.getTag();
  29863. this._container != a ? this._container.addChild(a, c, d) : cc.Layer.prototype.addChild.call(this, a, c, d)
  29864. },
  29865. isTouchEnabled: function() {
  29866. return null != this._touchListener
  29867. },
  29868. setTouchEnabled: function(a) {
  29869. this._touchListener && cc.eventManager.removeListener(this._touchListener);
  29870. this._touchListener = null;
  29871. a ? (a = cc.EventListener.create({
  29872. event: cc.EventListener.TOUCH_ONE_BY_ONE
  29873. }), 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)
  29874. },
  29875. _initWithViewSize: function(a) {
  29876. return null
  29877. },
  29878. _relocateContainer: function(a) {
  29879. var c = this.minContainerOffset(),
  29880. d = this.maxContainerOffset(),
  29881. e = this._direction,
  29882. f = this._container.getPosition(),
  29883. g = f.x,
  29884. h = f.y;
  29885. if (e === cc.SCROLLVIEW_DIRECTION_BOTH || e === cc.SCROLLVIEW_DIRECTION_HORIZONTAL) g = Math.max(g, c.x), g = Math.min(g, d.x);
  29886. if (e == cc.SCROLLVIEW_DIRECTION_BOTH || e == cc.SCROLLVIEW_DIRECTION_VERTICAL) h = Math.min(h, d.y), h = Math.max(h, c.y);
  29887. (h != f.y || g != f.x) && this.setContentOffset(cc.p(g, h), a)
  29888. },
  29889. _deaccelerateScrolling: function(a) {
  29890. if (this._dragging) this.unschedule(this._deaccelerateScrolling);
  29891. else {
  29892. var c, d;
  29893. c = this._container.getPosition();
  29894. a = this._scrollDistance;
  29895. this._container.setPosition(c.x + a.x, c.y + a.y);
  29896. this._bounceable ? (c = this._maxInset, d = this._minInset) : (c = this.maxContainerOffset(), d = this.minContainerOffset());
  29897. var e = this._container.getPositionX(),
  29898. f = this._container.getPositionY();
  29899. a.x *= SCROLL_DEACCEL_RATE;
  29900. a.y *= SCROLL_DEACCEL_RATE;
  29901. this.setContentOffset(cc.p(e, f));
  29902. 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)
  29903. }
  29904. },
  29905. _performedAnimatedScroll: function(a) {
  29906. this._dragging ? this.unschedule(this._performedAnimatedScroll) : this._delegate && this._delegate.scrollViewDidScroll && this._delegate.scrollViewDidScroll(this)
  29907. },
  29908. _stoppedAnimatedScroll: function(a) {
  29909. this.unschedule(this._performedAnimatedScroll);
  29910. this._delegate && this._delegate.scrollViewDidScroll && this._delegate.scrollViewDidScroll(this)
  29911. },
  29912. _beforeDraw: function(a) {
  29913. if (this._clippingToBounds) {
  29914. this._scissorRestored = !1;
  29915. var c = this._getViewRect(),
  29916. d = cc.view,
  29917. e = this.getScaleX(),
  29918. f = this.getScaleY();
  29919. a = a || cc._renderContext;
  29920. 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();
  29921. else if (d = cc.view, d.isScissorEnabled()) {
  29922. if (this._scissorRestored = !0, this._parentScissorRect = d.getScissorRect(), cc.rectIntersection(c, this._parentScissorRect)) {
  29923. var g = this._parentScissorRect;
  29924. a = Math.max(c.x, g.x);
  29925. f = Math.max(c.y, g.y);
  29926. e = Math.min(c.x + c.width, g.x + g.width);
  29927. c = Math.min(c.y + c.height, g.y + g.height);
  29928. d.setScissorInPoints(a, f, e - a, c - f)
  29929. }
  29930. } else a.enable(a.SCISSOR_TEST), d.setScissorInPoints(c.x, c.y, c.width, c.height)
  29931. }
  29932. },
  29933. _afterDraw: function(a) {
  29934. 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)))
  29935. },
  29936. _handleZoom: function() {},
  29937. _getViewRect: function() {
  29938. 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();
  29939. 0 > d && (a.x += c.width * d, d = -d);
  29940. 0 > e && (a.y += c.height * e, e = -e);
  29941. f = this._tmpViewRect;
  29942. f.x = a.x;
  29943. f.y = a.y;
  29944. f.width = c.width * d;
  29945. f.height = c.height * e;
  29946. return f
  29947. }
  29948. });
  29949. _p = cc.ScrollView.prototype;
  29950. cc.defineGetterSetter(_p, "minOffset", _p.minContainerOffset);
  29951. cc.defineGetterSetter(_p, "maxOffset", _p.maxContainerOffset);
  29952. cc.defineGetterSetter(_p, "bounceable", _p.isBounceable, _p.setBounceable);
  29953. cc.defineGetterSetter(_p, "viewSize", _p.getViewSize, _p.setViewSize);
  29954. cc.defineGetterSetter(_p, "container", _p.getContainer, _p.setContainer);
  29955. cc.defineGetterSetter(_p, "direction", _p.getDirection, _p.setDirection);
  29956. cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
  29957. cc.defineGetterSetter(_p, "clippingToBounds", _p.isClippingToBounds, _p.setClippingToBounds);
  29958. _p = null;
  29959. cc.ScrollView.create = function(a, c) {
  29960. return new cc.ScrollView(a, c)
  29961. };
  29962. cc.SortableObject = cc.Class.extend({
  29963. setObjectID: function(a) {},
  29964. getObjectID: function() {
  29965. return 0
  29966. }
  29967. });
  29968. cc.SortedObject = cc.SortableObject.extend({
  29969. _objectID: 0,
  29970. ctor: function() {
  29971. this._objectID = 0
  29972. },
  29973. setObjectID: function(a) {
  29974. this._objectID = a
  29975. },
  29976. getObjectID: function() {
  29977. return this._objectID
  29978. }
  29979. });
  29980. var _compareObject = function(a, c) {
  29981. return a.getObjectID() - c.getObjectID()
  29982. };
  29983. cc.ArrayForObjectSorting = cc.Class.extend({
  29984. _saveObjectArr: null,
  29985. ctor: function() {
  29986. this._saveObjectArr = []
  29987. },
  29988. insertSortedObject: function(a) {
  29989. if (!a) throw "cc.ArrayForObjectSorting.insertSortedObject(): addObject should be non-null.";
  29990. var c = this.indexOfSortedObject(a);
  29991. this.insertObject(a, c)
  29992. },
  29993. removeSortedObject: function(a) {
  29994. if (0 != this.count()) {
  29995. var c = this.indexOfSortedObject(a);
  29996. c < this.count() && c != cc.INVALID_INDEX && this.objectAtIndex(c).getObjectID() == a.getObjectID() && this.removeObjectAtIndex(c)
  29997. }
  29998. },
  29999. setObjectID_ofSortedObject: function(a, c) {
  30000. var d = this.indexOfSortedObject(c);
  30001. if (d < this.count() && d != cc.INVALID_INDEX) {
  30002. var e = this.objectAtIndex(d);
  30003. e.getObjectID() == c.getObjectID() && (this.removeObjectAtIndex(d), e.setObjectID(a), this.insertSortedObject(e))
  30004. }
  30005. },
  30006. objectWithObjectID: function(a) {
  30007. if (0 == this.count()) return null;
  30008. var c = new cc.SortedObject;
  30009. c.setObjectID(a);
  30010. var d = this.indexOfSortedObject(c);
  30011. d < this.count() && d != cc.INVALID_INDEX && (c = this.objectAtIndex(d), c.getObjectID() != a && (c = null));
  30012. return c
  30013. },
  30014. getObjectWithObjectID: function(a) {
  30015. return null
  30016. },
  30017. indexOfSortedObject: function(a) {
  30018. var c = 0;
  30019. if (a) {
  30020. var d = 0;
  30021. a = a.getObjectID();
  30022. for (var e = this._saveObjectArr, f = 0; f < e.length; f++) {
  30023. var g = e[f].getObjectID();
  30024. if (a == g || a >= d && a < g) break;
  30025. d = g;
  30026. c++
  30027. }
  30028. } else c = cc.INVALID_INDEX;
  30029. return c
  30030. },
  30031. count: function() {
  30032. return this._saveObjectArr.length
  30033. },
  30034. lastObject: function() {
  30035. var a = this._saveObjectArr;
  30036. return 0 == a.length ? null : a[a.length - 1]
  30037. },
  30038. objectAtIndex: function(a) {
  30039. return this._saveObjectArr[a]
  30040. },
  30041. addObject: function(a) {
  30042. this._saveObjectArr.push(a);
  30043. this._saveObjectArr.sort(_compareObject)
  30044. },
  30045. removeObjectAtIndex: function(a) {
  30046. this._saveObjectArr.splice(a, 1);
  30047. this._saveObjectArr.sort(_compareObject)
  30048. },
  30049. insertObject: function(a, c) {
  30050. this._saveObjectArr.splice(c, 0, a);
  30051. this._saveObjectArr.sort(_compareObject)
  30052. }
  30053. });
  30054. cc.TABLEVIEW_FILL_TOPDOWN = 0;
  30055. cc.TABLEVIEW_FILL_BOTTOMUP = 1;
  30056. cc.TableViewCell = cc.Node.extend({
  30057. _idx: 0,
  30058. _className: "TableViewCell",
  30059. getIdx: function() {
  30060. return this._idx
  30061. },
  30062. setIdx: function(a) {
  30063. this._idx = a
  30064. },
  30065. reset: function() {
  30066. this._idx = cc.INVALID_INDEX
  30067. },
  30068. setObjectID: function(a) {
  30069. this._idx = a
  30070. },
  30071. getObjectID: function() {
  30072. return this._idx
  30073. }
  30074. });
  30075. _p = cc.TableViewCell.prototype;
  30076. cc.defineGetterSetter(_p, "objectId", _p.getObjectID, _p.setObjectID);
  30077. _p = null;
  30078. cc.TableViewDelegate = cc.ScrollViewDelegate.extend({
  30079. tableCellTouched: function(a, c) {},
  30080. tableCellHighlight: function(a, c) {},
  30081. tableCellUnhighlight: function(a, c) {},
  30082. tableCellWillRecycle: function(a, c) {}
  30083. });
  30084. cc.TableViewDataSource = cc.Class.extend({
  30085. tableCellSizeForIndex: function(a, c) {
  30086. return this.cellSizeForTable(a)
  30087. },
  30088. cellSizeForTable: function(a) {
  30089. return cc.size(0, 0)
  30090. },
  30091. tableCellAtIndex: function(a, c) {
  30092. return null
  30093. },
  30094. numberOfCellsInTableView: function(a) {
  30095. return 0
  30096. }
  30097. });
  30098. cc.TableView = cc.ScrollView.extend({
  30099. _vOrdering: null,
  30100. _indices: null,
  30101. _cellsFreed: null,
  30102. _dataSource: null,
  30103. _tableViewDelegate: null,
  30104. _oldDirection: null,
  30105. _cellsPositions: null,
  30106. _touchedCell: null,
  30107. ctor: function(a, c, d) {
  30108. cc.ScrollView.prototype.ctor.call(this);
  30109. this._oldDirection = cc.SCROLLVIEW_DIRECTION_NONE;
  30110. this._cellsPositions = [];
  30111. this.initWithViewSize(c, d);
  30112. this.setDataSource(a);
  30113. this._updateCellPositions();
  30114. this._updateContentSize()
  30115. },
  30116. __indexFromOffset: function(a) {
  30117. var c = 0,
  30118. d = this._dataSource.numberOfCellsInTableView(this) - 1;
  30119. switch (this.getDirection()) {
  30120. case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
  30121. a = a.x;
  30122. break;
  30123. default:
  30124. a = a.y
  30125. }
  30126. for (var e = this._cellsPositions; d >= c;) {
  30127. var f = 0 | c + (d - c) / 2,
  30128. g = e[f],
  30129. h = e[f + 1];
  30130. if (a >= g && a <= h) return f;
  30131. a < g ? d = f - 1 : c = f + 1
  30132. }
  30133. return 0 >= c ? 0 : -1
  30134. },
  30135. _indexFromOffset: function(a) {
  30136. var c = {
  30137. x: a.x,
  30138. y: a.y
  30139. };
  30140. a = this._dataSource.numberOfCellsInTableView(this) - 1;
  30141. this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (c.y = this.getContainer().getContentSize().height - c.y);
  30142. c = this.__indexFromOffset(c); - 1 != c && (c = Math.max(0, c), c > a && (c = cc.INVALID_INDEX));
  30143. return c
  30144. },
  30145. __offsetFromIndex: function(a) {
  30146. switch (this.getDirection()) {
  30147. case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
  30148. a = cc.p(this._cellsPositions[a], 0);
  30149. break;
  30150. default:
  30151. a = cc.p(0, this._cellsPositions[a])
  30152. }
  30153. return a
  30154. },
  30155. _offsetFromIndex: function(a) {
  30156. var c = this.__offsetFromIndex(a);
  30157. a = this._dataSource.tableCellSizeForIndex(this, a);
  30158. this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (c.y = this.getContainer().getContentSize().height - c.y - a.height);
  30159. return c
  30160. },
  30161. _updateCellPositions: function() {
  30162. var a = this._dataSource.numberOfCellsInTableView(this),
  30163. c = this._cellsPositions;
  30164. if (0 < a) {
  30165. for (var d = 0, e, f = this._dataSource, g = 0; g < a; g++) switch (c[g] = d, e = f.tableCellSizeForIndex(this, g), this.getDirection()) {
  30166. case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
  30167. d += e.width;
  30168. break;
  30169. default:
  30170. d += e.height
  30171. }
  30172. this._cellsPositions[a] = d
  30173. }
  30174. },
  30175. _updateContentSize: function() {
  30176. var a = cc.size(0, 0),
  30177. c = this._dataSource.numberOfCellsInTableView(this);
  30178. if (0 < c) switch (a = this._cellsPositions[c], this.getDirection()) {
  30179. case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:
  30180. a = cc.size(a, this._viewSize.height);
  30181. break;
  30182. default:
  30183. a = cc.size(this._viewSize.width, a)
  30184. }
  30185. this.setContentSize(a);
  30186. 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)
  30187. },
  30188. _moveCellOutOfSight: function(a) {
  30189. this._tableViewDelegate && this._tableViewDelegate.tableCellWillRecycle && this._tableViewDelegate.tableCellWillRecycle(this, a);
  30190. this._cellsFreed.addObject(a);
  30191. this._cellsUsed.removeSortedObject(a);
  30192. cc.arrayRemoveObject(this._indices, a.getIdx());
  30193. a.reset();
  30194. a.getParent() == this.getContainer() && this.getContainer().removeChild(a, !0)
  30195. },
  30196. _setIndexForCell: function(a, c) {
  30197. c.setAnchorPoint(0, 0);
  30198. c.setPosition(this._offsetFromIndex(a));
  30199. c.setIdx(a)
  30200. },
  30201. _addCellIfNecessary: function(a) {
  30202. a.getParent() != this.getContainer() && this.getContainer().addChild(a);
  30203. this._cellsUsed.insertSortedObject(a);
  30204. var c = this._indices;
  30205. a = a.getIdx(); - 1 == c.indexOf(a) && (c.push(a), c.sort(function(a, c) {
  30206. return a - c
  30207. }))
  30208. },
  30209. getDataSource: function() {
  30210. return this._dataSource
  30211. },
  30212. setDataSource: function(a) {
  30213. this._dataSource = a
  30214. },
  30215. getDelegate: function() {
  30216. return this._tableViewDelegate
  30217. },
  30218. setDelegate: function(a) {
  30219. this._tableViewDelegate = a
  30220. },
  30221. setVerticalFillOrder: function(a) {
  30222. this._vOrdering != a && (this._vOrdering = a, 0 < this._cellsUsed.count() && this.reloadData())
  30223. },
  30224. getVerticalFillOrder: function() {
  30225. return this._vOrdering
  30226. },
  30227. initWithViewSize: function(a, c) {
  30228. 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
  30229. },
  30230. updateCellAtIndex: function(a) {
  30231. if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
  30232. var c = this.cellAtIndex(a);
  30233. c && this._moveCellOutOfSight(c);
  30234. c = this._dataSource.tableCellAtIndex(this, a);
  30235. this._setIndexForCell(a, c);
  30236. this._addCellIfNecessary(c)
  30237. }
  30238. },
  30239. insertCellAtIndex: function(a) {
  30240. if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
  30241. var c, d = this._cellsUsed;
  30242. if (c = d.objectWithObjectID(a))
  30243. for (var e = c = d.indexOfSortedObject(c); e < d.count(); e++) c = d.objectAtIndex(e), this._setIndexForCell(c.getIdx() + 1, c);
  30244. c = this._dataSource.tableCellAtIndex(this, a);
  30245. this._setIndexForCell(a, c);
  30246. this._addCellIfNecessary(c);
  30247. this._updateCellPositions();
  30248. this._updateContentSize()
  30249. }
  30250. },
  30251. removeCellAtIndex: function(a) {
  30252. if (!(a == cc.INVALID_INDEX || a > this._dataSource.numberOfCellsInTableView(this) - 1)) {
  30253. var c = this.cellAtIndex(a);
  30254. if (c) {
  30255. var d = this._cellsUsed,
  30256. e = d.indexOfSortedObject(c);
  30257. this._moveCellOutOfSight(c);
  30258. cc.arrayRemoveObject(this._indices, a);
  30259. this._updateCellPositions();
  30260. for (a = d.count() - 1; a > e; a--) c = d.objectAtIndex(a), this._setIndexForCell(c.getIdx() - 1, c)
  30261. }
  30262. }
  30263. },
  30264. reloadData: function() {
  30265. this._oldDirection = cc.SCROLLVIEW_DIRECTION_NONE;
  30266. for (var a = this._cellsUsed, c = this._cellsFreed, d = this.getContainer(), e = 0, f = a.count(); e < f; e++) {
  30267. var g = a.objectAtIndex(e);
  30268. this._tableViewDelegate && this._tableViewDelegate.tableCellWillRecycle && this._tableViewDelegate.tableCellWillRecycle(this, g);
  30269. c.addObject(g);
  30270. g.reset();
  30271. g.getParent() == d && d.removeChild(g, !0)
  30272. }
  30273. this._indices = [];
  30274. this._cellsUsed = new cc.ArrayForObjectSorting;
  30275. this._updateCellPositions();
  30276. this._updateContentSize();
  30277. 0 < this._dataSource.numberOfCellsInTableView(this) && this.scrollViewDidScroll(this)
  30278. },
  30279. dequeueCell: function() {
  30280. if (0 === this._cellsFreed.count()) return null;
  30281. var a = this._cellsFreed.objectAtIndex(0);
  30282. this._cellsFreed.removeObjectAtIndex(0);
  30283. return a
  30284. },
  30285. cellAtIndex: function(a) {
  30286. return -1 == this._indices.indexOf(a) ? null : this._cellsUsed.objectWithObjectID(a)
  30287. },
  30288. scrollViewDidScroll: function(a) {
  30289. var c = this._dataSource.numberOfCellsInTableView(this);
  30290. if (0 !== c) {
  30291. null != this._tableViewDelegate && this._tableViewDelegate.scrollViewDidScroll && this._tableViewDelegate.scrollViewDidScroll(this);
  30292. var d = 0,
  30293. e = this._viewSize,
  30294. d = this.getContainer(),
  30295. f = this.getContentOffset();
  30296. f.x *= -1;
  30297. f.y *= -1;
  30298. var g = Math.max(c - 1, 0);
  30299. this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN && (f.y += e.height / d.getScaleY());
  30300. a = this._indexFromOffset(f);
  30301. a === cc.INVALID_INDEX && (a = c - 1);
  30302. f.y = this._vOrdering === cc.TABLEVIEW_FILL_TOPDOWN ? f.y - e.height / d.getScaleY() : f.y + e.height / d.getScaleY();
  30303. f.x += e.width / d.getScaleX();
  30304. e = this._indexFromOffset(f);
  30305. e === cc.INVALID_INDEX && (e = c - 1);
  30306. f = this._cellsUsed;
  30307. if (0 < f.count()) {
  30308. c = f.objectAtIndex(0);
  30309. for (d = c.getIdx(); d < a;)
  30310. if (this._moveCellOutOfSight(c), 0 < f.count()) c = f.objectAtIndex(0), d = c.getIdx();
  30311. else break
  30312. }
  30313. if (0 < f.count()) {
  30314. c = f.lastObject();
  30315. for (d = c.getIdx(); d <= g && d > e;)
  30316. if (this._moveCellOutOfSight(c), 0 < f.count()) c = f.lastObject(), d = c.getIdx();
  30317. else break
  30318. }
  30319. for (g = this._indices; a <= e; a++) - 1 == g.indexOf(a) && this.updateCellAtIndex(a)
  30320. }
  30321. },
  30322. scrollViewDidZoom: function(a) {},
  30323. onTouchEnded: function(a, c) {
  30324. if (this.isVisible()) {
  30325. if (this._touchedCell) {
  30326. var d = this.getBoundingBox(),
  30327. e = cc.p(d.x, d.y),
  30328. e = this._parent.convertToWorldSpace(e);
  30329. d.x = e.x;
  30330. d.y = e.y;
  30331. e = this._tableViewDelegate;
  30332. cc.rectContainsPoint(d, a.getLocation()) && null != e && (e.tableCellUnhighlight && e.tableCellUnhighlight(this, this._touchedCell), e.tableCellTouched && e.tableCellTouched(this, this._touchedCell));
  30333. this._touchedCell = null
  30334. }
  30335. cc.ScrollView.prototype.onTouchEnded.call(this, a, c)
  30336. }
  30337. },
  30338. onTouchBegan: function(a, c) {
  30339. if (!this.isVisible()) return !1;
  30340. var d = cc.ScrollView.prototype.onTouchBegan.call(this, a, c);
  30341. if (1 === this._touches.length) {
  30342. var e;
  30343. e = this.getContainer().convertTouchToNodeSpace(a);
  30344. e = this._indexFromOffset(e);
  30345. (this._touchedCell = e === cc.INVALID_INDEX ? null : this.cellAtIndex(e)) && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellHighlight) && this._tableViewDelegate.tableCellHighlight(this, this._touchedCell)
  30346. } else this._touchedCell && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null);
  30347. return d
  30348. },
  30349. onTouchMoved: function(a, c) {
  30350. cc.ScrollView.prototype.onTouchMoved.call(this, a, c);
  30351. this._touchedCell && this.isTouchMoved() && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null)
  30352. },
  30353. onTouchCancelled: function(a, c) {
  30354. cc.ScrollView.prototype.onTouchCancelled.call(this, a, c);
  30355. this._touchedCell && (null != this._tableViewDelegate && this._tableViewDelegate.tableCellUnhighlight && this._tableViewDelegate.tableCellUnhighlight(this, this._touchedCell), this._touchedCell = null)
  30356. }
  30357. });
  30358. _p = cc.TableView.prototype;
  30359. cc.defineGetterSetter(_p, "dataSource", _p.getDataSource, _p.setDataSource);
  30360. cc.defineGetterSetter(_p, "delegate", _p.getDelegate, _p.setDelegate);
  30361. cc.defineGetterSetter(_p, "verticalFillOrder", _p.getVerticalFillOrder, _p.setVerticalFillOrder);
  30362. _p = null;
  30363. cc.TableView.create = function(a, c, d) {
  30364. return cc.TableView(a, c, d)
  30365. };
  30366. cc.ProtectedNode = cc.Node.extend({
  30367. _protectedChildren: null,
  30368. _reorderProtectedChildDirty: !1,
  30369. _insertProtectedChild: function(a, c) {
  30370. this._reorderProtectedChildDirty = !0;
  30371. this._protectedChildren.push(a);
  30372. a._setLocalZOrder(c)
  30373. },
  30374. ctor: function() {
  30375. cc.Node.prototype.ctor.call(this);
  30376. this._protectedChildren = []
  30377. },
  30378. addProtectedChild: function(a, c, d) {
  30379. cc.assert(null != a, "child must be non-nil");
  30380. cc.assert(!a.parent, "child already added. It can't be added again");
  30381. c = c || a.getLocalZOrder();
  30382. d && a.setTag(d);
  30383. this._insertProtectedChild(a, c);
  30384. a.setParent(this);
  30385. a.setOrderOfArrival(cc.s_globalOrderOfArrival);
  30386. if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
  30387. this._cascadeColorEnabled && this._enableCascadeColor();
  30388. this._cascadeOpacityEnabled && this._enableCascadeOpacity()
  30389. },
  30390. getProtectedChildByTag: function(a) {
  30391. cc.assert(a != cc.NODE_TAG_INVALID, "Invalid tag");
  30392. for (var c = this._protectedChildren, d = 0, e = c.length; d < e; d++)
  30393. if (c.getTag() == a) return c[d];
  30394. return null
  30395. },
  30396. removeProtectedChild: function(a, c) {
  30397. null == c && (c = !0);
  30398. var d = this._protectedChildren;
  30399. if (0 !== d.length) {
  30400. var e = d.indexOf(a); - 1 < e && (this._running && (a.onExitTransitionDidStart(), a.onExit()), c && a.cleanup(), a.setParent(null), d.splice(e, 1))
  30401. }
  30402. },
  30403. removeProtectedChildByTag: function(a, c) {
  30404. cc.assert(a != cc.NODE_TAG_INVALID, "Invalid tag");
  30405. null == c && (c = !0);
  30406. var d = this.getProtectedChildByTag(a);
  30407. null == d ? cc.log("cocos2d: removeChildByTag(tag \x3d %d): child not found!", a) : this.removeProtectedChild(d, c)
  30408. },
  30409. removeAllProtectedChildren: function() {
  30410. this.removeAllProtectedChildrenWithCleanup(!0)
  30411. },
  30412. removeAllProtectedChildrenWithCleanup: function(a) {
  30413. null == a && (a = !0);
  30414. for (var c = this._protectedChildren, d = 0, e = c.length; d < e; d++) {
  30415. var f = c[d];
  30416. this._running && (f.onExitTransitionDidStart(), f.onExit());
  30417. a && f.cleanup();
  30418. f.setParent(null)
  30419. }
  30420. c.length = 0
  30421. },
  30422. reorderProtectedChild: function(a, c) {
  30423. cc.assert(null != a, "Child must be non-nil");
  30424. this._reorderProtectedChildDirty = !0;
  30425. a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
  30426. a._setLocalZOrder(c)
  30427. },
  30428. sortAllProtectedChildren: function() {
  30429. if (this._reorderProtectedChildDirty) {
  30430. var a = this._protectedChildren,
  30431. c = a.length,
  30432. d, e, f;
  30433. for (d = 1; d < c; d++) {
  30434. f = a[d];
  30435. for (e = d - 1; 0 <= e;) {
  30436. if (f._localZOrder < a[e]._localZOrder) a[e + 1] = a[e];
  30437. else if (f._localZOrder === a[e]._localZOrder && f.arrivalOrder < a[e].arrivalOrder) a[e + 1] = a[e];
  30438. else break;
  30439. e--
  30440. }
  30441. a[e + 1] = f
  30442. }
  30443. this._reorderProtectedChildDirty = !1
  30444. }
  30445. },
  30446. visit: null,
  30447. _visitForCanvas: function(a) {
  30448. if (this._visible) {
  30449. a = a || cc._renderContext;
  30450. var c, d, e = this._children,
  30451. f, g = this._protectedChildren,
  30452. h = this._children.length,
  30453. k = g.length;
  30454. a.save();
  30455. this.transform(a);
  30456. this.sortAllChildren();
  30457. this.sortAllProtectedChildren();
  30458. for (c = 0; c < h; c++)
  30459. if (f = e[c], 0 > f._localZOrder) f.visit(a);
  30460. else break;
  30461. for (d = 0; d < k; d++)
  30462. if (f = g[d], 0 > f._localZOrder) f.visit(a);
  30463. else break;
  30464. for (this.draw(a); c < h; c++) e[c] && e[c].visit(a);
  30465. for (; d < k; d++) g[d] && g[d].visit(a);
  30466. this._cacheDirty = !1;
  30467. this.arrivalOrder = 0;
  30468. a.restore()
  30469. }
  30470. },
  30471. _visitForWebGL: function() {
  30472. if (this._visible) {
  30473. var a = cc._renderContext,
  30474. c, d = cc.current_stack,
  30475. e;
  30476. d.stack.push(d.top);
  30477. cc.kmMat4Assign(this._stackMatrix, d.top);
  30478. d.top = this._stackMatrix;
  30479. var f = this.grid;
  30480. f && f._active && f.beforeDraw();
  30481. this.transform();
  30482. var g = this._children,
  30483. h = this._protectedChildren,
  30484. k = g.length,
  30485. m = h.length;
  30486. this.sortAllChildren();
  30487. this.sortAllProtectedChildren();
  30488. for (c = 0; c < k; c++)
  30489. if (g[c] && 0 > g[c]._localZOrder) g[c].visit();
  30490. else break;
  30491. for (e = 0; e < m; e++)
  30492. if (h[e] && 0 > h[e]._localZOrder) h[e].visit();
  30493. else break;
  30494. for (this.draw(a); c < k; c++) g[c] && g[c].visit();
  30495. for (; e < m; e++) h[e] && h[e].visit();
  30496. this.arrivalOrder = 0;
  30497. f && f._active && f.afterDraw(this);
  30498. d.top = d.stack.pop()
  30499. }
  30500. },
  30501. cleanup: function() {
  30502. cc.Node.prototype.cleanup.call(this);
  30503. for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].cleanup()
  30504. },
  30505. onEnter: function() {
  30506. cc.Node.prototype.onEnter.call(this);
  30507. for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onEnter()
  30508. },
  30509. onEnterTransitionDidFinish: function() {
  30510. cc.Node.prototype.onEnterTransitionDidFinish.call(this);
  30511. for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onEnterTransitionDidFinish()
  30512. },
  30513. onExit: function() {
  30514. cc.Node.prototype.onExit.call(this);
  30515. for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onExit()
  30516. },
  30517. onExitTransitionDidStart: function() {
  30518. cc.Node.prototype.onExitTransitionDidStart.call(this);
  30519. for (var a = this._protectedChildren, c = 0, d = a.length; c < d; c++) a[c].onExitTransitionDidStart()
  30520. },
  30521. updateDisplayedOpacity: function(a) {
  30522. this._displayedOpacity = this._realOpacity * a / 255;
  30523. this._updateColor();
  30524. var c, d, e = this._displayedOpacity;
  30525. if (this._cascadeOpacityEnabled) {
  30526. d = this._children;
  30527. a = 0;
  30528. for (c = d.length; a < c; a++) d[a].updateDisplayedOpacity && d[a].updateDisplayedOpacity(e)
  30529. }
  30530. d = this._protectedChildren;
  30531. a = 0;
  30532. for (c = d.length; a < c; a++) d[a] && d[a].updateDisplayedOpacity(e)
  30533. },
  30534. updateDisplayedColor: function(a) {
  30535. var c = this._displayedColor,
  30536. d = this._realColor;
  30537. c.r = d.r * a.r / 255;
  30538. c.g = d.g * a.g / 255;
  30539. c.b = d.b * a.b / 255;
  30540. this._updateColor();
  30541. var e;
  30542. if (this._cascadeColorEnabled) {
  30543. e = this._children;
  30544. a = 0;
  30545. for (d = e.length; a < d; a++) e[a].updateDisplayedColor && e[a].updateDisplayedColor(c)
  30546. }
  30547. e = this._protectedChildren;
  30548. a = 0;
  30549. for (d = e.length; a < d; a++) e[a] && e[a].updateDisplayedColor(c)
  30550. },
  30551. disableCascadeColor: function() {
  30552. var a = cc.color.WHITE,
  30553. c, d, e = this._children;
  30554. c = 0;
  30555. for (d = e.length; c < d; c++) e[c].updateDisplayedColor(a);
  30556. e = this._protectedChildren;
  30557. c = 0;
  30558. for (d = e.length; c < d; c++) e[c].setColor(a)
  30559. }
  30560. });
  30561. cc.ProtectedNode.prototype.visit = cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.ProtectedNode.prototype._visitForCanvas : cc.ProtectedNode.prototype._visitForWebGL;
  30562. cc.ProtectedNode.create = function() {
  30563. return new cc.ProtectedNode
  30564. };
  30565. var ccui = ccui || {};
  30566. ccui.Class = ccui.Class || cc.Class;
  30567. ccui.Class.extend = ccui.Class.extend || cc.Class.extend;
  30568. ccui.Node = ccui.Node || cc.Node;
  30569. ccui.Node.extend = ccui.Node.extend || cc.Node.extend;
  30570. ccui.ProtectedNode = ccui.ProtectedNode || cc.ProtectedNode;
  30571. ccui.ProtectedNode.extend = ccui.ProtectedNode.extend || cc.ProtectedNode.extend;
  30572. ccui.cocosGUIVersion = "CocosGUI v1.0.0.0";
  30573. ccui.Widget = ccui.ProtectedNode.extend({
  30574. _enabled: !0,
  30575. _bright: !0,
  30576. _touchEnabled: !1,
  30577. _brightStyle: null,
  30578. _touchBeganPosition: null,
  30579. _touchMovePosition: null,
  30580. _touchEndPosition: null,
  30581. _touchEventListener: null,
  30582. _touchEventSelector: null,
  30583. _name: "default",
  30584. _widgetType: null,
  30585. _actionTag: 0,
  30586. _customSize: null,
  30587. _layoutParameterDictionary: null,
  30588. _layoutParameterType: 0,
  30589. _focused: !1,
  30590. _focusEnabled: !0,
  30591. _ignoreSize: !1,
  30592. _affectByClipping: !1,
  30593. _sizeType: null,
  30594. _sizePercent: null,
  30595. _positionType: null,
  30596. _positionPercent: null,
  30597. _reorderWidgetChildDirty: !1,
  30598. _hit: !1,
  30599. _nodes: null,
  30600. _touchListener: null,
  30601. _className: "Widget",
  30602. _flippedX: !1,
  30603. _flippedY: !1,
  30604. _opacity: 255,
  30605. _highlight: !1,
  30606. _touchEventCallback: null,
  30607. ctor: function() {
  30608. cc.ProtectedNode.prototype.ctor.call(this);
  30609. this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE;
  30610. this._touchBeganPosition = cc.p(0, 0);
  30611. this._touchMovePosition = cc.p(0, 0);
  30612. this._touchEndPosition = cc.p(0, 0);
  30613. this._widgetType = ccui.Widget.TYPE_WIDGET;
  30614. this._customSize = cc.size(0, 0);
  30615. this._layoutParameterDictionary = {};
  30616. this._sizeType = ccui.Widget.SIZE_ABSOLUTE;
  30617. this._sizePercent = cc.p(0, 0);
  30618. this._positionType = ccui.Widget.POSITION_ABSOLUTE;
  30619. this._positionPercent = cc.p(0, 0);
  30620. this._nodes = [];
  30621. this._layoutParameterType = ccui.LayoutParameter.NONE;
  30622. this.init()
  30623. },
  30624. init: function() {
  30625. 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
  30626. },
  30627. onEnter: function() {
  30628. this.updateSizeAndPosition();
  30629. cc.ProtectedNode.prototype.onEnter.call(this)
  30630. },
  30631. onExit: function() {
  30632. this.unscheduleUpdate();
  30633. cc.ProtectedNode.prototype.onExit.call(this)
  30634. },
  30635. visit: function(a) {
  30636. this._visible && (this._adaptRenderers(), cc.ProtectedNode.prototype.visit.call(this, a))
  30637. },
  30638. getWidgetParent: function() {
  30639. var a = this.getParent();
  30640. return a instanceof ccui.Widget ? a : null
  30641. },
  30642. _updateContentSizeWithTextureSize: function(a) {
  30643. this.setContentSize(this._ignoreSize ? a : this._customSize)
  30644. },
  30645. _isAncestorsEnabled: function() {
  30646. var a = this._getAncensterWidget(this);
  30647. return null == a ? !0 : a && !a.isEnabled() ? !1 : a._isAncestorsEnabled()
  30648. },
  30649. _getAncensterWidget: function(a) {
  30650. if (null == a) return null;
  30651. a = a.getParent();
  30652. return null == a ? null : a instanceof ccui.Widget ? a : this._getAncensterWidget(a.getParent())
  30653. },
  30654. _isAncestorsVisible: function(a) {
  30655. return null == a ? !0 : (a = a.getParent()) && !a.isVisible() ? !1 : this._isAncestorsVisible(a)
  30656. },
  30657. _cleanupWidget: function() {
  30658. this._eventDispatcher.removeEventListener(this._touchListener);
  30659. ccui.Widget._focusedWidget == this && (ccui.Widget._focusedWidget = null)
  30660. },
  30661. setEnabled: function(a) {
  30662. this._enabled = a
  30663. },
  30664. _initRenderer: function() {},
  30665. setContentSize: function(a, c) {
  30666. var d = void 0 === c ? a.width : a,
  30667. e = void 0 === c ? a.height : c;
  30668. cc.Node.prototype.setContentSize.call(this, d, e);
  30669. this._customSize.width = d;
  30670. this._customSize.height = e;
  30671. this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
  30672. if (this._running) {
  30673. var f = this.getWidgetParent(),
  30674. f = f ? f.getContentSize() : this._parent.getContentSize();
  30675. this._sizePercent.x = 0 < f.width ? d / f.width : 0;
  30676. this._sizePercent.y = 0 < f.height ? e / f.height : 0
  30677. }
  30678. this._onSizeChanged()
  30679. },
  30680. _setWidth: function(a) {
  30681. cc.Node.prototype._setWidth.call(this, a);
  30682. this._customSize.width = a;
  30683. this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
  30684. this._running && (a = (a = this.getWidgetParent()) ? a.width : this._parent.width, this._sizePercent.x = 0 < a ? this._customSize.width / a : 0);
  30685. this._onSizeChanged()
  30686. },
  30687. _setHeight: function(a) {
  30688. cc.Node.prototype._setHeight.call(this, a);
  30689. this._customSize.height = a;
  30690. this._ignoreSize && (this._contentSize = this.getVirtualRendererSize());
  30691. this._running && (a = (a = this.getWidgetParent()) ? a.height : this._parent.height, this._sizePercent.y = 0 < a ? this._customSize.height / a : 0);
  30692. this._onSizeChanged()
  30693. },
  30694. setSizePercent: function(a) {
  30695. this._sizePercent.x = a.x;
  30696. this._sizePercent.y = a.y;
  30697. var c = this._customSize.width,
  30698. d = this._customSize.height;
  30699. 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));
  30700. this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(c, d);
  30701. this._customSize.width = c;
  30702. this._customSize.height = d
  30703. },
  30704. _setWidthPercent: function(a) {
  30705. this._sizePercent.x = a;
  30706. var c = this._customSize.width;
  30707. this._running && (c = this.getWidgetParent(), c = (c ? c.width : this._parent.width) * a);
  30708. this._ignoreSize ? this._setWidth(this.getVirtualRendererSize().width) : this._setWidth(c);
  30709. this._customSize.width = c
  30710. },
  30711. _setHeightPercent: function(a) {
  30712. this._sizePercent.y = a;
  30713. var c = this._customSize.height;
  30714. this._running && (c = this.getWidgetParent(), c = (c ? c.height : this._parent.height) * a);
  30715. this._ignoreSize ? this._setHeight(this.getVirtualRendererSize().height) : this._setHeight(c);
  30716. this._customSize.height = c
  30717. },
  30718. updateSizeAndPosition: function(a) {
  30719. a || (a = (a = this.getWidgetParent()) ? a.getLayoutSize() : this._parent.getContentSize());
  30720. switch (this._sizeType) {
  30721. case ccui.Widget.SIZE_ABSOLUTE:
  30722. this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(this._customSize);
  30723. this._sizePercent.x = 0 < a.width ? this._customSize.width / a.width : 0;
  30724. this._sizePercent.y = 0 < a.height ? this._customSize.height / a.height : 0;
  30725. break;
  30726. case ccui.Widget.SIZE_PERCENT:
  30727. var c = cc.size(a.width * this._sizePercent.x, a.height * this._sizePercent.y);
  30728. this._ignoreSize ? this.setContentSize(this.getVirtualRendererSize()) : this.setContentSize(c);
  30729. this._customSize.width = c.width;
  30730. this._customSize.height = c.height
  30731. }
  30732. this._onSizeChanged();
  30733. c = this.getPosition();
  30734. switch (this._positionType) {
  30735. case ccui.Widget.POSITION_ABSOLUTE:
  30736. 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);
  30737. break;
  30738. case ccui.Widget.POSITION_PERCENT:
  30739. c = cc.p(a.width * this._positionPercent.x, a.height * this._positionPercent.y)
  30740. }
  30741. if (this._parent instanceof ccui.ImageView && (a = this._parent._imageRenderer) && !a._textureLoaded) return;
  30742. this.setPosition(c)
  30743. },
  30744. setSizeType: function(a) {
  30745. this._sizeType = a
  30746. },
  30747. getSizeType: function() {
  30748. return this._sizeType
  30749. },
  30750. ignoreContentAdaptWithSize: function(a) {
  30751. this._ignoreSize != a && (this._ignoreSize = a, this.setContentSize(a ? this.getVirtualRendererSize() : this._customSize), this._onSizeChanged())
  30752. },
  30753. isIgnoreContentAdaptWithSize: function() {
  30754. return this._ignoreSize
  30755. },
  30756. getCustomSize: function() {
  30757. return cc.size(this._customSize)
  30758. },
  30759. getLayoutSize: function() {
  30760. return cc.size(this._contentSize)
  30761. },
  30762. getSizePercent: function() {
  30763. return cc.p(this._sizePercent)
  30764. },
  30765. _getWidthPercent: function() {
  30766. return this._sizePercent.x
  30767. },
  30768. _getHeightPercent: function() {
  30769. return this._sizePercent.y
  30770. },
  30771. getWorldPosition: function() {
  30772. return this.convertToWorldSpace(cc.p(this._anchorPoint.x * this._contentSize.width, this._anchorPoint.y * this._contentSize.height))
  30773. },
  30774. getVirtualRenderer: function() {
  30775. return this
  30776. },
  30777. getVirtualRendererSize: function() {
  30778. return cc.size(this._contentSize)
  30779. },
  30780. _onSizeChanged: function() {
  30781. for (var a = this.getChildren(), c = 0, d = a.length; c < d; c++) {
  30782. var e = a[c];
  30783. e instanceof ccui.Widget && e.updateSizeAndPosition()
  30784. }
  30785. },
  30786. setTouchEnabled: function(a) {
  30787. this._touchEnabled !== a && ((this._touchEnabled = a) ? (this._touchListener = cc.EventListener.create({
  30788. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  30789. swallowTouches: !0,
  30790. onTouchBegan: this.onTouchBegan.bind(this),
  30791. onTouchMoved: this.onTouchMoved.bind(this),
  30792. onTouchEnded: this.onTouchEnded.bind(this)
  30793. }), cc.eventManager.addListener(this._touchListener, this)) : cc.eventManager.removeListener(this._touchListener))
  30794. },
  30795. isTouchEnabled: function() {
  30796. return this._touchEnabled
  30797. },
  30798. isHighlighted: function() {
  30799. return this._highlight
  30800. },
  30801. setHighlighted: function(a) {
  30802. if (a != this._highlight)
  30803. if (this._highlight = a, this._bright) this._highlight ? this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT) : this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL);
  30804. else this.onPressStateChangedToDisabled()
  30805. },
  30806. isFocused: function() {
  30807. return this._focused
  30808. },
  30809. setFocused: function(a) {
  30810. if (this._focused = a) ccui.Widget._focusedWidget = this
  30811. },
  30812. isFocusEnabled: function() {
  30813. return this._focusEnabled
  30814. },
  30815. setFocusEnabled: function(a) {
  30816. this._focused = a
  30817. },
  30818. findNextFocusedWidget: function(a, c) {
  30819. if (null == this.onNextFocusedWidget || null == this.onNextFocusedWidget(a)) {
  30820. var d = c instanceof ccui.Layout;
  30821. if (this.isFocused() || d) {
  30822. var e = this.getParent();
  30823. return null == e ? d ? c.findNextFocusedWidget(a, c) : c : e.findNextFocusedWidget(a, c)
  30824. }
  30825. return c
  30826. }
  30827. d = this.onNextFocusedWidget(a);
  30828. this.dispatchFocusEvent(this, d);
  30829. return d
  30830. },
  30831. requestFocus: function() {
  30832. this != ccui.Widget._focusedWidget && this.dispatchFocusEvent(ccui.Widget._focusedWidget, this)
  30833. },
  30834. getCurrentFocusedWidget: function() {
  30835. return ccui.Widget._focusedWidget
  30836. },
  30837. enableDpadNavigation: function(a) {},
  30838. onFocusChanged: null,
  30839. onNextFocusedWidget: null,
  30840. interceptTouchEvent: function(a, c, d) {
  30841. var e = this.getWidgetParent();
  30842. e && e.interceptTouchEvent(a, c, d)
  30843. },
  30844. onFocusChange: function(a, c) {
  30845. a && a.setFocused(!1);
  30846. c && c.setFocused(!0)
  30847. },
  30848. dispatchFocusEvent: function(a, c) {
  30849. a && !a.isFocused() && (a = ccui.Widget._focusedWidget);
  30850. if (c != a) {
  30851. if (c && c.onFocusChanged) c.onFocusChanged(a, c);
  30852. if (a && c.onFocusChanged) a.onFocusChanged(a, c);
  30853. cc.eventManager.dispatchEvent(new cc.EventFocus(a, c))
  30854. }
  30855. },
  30856. setBright: function(a) {
  30857. if (this._bright = a) this._brightStyle = ccui.Widget.BRIGHT_STYLE_NONE, this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL);
  30858. else this.onPressStateChangedToDisabled()
  30859. },
  30860. setBrightStyle: function(a) {
  30861. if (this._brightStyle != a) switch (this._brightStyle = a = a || ccui.Widget.BRIGHT_STYLE_NORMAL, this._brightStyle) {
  30862. case ccui.Widget.BRIGHT_STYLE_NORMAL:
  30863. this.onPressStateChangedToNormal();
  30864. break;
  30865. case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:
  30866. this.onPressStateChangedToPressed()
  30867. }
  30868. },
  30869. onPressStateChangedToNormal: function() {},
  30870. onPressStateChangedToPressed: function() {},
  30871. onPressStateChangedToDisabled: function() {},
  30872. didNotSelectSelf: function() {},
  30873. onTouchBegan: function(a, c) {
  30874. this._hit = !1;
  30875. if (this.isVisible() && this.isEnabled() && this._isAncestorsEnabled() && this._isAncestorsVisible(this)) {
  30876. var d = a.getLocation();
  30877. this._touchBeganPosition.x = d.x;
  30878. this._touchBeganPosition.y = d.y;
  30879. this.hitTest(this._touchBeganPosition) && this.isClippingParentContainsPoint(this._touchBeganPosition) && (this._hit = !0)
  30880. }
  30881. if (!this._hit) return !1;
  30882. this.setHighlighted(!0);
  30883. (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_BEGAN, this, a);
  30884. this._pushDownEvent();
  30885. return !0
  30886. },
  30887. onTouchMoved: function(a, c) {
  30888. var d = a.getLocation();
  30889. this._touchMovePosition.x = d.x;
  30890. this._touchMovePosition.y = d.y;
  30891. this.setHighlighted(this.hitTest(d));
  30892. (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, a);
  30893. this._moveEvent()
  30894. },
  30895. onTouchEnded: function(a, c) {
  30896. var d = a.getLocation();
  30897. this._touchEndPosition.x = d.x;
  30898. this._touchEndPosition.y = d.y;
  30899. (d = this.getWidgetParent()) && d.interceptTouchEvent(ccui.Widget.TOUCH_ENDED, this, a);
  30900. d = this._highlight;
  30901. this.setHighlighted(!1);
  30902. d ? this._releaseUpEvent() : this._cancelUpEvent()
  30903. },
  30904. onTouchCancelled: function(a) {
  30905. this.setHighlighted(!1);
  30906. this._cancelUpEvent()
  30907. },
  30908. onTouchLongClicked: function(a) {
  30909. this.longClickEvent()
  30910. },
  30911. _pushDownEvent: function() {
  30912. this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_BEGAN);
  30913. this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_BEGAN)
  30914. },
  30915. _moveEvent: function() {
  30916. this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_MOVED);
  30917. this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_MOVED)
  30918. },
  30919. _releaseUpEvent: function() {
  30920. this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_ENDED);
  30921. this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_ENDED)
  30922. },
  30923. _cancelUpEvent: function() {
  30924. this._touchEventCallback && this._touchEventCallback(this, ccui.Widget.TOUCH_CANCELED);
  30925. this._touchEventListener && this._touchEventSelector && this._touchEventSelector.call(this._touchEventListener, this, ccui.Widget.TOUCH_CANCELED)
  30926. },
  30927. longClickEvent: function() {},
  30928. addTouchEventListener: function(a, c) {
  30929. void 0 === c ? this._touchEventCallback = a : (this._touchEventSelector = a, this._touchEventListener = c)
  30930. },
  30931. hitTest: function(a) {
  30932. var c = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  30933. return cc.rectContainsPoint(c, this.convertToNodeSpace(a))
  30934. },
  30935. isClippingParentContainsPoint: function(a) {
  30936. this._affectByClipping = !1;
  30937. for (var c = this.getParent(), d = null; c;) {
  30938. if (c instanceof ccui.Layout && c.isClippingEnabled()) {
  30939. this._affectByClipping = !0;
  30940. d = c;
  30941. break
  30942. }
  30943. c = c.getParent()
  30944. }
  30945. return !this._affectByClipping ? !0 : d ? d.hitTest(a) ? d.isClippingParentContainsPoint(a) : !1 : !0
  30946. },
  30947. checkChildInfo: function(a, c, d) {
  30948. var e = this.getWidgetParent();
  30949. e && e.checkChildInfo(a, c, d)
  30950. },
  30951. setPosition: function(a, c) {
  30952. if (this._running) {
  30953. var d = this.getWidgetParent();
  30954. 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))
  30955. }
  30956. cc.Node.prototype.setPosition.call(this, a, c)
  30957. },
  30958. setPositionX: function(a) {
  30959. if (this._running) {
  30960. var c = this.getWidgetParent();
  30961. c && (c = c.width, this._positionPercent.x = 0 >= c ? 0 : a / c)
  30962. }
  30963. cc.Node.prototype.setPositionX.call(this, a)
  30964. },
  30965. setPositionY: function(a) {
  30966. if (this._running) {
  30967. var c = this.getWidgetParent();
  30968. c && (c = c.height, this._positionPercent.y = 0 >= c ? 0 : a / c)
  30969. }
  30970. cc.Node.prototype.setPositionY.call(this, a)
  30971. },
  30972. setPositionPercent: function(a) {
  30973. this._positionPercent = a;
  30974. if (this._running && (a = this.getWidgetParent())) a = a.getSize(), this.setPosition(a.width * this._positionPercent.x, a.height * this._positionPercent.y)
  30975. },
  30976. _setXPercent: function(a) {
  30977. this._positionPercent.x = a;
  30978. if (this._running) {
  30979. var c = this.getWidgetParent();
  30980. c && this.setPositionX(c.width * a)
  30981. }
  30982. },
  30983. _setYPercent: function(a) {
  30984. this._positionPercent.y = a;
  30985. if (this._running) {
  30986. var c = this.getWidgetParent();
  30987. c && this.setPositionY(c.height * a)
  30988. }
  30989. },
  30990. getPositionPercent: function() {
  30991. return cc.p(this._positionPercent)
  30992. },
  30993. _getXPercent: function() {
  30994. return this._positionPercent.x
  30995. },
  30996. _getYPercent: function() {
  30997. return this._positionPercent.y
  30998. },
  30999. setPositionType: function(a) {
  31000. this._positionType = a
  31001. },
  31002. getPositionType: function() {
  31003. return this._positionType
  31004. },
  31005. setFlippedX: function(a) {
  31006. this._flippedX = a;
  31007. this._updateFlippedX()
  31008. },
  31009. isFlippedX: function() {
  31010. return this._flippedX
  31011. },
  31012. setFlippedY: function(a) {
  31013. this._flippedY = a;
  31014. this._updateFlippedY()
  31015. },
  31016. isFlippedY: function() {
  31017. return this._flippedY
  31018. },
  31019. _updateFlippedX: function() {},
  31020. _updateFlippedY: function() {},
  31021. _adaptRenderers: function() {},
  31022. isBright: function() {
  31023. return this._bright
  31024. },
  31025. isEnabled: function() {
  31026. return this._enabled
  31027. },
  31028. getLeftBoundary: function() {
  31029. return this.getPositionX() - this._getAnchorX() * this._contentSize.width
  31030. },
  31031. getBottomBoundary: function() {
  31032. return this.getPositionY() - this._getAnchorY() * this._contentSize.height
  31033. },
  31034. getRightBoundary: function() {
  31035. return this.getLeftBoundary() + this._contentSize.width
  31036. },
  31037. getTopBoundary: function() {
  31038. return this.getBottomBoundary() + this._contentSize.height
  31039. },
  31040. getTouchBeganPosition: function() {
  31041. return cc.p(this._touchBeganPosition)
  31042. },
  31043. getTouchMovePosition: function() {
  31044. return cc.p(this._touchMovePosition)
  31045. },
  31046. getTouchEndPosition: function() {
  31047. return cc.p(this._touchEndPosition)
  31048. },
  31049. setName: function(a) {
  31050. this._name = a
  31051. },
  31052. getName: function() {
  31053. return this._name
  31054. },
  31055. getWidgetType: function() {
  31056. return this._widgetType
  31057. },
  31058. setLayoutParameter: function(a) {
  31059. a && (this._layoutParameterDictionary[a.getLayoutType()] = a, this._layoutParameterType = a.getLayoutType())
  31060. },
  31061. getLayoutParameter: function(a) {
  31062. a = a || this._layoutParameterType;
  31063. return this._layoutParameterDictionary[a]
  31064. },
  31065. getDescription: function() {
  31066. return "Widget"
  31067. },
  31068. clone: function() {
  31069. var a = this._createCloneInstance();
  31070. a._copyProperties(this);
  31071. a._copyClonedWidgetChildren(this);
  31072. return a
  31073. },
  31074. _createCloneInstance: function() {
  31075. return ccui.Widget.create()
  31076. },
  31077. _copyClonedWidgetChildren: function(a) {
  31078. a = a.getChildren();
  31079. for (var c = 0; c < a.length; c++) {
  31080. var d = a[c];
  31081. d instanceof ccui.Widget && this.addChild(d.clone())
  31082. }
  31083. },
  31084. _copySpecialProperties: function(a) {},
  31085. _copyProperties: function(a) {
  31086. this.setEnabled(a.isEnabled());
  31087. this.setVisible(a.isVisible());
  31088. this.setBright(a.isBright());
  31089. this.setTouchEnabled(a.isTouchEnabled());
  31090. this.setLocalZOrder(a.getLocalZOrder());
  31091. this.setTag(a.getTag());
  31092. this.setName(a.getName());
  31093. this.setActionTag(a.getActionTag());
  31094. this._ignoreSize = a._ignoreSize;
  31095. this.setContentSize(a._contentSize);
  31096. this._customSize.width = a._customSize.width;
  31097. this._customSize.height = a._customSize.height;
  31098. this._copySpecialProperties(a);
  31099. this._sizeType = a.getSizeType();
  31100. this._sizePercent.x = a._sizePercent.x;
  31101. this._sizePercent.y = a._sizePercent.y;
  31102. this._positionType = a._positionType;
  31103. this._positionPercent.x = a._positionPercent.x;
  31104. this._positionPercent.y = a._positionPercent.y;
  31105. this.setPosition(a.getPosition());
  31106. this.setAnchorPoint(a.getAnchorPoint());
  31107. this.setScaleX(a.getScaleX());
  31108. this.setScaleY(a.getScaleY());
  31109. this.setRotation(a.getRotation());
  31110. this.setRotationX(a.getRotationX());
  31111. this.setRotationY(a.getRotationY());
  31112. this.setFlippedX(a.isFlippedX());
  31113. this.setFlippedY(a.isFlippedY());
  31114. this.setColor(a.getColor());
  31115. this.setOpacity(a.getOpacity());
  31116. this._touchEventCallback = a._touchEventCallback;
  31117. this._touchEventListener = a._touchEventListener;
  31118. this._touchEventSelector = a._touchEventSelector;
  31119. this._focused = a._focused;
  31120. this._focusEnabled = a._focusEnabled;
  31121. for (var c in a._layoutParameterDictionary) {
  31122. var d = a._layoutParameterDictionary[c];
  31123. d && this.setLayoutParameter(d.clone())
  31124. }
  31125. this._onSizeChanged()
  31126. },
  31127. setActionTag: function(a) {
  31128. this._actionTag = a
  31129. },
  31130. getActionTag: function() {
  31131. return this._actionTag
  31132. },
  31133. getLeftInParent: function() {
  31134. cc.log("getLeftInParent is deprecated. Please use getLeftBoundary instead.");
  31135. return this.getLeftBoundary()
  31136. },
  31137. getBottomInParent: function() {
  31138. cc.log("getBottomInParent is deprecated. Please use getBottomBoundary instead.");
  31139. return this.getBottomBoundary()
  31140. },
  31141. getRightInParent: function() {
  31142. cc.log("getRightInParent is deprecated. Please use getRightBoundary instead.");
  31143. return this.getRightBoundary()
  31144. },
  31145. getTopInParent: function() {
  31146. cc.log("getTopInParent is deprecated. Please use getTopBoundary instead.");
  31147. return this.getTopBoundary()
  31148. },
  31149. getTouchEndPos: function() {
  31150. cc.log("getTouchEndPos is deprecated. Please use getTouchEndPosition instead.");
  31151. return this.getTouchEndPosition()
  31152. },
  31153. getTouchMovePos: function() {
  31154. cc.log("getTouchMovePos is deprecated. Please use getTouchMovePosition instead.");
  31155. return this.getTouchMovePosition()
  31156. },
  31157. clippingParentAreaContainPoint: function(a) {
  31158. cc.log("clippingParentAreaContainPoint is deprecated. Please use isClippingParentContainsPoint instead.");
  31159. this.isClippingParentContainsPoint(a)
  31160. },
  31161. getTouchStartPos: function() {
  31162. cc.log("getTouchStartPos is deprecated. Please use getTouchBeganPosition instead.");
  31163. return this.getTouchBeganPosition()
  31164. },
  31165. setSize: function(a) {
  31166. this.setContentSize(a)
  31167. },
  31168. getSize: function() {
  31169. return this.getContentSize()
  31170. },
  31171. addNode: function(a, c, d) {
  31172. 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))
  31173. },
  31174. getNodeByTag: function(a) {
  31175. for (var c = this._nodes, d = 0; d < c.length; d++) {
  31176. var e = c[d];
  31177. if (e && e.getTag() == a) return e
  31178. }
  31179. return null
  31180. },
  31181. getNodes: function() {
  31182. return this._nodes
  31183. },
  31184. removeNode: function(a, c) {
  31185. cc.Node.prototype.removeChild.call(this, a);
  31186. cc.arrayRemoveObject(this._nodes, a)
  31187. },
  31188. removeNodeByTag: function(a, c) {
  31189. var d = this.getNodeByTag(a);
  31190. d ? this.removeNode(d) : cc.log("cocos2d: removeNodeByTag(tag \x3d %d): child not found!", a)
  31191. },
  31192. removeAllNodes: function() {
  31193. for (var a = 0; a < this._nodes.length; a++) cc.Node.prototype.removeChild.call(this, this._nodes[a]);
  31194. this._nodes.length = 0
  31195. },
  31196. _findLayout: function() {
  31197. for (var a = this._parent; a;)
  31198. if (a._doLayout) {
  31199. a._doLayoutDirty = !0;
  31200. break
  31201. } else a = a._parent
  31202. },
  31203. _updateChildrenDisplayedRGBA: function() {
  31204. this.setColor(this.getColor());
  31205. this.setOpacity(this.getOpacity())
  31206. }
  31207. });
  31208. _p = ccui.Widget.prototype;
  31209. cc.defineGetterSetter(_p, "xPercent", _p._getXPercent, _p._setXPercent);
  31210. cc.defineGetterSetter(_p, "yPercent", _p._getYPercent, _p._setYPercent);
  31211. cc.defineGetterSetter(_p, "widthPercent", _p._getWidthPercent, _p._setWidthPercent);
  31212. cc.defineGetterSetter(_p, "heightPercent", _p._getHeightPercent, _p._setHeightPercent);
  31213. cc.defineGetterSetter(_p, "widgetParent", _p.getWidgetParent);
  31214. cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
  31215. cc.defineGetterSetter(_p, "focused", _p.isFocused, _p.setFocused);
  31216. cc.defineGetterSetter(_p, "sizeType", _p.getSizeType, _p.setSizeType);
  31217. cc.defineGetterSetter(_p, "widgetType", _p.getWidgetType);
  31218. cc.defineGetterSetter(_p, "touchEnabled", _p.isTouchEnabled, _p.setTouchEnabled);
  31219. cc.defineGetterSetter(_p, "updateEnabled", _p.isUpdateEnabled, _p.setUpdateEnabled);
  31220. cc.defineGetterSetter(_p, "bright", _p.isBright, _p.setBright);
  31221. cc.defineGetterSetter(_p, "name", _p.getName, _p.setName);
  31222. cc.defineGetterSetter(_p, "actionTag", _p.getActionTag, _p.setActionTag);
  31223. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  31224. _p = null;
  31225. ccui.Widget.create = function() {
  31226. return new ccui.Widget
  31227. };
  31228. ccui.Widget._focusedWidget = null;
  31229. ccui.Widget.getCurrentFocusedWidget = function() {
  31230. return ccui.Widget._focusedWidget
  31231. };
  31232. ccui.Widget.BRIGHT_STYLE_NONE = -1;
  31233. ccui.Widget.BRIGHT_STYLE_NORMAL = 0;
  31234. ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT = 1;
  31235. ccui.Widget.TYPE_WIDGET = 0;
  31236. ccui.Widget.TYPE_CONTAINER = 1;
  31237. ccui.Widget.LEFT = 0;
  31238. ccui.Widget.RIGHT = 1;
  31239. ccui.Widget.UP = 0;
  31240. ccui.Widget.DOWN = 1;
  31241. ccui.Widget.LOCAL_TEXTURE = 0;
  31242. ccui.Widget.PLIST_TEXTURE = 1;
  31243. ccui.Widget.TOUCH_BEGAN = 0;
  31244. ccui.Widget.TOUCH_MOVED = 1;
  31245. ccui.Widget.TOUCH_ENDED = 2;
  31246. ccui.Widget.TOUCH_CANCELED = 3;
  31247. ccui.Widget.SIZE_ABSOLUTE = 0;
  31248. ccui.Widget.SIZE_PERCENT = 1;
  31249. ccui.Widget.POSITION_ABSOLUTE = 0;
  31250. ccui.Widget.POSITION_PERCENT = 1;
  31251. cc.EventFocus = cc.Event.extend({
  31252. _widgetGetFocus: null,
  31253. _widgetLoseFocus: null,
  31254. ctor: function(a, c) {
  31255. this._widgetGetFocus = c;
  31256. this._widgetLoseFocus = a
  31257. }
  31258. });
  31259. ccui.Layout = ccui.Widget.extend({
  31260. _clippingEnabled: !1,
  31261. _backGroundScale9Enabled: null,
  31262. _backGroundImage: null,
  31263. _backGroundImageFileName: null,
  31264. _backGroundImageCapInsets: null,
  31265. _colorType: null,
  31266. _bgImageTexType: ccui.Widget.LOCAL_TEXTURE,
  31267. _colorRender: null,
  31268. _gradientRender: null,
  31269. _color: null,
  31270. _startColor: null,
  31271. _endColor: null,
  31272. _alongVector: null,
  31273. _opacity: 255,
  31274. _backGroundImageTextureSize: null,
  31275. _layoutType: null,
  31276. _doLayoutDirty: !0,
  31277. _clippingRectDirty: !0,
  31278. _clippingType: null,
  31279. _clippingStencil: null,
  31280. _handleScissor: !1,
  31281. _scissorRectDirty: !1,
  31282. _clippingRect: null,
  31283. _clippingParent: null,
  31284. _className: "Layout",
  31285. _backGroundImageColor: null,
  31286. _finalPositionX: 0,
  31287. _finalPositionY: 0,
  31288. _currentStencilEnabled: 0,
  31289. _currentStencilWriteMask: 0,
  31290. _currentStencilFunc: 0,
  31291. _currentStencilRef: 0,
  31292. _currentStencilValueMask: 0,
  31293. _currentStencilFail: 0,
  31294. _currentStencilPassDepthFail: 0,
  31295. _currentStencilPassDepthPass: 0,
  31296. _currentDepthWriteMask: 0,
  31297. _currentAlphaTestEnabled: 0,
  31298. _currentAlphaTestFunc: 0,
  31299. _currentAlphaTestRef: 0,
  31300. _backGroundImageOpacity: 0,
  31301. _mask_layer_le: 0,
  31302. _loopFocus: !1,
  31303. __passFocusToChild: !1,
  31304. _isFocusPassing: !1,
  31305. ctor: function() {
  31306. this._layoutType = ccui.Layout.ABSOLUTE;
  31307. this._widgetType = ccui.Widget.TYPE_CONTAINER;
  31308. this._clippingType = ccui.Layout.CLIPPING_STENCIL;
  31309. this._colorType = ccui.Layout.BG_COLOR_NONE;
  31310. ccui.Widget.prototype.ctor.call(this);
  31311. this._backGroundImageCapInsets = cc.rect(0, 0, 0, 0);
  31312. this._color = cc.color(255, 255, 255, 255);
  31313. this._startColor = cc.color(255, 255, 255, 255);
  31314. this._endColor = cc.color(255, 255, 255, 255);
  31315. this._alongVector = cc.p(0, -1);
  31316. this._backGroundImageTextureSize = cc.size(0, 0);
  31317. this._clippingRect = cc.rect(0, 0, 0, 0);
  31318. this._backGroundImageColor = cc.color(255, 255, 255, 255)
  31319. },
  31320. onEnter: function() {
  31321. ccui.Widget.prototype.onEnter.call(this);
  31322. if (this._clippingStencil) this._clippingStencil.onEnter();
  31323. this._clippingRectDirty = this._doLayoutDirty = !0
  31324. },
  31325. onExit: function() {
  31326. ccui.Widget.prototype.onExit.call(this);
  31327. if (this._clippingStencil) this._clippingStencil.onExit()
  31328. },
  31329. setLoopFocus: function(a) {
  31330. this._loopFocus = a
  31331. },
  31332. isLoopFocus: function() {
  31333. return this._loopFocus
  31334. },
  31335. setPassFocusToChild: function(a) {
  31336. this.__passFocusToChild = a
  31337. },
  31338. isPassFocusToChild: function() {
  31339. return this.__passFocusToChild
  31340. },
  31341. findNextFocusedWidget: function(a, c) {
  31342. if (this._isFocusPassing || this.isFocused()) {
  31343. var d = this.getParent();
  31344. this._isFocusPassing = !1;
  31345. if (this.__passFocusToChild) {
  31346. var e = this._passFocusToChild(a, c);
  31347. return e instanceof ccui.Layout && d ? (d._isFocusPassing = !0, d.findNextFocusedWidget(a, this)) : e
  31348. }
  31349. if (null == d) return this;
  31350. d._isFocusPassing = !0;
  31351. return d.findNextFocusedWidget(a, this)
  31352. }
  31353. if (c.isFocused() || c instanceof ccui.Layout)
  31354. if (this._layoutType == ccui.Layout.LINEAR_HORIZONTAL) switch (a) {
  31355. case ccui.Widget.LEFT:
  31356. return this._getPreviousFocusedWidget(a, c);
  31357. case ccui.Widget.RIGHT:
  31358. return this._getNextFocusedWidget(a, c);
  31359. case ccui.Widget.DOWN:
  31360. case ccui.Widget.UP:
  31361. return this._isLastWidgetInContainer(this, a) ? this._isWidgetAncestorSupportLoopFocus(c, a) ? this.findNextFocusedWidget(a, this) : c : this.findNextFocusedWidget(a, this);
  31362. default:
  31363. return cc.assert(0, "Invalid Focus Direction"), c
  31364. } else if (this._layoutType == ccui.Layout.LINEAR_VERTICAL) switch (a) {
  31365. case ccui.Widget.LEFT:
  31366. case ccui.Widget.RIGHT:
  31367. return this._isLastWidgetInContainer(this, a) ? this._isWidgetAncestorSupportLoopFocus(c, a) ? this.findNextFocusedWidget(a, this) : c : this.findNextFocusedWidget(a, this);
  31368. case ccui.Widget.DOWN:
  31369. return this._getNextFocusedWidget(a, c);
  31370. case ccui.Widget.UP:
  31371. return this._getPreviousFocusedWidget(a, c);
  31372. default:
  31373. return cc.assert(0, "Invalid Focus Direction"), c
  31374. } else return cc.assert(0, "Un Supported Layout type, please use VBox and HBox instead!!!"), c;
  31375. else return c
  31376. },
  31377. onPassFocusToChild: null,
  31378. init: function() {
  31379. 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
  31380. },
  31381. __stencilDraw: function(a) {
  31382. a = a || cc._renderContext;
  31383. for (var c = this._clippingStencil, d = cc.view.getScaleX(), e = cc.view.getScaleY(), f = 0; f < c._buffer.length; f++) {
  31384. var g = c._buffer[f].verts,
  31385. h = g[0];
  31386. a.beginPath();
  31387. a.moveTo(h.x * d, -h.y * e);
  31388. for (var h = 1, k = g.length; h < k; h++) a.lineTo(g[h].x * d, -g[h].y * e)
  31389. }
  31390. },
  31391. addChild: function(a, c, d) {
  31392. a instanceof ccui.Widget && this._supplyTheLayoutParameterLackToChild(a);
  31393. ccui.Widget.prototype.addChild.call(this, a, c, d);
  31394. this._doLayoutDirty = !0
  31395. },
  31396. removeChild: function(a, c) {
  31397. ccui.Widget.prototype.removeChild.call(this, a, c);
  31398. this._doLayoutDirty = !0
  31399. },
  31400. removeAllChildren: function(a) {
  31401. ccui.Widget.prototype.removeAllChildren.call(this, a);
  31402. this._doLayoutDirty = !0
  31403. },
  31404. removeAllChildrenWithCleanup: function(a) {
  31405. ccui.Widget.prototype.removeAllChildrenWithCleanup.call(this, a);
  31406. this._doLayoutDirty = !0
  31407. },
  31408. isClippingEnabled: function() {
  31409. return this._clippingEnabled
  31410. },
  31411. visit: function(a) {
  31412. if (this._visible)
  31413. if (this._adaptRenderers(), this._doLayout(), this._clippingEnabled) switch (this._clippingType) {
  31414. case ccui.Layout.CLIPPING_STENCIL:
  31415. this._stencilClippingVisit(a);
  31416. break;
  31417. case ccui.Layout.CLIPPING_SCISSOR:
  31418. this._scissorClippingVisit(a)
  31419. } else ccui.Widget.prototype.visit.call(this, a)
  31420. },
  31421. _stencilClippingVisit: null,
  31422. _stencilClippingVisitForWebGL: function(a) {
  31423. var c = a || cc._renderContext;
  31424. if (this._clippingStencil && this._clippingStencil.isVisible())
  31425. 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);
  31426. else {
  31427. ccui.Layout._layer++;
  31428. var d = 1 << ccui.Layout._layer,
  31429. e = d | d - 1;
  31430. a = c.isEnabled(c.STENCIL_TEST);
  31431. var f = c.getParameter(c.STENCIL_WRITEMASK),
  31432. g = c.getParameter(c.STENCIL_FUNC),
  31433. h = c.getParameter(c.STENCIL_REF),
  31434. k = c.getParameter(c.STENCIL_VALUE_MASK),
  31435. m = c.getParameter(c.STENCIL_FAIL),
  31436. n = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL),
  31437. q = c.getParameter(c.STENCIL_PASS_DEPTH_PASS);
  31438. c.enable(c.STENCIL_TEST);
  31439. c.stencilMask(d);
  31440. var r = c.getParameter(c.DEPTH_WRITEMASK);
  31441. c.depthMask(!1);
  31442. c.stencilFunc(c.NEVER, d, d);
  31443. c.stencilOp(c.ZERO, c.KEEP, c.KEEP);
  31444. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  31445. cc.kmGLPushMatrix();
  31446. cc.kmGLLoadIdentity();
  31447. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  31448. cc.kmGLPushMatrix();
  31449. cc.kmGLLoadIdentity();
  31450. cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255));
  31451. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  31452. cc.kmGLPopMatrix();
  31453. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  31454. cc.kmGLPopMatrix();
  31455. c.stencilFunc(c.NEVER, d, d);
  31456. c.stencilOp(c.REPLACE, c.KEEP, c.KEEP);
  31457. cc.kmGLPushMatrix();
  31458. this.transform();
  31459. this._clippingStencil.visit();
  31460. c.depthMask(r);
  31461. c.stencilFunc(c.EQUAL, e, e);
  31462. c.stencilOp(c.KEEP, c.KEEP, c.KEEP);
  31463. e = d = 0;
  31464. this.sortAllChildren();
  31465. this.sortAllProtectedChildren();
  31466. for (var r = this._children, t = this._protectedChildren, s = r.length, v = t.length, u; d < s; d++)
  31467. if ((u = r[d]) && 0 > u.getLocalZOrder()) u.visit();
  31468. else break;
  31469. for (; e < v; e++)
  31470. if ((u = t[e]) && 0 > u.getLocalZOrder()) u.visit();
  31471. else break;
  31472. for (this.draw(); d < s; d++) r[d].visit();
  31473. for (; e < v; e++) t[e].visit();
  31474. c.stencilFunc(g, h, k);
  31475. c.stencilOp(m, n, q);
  31476. c.stencilMask(f);
  31477. a || c.disable(c.STENCIL_TEST);
  31478. ccui.Layout._layer--;
  31479. cc.kmGLPopMatrix()
  31480. }
  31481. },
  31482. _stencilClippingVisitForCanvas: function(a) {
  31483. if (this._clippingStencil && this._clippingStencil.isVisible()) {
  31484. a = a || cc._renderContext;
  31485. if (this._clippingStencil instanceof cc.Sprite) {
  31486. var c = a.canvas,
  31487. d = ccui.Layout._getSharedCache();
  31488. d.width = c.width;
  31489. d.height = c.height;
  31490. d.getContext("2d").drawImage(c, 0, 0);
  31491. a.save();
  31492. cc.ProtectedNode.prototype.visit.call(this, a);
  31493. a.globalCompositeOperation = "destination-in";
  31494. this.transform(a);
  31495. this._clippingStencil.visit();
  31496. a.restore();
  31497. a.save();
  31498. a.setTransform(1, 0, 0, 1, 0, 0);
  31499. a.globalCompositeOperation = "destination-over";
  31500. a.drawImage(d, 0, 0)
  31501. } else {
  31502. var d = this._children,
  31503. e;
  31504. a.save();
  31505. this.transform(a);
  31506. this._clippingStencil.visit(a);
  31507. a.clip();
  31508. this.sortAllChildren();
  31509. this.sortAllProtectedChildren();
  31510. for (var f, g = this._protectedChildren, h = d.length, k = g.length, c = 0; c < h; c++)
  31511. if ((e = d[c]) && 0 > e._localZOrder) e.visit(a);
  31512. else break;
  31513. for (f = 0; f < k; f++)
  31514. if ((e = g[f]) && 0 > e._localZOrder) e.visit(a);
  31515. else break;
  31516. for (; c < h; c++) d[c].visit(a);
  31517. for (; f < k; f++) g[f].visit(a)
  31518. }
  31519. a.restore()
  31520. }
  31521. },
  31522. _scissorClippingVisit: null,
  31523. _scissorClippingVisitForWebGL: function(a) {
  31524. var c = this._getClippingRect();
  31525. a = a || cc._renderContext;
  31526. this._handleScissor && a.enable(a.SCISSOR_TEST);
  31527. cc.view.setScissorInPoints(c.x, c.y, c.width, c.height);
  31528. cc.Node.prototype.visit.call(this);
  31529. this._handleScissor && a.disable(a.SCISSOR_TEST)
  31530. },
  31531. setClippingEnabled: function(a) {
  31532. if (a != this._clippingEnabled) switch (this._clippingEnabled = a, this._clippingType) {
  31533. case ccui.Layout.CLIPPING_STENCIL:
  31534. if (a) {
  31535. this._clippingStencil = cc.DrawNode.create();
  31536. cc._renderType === cc._RENDER_TYPE_CANVAS && (this._clippingStencil.draw = this.__stencilDraw.bind(this));
  31537. if (this._running) this._clippingStencil.onEnter();
  31538. this._setStencilClippingSize(this._contentSize)
  31539. } else {
  31540. if (this._running && this._clippingStencil) this._clippingStencil.onExit();
  31541. this._clippingStencil = null
  31542. }
  31543. }
  31544. },
  31545. setClippingType: function(a) {
  31546. if (a != this._clippingType) {
  31547. var c = this.isClippingEnabled();
  31548. this.setClippingEnabled(!1);
  31549. this._clippingType = a;
  31550. this.setClippingEnabled(c)
  31551. }
  31552. },
  31553. getClippingType: function() {
  31554. return this._clippingType
  31555. },
  31556. _setStencilClippingSize: function(a) {
  31557. if (this._clippingEnabled && this._clippingType == ccui.Layout.CLIPPING_STENCIL) {
  31558. var c = [];
  31559. c[0] = cc.p(0, 0);
  31560. c[1] = cc.p(a.width, 0);
  31561. c[2] = cc.p(a.width, a.height);
  31562. c[3] = cc.p(0, a.height);
  31563. a = cc.color.GREEN;
  31564. this._clippingStencil.clear();
  31565. this._clippingStencil.drawPoly(c, 4, a, 0, a)
  31566. }
  31567. },
  31568. rendererVisitCallBack: function() {
  31569. this._doLayout()
  31570. },
  31571. _getClippingRect: function() {
  31572. if (this._clippingRectDirty) {
  31573. 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;)
  31574. if ((c = c.getParent()) && c instanceof ccui.Layout && c.isClippingEnabled()) {
  31575. this._clippingParent = c;
  31576. break
  31577. }
  31578. if (this._clippingParent) {
  31579. var c = this._clippingParent._getClippingRect(),
  31580. f = a.x - d * this._anchorPoint.x,
  31581. g = a.y - e * this._anchorPoint.y,
  31582. h = d,
  31583. k = e,
  31584. m = a.x - c.x;
  31585. 0 > m && (f = c.x, h += m);
  31586. d = a.x + d - (c.x + c.width);
  31587. 0 < d && (h -= d);
  31588. d = a.y + e - (c.y + c.height);
  31589. 0 < d && (k -= d);
  31590. a = a.y - c.y;
  31591. 0 > a && (g = c.x, k += a);
  31592. 0 > h && (h = 0);
  31593. 0 > k && (k = 0);
  31594. this._clippingRect.x = f;
  31595. this._clippingRect.y = g;
  31596. this._clippingRect.width = h;
  31597. this._clippingRect.height = k
  31598. } 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;
  31599. this._clippingRectDirty = !1
  31600. }
  31601. return this._clippingRect
  31602. },
  31603. _onSizeChanged: function() {
  31604. ccui.Widget.prototype._onSizeChanged.call(this);
  31605. var a = this._contentSize;
  31606. this._setStencilClippingSize(a);
  31607. this._clippingRectDirty = this._doLayoutDirty = !0;
  31608. this._backGroundImage && (this._backGroundImage.setPosition(0.5 * a.width, 0.5 * a.height), this._backGroundScale9Enabled && this._backGroundImage instanceof cc.Scale9Sprite && this._backGroundImage.setPreferredSize(a));
  31609. this._colorRender && this._colorRender.setContentSize(a);
  31610. this._gradientRender && this._gradientRender.setContentSize(a)
  31611. },
  31612. setBackGroundImageScale9Enabled: function(a) {
  31613. 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))
  31614. },
  31615. isBackGroundImageScale9Enabled: function() {
  31616. return this._backGroundScale9Enabled
  31617. },
  31618. setBackGroundImage: function(a, c) {
  31619. if (a) {
  31620. c = c || ccui.Widget.LOCAL_TEXTURE;
  31621. null == this._backGroundImage && this._addBackGroundImage();
  31622. this._backGroundImageFileName = a;
  31623. this._bgImageTexType = c;
  31624. var d = this._backGroundImage;
  31625. if (this._backGroundScale9Enabled) {
  31626. switch (this._bgImageTexType) {
  31627. case ccui.Widget.LOCAL_TEXTURE:
  31628. d.initWithFile(a);
  31629. break;
  31630. case ccui.Widget.PLIST_TEXTURE:
  31631. d.initWithSpriteFrameName(a)
  31632. }
  31633. d.setPreferredSize(this._contentSize)
  31634. } else switch (this._bgImageTexType) {
  31635. case ccui.Widget.LOCAL_TEXTURE:
  31636. d.initWithFile(a);
  31637. break;
  31638. case ccui.Widget.PLIST_TEXTURE:
  31639. d.initWithSpriteFrameName(a)
  31640. }
  31641. this._backGroundImageTextureSize = d.getContentSize();
  31642. d.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height);
  31643. this._updateBackGroundImageColor()
  31644. }
  31645. },
  31646. setBackGroundImageCapInsets: function(a) {
  31647. this._backGroundImageCapInsets = a;
  31648. this._backGroundScale9Enabled && this._backGroundImage.setCapInsets(a)
  31649. },
  31650. getBackGroundImageCapInsets: function() {
  31651. return this._backGroundImageCapInsets
  31652. },
  31653. _supplyTheLayoutParameterLackToChild: function(a) {
  31654. if (a) switch (this._layoutType) {
  31655. case ccui.Layout.LINEAR_HORIZONTAL:
  31656. case ccui.Layout.LINEAR_VERTICAL:
  31657. var c = a.getLayoutParameter(ccui.LayoutParameter.LINEAR);
  31658. c || a.setLayoutParameter(ccui.LinearLayoutParameter.create());
  31659. break;
  31660. case ccui.Layout.RELATIVE:
  31661. (c = a.getLayoutParameter(ccui.LayoutParameter.RELATIVE)) || a.setLayoutParameter(ccui.RelativeLayoutParameter.create())
  31662. }
  31663. },
  31664. _addBackGroundImage: function() {
  31665. this._backGroundScale9Enabled ? (this._backGroundImage = cc.Scale9Sprite.create(), this._backGroundImage.setPreferredSize(this._contentSize)) : this._backGroundImage = cc.Sprite.create();
  31666. this.addProtectedChild(this._backGroundImage, ccui.Layout.BACKGROUND_IMAGE_ZORDER, -1);
  31667. this._backGroundImage.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  31668. },
  31669. removeBackGroundImage: function() {
  31670. this._backGroundImage && (this.removeProtectedChild(this._backGroundImage), this._backGroundImage = null, this._backGroundImageFileName = "", this._backGroundImageTextureSize.width = 0, this._backGroundImageTextureSize.height = 0)
  31671. },
  31672. setBackGroundColorType: function(a) {
  31673. if (this._colorType != a) {
  31674. switch (this._colorType) {
  31675. case ccui.Layout.BG_COLOR_NONE:
  31676. this._colorRender && (this.removeProtectedChild(this._colorRender), this._colorRender = null);
  31677. this._gradientRender && (this.removeProtectedChild(this._gradientRender), this._gradientRender = null);
  31678. break;
  31679. case ccui.Layout.BG_COLOR_SOLID:
  31680. this._colorRender && (this.removeProtectedChild(this._colorRender), this._colorRender = null);
  31681. break;
  31682. case ccui.Layout.BG_COLOR_GRADIENT:
  31683. this._gradientRender && (this.removeProtectedChild(this._gradientRender), this._gradientRender = null)
  31684. }
  31685. this._colorType = a;
  31686. switch (this._colorType) {
  31687. case ccui.Layout.BG_COLOR_SOLID:
  31688. this._colorRender = cc.LayerColor.create();
  31689. this._colorRender.setContentSize(this._contentSize);
  31690. this._colorRender.setOpacity(this._opacity);
  31691. this._colorRender.setColor(this._color);
  31692. this.addProtectedChild(this._colorRender, ccui.Layout.BACKGROUND_RENDERER_ZORDER, -1);
  31693. break;
  31694. case ccui.Layout.BG_COLOR_GRADIENT:
  31695. 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)
  31696. }
  31697. }
  31698. },
  31699. getBackGroundColorType: function() {
  31700. return this._colorType
  31701. },
  31702. setBackGroundColor: function(a, c) {
  31703. 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))
  31704. },
  31705. getBackGroundColor: function() {
  31706. var a = this._color;
  31707. return cc.color(a.r, a.g, a.b, a.a)
  31708. },
  31709. getBackGroundStartColor: function() {
  31710. var a = this._startColor;
  31711. return cc.color(a.r, a.g, a.b, a.a)
  31712. },
  31713. getBackGroundEndColor: function() {
  31714. var a = this._endColor;
  31715. return cc.color(a.r, a.g, a.b, a.a)
  31716. },
  31717. setBackGroundColorOpacity: function(a) {
  31718. this._opacity = a;
  31719. switch (this._colorType) {
  31720. case ccui.Layout.BG_COLOR_SOLID:
  31721. this._colorRender.setOpacity(a);
  31722. break;
  31723. case ccui.Layout.BG_COLOR_GRADIENT:
  31724. this._gradientRender.setOpacity(a)
  31725. }
  31726. },
  31727. getBackGroundColorOpacity: function() {
  31728. return this._opacity
  31729. },
  31730. setBackGroundColorVector: function(a) {
  31731. this._alongVector.x = a.x;
  31732. this._alongVector.y = a.y;
  31733. this._gradientRender && this._gradientRender.setVector(a)
  31734. },
  31735. getBackGroundColorVector: function() {
  31736. return this._alongVector
  31737. },
  31738. setBackGroundImageColor: function(a) {
  31739. this._backGroundImageColor.r = a.r;
  31740. this._backGroundImageColor.g = a.g;
  31741. this._backGroundImageColor.b = a.b;
  31742. this._updateBackGroundImageColor()
  31743. },
  31744. setBackGroundImageOpacity: function(a) {
  31745. this._backGroundImageColor.a = a;
  31746. this.getBackGroundImageColor()
  31747. },
  31748. getBackGroundImageColor: function() {
  31749. var a = this._backGroundImageColor;
  31750. return cc.color(a.r, a.g, a.b, a.a)
  31751. },
  31752. getBackGroundImageOpacity: function() {
  31753. return this._backGroundImageColor.a
  31754. },
  31755. _updateBackGroundImageColor: function() {
  31756. this._backGroundImage && this._backGroundImage.setColor(this._backGroundImageColor)
  31757. },
  31758. getBackGroundImageTextureSize: function() {
  31759. return this._backGroundImageTextureSize
  31760. },
  31761. setLayoutType: function(a) {
  31762. this._layoutType = a;
  31763. a = this._children;
  31764. for (var c = null, d = 0; d < a.length; d++) c = a[d], c instanceof ccui.Widget && this._supplyTheLayoutParameterLackToChild(c);
  31765. this._doLayoutDirty = !0
  31766. },
  31767. getLayoutType: function() {
  31768. return this._layoutType
  31769. },
  31770. requestDoLayout: function() {
  31771. this._doLayoutDirty = !0
  31772. },
  31773. _doLayout: function() {
  31774. if (this._doLayoutDirty) {
  31775. this.sortAllChildren();
  31776. var a = ccui.getLayoutManager(this._layoutType);
  31777. a && a._doLayout(this);
  31778. this._doLayoutDirty = !1
  31779. }
  31780. },
  31781. _getLayoutContentSize: function() {
  31782. return this.getContentSize()
  31783. },
  31784. _getLayoutElements: function() {
  31785. return this.getChildren()
  31786. },
  31787. _onBeforeVisitStencil: function() {},
  31788. _drawFullScreenQuadClearStencil: function() {},
  31789. _onAfterDrawStencil: function() {},
  31790. _onAfterVisitStencil: function() {},
  31791. _onAfterVisitScissor: function() {},
  31792. _onAfterVisitScissor: function() {},
  31793. _updateBackGroundImageOpacity: function() {
  31794. this._backGroundImage && this._backGroundImage.setOpacity(this._backGroundImageOpacity)
  31795. },
  31796. _updateBackGroundImageRGBA: function() {
  31797. this._backGroundImage && (this._backGroundImage.setColor(this._backGroundImageColor), this._backGroundImage.setOpacity(this._backGroundImageOpacity))
  31798. },
  31799. _getLayoutAccumulatedSize: function() {
  31800. for (var a = this.getChildren(), c = cc.size(0, 0), d = 0, e, f = 0, g = a.length; f < g; f++)
  31801. if (e = a[f], null != e && e instanceof ccui.Layout) e = e._getLayoutAccumulatedSize(), c.width += e.width, c.height += e.height;
  31802. else if (e instanceof ccui.Widget) {
  31803. d++;
  31804. var h = e.getLayoutParameter().getMargin();
  31805. e = e.getContentSize();
  31806. c.width += e.width + 0.5 * (h.right + h.left);
  31807. c.height += e.height + 0.5 * (h.top + h.bottom)
  31808. }
  31809. a = this.getLayoutType();
  31810. a == ccui.Layout.LINEAR_HORIZONTAL && (c.height -= c.height / d * (d - 1));
  31811. a == ccui.Layout.LINEAR_VERTICAL && (c.width -= c.width / d * (d - 1));
  31812. return c
  31813. },
  31814. _findNearestChildWidgetIndex: function(a, c) {
  31815. if (null == c || c == this) return this._findFirstFocusEnabledWidgetIndex();
  31816. var d = 0,
  31817. e = this.getChildren(),
  31818. f = e.length,
  31819. g, h = cc.FLT_MAX,
  31820. k = 0;
  31821. if (a == ccui.Widget.LEFT || a == ccui.Widget.RIGHT || a == ccui.Widget.DOWN || a == ccui.Widget.UP) {
  31822. for (g = this._getWorldCenterPoint(c); d < f;) {
  31823. var m = e[d];
  31824. 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));
  31825. d++
  31826. }
  31827. return k
  31828. }
  31829. cc.log("invalid focus direction!");
  31830. return 0
  31831. },
  31832. _findFarthestChildWidgetIndex: function(a, c) {
  31833. if (null == c || c == this) return this._findFirstFocusEnabledWidgetIndex();
  31834. var d = 0,
  31835. e = this.getChildren(),
  31836. f = e.length,
  31837. g = -cc.FLT_MAX,
  31838. h = 0;
  31839. if (a == ccui.Widget.LEFT || a == ccui.Widget.RIGHT || a == ccui.Widget.DOWN || a == ccui.Widget.UP) {
  31840. for (var k = this._getWorldCenterPoint(c); d < f;) {
  31841. var m = e[d];
  31842. 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));
  31843. d++
  31844. }
  31845. return h
  31846. }
  31847. cc.log("invalid focus direction!!!");
  31848. return 0
  31849. },
  31850. _calculateNearestDistance: function(a) {
  31851. for (var c = cc.FLT_MAX, d = this._getWorldCenterPoint(a), e = this._children, f = 0, g = e.length; f < g; f++) {
  31852. var h = e[f];
  31853. if (h instanceof ccui.Layout) h = h._calculateNearestDistance(a);
  31854. else if (h instanceof ccui.Widget && h.isFocusEnabled()) h = cc.pLength(cc.pSub(this._getWorldCenterPoint(h), d));
  31855. else continue;
  31856. h < c && (c = h)
  31857. }
  31858. return c
  31859. },
  31860. _calculateFarthestDistance: function(a) {
  31861. for (var c = -cc.FLT_MAX, d = this._getWorldCenterPoint(a), e = this._children, f = 0, g = e.length; f < g; f++) {
  31862. var h = e[f];
  31863. if (h instanceof ccui.Layout) h = h._calculateFarthestDistance(a);
  31864. else if (h instanceof ccui.Widget && h.isFocusEnabled()) h = this._getWorldCenterPoint(h), h = cc.pLength(cc.pSub(h, d));
  31865. else continue;
  31866. h > c && (c = h)
  31867. }
  31868. return c
  31869. },
  31870. _findProperSearchingFunctor: function(a, c) {
  31871. if (null != c) {
  31872. var d = this._getWorldCenterPoint(c),
  31873. e = this._getWorldCenterPoint(this._findFirstNonLayoutWidget());
  31874. 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!")
  31875. }
  31876. },
  31877. _findFirstNonLayoutWidget: function() {
  31878. for (var a = this._children, c = 0, d = a.length; c < d; c++) {
  31879. var e = a[c];
  31880. if (e instanceof ccui.Layout) {
  31881. if (e = e._findFirstNonLayoutWidget()) return e
  31882. } else if (e instanceof cc.Widget) return e
  31883. }
  31884. return null
  31885. },
  31886. _findFirstFocusEnabledWidgetIndex: function() {
  31887. for (var a = 0, c = this.getChildren(), d = c.length; a < d;) {
  31888. var e = c[a];
  31889. if (e && e instanceof ccui.Widget && e.isFocusEnabled()) return a;
  31890. a++
  31891. }
  31892. return 0
  31893. },
  31894. _findFocusEnabledChildWidgetByIndex: function(a) {
  31895. var c = this._getChildWidgetByIndex(a);
  31896. return c ? c.isFocusEnabled() ? c : this._findFocusEnabledChildWidgetByIndex(a + 1) : null
  31897. },
  31898. _getWorldCenterPoint: function(a) {
  31899. var c = a instanceof ccui.Layout ? a._getLayoutAccumulatedSize() : a.getContentSize();
  31900. return a.convertToWorldSpace(cc.p(c.width / 2, c.height / 2))
  31901. },
  31902. _getNextFocusedWidget: function(a, c) {
  31903. var d = null,
  31904. d = this._children,
  31905. e = d.indexOf(c),
  31906. e = e + 1;
  31907. if (e < d.length) {
  31908. if (d = this._getChildWidgetByIndex(e)) {
  31909. if (d.isFocusEnabled()) {
  31910. if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
  31911. this.dispatchFocusEvent(c, d);
  31912. return d
  31913. }
  31914. return this._getNextFocusedWidget(a, d)
  31915. }
  31916. return c
  31917. }
  31918. if (this._loopFocus) {
  31919. if (this._checkFocusEnabledChild()) {
  31920. d = this._getChildWidgetByIndex(0);
  31921. if (d.isFocusEnabled()) {
  31922. if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
  31923. this.dispatchFocusEvent(c, d);
  31924. return d
  31925. }
  31926. return this._getNextFocusedWidget(a, d)
  31927. }
  31928. return c instanceof ccui.Layout ? c : this._focusedWidget
  31929. }
  31930. return this._isLastWidgetInContainer(c, a) ? this._isWidgetAncestorSupportLoopFocus(this, a) ? this.findNextFocusedWidget(a, this) : c instanceof ccui.Layout ? c : this._focusedWidget : this.findNextFocusedWidget(a, this)
  31931. },
  31932. _getPreviousFocusedWidget: function(a, c) {
  31933. var d = null,
  31934. d = this._children,
  31935. e = d.indexOf(c),
  31936. e = e - 1;
  31937. if (0 <= e) {
  31938. d = this._getChildWidgetByIndex(e);
  31939. if (d.isFocusEnabled()) {
  31940. if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
  31941. this.dispatchFocusEvent(c, d);
  31942. return d
  31943. }
  31944. return this._getPreviousFocusedWidget(a, d)
  31945. }
  31946. if (this._loopFocus) {
  31947. if (this._checkFocusEnabledChild()) {
  31948. e = d.length - 1;
  31949. d = this._getChildWidgetByIndex(e);
  31950. if (d.isFocusEnabled()) {
  31951. if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
  31952. this.dispatchFocusEvent(c, d);
  31953. return d
  31954. }
  31955. return this._getPreviousFocusedWidget(a, d)
  31956. }
  31957. return c instanceof ccui.Layout ? c : this._focusedWidget
  31958. }
  31959. return this._isLastWidgetInContainer(c, a) ? this._isWidgetAncestorSupportLoopFocus(this, a) ? this.findNextFocusedWidget(a, this) : c instanceof ccui.Layout ? c : this._focusedWidget : this.findNextFocusedWidget(a, this)
  31960. },
  31961. _getChildWidgetByIndex: function(a) {
  31962. for (var c = this._children, d = c.length, e = 0, f = a; a < d;) {
  31963. var g = c[a];
  31964. if (g && g instanceof ccui.Widget) return g;
  31965. e++;
  31966. a++
  31967. }
  31968. for (a = 0; a < f;) {
  31969. if ((d = c[a]) && d instanceof ccui.Widget) return d;
  31970. e++;
  31971. a++
  31972. }
  31973. return null
  31974. },
  31975. _isLastWidgetInContainer: function(a, c) {
  31976. var d = a.getParent();
  31977. if (d instanceof ccui.Layout) return !0;
  31978. var e = d.getChildren(),
  31979. f = e.indexOf(a);
  31980. if (d.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) {
  31981. if (c == ccui.Widget.LEFT) return 0 == f ? this._isLastWidgetInContainer(d, c) : !1;
  31982. if (c == ccui.Widget.RIGHT) return f == e.length - 1 ? this._isLastWidgetInContainer(d, c) : !1;
  31983. if (c == ccui.Widget.DOWN || c == ccui.Widget.UP) return this._isLastWidgetInContainer(d, c)
  31984. } else if (d.getLayoutType() == ccui.Layout.LINEAR_VERTICAL) {
  31985. if (c == ccui.Widget.UP) return 0 == f ? this._isLastWidgetInContainer(d, c) : !1;
  31986. if (c == ccui.Widget.DOWN) return f == e.length - 1 ? this._isLastWidgetInContainer(d, c) : !1;
  31987. if (c == ccui.Widget.LEFT || c == ccui.Widget.RIGHT) return this._isLastWidgetInContainer(d, c)
  31988. } else return cc.log("invalid layout Type"), !1
  31989. },
  31990. _isWidgetAncestorSupportLoopFocus: function(a, c) {
  31991. var d = a.getParent();
  31992. if (null == d) return !1;
  31993. if (d.isLoopFocus()) {
  31994. var e = d.getLayoutType();
  31995. if (e == ccui.Layout.LINEAR_HORIZONTAL) return c == ccui.Widget.LEFT || c == ccui.Widget.RIGHT ? !0 : this._isWidgetAncestorSupportLoopFocus(d, c);
  31996. if (e == ccui.Layout.LINEAR_VERTICAL) return c == ccui.Widget.DOWN || c == ccui.Widget.UP ? !0 : this._isWidgetAncestorSupportLoopFocus(d, c);
  31997. cc.assert(0, "invalid layout type")
  31998. } else return this._isWidgetAncestorSupportLoopFocus(d, c)
  31999. },
  32000. _passFocusToChild: function(a, c) {
  32001. if (this._checkFocusEnabledChild()) {
  32002. var d = ccui.Widget.getCurrentFocusedWidget();
  32003. this._findProperSearchingFunctor(a, d);
  32004. d = this.onPassFocusToChild(a, d);
  32005. d = this._getChildWidgetByIndex(d);
  32006. if (d instanceof ccui.Layout) return d._isFocusPassing = !0, d.findNextFocusedWidget(a, d);
  32007. this.dispatchFocusEvent(c, d);
  32008. return d
  32009. }
  32010. return this
  32011. },
  32012. _checkFocusEnabledChild: function() {
  32013. for (var a = this._children, c = 0, d = a.length; c < d; c++) {
  32014. var e = a[c];
  32015. if (e && e instanceof ccui.Widget && e.isFocusEnabled()) return !0
  32016. }
  32017. return !1
  32018. },
  32019. getDescription: function() {
  32020. return "Layout"
  32021. },
  32022. _createCloneInstance: function() {
  32023. return ccui.Layout.create()
  32024. },
  32025. _copyClonedWidgetChildren: function(a) {
  32026. ccui.Widget.prototype._copyClonedWidgetChildren.call(this, a)
  32027. },
  32028. _copySpecialProperties: function(a) {
  32029. 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)
  32030. }
  32031. });
  32032. ccui.Layout._init_once = null;
  32033. ccui.Layout._visit_once = null;
  32034. ccui.Layout._layer = -1;
  32035. ccui.Layout._sharedCache = null;
  32036. 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);
  32037. ccui.Layout._getSharedCache = function() {
  32038. return cc.ClippingNode._sharedCache || (cc.ClippingNode._sharedCache = cc.newElement("canvas"))
  32039. };
  32040. _p = ccui.Layout.prototype;
  32041. cc.defineGetterSetter(_p, "clippingEnabled", _p.isClippingEnabled, _p.setClippingEnabled);
  32042. cc.defineGetterSetter(_p, "clippingType", null, _p.setClippingType);
  32043. cc.defineGetterSetter(_p, "layoutType", _p.getLayoutType, _p.setLayoutType);
  32044. _p = null;
  32045. ccui.Layout.create = function() {
  32046. return new ccui.Layout
  32047. };
  32048. ccui.Layout.BG_COLOR_NONE = 0;
  32049. ccui.Layout.BG_COLOR_SOLID = 1;
  32050. ccui.Layout.BG_COLOR_GRADIENT = 2;
  32051. ccui.Layout.ABSOLUTE = 0;
  32052. ccui.Layout.LINEAR_VERTICAL = 1;
  32053. ccui.Layout.LINEAR_HORIZONTAL = 2;
  32054. ccui.Layout.RELATIVE = 3;
  32055. ccui.Layout.CLIPPING_STENCIL = 0;
  32056. ccui.Layout.CLIPPING_SCISSOR = 1;
  32057. ccui.Layout.BACKGROUND_IMAGE_ZORDER = -2;
  32058. ccui.Layout.BACKGROUND_RENDERER_ZORDER = -2;
  32059. ccui.Margin = ccui.Class.extend({
  32060. left: 0,
  32061. top: 0,
  32062. right: 0,
  32063. bottom: 0,
  32064. ctor: function(a, c, d, e) {
  32065. a && void 0 === c && (this.left = a.left, this.top = a.top, this.right = a.right, this.bottom = a.bottom);
  32066. void 0 !== e && (this.left = a, this.top = c, this.right = d, this.bottom = e)
  32067. },
  32068. setMargin: function(a, c, d, e) {
  32069. this.left = a;
  32070. this.top = c;
  32071. this.right = d;
  32072. this.bottom = e
  32073. },
  32074. equals: function(a) {
  32075. return this.left == a.left && this.top == a.top && this.right == a.right && this.bottom == a.bottom
  32076. }
  32077. });
  32078. ccui.MarginZero = function() {
  32079. return new ccui.Margin(0, 0, 0, 0)
  32080. };
  32081. ccui.LayoutParameter = ccui.Class.extend({
  32082. _margin: null,
  32083. _layoutParameterType: null,
  32084. ctor: function() {
  32085. this._margin = new ccui.Margin;
  32086. this._layoutParameterType = ccui.LayoutParameter.NONE
  32087. },
  32088. setMargin: function(a, c, d, e) {
  32089. "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)
  32090. },
  32091. getMargin: function() {
  32092. return this._margin
  32093. },
  32094. getLayoutType: function() {
  32095. return this._layoutParameterType
  32096. },
  32097. clone: function() {
  32098. var a = this._createCloneInstance();
  32099. a._copyProperties(this);
  32100. return a
  32101. },
  32102. _createCloneInstance: function() {
  32103. return ccui.LayoutParameter.create()
  32104. },
  32105. _copyProperties: function(a) {
  32106. this._margin.bottom = a._margin.bottom;
  32107. this._margin.left = a._margin.left;
  32108. this._margin.right = a._margin.right;
  32109. this._margin.top = a._margin.top
  32110. }
  32111. });
  32112. ccui.LayoutParameter.create = function() {
  32113. return new ccui.LayoutParameter
  32114. };
  32115. ccui.LayoutParameter.NONE = 0;
  32116. ccui.LayoutParameter.LINEAR = 1;
  32117. ccui.LayoutParameter.RELATIVE = 2;
  32118. ccui.LinearLayoutParameter = ccui.LayoutParameter.extend({
  32119. _linearGravity: null,
  32120. ctor: function() {
  32121. ccui.LayoutParameter.prototype.ctor.call(this);
  32122. this._linearGravity = ccui.LinearLayoutParameter.NONE;
  32123. this._layoutParameterType = ccui.LayoutParameter.LINEAR
  32124. },
  32125. setGravity: function(a) {
  32126. this._linearGravity = a
  32127. },
  32128. getGravity: function() {
  32129. return this._linearGravity
  32130. },
  32131. _createCloneInstance: function() {
  32132. return ccui.LinearLayoutParameter.create()
  32133. },
  32134. _copyProperties: function(a) {
  32135. ccui.LayoutParameter.prototype._copyProperties.call(this, a);
  32136. a instanceof ccui.LinearLayoutParameter && this.setGravity(a._linearGravity)
  32137. }
  32138. });
  32139. ccui.LinearLayoutParameter.create = function() {
  32140. return new ccui.LinearLayoutParameter
  32141. };
  32142. ccui.LinearLayoutParameter.NONE = 0;
  32143. ccui.LinearLayoutParameter.LEFT = 1;
  32144. ccui.LinearLayoutParameter.TOP = 2;
  32145. ccui.LinearLayoutParameter.RIGHT = 3;
  32146. ccui.LinearLayoutParameter.BOTTOM = 4;
  32147. ccui.LinearLayoutParameter.CENTER_VERTICAL = 5;
  32148. ccui.LinearLayoutParameter.CENTER_HORIZONTAL = 6;
  32149. ccui.RelativeLayoutParameter = ccui.LayoutParameter.extend({
  32150. _relativeAlign: null,
  32151. _relativeWidgetName: "",
  32152. _relativeLayoutName: "",
  32153. _put: !1,
  32154. ctor: function() {
  32155. ccui.LayoutParameter.prototype.ctor.call(this);
  32156. this._relativeAlign = ccui.RelativeLayoutParameter.NONE;
  32157. this._relativeLayoutName = this._relativeWidgetName = "";
  32158. this._put = !1;
  32159. this._layoutParameterType = ccui.LayoutParameter.RELATIVE
  32160. },
  32161. setAlign: function(a) {
  32162. this._relativeAlign = a
  32163. },
  32164. getAlign: function() {
  32165. return this._relativeAlign
  32166. },
  32167. setRelativeToWidgetName: function(a) {
  32168. this._relativeWidgetName = a
  32169. },
  32170. getRelativeToWidgetName: function() {
  32171. return this._relativeWidgetName
  32172. },
  32173. setRelativeName: function(a) {
  32174. this._relativeLayoutName = a
  32175. },
  32176. getRelativeName: function() {
  32177. return this._relativeLayoutName
  32178. },
  32179. _createCloneInstance: function() {
  32180. return ccui.RelativeLayoutParameter.create()
  32181. },
  32182. _copyProperties: function(a) {
  32183. ccui.LayoutParameter.prototype._copyProperties.call(this, a);
  32184. a instanceof ccui.RelativeLayoutParameter && (this.setAlign(a._relativeAlign), this.setRelativeToWidgetName(a._relativeWidgetName), this.setRelativeName(a._relativeLayoutName))
  32185. }
  32186. });
  32187. ccui.RelativeLayoutParameter.create = function() {
  32188. return new ccui.RelativeLayoutParameter
  32189. };
  32190. ccui.RelativeLayoutParameter.NONE = 0;
  32191. ccui.RelativeLayoutParameter.PARENT_TOP_LEFT = 1;
  32192. ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL = 2;
  32193. ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT = 3;
  32194. ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL = 4;
  32195. ccui.RelativeLayoutParameter.CENTER_IN_PARENT = 5;
  32196. ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL = 6;
  32197. ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM = 7;
  32198. ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL = 8;
  32199. ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM = 9;
  32200. ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN = 10;
  32201. ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER = 11;
  32202. ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN = 12;
  32203. ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN = 13;
  32204. ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER = 14;
  32205. ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN = 15;
  32206. ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN = 16;
  32207. ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17;
  32208. ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18;
  32209. ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19;
  32210. ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20;
  32211. ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21;
  32212. ccui.LINEAR_GRAVITY_NONE = 0;
  32213. ccui.LINEAR_GRAVITY_LEFT = 1;
  32214. ccui.LINEAR_GRAVITY_TOP = 2;
  32215. ccui.LINEAR_GRAVITY_RIGHT = 3;
  32216. ccui.LINEAR_GRAVITY_BOTTOM = 4;
  32217. ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5;
  32218. ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6;
  32219. ccui.RELATIVE_ALIGN_NONE = 0;
  32220. ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1;
  32221. ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2;
  32222. ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3;
  32223. ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4;
  32224. ccui.RELATIVE_ALIGN_PARENT_CENTER = 5;
  32225. ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6;
  32226. ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7;
  32227. ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8;
  32228. ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9;
  32229. ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10;
  32230. ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11;
  32231. ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12;
  32232. ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13;
  32233. ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14;
  32234. ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15;
  32235. ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16;
  32236. ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17;
  32237. ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18;
  32238. ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19;
  32239. ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20;
  32240. ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21;
  32241. ccui.getLayoutManager = function(a) {
  32242. switch (a) {
  32243. case ccui.Layout.LINEAR_VERTICAL:
  32244. return ccui.linearVerticalLayoutManager;
  32245. case ccui.Layout.LINEAR_HORIZONTAL:
  32246. return ccui.linearHorizontalLayoutManager;
  32247. case ccui.Layout.RELATIVE:
  32248. return ccui.relativeLayoutManager
  32249. }
  32250. return null
  32251. };
  32252. ccui.linearVerticalLayoutManager = {
  32253. _doLayout: function(a) {
  32254. var c = a._getLayoutContentSize();
  32255. a = a._getLayoutElements();
  32256. for (var d = c.height, e = 0, f = a.length; e < f; e++) {
  32257. var g = a[e];
  32258. if (g) {
  32259. var h = g.getLayoutParameter();
  32260. if (h) {
  32261. var k = h.getGravity(),
  32262. m = g.getAnchorPoint(),
  32263. n = g.getContentSize(),
  32264. q = m.x * n.width,
  32265. d = d - (1 - m.y) * n.height;
  32266. switch (k) {
  32267. case ccui.LinearLayoutParameter.RIGHT:
  32268. q = c.width - (1 - m.x) * n.width;
  32269. break;
  32270. case ccui.LinearLayoutParameter.CENTER_HORIZONTAL:
  32271. q = c.width / 2 - n.width * (0.5 - m.x)
  32272. }
  32273. h = h.getMargin();
  32274. q += h.left;
  32275. d -= h.top;
  32276. g.setPosition(q, d);
  32277. d = g.getPositionY() - g.getAnchorPoint().y * g.getContentSize().height - h.bottom
  32278. }
  32279. }
  32280. }
  32281. }
  32282. };
  32283. ccui.linearHorizontalLayoutManager = {
  32284. _doLayout: function(a) {
  32285. var c = a._getLayoutContentSize();
  32286. a = a._getLayoutElements();
  32287. for (var d = 0, e = 0, f = a.length; e < f; e++) {
  32288. var g = a[e];
  32289. if (g) {
  32290. var h = g.getLayoutParameter();
  32291. if (h) {
  32292. var k = h.getGravity(),
  32293. m = g.getAnchorPoint(),
  32294. n = g.getSize(),
  32295. d = d + m.x * n.width,
  32296. q = c.height - (1 - m.y) * n.height;
  32297. switch (k) {
  32298. case ccui.LinearLayoutParameter.BOTTOM:
  32299. q = m.y * n.height;
  32300. break;
  32301. case ccui.LinearLayoutParameter.CENTER_VERTICAL:
  32302. q = c.height / 2 - n.height * (0.5 - m.y)
  32303. }
  32304. h = h.getMargin();
  32305. d += h.left;
  32306. q -= h.top;
  32307. g.setPosition(d, q);
  32308. d = g.getRightBoundary() + h.right
  32309. }
  32310. }
  32311. }
  32312. }
  32313. };
  32314. ccui.relativeLayoutManager = {
  32315. _unlayoutChildCount: 0,
  32316. _widgetChildren: [],
  32317. _widget: null,
  32318. _finalPositionX: 0,
  32319. _finalPositionY: 0,
  32320. _relativeWidgetLP: null,
  32321. _doLayout: function(a) {
  32322. for (var c = this._widgetChildren = this._getAllWidgets(a); 0 < this._unlayoutChildCount;) {
  32323. for (var d = 0, e = c.length; d < e; d++) {
  32324. this._widget = c[d];
  32325. var f = this._widget.getLayoutParameter();
  32326. f && !f._put && this._calculateFinalPositionWithRelativeWidget(a) && (this._calculateFinalPositionWithRelativeAlign(), this._widget.setPosition(this._finalPositionX, this._finalPositionY), f._put = !0)
  32327. }
  32328. this._unlayoutChildCount--
  32329. }
  32330. this._widgetChildren.length = 0
  32331. },
  32332. _getAllWidgets: function(a) {
  32333. a = a._getLayoutElements();
  32334. for (var c = this._widgetChildren, d = c.length = 0, e = a.length; d < e; d++) {
  32335. var f = a[d];
  32336. f && (f.getLayoutParameter()._put = !1, this._unlayoutChildCount++, c.push(f))
  32337. }
  32338. return c
  32339. },
  32340. _getRelativeWidget: function(a) {
  32341. var c = null;
  32342. if ((a = a.getLayoutParameter().getRelativeToWidgetName()) && 0 != a.length)
  32343. for (var d = this._widgetChildren, e = 0, f = d.length; e < f; e++) {
  32344. var g = d[e];
  32345. if (g) {
  32346. var h = g.getLayoutParameter();
  32347. if (h && h.getRelativeName() == a) {
  32348. c = g;
  32349. this._relativeWidgetLP = h;
  32350. break
  32351. }
  32352. }
  32353. }
  32354. return c
  32355. },
  32356. _calculateFinalPositionWithRelativeWidget: function(a) {
  32357. var c = this._widget,
  32358. d = c.getAnchorPoint(),
  32359. e = c.getContentSize();
  32360. this._finalPositionY = this._finalPositionX = 0;
  32361. var f = this._getRelativeWidget(c),
  32362. c = c.getLayoutParameter().getAlign();
  32363. a = a._getLayoutContentSize();
  32364. switch (c) {
  32365. case ccui.RelativeLayoutParameter.NONE:
  32366. case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:
  32367. this._finalPositionX = d.x * e.width;
  32368. this._finalPositionY = a.height - (1 - d.y) * e.height;
  32369. break;
  32370. case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:
  32371. this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
  32372. this._finalPositionY = a.height - (1 - d.y) * e.height;
  32373. break;
  32374. case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:
  32375. this._finalPositionX = a.width - (1 - d.x) * e.width;
  32376. this._finalPositionY = a.height - (1 - d.y) * e.height;
  32377. break;
  32378. case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:
  32379. this._finalPositionX = d.x * e.width;
  32380. this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
  32381. break;
  32382. case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:
  32383. this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
  32384. this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
  32385. break;
  32386. case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:
  32387. this._finalPositionX = a.width - (1 - d.x) * e.width;
  32388. this._finalPositionY = 0.5 * a.height - e.height * (0.5 - d.y);
  32389. break;
  32390. case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:
  32391. this._finalPositionX = d.x * e.width;
  32392. this._finalPositionY = d.y * e.height;
  32393. break;
  32394. case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:
  32395. this._finalPositionX = 0.5 * a.width - e.width * (0.5 - d.x);
  32396. this._finalPositionY = d.y * e.height;
  32397. break;
  32398. case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:
  32399. this._finalPositionX = a.width - (1 - d.x) * e.width;
  32400. this._finalPositionY = d.y * e.height;
  32401. break;
  32402. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:
  32403. if (f) {
  32404. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32405. this._finalPositionY = f.getTopBoundary() + d.y * e.height;
  32406. this._finalPositionX = f.getLeftBoundary() + d.x * e.width
  32407. }
  32408. break;
  32409. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:
  32410. if (f) {
  32411. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32412. a = f.getContentSize();
  32413. this._finalPositionY = f.getTopBoundary() + d.y * e.height;
  32414. this._finalPositionX = f.getLeftBoundary() + 0.5 * a.width + d.x * e.width - 0.5 * e.width
  32415. }
  32416. break;
  32417. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:
  32418. if (f) {
  32419. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32420. this._finalPositionY = f.getTopBoundary() + d.y * e.height;
  32421. this._finalPositionX = f.getRightBoundary() - (1 - d.x) * e.width
  32422. }
  32423. break;
  32424. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:
  32425. if (f) {
  32426. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32427. this._finalPositionY = f.getTopBoundary() - (1 - d.y) * e.height;
  32428. this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width
  32429. }
  32430. break;
  32431. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:
  32432. if (f) {
  32433. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32434. a = f.getContentSize();
  32435. this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width;
  32436. this._finalPositionY = f.getBottomBoundary() + 0.5 * a.height + d.y * e.height - 0.5 * e.height
  32437. }
  32438. break;
  32439. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:
  32440. if (f) {
  32441. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32442. this._finalPositionY = f.getBottomBoundary() + d.y * e.height;
  32443. this._finalPositionX = f.getLeftBoundary() - (1 - d.x) * e.width
  32444. }
  32445. break;
  32446. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:
  32447. if (f) {
  32448. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32449. this._finalPositionY = f.getTopBoundary() - (1 - d.y) * e.height;
  32450. this._finalPositionX = f.getRightBoundary() + d.x * e.width
  32451. }
  32452. break;
  32453. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:
  32454. if (f) {
  32455. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32456. a = f.getContentSize();
  32457. this._finalPositionX = f.getRightBoundary() + d.x * e.width;
  32458. this._finalPositionY = f.getBottomBoundary() + 0.5 * a.height + d.y * e.height - 0.5 * e.height
  32459. }
  32460. break;
  32461. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:
  32462. if (f) {
  32463. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32464. this._finalPositionY = f.getBottomBoundary() + d.y * e.height;
  32465. this._finalPositionX = f.getRightBoundary() + d.x * e.width
  32466. }
  32467. break;
  32468. case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:
  32469. if (f) {
  32470. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32471. this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
  32472. this._finalPositionX = f.getLeftBoundary() + d.x * e.width
  32473. }
  32474. break;
  32475. case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:
  32476. if (f) {
  32477. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32478. a = f.getContentSize();
  32479. this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
  32480. this._finalPositionX = f.getLeftBoundary() + 0.5 * a.width + d.x * e.width - 0.5 * e.width
  32481. }
  32482. break;
  32483. case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:
  32484. if (f) {
  32485. if (this._relativeWidgetLP && !this._relativeWidgetLP._put) return !1;
  32486. this._finalPositionY = f.getBottomBoundary() - (1 - d.y) * e.height;
  32487. this._finalPositionX = f.getRightBoundary() - (1 - d.x) * e.width
  32488. }
  32489. }
  32490. return !0
  32491. },
  32492. _calculateFinalPositionWithRelativeAlign: function() {
  32493. var a = this._widget.getLayoutParameter(),
  32494. c = a.getMargin();
  32495. switch (a.getAlign()) {
  32496. case ccui.RelativeLayoutParameter.NONE:
  32497. case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:
  32498. this._finalPositionX += c.left;
  32499. this._finalPositionY -= c.top;
  32500. break;
  32501. case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:
  32502. this._finalPositionY -= c.top;
  32503. break;
  32504. case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:
  32505. this._finalPositionX -= c.right;
  32506. this._finalPositionY -= c.top;
  32507. break;
  32508. case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:
  32509. this._finalPositionX += c.left;
  32510. break;
  32511. case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:
  32512. this._finalPositionX -= c.right;
  32513. break;
  32514. case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:
  32515. this._finalPositionX += c.left;
  32516. this._finalPositionY += c.bottom;
  32517. break;
  32518. case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:
  32519. this._finalPositionY += c.bottom;
  32520. break;
  32521. case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:
  32522. this._finalPositionX -= c.right;
  32523. this._finalPositionY += c.bottom;
  32524. break;
  32525. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:
  32526. this._finalPositionY += c.bottom;
  32527. this._finalPositionX += c.left;
  32528. break;
  32529. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:
  32530. this._finalPositionY += c.bottom;
  32531. this._finalPositionX -= c.right;
  32532. break;
  32533. case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:
  32534. this._finalPositionY += c.bottom;
  32535. break;
  32536. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:
  32537. this._finalPositionX -= c.right;
  32538. this._finalPositionY -= c.top;
  32539. break;
  32540. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:
  32541. this._finalPositionX -= c.right;
  32542. this._finalPositionY += c.bottom;
  32543. break;
  32544. case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:
  32545. this._finalPositionX -= c.right;
  32546. break;
  32547. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:
  32548. this._finalPositionX += c.left;
  32549. this._finalPositionY -= c.top;
  32550. break;
  32551. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:
  32552. this._finalPositionX += c.left;
  32553. this._finalPositionY += c.bottom;
  32554. break;
  32555. case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:
  32556. this._finalPositionX += c.left;
  32557. break;
  32558. case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:
  32559. this._finalPositionY -= c.top;
  32560. this._finalPositionX += c.left;
  32561. break;
  32562. case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:
  32563. this._finalPositionY -= c.top;
  32564. this._finalPositionX -= c.right;
  32565. break;
  32566. case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:
  32567. this._finalPositionY -= c.top
  32568. }
  32569. }
  32570. };
  32571. ccui.HBox = ccui.Layout.extend({
  32572. init: function() {
  32573. return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL), !0) : !1
  32574. },
  32575. initWithSize: function(a) {
  32576. return this.init() ? (this.setContentSize(a), !0) : !1
  32577. }
  32578. });
  32579. ccui.HBox.create = function(a) {
  32580. var c = new ccui.HBox;
  32581. if (a) {
  32582. if (c.initWithSize(a)) return c
  32583. } else if (c.init()) return c;
  32584. return null
  32585. };
  32586. ccui.RelativeBox = ccui.Layout.extend({
  32587. init: function() {
  32588. return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.RELATIVE), !0) : !1
  32589. },
  32590. initWithSize: function(a) {
  32591. return this.init() ? (this.setContentSize(a), !0) : !1
  32592. }
  32593. });
  32594. ccui.RelativeBox.create = function(a) {
  32595. var c = new ccui.RelativeBox;
  32596. if (a) {
  32597. if (c.initWithSize(a)) return c
  32598. } else if (c.init()) return c;
  32599. return null
  32600. };
  32601. ccui.VBox = ccui.Layout.extend({
  32602. init: function() {
  32603. return ccui.Layout.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_VERTICAL), !0) : !1
  32604. },
  32605. initWithSize: function(a) {
  32606. return this.init() ? (this.setContentSize(a), !0) : !1
  32607. }
  32608. });
  32609. ccui.VBox.create = function(a) {
  32610. var c = new ccui.VBox;
  32611. if (a) {
  32612. if (c.initWithSize(a)) return c
  32613. } else if (c.init()) return c;
  32614. return null
  32615. };
  32616. ccui.helper = {
  32617. seekWidgetByTag: function(a, c) {
  32618. if (!a) return null;
  32619. if (a.getTag() == c) return a;
  32620. for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
  32621. var g = ccui.helper.seekWidgetByTag(d[f], c);
  32622. if (null != g) return g
  32623. }
  32624. return null
  32625. },
  32626. seekWidgetByName: function(a, c) {
  32627. if (!a) return null;
  32628. if (a.getName() == c) return a;
  32629. for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
  32630. var g = ccui.helper.seekWidgetByName(d[f], c);
  32631. if (null != g) return g
  32632. }
  32633. return null
  32634. },
  32635. seekWidgetByRelativeName: function(a, c) {
  32636. if (!a) return null;
  32637. for (var d = a.getChildren(), e = d.length, f = 0; f < e; f++) {
  32638. var g = d[f],
  32639. h = g.getLayoutParameter(ccui.LayoutParameter.RELATIVE);
  32640. if (h && h.getRelativeName() == c) return g
  32641. }
  32642. return null
  32643. },
  32644. seekActionWidgetByActionTag: function(a, c) {
  32645. if (!a) return null;
  32646. if (a.getActionTag() == c) return a;
  32647. for (var d = a.getChildren(), e = 0; e < d.length; e++) {
  32648. var f = ccui.helper.seekActionWidgetByActionTag(d[e], c);
  32649. if (null != f) return f
  32650. }
  32651. return null
  32652. }
  32653. };
  32654. ccui.Button = ccui.Widget.extend({
  32655. _buttonNormalRenderer: null,
  32656. _buttonClickedRenderer: null,
  32657. _buttonDisableRenderer: null,
  32658. _titleRenderer: null,
  32659. _normalFileName: "",
  32660. _clickedFileName: "",
  32661. _disabledFileName: "",
  32662. _prevIgnoreSize: !0,
  32663. _scale9Enabled: !1,
  32664. _capInsetsNormal: null,
  32665. _capInsetsPressed: null,
  32666. _capInsetsDisabled: null,
  32667. _normalTexType: ccui.Widget.LOCAL_TEXTURE,
  32668. _pressedTexType: ccui.Widget.LOCAL_TEXTURE,
  32669. _disabledTexType: ccui.Widget.LOCAL_TEXTURE,
  32670. _normalTextureSize: null,
  32671. _pressedTextureSize: null,
  32672. _disabledTextureSize: null,
  32673. pressedActionEnabled: !1,
  32674. _titleColor: null,
  32675. _normalTextureScaleXInSize: 1,
  32676. _normalTextureScaleYInSize: 1,
  32677. _pressedTextureScaleXInSize: 1,
  32678. _pressedTextureScaleYInSize: 1,
  32679. _normalTextureLoaded: !1,
  32680. _pressedTextureLoaded: !1,
  32681. _disabledTextureLoaded: !1,
  32682. _className: "Button",
  32683. _normalTextureAdaptDirty: !0,
  32684. _pressedTextureAdaptDirty: !0,
  32685. _disabledTextureAdaptDirty: !0,
  32686. _fontName: "Thonburi",
  32687. _fontSize: 12,
  32688. _type: 0,
  32689. ctor: function(a, c, d, e) {
  32690. this._capInsetsNormal = cc.rect(0, 0, 0, 0);
  32691. this._capInsetsPressed = cc.rect(0, 0, 0, 0);
  32692. this._capInsetsDisabled = cc.rect(0, 0, 0, 0);
  32693. this._normalTextureSize = cc.size(0, 0);
  32694. this._pressedTextureSize = cc.size(0, 0);
  32695. this._disabledTextureSize = cc.size(0, 0);
  32696. this._titleColor = cc.color.WHITE;
  32697. ccui.Widget.prototype.ctor.call(this);
  32698. this.setTouchEnabled(!0);
  32699. e && this.init(a, c, d, e)
  32700. },
  32701. init: function(a, c, d, e) {
  32702. if (ccui.Widget.prototype.init.call(this)) {
  32703. if (void 0 === a) return !0;
  32704. this.loadTextures(a, c, d, e)
  32705. }
  32706. return !1
  32707. },
  32708. _initRenderer: function() {
  32709. this._buttonNormalRenderer = cc.Sprite.create();
  32710. this._buttonClickedRenderer = cc.Sprite.create();
  32711. this._buttonDisableRenderer = cc.Sprite.create();
  32712. this._titleRenderer = cc.LabelTTF.create("");
  32713. this._titleRenderer.setAnchorPoint(0.5, 0.5);
  32714. this.addProtectedChild(this._buttonNormalRenderer, ccui.Button.NORMAL_RENDERER_ZORDER, -1);
  32715. this.addProtectedChild(this._buttonClickedRenderer, ccui.Button.PRESSED_RENDERER_ZORDER, -1);
  32716. this.addProtectedChild(this._buttonDisableRenderer, ccui.Button.DISABLED_RENDERER_ZORDER, -1);
  32717. this.addProtectedChild(this._titleRenderer, ccui.Button.TITLE_RENDERER_ZORDER, -1)
  32718. },
  32719. setScale9Enabled: function(a) {
  32720. 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))
  32721. },
  32722. isScale9Enabled: function() {
  32723. return this._scale9Enabled
  32724. },
  32725. ignoreContentAdaptWithSize: function(a) {
  32726. if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
  32727. },
  32728. getVirtualRendererSize: function() {
  32729. return cc.size(this._normalTextureSize)
  32730. },
  32731. loadTextures: function(a, c, d, e) {
  32732. this.loadTextureNormal(a, e);
  32733. this.loadTexturePressed(c, e);
  32734. this.loadTextureDisabled(d, e)
  32735. },
  32736. loadTextureNormal: function(a, c) {
  32737. if (a) {
  32738. c = c || ccui.Widget.LOCAL_TEXTURE;
  32739. this._normalFileName = a;
  32740. this._normalTexType = c;
  32741. var d = this;
  32742. (!this._buttonNormalRenderer.texture || !this._buttonNormalRenderer.texture.isLoaded()) && this._buttonNormalRenderer.addLoadedEventListener(function() {
  32743. d._findLayout();
  32744. d._normalTextureSize = d._buttonNormalRenderer.getContentSize();
  32745. d._updateFlippedX();
  32746. d._updateFlippedY();
  32747. d._updateChildrenDisplayedRGBA();
  32748. d._buttonNormalRenderer.setColor(d.getColor());
  32749. d._buttonNormalRenderer.setOpacity(d.getOpacity());
  32750. d._updateContentSizeWithTextureSize(d._normalTextureSize);
  32751. d._normalTextureLoaded = !0;
  32752. d._normalTextureAdaptDirty = !0
  32753. });
  32754. if (this._scale9Enabled) {
  32755. var e = this._buttonNormalRenderer;
  32756. switch (this._normalTexType) {
  32757. case ccui.Widget.LOCAL_TEXTURE:
  32758. e.initWithFile(a);
  32759. break;
  32760. case ccui.Widget.PLIST_TEXTURE:
  32761. e.initWithSpriteFrameName(a)
  32762. }
  32763. e.setCapInsets(this._capInsetsNormal)
  32764. } else switch (e = this._buttonNormalRenderer, this._normalTexType) {
  32765. case ccui.Widget.LOCAL_TEXTURE:
  32766. e.initWithFile(a);
  32767. break;
  32768. case ccui.Widget.PLIST_TEXTURE:
  32769. e.initWithSpriteFrameName(a)
  32770. }
  32771. this._normalTextureSize = this._buttonNormalRenderer.getContentSize();
  32772. this._updateFlippedX();
  32773. this._updateFlippedY();
  32774. this._updateChildrenDisplayedRGBA();
  32775. this._updateContentSizeWithTextureSize(this._normalTextureSize);
  32776. this._normalTextureAdaptDirty = this._normalTextureLoaded = !0
  32777. }
  32778. },
  32779. loadTexturePressed: function(a, c) {
  32780. if (a) {
  32781. c = c || ccui.Widget.LOCAL_TEXTURE;
  32782. this._clickedFileName = a;
  32783. this._pressedTexType = c;
  32784. var d = this;
  32785. (!this._buttonClickedRenderer.texture || !this._buttonClickedRenderer.texture.isLoaded()) && this._buttonClickedRenderer.addLoadedEventListener(function() {
  32786. d._findLayout();
  32787. d._pressedTextureSize = d._buttonClickedRenderer.getContentSize();
  32788. d._updateFlippedX();
  32789. d._updateFlippedY();
  32790. d._updateChildrenDisplayedRGBA();
  32791. d._pressedTextureLoaded = !0;
  32792. d._pressedTextureAdaptDirty = !0
  32793. });
  32794. if (this._scale9Enabled) {
  32795. var e = this._buttonClickedRenderer;
  32796. switch (this._pressedTexType) {
  32797. case ccui.Widget.LOCAL_TEXTURE:
  32798. e.initWithFile(a);
  32799. break;
  32800. case ccui.Widget.PLIST_TEXTURE:
  32801. e.initWithSpriteFrameName(a)
  32802. }
  32803. e.setCapInsets(this._capInsetsPressed)
  32804. } else switch (e = this._buttonClickedRenderer, this._pressedTexType) {
  32805. case ccui.Widget.LOCAL_TEXTURE:
  32806. e.initWithFile(a);
  32807. break;
  32808. case ccui.Widget.PLIST_TEXTURE:
  32809. e.initWithSpriteFrameName(a)
  32810. }
  32811. this._pressedTextureSize = this._buttonClickedRenderer.getContentSize();
  32812. this._updateFlippedX();
  32813. this._updateFlippedY();
  32814. this._updateChildrenDisplayedRGBA();
  32815. this._pressedTextureAdaptDirty = this._pressedTextureLoaded = !0
  32816. }
  32817. },
  32818. loadTextureDisabled: function(a, c) {
  32819. if (a) {
  32820. c = c || ccui.Widget.LOCAL_TEXTURE;
  32821. this._disabledFileName = a;
  32822. this._disabledTexType = c;
  32823. var d = this;
  32824. (!this._buttonDisableRenderer.texture || !this._buttonDisableRenderer.texture.isLoaded()) && this._buttonDisableRenderer.addLoadedEventListener(function() {
  32825. d._findLayout();
  32826. d._disabledTextureSize = d._buttonDisableRenderer.getContentSize();
  32827. d._updateFlippedX();
  32828. d._updateFlippedY();
  32829. d._updateChildrenDisplayedRGBA();
  32830. d._disabledTextureLoaded = !0;
  32831. d._disabledTextureAdaptDirty = !0
  32832. });
  32833. if (this._scale9Enabled) {
  32834. var e = this._buttonDisableRenderer;
  32835. switch (this._disabledTexType) {
  32836. case ccui.Widget.LOCAL_TEXTURE:
  32837. e.initWithFile(a);
  32838. break;
  32839. case ccui.Widget.PLIST_TEXTURE:
  32840. e.initWithSpriteFrameName(a)
  32841. }
  32842. e.setCapInsets(this._capInsetsDisabled)
  32843. } else switch (e = this._buttonDisableRenderer, this._disabledTexType) {
  32844. case ccui.Widget.LOCAL_TEXTURE:
  32845. e.initWithFile(a);
  32846. break;
  32847. case ccui.Widget.PLIST_TEXTURE:
  32848. e.initWithSpriteFrameName(a)
  32849. }
  32850. this._disabledTextureSize = this._buttonDisableRenderer.getContentSize();
  32851. this._updateFlippedX();
  32852. this._updateFlippedY();
  32853. this._updateChildrenDisplayedRGBA();
  32854. this._disabledTextureAdaptDirty = this._disabledTextureLoaded = !0
  32855. }
  32856. },
  32857. setCapInsets: function(a) {
  32858. this.setCapInsetsNormalRenderer(a);
  32859. this.setCapInsetsPressedRenderer(a);
  32860. this.setCapInsetsDisabledRenderer(a)
  32861. },
  32862. setCapInsetsNormalRenderer: function(a) {
  32863. this._capInsetsNormal = a;
  32864. this._scale9Enabled && this._buttonNormalRenderer.setCapInsets(a)
  32865. },
  32866. getCapInsetsNormalRenderer: function() {
  32867. return this._capInsetsNormal
  32868. },
  32869. setCapInsetsPressedRenderer: function(a) {
  32870. this._capInsetsPressed = a;
  32871. this._scale9Enabled && this._buttonClickedRenderer.setCapInsets(a)
  32872. },
  32873. getCapInsetsPressedRenderer: function() {
  32874. return this._capInsetsPressed
  32875. },
  32876. setCapInsetsDisabledRenderer: function(a) {
  32877. this._capInsetsDisabled = a;
  32878. this._scale9Enabled && this._buttonDisableRenderer.setCapInsets(a)
  32879. },
  32880. getCapInsetsDisabledRenderer: function() {
  32881. return this._capInsetsDisabled
  32882. },
  32883. onPressStateChangedToNormal: function() {
  32884. this._buttonNormalRenderer.setVisible(!0);
  32885. this._buttonClickedRenderer.setVisible(!1);
  32886. this._buttonDisableRenderer.setVisible(!1);
  32887. if (this._pressedTextureLoaded) {
  32888. if (this.pressedActionEnabled) {
  32889. this._buttonNormalRenderer.stopAllActions();
  32890. this._buttonClickedRenderer.stopAllActions();
  32891. var a = cc.ScaleTo.create(0.05, this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
  32892. this._buttonNormalRenderer.runAction(a);
  32893. this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize)
  32894. }
  32895. } else this._scale9Enabled ? this._updateTexturesRGBA() : (this._buttonNormalRenderer.stopAllActions(), this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize))
  32896. },
  32897. onPressStateChangedToPressed: function() {
  32898. var a = this._buttonNormalRenderer;
  32899. if (this._pressedTextureLoaded) {
  32900. if (a.setVisible(!1), this._buttonClickedRenderer.setVisible(!0), this._buttonDisableRenderer.setVisible(!1), this.pressedActionEnabled) {
  32901. a.stopAllActions();
  32902. this._buttonClickedRenderer.stopAllActions();
  32903. var c = cc.ScaleTo.create(0.05, this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1);
  32904. this._buttonClickedRenderer.runAction(c);
  32905. a.setScale(this._pressedTextureScaleXInSize + 0.1, this._pressedTextureScaleYInSize + 0.1)
  32906. }
  32907. } 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))
  32908. },
  32909. onPressStateChangedToDisabled: function() {
  32910. this._buttonNormalRenderer.setVisible(!1);
  32911. this._buttonClickedRenderer.setVisible(!1);
  32912. this._buttonDisableRenderer.setVisible(!0);
  32913. this._buttonNormalRenderer.setScale(this._normalTextureScaleXInSize, this._normalTextureScaleYInSize);
  32914. this._buttonClickedRenderer.setScale(this._pressedTextureScaleXInSize, this._pressedTextureScaleYInSize)
  32915. },
  32916. _updateFlippedX: function() {
  32917. var a = this._flippedX ? -1 : 1;
  32918. this._titleRenderer.setScaleX(a);
  32919. 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))
  32920. },
  32921. _updateFlippedY: function() {
  32922. var a = this._flippedY ? -1 : 1;
  32923. this._titleRenderer.setScaleY(a);
  32924. 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))
  32925. },
  32926. _updateTexturesRGBA: function() {
  32927. this._buttonNormalRenderer.setColor(this.getColor());
  32928. this._buttonClickedRenderer.setColor(this.getColor());
  32929. this._buttonDisableRenderer.setColor(this.getColor());
  32930. this._buttonNormalRenderer.setOpacity(this.getOpacity());
  32931. this._buttonClickedRenderer.setOpacity(this.getOpacity());
  32932. this._buttonDisableRenderer.setOpacity(this.getOpacity())
  32933. },
  32934. _onSizeChanged: function() {
  32935. ccui.Widget.prototype._onSizeChanged.call(this);
  32936. this._updateTitleLocation();
  32937. this._disabledTextureAdaptDirty = this._pressedTextureAdaptDirty = this._normalTextureAdaptDirty = !0
  32938. },
  32939. getVirtualRenderer: function() {
  32940. if (this._bright) switch (this._brightStyle) {
  32941. case ccui.Widget.BRIGHT_STYLE_NORMAL:
  32942. return this._buttonNormalRenderer;
  32943. case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:
  32944. return this._buttonClickedRenderer;
  32945. default:
  32946. return null
  32947. } else return this._buttonDisableRenderer
  32948. },
  32949. _normalTextureScaleChangedWithSize: function() {
  32950. if (this._ignoreSize) this._scale9Enabled || (this._buttonNormalRenderer.setScale(1), this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1);
  32951. else if (this._scale9Enabled) this._buttonNormalRenderer.setPreferredSize(this._contentSize), this._normalTextureScaleXInSize = this._normalTextureScaleYInSize = 1;
  32952. else {
  32953. var a = this._normalTextureSize;
  32954. if (0 >= a.width || 0 >= a.height) {
  32955. this._buttonNormalRenderer.setScale(1);
  32956. return
  32957. }
  32958. var c = this._contentSize.width / a.width,
  32959. a = this._contentSize.height / a.height;
  32960. this._buttonNormalRenderer.setScaleX(c);
  32961. this._buttonNormalRenderer.setScaleY(a);
  32962. this._normalTextureScaleXInSize = c;
  32963. this._normalTextureScaleYInSize = a
  32964. }
  32965. this._buttonNormalRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  32966. },
  32967. _pressedTextureScaleChangedWithSize: function() {
  32968. if (this._ignoreSize) this._scale9Enabled || (this._buttonClickedRenderer.setScale(1), this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1);
  32969. else if (this._scale9Enabled) this._buttonClickedRenderer.setPreferredSize(this._contentSize), this._pressedTextureScaleXInSize = this._pressedTextureScaleYInSize = 1;
  32970. else {
  32971. var a = this._pressedTextureSize;
  32972. if (0 >= a.width || 0 >= a.height) {
  32973. this._buttonClickedRenderer.setScale(1);
  32974. return
  32975. }
  32976. var c = this._contentSize.width / a.width,
  32977. a = this._contentSize.height / a.height;
  32978. this._buttonClickedRenderer.setScaleX(c);
  32979. this._buttonClickedRenderer.setScaleY(a);
  32980. this._pressedTextureScaleXInSize = c;
  32981. this._pressedTextureScaleYInSize = a
  32982. }
  32983. this._buttonClickedRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  32984. },
  32985. _disabledTextureScaleChangedWithSize: function() {
  32986. if (this._ignoreSize) this._scale9Enabled || this._buttonDisableRenderer.setScale(1);
  32987. else if (this._scale9Enabled) this._buttonDisableRenderer.setPreferredSize(this._contentSize);
  32988. else {
  32989. var a = this._disabledTextureSize;
  32990. if (0 >= a.width || 0 >= a.height) {
  32991. this._buttonDisableRenderer.setScale(1);
  32992. return
  32993. }
  32994. var c = this._contentSize.height / a.height;
  32995. this._buttonDisableRenderer.setScaleX(this._contentSize.width / a.width);
  32996. this._buttonDisableRenderer.setScaleY(c)
  32997. }
  32998. this._buttonDisableRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  32999. },
  33000. _adaptRenderers: function() {
  33001. this._normalTextureAdaptDirty && (this._normalTextureScaleChangedWithSize(), this._normalTextureAdaptDirty = !1);
  33002. this._pressedTextureAdaptDirty && (this._pressedTextureScaleChangedWithSize(), this._pressedTextureAdaptDirty = !1);
  33003. this._disabledTextureAdaptDirty && (this._disabledTextureScaleChangedWithSize(), this._disabledTextureAdaptDirty = !1)
  33004. },
  33005. _updateTitleLocation: function() {
  33006. this._titleRenderer.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height)
  33007. },
  33008. setPressedActionEnabled: function(a) {
  33009. this.pressedActionEnabled = a
  33010. },
  33011. setTitleText: function(a) {
  33012. this._titleRenderer.setString(a)
  33013. },
  33014. getTitleText: function() {
  33015. return this._titleRenderer.getString()
  33016. },
  33017. setTitleColor: function(a) {
  33018. this._titleColor.r = a.r;
  33019. this._titleColor.g = a.g;
  33020. this._titleColor.b = a.b;
  33021. this._titleRenderer.updateDisplayedColor(a)
  33022. },
  33023. getTitleColor: function() {
  33024. return this._titleRenderer.getColor()
  33025. },
  33026. setTitleFontSize: function(a) {
  33027. this._titleRenderer.setFontSize(a)
  33028. },
  33029. getTitleFontSize: function() {
  33030. return this._titleRenderer.getFontSize()
  33031. },
  33032. setTitleFontName: function(a) {
  33033. this._titleRenderer.setFontName(a);
  33034. this._fontName = a
  33035. },
  33036. getTitleFontName: function() {
  33037. return this._titleRenderer.getFontName()
  33038. },
  33039. _setTitleFont: function(a) {
  33040. this._titleRenderer.font = a
  33041. },
  33042. _getTitleFont: function() {
  33043. return this._titleRenderer.font
  33044. },
  33045. getDescription: function() {
  33046. return "Button"
  33047. },
  33048. _createCloneInstance: function() {
  33049. return ccui.Button.create()
  33050. },
  33051. _copySpecialProperties: function(a) {
  33052. this._prevIgnoreSize = a._prevIgnoreSize;
  33053. this.setScale9Enabled(a._scale9Enabled);
  33054. this.loadTextureNormal(a._normalFileName, a._normalTexType);
  33055. this.loadTexturePressed(a._clickedFileName, a._pressedTexType);
  33056. this.loadTextureDisabled(a._disabledFileName, a._disabledTexType);
  33057. this.setCapInsetsNormalRenderer(a._capInsetsNormal);
  33058. this.setCapInsetsPressedRenderer(a._capInsetsPressed);
  33059. this.setCapInsetsDisabledRenderer(a._capInsetsDisabled);
  33060. this.setTitleText(a.getTitleText());
  33061. this.setTitleFontName(a.getTitleFontName());
  33062. this.setTitleFontSize(a.getTitleFontSize());
  33063. this.setTitleColor(a.getTitleColor());
  33064. this.setPressedActionEnabled(a.pressedActionEnabled)
  33065. }
  33066. });
  33067. _p = ccui.Button.prototype;
  33068. cc.defineGetterSetter(_p, "titleText", _p.getTitleText, _p.setTitleText);
  33069. cc.defineGetterSetter(_p, "titleFont", _p._getTitleFont, _p._setTitleFont);
  33070. cc.defineGetterSetter(_p, "titleFontSize", _p.getTitleFontSize, _p.setTitleFontSize);
  33071. cc.defineGetterSetter(_p, "titleFontName", _p.getTitleFontName, _p.setTitleFontName);
  33072. cc.defineGetterSetter(_p, "titleColor", _p.getTitleColor, _p.setTitleColor);
  33073. _p = null;
  33074. ccui.Button.create = function(a, c, d, e) {
  33075. return new ccui.Button(a, c, d, e)
  33076. };
  33077. ccui.Button.NORMAL_RENDERER_ZORDER = -2;
  33078. ccui.Button.PRESSED_RENDERER_ZORDER = -2;
  33079. ccui.Button.DISABLED_RENDERER_ZORDER = -2;
  33080. ccui.Button.TITLE_RENDERER_ZORDER = -1;
  33081. ccui.Button.SYSTEM = 0;
  33082. ccui.Button.TTF = 1;
  33083. ccui.CheckBox = ccui.Widget.extend({
  33084. _backGroundBoxRenderer: null,
  33085. _backGroundSelectedBoxRenderer: null,
  33086. _frontCrossRenderer: null,
  33087. _backGroundBoxDisabledRenderer: null,
  33088. _frontCrossDisabledRenderer: null,
  33089. _isSelected: !0,
  33090. _checkBoxEventListener: null,
  33091. _checkBoxEventSelector: null,
  33092. _checkBoxEventCallback: null,
  33093. _backGroundTexType: ccui.Widget.LOCAL_TEXTURE,
  33094. _backGroundSelectedTexType: ccui.Widget.LOCAL_TEXTURE,
  33095. _frontCrossTexType: ccui.Widget.LOCAL_TEXTURE,
  33096. _backGroundDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
  33097. _frontCrossDisabledTexType: ccui.Widget.LOCAL_TEXTURE,
  33098. _backGroundFileName: "",
  33099. _backGroundSelectedFileName: "",
  33100. _frontCrossFileName: "",
  33101. _backGroundDisabledFileName: "",
  33102. _frontCrossDisabledFileName: "",
  33103. _className: "CheckBox",
  33104. _backGroundBoxRendererAdaptDirty: !0,
  33105. _backGroundSelectedBoxRendererAdaptDirty: !0,
  33106. _frontCrossRendererAdaptDirty: !0,
  33107. _backGroundBoxDisabledRendererAdaptDirty: !0,
  33108. _frontCrossDisabledRendererAdaptDirty: !0,
  33109. ctor: function(a, c, d, e, f, g) {
  33110. ccui.Widget.prototype.ctor.call(this);
  33111. this.setTouchEnabled(!0);
  33112. g && this.init(a, c, d, e, f, g)
  33113. },
  33114. init: function(a, c, d, e, f, g) {
  33115. 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
  33116. },
  33117. _initRenderer: function() {
  33118. this._backGroundBoxRenderer = cc.Sprite.create();
  33119. this._backGroundSelectedBoxRenderer = cc.Sprite.create();
  33120. this._frontCrossRenderer = cc.Sprite.create();
  33121. this._backGroundBoxDisabledRenderer = cc.Sprite.create();
  33122. this._frontCrossDisabledRenderer = cc.Sprite.create();
  33123. this.addProtectedChild(this._backGroundBoxRenderer, ccui.CheckBox.BOX_RENDERER_ZORDER, -1);
  33124. this.addProtectedChild(this._backGroundSelectedBoxRenderer, ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER, -1);
  33125. this.addProtectedChild(this._frontCrossRenderer, ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER, -1);
  33126. this.addProtectedChild(this._backGroundBoxDisabledRenderer, ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER, -1);
  33127. this.addProtectedChild(this._frontCrossDisabledRenderer, ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER, -1)
  33128. },
  33129. loadTextures: function(a, c, d, e, f, g) {
  33130. this.loadTextureBackGround(a, g);
  33131. this.loadTextureBackGroundSelected(c, g);
  33132. this.loadTextureFrontCross(d, g);
  33133. this.loadTextureBackGroundDisabled(e, g);
  33134. this.loadTextureFrontCrossDisabled(f, g)
  33135. },
  33136. loadTextureBackGround: function(a, c) {
  33137. if (a) {
  33138. c = c || ccui.Widget.LOCAL_TEXTURE;
  33139. this._backGroundFileName = a;
  33140. this._backGroundTexType = c;
  33141. var d = this._backGroundBoxRenderer,
  33142. e = this;
  33143. (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
  33144. e._findLayout();
  33145. e._updateFlippedX();
  33146. e._updateFlippedY();
  33147. e._updateChildrenDisplayedRGBA();
  33148. e._updateContentSizeWithTextureSize(e._backGroundBoxRenderer.getContentSize());
  33149. e._backGroundBoxRendererAdaptDirty = !0
  33150. });
  33151. switch (this._backGroundTexType) {
  33152. case ccui.Widget.LOCAL_TEXTURE:
  33153. d.initWithFile(a);
  33154. break;
  33155. case ccui.Widget.PLIST_TEXTURE:
  33156. d.initWithSpriteFrameName(a)
  33157. }
  33158. d.textureLoaded() || (this._backGroundBoxRenderer.setContentSize(this._customSize), d.addLoadedEventListener(function() {
  33159. this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize())
  33160. }, this));
  33161. this._updateFlippedX();
  33162. this._updateFlippedY();
  33163. this._updateChildrenDisplayedRGBA();
  33164. this._updateContentSizeWithTextureSize(this._backGroundBoxRenderer.getContentSize());
  33165. this._backGroundBoxRendererAdaptDirty = !0
  33166. }
  33167. },
  33168. loadTextureBackGroundSelected: function(a, c) {
  33169. if (a) {
  33170. c = c || ccui.Widget.LOCAL_TEXTURE;
  33171. this._backGroundSelectedFileName = a;
  33172. this._backGroundSelectedTexType = c;
  33173. var d = this;
  33174. (!this._backGroundSelectedBoxRenderer.texture || !this._backGroundSelectedBoxRenderer.texture.isLoaded()) && this._backGroundSelectedBoxRenderer.addLoadedEventListener(function() {
  33175. d._findLayout();
  33176. d._updateFlippedX();
  33177. d._updateFlippedY();
  33178. d._updateChildrenDisplayedRGBA();
  33179. d._backGroundSelectedBoxRendererAdaptDirty = !0
  33180. });
  33181. switch (this._backGroundSelectedTexType) {
  33182. case ccui.Widget.LOCAL_TEXTURE:
  33183. this._backGroundSelectedBoxRenderer.initWithFile(a);
  33184. break;
  33185. case ccui.Widget.PLIST_TEXTURE:
  33186. this._backGroundSelectedBoxRenderer.initWithSpriteFrameName(a)
  33187. }
  33188. this._updateFlippedX();
  33189. this._updateFlippedY();
  33190. this._updateChildrenDisplayedRGBA();
  33191. this._backGroundSelectedBoxRendererAdaptDirty = !0
  33192. }
  33193. },
  33194. loadTextureFrontCross: function(a, c) {
  33195. if (a) {
  33196. c = c || ccui.Widget.LOCAL_TEXTURE;
  33197. this._frontCrossFileName = a;
  33198. this._frontCrossTexType = c;
  33199. var d = this;
  33200. (!this._frontCrossRenderer.texture || !this._frontCrossRenderer.texture.isLoaded()) && this._frontCrossRenderer.addLoadedEventListener(function() {
  33201. d._findLayout();
  33202. d._updateFlippedX();
  33203. d._updateFlippedY();
  33204. d._updateChildrenDisplayedRGBA();
  33205. d._frontCrossRendererAdaptDirty = !0
  33206. });
  33207. switch (this._frontCrossTexType) {
  33208. case ccui.Widget.LOCAL_TEXTURE:
  33209. this._frontCrossRenderer.initWithFile(a);
  33210. break;
  33211. case ccui.Widget.PLIST_TEXTURE:
  33212. this._frontCrossRenderer.initWithSpriteFrameName(a)
  33213. }
  33214. this._updateFlippedX();
  33215. this._updateFlippedY();
  33216. this._updateChildrenDisplayedRGBA();
  33217. this._frontCrossRendererAdaptDirty = !0
  33218. }
  33219. },
  33220. loadTextureBackGroundDisabled: function(a, c) {
  33221. if (a) {
  33222. c = c || ccui.Widget.LOCAL_TEXTURE;
  33223. this._backGroundDisabledFileName = a;
  33224. this._backGroundDisabledTexType = c;
  33225. var d = this;
  33226. (!this._backGroundBoxDisabledRenderer.texture || !this._backGroundBoxDisabledRenderer.texture.isLoaded()) && this._backGroundBoxDisabledRenderer.addLoadedEventListener(function() {
  33227. d._findLayout();
  33228. d._updateFlippedX();
  33229. d._updateFlippedY();
  33230. d._updateChildrenDisplayedRGBA();
  33231. d._backGroundBoxDisabledRendererAdaptDirty = !0
  33232. });
  33233. switch (this._backGroundDisabledTexType) {
  33234. case ccui.Widget.LOCAL_TEXTURE:
  33235. this._backGroundBoxDisabledRenderer.initWithFile(a);
  33236. break;
  33237. case ccui.Widget.PLIST_TEXTURE:
  33238. this._backGroundBoxDisabledRenderer.initWithSpriteFrameName(a)
  33239. }
  33240. this._updateFlippedX();
  33241. this._updateFlippedY();
  33242. this._updateChildrenDisplayedRGBA();
  33243. this._backGroundBoxDisabledRendererAdaptDirty = !0
  33244. }
  33245. },
  33246. loadTextureFrontCrossDisabled: function(a, c) {
  33247. if (a) {
  33248. c = c || ccui.Widget.LOCAL_TEXTURE;
  33249. this._frontCrossDisabledFileName = a;
  33250. this._frontCrossDisabledTexType = c;
  33251. var d = this;
  33252. (!this._frontCrossDisabledRenderer.texture || !this._frontCrossDisabledRenderer.texture.isLoaded()) && this._frontCrossDisabledRenderer.addLoadedEventListener(function() {
  33253. d._findLayout();
  33254. d._updateFlippedX();
  33255. d._updateFlippedY();
  33256. d._updateChildrenDisplayedRGBA();
  33257. d._frontCrossDisabledRendererAdaptDirty = !0
  33258. });
  33259. switch (this._frontCrossDisabledTexType) {
  33260. case ccui.Widget.LOCAL_TEXTURE:
  33261. this._frontCrossDisabledRenderer.initWithFile(a);
  33262. break;
  33263. case ccui.Widget.PLIST_TEXTURE:
  33264. this._frontCrossDisabledRenderer.initWithSpriteFrameName(a)
  33265. }
  33266. this._updateFlippedX();
  33267. this._updateFlippedY();
  33268. this._updateChildrenDisplayedRGBA();
  33269. this._frontCrossDisabledRendererAdaptDirty = !0
  33270. }
  33271. },
  33272. onPressStateChangedToNormal: function() {
  33273. this._backGroundBoxRenderer.setVisible(!0);
  33274. this._backGroundSelectedBoxRenderer.setVisible(!1);
  33275. this._backGroundBoxDisabledRenderer.setVisible(!1);
  33276. this._frontCrossDisabledRenderer.setVisible(!1)
  33277. },
  33278. onPressStateChangedToPressed: function() {
  33279. this._backGroundBoxRenderer.setVisible(!1);
  33280. this._backGroundSelectedBoxRenderer.setVisible(!0);
  33281. this._backGroundBoxDisabledRenderer.setVisible(!1);
  33282. this._frontCrossDisabledRenderer.setVisible(!1)
  33283. },
  33284. onPressStateChangedToDisabled: function() {
  33285. this._backGroundBoxRenderer.setVisible(!1);
  33286. this._backGroundSelectedBoxRenderer.setVisible(!1);
  33287. this._backGroundBoxDisabledRenderer.setVisible(!0);
  33288. this._frontCrossRenderer.setVisible(!1);
  33289. this._isSelected && this._frontCrossDisabledRenderer.setVisible(!0)
  33290. },
  33291. setSelectedState: function(a) {
  33292. a != this._isSelected && (this._isSelected = a, this._frontCrossRenderer.setVisible(this._isSelected))
  33293. },
  33294. getSelectedState: function() {
  33295. return this._isSelected
  33296. },
  33297. _selectedEvent: function() {
  33298. this._checkBoxEventCallback && this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_SELECTED);
  33299. this._checkBoxEventListener && this._checkBoxEventSelector && this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_SELECTED)
  33300. },
  33301. _unSelectedEvent: function() {
  33302. this._checkBoxEventCallback && this._checkBoxEventCallback(this, ccui.CheckBox.EVENT_UNSELECTED);
  33303. this._checkBoxEventListener && this._checkBoxEventSelector && this._checkBoxEventSelector.call(this._checkBoxEventListener, this, ccui.CheckBox.EVENT_UNSELECTED)
  33304. },
  33305. _releaseUpEvent: function() {
  33306. ccui.Widget.prototype._releaseUpEvent.call(this);
  33307. this._isSelected ? (this.setSelectedState(!1), this._unSelectedEvent()) : (this.setSelectedState(!0), this._selectedEvent())
  33308. },
  33309. addEventListenerCheckBox: function(a, c) {
  33310. this._checkBoxEventSelector = a;
  33311. this._checkBoxEventListener = c
  33312. },
  33313. addEventListener: function(a) {
  33314. this._checkBoxEventCallback = a
  33315. },
  33316. getVirtualRendererSize: function() {
  33317. return this._backGroundBoxRenderer.getContentSize()
  33318. },
  33319. _updateFlippedX: function() {
  33320. this._backGroundBoxRenderer.setFlippedX(this._flippedX);
  33321. this._backGroundSelectedBoxRenderer.setFlippedX(this._flippedX);
  33322. this._frontCrossRenderer.setFlippedX(this._flippedX);
  33323. this._backGroundBoxDisabledRenderer.setFlippedX(this._flippedX);
  33324. this._frontCrossDisabledRenderer.setFlippedX(this._flippedX)
  33325. },
  33326. _updateFlippedY: function() {
  33327. this._backGroundBoxRenderer.setFlippedY(this._flippedY);
  33328. this._backGroundSelectedBoxRenderer.setFlippedY(this._flippedY);
  33329. this._frontCrossRenderer.setFlippedY(this._flippedY);
  33330. this._backGroundBoxDisabledRenderer.setFlippedY(this._flippedY);
  33331. this._frontCrossDisabledRenderer.setFlippedY(this._flippedY)
  33332. },
  33333. _onSizeChanged: function() {
  33334. ccui.Widget.prototype._onSizeChanged.call(this);
  33335. this._frontCrossDisabledRendererAdaptDirty = this._backGroundBoxDisabledRendererAdaptDirty = this._frontCrossRendererAdaptDirty = this._backGroundSelectedBoxRendererAdaptDirty = this._backGroundBoxRendererAdaptDirty = !0
  33336. },
  33337. getVirtualRenderer: function() {
  33338. return this._backGroundBoxRenderer
  33339. },
  33340. _backGroundTextureScaleChangedWithSize: function() {
  33341. var a = this._backGroundBoxRenderer,
  33342. c = this._contentSize;
  33343. if (this._ignoreSize) a.setScale(1);
  33344. else {
  33345. var d = a.getContentSize();
  33346. if (0 >= d.width || 0 >= d.height) {
  33347. a.setScale(1);
  33348. return
  33349. }
  33350. var e = c.height / d.height;
  33351. a.setScaleX(c.width / d.width);
  33352. a.setScaleY(e)
  33353. }
  33354. a.setPosition(0.5 * c.width, 0.5 * c.height)
  33355. },
  33356. _backGroundSelectedTextureScaleChangedWithSize: function() {
  33357. var a = this._backGroundSelectedBoxRenderer,
  33358. c = this._contentSize;
  33359. if (this._ignoreSize) a.setScale(1);
  33360. else {
  33361. var d = a.getContentSize();
  33362. if (0 >= d.width || 0 >= d.height) {
  33363. a.setScale(1);
  33364. return
  33365. }
  33366. var e = c.height / d.height;
  33367. a.setScaleX(c.width / d.width);
  33368. a.setScaleY(e)
  33369. }
  33370. a.setPosition(0.5 * c.width, 0.5 * c.height)
  33371. },
  33372. _frontCrossTextureScaleChangedWithSize: function() {
  33373. var a = this._frontCrossRenderer,
  33374. c = this._contentSize;
  33375. if (this._ignoreSize) a.setScale(1);
  33376. else {
  33377. var d = a.getContentSize();
  33378. if (0 >= d.width || 0 >= d.height) {
  33379. a.setScale(1);
  33380. return
  33381. }
  33382. var e = c.height / d.height;
  33383. a.setScaleX(c.width / d.width);
  33384. a.setScaleY(e)
  33385. }
  33386. a.setPosition(0.5 * c.width, 0.5 * c.height)
  33387. },
  33388. _backGroundDisabledTextureScaleChangedWithSize: function() {
  33389. var a = this._backGroundBoxDisabledRenderer,
  33390. c = this._contentSize;
  33391. if (this._ignoreSize) a.setScale(1);
  33392. else {
  33393. var d = a.getContentSize();
  33394. if (0 >= d.width || 0 >= d.height) {
  33395. a.setScale(1);
  33396. return
  33397. }
  33398. var e = c.height / d.height;
  33399. a.setScaleX(c.width / d.width);
  33400. a.setScaleY(e)
  33401. }
  33402. a.setPosition(0.5 * c.width, 0.5 * c.height)
  33403. },
  33404. _frontCrossDisabledTextureScaleChangedWithSize: function() {
  33405. var a = this._frontCrossDisabledRenderer,
  33406. c = this._contentSize;
  33407. if (this._ignoreSize) a.setScale(1);
  33408. else {
  33409. var d = a.getContentSize();
  33410. if (0 >= d.width || 0 >= d.height) {
  33411. a.setScale(1);
  33412. return
  33413. }
  33414. var e = c.height / d.height;
  33415. a.setScaleX(c.width / d.width);
  33416. a.setScaleY(e)
  33417. }
  33418. a.setPosition(0.5 * c.width, 0.5 * c.height)
  33419. },
  33420. getDescription: function() {
  33421. return "CheckBox"
  33422. },
  33423. _createCloneInstance: function() {
  33424. return ccui.CheckBox.create()
  33425. },
  33426. _copySpecialProperties: function(a) {
  33427. 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)
  33428. },
  33429. _adaptRenderers: function() {
  33430. this._backGroundBoxRendererAdaptDirty && (this._backGroundTextureScaleChangedWithSize(), this._backGroundBoxRendererAdaptDirty = !1);
  33431. this._backGroundSelectedBoxRendererAdaptDirty && (this._backGroundSelectedTextureScaleChangedWithSize(), this._backGroundSelectedBoxRendererAdaptDirty = !1);
  33432. this._frontCrossRendererAdaptDirty && (this._frontCrossTextureScaleChangedWithSize(), this._frontCrossRendererAdaptDirty = !1);
  33433. this._backGroundBoxDisabledRendererAdaptDirty && (this._backGroundDisabledTextureScaleChangedWithSize(), this._backGroundBoxDisabledRendererAdaptDirty = !1);
  33434. this._frontCrossDisabledRendererAdaptDirty && (this._frontCrossDisabledTextureScaleChangedWithSize(), this._frontCrossDisabledRendererAdaptDirty = !1)
  33435. }
  33436. });
  33437. _p = ccui.CheckBox.prototype;
  33438. cc.defineGetterSetter(_p, "selected", _p.getSelectedState, _p.setSelectedState);
  33439. _p = null;
  33440. ccui.CheckBox.create = function(a, c, d, e, f, g) {
  33441. return new ccui.CheckBox(a, c, d, e, f, g)
  33442. };
  33443. ccui.CheckBox.EVENT_SELECTED = 0;
  33444. ccui.CheckBox.EVENT_UNSELECTED = 1;
  33445. ccui.CheckBox.BOX_RENDERER_ZORDER = -1;
  33446. ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER = -1;
  33447. ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER = -1;
  33448. ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER = -1;
  33449. ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER = -1;
  33450. ccui.ImageView = ccui.Widget.extend({
  33451. _scale9Enabled: !1,
  33452. _prevIgnoreSize: !0,
  33453. _capInsets: null,
  33454. _imageRenderer: null,
  33455. _textureFile: "",
  33456. _imageTexType: ccui.Widget.LOCAL_TEXTURE,
  33457. _imageTextureSize: null,
  33458. _className: "ImageView",
  33459. _imageRendererAdaptDirty: !0,
  33460. ctor: function(a, c) {
  33461. this._capInsets = cc.rect(0, 0, 0, 0);
  33462. this._imageTextureSize = cc.size(this._capInsets.width, this._capInsets.height);
  33463. ccui.Widget.prototype.ctor.call(this);
  33464. c && this.init(a, c)
  33465. },
  33466. init: function(a, c) {
  33467. return ccui.Widget.prototype.init.call(this) ? (void 0 === a ? this._imageTexType = ccui.Widget.LOCAL_TEXTURE : this.loadTexture(a, c), !0) : !1
  33468. },
  33469. _initRenderer: function() {
  33470. this._imageRenderer = cc.Sprite.create();
  33471. this.addProtectedChild(this._imageRenderer, ccui.ImageView.RENDERER_ZORDER, -1)
  33472. },
  33473. loadTexture: function(a, c) {
  33474. if (a) {
  33475. var d = this;
  33476. c = c || ccui.Widget.LOCAL_TEXTURE;
  33477. this._textureFile = a;
  33478. this._imageTexType = c;
  33479. var e = d._imageRenderer;
  33480. switch (d._imageTexType) {
  33481. case ccui.Widget.LOCAL_TEXTURE:
  33482. d._scale9Enabled ? (e.initWithFile(a), e.setCapInsets(d._capInsets)) : e.initWithFile(a);
  33483. break;
  33484. case ccui.Widget.PLIST_TEXTURE:
  33485. d._scale9Enabled ? (e.initWithSpriteFrameName(a), e.setCapInsets(d._capInsets)) : e.initWithSpriteFrameName(a)
  33486. }(!e.texture || !e.texture.isLoaded()) && e.addLoadedEventListener(function() {
  33487. d._findLayout();
  33488. d._imageTextureSize = e.getContentSize();
  33489. d._updateFlippedX();
  33490. d._updateFlippedY();
  33491. d._updateChildrenDisplayedRGBA();
  33492. d._updateContentSizeWithTextureSize(d._imageTextureSize);
  33493. d._imageRendererAdaptDirty = !0
  33494. });
  33495. d._imageTextureSize = e.getContentSize();
  33496. d._updateFlippedX();
  33497. d._updateFlippedY();
  33498. this._updateChildrenDisplayedRGBA();
  33499. d._updateContentSizeWithTextureSize(d._imageTextureSize);
  33500. d._imageRendererAdaptDirty = !0
  33501. }
  33502. },
  33503. setTextureRect: function(a) {
  33504. this._scale9Enabled || this._imageRenderer.setTextureRect(a)
  33505. },
  33506. _updateFlippedX: function() {
  33507. this._scale9Enabled ? this._imageRenderer.setScaleX(this._flippedX ? -1 : 1) : this._imageRenderer.setFlippedX(this._flippedX)
  33508. },
  33509. _updateFlippedY: function() {
  33510. this._scale9Enabled ? this._imageRenderer.setScaleY(this._flippedY ? -1 : 1) : this._imageRenderer.setFlippedY(this._flippedY)
  33511. },
  33512. setScale9Enabled: function(a) {
  33513. 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))
  33514. },
  33515. isScale9Enabled: function() {
  33516. return this._scale9Enabled
  33517. },
  33518. ignoreContentAdaptWithSize: function(a) {
  33519. if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
  33520. },
  33521. setCapInsets: function(a) {
  33522. this._capInsets = a;
  33523. this._scale9Enabled && this._imageRenderer.setCapInsets(a)
  33524. },
  33525. getCapInsets: function() {
  33526. return this._capInsets
  33527. },
  33528. _onSizeChanged: function() {
  33529. ccui.Widget.prototype._onSizeChanged.call(this);
  33530. this._imageRendererAdaptDirty = !0
  33531. },
  33532. _adaptRenderers: function() {
  33533. this._imageRendererAdaptDirty && (this._imageTextureScaleChangedWithSize(), this._imageRendererAdaptDirty = !1)
  33534. },
  33535. getVirtualRendererSize: function() {
  33536. return cc.size(this._imageTextureSize)
  33537. },
  33538. getVirtualRenderer: function() {
  33539. return this._imageRenderer
  33540. },
  33541. _imageTextureScaleChangedWithSize: function() {
  33542. if (this._ignoreSize) this._scale9Enabled || this._imageRenderer.setScale(1);
  33543. else if (this._scale9Enabled) this._imageRenderer.setPreferredSize(this._contentSize);
  33544. else {
  33545. var a = this._imageRenderer.getContentSize();
  33546. if (0 >= a.width || 0 >= a.height) {
  33547. this._imageRenderer.setScale(1);
  33548. return
  33549. }
  33550. this._imageRenderer.setScaleX(this._contentSize.width / a.width);
  33551. this._imageRenderer.setScaleY(this._contentSize.height / a.height)
  33552. }
  33553. this._imageRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  33554. },
  33555. getDescription: function() {
  33556. return "ImageView"
  33557. },
  33558. _createCloneInstance: function() {
  33559. return ccui.ImageView.create()
  33560. },
  33561. _copySpecialProperties: function(a) {
  33562. a instanceof ccui.ImageView && (this._prevIgnoreSize = a._prevIgnoreSize, this.setScale9Enabled(a._scale9Enabled), this.loadTexture(a._textureFile, a._imageTexType), this.setCapInsets(a._capInsets))
  33563. }
  33564. });
  33565. ccui.ImageView.create = function(a, c) {
  33566. return new ccui.ImageView(a, c)
  33567. };
  33568. ccui.ImageView.RENDERER_ZORDER = -1;
  33569. ccui.LoadingBar = ccui.Widget.extend({
  33570. _direction: null,
  33571. _percent: 100,
  33572. _totalLength: 0,
  33573. _barRenderer: null,
  33574. _renderBarTexType: ccui.Widget.LOCAL_TEXTURE,
  33575. _barRendererTextureSize: null,
  33576. _scale9Enabled: !1,
  33577. _prevIgnoreSize: !0,
  33578. _capInsets: null,
  33579. _textureFile: "",
  33580. _isTextureLoaded: !1,
  33581. _className: "LoadingBar",
  33582. _barRendererAdaptDirty: !0,
  33583. ctor: function(a, c) {
  33584. this._direction = ccui.LoadingBar.TYPE_LEFT;
  33585. this._barRendererTextureSize = cc.size(0, 0);
  33586. this._capInsets = cc.rect(0, 0, 0, 0);
  33587. ccui.Widget.prototype.ctor.call(this);
  33588. void 0 !== a && this.loadTexture(a);
  33589. void 0 !== c && this.setPercent(c)
  33590. },
  33591. _initRenderer: function() {
  33592. this._barRenderer = cc.Sprite.create();
  33593. cc.Node.prototype.addChild.call(this, this._barRenderer, ccui.LoadingBar.RENDERER_ZORDER, -1);
  33594. this._barRenderer.setAnchorPoint(0, 0.5)
  33595. },
  33596. setDirection: function(a) {
  33597. if (this._direction != a) switch (this._direction = a, this._direction) {
  33598. case ccui.LoadingBar.TYPE_LEFT:
  33599. this._barRenderer.setAnchorPoint(0, 0.5);
  33600. this._barRenderer.setPosition(0.5 * -this._totalLength, 0);
  33601. this._scale9Enabled || this._barRenderer.setFlippedX(!1);
  33602. break;
  33603. case ccui.LoadingBar.TYPE_RIGHT:
  33604. this._barRenderer.setAnchorPoint(1, 0.5), this._barRenderer.setPosition(0.5 * this._totalLength, 0), this._scale9Enabled || this._barRenderer.setFlippedX(!0)
  33605. }
  33606. },
  33607. getDirection: function() {
  33608. return this._direction
  33609. },
  33610. loadTexture: function(a, c) {
  33611. if (a) {
  33612. this._renderBarTexType = c = c || ccui.Widget.LOCAL_TEXTURE;
  33613. this._textureFile = a;
  33614. var d = this._barRenderer,
  33615. e = this;
  33616. (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
  33617. e._findLayout();
  33618. var a = d.getContentSize();
  33619. e._barRendererTextureSize.width = a.width;
  33620. e._barRendererTextureSize.height = a.height;
  33621. switch (e._direction) {
  33622. case ccui.LoadingBar.TYPE_LEFT:
  33623. d.setAnchorPoint(0, 0.5);
  33624. e._scale9Enabled || d.setFlippedX(!1);
  33625. break;
  33626. case ccui.LoadingBar.TYPE_RIGHT:
  33627. d.setAnchorPoint(1, 0.5), e._scale9Enabled || d.setFlippedX(!0)
  33628. }
  33629. e._updateChildrenDisplayedRGBA();
  33630. e._barRendererScaleChangedWithSize();
  33631. e._updateContentSizeWithTextureSize(e._barRendererTextureSize);
  33632. e._barRendererAdaptDirty = !0
  33633. });
  33634. switch (this._renderBarTexType) {
  33635. case ccui.Widget.LOCAL_TEXTURE:
  33636. this._scale9Enabled ? (d.initWithFile(a), d.setCapInsets(this._capInsets)) : d.initWithFile(a);
  33637. break;
  33638. case ccui.Widget.PLIST_TEXTURE:
  33639. this._scale9Enabled ? (d.initWithSpriteFrameName(a), d.setCapInsets(this._capInsets)) : d.initWithSpriteFrameName(a)
  33640. }
  33641. var f = d.getContentSize();
  33642. this._barRendererTextureSize.width = f.width;
  33643. this._barRendererTextureSize.height = f.height;
  33644. switch (this._direction) {
  33645. case ccui.LoadingBar.TYPE_LEFT:
  33646. d.setAnchorPoint(0, 0.5);
  33647. this._scale9Enabled || d.setFlippedX(!1);
  33648. break;
  33649. case ccui.LoadingBar.TYPE_RIGHT:
  33650. d.setAnchorPoint(1, 0.5), this._scale9Enabled || d.setFlippedX(!0)
  33651. }
  33652. this._updateChildrenDisplayedRGBA();
  33653. this._barRendererScaleChangedWithSize();
  33654. this._updateContentSizeWithTextureSize(this._barRendererTextureSize);
  33655. this._barRendererAdaptDirty = !0
  33656. }
  33657. },
  33658. setScale9Enabled: function(a) {
  33659. 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))
  33660. },
  33661. isScale9Enabled: function() {
  33662. return this._scale9Enabled
  33663. },
  33664. setCapInsets: function(a) {
  33665. this._capInsets = a;
  33666. this._scale9Enabled && this._barRenderer.setCapInsets(a)
  33667. },
  33668. getCapInsets: function() {
  33669. return this._capInsets
  33670. },
  33671. setPercent: function(a) {
  33672. if (!(0 > a || 100 < a) && !(0 >= this._totalLength))
  33673. if (this._percent = a, a = this._percent / 100, this._scale9Enabled) this._setScale9Scale();
  33674. else {
  33675. var c = this._barRenderer.getTextureRect();
  33676. c.width = this._barRendererTextureSize.width * a;
  33677. this._barRenderer.setTextureRect(cc.rect(c.x, c.y, this._barRendererTextureSize.width * a, this._barRendererTextureSize.height))
  33678. }
  33679. },
  33680. getPercent: function() {
  33681. return this._percent
  33682. },
  33683. _onSizeChanged: function() {
  33684. ccui.Widget.prototype._onSizeChanged.call(this);
  33685. this._barRendererAdaptDirty = !0
  33686. },
  33687. _adaptRenderers: function() {
  33688. this._barRendererAdaptDirty && (this._barRendererScaleChangedWithSize(), this._barRendererAdaptDirty = !1)
  33689. },
  33690. ignoreContentAdaptWithSize: function(a) {
  33691. if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
  33692. },
  33693. getVirtualRendererSize: function() {
  33694. return cc.size(this._barRendererTextureSize)
  33695. },
  33696. getVirtualRenderer: function() {
  33697. return this._barRenderer
  33698. },
  33699. _barRendererScaleChangedWithSize: function() {
  33700. var a = this._barRenderer,
  33701. c = this._contentSize;
  33702. if (this._ignoreSize) this._scale9Enabled || (this._totalLength = this._barRendererTextureSize.width, a.setScale(1));
  33703. else if (this._totalLength = c.width, this._scale9Enabled) this._setScale9Scale();
  33704. else {
  33705. var d = this._barRendererTextureSize;
  33706. if (0 >= d.width || 0 >= d.height) {
  33707. a.setScale(1);
  33708. return
  33709. }
  33710. var e = c.height / d.height;
  33711. a.setScaleX(c.width / d.width);
  33712. a.setScaleY(e)
  33713. }
  33714. switch (this._direction) {
  33715. case ccui.LoadingBar.TYPE_LEFT:
  33716. a.setPosition(0, 0.5 * c.height);
  33717. break;
  33718. case ccui.LoadingBar.TYPE_RIGHT:
  33719. a.setPosition(this._totalLength, 0.5 * c.height)
  33720. }
  33721. },
  33722. _setScale9Scale: function() {
  33723. this._barRenderer.setPreferredSize(cc.size(this._percent / 100 * this._totalLength, this._contentSize.height))
  33724. },
  33725. getDescription: function() {
  33726. return "LoadingBar"
  33727. },
  33728. _createCloneInstance: function() {
  33729. return ccui.LoadingBar.create()
  33730. },
  33731. _copySpecialProperties: function(a) {
  33732. 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))
  33733. }
  33734. });
  33735. _p = ccui.LoadingBar.prototype;
  33736. cc.defineGetterSetter(_p, "direction", _p.getDirection, _p.setDirection);
  33737. cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
  33738. _p = null;
  33739. ccui.LoadingBar.create = function(a, c) {
  33740. return new ccui.LoadingBar(a, c)
  33741. };
  33742. ccui.LoadingBar.TYPE_LEFT = 0;
  33743. ccui.LoadingBar.TYPE_RIGHT = 1;
  33744. ccui.LoadingBar.RENDERER_ZORDER = -1;
  33745. ccui.Slider = ccui.Widget.extend({
  33746. _barRenderer: null,
  33747. _progressBarRenderer: null,
  33748. _progressBarTextureSize: null,
  33749. _slidBallNormalRenderer: null,
  33750. _slidBallPressedRenderer: null,
  33751. _slidBallDisabledRenderer: null,
  33752. _slidBallRenderer: null,
  33753. _barLength: 0,
  33754. _percent: 0,
  33755. _scale9Enabled: !1,
  33756. _prevIgnoreSize: !0,
  33757. _textureFile: "",
  33758. _progressBarTextureFile: "",
  33759. _slidBallNormalTextureFile: "",
  33760. _slidBallPressedTextureFile: "",
  33761. _slidBallDisabledTextureFile: "",
  33762. _capInsetsBarRenderer: null,
  33763. _capInsetsProgressBarRenderer: null,
  33764. _sliderEventListener: null,
  33765. _sliderEventSelector: null,
  33766. _barTexType: ccui.Widget.LOCAL_TEXTURE,
  33767. _progressBarTexType: ccui.Widget.LOCAL_TEXTURE,
  33768. _ballNTexType: ccui.Widget.LOCAL_TEXTURE,
  33769. _ballPTexType: ccui.Widget.LOCAL_TEXTURE,
  33770. _ballDTexType: ccui.Widget.LOCAL_TEXTURE,
  33771. _isTextureLoaded: !1,
  33772. _className: "Slider",
  33773. _barRendererAdaptDirty: !0,
  33774. _progressBarRendererDirty: !0,
  33775. ctor: function() {
  33776. this._progressBarTextureSize = cc.size(0, 0);
  33777. this._capInsetsBarRenderer = cc.rect(0, 0, 0, 0);
  33778. this._capInsetsProgressBarRenderer = cc.rect(0, 0, 0, 0);
  33779. ccui.Widget.prototype.ctor.call(this)
  33780. },
  33781. init: function() {
  33782. return ccui.Widget.prototype.init.call(this) ? !0 : !1
  33783. },
  33784. _initRenderer: function() {
  33785. this._barRenderer = cc.Sprite.create();
  33786. this._progressBarRenderer = cc.Sprite.create();
  33787. this._progressBarRenderer.setAnchorPoint(0, 0.5);
  33788. this.addProtectedChild(this._barRenderer, ccui.Slider.BASEBAR_RENDERER_ZORDER, -1);
  33789. this.addProtectedChild(this._progressBarRenderer, ccui.Slider.PROGRESSBAR_RENDERER_ZORDER, -1);
  33790. this._slidBallNormalRenderer = cc.Sprite.create();
  33791. this._slidBallPressedRenderer = cc.Sprite.create();
  33792. this._slidBallPressedRenderer.setVisible(!1);
  33793. this._slidBallDisabledRenderer = cc.Sprite.create();
  33794. this._slidBallDisabledRenderer.setVisible(!1);
  33795. this._slidBallRenderer = cc.Node.create();
  33796. this._slidBallRenderer.addChild(this._slidBallNormalRenderer);
  33797. this._slidBallRenderer.addChild(this._slidBallPressedRenderer);
  33798. this._slidBallRenderer.addChild(this._slidBallDisabledRenderer);
  33799. this.addProtectedChild(this._slidBallRenderer, ccui.Slider.BALL_RENDERER_ZORDER, -1)
  33800. },
  33801. loadBarTexture: function(a, c) {
  33802. if (a) {
  33803. c = c || ccui.Widget.LOCAL_TEXTURE;
  33804. this._textureFile = a;
  33805. this._barTexType = c;
  33806. var d = this._barRenderer,
  33807. e = this;
  33808. (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
  33809. e._findLayout();
  33810. e._updateChildrenDisplayedRGBA();
  33811. e._barRendererAdaptDirty = !0;
  33812. e._progressBarRendererDirty = !0;
  33813. e._updateContentSizeWithTextureSize(e._barRenderer.getContentSize())
  33814. });
  33815. switch (this._barTexType) {
  33816. case ccui.Widget.LOCAL_TEXTURE:
  33817. d.initWithFile(a);
  33818. break;
  33819. case ccui.Widget.PLIST_TEXTURE:
  33820. d.initWithSpriteFrameName(a)
  33821. }
  33822. this._updateChildrenDisplayedRGBA();
  33823. this._progressBarRendererDirty = this._barRendererAdaptDirty = !0;
  33824. this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize())
  33825. }
  33826. },
  33827. loadProgressBarTexture: function(a, c) {
  33828. if (a) {
  33829. c = c || ccui.Widget.LOCAL_TEXTURE;
  33830. this._progressBarTextureFile = a;
  33831. this._progressBarTexType = c;
  33832. var d = this._progressBarRenderer,
  33833. e = this;
  33834. (!d.texture || !d.texture.isLoaded()) && d.addLoadedEventListener(function() {
  33835. e._findLayout();
  33836. e._updateChildrenDisplayedRGBA();
  33837. e._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5));
  33838. var a = e._progressBarRenderer.getContentSize();
  33839. e._progressBarTextureSize = {
  33840. width: a.width,
  33841. height: a.height
  33842. };
  33843. e._progressBarRendererDirty = !0
  33844. });
  33845. switch (this._progressBarTexType) {
  33846. case ccui.Widget.LOCAL_TEXTURE:
  33847. d.initWithFile(a);
  33848. break;
  33849. case ccui.Widget.PLIST_TEXTURE:
  33850. d.initWithSpriteFrameName(a)
  33851. }
  33852. this._updateChildrenDisplayedRGBA();
  33853. this._progressBarRenderer.setAnchorPoint(cc.p(0, 0.5));
  33854. d = this._progressBarRenderer.getContentSize();
  33855. this._progressBarTextureSize = {
  33856. width: d.width,
  33857. height: d.height
  33858. };
  33859. this._progressBarRendererDirty = !0
  33860. }
  33861. },
  33862. setScale9Enabled: function(a) {
  33863. 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))
  33864. },
  33865. isScale9Enabled: function() {
  33866. return this._scale9Enabled
  33867. },
  33868. ignoreContentAdaptWithSize: function(a) {
  33869. if (!this._scale9Enabled || this._scale9Enabled && !a) ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a), this._prevIgnoreSize = a
  33870. },
  33871. setCapInsets: function(a) {
  33872. this.setCapInsetsBarRenderer(a);
  33873. this.setCapInsetProgressBarRenderer(a)
  33874. },
  33875. setCapInsetsBarRenderer: function(a) {
  33876. this._capInsetsBarRenderer = a;
  33877. this._scale9Enabled && this._barRenderer.setCapInsets(a)
  33878. },
  33879. getCapInsetsBarRenderer: function() {
  33880. return this._capInsetsBarRenderer
  33881. },
  33882. setCapInsetProgressBarRebderer: function(a) {
  33883. this._capInsetsProgressBarRenderer = a;
  33884. this._scale9Enabled && this._progressBarRenderer.setCapInsets(a)
  33885. },
  33886. setCapInsetProgressBarRenderer: function(a) {
  33887. this._capInsetsProgressBarRenderer = a;
  33888. this._scale9Enabled && this._progressBarRenderer.setCapInsets(a)
  33889. },
  33890. getCapInsetsProgressBarRebderer: function() {
  33891. return this._capInsetsProgressBarRenderer
  33892. },
  33893. loadSlidBallTextures: function(a, c, d, e) {
  33894. this.loadSlidBallTextureNormal(a, e);
  33895. this.loadSlidBallTexturePressed(c, e);
  33896. this.loadSlidBallTextureDisabled(d, e)
  33897. },
  33898. loadSlidBallTextureNormal: function(a, c) {
  33899. if (a) {
  33900. c = c || ccui.Widget.LOCAL_TEXTURE;
  33901. this._slidBallNormalTextureFile = a;
  33902. this._ballNTexType = c;
  33903. var d = this;
  33904. (!this._slidBallNormalRenderer.texture || !this._slidBallNormalRenderer.texture.isLoaded()) && this._slidBallNormalRenderer.addLoadedEventListener(function() {
  33905. d._updateChildrenDisplayedRGBA()
  33906. });
  33907. switch (this._ballNTexType) {
  33908. case ccui.Widget.LOCAL_TEXTURE:
  33909. this._slidBallNormalRenderer.initWithFile(a);
  33910. break;
  33911. case ccui.Widget.PLIST_TEXTURE:
  33912. this._slidBallNormalRenderer.initWithSpriteFrameName(a)
  33913. }
  33914. this._updateChildrenDisplayedRGBA()
  33915. }
  33916. },
  33917. loadSlidBallTexturePressed: function(a, c) {
  33918. if (a) {
  33919. c = c || ccui.Widget.LOCAL_TEXTURE;
  33920. this._slidBallPressedTextureFile = a;
  33921. this._ballPTexType = c;
  33922. var d = this;
  33923. (!this._slidBallPressedRenderer.texture || !this._slidBallPressedRenderer.texture.isLoaded()) && this._slidBallPressedRenderer.addLoadedEventListener(function() {
  33924. d._updateChildrenDisplayedRGBA()
  33925. });
  33926. switch (this._ballPTexType) {
  33927. case ccui.Widget.LOCAL_TEXTURE:
  33928. this._slidBallPressedRenderer.initWithFile(a);
  33929. break;
  33930. case ccui.Widget.PLIST_TEXTURE:
  33931. this._slidBallPressedRenderer.initWithSpriteFrameName(a)
  33932. }
  33933. this._updateChildrenDisplayedRGBA()
  33934. }
  33935. },
  33936. loadSlidBallTextureDisabled: function(a, c) {
  33937. if (a) {
  33938. c = c || ccui.Widget.LOCAL_TEXTURE;
  33939. this._slidBallDisabledTextureFile = a;
  33940. this._ballDTexType = c;
  33941. var d = this;
  33942. (!this._slidBallDisabledRenderer.texture || !this._slidBallDisabledRenderer.texture.isLoaded()) && this._slidBallDisabledRenderer.addLoadedEventListener(function() {
  33943. d._updateChildrenDisplayedRGBA()
  33944. });
  33945. switch (this._ballDTexType) {
  33946. case ccui.Widget.LOCAL_TEXTURE:
  33947. this._slidBallDisabledRenderer.initWithFile(a);
  33948. break;
  33949. case ccui.Widget.PLIST_TEXTURE:
  33950. this._slidBallDisabledRenderer.initWithSpriteFrameName(a)
  33951. }
  33952. this._updateChildrenDisplayedRGBA()
  33953. }
  33954. },
  33955. setPercent: function(a) {
  33956. 100 < a && (a = 100);
  33957. 0 > a && (a = 0);
  33958. this._percent = a;
  33959. a = this._barLength * (a / 100);
  33960. this._slidBallRenderer.setPosition(cc.p(a, this._contentSize.height / 2));
  33961. if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(cc.size(a, this._progressBarTextureSize.height));
  33962. else {
  33963. var c = this._progressBarRenderer,
  33964. d = c.getTextureRect();
  33965. c.setTextureRect(cc.rect(d.x, d.y, a, d.height), c.isTextureRectRotated())
  33966. }
  33967. },
  33968. hitTest: function(a) {
  33969. a = this._slidBallNormalRenderer.convertToNodeSpace(a);
  33970. var c = this._slidBallNormalRenderer.getContentSize(),
  33971. c = cc.rect(0, 0, c.width, c.height);
  33972. return a.x >= c.x && a.x <= c.x + c.width && a.y >= c.y && a.y <= c.y + c.height ? !0 : !1
  33973. },
  33974. onTouchBegan: function(a, c) {
  33975. var d = ccui.Widget.prototype.onTouchBegan.call(this, a, c);
  33976. if (this._hit) {
  33977. var e = this.convertToNodeSpace(this._touchBeganPosition);
  33978. this.setPercent(this._getPercentWithBallPos(e.x));
  33979. this._percentChangedEvent()
  33980. }
  33981. return d
  33982. },
  33983. onTouchMoved: function(a, c) {
  33984. var d = a.getLocation(),
  33985. d = this.convertToNodeSpace(d);
  33986. this.setPercent(this._getPercentWithBallPos(d.x));
  33987. this._percentChangedEvent()
  33988. },
  33989. onTouchEnded: function(a, c) {
  33990. ccui.Widget.prototype.onTouchEnded.call(this, a, c)
  33991. },
  33992. onTouchCancelled: function(a, c) {
  33993. ccui.Widget.prototype.onTouchCancelled.call(this, a, c)
  33994. },
  33995. _getPercentWithBallPos: function(a) {
  33996. return 100 * (a / this._barLength)
  33997. },
  33998. addEventListenerSlider: function(a, c) {
  33999. this._sliderEventSelector = a;
  34000. this._sliderEventListener = c
  34001. },
  34002. addEventListener: function(a) {
  34003. this._eventCallback = a
  34004. },
  34005. _percentChangedEvent: function() {
  34006. this._sliderEventListener && this._sliderEventSelector && this._sliderEventSelector.call(this._sliderEventListener, this, ccui.Slider.EVENT_PERCENT_CHANGED);
  34007. this._eventCallback && this._eventCallback(ccui.Slider.EVENT_PERCENT_CHANGED)
  34008. },
  34009. getPercent: function() {
  34010. return this._percent
  34011. },
  34012. _onSizeChanged: function() {
  34013. ccui.Widget.prototype._onSizeChanged.call(this);
  34014. this._progressBarRendererDirty = this._barRendererAdaptDirty = !0
  34015. },
  34016. _adaptRenderers: function() {
  34017. this._barRendererAdaptDirty && (this._barRendererScaleChangedWithSize(), this._barRendererAdaptDirty = !1);
  34018. this._progressBarRendererDirty && (this._progressBarRendererScaleChangedWithSize(), this._progressBarRendererDirty = !1)
  34019. },
  34020. getVirtualRendererSize: function() {
  34021. return this._barRenderer.getContentSize()
  34022. },
  34023. getVirtualRenderer: function() {
  34024. return this._barRenderer
  34025. },
  34026. _barRendererScaleChangedWithSize: function() {
  34027. if (this._ignoreSize) this._barRenderer.setScale(1), this._barLength = this._contentSize.width;
  34028. else if (this._barLength = this._contentSize.width, this._scale9Enabled) this._barRenderer.setPreferredSize(this._contentSize);
  34029. else {
  34030. var a = this._barRenderer.getContentSize();
  34031. if (0 >= a.width || 0 >= a.height) {
  34032. this._barRenderer.setScale(1);
  34033. return
  34034. }
  34035. var c = this._contentSize.height / a.height;
  34036. this._barRenderer.setScaleX(this._contentSize.width / a.width);
  34037. this._barRenderer.setScaleY(c)
  34038. }
  34039. this._barRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2);
  34040. this.setPercent(this._percent)
  34041. },
  34042. _progressBarRendererScaleChangedWithSize: function() {
  34043. if (this._ignoreSize) {
  34044. if (!this._scale9Enabled) {
  34045. var a = this._progressBarTextureSize,
  34046. c = this._contentSize.width / a.width,
  34047. a = this._contentSize.height / a.height;
  34048. this._progressBarRenderer.setScaleX(c);
  34049. this._progressBarRenderer.setScaleY(a)
  34050. }
  34051. } else if (this._scale9Enabled) this._progressBarRenderer.setPreferredSize(this._contentSize), this._progressBarTextureSize = this._progressBarRenderer.getContentSize();
  34052. else {
  34053. a = this._progressBarTextureSize;
  34054. if (0 >= a.width || 0 >= a.height) {
  34055. this._progressBarRenderer.setScale(1);
  34056. return
  34057. }
  34058. c = this._contentSize.width / a.width;
  34059. a = this._contentSize.height / a.height;
  34060. this._progressBarRenderer.setScaleX(c);
  34061. this._progressBarRenderer.setScaleY(a)
  34062. }
  34063. this._progressBarRenderer.setPosition(0, this._contentSize.height / 2);
  34064. this.setPercent(this._percent)
  34065. },
  34066. _onPressStateChangedToNormal: function() {
  34067. this._slidBallNormalRenderer.setVisible(!0);
  34068. this._slidBallPressedRenderer.setVisible(!1);
  34069. this._slidBallDisabledRenderer.setVisible(!1)
  34070. },
  34071. _onPressStateChangedToPressed: function() {
  34072. this._slidBallNormalRenderer.setVisible(!1);
  34073. this._slidBallPressedRenderer.setVisible(!0);
  34074. this._slidBallDisabledRenderer.setVisible(!1)
  34075. },
  34076. _onPressStateChangedToDisabled: function() {
  34077. this._slidBallNormalRenderer.setVisible(!1);
  34078. this._slidBallPressedRenderer.setVisible(!1);
  34079. this._slidBallDisabledRenderer.setVisible(!0)
  34080. },
  34081. getDescription: function() {
  34082. return "Slider"
  34083. },
  34084. _createCloneInstance: function() {
  34085. return ccui.Slider.create()
  34086. },
  34087. _copySpecialProperties: function(a) {
  34088. this._prevIgnoreSize = a._prevIgnoreSize;
  34089. this.setScale9Enabled(a._scale9Enabled);
  34090. this.loadBarTexture(a._textureFile, a._barTexType);
  34091. this.loadProgressBarTexture(a._progressBarTextureFile, a._progressBarTexType);
  34092. this.loadSlidBallTextureNormal(a._slidBallNormalTextureFile, a._ballNTexType);
  34093. this.loadSlidBallTexturePressed(a._slidBallPressedTextureFile, a._ballPTexType);
  34094. this.loadSlidBallTextureDisabled(a._slidBallDisabledTextureFile, a._ballDTexType);
  34095. this.setPercent(a.getPercent());
  34096. this._sliderEventListener = a._sliderEventListener;
  34097. this._sliderEventSelector = a._sliderEventSelector;
  34098. this._eventCallback = a._eventCallback
  34099. }
  34100. });
  34101. _p = ccui.Slider.prototype;
  34102. cc.defineGetterSetter(_p, "percent", _p.getPercent, _p.setPercent);
  34103. _p = null;
  34104. ccui.Slider.create = function() {
  34105. return new ccui.Slider
  34106. };
  34107. ccui.Slider.EVENT_PERCENT_CHANGED = 0;
  34108. ccui.Slider.BASEBAR_RENDERER_ZORDER = -3;
  34109. ccui.Slider.PROGRESSBAR_RENDERER_ZORDER = -2;
  34110. ccui.Slider.BALL_RENDERER_ZORDER = -1;
  34111. ccui.Text = ccui.Widget.extend({
  34112. _touchScaleChangeEnabled: !1,
  34113. _normalScaleValueX: 1,
  34114. _normalScaleValueY: 1,
  34115. _fontName: "Thonburi",
  34116. _fontSize: 10,
  34117. _onSelectedScaleOffset: 0.5,
  34118. _labelRenderer: "",
  34119. _textAreaSize: null,
  34120. _textVerticalAlignment: 0,
  34121. _textHorizontalAlignment: 0,
  34122. _className: "Text",
  34123. _type: null,
  34124. _labelRendererAdaptDirty: !0,
  34125. ctor: function(a, c, d) {
  34126. this._type = ccui.Text.Type.SYSTEM;
  34127. this._textAreaSize = cc.size(0, 0);
  34128. ccui.Widget.prototype.ctor.call(this);
  34129. d && this.init(a, c, d)
  34130. },
  34131. init: function(a, c, d) {
  34132. return ccui.Widget.prototype.init.call(this) ? (0 < arguments.length && (this.setString(a), this.setFontName(c), this.setFontSize(d)), !0) : !1
  34133. },
  34134. _initRenderer: function() {
  34135. this._labelRenderer = new cc.LabelTTF;
  34136. this.addProtectedChild(this._labelRenderer, ccui.Text.RENDERER_ZORDER, -1)
  34137. },
  34138. setText: function(a) {
  34139. cc.log("Please use the setString");
  34140. this.setString(a)
  34141. },
  34142. setString: function(a) {
  34143. this._labelRenderer.setString(a);
  34144. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34145. this._labelRendererAdaptDirty = !0
  34146. },
  34147. getStringValue: function() {
  34148. cc.log("Please use the getString");
  34149. return this._labelRenderer.getString()
  34150. },
  34151. getString: function() {
  34152. return this._labelRenderer.getString()
  34153. },
  34154. getStringLength: function() {
  34155. return this._labelRenderer.getStringLength()
  34156. },
  34157. setFontSize: function(a) {
  34158. this._labelRenderer.setFontSize(a);
  34159. this._fontSize = a;
  34160. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34161. this._labelRendererAdaptDirty = !0
  34162. },
  34163. getFontSize: function() {
  34164. return this._fontSize
  34165. },
  34166. setFontName: function(a) {
  34167. this._fontName = a;
  34168. this._labelRenderer.setFontName(a);
  34169. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34170. this._labelRendererAdaptDirty = !0
  34171. },
  34172. getFontName: function() {
  34173. return this._fontName
  34174. },
  34175. _setFont: function(a) {
  34176. var c = cc.LabelTTF._fontStyleRE.exec(a);
  34177. c && (this._fontSize = parseInt(c[1]), this._fontName = c[2], this._labelRenderer._setFont(a), this._labelScaleChangedWithSize())
  34178. },
  34179. _getFont: function() {
  34180. return this._labelRenderer._getFont()
  34181. },
  34182. getType: function() {
  34183. return this._type
  34184. },
  34185. setTextAreaSize: function(a) {
  34186. this._labelRenderer.setDimensions(a);
  34187. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34188. this._labelRendererAdaptDirty = !0
  34189. },
  34190. getTextAreaSize: function() {
  34191. return this._labelRenderer.getDimensions()
  34192. },
  34193. setTextHorizontalAlignment: function(a) {
  34194. this._labelRenderer.setHorizontalAlignment(a);
  34195. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34196. this._labelRendererAdaptDirty = !0
  34197. },
  34198. getTextHorizontalAlignment: function() {
  34199. return this._labelRenderer.getHorizontalAlignment()
  34200. },
  34201. setTextVerticalAlignment: function(a) {
  34202. this._labelRenderer.setVerticalAlignment(a);
  34203. this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize());
  34204. this._labelRendererAdaptDirty = !0
  34205. },
  34206. getTextVerticalAlignment: function() {
  34207. return this._labelRenderer.getVerticalAlignment()
  34208. },
  34209. setTouchScaleChangeEnabled: function(a) {
  34210. this._touchScaleChangeEnabled = a
  34211. },
  34212. isTouchScaleChangeEnabled: function() {
  34213. return this._touchScaleChangeEnabled
  34214. },
  34215. _onPressStateChangedToNormal: function() {
  34216. this._touchScaleChangeEnabled && (this._labelRenderer.setScaleX(this._normalScaleValueX), this._labelRenderer.setScaleY(this._normalScaleValueY))
  34217. },
  34218. _onPressStateChangedToPressed: function() {
  34219. this._touchScaleChangeEnabled && (this._labelRenderer.setScaleX(this._normalScaleValueX + this._onSelectedScaleOffset), this._labelRenderer.setScaleY(this._normalScaleValueY + this._onSelectedScaleOffset))
  34220. },
  34221. _onPressStateChangedToDisabled: function() {},
  34222. _updateFlippedX: function() {
  34223. this._flippedX ? this._labelRenderer.setScaleX(-1) : this._labelRenderer.setScaleX(1)
  34224. },
  34225. _updateFlippedY: function() {
  34226. this._flippedY ? this._labelRenderer.setScaleY(-1) : this._labelRenderer.setScaleY(1)
  34227. },
  34228. _onSizeChanged: function() {
  34229. ccui.Widget.prototype._onSizeChanged.call(this);
  34230. this._labelRendererAdaptDirty = !0
  34231. },
  34232. _adaptRenderers: function() {
  34233. this._labelRendererAdaptDirty && (this._labelScaleChangedWithSize(), this._labelRendererAdaptDirty = !1)
  34234. },
  34235. getVirtualRendererSize: function() {
  34236. return this._labelRenderer.getContentSize()
  34237. },
  34238. getVirtualRenderer: function() {
  34239. return this._labelRenderer
  34240. },
  34241. _labelScaleChangedWithSize: function() {
  34242. var a = this._contentSize;
  34243. if (this._ignoreSize) this._labelRenderer.setScale(1), this._normalScaleValueX = this._normalScaleValueY = 1;
  34244. else {
  34245. this._labelRenderer.setDimensions(cc.size(a.width, a.height));
  34246. var c = this._labelRenderer.getContentSize();
  34247. if (0 >= c.width || 0 >= c.height) {
  34248. this._labelRenderer.setScale(1);
  34249. return
  34250. }
  34251. var d = a.width / c.width,
  34252. c = a.height / c.height;
  34253. this._labelRenderer.setScaleX(d);
  34254. this._labelRenderer.setScaleY(c);
  34255. this._normalScaleValueX = d;
  34256. this._normalScaleValueY = c
  34257. }
  34258. this._labelRenderer.setPosition(a.width / 2, a.height / 2)
  34259. },
  34260. getDescription: function() {
  34261. return "Label"
  34262. },
  34263. enableShadow: function(a, c, d) {
  34264. this._labelRenderer.enableShadow(a, c, d)
  34265. },
  34266. enableOutline: function(a, c) {
  34267. this._labelRenderer.enableOutline(a, c)
  34268. },
  34269. enableGlow: function(a) {
  34270. this._type == ccui.Text.Type.TTF && this._labelRenderer.enableGlow(a)
  34271. },
  34272. disableEffect: function() {
  34273. this._labelRenderer.disableEffect()
  34274. },
  34275. _createCloneInstance: function() {
  34276. return ccui.Text.create()
  34277. },
  34278. _copySpecialProperties: function(a) {
  34279. 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()))
  34280. },
  34281. _setBoundingWidth: function(a) {
  34282. this._textAreaSize.width = a;
  34283. this._labelRenderer._setBoundingWidth(a);
  34284. this._labelScaleChangedWithSize()
  34285. },
  34286. _setBoundingHeight: function(a) {
  34287. this._textAreaSize.height = a;
  34288. this._labelRenderer._setBoundingHeight(a);
  34289. this._labelScaleChangedWithSize()
  34290. },
  34291. _getBoundingWidth: function() {
  34292. return this._textAreaSize.width
  34293. },
  34294. _getBoundingHeight: function() {
  34295. return this._textAreaSize.height
  34296. }
  34297. });
  34298. _p = ccui.Text.prototype;
  34299. cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p._setBoundingWidth);
  34300. cc.defineGetterSetter(_p, "boundingHeight", _p._getBoundingHeight, _p._setBoundingHeight);
  34301. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  34302. cc.defineGetterSetter(_p, "stringLength", _p.getStringLength);
  34303. cc.defineGetterSetter(_p, "font", _p._getFont, _p._setFont);
  34304. cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
  34305. cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
  34306. cc.defineGetterSetter(_p, "textAlign", _p.getTextHorizontalAlignment, _p.setTextHorizontalAlignment);
  34307. cc.defineGetterSetter(_p, "verticalAlign", _p.getTextVerticalAlignment, _p.setTextVerticalAlignment);
  34308. _p = null;
  34309. ccui.Label = ccui.Text.create = function(a, c, d) {
  34310. return new ccui.Text(a, c, d)
  34311. };
  34312. ccui.Text.RENDERER_ZORDER = -1;
  34313. ccui.Text.Type = {
  34314. SYSTEM: 0,
  34315. TTF: 1
  34316. };
  34317. ccui.TextAtlas = ccui.Widget.extend({
  34318. _labelAtlasRenderer: null,
  34319. _stringValue: "",
  34320. _charMapFileName: "",
  34321. _itemWidth: 0,
  34322. _itemHeight: 0,
  34323. _startCharMap: "",
  34324. _className: "TextAtlas",
  34325. _labelAtlasRendererAdaptDirty: null,
  34326. ctor: function(a, c, d, e, f) {
  34327. ccui.Widget.prototype.ctor.call(this);
  34328. f && this.setProperty(a, c, d, e, f)
  34329. },
  34330. _initRenderer: function() {
  34331. this._labelAtlasRenderer = new cc.LabelAtlas;
  34332. this._labelAtlasRenderer.setAnchorPoint(cc.p(0.5, 0.5));
  34333. this.addProtectedChild(this._labelAtlasRenderer, ccui.TextAtlas.RENDERER_ZORDER, -1)
  34334. },
  34335. setProperty: function(a, c, d, e, f) {
  34336. this._stringValue = a;
  34337. this._charMapFileName = c;
  34338. this._itemWidth = d;
  34339. this._itemHeight = e;
  34340. this._startCharMap = f;
  34341. this._labelAtlasRenderer.initWithString(a, this._charMapFileName, this._itemWidth, this._itemHeight, this._startCharMap[0]);
  34342. this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());
  34343. this._labelAtlasRendererAdaptDirty = !0
  34344. },
  34345. setString: function(a) {
  34346. this._stringValue = a;
  34347. this._labelAtlasRenderer.setString(a);
  34348. this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize());
  34349. this._labelAtlasRendererAdaptDirty = !0
  34350. },
  34351. setStringValue: function(a) {
  34352. cc.log("Please use the setString");
  34353. this.setString(a)
  34354. },
  34355. getStringValue: function() {
  34356. cc.log("Please use the getString");
  34357. return this.getString()
  34358. },
  34359. getString: function() {
  34360. return this._labelAtlasRenderer.getString()
  34361. },
  34362. getStringLength: function() {
  34363. return this._labelAtlasRenderer.getStringLength()
  34364. },
  34365. _onSizeChanged: function() {
  34366. ccui.Widget.prototype._onSizeChanged.call(this);
  34367. this._labelAtlasRendererAdaptDirty = !0
  34368. },
  34369. _adaptRenderers: function() {
  34370. this._labelAtlasRendererAdaptDirty && (this._labelAtlasScaleChangedWithSize(), this._labelAtlasRendererAdaptDirty = !1)
  34371. },
  34372. getVirtualRendererSize: function() {
  34373. return this._labelAtlasRenderer.getContentSize()
  34374. },
  34375. getVirtualRenderer: function() {
  34376. return this._labelAtlasRenderer
  34377. },
  34378. _labelAtlasScaleChangedWithSize: function() {
  34379. var a = this._labelAtlasRenderer;
  34380. if (this._ignoreSize) a.setScale(1);
  34381. else {
  34382. var c = a.getContentSize();
  34383. if (0 >= c.width || 0 >= c.height) {
  34384. a.setScale(1);
  34385. return
  34386. }
  34387. a.setScaleX(this._contentSize.width / c.width);
  34388. a.setScaleY(this._contentSize.height / c.height)
  34389. }
  34390. a.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  34391. },
  34392. getDescription: function() {
  34393. return "LabelAtlas"
  34394. },
  34395. _copySpecialProperties: function(a) {
  34396. a && this.setProperty(a._stringValue, a._charMapFileName, a._itemWidth, a._itemHeight, a._startCharMap)
  34397. },
  34398. _createCloneInstance: function() {
  34399. return ccui.TextAtlas.create()
  34400. }
  34401. });
  34402. _p = ccui.TextAtlas.prototype;
  34403. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  34404. _p = null;
  34405. ccui.TextAtlas.create = function(a, c, d, e, f) {
  34406. return new ccui.TextAtlas(a, c, d, e, f)
  34407. };
  34408. ccui.TextAtlas.RENDERER_ZORDER = -1;
  34409. ccui.LabelBMFont = ccui.TextBMFont = ccui.Widget.extend({
  34410. _labelBMFontRenderer: null,
  34411. _fntFileHasInit: !1,
  34412. _fntFileName: "",
  34413. _stringValue: "",
  34414. _className: "TextBMFont",
  34415. _labelBMFontRendererAdaptDirty: !0,
  34416. ctor: function(a, c) {
  34417. ccui.Widget.prototype.ctor.call(this);
  34418. void 0 != c && (this.setFntFile(c), this.setString(a))
  34419. },
  34420. _initRenderer: function() {
  34421. this._labelBMFontRenderer = cc.LabelBMFont.create();
  34422. this.addProtectedChild(this._labelBMFontRenderer, ccui.TextBMFont.RENDERER_ZORDER, -1)
  34423. },
  34424. setFntFile: function(a) {
  34425. if (a) {
  34426. var c = this;
  34427. c._fntFileName = a;
  34428. c._fntFileHasInit = !0;
  34429. c._labelBMFontRenderer.initWithString(this._stringValue, a);
  34430. a = c._labelBMFontRenderer;
  34431. a._textureLoaded || a.addLoadedEventListener(function() {
  34432. c.updateSizeAndPosition()
  34433. })
  34434. }
  34435. },
  34436. setText: function(a) {
  34437. cc.log("Please use the setString");
  34438. this.setString(a)
  34439. },
  34440. setString: function(a) {
  34441. this._stringValue = a;
  34442. this._fntFileHasInit && (this._labelBMFontRenderer.setString(a), this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()), this._labelBMFontRendererAdaptDirty = !0)
  34443. },
  34444. getString: function() {
  34445. return this._stringValue
  34446. },
  34447. getStringLength: function() {
  34448. return this._labelBMFontRenderer.getStringLength()
  34449. },
  34450. _onSizeChanged: function() {
  34451. ccui.Widget.prototype._onSizeChanged.call(this);
  34452. this._labelBMFontRendererAdaptDirty = !0
  34453. },
  34454. _adaptRenderers: function() {
  34455. this._labelBMFontRendererAdaptDirty && (this._labelBMFontScaleChangedWithSize(), this._labelBMFontRendererAdaptDirty = !1)
  34456. },
  34457. getVirtualRendererSize: function() {
  34458. return this._labelBMFontRenderer.getContentSize()
  34459. },
  34460. getVirtualRenderer: function() {
  34461. return this._labelBMFontRenderer
  34462. },
  34463. _labelBMFontScaleChangedWithSize: function() {
  34464. var a = this._labelBMFontRenderer;
  34465. if (this._ignoreSize) a.setScale(1);
  34466. else {
  34467. var c = a.getContentSize();
  34468. if (0 >= c.width || 0 >= c.height) {
  34469. a.setScale(1);
  34470. return
  34471. }
  34472. a.setScaleX(this._contentSize.width / c.width);
  34473. a.setScaleY(this._contentSize.height / c.height)
  34474. }
  34475. a.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  34476. },
  34477. getDescription: function() {
  34478. return "LabelBMFont"
  34479. },
  34480. createCloneInstance: function() {
  34481. return ccui.TextBMFont.create()
  34482. },
  34483. copySpecialProperties: function(a) {
  34484. this.setFntFile(a._fntFileName);
  34485. this.setString(a._stringValue)
  34486. }
  34487. });
  34488. _p = ccui.TextBMFont.prototype;
  34489. cc.defineGetterSetter(_p, "string", _p.getString, _p.setStringValue);
  34490. _p = null;
  34491. ccui.TextBMFont.create = function(a, c) {
  34492. return new ccui.ccui.TextBMFont(a, c)
  34493. };
  34494. ccui.TextBMFont.RENDERER_ZORDER = -1;
  34495. ccui.UICCTextField = cc.TextFieldTTF.extend({
  34496. _maxLengthEnabled: !1,
  34497. _maxLength: 0,
  34498. _passwordEnabled: !1,
  34499. _passwordStyleText: "",
  34500. _attachWithIME: !1,
  34501. _detachWithIME: !1,
  34502. _insertText: !1,
  34503. _deleteBackward: !1,
  34504. _className: "UICCTextField",
  34505. _textFieldRendererAdaptDirty: !0,
  34506. ctor: function() {
  34507. cc.TextFieldTTF.prototype.ctor.call(this);
  34508. this._maxLengthEnabled = !1;
  34509. this._maxLength = 0;
  34510. this._passwordEnabled = !1;
  34511. this._passwordStyleText = "*";
  34512. this._deleteBackward = this._insertText = this._detachWithIME = this._attachWithIME = !1
  34513. },
  34514. onEnter: function() {
  34515. cc.TextFieldTTF.prototype.onEnter.call(this);
  34516. cc.TextFieldTTF.prototype.setDelegate.call(this, this)
  34517. },
  34518. onTextFieldAttachWithIME: function(a) {
  34519. this.setAttachWithIME(!0);
  34520. return !1
  34521. },
  34522. onTextFieldInsertText: function(a, c, d) {
  34523. if (1 == d && "\n" == c) return !1;
  34524. this.setInsertText(!0);
  34525. return this._maxLengthEnabled && cc.TextFieldTTF.prototype.getCharCount.call(this) >= this._maxLength
  34526. },
  34527. onTextFieldDeleteBackward: function(a, c, d) {
  34528. this.setDeleteBackward(!0);
  34529. return !1
  34530. },
  34531. onTextFieldDetachWithIME: function(a) {
  34532. this.setDetachWithIME(!0);
  34533. return !1
  34534. },
  34535. insertText: function(a, c) {
  34536. "\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()))
  34537. },
  34538. deleteBackward: function() {
  34539. cc.TextFieldTTF.prototype.deleteBackward.call(this);
  34540. 0 < cc.TextFieldTTF.prototype.getCharCount.call(this) && this._passwordEnabled && this.setPasswordText(this._inputText)
  34541. },
  34542. openIME: function() {
  34543. cc.TextFieldTTF.prototype.attachWithIME.call(this)
  34544. },
  34545. closeIME: function() {
  34546. cc.TextFieldTTF.prototype.detachWithIME.call(this)
  34547. },
  34548. setMaxLengthEnabled: function(a) {
  34549. this._maxLengthEnabled = a
  34550. },
  34551. isMaxLengthEnabled: function() {
  34552. return this._maxLengthEnabled
  34553. },
  34554. setMaxLength: function(a) {
  34555. this._maxLength = a
  34556. },
  34557. getMaxLength: function() {
  34558. return this._maxLength
  34559. },
  34560. getCharCount: function() {
  34561. return cc.TextFieldTTF.prototype.getCharCount.call(this)
  34562. },
  34563. setPasswordEnabled: function(a) {
  34564. this._passwordEnabled = a
  34565. },
  34566. isPasswordEnabled: function() {
  34567. return this._passwordEnabled
  34568. },
  34569. setPasswordStyleText: function(a) {
  34570. if (!(1 < a.length)) {
  34571. var c = a.charCodeAt(0);
  34572. 33 > c || 126 < c || (this._passwordStyleText = a)
  34573. }
  34574. },
  34575. setPasswordText: function(a) {
  34576. var c = "",
  34577. d = a.length;
  34578. a = d;
  34579. this._maxLengthEnabled && d > this._maxLength && (a = this._maxLength);
  34580. for (d = 0; d < a; ++d) c += this._passwordStyleText;
  34581. cc.LabelTTF.prototype.setString.call(this, c)
  34582. },
  34583. setAttachWithIME: function(a) {
  34584. this._attachWithIME = a
  34585. },
  34586. getAttachWithIME: function() {
  34587. return this._attachWithIME
  34588. },
  34589. setDetachWithIME: function(a) {
  34590. this._detachWithIME = a
  34591. },
  34592. getDetachWithIME: function() {
  34593. return this._detachWithIME
  34594. },
  34595. setInsertText: function(a) {
  34596. this._insertText = a
  34597. },
  34598. getInsertText: function() {
  34599. return this._insertText
  34600. },
  34601. setDeleteBackward: function(a) {
  34602. this._deleteBackward = a
  34603. },
  34604. getDeleteBackward: function() {
  34605. return this._deleteBackward
  34606. },
  34607. init: function() {
  34608. return ccui.Widget.prototype.init.call(this) ? (this.setTouchEnabled(!0), !0) : !1
  34609. },
  34610. onDraw: function(a) {
  34611. return !1
  34612. }
  34613. });
  34614. ccui.UICCTextField.create = function(a, c, d) {
  34615. var e = new ccui.UICCTextField;
  34616. return e && e.initWithString("", c, d) ? (a && e.setPlaceHolder(a), e) : null
  34617. };
  34618. ccui.TextField = ccui.Widget.extend({
  34619. _textFieldRenderer: null,
  34620. _touchWidth: 0,
  34621. _touchHeight: 0,
  34622. _useTouchArea: !1,
  34623. _textFieldEventListener: null,
  34624. _textFieldEventSelector: null,
  34625. _passwordStyleText: "",
  34626. _textFieldRendererAdaptDirty: !0,
  34627. _fontName: "",
  34628. _fontSize: 12,
  34629. ctor: function() {
  34630. ccui.Widget.prototype.ctor.call(this)
  34631. },
  34632. init: function() {
  34633. return ccui.Widget.prototype.init.call(this) ? (this.setTouchEnabled(!0), !0) : !1
  34634. },
  34635. onEnter: function() {
  34636. ccui.Widget.prototype.onEnter.call(this);
  34637. this.scheduleUpdate()
  34638. },
  34639. _initRenderer: function() {
  34640. this._textFieldRenderer = ccui.UICCTextField.create("input words here", "Thonburi", 20);
  34641. this.addProtectedChild(this._textFieldRenderer, ccui.TextField.RENDERER_ZORDER, -1)
  34642. },
  34643. setTouchSize: function(a) {
  34644. this._touchWidth = a.width;
  34645. this._touchHeight = a.height
  34646. },
  34647. setTouchAreaEnabled: function(a) {
  34648. this._useTouchArea = a
  34649. },
  34650. hitTest: function(a) {
  34651. if (this._useTouchArea) {
  34652. a = this.convertToNodeSpace(a);
  34653. var c = cc.rect(-this._touchWidth * this._anchorPoint.x, -this._touchHeight * this._anchorPoint.y, this._touchWidth, this._touchHeight);
  34654. return a.x >= c.x && a.x <= c.x + c.width && a.y >= c.y && a.y <= c.y + c.height
  34655. }
  34656. return ccui.Widget.prototype.hitTest.call(this, a)
  34657. },
  34658. getTouchSize: function() {
  34659. return cc.size(this._touchWidth, this._touchHeight)
  34660. },
  34661. setText: function(a) {
  34662. cc.log("Please use the setString");
  34663. this.setString(a)
  34664. },
  34665. setString: function(a) {
  34666. 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()))
  34667. },
  34668. setPlaceHolder: function(a) {
  34669. this._textFieldRenderer.setPlaceHolder(a);
  34670. this._textFieldRendererAdaptDirty = !0;
  34671. this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
  34672. },
  34673. getPlaceHolder: function() {
  34674. return this._textFieldRenderer.getPlaceHolder()
  34675. },
  34676. setFontSize: function(a) {
  34677. this._textFieldRenderer.setFontSize(a);
  34678. this._fontSize = a;
  34679. this._textFieldRendererAdaptDirty = !0;
  34680. this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
  34681. },
  34682. getFontSize: function() {
  34683. return this._fontSize
  34684. },
  34685. setFontName: function(a) {
  34686. this._textFieldRenderer.setFontName(a);
  34687. this._fontName = a;
  34688. this._textFieldRendererAdaptDirty = !0;
  34689. this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())
  34690. },
  34691. getFontName: function() {
  34692. return this._fontName
  34693. },
  34694. didNotSelectSelf: function() {
  34695. this._textFieldRenderer.detachWithIME()
  34696. },
  34697. getStringValue: function() {
  34698. cc.log("Please use the getString");
  34699. return this.getString()
  34700. },
  34701. getString: function() {
  34702. return this._textFieldRenderer.getString()
  34703. },
  34704. getStringLength: function() {
  34705. return this._textFieldRenderer.getStringLength()
  34706. },
  34707. onTouchBegan: function(a, c) {
  34708. var d = this,
  34709. e = ccui.Widget.prototype.onTouchBegan.call(d, a, c);
  34710. d._hit && setTimeout(function() {
  34711. d._textFieldRenderer.attachWithIME()
  34712. }, 0);
  34713. return e
  34714. },
  34715. setMaxLengthEnabled: function(a) {
  34716. this._textFieldRenderer.setMaxLengthEnabled(a)
  34717. },
  34718. isMaxLengthEnabled: function() {
  34719. return this._textFieldRenderer.isMaxLengthEnabled()
  34720. },
  34721. setMaxLength: function(a) {
  34722. this._textFieldRenderer.setMaxLength(a);
  34723. this.setString(this.getString())
  34724. },
  34725. getMaxLength: function() {
  34726. return this._textFieldRenderer.getMaxLength()
  34727. },
  34728. setPasswordEnabled: function(a) {
  34729. this._textFieldRenderer.setPasswordEnabled(a)
  34730. },
  34731. isPasswordEnabled: function() {
  34732. return this._textFieldRenderer.isPasswordEnabled()
  34733. },
  34734. setPasswordStyleText: function(a) {
  34735. this._textFieldRenderer.setPasswordStyleText(a);
  34736. this._passwordStyleText = a;
  34737. this.setString(this.getString())
  34738. },
  34739. getPasswordStyleText: function() {
  34740. return this._passwordStyleText
  34741. },
  34742. update: function(a) {
  34743. this.getAttachWithIME() && (this._attachWithIMEEvent(), this.setAttachWithIME(!1));
  34744. this.getDetachWithIME() && (this._detachWithIMEEvent(), this.setDetachWithIME(!1));
  34745. this.getInsertText() && (this._insertTextEvent(), this.setInsertText(!1), this._textFieldRendererAdaptDirty = !0, this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()));
  34746. this.getDeleteBackward() && (this._deleteBackwardEvent(), this.setDeleteBackward(!1), this._textFieldRendererAdaptDirty = !0, this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()))
  34747. },
  34748. getAttachWithIME: function() {
  34749. return this._textFieldRenderer.getAttachWithIME()
  34750. },
  34751. setAttachWithIME: function(a) {
  34752. this._textFieldRenderer.setAttachWithIME(a)
  34753. },
  34754. getDetachWithIME: function() {
  34755. return this._textFieldRenderer.getDetachWithIME()
  34756. },
  34757. setDetachWithIME: function(a) {
  34758. this._textFieldRenderer.setDetachWithIME(a)
  34759. },
  34760. getInsertText: function() {
  34761. return this._textFieldRenderer.getInsertText()
  34762. },
  34763. setInsertText: function(a) {
  34764. this._textFieldRenderer.setInsertText(a)
  34765. },
  34766. getDeleteBackward: function() {
  34767. return this._textFieldRenderer.getDeleteBackward()
  34768. },
  34769. setDeleteBackward: function(a) {
  34770. this._textFieldRenderer.setDeleteBackward(a)
  34771. },
  34772. _attachWithIMEEvent: function() {
  34773. this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_ATTACH_WITH_IME);
  34774. this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_ATTACH_WITH_IME)
  34775. },
  34776. _detachWithIMEEvent: function() {
  34777. this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DETACH_WITH_IME);
  34778. this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_DETACH_WITH_IME)
  34779. },
  34780. _insertTextEvent: function() {
  34781. this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_INSERT_TEXT);
  34782. this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_INSERT_TEXT)
  34783. },
  34784. _deleteBackwardEvent: function() {
  34785. this._textFieldEventListener && this._textFieldEventSelector && this._textFieldEventSelector.call(this._textFieldEventListener, this, ccui.TextField.EVENT_DELETE_BACKWARD);
  34786. this._eventCallback && this._eventCallback(this, ccui.TextField.EVENT_DELETE_BACKWARD)
  34787. },
  34788. addEventListenerTextField: function(a, c) {
  34789. this._textFieldEventSelector = a;
  34790. this._textFieldEventListener = c
  34791. },
  34792. addEventListener: function(a) {
  34793. this._eventCallback = a
  34794. },
  34795. _onSizeChanged: function() {
  34796. ccui.Widget.prototype._onSizeChanged.call(this);
  34797. this._textFieldRendererAdaptDirty = !0
  34798. },
  34799. _adaptRenderers: function() {
  34800. this._textFieldRendererAdaptDirty && (this._textfieldRendererScaleChangedWithSize(), this._textFieldRendererAdaptDirty = !1)
  34801. },
  34802. _textfieldRendererScaleChangedWithSize: function() {
  34803. this._ignoreSize || this._textFieldRenderer.setDimensions(this._contentSize);
  34804. this._textFieldRenderer.setPosition(this._contentSize.width / 2, this._contentSize.height / 2)
  34805. },
  34806. getVirtualRendererSize: function() {
  34807. return this._textFieldRenderer.getContentSize()
  34808. },
  34809. getVirtualRenderer: function() {
  34810. return this._textFieldRenderer
  34811. },
  34812. getDescription: function() {
  34813. return "TextField"
  34814. },
  34815. attachWithIME: function() {
  34816. this._textFieldRenderer.attachWithIME()
  34817. },
  34818. _createCloneInstance: function() {
  34819. return ccui.TextField.create()
  34820. },
  34821. _copySpecialProperties: function(a) {
  34822. this.setString(a._textFieldRenderer.getString());
  34823. this.setPlaceHolder(a.getString());
  34824. this.setFontSize(a._textFieldRenderer.getFontSize());
  34825. this.setFontName(a._textFieldRenderer.getFontName());
  34826. this.setMaxLengthEnabled(a.isMaxLengthEnabled());
  34827. this.setMaxLength(a.getMaxLength());
  34828. this.setPasswordEnabled(a.isPasswordEnabled());
  34829. this.setPasswordStyleText(a._passwordStyleText);
  34830. this.setAttachWithIME(a.getAttachWithIME());
  34831. this.setDetachWithIME(a.getDetachWithIME());
  34832. this.setInsertText(a.getInsertText());
  34833. this.setDeleteBackward(a.getDeleteBackward())
  34834. },
  34835. setTextAreaSize: function(a) {
  34836. this.setContentSize(a)
  34837. },
  34838. setTextHorizontalAlignment: function(a) {
  34839. this._textFieldRenderer.setHorizontalAlignment(a)
  34840. },
  34841. setTextVerticalAlignment: function(a) {
  34842. this._textFieldRenderer.setVerticalAlignment(a)
  34843. },
  34844. _setFont: function(a) {
  34845. this._textFieldRender._setFont(a);
  34846. this._textFieldRendererAdaptDirty = !0
  34847. },
  34848. _getFont: function() {
  34849. return this._textFieldRender._getFont()
  34850. }
  34851. });
  34852. ccui.TextField.create = function(a, c, d) {
  34853. var e = new ccui.TextField;
  34854. return e && e.init() ? (a && (c && d) && (e.setPlaceHolder(a), e.setFontName(c), e.setFontSize(d)), e) : null
  34855. };
  34856. _p = ccui.TextField.prototype;
  34857. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  34858. cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
  34859. cc.defineGetterSetter(_p, "font", _p._getFont, _p._setFont);
  34860. cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
  34861. cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
  34862. cc.defineGetterSetter(_p, "maxLengthEnabled", _p.isMaxLengthEnabled, _p.setMaxLengthEnabled);
  34863. cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength);
  34864. cc.defineGetterSetter(_p, "passwordEnabled", _p.isPasswordEnabled, _p.setPasswordEnabled);
  34865. _p = null;
  34866. ccui.TextField.create = function() {
  34867. return new ccui.TextField
  34868. };
  34869. ccui.TextField.EVENT_ATTACH_WITH_IME = 0;
  34870. ccui.TextField.EVENT_DETACH_WITH_IME = 1;
  34871. ccui.TextField.EVENT_INSERT_TEXT = 2;
  34872. ccui.TextField.EVENT_DELETE_BACKWARD = 3;
  34873. ccui.TextField.RENDERER_ZORDER = -1;
  34874. ccui.RichElement = ccui.Class.extend({
  34875. _type: 0,
  34876. _tag: 0,
  34877. _color: null,
  34878. _opacity: 0,
  34879. ctor: function() {
  34880. this._tag = this._type = 0;
  34881. this._color = cc.color(255, 255, 255, 255)
  34882. },
  34883. init: function(a, c, d) {
  34884. this._tag = a;
  34885. this._color.r = c.r;
  34886. this._color.g = c.g;
  34887. this._color.b = c.b;
  34888. this._opacity = d;
  34889. this._color.a = void 0 === d ? c.a : d
  34890. }
  34891. });
  34892. ccui.RichElementText = ccui.RichElement.extend({
  34893. _text: "",
  34894. _fontName: "",
  34895. _fontSize: 0,
  34896. ctor: function(a, c, d, e, f, g) {
  34897. ccui.RichElement.prototype.ctor.call(this);
  34898. this._type = ccui.RichElement.TEXT;
  34899. this._fontName = this._text = "";
  34900. this._fontSize = 0;
  34901. g && this.init(a, c, d, e, f, g)
  34902. },
  34903. init: function(a, c, d, e, f, g) {
  34904. ccui.RichElement.prototype.init.call(this, a, c, d);
  34905. this._text = e;
  34906. this._fontName = f;
  34907. this._fontSize = g
  34908. }
  34909. });
  34910. ccui.RichElementText.create = function(a, c, d, e, f, g) {
  34911. return new ccui.RichElementText(a, c, d, e, f, g)
  34912. };
  34913. ccui.RichElementImage = ccui.RichElement.extend({
  34914. _filePath: "",
  34915. _textureRect: null,
  34916. _textureType: 0,
  34917. ctor: function(a, c, d, e) {
  34918. ccui.RichElement.prototype.ctor.call(this);
  34919. this._type = ccui.RichElement.IMAGE;
  34920. this._filePath = "";
  34921. this._textureRect = cc.rect(0, 0, 0, 0);
  34922. this._textureType = 0;
  34923. e && this.init(a, c, d, e)
  34924. },
  34925. init: function(a, c, d, e) {
  34926. ccui.RichElement.prototype.init.call(this, a, c, d);
  34927. this._filePath = e
  34928. }
  34929. });
  34930. ccui.RichElementImage.create = function(a, c, d, e) {
  34931. return new ccui.RichElementImage(a, c, d, e)
  34932. };
  34933. ccui.RichElementCustomNode = ccui.RichElement.extend({
  34934. _customNode: null,
  34935. ctor: function(a, c, d, e) {
  34936. ccui.RichElement.prototype.ctor.call(this);
  34937. this._type = ccui.RichElement.CUSTOM;
  34938. this._customNode = null;
  34939. e && this.init(a, c, d, e)
  34940. },
  34941. init: function(a, c, d, e) {
  34942. ccui.RichElement.prototype.init.call(this, a, c, d);
  34943. this._customNode = e
  34944. }
  34945. });
  34946. ccui.RichElementCustomNode.create = function(a, c, d, e) {
  34947. return new ccui.RichElementCustomNode(a, c, d, e)
  34948. };
  34949. ccui.RichText = ccui.Widget.extend({
  34950. _formatTextDirty: !1,
  34951. _richElements: null,
  34952. _elementRenders: null,
  34953. _leftSpaceWidth: 0,
  34954. _verticalSpace: 0,
  34955. _elementRenderersContainer: null,
  34956. ctor: function() {
  34957. ccui.Widget.prototype.ctor.call(this);
  34958. this._formatTextDirty = !1;
  34959. this._richElements = [];
  34960. this._elementRenders = [];
  34961. this._verticalSpace = this._leftSpaceWidth = 0
  34962. },
  34963. _initRenderer: function() {
  34964. this._elementRenderersContainer = cc.Node.create();
  34965. this._elementRenderersContainer.setAnchorPoint(0.5, 0.5);
  34966. this.addProtectedChild(this._elementRenderersContainer, 0, -1)
  34967. },
  34968. insertElement: function(a, c) {
  34969. this._richElements.splice(c, 0, a);
  34970. this._formatTextDirty = !0
  34971. },
  34972. pushBackElement: function(a) {
  34973. this._richElements.push(a);
  34974. this._formatTextDirty = !0
  34975. },
  34976. removeElement: function(a) {
  34977. "number" === typeof a ? this._richElements.splice(a, 1) : cc.arrayRemoveObject(this._richElements, a);
  34978. this._formatTextDirty = !0
  34979. },
  34980. formatText: function() {
  34981. if (this._formatTextDirty) {
  34982. this._elementRenderersContainer.removeAllChildren();
  34983. this._elementRenders.length = 0;
  34984. var a, c, d = this._richElements;
  34985. if (this._ignoreSize) {
  34986. this._addNewLine();
  34987. for (a = 0; a < d.length; a++) {
  34988. c = d[a];
  34989. var e = null;
  34990. switch (c._type) {
  34991. case ccui.RichElement.TEXT:
  34992. e = cc.LabelTTF.create(c._text, c._fontName, c._fontSize);
  34993. break;
  34994. case ccui.RichElement.IMAGE:
  34995. e = cc.Sprite.create(c._filePath);
  34996. break;
  34997. case ccui.RichElement.CUSTOM:
  34998. e = c._customNode
  34999. }
  35000. e.setColor(c._color);
  35001. e.setOpacity(c._color.a);
  35002. this._pushToContainer(e)
  35003. }
  35004. } else {
  35005. this._addNewLine();
  35006. for (a = 0; a < d.length; a++) switch (c = d[a], c._type) {
  35007. case ccui.RichElement.TEXT:
  35008. this._handleTextRenderer(c._text, c._fontName, c._fontSize, c._color);
  35009. break;
  35010. case ccui.RichElement.IMAGE:
  35011. this._handleImageRenderer(c._filePath, c._color, c._color.a);
  35012. break;
  35013. case ccui.RichElement.CUSTOM:
  35014. this._handleCustomRenderer(c._customNode)
  35015. }
  35016. }
  35017. this.formatRenderers();
  35018. this._formatTextDirty = !1
  35019. }
  35020. },
  35021. _handleTextRenderer: function(a, c, d, e) {
  35022. var f = cc.LabelTTF.create(a, c, d),
  35023. g = f.getContentSize().width;
  35024. this._leftSpaceWidth -= g;
  35025. 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))
  35026. },
  35027. _handleImageRenderer: function(a, c, d) {
  35028. a = cc.Sprite.create(a);
  35029. this._handleCustomRenderer(a)
  35030. },
  35031. _formarRenderers: function() {},
  35032. _handleCustomRenderer: function(a) {
  35033. var c = a.getContentSize();
  35034. this._leftSpaceWidth -= c.width;
  35035. 0 > this._leftSpaceWidth ? (this._addNewLine(), this._pushToContainer(a), this._leftSpaceWidth -= c.width) : this._pushToContainer(a)
  35036. },
  35037. _addNewLine: function() {
  35038. this._leftSpaceWidth = this._customSize.width;
  35039. this._elementRenders.push([])
  35040. },
  35041. formatRenderers: function() {
  35042. var a = 0,
  35043. c = this._elementRenderersContainer,
  35044. d = this._elementRenders,
  35045. e, f, g, h, k;
  35046. if (this._ignoreSize) {
  35047. e = 0;
  35048. g = d[0];
  35049. 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;
  35050. c.setContentSize(cc.size(e, a))
  35051. } else {
  35052. var m = [];
  35053. for (e = 0; e < d.length; e++) {
  35054. g = d[e];
  35055. for (f = h = 0; f < g.length; f++) k = g[f], h = Math.max(k.getContentSize().height, h);
  35056. m[e] = h;
  35057. a += m[e]
  35058. }
  35059. a = this._customSize.height;
  35060. for (e = 0; e < d.length; e++) {
  35061. g = d[e];
  35062. h = 0;
  35063. a -= m[e] + this._verticalSpace;
  35064. 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
  35065. }
  35066. c.setContentSize(this._contentSize)
  35067. }
  35068. f = d.length;
  35069. for (e = 0; e < f; e++) d[e].length = 0;
  35070. this._elementRenders.length = 0;
  35071. this.setContentSize(this._ignoreSize ? this.getVirtualRendererSize() : this._customSize);
  35072. this._updateContentSizeWithTextureSize(this._contentSize);
  35073. c.setPosition(0.5 * this._contentSize.width, 0.5 * this._contentSize.height)
  35074. },
  35075. _pushToContainer: function(a) {
  35076. 0 >= this._elementRenders.length || this._elementRenders[this._elementRenders.length - 1].push(a)
  35077. },
  35078. visit: function(a, c, d) {
  35079. this._enabled && (this.formatText(), ccui.Widget.prototype.visit.call(this, a, c, d))
  35080. },
  35081. setVerticalSpace: function(a) {
  35082. this._verticalSpace = a
  35083. },
  35084. setAnchorPoint: function(a) {
  35085. ccui.Widget.prototype.setAnchorPoint.call(this, a);
  35086. this._elementRenderersContainer.setAnchorPoint(a)
  35087. },
  35088. getVirtualRendererSize: function() {
  35089. return this._elementRenderersContainer.getContentSize()
  35090. },
  35091. ignoreContentAdaptWithSize: function(a) {
  35092. this._ignoreSize != a && (this._formatTextDirty = !0, ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this, a))
  35093. },
  35094. getDescription: function() {
  35095. return "RichText"
  35096. }
  35097. });
  35098. ccui.RichText.create = function() {
  35099. return new ccui.RichText
  35100. };
  35101. ccui.RichElement.TEXT = 0;
  35102. ccui.RichElement.IMAGE = 1;
  35103. ccui.RichElement.CUSTOM = 2;
  35104. ccui.ScrollView = ccui.Layout.extend({
  35105. _innerContainer: null,
  35106. direction: null,
  35107. _autoScrollDir: null,
  35108. _topBoundary: 0,
  35109. _bottomBoundary: 0,
  35110. _leftBoundary: 0,
  35111. _rightBoundary: 0,
  35112. _bounceTopBoundary: 0,
  35113. _bounceBottomBoundary: 0,
  35114. _bounceLeftBoundary: 0,
  35115. _bounceRightBoundary: 0,
  35116. _autoScroll: !1,
  35117. _autoScrollAddUpTime: 0,
  35118. _autoScrollOriginalSpeed: 0,
  35119. _autoScrollAcceleration: 0,
  35120. _isAutoScrollSpeedAttenuated: !1,
  35121. _needCheckAutoScrollDestination: !1,
  35122. _autoScrollDestination: null,
  35123. _bePressed: !1,
  35124. _slidTime: 0,
  35125. _moveChildPoint: null,
  35126. _childFocusCancelOffset: 0,
  35127. _leftBounceNeeded: !1,
  35128. _topBounceNeeded: !1,
  35129. _rightBounceNeeded: !1,
  35130. _bottomBounceNeeded: !1,
  35131. bounceEnabled: !1,
  35132. _bouncing: !1,
  35133. _bounceDir: null,
  35134. _bounceOriginalSpeed: 0,
  35135. inertiaScrollEnabled: !1,
  35136. _scrollViewEventListener: null,
  35137. _scrollViewEventSelector: null,
  35138. _className: "ScrollView",
  35139. _eventCallback: null,
  35140. ctor: function() {
  35141. ccui.Layout.prototype.ctor.call(this);
  35142. this.direction = ccui.ScrollView.DIR_NONE;
  35143. this._autoScrollDir = cc.p(0, 0);
  35144. this._autoScrollAcceleration = -1E3;
  35145. this._autoScrollDestination = cc.p(0, 0);
  35146. this._slidTime = 0;
  35147. this._moveChildPoint = cc.p(0, 0);
  35148. this._childFocusCancelOffset = 5;
  35149. this._bounceDir = cc.p(0, 0);
  35150. this._bounceOriginalSpeed = 0;
  35151. this.inertiaScrollEnabled = !0;
  35152. this.setTouchEnabled(!0)
  35153. },
  35154. init: function() {
  35155. return ccui.Layout.prototype.init.call(this) ? (this.setClippingEnabled(!0), this._innerContainer.setTouchEnabled(!1), !0) : !1
  35156. },
  35157. onEnter: function() {
  35158. ccui.Layout.prototype.onEnter.call(this);
  35159. this.scheduleUpdate(!0)
  35160. },
  35161. findNextFocusedWidget: function(a, c) {
  35162. 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)
  35163. },
  35164. _initRenderer: function() {
  35165. ccui.Layout.prototype._initRenderer.call(this);
  35166. this._innerContainer = ccui.Layout.create();
  35167. this.addProtectedChild(this._innerContainer, 1, 1)
  35168. },
  35169. _onSizeChanged: function() {
  35170. ccui.Layout.prototype._onSizeChanged.call(this);
  35171. var a = this._contentSize;
  35172. this._topBoundary = a.height;
  35173. this._rightBoundary = a.width;
  35174. var c = a.width / 3,
  35175. d = a.height / 3;
  35176. this._bounceTopBoundary = a.height - d;
  35177. this._bounceBottomBoundary = d;
  35178. this._bounceLeftBoundary = c;
  35179. this._bounceRightBoundary = a.width - c;
  35180. c = this._innerContainer.getContentSize();
  35181. this._innerContainer.setContentSize(cc.size(Math.max(c.width, a.width), Math.max(c.height, a.height)));
  35182. this._innerContainer.setPosition(0, a.height - this._innerContainer.getContentSize().height)
  35183. },
  35184. setInnerContainerSize: function(a) {
  35185. var c = this._innerContainer,
  35186. d = this._contentSize,
  35187. e = d.width,
  35188. f = d.height,
  35189. g = c.getContentSize();
  35190. a.width < d.width ? cc.log("Inner width \x3c\x3d ScrollView width, it will be force sized!") : e = a.width;
  35191. a.height < d.height ? cc.log("Inner height \x3c\x3d ScrollView height, it will be force sized!") : f = a.height;
  35192. c.setContentSize(cc.size(e, f));
  35193. switch (this.direction) {
  35194. case ccui.ScrollView.DIR_VERTICAL:
  35195. e = c.getContentSize();
  35196. g = g.height - e.height;
  35197. this._scrollChildren(0, g);
  35198. break;
  35199. case ccui.ScrollView.DIR_HORIZONTAL:
  35200. c.getRightBoundary() <= d.width && (e = c.getContentSize(), g = g.width - e.width, this._scrollChildren(g, 0));
  35201. break;
  35202. case ccui.ScrollView.DIR_BOTH:
  35203. e = c.getContentSize(), a = g.height - e.height, g = c.getRightBoundary() <= d.width ? g.width - e.width : 0, this._scrollChildren(g, a)
  35204. }
  35205. g = c.getContentSize();
  35206. a = c.getPosition();
  35207. e = c.getAnchorPoint();
  35208. 0 < c.getLeftBoundary() && c.setPosition(e.x * g.width, a.y);
  35209. c.getRightBoundary() < d.width && c.setPosition(d.width - (1 - e.x) * g.width, a.y);
  35210. 0 < a.y && c.setPosition(a.x, e.y * g.height);
  35211. c.getTopBoundary() < d.height && c.setPosition(a.x, d.height - (1 - e.y) * g.height)
  35212. },
  35213. _setInnerWidth: function(a) {
  35214. var c = this._contentSize.width,
  35215. d = c,
  35216. e = this._innerContainer,
  35217. f = e.width;
  35218. a < c ? cc.log("Inner width \x3c\x3d scrollview width, it will be force sized!") : d = a;
  35219. e.width = d;
  35220. switch (this.direction) {
  35221. case ccui.ScrollView.DIR_HORIZONTAL:
  35222. case ccui.ScrollView.DIR_BOTH:
  35223. e.getRightBoundary() <= c && this._scrollChildren(f - e.width, 0)
  35224. }
  35225. a = e.anchorX;
  35226. 0 < e.getLeftBoundary() && (e.x = a * d);
  35227. e.getRightBoundary() < c && (e.x = c - (1 - a) * d)
  35228. },
  35229. _setInnerHeight: function(a) {
  35230. var c = this._contentSize.height,
  35231. d = c,
  35232. e = this._innerContainer,
  35233. f = e.height;
  35234. a < c ? cc.log("Inner height \x3c\x3d scrollview height, it will be force sized!") : d = a;
  35235. e.height = d;
  35236. switch (this.direction) {
  35237. case ccui.ScrollView.DIR_VERTICAL:
  35238. case ccui.ScrollView.DIR_BOTH:
  35239. this._scrollChildren(0, f - d)
  35240. }
  35241. a = e.anchorY;
  35242. 0 < e.getLeftBoundary() && (e.y = a * d);
  35243. e.getRightBoundary() < c && (e.y = c - (1 - a) * d)
  35244. },
  35245. getInnerContainerSize: function() {
  35246. return this._innerContainer.getContentSize()
  35247. },
  35248. _getInnerWidth: function() {
  35249. return this._innerContainer.width
  35250. },
  35251. _getInnerHeight: function() {
  35252. return this._innerContainer.height
  35253. },
  35254. addChild: function(a, c, d) {
  35255. if (!a) return !1;
  35256. c = c || a.getLocalZOrder();
  35257. d = d || a.getTag();
  35258. return this._innerContainer.addChild(a, c, d)
  35259. },
  35260. removeAllChildren: function() {
  35261. this.removeAllChildrenWithCleanup(!0)
  35262. },
  35263. removeAllChildrenWithCleanup: function(a) {
  35264. this._innerContainer.removeAllChildrenWithCleanup(a)
  35265. },
  35266. removeChild: function(a, c) {
  35267. return this._innerContainer.removeChild(a, c)
  35268. },
  35269. getChildren: function() {
  35270. return this._innerContainer.getChildren()
  35271. },
  35272. getChildrenCount: function() {
  35273. return this._innerContainer.getChildrenCount()
  35274. },
  35275. getChildByTag: function(a) {
  35276. return this._innerContainer.getChildByTag(a)
  35277. },
  35278. getChildByName: function(a) {
  35279. return this._innerContainer.getChildByName(a)
  35280. },
  35281. _moveChildren: function(a, c) {
  35282. var d = this._innerContainer;
  35283. this._moveChildPoint.x = d.x + a;
  35284. this._moveChildPoint.y = d.y + c;
  35285. this._innerContainer.setPosition(this._moveChildPoint)
  35286. },
  35287. _autoScrollChildren: function(a) {
  35288. var c = this._autoScrollAddUpTime;
  35289. this._autoScrollAddUpTime += a;
  35290. 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()));
  35291. else if (this._needCheckAutoScrollDestination) {
  35292. var c = this._autoScrollDir.x * a * this._autoScrollOriginalSpeed,
  35293. d = this._autoScrollDir.y * a * this._autoScrollOriginalSpeed;
  35294. a = this._checkCustomScrollDestination(c, d);
  35295. c = this._scrollChildren(c, d);
  35296. if (!a || !c) this._stopAutoScrollChildren(), this._checkNeedBounce()
  35297. } else this._scrollChildren(this._autoScrollDir.x * a * this._autoScrollOriginalSpeed, this._autoScrollDir.y * a * this._autoScrollOriginalSpeed) || (this._stopAutoScrollChildren(), this._checkNeedBounce())
  35298. },
  35299. _bounceChildren: function(a) {
  35300. var c = this._bounceOriginalSpeed,
  35301. d = this._bounceDir;
  35302. 0 >= c && this._stopBounceChildren();
  35303. this._bounceScrollChildren(d.x * a * c, d.y * a * c) || this._stopBounceChildren()
  35304. },
  35305. _checkNeedBounce: function() {
  35306. if (!this.bounceEnabled) return !1;
  35307. this._checkBounceBoundary();
  35308. var a = this._topBounceNeeded,
  35309. c = this._bottomBounceNeeded,
  35310. d = this._leftBounceNeeded,
  35311. e = this._rightBounceNeeded;
  35312. if (a || c || d || e) {
  35313. var f = this._contentSize,
  35314. g = this._innerContainer;
  35315. 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));
  35316. return !0
  35317. }
  35318. return !1
  35319. },
  35320. _checkBounceBoundary: function() {
  35321. var a = this._innerContainer;
  35322. a.getBottomBoundary() > this._bottomBoundary ? (this._scrollToBottomEvent(), this._bottomBounceNeeded = !0) : this._bottomBounceNeeded = !1;
  35323. a.getTopBoundary() < this._topBoundary ? (this._scrollToTopEvent(), this._topBounceNeeded = !0) : this._topBounceNeeded = !1;
  35324. a.getRightBoundary() < this._rightBoundary ? (this._scrollToRightEvent(), this._rightBounceNeeded = !0) : this._rightBounceNeeded = !1;
  35325. a.getLeftBoundary() > this._leftBoundary ? (this._scrollToLeftEvent(), this._leftBounceNeeded = !0) : this._leftBounceNeeded = !1
  35326. },
  35327. _startBounceChildren: function(a) {
  35328. this._bounceOriginalSpeed = a;
  35329. this._bouncing = !0
  35330. },
  35331. _stopBounceChildren: function() {
  35332. this._bouncing = !1;
  35333. this._bounceOriginalSpeed = 0;
  35334. this._bottomBounceNeeded = this._topBounceNeeded = this._rightBounceNeeded = this._leftBounceNeeded = !1
  35335. },
  35336. _startAutoScrollChildrenWithOriginalSpeed: function(a, c, d, e) {
  35337. this._stopAutoScrollChildren();
  35338. this._autoScrollDir = a;
  35339. this._isAutoScrollSpeedAttenuated = d;
  35340. this._autoScrollOriginalSpeed = c;
  35341. this._autoScroll = !0;
  35342. this._autoScrollAcceleration = e
  35343. },
  35344. _startAutoScrollChildrenWithDestination: function(a, c, d) {
  35345. this._needCheckAutoScrollDestination = !1;
  35346. this._autoScrollDestination = a;
  35347. var e = cc.pSub(a, this._innerContainer.getPosition());
  35348. a = cc.pNormalize(e);
  35349. var f = 0,
  35350. g = -1E3,
  35351. e = cc.pLength(e);
  35352. d ? (g = -(2 * e) / (c * c), f = 2 * e / c) : (this._needCheckAutoScrollDestination = !0, f = e / c);
  35353. this._startAutoScrollChildrenWithOriginalSpeed(a, f, d, g)
  35354. },
  35355. _jumpToDestination: function(a, c) {
  35356. void 0 !== a.x && (c = a.y, a = a.x);
  35357. var d = a,
  35358. e = c;
  35359. switch (this.direction) {
  35360. case ccui.ScrollView.DIR_VERTICAL:
  35361. 0 >= c && (e = Math.max(c, this._contentSize.height - this._innerContainer.getContentSize().height));
  35362. break;
  35363. case ccui.ScrollView.DIR_HORIZONTAL:
  35364. 0 >= a && (d = Math.max(a, this._contentSize.width - this._innerContainer.getContentSize().width));
  35365. break;
  35366. case ccui.ScrollView.DIR_BOTH:
  35367. 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))
  35368. }
  35369. this._innerContainer.setPosition(d, e)
  35370. },
  35371. _stopAutoScrollChildren: function() {
  35372. this._autoScroll = !1;
  35373. this._autoScrollAddUpTime = this._autoScrollOriginalSpeed = 0
  35374. },
  35375. _bounceScrollChildren: function(a, c) {
  35376. var d = !0,
  35377. e, f, g, h;
  35378. h = this._innerContainer;
  35379. 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));
  35380. return d
  35381. },
  35382. _checkCustomScrollDestination: function(a, c) {
  35383. var d = !0,
  35384. e, f;
  35385. e = this._innerContainer;
  35386. var g = this._autoScrollDestination;
  35387. switch (this.direction) {
  35388. case ccui.ScrollView.DIR_VERTICAL:
  35389. 0 < this._autoScrollDir.y ? (e = e.getBottomBoundary(), e + c >= g.y && (d = !1)) : (e = e.getBottomBoundary(), e + c <= g.y && (d = !1));
  35390. break;
  35391. case ccui.ScrollView.DIR_HORIZONTAL:
  35392. 0 < this._autoScrollDir.x ? (f = e.getLeftBoundary(), f + a >= g.x && (d = !1)) : (f = e.getLeftBoundary(), f + a <= g.x && (d = !1));
  35393. break;
  35394. case ccui.ScrollView.DIR_BOTH:
  35395. 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))
  35396. }
  35397. return d
  35398. },
  35399. getCurAutoScrollDistance: function(a) {
  35400. this._autoScrollOriginalSpeed -= this._autoScrollAcceleration * a;
  35401. return this._autoScrollOriginalSpeed * a
  35402. },
  35403. _scrollChildren: function(a, c) {
  35404. var d = !0;
  35405. this._scrollingEvent();
  35406. switch (this.direction) {
  35407. case ccui.ScrollView.DIR_VERTICAL:
  35408. d = this._scrollChildrenVertical(a, c);
  35409. break;
  35410. case ccui.ScrollView.DIR_HORIZONTAL:
  35411. d = this._scrollChildrenHorizontal(a, c);
  35412. break;
  35413. case ccui.ScrollView.DIR_BOTH:
  35414. d = this._scrollChildrenBoth(a, c)
  35415. }
  35416. return d
  35417. },
  35418. _scrollChildrenVertical: function(a, c) {
  35419. var d = c,
  35420. e = !0,
  35421. f, g = this._innerContainer;
  35422. 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));
  35423. this._moveChildren(0, d);
  35424. return e
  35425. },
  35426. _scrollChildrenHorizontal: function(a, c) {
  35427. var d = !0,
  35428. e = a,
  35429. f, g = this._innerContainer;
  35430. 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));
  35431. this._moveChildren(e, 0);
  35432. return d
  35433. },
  35434. _scrollChildrenBoth: function(a, c) {
  35435. var d = !0,
  35436. e = a,
  35437. f = c,
  35438. g, h;
  35439. h = this._innerContainer;
  35440. 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));
  35441. this._moveChildren(e, f);
  35442. return d
  35443. },
  35444. scrollToBottom: function(a, c) {
  35445. this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), a, c)
  35446. },
  35447. scrollToTop: function(a, c) {
  35448. this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height), a, c)
  35449. },
  35450. scrollToLeft: function(a, c) {
  35451. this._startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), a, c)
  35452. },
  35453. scrollToRight: function(a, c) {
  35454. this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()), a, c)
  35455. },
  35456. scrollToTopLeft: function(a, c) {
  35457. 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)
  35458. },
  35459. scrollToTopRight: function(a, c) {
  35460. if (this.direction != ccui.ScrollView.DIR_BOTH) cc.log("Scroll direction is not both!");
  35461. else {
  35462. var d = this._innerContainer.getContentSize();
  35463. this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - d.width, this._contentSize.height - d.height), a, c)
  35464. }
  35465. },
  35466. scrollToBottomLeft: function(a, c) {
  35467. this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._startAutoScrollChildrenWithDestination(cc.p(0, 0), a, c)
  35468. },
  35469. scrollToBottomRight: function(a, c) {
  35470. 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)
  35471. },
  35472. scrollToPercentVertical: function(a, c, d) {
  35473. var e = this._contentSize.height - this._innerContainer.getContentSize().height,
  35474. f = -e;
  35475. this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), e + a * f / 100), c, d)
  35476. },
  35477. scrollToPercentHorizontal: function(a, c, d) {
  35478. var e = this._innerContainer.getContentSize().width - this._contentSize.width;
  35479. this._startAutoScrollChildrenWithDestination(cc.p(-(a * e / 100), this._innerContainer.getPositionY()), c, d)
  35480. },
  35481. scrollToPercentBothDirection: function(a, c, d) {
  35482. if (this.direction == ccui.ScrollView.DIR_BOTH) {
  35483. var e = this._contentSize.height - this._innerContainer.getContentSize().height,
  35484. f = -e,
  35485. g = this._innerContainer.getContentSize().width - this._contentSize.width;
  35486. this._startAutoScrollChildrenWithDestination(cc.p(-(a.x * g / 100), e + a.y * f / 100), c, d)
  35487. }
  35488. },
  35489. jumpToBottom: function() {
  35490. this._jumpToDestination(this._innerContainer.getPositionX(), 0)
  35491. },
  35492. jumpToTop: function() {
  35493. this._jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height)
  35494. },
  35495. jumpToLeft: function() {
  35496. this._jumpToDestination(0, this._innerContainer.getPositionY())
  35497. },
  35498. jumpToRight: function() {
  35499. this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY())
  35500. },
  35501. jumpToTopLeft: function() {
  35502. this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height)
  35503. },
  35504. jumpToTopRight: function() {
  35505. if (this.direction != ccui.ScrollView.DIR_BOTH) cc.log("Scroll direction is not both!");
  35506. else {
  35507. var a = this._innerContainer.getContentSize();
  35508. this._jumpToDestination(this._contentSize.width - a.width, this._contentSize.height - a.height)
  35509. }
  35510. },
  35511. jumpToBottomLeft: function() {
  35512. this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(0, 0)
  35513. },
  35514. jumpToBottomRight: function() {
  35515. this.direction != ccui.ScrollView.DIR_BOTH ? cc.log("Scroll direction is not both!") : this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0)
  35516. },
  35517. jumpToPercentVertical: function(a) {
  35518. var c = this._contentSize.height - this._innerContainer.getContentSize().height,
  35519. d = -c;
  35520. this._jumpToDestination(this._innerContainer.getPositionX(), c + a * d / 100)
  35521. },
  35522. jumpToPercentHorizontal: function(a) {
  35523. var c = this._innerContainer.getContentSize().width - this._contentSize.width;
  35524. this._jumpToDestination(-(a * c / 100), this._innerContainer.getPositionY())
  35525. },
  35526. jumpToPercentBothDirection: function(a) {
  35527. if (this.direction == ccui.ScrollView.DIR_BOTH) {
  35528. var c = this._innerContainer.getContentSize(),
  35529. d = this._contentSize.height - c.height;
  35530. this._jumpToDestination(-(a.x * (c.width - this._contentSize.width) / 100), d + a.y * -d / 100)
  35531. }
  35532. },
  35533. _startRecordSlidAction: function() {
  35534. this._autoScroll && this._stopAutoScrollChildren();
  35535. this._bouncing && this._stopBounceChildren();
  35536. this._slidTime = 0
  35537. },
  35538. _endRecordSlidAction: function() {
  35539. if (!this._checkNeedBounce() && this.inertiaScrollEnabled && !(0.016 >= this._slidTime)) {
  35540. var a = 0,
  35541. c;
  35542. switch (this.direction) {
  35543. case ccui.ScrollView.DIR_VERTICAL:
  35544. a = this._touchEndPosition.y - this._touchBeganPosition.y;
  35545. c = 0 > a ? ccui.ScrollView.SCROLLDIR_DOWN : ccui.ScrollView.SCROLLDIR_UP;
  35546. break;
  35547. case ccui.ScrollView.DIR_HORIZONTAL:
  35548. a = this._touchEndPosition.x - this._touchBeganPosition.x;
  35549. c = 0 > a ? ccui.ScrollView.SCROLLDIR_LEFT : ccui.ScrollView.SCROLLDIR_RIGHT;
  35550. break;
  35551. case ccui.ScrollView.DIR_BOTH:
  35552. c = cc.pSub(this._touchEndPosition, this._touchBeganPosition), a = cc.pLength(c), c = cc.pNormalize(c)
  35553. }
  35554. a = Math.min(Math.abs(a) / this._slidTime, ccui.ScrollView.AUTO_SCROLL_MAX_SPEED);
  35555. this._startAutoScrollChildrenWithOriginalSpeed(c, a, !0, -1E3);
  35556. this._slidTime = 0
  35557. }
  35558. },
  35559. _handlePressLogic: function(a) {
  35560. this._startRecordSlidAction();
  35561. this._bePressed = !0
  35562. },
  35563. _handleMoveLogic: function(a) {
  35564. a = cc.pSub(a.getLocation(), a.getPreviousLocation());
  35565. switch (this.direction) {
  35566. case ccui.ScrollView.DIR_VERTICAL:
  35567. this._scrollChildren(0, a.y);
  35568. break;
  35569. case ccui.ScrollView.DIR_HORIZONTAL:
  35570. this._scrollChildren(a.x, 0);
  35571. break;
  35572. case ccui.ScrollView.DIR_BOTH:
  35573. this._scrollChildren(a.x, a.y)
  35574. }
  35575. },
  35576. _handleReleaseLogic: function(a) {
  35577. this._endRecordSlidAction();
  35578. this._bePressed = !1
  35579. },
  35580. onTouchBegan: function(a, c) {
  35581. var d = ccui.Layout.prototype.onTouchBegan.call(this, a, c);
  35582. this._hit && this._handlePressLogic(a);
  35583. return d
  35584. },
  35585. onTouchMoved: function(a, c) {
  35586. ccui.Layout.prototype.onTouchMoved.call(this, a, c);
  35587. this._handleMoveLogic(a)
  35588. },
  35589. onTouchEnded: function(a, c) {
  35590. ccui.Layout.prototype.onTouchEnded.call(this, a, c);
  35591. this._handleReleaseLogic(a)
  35592. },
  35593. onTouchCancelled: function(a, c) {
  35594. ccui.Layout.prototype.onTouchCancelled.call(this, a, c)
  35595. },
  35596. update: function(a) {
  35597. this._autoScroll && this._autoScrollChildren(a);
  35598. this._bouncing && this._bounceChildren(a);
  35599. this._recordSlidTime(a)
  35600. },
  35601. _recordSlidTime: function(a) {
  35602. this._bePressed && (this._slidTime += a)
  35603. },
  35604. interceptTouchEvent: function(a, c, d) {
  35605. var e = d.getLocation();
  35606. switch (a) {
  35607. case ccui.Widget.TOUCH_BEGAN:
  35608. this._touchBeganPosition.x = e.x;
  35609. this._touchBeganPosition.y = e.y;
  35610. this._handlePressLogic(d);
  35611. break;
  35612. case ccui.Widget.TOUCH_MOVED:
  35613. 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));
  35614. break;
  35615. case ccui.Widget.TOUCH_CANCELED:
  35616. case ccui.Widget.TOUCH_ENDED:
  35617. this._touchEndPosition.x = e.x, this._touchEndPosition.y = e.y, this._handleReleaseLogic(d)
  35618. }
  35619. },
  35620. _scrollToTopEvent: function() {
  35621. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP);
  35622. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP)
  35623. },
  35624. _scrollToBottomEvent: function() {
  35625. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM);
  35626. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM)
  35627. },
  35628. _scrollToLeftEvent: function() {
  35629. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT);
  35630. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT)
  35631. },
  35632. _scrollToRightEvent: function() {
  35633. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT);
  35634. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT)
  35635. },
  35636. _scrollingEvent: function() {
  35637. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING);
  35638. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_SCROLLING)
  35639. },
  35640. _bounceTopEvent: function() {
  35641. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP);
  35642. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_TOP)
  35643. },
  35644. _bounceBottomEvent: function() {
  35645. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM);
  35646. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM)
  35647. },
  35648. _bounceLeftEvent: function() {
  35649. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT);
  35650. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT)
  35651. },
  35652. _bounceRightEvent: function() {
  35653. this._scrollViewEventListener && this._scrollViewEventSelector && this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT);
  35654. this._eventCallback && this._eventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT)
  35655. },
  35656. addEventListenerScrollView: function(a, c) {
  35657. this._scrollViewEventSelector = a;
  35658. this._scrollViewEventListener = c
  35659. },
  35660. addEventListener: function(a) {
  35661. this._eventCallback = a
  35662. },
  35663. setDirection: function(a) {
  35664. this.direction = a
  35665. },
  35666. getDirection: function() {
  35667. return this.direction
  35668. },
  35669. setBounceEnabled: function(a) {
  35670. this.bounceEnabled = a
  35671. },
  35672. isBounceEnabled: function() {
  35673. return this.bounceEnabled
  35674. },
  35675. setInertiaScrollEnabled: function(a) {
  35676. this.inertiaScrollEnabled = a
  35677. },
  35678. isInertiaScrollEnabled: function() {
  35679. return this.inertiaScrollEnabled
  35680. },
  35681. getInnerContainer: function() {
  35682. return this._innerContainer
  35683. },
  35684. setLayoutType: function(a) {
  35685. this._innerContainer.setLayoutType(a)
  35686. },
  35687. getLayoutType: function() {
  35688. return this._innerContainer.getLayoutType()
  35689. },
  35690. _doLayout: function() {
  35691. this._doLayoutDirty && (this._doLayoutDirty = !1)
  35692. },
  35693. getDescription: function() {
  35694. return "ScrollView"
  35695. },
  35696. _createCloneInstance: function() {
  35697. return ccui.ScrollView.create()
  35698. },
  35699. _copyClonedWidgetChildren: function(a) {
  35700. ccui.Layout.prototype._copyClonedWidgetChildren.call(this, a)
  35701. },
  35702. _copySpecialProperties: function(a) {
  35703. 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)
  35704. },
  35705. getNodeByTag: function(a) {
  35706. return this._innerContainer.getNodeByTag(a)
  35707. },
  35708. getNodes: function() {
  35709. return this._innerContainer.getNodes()
  35710. },
  35711. removeNode: function(a) {
  35712. this._innerContainer.removeNode(a)
  35713. },
  35714. removeNodeByTag: function(a) {
  35715. this._innerContainer.removeNodeByTag(a)
  35716. },
  35717. removeAllNodes: function() {
  35718. this._innerContainer.removeAllNodes()
  35719. },
  35720. addNode: function(a, c, d) {
  35721. this._innerContainer.addNode(a, c, d)
  35722. }
  35723. });
  35724. _p = ccui.ScrollView.prototype;
  35725. cc.defineGetterSetter(_p, "innerWidth", _p._getInnerWidth, _p._setInnerWidth);
  35726. cc.defineGetterSetter(_p, "innerHeight", _p._getInnerHeight, _p._setInnerHeight);
  35727. _p = null;
  35728. ccui.ScrollView.create = function() {
  35729. return new ccui.ScrollView
  35730. };
  35731. ccui.ScrollView.DIR_NONE = 0;
  35732. ccui.ScrollView.DIR_VERTICAL = 1;
  35733. ccui.ScrollView.DIR_HORIZONTAL = 2;
  35734. ccui.ScrollView.DIR_BOTH = 3;
  35735. ccui.ScrollView.EVENT_SCROLL_TO_TOP = 0;
  35736. ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM = 1;
  35737. ccui.ScrollView.EVENT_SCROLL_TO_LEFT = 2;
  35738. ccui.ScrollView.EVENT_SCROLL_TO_RIGHT = 3;
  35739. ccui.ScrollView.EVENT_SCROLLING = 4;
  35740. ccui.ScrollView.EVENT_BOUNCE_TOP = 5;
  35741. ccui.ScrollView.EVENT_BOUNCE_BOTTOM = 6;
  35742. ccui.ScrollView.EVENT_BOUNCE_LEFT = 7;
  35743. ccui.ScrollView.EVENT_BOUNCE_RIGHT = 8;
  35744. ccui.ScrollView.AUTO_SCROLL_MAX_SPEED = 1E3;
  35745. ccui.ScrollView.SCROLLDIR_UP = cc.p(0, 1);
  35746. ccui.ScrollView.SCROLLDIR_DOWN = cc.p(0, -1);
  35747. ccui.ScrollView.SCROLLDIR_LEFT = cc.p(-1, 0);
  35748. ccui.ScrollView.SCROLLDIR_RIGHT = cc.p(1, 0);
  35749. ccui.ListView = ccui.ScrollView.extend({
  35750. _model: null,
  35751. _items: null,
  35752. _gravity: null,
  35753. _itemsMargin: 0,
  35754. _curSelectedIndex: 0,
  35755. _refreshViewDirty: !0,
  35756. _listViewEventListener: null,
  35757. _listViewEventSelector: null,
  35758. _eventCallback: null,
  35759. ctor: function() {
  35760. ccui.ScrollView.prototype.ctor.call(this);
  35761. this._items = [];
  35762. this._gravity = ccui.ListView.GRAVITY_CENTER_HORIZONTAL;
  35763. this.setTouchEnabled(!0);
  35764. this.init()
  35765. },
  35766. init: function() {
  35767. return ccui.ScrollView.prototype.init.call(this) ? (this.setLayoutType(ccui.Layout.LINEAR_VERTICAL), !0) : !1
  35768. },
  35769. setItemModel: function(a) {
  35770. a && (this._model = a)
  35771. },
  35772. _updateInnerContainerSize: function() {
  35773. var a = this._items,
  35774. c, d;
  35775. switch (this.direction) {
  35776. case ccui.ScrollView.DIR_VERTICAL:
  35777. c = a.length;
  35778. var e = (c - 1) * this._itemsMargin;
  35779. for (d = 0; d < c; d++) e += a[d].getContentSize().height;
  35780. this.setInnerContainerSize(cc.size(this._contentSize.width, e));
  35781. break;
  35782. case ccui.ScrollView.DIR_HORIZONTAL:
  35783. c = a.length;
  35784. e = (c - 1) * this._itemsMargin;
  35785. for (d = 0; d < c; d++) e += a[d].getContentSize().width;
  35786. this.setInnerContainerSize(cc.size(e, this._contentSize.height))
  35787. }
  35788. },
  35789. _remedyLayoutParameter: function(a) {
  35790. if (a) {
  35791. var c;
  35792. switch (this.direction) {
  35793. case ccui.ScrollView.DIR_VERTICAL:
  35794. 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) {
  35795. case ccui.ListView.GRAVITY_LEFT:
  35796. c.setGravity(ccui.LinearLayoutParameter.LEFT);
  35797. break;
  35798. case ccui.ListView.GRAVITY_RIGHT:
  35799. c.setGravity(ccui.LinearLayoutParameter.RIGHT);
  35800. break;
  35801. case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:
  35802. c.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)
  35803. } else {
  35804. c = ccui.LinearLayoutParameter.create();
  35805. switch (this._gravity) {
  35806. case ccui.ListView.GRAVITY_LEFT:
  35807. c.setGravity(ccui.LinearLayoutParameter.LEFT);
  35808. break;
  35809. case ccui.ListView.GRAVITY_RIGHT:
  35810. c.setGravity(ccui.LinearLayoutParameter.RIGHT);
  35811. break;
  35812. case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:
  35813. c.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)
  35814. }
  35815. 0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(0, this._itemsMargin, 0, 0));
  35816. a.setLayoutParameter(c)
  35817. }
  35818. break;
  35819. case ccui.ScrollView.DIR_HORIZONTAL:
  35820. 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) {
  35821. case ccui.ListView.GRAVITY_TOP:
  35822. c.setGravity(ccui.LinearLayoutParameter.TOP);
  35823. break;
  35824. case ccui.ListView.GRAVITY_BOTTOM:
  35825. c.setGravity(ccui.LinearLayoutParameter.BOTTOM);
  35826. break;
  35827. case ccui.ListView.GRAVITY_CENTER_VERTICAL:
  35828. c.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)
  35829. } else {
  35830. c = ccui.LinearLayoutParameter.create();
  35831. switch (this._gravity) {
  35832. case ccui.ListView.GRAVITY_TOP:
  35833. c.setGravity(ccui.LinearLayoutParameter.TOP);
  35834. break;
  35835. case ccui.ListView.GRAVITY_BOTTOM:
  35836. c.setGravity(ccui.LinearLayoutParameter.BOTTOM);
  35837. break;
  35838. case ccui.ListView.GRAVITY_CENTER_VERTICAL:
  35839. c.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)
  35840. }
  35841. 0 == this.getIndex(a) ? c.setMargin(ccui.MarginZero()) : c.setMargin(new ccui.Margin(this._itemsMargin, 0, 0, 0));
  35842. a.setLayoutParameter(c)
  35843. }
  35844. }
  35845. }
  35846. },
  35847. pushBackDefaultItem: function() {
  35848. if (this._model) {
  35849. var a = this._model.clone();
  35850. this._remedyLayoutParameter(a);
  35851. this.addChild(a);
  35852. this._refreshViewDirty = !0
  35853. }
  35854. },
  35855. insertDefaultItem: function(a) {
  35856. if (this._model) {
  35857. var c = this._model.clone();
  35858. this._items.splice(a, 0, c);
  35859. ccui.ScrollView.prototype.addChild.call(this, c);
  35860. this._remedyLayoutParameter(c);
  35861. this._refreshViewDirty = !0
  35862. }
  35863. },
  35864. pushBackCustomItem: function(a) {
  35865. this._remedyLayoutParameter(a);
  35866. this.addChild(a);
  35867. this._refreshViewDirty = !0
  35868. },
  35869. addChild: function(a, c, d) {
  35870. 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))
  35871. },
  35872. removeChild: function(a, c) {
  35873. if (a) {
  35874. var d = this._items.indexOf(a); - 1 < d && this._items.splice(d, 1);
  35875. ccui.ScrollView.prototype.removeChild.call(this, a, c)
  35876. }
  35877. },
  35878. removeAllChildren: function() {
  35879. this.removeAllChildrenWithCleanup(!0)
  35880. },
  35881. removeAllChildrenWithCleanup: function(a) {
  35882. ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this, a);
  35883. this._items = []
  35884. },
  35885. insertCustomItem: function(a, c) {
  35886. this._items.splice(c, 0, a);
  35887. ccui.ScrollView.prototype.addChild.call(this, a);
  35888. this._remedyLayoutParameter(a);
  35889. this._refreshViewDirty = !0
  35890. },
  35891. removeItem: function(a) {
  35892. if (a = this.getItem(a)) this.removeChild(a, !0), this._refreshViewDirty = !0
  35893. },
  35894. removeLastItem: function() {
  35895. this.removeItem(this._items.length - 1)
  35896. },
  35897. removeAllItems: function() {
  35898. this.removeAllChildren()
  35899. },
  35900. getItem: function(a) {
  35901. return 0 > a || a >= this._items.length ? null : this._items[a]
  35902. },
  35903. getItems: function() {
  35904. return this._items
  35905. },
  35906. getIndex: function(a) {
  35907. return this._items.indexOf(a)
  35908. },
  35909. setGravity: function(a) {
  35910. this._gravity != a && (this._gravity = a, this._refreshViewDirty = !0)
  35911. },
  35912. setItemsMargin: function(a) {
  35913. this._itemsMargin != a && (this._itemsMargin = a, this._refreshViewDirty = !0)
  35914. },
  35915. getItemsMargin: function() {
  35916. return this._itemsMargin
  35917. },
  35918. setDirection: function(a) {
  35919. switch (a) {
  35920. case ccui.ScrollView.DIR_VERTICAL:
  35921. this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);
  35922. break;
  35923. case ccui.ScrollView.DIR_HORIZONTAL:
  35924. this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);
  35925. break;
  35926. case ccui.ScrollView.DIR_BOTH:
  35927. return;
  35928. default:
  35929. return
  35930. }
  35931. ccui.ScrollView.prototype.setDirection.call(this, a)
  35932. },
  35933. requestRefreshView: function() {
  35934. this._refreshViewDirty = !0
  35935. },
  35936. refreshView: function() {
  35937. for (var a = this._items, c = 0; c < a.length; c++) {
  35938. var d = a[c];
  35939. d.setLocalZOrder(c);
  35940. this._remedyLayoutParameter(d)
  35941. }
  35942. this._updateInnerContainerSize()
  35943. },
  35944. doLayout: function() {
  35945. this._doLayout()
  35946. },
  35947. _doLayout: function() {
  35948. ccui.Layout.prototype._doLayout.call(this);
  35949. this._refreshViewDirty && (this.refreshView(), this._refreshViewDirty = !1)
  35950. },
  35951. addEventListenerListView: function(a, c) {
  35952. this._listViewEventListener = c;
  35953. this._listViewEventSelector = a
  35954. },
  35955. addEventListener: function(a) {
  35956. this._eventCallback = a
  35957. },
  35958. _selectedItemEvent: function(a) {
  35959. a = a == ccui.Widget.TOUCH_BEGAN ? ccui.ListView.ON_SELECTED_ITEM_START : ccui.ListView.ON_SELECTED_ITEM_END;
  35960. this._listViewEventListener && this._listViewEventSelector && this._listViewEventSelector.call(this._listViewEventListener, this, a);
  35961. this._eventCallback && this._eventCallback(this, a)
  35962. },
  35963. interceptTouchEvent: function(a, c, d) {
  35964. ccui.ScrollView.prototype.interceptTouchEvent.call(this, a, c, d);
  35965. if (a != ccui.Widget.TOUCH_MOVED) {
  35966. for (d = c; d;) {
  35967. if (d && d.getParent() == this._innerContainer) {
  35968. this._curSelectedIndex = this.getIndex(d);
  35969. break
  35970. }
  35971. d = d.getParent()
  35972. }
  35973. c.isHighlighted() && this._selectedItemEvent(a)
  35974. }
  35975. },
  35976. getCurSelectedIndex: function() {
  35977. return this._curSelectedIndex
  35978. },
  35979. _onSizeChanged: function() {
  35980. ccui.ScrollView.prototype._onSizeChanged.call(this);
  35981. this._refreshViewDirty = !0
  35982. },
  35983. getDescription: function() {
  35984. return "ListView"
  35985. },
  35986. _createCloneInstance: function() {
  35987. return ccui.ListView.create()
  35988. },
  35989. _copyClonedWidgetChildren: function(a) {
  35990. a = a.getItems();
  35991. for (var c = 0; c < a.length; c++) this.pushBackCustomItem(a[c].clone())
  35992. },
  35993. _copySpecialProperties: function(a) {
  35994. 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)
  35995. }
  35996. });
  35997. ccui.ListView.create = function() {
  35998. return new ccui.ListView
  35999. };
  36000. ccui.ListView.EVENT_SELECTED_ITEM = 0;
  36001. ccui.ListView.ON_SELECTED_ITEM_START = 0;
  36002. ccui.ListView.ON_SELECTED_ITEM_END = 1;
  36003. ccui.ListView.GRAVITY_LEFT = 0;
  36004. ccui.ListView.GRAVITY_RIGHT = 1;
  36005. ccui.ListView.GRAVITY_CENTER_HORIZONTAL = 2;
  36006. ccui.ListView.GRAVITY_TOP = 3;
  36007. ccui.ListView.GRAVITY_BOTTOM = 4;
  36008. ccui.ListView.GRAVITY_CENTER_VERTICAL = 5;
  36009. ccui.PageView = ccui.Layout.extend({
  36010. _curPageIdx: 0,
  36011. _pages: null,
  36012. _touchMoveDirection: null,
  36013. _touchStartLocation: 0,
  36014. _touchMoveStartLocation: 0,
  36015. _movePagePoint: null,
  36016. _leftBoundaryChild: null,
  36017. _rightBoundaryChild: null,
  36018. _leftBoundary: 0,
  36019. _rightBoundary: 0,
  36020. _isAutoScrolling: !1,
  36021. _autoScrollDistance: 0,
  36022. _autoScrollSpeed: 0,
  36023. _autoScrollDirection: 0,
  36024. _childFocusCancelOffset: 0,
  36025. _pageViewEventListener: null,
  36026. _pageViewEventSelector: null,
  36027. _className: "PageView",
  36028. _eventCallback: null,
  36029. ctor: function() {
  36030. ccui.Layout.prototype.ctor.call(this);
  36031. this._pages = [];
  36032. this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT;
  36033. this._rightBoundaryChild = this._leftBoundaryChild = this._movePagePoint = null;
  36034. this._childFocusCancelOffset = 5;
  36035. this._pageViewEventSelector = this._pageViewEventListener = null;
  36036. this.setTouchEnabled(!0)
  36037. },
  36038. init: function() {
  36039. return ccui.Layout.prototype.init.call(this) ? (this.setClippingEnabled(!0), !0) : !1
  36040. },
  36041. onEnter: function() {
  36042. ccui.Layout.prototype.onEnter.call(this);
  36043. this.scheduleUpdate(!0)
  36044. },
  36045. addWidgetToPage: function(a, c, d) {
  36046. if (a && !(0 > c)) {
  36047. var e = this._getPageCount();
  36048. 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)
  36049. }
  36050. },
  36051. _createPage: function() {
  36052. var a = ccui.Layout.create();
  36053. a.setContentSize(this.getContentSize());
  36054. return a
  36055. },
  36056. addPage: function(a) {
  36057. a && -1 == this._pages.indexOf(a) && (this.addChild(a), this._pages.push(a), this._doLayoutDirty = !0)
  36058. },
  36059. insertPage: function(a, c) {
  36060. if (!(0 > c || !a || -1 != this._pages.indexOf(a))) {
  36061. var d = this._getPageCount();
  36062. c >= d ? this.addPage(a) : (this._pages[c] = a, this.addChild(a));
  36063. this._doLayoutDirty = !0
  36064. }
  36065. },
  36066. removePage: function(a) {
  36067. a && (this.removeChild(a), a = this._pages.indexOf(a), -1 < a && this._pages.splice(a, 1), this._doLayoutDirty = !0)
  36068. },
  36069. removePageAtIndex: function(a) {
  36070. 0 > a || a >= this._pages.length || (a = this._pages[a]) && this.removePage(a)
  36071. },
  36072. removeAllPages: function() {
  36073. for (var a = this._pages, c = 0, d = a.length; c < d; c++) this.removeChild(a[c]);
  36074. this._pages.length = 0
  36075. },
  36076. _updateBoundaryPages: function() {
  36077. var a = this._pages;
  36078. 0 >= a.length ? this._rightBoundaryChild = this._leftBoundaryChild = null : (this._leftBoundaryChild = a[0], this._rightBoundaryChild = a[a.length - 1])
  36079. },
  36080. _getPageCount: function() {
  36081. return this._pages.length
  36082. },
  36083. _getPositionXByIndex: function(a) {
  36084. return this.getContentSize().width * (a - this._curPageIdx)
  36085. },
  36086. _onSizeChanged: function() {
  36087. ccui.Layout.prototype._onSizeChanged.call(this);
  36088. this._rightBoundary = this.getContentSize().width;
  36089. this._doLayoutDirty = !0
  36090. },
  36091. _updateAllPagesSize: function() {
  36092. for (var a = this.getContentSize(), c = this._pages, d = 0, e = c.length; d < e; d++) c[d].setContentSize(a)
  36093. },
  36094. _updateAllPagesPosition: function() {
  36095. var a = this._getPageCount();
  36096. if (0 >= a) this._curPageIdx = 0;
  36097. else {
  36098. this._curPageIdx >= a && (this._curPageIdx = a - 1);
  36099. for (var c = this.getContentSize().width, d = this._pages, e = 0; e < a; e++) d[e].setPosition(cc.p((e - this._curPageIdx) * c, 0))
  36100. }
  36101. },
  36102. scrollToPage: function(a) {
  36103. 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)
  36104. },
  36105. update: function(a) {
  36106. this._isAutoScrolling && this._autoScroll(a)
  36107. },
  36108. setLayoutType: function(a) {},
  36109. getLayoutType: function() {
  36110. return ccui.Layout.ABSOLUTE
  36111. },
  36112. _autoScroll: function(a) {
  36113. switch (this._autoScrollDirection) {
  36114. case ccui.PageView.DIRECTION_LEFT:
  36115. a *= this._autoScrollSpeed;
  36116. 0 <= this._autoScrollDistance + a ? (a = -this._autoScrollDistance, this._autoScrollDistance = 0, this._isAutoScrolling = !1) : this._autoScrollDistance += a;
  36117. this._scrollPages(-a);
  36118. this._isAutoScrolling || this._pageTurningEvent();
  36119. break;
  36120. case ccui.PageView.DIRECTION_RIGHT:
  36121. 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()
  36122. }
  36123. },
  36124. onTouchMoved: function(a, c) {
  36125. this._handleMoveLogic(a);
  36126. var d = this.getWidgetParent();
  36127. d && d.interceptTouchEvent(ccui.Widget.TOUCH_MOVED, this, a);
  36128. this._moveEvent()
  36129. },
  36130. onTouchEnded: function(a, c) {
  36131. ccui.Layout.prototype.onTouchEnded.call(this, a, c);
  36132. this._handleReleaseLogic(a)
  36133. },
  36134. onTouchCancelled: function(a, c) {
  36135. ccui.Layout.prototype.onTouchCancelled.call(this, a, c);
  36136. this._handleReleaseLogic(a)
  36137. },
  36138. _doLayout: function() {
  36139. this._doLayoutDirty && (this._updateAllPagesPosition(), this._updateAllPagesSize(), this._updateBoundaryPages(), this._doLayoutDirty = !1)
  36140. },
  36141. _movePages: function(a) {
  36142. for (var c = this._pages, d = c.length, e = 0; e < d; e++) {
  36143. var f = c[e];
  36144. f.setPositionX(f.getPositionX() + a)
  36145. }
  36146. },
  36147. _scrollPages: function(a) {
  36148. if (0 >= this._pages.length || !this._leftBoundaryChild || !this._rightBoundaryChild) return !1;
  36149. var c = a;
  36150. switch (this._touchMoveDirection) {
  36151. case ccui.PageView.TOUCH_DIR_LEFT:
  36152. var d = this._rightBoundaryChild.getRightBoundary();
  36153. if (d + a <= this._rightBoundary) return c = this._rightBoundary - d, this._movePages(c), !1;
  36154. break;
  36155. case ccui.PageView.TOUCH_DIR_RIGHT:
  36156. if (d = this._leftBoundaryChild.getLeftBoundary(), d + a >= this._leftBoundary) return c = this._leftBoundary - d, this._movePages(c), !1
  36157. }
  36158. this._movePages(c);
  36159. return !0
  36160. },
  36161. _handleMoveLogic: function(a) {
  36162. a = a.getLocation().x - a.getPreviousLocation().x;
  36163. 0 > a ? this._touchMoveDirection = ccui.PageView.TOUCH_DIR_LEFT : 0 < a && (this._touchMoveDirection = ccui.PageView.TOUCH_DIR_RIGHT);
  36164. this._scrollPages(a)
  36165. },
  36166. _handleReleaseLogic: function(a) {
  36167. if (!(0 >= this._pages.length) && (a = this._pages[this._curPageIdx])) {
  36168. var c = a.getPosition();
  36169. a = this._pages.length;
  36170. var c = c.x,
  36171. d = this.getSize().width / 2;
  36172. 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)
  36173. }
  36174. },
  36175. interceptTouchEvent: function(a, c, d) {
  36176. var e = d.getLocation();
  36177. switch (a) {
  36178. case ccui.Widget.TOUCH_MOVED:
  36179. a = 0;
  36180. a = Math.abs(c.getTouchBeganPosition().x - e.x);
  36181. a > this._childFocusCancelOffset && (c.setFocused(!1), this._handleMoveLogic(d));
  36182. break;
  36183. case ccui.Widget.TOUCH_ENDED:
  36184. case ccui.Widget.TOUCH_CANCELED:
  36185. this._handleReleaseLogic(d)
  36186. }
  36187. },
  36188. _pageTurningEvent: function() {
  36189. this._pageViewEventListener && this._pageViewEventSelector && this._pageViewEventSelector.call(this._pageViewEventListener, this, ccui.PageView.EVENT_TURNING);
  36190. this._eventCallback && this._eventCallback(this, ccui.PageView.EVENT_TURNING)
  36191. },
  36192. addEventListenerPageView: function(a, c) {
  36193. this._pageViewEventSelector = a;
  36194. this._pageViewEventListener = c
  36195. },
  36196. addEventListener: function(a) {
  36197. this._eventCallback = a
  36198. },
  36199. getCurPageIndex: function() {
  36200. return this._curPageIdx
  36201. },
  36202. getPages: function() {
  36203. return this._pages
  36204. },
  36205. getPage: function(a) {
  36206. return 0 > a || a >= this.getPages().size() ? null : this._pages[a]
  36207. },
  36208. getDescription: function() {
  36209. return "PageView"
  36210. },
  36211. _createCloneInstance: function() {
  36212. return ccui.PageView.create()
  36213. },
  36214. _copyClonedWidgetChildren: function(a) {
  36215. a = a.getPages();
  36216. for (var c = 0; c < a.length; c++) this.addPage(a[c].clone())
  36217. },
  36218. _copySpecialProperties: function(a) {
  36219. ccui.Layout.prototype._copySpecialProperties.call(this, a);
  36220. this._eventCallback = a._eventCallback;
  36221. this._pageViewEventListener = a._pageViewEventListener;
  36222. this._pageViewEventSelector = a._pageViewEventSelector
  36223. }
  36224. });
  36225. ccui.PageView.create = function() {
  36226. return new ccui.PageView
  36227. };
  36228. ccui.PageView.EVENT_TURNING = 0;
  36229. ccui.PageView.TOUCH_DIR_LEFT = 0;
  36230. ccui.PageView.TOUCH_DIR_RIGHT = 1;
  36231. ccui.PageView.DIRECTION_LEFT = 0;
  36232. ccui.PageView.DIRECTION_RIGHT = 1;
  36233. cc.Component = cc.Class.extend({
  36234. _owner: null,
  36235. _name: "",
  36236. _enabled: !0,
  36237. ctor: function() {
  36238. this._owner = null;
  36239. this._name = "";
  36240. this._enabled = !0
  36241. },
  36242. init: function() {
  36243. return !0
  36244. },
  36245. onEnter: function() {},
  36246. onExit: function() {},
  36247. update: function(a) {},
  36248. serialize: function(a) {},
  36249. isEnabled: function() {
  36250. return this._enabled
  36251. },
  36252. setEnabled: function(a) {
  36253. this._enabled = a
  36254. },
  36255. getName: function() {
  36256. return this._name
  36257. },
  36258. setName: function(a) {
  36259. this._name = a
  36260. },
  36261. setOwner: function(a) {
  36262. this._owner = a
  36263. },
  36264. getOwner: function() {
  36265. return this._owner
  36266. }
  36267. });
  36268. cc.Component.create = function() {
  36269. return new cc.Component
  36270. };
  36271. cc.ComponentContainer = cc.Class.extend({
  36272. _components: null,
  36273. _owner: null,
  36274. ctor: function(a) {
  36275. this._components = null;
  36276. this._owner = a
  36277. },
  36278. getComponent: function(a) {
  36279. if (!a) throw "cc.ComponentContainer.getComponent(): name should be non-null";
  36280. a = a.trim();
  36281. return this._components[a]
  36282. },
  36283. add: function(a) {
  36284. if (!a) throw "cc.ComponentContainer.add(): component should be non-null";
  36285. if (a.getOwner()) return cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"), !1;
  36286. null == this._components && (this._components = {}, this._owner.scheduleUpdate());
  36287. if (this._components[a.getName()]) return cc.log("cc.ComponentContainer.add(): Component already added. It can't be added again"), !1;
  36288. a.setOwner(this._owner);
  36289. this._components[a.getName()] = a;
  36290. a.onEnter();
  36291. return !0
  36292. },
  36293. remove: function(a) {
  36294. if (!a) throw "cc.ComponentContainer.remove(): name should be non-null";
  36295. if (!this._components) return !1;
  36296. if (a instanceof cc.Component) return this._removeByComponent(a);
  36297. a = a.trim();
  36298. return this._removeByComponent(this._components[a])
  36299. },
  36300. _removeByComponent: function(a) {
  36301. if (a) return !1;
  36302. a.onExit();
  36303. a.setOwner(null);
  36304. delete this._components[a.getName()];
  36305. return !0
  36306. },
  36307. removeAll: function() {
  36308. if (this._components) {
  36309. var a = this._components,
  36310. c;
  36311. for (c in a) {
  36312. var d = a[c];
  36313. d.onExit();
  36314. d.setOwner(null);
  36315. delete a[c]
  36316. }
  36317. this._owner.unscheduleUpdate();
  36318. this._components = null
  36319. }
  36320. },
  36321. _alloc: function() {
  36322. this._components = {}
  36323. },
  36324. visit: function(a) {
  36325. if (this._components) {
  36326. var c = this._components,
  36327. d;
  36328. for (d in c) c[d].update(a)
  36329. }
  36330. },
  36331. isEmpty: function() {
  36332. if (!this._components) return !0;
  36333. for (var a in this._components) return !1;
  36334. return !0
  36335. }
  36336. });
  36337. var ccs = ccs || {};
  36338. ccs.Class = ccs.Class || cc.Class;
  36339. ccs.Class.extend = ccs.Class.extend || cc.Class.extend;
  36340. ccs.Node = ccs.Node || cc.Node;
  36341. ccs.Node.extend = ccs.Node.extend || cc.Node.extend;
  36342. ccs.Sprite = ccs.Sprite || cc.Sprite;
  36343. ccs.Sprite.extend = ccs.Sprite.extend || cc.Sprite.extend;
  36344. ccs.Component = ccs.Component || cc.Component;
  36345. ccs.Component.extend = ccs.Component.extend || cc.Component.extend;
  36346. ccs.cocostudioVersion = "v1.3.0.0";
  36347. ccs.VERSION_COMBINED = 0.3;
  36348. ccs.VERSION_CHANGE_ROTATION_RANGE = 1;
  36349. ccs.VERSION_COLOR_READING = 1.1;
  36350. ccs.MAX_VERTEXZ_VALUE = 5E6;
  36351. ccs.ARMATURE_MAX_CHILD = 50;
  36352. ccs.ARMATURE_MAX_ZORDER = 100;
  36353. ccs.ARMATURE_MAX_COUNT = ccs.MAX_VERTEXZ_VALUE / ccs.ARMATURE_MAX_CHILD / ccs.ARMATURE_MAX_ZORDER;
  36354. ccs.AUTO_ADD_SPRITE_FRAME_NAME_PREFIX = !1;
  36355. ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT = !1;
  36356. ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX = !1;
  36357. ccs.armatureVersion = function() {
  36358. return "v1.1.0.0"
  36359. };
  36360. ccs.CONST_VERSION = "version";
  36361. ccs.CONST_VERSION_2_0 = 2;
  36362. ccs.CONST_VERSION_COMBINED = 0.3;
  36363. ccs.CONST_ARMATURES = "armatures";
  36364. ccs.CONST_ARMATURE = "armature";
  36365. ccs.CONST_BONE = "b";
  36366. ccs.CONST_DISPLAY = "d";
  36367. ccs.CONST_ANIMATIONS = "animations";
  36368. ccs.CONST_ANIMATION = "animation";
  36369. ccs.CONST_MOVEMENT = "mov";
  36370. ccs.CONST_FRAME = "f";
  36371. ccs.CONST_TEXTURE_ATLAS = "TextureAtlas";
  36372. ccs.CONST_SUB_TEXTURE = "SubTexture";
  36373. ccs.CONST_SKELETON = "skeleton";
  36374. ccs.CONST_A_NAME = "name";
  36375. ccs.CONST_A_DURATION = "dr";
  36376. ccs.CONST_A_FRAME_INDEX = "fi";
  36377. ccs.CONST_A_DURATION_TO = "to";
  36378. ccs.CONST_A_DURATION_TWEEN = "drTW";
  36379. ccs.CONST_A_LOOP = "lp";
  36380. ccs.CONST_A_MOVEMENT_SCALE = "sc";
  36381. ccs.CONST_A_MOVEMENT_DELAY = "dl";
  36382. ccs.CONST_A_DISPLAY_INDEX = "dI";
  36383. ccs.CONST_A_PLIST = "plist";
  36384. ccs.CONST_A_PARENT = "parent";
  36385. ccs.CONST_A_SKEW_X = "kX";
  36386. ccs.CONST_A_SKEW_Y = "kY";
  36387. ccs.CONST_A_SCALE_X = "cX";
  36388. ccs.CONST_A_SCALE_Y = "cY";
  36389. ccs.CONST_A_Z = "z";
  36390. ccs.CONST_A_EVENT = "evt";
  36391. ccs.CONST_A_SOUND = "sd";
  36392. ccs.CONST_A_SOUND_EFFECT = "sdE";
  36393. ccs.CONST_A_TWEEN_EASING = "twE";
  36394. ccs.CONST_A_EASING_PARAM = "twEP";
  36395. ccs.CONST_A_TWEEN_ROTATE = "twR";
  36396. ccs.CONST_A_IS_ARMATURE = "isArmature";
  36397. ccs.CONST_A_DISPLAY_TYPE = "displayType";
  36398. ccs.CONST_A_MOVEMENT = "mov";
  36399. ccs.CONST_A_X = "x";
  36400. ccs.CONST_A_Y = "y";
  36401. ccs.CONST_A_COCOS2DX_X = "cocos2d_x";
  36402. ccs.CONST_A_COCOS2DX_Y = "cocos2d_y";
  36403. ccs.CONST_A_WIDTH = "width";
  36404. ccs.CONST_A_HEIGHT = "height";
  36405. ccs.CONST_A_PIVOT_X = "pX";
  36406. ccs.CONST_A_PIVOT_Y = "pY";
  36407. ccs.CONST_A_COCOS2D_PIVOT_X = "cocos2d_pX";
  36408. ccs.CONST_A_COCOS2D_PIVOT_Y = "cocos2d_pY";
  36409. ccs.CONST_A_BLEND_TYPE = "bd";
  36410. ccs.CONST_A_BLEND_SRC = "bd_src";
  36411. ccs.CONST_A_BLEND_DST = "bd_dst";
  36412. ccs.CONST_A_ALPHA = "a";
  36413. ccs.CONST_A_RED = "r";
  36414. ccs.CONST_A_GREEN = "g";
  36415. ccs.CONST_A_BLUE = "b";
  36416. ccs.CONST_A_ALPHA_OFFSET = "aM";
  36417. ccs.CONST_A_RED_OFFSET = "rM";
  36418. ccs.CONST_A_GREEN_OFFSET = "gM";
  36419. ccs.CONST_A_BLUE_OFFSET = "bM";
  36420. ccs.CONST_A_COLOR_TRANSFORM = "colorTransform";
  36421. ccs.CONST_A_TWEEN_FRAME = "tweenFrame";
  36422. ccs.CONST_CONTOUR = "con";
  36423. ccs.CONST_CONTOUR_VERTEX = "con_vt";
  36424. ccs.CONST_FL_NAN = "NaN";
  36425. ccs.CONST_FRAME_DATA = "frame_data";
  36426. ccs.CONST_MOVEMENT_BONE_DATA = "mov_bone_data";
  36427. ccs.CONST_MOVEMENT_DATA = "mov_data";
  36428. ccs.CONST_ANIMATION_DATA = "animation_data";
  36429. ccs.CONST_DISPLAY_DATA = "display_data";
  36430. ccs.CONST_SKIN_DATA = "skin_data";
  36431. ccs.CONST_BONE_DATA = "bone_data";
  36432. ccs.CONST_ARMATURE_DATA = "armature_data";
  36433. ccs.CONST_CONTOUR_DATA = "contour_data";
  36434. ccs.CONST_TEXTURE_DATA = "texture_data";
  36435. ccs.CONST_VERTEX_POINT = "vertex";
  36436. ccs.CONST_COLOR_INFO = "color";
  36437. ccs.CONST_CONFIG_FILE_PATH = "config_file_path";
  36438. ccs.CONST_CONTENT_SCALE = "content_scale";
  36439. ccs.DataInfo = function() {
  36440. this.asyncStruct = null;
  36441. this.configFileQueue = [];
  36442. this.contentScale = 1;
  36443. this.baseFilePath = this.filename = "";
  36444. this.cocoStudioVersion = this.flashToolVersion = 0
  36445. };
  36446. ccs.dataReaderHelper = {
  36447. ConfigType: {
  36448. DragonBone_XML: 0,
  36449. CocoStudio_JSON: 1,
  36450. CocoStudio_Binary: 2
  36451. },
  36452. _configFileList: [],
  36453. _flashToolVersion: ccs.CONST_VERSION_2_0,
  36454. _positionReadScale: 1,
  36455. _asyncRefCount: 0,
  36456. _asyncRefTotalCount: 0,
  36457. _dataQueue: null,
  36458. setPositionReadScale: function(a) {
  36459. this._positionReadScale = a
  36460. },
  36461. getPositionReadScale: function() {
  36462. return this._positionReadScale
  36463. },
  36464. addDataFromFile: function(a) {
  36465. if (-1 == this._configFileList.indexOf(a)) {
  36466. this._configFileList.push(a);
  36467. var c = this._initBaseFilePath(a),
  36468. d = cc.path.extname(a).toLowerCase(),
  36469. e = new ccs.DataInfo;
  36470. e.filename = a;
  36471. e.basefilePath = c;
  36472. ".xml" == d ? ccs.dataReaderHelper.addDataFromXML(a, e) : ".json" == d || ".exportjson" == d ? ccs.dataReaderHelper.addDataFromJson(a, e) : ".csb" == d && ccs.dataReaderHelper.addDataFromBinaryCache(a, e)
  36473. }
  36474. },
  36475. addDataFromFileAsync: function(a, c, d, e, f) {
  36476. 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));
  36477. else {
  36478. this._asyncRefTotalCount++;
  36479. this._asyncRefCount++;
  36480. var g = this;
  36481. cc.director.getScheduler().scheduleCallbackForTarget(this, function() {
  36482. g.addDataFromFile(d);
  36483. g._asyncRefCount--;
  36484. g._asyncCallBack(e, f, (g._asyncRefTotalCount - g._asyncRefCount) / g._asyncRefTotalCount)
  36485. }, 0.1, !1)
  36486. }
  36487. },
  36488. removeConfigFile: function(a) {
  36489. for (var c = this._configFileList, d = c.length, e = c[d], f = 0; f < d; f++) c[f] == a && (e = f);
  36490. e != c[d] && cc.arrayRemoveObject(c, a)
  36491. },
  36492. addDataFromCache: function(a, c) {
  36493. if (a) {
  36494. c.flashToolVersion = parseFloat(a.getAttribute(ccs.CONST_VERSION));
  36495. var d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_ARMATURES + " \x3e " + ccs.CONST_ARMATURE + ""),
  36496. e = ccs.armatureDataManager,
  36497. f;
  36498. for (f = 0; f < d.length; f++) {
  36499. var g = this.decodeArmature(d[f], c);
  36500. e.addArmatureData(g.name, g, c.filename)
  36501. }
  36502. d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_ANIMATIONS + " \x3e " + ccs.CONST_ANIMATION + "");
  36503. for (f = 0; f < d.length; f++) g = this.decodeAnimation(d[f], c), e.addAnimationData(g.name, g, c.filename);
  36504. d = a.querySelectorAll(ccs.CONST_SKELETON + " \x3e " + ccs.CONST_TEXTURE_ATLAS + " \x3e " + ccs.CONST_SUB_TEXTURE + "");
  36505. for (f = 0; f < d.length; f++) g = this.decodeTexture(d[f], c), e.addTextureData(g.name, g, c.filename)
  36506. } else cc.log("XML error or XML is empty.")
  36507. },
  36508. decodeArmature: function(a, c) {
  36509. var d = new ccs.ArmatureData;
  36510. d.init();
  36511. d.name = a.getAttribute(ccs.CONST_A_NAME);
  36512. for (var e = a.querySelectorAll(ccs.CONST_ARMATURE + " \x3e " + ccs.CONST_BONE), f = 0; f < e.length; f++) {
  36513. var g = e[f],
  36514. h = g.getAttribute(ccs.CONST_A_PARENT),
  36515. k = null;
  36516. if (h)
  36517. for (var m = 0; m < e.length && !(k = e[m], h == e[m].getAttribute(ccs.CONST_A_NAME)); m++);
  36518. g = this.decodeBone(g, k, c);
  36519. d.addBoneData(g)
  36520. }
  36521. return d
  36522. },
  36523. decodeArmatureFromJSON: function(a, c) {
  36524. var d = new ccs.ArmatureData;
  36525. d.init();
  36526. var e = a[ccs.CONST_A_NAME];
  36527. e && (d.name = e);
  36528. c.cocoStudioVersion = d.dataVersion = a[ccs.CONST_VERSION] || 0.1;
  36529. for (var e = a[ccs.CONST_BONE_DATA], f = 0; f < e.length; f++) {
  36530. var g = this.decodeBoneFromJson(e[f], c);
  36531. d.addBoneData(g)
  36532. }
  36533. return d
  36534. },
  36535. decodeBone: function(a, c, d) {
  36536. c = new ccs.BoneData;
  36537. c.init();
  36538. c.name = a.getAttribute(ccs.CONST_A_NAME);
  36539. c.parentName = a.getAttribute(ccs.CONST_A_PARENT) || "";
  36540. c.zOrder = parseInt(a.getAttribute(ccs.CONST_A_Z)) || 0;
  36541. a = a.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_DISPLAY);
  36542. for (var e = 0; e < a.length; e++) {
  36543. var f = this.decodeBoneDisplay(a[e], d);
  36544. c.addDisplayData(f)
  36545. }
  36546. return c
  36547. },
  36548. decodeBoneFromJson: function(a, c) {
  36549. var d = new ccs.BoneData;
  36550. d.init();
  36551. this.decodeNodeFromJson(d, a, c);
  36552. d.name = a[ccs.CONST_A_NAME] || "";
  36553. d.parentName = a[ccs.CONST_A_PARENT] || "";
  36554. for (var e = a[ccs.CONST_DISPLAY_DATA] || [], f = 0; f < e.length; f++) {
  36555. var g = this.decodeBoneDisplayFromJson(e[f], c);
  36556. d.addDisplayData(g)
  36557. }
  36558. return d
  36559. },
  36560. decodeBoneDisplay: function(a, c) {
  36561. var d = null;
  36562. 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);
  36563. var e = a.getAttribute(ccs.CONST_A_NAME) || "";
  36564. e && (d.displayName = e);
  36565. return d
  36566. },
  36567. decodeBoneDisplayFromJson: function(a, c) {
  36568. var d = a[ccs.CONST_A_DISPLAY_TYPE] || ccs.DISPLAY_TYPE_SPRITE,
  36569. e = null;
  36570. switch (d) {
  36571. case ccs.DISPLAY_TYPE_SPRITE:
  36572. var e = new ccs.SpriteDisplayData,
  36573. f = a[ccs.CONST_A_NAME];
  36574. null != f && (e.displayName = f);
  36575. if (f = (a[ccs.CONST_SKIN_DATA] || [])[0]) {
  36576. var g = e.skinData;
  36577. g.x = f[ccs.CONST_A_X] * this._positionReadScale;
  36578. g.y = f[ccs.CONST_A_Y] * this._positionReadScale;
  36579. g.scaleX = null == f[ccs.CONST_A_SCALE_X] ? 1 : f[ccs.CONST_A_SCALE_X];
  36580. g.scaleY = null == f[ccs.CONST_A_SCALE_Y] ? 1 : f[ccs.CONST_A_SCALE_Y];
  36581. g.skewX = null == f[ccs.CONST_A_SKEW_X] ? 1 : f[ccs.CONST_A_SKEW_X];
  36582. g.skewY = null == f[ccs.CONST_A_SKEW_Y] ? 1 : f[ccs.CONST_A_SKEW_Y];
  36583. g.x *= c.contentScale;
  36584. g.y *= c.contentScale
  36585. }
  36586. break;
  36587. case ccs.DISPLAY_TYPE_ARMATURE:
  36588. e = new ccs.ArmatureDisplayData;
  36589. f = a[ccs.CONST_A_NAME];
  36590. null != f && (e.displayName = a[ccs.CONST_A_NAME]);
  36591. break;
  36592. case ccs.DISPLAY_TYPE_PARTICLE:
  36593. e = new ccs.ParticleDisplayData;
  36594. f = a[ccs.CONST_A_PLIST];
  36595. null != f && (e.displayName = c.asyncStruct ? c.asyncStruct.basefilePath + f : c.basefilePath + f);
  36596. break;
  36597. default:
  36598. e = new ccs.SpriteDisplayData
  36599. }
  36600. e.displayType = d;
  36601. return e
  36602. },
  36603. decodeAnimation: function(a, c) {
  36604. var d = new ccs.AnimationData,
  36605. e = a.getAttribute(ccs.CONST_A_NAME),
  36606. f = ccs.armatureDataManager.getArmatureData(e);
  36607. d.name = e;
  36608. 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);
  36609. return d
  36610. },
  36611. decodeAnimationFromJson: function(a, c) {
  36612. var d = new ccs.AnimationData;
  36613. a[ccs.CONST_A_NAME] && (d.name = a[ccs.CONST_A_NAME]);
  36614. for (var e = a[ccs.CONST_MOVEMENT_DATA] || [], f = 0; f < e.length; f++) {
  36615. var g = this.decodeMovementFromJson(e[f], c);
  36616. d.addMovement(g)
  36617. }
  36618. return d
  36619. },
  36620. decodeMovement: function(a, c, d) {
  36621. var e = new ccs.MovementData;
  36622. e.name = a.getAttribute(ccs.CONST_A_NAME);
  36623. var f;
  36624. f = 0;
  36625. f = a.getAttribute(ccs.CONST_A_DURATION);
  36626. e.duration = null == f ? 0 : parseFloat(f);
  36627. f = a.getAttribute(ccs.CONST_A_DURATION_TO);
  36628. e.durationTo = null == f ? 0 : parseFloat(f);
  36629. f = a.getAttribute(ccs.CONST_A_DURATION_TWEEN);
  36630. e.durationTween = null == f ? 0 : parseFloat(f);
  36631. f = a.getAttribute(ccs.CONST_A_LOOP);
  36632. e.loop = f ? Boolean(parseFloat(f)) : !0;
  36633. 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;
  36634. a = a.querySelectorAll(ccs.CONST_MOVEMENT + " \x3e " + ccs.CONST_BONE);
  36635. var g = null;
  36636. for (f = 0; f < a.length; f++) {
  36637. var g = a[f],
  36638. h = g.getAttribute(ccs.CONST_A_NAME);
  36639. if (!e.getMovementBoneData(h)) {
  36640. var h = c.getBoneData(h),
  36641. k = h.parentName,
  36642. m = null;
  36643. if ("" != k)
  36644. for (var n = 0; n < a.length && !(m = a[n], k == m.getAttribute(ccs.CONST_A_NAME)); n++);
  36645. g = this.decodeMovementBone(g, m, h, d);
  36646. e.addMovementBoneData(g)
  36647. }
  36648. }
  36649. return e
  36650. },
  36651. decodeMovementFromJson: function(a, c) {
  36652. var d = new ccs.MovementData;
  36653. d.loop = null == a[ccs.CONST_A_LOOP] ? !1 : a[ccs.CONST_A_LOOP];
  36654. d.durationTween = a[ccs.CONST_A_DURATION_TWEEN] || 0;
  36655. d.durationTo = a[ccs.CONST_A_DURATION_TO] || 0;
  36656. d.duration = a[ccs.CONST_A_DURATION] || 0;
  36657. d.scale = null == a[ccs.CONST_A_DURATION] ? 1 : null == a[ccs.CONST_A_MOVEMENT_SCALE] ? 1 : a[ccs.CONST_A_MOVEMENT_SCALE];
  36658. d.tweenEasing = null == a[ccs.CONST_A_TWEEN_EASING] ? ccs.TweenType.linear : a[ccs.CONST_A_TWEEN_EASING];
  36659. var e = a[ccs.CONST_A_NAME];
  36660. e && (d.name = e);
  36661. for (var e = a[ccs.CONST_MOVEMENT_BONE_DATA] || [], f = 0; f < e.length; f++) {
  36662. var g = this.decodeMovementBoneFromJson(e[f], c);
  36663. d.addMovementBoneData(g)
  36664. }
  36665. return d
  36666. },
  36667. decodeMovementBone: function(a, c, d, e) {
  36668. var f = new ccs.MovementBoneData;
  36669. f.init();
  36670. var g;
  36671. 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);
  36672. var h = 0,
  36673. k = g = 0,
  36674. m = null,
  36675. n = [];
  36676. if (null != c) {
  36677. for (var q = c.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_FRAME), h = 0; h < q.length; h++) n.push(q[h]);
  36678. h = n.length
  36679. }
  36680. f.name = a.getAttribute(ccs.CONST_A_NAME);
  36681. a = a.querySelectorAll(ccs.CONST_BONE + " \x3e " + ccs.CONST_FRAME);
  36682. for (var r = q = 0, t = 0; t < a.length; t++) {
  36683. var s = a[t];
  36684. if (c)
  36685. for (; q < h && (m ? r < g || r >= g + k : 1);) m = n[q], g += k, k = parseFloat(m.getAttribute(ccs.CONST_A_DURATION)), q++;
  36686. s = this.decodeFrame(s, m, d, e);
  36687. f.addFrameData(s);
  36688. s.frameID = r;
  36689. r += s.duration;
  36690. f.duration = r
  36691. }
  36692. c = f.frameList;
  36693. d = Math.PI;
  36694. for (h = c.length - 1; 0 <= h; h--)
  36695. if (0 < h) {
  36696. e = c[h].skewX - c[h - 1].skewX;
  36697. g = c[h].skewY - c[h - 1].skewY;
  36698. if (e < -d || e > d) c[h - 1].skewX = 0 > e ? c[h - 1].skewX - 2 * d : c[h - 1].skewX + 2 * d;
  36699. if (g < -d || g > d) c[h - 1].skewY = 0 > g ? c[h - 1].skewY - 2 * d : c[h - 1].skewY + 2 * d
  36700. }
  36701. c = new ccs.FrameData;
  36702. c.copy(f.frameList[f.frameList.length - 1]);
  36703. c.frameID = f.duration;
  36704. f.addFrameData(c);
  36705. return f
  36706. },
  36707. decodeMovementBoneFromJson: function(a, c) {
  36708. var d = new ccs.MovementBoneData;
  36709. d.init();
  36710. d.delay = a[ccs.CONST_A_MOVEMENT_DELAY] || 0;
  36711. var e = a[ccs.CONST_A_NAME];
  36712. e && (d.name = e);
  36713. for (var f = (a[ccs.CONST_FRAME_DATA] || []).length, e = 0; e < f; e++) {
  36714. var g = this.decodeFrameFromJson(a[ccs.CONST_FRAME_DATA][e], c);
  36715. d.addFrameData(g);
  36716. c.cocoStudioVersion < ccs.CONST_VERSION_COMBINED && (g.frameID = d.duration, d.duration += g.duration)
  36717. }
  36718. if (c.cocoStudioVersion < ccs.VERSION_CHANGE_ROTATION_RANGE) {
  36719. f = d.frameList;
  36720. g = Math.PI;
  36721. for (e = f.length - 1; 0 <= e; e--)
  36722. if (0 < e) {
  36723. var h = f[e].skewX - f[e - 1].skewX,
  36724. k = f[e].skewY - f[e - 1].skewY;
  36725. if (h < -g || h > g) f[e - 1].skewX = 0 > h ? f[e - 1].skewX - 2 * g : f[e - 1].skewX + 2 * g;
  36726. if (k < -g || k > g) f[e - 1].skewY = 0 > k ? f[e - 1].skewY - 2 * g : f[e - 1].skewY + 2 * g
  36727. }
  36728. }
  36729. 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);
  36730. return d
  36731. },
  36732. decodeFrame: function(a, c, d, e) {
  36733. var f = 0,
  36734. f = f = f = f = f = f = f = f = f = f = f = 0;
  36735. d = new ccs.FrameData;
  36736. d.strMovement = a.getAttribute(ccs.CONST_A_MOVEMENT) || "";
  36737. d.movement = d.strMovement;
  36738. d.strEvent = a.getAttribute(ccs.CONST_A_EVENT) || "";
  36739. d.event = d.strEvent;
  36740. d.strSound = a.getAttribute(ccs.CONST_A_SOUND) || "";
  36741. d.sound = d.strSound;
  36742. d.strSoundEffect = a.getAttribute(ccs.CONST_A_SOUND_EFFECT) || "";
  36743. d.soundEffect = d.strSoundEffect;
  36744. f = a.getAttribute(ccs.CONST_A_TWEEN_FRAME);
  36745. d.isTween = void 0 == f ? !0 : Boolean(f);
  36746. if (e.flashToolVersion >= ccs.CONST_VERSION_2_0) {
  36747. if (f = a.getAttribute(ccs.CONST_A_COCOS2DX_X)) d.x = parseFloat(f), d.x *= this._positionReadScale;
  36748. f = a.getAttribute(ccs.CONST_A_COCOS2DX_Y)
  36749. } else {
  36750. if (f = a.getAttribute(ccs.CONST_A_X)) d.x = parseFloat(f), d.x *= this._positionReadScale;
  36751. f = a.getAttribute(ccs.CONST_A_Y)
  36752. }
  36753. f && (d.y = -parseFloat(f), d.y *= this._positionReadScale);
  36754. f = a.getAttribute(ccs.CONST_A_SCALE_X);
  36755. null != f && (d.scaleX = parseFloat(f));
  36756. f = a.getAttribute(ccs.CONST_A_SCALE_Y);
  36757. null != f && (d.scaleY = parseFloat(f));
  36758. f = a.getAttribute(ccs.CONST_A_SKEW_X);
  36759. null != f && (d.skewX = cc.degreesToRadians(parseFloat(f)));
  36760. f = a.getAttribute(ccs.CONST_A_SKEW_Y);
  36761. null != f && (d.skewY = cc.degreesToRadians(-parseFloat(f)));
  36762. f = a.getAttribute(ccs.CONST_A_DURATION);
  36763. null != f && (d.duration = parseFloat(f));
  36764. f = a.getAttribute(ccs.CONST_A_DISPLAY_INDEX);
  36765. null != f && (d.displayIndex = parseFloat(f));
  36766. f = a.getAttribute(ccs.CONST_A_Z);
  36767. null != f && (d.zOrder = parseInt(f));
  36768. f = a.getAttribute(ccs.CONST_A_TWEEN_ROTATE);
  36769. null != f && (d.tweenRotate = parseFloat(f));
  36770. f = a.getAttribute(ccs.CONST_A_BLEND_TYPE);
  36771. if (null != f) {
  36772. var g = d.blendFunc;
  36773. switch (f) {
  36774. case ccs.BLEND_TYPE_NORMAL:
  36775. g.src = cc.BLEND_SRC;
  36776. g.dst = cc.BLEND_DST;
  36777. break;
  36778. case ccs.BLEND_TYPE_ADD:
  36779. g.src = cc.SRC_ALPHA;
  36780. g.dst = cc.ONE;
  36781. break;
  36782. case ccs.BLEND_TYPE_MULTIPLY:
  36783. g.src = cc.DST_COLOR;
  36784. g.dst = cc.ONE_MINUS_SRC_ALPHA;
  36785. break;
  36786. case ccs.BLEND_TYPE_SCREEN:
  36787. g.src = cc.ONE;
  36788. g.dst = cc.ONE_MINUS_DST_COLOR;
  36789. break;
  36790. default:
  36791. d.blendFunc.src = cc.BLEND_SRC, d.blendFunc.dst = cc.BLEND_DST
  36792. }
  36793. }
  36794. var h = a.querySelectorAll(ccs.CONST_FRAME + " \x3e " + ccs.CONST_A_COLOR_TRANSFORM);
  36795. if (h && 0 < h.length) {
  36796. var h = h[0],
  36797. k, m, n, q, r, f = h.getAttribute(ccs.CONST_A_ALPHA) || 0,
  36798. g = h.getAttribute(ccs.CONST_A_RED) || 0;
  36799. k = h.getAttribute(ccs.CONST_A_GREEN) || 0;
  36800. m = h.getAttribute(ccs.CONST_A_BLUE) || 0;
  36801. n = h.getAttribute(ccs.CONST_A_ALPHA_OFFSET) || 0;
  36802. q = h.getAttribute(ccs.CONST_A_RED_OFFSET) || 0;
  36803. r = h.getAttribute(ccs.CONST_A_GREEN_OFFSET) || 0;
  36804. h = h.getAttribute(ccs.CONST_A_BLUE_OFFSET) || 0;
  36805. d.a = 2.55 * n + f;
  36806. d.r = 2.55 * q + g;
  36807. d.g = 2.55 * r + k;
  36808. d.b = 2.55 * h + m;
  36809. d.isUseColorInfo = !0
  36810. }
  36811. f = a.getAttribute(ccs.CONST_A_TWEEN_EASING);
  36812. 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);
  36813. 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));
  36814. return d
  36815. },
  36816. decodeFrameFromJson: function(a, c) {
  36817. var d = new ccs.FrameData;
  36818. this.decodeNodeFromJson(d, a, c);
  36819. d.tweenEasing = a[ccs.CONST_A_TWEEN_EASING] || ccs.TweenType.linear;
  36820. d.displayIndex = a[ccs.CONST_A_DISPLAY_INDEX];
  36821. var e = null == a[ccs.CONST_A_BLEND_DST] ? cc.BLEND_DST : a[ccs.CONST_A_BLEND_DST];
  36822. d.blendFunc.src = null == a[ccs.CONST_A_BLEND_SRC] ? cc.BLEND_SRC : a[ccs.CONST_A_BLEND_SRC];
  36823. d.blendFunc.dst = e;
  36824. d.isTween = null == a[ccs.CONST_A_TWEEN_FRAME] ? !0 : a[ccs.CONST_A_TWEEN_FRAME];
  36825. e = a[ccs.CONST_A_EVENT];
  36826. null != e && (d.strEvent = e, d.event = e);
  36827. 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];
  36828. for (var e = a[ccs.CONST_A_EASING_PARAM] || [], f = 0; f < e.length; f++) d.easingParams[f] = e[f];
  36829. return d
  36830. },
  36831. decodeTexture: function(a, c) {
  36832. var d = new ccs.TextureData;
  36833. d.init();
  36834. a.getAttribute(ccs.CONST_A_NAME) && (d.name = a.getAttribute(ccs.CONST_A_NAME));
  36835. var e, f;
  36836. 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);
  36837. var g = parseFloat(a.getAttribute(ccs.CONST_A_WIDTH)) || 0,
  36838. h = parseFloat(a.getAttribute(ccs.CONST_A_HEIGHT)) || 0;
  36839. d.pivotX = e / g;
  36840. d.pivotY = (h - f) / h;
  36841. e = a.querySelectorAll(ccs.CONST_SUB_TEXTURE + " \x3e " + ccs.CONST_CONTOUR);
  36842. for (f = 0; f < e.length; f++) d.addContourData(this.decodeContour(e[f], c));
  36843. return d
  36844. },
  36845. decodeTextureFromJson: function(a) {
  36846. var c = new ccs.TextureData;
  36847. c.init();
  36848. var d = a[ccs.CONST_A_NAME];
  36849. null != d && (c.name = d);
  36850. c.width = a[ccs.CONST_A_WIDTH] || 0;
  36851. c.height = a[ccs.CONST_A_HEIGHT] || 0;
  36852. c.pivotX = a[ccs.CONST_A_PIVOT_X] || 0;
  36853. c.pivotY = a[ccs.CONST_A_PIVOT_Y] || 0;
  36854. a = a[ccs.CONST_CONTOUR_DATA] || [];
  36855. for (d = 0; d < a.length; d++) c.contourDataList.push(this.decodeContourFromJson(a[d]));
  36856. return c
  36857. },
  36858. decodeContour: function(a, c) {
  36859. var d = new ccs.ContourData;
  36860. d.init();
  36861. for (var e = a.querySelectorAll(ccs.CONST_CONTOUR + " \x3e " + ccs.CONST_CONTOUR_VERTEX), f, g = 0; g < e.length; g++) {
  36862. f = e[g];
  36863. var h = cc.p(0, 0);
  36864. h.x = parseFloat(f.getAttribute(ccs.CONST_A_X)) || 0;
  36865. h.y = parseFloat(f.getAttribute(ccs.CONST_A_Y)) || 0;
  36866. h.y = -h.y;
  36867. d.vertexList.push(h)
  36868. }
  36869. return d
  36870. },
  36871. decodeContourFromJson: function(a) {
  36872. var c = new ccs.ContourData;
  36873. c.init();
  36874. a = a[ccs.CONST_VERTEX_POINT] || [];
  36875. for (var d = a.length, e = 0; e < d; e++) {
  36876. var f = a[e],
  36877. g = cc.p(0, 0);
  36878. g.x = f[ccs.CONST_A_X] || 0;
  36879. g.y = f[ccs.CONST_A_Y] || 0;
  36880. c.vertexList.push(g)
  36881. }
  36882. return c
  36883. },
  36884. addDataFromJsonCache: function(a, c) {
  36885. c.contentScale = null == a[ccs.CONST_CONTENT_SCALE] ? 1 : a[ccs.CONST_CONTENT_SCALE];
  36886. var d = a[ccs.CONST_ARMATURE_DATA] || [],
  36887. e, f;
  36888. for (e = 0; e < d.length; e++) f = this.decodeArmatureFromJSON(d[e], c), ccs.armatureDataManager.addArmatureData(f.name, f, c.filename);
  36889. d = a[ccs.CONST_ANIMATION_DATA] || [];
  36890. for (e = 0; e < d.length; e++) f = this.decodeAnimationFromJson(d[e], c), ccs.armatureDataManager.addAnimationData(f.name, f, c.filename);
  36891. d = a[ccs.CONST_TEXTURE_DATA] || [];
  36892. for (e = 0; e < d.length; e++) f = this.decodeTextureFromJson(d[e], c), ccs.armatureDataManager.addTextureData(f.name, f, c.filename);
  36893. if (null == c.asyncStruct ? ccs.armatureDataManager.isAutoLoadSpriteFile() : c.asyncStruct.autoLoadSpriteFile) {
  36894. var d = a[ccs.CONST_CONFIG_FILE_PATH] || [],
  36895. g;
  36896. 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)
  36897. }
  36898. },
  36899. decodeNodeFromJson: function(a, c, d) {
  36900. a.x = c[ccs.CONST_A_X] * this._positionReadScale;
  36901. a.y = c[ccs.CONST_A_Y] * this._positionReadScale;
  36902. a.x *= d.contentScale;
  36903. a.y *= d.contentScale;
  36904. a.zOrder = c[ccs.CONST_A_Z];
  36905. a.skewX = c[ccs.CONST_A_SKEW_X] || 0;
  36906. a.skewY = c[ccs.CONST_A_SKEW_Y] || 0;
  36907. a.scaleX = null == c[ccs.CONST_A_SCALE_X] ? 1 : c[ccs.CONST_A_SCALE_X];
  36908. a.scaleY = null == c[ccs.CONST_A_SCALE_Y] ? 1 : c[ccs.CONST_A_SCALE_Y];
  36909. 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
  36910. },
  36911. clear: function() {
  36912. this._configFileList = [];
  36913. this._asyncRefTotalCount = this._asyncRefCount = 0
  36914. },
  36915. _asyncCallBack: function(a, c, d) {
  36916. a && "function" === typeof a && a.call(c, d);
  36917. if (c && a && "string" === typeof a) c[a](d)
  36918. },
  36919. _initBaseFilePath: function(a) {
  36920. var c = a.lastIndexOf("/");
  36921. return a = -1 < c ? a.substr(0, c + 1) : ""
  36922. },
  36923. addDataFromXML: function(a, c) {
  36924. var d = cc.loader.getRes(a);
  36925. if (!d) throw "Please load the resource first : " + a;
  36926. (d = cc.saxParser.parse(d).documentElement) && this.addDataFromCache(d, c)
  36927. },
  36928. addDataFromJson: function(a, c) {
  36929. var d = cc.loader.getRes(a);
  36930. this.addDataFromJsonCache(d, c)
  36931. }
  36932. };
  36933. ccs.spriteFrameCacheHelper = {
  36934. _textureAtlasDic: {},
  36935. _imagePaths: [],
  36936. addSpriteFrameFromFile: function(a, c) {
  36937. cc.spriteFrameCache.addSpriteFrames(a, c)
  36938. },
  36939. getTexureAtlasWithTexture: function(a) {
  36940. return null
  36941. },
  36942. clear: function() {
  36943. this._textureAtlasDic = {};
  36944. this._imagePaths = []
  36945. }
  36946. };
  36947. ccs.TransformHelp = ccs.TransformHelp || ccs.Class.extend({});
  36948. ccs.TransformHelp.helpMatrix1 = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
  36949. ccs.TransformHelp.helpMatrix2 = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
  36950. ccs.TransformHelp.helpPoint1 = cc.p(0, 0);
  36951. ccs.TransformHelp.helpPoint2 = cc.p(0, 0);
  36952. ccs.TransformHelp.helpParentNode = {};
  36953. ccs.TransformHelp.transformFromParent = function(a, c) {
  36954. this.nodeToMatrix(a, this.helpMatrix1);
  36955. this.nodeToMatrix(c, this.helpMatrix2);
  36956. this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2);
  36957. this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
  36958. this.matrixToNode(this.helpMatrix1, a)
  36959. };
  36960. ccs.TransformHelp.transformToParent = function(a, c) {
  36961. this.nodeToMatrix(a, this.helpMatrix1);
  36962. this.nodeToMatrix(c, this.helpMatrix2);
  36963. this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
  36964. this.matrixToNode(this.helpMatrix1, a)
  36965. };
  36966. ccs.TransformHelp.transformFromParentWithoutScale = function(a, c) {
  36967. for (var d in c) this.helpParentNode[d] = c[d];
  36968. this.helpParentNode.scaleX = 1;
  36969. this.helpParentNode.scaleY = 1;
  36970. this.nodeToMatrix(a, this.helpMatrix1);
  36971. this.nodeToMatrix(this.helpParentNode, this.helpMatrix2);
  36972. this.helpMatrix2 = cc.affineTransformInvert(this.helpMatrix2);
  36973. this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
  36974. this.matrixToNode(this.helpMatrix1, a)
  36975. };
  36976. ccs.TransformHelp.transformToParentWithoutScale = function(a, c) {
  36977. for (var d in c) this.helpParentNode[d] = c[d];
  36978. this.helpParentNode.scaleX = 1;
  36979. this.helpParentNode.scaleY = 1;
  36980. this.nodeToMatrix(a, this.helpMatrix1);
  36981. this.nodeToMatrix(this.helpParentNode, this.helpMatrix2);
  36982. this.helpMatrix1 = cc.affineTransformConcat(this.helpMatrix1, this.helpMatrix2);
  36983. this.matrixToNode(this.helpMatrix1, a)
  36984. };
  36985. ccs.TransformHelp.nodeToMatrix = function(a, c) {
  36986. if (a.skewX == -a.skewY) {
  36987. var d = Math.sin(a.skewX),
  36988. e = Math.cos(a.skewX);
  36989. c.a = a.scaleX * e;
  36990. c.b = a.scaleX * -d;
  36991. c.c = a.scaleY * d;
  36992. c.d = a.scaleY * e
  36993. } 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);
  36994. c.tx = a.x;
  36995. c.ty = a.y
  36996. };
  36997. ccs.TransformHelp.matrixToNode = function(a, c) {
  36998. this.helpPoint1.x = 0;
  36999. this.helpPoint1.y = 1;
  37000. this.helpPoint1 = cc.pointApplyAffineTransform(this.helpPoint1, a);
  37001. this.helpPoint1.x -= a.tx;
  37002. this.helpPoint1.y -= a.ty;
  37003. this.helpPoint2.x = 1;
  37004. this.helpPoint2.y = 0;
  37005. this.helpPoint2 = cc.pointApplyAffineTransform(this.helpPoint2, a);
  37006. this.helpPoint2.x -= a.tx;
  37007. this.helpPoint2.y -= a.ty;
  37008. c.skewX = -(Math.atan2(this.helpPoint1.y, this.helpPoint1.x) - 1.5707964);
  37009. c.skewY = Math.atan2(this.helpPoint2.y, this.helpPoint2.x);
  37010. c.scaleX = Math.sqrt(a.a * a.a + a.b * a.b);
  37011. c.scaleY = Math.sqrt(a.c * a.c + a.d * a.d);
  37012. c.x = a.tx;
  37013. c.y = a.ty
  37014. };
  37015. ccs.TransformHelp.nodeConcat = function(a, c) {
  37016. a.x += c.x;
  37017. a.y += c.y;
  37018. a.skewX += c.skewX;
  37019. a.skewY += c.skewY;
  37020. a.scaleX += c.scaleX;
  37021. a.scaleY += c.scaleY
  37022. };
  37023. ccs.TransformHelp.nodeSub = function(a, c) {
  37024. a.x -= c.x;
  37025. a.y -= c.y;
  37026. a.skewX -= c.skewX;
  37027. a.skewY -= c.skewY;
  37028. a.scaleX -= c.scaleX;
  37029. a.scaleY -= c.scaleY
  37030. };
  37031. ccs.TweenType = {
  37032. customEasing: -1,
  37033. linear: 0,
  37034. sineEaseIn: 1,
  37035. sineEaseOut: 2,
  37036. sineEaseInOut: 3,
  37037. quadEaseIn: 4,
  37038. quadEaseOut: 5,
  37039. quadEaseInOut: 6,
  37040. cubicEaseIn: 7,
  37041. cubicEaseOut: 8,
  37042. cubicEaseInOut: 9,
  37043. quartEaseIn: 10,
  37044. quartEaseOut: 11,
  37045. quartEaseInOut: 12,
  37046. quintEaseIn: 13,
  37047. quintEaseOut: 14,
  37048. quintEaseInOut: 15,
  37049. expoEaseIn: 16,
  37050. expoEaseOut: 17,
  37051. expoEaseInOut: 18,
  37052. circEaseIn: 19,
  37053. eircEaseOut: 20,
  37054. circEaseInOut: 21,
  37055. elasticEaseIn: 22,
  37056. elasticEaseOut: 23,
  37057. elasticEaseInOut: 24,
  37058. backEaseIn: 25,
  37059. backEaseOut: 26,
  37060. backEaseInOut: 27,
  37061. bounceEaseIn: 28,
  37062. bounceEaseOut: 29,
  37063. bounceEaseInOut: 30,
  37064. tweenEasingMax: 1E4
  37065. };
  37066. ccs.TweenFunction = ccs.TweenFunction || ccs.Class.extend({});
  37067. ccs.DOUBLE_PI = ccs.M_PI_X_2 = 2 * Math.PI;
  37068. ccs.HALF_PI = ccs.M_PI_2 = Math.PI / 2;
  37069. ccs.M_PI = Math.PI;
  37070. ccs.TweenFunction.tweenTo = function(a, c, d) {
  37071. var e = 0;
  37072. switch (c) {
  37073. case ccs.TweenType.customEasing:
  37074. e = this.customEase(a, d);
  37075. break;
  37076. case ccs.TweenType.linear:
  37077. e = this.linear(a);
  37078. break;
  37079. case ccs.TweenType.sineEaseIn:
  37080. e = this.sineEaseIn(a);
  37081. break;
  37082. case ccs.TweenType.sineEaseOut:
  37083. e = this.sineEaseOut(a);
  37084. break;
  37085. case ccs.TweenType.sineEaseInOut:
  37086. e = this.sineEaseInOut(a);
  37087. break;
  37088. case ccs.TweenType.quadEaseIn:
  37089. e = this.quadEaseIn(a);
  37090. break;
  37091. case ccs.TweenType.quadEaseOut:
  37092. e = this.quadEaseOut(a);
  37093. break;
  37094. case ccs.TweenType.quadEaseInOut:
  37095. e = this.quadEaseInOut(a);
  37096. break;
  37097. case ccs.TweenType.cubicEaseIn:
  37098. e = this.cubicEaseIn(a);
  37099. break;
  37100. case ccs.TweenType.cubicEaseOut:
  37101. e = this.cubicEaseOut(a);
  37102. break;
  37103. case ccs.TweenType.cubicEaseInOut:
  37104. e = this.cubicEaseInOut(a);
  37105. break;
  37106. case ccs.TweenType.quartEaseIn:
  37107. e = this.quartEaseIn(a);
  37108. break;
  37109. case ccs.TweenType.quartEaseOut:
  37110. e = this.quartEaseOut(a);
  37111. break;
  37112. case ccs.TweenType.quartEaseInOut:
  37113. e = this.quartEaseInOut(a);
  37114. break;
  37115. case ccs.TweenType.quintEaseIn:
  37116. e = this.quintEaseIn(a);
  37117. break;
  37118. case ccs.TweenType.quintEaseOut:
  37119. e = this.quintEaseOut(a);
  37120. break;
  37121. case ccs.TweenType.quintEaseInOut:
  37122. e = this.quintEaseInOut(a);
  37123. break;
  37124. case ccs.TweenType.expoEaseIn:
  37125. e = this.expoEaseIn(a);
  37126. break;
  37127. case ccs.TweenType.expoEaseOut:
  37128. e = this.expoEaseOut(a);
  37129. break;
  37130. case ccs.TweenType.expoEaseInOut:
  37131. e = this.expoEaseInOut(a);
  37132. break;
  37133. case ccs.TweenType.circEaseIn:
  37134. e = this.circEaseIn(a);
  37135. break;
  37136. case ccs.TweenType.eircEaseOut:
  37137. e = this.circEaseOut(a);
  37138. break;
  37139. case ccs.TweenType.circEaseInOut:
  37140. e = this.circEaseInOut(a);
  37141. break;
  37142. case ccs.TweenType.elasticEaseIn:
  37143. c = 0.3;
  37144. null != d && (c = d[0]);
  37145. e = this.elasticEaseIn(a, c);
  37146. break;
  37147. case ccs.TweenType.elasticEaseOut:
  37148. c = 0.3;
  37149. null != d && (c = d[0]);
  37150. e = this.elasticEaseOut(a, c);
  37151. break;
  37152. case ccs.TweenType.elasticEaseInOut:
  37153. c = 0.3;
  37154. null != d && (c = d[0]);
  37155. e = this.elasticEaseInOut(a, c);
  37156. break;
  37157. case ccs.TweenType.backEaseIn:
  37158. e = this.backEaseIn(a);
  37159. break;
  37160. case ccs.TweenType.backEaseOut:
  37161. e = this.backEaseOut(a);
  37162. break;
  37163. case ccs.TweenType.backEaseInOut:
  37164. e = this.backEaseInOut(a);
  37165. break;
  37166. case ccs.TweenType.bounceEaseIn:
  37167. e = this.bounceEaseIn(a);
  37168. break;
  37169. case ccs.TweenType.bounceEaseOut:
  37170. e = this.bounceEaseOut(a);
  37171. break;
  37172. case ccs.TweenType.bounceEaseInOut:
  37173. e = this.bounceEaseInOut(a);
  37174. break;
  37175. default:
  37176. e = this.sineEaseInOut(a)
  37177. }
  37178. return e
  37179. };
  37180. ccs.TweenFunction.linear = function(a) {
  37181. return a
  37182. };
  37183. ccs.TweenFunction.sineEaseIn = function(a) {
  37184. return -1 * Math.cos(a * ccs.HALF_PI) + 1
  37185. };
  37186. ccs.TweenFunction.sineEaseOut = function(a) {
  37187. return Math.sin(a * ccs.HALF_PI)
  37188. };
  37189. ccs.TweenFunction.sineEaseInOut = function(a) {
  37190. return -0.5 * (Math.cos(ccs.M_PI * a) - 1)
  37191. };
  37192. ccs.TweenFunction.quadEaseIn = function(a) {
  37193. return a * a
  37194. };
  37195. ccs.TweenFunction.quadEaseOut = function(a) {
  37196. return -1 * a * (a - 2)
  37197. };
  37198. ccs.TweenFunction.quadEaseInOut = function(a) {
  37199. a *= 2;
  37200. if (1 > a) return 0.5 * a * a;
  37201. --a;
  37202. return -0.5 * (a * (a - 2) - 1)
  37203. };
  37204. ccs.TweenFunction.cubicEaseIn = function(a) {
  37205. return a * a * a
  37206. };
  37207. ccs.TweenFunction.cubicEaseOut = function(a) {
  37208. a -= 1;
  37209. return a * a * a + 1
  37210. };
  37211. ccs.TweenFunction.cubicEaseInOut = function(a) {
  37212. a *= 2;
  37213. if (1 > a) return 0.5 * a * a * a;
  37214. a -= 2;
  37215. return 0.5 * (a * a * a + 2)
  37216. };
  37217. ccs.TweenFunction.quartEaseIn = function(a) {
  37218. return a * a * a * a
  37219. };
  37220. ccs.TweenFunction.quartEaseOut = function(a) {
  37221. a -= 1;
  37222. return -(a * a * a * a - 1)
  37223. };
  37224. ccs.TweenFunction.quartEaseInOut = function(a) {
  37225. a *= 2;
  37226. if (1 > a) return 0.5 * a * a * a * a;
  37227. a -= 2;
  37228. return -0.5 * (a * a * a * a - 2)
  37229. };
  37230. ccs.TweenFunction.quintEaseIn = function(a) {
  37231. return a * a * a * a * a
  37232. };
  37233. ccs.TweenFunction.quintEaseOut = function(a) {
  37234. a -= 1;
  37235. return a * a * a * a * a + 1
  37236. };
  37237. ccs.TweenFunction.quintEaseInOut = function(a) {
  37238. a *= 2;
  37239. if (1 > a) return 0.5 * a * a * a * a * a;
  37240. a -= 2;
  37241. return 0.5 * (a * a * a * a * a + 2)
  37242. };
  37243. ccs.TweenFunction.expoEaseIn = function(a) {
  37244. return 0 == a ? 0 : Math.pow(2, 10 * (a - 1)) - 0.0010
  37245. };
  37246. ccs.TweenFunction.expoEaseOut = function(a) {
  37247. return 1 == a ? 1 : -Math.pow(2, -10 * a) + 1
  37248. };
  37249. ccs.TweenFunction.expoEaseInOut = function(a) {
  37250. a /= 0.5;
  37251. return a = 1 > a ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  37252. };
  37253. ccs.TweenFunction.circEaseIn = function(a) {
  37254. return -1 * (Math.sqrt(1 - a * a) - 1)
  37255. };
  37256. ccs.TweenFunction.circEaseOut = function(a) {
  37257. a -= 1;
  37258. return Math.sqrt(1 - a * a)
  37259. };
  37260. ccs.TweenFunction.circEaseInOut = function(a) {
  37261. a *= 2;
  37262. if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
  37263. a -= 2;
  37264. return 0.5 * (Math.sqrt(1 - a * a) + 1)
  37265. };
  37266. ccs.TweenFunction.elasticEaseIn = function(a, c) {
  37267. var d = 0.3;
  37268. 0 < c.length && (d = c[0]);
  37269. var e = 0;
  37270. 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));
  37271. return e
  37272. };
  37273. ccs.TweenFunction.elasticEaseOut = function(a, c) {
  37274. var d = 0.3;
  37275. 0 < c.length && (d = c[0]);
  37276. var e = 0;
  37277. 0 == a || 1 == a ? e = a : (e = d / 4, e = Math.pow(2, -10 * a) * Math.sin((a - e) * ccs.DOUBLE_PI / d) + 1);
  37278. return e
  37279. };
  37280. ccs.TweenFunction.elasticEaseInOut = function(a, c) {
  37281. var d = 0.3;
  37282. 0 < c.length && (d = c[0]);
  37283. var e = 0;
  37284. 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);
  37285. return e
  37286. };
  37287. ccs.TweenFunction.backEaseIn = function(a) {
  37288. return a * a * (2.70158 * a - 1.70158)
  37289. };
  37290. ccs.TweenFunction.backEaseOut = function(a) {
  37291. a -= 1;
  37292. return a * a * (2.70158 * a + 1.70158) + 1
  37293. };
  37294. ccs.TweenFunction.backEaseInOut = function(a) {
  37295. a *= 2;
  37296. if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
  37297. a -= 2;
  37298. return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
  37299. };
  37300. ccs.bounceTime = function(a) {
  37301. if (a < 1 / 2.75) return 7.5625 * a * a;
  37302. if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
  37303. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
  37304. a -= 2.625 / 2.75;
  37305. return 7.5625 * a * a + 0.984375
  37306. };
  37307. ccs.TweenFunction.bounceEaseIn = function(a) {
  37308. return 1 - ccs.bounceTime(1 - a)
  37309. };
  37310. ccs.TweenFunction.bounceEaseOut = function(a) {
  37311. return ccs.bounceTime(a)
  37312. };
  37313. ccs.TweenFunction.bounceEaseInOut = function(a) {
  37314. var c = 0;
  37315. return c = 0.5 > a ? 0.5 * (1 - ccs.bounceTime(1 - 2 * a)) : 0.5 * ccs.bounceTime(2 * a - 1) + 0.5
  37316. };
  37317. ccs.TweenFunction.customEase = function(a, c) {
  37318. if (0 < c.length) {
  37319. var d = 1 - a;
  37320. return c[1] * d * d * d + 3 * c[3] * a * d * d + 3 * c[5] * a * a * d + c[7] * a * a * a
  37321. }
  37322. return a
  37323. };
  37324. ccs.TweenFunction.easeIn = function(a, c) {
  37325. return Math.pow(a, c)
  37326. };
  37327. ccs.TweenFunction.easeOut = function(a, c) {
  37328. return Math.pow(a, 1 / c)
  37329. };
  37330. ccs.TweenFunction.easeInOut = function(a, c) {
  37331. a *= 2;
  37332. return 1 > a ? 0.5 * Math.pow(a, c) : 1 - 0.5 * Math.pow(2 - a, c)
  37333. };
  37334. ccs.TweenFunction.quadraticIn = function(a) {
  37335. return Math.pow(a, 2)
  37336. };
  37337. ccs.TweenFunction.quadraticOut = function(a) {
  37338. return -a * (a - 2)
  37339. };
  37340. ccs.TweenFunction.bezieratFunction = function(a, c, d, e, f) {
  37341. 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
  37342. };
  37343. var ENABLE_PHYSICS_DETECT = !1;
  37344. ccs.fmodf = function(a, c) {
  37345. for (; a > c;) a -= c;
  37346. return a
  37347. };
  37348. var CC_SAFE_RELEASE = function(a) {
  37349. a && a.release && a.release()
  37350. };
  37351. ccs.isSpriteContainPoint = function(a, c, d) {
  37352. c = a.convertToNodeSpace(c);
  37353. d && (d.x = c.x, d.y = c.y);
  37354. a = a.getContentSize();
  37355. return cc.rectContainsPoint(cc.rect(0, 0, a.width, a.height), c)
  37356. };
  37357. ccs.SPRITE_CONTAIN_POINT = ccs.isSpriteContainPoint;
  37358. ccs.SPRITE_CONTAIN_POINT_WITH_RETURN = ccs.isSpriteContainPoint;
  37359. ccs.extBezierTo = function(a, c, d, e, f) {
  37360. var g = cc.p(0, 0);
  37361. 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);
  37362. 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));
  37363. return g
  37364. };
  37365. ccs.extCircleTo = function(a, c, d, e, f) {
  37366. var g = cc.p(0, 0);
  37367. g.x = c.x + d * Math.cos(e + f * a);
  37368. g.y = c.y + d * Math.sin(e + f * a);
  37369. return g
  37370. };
  37371. ccs.RelativeData = function() {
  37372. this.plistFiles = [];
  37373. this.armatures = [];
  37374. this.animations = [];
  37375. this.textures = []
  37376. };
  37377. ccs.armatureDataManager = {
  37378. _animationDatas: {},
  37379. _armarureDatas: {},
  37380. _textureDatas: {},
  37381. _autoLoadSpriteFile: !1,
  37382. _relativeDatas: {},
  37383. s_sharedArmatureDataManager: null,
  37384. removeArmatureFileInfo: function(a) {
  37385. var c = this.getRelativeData(a);
  37386. if (c) {
  37387. for (var d = 0; d < c.armatures.length; d++) {
  37388. var e = c.armatures[d];
  37389. this.removeArmatureData(e)
  37390. }
  37391. for (d = 0; d < c.animations.length; d++) e = c.animations[d], this.removeAnimationData(e);
  37392. for (d = 0; d < c.textures.length; d++) e = c.textures[d], this.removeTextureData(e);
  37393. for (d = 0; d < c.plistFiles.length; d++) e = c.plistFiles[d], cc.spriteFrameCache.removeSpriteFramesFromFile(e);
  37394. delete this._relativeDatas[a];
  37395. ccs.dataReaderHelper.removeConfigFile(a)
  37396. }
  37397. },
  37398. addArmatureData: function(a, c, d) {
  37399. (d = this.getRelativeData(d)) && d.armatures.push(a);
  37400. this._armarureDatas[a] = c
  37401. },
  37402. getArmatureData: function(a) {
  37403. var c = null;
  37404. this._armarureDatas && (c = this._armarureDatas[a]);
  37405. return c
  37406. },
  37407. removeArmatureData: function(a) {
  37408. this._armarureDatas[a] && delete this._armarureDatas[a]
  37409. },
  37410. addAnimationData: function(a, c, d) {
  37411. (d = this.getRelativeData(d)) && d.animations.push(a);
  37412. this._animationDatas[a] = c
  37413. },
  37414. getAnimationData: function(a) {
  37415. var c = null;
  37416. this._animationDatas[a] && (c = this._animationDatas[a]);
  37417. return c
  37418. },
  37419. removeAnimationData: function(a) {
  37420. this._animationDatas[a] && delete this._animationDatas[a]
  37421. },
  37422. addTextureData: function(a, c, d) {
  37423. (d = this.getRelativeData(d)) && d.textures.push(a);
  37424. this._textureDatas[a] = c
  37425. },
  37426. getTextureData: function(a) {
  37427. var c = null;
  37428. this._textureDatas && (c = this._textureDatas[a]);
  37429. return c
  37430. },
  37431. removeTextureData: function(a) {
  37432. this._textureDatas[a] && delete this._textureDatas[a]
  37433. },
  37434. addArmatureFileInfo: function() {
  37435. var a, c, d;
  37436. switch (arguments.length) {
  37437. case 1:
  37438. d = arguments[0];
  37439. this.addRelativeData(d);
  37440. this._autoLoadSpriteFile = !0;
  37441. ccs.dataReaderHelper.addDataFromFile(d);
  37442. break;
  37443. case 3:
  37444. a = arguments[0], c = arguments[1], d = arguments[2], this.addRelativeData(d), this._autoLoadSpriteFile = !1, ccs.dataReaderHelper.addDataFromFile(d), this.addSpriteFrameFromFile(c, a)
  37445. }
  37446. },
  37447. addArmatureFileInfoAsync: function() {
  37448. var a, c, d, e, f;
  37449. switch (arguments.length) {
  37450. case 3:
  37451. d = arguments[0];
  37452. e = arguments[2];
  37453. f = arguments[1];
  37454. this.addRelativeData(d);
  37455. this._autoLoadSpriteFile = !0;
  37456. ccs.dataReaderHelper.addDataFromFileAsync("", "", d, f, e);
  37457. break;
  37458. case 5:
  37459. 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)
  37460. }
  37461. },
  37462. addSpriteFrameFromFile: function(a, c, d) {
  37463. (d = this.getRelativeData(d)) && d.plistFiles.push(a);
  37464. ccs.spriteFrameCacheHelper.addSpriteFrameFromFile(a, c)
  37465. },
  37466. isAutoLoadSpriteFile: function() {
  37467. return this._autoLoadSpriteFile
  37468. },
  37469. getArmatureDatas: function() {
  37470. return this._armarureDatas
  37471. },
  37472. getAnimationDatas: function() {
  37473. return this._animationDatas
  37474. },
  37475. getTextureDatas: function() {
  37476. return this._textureDatas
  37477. },
  37478. addRelativeData: function(a) {
  37479. this._relativeDatas[a] || (this._relativeDatas[a] = new ccs.RelativeData)
  37480. },
  37481. getRelativeData: function(a) {
  37482. return this._relativeDatas[a]
  37483. },
  37484. clear: function() {
  37485. this._animationDatas = {};
  37486. this._armarureDatas = {};
  37487. this._textureDatas = {};
  37488. ccs.spriteFrameCacheHelper.clear();
  37489. ccs.dataReaderHelper.clear()
  37490. }
  37491. };
  37492. ccs.BLEND_TYPE_NORMAL = 0;
  37493. ccs.BLEND_TYPE_LAYER = 1;
  37494. ccs.BLEND_TYPE_DARKEN = 2;
  37495. ccs.BLEND_TYPE_MULTIPLY = 3;
  37496. ccs.BLEND_TYPE_LIGHTEN = 4;
  37497. ccs.BLEND_TYPE_SCREEN = 5;
  37498. ccs.BLEND_TYPE_OVERLAY = 6;
  37499. ccs.BLEND_TYPE_HIGHLIGHT = 7;
  37500. ccs.BLEND_TYPE_ADD = 8;
  37501. ccs.BLEND_TYPE_SUBTRACT = 9;
  37502. ccs.BLEND_TYPE_DIFFERENCE = 10;
  37503. ccs.BLEND_TYPE_INVERT = 11;
  37504. ccs.BLEND_TYPE_ALPHA = 12;
  37505. ccs.BLEND_TYPE_ERASE = 13;
  37506. ccs.DISPLAY_TYPE_SPRITE = 0;
  37507. ccs.DISPLAY_TYPE_ARMATURE = 1;
  37508. ccs.DISPLAY_TYPE_PARTICLE = 2;
  37509. ccs.DISPLAY_TYPE_MAX = 3;
  37510. ccs.BaseData = ccs.Class.extend({
  37511. x: 0,
  37512. y: 0,
  37513. zOrder: 0,
  37514. skewX: 0,
  37515. skewY: 0,
  37516. scaleX: 1,
  37517. scaleY: 1,
  37518. tweenRotate: 0,
  37519. isUseColorInfo: !1,
  37520. r: 255,
  37521. g: 255,
  37522. b: 255,
  37523. a: 255,
  37524. ctor: function() {
  37525. this.skewY = this.skewX = this.zOrder = this.y = this.x = 0;
  37526. this.scaleY = this.scaleX = 1;
  37527. this.tweenRotate = 0;
  37528. this.isUseColorInfo = !1;
  37529. this.a = this.b = this.g = this.r = 255
  37530. },
  37531. copy: function(a) {
  37532. this.x = a.x;
  37533. this.y = a.y;
  37534. this.zOrder = a.zOrder;
  37535. this.scaleX = a.scaleX;
  37536. this.scaleY = a.scaleY;
  37537. this.skewX = a.skewX;
  37538. this.skewY = a.skewY;
  37539. this.tweenRotate = a.tweenRotate;
  37540. this.isUseColorInfo = a.isUseColorInfo;
  37541. this.r = a.r;
  37542. this.g = a.g;
  37543. this.b = a.b;
  37544. this.a = a.a
  37545. },
  37546. setColor: function(a) {
  37547. this.r = a.r;
  37548. this.g = a.g;
  37549. this.b = a.b;
  37550. this.a = a.a
  37551. },
  37552. getColor: function() {
  37553. return cc.color(this.r, this.g, this.b, this.a)
  37554. },
  37555. subtract: function(a, c, d) {
  37556. this.x = c.x - a.x;
  37557. this.y = c.y - a.y;
  37558. this.scaleX = c.scaleX - a.scaleX;
  37559. this.scaleY = c.scaleY - a.scaleY;
  37560. this.skewX = c.skewX - a.skewX;
  37561. this.skewY = c.skewY - a.skewY;
  37562. 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);
  37563. 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));
  37564. c.tweenRotate && (this.skewX += 2 * c.tweenRotate * ccs.PI, this.skewY -= 2 * c.tweenRotate * ccs.PI)
  37565. }
  37566. });
  37567. ccs.DisplayData = ccs.Class.extend({
  37568. displayType: ccs.DISPLAY_TYPE_MAX,
  37569. displayName: "",
  37570. ctor: function() {
  37571. this.displayType = ccs.DISPLAY_TYPE_MAX
  37572. },
  37573. changeDisplayToTexture: function(a) {
  37574. var c = a.lastIndexOf("."); - 1 != c && (a = a.substring(0, c));
  37575. return a
  37576. },
  37577. copy: function(a) {
  37578. this.displayName = a.displayName;
  37579. this.displayType = a.displayType
  37580. }
  37581. });
  37582. ccs.SpriteDisplayData = ccs.DisplayData.extend({
  37583. skinData: null,
  37584. ctor: function() {
  37585. this.skinData = new ccs.BaseData;
  37586. this.displayType = ccs.DISPLAY_TYPE_SPRITE
  37587. },
  37588. copy: function(a) {
  37589. ccs.DisplayData.prototype.copy.call(this, a);
  37590. this.skinData = a.skinData
  37591. },
  37592. SpriteDisplayData: function() {
  37593. this.displayType = ccs.DISPLAY_TYPE_SPRITE
  37594. }
  37595. });
  37596. ccs.ArmatureDisplayData = ccs.DisplayData.extend({
  37597. displayName: "",
  37598. ctor: function() {
  37599. this.displayName = "";
  37600. this.displayType = ccs.DISPLAY_TYPE_ARMATURE
  37601. }
  37602. });
  37603. ccs.ParticleDisplayData = ccs.DisplayData.extend({
  37604. ctor: function() {
  37605. this.displayType = ccs.DISPLAY_TYPE_PARTICLE
  37606. }
  37607. });
  37608. ccs.BoneData = ccs.BaseData.extend({
  37609. displayDataList: null,
  37610. name: "",
  37611. parentName: "",
  37612. boneDataTransform: null,
  37613. ctor: function() {
  37614. this.displayDataList = [];
  37615. this.parentName = this.name = "";
  37616. this.boneDataTransform = null
  37617. },
  37618. init: function() {
  37619. this.displayDataList.length = 0;
  37620. return !0
  37621. },
  37622. addDisplayData: function(a) {
  37623. this.displayDataList.push(a)
  37624. },
  37625. getDisplayData: function(a) {
  37626. return this.displayDataList[a]
  37627. }
  37628. });
  37629. ccs.ArmatureData = ccs.Class.extend({
  37630. boneDataDic: null,
  37631. name: "",
  37632. dataVersion: 0.1,
  37633. ctor: function() {
  37634. this.boneDataDic = {};
  37635. this.name = "";
  37636. this.dataVersion = 0.1
  37637. },
  37638. init: function() {
  37639. return !0
  37640. },
  37641. addBoneData: function(a) {
  37642. this.boneDataDic[a.name] = a
  37643. },
  37644. getBoneDataDic: function() {
  37645. return this.boneDataDic
  37646. },
  37647. getBoneData: function(a) {
  37648. return this.boneDataDic[a]
  37649. }
  37650. });
  37651. ccs.FrameData = ccs.BaseData.extend({
  37652. duration: 0,
  37653. tweenEasing: 0,
  37654. easingParamNumber: 0,
  37655. easingParams: null,
  37656. displayIndex: -1,
  37657. movement: "",
  37658. event: "",
  37659. sound: "",
  37660. soundEffect: "",
  37661. blendFunc: 0,
  37662. frameID: 0,
  37663. isTween: !0,
  37664. ctor: function() {
  37665. ccs.BaseData.prototype.ctor.call(this);
  37666. this.duration = 1;
  37667. this.tweenEasing = ccs.TweenType.linear;
  37668. this.easingParamNumber = 0;
  37669. this.easingParams = [];
  37670. this.displayIndex = 0;
  37671. this.soundEffect = this.sound = this.event = this.movement = "";
  37672. this.blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  37673. this.frameID = 0;
  37674. this.isTween = !0
  37675. },
  37676. copy: function(a) {
  37677. ccs.BaseData.prototype.copy.call(this, a);
  37678. this.duration = a.duration;
  37679. this.displayIndex = a.displayIndex;
  37680. this.tweenEasing = a.tweenEasing;
  37681. this.easingParamNumber = a.easingParamNumber;
  37682. if (0 != this.easingParamNumber)
  37683. for (var c = 0; c < this.easingParamNumber; c++) this.easingParams[c] = a.easingParams[c];
  37684. this.blendFunc = a.blendFunc;
  37685. this.isTween = a.isTween
  37686. }
  37687. });
  37688. ccs.MovementBoneData = ccs.Class.extend({
  37689. delay: 0,
  37690. scale: 1,
  37691. duration: 0,
  37692. frameList: null,
  37693. name: "",
  37694. ctor: function() {
  37695. this.delay = 0;
  37696. this.scale = 1;
  37697. this.duration = 0;
  37698. this.frameList = [];
  37699. this.name = ""
  37700. },
  37701. init: function() {
  37702. return !0
  37703. },
  37704. addFrameData: function(a) {
  37705. this.frameList.push(a)
  37706. },
  37707. getFrameData: function(a) {
  37708. return this.frameList[a]
  37709. }
  37710. });
  37711. ccs.MovementData = function() {
  37712. this.name = "";
  37713. this.duration = 0;
  37714. this.scale = 1;
  37715. this.durationTween = this.durationTo = 0;
  37716. this.loop = !0;
  37717. this.tweenEasing = ccs.TweenType.linear;
  37718. this.movBoneDataDic = {}
  37719. };
  37720. ccs.MovementData.prototype.addMovementBoneData = function(a) {
  37721. this.movBoneDataDic[a.name] = a
  37722. };
  37723. ccs.MovementData.prototype.getMovementBoneData = function(a) {
  37724. return this.movBoneDataDic[a]
  37725. };
  37726. ccs.AnimationData = function() {
  37727. this.movementDataDic = {};
  37728. this.movementNames = [];
  37729. this.name = ""
  37730. };
  37731. ccs.AnimationData.prototype.addMovement = function(a) {
  37732. this.movementDataDic[a.name] = a;
  37733. this.movementNames.push(a.name)
  37734. };
  37735. ccs.AnimationData.prototype.getMovement = function(a) {
  37736. return this.movementDataDic[a]
  37737. };
  37738. ccs.AnimationData.prototype.getMovementCount = function() {
  37739. return Object.keys(this.movementDataDic).length
  37740. };
  37741. ccs.ContourVertex2 = function(a, c) {
  37742. this.x = a || 0;
  37743. this.y = c || 0
  37744. };
  37745. ccs.ContourData = function() {
  37746. this.vertexList = []
  37747. };
  37748. ccs.ContourData.prototype.init = function() {
  37749. this.vertexList.length = 0;
  37750. return !0
  37751. };
  37752. ccs.ContourData.prototype.addVertex = function(a) {
  37753. this.vertexList.push(a)
  37754. };
  37755. ccs.TextureData = function() {
  37756. this.width = this.height = 0;
  37757. this.pivotY = this.pivotX = 0.5;
  37758. this.name = "";
  37759. this.contourDataList = []
  37760. };
  37761. ccs.TextureData.prototype.init = function() {
  37762. this.contourDataList.length = 0
  37763. };
  37764. ccs.TextureData.prototype.addContourData = function(a) {
  37765. this.contourDataList.push(a)
  37766. };
  37767. ccs.TextureData.prototype.getContourData = function(a) {
  37768. return this.contourDataList[a]
  37769. };
  37770. ccs.DecorativeDisplay = ccs.Class.extend({
  37771. _display: null,
  37772. _colliderDetector: null,
  37773. _displayData: null,
  37774. ctor: function() {
  37775. this._displayData = this._colliderDetector = this._display = null
  37776. },
  37777. init: function() {
  37778. return !0
  37779. },
  37780. setDisplay: function(a) {
  37781. this._display = a
  37782. },
  37783. getDisplay: function() {
  37784. return this._display
  37785. },
  37786. setColliderDetector: function(a) {
  37787. this._colliderDetector = a
  37788. },
  37789. getColliderDetector: function() {
  37790. return this._colliderDetector
  37791. },
  37792. setDisplayData: function(a) {
  37793. this._displayData = a
  37794. },
  37795. getDisplayData: function() {
  37796. return this._displayData
  37797. },
  37798. release: function() {
  37799. this._colliderDetector = this._displayData = this._display = null
  37800. }
  37801. });
  37802. ccs.DecorativeDisplay.create = function() {
  37803. var a = new ccs.DecorativeDisplay;
  37804. return a && a.init() ? a : null
  37805. };
  37806. ccs.displayFactory = {
  37807. addDisplay: function(a, c, d) {
  37808. switch (d.displayType) {
  37809. case ccs.DISPLAY_TYPE_SPRITE:
  37810. this.addSpriteDisplay(a, c, d);
  37811. break;
  37812. case ccs.DISPLAY_TYPE_PARTICLE:
  37813. this.addParticleDisplay(a, c, d);
  37814. break;
  37815. case ccs.DISPLAY_TYPE_ARMATURE:
  37816. this.addArmatureDisplay(a, c, d)
  37817. }
  37818. },
  37819. createDisplay: function(a, c) {
  37820. switch (c.getDisplayData().displayType) {
  37821. case ccs.DISPLAY_TYPE_SPRITE:
  37822. this.createSpriteDisplay(a, c);
  37823. break;
  37824. case ccs.DISPLAY_TYPE_PARTICLE:
  37825. this.createParticleDisplay(a, c);
  37826. break;
  37827. case ccs.DISPLAY_TYPE_ARMATURE:
  37828. this.createArmatureDisplay(a, c)
  37829. }
  37830. },
  37831. _helpTransform: {
  37832. a: 1,
  37833. b: 0,
  37834. c: 0,
  37835. d: 1,
  37836. tx: 0,
  37837. ty: 0
  37838. },
  37839. updateDisplay: function(a, c, d) {
  37840. var e = a.getDisplayRenderNode();
  37841. if (e) {
  37842. switch (a.getDisplayRenderNodeType()) {
  37843. case ccs.DISPLAY_TYPE_SPRITE:
  37844. d && e.updateArmatureTransform();
  37845. break;
  37846. case ccs.DISPLAY_TYPE_PARTICLE:
  37847. this.updateParticleDisplay(a, e, c);
  37848. break;
  37849. case ccs.DISPLAY_TYPE_ARMATURE:
  37850. this.updateArmatureDisplay(a, e, c);
  37851. break;
  37852. default:
  37853. c = a.getNodeToArmatureTransform(), e.setAdditionalTransform(c)
  37854. }
  37855. if ((ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && d)
  37856. if (e = a.getDisplayManager().getCurrentDecorativeDisplay(), d = e.getColliderDetector()) {
  37857. c = e.getDisplay();
  37858. var f = c.nodeToParentTransform(),
  37859. e = this._helpTransform;
  37860. e.a = f.a;
  37861. e.b = f.b;
  37862. e.c = f.c;
  37863. e.d = f.d;
  37864. e.tx = f.tx;
  37865. e.ty = f.ty;
  37866. c = cc.pointApplyAffineTransform(c.getAnchorPointInPoints(), e);
  37867. e.tx = c.x;
  37868. e.ty = c.y;
  37869. a = cc.affineTransformConcat(e, a.getArmature().nodeToParentTransform());
  37870. d.updateTransform(a)
  37871. }
  37872. }
  37873. },
  37874. addSpriteDisplay: function(a, c, d) {
  37875. var e = new ccs.SpriteDisplayData;
  37876. e.copy(d);
  37877. c.setDisplayData(e);
  37878. this.createSpriteDisplay(a, c)
  37879. },
  37880. createSpriteDisplay: function(a, c) {
  37881. var d = null,
  37882. e = c.getDisplayData(),
  37883. d = e.displayName,
  37884. f = d.lastIndexOf("."); - 1 != f && (d = d.substring(0, f));
  37885. d = "" == d ? ccs.Skin.create() : ccs.Skin.createWithSpriteFrameName(d + ".png");
  37886. c.setDisplay(d);
  37887. 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)))
  37888. },
  37889. initSpriteDisplay: function(a, c, d, e) {
  37890. var f = d.lastIndexOf("."); - 1 != f && (d = d.substring(0, f));
  37891. (d = ccs.armatureDataManager.getTextureData(d)) && e.setAnchorPoint(cc.p(d.pivotX, d.pivotY));
  37892. 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)
  37893. },
  37894. addArmatureDisplay: function(a, c, d) {
  37895. var e = new ccs.ArmatureDisplayData;
  37896. e.copy(d);
  37897. c.setDisplayData(e);
  37898. this.createArmatureDisplay(a, c)
  37899. },
  37900. createArmatureDisplay: function(a, c) {
  37901. var d = c.getDisplayData(),
  37902. d = ccs.Armature.create(d.displayName, a);
  37903. c.setDisplay(d)
  37904. },
  37905. updateArmatureDisplay: function(a, c, d) {
  37906. c && (c.sortAllChildren(), c.update(d))
  37907. },
  37908. addParticleDisplay: function(a, c, d) {
  37909. var e = new ccs.ParticleDisplayData;
  37910. e.copy(d);
  37911. c.setDisplayData(e);
  37912. this.createParticleDisplay(a, c)
  37913. },
  37914. createParticleDisplay: function(a, c) {
  37915. var d = c.getDisplayData(),
  37916. d = cc.ParticleSystem.create(d.displayName);
  37917. d.removeFromParent();
  37918. d.cleanup();
  37919. a.getArmature() && d.setParent(a.getArmature());
  37920. c.setDisplay(d)
  37921. },
  37922. updateParticleDisplay: function(a, c, d) {
  37923. var e = new ccs.BaseData;
  37924. ccs.TransformHelp.matrixToNode(a.nodeToArmatureTransform(), e);
  37925. c.setPosition(e.x, e.y);
  37926. c.setScaleX(e.scaleX);
  37927. c.setScaleY(e.scaleY);
  37928. c.update(d)
  37929. }
  37930. };
  37931. ccs.DisplayManager = ccs.Class.extend({
  37932. _decoDisplayList: null,
  37933. _currentDecoDisplay: null,
  37934. _displayRenderNode: null,
  37935. _displayIndex: null,
  37936. _forceChangeDisplay: !1,
  37937. _bone: null,
  37938. _visible: !0,
  37939. _displayType: null,
  37940. ctor: function() {
  37941. this._decoDisplayList = [];
  37942. this._displayIndex = this._displayRenderNode = this._currentDecoDisplay = null;
  37943. this._forceChangeDisplay = !1;
  37944. this._bone = null;
  37945. this._visible = !0;
  37946. this._displayType = ccs.DISPLAY_TYPE_MAX
  37947. },
  37948. init: function(a) {
  37949. this._bone = a;
  37950. this.initDisplayList(a.getBoneData());
  37951. return !0
  37952. },
  37953. addDisplay: function(a, c) {
  37954. var d, e = this._decoDisplayList;
  37955. 0 <= c && c < e.length ? d = e[c] : (d = ccs.DecorativeDisplay.create(), e.push(d));
  37956. if (a instanceof ccs.DisplayData) cc.displayFactory.addDisplay(this._bone, d, a);
  37957. else {
  37958. var f = null;
  37959. if (a instanceof ccs.Skin) {
  37960. a.setBone(this._bone);
  37961. f = new ccs.SpriteDisplayData;
  37962. ccs.displayFactory.initSpriteDisplay(this._bone, d, a.getDisplayName(), a);
  37963. var g = d.getDisplayData();
  37964. if (g instanceof ccs.SpriteDisplayData) a.setSkinData(g.skinData), f.skinData = g.skinData;
  37965. else {
  37966. for (var g = !1, h = e.length - 2; 0 <= h; h--) {
  37967. var k = e[h].getDisplayData();
  37968. if (k instanceof ccs.SpriteDisplayData) {
  37969. g = !0;
  37970. a.setSkinData(k.skinData);
  37971. f.skinData = k.skinData;
  37972. break
  37973. }
  37974. }
  37975. g || a.setSkinData(new ccs.BaseData)
  37976. }
  37977. } 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;
  37978. d.setDisplay(a);
  37979. d.setDisplayData(f)
  37980. }
  37981. c == this._displayIndex && (this._displayIndex = -1, this.changeDisplayWithIndex(c, !1))
  37982. },
  37983. _addDisplayOther: function(a, c) {
  37984. var d = null;
  37985. if (c instanceof ccs.Skin) {
  37986. c.setBone(this._bone);
  37987. d = new ccs.SpriteDisplayData;
  37988. d.displayName = c.getDisplayName();
  37989. ccs.displayFactory.initSpriteDisplay(this._bone, a, c.getDisplayName(), c);
  37990. var e = a.getDisplayData();
  37991. if (e instanceof ccs.SpriteDisplayData) c.setSkinData(e.skinData);
  37992. else {
  37993. for (var e = !1, f = this._decoDisplayList.length - 2; 0 <= f; f--) {
  37994. var g = this._decoDisplayList[f].getDisplayData();
  37995. if (g) {
  37996. e = !0;
  37997. c.setSkinData(g.skinData);
  37998. d.skinData = g.skinData;
  37999. break
  38000. }
  38001. }
  38002. e || c.setSkinData(new ccs.BaseData);
  38003. c.setSkinData(new ccs.BaseData)
  38004. }
  38005. } 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;
  38006. a.setDisplay(c);
  38007. a.setDisplayData(d)
  38008. },
  38009. removeDisplay: function(a) {
  38010. this._decoDisplayList.splice(a, 1);
  38011. a === this._displayIndex && (this.setCurrentDecorativeDisplay(null), this._displayIndex = -1)
  38012. },
  38013. getDecorativeDisplayList: function() {
  38014. return this._decoDisplayList
  38015. },
  38016. changeDisplayWithIndex: function(a, c) {
  38017. 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])))
  38018. },
  38019. changeDisplayWithName: function(a, c) {
  38020. for (var d = this._decoDisplayList, e = 0; e < d.length; e++)
  38021. if (d[e].getDisplayData().displayName == a) {
  38022. this.changeDisplayWithIndex(e, c);
  38023. break
  38024. }
  38025. },
  38026. setCurrentDecorativeDisplay: function(a) {
  38027. var c = this._currentDecoDisplay;
  38028. (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && c && c.getColliderDetector() && c.getColliderDetector().setActive(!1);
  38029. c = this._currentDecoDisplay = a;
  38030. (ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT || ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) && c && c.getColliderDetector() && c.getColliderDetector().setActive(!0);
  38031. a = !c ? null : c.getDisplay();
  38032. var c = this._displayRenderNode,
  38033. d = this._bone;
  38034. c && (c instanceof ccs.Armature && d.setChildArmature(null), c.removeFromParent(!0));
  38035. (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
  38036. },
  38037. getDisplayRenderNode: function() {
  38038. return this._displayRenderNode
  38039. },
  38040. getDisplayRenderNodeType: function() {
  38041. return this._displayType
  38042. },
  38043. getCurrentDisplayIndex: function() {
  38044. return this._displayIndex
  38045. },
  38046. getCurrentDecorativeDisplay: function() {
  38047. return this._currentDecoDisplay
  38048. },
  38049. getDecorativeDisplayByIndex: function(a) {
  38050. return this._decoDisplayList[a]
  38051. },
  38052. initDisplayList: function(a) {
  38053. this._decoDisplayList.length = 0;
  38054. if (a) {
  38055. a = a.displayDataList;
  38056. for (var c = this._decoDisplayList, d = this._bone, e = 0; e < a.length; e++) {
  38057. var f = a[e],
  38058. g = ccs.DecorativeDisplay.create();
  38059. g.setDisplayData(f);
  38060. ccs.displayFactory.createDisplay(d, g);
  38061. c.push(g)
  38062. }
  38063. }
  38064. },
  38065. containPoint: function(a, c) {
  38066. if (!this._visible || 0 > this._displayIndex) return !1;
  38067. void 0 !== c && (a = cc.p(a, c));
  38068. if (this._currentDecoDisplay.getDisplayData().displayType == ccs.DISPLAY_TYPE_SPRITE) {
  38069. var d = this._currentDecoDisplay.getDisplay(),
  38070. d = d.getChildByTag(0);
  38071. return ccs.SPRITE_CONTAIN_POINT_WITH_RETURN(d, a)
  38072. }
  38073. return !1
  38074. },
  38075. setVisible: function(a) {
  38076. this._displayRenderNode && (this._visible = a, this._displayRenderNode.setVisible(a))
  38077. },
  38078. isVisible: function() {
  38079. return this._visible
  38080. },
  38081. getContentSize: function() {
  38082. return !this._displayRenderNode ? cc.size(0, 0) : this._displayRenderNode.getContentSize()
  38083. },
  38084. getBoundingBox: function() {
  38085. return !this._displayRenderNode ? cc.rect(0, 0, 0, 0) : this._displayRenderNode.getBoundingBox()
  38086. },
  38087. getAnchorPoint: function() {
  38088. return !this._displayRenderNode ? cc.p(0, 0) : this._displayRenderNode.getAnchorPoint()
  38089. },
  38090. getAnchorPointInPoints: function() {
  38091. return !this._displayRenderNode ? cc.p(0, 0) : this._displayRenderNode.getAnchorPointInPoints()
  38092. },
  38093. getForceChangeDisplay: function() {
  38094. return this._forceChangeDisplay
  38095. },
  38096. release: function() {
  38097. this._decoDisplayList = null;
  38098. this._displayRenderNode && (this._displayRenderNode.removeFromParent(!0), this._displayRenderNode = null)
  38099. }
  38100. });
  38101. ccs.DisplayManager.create = function(a) {
  38102. var c = new ccs.DisplayManager;
  38103. return c && c.init(a) ? c : null
  38104. };
  38105. ccs.Skin = ccs.Sprite.extend({
  38106. _skinData: null,
  38107. bone: null,
  38108. _skinTransform: null,
  38109. _displayName: "",
  38110. _armature: null,
  38111. _className: "Skin",
  38112. ctor: function() {
  38113. cc.Sprite.prototype.ctor.call(this);
  38114. this.bone = this._skinData = null;
  38115. this._displayName = "";
  38116. this._skinTransform = cc.affineTransformIdentity();
  38117. this._armature = null
  38118. },
  38119. initWithSpriteFrameName: function(a) {
  38120. if ("" == a) return !1;
  38121. var c = cc.spriteFrameCache.getSpriteFrame(a),
  38122. d = !0;
  38123. c ? this.initWithSpriteFrame(c) : (cc.log("Can't find CCSpriteFrame with %s. Please check your .plist file", a), d = !1);
  38124. this._displayName = a;
  38125. return d
  38126. },
  38127. initWithFile: function(a) {
  38128. var c = cc.Sprite.prototype.initWithFile.call(this, a);
  38129. this._displayName = a;
  38130. return c
  38131. },
  38132. setSkinData: function(a) {
  38133. this._skinData = a;
  38134. this.setScaleX(a.scaleX);
  38135. this.setScaleY(a.scaleY);
  38136. this.setRotationX(cc.radiansToDegrees(a.skewX));
  38137. this.setRotationY(cc.radiansToDegrees(-a.skewY));
  38138. this.setPosition(a.x, a.y);
  38139. a = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform();
  38140. var c = this._skinTransform;
  38141. c.a = a.a;
  38142. c.b = a.b;
  38143. c.c = a.c;
  38144. c.d = a.d;
  38145. c.tx = a.tx;
  38146. c.ty = a.ty;
  38147. this.updateArmatureTransform()
  38148. },
  38149. getSkinData: function() {
  38150. return this._skinData
  38151. },
  38152. updateArmatureTransform: function() {
  38153. this._transform = cc.affineTransformConcat(this._skinTransform, this.bone.getNodeToArmatureTransform())
  38154. },
  38155. _updateTransformForWebGL: function() {
  38156. var a = this._quad;
  38157. if (this._visible) {
  38158. var c = this.getNodeToParentTransform ? this.getNodeToParentTransform() : this.nodeToParentTransform(),
  38159. d = this._rect,
  38160. e = this._offsetPosition.x,
  38161. f = this._offsetPosition.y,
  38162. g = e + d.width,
  38163. h = f + d.height,
  38164. k = c.tx,
  38165. m = c.ty,
  38166. n = c.a,
  38167. q = c.b,
  38168. r = c.d,
  38169. t = -c.c,
  38170. c = e * n - f * t + k,
  38171. d = e * q + f * r + m,
  38172. s = g * n - f * t + k,
  38173. f = g * q + f * r + m,
  38174. v = g * n - h * t + k,
  38175. g = g * q + h * r + m,
  38176. k = e * n - h * t + k,
  38177. e = e * q + h * r + m,
  38178. h = this._vertexZ;
  38179. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (c |= 0, d |= 0, s |= 0, f |= 0, v |= 0, g |= 0, k |= 0, e |= 0);
  38180. this.SET_VERTEX3F(a.bl.vertices, c, d, h);
  38181. this.SET_VERTEX3F(a.br.vertices, s, f, h);
  38182. this.SET_VERTEX3F(a.tl.vertices, k, e, h);
  38183. this.SET_VERTEX3F(a.tr.vertices, v, g, h)
  38184. } else a.br.vertices = a.tl.vertices = a.tr.vertices = a.bl.vertices = {
  38185. x: 0,
  38186. y: 0,
  38187. z: 0
  38188. };
  38189. this._textureAtlas && this._textureAtlas.updateQuad(a, this._textureAtlas.getTotalQuads());
  38190. this._quadDirty = !0
  38191. },
  38192. SET_VERTEX3F: function(a, c, d, e) {
  38193. a.x = c;
  38194. a.y = d;
  38195. a.z = e
  38196. },
  38197. RENDER_IN_SUBPIXEL: function(a) {
  38198. return cc.SPRITEBATCHNODE_RENDER_SUBPIXEL ? a : Math.ceil(a)
  38199. },
  38200. getNodeToWorldTransform: function() {
  38201. return cc.affineTransformConcat(this._transform, this.bone.getArmature().getNodeToWorldTransform())
  38202. },
  38203. getNodeToWorldTransformAR: function() {
  38204. var a = this._transform;
  38205. this._anchorPointInPoints = cc.pointApplyAffineTransform(this._anchorPointInPoints, a);
  38206. a.tx = this._anchorPointInPoints.x;
  38207. a.ty = this._anchorPointInPoints.y;
  38208. return cc.affineTransformConcat(a, this.bone.getArmature().nodeToWorldTransform())
  38209. },
  38210. setBone: function(a) {
  38211. this.bone = a;
  38212. if (a = this.bone.getArmature()) this._armature = a
  38213. },
  38214. getBone: function() {
  38215. return this.bone
  38216. },
  38217. getDisplayName: function() {
  38218. return this._displayName
  38219. }
  38220. });
  38221. cc._renderType == cc._RENDER_TYPE_WEBGL && (ccs.Skin.prototype.updateTransform = ccs.Skin.prototype._updateTransformForWebGL);
  38222. _p = ccs.Skin.prototype;
  38223. cc.defineGetterSetter(_p, "skinData", _p.getSkinData, _p.setSkinData);
  38224. cc.defineGetterSetter(_p, "displayName", _p.getDisplayName);
  38225. _p = null;
  38226. ccs.Skin.create = function(a, c) {
  38227. var d = arguments.length,
  38228. e = new ccs.Skin;
  38229. if (0 === d || null == a || "" == a) {
  38230. if (e.init()) return e
  38231. } else if ("#" == a[0]) {
  38232. if (e && e.initWithSpriteFrameName(a)) return e
  38233. } else if (e && e.initWithFile(a, c)) return e;
  38234. return null
  38235. };
  38236. ccs.Skin.createWithSpriteFrameName = function(a) {
  38237. var c = new ccs.Skin;
  38238. return c && c.initWithSpriteFrameName(a) ? c : null
  38239. };
  38240. ccs.ANIMATION_TYPE_SINGLE_FRAME = -4;
  38241. ccs.ANIMATION_TYPE_NO_LOOP = -3;
  38242. ccs.ANIMATION_TYPE_TO_LOOP_FRONT = -2;
  38243. ccs.ANIMATION_TYPE_TO_LOOP_BACK = -1;
  38244. ccs.ANIMATION_TYPE_LOOP_FRONT = 0;
  38245. ccs.ANIMATION_TYPE_LOOP_BACK = 1;
  38246. ccs.ANIMATION_TYPE_MAX = 2;
  38247. ccs.ProcessBase = ccs.Class.extend({
  38248. _processScale: 1,
  38249. _isComplete: !0,
  38250. _isPause: !0,
  38251. _isPlaying: !1,
  38252. _currentPercent: 0,
  38253. _rawDuration: 0,
  38254. _loopType: 0,
  38255. _tweenEasing: 0,
  38256. animationInternal: null,
  38257. _currentFrame: 0,
  38258. _durationTween: 0,
  38259. _nextFrameIndex: 0,
  38260. _curFrameIndex: null,
  38261. _isLoopBack: !1,
  38262. ctor: function() {
  38263. this._processScale = 1;
  38264. this._isPause = this._isComplete = !0;
  38265. this._isPlaying = !1;
  38266. this._rawDuration = this._durationTween = this._currentPercent = this._currentFrame = 0;
  38267. this._loopType = ccs.ANIMATION_TYPE_LOOP_BACK;
  38268. this._tweenEasing = ccs.TweenType.linear;
  38269. this.animationInternal = 1 / 60;
  38270. this._durationTween = this._curFrameIndex = 0;
  38271. this._isLoopBack = !1
  38272. },
  38273. pause: function() {
  38274. this._isPause = !0;
  38275. this._isPlaying = !1
  38276. },
  38277. resume: function() {
  38278. this._isPause = !1;
  38279. this._isPlaying = !0
  38280. },
  38281. stop: function() {
  38282. this._isComplete = !0;
  38283. this._isPlaying = !1
  38284. },
  38285. play: function(a, c, d, e) {
  38286. this._isPause = this._isComplete = !1;
  38287. this._isPlaying = !0;
  38288. this._currentFrame = 0;
  38289. this._nextFrameIndex = a;
  38290. this._tweenEasing = e
  38291. },
  38292. update: function(a) {
  38293. if (!this._isComplete && !this._isPause && !(0 >= this._rawDuration || 1 < a)) {
  38294. var c = void 0 === this._nextFrameIndex ? 0 : this._nextFrameIndex,
  38295. d = this._currentFrame;
  38296. 0 >= c ? (this._currentPercent = 1, d = 0) : (d += this._processScale * (a / this.animationInternal), this._currentPercent = d / c, d = ccs.fmodf(d, c));
  38297. this._currentFrame = d;
  38298. this.updateHandler()
  38299. }
  38300. },
  38301. gotoFrame: function(a) {
  38302. var c = this._loopType;
  38303. c == ccs.ANIMATION_TYPE_NO_LOOP ? c = ccs.ANIMATION_TYPE_MAX : c == ccs.ANIMATION_TYPE_TO_LOOP_FRONT && (c = ccs.ANIMATION_TYPE_LOOP_FRONT);
  38304. this._loopType = c;
  38305. this._curFrameIndex = a;
  38306. this._nextFrameIndex = this._durationTween
  38307. },
  38308. getCurrentFrameIndex: function() {
  38309. return this._curFrameIndex = (this._rawDuration - 1) * this._currentPercent
  38310. },
  38311. updateHandler: function() {},
  38312. isPause: function() {
  38313. return this._isPause
  38314. },
  38315. isComplete: function() {
  38316. return this._isComplete
  38317. },
  38318. getCurrentPercent: function() {
  38319. return this._currentPercent
  38320. },
  38321. getRawDuration: function() {
  38322. return this._rawDuration
  38323. },
  38324. getLoop: function() {
  38325. return this._loopType
  38326. },
  38327. getTweenEasing: function() {
  38328. return this._tweenEasing
  38329. },
  38330. getAnimationInternal: function() {
  38331. return this.animationInternal
  38332. },
  38333. setAnimationInternal: function(a) {
  38334. this.animationInternal = a
  38335. },
  38336. getProcessScale: function() {
  38337. return this._processScale
  38338. },
  38339. setProcessScale: function(a) {
  38340. this._processScale = a
  38341. },
  38342. isPlaying: function() {
  38343. return this._isPlaying
  38344. }
  38345. });
  38346. _p = ccs.ProcessBase.prototype;
  38347. cc.defineGetterSetter(_p, "currentFrameIndex", _p.getCurrentFrameIndex);
  38348. cc.defineGetterSetter(_p, "paused", _p.isPause);
  38349. cc.defineGetterSetter(_p, "completed", _p.isComplete);
  38350. cc.defineGetterSetter(_p, "currentPercent", _p.getCurrentPercent);
  38351. cc.defineGetterSetter(_p, "rawDuration", _p.getRawDuration);
  38352. cc.defineGetterSetter(_p, "loop", _p.getLoop);
  38353. cc.defineGetterSetter(_p, "tweenEasing", _p.getTweenEasing);
  38354. cc.defineGetterSetter(_p, "playing", _p.isPlaying);
  38355. _p = null;
  38356. ccs.MovementEventType = {
  38357. start: 0,
  38358. complete: 1,
  38359. loopComplete: 2
  38360. };
  38361. ccs.AnimationEvent = ccs.Class.extend({
  38362. _arguments: null,
  38363. _callFunc: null,
  38364. _selectorTarget: null,
  38365. ctor: function(a, c, d) {
  38366. this._data = d;
  38367. this._callFunc = a;
  38368. this._selectorTarget = c
  38369. },
  38370. call: function() {
  38371. this._callFunc && this._callFunc.apply(this._selectorTarget, this._arguments)
  38372. },
  38373. setArguments: function(a) {
  38374. this._arguments = a
  38375. }
  38376. });
  38377. ccs.MovementEvent = function() {
  38378. this.armature = null;
  38379. this.movementID = this.movementType = ""
  38380. };
  38381. ccs.FrameEvent = function() {
  38382. this.bone = null;
  38383. this.frameEventName = "";
  38384. this.currentFrameIndex = this.originFrameIndex = 0
  38385. };
  38386. ccs.ArmatureAnimation = ccs.ProcessBase.extend({
  38387. _animationData: null,
  38388. _movementData: null,
  38389. _armature: null,
  38390. _movementID: "",
  38391. _toIndex: 0,
  38392. _tweenList: null,
  38393. _speedScale: 1,
  38394. _ignoreFrameEvent: !1,
  38395. _frameEventQueue: null,
  38396. _movementEventQueue: null,
  38397. _movementList: null,
  38398. _onMovementList: !1,
  38399. _movementListLoop: !1,
  38400. _movementIndex: 0,
  38401. _movementListDurationTo: -1,
  38402. _movementEventCallFunc: null,
  38403. _frameEventCallFunc: null,
  38404. _movementEventTarget: null,
  38405. _frameEventTarget: null,
  38406. _movementEventListener: null,
  38407. _frameEventListener: null,
  38408. ctor: function() {
  38409. ccs.ProcessBase.prototype.ctor.call(this);
  38410. this._tweenList = [];
  38411. this._movementList = [];
  38412. this._frameEventQueue = [];
  38413. this._movementEventQueue = []
  38414. },
  38415. init: function(a) {
  38416. this._armature = a;
  38417. this._tweenList.length = 0;
  38418. return !0
  38419. },
  38420. pause: function() {
  38421. for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].pause();
  38422. ccs.ProcessBase.prototype.pause.call(this)
  38423. },
  38424. resume: function() {
  38425. for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].resume();
  38426. ccs.ProcessBase.prototype.resume.call(this)
  38427. },
  38428. stop: function() {
  38429. for (var a = this._tweenList, c = 0; c < a.length; c++) a[c].stop();
  38430. a.length = 0;
  38431. ccs.ProcessBase.prototype.stop.call(this)
  38432. },
  38433. setAnimationScale: function(a) {
  38434. return this.setSpeedScale(a)
  38435. },
  38436. getAnimationScale: function() {
  38437. return this.getSpeedScale()
  38438. },
  38439. setSpeedScale: function(a) {
  38440. if (a != this._speedScale) {
  38441. this._speedScale = a;
  38442. this._processScale = !this._movementData ? this._speedScale : this._speedScale * this._movementData.scale;
  38443. a = this._armature.getBoneDic();
  38444. for (var c in a) {
  38445. var d = a[c];
  38446. d.getTween().setProcessScale(this._processScale);
  38447. d.getChildArmature() && d.getChildArmature().getAnimation().setProcessScale(this._processScale)
  38448. }
  38449. }
  38450. },
  38451. getSpeedScale: function() {
  38452. return this._speedScale
  38453. },
  38454. play: function(a, c, d) {
  38455. cc.assert(this._animationData, "this.animationData can not be null");
  38456. this._movementData = this._animationData.getMovement(a);
  38457. cc.assert(this._movementData, "this._movementData can not be null");
  38458. c = void 0 === c ? -1 : c;
  38459. d = void 0 === d ? -1 : d;
  38460. this._rawDuration = this._movementData.duration;
  38461. this._movementID = a;
  38462. this._processScale = this._speedScale * this._movementData.scale;
  38463. c = -1 == c ? this._movementData.durationTo : c;
  38464. a = 0 == this._movementData.durationTween ? this._rawDuration : this._movementData.durationTween;
  38465. var e = this._movementData.tweenEasing;
  38466. d = !d || 0 > d ? this._movementData.loop : d;
  38467. this._onMovementList = !1;
  38468. ccs.ProcessBase.prototype.play.call(this, c, a, d, e);
  38469. 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);
  38470. var f;
  38471. this._tweenList = [];
  38472. var g = this._armature.getBoneDic(),
  38473. h;
  38474. for (h in g) {
  38475. var k = g[h];
  38476. f = this._movementData.movBoneDataDic[k.getName()];
  38477. var m = k.getTween();
  38478. 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())
  38479. }
  38480. this._armature.update(0)
  38481. },
  38482. playByIndex: function(a, c, d, e, f) {
  38483. cc.log("playByIndex is deprecated. Use playWithIndex instead.");
  38484. this.playWithIndex(a, c, e)
  38485. },
  38486. playWithIndex: function(a, c, d) {
  38487. var e = this._animationData.movementNames;
  38488. cc.assert(-1 < a && a < e.length);
  38489. this.play(e[a], c, d)
  38490. },
  38491. playWithNames: function(a, c, d) {
  38492. this._movementListLoop = void 0 === d ? !0 : d;
  38493. this._movementListDurationTo = void 0 === c ? -1 : c;
  38494. this._onMovementList = !0;
  38495. this._movementIndex = 0;
  38496. a instanceof Array ? this._movementList = a : this._movementList.length = 0;
  38497. this.updateMovementList()
  38498. },
  38499. playWithIndexes: function(a, c, d) {
  38500. this._movementList.length = 0;
  38501. this._movementListLoop = void 0 === d ? !0 : d;
  38502. this._movementListDurationTo = void 0 === c ? -1 : c;
  38503. this._onMovementList = !0;
  38504. this._movementIndex = 0;
  38505. c = this._animationData.movementNames;
  38506. for (d = 0; d < a.length; d++) this._movementList.push(c[a[d]]);
  38507. this.updateMovementList()
  38508. },
  38509. gotoAndPlay: function(a) {
  38510. 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.");
  38511. else {
  38512. var c = this._ignoreFrameEvent;
  38513. this._isPlaying = this._ignoreFrameEvent = !0;
  38514. this._isComplete = this._isPause = !1;
  38515. ccs.ProcessBase.prototype.gotoFrame.call(this, a);
  38516. this._currentPercent = this._curFrameIndex / (this._movementData.duration - 1);
  38517. this._currentFrame = this._nextFrameIndex * this._currentPercent;
  38518. for (var d = this._tweenList, e = 0; e < d.length; e++) d[e].gotoAndPlay(a);
  38519. this._armature.update(0);
  38520. this._ignoreFrameEvent = c
  38521. }
  38522. },
  38523. gotoAndPause: function(a) {
  38524. this.gotoAndPlay(a);
  38525. this.pause()
  38526. },
  38527. getMovementCount: function() {
  38528. return this._animationData.getMovementCount()
  38529. },
  38530. update: function(a) {
  38531. ccs.ProcessBase.prototype.update.call(this, a);
  38532. for (var c = this._tweenList, d = 0; d < c.length; d++) c[d].update(a);
  38533. 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;
  38534. 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)
  38535. },
  38536. updateHandler: function() {
  38537. var a = this._currentPercent;
  38538. if (1 <= a) {
  38539. switch (this._loopType) {
  38540. case ccs.ANIMATION_TYPE_NO_LOOP:
  38541. this._loopType = ccs.ANIMATION_TYPE_MAX;
  38542. this._currentFrame = (a - 1) * this._nextFrameIndex;
  38543. a = this._currentFrame / this._durationTween;
  38544. if (1 > a) {
  38545. this._nextFrameIndex = this._durationTween;
  38546. this.movementEvent(this._armature, ccs.MovementEventType.start, this._movementID);
  38547. break
  38548. }
  38549. break;
  38550. case ccs.ANIMATION_TYPE_MAX:
  38551. case ccs.ANIMATION_TYPE_SINGLE_FRAME:
  38552. a = 1;
  38553. this._isComplete = !0;
  38554. this._isPlaying = !1;
  38555. this.movementEvent(this._armature, ccs.MovementEventType.complete, this._movementID);
  38556. this.updateMovementList();
  38557. break;
  38558. case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:
  38559. this._loopType = ccs.ANIMATION_TYPE_LOOP_FRONT;
  38560. a = ccs.fmodf(a, 1);
  38561. this._currentFrame = 0 == this._nextFrameIndex ? 0 : ccs.fmodf(this._currentFrame, this._nextFrameIndex);
  38562. this._nextFrameIndex = 0 < this._durationTween ? this._durationTween : 1;
  38563. this.movementEvent(this, ccs.MovementEventType.start, this._movementID);
  38564. break;
  38565. default:
  38566. this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex), this._toIndex = 0, this.movementEvent(this._armature, ccs.MovementEventType.loopComplete, this._movementID)
  38567. }
  38568. this._currentPercent = a
  38569. }
  38570. },
  38571. getCurrentMovementID: function() {
  38572. return this._isComplete ? "" : this._movementID
  38573. },
  38574. setMovementEventCallFunc: function(a, c) {
  38575. 1 == arguments.length ? this._frameEventListener = c : 2 == arguments.length && (this._movementEventTarget = c, this._movementEventCallFunc = a)
  38576. },
  38577. setFrameEventCallFunc: function(a, c) {
  38578. 1 == arguments.length ? this._frameEventListener = c : 2 == arguments.length && (this._frameEventTarget = c, this._frameEventCallFunc = a)
  38579. },
  38580. setUserObject: function(a) {
  38581. this._userObject = a
  38582. },
  38583. frameEvent: function(a, c, d, e) {
  38584. if (this._frameEventTarget && this._frameEventCallFunc || this._frameEventListener) {
  38585. var f = new ccs.FrameEvent;
  38586. f.bone = a;
  38587. f.frameEventName = c;
  38588. f.originFrameIndex = d;
  38589. f.currentFrameIndex = e;
  38590. this._frameEventQueue.push(f)
  38591. }
  38592. },
  38593. movementEvent: function(a, c, d) {
  38594. if (this._movementEventTarget && this._movementEventCallFunc || this._movementEventListener) {
  38595. var e = new ccs.MovementEvent;
  38596. e.armature = a;
  38597. e.movementType = c;
  38598. e.movementID = d;
  38599. this._movementEventQueue.push(e)
  38600. }
  38601. },
  38602. updateMovementList: function() {
  38603. if (this._onMovementList) {
  38604. var a, c = this._movementList;
  38605. 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;
  38606. this._onMovementList = !0
  38607. }
  38608. },
  38609. setAnimationData: function(a) {
  38610. this._animationData != a && (this._animationData = a)
  38611. },
  38612. getAnimationData: function() {
  38613. return this._animationData
  38614. },
  38615. getUserObject: function() {
  38616. return this._userObject
  38617. },
  38618. isIgnoreFrameEvent: function() {
  38619. return this._ignoreFrameEvent
  38620. }
  38621. });
  38622. _p = ccs.ArmatureAnimation.prototype;
  38623. cc.defineGetterSetter(_p, "speedScale", _p.getSpeedScale, _p.setSpeedScale);
  38624. cc.defineGetterSetter(_p, "animationScale", _p.getAnimationScale, _p.setAnimationScale);
  38625. _p = null;
  38626. ccs.ArmatureAnimation.create = function(a) {
  38627. var c = new ccs.ArmatureAnimation;
  38628. return c && c.init(a) ? c : null
  38629. };
  38630. ccs.Tween = ccs.ProcessBase.extend({
  38631. _tweenData: null,
  38632. _to: null,
  38633. _from: null,
  38634. _between: null,
  38635. _movementBoneData: null,
  38636. _bone: null,
  38637. _frameTweenEasing: 0,
  38638. _betweenDuration: 0,
  38639. _totalDuration: 0,
  38640. _toIndex: 0,
  38641. _fromIndex: 0,
  38642. _animation: null,
  38643. _passLastFrame: !1,
  38644. ctor: function() {
  38645. ccs.ProcessBase.prototype.ctor.call(this);
  38646. this._frameTweenEasing = ccs.TweenType.linear
  38647. },
  38648. init: function(a) {
  38649. this._from = new ccs.FrameData;
  38650. this._between = new ccs.FrameData;
  38651. this._bone = a;
  38652. this._tweenData = this._bone.getTweenData();
  38653. this._tweenData.displayIndex = -1;
  38654. this._animation = null != this._bone.getArmature() ? this._bone.getArmature().getAnimation() : null;
  38655. return !0
  38656. },
  38657. play: function(a, c, d, e, f) {
  38658. ccs.ProcessBase.prototype.play.call(this, c, d, e, f);
  38659. this._loopType = e ? ccs.ANIMATION_TYPE_TO_LOOP_FRONT : ccs.ANIMATION_TYPE_NO_LOOP;
  38660. this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
  38661. f = a != this._movementBoneData;
  38662. this.setMovementBoneData(a);
  38663. this._rawDuration = this._movementBoneData.duration;
  38664. a = this._movementBoneData.getFrameData(0);
  38665. this._tweenData.displayIndex = a.displayIndex;
  38666. 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);
  38667. 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));
  38668. this.tweenNodeTo(0)
  38669. },
  38670. gotoAndPlay: function(a) {
  38671. ccs.ProcessBase.prototype.gotoFrame.call(this, a);
  38672. this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
  38673. this._isPlaying = !0;
  38674. this._isComplete = this._isPause = !1;
  38675. this._currentPercent = this._curFrameIndex / (this._rawDuration - 1);
  38676. this._currentFrame = this._nextFrameIndex * this._currentPercent
  38677. },
  38678. gotoAndPause: function(a) {
  38679. this.gotoAndPlay(a);
  38680. this.pause()
  38681. },
  38682. updateHandler: function() {
  38683. var a = this._currentPercent || 1,
  38684. c = this._loopType;
  38685. if (1 <= a) switch (c) {
  38686. case ccs.ANIMATION_TYPE_SINGLE_FRAME:
  38687. a = 1;
  38688. this._isComplete = !0;
  38689. this._isPlaying = !1;
  38690. break;
  38691. case ccs.ANIMATION_TYPE_NO_LOOP:
  38692. c = ccs.ANIMATION_TYPE_MAX;
  38693. a = 0 >= this._durationTween ? 1 : (a - 1) * this._nextFrameIndex / this._durationTween;
  38694. 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);
  38695. break;
  38696. case ccs.ANIMATION_TYPE_TO_LOOP_FRONT:
  38697. c = ccs.ANIMATION_TYPE_LOOP_FRONT;
  38698. this._nextFrameIndex = 0 < this._durationTween ? this._durationTween : 1;
  38699. 0 != this._movementBoneData.delay ? (this._currentFrame = (1 - this._movementBoneData.delay) * this._nextFrameIndex, a = this._currentFrame / this._nextFrameIndex) : this._currentFrame = a = 0;
  38700. this._fromIndex = this._toIndex = this._betweenDuration = this._totalDuration = 0;
  38701. break;
  38702. case ccs.ANIMATION_TYPE_MAX:
  38703. a = 1;
  38704. this._isComplete = !0;
  38705. this._isPlaying = !1;
  38706. break;
  38707. default:
  38708. this._currentFrame = ccs.fmodf(this._currentFrame, this._nextFrameIndex)
  38709. }
  38710. 1 > a && c < ccs.ANIMATION_TYPE_TO_LOOP_BACK && (a = Math.sin(a * cc.PI / 2));
  38711. this._currentPercent = a;
  38712. this._loopType = c;
  38713. c > ccs.ANIMATION_TYPE_TO_LOOP_BACK && (a = this.updateFrameData(a));
  38714. this._frameTweenEasing != ccs.TweenType.tweenEasingMax && this.tweenNodeTo(a)
  38715. },
  38716. setBetween: function(a, c, d) {
  38717. void 0 === d && (d = !0);
  38718. 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));
  38719. a.isTween || (this._tweenData.copy(a), this._tweenData.isTween = !0);
  38720. this.arriveKeyFrame(a)
  38721. },
  38722. arriveKeyFrame: function(a) {
  38723. if (a) {
  38724. var c = this._bone,
  38725. d = c.getDisplayManager(),
  38726. e = a.displayIndex;
  38727. d.getForceChangeDisplay() || d.changeDisplayWithIndex(e, !1);
  38728. this._tweenData.zOrder = a.zOrder;
  38729. c.updateZOrder();
  38730. this._bone.setBlendFunc(a.blendFunc);
  38731. (c = c.getChildArmature()) && "" != a.movement && c.getAnimation().play(a.movement)
  38732. }
  38733. },
  38734. tweenNodeTo: function(a, c) {
  38735. c || (c = this._tweenData);
  38736. var d = this._from,
  38737. e = this._between;
  38738. d.isTween || (a = 0);
  38739. c.x = d.x + a * e.x;
  38740. c.y = d.y + a * e.y;
  38741. c.scaleX = d.scaleX + a * e.scaleX;
  38742. c.scaleY = d.scaleY + a * e.scaleY;
  38743. c.skewX = d.skewX + a * e.skewX;
  38744. c.skewY = d.skewY + a * e.skewY;
  38745. this._bone.setTransformDirty(!0);
  38746. c && e.isUseColorInfo && this.tweenColorTo(a, c);
  38747. return c
  38748. },
  38749. tweenColorTo: function(a, c) {
  38750. var d = this._from,
  38751. e = this._between;
  38752. c.a = d.a + a * e.a;
  38753. c.r = d.r + a * e.r;
  38754. c.g = d.g + a * e.g;
  38755. c.b = d.b + a * e.b;
  38756. this._bone.updateColor()
  38757. },
  38758. updateFrameData: function(a) {
  38759. 1 < a && 0 != this._movementBoneData.delay && (a = ccs.fmodf(a, 1));
  38760. a *= this._rawDuration - 1;
  38761. var c, d, e = this._totalDuration,
  38762. f = this._betweenDuration,
  38763. g = this._toIndex;
  38764. if (a < e || a >= e + f) {
  38765. var f = this._movementBoneData.frameList,
  38766. h = f.length;
  38767. if (a < f[0].frameID) return c = d = f[0], this.setBetween(c, d), this._currentPercent;
  38768. if (a >= f[h - 1].frameID) {
  38769. if (this._passLastFrame) return c = d = f[h - 1], this.setBetween(c, d), this._currentPercent;
  38770. this._passLastFrame = !0
  38771. } else this._passLastFrame = !1;
  38772. do
  38773. 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;
  38774. while (a < c.frameID || a >= d.frameID);
  38775. f = d.frameID - c.frameID;
  38776. this._frameTweenEasing = c.tweenEasing;
  38777. this.setBetween(c, d, !1);
  38778. this._totalDuration = e;
  38779. this._betweenDuration = f;
  38780. this._toIndex = g
  38781. }
  38782. a = 0 == f ? 0 : (a - this._totalDuration) / this._betweenDuration;
  38783. c = this._frameTweenEasing != ccs.TweenType.linear ? this._frameTweenEasing : this._tweenEasing;
  38784. c != ccs.TweenType.tweenEasingMax && (c != ccs.TweenType.linear && !this._passLastFrame) && (a = ccs.TweenFunction.tweenTo(a, c, this._from.easingParams));
  38785. return a
  38786. },
  38787. setAnimation: function(a) {
  38788. this._animation = a
  38789. },
  38790. getAnimation: function() {
  38791. return this._animation
  38792. },
  38793. setMovementBoneData: function(a) {
  38794. this._movementBoneData = a
  38795. }
  38796. });
  38797. _p = ccs.Tween.prototype;
  38798. cc.defineGetterSetter(_p, "animation", _p.getAnimation, _p.setAnimation);
  38799. _p = null;
  38800. ccs.Tween.create = function(a) {
  38801. var c = new ccs.Tween;
  38802. return c && c.init(a) ? c : null
  38803. };
  38804. ccs.PT_RATIO = 32;
  38805. ccs.ColliderFilter = ccs.Class.extend({
  38806. _collisionType: 0,
  38807. _group: 0,
  38808. _categoryBits: 0,
  38809. _groupIndex: 0,
  38810. _maskBits: 0,
  38811. ctor: function(a, c) {
  38812. this._collisionType = a || 0;
  38813. this._group = c || 0
  38814. },
  38815. updateShape: function(a) {
  38816. if (a instanceof cp.Shape) a.collision_type = this._collisionType, a.group = this._group;
  38817. else if (a instanceof Box2D.b2FilterData) {
  38818. var c = new Box2D.b2FilterData;
  38819. c.categoryBits = this._categoryBits;
  38820. c.groupIndex = this._groupIndex;
  38821. c.maskBits = this._maskBits;
  38822. a.SetFilterData(c)
  38823. }
  38824. }
  38825. });
  38826. ccs.ColliderBody = ccs.Class.extend({
  38827. shape: null,
  38828. coutourData: null,
  38829. colliderFilter: null,
  38830. _calculatedVertexList: null,
  38831. ctor: function(a) {
  38832. this.shape = null;
  38833. this.coutourData = a;
  38834. this.colliderFilter = new ccs.ColliderFilter;
  38835. ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX && (this._calculatedVertexList = [])
  38836. },
  38837. getContourData: function() {
  38838. return this.coutourData
  38839. },
  38840. setColliderFilter: function(a) {
  38841. this.colliderFilter = a
  38842. },
  38843. getCalculatedVertexList: function() {
  38844. return this._calculatedVertexList
  38845. },
  38846. setB2Fixture: function(a) {
  38847. this._fixture = a
  38848. },
  38849. getB2Fixture: function() {
  38850. return this._fixture
  38851. },
  38852. setShape: function(a) {
  38853. this.shape = a
  38854. },
  38855. getShape: function() {
  38856. return this.shape
  38857. },
  38858. setContourData: function(a) {
  38859. this.coutourData = a
  38860. },
  38861. getColliderFilter: function() {
  38862. return this.colliderFilter
  38863. }
  38864. });
  38865. ccs.ColliderDetector = ccs.Class.extend({
  38866. _colliderBodyList: null,
  38867. _bone: null,
  38868. _body: null,
  38869. _active: !1,
  38870. _filter: null,
  38871. helpPoint: cc.p(0, 0),
  38872. ctor: function() {
  38873. this._colliderBodyList = [];
  38874. this._body = this._bone = null;
  38875. this._active = !1;
  38876. this._filter = null
  38877. },
  38878. init: function(a) {
  38879. this._colliderBodyList.length = 0;
  38880. a && (this._bone = a);
  38881. this._filter = new ccs.ColliderFilter;
  38882. return !0
  38883. },
  38884. addContourData: function(a) {
  38885. var c = new ccs.ColliderBody(a);
  38886. this._colliderBodyList.push(c);
  38887. if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
  38888. c = c.getCalculatedVertexList();
  38889. a = a.vertexList;
  38890. for (var d = 0; d < a.length; d++) {
  38891. var e = new ccs.ContourVertex2(0, 0);
  38892. c.push(e)
  38893. }
  38894. }
  38895. },
  38896. addContourDataList: function(a) {
  38897. for (var c = 0; c < a.length; c++) this.addContourData(a[c])
  38898. },
  38899. removeContourData: function(a) {
  38900. var c = [],
  38901. d, e = this._colliderBodyList;
  38902. for (d = 0; d < e.length; d++) {
  38903. var f = e[d];
  38904. f && f.getContourData() == a && c.push(f)
  38905. }
  38906. for (d = 0; d < c.length; d++) cc.arrayRemoveObject(e, c[d])
  38907. },
  38908. removeAll: function() {
  38909. this._colliderBodyList.length = 0
  38910. },
  38911. setActive: function(a) {
  38912. if (this._active != a) {
  38913. this._active = a;
  38914. a = this._body;
  38915. var c;
  38916. if (a)
  38917. if (c = null, this._active)
  38918. for (var d = 0; d < this._colliderBodyList.length; d++) c = this._colliderBodyList[d], c = c.getShape(), a.space.addShape(c);
  38919. else
  38920. for (d = 0; d < this._colliderBodyList.length; d++) c = this._colliderBodyList[d], c = c.getShape(), a.space.removeShape(c)
  38921. }
  38922. },
  38923. getActive: function() {
  38924. return this._active
  38925. },
  38926. getColliderBodyList: function() {
  38927. return this._colliderBodyList
  38928. },
  38929. setColliderFilter: function(a) {
  38930. this._filter = a;
  38931. for (var c = this._colliderBodyList, d = 0; d < c.length; d++) {
  38932. var e = c[d];
  38933. e.setColliderFilter(a);
  38934. e.getShape() && e.getColliderFilter().updateShape(e.getShape())
  38935. }
  38936. },
  38937. getColliderFilter: function() {
  38938. return this._filter
  38939. },
  38940. updateTransform: function(a) {
  38941. if (this._active)
  38942. for (var c = null, d = this._body, e = this.helpPoint, f = 0; f < this._colliderBodyList.length; f++) {
  38943. var c = this._colliderBodyList[f],
  38944. g = c.getContourData(),
  38945. h = null;
  38946. d && (h = c.getShape());
  38947. for (var g = g.vertexList, k = c.getCalculatedVertexList(), c = 0; c < g.length; c++) {
  38948. e.x = g[c].x;
  38949. e.y = g[c].y;
  38950. e = cc.pointApplyAffineTransform(e, a);
  38951. if (ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX) {
  38952. var m = cc.p(0, 0);
  38953. m.x = e.x;
  38954. m.y = e.y;
  38955. k[c] = m
  38956. }
  38957. h && (h.verts[2 * c] = e.x, h.verts[2 * c + 1] = e.y)
  38958. }
  38959. if (h)
  38960. 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])
  38961. }
  38962. },
  38963. setBody: function(a) {
  38964. this._body = a;
  38965. for (var c = this._colliderBodyList, d = 0; d < c.length; d++) {
  38966. a = c[d];
  38967. for (var e = [], f = a.getContourData().vertexList, g = 0; g < f.length; g++) {
  38968. var h = f[g];
  38969. e.push(h.x);
  38970. e.push(h.y)
  38971. }
  38972. e = new cp.PolyShape(this._body, e, cp.vzero);
  38973. e.sensor = !0;
  38974. e.data = this._bone;
  38975. this._active && this._body.space.addShape(e);
  38976. a.setShape(e);
  38977. a.getColliderFilter().updateShape(e)
  38978. }
  38979. },
  38980. getBody: function() {
  38981. return this._body
  38982. }
  38983. });
  38984. _p = ccs.ColliderDetector.prototype;
  38985. cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setColliderFilter);
  38986. cc.defineGetterSetter(_p, "active", _p.getActive, _p.setActive);
  38987. cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
  38988. _p = null;
  38989. ccs.ColliderDetector.create = function(a) {
  38990. var c = new ccs.ColliderDetector;
  38991. return c && c.init(a) ? c : null
  38992. };
  38993. ccs.Armature = ccs.Node.extend({
  38994. animation: null,
  38995. armatureData: null,
  38996. batchNode: null,
  38997. _textureAtlas: null,
  38998. _parentBone: null,
  38999. _boneDic: null,
  39000. _topBoneList: null,
  39001. _armatureIndexDic: null,
  39002. _offsetPoint: null,
  39003. version: 0,
  39004. _armatureTransformDirty: !0,
  39005. _body: null,
  39006. _blendFunc: null,
  39007. _className: "Armature",
  39008. _realAnchorPointInPoints: null,
  39009. ctor: function(a, c) {
  39010. cc.Node.prototype.ctor.call(this);
  39011. this._name = "";
  39012. this._topBoneList = [];
  39013. this._armatureIndexDic = {};
  39014. this._offsetPoint = cc.p(0, 0);
  39015. this._armatureTransformDirty = !0;
  39016. this._realAnchorPointInPoints = cc.p(0, 0);
  39017. a && ccs.Armature.prototype.init.call(this, a, c)
  39018. },
  39019. init: function(a, c) {
  39020. cc.Node.prototype.init.call(this);
  39021. c && (this._parentBone = c);
  39022. this.removeAllChildren();
  39023. this.animation = new ccs.ArmatureAnimation;
  39024. this.animation.init(this);
  39025. this._boneDic = {};
  39026. this._topBoneList.length = 0;
  39027. this._blendFunc = {
  39028. src: cc.BLEND_SRC,
  39029. dst: cc.BLEND_DST
  39030. };
  39031. this._name = a || "";
  39032. var d = ccs.armatureDataManager,
  39033. e;
  39034. if ("" != a) {
  39035. e = d.getAnimationData(a);
  39036. cc.assert(e, "AnimationData not exist!");
  39037. this.animation.setAnimationData(e);
  39038. d = d.getArmatureData(a);
  39039. cc.assert(d, "ArmatureData not exist!");
  39040. this.armatureData = d;
  39041. var d = d.getBoneDataDic(),
  39042. f;
  39043. for (f in d) {
  39044. var d = this.createBone(String(f)),
  39045. g = e.getMovement(e.movementNames[0]);
  39046. if (g && (g = g.getMovementBoneData(d.getName())) && !(0 >= g.frameList.length))
  39047. if (g = g.getFrameData(0)) d.getTweenData().copy(g), d.changeDisplayWithIndex(g.displayIndex, !1)
  39048. }
  39049. this.update(0);
  39050. this.updateOffsetPoint()
  39051. } 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);
  39052. cc._renderType === cc._RENDER_TYPE_WEBGL && this.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR));
  39053. this.setCascadeOpacityEnabled(!0);
  39054. this.setCascadeColorEnabled(!0);
  39055. return !0
  39056. },
  39057. createBone: function(a) {
  39058. var c = this.getBone(a);
  39059. if (c) return c;
  39060. var c = this.armatureData.getBoneData(a),
  39061. d = c.parentName,
  39062. e = null;
  39063. d ? (this.createBone(d), e = ccs.Bone.create(a), this.addBone(e, d)) : (e = ccs.Bone.create(a), this.addBone(e, ""));
  39064. e.setBoneData(c);
  39065. e.getDisplayManager().changeDisplayWithIndex(-1, !1);
  39066. return e
  39067. },
  39068. addBone: function(a, c) {
  39069. cc.assert(a, "Argument must be non-nil");
  39070. var d = this._boneDic;
  39071. a.getName() && cc.assert(!d[a.getName()], "bone already added. It can't be added again");
  39072. if (c) {
  39073. var e = d[c];
  39074. e ? e.addChildBone(a) : this._topBoneList.push(a)
  39075. } else this._topBoneList.push(a);
  39076. a.setArmature(this);
  39077. d[a.getName()] = a;
  39078. this.addChild(a)
  39079. },
  39080. removeBone: function(a, c) {
  39081. cc.assert(a, "bone must be added to the bone dictionary!");
  39082. a.setArmature(null);
  39083. a.removeFromParent(c);
  39084. cc.arrayRemoveObject(this._topBoneList, a);
  39085. delete this._boneDic[a.getName()];
  39086. this.removeChild(a, !0)
  39087. },
  39088. getBone: function(a) {
  39089. return this._boneDic[a]
  39090. },
  39091. changeBoneParent: function(a, c) {
  39092. cc.assert(a, "bone must be added to the bone dictionary!");
  39093. var d = a.getParentBone();
  39094. d && (cc.arrayRemoveObject(d.getChildren(), a), a.setParentBone(null));
  39095. c && ((d = this._boneDic[c]) ? (d.addChildBone(a), cc.arrayRemoveObject(this._topBoneList, a)) : this._topBoneList.push(a))
  39096. },
  39097. getBoneDic: function() {
  39098. return this._boneDic
  39099. },
  39100. updateOffsetPoint: function() {
  39101. var a = this.getBoundingBox();
  39102. this.setContentSize(a);
  39103. var c = this._offsetPoint;
  39104. c.x = -a.x;
  39105. c.y = -a.y;
  39106. 0 != a.width && 0 != a.height && this.setAnchorPoint(c.x / a.width, c.y / a.height)
  39107. },
  39108. setAnchorPoint: function(a, c) {
  39109. var d, e;
  39110. void 0 !== c ? (d = a, e = c) : (d = a.x, e = a.y);
  39111. var f = this._anchorPoint;
  39112. if (d != f.x || e != f.y) {
  39113. var g = this._contentSize;
  39114. f.x = d;
  39115. f.y = e;
  39116. this._anchorPointInPoints.x = g.width * f.x - this._offsetPoint.x;
  39117. this._anchorPointInPoints.y = g.height * f.y - this._offsetPoint.y;
  39118. this._realAnchorPointInPoints.x = g.width * f.x;
  39119. this._realAnchorPointInPoints.y = g.height * f.y;
  39120. this.setNodeDirty()
  39121. }
  39122. },
  39123. _setAnchorX: function(a) {
  39124. 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())
  39125. },
  39126. _setAnchorY: function(a) {
  39127. 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())
  39128. },
  39129. getAnchorPointInPoints: function() {
  39130. return this._realAnchorPointInPoints
  39131. },
  39132. setAnimation: function(a) {
  39133. this.animation = a
  39134. },
  39135. getAnimation: function() {
  39136. return this.animation
  39137. },
  39138. getArmatureTransformDirty: function() {
  39139. return this._armatureTransformDirty
  39140. },
  39141. update: function(a) {
  39142. this.animation.update(a);
  39143. for (var c = this._topBoneList, d = 0; d < c.length; d++) c[d].update(a);
  39144. this._armatureTransformDirty = !1
  39145. },
  39146. draw: function(a) {
  39147. for (var c = this._children, d = cc.BlendFunc.ALPHA_PREMULTIPLIED, e = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED, f = 0, g = c.length; f < g; f++) {
  39148. var h = c[f];
  39149. if (h) {
  39150. var k = h.getDisplayRenderNode();
  39151. if (null != k) switch (h.getDisplayRenderNodeType()) {
  39152. case ccs.DISPLAY_TYPE_SPRITE:
  39153. if (k instanceof ccs.Skin)
  39154. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  39155. k.updateTransform();
  39156. var m = h.getBlendFunc();
  39157. 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);
  39158. k.draw(a)
  39159. } else k.visit(a);
  39160. break;
  39161. case ccs.DISPLAY_TYPE_ARMATURE:
  39162. k.draw(a);
  39163. break;
  39164. default:
  39165. k.visit(a)
  39166. }
  39167. } else h instanceof cc.Node && h.visit(a)
  39168. }
  39169. },
  39170. onEnter: function() {
  39171. cc.Node.prototype.onEnter.call(this);
  39172. this.scheduleUpdate()
  39173. },
  39174. onExit: function() {
  39175. cc.Node.prototype.onExit.call(this);
  39176. this.unscheduleUpdate()
  39177. },
  39178. visit: null,
  39179. _visitForCanvas: function(a) {
  39180. var c = a || cc._renderContext;
  39181. this._visible && (c.save(), this.transform(c), this.sortAllChildren(), this.draw(a), this._cacheDirty = !1, this.arrivalOrder = 0, c.restore())
  39182. },
  39183. _visitForWebGL: function() {
  39184. if (this._visible) {
  39185. var a = cc._renderContext,
  39186. c = cc.current_stack;
  39187. c.stack.push(c.top);
  39188. cc.kmMat4Assign(this._stackMatrix, c.top);
  39189. c.top = this._stackMatrix;
  39190. this.transform();
  39191. this.sortAllChildren();
  39192. this.draw(a);
  39193. this.arrivalOrder = 0;
  39194. c.top = c.stack.pop()
  39195. }
  39196. },
  39197. getBoundingBox: function() {
  39198. 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++)
  39199. 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);
  39200. return cc.rectApplyAffineTransform(g, this.getNodeToParentTransform())
  39201. },
  39202. getBoneAtPoint: function(a, c) {
  39203. for (var d = this._children, e = d.length - 1; 0 <= e; e--) {
  39204. var f = d[e];
  39205. if (f instanceof ccs.Bone && f.getDisplayManager().containPoint(a, c)) return f
  39206. }
  39207. return null
  39208. },
  39209. setParentBone: function(a) {
  39210. this._parentBone = a;
  39211. a = this._boneDic;
  39212. for (var c in a) a[c].setArmature(this)
  39213. },
  39214. getParentBone: function() {
  39215. return this._parentBone
  39216. },
  39217. drawContour: function() {
  39218. cc._drawingUtil.setDrawColor(255, 255, 255, 255);
  39219. cc._drawingUtil.setLineWidth(1);
  39220. var a = this._boneDic,
  39221. c;
  39222. for (c in a) {
  39223. var d = a[c].getColliderDetector();
  39224. if (d)
  39225. for (var d = d.getColliderBodyList(), e = 0; e < d.length; e++) {
  39226. var f = d[e].getCalculatedVertexList();
  39227. cc._drawingUtil.drawPoly(f, f.length, !0)
  39228. }
  39229. }
  39230. },
  39231. setBody: function(a) {
  39232. if (this._body != a) {
  39233. this._body = a;
  39234. this._body.data = this;
  39235. var c, d;
  39236. a = this._children;
  39237. for (var e = 0; e < a.length; e++)
  39238. if (c = a[e], c instanceof ccs.Bone) {
  39239. c = c.getDisplayManager().getDecorativeDisplayList();
  39240. for (var f = 0; f < c.length; f++) d = c[f], (d = d.getColliderDetector()) && d.setBody(this._body)
  39241. }
  39242. }
  39243. },
  39244. getShapeList: function() {
  39245. return this._body ? this._body.shapeList : null
  39246. },
  39247. getBody: function() {
  39248. return this._body
  39249. },
  39250. setBlendFunc: function(a) {
  39251. this._blendFunc = a
  39252. },
  39253. getBlendFunc: function() {
  39254. return this._blendFunc
  39255. },
  39256. setColliderFilter: function(a) {
  39257. var c = this._boneDic,
  39258. d;
  39259. for (d in c) c[d].setColliderFilter(a)
  39260. },
  39261. getArmatureData: function() {
  39262. return this.armatureData
  39263. },
  39264. setArmatureData: function(a) {
  39265. this.armatureData = a
  39266. },
  39267. getBatchNode: function() {
  39268. return this.batchNode
  39269. },
  39270. setBatchNode: function(a) {
  39271. this.batchNode = a
  39272. },
  39273. getVersion: function() {
  39274. return this.version
  39275. },
  39276. setVersion: function(a) {
  39277. this.version = a
  39278. }
  39279. });
  39280. ccs.Armature.prototype.visit = cc._renderType == cc._RENDER_TYPE_WEBGL ? ccs.Armature.prototype._visitForWebGL : ccs.Armature.prototype._visitForCanvas;
  39281. _p = ccs.Armature.prototype;
  39282. cc.defineGetterSetter(_p, "parentBone", _p.getParentBone, _p.setParentBone);
  39283. cc.defineGetterSetter(_p, "body", _p.getBody, _p.setBody);
  39284. cc.defineGetterSetter(_p, "colliderFilter", null, _p.setColliderFilter);
  39285. _p = null;
  39286. ccs.Armature.create = function(a, c) {
  39287. var d = new ccs.Armature;
  39288. return d.init(a, c) ? d : null
  39289. };
  39290. ccs.Bone = ccs.Node.extend({
  39291. _boneData: null,
  39292. _armature: null,
  39293. _childArmature: null,
  39294. _displayManager: null,
  39295. ignoreMovementBoneData: !1,
  39296. _tween: null,
  39297. _tweenData: null,
  39298. _parentBone: null,
  39299. _boneTransformDirty: !1,
  39300. _worldTransform: null,
  39301. _blendFunc: 0,
  39302. blendDirty: !1,
  39303. _worldInfo: null,
  39304. _armatureParentBone: null,
  39305. _dataVersion: 0,
  39306. _className: "Bone",
  39307. ctor: function() {
  39308. cc.Node.prototype.ctor.call(this);
  39309. this._displayManager = this._tween = this._boneData = this._childArmature = this._armature = this._parentBone = this._tweenData = null;
  39310. this.ignoreMovementBoneData = !1;
  39311. this._worldTransform = cc.affineTransformMake(1, 0, 0, 1, 0, 0);
  39312. this._boneTransformDirty = !0;
  39313. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  39314. this.blendDirty = !1;
  39315. this._armatureParentBone = this._worldInfo = null;
  39316. this._dataVersion = 0
  39317. },
  39318. init: function(a) {
  39319. a && (this._name = a);
  39320. this._tweenData = new ccs.FrameData;
  39321. this._tween = new ccs.Tween;
  39322. this._tween.init(this);
  39323. this._displayManager = new ccs.DisplayManager;
  39324. this._displayManager.init(this);
  39325. this._worldInfo = new ccs.BaseData;
  39326. this._boneData = new ccs.BaseData;
  39327. return !0
  39328. },
  39329. setBoneData: function(a) {
  39330. cc.assert(a, "_boneData must not be null");
  39331. this._boneData != a && (this._boneData = a);
  39332. this.setName(this._boneData.name);
  39333. this._localZOrder = this._boneData.zOrder;
  39334. this._displayManager.initDisplayList(a)
  39335. },
  39336. getBoneData: function() {
  39337. return this._boneData
  39338. },
  39339. setArmature: function(a) {
  39340. (this._armature = a) ? (this._tween.setAnimation(this._armature.getAnimation()), this._dataVersion = this._armature.getArmatureData().dataVersion, this._armatureParentBone = this._armature.getParentBone()) : this._armatureParentBone = null
  39341. },
  39342. getArmature: function() {
  39343. return this._armature
  39344. },
  39345. update: function(a) {
  39346. this._parentBone && (this._boneTransformDirty = this._boneTransformDirty || this._parentBone.isTransformDirty());
  39347. this._armatureParentBone && !this._boneTransformDirty && (this._boneTransformDirty = this._armatureParentBone.isTransformDirty());
  39348. if (this._boneTransformDirty) {
  39349. var c = this._tweenData;
  39350. this._dataVersion >= ccs.CONST_VERSION_COMBINED && (ccs.TransformHelp.nodeConcat(c, this._boneData), c.scaleX -= 1, c.scaleY -= 1);
  39351. var d = this._worldInfo;
  39352. d.copy(c);
  39353. d.x = c.x + this._position.x;
  39354. d.y = c.y + this._position.y;
  39355. d.scaleX = c.scaleX * this._scaleX;
  39356. d.scaleY = c.scaleY * this._scaleY;
  39357. d.skewX = c.skewX + this._skewX + this._rotationX;
  39358. d.skewY = c.skewY + this._skewY - this._rotationY;
  39359. this._parentBone ? this.applyParentTransform(this._parentBone) : this._armatureParentBone && this.applyParentTransform(this._armatureParentBone);
  39360. ccs.TransformHelp.nodeToMatrix(d, this._worldTransform);
  39361. this._armatureParentBone && (this._worldTransform = cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToParentTransform()))
  39362. }
  39363. ccs.displayFactory.updateDisplay(this, a, this._boneTransformDirty || this._armature.getArmatureTransformDirty());
  39364. for (c = 0; c < this._children.length; c++) this._children[c].update(a);
  39365. this._boneTransformDirty = !1
  39366. },
  39367. applyParentTransform: function(a) {
  39368. var c = this._worldInfo,
  39369. d = a._worldTransform;
  39370. a = a._worldInfo;
  39371. var e = c.x,
  39372. f = c.y;
  39373. c.x = e * d.a + f * d.c + a.x;
  39374. c.y = e * d.b + f * d.d + a.y;
  39375. c.scaleX *= a.scaleX;
  39376. c.scaleY *= a.scaleY;
  39377. c.skewX += a.skewX;
  39378. c.skewY += a.skewY
  39379. },
  39380. setBlendFunc: function(a) {
  39381. if (this._blendFunc.src != a.src || this._blendFunc.dst != a.dst) this._blendFunc = a, this.blendDirty = !0
  39382. },
  39383. updateDisplayedColor: function(a) {
  39384. this._realColor = cc.color(255, 255, 255);
  39385. cc.Node.prototype.updateDisplayedColor.call(this, a)
  39386. },
  39387. updateDisplayedOpacity: function(a) {
  39388. this._realOpacity = 255;
  39389. cc.Node.prototype.updateDisplayedOpacity.call(this, a)
  39390. },
  39391. updateColor: function() {
  39392. var a = this._displayManager.getDisplayRenderNode();
  39393. 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))
  39394. },
  39395. updateZOrder: function() {
  39396. this._armature.getArmatureData().dataVersion >= ccs.CONST_VERSION_COMBINED ? this.setLocalZOrder(this._tweenData.zOrder + this._boneData.zOrder) : this.setLocalZOrder(this._tweenData.zOrder)
  39397. },
  39398. addChildBone: function(a) {
  39399. cc.assert(a, "Argument must be non-nil");
  39400. cc.assert(!a.parentBone, "child already added. It can't be added again");
  39401. 0 > this._children.indexOf(a) && (this._children.push(a), a.setParentBone(this))
  39402. },
  39403. removeChildBone: function(a, c) {
  39404. if (0 < this._children.length && -1 != this._children.getIndex(a)) {
  39405. if (c)
  39406. for (var d = a._children, e = 0; e < d.length; e++) a.removeChildBone(d[e], c);
  39407. a.setParentBone(null);
  39408. a.getDisplayManager().setCurrentDecorativeDisplay(null);
  39409. cc.arrayRemoveObject(this._children, a)
  39410. }
  39411. },
  39412. removeFromParent: function(a) {
  39413. this._parentBone && this._parentBone.removeChildBone(this, a)
  39414. },
  39415. setParentBone: function(a) {
  39416. this._parentBone = a
  39417. },
  39418. getParentBone: function() {
  39419. return this._parentBone
  39420. },
  39421. setChildArmature: function(a) {
  39422. this._childArmature != a && (null == a && this._childArmature && this._childArmature.setParentBone(null), this._childArmature = a)
  39423. },
  39424. getChildArmature: function() {
  39425. return this._childArmature
  39426. },
  39427. getTween: function() {
  39428. return this._tween
  39429. },
  39430. setLocalZOrder: function(a) {
  39431. this._localZOrder != a && cc.Node.prototype.setLocalZOrder.call(this, a)
  39432. },
  39433. getNodeToArmatureTransform: function() {
  39434. return this._worldTransform
  39435. },
  39436. getNodeToWorldTransform: function() {
  39437. return cc.affineTransformConcat(this._worldTransform, this._armature.getNodeToWorldTransform())
  39438. },
  39439. getDisplayRenderNode: function() {
  39440. return this._displayManager.getDisplayRenderNode()
  39441. },
  39442. getDisplayRenderNodeType: function() {
  39443. return this._displayManager.getDisplayRenderNodeType()
  39444. },
  39445. addDisplay: function(a, c) {
  39446. return this._displayManager.addDisplay(a, c || 0)
  39447. },
  39448. removeDisplay: function(a) {
  39449. this._displayManager.removeDisplay(a)
  39450. },
  39451. changeDisplayByIndex: function(a, c) {
  39452. cc.log("changeDisplayByIndex is deprecated. Use changeDisplayWithIndex instead.");
  39453. this.changeDisplayWithIndex(a, c)
  39454. },
  39455. changeDisplayByName: function(a, c) {
  39456. this.changeDisplayWithName(a, c)
  39457. },
  39458. changeDisplayWithIndex: function(a, c) {
  39459. this._displayManager.changeDisplayWithIndex(a, c)
  39460. },
  39461. changeDisplayWithName: function(a, c) {
  39462. this._displayManager.changeDisplayWithName(a, c)
  39463. },
  39464. getColliderDetector: function() {
  39465. var a = this._displayManager.getCurrentDecorativeDisplay();
  39466. return a && (a = a.getColliderDetector()) ? a : null
  39467. },
  39468. setColliderFilter: function(a) {
  39469. for (var c = this._displayManager.getDecorativeDisplayList(), d = 0; d < c.length; d++) {
  39470. var e = c[d].getColliderDetector();
  39471. e && e.setColliderFilter(a)
  39472. }
  39473. },
  39474. getColliderFilter: function() {
  39475. var a = this.displayManager.getCurrentDecorativeDisplay();
  39476. return a && (a = a.getColliderDetector()) ? a.getColliderFilter() : null
  39477. },
  39478. setTransformDirty: function(a) {
  39479. this._boneTransformDirty = a
  39480. },
  39481. isTransformDirty: function() {
  39482. return this._boneTransformDirty
  39483. },
  39484. getDisplayManager: function() {
  39485. return this._displayManager
  39486. },
  39487. setIgnoreMovementBoneData: function(a) {
  39488. this._ignoreMovementBoneData = a
  39489. },
  39490. isIgnoreMovementBoneData: function() {
  39491. return this._ignoreMovementBoneData
  39492. },
  39493. getBlendFunc: function() {
  39494. return this._blendFunc
  39495. },
  39496. setBlendDirty: function(a) {
  39497. this._blendDirty = a
  39498. },
  39499. isBlendDirty: function() {
  39500. return this._blendDirty
  39501. },
  39502. getTweenData: function() {
  39503. return this._tweenData
  39504. },
  39505. getWorldInfo: function() {
  39506. return this._worldInfo
  39507. },
  39508. getChildrenBone: function() {
  39509. return this._children
  39510. },
  39511. nodeToArmatureTransform: function() {
  39512. return this.getNodeToArmatureTransform()
  39513. },
  39514. nodeToWorldTransform: function() {
  39515. return this.getNodeToWorldTransform()
  39516. },
  39517. getColliderBodyList: function() {
  39518. var a = this.getColliderDetector();
  39519. return a ? a.getColliderBodyList() : null
  39520. },
  39521. getIgnoreMovementBoneData: function() {
  39522. return this.isIgnoreMovementBoneData()
  39523. }
  39524. });
  39525. _p = ccs.Bone.prototype;
  39526. cc.defineGetterSetter(_p, "boneData", _p.getBoneData, _p.setBoneData);
  39527. cc.defineGetterSetter(_p, "armature", _p.getArmature, _p.setArmature);
  39528. cc.defineGetterSetter(_p, "childArmature", _p.getChildArmature, _p.setChildArmature);
  39529. cc.defineGetterSetter(_p, "childrenBone", _p.getChildrenBone);
  39530. cc.defineGetterSetter(_p, "tween", _p.getTween);
  39531. cc.defineGetterSetter(_p, "tweenData", _p.getTweenData);
  39532. cc.defineGetterSetter(_p, "colliderFilter", _p.getColliderFilter, _p.setColliderFilter);
  39533. _p = null;
  39534. ccs.Bone.create = function(a) {
  39535. var c = new ccs.Bone;
  39536. return c && c.init(a) ? c : null
  39537. };
  39538. ccs.FRAME_TYPE_MOVE = 0;
  39539. ccs.FRAME_TYPE_SCALE = 1;
  39540. ccs.FRAME_TYPE_ROTATE = 2;
  39541. ccs.FRAME_TYPE_TINT = 3;
  39542. ccs.FRAME_TYPE_FADE = 4;
  39543. ccs.FRAME_TYPE_MAX = 5;
  39544. ccs.FrameEaseType = {
  39545. Custom: -1,
  39546. Linear: 0,
  39547. Sine_EaseIn: 1,
  39548. Sine_EaseOut: 2,
  39549. Sine_EaseInOut: 3,
  39550. Quad_EaseIn: 4,
  39551. Quad_EaseOut: 5,
  39552. Quad_EaseInOut: 6,
  39553. Cubic_EaseIn: 7,
  39554. Cubic_EaseOut: 8,
  39555. Cubic_EaseInOut: 9,
  39556. Quart_EaseIn: 10,
  39557. Quart_EaseOut: 11,
  39558. Quart_EaseInOut: 12,
  39559. Quint_EaseIn: 13,
  39560. Quint_EaseOut: 14,
  39561. Quint_EaseInOut: 15,
  39562. Expo_EaseIn: 16,
  39563. Expo_EaseOut: 17,
  39564. Expo_EaseInOut: 18,
  39565. Circ_EaseIn: 19,
  39566. Circ_EaseOut: 20,
  39567. Circ_EaseInOut: 21,
  39568. Elastic_EaesIn: 22,
  39569. Elastic_EaesOut: 23,
  39570. Elastic_EaesInOut: 24,
  39571. Back_EaseIn: 25,
  39572. Back_EaseOut: 26,
  39573. Back_EaseInOut: 27,
  39574. Bounce_EaseIn: 28,
  39575. Bounce_EaseOut: 29,
  39576. Bounce_EaseInOut: 30
  39577. };
  39578. ccs.ActionFrame = ccs.Class.extend({
  39579. frameType: 0,
  39580. easingType: 0,
  39581. frameIndex: 0,
  39582. frameTweenParameter: null,
  39583. time: 0,
  39584. ctor: function() {
  39585. this.time = this.frameIndex = this.easingType = this.frameType = 0
  39586. },
  39587. getAction: function(a) {
  39588. return null
  39589. },
  39590. _getEasingAction: function(a) {
  39591. if (null === a) return console.error("Action cannot be null!"), null;
  39592. var c;
  39593. switch (this.easingType) {
  39594. case ccs.FrameEaseType.Linear:
  39595. c = a;
  39596. break;
  39597. case ccs.FrameEaseType.Sine_EaseIn:
  39598. c = a.easing(cc.easeSineIn());
  39599. break;
  39600. case ccs.FrameEaseType.Sine_EaseOut:
  39601. c = a.easing(cc.easeSineOut());
  39602. break;
  39603. case ccs.FrameEaseType.Sine_EaseInOut:
  39604. c = a.easing(cc.easeSineInOut());
  39605. break;
  39606. case ccs.FrameEaseType.Quad_EaseIn:
  39607. c = a.easing(cc.easeQuadraticActionIn());
  39608. break;
  39609. case ccs.FrameEaseType.Quad_EaseOut:
  39610. c = a.easing(cc.easeQuadraticActionOut());
  39611. break;
  39612. case ccs.FrameEaseType.Quad_EaseInOut:
  39613. c = a.easing(cc.easeQuadraticActionInOut());
  39614. break;
  39615. case ccs.FrameEaseType.Cubic_EaseIn:
  39616. c = a.easing(cc.easeCubicActionIn());
  39617. break;
  39618. case ccs.FrameEaseType.Cubic_EaseOut:
  39619. c = a.easing(cc.easeCubicActionOut());
  39620. break;
  39621. case ccs.FrameEaseType.Cubic_EaseInOut:
  39622. c = a.easing(cc.easeCubicActionInOut());
  39623. break;
  39624. case ccs.FrameEaseType.Quart_EaseIn:
  39625. c = a.easing(cc.easeQuarticActionIn());
  39626. break;
  39627. case ccs.FrameEaseType.Quart_EaseOut:
  39628. c = a.easing(cc.easeQuarticActionOut());
  39629. break;
  39630. case ccs.FrameEaseType.Quart_EaseInOut:
  39631. c = a.easing(cc.easeQuarticActionInOut());
  39632. break;
  39633. case ccs.FrameEaseType.Quint_EaseIn:
  39634. c = a.easing(cc.easeQuinticActionIn());
  39635. break;
  39636. case ccs.FrameEaseType.Quint_EaseOut:
  39637. c = a.easing(cc.easeQuinticActionOut());
  39638. break;
  39639. case ccs.FrameEaseType.Quint_EaseInOut:
  39640. c = a.easing(cc.easeQuinticActionInOut());
  39641. break;
  39642. case ccs.FrameEaseType.Expo_EaseIn:
  39643. c = a.easing(cc.easeExponentialIn());
  39644. break;
  39645. case ccs.FrameEaseType.Expo_EaseOut:
  39646. c = a.easing(cc.easeExponentialOut());
  39647. break;
  39648. case ccs.FrameEaseType.Expo_EaseInOut:
  39649. c = a.easing(cc.easeExponentialInOut());
  39650. break;
  39651. case ccs.FrameEaseType.Circ_EaseIn:
  39652. c = a.easing(cc.easeCircleActionIn());
  39653. break;
  39654. case ccs.FrameEaseType.Circ_EaseOut:
  39655. c = a.easing(cc.easeCircleActionOut());
  39656. break;
  39657. case ccs.FrameEaseType.Circ_EaseInOut:
  39658. c = a.easing(cc.easeCircleActionInOut());
  39659. break;
  39660. case ccs.FrameEaseType.Elastic_EaesIn:
  39661. c = a.easing(cc.easeElasticIn());
  39662. break;
  39663. case ccs.FrameEaseType.Elastic_EaesOut:
  39664. c = a.easing(cc.easeElasticOut());
  39665. break;
  39666. case ccs.FrameEaseType.Elastic_EaesInOut:
  39667. c = a.easing(cc.easeElasticInOut());
  39668. break;
  39669. case ccs.FrameEaseType.Back_EaseIn:
  39670. c = a.easing(cc.easeBackIn());
  39671. break;
  39672. case ccs.FrameEaseType.Back_EaseOut:
  39673. c = a.easing(cc.easeBackOut());
  39674. break;
  39675. case ccs.FrameEaseType.Back_EaseInOut:
  39676. c = a.easing(cc.easeBackInOut());
  39677. break;
  39678. case ccs.FrameEaseType.Bounce_EaseIn:
  39679. c = a.easing(cc.easeBounceIn());
  39680. break;
  39681. case ccs.FrameEaseType.Bounce_EaseOut:
  39682. c = a.easing(cc.easeBounceOut());
  39683. break;
  39684. case ccs.FrameEaseType.Bounce_EaseInOut:
  39685. c = a.easing(cc.easeBounceInOut())
  39686. }
  39687. return c
  39688. },
  39689. setEasingParameter: function(a) {
  39690. this._Parameter = [];
  39691. for (var c = 0; c < a.length; c++) this._Parameter.push(a[c])
  39692. },
  39693. setEasingType: function(a) {
  39694. this._easingType = a
  39695. }
  39696. });
  39697. ccs.ActionMoveFrame = ccs.ActionFrame.extend({
  39698. _position: null,
  39699. ctor: function() {
  39700. ccs.ActionFrame.prototype.ctor.call(this);
  39701. this._position = cc.p(0, 0);
  39702. this.frameType = ccs.FRAME_TYPE_MOVE
  39703. },
  39704. setPosition: function(a, c) {
  39705. void 0 === c ? (this._position.x = a.x, this._position.y = a.y) : (this._position.x = a, this._position.y = c)
  39706. },
  39707. getPosition: function() {
  39708. return this._position
  39709. },
  39710. getAction: function(a) {
  39711. a = cc.MoveTo.create(a, this._position);
  39712. a.easingType = this.easingType || ccs.FrameEaseType.Linear;
  39713. return this._getEasingAction(a)
  39714. }
  39715. });
  39716. ccs.ActionScaleFrame = ccs.ActionFrame.extend({
  39717. _scaleX: 1,
  39718. _scaleY: 1,
  39719. ctor: function() {
  39720. ccs.ActionFrame.prototype.ctor.call(this);
  39721. this._scaleY = this._scaleX = 1;
  39722. this.frameType = ccs.FRAME_TYPE_SCALE
  39723. },
  39724. setScaleX: function(a) {
  39725. this._scaleX = a
  39726. },
  39727. getScaleX: function() {
  39728. return this._scaleX
  39729. },
  39730. setScaleY: function(a) {
  39731. this._scaleY = a
  39732. },
  39733. getScaleY: function() {
  39734. return this._scaleY
  39735. },
  39736. getAction: function(a) {
  39737. a = cc.ScaleTo.create(a, this._scaleX, this._scaleY);
  39738. a.easingType = this.easingType || ccs.FrameEaseType.Linear;
  39739. return this._getEasingAction(a)
  39740. }
  39741. });
  39742. ccs.ActionRotationFrame = ccs.ActionFrame.extend({
  39743. _rotation: 0,
  39744. ctor: function() {
  39745. ccs.ActionFrame.prototype.ctor.call(this);
  39746. this._rotation = 0;
  39747. this.frameType = ccs.FRAME_TYPE_ROTATE
  39748. },
  39749. setRotation: function(a) {
  39750. this._rotation = a
  39751. },
  39752. getRotation: function() {
  39753. return this._rotation
  39754. },
  39755. getAction: function(a) {
  39756. a = cc.RotateTo.create(a, this._rotation);
  39757. a.easingType = this.easingType || ccs.FrameEaseType.Linear;
  39758. return this._getEasingAction(a)
  39759. }
  39760. });
  39761. ccs.ActionFadeFrame = ccs.ActionFrame.extend({
  39762. _opacity: 255,
  39763. ctor: function() {
  39764. ccs.ActionFrame.prototype.ctor.call(this);
  39765. this._opacity = 255;
  39766. this.frameType = ccs.FRAME_TYPE_FADE
  39767. },
  39768. setOpacity: function(a) {
  39769. this._opacity = a
  39770. },
  39771. getOpacity: function() {
  39772. return this._opacity
  39773. },
  39774. getAction: function(a) {
  39775. a = cc.FadeTo.create(a, this._opacity);
  39776. a.easingType = this.easingType || ccs.FrameEaseType.Linear;
  39777. return this._getEasingAction(a)
  39778. }
  39779. });
  39780. ccs.ActionTintFrame = ccs.ActionFrame.extend({
  39781. _color: null,
  39782. ctor: function() {
  39783. ccs.ActionFrame.prototype.ctor.call(this);
  39784. this._color = cc.color(255, 255, 255, 255);
  39785. this.frameType = ccs.FRAME_TYPE_TINT
  39786. },
  39787. setColor: function(a) {
  39788. var c = this._color;
  39789. c.r = a.r;
  39790. c.g = a.g;
  39791. c.b = a.b
  39792. },
  39793. getColor: function() {
  39794. var a = this._color;
  39795. return cc.color(a.r, a.g, a.b, a.a)
  39796. },
  39797. getAction: function(a) {
  39798. a = cc.TintTo.create(a, this._color.r, this._color.g, this._color.b);
  39799. a.easingType = this.easingType || ccs.FrameEaseType.Linear;
  39800. return this._getEasingAction(a)
  39801. }
  39802. });
  39803. ccs.actionManager = {
  39804. _actionDic: {},
  39805. initWithDictionary: function(a, c, d) {
  39806. var e = a.lastIndexOf("/");
  39807. a = a.substr(e + 1, a.length);
  39808. c = c.actionlist;
  39809. for (var e = [], f = 0; f < c.length; f++) {
  39810. var g = new ccs.ActionObject;
  39811. g.initWithDictionary(c[f], d);
  39812. e.push(g)
  39813. }
  39814. this._actionDic[a] = e
  39815. },
  39816. getActionByName: function(a, c) {
  39817. var d = this._actionDic[a];
  39818. if (!d) return null;
  39819. for (var e = 0; e < d.length; e++) {
  39820. var f = d[e];
  39821. if (c == f.getName()) return f
  39822. }
  39823. return null
  39824. },
  39825. playActionByName: function(a, c, d) {
  39826. (a = this.getActionByName(a, c)) && a.play(d)
  39827. },
  39828. releaseActions: function() {
  39829. this._actionDic = {}
  39830. },
  39831. clear: function() {
  39832. this._actionDic = {}
  39833. }
  39834. };
  39835. ccs.ActionNode = ccs.Class.extend({
  39836. _currentFrameIndex: 0,
  39837. _destFrameIndex: 0,
  39838. _unitTime: 0,
  39839. _actionTag: 0,
  39840. _bject: null,
  39841. _actionSpawn: null,
  39842. _action: null,
  39843. _frameArray: null,
  39844. _frameArrayNum: 0,
  39845. ctor: function() {
  39846. this._destFrameIndex = this._currentFrameIndex = 0;
  39847. this._unitTime = 0.1;
  39848. this._actionTag = 0;
  39849. this._action = this._actionSpawn = this._bject = null;
  39850. this._frameArray = [];
  39851. this._frameArrayNum = ccs.FRAME_TYPE_MAX;
  39852. for (var a = 0; a < this._frameArrayNum; a++) this._frameArray.push([])
  39853. },
  39854. initWithDictionary: function(a, c) {
  39855. this.setActionTag(a.ActionTag);
  39856. for (var d = a.actionframelist, e = 0; e < d.length; e++) {
  39857. for (var f = d[e], g = f.tweenType, h = f.tweenParameter, k = [], m = 0; m < h; m++) k.push(f.tweenParameter[m]);
  39858. if (void 0 !== f.positionx) {
  39859. var m = f.positionx,
  39860. n = f.positiony,
  39861. h = new ccs.ActionMoveFrame;
  39862. h.setEasingType(g);
  39863. h.setEasingParameter(k);
  39864. h.setPosition(m, n);
  39865. m = this._frameArray[ccs.FRAME_TYPE_MOVE];
  39866. m.push(h)
  39867. }
  39868. 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));
  39869. 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));
  39870. 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));
  39871. 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))
  39872. }
  39873. this.initActionNodeFromRoot(c)
  39874. },
  39875. initActionNodeFromRoot: function(a) {
  39876. a instanceof ccui.Widget && (a = ccui.helper.seekActionWidgetByActionTag(a, this.getActionTag())) && this.setObject(a)
  39877. },
  39878. setUnitTime: function(a) {
  39879. this._unitTime = a;
  39880. this.refreshActionProperty()
  39881. },
  39882. getUnitTime: function() {
  39883. return this._unitTime
  39884. },
  39885. setActionTag: function(a) {
  39886. this._actionTag = a
  39887. },
  39888. getActionTag: function() {
  39889. return this._actionTag
  39890. },
  39891. setObject: function(a) {
  39892. this._object = a
  39893. },
  39894. getObject: function() {
  39895. return this._object
  39896. },
  39897. getActionNode: function() {
  39898. return this._object instanceof cc.Node || this._object instanceof ccui.Widget ? this._object : null
  39899. },
  39900. insertFrame: function(a, c) {
  39901. null != c && this._frameArray[c.frameType].splice(a, 0, c)
  39902. },
  39903. addFrame: function(a) {
  39904. a && this._frameArray[a.frameType].push(a)
  39905. },
  39906. deleteFrame: function(a) {
  39907. null != a && cc.arrayRemoveObject(this._frameArray[a.frameType], a)
  39908. },
  39909. clearAllFrame: function() {
  39910. for (var a = 0; a < this._frameArrayNum; a++) this._frameArray[a] = []
  39911. },
  39912. refreshActionProperty: function() {
  39913. if (null == this._object) return null;
  39914. for (var a = [], c = 0; c < this._frameArrayNum; c++) {
  39915. var d = this._frameArray[c];
  39916. if (!(0 >= d.length)) {
  39917. for (var e = [], f = 0; f < d.length; f++) {
  39918. var g = d[f];
  39919. if (0 != f) {
  39920. var h = (g.frameIndex - d[f - 1].frameIndex) * this.getUnitTime();
  39921. (g = g.getAction(h)) && e.push(g)
  39922. }
  39923. }
  39924. e && (d = cc.Sequence.create(e), null != d && a.push(d))
  39925. }
  39926. }
  39927. this._action = null;
  39928. return this._actionSpawn = cc.Spawn.create(a)
  39929. },
  39930. playAction: function(a) {
  39931. null == this._object || null == this._actionSpawn || (this._action = a ? cc.Sequence.create(this._actionSpawn, a) : cc.Sequence.create(this._actionSpawn), this.runAction())
  39932. },
  39933. runAction: function() {
  39934. var a = this.getActionNode();
  39935. null != a && null != this._action && a.runAction(this._action)
  39936. },
  39937. stopAction: function() {
  39938. var a = this.getActionNode();
  39939. null != a && null != this._action && (this._action.isDone() || a.stopAction(this._action))
  39940. },
  39941. getFirstFrameIndex: function() {
  39942. for (var a = 99999, c = !1, d = 0; d < this._frameArrayNum; d++) {
  39943. var e = this._frameArray[d];
  39944. 0 >= e.length || (c = !0, e = e[0].frameIndex, a = a > e ? e : a)
  39945. }
  39946. c || (a = 0);
  39947. return a
  39948. },
  39949. getLastFrameIndex: function() {
  39950. for (var a = -1, c = !1, d = 0; d < this._frameArrayNum; d++) {
  39951. var e = this._frameArray[d];
  39952. 0 >= e.length || (c = !0, e = e[e.length - 1].frameIndex, a = a < e ? e : a)
  39953. }
  39954. c || (a = 0);
  39955. return a
  39956. },
  39957. updateActionToTimeLine: function(a) {
  39958. for (var c = !1, d = this.getUnitTime(), e = 0; e < this._frameArrayNum; e++) {
  39959. var f = this._frameArray[e];
  39960. if (null != f)
  39961. for (var g = 0; g < f.length; g++) {
  39962. var h = f[g];
  39963. if (h.frameIndex * d == a) {
  39964. this.easingToFrame(1, 1, h);
  39965. c = !0;
  39966. break
  39967. } else if (h.frameIndex * d > a) {
  39968. 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);
  39969. break
  39970. }
  39971. }
  39972. }
  39973. return c
  39974. },
  39975. easingToFrame: function(a, c, d) {
  39976. a = d.getAction(a);
  39977. d = this.getActionNode();
  39978. null == a || null == d || (a.startWithTarget(d), a.update(c))
  39979. },
  39980. isActionDoneOnce: function() {
  39981. return null == this._action ? !0 : this._action.isDone()
  39982. }
  39983. });
  39984. ccs.ActionObject = ccs.Class.extend({
  39985. _actionNodeList: null,
  39986. _name: "",
  39987. _loop: !1,
  39988. _pause: !1,
  39989. _playing: !1,
  39990. _unitTime: 0,
  39991. _currentTime: 0,
  39992. _scheduler: null,
  39993. _fTotalTime: 0,
  39994. ctor: function() {
  39995. this._actionNodeList = [];
  39996. this._name = "";
  39997. this._playing = this._pause = this._loop = !1;
  39998. this._unitTime = 0.1;
  39999. this._fTotalTime = this._currentTime = 0;
  40000. this._scheduler = new cc.Scheduler;
  40001. cc.director.getScheduler().scheduleUpdateForTarget(this._scheduler, 0, !1)
  40002. },
  40003. setName: function(a) {
  40004. this._name = a
  40005. },
  40006. getName: function() {
  40007. return this._name
  40008. },
  40009. setLoop: function(a) {
  40010. this._loop = a
  40011. },
  40012. getLoop: function() {
  40013. return this._loop
  40014. },
  40015. setUnitTime: function(a) {
  40016. this._unitTime = a;
  40017. a = this._actionNodeList.length;
  40018. for (var c = 0; c < a; c++) this._actionNodeList[c].setUnitTime(this._unitTime)
  40019. },
  40020. getUnitTime: function() {
  40021. return this._unitTime
  40022. },
  40023. getCurrentTime: function() {
  40024. return this._currentTime
  40025. },
  40026. setCurrentTime: function(a) {
  40027. this._currentTime = a
  40028. },
  40029. getTotalTime: function() {
  40030. return this._fTotalTime
  40031. },
  40032. isPlaying: function() {
  40033. return this._playing
  40034. },
  40035. initWithDictionary: function(a, c) {
  40036. this.setName(a.name);
  40037. this.setLoop(a.loop);
  40038. this.setUnitTime(a.unittime);
  40039. for (var d = a.actionnodelist, e = 0, f = 0; f < d.length; f++) {
  40040. var g = new ccs.ActionNode;
  40041. g.initWithDictionary(d[f], c);
  40042. g.setUnitTime(this.getUnitTime());
  40043. this._actionNodeList.push(g);
  40044. g = g.getLastFrameIndex() - g.getFirstFrameIndex();
  40045. g > e && (e = g)
  40046. }
  40047. this._fTotalTime = e * this._unitTime
  40048. },
  40049. addActionNode: function(a) {
  40050. a && (this._actionNodeList.push(a), a.setUnitTime(this._unitTime))
  40051. },
  40052. removeActionNode: function(a) {
  40053. null != a && cc.arrayRemoveObject(this._actionNodeList, a)
  40054. },
  40055. play: function(a) {
  40056. this.stop();
  40057. this.updateToFrameByTime(0);
  40058. for (var c = this._actionNodeList.length, d = 0; d < c; d++) this._actionNodeList[d].playAction(a);
  40059. this._loop && this._scheduler.scheduleCallbackForTarget(this, this.simulationActionUpdate, 0, cc.REPEAT_FOREVER, 0, !1)
  40060. },
  40061. pause: function() {
  40062. this._pause = !0
  40063. },
  40064. stop: function() {
  40065. for (var a = 0; a < this._actionNodeList.length; a++) this._actionNodeList[a].stopAction();
  40066. this._scheduler.unscheduleCallbackForTarget(this, this.simulationActionUpdate);
  40067. this._pause = !1
  40068. },
  40069. updateToFrameByTime: function(a) {
  40070. this._currentTime = a;
  40071. for (var c = 0; c < this._actionNodeList.length; c++) this._actionNodeList[c].updateActionToTimeLine(a)
  40072. },
  40073. simulationActionUpdate: function(a) {
  40074. if (this._loop) {
  40075. a = !0;
  40076. for (var c = this._actionNodeList, d = 0; d < c.length; d++)
  40077. if (!1 == c[d].isActionDoneOnce()) {
  40078. a = !1;
  40079. break
  40080. }
  40081. a && this.play()
  40082. }
  40083. }
  40084. });
  40085. ccs.ComAttribute = ccs.Component.extend({
  40086. _jsonDict: null,
  40087. _filePath: "",
  40088. ctor: function() {
  40089. cc.Component.prototype.ctor.call(this);
  40090. this._jsonDict = {};
  40091. this._filePath = "";
  40092. this._name = "CCComAttribute"
  40093. },
  40094. init: function() {
  40095. this._jsonDict = {};
  40096. return !0
  40097. },
  40098. setInt: function(a, c) {
  40099. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40100. },
  40101. setDouble: function(a, c) {
  40102. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40103. },
  40104. setFloat: function(a, c) {
  40105. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40106. },
  40107. setBool: function(a, c) {
  40108. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40109. },
  40110. setString: function(a, c) {
  40111. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40112. },
  40113. setObject: function(a, c) {
  40114. a ? this._jsonDict[a] = c : cc.log("Argument must be non-nil")
  40115. },
  40116. getInt: function(a) {
  40117. return parseInt(this._jsonDict[a] || 0)
  40118. },
  40119. getDouble: function(a) {
  40120. return parseFloat(this._jsonDict[a] || 0)
  40121. },
  40122. getFloat: function(a) {
  40123. return parseFloat(this._jsonDict[a] || 0)
  40124. },
  40125. getBool: function(a) {
  40126. return Boolean(this._jsonDict[a] || !1)
  40127. },
  40128. getString: function(a) {
  40129. return this._jsonDict[a] || ""
  40130. },
  40131. getObject: function(a) {
  40132. return this._jsonDict[a]
  40133. },
  40134. parse: function(a) {
  40135. this._jsonDict = cc.loader.getRes(a)
  40136. }
  40137. });
  40138. ccs.ComAttribute.create = function() {
  40139. var a = new ccs.ComAttribute;
  40140. return a && a.init() ? a : null
  40141. };
  40142. ccs.ComAudio = ccs.Component.extend({
  40143. _filePath: "",
  40144. _loop: !1,
  40145. ctor: function() {
  40146. cc.Component.prototype.ctor.call(this);
  40147. this._name = "Audio"
  40148. },
  40149. init: function() {
  40150. return !0
  40151. },
  40152. onEnter: function() {},
  40153. onExit: function() {
  40154. this.stopBackgroundMusic(!0);
  40155. this.stopAllEffects()
  40156. },
  40157. end: function() {
  40158. cc.audioEngine.end()
  40159. },
  40160. preloadBackgroundMusic: function(a) {
  40161. cc.loader.load(a)
  40162. },
  40163. playBackgroundMusic: function(a, c) {
  40164. a ? cc.audioEngine.playMusic(a, c) : cc.audioEngine.playMusic(this._filePath, this._loop)
  40165. },
  40166. stopBackgroundMusic: function(a) {
  40167. cc.audioEngine.stopMusic(a)
  40168. },
  40169. pauseBackgroundMusic: function() {
  40170. cc.audioEngine.pauseMusic()
  40171. },
  40172. resumeBackgroundMusic: function() {
  40173. cc.audioEngine.resumeMusic()
  40174. },
  40175. rewindBackgroundMusic: function() {
  40176. cc.audioEngine.rewindMusic()
  40177. },
  40178. willPlayBackgroundMusic: function() {
  40179. return cc.audioEngine.willPlayMusic()
  40180. },
  40181. isBackgroundMusicPlaying: function() {
  40182. return cc.audioEngine.isMusicPlaying()
  40183. },
  40184. getBackgroundMusicVolume: function() {
  40185. return cc.audioEngine.getMusicVolume()
  40186. },
  40187. setBackgroundMusicVolume: function(a) {
  40188. cc.audioEngine.setMusicVolume(a)
  40189. },
  40190. getEffectsVolume: function() {
  40191. return cc.audioEngine.getEffectsVolume()
  40192. },
  40193. setEffectsVolume: function(a) {
  40194. cc.audioEngine.setEffectsVolume(a)
  40195. },
  40196. playEffect: function(a, c) {
  40197. return a ? cc.audioEngine.playEffect(a, c) : cc.audioEngine.playEffect(this._filePath, this._loop)
  40198. },
  40199. pauseEffect: function(a) {
  40200. cc.audioEngine.pauseEffect(a)
  40201. },
  40202. pauseAllEffects: function() {
  40203. cc.audioEngine.pauseAllEffects()
  40204. },
  40205. resumeEffect: function(a) {
  40206. cc.audioEngine.resumeEffect(a)
  40207. },
  40208. resumeAllEffects: function() {
  40209. cc.audioEngine.resumeAllEffects()
  40210. },
  40211. stopEffect: function(a) {
  40212. cc.audioEngine.stopEffect(a)
  40213. },
  40214. stopAllEffects: function() {
  40215. cc.audioEngine.stopAllEffects()
  40216. },
  40217. preloadEffect: function(a) {
  40218. cc.loader.getRes(a);
  40219. this.setFile(a);
  40220. this.setLoop(!1)
  40221. },
  40222. unloadEffect: function(a) {
  40223. cc.audioEngine.unloadEffect(a)
  40224. },
  40225. setFile: function(a) {
  40226. this._filePath = a
  40227. },
  40228. setLoop: function(a) {
  40229. this._loop = a
  40230. },
  40231. getFile: function() {
  40232. return this._filePath
  40233. },
  40234. isLoop: function() {
  40235. return this._loop
  40236. }
  40237. });
  40238. ccs.ComAudio.create = function() {
  40239. var a = new ccs.ComAudio;
  40240. return a && a.init() ? a : null
  40241. };
  40242. ccs.ComController = ccs.Component.extend({
  40243. ctor: function() {
  40244. cc.Component.prototype.ctor.call(this);
  40245. this._name = "ComController"
  40246. },
  40247. init: function() {
  40248. return !0
  40249. },
  40250. onEnter: function() {
  40251. null != this._owner && this._owner.scheduleUpdate()
  40252. },
  40253. onExit: function() {},
  40254. update: function(a) {},
  40255. isEnabled: function() {
  40256. return this._enabled
  40257. },
  40258. setEnabled: function(a) {
  40259. this._enabled = b
  40260. }
  40261. });
  40262. ccs.ComController.create = function() {
  40263. var a = new ccs.ComController;
  40264. return a && a.init() ? a : null
  40265. };
  40266. ccs.ComRender = ccs.Component.extend({
  40267. _render: null,
  40268. ctor: function(a, c) {
  40269. cc.Component.prototype.ctor.call(this);
  40270. this._render = a;
  40271. this._name = c;
  40272. this.isRenderer = !0
  40273. },
  40274. onEnter: function() {
  40275. this._owner && this._owner.addChild(this._render)
  40276. },
  40277. onExit: function() {
  40278. this._owner && (this._owner.removeChild(this._render, !0), this._render = null)
  40279. },
  40280. getNode: function() {
  40281. return this._render
  40282. },
  40283. setNode: function(a) {
  40284. this._render = a
  40285. }
  40286. });
  40287. ccs.ComRender.create = function(a, c) {
  40288. var d = new ccs.ComRender(a, c);
  40289. return d && d.init() ? d : null
  40290. };
  40291. ccs.objectFactory = {
  40292. _typeMap: {},
  40293. destroyInstance: function() {
  40294. this._instance = null
  40295. },
  40296. createObject: function(a) {
  40297. var c = null;
  40298. (a = this._typeMap[a]) && (c = "function" == typeof a._fun ? new a._fun : a._fun);
  40299. return c
  40300. },
  40301. registerType: function(a) {
  40302. this._typeMap[a._className] = a
  40303. },
  40304. createGUI: function(a) {
  40305. var c = null;
  40306. "Panel" === a ? a = "Layout" : "TextArea" === a ? a = "Label" : "TextButton" === a && (a = "Button");
  40307. if ((a = this._typeMap[a]) && a._fun) c = a._fun;
  40308. return c
  40309. },
  40310. createWidgetReaderProtocol: function(a) {
  40311. var c = null;
  40312. if ((a = this._typeMap[a]) && a._fun) c = a._fun;
  40313. return c
  40314. }
  40315. };
  40316. ccs.TInfo = ccs.Class.extend({
  40317. _className: "",
  40318. _fun: null,
  40319. ctor: function(a, c) {
  40320. c ? (this._className = a, this._fun = c) : (this._className = a._className, this._fun = a._fun);
  40321. ccs.objectFactory.registerType(this)
  40322. }
  40323. });
  40324. ccs.sendEvent = function(a) {
  40325. a = ccs.triggerManager.get(a);
  40326. if (null != a)
  40327. for (var c = 0; c < a.length; c++) {
  40328. var d = a[c];
  40329. null != d && d.detect() && d.done()
  40330. }
  40331. };
  40332. ccs.registerTriggerClass = function(a, c) {
  40333. new ccs.TInfo(a, c)
  40334. };
  40335. ccs.triggerManager = {
  40336. _eventTriggers: {},
  40337. _triggerObjs: {},
  40338. _movementDispatches: [],
  40339. destroyInstance: function() {
  40340. this.removeAll();
  40341. this._instance = null
  40342. },
  40343. parse: function(a) {
  40344. for (var c = 0; c < a.length; ++c) {
  40345. var d = a[c],
  40346. e = ccs.TriggerObj.create();
  40347. e.serialize(d);
  40348. for (var d = e.getEvents(), f = 0; f < d.length; f++) this.add(d[f], e);
  40349. this._triggerObjs[e.getId()] = e
  40350. }
  40351. },
  40352. get: function(a) {
  40353. return this._eventTriggers[a]
  40354. },
  40355. getTriggerObj: function(a) {
  40356. return this._triggerObjs[a]
  40357. },
  40358. add: function(a, c) {
  40359. var d = this._eventTriggers[a];
  40360. d || (d = []); - 1 == d.indexOf(c) && (d.push(c), this._eventTriggers[a] = d)
  40361. },
  40362. removeAll: function() {
  40363. for (var a in this._eventTriggers)
  40364. for (var c = this._eventTriggers[a], d = 0; d < c.length; d++) c[d].removeAll();
  40365. this._eventTriggers = {}
  40366. },
  40367. remove: function(a, c) {
  40368. if (c) return this._removeObj(a, c);
  40369. var d = !1,
  40370. e = this._eventTriggers[a];
  40371. if (e) {
  40372. for (d = 0; d < e.length; d++) {
  40373. var f = e[d];
  40374. f && f.removeAll()
  40375. }
  40376. delete this._eventTriggers[a];
  40377. d = !0
  40378. }
  40379. return d
  40380. },
  40381. _removeObj: function(a, c) {
  40382. var d = !1;
  40383. do {
  40384. var e = this._eventTriggers[a];
  40385. if (e) {
  40386. for (d = 0; d < e.length; d++) {
  40387. var f = e[d];
  40388. if (f && f == c) {
  40389. f.removeAll();
  40390. e.splice(d, 1);
  40391. break
  40392. }
  40393. }
  40394. d = !0
  40395. }
  40396. } while (0);
  40397. return d
  40398. },
  40399. removeTriggerObj: function(a) {
  40400. a = this.getTriggerObj(a);
  40401. if (!a) return !1;
  40402. for (var c = a.getEvents(), d = 0; d < c.length; d++) this.remove(c[d], a);
  40403. return !0
  40404. },
  40405. isEmpty: function() {
  40406. return !this._eventTriggers || 0 >= this._eventTriggers.length
  40407. },
  40408. addArmatureMovementCallBack: function(a, c, d) {
  40409. if (!(null == a || null == d || null == c)) {
  40410. for (var e, f = !1, g = 0; g < this._movementDispatches.length; g++)
  40411. if ((e = this._movementDispatches[g]) && e[0] == a) e.addAnimationEventCallBack(c, d), f = !0;
  40412. f || (e = new ccs.ArmatureMovementDispatcher, a.getAnimation().setMovementEventCallFunc(e.animationEvent, e), e.addAnimationEventCallBack(c, d), this._movementDispatches.push([a, e]))
  40413. }
  40414. },
  40415. removeArmatureMovementCallBack: function(a, c, d) {
  40416. if (!(null == a || null == c || null == d))
  40417. for (var e, f = 0; f < this._movementDispatches.length; f++)(e = this._movementDispatches[f]) && e[0] == a && e.removeAnimationEventCallBack(d, c)
  40418. },
  40419. removeArmatureAllMovementCallBack: function(a) {
  40420. if (null != a)
  40421. for (var c, d = 0; d < this._movementDispatches.length; d++)
  40422. if ((c = this._movementDispatches[d]) && c[0] == a) {
  40423. this._movementDispatches.splice(d, 1);
  40424. break
  40425. }
  40426. },
  40427. removeAllArmatureMovementCallBack: function() {
  40428. this._movementDispatches = []
  40429. },
  40430. version: function() {
  40431. return "1.2.0.0"
  40432. }
  40433. };
  40434. ccs.ArmatureMovementDispatcher = ccs.Class.extend({
  40435. _mapEventAnimation: null,
  40436. ctor: function() {
  40437. this._mapEventAnimation = []
  40438. },
  40439. animationEvent: function(a, c, d) {
  40440. 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)
  40441. },
  40442. addAnimationEventCallBack: function(a, c) {
  40443. this._mapEventAnimation.push([c, a])
  40444. },
  40445. removeAnimationEventCallBack: function(a, c) {
  40446. for (var d, e = 0; e < this._mapEventAnimation.length; e++) d = this._mapEventAnimation[e], d[0] == c && this._mapEventAnimation.splice(e, 1)
  40447. }
  40448. });
  40449. ccs.BaseTriggerCondition = ccs.Class.extend({
  40450. ctor: function() {},
  40451. init: function() {
  40452. return !0
  40453. },
  40454. detect: function() {
  40455. return !0
  40456. },
  40457. serialize: function(a) {},
  40458. removeAll: function() {}
  40459. });
  40460. ccs.BaseTriggerAction = ccs.Class.extend({
  40461. ctor: function() {},
  40462. init: function() {
  40463. return !0
  40464. },
  40465. done: function() {},
  40466. serialize: function(a) {},
  40467. removeAll: function() {}
  40468. });
  40469. ccs.TriggerObj = ccs.Class.extend({
  40470. _cons: null,
  40471. _acts: null,
  40472. _id: 0,
  40473. _enable: !0,
  40474. _vInt: null,
  40475. ctor: function() {
  40476. this._id = 0;
  40477. this._enable = !0
  40478. },
  40479. init: function() {
  40480. this._cons = [];
  40481. this._acts = [];
  40482. this._vInt = [];
  40483. return !0
  40484. },
  40485. detect: function() {
  40486. if (!this._enable || 0 == this._cons.length) return !0;
  40487. for (var a = !0, c = null, d = 0; d < this._cons.length; d++)(c = this._cons[d]) && c.detect && (a = a && c.detect());
  40488. return a
  40489. },
  40490. done: function() {
  40491. if (this._enable && 0 != this._acts.length)
  40492. for (var a, c = 0; c < this._acts.length; c++)(a = this._acts[c]) && a.done && a.done()
  40493. },
  40494. removeAll: function() {
  40495. for (var a = null, c = 0; c < this._cons.length; c++)(a = this._cons[c]) && a.removeAll();
  40496. this._cons = [];
  40497. for (c = 0; c < this._acts.length; c++)(a = this._acts[c]) && a.removeAll();
  40498. this._acts = []
  40499. },
  40500. serialize: function(a) {
  40501. this._id = a.id || 0;
  40502. for (var c = a.conditions || [], d = 0; d < c.length; d++) {
  40503. var e = c[d],
  40504. f = e.classname,
  40505. g = ccs.objectFactory.createObject(f);
  40506. g ? (g.serialize(e), g.init(), this._cons.push(g)) : cc.log("class named classname(" + f + ") can not implement!")
  40507. }
  40508. c = a.actions || [];
  40509. 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!");
  40510. a = a.events || [];
  40511. for (d = 0; d < a.length; d++) e = a[d], e = e.id, 0 > e || this._vInt.push(e)
  40512. },
  40513. getId: function() {
  40514. return this._id
  40515. },
  40516. setEnable: function(a) {
  40517. this._enable = a
  40518. },
  40519. getEvents: function() {
  40520. return this._vInt
  40521. }
  40522. });
  40523. ccs.TriggerObj.create = function() {
  40524. var a = new ccs.TriggerObj;
  40525. return a.init() ? a : null
  40526. };
  40527. ccs.ButtonReader = {
  40528. getInstance: function() {
  40529. return ccs.ButtonReader
  40530. },
  40531. setPropsFromJsonDictionary: function(a, c) {
  40532. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40533. var d = ccs.uiReader.getFilePath(),
  40534. e = c.scale9Enable;
  40535. a.setScale9Enabled(e);
  40536. var f = c.normalData;
  40537. switch (f.resourceType) {
  40538. case 0:
  40539. f = f.path;
  40540. a.loadTextureNormal(f && "" !== f ? d + f : null);
  40541. break;
  40542. case 1:
  40543. f = f.path, a.loadTextureNormal(f, 1)
  40544. }
  40545. f = c.pressedData;
  40546. switch (f.resourceType) {
  40547. case 0:
  40548. f = f.path;
  40549. a.loadTexturePressed(f && "" !== f ? d + f : null);
  40550. break;
  40551. case 1:
  40552. f = f.path, a.loadTexturePressed(f, 1)
  40553. }
  40554. f = c.disabledData;
  40555. switch (f.resourceType) {
  40556. case 0:
  40557. f = f.path;
  40558. a.loadTextureDisabled(f && "" !== f ? d + f : null);
  40559. break;
  40560. case 1:
  40561. f = f.path, a.loadTextureDisabled(f, 1)
  40562. }
  40563. 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)));
  40564. d = c.text;
  40565. null != d && a.setTitleText(d);
  40566. a.setTitleColor(cc.color(c.textColorR ? c.textColorR : 255, c.textColorG ? c.textColorG : 255, c.textColorB ? c.textColorB : 255));
  40567. null != c.fontSize && a.setTitleFontSize(c.fontSize);
  40568. c.fontName && a.setTitleFontName(c.fontName);
  40569. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40570. }
  40571. };
  40572. ccs.CheckBoxReader = {
  40573. getInstance: function() {
  40574. return ccs.CheckBoxReader
  40575. },
  40576. setPropsFromJsonDictionary: function(a, c) {
  40577. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40578. var d = c.backGroundBoxData,
  40579. e = d.resourceType,
  40580. d = ccs.WidgetReader.getResourcePath(d, "path", e);
  40581. a.loadTextureBackGround(d, e);
  40582. var f = c.backGroundBoxSelectedData,
  40583. g = f.resourceType,
  40584. f = ccs.WidgetReader.getResourcePath(f, "path", g);
  40585. f || (g = e, f = d);
  40586. a.loadTextureBackGroundSelected(f, g);
  40587. d = c.frontCrossData;
  40588. e = d.resourceType;
  40589. d = ccs.WidgetReader.getResourcePath(d, "path", e);
  40590. a.loadTextureFrontCross(d, e);
  40591. f = c.backGroundBoxDisabledData;
  40592. g = f.resourceType;
  40593. f = ccs.WidgetReader.getResourcePath(f, "path", g);
  40594. f || (g = e, f = d);
  40595. a.loadTextureBackGroundDisabled(f, g);
  40596. d = c.frontCrossDisabledData;
  40597. e = d.resourceType;
  40598. d = ccs.WidgetReader.getResourcePath(d, "path", e);
  40599. a.loadTextureFrontCrossDisabled(d, e);
  40600. c.selectedState && a.setSelectedState(c.selectedState);
  40601. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40602. }
  40603. };
  40604. ccs.ImageViewReader = {
  40605. getInstance: function() {
  40606. return ccs.ImageViewReader
  40607. },
  40608. setPropsFromJsonDictionary: function(a, c) {
  40609. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40610. var d = ccs.uiReader.getFilePath(),
  40611. e = c.fileNameData;
  40612. switch (e.resourceType) {
  40613. case 0:
  40614. (e = e.path) && "" !== e && a.loadTexture(d + e);
  40615. break;
  40616. case 1:
  40617. e = e.path, a.loadTexture(e, 1)
  40618. }
  40619. d = !1;
  40620. c.scale9Enable && (d = c.scale9Enable);
  40621. a.setScale9Enabled(d);
  40622. 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)));
  40623. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40624. }
  40625. };
  40626. ccs.LabelAtlasReader = {
  40627. getInstance: function() {
  40628. return ccs.LabelAtlasReader
  40629. },
  40630. setPropsFromJsonDictionary: function(a, c) {
  40631. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40632. var d = ccs.uiReader.getFilePath(),
  40633. e = c.charMapFileData || c.charMapFile,
  40634. f = c.itemWidth,
  40635. g = c.itemHeight,
  40636. h = c.startCharMap;
  40637. if (null != c.stringValue && e && null != f && null != g && null != h) switch (e = c.charMapFileData, e.resourceType) {
  40638. case 0:
  40639. a.setProperty(c.stringValue, d + e.path, c.itemWidth, c.itemHeight, c.startCharMap);
  40640. break;
  40641. case 1:
  40642. cc.log("Wrong res type of LabelAtlas!")
  40643. }
  40644. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40645. }
  40646. };
  40647. ccs.LabelBMFontReader = {
  40648. getInstance: function() {
  40649. return ccs.LabelBMFontReader
  40650. },
  40651. setPropsFromJsonDictionary: function(a, c) {
  40652. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40653. var d = ccs.uiReader.getFilePath(),
  40654. e = c.fileNameData;
  40655. switch (e.resourceType) {
  40656. case 0:
  40657. a.setFntFile(d + e.path);
  40658. break;
  40659. case 1:
  40660. cc.log("Wrong res type of LabelAtlas!")
  40661. }
  40662. a.setString(c.text);
  40663. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40664. }
  40665. };
  40666. ccs.LabelReader = {
  40667. getInstance: function() {
  40668. return ccs.LabelReader
  40669. },
  40670. setPropsFromJsonDictionary: function(a, c) {
  40671. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40672. a.setTouchScaleChangeEnabled(c.touchScaleEnable);
  40673. a.setString(c.text);
  40674. null != c.fontSize && a.setFontSize(c.fontSize);
  40675. null != c.fontName && a.setFontName(c.fontName);
  40676. var d = c.areaHeight;
  40677. null != c.areaWidth && null != d && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
  40678. null != c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
  40679. null != c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
  40680. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40681. }
  40682. };
  40683. ccs.LayoutReader = {
  40684. getInstance: function() {
  40685. return ccs.LayoutReader
  40686. },
  40687. setPropsFromJsonDictionary: function(a, c) {
  40688. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40689. var d = ccs.uiReader.getFilePath(),
  40690. e = 0,
  40691. f = 0;
  40692. c.adaptScreen ? (f = cc.director.getWinSize(), e = f.width, f = f.height) : (e = c.width, f = c.height);
  40693. a.setSize(cc.size(e, f));
  40694. a.setClippingEnabled(c.clipAble);
  40695. e = c.backGroundScale9Enable;
  40696. a.setBackGroundImageScale9Enabled(e);
  40697. var f = c.bgColorR,
  40698. g = c.bgColorG,
  40699. h = c.bgColorB,
  40700. k = c.bgStartColorR,
  40701. m = c.bgStartColorG,
  40702. n = c.bgStartColorB,
  40703. q = c.bgEndColorR,
  40704. r = c.bgEndColorG,
  40705. t = c.bgEndColorB;
  40706. a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
  40707. var s = c.bgColorOpacity;
  40708. a.setBackGroundColorType(c.colorType);
  40709. a.setBackGroundColor(cc.color(k, m, n), cc.color(q, r, t));
  40710. a.setBackGroundColor(cc.color(f, g, h));
  40711. a.setBackGroundColorOpacity(s);
  40712. if (f = c.backGroundImageData) switch (f.resourceType) {
  40713. case 0:
  40714. f = f.path;
  40715. a.setBackGroundImage(f && "" !== f ? d + f : null);
  40716. break;
  40717. case 1:
  40718. f = f.path, a.setBackGroundImage(f, 1)
  40719. }
  40720. e && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
  40721. a.setLayoutType(c.layoutType);
  40722. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40723. }
  40724. };
  40725. ccs.ScrollViewReader = {
  40726. getInstance: function() {
  40727. return ccs.ScrollViewReader
  40728. },
  40729. setPropsFromJsonDictionary: function(a, c) {
  40730. ccs.LayoutReader.setPropsFromJsonDictionary.call(this, a, c);
  40731. a.setInnerContainerSize(cc.size(c.innerWidth || 200, c.innerHeight || 200));
  40732. a.setDirection(c.direction || 1);
  40733. a.setBounceEnabled(c.bounceEnable);
  40734. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40735. }
  40736. };
  40737. ccs.ListViewReader = {
  40738. getInstance: function() {
  40739. return ccs.ListViewReader
  40740. },
  40741. setPropsFromJsonDictionary: function(a, c) {
  40742. ccs.ScrollViewReader.setPropsFromJsonDictionary.call(this, a, c);
  40743. a.setDirection(c.direction);
  40744. a.setGravity(c.gravity);
  40745. a.setItemsMargin(c.itemMargin)
  40746. }
  40747. };
  40748. ccs.LoadingBarReader = {
  40749. getInstance: function() {
  40750. return ccs.LoadingBarReader
  40751. },
  40752. setPropsFromJsonDictionary: function(a, c) {
  40753. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40754. var d = ccs.uiReader.getFilePath(),
  40755. e = c.textureData;
  40756. switch (e.resourceType) {
  40757. case 0:
  40758. (e = e.path) && "" !== e && a.loadTexture(d + e);
  40759. break;
  40760. case 1:
  40761. e = e.path, a.loadTexture(e, 1)
  40762. }
  40763. d = c.scale9Enable;
  40764. a.setScale9Enabled(d);
  40765. d && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), a.setSize(cc.size(c.width, c.height)));
  40766. a.setDirection(c.direction);
  40767. a.setPercent(c.percent);
  40768. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40769. }
  40770. };
  40771. ccs.PageViewReader = {
  40772. instancePageViewReader: null,
  40773. getInstance: function() {
  40774. return ccs.PageViewReader
  40775. },
  40776. setPropsFromJsonDictionary: function(a, c) {
  40777. ccs.LayoutReader.setPropsFromJsonDictionary.call(this, a, c)
  40778. }
  40779. };
  40780. ccs.SliderReader = {
  40781. getInstance: function() {
  40782. return ccs.SliderReader
  40783. },
  40784. setPropsFromJsonDictionary: function(a, c) {
  40785. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40786. var d = ccs.uiReader.getFilePath(),
  40787. e = c.scale9Enable;
  40788. a.setScale9Enabled(e);
  40789. var f = c.length,
  40790. g = c.barFileNameData,
  40791. h = g.resourceType,
  40792. g = g.path;
  40793. if (null != c.barFileName) {
  40794. if (e) {
  40795. switch (h) {
  40796. case 0:
  40797. a.loadBarTexture(g ? d + g : null);
  40798. break;
  40799. case 1:
  40800. a.loadBarTexture(g, 1)
  40801. }
  40802. a.setSize(cc.size(f, a.getContentSize().height))
  40803. }
  40804. } else switch (h) {
  40805. case 0:
  40806. a.loadBarTexture(g ? d + g : null);
  40807. break;
  40808. case 1:
  40809. a.loadBarTexture(g, 1)
  40810. }
  40811. f = c.ballNormalData;
  40812. e = f.resourceType;
  40813. f = f.path;
  40814. switch (e) {
  40815. case 0:
  40816. a.loadSlidBallTextureNormal(f ? d + f : null);
  40817. break;
  40818. case 1:
  40819. a.loadSlidBallTextureNormal(f, 1)
  40820. }
  40821. g = c.ballPressedData;
  40822. h = g.resourceType;
  40823. g = g.path;
  40824. null === g && (h = e, g = f);
  40825. switch (h) {
  40826. case 0:
  40827. a.loadSlidBallTexturePressed(g ? d + g : null);
  40828. break;
  40829. case 1:
  40830. a.loadSlidBallTexturePressed(g, 1)
  40831. }
  40832. e = c.ballDisabledData;
  40833. f = e.path;
  40834. switch (e.resourceType) {
  40835. case 0:
  40836. a.loadSlidBallTextureDisabled(f ? d + f : null);
  40837. break;
  40838. case 1:
  40839. a.loadSlidBallTextureDisabled(f, 1)
  40840. }
  40841. e = c.progressBarData;
  40842. f = e.path;
  40843. switch (e.resourceType) {
  40844. case 0:
  40845. a.loadProgressBarTexture(f ? d + f : null);
  40846. break;
  40847. case 1:
  40848. a.loadProgressBarTexture(f, 1)
  40849. }
  40850. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40851. }
  40852. };
  40853. ccs.TextFieldReader = {
  40854. getInstance: function() {
  40855. return ccs.TextFieldReader
  40856. },
  40857. setPropsFromJsonDictionary: function(a, c) {
  40858. ccs.WidgetReader.setPropsFromJsonDictionary.call(this, a, c);
  40859. var d = c.placeHolder;
  40860. d && a.setPlaceHolder(d);
  40861. a.setString(c.text);
  40862. (d = c.fontSize1) && a.setFontSize(d);
  40863. (d = c.fontName) && a.setFontName(d);
  40864. var d = c.touchSizeWidth,
  40865. e = c.touchSizeHeight;
  40866. d && e && a.setTouchSize(d, e);
  40867. d = c.maxLengthEnable;
  40868. a.setMaxLengthEnabled(d);
  40869. d && a.setMaxLength(c.maxLength);
  40870. d = c.passwordEnable;
  40871. a.setPasswordEnabled(d);
  40872. d && a.setPasswordStyleText(c.passwordStyleText);
  40873. d = c.areaWidth;
  40874. e = c.areaHeight;
  40875. d && e && (d = cc.size(d, e), a.setTextAreaSize(d));
  40876. (d = c.hAlignment) && a.setTextHorizontalAlignment(d);
  40877. (d = c.vAlignment) && a.setTextVerticalAlignment(d);
  40878. ccs.WidgetReader.setColorPropsFromJsonDictionary.call(this, a, c)
  40879. }
  40880. };
  40881. ccs.WidgetReaderProtocol = ccs.Class.extend({
  40882. setPropsFromJsonDictionary: function(a, c) {}
  40883. });
  40884. ccs.WidgetReader = {
  40885. getInstance: function() {
  40886. return ccs.WidgetReader
  40887. },
  40888. setPropsFromJsonDictionary: function(a, c) {
  40889. var d = c.ignoreSize;
  40890. null != d && a.ignoreContentAdaptWithSize(d);
  40891. a.setSizeType(c.sizeType);
  40892. a.setPositionType(c.positionType);
  40893. a.setSizePercent(cc.p(c.sizePercentX, c.sizePercentY));
  40894. a.setPositionPercent(cc.p(c.positionPercentX, c.positionPercentY));
  40895. var e = d = 0;
  40896. c.adaptScreen ? (e = cc.director.getWinSize(), d = e.width, e = e.height) : (d = c.width, e = c.height);
  40897. a.setContentSize(d, e);
  40898. a.setTag(c.tag);
  40899. a.setActionTag(c.actiontag);
  40900. a.setTouchEnabled(c.touchAble);
  40901. d = c.name;
  40902. a.setName(d ? d : "default");
  40903. a.setPosition(c.x, c.y);
  40904. a.setScaleX(c.scaleX || 1);
  40905. a.setScaleY(c.scaleY || 1);
  40906. a.setRotation(c.rotation || 0);
  40907. d = c.visible || !1;
  40908. null != d && a.setVisible(d);
  40909. a.setLocalZOrder(c.ZOrder);
  40910. if (null != c.layoutParameter) {
  40911. d = c.layoutParameter;
  40912. e = null;
  40913. switch (d.type) {
  40914. case 1:
  40915. e = new ccui.LinearLayoutParameter;
  40916. e.setGravity(d.gravity);
  40917. break;
  40918. case 2:
  40919. var f = e = new ccui.RelativeLayoutParameter;
  40920. f.setRelativeName(d.relativeName);
  40921. f.setRelativeToWidgetName(d.relativeToName);
  40922. f.setAlign(d.align)
  40923. }
  40924. null != e && (e.setMargin(d.marginLeft || 0, d.marginTop || 0, d.marginRight || 0, d.marginDown || 0), a.setLayoutParameter(e))
  40925. }
  40926. },
  40927. setColorPropsFromJsonDictionary: function(a, c) {
  40928. var d = c.opacity;
  40929. null != d && a.setOpacity(d);
  40930. var d = c.colorR,
  40931. e = c.colorG,
  40932. f = c.colorB;
  40933. a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
  40934. ccs.WidgetReader.setAnchorPointForWidget(a, c);
  40935. a.setFlippedX(c.flipX);
  40936. a.setFlippedY(c.flipY)
  40937. },
  40938. setAnchorPointForWidget: function(a, c) {
  40939. var d = c.anchorPointX,
  40940. e;
  40941. e = null != d ? c.anchorPointX : a.getAnchorPoint().x;
  40942. var f = c.anchorPointY,
  40943. g;
  40944. g = null != f ? c.anchorPointY : a.getAnchorPoint().y;
  40945. (null != d || null != f) && a.setAnchorPoint(cc.p(e, g))
  40946. },
  40947. getResourcePath: function(a, c, d) {
  40948. a = a[c];
  40949. var e;
  40950. null != a && (0 == d ? e = ccs.uiReader.getFilePath() + a : 1 == d ? e = a : cc.assert(0, "invalid TextureResType!!!"));
  40951. return e
  40952. }
  40953. };
  40954. (function() {
  40955. var a = ccs.objectFactory;
  40956. a.registerType({
  40957. _className: "ButtonReader",
  40958. _fun: ccs.ButtonReader
  40959. });
  40960. a.registerType({
  40961. _className: "CheckBoxReader",
  40962. _fun: ccs.CheckBoxReader
  40963. });
  40964. a.registerType({
  40965. _className: "SliderReader",
  40966. _fun: ccs.SliderReader
  40967. });
  40968. a.registerType({
  40969. _className: "ImageViewReader",
  40970. _fun: ccs.ImageViewReader
  40971. });
  40972. a.registerType({
  40973. _className: "LoadingBarReader",
  40974. _fun: ccs.LoadingBarReader
  40975. });
  40976. a.registerType({
  40977. _className: "TextAtlasReader",
  40978. _fun: ccs.LabelAtlasReader
  40979. });
  40980. a.registerType({
  40981. _className: "TextReader",
  40982. _fun: ccs.LabelReader
  40983. });
  40984. a.registerType({
  40985. _className: "TextBMFontReader",
  40986. _fun: ccs.LabelBMFontReader
  40987. });
  40988. a.registerType({
  40989. _className: "TextFieldReader",
  40990. _fun: ccs.TextFieldReader
  40991. });
  40992. a.registerType({
  40993. _className: "LayoutReader",
  40994. _fun: ccs.LayoutReader
  40995. });
  40996. a.registerType({
  40997. _className: "PageViewReader",
  40998. _fun: ccs.PageViewReader
  40999. });
  41000. a.registerType({
  41001. _className: "ScrollViewReader",
  41002. _fun: ccs.ScrollViewReader
  41003. });
  41004. a.registerType({
  41005. _className: "ListViewReader",
  41006. _fun: ccs.ListViewReader
  41007. });
  41008. a.registerType({
  41009. _className: "WidgetReader",
  41010. _fun: ccs.WidgetReader
  41011. });
  41012. a.registerType({
  41013. _className: "Button",
  41014. _fun: ccui.Button
  41015. });
  41016. a.registerType({
  41017. _className: "CheckBox",
  41018. _fun: ccui.CheckBox
  41019. });
  41020. a.registerType({
  41021. _className: "ImageView",
  41022. _fun: ccui.ImageView
  41023. });
  41024. a.registerType({
  41025. _className: "Text",
  41026. _fun: ccui.Text
  41027. });
  41028. a.registerType({
  41029. _className: "TextAtlas",
  41030. _fun: ccui.TextAtlas
  41031. });
  41032. a.registerType({
  41033. _className: "TextBMFont",
  41034. _fun: ccui.TextBMFont
  41035. });
  41036. a.registerType({
  41037. _className: "LoadingBar",
  41038. _fun: ccui.LoadingBar
  41039. });
  41040. a.registerType({
  41041. _className: "Slider",
  41042. _fun: ccui.Slider
  41043. });
  41044. a.registerType({
  41045. _className: "TextField",
  41046. _fun: ccui.TextField
  41047. });
  41048. a.registerType({
  41049. _className: "Layout",
  41050. _fun: ccui.Layout
  41051. });
  41052. a.registerType({
  41053. _className: "ListView",
  41054. _fun: ccui.ListView
  41055. });
  41056. a.registerType({
  41057. _className: "PageView",
  41058. _fun: ccui.PageView
  41059. });
  41060. a.registerType({
  41061. _className: "ScrollView",
  41062. _fun: ccui.ScrollView
  41063. })
  41064. })();
  41065. ccs.uiReader = {
  41066. _filePath: "",
  41067. _olderVersion: !1,
  41068. _fileDesignSizes: {},
  41069. _mapObject: {},
  41070. _mapParseSelector: {},
  41071. getVersionInteger: function(a) {
  41072. if (!a) return 0;
  41073. var c = a,
  41074. d = c.length;
  41075. if (7 > d) return 0;
  41076. var e = c.indexOf("."),
  41077. f = c.substr(0, e),
  41078. c = c.substr(e + 1, d - 1),
  41079. e = c.indexOf("."),
  41080. g = c.substr(0, e),
  41081. c = c.substr(e + 1, d - 1),
  41082. e = c.indexOf(".");
  41083. a = c.substr(0, e);
  41084. c = c.substr(e + 1, d - 1);
  41085. e = c.indexOf(".");
  41086. c = -1 == e ? c : c.substr(0, e);
  41087. f = parseInt(f);
  41088. g = parseInt(g);
  41089. a = parseInt(a);
  41090. c = parseInt(c);
  41091. return 1E3 * f + 100 * g + 10 * a + c
  41092. },
  41093. storeFileDesignSize: function(a, c) {
  41094. this._fileDesignSizes[a] = c
  41095. },
  41096. getFileDesignSize: function(a) {
  41097. return this._fileDesignSizes[a]
  41098. },
  41099. widgetFromJsonFile: function(a) {
  41100. var c = cc.loader.getRes(a);
  41101. if (!c) throw "Please load the resource first : " + a;
  41102. var d = cc.path.dirname(a);
  41103. this._filePath = "" == d ? d : d + "/";
  41104. var d = c.version,
  41105. e = this.getVersionInteger(d);
  41106. a = (d ? 250 > e ? new ccs.WidgetPropertiesReader0250 : new ccs.WidgetPropertiesReader0300 : new ccs.WidgetPropertiesReader0250).createWidget(c, this._filePath, a);
  41107. if (!d || 250 > e) this._olderVersion = !0;
  41108. return a
  41109. },
  41110. clear: function() {
  41111. this._filePath = "";
  41112. this._olderVersion = !1;
  41113. this._fileDesignSizes = {}
  41114. },
  41115. registerTypeAndCallBack: function(a, c, d, e) {
  41116. var f = ccs.objectFactory;
  41117. c = new ccs.TInfo(a, c);
  41118. f.registerType(c);
  41119. d && (this._mapObject[a] = d);
  41120. e && (this._mapParseSelector[a] = e)
  41121. },
  41122. getFilePath: function() {
  41123. return this._filePath
  41124. },
  41125. getParseObjectMap: function() {
  41126. return this._mapObject
  41127. },
  41128. getParseCallBackMap: function() {
  41129. return this._mapParseSelector
  41130. }
  41131. };
  41132. ccs.WidgetPropertiesReader = ccs.Class.extend({
  41133. _filePath: "",
  41134. createWidget: function(a, c, d) {},
  41135. widgetFromJsonDictionary: function(a) {},
  41136. createGUI: function(a) {
  41137. a = this.getGUIClassName(a);
  41138. return ccs.objectFactory.createObject(a)
  41139. },
  41140. getGUIClassName: function(a) {
  41141. var c = a;
  41142. "Panel" == a ? c = "Layout" : "TextArea" == a ? c = "Text" : "TextButton" == a ? c = "Button" : "Label" == a ? c = "Text" : "LabelAtlas" == a ? c = "TextAtlas" : "LabelBMFont" == a && (c = "TextBMFont");
  41143. return c
  41144. },
  41145. getWidgetReaderClassName: function(a) {
  41146. "Panel" == a ? a = "Layout" : "TextArea" == a ? a = "Text" : "TextButton" == a ? a = "Button" : "Label" == a ? a = "Text" : "LabelAtlas" == a ? a = "TextAtlas" : "LabelBMFont" == a && (a = "TextBMFont");
  41147. return a + "Reader"
  41148. },
  41149. getWidgetReaderClassNameFromWidget: function(a) {
  41150. var c;
  41151. 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");
  41152. return c
  41153. },
  41154. createWidgetReaderProtocol: function(a) {
  41155. return ccs.objectFactory.createObject(a)
  41156. }
  41157. });
  41158. ccs.WidgetPropertiesReader0250 = ccs.WidgetPropertiesReader.extend({
  41159. createWidget: function(a, c, d) {
  41160. this._filePath = "" == c ? c : cc.path.join(c, "/");
  41161. for (var e = a.textures, f = 0; f < e.length; f++) {
  41162. var g = c,
  41163. g = g + e[f];
  41164. cc.spriteFrameCache.addSpriteFrames(g)
  41165. }
  41166. c = a.designWidth;
  41167. e = a.designHeight;
  41168. 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));
  41169. f = this.widgetFromJsonDictionary(a.widgetTree);
  41170. g = f.getContentSize();
  41171. 0 == g.width && 0 == g.height && f.setSize(cc.size(c, e));
  41172. ccs.actionManager.initWithDictionary(d, a.animation, f);
  41173. return f
  41174. },
  41175. widgetFromJsonDictionary: function(a) {
  41176. var c = null,
  41177. d = a.classname,
  41178. e = a.options;
  41179. "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));
  41180. a = a.children;
  41181. for (d = 0; d < a.length; d++)(e = this.widgetFromJsonDictionary(a[d])) && c.addChild(e);
  41182. return c
  41183. },
  41184. setPropsForWidgetFromJsonDictionary: function(a, c) {
  41185. void 0 !== c.ignoreSize && a.ignoreContentAdaptWithSize(c.ignoreSize);
  41186. a.setSize(cc.size(c.width, c.height));
  41187. a.setTag(c.tag);
  41188. a.setActionTag(c.actiontag);
  41189. a.setTouchEnabled(c.touchAble);
  41190. var d = c.name;
  41191. a.setName(d ? d : "default");
  41192. a.setPosition(cc.p(c.x, c.y));
  41193. void 0 !== c.scaleX && a.setScaleX(c.scaleX);
  41194. void 0 !== c.scaleY && a.setScaleY(c.scaleY);
  41195. void 0 !== c.rotation && a.setRotation(c.rotation);
  41196. void 0 !== c.visible && a.setVisible(c.visible);
  41197. a.setLocalZOrder(c.ZOrder)
  41198. },
  41199. setPropsForAllWidgetFromJsonDictionary: function() {},
  41200. setPropsForAllCustomWidgetFromJsonDictionary: function() {},
  41201. setColorPropsForWidgetFromJsonDictionary: function(a, c) {
  41202. void 0 !== c.opacity && a.setOpacity(c.opacity);
  41203. 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));
  41204. var d = void 0 !== c.anchorPointX ? c.anchorPointX : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0,
  41205. e = void 0 !== c.anchorPointY ? c.anchorPointY : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0;
  41206. a.setAnchorPoint(d, e);
  41207. d = c.flipY;
  41208. a.setFlippedX(c.flipX);
  41209. a.setFlippedY(d)
  41210. },
  41211. setPropsForButtonFromJsonDictionary: function(a, c) {
  41212. this.setPropsForWidgetFromJsonDictionary(a, c);
  41213. var d = c.scale9Enable;
  41214. a.setScale9Enabled(d);
  41215. var e = c.normal,
  41216. f = c.pressed,
  41217. g = c.disabled,
  41218. h = e ? this._filePath + e : null,
  41219. k = f ? this._filePath + f : null,
  41220. m = g ? this._filePath + g : null,
  41221. n = c.useMergedTexture;
  41222. 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);
  41223. void 0 !== c.text && (d = c.text || "") && a.setTitleText(d);
  41224. void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
  41225. void 0 !== c.fontName && a.setTitleFontName(c.fontName);
  41226. d = cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255);
  41227. a.setTitleColor(d);
  41228. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41229. },
  41230. setPropsForCheckBoxFromJsonDictionary: function(a, c) {
  41231. this.setPropsForWidgetFromJsonDictionary(a, c);
  41232. var d = c.backGroundBox,
  41233. e = c.backGroundBoxSelected,
  41234. f = c.frontCross,
  41235. g = c.backGroundBoxDisabled,
  41236. h = c.frontCrossDisabled,
  41237. k = this._filePath,
  41238. m = d ? k + d : null,
  41239. n = e ? k + e : null,
  41240. q = f ? k + f : null,
  41241. r = g ? k + g : null,
  41242. k = h ? k + h : null;
  41243. c.useMergedTexture ? a.loadTextures(d, e, f, g, h, ccui.Widget.PLIST_TEXTURE) : a.loadTextures(m, n, q, r, k);
  41244. a.setSelectedState(c.selectedState || !1);
  41245. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41246. },
  41247. setPropsForImageViewFromJsonDictionary: function(a, c) {
  41248. this.setPropsForWidgetFromJsonDictionary(a, c);
  41249. var d = c.fileName,
  41250. e = c.scale9Enable || !1;
  41251. a.setScale9Enabled(e);
  41252. var f = this._filePath,
  41253. g = null;
  41254. d && (g = f + d);
  41255. f = c.useMergedTexture;
  41256. 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);
  41257. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41258. },
  41259. setPropsForLabelFromJsonDictionary: function(a, c) {
  41260. this.setPropsForWidgetFromJsonDictionary(a, c);
  41261. a.setTouchScaleChangeEnabled(c.touchScaleEnable);
  41262. a.setString(c.text);
  41263. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41264. void 0 !== c.fontName && a.setFontName(c.fontName);
  41265. if (void 0 !== c.areaWidth && void 0 !== c.areaHeight) {
  41266. var d = cc.size(c.areaWidth, c.areaHeight);
  41267. a.setTextAreaSize(d)
  41268. }
  41269. c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
  41270. c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
  41271. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41272. },
  41273. setPropsForLabelAtlasFromJsonDictionary: function(a, c) {
  41274. this.setPropsForWidgetFromJsonDictionary(a, c);
  41275. var d = void 0 !== c.charMapFile,
  41276. e = void 0 !== c.itemWidth,
  41277. f = void 0 !== c.itemHeight,
  41278. g = void 0 !== c.startCharMap;
  41279. void 0 !== c.stringValue && (d && e && f && g && c.charMapFile) && a.setProperty(c.stringValue, this._filePath + c.charMapFile, c.itemWidth, c.itemHeight, c.startCharMap);
  41280. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41281. },
  41282. setPropsForLayoutFromJsonDictionary: function(a, c) {
  41283. this.setPropsForWidgetFromJsonDictionary(a, c);
  41284. !(a instanceof ccui.ScrollView) && !(a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
  41285. var d = c.backGroundScale9Enable;
  41286. a.setBackGroundImageScale9Enabled(d);
  41287. var e = c.bgColorR,
  41288. f = c.bgColorG,
  41289. g = c.bgColorB,
  41290. h = c.bgStartColorR,
  41291. k = c.bgStartColorG,
  41292. m = c.bgStartColorB,
  41293. n = c.bgEndColorR,
  41294. q = c.bgEndColorG,
  41295. r = c.bgEndColorB;
  41296. a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
  41297. var t = c.bgColorOpacity;
  41298. a.setBackGroundColorType(c.colorType);
  41299. a.setBackGroundColor(cc.color(h, k, m), cc.color(n, q, r));
  41300. a.setBackGroundColor(cc.color(e, f, g));
  41301. a.setBackGroundColorOpacity(t);
  41302. f = (e = c.backGroundImage) ? this._filePath + e : null;
  41303. c.useMergedTexture ? a.setBackGroundImage(e, ccui.Widget.PLIST_TEXTURE) : a.setBackGroundImage(f);
  41304. d && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
  41305. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41306. },
  41307. setPropsForScrollViewFromJsonDictionary: function(a, c) {
  41308. this.setPropsForLayoutFromJsonDictionary(a, c);
  41309. a.setInnerContainerSize(cc.size(c.innerWidth, c.innerHeight));
  41310. a.setDirection(c.direction);
  41311. a.setBounceEnabled(c.bounceEnable);
  41312. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41313. },
  41314. setPropsForContainerWidgetFromJsonDictionary: function(a, c) {
  41315. this.setPropsForWidgetFromJsonDictionary(a, c);
  41316. (a instanceof ccui.ScrollView || a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
  41317. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41318. },
  41319. setPropsForSliderFromJsonDictionary: function(a, c) {
  41320. this.setPropsForWidgetFromJsonDictionary(a, c);
  41321. var d = c.barTextureScale9Enable || !1;
  41322. a.setScale9Enabled(d);
  41323. var e = c.length,
  41324. f = c.useMergedTexture;
  41325. if (void 0 !== c.barFileName)
  41326. if (d) {
  41327. var g = (d = c.barFileName) ? this._filePath + d : null;
  41328. f ? a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadBarTexture(g);
  41329. a.setSize(cc.size(e, a.getContentSize().height))
  41330. } else g = (d = c.barFileName) ? this._filePath + d : null, f ? a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadBarTexture(g);
  41331. var e = c.ballNormal,
  41332. d = c.ballPressed,
  41333. g = c.ballDisabled,
  41334. h = e ? this._filePath + e : null,
  41335. k = d ? this._filePath + d : null,
  41336. m = g ? this._filePath + g : null;
  41337. f ? a.loadSlidBallTextures(e, d, g, ccui.Widget.PLIST_TEXTURE) : a.loadSlidBallTextures(h, k, m);
  41338. a.setPercent(c.percent);
  41339. g = (d = c.progressBarFileName) ? this._filePath + d : null;
  41340. f ? a.loadProgressBarTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadProgressBarTexture(g);
  41341. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41342. },
  41343. setPropsForTextAreaFromJsonDictionary: function(a, c) {
  41344. this.setPropsForWidgetFromJsonDictionary(a, c);
  41345. a.setString(c.text);
  41346. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41347. var d = c.colorR,
  41348. e = c.colorG,
  41349. f = c.colorB;
  41350. a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
  41351. a.setFontName(c.fontName);
  41352. void 0 !== c.areaWidth && void 0 !== c.areaHeight && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
  41353. c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
  41354. c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
  41355. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41356. },
  41357. setPropsForTextButtonFromJsonDictionary: function(a, c) {
  41358. this.setPropsForButtonFromJsonDictionary(a, c);
  41359. a.setTitleText(c.text || "");
  41360. 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));
  41361. void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
  41362. void 0 !== c.fontName && a.setTitleFontName(c.fontName);
  41363. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41364. },
  41365. setPropsForTextFieldFromJsonDictionary: function(a, c) {
  41366. this.setPropsForWidgetFromJsonDictionary(a, c);
  41367. void 0 !== c.placeHolder && a.setPlaceHolder(c.placeHolder);
  41368. a.setString(c.text);
  41369. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41370. void 0 !== c.fontName && a.setFontName(c.fontName);
  41371. void 0 !== c.touchSizeWidth && void 0 !== c.touchSizeHeight && a.setTouchSize(cc.size(c.touchSizeWidth, c.touchSizeHeight));
  41372. var d = c.maxLengthEnable;
  41373. a.setMaxLengthEnabled(d);
  41374. d && a.setMaxLength(c.maxLength);
  41375. d = c.passwordEnable;
  41376. a.setPasswordEnabled(d);
  41377. d && a.setPasswordStyleText(c.passwordStyleText);
  41378. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41379. },
  41380. setPropsForLoadingBarFromJsonDictionary: function(a, c) {
  41381. this.setPropsForWidgetFromJsonDictionary(a, c);
  41382. var d = c.texture,
  41383. e = d ? this._filePath + d : null;
  41384. c.useMergedTexture ? a.loadTexture(d, ccui.Widget.PLIST_TEXTURE) : a.loadTexture(e);
  41385. a.setDirection(c.direction);
  41386. a.setPercent(c.percent);
  41387. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41388. },
  41389. setPropsForListViewFromJsonDictionary: function(a, c) {
  41390. this.setPropsForLayoutFromJsonDictionary(a, c)
  41391. },
  41392. setPropsForPageViewFromJsonDictionary: function(a, c) {
  41393. this.setPropsForLayoutFromJsonDictionary(a, c)
  41394. },
  41395. setPropsForLabelBMFontFromJsonDictionary: function(a, c) {
  41396. this.setPropsForWidgetFromJsonDictionary(a, c);
  41397. a.setFntFile(this._filePath + c.fileName);
  41398. a.setString(c.text);
  41399. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41400. }
  41401. });
  41402. ccs.WidgetPropertiesReader0300 = ccs.WidgetPropertiesReader.extend({
  41403. createWidget: function(a, c, d) {
  41404. this._filePath = "" == c ? c : cc.path.join(c, "/");
  41405. for (var e = a.textures, f = 0; f < e.length; f++) {
  41406. var g = c,
  41407. g = g + e[f];
  41408. cc.spriteFrameCache.addSpriteFrames(g)
  41409. }
  41410. c = a.designWidth;
  41411. e = a.designHeight;
  41412. 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));
  41413. f = this.widgetFromJsonDictionary(a.widgetTree);
  41414. g = f.getContentSize();
  41415. 0 == g.width && 0 == g.height && f.setSize(cc.size(c, e));
  41416. ccs.actionManager.initWithDictionary(d, a.animation, f);
  41417. return f
  41418. },
  41419. setPropsForAllWidgetFromJsonDictionary: function(a, c, d) {
  41420. a && a.setPropsFromJsonDictionary && a.setPropsFromJsonDictionary(c, d)
  41421. },
  41422. setPropsForAllCustomWidgetFromJsonDictionary: function(a, c, d) {
  41423. var e = ccs.uiReader,
  41424. f = e.getParseObjectMap()[a],
  41425. e = e.getParseCallBackMap()[a];
  41426. f && e && e(a, c, d)
  41427. },
  41428. widgetFromJsonDictionary: function(a) {
  41429. var c = a.classname,
  41430. d = a.options,
  41431. e = this.createGUI(c),
  41432. f = this.getWidgetReaderClassName(c);
  41433. (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."));
  41434. a = a.children;
  41435. for (c = 0; c < a.length; c++)
  41436. if (d = this.widgetFromJsonDictionary(a[c]))
  41437. if (e instanceof ccui.PageView) e.addPage(d);
  41438. else if (e instanceof ccui.ListView) e.pushBackCustomItem(d);
  41439. else {
  41440. if (!(e instanceof ccui.Layout)) {
  41441. if (d.getPositionType() == ccui.Widget.POSITION_PERCENT) {
  41442. var f = d.getPositionPercent(),
  41443. g = e.getAnchorPoint();
  41444. d.setPositionPercent(cc.p(f.x + g.x, f.y + g.y))
  41445. }
  41446. f = e.getAnchorPointInPoints();
  41447. d.setPosition(cc.p(d.getPositionX() + f.x, d.getPositionY() + f.y))
  41448. }
  41449. e.addChild(d)
  41450. }
  41451. return e
  41452. },
  41453. setPropsForWidgetFromJsonDictionary: function(a, c) {
  41454. var d = c.name;
  41455. a.setName(d ? d : "default");
  41456. void 0 !== c.ignoreSize && a.ignoreContentAdaptWithSize(c.ignoreSize);
  41457. a.setSizeType(c.sizeType);
  41458. a.setPositionType(c.positionType);
  41459. a.setSizePercent(cc.p(c.sizePercentX, c.sizePercentY));
  41460. a.setPositionPercent(cc.p(c.positionPercentX, c.positionPercentY));
  41461. a.setSize(cc.size(c.width, c.height));
  41462. a.setTag(c.tag);
  41463. a.setActionTag(c.actiontag);
  41464. a.setTouchEnabled(c.touchAble);
  41465. a.setPosition(cc.p(c.x, c.y));
  41466. void 0 !== c.scaleX && a.setScaleX(c.scaleX);
  41467. void 0 !== c.scaleY && a.setScaleY(c.scaleY);
  41468. void 0 !== c.rotation && a.setRotation(c.rotation);
  41469. void 0 !== c.visible && a.setVisible(c.visible);
  41470. a.setLocalZOrder(c.ZOrder);
  41471. if (d = c.layoutParameter) {
  41472. var e;
  41473. switch (d.type) {
  41474. case 1:
  41475. e = ccui.LinearLayoutParameter.create();
  41476. e.setGravity(d.gravity);
  41477. break;
  41478. case 2:
  41479. e = ccui.RelativeLayoutParameter.create(), e.setRelativeName(d.relativeName), e.setRelativeToWidgetName(d.relativeToName), e.setAlign(d.align)
  41480. }
  41481. e.setMargin(new ccui.Margin(d.marginLeft, d.marginTop, d.marginRight, d.marginDown));
  41482. a.setLayoutParameter(e)
  41483. }
  41484. },
  41485. setColorPropsForWidgetFromJsonDictionary: function(a, c) {
  41486. void 0 !== c.opacity && a.setOpacity(c.opacity);
  41487. 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));
  41488. var d = void 0 !== c.anchorPointX ? c.anchorPointX : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0,
  41489. e = void 0 !== c.anchorPointY ? c.anchorPointY : a.getWidgetType() == ccui.Widget.TYPE_WIDGET ? 0.5 : 0;
  41490. a.setAnchorPoint(d, e);
  41491. d = c.flipY;
  41492. a.setFlippedX(c.flipX);
  41493. a.setFlippedY(d)
  41494. },
  41495. setPropsForButtonFromJsonDictionary: function(a, c) {
  41496. this.setPropsForWidgetFromJsonDictionary(a, c);
  41497. var d = c.scale9Enable;
  41498. a.setScale9Enabled(d);
  41499. var e = c.normalData;
  41500. switch (e.resourceType) {
  41501. case 0:
  41502. e = e.path;
  41503. a.loadTextureNormal(e ? this._filePath + e : null);
  41504. break;
  41505. case 1:
  41506. e = e.path, a.loadTextureNormal(e, ccui.Widget.PLIST_TEXTURE)
  41507. }
  41508. e = c.pressedData;
  41509. switch (e.resourceType) {
  41510. case 0:
  41511. e = e.path;
  41512. a.loadTexturePressed(e ? this._filePath + e : null);
  41513. break;
  41514. case 1:
  41515. e = e.path, a.loadTexturePressed(e, ccui.Widget.PLIST_TEXTURE)
  41516. }
  41517. e = c.disabledData;
  41518. switch (e.resourceType) {
  41519. case 0:
  41520. e = e.path;
  41521. a.loadTextureDisabled(e ? this._filePath + e : null);
  41522. break;
  41523. case 1:
  41524. e = e.path, a.loadTextureDisabled(e, ccui.Widget.PLIST_TEXTURE)
  41525. }
  41526. 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)));
  41527. void 0 !== c.text && (d = c.text || "") && a.setTitleText(d);
  41528. void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
  41529. void 0 !== c.fontName && a.setTitleFontName(c.fontName);
  41530. d = cc.color(void 0 !== c.textColorR ? c.textColorR : 255, void 0 !== c.textColorG ? c.textColorG : 255, void 0 !== c.textColorB ? c.textColorB : 255);
  41531. a.setTitleColor(d);
  41532. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41533. },
  41534. setPropsForCheckBoxFromJsonDictionary: function(a, c) {
  41535. this.setPropsForWidgetFromJsonDictionary(a, c);
  41536. var d = c.backGroundBoxData;
  41537. switch (d.resourceType) {
  41538. case 0:
  41539. d = d.path;
  41540. a.loadTextureBackGround(d ? this._filePath + d : null);
  41541. break;
  41542. case 1:
  41543. d = d.path, a.loadTextureBackGround(d, ccui.Widget.PLIST_TEXTURE)
  41544. }
  41545. d = c.backGroundBoxSelectedData;
  41546. switch (d.resourceType) {
  41547. case 0:
  41548. d = d.path;
  41549. a.loadTextureBackGroundSelected(d ? this._filePath + d : null);
  41550. break;
  41551. case 1:
  41552. d = d.path, a.loadTextureBackGroundSelected(d, ccui.Widget.PLIST_TEXTURE)
  41553. }
  41554. d = c.frontCrossData;
  41555. switch (d.resourceType) {
  41556. case 0:
  41557. d = d.path;
  41558. a.loadTextureFrontCross(d ? this._filePath + d : null);
  41559. break;
  41560. case 1:
  41561. d = d.path, a.loadTextureFrontCross(d, ccui.Widget.PLIST_TEXTURE)
  41562. }
  41563. d = c.backGroundBoxDisabledData;
  41564. switch (d.resourceType) {
  41565. case 0:
  41566. d = d.path;
  41567. a.loadTextureBackGroundDisabled(d ? this._filePath + d : null);
  41568. break;
  41569. case 1:
  41570. d = d.path, a.loadTextureBackGroundDisabled(d, ccui.Widget.PLIST_TEXTURE)
  41571. }
  41572. switch (c.frontCrossDisabledData.resourceType) {
  41573. case 0:
  41574. d = c.path;
  41575. a.loadTextureFrontCrossDisabled(d ? this._filePath + d : null);
  41576. break;
  41577. case 1:
  41578. d = c.path, a.loadTextureFrontCrossDisabled(d, ccui.Widget.PLIST_TEXTURE)
  41579. }
  41580. a.setSelectedState(c.selectedState || !1);
  41581. a.setSelectedState(c, "selectedState");
  41582. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41583. },
  41584. setPropsForImageViewFromJsonDictionary: function(a, c) {
  41585. this.setPropsForWidgetFromJsonDictionary(a, c);
  41586. var d = c.fileNameData;
  41587. switch (d.resourceType) {
  41588. case 0:
  41589. var e = this._filePath;
  41590. (d = d.path) && a.loadTexture(e + d);
  41591. break;
  41592. case 1:
  41593. d = d.path, a.loadTexture(d, ccui.Widget.PLIST_TEXTURE)
  41594. }
  41595. e = c.scale9Enable || !1;
  41596. a.setScale9Enabled(e);
  41597. 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)));
  41598. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41599. },
  41600. setPropsForLabelFromJsonDictionary: function(a, c) {
  41601. this.setPropsForWidgetFromJsonDictionary(a, c);
  41602. a.setTouchScaleChangeEnabled(c.touchScaleEnable);
  41603. a.setString(c.text);
  41604. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41605. void 0 !== c.fontName && a.setFontName(c.fontName);
  41606. if (void 0 !== c.areaWidth && void 0 !== c.areaHeight) {
  41607. var d = cc.size(c.areaWidth, c.areaHeight);
  41608. a.setTextAreaSize(d)
  41609. }
  41610. c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
  41611. c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
  41612. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41613. },
  41614. setPropsForLabelAtlasFromJsonDictionary: function(a, c) {
  41615. this.setPropsForWidgetFromJsonDictionary(a, c);
  41616. var d = void 0 !== c.charMapFile,
  41617. e = void 0 !== c.itemWidth,
  41618. f = void 0 !== c.itemHeight,
  41619. g = void 0 !== c.startCharMap;
  41620. if (void 0 !== c.stringValue && d && e && f && g) switch (d = c.charMapFileData, d.resourceType) {
  41621. case 0:
  41622. a.setProperty(c.stringValue, this._filePath + d.path, c.itemWidth, c.itemHeight, c.startCharMap);
  41623. break;
  41624. case 1:
  41625. cc.log("Wrong res type of LabelAtlas!")
  41626. }
  41627. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41628. },
  41629. setPropsForLayoutFromJsonDictionary: function(a, c) {
  41630. this.setPropsForWidgetFromJsonDictionary(a, c);
  41631. !(a instanceof ccui.ScrollView) && !(a instanceof ccui.ListView) && a.setClippingEnabled(c.clipAble);
  41632. var d = c.backGroundScale9Enable;
  41633. a.setBackGroundImageScale9Enabled(d);
  41634. var e = c.bgColorR,
  41635. f = c.bgColorG,
  41636. g = c.bgColorB,
  41637. h = c.bgStartColorR,
  41638. k = c.bgStartColorG,
  41639. m = c.bgStartColorB,
  41640. n = c.bgEndColorR,
  41641. q = c.bgEndColorG,
  41642. r = c.bgEndColorB;
  41643. a.setBackGroundColorVector(cc.p(c.vectorX, c.vectorY));
  41644. var t = c.bgColorOpacity;
  41645. a.setBackGroundColorType(c.colorType);
  41646. a.setBackGroundColor(cc.color(h, k, m), cc.color(n, q, r));
  41647. a.setBackGroundColor(cc.color(e, f, g));
  41648. a.setBackGroundColorOpacity(t);
  41649. e = c.backGroundImageData || {};
  41650. switch (e.resourceType) {
  41651. case 0:
  41652. e = e.path;
  41653. a.setBackGroundImage(e ? this._filePath + e : null);
  41654. break;
  41655. case 1:
  41656. e = e.path, a.setBackGroundImage(e, ccui.Widget.PLIST_TEXTURE)
  41657. }
  41658. d && a.setBackGroundImageCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight));
  41659. a.setLayoutType(c.layoutType);
  41660. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41661. },
  41662. setPropsForScrollViewFromJsonDictionary: function(a, c) {
  41663. this.setPropsForLayoutFromJsonDictionary(a, c);
  41664. a.setInnerContainerSize(cc.size(c.innerWidth, c.innerHeight));
  41665. a.setDirection(c.direction);
  41666. a.setBounceEnabled(c.bounceEnable);
  41667. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41668. },
  41669. setPropsForSliderFromJsonDictionary: function(a, c) {
  41670. this.setPropsForWidgetFromJsonDictionary(a, c);
  41671. var d = c.barTextureScale9Enable || !1;
  41672. a.setScale9Enabled(d);
  41673. var e = c.length;
  41674. if (void 0 !== c.barFileName)
  41675. if (d) {
  41676. var d = c.barFileNameData,
  41677. f = d.resourceType;
  41678. switch (f) {
  41679. case 0:
  41680. d = (d = d.path) ? this._filePath + d : null;
  41681. a.loadBarTexture(d);
  41682. break;
  41683. case 1:
  41684. d = d.path, a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE)
  41685. }
  41686. a.setSize(cc.size(e, a.getContentSize().height))
  41687. } else switch (d = c.barFileNameData, f = d.resourceType, f) {
  41688. case 0:
  41689. d = (d = d.path) ? this._filePath + d : null;
  41690. a.loadBarTexture(d);
  41691. break;
  41692. case 1:
  41693. d = d.path, a.loadBarTexture(d, ccui.Widget.PLIST_TEXTURE)
  41694. }
  41695. e = c.ballNormalData;
  41696. switch (e.resourceType) {
  41697. case 0:
  41698. e = e.path;
  41699. a.loadSlidBallTextureNormal(e ? this._filePath + e : null);
  41700. break;
  41701. case 1:
  41702. e = e.path, a.loadSlidBallTextureNormal(e, ccui.Widget.PLIST_TEXTURE)
  41703. }
  41704. e = c.ballPressedData;
  41705. switch (e.resourceType) {
  41706. case 0:
  41707. e = e.path;
  41708. a.loadSlidBallTexturePressed(e ? this._filePath + e : null);
  41709. break;
  41710. case 1:
  41711. e = e.path, a.loadSlidBallTexturePressed(e, ccui.Widget.PLIST_TEXTURE)
  41712. }
  41713. e = c.ballDisabledData;
  41714. switch (e.resourceType) {
  41715. case 0:
  41716. e = e.path;
  41717. a.loadSlidBallTextureDisabled(e ? this._filePath + e : null);
  41718. break;
  41719. case 1:
  41720. e = e.path, a.loadSlidBallTextureDisabled(e, ccui.Widget.PLIST_TEXTURE)
  41721. }
  41722. e = c.progressBarData;
  41723. switch (e.resourceType) {
  41724. case 0:
  41725. d = (d = e.path) ? this._filePath + d : null;
  41726. a.loadProgressBarTexture(d);
  41727. break;
  41728. case 1:
  41729. d = e.path, a.loadProgressBarTexture(d, ccui.Widget.PLIST_TEXTURE)
  41730. }
  41731. this.setColorPropsForWidgetFromJsonDictionary(a, c);
  41732. a.setPercent(c.percent)
  41733. },
  41734. setPropsForTextAreaFromJsonDictionary: function(a, c) {
  41735. this.setPropsForWidgetFromJsonDictionary(a, c);
  41736. a.setString(c.text);
  41737. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41738. var d = c.colorR,
  41739. e = c.colorG,
  41740. f = c.colorB;
  41741. a.setColor(cc.color(null == d ? 255 : d, null == e ? 255 : e, null == f ? 255 : f));
  41742. a.setFontName(c.fontName);
  41743. void 0 !== c.areaWidth && void 0 !== c.areaHeight && (d = cc.size(c.areaWidth, c.areaHeight), a.setTextAreaSize(d));
  41744. c.hAlignment && a.setTextHorizontalAlignment(c.hAlignment);
  41745. c.vAlignment && a.setTextVerticalAlignment(c.vAlignment);
  41746. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41747. },
  41748. setPropsForTextButtonFromJsonDictionary: function(a, c) {
  41749. this.setPropsForButtonFromJsonDictionary(a, c);
  41750. a.setTitleText(c.text || "");
  41751. 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));
  41752. void 0 !== c.fontSize && a.setTitleFontSize(c.fontSize);
  41753. void 0 !== c.fontName && a.setTitleFontName(c.fontName);
  41754. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41755. },
  41756. setPropsForTextFieldFromJsonDictionary: function(a, c) {
  41757. this.setPropsForWidgetFromJsonDictionary(a, c);
  41758. void 0 !== c.placeHolder && a.setPlaceHolder(c.placeHolder);
  41759. a.setString(c.text);
  41760. void 0 !== c.fontSize && a.setFontSize(c.fontSize);
  41761. void 0 !== c.fontName && a.setFontName(c.fontName);
  41762. void 0 !== c.touchSizeWidth && void 0 !== c.touchSizeHeight && a.setTouchSize(cc.size(c.touchSizeWidth, c.touchSizeHeight));
  41763. var d = c.maxLengthEnable;
  41764. a.setMaxLengthEnabled(d);
  41765. d && a.setMaxLength(c.maxLength);
  41766. d = c.passwordEnable;
  41767. a.setPasswordEnabled(d);
  41768. d && a.setPasswordStyleText(c.passwordStyleText);
  41769. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41770. },
  41771. setPropsForLoadingBarFromJsonDictionary: function(a, c) {
  41772. this.setPropsForWidgetFromJsonDictionary(a, c);
  41773. var d = c.textureData;
  41774. switch (d.resourceType) {
  41775. case 0:
  41776. var e = this._filePath;
  41777. (d = d.path) && a.loadTexture(e + d);
  41778. break;
  41779. case 1:
  41780. d = d.path, a.loadTexture(d, ccui.Widget.PLIST_TEXTURE)
  41781. }
  41782. e = c.scale9Enable;
  41783. a.setScale9Enabled(e);
  41784. e && (a.setCapInsets(cc.rect(c.capInsetsX, c.capInsetsY, c.capInsetsWidth, c.capInsetsHeight)), a.setSize(cc.size(c.width, c.height)));
  41785. a.setDirection(c.direction);
  41786. a.setPercent(c.percent);
  41787. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41788. },
  41789. setPropsForListViewFromJsonDictionary: function(a, c) {
  41790. this.setPropsForLayoutFromJsonDictionary(a, c);
  41791. a.setInnerContainerSize(cc.size(c.innerWidth || 0, c.innerHeight || 0));
  41792. a.setDirection(c.direction || 0);
  41793. a.setGravity(c.gravity || 0);
  41794. a.setItemsMargin(c.itemMargin || 0)
  41795. },
  41796. setPropsForPageViewFromJsonDictionary: function(a, c) {
  41797. this.setPropsForLayoutFromJsonDictionary(a, c)
  41798. },
  41799. setPropsForLabelBMFontFromJsonDictionary: function(a, c) {
  41800. this.setPropsForWidgetFromJsonDictionary(a, c);
  41801. var d = c.fileNameData;
  41802. switch (d.resourceType) {
  41803. case 0:
  41804. a.setFntFile(this._filePath + d.path);
  41805. break;
  41806. case 1:
  41807. cc.log("Wrong res type of LabelAtlas!")
  41808. }
  41809. a.setString(c.text);
  41810. this.setColorPropsForWidgetFromJsonDictionary(a, c)
  41811. }
  41812. });
  41813. ccs.sceneReader = {
  41814. _baseBath: "",
  41815. _listener: null,
  41816. _selector: null,
  41817. _node: null,
  41818. createNodeWithSceneFile: function(a) {
  41819. this._node = null;
  41820. this._baseBath = cc.path.dirname(a);
  41821. var c = cc.loader.getRes(a);
  41822. if (!c) throw "Please load the resource first : " + a;
  41823. this._node = this.createObject(c, null);
  41824. ccs.triggerManager.parse(c.Triggers || []);
  41825. return this._node
  41826. },
  41827. createObject: function(a, c) {
  41828. var d = a.classname;
  41829. if ("CCNode" == d) {
  41830. var e = null;
  41831. c ? (e = cc.Node.create(), c.addChild(e)) : e = cc.Node.create();
  41832. this.setPropertyFromJsonDict(e, a);
  41833. for (var f = a.components, g = 0; g < f.length; g++) {
  41834. var h = f[g];
  41835. if (!h) break;
  41836. var d = h.classname,
  41837. k = h.name,
  41838. m = h.fileData,
  41839. n = "",
  41840. q = "",
  41841. r = 0;
  41842. null != m && (r = void 0 !== m.resourceType ? m.resourceType : -1, n = cc.path.join(this._baseBath, m.path), q = m.plistFile);
  41843. var t = cc.path.extname(n);
  41844. if ("CCSprite" == d) {
  41845. d = null;
  41846. if (0 == r) {
  41847. if (".png" != t) continue;
  41848. d = cc.Sprite.create(n)
  41849. } else if (1 == r) {
  41850. if (".plist" != t) continue;
  41851. q = cc.path.join(this._baseBath, q);
  41852. n = cc.path.changeExtname(q, ".png");
  41853. cc.spriteFrameCache.addSpriteFrames(q, n);
  41854. d = cc.Sprite.create("#" + m.path)
  41855. } else continue;
  41856. n = ccs.ComRender.create(d, "CCSprite");
  41857. null != k && n.setName(k);
  41858. e.addComponent(n);
  41859. this._callSelector(d, h)
  41860. } 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));
  41861. 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!"));
  41862. 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));
  41863. else if ("CCComAudio" == d) {
  41864. var s = null;
  41865. 0 == r && (s = ccs.ComAudio.create(), s.preloadEffect(n), k && s.setName(k), e.addComponent(s), this._callSelector(s, h))
  41866. } 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))
  41867. }
  41868. f = a.gameobjects;
  41869. for (g = 0; g < f.length; g++) {
  41870. h = f[g];
  41871. if (!h) break;
  41872. this.createObject(h, e)
  41873. }
  41874. return e
  41875. }
  41876. return null
  41877. },
  41878. nodeByTag: function(a, c) {
  41879. if (null == a) return null;
  41880. for (var d = null, e = a.getChildren(), f = 0; f < e.length && !((d = e[f]) && d.getTag() == c) && !(d = this.nodeByTag(d, c)); f++);
  41881. return d
  41882. },
  41883. getNodeByTag: function(a) {
  41884. return null == this._node ? null : this._node.getTag() == a ? this._node : this.nodeByTag(this._node, a)
  41885. },
  41886. setPropertyFromJsonDict: function(a, c) {
  41887. a.setPosition("undefined" === typeof c.x ? 0 : c.x, "undefined" === typeof c.y ? 0 : c.y);
  41888. a.setVisible(Boolean("undefined" === typeof c.visible ? 1 : c.visible));
  41889. a.setTag("undefined" === typeof c.objecttag ? -1 : c.objecttag);
  41890. a.setLocalZOrder("undefined" === typeof c.zorder ? 0 : c.zorder);
  41891. var d = "undefined" === typeof c.scaley ? 1 : c.scaley;
  41892. a.setScaleX("undefined" === typeof c.scalex ? 1 : c.scalex);
  41893. a.setScaleY(d);
  41894. a.setRotation("undefined" === typeof c.rotation ? 0 : c.rotation)
  41895. },
  41896. setTarget: function(a, c) {
  41897. this._listener = c;
  41898. this._selector = a
  41899. },
  41900. _callSelector: function(a, c) {
  41901. this._selector && this._selector.call(this._listener, a, c)
  41902. },
  41903. version: function() {
  41904. return "1.2.0.0"
  41905. },
  41906. clear: function() {
  41907. ccs.triggerManager.removeAll();
  41908. cc.audioEngine.end()
  41909. }
  41910. };
  41911. var baseURL = "./images/",
  41912. res = {
  41913. background_png: baseURL + "background.png",
  41914. time_png: baseURL + "time.png",
  41915. wordBg_png: baseURL + "xinxi.png",
  41916. buttomBg_png: baseURL + "buttomBg.png",
  41917. wrongMark_png: baseURL + "wrongMark.png",
  41918. s_jin: baseURL + "01.png",
  41919. dialogBg: baseURL + "dialogBg.png",
  41920. dibanzi: baseURL + "diban.png",
  41921. wordBg: baseURL + "wordBg.png",
  41922. toumingdi: baseURL + "toumingdi.png",
  41923. banzi: baseURL + "banzi.png",
  41924. ready_png: baseURL + "ready.png",
  41925. go_png: baseURL + "go.png",
  41926. login_figure: baseURL + "login_ice.png",
  41927. s_overfigure: baseURL + "renwu/role3.png",
  41928. s_guide_png: baseURL + "guide.png",
  41929. s_share: baseURL + "share.png",
  41930. s_paopao: baseURL + "paopao.png",
  41931. s_fenxiangzi: baseURL + "zi.png",
  41932. s_fenxiang: baseURL + "fenxiang.png",
  41933. s_fnt: baseURL + "font.fnt",
  41934. s_fntpng: baseURL + "fontpng.png",
  41935. s_role1: baseURL + "renwu/role1.png",
  41936. s_role2: baseURL + "renwu/role2.png",
  41937. s_role3: baseURL + "renwu/role3.png",
  41938. cakeRed_png: baseURL + "cakeRed.png",
  41939. cakeGreen_png: baseURL + "cakeGreen.png",
  41940. cakeBlue_png: baseURL + "cakeBlue.png",
  41941. cakeButtom_png: baseURL + "cakeButtom.png",
  41942. macaronsBule_png: baseURL + "macaronsBule.png",
  41943. macaronsButtom_png: baseURL + "macaronsButtom.png",
  41944. macaronsGreen_png: baseURL + "macaronsGreen.png",
  41945. macaronsMiddle_png: baseURL + "macaronsMiddle.png",
  41946. macaronsRed_png: baseURL + "macaronsRed.png",
  41947. macaronsTop_png: baseURL + "macaronsTop.png",
  41948. iceButtom_png: baseURL + "iceBottom.png",
  41949. iceBule_png: baseURL + "iceBule.png",
  41950. iceGreen_png: baseURL + "iceGreen.png",
  41951. iceRed_png: baseURL + "iceRed.png",
  41952. btnNewGame_png: baseURL + "btnNewGame.png",
  41953. btnAgain_png: baseURL + "btnAgain.png",
  41954. btnShare_png: baseURL + "btnShare.png",
  41955. progressBarBg_png: baseURL + "progressBarBg.png",
  41956. progressBar_png: baseURL + "progressBar.png",
  41957. gameLogo_png: baseURL + "gameLogo.png",
  41958. btnShare1: baseURL + "btnShare1.png",
  41959. btnKnown: baseURL + "btnKnown.png"
  41960. };
  41961. var music = {
  41962. readyGo: baseURL + "music/readygo01.mp3",
  41963. last10sec: baseURL + "music/10sec01.mp3",
  41964. gameBg: baseURL + "music/gameBG101.mp3",
  41965. result: baseURL + "music/jiesuan01.mp3",
  41966. hits1: baseURL + "music/lianji101.mp3",
  41967. hits2: baseURL + "music/lianji102.mp3",
  41968. hits3: baseURL + "music/lianji103.mp3",
  41969. hits4: baseURL + "music/lianji104.mp3",
  41970. hitsOver: baseURL + "music/lianjiover101.mp3",
  41971. wrong: baseURL + "music/wrong01.mp3"
  41972. },
  41973. g_resources = [],
  41974. i;
  41975. for (i in res) g_resources.push(res[i]);
  41976. for (var j in music) g_resources.push(music[j]);
  41977. var Config = {
  41978. ice: null,
  41979. cake: null,
  41980. macarons: null,
  41981. typeIce: "typeice",
  41982. typecake: "typecake",
  41983. progressBarConfig: null,
  41984. vision: 10
  41985. };
  41986. Config.ice = [res.iceBule_png, res.iceGreen_png, res.iceRed_png];
  41987. Config.ice.buttom = res.iceButtom_png;
  41988. Config.ice.bheight = 80;
  41989. Config.ice.foodtype = "ice";
  41990. Config.ice.itemHeight = 35;
  41991. Config.cake = [res.cakeRed_png, res.cakeGreen_png, res.cakeBlue_png];
  41992. Config.cake.buttom = res.cakeButtom_png;
  41993. Config.cake.bheight = 0;
  41994. Config.cake.foodtype = "cake";
  41995. Config.cake.itemHeight = 50;
  41996. Config.macarons = [res.macaronsBule_png, res.macaronsGreen_png, res.macaronsRed_png];
  41997. Config.macarons.top = res.macaronsTop_png;
  41998. Config.macarons.buttom = res.macaronsButtom_png;
  41999. Config.macarons.middle = res.macaronsMiddle_png;
  42000. Config.macarons.middleHeight = 55;
  42001. Config.macarons.bheight = 20;
  42002. Config.macarons.foodtype = "macarons";
  42003. Config.macarons.itemHeight = 50;
  42004. Config.progressBarConfig = {
  42005. limit: 6E4,
  42006. now: 6E4
  42007. };
  42008. Config.alreadyGoTime = 60;
  42009. var lead = null,
  42010. GameLayer = cc.LayerColor.extend({
  42011. ctor: function() {
  42012. this._super()
  42013. },
  42014. init: function() {
  42015. this._super();
  42016. GameL = this;
  42017. Func.ice_random();
  42018. Func.res_random(Data.victoryNum);
  42019. var a = cc.Sprite.create(res.background_png);
  42020. a.setAnchorPoint(cc.p(0.5, 0.5));
  42021. a.x = gameSize.width / 2;
  42022. a.y = gameSize.height / 2;
  42023. this.addChild(a, 0);
  42024. a = ccui.ImageView.create();
  42025. a.loadTexture(res.toumingdi);
  42026. a.setScale9Enabled(!0);
  42027. a.setContentSize(cc.size(592, 616));
  42028. a.setTextureRect(cc.rect(23, 73, 1, 1));
  42029. a.x = gameSize.width / 2;
  42030. a.y = gameSize.height / 2 - 10;
  42031. this.addChild(a, 2);
  42032. a = ccui.ImageView.create();
  42033. a.loadTexture(res.wordBg);
  42034. a.setScale9Enabled(!0);
  42035. a.setContentSize(cc.size(275, 400));
  42036. a.setTextureRect(cc.rect(117, 50, 1, 1));
  42037. a.x = gameSize.width / 2 - 143;
  42038. a.y = gameSize.height / 2 - 100;
  42039. this.addChild(a, 2);
  42040. var c = ccui.ImageView.create();
  42041. c.loadTexture(res.dibanzi);
  42042. c.x = 140;
  42043. c.y = 10;
  42044. a.addChild(c, 2);
  42045. a = ccui.ImageView.create();
  42046. a.loadTexture(res.wordBg);
  42047. a.setScale9Enabled(!0);
  42048. a.setContentSize(cc.size(275, 400));
  42049. a.setTextureRect(cc.rect(117, 50, 1, 1));
  42050. a.x = gameSize.width / 2 + 140;
  42051. a.y = gameSize.height / 2 - 100;
  42052. this.addChild(a, 2);
  42053. c = ccui.ImageView.create();
  42054. c.loadTexture(res.dibanzi);
  42055. c.x = 140;
  42056. c.y = 10;
  42057. a.addChild(c, 2);
  42058. a = ccui.ImageView.create();
  42059. a.loadTexture(res.banzi);
  42060. a.setScale9Enabled(!0);
  42061. a.setContentSize(cc.size(617, 111));
  42062. a.setTextureRect(cc.rect(80, 37, 1, 1));
  42063. a.x = gameSize.width / 2;
  42064. a.y = gameSize.height / 2 + 185;
  42065. this.addChild(a, 2);
  42066. GameL.ready = cc.Sprite.create(res.ready_png);
  42067. GameL.ready.setAnchorPoint(cc.p(0.5, 0.5));
  42068. GameL.ready.x = gameSize.width / 2;
  42069. GameL.ready.y = gameSize.height / 2 + 150;
  42070. GameL.ready.visible = !1;
  42071. this.addChild(GameL.ready, 100);
  42072. GameL.go = cc.Sprite.create(res.go_png);
  42073. GameL.go.setAnchorPoint(cc.p(0.5, 0.5));
  42074. GameL.go.x = gameSize.width / 2;
  42075. GameL.go.y = gameSize.height / 2;
  42076. GameL.go.visible = !1;
  42077. this.addChild(GameL.go, 100);
  42078. lead = cc.Sprite.create(res.s_role1);
  42079. lead.setAnchorPoint(cc.p(0.5, 0.5));
  42080. lead.x = gameSize.width / 2 - 130;
  42081. lead.y = gameSize.height / 2 + 364;
  42082. this.addChild(lead, 10);
  42083. GameL.victoryNum = new cc.LabelBMFont("0", res.s_fnt);
  42084. GameL.victoryNum.x = gameSize.width / 2 + 70;
  42085. GameL.victoryNum.y = gameSize.height / 2 + 305;
  42086. GameL.victoryNum.setScale(2);
  42087. this.addChild(GameL.victoryNum, 15);
  42088. a = cc.Sprite.create(res.buttomBg_png);
  42089. a.setAnchorPoint(cc.p(0.5, 0.5));
  42090. a.x = gameSize.width / 2;
  42091. a.y = gameSize.height / 2 - 375;
  42092. a.scaleY = 0.95;
  42093. this.addChild(a, 5);
  42094. c = cc.Sprite.create(res.s_jin);
  42095. a.setAnchorPoint(cc.p(0.5, 0.5));
  42096. c.x = gameSize.width / 2 + 130;
  42097. c.y = gameSize.height / 2 + 305;
  42098. a.scaleX = 0.95;
  42099. a.scaleY = 0.95;
  42100. this.addChild(c, 15);
  42101. a = cc.Sprite.create(res.wordBg_png);
  42102. a.setAnchorPoint(cc.p(0.5, 0.5));
  42103. a.x = gameSize.width / 2 + 100;
  42104. a.y = gameSize.height / 2 + 300;
  42105. a.scaleX = 0.9;
  42106. a.scaleY = 0.9;
  42107. this.addChild(a, 10);
  42108. a = cc.Sprite.create(res.progressBarBg_png);
  42109. a.setAnchorPoint(cc.p(0.5, 0.5));
  42110. a.x = gameSize.width / 2 + 10;
  42111. a.y = gameSize.height / 2 + 160;
  42112. a.scaleX = 1;
  42113. a.scaleY = 0.93;
  42114. this.addChild(a, 1);
  42115. GameL.timeBar = new ccui.LoadingBar;
  42116. GameL.timeBar.setName("TimeBar");
  42117. GameL.timeBar.loadTexture(res.progressBar_png);
  42118. GameL.timeBar.setDirection(ccui.LoadingBar.TYPE_LEFT);
  42119. GameL.timeBar.setPercent(100);
  42120. GameL.timeBar.x = gameSize.width / 2;
  42121. GameL.timeBar.y = gameSize.height / 2 + 160;
  42122. this.addChild(GameL.timeBar, 3);
  42123. Func.barReset = function() {
  42124. GameL.timeBar.setPercent(100)
  42125. };
  42126. a = cc.Sprite.create(res.time_png);
  42127. a.setAnchorPoint(cc.p(0.5, 0.5));
  42128. a.x = gameSize.width / 2 - 231;
  42129. a.y = gameSize.height / 2 + 160;
  42130. a.scaleX = 0.93;
  42131. a.scaleY = 0.93;
  42132. this.addChild(a, 4);
  42133. this.wrongMark = cc.Sprite.create(res.wrongMark_png);
  42134. this.wrongMark.x = gameSize.width / 2 + 145;
  42135. this.wrongMark.y = gameSize.height / 2 - 210;
  42136. this.wrongMark.visible = !1;
  42137. this.addChild(this.wrongMark, 14);
  42138. GameL.listener = cc.EventListener.create({
  42139. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  42140. swallowTouches: !0,
  42141. onTouchBegan: function(a, c) {
  42142. var d = c.getCurrentTarget();
  42143. 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) {
  42144. Data.buttonContinue++;
  42145. if (Data.buttonContinue > Data.res_num.length) {
  42146. Data.buttonContinue = Data.foodHeapArray.length;
  42147. return
  42148. }
  42149. Func.makeFoodHeap(d.foodName)
  42150. }
  42151. return !1
  42152. },
  42153. onTouchMoved: function(a, c) {},
  42154. onTouchEnded: function(a, c) {
  42155. c.getCurrentTarget().setOpacity(255);
  42156. this.judgeEvent(c.getCurrentTarget().name)
  42157. }
  42158. });
  42159. 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()));
  42160. 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);
  42161. cc.log("Data.res fuzhi \x3d ");
  42162. cc.log(Data.res_num);
  42163. Func.makeFoodModel(Data.res_num, this);
  42164. Func.makeRightButtom(Data.res_num, this);
  42165. Func.reloadGame = function() {
  42166. Data.releadTimes = 0;
  42167. Data.releadNeedCount = Data.modelFoodArray.length - 1;
  42168. switch (Data.victoryNum) {
  42169. case 10:
  42170. lead.setTexture(res.s_role2);
  42171. break;
  42172. case 20:
  42173. lead.setTexture(res.s_role3)
  42174. }
  42175. Func.finish_down(Data.modelFoodArray, 100, -100, function() {
  42176. if (Data.releadTimes >= Data.releadNeedCount) {
  42177. Data.modelFoodArray.top && Data.modelFoodArray.top.removeFromParent();
  42178. Data.modelFoodArray.buttom && Data.modelFoodArray.buttom.removeFromParent();
  42179. if (Data.modelFoodArray.middle)
  42180. for (var a = 0; a < Data.modelFoodArray.middle.length; a++) Data.modelFoodArray.middle[a].removeFromParent();
  42181. Data.foodHeapArray = Func.removeSpirtArray(Data.foodHeapArray);
  42182. Data.point = 0;
  42183. Data.res_button = [];
  42184. Data.res_num = [];
  42185. Func.ice_random();
  42186. Func.res_random(Data.victoryNum);
  42187. Func.res_ra = Data.res_num.foodtype;
  42188. for (a = 0; a < Data.res_button.length; a++) {
  42189. Data.foodArray[a].type = "food";
  42190. Data.foodArray[a].setAnchorPoint(cc.p(1, 1));
  42191. var c = Data.res_button[a];
  42192. Data.foodArray[a].foodName = c;
  42193. Data.foodArray[a].setTexture(c);
  42194. Data.foodArray[a].x = 200 * a + gameSize.width / 2 - 140 - (142 - Data.foodArray[a].width) / 2;
  42195. Data.foodArray[a].y = 90 + gameSize.height / 2 - 433 - (105 - Data.foodArray[a].height)
  42196. }
  42197. Func.makeFoodModel(Data.res_num, this);
  42198. Func.makeRightButtom(Data.res_num, this)
  42199. } else Data.releadTimes++
  42200. })
  42201. };
  42202. var d = function(a, c) {
  42203. setTimeout(function() {
  42204. a();
  42205. d(a, c)
  42206. }, c)
  42207. };
  42208. d(function() {
  42209. if (!Data.gameStop)
  42210. if (Data.alreadyGoTime == Config.alreadyGoTime && (Data.touchAble = !1), 0 < Data.alreadyGoTime) GameL.ready.visible = !0, 15 > Data.alreadyGoTime && (GameL.go.visible = !0), Data.alreadyGoTime--;
  42211. else {
  42212. 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);
  42213. GameL.timeBar.setPercent(100 * Data.lastTime / Config.progressBarConfig.limit);
  42214. var a = (new Date).getTime();
  42215. a < Data.beforeTime && (Data.startTime = a - Data.deltaTime, alert("\u6539\u65f6\u95f4\u4e5f\u6ca1\u7528\u6492"));
  42216. Data.beforeTime = a;
  42217. Data.deltaTime = a - Data.startTime;
  42218. Data.lastTime = Config.progressBarConfig.now - Data.deltaTime;
  42219. 11E3 >= Data.lastTime && Data.music.last10sec && (Data.music.last10sec = !1, cc.audioEngine.stopMusic(!0), Data.music.last10MusicId = cc.audioEngine.playEffect(music.last10sec));
  42220. 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;
  42221. 0 > Data.lastTime && (Data.lastTime = 0, Data.gameStop = !0, cc.audioEngine.stopMusic(!0), cc.audioEngine.stopEffect(Data.music.last10MusicId), Func.result(Data.victoryNum))
  42222. }
  42223. }, 10);
  42224. return !0
  42225. }
  42226. }),
  42227. GameL = null;
  42228. var gameScene = null,
  42229. layerLogin = null,
  42230. gameSize = null,
  42231. layerGame = null,
  42232. gameOver = null,
  42233. b_guide_bu = null,
  42234. b_begin = null,
  42235. b_guide = null,
  42236. loginScene = cc.Scene.extend({
  42237. onEnter: function() {
  42238. this._super();
  42239. layerLogin = new login;
  42240. this.addChild(layerLogin);
  42241. layerGame = new GameLayer;
  42242. gameOver = new layerOver;
  42243. gameOver.setVisible(!1);
  42244. this.addChild(gameOver, 100)
  42245. }
  42246. }),
  42247. login = cc.Layer.extend({
  42248. beganNum: 0,
  42249. ctor: function() {
  42250. this._super();
  42251. gameSize = cc.winSize;
  42252. cc.log("game" + gameSize);
  42253. this.init()
  42254. },
  42255. init: function() {
  42256. var a = new cc.Sprite(res.background_png);
  42257. a.attr({
  42258. x: gameSize.width / 2,
  42259. y: gameSize.height / 2,
  42260. anchorX: 0.5,
  42261. anchorY: 0.5,
  42262. scaleX: 2.3,
  42263. scaleY: 2.6
  42264. });
  42265. this.addChild(a, 2);
  42266. a = new cc.Sprite(res.gameLogo_png);
  42267. a.attr({
  42268. x: gameSize.width / 2,
  42269. y: gameSize.height / 2 + 400,
  42270. anchorX: 0.5,
  42271. anchorY: 0.5
  42272. });
  42273. this.addChild(a, 2);
  42274. a = new cc.Sprite(res.login_figure);
  42275. a.attr({
  42276. x: gameSize.width / 2,
  42277. y: gameSize.height / 2,
  42278. anchorX: 0.5,
  42279. anchorY: 0.5
  42280. });
  42281. this.addChild(a, 2);
  42282. b_begin = new ccui.Button;
  42283. b_begin.loadTextures(res.btnNewGame_png, "", "");
  42284. b_begin.x = gameSize.width / 2;
  42285. b_begin.y = gameSize.height / 2 - 300;
  42286. b_begin.addTouchEventListener(this.beginEvent, this);
  42287. this.addChild(b_begin, 2);
  42288. b_guide_bu = new ccui.Button;
  42289. b_guide_bu.loadTextures(res.s_guide_png, res.s_guide_png, "");
  42290. b_guide_bu.x = gameSize.width / 2;
  42291. b_guide_bu.y = gameSize.height / 2 + 30;
  42292. b_guide_bu.addTouchEventListener(this.guide_buEvent, this);
  42293. b_guide_bu.setTouchEnabled(!1);
  42294. b_guide_bu.setVisible(!1);
  42295. this.addChild(b_guide_bu, 10)
  42296. },
  42297. beginEvent: function(a, c) {
  42298. switch (c) {
  42299. case ccui.Widget.TOUCH_ENDED:
  42300. cc.log("\u5f00\u59cb"), b_guide_bu.setVisible(!0), b_guide_bu.setTouchEnabled(!0);
  42301. }
  42302. },
  42303. guide_buEvent: function(a, c) {
  42304. switch (c) {
  42305. case ccui.Widget.TOUCH_ENDED:
  42306. 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)
  42307. }
  42308. }
  42309. });
  42310. var Data = {
  42311. res_button: [],
  42312. res_num: [],
  42313. foodArray: [],
  42314. foodHeapArray: [],
  42315. point: 0,
  42316. iceType: null,
  42317. victoryNum: 1,
  42318. gameStop: !1,
  42319. touchAble: !0,
  42320. wrongMarkTime: 0,
  42321. buttonCountinue: 0,
  42322. alreadyGoTime: Config.alreadyGoTime,
  42323. music: {
  42324. bgMusicId: 0,
  42325. hits: 0,
  42326. last10sec: !1,
  42327. last10MusicId: 0
  42328. },
  42329. modelFoodArray: [],
  42330. startTime: 0,
  42331. beforeTime: 0,
  42332. deltaTime: 0,
  42333. lastTime: Config.progressBarConfig.now,
  42334. reloadTimes: 0,
  42335. reloadNeedCount: 0
  42336. };
  42337. var Func = {
  42338. ice_random: function() {
  42339. var a = Math.ceil(3 * Math.random());
  42340. cc.log("this_randomCuot" + a);
  42341. 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;
  42342. else switch (a) {
  42343. case 1:
  42344. Func.ice_Event(Config.ice);
  42345. 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");
  42346. break;
  42347. case 2:
  42348. Func.ice_Event(Config.cake);
  42349. 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");
  42350. break;
  42351. case 3:
  42352. 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")
  42353. }
  42354. cc.log("return Res-Button");
  42355. cc.log(Data.res_button);
  42356. cc.log(Data.res_button.bheight);
  42357. a = Math.ceil(3 * Math.random());
  42358. Data.res_num.splice(a - 1, 1, Data.res_num[2]);
  42359. return Data.res_button
  42360. },
  42361. ice_Event: function(a) {
  42362. Data.res_num || (Data.res_num = []);
  42363. Data.res_button || (Data.res_button = []);
  42364. for (var c = 0; c < a.length; c++) Data.res_num.push(a[c]), Data.res_button.push(a[c])
  42365. },
  42366. res_random: function(a) {
  42367. cc.log("cishu \x3d " + a);
  42368. cc.log("all_cout0" + a);
  42369. 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);
  42370. else {
  42371. 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]);
  42372. 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 ");
  42373. else if (16 > a) {
  42374. cc.log("all count 16 " + a);
  42375. cc.log("di 16 ci data");
  42376. cc.log(Data.res_button);
  42377. cc.log(Data.res_num);
  42378. a = Math.ceil(3 * Math.random());
  42379. switch (Math.ceil(3 * Math.random())) {
  42380. case 1:
  42381. Data.res_num.splice(a - 1, 1);
  42382. break;
  42383. case 2:
  42384. a = Data.res_num[a - 1];
  42385. Data.res_num.push(a);
  42386. break;
  42387. case 3:
  42388. Data.res_num.splice(a - 1, 1, Data.res_num[0])
  42389. }
  42390. cc.log("xiaoyu 16 de ")
  42391. } else if (25 > a) {
  42392. cc.log("all count 25 " + a);
  42393. cc.log("di 25 ci data");
  42394. cc.log(Data.res_button);
  42395. cc.log(Data.res_num);
  42396. a = Math.ceil(3 * Math.random());
  42397. switch (Math.ceil(4 * Math.random())) {
  42398. case 1:
  42399. Data.res_num.splice(a - 1, 1);
  42400. break;
  42401. case 2:
  42402. a = Data.res_num[a - 1];
  42403. Data.res_num.push(a);
  42404. break;
  42405. case 3:
  42406. a = Data.res_num[a - 1];
  42407. var c = Data.res_num[2];
  42408. Data.res_num.push(c);
  42409. Data.res_num.push(a);
  42410. break;
  42411. case 4:
  42412. Data.res_num.splice(a - 1, 1, Data.res_num[1])
  42413. }
  42414. cc.log("xiaoyu 25 de ")
  42415. } else {
  42416. cc.log("all count 28 " + a);
  42417. cc.log("di 28 ci data");
  42418. cc.log(Data.res_button);
  42419. cc.log(Data.res_num);
  42420. a = Math.ceil(3 * Math.random());
  42421. switch (Math.ceil(3 * Math.random())) {
  42422. case 1:
  42423. a = Data.res_num[a - 1];
  42424. Data.res_num.push(a);
  42425. break;
  42426. case 2:
  42427. a = Data.res_num[a - 1];
  42428. c = Data.res_num[2];
  42429. Data.res_num.push(c);
  42430. Data.res_num.push(a);
  42431. break;
  42432. case 3:
  42433. Data.res_num.splice(a - 1, 1, Data.res_num[0])
  42434. }
  42435. cc.log("dayu 25 de ")
  42436. }
  42437. cc.log(Data.res_num)
  42438. }
  42439. return Data.res_num
  42440. },
  42441. makeRightButtom: function(a) {
  42442. if (null != a) {
  42443. null == Data.foodHeapArray && (Data.foodHeapArray = []);
  42444. 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);
  42445. var c = Data.foodHeapArray.buttom.y + Data.foodHeapArray.buttom.bheight + 30;
  42446. if (a.middle) {
  42447. Data.foodHeapArray.middle = [];
  42448. Data.foodHeapArray.middleHeight = a.middleHeight;
  42449. for (var d = a.length - 1, e = 0; e < d; e++) {
  42450. var f = cc.Sprite.create(a.middle);
  42451. f.scaleX = 1;
  42452. f.scaleY = 1;
  42453. GameL.addChild(f, 9);
  42454. f.x = gameSize.width / 2 + 142;
  42455. f.y = c;
  42456. Data.foodHeapArray.middle.push(f);
  42457. c += Data.foodHeapArray.middleHeight
  42458. }
  42459. }
  42460. 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);
  42461. a.itemHeight && (Data.foodHeapArray.itemHeight = a.itemHeight);
  42462. a.foodtype && (Data.foodHeapArray.foodtype = a.foodtype)
  42463. }
  42464. },
  42465. makeFoodHeap: function(a) {
  42466. if (null != a && (null == Data.foodHeapArray && (Data.foodHeapArray = []), !(Data.foodHeapArray.length >= Data.modelFoodArray.length))) {
  42467. var c = cc.Sprite.create(a);
  42468. c.foodImg = a;
  42469. Data.foodHeapArray.push(c);
  42470. var d = Data.foodHeapArray.length - 1;
  42471. c.scaleX = 1;
  42472. c.scaleY = 1;
  42473. c.x = gameSize.width / 2 + 142;
  42474. c.y = 1E3 + 50 * d;
  42475. c.foodtype = Data.foodHeapArray.foodtype;
  42476. GameL.addChild(c, 10);
  42477. var e = null;
  42478. switch (Data.music.hits) {
  42479. case 0:
  42480. e = music.hits1;
  42481. break;
  42482. case 1:
  42483. e = music.hits2;
  42484. break;
  42485. case 2:
  42486. e = music.hits3;
  42487. break;
  42488. case 3:
  42489. e = music.hits4;
  42490. break;
  42491. default:
  42492. e = music.hits4
  42493. };
  42494. cc.audioEngine.playEffect(e);
  42495. Func.item_down(c, gameSize.width / 2 + 142, Data.modelFoodArray.buttom.bheight + d * Data.modelFoodArray.itemHeight + gameSize.height / 2 - 280, function() {
  42496. 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)
  42497. })
  42498. }
  42499. },
  42500. makeFoodModel: function(a) {
  42501. if (null != a) {
  42502. null == Data.modelFoodArray && (Data.modelFoodArray = []);
  42503. Data.modelFoodArray.foodtype = a.foodtype;
  42504. a.itemHeight && (Data.modelFoodArray.itemHeight = a.itemHeight);
  42505. Data.modelFoodArray.buttom = null;
  42506. Data.modelFoodArray.top = null;
  42507. 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);
  42508. var c = Data.modelFoodArray.buttom.y + Data.modelFoodArray.buttom.bheight + 30;
  42509. if (a.middle) {
  42510. Data.modelFoodArray.middle = [];
  42511. Data.modelFoodArray.middleHeight = a.middleHeight;
  42512. for (var d = a.length - 1, e = 0; e < d; e++) {
  42513. var f = cc.Sprite.create(a.middle);
  42514. f.scaleX = 1;
  42515. f.scaleY = 1;
  42516. GameL.addChild(f, 9);
  42517. f.x = gameSize.width / 2 - 132;
  42518. f.y = c;
  42519. Data.modelFoodArray.middle.push(f);
  42520. c += Data.modelFoodArray.middleHeight
  42521. }
  42522. }
  42523. for (e = 0; e < Data.modelFoodArray.length; e++) Data.modelFoodArray[e].visible = !1;
  42524. d = Data.modelFoodArray.buttom.bheight + Data.modelFoodArray.itemHeight + gameSize.height / 2 - 280;
  42525. 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;
  42526. 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)
  42527. }
  42528. },
  42529. isRight: function(a) {
  42530. return !(Data.point >= Data.res_num.length) && Data.res_num[Data.point] == a ? (Data.point++, !0) : !1
  42531. },
  42532. isAllOk: function() {
  42533. if (Data.foodHeapArray.length == Data.res_num.length) {
  42534. for (var a = !0, c = 0; c < Data.foodHeapArray.length; c++) Data.foodHeapArray[c].foodImg != Data.res_num[c] && (a = !1);
  42535. !1 == a && (Data.buttonContinue = 0, Data.wrongMarkTime = 10);
  42536. return a
  42537. }
  42538. return !1
  42539. },
  42540. removeSpirtArray: function(a) {
  42541. cc.log("begin remove");
  42542. a.top && a.top.removeFromParent();
  42543. a.buttom && a.buttom.removeFromParent();
  42544. if (a.middle)
  42545. for (var c = 0; c < a.middle.length; c++) a.middle[c].removeFromParent();
  42546. for (c = 0; c < a.length; c++) console.log(a[c]), a[c].removeFromParent();
  42547. cc.log(a);
  42548. cc.log("end");
  42549. return []
  42550. },
  42551. reloadGame: null,
  42552. item_down: function(a, c, d, e) {
  42553. cc.log("sheng create");
  42554. cc.log(a.foodtype);
  42555. switch (a.foodtype) {
  42556. case "ice":
  42557. Func.iceAction(a, c, d, e);
  42558. break;
  42559. case "cake":
  42560. Func.cakeAction(a, c, d, e);
  42561. break;
  42562. case "macarons":
  42563. Func.macarons(a, c, d, e)
  42564. }
  42565. },
  42566. iceAction: function(a, c, d, e) {
  42567. c = new cc.MoveTo(0.3, cc.p(c, d - 24));
  42568. d = new cc.ScaleTo(0.1, 1, 1.4);
  42569. var f = new cc.ScaleTo(0.1, 1, 1),
  42570. g = new cc.ScaleTo(0.1, 1, 1.3),
  42571. h = new cc.ScaleTo(0.1, 1, 1),
  42572. k = new cc.ScaleTo(0.1, 1, 1.2),
  42573. m = new cc.ScaleTo(0.1, 1, 1),
  42574. n = new cc.ScaleTo(0.1, 1, 1.1),
  42575. q = new cc.ScaleTo(0.1, 1, 1);
  42576. e = new cc.Sequence(c, d, f, g, h, k, m, n, q, new cc.CallFunc(e, this, !0));
  42577. a.setAnchorPoint(cc.p(0.5, 0));
  42578. a.runAction(e)
  42579. },
  42580. macarons: function(a, c, d, e) {
  42581. c = new cc.MoveTo(0.3, cc.p(c, d + 35));
  42582. d = new cc.RotateTo(0.1, -10);
  42583. var f = new cc.RotateTo(0.1, 0),
  42584. g = new cc.RotateTo(0.1, 10),
  42585. h = new cc.RotateTo(0.1, 0),
  42586. k = new cc.RotateTo(0.1, 5),
  42587. m = new cc.RotateTo(0.1, 0);
  42588. e = new cc.Sequence(c, d, f, g, h, k, m, new cc.CallFunc(e, this, !0));
  42589. a.runAction(e)
  42590. },
  42591. cakeAction: function(a, c, d, e) {
  42592. cc.log("zhixing cakeAction");
  42593. c = new cc.MoveTo(0.2, cc.p(c, d + 35));
  42594. d = new cc.ScaleTo(0.1, 1, 1);
  42595. var f = new cc.ScaleTo(0.1, 1, 0.8),
  42596. g = new cc.ScaleTo(0.1, 1, 1.1),
  42597. h = new cc.ScaleTo(0.1, 1, 0.9),
  42598. k = new cc.ScaleTo(0.1, 1, 1),
  42599. m = new cc.ScaleTo(0.1, 1, 0.95),
  42600. n = new cc.ScaleTo(0.1, 1, 1.02),
  42601. q = new cc.ScaleTo(0.1, 1, 1);
  42602. cc.log("wupin diao luo");
  42603. cc.log(a);
  42604. e = new cc.Sequence(c, d, f, g, h, k, m, n, q, new cc.CallFunc(e, this, !0));
  42605. a.setAnchorPoint(cc.p(0.5, 0.3));
  42606. cc.log("\u6389\u843d\u5b8c\u6210");
  42607. a.runAction(e)
  42608. },
  42609. finish_down: function(a, c, d, e) {
  42610. for (var f = 0; f < a.length; f++) {
  42611. var g = new cc.MoveTo(0.1, cc.p(c, d)),
  42612. g = new cc.Sequence(g, new cc.CallFunc(e, this, !0));
  42613. a[f].runAction(g)
  42614. }
  42615. a.buttom && (g = new cc.MoveTo(0.1, cc.p(c, d)), g = new cc.Sequence(g), a.buttom.runAction(g));
  42616. a.top && (g = new cc.MoveTo(0.1, cc.p(c, d)), g = new cc.Sequence(g), a.top.runAction(g));
  42617. if (a.middle)
  42618. 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)
  42619. },
  42620. overfunc: null,
  42621. result: function(a) {
  42622. cc.log("gameOver");
  42623. GameL.visible = !1;
  42624. dp_submitScore(a - 1);
  42625. window.scroe = a - 1;
  42626. // updateShare(a - 1);
  42627. // Play68.setRankingScoreDesc(a - 1);
  42628. document.getElementById("toolbar").style.display = "block";
  42629. Func.overfunc(a);
  42630. cc.audioEngine.playEffect(music.result)
  42631. },
  42632. barReset: null,
  42633. reStart: function() {
  42634. Data.foodHeapArray = Func.removeSpirtArray(Data.foodHeapArray);
  42635. GameL.visible = !0;
  42636. Data.res_button = [];
  42637. Data.res_num = [];
  42638. Data.foodHeapArray = [];
  42639. Data.point = 0;
  42640. Data.iceType = null;
  42641. Data.victoryNum = 1;
  42642. GameL.victoryNum.setString(Data.victoryNum - 1 + "\u65a4");
  42643. Data.gameStop = !1;
  42644. Data.touchAble = !0;
  42645. Data.wrongMarkTime = 0;
  42646. Data.music.hits = 0;
  42647. Data.alreadyGoTime = Config.alreadyGoTime;
  42648. Data.lastTime = Config.progressBarConfig.now;
  42649. Func.barReset();
  42650. Func.reloadGame()
  42651. },
  42652. createNumSprite: function(a) {
  42653. new cc.Sprite("")
  42654. }
  42655. };
  42656. Func.overfunc = function(a) {
  42657. cc.log("gameOver begin");
  42658. b_share.setTouchEnabled(!0);
  42659. cc.log("get cunt \x3d" + a);
  42660. fin_cunt = a - 1;
  42661. gameOver.setVisible(!0);
  42662. cc.log(gameOver.overrole);
  42663. 10 > fin_cunt ? gameOver.overrole.loadTexture(res.s_role1) : 20 > fin_cunt ? gameOver.overrole.loadTexture(res.s_role2) : gameOver.overrole.loadTexture(res.s_role3);
  42664. gameOver.num.setString(fin_cunt);
  42665. gameOver.numJin.setString(fin_cunt);
  42666. return !0
  42667. };
  42668. var fin_cunt = null,
  42669. b_again = null,
  42670. b_share = null,
  42671. b_share_l = null,
  42672. layerOver = cc.Layer.extend({
  42673. overrole: null,
  42674. paopao: null,
  42675. fenxiangzi: null,
  42676. fenxiang: null,
  42677. num: null,
  42678. numJin: null,
  42679. overfigure: null,
  42680. b_share1: null,
  42681. ctor: function() {
  42682. this._super();
  42683. this.init()
  42684. },
  42685. init: function() {
  42686. this.backsprite = new cc.Sprite(res.background_png);
  42687. this.backsprite.attr({
  42688. x: gameSize.width / 2,
  42689. y: gameSize.height / 2,
  42690. anchorX: 0.5,
  42691. anchorY: 0.5,
  42692. scaleX: 2.1,
  42693. scaleY: 2
  42694. });
  42695. this.addChild(this.backsprite, 2);
  42696. cc.log("fin_cunt\x3d" + fin_cunt);
  42697. this.overfigure = new cc.Sprite(res.dialogBg);
  42698. this.overfigure.attr({
  42699. x: gameSize.width / 2,
  42700. y: gameSize.height / 2 - 200,
  42701. anchorX: 0.5,
  42702. anchorY: 0.5
  42703. });
  42704. this.addChild(this.overfigure, 2);
  42705. this.num = new cc.LabelBMFont("0", res.s_fnt);
  42706. this.num.x = gameSize.width / 2 + 135;
  42707. this.num.y = gameSize.height / 2 - 175;
  42708. this.addChild(this.num, 3);
  42709. this.numJin = new cc.LabelBMFont("0", res.s_fnt);
  42710. this.numJin.x = gameSize.width / 2 - 50;
  42711. this.numJin.y = gameSize.height / 2 - 175;
  42712. this.addChild(this.numJin, 3);
  42713. this.overrole = new ccui.ImageView;
  42714. this.overrole.x = gameSize.width / 2;
  42715. this.overrole.y = gameSize.height / 2 + 30;
  42716. this.overrole.loadTexture(res.s_role1);
  42717. this.addChild(this.overrole, 2);
  42718. b_again = new ccui.Button;
  42719. b_again.loadTextures(res.btnShare_png, "", "");
  42720. b_again.x = gameSize.width / 2 - 130;
  42721. b_again.y = gameSize.height / 2 - 360;
  42722. b_again.addTouchEventListener(this.shareTips, this);
  42723. b_again.setTouchEnabled(!1);
  42724. b_again.setVisible(!1);
  42725. this.addChild(b_again, 11);
  42726. b_again2 = new ccui.Button;
  42727. b_again2.loadTextures(res.btnAgain_png, "", "");
  42728. b_again2.x = gameSize.width / 2 - 130;
  42729. b_again2.y = gameSize.height / 2 - 360;
  42730. b_again2.addTouchEventListener(this.againEvent, this);
  42731. this.addChild(b_again2, 2);
  42732. b_share = new ccui.Button;
  42733. b_share.loadTextures(res.btnKnown, "", "");
  42734. b_share.x = gameSize.width / 2 + 130;
  42735. b_share.y = gameSize.height / 2 - 360;
  42736. b_share.addTouchEventListener(this.shareEvent, this);
  42737. this.addChild(b_share, 2);
  42738. this.b_share1 = new ccui.Button;
  42739. this.b_share1.loadTextures(res.btnShare1, "", "");
  42740. this.b_share1.x = gameSize.width / 2 + 130;
  42741. this.b_share1.y = gameSize.height / 2 - 360;
  42742. this.b_share1.addTouchEventListener(this.jumpurl, this);
  42743. this.b_share1.setTouchEnabled(!1);
  42744. this.b_share1.setVisible(!1);
  42745. this.addChild(this.b_share1, 11);
  42746. b_share_l = new ccui.Button;
  42747. b_share_l.loadTextures(res.s_share, "", "");
  42748. b_share_l.x = gameSize.width / 2;
  42749. b_share_l.y = gameSize.height / 2 + 30;
  42750. b_share_l.addTouchEventListener(this.shareLayerEvent, this);
  42751. b_share_l.setTouchEnabled(!1);
  42752. b_share_l.setVisible(!1);
  42753. this.addChild(b_share_l, 10);
  42754. this.paopao = new cc.Sprite(res.s_paopao);
  42755. this.paopao.attr({
  42756. x: gameSize.width / 2 + 90,
  42757. y: gameSize.height - 80,
  42758. anchorX: 0.5,
  42759. anchorY: 0.5
  42760. });
  42761. this.paopao.setVisible(!1);
  42762. this.addChild(this.paopao, 12);
  42763. this.fenxiangzi = new cc.Sprite(res.s_fenxiangzi);
  42764. this.fenxiangzi.attr({
  42765. x: gameSize.width / 2,
  42766. y: gameSize.height - 920,
  42767. anchorX: 0.5,
  42768. anchorY: 0.5
  42769. });
  42770. this.fenxiangzi.setVisible(!1);
  42771. this.addChild(this.fenxiangzi, 12);
  42772. this.fenxiang = new cc.Sprite(res.s_fenxiang);
  42773. this.fenxiang.attr({
  42774. x: gameSize.width / 2 + 80,
  42775. y: gameSize.height - 100,
  42776. anchorX: 0.5,
  42777. anchorY: 0.5
  42778. });
  42779. this.fenxiang.setVisible(!1);
  42780. this.addChild(this.fenxiang, 22)
  42781. },
  42782. againEvent: function(a, c) {
  42783. document.getElementById("toolbar").style.display = "none";
  42784. switch (c) {
  42785. case ccui.Widget.TOUCH_ENDED:
  42786. gameOver.setVisible(!1), b_again.setTouchEnabled(!1), b_share.setTouchEnabled(!1), Func.reStart();
  42787. }
  42788. },
  42789. shareTips: function(a, c) {
  42790. switch (c) {
  42791. case ccui.Widget.TOUCH_ENDED:
  42792. 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))
  42793. }
  42794. },
  42795. shareEvent: function(a, c) {
  42796. switch (c) {
  42797. case ccui.Widget.TOUCH_ENDED:
  42798. dp_share();
  42799. return;
  42800. 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)
  42801. }
  42802. },
  42803. shareLayerEvent: function(a, c) {
  42804. switch (c) {
  42805. case ccui.Widget.TOUCH_ENDED:
  42806. 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()
  42807. }
  42808. },
  42809. jumpurl: function(a, c) {
  42810. switch (c) {
  42811. case ccui.Widget.TOUCH_ENDED:
  42812. jump()
  42813. }
  42814. }
  42815. });
  42816. cc.game.onStart = function() {
  42817. cc.view.adjustViewPort(!0);
  42818. var a = cc.view.getFrameSize();
  42819. factorX = a.width / 640;
  42820. factorY = a.height / 960;
  42821. cc.view.setDesignResolutionSize(640, 960, cc.ResolutionPolicy.SHOW_ALL);
  42822. cc.LoaderScene.preload(g_resources, function() {
  42823. gameScene = new loginScene;
  42824. cc.director.runScene(gameScene)
  42825. }, this)
  42826. };
  42827. cc.game.run();