game.min.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497
  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, b, c, d) {
  11. a.addEventListener(b, c, d)
  12. };
  13. cc._isNodeJs = "undefined" !== typeof require && require("fs");
  14. cc.each = function(a, b, c) {
  15. if (a)
  16. if (a instanceof Array)
  17. for (var d = 0, e = a.length; d < e && !1 !== b.call(c, a[d], d); d++);
  18. else
  19. for (d in a)
  20. if (!1 === b.call(c, a[d], d)) break
  21. };
  22. cc.extend = function(a) {
  23. var b = 2 <= arguments.length ? Array.prototype.slice.call(arguments, 1) : [];
  24. cc.each(b, function(b) {
  25. for (var d in b) b.hasOwnProperty(d) && (a[d] = b[d])
  26. });
  27. return a
  28. };
  29. cc.isFunction = function(a) {
  30. return "function" === typeof a
  31. };
  32. cc.isNumber = function(a) {
  33. return "number" === typeof a || "[object Number]" === Object.prototype.toString.call(a)
  34. };
  35. cc.isString = function(a) {
  36. return "string" === typeof a || "[object String]" === Object.prototype.toString.call(a)
  37. };
  38. cc.isArray = function(a) {
  39. return Array.isArray(a) || "object" === typeof a && "[object Array]" === Object.prototype.toString.call(a)
  40. };
  41. cc.isUndefined = function(a) {
  42. return "undefined" === typeof a
  43. };
  44. cc.isObject = function(a) {
  45. return "object" === typeof a && "[object Object]" === Object.prototype.toString.call(a)
  46. };
  47. cc.isCrossOrigin = function(a) {
  48. if (!a) return cc.log("invalid URL"), !1;
  49. var b = a.indexOf("://");
  50. if (-1 === b) return !1;
  51. b = a.indexOf("/", b + 3);
  52. return (-1 === b ? a : a.substring(0, b)) !== location.origin
  53. };
  54. cc.AsyncPool = function(a, b, c, d, e) {
  55. var f = this;
  56. f._srcObj = a;
  57. f._limit = b;
  58. f._pool = [];
  59. f._iterator = c;
  60. f._iteratorTarget = e;
  61. f._onEnd = d;
  62. f._onEndTarget = e;
  63. f._results = a instanceof Array ? [] : {};
  64. f._isErr = !1;
  65. cc.each(a, function(a, b) {
  66. f._pool.push({
  67. index: b,
  68. value: a
  69. })
  70. });
  71. f.size = f._pool.length;
  72. f.finishedSize = 0;
  73. f._workingSize = 0;
  74. f._limit = f._limit || f.size;
  75. f.onIterator = function(a, b) {
  76. f._iterator = a;
  77. f._iteratorTarget = b
  78. };
  79. f.onEnd = function(a, b) {
  80. f._onEnd = a;
  81. f._onEndTarget = b
  82. };
  83. f._handleItem = function() {
  84. var a = this;
  85. if (!(0 === a._pool.length ||
  86. a._workingSize >= a._limit)) {
  87. var b = a._pool.shift(),
  88. c = b.value,
  89. d = b.index;
  90. a._workingSize++;
  91. a._iterator.call(a._iteratorTarget, c, d, function(b) {
  92. if (!a._isErr)
  93. if (a.finishedSize++, a._workingSize--, b) a._isErr = !0, a._onEnd && a._onEnd.call(a._onEndTarget, b);
  94. else {
  95. var c = Array.prototype.slice.call(arguments, 1);
  96. a._results[this.index] = c[0];
  97. a.finishedSize === a.size ? a._onEnd && a._onEnd.call(a._onEndTarget, null, a._results) : a._handleItem()
  98. }
  99. }.bind(b), a)
  100. }
  101. };
  102. f.flow = function() {
  103. if (0 === this._pool.length) this._onEnd && this._onEnd.call(this._onEndTarget,
  104. null, []);
  105. else
  106. for (var a = 0; a < this._limit; a++) this._handleItem()
  107. }
  108. };
  109. cc.async = {
  110. series: function(a, b, c) {
  111. a = new cc.AsyncPool(a, 1, function(a, b, f) {
  112. a.call(c, f)
  113. }, b, c);
  114. a.flow();
  115. return a
  116. },
  117. parallel: function(a, b, c) {
  118. a = new cc.AsyncPool(a, 0, function(a, b, f) {
  119. a.call(c, f)
  120. }, b, c);
  121. a.flow();
  122. return a
  123. },
  124. waterfall: function(a, b, c) {
  125. var d = [],
  126. e = [null],
  127. f = new cc.AsyncPool(a, 1, function(b, f, k) {
  128. d.push(function(b) {
  129. d = Array.prototype.slice.call(arguments, 1);
  130. a.length - 1 === f && (e = e.concat(d));
  131. k.apply(null, arguments)
  132. });
  133. b.apply(c, d)
  134. }, function(a) {
  135. if (b) {
  136. if (a) return b.call(c, a);
  137. b.apply(c, e)
  138. }
  139. });
  140. f.flow();
  141. return f
  142. },
  143. map: function(a, b, c, d) {
  144. var e = b;
  145. "object" === typeof b && (c = b.cb, d = b.iteratorTarget, e = b.iterator);
  146. a = new cc.AsyncPool(a, 0, e, c, d);
  147. a.flow();
  148. return a
  149. },
  150. mapLimit: function(a, b, c, d, e) {
  151. a = new cc.AsyncPool(a, b, c, d, e);
  152. a.flow();
  153. return a
  154. }
  155. };
  156. cc.path = {
  157. join: function() {
  158. for (var a = arguments.length, b = "", c = 0; c < a; c++) b = (b + ("" === b ? "" : "/") + arguments[c]).replace(/(\/|\\\\)$/, "");
  159. return b
  160. },
  161. extname: function(a) {
  162. return (a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null
  163. },
  164. mainFileName: function(a) {
  165. if (a) {
  166. var b = a.lastIndexOf(".");
  167. if (-1 !== b) return a.substring(0, b)
  168. }
  169. return a
  170. },
  171. basename: function(a, b) {
  172. var c = a.indexOf("?");
  173. 0 < c && (a = a.substring(0, c));
  174. c = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, ""));
  175. if (!c) return null;
  176. c = c[2];
  177. return b && a.substring(a.length -
  178. b.length).toLowerCase() === b.toLowerCase() ? c.substring(0, c.length - b.length) : c
  179. },
  180. dirname: function(a) {
  181. return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2")
  182. },
  183. changeExtname: function(a, b) {
  184. b = b || "";
  185. var c = a.indexOf("?"),
  186. d = "";
  187. 0 < c && (d = a.substring(c), a = a.substring(0, c));
  188. c = a.lastIndexOf(".");
  189. return 0 > c ? a + b + d : a.substring(0, c) + b + d
  190. },
  191. changeBasename: function(a, b, c) {
  192. if (0 === b.indexOf(".")) return this.changeExtname(a, b);
  193. var d = a.indexOf("?"),
  194. e = "";
  195. c = c ? this.extname(a) : "";
  196. 0 < d && (e = a.substring(d), a = a.substring(0, d));
  197. d = a.lastIndexOf("/");
  198. return a.substring(0, 0 >= d ? 0 : d + 1) + b + c + e
  199. }
  200. };
  201. cc.loader = {
  202. _jsCache: {},
  203. _register: {},
  204. _langPathCache: {},
  205. _aliases: {},
  206. resPath: "",
  207. audioPath: "",
  208. cache: {},
  209. getXMLHttpRequest: function() {
  210. return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP")
  211. },
  212. _getArgs4Js: function(a) {
  213. var b = a[0],
  214. c = a[1],
  215. d = a[2],
  216. e = ["", null, null];
  217. if (1 === a.length) e[1] = b instanceof Array ? b : [b];
  218. else if (2 === a.length) "function" === typeof c ? (e[1] = b instanceof Array ? b : [b], e[2] = c) : (e[0] = b || "", e[1] = c instanceof Array ? c : [c]);
  219. else if (3 === a.length) e[0] = b || "", e[1] = c instanceof
  220. Array ? c : [c], e[2] = d;
  221. else throw "arguments error to load js!";
  222. return e
  223. },
  224. loadJs: function(a, b, c) {
  225. var d = this,
  226. e = d._jsCache,
  227. f = d._getArgs4Js(arguments),
  228. g = f[0],
  229. h = f[1],
  230. f = f[2]; - 1 < navigator.userAgent.indexOf("Trident/5") ? d._loadJs4Dependency(g, h, 0, f) : cc.async.map(h, function(a, b, c) {
  231. a = cc.path.join(g, a);
  232. if (e[a]) return c(null);
  233. d._createScript(a, !1, c)
  234. }, f)
  235. },
  236. loadJsWithImg: function(a, b, c) {
  237. var d = this._loadJsImg(),
  238. e = this._getArgs4Js(arguments);
  239. this.loadJs(e[0], e[1], function(a) {
  240. if (a) throw a;
  241. d.parentNode.removeChild(d);
  242. if (e[2]) e[2]()
  243. })
  244. },
  245. _createScript: function(a, b, c) {
  246. var d = document,
  247. e = cc.newElement("script");
  248. e.async = b;
  249. this._jsCache[a] = !0;
  250. cc.game.config.noCache && "string" === typeof a ? this._noCacheRex.test(a) ? e.src = a + "\x26_t\x3d" + (new Date - 0) : e.src = a + "?_t\x3d" + (new Date - 0) : e.src = a;
  251. cc._addEventListener(e, "load", function() {
  252. e.parentNode.removeChild(e);
  253. this.removeEventListener("load", arguments.callee, !1);
  254. c()
  255. }, !1);
  256. cc._addEventListener(e, "error", function() {
  257. e.parentNode.removeChild(e);
  258. c("Load " + a + " failed!")
  259. }, !1);
  260. d.body.appendChild(e)
  261. },
  262. _loadJs4Dependency: function(a,
  263. b, c, d) {
  264. if (c >= b.length) d && d();
  265. else {
  266. var e = this;
  267. e._createScript(cc.path.join(a, b[c]), !1, function(f) {
  268. if (f) return d(f);
  269. e._loadJs4Dependency(a, b, c + 1, d)
  270. })
  271. }
  272. },
  273. _loadJsImg: function() {
  274. var a = document,
  275. b = a.getElementById("cocos2d_loadJsImg");
  276. if (!b) {
  277. b = cc.newElement("img");
  278. cc._loadingImage && (b.src = cc._loadingImage);
  279. a = a.getElementById(cc.game.config.id);
  280. a.style.backgroundColor = "black";
  281. a.parentNode.appendChild(b);
  282. var c = getComputedStyle ? getComputedStyle(a) : a.currentStyle;
  283. c || (c = {
  284. width: a.width,
  285. height: a.height
  286. });
  287. b.style.left =
  288. a.offsetLeft + (parseFloat(c.width) - b.width) / 2 + "px";
  289. b.style.top = a.offsetTop + (parseFloat(c.height) - b.height) / 2 + "px";
  290. b.style.position = "absolute"
  291. }
  292. return b
  293. },
  294. loadTxt: function(a, b) {
  295. if (cc._isNodeJs) require("fs").readFile(a, function(a, c) {
  296. a ? b(a) : b(null, c.toString())
  297. });
  298. else {
  299. var c = this.getXMLHttpRequest(),
  300. d = "load " + a + " failed!";
  301. c.open("GET", a, !0);
  302. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (c.setRequestHeader("Accept-Charset", "utf-8"), c.onreadystatechange = function() {
  303. 4 === c.readyState &&
  304. (200 === c.status ? b(null, c.responseText) : b(d))
  305. }) : (c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dutf-8"), c.onload = function() {
  306. 4 === c.readyState && (200 === c.status ? b(null, c.responseText) : b(d))
  307. });
  308. c.send(null)
  309. }
  310. },
  311. _loadTxtSync: function(a) {
  312. if (cc._isNodeJs) return require("fs").readFileSync(a).toString();
  313. var b = this.getXMLHttpRequest();
  314. b.open("GET", a, !1);
  315. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? b.setRequestHeader("Accept-Charset", "utf-8") : b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dutf-8");
  316. b.send(null);
  317. return 4 === !b.readyState || 200 !== b.status ? null : b.responseText
  318. },
  319. loadCsb: function(a, b) {
  320. var c = new XMLHttpRequest;
  321. c.open("GET", a, !0);
  322. c.responseType = "arraybuffer";
  323. c.onload = function() {
  324. var d = c.response;
  325. d && (window.msg = d);
  326. 4 === c.readyState && (200 === c.status ? b(null, c.response) : b("load " + a + " failed!"))
  327. };
  328. c.send(null)
  329. },
  330. loadJson: function(a, b) {
  331. this.loadTxt(a, function(c, d) {
  332. if (c) b(c);
  333. else {
  334. try {
  335. var e = JSON.parse(d)
  336. } catch (f) {
  337. throw "parse json [" + a + "] failed : " + f;
  338. }
  339. b(null, e)
  340. }
  341. })
  342. },
  343. _checkIsImageURL: function(a) {
  344. return null !=
  345. /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)
  346. },
  347. loadImg: function(a, b, c) {
  348. var d = {
  349. isCrossOrigin: !0
  350. };
  351. void 0 !== c ? d.isCrossOrigin = null === b.isCrossOrigin ? d.isCrossOrigin : b.isCrossOrigin : void 0 !== b && (c = b);
  352. var e = this.getRes(a);
  353. if (e) return c && c(null, e), e;
  354. e = new Image;
  355. d.isCrossOrigin && "file://" !== location.origin && (e.crossOrigin = "Anonymous");
  356. var f = function() {
  357. this.removeEventListener("load", f, !1);
  358. this.removeEventListener("error", h, !1);
  359. cc.loader.cache[a] = e;
  360. c && c(null, e)
  361. },
  362. g = this,
  363. h = function() {
  364. this.removeEventListener("error",
  365. h, !1);
  366. e.crossOrigin && "anonymous" === e.crossOrigin.toLowerCase() ? (d.isCrossOrigin = !1, g.release(a), cc.loader.loadImg(a, d, c)) : "function" === typeof c && c("load image failed")
  367. };
  368. cc._addEventListener(e, "load", f);
  369. cc._addEventListener(e, "error", h);
  370. e.src = a;
  371. return e
  372. },
  373. _loadResIterator: function(a, b, c) {
  374. var d = this,
  375. e = null,
  376. f = a.type;
  377. f ? (f = "." + f.toLowerCase(), e = a.src ? a.src : a.name + f) : (e = a, f = cc.path.extname(e));
  378. if (b = d.getRes(e)) return c(null, b);
  379. b = null;
  380. f && (b = d._register[f.toLowerCase()]);
  381. if (!b) return cc.error("loader for [" +
  382. f + "] not exists!"), c();
  383. f = b.getBasePath ? b.getBasePath() : d.resPath;
  384. f = d.getUrl(f, e);
  385. cc.game.config.noCache && "string" === typeof f && (f = d._noCacheRex.test(f) ? f + ("\x26_t\x3d" + (new Date - 0)) : f + ("?_t\x3d" + (new Date - 0)));
  386. b.load(f, e, a, function(a, b) {
  387. a ? (cc.log(a), d.cache[e] = null, delete d.cache[e], c()) : (d.cache[e] = b, c(null, b))
  388. })
  389. },
  390. _noCacheRex: /\?/,
  391. getUrl: function(a, b) {
  392. var c = this._langPathCache,
  393. d = cc.path;
  394. if (void 0 !== a && void 0 === b) {
  395. b = a;
  396. var e = d.extname(b),
  397. e = e ? e.toLowerCase() : "";
  398. a = (e = this._register[e]) ? e.getBasePath ?
  399. e.getBasePath() : this.resPath : this.resPath
  400. }
  401. b = cc.path.join(a || "", b);
  402. if (b.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) {
  403. if (c[b]) return c[b];
  404. d = d.extname(b) || "";
  405. b = c[b] = b.substring(0, b.length - d.length) + "_" + cc.sys.language + d
  406. }
  407. return b
  408. },
  409. load: function(a, b, c) {
  410. var d = this,
  411. e = arguments.length;
  412. if (0 === e) throw "arguments error!";
  413. 3 === e ? "function" === typeof b && (b = "function" === typeof c ? {
  414. trigger: b,
  415. cb: c
  416. } : {
  417. cb: b,
  418. cbTarget: c
  419. }) : 2 === e ? "function" === typeof b && (b = {
  420. cb: b
  421. }) : 1 === e && (b = {});
  422. a instanceof Array || (a = [a]);
  423. e = new cc.AsyncPool(a, 0, function(a,
  424. c, e, k) {
  425. d._loadResIterator(a, c, function(a) {
  426. if (a) return e(a);
  427. var c = Array.prototype.slice.call(arguments, 1);
  428. b.trigger && b.trigger.call(b.triggerTarget, c[0], k.size, k.finishedSize);
  429. e(null, c[0])
  430. })
  431. }, b.cb, b.cbTarget);
  432. e.flow();
  433. return e
  434. },
  435. _handleAliases: function(a, b) {
  436. var c = this._aliases,
  437. d = [],
  438. e;
  439. for (e in a) {
  440. var f = a[e];
  441. c[e] = f;
  442. d.push(f)
  443. }
  444. this.load(d, b)
  445. },
  446. loadAliases: function(a, b) {
  447. var c = this,
  448. d = c.getRes(a);
  449. d ? c._handleAliases(d.filenames, b) : c.load(a, function(a, d) {
  450. c._handleAliases(d[0].filenames, b)
  451. })
  452. },
  453. register: function(a,
  454. b) {
  455. if (a && b) {
  456. if ("string" === typeof a) return this._register[a.trim().toLowerCase()] = b;
  457. for (var c = 0, d = a.length; c < d; c++) this._register["." + a[c].trim().toLowerCase()] = b
  458. }
  459. },
  460. getRes: function(a) {
  461. return this.cache[a] || this.cache[this._aliases[a]]
  462. },
  463. release: function(a) {
  464. var b = this.cache,
  465. c = this._aliases;
  466. delete b[a];
  467. delete b[c[a]];
  468. delete c[a]
  469. },
  470. releaseAll: function() {
  471. var a = this.cache,
  472. b = this._aliases,
  473. c;
  474. for (c in a) delete a[c];
  475. for (c in b) delete b[c]
  476. }
  477. };
  478. cc.formatStr = function() {
  479. var a = arguments,
  480. b = a.length;
  481. if (1 > b) return "";
  482. var c = a[0],
  483. d = !0;
  484. "object" === typeof c && (d = !1);
  485. for (var e = 1; e < b; ++e) {
  486. var f = a[e];
  487. if (d)
  488. for (;;) {
  489. var g = null;
  490. if ("number" === typeof f && (g = c.match(/(%d)|(%s)/))) {
  491. c = c.replace(/(%d)|(%s)/, f);
  492. break
  493. }
  494. c = (g = c.match(/%s/)) ? c.replace(/%s/, f) : c + (" " + f);
  495. break
  496. } else c += " " + f
  497. }
  498. return c
  499. };
  500. (function() {
  501. var a = window,
  502. b, c;
  503. cc.isUndefined(document.hidden) ? cc.isUndefined(document.mozHidden) ? cc.isUndefined(document.msHidden) ? cc.isUndefined(document.webkitHidden) || (b = "webkitHidden", c = "webkitvisibilitychange") : (b = "msHidden", c = "msvisibilitychange") : (b = "mozHidden", c = "mozvisibilitychange") : (b = "hidden", c = "visibilitychange");
  504. var d = function() {
  505. cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide)
  506. },
  507. e = function() {
  508. cc.eventManager && cc.game._eventShow && cc.eventManager.dispatchEvent(cc.game._eventShow);
  509. cc.game._intervalId && (window.cancelAnimationFrame(cc.game._intervalId), cc.game._runMainLoop())
  510. };
  511. b ? cc._addEventListener(document, c, function() {
  512. document[b] ? d() : e()
  513. }, !1) : (cc._addEventListener(a, "blur", d, !1), cc._addEventListener(a, "focus", e, !1)); - 1 < navigator.userAgent.indexOf("MicroMessenger") && (a.onfocus = function() {
  514. e()
  515. });
  516. "onpageshow" in window && "onpagehide" in window && (cc._addEventListener(a, "pagehide", d, !1), cc._addEventListener(a, "pageshow", e, !1));
  517. c = a = null
  518. })();
  519. cc.log = cc.warn = cc.error = cc.assert = function() {};
  520. cc.create3DContext = function(a, b) {
  521. for (var c = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], d = null, e = 0; e < c.length; ++e) {
  522. try {
  523. d = a.getContext(c[e], b)
  524. } catch (f) {}
  525. if (d) break
  526. }
  527. return d
  528. };
  529. cc._initSys = function(a, b) {
  530. cc._RENDER_TYPE_CANVAS = 0;
  531. cc._RENDER_TYPE_WEBGL = 1;
  532. cc.sys = {};
  533. var c = cc.sys;
  534. c.LANGUAGE_ENGLISH = "en";
  535. c.LANGUAGE_CHINESE = "zh";
  536. c.LANGUAGE_FRENCH = "fr";
  537. c.LANGUAGE_ITALIAN = "it";
  538. c.LANGUAGE_GERMAN = "de";
  539. c.LANGUAGE_SPANISH = "es";
  540. c.LANGUAGE_DUTCH = "du";
  541. c.LANGUAGE_RUSSIAN = "ru";
  542. c.LANGUAGE_KOREAN = "ko";
  543. c.LANGUAGE_JAPANESE = "ja";
  544. c.LANGUAGE_HUNGARIAN = "hu";
  545. c.LANGUAGE_PORTUGUESE = "pt";
  546. c.LANGUAGE_ARABIC = "ar";
  547. c.LANGUAGE_NORWEGIAN = "no";
  548. c.LANGUAGE_POLISH = "pl";
  549. c.OS_IOS = "iOS";
  550. c.OS_ANDROID = "Android";
  551. c.OS_WINDOWS =
  552. "Windows";
  553. c.OS_MARMALADE = "Marmalade";
  554. c.OS_LINUX = "Linux";
  555. c.OS_BADA = "Bada";
  556. c.OS_BLACKBERRY = "Blackberry";
  557. c.OS_OSX = "OS X";
  558. c.OS_WP8 = "WP8";
  559. c.OS_WINRT = "WINRT";
  560. c.OS_UNKNOWN = "Unknown";
  561. c.UNKNOWN = 0;
  562. c.IOS = 1;
  563. c.ANDROID = 2;
  564. c.WIN32 = 3;
  565. c.MARMALADE = 4;
  566. c.LINUX = 5;
  567. c.BADA = 6;
  568. c.BLACKBERRY = 7;
  569. c.MACOS = 8;
  570. c.NACL = 9;
  571. c.EMSCRIPTEN = 10;
  572. c.TIZEN = 11;
  573. c.QT5 = 12;
  574. c.WP8 = 13;
  575. c.WINRT = 14;
  576. c.MOBILE_BROWSER = 100;
  577. c.DESKTOP_BROWSER = 101;
  578. c.BROWSER_TYPE_WECHAT = "wechat";
  579. c.BROWSER_TYPE_ANDROID = "androidbrowser";
  580. c.BROWSER_TYPE_IE = "ie";
  581. c.BROWSER_TYPE_QQ = "qqbrowser";
  582. c.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
  583. c.BROWSER_TYPE_UC = "ucbrowser";
  584. c.BROWSER_TYPE_360 = "360browser";
  585. c.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
  586. c.BROWSER_TYPE_BAIDU = "baidubrowser";
  587. c.BROWSER_TYPE_MAXTHON = "maxthon";
  588. c.BROWSER_TYPE_OPERA = "opera";
  589. c.BROWSER_TYPE_OUPENG = "oupeng";
  590. c.BROWSER_TYPE_MIUI = "miuibrowser";
  591. c.BROWSER_TYPE_FIREFOX = "firefox";
  592. c.BROWSER_TYPE_SAFARI = "safari";
  593. c.BROWSER_TYPE_CHROME = "chrome";
  594. c.BROWSER_TYPE_LIEBAO = "liebao";
  595. c.BROWSER_TYPE_QZONE = "qzone";
  596. c.BROWSER_TYPE_SOUGOU = "sogou";
  597. c.BROWSER_TYPE_UNKNOWN =
  598. "unknown";
  599. c.isNative = !1;
  600. var d = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_SAFARI],
  601. e = [c.OS_IOS, c.OS_WINDOWS, c.OS_OSX, c.OS_LINUX],
  602. f = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_BAIDU_APP, c.BROWSER_TYPE_SAFARI, c.BROWSER_TYPE_UC, c.BROWSER_TYPE_QQ, c.BROWSER_TYPE_MOBILE_QQ, c.BROWSER_TYPE_IE],
  603. g = window,
  604. h = g.navigator,
  605. k = document,
  606. m = k.documentElement,
  607. n = h.userAgent.toLowerCase();
  608. c.isMobile = -1 !==
  609. n.indexOf("mobile") || -1 !== n.indexOf("android");
  610. c.platform = c.isMobile ? c.MOBILE_BROWSER : c.DESKTOP_BROWSER;
  611. var p = h.language,
  612. p = (p = p ? p : h.browserLanguage) ? p.split("-")[0] : c.LANGUAGE_ENGLISH;
  613. c.language = p;
  614. var p = c.BROWSER_TYPE_UNKNOWN,
  615. t = n.match(/sogou|qzone|liebao|micromessenger|qqbrowser|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || n.match(/chrome|safari/i);
  616. t && 0 < t.length ? (p = t[0], "micromessenger" === p ? p = c.BROWSER_TYPE_WECHAT : "safari" === p && n.match(/android.*applewebkit/) ?
  617. p = c.BROWSER_TYPE_ANDROID : "trident" === p ? p = c.BROWSER_TYPE_IE : "360 aphone" === p && (p = c.BROWSER_TYPE_360)) : n.indexOf("iphone") && n.indexOf("mobile") && (p = "safari");
  618. c.browserType = p;
  619. p = n.match(/(iPad|iPhone|iPod)/i) ? !0 : !1;
  620. n = n.match(/android/i) || h.platform.match(/android/i) ? !0 : !1;
  621. t = c.OS_UNKNOWN; - 1 !== h.appVersion.indexOf("Win") ? t = c.OS_WINDOWS : p ? t = c.OS_IOS : -1 !== h.appVersion.indexOf("Mac") ? t = c.OS_OSX : -1 !== h.appVersion.indexOf("X11") && -1 === h.appVersion.indexOf("Linux") ? t = c.OS_UNIX : n ? t = c.OS_ANDROID : -1 !== h.appVersion.indexOf("Linux") &&
  622. (t = c.OS_LINUX);
  623. c.os = t;
  624. c._supportMultipleAudio = -1 < f.indexOf(c.browserType);
  625. var f = parseInt(a[b.renderMode]),
  626. n = cc._RENDER_TYPE_WEBGL,
  627. t = cc.newElement("Canvas"),
  628. r = cc._supportRender = !0,
  629. r = p ? !window.WebGLRenderingContext || -1 === e.indexOf(c.os) : !window.WebGLRenderingContext || -1 === d.indexOf(c.browserType) || -1 === e.indexOf(c.os);
  630. if (1 === f || 0 === f && r || "file://" === location.origin) n = cc._RENDER_TYPE_CANVAS;
  631. c._canUseCanvasNewBlendModes = function() {
  632. var a = document.createElement("canvas");
  633. a.width = 1;
  634. a.height = 1;
  635. a = a.getContext("2d");
  636. a.fillStyle = "#000";
  637. a.fillRect(0, 0, 1, 1);
  638. a.globalCompositeOperation = "multiply";
  639. var b = document.createElement("canvas");
  640. b.width = 1;
  641. b.height = 1;
  642. var c = b.getContext("2d");
  643. c.fillStyle = "#fff";
  644. c.fillRect(0, 0, 1, 1);
  645. a.drawImage(b, 0, 0, 1, 1);
  646. return 0 === a.getImageData(0, 0, 1, 1).data[0]
  647. };
  648. c._supportCanvasNewBlendModes = c._canUseCanvasNewBlendModes();
  649. n !== cc._RENDER_TYPE_WEBGL || g.WebGLRenderingContext && cc.create3DContext(t, {
  650. stencil: !0,
  651. preserveDrawingBuffer: !0
  652. }) || (0 === f ? n = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1);
  653. if (n ===
  654. cc._RENDER_TYPE_CANVAS) try {
  655. t.getContext("2d")
  656. } catch (u) {
  657. cc._supportRender = !1
  658. }
  659. cc._renderType = n;
  660. try {
  661. c._supportWebAudio = !!(g.AudioContext || g.webkitAudioContext || g.mozAudioContext)
  662. } catch (s) {
  663. c._supportWebAudio = !1
  664. }
  665. try {
  666. var v = c.localStorage = g.localStorage;
  667. v.setItem("storage", "");
  668. v.removeItem("storage");
  669. v = null
  670. } catch (x) {
  671. "SECURITY_ERR" !== x.name && "QuotaExceededError" !== x.name || cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"), c.localStorage = function() {}
  672. }
  673. d = c.capabilities = {
  674. canvas: !0
  675. };
  676. cc._renderType === cc._RENDER_TYPE_WEBGL && (d.opengl = !0);
  677. if (void 0 !== m.ontouchstart || void 0 !== k.ontouchstart || h.msPointerEnabled) d.touches = !0;
  678. void 0 !== m.onmouseup && (d.mouse = !0);
  679. void 0 !== m.onkeyup && (d.keyboard = !0);
  680. if (g.DeviceMotionEvent || g.DeviceOrientationEvent) d.accelerometer = !0;
  681. c.garbageCollect = function() {};
  682. c.dumpRoot = function() {};
  683. c.restartVM = function() {};
  684. c.cleanScript = function(a) {};
  685. c.dump = function() {
  686. var a;
  687. a = "" + ("isMobile : " + this.isMobile + "\r\n");
  688. a += "language : " + this.language + "\r\n";
  689. a += "browserType : " + this.browserType + "\r\n";
  690. a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n";
  691. a += "os : " + this.os + "\r\n";
  692. a += "platform : " + this.platform + "\r\n";
  693. cc.log(a)
  694. };
  695. c.openURL = function(a) {
  696. window.open(a)
  697. }
  698. };
  699. cc.ORIENTATION_PORTRAIT = 0;
  700. cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
  701. cc.ORIENTATION_LANDSCAPE_LEFT = 2;
  702. cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
  703. cc._drawingUtil = null;
  704. cc._renderContext = null;
  705. cc._canvas = null;
  706. cc._gameDiv = null;
  707. cc._rendererInitialized = !1;
  708. cc._setupCalled = !1;
  709. cc._setup = function(a, b, c) {
  710. if (!cc._setupCalled) {
  711. cc._setupCalled = !0;
  712. var d = window,
  713. e = cc.$(a) || cc.$("#" + a),
  714. f;
  715. cc.game._setAnimFrame();
  716. "CANVAS" === e.tagName ? (b = b || e.width, c = c || e.height, f = cc.container = cc.newElement("DIV"), a = cc._canvas = e, a.parentNode.insertBefore(f, a), a.appendTo(f), f.setAttribute("id", "Cocos2dGameContainer")) : ("DIV" !== e.tagName && cc.log("Warning: target element is not a DIV or CANVAS"), b = b || e.clientWidth, c = c || e.clientHeight, f = cc.container = e, a = cc._canvas = cc.$(cc.newElement("CANVAS")), e.appendChild(a));
  717. a.addClass("gameCanvas");
  718. a.setAttribute("width", b || 480);
  719. a.setAttribute("height", c || 320);
  720. a.setAttribute("tabindex", 99);
  721. a.style.outline = "none";
  722. e = f.style;
  723. e.width = (b || 480) + "px";
  724. e.height = (c || 320) + "px";
  725. e.margin = "0 auto";
  726. e.position = "relative";
  727. e.overflow = "hidden";
  728. f.top = "100%";
  729. cc._renderType === cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, {
  730. stencil: !0,
  731. preserveDrawingBuffer: !0,
  732. antialias: !cc.sys.isMobile,
  733. alpha: !1
  734. }));
  735. cc._renderContext ? (d.gl = cc._renderContext, cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext),
  736. cc._rendererInitialized = !0, cc.textureCache._initializingRenderer(), cc.shaderCache._init()) : (cc._renderContext = new cc.CanvasContextWrapper(a.getContext("2d")), cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(cc._renderContext) : null);
  737. cc._gameDiv = f;
  738. cc.log(cc.ENGINE_VERSION);
  739. cc._setContextMenuEnable(!1);
  740. cc.sys.isMobile && (b = cc.newElement("style"), b.type = "text/css", document.body.appendChild(b), b.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);}");
  741. cc.view = cc.EGLView._getInstance();
  742. cc.inputManager.registerSystemEvent(cc._canvas);
  743. cc.director = cc.Director._getInstance();
  744. cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view);
  745. cc.winSize = cc.director.getWinSize();
  746. cc.saxParser = new cc.SAXParser;
  747. cc.plistParser = new cc.PlistParser
  748. }
  749. };
  750. cc._checkWebGLRenderMode = function() {
  751. if (cc._renderType !== cc._RENDER_TYPE_WEBGL) throw "This feature supports WebGL render mode only.";
  752. };
  753. cc._isContextMenuEnable = !1;
  754. cc._setContextMenuEnable = function(a) {
  755. cc._isContextMenuEnable = a;
  756. cc._canvas.oncontextmenu = function() {
  757. if (!cc._isContextMenuEnable) return !1
  758. }
  759. };
  760. cc.game = {
  761. DEBUG_MODE_NONE: 0,
  762. DEBUG_MODE_INFO: 1,
  763. DEBUG_MODE_WARN: 2,
  764. DEBUG_MODE_ERROR: 3,
  765. DEBUG_MODE_INFO_FOR_WEB_PAGE: 4,
  766. DEBUG_MODE_WARN_FOR_WEB_PAGE: 5,
  767. DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6,
  768. EVENT_HIDE: "game_on_hide",
  769. EVENT_SHOW: "game_on_show",
  770. _eventHide: null,
  771. _eventShow: null,
  772. _onBeforeStartArr: [],
  773. CONFIG_KEY: {
  774. engineDir: "engineDir",
  775. dependencies: "dependencies",
  776. debugMode: "debugMode",
  777. showFPS: "showFPS",
  778. frameRate: "frameRate",
  779. id: "id",
  780. renderMode: "renderMode",
  781. jsList: "jsList",
  782. classReleaseMode: "classReleaseMode"
  783. },
  784. _prepareCalled: !1,
  785. _prepared: !1,
  786. _paused: !0,
  787. _intervalId: null,
  788. _lastTime: null,
  789. _frameTime: null,
  790. config: null,
  791. onStart: null,
  792. onStop: null,
  793. setFrameRate: function(a) {
  794. this.config[this.CONFIG_KEY.frameRate] = a;
  795. this._intervalId && window.cancelAnimationFrame(this._intervalId);
  796. this._paused = !0;
  797. this._setAnimFrame();
  798. this._runMainLoop()
  799. },
  800. _setAnimFrame: function() {
  801. this._lastTime = new Date;
  802. this._frameTime = 1E3 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
  803. cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT || 60 !== cc.game.config[cc.game.CONFIG_KEY.frameRate] ?
  804. (window.requestAnimFrame = this._stTime, window.cancelAnimationFrame = this._ctTime) : (window.requestAnimFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || this._stTime, window.cancelAnimationFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame ||
  805. window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || this._ctTime)
  806. },
  807. _stTime: function(a) {
  808. var b = (new Date).getTime(),
  809. c = Math.max(0, cc.game._frameTime - (b - cc.game._lastTime)),
  810. d = window.setTimeout(function() {
  811. a()
  812. }, c);
  813. cc.game._lastTime = b + c;
  814. return d
  815. },
  816. _ctTime: function(a) {
  817. window.clearTimeout(a)
  818. },
  819. _runMainLoop: function() {
  820. var a = this,
  821. b, c = cc.director;
  822. c.setDisplayStats(a.config[a.CONFIG_KEY.showFPS]);
  823. b = function() {
  824. a._paused || (c.mainLoop(), a._intervalId &&
  825. window.cancelAnimationFrame(a._intervalId), a._intervalId = window.requestAnimFrame(b))
  826. };
  827. window.requestAnimFrame(b);
  828. a._paused = !1
  829. },
  830. restart: function() {
  831. cc.director.popToSceneStackLevel(0);
  832. cc.audioEngine && cc.audioEngine.end();
  833. cc.game.onStart()
  834. },
  835. run: function(a) {
  836. var b = this,
  837. c = function() {
  838. a && (b.config[b.CONFIG_KEY.id] = a);
  839. b._prepareCalled || b.prepare(function() {
  840. b._prepared = !0
  841. });
  842. cc._supportRender && (b._checkPrepare = setInterval(function() {
  843. b._prepared && (cc._setup(b.config[b.CONFIG_KEY.id]), b._runMainLoop(), b._eventHide =
  844. b._eventHide || new cc.EventCustom(b.EVENT_HIDE), b._eventHide.setUserData(b), b._eventShow = b._eventShow || new cc.EventCustom(b.EVENT_SHOW), b._eventShow.setUserData(b), b.onStart(), clearInterval(b._checkPrepare))
  845. }, 10))
  846. };
  847. document.body ? c() : cc._addEventListener(window, "load", function() {
  848. this.removeEventListener("load", arguments.callee, !1);
  849. c()
  850. }, !1)
  851. },
  852. _initConfig: function() {
  853. var a = this.CONFIG_KEY,
  854. b = function(b) {
  855. b[a.engineDir] = b[a.engineDir] || "frameworks/cocos2d-html5";
  856. null == b[a.debugMode] && (b[a.debugMode] = 0);
  857. b[a.frameRate] =
  858. b[a.frameRate] || 60;
  859. null == b[a.renderMode] && (b[a.renderMode] = 1);
  860. return b
  861. };
  862. if (document.ccConfig) this.config = b(document.ccConfig);
  863. else try {
  864. for (var c = document.getElementsByTagName("script"), d = 0; d < c.length; d++) {
  865. var e = c[d].getAttribute("cocos");
  866. if ("" === e || e) break
  867. }
  868. var f, g, h;
  869. if (d < c.length) {
  870. if (f = c[d].src) h = /(.*)\//.exec(f)[0], cc.loader.resPath = h, f = cc.path.join(h, "project.json");
  871. g = cc.loader._loadTxtSync(f)
  872. }
  873. g || (g = cc.loader._loadTxtSync("project.json"));
  874. var k = JSON.parse(g);
  875. this.config = b(k || {})
  876. } catch (m) {
  877. cc.log("Failed to read or parse project.json"),
  878. this.config = b({})
  879. }
  880. cc._initSys(this.config, a)
  881. },
  882. _jsAddedCache: {},
  883. _getJsListOfModule: function(a, b, c) {
  884. var d = this._jsAddedCache;
  885. if (d[b]) return null;
  886. c = c || "";
  887. var e = [],
  888. f = a[b];
  889. if (!f) throw "can not find module [" + b + "]";
  890. b = cc.path;
  891. for (var g = 0, h = f.length; g < h; g++) {
  892. var k = f[g];
  893. if (!d[k]) {
  894. var m = b.extname(k);
  895. m ? ".js" === m.toLowerCase() && e.push(b.join(c, k)) : (m = this._getJsListOfModule(a, k, c)) && (e = e.concat(m));
  896. d[k] = 1
  897. }
  898. }
  899. return e
  900. },
  901. prepare: function(a) {
  902. var b = this,
  903. c = b.config,
  904. d = b.CONFIG_KEY,
  905. e = c[d.engineDir],
  906. f = cc.loader;
  907. if (!cc._supportRender) throw "The renderer doesn't support the renderMode " +
  908. c[d.renderMode];
  909. b._prepareCalled = !0;
  910. var g = c[d.jsList] || [];
  911. cc.Class ? f.loadJsWithImg("", g, function(c) {
  912. if (c) throw c;
  913. b._prepared = !0;
  914. a && a()
  915. }) : (d = cc.path.join(e, "moduleConfig.json"), f.loadJson(d, function(d, f) {
  916. if (d) throw d;
  917. var m = c.modules || [],
  918. n = f.module,
  919. p = [];
  920. cc._renderType === cc._RENDER_TYPE_WEBGL ? m.splice(0, 0, "shaders") : 0 > m.indexOf("core") && m.splice(0, 0, "core");
  921. for (var t = 0, r = m.length; t < r; t++) {
  922. var u = b._getJsListOfModule(n, m[t], e);
  923. u && (p = p.concat(u))
  924. }
  925. p = p.concat(g);
  926. cc.loader.loadJsWithImg(p, function(c) {
  927. if (c) throw c;
  928. b._prepared = !0;
  929. a && a()
  930. })
  931. }))
  932. }
  933. };
  934. cc.game._initConfig();
  935. Function.prototype.bind = Function.prototype.bind || function(a) {
  936. if (!cc.isFunction(this)) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  937. var b = Array.prototype.slice.call(arguments, 1),
  938. c = this,
  939. d = function() {},
  940. e = function() {
  941. return c.apply(this instanceof d && a ? this : a, b.concat(Array.prototype.slice.call(arguments)))
  942. };
  943. d.prototype = this.prototype;
  944. e.prototype = new d;
  945. return e
  946. };
  947. cc._LogInfos = {
  948. ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null",
  949. ActionManager_removeAction: "cocos2d: removeAction: Target not found",
  950. ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag",
  951. ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null",
  952. ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag",
  953. ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag \x3d %s): Action not found",
  954. configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",
  955. configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s",
  956. configuration_loadConfigFile_2: "Please load the resource first : %s",
  957. Director_resume: "cocos2d: Director: Error in gettimeofday",
  958. Director_setProjection: "cocos2d: Director: unrecognized projection",
  959. Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection",
  960. Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday",
  961. Director_popScene: "running scene should not null",
  962. Director_pushScene: "the scene should not null",
  963. arrayVerifyType: "element type is wrong!",
  964. Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",
  965. Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",
  966. Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",
  967. Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null",
  968. Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null",
  969. Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null",
  970. Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.",
  971. Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.",
  972. Node_getRotation: "RotationX !\x3d RotationY. Don't know which one to return",
  973. Node_getScale: "ScaleX !\x3d ScaleY. Don't know which one to return",
  974. Node_addChild: "An Node can't be added as a child of itself.",
  975. Node_addChild_2: "child already added. It can't be added again",
  976. Node_addChild_3: "child must be non-null",
  977. Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead",
  978. Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead",
  979. Node_removeChildByTag: "argument tag is an invalid tag",
  980. Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag \x3d %s): child not found!",
  981. Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",
  982. Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag",
  983. Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag",
  984. Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.",
  985. Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.",
  986. Node__arrayMakeObjectsPerformSelector: "Unknown callback function",
  987. Node_reorderChild: "child must be non-null",
  988. Node_runAction: "cc.Node.runAction(): action must be non-null",
  989. Node_schedule: "callback function must be non-null",
  990. Node_schedule_2: "interval must be positive",
  991. Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  992. AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",
  993. AtlasNode_initWithTileFile: "",
  994. AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  995. _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",
  996. _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",
  997. _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",
  998. _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",
  999. EventListener_create: "Invalid parameter.",
  1000. __getListenerID: "Don't call this method if the event is for touch.",
  1001. eventManager__forceAddEventListener: "Invalid scene graph priority!",
  1002. eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.",
  1003. eventManager_removeListeners: "Invalid listener type!",
  1004. eventManager_setPriority: "Can't set fixed priority with scene graph based listener.",
  1005. eventManager_addListener_2: "Invalid parameters.",
  1006. eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener",
  1007. eventManager_addListener_4: "The listener has been registered, please don't register it again.",
  1008. LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript",
  1009. LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message",
  1010. LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message",
  1011. LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null",
  1012. EGLView_setDesignResolutionSize: "Resolution not valid",
  1013. EGLView_setDesignResolutionSize_2: "should set resolutionPolicy",
  1014. inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s",
  1015. swap: "cc.swap is being modified from original macro, please check usage",
  1016. checkGLErrorDebug: "WebGL error %s",
  1017. animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",
  1018. animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format",
  1019. animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found",
  1020. animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  1021. 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.",
  1022. 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.",
  1023. 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.",
  1024. animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  1025. 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.",
  1026. animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name",
  1027. Sprite_reorderChild: "cc.Sprite.reorderChild(): this child is not in children list",
  1028. Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",
  1029. Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",
  1030. Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",
  1031. Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.",
  1032. Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
  1033. Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",
  1034. Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",
  1035. Sprite_initWithSpriteFrameName1: " is null, please check.",
  1036. Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null",
  1037. Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",
  1038. Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null",
  1039. Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",
  1040. Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",
  1041. Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null",
  1042. Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",
  1043. Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1044. Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1045. Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1046. Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",
  1047. Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  1048. Sprite_setSpriteFrame: "Invalid spriteFrameName",
  1049. Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",
  1050. Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  1051. Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  1052. SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",
  1053. SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",
  1054. SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas",
  1055. SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",
  1056. SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",
  1057. SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",
  1058. SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild(): child should be non-null",
  1059. spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",
  1060. spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists",
  1061. spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",
  1062. spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found",
  1063. spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s",
  1064. spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",
  1065. spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil",
  1066. CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1067. CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1068. CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1069. CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  1070. CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null",
  1071. CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName",
  1072. CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",
  1073. CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  1074. CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  1075. CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null",
  1076. TextureAtlas_initWithFile: "cocos2d: Could not open file: %s",
  1077. TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads",
  1078. TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null",
  1079. TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null",
  1080. TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index",
  1081. TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index",
  1082. TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount",
  1083. TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",
  1084. TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",
  1085. TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index",
  1086. TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",
  1087. TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",
  1088. TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",
  1089. TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",
  1090. textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  1091. textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  1092. textureCache_textureForKey: "textureForKey is deprecated. Please use getTextureForKey instead.",
  1093. textureCache_addPVRImage: "addPVRImage does not support on HTML5",
  1094. textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache",
  1095. textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id\x3d%s %s x %s",
  1096. textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s",
  1097. textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",
  1098. textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null",
  1099. Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5",
  1100. Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5",
  1101. Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5",
  1102. Texture2D_addImage: "cc.Texture.addImage(): path should be non-null",
  1103. Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",
  1104. Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",
  1105. Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5",
  1106. Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5",
  1107. Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5",
  1108. Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5",
  1109. Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",
  1110. Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",
  1111. Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null",
  1112. Texture2D_initWithData: "NSInternalInconsistencyException",
  1113. MissingFile: "Missing file: %s",
  1114. radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()",
  1115. RectWidth: "Rect width exceeds maximum margin: %s",
  1116. RectHeight: "Rect height exceeds maximum margin: %s",
  1117. EventManager__updateListeners: "If program goes here, there should be event in dispatch.",
  1118. EventManager__updateListeners_2: "_inDispatch should be 1 here."
  1119. };
  1120. cc._logToWebPage = function(a) {
  1121. if (cc._canvas) {
  1122. var b = cc._logList,
  1123. c = document;
  1124. if (!b) {
  1125. var d = c.createElement("Div"),
  1126. b = d.style;
  1127. d.setAttribute("id", "logInfoDiv");
  1128. cc._canvas.parentNode.appendChild(d);
  1129. d.setAttribute("width", "200");
  1130. d.setAttribute("height", cc._canvas.height);
  1131. b.zIndex = "99999";
  1132. b.position = "absolute";
  1133. b.top = "0";
  1134. b.left = "0";
  1135. b = cc._logList = c.createElement("textarea");
  1136. c = b.style;
  1137. b.setAttribute("rows", "20");
  1138. b.setAttribute("cols", "30");
  1139. b.setAttribute("disabled", !0);
  1140. d.appendChild(b);
  1141. c.backgroundColor = "transparent";
  1142. c.borderBottom = "1px solid #cccccc";
  1143. c.borderRightWidth = "0px";
  1144. c.borderLeftWidth = "0px";
  1145. c.borderTopWidth = "0px";
  1146. c.borderTopStyle = "none";
  1147. c.borderRightStyle = "none";
  1148. c.borderLeftStyle = "none";
  1149. c.padding = "0px";
  1150. c.margin = 0
  1151. }
  1152. b.value = b.value + a + "\r\n";
  1153. b.scrollTop = b.scrollHeight
  1154. }
  1155. };
  1156. cc._formatString = function(a) {
  1157. if (cc.isObject(a)) try {
  1158. return JSON.stringify(a)
  1159. } catch (b) {
  1160. return ""
  1161. } else return a
  1162. };
  1163. cc._initDebugSetting = function(a) {
  1164. var b = cc.game;
  1165. if (a !== b.DEBUG_MODE_NONE) {
  1166. var c;
  1167. a > b.DEBUG_MODE_ERROR ? (c = cc._logToWebPage.bind(cc), cc.error = function() {
  1168. c("ERROR : " + cc.formatStr.apply(cc, arguments))
  1169. }, cc.assert = function(a, b) {
  1170. if (!a && b) {
  1171. for (var f = 2; f < arguments.length; f++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[f]));
  1172. c("Assert: " + b)
  1173. }
  1174. }, a !== b.DEBUG_MODE_ERROR_FOR_WEB_PAGE && (cc.warn = function() {
  1175. c("WARN : " + cc.formatStr.apply(cc, arguments))
  1176. }), a === b.DEBUG_MODE_INFO_FOR_WEB_PAGE && (cc.log = function() {
  1177. c(cc.formatStr.apply(cc,
  1178. arguments))
  1179. })) : console && console.log.apply && (cc.error = function() {
  1180. return console.error.apply(console, arguments)
  1181. }, cc.assert = function(a, b) {
  1182. if (!a && b) {
  1183. for (var c = 2; c < arguments.length; c++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
  1184. throw b;
  1185. }
  1186. }, a !== b.DEBUG_MODE_ERROR && (cc.warn = function() {
  1187. return console.warn.apply(console, arguments)
  1188. }), a === b.DEBUG_MODE_INFO && (cc.log = function() {
  1189. return console.log.apply(console, arguments)
  1190. }))
  1191. }
  1192. };
  1193. cc._initDebugSetting(cc.game.config[cc.game.CONFIG_KEY.debugMode]);
  1194. cc.loader.loadBinary = function(a, b) {
  1195. var c = this,
  1196. d = this.getXMLHttpRequest(),
  1197. e = "load " + a + " failed!";
  1198. d.open("GET", a, !0);
  1199. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "x-user-defined"), d.onreadystatechange = function() {
  1200. if (4 === d.readyState && 200 === d.status) {
  1201. var a = cc._convertResponseBodyToText(d.responseBody);
  1202. b(null, c._str2Uint8Array(a))
  1203. } else b(e)
  1204. }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dx-user-defined"), d.onload = function() {
  1205. 4 ===
  1206. d.readyState && 200 === d.status ? b(null, c._str2Uint8Array(d.responseText)) : b(e)
  1207. });
  1208. d.send(null)
  1209. };
  1210. cc.loader._str2Uint8Array = function(a) {
  1211. if (!a) return null;
  1212. for (var b = new Uint8Array(a.length), c = 0; c < a.length; c++) b[c] = a.charCodeAt(c) & 255;
  1213. return b
  1214. };
  1215. cc.loader.loadBinarySync = function(a) {
  1216. var b = this.getXMLHttpRequest(),
  1217. c = "load " + a + " failed!";
  1218. b.open("GET", a, !1);
  1219. a = null;
  1220. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1221. b.setRequestHeader("Accept-Charset", "x-user-defined");
  1222. b.send(null);
  1223. if (200 !== b.status) return cc.log(c), null;
  1224. (b = cc._convertResponseBodyToText(b.responseBody)) && (a = this._str2Uint8Array(b))
  1225. } else {
  1226. b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dx-user-defined");
  1227. b.send(null);
  1228. if (200 !== b.status) return cc.log(c),
  1229. null;
  1230. a = this._str2Uint8Array(b.responseText)
  1231. }
  1232. return a
  1233. };
  1234. var Uint8Array = Uint8Array || Array;
  1235. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1236. 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',
  1237. myVBScript =
  1238. cc.newElement("script");
  1239. myVBScript.type = "text/vbscript";
  1240. myVBScript.textContent = IEBinaryToArray_ByteStr_Script;
  1241. document.body.appendChild(myVBScript);
  1242. cc._convertResponseBodyToText = function(a) {
  1243. for (var b = {}, c = 0; 256 > c; c++)
  1244. for (var d = 0; 256 > d; d++) b[String.fromCharCode(c + 256 * d)] = String.fromCharCode(c) + String.fromCharCode(d);
  1245. c = IEBinaryToArray_ByteStr(a);
  1246. a = IEBinaryToArray_ByteStr_Last(a);
  1247. return c.replace(/[\s\S]/g, function(a) {
  1248. return b[a]
  1249. }) + a
  1250. }
  1251. };
  1252. cc = cc || {};
  1253. cc._loadingImage = "data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7";
  1254. cc._fpsImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgCAYAAAD9qabkAAAKQ2lDQ1BJQ0MgcHJvZmlsZQAAeNqdU3dYk/cWPt/3ZQ9WQtjwsZdsgQAiI6wIyBBZohCSAGGEEBJAxYWIClYUFRGcSFXEgtUKSJ2I4qAouGdBiohai1VcOO4f3Ke1fXrv7e371/u855zn/M55zw+AERImkeaiagA5UoU8Otgfj09IxMm9gAIVSOAEIBDmy8JnBcUAAPADeXh+dLA//AGvbwACAHDVLiQSx+H/g7pQJlcAIJEA4CIS5wsBkFIAyC5UyBQAyBgAsFOzZAoAlAAAbHl8QiIAqg0A7PRJPgUA2KmT3BcA2KIcqQgAjQEAmShHJAJAuwBgVYFSLALAwgCgrEAiLgTArgGAWbYyRwKAvQUAdo5YkA9AYACAmUIszAAgOAIAQx4TzQMgTAOgMNK/4KlfcIW4SAEAwMuVzZdL0jMUuJXQGnfy8ODiIeLCbLFCYRcpEGYJ5CKcl5sjE0jnA0zODAAAGvnRwf44P5Dn5uTh5mbnbO/0xaL+a/BvIj4h8d/+vIwCBAAQTs/v2l/l5dYDcMcBsHW/a6lbANpWAGjf+V0z2wmgWgrQevmLeTj8QB6eoVDIPB0cCgsL7SViob0w44s+/zPhb+CLfvb8QB7+23rwAHGaQJmtwKOD/XFhbnauUo7nywRCMW735yP+x4V//Y4p0eI0sVwsFYrxWIm4UCJNx3m5UpFEIcmV4hLpfzLxH5b9CZN3DQCshk/ATrYHtctswH7uAQKLDljSdgBAfvMtjBoLkQAQZzQyefcAAJO/+Y9AKwEAzZek4wAAvOgYXKiUF0zGCAAARKCBKrBBBwzBFKzADpzBHbzAFwJhBkRADCTAPBBCBuSAHAqhGJZBGVTAOtgEtbADGqARmuEQtMExOA3n4BJcgetwFwZgGJ7CGLyGCQRByAgTYSE6iBFijtgizggXmY4EImFINJKApCDpiBRRIsXIcqQCqUJqkV1II/ItchQ5jVxA+pDbyCAyivyKvEcxlIGyUQPUAnVAuagfGorGoHPRdDQPXYCWomvRGrQePYC2oqfRS+h1dAB9io5jgNExDmaM2WFcjIdFYIlYGibHFmPlWDVWjzVjHVg3dhUbwJ5h7wgkAouAE+wIXoQQwmyCkJBHWExYQ6gl7CO0EroIVwmDhDHCJyKTqE+0JXoS+cR4YjqxkFhGrCbuIR4hniVeJw4TX5NIJA7JkuROCiElkDJJC0lrSNtILaRTpD7SEGmcTCbrkG3J3uQIsoCsIJeRt5APkE+S+8nD5LcUOsWI4kwJoiRSpJQSSjVlP+UEpZ8yQpmgqlHNqZ7UCKqIOp9aSW2gdlAvU4epEzR1miXNmxZDy6Qto9XQmmlnafdoL+l0ugndgx5Fl9CX0mvoB+nn6YP0dwwNhg2Dx0hiKBlrGXsZpxi3GS+ZTKYF05eZyFQw1zIbmWeYD5hvVVgq9ip8FZHKEpU6lVaVfpXnqlRVc1U/1XmqC1SrVQ+rXlZ9pkZVs1DjqQnUFqvVqR1Vu6k2rs5Sd1KPUM9RX6O+X/2C+mMNsoaFRqCGSKNUY7fGGY0hFsYyZfFYQtZyVgPrLGuYTWJbsvnsTHYF+xt2L3tMU0NzqmasZpFmneZxzQEOxrHg8DnZnErOIc4NznstAy0/LbHWaq1mrX6tN9p62r7aYu1y7Rbt69rvdXCdQJ0snfU6bTr3dQm6NrpRuoW623XP6j7TY+t56Qn1yvUO6d3RR/Vt9KP1F+rv1u/RHzcwNAg2kBlsMThj8MyQY+hrmGm40fCE4agRy2i6kcRoo9FJoye4Ju6HZ+M1eBc+ZqxvHGKsNN5l3Gs8YWJpMtukxKTF5L4pzZRrmma60bTTdMzMyCzcrNisyeyOOdWca55hvtm82/yNhaVFnMVKizaLx5balnzLBZZNlvesmFY+VnlW9VbXrEnWXOss623WV2xQG1ebDJs6m8u2qK2brcR2m23fFOIUjynSKfVTbtox7PzsCuya7AbtOfZh9iX2bfbPHcwcEh3WO3Q7fHJ0dcx2bHC866ThNMOpxKnD6VdnG2ehc53zNRemS5DLEpd2lxdTbaeKp26fesuV5RruutK10/Wjm7ub3K3ZbdTdzD3Ffav7TS6bG8ldwz3vQfTw91jicczjnaebp8LzkOcvXnZeWV77vR5Ps5wmntYwbcjbxFvgvct7YDo+PWX6zukDPsY+Ap96n4e+pr4i3z2+I37Wfpl+B/ye+zv6y/2P+L/hefIW8U4FYAHBAeUBvYEagbMDawMfBJkEpQc1BY0FuwYvDD4VQgwJDVkfcpNvwBfyG/ljM9xnLJrRFcoInRVaG/owzCZMHtYRjobPCN8Qfm+m+UzpzLYIiOBHbIi4H2kZmRf5fRQpKjKqLupRtFN0cXT3LNas5Fn7Z72O8Y+pjLk722q2cnZnrGpsUmxj7Ju4gLiquIF4h/hF8ZcSdBMkCe2J5MTYxD2J43MC52yaM5zkmlSWdGOu5dyiuRfm6c7Lnnc8WTVZkHw4hZgSl7I/5YMgQlAvGE/lp25NHRPyhJuFT0W+oo2iUbG3uEo8kuadVpX2ON07fUP6aIZPRnXGMwlPUit5kRmSuSPzTVZE1t6sz9lx2S05lJyUnKNSDWmWtCvXMLcot09mKyuTDeR55m3KG5OHyvfkI/lz89sVbIVM0aO0Uq5QDhZML6greFsYW3i4SL1IWtQz32b+6vkjC4IWfL2QsFC4sLPYuHhZ8eAiv0W7FiOLUxd3LjFdUrpkeGnw0n3LaMuylv1Q4lhSVfJqedzyjlKD0qWlQyuCVzSVqZTJy26u9Fq5YxVhlWRV72qX1VtWfyoXlV+scKyorviwRrjm4ldOX9V89Xlt2treSrfK7etI66Trbqz3Wb+vSr1qQdXQhvANrRvxjeUbX21K3nShemr1js20zcrNAzVhNe1bzLas2/KhNqP2ep1/XctW/a2rt77ZJtrWv913e/MOgx0VO97vlOy8tSt4V2u9RX31btLugt2PGmIbur/mft24R3dPxZ6Pe6V7B/ZF7+tqdG9s3K+/v7IJbVI2jR5IOnDlm4Bv2pvtmne1cFoqDsJB5cEn36Z8e+NQ6KHOw9zDzd+Zf7f1COtIeSvSOr91rC2jbaA9ob3v6IyjnR1eHUe+t/9+7zHjY3XHNY9XnqCdKD3x+eSCk+OnZKeenU4/PdSZ3Hn3TPyZa11RXb1nQ8+ePxd07ky3X/fJ897nj13wvHD0Ivdi2yW3S609rj1HfnD94UivW2/rZffL7Vc8rnT0Tes70e/Tf/pqwNVz1/jXLl2feb3vxuwbt24m3Ry4Jbr1+Hb27Rd3Cu5M3F16j3iv/L7a/eoH+g/qf7T+sWXAbeD4YMBgz8NZD+8OCYee/pT/04fh0kfMR9UjRiONj50fHxsNGr3yZM6T4aeypxPPyn5W/3nrc6vn3/3i+0vPWPzY8Av5i8+/rnmp83Lvq6mvOscjxx+8znk98ab8rc7bfe+477rfx70fmSj8QP5Q89H6Y8en0E/3Pud8/vwv94Tz+4A5JREAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcAgcQLxxUBNp/AAAQZ0lEQVR42u2be3QVVZbGv1N17829eRLyIKAEOiISEtPhJTJAYuyBDmhWjAEx4iAGBhxA4wABbVAMWUAeykMCM+HRTcBRWkNH2l5moS0LCCrQTkYeQWBQSCAIgYRXEpKbW/XNH5zS4noR7faPEeu31l0h4dSpvc+t/Z199jkFWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY/H9D/MR9qfKnLj/00U71aqfJn9+HCkCR/Wk36ddsgyJ/1wF4fkDfqqm9/gPsUeTnVr6a2xlQfnxdI7zs0W7irzD17Ytb2WT7EeNv/r4ox1O3Quf2QP2pgt9utwfout4FQE8AVBSlnaRmfvAURQkg2RlAbwB9AThlW5L0GaiKojhJhgOIBqDa7XaPrusdPtr5kQwF0BVAAoBIABRCKDd5aFUhRDAAw57eAOwAhKIoupft3zoqhB1AqLwuHIBut9uFt02qqvqRDJR2dAEQJj/BAOjn56dqmma+xiaECAEQAWAggLsB6A6HQ2iaZggBhBAqgEAAnQB0kzaEmT4hAITT6VQ8Ho/HJAKKECJQtr8LwD1y/A1/vcdfEUIEyfZ9AcQbYvZ942Px88L2UwlJR0dH0EMPPbRj5syZPUeNGrXR7Xb/641xIwJ1XY9NSUlZm52dfW+XLl1w8uRJzJ8//+OGhoYJqqqe1TSt1Wsm9NN1PSIqKmr12rVrR5WUlHy1bdu2AQCumWc3IYRD1/UwVVXnFRQUTIuNjUVzczN2797dWFJSkq8oymZd15sAGAEnFEUJ1nX9nzIzM1dnZmZGh4SE4OTJk5g5c+Zf29vbp9pstrMej6fVOyhIhgAYU1hY+B+hoaGoqKg4XVlZea+XTULTNFdCQsLGiRMnPuR2u3UhBOV9eeDAAWXTpk095DUe6WsoyRE5OTlr0tLSAux2O/bs2cO5c+e+pijKUpIXSHaQVAGkvPLKK++6XK4OksJLCFlXV2cvKSlJBFAjhU+x2WwhHo9nUHp6+urMzMy7wsLCUF9fjxdffPHjxsbGiTab7WuPx9NiEutOuq4PyMjI+M+srKyYqKgoHD58GDNmzNjq8XhyVFU9b/q+LH7hBAEYu3PnTlZVVRFAGgCX6f/tAHoOHDjwa0p27txp/JO9e/f+QM7cipw9nfL3kQBKt2zZQpJ87rnn6mQmoHilw2EACs+cOUOSrK+vZ1NTE0nyo48+IoBpxswoBcMJ4Ndjx471kOTFixe5d+9ekqTH42H//v13A4jyzpAURfEH0H/OnDnthu1z5sw558MmFUCPWbNmnaMP3nrrLZoyDmP8Hl68eDFJ8siRI9/Yc+zYMQKYKdtAztrTrl27xptRXV1NAKMAOAyBBBA/Y8aMdpLs6Ojgxx9//E37+++//29yvFXppwvAwMcee8xjtDHsuXLlCqOjo//ia3wsfpkoALqFhoZuIckJEyackimm3dQmEMDUmpoakmRISMhhAHOHDx/eQJIbN24kgKEyMAHAFRMTs2XXrl1saWkhSZ0kp0+ffhrAr3wEW/S8efOukORLL72kA1gKYMPWrVtJkk899dRJAHeYrgsEsIQkjx8/TgDvAPjd448/3kaSb7zxBmUa7vC6z53BwcFbSHL9+vU6Sc6aNes8gF5ewWAH0PfVV18lSQL4DMBGIcQ6AKtcLleBFC2jXtFt8ODBe0iyoqKCAJYByC8qKmJDQwOzsrK+MAmqo1OnTveHhoa+GRkZ+XZkZOSWiIiIvzgcjk9mzpypkWRmZuZpmbYbGV4AgPnNzc1sa2sjgN0A5iQmJtaSZHl5OQHcb/K3s81mW0uSTU1NBFAFYFbfvn1Pk+Tbb79NAA8IIVzW42/hByA+Pz/fLR/2ZXIda05NI/z9/TeR5J49ewhgqlxTrtI0jY2NjQQw3zTLuWJiYjaUlJToS5Ys6fjkk080kwDEeAmADcA9GzZsIElGRUW9CyAWwLApU6Y0kOSKFSsog9QICGdERMTGsrIyZmVlEcC9AB4IDw/fTpLbtm0jgN94CUAnAJmVlZVcs2aNZ/LkyRdJcvbs2b4EwAkgZfPmzTxw4AABFAN4BkC6vFeUSewcAO5duXIlSTIhIaEawGMAxgKYAmAGgCS73e5vrKVk/yGythANYEhCQsIhkly+fDkBpKqqGmL6DgIALDKN/3yZpVWQZGVlJQE8aPI3KiMjo5okV61aRQAjAPQBMPfIkSN0u90EUCBtsPiFEwpgbn19PdetW2fM5N4zQ9ekpKQqkty0aRMBpMjiWM6JEydIkoqirJUFJ6iq6pAPVy8A6cZMehMBUACEuVyuFwG8HBwcPEIWx367ZMkSjSQXLVrUJouTRorrkAHdA8BdQogsAOsKCwtJkmPGjDkvMw2bDDo/ADEjRoz4XylyFbm5uY0mAbjLyyZ/AOOrq6tZVlbWsWDBgo69e/eyoqKCgwcPPg4gSQaoIRbp27dvN7KF+tLSUr28vJwFBQXtMpvpYRIM7+wrAkDeqVOnePbsWQIoNKfzpiXPg8uXLydJJicnNwF4f+nSpW6STEtLq5fjYwhk1wkTJtSQ5Ouvv04AqTKj+N2xY8dIkgEBAW/Ie1v8wncRegwZMmQvSfbr12+3Ua33WqPfOWbMmP0kWVpaSgCDZAqcfejQIWNZsEGKgvnh9gfQb9myZd8nAEJVVZtMkUNk8CcNHTq0liR1XWdYWNhmH1mJIme80OnTp18x1rp5eXkEsNJms92Fb7e/IgEsvHz5Mp999tkmAI/l5uZeMC0B7vEqqAYAyL106RJJsra2lpWVld+sucePH38ZQG+5NncBeOrgwYMkqbe3t/Po0aOsra011wAWyl0H7x0JJ4DE+fPnu0kyPT29DsDdUrBuyNKEEAkAdpw/f/6GeoEM8GUmfwEgPCIiopwkGxsbabPZPgOw6L777vvm4p49e26VGYjFLxUhhD+ApLKyMp44ccIoVnXybgbgzkcfffRzklyzZg0BDJYCMMmoCwQFBXkLgLGWvvcWAgBToSsKwNPTp09vMR7UuLi4rwH0lgU8c/Db5ezbeeTIkRWzZ8++aMxu+fn5BPCADBwHgP4LFy701NXVEUAJgAnPP/98kyxMNgHo53A4zH77BQQETMvPz7+Um5vbBuAlAFMSExPPmdbVL0qh8Acw8fDhw5SCchVAEYAVb775JknyhRdeaJYztHfxMwLAaqNwCGC2FArv8x0hAHKNLGPKlCme5OTk/Zs3bzb7O0wKiiG8KXl5ed8IxenTp0mSR48e1UmyW7duWywBuD2xyQcgFECgoih+8H1gyJgZV5Lkyy+/3CbTRIePtl2HDBmyw1QBHyGDdXZdXR1JUghRKkXBjOMHCoBdpr0L3nvvPZLkF198wejo6O0A4lVVDTb74HQ6AwD8Wq7Jh8rgGgDgQ13XjVR8qaxJuADMbmlpYXl5uV5UVNRWUFDgfv/993Vj/ZydnU1c37eHXML4S3viAcQqitJD2l104cIFY8lTKsXSBWBMVVWVcd9yed2A1NTUQ6Zl00CvLMMOoHdubm6zFIlWOf5+PsY/Kj09vdrU11QAwwGsv3jxIk21m2DZr10I0RXAuAcffPBgaWkpV69eTYfDcdiwUxY0w6xw+flX8L1xApjevXv3lREREaW6rofB93aPDUDQpEmTMgHgtddeqwBwEd/utZvpqK6uPgEAcXFxkA94NwB9unfvjrNnz4LklwDcf08iIqv66Zs2bXrl4YcfxooVKxAbG7uqrq5uAYA2TdOEqqpGYIi2tjbl6aeffu/YsWPv5uTk7JaC1wHg4Pnz542MwoVvTx+21dbWYvjw4WLixIl+2dnZ9lGjRgmSTE1NRUpKCkwFTGiaxtTU1OXTpk3707Bhw/6g67pDipnT4biuj7qut+Lbk3Vf1tTUXI9qu91Pjq1QFEUBgJaWFgBo8yGOQ8eNGxcAAOvXr/8QwBUfYygAKL169eoCABcuXACAWtn2hOGv0+kMNO1KiPDw8F4A4rZv3/7R1KlTR0+bNu1ht9u9r1+/fqitrQXJgwDarRC6/QjPzs4+QJIffPCB9/aQmSAA43ft2mW0e1QGoi8CAPyLsZccExNTC2BlRkbGRdOyYJCP2csBIN6UAZzCd7cBbQCijYp/dXU1ExMTz6SmptaMHj36f9LS0vYlJCRsl6mxIWSdu3fv/g5J7t+/nwC2AShMTk6+SJKff/45AWRLYbD7+fndAeDf5BJnLoCCyZMnt5JkdnZ2C4B/F0KEm1Pu+Pj4rST55ZdfEsBWAK+mpaVdMo3raDn7KwDuSEpK+m+S3LBhAwG8DuCtHTt2UBbpjgC408vvcFVV15HkuXPnjMp+p5uMf0RcXNyHJNnQ0EBVVfcCWBQXF3fG+Jv0yxABPwB5LS0tRmFxN4BlTzzxxGWSXLx4sS5F3GGFy+1Hp5SUlJq6ujoWFxdTpsZ2H+0iIyMj/0iSWVlZX5mr5jfJFroPGzasxlhTnjp1iiTZ3NxMl8tlrCd9pfa9SkpKSJI5OTmnZOageLUZZqxvfVFWVkZcPwdgNwnSCKPqb17jkmR8fPzfZMDZ5CRsFBmNI7h95s2b1yhT7/MAYmStwCx4vy0uLqa3v5qmEcCfvSr1QQAeXb16NY3Cm3HQ55133iGAp+SxZTNhKSkpfzUddkrFjYevzAQCeGjp0qXfsYckY2NjTwD4leGDLCL2HTdunNtoY+zWSHFcIHdsFCtcfuZ1vO9Eqs3m7/F47sb1k2qX/f3997W2tl7BjWfpBYDOzzzzzIVJkyZh0KBBCwEsB3AJvl9AETabLcDj8dwRFRW1ctasWb8JCgpSzp07d62wsPC/Wltb8xRFadR1/ZqPXYbgAQMGbI2Pjw/+6quv9ldVVT0r01ezuPRJSUn5Y9euXXVd11WzDaqq6kePHm3+7LPPRgO4KlNuxWazhXo8nuTk5OSXMjIyEl0uFxoaGtqKior+dPXq1VdUVT0jj7r68ieoT58+vx8yZMjdx48fP1JVVTVF9m20VW02WyfZf97YsWPjXS4X6urqWvPy8jYCWCyEuEDS8FdVFKWzruv//OSTTy5OTk7uqWkaPv3007qysrJ8RVH+LI8ym8/rB3Tu3HnRI488knLo0KG2ffv2ZQI4C98vP6mqqoZqmpaclpa2cOTIkX39/f3R0NDQUVxc/G5TU9PLqqrWa5rWLH1QVFUN0TStX1JSUvH48eP7BwYG4uDBg1cKCgpeBbBe2u+2Qug2EwD5N5sMPuNtMe8XP4TT6Qxoa2sbIGeXvUKIK7d4IISiKC5d1wPljOfA9bPwzYqiXNV13dd6Uqiq6qdpml2mpe02m63d4/G4vcTF5fF47LJf71nJA6BZVVW3pmntuPHlmAD5wk6Q9NnbHp9vHaqq6tA0zU/64PZhk1FfCZB9G/23ALiqKEqzD39tpvbGUqoFwFUhRLP3yzpCCDtJpxyXDulfG27+pqRR3DXsUWVd4Yq0x/taVQjhIhksC8L+ABpM9ljBf5sKwI8pIBr75L5E4vvu+UNeG/a+hv+AL7yFH8qPtOfHjtOP6V/Bja8D6z/B2Nys/1u9Xv33tLf4GfF/LC4GCJwByWIAAAAASUVORK5CYII\x3d";
  1255. cc._loaderImage = "data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k\x3d";
  1256. var cc = cc || {},
  1257. ClassManager = {
  1258. id: 0 | 998 * Math.random(),
  1259. instanceId: 0 | 998 * Math.random(),
  1260. compileSuper: function(a, b, c) {
  1261. a = a.toString();
  1262. var d = a.indexOf("("),
  1263. e = a.indexOf(")"),
  1264. d = a.substring(d + 1, e),
  1265. d = d.trim(),
  1266. e = a.indexOf("{"),
  1267. f = a.lastIndexOf("}");
  1268. for (a = a.substring(e + 1, f); - 1 !== a.indexOf("this._super");) {
  1269. var e = a.indexOf("this._super"),
  1270. f = a.indexOf("(", e),
  1271. g = a.indexOf(")", f),
  1272. g = a.substring(f + 1, g),
  1273. g = (g = g.trim()) ? "," : "";
  1274. a = a.substring(0, e) + "ClassManager[" + c + "]." + b + ".call(this" + g + a.substring(f + 1)
  1275. }
  1276. return Function(d, a)
  1277. },
  1278. getNewID: function() {
  1279. return this.id++
  1280. },
  1281. getNewInstanceId: function() {
  1282. return this.instanceId++
  1283. }
  1284. };
  1285. ClassManager.compileSuper.ClassManager = ClassManager;
  1286. (function() {
  1287. var a = /\b_super\b/,
  1288. b = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];
  1289. b && console.log("release Mode");
  1290. cc.Class = function() {};
  1291. cc.Class.extend = function(c) {
  1292. function d() {
  1293. this.__instanceId = ClassManager.getNewInstanceId();
  1294. this.ctor && this.ctor.apply(this, arguments)
  1295. }
  1296. var e = this.prototype,
  1297. f = Object.create(e),
  1298. g = ClassManager.getNewID();
  1299. ClassManager[g] = e;
  1300. var h = {
  1301. writable: !0,
  1302. enumerable: !1,
  1303. configurable: !0
  1304. };
  1305. f.__instanceId = null;
  1306. d.id = g;
  1307. h.value = g;
  1308. Object.defineProperty(f, "__pid", h);
  1309. d.prototype = f;
  1310. h.value = d;
  1311. Object.defineProperty(d.prototype, "constructor", h);
  1312. this.__getters__ && (d.__getters__ = cc.clone(this.__getters__));
  1313. this.__setters__ && (d.__setters__ = cc.clone(this.__setters__));
  1314. for (var k = 0, m = arguments.length; k < m; ++k) {
  1315. var n = arguments[k],
  1316. p;
  1317. for (p in n) {
  1318. var t = "function" === typeof n[p],
  1319. r = "function" === typeof e[p],
  1320. u = a.test(n[p]);
  1321. b && t && r && u ? (h.value = ClassManager.compileSuper(n[p], p, g), Object.defineProperty(f, p, h)) : t && r && u ? (h.value = function(a, b) {
  1322. return function() {
  1323. var c = this._super;
  1324. this._super = e[a];
  1325. var d = b.apply(this,
  1326. arguments);
  1327. this._super = c;
  1328. return d
  1329. }
  1330. }(p, n[p]), Object.defineProperty(f, p, h)) : t ? (h.value = n[p], Object.defineProperty(f, p, h)) : f[p] = n[p];
  1331. if (t) {
  1332. var s, v;
  1333. if (this.__getters__ && this.__getters__[p]) {
  1334. var t = this.__getters__[p],
  1335. x;
  1336. for (x in this.__setters__)
  1337. if (this.__setters__[x] === t) {
  1338. v = x;
  1339. break
  1340. }
  1341. cc.defineGetterSetter(f, t, n[p], n[v] ? n[v] : f[v], p, v)
  1342. }
  1343. if (this.__setters__ && this.__setters__[p]) {
  1344. t = this.__setters__[p];
  1345. for (x in this.__getters__)
  1346. if (this.__getters__[x] === t) {
  1347. s = x;
  1348. break
  1349. }
  1350. cc.defineGetterSetter(f, t, n[s] ? n[s] : f[s], n[p],
  1351. s, p)
  1352. }
  1353. }
  1354. }
  1355. }
  1356. d.extend = cc.Class.extend;
  1357. d.implement = function(a) {
  1358. for (var b in a) f[b] = a[b]
  1359. };
  1360. return d
  1361. }
  1362. })();
  1363. cc.defineGetterSetter = function(a, b, c, d, e, f) {
  1364. if (a.__defineGetter__) c && a.__defineGetter__(b, c), d && a.__defineSetter__(b, d);
  1365. else if (Object.defineProperty) {
  1366. var g = {
  1367. enumerable: !1,
  1368. configurable: !0
  1369. };
  1370. c && (g.get = c);
  1371. d && (g.set = d);
  1372. Object.defineProperty(a, b, g)
  1373. } else throw Error("browser does not support getters"); if (!e && !f)
  1374. for (var g = null != c, h = void 0 != d, k = Object.getOwnPropertyNames(a), m = 0; m < k.length; m++) {
  1375. var n = k[m];
  1376. if ((a.__lookupGetter__ ? !a.__lookupGetter__(n) : !Object.getOwnPropertyDescriptor(a, n)) && "function" === typeof a[n]) {
  1377. var p =
  1378. a[n];
  1379. if (g && p === c && (e = n, !h || f)) break;
  1380. if (h && p === d && (f = n, !g || e)) break
  1381. }
  1382. }
  1383. a = a.constructor;
  1384. e && (a.__getters__ || (a.__getters__ = {}), a.__getters__[e] = b);
  1385. f && (a.__setters__ || (a.__setters__ = {}), a.__setters__[f] = b)
  1386. };
  1387. cc.clone = function(a) {
  1388. var b = a.constructor ? new a.constructor : {},
  1389. c;
  1390. for (c in a) {
  1391. var d = a[c];
  1392. b[c] = "object" !== typeof d || !d || d instanceof cc.Node || d instanceof HTMLElement ? d : cc.clone(d)
  1393. }
  1394. return b
  1395. };
  1396. cc.inject = function(a, b) {
  1397. for (var c in a) b[c] = a[c]
  1398. };
  1399. cc = cc || {};
  1400. cc._tmp = cc._tmp || {};
  1401. cc.associateWithNative = function(a, b) {};
  1402. cc.KEY = {
  1403. none: 0,
  1404. back: 6,
  1405. menu: 18,
  1406. backspace: 8,
  1407. tab: 9,
  1408. enter: 13,
  1409. shift: 16,
  1410. ctrl: 17,
  1411. alt: 18,
  1412. pause: 19,
  1413. capslock: 20,
  1414. escape: 27,
  1415. space: 32,
  1416. pageup: 33,
  1417. pagedown: 34,
  1418. end: 35,
  1419. home: 36,
  1420. left: 37,
  1421. up: 38,
  1422. right: 39,
  1423. down: 40,
  1424. select: 41,
  1425. insert: 45,
  1426. Delete: 46,
  1427. 0: 48,
  1428. 1: 49,
  1429. 2: 50,
  1430. 3: 51,
  1431. 4: 52,
  1432. 5: 53,
  1433. 6: 54,
  1434. 7: 55,
  1435. 8: 56,
  1436. 9: 57,
  1437. a: 65,
  1438. b: 66,
  1439. c: 67,
  1440. d: 68,
  1441. e: 69,
  1442. f: 70,
  1443. g: 71,
  1444. h: 72,
  1445. i: 73,
  1446. j: 74,
  1447. k: 75,
  1448. l: 76,
  1449. m: 77,
  1450. n: 78,
  1451. o: 79,
  1452. p: 80,
  1453. q: 81,
  1454. r: 82,
  1455. s: 83,
  1456. t: 84,
  1457. u: 85,
  1458. v: 86,
  1459. w: 87,
  1460. x: 88,
  1461. y: 89,
  1462. z: 90,
  1463. num0: 96,
  1464. num1: 97,
  1465. num2: 98,
  1466. num3: 99,
  1467. num4: 100,
  1468. num5: 101,
  1469. num6: 102,
  1470. num7: 103,
  1471. num8: 104,
  1472. num9: 105,
  1473. "*": 106,
  1474. "+": 107,
  1475. "-": 109,
  1476. numdel: 110,
  1477. "/": 111,
  1478. f1: 112,
  1479. f2: 113,
  1480. f3: 114,
  1481. f4: 115,
  1482. f5: 116,
  1483. f6: 117,
  1484. f7: 118,
  1485. f8: 119,
  1486. f9: 120,
  1487. f10: 121,
  1488. f11: 122,
  1489. f12: 123,
  1490. numlock: 144,
  1491. scrolllock: 145,
  1492. ";": 186,
  1493. semicolon: 186,
  1494. equal: 187,
  1495. "\x3d": 187,
  1496. ",": 188,
  1497. comma: 188,
  1498. dash: 189,
  1499. ".": 190,
  1500. period: 190,
  1501. forwardslash: 191,
  1502. grave: 192,
  1503. "[": 219,
  1504. openbracket: 219,
  1505. backslash: 220,
  1506. "]": 221,
  1507. closebracket: 221,
  1508. quote: 222,
  1509. dpadLeft: 1E3,
  1510. dpadRight: 1001,
  1511. dpadUp: 1003,
  1512. dpadDown: 1004,
  1513. dpadCenter: 1005
  1514. };
  1515. cc.FMT_JPG = 0;
  1516. cc.FMT_PNG = 1;
  1517. cc.FMT_TIFF = 2;
  1518. cc.FMT_RAWDATA = 3;
  1519. cc.FMT_WEBP = 4;
  1520. cc.FMT_UNKNOWN = 5;
  1521. cc.getImageFormatByData = function(a) {
  1522. 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
  1523. };
  1524. cc.inherits = function(a, b) {
  1525. function c() {}
  1526. c.prototype = b.prototype;
  1527. a.superClass_ = b.prototype;
  1528. a.prototype = new c;
  1529. a.prototype.constructor = a
  1530. };
  1531. cc.base = function(a, b, c) {
  1532. var d = arguments.callee.caller;
  1533. if (d.superClass_) return ret = d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1));
  1534. for (var e = Array.prototype.slice.call(arguments, 2), f = !1, g = a.constructor; g; g = g.superClass_ && g.superClass_.constructor)
  1535. if (g.prototype[b] === d) f = !0;
  1536. else if (f) return g.prototype[b].apply(a, e);
  1537. if (a[b] === d) return a.constructor.prototype[b].apply(a, e);
  1538. throw Error("cc.base called from a method of one name to a method of a different name");
  1539. };
  1540. cc.Point = function(a, b) {
  1541. this.x = a || 0;
  1542. this.y = b || 0
  1543. };
  1544. cc.p = function(a, b) {
  1545. return void 0 === a ? {
  1546. x: 0,
  1547. y: 0
  1548. } : void 0 === b ? {
  1549. x: a.x,
  1550. y: a.y
  1551. } : {
  1552. x: a,
  1553. y: b
  1554. }
  1555. };
  1556. cc.pointEqualToPoint = function(a, b) {
  1557. return a && b && a.x === b.x && a.y === b.y
  1558. };
  1559. cc.Size = function(a, b) {
  1560. this.width = a || 0;
  1561. this.height = b || 0
  1562. };
  1563. cc.size = function(a, b) {
  1564. return void 0 === a ? {
  1565. width: 0,
  1566. height: 0
  1567. } : void 0 === b ? {
  1568. width: a.width,
  1569. height: a.height
  1570. } : {
  1571. width: a,
  1572. height: b
  1573. }
  1574. };
  1575. cc.sizeEqualToSize = function(a, b) {
  1576. return a && b && a.width === b.width && a.height === b.height
  1577. };
  1578. cc.Rect = function(a, b, c, d) {
  1579. this.x = a || 0;
  1580. this.y = b || 0;
  1581. this.width = c || 0;
  1582. this.height = d || 0
  1583. };
  1584. cc.rect = function(a, b, c, d) {
  1585. return void 0 === a ? {
  1586. x: 0,
  1587. y: 0,
  1588. width: 0,
  1589. height: 0
  1590. } : void 0 === b ? {
  1591. x: a.x,
  1592. y: a.y,
  1593. width: a.width,
  1594. height: a.height
  1595. } : {
  1596. x: a,
  1597. y: b,
  1598. width: c,
  1599. height: d
  1600. }
  1601. };
  1602. cc.rectEqualToRect = function(a, b) {
  1603. return a && b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
  1604. };
  1605. cc._rectEqualToZero = function(a) {
  1606. return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height
  1607. };
  1608. cc.rectContainsRect = function(a, b) {
  1609. return a && b ? !(a.x >= b.x || a.y >= b.y || a.x + a.width <= b.x + b.width || a.y + a.height <= b.y + b.height) : !1
  1610. };
  1611. cc.rectGetMaxX = function(a) {
  1612. return a.x + a.width
  1613. };
  1614. cc.rectGetMidX = function(a) {
  1615. return a.x + a.width / 2
  1616. };
  1617. cc.rectGetMinX = function(a) {
  1618. return a.x
  1619. };
  1620. cc.rectGetMaxY = function(a) {
  1621. return a.y + a.height
  1622. };
  1623. cc.rectGetMidY = function(a) {
  1624. return a.y + a.height / 2
  1625. };
  1626. cc.rectGetMinY = function(a) {
  1627. return a.y
  1628. };
  1629. cc.rectContainsPoint = function(a, b) {
  1630. return b.x >= cc.rectGetMinX(a) && b.x <= cc.rectGetMaxX(a) && b.y >= cc.rectGetMinY(a) && b.y <= cc.rectGetMaxY(a)
  1631. };
  1632. cc.rectIntersectsRect = function(a, b) {
  1633. var c = a.y + a.height,
  1634. d = b.x + b.width,
  1635. e = b.y + b.height;
  1636. return !(a.x + a.width < b.x || d < a.x || c < b.y || e < a.y)
  1637. };
  1638. cc.rectOverlapsRect = function(a, b) {
  1639. return !(a.x + a.width < b.x || b.x + b.width < a.x || a.y + a.height < b.y || b.y + b.height < a.y)
  1640. };
  1641. cc.rectUnion = function(a, b) {
  1642. var c = cc.rect(0, 0, 0, 0);
  1643. c.x = Math.min(a.x, b.x);
  1644. c.y = Math.min(a.y, b.y);
  1645. c.width = Math.max(a.x + a.width, b.x + b.width) - c.x;
  1646. c.height = Math.max(a.y + a.height, b.y + b.height) - c.y;
  1647. return c
  1648. };
  1649. cc.rectIntersection = function(a, b) {
  1650. var c = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(b)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(b)), 0, 0);
  1651. c.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(b)) - cc.rectGetMinX(c);
  1652. c.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(b)) - cc.rectGetMinY(c);
  1653. return c
  1654. };
  1655. cc.SAXParser = cc.Class.extend({
  1656. _parser: null,
  1657. _isSupportDOMParser: null,
  1658. ctor: function() {
  1659. window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1
  1660. },
  1661. parse: function(a) {
  1662. return this._parseXML(a)
  1663. },
  1664. _parseXML: function(a) {
  1665. var b;
  1666. this._isSupportDOMParser ? b = this._parser.parseFromString(a, "text/xml") : (b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a));
  1667. return b
  1668. }
  1669. });
  1670. cc.PlistParser = cc.SAXParser.extend({
  1671. parse: function(a) {
  1672. a = this._parseXML(a).documentElement;
  1673. if ("plist" !== a.tagName) throw "Not a plist file!";
  1674. for (var b = null, c = 0, d = a.childNodes.length; c < d && (b = a.childNodes[c], 1 !== b.nodeType); c++);
  1675. return this._parseNode(b)
  1676. },
  1677. _parseNode: function(a) {
  1678. var b = null,
  1679. c = a.tagName;
  1680. if ("dict" === c) b = this._parseDict(a);
  1681. else if ("array" === c) b = this._parseArray(a);
  1682. else if ("string" === c)
  1683. if (1 === a.childNodes.length) b = a.firstChild.nodeValue;
  1684. else
  1685. for (b = "", c = 0; c < a.childNodes.length; c++) b += a.childNodes[c].nodeValue;
  1686. else "false" === c ? b = !1 : "true" === c ? b = !0 : "real" === c ? b = parseFloat(a.firstChild.nodeValue) : "integer" === c && (b = parseInt(a.firstChild.nodeValue, 10));
  1687. return b
  1688. },
  1689. _parseArray: function(a) {
  1690. for (var b = [], c = 0, d = a.childNodes.length; c < d; c++) {
  1691. var e = a.childNodes[c];
  1692. 1 === e.nodeType && b.push(this._parseNode(e))
  1693. }
  1694. return b
  1695. },
  1696. _parseDict: function(a) {
  1697. for (var b = {}, c = null, d = 0, e = a.childNodes.length; d < e; d++) {
  1698. var f = a.childNodes[d];
  1699. 1 === f.nodeType && ("key" === f.tagName ? c = f.firstChild.nodeValue : b[c] = this._parseNode(f))
  1700. }
  1701. return b
  1702. }
  1703. });
  1704. cc._txtLoader = {
  1705. load: function(a, b, c, d) {
  1706. cc.loader.loadTxt(a, d)
  1707. }
  1708. };
  1709. cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader);
  1710. cc._jsonLoader = {
  1711. load: function(a, b, c, d) {
  1712. cc.loader.loadJson(a, d)
  1713. }
  1714. };
  1715. cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
  1716. cc._jsLoader = {
  1717. load: function(a, b, c, d) {
  1718. cc.loader.loadJs(a, d)
  1719. }
  1720. };
  1721. cc.loader.register(["js"], cc._jsLoader);
  1722. cc._imgLoader = {
  1723. load: function(a, b, c, d) {
  1724. cc.loader.cache[b] = cc.loader.loadImg(a, function(a, c) {
  1725. if (a) return d(a);
  1726. cc.textureCache.handleLoadedTexture(b);
  1727. d(null, c)
  1728. })
  1729. }
  1730. };
  1731. cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader);
  1732. cc._serverImgLoader = {
  1733. load: function(a, b, c, d) {
  1734. cc.loader.cache[b] = cc.loader.loadImg(c.src, function(a, c) {
  1735. if (a) return d(a);
  1736. cc.textureCache.handleLoadedTexture(b);
  1737. d(null, c)
  1738. })
  1739. }
  1740. };
  1741. cc.loader.register(["serverImg"], cc._serverImgLoader);
  1742. cc._plistLoader = {
  1743. load: function(a, b, c, d) {
  1744. cc.loader.loadTxt(a, function(a, b) {
  1745. if (a) return d(a);
  1746. d(null, cc.plistParser.parse(b))
  1747. })
  1748. }
  1749. };
  1750. cc.loader.register(["plist"], cc._plistLoader);
  1751. cc._fontLoader = {
  1752. TYPE: {
  1753. ".eot": "embedded-opentype",
  1754. ".ttf": "truetype",
  1755. ".woff": "woff",
  1756. ".svg": "svg"
  1757. },
  1758. _loadFont: function(a, b, c) {
  1759. var d = document,
  1760. e = cc.path,
  1761. f = this.TYPE,
  1762. g = cc.newElement("style");
  1763. g.type = "text/css";
  1764. d.body.appendChild(g);
  1765. var h = "@font-face { font-family:" + a + "; src:";
  1766. if (b instanceof Array)
  1767. for (var k = 0, m = b.length; k < m; k++) c = e.extname(b[k]).toLowerCase(), h += "url('" + b[k] + "') format('" + f[c] + "')", h += k === m - 1 ? ";" : ",";
  1768. else h += "url('" + b + "') format('" + f[c] + "');";
  1769. g.textContent += h + "};";
  1770. b = cc.newElement("div");
  1771. c = b.style;
  1772. c.fontFamily = a;
  1773. b.innerHTML = ".";
  1774. c.position = "absolute";
  1775. c.left = "-100px";
  1776. c.top = "-100px";
  1777. d.body.appendChild(b)
  1778. },
  1779. load: function(a, b, c, d) {
  1780. b = c.type;
  1781. a = c.name;
  1782. b = c.srcs;
  1783. cc.isString(c) ? (b = cc.path.extname(c), a = cc.path.basename(c, b), this._loadFont(a, c, b)) : this._loadFont(a, b);
  1784. d(null, !0)
  1785. }
  1786. };
  1787. cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
  1788. cc._binaryLoader = {
  1789. load: function(a, b, c, d) {
  1790. cc.loader.loadBinary(a, d)
  1791. }
  1792. };
  1793. cc._csbLoader = {
  1794. load: function(a, b, c, d) {
  1795. cc.loader.loadCsb(a, d)
  1796. }
  1797. };
  1798. cc.loader.register(["csb"], cc._csbLoader);
  1799. window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-JS v3.5";
  1800. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
  1801. cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
  1802. cc.DIRECTOR_FPS_INTERVAL = 0.5;
  1803. cc.COCOSNODE_RENDER_SUBPIXEL = 1;
  1804. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
  1805. cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
  1806. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
  1807. cc.TEXTURE_ATLAS_USE_VAO = 0;
  1808. cc.TEXTURE_NPOT_SUPPORT = 0;
  1809. cc.RETINA_DISPLAY_SUPPORT = 1;
  1810. cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
  1811. cc.USE_LA88_LABELS = 1;
  1812. cc.SPRITE_DEBUG_DRAW = 0;
  1813. cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
  1814. cc.LABELBMFONT_DEBUG_DRAW = 0;
  1815. cc.LABELATLAS_DEBUG_DRAW = 0;
  1816. cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
  1817. cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
  1818. cc.ENABLE_STACKABLE_ACTIONS = 1;
  1819. cc.ENABLE_GL_STATE_CACHE = 1;
  1820. cc.$ = function(a) {
  1821. var b = this === cc ? document : this;
  1822. if (a = a instanceof HTMLElement ? a : b.querySelector(a)) a.find = a.find || cc.$, a.hasClass = a.hasClass || function(a) {
  1823. return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)"))
  1824. }, a.addClass = a.addClass || function(a) {
  1825. this.hasClass(a) || (this.className && (this.className += " "), this.className += a);
  1826. return this
  1827. }, a.removeClass = a.removeClass || function(a) {
  1828. this.hasClass(a) && (this.className = this.className.replace(a, ""));
  1829. return this
  1830. }, a.remove = a.remove || function() {
  1831. this.parentNode &&
  1832. this.parentNode.removeChild(this);
  1833. return this
  1834. }, a.appendTo = a.appendTo || function(a) {
  1835. a.appendChild(this);
  1836. return this
  1837. }, a.prependTo = a.prependTo || function(a) {
  1838. a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this);
  1839. return this
  1840. }, a.transforms = a.transforms || function() {
  1841. this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew);
  1842. return this
  1843. }, a.position = a.position || {
  1844. x: 0,
  1845. y: 0
  1846. }, a.rotation = a.rotation || 0, a.scale = a.scale || {
  1847. x: 1,
  1848. y: 1
  1849. }, a.skew =
  1850. a.skew || {
  1851. x: 0,
  1852. y: 0
  1853. }, a.translates = function(a, b) {
  1854. this.position.x = a;
  1855. this.position.y = b;
  1856. this.transforms();
  1857. return this
  1858. }, a.rotate = function(a) {
  1859. this.rotation = a;
  1860. this.transforms();
  1861. return this
  1862. }, a.resize = function(a, b) {
  1863. this.scale.x = a;
  1864. this.scale.y = b;
  1865. this.transforms();
  1866. return this
  1867. }, a.setSkew = function(a, b) {
  1868. this.skew.x = a;
  1869. this.skew.y = b;
  1870. this.transforms();
  1871. return this
  1872. };
  1873. return a
  1874. };
  1875. switch (cc.sys.browserType) {
  1876. case cc.sys.BROWSER_TYPE_FIREFOX:
  1877. cc.$.pfx = "Moz";
  1878. cc.$.hd = !0;
  1879. break;
  1880. case cc.sys.BROWSER_TYPE_CHROME:
  1881. case cc.sys.BROWSER_TYPE_SAFARI:
  1882. cc.$.pfx = "webkit";
  1883. cc.$.hd = !0;
  1884. break;
  1885. case cc.sys.BROWSER_TYPE_OPERA:
  1886. cc.$.pfx = "O";
  1887. cc.$.hd = !1;
  1888. break;
  1889. case cc.sys.BROWSER_TYPE_IE:
  1890. cc.$.pfx = "ms";
  1891. cc.$.hd = !1;
  1892. break;
  1893. default:
  1894. cc.$.pfx = "webkit", cc.$.hd = !0
  1895. }
  1896. cc.$.trans = cc.$.pfx + "Transform";
  1897. cc.$.translate = cc.$.hd ? function(a) {
  1898. return "translate3d(" + a.x + "px, " + a.y + "px, 0) "
  1899. } : function(a) {
  1900. return "translate(" + a.x + "px, " + a.y + "px) "
  1901. };
  1902. cc.$.rotate = cc.$.hd ? function(a) {
  1903. return "rotateZ(" + a + "deg) "
  1904. } : function(a) {
  1905. return "rotate(" + a + "deg) "
  1906. };
  1907. cc.$.scale = function(a) {
  1908. return "scale(" + a.x + ", " + a.y + ") "
  1909. };
  1910. cc.$.skew = function(a) {
  1911. return "skewX(" + -a.x + "deg) skewY(" + a.y + "deg)"
  1912. };
  1913. cc.$new = function(a) {
  1914. return cc.$(document.createElement(a))
  1915. };
  1916. cc.$.findpos = function(a) {
  1917. var b = 0,
  1918. c = 0;
  1919. do b += a.offsetLeft, c += a.offsetTop; while (a = a.offsetParent);
  1920. return {
  1921. x: b,
  1922. y: c
  1923. }
  1924. };
  1925. cc.INVALID_INDEX = -1;
  1926. cc.PI = Math.PI;
  1927. cc.FLT_MAX = parseFloat("3.402823466e+38F");
  1928. cc.FLT_MIN = parseFloat("1.175494351e-38F");
  1929. cc.RAD = cc.PI / 180;
  1930. cc.DEG = 180 / cc.PI;
  1931. cc.UINT_MAX = 4294967295;
  1932. cc.swap = function(a, b, c) {
  1933. if (!cc.isObject(c) || cc.isUndefined(c.x) || cc.isUndefined(c.y)) cc.log(cc._LogInfos.swap);
  1934. else {
  1935. var d = c[a];
  1936. c[a] = c[b];
  1937. c[b] = d
  1938. }
  1939. };
  1940. cc.lerp = function(a, b, c) {
  1941. return a + (b - a) * c
  1942. };
  1943. cc.rand = function() {
  1944. return 16777215 * Math.random()
  1945. };
  1946. cc.randomMinus1To1 = function() {
  1947. return 2 * (Math.random() - 0.5)
  1948. };
  1949. cc.random0To1 = Math.random;
  1950. cc.degreesToRadians = function(a) {
  1951. return a * cc.RAD
  1952. };
  1953. cc.radiansToDegrees = function(a) {
  1954. return a * cc.DEG
  1955. };
  1956. cc.radiansToDegress = function(a) {
  1957. cc.log(cc._LogInfos.radiansToDegress);
  1958. return a * cc.DEG
  1959. };
  1960. cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
  1961. cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770;
  1962. cc.BLEND_DST = 771;
  1963. cc.nodeDrawSetup = function(a) {
  1964. a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())
  1965. };
  1966. cc.enableDefaultGLStates = function() {};
  1967. cc.disableDefaultGLStates = function() {};
  1968. cc.incrementGLDraws = function(a) {
  1969. cc.g_NumberOfDraws += a
  1970. };
  1971. cc.FLT_EPSILON = 1.192092896E-7;
  1972. cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ? function() {
  1973. return cc.director.getContentScaleFactor()
  1974. } : function() {
  1975. return 1
  1976. };
  1977. cc.pointPointsToPixels = function(a) {
  1978. var b = cc.contentScaleFactor();
  1979. return cc.p(a.x * b, a.y * b)
  1980. };
  1981. cc.pointPixelsToPoints = function(a) {
  1982. var b = cc.contentScaleFactor();
  1983. return cc.p(a.x / b, a.y / b)
  1984. };
  1985. cc._pointPixelsToPointsOut = function(a, b) {
  1986. var c = cc.contentScaleFactor();
  1987. b.x = a.x / c;
  1988. b.y = a.y / c
  1989. };
  1990. cc.sizePointsToPixels = function(a) {
  1991. var b = cc.contentScaleFactor();
  1992. return cc.size(a.width * b, a.height * b)
  1993. };
  1994. cc.sizePixelsToPoints = function(a) {
  1995. var b = cc.contentScaleFactor();
  1996. return cc.size(a.width / b, a.height / b)
  1997. };
  1998. cc._sizePixelsToPointsOut = function(a, b) {
  1999. var c = cc.contentScaleFactor();
  2000. b.width = a.width / c;
  2001. b.height = a.height / c
  2002. };
  2003. cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
  2004. var b = cc.contentScaleFactor();
  2005. return cc.rect(a.x / b, a.y / b, a.width / b, a.height / b)
  2006. } : function(a) {
  2007. return a
  2008. };
  2009. cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function(a) {
  2010. var b = cc.contentScaleFactor();
  2011. return cc.rect(a.x * b, a.y * b, a.width * b, a.height * b)
  2012. } : function(a) {
  2013. return a
  2014. };
  2015. cc.ONE = 1;
  2016. cc.ZERO = 0;
  2017. cc.SRC_ALPHA = 770;
  2018. cc.SRC_ALPHA_SATURATE = 776;
  2019. cc.SRC_COLOR = 768;
  2020. cc.DST_ALPHA = 772;
  2021. cc.DST_COLOR = 774;
  2022. cc.ONE_MINUS_SRC_ALPHA = 771;
  2023. cc.ONE_MINUS_SRC_COLOR = 769;
  2024. cc.ONE_MINUS_DST_ALPHA = 773;
  2025. cc.ONE_MINUS_DST_COLOR = 775;
  2026. cc.ONE_MINUS_CONSTANT_ALPHA = 32772;
  2027. cc.ONE_MINUS_CONSTANT_COLOR = 32770;
  2028. cc.LINEAR = 9729;
  2029. cc.REPEAT = 10497;
  2030. cc.CLAMP_TO_EDGE = 33071;
  2031. cc.MIRRORED_REPEAT = 33648;
  2032. cc.checkGLErrorDebug = function() {
  2033. if (cc.renderMode === cc._RENDER_TYPE_WEBGL) {
  2034. var a = cc._renderContext.getError();
  2035. a && cc.log(cc._LogInfos.checkGLErrorDebug, a)
  2036. }
  2037. };
  2038. cc.DEVICE_ORIENTATION_PORTRAIT = 0;
  2039. cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
  2040. cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
  2041. cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
  2042. cc.DEVICE_MAX_ORIENTATIONS = 2;
  2043. cc.VERTEX_ATTRIB_FLAG_NONE = 0;
  2044. cc.VERTEX_ATTRIB_FLAG_POSITION = 1;
  2045. cc.VERTEX_ATTRIB_FLAG_COLOR = 2;
  2046. cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4;
  2047. cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  2048. cc.GL_ALL = 0;
  2049. cc.VERTEX_ATTRIB_POSITION = 0;
  2050. cc.VERTEX_ATTRIB_COLOR = 1;
  2051. cc.VERTEX_ATTRIB_TEX_COORDS = 2;
  2052. cc.VERTEX_ATTRIB_MAX = 3;
  2053. cc.UNIFORM_PMATRIX = 0;
  2054. cc.UNIFORM_MVMATRIX = 1;
  2055. cc.UNIFORM_MVPMATRIX = 2;
  2056. cc.UNIFORM_TIME = 3;
  2057. cc.UNIFORM_SINTIME = 4;
  2058. cc.UNIFORM_COSTIME = 5;
  2059. cc.UNIFORM_RANDOM01 = 6;
  2060. cc.UNIFORM_SAMPLER = 7;
  2061. cc.UNIFORM_MAX = 8;
  2062. cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
  2063. cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
  2064. cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
  2065. cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
  2066. cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
  2067. cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
  2068. cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
  2069. cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
  2070. cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
  2071. cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
  2072. cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
  2073. cc.UNIFORM_TIME_S = "CC_Time";
  2074. cc.UNIFORM_SINTIME_S = "CC_SinTime";
  2075. cc.UNIFORM_COSTIME_S = "CC_CosTime";
  2076. cc.UNIFORM_RANDOM01_S = "CC_Random01";
  2077. cc.UNIFORM_SAMPLER_S = "CC_Texture0";
  2078. cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
  2079. cc.ATTRIBUTE_NAME_COLOR = "a_color";
  2080. cc.ATTRIBUTE_NAME_POSITION = "a_position";
  2081. cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
  2082. cc.ITEM_SIZE = 32;
  2083. cc.CURRENT_ITEM = 3233828865;
  2084. cc.ZOOM_ACTION_TAG = 3233828866;
  2085. cc.NORMAL_TAG = 8801;
  2086. cc.SELECTED_TAG = 8802;
  2087. cc.DISABLE_TAG = 8803;
  2088. cc.arrayVerifyType = function(a, b) {
  2089. if (a && 0 < a.length)
  2090. for (var c = 0; c < a.length; c++)
  2091. if (!(a[c] instanceof b)) return cc.log("element type is wrong!"), !1;
  2092. return !0
  2093. };
  2094. cc.arrayRemoveObject = function(a, b) {
  2095. for (var c = 0, d = a.length; c < d; c++)
  2096. if (a[c] === b) {
  2097. a.splice(c, 1);
  2098. break
  2099. }
  2100. };
  2101. cc.arrayRemoveArray = function(a, b) {
  2102. for (var c = 0, d = b.length; c < d; c++) cc.arrayRemoveObject(a, b[c])
  2103. };
  2104. cc.arrayAppendObjectsToIndex = function(a, b, c) {
  2105. a.splice.apply(a, [c, 0].concat(b));
  2106. return a
  2107. };
  2108. cc.copyArray = function(a) {
  2109. var b, c = a.length,
  2110. d = Array(c);
  2111. for (b = 0; b < c; b += 1) d[b] = a[b];
  2112. return d
  2113. };
  2114. cc = cc || {};
  2115. cc._tmp = cc._tmp || {};
  2116. cc._tmp.WebGLColor = function() {
  2117. cc.color = function(a, c, d, e, f, g) {
  2118. return void 0 === a ? new cc.Color(0, 0, 0, 255, f, g) : cc.isString(a) ? (a = cc.hexToColor(a), new cc.Color(a.r, a.g, a.b, a.a)) : cc.isObject(a) ? new cc.Color(a.r, a.g, a.b, a.a, a.arrayBuffer, a.offset) : new cc.Color(a, c, d, e, f, g)
  2119. };
  2120. cc.Color = function(a, c, d, e, f, g) {
  2121. this._arrayBuffer = f || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT);
  2122. this._offset = g || 0;
  2123. f = this._arrayBuffer;
  2124. g = this._offset;
  2125. var h = Uint8Array.BYTES_PER_ELEMENT;
  2126. this._rU8 = new Uint8Array(f, g, 1);
  2127. this._gU8 = new Uint8Array(f,
  2128. g + h, 1);
  2129. this._bU8 = new Uint8Array(f, g + 2 * h, 1);
  2130. this._aU8 = new Uint8Array(f, g + 3 * h, 1);
  2131. this._rU8[0] = a || 0;
  2132. this._gU8[0] = c || 0;
  2133. this._bU8[0] = d || 0;
  2134. this._aU8[0] = null == e ? 255 : e;
  2135. void 0 === e && (this.a_undefined = !0)
  2136. };
  2137. cc.Color.BYTES_PER_ELEMENT = 4;
  2138. var a = cc.Color.prototype;
  2139. a._getR = function() {
  2140. return this._rU8[0]
  2141. };
  2142. a._setR = function(a) {
  2143. this._rU8[0] = 0 > a ? 0 : a
  2144. };
  2145. a._getG = function() {
  2146. return this._gU8[0]
  2147. };
  2148. a._setG = function(a) {
  2149. this._gU8[0] = 0 > a ? 0 : a
  2150. };
  2151. a._getB = function() {
  2152. return this._bU8[0]
  2153. };
  2154. a._setB = function(a) {
  2155. this._bU8[0] = 0 > a ? 0 : a
  2156. };
  2157. a._getA =
  2158. function() {
  2159. return this._aU8[0]
  2160. };
  2161. a._setA = function(a) {
  2162. this._aU8[0] = 0 > a ? 0 : a
  2163. };
  2164. cc.defineGetterSetter(a, "r", a._getR, a._setR);
  2165. cc.defineGetterSetter(a, "g", a._getG, a._setG);
  2166. cc.defineGetterSetter(a, "b", a._getB, a._setB);
  2167. cc.defineGetterSetter(a, "a", a._getA, a._setA);
  2168. cc.Vertex2F = function(a, c, d, e) {
  2169. this._arrayBuffer = d || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
  2170. this._offset = e || 0;
  2171. this._xF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  2172. this._yF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  2173. this._xF32[0] =
  2174. a || 0;
  2175. this._yF32[0] = c || 0
  2176. };
  2177. cc.Vertex2F.BYTES_PER_ELEMENT = 8;
  2178. a = cc.Vertex2F.prototype;
  2179. a._getX = function() {
  2180. return this._xF32[0]
  2181. };
  2182. a._setX = function(a) {
  2183. this._xF32[0] = a
  2184. };
  2185. a._getY = function() {
  2186. return this._yF32[0]
  2187. };
  2188. a._setY = function(a) {
  2189. this._yF32[0] = a
  2190. };
  2191. cc.defineGetterSetter(a, "x", a._getX, a._setX);
  2192. cc.defineGetterSetter(a, "y", a._getY, a._setY);
  2193. cc.Vertex3F = function(a, c, d, e, f) {
  2194. this._arrayBuffer = e || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
  2195. this._offset = f || 0;
  2196. e = this._arrayBuffer;
  2197. f = this._offset;
  2198. this._xF32 = new Float32Array(e,
  2199. f, 1);
  2200. this._xF32[0] = a || 0;
  2201. this._yF32 = new Float32Array(e, f + Float32Array.BYTES_PER_ELEMENT, 1);
  2202. this._yF32[0] = c || 0;
  2203. this._zF32 = new Float32Array(e, f + 2 * Float32Array.BYTES_PER_ELEMENT, 1);
  2204. this._zF32[0] = d || 0
  2205. };
  2206. cc.Vertex3F.BYTES_PER_ELEMENT = 12;
  2207. a = cc.Vertex3F.prototype;
  2208. a._getX = function() {
  2209. return this._xF32[0]
  2210. };
  2211. a._setX = function(a) {
  2212. this._xF32[0] = a
  2213. };
  2214. a._getY = function() {
  2215. return this._yF32[0]
  2216. };
  2217. a._setY = function(a) {
  2218. this._yF32[0] = a
  2219. };
  2220. a._getZ = function() {
  2221. return this._zF32[0]
  2222. };
  2223. a._setZ = function(a) {
  2224. this._zF32[0] = a
  2225. };
  2226. cc.defineGetterSetter(a,
  2227. "x", a._getX, a._setX);
  2228. cc.defineGetterSetter(a, "y", a._getY, a._setY);
  2229. cc.defineGetterSetter(a, "z", a._getZ, a._setZ);
  2230. cc.Tex2F = function(a, c, d, e) {
  2231. this._arrayBuffer = d || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);
  2232. this._offset = e || 0;
  2233. this._uF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  2234. this._vF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  2235. this._uF32[0] = a || 0;
  2236. this._vF32[0] = c || 0
  2237. };
  2238. cc.Tex2F.BYTES_PER_ELEMENT = 8;
  2239. a = cc.Tex2F.prototype;
  2240. a._getU = function() {
  2241. return this._uF32[0]
  2242. };
  2243. a._setU = function(a) {
  2244. this._uF32[0] =
  2245. a
  2246. };
  2247. a._getV = function() {
  2248. return this._vF32[0]
  2249. };
  2250. a._setV = function(a) {
  2251. this._vF32[0] = a
  2252. };
  2253. cc.defineGetterSetter(a, "u", a._getU, a._setU);
  2254. cc.defineGetterSetter(a, "v", a._getV, a._setV);
  2255. cc.Quad2 = function(a, c, d, e, f, g) {
  2256. this._arrayBuffer = f || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);
  2257. this._offset = g || 0;
  2258. f = this._arrayBuffer;
  2259. g = cc.Vertex2F.BYTES_PER_ELEMENT;
  2260. this._tl = a ? new cc.Vertex2F(a.x, a.y, f, 0) : new cc.Vertex2F(0, 0, f, 0);
  2261. this._tr = c ? new cc.Vertex2F(c.x, c.y, f, g) : new cc.Vertex2F(0, 0, f, g);
  2262. this._bl = d ? new cc.Vertex2F(d.x, d.y,
  2263. f, 2 * g) : new cc.Vertex2F(0, 0, f, 2 * g);
  2264. this._br = e ? new cc.Vertex2F(e.x, e.y, f, 3 * g) : new cc.Vertex2F(0, 0, f, 3 * g)
  2265. };
  2266. cc.Quad2.BYTES_PER_ELEMENT = 32;
  2267. a = cc.Quad2.prototype;
  2268. a._getTL = function() {
  2269. return this._tl
  2270. };
  2271. a._setTL = function(a) {
  2272. this._tl.x = a.x;
  2273. this._tl.y = a.y
  2274. };
  2275. a._getTR = function() {
  2276. return this._tr
  2277. };
  2278. a._setTR = function(a) {
  2279. this._tr.x = a.x;
  2280. this._tr.y = a.y
  2281. };
  2282. a._getBL = function() {
  2283. return this._bl
  2284. };
  2285. a._setBL = function(a) {
  2286. this._bl.x = a.x;
  2287. this._bl.y = a.y
  2288. };
  2289. a._getBR = function() {
  2290. return this._br
  2291. };
  2292. a._setBR = function(a) {
  2293. this._br.x = a.x;
  2294. this._br.y =
  2295. a.y
  2296. };
  2297. cc.defineGetterSetter(a, "tl", a._getTL, a._setTL);
  2298. cc.defineGetterSetter(a, "tr", a._getTR, a._setTR);
  2299. cc.defineGetterSetter(a, "bl", a._getBL, a._setBL);
  2300. cc.defineGetterSetter(a, "br", a._getBR, a._setBR);
  2301. cc.Quad3 = function(a, c, d, e) {
  2302. this.bl = a || new cc.Vertex3F(0, 0, 0);
  2303. this.br = c || new cc.Vertex3F(0, 0, 0);
  2304. this.tl = d || new cc.Vertex3F(0, 0, 0);
  2305. this.tr = e || new cc.Vertex3F(0, 0, 0)
  2306. };
  2307. cc.V3F_C4B_T2F = function(a, c, d, e, f) {
  2308. this._arrayBuffer = e || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
  2309. this._offset = f || 0;
  2310. e = this._arrayBuffer;
  2311. f = this._offset;
  2312. var g = cc.Vertex3F.BYTES_PER_ELEMENT;
  2313. this._vertices = a ? new cc.Vertex3F(a.x, a.y, a.z, e, f) : new cc.Vertex3F(0, 0, 0, e, f);
  2314. this._colors = c ? cc.color(c.r, c.g, c.b, c.a, e, f + g) : cc.color(0, 0, 0, 0, e, f + g);
  2315. this._texCoords = d ? new cc.Tex2F(d.u, d.v, e, f + g + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, e, f + g + cc.Color.BYTES_PER_ELEMENT)
  2316. };
  2317. cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24;
  2318. a = cc.V3F_C4B_T2F.prototype;
  2319. a._getVertices = function() {
  2320. return this._vertices
  2321. };
  2322. a._setVertices = function(a) {
  2323. var c = this._vertices;
  2324. c.x = a.x;
  2325. c.y = a.y;
  2326. c.z =
  2327. a.z
  2328. };
  2329. a._getColor = function() {
  2330. return this._colors
  2331. };
  2332. a._setColor = function(a) {
  2333. var c = this._colors;
  2334. c.r = a.r;
  2335. c.g = a.g;
  2336. c.b = a.b;
  2337. c.a = a.a
  2338. };
  2339. a._getTexCoords = function() {
  2340. return this._texCoords
  2341. };
  2342. a._setTexCoords = function(a) {
  2343. this._texCoords.u = a.u;
  2344. this._texCoords.v = a.v
  2345. };
  2346. cc.defineGetterSetter(a, "vertices", a._getVertices, a._setVertices);
  2347. cc.defineGetterSetter(a, "colors", a._getColor, a._setColor);
  2348. cc.defineGetterSetter(a, "texCoords", a._getTexCoords, a._setTexCoords);
  2349. cc.V3F_C4B_T2F_Quad = function(a, c, d, e, f, g) {
  2350. this._arrayBuffer =
  2351. f || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
  2352. this._offset = g || 0;
  2353. f = this._arrayBuffer;
  2354. g = this._offset;
  2355. var h = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;
  2356. this._tl = a ? new cc.V3F_C4B_T2F(a.vertices, a.colors, a.texCoords, f, g) : new cc.V3F_C4B_T2F(null, null, null, f, g);
  2357. this._bl = c ? new cc.V3F_C4B_T2F(c.vertices, c.colors, c.texCoords, f, g + h) : new cc.V3F_C4B_T2F(null, null, null, f, g + h);
  2358. this._tr = d ? new cc.V3F_C4B_T2F(d.vertices, d.colors, d.texCoords, f, g + 2 * h) : new cc.V3F_C4B_T2F(null, null, null, f, g + 2 * h);
  2359. this._br = e ? new cc.V3F_C4B_T2F(e.vertices,
  2360. e.colors, e.texCoords, f, g + 3 * h) : new cc.V3F_C4B_T2F(null, null, null, f, g + 3 * h)
  2361. };
  2362. cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96;
  2363. a = cc.V3F_C4B_T2F_Quad.prototype;
  2364. a._getTL = function() {
  2365. return this._tl
  2366. };
  2367. a._setTL = function(a) {
  2368. var c = this._tl;
  2369. c.vertices = a.vertices;
  2370. c.colors = a.colors;
  2371. c.texCoords = a.texCoords
  2372. };
  2373. a._getBL = function() {
  2374. return this._bl
  2375. };
  2376. a._setBL = function(a) {
  2377. var c = this._bl;
  2378. c.vertices = a.vertices;
  2379. c.colors = a.colors;
  2380. c.texCoords = a.texCoords
  2381. };
  2382. a._getTR = function() {
  2383. return this._tr
  2384. };
  2385. a._setTR = function(a) {
  2386. var c = this._tr;
  2387. c.vertices =
  2388. a.vertices;
  2389. c.colors = a.colors;
  2390. c.texCoords = a.texCoords
  2391. };
  2392. a._getBR = function() {
  2393. return this._br
  2394. };
  2395. a._setBR = function(a) {
  2396. var c = this._br;
  2397. c.vertices = a.vertices;
  2398. c.colors = a.colors;
  2399. c.texCoords = a.texCoords
  2400. };
  2401. a._getArrayBuffer = function() {
  2402. return this._arrayBuffer
  2403. };
  2404. cc.defineGetterSetter(a, "tl", a._getTL, a._setTL);
  2405. cc.defineGetterSetter(a, "tr", a._getTR, a._setTR);
  2406. cc.defineGetterSetter(a, "bl", a._getBL, a._setBL);
  2407. cc.defineGetterSetter(a, "br", a._getBR, a._setBR);
  2408. cc.defineGetterSetter(a, "arrayBuffer", a._getArrayBuffer, null);
  2409. cc.V3F_C4B_T2F_QuadZero = function() {
  2410. return new cc.V3F_C4B_T2F_Quad
  2411. };
  2412. cc.V3F_C4B_T2F_QuadCopy = function(a) {
  2413. if (!a) return cc.V3F_C4B_T2F_QuadZero();
  2414. var c = a.tl,
  2415. d = a.bl,
  2416. e = a.tr;
  2417. a = a.br;
  2418. return {
  2419. tl: {
  2420. vertices: {
  2421. x: c.vertices.x,
  2422. y: c.vertices.y,
  2423. z: c.vertices.z
  2424. },
  2425. colors: {
  2426. r: c.colors.r,
  2427. g: c.colors.g,
  2428. b: c.colors.b,
  2429. a: c.colors.a
  2430. },
  2431. texCoords: {
  2432. u: c.texCoords.u,
  2433. v: c.texCoords.v
  2434. }
  2435. },
  2436. bl: {
  2437. vertices: {
  2438. x: d.vertices.x,
  2439. y: d.vertices.y,
  2440. z: d.vertices.z
  2441. },
  2442. colors: {
  2443. r: d.colors.r,
  2444. g: d.colors.g,
  2445. b: d.colors.b,
  2446. a: d.colors.a
  2447. },
  2448. texCoords: {
  2449. u: d.texCoords.u,
  2450. v: d.texCoords.v
  2451. }
  2452. },
  2453. tr: {
  2454. vertices: {
  2455. x: e.vertices.x,
  2456. y: e.vertices.y,
  2457. z: e.vertices.z
  2458. },
  2459. colors: {
  2460. r: e.colors.r,
  2461. g: e.colors.g,
  2462. b: e.colors.b,
  2463. a: e.colors.a
  2464. },
  2465. texCoords: {
  2466. u: e.texCoords.u,
  2467. v: e.texCoords.v
  2468. }
  2469. },
  2470. br: {
  2471. vertices: {
  2472. x: a.vertices.x,
  2473. y: a.vertices.y,
  2474. z: a.vertices.z
  2475. },
  2476. colors: {
  2477. r: a.colors.r,
  2478. g: a.colors.g,
  2479. b: a.colors.b,
  2480. a: a.colors.a
  2481. },
  2482. texCoords: {
  2483. u: a.texCoords.u,
  2484. v: a.texCoords.v
  2485. }
  2486. }
  2487. }
  2488. };
  2489. cc.V3F_C4B_T2F_QuadsCopy = function(a) {
  2490. if (!a) return [];
  2491. for (var c = [], d = 0; d < a.length; d++) c.push(cc.V3F_C4B_T2F_QuadCopy(a[d]));
  2492. return c
  2493. };
  2494. cc.V2F_C4B_T2F = function(a, c, d, e, f) {
  2495. this._arrayBuffer =
  2496. e || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);
  2497. this._offset = f || 0;
  2498. e = this._arrayBuffer;
  2499. f = this._offset;
  2500. var g = cc.Vertex2F.BYTES_PER_ELEMENT;
  2501. this._vertices = a ? new cc.Vertex2F(a.x, a.y, e, f) : new cc.Vertex2F(0, 0, e, f);
  2502. this._colors = c ? cc.color(c.r, c.g, c.b, c.a, e, f + g) : cc.color(0, 0, 0, 0, e, f + g);
  2503. this._texCoords = d ? new cc.Tex2F(d.u, d.v, e, f + g + cc.Color.BYTES_PER_ELEMENT) : new cc.Tex2F(0, 0, e, f + g + cc.Color.BYTES_PER_ELEMENT)
  2504. };
  2505. cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20;
  2506. a = cc.V2F_C4B_T2F.prototype;
  2507. a._getVertices = function() {
  2508. return this._vertices
  2509. };
  2510. a._setVertices = function(a) {
  2511. this._vertices.x = a.x;
  2512. this._vertices.y = a.y
  2513. };
  2514. a._getColor = function() {
  2515. return this._colors
  2516. };
  2517. a._setColor = function(a) {
  2518. var c = this._colors;
  2519. c.r = a.r;
  2520. c.g = a.g;
  2521. c.b = a.b;
  2522. c.a = a.a
  2523. };
  2524. a._getTexCoords = function() {
  2525. return this._texCoords
  2526. };
  2527. a._setTexCoords = function(a) {
  2528. this._texCoords.u = a.u;
  2529. this._texCoords.v = a.v
  2530. };
  2531. cc.defineGetterSetter(a, "vertices", a._getVertices, a._setVertices);
  2532. cc.defineGetterSetter(a, "colors", a._getColor, a._setColor);
  2533. cc.defineGetterSetter(a, "texCoords", a._getTexCoords, a._setTexCoords);
  2534. cc.V2F_C4B_T2F_Triangle = function(a, c, d, e, f) {
  2535. this._arrayBuffer = e || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);
  2536. this._offset = f || 0;
  2537. e = this._arrayBuffer;
  2538. f = this._offset;
  2539. var g = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  2540. this._a = a ? new cc.V2F_C4B_T2F(a.vertices, a.colors, a.texCoords, e, f) : new cc.V2F_C4B_T2F(null, null, null, e, f);
  2541. this._b = c ? new cc.V2F_C4B_T2F(c.vertices, c.colors, c.texCoords, e, f + g) : new cc.V2F_C4B_T2F(null, null, null, e, f + g);
  2542. this._c = d ? new cc.V2F_C4B_T2F(d.vertices, d.colors, d.texCoords, e, f + 2 * g) : new cc.V2F_C4B_T2F(null,
  2543. null, null, e, f + 2 * g)
  2544. };
  2545. cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60;
  2546. a = cc.V2F_C4B_T2F_Triangle.prototype;
  2547. a._getA = function() {
  2548. return this._a
  2549. };
  2550. a._setA = function(a) {
  2551. var c = this._a;
  2552. c.vertices = a.vertices;
  2553. c.colors = a.colors;
  2554. c.texCoords = a.texCoords
  2555. };
  2556. a._getB = function() {
  2557. return this._b
  2558. };
  2559. a._setB = function(a) {
  2560. var c = this._b;
  2561. c.vertices = a.vertices;
  2562. c.colors = a.colors;
  2563. c.texCoords = a.texCoords
  2564. };
  2565. a._getC = function() {
  2566. return this._c
  2567. };
  2568. a._setC = function(a) {
  2569. var c = this._c;
  2570. c.vertices = a.vertices;
  2571. c.colors = a.colors;
  2572. c.texCoords = a.texCoords
  2573. };
  2574. cc.defineGetterSetter(a, "a", a._getA, a._setA);
  2575. cc.defineGetterSetter(a, "b", a._getB, a._setB);
  2576. cc.defineGetterSetter(a, "c", a._getC, a._setC)
  2577. };
  2578. cc._tmp.PrototypeColor = function() {
  2579. var a = cc.color;
  2580. a._getWhite = function() {
  2581. return a(255, 255, 255)
  2582. };
  2583. a._getYellow = function() {
  2584. return a(255, 255, 0)
  2585. };
  2586. a._getBlue = function() {
  2587. return a(0, 0, 255)
  2588. };
  2589. a._getGreen = function() {
  2590. return a(0, 255, 0)
  2591. };
  2592. a._getRed = function() {
  2593. return a(255, 0, 0)
  2594. };
  2595. a._getMagenta = function() {
  2596. return a(255, 0, 255)
  2597. };
  2598. a._getBlack = function() {
  2599. return a(0, 0, 0)
  2600. };
  2601. a._getOrange = function() {
  2602. return a(255, 127, 0)
  2603. };
  2604. a._getGray = function() {
  2605. return a(166, 166, 166)
  2606. };
  2607. cc.defineGetterSetter(a, "WHITE", a._getWhite);
  2608. cc.defineGetterSetter(a,
  2609. "YELLOW", a._getYellow);
  2610. cc.defineGetterSetter(a, "BLUE", a._getBlue);
  2611. cc.defineGetterSetter(a, "GREEN", a._getGreen);
  2612. cc.defineGetterSetter(a, "RED", a._getRed);
  2613. cc.defineGetterSetter(a, "MAGENTA", a._getMagenta);
  2614. cc.defineGetterSetter(a, "BLACK", a._getBlack);
  2615. cc.defineGetterSetter(a, "ORANGE", a._getOrange);
  2616. cc.defineGetterSetter(a, "GRAY", a._getGray);
  2617. cc.BlendFunc._disable = function() {
  2618. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2619. };
  2620. cc.BlendFunc._alphaPremultiplied = function() {
  2621. return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA)
  2622. };
  2623. cc.BlendFunc._alphaNonPremultiplied = function() {
  2624. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA)
  2625. };
  2626. cc.BlendFunc._additive = function() {
  2627. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE)
  2628. };
  2629. cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable);
  2630. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied);
  2631. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied);
  2632. cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive)
  2633. };
  2634. cc.Color = function(a, b, c, d) {
  2635. this.r = a || 0;
  2636. this.g = b || 0;
  2637. this.b = c || 0;
  2638. this.a = null == d ? 255 : d
  2639. };
  2640. cc.color = function(a, b, c, d) {
  2641. return void 0 === a ? {
  2642. r: 0,
  2643. g: 0,
  2644. b: 0,
  2645. a: 255
  2646. } : cc.isString(a) ? cc.hexToColor(a) : cc.isObject(a) ? {
  2647. r: a.r,
  2648. g: a.g,
  2649. b: a.b,
  2650. a: null == a.a ? 255 : a.a
  2651. } : {
  2652. r: a,
  2653. g: b,
  2654. b: c,
  2655. a: null == d ? 255 : d
  2656. }
  2657. };
  2658. cc.colorEqual = function(a, b) {
  2659. return a.r === b.r && a.g === b.g && a.b === b.b
  2660. };
  2661. cc.Acceleration = function(a, b, c, d) {
  2662. this.x = a || 0;
  2663. this.y = b || 0;
  2664. this.z = c || 0;
  2665. this.timestamp = d || 0
  2666. };
  2667. cc.Vertex2F = function(a, b) {
  2668. this.x = a || 0;
  2669. this.y = b || 0
  2670. };
  2671. cc.vertex2 = function(a, b) {
  2672. return new cc.Vertex2F(a, b)
  2673. };
  2674. cc.Vertex3F = function(a, b, c) {
  2675. this.x = a || 0;
  2676. this.y = b || 0;
  2677. this.z = c || 0
  2678. };
  2679. cc.vertex3 = function(a, b, c) {
  2680. return new cc.Vertex3F(a, b, c)
  2681. };
  2682. cc.Tex2F = function(a, b) {
  2683. this.u = a || 0;
  2684. this.v = b || 0
  2685. };
  2686. cc.tex2 = function(a, b) {
  2687. return new cc.Tex2F(a, b)
  2688. };
  2689. cc.BlendFunc = function(a, b) {
  2690. this.src = a;
  2691. this.dst = b
  2692. };
  2693. cc.blendFuncDisable = function() {
  2694. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2695. };
  2696. cc.hexToColor = function(a) {
  2697. a = a.replace(/^#?/, "0x");
  2698. a = parseInt(a);
  2699. return cc.color(a >> 16, (a >> 8) % 256, a % 256)
  2700. };
  2701. cc.colorToHex = function(a) {
  2702. var b = a.r.toString(16),
  2703. c = a.g.toString(16),
  2704. d = a.b.toString(16);
  2705. return "#" + (16 > a.r ? "0" + b : b) + (16 > a.g ? "0" + c : c) + (16 > a.b ? "0" + d : d)
  2706. };
  2707. cc.TEXT_ALIGNMENT_LEFT = 0;
  2708. cc.TEXT_ALIGNMENT_CENTER = 1;
  2709. cc.TEXT_ALIGNMENT_RIGHT = 2;
  2710. cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
  2711. cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
  2712. cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
  2713. cc._Dictionary = cc.Class.extend({
  2714. _keyMapTb: null,
  2715. _valueMapTb: null,
  2716. __currId: 0,
  2717. ctor: function() {
  2718. this._keyMapTb = {};
  2719. this._valueMapTb = {};
  2720. this.__currId = 2 << (0 | 10 * Math.random())
  2721. },
  2722. __getKey: function() {
  2723. this.__currId++;
  2724. return "key_" + this.__currId
  2725. },
  2726. setObject: function(a, b) {
  2727. if (null != b) {
  2728. var c = this.__getKey();
  2729. this._keyMapTb[c] = b;
  2730. this._valueMapTb[c] = a
  2731. }
  2732. },
  2733. objectForKey: function(a) {
  2734. if (null == a) return null;
  2735. var b = this._keyMapTb,
  2736. c;
  2737. for (c in b)
  2738. if (b[c] === a) return this._valueMapTb[c];
  2739. return null
  2740. },
  2741. valueForKey: function(a) {
  2742. return this.objectForKey(a)
  2743. },
  2744. removeObjectForKey: function(a) {
  2745. if (null != a) {
  2746. var b = this._keyMapTb,
  2747. c;
  2748. for (c in b)
  2749. if (b[c] === a) {
  2750. delete this._valueMapTb[c];
  2751. delete b[c];
  2752. break
  2753. }
  2754. }
  2755. },
  2756. removeObjectsForKeys: function(a) {
  2757. if (null != a)
  2758. for (var b = 0; b < a.length; b++) this.removeObjectForKey(a[b])
  2759. },
  2760. allKeys: function() {
  2761. var a = [],
  2762. b = this._keyMapTb,
  2763. c;
  2764. for (c in b) a.push(b[c]);
  2765. return a
  2766. },
  2767. removeAllObjects: function() {
  2768. this._keyMapTb = {};
  2769. this._valueMapTb = {}
  2770. },
  2771. count: function() {
  2772. return this.allKeys().length
  2773. }
  2774. });
  2775. cc.FontDefinition = function(a) {
  2776. this.fontName = "Arial";
  2777. this.fontSize = 12;
  2778. this.textAlign = cc.TEXT_ALIGNMENT_CENTER;
  2779. this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  2780. this.fillStyle = cc.color(255, 255, 255, 255);
  2781. this.boundingHeight = this.boundingWidth = 0;
  2782. this.strokeEnabled = !1;
  2783. this.strokeStyle = cc.color(255, 255, 255, 255);
  2784. this.lineWidth = 1;
  2785. this.fontWeight = this.fontStyle = this.lineHeight = "normal";
  2786. this.shadowEnabled = !1;
  2787. this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0;
  2788. this.shadowOpacity = 1;
  2789. if (a && a instanceof Object)
  2790. for (var b in a) this[b] =
  2791. a[b]
  2792. };
  2793. cc.FontDefinition.prototype._getCanvasFontStr = function() {
  2794. return this.fontStyle + " " + this.fontWeight + " " + this.fontSize + "px/" + (this.lineHeight.charAt ? this.lineHeight : this.lineHeight + "px") + " '" + this.fontName + "'"
  2795. };
  2796. cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert(cc.isFunction(cc._tmp.WebGLColor), cc._LogInfos.MissingFile, "CCTypesWebGL.js"), cc._tmp.WebGLColor(), delete cc._tmp.WebGLColor);
  2797. cc.assert(cc.isFunction(cc._tmp.PrototypeColor), cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js");
  2798. cc._tmp.PrototypeColor();
  2799. delete cc._tmp.PrototypeColor;
  2800. cc.Touches = [];
  2801. cc.TouchesIntergerDict = {};
  2802. cc.DENSITYDPI_DEVICE = "device-dpi";
  2803. cc.DENSITYDPI_HIGH = "high-dpi";
  2804. cc.DENSITYDPI_MEDIUM = "medium-dpi";
  2805. cc.DENSITYDPI_LOW = "low-dpi";
  2806. cc.__BrowserGetter = {
  2807. init: function() {
  2808. this.html = document.getElementsByTagName("html")[0]
  2809. },
  2810. availWidth: function(a) {
  2811. return a && a !== this.html ? a.clientWidth : window.innerWidth
  2812. },
  2813. availHeight: function(a) {
  2814. return a && a !== this.html ? a.clientHeight : window.innerHeight
  2815. },
  2816. meta: {
  2817. width: "device-width",
  2818. "user-scalable": "no"
  2819. },
  2820. adaptationType: cc.sys.browserType
  2821. }; - 1 < window.navigator.userAgent.indexOf("OS 8_1_") && (cc.__BrowserGetter.adaptationType = cc.sys.BROWSER_TYPE_MIUI);
  2822. switch (cc.__BrowserGetter.adaptationType) {
  2823. case cc.sys.BROWSER_TYPE_SAFARI:
  2824. cc.__BrowserGetter.meta["minimal-ui"] = "true";
  2825. cc.__BrowserGetter.availWidth = function(a) {
  2826. return a.clientWidth
  2827. };
  2828. cc.__BrowserGetter.availHeight = function(a) {
  2829. return a.clientHeight
  2830. };
  2831. break;
  2832. case cc.sys.BROWSER_TYPE_CHROME:
  2833. cc.__BrowserGetter.__defineGetter__("target-densitydpi", function() {
  2834. return cc.view._targetDensityDPI
  2835. });
  2836. case cc.sys.BROWSER_TYPE_SOUGOU:
  2837. case cc.sys.BROWSER_TYPE_UC:
  2838. cc.__BrowserGetter.availWidth = function(a) {
  2839. return a.clientWidth
  2840. };
  2841. cc.__BrowserGetter.availHeight = function(a) {
  2842. return a.clientHeight
  2843. };
  2844. break;
  2845. case cc.sys.BROWSER_TYPE_MIUI:
  2846. cc.__BrowserGetter.init = function(a) {
  2847. if (!a.__resizeWithBrowserSize) {
  2848. var b = function() {
  2849. a.setDesignResolutionSize(a._designResolutionSize.width, a._designResolutionSize.height, a._resolutionPolicy);
  2850. window.removeEventListener("resize", b, !1)
  2851. };
  2852. window.addEventListener("resize", b, !1)
  2853. }
  2854. }
  2855. }
  2856. cc.EGLView = cc.Class.extend({
  2857. _delegate: null,
  2858. _frameSize: null,
  2859. _designResolutionSize: null,
  2860. _originalDesignResolutionSize: null,
  2861. _viewPortRect: null,
  2862. _visibleRect: null,
  2863. _retinaEnabled: !1,
  2864. _autoFullScreen: !0,
  2865. _devicePixelRatio: 1,
  2866. _viewName: "",
  2867. _resizeCallback: null,
  2868. _scaleX: 1,
  2869. _originalScaleX: 1,
  2870. _scaleY: 1,
  2871. _originalScaleY: 1,
  2872. _indexBitsUsed: 0,
  2873. _maxTouches: 5,
  2874. _resolutionPolicy: null,
  2875. _rpExactFit: null,
  2876. _rpShowAll: null,
  2877. _rpNoBorder: null,
  2878. _rpFixedHeight: null,
  2879. _rpFixedWidth: null,
  2880. _initialized: !1,
  2881. _captured: !1,
  2882. _wnd: null,
  2883. _hDC: null,
  2884. _hRC: null,
  2885. _supportTouch: !1,
  2886. _contentTranslateLeftTop: null,
  2887. _frame: null,
  2888. _frameZoomFactor: 1,
  2889. __resizeWithBrowserSize: !1,
  2890. _isAdjustViewPort: !0,
  2891. _targetDensityDPI: null,
  2892. ctor: function() {
  2893. var a = document,
  2894. b = cc.ContainerStrategy,
  2895. c = cc.ContentStrategy;
  2896. cc.__BrowserGetter.init(this);
  2897. this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode;
  2898. this._frameSize = cc.size(0, 0);
  2899. this._initFrameSize();
  2900. var a = cc._canvas.width,
  2901. d = cc._canvas.height;
  2902. this._designResolutionSize = cc.size(a, d);
  2903. this._originalDesignResolutionSize =
  2904. cc.size(a, d);
  2905. this._viewPortRect = cc.rect(0, 0, a, d);
  2906. this._visibleRect = cc.rect(0, 0, a, d);
  2907. this._contentTranslateLeftTop = {
  2908. left: 0,
  2909. top: 0
  2910. };
  2911. this._viewName = "Cocos2dHTML5";
  2912. a = cc.sys;
  2913. this.enableRetina(a.os === a.OS_IOS || a.os === a.OS_OSX);
  2914. cc.visibleRect && cc.visibleRect.init(this._visibleRect);
  2915. this._rpExactFit = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.EXACT_FIT);
  2916. this._rpShowAll = new cc.ResolutionPolicy(b.PROPORTION_TO_FRAME, c.SHOW_ALL);
  2917. this._rpNoBorder = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.NO_BORDER);
  2918. this._rpFixedHeight =
  2919. new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_HEIGHT);
  2920. this._rpFixedWidth = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_WIDTH);
  2921. this._hDC = cc._canvas;
  2922. this._hRC = cc._renderContext;
  2923. this._targetDensityDPI = cc.DENSITYDPI_HIGH
  2924. },
  2925. _resizeEvent: function() {
  2926. var a;
  2927. a = this.setDesignResolutionSize ? this : cc.view;
  2928. var b = a._frameSize.width,
  2929. c = a._frameSize.height;
  2930. a._initFrameSize();
  2931. if (a._frameSize.width !== b || a._frameSize.height !== c) a._resizeCallback && a._resizeCallback.call(), b = a._originalDesignResolutionSize.width, c =
  2932. a._originalDesignResolutionSize.height, 0 < b && a.setDesignResolutionSize(b, c, a._resolutionPolicy)
  2933. },
  2934. setTargetDensityDPI: function(a) {
  2935. this._targetDensityDPI = a;
  2936. this._setViewPortMeta()
  2937. },
  2938. getTargetDensityDPI: function() {
  2939. return this._targetDensityDPI
  2940. },
  2941. resizeWithBrowserSize: function(a) {
  2942. a ? this.__resizeWithBrowserSize || (this.__resizeWithBrowserSize = !0, cc._addEventListener(window, "resize", this._resizeEvent), cc._addEventListener(window, "orientationchange", this._resizeEvent)) : this.__resizeWithBrowserSize && (this.__resizeWithBrowserSize = !1, window.removeEventListener("resize", this._resizeEvent), window.removeEventListener("orientationchange", this._resizeEvent))
  2943. },
  2944. setResizeCallback: function(a) {
  2945. if (cc.isFunction(a) || null == a) this._resizeCallback = a
  2946. },
  2947. _initFrameSize: function() {
  2948. var a = this._frameSize;
  2949. a.width = cc.__BrowserGetter.availWidth(this._frame);
  2950. a.height = cc.__BrowserGetter.availHeight(this._frame)
  2951. },
  2952. _adjustSizeKeepCanvasSize: function() {
  2953. var a = this._originalDesignResolutionSize.width,
  2954. b = this._originalDesignResolutionSize.height;
  2955. 0 < a && this.setDesignResolutionSize(a,
  2956. b, this._resolutionPolicy)
  2957. },
  2958. _setViewPortMeta: function() {
  2959. if (this._isAdjustViewPort) {
  2960. var a = document.getElementById("cocosMetaElement");
  2961. a && document.head.removeChild(a);
  2962. var b, c = (a = document.getElementsByName("viewport")) ? a[0] : null,
  2963. d, a = cc.newElement("meta");
  2964. a.id = "cocosMetaElement";
  2965. a.name = "viewport";
  2966. a.content = "";
  2967. b = cc.__BrowserGetter.meta;
  2968. d = c ? c.content : "";
  2969. for (var e in b) RegExp(e).test(d) || (d += "," + e + "\x3d" + b[e]);
  2970. /^,/.test(d) && (d = d.substr(1));
  2971. a.content = d;
  2972. c && (c.content = d);
  2973. document.head.appendChild(a)
  2974. }
  2975. },
  2976. _setScaleXYForRenderTexture: function() {
  2977. var a =
  2978. cc.contentScaleFactor();
  2979. this._scaleY = this._scaleX = a
  2980. },
  2981. _resetScale: function() {
  2982. this._scaleX = this._originalScaleX;
  2983. this._scaleY = this._originalScaleY
  2984. },
  2985. _adjustSizeToBrowser: function() {},
  2986. initialize: function() {
  2987. this._initialized = !0
  2988. },
  2989. adjustViewPort: function(a) {
  2990. this._isAdjustViewPort = a
  2991. },
  2992. enableRetina: function(a) {
  2993. this._retinaEnabled = a ? !0 : !1
  2994. },
  2995. isRetinaEnabled: function() {
  2996. return this._retinaEnabled
  2997. },
  2998. enableAutoFullScreen: function(a) {
  2999. this._autoFullScreen = a ? !0 : !1
  3000. },
  3001. isAutoFullScreenEnabled: function() {
  3002. return this._autoFullScreen
  3003. },
  3004. end: function() {},
  3005. isOpenGLReady: function() {
  3006. return null !== this._hDC && null !== this._hRC
  3007. },
  3008. setFrameZoomFactor: function(a) {
  3009. this._frameZoomFactor = a;
  3010. this.centerWindow();
  3011. cc.director.setProjection(cc.director.getProjection())
  3012. },
  3013. swapBuffers: function() {},
  3014. setIMEKeyboardState: function(a) {},
  3015. setContentTranslateLeftTop: function(a, b) {
  3016. this._contentTranslateLeftTop = {
  3017. left: a,
  3018. top: b
  3019. }
  3020. },
  3021. getContentTranslateLeftTop: function() {
  3022. return this._contentTranslateLeftTop
  3023. },
  3024. getFrameSize: function() {
  3025. return cc.size(this._frameSize.width, this._frameSize.height)
  3026. },
  3027. setFrameSize: function(a, b) {
  3028. this._frameSize.width = a;
  3029. this._frameSize.height = b;
  3030. this._frame.style.width = a + "px";
  3031. this._frame.style.height = b + "px";
  3032. this._resizeEvent();
  3033. cc.director.setProjection(cc.director.getProjection())
  3034. },
  3035. centerWindow: function() {},
  3036. getVisibleSize: function() {
  3037. return cc.size(this._visibleRect.width, this._visibleRect.height)
  3038. },
  3039. getVisibleOrigin: function() {
  3040. return cc.p(this._visibleRect.x, this._visibleRect.y)
  3041. },
  3042. canSetContentScaleFactor: function() {
  3043. return !0
  3044. },
  3045. getResolutionPolicy: function() {
  3046. return this._resolutionPolicy
  3047. },
  3048. setResolutionPolicy: function(a) {
  3049. if (a instanceof cc.ResolutionPolicy) this._resolutionPolicy = a;
  3050. else {
  3051. var b = cc.ResolutionPolicy;
  3052. a === b.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit);
  3053. a === b.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll);
  3054. a === b.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder);
  3055. a === b.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight);
  3056. a === b.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth)
  3057. }
  3058. },
  3059. setDesignResolutionSize: function(a, b, c) {
  3060. if (0 < a || 0 < b)
  3061. if (this.setResolutionPolicy(c),
  3062. c = this._resolutionPolicy) {
  3063. c.preApply(this);
  3064. cc.sys.isMobile && this._setViewPortMeta();
  3065. this._initFrameSize();
  3066. this._originalDesignResolutionSize.width = this._designResolutionSize.width = a;
  3067. this._originalDesignResolutionSize.height = this._designResolutionSize.height = b;
  3068. var d = c.apply(this, this._designResolutionSize);
  3069. d.scale && 2 === d.scale.length && (this._scaleX = d.scale[0], this._scaleY = d.scale[1]);
  3070. d.viewport && (a = this._viewPortRect, b = this._visibleRect, d = d.viewport, a.x = d.x, a.y = d.y, a.width = d.width, a.height = d.height,
  3071. b.x = -a.x / this._scaleX, b.y = -a.y / this._scaleY, b.width = cc._canvas.width / this._scaleX, b.height = cc._canvas.height / this._scaleY, cc._renderContext.setOffset && cc._renderContext.setOffset(a.x, -a.y));
  3072. a = cc.director;
  3073. a._winSizeInPoints.width = this._designResolutionSize.width;
  3074. a._winSizeInPoints.height = this._designResolutionSize.height;
  3075. c.postApply(this);
  3076. cc.winSize.width = a._winSizeInPoints.width;
  3077. cc.winSize.height = a._winSizeInPoints.height;
  3078. cc._renderType === cc._RENDER_TYPE_WEBGL && (a._createStatsLabel(), a.setGLDefaultValues());
  3079. this._originalScaleX = this._scaleX;
  3080. this._originalScaleY = this._scaleY;
  3081. cc.DOM && cc.DOM._resetEGLViewDiv();
  3082. cc.visibleRect && cc.visibleRect.init(this._visibleRect)
  3083. } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2);
  3084. else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize)
  3085. },
  3086. getDesignResolutionSize: function() {
  3087. return cc.size(this._designResolutionSize.width, this._designResolutionSize.height)
  3088. },
  3089. setViewPortInPoints: function(a, b, c, d) {
  3090. var e = this._frameZoomFactor,
  3091. f = this._scaleX,
  3092. g = this._scaleY;
  3093. cc._renderContext.viewport(a *
  3094. f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  3095. },
  3096. setScissorInPoints: function(a, b, c, d) {
  3097. var e = this._frameZoomFactor,
  3098. f = this._scaleX,
  3099. g = this._scaleY;
  3100. cc._renderContext.scissor(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  3101. },
  3102. isScissorEnabled: function() {
  3103. var a = cc._renderContext;
  3104. return a.isEnabled(a.SCISSOR_TEST)
  3105. },
  3106. getScissorRect: function() {
  3107. var a = cc._renderContext,
  3108. b = this._scaleX,
  3109. c = this._scaleY,
  3110. a = a.getParameter(a.SCISSOR_BOX);
  3111. return cc.rect((a[0] - this._viewPortRect.x) /
  3112. b, (a[1] - this._viewPortRect.y) / c, a[2] / b, a[3] / c)
  3113. },
  3114. setViewName: function(a) {
  3115. null != a && 0 < a.length && (this._viewName = a)
  3116. },
  3117. getViewName: function() {
  3118. return this._viewName
  3119. },
  3120. getViewPortRect: function() {
  3121. return this._viewPortRect
  3122. },
  3123. getScaleX: function() {
  3124. return this._scaleX
  3125. },
  3126. getScaleY: function() {
  3127. return this._scaleY
  3128. },
  3129. getDevicePixelRatio: function() {
  3130. return this._devicePixelRatio
  3131. },
  3132. convertToLocationInView: function(a, b, c) {
  3133. return {
  3134. x: this._devicePixelRatio * (a - c.left),
  3135. y: this._devicePixelRatio * (c.top + c.height - b)
  3136. }
  3137. },
  3138. _convertMouseToLocationInView: function(a,
  3139. b) {
  3140. var c = this._viewPortRect;
  3141. a.x = (this._devicePixelRatio * (a.x - b.left) - c.x) / this._scaleX;
  3142. a.y = (this._devicePixelRatio * (b.top + b.height - a.y) - c.y) / this._scaleY
  3143. },
  3144. _convertTouchesWithScale: function(a) {
  3145. for (var b = this._viewPortRect, c = this._scaleX, d = this._scaleY, e, f, g, h = 0; h < a.length; h++) e = a[h], f = e._point, g = e._prevPoint, e._setPoint((f.x - b.x) / c, (f.y - b.y) / d), e._setPrevPoint((g.x - b.x) / c, (g.y - b.y) / d)
  3146. }
  3147. });
  3148. cc.EGLView._getInstance = function() {
  3149. this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize());
  3150. return this._instance
  3151. };
  3152. cc.ContainerStrategy = cc.Class.extend({
  3153. preApply: function(a) {},
  3154. apply: function(a, b) {},
  3155. postApply: function(a) {},
  3156. _setupContainer: function(a, b, c) {
  3157. var d = a._frame;
  3158. cc.view._autoFullScreen && cc.sys.isMobile && d === document.documentElement && cc.screen.autoFullScreen(d);
  3159. var d = cc._canvas,
  3160. e = cc.container;
  3161. e.style.width = d.style.width = b + "px";
  3162. e.style.height = d.style.height = c + "px";
  3163. e = a._devicePixelRatio = 1;
  3164. a.isRetinaEnabled() && (e = a._devicePixelRatio = window.devicePixelRatio || 1);
  3165. d.width = b * e;
  3166. d.height = c * e;
  3167. cc._renderContext.resetCache &&
  3168. cc._renderContext.resetCache();
  3169. a = document.body;
  3170. var f;
  3171. a && (f = a.style) && (f.paddingTop = f.paddingTop || "0px", f.paddingRight = f.paddingRight || "0px", f.paddingBottom = f.paddingBottom || "0px", f.paddingLeft = f.paddingLeft || "0px", f.borderTop = f.borderTop || "0px", f.borderRight = f.borderRight || "0px", f.borderBottom = f.borderBottom || "0px", f.borderLeft = f.borderLeft || "0px", f.marginTop = f.marginTop || "0px", f.marginRight = f.marginRight || "0px", f.marginBottom = f.marginBottom || "0px", f.marginLeft = f.marginLeft || "0px")
  3172. },
  3173. _fixContainer: function() {
  3174. document.body.insertBefore(cc.container,
  3175. document.body.firstChild);
  3176. var a = document.body.style;
  3177. a.width = window.innerWidth + "px";
  3178. a.height = window.innerHeight + "px";
  3179. a.overflow = "hidden";
  3180. a = cc.container.style;
  3181. a.position = "fixed";
  3182. a.left = a.top = "0px";
  3183. document.body.scrollTop = 0
  3184. }
  3185. });
  3186. cc.ContentStrategy = cc.Class.extend({
  3187. _result: {
  3188. scale: [1, 1],
  3189. viewport: null
  3190. },
  3191. _buildResult: function(a, b, c, d, e, f) {
  3192. 2 > Math.abs(a - c) && (c = a);
  3193. 2 > Math.abs(b - d) && (d = b);
  3194. a = cc.rect(Math.round((a - c) / 2), Math.round((b - d) / 2), c, d);
  3195. this._result.scale = [e, f];
  3196. this._result.viewport = a;
  3197. return this._result
  3198. },
  3199. preApply: function(a) {},
  3200. apply: function(a, b) {
  3201. return {
  3202. scale: [1, 1]
  3203. }
  3204. },
  3205. postApply: function(a) {}
  3206. });
  3207. (function() {
  3208. var a = cc.ContainerStrategy.extend({
  3209. apply: function(a) {
  3210. this._setupContainer(a, a._frameSize.width, a._frameSize.height)
  3211. }
  3212. }),
  3213. b = cc.ContainerStrategy.extend({
  3214. apply: function(a, b) {
  3215. var c = a._frameSize.width,
  3216. d = a._frameSize.height,
  3217. e = cc.container.style,
  3218. n = b.width,
  3219. p = b.height,
  3220. t = c / n,
  3221. r = d / p,
  3222. u, s;
  3223. t < r ? (u = c, s = p * t) : (u = n * r, s = d);
  3224. n = Math.round((c - u) / 2);
  3225. s = Math.round((d - s) / 2);
  3226. this._setupContainer(a, c - 2 * n, d - 2 * s);
  3227. e.marginLeft = n + "px";
  3228. e.marginRight = n + "px";
  3229. e.marginTop = s + "px";
  3230. e.marginBottom = s + "px"
  3231. }
  3232. });
  3233. a.extend({
  3234. preApply: function(a) {
  3235. this._super(a);
  3236. a._frame = document.documentElement
  3237. },
  3238. apply: function(a) {
  3239. this._super(a);
  3240. this._fixContainer()
  3241. }
  3242. });
  3243. b.extend({
  3244. preApply: function(a) {
  3245. this._super(a);
  3246. a._frame = document.documentElement
  3247. },
  3248. apply: function(a, b) {
  3249. this._super(a, b);
  3250. this._fixContainer()
  3251. }
  3252. });
  3253. var c = cc.ContainerStrategy.extend({
  3254. apply: function(a) {
  3255. this._setupContainer(a, cc._canvas.width, cc._canvas.height)
  3256. }
  3257. });
  3258. cc.ContainerStrategy.EQUAL_TO_FRAME = new a;
  3259. cc.ContainerStrategy.PROPORTION_TO_FRAME = new b;
  3260. cc.ContainerStrategy.ORIGINAL_CONTAINER = new c;
  3261. var a = cc.ContentStrategy.extend({
  3262. apply: function(a,
  3263. b) {
  3264. var c = cc._canvas.width,
  3265. d = cc._canvas.height;
  3266. return this._buildResult(c, d, c, d, c / b.width, d / b.height)
  3267. }
  3268. }),
  3269. b = cc.ContentStrategy.extend({
  3270. apply: function(a, b) {
  3271. var c = cc._canvas.width,
  3272. d = cc._canvas.height,
  3273. e = b.width,
  3274. n = b.height,
  3275. p = c / e,
  3276. t = d / n,
  3277. r = 0,
  3278. u, s;
  3279. p < t ? (r = p, u = c, s = n * r) : (r = t, u = e * r, s = d);
  3280. return this._buildResult(c, d, u, s, r, r)
  3281. }
  3282. }),
  3283. c = cc.ContentStrategy.extend({
  3284. apply: function(a, b) {
  3285. var c = cc._canvas.width,
  3286. d = cc._canvas.height,
  3287. e = b.width,
  3288. n = b.height,
  3289. p = c / e,
  3290. t = d / n,
  3291. r, u, s;
  3292. p < t ? (r = t, u = e * r, s = d) : (r = p, u = c, s = n * r);
  3293. return this._buildResult(c,
  3294. d, u, s, r, r)
  3295. }
  3296. }),
  3297. d = cc.ContentStrategy.extend({
  3298. apply: function(a, b) {
  3299. var c = cc._canvas.width,
  3300. d = cc._canvas.height,
  3301. e = d / b.height;
  3302. return this._buildResult(c, d, c, d, e, e)
  3303. },
  3304. postApply: function(a) {
  3305. cc.director._winSizeInPoints = a.getVisibleSize()
  3306. }
  3307. }),
  3308. e = cc.ContentStrategy.extend({
  3309. apply: function(a, b) {
  3310. var c = cc._canvas.width,
  3311. d = cc._canvas.height,
  3312. e = c / b.width;
  3313. return this._buildResult(c, d, c, d, e, e)
  3314. },
  3315. postApply: function(a) {
  3316. cc.director._winSizeInPoints = a.getVisibleSize()
  3317. }
  3318. });
  3319. cc.ContentStrategy.EXACT_FIT = new a;
  3320. cc.ContentStrategy.SHOW_ALL =
  3321. new b;
  3322. cc.ContentStrategy.NO_BORDER = new c;
  3323. cc.ContentStrategy.FIXED_HEIGHT = new d;
  3324. cc.ContentStrategy.FIXED_WIDTH = new e
  3325. })();
  3326. cc.ResolutionPolicy = cc.Class.extend({
  3327. _containerStrategy: null,
  3328. _contentStrategy: null,
  3329. ctor: function(a, b) {
  3330. this.setContainerStrategy(a);
  3331. this.setContentStrategy(b)
  3332. },
  3333. preApply: function(a) {
  3334. this._containerStrategy.preApply(a);
  3335. this._contentStrategy.preApply(a)
  3336. },
  3337. apply: function(a, b) {
  3338. this._containerStrategy.apply(a, b);
  3339. return this._contentStrategy.apply(a, b)
  3340. },
  3341. postApply: function(a) {
  3342. this._containerStrategy.postApply(a);
  3343. this._contentStrategy.postApply(a)
  3344. },
  3345. setContainerStrategy: function(a) {
  3346. a instanceof cc.ContainerStrategy &&
  3347. (this._containerStrategy = a)
  3348. },
  3349. setContentStrategy: function(a) {
  3350. a instanceof cc.ContentStrategy && (this._contentStrategy = a)
  3351. }
  3352. });
  3353. cc.ResolutionPolicy.EXACT_FIT = 0;
  3354. cc.ResolutionPolicy.NO_BORDER = 1;
  3355. cc.ResolutionPolicy.SHOW_ALL = 2;
  3356. cc.ResolutionPolicy.FIXED_HEIGHT = 3;
  3357. cc.ResolutionPolicy.FIXED_WIDTH = 4;
  3358. cc.ResolutionPolicy.UNKNOWN = 5;
  3359. cc.screen = {
  3360. _supportsFullScreen: !1,
  3361. _preOnFullScreenChange: null,
  3362. _touchEvent: "",
  3363. _fn: null,
  3364. _fnMap: [
  3365. ["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement"],
  3366. ["requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement"],
  3367. ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"],
  3368. ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen",
  3369. "mozFullScreenElement"
  3370. ],
  3371. ["msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement"]
  3372. ],
  3373. init: function() {
  3374. this._fn = {};
  3375. var a, b, c = this._fnMap,
  3376. d;
  3377. a = 0;
  3378. for (l = c.length; a < l; a++)
  3379. if ((b = c[a]) && b[1] in document) {
  3380. a = 0;
  3381. for (d = b.length; a < d; a++) this._fn[c[0][a]] = b[a];
  3382. break
  3383. }
  3384. this._supportsFullScreen = "undefined" !== typeof this._fn.requestFullscreen;
  3385. this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown"
  3386. },
  3387. fullScreen: function() {
  3388. return this._supportsFullScreen && document[this._fn.fullscreenElement]
  3389. },
  3390. requestFullScreen: function(a, b) {
  3391. if (this._supportsFullScreen) {
  3392. a = a || document.documentElement;
  3393. if (b) {
  3394. var c = this._fn.fullscreenchange;
  3395. this._preOnFullScreenChange && document.removeEventListener(c, this._preOnFullScreenChange);
  3396. this._preOnFullScreenChange = b;
  3397. cc._addEventListener(document, c, b, !1)
  3398. }
  3399. return a[this._fn.requestFullscreen]()
  3400. }
  3401. },
  3402. exitFullScreen: function() {
  3403. return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : !0
  3404. },
  3405. autoFullScreen: function(a, b) {
  3406. function c() {
  3407. e.requestFullScreen(a, b);
  3408. d.removeEventListener(e._touchEvent,
  3409. c)
  3410. }
  3411. a = a || document.body;
  3412. var d = cc._canvas || a,
  3413. e = this;
  3414. this.requestFullScreen(a, b);
  3415. cc._addEventListener(d, this._touchEvent, c)
  3416. }
  3417. };
  3418. cc.screen.init();
  3419. cc.visibleRect = {
  3420. topLeft: cc.p(0, 0),
  3421. topRight: cc.p(0, 0),
  3422. top: cc.p(0, 0),
  3423. bottomLeft: cc.p(0, 0),
  3424. bottomRight: cc.p(0, 0),
  3425. bottom: cc.p(0, 0),
  3426. center: cc.p(0, 0),
  3427. left: cc.p(0, 0),
  3428. right: cc.p(0, 0),
  3429. width: 0,
  3430. height: 0,
  3431. init: function(a) {
  3432. var b = this.width = a.width,
  3433. c = this.height = a.height,
  3434. d = a.x;
  3435. a = a.y;
  3436. var e = a + c,
  3437. f = d + b;
  3438. this.topLeft.x = d;
  3439. this.topLeft.y = e;
  3440. this.topRight.x = f;
  3441. this.topRight.y = e;
  3442. this.top.x = d + b / 2;
  3443. this.top.y = e;
  3444. this.bottomLeft.x = d;
  3445. this.bottomLeft.y = a;
  3446. this.bottomRight.x = f;
  3447. this.bottomRight.y = a;
  3448. this.bottom.x = d + b / 2;
  3449. this.bottom.y =
  3450. a;
  3451. this.center.x = d + b / 2;
  3452. this.center.y = a + c / 2;
  3453. this.left.x = d;
  3454. this.left.y = a + c / 2;
  3455. this.right.x = f;
  3456. this.right.y = a + c / 2
  3457. }
  3458. };
  3459. cc.UIInterfaceOrientationLandscapeLeft = -90;
  3460. cc.UIInterfaceOrientationLandscapeRight = 90;
  3461. cc.UIInterfaceOrientationPortraitUpsideDown = 180;
  3462. cc.UIInterfaceOrientationPortrait = 0;
  3463. cc.inputManager = {
  3464. _mousePressed: !1,
  3465. _isRegisterEvent: !1,
  3466. _preTouchPoint: cc.p(0, 0),
  3467. _prevMousePoint: cc.p(0, 0),
  3468. _preTouchPool: [],
  3469. _preTouchPoolPointer: 0,
  3470. _touches: [],
  3471. _touchesIntegerDict: {},
  3472. _indexBitsUsed: 0,
  3473. _maxTouches: 5,
  3474. _accelEnabled: !1,
  3475. _accelInterval: 1 / 30,
  3476. _accelMinus: 1,
  3477. _accelCurTime: 0,
  3478. _acceleration: null,
  3479. _accelDeviceEvent: null,
  3480. _getUnUsedIndex: function() {
  3481. for (var a = this._indexBitsUsed, b = 0; b < this._maxTouches; b++) {
  3482. if (!(a & 1)) return this._indexBitsUsed |= 1 << b, b;
  3483. a >>= 1
  3484. }
  3485. return -1
  3486. },
  3487. _removeUsedIndexBit: function(a) {
  3488. 0 > a ||
  3489. a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a)
  3490. },
  3491. _glView: null,
  3492. handleTouchesBegin: function(a) {
  3493. for (var b, c, d, e = [], f = this._touchesIntegerDict, g = 0, h = a.length; g < h; g++)
  3494. if (b = a[g], d = b.getID(), c = f[d], null == c) {
  3495. var k = this._getUnUsedIndex(); - 1 === k ? cc.log(cc._LogInfos.inputManager_handleTouchesBegin, k) : (c = this._touches[k] = new cc.Touch(b._point.x, b._point.y, b.getID()), c._setPrevPoint(b._prevPoint), f[d] = k, e.push(c))
  3496. }
  3497. 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode =
  3498. cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a))
  3499. },
  3500. handleTouchesMove: function(a) {
  3501. for (var b, c, d = [], e = this._touches, f = 0, g = a.length; f < g; f++) b = a[f], c = b.getID(), c = this._touchesIntegerDict[c], null != c && e[c] && (e[c]._setPoint(b._point), e[c]._setPrevPoint(b._prevPoint), d.push(e[c]));
  3502. 0 < d.length && (this._glView._convertTouchesWithScale(d), a = new cc.EventTouch(d), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a))
  3503. },
  3504. handleTouchesEnd: function(a) {
  3505. a = this.getSetOfTouchesEndOrCancel(a);
  3506. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED, cc.eventManager.dispatchEvent(a))
  3507. },
  3508. handleTouchesCancel: function(a) {
  3509. a = this.getSetOfTouchesEndOrCancel(a);
  3510. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a))
  3511. },
  3512. getSetOfTouchesEndOrCancel: function(a) {
  3513. for (var b, c, d, e = [], f = this._touches, g = this._touchesIntegerDict, h = 0, k = a.length; h <
  3514. k; h++) b = a[h], d = b.getID(), c = g[d], null != c && f[c] && (f[c]._setPoint(b._point), f[c]._setPrevPoint(b._prevPoint), e.push(f[c]), this._removeUsedIndexBit(c), delete g[d]);
  3515. return e
  3516. },
  3517. getHTMLElementPosition: function(a) {
  3518. var b = document.documentElement,
  3519. c = window,
  3520. d = null,
  3521. d = cc.isFunction(a.getBoundingClientRect) ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? {
  3522. left: 0,
  3523. top: 0,
  3524. width: a.width,
  3525. height: a.height
  3526. } : {
  3527. left: 0,
  3528. top: 0,
  3529. width: parseInt(a.style.width),
  3530. height: parseInt(a.style.height)
  3531. };
  3532. return {
  3533. left: d.left + c.pageXOffset -
  3534. b.clientLeft,
  3535. top: d.top + c.pageYOffset - b.clientTop,
  3536. width: d.width,
  3537. height: d.height
  3538. }
  3539. },
  3540. getPreTouch: function(a) {
  3541. for (var b = null, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--)
  3542. if (c[e].getID() === d) {
  3543. b = c[e];
  3544. break
  3545. }
  3546. b || (b = a);
  3547. return b
  3548. },
  3549. setPreTouch: function(a) {
  3550. for (var b = !1, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--)
  3551. if (c[e].getID() === d) {
  3552. c[e] = a;
  3553. b = !0;
  3554. break
  3555. }
  3556. b || (50 >= c.length ? c.push(a) : (c[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50))
  3557. },
  3558. getTouchByXY: function(a,
  3559. b, c) {
  3560. var d = this._preTouchPoint;
  3561. a = this._glView.convertToLocationInView(a, b, c);
  3562. b = new cc.Touch(a.x, a.y);
  3563. b._setPrevPoint(d.x, d.y);
  3564. d.x = a.x;
  3565. d.y = a.y;
  3566. return b
  3567. },
  3568. getMouseEvent: function(a, b, c) {
  3569. var d = this._prevMousePoint;
  3570. this._glView._convertMouseToLocationInView(a, b);
  3571. b = new cc.EventMouse(c);
  3572. b.setLocation(a.x, a.y);
  3573. b._setPrevCursor(d.x, d.y);
  3574. d.x = a.x;
  3575. d.y = a.y;
  3576. return b
  3577. },
  3578. getPointByEvent: function(a, b) {
  3579. if (null != a.pageX) return {
  3580. x: a.pageX,
  3581. y: a.pageY
  3582. };
  3583. b.left -= document.body.scrollLeft;
  3584. b.top -= document.body.scrollTop;
  3585. return {
  3586. x: a.clientX,
  3587. y: a.clientY
  3588. }
  3589. },
  3590. getTouchesByEvent: function(a, b) {
  3591. for (var c = [], d = this._glView, e, f, g = this._preTouchPoint, h = a.changedTouches.length, k = 0; k < h; k++)
  3592. if (e = a.changedTouches[k]) {
  3593. var m;
  3594. m = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? d.convertToLocationInView(e.pageX, e.pageY, b) : d.convertToLocationInView(e.clientX, e.clientY, b);
  3595. null != e.identifier ? (e = new cc.Touch(m.x, m.y, e.identifier), f = this.getPreTouch(e).getLocation(), e._setPrevPoint(f.x, f.y), this.setPreTouch(e)) : (e = new cc.Touch(m.x, m.y), e._setPrevPoint(g.x, g.y));
  3596. g.x = m.x;
  3597. g.y = m.y;
  3598. c.push(e)
  3599. }
  3600. return c
  3601. },
  3602. registerSystemEvent: function(a) {
  3603. if (!this._isRegisterEvent) {
  3604. this._glView = cc.view;
  3605. var b = this,
  3606. c = "mouse" in cc.sys.capabilities,
  3607. d = "touches" in cc.sys.capabilities,
  3608. e = !1;
  3609. cc.sys.isMobile && (e = !0);
  3610. c && (cc._addEventListener(window, "mousedown", function() {
  3611. b._mousePressed = !0
  3612. }, !1), cc._addEventListener(window, "mouseup", function(c) {
  3613. if (!e) {
  3614. var d = b._mousePressed;
  3615. b._mousePressed = !1;
  3616. if (d) {
  3617. var d = b.getHTMLElementPosition(a),
  3618. f = b.getPointByEvent(c, d);
  3619. cc.rectContainsPoint(new cc.Rect(d.left,
  3620. d.top, d.width, d.height), f) || (b.handleTouchesEnd([b.getTouchByXY(f.x, f.y, d)]), d = b.getMouseEvent(f, d, cc.EventMouse.UP), d.setButton(c.button), cc.eventManager.dispatchEvent(d))
  3621. }
  3622. }
  3623. }, !1), cc._addEventListener(a, "mousedown", function(c) {
  3624. if (!e) {
  3625. b._mousePressed = !0;
  3626. var d = b.getHTMLElementPosition(a),
  3627. f = b.getPointByEvent(c, d);
  3628. b.handleTouchesBegin([b.getTouchByXY(f.x, f.y, d)]);
  3629. d = b.getMouseEvent(f, d, cc.EventMouse.DOWN);
  3630. d.setButton(c.button);
  3631. cc.eventManager.dispatchEvent(d);
  3632. c.stopPropagation();
  3633. c.preventDefault();
  3634. a.focus()
  3635. }
  3636. }, !1), cc._addEventListener(a, "mouseup", function(c) {
  3637. if (!e) {
  3638. b._mousePressed = !1;
  3639. var d = b.getHTMLElementPosition(a),
  3640. f = b.getPointByEvent(c, d);
  3641. b.handleTouchesEnd([b.getTouchByXY(f.x, f.y, d)]);
  3642. d = b.getMouseEvent(f, d, cc.EventMouse.UP);
  3643. d.setButton(c.button);
  3644. cc.eventManager.dispatchEvent(d);
  3645. c.stopPropagation();
  3646. c.preventDefault()
  3647. }
  3648. }, !1), cc._addEventListener(a, "mousemove", function(c) {
  3649. if (!e) {
  3650. var d = b.getHTMLElementPosition(a),
  3651. f = b.getPointByEvent(c, d);
  3652. b.handleTouchesMove([b.getTouchByXY(f.x, f.y, d)]);
  3653. d = b.getMouseEvent(f,
  3654. d, cc.EventMouse.MOVE);
  3655. b._mousePressed ? d.setButton(c.button) : d.setButton(null);
  3656. cc.eventManager.dispatchEvent(d);
  3657. c.stopPropagation();
  3658. c.preventDefault()
  3659. }
  3660. }, !1), cc._addEventListener(a, "mousewheel", function(c) {
  3661. var d = b.getHTMLElementPosition(a),
  3662. e = b.getPointByEvent(c, d),
  3663. d = b.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  3664. d.setButton(c.button);
  3665. d.setScrollData(0, c.wheelDelta);
  3666. cc.eventManager.dispatchEvent(d);
  3667. c.stopPropagation();
  3668. c.preventDefault()
  3669. }, !1), cc._addEventListener(a, "DOMMouseScroll", function(c) {
  3670. var d = b.getHTMLElementPosition(a),
  3671. e = b.getPointByEvent(c, d),
  3672. d = b.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  3673. d.setButton(c.button);
  3674. d.setScrollData(0, -120 * c.detail);
  3675. cc.eventManager.dispatchEvent(d);
  3676. c.stopPropagation();
  3677. c.preventDefault()
  3678. }, !1));
  3679. if (window.navigator.msPointerEnabled) {
  3680. var c = {
  3681. MSPointerDown: b.handleTouchesBegin,
  3682. MSPointerMove: b.handleTouchesMove,
  3683. MSPointerUp: b.handleTouchesEnd,
  3684. MSPointerCancel: b.handleTouchesCancel
  3685. },
  3686. f;
  3687. for (f in c)(function(c, d) {
  3688. cc._addEventListener(a, c, function(c) {
  3689. var e = b.getHTMLElementPosition(a);
  3690. e.left -= document.documentElement.scrollLeft;
  3691. e.top -= document.documentElement.scrollTop;
  3692. d.call(b, [b.getTouchByXY(c.clientX, c.clientY, e)]);
  3693. c.stopPropagation()
  3694. }, !1)
  3695. })(f, c[f])
  3696. }
  3697. d && (cc._addEventListener(a, "touchstart", function(c) {
  3698. if (c.changedTouches) {
  3699. var d = b.getHTMLElementPosition(a);
  3700. d.left -= document.body.scrollLeft;
  3701. d.top -= document.body.scrollTop;
  3702. b.handleTouchesBegin(b.getTouchesByEvent(c, d));
  3703. c.stopPropagation();
  3704. c.preventDefault();
  3705. a.focus()
  3706. }
  3707. }, !1), cc._addEventListener(a, "touchmove", function(c) {
  3708. if (c.changedTouches) {
  3709. var d = b.getHTMLElementPosition(a);
  3710. d.left -= document.body.scrollLeft;
  3711. d.top -= document.body.scrollTop;
  3712. b.handleTouchesMove(b.getTouchesByEvent(c, d));
  3713. c.stopPropagation();
  3714. c.preventDefault()
  3715. }
  3716. }, !1), cc._addEventListener(a, "touchend", function(c) {
  3717. if (c.changedTouches) {
  3718. var d = b.getHTMLElementPosition(a);
  3719. d.left -= document.body.scrollLeft;
  3720. d.top -= document.body.scrollTop;
  3721. b.handleTouchesEnd(b.getTouchesByEvent(c, d));
  3722. c.stopPropagation();
  3723. c.preventDefault()
  3724. }
  3725. }, !1), cc._addEventListener(a, "touchcancel", function(c) {
  3726. if (c.changedTouches) {
  3727. var d = b.getHTMLElementPosition(a);
  3728. d.left -= document.body.scrollLeft;
  3729. d.top -= document.body.scrollTop;
  3730. b.handleTouchesCancel(b.getTouchesByEvent(c, d));
  3731. c.stopPropagation();
  3732. c.preventDefault()
  3733. }
  3734. }, !1));
  3735. this._registerKeyboardEvent();
  3736. this._registerAccelerometerEvent();
  3737. this._isRegisterEvent = !0
  3738. }
  3739. },
  3740. _registerKeyboardEvent: function() {},
  3741. _registerAccelerometerEvent: function() {},
  3742. update: function(a) {
  3743. this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));
  3744. this._accelCurTime += a
  3745. }
  3746. };
  3747. var _p = cc.inputManager;
  3748. _p.setAccelerometerEnabled = function(a) {
  3749. this._accelEnabled !== a && (this._accelEnabled = a, a = cc.director.getScheduler(), this._accelCurTime = 0, a.scheduleUpdate(this))
  3750. };
  3751. _p.setAccelerometerInterval = function(a) {
  3752. this._accelInterval !== a && (this._accelInterval = a)
  3753. };
  3754. _p._registerKeyboardEvent = function() {
  3755. cc._addEventListener(cc._canvas, "keydown", function(a) {
  3756. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !0));
  3757. a.stopPropagation();
  3758. a.preventDefault()
  3759. }, !1);
  3760. cc._addEventListener(cc._canvas, "keyup", function(a) {
  3761. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !1));
  3762. a.stopPropagation();
  3763. a.preventDefault()
  3764. }, !1)
  3765. };
  3766. _p._registerAccelerometerEvent = function() {
  3767. var a = window;
  3768. this._acceleration = new cc.Acceleration;
  3769. this._accelDeviceEvent = a.DeviceMotionEvent || a.DeviceOrientationEvent;
  3770. cc.sys.browserType === cc.sys.BROWSER_TYPE_MOBILE_QQ && (this._accelDeviceEvent = window.DeviceOrientationEvent);
  3771. var b = this._accelDeviceEvent === a.DeviceMotionEvent ? "devicemotion" : "deviceorientation",
  3772. c = navigator.userAgent;
  3773. if (/Android/.test(c) || /Adr/.test(c) && cc.sys.browserType === cc.BROWSER_TYPE_UC) this._minus = -1;
  3774. cc._addEventListener(a, b, this.didAccelerate.bind(this), !1)
  3775. };
  3776. _p.didAccelerate = function(a) {
  3777. var b = window;
  3778. if (this._accelEnabled) {
  3779. var c = this._acceleration,
  3780. d, e, f;
  3781. this._accelDeviceEvent === window.DeviceMotionEvent ? (f = a.accelerationIncludingGravity, d = this._accelMinus * f.x * 0.1, e = this._accelMinus * f.y * 0.1, f = 0.1 * f.z) : (d = a.gamma / 90 * 0.981, e = 0.981 * -(a.beta / 90), f = a.alpha / 90 * 0.981);
  3782. cc.sys.os === cc.sys.OS_ANDROID ? (c.x = -d, c.y = -e) : (c.x = d, c.y = e);
  3783. c.z = f;
  3784. c.timestamp = a.timeStamp || Date.now();
  3785. a = c.x;
  3786. b.orientation === cc.UIInterfaceOrientationLandscapeRight ? (c.x = -c.y, c.y = a) : b.orientation === cc.UIInterfaceOrientationLandscapeLeft ?
  3787. (c.x = c.y, c.y = -a) : b.orientation === cc.UIInterfaceOrientationPortraitUpsideDown && (c.x = -c.x, c.y = -c.y)
  3788. }
  3789. };
  3790. delete _p;
  3791. cc.AffineTransform = function(a, b, c, d, e, f) {
  3792. this.a = a;
  3793. this.b = b;
  3794. this.c = c;
  3795. this.d = d;
  3796. this.tx = e;
  3797. this.ty = f
  3798. };
  3799. cc.affineTransformMake = function(a, b, c, d, e, f) {
  3800. return {
  3801. a: a,
  3802. b: b,
  3803. c: c,
  3804. d: d,
  3805. tx: e,
  3806. ty: f
  3807. }
  3808. };
  3809. cc.pointApplyAffineTransform = function(a, b, c) {
  3810. var d;
  3811. void 0 === c ? (c = b, d = a.x, a = a.y) : (d = a, a = b);
  3812. return {
  3813. x: c.a * d + c.c * a + c.tx,
  3814. y: c.b * d + c.d * a + c.ty
  3815. }
  3816. };
  3817. cc._pointApplyAffineTransform = function(a, b, c) {
  3818. return cc.pointApplyAffineTransform(a, b, c)
  3819. };
  3820. cc.sizeApplyAffineTransform = function(a, b) {
  3821. return {
  3822. width: b.a * a.width + b.c * a.height,
  3823. height: b.b * a.width + b.d * a.height
  3824. }
  3825. };
  3826. cc.affineTransformMakeIdentity = function() {
  3827. return {
  3828. a: 1,
  3829. b: 0,
  3830. c: 0,
  3831. d: 1,
  3832. tx: 0,
  3833. ty: 0
  3834. }
  3835. };
  3836. cc.affineTransformIdentity = function() {
  3837. return {
  3838. a: 1,
  3839. b: 0,
  3840. c: 0,
  3841. d: 1,
  3842. tx: 0,
  3843. ty: 0
  3844. }
  3845. };
  3846. cc.rectApplyAffineTransform = function(a, b) {
  3847. var c = cc.rectGetMinY(a),
  3848. d = cc.rectGetMinX(a),
  3849. e = cc.rectGetMaxX(a),
  3850. f = cc.rectGetMaxY(a),
  3851. g = cc.pointApplyAffineTransform(d, c, b),
  3852. c = cc.pointApplyAffineTransform(e, c, b),
  3853. d = cc.pointApplyAffineTransform(d, f, b),
  3854. h = cc.pointApplyAffineTransform(e, f, b),
  3855. e = Math.min(g.x, c.x, d.x, h.x),
  3856. f = Math.max(g.x, c.x, d.x, h.x),
  3857. k = Math.min(g.y, c.y, d.y, h.y),
  3858. g = Math.max(g.y, c.y, d.y, h.y);
  3859. return cc.rect(e, k, f - e, g - k)
  3860. };
  3861. cc._rectApplyAffineTransformIn = function(a, b) {
  3862. var c = cc.rectGetMinY(a),
  3863. d = cc.rectGetMinX(a),
  3864. e = cc.rectGetMaxX(a),
  3865. f = cc.rectGetMaxY(a),
  3866. g = cc.pointApplyAffineTransform(d, c, b),
  3867. c = cc.pointApplyAffineTransform(e, c, b),
  3868. d = cc.pointApplyAffineTransform(d, f, b),
  3869. h = cc.pointApplyAffineTransform(e, f, b),
  3870. e = Math.min(g.x, c.x, d.x, h.x),
  3871. f = Math.max(g.x, c.x, d.x, h.x),
  3872. k = Math.min(g.y, c.y, d.y, h.y),
  3873. g = Math.max(g.y, c.y, d.y, h.y);
  3874. a.x = e;
  3875. a.y = k;
  3876. a.width = f - e;
  3877. a.height = g - k;
  3878. return a
  3879. };
  3880. cc.affineTransformTranslate = function(a, b, c) {
  3881. return {
  3882. a: a.a,
  3883. b: a.b,
  3884. c: a.c,
  3885. d: a.d,
  3886. tx: a.tx + a.a * b + a.c * c,
  3887. ty: a.ty + a.b * b + a.d * c
  3888. }
  3889. };
  3890. cc.affineTransformScale = function(a, b, c) {
  3891. return {
  3892. a: a.a * b,
  3893. b: a.b * b,
  3894. c: a.c * c,
  3895. d: a.d * c,
  3896. tx: a.tx,
  3897. ty: a.ty
  3898. }
  3899. };
  3900. cc.affineTransformRotate = function(a, b) {
  3901. var c = Math.sin(b),
  3902. d = Math.cos(b);
  3903. return {
  3904. a: a.a * d + a.c * c,
  3905. b: a.b * d + a.d * c,
  3906. c: a.c * d - a.a * c,
  3907. d: a.d * d - a.b * c,
  3908. tx: a.tx,
  3909. ty: a.ty
  3910. }
  3911. };
  3912. cc.affineTransformConcat = function(a, b) {
  3913. return {
  3914. a: a.a * b.a + a.b * b.c,
  3915. b: a.a * b.b + a.b * b.d,
  3916. c: a.c * b.a + a.d * b.c,
  3917. d: a.c * b.b + a.d * b.d,
  3918. tx: a.tx * b.a + a.ty * b.c + b.tx,
  3919. ty: a.tx * b.b + a.ty * b.d + b.ty
  3920. }
  3921. };
  3922. cc.affineTransformEqualToTransform = function(a, b) {
  3923. return a.a === b.a && a.b === b.b && a.c === b.c && a.d === b.d && a.tx === b.tx && a.ty === b.ty
  3924. };
  3925. cc.affineTransformInvert = function(a) {
  3926. var b = 1 / (a.a * a.d - a.b * a.c);
  3927. return {
  3928. a: b * a.d,
  3929. b: -b * a.b,
  3930. c: -b * a.c,
  3931. d: b * a.a,
  3932. tx: b * (a.c * a.ty - a.d * a.tx),
  3933. ty: b * (a.b * a.tx - a.a * a.ty)
  3934. }
  3935. };
  3936. cc.POINT_EPSILON = parseFloat("1.192092896e-07F");
  3937. cc.pNeg = function(a) {
  3938. return cc.p(-a.x, -a.y)
  3939. };
  3940. cc.pAdd = function(a, b) {
  3941. return cc.p(a.x + b.x, a.y + b.y)
  3942. };
  3943. cc.pSub = function(a, b) {
  3944. return cc.p(a.x - b.x, a.y - b.y)
  3945. };
  3946. cc.pMult = function(a, b) {
  3947. return cc.p(a.x * b, a.y * b)
  3948. };
  3949. cc.pMidpoint = function(a, b) {
  3950. return cc.pMult(cc.pAdd(a, b), 0.5)
  3951. };
  3952. cc.pDot = function(a, b) {
  3953. return a.x * b.x + a.y * b.y
  3954. };
  3955. cc.pCross = function(a, b) {
  3956. return a.x * b.y - a.y * b.x
  3957. };
  3958. cc.pPerp = function(a) {
  3959. return cc.p(-a.y, a.x)
  3960. };
  3961. cc.pRPerp = function(a) {
  3962. return cc.p(a.y, -a.x)
  3963. };
  3964. cc.pProject = function(a, b) {
  3965. return cc.pMult(b, cc.pDot(a, b) / cc.pDot(b, b))
  3966. };
  3967. cc.pRotate = function(a, b) {
  3968. return cc.p(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x)
  3969. };
  3970. cc.pUnrotate = function(a, b) {
  3971. return cc.p(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y)
  3972. };
  3973. cc.pLengthSQ = function(a) {
  3974. return cc.pDot(a, a)
  3975. };
  3976. cc.pDistanceSQ = function(a, b) {
  3977. return cc.pLengthSQ(cc.pSub(a, b))
  3978. };
  3979. cc.pLength = function(a) {
  3980. return Math.sqrt(cc.pLengthSQ(a))
  3981. };
  3982. cc.pDistance = function(a, b) {
  3983. return cc.pLength(cc.pSub(a, b))
  3984. };
  3985. cc.pNormalize = function(a) {
  3986. var b = cc.pLength(a);
  3987. return 0 === b ? cc.p(a) : cc.pMult(a, 1 / b)
  3988. };
  3989. cc.pForAngle = function(a) {
  3990. return cc.p(Math.cos(a), Math.sin(a))
  3991. };
  3992. cc.pToAngle = function(a) {
  3993. return Math.atan2(a.y, a.x)
  3994. };
  3995. cc.clampf = function(a, b, c) {
  3996. if (b > c) {
  3997. var d = b;
  3998. b = c;
  3999. c = d
  4000. }
  4001. return a < b ? b : a < c ? a : c
  4002. };
  4003. cc.pClamp = function(a, b, c) {
  4004. return cc.p(cc.clampf(a.x, b.x, c.x), cc.clampf(a.y, b.y, c.y))
  4005. };
  4006. cc.pFromSize = function(a) {
  4007. return cc.p(a.width, a.height)
  4008. };
  4009. cc.pCompOp = function(a, b) {
  4010. return cc.p(b(a.x), b(a.y))
  4011. };
  4012. cc.pLerp = function(a, b, c) {
  4013. return cc.pAdd(cc.pMult(a, 1 - c), cc.pMult(b, c))
  4014. };
  4015. cc.pFuzzyEqual = function(a, b, c) {
  4016. return a.x - c <= b.x && b.x <= a.x + c && a.y - c <= b.y && b.y <= a.y + c ? !0 : !1
  4017. };
  4018. cc.pCompMult = function(a, b) {
  4019. return cc.p(a.x * b.x, a.y * b.y)
  4020. };
  4021. cc.pAngleSigned = function(a, b) {
  4022. var c = cc.pNormalize(a),
  4023. d = cc.pNormalize(b),
  4024. c = Math.atan2(c.x * d.y - c.y * d.x, cc.pDot(c, d));
  4025. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  4026. };
  4027. cc.pAngle = function(a, b) {
  4028. var c = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(b)));
  4029. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  4030. };
  4031. cc.pRotateByAngle = function(a, b, c) {
  4032. a = cc.pSub(a, b);
  4033. var d = Math.cos(c);
  4034. c = Math.sin(c);
  4035. var e = a.x;
  4036. a.x = e * d - a.y * c + b.x;
  4037. a.y = e * c + a.y * d + b.y;
  4038. return a
  4039. };
  4040. cc.pLineIntersect = function(a, b, c, d, e) {
  4041. if (a.x === b.x && a.y === b.y || c.x === d.x && c.y === d.y) return !1;
  4042. var f = b.x - a.x;
  4043. b = b.y - a.y;
  4044. var g = d.x - c.x;
  4045. d = d.y - c.y;
  4046. var h = a.x - c.x;
  4047. a = a.y - c.y;
  4048. c = d * f - g * b;
  4049. e.x = g * a - d * h;
  4050. e.y = f * a - b * h;
  4051. if (0 === c) return 0 === e.x || 0 === e.y ? !0 : !1;
  4052. e.x /= c;
  4053. e.y /= c;
  4054. return !0
  4055. };
  4056. cc.pSegmentIntersect = function(a, b, c, d) {
  4057. var e = cc.p(0, 0);
  4058. return cc.pLineIntersect(a, b, c, d, e) && 0 <= e.x && 1 >= e.x && 0 <= e.y && 1 >= e.y ? !0 : !1
  4059. };
  4060. cc.pIntersectPoint = function(a, b, c, d) {
  4061. var e = cc.p(0, 0);
  4062. return cc.pLineIntersect(a, b, c, d, e) ? (c = cc.p(0, 0), c.x = a.x + e.x * (b.x - a.x), c.y = a.y + e.x * (b.y - a.y), c) : cc.p(0, 0)
  4063. };
  4064. cc.pSameAs = function(a, b) {
  4065. return null != a && null != b ? a.x === b.x && a.y === b.y : !1
  4066. };
  4067. cc.pZeroIn = function(a) {
  4068. a.x = 0;
  4069. a.y = 0
  4070. };
  4071. cc.pIn = function(a, b) {
  4072. a.x = b.x;
  4073. a.y = b.y
  4074. };
  4075. cc.pMultIn = function(a, b) {
  4076. a.x *= b;
  4077. a.y *= b
  4078. };
  4079. cc.pSubIn = function(a, b) {
  4080. a.x -= b.x;
  4081. a.y -= b.y
  4082. };
  4083. cc.pAddIn = function(a, b) {
  4084. a.x += b.x;
  4085. a.y += b.y
  4086. };
  4087. cc.pNormalizeIn = function(a) {
  4088. cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y))
  4089. };
  4090. cc.vertexLineToPolygon = function(a, b, c, d, e) {
  4091. e += d;
  4092. if (!(1 >= e)) {
  4093. b *= 0.5;
  4094. for (var f, g = e - 1, h = d; h < e; h++) {
  4095. f = 2 * h;
  4096. var k = cc.p(a[2 * h], a[2 * h + 1]),
  4097. m;
  4098. if (0 === h) m = cc.pPerp(cc.pNormalize(cc.pSub(k, cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1]))));
  4099. else if (h === g) m = cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]), k)));
  4100. else {
  4101. m = cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]);
  4102. var n = cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1]),
  4103. p = cc.pNormalize(cc.pSub(n, k)),
  4104. t = cc.pNormalize(cc.pSub(m, k)),
  4105. r = Math.acos(cc.pDot(p, t));
  4106. m = r < cc.degreesToRadians(70) ? cc.pPerp(cc.pNormalize(cc.pMidpoint(p,
  4107. t))) : r < cc.degreesToRadians(170) ? cc.pNormalize(cc.pMidpoint(p, t)) : cc.pPerp(cc.pNormalize(cc.pSub(n, m)))
  4108. }
  4109. m = cc.pMult(m, b);
  4110. c[2 * f] = k.x + m.x;
  4111. c[2 * f + 1] = k.y + m.y;
  4112. c[2 * (f + 1)] = k.x - m.x;
  4113. c[2 * (f + 1) + 1] = k.y - m.y
  4114. }
  4115. for (h = 0 === d ? 0 : d - 1; h < g; h++) f = 2 * h, a = f + 2, b = cc.vertex2(c[2 * f], c[2 * f + 1]), e = cc.vertex2(c[2 * (f + 1)], c[2 * (f + 1) + 1]), f = cc.vertex2(c[2 * a], c[2 * a]), d = cc.vertex2(c[2 * (a + 1)], c[2 * (a + 1) + 1]), b = !cc.vertexLineIntersect(b.x, b.y, d.x, d.y, e.x, e.y, f.x, f.y), !b.isSuccess && (0 > b.value || 1 < b.value) && (b.isSuccess = !0), b.isSuccess && (c[2 * a] = d.x,
  4116. c[2 * a + 1] = d.y, c[2 * (a + 1)] = f.x, c[2 * (a + 1) + 1] = f.y)
  4117. }
  4118. };
  4119. cc.vertexLineIntersect = function(a, b, c, d, e, f, g, h) {
  4120. if (a === c && b === d || e === g && f === h) return {
  4121. isSuccess: !1,
  4122. value: 0
  4123. };
  4124. c -= a;
  4125. d -= b;
  4126. e -= a;
  4127. f -= b;
  4128. g -= a;
  4129. h -= b;
  4130. a = Math.sqrt(c * c + d * d);
  4131. c /= a;
  4132. d /= a;
  4133. b = e * c + f * d;
  4134. f = f * c - e * d;
  4135. e = b;
  4136. b = g * c + h * d;
  4137. h = h * c - g * d;
  4138. g = b;
  4139. return f === h ? {
  4140. isSuccess: !1,
  4141. value: 0
  4142. } : {
  4143. isSuccess: !0,
  4144. value: (g + (e - g) * h / (h - f)) / a
  4145. }
  4146. };
  4147. cc.vertexListIsClockwise = function(a) {
  4148. for (var b = 0, c = a.length; b < c; b++) {
  4149. var d = a[(b + 1) % c],
  4150. e = a[(b + 2) % c];
  4151. if (0 < cc.pCross(cc.pSub(d, a[b]), cc.pSub(e, d))) return !1
  4152. }
  4153. return !0
  4154. };
  4155. cc.CGAffineToGL = function(a, b) {
  4156. b[2] = b[3] = b[6] = b[7] = b[8] = b[9] = b[11] = b[14] = 0;
  4157. b[10] = b[15] = 1;
  4158. b[0] = a.a;
  4159. b[4] = a.c;
  4160. b[12] = a.tx;
  4161. b[1] = a.b;
  4162. b[5] = a.d;
  4163. b[13] = a.ty
  4164. };
  4165. cc.GLToCGAffine = function(a, b) {
  4166. b.a = a[0];
  4167. b.c = a[4];
  4168. b.tx = a[12];
  4169. b.b = a[1];
  4170. b.d = a[5];
  4171. b.ty = a[13]
  4172. };
  4173. cc.Touch = cc.Class.extend({
  4174. _point: null,
  4175. _prevPoint: null,
  4176. _id: 0,
  4177. _startPointCaptured: !1,
  4178. _startPoint: null,
  4179. ctor: function(a, b, c) {
  4180. this._point = cc.p(a || 0, b || 0);
  4181. this._id = c || 0
  4182. },
  4183. getLocation: function() {
  4184. return {
  4185. x: this._point.x,
  4186. y: this._point.y
  4187. }
  4188. },
  4189. getLocationX: function() {
  4190. return this._point.x
  4191. },
  4192. getLocationY: function() {
  4193. return this._point.y
  4194. },
  4195. getPreviousLocation: function() {
  4196. return {
  4197. x: this._prevPoint.x,
  4198. y: this._prevPoint.y
  4199. }
  4200. },
  4201. getStartLocation: function() {
  4202. return {
  4203. x: this._startPoint.x,
  4204. y: this._startPoint.y
  4205. }
  4206. },
  4207. getDelta: function() {
  4208. return cc.pSub(this._point,
  4209. this._prevPoint)
  4210. },
  4211. getLocationInView: function() {
  4212. return {
  4213. x: this._point.x,
  4214. y: this._point.y
  4215. }
  4216. },
  4217. getPreviousLocationInView: function() {
  4218. return {
  4219. x: this._prevPoint.x,
  4220. y: this._prevPoint.y
  4221. }
  4222. },
  4223. getStartLocationInView: function() {
  4224. return {
  4225. x: this._startPoint.x,
  4226. y: this._startPoint.y
  4227. }
  4228. },
  4229. getID: function() {
  4230. return this._id
  4231. },
  4232. getId: function() {
  4233. cc.log("getId is deprecated. Please use getID instead.");
  4234. return this._id
  4235. },
  4236. setTouchInfo: function(a, b, c) {
  4237. this._prevPoint = this._point;
  4238. this._point = cc.p(b || 0, c || 0);
  4239. this._id = a;
  4240. this._startPointCaptured ||
  4241. (this._startPoint = cc.p(this._point), this._startPointCaptured = !0)
  4242. },
  4243. _setPoint: function(a, b) {
  4244. void 0 === b ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = b)
  4245. },
  4246. _setPrevPoint: function(a, b) {
  4247. this._prevPoint = void 0 === b ? cc.p(a.x, a.y) : cc.p(a || 0, b || 0)
  4248. }
  4249. });
  4250. cc.Event = cc.Class.extend({
  4251. _type: 0,
  4252. _isStopped: !1,
  4253. _currentTarget: null,
  4254. _setCurrentTarget: function(a) {
  4255. this._currentTarget = a
  4256. },
  4257. ctor: function(a) {
  4258. this._type = a
  4259. },
  4260. getType: function() {
  4261. return this._type
  4262. },
  4263. stopPropagation: function() {
  4264. this._isStopped = !0
  4265. },
  4266. isStopped: function() {
  4267. return this._isStopped
  4268. },
  4269. getCurrentTarget: function() {
  4270. return this._currentTarget
  4271. }
  4272. });
  4273. cc.Event.TOUCH = 0;
  4274. cc.Event.KEYBOARD = 1;
  4275. cc.Event.ACCELERATION = 2;
  4276. cc.Event.MOUSE = 3;
  4277. cc.Event.FOCUS = 4;
  4278. cc.Event.CUSTOM = 6;
  4279. cc.EventCustom = cc.Event.extend({
  4280. _eventName: null,
  4281. _userData: null,
  4282. ctor: function(a) {
  4283. cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM);
  4284. this._eventName = a
  4285. },
  4286. setUserData: function(a) {
  4287. this._userData = a
  4288. },
  4289. getUserData: function() {
  4290. return this._userData
  4291. },
  4292. getEventName: function() {
  4293. return this._eventName
  4294. }
  4295. });
  4296. cc.EventMouse = cc.Event.extend({
  4297. _eventType: 0,
  4298. _button: 0,
  4299. _x: 0,
  4300. _y: 0,
  4301. _prevX: 0,
  4302. _prevY: 0,
  4303. _scrollX: 0,
  4304. _scrollY: 0,
  4305. ctor: function(a) {
  4306. cc.Event.prototype.ctor.call(this, cc.Event.MOUSE);
  4307. this._eventType = a
  4308. },
  4309. setScrollData: function(a, b) {
  4310. this._scrollX = a;
  4311. this._scrollY = b
  4312. },
  4313. getScrollX: function() {
  4314. return this._scrollX
  4315. },
  4316. getScrollY: function() {
  4317. return this._scrollY
  4318. },
  4319. setLocation: function(a, b) {
  4320. this._x = a;
  4321. this._y = b
  4322. },
  4323. getLocation: function() {
  4324. return {
  4325. x: this._x,
  4326. y: this._y
  4327. }
  4328. },
  4329. getLocationInView: function() {
  4330. return {
  4331. x: this._x,
  4332. y: cc.view._designResolutionSize.height -
  4333. this._y
  4334. }
  4335. },
  4336. _setPrevCursor: function(a, b) {
  4337. this._prevX = a;
  4338. this._prevY = b
  4339. },
  4340. getDelta: function() {
  4341. return {
  4342. x: this._x - this._prevX,
  4343. y: this._y - this._prevY
  4344. }
  4345. },
  4346. getDeltaX: function() {
  4347. return this._x - this._prevX
  4348. },
  4349. getDeltaY: function() {
  4350. return this._y - this._prevY
  4351. },
  4352. setButton: function(a) {
  4353. this._button = a
  4354. },
  4355. getButton: function() {
  4356. return this._button
  4357. },
  4358. getLocationX: function() {
  4359. return this._x
  4360. },
  4361. getLocationY: function() {
  4362. return this._y
  4363. }
  4364. });
  4365. cc.EventMouse.NONE = 0;
  4366. cc.EventMouse.DOWN = 1;
  4367. cc.EventMouse.UP = 2;
  4368. cc.EventMouse.MOVE = 3;
  4369. cc.EventMouse.SCROLL = 4;
  4370. cc.EventMouse.BUTTON_LEFT = 0;
  4371. cc.EventMouse.BUTTON_RIGHT = 2;
  4372. cc.EventMouse.BUTTON_MIDDLE = 1;
  4373. cc.EventMouse.BUTTON_4 = 3;
  4374. cc.EventMouse.BUTTON_5 = 4;
  4375. cc.EventMouse.BUTTON_6 = 5;
  4376. cc.EventMouse.BUTTON_7 = 6;
  4377. cc.EventMouse.BUTTON_8 = 7;
  4378. cc.EventTouch = cc.Event.extend({
  4379. _eventCode: 0,
  4380. _touches: null,
  4381. ctor: function(a) {
  4382. cc.Event.prototype.ctor.call(this, cc.Event.TOUCH);
  4383. this._touches = a || []
  4384. },
  4385. getEventCode: function() {
  4386. return this._eventCode
  4387. },
  4388. getTouches: function() {
  4389. return this._touches
  4390. },
  4391. _setEventCode: function(a) {
  4392. this._eventCode = a
  4393. },
  4394. _setTouches: function(a) {
  4395. this._touches = a
  4396. }
  4397. });
  4398. cc.EventTouch.MAX_TOUCHES = 5;
  4399. cc.EventTouch.EventCode = {
  4400. BEGAN: 0,
  4401. MOVED: 1,
  4402. ENDED: 2,
  4403. CANCELLED: 3
  4404. };
  4405. cc.EventFocus = cc.Event.extend({
  4406. _widgetGetFocus: null,
  4407. _widgetLoseFocus: null,
  4408. ctor: function(a, b) {
  4409. cc.Event.prototype.ctor.call(this, cc.Event.FOCUS);
  4410. this._widgetGetFocus = b;
  4411. this._widgetLoseFocus = a
  4412. }
  4413. });
  4414. cc.EventListener = cc.Class.extend({
  4415. _onEvent: null,
  4416. _type: 0,
  4417. _listenerID: null,
  4418. _registered: !1,
  4419. _fixedPriority: 0,
  4420. _node: null,
  4421. _paused: !0,
  4422. _isEnabled: !0,
  4423. ctor: function(a, b, c) {
  4424. this._onEvent = c;
  4425. this._type = a || 0;
  4426. this._listenerID = b || ""
  4427. },
  4428. _setPaused: function(a) {
  4429. this._paused = a
  4430. },
  4431. _isPaused: function() {
  4432. return this._paused
  4433. },
  4434. _setRegistered: function(a) {
  4435. this._registered = a
  4436. },
  4437. _isRegistered: function() {
  4438. return this._registered
  4439. },
  4440. _getType: function() {
  4441. return this._type
  4442. },
  4443. _getListenerID: function() {
  4444. return this._listenerID
  4445. },
  4446. _setFixedPriority: function(a) {
  4447. this._fixedPriority =
  4448. a
  4449. },
  4450. _getFixedPriority: function() {
  4451. return this._fixedPriority
  4452. },
  4453. _setSceneGraphPriority: function(a) {
  4454. this._node = a
  4455. },
  4456. _getSceneGraphPriority: function() {
  4457. return this._node
  4458. },
  4459. checkAvailable: function() {
  4460. return null !== this._onEvent
  4461. },
  4462. clone: function() {
  4463. return null
  4464. },
  4465. setEnabled: function(a) {
  4466. this._isEnabled = a
  4467. },
  4468. isEnabled: function() {
  4469. return this._isEnabled
  4470. },
  4471. retain: function() {},
  4472. release: function() {}
  4473. });
  4474. cc.EventListener.UNKNOWN = 0;
  4475. cc.EventListener.TOUCH_ONE_BY_ONE = 1;
  4476. cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
  4477. cc.EventListener.KEYBOARD = 3;
  4478. cc.EventListener.MOUSE = 4;
  4479. cc.EventListener.ACCELERATION = 5;
  4480. cc.EventListener.ACCELERATION = 6;
  4481. cc.EventListener.CUSTOM = 8;
  4482. cc.EventListener.FOCUS = 7;
  4483. cc._EventListenerCustom = cc.EventListener.extend({
  4484. _onCustomEvent: null,
  4485. ctor: function(a, b) {
  4486. this._onCustomEvent = b;
  4487. var c = this;
  4488. cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a, function(a) {
  4489. null !== c._onCustomEvent && c._onCustomEvent(a)
  4490. })
  4491. },
  4492. checkAvailable: function() {
  4493. return cc.EventListener.prototype.checkAvailable.call(this) && null !== this._onCustomEvent
  4494. },
  4495. clone: function() {
  4496. return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent)
  4497. }
  4498. });
  4499. cc._EventListenerCustom.create = function(a, b) {
  4500. return new cc._EventListenerCustom(a, b)
  4501. };
  4502. cc._EventListenerMouse = cc.EventListener.extend({
  4503. onMouseDown: null,
  4504. onMouseUp: null,
  4505. onMouseMove: null,
  4506. onMouseScroll: null,
  4507. ctor: function() {
  4508. var a = this;
  4509. cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID, function(b) {
  4510. var c = cc.EventMouse;
  4511. switch (b._eventType) {
  4512. case c.DOWN:
  4513. if (a.onMouseDown) a.onMouseDown(b);
  4514. break;
  4515. case c.UP:
  4516. if (a.onMouseUp) a.onMouseUp(b);
  4517. break;
  4518. case c.MOVE:
  4519. if (a.onMouseMove) a.onMouseMove(b);
  4520. break;
  4521. case c.SCROLL:
  4522. if (a.onMouseScroll) a.onMouseScroll(b)
  4523. }
  4524. })
  4525. },
  4526. clone: function() {
  4527. var a = new cc._EventListenerMouse;
  4528. a.onMouseDown = this.onMouseDown;
  4529. a.onMouseUp = this.onMouseUp;
  4530. a.onMouseMove = this.onMouseMove;
  4531. a.onMouseScroll = this.onMouseScroll;
  4532. return a
  4533. },
  4534. checkAvailable: function() {
  4535. return !0
  4536. }
  4537. });
  4538. cc._EventListenerMouse.LISTENER_ID = "__cc_mouse";
  4539. cc._EventListenerMouse.create = function() {
  4540. return new cc._EventListenerMouse
  4541. };
  4542. cc._EventListenerTouchOneByOne = cc.EventListener.extend({
  4543. _claimedTouches: null,
  4544. swallowTouches: !1,
  4545. onTouchBegan: null,
  4546. onTouchMoved: null,
  4547. onTouchEnded: null,
  4548. onTouchCancelled: null,
  4549. ctor: function() {
  4550. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null);
  4551. this._claimedTouches = []
  4552. },
  4553. setSwallowTouches: function(a) {
  4554. this.swallowTouches = a
  4555. },
  4556. isSwallowTouches: function() {
  4557. return this.swallowTouches
  4558. },
  4559. clone: function() {
  4560. var a = new cc._EventListenerTouchOneByOne;
  4561. a.onTouchBegan = this.onTouchBegan;
  4562. a.onTouchMoved = this.onTouchMoved;
  4563. a.onTouchEnded = this.onTouchEnded;
  4564. a.onTouchCancelled = this.onTouchCancelled;
  4565. a.swallowTouches = this.swallowTouches;
  4566. return a
  4567. },
  4568. checkAvailable: function() {
  4569. return this.onTouchBegan ? !0 : (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1)
  4570. }
  4571. });
  4572. cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one";
  4573. cc._EventListenerTouchOneByOne.create = function() {
  4574. return new cc._EventListenerTouchOneByOne
  4575. };
  4576. cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({
  4577. onTouchesBegan: null,
  4578. onTouchesMoved: null,
  4579. onTouchesEnded: null,
  4580. onTouchesCancelled: null,
  4581. ctor: function() {
  4582. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null)
  4583. },
  4584. clone: function() {
  4585. var a = new cc._EventListenerTouchAllAtOnce;
  4586. a.onTouchesBegan = this.onTouchesBegan;
  4587. a.onTouchesMoved = this.onTouchesMoved;
  4588. a.onTouchesEnded = this.onTouchesEnded;
  4589. a.onTouchesCancelled = this.onTouchesCancelled;
  4590. return a
  4591. },
  4592. checkAvailable: function() {
  4593. return null === this.onTouchesBegan && null === this.onTouchesMoved && null === this.onTouchesEnded && null === this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0
  4594. }
  4595. });
  4596. cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
  4597. cc._EventListenerTouchAllAtOnce.create = function() {
  4598. return new cc._EventListenerTouchAllAtOnce
  4599. };
  4600. cc.EventListener.create = function(a) {
  4601. cc.assert(a && a.event, cc._LogInfos.EventListener_create);
  4602. var b = a.event;
  4603. delete a.event;
  4604. var c = null;
  4605. b === cc.EventListener.TOUCH_ONE_BY_ONE ? c = new cc._EventListenerTouchOneByOne : b === cc.EventListener.TOUCH_ALL_AT_ONCE ? c = new cc._EventListenerTouchAllAtOnce : b === cc.EventListener.MOUSE ? c = new cc._EventListenerMouse : b === cc.EventListener.CUSTOM ? (c = new cc._EventListenerCustom(a.eventName, a.callback), delete a.eventName, delete a.callback) : b === cc.EventListener.KEYBOARD ? c = new cc._EventListenerKeyboard :
  4606. b === cc.EventListener.ACCELERATION ? (c = new cc._EventListenerAcceleration(a.callback), delete a.callback) : b === cc.EventListener.FOCUS && (c = new cc._EventListenerFocus);
  4607. for (var d in a) c[d] = a[d];
  4608. return c
  4609. };
  4610. cc._EventListenerFocus = cc.EventListener.extend({
  4611. clone: function() {
  4612. var a = new cc._EventListenerFocus;
  4613. a.onFocusChanged = this.onFocusChanged;
  4614. return a
  4615. },
  4616. checkAvailable: function() {
  4617. return this.onFocusChanged ? !0 : (cc.log("Invalid EventListenerFocus!"), !1)
  4618. },
  4619. onFocusChanged: null,
  4620. ctor: function() {
  4621. cc.EventListener.prototype.ctor.call(this, cc.EventListener.FOCUS, cc._EventListenerFocus.LISTENER_ID, function(a) {
  4622. if (this.onFocusChanged) this.onFocusChanged(a._widgetLoseFocus, a._widgetGetFocus)
  4623. })
  4624. }
  4625. });
  4626. cc._EventListenerFocus.LISTENER_ID = "__cc_focus_event";
  4627. cc._EventListenerVector = cc.Class.extend({
  4628. _fixedListeners: null,
  4629. _sceneGraphListeners: null,
  4630. gt0Index: 0,
  4631. ctor: function() {
  4632. this._fixedListeners = [];
  4633. this._sceneGraphListeners = []
  4634. },
  4635. size: function() {
  4636. return this._fixedListeners.length + this._sceneGraphListeners.length
  4637. },
  4638. empty: function() {
  4639. return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length
  4640. },
  4641. push: function(a) {
  4642. 0 === a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a)
  4643. },
  4644. clearSceneGraphListeners: function() {
  4645. this._sceneGraphListeners.length =
  4646. 0
  4647. },
  4648. clearFixedListeners: function() {
  4649. this._fixedListeners.length = 0
  4650. },
  4651. clear: function() {
  4652. this._sceneGraphListeners.length = 0;
  4653. this._fixedListeners.length = 0
  4654. },
  4655. getFixedPriorityListeners: function() {
  4656. return this._fixedListeners
  4657. },
  4658. getSceneGraphPriorityListeners: function() {
  4659. return this._sceneGraphListeners
  4660. }
  4661. });
  4662. cc.__getListenerID = function(a) {
  4663. var b = cc.Event,
  4664. c = a.getType();
  4665. if (c === b.ACCELERATION) return cc._EventListenerAcceleration.LISTENER_ID;
  4666. if (c === b.CUSTOM) return a.getEventName();
  4667. if (c === b.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID;
  4668. if (c === b.MOUSE) return cc._EventListenerMouse.LISTENER_ID;
  4669. if (c === b.FOCUS) return cc._EventListenerFocus.LISTENER_ID;
  4670. c === b.TOUCH && cc.log(cc._LogInfos.__getListenerID);
  4671. return ""
  4672. };
  4673. cc.eventManager = {
  4674. DIRTY_NONE: 0,
  4675. DIRTY_FIXED_PRIORITY: 1,
  4676. DIRTY_SCENE_GRAPH_PRIORITY: 2,
  4677. DIRTY_ALL: 3,
  4678. _listenersMap: {},
  4679. _priorityDirtyFlagMap: {},
  4680. _nodeListenersMap: {},
  4681. _nodePriorityMap: {},
  4682. _globalZOrderNodeMap: {},
  4683. _toAddedListeners: [],
  4684. _dirtyNodes: [],
  4685. _inDispatch: 0,
  4686. _isEnabled: !1,
  4687. _nodePriorityIndex: 0,
  4688. _internalCustomListenerIDs: [cc.game.EVENT_HIDE, cc.game.EVENT_SHOW],
  4689. _setDirtyForNode: function(a) {
  4690. null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a);
  4691. a = a.getChildren();
  4692. for (var b = 0, c = a.length; b < c; b++) this._setDirtyForNode(a[b])
  4693. },
  4694. pauseTarget: function(a, b) {
  4695. var c = this._nodeListenersMap[a.__instanceId],
  4696. d, e;
  4697. if (c)
  4698. for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!0);
  4699. if (!0 === b)
  4700. for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.pauseTarget(c[d], !0)
  4701. },
  4702. resumeTarget: function(a, b) {
  4703. var c = this._nodeListenersMap[a.__instanceId],
  4704. d, e;
  4705. if (c)
  4706. for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!1);
  4707. this._setDirtyForNode(a);
  4708. if (!0 === b)
  4709. for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.resumeTarget(c[d], !0)
  4710. },
  4711. _addListener: function(a) {
  4712. 0 === this._inDispatch ? this._forceAddEventListener(a) :
  4713. this._toAddedListeners.push(a)
  4714. },
  4715. _forceAddEventListener: function(a) {
  4716. var b = a._getListenerID(),
  4717. c = this._listenersMap[b];
  4718. c || (c = new cc._EventListenerVector, this._listenersMap[b] = c);
  4719. c.push(a);
  4720. 0 === a._getFixedPriority() ? (this._setDirty(b, this.DIRTY_SCENE_GRAPH_PRIORITY), b = a._getSceneGraphPriority(), null === b && cc.log(cc._LogInfos.eventManager__forceAddEventListener), this._associateNodeAndEventListener(b, a), b.isRunning() && this.resumeTarget(b)) : this._setDirty(b, this.DIRTY_FIXED_PRIORITY)
  4721. },
  4722. _getListeners: function(a) {
  4723. return this._listenersMap[a]
  4724. },
  4725. _updateDirtyFlagForSceneGraph: function() {
  4726. if (0 !== this._dirtyNodes.length) {
  4727. for (var a = this._dirtyNodes, b, c, d = this._nodeListenersMap, e = 0, f = a.length; e < f; e++)
  4728. if (b = d[a[e].__instanceId])
  4729. for (var g = 0, h = b.length; g < h; g++)(c = b[g]) && this._setDirty(c._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
  4730. this._dirtyNodes.length = 0
  4731. }
  4732. },
  4733. _removeAllListenersInVector: function(a) {
  4734. if (a)
  4735. for (var b, c = 0; c < a.length;) b = a[c], b._setRegistered(!1), null != b._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(b._getSceneGraphPriority(),
  4736. b), b._setSceneGraphPriority(null)), 0 === this._inDispatch ? cc.arrayRemoveObject(a, b) : ++c
  4737. },
  4738. _removeListenersForListenerID: function(a) {
  4739. var b = this._listenersMap[a];
  4740. if (b) {
  4741. var c = b.getFixedPriorityListeners(),
  4742. d = b.getSceneGraphPriorityListeners();
  4743. this._removeAllListenersInVector(d);
  4744. this._removeAllListenersInVector(c);
  4745. delete this._priorityDirtyFlagMap[a];
  4746. this._inDispatch || (b.clear(), delete this._listenersMap[a])
  4747. }
  4748. c = this._toAddedListeners;
  4749. for (b = 0; b < c.length;)(d = c[b]) && d._getListenerID() === a ? cc.arrayRemoveObject(c,
  4750. d) : ++b
  4751. },
  4752. _sortEventListeners: function(a) {
  4753. var b = this.DIRTY_NONE,
  4754. c = this._priorityDirtyFlagMap;
  4755. c[a] && (b = c[a]);
  4756. b !== this.DIRTY_NONE && (c[a] = this.DIRTY_NONE, b & this.DIRTY_FIXED_PRIORITY && this._sortListenersOfFixedPriority(a), b & this.DIRTY_SCENE_GRAPH_PRIORITY && ((b = cc.director.getRunningScene()) ? this._sortListenersOfSceneGraphPriority(a, b) : c[a] = this.DIRTY_SCENE_GRAPH_PRIORITY))
  4757. },
  4758. _sortListenersOfSceneGraphPriority: function(a, b) {
  4759. var c = this._getListeners(a);
  4760. if (c) {
  4761. var d = c.getSceneGraphPriorityListeners();
  4762. d && 0 !==
  4763. d.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {}, this._visitTarget(b, !0), c.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))
  4764. }
  4765. },
  4766. _sortEventListenersOfSceneGraphPriorityDes: function(a, b) {
  4767. var c = cc.eventManager._nodePriorityMap;
  4768. return a && b && a._getSceneGraphPriority() && b._getSceneGraphPriority() ? c[b._getSceneGraphPriority().__instanceId] - c[a._getSceneGraphPriority().__instanceId] : -1
  4769. },
  4770. _sortListenersOfFixedPriority: function(a) {
  4771. if (a = this._listenersMap[a]) {
  4772. var b =
  4773. a.getFixedPriorityListeners();
  4774. if (b && 0 !== b.length) {
  4775. b.sort(this._sortListenersOfFixedPriorityAsc);
  4776. for (var c = 0, d = b.length; c < d && !(0 <= b[c]._getFixedPriority());)++c;
  4777. a.gt0Index = c
  4778. }
  4779. }
  4780. },
  4781. _sortListenersOfFixedPriorityAsc: function(a, b) {
  4782. return a._getFixedPriority() - b._getFixedPriority()
  4783. },
  4784. _onUpdateListeners: function(a) {
  4785. if (a = this._listenersMap[a]) {
  4786. var b = a.getFixedPriorityListeners(),
  4787. c = a.getSceneGraphPriorityListeners(),
  4788. d, e;
  4789. if (c)
  4790. for (d = 0; d < c.length;) e = c[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(c, e);
  4791. if (b)
  4792. for (d =
  4793. 0; d < b.length;) e = b[d], e._isRegistered() ? ++d : cc.arrayRemoveObject(b, e);
  4794. c && 0 === c.length && a.clearSceneGraphListeners();
  4795. b && 0 === b.length && a.clearFixedListeners()
  4796. }
  4797. },
  4798. _updateListeners: function(a) {
  4799. var b = this._inDispatch;
  4800. cc.assert(0 < b, cc._LogInfos.EventManager__updateListeners);
  4801. if (!(1 < b)) {
  4802. a.getType() === cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a));
  4803. cc.assert(1 ===
  4804. b, cc._LogInfos.EventManager__updateListeners_2);
  4805. a = this._listenersMap;
  4806. var b = this._priorityDirtyFlagMap,
  4807. c;
  4808. for (c in a) a[c].empty() && (delete b[c], delete a[c]);
  4809. c = this._toAddedListeners;
  4810. if (0 !== c.length) {
  4811. a = 0;
  4812. for (b = c.length; a < b; a++) this._forceAddEventListener(c[a]);
  4813. this._toAddedListeners.length = 0
  4814. }
  4815. }
  4816. },
  4817. _onTouchEventCallback: function(a, b) {
  4818. if (!a._isRegistered) return !1;
  4819. var c = b.event,
  4820. d = b.selTouch;
  4821. c._setCurrentTarget(a._node);
  4822. var e = !1,
  4823. f, g = c.getEventCode(),
  4824. h = cc.EventTouch.EventCode;
  4825. if (g === h.BEGAN) a.onTouchBegan &&
  4826. (e = a.onTouchBegan(d, c)) && a._registered && a._claimedTouches.push(d);
  4827. else if (0 < a._claimedTouches.length && -1 !== (f = a._claimedTouches.indexOf(d)))
  4828. if (e = !0, g === h.MOVED && a.onTouchMoved) a.onTouchMoved(d, c);
  4829. else if (g === h.ENDED) {
  4830. if (a.onTouchEnded) a.onTouchEnded(d, c);
  4831. a._registered && a._claimedTouches.splice(f, 1)
  4832. } else if (g === h.CANCELLED) {
  4833. if (a.onTouchCancelled) a.onTouchCancelled(d, c);
  4834. a._registered && a._claimedTouches.splice(f, 1)
  4835. }
  4836. return c.isStopped() ? (cc.eventManager._updateListeners(c), !0) : e && a._registered && a.swallowTouches ?
  4837. (b.needsMutableSet && b.touches.splice(d, 1), !0) : !1
  4838. },
  4839. _dispatchTouchEvent: function(a) {
  4840. this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);
  4841. this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4842. var b = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),
  4843. c = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4844. if (null !== b || null !== c) {
  4845. var d = a.getTouches(),
  4846. e = cc.copyArray(d),
  4847. f = {
  4848. event: a,
  4849. needsMutableSet: b && c,
  4850. touches: e,
  4851. selTouch: null
  4852. };
  4853. if (b)
  4854. for (var g = 0; g < d.length; g++)
  4855. if (f.selTouch =
  4856. d[g], this._dispatchEventToListeners(b, this._onTouchEventCallback, f), a.isStopped()) return;
  4857. if (c && 0 < e.length && (this._dispatchEventToListeners(c, this._onTouchesEventCallback, {
  4858. event: a,
  4859. touches: e
  4860. }), a.isStopped())) return;
  4861. this._updateListeners(a)
  4862. }
  4863. },
  4864. _onTouchesEventCallback: function(a, b) {
  4865. if (!a._registered) return !1;
  4866. var c = cc.EventTouch.EventCode,
  4867. d = b.event,
  4868. e = b.touches,
  4869. f = d.getEventCode();
  4870. d._setCurrentTarget(a._node);
  4871. if (f === c.BEGAN && a.onTouchesBegan) a.onTouchesBegan(e, d);
  4872. else if (f === c.MOVED && a.onTouchesMoved) a.onTouchesMoved(e,
  4873. d);
  4874. else if (f === c.ENDED && a.onTouchesEnded) a.onTouchesEnded(e, d);
  4875. else if (f === c.CANCELLED && a.onTouchesCancelled) a.onTouchesCancelled(e, d);
  4876. return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : !1
  4877. },
  4878. _associateNodeAndEventListener: function(a, b) {
  4879. var c = this._nodeListenersMap[a.__instanceId];
  4880. c || (c = [], this._nodeListenersMap[a.__instanceId] = c);
  4881. c.push(b)
  4882. },
  4883. _dissociateNodeAndEventListener: function(a, b) {
  4884. var c = this._nodeListenersMap[a.__instanceId];
  4885. c && (cc.arrayRemoveObject(c, b), 0 === c.length && delete this._nodeListenersMap[a.__instanceId])
  4886. },
  4887. _dispatchEventToListeners: function(a, b, c) {
  4888. var d = !1,
  4889. e = a.getFixedPriorityListeners(),
  4890. f = a.getSceneGraphPriorityListeners(),
  4891. g = 0,
  4892. h;
  4893. if (e && 0 !== e.length)
  4894. for (; g < a.gt0Index; ++g)
  4895. if (h = e[g], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  4896. d = !0;
  4897. break
  4898. }
  4899. if (f && !d)
  4900. for (a = 0; a < f.length; a++)
  4901. if (h = f[a], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  4902. d = !0;
  4903. break
  4904. }
  4905. if (e && !d)
  4906. for (; g < e.length && (h = e[g], !h.isEnabled() || h._isPaused() || !h._isRegistered() || !b(h, c)); ++g);
  4907. },
  4908. _setDirty: function(a, b) {
  4909. var c = this._priorityDirtyFlagMap;
  4910. c[a] = null == c[a] ? b : b | c[a]
  4911. },
  4912. _visitTarget: function(a, b) {
  4913. var c = a.getChildren(),
  4914. d = 0,
  4915. e = c.length,
  4916. f = this._globalZOrderNodeMap,
  4917. g = this._nodeListenersMap;
  4918. if (0 < e) {
  4919. for (var h; d < e; d++)
  4920. if ((h = c[d]) && 0 > h.getLocalZOrder()) this._visitTarget(h, !1);
  4921. else break;
  4922. null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  4923. for (; d < e; d++)(h = c[d]) && this._visitTarget(h, !1)
  4924. } else null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  4925. if (b) {
  4926. var c = [],
  4927. k;
  4928. for (k in f) c.push(k);
  4929. c.sort(this._sortNumberAsc);
  4930. k = c.length;
  4931. h = this._nodePriorityMap;
  4932. for (d = 0; d < k; d++)
  4933. for (e = f[c[d]], g = 0; g < e.length; g++) h[e[g]] = ++this._nodePriorityIndex;
  4934. this._globalZOrderNodeMap = {}
  4935. }
  4936. },
  4937. _sortNumberAsc: function(a, b) {
  4938. return a - b
  4939. },
  4940. addListener: function(a, b) {
  4941. cc.assert(a && b, cc._LogInfos.eventManager_addListener_2);
  4942. if (!(a instanceof cc.EventListener)) cc.assert(!cc.isNumber(b), cc._LogInfos.eventManager_addListener_3), a = cc.EventListener.create(a);
  4943. else if (a._isRegistered()) {
  4944. cc.log(cc._LogInfos.eventManager_addListener_4);
  4945. return
  4946. }
  4947. if (a.checkAvailable()) {
  4948. if (cc.isNumber(b)) {
  4949. if (0 === b) {
  4950. cc.log(cc._LogInfos.eventManager_addListener);
  4951. return
  4952. }
  4953. a._setSceneGraphPriority(null);
  4954. a._setFixedPriority(b);
  4955. a._setRegistered(!0);
  4956. a._setPaused(!1)
  4957. } else a._setSceneGraphPriority(b), a._setFixedPriority(0), a._setRegistered(!0);
  4958. this._addListener(a);
  4959. return a
  4960. }
  4961. },
  4962. addCustomListener: function(a, b) {
  4963. var c = new cc._EventListenerCustom(a, b);
  4964. this.addListener(c, 1);
  4965. return c
  4966. },
  4967. removeListener: function(a) {
  4968. if (null != a) {
  4969. var b, c = this._listenersMap,
  4970. d;
  4971. for (d in c) {
  4972. var e =
  4973. c[d],
  4974. f = e.getFixedPriorityListeners();
  4975. b = e.getSceneGraphPriorityListeners();
  4976. (b = this._removeListenerInVector(b, a)) ? this._setDirty(a._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY): (b = this._removeListenerInVector(f, a)) && this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY);
  4977. e.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete c[d]);
  4978. if (b) break
  4979. }
  4980. if (!b)
  4981. for (c = this._toAddedListeners, d = 0, e = c.length; d < e; d++)
  4982. if (f = c[d], f === a) {
  4983. cc.arrayRemoveObject(c, f);
  4984. f._setRegistered(!1);
  4985. break
  4986. }
  4987. }
  4988. },
  4989. _removeListenerInVector: function(a,
  4990. b) {
  4991. if (null == a) return !1;
  4992. for (var c = 0, d = a.length; c < d; c++) {
  4993. var e = a[c];
  4994. if (e === b) return e._setRegistered(!1), null != e._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e), e._setSceneGraphPriority(null)), 0 === this._inDispatch && cc.arrayRemoveObject(a, e), !0
  4995. }
  4996. return !1
  4997. },
  4998. removeListeners: function(a, b) {
  4999. if (a instanceof cc.Node) {
  5000. delete this._nodePriorityMap[a.__instanceId];
  5001. cc.arrayRemoveObject(this._dirtyNodes, a);
  5002. var c = this._nodeListenersMap[a.__instanceId];
  5003. if (c) {
  5004. for (var d = cc.copyArray(c),
  5005. c = 0; c < d.length; c++) this.removeListener(d[c]);
  5006. d.length = 0
  5007. }
  5008. d = this._toAddedListeners;
  5009. for (c = 0; c < d.length;) {
  5010. var e = d[c];
  5011. e._getSceneGraphPriority() === a ? (e._setSceneGraphPriority(null), e._setRegistered(!1), d.splice(c, 1)) : ++c
  5012. }
  5013. if (!0 === b)
  5014. for (d = a.getChildren(), c = 0, e = d.length; c < e; c++) this.removeListeners(d[c], !0)
  5015. } 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) :
  5016. 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)
  5017. },
  5018. removeCustomListeners: function(a) {
  5019. this._removeListenersForListenerID(a)
  5020. },
  5021. removeAllListeners: function() {
  5022. var a = this._listenersMap,
  5023. b = this._internalCustomListenerIDs,
  5024. c;
  5025. for (c in a) - 1 === b.indexOf(c) && this._removeListenersForListenerID(c)
  5026. },
  5027. setPriority: function(a, b) {
  5028. if (null != a) {
  5029. var c = this._listenersMap,
  5030. d;
  5031. for (d in c) {
  5032. var e = c[d].getFixedPriorityListeners();
  5033. if (e && -1 !== e.indexOf(a)) {
  5034. null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority);
  5035. a._getFixedPriority() !== b && (a._setFixedPriority(b), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY));
  5036. break
  5037. }
  5038. }
  5039. }
  5040. },
  5041. setEnabled: function(a) {
  5042. this._isEnabled = a
  5043. },
  5044. isEnabled: function() {
  5045. return this._isEnabled
  5046. },
  5047. dispatchEvent: function(a) {
  5048. if (this._isEnabled) {
  5049. this._updateDirtyFlagForSceneGraph();
  5050. this._inDispatch++;
  5051. if (!a || !a.getType) throw "event is undefined";
  5052. if (a.getType() === cc.Event.TOUCH) this._dispatchTouchEvent(a);
  5053. else {
  5054. var b = cc.__getListenerID(a);
  5055. this._sortEventListeners(b);
  5056. b = this._listenersMap[b];
  5057. null != b && this._dispatchEventToListeners(b, this._onListenerCallback, a);
  5058. this._updateListeners(a)
  5059. }
  5060. this._inDispatch--
  5061. }
  5062. },
  5063. _onListenerCallback: function(a, b) {
  5064. b._setCurrentTarget(a._getSceneGraphPriority());
  5065. a._onEvent(b);
  5066. return b.isStopped()
  5067. },
  5068. dispatchCustomEvent: function(a, b) {
  5069. var c = new cc.EventCustom(a);
  5070. c.setUserData(b);
  5071. this.dispatchEvent(c)
  5072. }
  5073. };
  5074. cc.EventHelper = function() {};
  5075. cc.EventHelper.prototype = {
  5076. constructor: cc.EventHelper,
  5077. apply: function(a) {
  5078. a.addEventListener = cc.EventHelper.prototype.addEventListener;
  5079. a.hasEventListener = cc.EventHelper.prototype.hasEventListener;
  5080. a.removeEventListener = cc.EventHelper.prototype.removeEventListener;
  5081. a.dispatchEvent = cc.EventHelper.prototype.dispatchEvent
  5082. },
  5083. addEventListener: function(a, b, c) {
  5084. if ("load" === a && this._textureLoaded) setTimeout(function() {
  5085. b.call(c)
  5086. }, 0);
  5087. else {
  5088. void 0 === this._listeners && (this._listeners = {});
  5089. var d = this._listeners;
  5090. void 0 ===
  5091. d[a] && (d[a] = []);
  5092. this.hasEventListener(a, b, c) || d[a].push({
  5093. callback: b,
  5094. eventTarget: c
  5095. })
  5096. }
  5097. },
  5098. hasEventListener: function(a, b, c) {
  5099. if (void 0 === this._listeners) return !1;
  5100. var d = this._listeners;
  5101. if (void 0 !== d[a]) {
  5102. a = 0;
  5103. for (var e = d.length; a < e; a++) {
  5104. var f = d[a];
  5105. if (f.callback === b && f.eventTarget === c) return !0
  5106. }
  5107. }
  5108. return !1
  5109. },
  5110. removeEventListener: function(a, b) {
  5111. if (void 0 !== this._listeners) {
  5112. var c = this._listeners[a];
  5113. if (void 0 !== c)
  5114. for (var d = 0; d < c.length;) c[d].eventTarget === b ? c.splice(d, 1) : d++
  5115. }
  5116. },
  5117. dispatchEvent: function(a, b) {
  5118. if (void 0 !==
  5119. this._listeners) {
  5120. null == b && (b = !0);
  5121. var c = this._listeners[a];
  5122. if (void 0 !== c) {
  5123. for (var d = [], e = c.length, f = 0; f < e; f++) d[f] = c[f];
  5124. for (f = 0; f < e; f++) d[f].callback.call(d[f].eventTarget, this);
  5125. b && (c.length = 0)
  5126. }
  5127. }
  5128. }
  5129. };
  5130. cc.EventAcceleration = cc.Event.extend({
  5131. _acc: null,
  5132. ctor: function(a) {
  5133. cc.Event.prototype.ctor.call(this, cc.Event.ACCELERATION);
  5134. this._acc = a
  5135. }
  5136. });
  5137. cc.EventKeyboard = cc.Event.extend({
  5138. _keyCode: 0,
  5139. _isPressed: !1,
  5140. ctor: function(a, b) {
  5141. cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD);
  5142. this._keyCode = a;
  5143. this._isPressed = b
  5144. }
  5145. });
  5146. cc._EventListenerAcceleration = cc.EventListener.extend({
  5147. _onAccelerationEvent: null,
  5148. ctor: function(a) {
  5149. this._onAccelerationEvent = a;
  5150. var b = this;
  5151. cc.EventListener.prototype.ctor.call(this, cc.EventListener.ACCELERATION, cc._EventListenerAcceleration.LISTENER_ID, function(a) {
  5152. b._onAccelerationEvent(a._acc, a)
  5153. })
  5154. },
  5155. checkAvailable: function() {
  5156. cc.assert(this._onAccelerationEvent, cc._LogInfos._EventListenerAcceleration_checkAvailable);
  5157. return !0
  5158. },
  5159. clone: function() {
  5160. return new cc._EventListenerAcceleration(this._onAccelerationEvent)
  5161. }
  5162. });
  5163. cc._EventListenerAcceleration.LISTENER_ID = "__cc_acceleration";
  5164. cc._EventListenerAcceleration.create = function(a) {
  5165. return new cc._EventListenerAcceleration(a)
  5166. };
  5167. cc._EventListenerKeyboard = cc.EventListener.extend({
  5168. onKeyPressed: null,
  5169. onKeyReleased: null,
  5170. ctor: function() {
  5171. var a = this;
  5172. cc.EventListener.prototype.ctor.call(this, cc.EventListener.KEYBOARD, cc._EventListenerKeyboard.LISTENER_ID, function(b) {
  5173. if (b._isPressed) {
  5174. if (a.onKeyPressed) a.onKeyPressed(b._keyCode, b)
  5175. } else if (a.onKeyReleased) a.onKeyReleased(b._keyCode, b)
  5176. })
  5177. },
  5178. clone: function() {
  5179. var a = new cc._EventListenerKeyboard;
  5180. a.onKeyPressed = this.onKeyPressed;
  5181. a.onKeyReleased = this.onKeyReleased;
  5182. return a
  5183. },
  5184. checkAvailable: function() {
  5185. return null ===
  5186. this.onKeyPressed && null === this.onKeyReleased ? (cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable), !1) : !0
  5187. }
  5188. });
  5189. cc._EventListenerKeyboard.LISTENER_ID = "__cc_keyboard";
  5190. cc._EventListenerKeyboard.create = function() {
  5191. return new cc._EventListenerKeyboard
  5192. };
  5193. cc.rendererCanvas = {
  5194. childrenOrderDirty: !0,
  5195. _transformNodePool: [],
  5196. _renderCmds: [],
  5197. _isCacheToCanvasOn: !1,
  5198. _cacheToCanvasCmds: {},
  5199. _cacheInstanceIds: [],
  5200. _currentID: 0,
  5201. getRenderCmd: function(a) {
  5202. return a._createRenderCmd()
  5203. },
  5204. rendering: function(a) {
  5205. var b = this._renderCmds,
  5206. c, d = cc.view.getScaleX(),
  5207. e = cc.view.getScaleY(),
  5208. f = a || cc._renderContext;
  5209. f.computeRealOffsetY();
  5210. a = 0;
  5211. for (c = b.length; a < c; a++) b[a].rendering(f, d, e)
  5212. },
  5213. _renderingToCacheCanvas: function(a, b, c, d) {
  5214. a || cc.log("The context of RenderTexture is invalid.");
  5215. c = cc.isUndefined(c) ?
  5216. 1 : c;
  5217. d = cc.isUndefined(d) ? 1 : d;
  5218. b = b || this._currentID;
  5219. var e = this._cacheToCanvasCmds[b],
  5220. f, g;
  5221. a.computeRealOffsetY();
  5222. f = 0;
  5223. for (g = e.length; f < g; f++) e[f].rendering(a, c, d);
  5224. e.length = 0;
  5225. a = this._cacheInstanceIds;
  5226. delete this._cacheToCanvasCmds[b];
  5227. cc.arrayRemoveObject(a, b);
  5228. 0 === a.length ? this._isCacheToCanvasOn = !1 : this._currentID = a[a.length - 1]
  5229. },
  5230. _turnToCacheMode: function(a) {
  5231. this._isCacheToCanvasOn = !0;
  5232. a = a || 0;
  5233. this._cacheToCanvasCmds[a] = []; - 1 === this._cacheInstanceIds.indexOf(a) && this._cacheInstanceIds.push(a);
  5234. this._currentID =
  5235. a
  5236. },
  5237. _turnToNormalMode: function() {
  5238. this._isCacheToCanvasOn = !1
  5239. },
  5240. resetFlag: function() {
  5241. this.childrenOrderDirty = !1;
  5242. this._transformNodePool.length = 0
  5243. },
  5244. transform: function() {
  5245. var a = this._transformNodePool;
  5246. a.sort(this._sortNodeByLevelAsc);
  5247. for (var b = 0, c = a.length; b < c; b++) 0 !== a[b]._dirtyFlag && a[b].updateStatus();
  5248. a.length = 0
  5249. },
  5250. transformDirty: function() {
  5251. return 0 < this._transformNodePool.length
  5252. },
  5253. _sortNodeByLevelAsc: function(a, b) {
  5254. return a._curLevel - b._curLevel
  5255. },
  5256. pushDirtyNode: function(a) {
  5257. this._transformNodePool.push(a)
  5258. },
  5259. clearRenderCommands: function() {
  5260. this._renderCmds.length = 0
  5261. },
  5262. pushRenderCommand: function(a) {
  5263. if (a._needDraw)
  5264. if (this._isCacheToCanvasOn) {
  5265. var b = this._cacheToCanvasCmds[this._currentID]; - 1 === b.indexOf(a) && b.push(a)
  5266. } else -1 === this._renderCmds.indexOf(a) && this._renderCmds.push(a)
  5267. }
  5268. };
  5269. cc._renderType === cc._RENDER_TYPE_CANVAS && (cc.renderer = cc.rendererCanvas);
  5270. (function() {
  5271. cc.CanvasContextWrapper = function(a) {
  5272. this._context = a;
  5273. this._saveCount = 0;
  5274. this._currentAlpha = a.globalAlpha;
  5275. this._currentCompositeOperation = a.globalCompositeOperation;
  5276. this._currentFillStyle = a.fillStyle;
  5277. this._currentStrokeStyle = a.strokeStyle;
  5278. this._offsetY = this._offsetX = 0;
  5279. this._realOffsetY = this.height;
  5280. this._armatureMode = 0
  5281. };
  5282. var a = cc.CanvasContextWrapper.prototype;
  5283. a.resetCache = function() {
  5284. var a = this._context;
  5285. this._currentAlpha = a.globalAlpha;
  5286. this._currentCompositeOperation = a.globalCompositeOperation;
  5287. this._currentFillStyle = a.fillStyle;
  5288. this._currentStrokeStyle = a.strokeStyle;
  5289. this._realOffsetY = this._context.canvas.height + this._offsetY
  5290. };
  5291. a.setOffset = function(a, c) {
  5292. this._offsetX = a;
  5293. this._offsetY = c;
  5294. this._realOffsetY = this._context.canvas.height + this._offsetY
  5295. };
  5296. a.computeRealOffsetY = function() {
  5297. this._realOffsetY = this._context.canvas.height + this._offsetY
  5298. };
  5299. a.setViewScale = function(a, c) {
  5300. this._scaleX = a;
  5301. this._scaleY = c
  5302. };
  5303. a.getContext = function() {
  5304. return this._context
  5305. };
  5306. a.save = function() {
  5307. this._context.save();
  5308. this._saveCount++
  5309. };
  5310. a.restore = function() {
  5311. this._context.restore();
  5312. this._saveCount--
  5313. };
  5314. a.setGlobalAlpha = function(a) {
  5315. 0 < this._saveCount ? this._context.globalAlpha = a : this._currentAlpha !== a && (this._currentAlpha = a, this._context.globalAlpha = a)
  5316. };
  5317. a.setCompositeOperation = function(a) {
  5318. 0 < this._saveCount ? this._context.globalCompositeOperation = a : this._currentCompositeOperation !== a && (this._currentCompositeOperation = a, this._context.globalCompositeOperation = a)
  5319. };
  5320. a.setFillStyle = function(a) {
  5321. 0 < this._saveCount ? this._context.fillStyle = a : this._currentFillStyle !==
  5322. a && (this._currentFillStyle = a, this._context.fillStyle = a)
  5323. };
  5324. a.setStrokeStyle = function(a) {
  5325. 0 < this._saveCount ? this._context.strokeStyle = a : this._currentStrokeStyle !== a && (this._currentStrokeStyle = a, this._context.strokeStyle = a)
  5326. };
  5327. a.setTransform = function(a, c, d) {
  5328. 0 < this._armatureMode ? (this.restore(), this.save(), this._context.transform(a.a, -a.b, -a.c, a.d, a.tx * c, -(a.ty * d))) : this._context.setTransform(a.a, -a.b, -a.c, a.d, this._offsetX + a.tx * c, this._realOffsetY - a.ty * d)
  5329. };
  5330. a._switchToArmatureMode = function(a, c, d, e) {
  5331. a ? (this._armatureMode++,
  5332. this._context.setTransform(c.a, c.c, c.b, c.d, this._offsetX + c.tx * d, this._realOffsetY - c.ty * e), this.save()) : (this._armatureMode--, this.restore())
  5333. }
  5334. })();
  5335. cc.rendererWebGL = {
  5336. childrenOrderDirty: !0,
  5337. _transformNodePool: [],
  5338. _renderCmds: [],
  5339. _isCacheToBufferOn: !1,
  5340. _cacheToBufferCmds: {},
  5341. _cacheInstanceIds: [],
  5342. _currentID: 0,
  5343. getRenderCmd: function(a) {
  5344. return a._createRenderCmd()
  5345. },
  5346. rendering: function(a) {
  5347. var b = this._renderCmds,
  5348. c, d = a || cc._renderContext;
  5349. a = 0;
  5350. for (c = b.length; a < c; a++) b[a].rendering(d)
  5351. },
  5352. _turnToCacheMode: function(a) {
  5353. this._isCacheToBufferOn = !0;
  5354. a = a || 0;
  5355. this._cacheToBufferCmds[a] = [];
  5356. this._cacheInstanceIds.push(a);
  5357. this._currentID = a
  5358. },
  5359. _turnToNormalMode: function() {
  5360. this._isCacheToBufferOn = !1
  5361. },
  5362. _renderingToBuffer: function(a) {
  5363. a = a || this._currentID;
  5364. var b = this._cacheToBufferCmds[a],
  5365. c, d, e = cc._renderContext,
  5366. f = this._cacheInstanceIds;
  5367. c = 0;
  5368. for (d = b.length; c < d; c++) b[c].rendering(e);
  5369. b.length = 0;
  5370. delete this._cacheToBufferCmds[a];
  5371. cc.arrayRemoveObject(f, a);
  5372. 0 === f.length ? this._isCacheToBufferOn = !1 : this._currentID = f[f.length - 1]
  5373. },
  5374. resetFlag: function() {
  5375. this.childrenOrderDirty = !1;
  5376. this._transformNodePool.length = 0
  5377. },
  5378. transform: function() {
  5379. var a = this._transformNodePool;
  5380. a.sort(this._sortNodeByLevelAsc);
  5381. for (var b =
  5382. 0, c = a.length; b < c; b++) a[b].updateStatus();
  5383. a.length = 0
  5384. },
  5385. transformDirty: function() {
  5386. return 0 < this._transformNodePool.length
  5387. },
  5388. _sortNodeByLevelAsc: function(a, b) {
  5389. return a._curLevel - b._curLevel
  5390. },
  5391. pushDirtyNode: function(a) {
  5392. this._transformNodePool.push(a)
  5393. },
  5394. clearRenderCommands: function() {
  5395. this._renderCmds.length = 0
  5396. },
  5397. pushRenderCommand: function(a) {
  5398. if (a._needDraw)
  5399. if (this._isCacheToBufferOn) {
  5400. var b = this._cacheToBufferCmds[this._currentID]; - 1 === b.indexOf(a) && b.push(a)
  5401. } else -1 === this._renderCmds.indexOf(a) && this._renderCmds.push(a)
  5402. }
  5403. };
  5404. cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.renderer = cc.rendererWebGL);
  5405. cc._tmp.PrototypeCCNode = function() {
  5406. var a = cc.Node.prototype;
  5407. cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX);
  5408. cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY);
  5409. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  5410. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight);
  5411. cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX);
  5412. cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY);
  5413. cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX);
  5414. cc.defineGetterSetter(a, "skewY",
  5415. a.getSkewY, a.setSkewY);
  5416. cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder);
  5417. cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ);
  5418. cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation);
  5419. cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX);
  5420. cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY);
  5421. cc.defineGetterSetter(a, "scale", a.getScale, a.setScale);
  5422. cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX);
  5423. cc.defineGetterSetter(a, "scaleY", a.getScaleY,
  5424. a.setScaleY);
  5425. cc.defineGetterSetter(a, "children", a.getChildren);
  5426. cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount);
  5427. cc.defineGetterSetter(a, "parent", a.getParent, a.setParent);
  5428. cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible);
  5429. cc.defineGetterSetter(a, "running", a.isRunning);
  5430. cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition);
  5431. cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager);
  5432. cc.defineGetterSetter(a, "scheduler",
  5433. a.getScheduler, a.setScheduler);
  5434. cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram);
  5435. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  5436. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB);
  5437. cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
  5438. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  5439. cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
  5440. };
  5441. cc.NODE_TAG_INVALID = -1;
  5442. cc.s_globalOrderOfArrival = 1;
  5443. cc.Node = cc.Class.extend({
  5444. _localZOrder: 0,
  5445. _globalZOrder: 0,
  5446. _vertexZ: 0,
  5447. _rotationX: 0,
  5448. _rotationY: 0,
  5449. _scaleX: 1,
  5450. _scaleY: 1,
  5451. _position: null,
  5452. _normalizedPosition: null,
  5453. _usingNormalizedPosition: !1,
  5454. _normalizedPositionDirty: !1,
  5455. _skewX: 0,
  5456. _skewY: 0,
  5457. _children: null,
  5458. _visible: !0,
  5459. _anchorPoint: null,
  5460. _contentSize: null,
  5461. _running: !1,
  5462. _parent: null,
  5463. _ignoreAnchorPointForPosition: !1,
  5464. tag: cc.NODE_TAG_INVALID,
  5465. userData: null,
  5466. userObject: null,
  5467. _reorderChildDirty: !1,
  5468. _shaderProgram: null,
  5469. arrivalOrder: 0,
  5470. _actionManager: null,
  5471. _scheduler: null,
  5472. _eventDispatcher: null,
  5473. _additionalTransformDirty: !1,
  5474. _additionalTransform: null,
  5475. _componentContainer: null,
  5476. _isTransitionFinished: !1,
  5477. _className: "Node",
  5478. _showNode: !1,
  5479. _name: "",
  5480. _realOpacity: 255,
  5481. _realColor: null,
  5482. _cascadeColorEnabled: !1,
  5483. _cascadeOpacityEnabled: !1,
  5484. _renderCmd: null,
  5485. _camera: null,
  5486. ctor: function() {
  5487. this._initNode();
  5488. this._initRendererCmd()
  5489. },
  5490. _initNode: function() {
  5491. this._anchorPoint = cc.p(0, 0);
  5492. this._contentSize = cc.size(0, 0);
  5493. this._position = cc.p(0, 0);
  5494. this._normalizedPosition = cc.p(0, 0);
  5495. this._children = [];
  5496. var a = cc.director;
  5497. this._actionManager =
  5498. a.getActionManager();
  5499. this._scheduler = a.getScheduler();
  5500. this._additionalTransform = cc.affineTransformMakeIdentity();
  5501. cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this));
  5502. this._realOpacity = 255;
  5503. this._realColor = cc.color(255, 255, 255, 255);
  5504. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1
  5505. },
  5506. init: function() {
  5507. return !0
  5508. },
  5509. _arrayMakeObjectsPerformSelector: function(a, b) {
  5510. if (a && 0 !== a.length) {
  5511. var c, d = a.length,
  5512. e;
  5513. c = cc.Node._stateCallbackType;
  5514. switch (b) {
  5515. case c.onEnter:
  5516. for (c = 0; c < d; c++)
  5517. if (e =
  5518. a[c]) e.onEnter();
  5519. break;
  5520. case c.onExit:
  5521. for (c = 0; c < d; c++)
  5522. if (e = a[c]) e.onExit();
  5523. break;
  5524. case c.onEnterTransitionDidFinish:
  5525. for (c = 0; c < d; c++)
  5526. if (e = a[c]) e.onEnterTransitionDidFinish();
  5527. break;
  5528. case c.cleanup:
  5529. for (c = 0; c < d; c++)(e = a[c]) && e.cleanup();
  5530. break;
  5531. case c.updateTransform:
  5532. for (c = 0; c < d; c++)(e = a[c]) && e.updateTransform();
  5533. break;
  5534. case c.onExitTransitionDidStart:
  5535. for (c = 0; c < d; c++)
  5536. if (e = a[c]) e.onExitTransitionDidStart();
  5537. break;
  5538. case c.sortAllChildren:
  5539. for (c = 0; c < d; c++)(e = a[c]) && e.sortAllChildren();
  5540. break;
  5541. default:
  5542. cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector)
  5543. }
  5544. }
  5545. },
  5546. attr: function(a) {
  5547. for (var b in a) this[b] = a[b]
  5548. },
  5549. getSkewX: function() {
  5550. return this._skewX
  5551. },
  5552. setSkewX: function(a) {
  5553. this._skewX = a;
  5554. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5555. },
  5556. getSkewY: function() {
  5557. return this._skewY
  5558. },
  5559. setSkewY: function(a) {
  5560. this._skewY = a;
  5561. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5562. },
  5563. setLocalZOrder: function(a) {
  5564. this._localZOrder = a;
  5565. this._parent && this._parent.reorderChild(this, a);
  5566. cc.eventManager._setDirtyForNode(this)
  5567. },
  5568. _setLocalZOrder: function(a) {
  5569. this._localZOrder =
  5570. a
  5571. },
  5572. getLocalZOrder: function() {
  5573. return this._localZOrder
  5574. },
  5575. getZOrder: function() {
  5576. cc.log(cc._LogInfos.Node_getZOrder);
  5577. return this.getLocalZOrder()
  5578. },
  5579. setZOrder: function(a) {
  5580. cc.log(cc._LogInfos.Node_setZOrder);
  5581. this.setLocalZOrder(a)
  5582. },
  5583. setGlobalZOrder: function(a) {
  5584. this._globalZOrder !== a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this))
  5585. },
  5586. getGlobalZOrder: function() {
  5587. return this._globalZOrder
  5588. },
  5589. getVertexZ: function() {
  5590. return this._vertexZ
  5591. },
  5592. setVertexZ: function(a) {
  5593. this._vertexZ = a
  5594. },
  5595. getRotation: function() {
  5596. this._rotationX !==
  5597. this._rotationY && cc.log(cc._LogInfos.Node_getRotation);
  5598. return this._rotationX
  5599. },
  5600. setRotation: function(a) {
  5601. this._rotationX = this._rotationY = a;
  5602. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5603. },
  5604. getRotationX: function() {
  5605. return this._rotationX
  5606. },
  5607. setRotationX: function(a) {
  5608. this._rotationX = a;
  5609. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5610. },
  5611. getRotationY: function() {
  5612. return this._rotationY
  5613. },
  5614. setRotationY: function(a) {
  5615. this._rotationY = a;
  5616. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5617. },
  5618. getScale: function() {
  5619. this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale);
  5620. return this._scaleX
  5621. },
  5622. setScale: function(a, b) {
  5623. this._scaleX = a;
  5624. this._scaleY = b || 0 === b ? b : a;
  5625. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5626. },
  5627. getScaleX: function() {
  5628. return this._scaleX
  5629. },
  5630. setScaleX: function(a) {
  5631. this._scaleX = a;
  5632. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5633. },
  5634. getScaleY: function() {
  5635. return this._scaleY
  5636. },
  5637. setScaleY: function(a) {
  5638. this._scaleY = a;
  5639. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5640. },
  5641. setPosition: function(a, b) {
  5642. var c = this._position;
  5643. if (void 0 === b) {
  5644. if (c.x === a.x && c.y === a.y) return;
  5645. c.x = a.x;
  5646. c.y = a.y
  5647. } else {
  5648. if (c.x === a.x && c.y === b) return;
  5649. c.x = a;
  5650. c.y = b
  5651. }
  5652. this._usingNormalizedPosition = !1;
  5653. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5654. },
  5655. setNormalizedPosition: function(a, b) {
  5656. var c = this._normalizedPosition;
  5657. void 0 === b ? (c.x = a.x, c.y = a.y) : (c.x = a, c.y = b);
  5658. this._normalizedPositionDirty = this._usingNormalizedPosition = !0;
  5659. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5660. },
  5661. getPosition: function() {
  5662. return cc.p(this._position)
  5663. },
  5664. getNormalizedPosition: function() {
  5665. return cc.p(this._normalizedPosition)
  5666. },
  5667. getPositionX: function() {
  5668. return this._position.x
  5669. },
  5670. setPositionX: function(a) {
  5671. this._position.x = a;
  5672. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5673. },
  5674. getPositionY: function() {
  5675. return this._position.y
  5676. },
  5677. setPositionY: function(a) {
  5678. this._position.y = a;
  5679. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5680. },
  5681. getChildrenCount: function() {
  5682. return this._children.length
  5683. },
  5684. getChildren: function() {
  5685. return this._children
  5686. },
  5687. isVisible: function() {
  5688. return this._visible
  5689. },
  5690. setVisible: function(a) {
  5691. this._visible !== a && (this._visible = a, this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty), cc.renderer.childrenOrderDirty = !0)
  5692. },
  5693. getAnchorPoint: function() {
  5694. return cc.p(this._anchorPoint)
  5695. },
  5696. setAnchorPoint: function(a, b) {
  5697. var c = this._anchorPoint;
  5698. if (void 0 === b) {
  5699. if (a.x === c.x && a.y === c.y) return;
  5700. c.x = a.x;
  5701. c.y = a.y
  5702. } else {
  5703. if (a === c.x && b === c.y) return;
  5704. c.x = a;
  5705. c.y = b
  5706. }
  5707. this._renderCmd._updateAnchorPointInPoint()
  5708. },
  5709. _getAnchorX: function() {
  5710. return this._anchorPoint.x
  5711. },
  5712. _setAnchorX: function(a) {
  5713. this._anchorPoint.x !==
  5714. a && (this._anchorPoint.x = a, this._renderCmd._updateAnchorPointInPoint())
  5715. },
  5716. _getAnchorY: function() {
  5717. return this._anchorPoint.y
  5718. },
  5719. _setAnchorY: function(a) {
  5720. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._renderCmd._updateAnchorPointInPoint())
  5721. },
  5722. getAnchorPointInPoints: function() {
  5723. return this._renderCmd.getAnchorPointInPoints()
  5724. },
  5725. _getWidth: function() {
  5726. return this._contentSize.width
  5727. },
  5728. _setWidth: function(a) {
  5729. this._contentSize.width = a;
  5730. this._renderCmd._updateAnchorPointInPoint()
  5731. },
  5732. _getHeight: function() {
  5733. return this._contentSize.height
  5734. },
  5735. _setHeight: function(a) {
  5736. this._contentSize.height = a;
  5737. this._renderCmd._updateAnchorPointInPoint()
  5738. },
  5739. getContentSize: function() {
  5740. return cc.size(this._contentSize)
  5741. },
  5742. setContentSize: function(a, b) {
  5743. var c = this._contentSize;
  5744. if (void 0 === b) {
  5745. if (a.width === c.width && a.height === c.height) return;
  5746. c.width = a.width;
  5747. c.height = a.height
  5748. } else {
  5749. if (a === c.width && b === c.height) return;
  5750. c.width = a;
  5751. c.height = b
  5752. }
  5753. this._renderCmd._updateAnchorPointInPoint()
  5754. },
  5755. isRunning: function() {
  5756. return this._running
  5757. },
  5758. getParent: function() {
  5759. return this._parent
  5760. },
  5761. setParent: function(a) {
  5762. this._parent =
  5763. a
  5764. },
  5765. isIgnoreAnchorPointForPosition: function() {
  5766. return this._ignoreAnchorPointForPosition
  5767. },
  5768. ignoreAnchorPointForPosition: function(a) {
  5769. a !== this._ignoreAnchorPointForPosition && (this._ignoreAnchorPointForPosition = a, this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))
  5770. },
  5771. getTag: function() {
  5772. return this.tag
  5773. },
  5774. setTag: function(a) {
  5775. this.tag = a
  5776. },
  5777. setName: function(a) {
  5778. this._name = a
  5779. },
  5780. getName: function() {
  5781. return this._name
  5782. },
  5783. getUserData: function() {
  5784. return this.userData
  5785. },
  5786. setUserData: function(a) {
  5787. this.userData = a
  5788. },
  5789. getUserObject: function() {
  5790. return this.userObject
  5791. },
  5792. setUserObject: function(a) {
  5793. this.userObject !== a && (this.userObject = a)
  5794. },
  5795. getOrderOfArrival: function() {
  5796. return this.arrivalOrder
  5797. },
  5798. setOrderOfArrival: function(a) {
  5799. this.arrivalOrder = a
  5800. },
  5801. getActionManager: function() {
  5802. this._actionManager || (this._actionManager = cc.director.getActionManager());
  5803. return this._actionManager
  5804. },
  5805. setActionManager: function(a) {
  5806. this._actionManager !== a && (this.stopAllActions(), this._actionManager = a)
  5807. },
  5808. getScheduler: function() {
  5809. this._scheduler || (this._scheduler = cc.director.getScheduler());
  5810. return this._scheduler
  5811. },
  5812. setScheduler: function(a) {
  5813. this._scheduler !== a && (this.unscheduleAllCallbacks(), this._scheduler = a)
  5814. },
  5815. boundingBox: function() {
  5816. cc.log(cc._LogInfos.Node_boundingBox);
  5817. return this.getBoundingBox()
  5818. },
  5819. getBoundingBox: function() {
  5820. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  5821. return cc._rectApplyAffineTransformIn(a, this.getNodeToParentTransform())
  5822. },
  5823. cleanup: function() {
  5824. this.stopAllActions();
  5825. this.unscheduleAllCallbacks();
  5826. cc.eventManager.removeListeners(this);
  5827. this._arrayMakeObjectsPerformSelector(this._children,
  5828. cc.Node._stateCallbackType.cleanup)
  5829. },
  5830. getChildByTag: function(a) {
  5831. var b = this._children;
  5832. if (null !== b)
  5833. for (var c = 0; c < b.length; c++) {
  5834. var d = b[c];
  5835. if (d && d.tag === a) return d
  5836. }
  5837. return null
  5838. },
  5839. getChildByName: function(a) {
  5840. if (!a) return cc.log("Invalid name"), null;
  5841. for (var b = this._children, c = 0, d = b.length; c < d; c++)
  5842. if (b[c]._name === a) return b[c];
  5843. return null
  5844. },
  5845. addChild: function(a, b, c) {
  5846. b = void 0 === b ? a._localZOrder : b;
  5847. var d, e = !1;
  5848. cc.isUndefined(c) ? (c = void 0, d = a._name) : cc.isString(c) ? (d = c, c = void 0) : cc.isNumber(c) && (e = !0, d = "");
  5849. cc.assert(a,
  5850. cc._LogInfos.Node_addChild_3);
  5851. cc.assert(null === a._parent, "child already added. It can't be added again");
  5852. this._addChildHelper(a, b, c, d, e)
  5853. },
  5854. _addChildHelper: function(a, b, c, d, e) {
  5855. this._children || (this._children = []);
  5856. this._insertChild(a, b);
  5857. e ? a.setTag(c) : a.setName(d);
  5858. a.setParent(this);
  5859. a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
  5860. if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
  5861. this._cascadeColorEnabled && a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);
  5862. this._cascadeOpacityEnabled && a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  5863. },
  5864. removeFromParent: function(a) {
  5865. this._parent && (null == a && (a = !0), this._parent.removeChild(this, a))
  5866. },
  5867. removeFromParentAndCleanup: function(a) {
  5868. cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
  5869. this.removeFromParent(a)
  5870. },
  5871. removeChild: function(a, b) {
  5872. 0 !== this._children.length && (null == b && (b = !0), -1 < this._children.indexOf(a) && this._detachChild(a, b), cc.renderer.childrenOrderDirty = !0)
  5873. },
  5874. removeChildByTag: function(a, b) {
  5875. a === cc.NODE_TAG_INVALID &&
  5876. cc.log(cc._LogInfos.Node_removeChildByTag);
  5877. var c = this.getChildByTag(a);
  5878. null == c ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(c, b)
  5879. },
  5880. removeAllChildrenWithCleanup: function(a) {
  5881. this.removeAllChildren(a)
  5882. },
  5883. removeAllChildren: function(a) {
  5884. var b = this._children;
  5885. if (null !== b) {
  5886. null == a && (a = !0);
  5887. for (var c = 0; c < b.length; c++) {
  5888. var d = b[c];
  5889. d && (this._running && (d.onExitTransitionDidStart(), d.onExit()), a && d.cleanup(), d.parent = null)
  5890. }
  5891. this._children.length = 0
  5892. }
  5893. },
  5894. _detachChild: function(a, b) {
  5895. this._running && (a.onExitTransitionDidStart(),
  5896. a.onExit());
  5897. b && a.cleanup();
  5898. a.parent = null;
  5899. a._renderCmd.detachFromParent();
  5900. cc.arrayRemoveObject(this._children, a)
  5901. },
  5902. _insertChild: function(a, b) {
  5903. cc.renderer.childrenOrderDirty = this._reorderChildDirty = !0;
  5904. this._children.push(a);
  5905. a._setLocalZOrder(b)
  5906. },
  5907. setNodeDirty: function() {
  5908. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  5909. },
  5910. reorderChild: function(a, b) {
  5911. cc.assert(a, cc._LogInfos.Node_reorderChild);
  5912. cc.renderer.childrenOrderDirty = this._reorderChildDirty = !0;
  5913. a.arrivalOrder = cc.s_globalOrderOfArrival;
  5914. cc.s_globalOrderOfArrival++;
  5915. a._setLocalZOrder(b)
  5916. },
  5917. sortAllChildren: function() {
  5918. if (this._reorderChildDirty) {
  5919. var a = this._children,
  5920. b = a.length,
  5921. c, d, e;
  5922. for (c = 1; c < b; c++) {
  5923. e = a[c];
  5924. for (d = c - 1; 0 <= d;) {
  5925. if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d];
  5926. else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d];
  5927. else break;
  5928. d--
  5929. }
  5930. a[d + 1] = e
  5931. }
  5932. this._reorderChildDirty = !1
  5933. }
  5934. },
  5935. draw: function(a) {},
  5936. transformAncestors: function() {
  5937. null !== this._parent && (this._parent.transformAncestors(), this._parent.transform())
  5938. },
  5939. onEnter: function() {
  5940. this._isTransitionFinished = !1;
  5941. this._running = !0;
  5942. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnter);
  5943. this.resume()
  5944. },
  5945. onEnterTransitionDidFinish: function() {
  5946. this._isTransitionFinished = !0;
  5947. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnterTransitionDidFinish)
  5948. },
  5949. onExitTransitionDidStart: function() {
  5950. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExitTransitionDidStart)
  5951. },
  5952. onExit: function() {
  5953. this._running = !1;
  5954. this.pause();
  5955. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExit);
  5956. this.removeAllComponents()
  5957. },
  5958. runAction: function(a) {
  5959. cc.assert(a, cc._LogInfos.Node_runAction);
  5960. this.actionManager.addAction(a, this, !this._running);
  5961. return a
  5962. },
  5963. stopAllActions: function() {
  5964. this.actionManager && this.actionManager.removeAllActionsFromTarget(this)
  5965. },
  5966. stopAction: function(a) {
  5967. this.actionManager.removeAction(a)
  5968. },
  5969. stopActionByTag: function(a) {
  5970. a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) :
  5971. this.actionManager.removeActionByTag(a, this)
  5972. },
  5973. getActionByTag: function(a) {
  5974. return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this)
  5975. },
  5976. getNumberOfRunningActions: function() {
  5977. return this.actionManager.numberOfRunningActionsInTarget(this)
  5978. },
  5979. scheduleUpdate: function() {
  5980. this.scheduleUpdateWithPriority(0)
  5981. },
  5982. scheduleUpdateWithPriority: function(a) {
  5983. this.scheduler.scheduleUpdate(this, a, !this._running)
  5984. },
  5985. unscheduleUpdate: function() {
  5986. this.scheduler.unscheduleUpdate(this)
  5987. },
  5988. schedule: function(a, b, c, d, e) {
  5989. var f = arguments.length;
  5990. "function" === typeof a ? 1 === f ? (b = 0, c = cc.REPEAT_FOREVER, d = 0, e = this.__instanceId) : 2 === f ? "number" === typeof b ? (c = cc.REPEAT_FOREVER, d = 0, e = this.__instanceId) : (e = b, b = 0, c = cc.REPEAT_FOREVER, d = 0) : 3 === f ? ("string" === typeof c ? (e = c, c = cc.REPEAT_FOREVER) : e = this.__instanceId, d = 0) : 4 === f && (e = this.__instanceId) : 1 === f ? (b = 0, c = cc.REPEAT_FOREVER, d = 0) : 2 === f && (c = cc.REPEAT_FOREVER, d = 0);
  5991. cc.assert(a, cc._LogInfos.Node_schedule);
  5992. cc.assert(0 <= b, cc._LogInfos.Node_schedule_2);
  5993. c = null ==
  5994. c ? cc.REPEAT_FOREVER : c;
  5995. this.scheduler.schedule(a, this, b || 0, c, d || 0, !this._running, e)
  5996. },
  5997. scheduleOnce: function(a, b, c) {
  5998. void 0 === c && (c = this.__instanceId);
  5999. this.schedule(a, 0, 0, b, c)
  6000. },
  6001. unschedule: function(a) {
  6002. a && this.scheduler.unschedule(a, this)
  6003. },
  6004. unscheduleAllCallbacks: function() {
  6005. this.scheduler.unscheduleAllForTarget(this)
  6006. },
  6007. resumeSchedulerAndActions: function() {
  6008. cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);
  6009. this.resume()
  6010. },
  6011. resume: function() {
  6012. this.scheduler.resumeTarget(this);
  6013. this.actionManager && this.actionManager.resumeTarget(this);
  6014. cc.eventManager.resumeTarget(this)
  6015. },
  6016. pauseSchedulerAndActions: function() {
  6017. cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
  6018. this.pause()
  6019. },
  6020. pause: function() {
  6021. this.scheduler.pauseTarget(this);
  6022. this.actionManager && this.actionManager.pauseTarget(this);
  6023. cc.eventManager.pauseTarget(this)
  6024. },
  6025. setAdditionalTransform: function(a) {
  6026. if (null == a) return this._additionalTransformDirty = !1;
  6027. this._additionalTransform = a;
  6028. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);
  6029. this._additionalTransformDirty = !0
  6030. },
  6031. getParentToNodeTransform: function() {
  6032. this._renderCmd.getParentToNodeTransform()
  6033. },
  6034. parentToNodeTransform: function() {
  6035. return this.getParentToNodeTransform()
  6036. },
  6037. getNodeToWorldTransform: function() {
  6038. for (var a = this.getNodeToParentTransform(), b = this._parent; null !== b; b = b.parent) a = cc.affineTransformConcat(a, b.getNodeToParentTransform());
  6039. return a
  6040. },
  6041. nodeToWorldTransform: function() {
  6042. return this.getNodeToWorldTransform()
  6043. },
  6044. getWorldToNodeTransform: function() {
  6045. return cc.affineTransformInvert(this.getNodeToWorldTransform())
  6046. },
  6047. worldToNodeTransform: function() {
  6048. return this.getWorldToNodeTransform()
  6049. },
  6050. convertToNodeSpace: function(a) {
  6051. return cc.pointApplyAffineTransform(a,
  6052. this.getWorldToNodeTransform())
  6053. },
  6054. convertToWorldSpace: function(a) {
  6055. a = a || cc.p(0, 0);
  6056. return cc.pointApplyAffineTransform(a, this.getNodeToWorldTransform())
  6057. },
  6058. convertToNodeSpaceAR: function(a) {
  6059. return cc.pSub(this.convertToNodeSpace(a), this._renderCmd.getAnchorPointInPoints())
  6060. },
  6061. convertToWorldSpaceAR: function(a) {
  6062. a = a || cc.p(0, 0);
  6063. a = cc.pAdd(a, this._renderCmd.getAnchorPointInPoints());
  6064. return this.convertToWorldSpace(a)
  6065. },
  6066. _convertToWindowSpace: function(a) {
  6067. a = this.convertToWorldSpace(a);
  6068. return cc.director.convertToUI(a)
  6069. },
  6070. convertTouchToNodeSpace: function(a) {
  6071. a = a.getLocation();
  6072. return this.convertToNodeSpace(a)
  6073. },
  6074. convertTouchToNodeSpaceAR: function(a) {
  6075. a = cc.director.convertToGL(a.getLocation());
  6076. return this.convertToNodeSpaceAR(a)
  6077. },
  6078. update: function(a) {
  6079. this._componentContainer && !this._componentContainer.isEmpty() && this._componentContainer.visit(a)
  6080. },
  6081. updateTransform: function() {
  6082. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform)
  6083. },
  6084. retain: function() {},
  6085. release: function() {},
  6086. getComponent: function(a) {
  6087. return this._componentContainer ?
  6088. this._componentContainer.getComponent(a) : null
  6089. },
  6090. addComponent: function(a) {
  6091. this._componentContainer && this._componentContainer.add(a)
  6092. },
  6093. removeComponent: function(a) {
  6094. return this._componentContainer ? this._componentContainer.remove(a) : !1
  6095. },
  6096. removeAllComponents: function() {
  6097. this._componentContainer && this._componentContainer.removeAll()
  6098. },
  6099. grid: null,
  6100. visit: function(a) {
  6101. this._renderCmd.visit(a)
  6102. },
  6103. transform: function(a, b) {
  6104. this._renderCmd.transform(a, b)
  6105. },
  6106. nodeToParentTransform: function() {
  6107. return this.getNodeToParentTransform()
  6108. },
  6109. getNodeToParentTransform: function() {
  6110. return this._renderCmd.getNodeToParentTransform()
  6111. },
  6112. getCamera: function() {
  6113. this._camera || (this._camera = new cc.Camera);
  6114. return this._camera
  6115. },
  6116. getGrid: function() {
  6117. return this.grid
  6118. },
  6119. setGrid: function(a) {
  6120. this.grid = a
  6121. },
  6122. getShaderProgram: function() {
  6123. return this._renderCmd.getShaderProgram()
  6124. },
  6125. setShaderProgram: function(a) {
  6126. this._renderCmd.setShaderProgram(a)
  6127. },
  6128. getGLServerState: function() {
  6129. return 0
  6130. },
  6131. setGLServerState: function(a) {},
  6132. getBoundingBoxToWorld: function() {
  6133. var a = cc.rect(0, 0, this._contentSize.width,
  6134. this._contentSize.height),
  6135. b = this.getNodeToWorldTransform(),
  6136. a = cc.rectApplyAffineTransform(a, b);
  6137. if (!this._children) return a;
  6138. for (var c = this._children, d = 0; d < c.length; d++) {
  6139. var e = c[d];
  6140. e && e._visible && (e = e._getBoundingBoxToCurrentNode(b)) && (a = cc.rectUnion(a, e))
  6141. }
  6142. return a
  6143. },
  6144. _getBoundingBoxToCurrentNode: function(a) {
  6145. var b = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  6146. a = null == a ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), a);
  6147. b = cc.rectApplyAffineTransform(b,
  6148. a);
  6149. if (!this._children) return b;
  6150. for (var c = this._children, d = 0; d < c.length; d++) {
  6151. var e = c[d];
  6152. e && e._visible && (e = e._getBoundingBoxToCurrentNode(a)) && (b = cc.rectUnion(b, e))
  6153. }
  6154. return b
  6155. },
  6156. getOpacity: function() {
  6157. return this._realOpacity
  6158. },
  6159. getDisplayedOpacity: function() {
  6160. return this._renderCmd.getDisplayedOpacity()
  6161. },
  6162. setOpacity: function(a) {
  6163. this._realOpacity = a;
  6164. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  6165. },
  6166. updateDisplayedOpacity: function(a) {
  6167. this._renderCmd._updateDisplayOpacity(a)
  6168. },
  6169. isCascadeOpacityEnabled: function() {
  6170. return this._cascadeOpacityEnabled
  6171. },
  6172. setCascadeOpacityEnabled: function(a) {
  6173. this._cascadeOpacityEnabled !== a && (this._cascadeOpacityEnabled = a, this._renderCmd.setCascadeOpacityEnabledDirty())
  6174. },
  6175. getColor: function() {
  6176. var a = this._realColor;
  6177. return cc.color(a.r, a.g, a.b, a.a)
  6178. },
  6179. getDisplayedColor: function() {
  6180. return this._renderCmd.getDisplayedColor()
  6181. },
  6182. setColor: function(a) {
  6183. var b = this._realColor;
  6184. b.r = a.r;
  6185. b.g = a.g;
  6186. b.b = a.b;
  6187. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)
  6188. },
  6189. updateDisplayedColor: function(a) {
  6190. this._renderCmd._updateDisplayColor(a)
  6191. },
  6192. isCascadeColorEnabled: function() {
  6193. return this._cascadeColorEnabled
  6194. },
  6195. setCascadeColorEnabled: function(a) {
  6196. this._cascadeColorEnabled !== a && (this._cascadeColorEnabled = a, this._renderCmd.setCascadeColorEnabledDirty())
  6197. },
  6198. setOpacityModifyRGB: function(a) {},
  6199. isOpacityModifyRGB: function() {
  6200. return !1
  6201. },
  6202. _initRendererCmd: function() {
  6203. this._renderCmd = cc.renderer.getRenderCmd(this)
  6204. },
  6205. _createRenderCmd: function() {
  6206. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Node.CanvasRenderCmd(this) : new cc.Node.WebGLRenderCmd(this)
  6207. }
  6208. });
  6209. cc.Node.create = function() {
  6210. return new cc.Node
  6211. };
  6212. cc.Node._stateCallbackType = {
  6213. onEnter: 1,
  6214. onExit: 2,
  6215. cleanup: 3,
  6216. onEnterTransitionDidFinish: 4,
  6217. updateTransform: 5,
  6218. onExitTransitionDidStart: 6,
  6219. sortAllChildren: 7
  6220. };
  6221. cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode), cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
  6222. cc._tmp.PrototypeCCNode();
  6223. delete cc._tmp.PrototypeCCNode;
  6224. cc.CustomRenderCmd = function(a, b) {
  6225. this._needDraw = !0;
  6226. this._target = a;
  6227. this._callback = b;
  6228. this.rendering = function(a, b, e) {
  6229. this._callback && this._callback.call(this._target, a, b, e)
  6230. }
  6231. };
  6232. cc.Node._dirtyFlags = {
  6233. transformDirty: 1,
  6234. visibleDirty: 2,
  6235. colorDirty: 4,
  6236. opacityDirty: 8,
  6237. cacheDirty: 16,
  6238. orderDirty: 32,
  6239. textDirty: 64,
  6240. gradientDirty: 128,
  6241. all: 255
  6242. };
  6243. cc.Node.RenderCmd = function(a) {
  6244. this._dirtyFlag = 1;
  6245. this._node = a;
  6246. this._needDraw = !1;
  6247. this._anchorPointInPoints = new cc.Point(0, 0);
  6248. this._transform = {
  6249. a: 1,
  6250. b: 0,
  6251. c: 0,
  6252. d: 1,
  6253. tx: 0,
  6254. ty: 0
  6255. };
  6256. this._worldTransform = {
  6257. a: 1,
  6258. b: 0,
  6259. c: 0,
  6260. d: 1,
  6261. tx: 0,
  6262. ty: 0
  6263. };
  6264. this._inverse = {
  6265. a: 1,
  6266. b: 0,
  6267. c: 0,
  6268. d: 1,
  6269. tx: 0,
  6270. ty: 0
  6271. };
  6272. this._displayedOpacity = 255;
  6273. this._displayedColor = cc.color(255, 255, 255, 255);
  6274. this._cascadeOpacityEnabledDirty = this._cascadeColorEnabledDirty = !1;
  6275. this._curLevel = -1
  6276. };
  6277. cc.Node.RenderCmd.prototype = {
  6278. constructor: cc.Node.RenderCmd,
  6279. getAnchorPointInPoints: function() {
  6280. return cc.p(this._anchorPointInPoints)
  6281. },
  6282. getDisplayedColor: function() {
  6283. var a = this._displayedColor;
  6284. return cc.color(a.r, a.g, a.b, a.a)
  6285. },
  6286. getDisplayedOpacity: function() {
  6287. return this._displayedOpacity
  6288. },
  6289. setCascadeColorEnabledDirty: function() {
  6290. this._cascadeColorEnabledDirty = !0;
  6291. this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)
  6292. },
  6293. setCascadeOpacityEnabledDirty: function() {
  6294. this._cascadeOpacityEnabledDirty = !0;
  6295. this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  6296. },
  6297. getParentToNodeTransform: function() {
  6298. this._dirtyFlag & cc.Node._dirtyFlags.transformDirty && (this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()));
  6299. return this._inverse
  6300. },
  6301. detachFromParent: function() {},
  6302. _updateAnchorPointInPoint: function() {
  6303. var a = this._anchorPointInPoints,
  6304. b = this._node._contentSize,
  6305. c = this._node._anchorPoint;
  6306. a.x = b.width * c.x;
  6307. a.y = b.height * c.y;
  6308. this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)
  6309. },
  6310. setDirtyFlag: function(a) {
  6311. 0 === this._dirtyFlag && 0 !== a && cc.renderer.pushDirtyNode(this);
  6312. this._dirtyFlag |= a
  6313. },
  6314. getParentRenderCmd: function() {
  6315. return this._node && this._node._parent && this._node._parent._renderCmd ? this._node._parent._renderCmd : null
  6316. },
  6317. _updateDisplayColor: function(a) {
  6318. var b = this._node,
  6319. c = this._displayedColor,
  6320. d = b._realColor,
  6321. e;
  6322. if (this._cascadeColorEnabledDirty && !b._cascadeColorEnabled) {
  6323. c.r = d.r;
  6324. c.g = d.g;
  6325. c.b = d.b;
  6326. c = new cc.Color(255, 255, 255, 255);
  6327. a = b._children;
  6328. b = 0;
  6329. for (d = a.length; b < d; b++)(e = a[b]) && e._renderCmd && e._renderCmd._updateDisplayColor(c);
  6330. this._cascadeColorEnabledDirty = !1
  6331. } else if (void 0 ===
  6332. a && (a = (a = b._parent) && a._cascadeColorEnabled ? a.getDisplayedColor() : cc.color.WHITE), c.r = 0 | d.r * a.r / 255, c.g = 0 | d.g * a.g / 255, c.b = 0 | d.b * a.b / 255, b._cascadeColorEnabled)
  6333. for (a = b._children, b = 0, d = a.length; b < d; b++)(e = a[b]) && e._renderCmd && (e._renderCmd._updateDisplayColor(c), e._renderCmd._updateColor());
  6334. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.colorDirty
  6335. },
  6336. _updateDisplayOpacity: function(a) {
  6337. var b = this._node,
  6338. c, d;
  6339. if (this._cascadeOpacityEnabledDirty && !b._cascadeOpacityEnabled) {
  6340. this._displayedOpacity = b._realOpacity;
  6341. c = b._children;
  6342. a = 0;
  6343. for (b = c.length; a < b; a++)(d = c[a]) && d._renderCmd && d._renderCmd._updateDisplayOpacity(255);
  6344. this._cascadeOpacityEnabledDirty = !1
  6345. } else if (void 0 === a && (c = b._parent, a = 255, c && c._cascadeOpacityEnabled && (a = c.getDisplayedOpacity())), this._displayedOpacity = b._realOpacity * a / 255, b._cascadeOpacityEnabled)
  6346. for (c = b._children, a = 0, b = c.length; a < b; a++)(d = c[a]) && d._renderCmd && (d._renderCmd._updateDisplayOpacity(this._displayedOpacity), d._renderCmd._updateColor());
  6347. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.opacityDirty
  6348. },
  6349. _syncDisplayColor: function(a) {
  6350. var b = this._node,
  6351. c = this._displayedColor,
  6352. d = b._realColor;
  6353. void 0 === a && (a = (a = b._parent) && a._cascadeColorEnabled ? a.getDisplayedColor() : cc.color.WHITE);
  6354. c.r = 0 | d.r * a.r / 255;
  6355. c.g = 0 | d.g * a.g / 255;
  6356. c.b = 0 | d.b * a.b / 255
  6357. },
  6358. _syncDisplayOpacity: function(a) {
  6359. var b = this._node;
  6360. if (void 0 === a) {
  6361. var c = b._parent;
  6362. a = 255;
  6363. c && c._cascadeOpacityEnabled && (a = c.getDisplayedOpacity())
  6364. }
  6365. this._displayedOpacity = b._realOpacity * a / 255
  6366. },
  6367. _updateColor: function() {},
  6368. updateStatus: function() {
  6369. var a = cc.Node._dirtyFlags,
  6370. b = this._dirtyFlag,
  6371. c = b & a.colorDirty,
  6372. d = b & a.opacityDirty;
  6373. c && this._updateDisplayColor();
  6374. d && this._updateDisplayOpacity();
  6375. (c || d) && this._updateColor();
  6376. b & a.transformDirty && (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)
  6377. }
  6378. };
  6379. (function() {
  6380. cc.Node.CanvasRenderCmd = function(a) {
  6381. cc.Node.RenderCmd.call(this, a);
  6382. this._cachedParent = null;
  6383. this._cacheDirty = !1
  6384. };
  6385. var a = cc.Node.CanvasRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype);
  6386. a.constructor = cc.Node.CanvasRenderCmd;
  6387. a.transform = function(a, c) {
  6388. var d = this.getNodeToParentTransform(),
  6389. e = this._worldTransform;
  6390. this._cacheDirty = !0;
  6391. if (a) {
  6392. var f = a._worldTransform;
  6393. e.a = d.a * f.a + d.b * f.c;
  6394. e.b = d.a * f.b + d.b * f.d;
  6395. e.c = d.c * f.a + d.d * f.c;
  6396. e.d = d.c * f.b + d.d * f.d;
  6397. e.tx = f.a * d.tx + f.c * d.ty + f.tx;
  6398. e.ty = f.d * d.ty +
  6399. f.ty + f.b * d.tx
  6400. } else e.a = d.a, e.b = d.b, e.c = d.c, e.d = d.d, e.tx = d.tx, e.ty = d.ty; if (c && (d = this._node._children) && 0 !== d.length)
  6401. for (e = 0, f = d.length; e < f; e++) d[e]._renderCmd.transform(this, c)
  6402. };
  6403. a.getNodeToParentTransform = function() {
  6404. var a = this._node,
  6405. c = !1;
  6406. a._usingNormalizedPosition && a._parent && (c = a._parent._contentSize, a._position.x = a._normalizedPosition.x * c.width, a._position.y = a._normalizedPosition.y * c.height, a._normalizedPositionDirty = !1, c = !0);
  6407. if (c || this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) {
  6408. c = this._transform;
  6409. c.tx = a._position.x;
  6410. c.ty = a._position.y;
  6411. var d = 1,
  6412. e = 0,
  6413. f = 0,
  6414. g = 1;
  6415. a._rotationX && (g = 0.017453292519943295 * a._rotationX, f = Math.sin(g), g = Math.cos(g));
  6416. a._rotationY && (e = 0.017453292519943295 * a._rotationY, d = Math.cos(e), e = -Math.sin(e));
  6417. c.a = d;
  6418. c.b = e;
  6419. c.c = f;
  6420. c.d = g;
  6421. var h = a._scaleX,
  6422. k = a._scaleY,
  6423. m = this._anchorPointInPoints.x,
  6424. n = this._anchorPointInPoints.y,
  6425. p = 1E-6 > h && -1E-6 < h ? 1E-6 : h,
  6426. t = 1E-6 > k && -1E-6 < k ? 1E-6 : k;
  6427. if (1 !== h || 1 !== k) d = c.a *= p, e = c.b *= p, f = c.c *= t, g = c.d *= t;
  6428. if (a._skewX || a._skewY) h = Math.tan(-a._skewX * Math.PI / 180), k = Math.tan(-a._skewY *
  6429. Math.PI / 180), Infinity === h && (h = 99999999), Infinity === k && (k = 99999999), p = n * h, t = m * k, c.a = d - f * k, c.b = e - g * k, c.c = f - d * h, c.d = g - e * h, c.tx += d * p + f * t, c.ty += e * p + g * t;
  6430. c.tx -= d * m + f * n;
  6431. c.ty -= e * m + g * n;
  6432. a._ignoreAnchorPointForPosition && (c.tx += m, c.ty += n);
  6433. a._additionalTransformDirty && (this._transform = cc.affineTransformConcat(c, a._additionalTransform))
  6434. }
  6435. return this._transform
  6436. };
  6437. a.visit = function(a) {
  6438. var c = this._node;
  6439. if (c._visible) {
  6440. if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1;
  6441. var d = c._children,
  6442. e;
  6443. this._syncStatus(a);
  6444. a = d.length;
  6445. if (0 < a) {
  6446. c.sortAllChildren();
  6447. for (c = 0; c < a; c++)
  6448. if (e = d[c], 0 > e._localZOrder) e._renderCmd.visit(this);
  6449. else break;
  6450. for (cc.renderer.pushRenderCommand(this); c < a; c++) d[c]._renderCmd.visit(this)
  6451. } else cc.renderer.pushRenderCommand(this);
  6452. this._dirtyFlag = 0
  6453. }
  6454. };
  6455. a._syncStatus = function(a) {
  6456. var c = cc.Node._dirtyFlags,
  6457. d = this._dirtyFlag,
  6458. e = a ? a._node : null;
  6459. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty);
  6460. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  6461. a && a._dirtyFlag &
  6462. c.transformDirty && (d |= c.transformDirty);
  6463. var e = d & c.colorDirty,
  6464. f = d & c.opacityDirty,
  6465. c = d & c.transformDirty;
  6466. this._dirtyFlag = d;
  6467. e && this._syncDisplayColor();
  6468. f && this._syncDisplayOpacity();
  6469. e && this._updateColor();
  6470. c && this.transform(a)
  6471. };
  6472. a.setDirtyFlag = function(a) {
  6473. cc.Node.RenderCmd.prototype.setDirtyFlag.call(this, a);
  6474. this._setCacheDirty();
  6475. this._cachedParent && this._cachedParent.setDirtyFlag(a)
  6476. };
  6477. a._setCacheDirty = function() {
  6478. if (!1 === this._cacheDirty) {
  6479. this._cacheDirty = !0;
  6480. var a = this._cachedParent;
  6481. a && a !== this && a._setNodeDirtyForCache &&
  6482. a._setNodeDirtyForCache()
  6483. }
  6484. };
  6485. a._setCachedParent = function(a) {
  6486. if (this._cachedParent !== a) {
  6487. this._cachedParent = a;
  6488. for (var c = this._node._children, d = 0, e = c.length; d < e; d++) c[d]._renderCmd._setCachedParent(a)
  6489. }
  6490. };
  6491. a.detachFromParent = function() {
  6492. this._cachedParent = null;
  6493. for (var a = this._node._children, c, d = 0, e = a.length; d < e; d++)(c = a[d]) && c._renderCmd && c._renderCmd.detachFromParent()
  6494. };
  6495. a.setShaderProgram = function(a) {};
  6496. a.getShaderProgram = function() {
  6497. return null
  6498. };
  6499. cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc = function(a) {
  6500. return a ?
  6501. a.src === cc.SRC_ALPHA && a.dst === cc.ONE || a.src === cc.ONE && a.dst === cc.ONE ? "lighter" : a.src === cc.ZERO && a.dst === cc.SRC_ALPHA ? "destination-in" : a.src === cc.ZERO && a.dst === cc.ONE_MINUS_SRC_ALPHA ? "destination-out" : "source-over" : "source-over"
  6502. }
  6503. })();
  6504. (function() {
  6505. cc.Node.WebGLRenderCmd = function(a) {
  6506. cc.Node.RenderCmd.call(this, a);
  6507. a = new cc.math.Matrix4;
  6508. var c = a.mat;
  6509. c[2] = c[3] = c[6] = c[7] = c[8] = c[9] = c[11] = c[14] = 0;
  6510. c[10] = c[15] = 1;
  6511. this._transform4x4 = a;
  6512. this._stackMatrix = new cc.math.Matrix4;
  6513. this._camera = this._shaderProgram = null
  6514. };
  6515. var a = cc.Node.WebGLRenderCmd.prototype = Object.create(cc.Node.RenderCmd.prototype);
  6516. a.constructor = cc.Node.WebGLRenderCmd;
  6517. a.getNodeToParentTransform = function() {
  6518. var a = this._node;
  6519. if (a._usingNormalizedPosition && a._parent) {
  6520. var c = a._parent._contentSize;
  6521. a._position.x = a._normalizedPosition.x * c.width;
  6522. a._position.y = a._normalizedPosition.y * c.height;
  6523. a._normalizedPositionDirty = !1
  6524. }
  6525. if (this._dirtyFlag & cc.Node._dirtyFlags.transformDirty) {
  6526. var c = a._position.x,
  6527. d = a._position.y,
  6528. e = this._anchorPointInPoints.x,
  6529. f = -e,
  6530. g = this._anchorPointInPoints.y,
  6531. h = -g,
  6532. k = a._scaleX,
  6533. m = a._scaleY,
  6534. n = 0.017453292519943295 * a._rotationX,
  6535. p = 0.017453292519943295 * a._rotationY;
  6536. a._ignoreAnchorPointForPosition && (c += e, d += g);
  6537. var t = 1,
  6538. r = 0,
  6539. u = 1,
  6540. s = 0;
  6541. if (0 !== a._rotationX || 0 !== a._rotationY) t = Math.cos(-n), r = Math.sin(-n),
  6542. u = Math.cos(-p), s = Math.sin(-p);
  6543. n = a._skewX || a._skewY;
  6544. n || 0 === e && 0 === g || (c += u * f * k + -r * h * m, d += s * f * k + t * h * m);
  6545. p = this._transform;
  6546. p.a = u * k;
  6547. p.b = s * k;
  6548. p.c = -r * m;
  6549. p.d = t * m;
  6550. p.tx = c;
  6551. p.ty = d;
  6552. n && (p = cc.affineTransformConcat({
  6553. a: 1,
  6554. b: Math.tan(cc.degreesToRadians(a._skewY)),
  6555. c: Math.tan(cc.degreesToRadians(a._skewX)),
  6556. d: 1,
  6557. tx: 0,
  6558. ty: 0
  6559. }, p), 0 !== e || 0 !== g) && (p = cc.affineTransformTranslate(p, f, h));
  6560. a._additionalTransformDirty && (p = cc.affineTransformConcat(p, a._additionalTransform), a._additionalTransformDirty = !1);
  6561. this._transform = p
  6562. }
  6563. return this._transform
  6564. };
  6565. a._syncStatus = function(a) {
  6566. var c = cc.Node._dirtyFlags,
  6567. d = this._dirtyFlag,
  6568. e = a ? a._node : null;
  6569. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty);
  6570. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  6571. a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty);
  6572. e = d & c.colorDirty;
  6573. c = d & c.opacityDirty;
  6574. this._dirtyFlag = d;
  6575. e && this._syncDisplayColor();
  6576. c && this._syncDisplayOpacity();
  6577. (e || c) && this._updateColor();
  6578. this.transform(a)
  6579. };
  6580. a._updateColor = function() {};
  6581. a.visit = function(a) {
  6582. var c =
  6583. this._node;
  6584. if (c._visible) {
  6585. a = a || this.getParentRenderCmd();
  6586. c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1);
  6587. var d = cc.current_stack;
  6588. d.stack.push(d.top);
  6589. this._syncStatus(a);
  6590. d.top = this._stackMatrix;
  6591. if ((a = c._children) && 0 < a.length) {
  6592. var e = a.length;
  6593. c.sortAllChildren();
  6594. for (c = 0; c < e; c++)
  6595. if (a[c] && 0 > a[c]._localZOrder) a[c]._renderCmd.visit(this);
  6596. else break;
  6597. for (cc.renderer.pushRenderCommand(this); c < e; c++) a[c] && a[c]._renderCmd.visit(this)
  6598. } else cc.renderer.pushRenderCommand(this);
  6599. this._dirtyFlag = 0;
  6600. d.top = d.stack.pop()
  6601. }
  6602. };
  6603. a.transform = function(a, c) {
  6604. var d = this._transform4x4,
  6605. e = this._stackMatrix,
  6606. f = this._node,
  6607. g = (a = a || this.getParentRenderCmd()) ? a._stackMatrix : cc.current_stack.top,
  6608. h = this.getNodeToParentTransform();
  6609. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty;
  6610. var k = d.mat;
  6611. k[0] = h.a;
  6612. k[4] = h.c;
  6613. k[12] = h.tx;
  6614. k[1] = h.b;
  6615. k[5] = h.d;
  6616. k[13] = h.ty;
  6617. k[14] = f._vertexZ;
  6618. cc.kmMat4Multiply(e, g, d);
  6619. null === f._camera || null !== f.grid && f.grid.isActive() || (g = this._anchorPointInPoints.x, h = this._anchorPointInPoints.y,
  6620. 0 !== g || 0 !== h ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (g |= 0, h |= 0), k = cc.math.Matrix4.createByTranslation(g, h, 0, d), e.multiply(k), f._camera._locateForRenderer(e), k = cc.math.Matrix4.createByTranslation(-g, -h, 0, k), e.multiply(k), d.identity()) : f._camera._locateForRenderer(e));
  6621. if (c && f._children && 0 !== f._children.length)
  6622. for (f = f._children, d = 0, e = f.length; d < e; d++) f[d]._renderCmd.transform(this, c)
  6623. };
  6624. a.setShaderProgram = function(a) {
  6625. this._shaderProgram = a
  6626. };
  6627. a.getShaderProgram = function() {
  6628. return this._shaderProgram
  6629. }
  6630. })();
  6631. cc.AtlasNode = cc.Node.extend({
  6632. textureAtlas: null,
  6633. quadsToDraw: 0,
  6634. _itemsPerRow: 0,
  6635. _itemsPerColumn: 0,
  6636. _itemWidth: 0,
  6637. _itemHeight: 0,
  6638. _opacityModifyRGB: !1,
  6639. _blendFunc: null,
  6640. _ignoreContentScaleFactor: !1,
  6641. _className: "AtlasNode",
  6642. _textureForCanvas: null,
  6643. ctor: function(a, b, c, d) {
  6644. cc.Node.prototype.ctor.call(this);
  6645. this._blendFunc = {
  6646. src: cc.BLEND_SRC,
  6647. dst: cc.BLEND_DST
  6648. };
  6649. this._ignoreContentScaleFactor = !1;
  6650. void 0 !== d && this.initWithTileFile(a, b, c, d)
  6651. },
  6652. _createRenderCmd: function() {
  6653. this._renderCmd = cc._renderType === cc._RENDER_TYPE_CANVAS ?
  6654. new cc.AtlasNode.CanvasRenderCmd(this) : new cc.AtlasNode.WebGLRenderCmd(this)
  6655. },
  6656. updateAtlasValues: function() {
  6657. cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)
  6658. },
  6659. getColor: function() {
  6660. return this._opacityModifyRGB ? this._renderCmd._colorUnmodified : cc.Node.prototype.getColor.call(this)
  6661. },
  6662. setOpacityModifyRGB: function(a) {
  6663. var b = this.color;
  6664. this._opacityModifyRGB = a;
  6665. this.setColor(b)
  6666. },
  6667. isOpacityModifyRGB: function() {
  6668. return this._opacityModifyRGB
  6669. },
  6670. getBlendFunc: function() {
  6671. return this._blendFunc
  6672. },
  6673. setBlendFunc: function(a,
  6674. b) {
  6675. this._blendFunc = void 0 === b ? a : {
  6676. src: a,
  6677. dst: b
  6678. }
  6679. },
  6680. setTextureAtlas: function(a) {
  6681. this.textureAtlas = a
  6682. },
  6683. getTextureAtlas: function() {
  6684. return this.textureAtlas
  6685. },
  6686. getQuadsToDraw: function() {
  6687. return this.quadsToDraw
  6688. },
  6689. setQuadsToDraw: function(a) {
  6690. this.quadsToDraw = a
  6691. },
  6692. initWithTileFile: function(a, b, c, d) {
  6693. if (!a) throw "cc.AtlasNode.initWithTileFile(): title should not be null";
  6694. a = cc.textureCache.addImage(a);
  6695. return this.initWithTexture(a, b, c, d)
  6696. },
  6697. initWithTexture: function(a, b, c, d) {
  6698. return this._renderCmd.initWithTexture(a, b, c, d)
  6699. },
  6700. setColor: function(a) {
  6701. this._renderCmd.setColor(a)
  6702. },
  6703. setOpacity: function(a) {
  6704. this._renderCmd.setOpacity(a)
  6705. },
  6706. getTexture: function() {
  6707. return this._renderCmd.getTexture()
  6708. },
  6709. setTexture: function(a) {
  6710. this._renderCmd.setTexture(a)
  6711. },
  6712. _setIgnoreContentScaleFactor: function(a) {
  6713. this._ignoreContentScaleFactor = a
  6714. }
  6715. });
  6716. _p = cc.AtlasNode.prototype;
  6717. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  6718. cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor);
  6719. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  6720. cc.EventHelper.prototype.apply(_p);
  6721. cc.AtlasNode.create = function(a, b, c, d) {
  6722. return new cc.AtlasNode(a, b, c, d)
  6723. };
  6724. (function() {
  6725. cc.AtlasNode.CanvasRenderCmd = function(a) {
  6726. cc.Node.CanvasRenderCmd.call(this, a);
  6727. this._needDraw = !1;
  6728. this._colorUnmodified = cc.color.WHITE;
  6729. this._texture = this._originalTexture = null
  6730. };
  6731. var a = cc.AtlasNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  6732. a.constructor = cc.AtlasNode.CanvasRenderCmd;
  6733. a.initWithTexture = function(a, c, d, e) {
  6734. var f = this._node;
  6735. f._itemWidth = c;
  6736. f._itemHeight = d;
  6737. f._opacityModifyRGB = !0;
  6738. this._originalTexture = a;
  6739. if (!this._originalTexture) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
  6740. this._texture = this._originalTexture;
  6741. this._calculateMaxItems();
  6742. f.quadsToDraw = e;
  6743. return !0
  6744. };
  6745. a.setColor = function(a) {
  6746. var c = this._node._realColor;
  6747. if (c.r !== a.r || c.g !== a.g || c.b !== a.b) this._colorUnmodified = a, this._changeTextureColor()
  6748. };
  6749. a._changeTextureColor = cc.sys._supportCanvasNewBlendModes ? function() {
  6750. var a = this._node,
  6751. c = a.getTexture();
  6752. if (c && this._originalTexture) {
  6753. var d = this._originalTexture.getHtmlElementObj();
  6754. if (d) {
  6755. var e = c.getHtmlElementObj(),
  6756. c = cc.rect(0, 0, d.width, d.height);
  6757. e instanceof HTMLCanvasElement ?
  6758. cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._colorUnmodified, c, e) : (e = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._colorUnmodified, c), c = new cc.Texture2D, c.initWithElement(e), c.handleLoadedTexture(), a.setTexture(c))
  6759. }
  6760. }
  6761. } : function() {
  6762. var a = this._node,
  6763. c, d = a.getTexture();
  6764. if (d && this._originalTexture && (c = d.getHtmlElementObj())) {
  6765. var e = this._originalTexture.getHtmlElementObj();
  6766. if (d = cc.textureCache.getTextureColors(e)) e = cc.rect(0, 0, e.width, e.height), c instanceof HTMLCanvasElement ?
  6767. cc.Sprite.CanvasRenderCmd._generateTintImage(c, d, this._displayedColor, e, c) : (c = cc.Sprite.CanvasRenderCmd._generateTintImage(c, d, this._displayedColor, e), d = new cc.Texture2D, d.initWithElement(c), d.handleLoadedTexture(), a.setTexture(d))
  6768. }
  6769. };
  6770. a.setOpacity = function(a) {
  6771. cc.Node.prototype.setOpacity.call(this._node, a)
  6772. };
  6773. a.getTexture = function() {
  6774. return this._texture
  6775. };
  6776. a.setTexture = function(a) {
  6777. this._texture = a
  6778. };
  6779. a._calculateMaxItems = function() {
  6780. var a = this._node,
  6781. c = this._texture.getContentSize();
  6782. a._itemsPerColumn = 0 | c.height /
  6783. a._itemHeight;
  6784. a._itemsPerRow = 0 | c.width / a._itemWidth
  6785. }
  6786. })();
  6787. (function() {
  6788. cc.AtlasNode.WebGLRenderCmd = function(a) {
  6789. cc.Node.WebGLRenderCmd.call(this, a);
  6790. this._needDraw = !0;
  6791. this._textureAtlas = null;
  6792. this._colorUnmodified = cc.color.WHITE;
  6793. this._uniformColor = this._colorF32Array = null;
  6794. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  6795. this._uniformColor = cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(), "u_color")
  6796. };
  6797. var a = cc.AtlasNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  6798. a.constructor =
  6799. cc.AtlasNode.WebGLRenderCmd;
  6800. a._updateBlendFunc = function() {
  6801. var a = this._node;
  6802. this._textureAtlas.texture.hasPremultipliedAlpha() || (a._blendFunc.src = cc.SRC_ALPHA, a._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  6803. };
  6804. a._updateOpacityModifyRGB = function() {
  6805. this._node._opacityModifyRGB = this._textureAtlas.texture.hasPremultipliedAlpha()
  6806. };
  6807. a.rendering = function(a) {
  6808. a = a || cc._renderContext;
  6809. var c = this._node;
  6810. this._shaderProgram.use();
  6811. this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
  6812. cc.glBlendFunc(c._blendFunc.src,
  6813. c._blendFunc.dst);
  6814. this._uniformColor && this._colorF32Array && (a.uniform4fv(this._uniformColor, this._colorF32Array), this._textureAtlas.drawNumberOfQuads(c.quadsToDraw, 0))
  6815. };
  6816. a.initWithTexture = function(a, c, d, e) {
  6817. var f = this._node;
  6818. f._itemWidth = c;
  6819. f._itemHeight = d;
  6820. this._colorUnmodified = cc.color.WHITE;
  6821. f._opacityModifyRGB = !0;
  6822. f._blendFunc.src = cc.BLEND_SRC;
  6823. f._blendFunc.dst = cc.BLEND_DST;
  6824. c = f._realColor;
  6825. this._colorF32Array = new Float32Array([c.r / 255, c.g / 255, c.b / 255, f._realOpacity / 255]);
  6826. this._textureAtlas = new cc.TextureAtlas;
  6827. this._textureAtlas.initWithTexture(a, e);
  6828. if (!this._textureAtlas) return cc.log(cc._LogInfos.AtlasNode__initWithTexture), !1;
  6829. this._updateBlendFunc();
  6830. this._updateOpacityModifyRGB();
  6831. this._calculateMaxItems();
  6832. f.quadsToDraw = e;
  6833. return !0
  6834. };
  6835. a.setColor = function(a) {
  6836. var c = cc.color(a.r, a.g, a.b),
  6837. d = this._node;
  6838. this._colorUnmodified = a;
  6839. a = this._displayedOpacity;
  6840. d._opacityModifyRGB && (c.r = c.r * a / 255, c.g = c.g * a / 255, c.b = c.b * a / 255);
  6841. cc.Node.prototype.setColor.call(d, c)
  6842. };
  6843. a.setOpacity = function(a) {
  6844. var c = this._node;
  6845. cc.Node.prototype.setOpacity.call(c,
  6846. a);
  6847. c._opacityModifyRGB && (c.color = this._colorUnmodified)
  6848. };
  6849. a._updateColor = function() {
  6850. var a = this._displayedColor;
  6851. this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, this._displayedOpacity / 255])
  6852. };
  6853. a.getTexture = function() {
  6854. return this._textureAtlas.texture
  6855. };
  6856. a.setTexture = function(a) {
  6857. this._textureAtlas.texture = a;
  6858. this._updateBlendFunc();
  6859. this._updateOpacityModifyRGB()
  6860. };
  6861. a._calculateMaxItems = function() {
  6862. var a = this._node,
  6863. c = this._textureAtlas.texture,
  6864. d = c.getContentSize();
  6865. a._ignoreContentScaleFactor && (d =
  6866. c.getContentSizeInPixels());
  6867. a._itemsPerColumn = 0 | d.height / a._itemHeight;
  6868. a._itemsPerRow = 0 | d.width / a._itemWidth
  6869. }
  6870. })();
  6871. cc._tmp.WebGLTexture2D = function() {
  6872. cc.Texture2D = cc.Class.extend({
  6873. _pVRHaveAlphaPremultiplied: !0,
  6874. _pixelFormat: null,
  6875. _pixelsWide: 0,
  6876. _pixelsHigh: 0,
  6877. _name: "",
  6878. _contentSize: null,
  6879. maxS: 0,
  6880. maxT: 0,
  6881. _hasPremultipliedAlpha: !1,
  6882. _hasMipmaps: !1,
  6883. shaderProgram: null,
  6884. _textureLoaded: !1,
  6885. _htmlElementObj: null,
  6886. _webTextureObj: null,
  6887. url: null,
  6888. ctor: function() {
  6889. this._contentSize = cc.size(0, 0);
  6890. this._pixelFormat = cc.Texture2D.defaultPixelFormat
  6891. },
  6892. releaseTexture: function() {
  6893. this._webTextureObj && cc._renderContext.deleteTexture(this._webTextureObj);
  6894. cc.loader.release(this.url)
  6895. },
  6896. getPixelFormat: function() {
  6897. return this._pixelFormat
  6898. },
  6899. getPixelsWide: function() {
  6900. return this._pixelsWide
  6901. },
  6902. getPixelsHigh: function() {
  6903. return this._pixelsHigh
  6904. },
  6905. getName: function() {
  6906. return this._webTextureObj
  6907. },
  6908. getContentSize: function() {
  6909. return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor())
  6910. },
  6911. _getWidth: function() {
  6912. return this._contentSize.width / cc.contentScaleFactor()
  6913. },
  6914. _getHeight: function() {
  6915. return this._contentSize.height / cc.contentScaleFactor()
  6916. },
  6917. getContentSizeInPixels: function() {
  6918. return this._contentSize
  6919. },
  6920. getMaxS: function() {
  6921. return this.maxS
  6922. },
  6923. setMaxS: function(a) {
  6924. this.maxS = a
  6925. },
  6926. getMaxT: function() {
  6927. return this.maxT
  6928. },
  6929. setMaxT: function(a) {
  6930. this.maxT = a
  6931. },
  6932. getShaderProgram: function() {
  6933. return this.shaderProgram
  6934. },
  6935. setShaderProgram: function(a) {
  6936. this.shaderProgram = a
  6937. },
  6938. hasPremultipliedAlpha: function() {
  6939. return this._hasPremultipliedAlpha
  6940. },
  6941. hasMipmaps: function() {
  6942. return this._hasMipmaps
  6943. },
  6944. description: function() {
  6945. return "\x3ccc.Texture2D | Name \x3d " + this._name + " | Dimensions \x3d " +
  6946. this._pixelsWide + " x " + this._pixelsHigh + " | Coordinates \x3d (" + this.maxS + ", " + this.maxT + ")\x3e"
  6947. },
  6948. releaseData: function(a) {},
  6949. keepData: function(a, b) {
  6950. return a
  6951. },
  6952. initWithData: function(a, b, c, d, e) {
  6953. var f = cc.Texture2D,
  6954. g = cc._renderContext,
  6955. h = g.RGBA,
  6956. k = g.UNSIGNED_BYTE,
  6957. m = c * cc.Texture2D._B[b] / 8;
  6958. 0 === m % 8 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 8) : 0 === m % 4 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 4) : 0 === m % 2 ? g.pixelStorei(g.UNPACK_ALIGNMENT, 2) : g.pixelStorei(g.UNPACK_ALIGNMENT, 1);
  6959. this._webTextureObj = g.createTexture();
  6960. cc.glBindTexture2D(this);
  6961. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MIN_FILTER, g.LINEAR);
  6962. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MAG_FILTER, g.LINEAR);
  6963. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE);
  6964. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE);
  6965. switch (b) {
  6966. case f.PIXEL_FORMAT_RGBA8888:
  6967. h = g.RGBA;
  6968. break;
  6969. case f.PIXEL_FORMAT_RGB888:
  6970. h = g.RGB;
  6971. break;
  6972. case f.PIXEL_FORMAT_RGBA4444:
  6973. k = g.UNSIGNED_SHORT_4_4_4_4;
  6974. break;
  6975. case f.PIXEL_FORMAT_RGB5A1:
  6976. k = g.UNSIGNED_SHORT_5_5_5_1;
  6977. break;
  6978. case f.PIXEL_FORMAT_RGB565:
  6979. k = g.UNSIGNED_SHORT_5_6_5;
  6980. break;
  6981. case f.PIXEL_FORMAT_AI88:
  6982. h = g.LUMINANCE_ALPHA;
  6983. break;
  6984. case f.PIXEL_FORMAT_A8:
  6985. h = g.ALPHA;
  6986. break;
  6987. case f.PIXEL_FORMAT_I8:
  6988. h = g.LUMINANCE;
  6989. break;
  6990. default:
  6991. cc.assert(0, cc._LogInfos.Texture2D_initWithData)
  6992. }
  6993. g.texImage2D(g.TEXTURE_2D, 0, h, c, d, 0, h, k, a);
  6994. this._contentSize.width = e.width;
  6995. this._contentSize.height = e.height;
  6996. this._pixelsWide = c;
  6997. this._pixelsHigh = d;
  6998. this._pixelFormat = b;
  6999. this.maxS = e.width / c;
  7000. this.maxT = e.height / d;
  7001. this._hasMipmaps = this._hasPremultipliedAlpha = !1;
  7002. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
  7003. return this._textureLoaded = !0
  7004. },
  7005. drawAtPoint: function(a) {
  7006. var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0],
  7007. c = this._pixelsWide * this.maxS,
  7008. d = this._pixelsHigh * this.maxT;
  7009. a = [a.x, a.y, 0, c + a.x, a.y, 0, a.x, d + a.y, 0, c + a.x, d + a.y, 0];
  7010. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  7011. this._shaderProgram.use();
  7012. this._shaderProgram.setUniformsForBuiltins();
  7013. cc.glBindTexture2D(this);
  7014. c = cc._renderContext;
  7015. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a);
  7016. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,
  7017. 2, c.FLOAT, !1, 0, b);
  7018. c.drawArrays(c.TRIANGLE_STRIP, 0, 4)
  7019. },
  7020. drawInRect: function(a) {
  7021. var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0];
  7022. 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];
  7023. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  7024. this._shaderProgram.use();
  7025. this._shaderProgram.setUniformsForBuiltins();
  7026. cc.glBindTexture2D(this);
  7027. var c = cc._renderContext;
  7028. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a);
  7029. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,
  7030. 2, c.FLOAT, !1, 0, b);
  7031. c.drawArrays(c.TRIANGLE_STRIP, 0, 4)
  7032. },
  7033. initWithImage: function(a) {
  7034. if (null == a) return cc.log(cc._LogInfos.Texture2D_initWithImage), !1;
  7035. var b = a.getWidth(),
  7036. c = a.getHeight(),
  7037. d = cc.configuration.getMaxTextureSize();
  7038. if (b > d || c > d) return cc.log(cc._LogInfos.Texture2D_initWithImage_2, b, c, d, d), !1;
  7039. this._textureLoaded = !0;
  7040. return this._initPremultipliedATextureWithImage(a, b, c)
  7041. },
  7042. initWithElement: function(a) {
  7043. a && (this._webTextureObj = cc._renderContext.createTexture(), this._htmlElementObj = a, this._textureLoaded = !0)
  7044. },
  7045. getHtmlElementObj: function() {
  7046. return this._htmlElementObj
  7047. },
  7048. isLoaded: function() {
  7049. return this._textureLoaded
  7050. },
  7051. handleLoadedTexture: function(a) {
  7052. a = void 0 === a ? !1 : a;
  7053. if (cc._rendererInitialized) {
  7054. if (!this._htmlElementObj) {
  7055. var b = cc.loader.getRes(this.url);
  7056. if (!b) return;
  7057. this.initWithElement(b)
  7058. }
  7059. this._htmlElementObj.width && this._htmlElementObj.height && (b = cc._renderContext, cc.glBindTexture2D(this), b.pixelStorei(b.UNPACK_ALIGNMENT, 4), a && b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1), b.texImage2D(b.TEXTURE_2D,
  7060. 0, b.RGBA, b.RGBA, b.UNSIGNED_BYTE, this._htmlElementObj), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.LINEAR), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, b.LINEAR), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE), this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE), cc.glBindTexture2D(null), a && b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), b = this._htmlElementObj.height, this._pixelsWide =
  7061. this._contentSize.width = this._htmlElementObj.width, this._pixelsHigh = this._contentSize.height = b, this._pixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.maxT = this.maxS = 1, this._hasPremultipliedAlpha = a, this._hasMipmaps = !1, this.dispatchEvent("load"))
  7062. }
  7063. },
  7064. initWithString: function(a, b, c, d, e, f) {
  7065. cc.log(cc._LogInfos.Texture2D_initWithString);
  7066. return null
  7067. },
  7068. initWithETCFile: function(a) {
  7069. cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
  7070. return !1
  7071. },
  7072. initWithPVRFile: function(a) {
  7073. cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);
  7074. return !1
  7075. },
  7076. initWithPVRTCData: function(a, b, c, d, e, f) {
  7077. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);
  7078. return !1
  7079. },
  7080. setTexParameters: function(a, b, c, d) {
  7081. var e = cc._renderContext;
  7082. void 0 !== b && (a = {
  7083. minFilter: a,
  7084. magFilter: b,
  7085. wrapS: c,
  7086. wrapT: d
  7087. });
  7088. cc.assert(this._pixelsWide === cc.NextPOT(this._pixelsWide) && this._pixelsHigh === cc.NextPOT(this._pixelsHigh) || a.wrapS === e.CLAMP_TO_EDGE && a.wrapT === e.CLAMP_TO_EDGE, "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures");
  7089. cc.glBindTexture2D(this);
  7090. e.texParameteri(e.TEXTURE_2D,
  7091. e.TEXTURE_MIN_FILTER, a.minFilter);
  7092. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, a.magFilter);
  7093. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, a.wrapS);
  7094. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, a.wrapT)
  7095. },
  7096. setAntiAliasTexParameters: function() {
  7097. var a = cc._renderContext;
  7098. cc.glBindTexture2D(this);
  7099. 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);
  7100. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR)
  7101. },
  7102. setAliasTexParameters: function() {
  7103. var a = cc._renderContext;
  7104. cc.glBindTexture2D(this);
  7105. 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);
  7106. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
  7107. },
  7108. generateMipmap: function() {
  7109. cc.assert(this._pixelsWide === cc.NextPOT(this._pixelsWide) && this._pixelsHigh === cc.NextPOT(this._pixelsHigh), "Mimpap texture only works in POT textures");
  7110. cc.glBindTexture2D(this);
  7111. cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
  7112. this._hasMipmaps = !0
  7113. },
  7114. stringForFormat: function() {
  7115. return cc.Texture2D._M[this._pixelFormat]
  7116. },
  7117. bitsPerPixelForFormat: function(a) {
  7118. a = a || this._pixelFormat;
  7119. var b = cc.Texture2D._B[a];
  7120. if (null != b) return b;
  7121. cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, a);
  7122. return -1
  7123. },
  7124. _initPremultipliedATextureWithImage: function(a, b, c) {
  7125. var d = cc.Texture2D,
  7126. e = a.getData(),
  7127. f = null,
  7128. f = null,
  7129. g = a.hasAlpha(),
  7130. h = cc.size(a.getWidth(), a.getHeight()),
  7131. k = d.defaultPixelFormat,
  7132. m = a.getBitsPerComponent();
  7133. g || (8 <= m ? k = d.PIXEL_FORMAT_RGB888 : (cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage), k = d.PIXEL_FORMAT_RGB565));
  7134. var n = b * c;
  7135. if (k === d.PIXEL_FORMAT_RGB565)
  7136. if (g)
  7137. for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 3 << 11 | (f[m] >> 8 & 255) >> 2 << 5 | (f[m] >> 16 & 255) >> 3 << 0;
  7138. else
  7139. for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] & 255) >> 3 << 11 | (f[m] & 255) >> 2 << 5 | (f[m] & 255) >> 3 << 0;
  7140. else if (k === d.PIXEL_FORMAT_RGBA4444)
  7141. for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >>
  7142. 0 & 255) >> 4 << 12 | (f[m] >> 8 & 255) >> 4 << 8 | (f[m] >> 16 & 255) >> 4 << 4 | (f[m] >> 24 & 255) >> 4 << 0;
  7143. else if (k === d.PIXEL_FORMAT_RGB5A1)
  7144. for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 3 << 11 | (f[m] >> 8 & 255) >> 3 << 6 | (f[m] >> 16 & 255) >> 3 << 1 | (f[m] >> 24 & 255) >> 7 << 0;
  7145. else if (k === d.PIXEL_FORMAT_A8)
  7146. for (e = new Uint8Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = f >> 24 & 255;
  7147. if (g && k === d.PIXEL_FORMAT_RGB888)
  7148. for (f = a.getData(), e = new Uint8Array(b * c * 3), m = 0; m < n; ++m) e[3 * m] = f >> 0 & 255, e[3 * m + 1] = f >> 8 & 255, e[3 * m + 2] = f >> 16 & 255;
  7149. this.initWithData(e,
  7150. k, b, c, h);
  7151. a.getData();
  7152. this._hasPremultipliedAlpha = a.isPremultipliedAlpha();
  7153. return !0
  7154. },
  7155. addLoadedEventListener: function(a, b) {
  7156. this.addEventListener("load", a, b)
  7157. },
  7158. removeLoadedEventListener: function(a) {
  7159. this.removeEventListener("load", a)
  7160. }
  7161. })
  7162. };
  7163. cc._tmp.WebGLTextureAtlas = function() {
  7164. var a = cc.TextureAtlas.prototype;
  7165. a._setupVBO = function() {
  7166. var a = cc._renderContext;
  7167. this._buffersVBO[0] = a.createBuffer();
  7168. this._buffersVBO[1] = a.createBuffer();
  7169. this._quadsWebBuffer = a.createBuffer();
  7170. this._mapBuffers()
  7171. };
  7172. a._mapBuffers = function() {
  7173. var a = cc._renderContext;
  7174. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  7175. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  7176. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  7177. a.bufferData(a.ELEMENT_ARRAY_BUFFER,
  7178. this._indices, a.STATIC_DRAW)
  7179. };
  7180. a.drawNumberOfQuads = function(a, c) {
  7181. c = c || 0;
  7182. if (0 !== a && this.texture && this.texture.isLoaded()) {
  7183. var d = cc._renderContext;
  7184. cc.glBindTexture2D(this.texture);
  7185. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  7186. d.bindBuffer(d.ARRAY_BUFFER, this._quadsWebBuffer);
  7187. this.dirty && (d.bufferData(d.ARRAY_BUFFER, this._quadsArrayBuffer, d.DYNAMIC_DRAW), this.dirty = !1);
  7188. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, d.FLOAT, !1, 24, 0);
  7189. d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, d.UNSIGNED_BYTE, !0, 24, 12);
  7190. d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 24, 16);
  7191. d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  7192. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? d.drawElements(d.TRIANGLE_STRIP, 6 * a, d.UNSIGNED_SHORT, 6 * c * this._indices.BYTES_PER_ELEMENT) : d.drawElements(d.TRIANGLES, 6 * a, d.UNSIGNED_SHORT, 6 * c * this._indices.BYTES_PER_ELEMENT);
  7193. cc.g_NumberOfDraws++
  7194. }
  7195. }
  7196. };
  7197. cc._tmp.WebGLTextureCache = function() {
  7198. var a = cc.textureCache;
  7199. a.handleLoadedTexture = function(a) {
  7200. var c = this._textures;
  7201. cc._rendererInitialized || (c = this._loadedTexturesBefore);
  7202. var d = c[a];
  7203. d || (d = c[a] = new cc.Texture2D, d.url = a);
  7204. d.handleLoadedTexture()
  7205. };
  7206. a.addImage = function(a, c, d) {
  7207. cc.assert(a, cc._LogInfos.Texture2D_addImage_2);
  7208. var e = this._textures;
  7209. cc._rendererInitialized || (e = this._loadedTexturesBefore);
  7210. var f = e[a] || e[cc.loader._aliases[a]];
  7211. if (f) return c && c.call(d, f), f;
  7212. f = e[a] = new cc.Texture2D;
  7213. f.url = a;
  7214. (cc.loader._checkIsImageURL(a) ?
  7215. cc.loader.load : cc.loader.loadImg).call(cc.loader, a, function(f, h) {
  7216. if (f) return c && c.call(d, f);
  7217. cc.textureCache.handleLoadedTexture(a);
  7218. var k = e[a];
  7219. c && c.call(d, k)
  7220. });
  7221. return f
  7222. };
  7223. a.addImageAsync = a.addImage;
  7224. a = null
  7225. };
  7226. cc._tmp.PrototypeTexture2D = function() {
  7227. var a = cc.Texture2D;
  7228. a.PVRImagesHavePremultipliedAlpha = function(a) {
  7229. cc.PVRHaveAlphaPremultiplied_ = a
  7230. };
  7231. a.PIXEL_FORMAT_RGBA8888 = 2;
  7232. a.PIXEL_FORMAT_RGB888 = 3;
  7233. a.PIXEL_FORMAT_RGB565 = 4;
  7234. a.PIXEL_FORMAT_A8 = 5;
  7235. a.PIXEL_FORMAT_I8 = 6;
  7236. a.PIXEL_FORMAT_AI88 = 7;
  7237. a.PIXEL_FORMAT_RGBA4444 = 8;
  7238. a.PIXEL_FORMAT_RGB5A1 = 7;
  7239. a.PIXEL_FORMAT_PVRTC4 = 9;
  7240. a.PIXEL_FORMAT_PVRTC2 = 10;
  7241. a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888;
  7242. var b = cc.Texture2D._M = {};
  7243. b[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888";
  7244. b[a.PIXEL_FORMAT_RGB888] =
  7245. "RGB888";
  7246. b[a.PIXEL_FORMAT_RGB565] = "RGB565";
  7247. b[a.PIXEL_FORMAT_A8] = "A8";
  7248. b[a.PIXEL_FORMAT_I8] = "I8";
  7249. b[a.PIXEL_FORMAT_AI88] = "AI88";
  7250. b[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444";
  7251. b[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1";
  7252. b[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4";
  7253. b[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2";
  7254. b = cc.Texture2D._B = {};
  7255. b[a.PIXEL_FORMAT_RGBA8888] = 32;
  7256. b[a.PIXEL_FORMAT_RGB888] = 24;
  7257. b[a.PIXEL_FORMAT_RGB565] = 16;
  7258. b[a.PIXEL_FORMAT_A8] = 8;
  7259. b[a.PIXEL_FORMAT_I8] = 8;
  7260. b[a.PIXEL_FORMAT_AI88] = 16;
  7261. b[a.PIXEL_FORMAT_RGBA4444] = 16;
  7262. b[a.PIXEL_FORMAT_RGB5A1] = 16;
  7263. b[a.PIXEL_FORMAT_PVRTC4] = 4;
  7264. b[a.PIXEL_FORMAT_PVRTC2] = 3;
  7265. b = cc.Texture2D.prototype;
  7266. cc.defineGetterSetter(b, "name", b.getName);
  7267. cc.defineGetterSetter(b, "pixelFormat", b.getPixelFormat);
  7268. cc.defineGetterSetter(b, "pixelsWidth", b.getPixelsWide);
  7269. cc.defineGetterSetter(b, "pixelsHeight", b.getPixelsHigh);
  7270. cc.defineGetterSetter(b, "width", b._getWidth);
  7271. cc.defineGetterSetter(b, "height", b._getHeight);
  7272. a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT
  7273. };
  7274. cc._tmp.PrototypeTextureAtlas = function() {
  7275. var a = cc.TextureAtlas.prototype;
  7276. cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads);
  7277. cc.defineGetterSetter(a, "capacity", a.getCapacity);
  7278. cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads)
  7279. };
  7280. cc.ALIGN_CENTER = 51;
  7281. cc.ALIGN_TOP = 19;
  7282. cc.ALIGN_TOP_RIGHT = 18;
  7283. cc.ALIGN_RIGHT = 50;
  7284. cc.ALIGN_BOTTOM_RIGHT = 34;
  7285. cc.ALIGN_BOTTOM = 35;
  7286. cc.ALIGN_BOTTOM_LEFT = 33;
  7287. cc.ALIGN_LEFT = 49;
  7288. cc.ALIGN_TOP_LEFT = 17;
  7289. cc.PVRHaveAlphaPremultiplied_ = !1;
  7290. cc._renderType === cc._RENDER_TYPE_CANVAS ? (cc.Texture2D = cc.Class.extend({
  7291. _contentSize: null,
  7292. _textureLoaded: !1,
  7293. _htmlElementObj: null,
  7294. url: null,
  7295. _pattern: null,
  7296. ctor: function() {
  7297. this._contentSize = cc.size(0, 0);
  7298. this._textureLoaded = !1;
  7299. this._htmlElementObj = null;
  7300. this._pattern = ""
  7301. },
  7302. getPixelsWide: function() {
  7303. return this._contentSize.width
  7304. },
  7305. getPixelsHigh: function() {
  7306. return this._contentSize.height
  7307. },
  7308. getContentSize: function() {
  7309. var a = cc.contentScaleFactor();
  7310. return cc.size(this._contentSize.width / a, this._contentSize.height /
  7311. a)
  7312. },
  7313. _getWidth: function() {
  7314. return this._contentSize.width / cc.contentScaleFactor()
  7315. },
  7316. _getHeight: function() {
  7317. return this._contentSize.height / cc.contentScaleFactor()
  7318. },
  7319. getContentSizeInPixels: function() {
  7320. return this._contentSize
  7321. },
  7322. initWithElement: function(a) {
  7323. a && (this._htmlElementObj = a, this._contentSize.width = a.width, this._contentSize.height = a.height, this._textureLoaded = !0)
  7324. },
  7325. getHtmlElementObj: function() {
  7326. return this._htmlElementObj
  7327. },
  7328. isLoaded: function() {
  7329. return this._textureLoaded
  7330. },
  7331. handleLoadedTexture: function() {
  7332. if (!this._textureLoaded) {
  7333. if (!this._htmlElementObj) {
  7334. var a =
  7335. cc.loader.getRes(this.url);
  7336. if (!a) return;
  7337. this.initWithElement(a)
  7338. }
  7339. a = this._htmlElementObj;
  7340. this._contentSize.width = a.width;
  7341. this._contentSize.height = a.height;
  7342. this.dispatchEvent("load")
  7343. }
  7344. },
  7345. description: function() {
  7346. return "\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e"
  7347. },
  7348. initWithData: function(a, b, c, d, e) {
  7349. return !1
  7350. },
  7351. initWithImage: function(a) {
  7352. return !1
  7353. },
  7354. initWithString: function(a, b, c, d, e, f) {
  7355. return !1
  7356. },
  7357. releaseTexture: function() {
  7358. cc.loader.release(this.url)
  7359. },
  7360. getName: function() {
  7361. return null
  7362. },
  7363. getMaxS: function() {
  7364. return 1
  7365. },
  7366. setMaxS: function(a) {},
  7367. getMaxT: function() {
  7368. return 1
  7369. },
  7370. setMaxT: function(a) {},
  7371. getPixelFormat: function() {
  7372. return null
  7373. },
  7374. getShaderProgram: function() {
  7375. return null
  7376. },
  7377. setShaderProgram: function(a) {},
  7378. hasPremultipliedAlpha: function() {
  7379. return !1
  7380. },
  7381. hasMipmaps: function() {
  7382. return !1
  7383. },
  7384. releaseData: function(a) {},
  7385. keepData: function(a, b) {
  7386. return a
  7387. },
  7388. drawAtPoint: function(a) {},
  7389. drawInRect: function(a) {},
  7390. initWithETCFile: function(a) {
  7391. cc.log(cc._LogInfos.Texture2D_initWithETCFile);
  7392. return !1
  7393. },
  7394. initWithPVRFile: function(a) {
  7395. cc.log(cc._LogInfos.Texture2D_initWithPVRFile);
  7396. return !1
  7397. },
  7398. initWithPVRTCData: function(a, b, c, d, e, f) {
  7399. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);
  7400. return !1
  7401. },
  7402. setTexParameters: function(a, b, c, d) {
  7403. void 0 !== b && (a = {
  7404. minFilter: a,
  7405. magFilter: b,
  7406. wrapS: c,
  7407. wrapT: d
  7408. });
  7409. this._pattern = a.wrapS === cc.REPEAT && a.wrapT === cc.REPEAT ? "repeat" : a.wrapS === cc.REPEAT ? "repeat-x" : a.wrapT === cc.REPEAT ? "repeat-y" : ""
  7410. },
  7411. setAntiAliasTexParameters: function() {},
  7412. setAliasTexParameters: function() {},
  7413. generateMipmap: function() {},
  7414. stringForFormat: function() {
  7415. return ""
  7416. },
  7417. bitsPerPixelForFormat: function(a) {
  7418. return -1
  7419. },
  7420. addLoadedEventListener: function(a, b) {
  7421. this.addEventListener("load", a, b)
  7422. },
  7423. removeLoadedEventListener: function(a) {
  7424. this.removeEventListener("load", a)
  7425. },
  7426. _grayElementObj: null,
  7427. _backupElement: null,
  7428. _isGray: !1,
  7429. _switchToGray: function(a) {
  7430. this._textureLoaded && this._isGray !== a && ((this._isGray = a) ? (this._backupElement = this._htmlElementObj, this._grayElementObj || (this._grayElementObj = cc.Texture2D._generateGrayTexture(this._htmlElementObj)), this._htmlElementObj = this._grayElementObj) : null !== this._backupElement && (this._htmlElementObj =
  7431. this._backupElement))
  7432. }
  7433. }), cc.Texture2D._generateGrayTexture = function(a, b, c) {
  7434. if (null === a) return null;
  7435. c = c || cc.newElement("canvas");
  7436. b = b || cc.rect(0, 0, a.width, a.height);
  7437. c.width = b.width;
  7438. c.height = b.height;
  7439. var d = c.getContext("2d");
  7440. d.drawImage(a, b.x, b.y, b.width, b.height, 0, 0, b.width, b.height);
  7441. a = d.getImageData(0, 0, b.width, b.height);
  7442. b = a.data;
  7443. for (var e = 0, f = b.length; e < f; e += 4) b[e] = b[e + 1] = b[e + 2] = 0.34 * b[e] + 0.5 * b[e + 1] + 0.16 * b[e + 2];
  7444. d.putImageData(a, 0, 0);
  7445. return c
  7446. }) : (cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D), cc._LogInfos.MissingFile,
  7447. "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D);
  7448. cc.EventHelper.prototype.apply(cc.Texture2D.prototype);
  7449. cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  7450. cc._tmp.PrototypeTexture2D();
  7451. delete cc._tmp.PrototypeTexture2D;
  7452. cc.textureCache = {
  7453. _textures: {},
  7454. _textureColorsCache: {},
  7455. _textureKeySeq: 0 | 1E3 * Math.random(),
  7456. _loadedTexturesBefore: {},
  7457. _initializingRenderer: function() {
  7458. var a, b = this._loadedTexturesBefore,
  7459. c = this._textures;
  7460. for (a in b) {
  7461. var d = b[a];
  7462. d.handleLoadedTexture();
  7463. c[a] = d
  7464. }
  7465. this._loadedTexturesBefore = {}
  7466. },
  7467. addPVRTCImage: function(a) {
  7468. cc.log(cc._LogInfos.textureCache_addPVRTCImage)
  7469. },
  7470. addETCImage: function(a) {
  7471. cc.log(cc._LogInfos.textureCache_addETCImage)
  7472. },
  7473. description: function() {
  7474. return "\x3cTextureCache | Number of textures \x3d " +
  7475. this._textures.length + "\x3e"
  7476. },
  7477. textureForKey: function(a) {
  7478. cc.log(cc._LogInfos.textureCache_textureForKey);
  7479. return this.getTextureForKey(a)
  7480. },
  7481. getTextureForKey: function(a) {
  7482. return this._textures[a] || this._textures[cc.loader._aliases[a]]
  7483. },
  7484. getKeyByTexture: function(a) {
  7485. for (var b in this._textures)
  7486. if (this._textures[b] === a) return b;
  7487. return null
  7488. },
  7489. _generalTextureKey: function() {
  7490. this._textureKeySeq++;
  7491. return "_textureKey_" + this._textureKeySeq
  7492. },
  7493. getTextureColors: function(a) {
  7494. var b = this.getKeyByTexture(a);
  7495. b || (b = a instanceof HTMLImageElement ? a.src : this._generalTextureKey());
  7496. this._textureColorsCache[b] || (this._textureColorsCache[b] = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor(a));
  7497. return this._textureColorsCache[b]
  7498. },
  7499. addPVRImage: function(a) {
  7500. cc.log(cc._LogInfos.textureCache_addPVRImage)
  7501. },
  7502. removeAllTextures: function() {
  7503. var a = this._textures,
  7504. b;
  7505. for (b in a) a[b] && a[b].releaseTexture();
  7506. this._textures = {}
  7507. },
  7508. removeTexture: function(a) {
  7509. if (a) {
  7510. var b = this._textures,
  7511. c;
  7512. for (c in b) b[c] === a && (b[c].releaseTexture(), delete b[c])
  7513. }
  7514. },
  7515. removeTextureForKey: function(a) {
  7516. null !=
  7517. a && this._textures[a] && delete this._textures[a]
  7518. },
  7519. cacheImage: function(a, b) {
  7520. if (b instanceof cc.Texture2D) this._textures[a] = b;
  7521. else {
  7522. var c = new cc.Texture2D;
  7523. c.initWithElement(b);
  7524. c.handleLoadedTexture();
  7525. this._textures[a] = c
  7526. }
  7527. },
  7528. addUIImage: function(a, b) {
  7529. cc.assert(a, cc._LogInfos.textureCache_addUIImage_2);
  7530. if (b && this._textures[b]) return this._textures[b];
  7531. var c = new cc.Texture2D;
  7532. c.initWithImage(a);
  7533. null != b ? this._textures[b] = c : cc.log(cc._LogInfos.textureCache_addUIImage);
  7534. return c
  7535. },
  7536. dumpCachedTextureInfo: function() {
  7537. var a =
  7538. 0,
  7539. b = 0,
  7540. c = this._textures,
  7541. d;
  7542. for (d in c) {
  7543. var e = c[d];
  7544. a++;
  7545. e.getHtmlElementObj() instanceof HTMLImageElement ? cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo, d, e.getHtmlElementObj().src, e.pixelsWidth, e.pixelsHeight) : cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, e.pixelsWidth, e.pixelsHeight);
  7546. b += e.pixelsWidth * e.pixelsHeight * 4
  7547. }
  7548. c = this._textureColorsCache;
  7549. for (d in c) {
  7550. var e = c[d],
  7551. f;
  7552. for (f in e) {
  7553. var g = e[f];
  7554. a++;
  7555. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, g.width, g.height);
  7556. b += g.width *
  7557. g.height * 4
  7558. }
  7559. }
  7560. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, b / 1024, (b / 1048576).toFixed(2))
  7561. },
  7562. _clear: function() {
  7563. this._textures = {};
  7564. this._textureColorsCache = {};
  7565. this._textureKeySeq = 0 | 1E3 * Math.random();
  7566. this._loadedTexturesBefore = {}
  7567. }
  7568. };
  7569. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function(a) {
  7570. var b = this._textures,
  7571. c = b[a];
  7572. c || (c = b[a] = new cc.Texture2D, c.url = a);
  7573. c.handleLoadedTexture()
  7574. }, _p.addImage = function(a, b, c) {
  7575. cc.assert(a, cc._LogInfos.Texture2D_addImage);
  7576. var d = this._textures,
  7577. e = d[a] || d[cc.loader._aliases[a]];
  7578. if (e) return b && b.call(c, e), e;
  7579. e = d[a] = new cc.Texture2D;
  7580. e.url = a;
  7581. (cc.loader._checkIsImageURL(a) ? cc.loader.load : cc.loader.loadImg).call(cc.loader, a, function(e, g) {
  7582. if (e) return b && b.call(c, e);
  7583. cc.textureCache.handleLoadedTexture(a);
  7584. var h = d[a];
  7585. b && b.call(c, h)
  7586. });
  7587. return e
  7588. }, _p.addImageAsync = _p.addImage, _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache);
  7589. cc.TextureAtlas = cc.Class.extend({
  7590. dirty: !1,
  7591. texture: null,
  7592. _indices: null,
  7593. _buffersVBO: null,
  7594. _capacity: 0,
  7595. _quads: null,
  7596. _quadsArrayBuffer: null,
  7597. _quadsWebBuffer: null,
  7598. _quadsReader: null,
  7599. ctor: function(a, b) {
  7600. this._buffersVBO = [];
  7601. cc.isString(a) ? this.initWithFile(a, b) : a instanceof cc.Texture2D && this.initWithTexture(a, b)
  7602. },
  7603. getTotalQuads: function() {
  7604. return this._totalQuads
  7605. },
  7606. getCapacity: function() {
  7607. return this._capacity
  7608. },
  7609. getTexture: function() {
  7610. return this.texture
  7611. },
  7612. setTexture: function(a) {
  7613. this.texture = a
  7614. },
  7615. setDirty: function(a) {
  7616. this.dirty =
  7617. a
  7618. },
  7619. isDirty: function() {
  7620. return this.dirty
  7621. },
  7622. getQuads: function() {
  7623. return this._quads
  7624. },
  7625. setQuads: function(a) {
  7626. this._quads = a
  7627. },
  7628. _copyQuadsToTextureAtlas: function(a, b) {
  7629. if (a)
  7630. for (var c = 0; c < a.length; c++) this._setQuadToArray(a[c], b + c)
  7631. },
  7632. _setQuadToArray: function(a, b) {
  7633. var c = this._quads;
  7634. c[b] ? (c[b].bl = a.bl, c[b].br = a.br, c[b].tl = a.tl, c[b].tr = a.tr) : c[b] = new cc.V3F_C4B_T2F_Quad(a.tl, a.bl, a.tr, a.br, this._quadsArrayBuffer, b * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT)
  7635. },
  7636. description: function() {
  7637. return "\x3ccc.TextureAtlas | totalQuads \x3d" +
  7638. this._totalQuads + "\x3e"
  7639. },
  7640. _setupIndices: function() {
  7641. if (0 !== this._capacity)
  7642. for (var a = this._indices, b = this._capacity, c = 0; c < b; c++) cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP ? (a[6 * c + 0] = 4 * c + 0, a[6 * c + 1] = 4 * c + 0, a[6 * c + 2] = 4 * c + 2, a[6 * c + 3] = 4 * c + 1, a[6 * c + 4] = 4 * c + 3, a[6 * c + 5] = 4 * c + 3) : (a[6 * c + 0] = 4 * c + 0, a[6 * c + 1] = 4 * c + 1, a[6 * c + 2] = 4 * c + 2, a[6 * c + 3] = 4 * c + 3, a[6 * c + 4] = 4 * c + 2, a[6 * c + 5] = 4 * c + 1)
  7643. },
  7644. _setupVBO: function() {
  7645. var a = cc._renderContext;
  7646. this._buffersVBO[0] = a.createBuffer();
  7647. this._buffersVBO[1] = a.createBuffer();
  7648. this._quadsWebBuffer = a.createBuffer();
  7649. this._mapBuffers()
  7650. },
  7651. _mapBuffers: function() {
  7652. var a = cc._renderContext;
  7653. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  7654. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  7655. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  7656. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  7657. },
  7658. initWithFile: function(a, b) {
  7659. var c = cc.textureCache.addImage(a);
  7660. if (c) return this.initWithTexture(c, b);
  7661. cc.log(cc._LogInfos.TextureAtlas_initWithFile, a);
  7662. return !1
  7663. },
  7664. initWithTexture: function(a, b) {
  7665. cc.assert(a,
  7666. cc._LogInfos.TextureAtlas_initWithTexture);
  7667. this._capacity = b |= 0;
  7668. this._totalQuads = 0;
  7669. this.texture = a;
  7670. this._quads = [];
  7671. this._indices = new Uint16Array(6 * b);
  7672. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7673. this._quadsArrayBuffer = new ArrayBuffer(c * b);
  7674. this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
  7675. if ((!this._quads || !this._indices) && 0 < b) return !1;
  7676. for (var d = this._quads, e = 0; e < b; e++) d[e] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, e * c);
  7677. this._setupIndices();
  7678. this._setupVBO();
  7679. return this.dirty = !0
  7680. },
  7681. updateQuad: function(a, b) {
  7682. cc.assert(a, cc._LogInfos.TextureAtlas_updateQuad);
  7683. cc.assert(0 <= b && b < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2);
  7684. this._totalQuads = Math.max(b + 1, this._totalQuads);
  7685. this._setQuadToArray(a, b);
  7686. this.dirty = !0
  7687. },
  7688. insertQuad: function(a, b) {
  7689. cc.assert(b < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2);
  7690. this._totalQuads++;
  7691. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  7692. else {
  7693. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7694. d = b * c,
  7695. e = (this._totalQuads -
  7696. 1 - b) * c;
  7697. this._quads[this._totalQuads - 1] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * c);
  7698. this._quadsReader.set(this._quadsReader.subarray(d, d + e), d + c);
  7699. this._setQuadToArray(a, b);
  7700. this.dirty = !0
  7701. }
  7702. },
  7703. insertQuads: function(a, b, c) {
  7704. c = c || a.length;
  7705. cc.assert(b + c <= this._capacity, cc._LogInfos.TextureAtlas_insertQuads);
  7706. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7707. this._totalQuads += c;
  7708. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  7709. else {
  7710. var e = b *
  7711. d,
  7712. f = (this._totalQuads - 1 - b - c) * d,
  7713. g = this._totalQuads - 1 - c,
  7714. h;
  7715. for (h = 0; h < c; h++) this._quads[g + h] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * d);
  7716. this._quadsReader.set(this._quadsReader.subarray(e, e + f), e + d * c);
  7717. for (h = 0; h < c; h++) this._setQuadToArray(a[h], b + h);
  7718. this.dirty = !0
  7719. }
  7720. },
  7721. insertQuadFromIndex: function(a, b) {
  7722. if (a !== b) {
  7723. cc.assert(0 <= b || b < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex);
  7724. cc.assert(0 <= a || a < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex_2);
  7725. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7726. d = this._quadsReader,
  7727. e = d.subarray(a * c, c),
  7728. f;
  7729. a > b ? (f = b * c, d.set(d.subarray(f, f + (a - b) * c), f + c), d.set(e, f)) : (f = (a + 1) * c, d.set(d.subarray(f, f + (b - a) * c), f - c), d.set(e, b * c));
  7730. this.dirty = !0
  7731. }
  7732. },
  7733. removeQuadAtIndex: function(a) {
  7734. cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex);
  7735. var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7736. this._totalQuads--;
  7737. this._quads.length = this._totalQuads;
  7738. if (a !== this._totalQuads) {
  7739. var c = (a + 1) * b;
  7740. this._quadsReader.set(this._quadsReader.subarray(c,
  7741. c + (this._totalQuads - a) * b), c - b)
  7742. }
  7743. this.dirty = !0
  7744. },
  7745. removeQuadsAtIndex: function(a, b) {
  7746. cc.assert(a + b <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex);
  7747. this._totalQuads -= b;
  7748. if (a !== this._totalQuads) {
  7749. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7750. d = (a + b) * c,
  7751. e = a * c;
  7752. this._quadsReader.set(this._quadsReader.subarray(d, d + (this._totalQuads - a) * c), e)
  7753. }
  7754. this.dirty = !0
  7755. },
  7756. removeAllQuads: function() {
  7757. this._totalQuads = this._quads.length = 0
  7758. },
  7759. _setDirty: function(a) {
  7760. this.dirty = a
  7761. },
  7762. resizeCapacity: function(a) {
  7763. if (a === this._capacity) return !0;
  7764. var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7765. c = this._capacity;
  7766. this._totalQuads = Math.min(this._totalQuads, a);
  7767. var d = this._capacity = 0 | a,
  7768. e = this._totalQuads;
  7769. if (null === this._quads)
  7770. for (this._quads = [], this._quadsArrayBuffer = new ArrayBuffer(b * d), this._quadsReader = new Uint8Array(this._quadsArrayBuffer), a = 0; a < d; a++) this._quads = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, a * b);
  7771. else {
  7772. var f, g, h = this._quads;
  7773. if (d > c) {
  7774. f = [];
  7775. g = new ArrayBuffer(b * d);
  7776. for (a = 0; a < e; a++) f[a] = new cc.V3F_C4B_T2F_Quad(h[a].tl,
  7777. h[a].bl, h[a].tr, h[a].br, g, a * b);
  7778. for (; a < d; a++) f[a] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, g, a * b)
  7779. } else
  7780. for (e = Math.max(e, d), f = [], g = new ArrayBuffer(b * d), a = 0; a < e; a++) f[a] = new cc.V3F_C4B_T2F_Quad(h[a].tl, h[a].bl, h[a].tr, h[a].br, g, a * b);
  7781. this._quadsReader = new Uint8Array(g);
  7782. this._quads = f;
  7783. this._quadsArrayBuffer = g
  7784. }
  7785. null === this._indices ? this._indices = new Uint16Array(6 * d) : d > c ? (b = new Uint16Array(6 * d), b.set(this._indices, 0), this._indices = b) : this._indices = this._indices.subarray(0, 6 * d);
  7786. this._setupIndices();
  7787. this._mapBuffers();
  7788. return this.dirty = !0
  7789. },
  7790. increaseTotalQuadsWith: function(a) {
  7791. this._totalQuads += a
  7792. },
  7793. moveQuadsFromIndex: function(a, b, c) {
  7794. if (void 0 === c) {
  7795. if (c = b, b = this._totalQuads - a, cc.assert(c + (this._totalQuads - a) <= this._capacity, cc._LogInfos.TextureAtlas_moveQuadsFromIndex), 0 === b) return
  7796. } else if (cc.assert(c + b <= this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2), cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_moveQuadsFromIndex_3), a === c) return;
  7797. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7798. e = a * d,
  7799. f = b * d,
  7800. g = this._quadsReader,
  7801. h = g.subarray(e, e + f),
  7802. k = c * d;
  7803. c < a ? (b = c * d, g.set(g.subarray(b, b + (a - c) * d), b + f)) : (b = (a + b) * d, g.set(g.subarray(b, b + (c - a) * d), e));
  7804. g.set(h, k);
  7805. this.dirty = !0
  7806. },
  7807. fillWithEmptyQuadsFromIndex: function(a, b) {
  7808. for (var c = b * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, d = new Uint8Array(this._quadsArrayBuffer, a * cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT, c), e = 0; e < c; e++) d[e] = 0
  7809. },
  7810. drawQuads: function() {
  7811. this.drawNumberOfQuads(this._totalQuads, 0)
  7812. },
  7813. _releaseBuffer: function() {
  7814. var a = cc._renderContext;
  7815. this._buffersVBO && (this._buffersVBO[0] && a.deleteBuffer(this._buffersVBO[0]),
  7816. this._buffersVBO[1] && a.deleteBuffer(this._buffersVBO[1]));
  7817. this._quadsWebBuffer && a.deleteBuffer(this._quadsWebBuffer)
  7818. }
  7819. });
  7820. _p = cc.TextureAtlas.prototype;
  7821. cc.defineGetterSetter(_p, "totalQuads", _p.getTotalQuads);
  7822. cc.defineGetterSetter(_p, "capacity", _p.getCapacity);
  7823. cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads);
  7824. cc.TextureAtlas.create = function(a, b) {
  7825. return new cc.TextureAtlas(a, b)
  7826. };
  7827. cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create;
  7828. cc._renderType === cc._RENDER_TYPE_WEBGL && (cc.assert(cc.isFunction(cc._tmp.WebGLTextureAtlas), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureAtlas(), delete cc._tmp.WebGLTextureAtlas);
  7829. cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  7830. cc._tmp.PrototypeTextureAtlas();
  7831. delete cc._tmp.PrototypeTextureAtlas;
  7832. cc.Scene = cc.Node.extend({
  7833. _className: "Scene",
  7834. ctor: function() {
  7835. cc.Node.prototype.ctor.call(this);
  7836. this._ignoreAnchorPointForPosition = !0;
  7837. this.setAnchorPoint(0.5, 0.5);
  7838. this.setContentSize(cc.director.getWinSize())
  7839. }
  7840. });
  7841. cc.Scene.create = function() {
  7842. return new cc.Scene
  7843. };
  7844. cc.LoaderScene = cc.Scene.extend({
  7845. _interval: null,
  7846. _label: null,
  7847. _className: "LoaderScene",
  7848. init: function() {
  7849. var a = this,
  7850. b = 200,
  7851. c = a._bgLayer = new cc.LayerColor(cc.color(32, 32, 32, 255));
  7852. a.addChild(c, 0);
  7853. var d = 24,
  7854. e = -b / 2 + 100;
  7855. cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, {
  7856. isCrossOrigin: !1
  7857. }, function(c, d) {
  7858. b = d.height;
  7859. a._initStage(d, cc.visibleRect.center)
  7860. }), d = 14, e = -b / 2 - 10);
  7861. d = a._label = new cc.LabelTTF("Loading... 0%", "Arial", d);
  7862. d.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, e)));
  7863. d.setColor(cc.color(180, 180, 180));
  7864. c.addChild(this._label, 10);
  7865. return !0
  7866. },
  7867. _initStage: function(a, b) {
  7868. var c = this._texture2d = new cc.Texture2D;
  7869. c.initWithElement(a);
  7870. c.handleLoadedTexture();
  7871. c = this._logo = new cc.Sprite(c);
  7872. c.setScale(cc.contentScaleFactor());
  7873. c.x = b.x;
  7874. c.y = b.y;
  7875. this._bgLayer.addChild(c, 10)
  7876. },
  7877. onEnter: function() {
  7878. cc.Node.prototype.onEnter.call(this);
  7879. this.schedule(this._startLoading, 0.3)
  7880. },
  7881. onExit: function() {
  7882. cc.Node.prototype.onExit.call(this);
  7883. this._label.setString("Loading... 0%")
  7884. },
  7885. initWithResources: function(a, b) {
  7886. cc.isString(a) && (a = [a]);
  7887. this.resources = a || [];
  7888. this.cb = b
  7889. },
  7890. _startLoading: function() {
  7891. var a = this;
  7892. a.unschedule(a._startLoading);
  7893. cc.loader.load(a.resources, function(b, c, d) {
  7894. b = Math.min(d / c * 100 | 0, 100);
  7895. a._label.setString("Loading... " + b + "%")
  7896. }, function() {
  7897. a.cb && a.cb()
  7898. })
  7899. }
  7900. });
  7901. cc.LoaderScene.preload = function(a, b) {
  7902. var c = cc;
  7903. c.loaderScene || (c.loaderScene = new cc.LoaderScene, c.loaderScene.init());
  7904. c.loaderScene.initWithResources(a, b);
  7905. cc.director.runScene(c.loaderScene);
  7906. return c.loaderScene
  7907. };
  7908. cc.Layer = cc.Node.extend({
  7909. _className: "Layer",
  7910. ctor: function() {
  7911. var a = cc.Node.prototype;
  7912. a.ctor.call(this);
  7913. this._ignoreAnchorPointForPosition = !0;
  7914. a.setAnchorPoint.call(this, 0.5, 0.5);
  7915. a.setContentSize.call(this, cc.winSize)
  7916. },
  7917. init: function() {
  7918. this._ignoreAnchorPointForPosition = !0;
  7919. this.setAnchorPoint(0.5, 0.5);
  7920. this.setContentSize(cc.winSize);
  7921. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1;
  7922. return !0
  7923. },
  7924. bake: function() {
  7925. this._renderCmd.bake()
  7926. },
  7927. unbake: function() {
  7928. this._renderCmd.unbake()
  7929. },
  7930. isBaked: function() {
  7931. return this._isBaked
  7932. },
  7933. addChild: function(a, b, c) {
  7934. cc.Node.prototype.addChild.call(this, a, b, c);
  7935. this._renderCmd._bakeForAddChild(a)
  7936. },
  7937. _createRenderCmd: function() {
  7938. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Layer.CanvasRenderCmd(this) : new cc.Layer.WebGLRenderCmd(this)
  7939. }
  7940. });
  7941. cc.Layer.create = function() {
  7942. return new cc.Layer
  7943. };
  7944. cc.LayerColor = cc.Layer.extend({
  7945. _blendFunc: null,
  7946. _className: "LayerColor",
  7947. getBlendFunc: function() {
  7948. return this._blendFunc
  7949. },
  7950. changeWidthAndHeight: function(a, b) {
  7951. this.width = a;
  7952. this.height = b
  7953. },
  7954. changeWidth: function(a) {
  7955. this.width = a
  7956. },
  7957. changeHeight: function(a) {
  7958. this.height = a
  7959. },
  7960. setOpacityModifyRGB: function(a) {},
  7961. isOpacityModifyRGB: function() {
  7962. return !1
  7963. },
  7964. ctor: function(a, b, c) {
  7965. cc.Layer.prototype.ctor.call(this);
  7966. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  7967. cc.LayerColor.prototype.init.call(this, a, b, c)
  7968. },
  7969. init: function(a,
  7970. b, c) {
  7971. cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));
  7972. var d = cc.director.getWinSize();
  7973. a = a || cc.color(0, 0, 0, 255);
  7974. b = void 0 === b ? d.width : b;
  7975. c = void 0 === c ? d.height : c;
  7976. d = this._realColor;
  7977. d.r = a.r;
  7978. d.g = a.g;
  7979. d.b = a.b;
  7980. this._realOpacity = a.a;
  7981. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty);
  7982. cc.LayerColor.prototype.setContentSize.call(this, b, c);
  7983. return !0
  7984. },
  7985. setBlendFunc: function(a, b) {
  7986. var c = this._blendFunc;
  7987. void 0 ===
  7988. b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b);
  7989. this._renderCmd.updateBlendFunc(c)
  7990. },
  7991. _setWidth: function(a) {
  7992. cc.Node.prototype._setWidth.call(this, a);
  7993. this._renderCmd._updateSquareVerticesWidth(a)
  7994. },
  7995. _setHeight: function(a) {
  7996. cc.Node.prototype._setHeight.call(this, a);
  7997. this._renderCmd._updateSquareVerticesHeight(a)
  7998. },
  7999. setContentSize: function(a, b) {
  8000. cc.Layer.prototype.setContentSize.call(this, a, b);
  8001. this._renderCmd._updateSquareVertices(a, b)
  8002. },
  8003. _createRenderCmd: function() {
  8004. return cc._renderType === cc._RENDER_TYPE_CANVAS ?
  8005. new cc.LayerColor.CanvasRenderCmd(this) : new cc.LayerColor.WebGLRenderCmd(this)
  8006. }
  8007. });
  8008. cc.LayerColor.create = function(a, b, c) {
  8009. return new cc.LayerColor(a, b, c)
  8010. };
  8011. (function() {
  8012. var a = cc.LayerColor.prototype;
  8013. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  8014. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight)
  8015. })();
  8016. cc.LayerGradient = cc.LayerColor.extend({
  8017. _endColor: null,
  8018. _startOpacity: 255,
  8019. _endOpacity: 255,
  8020. _alongVector: null,
  8021. _compressedInterpolation: !1,
  8022. _className: "LayerGradient",
  8023. _colorStops: [],
  8024. ctor: function(a, b, c, d) {
  8025. cc.LayerColor.prototype.ctor.call(this);
  8026. this._endColor = cc.color(0, 0, 0, 255);
  8027. this._alongVector = cc.p(0, -1);
  8028. this._endOpacity = this._startOpacity = 255;
  8029. d && d instanceof Array ? (this._colorStops = d, d.splice(0, 0, {
  8030. p: 0,
  8031. color: a || cc.color.BLACK
  8032. }), d.push({
  8033. p: 1,
  8034. color: b || cc.color.BLACK
  8035. })) : this._colorStops = [{
  8036. p: 0,
  8037. color: a || cc.color.BLACK
  8038. }, {
  8039. p: 1,
  8040. color: b || cc.color.BLACK
  8041. }];
  8042. cc.LayerGradient.prototype.init.call(this, a, b, c, d)
  8043. },
  8044. init: function(a, b, c, d) {
  8045. a = a || cc.color(0, 0, 0, 255);
  8046. b = b || cc.color(0, 0, 0, 255);
  8047. c = c || cc.p(0, -1);
  8048. d = this._endColor;
  8049. this._startOpacity = a.a;
  8050. d.r = b.r;
  8051. d.g = b.g;
  8052. d.b = b.b;
  8053. this._endOpacity = b.a;
  8054. this._alongVector = c;
  8055. this._compressedInterpolation = !0;
  8056. cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255));
  8057. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty | cc.Node._dirtyFlags.gradientDirty);
  8058. return !0
  8059. },
  8060. setContentSize: function(a, b) {
  8061. cc.LayerColor.prototype.setContentSize.call(this, a, b);
  8062. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)
  8063. },
  8064. _setWidth: function(a) {
  8065. cc.LayerColor.prototype._setWidth.call(this, a);
  8066. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)
  8067. },
  8068. _setHeight: function(a) {
  8069. cc.LayerColor.prototype._setHeight.call(this, a);
  8070. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)
  8071. },
  8072. getStartColor: function() {
  8073. return cc.color(this._realColor)
  8074. },
  8075. setStartColor: function(a) {
  8076. this.color =
  8077. a;
  8078. var b = this._colorStops;
  8079. b && 0 < b.length && (b = b[0].color, b.r = a.r, b.g = a.g, b.b = a.b)
  8080. },
  8081. setEndColor: function(a) {
  8082. var b = this._endColor;
  8083. b.r = a.r;
  8084. b.g = a.g;
  8085. b.b = a.b;
  8086. (b = this._colorStops) && 0 < b.length && (b = b[b.length - 1].color, b.r = a.r, b.g = a.g, b.b = a.b);
  8087. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)
  8088. },
  8089. getEndColor: function() {
  8090. return cc.color(this._endColor)
  8091. },
  8092. setStartOpacity: function(a) {
  8093. this._startOpacity = a;
  8094. var b = this._colorStops;
  8095. b && 0 < b.length && (b[0].color.a = a);
  8096. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  8097. },
  8098. getStartOpacity: function() {
  8099. return this._startOpacity
  8100. },
  8101. setEndOpacity: function(a) {
  8102. this._endOpacity = a;
  8103. var b = this._colorStops;
  8104. b && 0 < b.length && (b[b.length - 1].color.a = a);
  8105. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  8106. },
  8107. getEndOpacity: function() {
  8108. return this._endOpacity
  8109. },
  8110. setVector: function(a) {
  8111. this._alongVector.x = a.x;
  8112. this._alongVector.y = a.y;
  8113. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)
  8114. },
  8115. getVector: function() {
  8116. return cc.p(this._alongVector.x, this._alongVector.y)
  8117. },
  8118. isCompressedInterpolation: function() {
  8119. return this._compressedInterpolation
  8120. },
  8121. setCompressedInterpolation: function(a) {
  8122. this._compressedInterpolation = a;
  8123. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)
  8124. },
  8125. getColorStops: function() {
  8126. return this._colorStops
  8127. },
  8128. setColorStops: function(a) {
  8129. this._colorStops = a;
  8130. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty | cc.Node._dirtyFlags.gradientDirty)
  8131. },
  8132. _createRenderCmd: function() {
  8133. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.LayerGradient.CanvasRenderCmd(this) : new cc.LayerGradient.WebGLRenderCmd(this)
  8134. }
  8135. });
  8136. cc.LayerGradient.create = function(a, b, c, d) {
  8137. return new cc.LayerGradient(a, b, c, d)
  8138. };
  8139. (function() {
  8140. var a = cc.LayerGradient.prototype;
  8141. cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor);
  8142. cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor);
  8143. cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity);
  8144. cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity);
  8145. cc.defineGetterSetter(a, "vector", a.getVector, a.setVector);
  8146. cc.defineGetterSetter(a, "colorStops", a.getColorStops, a.setColorStops)
  8147. })();
  8148. cc.LayerMultiplex = cc.Layer.extend({
  8149. _enabledLayer: 0,
  8150. _layers: null,
  8151. _className: "LayerMultiplex",
  8152. ctor: function(a) {
  8153. cc.Layer.prototype.ctor.call(this);
  8154. a instanceof Array ? cc.LayerMultiplex.prototype.initWithLayers.call(this, a) : cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments))
  8155. },
  8156. initWithLayers: function(a) {
  8157. 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);
  8158. this._layers = a;
  8159. this._enabledLayer = 0;
  8160. this.addChild(this._layers[this._enabledLayer]);
  8161. return !0
  8162. },
  8163. switchTo: function(a) {
  8164. 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]))
  8165. },
  8166. switchToAndReleaseMe: function(a) {
  8167. 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]))
  8168. },
  8169. addLayer: function(a) {
  8170. a ? this._layers.push(a) :
  8171. cc.log(cc._LogInfos.LayerMultiplex_addLayer)
  8172. }
  8173. });
  8174. cc.LayerMultiplex.create = function() {
  8175. return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))
  8176. };
  8177. (function() {
  8178. cc.Layer.CanvasRenderCmd = function(a) {
  8179. cc.Node.CanvasRenderCmd.call(this, a);
  8180. this._isBaked = !1;
  8181. this._bakeSprite = null
  8182. };
  8183. var a = cc.Layer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  8184. a.constructor = cc.Layer.CanvasRenderCmd;
  8185. a.bake = function() {
  8186. if (!this._isBaked) {
  8187. this._needDraw = !0;
  8188. this._isBaked = this._cacheDirty = cc.renderer.childrenOrderDirty = !0;
  8189. for (var a = this._node._children, c = 0, d = a.length; c < d; c++) a[c]._renderCmd._setCachedParent(this);
  8190. this._bakeSprite || (this._bakeSprite =
  8191. new cc.BakeSprite, this._bakeSprite.setAnchorPoint(0, 0))
  8192. }
  8193. };
  8194. a.unbake = function() {
  8195. if (this._isBaked) {
  8196. cc.renderer.childrenOrderDirty = !0;
  8197. this._isBaked = this._needDraw = !1;
  8198. this._cacheDirty = !0;
  8199. for (var a = this._node._children, c = 0, d = a.length; c < d; c++) a[c]._renderCmd._setCachedParent(null)
  8200. }
  8201. };
  8202. a.isBaked = function() {
  8203. return this._isBaked
  8204. };
  8205. a.rendering = function() {
  8206. if (this._cacheDirty) {
  8207. var a = this._node,
  8208. c = a._children,
  8209. d = this._bakeSprite;
  8210. this.transform(this.getParentRenderCmd(), !0);
  8211. var e = this._getBoundingBoxForBake();
  8212. e.width =
  8213. 0 | e.width + 0.5;
  8214. e.height = 0 | e.height + 0.5;
  8215. var f = d.getCacheContext(),
  8216. g = f.getContext();
  8217. d.resetCanvasSize(e.width, e.height);
  8218. f.setOffset(0 - e.x, g.canvas.height - e.height + e.y);
  8219. d.setPosition(e.x, e.y);
  8220. a.sortAllChildren();
  8221. cc.renderer._turnToCacheMode(this.__instanceId);
  8222. a = 0;
  8223. for (e = c.length; a < e; a++) c[a].visit(this);
  8224. cc.renderer._renderingToCacheCanvas(f, this.__instanceId);
  8225. d.transform();
  8226. this._cacheDirty = !1
  8227. }
  8228. };
  8229. a.visit = function(a) {
  8230. if (this._isBaked) {
  8231. var c = this._node,
  8232. d = c._children.length;
  8233. c._visible && 0 !== d && (this._syncStatus(a),
  8234. cc.renderer.pushRenderCommand(this), this._bakeSprite.visit(this), this._dirtyFlag = 0)
  8235. } else cc.Node.CanvasRenderCmd.prototype.visit.call(this, a)
  8236. };
  8237. a._bakeForAddChild = function(a) {
  8238. a._parent === this._node && this._isBaked && a._renderCmd._setCachedParent(this)
  8239. };
  8240. a._getBoundingBoxForBake = function() {
  8241. var a = null,
  8242. c = this._node;
  8243. if (!c._children || 0 === c._children.length) return cc.rect(0, 0, 10, 10);
  8244. for (var d = c.getNodeToWorldTransform(), c = c._children, e = 0, f = c.length; e < f; e++) {
  8245. var g = c[e];
  8246. g && g._visible && (a ? (g = g._getBoundingBoxToCurrentNode(d)) &&
  8247. (a = cc.rectUnion(a, g)) : a = g._getBoundingBoxToCurrentNode(d))
  8248. }
  8249. return a
  8250. }
  8251. })();
  8252. (function() {
  8253. cc.LayerColor.CanvasRenderCmd = function(a) {
  8254. cc.Layer.CanvasRenderCmd.call(this, a);
  8255. this._needDraw = !0;
  8256. this._blendFuncStr = "source-over";
  8257. this._bakeRenderCmd = new cc.CustomRenderCmd(this, this._bakeRendering)
  8258. };
  8259. var a = cc.LayerColor.CanvasRenderCmd.prototype = Object.create(cc.Layer.CanvasRenderCmd.prototype);
  8260. a.constructor = cc.LayerColor.CanvasRenderCmd;
  8261. a.unbake = function() {
  8262. cc.Layer.CanvasRenderCmd.prototype.unbake.call(this);
  8263. this._needDraw = !0
  8264. };
  8265. a.rendering = function(a, c, d) {
  8266. a = a || cc._renderContext;
  8267. var e =
  8268. a.getContext(),
  8269. f = this._node,
  8270. g = this._displayedColor,
  8271. h = this._displayedOpacity / 255,
  8272. k = f._contentSize.width,
  8273. f = f._contentSize.height;
  8274. 0 !== h && (a.setCompositeOperation(this._blendFuncStr), a.setGlobalAlpha(h), a.setFillStyle("rgba(" + (0 | g.r) + "," + (0 | g.g) + "," + (0 | g.b) + ", 1)"), a.setTransform(this._worldTransform, c, d), e.fillRect(0, 0, k * c, -f * d), cc.g_NumberOfDraws++)
  8275. };
  8276. a.updateBlendFunc = function(a) {
  8277. this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)
  8278. };
  8279. a._updateSquareVertices = a._updateSquareVerticesWidth =
  8280. a._updateSquareVerticesHeight = function() {};
  8281. a._bakeRendering = function() {
  8282. if (this._cacheDirty) {
  8283. var a = this._node,
  8284. c = this._bakeSprite,
  8285. d = a._children,
  8286. e = d.length;
  8287. this.transform(this.getParentRenderCmd(), !0);
  8288. var f = this._getBoundingBoxForBake();
  8289. f.width = 0 | f.width + 0.5;
  8290. f.height = 0 | f.height + 0.5;
  8291. var g = c.getCacheContext(),
  8292. h = g.getContext();
  8293. c.resetCanvasSize(f.width, f.height);
  8294. g.setOffset(0 - f.x, h.canvas.height - f.height + f.y);
  8295. c.setPosition(f.x, f.y);
  8296. cc.renderer._turnToCacheMode(this.__instanceId);
  8297. if (0 < e) {
  8298. a.sortAllChildren();
  8299. for (a = 0; a < e; a++)
  8300. if (f = d[a], 0 > f._localZOrder) f._renderCmd.visit(this);
  8301. else break;
  8302. for (cc.renderer.pushRenderCommand(this); a < e; a++) d[a]._renderCmd.visit(this)
  8303. } else cc.renderer.pushRenderCommand(this);
  8304. cc.renderer._renderingToCacheCanvas(g, this.__instanceId);
  8305. c.transform();
  8306. this._cacheDirty = !1
  8307. }
  8308. };
  8309. a.visit = function(a) {
  8310. this._isBaked ? this._node._visible && (this._syncStatus(a), cc.renderer.pushRenderCommand(this._bakeRenderCmd), this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty), this._bakeSprite.visit(this),
  8311. this._dirtyFlag = 0) : cc.Node.CanvasRenderCmd.prototype.visit.call(this)
  8312. };
  8313. a._getBoundingBoxForBake = function() {
  8314. var a = this._node,
  8315. c = cc.rect(0, 0, a._contentSize.width, a._contentSize.height),
  8316. d = a.getNodeToWorldTransform(),
  8317. c = cc.rectApplyAffineTransform(c, a.getNodeToWorldTransform());
  8318. if (!a._children || 0 === a._children.length) return c;
  8319. for (var a = a._children, e = 0; e < a.length; e++) {
  8320. var f = a[e];
  8321. f && f._visible && (f = f._getBoundingBoxToCurrentNode(d), c = cc.rectUnion(c, f))
  8322. }
  8323. return c
  8324. }
  8325. })();
  8326. (function() {
  8327. cc.LayerGradient.RenderCmd = {
  8328. updateStatus: function() {
  8329. var a = cc.Node._dirtyFlags,
  8330. b = this._dirtyFlag,
  8331. c = b & a.colorDirty,
  8332. d = b & a.opacityDirty;
  8333. c && this._updateDisplayColor();
  8334. d && this._updateDisplayOpacity();
  8335. b & a.transformDirty && this.transform(null, !0);
  8336. (c || d || b & a.gradientDirty) && this._updateColor();
  8337. this._dirtyFlag = 0
  8338. }
  8339. }
  8340. })();
  8341. (function() {
  8342. cc.LayerGradient.CanvasRenderCmd = function(a) {
  8343. cc.LayerColor.CanvasRenderCmd.call(this, a);
  8344. this._needDraw = !0;
  8345. this._startPoint = cc.p(0, 0);
  8346. this._endPoint = cc.p(0, 0);
  8347. this._endStopStr = this._startStopStr = null
  8348. };
  8349. var a = cc.LayerGradient.CanvasRenderCmd.prototype = Object.create(cc.LayerColor.CanvasRenderCmd.prototype);
  8350. cc.inject(cc.LayerGradient.RenderCmd, a);
  8351. a.constructor = cc.LayerGradient.CanvasRenderCmd;
  8352. a.rendering = function(a, c, d) {
  8353. a = a || cc._renderContext;
  8354. var e = a.getContext(),
  8355. f = this._node,
  8356. g = this._displayedOpacity /
  8357. 255;
  8358. if (0 !== g) {
  8359. var h = f._contentSize.width,
  8360. k = f._contentSize.height;
  8361. a.setCompositeOperation(this._blendFuncStr);
  8362. a.setGlobalAlpha(g);
  8363. g = e.createLinearGradient(this._startPoint.x * c, this._startPoint.y * d, this._endPoint.x * c, this._endPoint.y * d);
  8364. if (f._colorStops)
  8365. for (var m = 0; m < f._colorStops.length; m++) g.addColorStop(f._colorStops[m].p, this._colorStopsStr[m]);
  8366. else g.addColorStop(0, this._startStopStr), g.addColorStop(1, this._endStopStr);
  8367. a.setFillStyle(g);
  8368. a.setTransform(this._worldTransform, c, d);
  8369. e.fillRect(0, 0, h *
  8370. c, -k * d);
  8371. cc.g_NumberOfDraws++
  8372. }
  8373. };
  8374. a._syncStatus = function(a) {
  8375. var c = cc.Node._dirtyFlags,
  8376. d = this._dirtyFlag,
  8377. e = a ? a._node : null;
  8378. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty);
  8379. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  8380. a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty);
  8381. var e = d & c.colorDirty,
  8382. f = d & c.opacityDirty;
  8383. this._dirtyFlag = d;
  8384. e && this._syncDisplayColor();
  8385. f && this._syncDisplayOpacity();
  8386. d & c.transformDirty && this.transform(a);
  8387. (e || f || d & c.gradientDirty) &&
  8388. this._updateColor()
  8389. };
  8390. a._updateColor = function() {
  8391. var a = this._node,
  8392. c = a._contentSize,
  8393. d = 0.5 * c.width,
  8394. c = 0.5 * c.height;
  8395. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty;
  8396. var e = cc.pAngleSigned(cc.p(0, -1), a._alongVector),
  8397. e = cc.pRotateByAngle(cc.p(0, -1), cc.p(0, 0), e),
  8398. f = Math.min(Math.abs(1 / e.x), Math.abs(1 / e.y));
  8399. this._startPoint.x = d * -e.x * f + d;
  8400. this._startPoint.y = c * e.y * f - c;
  8401. this._endPoint.x = d * e.x * f + d;
  8402. this._endPoint.y = c * -e.y * f - c;
  8403. d = this._displayedColor;
  8404. c = a._endColor;
  8405. e = a._startOpacity / 255;
  8406. f = a._endOpacity /
  8407. 255;
  8408. this._startStopStr = "rgba(" + Math.round(d.r) + "," + Math.round(d.g) + "," + Math.round(d.b) + "," + e.toFixed(4) + ")";
  8409. this._endStopStr = "rgba(" + Math.round(c.r) + "," + Math.round(c.g) + "," + Math.round(c.b) + "," + f.toFixed(4) + ")";
  8410. if (a._colorStops)
  8411. for (this._endOpacity = this._startOpacity = 0, this._colorStopsStr = [], d = 0; d < a._colorStops.length; d++) c = a._colorStops[d].color, e = null == c.a ? 1 : c.a / 255, this._colorStopsStr.push("rgba(" + Math.round(c.r) + "," + Math.round(c.g) + "," + Math.round(c.b) + "," + e.toFixed(4) + ")")
  8412. }
  8413. })();
  8414. (function() {
  8415. cc.Layer.WebGLRenderCmd = function(a) {
  8416. cc.Node.WebGLRenderCmd.call(this, a)
  8417. };
  8418. var a = cc.Layer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  8419. a.constructor = cc.Layer.WebGLRenderCmd;
  8420. a.bake = function() {};
  8421. a.unbake = function() {};
  8422. a._bakeForAddChild = function() {}
  8423. })();
  8424. (function() {
  8425. cc.LayerColor.WebGLRenderCmd = function(a) {
  8426. cc.Layer.WebGLRenderCmd.call(this, a);
  8427. this._needDraw = !0;
  8428. this._squareVerticesAB = new ArrayBuffer(32);
  8429. this._squareColorsAB = new ArrayBuffer(16);
  8430. a = this._squareVerticesAB;
  8431. var c = this._squareColorsAB,
  8432. d = cc.Vertex2F.BYTES_PER_ELEMENT,
  8433. e = cc.Color.BYTES_PER_ELEMENT;
  8434. this._squareVertices = [new cc.Vertex2F(0, 0, a, 0), new cc.Vertex2F(0, 0, a, d), new cc.Vertex2F(0, 0, a, 2 * d), new cc.Vertex2F(0, 0, a, 3 * d)];
  8435. this._squareColors = [cc.color(0, 0, 0, 255, c, 0), cc.color(0, 0, 0, 255, c, e), cc.color(0,
  8436. 0, 0, 255, c, 2 * e), cc.color(0, 0, 0, 255, c, 3 * e)];
  8437. this._verticesFloat32Buffer = cc._renderContext.createBuffer();
  8438. this._colorsUint8Buffer = cc._renderContext.createBuffer()
  8439. };
  8440. var a = cc.LayerColor.WebGLRenderCmd.prototype = Object.create(cc.Layer.WebGLRenderCmd.prototype);
  8441. a.constructor = cc.LayerColor.WebGLRenderCmd;
  8442. a.rendering = function(a) {
  8443. a = a || cc._renderContext;
  8444. var c = this._node;
  8445. this._shaderProgram.use();
  8446. this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
  8447. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION |
  8448. cc.VERTEX_ATTRIB_FLAG_COLOR);
  8449. cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst);
  8450. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  8451. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  8452. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  8453. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0);
  8454. a.drawArrays(a.TRIANGLE_STRIP, 0, this._squareVertices.length)
  8455. };
  8456. a._updateSquareVertices = function(a, c) {
  8457. var d = this._squareVertices;
  8458. void 0 === c ? (d[1].x = a.width, d[2].y = a.height, d[3].x =
  8459. a.width, d[3].y = a.height) : (d[1].x = a, d[2].y = c, d[3].x = a, d[3].y = c);
  8460. this._bindLayerVerticesBufferData()
  8461. };
  8462. a._updateSquareVerticesWidth = function(a) {
  8463. var c = this._squareVertices;
  8464. c[1].x = a;
  8465. c[3].x = a;
  8466. this._bindLayerVerticesBufferData()
  8467. };
  8468. a._updateSquareVerticesHeight = function(a) {
  8469. var c = this._squareVertices;
  8470. c[2].y = a;
  8471. c[3].y = a;
  8472. this._bindLayerVerticesBufferData()
  8473. };
  8474. a._updateColor = function() {
  8475. for (var a = this._displayedColor, c = this._displayedOpacity, d = this._squareColors, e = 0; 4 > e; e++) d[e].r = a.r, d[e].g = a.g, d[e].b = a.b, d[e].a =
  8476. c;
  8477. this._bindLayerColorsBufferData()
  8478. };
  8479. a._bindLayerVerticesBufferData = function() {
  8480. var a = cc._renderContext;
  8481. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  8482. a.bufferData(a.ARRAY_BUFFER, this._squareVerticesAB, a.STATIC_DRAW)
  8483. };
  8484. a._bindLayerColorsBufferData = function() {
  8485. var a = cc._renderContext;
  8486. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  8487. a.bufferData(a.ARRAY_BUFFER, this._squareColorsAB, a.STATIC_DRAW)
  8488. };
  8489. a.updateBlendFunc = function(a) {}
  8490. })();
  8491. (function() {
  8492. cc.LayerGradient.WebGLRenderCmd = function(a) {
  8493. cc.LayerColor.WebGLRenderCmd.call(this, a);
  8494. this._needDraw = !0;
  8495. this._clipRect = new cc.Rect;
  8496. this._clippingRectDirty = !1
  8497. };
  8498. var a = cc.LayerGradient.WebGLRenderCmd.prototype = Object.create(cc.LayerColor.WebGLRenderCmd.prototype);
  8499. cc.inject(cc.LayerGradient.RenderCmd, a);
  8500. a.constructor = cc.LayerGradient.WebGLRenderCmd;
  8501. a._syncStatus = function(a) {
  8502. var c = cc.Node._dirtyFlags,
  8503. d = this._dirtyFlag,
  8504. e = a ? a._node : null;
  8505. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |=
  8506. c.colorDirty);
  8507. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  8508. a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty);
  8509. var e = d & c.colorDirty,
  8510. f = d & c.opacityDirty;
  8511. this._dirtyFlag = d;
  8512. e && this._syncDisplayColor();
  8513. f && this._syncDisplayOpacity();
  8514. this.transform(a);
  8515. (e || f || d & c.gradientDirty) && this._updateColor()
  8516. };
  8517. a._updateColor = function() {
  8518. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.gradientDirty;
  8519. var a = this._node,
  8520. c = a._colorStops;
  8521. if (c && !(2 > c.length)) {
  8522. this._clippingRectDirty = !0;
  8523. var d = c.length,
  8524. e = 2 * d,
  8525. f, g = a._contentSize;
  8526. this._squareVerticesAB = new ArrayBuffer(8 * e);
  8527. this._squareColorsAB = new ArrayBuffer(4 * e);
  8528. var h = this._squareVertices,
  8529. k = this._squareColors;
  8530. h.length = 0;
  8531. k.length = 0;
  8532. var m = this._squareVerticesAB,
  8533. n = this._squareColorsAB,
  8534. p = cc.Vertex2F.BYTES_PER_ELEMENT,
  8535. t = cc.Color.BYTES_PER_ELEMENT;
  8536. for (f = 0; f < e; f++) h.push(new cc.Vertex2F(0, 0, m, p * f)), k.push(cc.color(0, 0, 0, 255, n, t * f));
  8537. n = Math.PI + cc.pAngleSigned(cc.p(0, -1), a._alongVector);
  8538. a = cc.p(g.width / 2, g.height / 2);
  8539. f = Math.round(cc.radiansToDegrees(n));
  8540. e = cc.affineTransformMake(1, 0, 0, 1, a.x, a.y);
  8541. e = cc.affineTransformRotate(e, n);
  8542. 90 > f ? (p = cc.p(-a.x, a.y), f = cc.p(a.x, a.y)) : 180 > f ? (p = cc.p(a.x, a.y), f = cc.p(a.x, -a.y)) : 270 > f ? (p = cc.p(a.x, -a.y), f = cc.p(-a.x, -a.y)) : (p = cc.p(-a.x, -a.y), f = cc.p(-a.x, a.y));
  8543. m = Math.sin(n);
  8544. n = Math.cos(n);
  8545. p = Math.abs((p.x * n - p.y * m) / a.x);
  8546. f = Math.abs((f.x * m + f.y * n) / a.y);
  8547. e = cc.affineTransformScale(e, p, f);
  8548. for (f = 0; f < d; f++) m = c[f].p * g.height, n = cc.pointApplyAffineTransform(-a.x, m - a.y, e), h[2 * f].x = n.x, h[2 * f].y = n.y, m = cc.pointApplyAffineTransform(g.width - a.x,
  8549. m - a.y, e), h[2 * f + 1].x = m.x, h[2 * f + 1].y = m.y;
  8550. g = this._displayedOpacity / 255;
  8551. for (f = 0; f < d; f++) h = c[f].color, a = k[2 * f], e = k[2 * f + 1], a.r = h.r, a.g = h.g, a.b = h.b, a.a = h.a * g, e.r = h.r, e.g = h.g, e.b = h.b, e.a = h.a * g;
  8552. this._bindLayerVerticesBufferData();
  8553. this._bindLayerColorsBufferData()
  8554. }
  8555. };
  8556. a.rendering = function(a) {
  8557. a = a || cc._renderContext;
  8558. var c = this._node,
  8559. d = this._getClippingRect();
  8560. a.enable(a.SCISSOR_TEST);
  8561. cc.view.setScissorInPoints(d.x, d.y, d.width, d.height);
  8562. this._shaderProgram.use();
  8563. this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
  8564. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR);
  8565. cc.glBlendFunc(c._blendFunc.src, c._blendFunc.dst);
  8566. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  8567. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  8568. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  8569. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0);
  8570. a.drawArrays(a.TRIANGLE_STRIP, 0, this._squareVertices.length);
  8571. a.disable(a.SCISSOR_TEST)
  8572. };
  8573. a._getClippingRect = function() {
  8574. if (this._clippingRectDirty) {
  8575. var a =
  8576. this._node,
  8577. c = cc.rect(0, 0, a._contentSize.width, a._contentSize.height),
  8578. a = a.getNodeToWorldTransform();
  8579. this._clipRect = cc._rectApplyAffineTransformIn(c, a)
  8580. }
  8581. return this._clipRect
  8582. }
  8583. })();
  8584. cc._tmp.PrototypeSprite = function() {
  8585. var a = cc.Sprite.prototype;
  8586. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  8587. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  8588. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  8589. cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX);
  8590. cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY);
  8591. cc.defineGetterSetter(a, "offsetX", a._getOffsetX);
  8592. cc.defineGetterSetter(a, "offsetY", a._getOffsetY);
  8593. cc.defineGetterSetter(a,
  8594. "texture", a.getTexture, a.setTexture);
  8595. cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated);
  8596. cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode);
  8597. cc.defineGetterSetter(a, "quad", a.getQuad)
  8598. };
  8599. cc.Sprite = cc.Node.extend({
  8600. dirty: !1,
  8601. atlasIndex: 0,
  8602. textureAtlas: null,
  8603. _batchNode: null,
  8604. _recursiveDirty: null,
  8605. _hasChildren: null,
  8606. _shouldBeHidden: !1,
  8607. _transformToBatch: null,
  8608. _blendFunc: null,
  8609. _texture: null,
  8610. _rect: null,
  8611. _rectRotated: !1,
  8612. _offsetPosition: null,
  8613. _unflippedOffsetPositionFromCenter: null,
  8614. _opacityModifyRGB: !1,
  8615. _flippedX: !1,
  8616. _flippedY: !1,
  8617. _textureLoaded: !1,
  8618. _className: "Sprite",
  8619. ctor: function(a, b, c) {
  8620. cc.Node.prototype.ctor.call(this);
  8621. this._shouldBeHidden = !1;
  8622. this._offsetPosition = cc.p(0, 0);
  8623. this._unflippedOffsetPositionFromCenter =
  8624. cc.p(0, 0);
  8625. this._blendFunc = {
  8626. src: cc.BLEND_SRC,
  8627. dst: cc.BLEND_DST
  8628. };
  8629. this._rect = cc.rect(0, 0, 0, 0);
  8630. this._softInit(a, b, c)
  8631. },
  8632. textureLoaded: function() {
  8633. return this._textureLoaded
  8634. },
  8635. addLoadedEventListener: function(a, b) {
  8636. this.addEventListener("load", a, b)
  8637. },
  8638. isDirty: function() {
  8639. return this.dirty
  8640. },
  8641. setDirty: function(a) {
  8642. this.dirty = a
  8643. },
  8644. isTextureRectRotated: function() {
  8645. return this._rectRotated
  8646. },
  8647. getAtlasIndex: function() {
  8648. return this.atlasIndex
  8649. },
  8650. setAtlasIndex: function(a) {
  8651. this.atlasIndex = a
  8652. },
  8653. getTextureRect: function() {
  8654. return cc.rect(this._rect)
  8655. },
  8656. getTextureAtlas: function() {
  8657. return this.textureAtlas
  8658. },
  8659. setTextureAtlas: function(a) {
  8660. this.textureAtlas = a
  8661. },
  8662. getOffsetPosition: function() {
  8663. return cc.p(this._offsetPosition)
  8664. },
  8665. _getOffsetX: function() {
  8666. return this._offsetPosition.x
  8667. },
  8668. _getOffsetY: function() {
  8669. return this._offsetPosition.y
  8670. },
  8671. getBlendFunc: function() {
  8672. return this._blendFunc
  8673. },
  8674. initWithSpriteFrame: function(a) {
  8675. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrame);
  8676. a.textureLoaded() || (this._textureLoaded = !1, a.addEventListener("load", this._renderCmd._spriteFrameLoadedCallback,
  8677. this));
  8678. var b = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated,
  8679. b = this.initWithTexture(a.getTexture(), a.getRect(), b);
  8680. this.setSpriteFrame(a);
  8681. return b
  8682. },
  8683. initWithSpriteFrameName: function(a) {
  8684. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName);
  8685. var b = cc.spriteFrameCache.getSpriteFrame(a);
  8686. cc.assert(b, a + cc._LogInfos.Sprite_initWithSpriteFrameName1);
  8687. return this.initWithSpriteFrame(b)
  8688. },
  8689. useBatchNode: function(a) {
  8690. this.textureAtlas = a.getTextureAtlas();
  8691. this._batchNode = a
  8692. },
  8693. setVertexRect: function(a) {
  8694. var b = this._rect;
  8695. b.x = a.x;
  8696. b.y = a.y;
  8697. b.width = a.width;
  8698. b.height = a.height
  8699. },
  8700. sortAllChildren: function() {
  8701. if (this._reorderChildDirty) {
  8702. var a = this._children,
  8703. b = a.length,
  8704. c, d, e;
  8705. for (c = 1; c < b; c++) {
  8706. e = a[c];
  8707. for (d = c - 1; 0 <= d;) {
  8708. if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d];
  8709. else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d];
  8710. else break;
  8711. d--
  8712. }
  8713. a[d + 1] = e
  8714. }
  8715. this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node._stateCallbackType.sortAllChildren);
  8716. this._reorderChildDirty = !1
  8717. }
  8718. },
  8719. reorderChild: function(a, b) {
  8720. cc.assert(a,
  8721. cc._LogInfos.Sprite_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.Sprite_reorderChild) : b !== a.zIndex && (this._batchNode && !this._reorderChildDirty && (this._setReorderChildDirtyRecursively(), this._batchNode.reorderBatch(!0)), cc.Node.prototype.reorderChild.call(this, a, b))
  8722. },
  8723. removeChild: function(a, b) {
  8724. this._batchNode && this._batchNode.removeSpriteFromAtlas(a);
  8725. cc.Node.prototype.removeChild.call(this, a, b)
  8726. },
  8727. setVisible: function(a) {
  8728. cc.Node.prototype.setVisible.call(this, a);
  8729. this._renderCmd.setDirtyRecursively(!0)
  8730. },
  8731. removeAllChildren: function(a) {
  8732. var b = this._children,
  8733. c = this._batchNode;
  8734. if (c && null != b)
  8735. for (var d = 0, e = b.length; d < e; d++) c.removeSpriteFromAtlas(b[d]);
  8736. cc.Node.prototype.removeAllChildren.call(this, a);
  8737. this._hasChildren = !1
  8738. },
  8739. ignoreAnchorPointForPosition: function(a) {
  8740. this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a)
  8741. },
  8742. setFlippedX: function(a) {
  8743. this._flippedX !== a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated,
  8744. this._contentSize), this.setNodeDirty(!0))
  8745. },
  8746. setFlippedY: function(a) {
  8747. this._flippedY !== a && (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  8748. },
  8749. isFlippedX: function() {
  8750. return this._flippedX
  8751. },
  8752. isFlippedY: function() {
  8753. return this._flippedY
  8754. },
  8755. setOpacityModifyRGB: function(a) {
  8756. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this._renderCmd._setColorDirty())
  8757. },
  8758. isOpacityModifyRGB: function() {
  8759. return this._opacityModifyRGB
  8760. },
  8761. setDisplayFrameWithAnimationName: function(a,
  8762. b) {
  8763. cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
  8764. var c = cc.animationCache.getAnimation(a);
  8765. c ? (c = c.getFrames()[b]) ? this.setSpriteFrame(c.getSpriteFrame()) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)
  8766. },
  8767. getBatchNode: function() {
  8768. return this._batchNode
  8769. },
  8770. _setReorderChildDirtyRecursively: function() {
  8771. if (!this._reorderChildDirty) {
  8772. this._reorderChildDirty = !0;
  8773. for (var a = this._parent; a && a !== this._batchNode;) a._setReorderChildDirtyRecursively(),
  8774. a = a.parent
  8775. }
  8776. },
  8777. getTexture: function() {
  8778. return this._texture
  8779. },
  8780. _softInit: function(a, b, c) {
  8781. if (void 0 === a) cc.Sprite.prototype.init.call(this);
  8782. else if (cc.isString(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, b);
  8783. else if (cc.isObject(a))
  8784. if (a instanceof cc.Texture2D) this.initWithTexture(a, b, c);
  8785. else if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a);
  8786. else if (a instanceof HTMLImageElement || a instanceof HTMLCanvasElement) b =
  8787. new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.initWithTexture(b)
  8788. },
  8789. getQuad: function() {
  8790. return this._renderCmd.getQuad()
  8791. },
  8792. setBlendFunc: function(a, b) {
  8793. var c = this._blendFunc;
  8794. void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b);
  8795. this._renderCmd.updateBlendFunc(c)
  8796. },
  8797. init: function() {
  8798. if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
  8799. cc.Node.prototype.init.call(this);
  8800. this.dirty = this._recursiveDirty = !1;
  8801. this._blendFunc.src = cc.BLEND_SRC;
  8802. this._blendFunc.dst = cc.BLEND_DST;
  8803. this.texture = null;
  8804. this._flippedX = this._flippedY = !1;
  8805. this.anchorY = this.anchorX = 0.5;
  8806. this._offsetPosition.x = 0;
  8807. this._offsetPosition.y = 0;
  8808. this._hasChildren = !1;
  8809. this._renderCmd._init();
  8810. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  8811. return !0
  8812. },
  8813. initWithFile: function(a, b) {
  8814. cc.assert(a, cc._LogInfos.Sprite_initWithFile);
  8815. var c = cc.textureCache.getTextureForKey(a);
  8816. if (c) {
  8817. if (!b) {
  8818. var d = c.getContentSize();
  8819. b = cc.rect(0, 0, d.width, d.height)
  8820. }
  8821. return this.initWithTexture(c, b)
  8822. }
  8823. c = cc.textureCache.addImage(a);
  8824. return this.initWithTexture(c,
  8825. b || cc.rect(0, 0, c._contentSize.width, c._contentSize.height))
  8826. },
  8827. initWithTexture: function(a, b, c, d) {
  8828. cc.assert(0 !== arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
  8829. c = c || !1;
  8830. a = this._renderCmd._handleTextureForRotatedTexture(a, b, c, d);
  8831. if (!cc.Node.prototype.init.call(this)) return !1;
  8832. this._batchNode = null;
  8833. this.dirty = this._recursiveDirty = !1;
  8834. this._opacityModifyRGB = !0;
  8835. this._blendFunc.src = cc.BLEND_SRC;
  8836. this._blendFunc.dst = cc.BLEND_DST;
  8837. this._flippedX = this._flippedY = !1;
  8838. this.setAnchorPoint(0.5, 0.5);
  8839. this._offsetPosition.x =
  8840. 0;
  8841. this._offsetPosition.y = 0;
  8842. this._hasChildren = !1;
  8843. this._renderCmd._init();
  8844. var e = a.isLoaded();
  8845. this._textureLoaded = e;
  8846. if (!e) return this._rectRotated = c, b && (this._rect.x = b.x, this._rect.y = b.y, this._rect.width = b.width, this._rect.height = b.height), this.texture && this.texture.removeEventListener("load", this), a.addEventListener("load", this._renderCmd._textureLoadedCallback, this), this.texture = a, !0;
  8847. b || (b = cc.rect(0, 0, a.width, a.height));
  8848. this._renderCmd._checkTextureBoundary(a, b, c);
  8849. this.texture = a;
  8850. this.setTextureRect(b,
  8851. c);
  8852. this.setBatchNode(null);
  8853. return !0
  8854. },
  8855. setTextureRect: function(a, b, c, d) {
  8856. this._rectRotated = b || !1;
  8857. this.setContentSize(c || a);
  8858. this.setVertexRect(a);
  8859. this._renderCmd._setTextureCoords(a, d);
  8860. a = this._unflippedOffsetPositionFromCenter.x;
  8861. b = this._unflippedOffsetPositionFromCenter.y;
  8862. this._flippedX && (a = -a);
  8863. this._flippedY && (b = -b);
  8864. c = this._rect;
  8865. this._offsetPosition.x = a + (this._contentSize.width - c.width) / 2;
  8866. this._offsetPosition.y = b + (this._contentSize.height - c.height) / 2;
  8867. this._batchNode ? this.dirty = !0 : this._renderCmd._resetForBatchNode()
  8868. },
  8869. updateTransform: function() {
  8870. this._renderCmd.updateTransform()
  8871. },
  8872. addChild: function(a, b, c) {
  8873. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2);
  8874. null == b && (b = a._localZOrder);
  8875. null == c && (c = a.tag);
  8876. this._renderCmd._setBatchNodeForAddChild(a) && (cc.Node.prototype.addChild.call(this, a, b, c), this._hasChildren = !0)
  8877. },
  8878. setSpriteFrame: function(a) {
  8879. var b = this;
  8880. cc.isString(a) && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.Sprite_setSpriteFrame));
  8881. this.setNodeDirty(!0);
  8882. var c = a.getOffset();
  8883. b._unflippedOffsetPositionFromCenter.x =
  8884. c.x;
  8885. b._unflippedOffsetPositionFromCenter.y = c.y;
  8886. c = a.getTexture();
  8887. a.textureLoaded() ? (c !== b._texture && (b.texture = c), b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize())) : (b._textureLoaded = !1, a.addEventListener("load", function(a) {
  8888. b._textureLoaded = !0;
  8889. var c = a.getTexture();
  8890. c !== b._texture && (b.texture = c);
  8891. b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8892. b.dispatchEvent("load");
  8893. b.setColor(b.color)
  8894. }, b));
  8895. this._renderCmd._updateForSetSpriteFrame(c)
  8896. },
  8897. setDisplayFrame: function(a) {
  8898. cc.log(cc._LogInfos.Sprite_setDisplayFrame);
  8899. this.setSpriteFrame(a)
  8900. },
  8901. isFrameDisplayed: function(a) {
  8902. return this._renderCmd.isFrameDisplayed(a)
  8903. },
  8904. displayFrame: function() {
  8905. return this.getSpriteFrame()
  8906. },
  8907. getSpriteFrame: function() {
  8908. return new cc.SpriteFrame(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize))
  8909. },
  8910. setBatchNode: function(a) {
  8911. (this._batchNode = a) ? (this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.getTextureAtlas()) :
  8912. (this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED, this.textureAtlas = null, this.dirty = this._recursiveDirty = !1, this._renderCmd._resetForBatchNode())
  8913. },
  8914. setTexture: function(a) {
  8915. if (!a) return this._renderCmd._setTexture(null);
  8916. cc.isString(a) ? (a = cc.textureCache.addImage(a), a._textureLoaded ? (this._renderCmd._setTexture(a), this._changeRectWithTexture(a.getContentSize()), this.setColor(this._realColor), this._textureLoaded = !0) : a.addEventListener("load", function() {
  8917. this._renderCmd._setTexture(a);
  8918. this._changeRectWithTexture(a.getContentSize());
  8919. this.setColor(this._realColor);
  8920. this._textureLoaded = !0
  8921. }, this)) : (cc.assert(a instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2), this._changeRectWithTexture(a.getContentSize()), this._renderCmd._setTexture(a))
  8922. },
  8923. _changeRectWithTexture: function(a) {
  8924. if (a && (a.width || a.height)) {
  8925. var b = this.getTextureRect();
  8926. b.height || b.width || (a.x = a.x || 0, a.y = a.y || 0, a.width = a.width || 0, a.height = a.height || 0, this.setTextureRect(a))
  8927. }
  8928. },
  8929. _createRenderCmd: function() {
  8930. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.Sprite.CanvasRenderCmd(this) :
  8931. new cc.Sprite.WebGLRenderCmd(this)
  8932. }
  8933. });
  8934. cc.Sprite.create = function(a, b, c) {
  8935. return new cc.Sprite(a, b, c)
  8936. };
  8937. cc.Sprite.createWithTexture = cc.Sprite.create;
  8938. cc.Sprite.createWithSpriteFrameName = cc.Sprite.create;
  8939. cc.Sprite.createWithSpriteFrame = cc.Sprite.create;
  8940. cc.Sprite.INDEX_NOT_INITIALIZED = -1;
  8941. cc.EventHelper.prototype.apply(cc.Sprite.prototype);
  8942. cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
  8943. cc._tmp.PrototypeSprite();
  8944. delete cc._tmp.PrototypeSprite;
  8945. (function() {
  8946. cc.Sprite.CanvasRenderCmd = function(a) {
  8947. cc.Node.CanvasRenderCmd.call(this, a);
  8948. this._needDraw = !0;
  8949. this._textureCoord = {
  8950. renderX: 0,
  8951. renderY: 0,
  8952. x: 0,
  8953. y: 0,
  8954. width: 0,
  8955. height: 0,
  8956. validRect: !1
  8957. };
  8958. this._blendFuncStr = "source-over";
  8959. this._colorized = !1;
  8960. this._originalTexture = null
  8961. };
  8962. var a = cc.Sprite.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  8963. a.constructor = cc.Sprite.CanvasRenderCmd;
  8964. a._init = function() {};
  8965. a.setDirtyRecursively = function(a) {};
  8966. a._resetForBatchNode = function() {};
  8967. a._setTexture = function(a) {
  8968. var c =
  8969. this._node;
  8970. c._texture !== a && (a ? (a.getHtmlElementObj() instanceof HTMLImageElement && (this._originalTexture = a), c._textureLoaded = a._textureLoaded) : c._textureLoaded = !1, c._texture = a)
  8971. };
  8972. a._setColorDirty = function() {
  8973. this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty | cc.Node._dirtyFlags.opacityDirty)
  8974. };
  8975. a.isFrameDisplayed = function(a) {
  8976. var c = this._node;
  8977. return a.getTexture() !== c._texture ? !1 : cc.rectEqualToRect(a.getRect(), c._rect)
  8978. };
  8979. a.updateBlendFunc = function(a) {
  8980. this._blendFuncStr = cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)
  8981. };
  8982. a._setBatchNodeForAddChild = function(a) {
  8983. return !0
  8984. };
  8985. a._handleTextureForRotatedTexture = function(a, c, d, e) {
  8986. d && a.isLoaded() && (a = a.getHtmlElementObj(), a = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(a, c, e), e = new cc.Texture2D, e.initWithElement(a), e.handleLoadedTexture(), a = e, c.x = c.y = 0, this._node._rect = cc.rect(0, 0, c.width, c.height));
  8987. return a
  8988. };
  8989. a._checkTextureBoundary = function(a, c, d) {
  8990. a && a.url && (d = c.y + c.height, c.x + c.width > a.width && cc.error(cc._LogInfos.RectWidth, a.url), d > a.height && cc.error(cc._LogInfos.RectHeight,
  8991. a.url));
  8992. this._node._originalTexture = a
  8993. };
  8994. a.rendering = function(a, c, d) {
  8995. var e = this._node,
  8996. f = this._textureCoord,
  8997. g = this._displayedOpacity / 255;
  8998. if ((!e._texture || 0 !== f.width && 0 !== f.height && e._texture._textureLoaded) && 0 !== g) {
  8999. a = a || cc._renderContext;
  9000. var h = a.getContext(),
  9001. k = e._offsetPosition.x,
  9002. m = e._rect.height,
  9003. n = e._rect.width,
  9004. p = -e._offsetPosition.y - m;
  9005. a.setTransform(this._worldTransform, c, d);
  9006. a.setCompositeOperation(this._blendFuncStr);
  9007. a.setGlobalAlpha(g);
  9008. (e._flippedX || e._flippedY) && a.save();
  9009. e._flippedX && (k = -k - n, h.scale(-1,
  9010. 1));
  9011. e._flippedY && (p = e._offsetPosition.y, h.scale(1, -1));
  9012. e._texture ? (g = e._texture._htmlElementObj, "" !== e._texture._pattern ? (a.setFillStyle(h.createPattern(g, e._texture._pattern)), h.fillRect(k * c, p * d, n * c, m * d)) : this._colorized ? h.drawImage(g, 0, 0, f.width, f.height, k * c, p * d, n * c, m * d) : h.drawImage(g, f.renderX, f.renderY, f.width, f.height, k * c, p * d, n * c, m * d)) : (g = e._contentSize, f.validRect && (f = this._displayedColor, a.setFillStyle("rgba(" + f.r + "," + f.g + "," + f.b + ",1)"), h.fillRect(k * c, p * d, g.width * c, g.height * d)));
  9013. (e._flippedX ||
  9014. e._flippedY) && a.restore();
  9015. cc.g_NumberOfDraws++
  9016. }
  9017. };
  9018. a._updateColor = cc.sys._supportCanvasNewBlendModes ? function() {
  9019. var a = this._node,
  9020. c = this._displayedColor;
  9021. if (255 === c.r && 255 === c.g && 255 === c.b) this._colorized && (this._colorized = !1, a.texture = this._originalTexture);
  9022. else {
  9023. var d, e = a._texture,
  9024. f = this._textureCoord;
  9025. e && f.validRect && this._originalTexture && (d = e.getHtmlElementObj()) && (this._colorized = !0, d instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor && this._originalTexture._htmlElementObj !==
  9026. d ? cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, c, f, d) : (d = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(this._originalTexture._htmlElementObj, c, f), e = new cc.Texture2D, e.initWithElement(d), e.handleLoadedTexture(), a.texture = e))
  9027. }
  9028. } : function() {
  9029. var a = this._node,
  9030. c = this._displayedColor;
  9031. if (255 === c.r && 255 === c.g && 255 === c.b) this._colorized && (this._colorized = !1, a.texture = this._originalTexture);
  9032. else {
  9033. var d, e = a._texture,
  9034. f = this._textureCoord;
  9035. e && f.validRect &&
  9036. this._originalTexture && (d = e.getHtmlElementObj()) && (e = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())) && (this._colorized = !0, d instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.Sprite.CanvasRenderCmd._generateTintImage(d, e, c, f, d) : (d = cc.Sprite.CanvasRenderCmd._generateTintImage(d, e, c, f), e = new cc.Texture2D, e.initWithElement(d), e.handleLoadedTexture(), a.texture = e))
  9037. }
  9038. };
  9039. a.getQuad = function() {
  9040. return null
  9041. };
  9042. a._updateForSetSpriteFrame = function(a,
  9043. c) {
  9044. var d = this._node;
  9045. d._rectRotated && (d._originalTexture = a);
  9046. this._colorized = !1;
  9047. this._textureCoord.renderX = this._textureCoord.x;
  9048. this._textureCoord.renderY = this._textureCoord.y;
  9049. c && (d = d.getColor(), 255 === d.r && 255 === d.g && 255 === d.b || this._updateColor())
  9050. };
  9051. a.updateTransform = function() {
  9052. var a = this._node;
  9053. if (a.dirty) {
  9054. var c = a._parent;
  9055. !a._visible || c && c !== a._batchNode && c._shouldBeHidden ? a._shouldBeHidden = !0 : (a._shouldBeHidden = !1, a._transformToBatch = c && c !== a._batchNode ? cc.affineTransformConcat(this.getNodeToParentTransform(),
  9056. c._transformToBatch) : this.getNodeToParentTransform());
  9057. a._recursiveDirty = !1;
  9058. a.dirty = !1
  9059. }
  9060. a._hasChildren && a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform)
  9061. };
  9062. a._updateDisplayColor = function(a) {
  9063. cc.Node.CanvasRenderCmd.prototype._updateDisplayColor.call(this, a)
  9064. };
  9065. a._spriteFrameLoadedCallback = function(a) {
  9066. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  9067. this._renderCmd._updateColor();
  9068. this.dispatchEvent("load")
  9069. };
  9070. a._textureLoadedCallback = function(a) {
  9071. if (!this._textureLoaded) {
  9072. this._textureLoaded = !0;
  9073. var c = this._rect,
  9074. d = this._renderCmd;
  9075. c ? cc._rectEqualToZero(c) && (c.width = a.width, c.height = a.height) : c = cc.rect(0, 0, a.width, a.height);
  9076. this.texture = d._originalTexture = a;
  9077. this.setTextureRect(c, this._rectRotated);
  9078. a = d._displayedColor;
  9079. 255 === a.r && 255 === a.g && 255 === a.b || d._updateColor();
  9080. this.setBatchNode(this._batchNode);
  9081. this.dispatchEvent("load")
  9082. }
  9083. };
  9084. a._setTextureCoords = function(a, c) {
  9085. void 0 === c && (c = !0);
  9086. var d = this._textureCoord,
  9087. e = c ? cc.contentScaleFactor() : 1;
  9088. d.renderX = d.x = 0 | a.x * e;
  9089. d.renderY = d.y = 0 | a.y * e;
  9090. d.width =
  9091. 0 | a.width * e;
  9092. d.height = 0 | a.height * e;
  9093. d.validRect = !(0 === d.width || 0 === d.height || 0 > d.x || 0 > d.y);
  9094. this._colorized && (this._node._texture = this._originalTexture, this._colorized = !1, this._updateColor())
  9095. };
  9096. cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply = function(a, c, d, e) {
  9097. e = e || cc.newElement("canvas");
  9098. d = d || cc.rect(0, 0, a.width, a.height);
  9099. var f = e.getContext("2d");
  9100. e.width !== d.width || e.height !== d.height ? (e.width = d.width, e.height = d.height) : f.globalCompositeOperation = "source-over";
  9101. f.fillStyle = "rgb(" + (0 | c.r) + "," +
  9102. (0 | c.g) + "," + (0 | c.b) + ")";
  9103. f.fillRect(0, 0, d.width, d.height);
  9104. f.globalCompositeOperation = "multiply";
  9105. f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
  9106. f.globalCompositeOperation = "destination-atop";
  9107. f.drawImage(a, d.x, d.y, d.width, d.height, 0, 0, d.width, d.height);
  9108. return e
  9109. };
  9110. cc.Sprite.CanvasRenderCmd._generateTintImage = function(a, c, d, e, f) {
  9111. e || (e = cc.rect(0, 0, a.width, a.height));
  9112. a = d.r / 255;
  9113. var g = d.g / 255;
  9114. d = d.b / 255;
  9115. var h = Math.min(e.width, c[0].width),
  9116. k = Math.min(e.height, c[0].height),
  9117. m;
  9118. f ? (m = f.getContext("2d"),
  9119. m.clearRect(0, 0, h, k)) : (f = cc.newElement("canvas"), f.width = h, f.height = k, m = f.getContext("2d"));
  9120. m.save();
  9121. m.globalCompositeOperation = "lighter";
  9122. var n = m.globalAlpha;
  9123. 0 < a && (m.globalAlpha = a * n, m.drawImage(c[0], e.x, e.y, h, k, 0, 0, h, k));
  9124. 0 < g && (m.globalAlpha = g * n, m.drawImage(c[1], e.x, e.y, h, k, 0, 0, h, k));
  9125. 0 < d && (m.globalAlpha = d * n, m.drawImage(c[2], e.x, e.y, h, k, 0, 0, h, k));
  9126. 1 > a + g + d && (m.globalAlpha = n, m.drawImage(c[3], e.x, e.y, h, k, 0, 0, h, k));
  9127. m.restore();
  9128. return f
  9129. };
  9130. cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor = function(a) {
  9131. function c() {
  9132. var c =
  9133. cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor,
  9134. e = a.width,
  9135. h = a.height;
  9136. d[0].width = e;
  9137. d[0].height = h;
  9138. d[1].width = e;
  9139. d[1].height = h;
  9140. d[2].width = e;
  9141. d[2].height = h;
  9142. d[3].width = e;
  9143. d[3].height = h;
  9144. c.canvas.width = e;
  9145. c.canvas.height = h;
  9146. var k = c.canvas.getContext("2d");
  9147. k.drawImage(a, 0, 0);
  9148. c.tempCanvas.width = e;
  9149. c.tempCanvas.height = h;
  9150. for (var k = k.getImageData(0, 0, e, h).data, m = 0; 4 > m; m++) {
  9151. var n = d[m].getContext("2d");
  9152. n.getImageData(0, 0, e, h).data;
  9153. c.tempCtx.drawImage(a, 0, 0);
  9154. for (var p = c.tempCtx.getImageData(0, 0, e, h), t = p.data,
  9155. r = 0; r < k.length; r += 4) t[r] = 0 === m ? k[r] : 0, t[r + 1] = 1 === m ? k[r + 1] : 0, t[r + 2] = 2 === m ? k[r + 2] : 0, t[r + 3] = k[r + 3];
  9156. n.putImageData(p, 0, 0)
  9157. }
  9158. a.onload = null
  9159. }
  9160. if (a.channelCache) return a.channelCache;
  9161. var d = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")];
  9162. try {
  9163. c()
  9164. } catch (e) {
  9165. a.onload = c
  9166. }
  9167. return a.channelCache = d
  9168. };
  9169. cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.canvas = cc.newElement("canvas");
  9170. cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas = cc.newElement("canvas");
  9171. cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCtx = cc.Sprite.CanvasRenderCmd._generateTextureCacheForColor.tempCanvas.getContext("2d");
  9172. cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas = function(a, c, d) {
  9173. if (!a) return null;
  9174. if (!c) return a;
  9175. d = null == d ? !0 : d;
  9176. var e = cc.newElement("canvas");
  9177. e.width = c.width;
  9178. e.height = c.height;
  9179. var f = e.getContext("2d");
  9180. f.translate(e.width / 2, e.height / 2);
  9181. d ? f.rotate(-1.5707963267948966) : f.rotate(1.5707963267948966);
  9182. f.drawImage(a, c.x, c.y, c.height, c.width, -c.height / 2, -c.width /
  9183. 2, c.height, c.width);
  9184. return e
  9185. }
  9186. })();
  9187. (function() {
  9188. cc.Sprite.WebGLRenderCmd = function(a) {
  9189. cc.Node.WebGLRenderCmd.call(this, a);
  9190. this._needDraw = !0;
  9191. this._quad = new cc.V3F_C4B_T2F_Quad;
  9192. this._quadWebBuffer = cc._renderContext.createBuffer();
  9193. this._quadDirty = !0;
  9194. this._recursiveDirty = this._dirty = !1
  9195. };
  9196. var a = cc.Sprite.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  9197. a.constructor = cc.Sprite.WebGLRenderCmd;
  9198. a.updateBlendFunc = function(a) {};
  9199. a.setDirtyFlag = function(a) {
  9200. cc.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this, a);
  9201. this._dirty = !0
  9202. };
  9203. a.setDirtyRecursively = function(a) {
  9204. this._dirty = this._recursiveDirty = a;
  9205. for (var c = this._node._children, d, e = c ? c.length : 0, f = 0; f < e; f++) d = c[f], d instanceof cc.Sprite && d._renderCmd.setDirtyRecursively(a)
  9206. };
  9207. a._setBatchNodeForAddChild = function(a) {
  9208. var c = this._node;
  9209. if (c._batchNode) {
  9210. if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.Sprite_addChild), !1;
  9211. a.texture._webTextureObj !== c.textureAtlas.texture._webTextureObj && cc.log(cc._LogInfos.Sprite_addChild_2);
  9212. c._batchNode.appendChild(a);
  9213. c._reorderChildDirty ||
  9214. c._setReorderChildDirtyRecursively()
  9215. }
  9216. return !0
  9217. };
  9218. a._handleTextureForRotatedTexture = function(a) {
  9219. return a
  9220. };
  9221. a.isFrameDisplayed = function(a) {
  9222. var c = this._node;
  9223. return cc.rectEqualToRect(a.getRect(), c._rect) && a.getTexture().getName() === c._texture.getName() && cc.pointEqualToPoint(a.getOffset(), c._unflippedOffsetPositionFromCenter)
  9224. };
  9225. a._init = function() {
  9226. var a = {
  9227. r: 255,
  9228. g: 255,
  9229. b: 255,
  9230. a: 255
  9231. },
  9232. c = this._quad;
  9233. c.bl.colors = a;
  9234. c.br.colors = a;
  9235. c.tl.colors = a;
  9236. c.tr.colors = a;
  9237. this._quadDirty = !0
  9238. };
  9239. a._resetForBatchNode = function() {
  9240. var a = this._node,
  9241. c = a._offsetPosition.x,
  9242. d = a._offsetPosition.y,
  9243. e = c + a._rect.width,
  9244. a = d + a._rect.height,
  9245. f = this._quad;
  9246. f.bl.vertices = {
  9247. x: c,
  9248. y: d,
  9249. z: 0
  9250. };
  9251. f.br.vertices = {
  9252. x: e,
  9253. y: d,
  9254. z: 0
  9255. };
  9256. f.tl.vertices = {
  9257. x: c,
  9258. y: a,
  9259. z: 0
  9260. };
  9261. f.tr.vertices = {
  9262. x: e,
  9263. y: a,
  9264. z: 0
  9265. };
  9266. this._quadDirty = !0
  9267. };
  9268. a.getQuad = function() {
  9269. return this._quad
  9270. };
  9271. a._updateForSetSpriteFrame = function() {};
  9272. a._spriteFrameLoadedCallback = function(a) {
  9273. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  9274. this.dispatchEvent("load")
  9275. };
  9276. a._textureLoadedCallback = function(a) {
  9277. var c = this._renderCmd;
  9278. if (!this._textureLoaded) {
  9279. this._textureLoaded = !0;
  9280. var d = this._rect;
  9281. d ? cc._rectEqualToZero(d) && (d.width = a.width, d.height = a.height) : d = cc.rect(0, 0, a.width, a.height);
  9282. this.texture = a;
  9283. this.setTextureRect(d, this._rectRotated);
  9284. this.setBatchNode(this._batchNode);
  9285. c._quadDirty = !0;
  9286. this.dispatchEvent("load")
  9287. }
  9288. };
  9289. a._setTextureCoords = function(a, c) {
  9290. void 0 === c && (c = !0);
  9291. c && (a = cc.rectPointsToPixels(a));
  9292. var d = this._node,
  9293. e = d._batchNode ? d.textureAtlas.texture : d._texture;
  9294. if (e) {
  9295. var f = e.pixelsWidth,
  9296. g = e.pixelsHeight,
  9297. h, k, m = this._quad;
  9298. d._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (e = (2 * a.x + 1) / (2 * f), f = e + (2 * a.height - 2) / (2 * f), h = (2 * a.y + 1) / (2 * g), g = h + (2 * a.width - 2) / (2 * g)) : (e = a.x / f, f = (a.x + a.height) / f, h = a.y / g, g = (a.y + a.width) / g), d._flippedX && (k = h, h = g, g = k), d._flippedY && (k = e, e = f, f = k), m.bl.texCoords.u = e, m.bl.texCoords.v = h, m.br.texCoords.u = e, m.br.texCoords.v = g, m.tl.texCoords.u = f, m.tl.texCoords.v = h, m.tr.texCoords.u = f, m.tr.texCoords.v = g) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (e = (2 * a.x + 1) / (2 * f), f = e + (2 * a.width - 2) / (2 * f), h = (2 * a.y + 1) / (2 * g), g =
  9299. h + (2 * a.height - 2) / (2 * g)) : (e = a.x / f, f = (a.x + a.width) / f, h = a.y / g, g = (a.y + a.height) / g), d._flippedX && (k = e, e = f, f = k), d._flippedY && (k = h, h = g, g = k), m.bl.texCoords.u = e, m.bl.texCoords.v = g, m.br.texCoords.u = f, m.br.texCoords.v = g, m.tl.texCoords.u = e, m.tl.texCoords.v = h, m.tr.texCoords.u = f, m.tr.texCoords.v = h);
  9300. this._quadDirty = !0
  9301. }
  9302. };
  9303. a.transform = function(a, c) {
  9304. cc.Node.WebGLRenderCmd.prototype.transform.call(this, a, c);
  9305. this._dirty = !0
  9306. };
  9307. a._setColorDirty = function() {};
  9308. a._updateColor = function() {
  9309. var a = this._displayedColor,
  9310. c = this._displayedOpacity,
  9311. d = this._node,
  9312. a = {
  9313. r: a.r,
  9314. g: a.g,
  9315. b: a.b,
  9316. a: c
  9317. };
  9318. d._opacityModifyRGB && (a.r *= c / 255, a.g *= c / 255, a.b *= c / 255);
  9319. c = this._quad;
  9320. c.bl.colors = a;
  9321. c.br.colors = a;
  9322. c.tl.colors = a;
  9323. c.tr.colors = a;
  9324. d._batchNode && (d.atlasIndex !== cc.Sprite.INDEX_NOT_INITIALIZED ? d.textureAtlas.updateQuad(c, d.atlasIndex) : this._dirty = !0);
  9325. this._quadDirty = !0
  9326. };
  9327. a._updateBlendFunc = function() {
  9328. if (this._batchNode) cc.log(cc._LogInfos.Sprite__updateBlendFunc);
  9329. else {
  9330. var a = this._node;
  9331. a._texture && a._texture.hasPremultipliedAlpha() ? (a._blendFunc.src = cc.BLEND_SRC, a._blendFunc.dst =
  9332. cc.BLEND_DST, a.opacityModifyRGB = !0) : (a._blendFunc.src = cc.SRC_ALPHA, a._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA, a.opacityModifyRGB = !1)
  9333. }
  9334. };
  9335. a._setTexture = function(a) {
  9336. var c = this._node;
  9337. if (c._batchNode) {
  9338. if (c._batchNode.texture !== a) {
  9339. cc.log(cc._LogInfos.Sprite_setTexture);
  9340. return
  9341. }
  9342. } else c._texture !== a && (c._textureLoaded = a ? a._textureLoaded : !1, c._texture = a, this._updateBlendFunc());
  9343. this._shaderProgram = a ? cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) : cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR)
  9344. };
  9345. a.updateTransform = function() {
  9346. var a = this._node;
  9347. if (this._dirty) {
  9348. var c = this._quad,
  9349. d = a._parent;
  9350. if (!a._visible || d && d !== a._batchNode && d._shouldBeHidden) c.br.vertices = c.tl.vertices = c.tr.vertices = c.bl.vertices = {
  9351. x: 0,
  9352. y: 0,
  9353. z: 0
  9354. }, a._shouldBeHidden = !0;
  9355. else {
  9356. a._shouldBeHidden = !1;
  9357. 0 !== this._dirtyFlag && (this.updateStatus(), this._dirtyFlag = 0);
  9358. a._transformToBatch = d && d !== a._batchNode ? cc.affineTransformConcat(this.getNodeToParentTransform(), d._transformToBatch) : this.getNodeToParentTransform();
  9359. var e = a._transformToBatch,
  9360. f =
  9361. a._rect,
  9362. d = a._offsetPosition.x,
  9363. g = a._offsetPosition.y,
  9364. h = d + f.width,
  9365. k = g + f.height,
  9366. m = e.tx,
  9367. n = e.ty,
  9368. p = e.a,
  9369. t = e.b,
  9370. r = e.d,
  9371. u = -e.c,
  9372. e = d * p - g * u + m,
  9373. f = d * t + g * r + n,
  9374. s = h * p - g * u + m,
  9375. g = h * t + g * r + n,
  9376. v = h * p - k * u + m,
  9377. h = h * t + k * r + n,
  9378. m = d * p - k * u + m,
  9379. d = d * t + k * r + n,
  9380. k = a._vertexZ;
  9381. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (e |= 0, f |= 0, s |= 0, g |= 0, v |= 0, h |= 0, m |= 0, d |= 0);
  9382. c.bl.vertices = {
  9383. x: e,
  9384. y: f,
  9385. z: k
  9386. };
  9387. c.br.vertices = {
  9388. x: s,
  9389. y: g,
  9390. z: k
  9391. };
  9392. c.tl.vertices = {
  9393. x: m,
  9394. y: d,
  9395. z: k
  9396. };
  9397. c.tr.vertices = {
  9398. x: v,
  9399. y: h,
  9400. z: k
  9401. }
  9402. }
  9403. a.textureAtlas.updateQuad(c, a.atlasIndex);
  9404. this._dirty = a._recursiveDirty = !1
  9405. }
  9406. a._hasChildren &&
  9407. a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform)
  9408. };
  9409. a._checkTextureBoundary = function(a, c, d) {
  9410. a && a.url && (d ? (d = c.x + c.height, c = c.y + c.width) : (d = c.x + c.width, c = c.y + c.height), d > a.width && cc.error(cc._LogInfos.RectWidth, a.url), c > a.height && cc.error(cc._LogInfos.RectHeight, a.url))
  9411. };
  9412. a.rendering = function(a) {
  9413. var c = this._node,
  9414. d = c._texture;
  9415. d && !d._textureLoaded || 0 === this._displayedOpacity || (a = a || cc._renderContext, d ? d._textureLoaded && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),
  9416. cc.glBlendFunc(c._blendFunc.src, c._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._setUniformForMVPMatrixWithMat4(this._stackMatrix),
  9417. cc.glBlendFunc(c._blendFunc.src, c._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 && (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_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4)), cc.g_NumberOfDraws++,
  9418. 0 === cc.SPRITE_DEBUG_DRAW && !c._showNode) || (cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW), cc.current_stack.stack.push(cc.current_stack.top), cc.current_stack.top = this._stackMatrix, 1 === cc.SPRITE_DEBUG_DRAW || c._showNode ? (c = this._quad, c = [cc.p(c.tl.vertices.x, c.tl.vertices.y), cc.p(c.bl.vertices.x, c.bl.vertices.y), cc.p(c.br.vertices.x, c.br.vertices.y), cc.p(c.tr.vertices.x, c.tr.vertices.y)], cc._drawingUtil.drawPoly(c, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (d = c.getTextureRect(), c = c.getOffsetPosition(), c = [cc.p(c.x, c.y), cc.p(c.x +
  9419. d.width, c.y), cc.p(c.x + d.width, c.y + d.height), cc.p(c.x, c.y + d.height)], cc._drawingUtil.drawPoly(c, 4, !0)), cc.current_stack.top = cc.current_stack.stack.pop())
  9420. }
  9421. })();
  9422. cc.SpriteBatchNode = cc.Node.extend({
  9423. _blendFunc: null,
  9424. _descendants: null,
  9425. _className: "SpriteBatchNode",
  9426. ctor: function(a, b) {
  9427. cc.Node.prototype.ctor.call(this);
  9428. this._descendants = [];
  9429. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  9430. var c;
  9431. b = b || cc.SpriteBatchNode.DEFAULT_CAPACITY;
  9432. cc.isString(a) ? (c = cc.textureCache.getTextureForKey(a)) || (c = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (c = a);
  9433. c && this.initWithTexture(c, b)
  9434. },
  9435. addSpriteWithoutQuad: function(a, b, c) {
  9436. cc.assert(a, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2);
  9437. if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad), null;
  9438. a.atlasIndex = b;
  9439. var d = 0,
  9440. e, f = this._descendants;
  9441. if (f && 0 < f.length)
  9442. for (d = 0, e = f.length; d < e; d++) {
  9443. var g = f[d];
  9444. if (g && g.atlasIndex >= b) break
  9445. }
  9446. f.splice(d, 0, a);
  9447. cc.Node.prototype.addChild.call(this, a, b, c);
  9448. this.reorderBatch(!1);
  9449. return this
  9450. },
  9451. getTextureAtlas: function() {
  9452. return this._renderCmd.getTextureAtlas()
  9453. },
  9454. setTextureAtlas: function(a) {
  9455. this._renderCmd.getTextureAtlas(a)
  9456. },
  9457. getDescendants: function() {
  9458. return this._descendants
  9459. },
  9460. initWithFile: function(a, b) {
  9461. var c = cc.textureCache.getTextureForKey(a);
  9462. c || (c = cc.textureCache.addImage(a));
  9463. return this.initWithTexture(c, b)
  9464. },
  9465. _setNodeDirtyForCache: function() {
  9466. this._renderCmd && this._renderCmd._setNodeDirtyForCache && this._renderCmd._setNodeDirtyForCache()
  9467. },
  9468. init: function(a, b) {
  9469. var c = cc.textureCache.getTextureForKey(a);
  9470. c || (c = cc.textureCache.addImage(a));
  9471. return this.initWithTexture(c, b)
  9472. },
  9473. increaseAtlasCapacity: function() {
  9474. this._renderCmd.increaseAtlasCapacity()
  9475. },
  9476. removeChildAtIndex: function(a,
  9477. b) {
  9478. this.removeChild(this._children[a], b)
  9479. },
  9480. rebuildIndexInOrder: function(a, b) {
  9481. var c = a.children;
  9482. if (c && 0 < c.length)
  9483. for (var d = 0; d < c.length; d++) {
  9484. var e = c[d];
  9485. e && 0 > e.zIndex && (b = this.rebuildIndexInOrder(e, b))
  9486. }!a === this && (a.atlasIndex = b, b++);
  9487. if (c && 0 < c.length)
  9488. for (d = 0; d < c.length; d++)(e = c[d]) && 0 <= e.zIndex && (b = this.rebuildIndexInOrder(e, b));
  9489. return b
  9490. },
  9491. highestAtlasIndexInChild: function(a) {
  9492. var b = a.children;
  9493. return b && 0 !== b.length ? this.highestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex
  9494. },
  9495. lowestAtlasIndexInChild: function(a) {
  9496. var b =
  9497. a.children;
  9498. return b && 0 !== b.length ? this.lowestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex
  9499. },
  9500. atlasIndexForChild: function(a, b) {
  9501. var c = a.parent,
  9502. d = c.children,
  9503. e = d.indexOf(a),
  9504. f = null;
  9505. 0 < e && e < cc.UINT_MAX && (f = d[e - 1]);
  9506. return c === this ? 0 === e ? 0 : this.highestAtlasIndexInChild(f) + 1 : 0 === e ? 0 > b ? c.atlasIndex : c.atlasIndex + 1 : 0 > f.zIndex && 0 > b || 0 <= f.zIndex && 0 <= b ? this.highestAtlasIndexInChild(f) + 1 : c.atlasIndex + 1
  9507. },
  9508. reorderBatch: function(a) {
  9509. this._reorderChildDirty = a
  9510. },
  9511. setBlendFunc: function(a, b) {
  9512. this._blendFunc = void 0 === b ? a : {
  9513. src: a,
  9514. dst: b
  9515. }
  9516. },
  9517. getBlendFunc: function() {
  9518. return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst)
  9519. },
  9520. reorderChild: function(a, b) {
  9521. cc.assert(a, cc._LogInfos.SpriteBatchNode_reorderChild_2); - 1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_reorderChild) : b !== a.zIndex && cc.Node.prototype.reorderChild.call(this, a, b)
  9522. },
  9523. removeChild: function(a, b) {
  9524. null != a && (-1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_removeChild) : (this.removeSpriteFromAtlas(a), cc.Node.prototype.removeChild.call(this,
  9525. a, b)))
  9526. },
  9527. updateQuadFromSprite: function(a, b) {
  9528. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2);
  9529. a instanceof cc.Sprite ? (this._renderCmd.checkAtlasCapacity(), a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform()) : cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
  9530. },
  9531. insertQuadFromSprite: function(a, b) {
  9532. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2);
  9533. a instanceof cc.Sprite ? (this._renderCmd.insertQuad(a, b), a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform(),
  9534. this._renderCmd.cutting(a, b)) : cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite)
  9535. },
  9536. initWithTexture: function(a, b) {
  9537. this._children.length = 0;
  9538. this._descendants.length = 0;
  9539. b = b || cc.SpriteBatchNode.DEFAULT_CAPACITY;
  9540. this._renderCmd.initWithTexture(a, b);
  9541. return !0
  9542. },
  9543. insertChild: function(a, b) {
  9544. a.batchNode = this;
  9545. a.atlasIndex = b;
  9546. a.dirty = !0;
  9547. this._renderCmd.insertQuad(a, b);
  9548. this._descendants.splice(b, 0, a);
  9549. var c = b + 1,
  9550. d = this._descendants;
  9551. if (d && 0 < d.length)
  9552. for (; c < d.length; c++) d[c].atlasIndex++;
  9553. var d = a.children,
  9554. e, f;
  9555. if (d)
  9556. for (c =
  9557. 0, f = d.length || 0; c < f; c++)
  9558. if (e = d[c]) {
  9559. var g = this.atlasIndexForChild(e, e.zIndex);
  9560. this.insertChild(e, g)
  9561. }
  9562. },
  9563. appendChild: function(a) {
  9564. this._reorderChildDirty = !0;
  9565. a.batchNode = this;
  9566. a.dirty = !0;
  9567. this._descendants.push(a);
  9568. var b = this._descendants.length - 1;
  9569. a.atlasIndex = b;
  9570. this._renderCmd.insertQuad(a, b);
  9571. a = a.children;
  9572. for (var b = 0, c = a.length || 0; b < c; b++) this.appendChild(a[b])
  9573. },
  9574. removeSpriteFromAtlas: function(a) {
  9575. this._renderCmd.removeQuadAtIndex(a.atlasIndex);
  9576. a.batchNode = null;
  9577. var b = this._descendants,
  9578. c = b.indexOf(a);
  9579. if (-1 !==
  9580. c) {
  9581. b.splice(c, 1);
  9582. for (var d = b.length; c < d; ++c) b[c].atlasIndex--
  9583. }
  9584. if (a = a.children)
  9585. for (b = 0, c = a.length || 0; b < c; b++) a[b] && this.removeSpriteFromAtlas(a[b])
  9586. },
  9587. getTexture: function() {
  9588. return this._renderCmd.getTexture()
  9589. },
  9590. setTexture: function(a) {
  9591. this._renderCmd.setTexture(a)
  9592. },
  9593. addChild: function(a, b, c) {
  9594. cc.assert(null != a, cc._LogInfos.CCSpriteBatchNode_addChild_3);
  9595. this._renderCmd.isValidChild(a) && (b = null == b ? a.zIndex : b, c = null == c ? a.tag : c, cc.Node.prototype.addChild.call(this, a, b, c), this.appendChild(a))
  9596. },
  9597. removeAllChildren: function(a) {
  9598. var b =
  9599. this._descendants;
  9600. if (b && 0 < b.length)
  9601. for (var c = 0, d = b.length; c < d; c++) b[c] && (b[c].batchNode = null);
  9602. cc.Node.prototype.removeAllChildren.call(this, a);
  9603. this._descendants.length = 0;
  9604. this._renderCmd.removeAllQuads()
  9605. },
  9606. sortAllChildren: function() {
  9607. if (this._reorderChildDirty) {
  9608. var a = this._children,
  9609. b, c = 0,
  9610. d = a.length,
  9611. e;
  9612. for (b = 1; b < d; b++) {
  9613. var f = a[b],
  9614. c = b - 1;
  9615. for (e = a[c]; 0 <= c && (f._localZOrder < e._localZOrder || f._localZOrder === e._localZOrder && f.arrivalOrder < e.arrivalOrder);) a[c + 1] = e, c -= 1, e = a[c];
  9616. a[c + 1] = f
  9617. }
  9618. 0 < a.length && (this._arrayMakeObjectsPerformSelector(a,
  9619. cc.Node._stateCallbackType.sortAllChildren), this._renderCmd.updateChildrenAtlasIndex(a));
  9620. this._reorderChildDirty = !1
  9621. }
  9622. },
  9623. _createRenderCmd: function() {
  9624. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.SpriteBatchNode.CanvasRenderCmd(this) : new cc.SpriteBatchNode.WebGLRenderCmd(this)
  9625. }
  9626. });
  9627. _p = cc.SpriteBatchNode.prototype;
  9628. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  9629. cc.defineGetterSetter(_p, "textureAtlas", _p.getTextureAtlas, _p.setTextureAtlas);
  9630. cc.defineGetterSetter(_p, "descendants", _p.getDescendants);
  9631. cc.SpriteBatchNode.DEFAULT_CAPACITY = 29;
  9632. cc.SpriteBatchNode.create = function(a, b) {
  9633. return new cc.SpriteBatchNode(a, b)
  9634. };
  9635. cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create;
  9636. (function() {
  9637. cc.SpriteBatchNode.CanvasRenderCmd = function(a) {
  9638. cc.Node.CanvasRenderCmd.call(this, a);
  9639. this._originalTexture = this._texture = null
  9640. };
  9641. var a = cc.SpriteBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  9642. a.constructor = cc.SpriteBatchNode.CanvasRenderCmd;
  9643. a.checkAtlasCapacity = function() {};
  9644. a.isValidChild = function(a) {
  9645. return a instanceof cc.Sprite ? !0 : (cc.log(cc._LogInfos.Sprite_addChild_4), !1)
  9646. };
  9647. a.initWithTexture = function(a, c) {
  9648. this._texture = this._originalTexture = a
  9649. };
  9650. a.insertQuad =
  9651. function(a, c) {};
  9652. a.increaseAtlasCapacity = function() {};
  9653. a.removeQuadAtIndex = function() {};
  9654. a.removeAllQuads = function() {};
  9655. a.getTexture = function() {
  9656. return this._texture
  9657. };
  9658. a.setTexture = function(a) {
  9659. this._texture = a;
  9660. for (var c = this._node._children, d = 0; d < c.length; d++) c[d].setTexture(a)
  9661. };
  9662. a.updateChildrenAtlasIndex = function(a) {
  9663. for (var c = this._node._descendants.length = 0, d = a.length; c < d; c++) this._updateAtlasIndex(a[c])
  9664. };
  9665. a._updateAtlasIndex = function(a) {
  9666. var c = this._node._descendants,
  9667. d = a.children,
  9668. e, f = d.length;
  9669. for (e = 0; e <
  9670. f; e++)
  9671. if (0 > d[e]._localZOrder) c.push(d[e]);
  9672. else break;
  9673. for (c.push(a); e < f; e++) c.push(d[e])
  9674. };
  9675. a.getTextureAtlas = function() {};
  9676. a.setTextureAtlas = function(a) {};
  9677. a.cutting = function(a, c) {
  9678. this._node._children.splice(c, 0, a)
  9679. }
  9680. })();
  9681. (function() {
  9682. cc.SpriteBatchNode.WebGLRenderCmd = function(a) {
  9683. cc.Node.WebGLRenderCmd.call(this, a);
  9684. this._needDraw = !0;
  9685. this._textureAtlas = null
  9686. };
  9687. var a = cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  9688. a.constructor = cc.SpriteBatchNode.WebGLRenderCmd;
  9689. a.isValidChild = function(a) {
  9690. return a instanceof cc.Sprite ? a.texture != this.getTexture() ? (cc.log(cc._LogInfos.Sprite_addChild_5), !1) : !0 : (cc.log(cc._LogInfos.Sprite_addChild_4), !1)
  9691. };
  9692. a.rendering = function() {
  9693. var a = this._node;
  9694. 0 !== this._textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), a._arrayMakeObjectsPerformSelector(a._children, cc.Node._stateCallbackType.updateTransform), cc.glBlendFunc(a._blendFunc.src, a._blendFunc.dst), this._textureAtlas.drawQuads())
  9695. };
  9696. a.visit = function(a) {
  9697. var c = this._node;
  9698. if (c._visible) {
  9699. c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1);
  9700. var d = cc.current_stack;
  9701. d.stack.push(d.top);
  9702. this._dirtyFlag &
  9703. cc.Node._dirtyFlags.transformDirty || this.transform(a);
  9704. this.updateStatus(a);
  9705. d.top = this._stackMatrix;
  9706. c.sortAllChildren();
  9707. cc.renderer.pushRenderCommand(this);
  9708. this._dirtyFlag = 0;
  9709. d.top = d.stack.pop()
  9710. }
  9711. };
  9712. a.checkAtlasCapacity = function(a) {
  9713. for (var c = this._textureAtlas; a >= c.capacity || c.capacity === c.totalQuads;) this.increaseAtlasCapacity()
  9714. };
  9715. a.increaseAtlasCapacity = function() {
  9716. var a = this._textureAtlas.capacity,
  9717. c = Math.floor(4 * (a + 1) / 3);
  9718. cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, a, c);
  9719. this._textureAtlas.resizeCapacity(c) ||
  9720. cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)
  9721. };
  9722. a.initWithTexture = function(a, c) {
  9723. this._textureAtlas = new cc.TextureAtlas;
  9724. this._textureAtlas.initWithTexture(a, c);
  9725. this._updateBlendFunc();
  9726. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  9727. };
  9728. a.insertQuad = function(a, c) {
  9729. var d = this._textureAtlas;
  9730. d.totalQuads >= d.capacity && this.increaseAtlasCapacity();
  9731. d.insertQuad(a.quad, c)
  9732. };
  9733. a.removeQuadAtIndex = function(a) {
  9734. this._textureAtlas.removeQuadAtIndex(a)
  9735. };
  9736. a.getTexture = function() {
  9737. return this._textureAtlas.texture
  9738. };
  9739. a.setTexture = function(a) {
  9740. this._textureAtlas.setTexture(a);
  9741. a && this._updateBlendFunc()
  9742. };
  9743. a.removeAllQuads = function() {
  9744. this._textureAtlas.removeAllQuads()
  9745. };
  9746. a._swap = function(a, c) {
  9747. var d = this._node._descendants,
  9748. e = this._textureAtlas,
  9749. f = e.quads,
  9750. g = d[a],
  9751. h = cc.V3F_C4B_T2F_QuadCopy(f[a]);
  9752. d[c].atlasIndex = a;
  9753. d[a] = d[c];
  9754. e.updateQuad(f[c], a);
  9755. d[c] = g;
  9756. e.updateQuad(h, c)
  9757. };
  9758. a._updateAtlasIndex = function(a, c) {
  9759. var d = 0,
  9760. e = a.children;
  9761. e && (d = e.length);
  9762. var f = 0;
  9763. if (0 === d) f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f,
  9764. c), c++;
  9765. else {
  9766. f = !0;
  9767. 0 <= e[0].zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++, f = !1);
  9768. for (d = 0; d < e.length; d++) {
  9769. var g = e[d];
  9770. f && 0 <= g.zIndex && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++, f = !1);
  9771. c = this._updateAtlasIndex(g, c)
  9772. }
  9773. f && (f = a.atlasIndex, a.atlasIndex = c, a.arrivalOrder = 0, f !== c && this._swap(f, c), c++)
  9774. }
  9775. return c
  9776. };
  9777. a.updateChildrenAtlasIndex = function(a) {
  9778. for (var c = 0, d = 0; d < a.length; d++) c = this._updateAtlasIndex(a[d], c)
  9779. };
  9780. a._updateBlendFunc = function() {
  9781. if (!this._textureAtlas.texture.hasPremultipliedAlpha()) {
  9782. var a =
  9783. this._node._blendFunc;
  9784. a.src = cc.SRC_ALPHA;
  9785. a.dst = cc.ONE_MINUS_SRC_ALPHA
  9786. }
  9787. };
  9788. a.getTextureAtlas = function() {
  9789. return this._textureAtlas
  9790. };
  9791. a.setTextureAtlas = function(a) {
  9792. a !== this._textureAtlas && (this._textureAtlas = a)
  9793. };
  9794. a.cutting = function() {}
  9795. })();
  9796. cc.BakeSprite = cc.Sprite.extend({
  9797. _cacheCanvas: null,
  9798. _cacheContext: null,
  9799. ctor: function() {
  9800. cc.Sprite.prototype.ctor.call(this);
  9801. var a = document.createElement("canvas");
  9802. a.width = a.height = 10;
  9803. this._cacheCanvas = a;
  9804. this._cacheContext = new cc.CanvasContextWrapper(a.getContext("2d"));
  9805. var b = new cc.Texture2D;
  9806. b.initWithElement(a);
  9807. b.handleLoadedTexture();
  9808. this.setTexture(b)
  9809. },
  9810. getCacheContext: function() {
  9811. return this._cacheContext
  9812. },
  9813. getCacheCanvas: function() {
  9814. return this._cacheCanvas
  9815. },
  9816. resetCanvasSize: function(a, b) {
  9817. void 0 === b &&
  9818. (b = a.height, a = a.width);
  9819. var c = this._cacheCanvas;
  9820. c.width = a;
  9821. c.height = b;
  9822. this.getTexture().handleLoadedTexture();
  9823. this.setTextureRect(cc.rect(0, 0, a, b), !1)
  9824. }
  9825. });
  9826. cc.AnimationFrame = cc.Class.extend({
  9827. _spriteFrame: null,
  9828. _delayPerUnit: 0,
  9829. _userInfo: null,
  9830. ctor: function(a, b, c) {
  9831. this._spriteFrame = a || null;
  9832. this._delayPerUnit = b || 0;
  9833. this._userInfo = c || null
  9834. },
  9835. clone: function() {
  9836. var a = new cc.AnimationFrame;
  9837. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  9838. return a
  9839. },
  9840. copyWithZone: function(a) {
  9841. return cc.clone(this)
  9842. },
  9843. copy: function(a) {
  9844. a = new cc.AnimationFrame;
  9845. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  9846. return a
  9847. },
  9848. initWithSpriteFrame: function(a,
  9849. b, c) {
  9850. this._spriteFrame = a;
  9851. this._delayPerUnit = b;
  9852. this._userInfo = c;
  9853. return !0
  9854. },
  9855. getSpriteFrame: function() {
  9856. return this._spriteFrame
  9857. },
  9858. setSpriteFrame: function(a) {
  9859. this._spriteFrame = a
  9860. },
  9861. getDelayUnits: function() {
  9862. return this._delayPerUnit
  9863. },
  9864. setDelayUnits: function(a) {
  9865. this._delayPerUnit = a
  9866. },
  9867. getUserInfo: function() {
  9868. return this._userInfo
  9869. },
  9870. setUserInfo: function(a) {
  9871. this._userInfo = a
  9872. }
  9873. });
  9874. cc.AnimationFrame.create = function(a, b, c) {
  9875. return new cc.AnimationFrame(a, b, c)
  9876. };
  9877. cc.Animation = cc.Class.extend({
  9878. _frames: null,
  9879. _loops: 0,
  9880. _restoreOriginalFrame: !1,
  9881. _duration: 0,
  9882. _delayPerUnit: 0,
  9883. _totalDelayUnits: 0,
  9884. ctor: function(a, b, c) {
  9885. this._frames = [];
  9886. if (void 0 === a) this.initWithSpriteFrames(null, 0);
  9887. else {
  9888. var d = a[0];
  9889. d && (d instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, b, c) : d instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, b, c))
  9890. }
  9891. },
  9892. getFrames: function() {
  9893. return this._frames
  9894. },
  9895. setFrames: function(a) {
  9896. this._frames = a
  9897. },
  9898. addSpriteFrame: function(a) {
  9899. var b = new cc.AnimationFrame;
  9900. b.initWithSpriteFrame(a,
  9901. 1, null);
  9902. this._frames.push(b);
  9903. this._totalDelayUnits++
  9904. },
  9905. addSpriteFrameWithFile: function(a) {
  9906. a = cc.textureCache.addImage(a);
  9907. var b = cc.rect(0, 0, 0, 0);
  9908. b.width = a.width;
  9909. b.height = a.height;
  9910. a = new cc.SpriteFrame(a, b);
  9911. this.addSpriteFrame(a)
  9912. },
  9913. addSpriteFrameWithTexture: function(a, b) {
  9914. var c = new cc.SpriteFrame(a, b);
  9915. this.addSpriteFrame(c)
  9916. },
  9917. initWithAnimationFrames: function(a, b, c) {
  9918. cc.arrayVerifyType(a, cc.AnimationFrame);
  9919. this._delayPerUnit = b;
  9920. this._loops = void 0 === c ? 1 : c;
  9921. this._totalDelayUnits = 0;
  9922. b = this._frames;
  9923. for (c = b.length =
  9924. 0; c < a.length; c++) {
  9925. var d = a[c];
  9926. b.push(d);
  9927. this._totalDelayUnits += d.getDelayUnits()
  9928. }
  9929. return !0
  9930. },
  9931. clone: function() {
  9932. var a = new cc.Animation;
  9933. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9934. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9935. return a
  9936. },
  9937. copyWithZone: function(a) {
  9938. a = new cc.Animation;
  9939. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9940. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9941. return a
  9942. },
  9943. _copyFrames: function() {
  9944. for (var a = [], b = 0; b < this._frames.length; b++) a.push(this._frames[b].clone());
  9945. return a
  9946. },
  9947. copy: function(a) {
  9948. return this.copyWithZone(null)
  9949. },
  9950. getLoops: function() {
  9951. return this._loops
  9952. },
  9953. setLoops: function(a) {
  9954. this._loops = a
  9955. },
  9956. setRestoreOriginalFrame: function(a) {
  9957. this._restoreOriginalFrame = a
  9958. },
  9959. getRestoreOriginalFrame: function() {
  9960. return this._restoreOriginalFrame
  9961. },
  9962. getDuration: function() {
  9963. return this._totalDelayUnits * this._delayPerUnit
  9964. },
  9965. getDelayPerUnit: function() {
  9966. return this._delayPerUnit
  9967. },
  9968. setDelayPerUnit: function(a) {
  9969. this._delayPerUnit = a
  9970. },
  9971. getTotalDelayUnits: function() {
  9972. return this._totalDelayUnits
  9973. },
  9974. initWithSpriteFrames: function(a, b, c) {
  9975. cc.arrayVerifyType(a, cc.SpriteFrame);
  9976. this._loops = void 0 === c ? 1 : c;
  9977. this._delayPerUnit = b || 0;
  9978. this._totalDelayUnits = 0;
  9979. b = this._frames;
  9980. b.length = 0;
  9981. if (a) {
  9982. for (c = 0; c < a.length; c++) {
  9983. var d = a[c],
  9984. e = new cc.AnimationFrame;
  9985. e.initWithSpriteFrame(d, 1, null);
  9986. b.push(e)
  9987. }
  9988. this._totalDelayUnits += a.length
  9989. }
  9990. return !0
  9991. },
  9992. retain: function() {},
  9993. release: function() {}
  9994. });
  9995. cc.Animation.create = function(a, b, c) {
  9996. return new cc.Animation(a, b, c)
  9997. };
  9998. cc.Animation.createWithAnimationFrames = cc.Animation.create;
  9999. cc.animationCache = {
  10000. _animations: {},
  10001. addAnimation: function(a, b) {
  10002. this._animations[b] = a
  10003. },
  10004. removeAnimation: function(a) {
  10005. a && this._animations[a] && delete this._animations[a]
  10006. },
  10007. getAnimation: function(a) {
  10008. return this._animations[a] ? this._animations[a] : null
  10009. },
  10010. _addAnimationsWithDictionary: function(a, b) {
  10011. var c = a.animations;
  10012. if (c) {
  10013. var d = 1,
  10014. e = a.properties;
  10015. if (e)
  10016. for (var d = null != e.format ? parseInt(e.format) : d, e = e.spritesheets, f = cc.spriteFrameCache, g = cc.path, h = 0; h < e.length; h++) f.addSpriteFrames(g.changeBasename(b, e[h]));
  10017. switch (d) {
  10018. case 1:
  10019. this._parseVersion1(c);
  10020. break;
  10021. case 2:
  10022. this._parseVersion2(c);
  10023. break;
  10024. default:
  10025. cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)
  10026. }
  10027. } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)
  10028. },
  10029. addAnimations: function(a) {
  10030. cc.assert(a, cc._LogInfos.animationCache_addAnimations_2);
  10031. var b = cc.loader.getRes(a);
  10032. b ? this._addAnimationsWithDictionary(b, a) : cc.log(cc._LogInfos.animationCache_addAnimations)
  10033. },
  10034. _parseVersion1: function(a) {
  10035. var b = cc.spriteFrameCache,
  10036. c;
  10037. for (c in a) {
  10038. var d = a[c],
  10039. e = d.frames,
  10040. d = parseFloat(d.delay) ||
  10041. 0,
  10042. f = null;
  10043. if (e) {
  10044. for (var f = [], g = 0; g < e.length; g++) {
  10045. var h = b.getSpriteFrame(e[g]);
  10046. if (h) {
  10047. var k = new cc.AnimationFrame;
  10048. k.initWithSpriteFrame(h, 1, null);
  10049. f.push(k)
  10050. } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, c, e[g])
  10051. }
  10052. 0 === f.length ? cc.log(cc._LogInfos.animationCache__parseVersion1_3, c) : (f.length !== e.length && cc.log(cc._LogInfos.animationCache__parseVersion1_4, c), f = new cc.Animation(f, d, 1), cc.animationCache.addAnimation(f, c))
  10053. } else cc.log(cc._LogInfos.animationCache__parseVersion1, c)
  10054. }
  10055. },
  10056. _parseVersion2: function(a) {
  10057. var b =
  10058. cc.spriteFrameCache,
  10059. c;
  10060. for (c in a) {
  10061. var d = a[c],
  10062. e = d.loop,
  10063. f = parseInt(d.loops),
  10064. e = e ? cc.REPEAT_FOREVER : isNaN(f) ? 1 : f,
  10065. f = d.restoreOriginalFrame && !0 == d.restoreOriginalFrame ? !0 : !1,
  10066. g = d.frames;
  10067. if (g) {
  10068. for (var h = [], k = 0; k < g.length; k++) {
  10069. var m = g[k],
  10070. n = m.spriteframe,
  10071. p = b.getSpriteFrame(n);
  10072. if (p) {
  10073. var n = parseFloat(m.delayUnits) || 0,
  10074. m = m.notification,
  10075. t = new cc.AnimationFrame;
  10076. t.initWithSpriteFrame(p, n, m);
  10077. h.push(t)
  10078. } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, c, n)
  10079. }
  10080. d = parseFloat(d.delayPerUnit) || 0;
  10081. g = new cc.Animation;
  10082. g.initWithAnimationFrames(h,
  10083. d, e);
  10084. g.setRestoreOriginalFrame(f);
  10085. cc.animationCache.addAnimation(g, c)
  10086. } else cc.log(cc._LogInfos.animationCache__parseVersion2, c)
  10087. }
  10088. },
  10089. _clear: function() {
  10090. this._animations = {}
  10091. }
  10092. };
  10093. cc.SpriteFrame = cc.Class.extend({
  10094. _offset: null,
  10095. _originalSize: null,
  10096. _rectInPixels: null,
  10097. _rotated: !1,
  10098. _rect: null,
  10099. _offsetInPixels: null,
  10100. _originalSizeInPixels: null,
  10101. _texture: null,
  10102. _textureFilename: "",
  10103. _textureLoaded: !1,
  10104. ctor: function(a, b, c, d, e) {
  10105. this._offset = cc.p(0, 0);
  10106. this._offsetInPixels = cc.p(0, 0);
  10107. this._originalSize = cc.size(0, 0);
  10108. this._rotated = !1;
  10109. this._originalSizeInPixels = cc.size(0, 0);
  10110. this._textureFilename = "";
  10111. this._texture = null;
  10112. this._textureLoaded = !1;
  10113. void 0 !== a && void 0 !== b && (void 0 === c || void 0 === d || void 0 === e ?
  10114. this.initWithTexture(a, b) : this.initWithTexture(a, b, c, d, e))
  10115. },
  10116. textureLoaded: function() {
  10117. return this._textureLoaded
  10118. },
  10119. addLoadedEventListener: function(a, b) {
  10120. this.addEventListener("load", a, b)
  10121. },
  10122. getRectInPixels: function() {
  10123. var a = this._rectInPixels;
  10124. return cc.rect(a.x, a.y, a.width, a.height)
  10125. },
  10126. setRectInPixels: function(a) {
  10127. this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0));
  10128. this._rectInPixels.x = a.x;
  10129. this._rectInPixels.y = a.y;
  10130. this._rectInPixels.width = a.width;
  10131. this._rectInPixels.height = a.height;
  10132. this._rect = cc.rectPixelsToPoints(a)
  10133. },
  10134. isRotated: function() {
  10135. return this._rotated
  10136. },
  10137. setRotated: function(a) {
  10138. this._rotated = a
  10139. },
  10140. getRect: function() {
  10141. var a = this._rect;
  10142. return cc.rect(a.x, a.y, a.width, a.height)
  10143. },
  10144. setRect: function(a) {
  10145. this._rect || (this._rect = cc.rect(0, 0, 0, 0));
  10146. this._rect.x = a.x;
  10147. this._rect.y = a.y;
  10148. this._rect.width = a.width;
  10149. this._rect.height = a.height;
  10150. this._rectInPixels = cc.rectPointsToPixels(this._rect)
  10151. },
  10152. getOffsetInPixels: function() {
  10153. return cc.p(this._offsetInPixels)
  10154. },
  10155. setOffsetInPixels: function(a) {
  10156. this._offsetInPixels.x = a.x;
  10157. this._offsetInPixels.y =
  10158. a.y;
  10159. cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset)
  10160. },
  10161. getOriginalSizeInPixels: function() {
  10162. return cc.size(this._originalSizeInPixels)
  10163. },
  10164. setOriginalSizeInPixels: function(a) {
  10165. this._originalSizeInPixels.width = a.width;
  10166. this._originalSizeInPixels.height = a.height
  10167. },
  10168. getOriginalSize: function() {
  10169. return cc.size(this._originalSize)
  10170. },
  10171. setOriginalSize: function(a) {
  10172. this._originalSize.width = a.width;
  10173. this._originalSize.height = a.height
  10174. },
  10175. getTexture: function() {
  10176. if (this._texture) return this._texture;
  10177. if ("" !== this._textureFilename) {
  10178. var a =
  10179. cc.textureCache.addImage(this._textureFilename);
  10180. a && (this._textureLoaded = a.isLoaded());
  10181. return a
  10182. }
  10183. return null
  10184. },
  10185. setTexture: function(a) {
  10186. if (this._texture !== a) {
  10187. var b = a.isLoaded();
  10188. this._textureLoaded = b;
  10189. this._texture = a;
  10190. b || a.addEventListener("load", function(a) {
  10191. this._textureLoaded = !0;
  10192. if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) {
  10193. var b = a.getHtmlElementObj(),
  10194. b = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(b, this.getRect()),
  10195. e = new cc.Texture2D;
  10196. e.initWithElement(b);
  10197. e.handleLoadedTexture();
  10198. this.setTexture(e);
  10199. b = this.getRect();
  10200. this.setRect(cc.rect(0, 0, b.width, b.height))
  10201. }
  10202. b = this._rect;
  10203. 0 === b.width && 0 === b.height && (b = a.width, a = a.height, this._rect.width = b, 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 = b, this._originalSize.height = a);
  10204. this.dispatchEvent("load")
  10205. }, this)
  10206. }
  10207. },
  10208. getOffset: function() {
  10209. return cc.p(this._offset)
  10210. },
  10211. setOffset: function(a) {
  10212. this._offset.x =
  10213. a.x;
  10214. this._offset.y = a.y
  10215. },
  10216. clone: function() {
  10217. var a = new cc.SpriteFrame;
  10218. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  10219. a.setTexture(this._texture);
  10220. return a
  10221. },
  10222. copyWithZone: function() {
  10223. var a = new cc.SpriteFrame;
  10224. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  10225. a.setTexture(this._texture);
  10226. return a
  10227. },
  10228. copy: function() {
  10229. return this.copyWithZone()
  10230. },
  10231. initWithTexture: function(a,
  10232. b, c, d, e) {
  10233. 2 === arguments.length && (b = cc.rectPointsToPixels(b));
  10234. d = d || cc.p(0, 0);
  10235. e = e || b;
  10236. c = c || !1;
  10237. cc.isString(a) ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a);
  10238. a = this.getTexture();
  10239. this._rectInPixels = b;
  10240. b = this._rect = cc.rectPixelsToPoints(b);
  10241. if (a && a.url && a.isLoaded()) {
  10242. var f, g;
  10243. c ? (f = b.x + b.height, g = b.y + b.width) : (f = b.x + b.width, g = b.y + b.height);
  10244. f > a.getPixelsWide() && cc.error(cc._LogInfos.RectWidth, a.url);
  10245. g > a.getPixelsHigh() && cc.error(cc._LogInfos.RectHeight, a.url)
  10246. }
  10247. this._offsetInPixels.x =
  10248. d.x;
  10249. this._offsetInPixels.y = d.y;
  10250. cc._pointPixelsToPointsOut(d, this._offset);
  10251. this._originalSizeInPixels.width = e.width;
  10252. this._originalSizeInPixels.height = e.height;
  10253. cc._sizePixelsToPointsOut(e, this._originalSize);
  10254. this._rotated = c;
  10255. return !0
  10256. }
  10257. });
  10258. cc.EventHelper.prototype.apply(cc.SpriteFrame.prototype);
  10259. cc.SpriteFrame.create = function(a, b, c, d, e) {
  10260. return new cc.SpriteFrame(a, b, c, d, e)
  10261. };
  10262. cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create;
  10263. cc.SpriteFrame._frameWithTextureForCanvas = function(a, b, c, d, e) {
  10264. var f = new cc.SpriteFrame;
  10265. f._texture = a;
  10266. f._rectInPixels = b;
  10267. f._rect = cc.rectPixelsToPoints(b);
  10268. f._offsetInPixels.x = d.x;
  10269. f._offsetInPixels.y = d.y;
  10270. cc._pointPixelsToPointsOut(f._offsetInPixels, f._offset);
  10271. f._originalSizeInPixels.width = e.width;
  10272. f._originalSizeInPixels.height = e.height;
  10273. cc._sizePixelsToPointsOut(f._originalSizeInPixels, f._originalSize);
  10274. f._rotated = c;
  10275. return f
  10276. };
  10277. cc.spriteFrameCache = {
  10278. _CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,
  10279. _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,
  10280. _spriteFrames: {},
  10281. _spriteFramesAliases: {},
  10282. _frameConfigCache: {},
  10283. _rectFromString: function(a) {
  10284. return (a = this._CCNS_REG2.exec(a)) ? cc.rect(parseFloat(a[1]), parseFloat(a[2]), parseFloat(a[3]), parseFloat(a[4])) : cc.rect(0, 0, 0, 0)
  10285. },
  10286. _pointFromString: function(a) {
  10287. return (a = this._CCNS_REG1.exec(a)) ?
  10288. cc.p(parseFloat(a[1]), parseFloat(a[2])) : cc.p(0, 0)
  10289. },
  10290. _sizeFromString: function(a) {
  10291. return (a = this._CCNS_REG1.exec(a)) ? cc.size(parseFloat(a[1]), parseFloat(a[2])) : cc.size(0, 0)
  10292. },
  10293. _getFrameConfig: function(a) {
  10294. var b = cc.loader.getRes(a);
  10295. cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a);
  10296. cc.loader.release(a);
  10297. if (b._inited) return this._frameConfigCache[a] = b;
  10298. this._frameConfigCache[a] = this._parseFrameConfig(b);
  10299. return this._frameConfigCache[a]
  10300. },
  10301. _getFrameConfigByJsonObject: function(a, b) {
  10302. cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2,
  10303. a);
  10304. this._frameConfigCache[a] = this._parseFrameConfig(b);
  10305. return this._frameConfigCache[a]
  10306. },
  10307. _parseFrameConfig: function(a) {
  10308. var b = a.frames,
  10309. c = a.metadata || a.meta;
  10310. a = {};
  10311. var d = {},
  10312. e = 0;
  10313. c && (e = c.format, e = 1 >= e.length ? parseInt(e) : e, d.image = c.textureFileName || c.textureFileName || c.image);
  10314. for (var f in b) {
  10315. var g = b[f];
  10316. if (g) {
  10317. c = {};
  10318. if (0 == e) {
  10319. c.rect = cc.rect(g.x, g.y, g.width, g.height);
  10320. c.rotated = !1;
  10321. c.offset = cc.p(g.offsetX, g.offsetY);
  10322. var h = g.originalWidth,
  10323. g = g.originalHeight;
  10324. h && g || cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);
  10325. h = Math.abs(h);
  10326. g = Math.abs(g);
  10327. c.size = cc.size(h, g)
  10328. } else if (1 == e || 2 == e) c.rect = this._rectFromString(g.frame), c.rotated = g.rotated || !1, c.offset = this._pointFromString(g.offset), c.size = this._sizeFromString(g.sourceSize);
  10329. else if (3 == e) {
  10330. var h = this._sizeFromString(g.spriteSize),
  10331. k = this._rectFromString(g.textureRect);
  10332. h && (k = cc.rect(k.x, k.y, h.width, h.height));
  10333. c.rect = k;
  10334. c.rotated = g.textureRotated || !1;
  10335. c.offset = this._pointFromString(g.spriteOffset);
  10336. c.size = this._sizeFromString(g.spriteSourceSize);
  10337. c.aliases = g.aliases
  10338. } else h =
  10339. g.frame, k = g.sourceSize, f = g.filename || f, c.rect = cc.rect(h.x, h.y, h.w, h.h), c.rotated = g.rotated || !1, c.offset = cc.p(0, 0), c.size = cc.size(k.w, k.h);
  10340. a[f] = c
  10341. }
  10342. }
  10343. return {
  10344. _inited: !0,
  10345. frames: a,
  10346. meta: d
  10347. }
  10348. },
  10349. _addSpriteFramesByObject: function(a, b, c) {
  10350. cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
  10351. b && b.frames && (b = this._frameConfigCache[a] || this._getFrameConfigByJsonObject(a, b), this._createSpriteFrames(a, b, c))
  10352. },
  10353. _createSpriteFrames: function(a, b, c) {
  10354. var d = b.frames;
  10355. b = b.meta;
  10356. c ? c instanceof cc.Texture2D || (cc.isString(c) ?
  10357. c = cc.textureCache.addImage(c) : cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3)) : (c = cc.path.changeBasename(a, b.image || ".png"), c = cc.textureCache.addImage(c));
  10358. a = this._spriteFramesAliases;
  10359. b = this._spriteFrames;
  10360. for (var e in d) {
  10361. var f = d[e],
  10362. g = b[e];
  10363. if (!g) {
  10364. g = new cc.SpriteFrame(c, f.rect, f.rotated, f.offset, f.size);
  10365. if (f = f.aliases)
  10366. for (var h = 0, k = f.length; h < k; h++) {
  10367. var m = f[h];
  10368. a[m] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, m);
  10369. a[m] = e
  10370. }
  10371. cc._renderType === cc._RENDER_TYPE_CANVAS && g.isRotated() && g.getTexture().isLoaded() &&
  10372. (f = g.getTexture().getHtmlElementObj(), f = cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(f, g.getRectInPixels()), h = new cc.Texture2D, h.initWithElement(f), h.handleLoadedTexture(), g.setTexture(h), f = g._rect, g.setRect(cc.rect(0, 0, f.width, f.height)));
  10373. b[e] = g
  10374. }
  10375. }
  10376. },
  10377. addSpriteFrames: function(a, b) {
  10378. cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
  10379. var c = this._frameConfigCache[a] || cc.loader.getRes(a);
  10380. c && c.frames && (c = this._frameConfigCache[a] || this._getFrameConfig(a), this._createSpriteFrames(a, c, b))
  10381. },
  10382. _checkConflict: function(a) {
  10383. a =
  10384. a.frames;
  10385. for (var b in a) this._spriteFrames[b] && cc.log(cc._LogInfos.spriteFrameCache__checkConflict, b)
  10386. },
  10387. addSpriteFrame: function(a, b) {
  10388. this._spriteFrames[b] = a
  10389. },
  10390. removeSpriteFrames: function() {
  10391. this._spriteFrames = {};
  10392. this._spriteFramesAliases = {}
  10393. },
  10394. removeSpriteFrameByName: function(a) {
  10395. a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a])
  10396. },
  10397. removeSpriteFramesFromFile: function(a) {
  10398. var b = this._spriteFrames,
  10399. c = this._spriteFramesAliases;
  10400. if (a = this._frameConfigCache[a]) {
  10401. a =
  10402. a.frames;
  10403. for (var d in a)
  10404. if (b[d]) {
  10405. delete b[d];
  10406. for (var e in c) c[e] === d && delete c[e]
  10407. }
  10408. }
  10409. },
  10410. removeSpriteFramesFromTexture: function(a) {
  10411. var b = this._spriteFrames,
  10412. c = this._spriteFramesAliases,
  10413. d;
  10414. for (d in b) {
  10415. var e = b[d];
  10416. if (e && e.getTexture() === a) {
  10417. delete b[d];
  10418. for (var f in c) c[f] === d && delete c[f]
  10419. }
  10420. }
  10421. },
  10422. getSpriteFrame: function(a) {
  10423. var b = this._spriteFrames[a];
  10424. if (!b) {
  10425. var c = this._spriteFramesAliases[a];
  10426. c && ((b = this._spriteFrames[c.toString()]) || delete this._spriteFramesAliases[a])
  10427. }
  10428. return b
  10429. },
  10430. _clear: function() {
  10431. this._spriteFrames = {};
  10432. this._spriteFramesAliases = {};
  10433. this._frameConfigCache = {}
  10434. }
  10435. };
  10436. cc.configuration = {
  10437. ERROR: 0,
  10438. STRING: 1,
  10439. INT: 2,
  10440. DOUBLE: 3,
  10441. BOOLEAN: 4,
  10442. _maxTextureSize: 0,
  10443. _maxModelviewStackDepth: 0,
  10444. _supportsPVRTC: !1,
  10445. _supportsNPOT: !1,
  10446. _supportsBGRA8888: !1,
  10447. _supportsDiscardFramebuffer: !1,
  10448. _supportsShareableVAO: !1,
  10449. _maxSamplesAllowed: 0,
  10450. _maxTextureUnits: 0,
  10451. _GlExtensions: "",
  10452. _valueDict: {},
  10453. _inited: !1,
  10454. _init: function() {
  10455. var a = this._valueDict;
  10456. a["cocos2d.x.version"] = cc.ENGINE_VERSION;
  10457. a["cocos2d.x.compiled_with_profiler"] = !1;
  10458. a["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
  10459. this._inited = !0
  10460. },
  10461. getMaxTextureSize: function() {
  10462. return this._maxTextureSize
  10463. },
  10464. getMaxModelviewStackDepth: function() {
  10465. return this._maxModelviewStackDepth
  10466. },
  10467. getMaxTextureUnits: function() {
  10468. return this._maxTextureUnits
  10469. },
  10470. supportsNPOT: function() {
  10471. return this._supportsNPOT
  10472. },
  10473. supportsPVRTC: function() {
  10474. return this._supportsPVRTC
  10475. },
  10476. supportsETC: function() {
  10477. return !1
  10478. },
  10479. supportsS3TC: function() {
  10480. return !1
  10481. },
  10482. supportsATITC: function() {
  10483. return !1
  10484. },
  10485. supportsBGRA8888: function() {
  10486. return this._supportsBGRA8888
  10487. },
  10488. supportsDiscardFramebuffer: function() {
  10489. return this._supportsDiscardFramebuffer
  10490. },
  10491. supportsShareableVAO: function() {
  10492. return this._supportsShareableVAO
  10493. },
  10494. checkForGLExtension: function(a) {
  10495. return -1 < this._GlExtensions.indexOf(a)
  10496. },
  10497. getValue: function(a, b) {
  10498. this._inited || this._init();
  10499. var c = this._valueDict;
  10500. return c[a] ? c[a] : b
  10501. },
  10502. setValue: function(a, b) {
  10503. this._valueDict[a] = b
  10504. },
  10505. dumpInfo: function() {
  10506. 0 === cc.ENABLE_GL_STATE_CACHE && (cc.log(""), cc.log(cc._LogInfos.configuration_dumpInfo), cc.log(""))
  10507. },
  10508. gatherGPUInfo: function() {
  10509. if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
  10510. this._inited || this._init();
  10511. var a = cc._renderContext,
  10512. b = this._valueDict;
  10513. b["gl.vendor"] = a.getParameter(a.VENDOR);
  10514. b["gl.renderer"] = a.getParameter(a.RENDERER);
  10515. b["gl.version"] = a.getParameter(a.VERSION);
  10516. this._GlExtensions = "";
  10517. for (var c = a.getSupportedExtensions(), d = 0; d < c.length; d++) this._GlExtensions += c[d] + " ";
  10518. this._maxTextureSize = a.getParameter(a.MAX_TEXTURE_SIZE);
  10519. b["gl.max_texture_size"] = this._maxTextureSize;
  10520. this._maxTextureUnits = a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  10521. b["gl.max_texture_units"] = this._maxTextureUnits;
  10522. this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
  10523. b["gl.supports_PVRTC"] = this._supportsPVRTC;
  10524. this._supportsNPOT = !1;
  10525. b["gl.supports_NPOT"] = this._supportsNPOT;
  10526. this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888");
  10527. b["gl.supports_BGRA8888"] = this._supportsBGRA8888;
  10528. this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer");
  10529. b["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer;
  10530. this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object");
  10531. b["gl.supports_vertex_array_object"] =
  10532. this._supportsShareableVAO;
  10533. cc.checkGLErrorDebug()
  10534. }
  10535. },
  10536. loadConfigFile: function(a) {
  10537. this._inited || this._init();
  10538. var b = cc.loader.getRes(a);
  10539. if (!b) throw "Please load the resource first : " + a;
  10540. cc.assert(b, cc._LogInfos.configuration_loadConfigFile_2, a);
  10541. if (b = b.data)
  10542. for (var c in b) this._valueDict[c] = b[c];
  10543. else cc.log(cc._LogInfos.configuration_loadConfigFile, a)
  10544. }
  10545. };
  10546. cc.g_NumberOfDraws = 0;
  10547. cc.GLToClipTransform = function(a) {
  10548. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a);
  10549. var b = new cc.math.Matrix4;
  10550. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, b);
  10551. a.multiply(b)
  10552. };
  10553. cc.Director = cc.Class.extend({
  10554. _landscape: !1,
  10555. _nextDeltaTimeZero: !1,
  10556. _paused: !1,
  10557. _purgeDirectorInNextLoop: !1,
  10558. _sendCleanupToScene: !1,
  10559. _animationInterval: 0,
  10560. _oldAnimationInterval: 0,
  10561. _projection: 0,
  10562. _accumDt: 0,
  10563. _contentScaleFactor: 1,
  10564. _displayStats: !1,
  10565. _deltaTime: 0,
  10566. _frameRate: 0,
  10567. _FPSLabel: null,
  10568. _SPFLabel: null,
  10569. _drawsLabel: null,
  10570. _winSizeInPoints: null,
  10571. _lastUpdate: null,
  10572. _nextScene: null,
  10573. _notificationNode: null,
  10574. _openGLView: null,
  10575. _scenesStack: null,
  10576. _projectionDelegate: null,
  10577. _runningScene: null,
  10578. _frames: 0,
  10579. _totalFrames: 0,
  10580. _secondsPerFrame: 0,
  10581. _dirtyRegion: null,
  10582. _scheduler: null,
  10583. _actionManager: null,
  10584. _eventProjectionChanged: null,
  10585. _eventAfterDraw: null,
  10586. _eventAfterVisit: null,
  10587. _eventAfterUpdate: null,
  10588. ctor: function() {
  10589. var a = this;
  10590. a._lastUpdate = Date.now();
  10591. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
  10592. a._lastUpdate = Date.now()
  10593. })
  10594. },
  10595. init: function() {
  10596. this._oldAnimationInterval = this._animationInterval = 1 / cc.defaultFPS;
  10597. this._scenesStack = [];
  10598. this._projection = cc.Director.PROJECTION_DEFAULT;
  10599. this._projectionDelegate = null;
  10600. this._frameRate = this._accumDt =
  10601. 0;
  10602. this._displayStats = !1;
  10603. this._totalFrames = this._frames = 0;
  10604. this._lastUpdate = Date.now();
  10605. this._purgeDirectorInNextLoop = this._paused = !1;
  10606. this._winSizeInPoints = cc.size(0, 0);
  10607. this._openGLView = null;
  10608. this._contentScaleFactor = 1;
  10609. this._scheduler = new cc.Scheduler;
  10610. cc.ActionManager ? (this._actionManager = new cc.ActionManager, this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1)) : this._actionManager = null;
  10611. this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
  10612. this._eventAfterDraw.setUserData(this);
  10613. this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);
  10614. this._eventAfterVisit.setUserData(this);
  10615. this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);
  10616. this._eventAfterUpdate.setUserData(this);
  10617. this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);
  10618. this._eventProjectionChanged.setUserData(this);
  10619. return !0
  10620. },
  10621. calculateDeltaTime: function() {
  10622. var a = Date.now();
  10623. this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime =
  10624. (a - this._lastUpdate) / 1E3;
  10625. 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60);
  10626. this._lastUpdate = a
  10627. },
  10628. convertToGL: null,
  10629. convertToUI: null,
  10630. drawScene: function() {
  10631. var a = cc.renderer;
  10632. this.calculateDeltaTime();
  10633. this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate));
  10634. this._clear();
  10635. this._nextScene && this.setNextScene();
  10636. this._beforeVisitScene && this._beforeVisitScene();
  10637. this._runningScene && (!0 === a.childrenOrderDirty ? (cc.renderer.clearRenderCommands(),
  10638. this._runningScene._renderCmd._curLevel = 0, this._runningScene.visit(), a.resetFlag()) : !0 === a.transformDirty() && a.transform(), cc.eventManager.dispatchEvent(this._eventAfterVisit));
  10639. this._notificationNode && this._notificationNode.visit();
  10640. this._displayStats && this._showStats();
  10641. this._afterVisitScene && this._afterVisitScene();
  10642. a.rendering(cc._renderContext);
  10643. cc.eventManager.dispatchEvent(this._eventAfterDraw);
  10644. this._totalFrames++;
  10645. this._displayStats && this._calculateMPF()
  10646. },
  10647. _beforeVisitScene: null,
  10648. _afterVisitScene: null,
  10649. end: function() {
  10650. this._purgeDirectorInNextLoop = !0
  10651. },
  10652. getContentScaleFactor: function() {
  10653. return this._contentScaleFactor
  10654. },
  10655. getNotificationNode: function() {
  10656. return this._notificationNode
  10657. },
  10658. getWinSize: function() {
  10659. return cc.size(this._winSizeInPoints)
  10660. },
  10661. getWinSizeInPixels: function() {
  10662. return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor)
  10663. },
  10664. getVisibleSize: null,
  10665. getVisibleOrigin: null,
  10666. getZEye: null,
  10667. pause: function() {
  10668. this._paused || (this._oldAnimationInterval =
  10669. this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0)
  10670. },
  10671. popScene: function() {
  10672. cc.assert(this._runningScene, cc._LogInfos.Director_popScene);
  10673. this._scenesStack.pop();
  10674. var a = this._scenesStack.length;
  10675. 0 === a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a - 1])
  10676. },
  10677. purgeCachedData: function() {
  10678. cc.animationCache._clear();
  10679. cc.spriteFrameCache._clear();
  10680. cc.textureCache._clear()
  10681. },
  10682. purgeDirector: function() {
  10683. this.getScheduler().unscheduleAll();
  10684. cc.eventManager && cc.eventManager.setEnabled(!1);
  10685. this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup());
  10686. this._nextScene = this._runningScene = null;
  10687. this._scenesStack.length = 0;
  10688. this.stopAnimation();
  10689. this.purgeCachedData();
  10690. cc.checkGLErrorDebug()
  10691. },
  10692. pushScene: function(a) {
  10693. cc.assert(a, cc._LogInfos.Director_pushScene);
  10694. this._sendCleanupToScene = !1;
  10695. this._scenesStack.push(a);
  10696. this._nextScene = a
  10697. },
  10698. runScene: function(a) {
  10699. cc.assert(a, cc._LogInfos.Director_pushScene);
  10700. if (this._runningScene) {
  10701. var b = this._scenesStack.length;
  10702. 0 === b ? (this._sendCleanupToScene = !0, this._scenesStack[b] = a) : (this._sendCleanupToScene = !0, this._scenesStack[b - 1] = a);
  10703. this._nextScene = a
  10704. } else this.pushScene(a), this.startAnimation()
  10705. },
  10706. resume: function() {
  10707. this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate = Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0)
  10708. },
  10709. setContentScaleFactor: function(a) {
  10710. a !== this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel())
  10711. },
  10712. setDepthTest: null,
  10713. setDefaultValues: function() {},
  10714. setNextDeltaTimeZero: function(a) {
  10715. this._nextDeltaTimeZero = a
  10716. },
  10717. setNextScene: function() {
  10718. var a = !1,
  10719. b = !1;
  10720. cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, b = this._nextScene ? this._nextScene instanceof cc.TransitionScene : !1);
  10721. if (!b) {
  10722. if (b = this._runningScene) b.onExitTransitionDidStart(), b.onExit();
  10723. this._sendCleanupToScene && b && b.cleanup()
  10724. }
  10725. this._runningScene = this._nextScene;
  10726. cc.renderer.childrenOrderDirty = !0;
  10727. this._nextScene = null;
  10728. a || null ===
  10729. this._runningScene || (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish())
  10730. },
  10731. setNotificationNode: function(a) {
  10732. this._notificationNode = a
  10733. },
  10734. getDelegate: function() {
  10735. return this._projectionDelegate
  10736. },
  10737. setDelegate: function(a) {
  10738. this._projectionDelegate = a
  10739. },
  10740. setOpenGLView: null,
  10741. setProjection: null,
  10742. setViewport: null,
  10743. getOpenGLView: null,
  10744. getProjection: null,
  10745. setAlphaBlending: null,
  10746. _showStats: function() {
  10747. this._frames++;
  10748. this._accumDt += this._deltaTime;
  10749. this._FPSLabel && this._SPFLabel && this._drawsLabel ? (this._accumDt >
  10750. 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();
  10751. cc.g_NumberOfDraws = 0
  10752. },
  10753. isSendCleanupToScene: function() {
  10754. return this._sendCleanupToScene
  10755. },
  10756. getRunningScene: function() {
  10757. return this._runningScene
  10758. },
  10759. getAnimationInterval: function() {
  10760. return this._animationInterval
  10761. },
  10762. isDisplayStats: function() {
  10763. return this._displayStats
  10764. },
  10765. setDisplayStats: function(a) {
  10766. this._displayStats = a
  10767. },
  10768. getSecondsPerFrame: function() {
  10769. return this._secondsPerFrame
  10770. },
  10771. isNextDeltaTimeZero: function() {
  10772. return this._nextDeltaTimeZero
  10773. },
  10774. isPaused: function() {
  10775. return this._paused
  10776. },
  10777. getTotalFrames: function() {
  10778. return this._totalFrames
  10779. },
  10780. popToRootScene: function() {
  10781. this.popToSceneStackLevel(1)
  10782. },
  10783. popToSceneStackLevel: function(a) {
  10784. cc.assert(this._runningScene, cc._LogInfos.Director_popToSceneStackLevel_2);
  10785. var b = this._scenesStack,
  10786. c = b.length;
  10787. if (0 === c) this.end();
  10788. else if (!(a > c)) {
  10789. for (; c > a;) {
  10790. var d = b.pop();
  10791. d.running && (d.onExitTransitionDidStart(), d.onExit());
  10792. d.cleanup();
  10793. c--
  10794. }
  10795. this._nextScene = b[b.length - 1];
  10796. this._sendCleanupToScene = !1
  10797. }
  10798. },
  10799. getScheduler: function() {
  10800. return this._scheduler
  10801. },
  10802. setScheduler: function(a) {
  10803. this._scheduler !== a && (this._scheduler = a)
  10804. },
  10805. getActionManager: function() {
  10806. return this._actionManager
  10807. },
  10808. setActionManager: function(a) {
  10809. this._actionManager !== a && (this._actionManager = a)
  10810. },
  10811. getDeltaTime: function() {
  10812. return this._deltaTime
  10813. },
  10814. _createStatsLabel: null,
  10815. _calculateMPF: function() {
  10816. this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3
  10817. }
  10818. });
  10819. cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
  10820. cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
  10821. cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
  10822. cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
  10823. cc.DisplayLinkDirector = cc.Director.extend({
  10824. invalid: !1,
  10825. startAnimation: function() {
  10826. this._nextDeltaTimeZero = !0;
  10827. this.invalid = !1
  10828. },
  10829. mainLoop: function() {
  10830. this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene()
  10831. },
  10832. stopAnimation: function() {
  10833. this.invalid = !0
  10834. },
  10835. setAnimationInterval: function(a) {
  10836. this._animationInterval = a;
  10837. this.invalid || (this.stopAnimation(), this.startAnimation())
  10838. }
  10839. });
  10840. cc.Director.sharedDirector = null;
  10841. cc.Director.firstUseDirector = !0;
  10842. cc.Director._getInstance = function() {
  10843. cc.Director.firstUseDirector && (cc.Director.firstUseDirector = !1, cc.Director.sharedDirector = new cc.DisplayLinkDirector, cc.Director.sharedDirector.init());
  10844. return cc.Director.sharedDirector
  10845. };
  10846. cc.defaultFPS = 60;
  10847. cc.Director.PROJECTION_2D = 0;
  10848. cc.Director.PROJECTION_3D = 1;
  10849. cc.Director.PROJECTION_CUSTOM = 3;
  10850. cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
  10851. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Director.prototype, _p.setProjection = function(a) {
  10852. this._projection = a;
  10853. cc.eventManager.dispatchEvent(this._eventProjectionChanged)
  10854. }, _p.setDepthTest = function() {}, _p.setOpenGLView = function(a) {
  10855. this._winSizeInPoints.width = cc._canvas.width;
  10856. this._winSizeInPoints.height = cc._canvas.height;
  10857. this._openGLView = a || cc.view;
  10858. cc.eventManager && cc.eventManager.setEnabled(!0)
  10859. }, _p._clear = function() {
  10860. var a = this._openGLView.getViewPortRect(),
  10861. b = cc._renderContext.getContext();
  10862. b.setTransform(1,
  10863. 0, 0, 1, 0, 0);
  10864. b.clearRect(-a.x, a.y, a.width, a.height)
  10865. }, _p._createStatsLabel = function() {
  10866. var a = 0,
  10867. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24;
  10868. this._FPSLabel = new cc.LabelTTF("000.0", "Arial", a);
  10869. this._SPFLabel = new cc.LabelTTF("0.000", "Arial", a);
  10870. this._drawsLabel = new cc.LabelTTF("0000", "Arial", a);
  10871. a = cc.DIRECTOR_STATS_POSITION;
  10872. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  10873. this._SPFLabel.setPosition(this._SPFLabel.width /
  10874. 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  10875. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  10876. }, _p.getVisibleSize = function() {
  10877. return this.getWinSize()
  10878. }, _p.getVisibleOrigin = function() {
  10879. return cc.p(0, 0)
  10880. }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load", function() {
  10881. cc.Director._fpsImageLoaded = !0
  10882. }), cc._fpsImage && (cc.Director._fpsImage.src = cc._fpsImage));
  10883. cc._renderType === cc._RENDER_TYPE_WEBGL && function() {
  10884. cc.DirectorDelegate = cc.Class.extend({
  10885. updateProjection: function() {}
  10886. });
  10887. var a = cc.Director.prototype;
  10888. a.setProjection = function(a) {
  10889. var c = this._winSizeInPoints;
  10890. this.setViewport();
  10891. var d = this._openGLView,
  10892. e = d._viewPortRect.x / d._scaleX,
  10893. f = d._viewPortRect.y / d._scaleY;
  10894. switch (a) {
  10895. case cc.Director.PROJECTION_2D:
  10896. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  10897. cc.kmGLLoadIdentity();
  10898. d = cc.math.Matrix4.createOrthographicProjection(-e, c.width - e, -f, c.height - f, -1024, 1024);
  10899. cc.kmGLMultMatrix(d);
  10900. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  10901. cc.kmGLLoadIdentity();
  10902. break;
  10903. case cc.Director.PROJECTION_3D:
  10904. var g = this.getZEye(),
  10905. h = new cc.math.Matrix4,
  10906. d = new cc.math.Matrix4;
  10907. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  10908. cc.kmGLLoadIdentity();
  10909. h = cc.math.Matrix4.createPerspectiveProjection(60, c.width / c.height, 0.1, 2 * g);
  10910. cc.kmGLMultMatrix(h);
  10911. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  10912. cc.kmGLLoadIdentity();
  10913. g = new cc.math.Vec3(-e + c.width / 2, -f + c.height / 2, g);
  10914. c = new cc.math.Vec3(-e + c.width / 2, -f + c.height / 2, 0);
  10915. e = new cc.math.Vec3(0, 1, 0);
  10916. d.lookAt(g, c, e);
  10917. cc.kmGLMultMatrix(d);
  10918. break;
  10919. case cc.Director.PROJECTION_CUSTOM:
  10920. this._projectionDelegate && this._projectionDelegate.updateProjection();
  10921. break;
  10922. default:
  10923. cc.log(cc._LogInfos.Director_setProjection)
  10924. }
  10925. this._projection = a;
  10926. cc.eventManager.dispatchEvent(this._eventProjectionChanged);
  10927. cc.setProjectionMatrixDirty();
  10928. cc.renderer.childrenOrderDirty = !0
  10929. };
  10930. a.setDepthTest = function(a) {
  10931. var c = cc._renderContext;
  10932. a ? (c.clearDepth(1), c.enable(c.DEPTH_TEST), c.depthFunc(c.LEQUAL)) : c.disable(c.DEPTH_TEST)
  10933. };
  10934. a.setOpenGLView =
  10935. function(a) {
  10936. this._winSizeInPoints.width = cc._canvas.width;
  10937. this._winSizeInPoints.height = cc._canvas.height;
  10938. this._openGLView = a || cc.view;
  10939. a = cc.configuration;
  10940. a.gatherGPUInfo();
  10941. a.dumpInfo();
  10942. this._createStatsLabel();
  10943. this.setGLDefaultValues();
  10944. cc.eventManager && cc.eventManager.setEnabled(!0)
  10945. };
  10946. a._clear = function() {
  10947. var a = cc._renderContext;
  10948. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
  10949. };
  10950. a._beforeVisitScene = function() {
  10951. cc.kmGLPushMatrix()
  10952. };
  10953. a._afterVisitScene = function() {
  10954. cc.kmGLPopMatrix()
  10955. };
  10956. a._createStatsLabel = function() {
  10957. if (!cc.LabelAtlas) this._createStatsLabelForCanvas();
  10958. else if (null != cc.Director._fpsImageLoaded && !1 !== cc.Director._fpsImageLoaded) {
  10959. var a = new cc.Texture2D;
  10960. a.initWithElement(cc.Director._fpsImage);
  10961. a.handleLoadedTexture();
  10962. var c = cc.view.getDesignResolutionSize().height / 320;
  10963. 0 === c && (c = this._winSizeInPoints.height / 320);
  10964. var d = new cc.LabelAtlas;
  10965. d._setIgnoreContentScaleFactor(!0);
  10966. d.initWithString("00.0", a, 12, 32, ".");
  10967. d.scale = c;
  10968. this._FPSLabel = d;
  10969. d = new cc.LabelAtlas;
  10970. d._setIgnoreContentScaleFactor(!0);
  10971. d.initWithString("0.000", a, 12, 32, ".");
  10972. d.scale = c;
  10973. this._SPFLabel =
  10974. d;
  10975. d = new cc.LabelAtlas;
  10976. d._setIgnoreContentScaleFactor(!0);
  10977. d.initWithString("000", a, 12, 32, ".");
  10978. d.scale = c;
  10979. this._drawsLabel = d;
  10980. a = cc.DIRECTOR_STATS_POSITION;
  10981. this._drawsLabel.setPosition(a.x, 34 * c + a.y);
  10982. this._SPFLabel.setPosition(a.x, 17 * c + a.y);
  10983. this._FPSLabel.setPosition(a)
  10984. }
  10985. };
  10986. a._createStatsLabelForCanvas = function() {
  10987. var a = 0,
  10988. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24;
  10989. this._FPSLabel = new cc.LabelTTF("000.0", "Arial", a);
  10990. this._SPFLabel =
  10991. new cc.LabelTTF("0.000", "Arial", a);
  10992. this._drawsLabel = new cc.LabelTTF("0000", "Arial", a);
  10993. a = cc.DIRECTOR_STATS_POSITION;
  10994. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  10995. this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  10996. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  10997. };
  10998. a.convertToGL = function(a) {
  10999. var c = new cc.math.Matrix4;
  11000. cc.GLToClipTransform(c);
  11001. var d = c.inverse(),
  11002. c = c.mat[14] / c.mat[15],
  11003. e = this._openGLView.getDesignResolutionSize();
  11004. a = new cc.math.Vec3(2 * a.x / e.width - 1, 1 - 2 * a.y / e.height, c);
  11005. a.transformCoord(d);
  11006. return cc.p(a.x, a.y)
  11007. };
  11008. a.convertToUI = function(a) {
  11009. var c = new cc.math.Matrix4;
  11010. cc.GLToClipTransform(c);
  11011. a = new cc.math.Vec3(a.x, a.y, 0);
  11012. a.transformCoord(c);
  11013. c = this._openGLView.getDesignResolutionSize();
  11014. return cc.p(c.width * (0.5 * a.x + 0.5), c.height * (0.5 * -a.y + 0.5))
  11015. };
  11016. a.getVisibleSize = function() {
  11017. return this._openGLView.getVisibleSize()
  11018. };
  11019. a.getVisibleOrigin = function() {
  11020. return this._openGLView.getVisibleOrigin()
  11021. };
  11022. a.getZEye = function() {
  11023. return this._winSizeInPoints.height /
  11024. 1.1566
  11025. };
  11026. a.setViewport = function() {
  11027. var a = this._openGLView;
  11028. if (a) {
  11029. var c = this._winSizeInPoints;
  11030. a.setViewPortInPoints(-a._viewPortRect.x / a._scaleX, -a._viewPortRect.y / a._scaleY, c.width, c.height)
  11031. }
  11032. };
  11033. a.getOpenGLView = function() {
  11034. return this._openGLView
  11035. };
  11036. a.getProjection = function() {
  11037. return this._projection
  11038. };
  11039. a.setAlphaBlending = function(a) {
  11040. a ? cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST) : cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO)
  11041. };
  11042. a.setGLDefaultValues = function() {
  11043. this.setAlphaBlending(!0);
  11044. this.setDepthTest(!1);
  11045. this.setProjection(this._projection);
  11046. cc._renderContext.clearColor(0, 0, 0, 1)
  11047. }
  11048. }();
  11049. cc.Camera = cc.Class.extend({
  11050. _eyeX: null,
  11051. _eyeY: null,
  11052. _eyeZ: null,
  11053. _centerX: null,
  11054. _centerY: null,
  11055. _centerZ: null,
  11056. _upX: null,
  11057. _upY: null,
  11058. _upZ: null,
  11059. _dirty: !1,
  11060. _lookupMatrix: null,
  11061. ctor: function() {
  11062. this._lookupMatrix = new cc.math.Matrix4;
  11063. this.restore()
  11064. },
  11065. description: function() {
  11066. return "\x3cCCCamera | center \x3d(" + this._centerX + "," + this._centerY + "," + this._centerZ + ")\x3e"
  11067. },
  11068. setDirty: function(a) {
  11069. this._dirty = a
  11070. },
  11071. isDirty: function() {
  11072. return this._dirty
  11073. },
  11074. restore: function() {
  11075. this._eyeX = this._eyeY = 0;
  11076. this._eyeZ = cc.Camera.getZEye();
  11077. this._upX =
  11078. this._centerX = this._centerY = this._centerZ = 0;
  11079. this._upY = 1;
  11080. this._upZ = 0;
  11081. this._lookupMatrix.identity();
  11082. this._dirty = !1
  11083. },
  11084. locate: function() {
  11085. if (this._dirty) {
  11086. var a = new cc.math.Vec3(this._eyeX, this._eyeY, this._eyeZ),
  11087. b = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ),
  11088. c = new cc.math.Vec3(this._upX, this._upY, this._upZ);
  11089. this._lookupMatrix.lookAt(a, b, c);
  11090. this._dirty = !1
  11091. }
  11092. cc.kmGLMultMatrix(this._lookupMatrix)
  11093. },
  11094. _locateForRenderer: function(a) {
  11095. if (this._dirty) {
  11096. var b = new cc.math.Vec3(this._eyeX, this._eyeY, this._eyeZ),
  11097. c = new cc.math.Vec3(this._centerX, this._centerY, this._centerZ),
  11098. d = new cc.math.Vec3(this._upX, this._upY, this._upZ);
  11099. this._lookupMatrix.lookAt(b, c, d);
  11100. this._dirty = !1
  11101. }
  11102. a.multiply(this._lookupMatrix)
  11103. },
  11104. setEyeXYZ: function(a, b, c) {
  11105. this.setEye(a, b, c)
  11106. },
  11107. setEye: function(a, b, c) {
  11108. this._eyeX = a;
  11109. this._eyeY = b;
  11110. this._eyeZ = c;
  11111. this._dirty = !0
  11112. },
  11113. setCenterXYZ: function(a, b, c) {
  11114. this.setCenter(a, b, c)
  11115. },
  11116. setCenter: function(a, b, c) {
  11117. this._centerX = a;
  11118. this._centerY = b;
  11119. this._centerZ = c;
  11120. this._dirty = !0
  11121. },
  11122. setUpXYZ: function(a, b, c) {
  11123. this.setUp(a, b, c)
  11124. },
  11125. setUp: function(a, b, c) {
  11126. this._upX = a;
  11127. this._upY = b;
  11128. this._upZ = c;
  11129. this._dirty = !0
  11130. },
  11131. getEyeXYZ: function(a, b, c) {
  11132. return {
  11133. x: this._eyeX,
  11134. y: this._eyeY,
  11135. z: this._eyeZ
  11136. }
  11137. },
  11138. getEye: function() {
  11139. return {
  11140. x: this._eyeX,
  11141. y: this._eyeY,
  11142. z: this._eyeZ
  11143. }
  11144. },
  11145. getCenterXYZ: function(a, b, c) {
  11146. return {
  11147. x: this._centerX,
  11148. y: this._centerY,
  11149. z: this._centerZ
  11150. }
  11151. },
  11152. getCenter: function() {
  11153. return {
  11154. x: this._centerX,
  11155. y: this._centerY,
  11156. z: this._centerZ
  11157. }
  11158. },
  11159. getUpXYZ: function(a, b, c) {
  11160. return {
  11161. x: this._upX,
  11162. y: this._upY,
  11163. z: this._upZ
  11164. }
  11165. },
  11166. getUp: function() {
  11167. return {
  11168. x: this._upX,
  11169. y: this._upY,
  11170. z: this._upZ
  11171. }
  11172. },
  11173. _DISALLOW_COPY_AND_ASSIGN: function(a) {}
  11174. });
  11175. cc.Camera.getZEye = function() {
  11176. return cc.FLT_EPSILON
  11177. };
  11178. cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1;
  11179. cc.ListEntry = function(a, b, c, d, e, f, g) {
  11180. this.prev = a;
  11181. this.next = b;
  11182. this.callback = c;
  11183. this.target = d;
  11184. this.priority = e;
  11185. this.paused = f;
  11186. this.markedForDeletion = g
  11187. };
  11188. cc.HashUpdateEntry = function(a, b, c, d, e) {
  11189. this.list = a;
  11190. this.entry = b;
  11191. this.target = c;
  11192. this.callback = d;
  11193. this.hh = e
  11194. };
  11195. cc.HashTimerEntry = cc.hashSelectorEntry = function(a, b, c, d, e, f, g) {
  11196. this.timers = a;
  11197. this.target = b;
  11198. this.timerIndex = c;
  11199. this.currentTimer = d;
  11200. this.currentTimerSalvaged = e;
  11201. this.paused = f;
  11202. this.hh = g
  11203. };
  11204. cc.Timer = cc.Class.extend({
  11205. _scheduler: null,
  11206. _elapsed: 0,
  11207. _runForever: !1,
  11208. _useDelay: !1,
  11209. _timesExecuted: 0,
  11210. _repeat: 0,
  11211. _delay: 0,
  11212. _interval: 0,
  11213. getInterval: function() {
  11214. return this._interval
  11215. },
  11216. setInterval: function(a) {
  11217. this._interval = a
  11218. },
  11219. setupTimerWithInterval: function(a, b, c) {
  11220. this._elapsed = -1;
  11221. this._interval = a;
  11222. this._delay = c;
  11223. this._useDelay = 0 < this._delay;
  11224. this._repeat = b;
  11225. this._runForever = this._repeat === cc.REPEAT_FOREVER
  11226. },
  11227. trigger: function() {
  11228. return 0
  11229. },
  11230. cancel: function() {
  11231. return 0
  11232. },
  11233. ctor: function() {
  11234. this._scheduler = null;
  11235. this._elapsed = -1;
  11236. this._useDelay = this._runForever = !1;
  11237. this._interval = this._delay = this._repeat = this._timesExecuted = 0
  11238. },
  11239. update: function(a) {
  11240. -1 === this._elapsed ? this._timesExecuted = this._elapsed = 0 : (this._elapsed += a, this._runForever && !this._useDelay ? this._elapsed >= this._interval && (this.trigger(), this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (this.trigger(), this._elapsed -= this._delay, this._timesExecuted += 1, this._useDelay = !1) : this._elapsed >= this._interval && (this.trigger(), this._elapsed = 0, this._timesExecuted +=
  11241. 1), !this._runForever && this._timesExecuted > this._repeat && this.cancel()))
  11242. }
  11243. });
  11244. cc.TimerTargetSelector = cc.Timer.extend({
  11245. _target: null,
  11246. _selector: null,
  11247. ctor: function() {
  11248. this._selector = this._target = null
  11249. },
  11250. initWithSelector: function(a, b, c, d, e, f) {
  11251. this._scheduler = a;
  11252. this._target = c;
  11253. this._selector = b;
  11254. this.setupTimerWithInterval(d, e, f);
  11255. return !0
  11256. },
  11257. getSelector: function() {
  11258. return this._selector
  11259. },
  11260. trigger: function() {
  11261. this._target && this._selector && this._target.call(this._selector, this._elapsed)
  11262. },
  11263. cancel: function() {
  11264. this._scheduler.unschedule(this._selector, this._target)
  11265. }
  11266. });
  11267. cc.TimerTargetCallback = cc.Timer.extend({
  11268. _target: null,
  11269. _callback: null,
  11270. _key: null,
  11271. ctor: function() {
  11272. this._callback = this._target = null
  11273. },
  11274. initWithCallback: function(a, b, c, d, e, f, g) {
  11275. this._scheduler = a;
  11276. this._target = c;
  11277. this._callback = b;
  11278. this._key = d;
  11279. this.setupTimerWithInterval(e, f, g);
  11280. return !0
  11281. },
  11282. getCallback: function() {
  11283. return this._callback
  11284. },
  11285. getKey: function() {
  11286. return this._key
  11287. },
  11288. trigger: function() {
  11289. this._callback && this._callback.call(this._target, this._elapsed)
  11290. },
  11291. cancel: function() {
  11292. this._scheduler.unschedule(this._key, this._target)
  11293. }
  11294. });
  11295. cc.Scheduler = cc.Class.extend({
  11296. _timeScale: 1,
  11297. _updatesNegList: null,
  11298. _updates0List: null,
  11299. _updatesPosList: null,
  11300. _hashForTimers: null,
  11301. _arrayForTimers: null,
  11302. _hashForUpdates: null,
  11303. _currentTarget: null,
  11304. _currentTargetSalvaged: !1,
  11305. _updateHashLocked: !1,
  11306. ctor: function() {
  11307. this._timeScale = 1;
  11308. this._updatesNegList = [];
  11309. this._updates0List = [];
  11310. this._updatesPosList = [];
  11311. this._hashForUpdates = {};
  11312. this._hashForTimers = {};
  11313. this._currentTarget = null;
  11314. this._updateHashLocked = this._currentTargetSalvaged = !1;
  11315. this._arrayForTimers = []
  11316. },
  11317. _schedulePerFrame: function(a,
  11318. b, c, d) {
  11319. var e = this._hashForUpdates[b.__instanceId];
  11320. if (e && e.entry)
  11321. if (e.entry.priority !== c) {
  11322. if (this._updateHashLocked) {
  11323. cc.log("warning: you CANNOT change update priority in scheduled function");
  11324. e.entry.markedForDeletion = !1;
  11325. e.entry.paused = d;
  11326. return
  11327. }
  11328. this.unscheduleUpdate(b)
  11329. } else {
  11330. e.entry.markedForDeletion = !1;
  11331. e.entry.paused = d;
  11332. return
  11333. }
  11334. 0 === c ? this._appendIn(this._updates0List, a, b, d) : 0 > c ? this._priorityIn(this._updatesNegList, a, b, c, d) : this._priorityIn(this._updatesPosList, a, b, c, d)
  11335. },
  11336. _removeHashElement: function(a) {
  11337. delete this._hashForTimers[a.target.__instanceId];
  11338. cc.arrayRemoveObject(this._arrayForTimers, a);
  11339. a.Timer = null;
  11340. a.target = null
  11341. },
  11342. _removeUpdateFromHash: function(a) {
  11343. if (a = this._hashForUpdates[a.target.__instanceId]) cc.arrayRemoveObject(a.list, a.entry), delete this._hashForUpdates[a.target.__instanceId], a.entry = null, a.target = null
  11344. },
  11345. _priorityIn: function(a, b, c, d, e) {
  11346. b = new cc.ListEntry(null, null, b, c, d, e, !1);
  11347. if (a) {
  11348. e = a.length - 1;
  11349. for (var f = 0; f <= e && !(d < a[f].priority); f++);
  11350. a.splice(f, 0, b)
  11351. } else a = [], a.push(b);
  11352. this._hashForUpdates[c.__instanceId] = new cc.HashUpdateEntry(a,
  11353. b, c, null);
  11354. return a
  11355. },
  11356. _appendIn: function(a, b, c, d) {
  11357. b = new cc.ListEntry(null, null, b, c, 0, d, !1);
  11358. a.push(b);
  11359. this._hashForUpdates[c.__instanceId] = new cc.HashUpdateEntry(a, b, c, null, null)
  11360. },
  11361. setTimeScale: function(a) {
  11362. this._timeScale = a
  11363. },
  11364. getTimeScale: function() {
  11365. return this._timeScale
  11366. },
  11367. update: function(a) {
  11368. this._updateHashLocked = !0;
  11369. 1 !== this._timeScale && (a *= this._timeScale);
  11370. var b, c, d, e;
  11371. b = 0;
  11372. c = this._updatesNegList;
  11373. for (d = c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a);
  11374. b = 0;
  11375. c = this._updates0List;
  11376. for (d =
  11377. c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a);
  11378. b = 0;
  11379. c = this._updatesPosList;
  11380. for (d = c.length; b < d; b++) e = c[b], e.paused || e.markedForDeletion || e.callback(a);
  11381. d = this._arrayForTimers;
  11382. for (b = 0; b < d.length; b++) {
  11383. this._currentTarget = c = d[b];
  11384. this._currentTargetSalvaged = !1;
  11385. if (!c.paused)
  11386. for (c.timerIndex = 0; c.timerIndex < c.timers.length; ++c.timerIndex) c.currentTimer = c.timers[c.timerIndex], c.currentTimerSalvaged = !1, c.currentTimer.update(a), c.currentTimer = null;
  11387. this._currentTargetSalvaged && 0 === this._currentTarget.timers.length &&
  11388. this._removeHashElement(this._currentTarget)
  11389. }
  11390. b = 0;
  11391. for (c = this._updatesNegList; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++;
  11392. b = 0;
  11393. for (c = this._updates0List; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++;
  11394. b = 0;
  11395. for (c = this._updatesPosList; b < c.length;) e = c[b], e.markedForDeletion ? this._removeUpdateFromHash(e) : b++;
  11396. this._updateHashLocked = !1;
  11397. this._currentTarget = null
  11398. },
  11399. scheduleCallbackForTarget: function(a, b, c, d, e, f) {
  11400. this.schedule(b, a, c, d, e, f, a.__instanceId + "")
  11401. },
  11402. schedule: function(a, b, c, d, e, f, g) {
  11403. var h = !1;
  11404. if ("function" !== typeof a) var k = a,
  11405. h = !0;
  11406. !1 === h ? 5 === arguments.length && (g = e, f = d, e = 0, d = cc.REPEAT_FOREVER) : 4 === arguments.length && (f = d, d = cc.REPEAT_FOREVER, e = 0);
  11407. cc.assert(b, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
  11408. !1 === h && cc.assert(g, "key should not be empty!");
  11409. var m = this._hashForTimers[b.__instanceId];
  11410. m ? cc.assert(m.paused === f, "") : (m = new cc.HashTimerEntry(null, b, 0, null, null, f, null), this._arrayForTimers.push(m), this._hashForTimers[b.__instanceId] = m);
  11411. var n,
  11412. p;
  11413. if (null == m.timers) m.timers = [];
  11414. else if (!1 === h)
  11415. for (p = 0; p < m.timers.length; p++) {
  11416. if (n = m.timers[p], a === n._callback) {
  11417. cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, n.getInterval().toFixed(4), c.toFixed(4));
  11418. n._interval = c;
  11419. return
  11420. }
  11421. } else
  11422. for (p = 0; p < m.timers.length; ++p)
  11423. if ((n = m.timers[p]) && k === n.getSelector()) {
  11424. cc.log("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", n.getInterval(), c);
  11425. n.setInterval(c);
  11426. return
  11427. }!1 === h ? (n = new cc.TimerTargetCallback, n.initWithCallback(this,
  11428. a, b, g, c, d, e)) : (n = new cc.TimerTargetSelector, n.initWithSelector(this, k, b, c, d, e));
  11429. m.timers.push(n)
  11430. },
  11431. scheduleUpdate: function(a, b, c) {
  11432. this._schedulePerFrame(function(b) {
  11433. a.update(b)
  11434. }, a, b, c)
  11435. },
  11436. _getUnscheduleMark: function(a, b) {
  11437. switch (typeof a) {
  11438. case "number":
  11439. case "string":
  11440. return a === b.getKey();
  11441. case "function":
  11442. return a === b._callback;
  11443. default:
  11444. return a === b.getSelector()
  11445. }
  11446. },
  11447. unschedule: function(a, b) {
  11448. if (b && a) {
  11449. var c = this._hashForTimers[b.__instanceId];
  11450. if (c)
  11451. for (var d = c.timers, e = 0, f = d.length; e < f; e++) {
  11452. var g = d[e];
  11453. if (this._getUnscheduleMark(a,
  11454. g)) {
  11455. g !== c.currentTimer || c.currentTimerSalvaged || (c.currentTimerSalvaged = !0);
  11456. d.splice(e, 1);
  11457. c.timerIndex >= e && c.timerIndex--;
  11458. 0 === d.length && (this._currentTarget === c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c));
  11459. break
  11460. }
  11461. }
  11462. }
  11463. },
  11464. unscheduleUpdate: function(a) {
  11465. null != a && (a = this._hashForUpdates[a.__instanceId]) && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry))
  11466. },
  11467. unscheduleAllForTarget: function(a) {
  11468. if (null != a) {
  11469. var b = this._hashForTimers[a.__instanceId];
  11470. b && (-1 < b.timers.indexOf(b.currentTimer) &&
  11471. !b.currentTimerSalvaged && (b.currentTimerSalvaged = !0), b.timers.length = 0, this._currentTarget === b ? this._currentTargetSalvaged = !0 : this._removeHashElement(b));
  11472. this.unscheduleUpdate(a)
  11473. }
  11474. },
  11475. unscheduleAll: function() {
  11476. this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  11477. },
  11478. unscheduleAllWithMinPriority: function(a) {
  11479. var b, c, d = this._arrayForTimers;
  11480. for (b = 0; b < d.length; b++) c = d[b], this.unscheduleAllForTarget(c.target);
  11481. if (0 > a)
  11482. for (b = 0; b < this._updatesNegList.length; b++)(c = this._updatesNegList[b]) && c.priority >=
  11483. a && this.unscheduleUpdate(c.target);
  11484. if (0 >= a)
  11485. for (b = 0; b < this._updates0List.length; b++)(c = this._updates0List[b]) && this.unscheduleUpdate(c.target);
  11486. for (b = 0; b < this._updatesPosList.length; b++)(c = this._updatesPosList[b]) && c.priority >= a && this.unscheduleUpdate(c.target)
  11487. },
  11488. isScheduled: function(a, b) {
  11489. cc.assert(a, "Argument key must not be empty");
  11490. cc.assert(b, "Argument target must be non-nullptr");
  11491. var c = this._hashForUpdates[b.__instanceId];
  11492. if (!c) return !1;
  11493. if (null != c.timers)
  11494. for (var c = c.timers, d = 0; d < c.length; ++d)
  11495. if (a ===
  11496. c[d].getKey()) return !0;
  11497. return !1
  11498. },
  11499. pauseAllTargets: function() {
  11500. return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  11501. },
  11502. pauseAllTargetsWithMinPriority: function(a) {
  11503. var b = [],
  11504. c, d = this._arrayForTimers,
  11505. e, f;
  11506. e = 0;
  11507. for (f = d.length; e < f; e++)
  11508. if (c = d[e]) c.paused = !0, b.push(c.target);
  11509. if (0 > a)
  11510. for (e = 0; e < this._updatesNegList.length; e++)(d = this._updatesNegList[e]) && d.priority >= a && (c.paused = !0, b.push(c.target));
  11511. if (0 >= a)
  11512. for (e = 0; e < this._updates0List.length; e++)
  11513. if (d = this._updates0List[e]) c.paused = !0, b.push(c.target);
  11514. for (e = 0; e < this._updatesPosList.length; e++)(d = this._updatesPosList[e]) && d.priority >= a && (c.paused = !0, b.push(c.target));
  11515. return b
  11516. },
  11517. resumeTargets: function(a) {
  11518. if (a)
  11519. for (var b = 0; b < a.length; b++) this.resumeTarget(a[b])
  11520. },
  11521. pauseTarget: function(a) {
  11522. cc.assert(a, cc._LogInfos.Scheduler_pauseTarget);
  11523. var b = this._hashForTimers[a.__instanceId];
  11524. b && (b.paused = !0);
  11525. if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !0
  11526. },
  11527. resumeTarget: function(a) {
  11528. cc.assert(a, cc._LogInfos.Scheduler_resumeTarget);
  11529. var b = this._hashForTimers[a.__instanceId];
  11530. b && (b.paused = !1);
  11531. if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !1
  11532. },
  11533. isTargetPaused: function(a) {
  11534. cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused);
  11535. var b = this._hashForTimers[a.__instanceId];
  11536. return b ? b.paused : (a = this._hashForUpdates[a.__instanceId]) ? a.entry.paused : !1
  11537. },
  11538. scheduleUpdateForTarget: function(a, b, c) {
  11539. this.scheduleUpdate(a, b, c)
  11540. },
  11541. unscheduleCallbackForTarget: function(a, b) {
  11542. this.unschedule(b, a)
  11543. },
  11544. unscheduleUpdateForTarget: function(a) {
  11545. this.unscheduleUpdate(a)
  11546. },
  11547. unscheduleAllCallbacksForTarget: function(a) {
  11548. this.unschedule(a.__instanceId +
  11549. "", a)
  11550. },
  11551. unscheduleAllCallbacks: function() {
  11552. this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  11553. },
  11554. unscheduleAllCallbacksWithMinPriority: function(a) {
  11555. this.unscheduleAllWithMinPriority(a)
  11556. }
  11557. });
  11558. cc.Scheduler.PRIORITY_SYSTEM = -2147483648;
  11559. cc.PI2 = 2 * Math.PI;
  11560. cc.DrawingPrimitiveCanvas = cc.Class.extend({
  11561. _cacheArray: [],
  11562. _renderContext: null,
  11563. ctor: function(a) {
  11564. this._renderContext = a
  11565. },
  11566. drawPoint: function(a, b) {
  11567. b || (b = 1);
  11568. var c = cc.view.getScaleX(),
  11569. d = cc.view.getScaleY(),
  11570. d = cc.p(a.x * c, a.y * d),
  11571. e = this._renderContext.getContext();
  11572. e.beginPath();
  11573. e.arc(d.x, -d.y, b * c, 0, 2 * Math.PI, !1);
  11574. e.closePath();
  11575. e.fill()
  11576. },
  11577. drawPoints: function(a, b, c) {
  11578. if (null != a) {
  11579. c || (c = 1);
  11580. b = this._renderContext.getContext();
  11581. var d = cc.view.getScaleX(),
  11582. e = cc.view.getScaleY();
  11583. b.beginPath();
  11584. for (var f = 0, g = a.length; f < g; f++) b.arc(a[f].x *
  11585. d, -a[f].y * e, c * d, 0, 2 * Math.PI, !1);
  11586. b.closePath();
  11587. b.fill()
  11588. }
  11589. },
  11590. drawLine: function(a, b) {
  11591. var c = this._renderContext.getContext(),
  11592. d = cc.view.getScaleX(),
  11593. e = cc.view.getScaleY();
  11594. c.beginPath();
  11595. c.moveTo(a.x * d, -a.y * e);
  11596. c.lineTo(b.x * d, -b.y * e);
  11597. c.closePath();
  11598. c.stroke()
  11599. },
  11600. drawRect: function(a, b) {
  11601. this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y));
  11602. this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y));
  11603. this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y));
  11604. this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y))
  11605. },
  11606. drawSolidRect: function(a, b, c) {
  11607. a = [a, cc.p(b.x, a.y), b, cc.p(a.x,
  11608. b.y)];
  11609. this.drawSolidPoly(a, 4, c)
  11610. },
  11611. drawPoly: function(a, b, c, d) {
  11612. d = d || !1;
  11613. if (null != a) {
  11614. if (3 > a.length) throw Error("Polygon's point must greater than 2");
  11615. var e = a[0];
  11616. b = this._renderContext.getContext();
  11617. var f = cc.view.getScaleX(),
  11618. g = cc.view.getScaleY();
  11619. b.beginPath();
  11620. b.moveTo(e.x * f, -e.y * g);
  11621. for (var e = 1, h = a.length; e < h; e++) b.lineTo(a[e].x * f, -a[e].y * g);
  11622. c && b.closePath();
  11623. d ? b.fill() : b.stroke()
  11624. }
  11625. },
  11626. drawSolidPoly: function(a, b, c) {
  11627. this.setDrawColor(c.r, c.g, c.b, c.a);
  11628. this.drawPoly(a, b, !0, !0)
  11629. },
  11630. drawCircle: function(a, b, c, d, e) {
  11631. e =
  11632. e || !1;
  11633. d = this._renderContext.getContext();
  11634. var f = cc.view.getScaleX(),
  11635. g = cc.view.getScaleY();
  11636. d.beginPath();
  11637. d.arc(0 | a.x * f, 0 | -(a.y * g), b * f, -c, -(c - 2 * Math.PI), !1);
  11638. e && d.lineTo(0 | a.x * f, 0 | -(a.y * g));
  11639. d.stroke()
  11640. },
  11641. drawQuadBezier: function(a, b, c, d) {
  11642. for (var e = this._cacheArray, f = e.length = 0, g = 0; g < d; g++) {
  11643. var h = Math.pow(1 - f, 2) * a.x + 2 * (1 - f) * f * b.x + f * f * c.x,
  11644. k = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y;
  11645. e.push(cc.p(h, k));
  11646. f += 1 / d
  11647. }
  11648. e.push(cc.p(c.x, c.y));
  11649. this.drawPoly(e, d + 1, !1, !1)
  11650. },
  11651. drawCubicBezier: function(a, b, c, d, e) {
  11652. for (var f = this._cacheArray,
  11653. g = f.length = 0, h = 0; h < e; h++) {
  11654. var k = Math.pow(1 - g, 3) * a.x + 3 * Math.pow(1 - g, 2) * g * b.x + 3 * (1 - g) * g * g * c.x + g * g * g * d.x,
  11655. m = Math.pow(1 - g, 3) * a.y + 3 * Math.pow(1 - g, 2) * g * b.y + 3 * (1 - g) * g * g * c.y + g * g * g * d.y;
  11656. f.push(cc.p(k, m));
  11657. g += 1 / e
  11658. }
  11659. f.push(cc.p(d.x, d.y));
  11660. this.drawPoly(f, e + 1, !1, !1)
  11661. },
  11662. drawCatmullRom: function(a, b) {
  11663. this.drawCardinalSpline(a, 0.5, b)
  11664. },
  11665. drawCardinalSpline: function(a, b, c) {
  11666. cc._renderContext.setStrokeStyle("rgba(255,255,255,1)");
  11667. var d = this._cacheArray;
  11668. d.length = 0;
  11669. for (var e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c, 1 === f ? (e = a.length - 1,
  11670. f = 1) : (e = 0 | f / g, f = (f - g * e) / g), e = cc.CardinalSplineAt(cc.getControlPointAt(a, e - 1), cc.getControlPointAt(a, e - 0), cc.getControlPointAt(a, e + 1), cc.getControlPointAt(a, e + 2), b, f), d.push(e);
  11671. this.drawPoly(d, c + 1, !1, !1)
  11672. },
  11673. drawImage: function(a, b, c, d, e) {
  11674. var f = arguments.length,
  11675. g = this._renderContext.getContext();
  11676. switch (f) {
  11677. case 2:
  11678. g.drawImage(a, b.x, -(b.y + a.height));
  11679. break;
  11680. case 3:
  11681. g.drawImage(a, b.x, -(b.y + c.height), c.width, c.height);
  11682. break;
  11683. case 5:
  11684. g.drawImage(a, b.x, b.y, c.width, c.height, d.x, -(d.y + e.height), e.width, e.height);
  11685. break;
  11686. default:
  11687. throw Error("Argument must be non-nil");
  11688. }
  11689. },
  11690. drawStar: function(a, b, c) {
  11691. a = a || this._renderContext;
  11692. var d = a.getContext();
  11693. b *= cc.view.getScaleX();
  11694. c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b);
  11695. a.setFillStyle(c + ",1)");
  11696. var e = b / 10;
  11697. d.beginPath();
  11698. d.moveTo(-b, b);
  11699. d.lineTo(0, e);
  11700. d.lineTo(b, b);
  11701. d.lineTo(e, 0);
  11702. d.lineTo(b, -b);
  11703. d.lineTo(0, -e);
  11704. d.lineTo(-b, -b);
  11705. d.lineTo(-e, 0);
  11706. d.lineTo(-b, b);
  11707. d.closePath();
  11708. d.fill();
  11709. var f = d.createRadialGradient(0, 0, e, 0, 0, b);
  11710. f.addColorStop(0, c + ", 1)");
  11711. f.addColorStop(0.3, c + ", 0.8)");
  11712. f.addColorStop(1,
  11713. c + ", 0.0)");
  11714. a.setFillStyle(f);
  11715. d.beginPath();
  11716. d.arc(0, 0, b - e, 0, cc.PI2, !1);
  11717. d.closePath();
  11718. d.fill()
  11719. },
  11720. drawColorBall: function(a, b, c) {
  11721. a = a || this._renderContext;
  11722. var d = a.getContext();
  11723. b *= cc.view.getScaleX();
  11724. c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b);
  11725. var e = d.createRadialGradient(0, 0, b / 10, 0, 0, b);
  11726. e.addColorStop(0, c + ", 1)");
  11727. e.addColorStop(0.3, c + ", 0.8)");
  11728. e.addColorStop(0.6, c + ", 0.4)");
  11729. e.addColorStop(1, c + ", 0.0)");
  11730. a.setFillStyle(e);
  11731. d.beginPath();
  11732. d.arc(0, 0, b, 0, cc.PI2, !1);
  11733. d.closePath();
  11734. d.fill()
  11735. },
  11736. fillText: function(a, b,
  11737. c) {
  11738. this._renderContext.getContext().fillText(a, b, -c)
  11739. },
  11740. setDrawColor: function(a, b, c, d) {
  11741. this._renderContext.setFillStyle("rgba(" + a + "," + b + "," + c + "," + d / 255 + ")");
  11742. this._renderContext.setStrokeStyle("rgba(" + a + "," + b + "," + c + "," + d / 255 + ")")
  11743. },
  11744. setPointSize: function(a) {},
  11745. setLineWidth: function(a) {
  11746. this._renderContext.getContext().lineWidth = a * cc.view.getScaleX()
  11747. }
  11748. });
  11749. cc.DrawingPrimitiveWebGL = cc.Class.extend({
  11750. _renderContext: null,
  11751. _initialized: !1,
  11752. _shader: null,
  11753. _colorLocation: -1,
  11754. _colorArray: null,
  11755. _pointSizeLocation: -1,
  11756. _pointSize: -1,
  11757. ctor: function(a) {
  11758. null == a && (a = cc._renderContext);
  11759. if (!a instanceof WebGLRenderingContext) throw "Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext";
  11760. this._renderContext = a;
  11761. this._colorArray = new Float32Array([1, 1, 1, 1])
  11762. },
  11763. lazy_init: function() {
  11764. this._initialized || (this._shader = cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR),
  11765. this._colorLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_color"), this._pointSizeLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_pointSize"), this._initialized = !0)
  11766. },
  11767. drawInit: function() {
  11768. this._initialized = !1
  11769. },
  11770. drawPoint: function(a) {
  11771. this.lazy_init();
  11772. var b = this._renderContext;
  11773. this._shader.use();
  11774. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11775. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11776. b.uniform4fv(this._colorLocation,
  11777. this._colorArray);
  11778. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  11779. var c = b.createBuffer();
  11780. b.bindBuffer(b.ARRAY_BUFFER, c);
  11781. b.bufferData(b.ARRAY_BUFFER, new Float32Array([a.x, a.y]), b.STATIC_DRAW);
  11782. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  11783. b.drawArrays(b.POINTS, 0, 1);
  11784. b.deleteBuffer(c);
  11785. cc.incrementGLDraws(1)
  11786. },
  11787. drawPoints: function(a, b) {
  11788. if (a && 0 !== a.length) {
  11789. this.lazy_init();
  11790. var c = this._renderContext;
  11791. this._shader.use();
  11792. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11793. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11794. c.uniform4fv(this._colorLocation, this._colorArray);
  11795. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  11796. var d = c.createBuffer();
  11797. c.bindBuffer(c.ARRAY_BUFFER, d);
  11798. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
  11799. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  11800. c.drawArrays(c.POINTS, 0, a.length);
  11801. c.deleteBuffer(d);
  11802. cc.incrementGLDraws(1)
  11803. }
  11804. },
  11805. _pointsToTypeArray: function(a) {
  11806. for (var b = new Float32Array(2 *
  11807. a.length), c = 0; c < a.length; c++) b[2 * c] = a[c].x, b[2 * c + 1] = a[c].y;
  11808. return b
  11809. },
  11810. drawLine: function(a, b) {
  11811. this.lazy_init();
  11812. var c = this._renderContext;
  11813. this._shader.use();
  11814. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11815. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11816. c.uniform4fv(this._colorLocation, this._colorArray);
  11817. var d = c.createBuffer();
  11818. c.bindBuffer(c.ARRAY_BUFFER, d);
  11819. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray([a, b]), c.STATIC_DRAW);
  11820. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
  11821. 2, c.FLOAT, !1, 0, 0);
  11822. c.drawArrays(c.LINES, 0, 2);
  11823. c.deleteBuffer(d);
  11824. cc.incrementGLDraws(1)
  11825. },
  11826. drawRect: function(a, b) {
  11827. this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y));
  11828. this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y));
  11829. this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y));
  11830. this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y))
  11831. },
  11832. drawSolidRect: function(a, b, c) {
  11833. a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)];
  11834. this.drawSolidPoly(a, 4, c)
  11835. },
  11836. drawPoly: function(a, b, c) {
  11837. this.lazy_init();
  11838. b = this._renderContext;
  11839. this._shader.use();
  11840. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11841. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11842. b.uniform4fv(this._colorLocation, this._colorArray);
  11843. var d = b.createBuffer();
  11844. b.bindBuffer(b.ARRAY_BUFFER, d);
  11845. b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW);
  11846. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  11847. c ? b.drawArrays(b.LINE_LOOP, 0, a.length) : b.drawArrays(b.LINE_STRIP, 0, a.length);
  11848. b.deleteBuffer(d);
  11849. cc.incrementGLDraws(1)
  11850. },
  11851. drawSolidPoly: function(a, b, c) {
  11852. this.lazy_init();
  11853. c && this.setDrawColor(c.r, c.g, c.b, c.a);
  11854. b = this._renderContext;
  11855. this._shader.use();
  11856. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11857. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11858. b.uniform4fv(this._colorLocation, this._colorArray);
  11859. c = b.createBuffer();
  11860. b.bindBuffer(b.ARRAY_BUFFER, c);
  11861. b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW);
  11862. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  11863. b.drawArrays(b.TRIANGLE_FAN, 0, a.length);
  11864. b.deleteBuffer(c);
  11865. cc.incrementGLDraws(1)
  11866. },
  11867. drawCircle: function(a,
  11868. b, c, d, e) {
  11869. this.lazy_init();
  11870. var f = 1;
  11871. e && f++;
  11872. var g = 2 * Math.PI / d;
  11873. if (e = new Float32Array(2 * (d + 2))) {
  11874. for (var h = 0; h <= d; h++) {
  11875. var k = h * g,
  11876. m = b * Math.cos(k + c) + a.x,
  11877. k = b * Math.sin(k + c) + a.y;
  11878. e[2 * h] = m;
  11879. e[2 * h + 1] = k
  11880. }
  11881. e[2 * (d + 1)] = a.x;
  11882. e[2 * (d + 1) + 1] = a.y;
  11883. a = this._renderContext;
  11884. this._shader.use();
  11885. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11886. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11887. a.uniform4fv(this._colorLocation, this._colorArray);
  11888. b = a.createBuffer();
  11889. a.bindBuffer(a.ARRAY_BUFFER, b);
  11890. a.bufferData(a.ARRAY_BUFFER,
  11891. e, a.STATIC_DRAW);
  11892. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11893. a.drawArrays(a.LINE_STRIP, 0, d + f);
  11894. a.deleteBuffer(b);
  11895. cc.incrementGLDraws(1)
  11896. }
  11897. },
  11898. drawQuadBezier: function(a, b, c, d) {
  11899. this.lazy_init();
  11900. for (var e = new Float32Array(2 * (d + 1)), f = 0, g = 0; g < d; g++) e[2 * g] = Math.pow(1 - f, 2) * a.x + 2 * (1 - f) * f * b.x + f * f * c.x, e[2 * g + 1] = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y, f += 1 / d;
  11901. e[2 * d] = c.x;
  11902. e[2 * d + 1] = c.y;
  11903. a = this._renderContext;
  11904. this._shader.use();
  11905. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11906. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11907. a.uniform4fv(this._colorLocation, this._colorArray);
  11908. b = a.createBuffer();
  11909. a.bindBuffer(a.ARRAY_BUFFER, b);
  11910. a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW);
  11911. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11912. a.drawArrays(a.LINE_STRIP, 0, d + 1);
  11913. a.deleteBuffer(b);
  11914. cc.incrementGLDraws(1)
  11915. },
  11916. drawCubicBezier: function(a, b, c, d, e) {
  11917. this.lazy_init();
  11918. for (var f = new Float32Array(2 * (e + 1)), g = 0, h = 0; h < e; h++) f[2 * h] = Math.pow(1 - g, 3) * a.x + 3 * Math.pow(1 - g, 2) * g * b.x + 3 * (1 - g) * g * g * c.x + g * g * g * d.x, f[2 * h + 1] = Math.pow(1 - g, 3) * a.y + 3 * Math.pow(1 -
  11919. g, 2) * g * b.y + 3 * (1 - g) * g * g * c.y + g * g * g * d.y, g += 1 / e;
  11920. f[2 * e] = d.x;
  11921. f[2 * e + 1] = d.y;
  11922. a = this._renderContext;
  11923. this._shader.use();
  11924. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11925. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11926. a.uniform4fv(this._colorLocation, this._colorArray);
  11927. b = a.createBuffer();
  11928. a.bindBuffer(a.ARRAY_BUFFER, b);
  11929. a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
  11930. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11931. a.drawArrays(a.LINE_STRIP, 0, e + 1);
  11932. a.deleteBuffer(b);
  11933. cc.incrementGLDraws(1)
  11934. },
  11935. drawCatmullRom: function(a, b) {
  11936. this.drawCardinalSpline(a, 0.5, b)
  11937. },
  11938. drawCardinalSpline: function(a, b, c) {
  11939. this.lazy_init();
  11940. for (var d = new Float32Array(2 * (c + 1)), e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c, 1 === f ? (e = a.length - 1, f = 1) : (e = 0 | f / g, f = (f - g * e) / g), e = cc.cardinalSplineAt(cc.getControlPointAt(a, e - 1), cc.getControlPointAt(a, e), cc.getControlPointAt(a, e + 1), cc.getControlPointAt(a, e + 2), b, f), d[2 * h] = e.x, d[2 * h + 1] = e.y;
  11941. a = this._renderContext;
  11942. this._shader.use();
  11943. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11944. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11945. a.uniform4fv(this._colorLocation, this._colorArray);
  11946. b = a.createBuffer();
  11947. a.bindBuffer(a.ARRAY_BUFFER, b);
  11948. a.bufferData(a.ARRAY_BUFFER, d, a.STATIC_DRAW);
  11949. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11950. a.drawArrays(a.LINE_STRIP, 0, c + 1);
  11951. a.deleteBuffer(b);
  11952. cc.incrementGLDraws(1)
  11953. },
  11954. setDrawColor: function(a, b, c, d) {
  11955. this._colorArray[0] = a / 255;
  11956. this._colorArray[1] = b / 255;
  11957. this._colorArray[2] = c / 255;
  11958. this._colorArray[3] = d / 255
  11959. },
  11960. setPointSize: function(a) {
  11961. this._pointSize =
  11962. a * cc.contentScaleFactor()
  11963. },
  11964. setLineWidth: function(a) {
  11965. this._renderContext.lineWidth && this._renderContext.lineWidth(a)
  11966. }
  11967. });
  11968. cc._tmp.PrototypeLabelTTF = function() {
  11969. var a = cc.LabelTTF.prototype;
  11970. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  11971. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  11972. cc.defineGetterSetter(a, "string", a.getString, a.setString);
  11973. cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment);
  11974. cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment);
  11975. cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize);
  11976. cc.defineGetterSetter(a,
  11977. "fontName", a.getFontName, a.setFontName);
  11978. cc.defineGetterSetter(a, "font", a._getFont, a._setFont);
  11979. cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth);
  11980. cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight);
  11981. cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor);
  11982. cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle);
  11983. cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth);
  11984. cc.defineGetterSetter(a, "shadowOffsetX",
  11985. a._getShadowOffsetX, a._setShadowOffsetX);
  11986. cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY);
  11987. cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity);
  11988. cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur)
  11989. };
  11990. cc.LabelTTF = cc.Sprite.extend({
  11991. _dimensions: null,
  11992. _hAlignment: cc.TEXT_ALIGNMENT_CENTER,
  11993. _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP,
  11994. _fontName: null,
  11995. _fontSize: 0,
  11996. _string: "",
  11997. _originalText: null,
  11998. _shadowEnabled: !1,
  11999. _shadowOffset: null,
  12000. _shadowOpacity: 0,
  12001. _shadowBlur: 0,
  12002. _shadowColor: null,
  12003. _strokeEnabled: !1,
  12004. _strokeColor: null,
  12005. _strokeSize: 0,
  12006. _textFillColor: null,
  12007. _strokeShadowOffsetX: 0,
  12008. _strokeShadowOffsetY: 0,
  12009. _needUpdateTexture: !1,
  12010. _lineWidths: null,
  12011. _className: "LabelTTF",
  12012. _fontStyle: "normal",
  12013. _fontWeight: "normal",
  12014. _lineHeight: "normal",
  12015. initWithString: function(a, b, c, d, e, f) {
  12016. a = a ? a + "" : "";
  12017. c = c || 16;
  12018. d = d || cc.size(0, 0);
  12019. e = e || cc.TEXT_ALIGNMENT_LEFT;
  12020. f = f || cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  12021. this._opacityModifyRGB = !1;
  12022. this._dimensions = cc.size(d.width, d.height);
  12023. this._fontName = b || "Arial";
  12024. this._hAlignment = e;
  12025. this._vAlignment = f;
  12026. this._fontSize = c;
  12027. this._renderCmd._setFontStyle(this._fontName, c, this._fontStyle, this._fontWeight);
  12028. this.string = a;
  12029. this._renderCmd._setColorsString();
  12030. this._renderCmd._updateTexture();
  12031. this._setUpdateTextureDirty();
  12032. return !0
  12033. },
  12034. _setUpdateTextureDirty: function() {
  12035. this._needUpdateTexture = !0;
  12036. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.textDirty)
  12037. },
  12038. ctor: function(a, b, c, d, e, f) {
  12039. cc.Sprite.prototype.ctor.call(this);
  12040. this._dimensions = cc.size(0, 0);
  12041. this._hAlignment = cc.TEXT_ALIGNMENT_LEFT;
  12042. this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  12043. this._opacityModifyRGB = !1;
  12044. this._fontName = "Arial";
  12045. this._shadowEnabled = !1;
  12046. this._shadowOffset = cc.p(0, 0);
  12047. this._shadowBlur = this._shadowOpacity = 0;
  12048. this._strokeEnabled = !1;
  12049. this._strokeColor = cc.color(255, 255, 255, 255);
  12050. this._strokeSize = 0;
  12051. this._textFillColor = cc.color(255,
  12052. 255, 255, 255);
  12053. this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0;
  12054. this._needUpdateTexture = !1;
  12055. this._lineWidths = [];
  12056. this._renderCmd._setColorsString();
  12057. this._textureLoaded = !0;
  12058. b && b instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, b) : cc.LabelTTF.prototype.initWithString.call(this, a, b, c, d, e, f)
  12059. },
  12060. init: function() {
  12061. return this.initWithString(" ", this._fontName, this._fontSize)
  12062. },
  12063. description: function() {
  12064. return "\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) +
  12065. "\x3e"
  12066. },
  12067. getLineHeight: function() {
  12068. return !this._lineHeight || this._lineHeight.charAt ? this._renderCmd._getFontClientHeight() : this._lineHeight || this._renderCmd._getFontClientHeight()
  12069. },
  12070. setLineHeight: function(a) {
  12071. this._lineHeight = a
  12072. },
  12073. getString: function() {
  12074. return this._string
  12075. },
  12076. getHorizontalAlignment: function() {
  12077. return this._hAlignment
  12078. },
  12079. getVerticalAlignment: function() {
  12080. return this._vAlignment
  12081. },
  12082. getDimensions: function() {
  12083. return cc.size(this._dimensions)
  12084. },
  12085. getFontSize: function() {
  12086. return this._fontSize
  12087. },
  12088. getFontName: function() {
  12089. return this._fontName
  12090. },
  12091. initWithStringAndTextDefinition: function(a, b) {
  12092. this._updateWithTextDefinition(b, !1);
  12093. this.string = a;
  12094. return !0
  12095. },
  12096. setTextDefinition: function(a) {
  12097. a && this._updateWithTextDefinition(a, !0)
  12098. },
  12099. getTextDefinition: function() {
  12100. return this._prepareTextDefinition(!1)
  12101. },
  12102. enableShadow: function(a, b, c, d) {
  12103. null != a.r && null != a.g && null != a.b && null != a.a ? this._enableShadow(a, b, c) : this._enableShadowNoneColor(a, b, c, d)
  12104. },
  12105. _enableShadowNoneColor: function(a, b, c, d) {
  12106. c = c || 0.5;
  12107. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  12108. var e = this._shadowOffset;
  12109. if (e && e.x !== a || e._y !== b) e.x = a, e.y = b;
  12110. this._shadowOpacity !== c && (this._shadowOpacity = c);
  12111. this._renderCmd._setColorsString();
  12112. this._shadowBlur !== d && (this._shadowBlur = d);
  12113. this._setUpdateTextureDirty()
  12114. },
  12115. _enableShadow: function(a, b, c) {
  12116. this._shadowColor || (this._shadowColor = cc.color(255, 255, 255, 128));
  12117. this._shadowColor.r = a.r;
  12118. this._shadowColor.g = a.g;
  12119. this._shadowColor.b = a.b;
  12120. this._enableShadowNoneColor(b.width || b.x || 0, b.height || b.y || 0, null != a.a ? a.a / 255 : 0.5, c)
  12121. },
  12122. _getShadowOffsetX: function() {
  12123. return this._shadowOffset.x
  12124. },
  12125. _setShadowOffsetX: function(a) {
  12126. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  12127. this._shadowOffset.x !== a && (this._shadowOffset.x = a, this._setUpdateTextureDirty())
  12128. },
  12129. _getShadowOffsetY: function() {
  12130. return this._shadowOffset._y
  12131. },
  12132. _setShadowOffsetY: function(a) {
  12133. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  12134. this._shadowOffset._y !== a && (this._shadowOffset._y = a, this._setUpdateTextureDirty())
  12135. },
  12136. _getShadowOffset: function() {
  12137. return cc.p(this._shadowOffset.x, this._shadowOffset.y)
  12138. },
  12139. _setShadowOffset: function(a) {
  12140. !1 ===
  12141. this._shadowEnabled && (this._shadowEnabled = !0);
  12142. if (this._shadowOffset.x !== a.x || this._shadowOffset.y !== a.y) this._shadowOffset.x = a.x, this._shadowOffset.y = a.y, this._setUpdateTextureDirty()
  12143. },
  12144. _getShadowOpacity: function() {
  12145. return this._shadowOpacity
  12146. },
  12147. _setShadowOpacity: function(a) {
  12148. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  12149. this._shadowOpacity !== a && (this._shadowOpacity = a, this._renderCmd._setColorsString(), this._setUpdateTextureDirty())
  12150. },
  12151. _getShadowBlur: function() {
  12152. return this._shadowBlur
  12153. },
  12154. _setShadowBlur: function(a) {
  12155. !1 ===
  12156. this._shadowEnabled && (this._shadowEnabled = !0);
  12157. this._shadowBlur !== a && (this._shadowBlur = a, this._setUpdateTextureDirty())
  12158. },
  12159. disableShadow: function() {
  12160. this._shadowEnabled && (this._shadowEnabled = !1, this._setUpdateTextureDirty())
  12161. },
  12162. enableStroke: function(a, b) {
  12163. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  12164. var c = this._strokeColor;
  12165. 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._renderCmd._setColorsString();
  12166. this._strokeSize !== b && (this._strokeSize = b || 0);
  12167. this._setUpdateTextureDirty()
  12168. },
  12169. _getStrokeStyle: function() {
  12170. return this._strokeColor
  12171. },
  12172. _setStrokeStyle: function(a) {
  12173. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  12174. var b = this._strokeColor;
  12175. if (b.r !== a.r || b.g !== a.g || b.b !== a.b) b.r = a.r, b.g = a.g, b.b = a.b, this._renderCmd._setColorsString(), this._setUpdateTextureDirty()
  12176. },
  12177. _getLineWidth: function() {
  12178. return this._strokeSize
  12179. },
  12180. _setLineWidth: function(a) {
  12181. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  12182. this._strokeSize !== a && (this._strokeSize = a || 0, this._setUpdateTextureDirty())
  12183. },
  12184. disableStroke: function() {
  12185. this._strokeEnabled && (this._strokeEnabled = !1,
  12186. this._setUpdateTextureDirty())
  12187. },
  12188. setFontFillColor: function(a) {
  12189. var b = this._textFillColor;
  12190. if (b.r !== a.r || b.g !== a.g || b.b !== a.b) b.r = a.r, b.g = a.g, b.b = a.b, this._renderCmd._setColorsString(), this._needUpdateTexture = !0
  12191. },
  12192. _getFillStyle: function() {
  12193. return this._textFillColor
  12194. },
  12195. _updateWithTextDefinition: function(a, b) {
  12196. a.fontDimensions ? (this._dimensions.width = a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0);
  12197. this._hAlignment = a.textAlign;
  12198. this._vAlignment = a.verticalAlign;
  12199. this._fontName = a.fontName;
  12200. this._fontSize = a.fontSize || 12;
  12201. this._lineHeight = a.lineHeight ? a.lineHeight : this._fontSize;
  12202. this._renderCmd._setFontStyle(a);
  12203. a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur);
  12204. a.strokeEnabled && this.enableStroke(a.strokeStyle, a.lineWidth);
  12205. this.setFontFillColor(a.fillStyle);
  12206. b && this._renderCmd._updateTexture();
  12207. var c = cc.Node._dirtyFlags;
  12208. this._renderCmd.setDirtyFlag(c.colorDirty | c.opacityDirty | c.textDirty)
  12209. },
  12210. _prepareTextDefinition: function(a) {
  12211. var b =
  12212. new cc.FontDefinition;
  12213. a ? (b.fontSize = this._fontSize, b.boundingWidth = cc.contentScaleFactor() * this._dimensions.width, b.boundingHeight = cc.contentScaleFactor() * this._dimensions.height) : (b.fontSize = this._fontSize, b.boundingWidth = this._dimensions.width, b.boundingHeight = this._dimensions.height);
  12214. b.fontName = this._fontName;
  12215. b.textAlign = this._hAlignment;
  12216. b.verticalAlign = this._vAlignment;
  12217. if (this._strokeEnabled) {
  12218. b.strokeEnabled = !0;
  12219. var c = this._strokeColor;
  12220. b.strokeStyle = cc.color(c.r, c.g, c.b);
  12221. b.lineWidth = this._strokeSize
  12222. } else b.strokeEnabled = !1;
  12223. this._shadowEnabled ? (b.shadowEnabled = !0, b.shadowBlur = this._shadowBlur, b.shadowOpacity = this._shadowOpacity, b.shadowOffsetX = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.x, b.shadowOffsetY = (a ? cc.contentScaleFactor() : 1) * this._shadowOffset.y) : b._shadowEnabled = !1;
  12224. a = this._textFillColor;
  12225. b.fillStyle = cc.color(a.r, a.g, a.b);
  12226. return b
  12227. },
  12228. setString: function(a) {
  12229. a = String(a);
  12230. this._originalText !== a && (this._originalText = a + "", this._updateString(), this._setUpdateTextureDirty(), this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))
  12231. },
  12232. _updateString: function() {
  12233. this._string && "" !== this._string || this._string === this._originalText || (cc.renderer.childrenOrderDirty = !0);
  12234. this._string = this._originalText
  12235. },
  12236. setHorizontalAlignment: function(a) {
  12237. a !== this._hAlignment && (this._hAlignment = a, this._setUpdateTextureDirty())
  12238. },
  12239. setVerticalAlignment: function(a) {
  12240. a !== this._vAlignment && (this._vAlignment = a, this._setUpdateTextureDirty())
  12241. },
  12242. setDimensions: function(a, b) {
  12243. var c;
  12244. void 0 === b ? (c = a.width, b = a.height) : c = a;
  12245. if (c !== this._dimensions.width || b !== this._dimensions.height) this._dimensions.width =
  12246. c, this._dimensions.height = b, this._updateString(), this._setUpdateTextureDirty()
  12247. },
  12248. _getBoundingWidth: function() {
  12249. return this._dimensions.width
  12250. },
  12251. _setBoundingWidth: function(a) {
  12252. a !== this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._setUpdateTextureDirty())
  12253. },
  12254. _getBoundingHeight: function() {
  12255. return this._dimensions.height
  12256. },
  12257. _setBoundingHeight: function(a) {
  12258. a !== this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._setUpdateTextureDirty())
  12259. },
  12260. setFontSize: function(a) {
  12261. this._fontSize !==
  12262. a && (this._fontSize = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty())
  12263. },
  12264. setFontName: function(a) {
  12265. this._fontName && this._fontName !== a && (this._fontName = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty())
  12266. },
  12267. _getFont: function() {
  12268. return this._renderCmd._getFontStyle()
  12269. },
  12270. _setFont: function(a) {
  12271. if (a = cc.LabelTTF._fontStyleRE.exec(a)) this._fontSize = parseInt(a[1]), this._fontName =
  12272. a[2], this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty()
  12273. },
  12274. getContentSize: function() {
  12275. this._needUpdateTexture && this._renderCmd._updateTTF();
  12276. return cc.Sprite.prototype.getContentSize.call(this)
  12277. },
  12278. _getWidth: function() {
  12279. this._needUpdateTexture && this._renderCmd._updateTTF();
  12280. return cc.Sprite.prototype._getWidth.call(this)
  12281. },
  12282. _getHeight: function() {
  12283. this._needUpdateTexture && this._renderCmd._updateTTF();
  12284. return cc.Sprite.prototype._getHeight.call(this)
  12285. },
  12286. setTextureRect: function(a, b, c) {
  12287. cc.Sprite.prototype.setTextureRect.call(this, a, b, c, !1)
  12288. },
  12289. _createRenderCmd: function() {
  12290. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.LabelTTF.CanvasRenderCmd(this) : new cc.LabelTTF.WebGLRenderCmd(this)
  12291. },
  12292. _setFontStyle: function(a) {
  12293. this._fontStyle !== a && (this._fontStyle = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty())
  12294. },
  12295. _getFontStyle: function() {
  12296. return this._fontStyle
  12297. },
  12298. _setFontWeight: function(a) {
  12299. this._fontWeight !==
  12300. a && (this._fontWeight = a, this._renderCmd._setFontStyle(this._fontName, this._fontSize, this._fontStyle, this._fontWeight), this._setUpdateTextureDirty())
  12301. },
  12302. _getFontWeight: function() {
  12303. return this._fontWeight
  12304. }
  12305. });
  12306. cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF), cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js");
  12307. cc._tmp.PrototypeLabelTTF();
  12308. delete cc._tmp.PrototypeLabelTTF;
  12309. cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
  12310. cc.LabelTTF.create = function(a, b, c, d, e, f) {
  12311. return new cc.LabelTTF(a, b, c, d, e, f)
  12312. };
  12313. cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create;
  12314. cc.LabelTTF._SHADER_PROGRAM = cc.USE_LA88_LABELS ? cc.SHADER_POSITION_TEXTURECOLOR : cc.SHADER_POSITION_TEXTUREA8COLOR;
  12315. cc.LabelTTF.__labelHeightDiv = cc.newElement("div");
  12316. cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial";
  12317. cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
  12318. cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
  12319. cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
  12320. cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
  12321. document.body ? document.body.appendChild(cc.LabelTTF.__labelHeightDiv) : cc._addEventListener(window, "load", function() {
  12322. this.removeEventListener("load", arguments.callee, !1);
  12323. document.body.appendChild(cc.LabelTTF.__labelHeightDiv)
  12324. }, !1);
  12325. cc.LabelTTF.__getFontHeightByDiv = function(a, b) {
  12326. if (a instanceof cc.FontDefinition) {
  12327. var c = cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()];
  12328. if (0 < c) return c;
  12329. var d = cc.LabelTTF.__labelHeightDiv;
  12330. d.innerHTML = "ajghl~!";
  12331. d.style.fontFamily = a.fontName;
  12332. d.style.fontSize = a.fontSize + "px";
  12333. d.style.fontStyle = a.fontStyle;
  12334. d.style.fontWeight = a.fontWeight;
  12335. c = d.clientHeight;
  12336. cc.LabelTTF.__fontHeightCache[a._getCanvasFontStr()] = c;
  12337. d.innerHTML = "";
  12338. return c
  12339. }
  12340. c = cc.LabelTTF.__fontHeightCache[a + "." + b];
  12341. if (0 < c) return c;
  12342. d = cc.LabelTTF.__labelHeightDiv;
  12343. d.innerHTML = "ajghl~!";
  12344. d.style.fontFamily = a;
  12345. d.style.fontSize = b + "px";
  12346. c = d.clientHeight;
  12347. cc.LabelTTF.__fontHeightCache[a + "." + b] = c;
  12348. d.innerHTML = "";
  12349. return c
  12350. };
  12351. cc.LabelTTF.__fontHeightCache = {};
  12352. cc.LabelTTF._textAlign = ["left", "center", "right"];
  12353. cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
  12354. cc.LabelTTF.wrapInspection = !0;
  12355. 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)/;
  12356. cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/;
  12357. 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)$/;
  12358. cc.LabelTTF._lastEnglish = /[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]+$/;
  12359. cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9\u00c4\u00d6\u00dc\u00e4\u00f6\u00fc\u00df\u00e9\u00e8\u00e7\u00e0\u00f9\u00ea\u00e2\u00ee\u00f4\u00fb]/;
  12360. (function() {
  12361. cc.LabelTTF.RenderCmd = function() {
  12362. this._fontClientHeight = 18;
  12363. this._fontStyleStr = "";
  12364. this._shadowColorStr = "rgba(128, 128, 128, 0.5)";
  12365. this._strokeColorStr = "";
  12366. this._fillColorStr = "rgba(255,255,255,1)";
  12367. this._labelContext = this._labelCanvas = null;
  12368. this._lineWidths = [];
  12369. this._strings = [];
  12370. this._isMultiLine = !1
  12371. };
  12372. var a = cc.LabelTTF.RenderCmd.prototype;
  12373. a.constructor = cc.LabelTTF.RenderCmd;
  12374. a._getLabelContext = function() {
  12375. if (this._labelContext) return this._labelContext;
  12376. var a = this._node;
  12377. if (!this._labelCanvas) {
  12378. var c =
  12379. cc.newElement("canvas");
  12380. c.width = 1;
  12381. c.height = 1;
  12382. var d = new cc.Texture2D;
  12383. d.initWithElement(c);
  12384. a.setTexture(d);
  12385. this._labelCanvas = c
  12386. }
  12387. return this._labelContext = this._labelCanvas.getContext("2d")
  12388. };
  12389. a._setFontStyle = function(a, c, d, e) {
  12390. a instanceof cc.FontDefinition ? (this._fontStyleStr = a._getCanvasFontStr(), this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a)) : (this._fontStyleStr = d + " " + e + " " + c + "px '" + a + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a, c))
  12391. };
  12392. a._getFontStyle = function() {
  12393. return this._fontStyleStr
  12394. };
  12395. a._getFontClientHeight = function() {
  12396. return this._fontClientHeight
  12397. };
  12398. a._updateTexture = function() {
  12399. this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.textDirty;
  12400. var a = this._node,
  12401. c = this._getLabelContext(),
  12402. d = this._labelCanvas,
  12403. e = a._contentSize;
  12404. if (0 === a._string.length) return d.width = 1, d.height = e.height || 1, a._texture && a._texture.handleLoadedTexture(), a.setTextureRect(cc.rect(0, 0, 1, e.height)), !0;
  12405. c.font = this._fontStyleStr;
  12406. this._updateTTF();
  12407. var f = e.width,
  12408. e = e.height,
  12409. g = d.width === f && d.height === e;
  12410. d.width = f;
  12411. d.height =
  12412. e;
  12413. g && c.clearRect(0, 0, f, e);
  12414. this._drawTTFInCanvas(c);
  12415. a._texture && a._texture.handleLoadedTexture();
  12416. a.setTextureRect(cc.rect(0, 0, f, e));
  12417. return !0
  12418. };
  12419. a._measureConfig = function() {
  12420. this._getLabelContext().font = this._fontStyleStr
  12421. };
  12422. a._measure = function(a) {
  12423. return this._getLabelContext().measureText(a).width
  12424. };
  12425. a._updateTTF = function() {
  12426. var a = this._node,
  12427. c = a._dimensions.width,
  12428. d, e, f = this._lineWidths;
  12429. f.length = 0;
  12430. this._isMultiLine = !1;
  12431. this._measureConfig();
  12432. if (0 !== c)
  12433. for (this._strings = a._string.split("\n"), d = 0; d < this._strings.length; d++) this._checkWarp(this._strings,
  12434. d, c);
  12435. else
  12436. for (this._strings = a._string.split("\n"), d = 0, e = this._strings.length; d < e; d++) f.push(this._measure(this._strings[d]));
  12437. 0 < this._strings.length && (this._isMultiLine = !0);
  12438. e = d = 0;
  12439. a._strokeEnabled && (d = e = 2 * a._strokeSize);
  12440. if (a._shadowEnabled) {
  12441. var g = a._shadowOffset;
  12442. d += 2 * Math.abs(g.x);
  12443. e += 2 * Math.abs(g.y)
  12444. }
  12445. c = 0 === c ? this._isMultiLine ? cc.size(Math.ceil(Math.max.apply(Math, f) + d), Math.ceil(this._fontClientHeight * this._strings.length + e)) : cc.size(Math.ceil(this._measure(a._string) + d), Math.ceil(this._fontClientHeight +
  12446. e)) : 0 === a._dimensions.height ? this._isMultiLine ? cc.size(Math.ceil(c + d), Math.ceil(a.getLineHeight() * this._strings.length + e)) : cc.size(Math.ceil(c + d), Math.ceil(a.getLineHeight() + e)) : cc.size(Math.ceil(c + d), Math.ceil(a._dimensions.height + e));
  12447. "normal" !== a._getFontStyle() && (c.width = Math.ceil(c.width + 0.3 * a._fontSize));
  12448. a.setContentSize(c);
  12449. a._strokeShadowOffsetX = d;
  12450. a._strokeShadowOffsetY = e;
  12451. a = a._anchorPoint;
  12452. this._anchorPointInPoints.x = 0.5 * d + (c.width - d) * a.x;
  12453. this._anchorPointInPoints.y = 0.5 * e + (c.height - e) * a.y
  12454. };
  12455. a._drawTTFInCanvas =
  12456. function(a) {
  12457. if (a) {
  12458. var c = this._node,
  12459. d = c._strokeShadowOffsetX,
  12460. e = c._strokeShadowOffsetY,
  12461. f = c._contentSize.height - e,
  12462. g = c._vAlignment,
  12463. h = c._hAlignment,
  12464. k = c._strokeSize;
  12465. a.setTransform(1, 0, 0, 1, 0.5 * d, f + 0.5 * e);
  12466. a.font !== this._fontStyleStr && (a.font = this._fontStyleStr);
  12467. a.fillStyle = this._fillColorStr;
  12468. var m = e = 0,
  12469. n = c._strokeEnabled;
  12470. n && (a.lineWidth = 2 * k, a.strokeStyle = this._strokeColorStr);
  12471. c._shadowEnabled && (k = c._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = k.x, a.shadowOffsetY = -k.y, a.shadowBlur = c._shadowBlur);
  12472. a.textBaseline = cc.LabelTTF._textBaseline[g];
  12473. a.textAlign = cc.LabelTTF._textAlign[h];
  12474. var p = c._contentSize.width - d,
  12475. d = c.getLineHeight(),
  12476. k = (d - this._fontClientHeight) / 2,
  12477. e = h === cc.TEXT_ALIGNMENT_RIGHT ? e + p : h === cc.TEXT_ALIGNMENT_CENTER ? e + p / 2 : e + 0;
  12478. if (this._isMultiLine)
  12479. for (c = this._strings.length, g === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? m = d - 2 * k + f - d * c : g === cc.VERTICAL_TEXT_ALIGNMENT_CENTER && (m = (d - 2 * k) / 2 + (f - d * c) / 2), g = 0; g < c; g++) h = this._strings[g], p = -f + (d * g + k) + m, n && a.strokeText(h, e, p), a.fillText(h, e, p);
  12480. else g !== cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM &&
  12481. (m = g === cc.VERTICAL_TEXT_ALIGNMENT_TOP ? m - f : m - 0.5 * f), n && a.strokeText(c._string, e, m), a.fillText(c._string, e, m)
  12482. }
  12483. };
  12484. a._checkWarp = function(a, c, d) {
  12485. var e = a[c],
  12486. f = this._measure(e);
  12487. if (f > d && 1 < e.length) {
  12488. for (var g = d / f * e.length | 0, h = e.substr(g), k = f - this._measure(h), m, n = 0, p = 0; k > d && 100 > p++;) g *= d / k, g |= 0, h = e.substr(g), k = f - this._measure(h);
  12489. for (p = 0; k < d && 100 > p++;) 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);
  12490. g -= n;
  12491. 0 === g && (g = 1, m = m.substr(1));
  12492. d = e.substr(0, g);
  12493. cc.LabelTTF.wrapInspection &&
  12494. 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));
  12495. 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));
  12496. a[c] = m || h;
  12497. a.splice(c, 0, d)
  12498. }
  12499. }
  12500. })();
  12501. (function() {
  12502. cc.LabelTTF.CanvasRenderCmd = function(a) {
  12503. cc.Sprite.CanvasRenderCmd.call(this, a);
  12504. cc.LabelTTF.RenderCmd.call(this)
  12505. };
  12506. cc.LabelTTF.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype);
  12507. cc.inject(cc.LabelTTF.RenderCmd.prototype, cc.LabelTTF.CanvasRenderCmd.prototype);
  12508. var a = cc.LabelTTF.CanvasRenderCmd.prototype;
  12509. a.constructor = cc.LabelTTF.CanvasRenderCmd;
  12510. a.updateStatus = function() {
  12511. var a = cc.Node._dirtyFlags,
  12512. c = this._dirtyFlag,
  12513. d = c & a.colorDirty,
  12514. e = c & a.opacityDirty;
  12515. d && this._updateDisplayColor();
  12516. e && this._updateDisplayOpacity();
  12517. d ? this._updateColor() : c & a.textDirty && this._updateTexture();
  12518. this._dirtyFlag & a.transformDirty && (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)
  12519. };
  12520. a._syncStatus = function(a) {
  12521. var c = cc.Node._dirtyFlags,
  12522. d = this._dirtyFlag,
  12523. e = a ? a._node : null;
  12524. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty);
  12525. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  12526. a && a._dirtyFlag & c.transformDirty &&
  12527. (d |= c.transformDirty);
  12528. var e = d & c.colorDirty,
  12529. f = d & c.opacityDirty;
  12530. this._dirtyFlag = d;
  12531. e && this._syncDisplayColor();
  12532. f && this._syncDisplayOpacity();
  12533. e ? this._updateColor() : d & c.textDirty && this._updateTexture();
  12534. d & c.transformDirty && this.transform(a)
  12535. };
  12536. a._setColorsString = function() {
  12537. var a = this._displayedColor,
  12538. c = this._node,
  12539. d = c._shadowColor || this._displayedColor,
  12540. e = c._strokeColor,
  12541. f = c._textFillColor;
  12542. this._shadowColorStr = "rgba(" + (0 | 0.5 * d.r) + "," + (0 | 0.5 * d.g) + "," + (0 | 0.5 * d.b) + "," + c._shadowOpacity + ")";
  12543. this._fillColorStr = "rgba(" +
  12544. (0 | a.r / 255 * f.r) + "," + (0 | a.g / 255 * f.g) + "," + (0 | a.b / 255 * f.b) + ", 1)";
  12545. this._strokeColorStr = "rgba(" + (0 | a.r / 255 * e.r) + "," + (0 | a.g / 255 * e.g) + "," + (0 | a.b / 255 * e.b) + ", 1)"
  12546. };
  12547. a._updateColor = function() {
  12548. this._setColorsString();
  12549. this._updateTexture()
  12550. }
  12551. })();
  12552. (function() {
  12553. cc.LabelTTF.WebGLRenderCmd = function(a) {
  12554. cc.Sprite.WebGLRenderCmd.call(this, a);
  12555. cc.LabelTTF.RenderCmd.call(this);
  12556. this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM))
  12557. };
  12558. var a = cc.LabelTTF.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype);
  12559. cc.inject(cc.LabelTTF.RenderCmd.prototype, a);
  12560. a.constructor = cc.LabelTTF.WebGLRenderCmd;
  12561. a._setColorsString = function() {
  12562. this.setDirtyFlag(cc.Node._dirtyFlags.textDirty);
  12563. var a = this._node,
  12564. c = a._strokeColor,
  12565. d = a._textFillColor;
  12566. this._shadowColorStr = "rgba(128,128,128," + a._shadowOpacity + ")";
  12567. this._fillColorStr = "rgba(" + (0 | d.r) + "," + (0 | d.g) + "," + (0 | d.b) + ", 1)";
  12568. this._strokeColorStr = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + ", 1)"
  12569. };
  12570. a.updateStatus = function() {
  12571. var a = cc.Node._dirtyFlags,
  12572. c = this._dirtyFlag,
  12573. d = c & a.colorDirty,
  12574. e = c & a.opacityDirty;
  12575. d && this._updateDisplayColor();
  12576. e && this._updateDisplayOpacity();
  12577. d || e ? (this._setColorsString(), this._updateColor(), this._updateTexture()) : c & a.textDirty && this._updateTexture();
  12578. this._dirtyFlag & a.transformDirty &&
  12579. (this.transform(this.getParentRenderCmd(), !0), this._dirtyFlag ^= this._dirtyFlag & cc.Node._dirtyFlags.transformDirty)
  12580. };
  12581. a._syncStatus = function(a) {
  12582. var c = cc.Node._dirtyFlags,
  12583. d = this._dirtyFlag,
  12584. e = a ? a._node : null;
  12585. e && e._cascadeColorEnabled && a._dirtyFlag & c.colorDirty && (d |= c.colorDirty);
  12586. e && e._cascadeOpacityEnabled && a._dirtyFlag & c.opacityDirty && (d |= c.opacityDirty);
  12587. a && a._dirtyFlag & c.transformDirty && (d |= c.transformDirty);
  12588. var e = d & c.colorDirty,
  12589. f = d & c.opacityDirty;
  12590. this._dirtyFlag = d;
  12591. e && this._syncDisplayColor();
  12592. f && this._syncDisplayOpacity();
  12593. e || f ? (this._setColorsString(), this._updateColor(), this._updateTexture()) : d & c.textDirty && this._updateTexture();
  12594. this.transform(a)
  12595. }
  12596. })();
  12597. cc.HashElement = cc.Class.extend({
  12598. actions: null,
  12599. target: null,
  12600. actionIndex: 0,
  12601. currentAction: null,
  12602. currentActionSalvaged: !1,
  12603. paused: !1,
  12604. hh: null,
  12605. ctor: function() {
  12606. this.actions = [];
  12607. this.target = null;
  12608. this.actionIndex = 0;
  12609. this.currentAction = null;
  12610. this.paused = this.currentActionSalvaged = !1;
  12611. this.hh = null
  12612. }
  12613. });
  12614. cc.ActionManager = cc.Class.extend({
  12615. _hashTargets: null,
  12616. _arrayTargets: null,
  12617. _currentTarget: null,
  12618. _currentTargetSalvaged: !1,
  12619. _searchElementByTarget: function(a, b) {
  12620. for (var c = 0; c < a.length; c++)
  12621. if (b === a[c].target) return a[c];
  12622. return null
  12623. },
  12624. ctor: function() {
  12625. this._hashTargets = {};
  12626. this._arrayTargets = [];
  12627. this._currentTarget = null;
  12628. this._currentTargetSalvaged = !1
  12629. },
  12630. addAction: function(a, b, c) {
  12631. if (!a) throw "cc.ActionManager.addAction(): action must be non-null";
  12632. if (!b) throw "cc.ActionManager.addAction(): action must be non-null";
  12633. var d = this._hashTargets[b.__instanceId];
  12634. d || (d = new cc.HashElement, d.paused = c, d.target = b, this._hashTargets[b.__instanceId] = d, this._arrayTargets.push(d));
  12635. this._actionAllocWithHashElement(d);
  12636. d.actions.push(a);
  12637. a.startWithTarget(b)
  12638. },
  12639. removeAllActions: function() {
  12640. for (var a = this._arrayTargets, b = 0; b < a.length; b++) {
  12641. var c = a[b];
  12642. c && this.removeAllActionsFromTarget(c.target, !0)
  12643. }
  12644. },
  12645. removeAllActionsFromTarget: function(a, b) {
  12646. if (null != a) {
  12647. var c = this._hashTargets[a.__instanceId];
  12648. c && (-1 === c.actions.indexOf(c.currentAction) ||
  12649. c.currentActionSalvaged || (c.currentActionSalvaged = !0), c.actions.length = 0, this._currentTarget !== c || b ? this._deleteHashElement(c) : this._currentTargetSalvaged = !0)
  12650. }
  12651. },
  12652. removeAction: function(a) {
  12653. if (null != a) {
  12654. var b = a.getOriginalTarget();
  12655. if (b = this._hashTargets[b.__instanceId])
  12656. for (var c = 0; c < b.actions.length; c++) {
  12657. if (b.actions[c] === a) {
  12658. b.actions.splice(c, 1);
  12659. break
  12660. }
  12661. } else cc.log(cc._LogInfos.ActionManager_removeAction)
  12662. }
  12663. },
  12664. removeActionByTag: function(a, b) {
  12665. a === cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_addAction);
  12666. cc.assert(b, cc._LogInfos.ActionManager_addAction);
  12667. var c = this._hashTargets[b.__instanceId];
  12668. if (c)
  12669. for (var d = c.actions.length, e = 0; e < d; ++e) {
  12670. var f = c.actions[e];
  12671. if (f && f.getTag() === a && f.getOriginalTarget() === b) {
  12672. this._removeActionAtIndex(e, c);
  12673. break
  12674. }
  12675. }
  12676. },
  12677. getActionByTag: function(a, b) {
  12678. a === cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_getActionByTag);
  12679. var c = this._hashTargets[b.__instanceId];
  12680. if (c) {
  12681. if (null != c.actions)
  12682. for (var d = 0; d < c.actions.length; ++d) {
  12683. var e = c.actions[d];
  12684. if (e && e.getTag() === a) return e
  12685. }
  12686. cc.log(cc._LogInfos.ActionManager_getActionByTag_2,
  12687. a)
  12688. }
  12689. return null
  12690. },
  12691. numberOfRunningActionsInTarget: function(a) {
  12692. return (a = this._hashTargets[a.__instanceId]) ? a.actions ? a.actions.length : 0 : 0
  12693. },
  12694. pauseTarget: function(a) {
  12695. if (a = this._hashTargets[a.__instanceId]) a.paused = !0
  12696. },
  12697. resumeTarget: function(a) {
  12698. if (a = this._hashTargets[a.__instanceId]) a.paused = !1
  12699. },
  12700. pauseAllRunningActions: function() {
  12701. for (var a = [], b = this._arrayTargets, c = 0; c < b.length; c++) {
  12702. var d = b[c];
  12703. d && !d.paused && (d.paused = !0, a.push(d.target))
  12704. }
  12705. return a
  12706. },
  12707. resumeTargets: function(a) {
  12708. if (a)
  12709. for (var b = 0; b < a.length; b++) a[b] &&
  12710. this.resumeTarget(a[b])
  12711. },
  12712. purgeSharedManager: function() {
  12713. cc.director.getScheduler().unscheduleUpdate(this)
  12714. },
  12715. _removeActionAtIndex: function(a, b) {
  12716. b.actions[a] !== b.currentAction || b.currentActionSalvaged || (b.currentActionSalvaged = !0);
  12717. b.actions.splice(a, 1);
  12718. b.actionIndex >= a && b.actionIndex--;
  12719. 0 === b.actions.length && (this._currentTarget === b ? this._currentTargetSalvaged = !0 : this._deleteHashElement(b))
  12720. },
  12721. _deleteHashElement: function(a) {
  12722. a && (delete this._hashTargets[a.target.__instanceId], cc.arrayRemoveObject(this._arrayTargets,
  12723. a), a.actions = null, a.target = null)
  12724. },
  12725. _actionAllocWithHashElement: function(a) {
  12726. null == a.actions && (a.actions = [])
  12727. },
  12728. update: function(a) {
  12729. for (var b = this._arrayTargets, c, d = 0; d < b.length; d++) {
  12730. c = this._currentTarget = b[d];
  12731. if (!c.paused)
  12732. for (c.actionIndex = 0; c.actionIndex < (c.actions ? c.actions.length : 0); c.actionIndex++)
  12733. if (c.currentAction = c.actions[c.actionIndex], c.currentAction) {
  12734. c.currentActionSalvaged = !1;
  12735. c.currentAction.step(a * (c.currentAction._speedMethod ? c.currentAction._speed : 1));
  12736. if (c.currentActionSalvaged) c.currentAction =
  12737. null;
  12738. else if (c.currentAction.isDone()) {
  12739. c.currentAction.stop();
  12740. var e = c.currentAction;
  12741. c.currentAction = null;
  12742. this.removeAction(e)
  12743. }
  12744. c.currentAction = null
  12745. }
  12746. this._currentTargetSalvaged && 0 === c.actions.length && this._deleteHashElement(c)
  12747. }
  12748. }
  12749. });
  12750. cc.math = cc.math || {};
  12751. cc.math.EPSILON = 0.015625;
  12752. cc.math.square = function(a) {
  12753. return a * a
  12754. };
  12755. cc.math.almostEqual = function(a, b) {
  12756. return a + cc.math.EPSILON > b && a - cc.math.EPSILON < b
  12757. };
  12758. (function(a) {
  12759. a.math.Vec2 = function(a, b) {
  12760. void 0 === b ? (this.x = a.x, this.y = a.y) : (this.x = a || 0, this.y = b || 0)
  12761. };
  12762. var b = a.math.Vec2.prototype;
  12763. b.fill = function(a, b) {
  12764. this.x = a;
  12765. this.y = b
  12766. };
  12767. b.length = function() {
  12768. return Math.sqrt(a.math.square(this.x) + a.math.square(this.y))
  12769. };
  12770. b.lengthSq = function() {
  12771. return a.math.square(this.x) + a.math.square(this.y)
  12772. };
  12773. b.normalize = function() {
  12774. var a = 1 / this.length();
  12775. this.x *= a;
  12776. this.y *= a;
  12777. return this
  12778. };
  12779. a.math.Vec2.add = function(a, b, e) {
  12780. a.x = b.x + e.x;
  12781. a.y = b.y + e.y;
  12782. return a
  12783. };
  12784. b.add = function(a) {
  12785. this.x += a.x;
  12786. this.y +=
  12787. a.y;
  12788. return this
  12789. };
  12790. b.dot = function(a) {
  12791. return this.x * a.x + this.y * a.y
  12792. };
  12793. a.math.Vec2.subtract = function(a, b, e) {
  12794. a.x = b.x - e.x;
  12795. a.y = b.y - e.y;
  12796. return a
  12797. };
  12798. b.subtract = function(a) {
  12799. this.x -= a.x;
  12800. this.y -= a.y;
  12801. return this
  12802. };
  12803. b.transform = function(a) {
  12804. var b = this.x,
  12805. e = this.y;
  12806. this.x = b * a.mat[0] + e * a.mat[3] + a.mat[6];
  12807. this.y = b * a.mat[1] + e * a.mat[4] + a.mat[7];
  12808. return this
  12809. };
  12810. a.math.Vec2.scale = function(a, b, e) {
  12811. a.x = b.x * e;
  12812. a.y = b.y * e;
  12813. return a
  12814. };
  12815. b.scale = function(a) {
  12816. this.x *= a;
  12817. this.y *= a;
  12818. return this
  12819. };
  12820. b.equals = function(b) {
  12821. return this.x < b.x + a.math.EPSILON &&
  12822. this.x > b.x - a.math.EPSILON && this.y < b.y + a.math.EPSILON && this.y > b.y - a.math.EPSILON
  12823. }
  12824. })(cc);
  12825. (function(a) {
  12826. a.kmVec3 = a.math.Vec3 = function(a, b, e) {
  12827. a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z) : (this.x = a || 0, this.y = b || 0, this.z = e || 0)
  12828. };
  12829. a.math.vec3 = function(b, d, e) {
  12830. return new a.math.Vec3(b, d, e)
  12831. };
  12832. var b = a.math.Vec3.prototype;
  12833. b.fill = function(a, b, e) {
  12834. a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z) : (this.x = a, this.y = b, this.z = e);
  12835. return this
  12836. };
  12837. b.length = function() {
  12838. return Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z))
  12839. };
  12840. b.lengthSq = function() {
  12841. return a.math.square(this.x) + a.math.square(this.y) +
  12842. a.math.square(this.z)
  12843. };
  12844. b.normalize = function() {
  12845. var a = 1 / this.length();
  12846. this.x *= a;
  12847. this.y *= a;
  12848. this.z *= a;
  12849. return this
  12850. };
  12851. b.cross = function(a) {
  12852. var b = this.x,
  12853. e = this.y,
  12854. f = this.z;
  12855. this.x = e * a.z - f * a.y;
  12856. this.y = f * a.x - b * a.z;
  12857. this.z = b * a.y - e * a.x;
  12858. return this
  12859. };
  12860. b.dot = function(a) {
  12861. return this.x * a.x + this.y * a.y + this.z * a.z
  12862. };
  12863. b.add = function(a) {
  12864. this.x += a.x;
  12865. this.y += a.y;
  12866. this.z += a.z;
  12867. return this
  12868. };
  12869. b.subtract = function(a) {
  12870. this.x -= a.x;
  12871. this.y -= a.y;
  12872. this.z -= a.z;
  12873. return this
  12874. };
  12875. b.transform = function(a) {
  12876. var b = this.x,
  12877. e = this.y,
  12878. f = this.z;
  12879. a = a.mat;
  12880. this.x = b *
  12881. a[0] + e * a[4] + f * a[8] + a[12];
  12882. this.y = b * a[1] + e * a[5] + f * a[9] + a[13];
  12883. this.z = b * a[2] + e * a[6] + f * a[10] + a[14];
  12884. return this
  12885. };
  12886. b.transformNormal = function(a) {
  12887. var b = this.x,
  12888. e = this.y,
  12889. f = this.z;
  12890. a = a.mat;
  12891. this.x = b * a[0] + e * a[4] + f * a[8];
  12892. this.y = b * a[1] + e * a[5] + f * a[9];
  12893. this.z = b * a[2] + e * a[6] + f * a[10];
  12894. return this
  12895. };
  12896. b.transformCoord = function(b) {
  12897. var d = new a.math.Vec4(this.x, this.y, this.z, 1);
  12898. d.transform(b);
  12899. this.x = d.x / d.w;
  12900. this.y = d.y / d.w;
  12901. this.z = d.z / d.w;
  12902. return this
  12903. };
  12904. b.scale = function(a) {
  12905. this.x *= a;
  12906. this.y *= a;
  12907. this.z *= a;
  12908. return this
  12909. };
  12910. b.equals = function(b) {
  12911. var d =
  12912. a.math.EPSILON;
  12913. return this.x < b.x + d && this.x > b.x - d && this.y < b.y + d && this.y > b.y - d && this.z < b.z + d && this.z > b.z - d
  12914. };
  12915. b.inverseTransform = function(b) {
  12916. b = b.mat;
  12917. var d = new a.math.Vec3(this.x - b[12], this.y - b[13], this.z - b[14]);
  12918. this.x = d.x * b[0] + d.y * b[1] + d.z * b[2];
  12919. this.y = d.x * b[4] + d.y * b[5] + d.z * b[6];
  12920. this.z = d.x * b[8] + d.y * b[9] + d.z * b[10];
  12921. return this
  12922. };
  12923. b.inverseTransformNormal = function(a) {
  12924. var b = this.x,
  12925. e = this.y,
  12926. f = this.z;
  12927. a = a.mat;
  12928. this.x = b * a[0] + e * a[1] + f * a[2];
  12929. this.y = b * a[4] + e * a[5] + f * a[6];
  12930. this.z = b * a[8] + e * a[9] + f * a[10];
  12931. return this
  12932. };
  12933. b.assignFrom =
  12934. function(a) {
  12935. if (!a) return this;
  12936. this.x = a.x;
  12937. this.y = a.y;
  12938. this.z = a.z;
  12939. return this
  12940. };
  12941. a.math.Vec3.zero = function(a) {
  12942. a.x = a.y = a.z = 0;
  12943. return a
  12944. };
  12945. b.toTypeArray = function() {
  12946. var a = new Float32Array(3);
  12947. a[0] = this.x;
  12948. a[1] = this.y;
  12949. a[2] = this.z;
  12950. return a
  12951. }
  12952. })(cc);
  12953. (function(a) {
  12954. a.math.Vec4 = function(a, b, e, f) {
  12955. a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a || 0, this.y = b || 0, this.z = e || 0, this.w = f || 0)
  12956. };
  12957. a.kmVec4 = a.math.Vec4;
  12958. var b = a.math.Vec4.prototype;
  12959. b.fill = function(a, b, e, f) {
  12960. a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a, this.y = b, this.z = e, this.w = f)
  12961. };
  12962. b.add = function(a) {
  12963. if (!a) return this;
  12964. this.x += a.x;
  12965. this.y += a.y;
  12966. this.z += a.z;
  12967. this.w += a.w;
  12968. return this
  12969. };
  12970. b.dot = function(a) {
  12971. return this.x * a.x + this.y * a.y + this.z * a.z + this.w * a.w
  12972. };
  12973. b.length =
  12974. function() {
  12975. return Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z) + a.math.square(this.w))
  12976. };
  12977. b.lengthSq = function() {
  12978. return a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z) + a.math.square(this.w)
  12979. };
  12980. b.lerp = function(a, b) {
  12981. return this
  12982. };
  12983. b.normalize = function() {
  12984. var a = 1 / this.length();
  12985. this.x *= a;
  12986. this.y *= a;
  12987. this.z *= a;
  12988. this.w *= a;
  12989. return this
  12990. };
  12991. b.scale = function(a) {
  12992. this.normalize();
  12993. this.x *= a;
  12994. this.y *= a;
  12995. this.z *= a;
  12996. this.w *= a;
  12997. return this
  12998. };
  12999. b.subtract = function(a) {
  13000. this.x -= a.x;
  13001. this.y -=
  13002. a.y;
  13003. this.z -= a.z;
  13004. this.w -= a.w
  13005. };
  13006. b.transform = function(a) {
  13007. var b = this.x,
  13008. e = this.y,
  13009. f = this.z,
  13010. g = this.w;
  13011. a = a.mat;
  13012. this.x = b * a[0] + e * a[4] + f * a[8] + g * a[12];
  13013. this.y = b * a[1] + e * a[5] + f * a[9] + g * a[13];
  13014. this.z = b * a[2] + e * a[6] + f * a[10] + g * a[14];
  13015. this.w = b * a[3] + e * a[7] + f * a[11] + g * a[15];
  13016. return this
  13017. };
  13018. a.math.Vec4.transformArray = function(b, d) {
  13019. for (var e = [], f = 0; f < b.length; f++) {
  13020. var g = new a.math.Vec4(b[f]);
  13021. g.transform(d);
  13022. e.push(g)
  13023. }
  13024. return e
  13025. };
  13026. b.equals = function(b) {
  13027. var d = a.math.EPSILON;
  13028. return this.x < b.x + d && this.x > b.x - d && this.y < b.y + d && this.y > b.y - d &&
  13029. this.z < b.z + d && this.z > b.z - d && this.w < b.w + d && this.w > b.w - d
  13030. };
  13031. b.assignFrom = function(a) {
  13032. this.x = a.x;
  13033. this.y = a.y;
  13034. this.z = a.z;
  13035. this.w = a.w;
  13036. return this
  13037. };
  13038. b.toTypeArray = function() {
  13039. var a = new Float32Array(4);
  13040. a[0] = this.x;
  13041. a[1] = this.y;
  13042. a[2] = this.z;
  13043. a[3] = this.w;
  13044. return a
  13045. }
  13046. })(cc);
  13047. (function(a) {
  13048. function b(b, d, e) {
  13049. d = new a.math.Vec2(d);
  13050. d.subtract(b);
  13051. e.x = -d.y;
  13052. e.y = d.x;
  13053. e.normalize()
  13054. }
  13055. a.math.Ray2 = function(b, d) {
  13056. this.start = b || new a.math.Vec2;
  13057. this.dir = d || new a.math.Vec2
  13058. };
  13059. a.math.Ray2.prototype.fill = function(a, b, e, f) {
  13060. this.start.x = a;
  13061. this.start.y = b;
  13062. this.dir.x = e;
  13063. this.dir.y = f
  13064. };
  13065. a.math.Ray2.prototype.intersectLineSegment = function(b, d, e) {
  13066. var f = this.start.x,
  13067. g = this.start.y,
  13068. h = this.start.x + this.dir.x,
  13069. k = this.start.y + this.dir.y,
  13070. m = b.x,
  13071. n = b.y,
  13072. p = d.x,
  13073. t = d.y,
  13074. r = (t - n) * (h - f) - (p - m) * (k - g);
  13075. if (r > -a.math.EPSILON &&
  13076. r < a.math.EPSILON) return !1;
  13077. n = ((p - m) * (g - n) - (t - n) * (f - m)) / r;
  13078. m = f + n * (h - f);
  13079. n = g + n * (k - g);
  13080. if (m < Math.min(b.x, d.x) - a.math.EPSILON || m > Math.max(b.x, d.x) + a.math.EPSILON || n < Math.min(b.y, d.y) - a.math.EPSILON || n > Math.max(b.y, d.y) + a.math.EPSILON || m < Math.min(f, h) - a.math.EPSILON || m > Math.max(f, h) + a.math.EPSILON || n < Math.min(g, k) - a.math.EPSILON || n > Math.max(g, k) + a.math.EPSILON) return !1;
  13081. e.x = m;
  13082. e.y = n;
  13083. return !0
  13084. };
  13085. a.math.Ray2.prototype.intersectTriangle = function(c, d, e, f, g) {
  13086. var h = new a.math.Vec2,
  13087. k = new a.math.Vec2,
  13088. m = new a.math.Vec2,
  13089. n = 1E4,
  13090. p = !1,
  13091. t;
  13092. this.intersectLineSegment(c, d, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, n = t, b(c, d, m)));
  13093. this.intersectLineSegment(d, e, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, n = t, b(d, e, m)));
  13094. this.intersectLineSegment(e, c, h) && (p = !0, t = h.subtract(this.start).length(), t < n && (k.x = h.x, k.y = h.y, b(e, c, m)));
  13095. p && (f.x = k.x, f.y = k.y, g && (g.x = m.x, g.y = m.y));
  13096. return p
  13097. }
  13098. })(cc);
  13099. var Float32Array = Float32Array || Array;
  13100. (function(a) {
  13101. a.math.Matrix3 = function(a) {
  13102. this.mat = a && a.mat ? new Float32Array(a.mat) : new Float32Array(9)
  13103. };
  13104. a.kmMat3 = a.math.Matrix3;
  13105. var b = a.math.Matrix3.prototype;
  13106. b.fill = function(a) {
  13107. var b = this.mat;
  13108. a = a.mat;
  13109. b[0] = a[0];
  13110. b[1] = a[1];
  13111. b[2] = a[2];
  13112. b[3] = a[3];
  13113. b[4] = a[4];
  13114. b[5] = a[5];
  13115. b[6] = a[6];
  13116. b[7] = a[7];
  13117. b[8] = a[8];
  13118. return this
  13119. };
  13120. b.adjugate = function() {
  13121. var a = this.mat,
  13122. b = a[0],
  13123. c = a[1],
  13124. g = a[2],
  13125. h = a[3],
  13126. k = a[4],
  13127. m = a[5],
  13128. n = a[6],
  13129. p = a[7],
  13130. t = a[8];
  13131. a[0] = k * t - m * p;
  13132. a[1] = g * p - c * t;
  13133. a[2] = c * m - g * k;
  13134. a[3] = m * n - h * t;
  13135. a[4] = b * t - g * n;
  13136. a[5] = g * h - b * m;
  13137. a[6] = h * p - k * n;
  13138. a[8] = b *
  13139. k - c * h;
  13140. return this
  13141. };
  13142. b.identity = function() {
  13143. var a = this.mat;
  13144. a[1] = a[2] = a[3] = a[5] = a[6] = a[7] = 0;
  13145. a[0] = a[4] = a[8] = 1;
  13146. return this
  13147. };
  13148. var c = new a.math.Matrix3;
  13149. b.inverse = function(a) {
  13150. if (0 === a) return this;
  13151. c.assignFrom(this);
  13152. a = 1 / a;
  13153. this.adjugate();
  13154. this.multiplyScalar(a);
  13155. return this
  13156. };
  13157. b.isIdentity = function() {
  13158. var a = this.mat;
  13159. return 1 === a[0] && 0 === a[1] && 0 === a[2] && 0 === a[3] && 1 === a[4] && 0 === a[5] && 0 === a[6] && 0 === a[7] && 1 === a[8]
  13160. };
  13161. b.transpose = function() {
  13162. var a = this.mat,
  13163. b = a[1],
  13164. c = a[2],
  13165. g = a[5],
  13166. h = a[6],
  13167. k = a[7];
  13168. a[1] = a[3];
  13169. a[2] = h;
  13170. a[3] = b;
  13171. a[5] =
  13172. k;
  13173. a[6] = c;
  13174. a[7] = g;
  13175. return this
  13176. };
  13177. b.determinant = function() {
  13178. var a = this.mat,
  13179. b = a[0] * a[4] * a[8] + a[1] * a[5] * a[6] + a[2] * a[3] * a[7];
  13180. return b -= a[2] * a[4] * a[6] + a[0] * a[5] * a[7] + a[1] * a[3] * a[8]
  13181. };
  13182. b.multiply = function(a) {
  13183. var b = this.mat,
  13184. c = a.mat;
  13185. a = b[0];
  13186. var g = b[1],
  13187. h = b[2],
  13188. k = b[3],
  13189. m = b[4],
  13190. n = b[5],
  13191. p = b[6],
  13192. t = b[7],
  13193. r = b[8],
  13194. u = c[0],
  13195. s = c[1],
  13196. v = c[2],
  13197. x = c[3],
  13198. D = c[4],
  13199. E = c[5],
  13200. A = c[6],
  13201. w = c[7],
  13202. c = c[8];
  13203. b[0] = a * u + k * s + p * v;
  13204. b[1] = g * u + m * s + t * v;
  13205. b[2] = h * u + n * s + r * v;
  13206. b[3] = h * u + n * s + r * v;
  13207. b[4] = g * x + m * D + t * E;
  13208. b[5] = h * x + n * D + r * E;
  13209. b[6] = a * A + k * w + p * c;
  13210. b[7] = g * A + m * w + t * c;
  13211. b[8] = h * A + n * w + r * c;
  13212. return this
  13213. };
  13214. b.multiplyScalar = function(a) {
  13215. var b = this.mat;
  13216. b[0] *= a;
  13217. b[1] *= a;
  13218. b[2] *= a;
  13219. b[3] *= a;
  13220. b[4] *= a;
  13221. b[5] *= a;
  13222. b[6] *= a;
  13223. b[7] *= a;
  13224. b[8] *= a;
  13225. return this
  13226. };
  13227. a.math.Matrix3.rotationAxisAngle = function(b, c) {
  13228. var f = Math.cos(c),
  13229. g = Math.sin(c),
  13230. h = new a.math.Matrix3,
  13231. k = h.mat;
  13232. k[0] = f + b.x * b.x * (1 - f);
  13233. k[1] = b.z * g + b.y * b.x * (1 - f);
  13234. k[2] = -b.y * g + b.z * b.x * (1 - f);
  13235. k[3] = -b.z * g + b.x * b.y * (1 - f);
  13236. k[4] = f + b.y * b.y * (1 - f);
  13237. k[5] = b.x * g + b.z * b.y * (1 - f);
  13238. k[6] = b.y * g + b.x * b.z * (1 - f);
  13239. k[7] = -b.x * g + b.y * b.z * (1 - f);
  13240. k[8] = f + b.z * b.z * (1 - f);
  13241. return h
  13242. };
  13243. b.assignFrom = function(b) {
  13244. if (this ===
  13245. b) return a.log("cc.math.Matrix3.assign(): current matrix equals matIn"), this;
  13246. var c = this.mat;
  13247. b = b.mat;
  13248. c[0] = b[0];
  13249. c[1] = b[1];
  13250. c[2] = b[2];
  13251. c[3] = b[3];
  13252. c[4] = b[4];
  13253. c[5] = b[5];
  13254. c[6] = b[6];
  13255. c[7] = b[7];
  13256. c[8] = b[8];
  13257. return this
  13258. };
  13259. b.equals = function(b) {
  13260. if (this === b) return !0;
  13261. var c = a.math.EPSILON,
  13262. f = this.mat;
  13263. b = b.mat;
  13264. for (var g = 0; 9 > g; ++g)
  13265. if (!(f[g] + c > b[g] && f[g] - c < b[g])) return !1;
  13266. return !0
  13267. };
  13268. a.math.Matrix3.createByRotationX = function(b) {
  13269. var c = new a.math.Matrix3,
  13270. f = c.mat;
  13271. f[0] = 1;
  13272. f[1] = 0;
  13273. f[2] = 0;
  13274. f[3] = 0;
  13275. f[4] = Math.cos(b);
  13276. f[5] = Math.sin(b);
  13277. f[6] = 0;
  13278. f[7] = -Math.sin(b);
  13279. f[8] = Math.cos(b);
  13280. return c
  13281. };
  13282. a.math.Matrix3.createByRotationY = function(b) {
  13283. var c = new a.math.Matrix3,
  13284. f = c.mat;
  13285. f[0] = Math.cos(b);
  13286. f[1] = 0;
  13287. f[2] = -Math.sin(b);
  13288. f[3] = 0;
  13289. f[4] = 1;
  13290. f[5] = 0;
  13291. f[6] = Math.sin(b);
  13292. f[7] = 0;
  13293. f[8] = Math.cos(b);
  13294. return c
  13295. };
  13296. a.math.Matrix3.createByRotationZ = function(b) {
  13297. var c = new a.math.Matrix3,
  13298. f = c.mat;
  13299. f[0] = Math.cos(b);
  13300. f[1] = -Math.sin(b);
  13301. f[2] = 0;
  13302. f[3] = Math.sin(b);
  13303. f[4] = Math.cos(b);
  13304. f[5] = 0;
  13305. f[6] = 0;
  13306. f[7] = 0;
  13307. f[8] = 1;
  13308. return c
  13309. };
  13310. a.math.Matrix3.createByRotation = function(b) {
  13311. var c = new a.math.Matrix3,
  13312. f = c.mat;
  13313. f[0] = Math.cos(b);
  13314. f[1] = Math.sin(b);
  13315. f[2] = 0;
  13316. f[3] = -Math.sin(b);
  13317. f[4] = Math.cos(b);
  13318. f[5] = 0;
  13319. f[6] = 0;
  13320. f[7] = 0;
  13321. f[8] = 1;
  13322. return c
  13323. };
  13324. a.math.Matrix3.createByScale = function(b, c) {
  13325. var f = new a.math.Matrix3;
  13326. f.identity();
  13327. f.mat[0] = b;
  13328. f.mat[4] = c;
  13329. return f
  13330. };
  13331. a.math.Matrix3.createByTranslation = function(b, c) {
  13332. var f = new a.math.Matrix3;
  13333. f.identity();
  13334. f.mat[6] = b;
  13335. f.mat[7] = c;
  13336. return f
  13337. };
  13338. a.math.Matrix3.createByQuaternion = function(b) {
  13339. if (!b) return null;
  13340. var c = new a.math.Matrix3,
  13341. f = c.mat;
  13342. f[0] = 1 - 2 * (b.y * b.y + b.z * b.z);
  13343. f[1] = 2 * (b.x * b.y - b.w * b.z);
  13344. f[2] = 2 *
  13345. (b.x * b.z + b.w * b.y);
  13346. f[3] = 2 * (b.x * b.y + b.w * b.z);
  13347. f[4] = 1 - 2 * (b.x * b.x + b.z * b.z);
  13348. f[5] = 2 * (b.y * b.z - b.w * b.x);
  13349. f[6] = 2 * (b.x * b.z - b.w * b.y);
  13350. f[7] = 2 * (b.y * b.z + b.w * b.x);
  13351. f[8] = 1 - 2 * (b.x * b.x + b.y * b.y);
  13352. return c
  13353. };
  13354. b.rotationToAxisAngle = function() {
  13355. return a.math.Quaternion.rotationMatrix(this).toAxisAndAngle()
  13356. }
  13357. })(cc);
  13358. (function(a) {
  13359. a.math.Matrix4 = function(a) {
  13360. this.mat = a && a.mat ? new Float32Array(a.mat) : new Float32Array(16)
  13361. };
  13362. a.kmMat4 = a.math.Matrix4;
  13363. var b = a.math.Matrix4.prototype;
  13364. b.fill = function(a) {
  13365. for (var b = this.mat, c = 0; 16 > c; c++) b[c] = a[c];
  13366. return this
  13367. };
  13368. a.kmMat4Identity = function(a) {
  13369. var b = a.mat;
  13370. b[1] = b[2] = b[3] = b[4] = b[6] = b[7] = b[8] = b[9] = b[11] = b[12] = b[13] = b[14] = 0;
  13371. b[0] = b[5] = b[10] = b[15] = 1;
  13372. return a
  13373. };
  13374. b.identity = function() {
  13375. var a = this.mat;
  13376. a[1] = a[2] = a[3] = a[4] = a[6] = a[7] = a[8] = a[9] = a[11] = a[12] = a[13] = a[14] = 0;
  13377. a[0] = a[5] = a[10] = a[15] = 1;
  13378. return this
  13379. };
  13380. b.get = function(a, b) {
  13381. return this.mat[a + 4 * b]
  13382. };
  13383. b.set = function(a, b, c) {
  13384. this.mat[a + 4 * b] = c
  13385. };
  13386. b.swap = function(a, b, c, d) {
  13387. var k = this.mat,
  13388. m = k[a + 4 * b];
  13389. k[a + 4 * b] = k[c + 4 * d];
  13390. k[c + 4 * d] = m
  13391. };
  13392. a.math.Matrix4._gaussj = function(a, b) {
  13393. var c, d = 0,
  13394. k = 0,
  13395. m, n, p, t, r = [0, 0, 0, 0],
  13396. u = [0, 0, 0, 0],
  13397. s = [0, 0, 0, 0];
  13398. for (c = 0; 4 > c; c++) {
  13399. for (m = t = 0; 4 > m; m++)
  13400. if (1 !== s[m])
  13401. for (n = 0; 4 > n; n++) 0 === s[n] && (p = Math.abs(a.get(m, n)), p >= t && (t = p, k = m, d = n));
  13402. ++s[d];
  13403. if (k !== d) {
  13404. for (m = 0; 4 > m; m++) a.swap(k, m, d, m);
  13405. for (m = 0; 4 > m; m++) b.swap(k, m, d, m)
  13406. }
  13407. u[c] = k;
  13408. r[c] = d;
  13409. if (0 === a.get(d,
  13410. d)) return !1;
  13411. n = 1 / a.get(d, d);
  13412. a.set(d, d, 1);
  13413. for (m = 0; 4 > m; m++) a.set(d, m, a.get(d, m) * n);
  13414. for (m = 0; 4 > m; m++) b.set(d, m, b.get(d, m) * n);
  13415. for (n = 0; 4 > n; n++)
  13416. if (n !== d) {
  13417. p = a.get(n, d);
  13418. a.set(n, d, 0);
  13419. for (m = 0; 4 > m; m++) a.set(n, m, a.get(n, m) - a.get(d, m) * p);
  13420. for (m = 0; 4 > m; m++) b.set(n, m, a.get(n, m) - b.get(d, m) * p)
  13421. }
  13422. }
  13423. for (m = 3; 0 <= m; m--)
  13424. if (u[m] !== r[m])
  13425. for (n = 0; 4 > n; n++) a.swap(n, u[m], n, r[m]);
  13426. return !0
  13427. };
  13428. var c = (new a.math.Matrix4).identity();
  13429. a.kmMat4Inverse = function(b, d) {
  13430. var g = new a.math.Matrix4(d);
  13431. if (!1 === a.math.Matrix4._gaussj(g, c)) return null;
  13432. b.assignFrom(g);
  13433. return b
  13434. };
  13435. b.inverse = function() {
  13436. var b = new a.math.Matrix4(this);
  13437. return !1 === a.math.Matrix4._gaussj(b, c) ? null : b
  13438. };
  13439. b.isIdentity = function() {
  13440. var a = this.mat;
  13441. return 1 === a[0] && 0 === a[1] && 0 === a[2] && 0 === a[3] && 0 === a[4] && 1 === a[5] && 0 === a[6] && 0 === a[7] && 0 === a[8] && 0 === a[9] && 1 === a[10] && 0 === a[11] && 0 === a[12] && 0 === a[13] && 0 === a[14] && 1 === a[15]
  13442. };
  13443. b.transpose = function() {
  13444. var a = this.mat,
  13445. b = a[1],
  13446. c = a[2],
  13447. d = a[3],
  13448. k = a[6],
  13449. m = a[7],
  13450. n = a[8],
  13451. p = a[9],
  13452. t = a[11],
  13453. r = a[12],
  13454. u = a[13],
  13455. s = a[14];
  13456. a[1] = a[4];
  13457. a[2] = n;
  13458. a[3] = r;
  13459. a[4] = b;
  13460. a[6] = p;
  13461. a[7] = u;
  13462. a[8] = c;
  13463. a[9] = k;
  13464. a[11] =
  13465. s;
  13466. a[12] = d;
  13467. a[13] = m;
  13468. a[14] = t;
  13469. return this
  13470. };
  13471. a.kmMat4Multiply = function(a, b, c) {
  13472. var d = a.mat,
  13473. k = b.mat,
  13474. m = c.mat;
  13475. c = k[0];
  13476. b = k[1];
  13477. var n = k[2],
  13478. p = k[3],
  13479. t = k[4],
  13480. r = k[5],
  13481. u = k[6],
  13482. s = k[7],
  13483. v = k[8],
  13484. x = k[9],
  13485. D = k[10],
  13486. E = k[11],
  13487. A = k[12],
  13488. w = k[13],
  13489. B = k[14],
  13490. k = k[15],
  13491. y = m[0],
  13492. z = m[1],
  13493. F = m[2],
  13494. J = m[3],
  13495. C = m[4],
  13496. N = m[5],
  13497. L = m[6],
  13498. P = m[7],
  13499. S = m[8],
  13500. I = m[9],
  13501. T = m[10],
  13502. K = m[11],
  13503. U = m[12],
  13504. V = m[13],
  13505. aa = m[14],
  13506. m = m[15];
  13507. d[0] = y * c + z * t + F * v + J * A;
  13508. d[1] = y * b + z * r + F * x + J * w;
  13509. d[2] = y * n + z * u + F * D + J * B;
  13510. d[3] = y * p + z * s + F * E + J * k;
  13511. d[4] = C * c + N * t + L * v + P * A;
  13512. d[5] = C * b + N * r + L * x + P * w;
  13513. d[6] = C * n + N * u + L * D + P * B;
  13514. d[7] = C * p + N * s +
  13515. L * E + P * k;
  13516. d[8] = S * c + I * t + T * v + K * A;
  13517. d[9] = S * b + I * r + T * x + K * w;
  13518. d[10] = S * n + I * u + T * D + K * B;
  13519. d[11] = S * p + I * s + T * E + K * k;
  13520. d[12] = U * c + V * t + aa * v + m * A;
  13521. d[13] = U * b + V * r + aa * x + m * w;
  13522. d[14] = U * n + V * u + aa * D + m * B;
  13523. d[15] = U * p + V * s + aa * E + m * k;
  13524. return a
  13525. };
  13526. b.multiply = function(a) {
  13527. var b = this.mat,
  13528. c = a.mat;
  13529. a = b[0];
  13530. var d = b[1],
  13531. k = b[2],
  13532. m = b[3],
  13533. n = b[4],
  13534. p = b[5],
  13535. t = b[6],
  13536. r = b[7],
  13537. u = b[8],
  13538. s = b[9],
  13539. v = b[10],
  13540. x = b[11],
  13541. D = b[12],
  13542. E = b[13],
  13543. A = b[14],
  13544. w = b[15],
  13545. B = c[0],
  13546. y = c[1],
  13547. z = c[2],
  13548. F = c[3],
  13549. J = c[4],
  13550. C = c[5],
  13551. N = c[6],
  13552. L = c[7],
  13553. P = c[8],
  13554. S = c[9],
  13555. I = c[10],
  13556. T = c[11],
  13557. K = c[12],
  13558. U = c[13],
  13559. V = c[14],
  13560. c = c[15];
  13561. b[0] = B * a + y * n + z * u + F *
  13562. D;
  13563. b[1] = B * d + y * p + z * s + F * E;
  13564. b[2] = B * k + y * t + z * v + F * A;
  13565. b[3] = B * m + y * r + z * x + F * w;
  13566. b[4] = J * a + C * n + N * u + L * D;
  13567. b[5] = J * d + C * p + N * s + L * E;
  13568. b[6] = J * k + C * t + N * v + L * A;
  13569. b[7] = J * m + C * r + N * x + L * w;
  13570. b[8] = P * a + S * n + I * u + T * D;
  13571. b[9] = P * d + S * p + I * s + T * E;
  13572. b[10] = P * k + S * t + I * v + T * A;
  13573. b[11] = P * m + S * r + I * x + T * w;
  13574. b[12] = K * a + U * n + V * u + c * D;
  13575. b[13] = K * d + U * p + V * s + c * E;
  13576. b[14] = K * k + U * t + V * v + c * A;
  13577. b[15] = K * m + U * r + V * x + c * w;
  13578. return this
  13579. };
  13580. a.getMat4MultiplyValue = function(a, b) {
  13581. var c = a.mat,
  13582. d = b.mat,
  13583. k = new Float32Array(16);
  13584. k[0] = c[0] * d[0] + c[4] * d[1] + c[8] * d[2] + c[12] * d[3];
  13585. k[1] = c[1] * d[0] + c[5] * d[1] + c[9] * d[2] + c[13] *
  13586. d[3];
  13587. k[2] = c[2] * d[0] + c[6] * d[1] + c[10] * d[2] + c[14] * d[3];
  13588. k[3] = c[3] * d[0] + c[7] * d[1] + c[11] * d[2] + c[15] * d[3];
  13589. k[4] = c[0] * d[4] + c[4] * d[5] + c[8] * d[6] + c[12] * d[7];
  13590. k[5] = c[1] * d[4] + c[5] * d[5] + c[9] * d[6] + c[13] * d[7];
  13591. k[6] = c[2] * d[4] + c[6] * d[5] + c[10] * d[6] + c[14] * d[7];
  13592. k[7] = c[3] * d[4] + c[7] * d[5] + c[11] * d[6] + c[15] * d[7];
  13593. k[8] = c[0] * d[8] + c[4] * d[9] + c[8] * d[10] + c[12] * d[11];
  13594. k[9] = c[1] * d[8] + c[5] * d[9] + c[9] * d[10] + c[13] * d[11];
  13595. k[10] = c[2] * d[8] + c[6] * d[9] + c[10] * d[10] + c[14] * d[11];
  13596. k[11] = c[3] * d[8] + c[7] * d[9] + c[11] * d[10] + c[15] * d[11];
  13597. k[12] = c[0] * d[12] + c[4] *
  13598. d[13] + c[8] * d[14] + c[12] * d[15];
  13599. k[13] = c[1] * d[12] + c[5] * d[13] + c[9] * d[14] + c[13] * d[15];
  13600. k[14] = c[2] * d[12] + c[6] * d[13] + c[10] * d[14] + c[14] * d[15];
  13601. k[15] = c[3] * d[12] + c[7] * d[13] + c[11] * d[14] + c[15] * d[15];
  13602. return k
  13603. };
  13604. a.kmMat4Assign = function(b, c) {
  13605. if (b === c) return a.log("cc.kmMat4Assign(): pOut equals pIn"), b;
  13606. var d = b.mat,
  13607. h = c.mat;
  13608. d[0] = h[0];
  13609. d[1] = h[1];
  13610. d[2] = h[2];
  13611. d[3] = h[3];
  13612. d[4] = h[4];
  13613. d[5] = h[5];
  13614. d[6] = h[6];
  13615. d[7] = h[7];
  13616. d[8] = h[8];
  13617. d[9] = h[9];
  13618. d[10] = h[10];
  13619. d[11] = h[11];
  13620. d[12] = h[12];
  13621. d[13] = h[13];
  13622. d[14] = h[14];
  13623. d[15] = h[15];
  13624. return b
  13625. };
  13626. b.assignFrom = function(b) {
  13627. if (this ===
  13628. b) return a.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"), this;
  13629. var c = this.mat;
  13630. b = b.mat;
  13631. c[0] = b[0];
  13632. c[1] = b[1];
  13633. c[2] = b[2];
  13634. c[3] = b[3];
  13635. c[4] = b[4];
  13636. c[5] = b[5];
  13637. c[6] = b[6];
  13638. c[7] = b[7];
  13639. c[8] = b[8];
  13640. c[9] = b[9];
  13641. c[10] = b[10];
  13642. c[11] = b[11];
  13643. c[12] = b[12];
  13644. c[13] = b[13];
  13645. c[14] = b[14];
  13646. c[15] = b[15];
  13647. return this
  13648. };
  13649. b.equals = function(b) {
  13650. if (this === b) return a.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."), !0;
  13651. var c = this.mat;
  13652. b = b.mat;
  13653. for (var d = a.math.EPSILON, h = 0; 16 > h; h++)
  13654. if (!(c[h] + d > b[h] && c[h] - d < b[h])) return !1;
  13655. return !0
  13656. };
  13657. a.math.Matrix4.createByRotationX = function(b, c) {
  13658. c = c || new a.math.Matrix4;
  13659. var d = c.mat;
  13660. d[0] = 1;
  13661. d[3] = d[2] = d[1] = 0;
  13662. d[4] = 0;
  13663. d[5] = Math.cos(b);
  13664. d[6] = Math.sin(b);
  13665. d[7] = 0;
  13666. d[8] = 0;
  13667. d[9] = -Math.sin(b);
  13668. d[10] = Math.cos(b);
  13669. d[11] = 0;
  13670. d[14] = d[13] = d[12] = 0;
  13671. d[15] = 1;
  13672. return c
  13673. };
  13674. a.math.Matrix4.createByRotationY = function(b, c) {
  13675. c = c || new a.math.Matrix4;
  13676. var d = c.mat;
  13677. d[0] = Math.cos(b);
  13678. d[1] = 0;
  13679. d[2] = -Math.sin(b);
  13680. d[3] = 0;
  13681. d[7] = d[6] = d[4] = 0;
  13682. d[5] = 1;
  13683. d[8] = Math.sin(b);
  13684. d[9] = 0;
  13685. d[10] = Math.cos(b);
  13686. d[11] = 0;
  13687. d[14] = d[13] = d[12] = 0;
  13688. d[15] = 1;
  13689. return c
  13690. };
  13691. a.math.Matrix4.createByRotationZ =
  13692. function(b, c) {
  13693. c = c || new a.math.Matrix4;
  13694. var d = c.mat;
  13695. d[0] = Math.cos(b);
  13696. d[1] = Math.sin(b);
  13697. d[3] = d[2] = 0;
  13698. d[4] = -Math.sin(b);
  13699. d[5] = Math.cos(b);
  13700. d[7] = d[6] = 0;
  13701. d[11] = d[9] = d[8] = 0;
  13702. d[10] = 1;
  13703. d[14] = d[13] = d[12] = 0;
  13704. d[15] = 1;
  13705. return c
  13706. };
  13707. a.math.Matrix4.createByPitchYawRoll = function(b, c, d, h) {
  13708. h = h || new a.math.Matrix4;
  13709. var k = Math.cos(b);
  13710. b = Math.sin(b);
  13711. var m = Math.cos(c);
  13712. c = Math.sin(c);
  13713. var n = Math.cos(d);
  13714. d = Math.sin(d);
  13715. var p = b * c,
  13716. t = k * c,
  13717. r = h.mat;
  13718. r[0] = m * n;
  13719. r[4] = m * d;
  13720. r[8] = -c;
  13721. r[1] = p * n - k * d;
  13722. r[5] = p * d + k * n;
  13723. r[9] = b * m;
  13724. r[2] = t * n + b * d;
  13725. r[6] = t * d - b * n;
  13726. r[10] = k * m;
  13727. r[3] = r[7] = r[11] = 0;
  13728. r[15] = 1;
  13729. return h
  13730. };
  13731. a.math.Matrix4.createByQuaternion = function(b, c) {
  13732. c = c || new a.math.Matrix4;
  13733. var d = c.mat;
  13734. d[0] = 1 - 2 * (b.y * b.y + b.z * b.z);
  13735. d[1] = 2 * (b.x * b.y + b.z * b.w);
  13736. d[2] = 2 * (b.x * b.z - b.y * b.w);
  13737. d[3] = 0;
  13738. d[4] = 2 * (b.x * b.y - b.z * b.w);
  13739. d[5] = 1 - 2 * (b.x * b.x + b.z * b.z);
  13740. d[6] = 2 * (b.z * b.y + b.x * b.w);
  13741. d[7] = 0;
  13742. d[8] = 2 * (b.x * b.z + b.y * b.w);
  13743. d[9] = 2 * (b.y * b.z - b.x * b.w);
  13744. d[10] = 1 - 2 * (b.x * b.x + b.y * b.y);
  13745. d[11] = 0;
  13746. d[14] = d[13] = d[12] = 0;
  13747. d[15] = 1;
  13748. return c
  13749. };
  13750. a.math.Matrix4.createByRotationTranslation = function(b, c, d) {
  13751. d = d || new a.math.Matrix4;
  13752. var h =
  13753. d.mat;
  13754. b = b.mat;
  13755. h[0] = b[0];
  13756. h[1] = b[1];
  13757. h[2] = b[2];
  13758. h[3] = 0;
  13759. h[4] = b[3];
  13760. h[5] = b[4];
  13761. h[6] = b[5];
  13762. h[7] = 0;
  13763. h[8] = b[6];
  13764. h[9] = b[7];
  13765. h[10] = b[8];
  13766. h[11] = 0;
  13767. h[12] = c.x;
  13768. h[13] = c.y;
  13769. h[14] = c.z;
  13770. h[15] = 1;
  13771. return d
  13772. };
  13773. a.math.Matrix4.createByScale = function(b, c, d, h) {
  13774. h = h || new a.math.Matrix4;
  13775. var k = h.mat;
  13776. k[0] = b;
  13777. k[5] = c;
  13778. k[10] = d;
  13779. k[15] = 1;
  13780. k[1] = k[2] = k[3] = k[4] = k[6] = k[7] = k[8] = k[9] = k[11] = k[12] = k[13] = k[14] = 0;
  13781. return h
  13782. };
  13783. a.kmMat4Translation = function(a, b, c, d) {
  13784. a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
  13785. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] =
  13786. a.mat[9] = a.mat[11] = 0;
  13787. a.mat[12] = b;
  13788. a.mat[13] = c;
  13789. a.mat[14] = d;
  13790. return a
  13791. };
  13792. a.math.Matrix4.createByTranslation = function(b, c, d, h) {
  13793. h = h || new a.math.Matrix4;
  13794. h.identity();
  13795. h.mat[12] = b;
  13796. h.mat[13] = c;
  13797. h.mat[14] = d;
  13798. return h
  13799. };
  13800. b.getUpVec3 = function() {
  13801. var b = this.mat;
  13802. return (new a.math.Vec3(b[4], b[5], b[6])).normalize()
  13803. };
  13804. b.getRightVec3 = function() {
  13805. var b = this.mat;
  13806. return (new a.math.Vec3(b[0], b[1], b[2])).normalize()
  13807. };
  13808. b.getForwardVec3 = function() {
  13809. var b = this.mat;
  13810. return (new a.math.Vec3(b[8], b[9], b[10])).normalize()
  13811. };
  13812. a.kmMat4PerspectiveProjection =
  13813. function(b, c, d, h, k) {
  13814. var m = a.degreesToRadians(c / 2);
  13815. c = k - h;
  13816. var n = Math.sin(m);
  13817. if (0 === c || 0 === n || 0 === d) return null;
  13818. m = Math.cos(m) / n;
  13819. b.identity();
  13820. b.mat[0] = m / d;
  13821. b.mat[5] = m;
  13822. b.mat[10] = -(k + h) / c;
  13823. b.mat[11] = -1;
  13824. b.mat[14] = -2 * h * k / c;
  13825. b.mat[15] = 0;
  13826. return b
  13827. };
  13828. a.math.Matrix4.createPerspectiveProjection = function(b, c, d, h) {
  13829. var k = a.degreesToRadians(b / 2);
  13830. b = h - d;
  13831. var m = Math.sin(k);
  13832. if (0 === b || 0 === m || 0 === c) return null;
  13833. var k = Math.cos(k) / m,
  13834. m = new a.math.Matrix4,
  13835. n = m.mat;
  13836. m.identity();
  13837. n[0] = k / c;
  13838. n[5] = k;
  13839. n[10] = -(h + d) / b;
  13840. n[11] = -1;
  13841. n[14] = -2 * d * h / b;
  13842. n[15] = 0;
  13843. return m
  13844. };
  13845. a.kmMat4OrthographicProjection = function(a, b, c, d, k, m, n) {
  13846. a.identity();
  13847. a.mat[0] = 2 / (c - b);
  13848. a.mat[5] = 2 / (k - d);
  13849. a.mat[10] = -2 / (n - m);
  13850. a.mat[12] = -((c + b) / (c - b));
  13851. a.mat[13] = -((k + d) / (k - d));
  13852. a.mat[14] = -((n + m) / (n - m));
  13853. return a
  13854. };
  13855. a.math.Matrix4.createOrthographicProjection = function(b, c, d, h, k, m) {
  13856. var n = new a.math.Matrix4,
  13857. p = n.mat;
  13858. n.identity();
  13859. p[0] = 2 / (c - b);
  13860. p[5] = 2 / (h - d);
  13861. p[10] = -2 / (m - k);
  13862. p[12] = -((c + b) / (c - b));
  13863. p[13] = -((h + d) / (h - d));
  13864. p[14] = -((m + k) / (m - k));
  13865. return n
  13866. };
  13867. a.kmMat4LookAt = function(b, c, d, h) {
  13868. d = new a.math.Vec3(d);
  13869. var k = new a.math.Vec3(h);
  13870. d.subtract(c);
  13871. d.normalize();
  13872. k.normalize();
  13873. h = new a.math.Vec3(d);
  13874. h.cross(k);
  13875. h.normalize();
  13876. k = new a.math.Vec3(h);
  13877. k.cross(d);
  13878. h.normalize();
  13879. b.identity();
  13880. b.mat[0] = h.x;
  13881. b.mat[4] = h.y;
  13882. b.mat[8] = h.z;
  13883. b.mat[1] = k.x;
  13884. b.mat[5] = k.y;
  13885. b.mat[9] = k.z;
  13886. b.mat[2] = -d.x;
  13887. b.mat[6] = -d.y;
  13888. b.mat[10] = -d.z;
  13889. c = a.math.Matrix4.createByTranslation(-c.x, -c.y, -c.z);
  13890. b.multiply(c);
  13891. return b
  13892. };
  13893. var d = new a.math.Matrix4;
  13894. b.lookAt = function(b, c, g) {
  13895. c = new a.math.Vec3(c);
  13896. var h = new a.math.Vec3(g);
  13897. g = this.mat;
  13898. c.subtract(b);
  13899. c.normalize();
  13900. h.normalize();
  13901. var k = new a.math.Vec3(c);
  13902. k.cross(h);
  13903. k.normalize();
  13904. h = new a.math.Vec3(k);
  13905. h.cross(c);
  13906. k.normalize();
  13907. this.identity();
  13908. g[0] = k.x;
  13909. g[4] = k.y;
  13910. g[8] = k.z;
  13911. g[1] = h.x;
  13912. g[5] = h.y;
  13913. g[9] = h.z;
  13914. g[2] = -c.x;
  13915. g[6] = -c.y;
  13916. g[10] = -c.z;
  13917. d = a.math.Matrix4.createByTranslation(-b.x, -b.y, -b.z, d);
  13918. this.multiply(d);
  13919. return this
  13920. };
  13921. a.kmMat4RotationAxisAngle = function(b, c, d) {
  13922. var h = Math.cos(d);
  13923. d = Math.sin(d);
  13924. c = new a.math.Vec3(c);
  13925. c.normalize();
  13926. b.mat[0] = h + c.x * c.x * (1 - h);
  13927. b.mat[1] = c.z * d + c.y * c.x * (1 - h);
  13928. b.mat[2] = -c.y * d + c.z * c.x * (1 - h);
  13929. b.mat[3] = 0;
  13930. b.mat[4] = -c.z * d + c.x * c.y * (1 - h);
  13931. b.mat[5] = h + c.y * c.y * (1 - h);
  13932. b.mat[6] = c.x * d + c.z * c.y * (1 - h);
  13933. b.mat[7] = 0;
  13934. b.mat[8] = c.y * d + c.x * c.z * (1 - h);
  13935. b.mat[9] = -c.x * d + c.y * c.z * (1 - h);
  13936. b.mat[10] = h + c.z * c.z * (1 - h);
  13937. b.mat[11] = 0;
  13938. b.mat[12] = 0;
  13939. b.mat[13] = 0;
  13940. b.mat[14] = 0;
  13941. b.mat[15] = 1;
  13942. return b
  13943. };
  13944. a.math.Matrix4.createByAxisAndAngle = function(b, c, d) {
  13945. d = d || new a.math.Matrix4;
  13946. var h = this.mat,
  13947. k = Math.cos(c);
  13948. c = Math.sin(c);
  13949. b = new a.math.Vec3(b);
  13950. b.normalize();
  13951. h[0] = k + b.x * b.x * (1 - k);
  13952. h[1] = b.z * c + b.y * b.x * (1 - k);
  13953. h[2] = -b.y * c + b.z * b.x * (1 - k);
  13954. h[3] = 0;
  13955. h[4] = -b.z * c + b.x * b.y * (1 - k);
  13956. h[5] =
  13957. k + b.y * b.y * (1 - k);
  13958. h[6] = b.x * c + b.z * b.y * (1 - k);
  13959. h[7] = 0;
  13960. h[8] = b.y * c + b.x * b.z * (1 - k);
  13961. h[9] = -b.x * c + b.y * b.z * (1 - k);
  13962. h[10] = k + b.z * b.z * (1 - k);
  13963. h[11] = 0;
  13964. h[12] = h[13] = h[14] = 0;
  13965. h[15] = 1;
  13966. return d
  13967. };
  13968. b.extractRotation = function() {
  13969. var b = new a.math.Matrix3,
  13970. c = this.mat,
  13971. d = b.mat;
  13972. d[0] = c[0];
  13973. d[1] = c[1];
  13974. d[2] = c[2];
  13975. d[3] = c[4];
  13976. d[4] = c[5];
  13977. d[5] = c[6];
  13978. d[6] = c[8];
  13979. d[7] = c[9];
  13980. d[8] = c[10];
  13981. return b
  13982. };
  13983. b.extractPlane = function(b) {
  13984. var c = new a.math.Plane,
  13985. d = this.mat;
  13986. switch (b) {
  13987. case a.math.Plane.RIGHT:
  13988. c.a = d[3] - d[0];
  13989. c.b = d[7] - d[4];
  13990. c.c = d[11] - d[8];
  13991. c.d = d[15] - d[12];
  13992. break;
  13993. case a.math.Plane.LEFT:
  13994. c.a = d[3] + d[0];
  13995. c.b = d[7] + d[4];
  13996. c.c = d[11] + d[8];
  13997. c.d = d[15] + d[12];
  13998. break;
  13999. case a.math.Plane.BOTTOM:
  14000. c.a = d[3] + d[1];
  14001. c.b = d[7] + d[5];
  14002. c.c = d[11] + d[9];
  14003. c.d = d[15] + d[13];
  14004. break;
  14005. case a.math.Plane.TOP:
  14006. c.a = d[3] - d[1];
  14007. c.b = d[7] - d[5];
  14008. c.c = d[11] - d[9];
  14009. c.d = d[15] - d[13];
  14010. break;
  14011. case a.math.Plane.FAR:
  14012. c.a = d[3] - d[2];
  14013. c.b = d[7] - d[6];
  14014. c.c = d[11] - d[10];
  14015. c.d = d[15] - d[14];
  14016. break;
  14017. case a.math.Plane.NEAR:
  14018. c.a = d[3] + d[2];
  14019. c.b = d[7] + d[6];
  14020. c.c = d[11] + d[10];
  14021. c.d = d[15] + d[14];
  14022. break;
  14023. default:
  14024. a.log("cc.math.Matrix4.extractPlane: Invalid plane index")
  14025. }
  14026. b =
  14027. Math.sqrt(c.a * c.a + c.b * c.b + c.c * c.c);
  14028. c.a /= b;
  14029. c.b /= b;
  14030. c.c /= b;
  14031. c.d /= b;
  14032. return c
  14033. };
  14034. b.toAxisAndAngle = function() {
  14035. var b = this.extractRotation();
  14036. return a.math.Quaternion.rotationMatrix(b).toAxisAndAngle()
  14037. }
  14038. })(cc);
  14039. (function(a) {
  14040. a.math.Plane = function(a, b, e, f) {
  14041. a && void 0 === b ? (this.a = a.a, this.b = a.b, this.c = a.c, this.d = a.d) : (this.a = a || 0, this.b = b || 0, this.c = e || 0, this.d = f || 0)
  14042. };
  14043. a.kmPlane = a.math.Plane;
  14044. var b = a.math.Plane.prototype;
  14045. a.math.Plane.LEFT = 0;
  14046. a.math.Plane.RIGHT = 1;
  14047. a.math.Plane.BOTTOM = 2;
  14048. a.math.Plane.TOP = 3;
  14049. a.math.Plane.NEAR = 4;
  14050. a.math.Plane.FAR = 5;
  14051. a.math.Plane.POINT_INFRONT_OF_PLANE = 0;
  14052. a.math.Plane.POINT_BEHIND_PLANE = 1;
  14053. a.math.Plane.POINT_ON_PLANE = 2;
  14054. b.dot = function(a) {
  14055. return this.a * a.x + this.b * a.y + this.c * a.z + this.d * a.w
  14056. };
  14057. b.dotCoord =
  14058. function(a) {
  14059. return this.a * a.x + this.b * a.y + this.c * a.z + this.d
  14060. };
  14061. b.dotNormal = function(a) {
  14062. return this.a * a.x + this.b * a.y + this.c * a.z
  14063. };
  14064. a.math.Plane.fromPointNormal = function(b, d) {
  14065. return new a.math.Plane(d.x, d.y, d.z, -d.dot(b))
  14066. };
  14067. a.math.Plane.fromPoints = function(b, d, e) {
  14068. d = new a.math.Vec3(d);
  14069. e = new a.math.Vec3(e);
  14070. var f = new a.math.Plane;
  14071. d.subtract(b);
  14072. e.subtract(b);
  14073. d.cross(e);
  14074. d.normalize();
  14075. f.a = d.x;
  14076. f.b = d.y;
  14077. f.c = d.z;
  14078. f.d = d.scale(-1).dot(b);
  14079. return f
  14080. };
  14081. b.normalize = function() {
  14082. var b = new a.math.Vec3(this.a, this.b, this.c),
  14083. d = 1 /
  14084. b.length();
  14085. b.normalize();
  14086. this.a = b.x;
  14087. this.b = b.y;
  14088. this.c = b.z;
  14089. this.d *= d;
  14090. return this
  14091. };
  14092. b.classifyPoint = function(b) {
  14093. b = this.a * b.x + this.b * b.y + this.c * b.z + this.d;
  14094. return 0.001 < b ? a.math.Plane.POINT_INFRONT_OF_PLANE : -0.001 > b ? a.math.Plane.POINT_BEHIND_PLANE : a.math.Plane.POINT_ON_PLANE
  14095. }
  14096. })(cc);
  14097. (function(a) {
  14098. a.math.Quaternion = function(a, b, e, f) {
  14099. a && void 0 === b ? (this.x = a.x, this.y = a.y, this.z = a.z, this.w = a.w) : (this.x = a || 0, this.y = b || 0, this.z = e || 0, this.w = f || 0)
  14100. };
  14101. a.kmQuaternion = a.math.Quaternion;
  14102. var b = a.math.Quaternion.prototype;
  14103. b.conjugate = function(a) {
  14104. this.x = -a.x;
  14105. this.y = -a.y;
  14106. this.z = -a.z;
  14107. this.w = a.w;
  14108. return this
  14109. };
  14110. b.dot = function(a) {
  14111. return this.w * a.w + this.x * a.x + this.y * a.y + this.z * a.z
  14112. };
  14113. b.exponential = function() {
  14114. return this
  14115. };
  14116. b.identity = function() {
  14117. this.z = this.y = this.x = 0;
  14118. this.w = 1;
  14119. return this
  14120. };
  14121. b.inverse = function() {
  14122. var b =
  14123. this.length();
  14124. if (Math.abs(b) > a.math.EPSILON) return this.w = this.z = this.y = this.x = 0, this;
  14125. this.conjugate(this).scale(1 / b);
  14126. return this
  14127. };
  14128. b.isIdentity = function() {
  14129. return 0 === this.x && 0 === this.y && 0 === this.z && 1 === this.w
  14130. };
  14131. b.length = function() {
  14132. return Math.sqrt(this.lengthSq())
  14133. };
  14134. b.lengthSq = function() {
  14135. return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
  14136. };
  14137. b.multiply = function(a) {
  14138. var b = this.x,
  14139. e = this.y,
  14140. f = this.z,
  14141. g = this.w;
  14142. this.w = g * a.w - b * a.x - e * a.y - f * a.z;
  14143. this.x = g * a.x + b * a.w + e * a.z - f * a.y;
  14144. this.y = g * a.y + e * a.w + f * a.x -
  14145. b * a.z;
  14146. this.z = g * a.z + f * a.w + b * a.y - e * a.x;
  14147. return this
  14148. };
  14149. b.normalize = function() {
  14150. var b = this.length();
  14151. if (Math.abs(b) <= a.math.EPSILON) throw "current quaternion is an invalid value";
  14152. this.scale(1 / b);
  14153. return this
  14154. };
  14155. b.rotationAxis = function(a, b) {
  14156. var e = 0.5 * b,
  14157. f = Math.sin(e);
  14158. this.w = Math.cos(e);
  14159. this.x = a.x * f;
  14160. this.y = a.y * f;
  14161. this.z = a.z * f;
  14162. return this
  14163. };
  14164. a.math.Quaternion.rotationMatrix = function(b) {
  14165. if (!b) return null;
  14166. var d, e, f;
  14167. d = [];
  14168. e = b.mat;
  14169. b = 0;
  14170. d[0] = e[0];
  14171. d[1] = e[3];
  14172. d[2] = e[6];
  14173. d[4] = e[1];
  14174. d[5] = e[4];
  14175. d[6] = e[7];
  14176. d[8] = e[2];
  14177. d[9] = e[5];
  14178. d[10] =
  14179. e[8];
  14180. d[15] = 1;
  14181. var g = d[0];
  14182. b = g[0] + g[5] + g[10] + 1;
  14183. b > a.math.EPSILON ? (b = 2 * Math.sqrt(b), d = (g[9] - g[6]) / b, e = (g[2] - g[8]) / b, f = (g[4] - g[1]) / b, b *= 0.25) : g[0] > g[5] && g[0] > g[10] ? (b = 2 * Math.sqrt(1 + g[0] - g[5] - g[10]), d = 0.25 * b, e = (g[4] + g[1]) / b, f = (g[2] + g[8]) / b, b = (g[9] - g[6]) / b) : g[5] > g[10] ? (b = 2 * Math.sqrt(1 + g[5] - g[0] - g[10]), d = (g[4] + g[1]) / b, e = 0.25 * b, f = (g[9] + g[6]) / b, b = (g[2] - g[8]) / b) : (b = 2 * Math.sqrt(1 + g[10] - g[0] - g[5]), d = (g[2] + g[8]) / b, e = (g[9] + g[6]) / b, f = 0.25 * b, b = (g[4] - g[1]) / b);
  14184. return new a.math.Quaternion(d, e, f, b)
  14185. };
  14186. a.math.Quaternion.rotationYawPitchRoll =
  14187. function(b, d, e) {
  14188. var f, g, h, k, m;
  14189. f = a.degreesToRadians(d) / 2;
  14190. g = a.degreesToRadians(b) / 2;
  14191. h = a.degreesToRadians(e) / 2;
  14192. e = Math.cos(f);
  14193. b = Math.cos(g);
  14194. d = Math.cos(h);
  14195. f = Math.sin(f);
  14196. g = Math.sin(g);
  14197. h = Math.sin(h);
  14198. k = b * d;
  14199. m = g * h;
  14200. var n = new a.math.Quaternion;
  14201. n.w = e * k + f * m;
  14202. n.x = f * k - e * m;
  14203. n.y = e * g * d + f * b * h;
  14204. n.z = e * b * h - f * g * d;
  14205. n.normalize();
  14206. return n
  14207. };
  14208. b.slerp = function(b, d) {
  14209. if (this.x === b.x && this.y === b.y && this.z === b.z && this.w === b.w) return this;
  14210. var e = this.dot(b),
  14211. f = Math.acos(e),
  14212. g = Math.sqrt(1 - a.math.square(e)),
  14213. e = Math.sin(d * f) / g,
  14214. f = Math.sin((1 -
  14215. d) * f) / g,
  14216. g = new a.math.Quaternion(b);
  14217. this.scale(f);
  14218. g.scale(e);
  14219. this.add(g);
  14220. return this
  14221. };
  14222. b.toAxisAndAngle = function() {
  14223. var b, d, e = new a.math.Vec3;
  14224. b = Math.acos(this.w);
  14225. d = Math.sqrt(a.math.square(this.x) + a.math.square(this.y) + a.math.square(this.z));
  14226. d > -a.math.EPSILON && d < a.math.EPSILON || d < 2 * Math.PI + a.math.EPSILON && d > 2 * Math.PI - a.math.EPSILON ? (b = 0, e.x = 0, e.y = 0, e.z = 1) : (b *= 2, e.x = this.x / d, e.y = this.y / d, e.z = this.z / d, e.normalize());
  14227. return {
  14228. axis: e,
  14229. angle: b
  14230. }
  14231. };
  14232. b.scale = function(a) {
  14233. this.x *= a;
  14234. this.y *= a;
  14235. this.z *= a;
  14236. this.w *= a;
  14237. return this
  14238. };
  14239. b.assignFrom = function(a) {
  14240. this.x = a.x;
  14241. this.y = a.y;
  14242. this.z = a.z;
  14243. this.w = a.w;
  14244. return this
  14245. };
  14246. b.add = function(a) {
  14247. this.x += a.x;
  14248. this.y += a.y;
  14249. this.z += a.z;
  14250. this.w += a.w;
  14251. return this
  14252. };
  14253. a.math.Quaternion.rotationBetweenVec3 = function(b, d, e) {
  14254. var f = new a.math.Vec3(b),
  14255. g = new a.math.Vec3(d);
  14256. f.normalize();
  14257. g.normalize();
  14258. var h = f.dot(g);
  14259. d = new a.math.Quaternion;
  14260. if (1 <= h) return d.identity(), d; - 0.999999 > h ? Math.abs(e.lengthSq()) < a.math.EPSILON ? d.rotationAxis(e, Math.PI) : (f = new a.math.Vec3(1, 0, 0), f.cross(b), Math.abs(f.lengthSq()) < a.math.EPSILON &&
  14261. (f.fill(0, 1, 0), f.cross(b)), f.normalize(), d.rotationAxis(f, Math.PI)) : (b = Math.sqrt(2 * (1 + h)), e = 1 / b, f.cross(g), d.x = f.x * e, d.y = f.y * e, d.z = f.z * e, d.w = 0.5 * b, d.normalize());
  14262. return d
  14263. };
  14264. b.multiplyVec3 = function(b) {
  14265. var d = this.x,
  14266. e = this.y,
  14267. f = this.z,
  14268. g = new a.math.Vec3(b),
  14269. h = new a.math.Vec3(d, e, f),
  14270. d = new a.math.Vec3(d, e, f);
  14271. h.cross(b);
  14272. d.cross(h);
  14273. h.scale(2 * q.w);
  14274. d.scale(2);
  14275. g.add(h);
  14276. g.add(d);
  14277. return g
  14278. }
  14279. })(cc);
  14280. cc.math.AABB = function(a, b) {
  14281. this.min = a || new cc.math.Vec3;
  14282. this.max = b || new cc.math.Vec3
  14283. };
  14284. cc.math.AABB.prototype.containsPoint = function(a) {
  14285. return a.x >= this.min.x && a.x <= this.max.x && a.y >= this.min.y && a.y <= this.max.y && a.z >= this.min.z && a.z <= this.max.z
  14286. };
  14287. cc.math.AABB.containsPoint = function(a, b) {
  14288. return a.x >= b.min.x && a.x <= b.max.x && a.y >= b.min.y && a.y <= b.max.y && a.z >= b.min.z && a.z <= b.max.z
  14289. };
  14290. cc.math.AABB.prototype.assignFrom = function(a) {
  14291. this.min.assignFrom(a.min);
  14292. this.max.assignFrom(a.max)
  14293. };
  14294. cc.math.AABB.assign = function(a, b) {
  14295. a.min.assignFrom(b.min);
  14296. a.max.assignFrom(b.max);
  14297. return a
  14298. };
  14299. (function(a) {
  14300. a.math.Matrix4Stack = function(a, b) {
  14301. this.top = a;
  14302. this.stack = b || []
  14303. };
  14304. a.km_mat4_stack = a.math.Matrix4Stack;
  14305. var b = a.math.Matrix4Stack.prototype;
  14306. b.initialize = function() {
  14307. this.stack.length = 0;
  14308. this.top = null
  14309. };
  14310. a.km_mat4_stack_push = function(b, d) {
  14311. b.stack.push(b.top);
  14312. b.top = new a.math.Matrix4(d)
  14313. };
  14314. a.km_mat4_stack_pop = function(a, b) {
  14315. a.top = a.stack.pop()
  14316. };
  14317. a.km_mat4_stack_release = function(a) {
  14318. a.stack = null;
  14319. a.top = null
  14320. };
  14321. b.push = function(b) {
  14322. b = b || this.top;
  14323. this.stack.push(this.top);
  14324. this.top = new a.math.Matrix4(b)
  14325. };
  14326. b.pop =
  14327. function() {
  14328. this.top = this.stack.pop()
  14329. };
  14330. b.release = function() {
  14331. this._matrixPool = this.top = this.stack = null
  14332. };
  14333. b._getFromPool = function(b) {
  14334. var d = this._matrixPool;
  14335. if (0 === d.length) return new a.math.Matrix4(b);
  14336. d = d.pop();
  14337. d.assignFrom(b);
  14338. return d
  14339. };
  14340. b._putInPool = function(a) {
  14341. this._matrixPool.push(a)
  14342. }
  14343. })(cc);
  14344. (function(a) {
  14345. a.KM_GL_MODELVIEW = 5888;
  14346. a.KM_GL_PROJECTION = 5889;
  14347. a.KM_GL_TEXTURE = 5890;
  14348. a.modelview_matrix_stack = new a.math.Matrix4Stack;
  14349. a.projection_matrix_stack = new a.math.Matrix4Stack;
  14350. a.texture_matrix_stack = new a.math.Matrix4Stack;
  14351. a.current_stack = null;
  14352. a.lazyInitialize = function() {
  14353. var b = new a.math.Matrix4;
  14354. a.modelview_matrix_stack.initialize();
  14355. a.projection_matrix_stack.initialize();
  14356. a.texture_matrix_stack.initialize();
  14357. a.current_stack = a.modelview_matrix_stack;
  14358. a.initialized = !0;
  14359. b.identity();
  14360. a.modelview_matrix_stack.push(b);
  14361. a.projection_matrix_stack.push(b);
  14362. a.texture_matrix_stack.push(b)
  14363. };
  14364. a.lazyInitialize();
  14365. a.kmGLFreeAll = function() {
  14366. a.modelview_matrix_stack.release();
  14367. a.modelview_matrix_stack = null;
  14368. a.projection_matrix_stack.release();
  14369. a.projection_matrix_stack = null;
  14370. a.texture_matrix_stack.release();
  14371. a.texture_matrix_stack = null;
  14372. a.initialized = !1;
  14373. a.current_stack = null
  14374. };
  14375. a.kmGLPushMatrix = function() {
  14376. a.current_stack.push(a.current_stack.top)
  14377. };
  14378. a.kmGLPushMatrixWitMat4 = function(b) {
  14379. a.current_stack.stack.push(a.current_stack.top);
  14380. b.assignFrom(a.current_stack.top);
  14381. a.current_stack.top = b
  14382. };
  14383. a.kmGLPopMatrix = function() {
  14384. a.current_stack.top = a.current_stack.stack.pop()
  14385. };
  14386. a.kmGLMatrixMode = function(b) {
  14387. switch (b) {
  14388. case a.KM_GL_MODELVIEW:
  14389. a.current_stack = a.modelview_matrix_stack;
  14390. break;
  14391. case a.KM_GL_PROJECTION:
  14392. a.current_stack = a.projection_matrix_stack;
  14393. break;
  14394. case a.KM_GL_TEXTURE:
  14395. a.current_stack = a.texture_matrix_stack;
  14396. break;
  14397. default:
  14398. throw "Invalid matrix mode specified";
  14399. }
  14400. };
  14401. a.kmGLLoadIdentity = function() {
  14402. a.current_stack.top.identity()
  14403. };
  14404. a.kmGLLoadMatrix = function(b) {
  14405. a.current_stack.top.assignFrom(b)
  14406. };
  14407. a.kmGLMultMatrix = function(b) {
  14408. a.current_stack.top.multiply(b)
  14409. };
  14410. var b = new a.math.Matrix4;
  14411. a.kmGLTranslatef = function(c, e, f) {
  14412. c = a.math.Matrix4.createByTranslation(c, e, f, b);
  14413. a.current_stack.top.multiply(c)
  14414. };
  14415. var c = new a.math.Vec3;
  14416. a.kmGLRotatef = function(d, e, f, g) {
  14417. c.fill(e, f, g);
  14418. d = a.math.Matrix4.createByAxisAndAngle(c, a.degreesToRadians(d), b);
  14419. a.current_stack.top.multiply(d)
  14420. };
  14421. a.kmGLScalef = function(c, e, f) {
  14422. c = a.math.Matrix4.createByScale(c, e, f, b);
  14423. a.current_stack.top.multiply(c)
  14424. };
  14425. a.kmGLGetMatrix = function(b, c) {
  14426. switch (b) {
  14427. case a.KM_GL_MODELVIEW:
  14428. c.assignFrom(a.modelview_matrix_stack.top);
  14429. break;
  14430. case a.KM_GL_PROJECTION:
  14431. c.assignFrom(a.projection_matrix_stack.top);
  14432. break;
  14433. case a.KM_GL_TEXTURE:
  14434. c.assignFrom(a.texture_matrix_stack.top);
  14435. break;
  14436. default:
  14437. throw "Invalid matrix mode specified";
  14438. }
  14439. }
  14440. })(cc);
  14441. cc.SHADER_POSITION_UCOLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n}\n";
  14442. 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}";
  14443. cc.SHADER_POSITION_COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n} ";
  14444. 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}";
  14445. 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}";
  14446. 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}";
  14447. cc.SHADER_POSITION_TEXTURE_FRAG = "precision lowp float; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord); \n}";
  14448. 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}";
  14449. cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG = "precision lowp float; \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord) * u_color; \n}";
  14450. 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}";
  14451. cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d vec4( v_fragmentColor.rgb, \n v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a \n ); \n}";
  14452. 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}";
  14453. cc.SHADER_POSITION_TEXTURE_COLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}";
  14454. 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}";
  14455. cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform float CC_alpha_value; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord); \n if ( texColor.a \x3c\x3d CC_alpha_value ) \n discard; \n gl_FragColor \x3d texColor * v_fragmentColor; \n}";
  14456. 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}";
  14457. cc.shaderCache = {
  14458. TYPE_POSITION_TEXTURECOLOR: 0,
  14459. TYPE_POSITION_TEXTURECOLOR_ALPHATEST: 1,
  14460. TYPE_POSITION_COLOR: 2,
  14461. TYPE_POSITION_TEXTURE: 3,
  14462. TYPE_POSITION_TEXTURE_UCOLOR: 4,
  14463. TYPE_POSITION_TEXTURE_A8COLOR: 5,
  14464. TYPE_POSITION_UCOLOR: 6,
  14465. TYPE_POSITION_LENGTH_TEXTURECOLOR: 7,
  14466. TYPE_MAX: 8,
  14467. _programs: {},
  14468. _init: function() {
  14469. this.loadDefaultShaders();
  14470. return !0
  14471. },
  14472. _loadDefaultShader: function(a, b) {
  14473. switch (b) {
  14474. case this.TYPE_POSITION_TEXTURECOLOR:
  14475. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_FRAG);
  14476. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14477. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  14478. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14479. break;
  14480. case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:
  14481. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG);
  14482. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14483. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  14484. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14485. break;
  14486. case this.TYPE_POSITION_COLOR:
  14487. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT, cc.SHADER_POSITION_COLOR_FRAG);
  14488. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14489. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  14490. break;
  14491. case this.TYPE_POSITION_TEXTURE:
  14492. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT, cc.SHADER_POSITION_TEXTURE_FRAG);
  14493. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,
  14494. cc.VERTEX_ATTRIB_POSITION);
  14495. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14496. break;
  14497. case this.TYPE_POSITION_TEXTURE_UCOLOR:
  14498. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT, cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG);
  14499. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14500. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14501. break;
  14502. case this.TYPE_POSITION_TEXTURE_A8COLOR:
  14503. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT,
  14504. cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG);
  14505. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14506. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  14507. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14508. break;
  14509. case this.TYPE_POSITION_UCOLOR:
  14510. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT, cc.SHADER_POSITION_UCOLOR_FRAG);
  14511. a.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION);
  14512. break;
  14513. case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:
  14514. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT,
  14515. cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG);
  14516. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  14517. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  14518. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  14519. break;
  14520. default:
  14521. cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type");
  14522. return
  14523. }
  14524. a.link();
  14525. a.updateUniforms()
  14526. },
  14527. loadDefaultShaders: function() {
  14528. var a = new cc.GLProgram;
  14529. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  14530. this._programs[cc.SHADER_POSITION_TEXTURECOLOR] =
  14531. a;
  14532. this._programs.ShaderPositionTextureColor = a;
  14533. a = new cc.GLProgram;
  14534. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  14535. this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST] = a;
  14536. this._programs.ShaderPositionTextureColorAlphaTest = a;
  14537. a = new cc.GLProgram;
  14538. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  14539. this._programs[cc.SHADER_POSITION_COLOR] = a;
  14540. this._programs.ShaderPositionColor = a;
  14541. a = new cc.GLProgram;
  14542. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  14543. this._programs[cc.SHADER_POSITION_TEXTURE] =
  14544. a;
  14545. this._programs.ShaderPositionTexture = a;
  14546. a = new cc.GLProgram;
  14547. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  14548. this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR] = a;
  14549. this._programs.ShaderPositionTextureUColor = a;
  14550. a = new cc.GLProgram;
  14551. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  14552. this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR] = a;
  14553. this._programs.ShaderPositionTextureA8Color = a;
  14554. a = new cc.GLProgram;
  14555. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR);
  14556. this._programs[cc.SHADER_POSITION_UCOLOR] =
  14557. a;
  14558. this._programs.ShaderPositionUColor = a;
  14559. a = new cc.GLProgram;
  14560. this._loadDefaultShader(a, this.TYPE_POSITION_LENGTH_TEXTURECOLOR);
  14561. this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR] = a;
  14562. this._programs.ShaderPositionLengthTextureColor = a
  14563. },
  14564. reloadDefaultShaders: function() {
  14565. var a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  14566. a.reset();
  14567. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  14568. a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
  14569. a.reset();
  14570. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  14571. a = this.programForKey(cc.SHADER_POSITION_COLOR);
  14572. a.reset();
  14573. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  14574. a = this.programForKey(cc.SHADER_POSITION_TEXTURE);
  14575. a.reset();
  14576. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  14577. a = this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  14578. a.reset();
  14579. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  14580. a = this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);
  14581. a.reset();
  14582. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  14583. a = this.programForKey(cc.SHADER_POSITION_UCOLOR);
  14584. a.reset();
  14585. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR)
  14586. },
  14587. programForKey: function(a) {
  14588. return this._programs[a]
  14589. },
  14590. getProgram: function(a) {
  14591. return this._programs[a]
  14592. },
  14593. addProgram: function(a, b) {
  14594. this._programs[b] = a
  14595. }
  14596. };
  14597. cc.HashUniformEntry = function(a, b, c) {
  14598. this.value = a;
  14599. this.location = b;
  14600. this.hh = c || {}
  14601. };
  14602. cc.GLProgram = cc.Class.extend({
  14603. _glContext: null,
  14604. _programObj: null,
  14605. _vertShader: null,
  14606. _fragShader: null,
  14607. _uniforms: null,
  14608. _hashForUniforms: null,
  14609. _usesTime: !1,
  14610. _updateUniformLocation: function(a, b, c) {
  14611. if (null == a) return !1;
  14612. c = !0;
  14613. for (var d = null, e = 0; e < this._hashForUniforms.length; e++) this._hashForUniforms[e].location == a && (d = this._hashForUniforms[e]);
  14614. d ? d.value == b ? c = !1 : d.value = b : (d = new cc.HashUniformEntry, d.location = a, d.value = b, this._hashForUniforms.push(d));
  14615. return c
  14616. },
  14617. _description: function() {
  14618. return "\x3cCCGLProgram \x3d " +
  14619. this.toString() + " | Program \x3d " + this._programObj.toString() + ", VertexShader \x3d " + this._vertShader.toString() + ", FragmentShader \x3d " + this._fragShader.toString() + "\x3e"
  14620. },
  14621. _compileShader: function(a, b, c) {
  14622. if (!c || !a) return !1;
  14623. c = (cc.GLProgram._isHighpSupported() ? "precision highp float;\n" : "precision mediump float;\n") + "uniform 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; \nuniform sampler2D CC_Texture0; \n//CC INCLUDES END \n" +
  14624. c;
  14625. this._glContext.shaderSource(a, c);
  14626. this._glContext.compileShader(a);
  14627. c = this._glContext.getShaderParameter(a, this._glContext.COMPILE_STATUS);
  14628. c || (cc.log("cocos2d: ERROR: Failed to compile shader:\n" + this._glContext.getShaderSource(a)), b === this._glContext.VERTEX_SHADER ? cc.log("cocos2d: \n" + this.vertexShaderLog()) : cc.log("cocos2d: \n" + this.fragmentShaderLog()));
  14629. return !0 === c
  14630. },
  14631. ctor: function(a, b, c) {
  14632. this._uniforms = [];
  14633. this._hashForUniforms = [];
  14634. this._glContext = c || cc._renderContext;
  14635. a && b && this.init(a, b)
  14636. },
  14637. destroyProgram: function() {
  14638. this._hashForUniforms =
  14639. this._uniforms = this._fragShader = this._vertShader = null;
  14640. this._glContext.deleteProgram(this._programObj)
  14641. },
  14642. initWithVertexShaderByteArray: function(a, b) {
  14643. var c = this._glContext;
  14644. this._programObj = c.createProgram();
  14645. this._fragShader = this._vertShader = null;
  14646. a && (this._vertShader = c.createShader(c.VERTEX_SHADER), this._compileShader(this._vertShader, c.VERTEX_SHADER, a) || cc.log("cocos2d: ERROR: Failed to compile vertex shader"));
  14647. b && (this._fragShader = c.createShader(c.FRAGMENT_SHADER), this._compileShader(this._fragShader,
  14648. c.FRAGMENT_SHADER, b) || cc.log("cocos2d: ERROR: Failed to compile fragment shader"));
  14649. this._vertShader && c.attachShader(this._programObj, this._vertShader);
  14650. cc.checkGLErrorDebug();
  14651. this._fragShader && c.attachShader(this._programObj, this._fragShader);
  14652. this._hashForUniforms.length = 0;
  14653. cc.checkGLErrorDebug();
  14654. return !0
  14655. },
  14656. initWithString: function(a, b) {
  14657. return this.initWithVertexShaderByteArray(a, b)
  14658. },
  14659. initWithVertexShaderFilename: function(a, b) {
  14660. var c = cc.loader.getRes(a);
  14661. if (!c) throw "Please load the resource firset : " + a;
  14662. var d = cc.loader.getRes(b);
  14663. if (!d) throw "Please load the resource firset : " + b;
  14664. return this.initWithVertexShaderByteArray(c, d)
  14665. },
  14666. init: function(a, b) {
  14667. return this.initWithVertexShaderFilename(a, b)
  14668. },
  14669. addAttribute: function(a, b) {
  14670. this._glContext.bindAttribLocation(this._programObj, b, a)
  14671. },
  14672. link: function() {
  14673. if (!this._programObj) return cc.log("cc.GLProgram.link(): Cannot link invalid program"), !1;
  14674. this._glContext.linkProgram(this._programObj);
  14675. this._vertShader && this._glContext.deleteShader(this._vertShader);
  14676. this._fragShader &&
  14677. this._glContext.deleteShader(this._fragShader);
  14678. this._fragShader = this._vertShader = null;
  14679. 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
  14680. },
  14681. use: function() {
  14682. cc.glUseProgram(this._programObj)
  14683. },
  14684. updateUniforms: function() {
  14685. this._uniforms[cc.UNIFORM_PMATRIX] =
  14686. this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S);
  14687. this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S);
  14688. this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S);
  14689. this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S);
  14690. this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S);
  14691. this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S);
  14692. this._usesTime = null != this._uniforms[cc.UNIFORM_TIME] || null != this._uniforms[cc.UNIFORM_SINTIME] || null != this._uniforms[cc.UNIFORM_COSTIME];
  14693. this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S);
  14694. this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S);
  14695. this.use();
  14696. this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER],
  14697. 0)
  14698. },
  14699. getUniformLocationForName: function(a) {
  14700. if (!a) throw "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null";
  14701. if (!this._programObj) throw "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized";
  14702. return this._glContext.getUniformLocation(this._programObj, a)
  14703. },
  14704. getUniformMVPMatrix: function() {
  14705. return this._uniforms[cc.UNIFORM_MVPMATRIX]
  14706. },
  14707. getUniformSampler: function() {
  14708. return this._uniforms[cc.UNIFORM_SAMPLER]
  14709. },
  14710. setUniformLocationWith1i: function(a,
  14711. b) {
  14712. this._updateUniformLocation(a, b) && this._glContext.uniform1i(a, b)
  14713. },
  14714. setUniformLocationWith2i: function(a, b, c) {
  14715. this._updateUniformLocation(a, [b, c]) && this._glContext.uniform2i(a, b, c)
  14716. },
  14717. setUniformLocationWith3i: function(a, b, c, d) {
  14718. this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3i(a, b, c, d)
  14719. },
  14720. setUniformLocationWith4i: function(a, b, c, d, e) {
  14721. this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4i(a, b, c, d, e)
  14722. },
  14723. setUniformLocationWith2iv: function(a, b, c) {
  14724. this._updateUniformLocation(a, b) &&
  14725. this._glContext.uniform2iv(a, b)
  14726. },
  14727. setUniformLocationWith3iv: function(a, b, c) {
  14728. this._updateUniformLocation(a, b) && this._glContext.uniform3iv(a, b)
  14729. },
  14730. setUniformLocationWith4iv: function(a, b, c) {
  14731. this._updateUniformLocation(a, b) && this._glContext.uniform4iv(a, b)
  14732. },
  14733. setUniformLocationI32: function(a, b) {
  14734. this.setUniformLocationWith1i(a, b)
  14735. },
  14736. setUniformLocationWith1f: function(a, b) {
  14737. this._updateUniformLocation(a, b) && this._glContext.uniform1f(a, b)
  14738. },
  14739. setUniformLocationWith2f: function(a, b, c) {
  14740. this._updateUniformLocation(a, [b,
  14741. c
  14742. ]) && this._glContext.uniform2f(a, b, c)
  14743. },
  14744. setUniformLocationWith3f: function(a, b, c, d) {
  14745. this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3f(a, b, c, d)
  14746. },
  14747. setUniformLocationWith4f: function(a, b, c, d, e) {
  14748. this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4f(a, b, c, d, e)
  14749. },
  14750. setUniformLocationWith2fv: function(a, b, c) {
  14751. this._updateUniformLocation(a, b) && this._glContext.uniform2fv(a, b)
  14752. },
  14753. setUniformLocationWith3fv: function(a, b, c) {
  14754. this._updateUniformLocation(a, b) && this._glContext.uniform3fv(a, b)
  14755. },
  14756. setUniformLocationWith4fv: function(a, b, c) {
  14757. this._updateUniformLocation(a, b) && this._glContext.uniform4fv(a, b)
  14758. },
  14759. setUniformLocationWithMatrix4fv: function(a, b, c) {
  14760. this._updateUniformLocation(a, b) && this._glContext.uniformMatrix4fv(a, !1, b)
  14761. },
  14762. setUniformLocationF32: function() {
  14763. if (!(2 > arguments.length)) switch (arguments.length) {
  14764. case 2:
  14765. this.setUniformLocationWith1f(arguments[0], arguments[1]);
  14766. break;
  14767. case 3:
  14768. this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]);
  14769. break;
  14770. case 4:
  14771. this.setUniformLocationWith3f(arguments[0],
  14772. arguments[1], arguments[2], arguments[3]);
  14773. break;
  14774. case 5:
  14775. this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
  14776. }
  14777. },
  14778. setUniformsForBuiltins: function() {
  14779. var a = new cc.math.Matrix4,
  14780. b = new cc.math.Matrix4,
  14781. c = new cc.math.Matrix4;
  14782. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a);
  14783. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, b);
  14784. cc.kmMat4Multiply(c, a, b);
  14785. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], a.mat, 1);
  14786. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],
  14787. b.mat, 1);
  14788. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], c.mat, 1);
  14789. 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],
  14790. Math.random(), Math.random(), Math.random(), Math.random())
  14791. },
  14792. _setUniformsForBuiltinsForRenderer: function(a) {
  14793. if (a && a._renderCmd) {
  14794. var b = new cc.math.Matrix4,
  14795. c = new cc.math.Matrix4;
  14796. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, b);
  14797. cc.kmMat4Multiply(c, b, a._renderCmd._stackMatrix);
  14798. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], b.mat, 1);
  14799. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], a._renderCmd._stackMatrix.mat, 1);
  14800. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],
  14801. c.mat, 1);
  14802. 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())
  14803. }
  14804. },
  14805. setUniformForModelViewProjectionMatrix: function() {
  14806. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top))
  14807. },
  14808. setUniformForModelViewProjectionMatrixWithMat4: function(a) {
  14809. cc.kmMat4Multiply(a, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top);
  14810. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, a.mat)
  14811. },
  14812. setUniformForModelViewAndProjectionMatrixWithMat4: function() {
  14813. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, cc.modelview_matrix_stack.top.mat);
  14814. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat)
  14815. },
  14816. _setUniformForMVPMatrixWithMat4: function(a) {
  14817. if (!a) throw "modelView matrix is undefined.";
  14818. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, a.mat);
  14819. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat)
  14820. },
  14821. vertexShaderLog: function() {
  14822. return this._glContext.getShaderInfoLog(this._vertShader)
  14823. },
  14824. getVertexShaderLog: function() {
  14825. return this._glContext.getShaderInfoLog(this._vertShader)
  14826. },
  14827. getFragmentShaderLog: function() {
  14828. return this._glContext.getShaderInfoLog(this._vertShader)
  14829. },
  14830. fragmentShaderLog: function() {
  14831. return this._glContext.getShaderInfoLog(this._fragShader)
  14832. },
  14833. programLog: function() {
  14834. return this._glContext.getProgramInfoLog(this._programObj)
  14835. },
  14836. getProgramLog: function() {
  14837. return this._glContext.getProgramInfoLog(this._programObj)
  14838. },
  14839. reset: function() {
  14840. this._fragShader = this._vertShader = null;
  14841. this._uniforms.length =
  14842. 0;
  14843. this._glContext.deleteProgram(this._programObj);
  14844. this._programObj = null;
  14845. for (var a = 0; a < this._hashForUniforms.length; a++) this._hashForUniforms[a].value = null, this._hashForUniforms[a] = null;
  14846. this._hashForUniforms.length = 0
  14847. },
  14848. getProgram: function() {
  14849. return this._programObj
  14850. },
  14851. retain: function() {},
  14852. release: function() {}
  14853. });
  14854. cc.GLProgram.create = function(a, b) {
  14855. return new cc.GLProgram(a, b)
  14856. };
  14857. cc.GLProgram._highpSupported = null;
  14858. cc.GLProgram._isHighpSupported = function() {
  14859. if (null == cc.GLProgram._highpSupported) {
  14860. var a = cc._renderContext,
  14861. a = a.getShaderPrecisionFormat(a.FRAGMENT_SHADER, a.HIGH_FLOAT);
  14862. cc.GLProgram._highpSupported = 0 !== a.precision
  14863. }
  14864. return cc.GLProgram._highpSupported
  14865. };
  14866. cc.setProgram = function(a, b) {
  14867. a.shaderProgram = b;
  14868. var c = a.children;
  14869. if (c)
  14870. for (var d = 0; d < c.length; d++) cc.setProgram(c[d], b)
  14871. };
  14872. cc._currentProjectionMatrix = -1;
  14873. cc._vertexAttribPosition = !1;
  14874. cc._vertexAttribColor = !1;
  14875. cc._vertexAttribTexCoords = !1;
  14876. 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));
  14877. cc.glInvalidateStateCache = function() {
  14878. cc.kmGLFreeAll();
  14879. cc._currentProjectionMatrix = -1;
  14880. cc._vertexAttribPosition = !1;
  14881. cc._vertexAttribColor = !1;
  14882. cc._vertexAttribTexCoords = !1;
  14883. if (cc.ENABLE_GL_STATE_CACHE) {
  14884. cc._currentShaderProgram = -1;
  14885. for (var a = 0; a < cc.MAX_ACTIVETEXTURE; a++) cc._currentBoundTexture[a] = -1;
  14886. cc._blendingSource = -1;
  14887. cc._blendingDest = -1;
  14888. cc._GLServerState = 0
  14889. }
  14890. };
  14891. cc.glUseProgram = function(a) {
  14892. a !== cc._currentShaderProgram && (cc._currentShaderProgram = a, cc._renderContext.useProgram(a))
  14893. };
  14894. cc.ENABLE_GL_STATE_CACHE || (cc.glUseProgram = function(a) {
  14895. cc._renderContext.useProgram(a)
  14896. });
  14897. cc.glDeleteProgram = function(a) {
  14898. cc.ENABLE_GL_STATE_CACHE && a === cc._currentShaderProgram && (cc._currentShaderProgram = -1);
  14899. gl.deleteProgram(a)
  14900. };
  14901. cc.glBlendFunc = function(a, b) {
  14902. if (a !== cc._blendingSource || b !== cc._blendingDest) cc._blendingSource = a, cc._blendingDest = b, cc.setBlending(a, b)
  14903. };
  14904. cc.setBlending = function(a, b) {
  14905. var c = cc._renderContext;
  14906. a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), cc._renderContext.blendFunc(a, b))
  14907. };
  14908. cc.glBlendFuncForParticle = function(a, b) {
  14909. if (a !== cc._blendingSource || b !== cc._blendingDest) {
  14910. cc._blendingSource = a;
  14911. cc._blendingDest = b;
  14912. var c = cc._renderContext;
  14913. a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), c.blendFuncSeparate(c.SRC_ALPHA, b, a, b))
  14914. }
  14915. };
  14916. cc.ENABLE_GL_STATE_CACHE || (cc.glBlendFunc = cc.setBlending);
  14917. cc.glBlendResetToCache = function() {
  14918. var a = cc._renderContext;
  14919. a.blendEquation(a.FUNC_ADD);
  14920. cc.ENABLE_GL_STATE_CACHE ? cc.setBlending(cc._blendingSource, cc._blendingDest) : cc.setBlending(a.BLEND_SRC, a.BLEND_DST)
  14921. };
  14922. cc.setProjectionMatrixDirty = function() {
  14923. cc._currentProjectionMatrix = -1
  14924. };
  14925. cc.glEnableVertexAttribs = function(a) {
  14926. var b = cc._renderContext,
  14927. c = a & cc.VERTEX_ATTRIB_FLAG_POSITION;
  14928. c !== cc._vertexAttribPosition && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION), cc._vertexAttribPosition = c);
  14929. c = a & cc.VERTEX_ATTRIB_FLAG_COLOR;
  14930. c !== cc._vertexAttribColor && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR), cc._vertexAttribColor = c);
  14931. a &= cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  14932. a !== cc._vertexAttribTexCoords &&
  14933. (a ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS), cc._vertexAttribTexCoords = a)
  14934. };
  14935. cc.glBindTexture2D = function(a) {
  14936. cc.glBindTexture2DN(0, a)
  14937. };
  14938. cc.glBindTexture2DN = function(a, b) {
  14939. if (cc._currentBoundTexture[a] !== b) {
  14940. cc._currentBoundTexture[a] = b;
  14941. var c = cc._renderContext;
  14942. c.activeTexture(c.TEXTURE0 + a);
  14943. b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null)
  14944. }
  14945. };
  14946. cc.ENABLE_GL_STATE_CACHE || (cc.glBindTexture2DN = function(a, b) {
  14947. var c = cc._renderContext;
  14948. c.activeTexture(c.TEXTURE0 + a);
  14949. b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null)
  14950. });
  14951. cc.glDeleteTexture = function(a) {
  14952. cc.glDeleteTextureN(0, a)
  14953. };
  14954. cc.glDeleteTextureN = function(a, b) {
  14955. cc.ENABLE_GL_STATE_CACHE && b === cc._currentBoundTexture[a] && (cc._currentBoundTexture[a] = -1);
  14956. cc._renderContext.deleteTexture(b)
  14957. };
  14958. cc.glBindVAO = function(a) {
  14959. cc.TEXTURE_ATLAS_USE_VAO && cc.ENABLE_GL_STATE_CACHE && cc._uVAO !== a && (cc._uVAO = a)
  14960. };
  14961. cc.glEnable = function(a) {};
  14962. cc.IMAGE_FORMAT_JPEG = 0;
  14963. cc.IMAGE_FORMAT_PNG = 1;
  14964. cc.IMAGE_FORMAT_RAWDATA = 9;
  14965. cc.NextPOT = function(a) {
  14966. a -= 1;
  14967. a |= a >> 1;
  14968. a |= a >> 2;
  14969. a |= a >> 4;
  14970. a |= a >> 8;
  14971. return (a | a >> 16) + 1
  14972. };
  14973. cc.RenderTexture = cc.Node.extend({
  14974. sprite: null,
  14975. clearFlags: 0,
  14976. clearDepthVal: 0,
  14977. autoDraw: !1,
  14978. _texture: null,
  14979. _pixelFormat: cc.Texture2D.PIXEL_FORMAT_RGBA8888,
  14980. clearStencilVal: 0,
  14981. _clearColor: null,
  14982. _className: "RenderTexture",
  14983. ctor: function(a, b, c, d) {
  14984. cc.Node.prototype.ctor.call(this);
  14985. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !0;
  14986. this._clearColor = new cc.Color(0, 0, 0, 255);
  14987. void 0 !== a && void 0 !== b && (c = c || cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.initWithWidthAndHeight(a, b, c, d || 0));
  14988. this.setAnchorPoint(0, 0)
  14989. },
  14990. _createRenderCmd: function() {
  14991. return cc._renderType ===
  14992. cc._RENDER_TYPE_CANVAS ? new cc.RenderTexture.CanvasRenderCmd(this) : new cc.RenderTexture.WebGLRenderCmd(this)
  14993. },
  14994. cleanup: function() {
  14995. cc.Node.prototype.onExit.call(this);
  14996. this._renderCmd.cleanup()
  14997. },
  14998. getSprite: function() {
  14999. return this.sprite
  15000. },
  15001. setSprite: function(a) {
  15002. this.sprite = a
  15003. },
  15004. setVirtualViewport: function(a, b, c) {
  15005. this._renderCmd.setVirtualViewport(a, b, c)
  15006. },
  15007. initWithWidthAndHeight: function(a, b, c, d) {
  15008. return this._renderCmd.initWithWidthAndHeight(a, b, c, d)
  15009. },
  15010. begin: function() {
  15011. cc.renderer._turnToCacheMode(this.__instanceId);
  15012. this._renderCmd.begin()
  15013. },
  15014. beginWithClear: function(a, b, c, d, e, f) {
  15015. var g = cc._renderContext;
  15016. e = e || g.COLOR_BUFFER_BIT;
  15017. f = f || g.COLOR_BUFFER_BIT | g.DEPTH_BUFFER_BIT;
  15018. this._beginWithClear(a, b, c, d, e, f, g.COLOR_BUFFER_BIT | g.DEPTH_BUFFER_BIT | g.STENCIL_BUFFER_BIT)
  15019. },
  15020. _beginWithClear: function(a, b, c, d, e, f, g) {
  15021. this.begin();
  15022. this._renderCmd._beginWithClear(a, b, c, d, e, f, g)
  15023. },
  15024. end: function() {
  15025. this._renderCmd.end()
  15026. },
  15027. clear: function(a, b, c, d) {
  15028. this.beginWithClear(a, b, c, d);
  15029. this.end()
  15030. },
  15031. clearRect: function(a, b, c, d) {
  15032. this._renderCmd.clearRect(a,
  15033. b, c, d)
  15034. },
  15035. clearDepth: function(a) {
  15036. this._renderCmd.clearDepth(a)
  15037. },
  15038. clearStencil: function(a) {
  15039. this._renderCmd.clearStencil(a)
  15040. },
  15041. getClearFlags: function() {
  15042. return this.clearFlags
  15043. },
  15044. setClearFlags: function(a) {
  15045. this.clearFlags = a
  15046. },
  15047. getClearColor: function() {
  15048. return this._clearColor
  15049. },
  15050. setClearColor: function(a) {
  15051. var b = this._clearColor;
  15052. b.r = a.r;
  15053. b.g = a.g;
  15054. b.b = a.b;
  15055. b.a = a.a;
  15056. this._renderCmd.updateClearColor(a)
  15057. },
  15058. getClearDepth: function() {
  15059. return this.clearDepthVal
  15060. },
  15061. setClearDepth: function(a) {
  15062. this.clearDepthVal = a
  15063. },
  15064. getClearStencil: function() {
  15065. return this.clearStencilVal
  15066. },
  15067. setClearStencil: function(a) {
  15068. this.clearStencilVal = a
  15069. },
  15070. isAutoDraw: function() {
  15071. return this.autoDraw
  15072. },
  15073. setAutoDraw: function(a) {
  15074. this.autoDraw = a
  15075. },
  15076. saveToFile: function(a, b) {
  15077. cc.log("saveToFile isn't supported on Cocos2d-Html5")
  15078. },
  15079. newCCImage: function(a) {
  15080. cc.log("saveToFile isn't supported on cocos2d-html5");
  15081. return null
  15082. },
  15083. listenToBackground: function(a) {},
  15084. listenToForeground: function(a) {}
  15085. });
  15086. _p = cc.RenderTexture.prototype;
  15087. cc.defineGetterSetter(_p, "clearColorVal", _p.getClearColor, _p.setClearColor);
  15088. cc.RenderTexture.create = function(a, b, c, d) {
  15089. return new cc.RenderTexture(a, b, c, d)
  15090. };
  15091. (function() {
  15092. cc.RenderTexture.CanvasRenderCmd = function(a) {
  15093. cc.Node.CanvasRenderCmd.call(this, a);
  15094. this._needDraw = !0;
  15095. this._clearColorStr = "rgba(255,255,255,1)";
  15096. this._cacheCanvas = cc.newElement("canvas");
  15097. this._cacheContext = new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"))
  15098. };
  15099. var a = cc.RenderTexture.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  15100. a.constructor = cc.RenderTexture.CanvasRenderCmd;
  15101. a.cleanup = function() {
  15102. this._cacheCanvas = this._cacheContext = null
  15103. };
  15104. a.clearStencil =
  15105. function(a) {};
  15106. a.setVirtualViewport = function(a, c, d) {};
  15107. a.updateClearColor = function(a) {
  15108. this._clearColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + "," + a.a / 255 + ")"
  15109. };
  15110. a.initWithWidthAndHeight = function(a, c, d, e) {
  15111. d = this._node;
  15112. e = this._cacheCanvas;
  15113. var f = cc.contentScaleFactor();
  15114. e.width = 0 | a * f;
  15115. e.height = 0 | c * f;
  15116. a = new cc.Texture2D;
  15117. a.initWithElement(e);
  15118. a.handleLoadedTexture();
  15119. a = d.sprite = new cc.Sprite(a);
  15120. a.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA);
  15121. d.autoDraw = !1;
  15122. d.addChild(a);
  15123. return !0
  15124. };
  15125. a.begin = function() {};
  15126. a._beginWithClear =
  15127. function(a, c, d, e, f, g, h) {
  15128. a = a || 0;
  15129. c = c || 0;
  15130. d = d || 0;
  15131. e = isNaN(e) ? 255 : e;
  15132. f = this._cacheContext.getContext();
  15133. g = this._cacheCanvas;
  15134. f.setTransform(1, 0, 0, 1, 0, 0);
  15135. this._cacheContext.setFillStyle("rgba(" + (0 | a) + "," + (0 | c) + "," + (0 | d) + "," + e / 255 + ")");
  15136. f.clearRect(0, 0, g.width, g.height);
  15137. f.fillRect(0, 0, g.width, g.height)
  15138. };
  15139. a.end = function() {
  15140. var a = this._node,
  15141. c = cc.contentScaleFactor();
  15142. cc.renderer._renderingToCacheCanvas(this._cacheContext, a.__instanceId, c, c)
  15143. };
  15144. a.clearRect = function(a, c, d, e) {
  15145. this._cacheContext.clearRect(a, c, d, -e)
  15146. };
  15147. a.clearDepth =
  15148. function(a) {
  15149. cc.log("clearDepth isn't supported on Cocos2d-Html5")
  15150. };
  15151. a.visit = function(a) {
  15152. var c = this._node;
  15153. this._syncStatus(a);
  15154. c.sprite.visit(this);
  15155. this._dirtyFlag = 0
  15156. }
  15157. })();
  15158. (function() {
  15159. cc.RenderTexture.WebGLRenderCmd = function(a) {
  15160. cc.Node.WebGLRenderCmd.call(this, a);
  15161. this._needDraw = !0;
  15162. this._depthRenderBuffer = this._textureCopy = this._oldFBO = this._fBO = null;
  15163. this._rtTextureRect = new cc.Rect;
  15164. this._fullRect = new cc.Rect;
  15165. this._fullViewport = new cc.Rect
  15166. };
  15167. var a = cc.RenderTexture.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  15168. a.constructor = cc.RenderTexture.WebGLRenderCmd;
  15169. a.setVirtualViewport = function(a, c, d) {
  15170. this._rtTextureRect.x = a.x;
  15171. this._rtTextureRect.y = a.y;
  15172. this._fullRect = c;
  15173. this._fullViewport = d
  15174. };
  15175. a.rendering = function(a) {
  15176. var c = a || cc._renderContext;
  15177. a = this._node;
  15178. if (a.autoDraw) {
  15179. a.begin();
  15180. var d = a.clearFlags;
  15181. if (d) {
  15182. var e = [0, 0, 0, 0],
  15183. f = 0,
  15184. g = 0;
  15185. d & c.COLOR_BUFFER_BIT && (e = c.getParameter(c.COLOR_CLEAR_VALUE), c.clearColor(a._clearColor.r / 255, a._clearColor.g / 255, a._clearColor.b / 255, a._clearColor.a / 255));
  15186. d & c.DEPTH_BUFFER_BIT && (f = c.getParameter(c.DEPTH_CLEAR_VALUE), c.clearDepth(a.clearDepthVal));
  15187. d & c.STENCIL_BUFFER_BIT && (g = c.getParameter(c.STENCIL_CLEAR_VALUE), c.clearStencil(a.clearStencilVal));
  15188. c.clear(d);
  15189. d & c.COLOR_BUFFER_BIT && c.clearColor(e[0], e[1], e[2], e[3]);
  15190. d & c.DEPTH_BUFFER_BIT && c.clearDepth(f);
  15191. d & c.STENCIL_BUFFER_BIT && c.clearStencil(g)
  15192. }
  15193. a.sortAllChildren();
  15194. c = a._children;
  15195. for (d = 0; d < c.length; d++) e = c[d], e !== a.sprite && e._renderCmd.visit(a.sprite._renderCmd);
  15196. a.end()
  15197. }
  15198. };
  15199. a.clearStencil = function(a) {
  15200. var c = cc._renderContext,
  15201. d = c.getParameter(c.STENCIL_CLEAR_VALUE);
  15202. c.clearStencil(a);
  15203. c.clear(c.STENCIL_BUFFER_BIT);
  15204. c.clearStencil(d)
  15205. };
  15206. a.cleanup = function() {
  15207. this._textureCopy = null;
  15208. var a = cc._renderContext;
  15209. a.deleteFramebuffer(this._fBO);
  15210. this._depthRenderBuffer && a.deleteRenderbuffer(this._depthRenderBuffer)
  15211. };
  15212. a.updateClearColor = function(a) {};
  15213. a.initWithWidthAndHeight = function(a, c, d, e) {
  15214. var f = this._node;
  15215. d === cc.Texture2D.PIXEL_FORMAT_A8 && cc.log("cc.RenderTexture._initWithWidthAndHeightForWebGL() : only RGB and RGBA formats are valid for a render texture;");
  15216. var g = cc._renderContext,
  15217. h = cc.contentScaleFactor();
  15218. this._fullRect = new cc.Rect(0, 0, a, c);
  15219. this._fullViewport = new cc.Rect(0, 0, a, c);
  15220. a = 0 | a * h;
  15221. c = 0 | c * h;
  15222. this._oldFBO =
  15223. g.getParameter(g.FRAMEBUFFER_BINDING);
  15224. var k;
  15225. cc.configuration.supportsNPOT() ? (h = a, k = c) : (h = cc.NextPOT(a), k = cc.NextPOT(c));
  15226. for (var m = new Uint8Array(h * k * 4), n = 0; n < h * k * 4; n++) m[n] = 0;
  15227. this._pixelFormat = d;
  15228. n = f._texture = new cc.Texture2D;
  15229. if (!f._texture) return !1;
  15230. n.initWithData(m, f._pixelFormat, h, k, cc.size(a, c));
  15231. d = g.getParameter(g.RENDERBUFFER_BINDING);
  15232. if (cc.configuration.checkForGLExtension("GL_QCOM")) {
  15233. this._textureCopy = new cc.Texture2D;
  15234. if (!this._textureCopy) return !1;
  15235. this._textureCopy.initWithData(m, f._pixelFormat,
  15236. h, k, cc.size(a, c))
  15237. }
  15238. this._fBO = g.createFramebuffer();
  15239. g.bindFramebuffer(g.FRAMEBUFFER, this._fBO);
  15240. g.framebufferTexture2D(g.FRAMEBUFFER, g.COLOR_ATTACHMENT0, g.TEXTURE_2D, n._webTextureObj, 0);
  15241. 0 !== e && (this._depthRenderBuffer = g.createRenderbuffer(), g.bindRenderbuffer(g.RENDERBUFFER, this._depthRenderBuffer), g.renderbufferStorage(g.RENDERBUFFER, e, h, k), e === g.DEPTH_STENCIL ? g.framebufferRenderbuffer(g.FRAMEBUFFER, g.DEPTH_STENCIL_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer) : e === g.STENCIL_INDEX || e === g.STENCIL_INDEX8 ?
  15242. g.framebufferRenderbuffer(g.FRAMEBUFFER, g.STENCIL_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer) : e === g.DEPTH_COMPONENT16 && g.framebufferRenderbuffer(g.FRAMEBUFFER, g.DEPTH_ATTACHMENT, g.RENDERBUFFER, this._depthRenderBuffer));
  15243. g.checkFramebufferStatus(g.FRAMEBUFFER) !== g.FRAMEBUFFER_COMPLETE && cc.log("Could not attach texture to the framebuffer");
  15244. n.setAliasTexParameters();
  15245. a = f.sprite = new cc.Sprite(n);
  15246. a.scaleY = -1;
  15247. a.setBlendFunc(g.ONE, g.ONE_MINUS_SRC_ALPHA);
  15248. g.bindRenderbuffer(g.RENDERBUFFER, d);
  15249. g.bindFramebuffer(g.FRAMEBUFFER,
  15250. this._oldFBO);
  15251. f.autoDraw = !1;
  15252. f.addChild(a);
  15253. return !0
  15254. };
  15255. a.begin = function() {
  15256. var a = this._node;
  15257. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  15258. cc.kmGLPushMatrix();
  15259. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  15260. cc.kmGLPushMatrix();
  15261. var c = cc._renderContext,
  15262. d = cc.director;
  15263. d.setProjection(d.getProjection());
  15264. var e = a._texture.getContentSizeInPixels(),
  15265. f = cc.director.getWinSizeInPixels(),
  15266. d = f.width / e.width,
  15267. e = f.height / e.height,
  15268. d = cc.math.Matrix4.createOrthographicProjection(-1 / d, 1 / d, -1 / e, 1 / e, -1, 1);
  15269. cc.kmGLMultMatrix(d);
  15270. d = new cc.Rect(0,
  15271. 0, 0, 0);
  15272. d.width = this._fullViewport.width;
  15273. d.height = this._fullViewport.height;
  15274. e = d.height / this._fullRect.height;
  15275. d.x = d.width / this._fullRect.width * (this._fullRect.x - this._rtTextureRect.x);
  15276. d.y = (this._fullRect.y - this._rtTextureRect.y) * e;
  15277. c.viewport(d.x, d.y, d.width, d.height);
  15278. this._oldFBO = c.getParameter(c.FRAMEBUFFER_BINDING);
  15279. c.bindFramebuffer(c.FRAMEBUFFER, this._fBO);
  15280. cc.configuration.checkForGLExtension("GL_QCOM") && (c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, this._textureCopy._webTextureObj,
  15281. 0), c.clear(c.COLOR_BUFFER_BIT | c.DEPTH_BUFFER_BIT), c.framebufferTexture2D(c.FRAMEBUFFER, c.COLOR_ATTACHMENT0, c.TEXTURE_2D, a._texture._webTextureObj, 0))
  15282. };
  15283. a._beginWithClear = function(a, c, d, e, f, g, h) {
  15284. a /= 255;
  15285. c /= 255;
  15286. d /= 255;
  15287. e /= 255;
  15288. var k = cc._renderContext,
  15289. m = [0, 0, 0, 0],
  15290. n = 0,
  15291. p = 0;
  15292. h & k.COLOR_BUFFER_BIT && (m = k.getParameter(k.COLOR_CLEAR_VALUE), k.clearColor(a, c, d, e));
  15293. h & k.DEPTH_BUFFER_BIT && (n = k.getParameter(k.DEPTH_CLEAR_VALUE), k.clearDepth(f));
  15294. h & k.STENCIL_BUFFER_BIT && (p = k.getParameter(k.STENCIL_CLEAR_VALUE), k.clearStencil(g));
  15295. k.clear(h);
  15296. h & k.COLOR_BUFFER_BIT && k.clearColor(m[0], m[1], m[2], m[3]);
  15297. h & k.DEPTH_BUFFER_BIT && k.clearDepth(n);
  15298. h & k.STENCIL_BUFFER_BIT && k.clearStencil(p)
  15299. };
  15300. a.end = function() {
  15301. cc.renderer._renderingToBuffer(this._node.__instanceId);
  15302. var a = cc._renderContext,
  15303. c = cc.director;
  15304. a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
  15305. c.setViewport();
  15306. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  15307. cc.kmGLPopMatrix();
  15308. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  15309. cc.kmGLPopMatrix()
  15310. };
  15311. a.clearRect = function(a, c, d, e) {};
  15312. a.clearDepth = function(a) {
  15313. var c = this._node;
  15314. c.begin();
  15315. var d = cc._renderContext,
  15316. e = d.getParameter(d.DEPTH_CLEAR_VALUE);
  15317. d.clearDepth(a);
  15318. d.clear(d.DEPTH_BUFFER_BIT);
  15319. d.clearDepth(e);
  15320. c.end()
  15321. };
  15322. a.visit = function(a) {
  15323. var c = this._node;
  15324. c._visible && (cc.kmGLPushMatrix(), this._syncStatus(a), cc.renderer.pushRenderCommand(this), c.sprite.visit(this), this._dirtyFlag = 0, cc.kmGLPopMatrix())
  15325. }
  15326. })();
  15327. cc.LabelAtlas = cc.AtlasNode.extend({
  15328. _string: null,
  15329. _mapStartChar: null,
  15330. _textureLoaded: !1,
  15331. _className: "LabelAtlas",
  15332. ctor: function(a, b, c, d, e) {
  15333. cc.AtlasNode.prototype.ctor.call(this);
  15334. this._renderCmd.setCascade();
  15335. b && cc.LabelAtlas.prototype.initWithString.call(this, a, b, c, d, e)
  15336. },
  15337. _createRenderCmd: function() {
  15338. return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.LabelAtlas.WebGLRenderCmd(this) : new cc.LabelAtlas.CanvasRenderCmd(this)
  15339. },
  15340. textureLoaded: function() {
  15341. return this._textureLoaded
  15342. },
  15343. addLoadedEventListener: function(a,
  15344. b) {
  15345. this.addEventListener("load", a, b)
  15346. },
  15347. initWithString: function(a, b, c, d, e) {
  15348. var f = a + "",
  15349. g, h;
  15350. if (void 0 === c) {
  15351. c = cc.loader.getRes(b);
  15352. if (1 !== parseInt(c.version, 10)) return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"), !1;
  15353. b = cc.path.changeBasename(b, c.textureFilename);
  15354. d = cc.contentScaleFactor();
  15355. g = parseInt(c.itemWidth, 10) / d;
  15356. h = parseInt(c.itemHeight, 10) / d;
  15357. c = String.fromCharCode(parseInt(c.firstChar, 10))
  15358. } else g = c || 0, h = d || 0, c = e || " ";
  15359. var k = null,
  15360. k = b instanceof cc.Texture2D ? b : cc.textureCache.addImage(b);
  15361. this._textureLoaded = b = k.isLoaded();
  15362. b || (this._string = f, k.addEventListener("load", function(a) {
  15363. this.initWithTexture(k, g, h, f.length);
  15364. this.string = this._string;
  15365. this.setColor(this._renderCmd._displayedColor);
  15366. this.dispatchEvent("load")
  15367. }, this));
  15368. return this.initWithTexture(k, g, h, f.length) ? (this._mapStartChar = c, this.string = f, !0) : !1
  15369. },
  15370. setColor: function(a) {
  15371. cc.AtlasNode.prototype.setColor.call(this, a);
  15372. this._renderCmd.updateAtlasValues()
  15373. },
  15374. getString: function() {
  15375. return this._string
  15376. },
  15377. addChild: function(a, b, c) {
  15378. this._renderCmd._addChild(a);
  15379. cc.Node.prototype.addChild.call(this, a, b, c)
  15380. },
  15381. updateAtlasValues: function() {
  15382. this._renderCmd.updateAtlasValues()
  15383. },
  15384. setString: function(a) {
  15385. a = String(a);
  15386. var b = a.length;
  15387. this._string = a;
  15388. this.setContentSize(b * this._itemWidth, this._itemHeight);
  15389. this._renderCmd.setString(a);
  15390. this._renderCmd.updateAtlasValues();
  15391. this.quadsToDraw = b
  15392. }
  15393. });
  15394. (function() {
  15395. var a = cc.LabelAtlas.prototype;
  15396. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  15397. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  15398. cc.defineGetterSetter(a, "string", a.getString, a.setString)
  15399. })();
  15400. cc.LabelAtlas.create = function(a, b, c, d, e) {
  15401. return new cc.LabelAtlas(a, b, c, d, e)
  15402. };
  15403. (function() {
  15404. cc.LabelAtlas.CanvasRenderCmd = function(a) {
  15405. cc.AtlasNode.CanvasRenderCmd.call(this, a);
  15406. this._needDraw = !1
  15407. };
  15408. var a = cc.LabelAtlas.CanvasRenderCmd.prototype = Object.create(cc.AtlasNode.CanvasRenderCmd.prototype);
  15409. a.constructor = cc.LabelAtlas.CanvasRenderCmd;
  15410. a.setCascade = function() {
  15411. var a = this._node;
  15412. a._cascadeOpacityEnabled = !0;
  15413. a._cascadeColorEnabled = !1
  15414. };
  15415. a.updateAtlasValues = function() {
  15416. for (var a = this._node, c = a._string || "", d = c.length, e = this._texture, f = a._itemWidth, g = a._itemHeight, h = 0; h < d; h++) {
  15417. var k = c.charCodeAt(h) -
  15418. a._mapStartChar.charCodeAt(0),
  15419. m = parseInt(k % a._itemsPerRow, 10),
  15420. k = parseInt(k / a._itemsPerRow, 10),
  15421. m = cc.rect(m * f, k * g, f, g),
  15422. k = c.charCodeAt(h),
  15423. n = a.getChildByTag(h);
  15424. n ? 32 === k ? (n.init(), n.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : (n.initWithTexture(e, m), n.visible = !0) : (n = new cc.Sprite, 32 === k ? (n.init(), n.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : n.initWithTexture(e, m), cc.Node.prototype.addChild.call(a, n, 0, h));
  15425. n.setPosition(h * f + f / 2, g / 2)
  15426. }
  15427. };
  15428. a.setString = function(a) {
  15429. a = this._node;
  15430. if (a._children) {
  15431. a =
  15432. a._children;
  15433. for (var c = a.length, d = 0; d < c; d++) {
  15434. var e = a[d];
  15435. e && !e._lateChild && (e.visible = !1)
  15436. }
  15437. }
  15438. };
  15439. a._addChild = function() {
  15440. child._lateChild = !0
  15441. }
  15442. })();
  15443. (function() {
  15444. cc.LabelAtlas.WebGLRenderCmd = function(a) {
  15445. cc.AtlasNode.WebGLRenderCmd.call(this, a);
  15446. this._needDraw = !0
  15447. };
  15448. var a = cc.LabelAtlas.WebGLRenderCmd.prototype = Object.create(cc.AtlasNode.WebGLRenderCmd.prototype);
  15449. a.constructor = cc.LabelAtlas.WebGLRenderCmd;
  15450. a.setCascade = function() {
  15451. var a = this._node;
  15452. a._cascadeOpacityEnabled = !0;
  15453. a._cascadeColorEnabled = !0
  15454. };
  15455. a.rendering = function(a) {
  15456. cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this, a);
  15457. cc.LABELATLAS_DEBUG_DRAW && (a = this._node.getContentSize(), a = [cc.p(0,
  15458. 0), cc.p(a.width, 0), cc.p(a.width, a.height), cc.p(0, a.height)], cc._drawingUtil.drawPoly(a, 4, !0))
  15459. };
  15460. a.updateAtlasValues = function() {
  15461. var a = this._node,
  15462. c = a._string,
  15463. d = c.length,
  15464. e = this._textureAtlas,
  15465. f = e.texture,
  15466. g = f.pixelsWidth,
  15467. f = f.pixelsHeight,
  15468. h = a._itemWidth,
  15469. k = a._itemHeight;
  15470. a._ignoreContentScaleFactor || (h = a._itemWidth * cc.contentScaleFactor(), k = a._itemHeight * cc.contentScaleFactor());
  15471. d > e.getCapacity() && cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");
  15472. for (var m = e.quads, n = this._displayedColor,
  15473. n = {
  15474. r: n.r,
  15475. g: n.g,
  15476. b: n.b,
  15477. a: a._displayedOpacity
  15478. }, p = a._itemWidth, t = 0; t < d; t++) {
  15479. var r = c.charCodeAt(t) - a._mapStartChar.charCodeAt(0),
  15480. u = r % a._itemsPerRow,
  15481. s = 0 | r / a._itemsPerRow,
  15482. v;
  15483. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (u = (2 * u * h + 1) / (2 * g), r = u + (2 * h - 2) / (2 * g), s = (2 * s * k + 1) / (2 * f), v = s + (2 * k - 2) / (2 * f)) : (u = u * h / g, r = u + h / g, s = s * k / f, v = s + k / f);
  15484. var x = m[t],
  15485. D = x.tl,
  15486. E = x.tr,
  15487. A = x.bl,
  15488. x = x.br;
  15489. D.texCoords.u = u;
  15490. D.texCoords.v = s;
  15491. E.texCoords.u = r;
  15492. E.texCoords.v = s;
  15493. A.texCoords.u = u;
  15494. A.texCoords.v = v;
  15495. x.texCoords.u = r;
  15496. x.texCoords.v = v;
  15497. A.vertices.x = t * p;
  15498. A.vertices.y =
  15499. 0;
  15500. A.vertices.z = 0;
  15501. x.vertices.x = t * p + p;
  15502. x.vertices.y = 0;
  15503. x.vertices.z = 0;
  15504. D.vertices.x = t * p;
  15505. D.vertices.y = a._itemHeight;
  15506. D.vertices.z = 0;
  15507. E.vertices.x = t * p + p;
  15508. E.vertices.y = a._itemHeight;
  15509. E.vertices.z = 0;
  15510. D.colors = n;
  15511. E.colors = n;
  15512. A.colors = n;
  15513. x.colors = n
  15514. }
  15515. 0 < d && (e.dirty = !0, a = e.totalQuads, d > a && e.increaseTotalQuadsWith(d - a))
  15516. };
  15517. a.setString = function(a) {
  15518. a = a.length;
  15519. a > this._textureAtlas.totalQuads && this._textureAtlas.resizeCapacity(a)
  15520. };
  15521. a._addChild = function() {}
  15522. })();
  15523. cc.LABEL_AUTOMATIC_WIDTH = -1;
  15524. cc.LabelBMFont = cc.SpriteBatchNode.extend({
  15525. _opacityModifyRGB: !1,
  15526. _string: "",
  15527. _config: null,
  15528. _fntFile: "",
  15529. _initialString: "",
  15530. _alignment: cc.TEXT_ALIGNMENT_CENTER,
  15531. _width: -1,
  15532. _lineBreakWithoutSpaces: !1,
  15533. _imageOffset: null,
  15534. _reusedChar: null,
  15535. _textureLoaded: !1,
  15536. _className: "LabelBMFont",
  15537. _createRenderCmd: function() {
  15538. return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.LabelBMFont.WebGLRenderCmd(this) : new cc.LabelBMFont.CanvasRenderCmd(this)
  15539. },
  15540. _setString: function(a, b) {
  15541. b ? this._initialString = a : this._string = a;
  15542. var c = this._children;
  15543. if (c)
  15544. for (var d = 0; d < c.length; d++) {
  15545. var e = c[d];
  15546. e && e.setVisible(!1)
  15547. }
  15548. this._textureLoaded && (this.createFontChars(), b && this.updateLabel())
  15549. },
  15550. ctor: function(a, b, c, d, e) {
  15551. cc.SpriteBatchNode.prototype.ctor.call(this);
  15552. this._imageOffset = cc.p(0, 0);
  15553. this._reusedChar = [];
  15554. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !0;
  15555. this.initWithString(a, b, c, d, e)
  15556. },
  15557. textureLoaded: function() {
  15558. return this._textureLoaded
  15559. },
  15560. addLoadedEventListener: function(a, b) {
  15561. this.addEventListener("load", a, b)
  15562. },
  15563. isOpacityModifyRGB: function() {
  15564. return this._opacityModifyRGB
  15565. },
  15566. setOpacityModifyRGB: function(a) {
  15567. this._opacityModifyRGB = a;
  15568. if (a = this._children)
  15569. for (var b = 0; b < a.length; b++) {
  15570. var c = a[b];
  15571. c && (c.opacityModifyRGB = this._opacityModifyRGB)
  15572. }
  15573. },
  15574. _changeTextureColor: function() {
  15575. this._renderCmd._changeTextureColor()
  15576. },
  15577. init: function() {
  15578. return this.initWithString(null, null, null, null, null)
  15579. },
  15580. initWithString: function(a, b, c, d, e) {
  15581. a = a || "";
  15582. this._config && cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");
  15583. if (b) {
  15584. var f = cc.loader.getRes(b);
  15585. if (!f) return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"), !1;
  15586. this._config = f;
  15587. this._fntFile = b;
  15588. b = cc.textureCache.addImage(f.atlasName);
  15589. (this._textureLoaded = f = b.isLoaded()) || b.addEventListener("load", function(a) {
  15590. this._textureLoaded = !0;
  15591. this.initWithTexture(a, this._initialString.length);
  15592. this.setString(this._initialString, !0);
  15593. this.dispatchEvent("load")
  15594. }, this)
  15595. } else b = new cc.Texture2D, f = new Image, b.initWithElement(f), this._textureLoaded = !1;
  15596. return this.initWithTexture(b, a.length) ? (this._alignment = d || cc.TEXT_ALIGNMENT_LEFT, this._imageOffset = e || cc.p(0, 0), this._width =
  15597. null == c ? -1 : c, this._realOpacity = 255, this._realColor = cc.color(255, 255, 255, 255), this._contentSize.width = 0, this._contentSize.height = 0, this.setAnchorPoint(0.5, 0.5), this._renderCmd._initBatchTexture(), this.setString(a, !0), !0) : !1
  15598. },
  15599. createFontChars: function() {
  15600. var a = this._renderCmd._texture || this.textureAtlas.texture,
  15601. b = 0,
  15602. c = cc.size(0, 0),
  15603. d = 0,
  15604. e = 1,
  15605. f = this._string,
  15606. g = f ? f.length : 0;
  15607. if (0 !== g) {
  15608. var h, k = this._config,
  15609. m = k.kerningDict,
  15610. n = k.commonHeight,
  15611. p = k.fontDefDictionary;
  15612. for (h = 0; h < g - 1; h++) 10 === f.charCodeAt(h) && e++;
  15613. var t =
  15614. n * e,
  15615. e = -(n - n * e),
  15616. r = -1;
  15617. for (h = 0; h < g; h++)
  15618. if (n = f.charCodeAt(h), 0 !== n)
  15619. if (10 === n) b = 0, e -= k.commonHeight;
  15620. else {
  15621. var u = m[r << 16 | n & 65535] || 0,
  15622. s = p[n];
  15623. if (s) {
  15624. var v = cc.rect(s.rect.x, s.rect.y, s.rect.width, s.rect.height),
  15625. v = cc.rectPixelsToPoints(v);
  15626. v.x += this._imageOffset.x;
  15627. v.y += this._imageOffset.y;
  15628. (r = this.getChildByTag(h)) ? this._renderCmd._updateCharTexture(r, v, n): (r = new cc.Sprite, r.initWithTexture(a, v, !1), r._newTextureWhenChangeColor = !0, this.addChild(r, 0, h));
  15629. r.opacityModifyRGB = this._opacityModifyRGB;
  15630. this._renderCmd._updateCharColorAndOpacity(r);
  15631. v = cc.p(b + s.xOffset + 0.5 * s.rect.width + u, e + (k.commonHeight - s.yOffset) - 0.5 * v.height * cc.contentScaleFactor());
  15632. r.setPosition(cc.pointPixelsToPoints(v));
  15633. b += s.xAdvance + u;
  15634. r = n;
  15635. d < b && (d = b)
  15636. } else cc.log("cocos2d: LabelBMFont: character not found " + f[h])
  15637. }
  15638. c.width = s && s.xAdvance < s.rect.width ? d - s.xAdvance + s.rect.width : d;
  15639. c.height = t;
  15640. this.setContentSize(cc.sizePixelsToPoints(c))
  15641. }
  15642. },
  15643. updateString: function(a) {
  15644. var b = this._children;
  15645. if (b)
  15646. for (var c = 0, d = b.length; c < d; c++) {
  15647. var e = b[c];
  15648. e && (e.visible = !1)
  15649. }
  15650. this._config && this.createFontChars();
  15651. a || this.updateLabel()
  15652. },
  15653. getString: function() {
  15654. return this._initialString
  15655. },
  15656. setString: function(a, b) {
  15657. a = String(a);
  15658. null == b && (b = !0);
  15659. null != a && cc.isString(a) || (a += "");
  15660. this._initialString = a;
  15661. this._setString(a, b)
  15662. },
  15663. _setStringForSetter: function(a) {
  15664. this.setString(a, !1)
  15665. },
  15666. setCString: function(a) {
  15667. this.setString(a, !0)
  15668. },
  15669. _getCharsWidth: function(a, b) {
  15670. if (0 >= b) return 0;
  15671. var c = this.getChildByTag(a),
  15672. d = this.getChildByTag(a + b);
  15673. return this._getLetterPosXLeft(d) - this._getLetterPosXLeft(c)
  15674. },
  15675. _checkWarp: function(a, b, c, d) {
  15676. for (var e =
  15677. a[b], f = 0, g = 0; g < b; g++) f += a[g].length;
  15678. var f = f + b - d,
  15679. h = this._getCharsWidth(f, a[b].length - 1);
  15680. if (h > c && 1 < e.length) {
  15681. d = c / h * e.length | 0;
  15682. for (var g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1), m, n = 0, p = 0; k > c && 100 > p++;) d *= c / k, d |= 0, g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1);
  15683. for (p = 0; k < c && 100 > p++;) g && (n = (m = cc.LabelTTF._wordRex.exec(g)) ? m[0].length : 1, m = g), this._lineBreakWithoutSpaces && (n = 0), d += n, g = e.substr(d), k = h - this._getCharsWidth(f + d, g.length - 1);
  15684. d -= n;
  15685. 0 === d && (d = 1, m = m.substr(1));
  15686. c = e.substr(0, d);
  15687. cc.LabelTTF.wrapInspection &&
  15688. cc.LabelTTF._symbolRex.test(m || g) && (n = (f = cc.LabelTTF._lastWordRex.exec(c)) ? f[0].length : 0, this._lineBreakWithoutSpaces && (n = 0), d -= n, m = e.substr(d), c = e.substr(0, d));
  15689. cc.LabelTTF._firsrEnglish.test(m) && (f = cc.LabelTTF._lastEnglish.exec(c)) && c !== f[0] && (n = f[0].length, this._lineBreakWithoutSpaces && (n = 0), d -= n, m = e.substr(d), c = e.substr(0, d));
  15690. a[b] = m || g;
  15691. a.splice(b, 0, c)
  15692. }
  15693. },
  15694. updateLabel: function() {
  15695. this.string = this._initialString;
  15696. var a, b, c;
  15697. if (0 < this._width) {
  15698. var d = this.string.split("\n"),
  15699. e = "",
  15700. f = 0,
  15701. g = 0;
  15702. for (a = 0; a < d.length; a++) g =
  15703. d.length, this._checkWarp(d, a, this._width * this._scaleX, f), g < d.length && f++, 0 < a && (e += "\n"), e += d[a];
  15704. e += String.fromCharCode(0);
  15705. this._setString(e, !1)
  15706. }
  15707. if (this._alignment !== cc.TEXT_ALIGNMENT_LEFT)
  15708. for (d = a = 0, e = this._string.length, f = [], g = 0; g < e; g++)
  15709. if (10 === this._string[g].charCodeAt(0) || 0 === this._string[g].charCodeAt(0)) {
  15710. b = 0;
  15711. var h = f.length;
  15712. if (0 === h) d++;
  15713. else if (c = a + h - 1 + d, !(0 > c)) {
  15714. var k = this.getChildByTag(c);
  15715. if (null != k) {
  15716. b = k.getPositionX() + k._getWidth() / 2;
  15717. k = 0;
  15718. switch (this._alignment) {
  15719. case cc.TEXT_ALIGNMENT_CENTER:
  15720. k =
  15721. this.width / 2 - b / 2;
  15722. break;
  15723. case cc.TEXT_ALIGNMENT_RIGHT:
  15724. k = this.width - b
  15725. }
  15726. if (0 !== k)
  15727. for (b = 0; b < h; b++) c = a + b + d, 0 > c || (c = this.getChildByTag(c)) && (c.x += k);
  15728. a += h;
  15729. d++;
  15730. f.length = 0
  15731. }
  15732. }
  15733. } else f.push(this._string[a])
  15734. },
  15735. setAlignment: function(a) {
  15736. this._alignment = a;
  15737. this.updateLabel()
  15738. },
  15739. _getAlignment: function() {
  15740. return this._alignment
  15741. },
  15742. setBoundingWidth: function(a) {
  15743. this._width = a;
  15744. this.updateLabel()
  15745. },
  15746. _getBoundingWidth: function() {
  15747. return this._width
  15748. },
  15749. setLineBreakWithoutSpace: function(a) {
  15750. this._lineBreakWithoutSpaces = a;
  15751. this.updateLabel()
  15752. },
  15753. setScale: function(a, b) {
  15754. cc.Node.prototype.setScale.call(this, a, b);
  15755. this.updateLabel()
  15756. },
  15757. setScaleX: function(a) {
  15758. cc.Node.prototype.setScaleX.call(this, a);
  15759. this.updateLabel()
  15760. },
  15761. setScaleY: function(a) {
  15762. cc.Node.prototype.setScaleY.call(this, a);
  15763. this.updateLabel()
  15764. },
  15765. setFntFile: function(a) {
  15766. if (null != a && a !== this._fntFile) {
  15767. var b = cc.loader.getRes(a);
  15768. b ? (this._fntFile = a, this._config = b, a = cc.textureCache.addImage(b.atlasName), this._textureLoaded = b = a.isLoaded(), this.texture = a, this._renderCmd._updateFntFileTexture(), b ? this.createFontChars() :
  15769. a.addEventListener("load", function(a) {
  15770. this._textureLoaded = !0;
  15771. this.texture = a;
  15772. this.createFontChars();
  15773. this._changeTextureColor();
  15774. this.updateLabel();
  15775. this.dispatchEvent("load")
  15776. }, this)) : cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file")
  15777. }
  15778. },
  15779. getFntFile: function() {
  15780. return this._fntFile
  15781. },
  15782. setTexture: function(a) {
  15783. this._renderCmd.setTexture(a)
  15784. },
  15785. setAnchorPoint: function(a, b) {
  15786. cc.Node.prototype.setAnchorPoint.call(this, a, b);
  15787. this.updateLabel()
  15788. },
  15789. _setAnchorX: function(a) {
  15790. cc.Node.prototype._setAnchorX.call(this,
  15791. a);
  15792. this.updateLabel()
  15793. },
  15794. _setAnchorY: function(a) {
  15795. cc.Node.prototype._setAnchorY.call(this, a);
  15796. this.updateLabel()
  15797. },
  15798. _atlasNameFromFntFile: function(a) {},
  15799. _kerningAmountForFirst: function(a, b) {
  15800. var c = 0;
  15801. if (this._configuration.kerningDictionary) {
  15802. var d = this._configuration.kerningDictionary[(a << 16 | b & 65535).toString()];
  15803. d && (c = d.amount)
  15804. }
  15805. return c
  15806. },
  15807. _getLetterPosXLeft: function(a) {
  15808. return a.getPositionX() * this._scaleX - a._getWidth() * this._scaleX * a._getAnchorX()
  15809. },
  15810. _getLetterPosXRight: function(a) {
  15811. return a.getPositionX() * this._scaleX +
  15812. a._getWidth() * this._scaleX * a._getAnchorX()
  15813. },
  15814. _isspace_unicode: function(a) {
  15815. a = a.charCodeAt(0);
  15816. 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
  15817. },
  15818. _utf8_trim_ws: function(a) {
  15819. var b = a.length;
  15820. if (!(0 >= b) && (b -= 1, this._isspace_unicode(a[b]))) {
  15821. for (var c = b - 1; 0 <= c; --c)
  15822. if (this._isspace_unicode(a[c])) b = c;
  15823. else break;
  15824. this._utf8_trim_from(a, b)
  15825. }
  15826. },
  15827. _utf8_trim_from: function(a, b) {
  15828. var c = a.length;
  15829. b >= c || 0 > b || a.splice(b, c)
  15830. }
  15831. });
  15832. (function() {
  15833. var a = cc.LabelBMFont.prototype;
  15834. cc.EventHelper.prototype.apply(a);
  15835. cc.defineGetterSetter(a, "string", a.getString, a._setStringForSetter);
  15836. cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a.setBoundingWidth);
  15837. cc.defineGetterSetter(a, "textAlign", a._getAlignment, a.setAlignment)
  15838. })();
  15839. cc.LabelBMFont.create = function(a, b, c, d, e) {
  15840. return new cc.LabelBMFont(a, b, c, d, e)
  15841. };
  15842. cc._fntLoader = {
  15843. INFO_EXP: /info [^\n]*(\n|$)/gi,
  15844. COMMON_EXP: /common [^\n]*(\n|$)/gi,
  15845. PAGE_EXP: /page [^\n]*(\n|$)/gi,
  15846. CHAR_EXP: /char [^\n]*(\n|$)/gi,
  15847. KERNING_EXP: /kerning [^\n]*(\n|$)/gi,
  15848. ITEM_EXP: /\w+=[^ \r\n]+/gi,
  15849. INT_EXP: /^[\-]?\d+$/,
  15850. _parseStrToObj: function(a) {
  15851. a = a.match(this.ITEM_EXP);
  15852. var b = {};
  15853. if (a)
  15854. for (var c = 0, d = a.length; c < d; c++) {
  15855. var e = a[c],
  15856. f = e.indexOf("\x3d"),
  15857. g = e.substring(0, f),
  15858. e = e.substring(f + 1);
  15859. e.match(this.INT_EXP) ? e = parseInt(e) : '"' === e[0] && (e = e.substring(1, e.length - 1));
  15860. b[g] = e
  15861. }
  15862. return b
  15863. },
  15864. parseFnt: function(a,
  15865. b) {
  15866. var c = {},
  15867. d = this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(",");
  15868. parseInt(d[0]);
  15869. parseInt(d[1]);
  15870. parseInt(d[2]);
  15871. parseInt(d[3]);
  15872. d = this._parseStrToObj(a.match(this.COMMON_EXP)[0]);
  15873. c.commonHeight = d.lineHeight;
  15874. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  15875. var e = cc.configuration.getMaxTextureSize();
  15876. (d.scaleW > e.width || d.scaleH > e.height) && cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")
  15877. }
  15878. 1 !== d.pages && cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
  15879. d = this._parseStrToObj(a.match(this.PAGE_EXP)[0]);
  15880. 0 !== d.id && cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
  15881. c.atlasName = cc.path.changeBasename(b, d.file);
  15882. for (var f = a.match(this.CHAR_EXP), g = c.fontDefDictionary = {}, d = 0, e = f.length; d < e; d++) {
  15883. var h = this._parseStrToObj(f[d]);
  15884. g[h.id] = {
  15885. rect: {
  15886. x: h.x,
  15887. y: h.y,
  15888. width: h.width,
  15889. height: h.height
  15890. },
  15891. xOffset: h.xoffset,
  15892. yOffset: h.yoffset,
  15893. xAdvance: h.xadvance
  15894. }
  15895. }
  15896. f = c.kerningDict = {};
  15897. if (g = a.match(this.KERNING_EXP))
  15898. for (d = 0, e = g.length; d < e; d++) h = this._parseStrToObj(g[d]),
  15899. f[h.first << 16 | h.second & 65535] = h.amount;
  15900. return c
  15901. },
  15902. load: function(a, b, c, d) {
  15903. var e = this;
  15904. cc.loader.loadTxt(a, function(a, c) {
  15905. if (a) return d(a);
  15906. d(null, e.parseFnt(c, b))
  15907. })
  15908. }
  15909. };
  15910. cc.loader.register(["fnt"], cc._fntLoader);
  15911. (function() {
  15912. cc.LabelBMFont.CanvasRenderCmd = function(a) {
  15913. cc.SpriteBatchNode.CanvasRenderCmd.call(this, a);
  15914. this._needDraw = !0
  15915. };
  15916. var a = cc.LabelBMFont.CanvasRenderCmd.prototype = Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);
  15917. a.constructor = cc.LabelBMFont.CanvasRenderCmd;
  15918. a.rendering = function() {
  15919. void 0
  15920. };
  15921. a._updateCharTexture = function(a, c, d) {
  15922. 32 === d ? a.setTextureRect(c, !1, cc.size(0, 0)) : (a.setTextureRect(c, !1), a.visible = !0)
  15923. };
  15924. a._updateCharColorAndOpacity = function(a) {
  15925. a._displayedColor = this._displayedColor;
  15926. a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty);
  15927. a._displayedOpacity = this._displayedOpacity;
  15928. a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  15929. };
  15930. a._updateFntFileTexture = function() {
  15931. var a = this._node;
  15932. a._originalTexture = a.texture
  15933. };
  15934. a.setTexture = function(a) {
  15935. for (var c = this._node._children, d = this._displayedColor, e = 0; e < c.length; e++) {
  15936. var f = c[e],
  15937. g = f._renderCmd,
  15938. h = g._displayedColor;
  15939. if (this._texture === g._texture || h.r === d.r && h.g === d.g && h.b === d.b) f.texture = a
  15940. }
  15941. this._texture = a
  15942. };
  15943. a._changeTextureColor =
  15944. cc.sys._supportCanvasNewBlendModes ? function() {
  15945. var a = this._node,
  15946. c = a.getTexture();
  15947. if (c && 0 < c.getContentSize().width) {
  15948. var d = this._originalTexture.getHtmlElementObj();
  15949. if (d) {
  15950. var e = c.getHtmlElementObj(),
  15951. f = cc.rect(0, 0, d.width, d.height);
  15952. e instanceof HTMLCanvasElement && !a._rectRotated ? cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._displayedColor, f, e) : (e = cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(d, this._displayedColor, f), c = new cc.Texture2D, c.initWithElement(e), c.handleLoadedTexture());
  15953. a.setTexture(c)
  15954. }
  15955. }
  15956. } : function() {
  15957. var a = this._node,
  15958. c, d = a.getTexture();
  15959. if (d && 0 < d.getContentSize().width && (c = d.getHtmlElementObj())) {
  15960. var e = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj());
  15961. e && (c instanceof HTMLCanvasElement && !this._rectRotated ? (cc.Sprite.CanvasRenderCmd._generateTintImage(c, e, this._displayedColor, null, c), this.setTexture(d)) : (c = cc.Sprite.CanvasRenderCmd._generateTintImage(c, e, this._displayedColor), d = new cc.Texture2D, d.initWithElement(c), d.handleLoadedTexture(),
  15962. a.setTexture(d)))
  15963. }
  15964. };
  15965. a._updateChildrenDisplayedOpacity = function(a) {
  15966. cc.Node.prototype.updateDisplayedOpacity.call(a, this._displayedOpacity)
  15967. };
  15968. a._updateChildrenDisplayedColor = function(a) {
  15969. cc.Node.prototype.updateDisplayedColor.call(a, this._displayedColor)
  15970. };
  15971. a._initBatchTexture = function() {}
  15972. })();
  15973. (function() {
  15974. cc.LabelBMFont.WebGLRenderCmd = function(a) {
  15975. cc.SpriteBatchNode.WebGLRenderCmd.call(this, a);
  15976. this._needDraw = !0
  15977. };
  15978. var a = cc.LabelBMFont.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);
  15979. a.constructor = cc.LabelBMFont.WebGLRenderCmd;
  15980. a._updateCharTexture = function(a, c, d) {
  15981. a.setTextureRect(c, !1);
  15982. a.visible = !0
  15983. };
  15984. a._updateFntFileTexture = function() {};
  15985. a._changeTextureColor = function() {};
  15986. a._updateChildrenDisplayedOpacity = function(a) {
  15987. a.updateDisplayedOpacity(this._displayedOpacity)
  15988. };
  15989. a._updateChildrenDisplayedColor = function(a) {
  15990. a.updateDisplayedColor(this._displayedColor)
  15991. };
  15992. a._initBatchTexture = function() {
  15993. var a = this._node,
  15994. c = a.textureAtlas.texture;
  15995. a._opacityModifyRGB = c.hasPremultipliedAlpha();
  15996. var d = a._reusedChar = new cc.Sprite;
  15997. d.initWithTexture(c, cc.rect(0, 0, 0, 0), !1);
  15998. d.batchNode = a
  15999. };
  16000. a.rendering = function(a) {
  16001. cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering.call(this, a);
  16002. a = this._node;
  16003. if (cc.LABELBMFONT_DEBUG_DRAW) {
  16004. a = a.getContentSize();
  16005. var c = cc.p(0 | -this._anchorPointInPoints.x, 0 | -this._anchorPointInPoints.y);
  16006. 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)];
  16007. cc._drawingUtil.setDrawColor(0, 255, 0, 255);
  16008. cc._drawingUtil.drawPoly(a, 4, !0)
  16009. }
  16010. };
  16011. a._updateCharColorAndOpacity = function() {}
  16012. })();
  16013. cc.MotionStreak = cc.Node.extend({
  16014. texture: null,
  16015. fastMode: !1,
  16016. startingPositionInitialized: !1,
  16017. _blendFunc: null,
  16018. _stroke: 0,
  16019. _fadeDelta: 0,
  16020. _minSeg: 0,
  16021. _maxPoints: 0,
  16022. _nuPoints: 0,
  16023. _previousNuPoints: 0,
  16024. _pointVertexes: null,
  16025. _pointState: null,
  16026. _vertices: null,
  16027. _colorPointer: null,
  16028. _texCoords: null,
  16029. _verticesBuffer: null,
  16030. _colorPointerBuffer: null,
  16031. _texCoordsBuffer: null,
  16032. _className: "MotionStreak",
  16033. ctor: function(a, b, c, d, e) {
  16034. cc.Node.prototype.ctor.call(this);
  16035. this._positionR = cc.p(0, 0);
  16036. this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
  16037. this.startingPositionInitialized = this.fastMode = !1;
  16038. this.texture = null;
  16039. this._previousNuPoints = this._nuPoints = this._maxPoints = this._minSeg = this._fadeDelta = this._stroke = 0;
  16040. this._texCoordsBuffer = this._colorPointerBuffer = this._verticesBuffer = this._texCoords = this._colorPointer = this._vertices = this._pointState = this._pointVertexes = null;
  16041. void 0 !== e && this.initWithFade(a, b, c, d, e)
  16042. },
  16043. getTexture: function() {
  16044. return this.texture
  16045. },
  16046. setTexture: function(a) {
  16047. this.texture !== a && (this.texture = a)
  16048. },
  16049. getBlendFunc: function() {
  16050. return this._blendFunc
  16051. },
  16052. setBlendFunc: function(a, b) {
  16053. void 0 === b ? this._blendFunc = a : (this._blendFunc.src = a, this._blendFunc.dst = b)
  16054. },
  16055. getOpacity: function() {
  16056. cc.log("cc.MotionStreak.getOpacity has not been supported.");
  16057. return 0
  16058. },
  16059. setOpacity: function(a) {
  16060. cc.log("cc.MotionStreak.setOpacity has not been supported.")
  16061. },
  16062. setOpacityModifyRGB: function(a) {},
  16063. isOpacityModifyRGB: function() {
  16064. return !1
  16065. },
  16066. isFastMode: function() {
  16067. return this.fastMode
  16068. },
  16069. setFastMode: function(a) {
  16070. this.fastMode = a
  16071. },
  16072. isStartingPositionInitialized: function() {
  16073. return this.startingPositionInitialized
  16074. },
  16075. setStartingPositionInitialized: function(a) {
  16076. this.startingPositionInitialized = a
  16077. },
  16078. initWithFade: function(a, b, c, d, e) {
  16079. if (!e) throw "cc.MotionStreak.initWithFade(): Invalid filename or texture";
  16080. cc.isString(e) && (e = cc.textureCache.addImage(e));
  16081. cc.Node.prototype.setPosition.call(this, cc.p(0, 0));
  16082. this.anchorY = this.anchorX = 0;
  16083. this.ignoreAnchor = !0;
  16084. this.startingPositionInitialized = !1;
  16085. this.fastMode = !0;
  16086. this._minSeg = -1 === b ? c / 5 : b;
  16087. this._minSeg *= this._minSeg;
  16088. this._stroke = c;
  16089. this._fadeDelta = 1 / a;
  16090. this._maxPoints = a = (0 | 60 * a) +
  16091. 2;
  16092. this._nuPoints = 0;
  16093. this._pointState = new Float32Array(a);
  16094. this._pointVertexes = new Float32Array(2 * a);
  16095. this._vertices = new Float32Array(4 * a);
  16096. this._texCoords = new Float32Array(4 * a);
  16097. this._colorPointer = new Uint8Array(8 * a);
  16098. this._verticesBuffer = gl.createBuffer();
  16099. this._texCoordsBuffer = gl.createBuffer();
  16100. this._colorPointerBuffer = gl.createBuffer();
  16101. this._blendFunc.src = gl.SRC_ALPHA;
  16102. this._blendFunc.dst = gl.ONE_MINUS_SRC_ALPHA;
  16103. this.texture = e;
  16104. this.color = d;
  16105. this.scheduleUpdate();
  16106. gl.bindBuffer(gl.ARRAY_BUFFER, this._verticesBuffer);
  16107. gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.DYNAMIC_DRAW);
  16108. gl.bindBuffer(gl.ARRAY_BUFFER, this._texCoordsBuffer);
  16109. gl.bufferData(gl.ARRAY_BUFFER, this._texCoords, gl.DYNAMIC_DRAW);
  16110. gl.bindBuffer(gl.ARRAY_BUFFER, this._colorPointerBuffer);
  16111. gl.bufferData(gl.ARRAY_BUFFER, this._colorPointer, gl.DYNAMIC_DRAW);
  16112. return !0
  16113. },
  16114. tintWithColor: function(a) {
  16115. this.color = a;
  16116. for (var b = this._colorPointer, c = 0, d = 2 * this._nuPoints; c < d; c++) b[4 * c] = a.r, b[4 * c + 1] = a.g, b[4 * c + 2] = a.b
  16117. },
  16118. reset: function() {
  16119. this._nuPoints = 0
  16120. },
  16121. setPosition: function(a,
  16122. b) {
  16123. this.startingPositionInitialized = !0;
  16124. void 0 === b ? (this._positionR.x = a.x, this._positionR.y = a.y) : (this._positionR.x = a, this._positionR.y = b)
  16125. },
  16126. getPositionX: function() {
  16127. return this._positionR.x
  16128. },
  16129. setPositionX: function(a) {
  16130. this._positionR.x = a;
  16131. this.startingPositionInitialized || (this.startingPositionInitialized = !0)
  16132. },
  16133. getPositionY: function() {
  16134. return this._positionR.y
  16135. },
  16136. setPositionY: function(a) {
  16137. this._positionR.y = a;
  16138. this.startingPositionInitialized || (this.startingPositionInitialized = !0)
  16139. },
  16140. update: function(a) {
  16141. if (this.startingPositionInitialized) {
  16142. this._renderCmd._updateDisplayColor();
  16143. a *= this._fadeDelta;
  16144. var b, c, d, e, f = 0,
  16145. g = this._nuPoints,
  16146. h = this._pointState,
  16147. k = this._pointVertexes,
  16148. m = this._vertices,
  16149. n = this._colorPointer;
  16150. for (d = 0; d < g; d++) h[d] -= a, 0 >= h[d] ? f++ : (b = d - f, 0 < f ? (h[b] = h[d], k[2 * b] = k[2 * d], k[2 * b + 1] = k[2 * d + 1], e = 2 * d, c = 2 * b, m[2 * c] = m[2 * e], m[2 * c + 1] = m[2 * e + 1], m[2 * (c + 1)] = m[2 * (e + 1)], m[2 * (c + 1) + 1] = m[2 * (e + 1) + 1], e *= 4, c *= 4, n[c + 0] = n[e + 0], n[c + 1] = n[e + 1], n[c + 2] = n[e + 2], n[c + 4] = n[e + 4], n[c + 5] = n[e + 5], n[c + 6] = n[e + 6]) : c = 8 * b, b = 255 * h[b], n[c + 3] = b, n[c + 7] = b);
  16151. g -= f;
  16152. d = !0;
  16153. g >= this._maxPoints ? d = !1 : 0 < g && (a = cc.pDistanceSQ(cc.p(k[2 *
  16154. (g - 1)], k[2 * (g - 1) + 1]), this._positionR) < this._minSeg, c = 1 === g ? !1 : cc.pDistanceSQ(cc.p(k[2 * (g - 2)], k[2 * (g - 2) + 1]), this._positionR) < 2 * this._minSeg, a || c) && (d = !1);
  16155. d && (k[2 * g] = this._positionR.x, k[2 * g + 1] = this._positionR.y, h[g] = 1, h = 8 * g, d = this.getDisplayedColor(), n[h] = d.r, n[h + 1] = d.g, n[h + 2] = d.b, n[h + 4] = d.r, n[h + 5] = d.g, n[h + 6] = d.b, n[h + 3] = 255, n[h + 7] = 255, 0 < g && this.fastMode && (1 < g ? cc.vertexLineToPolygon(k, this._stroke, this._vertices, g, 1) : cc.vertexLineToPolygon(k, this._stroke, this._vertices, 0, 2)), g++);
  16156. this.fastMode || cc.vertexLineToPolygon(k,
  16157. this._stroke, this._vertices, 0, g);
  16158. if (g && this._previousNuPoints !== g) {
  16159. k = 1 / g;
  16160. n = this._texCoords;
  16161. for (d = 0; d < g; d++) n[4 * d] = 0, n[4 * d + 1] = k * d, n[2 * (2 * d + 1)] = 1, n[2 * (2 * d + 1) + 1] = k * d;
  16162. this._previousNuPoints = g
  16163. }
  16164. this._nuPoints = g
  16165. }
  16166. },
  16167. _createRenderCmd: function() {
  16168. return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.MotionStreak.WebGLRenderCmd(this) : null
  16169. }
  16170. });
  16171. cc.MotionStreak.create = function(a, b, c, d, e) {
  16172. return new cc.MotionStreak(a, b, c, d, e)
  16173. };
  16174. cc.MotionStreak.WebGLRenderCmd = function(a) {
  16175. cc.Node.WebGLRenderCmd.call(this, a);
  16176. this._needDraw = !0;
  16177. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  16178. };
  16179. cc.MotionStreak.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  16180. cc.MotionStreak.WebGLRenderCmd.prototype.constructor = cc.Sprite.WebGLRenderCmd;
  16181. cc.MotionStreak.WebGLRenderCmd.prototype.rendering = function(a) {
  16182. var b = this._node;
  16183. 1 >= b._nuPoints || !b.texture || !b.texture.isLoaded() || (a = a || cc._renderContext, this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), cc.glBlendFunc(b._blendFunc.src, b._blendFunc.dst), cc.glBindTexture2D(b.texture), a.bindBuffer(a.ARRAY_BUFFER, b._verticesBuffer), a.bufferData(a.ARRAY_BUFFER, b._vertices, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
  16184. 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, b._texCoordsBuffer), a.bufferData(a.ARRAY_BUFFER, b._texCoords, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, 0), a.bindBuffer(a.ARRAY_BUFFER, b._colorPointerBuffer), a.bufferData(a.ARRAY_BUFFER, b._colorPointer, a.DYNAMIC_DRAW), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0), a.drawArrays(a.TRIANGLE_STRIP, 0, 2 * b._nuPoints), cc.g_NumberOfDraws++)
  16185. };
  16186. cc.NodeGrid = cc.Node.extend({
  16187. grid: null,
  16188. _target: null,
  16189. getGrid: function() {
  16190. return this.grid
  16191. },
  16192. setGrid: function(a) {
  16193. this.grid = a
  16194. },
  16195. setTarget: function(a) {
  16196. this._target = a
  16197. },
  16198. _transformForWebGL: function() {
  16199. var a = this._transform4x4,
  16200. b = cc.current_stack.top,
  16201. c = this.getNodeToParentTransform(),
  16202. d = a.mat;
  16203. d[0] = c.a;
  16204. d[4] = c.c;
  16205. d[12] = c.tx;
  16206. d[1] = c.b;
  16207. d[5] = c.d;
  16208. d[13] = c.ty;
  16209. d[14] = this._vertexZ;
  16210. b.multiply(a);
  16211. null === this._camera || this.grid && this.grid.isActive() || (b = this._renderCmd._anchorPointInPoints, a = b.x, b = b.y, 0 !== a || 0 !== b ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL ||
  16212. (a |= 0, b |= 0), cc.kmGLTranslatef(a, b, 0), this._camera.locate(), cc.kmGLTranslatef(-a, -b, 0)) : this._camera.locate())
  16213. },
  16214. _createRenderCmd: function() {
  16215. return cc._renderType === cc._RENDER_TYPE_WEBGL ? new cc.NodeGrid.WebGLRenderCmd(this) : new cc.Node.CanvasRenderCmd(this)
  16216. }
  16217. });
  16218. _p = cc.NodeGrid.prototype;
  16219. cc.defineGetterSetter(_p, "target", null, _p.setTarget);
  16220. cc.NodeGrid.create = function() {
  16221. return new cc.NodeGrid
  16222. };
  16223. (function() {
  16224. cc.NodeGrid.WebGLRenderCmd = function(a) {
  16225. cc.Node.WebGLRenderCmd.call(this, a);
  16226. this._needDraw = !1;
  16227. this._gridBeginCommand = new cc.CustomRenderCmd(this, this.onGridBeginDraw);
  16228. this._gridEndCommand = new cc.CustomRenderCmd(this, this.onGridEndDraw)
  16229. };
  16230. var a = cc.NodeGrid.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  16231. a.constructor = cc.NodeGrid.WebGLRenderCmd;
  16232. a.visit = function(a) {
  16233. var c = this._node;
  16234. if (c._visible) {
  16235. a = a || this.getParentRenderCmd();
  16236. c._parent && c._parent._renderCmd && (this._curLevel =
  16237. c._parent._renderCmd._curLevel + 1);
  16238. var d = cc.current_stack;
  16239. d.stack.push(d.top);
  16240. this._syncStatus(a);
  16241. d.top = this._stackMatrix;
  16242. cc.renderer.pushRenderCommand(this._gridBeginCommand);
  16243. c._target && c._target.visit();
  16244. if ((a = c._children) && 0 < a.length) {
  16245. var e = a.length;
  16246. c.sortAllChildren();
  16247. for (c = 0; c < e; c++) {
  16248. var f = a[c];
  16249. f && f.visit()
  16250. }
  16251. }
  16252. cc.renderer.pushRenderCommand(this._gridEndCommand);
  16253. this._dirtyFlag = 0;
  16254. d.top = d.stack.pop()
  16255. }
  16256. };
  16257. a.onGridBeginDraw = function() {
  16258. var a = this._node.grid;
  16259. a && a._active && a.beforeDraw()
  16260. };
  16261. a.onGridEndDraw =
  16262. function() {
  16263. var a = this._node.grid;
  16264. a && a._active && a.afterDraw(this._node)
  16265. }
  16266. })();
  16267. cc.v2fzero = function() {
  16268. return {
  16269. x: 0,
  16270. y: 0
  16271. }
  16272. };
  16273. cc.v2f = function(a, b) {
  16274. return {
  16275. x: a,
  16276. y: b
  16277. }
  16278. };
  16279. cc.v2fadd = function(a, b) {
  16280. return cc.v2f(a.x + b.x, a.y + b.y)
  16281. };
  16282. cc.v2fsub = function(a, b) {
  16283. return cc.v2f(a.x - b.x, a.y - b.y)
  16284. };
  16285. cc.v2fmult = function(a, b) {
  16286. return cc.v2f(a.x * b, a.y * b)
  16287. };
  16288. cc.v2fperp = function(a) {
  16289. return cc.v2f(-a.y, a.x)
  16290. };
  16291. cc.v2fneg = function(a) {
  16292. return cc.v2f(-a.x, -a.y)
  16293. };
  16294. cc.v2fdot = function(a, b) {
  16295. return a.x * b.x + a.y * b.y
  16296. };
  16297. cc.v2fforangle = function(a) {
  16298. return cc.v2f(Math.cos(a), Math.sin(a))
  16299. };
  16300. cc.v2fnormalize = function(a) {
  16301. a = cc.pNormalize(cc.p(a.x, a.y));
  16302. return cc.v2f(a.x, a.y)
  16303. };
  16304. cc.__v2f = function(a) {
  16305. return cc.v2f(a.x, a.y)
  16306. };
  16307. cc.__t = function(a) {
  16308. return {
  16309. u: a.x,
  16310. v: a.y
  16311. }
  16312. };
  16313. cc.DrawNodeCanvas = cc.Node.extend({
  16314. _buffer: null,
  16315. _blendFunc: null,
  16316. _lineWidth: 1,
  16317. _drawColor: null,
  16318. _className: "DrawNodeCanvas",
  16319. ctor: function() {
  16320. cc.Node.prototype.ctor.call(this);
  16321. var a = this._renderCmd;
  16322. a._buffer = this._buffer = [];
  16323. a._drawColor = this._drawColor = cc.color(255, 255, 255, 255);
  16324. a._blendFunc = this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  16325. this.init()
  16326. },
  16327. getBlendFunc: function() {
  16328. return this._blendFunc
  16329. },
  16330. setBlendFunc: function(a, b) {
  16331. void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src =
  16332. a, this._blendFunc.dst = b)
  16333. },
  16334. setLineWidth: function(a) {
  16335. this._lineWidth = a
  16336. },
  16337. getLineWidth: function() {
  16338. return this._lineWidth
  16339. },
  16340. setDrawColor: function(a) {
  16341. var b = this._drawColor;
  16342. b.r = a.r;
  16343. b.g = a.g;
  16344. b.b = a.b;
  16345. b.a = null == a.a ? 255 : a.a
  16346. },
  16347. getDrawColor: function() {
  16348. return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a)
  16349. },
  16350. drawRect: function(a, b, c, d, e) {
  16351. d = null == d ? this._lineWidth : d;
  16352. e = e || this.getDrawColor();
  16353. null == e.a && (e.a = 255);
  16354. a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)];
  16355. b = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16356. b.verts = a;
  16357. b.lineWidth = d;
  16358. b.lineColor = e;
  16359. b.isClosePolygon = !0;
  16360. b.isStroke = !0;
  16361. b.lineCap = "butt";
  16362. if (b.fillColor = c) null == c.a && (c.a = 255), b.isFill = !0;
  16363. this._buffer.push(b)
  16364. },
  16365. drawCircle: function(a, b, c, d, e, f, g) {
  16366. f = f || this._lineWidth;
  16367. g = g || this.getDrawColor();
  16368. null == g.a && (g.a = 255);
  16369. for (var h = 2 * Math.PI / d, k = [], m = 0; m <= d; m++) {
  16370. var n = m * h,
  16371. p = b * Math.cos(n + c) + a.x,
  16372. n = b * Math.sin(n + c) + a.y;
  16373. k.push(cc.p(p, n))
  16374. }
  16375. e && k.push(cc.p(a.x, a.y));
  16376. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16377. a.verts = k;
  16378. a.lineWidth = f;
  16379. a.lineColor = g;
  16380. a.isClosePolygon = !0;
  16381. a.isStroke = !0;
  16382. this._buffer.push(a)
  16383. },
  16384. drawQuadBezier: function(a, b, c, d, e, f) {
  16385. e = e || this._lineWidth;
  16386. f = f || this.getDrawColor();
  16387. null == f.a && (f.a = 255);
  16388. for (var g = [], h = 0, k = 0; k < d; k++) {
  16389. var m = Math.pow(1 - h, 2) * a.x + 2 * (1 - h) * h * b.x + h * h * c.x,
  16390. n = Math.pow(1 - h, 2) * a.y + 2 * (1 - h) * h * b.y + h * h * c.y;
  16391. g.push(cc.p(m, n));
  16392. h += 1 / d
  16393. }
  16394. g.push(cc.p(c.x, c.y));
  16395. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16396. a.verts = g;
  16397. a.lineWidth = e;
  16398. a.lineColor = f;
  16399. a.isStroke = !0;
  16400. a.lineCap = "round";
  16401. this._buffer.push(a)
  16402. },
  16403. drawCubicBezier: function(a, b, c, d, e, f, g) {
  16404. f = f || this._lineWidth;
  16405. g = g || this.getDrawColor();
  16406. null == g.a && (g.a = 255);
  16407. for (var h = [], k = 0, m = 0; m < e; m++) {
  16408. var n = Math.pow(1 - k, 3) * a.x + 3 * Math.pow(1 - k, 2) * k * b.x + 3 * (1 - k) * k * k * c.x + k * k * k * d.x,
  16409. p = Math.pow(1 - k, 3) * a.y + 3 * Math.pow(1 - k, 2) * k * b.y + 3 * (1 - k) * k * k * c.y + k * k * k * d.y;
  16410. h.push(cc.p(n, p));
  16411. k += 1 / e
  16412. }
  16413. h.push(cc.p(d.x, d.y));
  16414. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16415. a.verts = h;
  16416. a.lineWidth = f;
  16417. a.lineColor = g;
  16418. a.isStroke = !0;
  16419. a.lineCap = "round";
  16420. this._buffer.push(a)
  16421. },
  16422. drawCatmullRom: function(a, b, c, d) {
  16423. this.drawCardinalSpline(a, 0.5, b, c, d)
  16424. },
  16425. drawCardinalSpline: function(a,
  16426. b, c, d, e) {
  16427. d = d || this._lineWidth;
  16428. e = e || this.getDrawColor();
  16429. null == e.a && (e.a = 255);
  16430. for (var f = [], g, h, k = 1 / a.length, m = 0; m < c + 1; m++) h = m / c, 1 === h ? (g = a.length - 1, h = 1) : (g = 0 | h / k, h = (h - k * g) / k), g = cc.cardinalSplineAt(cc.getControlPointAt(a, g - 1), cc.getControlPointAt(a, g - 0), cc.getControlPointAt(a, g + 1), cc.getControlPointAt(a, g + 2), b, h), f.push(g);
  16431. a = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16432. a.verts = f;
  16433. a.lineWidth = d;
  16434. a.lineColor = e;
  16435. a.isStroke = !0;
  16436. a.lineCap = "round";
  16437. this._buffer.push(a)
  16438. },
  16439. drawDot: function(a, b, c) {
  16440. c = c || this.getDrawColor();
  16441. null == c.a && (c.a = 255);
  16442. var d = new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);
  16443. d.verts = [a];
  16444. d.lineWidth = b;
  16445. d.fillColor = c;
  16446. this._buffer.push(d)
  16447. },
  16448. drawDots: function(a, b, c) {
  16449. if (a && 0 != a.length) {
  16450. c = c || this.getDrawColor();
  16451. null == c.a && (c.a = 255);
  16452. for (var d = 0, e = a.length; d < e; d++) this.drawDot(a[d], b, c)
  16453. }
  16454. },
  16455. drawSegment: function(a, b, c, d) {
  16456. c = c || this._lineWidth;
  16457. d = d || this.getDrawColor();
  16458. null == d.a && (d.a = 255);
  16459. var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16460. e.verts = [a, b];
  16461. e.lineWidth = 2 * c;
  16462. e.lineColor = d;
  16463. e.isStroke = !0;
  16464. e.lineCap = "round";
  16465. this._buffer.push(e)
  16466. },
  16467. drawPoly_: function(a, b, c, d) {
  16468. c = null == c ? this._lineWidth : c;
  16469. d = d || this.getDrawColor();
  16470. null == d.a && (d.a = 255);
  16471. var e = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
  16472. e.verts = a;
  16473. e.fillColor = b;
  16474. e.lineWidth = c;
  16475. e.lineColor = d;
  16476. e.isClosePolygon = !0;
  16477. e.isStroke = !0;
  16478. e.lineCap = "round";
  16479. b && (e.isFill = !0);
  16480. this._buffer.push(e)
  16481. },
  16482. drawPoly: function(a, b, c, d) {
  16483. for (var e = [], f = 0; f < a.length; f++) e.push(cc.p(a[f].x, a[f].y));
  16484. return this.drawPoly_(e, b, c, d)
  16485. },
  16486. clear: function() {
  16487. this._buffer.length = 0
  16488. },
  16489. _createRenderCmd: function() {
  16490. return new cc.DrawNode.CanvasRenderCmd(this)
  16491. }
  16492. });
  16493. cc.DrawNodeWebGL = cc.Node.extend({
  16494. _bufferCapacity: 0,
  16495. _buffer: null,
  16496. _trianglesArrayBuffer: null,
  16497. _trianglesWebBuffer: null,
  16498. _trianglesReader: null,
  16499. _lineWidth: 1,
  16500. _drawColor: null,
  16501. _blendFunc: null,
  16502. _dirty: !1,
  16503. _className: "DrawNodeWebGL",
  16504. getBlendFunc: function() {
  16505. return this._blendFunc
  16506. },
  16507. setBlendFunc: function(a, b) {
  16508. void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.dst = b)
  16509. },
  16510. ctor: function() {
  16511. cc.Node.prototype.ctor.call(this);
  16512. this._buffer = [];
  16513. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC,
  16514. cc.BLEND_DST);
  16515. this._drawColor = cc.color(255, 255, 255, 255);
  16516. this.init()
  16517. },
  16518. init: function() {
  16519. 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
  16520. },
  16521. setLineWidth: function(a) {
  16522. this._lineWidth = a
  16523. },
  16524. getLineWidth: function() {
  16525. return this._lineWidth
  16526. },
  16527. setDrawColor: function(a) {
  16528. var b = this._drawColor;
  16529. b.r = a.r;
  16530. b.g = a.g;
  16531. b.b = a.b;
  16532. b.a = a.a
  16533. },
  16534. getDrawColor: function() {
  16535. return cc.color(this._drawColor.r,
  16536. this._drawColor.g, this._drawColor.b, this._drawColor.a)
  16537. },
  16538. drawRect: function(a, b, c, d, e) {
  16539. d = null == d ? this._lineWidth : d;
  16540. e = e || this.getDrawColor();
  16541. null == e.a && (e.a = 255);
  16542. a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)];
  16543. null == c ? this._drawSegments(a, d, e, !0) : this.drawPoly(a, c, d, e)
  16544. },
  16545. drawCircle: function(a, b, c, d, e, f, g) {
  16546. f = f || this._lineWidth;
  16547. g = g || this.getDrawColor();
  16548. null == g.a && (g.a = 255);
  16549. var h = 2 * Math.PI / d,
  16550. k = [],
  16551. m;
  16552. for (m = 0; m <= d; m++) {
  16553. var n = m * h,
  16554. p = b * Math.cos(n + c) + a.x,
  16555. n = b * Math.sin(n + c) + a.y;
  16556. k.push(cc.p(p, n))
  16557. }
  16558. e && k.push(cc.p(a.x, a.y));
  16559. f *=
  16560. 0.5;
  16561. m = 0;
  16562. for (a = k.length; m < a - 1; m++) this.drawSegment(k[m], k[m + 1], f, g)
  16563. },
  16564. drawQuadBezier: function(a, b, c, d, e, f) {
  16565. e = e || this._lineWidth;
  16566. f = f || this.getDrawColor();
  16567. null == f.a && (f.a = 255);
  16568. for (var g = [], h = 0, k = 0; k < d; k++) {
  16569. var m = Math.pow(1 - h, 2) * a.x + 2 * (1 - h) * h * b.x + h * h * c.x,
  16570. n = Math.pow(1 - h, 2) * a.y + 2 * (1 - h) * h * b.y + h * h * c.y;
  16571. g.push(cc.p(m, n));
  16572. h += 1 / d
  16573. }
  16574. g.push(cc.p(c.x, c.y));
  16575. this._drawSegments(g, e, f, !1)
  16576. },
  16577. drawCubicBezier: function(a, b, c, d, e, f, g) {
  16578. f = f || this._lineWidth;
  16579. g = g || this.getDrawColor();
  16580. null == g.a && (g.a = 255);
  16581. for (var h = [], k = 0, m = 0; m <
  16582. e; m++) {
  16583. var n = Math.pow(1 - k, 3) * a.x + 3 * Math.pow(1 - k, 2) * k * b.x + 3 * (1 - k) * k * k * c.x + k * k * k * d.x,
  16584. p = Math.pow(1 - k, 3) * a.y + 3 * Math.pow(1 - k, 2) * k * b.y + 3 * (1 - k) * k * k * c.y + k * k * k * d.y;
  16585. h.push(cc.p(n, p));
  16586. k += 1 / e
  16587. }
  16588. h.push(cc.p(d.x, d.y));
  16589. this._drawSegments(h, f, g, !1)
  16590. },
  16591. drawCatmullRom: function(a, b, c, d) {
  16592. this.drawCardinalSpline(a, 0.5, b, c, d)
  16593. },
  16594. drawCardinalSpline: function(a, b, c, d, e) {
  16595. d = d || this._lineWidth;
  16596. e = e || this.getDrawColor();
  16597. null == e.a && (e.a = 255);
  16598. for (var f = [], g, h, k = 1 / a.length, m = 0; m < c + 1; m++) h = m / c, 1 === h ? (g = a.length - 1, h = 1) : (g = 0 | h / k, h = (h - k * g) /
  16599. k), g = cc.cardinalSplineAt(cc.getControlPointAt(a, g - 1), cc.getControlPointAt(a, g - 0), cc.getControlPointAt(a, g + 1), cc.getControlPointAt(a, g + 2), b, h), f.push(g);
  16600. d *= 0.5;
  16601. a = 0;
  16602. for (b = f.length; a < b - 1; a++) this.drawSegment(f[a], f[a + 1], d, e)
  16603. },
  16604. _render: function() {
  16605. var a = cc._renderContext;
  16606. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  16607. a.bindBuffer(a.ARRAY_BUFFER, this._trianglesWebBuffer);
  16608. this._dirty && (a.bufferData(a.ARRAY_BUFFER, this._trianglesArrayBuffer, a.STREAM_DRAW), this._dirty = !1);
  16609. var b = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  16610. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, b, 0);
  16611. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, b, 8);
  16612. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, b, 12);
  16613. a.drawArrays(a.TRIANGLES, 0, 3 * this._buffer.length);
  16614. cc.incrementGLDraws(1)
  16615. },
  16616. _ensureCapacity: function(a) {
  16617. var b = this._buffer;
  16618. if (b.length + a > this._bufferCapacity) {
  16619. var c = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
  16620. this._bufferCapacity += Math.max(this._bufferCapacity, a);
  16621. if (null == b || 0 === b.length) this._buffer = [], this._trianglesArrayBuffer = new ArrayBuffer(c * this._bufferCapacity), this._trianglesReader = new Uint8Array(this._trianglesArrayBuffer);
  16622. else {
  16623. a = [];
  16624. for (var d = new ArrayBuffer(c * this._bufferCapacity), e = 0; e < b.length; e++) a[e] = new cc.V2F_C4B_T2F_Triangle(b[e].a, b[e].b, b[e].c, d, e * c);
  16625. this._trianglesReader = new Uint8Array(d);
  16626. this._trianglesArrayBuffer = d;
  16627. this._buffer = a
  16628. }
  16629. }
  16630. },
  16631. drawDot: function(a, b, c) {
  16632. c = c || this.getDrawColor();
  16633. null == c.a && (c.a = 255);
  16634. var d = {
  16635. r: 0 | c.r,
  16636. g: 0 | c.g,
  16637. b: 0 | c.b,
  16638. a: 0 | c.a
  16639. };
  16640. c = {
  16641. vertices: {
  16642. x: a.x - b,
  16643. y: a.y - b
  16644. },
  16645. colors: d,
  16646. texCoords: {
  16647. u: -1,
  16648. v: -1
  16649. }
  16650. };
  16651. var e = {
  16652. vertices: {
  16653. x: a.x - b,
  16654. y: a.y + b
  16655. },
  16656. colors: d,
  16657. texCoords: {
  16658. u: -1,
  16659. v: 1
  16660. }
  16661. },
  16662. f = {
  16663. vertices: {
  16664. x: a.x + b,
  16665. y: a.y + b
  16666. },
  16667. colors: d,
  16668. texCoords: {
  16669. u: 1,
  16670. v: 1
  16671. }
  16672. };
  16673. a = {
  16674. vertices: {
  16675. x: a.x + b,
  16676. y: a.y - b
  16677. },
  16678. colors: d,
  16679. texCoords: {
  16680. u: 1,
  16681. v: -1
  16682. }
  16683. };
  16684. this._ensureCapacity(6);
  16685. this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c, e, f, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));
  16686. this._buffer.push(new cc.V2F_C4B_T2F_Triangle(c, f, a, this._trianglesArrayBuffer, this._buffer.length * cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT));
  16687. this._dirty = !0
  16688. },
  16689. drawDots: function(a, b, c) {
  16690. if (a && 0 !== a.length) {
  16691. c = c || this.getDrawColor();
  16692. null == c.a && (c.a = 255);
  16693. for (var d = 0, e = a.length; d < e; d++) this.drawDot(a[d], b, c)
  16694. }
  16695. },
  16696. drawSegment: function(a, b, c, d) {
  16697. d = d || this.getDrawColor();
  16698. null == d.a && (d.a = 255);
  16699. c = c || 0.5 * this._lineWidth;
  16700. this._ensureCapacity(18);
  16701. d = {
  16702. r: 0 | d.r,
  16703. g: 0 | d.g,
  16704. b: 0 | d.b,
  16705. a: 0 | d.a
  16706. };
  16707. var e = cc.__v2f(a),
  16708. f = cc.__v2f(b);
  16709. b = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(f, e)));
  16710. a = cc.v2fperp(b);
  16711. var g = cc.v2fmult(b, c),
  16712. h = cc.v2fmult(a, c);
  16713. c = cc.v2fsub(f, cc.v2fadd(g, h));
  16714. var k = cc.v2fadd(f,
  16715. cc.v2fsub(g, h)),
  16716. m = cc.v2fsub(f, g),
  16717. f = cc.v2fadd(f, g),
  16718. n = cc.v2fsub(e, g),
  16719. p = cc.v2fadd(e, g),
  16720. t = cc.v2fsub(e, cc.v2fsub(g, h)),
  16721. e = cc.v2fadd(e, cc.v2fadd(g, h)),
  16722. g = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
  16723. h = this._trianglesArrayBuffer,
  16724. r = this._buffer;
  16725. r.push(new cc.V2F_C4B_T2F_Triangle({
  16726. vertices: c,
  16727. colors: d,
  16728. texCoords: cc.__t(cc.v2fneg(cc.v2fadd(b, a)))
  16729. }, {
  16730. vertices: k,
  16731. colors: d,
  16732. texCoords: cc.__t(cc.v2fsub(b, a))
  16733. }, {
  16734. vertices: m,
  16735. colors: d,
  16736. texCoords: cc.__t(cc.v2fneg(b))
  16737. }, h, r.length * g));
  16738. r.push(new cc.V2F_C4B_T2F_Triangle({
  16739. vertices: f,
  16740. colors: d,
  16741. texCoords: cc.__t(b)
  16742. }, {
  16743. vertices: k,
  16744. colors: d,
  16745. texCoords: cc.__t(cc.v2fsub(b, a))
  16746. }, {
  16747. vertices: m,
  16748. colors: d,
  16749. texCoords: cc.__t(cc.v2fneg(b))
  16750. }, h, r.length * g));
  16751. r.push(new cc.V2F_C4B_T2F_Triangle({
  16752. vertices: f,
  16753. colors: d,
  16754. texCoords: cc.__t(b)
  16755. }, {
  16756. vertices: n,
  16757. colors: d,
  16758. texCoords: cc.__t(cc.v2fneg(b))
  16759. }, {
  16760. vertices: m,
  16761. colors: d,
  16762. texCoords: cc.__t(cc.v2fneg(b))
  16763. }, h, r.length * g));
  16764. r.push(new cc.V2F_C4B_T2F_Triangle({
  16765. vertices: f,
  16766. colors: d,
  16767. texCoords: cc.__t(b)
  16768. }, {
  16769. vertices: n,
  16770. colors: d,
  16771. texCoords: cc.__t(cc.v2fneg(b))
  16772. }, {
  16773. vertices: p,
  16774. colors: d,
  16775. texCoords: cc.__t(b)
  16776. }, h, r.length * g));
  16777. r.push(new cc.V2F_C4B_T2F_Triangle({
  16778. vertices: t,
  16779. colors: d,
  16780. texCoords: cc.__t(cc.v2fsub(a, b))
  16781. }, {
  16782. vertices: n,
  16783. colors: d,
  16784. texCoords: cc.__t(cc.v2fneg(b))
  16785. }, {
  16786. vertices: p,
  16787. colors: d,
  16788. texCoords: cc.__t(b)
  16789. }, h, r.length * g));
  16790. r.push(new cc.V2F_C4B_T2F_Triangle({
  16791. vertices: t,
  16792. colors: d,
  16793. texCoords: cc.__t(cc.v2fsub(a, b))
  16794. }, {
  16795. vertices: e,
  16796. colors: d,
  16797. texCoords: cc.__t(cc.v2fadd(b, a))
  16798. }, {
  16799. vertices: p,
  16800. colors: d,
  16801. texCoords: cc.__t(b)
  16802. }, h, r.length * g));
  16803. this._dirty = !0
  16804. },
  16805. drawPoly: function(a, b, c, d) {
  16806. if (null == b) this._drawSegments(a,
  16807. c, d, !0);
  16808. else {
  16809. null == b.a && (b.a = 255);
  16810. null == d.a && (d.a = 255);
  16811. c = null == c ? this._lineWidth : c;
  16812. c *= 0.5;
  16813. b = {
  16814. r: 0 | b.r,
  16815. g: 0 | b.g,
  16816. b: 0 | b.b,
  16817. a: 0 | b.a
  16818. };
  16819. d = {
  16820. r: 0 | d.r,
  16821. g: 0 | d.g,
  16822. b: 0 | d.b,
  16823. a: 0 | d.a
  16824. };
  16825. var e = [],
  16826. f, g, h, k, m = a.length;
  16827. for (f = 0; f < m; f++) {
  16828. g = cc.__v2f(a[(f - 1 + m) % m]);
  16829. h = cc.__v2f(a[f]);
  16830. k = cc.__v2f(a[(f + 1) % m]);
  16831. var n = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h, g)));
  16832. h = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
  16833. n = cc.v2fmult(cc.v2fadd(n, h), 1 / (cc.v2fdot(n, h) + 1));
  16834. e[f] = {
  16835. offset: n,
  16836. n: h
  16837. }
  16838. }
  16839. n = 0 < c;
  16840. this._ensureCapacity(3 * (3 * m - 2));
  16841. var p = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,
  16842. t = this._trianglesArrayBuffer,
  16843. r = this._buffer,
  16844. u = !1 == n ? 0.5 : 0;
  16845. for (f = 0; f < m - 2; f++) g = cc.v2fsub(cc.__v2f(a[0]), cc.v2fmult(e[0].offset, u)), h = cc.v2fsub(cc.__v2f(a[f + 1]), cc.v2fmult(e[f + 1].offset, u)), k = cc.v2fsub(cc.__v2f(a[f + 2]), cc.v2fmult(e[f + 2].offset, u)), r.push(new cc.V2F_C4B_T2F_Triangle({
  16846. vertices: g,
  16847. colors: b,
  16848. texCoords: cc.__t(cc.v2fzero())
  16849. }, {
  16850. vertices: h,
  16851. colors: b,
  16852. texCoords: cc.__t(cc.v2fzero())
  16853. }, {
  16854. vertices: k,
  16855. colors: b,
  16856. texCoords: cc.__t(cc.v2fzero())
  16857. }, t, r.length * p));
  16858. for (f = 0; f < m; f++) {
  16859. u = (f + 1) % m;
  16860. g = cc.__v2f(a[f]);
  16861. h =
  16862. cc.__v2f(a[u]);
  16863. k = e[f].n;
  16864. var s = e[f].offset,
  16865. v = e[u].offset,
  16866. u = n ? cc.v2fsub(g, cc.v2fmult(s, c)) : cc.v2fsub(g, cc.v2fmult(s, 0.5)),
  16867. x = n ? cc.v2fsub(h, cc.v2fmult(v, c)) : cc.v2fsub(h, cc.v2fmult(v, 0.5));
  16868. g = n ? cc.v2fadd(g, cc.v2fmult(s, c)) : cc.v2fadd(g, cc.v2fmult(s, 0.5));
  16869. h = n ? cc.v2fadd(h, cc.v2fmult(v, c)) : cc.v2fadd(h, cc.v2fmult(v, 0.5));
  16870. n ? (r.push(new cc.V2F_C4B_T2F_Triangle({
  16871. vertices: u,
  16872. colors: d,
  16873. texCoords: cc.__t(cc.v2fneg(k))
  16874. }, {
  16875. vertices: x,
  16876. colors: d,
  16877. texCoords: cc.__t(cc.v2fneg(k))
  16878. }, {
  16879. vertices: h,
  16880. colors: d,
  16881. texCoords: cc.__t(k)
  16882. }, t, r.length *
  16883. p)), r.push(new cc.V2F_C4B_T2F_Triangle({
  16884. vertices: u,
  16885. colors: d,
  16886. texCoords: cc.__t(cc.v2fneg(k))
  16887. }, {
  16888. vertices: g,
  16889. colors: d,
  16890. texCoords: cc.__t(k)
  16891. }, {
  16892. vertices: h,
  16893. colors: d,
  16894. texCoords: cc.__t(k)
  16895. }, t, r.length * p))) : (r.push(new cc.V2F_C4B_T2F_Triangle({
  16896. vertices: u,
  16897. colors: b,
  16898. texCoords: cc.__t(cc.v2fzero())
  16899. }, {
  16900. vertices: x,
  16901. colors: b,
  16902. texCoords: cc.__t(cc.v2fzero())
  16903. }, {
  16904. vertices: h,
  16905. colors: b,
  16906. texCoords: cc.__t(k)
  16907. }, t, r.length * p)), r.push(new cc.V2F_C4B_T2F_Triangle({
  16908. vertices: u,
  16909. colors: b,
  16910. texCoords: cc.__t(cc.v2fzero())
  16911. }, {
  16912. vertices: g,
  16913. colors: b,
  16914. texCoords: cc.__t(k)
  16915. }, {
  16916. vertices: h,
  16917. colors: b,
  16918. texCoords: cc.__t(k)
  16919. }, t, r.length * p)))
  16920. }
  16921. this._dirty = !0
  16922. }
  16923. },
  16924. _drawSegments: function(a, b, c, d) {
  16925. b = null == b ? this._lineWidth : b;
  16926. c = c || this._drawColor;
  16927. null == c.a && (c.a = 255);
  16928. b *= 0.5;
  16929. if (!(0 >= b)) {
  16930. c = {
  16931. r: 0 | c.r,
  16932. g: 0 | c.g,
  16933. b: 0 | c.b,
  16934. a: 0 | c.a
  16935. };
  16936. var e = [],
  16937. f, g, h, k, m = a.length;
  16938. for (f = 0; f < m; f++) {
  16939. g = cc.__v2f(a[(f - 1 + m) % m]);
  16940. h = cc.__v2f(a[f]);
  16941. k = cc.__v2f(a[(f + 1) % m]);
  16942. var n = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h, g)));
  16943. h = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(k, h)));
  16944. k = cc.v2fmult(cc.v2fadd(n, h), 1 / (cc.v2fdot(n, h) + 1));
  16945. e[f] = {
  16946. offset: k,
  16947. n: h
  16948. }
  16949. }
  16950. this._ensureCapacity(3 * (3 * m - 2));
  16951. k = cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;
  16952. var n = this._trianglesArrayBuffer,
  16953. p = this._buffer;
  16954. d = d ? m : m - 1;
  16955. for (f = 0; f < d; f++) {
  16956. var t = (f + 1) % m;
  16957. g = cc.__v2f(a[f]);
  16958. h = cc.__v2f(a[t]);
  16959. var r = e[f].n,
  16960. u = e[f].offset,
  16961. s = e[t].offset,
  16962. t = cc.v2fsub(g, cc.v2fmult(u, b)),
  16963. v = cc.v2fsub(h, cc.v2fmult(s, b));
  16964. g = cc.v2fadd(g, cc.v2fmult(u, b));
  16965. h = cc.v2fadd(h, cc.v2fmult(s, b));
  16966. p.push(new cc.V2F_C4B_T2F_Triangle({
  16967. vertices: t,
  16968. colors: c,
  16969. texCoords: cc.__t(cc.v2fneg(r))
  16970. }, {
  16971. vertices: v,
  16972. colors: c,
  16973. texCoords: cc.__t(cc.v2fneg(r))
  16974. }, {
  16975. vertices: h,
  16976. colors: c,
  16977. texCoords: cc.__t(r)
  16978. }, n, p.length * k));
  16979. p.push(new cc.V2F_C4B_T2F_Triangle({
  16980. vertices: t,
  16981. colors: c,
  16982. texCoords: cc.__t(cc.v2fneg(r))
  16983. }, {
  16984. vertices: g,
  16985. colors: c,
  16986. texCoords: cc.__t(r)
  16987. }, {
  16988. vertices: h,
  16989. colors: c,
  16990. texCoords: cc.__t(r)
  16991. }, n, p.length * k))
  16992. }
  16993. this._dirty = !0
  16994. }
  16995. },
  16996. clear: function() {
  16997. this._buffer.length = 0;
  16998. this._dirty = !0
  16999. },
  17000. _createRenderCmd: function() {
  17001. return new cc.DrawNode.WebGLRenderCmd(this)
  17002. }
  17003. });
  17004. cc.DrawNode = cc._renderType === cc._RENDER_TYPE_WEBGL ? cc.DrawNodeWebGL : cc.DrawNodeCanvas;
  17005. cc.DrawNode.create = function() {
  17006. return new cc.DrawNode
  17007. };
  17008. cc._DrawNodeElement = function(a, b, c, d, e, f, g, h, k) {
  17009. this.type = a;
  17010. this.verts = b || null;
  17011. this.fillColor = c || null;
  17012. this.lineWidth = d || 0;
  17013. this.lineColor = e || null;
  17014. this.lineCap = f || "butt";
  17015. this.isClosePolygon = g || !1;
  17016. this.isFill = h || !1;
  17017. this.isStroke = k || !1
  17018. };
  17019. cc.DrawNode.TYPE_DOT = 0;
  17020. cc.DrawNode.TYPE_SEGMENT = 1;
  17021. cc.DrawNode.TYPE_POLY = 2;
  17022. (function() {
  17023. cc.DrawNode.CanvasRenderCmd = function(a) {
  17024. cc.Node.CanvasRenderCmd.call(this, a);
  17025. this._needDraw = !0;
  17026. this._blendFunc = this._drawColor = this._buffer = null
  17027. };
  17028. cc.DrawNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  17029. cc.DrawNode.CanvasRenderCmd.prototype.constructor = cc.DrawNode.CanvasRenderCmd;
  17030. cc.DrawNode.CanvasRenderCmd.prototype.rendering = function(a, b, c) {
  17031. a = a || cc._renderContext;
  17032. a.getContext();
  17033. var d = this._node._displayedOpacity / 255;
  17034. if (0 !== d) {
  17035. a.setTransform(this._worldTransform,
  17036. b, c);
  17037. a.setGlobalAlpha(d);
  17038. this._blendFunc && this._blendFunc.src === cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE && a.setCompositeOperation("lighter");
  17039. for (var d = this._buffer, e = 0, f = d.length; e < f; e++) {
  17040. var g = d[e];
  17041. switch (g.type) {
  17042. case cc.DrawNode.TYPE_DOT:
  17043. this._drawDot(a, g, b, c);
  17044. break;
  17045. case cc.DrawNode.TYPE_SEGMENT:
  17046. this._drawSegment(a, g, b, c);
  17047. break;
  17048. case cc.DrawNode.TYPE_POLY:
  17049. this._drawPoly(a, g, b, c)
  17050. }
  17051. }
  17052. }
  17053. };
  17054. cc.DrawNode.CanvasRenderCmd.prototype._drawDot = function(a, b, c, d) {
  17055. var e = b.fillColor,
  17056. f = b.verts[0];
  17057. b = b.lineWidth;
  17058. var g =
  17059. a.getContext();
  17060. a.setFillStyle("rgba(" + (0 | e.r) + "," + (0 | e.g) + "," + (0 | e.b) + "," + e.a / 255 + ")");
  17061. g.beginPath();
  17062. g.arc(f.x * c, -f.y * d, b * c, 0, 2 * Math.PI, !1);
  17063. g.closePath();
  17064. g.fill()
  17065. };
  17066. cc.DrawNode.CanvasRenderCmd.prototype._drawSegment = function(a, b, c, d) {
  17067. var e = b.lineColor,
  17068. f = b.verts[0],
  17069. g = b.verts[1],
  17070. h = b.lineWidth;
  17071. b = b.lineCap;
  17072. var k = a.getContext();
  17073. a.setStrokeStyle("rgba(" + (0 | e.r) + "," + (0 | e.g) + "," + (0 | e.b) + "," + e.a / 255 + ")");
  17074. k.lineWidth = h * c;
  17075. k.beginPath();
  17076. k.lineCap = b;
  17077. k.moveTo(f.x * c, -f.y * d);
  17078. k.lineTo(g.x * c, -g.y * d);
  17079. k.stroke()
  17080. };
  17081. cc.DrawNode.CanvasRenderCmd.prototype._drawPoly =
  17082. function(a, b, c, d) {
  17083. var e = b.verts,
  17084. f = b.lineCap;
  17085. if (null != e) {
  17086. var g = b.fillColor,
  17087. h = b.lineWidth,
  17088. k = b.lineColor,
  17089. m = b.isClosePolygon,
  17090. n = b.isFill;
  17091. b = b.isStroke;
  17092. var p = a.getContext(),
  17093. t = e[0];
  17094. p.lineCap = f;
  17095. g && a.setFillStyle("rgba(" + (0 | g.r) + "," + (0 | g.g) + "," + (0 | g.b) + "," + g.a / 255 + ")");
  17096. h && (p.lineWidth = h * c);
  17097. k && a.setStrokeStyle("rgba(" + (0 | k.r) + "," + (0 | k.g) + "," + (0 | k.b) + "," + k.a / 255 + ")");
  17098. p.beginPath();
  17099. p.moveTo(t.x * c, -t.y * d);
  17100. a = 1;
  17101. for (f = e.length; a < f; a++) p.lineTo(e[a].x * c, -e[a].y * d);
  17102. m && p.closePath();
  17103. n && p.fill();
  17104. b && p.stroke()
  17105. }
  17106. }
  17107. })();
  17108. (function() {
  17109. cc.DrawNode.WebGLRenderCmd = function(a) {
  17110. cc.Node.WebGLRenderCmd.call(this, a);
  17111. this._needDraw = !0
  17112. };
  17113. cc.DrawNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  17114. cc.DrawNode.WebGLRenderCmd.prototype.constructor = cc.DrawNode.WebGLRenderCmd;
  17115. cc.DrawNode.WebGLRenderCmd.prototype.rendering = function(a) {
  17116. a = this._node;
  17117. cc.glBlendFunc(a._blendFunc.src, a._blendFunc.dst);
  17118. this._shaderProgram.use();
  17119. this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
  17120. a._render()
  17121. }
  17122. })();
  17123. cc.stencilBits = -1;
  17124. cc.ClippingNode = cc.Node.extend({
  17125. alphaThreshold: 0,
  17126. inverted: !1,
  17127. _stencil: null,
  17128. _className: "ClippingNode",
  17129. ctor: function(a) {
  17130. a = a || null;
  17131. cc.Node.prototype.ctor.call(this);
  17132. this._stencil = a;
  17133. this.alphaThreshold = 1;
  17134. this.inverted = !1;
  17135. this._renderCmd.initStencilBits()
  17136. },
  17137. init: function(a) {
  17138. this._stencil = a;
  17139. this.alphaThreshold = 1;
  17140. this.inverted = !1;
  17141. this._renderCmd.initStencilBits();
  17142. return !0
  17143. },
  17144. onEnter: function() {
  17145. cc.Node.prototype.onEnter.call(this);
  17146. this._stencil.onEnter()
  17147. },
  17148. onEnterTransitionDidFinish: function() {
  17149. cc.Node.prototype.onEnterTransitionDidFinish.call(this);
  17150. this._stencil.onEnterTransitionDidFinish()
  17151. },
  17152. onExitTransitionDidStart: function() {
  17153. this._stencil.onExitTransitionDidStart();
  17154. cc.Node.prototype.onExitTransitionDidStart.call(this)
  17155. },
  17156. onExit: function() {
  17157. this._stencil.onExit();
  17158. cc.Node.prototype.onExit.call(this)
  17159. },
  17160. getAlphaThreshold: function() {
  17161. return this.alphaThreshold
  17162. },
  17163. setAlphaThreshold: function(a) {
  17164. this.alphaThreshold = a
  17165. },
  17166. isInverted: function() {
  17167. return this.inverted
  17168. },
  17169. setInverted: function(a) {
  17170. this.inverted = a
  17171. },
  17172. getStencil: function() {
  17173. return this._stencil
  17174. },
  17175. setStencil: function(a) {
  17176. this._stencil !== a && this._renderCmd.setStencil(a)
  17177. },
  17178. _createRenderCmd: function() {
  17179. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ClippingNode.CanvasRenderCmd(this) : new cc.ClippingNode.WebGLRenderCmd(this)
  17180. }
  17181. });
  17182. _p = cc.ClippingNode.prototype;
  17183. cc.defineGetterSetter(_p, "stencil", _p.getStencil, _p.setStencil);
  17184. cc.ClippingNode.create = function(a) {
  17185. return new cc.ClippingNode(a)
  17186. };
  17187. (function() {
  17188. cc.ClippingNode.CanvasRenderCmd = function(a) {
  17189. cc.Node.CanvasRenderCmd.call(this, a);
  17190. this._clipElemType = this._godhelpme = this._needDraw = !1;
  17191. this._rendererSaveCmd = new cc.CustomRenderCmd(this, this._saveCmdCallback);
  17192. this._rendererClipCmd = new cc.CustomRenderCmd(this, this._clipCmdCallback);
  17193. this._rendererRestoreCmd = new cc.CustomRenderCmd(this, this._restoreCmdCallback)
  17194. };
  17195. var a = cc.ClippingNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  17196. a.constructor = cc.ClippingNode.CanvasRenderCmd;
  17197. a.initStencilBits = function() {};
  17198. a.setStencil = function(a) {
  17199. if (null != a)
  17200. if (this._node._stencil = a, a instanceof cc.DrawNode) {
  17201. if (a._buffer)
  17202. for (var c = 0; c < a._buffer.length; c++) a._buffer[c].isFill = !1, a._buffer[c].isStroke = !1;
  17203. a._renderCmd.rendering = function(c, e, f) {
  17204. e = e || cc.view.getScaleX();
  17205. f = f || cc.view.getScaleY();
  17206. c = c || cc._renderContext;
  17207. var g = c.getContext(),
  17208. h = this._transform;
  17209. c.save();
  17210. g.transform(h.a, h.b, h.c, h.d, h.tx * e, -h.ty * f);
  17211. g.beginPath();
  17212. for (h = 0; h < a._buffer.length; h++) {
  17213. var k = a._buffer[h].verts,
  17214. m = k[0];
  17215. g.moveTo(m.x *
  17216. e, -m.y * f);
  17217. for (var m = 1, n = k.length; m < n; m++) g.lineTo(k[m].x * e, -k[m].y * f)
  17218. }
  17219. c.restore()
  17220. }
  17221. } else a._parent = this._node
  17222. };
  17223. a._saveCmdCallback = function(a, c, d) {
  17224. var e = a || cc._renderContext;
  17225. a = e.getContext();
  17226. this._clipElemType ? (c = cc.ClippingNode.CanvasRenderCmd._getSharedCache(), d = a.canvas, c.width = d.width, c.height = d.height, c.getContext("2d").drawImage(d, 0, 0)) : (e.save(), e.save(), e.setTransform(this._worldTransform, c, d))
  17227. };
  17228. a._setStencilCompositionOperation = function(a) {
  17229. if (a) {
  17230. var c = this._node;
  17231. a._renderCmd && a._renderCmd._blendFuncStr &&
  17232. (a._renderCmd._blendFuncStr = c.inverted ? "destination-out" : "destination-in");
  17233. if (a._children) {
  17234. a = a._children;
  17235. for (var c = 0, d = a.length; c < d; c++) this._setStencilCompositionOperation(a[c])
  17236. }
  17237. }
  17238. };
  17239. a._clipCmdCallback = function(a) {
  17240. var c = this._node;
  17241. a = a || cc._renderContext;
  17242. var d = a.getContext();
  17243. this._clipElemType ? this._setStencilCompositionOperation(c._stencil) : (a.restore(), c.inverted && (c = d.canvas, a.save(), d.setTransform(1, 0, 0, 1, 0, 0), d.moveTo(0, 0), d.lineTo(0, c.height), d.lineTo(c.width, c.height), d.lineTo(c.width, 0), d.lineTo(0,
  17244. 0), a.restore()), d.closePath(), d.clip())
  17245. };
  17246. a._restoreCmdCallback = function(a) {
  17247. var c = cc.ClippingNode.CanvasRenderCmd._getSharedCache();
  17248. a = a || cc._renderContext;
  17249. var d = a.getContext();
  17250. this._clipElemType ? (d.save(), d.setTransform(1, 0, 0, 1, 0, 0), d.globalCompositeOperation = "destination-over", d.drawImage(c, 0, 0), d.restore(), this._dirtyFlag = 0) : a.restore()
  17251. };
  17252. a.transform = function(a, c) {
  17253. cc.Node.CanvasRenderCmd.prototype.transform.call(this, a, c);
  17254. var d = this._node;
  17255. d._stencil && d._stencil._renderCmd && d._stencil._renderCmd.transform(this,
  17256. c)
  17257. };
  17258. a._cangodhelpme = function(a) {
  17259. if (!0 === a || !1 === a) cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme = a;
  17260. return cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme
  17261. };
  17262. a.visit = function(a) {
  17263. var c = this._node;
  17264. if (c._visible) {
  17265. if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1;
  17266. this._clipElemType = !(!this._cangodhelpme() && c._stencil instanceof cc.DrawNode);
  17267. if (c._stencil && c._stencil.visible) {
  17268. this._syncStatus(a);
  17269. cc.renderer.pushRenderCommand(this._rendererSaveCmd);
  17270. this._clipElemType ? cc.Node.CanvasRenderCmd.prototype.visit.call(this,
  17271. a) : c._stencil.visit(this);
  17272. cc.renderer.pushRenderCommand(this._rendererClipCmd);
  17273. if (this._clipElemType) c._stencil.visit(this);
  17274. else {
  17275. a = c._children;
  17276. this._cangodhelpme(!0);
  17277. var d = a.length;
  17278. if (0 < d)
  17279. for (c.sortAllChildren(), c = 0; c < d; c++) a[c]._renderCmd.visit(this);
  17280. this._cangodhelpme(!1)
  17281. }
  17282. cc.renderer.pushRenderCommand(this._rendererRestoreCmd);
  17283. this._dirtyFlag = 0
  17284. } else this.inverted && cc.Node.CanvasRenderCmd.prototype.visit.call(this, a)
  17285. }
  17286. };
  17287. cc.ClippingNode.CanvasRenderCmd._sharedCache = null;
  17288. cc.ClippingNode.CanvasRenderCmd._getSharedCache =
  17289. function() {
  17290. return cc.ClippingNode.CanvasRenderCmd._sharedCache || (cc.ClippingNode.CanvasRenderCmd._sharedCache = document.createElement("canvas"))
  17291. }
  17292. })();
  17293. (function() {
  17294. cc.ClippingNode.WebGLRenderCmd = function(a) {
  17295. cc.Node.WebGLRenderCmd.call(this, a);
  17296. this._needDraw = !1;
  17297. this._beforeVisitCmd = new cc.CustomRenderCmd(this, this._onBeforeVisit);
  17298. this._afterDrawStencilCmd = new cc.CustomRenderCmd(this, this._onAfterDrawStencil);
  17299. this._afterVisitCmd = new cc.CustomRenderCmd(this, this._onAfterVisit);
  17300. this._mask_layer_le = this._currentDepthWriteMask = this._currentStencilEnabled = this._currentStencilWriteMask = this._currentStencilPassDepthPass = this._currentStencilPassDepthFail =
  17301. this._currentStencilFail = this._currentStencilValueMask = this._currentStencilRef = this._currentStencilFunc = null
  17302. };
  17303. var a = cc.ClippingNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  17304. a.constructor = cc.ClippingNode.WebGLRenderCmd;
  17305. cc.ClippingNode.WebGLRenderCmd._init_once = null;
  17306. cc.ClippingNode.WebGLRenderCmd._visit_once = null;
  17307. cc.ClippingNode.WebGLRenderCmd._layer = -1;
  17308. a.initStencilBits = function() {
  17309. cc.ClippingNode.WebGLRenderCmd._init_once = !0;
  17310. cc.ClippingNode.WebGLRenderCmd._init_once &&
  17311. (cc.stencilBits = cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS), 0 >= cc.stencilBits && cc.log("Stencil buffer is not enabled."), cc.ClippingNode.WebGLRenderCmd._init_once = !1)
  17312. };
  17313. a.transform = function(a, c) {
  17314. var d = this._node;
  17315. cc.Node.WebGLRenderCmd.prototype.transform.call(this, a, c);
  17316. d._stencil && d._stencil._renderCmd.transform(this, c)
  17317. };
  17318. a.visit = function(a) {
  17319. var c = this._node;
  17320. if (c._visible)
  17321. if (c._parent && c._parent._renderCmd && (this._curLevel = c._parent._renderCmd._curLevel + 1), 1 > cc.stencilBits) cc.Node.WebGLRenderCmd.prototype.visit.call(this,
  17322. a);
  17323. else if (c._stencil && c._stencil.visible)
  17324. if (cc.ClippingNode.WebGLRenderCmd._layer + 1 === cc.stencilBits) cc.ClippingNode.WebGLRenderCmd._visit_once = !0, cc.ClippingNode.WebGLRenderCmd._visit_once && (cc.log("Nesting more than " + cc.stencilBits + "stencils is not supported. Everything will be drawn without stencil for this node and its children."), cc.ClippingNode.WebGLRenderCmd._visit_once = !1), cc.Node.WebGLRenderCmd.prototype.visit.call(this, a);
  17325. else {
  17326. cc.renderer.pushRenderCommand(this._beforeVisitCmd);
  17327. var d =
  17328. cc.current_stack;
  17329. d.stack.push(d.top);
  17330. this._syncStatus(a);
  17331. d.top = this._stackMatrix;
  17332. c._stencil._renderCmd.visit(this);
  17333. cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);
  17334. if ((a = c._children) && 0 < a.length) {
  17335. var e = a.length;
  17336. c.sortAllChildren();
  17337. for (c = 0; c < e; c++) a[c]._renderCmd.visit(this)
  17338. }
  17339. cc.renderer.pushRenderCommand(this._afterVisitCmd);
  17340. this._dirtyFlag = 0;
  17341. d.top = d.stack.pop()
  17342. } else c.inverted && cc.Node.WebGLRenderCmd.prototype.visit.call(this, a)
  17343. };
  17344. a.setStencil = function(a) {
  17345. var c = this._node;
  17346. c._stencil && (c._stencil._parent =
  17347. null);
  17348. c._stencil = a;
  17349. c._stencil && (c._stencil._parent = c)
  17350. };
  17351. a._drawFullScreenQuadClearStencil = function() {
  17352. var a = cc.projection_matrix_stack;
  17353. a.push();
  17354. a.top.identity();
  17355. var c = cc.modelview_matrix_stack;
  17356. c.push();
  17357. c.top.identity();
  17358. cc._drawingUtil.drawSolidRect(cc.p(-1, -1), cc.p(1, 1), cc.color(255, 255, 255, 255));
  17359. a.pop();
  17360. c.pop()
  17361. };
  17362. a._onBeforeVisit = function(a) {
  17363. var c = a || cc._renderContext;
  17364. a = this._node;
  17365. cc.ClippingNode.WebGLRenderCmd._layer++;
  17366. var d = 1 << cc.ClippingNode.WebGLRenderCmd._layer;
  17367. this._mask_layer_le = d | d - 1;
  17368. this._currentStencilEnabled =
  17369. c.isEnabled(c.STENCIL_TEST);
  17370. this._currentStencilWriteMask = c.getParameter(c.STENCIL_WRITEMASK);
  17371. this._currentStencilFunc = c.getParameter(c.STENCIL_FUNC);
  17372. this._currentStencilRef = c.getParameter(c.STENCIL_REF);
  17373. this._currentStencilValueMask = c.getParameter(c.STENCIL_VALUE_MASK);
  17374. this._currentStencilFail = c.getParameter(c.STENCIL_FAIL);
  17375. this._currentStencilPassDepthFail = c.getParameter(c.STENCIL_PASS_DEPTH_FAIL);
  17376. this._currentStencilPassDepthPass = c.getParameter(c.STENCIL_PASS_DEPTH_PASS);
  17377. c.enable(c.STENCIL_TEST);
  17378. c.stencilMask(d);
  17379. this._currentDepthWriteMask = c.getParameter(c.DEPTH_WRITEMASK);
  17380. c.depthMask(!1);
  17381. c.stencilFunc(c.NEVER, d, d);
  17382. c.stencilOp(a.inverted ? c.REPLACE : c.ZERO, c.KEEP, c.KEEP);
  17383. this._drawFullScreenQuadClearStencil();
  17384. c.stencilFunc(c.NEVER, d, d);
  17385. c.stencilOp(a.inverted ? c.ZERO : c.REPLACE, c.KEEP, c.KEEP);
  17386. 1 > a.alphaThreshold && (d = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST), c = c.getUniformLocation(d.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S), cc.glUseProgram(d.getProgram()), d.setUniformLocationWith1f(c,
  17387. a.alphaThreshold), cc.setProgram(a._stencil, d))
  17388. };
  17389. a._onAfterDrawStencil = function(a) {
  17390. a = a || cc._renderContext;
  17391. a.depthMask(this._currentDepthWriteMask);
  17392. a.stencilFunc(a.EQUAL, this._mask_layer_le, this._mask_layer_le);
  17393. a.stencilOp(a.KEEP, a.KEEP, a.KEEP)
  17394. };
  17395. a._onAfterVisit = function(a) {
  17396. a = a || cc._renderContext;
  17397. a.stencilFunc(this._currentStencilFunc, this._currentStencilRef, this._currentStencilValueMask);
  17398. a.stencilOp(this._currentStencilFail, this._currentStencilPassDepthFail, this._currentStencilPassDepthPass);
  17399. a.stencilMask(this._currentStencilWriteMask);
  17400. this._currentStencilEnabled || a.disable(a.STENCIL_TEST);
  17401. cc.ClippingNode.WebGLRenderCmd._layer--
  17402. }
  17403. })();
  17404. cc.GridBase = cc.Class.extend({
  17405. _active: !1,
  17406. _reuseGrid: 0,
  17407. _gridSize: null,
  17408. _texture: null,
  17409. _step: null,
  17410. _grabber: null,
  17411. _isTextureFlipped: !1,
  17412. _shaderProgram: null,
  17413. _directorProjection: 0,
  17414. _dirty: !1,
  17415. ctor: function(a, b, c) {
  17416. cc._checkWebGLRenderMode();
  17417. this._active = !1;
  17418. this._reuseGrid = 0;
  17419. this._texture = this._gridSize = null;
  17420. this._step = cc.p(0, 0);
  17421. this._grabber = null;
  17422. this._isTextureFlipped = !1;
  17423. this._shaderProgram = null;
  17424. this._directorProjection = 0;
  17425. this._dirty = !1;
  17426. void 0 !== a && this.initWithSize(a, b, c)
  17427. },
  17428. isActive: function() {
  17429. return this._active
  17430. },
  17431. setActive: function(a) {
  17432. this._active = a;
  17433. if (!a) {
  17434. a = cc.director;
  17435. var b = a.getProjection();
  17436. a.setProjection(b)
  17437. }
  17438. },
  17439. getReuseGrid: function() {
  17440. return this._reuseGrid
  17441. },
  17442. setReuseGrid: function(a) {
  17443. this._reuseGrid = a
  17444. },
  17445. getGridSize: function() {
  17446. return cc.size(this._gridSize.width, this._gridSize.height)
  17447. },
  17448. setGridSize: function(a) {
  17449. this._gridSize.width = parseInt(a.width);
  17450. this._gridSize.height = parseInt(a.height)
  17451. },
  17452. getStep: function() {
  17453. return cc.p(this._step.x, this._step.y)
  17454. },
  17455. setStep: function(a) {
  17456. this._step.x = a.x;
  17457. this._step.y = a.y
  17458. },
  17459. isTextureFlipped: function() {
  17460. return this._isTextureFlipped
  17461. },
  17462. setTextureFlipped: function(a) {
  17463. this._isTextureFlipped !== a && (this._isTextureFlipped = a, this.calculateVertexPoints())
  17464. },
  17465. initWithSize: function(a, b, c) {
  17466. if (!b) {
  17467. var d = cc.director.getWinSizeInPixels(),
  17468. e = cc.NextPOT(d.width),
  17469. f = cc.NextPOT(d.height),
  17470. g = new Uint8Array(e * f * 4);
  17471. if (!g) return cc.log("cocos2d: CCGrid: not enough memory."), !1;
  17472. b = new cc.Texture2D;
  17473. b.initWithData(g, cc.Texture2D.PIXEL_FORMAT_RGBA8888, e, f, d);
  17474. if (!b) return cc.log("cocos2d: CCGrid: error creating texture"), !1
  17475. }
  17476. this._active = !1;
  17477. this._reuseGrid = 0;
  17478. this._gridSize =
  17479. a;
  17480. this._texture = b;
  17481. this._isTextureFlipped = c || !1;
  17482. this._step.x = this._texture.width / a.width;
  17483. this._step.y = this._texture.height / a.height;
  17484. this._grabber = new cc.Grabber;
  17485. if (!this._grabber) return !1;
  17486. this._grabber.grab(this._texture);
  17487. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
  17488. this.calculateVertexPoints();
  17489. return !0
  17490. },
  17491. beforeDraw: function() {
  17492. this._directorProjection = cc.director.getProjection();
  17493. this._grabber.beforeRender(this._texture)
  17494. },
  17495. afterDraw: function(a) {
  17496. this._grabber.afterRender(this._texture);
  17497. if (a && a.getCamera().isDirty()) {
  17498. var b = a.getAnchorPointInPoints(),
  17499. c = a._renderCmd._stackMatrix,
  17500. d = cc.math.Matrix4.createByTranslation(b.x, b.y, 0);
  17501. c.multiply(d);
  17502. a._camera._locateForRenderer(c);
  17503. d = cc.math.Matrix4.createByTranslation(-b.x, -b.y, 0, d);
  17504. c.multiply(d)
  17505. }
  17506. cc.glBindTexture2D(this._texture);
  17507. this.beforeBlit();
  17508. this.blit(a);
  17509. this.afterBlit()
  17510. },
  17511. beforeBlit: function() {},
  17512. afterBlit: function() {},
  17513. blit: function() {
  17514. cc.log("cc.GridBase.blit(): Shall be overridden in subclass.")
  17515. },
  17516. reuse: function() {
  17517. cc.log("cc.GridBase.reuse(): Shall be overridden in subclass.")
  17518. },
  17519. calculateVertexPoints: function() {
  17520. cc.log("cc.GridBase.calculateVertexPoints(): Shall be overridden in subclass.")
  17521. },
  17522. set2DProjection: function() {
  17523. var a = cc.director.getWinSizeInPixels();
  17524. cc._renderContext.viewport(0, 0, a.width, a.height);
  17525. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  17526. cc.kmGLLoadIdentity();
  17527. a = cc.math.Matrix4.createOrthographicProjection(0, a.width, 0, a.height, -1, 1);
  17528. cc.kmGLMultMatrix(a);
  17529. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  17530. cc.kmGLLoadIdentity();
  17531. cc.setProjectionMatrixDirty()
  17532. }
  17533. });
  17534. cc.GridBase.create = function(a, b, c) {
  17535. return new cc.GridBase(a, b, c)
  17536. };
  17537. cc.Grid3D = cc.GridBase.extend({
  17538. _texCoordinates: null,
  17539. _vertices: null,
  17540. _originalVertices: null,
  17541. _indices: null,
  17542. _texCoordinateBuffer: null,
  17543. _verticesBuffer: null,
  17544. _indicesBuffer: null,
  17545. _needDepthTestForBlit: !1,
  17546. _oldDepthTestValue: !1,
  17547. _oldDepthWriteValue: !1,
  17548. ctor: function(a, b, c) {
  17549. cc.GridBase.prototype.ctor.call(this);
  17550. this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
  17551. void 0 !== a && this.initWithSize(a, b, c)
  17552. },
  17553. vertex: function(a) {
  17554. return this.getVertex(a)
  17555. },
  17556. getVertex: function(a) {
  17557. a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.vertex() : Numbers must be integers");
  17558. a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
  17559. var b = this._vertices;
  17560. return new cc.Vertex3F(b[a], b[a + 1], b[a + 2])
  17561. },
  17562. originalVertex: function(a) {
  17563. return this.getOriginalVertex(a)
  17564. },
  17565. getOriginalVertex: function(a) {
  17566. a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.originalVertex() : Numbers must be integers");
  17567. a = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y);
  17568. var b = this._originalVertices;
  17569. return new cc.Vertex3F(b[a], b[a +
  17570. 1], b[a + 2])
  17571. },
  17572. setVertex: function(a, b) {
  17573. a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.Grid3D.setVertex() : Numbers must be integers");
  17574. var c = 0 | 3 * (a.x * (this._gridSize.height + 1) + a.y),
  17575. d = this._vertices;
  17576. d[c] = b.x;
  17577. d[c + 1] = b.y;
  17578. d[c + 2] = b.z;
  17579. this._dirty = !0
  17580. },
  17581. beforeBlit: function() {
  17582. if (this._needDepthTestForBlit) {
  17583. var a = cc._renderContext;
  17584. this._oldDepthTestValue = a.isEnabled(a.DEPTH_TEST);
  17585. this._oldDepthWriteValue = a.getParameter(a.DEPTH_WRITEMASK);
  17586. a.enable(a.DEPTH_TEST);
  17587. a.depthMask(!0)
  17588. }
  17589. },
  17590. afterBlit: function() {
  17591. if (this._needDepthTestForBlit) {
  17592. var a =
  17593. cc._renderContext;
  17594. this._oldDepthTestValue ? a.enable(a.DEPTH_TEST) : a.disable(a.DEPTH_TEST);
  17595. a.depthMask(this._oldDepthWriteValue)
  17596. }
  17597. },
  17598. blit: function(a) {
  17599. var b = this._gridSize.width * this._gridSize.height;
  17600. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  17601. this._shaderProgram.use();
  17602. this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix);
  17603. a = cc._renderContext;
  17604. var c = this._dirty;
  17605. a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
  17606. c && a.bufferData(a.ARRAY_BUFFER,
  17607. this._vertices, a.DYNAMIC_DRAW);
  17608. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 0, 0);
  17609. a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer);
  17610. c && a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW);
  17611. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, 0);
  17612. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  17613. c && a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW);
  17614. a.drawElements(a.TRIANGLES, 6 * b, a.UNSIGNED_SHORT, 0);
  17615. c && (this._dirty = !1);
  17616. cc.incrementGLDraws(1)
  17617. },
  17618. reuse: function() {
  17619. if (0 < this._reuseGrid) {
  17620. for (var a = this._originalVertices, b = this._vertices, c = 0, d = this._vertices.length; c < d; c++) a[c] = b[c];
  17621. --this._reuseGrid
  17622. }
  17623. },
  17624. calculateVertexPoints: function() {
  17625. var a = cc._renderContext,
  17626. b = this._texture.pixelsWidth,
  17627. c = this._texture.pixelsHeight,
  17628. d = this._texture.getContentSizeInPixels().height,
  17629. e = this._gridSize,
  17630. f = (e.width + 1) * (e.height + 1);
  17631. this._vertices = new Float32Array(3 * f);
  17632. this._texCoordinates = new Float32Array(2 * f);
  17633. this._indices = new Uint16Array(e.width * e.height * 6);
  17634. this._verticesBuffer &&
  17635. a.deleteBuffer(this._verticesBuffer);
  17636. this._verticesBuffer = a.createBuffer();
  17637. this._texCoordinateBuffer && a.deleteBuffer(this._texCoordinateBuffer);
  17638. this._texCoordinateBuffer = a.createBuffer();
  17639. this._indicesBuffer && a.deleteBuffer(this._indicesBuffer);
  17640. this._indicesBuffer = a.createBuffer();
  17641. for (var g, h, k = this._indices, m = this._texCoordinates, n = this._isTextureFlipped, p = this._vertices, f = 0; f < e.width; ++f)
  17642. for (g = 0; g < e.height; ++g) {
  17643. var t = g * e.width + f;
  17644. h = f * this._step.x;
  17645. var r = h + this._step.x,
  17646. u = g * this._step.y,
  17647. s = u + this._step.y,
  17648. v = f * (e.height + 1) + g,
  17649. x = (f + 1) * (e.height + 1) + g,
  17650. D = (f + 1) * (e.height + 1) + (g + 1),
  17651. E = f * (e.height + 1) + (g + 1);
  17652. k[6 * t] = v;
  17653. k[6 * t + 1] = x;
  17654. k[6 * t + 2] = E;
  17655. k[6 * t + 3] = x;
  17656. k[6 * t + 4] = D;
  17657. k[6 * t + 5] = E;
  17658. var t = [3 * v, 3 * x, 3 * D, 3 * E],
  17659. A = [{
  17660. x: h,
  17661. y: u,
  17662. z: 0
  17663. }, {
  17664. x: r,
  17665. y: u,
  17666. z: 0
  17667. }, {
  17668. x: r,
  17669. y: s,
  17670. z: 0
  17671. }, {
  17672. x: h,
  17673. y: s,
  17674. z: 0
  17675. }],
  17676. v = [2 * v, 2 * x, 2 * D, 2 * E],
  17677. r = [cc.p(h, u), cc.p(r, u), cc.p(r, s), cc.p(h, s)];
  17678. for (h = 0; 4 > h; ++h) p[t[h]] = A[h].x, p[t[h] + 1] = A[h].y, p[t[h] + 2] = A[h].z, m[v[h]] = r[h].x / b, m[v[h] + 1] = n ? (d - r[h].y) / c : r[h].y / c
  17679. }
  17680. this._originalVertices = new Float32Array(this._vertices);
  17681. a.bindBuffer(a.ARRAY_BUFFER,
  17682. this._verticesBuffer);
  17683. a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
  17684. a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer);
  17685. a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW);
  17686. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  17687. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW);
  17688. this._dirty = !0
  17689. },
  17690. setNeedDepthTestForBlit: function(a) {
  17691. this._needDepthTestForBlit = a
  17692. },
  17693. getNeedDepthTestForBlit: function() {
  17694. return this._needDepthTestForBlit
  17695. }
  17696. });
  17697. cc.Grid3D.create = function(a, b, c) {
  17698. return new cc.Grid3D(a, b, c)
  17699. };
  17700. cc.TiledGrid3D = cc.GridBase.extend({
  17701. _texCoordinates: null,
  17702. _vertices: null,
  17703. _originalVertices: null,
  17704. _indices: null,
  17705. _texCoordinateBuffer: null,
  17706. _verticesBuffer: null,
  17707. _indicesBuffer: null,
  17708. ctor: function(a, b, c) {
  17709. cc.GridBase.prototype.ctor.call(this);
  17710. this._indicesBuffer = this._verticesBuffer = this._texCoordinateBuffer = this._indices = this._originalVertices = this._vertices = this._texCoordinates = null;
  17711. void 0 !== a && this.initWithSize(a, b, c)
  17712. },
  17713. tile: function(a) {
  17714. return this.getTile(a)
  17715. },
  17716. getTile: function(a) {
  17717. a.x === (0 | a.x) && a.y === (0 |
  17718. a.y) || cc.log("cc.TiledGrid3D.tile() : Numbers must be integers");
  17719. a = 12 * (this._gridSize.height * a.x + a.y);
  17720. var b = this._vertices;
  17721. return new cc.Quad3(new cc.Vertex3F(b[a], b[a + 1], b[a + 2]), new cc.Vertex3F(b[a + 3], b[a + 4], b[a + 5]), new cc.Vertex3F(b[a + 6], b[a + 7], b[a + 8]), new cc.Vertex3F(b[a + 9], b[a + 10], b[a + 11]))
  17722. },
  17723. getOriginalTile: function(a) {
  17724. a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers");
  17725. a = 12 * (this._gridSize.height * a.x + a.y);
  17726. var b = this._originalVertices;
  17727. return new cc.Quad3(new cc.Vertex3F(b[a],
  17728. b[a + 1], b[a + 2]), new cc.Vertex3F(b[a + 3], b[a + 4], b[a + 5]), new cc.Vertex3F(b[a + 6], b[a + 7], b[a + 8]), new cc.Vertex3F(b[a + 9], b[a + 10], b[a + 11]))
  17729. },
  17730. originalTile: function(a) {
  17731. return this.getOriginalTile(a)
  17732. },
  17733. setTile: function(a, b) {
  17734. a.x === (0 | a.x) && a.y === (0 | a.y) || cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers");
  17735. var c = 12 * (this._gridSize.height * a.x + a.y),
  17736. d = this._vertices;
  17737. d[c] = b.bl.x;
  17738. d[c + 1] = b.bl.y;
  17739. d[c + 2] = b.bl.z;
  17740. d[c + 3] = b.br.x;
  17741. d[c + 4] = b.br.y;
  17742. d[c + 5] = b.br.z;
  17743. d[c + 6] = b.tl.x;
  17744. d[c + 7] = b.tl.y;
  17745. d[c + 8] = b.tl.z;
  17746. d[c + 9] = b.tr.x;
  17747. d[c +
  17748. 10] = b.tr.y;
  17749. d[c + 11] = b.tr.z;
  17750. this._dirty = !0
  17751. },
  17752. blit: function(a) {
  17753. var b = this._gridSize.width * this._gridSize.height;
  17754. this._shaderProgram.use();
  17755. this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix);
  17756. a = cc._renderContext;
  17757. var c = this._dirty;
  17758. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  17759. a.bindBuffer(a.ARRAY_BUFFER, this._verticesBuffer);
  17760. c && a.bufferData(a.ARRAY_BUFFER, this._vertices, a.DYNAMIC_DRAW);
  17761. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,
  17762. 3, a.FLOAT, !1, 0, this._vertices);
  17763. a.bindBuffer(a.ARRAY_BUFFER, this._texCoordinateBuffer);
  17764. c && a.bufferData(a.ARRAY_BUFFER, this._texCoordinates, a.DYNAMIC_DRAW);
  17765. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 0, this._texCoordinates);
  17766. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  17767. c && a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW);
  17768. a.drawElements(a.TRIANGLES, 6 * b, a.UNSIGNED_SHORT, 0);
  17769. c && (this._dirty = !1);
  17770. cc.incrementGLDraws(1)
  17771. },
  17772. reuse: function() {
  17773. if (0 < this._reuseGrid) {
  17774. for (var a =
  17775. this._vertices, b = this._originalVertices, c = 0; c < a.length; c++) b[c] = a[c];
  17776. --this._reuseGrid
  17777. }
  17778. },
  17779. calculateVertexPoints: function() {
  17780. var a = this._texture.pixelsWidth,
  17781. b = this._texture.pixelsHeight,
  17782. c = this._texture.getContentSizeInPixels().height,
  17783. d = this._gridSize,
  17784. e = d.width * d.height;
  17785. this._vertices = new Float32Array(12 * e);
  17786. this._texCoordinates = new Float32Array(8 * e);
  17787. this._indices = new Uint16Array(6 * e);
  17788. var f = cc._renderContext;
  17789. this._verticesBuffer && f.deleteBuffer(this._verticesBuffer);
  17790. this._verticesBuffer = f.createBuffer();
  17791. this._texCoordinateBuffer && f.deleteBuffer(this._texCoordinateBuffer);
  17792. this._texCoordinateBuffer = f.createBuffer();
  17793. this._indicesBuffer && f.deleteBuffer(this._indicesBuffer);
  17794. this._indicesBuffer = f.createBuffer();
  17795. var g, h, k = 0,
  17796. m = this._step,
  17797. n = this._vertices,
  17798. p = this._texCoordinates,
  17799. t = this._isTextureFlipped;
  17800. for (g = 0; g < d.width; g++)
  17801. for (h = 0; h < d.height; h++) {
  17802. var r = g * m.x,
  17803. u = r + m.x,
  17804. s = h * m.y,
  17805. v = s + m.y;
  17806. n[12 * k] = r;
  17807. n[12 * k + 1] = s;
  17808. n[12 * k + 2] = 0;
  17809. n[12 * k + 3] = u;
  17810. n[12 * k + 4] = s;
  17811. n[12 * k + 5] = 0;
  17812. n[12 * k + 6] = r;
  17813. n[12 * k + 7] = v;
  17814. n[12 * k + 8] = 0;
  17815. n[12 * k + 9] = u;
  17816. n[12 *
  17817. k + 10] = v;
  17818. n[12 * k + 11] = 0;
  17819. var x = s,
  17820. D = v;
  17821. t && (x = c - s, D = c - v);
  17822. p[8 * k] = r / a;
  17823. p[8 * k + 1] = x / b;
  17824. p[8 * k + 2] = u / a;
  17825. p[8 * k + 3] = x / b;
  17826. p[8 * k + 4] = r / a;
  17827. p[8 * k + 5] = D / b;
  17828. p[8 * k + 6] = u / a;
  17829. p[8 * k + 7] = D / b;
  17830. k++
  17831. }
  17832. a = this._indices;
  17833. for (g = 0; g < e; g++) a[6 * g + 0] = 4 * g + 0, a[6 * g + 1] = 4 * g + 1, a[6 * g + 2] = 4 * g + 2, a[6 * g + 3] = 4 * g + 1, a[6 * g + 4] = 4 * g + 2, a[6 * g + 5] = 4 * g + 3;
  17834. this._originalVertices = new Float32Array(this._vertices);
  17835. f.bindBuffer(f.ARRAY_BUFFER, this._verticesBuffer);
  17836. f.bufferData(f.ARRAY_BUFFER, this._vertices, f.DYNAMIC_DRAW);
  17837. f.bindBuffer(f.ARRAY_BUFFER, this._texCoordinateBuffer);
  17838. f.bufferData(f.ARRAY_BUFFER,
  17839. this._texCoordinates, f.DYNAMIC_DRAW);
  17840. f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, this._indicesBuffer);
  17841. f.bufferData(f.ELEMENT_ARRAY_BUFFER, this._indices, f.DYNAMIC_DRAW);
  17842. this._dirty = !0
  17843. }
  17844. });
  17845. cc.TiledGrid3D.create = function(a, b, c) {
  17846. return new cc.TiledGrid3D(a, b, c)
  17847. };
  17848. cc.Grabber = cc.Class.extend({
  17849. _FBO: null,
  17850. _oldFBO: null,
  17851. _oldClearColor: null,
  17852. _gl: null,
  17853. ctor: function() {
  17854. cc._checkWebGLRenderMode();
  17855. this._gl = cc._renderContext;
  17856. this._oldClearColor = [0, 0, 0, 0];
  17857. this._oldFBO = null;
  17858. this._FBO = this._gl.createFramebuffer()
  17859. },
  17860. grab: function(a) {
  17861. var b = this._gl;
  17862. this._oldFBO = b.getParameter(b.FRAMEBUFFER_BINDING);
  17863. b.bindFramebuffer(b.FRAMEBUFFER, this._FBO);
  17864. b.framebufferTexture2D(b.FRAMEBUFFER, b.COLOR_ATTACHMENT0, b.TEXTURE_2D, a._webTextureObj, 0);
  17865. b.checkFramebufferStatus(b.FRAMEBUFFER) !== b.FRAMEBUFFER_COMPLETE &&
  17866. cc.log("Frame Grabber: could not attach texture to frmaebuffer");
  17867. b.bindFramebuffer(b.FRAMEBUFFER, this._oldFBO)
  17868. },
  17869. beforeRender: function(a) {
  17870. a = this._gl;
  17871. this._oldFBO = a.getParameter(a.FRAMEBUFFER_BINDING);
  17872. a.bindFramebuffer(a.FRAMEBUFFER, this._FBO);
  17873. this._oldClearColor = a.getParameter(a.COLOR_CLEAR_VALUE);
  17874. a.clearColor(0, 0, 0, 0);
  17875. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
  17876. },
  17877. afterRender: function(a) {
  17878. a = this._gl;
  17879. a.bindFramebuffer(a.FRAMEBUFFER, this._oldFBO);
  17880. a.colorMask(!0, !0, !0, !0)
  17881. },
  17882. destroy: function() {
  17883. this._gl.deleteFramebuffer(this._FBO)
  17884. }
  17885. });
  17886. cc.ACTION_TAG_INVALID = -1;
  17887. cc.Action = cc.Class.extend({
  17888. originalTarget: null,
  17889. target: null,
  17890. tag: cc.ACTION_TAG_INVALID,
  17891. ctor: function() {
  17892. this.target = this.originalTarget = null;
  17893. this.tag = cc.ACTION_TAG_INVALID
  17894. },
  17895. copy: function() {
  17896. cc.log("copy is deprecated. Please use clone instead.");
  17897. return this.clone()
  17898. },
  17899. clone: function() {
  17900. var a = new cc.Action;
  17901. a.originalTarget = null;
  17902. a.target = null;
  17903. a.tag = this.tag;
  17904. return a
  17905. },
  17906. isDone: function() {
  17907. return !0
  17908. },
  17909. startWithTarget: function(a) {
  17910. this.target = this.originalTarget = a
  17911. },
  17912. stop: function() {
  17913. this.target = null
  17914. },
  17915. step: function(a) {
  17916. cc.log("[Action step]. override me")
  17917. },
  17918. update: function(a) {
  17919. cc.log("[Action update]. override me")
  17920. },
  17921. getTarget: function() {
  17922. return this.target
  17923. },
  17924. setTarget: function(a) {
  17925. this.target = a
  17926. },
  17927. getOriginalTarget: function() {
  17928. return this.originalTarget
  17929. },
  17930. setOriginalTarget: function(a) {
  17931. this.originalTarget = a
  17932. },
  17933. getTag: function() {
  17934. return this.tag
  17935. },
  17936. setTag: function(a) {
  17937. this.tag = a
  17938. },
  17939. retain: function() {},
  17940. release: function() {}
  17941. });
  17942. cc.action = function() {
  17943. return new cc.Action
  17944. };
  17945. cc.Action.create = cc.action;
  17946. cc.FiniteTimeAction = cc.Action.extend({
  17947. _duration: 0,
  17948. ctor: function() {
  17949. cc.Action.prototype.ctor.call(this);
  17950. this._duration = 0
  17951. },
  17952. getDuration: function() {
  17953. return this._duration * (this._timesForRepeat || 1)
  17954. },
  17955. setDuration: function(a) {
  17956. this._duration = a
  17957. },
  17958. reverse: function() {
  17959. cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");
  17960. return null
  17961. },
  17962. clone: function() {
  17963. return new cc.FiniteTimeAction
  17964. }
  17965. });
  17966. cc.Speed = cc.Action.extend({
  17967. _speed: 0,
  17968. _innerAction: null,
  17969. ctor: function(a, b) {
  17970. cc.Action.prototype.ctor.call(this);
  17971. this._speed = 0;
  17972. this._innerAction = null;
  17973. a && this.initWithAction(a, b)
  17974. },
  17975. getSpeed: function() {
  17976. return this._speed
  17977. },
  17978. setSpeed: function(a) {
  17979. this._speed = a
  17980. },
  17981. initWithAction: function(a, b) {
  17982. if (!a) throw "cc.Speed.initWithAction(): action must be non nil";
  17983. this._innerAction = a;
  17984. this._speed = b;
  17985. return !0
  17986. },
  17987. clone: function() {
  17988. var a = new cc.Speed;
  17989. a.initWithAction(this._innerAction.clone(), this._speed);
  17990. return a
  17991. },
  17992. startWithTarget: function(a) {
  17993. cc.Action.prototype.startWithTarget.call(this,
  17994. a);
  17995. this._innerAction.startWithTarget(a)
  17996. },
  17997. stop: function() {
  17998. this._innerAction.stop();
  17999. cc.Action.prototype.stop.call(this)
  18000. },
  18001. step: function(a) {
  18002. this._innerAction.step(a * this._speed)
  18003. },
  18004. isDone: function() {
  18005. return this._innerAction.isDone()
  18006. },
  18007. reverse: function() {
  18008. return new cc.Speed(this._innerAction.reverse(), this._speed)
  18009. },
  18010. setInnerAction: function(a) {
  18011. this._innerAction !== a && (this._innerAction = a)
  18012. },
  18013. getInnerAction: function() {
  18014. return this._innerAction
  18015. }
  18016. });
  18017. cc.speed = function(a, b) {
  18018. return new cc.Speed(a, b)
  18019. };
  18020. cc.Speed.create = cc.speed;
  18021. cc.Follow = cc.Action.extend({
  18022. _followedNode: null,
  18023. _boundarySet: !1,
  18024. _boundaryFullyCovered: !1,
  18025. _halfScreenSize: null,
  18026. _fullScreenSize: null,
  18027. _worldRect: null,
  18028. leftBoundary: 0,
  18029. rightBoundary: 0,
  18030. topBoundary: 0,
  18031. bottomBoundary: 0,
  18032. ctor: function(a, b) {
  18033. cc.Action.prototype.ctor.call(this);
  18034. this._followedNode = null;
  18035. this._boundaryFullyCovered = this._boundarySet = !1;
  18036. this._fullScreenSize = this._halfScreenSize = null;
  18037. this.bottomBoundary = this.topBoundary = this.rightBoundary = this.leftBoundary = 0;
  18038. this._worldRect = cc.rect(0, 0, 0, 0);
  18039. a && (b ? this.initWithTarget(a,
  18040. b) : this.initWithTarget(a))
  18041. },
  18042. clone: function() {
  18043. var a = new cc.Follow,
  18044. b = this._worldRect,
  18045. b = new cc.Rect(b.x, b.y, b.width, b.height);
  18046. a.initWithTarget(this._followedNode, b);
  18047. return a
  18048. },
  18049. isBoundarySet: function() {
  18050. return this._boundarySet
  18051. },
  18052. setBoudarySet: function(a) {
  18053. this._boundarySet = a
  18054. },
  18055. initWithTarget: function(a, b) {
  18056. if (!a) throw "cc.Follow.initWithAction(): followedNode must be non nil";
  18057. b = b || cc.rect(0, 0, 0, 0);
  18058. this._followedNode = a;
  18059. this._worldRect = b;
  18060. this._boundarySet = !cc._rectEqualToZero(b);
  18061. this._boundaryFullyCovered = !1;
  18062. var c = cc.director.getWinSize();
  18063. this._fullScreenSize = cc.p(c.width, c.height);
  18064. this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5);
  18065. this._boundarySet && (this.leftBoundary = -(b.x + b.width - this._fullScreenSize.x), this.rightBoundary = -b.x, this.topBoundary = -b.y, this.bottomBoundary = -(b.y + b.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 =
  18066. (this.topBoundary + this.bottomBoundary) / 2), this.topBoundary === this.bottomBoundary && this.leftBoundary === this.rightBoundary && (this._boundaryFullyCovered = !0));
  18067. return !0
  18068. },
  18069. step: function(a) {
  18070. a = this._followedNode.x;
  18071. var b = this._followedNode.y;
  18072. a = this._halfScreenSize.x - a;
  18073. b = this._halfScreenSize.y - b;
  18074. this.target._renderCmd._dirtyFlag = 0;
  18075. this._boundarySet ? this._boundaryFullyCovered || this.target.setPosition(cc.clampf(a, this.leftBoundary, this.rightBoundary), cc.clampf(b, this.bottomBoundary, this.topBoundary)) : this.target.setPosition(a,
  18076. b)
  18077. },
  18078. isDone: function() {
  18079. return !this._followedNode.running
  18080. },
  18081. stop: function() {
  18082. this.target = null;
  18083. cc.Action.prototype.stop.call(this)
  18084. }
  18085. });
  18086. cc.follow = function(a, b) {
  18087. return new cc.Follow(a, b)
  18088. };
  18089. cc.Follow.create = cc.follow;
  18090. cc.ActionInterval = cc.FiniteTimeAction.extend({
  18091. _elapsed: 0,
  18092. _firstTick: !1,
  18093. _easeList: null,
  18094. _timesForRepeat: 1,
  18095. _repeatForever: !1,
  18096. _repeatMethod: !1,
  18097. _speed: 1,
  18098. _speedMethod: !1,
  18099. ctor: function(a) {
  18100. this._timesForRepeat = this._speed = 1;
  18101. this._repeatForever = !1;
  18102. this.MAX_VALUE = 2;
  18103. this._speedMethod = this._repeatMethod = !1;
  18104. cc.FiniteTimeAction.prototype.ctor.call(this);
  18105. void 0 !== a && this.initWithDuration(a)
  18106. },
  18107. getElapsed: function() {
  18108. return this._elapsed
  18109. },
  18110. initWithDuration: function(a) {
  18111. this._duration = 0 === a ? cc.FLT_EPSILON : a;
  18112. this._elapsed =
  18113. 0;
  18114. return this._firstTick = !0
  18115. },
  18116. isDone: function() {
  18117. return this._elapsed >= this._duration
  18118. },
  18119. _cloneDecoration: function(a) {
  18120. a._repeatForever = this._repeatForever;
  18121. a._speed = this._speed;
  18122. a._timesForRepeat = this._timesForRepeat;
  18123. a._easeList = this._easeList;
  18124. a._speedMethod = this._speedMethod;
  18125. a._repeatMethod = this._repeatMethod
  18126. },
  18127. _reverseEaseList: function(a) {
  18128. if (this._easeList) {
  18129. a._easeList = [];
  18130. for (var b = 0; b < this._easeList.length; b++) a._easeList.push(this._easeList[b].reverse())
  18131. }
  18132. },
  18133. clone: function() {
  18134. var a = new cc.ActionInterval(this._duration);
  18135. this._cloneDecoration(a);
  18136. return a
  18137. },
  18138. easing: function(a) {
  18139. this._easeList ? this._easeList.length = 0 : this._easeList = [];
  18140. for (var b = 0; b < arguments.length; b++) this._easeList.push(arguments[b]);
  18141. return this
  18142. },
  18143. _computeEaseTime: function(a) {
  18144. var b = this._easeList;
  18145. if (!b || 0 === b.length) return a;
  18146. for (var c = 0, d = b.length; c < d; c++) a = b[c].easing(a);
  18147. return a
  18148. },
  18149. step: function(a) {
  18150. this._firstTick ? (this._firstTick = !1, this._elapsed = 0) : this._elapsed += a;
  18151. a = this._elapsed / (1.192092896E-7 < this._duration ? this._duration : 1.192092896E-7);
  18152. a = 1 > a ?
  18153. a : 1;
  18154. this.update(0 < a ? a : 0);
  18155. this._repeatMethod && 1 < this._timesForRepeat && this.isDone() && (this._repeatForever || this._timesForRepeat--, this.startWithTarget(this.target), this.step(this._elapsed - this._duration))
  18156. },
  18157. startWithTarget: function(a) {
  18158. cc.Action.prototype.startWithTarget.call(this, a);
  18159. this._elapsed = 0;
  18160. this._firstTick = !0
  18161. },
  18162. reverse: function() {
  18163. cc.log("cc.IntervalAction: reverse not implemented.");
  18164. return null
  18165. },
  18166. setAmplitudeRate: function(a) {
  18167. cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")
  18168. },
  18169. getAmplitudeRate: function() {
  18170. cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
  18171. return 0
  18172. },
  18173. speed: function(a) {
  18174. if (0 >= a) return cc.log("The speed parameter error"), this;
  18175. this._speedMethod = !0;
  18176. this._speed *= a;
  18177. return this
  18178. },
  18179. getSpeed: function() {
  18180. return this._speed
  18181. },
  18182. setSpeed: function(a) {
  18183. this._speed = a;
  18184. return this
  18185. },
  18186. repeat: function(a) {
  18187. a = Math.round(a);
  18188. if (isNaN(a) || 1 > a) return cc.log("The repeat parameter error"), this;
  18189. this._repeatMethod = !0;
  18190. this._timesForRepeat *= a;
  18191. return this
  18192. },
  18193. repeatForever: function() {
  18194. this._repeatMethod = !0;
  18195. this._timesForRepeat = this.MAX_VALUE;
  18196. this._repeatForever = !0;
  18197. return this
  18198. }
  18199. });
  18200. cc.actionInterval = function(a) {
  18201. return new cc.ActionInterval(a)
  18202. };
  18203. cc.ActionInterval.create = cc.actionInterval;
  18204. cc.Sequence = cc.ActionInterval.extend({
  18205. _actions: null,
  18206. _split: null,
  18207. _last: 0,
  18208. ctor: function(a) {
  18209. cc.ActionInterval.prototype.ctor.call(this);
  18210. this._actions = [];
  18211. var b = a instanceof Array ? a : arguments,
  18212. c = b.length - 1;
  18213. 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript");
  18214. if (0 <= c) {
  18215. for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Sequence._actionOneTwo(d, b[e]));
  18216. this.initWithTwoActions(d, b[c])
  18217. }
  18218. },
  18219. initWithTwoActions: function(a, b) {
  18220. if (!a || !b) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil";
  18221. this.initWithDuration(a._duration + b._duration);
  18222. this._actions[0] = a;
  18223. this._actions[1] = b;
  18224. return !0
  18225. },
  18226. clone: function() {
  18227. var a = new cc.Sequence;
  18228. this._cloneDecoration(a);
  18229. a.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
  18230. return a
  18231. },
  18232. startWithTarget: function(a) {
  18233. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18234. this._split = this._actions[0]._duration / this._duration;
  18235. this._last = -1
  18236. },
  18237. stop: function() {
  18238. -1 !== this._last && this._actions[this._last].stop();
  18239. cc.Action.prototype.stop.call(this)
  18240. },
  18241. update: function(a) {
  18242. var b =
  18243. 0,
  18244. c = this._split,
  18245. d = this._actions,
  18246. e = this._last;
  18247. a = this._computeEaseTime(a);
  18248. a < c ? (a = 0 !== c ? a / c : 1, 0 === b && 1 === e && (d[1].update(0), d[1].stop())) : (b = 1, a = 1 === c ? 1 : (a - c) / (1 - c), -1 === e && (d[0].startWithTarget(this.target), d[0].update(1), d[0].stop()), e || (d[0].update(1), d[0].stop()));
  18249. d = d[b];
  18250. e === b && d.isDone() || (e !== b && d.startWithTarget(this.target), a *= d._timesForRepeat, d.update(1 < a ? a % 1 : a), this._last = b)
  18251. },
  18252. reverse: function() {
  18253. var a = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
  18254. this._cloneDecoration(a);
  18255. this._reverseEaseList(a);
  18256. return a
  18257. }
  18258. });
  18259. cc.sequence = function(a) {
  18260. var b = a instanceof Array ? a : arguments;
  18261. 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  18262. for (var c, d, e, f; b && 0 < b.length;)
  18263. for (d = Array.prototype.shift.call(b), f = d._timesForRepeat || 1, d._repeatMethod = !1, d._timesForRepeat = 1, e = 0, c || (c = d, e = 1), e; e < f; e++) c = cc.Sequence._actionOneTwo(c, d);
  18264. return c
  18265. };
  18266. cc.Sequence.create = cc.sequence;
  18267. cc.Sequence._actionOneTwo = function(a, b) {
  18268. var c = new cc.Sequence;
  18269. c.initWithTwoActions(a, b);
  18270. return c
  18271. };
  18272. cc.Repeat = cc.ActionInterval.extend({
  18273. _times: 0,
  18274. _total: 0,
  18275. _nextDt: 0,
  18276. _actionInstant: !1,
  18277. _innerAction: null,
  18278. ctor: function(a, b) {
  18279. cc.ActionInterval.prototype.ctor.call(this);
  18280. void 0 !== b && this.initWithAction(a, b)
  18281. },
  18282. initWithAction: function(a, b) {
  18283. return this.initWithDuration(a._duration * b) ? (this._times = b, this._innerAction = a, a instanceof cc.ActionInstant && (this._actionInstant = !0, this._times -= 1), this._total = 0, !0) : !1
  18284. },
  18285. clone: function() {
  18286. var a = new cc.Repeat;
  18287. this._cloneDecoration(a);
  18288. a.initWithAction(this._innerAction.clone(),
  18289. this._times);
  18290. return a
  18291. },
  18292. startWithTarget: function(a) {
  18293. this._total = 0;
  18294. this._nextDt = this._innerAction._duration / this._duration;
  18295. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18296. this._innerAction.startWithTarget(a)
  18297. },
  18298. stop: function() {
  18299. this._innerAction.stop();
  18300. cc.Action.prototype.stop.call(this)
  18301. },
  18302. update: function(a) {
  18303. a = this._computeEaseTime(a);
  18304. var b = this._innerAction,
  18305. c = this._duration,
  18306. d = this._times,
  18307. e = this._nextDt;
  18308. if (a >= e) {
  18309. for (; a > e && this._total < d;) b.update(1), this._total++, b.stop(), b.startWithTarget(this.target),
  18310. this._nextDt = e += b._duration / c;
  18311. 1 <= a && this._total < d && this._total++;
  18312. this._actionInstant || (this._total === d ? (b.update(1), b.stop()) : b.update(a - (e - b._duration / c)))
  18313. } else b.update(a * d % 1)
  18314. },
  18315. isDone: function() {
  18316. return this._total === this._times
  18317. },
  18318. reverse: function() {
  18319. var a = new cc.Repeat(this._innerAction.reverse(), this._times);
  18320. this._cloneDecoration(a);
  18321. this._reverseEaseList(a);
  18322. return a
  18323. },
  18324. setInnerAction: function(a) {
  18325. this._innerAction !== a && (this._innerAction = a)
  18326. },
  18327. getInnerAction: function() {
  18328. return this._innerAction
  18329. }
  18330. });
  18331. cc.repeat = function(a, b) {
  18332. return new cc.Repeat(a, b)
  18333. };
  18334. cc.Repeat.create = cc.repeat;
  18335. cc.RepeatForever = cc.ActionInterval.extend({
  18336. _innerAction: null,
  18337. ctor: function(a) {
  18338. cc.ActionInterval.prototype.ctor.call(this);
  18339. this._innerAction = null;
  18340. a && this.initWithAction(a)
  18341. },
  18342. initWithAction: function(a) {
  18343. if (!a) throw "cc.RepeatForever.initWithAction(): action must be non null";
  18344. this._innerAction = a;
  18345. return !0
  18346. },
  18347. clone: function() {
  18348. var a = new cc.RepeatForever;
  18349. this._cloneDecoration(a);
  18350. a.initWithAction(this._innerAction.clone());
  18351. return a
  18352. },
  18353. startWithTarget: function(a) {
  18354. cc.ActionInterval.prototype.startWithTarget.call(this,
  18355. a);
  18356. this._innerAction.startWithTarget(a)
  18357. },
  18358. step: function(a) {
  18359. var b = this._innerAction;
  18360. b.step(a);
  18361. b.isDone() && (b.startWithTarget(this.target), b.step(b.getElapsed() - b._duration))
  18362. },
  18363. isDone: function() {
  18364. return !1
  18365. },
  18366. reverse: function() {
  18367. var a = new cc.RepeatForever(this._innerAction.reverse());
  18368. this._cloneDecoration(a);
  18369. this._reverseEaseList(a);
  18370. return a
  18371. },
  18372. setInnerAction: function(a) {
  18373. this._innerAction !== a && (this._innerAction = a)
  18374. },
  18375. getInnerAction: function() {
  18376. return this._innerAction
  18377. }
  18378. });
  18379. cc.repeatForever = function(a) {
  18380. return new cc.RepeatForever(a)
  18381. };
  18382. cc.RepeatForever.create = cc.repeatForever;
  18383. cc.Spawn = cc.ActionInterval.extend({
  18384. _one: null,
  18385. _two: null,
  18386. ctor: function(a) {
  18387. cc.ActionInterval.prototype.ctor.call(this);
  18388. this._two = this._one = null;
  18389. var b = a instanceof Array ? a : arguments,
  18390. c = b.length - 1;
  18391. 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript");
  18392. if (0 <= c) {
  18393. for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Spawn._actionOneTwo(d, b[e]));
  18394. this.initWithTwoActions(d, b[c])
  18395. }
  18396. },
  18397. initWithTwoActions: function(a, b) {
  18398. if (!a || !b) throw "cc.Spawn.initWithTwoActions(): arguments must all be non null";
  18399. var c = !1,
  18400. d = a._duration,
  18401. e = b._duration;
  18402. this.initWithDuration(Math.max(d, e)) && (this._one = a, this._two = b, d > e ? this._two = cc.Sequence._actionOneTwo(b, cc.delayTime(d - e)) : d < e && (this._one = cc.Sequence._actionOneTwo(a, cc.delayTime(e - d))), c = !0);
  18403. return c
  18404. },
  18405. clone: function() {
  18406. var a = new cc.Spawn;
  18407. this._cloneDecoration(a);
  18408. a.initWithTwoActions(this._one.clone(), this._two.clone());
  18409. return a
  18410. },
  18411. startWithTarget: function(a) {
  18412. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18413. this._one.startWithTarget(a);
  18414. this._two.startWithTarget(a)
  18415. },
  18416. stop: function() {
  18417. this._one.stop();
  18418. this._two.stop();
  18419. cc.Action.prototype.stop.call(this)
  18420. },
  18421. update: function(a) {
  18422. a = this._computeEaseTime(a);
  18423. this._one && this._one.update(a);
  18424. this._two && this._two.update(a)
  18425. },
  18426. reverse: function() {
  18427. var a = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
  18428. this._cloneDecoration(a);
  18429. this._reverseEaseList(a);
  18430. return a
  18431. }
  18432. });
  18433. cc.spawn = function(a) {
  18434. var b = a instanceof Array ? a : arguments;
  18435. 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  18436. for (var c = b[0], d = 1; d < b.length; d++) null != b[d] && (c = cc.Spawn._actionOneTwo(c, b[d]));
  18437. return c
  18438. };
  18439. cc.Spawn.create = cc.spawn;
  18440. cc.Spawn._actionOneTwo = function(a, b) {
  18441. var c = new cc.Spawn;
  18442. c.initWithTwoActions(a, b);
  18443. return c
  18444. };
  18445. cc.RotateTo = cc.ActionInterval.extend({
  18446. _dstAngleX: 0,
  18447. _startAngleX: 0,
  18448. _diffAngleX: 0,
  18449. _dstAngleY: 0,
  18450. _startAngleY: 0,
  18451. _diffAngleY: 0,
  18452. ctor: function(a, b, c) {
  18453. cc.ActionInterval.prototype.ctor.call(this);
  18454. void 0 !== b && this.initWithDuration(a, b, c)
  18455. },
  18456. initWithDuration: function(a, b, c) {
  18457. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._dstAngleX = b || 0, this._dstAngleY = c || this._dstAngleX, !0) : !1
  18458. },
  18459. clone: function() {
  18460. var a = new cc.RotateTo;
  18461. this._cloneDecoration(a);
  18462. a.initWithDuration(this._duration, this._dstAngleX,
  18463. this._dstAngleY);
  18464. return a
  18465. },
  18466. startWithTarget: function(a) {
  18467. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18468. var b = a.rotationX % 360,
  18469. c = this._dstAngleX - b;
  18470. 180 < c && (c -= 360); - 180 > c && (c += 360);
  18471. this._startAngleX = b;
  18472. this._diffAngleX = c;
  18473. this._startAngleY = a.rotationY % 360;
  18474. a = this._dstAngleY - this._startAngleY;
  18475. 180 < a && (a -= 360); - 180 > a && (a += 360);
  18476. this._diffAngleY = a
  18477. },
  18478. reverse: function() {
  18479. cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")
  18480. },
  18481. update: function(a) {
  18482. a = this._computeEaseTime(a);
  18483. this.target && (this.target.rotationX =
  18484. this._startAngleX + this._diffAngleX * a, this.target.rotationY = this._startAngleY + this._diffAngleY * a)
  18485. }
  18486. });
  18487. cc.rotateTo = function(a, b, c) {
  18488. return new cc.RotateTo(a, b, c)
  18489. };
  18490. cc.RotateTo.create = cc.rotateTo;
  18491. cc.RotateBy = cc.ActionInterval.extend({
  18492. _angleX: 0,
  18493. _startAngleX: 0,
  18494. _angleY: 0,
  18495. _startAngleY: 0,
  18496. ctor: function(a, b, c) {
  18497. cc.ActionInterval.prototype.ctor.call(this);
  18498. void 0 !== b && this.initWithDuration(a, b, c)
  18499. },
  18500. initWithDuration: function(a, b, c) {
  18501. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._angleX = b || 0, this._angleY = c || this._angleX, !0) : !1
  18502. },
  18503. clone: function() {
  18504. var a = new cc.RotateBy;
  18505. this._cloneDecoration(a);
  18506. a.initWithDuration(this._duration, this._angleX, this._angleY);
  18507. return a
  18508. },
  18509. startWithTarget: function(a) {
  18510. cc.ActionInterval.prototype.startWithTarget.call(this,
  18511. a);
  18512. this._startAngleX = a.rotationX;
  18513. this._startAngleY = a.rotationY
  18514. },
  18515. update: function(a) {
  18516. a = this._computeEaseTime(a);
  18517. this.target && (this.target.rotationX = this._startAngleX + this._angleX * a, this.target.rotationY = this._startAngleY + this._angleY * a)
  18518. },
  18519. reverse: function() {
  18520. var a = new cc.RotateBy(this._duration, -this._angleX, -this._angleY);
  18521. this._cloneDecoration(a);
  18522. this._reverseEaseList(a);
  18523. return a
  18524. }
  18525. });
  18526. cc.rotateBy = function(a, b, c) {
  18527. return new cc.RotateBy(a, b, c)
  18528. };
  18529. cc.RotateBy.create = cc.rotateBy;
  18530. cc.MoveBy = cc.ActionInterval.extend({
  18531. _positionDelta: null,
  18532. _startPosition: null,
  18533. _previousPosition: null,
  18534. ctor: function(a, b, c) {
  18535. cc.ActionInterval.prototype.ctor.call(this);
  18536. this._positionDelta = cc.p(0, 0);
  18537. this._startPosition = cc.p(0, 0);
  18538. this._previousPosition = cc.p(0, 0);
  18539. void 0 !== b && this.initWithDuration(a, b, c)
  18540. },
  18541. initWithDuration: function(a, b, c) {
  18542. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 !== b.x && (c = b.y, b = b.x), this._positionDelta.x = b, this._positionDelta.y = c, !0) : !1
  18543. },
  18544. clone: function() {
  18545. var a =
  18546. new cc.MoveBy;
  18547. this._cloneDecoration(a);
  18548. a.initWithDuration(this._duration, this._positionDelta);
  18549. return a
  18550. },
  18551. startWithTarget: function(a) {
  18552. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18553. var b = a.getPositionX();
  18554. a = a.getPositionY();
  18555. this._previousPosition.x = b;
  18556. this._previousPosition.y = a;
  18557. this._startPosition.x = b;
  18558. this._startPosition.y = a
  18559. },
  18560. update: function(a) {
  18561. a = this._computeEaseTime(a);
  18562. if (this.target) {
  18563. var b = this._positionDelta.x * a;
  18564. a *= this._positionDelta.y;
  18565. var c = this._startPosition;
  18566. if (cc.ENABLE_STACKABLE_ACTIONS) {
  18567. var d =
  18568. this.target.getPositionX(),
  18569. e = this.target.getPositionY(),
  18570. f = this._previousPosition;
  18571. c.x = c.x + d - f.x;
  18572. c.y = c.y + e - f.y;
  18573. b += c.x;
  18574. a += c.y;
  18575. f.x = b;
  18576. f.y = a;
  18577. this.target.setPosition(b, a)
  18578. } else this.target.setPosition(c.x + b, c.y + a)
  18579. }
  18580. },
  18581. reverse: function() {
  18582. var a = new cc.MoveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
  18583. this._cloneDecoration(a);
  18584. this._reverseEaseList(a);
  18585. return a
  18586. }
  18587. });
  18588. cc.moveBy = function(a, b, c) {
  18589. return new cc.MoveBy(a, b, c)
  18590. };
  18591. cc.MoveBy.create = cc.moveBy;
  18592. cc.MoveTo = cc.MoveBy.extend({
  18593. _endPosition: null,
  18594. ctor: function(a, b, c) {
  18595. cc.MoveBy.prototype.ctor.call(this);
  18596. this._endPosition = cc.p(0, 0);
  18597. void 0 !== b && this.initWithDuration(a, b, c)
  18598. },
  18599. initWithDuration: function(a, b, c) {
  18600. return cc.MoveBy.prototype.initWithDuration.call(this, a, b, c) ? (void 0 !== b.x && (c = b.y, b = b.x), this._endPosition.x = b, this._endPosition.y = c, !0) : !1
  18601. },
  18602. clone: function() {
  18603. var a = new cc.MoveTo;
  18604. this._cloneDecoration(a);
  18605. a.initWithDuration(this._duration, this._endPosition);
  18606. return a
  18607. },
  18608. startWithTarget: function(a) {
  18609. cc.MoveBy.prototype.startWithTarget.call(this,
  18610. a);
  18611. this._positionDelta.x = this._endPosition.x - a.getPositionX();
  18612. this._positionDelta.y = this._endPosition.y - a.getPositionY()
  18613. }
  18614. });
  18615. cc.moveTo = function(a, b, c) {
  18616. return new cc.MoveTo(a, b, c)
  18617. };
  18618. cc.MoveTo.create = cc.moveTo;
  18619. cc.SkewTo = cc.ActionInterval.extend({
  18620. _skewX: 0,
  18621. _skewY: 0,
  18622. _startSkewX: 0,
  18623. _startSkewY: 0,
  18624. _endSkewX: 0,
  18625. _endSkewY: 0,
  18626. _deltaX: 0,
  18627. _deltaY: 0,
  18628. ctor: function(a, b, c) {
  18629. cc.ActionInterval.prototype.ctor.call(this);
  18630. void 0 !== c && this.initWithDuration(a, b, c)
  18631. },
  18632. initWithDuration: function(a, b, c) {
  18633. var d = !1;
  18634. cc.ActionInterval.prototype.initWithDuration.call(this, a) && (this._endSkewX = b, this._endSkewY = c, d = !0);
  18635. return d
  18636. },
  18637. clone: function() {
  18638. var a = new cc.SkewTo;
  18639. this._cloneDecoration(a);
  18640. a.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
  18641. return a
  18642. },
  18643. startWithTarget: function(a) {
  18644. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18645. this._startSkewX = a.skewX % 180;
  18646. this._deltaX = this._endSkewX - this._startSkewX;
  18647. 180 < this._deltaX && (this._deltaX -= 360); - 180 > this._deltaX && (this._deltaX += 360);
  18648. this._startSkewY = a.skewY % 360;
  18649. this._deltaY = this._endSkewY - this._startSkewY;
  18650. 180 < this._deltaY && (this._deltaY -= 360); - 180 > this._deltaY && (this._deltaY += 360)
  18651. },
  18652. update: function(a) {
  18653. a = this._computeEaseTime(a);
  18654. this.target.skewX = this._startSkewX + this._deltaX * a;
  18655. this.target.skewY =
  18656. this._startSkewY + this._deltaY * a
  18657. }
  18658. });
  18659. cc.skewTo = function(a, b, c) {
  18660. return new cc.SkewTo(a, b, c)
  18661. };
  18662. cc.SkewTo.create = cc.skewTo;
  18663. cc.SkewBy = cc.SkewTo.extend({
  18664. ctor: function(a, b, c) {
  18665. cc.SkewTo.prototype.ctor.call(this);
  18666. void 0 !== c && this.initWithDuration(a, b, c)
  18667. },
  18668. initWithDuration: function(a, b, c) {
  18669. var d = !1;
  18670. cc.SkewTo.prototype.initWithDuration.call(this, a, b, c) && (this._skewX = b, this._skewY = c, d = !0);
  18671. return d
  18672. },
  18673. clone: function() {
  18674. var a = new cc.SkewBy;
  18675. this._cloneDecoration(a);
  18676. a.initWithDuration(this._duration, this._skewX, this._skewY);
  18677. return a
  18678. },
  18679. startWithTarget: function(a) {
  18680. cc.SkewTo.prototype.startWithTarget.call(this, a);
  18681. this._deltaX = this._skewX;
  18682. this._deltaY = this._skewY;
  18683. this._endSkewX = this._startSkewX + this._deltaX;
  18684. this._endSkewY = this._startSkewY + this._deltaY
  18685. },
  18686. reverse: function() {
  18687. var a = new cc.SkewBy(this._duration, -this._skewX, -this._skewY);
  18688. this._cloneDecoration(a);
  18689. this._reverseEaseList(a);
  18690. return a
  18691. }
  18692. });
  18693. cc.skewBy = function(a, b, c) {
  18694. return new cc.SkewBy(a, b, c)
  18695. };
  18696. cc.SkewBy.create = cc.skewBy;
  18697. cc.JumpBy = cc.ActionInterval.extend({
  18698. _startPosition: null,
  18699. _delta: null,
  18700. _height: 0,
  18701. _jumps: 0,
  18702. _previousPosition: null,
  18703. ctor: function(a, b, c, d, e) {
  18704. cc.ActionInterval.prototype.ctor.call(this);
  18705. this._startPosition = cc.p(0, 0);
  18706. this._previousPosition = cc.p(0, 0);
  18707. this._delta = cc.p(0, 0);
  18708. void 0 !== d && this.initWithDuration(a, b, c, d, e)
  18709. },
  18710. initWithDuration: function(a, b, c, d, e) {
  18711. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (void 0 === e && (e = d, d = c, c = b.y, b = b.x), this._delta.x = b, this._delta.y = c, this._height = d, this._jumps =
  18712. e, !0) : !1
  18713. },
  18714. clone: function() {
  18715. var a = new cc.JumpBy;
  18716. this._cloneDecoration(a);
  18717. a.initWithDuration(this._duration, this._delta, this._height, this._jumps);
  18718. return a
  18719. },
  18720. startWithTarget: function(a) {
  18721. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18722. var b = a.getPositionX();
  18723. a = a.getPositionY();
  18724. this._previousPosition.x = b;
  18725. this._previousPosition.y = a;
  18726. this._startPosition.x = b;
  18727. this._startPosition.y = a
  18728. },
  18729. update: function(a) {
  18730. a = this._computeEaseTime(a);
  18731. if (this.target) {
  18732. var b = a * this._jumps % 1,
  18733. b = 4 * this._height * b * (1 - b),
  18734. b = b + this._delta.y *
  18735. a;
  18736. a *= this._delta.x;
  18737. var c = this._startPosition;
  18738. if (cc.ENABLE_STACKABLE_ACTIONS) {
  18739. var d = this.target.getPositionX(),
  18740. e = this.target.getPositionY(),
  18741. f = this._previousPosition;
  18742. c.x = c.x + d - f.x;
  18743. c.y = c.y + e - f.y;
  18744. a += c.x;
  18745. b += c.y;
  18746. f.x = a;
  18747. f.y = b;
  18748. this.target.setPosition(a, b)
  18749. } else this.target.setPosition(c.x + a, c.y + b)
  18750. }
  18751. },
  18752. reverse: function() {
  18753. var a = new cc.JumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
  18754. this._cloneDecoration(a);
  18755. this._reverseEaseList(a);
  18756. return a
  18757. }
  18758. });
  18759. cc.jumpBy = function(a, b, c, d, e) {
  18760. return new cc.JumpBy(a, b, c, d, e)
  18761. };
  18762. cc.JumpBy.create = cc.jumpBy;
  18763. cc.JumpTo = cc.JumpBy.extend({
  18764. _endPosition: null,
  18765. ctor: function(a, b, c, d, e) {
  18766. cc.JumpBy.prototype.ctor.call(this);
  18767. this._endPosition = cc.p(0, 0);
  18768. void 0 !== d && this.initWithDuration(a, b, c, d, e)
  18769. },
  18770. initWithDuration: function(a, b, c, d, e) {
  18771. return cc.JumpBy.prototype.initWithDuration.call(this, a, b, c, d, e) ? (void 0 === e && (c = b.y, b = b.x), this._endPosition.x = b, this._endPosition.y = c, !0) : !1
  18772. },
  18773. startWithTarget: function(a) {
  18774. cc.JumpBy.prototype.startWithTarget.call(this, a);
  18775. this._delta.x = this._endPosition.x - this._startPosition.x;
  18776. this._delta.y =
  18777. this._endPosition.y - this._startPosition.y
  18778. },
  18779. clone: function() {
  18780. var a = new cc.JumpTo;
  18781. this._cloneDecoration(a);
  18782. a.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
  18783. return a
  18784. }
  18785. });
  18786. cc.jumpTo = function(a, b, c, d, e) {
  18787. return new cc.JumpTo(a, b, c, d, e)
  18788. };
  18789. cc.JumpTo.create = cc.jumpTo;
  18790. cc.bezierAt = function(a, b, c, d, e) {
  18791. return Math.pow(1 - e, 3) * a + 3 * e * Math.pow(1 - e, 2) * b + 3 * Math.pow(e, 2) * (1 - e) * c + Math.pow(e, 3) * d
  18792. };
  18793. cc.BezierBy = cc.ActionInterval.extend({
  18794. _config: null,
  18795. _startPosition: null,
  18796. _previousPosition: null,
  18797. ctor: function(a, b) {
  18798. cc.ActionInterval.prototype.ctor.call(this);
  18799. this._config = [];
  18800. this._startPosition = cc.p(0, 0);
  18801. this._previousPosition = cc.p(0, 0);
  18802. b && this.initWithDuration(a, b)
  18803. },
  18804. initWithDuration: function(a, b) {
  18805. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._config = b, !0) : !1
  18806. },
  18807. clone: function() {
  18808. var a = new cc.BezierBy;
  18809. this._cloneDecoration(a);
  18810. for (var b = [], c = 0; c < this._config.length; c++) {
  18811. var d =
  18812. this._config[c];
  18813. b.push(cc.p(d.x, d.y))
  18814. }
  18815. a.initWithDuration(this._duration, b);
  18816. return a
  18817. },
  18818. startWithTarget: function(a) {
  18819. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18820. var b = a.getPositionX();
  18821. a = a.getPositionY();
  18822. this._previousPosition.x = b;
  18823. this._previousPosition.y = a;
  18824. this._startPosition.x = b;
  18825. this._startPosition.y = a
  18826. },
  18827. update: function(a) {
  18828. a = this._computeEaseTime(a);
  18829. if (this.target) {
  18830. var b = this._config,
  18831. c = b[0].y,
  18832. d = b[1].y,
  18833. e = b[2].y,
  18834. b = cc.bezierAt(0, b[0].x, b[1].x, b[2].x, a);
  18835. a = cc.bezierAt(0, c, d, e, a);
  18836. c = this._startPosition;
  18837. if (cc.ENABLE_STACKABLE_ACTIONS) {
  18838. var d = this.target.getPositionX(),
  18839. e = this.target.getPositionY(),
  18840. f = this._previousPosition;
  18841. c.x = c.x + d - f.x;
  18842. c.y = c.y + e - f.y;
  18843. b += c.x;
  18844. a += c.y;
  18845. f.x = b;
  18846. f.y = a;
  18847. this.target.setPosition(b, a)
  18848. } else this.target.setPosition(c.x + b, c.y + a)
  18849. }
  18850. },
  18851. reverse: function() {
  18852. var a = this._config,
  18853. a = [cc.pAdd(a[1], cc.pNeg(a[2])), cc.pAdd(a[0], cc.pNeg(a[2])), cc.pNeg(a[2])],
  18854. a = new cc.BezierBy(this._duration, a);
  18855. this._cloneDecoration(a);
  18856. this._reverseEaseList(a);
  18857. return a
  18858. }
  18859. });
  18860. cc.bezierBy = function(a, b) {
  18861. return new cc.BezierBy(a, b)
  18862. };
  18863. cc.BezierBy.create = cc.bezierBy;
  18864. cc.BezierTo = cc.BezierBy.extend({
  18865. _toConfig: null,
  18866. ctor: function(a, b) {
  18867. cc.BezierBy.prototype.ctor.call(this);
  18868. this._toConfig = [];
  18869. b && this.initWithDuration(a, b)
  18870. },
  18871. initWithDuration: function(a, b) {
  18872. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toConfig = b, !0) : !1
  18873. },
  18874. clone: function() {
  18875. var a = new cc.BezierTo;
  18876. this._cloneDecoration(a);
  18877. a.initWithDuration(this._duration, this._toConfig);
  18878. return a
  18879. },
  18880. startWithTarget: function(a) {
  18881. cc.BezierBy.prototype.startWithTarget.call(this, a);
  18882. a = this._startPosition;
  18883. var b =
  18884. this._toConfig,
  18885. c = this._config;
  18886. c[0] = cc.pSub(b[0], a);
  18887. c[1] = cc.pSub(b[1], a);
  18888. c[2] = cc.pSub(b[2], a)
  18889. }
  18890. });
  18891. cc.bezierTo = function(a, b) {
  18892. return new cc.BezierTo(a, b)
  18893. };
  18894. cc.BezierTo.create = cc.bezierTo;
  18895. cc.ScaleTo = cc.ActionInterval.extend({
  18896. _scaleX: 1,
  18897. _scaleY: 1,
  18898. _startScaleX: 1,
  18899. _startScaleY: 1,
  18900. _endScaleX: 0,
  18901. _endScaleY: 0,
  18902. _deltaX: 0,
  18903. _deltaY: 0,
  18904. ctor: function(a, b, c) {
  18905. cc.ActionInterval.prototype.ctor.call(this);
  18906. void 0 !== b && this.initWithDuration(a, b, c)
  18907. },
  18908. initWithDuration: function(a, b, c) {
  18909. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._endScaleX = b, this._endScaleY = null != c ? c : b, !0) : !1
  18910. },
  18911. clone: function() {
  18912. var a = new cc.ScaleTo;
  18913. this._cloneDecoration(a);
  18914. a.initWithDuration(this._duration, this._endScaleX,
  18915. this._endScaleY);
  18916. return a
  18917. },
  18918. startWithTarget: function(a) {
  18919. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18920. this._startScaleX = a.scaleX;
  18921. this._startScaleY = a.scaleY;
  18922. this._deltaX = this._endScaleX - this._startScaleX;
  18923. this._deltaY = this._endScaleY - this._startScaleY
  18924. },
  18925. update: function(a) {
  18926. a = this._computeEaseTime(a);
  18927. this.target && (this.target.scaleX = this._startScaleX + this._deltaX * a, this.target.scaleY = this._startScaleY + this._deltaY * a)
  18928. }
  18929. });
  18930. cc.scaleTo = function(a, b, c) {
  18931. return new cc.ScaleTo(a, b, c)
  18932. };
  18933. cc.ScaleTo.create = cc.scaleTo;
  18934. cc.ScaleBy = cc.ScaleTo.extend({
  18935. startWithTarget: function(a) {
  18936. cc.ScaleTo.prototype.startWithTarget.call(this, a);
  18937. this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
  18938. this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY
  18939. },
  18940. reverse: function() {
  18941. var a = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
  18942. this._cloneDecoration(a);
  18943. this._reverseEaseList(a);
  18944. return a
  18945. },
  18946. clone: function() {
  18947. var a = new cc.ScaleBy;
  18948. this._cloneDecoration(a);
  18949. a.initWithDuration(this._duration, this._endScaleX,
  18950. this._endScaleY);
  18951. return a
  18952. }
  18953. });
  18954. cc.scaleBy = function(a, b, c) {
  18955. return new cc.ScaleBy(a, b, c)
  18956. };
  18957. cc.ScaleBy.create = cc.scaleBy;
  18958. cc.Blink = cc.ActionInterval.extend({
  18959. _times: 0,
  18960. _originalState: !1,
  18961. ctor: function(a, b) {
  18962. cc.ActionInterval.prototype.ctor.call(this);
  18963. void 0 !== b && this.initWithDuration(a, b)
  18964. },
  18965. initWithDuration: function(a, b) {
  18966. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._times = b, !0) : !1
  18967. },
  18968. clone: function() {
  18969. var a = new cc.Blink;
  18970. this._cloneDecoration(a);
  18971. a.initWithDuration(this._duration, this._times);
  18972. return a
  18973. },
  18974. update: function(a) {
  18975. a = this._computeEaseTime(a);
  18976. if (this.target && !this.isDone()) {
  18977. var b = 1 / this._times;
  18978. this.target.visible =
  18979. a % b > b / 2
  18980. }
  18981. },
  18982. startWithTarget: function(a) {
  18983. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  18984. this._originalState = a.visible
  18985. },
  18986. stop: function() {
  18987. this.target.visible = this._originalState;
  18988. cc.ActionInterval.prototype.stop.call(this)
  18989. },
  18990. reverse: function() {
  18991. var a = new cc.Blink(this._duration, this._times);
  18992. this._cloneDecoration(a);
  18993. this._reverseEaseList(a);
  18994. return a
  18995. }
  18996. });
  18997. cc.blink = function(a, b) {
  18998. return new cc.Blink(a, b)
  18999. };
  19000. cc.Blink.create = cc.blink;
  19001. cc.FadeTo = cc.ActionInterval.extend({
  19002. _toOpacity: 0,
  19003. _fromOpacity: 0,
  19004. ctor: function(a, b) {
  19005. cc.ActionInterval.prototype.ctor.call(this);
  19006. void 0 !== b && this.initWithDuration(a, b)
  19007. },
  19008. initWithDuration: function(a, b) {
  19009. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toOpacity = b, !0) : !1
  19010. },
  19011. clone: function() {
  19012. var a = new cc.FadeTo;
  19013. this._cloneDecoration(a);
  19014. a.initWithDuration(this._duration, this._toOpacity);
  19015. return a
  19016. },
  19017. update: function(a) {
  19018. a = this._computeEaseTime(a);
  19019. var b = void 0 !== this._fromOpacity ? this._fromOpacity :
  19020. 255;
  19021. this.target.opacity = b + (this._toOpacity - b) * a
  19022. },
  19023. startWithTarget: function(a) {
  19024. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19025. this._fromOpacity = a.opacity
  19026. }
  19027. });
  19028. cc.fadeTo = function(a, b) {
  19029. return new cc.FadeTo(a, b)
  19030. };
  19031. cc.FadeTo.create = cc.fadeTo;
  19032. cc.FadeIn = cc.FadeTo.extend({
  19033. _reverseAction: null,
  19034. ctor: function(a) {
  19035. cc.FadeTo.prototype.ctor.call(this);
  19036. null == a && (a = 0);
  19037. this.initWithDuration(a, 255)
  19038. },
  19039. reverse: function() {
  19040. var a = new cc.FadeOut;
  19041. a.initWithDuration(this._duration, 0);
  19042. this._cloneDecoration(a);
  19043. this._reverseEaseList(a);
  19044. return a
  19045. },
  19046. clone: function() {
  19047. var a = new cc.FadeIn;
  19048. this._cloneDecoration(a);
  19049. a.initWithDuration(this._duration, this._toOpacity);
  19050. return a
  19051. },
  19052. startWithTarget: function(a) {
  19053. this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity);
  19054. cc.FadeTo.prototype.startWithTarget.call(this, a)
  19055. }
  19056. });
  19057. cc.fadeIn = function(a) {
  19058. return new cc.FadeIn(a)
  19059. };
  19060. cc.FadeIn.create = cc.fadeIn;
  19061. cc.FadeOut = cc.FadeTo.extend({
  19062. ctor: function(a) {
  19063. cc.FadeTo.prototype.ctor.call(this);
  19064. null == a && (a = 0);
  19065. this.initWithDuration(a, 0)
  19066. },
  19067. reverse: function() {
  19068. var a = new cc.FadeIn;
  19069. a._reverseAction = this;
  19070. a.initWithDuration(this._duration, 255);
  19071. this._cloneDecoration(a);
  19072. this._reverseEaseList(a);
  19073. return a
  19074. },
  19075. clone: function() {
  19076. var a = new cc.FadeOut;
  19077. this._cloneDecoration(a);
  19078. a.initWithDuration(this._duration, this._toOpacity);
  19079. return a
  19080. }
  19081. });
  19082. cc.fadeOut = function(a) {
  19083. return new cc.FadeOut(a)
  19084. };
  19085. cc.FadeOut.create = cc.fadeOut;
  19086. cc.TintTo = cc.ActionInterval.extend({
  19087. _to: null,
  19088. _from: null,
  19089. ctor: function(a, b, c, d) {
  19090. cc.ActionInterval.prototype.ctor.call(this);
  19091. this._to = cc.color(0, 0, 0);
  19092. this._from = cc.color(0, 0, 0);
  19093. void 0 !== d && this.initWithDuration(a, b, c, d)
  19094. },
  19095. initWithDuration: function(a, b, c, d) {
  19096. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = cc.color(b, c, d), !0) : !1
  19097. },
  19098. clone: function() {
  19099. var a = new cc.TintTo;
  19100. this._cloneDecoration(a);
  19101. var b = this._to;
  19102. a.initWithDuration(this._duration, b.r, b.g, b.b);
  19103. return a
  19104. },
  19105. startWithTarget: function(a) {
  19106. cc.ActionInterval.prototype.startWithTarget.call(this,
  19107. a);
  19108. this._from = this.target.color
  19109. },
  19110. update: function(a) {
  19111. a = this._computeEaseTime(a);
  19112. var b = this._from,
  19113. c = this._to;
  19114. b && (this.target.color = cc.color(b.r + (c.r - b.r) * a, b.g + (c.g - b.g) * a, b.b + (c.b - b.b) * a))
  19115. }
  19116. });
  19117. cc.tintTo = function(a, b, c, d) {
  19118. return new cc.TintTo(a, b, c, d)
  19119. };
  19120. cc.TintTo.create = cc.tintTo;
  19121. cc.TintBy = cc.ActionInterval.extend({
  19122. _deltaR: 0,
  19123. _deltaG: 0,
  19124. _deltaB: 0,
  19125. _fromR: 0,
  19126. _fromG: 0,
  19127. _fromB: 0,
  19128. ctor: function(a, b, c, d) {
  19129. cc.ActionInterval.prototype.ctor.call(this);
  19130. void 0 !== d && this.initWithDuration(a, b, c, d)
  19131. },
  19132. initWithDuration: function(a, b, c, d) {
  19133. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._deltaR = b, this._deltaG = c, this._deltaB = d, !0) : !1
  19134. },
  19135. clone: function() {
  19136. var a = new cc.TintBy;
  19137. this._cloneDecoration(a);
  19138. a.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
  19139. return a
  19140. },
  19141. startWithTarget: function(a) {
  19142. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19143. a = a.color;
  19144. this._fromR = a.r;
  19145. this._fromG = a.g;
  19146. this._fromB = a.b
  19147. },
  19148. update: function(a) {
  19149. a = this._computeEaseTime(a);
  19150. this.target.color = cc.color(this._fromR + this._deltaR * a, this._fromG + this._deltaG * a, this._fromB + this._deltaB * a)
  19151. },
  19152. reverse: function() {
  19153. var a = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
  19154. this._cloneDecoration(a);
  19155. this._reverseEaseList(a);
  19156. return a
  19157. }
  19158. });
  19159. cc.tintBy = function(a, b, c, d) {
  19160. return new cc.TintBy(a, b, c, d)
  19161. };
  19162. cc.TintBy.create = cc.tintBy;
  19163. cc.DelayTime = cc.ActionInterval.extend({
  19164. update: function(a) {},
  19165. reverse: function() {
  19166. var a = new cc.DelayTime(this._duration);
  19167. this._cloneDecoration(a);
  19168. this._reverseEaseList(a);
  19169. return a
  19170. },
  19171. clone: function() {
  19172. var a = new cc.DelayTime;
  19173. this._cloneDecoration(a);
  19174. a.initWithDuration(this._duration);
  19175. return a
  19176. }
  19177. });
  19178. cc.delayTime = function(a) {
  19179. return new cc.DelayTime(a)
  19180. };
  19181. cc.DelayTime.create = cc.delayTime;
  19182. cc.ReverseTime = cc.ActionInterval.extend({
  19183. _other: null,
  19184. ctor: function(a) {
  19185. cc.ActionInterval.prototype.ctor.call(this);
  19186. this._other = null;
  19187. a && this.initWithAction(a)
  19188. },
  19189. initWithAction: function(a) {
  19190. if (!a) throw "cc.ReverseTime.initWithAction(): action must be non null";
  19191. if (a === this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
  19192. return cc.ActionInterval.prototype.initWithDuration.call(this, a._duration) ? (this._other = a, !0) : !1
  19193. },
  19194. clone: function() {
  19195. var a = new cc.ReverseTime;
  19196. this._cloneDecoration(a);
  19197. a.initWithAction(this._other.clone());
  19198. return a
  19199. },
  19200. startWithTarget: function(a) {
  19201. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19202. this._other.startWithTarget(a)
  19203. },
  19204. update: function(a) {
  19205. a = this._computeEaseTime(a);
  19206. this._other && this._other.update(1 - a)
  19207. },
  19208. reverse: function() {
  19209. return this._other.clone()
  19210. },
  19211. stop: function() {
  19212. this._other.stop();
  19213. cc.Action.prototype.stop.call(this)
  19214. }
  19215. });
  19216. cc.reverseTime = function(a) {
  19217. return new cc.ReverseTime(a)
  19218. };
  19219. cc.ReverseTime.create = cc.reverseTime;
  19220. cc.Animate = cc.ActionInterval.extend({
  19221. _animation: null,
  19222. _nextFrame: 0,
  19223. _origFrame: null,
  19224. _executedLoops: 0,
  19225. _splitTimes: null,
  19226. ctor: function(a) {
  19227. cc.ActionInterval.prototype.ctor.call(this);
  19228. this._splitTimes = [];
  19229. a && this.initWithAnimation(a)
  19230. },
  19231. getAnimation: function() {
  19232. return this._animation
  19233. },
  19234. setAnimation: function(a) {
  19235. this._animation = a
  19236. },
  19237. initWithAnimation: function(a) {
  19238. if (!a) throw "cc.Animate.initWithAnimation(): animation must be non-NULL";
  19239. var b = a.getDuration();
  19240. if (this.initWithDuration(b * a.getLoops())) {
  19241. this._nextFrame =
  19242. 0;
  19243. this.setAnimation(a);
  19244. this._origFrame = null;
  19245. this._executedLoops = 0;
  19246. var c = this._splitTimes,
  19247. d = c.length = 0,
  19248. e = b / a.getTotalDelayUnits();
  19249. a = a.getFrames();
  19250. cc.arrayVerifyType(a, cc.AnimationFrame);
  19251. for (var f = 0; f < a.length; f++) {
  19252. var g = d * e / b,
  19253. d = d + a[f].getDelayUnits();
  19254. c.push(g)
  19255. }
  19256. return !0
  19257. }
  19258. return !1
  19259. },
  19260. clone: function() {
  19261. var a = new cc.Animate;
  19262. this._cloneDecoration(a);
  19263. a.initWithAnimation(this._animation.clone());
  19264. return a
  19265. },
  19266. startWithTarget: function(a) {
  19267. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19268. this._animation.getRestoreOriginalFrame() &&
  19269. (this._origFrame = a.displayFrame());
  19270. this._executedLoops = this._nextFrame = 0
  19271. },
  19272. update: function(a) {
  19273. a = this._computeEaseTime(a);
  19274. 1 > a && (a *= this._animation.getLoops(), (0 | a) > this._executedLoops && (this._nextFrame = 0, this._executedLoops++), a %= 1);
  19275. for (var b = this._animation.getFrames(), c = b.length, d = this._splitTimes, e = this._nextFrame; e < c; e++)
  19276. if (d[e] <= a) this.target.setSpriteFrame(b[e].getSpriteFrame()), this._nextFrame = e + 1;
  19277. else break
  19278. },
  19279. reverse: function() {
  19280. var a = this._animation,
  19281. b = a.getFrames(),
  19282. c = [];
  19283. cc.arrayVerifyType(b,
  19284. cc.AnimationFrame);
  19285. if (0 < b.length)
  19286. for (var d = b.length - 1; 0 <= d; d--) {
  19287. var e = b[d];
  19288. if (!e) break;
  19289. c.push(e.clone())
  19290. }
  19291. b = new cc.Animation(c, a.getDelayPerUnit(), a.getLoops());
  19292. b.setRestoreOriginalFrame(a.getRestoreOriginalFrame());
  19293. a = new cc.Animate(b);
  19294. this._cloneDecoration(a);
  19295. this._reverseEaseList(a);
  19296. return a
  19297. },
  19298. stop: function() {
  19299. this._animation.getRestoreOriginalFrame() && this.target && this.target.setSpriteFrame(this._origFrame);
  19300. cc.Action.prototype.stop.call(this)
  19301. }
  19302. });
  19303. cc.animate = function(a) {
  19304. return new cc.Animate(a)
  19305. };
  19306. cc.Animate.create = cc.animate;
  19307. cc.TargetedAction = cc.ActionInterval.extend({
  19308. _action: null,
  19309. _forcedTarget: null,
  19310. ctor: function(a, b) {
  19311. cc.ActionInterval.prototype.ctor.call(this);
  19312. b && this.initWithTarget(a, b)
  19313. },
  19314. initWithTarget: function(a, b) {
  19315. return this.initWithDuration(b._duration) ? (this._forcedTarget = a, this._action = b, !0) : !1
  19316. },
  19317. clone: function() {
  19318. var a = new cc.TargetedAction;
  19319. this._cloneDecoration(a);
  19320. a.initWithTarget(this._forcedTarget, this._action.clone());
  19321. return a
  19322. },
  19323. startWithTarget: function(a) {
  19324. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19325. this._action.startWithTarget(this._forcedTarget)
  19326. },
  19327. stop: function() {
  19328. this._action.stop()
  19329. },
  19330. update: function(a) {
  19331. a = this._computeEaseTime(a);
  19332. this._action.update(a)
  19333. },
  19334. getForcedTarget: function() {
  19335. return this._forcedTarget
  19336. },
  19337. setForcedTarget: function(a) {
  19338. this._forcedTarget !== a && (this._forcedTarget = a)
  19339. }
  19340. });
  19341. cc.targetedAction = function(a, b) {
  19342. return new cc.TargetedAction(a, b)
  19343. };
  19344. cc.TargetedAction.create = cc.targetedAction;
  19345. cc.ActionInstant = cc.FiniteTimeAction.extend({
  19346. isDone: function() {
  19347. return !0
  19348. },
  19349. step: function(a) {
  19350. this.update(1)
  19351. },
  19352. update: function(a) {},
  19353. reverse: function() {
  19354. return this.clone()
  19355. },
  19356. clone: function() {
  19357. return new cc.ActionInstant
  19358. }
  19359. });
  19360. cc.Show = cc.ActionInstant.extend({
  19361. update: function(a) {
  19362. this.target.visible = !0
  19363. },
  19364. reverse: function() {
  19365. return new cc.Hide
  19366. },
  19367. clone: function() {
  19368. return new cc.Show
  19369. }
  19370. });
  19371. cc.show = function() {
  19372. return new cc.Show
  19373. };
  19374. cc.Show.create = cc.show;
  19375. cc.Hide = cc.ActionInstant.extend({
  19376. update: function(a) {
  19377. this.target.visible = !1
  19378. },
  19379. reverse: function() {
  19380. return new cc.Show
  19381. },
  19382. clone: function() {
  19383. return new cc.Hide
  19384. }
  19385. });
  19386. cc.hide = function() {
  19387. return new cc.Hide
  19388. };
  19389. cc.Hide.create = cc.hide;
  19390. cc.ToggleVisibility = cc.ActionInstant.extend({
  19391. update: function(a) {
  19392. this.target.visible = !this.target.visible
  19393. },
  19394. reverse: function() {
  19395. return new cc.ToggleVisibility
  19396. },
  19397. clone: function() {
  19398. return new cc.ToggleVisibility
  19399. }
  19400. });
  19401. cc.toggleVisibility = function() {
  19402. return new cc.ToggleVisibility
  19403. };
  19404. cc.ToggleVisibility.create = cc.toggleVisibility;
  19405. cc.RemoveSelf = cc.ActionInstant.extend({
  19406. _isNeedCleanUp: !0,
  19407. ctor: function(a) {
  19408. cc.FiniteTimeAction.prototype.ctor.call(this);
  19409. void 0 !== a && this.init(a)
  19410. },
  19411. update: function(a) {
  19412. this.target.removeFromParent(this._isNeedCleanUp)
  19413. },
  19414. init: function(a) {
  19415. this._isNeedCleanUp = a;
  19416. return !0
  19417. },
  19418. reverse: function() {
  19419. return new cc.RemoveSelf(this._isNeedCleanUp)
  19420. },
  19421. clone: function() {
  19422. return new cc.RemoveSelf(this._isNeedCleanUp)
  19423. }
  19424. });
  19425. cc.removeSelf = function(a) {
  19426. return new cc.RemoveSelf(a)
  19427. };
  19428. cc.RemoveSelf.create = cc.removeSelf;
  19429. cc.FlipX = cc.ActionInstant.extend({
  19430. _flippedX: !1,
  19431. ctor: function(a) {
  19432. cc.FiniteTimeAction.prototype.ctor.call(this);
  19433. this._flippedX = !1;
  19434. void 0 !== a && this.initWithFlipX(a)
  19435. },
  19436. initWithFlipX: function(a) {
  19437. this._flippedX = a;
  19438. return !0
  19439. },
  19440. update: function(a) {
  19441. this.target.flippedX = this._flippedX
  19442. },
  19443. reverse: function() {
  19444. return new cc.FlipX(!this._flippedX)
  19445. },
  19446. clone: function() {
  19447. var a = new cc.FlipX;
  19448. a.initWithFlipX(this._flippedX);
  19449. return a
  19450. }
  19451. });
  19452. cc.flipX = function(a) {
  19453. return new cc.FlipX(a)
  19454. };
  19455. cc.FlipX.create = cc.flipX;
  19456. cc.FlipY = cc.ActionInstant.extend({
  19457. _flippedY: !1,
  19458. ctor: function(a) {
  19459. cc.FiniteTimeAction.prototype.ctor.call(this);
  19460. this._flippedY = !1;
  19461. void 0 !== a && this.initWithFlipY(a)
  19462. },
  19463. initWithFlipY: function(a) {
  19464. this._flippedY = a;
  19465. return !0
  19466. },
  19467. update: function(a) {
  19468. this.target.flippedY = this._flippedY
  19469. },
  19470. reverse: function() {
  19471. return new cc.FlipY(!this._flippedY)
  19472. },
  19473. clone: function() {
  19474. var a = new cc.FlipY;
  19475. a.initWithFlipY(this._flippedY);
  19476. return a
  19477. }
  19478. });
  19479. cc.flipY = function(a) {
  19480. return new cc.FlipY(a)
  19481. };
  19482. cc.FlipY.create = cc.flipY;
  19483. cc.Place = cc.ActionInstant.extend({
  19484. _x: 0,
  19485. _y: 0,
  19486. ctor: function(a, b) {
  19487. cc.FiniteTimeAction.prototype.ctor.call(this);
  19488. this._y = this._x = 0;
  19489. void 0 !== a && (void 0 !== a.x && (b = a.y, a = a.x), this.initWithPosition(a, b))
  19490. },
  19491. initWithPosition: function(a, b) {
  19492. this._x = a;
  19493. this._y = b;
  19494. return !0
  19495. },
  19496. update: function(a) {
  19497. this.target.setPosition(this._x, this._y)
  19498. },
  19499. clone: function() {
  19500. var a = new cc.Place;
  19501. a.initWithPosition(this._x, this._y);
  19502. return a
  19503. }
  19504. });
  19505. cc.place = function(a, b) {
  19506. return new cc.Place(a, b)
  19507. };
  19508. cc.Place.create = cc.place;
  19509. cc.CallFunc = cc.ActionInstant.extend({
  19510. _selectorTarget: null,
  19511. _callFunc: null,
  19512. _function: null,
  19513. _data: null,
  19514. ctor: function(a, b, c) {
  19515. cc.FiniteTimeAction.prototype.ctor.call(this);
  19516. void 0 !== a && (void 0 === b ? this.initWithFunction(a) : this.initWithFunction(a, b, c))
  19517. },
  19518. initWithFunction: function(a, b, c) {
  19519. b ? (this._data = c, this._callFunc = a, this._selectorTarget = b) : a && (this._function = a);
  19520. return !0
  19521. },
  19522. execute: function() {
  19523. null != this._callFunc ? this._callFunc.call(this._selectorTarget, this.target, this._data) : this._function && this._function.call(null,
  19524. this.target)
  19525. },
  19526. update: function(a) {
  19527. this.execute()
  19528. },
  19529. getTargetCallback: function() {
  19530. return this._selectorTarget
  19531. },
  19532. setTargetCallback: function(a) {
  19533. a !== this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), this._selectorTarget = a)
  19534. },
  19535. clone: function() {
  19536. var a = new cc.CallFunc;
  19537. this._selectorTarget ? a.initWithFunction(this._callFunc, this._selectorTarget, this._data) : this._function && a.initWithFunction(this._function);
  19538. return a
  19539. }
  19540. });
  19541. cc.callFunc = function(a, b, c) {
  19542. return new cc.CallFunc(a, b, c)
  19543. };
  19544. cc.CallFunc.create = cc.callFunc;
  19545. cc.ActionCamera = cc.ActionInterval.extend({
  19546. _centerXOrig: 0,
  19547. _centerYOrig: 0,
  19548. _centerZOrig: 0,
  19549. _eyeXOrig: 0,
  19550. _eyeYOrig: 0,
  19551. _eyeZOrig: 0,
  19552. _upXOrig: 0,
  19553. _upYOrig: 0,
  19554. _upZOrig: 0,
  19555. ctor: function() {
  19556. cc.ActionInterval.prototype.ctor.call(this);
  19557. this._upZOrig = this._upYOrig = this._upXOrig = this._eyeZOrig = this._eyeYOrig = this._eyeXOrig = this._centerZOrig = this._centerYOrig = this._centerXOrig = 0
  19558. },
  19559. startWithTarget: function(a) {
  19560. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19561. a = a.getCamera();
  19562. var b = a.getCenter();
  19563. this._centerXOrig = b.x;
  19564. this._centerYOrig = b.y;
  19565. this._centerZOrig = b.z;
  19566. b = a.getEye();
  19567. this._eyeXOrig = b.x;
  19568. this._eyeYOrig = b.y;
  19569. this._eyeZOrig = b.z;
  19570. a = a.getUp();
  19571. this._upXOrig = a.x;
  19572. this._upYOrig = a.y;
  19573. this._upZOrig = a.z
  19574. },
  19575. clone: function() {
  19576. return new cc.ActionCamera
  19577. },
  19578. reverse: function() {
  19579. return new cc.ReverseTime(this)
  19580. }
  19581. });
  19582. cc.OrbitCamera = cc.ActionCamera.extend({
  19583. _radius: 0,
  19584. _deltaRadius: 0,
  19585. _angleZ: 0,
  19586. _deltaAngleZ: 0,
  19587. _angleX: 0,
  19588. _deltaAngleX: 0,
  19589. _radZ: 0,
  19590. _radDeltaZ: 0,
  19591. _radX: 0,
  19592. _radDeltaX: 0,
  19593. ctor: function(a, b, c, d, e, f, g) {
  19594. cc.ActionCamera.prototype.ctor.call(this);
  19595. void 0 !== g && this.initWithDuration(a, b, c, d, e, f, g)
  19596. },
  19597. initWithDuration: function(a, b, c, d, e, f, g) {
  19598. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._radius = b, this._deltaRadius = c, this._angleZ = d, this._deltaAngleZ = e, this._angleX = f, this._deltaAngleX = g, this._radDeltaZ =
  19599. cc.degreesToRadians(e), this._radDeltaX = cc.degreesToRadians(g), !0) : !1
  19600. },
  19601. sphericalRadius: function() {
  19602. var a, b;
  19603. b = this.target.getCamera();
  19604. var c = b.getEye();
  19605. a = b.getCenter();
  19606. b = c.x - a.x;
  19607. var d = c.y - a.y;
  19608. a = c.z - a.z;
  19609. var c = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2) + Math.pow(a, 2)),
  19610. e = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2));
  19611. 0 === e && (e = cc.FLT_EPSILON);
  19612. 0 === c && (c = cc.FLT_EPSILON);
  19613. a = Math.acos(a / c);
  19614. b = 0 > b ? Math.PI - Math.asin(d / e) : Math.asin(d / e);
  19615. return {
  19616. newRadius: c / cc.Camera.getZEye(),
  19617. zenith: a,
  19618. azimuth: b
  19619. }
  19620. },
  19621. startWithTarget: function(a) {
  19622. cc.ActionInterval.prototype.startWithTarget.call(this,
  19623. a);
  19624. a = this.sphericalRadius();
  19625. isNaN(this._radius) && (this._radius = a.newRadius);
  19626. isNaN(this._angleZ) && (this._angleZ = cc.radiansToDegrees(a.zenith));
  19627. isNaN(this._angleX) && (this._angleX = cc.radiansToDegrees(a.azimuth));
  19628. this._radZ = cc.degreesToRadians(this._angleZ);
  19629. this._radX = cc.degreesToRadians(this._angleX)
  19630. },
  19631. clone: function() {
  19632. var a = new cc.OrbitCamera;
  19633. a.initWithDuration(this._duration, this._radius, this._deltaRadius, this._angleZ, this._deltaAngleZ, this._angleX, this._deltaAngleX);
  19634. return a
  19635. },
  19636. update: function(a) {
  19637. a =
  19638. this._computeEaseTime(a);
  19639. var b = (this._radius + this._deltaRadius * a) * cc.Camera.getZEye(),
  19640. c = this._radZ + this._radDeltaZ * a,
  19641. d = this._radX + this._radDeltaX * a;
  19642. a = Math.sin(c) * Math.cos(d) * b + this._centerXOrig;
  19643. d = Math.sin(c) * Math.sin(d) * b + this._centerYOrig;
  19644. b = Math.cos(c) * b + this._centerZOrig;
  19645. this.target.getCamera().setEye(a, d, b);
  19646. this.target.setNodeDirty()
  19647. }
  19648. });
  19649. cc.orbitCamera = function(a, b, c, d, e, f, g) {
  19650. return new cc.OrbitCamera(a, b, c, d, e, f, g)
  19651. };
  19652. cc.OrbitCamera.create = cc.orbitCamera;
  19653. cc.ActionEase = cc.ActionInterval.extend({
  19654. _inner: null,
  19655. ctor: function(a) {
  19656. cc.ActionInterval.prototype.ctor.call(this);
  19657. a && this.initWithAction(a)
  19658. },
  19659. initWithAction: function(a) {
  19660. if (!a) throw "cc.ActionEase.initWithAction(): action must be non nil";
  19661. return this.initWithDuration(a.getDuration()) ? (this._inner = a, !0) : !1
  19662. },
  19663. clone: function() {
  19664. var a = new cc.ActionEase;
  19665. a.initWithAction(this._inner.clone());
  19666. return a
  19667. },
  19668. startWithTarget: function(a) {
  19669. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  19670. this._inner.startWithTarget(this.target)
  19671. },
  19672. stop: function() {
  19673. this._inner.stop();
  19674. cc.ActionInterval.prototype.stop.call(this)
  19675. },
  19676. update: function(a) {
  19677. this._inner.update(a)
  19678. },
  19679. reverse: function() {
  19680. return new cc.ActionEase(this._inner.reverse())
  19681. },
  19682. getInnerAction: function() {
  19683. return this._inner
  19684. }
  19685. });
  19686. cc.actionEase = function(a) {
  19687. return new cc.ActionEase(a)
  19688. };
  19689. cc.ActionEase.create = cc.actionEase;
  19690. cc.EaseRateAction = cc.ActionEase.extend({
  19691. _rate: 0,
  19692. ctor: function(a, b) {
  19693. cc.ActionEase.prototype.ctor.call(this);
  19694. void 0 !== b && this.initWithAction(a, b)
  19695. },
  19696. setRate: function(a) {
  19697. this._rate = a
  19698. },
  19699. getRate: function() {
  19700. return this._rate
  19701. },
  19702. initWithAction: function(a, b) {
  19703. return cc.ActionEase.prototype.initWithAction.call(this, a) ? (this._rate = b, !0) : !1
  19704. },
  19705. clone: function() {
  19706. var a = new cc.EaseRateAction;
  19707. a.initWithAction(this._inner.clone(), this._rate);
  19708. return a
  19709. },
  19710. reverse: function() {
  19711. return new cc.EaseRateAction(this._inner.reverse(),
  19712. 1 / this._rate)
  19713. }
  19714. });
  19715. cc.easeRateAction = function(a, b) {
  19716. return new cc.EaseRateAction(a, b)
  19717. };
  19718. cc.EaseRateAction.create = cc.easeRateAction;
  19719. cc.EaseIn = cc.EaseRateAction.extend({
  19720. update: function(a) {
  19721. this._inner.update(Math.pow(a, this._rate))
  19722. },
  19723. reverse: function() {
  19724. return new cc.EaseIn(this._inner.reverse(), 1 / this._rate)
  19725. },
  19726. clone: function() {
  19727. var a = new cc.EaseIn;
  19728. a.initWithAction(this._inner.clone(), this._rate);
  19729. return a
  19730. }
  19731. });
  19732. cc.EaseIn.create = function(a, b) {
  19733. return new cc.EaseIn(a, b)
  19734. };
  19735. cc.easeIn = function(a) {
  19736. return {
  19737. _rate: a,
  19738. easing: function(a) {
  19739. return Math.pow(a, this._rate)
  19740. },
  19741. reverse: function() {
  19742. return cc.easeIn(1 / this._rate)
  19743. }
  19744. }
  19745. };
  19746. cc.EaseOut = cc.EaseRateAction.extend({
  19747. update: function(a) {
  19748. this._inner.update(Math.pow(a, 1 / this._rate))
  19749. },
  19750. reverse: function() {
  19751. return new cc.EaseOut(this._inner.reverse(), 1 / this._rate)
  19752. },
  19753. clone: function() {
  19754. var a = new cc.EaseOut;
  19755. a.initWithAction(this._inner.clone(), this._rate);
  19756. return a
  19757. }
  19758. });
  19759. cc.EaseOut.create = function(a, b) {
  19760. return new cc.EaseOut(a, b)
  19761. };
  19762. cc.easeOut = function(a) {
  19763. return {
  19764. _rate: a,
  19765. easing: function(a) {
  19766. return Math.pow(a, 1 / this._rate)
  19767. },
  19768. reverse: function() {
  19769. return cc.easeOut(1 / this._rate)
  19770. }
  19771. }
  19772. };
  19773. cc.EaseInOut = cc.EaseRateAction.extend({
  19774. update: function(a) {
  19775. a *= 2;
  19776. 1 > a ? this._inner.update(0.5 * Math.pow(a, this._rate)) : this._inner.update(1 - 0.5 * Math.pow(2 - a, this._rate))
  19777. },
  19778. clone: function() {
  19779. var a = new cc.EaseInOut;
  19780. a.initWithAction(this._inner.clone(), this._rate);
  19781. return a
  19782. },
  19783. reverse: function() {
  19784. return new cc.EaseInOut(this._inner.reverse(), this._rate)
  19785. }
  19786. });
  19787. cc.EaseInOut.create = function(a, b) {
  19788. return new cc.EaseInOut(a, b)
  19789. };
  19790. cc.easeInOut = function(a) {
  19791. return {
  19792. _rate: a,
  19793. easing: function(a) {
  19794. a *= 2;
  19795. return 1 > a ? 0.5 * Math.pow(a, this._rate) : 1 - 0.5 * Math.pow(2 - a, this._rate)
  19796. },
  19797. reverse: function() {
  19798. return cc.easeInOut(this._rate)
  19799. }
  19800. }
  19801. };
  19802. cc.EaseExponentialIn = cc.ActionEase.extend({
  19803. update: function(a) {
  19804. this._inner.update(0 === a ? 0 : Math.pow(2, 10 * (a - 1)))
  19805. },
  19806. reverse: function() {
  19807. return new cc.EaseExponentialOut(this._inner.reverse())
  19808. },
  19809. clone: function() {
  19810. var a = new cc.EaseExponentialIn;
  19811. a.initWithAction(this._inner.clone());
  19812. return a
  19813. }
  19814. });
  19815. cc.EaseExponentialIn.create = function(a) {
  19816. return new cc.EaseExponentialIn(a)
  19817. };
  19818. cc._easeExponentialInObj = {
  19819. easing: function(a) {
  19820. return 0 === a ? 0 : Math.pow(2, 10 * (a - 1))
  19821. },
  19822. reverse: function() {
  19823. return cc._easeExponentialOutObj
  19824. }
  19825. };
  19826. cc.easeExponentialIn = function() {
  19827. return cc._easeExponentialInObj
  19828. };
  19829. cc.EaseExponentialOut = cc.ActionEase.extend({
  19830. update: function(a) {
  19831. this._inner.update(1 === a ? 1 : -Math.pow(2, -10 * a) + 1)
  19832. },
  19833. reverse: function() {
  19834. return new cc.EaseExponentialIn(this._inner.reverse())
  19835. },
  19836. clone: function() {
  19837. var a = new cc.EaseExponentialOut;
  19838. a.initWithAction(this._inner.clone());
  19839. return a
  19840. }
  19841. });
  19842. cc.EaseExponentialOut.create = function(a) {
  19843. return new cc.EaseExponentialOut(a)
  19844. };
  19845. cc._easeExponentialOutObj = {
  19846. easing: function(a) {
  19847. return 1 === a ? 1 : -Math.pow(2, -10 * a) + 1
  19848. },
  19849. reverse: function() {
  19850. return cc._easeExponentialInObj
  19851. }
  19852. };
  19853. cc.easeExponentialOut = function() {
  19854. return cc._easeExponentialOutObj
  19855. };
  19856. cc.EaseExponentialInOut = cc.ActionEase.extend({
  19857. update: function(a) {
  19858. 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));
  19859. this._inner.update(a)
  19860. },
  19861. reverse: function() {
  19862. return new cc.EaseExponentialInOut(this._inner.reverse())
  19863. },
  19864. clone: function() {
  19865. var a = new cc.EaseExponentialInOut;
  19866. a.initWithAction(this._inner.clone());
  19867. return a
  19868. }
  19869. });
  19870. cc.EaseExponentialInOut.create = function(a) {
  19871. return new cc.EaseExponentialInOut(a)
  19872. };
  19873. cc._easeExponentialInOutObj = {
  19874. easing: function(a) {
  19875. 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
  19876. },
  19877. reverse: function() {
  19878. return cc._easeExponentialInOutObj
  19879. }
  19880. };
  19881. cc.easeExponentialInOut = function() {
  19882. return cc._easeExponentialInOutObj
  19883. };
  19884. cc.EaseSineIn = cc.ActionEase.extend({
  19885. update: function(a) {
  19886. a = 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1;
  19887. this._inner.update(a)
  19888. },
  19889. reverse: function() {
  19890. return new cc.EaseSineOut(this._inner.reverse())
  19891. },
  19892. clone: function() {
  19893. var a = new cc.EaseSineIn;
  19894. a.initWithAction(this._inner.clone());
  19895. return a
  19896. }
  19897. });
  19898. cc.EaseSineIn.create = function(a) {
  19899. return new cc.EaseSineIn(a)
  19900. };
  19901. cc._easeSineInObj = {
  19902. easing: function(a) {
  19903. return 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1
  19904. },
  19905. reverse: function() {
  19906. return cc._easeSineOutObj
  19907. }
  19908. };
  19909. cc.easeSineIn = function() {
  19910. return cc._easeSineInObj
  19911. };
  19912. cc.EaseSineOut = cc.ActionEase.extend({
  19913. update: function(a) {
  19914. a = 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2);
  19915. this._inner.update(a)
  19916. },
  19917. reverse: function() {
  19918. return new cc.EaseSineIn(this._inner.reverse())
  19919. },
  19920. clone: function() {
  19921. var a = new cc.EaseSineOut;
  19922. a.initWithAction(this._inner.clone());
  19923. return a
  19924. }
  19925. });
  19926. cc.EaseSineOut.create = function(a) {
  19927. return new cc.EaseSineOut(a)
  19928. };
  19929. cc._easeSineOutObj = {
  19930. easing: function(a) {
  19931. return 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2)
  19932. },
  19933. reverse: function() {
  19934. return cc._easeSineInObj
  19935. }
  19936. };
  19937. cc.easeSineOut = function() {
  19938. return cc._easeSineOutObj
  19939. };
  19940. cc.EaseSineInOut = cc.ActionEase.extend({
  19941. update: function(a) {
  19942. a = 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1);
  19943. this._inner.update(a)
  19944. },
  19945. clone: function() {
  19946. var a = new cc.EaseSineInOut;
  19947. a.initWithAction(this._inner.clone());
  19948. return a
  19949. },
  19950. reverse: function() {
  19951. return new cc.EaseSineInOut(this._inner.reverse())
  19952. }
  19953. });
  19954. cc.EaseSineInOut.create = function(a) {
  19955. return new cc.EaseSineInOut(a)
  19956. };
  19957. cc._easeSineInOutObj = {
  19958. easing: function(a) {
  19959. return 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1)
  19960. },
  19961. reverse: function() {
  19962. return cc._easeSineInOutObj
  19963. }
  19964. };
  19965. cc.easeSineInOut = function() {
  19966. return cc._easeSineInOutObj
  19967. };
  19968. cc.EaseElastic = cc.ActionEase.extend({
  19969. _period: 0.3,
  19970. ctor: function(a, b) {
  19971. cc.ActionEase.prototype.ctor.call(this);
  19972. a && this.initWithAction(a, b)
  19973. },
  19974. getPeriod: function() {
  19975. return this._period
  19976. },
  19977. setPeriod: function(a) {
  19978. this._period = a
  19979. },
  19980. initWithAction: function(a, b) {
  19981. cc.ActionEase.prototype.initWithAction.call(this, a);
  19982. this._period = null == b ? 0.3 : b;
  19983. return !0
  19984. },
  19985. reverse: function() {
  19986. cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
  19987. return null
  19988. },
  19989. clone: function() {
  19990. var a = new cc.EaseElastic;
  19991. a.initWithAction(this._inner.clone(),
  19992. this._period);
  19993. return a
  19994. }
  19995. });
  19996. cc.EaseElastic.create = function(a, b) {
  19997. return new cc.EaseElastic(a, b)
  19998. };
  19999. cc.EaseElasticIn = cc.EaseElastic.extend({
  20000. update: function(a) {
  20001. var b = 0;
  20002. 0 === a || 1 === a ? b = a : (b = this._period / 4, a -= 1, b = -Math.pow(2, 10 * a) * Math.sin((a - b) * Math.PI * 2 / this._period));
  20003. this._inner.update(b)
  20004. },
  20005. reverse: function() {
  20006. return new cc.EaseElasticOut(this._inner.reverse(), this._period)
  20007. },
  20008. clone: function() {
  20009. var a = new cc.EaseElasticIn;
  20010. a.initWithAction(this._inner.clone(), this._period);
  20011. return a
  20012. }
  20013. });
  20014. cc.EaseElasticIn.create = function(a, b) {
  20015. return new cc.EaseElasticIn(a, b)
  20016. };
  20017. cc._easeElasticInObj = {
  20018. easing: function(a) {
  20019. if (0 === a || 1 === a) return a;
  20020. a -= 1;
  20021. return -Math.pow(2, 10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3)
  20022. },
  20023. reverse: function() {
  20024. return cc._easeElasticOutObj
  20025. }
  20026. };
  20027. cc.easeElasticIn = function(a) {
  20028. return a && 0.3 !== a ? {
  20029. _period: a,
  20030. easing: function(a) {
  20031. if (0 === a || 1 === a) return a;
  20032. a -= 1;
  20033. return -Math.pow(2, 10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period)
  20034. },
  20035. reverse: function() {
  20036. return cc.easeElasticOut(this._period)
  20037. }
  20038. } : cc._easeElasticInObj
  20039. };
  20040. cc.EaseElasticOut = cc.EaseElastic.extend({
  20041. update: function(a) {
  20042. var b = 0;
  20043. 0 === a || 1 === a ? b = a : (b = this._period / 4, b = Math.pow(2, -10 * a) * Math.sin((a - b) * Math.PI * 2 / this._period) + 1);
  20044. this._inner.update(b)
  20045. },
  20046. reverse: function() {
  20047. return new cc.EaseElasticIn(this._inner.reverse(), this._period)
  20048. },
  20049. clone: function() {
  20050. var a = new cc.EaseElasticOut;
  20051. a.initWithAction(this._inner.clone(), this._period);
  20052. return a
  20053. }
  20054. });
  20055. cc.EaseElasticOut.create = function(a, b) {
  20056. return new cc.EaseElasticOut(a, b)
  20057. };
  20058. cc._easeElasticOutObj = {
  20059. easing: function(a) {
  20060. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3) + 1
  20061. },
  20062. reverse: function() {
  20063. return cc._easeElasticInObj
  20064. }
  20065. };
  20066. cc.easeElasticOut = function(a) {
  20067. return a && 0.3 !== a ? {
  20068. _period: a,
  20069. easing: function(a) {
  20070. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period) + 1
  20071. },
  20072. reverse: function() {
  20073. return cc.easeElasticIn(this._period)
  20074. }
  20075. } : cc._easeElasticOutObj
  20076. };
  20077. cc.EaseElasticInOut = cc.EaseElastic.extend({
  20078. update: function(a) {
  20079. var b = 0,
  20080. b = this._period;
  20081. if (0 === a || 1 === a) b = a;
  20082. else {
  20083. b || (b = this._period = 0.3 * 1.5);
  20084. var c = b / 4;
  20085. a = 2 * a - 1;
  20086. b = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin((a - c) * Math.PI * 2 / b) : Math.pow(2, -10 * a) * Math.sin((a - c) * Math.PI * 2 / b) * 0.5 + 1
  20087. }
  20088. this._inner.update(b)
  20089. },
  20090. reverse: function() {
  20091. return new cc.EaseElasticInOut(this._inner.reverse(), this._period)
  20092. },
  20093. clone: function() {
  20094. var a = new cc.EaseElasticInOut;
  20095. a.initWithAction(this._inner.clone(), this._period);
  20096. return a
  20097. }
  20098. });
  20099. cc.EaseElasticInOut.create = function(a, b) {
  20100. return new cc.EaseElasticInOut(a, b)
  20101. };
  20102. cc.easeElasticInOut = function(a) {
  20103. return {
  20104. _period: a || 0.3,
  20105. easing: function(a) {
  20106. var c = 0,
  20107. c = this._period;
  20108. if (0 === a || 1 === a) c = a;
  20109. else {
  20110. c || (c = this._period = 0.3 * 1.5);
  20111. var d = c / 4;
  20112. a = 2 * a - 1;
  20113. c = 0 > a ? -0.5 * Math.pow(2, 10 * a) * Math.sin((a - d) * Math.PI * 2 / c) : Math.pow(2, -10 * a) * Math.sin((a - d) * Math.PI * 2 / c) * 0.5 + 1
  20114. }
  20115. return c
  20116. },
  20117. reverse: function() {
  20118. return cc.easeElasticInOut(this._period)
  20119. }
  20120. }
  20121. };
  20122. cc.EaseBounce = cc.ActionEase.extend({
  20123. bounceTime: function(a) {
  20124. if (a < 1 / 2.75) return 7.5625 * a * a;
  20125. if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
  20126. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
  20127. a -= 2.625 / 2.75;
  20128. return 7.5625 * a * a + 0.984375
  20129. },
  20130. clone: function() {
  20131. var a = new cc.EaseBounce;
  20132. a.initWithAction(this._inner.clone());
  20133. return a
  20134. },
  20135. reverse: function() {
  20136. return new cc.EaseBounce(this._inner.reverse())
  20137. }
  20138. });
  20139. cc.EaseBounce.create = function(a) {
  20140. return new cc.EaseBounce(a)
  20141. };
  20142. cc.EaseBounceIn = cc.EaseBounce.extend({
  20143. update: function(a) {
  20144. a = 1 - this.bounceTime(1 - a);
  20145. this._inner.update(a)
  20146. },
  20147. reverse: function() {
  20148. return new cc.EaseBounceOut(this._inner.reverse())
  20149. },
  20150. clone: function() {
  20151. var a = new cc.EaseBounceIn;
  20152. a.initWithAction(this._inner.clone());
  20153. return a
  20154. }
  20155. });
  20156. cc.EaseBounceIn.create = function(a) {
  20157. return new cc.EaseBounceIn(a)
  20158. };
  20159. cc._bounceTime = function(a) {
  20160. if (a < 1 / 2.75) return 7.5625 * a * a;
  20161. if (a < 2 / 2.75) return a -= 1.5 / 2.75, 7.5625 * a * a + 0.75;
  20162. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75, 7.5625 * a * a + 0.9375;
  20163. a -= 2.625 / 2.75;
  20164. return 7.5625 * a * a + 0.984375
  20165. };
  20166. cc._easeBounceInObj = {
  20167. easing: function(a) {
  20168. return 1 - cc._bounceTime(1 - a)
  20169. },
  20170. reverse: function() {
  20171. return cc._easeBounceOutObj
  20172. }
  20173. };
  20174. cc.easeBounceIn = function() {
  20175. return cc._easeBounceInObj
  20176. };
  20177. cc.EaseBounceOut = cc.EaseBounce.extend({
  20178. update: function(a) {
  20179. a = this.bounceTime(a);
  20180. this._inner.update(a)
  20181. },
  20182. reverse: function() {
  20183. return new cc.EaseBounceIn(this._inner.reverse())
  20184. },
  20185. clone: function() {
  20186. var a = new cc.EaseBounceOut;
  20187. a.initWithAction(this._inner.clone());
  20188. return a
  20189. }
  20190. });
  20191. cc.EaseBounceOut.create = function(a) {
  20192. return new cc.EaseBounceOut(a)
  20193. };
  20194. cc._easeBounceOutObj = {
  20195. easing: function(a) {
  20196. return cc._bounceTime(a)
  20197. },
  20198. reverse: function() {
  20199. return cc._easeBounceInObj
  20200. }
  20201. };
  20202. cc.easeBounceOut = function() {
  20203. return cc._easeBounceOutObj
  20204. };
  20205. cc.EaseBounceInOut = cc.EaseBounce.extend({
  20206. update: function(a) {
  20207. var b = 0,
  20208. b = 0.5 > a ? 0.5 * (1 - this.bounceTime(1 - 2 * a)) : 0.5 * this.bounceTime(2 * a - 1) + 0.5;
  20209. this._inner.update(b)
  20210. },
  20211. clone: function() {
  20212. var a = new cc.EaseBounceInOut;
  20213. a.initWithAction(this._inner.clone());
  20214. return a
  20215. },
  20216. reverse: function() {
  20217. return new cc.EaseBounceInOut(this._inner.reverse())
  20218. }
  20219. });
  20220. cc.EaseBounceInOut.create = function(a) {
  20221. return new cc.EaseBounceInOut(a)
  20222. };
  20223. cc._easeBounceInOutObj = {
  20224. easing: function(a) {
  20225. return a = 0.5 > a ? 0.5 * (1 - cc._bounceTime(1 - 2 * a)) : 0.5 * cc._bounceTime(2 * a - 1) + 0.5
  20226. },
  20227. reverse: function() {
  20228. return cc._easeBounceInOutObj
  20229. }
  20230. };
  20231. cc.easeBounceInOut = function() {
  20232. return cc._easeBounceInOutObj
  20233. };
  20234. cc.EaseBackIn = cc.ActionEase.extend({
  20235. update: function(a) {
  20236. this._inner.update(0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158))
  20237. },
  20238. reverse: function() {
  20239. return new cc.EaseBackOut(this._inner.reverse())
  20240. },
  20241. clone: function() {
  20242. var a = new cc.EaseBackIn;
  20243. a.initWithAction(this._inner.clone());
  20244. return a
  20245. }
  20246. });
  20247. cc.EaseBackIn.create = function(a) {
  20248. return new cc.EaseBackIn(a)
  20249. };
  20250. cc._easeBackInObj = {
  20251. easing: function(a) {
  20252. return 0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158)
  20253. },
  20254. reverse: function() {
  20255. return cc._easeBackOutObj
  20256. }
  20257. };
  20258. cc.easeBackIn = function() {
  20259. return cc._easeBackInObj
  20260. };
  20261. cc.EaseBackOut = cc.ActionEase.extend({
  20262. update: function(a) {
  20263. a -= 1;
  20264. this._inner.update(a * a * (2.70158 * a + 1.70158) + 1)
  20265. },
  20266. reverse: function() {
  20267. return new cc.EaseBackIn(this._inner.reverse())
  20268. },
  20269. clone: function() {
  20270. var a = new cc.EaseBackOut;
  20271. a.initWithAction(this._inner.clone());
  20272. return a
  20273. }
  20274. });
  20275. cc.EaseBackOut.create = function(a) {
  20276. return new cc.EaseBackOut(a)
  20277. };
  20278. cc._easeBackOutObj = {
  20279. easing: function(a) {
  20280. a -= 1;
  20281. return a * a * (2.70158 * a + 1.70158) + 1
  20282. },
  20283. reverse: function() {
  20284. return cc._easeBackInObj
  20285. }
  20286. };
  20287. cc.easeBackOut = function() {
  20288. return cc._easeBackOutObj
  20289. };
  20290. cc.EaseBackInOut = cc.ActionEase.extend({
  20291. update: function(a) {
  20292. a *= 2;
  20293. 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))
  20294. },
  20295. clone: function() {
  20296. var a = new cc.EaseBackInOut;
  20297. a.initWithAction(this._inner.clone());
  20298. return a
  20299. },
  20300. reverse: function() {
  20301. return new cc.EaseBackInOut(this._inner.reverse())
  20302. }
  20303. });
  20304. cc.EaseBackInOut.create = function(a) {
  20305. return new cc.EaseBackInOut(a)
  20306. };
  20307. cc._easeBackInOutObj = {
  20308. easing: function(a) {
  20309. a *= 2;
  20310. if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
  20311. a -= 2;
  20312. return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
  20313. },
  20314. reverse: function() {
  20315. return cc._easeBackInOutObj
  20316. }
  20317. };
  20318. cc.easeBackInOut = function() {
  20319. return cc._easeBackInOutObj
  20320. };
  20321. cc.EaseBezierAction = cc.ActionEase.extend({
  20322. _p0: null,
  20323. _p1: null,
  20324. _p2: null,
  20325. _p3: null,
  20326. ctor: function(a) {
  20327. cc.ActionEase.prototype.ctor.call(this, a)
  20328. },
  20329. _updateTime: function(a, b, c, d, e) {
  20330. return Math.pow(1 - e, 3) * a + 3 * e * Math.pow(1 - e, 2) * b + 3 * Math.pow(e, 2) * (1 - e) * c + Math.pow(e, 3) * d
  20331. },
  20332. update: function(a) {
  20333. a = this._updateTime(this._p0, this._p1, this._p2, this._p3, a);
  20334. this._inner.update(a)
  20335. },
  20336. clone: function() {
  20337. var a = new cc.EaseBezierAction;
  20338. a.initWithAction(this._inner.clone());
  20339. a.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
  20340. return a
  20341. },
  20342. reverse: function() {
  20343. var a = new cc.EaseBezierAction(this._inner.reverse());
  20344. a.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
  20345. return a
  20346. },
  20347. setBezierParamer: function(a, b, c, d) {
  20348. this._p0 = a || 0;
  20349. this._p1 = b || 0;
  20350. this._p2 = c || 0;
  20351. this._p3 = d || 0
  20352. }
  20353. });
  20354. cc.EaseBezierAction.create = function(a) {
  20355. return new cc.EaseBezierAction(a)
  20356. };
  20357. cc.easeBezierAction = function(a, b, c, d) {
  20358. return {
  20359. easing: function(e) {
  20360. return cc.EaseBezierAction.prototype._updateTime(a, b, c, d, e)
  20361. },
  20362. reverse: function() {
  20363. return cc.easeBezierAction(d, c, b, a)
  20364. }
  20365. }
  20366. };
  20367. cc.EaseQuadraticActionIn = cc.ActionEase.extend({
  20368. _updateTime: function(a) {
  20369. return Math.pow(a, 2)
  20370. },
  20371. update: function(a) {
  20372. this._inner.update(this._updateTime(a))
  20373. },
  20374. clone: function() {
  20375. var a = new cc.EaseQuadraticActionIn;
  20376. a.initWithAction(this._inner.clone());
  20377. return a
  20378. },
  20379. reverse: function() {
  20380. return new cc.EaseQuadraticActionIn(this._inner.reverse())
  20381. }
  20382. });
  20383. cc.EaseQuadraticActionIn.create = function(a) {
  20384. return new cc.EaseQuadraticActionIn(a)
  20385. };
  20386. cc._easeQuadraticActionIn = {
  20387. easing: cc.EaseQuadraticActionIn.prototype._updateTime,
  20388. reverse: function() {
  20389. return cc._easeQuadraticActionIn
  20390. }
  20391. };
  20392. cc.easeQuadraticActionIn = function() {
  20393. return cc._easeQuadraticActionIn
  20394. };
  20395. cc.EaseQuadraticActionOut = cc.ActionEase.extend({
  20396. _updateTime: function(a) {
  20397. return -a * (a - 2)
  20398. },
  20399. update: function(a) {
  20400. this._inner.update(this._updateTime(a))
  20401. },
  20402. clone: function() {
  20403. var a = new cc.EaseQuadraticActionOut;
  20404. a.initWithAction();
  20405. return a
  20406. },
  20407. reverse: function() {
  20408. return new cc.EaseQuadraticActionOut(this._inner.reverse())
  20409. }
  20410. });
  20411. cc.EaseQuadraticActionOut.create = function(a) {
  20412. return new cc.EaseQuadraticActionOut(a)
  20413. };
  20414. cc._easeQuadraticActionOut = {
  20415. easing: cc.EaseQuadraticActionOut.prototype._updateTime,
  20416. reverse: function() {
  20417. return cc._easeQuadraticActionOut
  20418. }
  20419. };
  20420. cc.easeQuadraticActionOut = function() {
  20421. return cc._easeQuadraticActionOut
  20422. };
  20423. cc.EaseQuadraticActionInOut = cc.ActionEase.extend({
  20424. _updateTime: function(a) {
  20425. var b = a;
  20426. a *= 2;
  20427. 1 > a ? b = a * a * 0.5 : (--a, b = -0.5 * (a * (a - 2) - 1));
  20428. return b
  20429. },
  20430. update: function(a) {
  20431. this._inner.update(this._updateTime(a))
  20432. },
  20433. clone: function() {
  20434. var a = new cc.EaseQuadraticActionInOut;
  20435. a.initWithAction(this._inner.clone());
  20436. return a
  20437. },
  20438. reverse: function() {
  20439. return new cc.EaseQuadraticActionInOut(this._inner.reverse())
  20440. }
  20441. });
  20442. cc.EaseQuadraticActionInOut.create = function(a) {
  20443. return new cc.EaseQuadraticActionInOut(a)
  20444. };
  20445. cc._easeQuadraticActionInOut = {
  20446. easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
  20447. reverse: function() {
  20448. return cc._easeQuadraticActionInOut
  20449. }
  20450. };
  20451. cc.easeQuadraticActionInOut = function() {
  20452. return cc._easeQuadraticActionInOut
  20453. };
  20454. cc.EaseQuarticActionIn = cc.ActionEase.extend({
  20455. _updateTime: function(a) {
  20456. return a * a * a * a
  20457. },
  20458. update: function(a) {
  20459. this._inner.update(this._updateTime(a))
  20460. },
  20461. clone: function() {
  20462. var a = new cc.EaseQuarticActionIn;
  20463. a.initWithAction(this._inner.clone());
  20464. return a
  20465. },
  20466. reverse: function() {
  20467. return new cc.EaseQuarticActionIn(this._inner.reverse())
  20468. }
  20469. });
  20470. cc.EaseQuarticActionIn.create = function(a) {
  20471. return new cc.EaseQuarticActionIn(a)
  20472. };
  20473. cc._easeQuarticActionIn = {
  20474. easing: cc.EaseQuarticActionIn.prototype._updateTime,
  20475. reverse: function() {
  20476. return cc._easeQuarticActionIn
  20477. }
  20478. };
  20479. cc.easeQuarticActionIn = function() {
  20480. return cc._easeQuarticActionIn
  20481. };
  20482. cc.EaseQuarticActionOut = cc.ActionEase.extend({
  20483. _updateTime: function(a) {
  20484. a -= 1;
  20485. return -(a * a * a * a - 1)
  20486. },
  20487. update: function(a) {
  20488. this._inner.update(this._updateTime(a))
  20489. },
  20490. clone: function() {
  20491. var a = new cc.EaseQuarticActionOut;
  20492. a.initWithAction(this._inner.clone());
  20493. return a
  20494. },
  20495. reverse: function() {
  20496. return new cc.EaseQuarticActionOut(this._inner.reverse())
  20497. }
  20498. });
  20499. cc.EaseQuarticActionOut.create = function(a) {
  20500. return new cc.EaseQuarticActionOut(a)
  20501. };
  20502. cc._easeQuarticActionOut = {
  20503. easing: cc.EaseQuarticActionOut.prototype._updateTime,
  20504. reverse: function() {
  20505. return cc._easeQuarticActionOut
  20506. }
  20507. };
  20508. cc.easeQuarticActionOut = function() {
  20509. return cc._easeQuarticActionOut
  20510. };
  20511. cc.EaseQuarticActionInOut = cc.ActionEase.extend({
  20512. _updateTime: function(a) {
  20513. a *= 2;
  20514. if (1 > a) return 0.5 * a * a * a * a;
  20515. a -= 2;
  20516. return -0.5 * (a * a * a * a - 2)
  20517. },
  20518. update: function(a) {
  20519. this._inner.update(this._updateTime(a))
  20520. },
  20521. clone: function() {
  20522. var a = new cc.EaseQuarticActionInOut;
  20523. a.initWithAction(this._inner.clone());
  20524. return a
  20525. },
  20526. reverse: function() {
  20527. return new cc.EaseQuarticActionInOut(this._inner.reverse())
  20528. }
  20529. });
  20530. cc.EaseQuarticActionInOut.create = function(a) {
  20531. return new cc.EaseQuarticActionInOut(a)
  20532. };
  20533. cc._easeQuarticActionInOut = {
  20534. easing: cc.EaseQuarticActionInOut.prototype._updateTime,
  20535. reverse: function() {
  20536. return cc._easeQuarticActionInOut
  20537. }
  20538. };
  20539. cc.easeQuarticActionInOut = function() {
  20540. return cc._easeQuarticActionInOut
  20541. };
  20542. cc.EaseQuinticActionIn = cc.ActionEase.extend({
  20543. _updateTime: function(a) {
  20544. return a * a * a * a * a
  20545. },
  20546. update: function(a) {
  20547. this._inner.update(this._updateTime(a))
  20548. },
  20549. clone: function() {
  20550. var a = new cc.EaseQuinticActionIn;
  20551. a.initWithAction(this._inner.clone());
  20552. return a
  20553. },
  20554. reverse: function() {
  20555. return new cc.EaseQuinticActionIn(this._inner.reverse())
  20556. }
  20557. });
  20558. cc.EaseQuinticActionIn.create = function(a) {
  20559. return new cc.EaseQuinticActionIn(a)
  20560. };
  20561. cc._easeQuinticActionIn = {
  20562. easing: cc.EaseQuinticActionIn.prototype._updateTime,
  20563. reverse: function() {
  20564. return cc._easeQuinticActionIn
  20565. }
  20566. };
  20567. cc.easeQuinticActionIn = function() {
  20568. return cc._easeQuinticActionIn
  20569. };
  20570. cc.EaseQuinticActionOut = cc.ActionEase.extend({
  20571. _updateTime: function(a) {
  20572. a -= 1;
  20573. return a * a * a * a * a + 1
  20574. },
  20575. update: function(a) {
  20576. this._inner.update(this._updateTime(a))
  20577. },
  20578. clone: function() {
  20579. var a = new cc.EaseQuinticActionOut;
  20580. a.initWithAction(this._inner.clone());
  20581. return a
  20582. },
  20583. reverse: function() {
  20584. return new cc.EaseQuinticActionOut(this._inner.reverse())
  20585. }
  20586. });
  20587. cc.EaseQuinticActionOut.create = function(a) {
  20588. return new cc.EaseQuinticActionOut(a)
  20589. };
  20590. cc._easeQuinticActionOut = {
  20591. easing: cc.EaseQuinticActionOut.prototype._updateTime,
  20592. reverse: function() {
  20593. return cc._easeQuinticActionOut
  20594. }
  20595. };
  20596. cc.easeQuinticActionOut = function() {
  20597. return cc._easeQuinticActionOut
  20598. };
  20599. cc.EaseQuinticActionInOut = cc.ActionEase.extend({
  20600. _updateTime: function(a) {
  20601. a *= 2;
  20602. if (1 > a) return 0.5 * a * a * a * a * a;
  20603. a -= 2;
  20604. return 0.5 * (a * a * a * a * a + 2)
  20605. },
  20606. update: function(a) {
  20607. this._inner.update(this._updateTime(a))
  20608. },
  20609. clone: function() {
  20610. var a = new cc.EaseQuinticActionInOut;
  20611. a.initWithAction(this._inner.clone());
  20612. return a
  20613. },
  20614. reverse: function() {
  20615. return new cc.EaseQuinticActionInOut(this._inner.reverse())
  20616. }
  20617. });
  20618. cc.EaseQuinticActionInOut.create = function(a) {
  20619. return new cc.EaseQuinticActionInOut(a)
  20620. };
  20621. cc._easeQuinticActionInOut = {
  20622. easing: cc.EaseQuinticActionInOut.prototype._updateTime,
  20623. reverse: function() {
  20624. return cc._easeQuinticActionInOut
  20625. }
  20626. };
  20627. cc.easeQuinticActionInOut = function() {
  20628. return cc._easeQuinticActionInOut
  20629. };
  20630. cc.EaseCircleActionIn = cc.ActionEase.extend({
  20631. _updateTime: function(a) {
  20632. return -1 * (Math.sqrt(1 - a * a) - 1)
  20633. },
  20634. update: function(a) {
  20635. this._inner.update(this._updateTime(a))
  20636. },
  20637. clone: function() {
  20638. var a = new cc.EaseCircleActionIn;
  20639. a.initWithAction(this._inner.clone());
  20640. return a
  20641. },
  20642. reverse: function() {
  20643. return new cc.EaseCircleActionIn(this._inner.reverse())
  20644. }
  20645. });
  20646. cc.EaseCircleActionIn.create = function(a) {
  20647. return new cc.EaseCircleActionIn(a)
  20648. };
  20649. cc._easeCircleActionIn = {
  20650. easing: cc.EaseCircleActionIn.prototype._updateTime,
  20651. reverse: function() {
  20652. return cc._easeCircleActionIn
  20653. }
  20654. };
  20655. cc.easeCircleActionIn = function() {
  20656. return cc._easeCircleActionIn
  20657. };
  20658. cc.EaseCircleActionOut = cc.ActionEase.extend({
  20659. _updateTime: function(a) {
  20660. a -= 1;
  20661. return Math.sqrt(1 - a * a)
  20662. },
  20663. update: function(a) {
  20664. this._inner.update(this._updateTime(a))
  20665. },
  20666. clone: function() {
  20667. var a = new cc.EaseCircleActionOut;
  20668. a.initWithAction(this._inner.clone());
  20669. return a
  20670. },
  20671. reverse: function() {
  20672. return new cc.EaseCircleActionOut(this._inner.reverse())
  20673. }
  20674. });
  20675. cc.EaseCircleActionOut.create = function(a) {
  20676. return new cc.EaseCircleActionOut(a)
  20677. };
  20678. cc._easeCircleActionOut = {
  20679. easing: cc.EaseCircleActionOut.prototype._updateTime,
  20680. reverse: function() {
  20681. return cc._easeCircleActionOut
  20682. }
  20683. };
  20684. cc.easeCircleActionOut = function() {
  20685. return cc._easeCircleActionOut
  20686. };
  20687. cc.EaseCircleActionInOut = cc.ActionEase.extend({
  20688. _updateTime: function(a) {
  20689. a *= 2;
  20690. if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
  20691. a -= 2;
  20692. return 0.5 * (Math.sqrt(1 - a * a) + 1)
  20693. },
  20694. update: function(a) {
  20695. this._inner.update(this._updateTime(a))
  20696. },
  20697. clone: function() {
  20698. var a = new cc.EaseCircleActionInOut;
  20699. a.initWithAction(this._inner.clone());
  20700. return a
  20701. },
  20702. reverse: function() {
  20703. return new cc.EaseCircleActionInOut(this._inner.reverse())
  20704. }
  20705. });
  20706. cc.EaseCircleActionInOut.create = function(a) {
  20707. return new cc.EaseCircleActionInOut(a)
  20708. };
  20709. cc._easeCircleActionInOut = {
  20710. easing: cc.EaseCircleActionInOut.prototype._updateTime,
  20711. reverse: function() {
  20712. return cc._easeCircleActionInOut
  20713. }
  20714. };
  20715. cc.easeCircleActionInOut = function() {
  20716. return cc._easeCircleActionInOut
  20717. };
  20718. cc.EaseCubicActionIn = cc.ActionEase.extend({
  20719. _updateTime: function(a) {
  20720. return a * a * a
  20721. },
  20722. update: function(a) {
  20723. this._inner.update(this._updateTime(a))
  20724. },
  20725. clone: function() {
  20726. var a = new cc.EaseCubicActionIn;
  20727. a.initWithAction(this._inner.clone());
  20728. return a
  20729. },
  20730. reverse: function() {
  20731. return new cc.EaseCubicActionIn(this._inner.reverse())
  20732. }
  20733. });
  20734. cc.EaseCubicActionIn.create = function(a) {
  20735. return new cc.EaseCubicActionIn(a)
  20736. };
  20737. cc._easeCubicActionIn = {
  20738. easing: cc.EaseCubicActionIn.prototype._updateTime,
  20739. reverse: function() {
  20740. return cc._easeCubicActionIn
  20741. }
  20742. };
  20743. cc.easeCubicActionIn = function() {
  20744. return cc._easeCubicActionIn
  20745. };
  20746. cc.EaseCubicActionOut = cc.ActionEase.extend({
  20747. _updateTime: function(a) {
  20748. a -= 1;
  20749. return a * a * a + 1
  20750. },
  20751. update: function(a) {
  20752. this._inner.update(this._updateTime(a))
  20753. },
  20754. clone: function() {
  20755. var a = new cc.EaseCubicActionOut;
  20756. a.initWithAction(this._inner.clone());
  20757. return a
  20758. },
  20759. reverse: function() {
  20760. return new cc.EaseCubicActionOut(this._inner.reverse())
  20761. }
  20762. });
  20763. cc.EaseCubicActionOut.create = function(a) {
  20764. return new cc.EaseCubicActionOut(a)
  20765. };
  20766. cc._easeCubicActionOut = {
  20767. easing: cc.EaseCubicActionOut.prototype._updateTime,
  20768. reverse: function() {
  20769. return cc._easeCubicActionOut
  20770. }
  20771. };
  20772. cc.easeCubicActionOut = function() {
  20773. return cc._easeCubicActionOut
  20774. };
  20775. cc.EaseCubicActionInOut = cc.ActionEase.extend({
  20776. _updateTime: function(a) {
  20777. a *= 2;
  20778. if (1 > a) return 0.5 * a * a * a;
  20779. a -= 2;
  20780. return 0.5 * (a * a * a + 2)
  20781. },
  20782. update: function(a) {
  20783. this._inner.update(this._updateTime(a))
  20784. },
  20785. clone: function() {
  20786. var a = new cc.EaseCubicActionInOut;
  20787. a.initWithAction(this._inner.clone());
  20788. return a
  20789. },
  20790. reverse: function() {
  20791. return new cc.EaseCubicActionInOut(this._inner.reverse())
  20792. }
  20793. });
  20794. cc.EaseCubicActionInOut.create = function(a) {
  20795. return new cc.EaseCubicActionInOut(a)
  20796. };
  20797. cc._easeCubicActionInOut = {
  20798. easing: cc.EaseCubicActionInOut.prototype._updateTime,
  20799. reverse: function() {
  20800. return cc._easeCubicActionInOut
  20801. }
  20802. };
  20803. cc.easeCubicActionInOut = function() {
  20804. return cc._easeCubicActionInOut
  20805. };
  20806. cc.cardinalSplineAt = function(a, b, c, d, e, f) {
  20807. var g = f * f,
  20808. h = g * f,
  20809. k = (1 - e) / 2;
  20810. e = k * (-h + 2 * g - f);
  20811. var m = k * (-h + g) + (2 * h - 3 * g + 1);
  20812. f = k * (h - 2 * g + f) + (-2 * h + 3 * g);
  20813. g = k * (h - g);
  20814. return cc.p(a.x * e + b.x * m + c.x * f + d.x * g, a.y * e + b.y * m + c.y * f + d.y * g)
  20815. };
  20816. cc.reverseControlPoints = function(a) {
  20817. for (var b = [], c = a.length - 1; 0 <= c; c--) b.push(cc.p(a[c].x, a[c].y));
  20818. return b
  20819. };
  20820. cc.cloneControlPoints = function(a) {
  20821. for (var b = [], c = 0; c < a.length; c++) b.push(cc.p(a[c].x, a[c].y));
  20822. return b
  20823. };
  20824. cc.copyControlPoints = cc.cloneControlPoints;
  20825. cc.getControlPointAt = function(a, b) {
  20826. var c = Math.min(a.length - 1, Math.max(b, 0));
  20827. return a[c]
  20828. };
  20829. cc.reverseControlPointsInline = function(a) {
  20830. for (var b = a.length, c = 0 | b / 2, d = 0; d < c; ++d) {
  20831. var e = a[d];
  20832. a[d] = a[b - d - 1];
  20833. a[b - d - 1] = e
  20834. }
  20835. };
  20836. cc.CardinalSplineTo = cc.ActionInterval.extend({
  20837. _points: null,
  20838. _deltaT: 0,
  20839. _tension: 0,
  20840. _previousPosition: null,
  20841. _accumulatedDiff: null,
  20842. ctor: function(a, b, c) {
  20843. cc.ActionInterval.prototype.ctor.call(this);
  20844. this._points = [];
  20845. void 0 !== c && this.initWithDuration(a, b, c)
  20846. },
  20847. initWithDuration: function(a, b, c) {
  20848. if (!b || 0 === b.length) throw "Invalid configuration. It must at least have one control point";
  20849. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.setPoints(b), this._tension = c, !0) : !1
  20850. },
  20851. clone: function() {
  20852. var a =
  20853. new cc.CardinalSplineTo;
  20854. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  20855. return a
  20856. },
  20857. startWithTarget: function(a) {
  20858. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  20859. this._deltaT = 1 / (this._points.length - 1);
  20860. this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
  20861. this._accumulatedDiff = cc.p(0, 0)
  20862. },
  20863. update: function(a) {
  20864. a = this._computeEaseTime(a);
  20865. var b, c = this._points;
  20866. if (1 === a) b = c.length - 1, a = 1;
  20867. else {
  20868. var d = this._deltaT;
  20869. b = 0 | a / d;
  20870. a = (a - d * b) / d
  20871. }
  20872. b = cc.cardinalSplineAt(cc.getControlPointAt(c,
  20873. b - 1), cc.getControlPointAt(c, b - 0), cc.getControlPointAt(c, b + 1), cc.getControlPointAt(c, b + 2), this._tension, a);
  20874. cc.ENABLE_STACKABLE_ACTIONS && (c = this.target.getPositionX() - this._previousPosition.x, a = this.target.getPositionY() - this._previousPosition.y, 0 !== c || 0 !== a) && (d = this._accumulatedDiff, c = d.x + c, a = d.y + a, d.x = c, d.y = a, b.x += c, b.y += a);
  20875. this.updatePosition(b)
  20876. },
  20877. reverse: function() {
  20878. var a = cc.reverseControlPoints(this._points);
  20879. return cc.cardinalSplineTo(this._duration, a, this._tension)
  20880. },
  20881. updatePosition: function(a) {
  20882. this.target.setPosition(a);
  20883. this._previousPosition = a
  20884. },
  20885. getPoints: function() {
  20886. return this._points
  20887. },
  20888. setPoints: function(a) {
  20889. this._points = a
  20890. }
  20891. });
  20892. cc.cardinalSplineTo = function(a, b, c) {
  20893. return new cc.CardinalSplineTo(a, b, c)
  20894. };
  20895. cc.CardinalSplineTo.create = cc.cardinalSplineTo;
  20896. cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
  20897. _startPosition: null,
  20898. ctor: function(a, b, c) {
  20899. cc.CardinalSplineTo.prototype.ctor.call(this);
  20900. this._startPosition = cc.p(0, 0);
  20901. void 0 !== c && this.initWithDuration(a, b, c)
  20902. },
  20903. startWithTarget: function(a) {
  20904. cc.CardinalSplineTo.prototype.startWithTarget.call(this, a);
  20905. this._startPosition.x = a.getPositionX();
  20906. this._startPosition.y = a.getPositionY()
  20907. },
  20908. reverse: function() {
  20909. for (var a = this._points.slice(), b, c = a[0], d = 1; d < a.length; ++d) b = a[d], a[d] = cc.pSub(b, c), c = b;
  20910. a = cc.reverseControlPoints(a);
  20911. c = a[a.length - 1];
  20912. a.pop();
  20913. c.x = -c.x;
  20914. c.y = -c.y;
  20915. a.unshift(c);
  20916. for (d = 1; d < a.length; ++d) b = a[d], b.x = -b.x, b.y = -b.y, b.x += c.x, b.y += c.y, c = a[d] = b;
  20917. return cc.cardinalSplineBy(this._duration, a, this._tension)
  20918. },
  20919. updatePosition: function(a) {
  20920. var b = this._startPosition,
  20921. c = a.x + b.x;
  20922. a = a.y + b.y;
  20923. this._previousPosition.x = c;
  20924. this._previousPosition.y = a;
  20925. this.target.setPosition(c, a)
  20926. },
  20927. clone: function() {
  20928. var a = new cc.CardinalSplineBy;
  20929. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  20930. return a
  20931. }
  20932. });
  20933. cc.cardinalSplineBy = function(a, b, c) {
  20934. return new cc.CardinalSplineBy(a, b, c)
  20935. };
  20936. cc.CardinalSplineBy.create = cc.cardinalSplineBy;
  20937. cc.CatmullRomTo = cc.CardinalSplineTo.extend({
  20938. ctor: function(a, b) {
  20939. b && this.initWithDuration(a, b)
  20940. },
  20941. initWithDuration: function(a, b) {
  20942. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5)
  20943. },
  20944. clone: function() {
  20945. var a = new cc.CatmullRomTo;
  20946. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  20947. return a
  20948. }
  20949. });
  20950. cc.catmullRomTo = function(a, b) {
  20951. return new cc.CatmullRomTo(a, b)
  20952. };
  20953. cc.CatmullRomTo.create = cc.catmullRomTo;
  20954. cc.CatmullRomBy = cc.CardinalSplineBy.extend({
  20955. ctor: function(a, b) {
  20956. cc.CardinalSplineBy.prototype.ctor.call(this);
  20957. b && this.initWithDuration(a, b)
  20958. },
  20959. initWithDuration: function(a, b) {
  20960. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5)
  20961. },
  20962. clone: function() {
  20963. var a = new cc.CatmullRomBy;
  20964. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  20965. return a
  20966. }
  20967. });
  20968. cc.catmullRomBy = function(a, b) {
  20969. return new cc.CatmullRomBy(a, b)
  20970. };
  20971. cc.CatmullRomBy.create = cc.catmullRomBy;
  20972. cc.ActionTweenDelegate = cc.Class.extend({
  20973. updateTweenAction: function(a, b) {}
  20974. });
  20975. cc.ActionTween = cc.ActionInterval.extend({
  20976. key: "",
  20977. from: 0,
  20978. to: 0,
  20979. delta: 0,
  20980. ctor: function(a, b, c, d) {
  20981. cc.ActionInterval.prototype.ctor.call(this);
  20982. this.key = "";
  20983. void 0 !== d && this.initWithDuration(a, b, c, d)
  20984. },
  20985. initWithDuration: function(a, b, c, d) {
  20986. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.key = b, this.to = d, this.from = c, !0) : !1
  20987. },
  20988. startWithTarget: function(a) {
  20989. if (!a || !a.updateTweenAction) throw "cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
  20990. cc.ActionInterval.prototype.startWithTarget.call(this,
  20991. a);
  20992. this.delta = this.to - this.from
  20993. },
  20994. update: function(a) {
  20995. this.target.updateTweenAction(this.to - this.delta * (1 - a), this.key)
  20996. },
  20997. reverse: function() {
  20998. return new cc.ActionTween(this.duration, this.key, this.to, this.from)
  20999. },
  21000. clone: function() {
  21001. var a = new cc.ActionTween;
  21002. a.initWithDuration(this._duration, this.key, this.from, this.to);
  21003. return a
  21004. }
  21005. });
  21006. cc.actionTween = function(a, b, c, d) {
  21007. return new cc.ActionTween(a, b, c, d)
  21008. };
  21009. cc.ActionTween.create = cc.actionTween;
  21010. cc.GridAction = cc.ActionInterval.extend({
  21011. _gridSize: null,
  21012. _gridNodeTarget: null,
  21013. ctor: function(a, b) {
  21014. cc._checkWebGLRenderMode();
  21015. cc.ActionInterval.prototype.ctor.call(this);
  21016. this._gridSize = cc.size(0, 0);
  21017. b && this.initWithDuration(a, b)
  21018. },
  21019. _cacheTargetAsGridNode: function() {},
  21020. clone: function() {
  21021. var a = new cc.GridAction,
  21022. b = this._gridSize;
  21023. a.initWithDuration(this._duration, cc.size(b.width, b.height));
  21024. return a
  21025. },
  21026. startWithTarget: function(a) {
  21027. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  21028. cc.renderer.childrenOrderDirty = !0;
  21029. var b = this.getGrid(),
  21030. c = this.target;
  21031. (a = c.grid) && 0 < a.getReuseGrid() ? (b = a.getGridSize(), a.isActive() && b.width === this._gridSize.width && b.height === this._gridSize.height && a.reuse()) : (a && a.isActive() && a.setActive(!1), c.grid = b, c.grid.setActive(!0))
  21032. },
  21033. reverse: function() {
  21034. return new cc.ReverseTime(this)
  21035. },
  21036. initWithDuration: function(a, b) {
  21037. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._gridSize.width = b.width, this._gridSize.height = b.height, !0) : !1
  21038. },
  21039. getGrid: function() {
  21040. cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.")
  21041. }
  21042. });
  21043. cc.gridAction = function(a, b) {
  21044. return new cc.GridAction(a, b)
  21045. };
  21046. cc.GridAction.create = cc.gridAction;
  21047. cc.Grid3DAction = cc.GridAction.extend({
  21048. getGrid: function() {
  21049. return new cc.Grid3D(this._gridSize)
  21050. },
  21051. vertex: function(a) {
  21052. return this.getVertex(a)
  21053. },
  21054. getVertex: function(a) {
  21055. return this.target.grid.getVertex(a)
  21056. },
  21057. originalVertex: function(a) {
  21058. return this.getOriginalVertex(a)
  21059. },
  21060. getOriginalVertex: function(a) {
  21061. return this.target.grid.originalVertex(a)
  21062. },
  21063. setVertex: function(a, b) {
  21064. this.target.grid.setVertex(a, b)
  21065. }
  21066. });
  21067. cc.grid3DAction = function(a, b) {
  21068. return new cc.Grid3DAction(a, b)
  21069. };
  21070. cc.Grid3DAction.create = cc.grid3DAction;
  21071. cc.TiledGrid3DAction = cc.GridAction.extend({
  21072. tile: function(a) {
  21073. return this.getTile(a)
  21074. },
  21075. getTile: function(a) {
  21076. return this.target.grid.tile(a)
  21077. },
  21078. originalTile: function(a) {
  21079. return this.getOriginalTile(a)
  21080. },
  21081. getOriginalTile: function(a) {
  21082. return this.target.grid.originalTile(a)
  21083. },
  21084. setTile: function(a, b) {
  21085. this.target.grid.setTile(a, b)
  21086. },
  21087. getGrid: function() {
  21088. return new cc.TiledGrid3D(this._gridSize)
  21089. }
  21090. });
  21091. cc.tiledGrid3DAction = function(a, b) {
  21092. return new cc.TiledGrid3DAction(a, b)
  21093. };
  21094. cc.TiledGrid3DAction.create = cc.tiledGrid3DAction;
  21095. cc.StopGrid = cc.ActionInstant.extend({
  21096. startWithTarget: function(a) {
  21097. cc.ActionInstant.prototype.startWithTarget.call(this, a);
  21098. cc.renderer.childrenOrderDirty = !0;
  21099. (a = this.target.grid) && a.isActive() && a.setActive(!1)
  21100. }
  21101. });
  21102. cc.stopGrid = function() {
  21103. return new cc.StopGrid
  21104. };
  21105. cc.StopGrid.create = cc.stopGrid;
  21106. cc.ReuseGrid = cc.ActionInstant.extend({
  21107. _times: null,
  21108. ctor: function(a) {
  21109. cc.ActionInstant.prototype.ctor.call(this);
  21110. void 0 !== a && this.initWithTimes(a)
  21111. },
  21112. initWithTimes: function(a) {
  21113. this._times = a;
  21114. return !0
  21115. },
  21116. startWithTarget: function(a) {
  21117. cc.ActionInstant.prototype.startWithTarget.call(this, a);
  21118. cc.renderer.childrenOrderDirty = !0;
  21119. this.target.grid && this.target.grid.isActive() && this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times)
  21120. }
  21121. });
  21122. cc.reuseGrid = function(a) {
  21123. return new cc.ReuseGrid(a)
  21124. };
  21125. cc.ReuseGrid.create = cc.reuseGrid;
  21126. cc.Waves3D = cc.Grid3DAction.extend({
  21127. _waves: 0,
  21128. _amplitude: 0,
  21129. _amplitudeRate: 0,
  21130. ctor: function(a, b, c, d) {
  21131. cc.GridAction.prototype.ctor.call(this);
  21132. void 0 !== d && this.initWithDuration(a, b, c, d)
  21133. },
  21134. getAmplitude: function() {
  21135. return this._amplitude
  21136. },
  21137. setAmplitude: function(a) {
  21138. this._amplitude = a
  21139. },
  21140. getAmplitudeRate: function() {
  21141. return this._amplitudeRate
  21142. },
  21143. setAmplitudeRate: function(a) {
  21144. this._amplitudeRate = a
  21145. },
  21146. initWithDuration: function(a, b, c, d) {
  21147. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude =
  21148. d, this._amplitudeRate = 1, !0) : !1
  21149. },
  21150. update: function(a) {
  21151. for (var b = this._gridSize, c = this._amplitude, d = cc.p(0, 0), e = this._amplitudeRate, f = this._waves, g = 0; g < b.width + 1; ++g)
  21152. for (var h = 0; h < b.height + 1; ++h) {
  21153. d.x = g;
  21154. d.y = h;
  21155. var k = this.originalVertex(d);
  21156. k.z += Math.sin(Math.PI * a * f * 2 + 0.01 * (k.y + k.x)) * c * e;
  21157. this.setVertex(d, k)
  21158. }
  21159. }
  21160. });
  21161. cc.waves3D = function(a, b, c, d) {
  21162. return new cc.Waves3D(a, b, c, d)
  21163. };
  21164. cc.Waves3D.create = cc.waves3D;
  21165. cc.FlipX3D = cc.Grid3DAction.extend({
  21166. ctor: function(a) {
  21167. void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
  21168. },
  21169. initWithDuration: function(a) {
  21170. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, 1))
  21171. },
  21172. initWithSize: function(a, b) {
  21173. return 1 !== a.width || 1 !== a.height ? (cc.log("Grid size must be (1,1)"), !1) : cc.Grid3DAction.prototype.initWithDuration.call(this, b, a)
  21174. },
  21175. update: function(a) {
  21176. var b = Math.PI * a;
  21177. a = Math.sin(b);
  21178. var c = Math.cos(b / 2),
  21179. b = new cc.Vertex3F,
  21180. d = cc.p(0, 0);
  21181. d.x = d.y = 1;
  21182. var e = this.originalVertex(d);
  21183. d.x = d.y = 0;
  21184. var d = this.originalVertex(d),
  21185. f = e.x,
  21186. g = d.x,
  21187. h, k;
  21188. f > g ? (e = cc.p(0, 0), d = cc.p(0, 1), h = cc.p(1, 0), k = cc.p(1, 1)) : (h = cc.p(0, 0), k = cc.p(0, 1), e = cc.p(1, 0), d = cc.p(1, 1), f = g);
  21189. b.x = f - f * c;
  21190. b.z = Math.abs(parseFloat(f * a / 4));
  21191. a = this.originalVertex(e);
  21192. a.x = b.x;
  21193. a.z += b.z;
  21194. this.setVertex(e, a);
  21195. a = this.originalVertex(d);
  21196. a.x = b.x;
  21197. a.z += b.z;
  21198. this.setVertex(d, a);
  21199. a = this.originalVertex(h);
  21200. a.x -= b.x;
  21201. a.z -= b.z;
  21202. this.setVertex(h, a);
  21203. a = this.originalVertex(k);
  21204. a.x -= b.x;
  21205. a.z -= b.z;
  21206. this.setVertex(k,
  21207. a)
  21208. }
  21209. });
  21210. cc.flipX3D = function(a) {
  21211. return new cc.FlipX3D(a)
  21212. };
  21213. cc.FlipX3D.create = cc.flipX3D;
  21214. cc.FlipY3D = cc.FlipX3D.extend({
  21215. ctor: function(a) {
  21216. void 0 !== a ? cc.GridAction.prototype.ctor.call(this, a, cc.size(1, 1)) : cc.GridAction.prototype.ctor.call(this)
  21217. },
  21218. update: function(a) {
  21219. var b = Math.PI * a;
  21220. a = Math.sin(b);
  21221. var c = Math.cos(b / 2),
  21222. b = new cc.Vertex3F,
  21223. d = cc.p(0, 0);
  21224. d.x = d.y = 1;
  21225. var e = this.originalVertex(d);
  21226. d.x = d.y = 0;
  21227. var d = this.originalVertex(d),
  21228. f = e.y,
  21229. g = d.y,
  21230. h, k;
  21231. f > g ? (e = cc.p(0, 0), d = cc.p(0, 1), h = cc.p(1, 0), k = cc.p(1, 1)) : (d = cc.p(0, 0), e = cc.p(0, 1), k = cc.p(1, 0), h = cc.p(1, 1), f = g);
  21232. b.y = f - f * c;
  21233. b.z = Math.abs(parseFloat(f * a) / 4);
  21234. a = this.originalVertex(e);
  21235. a.y = b.y;
  21236. a.z += b.z;
  21237. this.setVertex(e, a);
  21238. a = this.originalVertex(d);
  21239. a.y -= b.y;
  21240. a.z -= b.z;
  21241. this.setVertex(d, a);
  21242. a = this.originalVertex(h);
  21243. a.y = b.y;
  21244. a.z += b.z;
  21245. this.setVertex(h, a);
  21246. a = this.originalVertex(k);
  21247. a.y -= b.y;
  21248. a.z -= b.z;
  21249. this.setVertex(k, a)
  21250. }
  21251. });
  21252. cc.flipY3D = function(a) {
  21253. return new cc.FlipY3D(a)
  21254. };
  21255. cc.FlipY3D.create = cc.flipY3D;
  21256. cc.Lens3D = cc.Grid3DAction.extend({
  21257. _position: null,
  21258. _radius: 0,
  21259. _lensEffect: 0,
  21260. _concave: !1,
  21261. _dirty: !1,
  21262. ctor: function(a, b, c, d) {
  21263. cc.GridAction.prototype.ctor.call(this);
  21264. this._position = cc.p(0, 0);
  21265. void 0 !== d && this.initWithDuration(a, b, c, d)
  21266. },
  21267. getLensEffect: function() {
  21268. return this._lensEffect
  21269. },
  21270. setLensEffect: function(a) {
  21271. this._lensEffect = a
  21272. },
  21273. setConcave: function(a) {
  21274. this._concave = a
  21275. },
  21276. getPosition: function() {
  21277. return this._position
  21278. },
  21279. setPosition: function(a) {
  21280. cc.pointEqualToPoint(a, this._position) || (this._position.x = a.x, this._position.y =
  21281. a.y, this._dirty = !0)
  21282. },
  21283. initWithDuration: function(a, b, c, d) {
  21284. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._radius = d, this._lensEffect = 0.7, this._dirty = !0) : !1
  21285. },
  21286. update: function(a) {
  21287. if (this._dirty) {
  21288. a = this._gridSize.width;
  21289. for (var b = this._gridSize.height, c = this._radius, d = this._lensEffect, e = cc.p(0, 0), f = cc.p(0, 0), g, h, k, m = 0; m < a + 1; ++m)
  21290. for (var n = 0; n < b + 1; ++n) e.x = m, e.y = n, g = this.originalVertex(e), f.x = this._position.x - g.x, f.y = this._position.y - g.y, h = cc.pLength(f), h < c && (h = c -
  21291. h, h /= c, 0 === h && (h = 0.001), h = Math.log(h) * d, k = Math.exp(h) * c, h = cc.pLength(f), 0 < h && (f.x /= h, f.y /= h, f.x *= k, f.y *= k, g.z += cc.pLength(f) * d)), this.setVertex(e, g);
  21292. this._dirty = !1
  21293. }
  21294. }
  21295. });
  21296. cc.lens3D = function(a, b, c, d) {
  21297. return new cc.Lens3D(a, b, c, d)
  21298. };
  21299. cc.Lens3D.create = cc.lens3D;
  21300. cc.Ripple3D = cc.Grid3DAction.extend({
  21301. _position: null,
  21302. _radius: 0,
  21303. _waves: 0,
  21304. _amplitude: 0,
  21305. _amplitudeRate: 0,
  21306. ctor: function(a, b, c, d, e, f) {
  21307. cc.GridAction.prototype.ctor.call(this);
  21308. this._position = cc.p(0, 0);
  21309. void 0 !== f && this.initWithDuration(a, b, c, d, e, f)
  21310. },
  21311. getPosition: function() {
  21312. return this._position
  21313. },
  21314. setPosition: function(a) {
  21315. this._position.x = a.x;
  21316. this._position.y = a.y
  21317. },
  21318. getAmplitude: function() {
  21319. return this._amplitude
  21320. },
  21321. setAmplitude: function(a) {
  21322. this._amplitude = a
  21323. },
  21324. getAmplitudeRate: function() {
  21325. return this._amplitudeRate
  21326. },
  21327. setAmplitudeRate: function(a) {
  21328. this._amplitudeRate = a
  21329. },
  21330. initWithDuration: function(a, b, c, d, e, f) {
  21331. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._radius = d, this._waves = e, this._amplitude = f, this._amplitudeRate = 1, !0) : !1
  21332. },
  21333. update: function(a) {
  21334. for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._radius, f = this._waves, g = this._amplitude, h = this._amplitudeRate, k, m, n = cc.p(0, 0), p = 0; p < b + 1; ++p)
  21335. for (var t = 0; t < c + 1; ++t) {
  21336. d.x = p;
  21337. d.y = t;
  21338. k = this.originalVertex(d);
  21339. n.x =
  21340. this._position.x - k.x;
  21341. n.y = this._position.y - k.y;
  21342. m = cc.pLength(n);
  21343. if (m < e) {
  21344. m = e - m;
  21345. var r = Math.pow(m / e, 2);
  21346. k.z += Math.sin(a * Math.PI * f * 2 + 0.1 * m) * g * h * r
  21347. }
  21348. this.setVertex(d, k)
  21349. }
  21350. }
  21351. });
  21352. cc.ripple3D = function(a, b, c, d, e, f) {
  21353. return new cc.Ripple3D(a, b, c, d, e, f)
  21354. };
  21355. cc.Ripple3D.create = cc.ripple3D;
  21356. cc.Shaky3D = cc.Grid3DAction.extend({
  21357. _randRange: 0,
  21358. _shakeZ: !1,
  21359. ctor: function(a, b, c, d) {
  21360. cc.GridAction.prototype.ctor.call(this);
  21361. void 0 !== d && this.initWithDuration(a, b, c, d)
  21362. },
  21363. initWithDuration: function(a, b, c, d) {
  21364. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._randRange = c, this._shakeZ = d, !0) : !1
  21365. },
  21366. update: function(a) {
  21367. a = this._gridSize.width;
  21368. for (var b = this._gridSize.height, c = this._randRange, d = this._shakeZ, e = cc.p(0, 0), f, g = 0; g < a + 1; ++g)
  21369. for (var h = 0; h < b + 1; ++h) e.x = g, e.y = h, f = this.originalVertex(e),
  21370. f.x += cc.rand() % (2 * c) - c, f.y += cc.rand() % (2 * c) - c, d && (f.z += cc.rand() % (2 * c) - c), this.setVertex(e, f)
  21371. }
  21372. });
  21373. cc.shaky3D = function(a, b, c, d) {
  21374. return new cc.Shaky3D(a, b, c, d)
  21375. };
  21376. cc.Shaky3D.create = cc.shaky3D;
  21377. cc.Liquid = cc.Grid3DAction.extend({
  21378. _waves: 0,
  21379. _amplitude: 0,
  21380. _amplitudeRate: 0,
  21381. ctor: function(a, b, c, d) {
  21382. cc.GridAction.prototype.ctor.call(this);
  21383. void 0 !== d && this.initWithDuration(a, b, c, d)
  21384. },
  21385. getAmplitude: function() {
  21386. return this._amplitude
  21387. },
  21388. setAmplitude: function(a) {
  21389. this._amplitude = a
  21390. },
  21391. getAmplitudeRate: function() {
  21392. return this._amplitudeRate
  21393. },
  21394. setAmplitudeRate: function(a) {
  21395. this._amplitudeRate = a
  21396. },
  21397. initWithDuration: function(a, b, c, d) {
  21398. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves = c, this._amplitude =
  21399. d, this._amplitudeRate = 1, !0) : !1
  21400. },
  21401. update: function(a) {
  21402. for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._waves, f = this._amplitude, g = this._amplitudeRate, h, k = 1; k < b; ++k)
  21403. for (var m = 1; m < c; ++m) d.x = k, d.y = m, h = this.originalVertex(d), h.x += Math.sin(a * Math.PI * e * 2 + 0.01 * h.x) * f * g, h.y += Math.sin(a * Math.PI * e * 2 + 0.01 * h.y) * f * g, this.setVertex(d, h)
  21404. }
  21405. });
  21406. cc.liquid = function(a, b, c, d) {
  21407. return new cc.Liquid(a, b, c, d)
  21408. };
  21409. cc.Liquid.create = cc.liquid;
  21410. cc.Waves = cc.Grid3DAction.extend({
  21411. _waves: 0,
  21412. _amplitude: 0,
  21413. _amplitudeRate: 0,
  21414. _vertical: !1,
  21415. _horizontal: !1,
  21416. ctor: function(a, b, c, d, e, f) {
  21417. cc.GridAction.prototype.ctor.call(this);
  21418. void 0 !== f && this.initWithDuration(a, b, c, d, e, f)
  21419. },
  21420. getAmplitude: function() {
  21421. return this._amplitude
  21422. },
  21423. setAmplitude: function(a) {
  21424. this._amplitude = a
  21425. },
  21426. getAmplitudeRate: function() {
  21427. return this._amplitudeRate
  21428. },
  21429. setAmplitudeRate: function(a) {
  21430. this._amplitudeRate = a
  21431. },
  21432. initWithDuration: function(a, b, c, d, e, f) {
  21433. return cc.Grid3DAction.prototype.initWithDuration.call(this,
  21434. a, b) ? (this._waves = c, this._amplitude = d, this._amplitudeRate = 1, this._horizontal = e, this._vertical = f, !0) : !1
  21435. },
  21436. update: function(a) {
  21437. for (var b = this._gridSize.width, c = this._gridSize.height, d = cc.p(0, 0), e = this._vertical, f = this._horizontal, g = this._waves, h = this._amplitude, k = this._amplitudeRate, m, n = 0; n < b + 1; ++n)
  21438. for (var p = 0; p < c + 1; ++p) d.x = n, d.y = p, m = this.originalVertex(d), e && (m.x += Math.sin(a * Math.PI * g * 2 + 0.01 * m.y) * h * k), f && (m.y += Math.sin(a * Math.PI * g * 2 + 0.01 * m.x) * h * k), this.setVertex(d, m)
  21439. }
  21440. });
  21441. cc.waves = function(a, b, c, d, e, f) {
  21442. return new cc.Waves(a, b, c, d, e, f)
  21443. };
  21444. cc.Waves.create = cc.waves;
  21445. cc.Twirl = cc.Grid3DAction.extend({
  21446. _position: null,
  21447. _twirls: 0,
  21448. _amplitude: 0,
  21449. _amplitudeRate: 0,
  21450. ctor: function(a, b, c, d, e) {
  21451. cc.GridAction.prototype.ctor.call(this);
  21452. this._position = cc.p(0, 0);
  21453. void 0 !== e && this.initWithDuration(a, b, c, d, e)
  21454. },
  21455. getPosition: function() {
  21456. return this._position
  21457. },
  21458. setPosition: function(a) {
  21459. this._position.x = a.x;
  21460. this._position.y = a.y
  21461. },
  21462. getAmplitude: function() {
  21463. return this._amplitude
  21464. },
  21465. setAmplitude: function(a) {
  21466. this._amplitude = a
  21467. },
  21468. getAmplitudeRate: function() {
  21469. return this._amplitudeRate
  21470. },
  21471. setAmplitudeRate: function(a) {
  21472. this._amplitudeRate =
  21473. a
  21474. },
  21475. initWithDuration: function(a, b, c, d, e) {
  21476. return cc.Grid3DAction.prototype.initWithDuration.call(this, a, b) ? (this.setPosition(c), this._twirls = d, this._amplitude = e, this._amplitudeRate = 1, !0) : !1
  21477. },
  21478. update: function(a) {
  21479. for (var b = this._position, c = this._gridSize.width, d = this._gridSize.height, e = cc.p(0, 0), f = 0.1 * this._amplitude * this._amplitudeRate, g = this._twirls, h, k, m, n = cc.p(0, 0), p = 0; p < c + 1; ++p)
  21480. for (var t = 0; t < d + 1; ++t) e.x = p, e.y = t, h = this.originalVertex(e), n.x = p - c / 2, n.y = t - d / 2, k = cc.pLength(n) * Math.cos(Math.PI / 2 + a * Math.PI *
  21481. g * 2) * f, m = Math.sin(k) * (h.y - b.y) + Math.cos(k) * (h.x - b.x), k = Math.cos(k) * (h.y - b.y) - Math.sin(k) * (h.x - b.x), h.x = b.x + m, h.y = b.y + k, this.setVertex(e, h)
  21482. }
  21483. });
  21484. cc.twirl = function(a, b, c, d, e) {
  21485. return new cc.Twirl(a, b, c, d, e)
  21486. };
  21487. cc.Twirl.create = cc.twirl;
  21488. cc.ShakyTiles3D = cc.TiledGrid3DAction.extend({
  21489. _randRange: 0,
  21490. _shakeZ: !1,
  21491. ctor: function(a, b, c, d) {
  21492. cc.GridAction.prototype.ctor.call(this);
  21493. void 0 !== d && this.initWithDuration(a, b, c, d)
  21494. },
  21495. initWithDuration: function(a, b, c, d) {
  21496. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._randRange = c, this._shakeZ = d, !0) : !1
  21497. },
  21498. update: function(a) {
  21499. a = this._gridSize;
  21500. for (var b = this._randRange, c = cc.p(0, 0), d = 0; d < a.width; ++d)
  21501. for (var e = 0; e < a.height; ++e) {
  21502. c.x = d;
  21503. c.y = e;
  21504. var f = this.originalTile(c);
  21505. f.bl.x += cc.rand() % (2 *
  21506. b) - b;
  21507. f.br.x += cc.rand() % (2 * b) - b;
  21508. f.tl.x += cc.rand() % (2 * b) - b;
  21509. f.tr.x += cc.rand() % (2 * b) - b;
  21510. f.bl.y += cc.rand() % (2 * b) - b;
  21511. f.br.y += cc.rand() % (2 * b) - b;
  21512. f.tl.y += cc.rand() % (2 * b) - b;
  21513. f.tr.y += cc.rand() % (2 * b) - b;
  21514. this._shakeZ && (f.bl.z += cc.rand() % (2 * b) - b, f.br.z += cc.rand() % (2 * b) - b, f.tl.z += cc.rand() % (2 * b) - b, f.tr.z += cc.rand() % (2 * b) - b);
  21515. this.setTile(c, f)
  21516. }
  21517. }
  21518. });
  21519. cc.shakyTiles3D = function(a, b, c, d) {
  21520. return new cc.ShakyTiles3D(a, b, c, d)
  21521. };
  21522. cc.ShakyTiles3D.create = cc.shakyTiles3D;
  21523. cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend({
  21524. _randRange: 0,
  21525. _once: !1,
  21526. _shatterZ: !1,
  21527. ctor: function(a, b, c, d) {
  21528. cc.GridAction.prototype.ctor.call(this);
  21529. void 0 !== d && this.initWithDuration(a, b, c, d)
  21530. },
  21531. initWithDuration: function(a, b, c, d) {
  21532. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._once = !1, this._randRange = c, this._shatterZ = d, !0) : !1
  21533. },
  21534. update: function(a) {
  21535. if (!1 === this._once) {
  21536. a = this._gridSize;
  21537. for (var b = this._randRange, c, d = cc.p(0, 0), e = 0; e < a.width; ++e)
  21538. for (var f = 0; f < a.height; ++f) d.x = e,
  21539. d.y = f, c = this.originalTile(d), c.bl.x += cc.rand() % (2 * b) - b, c.br.x += cc.rand() % (2 * b) - b, c.tl.x += cc.rand() % (2 * b) - b, c.tr.x += cc.rand() % (2 * b) - b, c.bl.y += cc.rand() % (2 * b) - b, c.br.y += cc.rand() % (2 * b) - b, c.tl.y += cc.rand() % (2 * b) - b, c.tr.y += cc.rand() % (2 * b) - b, this._shatterZ && (c.bl.z += cc.rand() % (2 * b) - b, c.br.z += cc.rand() % (2 * b) - b, c.tl.z += cc.rand() % (2 * b) - b, c.tr.z += cc.rand() % (2 * b) - b), this.setTile(d, c);
  21540. this._once = !0
  21541. }
  21542. }
  21543. });
  21544. cc.shatteredTiles3D = function(a, b, c, d) {
  21545. return new cc.ShatteredTiles3D(a, b, c, d)
  21546. };
  21547. cc.ShatteredTiles3D.create = cc.shatteredTiles3D;
  21548. cc.Tile = function(a, b, c) {
  21549. this.position = a || cc.p(0, 0);
  21550. this.startPosition = b || cc.p(0, 0);
  21551. this.delta = c || cc.p(0, 0)
  21552. };
  21553. cc.ShuffleTiles = cc.TiledGrid3DAction.extend({
  21554. _seed: 0,
  21555. _tilesCount: 0,
  21556. _tilesOrder: null,
  21557. _tiles: null,
  21558. ctor: function(a, b, c) {
  21559. cc.GridAction.prototype.ctor.call(this);
  21560. this._tilesOrder = [];
  21561. this._tiles = [];
  21562. void 0 !== c && this.initWithDuration(a, b, c)
  21563. },
  21564. initWithDuration: function(a, b, c) {
  21565. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._seed = c, this._tilesOrder.length = 0, this._tiles.length = 0, !0) : !1
  21566. },
  21567. shuffle: function(a, b) {
  21568. for (var c = b - 1; 0 <= c; c--) {
  21569. var d = 0 | cc.rand() % (c + 1),
  21570. e = a[c];
  21571. a[c] = a[d];
  21572. a[d] = e
  21573. }
  21574. },
  21575. getDelta: function(a) {
  21576. var b = this._gridSize,
  21577. c = a.width * b.height + a.height;
  21578. return cc.size(this._tilesOrder[c] / b.height - a.width, this._tilesOrder[c] % b.height - a.height)
  21579. },
  21580. placeTile: function(a, b) {
  21581. var c = this.originalTile(a),
  21582. d = this.target.grid.getStep(),
  21583. e = b.position;
  21584. c.bl.x += e.x * d.x;
  21585. c.bl.y += e.y * d.y;
  21586. c.br.x += e.x * d.x;
  21587. c.br.y += e.y * d.y;
  21588. c.tl.x += e.x * d.x;
  21589. c.tl.y += e.y * d.y;
  21590. c.tr.x += e.x * d.x;
  21591. c.tr.y += e.y * d.y;
  21592. this.setTile(a, c)
  21593. },
  21594. startWithTarget: function(a) {
  21595. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  21596. a = this._gridSize;
  21597. this._tilesCount = a.width * a.height;
  21598. for (var b = this._tilesOrder, c = b.length = 0; c < this._tilesCount; ++c) b[c] = c;
  21599. this.shuffle(b, this._tilesCount);
  21600. for (var b = this._tiles, c = b.length = 0, d = cc.size(0, 0), e = 0; e < a.width; ++e)
  21601. for (var f = 0; f < a.height; ++f) b[c] = new cc.Tile, b[c].position = cc.p(e, f), b[c].startPosition = cc.p(e, f), d.width = e, d.height = f, b[c].delta = this.getDelta(d), ++c
  21602. },
  21603. update: function(a) {
  21604. for (var b = 0, c = this._gridSize, d = this._tiles, e, f = cc.p(0, 0), g = 0; g < c.width; ++g)
  21605. for (var h = 0; h < c.height; ++h) f.x = g, f.y = h, e = d[b], e.position.x =
  21606. e.delta.width * a, e.position.y = e.delta.height * a, this.placeTile(f, e), ++b
  21607. }
  21608. });
  21609. cc.shuffleTiles = function(a, b, c) {
  21610. return new cc.ShuffleTiles(a, b, c)
  21611. };
  21612. cc.ShuffleTiles.create = cc.shuffleTiles;
  21613. cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend({
  21614. testFunc: function(a, b) {
  21615. var c = this._gridSize.width * b,
  21616. d = this._gridSize.height * b;
  21617. return 0 === c + d ? 1 : Math.pow((a.width + a.height) / (c + d), 6)
  21618. },
  21619. turnOnTile: function(a) {
  21620. this.setTile(a, this.originalTile(a))
  21621. },
  21622. turnOffTile: function(a) {
  21623. this.setTile(a, new cc.Quad3)
  21624. },
  21625. transformTile: function(a, b) {
  21626. var c = this.originalTile(a),
  21627. d = this.target.grid.getStep();
  21628. c.bl.x += d.x / 2 * (1 - b);
  21629. c.bl.y += d.y / 2 * (1 - b);
  21630. c.br.x -= d.x / 2 * (1 - b);
  21631. c.br.y += d.y / 2 * (1 - b);
  21632. c.tl.x += d.x / 2 * (1 - b);
  21633. c.tl.y -= d.y / 2 * (1 - b);
  21634. c.tr.x -=
  21635. d.x / 2 * (1 - b);
  21636. c.tr.y -= d.y / 2 * (1 - b);
  21637. this.setTile(a, c)
  21638. },
  21639. update: function(a) {
  21640. for (var b = this._gridSize, c = cc.p(0, 0), d = cc.size(0, 0), e, f = 0; f < b.width; ++f)
  21641. for (var g = 0; g < b.height; ++g) c.x = f, c.y = g, d.width = f, d.height = g, e = this.testFunc(d, a), 0 === e ? this.turnOffTile(c) : 1 > e ? this.transformTile(c, e) : this.turnOnTile(c)
  21642. }
  21643. });
  21644. cc.fadeOutTRTiles = function(a, b) {
  21645. return new cc.FadeOutTRTiles(a, b)
  21646. };
  21647. cc.FadeOutTRTiles.create = cc.fadeOutTRTiles;
  21648. cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend({
  21649. testFunc: function(a, b) {
  21650. return 0 === a.width + a.height ? 1 : Math.pow((this._gridSize.width * (1 - b) + this._gridSize.height * (1 - b)) / (a.width + a.height), 6)
  21651. }
  21652. });
  21653. cc.fadeOutBLTiles = function(a, b) {
  21654. return new cc.FadeOutBLTiles(a, b)
  21655. };
  21656. cc.FadeOutBLTiles.create = cc.fadeOutBLTiles;
  21657. cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend({
  21658. testFunc: function(a, b) {
  21659. var c = this._gridSize.height * b;
  21660. return 0 === c ? 1 : Math.pow(a.height / c, 6)
  21661. },
  21662. transformTile: function(a, b) {
  21663. var c = this.originalTile(a),
  21664. d = this.target.grid.getStep();
  21665. c.bl.y += d.y / 2 * (1 - b);
  21666. c.br.y += d.y / 2 * (1 - b);
  21667. c.tl.y -= d.y / 2 * (1 - b);
  21668. c.tr.y -= d.y / 2 * (1 - b);
  21669. this.setTile(a, c)
  21670. }
  21671. });
  21672. cc.fadeOutUpTiles = function(a, b) {
  21673. return new cc.FadeOutUpTiles(a, b)
  21674. };
  21675. cc.FadeOutUpTiles.create = cc.fadeOutUpTiles;
  21676. cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend({
  21677. testFunc: function(a, b) {
  21678. return 0 === a.height ? 1 : Math.pow(this._gridSize.height * (1 - b) / a.height, 6)
  21679. }
  21680. });
  21681. cc.fadeOutDownTiles = function(a, b) {
  21682. return new cc.FadeOutDownTiles(a, b)
  21683. };
  21684. cc.FadeOutDownTiles.create = cc.fadeOutDownTiles;
  21685. cc.TurnOffTiles = cc.TiledGrid3DAction.extend({
  21686. _seed: null,
  21687. _tilesCount: 0,
  21688. _tilesOrder: null,
  21689. ctor: function(a, b, c) {
  21690. cc.GridAction.prototype.ctor.call(this);
  21691. this._tilesOrder = [];
  21692. void 0 !== b && this.initWithDuration(a, b, c)
  21693. },
  21694. initWithDuration: function(a, b, c) {
  21695. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._seed = c || 0, this._tilesOrder.length = 0, !0) : !1
  21696. },
  21697. shuffle: function(a, b) {
  21698. for (var c = b - 1; 0 <= c; c--) {
  21699. var d = 0 | cc.rand() % (c + 1),
  21700. e = a[c];
  21701. a[c] = a[d];
  21702. a[d] = e
  21703. }
  21704. },
  21705. turnOnTile: function(a) {
  21706. this.setTile(a, this.originalTile(a))
  21707. },
  21708. turnOffTile: function(a) {
  21709. this.setTile(a, new cc.Quad3)
  21710. },
  21711. startWithTarget: function(a) {
  21712. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  21713. this._tilesCount = this._gridSize.width * this._gridSize.height;
  21714. a = this._tilesOrder;
  21715. for (var b = a.length = 0; b < this._tilesCount; ++b) a[b] = b;
  21716. this.shuffle(a, this._tilesCount)
  21717. },
  21718. update: function(a) {
  21719. a = 0 | a * this._tilesCount;
  21720. for (var b = this._gridSize, c, d = cc.p(0, 0), e = this._tilesOrder, f = 0; f < this._tilesCount; f++) c = e[f], d.x = 0 | c / b.height, d.y = c % (0 | b.height), f < a ? this.turnOffTile(d) : this.turnOnTile(d)
  21721. }
  21722. });
  21723. cc.turnOffTiles = function(a, b, c) {
  21724. return new cc.TurnOffTiles(a, b, c)
  21725. };
  21726. cc.TurnOffTiles.create = cc.turnOffTiles;
  21727. cc.WavesTiles3D = cc.TiledGrid3DAction.extend({
  21728. _waves: 0,
  21729. _amplitude: 0,
  21730. _amplitudeRate: 0,
  21731. ctor: function(a, b, c, d) {
  21732. cc.GridAction.prototype.ctor.call(this);
  21733. void 0 !== d && this.initWithDuration(a, b, c, d)
  21734. },
  21735. getAmplitude: function() {
  21736. return this._amplitude
  21737. },
  21738. setAmplitude: function(a) {
  21739. this._amplitude = a
  21740. },
  21741. getAmplitudeRate: function() {
  21742. return this._amplitudeRate
  21743. },
  21744. setAmplitudeRate: function(a) {
  21745. this._amplitudeRate = a
  21746. },
  21747. initWithDuration: function(a, b, c, d) {
  21748. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._waves =
  21749. c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1
  21750. },
  21751. update: function(a) {
  21752. for (var b = this._gridSize, c = this._waves, d = this._amplitude, e = this._amplitudeRate, f = cc.p(0, 0), g, h = 0; h < b.width; h++)
  21753. for (var k = 0; k < b.height; k++) f.x = h, f.y = k, g = this.originalTile(f), g.bl.z = Math.sin(a * Math.PI * c * 2 + 0.01 * (g.bl.y + g.bl.x)) * d * e, g.br.z = g.bl.z, g.tl.z = g.bl.z, g.tr.z = g.bl.z, this.setTile(f, g)
  21754. }
  21755. });
  21756. cc.wavesTiles3D = function(a, b, c, d) {
  21757. return new cc.WavesTiles3D(a, b, c, d)
  21758. };
  21759. cc.WavesTiles3D.create = cc.wavesTiles3D;
  21760. cc.JumpTiles3D = cc.TiledGrid3DAction.extend({
  21761. _jumps: 0,
  21762. _amplitude: 0,
  21763. _amplitudeRate: 0,
  21764. ctor: function(a, b, c, d) {
  21765. cc.GridAction.prototype.ctor.call(this);
  21766. void 0 !== d && this.initWithDuration(a, b, c, d)
  21767. },
  21768. getAmplitude: function() {
  21769. return this._amplitude
  21770. },
  21771. setAmplitude: function(a) {
  21772. this._amplitude = a
  21773. },
  21774. getAmplitudeRate: function() {
  21775. return this._amplitudeRate
  21776. },
  21777. setAmplitudeRate: function(a) {
  21778. this._amplitudeRate = a
  21779. },
  21780. initWithDuration: function(a, b, c, d) {
  21781. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, b) ? (this._jumps =
  21782. c, this._amplitude = d, this._amplitudeRate = 1, !0) : !1
  21783. },
  21784. update: function(a) {
  21785. var b = Math.sin(Math.PI * a * this._jumps * 2) * this._amplitude * this._amplitudeRate;
  21786. a = Math.sin(Math.PI * (a * this._jumps * 2 + 1)) * this._amplitude * this._amplitudeRate;
  21787. for (var c = this._gridSize, d = this.target.grid, e, f = cc.p(0, 0), g = 0; g < c.width; g++)
  21788. for (var h = 0; h < c.height; h++) f.x = g, f.y = h, e = d.originalTile(f), 0 === (g + h) % 2 ? (e.bl.z += b, e.br.z += b, e.tl.z += b, e.tr.z += b) : (e.bl.z += a, e.br.z += a, e.tl.z += a, e.tr.z += a), d.setTile(f, e)
  21789. }
  21790. });
  21791. cc.jumpTiles3D = function(a, b, c, d) {
  21792. return new cc.JumpTiles3D(a, b, c, d)
  21793. };
  21794. cc.JumpTiles3D.create = cc.jumpTiles3D;
  21795. cc.SplitRows = cc.TiledGrid3DAction.extend({
  21796. _rows: 0,
  21797. _winSize: null,
  21798. ctor: function(a, b) {
  21799. cc.GridAction.prototype.ctor.call(this);
  21800. void 0 !== b && this.initWithDuration(a, b)
  21801. },
  21802. initWithDuration: function(a, b) {
  21803. this._rows = b;
  21804. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(1, b))
  21805. },
  21806. update: function(a) {
  21807. for (var b = this._gridSize, c = this._winSize.width, d, e, f = cc.p(0, 0), g = 0; g < b.height; ++g) f.y = g, d = this.originalTile(f), e = 1, 0 === g % 2 && (e = -1), d.bl.x += e * c * a, d.br.x += e * c * a, d.tl.x += e * c * a, d.tr.x += e * c * a, this.setTile(f,
  21808. d)
  21809. },
  21810. startWithTarget: function(a) {
  21811. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  21812. this._winSize = cc.director.getWinSizeInPixels()
  21813. }
  21814. });
  21815. cc.splitRows = function(a, b) {
  21816. return new cc.SplitRows(a, b)
  21817. };
  21818. cc.SplitRows.create = cc.splitRows;
  21819. cc.SplitCols = cc.TiledGrid3DAction.extend({
  21820. _cols: 0,
  21821. _winSize: null,
  21822. ctor: function(a, b) {
  21823. cc.GridAction.prototype.ctor.call(this);
  21824. void 0 !== b && this.initWithDuration(a, b)
  21825. },
  21826. initWithDuration: function(a, b) {
  21827. this._cols = b;
  21828. return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, a, cc.size(b, 1))
  21829. },
  21830. update: function(a) {
  21831. for (var b = this._gridSize.width, c = this._winSize.height, d, e, f = cc.p(0, 0), g = 0; g < b; ++g) f.x = g, d = this.originalTile(f), e = 1, 0 === g % 2 && (e = -1), d.bl.y += e * c * a, d.br.y += e * c * a, d.tl.y += e * c * a, d.tr.y += e * c * a, this.setTile(f,
  21832. d);
  21833. cc.renderer.childrenOrderDirty = !0
  21834. },
  21835. startWithTarget: function(a) {
  21836. cc.TiledGrid3DAction.prototype.startWithTarget.call(this, a);
  21837. this._winSize = cc.director.getWinSizeInPixels()
  21838. }
  21839. });
  21840. cc.splitCols = function(a, b) {
  21841. return new cc.SplitCols(a, b)
  21842. };
  21843. cc.SplitCols.create = cc.splitCols;
  21844. cc.PageTurn3D = cc.Grid3DAction.extend({
  21845. getGrid: function() {
  21846. var a = new cc.Grid3D(this._gridSize);
  21847. a.setNeedDepthTestForBlit(!0);
  21848. return a
  21849. },
  21850. clone: function() {
  21851. var a = new cc.PageTurn3D;
  21852. a.initWithDuration(this._duration, this._gridSize);
  21853. return a
  21854. },
  21855. update: function(a) {
  21856. var b = Math.max(0, a - 0.25),
  21857. b = -100 - b * b * 500;
  21858. a = -Math.PI / 2 * Math.sqrt(a);
  21859. var c = +Math.PI / 2 + a;
  21860. a = Math.sin(c);
  21861. for (var c = Math.cos(c), d = this._gridSize, e = cc.p(0, 0), f = 0; f <= d.width; ++f)
  21862. for (var g = 0; g <= d.height; ++g) {
  21863. e.x = f;
  21864. e.y = g;
  21865. var h = this.getOriginalVertex(e),
  21866. k = Math.sqrt(h.x *
  21867. h.x + (h.y - b) * (h.y - b)),
  21868. m = k * a,
  21869. n = Math.asin(h.x / k) / a,
  21870. p = Math.cos(n);
  21871. h.x = n <= Math.PI ? m * Math.sin(n) : 0;
  21872. h.y = k + b - m * (1 - p) * a;
  21873. h.z = m * (1 - p) * c / 7;
  21874. 0.5 > h.z && (h.z = 0.5);
  21875. this.setVertex(e, h)
  21876. }
  21877. }
  21878. });
  21879. cc.pageTurn3D = function(a, b) {
  21880. return new cc.PageTurn3D(a, b)
  21881. };
  21882. cc.PageTurn3D.create = cc.pageTurn3D;
  21883. cc.ProgressTimer = cc.Node.extend({
  21884. _type: null,
  21885. _percentage: 0,
  21886. _sprite: null,
  21887. _midPoint: null,
  21888. _barChangeRate: null,
  21889. _reverseDirection: !1,
  21890. _className: "ProgressTimer",
  21891. ctor: function(a) {
  21892. cc.Node.prototype.ctor.call(this);
  21893. this._type = cc.ProgressTimer.TYPE_RADIAL;
  21894. this._percentage = 0;
  21895. this._midPoint = cc.p(0, 0);
  21896. this._barChangeRate = cc.p(0, 0);
  21897. this._reverseDirection = !1;
  21898. this._sprite = null;
  21899. a && this.initWithSprite(a)
  21900. },
  21901. getMidpoint: function() {
  21902. return cc.p(this._midPoint.x, this._midPoint.y)
  21903. },
  21904. setMidpoint: function(a) {
  21905. this._midPoint = cc.pClamp(a,
  21906. cc.p(0, 0), cc.p(1, 1))
  21907. },
  21908. getBarChangeRate: function() {
  21909. return cc.p(this._barChangeRate.x, this._barChangeRate.y)
  21910. },
  21911. setBarChangeRate: function(a) {
  21912. this._barChangeRate = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
  21913. },
  21914. getType: function() {
  21915. return this._type
  21916. },
  21917. getPercentage: function() {
  21918. return this._percentage
  21919. },
  21920. getSprite: function() {
  21921. return this._sprite
  21922. },
  21923. setPercentage: function(a) {
  21924. this._percentage !== a && (this._percentage = cc.clampf(a, 0, 100), this._renderCmd._updateProgress())
  21925. },
  21926. setOpacityModifyRGB: function(a) {},
  21927. isOpacityModifyRGB: function() {
  21928. return !1
  21929. },
  21930. isReverseDirection: function() {
  21931. return this._reverseDirection
  21932. },
  21933. setColor: function(a) {
  21934. this._sprite.color = a;
  21935. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)
  21936. },
  21937. setOpacity: function(a) {
  21938. this._sprite.opacity = a;
  21939. this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)
  21940. },
  21941. getColor: function() {
  21942. return this._sprite.color
  21943. },
  21944. getOpacity: function() {
  21945. return this._sprite.opacity
  21946. },
  21947. setReverseProgress: function(a) {
  21948. this._reverseDirection !== a && (this._reverseDirection = a, this._renderCmd.releaseData())
  21949. },
  21950. setSprite: function(a) {
  21951. this._sprite !==
  21952. a && ((this._sprite = a) ? this.setContentSize(a.width, a.height) : this.setContentSize(0, 0), this._renderCmd.releaseData())
  21953. },
  21954. setType: function(a) {
  21955. a !== this._type && (this._type = a, this._renderCmd.releaseData())
  21956. },
  21957. setReverseDirection: function(a) {
  21958. this._reverseDirection !== a && (this._reverseDirection = a, this._renderCmd.releaseData())
  21959. },
  21960. initWithSprite: function(a) {
  21961. this.percentage = 0;
  21962. this.setAnchorPoint(0.5, 0.5);
  21963. this._type = cc.ProgressTimer.TYPE_RADIAL;
  21964. this._reverseDirection = !1;
  21965. this.midPoint = cc.p(0.5, 0.5);
  21966. this.barChangeRate =
  21967. cc.p(1, 1);
  21968. this.setSprite(a);
  21969. this._renderCmd.initCmd();
  21970. return !0
  21971. },
  21972. _createRenderCmd: function() {
  21973. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ProgressTimer.CanvasRenderCmd(this) : new cc.ProgressTimer.WebGLRenderCmd(this)
  21974. }
  21975. });
  21976. _p = cc.ProgressTimer.prototype;
  21977. cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint);
  21978. cc.defineGetterSetter(_p, "barChangeRate", _p.getBarChangeRate, _p.setBarChangeRate);
  21979. cc.defineGetterSetter(_p, "type", _p.getType, _p.setType);
  21980. cc.defineGetterSetter(_p, "percentage", _p.getPercentage, _p.setPercentage);
  21981. cc.defineGetterSetter(_p, "sprite", _p.getSprite, _p.setSprite);
  21982. cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDirection);
  21983. cc.ProgressTimer.create = function(a) {
  21984. return new cc.ProgressTimer(a)
  21985. };
  21986. cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4;
  21987. cc.ProgressTimer.TEXTURE_COORDS = 75;
  21988. cc.ProgressTimer.TYPE_RADIAL = 0;
  21989. cc.ProgressTimer.TYPE_BAR = 1;
  21990. cc.ProgressTo = cc.ActionInterval.extend({
  21991. _to: 0,
  21992. _from: 0,
  21993. ctor: function(a, b) {
  21994. cc.ActionInterval.prototype.ctor.call(this);
  21995. this._from = this._to = 0;
  21996. void 0 !== b && this.initWithDuration(a, b)
  21997. },
  21998. initWithDuration: function(a, b) {
  21999. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = b, !0) : !1
  22000. },
  22001. clone: function() {
  22002. var a = new cc.ProgressTo;
  22003. a.initWithDuration(this._duration, this._to);
  22004. return a
  22005. },
  22006. reverse: function() {
  22007. cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported.");
  22008. return null
  22009. },
  22010. startWithTarget: function(a) {
  22011. cc.ActionInterval.prototype.startWithTarget.call(this,
  22012. a);
  22013. this._from = a.percentage
  22014. },
  22015. update: function(a) {
  22016. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  22017. }
  22018. });
  22019. cc.progressTo = function(a, b) {
  22020. return new cc.ProgressTo(a, b)
  22021. };
  22022. cc.ProgressTo.create = cc.progressTo;
  22023. cc.ProgressFromTo = cc.ActionInterval.extend({
  22024. _to: 0,
  22025. _from: 0,
  22026. ctor: function(a, b, c) {
  22027. cc.ActionInterval.prototype.ctor.call(this);
  22028. this._from = this._to = 0;
  22029. void 0 !== c && this.initWithDuration(a, b, c)
  22030. },
  22031. initWithDuration: function(a, b, c) {
  22032. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = c, this._from = b, !0) : !1
  22033. },
  22034. clone: function() {
  22035. var a = new cc.ProgressFromTo;
  22036. a.initWithDuration(this._duration, this._from, this._to);
  22037. return a
  22038. },
  22039. reverse: function() {
  22040. return cc.progressFromTo(this._duration, this._to, this._from)
  22041. },
  22042. startWithTarget: function(a) {
  22043. cc.ActionInterval.prototype.startWithTarget.call(this, a)
  22044. },
  22045. update: function(a) {
  22046. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  22047. }
  22048. });
  22049. cc.progressFromTo = function(a, b, c) {
  22050. return new cc.ProgressFromTo(a, b, c)
  22051. };
  22052. cc.ProgressFromTo.create = cc.progressFromTo;
  22053. (function() {
  22054. cc.ProgressTimer.CanvasRenderCmd = function(a) {
  22055. cc.Node.CanvasRenderCmd.call(this, a);
  22056. this._needDraw = !0;
  22057. this._PI180 = Math.PI / 180;
  22058. this._barRect = cc.rect(0, 0, 0, 0);
  22059. this._origin = cc.p(0, 0);
  22060. this._radius = 0;
  22061. this._endAngle = this._startAngle = 270;
  22062. this._counterClockWise = !1
  22063. };
  22064. var a = cc.ProgressTimer.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  22065. a.constructor = cc.ProgressTimer.CanvasRenderCmd;
  22066. a.rendering = function(a, c, d) {
  22067. a = a || cc._renderContext;
  22068. var e = a.getContext(),
  22069. f = this._node,
  22070. g = f._sprite,
  22071. h = g._renderCmd._textureCoord,
  22072. k = g._renderCmd._displayedOpacity / 255;
  22073. if (0 !== h.width && 0 !== h.height && g._texture && h.validRect && 0 !== k) {
  22074. a.setTransform(this._worldTransform, c, d);
  22075. a.setCompositeOperation(g._blendFuncStr);
  22076. a.setGlobalAlpha(k);
  22077. var m = g._rect,
  22078. n = g._offsetPosition,
  22079. k = n.x,
  22080. p = -n.y - m.height,
  22081. t = m.width,
  22082. m = m.height;
  22083. a.save();
  22084. g._flippedX && (k = -k - t, e.scale(-1, 1));
  22085. g._flippedY && (p = n.y, e.scale(1, -1));
  22086. f._type === cc.ProgressTimer.TYPE_BAR ? (f = this._barRect, e.beginPath(), e.rect(f.x * c, f.y * d, f.width * c, f.height * d), e.clip(),
  22087. e.closePath()) : f._type === cc.ProgressTimer.TYPE_RADIAL && (f = this._origin.x * c, n = this._origin.y * d, e.beginPath(), e.arc(f, n, this._radius * d, this._PI180 * this._startAngle, this._PI180 * this._endAngle, this._counterClockWise), e.lineTo(f, n), e.clip(), e.closePath());
  22088. f = g._texture.getHtmlElementObj();
  22089. g._colorized ? e.drawImage(f, 0, 0, h.width, h.height, k * c, p * d, t * c, m * d) : e.drawImage(f, h.renderX, h.renderY, h.width, h.height, k * c, p * d, t * c, m * d);
  22090. a.restore();
  22091. cc.g_NumberOfDraws++
  22092. }
  22093. };
  22094. a.releaseData = function() {};
  22095. a.initCmd = function() {};
  22096. a._updateProgress = function() {
  22097. var a = this._node,
  22098. c = a._sprite,
  22099. d = c.width,
  22100. e = c.height,
  22101. f = a._midPoint;
  22102. if (a._type === cc.ProgressTimer.TYPE_RADIAL) {
  22103. this._radius = Math.round(Math.sqrt(d * d + e * e));
  22104. var g, h = !1,
  22105. k = this._origin;
  22106. k.x = d * f.x;
  22107. k.y = -e * f.y;
  22108. a._reverseDirection ? (g = 270, f = 270 - 3.6 * a._percentage) : (f = -90, g = -90 + 3.6 * a._percentage);
  22109. c._flippedX && (k.x -= 2 * d * a._midPoint.x, f = -f - 180, g = -g - 180, h = !h);
  22110. c._flippedY && (k.y += 2 * e * a._midPoint.y, h = !h, f = -f, g = -g);
  22111. this._startAngle = f;
  22112. this._endAngle = g;
  22113. this._counterClockWise = h
  22114. } else h = a._barChangeRate,
  22115. k = a._percentage / 100, a = this._barRect, h = cc.size(d * (1 - h.x), e * (1 - h.y)), k = cc.size((d - h.width) * k, (e - h.height) * k), h = cc.size(h.width + k.width, h.height + k.height), g = cc.p(d * f.x, e * f.y), k = g.x - h.width / 2, 0.5 < f.x && h.width / 2 >= d - g.x && (k = d - h.width), d = g.y - h.height / 2, 0.5 < f.y && h.height / 2 >= e - g.y && (d = e - h.height), a.x = 0, e = 1, c._flippedX && (a.x -= h.width, e = -1), 0 < k && (a.x += k * e), a.y = 0, e = 1, c._flippedY && (a.y += h.height, e = -1), 0 < d && (a.y -= d * e), a.width = h.width, a.height = -h.height
  22116. };
  22117. a._updateColor = function() {};
  22118. a._syncStatus = function(a) {
  22119. var c =
  22120. this._node;
  22121. if (c._sprite) {
  22122. var d = cc.Node._dirtyFlags,
  22123. e = this._dirtyFlag,
  22124. f = a ? a._node : null;
  22125. f && f._cascadeColorEnabled && a._dirtyFlag & d.colorDirty && (e |= d.colorDirty);
  22126. f && f._cascadeOpacityEnabled && a._dirtyFlag & d.opacityDirty && (e |= d.opacityDirty);
  22127. a && a._dirtyFlag & d.transformDirty && (e |= d.transformDirty);
  22128. this._dirtyFlag = e;
  22129. var c = c._sprite._renderCmd,
  22130. f = c._dirtyFlag,
  22131. g = f & d.opacityDirty;
  22132. f & d.colorDirty && c._syncDisplayColor();
  22133. g && c._syncDisplayOpacity();
  22134. e & d.transformDirty && this.transform(a)
  22135. }
  22136. };
  22137. a.updateStatus = function() {
  22138. var a =
  22139. this._node;
  22140. if (a._sprite) {
  22141. var c = cc.Node._dirtyFlags,
  22142. d = this._dirtyFlag,
  22143. a = a._sprite._renderCmd,
  22144. e = a._dirtyFlag,
  22145. f = e & c.opacityDirty;
  22146. e & c.colorDirty && a._updateDisplayColor();
  22147. f && a._updateDisplayOpacity();
  22148. d & c.transformDirty && this.transform(this.getParentRenderCmd(), !0);
  22149. this._dirtyFlag = 0
  22150. }
  22151. }
  22152. })();
  22153. (function() {
  22154. cc.ProgressTimer.WebGLRenderCmd = function(a) {
  22155. cc.Node.WebGLRenderCmd.call(this, a);
  22156. this._needDraw = !0;
  22157. this._vertexWebGLBuffer = cc._renderContext.createBuffer();
  22158. this._vertexDataCount = 0;
  22159. this._vertexArrayBuffer = this._vertexData = null;
  22160. this._vertexDataDirty = !1
  22161. };
  22162. var a = cc.ProgressTimer.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  22163. a.constructor = cc.ProgressTimer.WebGLRenderCmd;
  22164. a.rendering = function(a) {
  22165. var c = this._node;
  22166. a = a || cc._renderContext;
  22167. if (this._vertexData && c._sprite) {
  22168. this._shaderProgram.use();
  22169. this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
  22170. var d = c._sprite._blendFunc;
  22171. cc.glBlendFunc(d.src, d.dst);
  22172. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  22173. cc.glBindTexture2D(c._sprite.texture);
  22174. a.bindBuffer(a.ARRAY_BUFFER, this._vertexWebGLBuffer);
  22175. this._vertexDataDirty && (a.bufferData(a.ARRAY_BUFFER, this._vertexArrayBuffer, a.DYNAMIC_DRAW), this._vertexDataDirty = !1);
  22176. d = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  22177. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, d, 0);
  22178. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,
  22179. 4, a.UNSIGNED_BYTE, !0, d, 8);
  22180. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, d, 12);
  22181. c._type === cc.ProgressTimer.TYPE_RADIAL ? a.drawArrays(a.TRIANGLE_FAN, 0, this._vertexDataCount) : c._type === cc.ProgressTimer.TYPE_BAR && (c._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));
  22182. cc.g_NumberOfDraws++
  22183. }
  22184. };
  22185. a._syncStatus = function(a) {
  22186. var c = this._node;
  22187. if (c._sprite) {
  22188. var d = cc.Node._dirtyFlags,
  22189. e = this._dirtyFlag,
  22190. f = a ? a._node : null;
  22191. f && f._cascadeColorEnabled && a._dirtyFlag & d.colorDirty && (e |= d.colorDirty);
  22192. f && f._cascadeOpacityEnabled && a._dirtyFlag & d.opacityDirty && (e |= d.opacityDirty);
  22193. a && a._dirtyFlag & d.transformDirty && (e |= d.transformDirty);
  22194. this._dirtyFlag = e;
  22195. c = c._sprite._renderCmd;
  22196. f = c._dirtyFlag;
  22197. e = f & d.colorDirty;
  22198. d = f & d.opacityDirty;
  22199. e && c._syncDisplayColor();
  22200. d && c._syncDisplayOpacity();
  22201. if (e || d) c._updateColor(), this._updateColor();
  22202. this.transform(a);
  22203. c._dirtyFlag =
  22204. 0
  22205. }
  22206. };
  22207. a.updateStatus = function() {
  22208. var a = this._node;
  22209. if (a._sprite) {
  22210. var c = cc.Node._dirtyFlags,
  22211. d = this._dirtyFlag,
  22212. a = a._sprite._renderCmd,
  22213. e = a._dirtyFlag,
  22214. f = e & c.colorDirty,
  22215. e = e & c.opacityDirty;
  22216. f && (a._updateDisplayColor(), this._dirtyFlag ^= this._dirtyFlag & c.colorDirty);
  22217. e && (a._updateDisplayOpacity(), this._dirtyFlag ^= this._dirtyFlag & c.opacityDirty);
  22218. if (f || e) a._updateColor(), this._updateColor();
  22219. d & c.transformDirty && this.transform(this.getParentRenderCmd(), !0)
  22220. }
  22221. };
  22222. a.releaseData = function() {
  22223. this._vertexData && (this._vertexArrayBuffer =
  22224. this._vertexData = null, this._vertexDataCount = 0)
  22225. };
  22226. a.initCmd = function() {
  22227. this._vertexArrayBuffer = this._vertexData = null;
  22228. this._vertexDataCount = 0;
  22229. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  22230. };
  22231. a._updateProgress = function() {
  22232. var a = this._node._type;
  22233. a === cc.ProgressTimer.TYPE_RADIAL ? this._updateRadial() : a === cc.ProgressTimer.TYPE_BAR && this._updateBar();
  22234. this._vertexDataDirty = !0
  22235. };
  22236. a._updateBar = function() {
  22237. var a = this._node;
  22238. if (a._sprite) {
  22239. var c, d = a._percentage / 100;
  22240. c = a._barChangeRate;
  22241. c = cc.pMult(cc.p(1 - c.x + d * c.x, 1 - c.y + d * c.y), 0.5);
  22242. d = cc.pSub(a._midPoint, c);
  22243. a = cc.pAdd(a._midPoint, c);
  22244. 0 > d.x && (a.x += -d.x, d.x = 0);
  22245. 1 < a.x && (d.x -= a.x - 1, a.x = 1);
  22246. 0 > d.y && (a.y += -d.y, d.y = 0);
  22247. 1 < a.y && (d.y -= a.y - 1, a.y = 1);
  22248. if (this._reverseDirection) {
  22249. if (!this._vertexData) {
  22250. this._vertexDataCount = 8;
  22251. var e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  22252. this._vertexArrayBuffer = new ArrayBuffer(8 * e);
  22253. var f = [];
  22254. for (c = 0; 8 > c; c++) f[c] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, c * e);
  22255. f[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0,
  22256. 1));
  22257. f[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1));
  22258. f[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0));
  22259. f[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0));
  22260. f[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1));
  22261. f[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1));
  22262. f[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0));
  22263. f[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0));
  22264. this._vertexData = f
  22265. }
  22266. c = this._vertexData;
  22267. c[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, a.y));
  22268. c[2].vertices =
  22269. this._vertexFromAlphaPoint(cc.p(d.x, a.y));
  22270. c[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
  22271. c[3].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
  22272. c[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, a.y));
  22273. c[4].vertices = this._vertexFromAlphaPoint(cc.p(a.x, a.y));
  22274. c[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, d.y));
  22275. c[5].vertices = this._vertexFromAlphaPoint(cc.p(a.x, d.y))
  22276. } else {
  22277. if (!this._vertexData)
  22278. for (this._vertexDataCount = 4, e = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, this._vertexArrayBuffer =
  22279. new ArrayBuffer(4 * e), this._vertexData = [], c = 0; 4 > c; c++) this._vertexData[c] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, c * e);
  22280. c = this._vertexData;
  22281. c[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, a.y));
  22282. c[0].vertices = this._vertexFromAlphaPoint(cc.p(d.x, a.y));
  22283. c[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(d.x, d.y));
  22284. c[1].vertices = this._vertexFromAlphaPoint(cc.p(d.x, d.y));
  22285. c[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, a.y));
  22286. c[2].vertices = this._vertexFromAlphaPoint(cc.p(a.x,
  22287. a.y));
  22288. c[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(a.x, d.y));
  22289. c[3].vertices = this._vertexFromAlphaPoint(cc.p(a.x, d.y))
  22290. }
  22291. this._updateColor()
  22292. }
  22293. };
  22294. a._updateRadial = function() {
  22295. var a = this._node;
  22296. if (a._sprite) {
  22297. var c, d = a._midPoint;
  22298. c = a._percentage / 100;
  22299. var e = 2 * cc.PI * (a._reverseDirection ? c : 1 - c),
  22300. a = cc.p(d.x, 1),
  22301. f = cc.pRotateByAngle(a, d, e),
  22302. e = 0;
  22303. if (0 === c) f = a, e = 0;
  22304. else if (1 === c) f = a, e = 4;
  22305. else {
  22306. var g = cc.FLT_MAX,
  22307. h = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
  22308. for (c = 0; c <= h; ++c) {
  22309. var k = (c + (h - 1)) % h,
  22310. m = this._boundaryTexCoord(c % h),
  22311. k =
  22312. this._boundaryTexCoord(k);
  22313. 0 === c ? k = cc.pLerp(m, k, 1 - d.x) : 4 === c && (m = cc.pLerp(m, k, 1 - d.x));
  22314. var n = cc.p(0, 0);
  22315. cc.pLineIntersect(m, k, d, f, n) && (0 !== c && 4 !== c || 0 <= n.x && 1 >= n.x) && 0 <= n.y && n.y < g && (g = n.y, e = c)
  22316. }
  22317. f = cc.pAdd(d, cc.pMult(cc.pSub(f, d), g))
  22318. }
  22319. g = !0;
  22320. this._vertexDataCount !== e + 3 && (g = !1, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0);
  22321. if (!this._vertexData) {
  22322. h = this._vertexDataCount = e + 3;
  22323. m = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  22324. this._vertexArrayBuffer = new ArrayBuffer(h * m);
  22325. k = [];
  22326. for (c = 0; c < h; c++) k[c] = new cc.V2F_C4B_T2F(null,
  22327. null, null, this._vertexArrayBuffer, c * m);
  22328. this._vertexData = k;
  22329. if (!this._vertexData) {
  22330. cc.log("cc.ProgressTimer._updateRadial() : Not enough memory");
  22331. return
  22332. }
  22333. }
  22334. this._updateColor();
  22335. h = this._vertexData;
  22336. if (!g)
  22337. for (h[0].texCoords = this._textureCoordFromAlphaPoint(d), h[0].vertices = this._vertexFromAlphaPoint(d), h[1].texCoords = this._textureCoordFromAlphaPoint(a), h[1].vertices = this._vertexFromAlphaPoint(a), c = 0; c < e; c++) d = this._boundaryTexCoord(c), h[c + 2].texCoords = this._textureCoordFromAlphaPoint(d), h[c + 2].vertices = this._vertexFromAlphaPoint(d);
  22338. h[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(f);
  22339. h[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(f)
  22340. }
  22341. };
  22342. a._boundaryTexCoord = function(a) {
  22343. if (a < cc.ProgressTimer.TEXTURE_COORDS_COUNT) {
  22344. var c = cc.ProgressTimer.TEXTURE_COORDS;
  22345. return this._node._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)
  22346. }
  22347. return cc.p(0, 0)
  22348. };
  22349. a._textureCoordFromAlphaPoint = function(a) {
  22350. var c = this._node._sprite;
  22351. if (!c) return {
  22352. u: 0,
  22353. v: 0
  22354. };
  22355. var d = c.quad,
  22356. e = cc.p(d.bl.texCoords.u,
  22357. d.bl.texCoords.v),
  22358. d = cc.p(d.tr.texCoords.u, d.tr.texCoords.v);
  22359. c.textureRectRotated && (c = a.x, a.x = a.y, a.y = c);
  22360. return {
  22361. u: e.x * (1 - a.x) + d.x * a.x,
  22362. v: e.y * (1 - a.y) + d.y * a.y
  22363. }
  22364. };
  22365. a._vertexFromAlphaPoint = function(a) {
  22366. var c = this._node._sprite;
  22367. if (!c) return {
  22368. x: 0,
  22369. y: 0
  22370. };
  22371. var d = c.quad,
  22372. c = cc.p(d.bl.vertices.x, d.bl.vertices.y),
  22373. d = cc.p(d.tr.vertices.x, d.tr.vertices.y);
  22374. return {
  22375. x: c.x * (1 - a.x) + d.x * a.x,
  22376. y: c.y * (1 - a.y) + d.y * a.y
  22377. }
  22378. };
  22379. a._updateColor = function() {
  22380. var a = this._node;
  22381. if (a._sprite && this._vertexData) {
  22382. for (var a = a._sprite.quad.tl.colors, c = this._vertexData,
  22383. d = 0, e = this._vertexDataCount; d < e; ++d) c[d].colors = a;
  22384. this._vertexDataDirty = !0
  22385. }
  22386. }
  22387. })();
  22388. cc.SCENE_FADE = 4208917214;
  22389. cc.TRANSITION_ORIENTATION_LEFT_OVER = 0;
  22390. cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1;
  22391. cc.TRANSITION_ORIENTATION_UP_OVER = 0;
  22392. cc.TRANSITION_ORIENTATION_DOWN_OVER = 1;
  22393. cc.TransitionScene = cc.Scene.extend({
  22394. _inScene: null,
  22395. _outScene: null,
  22396. _duration: null,
  22397. _isInSceneOnTop: !1,
  22398. _isSendCleanupToScene: !1,
  22399. _className: "TransitionScene",
  22400. ctor: function(a, b) {
  22401. cc.Scene.prototype.ctor.call(this);
  22402. void 0 !== a && void 0 !== b && this.initWithDuration(a, b)
  22403. },
  22404. _setNewScene: function(a) {
  22405. this.unschedule(this._setNewScene);
  22406. a = cc.director;
  22407. this._isSendCleanupToScene = a.isSendCleanupToScene();
  22408. a.runScene(this._inScene);
  22409. cc.eventManager.setEnabled(!0);
  22410. this._outScene.visible = !0
  22411. },
  22412. _sceneOrder: function() {
  22413. this._isInSceneOnTop = !0
  22414. },
  22415. visit: function() {
  22416. this._isInSceneOnTop ? (this._outScene.visit(), this._inScene.visit()) : (this._inScene.visit(), this._outScene.visit());
  22417. cc.Node.prototype.visit.call(this)
  22418. },
  22419. onEnter: function() {
  22420. cc.Node.prototype.onEnter.call(this);
  22421. cc.eventManager.setEnabled(!1);
  22422. this._outScene.onExitTransitionDidStart();
  22423. this._inScene.onEnter()
  22424. },
  22425. onExit: function() {
  22426. cc.Node.prototype.onExit.call(this);
  22427. cc.eventManager.setEnabled(!0);
  22428. this._outScene.onExit();
  22429. this._inScene.onEnterTransitionDidFinish()
  22430. },
  22431. cleanup: function() {
  22432. cc.Node.prototype.cleanup.call(this);
  22433. this._isSendCleanupToScene && this._outScene.cleanup()
  22434. },
  22435. initWithDuration: function(a, b) {
  22436. if (!b) throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";
  22437. if (this.init()) {
  22438. this._duration = a;
  22439. this.attr({
  22440. x: 0,
  22441. y: 0,
  22442. anchorX: 0,
  22443. anchorY: 0
  22444. });
  22445. this._inScene = b;
  22446. this._outScene = cc.director.getRunningScene();
  22447. this._outScene || (this._outScene = new cc.Scene, this._outScene.init());
  22448. if (this._inScene === this._outScene) throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
  22449. this._sceneOrder();
  22450. return !0
  22451. }
  22452. return !1
  22453. },
  22454. finish: function() {
  22455. this._inScene.attr({
  22456. visible: !0,
  22457. x: 0,
  22458. y: 0,
  22459. scale: 1,
  22460. rotation: 0
  22461. });
  22462. cc._renderType === cc._RENDER_TYPE_WEBGL && this._inScene.getCamera().restore();
  22463. this._outScene.attr({
  22464. visible: !1,
  22465. x: 0,
  22466. y: 0,
  22467. scale: 1,
  22468. rotation: 0
  22469. });
  22470. cc._renderType === cc._RENDER_TYPE_WEBGL && this._outScene.getCamera().restore();
  22471. this.schedule(this._setNewScene, 0)
  22472. },
  22473. hideOutShowIn: function() {
  22474. this._inScene.visible = !0;
  22475. this._outScene.visible = !1
  22476. }
  22477. });
  22478. cc.TransitionScene.create = function(a, b) {
  22479. return new cc.TransitionScene(a, b)
  22480. };
  22481. cc.TransitionSceneOriented = cc.TransitionScene.extend({
  22482. _orientation: 0,
  22483. ctor: function(a, b, c) {
  22484. cc.TransitionScene.prototype.ctor.call(this);
  22485. void 0 != c && this.initWithDuration(a, b, c)
  22486. },
  22487. initWithDuration: function(a, b, c) {
  22488. cc.TransitionScene.prototype.initWithDuration.call(this, a, b) && (this._orientation = c);
  22489. return !0
  22490. }
  22491. });
  22492. cc.TransitionSceneOriented.create = function(a, b, c) {
  22493. return new cc.TransitionSceneOriented(a, b, c)
  22494. };
  22495. cc.TransitionRotoZoom = cc.TransitionScene.extend({
  22496. ctor: function(a, b) {
  22497. cc.TransitionScene.prototype.ctor.call(this);
  22498. b && this.initWithDuration(a, b)
  22499. },
  22500. onEnter: function() {
  22501. cc.TransitionScene.prototype.onEnter.call(this);
  22502. this._inScene.attr({
  22503. scale: 0.001,
  22504. anchorX: 0.5,
  22505. anchorY: 0.5
  22506. });
  22507. this._outScene.attr({
  22508. scale: 1,
  22509. anchorX: 0.5,
  22510. anchorY: 0.5
  22511. });
  22512. var a = cc.sequence(cc.spawn(cc.scaleBy(this._duration / 2, 0.001), cc.rotateBy(this._duration / 2, 720)), cc.delayTime(this._duration / 2));
  22513. this._outScene.runAction(a);
  22514. this._inScene.runAction(cc.sequence(a.reverse(),
  22515. cc.callFunc(this.finish, this)))
  22516. }
  22517. });
  22518. cc.TransitionRotoZoom.create = function(a, b) {
  22519. return new cc.TransitionRotoZoom(a, b)
  22520. };
  22521. cc.TransitionJumpZoom = cc.TransitionScene.extend({
  22522. ctor: function(a, b) {
  22523. cc.TransitionScene.prototype.ctor.call(this);
  22524. b && this.initWithDuration(a, b)
  22525. },
  22526. onEnter: function() {
  22527. cc.TransitionScene.prototype.onEnter.call(this);
  22528. var a = cc.director.getWinSize();
  22529. this._inScene.attr({
  22530. scale: 0.5,
  22531. x: a.width,
  22532. y: 0,
  22533. anchorX: 0.5,
  22534. anchorY: 0.5
  22535. });
  22536. this._outScene.anchorX = 0.5;
  22537. this._outScene.anchorY = 0.5;
  22538. var b = cc.jumpBy(this._duration / 4, cc.p(-a.width, 0), a.width / 4, 2),
  22539. c = cc.scaleTo(this._duration / 4, 1),
  22540. a = cc.scaleTo(this._duration / 4, 0.5),
  22541. a = cc.sequence(a,
  22542. b),
  22543. b = cc.sequence(b, c),
  22544. c = cc.delayTime(this._duration / 2);
  22545. this._outScene.runAction(a);
  22546. this._inScene.runAction(cc.sequence(c, b, cc.callFunc(this.finish, this)))
  22547. }
  22548. });
  22549. cc.TransitionJumpZoom.create = function(a, b) {
  22550. return new cc.TransitionJumpZoom(a, b)
  22551. };
  22552. cc.TransitionMoveInL = cc.TransitionScene.extend({
  22553. ctor: function(a, b) {
  22554. cc.TransitionScene.prototype.ctor.call(this);
  22555. b && this.initWithDuration(a, b)
  22556. },
  22557. onEnter: function() {
  22558. cc.TransitionScene.prototype.onEnter.call(this);
  22559. this.initScenes();
  22560. var a = this.action();
  22561. this._inScene.runAction(cc.sequence(this.easeActionWithAction(a), cc.callFunc(this.finish, this)))
  22562. },
  22563. initScenes: function() {
  22564. this._inScene.setPosition(-cc.director.getWinSize().width, 0)
  22565. },
  22566. action: function() {
  22567. return cc.moveTo(this._duration, cc.p(0, 0))
  22568. },
  22569. easeActionWithAction: function(a) {
  22570. return new cc.EaseOut(a,
  22571. 2)
  22572. }
  22573. });
  22574. cc.TransitionMoveInL.create = function(a, b) {
  22575. return new cc.TransitionMoveInL(a, b)
  22576. };
  22577. cc.TransitionMoveInR = cc.TransitionMoveInL.extend({
  22578. ctor: function(a, b) {
  22579. cc.TransitionMoveInL.prototype.ctor.call(this);
  22580. b && this.initWithDuration(a, b)
  22581. },
  22582. initScenes: function() {
  22583. this._inScene.setPosition(cc.director.getWinSize().width, 0)
  22584. }
  22585. });
  22586. cc.TransitionMoveInR.create = function(a, b) {
  22587. return new cc.TransitionMoveInR(a, b)
  22588. };
  22589. cc.TransitionMoveInT = cc.TransitionMoveInL.extend({
  22590. ctor: function(a, b) {
  22591. cc.TransitionMoveInL.prototype.ctor.call(this);
  22592. b && this.initWithDuration(a, b)
  22593. },
  22594. initScenes: function() {
  22595. this._inScene.setPosition(0, cc.director.getWinSize().height)
  22596. }
  22597. });
  22598. cc.TransitionMoveInT.create = function(a, b) {
  22599. return new cc.TransitionMoveInT(a, b)
  22600. };
  22601. cc.TransitionMoveInB = cc.TransitionMoveInL.extend({
  22602. ctor: function(a, b) {
  22603. cc.TransitionMoveInL.prototype.ctor.call(this);
  22604. b && this.initWithDuration(a, b)
  22605. },
  22606. initScenes: function() {
  22607. this._inScene.setPosition(0, -cc.director.getWinSize().height)
  22608. }
  22609. });
  22610. cc.TransitionMoveInB.create = function(a, b) {
  22611. return new cc.TransitionMoveInB(a, b)
  22612. };
  22613. cc.ADJUST_FACTOR = 0.5;
  22614. cc.TransitionSlideInL = cc.TransitionScene.extend({
  22615. ctor: function(a, b) {
  22616. cc.TransitionScene.prototype.ctor.call(this);
  22617. b && this.initWithDuration(a, b)
  22618. },
  22619. _sceneOrder: function() {
  22620. this._isInSceneOnTop = !1
  22621. },
  22622. onEnter: function() {
  22623. cc.TransitionScene.prototype.onEnter.call(this);
  22624. this.initScenes();
  22625. var a = this.action(),
  22626. b = this.action(),
  22627. a = this.easeActionWithAction(a),
  22628. b = cc.sequence(this.easeActionWithAction(b), cc.callFunc(this.finish, this));
  22629. this._inScene.runAction(a);
  22630. this._outScene.runAction(b)
  22631. },
  22632. initScenes: function() {
  22633. this._inScene.setPosition(-cc.director.getWinSize().width +
  22634. cc.ADJUST_FACTOR, 0)
  22635. },
  22636. action: function() {
  22637. return cc.moveBy(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0))
  22638. },
  22639. easeActionWithAction: function(a) {
  22640. return new cc.EaseInOut(a, 2)
  22641. }
  22642. });
  22643. cc.TransitionSlideInL.create = function(a, b) {
  22644. return new cc.TransitionSlideInL(a, b)
  22645. };
  22646. cc.TransitionSlideInR = cc.TransitionSlideInL.extend({
  22647. ctor: function(a, b) {
  22648. cc.TransitionSlideInL.prototype.ctor.call(this);
  22649. b && this.initWithDuration(a, b)
  22650. },
  22651. _sceneOrder: function() {
  22652. this._isInSceneOnTop = !0
  22653. },
  22654. initScenes: function() {
  22655. this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)
  22656. },
  22657. action: function() {
  22658. return cc.moveBy(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0))
  22659. }
  22660. });
  22661. cc.TransitionSlideInR.create = function(a, b) {
  22662. return new cc.TransitionSlideInR(a, b)
  22663. };
  22664. cc.TransitionSlideInB = cc.TransitionSlideInL.extend({
  22665. ctor: function(a, b) {
  22666. cc.TransitionSlideInL.prototype.ctor.call(this);
  22667. b && this.initWithDuration(a, b)
  22668. },
  22669. _sceneOrder: function() {
  22670. this._isInSceneOnTop = !1
  22671. },
  22672. initScenes: function() {
  22673. this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))
  22674. },
  22675. action: function() {
  22676. return cc.moveBy(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR))
  22677. }
  22678. });
  22679. cc.TransitionSlideInB.create = function(a, b) {
  22680. return new cc.TransitionSlideInB(a, b)
  22681. };
  22682. cc.TransitionSlideInT = cc.TransitionSlideInL.extend({
  22683. ctor: function(a, b) {
  22684. cc.TransitionSlideInL.prototype.ctor.call(this);
  22685. b && this.initWithDuration(a, b)
  22686. },
  22687. _sceneOrder: function() {
  22688. this._isInSceneOnTop = !0
  22689. },
  22690. initScenes: function() {
  22691. this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)
  22692. },
  22693. action: function() {
  22694. return cc.moveBy(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)))
  22695. }
  22696. });
  22697. cc.TransitionSlideInT.create = function(a, b) {
  22698. return new cc.TransitionSlideInT(a, b)
  22699. };
  22700. cc.TransitionShrinkGrow = cc.TransitionScene.extend({
  22701. ctor: function(a, b) {
  22702. cc.TransitionScene.prototype.ctor.call(this);
  22703. b && this.initWithDuration(a, b)
  22704. },
  22705. onEnter: function() {
  22706. cc.TransitionScene.prototype.onEnter.call(this);
  22707. this._inScene.attr({
  22708. scale: 0.001,
  22709. anchorX: 2 / 3,
  22710. anchorY: 0.5
  22711. });
  22712. this._outScene.attr({
  22713. scale: 1,
  22714. anchorX: 1 / 3,
  22715. anchorY: 0.5
  22716. });
  22717. var a = cc.scaleTo(this._duration, 0.01),
  22718. b = cc.scaleTo(this._duration, 1);
  22719. this._inScene.runAction(this.easeActionWithAction(b));
  22720. this._outScene.runAction(cc.sequence(this.easeActionWithAction(a),
  22721. cc.callFunc(this.finish, this)))
  22722. },
  22723. easeActionWithAction: function(a) {
  22724. return new cc.EaseOut(a, 2)
  22725. }
  22726. });
  22727. cc.TransitionShrinkGrow.create = function(a, b) {
  22728. return new cc.TransitionShrinkGrow(a, b)
  22729. };
  22730. cc.TransitionFlipX = cc.TransitionSceneOriented.extend({
  22731. ctor: function(a, b, c) {
  22732. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22733. null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER);
  22734. b && this.initWithDuration(a, b, c)
  22735. },
  22736. onEnter: function() {
  22737. cc.TransitionScene.prototype.onEnter.call(this);
  22738. var a, b;
  22739. this._inScene.visible = !1;
  22740. var c;
  22741. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22742. a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration / 2, 1, 0,
  22743. c, a, 0, 0), cc.callFunc(this.finish, this));
  22744. b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 0, 0), cc.hide(), cc.delayTime(this._duration / 2));
  22745. this._inScene.runAction(a);
  22746. this._outScene.runAction(b)
  22747. }
  22748. });
  22749. cc.TransitionFlipX.create = function(a, b, c) {
  22750. return new cc.TransitionFlipX(a, b, c)
  22751. };
  22752. cc.TransitionFlipY = cc.TransitionSceneOriented.extend({
  22753. ctor: function(a, b, c) {
  22754. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22755. null == c && (c = cc.TRANSITION_ORIENTATION_UP_OVER);
  22756. b && this.initWithDuration(a, b, c)
  22757. },
  22758. onEnter: function() {
  22759. cc.TransitionScene.prototype.onEnter.call(this);
  22760. var a, b;
  22761. this._inScene.visible = !1;
  22762. var c;
  22763. this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22764. a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration / 2, 1, 0, c, a, 90,
  22765. 0), cc.callFunc(this.finish, this));
  22766. b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 90, 0), cc.hide(), cc.delayTime(this._duration / 2));
  22767. this._inScene.runAction(a);
  22768. this._outScene.runAction(b)
  22769. }
  22770. });
  22771. cc.TransitionFlipY.create = function(a, b, c) {
  22772. return new cc.TransitionFlipY(a, b, c)
  22773. };
  22774. cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend({
  22775. ctor: function(a, b, c) {
  22776. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22777. null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER);
  22778. b && this.initWithDuration(a, b, c)
  22779. },
  22780. onEnter: function() {
  22781. cc.TransitionScene.prototype.onEnter.call(this);
  22782. var a, b;
  22783. this._inScene.visible = !1;
  22784. var c;
  22785. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22786. a = cc.sequence(cc.delayTime(this._duration / 2), cc.show(), cc.orbitCamera(this._duration /
  22787. 2, 1, 0, c, a, -45, 0), cc.callFunc(this.finish, this));
  22788. b = cc.sequence(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 45, 0), cc.hide(), cc.delayTime(this._duration / 2));
  22789. this._inScene.runAction(a);
  22790. this._outScene.runAction(b)
  22791. }
  22792. });
  22793. cc.TransitionFlipAngular.create = function(a, b, c) {
  22794. return new cc.TransitionFlipAngular(a, b, c)
  22795. };
  22796. cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend({
  22797. ctor: function(a, b, c) {
  22798. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22799. null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER);
  22800. b && this.initWithDuration(a, b, c)
  22801. },
  22802. onEnter: function() {
  22803. cc.TransitionScene.prototype.onEnter.call(this);
  22804. var a, b;
  22805. this._inScene.visible = !1;
  22806. var c;
  22807. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22808. a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration / 2,
  22809. 1, 0, c, a, 0, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.callFunc(this.finish, this));
  22810. b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 0, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2));
  22811. this._inScene.scale = 0.5;
  22812. this._inScene.runAction(a);
  22813. this._outScene.runAction(b)
  22814. }
  22815. });
  22816. cc.TransitionZoomFlipX.create = function(a, b, c) {
  22817. return new cc.TransitionZoomFlipX(a, b, c)
  22818. };
  22819. cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend({
  22820. ctor: function(a, b, c) {
  22821. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22822. null == c && (c = cc.TRANSITION_ORIENTATION_UP_OVER);
  22823. b && this.initWithDuration(a, b, c)
  22824. },
  22825. onEnter: function() {
  22826. cc.TransitionScene.prototype.onEnter.call(this);
  22827. var a, b;
  22828. this._inScene.visible = !1;
  22829. var c;
  22830. this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22831. a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, c,
  22832. a, 90, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.callFunc(this.finish, this));
  22833. b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 90, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2));
  22834. this._inScene.scale = 0.5;
  22835. this._inScene.runAction(a);
  22836. this._outScene.runAction(b)
  22837. }
  22838. });
  22839. cc.TransitionZoomFlipY.create = function(a, b, c) {
  22840. return new cc.TransitionZoomFlipY(a, b, c)
  22841. };
  22842. cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend({
  22843. ctor: function(a, b, c) {
  22844. cc.TransitionSceneOriented.prototype.ctor.call(this);
  22845. null == c && (c = cc.TRANSITION_ORIENTATION_RIGHT_OVER);
  22846. b && this.initWithDuration(a, b, c)
  22847. },
  22848. onEnter: function() {
  22849. cc.TransitionScene.prototype.onEnter.call(this);
  22850. var a, b;
  22851. this._inScene.visible = !1;
  22852. var c;
  22853. this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER ? (a = 90, c = 270, b = 90) : (a = -90, c = 90, b = -90);
  22854. a = cc.sequence(cc.delayTime(this._duration / 2), cc.spawn(cc.orbitCamera(this._duration /
  22855. 2, 1, 0, c, a, -45, 0), cc.scaleTo(this._duration / 2, 1), cc.show()), cc.show(), cc.callFunc(this.finish, this));
  22856. b = cc.sequence(cc.spawn(cc.orbitCamera(this._duration / 2, 1, 0, 0, b, 45, 0), cc.scaleTo(this._duration / 2, 0.5)), cc.hide(), cc.delayTime(this._duration / 2));
  22857. this._inScene.scale = 0.5;
  22858. this._inScene.runAction(a);
  22859. this._outScene.runAction(b)
  22860. }
  22861. });
  22862. cc.TransitionZoomFlipAngular.create = function(a, b, c) {
  22863. return new cc.TransitionZoomFlipAngular(a, b, c)
  22864. };
  22865. cc.TransitionFade = cc.TransitionScene.extend({
  22866. _color: null,
  22867. ctor: function(a, b, c) {
  22868. cc.TransitionScene.prototype.ctor.call(this);
  22869. this._color = cc.color();
  22870. b && this.initWithDuration(a, b, c)
  22871. },
  22872. onEnter: function() {
  22873. cc.TransitionScene.prototype.onEnter.call(this);
  22874. var a = new cc.LayerColor(this._color);
  22875. this._inScene.visible = !1;
  22876. this.addChild(a, 2, cc.SCENE_FADE);
  22877. var a = this.getChildByTag(cc.SCENE_FADE),
  22878. b = cc.sequence(cc.fadeIn(this._duration / 2), cc.callFunc(this.hideOutShowIn, this), cc.fadeOut(this._duration / 2), cc.callFunc(this.finish,
  22879. this));
  22880. a.runAction(b)
  22881. },
  22882. onExit: function() {
  22883. cc.TransitionScene.prototype.onExit.call(this);
  22884. this.removeChildByTag(cc.SCENE_FADE, !1)
  22885. },
  22886. initWithDuration: function(a, b, c) {
  22887. c = c || cc.color.BLACK;
  22888. cc.TransitionScene.prototype.initWithDuration.call(this, a, b) && (this._color.r = c.r, this._color.g = c.g, this._color.b = c.b, this._color.a = 0);
  22889. return !0
  22890. }
  22891. });
  22892. cc.TransitionFade.create = function(a, b, c) {
  22893. return new cc.TransitionFade(a, b, c)
  22894. };
  22895. cc.TransitionCrossFade = cc.TransitionScene.extend({
  22896. ctor: function(a, b) {
  22897. cc.TransitionScene.prototype.ctor.call(this);
  22898. b && this.initWithDuration(a, b)
  22899. },
  22900. onEnter: function() {
  22901. cc.TransitionScene.prototype.onEnter.call(this);
  22902. var a = cc.color(0, 0, 0, 0),
  22903. b = cc.director.getWinSize(),
  22904. a = new cc.LayerColor(a),
  22905. c = new cc.RenderTexture(b.width, b.height);
  22906. c.sprite.anchorX = 0.5;
  22907. c.sprite.anchorY = 0.5;
  22908. c.attr({
  22909. x: b.width / 2,
  22910. y: b.height / 2,
  22911. anchorX: 0.5,
  22912. anchorY: 0.5
  22913. });
  22914. c.begin();
  22915. this._inScene.visit();
  22916. c.end();
  22917. var d = new cc.RenderTexture(b.width,
  22918. b.height);
  22919. d.setPosition(b.width / 2, b.height / 2);
  22920. d.sprite.anchorX = d.anchorX = 0.5;
  22921. d.sprite.anchorY = d.anchorY = 0.5;
  22922. d.begin();
  22923. this._outScene.visit();
  22924. d.end();
  22925. c.sprite.setBlendFunc(cc.ONE, cc.ONE);
  22926. d.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
  22927. a.addChild(c);
  22928. a.addChild(d);
  22929. c.sprite.opacity = 255;
  22930. d.sprite.opacity = 255;
  22931. b = cc.sequence(cc.fadeTo(this._duration, 0), cc.callFunc(this.hideOutShowIn, this), cc.callFunc(this.finish, this));
  22932. d.sprite.runAction(b);
  22933. this.addChild(a, 2, cc.SCENE_FADE)
  22934. },
  22935. onExit: function() {
  22936. this.removeChildByTag(cc.SCENE_FADE, !1);
  22937. cc.TransitionScene.prototype.onExit.call(this)
  22938. },
  22939. visit: function() {
  22940. cc.Node.prototype.visit.call(this)
  22941. },
  22942. draw: function() {}
  22943. });
  22944. cc.TransitionCrossFade.create = function(a, b) {
  22945. return new cc.TransitionCrossFade(a, b)
  22946. };
  22947. cc.TransitionTurnOffTiles = cc.TransitionScene.extend({
  22948. _gridProxy: null,
  22949. ctor: function(a, b) {
  22950. cc.TransitionScene.prototype.ctor.call(this);
  22951. this._gridProxy = new cc.NodeGrid;
  22952. b && this.initWithDuration(a, b)
  22953. },
  22954. _sceneOrder: function() {
  22955. this._isInSceneOnTop = !1
  22956. },
  22957. onEnter: function() {
  22958. cc.TransitionScene.prototype.onEnter.call(this);
  22959. this._gridProxy.setTarget(this._outScene);
  22960. this._gridProxy.onEnter();
  22961. var a = cc.director.getWinSize(),
  22962. a = cc.turnOffTiles(this._duration, cc.size(0 | a.width / a.height * 12, 12)),
  22963. a = this.easeActionWithAction(a);
  22964. this._gridProxy.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid()))
  22965. },
  22966. visit: function() {
  22967. this._inScene.visit();
  22968. this._gridProxy.visit()
  22969. },
  22970. easeActionWithAction: function(a) {
  22971. return a
  22972. }
  22973. });
  22974. cc.TransitionTurnOffTiles.create = function(a, b) {
  22975. return new cc.TransitionTurnOffTiles(a, b)
  22976. };
  22977. cc.TransitionSplitCols = cc.TransitionScene.extend({
  22978. _gridProxy: null,
  22979. _switchTargetToInscene: function() {
  22980. this._gridProxy.setTarget(this._inScene)
  22981. },
  22982. ctor: function(a, b) {
  22983. cc.TransitionScene.prototype.ctor.call(this);
  22984. this._gridProxy = new cc.NodeGrid;
  22985. b && this.initWithDuration(a, b)
  22986. },
  22987. onEnter: function() {
  22988. cc.TransitionScene.prototype.onEnter.call(this);
  22989. this._gridProxy.setTarget(this._outScene);
  22990. this._gridProxy.onEnter();
  22991. var a = this.action(),
  22992. a = cc.sequence(a, cc.callFunc(this._switchTargetToInscene, this), a.reverse());
  22993. this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a),
  22994. cc.callFunc(this.finish, this), cc.stopGrid()))
  22995. },
  22996. onExit: function() {
  22997. this._gridProxy.setTarget(null);
  22998. this._gridProxy.onExit();
  22999. cc.TransitionScene.prototype.onExit.call(this)
  23000. },
  23001. visit: function() {
  23002. this._gridProxy.visit()
  23003. },
  23004. easeActionWithAction: function(a) {
  23005. return new cc.EaseInOut(a, 3)
  23006. },
  23007. action: function() {
  23008. return cc.splitCols(this._duration / 2, 3)
  23009. }
  23010. });
  23011. cc.TransitionSplitCols.create = function(a, b) {
  23012. return new cc.TransitionSplitCols(a, b)
  23013. };
  23014. cc.TransitionSplitRows = cc.TransitionSplitCols.extend({
  23015. ctor: function(a, b) {
  23016. cc.TransitionSplitCols.prototype.ctor.call(this);
  23017. b && this.initWithDuration(a, b)
  23018. },
  23019. action: function() {
  23020. return cc.splitRows(this._duration / 2, 3)
  23021. }
  23022. });
  23023. cc.TransitionSplitRows.create = function(a, b) {
  23024. return new cc.TransitionSplitRows(a, b)
  23025. };
  23026. cc.TransitionFadeTR = cc.TransitionScene.extend({
  23027. _gridProxy: null,
  23028. ctor: function(a, b) {
  23029. cc.TransitionScene.prototype.ctor.call(this);
  23030. this._gridProxy = new cc.NodeGrid;
  23031. b && this.initWithDuration(a, b)
  23032. },
  23033. _sceneOrder: function() {
  23034. this._isInSceneOnTop = !1
  23035. },
  23036. onEnter: function() {
  23037. cc.TransitionScene.prototype.onEnter.call(this);
  23038. this._gridProxy.setTarget(this._outScene);
  23039. this._gridProxy.onEnter();
  23040. var a = cc.director.getWinSize(),
  23041. a = this.actionWithSize(cc.size(0 | a.width / a.height * 12, 12));
  23042. this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(a),
  23043. cc.callFunc(this.finish, this), cc.stopGrid()))
  23044. },
  23045. visit: function() {
  23046. this._inScene.visit();
  23047. this._gridProxy.visit()
  23048. },
  23049. easeActionWithAction: function(a) {
  23050. return a
  23051. },
  23052. actionWithSize: function(a) {
  23053. return cc.fadeOutTRTiles(this._duration, a)
  23054. }
  23055. });
  23056. cc.TransitionFadeTR.create = function(a, b) {
  23057. return new cc.TransitionFadeTR(a, b)
  23058. };
  23059. cc.TransitionFadeBL = cc.TransitionFadeTR.extend({
  23060. ctor: function(a, b) {
  23061. cc.TransitionFadeTR.prototype.ctor.call(this);
  23062. b && this.initWithDuration(a, b)
  23063. },
  23064. actionWithSize: function(a) {
  23065. return cc.fadeOutBLTiles(this._duration, a)
  23066. }
  23067. });
  23068. cc.TransitionFadeBL.create = function(a, b) {
  23069. return new cc.TransitionFadeBL(a, b)
  23070. };
  23071. cc.TransitionFadeUp = cc.TransitionFadeTR.extend({
  23072. ctor: function(a, b) {
  23073. cc.TransitionFadeTR.prototype.ctor.call(this);
  23074. b && this.initWithDuration(a, b)
  23075. },
  23076. actionWithSize: function(a) {
  23077. return new cc.FadeOutUpTiles(this._duration, a)
  23078. }
  23079. });
  23080. cc.TransitionFadeUp.create = function(a, b) {
  23081. return new cc.TransitionFadeUp(a, b)
  23082. };
  23083. cc.TransitionFadeDown = cc.TransitionFadeTR.extend({
  23084. ctor: function(a, b) {
  23085. cc.TransitionFadeTR.prototype.ctor.call(this);
  23086. b && this.initWithDuration(a, b)
  23087. },
  23088. actionWithSize: function(a) {
  23089. return cc.fadeOutDownTiles(this._duration, a)
  23090. }
  23091. });
  23092. cc.TransitionFadeDown.create = function(a, b) {
  23093. return new cc.TransitionFadeDown(a, b)
  23094. };
  23095. cc.SCENE_RADIAL = 49153;
  23096. cc.TransitionProgress = cc.TransitionScene.extend({
  23097. _to: 0,
  23098. _from: 0,
  23099. _sceneToBeModified: null,
  23100. _className: "TransitionProgress",
  23101. ctor: function(a, b) {
  23102. cc.TransitionScene.prototype.ctor.call(this);
  23103. b && this.initWithDuration(a, b)
  23104. },
  23105. _setAttrs: function(a, b, c) {
  23106. a.attr({
  23107. x: b,
  23108. y: c,
  23109. anchorX: 0.5,
  23110. anchorY: 0.5
  23111. })
  23112. },
  23113. onEnter: function() {
  23114. cc.TransitionScene.prototype.onEnter.call(this);
  23115. this._setupTransition();
  23116. var a = cc.director.getWinSize(),
  23117. b = new cc.RenderTexture(a.width, a.height);
  23118. b.sprite.anchorX = 0.5;
  23119. b.sprite.anchorY = 0.5;
  23120. this._setAttrs(b,
  23121. a.width / 2, a.height / 2);
  23122. b.clear(0, 0, 0, 1);
  23123. b.begin();
  23124. this._sceneToBeModified.visit();
  23125. b.end();
  23126. this._sceneToBeModified === this._outScene && this.hideOutShowIn();
  23127. a = this._progressTimerNodeWithRenderTexture(b);
  23128. b = cc.sequence(cc.progressFromTo(this._duration, this._from, this._to), cc.callFunc(this.finish, this));
  23129. a.runAction(b);
  23130. this.addChild(a, 2, cc.SCENE_RADIAL)
  23131. },
  23132. onExit: function() {
  23133. this.removeChildByTag(cc.SCENE_RADIAL, !0);
  23134. cc.TransitionScene.prototype.onExit.call(this)
  23135. },
  23136. _setupTransition: function() {
  23137. this._sceneToBeModified =
  23138. this._outScene;
  23139. this._from = 100;
  23140. this._to = 0
  23141. },
  23142. _progressTimerNodeWithRenderTexture: function(a) {
  23143. cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass");
  23144. return null
  23145. },
  23146. _sceneOrder: function() {
  23147. this._isInSceneOnTop = !1
  23148. }
  23149. });
  23150. cc.TransitionProgress.create = function(a, b) {
  23151. return new cc.TransitionProgress(a, b)
  23152. };
  23153. cc.TransitionProgressRadialCCW = cc.TransitionProgress.extend({
  23154. ctor: function(a, b) {
  23155. cc.TransitionProgress.prototype.ctor.call(this);
  23156. b && this.initWithDuration(a, b)
  23157. },
  23158. _progressTimerNodeWithRenderTexture: function(a) {
  23159. var b = cc.director.getWinSize();
  23160. a = new cc.ProgressTimer(a.sprite);
  23161. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23162. a.type = cc.ProgressTimer.TYPE_RADIAL;
  23163. a.reverseDir = !1;
  23164. a.percentage = 100;
  23165. this._setAttrs(a, b.width / 2, b.height / 2);
  23166. return a
  23167. }
  23168. });
  23169. cc.TransitionProgressRadialCCW.create = function(a, b) {
  23170. return new cc.TransitionProgressRadialCCW(a, b)
  23171. };
  23172. cc.TransitionProgressRadialCW = cc.TransitionProgress.extend({
  23173. ctor: function(a, b) {
  23174. cc.TransitionProgress.prototype.ctor.call(this);
  23175. b && this.initWithDuration(a, b)
  23176. },
  23177. _progressTimerNodeWithRenderTexture: function(a) {
  23178. var b = cc.director.getWinSize();
  23179. a = new cc.ProgressTimer(a.sprite);
  23180. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23181. a.type = cc.ProgressTimer.TYPE_RADIAL;
  23182. a.reverseDir = !0;
  23183. a.percentage = 100;
  23184. this._setAttrs(a, b.width / 2, b.height / 2);
  23185. return a
  23186. }
  23187. });
  23188. cc.TransitionProgressRadialCW.create = function(a, b) {
  23189. var c = new cc.TransitionProgressRadialCW;
  23190. return null !== c && c.initWithDuration(a, b) ? c : new cc.TransitionProgressRadialCW(a, b)
  23191. };
  23192. cc.TransitionProgressHorizontal = cc.TransitionProgress.extend({
  23193. ctor: function(a, b) {
  23194. cc.TransitionProgress.prototype.ctor.call(this);
  23195. b && this.initWithDuration(a, b)
  23196. },
  23197. _progressTimerNodeWithRenderTexture: function(a) {
  23198. var b = cc.director.getWinSize();
  23199. a = new cc.ProgressTimer(a.sprite);
  23200. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23201. a.type = cc.ProgressTimer.TYPE_BAR;
  23202. a.midPoint = cc.p(1, 0);
  23203. a.barChangeRate = cc.p(1, 0);
  23204. a.percentage = 100;
  23205. this._setAttrs(a, b.width / 2, b.height / 2);
  23206. return a
  23207. }
  23208. });
  23209. cc.TransitionProgressHorizontal.create = function(a, b) {
  23210. return new cc.TransitionProgressHorizontal(a, b)
  23211. };
  23212. cc.TransitionProgressVertical = cc.TransitionProgress.extend({
  23213. ctor: function(a, b) {
  23214. cc.TransitionProgress.prototype.ctor.call(this);
  23215. b && this.initWithDuration(a, b)
  23216. },
  23217. _progressTimerNodeWithRenderTexture: function(a) {
  23218. var b = cc.director.getWinSize();
  23219. a = new cc.ProgressTimer(a.sprite);
  23220. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23221. a.type = cc.ProgressTimer.TYPE_BAR;
  23222. a.midPoint = cc.p(0, 0);
  23223. a.barChangeRate = cc.p(0, 1);
  23224. a.percentage = 100;
  23225. this._setAttrs(a, b.width / 2, b.height / 2);
  23226. return a
  23227. }
  23228. });
  23229. cc.TransitionProgressVertical.create = function(a, b) {
  23230. return new cc.TransitionProgressVertical(a, b)
  23231. };
  23232. cc.TransitionProgressInOut = cc.TransitionProgress.extend({
  23233. ctor: function(a, b) {
  23234. cc.TransitionProgress.prototype.ctor.call(this);
  23235. b && this.initWithDuration(a, b)
  23236. },
  23237. _progressTimerNodeWithRenderTexture: function(a) {
  23238. var b = cc.director.getWinSize();
  23239. a = new cc.ProgressTimer(a.sprite);
  23240. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23241. a.type = cc.ProgressTimer.TYPE_BAR;
  23242. a.midPoint = cc.p(0.5, 0.5);
  23243. a.barChangeRate = cc.p(1, 1);
  23244. a.percentage = 0;
  23245. this._setAttrs(a, b.width / 2, b.height / 2);
  23246. return a
  23247. },
  23248. _sceneOrder: function() {
  23249. this._isInSceneOnTop = !1
  23250. },
  23251. _setupTransition: function() {
  23252. this._sceneToBeModified = this._inScene;
  23253. this._from = 0;
  23254. this._to = 100
  23255. }
  23256. });
  23257. cc.TransitionProgressInOut.create = function(a, b) {
  23258. return new cc.TransitionProgressInOut(a, b)
  23259. };
  23260. cc.TransitionProgressOutIn = cc.TransitionProgress.extend({
  23261. ctor: function(a, b) {
  23262. cc.TransitionProgress.prototype.ctor.call(this);
  23263. b && this.initWithDuration(a, b)
  23264. },
  23265. _progressTimerNodeWithRenderTexture: function(a) {
  23266. var b = cc.director.getWinSize();
  23267. a = new cc.ProgressTimer(a.sprite);
  23268. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.sprite.flippedY = !0);
  23269. a.type = cc.ProgressTimer.TYPE_BAR;
  23270. a.midPoint = cc.p(0.5, 0.5);
  23271. a.barChangeRate = cc.p(1, 1);
  23272. a.percentage = 100;
  23273. this._setAttrs(a, b.width / 2, b.height / 2);
  23274. return a
  23275. }
  23276. });
  23277. cc.TransitionProgressOutIn.create = function(a, b) {
  23278. return new cc.TransitionProgressOutIn(a, b)
  23279. };
  23280. cc.TransitionPageTurn = cc.TransitionScene.extend({
  23281. ctor: function(a, b, c) {
  23282. cc.TransitionScene.prototype.ctor.call(this);
  23283. this._gridProxy = new cc.NodeGrid;
  23284. this.initWithDuration(a, b, c)
  23285. },
  23286. _back: !0,
  23287. _gridProxy: null,
  23288. _className: "TransitionPageTurn",
  23289. initWithDuration: function(a, b, c) {
  23290. this._back = c;
  23291. cc.TransitionScene.prototype.initWithDuration.call(this, a, b);
  23292. return !0
  23293. },
  23294. actionWithSize: function(a) {
  23295. return this._back ? cc.reverseTime(cc.pageTurn3D(this._duration, a)) : cc.pageTurn3D(this._duration, a)
  23296. },
  23297. onEnter: function() {
  23298. cc.TransitionScene.prototype.onEnter.call(this);
  23299. var a = cc.director.getWinSize(),
  23300. b;
  23301. a.width > a.height ? (a = 16, b = 12) : (a = 12, b = 16);
  23302. a = this.actionWithSize(cc.size(a, b));
  23303. b = this._gridProxy;
  23304. this._back ? (b.setTarget(this._inScene), b.onEnter(), this._inScene.visible = !1, b.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid())), this._inScene.runAction(cc.show())) : (b.setTarget(this._outScene), b.onEnter(), b.runAction(cc.sequence(a, cc.callFunc(this.finish, this), cc.stopGrid())))
  23305. },
  23306. visit: function() {
  23307. this._back ? this._outScene.visit() : this._inScene.visit();
  23308. this._gridProxy.visit()
  23309. },
  23310. _sceneOrder: function() {
  23311. this._isInSceneOnTop = this._back
  23312. }
  23313. });
  23314. cc.TransitionPageTurn.create = function(a, b, c) {
  23315. return new cc.TransitionPageTurn(a, b, c)
  23316. };
  23317. cc.Codec = {
  23318. name: "Jacob__Codec"
  23319. };
  23320. cc.unzip = function() {
  23321. return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, arguments)
  23322. };
  23323. cc.unzipBase64 = function() {
  23324. var a = cc.Codec.Base64.decode.apply(cc.Codec.Base64, arguments);
  23325. return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip, [a])
  23326. };
  23327. cc.unzipBase64AsArray = function(a, b) {
  23328. b = b || 1;
  23329. var c = this.unzipBase64(a),
  23330. d = [],
  23331. e, f, g;
  23332. e = 0;
  23333. for (g = c.length / b; e < g; e++)
  23334. for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f;
  23335. return d
  23336. };
  23337. cc.unzipAsArray = function(a, b) {
  23338. b = b || 1;
  23339. var c = this.unzip(a),
  23340. d = [],
  23341. e, f, g;
  23342. e = 0;
  23343. for (g = c.length / b; e < g; e++)
  23344. for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f;
  23345. return d
  23346. };
  23347. cc.StringToArray = function(a) {
  23348. a = a.split(",");
  23349. var b = [],
  23350. c;
  23351. for (c = 0; c < a.length; c++) b.push(parseInt(a[c]));
  23352. return b
  23353. };
  23354. cc.Codec.Base64 = {
  23355. name: "Jacob__Codec__Base64"
  23356. };
  23357. cc.Codec.Base64._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\x3d";
  23358. cc.Codec.Base64.decode = function(a) {
  23359. var b = [],
  23360. c, d, e, f, g, h = 0;
  23361. for (a = a.replace(/[^A-Za-z0-9\+\/\=]/g, ""); h < a.length;) c = this._keyStr.indexOf(a.charAt(h++)), d = this._keyStr.indexOf(a.charAt(h++)), f = this._keyStr.indexOf(a.charAt(h++)), g = this._keyStr.indexOf(a.charAt(h++)), c = c << 2 | d >> 4, d = (d & 15) << 4 | f >> 2, e = (f & 3) << 6 | g, b.push(String.fromCharCode(c)), 64 !== f && b.push(String.fromCharCode(d)), 64 !== g && b.push(String.fromCharCode(e));
  23362. return b = b.join("")
  23363. };
  23364. cc.Codec.Base64.decodeAsArray = function(a, b) {
  23365. var c = this.decode(a),
  23366. d = [],
  23367. e, f, g;
  23368. e = 0;
  23369. for (g = c.length / b; e < g; e++)
  23370. for (d[e] = 0, f = b - 1; 0 <= f; --f) d[e] += c.charCodeAt(e * b + f) << 8 * f;
  23371. return d
  23372. };
  23373. cc.uint8ArrayToUint32Array = function(a) {
  23374. if (0 !== a.length % 4) return null;
  23375. for (var b = a.length / 4, c = window.Uint32Array ? new Uint32Array(b) : [], d = 0; d < b; d++) {
  23376. var e = 4 * d;
  23377. c[d] = a[e] + 256 * a[e + 1] + 65536 * a[e + 2] + 16777216 * a[e + 3]
  23378. }
  23379. return c
  23380. };
  23381. cc.Codec.GZip = function(a) {
  23382. this.data = a;
  23383. this.debug = !1;
  23384. this.gpflags = void 0;
  23385. this.files = 0;
  23386. this.unzipped = [];
  23387. this.buf32k = Array(32768);
  23388. this.bIdx = 0;
  23389. this.modeZIP = !1;
  23390. this.bytepos = 0;
  23391. this.bb = 1;
  23392. this.bits = 0;
  23393. this.nameBuf = [];
  23394. this.fileout = void 0;
  23395. this.literalTree = Array(cc.Codec.GZip.LITERALS);
  23396. this.distanceTree = Array(32);
  23397. this.treepos = 0;
  23398. this.Places = null;
  23399. this.len = 0;
  23400. this.fpos = Array(17);
  23401. this.fpos[0] = 0;
  23402. this.fmax = this.flens = void 0
  23403. };
  23404. cc.Codec.GZip.gunzip = function(a) {
  23405. return (new cc.Codec.GZip(a)).gunzip()[0][0]
  23406. };
  23407. cc.Codec.GZip.HufNode = function() {
  23408. this.b1 = this.b0 = 0;
  23409. this.jump = null;
  23410. this.jumppos = -1
  23411. };
  23412. cc.Codec.GZip.LITERALS = 288;
  23413. cc.Codec.GZip.NAMEMAX = 256;
  23414. 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,
  23415. 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
  23416. ];
  23417. 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];
  23418. 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];
  23419. 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];
  23420. 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];
  23421. cc.Codec.GZip.border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  23422. cc.Codec.GZip.prototype.gunzip = function() {
  23423. this.outputArr = [];
  23424. this.nextFile();
  23425. return this.unzipped
  23426. };
  23427. cc.Codec.GZip.prototype.readByte = function() {
  23428. this.bits += 8;
  23429. return this.bytepos < this.data.length ? this.data.charCodeAt(this.bytepos++) : -1
  23430. };
  23431. cc.Codec.GZip.prototype.byteAlign = function() {
  23432. this.bb = 1
  23433. };
  23434. cc.Codec.GZip.prototype.readBit = function() {
  23435. var a;
  23436. this.bits++;
  23437. a = this.bb & 1;
  23438. this.bb >>= 1;
  23439. 0 === this.bb && (this.bb = this.readByte(), a = this.bb & 1, this.bb = this.bb >> 1 | 128);
  23440. return a
  23441. };
  23442. cc.Codec.GZip.prototype.readBits = function(a) {
  23443. for (var b = 0, c = a; c--;) b = b << 1 | this.readBit();
  23444. a && (b = cc.Codec.GZip.bitReverse[b] >> 8 - a);
  23445. return b
  23446. };
  23447. cc.Codec.GZip.prototype.flushBuffer = function() {
  23448. this.bIdx = 0
  23449. };
  23450. cc.Codec.GZip.prototype.addBuffer = function(a) {
  23451. this.buf32k[this.bIdx++] = a;
  23452. this.outputArr.push(String.fromCharCode(a));
  23453. 32768 === this.bIdx && (this.bIdx = 0)
  23454. };
  23455. cc.Codec.GZip.prototype.IsPat = function() {
  23456. for (;;) {
  23457. if (this.fpos[this.len] >= this.fmax) return -1;
  23458. if (this.flens[this.fpos[this.len]] === this.len) return this.fpos[this.len]++;
  23459. this.fpos[this.len]++
  23460. }
  23461. };
  23462. cc.Codec.GZip.prototype.Rec = function() {
  23463. var a = this.Places[this.treepos],
  23464. b;
  23465. if (17 === this.len) return -1;
  23466. this.treepos++;
  23467. this.len++;
  23468. b = this.IsPat();
  23469. if (0 <= b) a.b0 = b;
  23470. else if (a.b0 = 32768, this.Rec()) return -1;
  23471. b = this.IsPat();
  23472. if (0 <= b) a.b1 = b, a.jump = null;
  23473. else if (a.b1 = 32768, a.jump = this.Places[this.treepos], a.jumppos = this.treepos, this.Rec()) return -1;
  23474. this.len--;
  23475. return 0
  23476. };
  23477. cc.Codec.GZip.prototype.CreateTree = function(a, b, c, d) {
  23478. this.Places = a;
  23479. this.treepos = 0;
  23480. this.flens = c;
  23481. this.fmax = b;
  23482. for (a = 0; 17 > a; a++) this.fpos[a] = 0;
  23483. this.len = 0;
  23484. return this.Rec() ? -1 : 0
  23485. };
  23486. cc.Codec.GZip.prototype.DecodeValue = function(a) {
  23487. for (var b, c, d = 0, e = a[d];;)
  23488. if (b = this.readBit()) {
  23489. if (!(e.b1 & 32768)) return e.b1;
  23490. e = e.jump;
  23491. b = a.length;
  23492. for (c = 0; c < b; c++)
  23493. if (a[c] === e) {
  23494. d = c;
  23495. break
  23496. }
  23497. } else {
  23498. if (!(e.b0 & 32768)) return e.b0;
  23499. d++;
  23500. e = a[d]
  23501. }
  23502. return -1
  23503. };
  23504. cc.Codec.GZip.prototype.DeflateLoop = function() {
  23505. var a, b, c, d, e;
  23506. do
  23507. if (a = this.readBit(), c = this.readBits(2), 0 === c)
  23508. for (this.byteAlign(), c = this.readByte(), c |= this.readByte() << 8, b = this.readByte(), b |= this.readByte() << 8, (c ^ ~b) & 65535 && document.write("BlockLen checksum mismatch\n"); c--;) b = this.readByte(), this.addBuffer(b);
  23509. else if (1 === c)
  23510. for (;;)
  23511. if (c = cc.Codec.GZip.bitReverse[this.readBits(7)] >> 1, 23 < c ? (c = c << 1 | this.readBit(), 199 < c ? (c -= 128, c = c << 1 | this.readBit()) : (c -= 48, 143 < c && (c += 136))) : c += 256, 256 > c) this.addBuffer(c);
  23512. else if (256 === c) break;
  23513. else {
  23514. var f;
  23515. c -= 257;
  23516. e = this.readBits(cc.Codec.GZip.cplext[c]) + cc.Codec.GZip.cplens[c];
  23517. c = cc.Codec.GZip.bitReverse[this.readBits(5)] >> 3;
  23518. 8 < cc.Codec.GZip.cpdext[c] ? (f = this.readBits(8), f |= this.readBits(cc.Codec.GZip.cpdext[c] - 8) << 8) : f = this.readBits(cc.Codec.GZip.cpdext[c]);
  23519. f += cc.Codec.GZip.cpdist[c];
  23520. for (c = 0; c < e; c++) b = this.buf32k[this.bIdx - f & 32767], this.addBuffer(b)
  23521. } else if (2 === c) {
  23522. var g = Array(320);
  23523. b = 257 + this.readBits(5);
  23524. f = 1 + this.readBits(5);
  23525. d = 4 + this.readBits(4);
  23526. for (c = 0; 19 > c; c++) g[c] =
  23527. 0;
  23528. for (c = 0; c < d; c++) g[cc.Codec.GZip.border[c]] = this.readBits(3);
  23529. e = this.distanceTree.length;
  23530. for (d = 0; d < e; d++) this.distanceTree[d] = new cc.Codec.GZip.HufNode;
  23531. if (this.CreateTree(this.distanceTree, 19, g, 0)) return this.flushBuffer(), 1;
  23532. e = b + f;
  23533. d = 0;
  23534. for (var h = -1; d < e;)
  23535. if (h++, c = this.DecodeValue(this.distanceTree), 16 > c) g[d++] = c;
  23536. else if (16 === c) {
  23537. var k;
  23538. c = 3 + this.readBits(2);
  23539. if (d + c > e) return this.flushBuffer(), 1;
  23540. for (k = d ? g[d - 1] : 0; c--;) g[d++] = k
  23541. } else {
  23542. c = 17 === c ? 3 + this.readBits(3) : 11 + this.readBits(7);
  23543. if (d + c > e) return this.flushBuffer(),
  23544. 1;
  23545. for (; c--;) g[d++] = 0
  23546. }
  23547. e = this.literalTree.length;
  23548. for (d = 0; d < e; d++) this.literalTree[d] = new cc.Codec.GZip.HufNode;
  23549. if (this.CreateTree(this.literalTree, b, g, 0)) return this.flushBuffer(), 1;
  23550. e = this.literalTree.length;
  23551. for (d = 0; d < e; d++) this.distanceTree[d] = new cc.Codec.GZip.HufNode;
  23552. c = [];
  23553. for (d = b; d < g.length; d++) c[d - b] = g[d];
  23554. if (this.CreateTree(this.distanceTree, f, c, 0)) return this.flushBuffer(), 1;
  23555. for (;;)
  23556. if (c = this.DecodeValue(this.literalTree), 256 <= c) {
  23557. c -= 256;
  23558. if (0 === c) break;
  23559. c--;
  23560. e = this.readBits(cc.Codec.GZip.cplext[c]) +
  23561. cc.Codec.GZip.cplens[c];
  23562. c = this.DecodeValue(this.distanceTree);
  23563. 8 < cc.Codec.GZip.cpdext[c] ? (f = this.readBits(8), f |= this.readBits(cc.Codec.GZip.cpdext[c] - 8) << 8) : f = this.readBits(cc.Codec.GZip.cpdext[c]);
  23564. for (f += cc.Codec.GZip.cpdist[c]; e--;) b = this.buf32k[this.bIdx - f & 32767], this.addBuffer(b)
  23565. } else this.addBuffer(c)
  23566. }
  23567. while (!a);
  23568. this.flushBuffer();
  23569. this.byteAlign();
  23570. return 0
  23571. };
  23572. cc.Codec.GZip.prototype.unzipFile = function(a) {
  23573. var b;
  23574. this.gunzip();
  23575. for (b = 0; b < this.unzipped.length; b++)
  23576. if (this.unzipped[b][1] === a) return this.unzipped[b][0]
  23577. };
  23578. cc.Codec.GZip.prototype.nextFile = function() {
  23579. this.outputArr = [];
  23580. this.modeZIP = !1;
  23581. var a = [];
  23582. a[0] = this.readByte();
  23583. a[1] = this.readByte();
  23584. 120 === a[0] && 218 === a[1] && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), "geonext.gxt"], this.files++);
  23585. 31 === a[0] && 139 === a[1] && (this.skipdir(), this.unzipped[this.files] = [this.outputArr.join(""), "file"], this.files++);
  23586. if (80 === a[0] && 75 === a[1] && (this.modeZIP = !0, a[2] = this.readByte(), a[3] = this.readByte(), 3 === a[2] && 4 === a[3])) {
  23587. a[0] = this.readByte();
  23588. a[1] = this.readByte();
  23589. this.gpflags = this.readByte();
  23590. this.gpflags |= this.readByte() << 8;
  23591. a = this.readByte();
  23592. a |= this.readByte() << 8;
  23593. this.readByte();
  23594. this.readByte();
  23595. this.readByte();
  23596. this.readByte();
  23597. this.readByte();
  23598. this.readByte();
  23599. this.readByte();
  23600. this.readByte();
  23601. this.readByte();
  23602. this.readByte();
  23603. this.readByte();
  23604. this.readByte();
  23605. var b = this.readByte(),
  23606. b = b | this.readByte() << 8,
  23607. c = this.readByte(),
  23608. c = c | this.readByte() << 8,
  23609. d = 0;
  23610. for (this.nameBuf = []; b--;) {
  23611. var e = this.readByte();
  23612. "/" === e | ":" === e ? d = 0 : d < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[d++] = String.fromCharCode(e))
  23613. }
  23614. this.fileout ||
  23615. (this.fileout = this.nameBuf);
  23616. for (var d = 0; d < c;) this.readByte(), d++;
  23617. 8 === a && (this.DeflateLoop(), this.unzipped[this.files] = [this.outputArr.join(""), this.nameBuf.join("")], this.files++);
  23618. this.skipdir()
  23619. }
  23620. };
  23621. cc.Codec.GZip.prototype.skipdir = function() {
  23622. var a = [],
  23623. b;
  23624. 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());
  23625. this.modeZIP && this.nextFile();
  23626. a[0] = this.readByte();
  23627. if (8 !== a[0]) return 0;
  23628. this.gpflags = this.readByte();
  23629. this.readByte();
  23630. this.readByte();
  23631. this.readByte();
  23632. this.readByte();
  23633. this.readByte();
  23634. this.readByte();
  23635. if (this.gpflags & 4)
  23636. for (a[0] =
  23637. this.readByte(), a[2] = this.readByte(), this.len = a[0] + 256 * a[1], a = 0; a < this.len; a++) this.readByte();
  23638. if (this.gpflags & 8)
  23639. for (a = 0, this.nameBuf = []; b = this.readByte();) {
  23640. if ("7" === b || ":" === b) a = 0;
  23641. a < cc.Codec.GZip.NAMEMAX - 1 && (this.nameBuf[a++] = b)
  23642. }
  23643. if (this.gpflags & 16)
  23644. for (; this.readByte(););
  23645. this.gpflags & 2 && (this.readByte(), this.readByte());
  23646. this.DeflateLoop();
  23647. this.readByte();
  23648. this.readByte();
  23649. this.readByte();
  23650. this.readByte();
  23651. this.modeZIP && this.nextFile()
  23652. };
  23653. /*
  23654. zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
  23655. (function() {
  23656. function a(a) {
  23657. throw a;
  23658. }
  23659. function b(a, b) {
  23660. var c = a.split("."),
  23661. d = A;
  23662. c[0] in d || !d.execScript || d.execScript("var " + c[0]);
  23663. for (var e; c.length && (e = c.shift());) c.length || b === D ? d = d[e] ? d[e] : d[e] = {} : d[e] = b
  23664. }
  23665. function c(a) {
  23666. if ("string" === typeof a) {
  23667. a = a.split("");
  23668. var b, c;
  23669. b = 0;
  23670. for (c = a.length; b < c; b++) a[b] = (a[b].charCodeAt(0) & 255) >>> 0
  23671. }
  23672. b = 1;
  23673. c = 0;
  23674. for (var d = a.length, e, f = 0; 0 < d;) {
  23675. e = 1024 < d ? 1024 : d;
  23676. d -= e;
  23677. do b += a[f++], c += b; while (--e);
  23678. b %= 65521;
  23679. c %= 65521
  23680. }
  23681. return (c << 16 | b) >>> 0
  23682. }
  23683. function d(b, c) {
  23684. this.index = "number" === typeof c ? c : 0;
  23685. this.i = 0;
  23686. this.buffer = b instanceof(w ? Uint8Array : Array) ? b : new(w ? Uint8Array : Array)(32768);
  23687. 2 * this.buffer.length <= this.index && a(Error("invalid index"));
  23688. this.buffer.length <= this.index && this.f()
  23689. }
  23690. function e(a) {
  23691. this.buffer = new(w ? Uint16Array : Array)(2 * a);
  23692. this.length = 0
  23693. }
  23694. function f(a) {
  23695. var b = a.length,
  23696. c = 0,
  23697. d = Number.POSITIVE_INFINITY,
  23698. e, f, g, h, k, m, n, p, t;
  23699. for (p = 0; p < b; ++p) a[p] > c && (c = a[p]), a[p] < d && (d = a[p]);
  23700. e = 1 << c;
  23701. f = new(w ? Uint32Array : Array)(e);
  23702. g = 1;
  23703. h = 0;
  23704. for (k = 2; g <= c;) {
  23705. for (p = 0; p < b; ++p)
  23706. if (a[p] === g) {
  23707. m = 0;
  23708. n = h;
  23709. for (t = 0; t < g; ++t) m =
  23710. m << 1 | n & 1, n >>= 1;
  23711. for (t = m; t < e; t += k) f[t] = g << 16 | p;
  23712. ++h
  23713. }++g;
  23714. h <<= 1;
  23715. k <<= 1
  23716. }
  23717. return [f, c, d]
  23718. }
  23719. function g(a, b) {
  23720. this.h = N;
  23721. this.w = 0;
  23722. this.input = a;
  23723. this.b = 0;
  23724. b && (b.lazy && (this.w = b.lazy), "number" === typeof b.compressionType && (this.h = b.compressionType), b.outputBuffer && (this.a = w && b.outputBuffer instanceof Array ? new Uint8Array(b.outputBuffer) : b.outputBuffer), "number" === typeof b.outputIndex && (this.b = b.outputIndex));
  23725. this.a || (this.a = new(w ? Uint8Array : Array)(32768))
  23726. }
  23727. function h(a, b) {
  23728. this.length = a;
  23729. this.G = b
  23730. }
  23731. function k() {
  23732. var b = P;
  23733. switch (E) {
  23734. case 3 ===
  23735. b:
  23736. return [257, b - 3, 0];
  23737. case 4 === b:
  23738. return [258, b - 4, 0];
  23739. case 5 === b:
  23740. return [259, b - 5, 0];
  23741. case 6 === b:
  23742. return [260, b - 6, 0];
  23743. case 7 === b:
  23744. return [261, b - 7, 0];
  23745. case 8 === b:
  23746. return [262, b - 8, 0];
  23747. case 9 === b:
  23748. return [263, b - 9, 0];
  23749. case 10 === b:
  23750. return [264, b - 10, 0];
  23751. case 12 >= b:
  23752. return [265, b - 11, 1];
  23753. case 14 >= b:
  23754. return [266, b - 13, 1];
  23755. case 16 >= b:
  23756. return [267, b - 15, 1];
  23757. case 18 >= b:
  23758. return [268, b - 17, 1];
  23759. case 22 >= b:
  23760. return [269, b - 19, 2];
  23761. case 26 >= b:
  23762. return [270, b - 23, 2];
  23763. case 30 >= b:
  23764. return [271, b - 27, 2];
  23765. case 34 >= b:
  23766. return [272, b - 31, 2];
  23767. case 42 >= b:
  23768. return [273, b - 35, 3];
  23769. case 50 >=
  23770. b:
  23771. return [274, b - 43, 3];
  23772. case 58 >= b:
  23773. return [275, b - 51, 3];
  23774. case 66 >= b:
  23775. return [276, b - 59, 3];
  23776. case 82 >= b:
  23777. return [277, b - 67, 4];
  23778. case 98 >= b:
  23779. return [278, b - 83, 4];
  23780. case 114 >= b:
  23781. return [279, b - 99, 4];
  23782. case 130 >= b:
  23783. return [280, b - 115, 4];
  23784. case 162 >= b:
  23785. return [281, b - 131, 5];
  23786. case 194 >= b:
  23787. return [282, b - 163, 5];
  23788. case 226 >= b:
  23789. return [283, b - 195, 5];
  23790. case 257 >= b:
  23791. return [284, b - 227, 5];
  23792. case 258 === b:
  23793. return [285, b - 258, 0];
  23794. default:
  23795. a("invalid length: " + b)
  23796. }
  23797. }
  23798. function m(b, c) {
  23799. function d(b, c) {
  23800. var e = b.G,
  23801. f = [],
  23802. g = 0,
  23803. h;
  23804. h = S[b.length];
  23805. f[g++] = h & 65535;
  23806. f[g++] = h >> 16 & 255;
  23807. f[g++] =
  23808. h >> 24;
  23809. var k;
  23810. switch (E) {
  23811. case 1 === e:
  23812. k = [0, e - 1, 0];
  23813. break;
  23814. case 2 === e:
  23815. k = [1, e - 2, 0];
  23816. break;
  23817. case 3 === e:
  23818. k = [2, e - 3, 0];
  23819. break;
  23820. case 4 === e:
  23821. k = [3, e - 4, 0];
  23822. break;
  23823. case 6 >= e:
  23824. k = [4, e - 5, 1];
  23825. break;
  23826. case 8 >= e:
  23827. k = [5, e - 7, 1];
  23828. break;
  23829. case 12 >= e:
  23830. k = [6, e - 9, 2];
  23831. break;
  23832. case 16 >= e:
  23833. k = [7, e - 13, 2];
  23834. break;
  23835. case 24 >= e:
  23836. k = [8, e - 17, 3];
  23837. break;
  23838. case 32 >= e:
  23839. k = [9, e - 25, 3];
  23840. break;
  23841. case 48 >= e:
  23842. k = [10, e - 33, 4];
  23843. break;
  23844. case 64 >= e:
  23845. k = [11, e - 49, 4];
  23846. break;
  23847. case 96 >= e:
  23848. k = [12, e - 65, 5];
  23849. break;
  23850. case 128 >= e:
  23851. k = [13, e - 97, 5];
  23852. break;
  23853. case 192 >= e:
  23854. k = [14, e - 129, 6];
  23855. break;
  23856. case 256 >= e:
  23857. k = [15, e - 193, 6];
  23858. break;
  23859. case 384 >= e:
  23860. k = [16, e - 257, 7];
  23861. break;
  23862. case 512 >= e:
  23863. k = [17, e - 385, 7];
  23864. break;
  23865. case 768 >= e:
  23866. k = [18, e - 513, 8];
  23867. break;
  23868. case 1024 >= e:
  23869. k = [19, e - 769, 8];
  23870. break;
  23871. case 1536 >= e:
  23872. k = [20, e - 1025, 9];
  23873. break;
  23874. case 2048 >= e:
  23875. k = [21, e - 1537, 9];
  23876. break;
  23877. case 3072 >= e:
  23878. k = [22, e - 2049, 10];
  23879. break;
  23880. case 4096 >= e:
  23881. k = [23, e - 3073, 10];
  23882. break;
  23883. case 6144 >= e:
  23884. k = [24, e - 4097, 11];
  23885. break;
  23886. case 8192 >= e:
  23887. k = [25, e - 6145, 11];
  23888. break;
  23889. case 12288 >= e:
  23890. k = [26, e - 8193, 12];
  23891. break;
  23892. case 16384 >= e:
  23893. k = [27, e - 12289, 12];
  23894. break;
  23895. case 24576 >= e:
  23896. k = [28, e - 16385, 13];
  23897. break;
  23898. case 32768 >= e:
  23899. k = [29, e - 24577, 13];
  23900. break;
  23901. default:
  23902. a("invalid distance")
  23903. }
  23904. h =
  23905. k;
  23906. f[g++] = h[0];
  23907. f[g++] = h[1];
  23908. f[g++] = h[2];
  23909. e = 0;
  23910. for (g = f.length; e < g; ++e) t[r++] = f[e];
  23911. u[f[0]]++;
  23912. x[f[3]]++;
  23913. s = b.length + c - 1;
  23914. p = null
  23915. }
  23916. var e, f, g, k, m, n = {},
  23917. p, t = w ? new Uint16Array(2 * c.length) : [],
  23918. r = 0,
  23919. s = 0,
  23920. u = new(w ? Uint32Array : Array)(286),
  23921. x = new(w ? Uint32Array : Array)(30),
  23922. y = b.w,
  23923. v;
  23924. if (!w) {
  23925. for (g = 0; 285 >= g;) u[g++] = 0;
  23926. for (g = 0; 29 >= g;) x[g++] = 0
  23927. }
  23928. u[256] = 1;
  23929. e = 0;
  23930. for (f = c.length; e < f; ++e) {
  23931. g = m = 0;
  23932. for (k = 3; g < k && e + g !== f; ++g) m = m << 8 | c[e + g];
  23933. n[m] === D && (n[m] = []);
  23934. g = n[m];
  23935. if (!(0 < s--)) {
  23936. for (; 0 < g.length && 32768 < e - g[0];) g.shift();
  23937. if (e + 3 >= f) {
  23938. p && d(p, -1);
  23939. g = 0;
  23940. for (k = f - e; g < k; ++g) v = c[e + g], t[r++] = v, ++u[v];
  23941. break
  23942. }
  23943. if (0 < g.length) {
  23944. m = k = D;
  23945. var A = 0,
  23946. B = D,
  23947. z = D,
  23948. C = B = D,
  23949. I = c.length,
  23950. z = 0,
  23951. C = g.length;
  23952. a: for (; z < C; z++) {
  23953. k = g[C - z - 1];
  23954. B = 3;
  23955. if (3 < A) {
  23956. for (B = A; 3 < B; B--)
  23957. if (c[k + B - 1] !== c[e + B - 1]) continue a;
  23958. B = A
  23959. }
  23960. for (; 258 > B && e + B < I && c[k + B] === c[e + B];)++B;
  23961. B > A && (m = k, A = B);
  23962. if (258 === B) break
  23963. }
  23964. k = new h(A, e - m);
  23965. p ? p.length < k.length ? (v = c[e - 1], t[r++] = v, ++u[v], d(k, 0)) : d(p, -1) : k.length < y ? p = k : d(k, 0)
  23966. } else p ? d(p, -1) : (v = c[e], t[r++] = v, ++u[v])
  23967. }
  23968. g.push(e)
  23969. }
  23970. t[r++] = 256;
  23971. u[256]++;
  23972. b.L = u;
  23973. b.K = x;
  23974. return w ? t.subarray(0, r) : t
  23975. }
  23976. function n(a,
  23977. b) {
  23978. function c(a) {
  23979. var b = t[a][r[a]];
  23980. b === n ? (c(a + 1), c(a + 1)) : --p[b];
  23981. ++r[a]
  23982. }
  23983. var d = a.length,
  23984. f = new e(572),
  23985. g = new(w ? Uint8Array : Array)(d),
  23986. h, k, m;
  23987. if (!w)
  23988. for (k = 0; k < d; k++) g[k] = 0;
  23989. for (k = 0; k < d; ++k) 0 < a[k] && f.push(k, a[k]);
  23990. d = Array(f.length / 2);
  23991. h = new(w ? Uint32Array : Array)(f.length / 2);
  23992. if (1 === d.length) return g[f.pop().index] = 1, g;
  23993. k = 0;
  23994. for (m = f.length / 2; k < m; ++k) d[k] = f.pop(), h[k] = d[k].value;
  23995. var n = h.length;
  23996. k = new(w ? Uint16Array : Array)(b);
  23997. var f = new(w ? Uint8Array : Array)(b),
  23998. p = new(w ? Uint8Array : Array)(n);
  23999. m = Array(b);
  24000. var t = Array(b),
  24001. r =
  24002. Array(b),
  24003. s = (1 << b) - n,
  24004. u = 1 << b - 1,
  24005. v, x, y;
  24006. k[b - 1] = n;
  24007. for (v = 0; v < b; ++v) s < u ? f[v] = 0 : (f[v] = 1, s -= u), s <<= 1, k[b - 2 - v] = (k[b - 1 - v] / 2 | 0) + n;
  24008. k[0] = f[0];
  24009. m[0] = Array(k[0]);
  24010. t[0] = Array(k[0]);
  24011. for (v = 1; v < b; ++v) k[v] > 2 * k[v - 1] + f[v] && (k[v] = 2 * k[v - 1] + f[v]), m[v] = Array(k[v]), t[v] = Array(k[v]);
  24012. for (s = 0; s < n; ++s) p[s] = b;
  24013. for (u = 0; u < k[b - 1]; ++u) m[b - 1][u] = h[u], t[b - 1][u] = u;
  24014. for (s = 0; s < b; ++s) r[s] = 0;
  24015. 1 === f[b - 1] && (--p[0], ++r[b - 1]);
  24016. for (v = b - 2; 0 <= v; --v) {
  24017. x = s = 0;
  24018. y = r[v + 1];
  24019. for (u = 0; u < k[v]; u++) x = m[v + 1][y] + m[v + 1][y + 1], x > h[s] ? (m[v][u] = x, t[v][u] = n, y += 2) : (m[v][u] = h[s],
  24020. t[v][u] = s, ++s);
  24021. r[v] = 0;
  24022. 1 === f[v] && c(v)
  24023. }
  24024. h = p;
  24025. k = 0;
  24026. for (m = d.length; k < m; ++k) g[d[k].index] = h[k];
  24027. return g
  24028. }
  24029. function p(b) {
  24030. var c = new(w ? Uint16Array : Array)(b.length),
  24031. d = [],
  24032. e = [],
  24033. f = 0,
  24034. g, h, k;
  24035. g = 0;
  24036. for (h = b.length; g < h; g++) d[b[g]] = (d[b[g]] | 0) + 1;
  24037. g = 1;
  24038. for (h = 16; g <= h; g++) e[g] = f, f += d[g] | 0, f > 1 << g && a("overcommitted"), f <<= 1;
  24039. 65536 > f && a("undercommitted");
  24040. g = 0;
  24041. for (h = b.length; g < h; g++)
  24042. for (f = e[b[g]], e[b[g]] += 1, d = c[g] = 0, k = b[g]; d < k; d++) c[g] = c[g] << 1 | f & 1, f >>>= 1;
  24043. return c
  24044. }
  24045. function t(a, b) {
  24046. this.input = a;
  24047. this.a = new(w ? Uint8Array : Array)(32768);
  24048. this.h =
  24049. I.j;
  24050. var c = {},
  24051. d;
  24052. !b && (b = {}) || "number" !== typeof b.compressionType || (this.h = b.compressionType);
  24053. for (d in b) c[d] = b[d];
  24054. c.outputBuffer = this.a;
  24055. this.z = new g(this.input, c)
  24056. }
  24057. function r(b, c) {
  24058. this.k = [];
  24059. this.l = 32768;
  24060. this.e = this.g = this.c = this.q = 0;
  24061. this.input = w ? new Uint8Array(b) : b;
  24062. this.s = !1;
  24063. this.m = K;
  24064. this.B = !1;
  24065. if (c || !(c = {})) c.index && (this.c = c.index), c.bufferSize && (this.l = c.bufferSize), c.bufferType && (this.m = c.bufferType), c.resize && (this.B = c.resize);
  24066. switch (this.m) {
  24067. case T:
  24068. this.b = 32768;
  24069. this.a = new(w ? Uint8Array : Array)(32768 +
  24070. this.l + 258);
  24071. break;
  24072. case K:
  24073. this.b = 0;
  24074. this.a = new(w ? Uint8Array : Array)(this.l);
  24075. this.f = this.J;
  24076. this.t = this.H;
  24077. this.o = this.I;
  24078. break;
  24079. default:
  24080. a(Error("invalid inflate mode"))
  24081. }
  24082. }
  24083. function u(b, c) {
  24084. for (var d = b.g, e = b.e, f = b.input, g = b.c, h; e < c;) h = f[g++], h === D && a(Error("input buffer is broken")), d |= h << e, e += 8;
  24085. b.g = d >>> c;
  24086. b.e = e - c;
  24087. b.c = g;
  24088. return d & (1 << c) - 1
  24089. }
  24090. function s(b, c) {
  24091. for (var d = b.g, e = b.e, f = b.input, g = b.c, h = c[0], k = c[1], m; e < k;) m = f[g++], m === D && a(Error("input buffer is broken")), d |= m << e, e += 8;
  24092. f = h[d & (1 << k) - 1];
  24093. h = f >>> 16;
  24094. b.g = d >> h;
  24095. b.e =
  24096. e - h;
  24097. b.c = g;
  24098. return f & 65535
  24099. }
  24100. function v(a) {
  24101. function b(a, c, d) {
  24102. var e, f, g, h;
  24103. for (h = 0; h < a;) switch (e = s(this, c), e) {
  24104. case 16:
  24105. for (g = 3 + u(this, 2); g--;) d[h++] = f;
  24106. break;
  24107. case 17:
  24108. for (g = 3 + u(this, 3); g--;) d[h++] = 0;
  24109. f = 0;
  24110. break;
  24111. case 18:
  24112. for (g = 11 + u(this, 7); g--;) d[h++] = 0;
  24113. f = 0;
  24114. break;
  24115. default:
  24116. f = d[h++] = e
  24117. }
  24118. return d
  24119. }
  24120. var c = u(a, 5) + 257,
  24121. d = u(a, 5) + 1,
  24122. e = u(a, 4) + 4,
  24123. g = new(w ? Uint8Array : Array)(U.length),
  24124. h;
  24125. for (h = 0; h < e; ++h) g[U[h]] = u(a, 3);
  24126. e = f(g);
  24127. g = new(w ? Uint8Array : Array)(c);
  24128. h = new(w ? Uint8Array : Array)(d);
  24129. a.o(f(b.call(a, c, e, g)), f(b.call(a, d, e, h)))
  24130. }
  24131. function x(b,
  24132. c) {
  24133. var d, e;
  24134. this.input = b;
  24135. this.c = 0;
  24136. if (c || !(c = {})) c.index && (this.c = c.index), c.verify && (this.M = c.verify);
  24137. d = b[this.c++];
  24138. e = b[this.c++];
  24139. switch (d & 15) {
  24140. case ia:
  24141. this.method = ia;
  24142. break;
  24143. default:
  24144. a(Error("unsupported compression method"))
  24145. }
  24146. 0 !== ((d << 8) + e) % 31 && a(Error("invalid fcheck flag:" + ((d << 8) + e) % 31));
  24147. e & 32 && a(Error("fdict flag is not supported"));
  24148. this.A = new r(b, {
  24149. index: this.c,
  24150. bufferSize: c.bufferSize,
  24151. bufferType: c.bufferType,
  24152. resize: c.resize
  24153. })
  24154. }
  24155. var D = void 0,
  24156. E = !0,
  24157. A = this,
  24158. w = "undefined" !== typeof Uint8Array && "undefined" !==
  24159. typeof Uint16Array && "undefined" !== typeof Uint32Array;
  24160. d.prototype.f = function() {
  24161. var a = this.buffer,
  24162. b, c = a.length,
  24163. d = new(w ? Uint8Array : Array)(c << 1);
  24164. if (w) d.set(a);
  24165. else
  24166. for (b = 0; b < c; ++b) d[b] = a[b];
  24167. return this.buffer = d
  24168. };
  24169. d.prototype.d = function(a, b, c) {
  24170. var d = this.buffer,
  24171. e = this.index,
  24172. f = this.i,
  24173. g = d[e];
  24174. c && 1 < b && (a = 8 < b ? (C[a & 255] << 24 | C[a >>> 8 & 255] << 16 | C[a >>> 16 & 255] << 8 | C[a >>> 24 & 255]) >> 32 - b : C[a] >> 8 - b);
  24175. if (8 > b + f) g = g << b | a, f += b;
  24176. else
  24177. for (c = 0; c < b; ++c) g = g << 1 | a >> b - c - 1 & 1, 8 === ++f && (f = 0, d[e++] = C[g], g = 0, e === d.length && (d = this.f()));
  24178. d[e] = g;
  24179. this.buffer = d;
  24180. this.i = f;
  24181. this.index = e
  24182. };
  24183. d.prototype.finish = function() {
  24184. var a = this.buffer,
  24185. b = this.index,
  24186. c;
  24187. 0 < this.i && (a[b] <<= 8 - this.i, a[b] = C[a[b]], b++);
  24188. w ? c = a.subarray(0, b) : (a.length = b, c = a);
  24189. return c
  24190. };
  24191. var B = new(w ? Uint8Array : Array)(256),
  24192. y;
  24193. for (y = 0; 256 > y; ++y) {
  24194. for (var z = y, F = z, J = 7, z = z >>> 1; z; z >>>= 1) F <<= 1, F |= z & 1, --J;
  24195. B[y] = (F << J & 255) >>> 0
  24196. }
  24197. var C = B,
  24198. B = [0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049,
  24199. 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,
  24200. 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,
  24201. 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,
  24202. 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,
  24203. 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,
  24204. 711928724, 3020668471, 3272380065, 1510334235, 755167117
  24205. ];
  24206. w && new Uint32Array(B);
  24207. e.prototype.getParent = function(a) {
  24208. return 2 * ((a - 2) / 4 | 0)
  24209. };
  24210. e.prototype.push = function(a, b) {
  24211. var c, d, e = this.buffer,
  24212. f;
  24213. c = this.length;
  24214. e[this.length++] = b;
  24215. for (e[this.length++] = a; 0 < c;)
  24216. if (d = this.getParent(c), e[c] > e[d]) f = e[c], e[c] = e[d], e[d] = f, f = e[c + 1], e[c + 1] = e[d + 1], e[d + 1] = f, c = d;
  24217. else break;
  24218. return this.length
  24219. };
  24220. e.prototype.pop = function() {
  24221. var a, b, c = this.buffer,
  24222. d, e, f;
  24223. b = c[0];
  24224. a = c[1];
  24225. this.length -= 2;
  24226. c[0] = c[this.length];
  24227. c[1] = c[this.length + 1];
  24228. for (f =
  24229. 0;;) {
  24230. e = 2 * f + 2;
  24231. if (e >= this.length) break;
  24232. e + 2 < this.length && c[e + 2] > c[e] && (e += 2);
  24233. if (c[e] > c[f]) d = c[f], c[f] = c[e], c[e] = d, d = c[f + 1], c[f + 1] = c[e + 1], c[e + 1] = d;
  24234. else break;
  24235. f = e
  24236. }
  24237. return {
  24238. index: a,
  24239. value: b,
  24240. length: this.length
  24241. }
  24242. };
  24243. var N = 2,
  24244. B = {
  24245. NONE: 0,
  24246. r: 1,
  24247. j: N,
  24248. N: 3
  24249. },
  24250. L = [];
  24251. for (y = 0; 288 > y; y++) switch (E) {
  24252. case 143 >= y:
  24253. L.push([y + 48, 8]);
  24254. break;
  24255. case 255 >= y:
  24256. L.push([y - 144 + 400, 9]);
  24257. break;
  24258. case 279 >= y:
  24259. L.push([y - 256 + 0, 7]);
  24260. break;
  24261. case 287 >= y:
  24262. L.push([y - 280 + 192, 8]);
  24263. break;
  24264. default:
  24265. a("invalid literal: " + y)
  24266. }
  24267. g.prototype.n = function() {
  24268. var b, c, e, f, g = this.input;
  24269. switch (this.h) {
  24270. case 0:
  24271. e = 0;
  24272. for (f = g.length; e < f;) {
  24273. c = w ? g.subarray(e, e + 65535) : g.slice(e, e + 65535);
  24274. e += c.length;
  24275. var h = e === f,
  24276. k = D,
  24277. t = k = D,
  24278. t = k = D,
  24279. r = this.a,
  24280. s = this.b;
  24281. if (w) {
  24282. for (r = new Uint8Array(this.a.buffer); r.length <= s + c.length + 5;) r = new Uint8Array(r.length << 1);
  24283. r.set(this.a)
  24284. }
  24285. k = h ? 1 : 0;
  24286. r[s++] = k | 0;
  24287. k = c.length;
  24288. t = ~k + 65536 & 65535;
  24289. r[s++] = k & 255;
  24290. r[s++] = k >>> 8 & 255;
  24291. r[s++] = t & 255;
  24292. r[s++] = t >>> 8 & 255;
  24293. if (w) r.set(c, s), s += c.length, r = r.subarray(0, s);
  24294. else {
  24295. k = 0;
  24296. for (t = c.length; k < t; ++k) r[s++] = c[k];
  24297. r.length = s
  24298. }
  24299. this.b = s;
  24300. this.a = r
  24301. }
  24302. break;
  24303. case 1:
  24304. e =
  24305. new d(new Uint8Array(this.a.buffer), this.b);
  24306. e.d(1, 1, E);
  24307. e.d(1, 2, E);
  24308. g = m(this, g);
  24309. c = 0;
  24310. for (h = g.length; c < h; c++)
  24311. if (f = g[c], d.prototype.d.apply(e, L[f]), 256 < f) e.d(g[++c], g[++c], E), e.d(g[++c], 5), e.d(g[++c], g[++c], E);
  24312. else if (256 === f) break;
  24313. this.a = e.finish();
  24314. this.b = this.a.length;
  24315. break;
  24316. case N:
  24317. f = new d(new Uint8Array(this.a), this.b);
  24318. var u, v, x, y = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15],
  24319. A, B, k = Array(19),
  24320. z, r = N;
  24321. f.d(1, 1, E);
  24322. f.d(r, 2, E);
  24323. g = m(this, g);
  24324. t = n(this.L, 15);
  24325. A = p(t);
  24326. r = n(this.K, 7);
  24327. s = p(r);
  24328. for (u = 286; 257 < u && 0 === t[u -
  24329. 1]; u--);
  24330. for (v = 30; 1 < v && 0 === r[v - 1]; v--);
  24331. var C = u,
  24332. I = v;
  24333. b = new(w ? Uint32Array : Array)(C + I);
  24334. var F = new(w ? Uint32Array : Array)(316),
  24335. J, K;
  24336. B = new(w ? Uint8Array : Array)(19);
  24337. for (z = x = 0; z < C; z++) b[x++] = t[z];
  24338. for (z = 0; z < I; z++) b[x++] = r[z];
  24339. if (!w)
  24340. for (z = 0, I = B.length; z < I; ++z) B[z] = 0;
  24341. z = J = 0;
  24342. for (I = b.length; z < I; z += x) {
  24343. for (x = 1; z + x < I && b[z + x] === b[z]; ++x);
  24344. C = x;
  24345. if (0 === b[z])
  24346. if (3 > C)
  24347. for (; 0 < C--;) F[J++] = 0, B[0]++;
  24348. else
  24349. for (; 0 < C;) K = 138 > C ? C : 138, K > C - 3 && K < C && (K = C - 3), 10 >= K ? (F[J++] = 17, F[J++] = K - 3, B[17]++) : (F[J++] = 18, F[J++] = K - 11, B[18]++), C -= K;
  24350. else if (F[J++] =
  24351. b[z], B[b[z]]++, C--, 3 > C)
  24352. for (; 0 < C--;) F[J++] = b[z], B[b[z]]++;
  24353. else
  24354. for (; 0 < C;) K = 6 > C ? C : 6, K > C - 3 && K < C && (K = C - 3), F[J++] = 16, F[J++] = K - 3, B[16]++, C -= K
  24355. }
  24356. b = w ? F.subarray(0, J) : F.slice(0, J);
  24357. B = n(B, 7);
  24358. for (z = 0; 19 > z; z++) k[z] = B[y[z]];
  24359. for (x = 19; 4 < x && 0 === k[x - 1]; x--);
  24360. y = p(B);
  24361. f.d(u - 257, 5, E);
  24362. f.d(v - 1, 5, E);
  24363. f.d(x - 4, 4, E);
  24364. for (z = 0; z < x; z++) f.d(k[z], 3, E);
  24365. z = 0;
  24366. for (k = b.length; z < k; z++)
  24367. if (c = b[z], f.d(y[c], B[c], E), 16 <= c) {
  24368. z++;
  24369. switch (c) {
  24370. case 16:
  24371. h = 2;
  24372. break;
  24373. case 17:
  24374. h = 3;
  24375. break;
  24376. case 18:
  24377. h = 7;
  24378. break;
  24379. default:
  24380. a("invalid code: " + c)
  24381. }
  24382. f.d(b[z], h, E)
  24383. }
  24384. h = [A, t];
  24385. s = [s,
  24386. r
  24387. ];
  24388. c = h[0];
  24389. h = h[1];
  24390. r = s[0];
  24391. A = s[1];
  24392. s = 0;
  24393. for (k = g.length; s < k; ++s)
  24394. if (e = g[s], f.d(c[e], h[e], E), 256 < e) f.d(g[++s], g[++s], E), t = g[++s], f.d(r[t], A[t], E), f.d(g[++s], g[++s], E);
  24395. else if (256 === e) break;
  24396. this.a = f.finish();
  24397. this.b = this.a.length;
  24398. break;
  24399. default:
  24400. a("invalid compression type")
  24401. }
  24402. return this.a
  24403. };
  24404. y = [];
  24405. var P;
  24406. for (P = 3; 258 >= P; P++) z = k(), y[P] = z[2] << 24 | z[1] << 16 | z[0];
  24407. var S = w ? new Uint32Array(y) : y,
  24408. I = B;
  24409. t.prototype.n = function() {
  24410. var b, d, e, f, g = 0;
  24411. f = this.a;
  24412. b = ia;
  24413. switch (b) {
  24414. case ia:
  24415. d = Math.LOG2E * Math.log(32768) - 8;
  24416. break;
  24417. default:
  24418. a(Error("invalid compression method"))
  24419. }
  24420. d =
  24421. d << 4 | b;
  24422. f[g++] = d;
  24423. switch (b) {
  24424. case ia:
  24425. switch (this.h) {
  24426. case I.NONE:
  24427. e = 0;
  24428. break;
  24429. case I.r:
  24430. e = 1;
  24431. break;
  24432. case I.j:
  24433. e = 2;
  24434. break;
  24435. default:
  24436. a(Error("unsupported compression type"))
  24437. }
  24438. break;
  24439. default:
  24440. a(Error("invalid compression method"))
  24441. }
  24442. b = e << 6 | 0;
  24443. f[g++] = b | 31 - (256 * d + b) % 31;
  24444. b = c(this.input);
  24445. this.z.b = g;
  24446. f = this.z.n();
  24447. g = f.length;
  24448. w && (f = new Uint8Array(f.buffer), f.length <= g + 4 && (this.a = new Uint8Array(f.length + 4), this.a.set(f), f = this.a), f = f.subarray(0, g + 4));
  24449. f[g++] = b >> 24 & 255;
  24450. f[g++] = b >> 16 & 255;
  24451. f[g++] = b >> 8 & 255;
  24452. f[g++] = b & 255;
  24453. return f
  24454. };
  24455. b("Zlib.Deflate",
  24456. t);
  24457. b("Zlib.Deflate.compress", function(a, b) {
  24458. return (new t(a, b)).n()
  24459. });
  24460. b("Zlib.Deflate.CompressionType", I);
  24461. b("Zlib.Deflate.CompressionType.NONE", I.NONE);
  24462. b("Zlib.Deflate.CompressionType.FIXED", I.r);
  24463. b("Zlib.Deflate.CompressionType.DYNAMIC", I.j);
  24464. var T = 0,
  24465. K = 1,
  24466. B = {
  24467. D: T,
  24468. C: K
  24469. };
  24470. r.prototype.p = function() {
  24471. for (; !this.s;) {
  24472. var b = u(this, 3);
  24473. b & 1 && (this.s = E);
  24474. b >>>= 1;
  24475. switch (b) {
  24476. case 0:
  24477. var b = this.input,
  24478. c = this.c,
  24479. d = this.a,
  24480. e = this.b,
  24481. f = D,
  24482. g = D,
  24483. h = D,
  24484. k = d.length,
  24485. f = D;
  24486. this.e = this.g = 0;
  24487. f = b[c++];
  24488. f === D && a(Error("invalid uncompressed block header: LEN (first byte)"));
  24489. g = f;
  24490. f = b[c++];
  24491. f === D && a(Error("invalid uncompressed block header: LEN (second byte)"));
  24492. g |= f << 8;
  24493. f = b[c++];
  24494. f === D && a(Error("invalid uncompressed block header: NLEN (first byte)"));
  24495. h = f;
  24496. f = b[c++];
  24497. f === D && a(Error("invalid uncompressed block header: NLEN (second byte)"));
  24498. h |= f << 8;
  24499. g === ~h && a(Error("invalid uncompressed block header: length verify"));
  24500. c + g > b.length && a(Error("input buffer is broken"));
  24501. switch (this.m) {
  24502. case T:
  24503. for (; e + g > d.length;) {
  24504. f = k - e;
  24505. g -= f;
  24506. if (w) d.set(b.subarray(c, c + f), e), e += f, c += f;
  24507. else
  24508. for (; f--;) d[e++] =
  24509. b[c++];
  24510. this.b = e;
  24511. d = this.f();
  24512. e = this.b
  24513. }
  24514. break;
  24515. case K:
  24516. for (; e + g > d.length;) d = this.f({
  24517. v: 2
  24518. });
  24519. break;
  24520. default:
  24521. a(Error("invalid inflate mode"))
  24522. }
  24523. if (w) d.set(b.subarray(c, c + g), e), e += g, c += g;
  24524. else
  24525. for (; g--;) d[e++] = b[c++];
  24526. this.c = c;
  24527. this.b = e;
  24528. this.a = d;
  24529. break;
  24530. case 1:
  24531. this.o(xa, ya);
  24532. break;
  24533. case 2:
  24534. v(this);
  24535. break;
  24536. default:
  24537. a(Error("unknown BTYPE: " + b))
  24538. }
  24539. }
  24540. return this.t()
  24541. };
  24542. y = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  24543. var U = w ? new Uint16Array(y) : y;
  24544. y = [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,
  24545. 258, 258, 258
  24546. ];
  24547. var V = w ? new Uint16Array(y) : y;
  24548. y = [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];
  24549. var aa = w ? new Uint8Array(y) : y;
  24550. y = [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];
  24551. var za = w ? new Uint16Array(y) : y;
  24552. y = [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];
  24553. var X = w ? new Uint8Array(y) : y;
  24554. y = new(w ? Uint8Array : Array)(288);
  24555. z = 0;
  24556. for (F = y.length; z < F; ++z) y[z] = 143 >= z ? 8 : 255 >= z ? 9 : 279 >= z ? 7 : 8;
  24557. var xa = f(y);
  24558. y = new(w ? Uint8Array :
  24559. Array)(30);
  24560. z = 0;
  24561. for (F = y.length; z < F; ++z) y[z] = 5;
  24562. var ya = f(y);
  24563. r.prototype.o = function(a, b) {
  24564. var c = this.a,
  24565. d = this.b;
  24566. this.u = a;
  24567. for (var e = c.length - 258, f, g, h; 256 !== (f = s(this, a));)
  24568. if (256 > f) d >= e && (this.b = d, c = this.f(), d = this.b), c[d++] = f;
  24569. else
  24570. for (f -= 257, h = V[f], 0 < aa[f] && (h += u(this, aa[f])), f = s(this, b), g = za[f], 0 < X[f] && (g += u(this, X[f])), d >= e && (this.b = d, c = this.f(), d = this.b); h--;) c[d] = c[d++-g];
  24571. for (; 8 <= this.e;) this.e -= 8, this.c--;
  24572. this.b = d
  24573. };
  24574. r.prototype.I = function(a, b) {
  24575. var c = this.a,
  24576. d = this.b;
  24577. this.u = a;
  24578. for (var e = c.length, f, g,
  24579. h; 256 !== (f = s(this, a));)
  24580. if (256 > f) d >= e && (c = this.f(), e = c.length), c[d++] = f;
  24581. else
  24582. for (f -= 257, h = V[f], 0 < aa[f] && (h += u(this, aa[f])), f = s(this, b), g = za[f], 0 < X[f] && (g += u(this, X[f])), d + h > e && (c = this.f(), e = c.length); h--;) c[d] = c[d++-g];
  24583. for (; 8 <= this.e;) this.e -= 8, this.c--;
  24584. this.b = d
  24585. };
  24586. r.prototype.f = function() {
  24587. var a = new(w ? Uint8Array : Array)(this.b - 32768),
  24588. b = this.b - 32768,
  24589. c, d, e = this.a;
  24590. if (w) a.set(e.subarray(32768, a.length));
  24591. else
  24592. for (c = 0, d = a.length; c < d; ++c) a[c] = e[c + 32768];
  24593. this.k.push(a);
  24594. this.q += a.length;
  24595. if (w) e.set(e.subarray(b,
  24596. b + 32768));
  24597. else
  24598. for (c = 0; 32768 > c; ++c) e[c] = e[b + c];
  24599. this.b = 32768;
  24600. return e
  24601. };
  24602. r.prototype.J = function(a) {
  24603. var b, c = this.input.length / this.c + 1 | 0,
  24604. d, e, f, g = this.input,
  24605. h = this.a;
  24606. a && ("number" === typeof a.v && (c = a.v), "number" === typeof a.F && (c += a.F));
  24607. 2 > c ? (d = (g.length - this.c) / this.u[2], f = d / 2 * 258 | 0, e = f < h.length ? h.length + f : h.length << 1) : e = h.length * c;
  24608. w ? (b = new Uint8Array(e), b.set(h)) : b = h;
  24609. return this.a = b
  24610. };
  24611. r.prototype.t = function() {
  24612. var a = 0,
  24613. b = this.a,
  24614. c = this.k,
  24615. d, e = new(w ? Uint8Array : Array)(this.q + (this.b - 32768)),
  24616. f, g, h, k;
  24617. if (0 === c.length) return w ?
  24618. this.a.subarray(32768, this.b) : this.a.slice(32768, this.b);
  24619. f = 0;
  24620. for (g = c.length; f < g; ++f)
  24621. for (d = c[f], h = 0, k = d.length; h < k; ++h) e[a++] = d[h];
  24622. f = 32768;
  24623. for (g = this.b; f < g; ++f) e[a++] = b[f];
  24624. this.k = [];
  24625. return this.buffer = e
  24626. };
  24627. r.prototype.H = function() {
  24628. var a, b = this.b;
  24629. w ? this.B ? (a = new Uint8Array(b), a.set(this.a.subarray(0, b))) : a = this.a.subarray(0, b) : (this.a.length > b && (this.a.length = b), a = this.a);
  24630. return this.buffer = a
  24631. };
  24632. x.prototype.p = function() {
  24633. var b = this.input,
  24634. d, e;
  24635. d = this.A.p();
  24636. this.c = this.A.c;
  24637. this.M && (e = (b[this.c++] << 24 | b[this.c++] <<
  24638. 16 | b[this.c++] << 8 | b[this.c++]) >>> 0, e !== c(d) && a(Error("invalid adler-32 checksum")));
  24639. return d
  24640. };
  24641. b("Zlib.Inflate", x);
  24642. b("Zlib.Inflate.BufferType", B);
  24643. B.ADAPTIVE = B.C;
  24644. B.BLOCK = B.D;
  24645. b("Zlib.Inflate.prototype.decompress", x.prototype.p);
  24646. B = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
  24647. w && new Uint16Array(B);
  24648. B = [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];
  24649. w && new Uint16Array(B);
  24650. B = [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];
  24651. w && new Uint8Array(B);
  24652. B = [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];
  24653. w && new Uint16Array(B);
  24654. B = [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];
  24655. w && new Uint8Array(B);
  24656. B = new(w ? Uint8Array : Array)(288);
  24657. y = 0;
  24658. for (z = B.length; y < z; ++y) B[y] = 143 >= y ? 8 : 255 >= y ? 9 : 279 >= y ? 7 : 8;
  24659. f(B);
  24660. B = new(w ? Uint8Array : Array)(30);
  24661. y = 0;
  24662. for (z = B.length; y < z; ++y) B[y] = 5;
  24663. f(B);
  24664. var ia = 8
  24665. }).call(this);
  24666. _p = window;
  24667. _p = _p.Zlib = _p.Zlib;
  24668. _p.Deflate = _p.Deflate;
  24669. _p.Deflate.compress = _p.Deflate.compress;
  24670. _p.Inflate = _p.Inflate;
  24671. _p.Inflate.BufferType = _p.Inflate.BufferType;
  24672. _p.Inflate.prototype.decompress = _p.Inflate.prototype.decompress;
  24673. cc.PNGReader = cc.Class.extend({
  24674. ctor: function(a) {
  24675. var b, c, d, e;
  24676. this.data = a;
  24677. this.pos = 8;
  24678. this.palette = [];
  24679. this.imgData = [];
  24680. this.transparency = {};
  24681. this.animation = null;
  24682. this.text = {};
  24683. for (d = null;;) {
  24684. b = this.readUInt32();
  24685. e = a = void 0;
  24686. e = [];
  24687. for (a = 0; 4 > a; ++a) e.push(String.fromCharCode(this.data[this.pos++]));
  24688. a = e.join("");
  24689. switch (a) {
  24690. case "IHDR":
  24691. this.width = this.readUInt32();
  24692. this.height = this.readUInt32();
  24693. this.bits = this.data[this.pos++];
  24694. this.colorType = this.data[this.pos++];
  24695. this.compressionMethod = this.data[this.pos++];
  24696. this.filterMethod =
  24697. this.data[this.pos++];
  24698. this.interlaceMethod = this.data[this.pos++];
  24699. break;
  24700. case "acTL":
  24701. this.animation = {
  24702. numFrames: this.readUInt32(),
  24703. numPlays: this.readUInt32() || Infinity,
  24704. frames: []
  24705. };
  24706. break;
  24707. case "PLTE":
  24708. this.palette = this.read(b);
  24709. break;
  24710. case "fcTL":
  24711. d && this.animation.frames.push(d);
  24712. this.pos += 4;
  24713. d = {
  24714. width: this.readUInt32(),
  24715. height: this.readUInt32(),
  24716. xOffset: this.readUInt32(),
  24717. yOffset: this.readUInt32()
  24718. };
  24719. a = this.readUInt16();
  24720. b = this.readUInt16() || 100;
  24721. d.delay = 1E3 * a / b;
  24722. d.disposeOp = this.data[this.pos++];
  24723. d.blendOp = this.data[this.pos++];
  24724. d.data = [];
  24725. break;
  24726. case "IDAT":
  24727. case "fdAT":
  24728. "fdAT" === a && (this.pos += 4, b -= 4);
  24729. a = (null != d ? d.data : void 0) || this.imgData;
  24730. for (e = 0; 0 <= b ? e < b : e > b; 0 <= b ? ++e : --e) a.push(this.data[this.pos++]);
  24731. break;
  24732. case "tRNS":
  24733. this.transparency = {};
  24734. switch (this.colorType) {
  24735. case 3:
  24736. this.transparency.indexed = this.read(b);
  24737. b = 255 - this.transparency.indexed.length;
  24738. if (0 < b)
  24739. for (a = 0; 0 <= b ? a < b : a > b; 0 <= b ? ++a : --a) this.transparency.indexed.push(255);
  24740. break;
  24741. case 0:
  24742. this.transparency.grayscale = this.read(b)[0];
  24743. break;
  24744. case 2:
  24745. this.transparency.rgb = this.read(b)
  24746. }
  24747. break;
  24748. case "tEXt":
  24749. e = this.read(b);
  24750. b = e.indexOf(0);
  24751. a = String.fromCharCode.apply(String, e.slice(0, b));
  24752. this.text[a] = String.fromCharCode.apply(String, e.slice(b + 1));
  24753. break;
  24754. case "IEND":
  24755. d && this.animation.frames.push(d);
  24756. a: {
  24757. switch (this.colorType) {
  24758. case 0:
  24759. case 3:
  24760. case 4:
  24761. d = 1;
  24762. break a;
  24763. case 2:
  24764. case 6:
  24765. d = 3;
  24766. break a
  24767. }
  24768. d = void 0
  24769. }
  24770. this.colors = d;
  24771. this.hasAlphaChannel = 4 === (c = this.colorType) || 6 === c;
  24772. c = this.colors + (this.hasAlphaChannel ? 1 : 0);
  24773. this.pixelBitlength = this.bits * c;
  24774. a: {
  24775. switch (this.colors) {
  24776. case 1:
  24777. c = "DeviceGray";
  24778. break a;
  24779. case 3:
  24780. c = "DeviceRGB";
  24781. break a
  24782. }
  24783. c = void 0
  24784. }
  24785. this.colorSpace = c;
  24786. Uint8Array != Array && (this.imgData = new Uint8Array(this.imgData));
  24787. return;
  24788. default:
  24789. this.pos += b
  24790. }
  24791. this.pos += 4;
  24792. if (this.pos > this.data.length) throw Error("Incomplete or corrupt PNG file");
  24793. }
  24794. },
  24795. read: function(a) {
  24796. var b, c;
  24797. c = [];
  24798. for (b = 0; 0 <= a ? b < a : b > a; 0 <= a ? ++b : --b) c.push(this.data[this.pos++]);
  24799. return c
  24800. },
  24801. readUInt32: function() {
  24802. var a, b, c, d;
  24803. a = this.data[this.pos++] << 24;
  24804. b = this.data[this.pos++] << 16;
  24805. c = this.data[this.pos++] << 8;
  24806. d = this.data[this.pos++];
  24807. return a | b | c | d
  24808. },
  24809. readUInt16: function() {
  24810. var a,
  24811. b;
  24812. a = this.data[this.pos++] << 8;
  24813. b = this.data[this.pos++];
  24814. return a | b
  24815. },
  24816. decodePixels: function(a) {
  24817. var b, c, d, e, f, g, h, k, m, n, p, t, r, u, s;
  24818. null == a && (a = this.imgData);
  24819. if (0 === a.length) return new Uint8Array(0);
  24820. a = (new Zlib.Inflate(a, {
  24821. index: 0,
  24822. verify: !1
  24823. })).decompress();
  24824. k = this.pixelBitlength / 8;
  24825. t = k * this.width;
  24826. m = new Uint8Array(t * this.height);
  24827. g = a.length;
  24828. for (c = n = p = 0; n < g;) {
  24829. switch (a[n++]) {
  24830. case 0:
  24831. for (b = 0; b < t; b += 1) m[c++] = a[n++];
  24832. break;
  24833. case 1:
  24834. for (e = r = 0; r < t; e = r += 1) b = a[n++], f = e < k ? 0 : m[c - k], m[c++] = (b + f) % 256;
  24835. break;
  24836. case 2:
  24837. for (e = f = 0; f <
  24838. t; e = f += 1) b = a[n++], d = (e - e % k) / k, r = p && m[(p - 1) * t + d * k + e % k], m[c++] = (r + b) % 256;
  24839. break;
  24840. case 3:
  24841. for (e = s = 0; s < t; e = s += 1) b = a[n++], d = (e - e % k) / k, f = e < k ? 0 : m[c - k], r = p && m[(p - 1) * t + d * k + e % k], m[c++] = (b + Math.floor((f + r) / 2)) % 256;
  24842. break;
  24843. case 4:
  24844. for (e = s = 0; s < t; e = s += 1) b = a[n++], d = (e - e % k) / k, f = e < k ? 0 : m[c - k], 0 === p ? r = u = 0 : (r = m[(p - 1) * t + d * k + e % k], u = d && m[(p - 1) * t + (d - 1) * k + e % k]), h = f + r - u, e = Math.abs(h - f), d = Math.abs(h - r), h = Math.abs(h - u), f = e <= d && e <= h ? f : d <= h ? r : u, m[c++] = (b + f) % 256;
  24845. break;
  24846. default:
  24847. throw Error("Invalid filter algorithm: " + a[n - 1]);
  24848. }
  24849. p++
  24850. }
  24851. return m
  24852. },
  24853. copyToImageData: function(a, b) {
  24854. var c, d, e, f, g, h, k, m;
  24855. d = this.colors;
  24856. m = null;
  24857. c = this.hasAlphaChannel;
  24858. this.palette.length && (m = null != (e = this._decodedPalette) ? e : this._decodedPalette = this.decodePalette(), d = 4, c = !0);
  24859. e = a.data || a;
  24860. k = e.length;
  24861. g = m || b;
  24862. f = h = 0;
  24863. if (1 === d)
  24864. for (; f < k;) d = m ? 4 * b[f / 4] : h, h = g[d++], e[f++] = h, e[f++] = h, e[f++] = h, e[f++] = c ? g[d++] : 255, h = d;
  24865. else
  24866. for (; f < k;) d = m ? 4 * b[f / 4] : h, e[f++] = g[d++], e[f++] = g[d++], e[f++] = g[d++], e[f++] = c ? g[d++] : 255, h = d
  24867. },
  24868. decodePalette: function() {
  24869. var a, b, c, d, e, f, g, h, k;
  24870. c = this.palette;
  24871. f = this.transparency.indexed || [];
  24872. e = new Uint8Array((f.length || 0) + c.length);
  24873. b = g = a = d = 0;
  24874. for (h = c.length; g < h; b = g += 3) e[d++] = c[b], e[d++] = c[b + 1], e[d++] = c[b + 2], e[d++] = null != (k = f[a++]) ? k : 255;
  24875. return e
  24876. },
  24877. render: function(a) {
  24878. var b;
  24879. a.width = this.width;
  24880. a.height = this.height;
  24881. a = a.getContext("2d");
  24882. b = a.createImageData(this.width, this.height);
  24883. this.copyToImageData(b, this.decodePixels());
  24884. return a.putImageData(b, 0, 0)
  24885. }
  24886. });
  24887. cc.tiffReader = {
  24888. _littleEndian: !1,
  24889. _tiffData: null,
  24890. _fileDirectories: [],
  24891. getUint8: function(a) {
  24892. return this._tiffData[a]
  24893. },
  24894. getUint16: function(a) {
  24895. return this._littleEndian ? this._tiffData[a + 1] << 8 | this._tiffData[a] : this._tiffData[a] << 8 | this._tiffData[a + 1]
  24896. },
  24897. getUint32: function(a) {
  24898. var b = this._tiffData;
  24899. return this._littleEndian ? b[a + 3] << 24 | b[a + 2] << 16 | b[a + 1] << 8 | b[a] : b[a] << 24 | b[a + 1] << 16 | b[a + 2] << 8 | b[a + 3]
  24900. },
  24901. checkLittleEndian: function() {
  24902. var a = this.getUint16(0);
  24903. if (18761 === a) this.littleEndian = !0;
  24904. else if (19789 === a) this.littleEndian = !1;
  24905. else throw console.log(a), TypeError("Invalid byte order value.");
  24906. return this.littleEndian
  24907. },
  24908. hasTowel: function() {
  24909. if (42 !== this.getUint16(2)) throw RangeError("You forgot your towel!");
  24910. return !0
  24911. },
  24912. getFieldTypeName: function(a) {
  24913. var b = this.fieldTypeNames;
  24914. return a in b ? b[a] : null
  24915. },
  24916. getFieldTagName: function(a) {
  24917. var b = this.fieldTagNames;
  24918. if (a in b) return b[a];
  24919. console.log("Unknown Field Tag:", a);
  24920. return "Tag" + a
  24921. },
  24922. getFieldTypeLength: function(a) {
  24923. return -1 !== ["BYTE", "ASCII", "SBYTE", "UNDEFINED"].indexOf(a) ? 1 : -1 !== ["SHORT",
  24924. "SSHORT"
  24925. ].indexOf(a) ? 2 : -1 !== ["LONG", "SLONG", "FLOAT"].indexOf(a) ? 4 : -1 !== ["RATIONAL", "SRATIONAL", "DOUBLE"].indexOf(a) ? 8 : null
  24926. },
  24927. getFieldValues: function(a, b, c, d) {
  24928. a = [];
  24929. var e = this.getFieldTypeLength(b);
  24930. if (4 >= e * c)!1 === this.littleEndian ? a.push(d >>> 8 * (4 - e)) : a.push(d);
  24931. else
  24932. for (var f = 0; f < c; f++) {
  24933. var g = e * f;
  24934. 8 <= e ? -1 !== ["RATIONAL", "SRATIONAL"].indexOf(b) ? (a.push(this.getUint32(d + g)), a.push(this.getUint32(d + g + 4))) : cc.log("Can't handle this field type or size") : a.push(this.getBytes(e, d + g))
  24935. }
  24936. "ASCII" === b && a.forEach(function(a,
  24937. b, c) {
  24938. c[b] = String.fromCharCode(a)
  24939. });
  24940. return a
  24941. },
  24942. getBytes: function(a, b) {
  24943. if (0 >= a) cc.log("No bytes requested");
  24944. else {
  24945. if (1 >= a) return this.getUint8(b);
  24946. if (2 >= a) return this.getUint16(b);
  24947. if (3 >= a) return this.getUint32(b) >>> 8;
  24948. if (4 >= a) return this.getUint32(b);
  24949. cc.log("Too many bytes requested")
  24950. }
  24951. },
  24952. getBits: function(a, b, c) {
  24953. c = c || 0;
  24954. b += Math.floor(c / 8);
  24955. var d = c + a;
  24956. a = 32 - a;
  24957. var e, f;
  24958. 0 >= d ? console.log("No bits requested") : 8 >= d ? (e = 24 + c, f = this.getUint8(b)) : 16 >= d ? (e = 16 + c, f = this.getUint16(b)) : 32 >= d ? (e = c, f = this.getUint32(b)) : console.log("Too many bits requested");
  24959. return {
  24960. bits: f << e >>> a,
  24961. byteOffset: b + Math.floor(d / 8),
  24962. bitOffset: d % 8
  24963. }
  24964. },
  24965. parseFileDirectory: function(a) {
  24966. var b = this.getUint16(a),
  24967. c = [];
  24968. a += 2;
  24969. for (var d = 0; d < b; a += 12, d++) {
  24970. var e = this.getUint16(a),
  24971. f = this.getUint16(a + 2),
  24972. g = this.getUint32(a + 4),
  24973. h = this.getUint32(a + 8),
  24974. e = this.getFieldTagName(e),
  24975. f = this.getFieldTypeName(f),
  24976. g = this.getFieldValues(e, f, g, h);
  24977. c[e] = {
  24978. type: f,
  24979. values: g
  24980. }
  24981. }
  24982. this._fileDirectories.push(c);
  24983. b = this.getUint32(a);
  24984. 0 !== b && this.parseFileDirectory(b)
  24985. },
  24986. clampColorSample: function(a, b) {
  24987. var c = Math.pow(2, 8 - b);
  24988. return Math.floor(a *
  24989. c + (c - 1))
  24990. },
  24991. parseTIFF: function(a, b) {
  24992. b = b || cc.newElement("canvas");
  24993. this._tiffData = a;
  24994. this.canvas = b;
  24995. this.checkLittleEndian();
  24996. if (this.hasTowel()) {
  24997. var c = this.getUint32(4);
  24998. this._fileDirectories.length = 0;
  24999. this.parseFileDirectory(c);
  25000. var d = this._fileDirectories[0],
  25001. c = d.ImageWidth.values[0],
  25002. e = d.ImageLength.values[0];
  25003. this.canvas.width = c;
  25004. this.canvas.height = e;
  25005. var f = [],
  25006. g = d.Compression ? d.Compression.values[0] : 1,
  25007. h = d.SamplesPerPixel.values[0],
  25008. k = [],
  25009. m = 0,
  25010. n = !1;
  25011. d.BitsPerSample.values.forEach(function(a, b, c) {
  25012. k[b] = {
  25013. bitsPerSample: a,
  25014. hasBytesPerSample: !1,
  25015. bytesPerSample: void 0
  25016. };
  25017. 0 === a % 8 && (k[b].hasBytesPerSample = !0, k[b].bytesPerSample = a / 8);
  25018. m += a
  25019. }, this);
  25020. if (0 === m % 8) var n = !0,
  25021. p = m / 8;
  25022. var t = d.StripOffsets.values,
  25023. r = t.length;
  25024. if (d.StripByteCounts) var u = d.StripByteCounts.values;
  25025. else if (cc.log("Missing StripByteCounts!"), 1 === r) u = [Math.ceil(c * e * m / 8)];
  25026. else throw Error("Cannot recover from missing StripByteCounts");
  25027. for (var s = 0; s < r; s++) {
  25028. var v = t[s];
  25029. f[s] = [];
  25030. for (var x = u[s], D = 0, E = 0, A = 1, w = !0, B = [], y = 0, z = 0, F = 0; D < x; D += A) switch (g) {
  25031. case 1:
  25032. A = 0;
  25033. for (B = []; A < h; A++)
  25034. if (k[A].hasBytesPerSample) B.push(this.getBytes(k[A].bytesPerSample,
  25035. v + D + k[A].bytesPerSample * A));
  25036. else {
  25037. var J = this.getBits(k[A].bitsPerSample, v + D, E);
  25038. B.push(J.bits);
  25039. D = J.byteOffset - v;
  25040. E = J.bitOffset;
  25041. throw RangeError("Cannot handle sub-byte bits per sample");
  25042. }
  25043. f[s].push(B);
  25044. if (n) A = p;
  25045. else throw A = 0, RangeError("Cannot handle sub-byte bits per pixel");
  25046. break;
  25047. case 32773:
  25048. if (w) {
  25049. var w = !1,
  25050. C = 1,
  25051. N = 1,
  25052. A = this.getInt8(v + D);
  25053. 0 <= A && 127 >= A ? C = A + 1 : -127 <= A && -1 >= A ? N = -A + 1 : w = !0
  25054. } else {
  25055. for (var L = this.getUint8(v + D), A = 0; A < N; A++) {
  25056. if (k[z].hasBytesPerSample) F = F << 8 * y | L, y++, y === k[z].bytesPerSample && (B.push(F),
  25057. F = y = 0, z++);
  25058. else throw RangeError("Cannot handle sub-byte bits per sample");
  25059. z === h && (f[s].push(B), B = [], z = 0)
  25060. }
  25061. C--;
  25062. 0 === C && (w = !0)
  25063. }
  25064. A = 1
  25065. }
  25066. }
  25067. if (b.getContext) {
  25068. p = this.canvas.getContext("2d");
  25069. p.fillStyle = "rgba(255, 255, 255, 0)";
  25070. s = d.RowsPerStrip ? d.RowsPerStrip.values[0] : e;
  25071. v = f.length;
  25072. e %= s;
  25073. e = 0 === e ? s : e;
  25074. D = s;
  25075. g = 0;
  25076. B = d.PhotometricInterpretation.values[0];
  25077. C = [];
  25078. N = 0;
  25079. d.ExtraSamples && (C = d.ExtraSamples.values, N = C.length);
  25080. if (d.ColorMap) var J = d.ColorMap.values,
  25081. P = Math.pow(2, k[0].bitsPerSample);
  25082. for (s = 0; s < v; s++) {
  25083. s + 1 === v && (D = e);
  25084. d =
  25085. f[s].length;
  25086. g *= s;
  25087. for (n = h = 0; h < D, n < d; h++)
  25088. for (t = 0; t < c; t++, n++) {
  25089. u = f[s][n];
  25090. w = E = x = 0;
  25091. r = 1;
  25092. if (0 < N)
  25093. for (x = 0; x < N; x++)
  25094. if (1 === C[x] || 2 === C[x]) {
  25095. r = u[3 + x] / 256;
  25096. break
  25097. }
  25098. switch (B) {
  25099. case 0:
  25100. if (k[0].hasBytesPerSample) var S = Math.pow(16, 2 * k[0].bytesPerSample);
  25101. u.forEach(function(a, b, c) {
  25102. c[b] = S - a
  25103. });
  25104. case 1:
  25105. x = E = w = this.clampColorSample(u[0], k[0].bitsPerSample);
  25106. break;
  25107. case 2:
  25108. x = this.clampColorSample(u[0], k[0].bitsPerSample);
  25109. E = this.clampColorSample(u[1], k[1].bitsPerSample);
  25110. w = this.clampColorSample(u[2], k[2].bitsPerSample);
  25111. break;
  25112. case 3:
  25113. if (void 0 ===
  25114. J) throw Error("Palette image missing color map");
  25115. u = u[0];
  25116. x = this.clampColorSample(J[u], 16);
  25117. E = this.clampColorSample(J[P + u], 16);
  25118. w = this.clampColorSample(J[2 * P + u], 16);
  25119. break;
  25120. default:
  25121. throw RangeError("Unknown Photometric Interpretation:", B);
  25122. }
  25123. p.fillStyle = "rgba(" + x + ", " + E + ", " + w + ", " + r + ")";
  25124. p.fillRect(t, g + h, 1, 1)
  25125. }
  25126. g = D
  25127. }
  25128. }
  25129. return this.canvas
  25130. }
  25131. },
  25132. fieldTagNames: {
  25133. 315: "Artist",
  25134. 258: "BitsPerSample",
  25135. 265: "CellLength",
  25136. 264: "CellWidth",
  25137. 320: "ColorMap",
  25138. 259: "Compression",
  25139. 33432: "Copyright",
  25140. 306: "DateTime",
  25141. 338: "ExtraSamples",
  25142. 266: "FillOrder",
  25143. 289: "FreeByteCounts",
  25144. 288: "FreeOffsets",
  25145. 291: "GrayResponseCurve",
  25146. 290: "GrayResponseUnit",
  25147. 316: "HostComputer",
  25148. 270: "ImageDescription",
  25149. 257: "ImageLength",
  25150. 256: "ImageWidth",
  25151. 271: "Make",
  25152. 281: "MaxSampleValue",
  25153. 280: "MinSampleValue",
  25154. 272: "Model",
  25155. 254: "NewSubfileType",
  25156. 274: "Orientation",
  25157. 262: "PhotometricInterpretation",
  25158. 284: "PlanarConfiguration",
  25159. 296: "ResolutionUnit",
  25160. 278: "RowsPerStrip",
  25161. 277: "SamplesPerPixel",
  25162. 305: "Software",
  25163. 279: "StripByteCounts",
  25164. 273: "StripOffsets",
  25165. 255: "SubfileType",
  25166. 263: "Threshholding",
  25167. 282: "XResolution",
  25168. 283: "YResolution",
  25169. 326: "BadFaxLines",
  25170. 327: "CleanFaxData",
  25171. 343: "ClipPath",
  25172. 328: "ConsecutiveBadFaxLines",
  25173. 433: "Decode",
  25174. 434: "DefaultImageColor",
  25175. 269: "DocumentName",
  25176. 336: "DotRange",
  25177. 321: "HalftoneHints",
  25178. 346: "Indexed",
  25179. 347: "JPEGTables",
  25180. 285: "PageName",
  25181. 297: "PageNumber",
  25182. 317: "Predictor",
  25183. 319: "PrimaryChromaticities",
  25184. 532: "ReferenceBlackWhite",
  25185. 339: "SampleFormat",
  25186. 559: "StripRowCounts",
  25187. 330: "SubIFDs",
  25188. 292: "T4Options",
  25189. 293: "T6Options",
  25190. 325: "TileByteCounts",
  25191. 323: "TileLength",
  25192. 324: "TileOffsets",
  25193. 322: "TileWidth",
  25194. 301: "TransferFunction",
  25195. 318: "WhitePoint",
  25196. 344: "XClipPathUnits",
  25197. 286: "XPosition",
  25198. 529: "YCbCrCoefficients",
  25199. 531: "YCbCrPositioning",
  25200. 530: "YCbCrSubSampling",
  25201. 345: "YClipPathUnits",
  25202. 287: "YPosition",
  25203. 37378: "ApertureValue",
  25204. 40961: "ColorSpace",
  25205. 36868: "DateTimeDigitized",
  25206. 36867: "DateTimeOriginal",
  25207. 34665: "Exif IFD",
  25208. 36864: "ExifVersion",
  25209. 33434: "ExposureTime",
  25210. 41728: "FileSource",
  25211. 37385: "Flash",
  25212. 40960: "FlashpixVersion",
  25213. 33437: "FNumber",
  25214. 42016: "ImageUniqueID",
  25215. 37384: "LightSource",
  25216. 37500: "MakerNote",
  25217. 37377: "ShutterSpeedValue",
  25218. 37510: "UserComment",
  25219. 33723: "IPTC",
  25220. 34675: "ICC Profile",
  25221. 700: "XMP",
  25222. 42112: "GDAL_METADATA",
  25223. 42113: "GDAL_NODATA",
  25224. 34377: "Photoshop"
  25225. },
  25226. fieldTypeNames: {
  25227. 1: "BYTE",
  25228. 2: "ASCII",
  25229. 3: "SHORT",
  25230. 4: "LONG",
  25231. 5: "RATIONAL",
  25232. 6: "SBYTE",
  25233. 7: "UNDEFINED",
  25234. 8: "SSHORT",
  25235. 9: "SLONG",
  25236. 10: "SRATIONAL",
  25237. 11: "FLOAT",
  25238. 12: "DOUBLE"
  25239. }
  25240. };
  25241. cc.Particle = function(a, b, c, d, e, f, g, h, k, m, n, p) {
  25242. this.pos = a ? a : cc.p(0, 0);
  25243. this.startPos = b ? b : cc.p(0, 0);
  25244. this.color = c ? c : {
  25245. r: 0,
  25246. g: 0,
  25247. b: 0,
  25248. a: 255
  25249. };
  25250. this.deltaColor = d ? d : {
  25251. r: 0,
  25252. g: 0,
  25253. b: 0,
  25254. a: 255
  25255. };
  25256. this.size = e || 0;
  25257. this.deltaSize = f || 0;
  25258. this.rotation = g || 0;
  25259. this.deltaRotation = h || 0;
  25260. this.timeToLive = k || 0;
  25261. this.atlasIndex = m || 0;
  25262. this.modeA = n ? n : new cc.Particle.ModeA;
  25263. this.modeB = p ? p : new cc.Particle.ModeB;
  25264. this.isChangeColor = !1;
  25265. this.drawPos = cc.p(0, 0)
  25266. };
  25267. cc.Particle.ModeA = function(a, b, c) {
  25268. this.dir = a ? a : cc.p(0, 0);
  25269. this.radialAccel = b || 0;
  25270. this.tangentialAccel = c || 0
  25271. };
  25272. cc.Particle.ModeB = function(a, b, c, d) {
  25273. this.angle = a || 0;
  25274. this.degreesPerSecond = b || 0;
  25275. this.radius = c || 0;
  25276. this.deltaRadius = d || 0
  25277. };
  25278. cc.Particle.TemporaryPoints = [cc.p(), cc.p(), cc.p(), cc.p()];
  25279. cc.ParticleSystem = cc.Node.extend({
  25280. _className: "ParticleSystem",
  25281. _plistFile: "",
  25282. _elapsed: 0,
  25283. _dontTint: !1,
  25284. modeA: null,
  25285. modeB: null,
  25286. _pointZeroForParticle: cc.p(0, 0),
  25287. _particles: null,
  25288. _emitCounter: 0,
  25289. _particleIdx: 0,
  25290. _batchNode: null,
  25291. atlasIndex: 0,
  25292. _transformSystemDirty: !1,
  25293. _allocatedParticles: 0,
  25294. _isActive: !1,
  25295. particleCount: 0,
  25296. duration: 0,
  25297. _sourcePosition: null,
  25298. _posVar: null,
  25299. life: 0,
  25300. lifeVar: 0,
  25301. angle: 0,
  25302. angleVar: 0,
  25303. startSize: 0,
  25304. startSizeVar: 0,
  25305. endSize: 0,
  25306. endSizeVar: 0,
  25307. _startColor: null,
  25308. _startColorVar: null,
  25309. _endColor: null,
  25310. _endColorVar: null,
  25311. startSpin: 0,
  25312. startSpinVar: 0,
  25313. endSpin: 0,
  25314. endSpinVar: 0,
  25315. emissionRate: 0,
  25316. _totalParticles: 0,
  25317. _texture: null,
  25318. _blendFunc: null,
  25319. _opacityModifyRGB: !1,
  25320. positionType: null,
  25321. autoRemoveOnFinish: !1,
  25322. emitterMode: 0,
  25323. _textureLoaded: null,
  25324. ctor: function(a) {
  25325. cc.Node.prototype.ctor.call(this);
  25326. this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
  25327. this.modeA = new cc.ParticleSystem.ModeA;
  25328. this.modeB = new cc.ParticleSystem.ModeB;
  25329. this._blendFunc = {
  25330. src: cc.BLEND_SRC,
  25331. dst: cc.BLEND_DST
  25332. };
  25333. this._particles = [];
  25334. this._sourcePosition = cc.p(0, 0);
  25335. this._posVar = cc.p(0,
  25336. 0);
  25337. this._startColor = cc.color(255, 255, 255, 255);
  25338. this._startColorVar = cc.color(255, 255, 255, 255);
  25339. this._endColor = cc.color(255, 255, 255, 255);
  25340. this._endColorVar = cc.color(255, 255, 255, 255);
  25341. this._plistFile = "";
  25342. this._elapsed = 0;
  25343. this._dontTint = !1;
  25344. this._pointZeroForParticle = cc.p(0, 0);
  25345. this._particleIdx = this._emitCounter = 0;
  25346. this._batchNode = null;
  25347. this.atlasIndex = 0;
  25348. this._transformSystemDirty = !1;
  25349. this._allocatedParticles = 0;
  25350. this._isActive = !1;
  25351. this._totalParticles = this.emissionRate = this.endSpinVar = this.endSpin = this.startSpinVar =
  25352. this.startSpin = this.endSizeVar = this.endSize = this.startSizeVar = this.startSize = this.angleVar = this.angle = this.lifeVar = this.life = this.duration = this.particleCount = 0;
  25353. this._texture = null;
  25354. this._opacityModifyRGB = !1;
  25355. this.positionType = cc.ParticleSystem.TYPE_FREE;
  25356. this.autoRemoveOnFinish = !1;
  25357. this._textureLoaded = !0;
  25358. !a || cc.isNumber(a) ? (a = a || 100, this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE), this.initWithTotalParticles(a)) : cc.isString(a) ? this.initWithFile(a) : cc.isObject(a) && this.initWithDictionary(a, "")
  25359. },
  25360. _createRenderCmd: function() {
  25361. return cc._renderType ===
  25362. cc._RENDER_TYPE_CANVAS ? new cc.ParticleSystem.CanvasRenderCmd(this) : new cc.ParticleSystem.WebGLRenderCmd(this)
  25363. },
  25364. ignoreColor: function(a) {
  25365. this._dontTint = a
  25366. },
  25367. initTexCoordsWithRect: function(a) {
  25368. this._renderCmd.initTexCoordsWithRect(a)
  25369. },
  25370. getBatchNode: function() {
  25371. return this._batchNode
  25372. },
  25373. setBatchNode: function(a) {
  25374. this._renderCmd.setBatchNode(a)
  25375. },
  25376. getAtlasIndex: function() {
  25377. return this.atlasIndex
  25378. },
  25379. setAtlasIndex: function(a) {
  25380. this.atlasIndex = a
  25381. },
  25382. getDrawMode: function() {
  25383. return this._renderCmd.getDrawMode()
  25384. },
  25385. setDrawMode: function(a) {
  25386. this._renderCmd.setDrawMode(a)
  25387. },
  25388. getShapeType: function() {
  25389. return this._renderCmd.getShapeType()
  25390. },
  25391. setShapeType: function(a) {
  25392. this._renderCmd.setShapeType(a)
  25393. },
  25394. isActive: function() {
  25395. return this._isActive
  25396. },
  25397. getParticleCount: function() {
  25398. return this.particleCount
  25399. },
  25400. setParticleCount: function(a) {
  25401. this.particleCount = a
  25402. },
  25403. getDuration: function() {
  25404. return this.duration
  25405. },
  25406. setDuration: function(a) {
  25407. this.duration = a
  25408. },
  25409. getSourcePosition: function() {
  25410. return {
  25411. x: this._sourcePosition.x,
  25412. y: this._sourcePosition.y
  25413. }
  25414. },
  25415. setSourcePosition: function(a) {
  25416. this._sourcePosition = a
  25417. },
  25418. getPosVar: function() {
  25419. return {
  25420. x: this._posVar.x,
  25421. y: this._posVar.y
  25422. }
  25423. },
  25424. setPosVar: function(a) {
  25425. this._posVar = a
  25426. },
  25427. getLife: function() {
  25428. return this.life
  25429. },
  25430. setLife: function(a) {
  25431. this.life = a
  25432. },
  25433. getLifeVar: function() {
  25434. return this.lifeVar
  25435. },
  25436. setLifeVar: function(a) {
  25437. this.lifeVar = a
  25438. },
  25439. getAngle: function() {
  25440. return this.angle
  25441. },
  25442. setAngle: function(a) {
  25443. this.angle = a
  25444. },
  25445. getAngleVar: function() {
  25446. return this.angleVar
  25447. },
  25448. setAngleVar: function(a) {
  25449. this.angleVar = a
  25450. },
  25451. getGravity: function() {
  25452. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");
  25453. var a = this.modeA.gravity;
  25454. return cc.p(a.x, a.y)
  25455. },
  25456. setGravity: function(a) {
  25457. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");
  25458. this.modeA.gravity = a
  25459. },
  25460. getSpeed: function() {
  25461. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");
  25462. return this.modeA.speed
  25463. },
  25464. setSpeed: function(a) {
  25465. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");
  25466. this.modeA.speed = a
  25467. },
  25468. getSpeedVar: function() {
  25469. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");
  25470. return this.modeA.speedVar
  25471. },
  25472. setSpeedVar: function(a) {
  25473. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
  25474. this.modeA.speedVar = a
  25475. },
  25476. getTangentialAccel: function() {
  25477. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");
  25478. return this.modeA.tangentialAccel
  25479. },
  25480. setTangentialAccel: function(a) {
  25481. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");
  25482. this.modeA.tangentialAccel = a
  25483. },
  25484. getTangentialAccelVar: function() {
  25485. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");
  25486. return this.modeA.tangentialAccelVar
  25487. },
  25488. setTangentialAccelVar: function(a) {
  25489. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY &&
  25490. cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");
  25491. this.modeA.tangentialAccelVar = a
  25492. },
  25493. getRadialAccel: function() {
  25494. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");
  25495. return this.modeA.radialAccel
  25496. },
  25497. setRadialAccel: function(a) {
  25498. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");
  25499. this.modeA.radialAccel = a
  25500. },
  25501. getRadialAccelVar: function() {
  25502. this.emitterMode !==
  25503. cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");
  25504. return this.modeA.radialAccelVar
  25505. },
  25506. setRadialAccelVar: function(a) {
  25507. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
  25508. this.modeA.radialAccelVar = a
  25509. },
  25510. getRotationIsDir: function() {
  25511. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");
  25512. return this.modeA.rotationIsDir
  25513. },
  25514. setRotationIsDir: function(a) {
  25515. this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY && cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");
  25516. this.modeA.rotationIsDir = a
  25517. },
  25518. getStartRadius: function() {
  25519. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
  25520. return this.modeB.startRadius
  25521. },
  25522. setStartRadius: function(a) {
  25523. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");
  25524. this.modeB.startRadius = a
  25525. },
  25526. getStartRadiusVar: function() {
  25527. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");
  25528. return this.modeB.startRadiusVar
  25529. },
  25530. setStartRadiusVar: function(a) {
  25531. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
  25532. this.modeB.startRadiusVar = a
  25533. },
  25534. getEndRadius: function() {
  25535. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");
  25536. return this.modeB.endRadius
  25537. },
  25538. setEndRadius: function(a) {
  25539. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");
  25540. this.modeB.endRadius = a
  25541. },
  25542. getEndRadiusVar: function() {
  25543. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
  25544. return this.modeB.endRadiusVar
  25545. },
  25546. setEndRadiusVar: function(a) {
  25547. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");
  25548. this.modeB.endRadiusVar = a
  25549. },
  25550. getRotatePerSecond: function() {
  25551. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");
  25552. return this.modeB.rotatePerSecond
  25553. },
  25554. setRotatePerSecond: function(a) {
  25555. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
  25556. this.modeB.rotatePerSecond = a
  25557. },
  25558. getRotatePerSecondVar: function() {
  25559. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS &&
  25560. cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");
  25561. return this.modeB.rotatePerSecondVar
  25562. },
  25563. setRotatePerSecondVar: function(a) {
  25564. this.emitterMode !== cc.ParticleSystem.MODE_RADIUS && cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");
  25565. this.modeB.rotatePerSecondVar = a
  25566. },
  25567. setScale: function(a, b) {
  25568. this._transformSystemDirty = !0;
  25569. cc.Node.prototype.setScale.call(this, a, b)
  25570. },
  25571. setRotation: function(a) {
  25572. this._transformSystemDirty = !0;
  25573. cc.Node.prototype.setRotation.call(this,
  25574. a)
  25575. },
  25576. setScaleX: function(a) {
  25577. this._transformSystemDirty = !0;
  25578. cc.Node.prototype.setScaleX.call(this, a)
  25579. },
  25580. setScaleY: function(a) {
  25581. this._transformSystemDirty = !0;
  25582. cc.Node.prototype.setScaleY.call(this, a)
  25583. },
  25584. getStartSize: function() {
  25585. return this.startSize
  25586. },
  25587. setStartSize: function(a) {
  25588. this.startSize = a
  25589. },
  25590. getStartSizeVar: function() {
  25591. return this.startSizeVar
  25592. },
  25593. setStartSizeVar: function(a) {
  25594. this.startSizeVar = a
  25595. },
  25596. getEndSize: function() {
  25597. return this.endSize
  25598. },
  25599. setEndSize: function(a) {
  25600. this.endSize = a
  25601. },
  25602. getEndSizeVar: function() {
  25603. return this.endSizeVar
  25604. },
  25605. setEndSizeVar: function(a) {
  25606. this.endSizeVar = a
  25607. },
  25608. getStartColor: function() {
  25609. return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a)
  25610. },
  25611. setStartColor: function(a) {
  25612. this._startColor = cc.color(a)
  25613. },
  25614. getStartColorVar: function() {
  25615. return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a)
  25616. },
  25617. setStartColorVar: function(a) {
  25618. this._startColorVar = cc.color(a)
  25619. },
  25620. getEndColor: function() {
  25621. return cc.color(this._endColor.r, this._endColor.g, this._endColor.b,
  25622. this._endColor.a)
  25623. },
  25624. setEndColor: function(a) {
  25625. this._endColor = cc.color(a)
  25626. },
  25627. getEndColorVar: function() {
  25628. return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a)
  25629. },
  25630. setEndColorVar: function(a) {
  25631. this._endColorVar = cc.color(a)
  25632. },
  25633. getStartSpin: function() {
  25634. return this.startSpin
  25635. },
  25636. setStartSpin: function(a) {
  25637. this.startSpin = a
  25638. },
  25639. getStartSpinVar: function() {
  25640. return this.startSpinVar
  25641. },
  25642. setStartSpinVar: function(a) {
  25643. this.startSpinVar = a
  25644. },
  25645. getEndSpin: function() {
  25646. return this.endSpin
  25647. },
  25648. setEndSpin: function(a) {
  25649. this.endSpin =
  25650. a
  25651. },
  25652. getEndSpinVar: function() {
  25653. return this.endSpinVar
  25654. },
  25655. setEndSpinVar: function(a) {
  25656. this.endSpinVar = a
  25657. },
  25658. getEmissionRate: function() {
  25659. return this.emissionRate
  25660. },
  25661. setEmissionRate: function(a) {
  25662. this.emissionRate = a
  25663. },
  25664. getTotalParticles: function() {
  25665. return this._totalParticles
  25666. },
  25667. setTotalParticles: function(a) {
  25668. this._renderCmd.setTotalParticles(a)
  25669. },
  25670. getTexture: function() {
  25671. return this._texture
  25672. },
  25673. setTexture: function(a) {
  25674. a && (a.isLoaded() ? this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height)) : (this._textureLoaded = !1, a.addEventListener("load",
  25675. function(a) {
  25676. this._textureLoaded = !0;
  25677. this.setTextureWithRect(a, cc.rect(0, 0, a.width, a.height))
  25678. }, this)))
  25679. },
  25680. getBlendFunc: function() {
  25681. return this._blendFunc
  25682. },
  25683. setBlendFunc: function(a, b) {
  25684. if (void 0 === b) this._blendFunc !== a && (this._blendFunc = a, this._updateBlendFunc());
  25685. else if (this._blendFunc.src !== a || this._blendFunc.dst !== b) this._blendFunc = {
  25686. src: a,
  25687. dst: b
  25688. }, this._updateBlendFunc()
  25689. },
  25690. isOpacityModifyRGB: function() {
  25691. return this._opacityModifyRGB
  25692. },
  25693. setOpacityModifyRGB: function(a) {
  25694. this._opacityModifyRGB = a
  25695. },
  25696. isBlendAdditive: function() {
  25697. return this._blendFunc.src ===
  25698. cc.SRC_ALPHA && this._blendFunc.dst === cc.ONE || this._blendFunc.src === cc.ONE && this._blendFunc.dst === cc.ONE
  25699. },
  25700. setBlendAdditive: function(a) {
  25701. var b = this._blendFunc;
  25702. a ? (b.src = cc.SRC_ALPHA, b.dst = cc.ONE) : this._renderCmd._setBlendAdditive()
  25703. },
  25704. getPositionType: function() {
  25705. return this.positionType
  25706. },
  25707. setPositionType: function(a) {
  25708. this.positionType = a
  25709. },
  25710. isAutoRemoveOnFinish: function() {
  25711. return this.autoRemoveOnFinish
  25712. },
  25713. setAutoRemoveOnFinish: function(a) {
  25714. this.autoRemoveOnFinish = a
  25715. },
  25716. getEmitterMode: function() {
  25717. return this.emitterMode
  25718. },
  25719. setEmitterMode: function(a) {
  25720. this.emitterMode = a
  25721. },
  25722. init: function() {
  25723. return this.initWithTotalParticles(150)
  25724. },
  25725. initWithFile: function(a) {
  25726. this._plistFile = a;
  25727. a = cc.loader.getRes(a);
  25728. return a ? this.initWithDictionary(a, "") : (cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"), !1)
  25729. },
  25730. getBoundingBoxToWorld: function() {
  25731. return cc.rect(0, 0, cc._canvas.width, cc._canvas.height)
  25732. },
  25733. initWithDictionary: function(a, b) {
  25734. var c = !1,
  25735. d = null,
  25736. d = this._valueForKey,
  25737. e = parseInt(d("maxParticles", a));
  25738. if (this.initWithTotalParticles(e)) {
  25739. this.angle =
  25740. parseFloat(d("angle", a));
  25741. this.angleVar = parseFloat(d("angleVariance", a));
  25742. this.duration = parseFloat(d("duration", a));
  25743. this._blendFunc.src = parseInt(d("blendFuncSource", a));
  25744. this._blendFunc.dst = parseInt(d("blendFuncDestination", a));
  25745. c = this._startColor;
  25746. c.r = 255 * parseFloat(d("startColorRed", a));
  25747. c.g = 255 * parseFloat(d("startColorGreen", a));
  25748. c.b = 255 * parseFloat(d("startColorBlue", a));
  25749. c.a = 255 * parseFloat(d("startColorAlpha", a));
  25750. c = this._startColorVar;
  25751. c.r = 255 * parseFloat(d("startColorVarianceRed", a));
  25752. c.g = 255 * parseFloat(d("startColorVarianceGreen",
  25753. a));
  25754. c.b = 255 * parseFloat(d("startColorVarianceBlue", a));
  25755. c.a = 255 * parseFloat(d("startColorVarianceAlpha", a));
  25756. c = this._endColor;
  25757. c.r = 255 * parseFloat(d("finishColorRed", a));
  25758. c.g = 255 * parseFloat(d("finishColorGreen", a));
  25759. c.b = 255 * parseFloat(d("finishColorBlue", a));
  25760. c.a = 255 * parseFloat(d("finishColorAlpha", a));
  25761. c = this._endColorVar;
  25762. c.r = 255 * parseFloat(d("finishColorVarianceRed", a));
  25763. c.g = 255 * parseFloat(d("finishColorVarianceGreen", a));
  25764. c.b = 255 * parseFloat(d("finishColorVarianceBlue", a));
  25765. c.a = 255 * parseFloat(d("finishColorVarianceAlpha",
  25766. a));
  25767. this.startSize = parseFloat(d("startParticleSize", a));
  25768. this.startSizeVar = parseFloat(d("startParticleSizeVariance", a));
  25769. this.endSize = parseFloat(d("finishParticleSize", a));
  25770. this.endSizeVar = parseFloat(d("finishParticleSizeVariance", a));
  25771. this.setPosition(parseFloat(d("sourcePositionx", a)), parseFloat(d("sourcePositiony", a)));
  25772. this._posVar.x = parseFloat(d("sourcePositionVariancex", a));
  25773. this._posVar.y = parseFloat(d("sourcePositionVariancey", a));
  25774. this.startSpin = parseFloat(d("rotationStart", a));
  25775. this.startSpinVar =
  25776. parseFloat(d("rotationStartVariance", a));
  25777. this.endSpin = parseFloat(d("rotationEnd", a));
  25778. this.endSpinVar = parseFloat(d("rotationEndVariance", a));
  25779. this.emitterMode = parseInt(d("emitterType", a));
  25780. if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) c = this.modeA, c.gravity.x = parseFloat(d("gravityx", a)), c.gravity.y = parseFloat(d("gravityy", a)), c.speed = parseFloat(d("speed", a)), c.speedVar = parseFloat(d("speedVariance", a)), e = d("radialAcceleration", a), c.radialAccel = e ? parseFloat(e) : 0, e = d("radialAccelVariance", a), c.radialAccelVar =
  25781. e ? parseFloat(e) : 0, e = d("tangentialAcceleration", a), c.tangentialAccel = e ? parseFloat(e) : 0, e = d("tangentialAccelVariance", a), c.tangentialAccelVar = e ? parseFloat(e) : 0, e = d("rotationIsDir", a).toLowerCase(), c.rotationIsDir = null != e && ("true" === e || "1" === e);
  25782. else if (this.emitterMode === cc.ParticleSystem.MODE_RADIUS) c = this.modeB, c.startRadius = parseFloat(d("maxRadius", a)), c.startRadiusVar = parseFloat(d("maxRadiusVariance", a)), c.endRadius = parseFloat(d("minRadius", a)), c.endRadiusVar = 0, c.rotatePerSecond = parseFloat(d("rotatePerSecond",
  25783. a)), c.rotatePerSecondVar = parseFloat(d("rotatePerSecondVariance", a));
  25784. else return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"), !1;
  25785. this.life = parseFloat(d("particleLifespan", a));
  25786. this.lifeVar = parseFloat(d("particleLifespanVariance", a));
  25787. this.emissionRate = this._totalParticles / this.life;
  25788. if (!this._batchNode)
  25789. if (this._opacityModifyRGB = !1, c = d("textureFileName", a), c = cc.path.changeBasename(this._plistFile, c), e = cc.textureCache.getTextureForKey(c)) this.setTexture(e);
  25790. else if ((d =
  25791. d("textureImageData", a)) && 0 !== d.length) {
  25792. d = cc.unzipBase64AsArray(d, 1);
  25793. if (!d) return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"), !1;
  25794. e = cc.getImageFormatByData(d);
  25795. if (e !== cc.FMT_TIFF && e !== cc.FMT_PNG) return cc.log("cc.ParticleSystem: unknown image format with Data"), !1;
  25796. var f = cc.newElement("canvas");
  25797. e === cc.FMT_PNG ? (new cc.PNGReader(d)).render(f) : cc.tiffReader.parseTIFF(d, f);
  25798. cc.textureCache.cacheImage(c, f);
  25799. (d = cc.textureCache.getTextureForKey(c)) || cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture");
  25800. this.setTexture(d)
  25801. } else {
  25802. e = cc.textureCache.addImage(c);
  25803. if (!e) return !1;
  25804. this.setTexture(e)
  25805. }
  25806. c = !0
  25807. }
  25808. return c
  25809. },
  25810. initWithTotalParticles: function(a) {
  25811. this._totalParticles = a;
  25812. var b, c = this._particles;
  25813. for (b = c.length = 0; b < a; b++) c[b] = new cc.Particle;
  25814. if (!c) return cc.log("Particle system: not enough memory"), !1;
  25815. this._allocatedParticles = a;
  25816. if (this._batchNode)
  25817. for (b = 0; b < this._totalParticles; b++) c[b].atlasIndex = b;
  25818. this._isActive = !0;
  25819. this._blendFunc.src = cc.BLEND_SRC;
  25820. this._blendFunc.dst = cc.BLEND_DST;
  25821. this.positionType = cc.ParticleSystem.TYPE_FREE;
  25822. this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
  25823. this._transformSystemDirty = this.autoRemoveOnFinish = !1;
  25824. this.scheduleUpdateWithPriority(1);
  25825. this._renderCmd._initWithTotalParticles(a);
  25826. return !0
  25827. },
  25828. destroyParticleSystem: function() {
  25829. this.unscheduleUpdate()
  25830. },
  25831. addParticle: function() {
  25832. if (this.isFull()) return !1;
  25833. var a = this._renderCmd.addParticle();
  25834. this.initParticle(a);
  25835. ++this.particleCount;
  25836. return !0
  25837. },
  25838. initParticle: function(a) {
  25839. var b = cc.randomMinus1To1;
  25840. a.timeToLive = this.life + this.lifeVar * b();
  25841. a.timeToLive = Math.max(0, a.timeToLive);
  25842. a.pos.x = this._sourcePosition.x + this._posVar.x * b();
  25843. a.pos.y = this._sourcePosition.y + this._posVar.y * b();
  25844. var c, d;
  25845. c = this._startColor;
  25846. var e = this._startColorVar,
  25847. f = this._endColor;
  25848. d = this._endColorVar;
  25849. c = {
  25850. r: cc.clampf(c.r + e.r * b(), 0, 255),
  25851. g: cc.clampf(c.g + e.g * b(), 0, 255),
  25852. b: cc.clampf(c.b + e.b * b(), 0, 255),
  25853. a: cc.clampf(c.a + e.a * b(), 0, 255)
  25854. };
  25855. d = {
  25856. r: cc.clampf(f.r + d.r * b(), 0, 255),
  25857. g: cc.clampf(f.g + d.g * b(), 0, 255),
  25858. b: cc.clampf(f.b + d.b * b(), 0, 255),
  25859. a: cc.clampf(f.a + d.a * b(), 0, 255)
  25860. };
  25861. a.color = c;
  25862. e = a.deltaColor;
  25863. f = a.timeToLive;
  25864. e.r = (d.r - c.r) / f;
  25865. e.g = (d.g - c.g) / f;
  25866. e.b = (d.b - c.b) / f;
  25867. e.a = (d.a - c.a) / f;
  25868. c = this.startSize + this.startSizeVar * b();
  25869. c = Math.max(0, c);
  25870. a.size = c;
  25871. this.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE ? a.deltaSize = 0 : (d = this.endSize + this.endSizeVar * b(), d = Math.max(0, d), a.deltaSize = (d - c) / f);
  25872. c = this.startSpin + this.startSpinVar * b();
  25873. d = this.endSpin + this.endSpinVar * b();
  25874. a.rotation = c;
  25875. a.deltaRotation = (d - c) / f;
  25876. this.positionType === cc.ParticleSystem.TYPE_FREE ? a.startPos = this.convertToWorldSpace(this._pointZeroForParticle) : this.positionType ===
  25877. cc.ParticleSystem.TYPE_RELATIVE && (a.startPos.x = this._position.x, a.startPos.y = this._position.y);
  25878. c = cc.degreesToRadians(this.angle + this.angleVar * b());
  25879. if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) f = this.modeA, d = a.modeA, e = f.speed + f.speedVar * b(), d.dir.x = Math.cos(c), d.dir.y = Math.sin(c), cc.pMultIn(d.dir, e), d.radialAccel = f.radialAccel + f.radialAccelVar * b(), d.tangentialAccel = f.tangentialAccel + f.tangentialAccelVar * b(), f.rotationIsDir && (a.rotation = -cc.radiansToDegrees(cc.pToAngle(d.dir)));
  25880. else {
  25881. d = this.modeB;
  25882. a = a.modeB;
  25883. var e = d.startRadius + d.startRadiusVar * b(),
  25884. g = d.endRadius + d.endRadiusVar * b();
  25885. a.radius = e;
  25886. a.deltaRadius = d.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS ? 0 : (g - e) / f;
  25887. a.angle = c;
  25888. a.degreesPerSecond = cc.degreesToRadians(d.rotatePerSecond + d.rotatePerSecondVar * b())
  25889. }
  25890. },
  25891. stopSystem: function() {
  25892. this._isActive = !1;
  25893. this._elapsed = this.duration;
  25894. this._emitCounter = 0
  25895. },
  25896. resetSystem: function() {
  25897. this._isActive = !0;
  25898. this._elapsed = 0;
  25899. var a = this._particles;
  25900. for (this._particleIdx = 0; this._particleIdx < this.particleCount; ++this._particleIdx) a[this._particleIdx].timeToLive =
  25901. 0
  25902. },
  25903. isFull: function() {
  25904. return this.particleCount >= this._totalParticles
  25905. },
  25906. updateQuadWithParticle: function(a, b) {
  25907. this._renderCmd.updateQuadWithParticle(a, b)
  25908. },
  25909. postStep: function() {
  25910. this._renderCmd.postStep()
  25911. },
  25912. update: function(a) {
  25913. if (this._isActive && this.emissionRate) {
  25914. var b = 1 / this.emissionRate;
  25915. this.particleCount < this._totalParticles && (this._emitCounter += a);
  25916. for (; this.particleCount < this._totalParticles && this._emitCounter > b;) this.addParticle(), this._emitCounter -= b;
  25917. this._elapsed += a; - 1 !== this.duration && this.duration <
  25918. this._elapsed && this.stopSystem()
  25919. }
  25920. this._particleIdx = 0;
  25921. b = cc.Particle.TemporaryPoints[0];
  25922. this.positionType === cc.ParticleSystem.TYPE_FREE ? cc.pIn(b, this.convertToWorldSpace(this._pointZeroForParticle)) : this.positionType === cc.ParticleSystem.TYPE_RELATIVE && (b.x = this._position.x, b.y = this._position.y);
  25923. if (this._visible) {
  25924. for (var c = cc.Particle.TemporaryPoints[1], d = cc.Particle.TemporaryPoints[2], e = cc.Particle.TemporaryPoints[3], f = this._particles; this._particleIdx < this.particleCount;) {
  25925. cc.pZeroIn(c);
  25926. cc.pZeroIn(d);
  25927. cc.pZeroIn(e);
  25928. var g = f[this._particleIdx];
  25929. g.timeToLive -= a;
  25930. if (0 < g.timeToLive) {
  25931. if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) {
  25932. var h = e,
  25933. k = c,
  25934. m = d;
  25935. g.pos.x || g.pos.y ? (cc.pIn(k, g.pos), cc.pNormalizeIn(k)) : cc.pZeroIn(k);
  25936. cc.pIn(m, k);
  25937. cc.pMultIn(k, g.modeA.radialAccel);
  25938. var n = m.x;
  25939. m.x = -m.y;
  25940. m.y = n;
  25941. cc.pMultIn(m, g.modeA.tangentialAccel);
  25942. cc.pIn(h, k);
  25943. cc.pAddIn(h, m);
  25944. cc.pAddIn(h, this.modeA.gravity);
  25945. cc.pMultIn(h, a);
  25946. cc.pAddIn(g.modeA.dir, h);
  25947. cc.pIn(h, g.modeA.dir);
  25948. cc.pMultIn(h, a);
  25949. cc.pAddIn(g.pos, h)
  25950. } else h = g.modeB, h.angle +=
  25951. h.degreesPerSecond * a, h.radius += h.deltaRadius * a, g.pos.x = -Math.cos(h.angle) * h.radius, g.pos.y = -Math.sin(h.angle) * h.radius;
  25952. this._renderCmd._updateDeltaColor(g, a);
  25953. g.size += g.deltaSize * a;
  25954. g.size = Math.max(0, g.size);
  25955. g.rotation += g.deltaRotation * a;
  25956. h = c;
  25957. this.positionType === cc.ParticleSystem.TYPE_FREE || this.positionType === cc.ParticleSystem.TYPE_RELATIVE ? (k = d, cc.pIn(k, b), cc.pSubIn(k, g.startPos), cc.pIn(h, g.pos), cc.pSubIn(h, k)) : cc.pIn(h, g.pos);
  25958. this._batchNode && (h.x += this._position.x, h.y += this._position.y);
  25959. this._renderCmd.updateParticlePosition(g,
  25960. h);
  25961. ++this._particleIdx
  25962. } else if (g = g.atlasIndex, this._particleIdx !== this.particleCount - 1 && (h = f[this._particleIdx], f[this._particleIdx] = f[this.particleCount - 1], f[this.particleCount - 1] = h), this._batchNode && (this._batchNode.disableParticle(this.atlasIndex + g), f[this.particleCount - 1].atlasIndex = g), --this.particleCount, 0 === this.particleCount && this.autoRemoveOnFinish) {
  25963. this.unscheduleUpdate();
  25964. this._parent.removeChild(this, !0);
  25965. return
  25966. }
  25967. }
  25968. this._transformSystemDirty = !1
  25969. }
  25970. this._batchNode || this.postStep()
  25971. },
  25972. updateWithNoTime: function() {
  25973. this.update(0)
  25974. },
  25975. _valueForKey: function(a, b) {
  25976. if (b) {
  25977. var c = b[a];
  25978. return null != c ? c : ""
  25979. }
  25980. return ""
  25981. },
  25982. _updateBlendFunc: function() {
  25983. if (this._batchNode) cc.log("Can't change blending functions when the particle is being batched");
  25984. else {
  25985. var a = this._texture;
  25986. if (a && a instanceof cc.Texture2D) {
  25987. this._opacityModifyRGB = !1;
  25988. var b = this._blendFunc;
  25989. b.src === cc.BLEND_SRC && b.dst === cc.BLEND_DST && (a.hasPremultipliedAlpha() ? this._opacityModifyRGB = !0 : (b.src = cc.SRC_ALPHA, b.dst = cc.ONE_MINUS_SRC_ALPHA))
  25990. }
  25991. }
  25992. },
  25993. clone: function() {
  25994. var a = new cc.ParticleSystem;
  25995. if (a.initWithTotalParticles(this.getTotalParticles())) {
  25996. a.setAngle(this.getAngle());
  25997. a.setAngleVar(this.getAngleVar());
  25998. a.setDuration(this.getDuration());
  25999. var b = this.getBlendFunc();
  26000. a.setBlendFunc(b.src, b.dst);
  26001. a.setStartColor(this.getStartColor());
  26002. a.setStartColorVar(this.getStartColorVar());
  26003. a.setEndColor(this.getEndColor());
  26004. a.setEndColorVar(this.getEndColorVar());
  26005. a.setStartSize(this.getStartSize());
  26006. a.setStartSizeVar(this.getStartSizeVar());
  26007. a.setEndSize(this.getEndSize());
  26008. a.setEndSizeVar(this.getEndSizeVar());
  26009. a.setPosition(cc.p(this.x, this.y));
  26010. a.setPosVar(cc.p(this.getPosVar().x, this.getPosVar().y));
  26011. a.setStartSpin(this.getStartSpin() || 0);
  26012. a.setStartSpinVar(this.getStartSpinVar() || 0);
  26013. a.setEndSpin(this.getEndSpin() || 0);
  26014. a.setEndSpinVar(this.getEndSpinVar() || 0);
  26015. a.setEmitterMode(this.getEmitterMode());
  26016. this.getEmitterMode() === cc.ParticleSystem.MODE_GRAVITY ? (b = this.getGravity(), a.setGravity(cc.p(b.x, b.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())) :
  26017. 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()));
  26018. a.setLife(this.getLife());
  26019. a.setLifeVar(this.getLifeVar());
  26020. a.setEmissionRate(this.getEmissionRate());
  26021. if (!this.getBatchNode() && (a.setOpacityModifyRGB(this.isOpacityModifyRGB()), b = this.getTexture())) {
  26022. var c =
  26023. b.getContentSize();
  26024. a.setTextureWithRect(b, cc.rect(0, 0, c.width, c.height))
  26025. }
  26026. }
  26027. return a
  26028. },
  26029. setDisplayFrame: function(a) {
  26030. if (a) {
  26031. var b = a.getOffsetInPixels();
  26032. 0 === b.x && 0 === b.y || cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");
  26033. a = a.getTexture();
  26034. this._texture !== a && this.setTexture(a)
  26035. }
  26036. },
  26037. setTextureWithRect: function(a, b) {
  26038. this._texture !== a && (this._texture = a, this._updateBlendFunc());
  26039. this.initTexCoordsWithRect(b)
  26040. },
  26041. listenBackToForeground: function(a) {}
  26042. });
  26043. _p = cc.ParticleSystem.prototype;
  26044. cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB);
  26045. cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode);
  26046. cc.defineGetterSetter(_p, "drawMode", _p.getDrawMode, _p.setDrawMode);
  26047. cc.defineGetterSetter(_p, "shapeType", _p.getShapeType, _p.setShapeType);
  26048. cc.defineGetterSetter(_p, "active", _p.isActive);
  26049. cc.defineGetterSetter(_p, "sourcePos", _p.getSourcePosition, _p.setSourcePosition);
  26050. cc.defineGetterSetter(_p, "posVar", _p.getPosVar, _p.setPosVar);
  26051. cc.defineGetterSetter(_p, "gravity", _p.getGravity, _p.setGravity);
  26052. cc.defineGetterSetter(_p, "speed", _p.getSpeed, _p.setSpeed);
  26053. cc.defineGetterSetter(_p, "speedVar", _p.getSpeedVar, _p.setSpeedVar);
  26054. cc.defineGetterSetter(_p, "tangentialAccel", _p.getTangentialAccel, _p.setTangentialAccel);
  26055. cc.defineGetterSetter(_p, "tangentialAccelVar", _p.getTangentialAccelVar, _p.setTangentialAccelVar);
  26056. cc.defineGetterSetter(_p, "radialAccel", _p.getRadialAccel, _p.setRadialAccel);
  26057. cc.defineGetterSetter(_p, "radialAccelVar", _p.getRadialAccelVar, _p.setRadialAccelVar);
  26058. cc.defineGetterSetter(_p, "rotationIsDir", _p.getRotationIsDir, _p.setRotationIsDir);
  26059. cc.defineGetterSetter(_p, "startRadius", _p.getStartRadius, _p.setStartRadius);
  26060. cc.defineGetterSetter(_p, "startRadiusVar", _p.getStartRadiusVar, _p.setStartRadiusVar);
  26061. cc.defineGetterSetter(_p, "endRadius", _p.getEndRadius, _p.setEndRadius);
  26062. cc.defineGetterSetter(_p, "endRadiusVar", _p.getEndRadiusVar, _p.setEndRadiusVar);
  26063. cc.defineGetterSetter(_p, "rotatePerS", _p.getRotatePerSecond, _p.setRotatePerSecond);
  26064. cc.defineGetterSetter(_p, "rotatePerSVar", _p.getRotatePerSecondVar, _p.setRotatePerSecondVar);
  26065. cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor);
  26066. cc.defineGetterSetter(_p, "startColorVar", _p.getStartColorVar, _p.setStartColorVar);
  26067. cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor);
  26068. cc.defineGetterSetter(_p, "endColorVar", _p.getEndColorVar, _p.setEndColorVar);
  26069. cc.defineGetterSetter(_p, "totalParticles", _p.getTotalParticles, _p.setTotalParticles);
  26070. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  26071. cc.ParticleSystem.create = function(a) {
  26072. return new cc.ParticleSystem(a)
  26073. };
  26074. cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create;
  26075. cc.ParticleSystem.ModeA = function(a, b, c, d, e, f, g, h) {
  26076. this.gravity = a ? a : cc.p(0, 0);
  26077. this.speed = b || 0;
  26078. this.speedVar = c || 0;
  26079. this.tangentialAccel = d || 0;
  26080. this.tangentialAccelVar = e || 0;
  26081. this.radialAccel = f || 0;
  26082. this.radialAccelVar = g || 0;
  26083. this.rotationIsDir = h || !1
  26084. };
  26085. cc.ParticleSystem.ModeB = function(a, b, c, d, e, f) {
  26086. this.startRadius = a || 0;
  26087. this.startRadiusVar = b || 0;
  26088. this.endRadius = c || 0;
  26089. this.endRadiusVar = d || 0;
  26090. this.rotatePerSecond = e || 0;
  26091. this.rotatePerSecondVar = f || 0
  26092. };
  26093. cc.ParticleSystem.SHAPE_MODE = 0;
  26094. cc.ParticleSystem.TEXTURE_MODE = 1;
  26095. cc.ParticleSystem.STAR_SHAPE = 0;
  26096. cc.ParticleSystem.BALL_SHAPE = 1;
  26097. cc.ParticleSystem.DURATION_INFINITY = -1;
  26098. cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
  26099. cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
  26100. cc.ParticleSystem.MODE_GRAVITY = 0;
  26101. cc.ParticleSystem.MODE_RADIUS = 1;
  26102. cc.ParticleSystem.TYPE_FREE = 0;
  26103. cc.ParticleSystem.TYPE_RELATIVE = 1;
  26104. cc.ParticleSystem.TYPE_GROUPED = 2;
  26105. (function() {
  26106. cc.ParticleSystem.CanvasRenderCmd = function(a) {
  26107. cc.Node.CanvasRenderCmd.call(this, a);
  26108. this._needDraw = !0;
  26109. this._drawMode = cc.ParticleSystem.TEXTURE_MODE;
  26110. this._shapeType = cc.ParticleSystem.BALL_SHAPE;
  26111. this._pointRect = cc.rect(0, 0, 0, 0)
  26112. };
  26113. var a = cc.ParticleSystem.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  26114. a.constructor = cc.ParticleSystem.CanvasRenderCmd;
  26115. a.getDrawMode = function() {
  26116. return this._drawMode
  26117. };
  26118. a.setDrawMode = function(a) {
  26119. this._drawMode = a
  26120. };
  26121. a.getShapeType = function() {
  26122. return this._shapeType
  26123. };
  26124. a.setShapeType = function(a) {
  26125. this._shapeType = a
  26126. };
  26127. a.setBatchNode = function(a) {
  26128. this._batchNode !== a && (this._node._batchNode = a)
  26129. };
  26130. a.updateQuadWithParticle = function(a, c) {};
  26131. a.updateParticlePosition = function(a, c) {
  26132. cc.pIn(a.drawPos, c)
  26133. };
  26134. a.rendering = function(a, c, d) {
  26135. a = a || cc._renderContext;
  26136. var e = a.getContext(),
  26137. f = this._node,
  26138. g = this._pointRect;
  26139. a.setTransform(this._worldTransform, c, d);
  26140. a.save();
  26141. f.isBlendAdditive() ? e.globalCompositeOperation = "lighter" : e.globalCompositeOperation = "source-over";
  26142. var h, k;
  26143. d = this._node.particleCount;
  26144. var m = this._node._particles;
  26145. if (f.drawMode !== cc.ParticleSystem.SHAPE_MODE && f._texture) {
  26146. if (!f._texture._textureLoaded) {
  26147. a.restore();
  26148. return
  26149. }
  26150. f = f._texture.getHtmlElementObj();
  26151. if (!f.width || !f.height) {
  26152. a.restore();
  26153. return
  26154. }
  26155. h = f;
  26156. for (c = 0; c < d; c++)
  26157. if (h = m[c], k = h.color.a / 255, 0 !== k) {
  26158. e.globalAlpha = k;
  26159. e.save();
  26160. e.translate(0 | h.drawPos.x, -(0 | h.drawPos.y));
  26161. var n = 4 * Math.floor(h.size / 4);
  26162. k = g.width;
  26163. var p = g.height;
  26164. e.scale(Math.max(1 / k * n, 1E-6), Math.max(1 / p * n, 1E-6));
  26165. h.rotation && e.rotate(cc.degreesToRadians(h.rotation));
  26166. h = h.isChangeColor ?
  26167. this._changeTextureColor(f, h.color, this._pointRect) : f;
  26168. e.drawImage(h, -(0 | k / 2), -(0 | p / 2));
  26169. e.restore()
  26170. }
  26171. } else
  26172. for (p = cc._drawingUtil, c = 0; c < d; c++) h = m[c], g = 0 | 0.5 * h.size, k = h.color.a / 255, 0 !== k && (e.globalAlpha = k, e.save(), e.translate(0 | h.drawPos.x, -(0 | h.drawPos.y)), f.shapeType === cc.ParticleSystem.STAR_SHAPE ? (h.rotation && e.rotate(cc.degreesToRadians(h.rotation)), p.drawStar(a, g, h.color)) : p.drawColorBall(a, g, h.color), e.restore());
  26173. a.restore();
  26174. cc.g_NumberOfDraws++
  26175. };
  26176. a._changeTextureColor = cc.sys._supportCanvasNewBlendModes ?
  26177. function(a, c, d) {
  26178. a.tintCache || (a.tintCache = document.createElement("canvas"), a.tintCache.width = a.width, a.tintCache.height = a.height);
  26179. return cc.Sprite.CanvasRenderCmd._generateTintImageWithMultiply(a, c, d, a.tintCache)
  26180. } : function(a, c, d) {
  26181. var e = cc.textureCache.getTextureColors(a);
  26182. return e ? (e.tintCache || (e.tintCache = document.createElement("canvas"), e.tintCache.width = a.width, e.tintCache.height = a.height), cc.Sprite.CanvasRenderCmd._generateTintImage(a, e, c, d, e.tintCache), e.tintCache) : null
  26183. };
  26184. a.initTexCoordsWithRect =
  26185. function(a) {
  26186. this._pointRect = a
  26187. };
  26188. a.setTotalParticles = function(a) {
  26189. this._node._totalParticles = 200 > a ? a : 200
  26190. };
  26191. a.addParticle = function() {
  26192. var a = this._node,
  26193. c = a._particles;
  26194. a.particleCount < c.length ? a = c[a.particleCount] : (a = new cc.Particle, c.push(a));
  26195. return a
  26196. };
  26197. a._setupVBO = function() {};
  26198. a._allocMemory = function() {
  26199. return !0
  26200. };
  26201. a.postStep = function() {};
  26202. a._setBlendAdditive = function() {
  26203. var a = this._node._blendFunc;
  26204. a.src = cc.BLEND_SRC;
  26205. a.dst = cc.BLEND_DST
  26206. };
  26207. a._initWithTotalParticles = function(a) {};
  26208. a._updateDeltaColor = function(a, c) {
  26209. this._node._dontTint ||
  26210. (a.color.r += a.deltaColor.r * c, a.color.g += a.deltaColor.g * c, a.color.b += a.deltaColor.b * c, a.color.a += a.deltaColor.a * c, a.isChangeColor = !0)
  26211. }
  26212. })();
  26213. (function() {
  26214. cc.ParticleSystem.WebGLRenderCmd = function(a) {
  26215. cc.Node.WebGLRenderCmd.call(this, a);
  26216. this._needDraw = !0;
  26217. this._buffersVBO = [0, 0];
  26218. this._quads = [];
  26219. this._indices = [];
  26220. this._quadsArrayBuffer = null
  26221. };
  26222. var a = cc.ParticleSystem.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  26223. a.constructor = cc.ParticleSystem.WebGLRenderCmd;
  26224. a.getDrawMode = function() {};
  26225. a.setDrawMode = function(a) {};
  26226. a.getShapeType = function() {};
  26227. a.setShapeType = function(a) {};
  26228. a.setBatchNode = function(a) {
  26229. var c = this._node;
  26230. if (c._batchNode !==
  26231. a) {
  26232. var d = c._batchNode;
  26233. if (c._batchNode = a)
  26234. for (var e = c._particles, f = 0; f < c._totalParticles; f++) e[f].atlasIndex = f;
  26235. a ? d || (c._batchNode.textureAtlas._copyQuadsToTextureAtlas(this._quads, c.atlasIndex), cc._renderContext.deleteBuffer(this._buffersVBO[1])) : (this._allocMemory(), this.initIndices(c._totalParticles), c.setTexture(d.getTexture()), this._setupVBO())
  26236. }
  26237. };
  26238. a.initIndices = function(a) {
  26239. for (var c = this._indices, d = 0; d < a; ++d) {
  26240. var e = 6 * d,
  26241. f = 4 * d;
  26242. c[e + 0] = f + 0;
  26243. c[e + 1] = f + 1;
  26244. c[e + 2] = f + 2;
  26245. c[e + 5] = f + 1;
  26246. c[e + 4] = f + 2;
  26247. c[e + 3] = f + 3
  26248. }
  26249. };
  26250. a.isDifferentTexture =
  26251. function(a, c) {
  26252. return a === c
  26253. };
  26254. a.updateParticlePosition = function(a, c) {
  26255. this.updateQuadWithParticle(a, c)
  26256. };
  26257. a.updateQuadWithParticle = function(a, c) {
  26258. var d = null,
  26259. e = this._node;
  26260. e._batchNode ? (d = e._batchNode.textureAtlas.quads[e.atlasIndex + a.atlasIndex], e._batchNode.textureAtlas.dirty = !0) : d = this._quads[e._particleIdx];
  26261. var f, g, h;
  26262. e._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);
  26263. h = 0 | a.color.a;
  26264. var k = d.bl.colors,
  26265. m = d.br.colors,
  26266. n = d.tl.colors,
  26267. p = d.tr.colors;
  26268. k.r = m.r = n.r = p.r = e;
  26269. k.g = m.g = n.g = p.g = f;
  26270. k.b = m.b = n.b = p.b = g;
  26271. k.a = m.a = n.a = p.a = h;
  26272. e = a.size / 2;
  26273. a.rotation ? (f = -e, g = -e, h = c.x, k = c.y, n = -cc.degreesToRadians(a.rotation), m = Math.cos(n), n = Math.sin(n), d.bl.vertices.x = f * m - g * n + h, d.bl.vertices.y = f * n + g * m + k, d.br.vertices.x = e * m - g * n + h, d.br.vertices.y = e * n + g * m + k, d.tl.vertices.x = f * m - e * n + h, d.tl.vertices.y = f * n + e * m + k, d.tr.vertices.x = e * m - e * n + h, d.tr.vertices.y = e * n + e * m + k) : (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 -
  26274. 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)
  26275. };
  26276. a.rendering = function(a) {
  26277. var c = this._node;
  26278. c._texture && (a = a || cc._renderContext, this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBindTexture2D(c._texture), cc.glBlendFuncForParticle(c._blendFunc.src, c._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,
  26279. 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 * c._particleIdx, a.UNSIGNED_SHORT, 0))
  26280. };
  26281. a.initTexCoordsWithRect = function(a) {
  26282. var c = this._node,
  26283. d = c.texture,
  26284. e = cc.contentScaleFactor(),
  26285. f = cc.rect(a.x * e, a.y * e, a.width * e, a.height * e),
  26286. e = a.width,
  26287. g = a.height;
  26288. d && (e = d.pixelsWidth, g = d.pixelsHeight);
  26289. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ?
  26290. (d = (2 * f.x + 1) / (2 * e), a = (2 * f.y + 1) / (2 * g), e = d + (2 * f.width - 2) / (2 * e), f = a + (2 * f.height - 2) / (2 * g)) : (d = f.x / e, a = f.y / g, e = d + f.width / e, f = a + f.height / g);
  26291. g = f;
  26292. f = a;
  26293. a = g;
  26294. var h = 0,
  26295. k = 0;
  26296. c._batchNode ? (g = c._batchNode.textureAtlas.quads, h = c.atlasIndex, k = c.atlasIndex + c._totalParticles) : (g = this._quads, h = 0, k = c._totalParticles);
  26297. for (c = h; c < k; c++) g[c] || (g[c] = cc.V3F_C4B_T2F_QuadZero()), h = g[c], h.bl.texCoords.u = d, h.bl.texCoords.v = a, h.br.texCoords.u = e, h.br.texCoords.v = a, h.tl.texCoords.u = d, h.tl.texCoords.v = f, h.tr.texCoords.u = e, h.tr.texCoords.v =
  26298. f
  26299. };
  26300. a.setTotalParticles = function(a) {
  26301. var c = this._node;
  26302. if (a > c._allocatedParticles) {
  26303. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  26304. this._indices = new Uint16Array(6 * a);
  26305. var e = new ArrayBuffer(a * d),
  26306. f = c._particles;
  26307. f.length = 0;
  26308. for (var g = this._quads, h = g.length = 0; h < a; h++) f[h] = new cc.Particle, g[h] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, e, h * d);
  26309. c._allocatedParticles = a;
  26310. c._totalParticles = a;
  26311. if (c._batchNode)
  26312. for (d = 0; d < a; d++) f[d].atlasIndex = d;
  26313. this._quadsArrayBuffer = e;
  26314. this.initIndices(a);
  26315. this._setupVBO();
  26316. c._texture && this.initTexCoordsWithRect(cc.rect(0,
  26317. 0, c._texture.width, c._texture.height))
  26318. } else c._totalParticles = a;
  26319. c.resetSystem()
  26320. };
  26321. a.addParticle = function() {
  26322. var a = this._node;
  26323. return a._particles[a.particleCount]
  26324. };
  26325. a._setupVBO = function() {
  26326. var a = cc._renderContext;
  26327. this._buffersVBO[0] = a.createBuffer();
  26328. a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
  26329. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  26330. this._buffersVBO[1] = a.createBuffer();
  26331. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  26332. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices,
  26333. a.STATIC_DRAW)
  26334. };
  26335. a._allocMemory = function() {
  26336. var a = this._node;
  26337. if (a._batchNode) return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"), !1;
  26338. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  26339. a = a._totalParticles,
  26340. d = this._quads;
  26341. d.length = 0;
  26342. this._indices = new Uint16Array(6 * a);
  26343. for (var e = new ArrayBuffer(c * a), f = 0; f < a; f++) d[f] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, e, f * c);
  26344. if (!d || !this._indices) return cc.log("cocos2d: Particle system: not enough memory"), !1;
  26345. this._quadsArrayBuffer =
  26346. e;
  26347. return !0
  26348. };
  26349. a.postStep = function() {
  26350. var a = cc._renderContext;
  26351. a.bindBuffer(a.ARRAY_BUFFER, this._buffersVBO[0]);
  26352. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW)
  26353. };
  26354. a._setBlendAdditive = function() {
  26355. var a = this._node._blendFunc;
  26356. this._texture && !this._texture.hasPremultipliedAlpha() ? (a.src = cc.SRC_ALPHA, a.dst = cc.ONE_MINUS_SRC_ALPHA) : (a.src = cc.BLEND_SRC, a.dst = cc.BLEND_DST)
  26357. };
  26358. a._initWithTotalParticles = function(a) {
  26359. if (!this._allocMemory()) return !1;
  26360. this.initIndices(a);
  26361. this._setupVBO();
  26362. this._shaderProgram =
  26363. cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  26364. };
  26365. a._updateDeltaColor = function(a, c) {
  26366. a.color.r += a.deltaColor.r * c;
  26367. a.color.g += a.deltaColor.g * c;
  26368. a.color.b += a.deltaColor.b * c;
  26369. a.color.a += a.deltaColor.a * c;
  26370. a.isChangeColor = !0
  26371. }
  26372. })();
  26373. cc.ParticleFire = cc.ParticleSystem.extend({
  26374. ctor: function() {
  26375. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 300 : 150)
  26376. },
  26377. initWithTotalParticles: function(a) {
  26378. 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),
  26379. 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
  26380. }
  26381. });
  26382. cc.ParticleFire.create = function() {
  26383. return new cc.ParticleFire
  26384. };
  26385. cc.ParticleFireworks = cc.ParticleSystem.extend({
  26386. ctor: function() {
  26387. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1500 : 150)
  26388. },
  26389. initWithTotalParticles: function(a) {
  26390. 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(),
  26391. 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
  26392. }
  26393. });
  26394. cc.ParticleFireworks.create = function() {
  26395. return new cc.ParticleFireworks
  26396. };
  26397. cc.ParticleSun = cc.ParticleSystem.extend({
  26398. ctor: function() {
  26399. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 350 : 150)
  26400. },
  26401. initWithTotalParticles: function(a) {
  26402. 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),
  26403. 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
  26404. }
  26405. });
  26406. cc.ParticleSun.create = function() {
  26407. return new cc.ParticleSun
  26408. };
  26409. cc.ParticleGalaxy = cc.ParticleSystem.extend({
  26410. ctor: function() {
  26411. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
  26412. },
  26413. initWithTotalParticles: function(a) {
  26414. 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),
  26415. 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,
  26416. 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
  26417. }
  26418. });
  26419. cc.ParticleGalaxy.create = function() {
  26420. return new cc.ParticleGalaxy
  26421. };
  26422. cc.ParticleFlower = cc.ParticleSystem.extend({
  26423. ctor: function() {
  26424. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 250 : 100)
  26425. },
  26426. initWithTotalParticles: function(a) {
  26427. 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),
  26428. 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)),
  26429. this.setEndColorVar(cc.color(0, 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
  26430. }
  26431. });
  26432. cc.ParticleFlower.create = function() {
  26433. return new cc.ParticleFlower
  26434. };
  26435. cc.ParticleMeteor = cc.ParticleSystem.extend({
  26436. ctor: function() {
  26437. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 150 : 100)
  26438. },
  26439. initWithTotalParticles: function(a) {
  26440. 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),
  26441. 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,
  26442. 0, 0, 0)), this.setBlendAdditive(!0), !0) : !1
  26443. }
  26444. });
  26445. cc.ParticleMeteor.create = function() {
  26446. return new cc.ParticleMeteor
  26447. };
  26448. cc.ParticleSpiral = cc.ParticleSystem.extend({
  26449. ctor: function() {
  26450. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 500 : 100)
  26451. },
  26452. initWithTotalParticles: function(a) {
  26453. 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),
  26454. 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)),
  26455. this.setEndColorVar(cc.color(128, 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1
  26456. }
  26457. });
  26458. cc.ParticleSpiral.create = function() {
  26459. return new cc.ParticleSpiral
  26460. };
  26461. cc.ParticleExplosion = cc.ParticleSystem.extend({
  26462. ctor: function() {
  26463. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 300)
  26464. },
  26465. initWithTotalParticles: function(a) {
  26466. 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),
  26467. 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,
  26468. 128, 128, 0)), this.setBlendAdditive(!1), !0) : !1
  26469. }
  26470. });
  26471. cc.ParticleExplosion.create = function() {
  26472. return new cc.ParticleExplosion
  26473. };
  26474. cc.ParticleSmoke = cc.ParticleSystem.extend({
  26475. ctor: function() {
  26476. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 200 : 100)
  26477. },
  26478. initWithTotalParticles: function(a) {
  26479. 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),
  26480. 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
  26481. }
  26482. });
  26483. cc.ParticleSmoke.create = function() {
  26484. return new cc.ParticleSmoke
  26485. };
  26486. cc.ParticleSnow = cc.ParticleSystem.extend({
  26487. ctor: function() {
  26488. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 700 : 250)
  26489. },
  26490. initWithTotalParticles: function(a) {
  26491. 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),
  26492. 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,
  26493. 0, 0, 0)), this.setBlendAdditive(!1), !0) : !1
  26494. }
  26495. });
  26496. cc.ParticleSnow.create = function() {
  26497. return new cc.ParticleSnow
  26498. };
  26499. cc.ParticleRain = cc.ParticleSystem.extend({
  26500. ctor: function() {
  26501. cc.ParticleSystem.prototype.ctor.call(this, cc._renderType === cc._RENDER_TYPE_WEBGL ? 1E3 : 300)
  26502. },
  26503. initWithTotalParticles: function(a) {
  26504. 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),
  26505. 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
  26506. }
  26507. });
  26508. cc.ParticleRain.create = function() {
  26509. return new cc.ParticleRain
  26510. };
  26511. cc.PARTICLE_DEFAULT_CAPACITY = 500;
  26512. cc.ParticleBatchNode = cc.Node.extend({
  26513. textureAtlas: null,
  26514. _blendFunc: null,
  26515. _className: "ParticleBatchNode",
  26516. ctor: function(a, b) {
  26517. cc.Node.prototype.ctor.call(this);
  26518. this._blendFunc = {
  26519. src: cc.BLEND_SRC,
  26520. dst: cc.BLEND_DST
  26521. };
  26522. cc.isString(a) ? this.init(a, b) : a instanceof cc.Texture2D && this.initWithTexture(a, b)
  26523. },
  26524. _createRenderCmd: function() {
  26525. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ParticleBatchNode.CanvasRenderCmd(this) : new cc.ParticleBatchNode.WebGLRenderCmd(this)
  26526. },
  26527. initWithTexture: function(a, b) {
  26528. this.textureAtlas =
  26529. new cc.TextureAtlas;
  26530. this.textureAtlas.initWithTexture(a, b);
  26531. this._children.length = 0;
  26532. this._renderCmd._initWithTexture();
  26533. return !0
  26534. },
  26535. initWithFile: function(a, b) {
  26536. var c = cc.textureCache.addImage(a);
  26537. return this.initWithTexture(c, b)
  26538. },
  26539. init: function(a, b) {
  26540. var c = cc.textureCache.addImage(a);
  26541. return this.initWithTexture(c, b)
  26542. },
  26543. addChild: function(a, b, c) {
  26544. if (!a) throw "cc.ParticleBatchNode.addChild() : child should be non-null";
  26545. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.addChild() : only supports cc.ParticleSystem as children";
  26546. b = null == b ? a.zIndex : b;
  26547. c = null == c ? a.tag : c;
  26548. if (a.getTexture() !== this.textureAtlas.texture) throw "cc.ParticleSystem.addChild() : the child is not using the same texture id";
  26549. var d = a.getBlendFunc();
  26550. if (0 === this._children.length) this.setBlendFunc(d);
  26551. else if (d.src !== this._blendFunc.src || d.dst !== this._blendFunc.dst) {
  26552. cc.log("cc.ParticleSystem.addChild() : Can't add a ParticleSystem that uses a different blending function");
  26553. return
  26554. }
  26555. b = this._addChildHelper(a, b, c);
  26556. c = 0;
  26557. 0 !== b ? (b = this._children[b - 1], c = b.getAtlasIndex() +
  26558. b.getTotalParticles()) : c = 0;
  26559. this.insertChild(a, c);
  26560. a.setBatchNode(this)
  26561. },
  26562. insertChild: function(a, b) {
  26563. var c = a.getTotalParticles(),
  26564. d = this.textureAtlas,
  26565. e = d.totalQuads;
  26566. a.setAtlasIndex(b);
  26567. e + c > d.getCapacity() && (this._increaseAtlasCapacityTo(e + c), d.fillWithEmptyQuadsFromIndex(d.getCapacity() - c, c));
  26568. a.getAtlasIndex() + c !== e && d.moveQuadsFromIndex(b, b + c);
  26569. d.increaseTotalQuadsWith(c);
  26570. this._updateAllAtlasIndexes()
  26571. },
  26572. removeChild: function(a, b) {
  26573. if (null != a) {
  26574. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children";
  26575. if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");
  26576. else {
  26577. cc.Node.prototype.removeChild.call(this, a, b);
  26578. var c = this.textureAtlas;
  26579. c.removeQuadsAtIndex(a.getAtlasIndex(), a.getTotalParticles());
  26580. c.fillWithEmptyQuadsFromIndex(c.totalQuads, a.getTotalParticles());
  26581. a.setBatchNode(null);
  26582. this._updateAllAtlasIndexes()
  26583. }
  26584. }
  26585. },
  26586. reorderChild: function(a, b) {
  26587. if (!a) throw "cc.ParticleBatchNode.reorderChild(): child should be non-null";
  26588. if (!(a instanceof cc.ParticleSystem)) throw "cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children";
  26589. if (-1 === this._children.indexOf(a)) cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");
  26590. else if (b !== a.zIndex) {
  26591. if (1 < this._children.length) {
  26592. var c = this._getCurrentIndex(a, b);
  26593. if (c.oldIndex !== c.newIndex) {
  26594. this._children.splice(c.oldIndex, 1);
  26595. this._children.splice(c.newIndex, 0, a);
  26596. c = a.getAtlasIndex();
  26597. this._updateAllAtlasIndexes();
  26598. for (var d = 0, e = this._children, f = 0; f < e.length; f++)
  26599. if (e[f] === a) {
  26600. d = a.getAtlasIndex();
  26601. break
  26602. }
  26603. this.textureAtlas.moveQuadsFromIndex(c, a.getTotalParticles(), d);
  26604. a.updateWithNoTime()
  26605. }
  26606. }
  26607. a._setLocalZOrder(b)
  26608. }
  26609. },
  26610. removeChildAtIndex: function(a, b) {
  26611. this.removeChild(this._children[i], b)
  26612. },
  26613. removeAllChildren: function(a) {
  26614. for (var b = this._children, c = 0; c < b.length; c++) b[c].setBatchNode(null);
  26615. cc.Node.prototype.removeAllChildren.call(this, a);
  26616. this.textureAtlas.removeAllQuads()
  26617. },
  26618. disableParticle: function(a) {
  26619. a = this.textureAtlas.quads[a];
  26620. 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;
  26621. this.textureAtlas._setDirty(!0)
  26622. },
  26623. getTexture: function() {
  26624. return this.textureAtlas.texture
  26625. },
  26626. setTexture: function(a) {
  26627. this.textureAtlas.texture = a;
  26628. var b = this._blendFunc;
  26629. a && !a.hasPremultipliedAlpha() && b.src === cc.BLEND_SRC && b.dst === cc.BLEND_DST && (b.src = cc.SRC_ALPHA, b.dst = cc.ONE_MINUS_SRC_ALPHA)
  26630. },
  26631. setBlendFunc: function(a, b) {
  26632. void 0 === b ? (this._blendFunc.src = a.src, this._blendFunc.dst = a.dst) : (this._blendFunc.src = a, this._blendFunc.src = b)
  26633. },
  26634. getBlendFunc: function() {
  26635. return new cc.BlendFunc(this._blendFunc.src, this._blendFunc.dst)
  26636. },
  26637. _updateAllAtlasIndexes: function() {
  26638. for (var a = 0, b = this._children, c = 0; c < b.length; c++) {
  26639. var d =
  26640. b[c];
  26641. d.setAtlasIndex(a);
  26642. a += d.getTotalParticles()
  26643. }
  26644. },
  26645. _increaseAtlasCapacityTo: function(a) {
  26646. cc.log("cocos2d: cc.ParticleBatchNode: resizing TextureAtlas capacity from [" + this.textureAtlas.getCapacity() + "] to [" + a + "].");
  26647. this.textureAtlas.resizeCapacity(a) || cc.log("cc.ParticleBatchNode._increaseAtlasCapacityTo() : WARNING: Not enough memory to resize the atlas")
  26648. },
  26649. _searchNewPositionInChildrenForZ: function(a) {
  26650. for (var b = this._children, c = b.length, d = 0; d < c; d++)
  26651. if (b[d].zIndex > a) return d;
  26652. return c
  26653. },
  26654. _getCurrentIndex: function(a,
  26655. b) {
  26656. for (var c = !1, d = !1, e = 0, f = 0, g = 0, h = this._children, k = h.length, m = 0; m < k; m++) {
  26657. var n = h[m];
  26658. if (n.zIndex > b && !d && (e = m, d = !0, c && d)) break;
  26659. if (a === n && (f = m, c = !0, d || (g = -1), c && d)) break
  26660. }
  26661. d || (e = k);
  26662. return {
  26663. newIndex: e + g,
  26664. oldIndex: f
  26665. }
  26666. },
  26667. _addChildHelper: function(a, b, c) {
  26668. if (!a) throw "cc.ParticleBatchNode._addChildHelper(): child should be non-null";
  26669. if (a.parent) return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"), null;
  26670. this._children || (this._children = []);
  26671. var d = this._searchNewPositionInChildrenForZ(b);
  26672. this._children.splice(d, 0, a);
  26673. a.tag = c;
  26674. a._setLocalZOrder(b);
  26675. a.parent = this;
  26676. this._running && (a.onEnter(), a.onEnterTransitionDidFinish());
  26677. return d
  26678. },
  26679. _updateBlendFunc: function() {
  26680. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  26681. },
  26682. getTextureAtlas: function() {
  26683. return this.textureAtlas
  26684. },
  26685. setTextureAtlas: function(a) {
  26686. this.textureAtlas = a
  26687. }
  26688. });
  26689. _p = cc.ParticleBatchNode.prototype;
  26690. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  26691. cc.ParticleBatchNode.create = function(a, b) {
  26692. return new cc.ParticleBatchNode(a, b)
  26693. };
  26694. (function() {
  26695. cc.ParticleBatchNode.CanvasRenderCmd = function(a) {
  26696. cc.Node.CanvasRenderCmd.call(this, a);
  26697. this._needDraw = !1
  26698. };
  26699. var a = cc.ParticleBatchNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  26700. a.constructor = cc.ParticleBatchNode.CanvasRenderCmd;
  26701. a._initWithTexture = function() {}
  26702. })();
  26703. (function() {
  26704. cc.ParticleBatchNode.WebGLRenderCmd = function(a) {
  26705. cc.Node.WebGLRenderCmd.call(this, a);
  26706. this._needDraw = !0
  26707. };
  26708. var a = cc.ParticleBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  26709. a.constructor = cc.ParticleBatchNode.WebGLRenderCmd;
  26710. a.rendering = function(a) {
  26711. a = this._node;
  26712. 0 !== a.textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), cc.glBlendFuncForParticle(a._blendFunc.src, a._blendFunc.dst), a.textureAtlas.drawQuads())
  26713. };
  26714. a._initWithTexture = function() {
  26715. this._shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)
  26716. };
  26717. a.visit = function(a) {
  26718. if (this._node._visible) {
  26719. var c = cc.current_stack;
  26720. c.stack.push(c.top);
  26721. this._syncStatus(a);
  26722. c.top = this._stackMatrix;
  26723. cc.renderer.pushRenderCommand(this);
  26724. this._dirtyFlag = 0;
  26725. cc.kmGLPopMatrix()
  26726. }
  26727. }
  26728. })();
  26729. cc.IMEKeyboardNotificationInfo = function(a, b, c) {
  26730. this.begin = a || cc.rect(0, 0, 0, 0);
  26731. this.end = b || cc.rect(0, 0, 0, 0);
  26732. this.duration = c || 0
  26733. };
  26734. cc.IMEDelegate = cc.Class.extend({
  26735. ctor: function() {
  26736. cc.imeDispatcher.addDelegate(this)
  26737. },
  26738. removeDelegate: function() {
  26739. cc.imeDispatcher.removeDelegate(this)
  26740. },
  26741. attachWithIME: function() {
  26742. return cc.imeDispatcher.attachDelegateWithIME(this)
  26743. },
  26744. detachWithIME: function() {
  26745. return cc.imeDispatcher.detachDelegateWithIME(this)
  26746. },
  26747. canAttachWithIME: function() {
  26748. return !1
  26749. },
  26750. didAttachWithIME: function() {},
  26751. canDetachWithIME: function() {
  26752. return !1
  26753. },
  26754. didDetachWithIME: function() {},
  26755. insertText: function(a, b) {},
  26756. deleteBackward: function() {},
  26757. getContentText: function() {
  26758. return ""
  26759. },
  26760. keyboardWillShow: function(a) {},
  26761. keyboardDidShow: function(a) {},
  26762. keyboardWillHide: function(a) {},
  26763. keyboardDidHide: function(a) {}
  26764. });
  26765. cc.IMEDispatcher = cc.Class.extend({
  26766. _domInputControl: null,
  26767. impl: null,
  26768. _currentInputString: "",
  26769. _lastClickPosition: null,
  26770. ctor: function() {
  26771. this.impl = new cc.IMEDispatcher.Impl;
  26772. this._lastClickPosition = cc.p(0, 0)
  26773. },
  26774. init: function() {
  26775. if (!cc.sys.isMobile) {
  26776. this._domInputControl = cc.$("#imeDispatcherInput");
  26777. 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,
  26778. 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));
  26779. var a = this;
  26780. cc._addEventListener(this._domInputControl, "input", function() {
  26781. a._processDomInputString(a._domInputControl.value)
  26782. }, !1);
  26783. cc._addEventListener(this._domInputControl, "keydown", function(b) {
  26784. b.keyCode ===
  26785. cc.KEY.tab ? (b.stopPropagation(), b.preventDefault()) : b.keyCode === cc.KEY.enter && (a.dispatchInsertText("\n", 1), b.stopPropagation(), b.preventDefault())
  26786. }, !1);
  26787. /msie/i.test(navigator.userAgent) && cc._addEventListener(this._domInputControl, "keyup", function(b) {
  26788. b.keyCode === cc.KEY.backspace && a._processDomInputString(a._domInputControl.value)
  26789. }, !1);
  26790. cc._addEventListener(window, "mousedown", function(b) {
  26791. var c = b.pageY || 0;
  26792. a._lastClickPosition.x = b.pageX || 0;
  26793. a._lastClickPosition.y = c
  26794. }, !1)
  26795. }
  26796. },
  26797. _processDomInputString: function(a) {
  26798. var b,
  26799. c;
  26800. b = this._currentInputString.length < a.length ? this._currentInputString.length : a.length;
  26801. for (c = 0; c < b && a[c] === this._currentInputString[c]; c++);
  26802. var d = this._currentInputString.length - c,
  26803. e = a.length - c;
  26804. for (b = 0; b < d; b++) this.dispatchDeleteBackward();
  26805. for (b = 0; b < e; b++) this.dispatchInsertText(a[c + b], 1);
  26806. this._currentInputString = a
  26807. },
  26808. dispatchInsertText: function(a, b) {
  26809. !this.impl || !a || 0 >= b || this.impl._delegateWithIme && this.impl._delegateWithIme.insertText(a, b)
  26810. },
  26811. dispatchDeleteBackward: function() {
  26812. this.impl && this.impl._delegateWithIme &&
  26813. this.impl._delegateWithIme.deleteBackward()
  26814. },
  26815. getContentText: function() {
  26816. if (this.impl && this.impl._delegateWithIme) {
  26817. var a = this.impl._delegateWithIme.getContentText();
  26818. return a ? a : ""
  26819. }
  26820. return ""
  26821. },
  26822. dispatchKeyboardWillShow: function(a) {
  26823. if (this.impl)
  26824. for (var b = 0; b < this.impl._delegateList.length; b++) {
  26825. var c = this.impl._delegateList[b];
  26826. c && c.keyboardWillShow(a)
  26827. }
  26828. },
  26829. dispatchKeyboardDidShow: function(a) {
  26830. if (this.impl)
  26831. for (var b = 0; b < this.impl._delegateList.length; b++) {
  26832. var c = this.impl._delegateList[b];
  26833. c && c.keyboardDidShow(a)
  26834. }
  26835. },
  26836. dispatchKeyboardWillHide: function(a) {
  26837. if (this.impl)
  26838. for (var b = 0; b < this.impl._delegateList.length; b++) {
  26839. var c = this.impl._delegateList[b];
  26840. c && c.keyboardWillHide(a)
  26841. }
  26842. },
  26843. dispatchKeyboardDidHide: function(a) {
  26844. if (this.impl)
  26845. for (var b = 0; b < this.impl._delegateList.length; b++) {
  26846. var c = this.impl._delegateList[b];
  26847. c && c.keyboardDidHide(a)
  26848. }
  26849. },
  26850. addDelegate: function(a) {
  26851. a && this.impl && (-1 < this.impl._delegateList.indexOf(a) || this.impl._delegateList.splice(0, 0, a))
  26852. },
  26853. attachDelegateWithIME: function(a) {
  26854. if (!this.impl || !a || -1 === this.impl._delegateList.indexOf(a)) return !1;
  26855. if (this.impl._delegateWithIme) {
  26856. if (!this.impl._delegateWithIme.canDetachWithIME() || !a.canAttachWithIME()) return !1;
  26857. var b = this.impl._delegateWithIme;
  26858. this.impl._delegateWithIme = null;
  26859. b.didDetachWithIME();
  26860. this._focusDomInput(a);
  26861. return !0
  26862. }
  26863. if (!a.canAttachWithIME()) return !1;
  26864. this._focusDomInput(a);
  26865. return !0
  26866. },
  26867. _focusDomInput: function(a) {
  26868. cc.sys.isMobile ? (this.impl._delegateWithIme = a, a.didAttachWithIME(), this._currentInputString = a.string || "", a = a.getTipMessage ? a.getTipMessage() : "please enter your word:", a = prompt(a,
  26869. 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())
  26870. },
  26871. _domInputControlTranslate: function() {
  26872. /msie/i.test(navigator.userAgent) ? (this._domInputControl.style.left = this._lastClickPosition.x + "px", this._domInputControl.style.top = this._lastClickPosition.y + "px") :
  26873. this._domInputControl.translates(this._lastClickPosition.x, this._lastClickPosition.y)
  26874. },
  26875. detachDelegateWithIME: function(a) {
  26876. if (!this.impl || !a || this.impl._delegateWithIme !== a || !a.canDetachWithIME()) return !1;
  26877. this.impl._delegateWithIme = null;
  26878. a.didDetachWithIME();
  26879. cc._canvas.focus();
  26880. return !0
  26881. },
  26882. removeDelegate: function(a) {
  26883. 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,
  26884. a))
  26885. },
  26886. processKeycode: function(a) {
  26887. 32 > a ? a === cc.KEY.backspace ? this.dispatchDeleteBackward() : a === cc.KEY.enter && this.dispatchInsertText("\n", 1) : 255 > a && this.dispatchInsertText(String.fromCharCode(a), 1)
  26888. }
  26889. });
  26890. cc.IMEDispatcher.Impl = cc.Class.extend({
  26891. _delegateWithIme: null,
  26892. _delegateList: null,
  26893. ctor: function() {
  26894. this._delegateList = []
  26895. },
  26896. findDelegate: function(a) {
  26897. for (var b = 0; b < this._delegateList.length; b++)
  26898. if (this._delegateList[b] === a) return b;
  26899. return null
  26900. }
  26901. });
  26902. cc.imeDispatcher = new cc.IMEDispatcher;
  26903. document.body ? cc.imeDispatcher.init() : cc._addEventListener(window, "load", function() {
  26904. cc.imeDispatcher.init()
  26905. }, !1);
  26906. cc.TextFieldDelegate = cc.Class.extend({
  26907. onTextFieldAttachWithIME: function(a) {
  26908. return !1
  26909. },
  26910. onTextFieldDetachWithIME: function(a) {
  26911. return !1
  26912. },
  26913. onTextFieldInsertText: function(a, b, c) {
  26914. return !1
  26915. },
  26916. onTextFieldDeleteBackward: function(a, b, c) {
  26917. return !1
  26918. },
  26919. onDraw: function(a) {
  26920. return !1
  26921. }
  26922. });
  26923. cc.TextFieldTTF = cc.LabelTTF.extend({
  26924. delegate: null,
  26925. colorSpaceHolder: null,
  26926. _colorText: null,
  26927. _lens: null,
  26928. _inputText: "",
  26929. _placeHolder: "",
  26930. _charCount: 0,
  26931. _className: "TextFieldTTF",
  26932. ctor: function(a, b, c, d, e) {
  26933. this.colorSpaceHolder = cc.color(127, 127, 127);
  26934. this._colorText = cc.color(255, 255, 255, 255);
  26935. cc.imeDispatcher.addDelegate(this);
  26936. cc.LabelTTF.prototype.ctor.call(this);
  26937. void 0 !== e ? (this.initWithPlaceHolder("", b, c, d, e), a && this.setPlaceHolder(a)) : void 0 === d && void 0 !== c && (this.initWithString("", b, c), a && this.setPlaceHolder(a))
  26938. },
  26939. getDelegate: function() {
  26940. return this.delegate
  26941. },
  26942. setDelegate: function(a) {
  26943. this.delegate = a
  26944. },
  26945. getCharCount: function() {
  26946. return this._charCount
  26947. },
  26948. getColorSpaceHolder: function() {
  26949. return cc.color(this.colorSpaceHolder)
  26950. },
  26951. setColorSpaceHolder: function(a) {
  26952. this.colorSpaceHolder.r = a.r;
  26953. this.colorSpaceHolder.g = a.g;
  26954. this.colorSpaceHolder.b = a.b;
  26955. this.colorSpaceHolder.a = cc.isUndefined(a.a) ? 255 : a.a;
  26956. this._inputText.length || this.setColor(this.colorSpaceHolder)
  26957. },
  26958. setTextColor: function(a) {
  26959. this._colorText.r = a.r;
  26960. this._colorText.g = a.g;
  26961. this._colorText.b = a.b;
  26962. this._colorText.a = cc.isUndefined(a.a) ? 255 : a.a;
  26963. this._inputText.length && this.setColor(this._colorText)
  26964. },
  26965. initWithPlaceHolder: function(a, b, c, d, e) {
  26966. switch (arguments.length) {
  26967. case 5:
  26968. return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, d, e, b, c);
  26969. case 3:
  26970. return a && this.setPlaceHolder(a), this.initWithString(this._placeHolder, arguments[1], arguments[2]);
  26971. default:
  26972. throw "Argument must be non-nil ";
  26973. }
  26974. },
  26975. setString: function(a) {
  26976. this._inputText = (a = String(a)) || "";
  26977. this._inputText.length ?
  26978. (cc.LabelTTF.prototype.setString.call(this, this._inputText), this.setColor(this._colorText)) : (cc.LabelTTF.prototype.setString.call(this, this._placeHolder), this.setColor(this.colorSpaceHolder));
  26979. cc._renderType === cc._RENDER_TYPE_CANVAS && this._renderCmd._updateTexture();
  26980. this._charCount = this._inputText.length
  26981. },
  26982. getString: function() {
  26983. return this._inputText
  26984. },
  26985. setPlaceHolder: function(a) {
  26986. this._placeHolder = a || "";
  26987. this._inputText.length || (cc.LabelTTF.prototype.setString.call(this, this._placeHolder), this.setColor(this.colorSpaceHolder))
  26988. },
  26989. getPlaceHolder: function() {
  26990. return this._placeHolder
  26991. },
  26992. draw: function(a) {
  26993. a = a || cc._renderContext;
  26994. this.delegate && this.delegate.onDraw(this) || cc.LabelTTF.prototype.draw.call(this, a)
  26995. },
  26996. visit: function(a) {
  26997. this._super(a)
  26998. },
  26999. attachWithIME: function() {
  27000. return cc.imeDispatcher.attachDelegateWithIME(this)
  27001. },
  27002. detachWithIME: function() {
  27003. return cc.imeDispatcher.detachDelegateWithIME(this)
  27004. },
  27005. canAttachWithIME: function() {
  27006. return this.delegate ? !this.delegate.onTextFieldAttachWithIME(this) : !0
  27007. },
  27008. didAttachWithIME: function() {},
  27009. canDetachWithIME: function() {
  27010. return this.delegate ?
  27011. !this.delegate.onTextFieldDetachWithIME(this) : !0
  27012. },
  27013. didDetachWithIME: function() {},
  27014. deleteBackward: function() {
  27015. var a = this._inputText.length;
  27016. 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.setColor(this.colorSpaceHolder)) : this.string = this._inputText.substring(0, a - 1))
  27017. },
  27018. removeDelegate: function() {
  27019. cc.imeDispatcher.removeDelegate(this)
  27020. },
  27021. _tipMessage: "please enter your word:",
  27022. setTipMessage: function(a) {
  27023. null != a && (this._tipMessage = a)
  27024. },
  27025. getTipMessage: function() {
  27026. return this._tipMessage
  27027. },
  27028. insertText: function(a, b) {
  27029. var c = a,
  27030. d = c.indexOf("\n"); - 1 < d && (c = c.substring(0, d));
  27031. if (0 < c.length) {
  27032. if (this.delegate && this.delegate.onTextFieldInsertText(this, c, c.length)) return;
  27033. c = this._inputText + c;
  27034. this._charCount = c.length;
  27035. this.string = c
  27036. } - 1 !== d && (this.delegate && this.delegate.onTextFieldInsertText(this, "\n", 1) || this.detachWithIME())
  27037. },
  27038. getContentText: function() {
  27039. return this._inputText
  27040. },
  27041. keyboardWillShow: function(a) {},
  27042. keyboardDidShow: function(a) {},
  27043. keyboardWillHide: function(a) {},
  27044. keyboardDidHide: function(a) {}
  27045. });
  27046. _p = cc.TextFieldTTF.prototype;
  27047. cc.defineGetterSetter(_p, "charCount", _p.getCharCount);
  27048. cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
  27049. cc.TextFieldTTF.create = function(a, b, c, d, e) {
  27050. return new cc.TextFieldTTF(a, b, c, d, e)
  27051. };
  27052. cc._globalFontSize = cc.ITEM_SIZE;
  27053. cc._globalFontName = "Arial";
  27054. cc._globalFontNameRelease = !1;
  27055. cc.MenuItem = cc.Node.extend({
  27056. _enabled: !1,
  27057. _target: null,
  27058. _callback: null,
  27059. _isSelected: !1,
  27060. _className: "MenuItem",
  27061. ctor: function(a, b) {
  27062. var c = cc.Node.prototype;
  27063. c.ctor.call(this);
  27064. this._callback = this._target = null;
  27065. this._enabled = this._isSelected = !1;
  27066. c.setAnchorPoint.call(this, 0.5, 0.5);
  27067. this._target = b || null;
  27068. if (this._callback = a || null) this._enabled = !0
  27069. },
  27070. isSelected: function() {
  27071. return this._isSelected
  27072. },
  27073. setOpacityModifyRGB: function(a) {},
  27074. isOpacityModifyRGB: function() {
  27075. return !1
  27076. },
  27077. setTarget: function(a, b) {
  27078. this._target = b;
  27079. this._callback =
  27080. a
  27081. },
  27082. isEnabled: function() {
  27083. return this._enabled
  27084. },
  27085. setEnabled: function(a) {
  27086. this._enabled = a
  27087. },
  27088. initWithCallback: function(a, b) {
  27089. this.anchorY = this.anchorX = 0.5;
  27090. this._target = b;
  27091. this._callback = a;
  27092. this._enabled = !0;
  27093. this._isSelected = !1;
  27094. return !0
  27095. },
  27096. rect: function() {
  27097. var a = this._position,
  27098. b = this._contentSize,
  27099. c = this._anchorPoint;
  27100. return cc.rect(a.x - b.width * c.x, a.y - b.height * c.y, b.width, b.height)
  27101. },
  27102. selected: function() {
  27103. this._isSelected = !0
  27104. },
  27105. unselected: function() {
  27106. this._isSelected = !1
  27107. },
  27108. setCallback: function(a, b) {
  27109. this._target = b;
  27110. this._callback =
  27111. a
  27112. },
  27113. activate: function() {
  27114. if (this._enabled) {
  27115. var a = this._target,
  27116. b = this._callback;
  27117. if (b)
  27118. if (a && cc.isString(b)) a[b](this);
  27119. else a && cc.isFunction(b) ? b.call(a, this) : b(this)
  27120. }
  27121. }
  27122. });
  27123. _p = cc.MenuItem.prototype;
  27124. cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
  27125. cc.MenuItem.create = function(a, b) {
  27126. return new cc.MenuItem(a, b)
  27127. };
  27128. cc.MenuItemLabel = cc.MenuItem.extend({
  27129. _disabledColor: null,
  27130. _label: null,
  27131. _originalScale: 0,
  27132. _colorBackup: null,
  27133. ctor: function(a, b, c) {
  27134. cc.MenuItem.prototype.ctor.call(this, b, c);
  27135. this._colorBackup = this._label = this._disabledColor = null;
  27136. a && (this._originalScale = 1, this._colorBackup = cc.color.WHITE, this._disabledColor = cc.color(126, 126, 126), this.setLabel(a), this.cascadeOpacity = this.cascadeColor = !0)
  27137. },
  27138. getDisabledColor: function() {
  27139. return this._disabledColor
  27140. },
  27141. setDisabledColor: function(a) {
  27142. this._disabledColor = a
  27143. },
  27144. getLabel: function() {
  27145. return this._label
  27146. },
  27147. setLabel: function(a) {
  27148. a && (this.addChild(a), a.anchorX = 0, a.anchorY = 0, this.width = a.width, this.height = a.height);
  27149. this._label && this.removeChild(this._label, !0);
  27150. this._label = a
  27151. },
  27152. setEnabled: function(a) {
  27153. if (this._enabled !== a) {
  27154. var b = this._label;
  27155. a ? b.color = this._colorBackup : (this._colorBackup = b.color, b.color = this._disabledColor)
  27156. }
  27157. cc.MenuItem.prototype.setEnabled.call(this, a)
  27158. },
  27159. setOpacity: function(a) {
  27160. this._label.opacity = a
  27161. },
  27162. getOpacity: function() {
  27163. return this._label.opacity
  27164. },
  27165. setColor: function(a) {
  27166. this._label.color = a
  27167. },
  27168. getColor: function() {
  27169. return this._label.color
  27170. },
  27171. initWithLabel: function(a, b, c) {
  27172. this.initWithCallback(b, c);
  27173. this._originalScale = 1;
  27174. this._colorBackup = cc.color.WHITE;
  27175. this._disabledColor = cc.color(126, 126, 126);
  27176. this.setLabel(a);
  27177. return this.cascadeOpacity = this.cascadeColor = !0
  27178. },
  27179. setString: function(a) {
  27180. this._label.string = a;
  27181. this.width = this._label.width;
  27182. this.height = this._label.height
  27183. },
  27184. getString: function() {
  27185. return this._label.string
  27186. },
  27187. activate: function() {
  27188. this._enabled && (this.stopAllActions(), this.scale = this._originalScale, cc.MenuItem.prototype.activate.call(this))
  27189. },
  27190. selected: function() {
  27191. if (this._enabled) {
  27192. cc.MenuItem.prototype.selected.call(this);
  27193. var a = this.getActionByTag(cc.ZOOM_ACTION_TAG);
  27194. a ? this.stopAction(a) : this._originalScale = this.scale;
  27195. a = cc.scaleTo(0.1, 1.2 * this._originalScale);
  27196. a.setTag(cc.ZOOM_ACTION_TAG);
  27197. this.runAction(a)
  27198. }
  27199. },
  27200. unselected: function() {
  27201. if (this._enabled) {
  27202. cc.MenuItem.prototype.unselected.call(this);
  27203. this.stopActionByTag(cc.ZOOM_ACTION_TAG);
  27204. var a = cc.scaleTo(0.1, this._originalScale);
  27205. a.setTag(cc.ZOOM_ACTION_TAG);
  27206. this.runAction(a)
  27207. }
  27208. }
  27209. });
  27210. _p = cc.MenuItemLabel.prototype;
  27211. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  27212. cc.defineGetterSetter(_p, "disabledColor", _p.getDisabledColor, _p.setDisabledColor);
  27213. cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel);
  27214. cc.MenuItemLabel.create = function(a, b, c) {
  27215. return new cc.MenuItemLabel(a, b, c)
  27216. };
  27217. cc.MenuItemAtlasFont = cc.MenuItemLabel.extend({
  27218. ctor: function(a, b, c, d, e, f, g) {
  27219. var h;
  27220. a && 0 < a.length && (h = new cc.LabelAtlas(a, b, c, d, e));
  27221. cc.MenuItemLabel.prototype.ctor.call(this, h, f, g)
  27222. },
  27223. initWithString: function(a, b, c, d, e, f, g) {
  27224. if (!a || 0 === a.length) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0";
  27225. var h = new cc.LabelAtlas;
  27226. h.initWithString(a, b, c, d, e);
  27227. this.initWithLabel(h, f, g);
  27228. return !0
  27229. }
  27230. });
  27231. cc.MenuItemAtlasFont.create = function(a, b, c, d, e, f, g) {
  27232. return new cc.MenuItemAtlasFont(a, b, c, d, e, f, g)
  27233. };
  27234. cc.MenuItemFont = cc.MenuItemLabel.extend({
  27235. _fontSize: null,
  27236. _fontName: null,
  27237. ctor: function(a, b, c) {
  27238. var d;
  27239. a && 0 < a.length ? (this._fontName = cc._globalFontName, this._fontSize = cc._globalFontSize, d = new cc.LabelTTF(a, this._fontName, this._fontSize)) : (this._fontSize = 0, this._fontName = "");
  27240. cc.MenuItemLabel.prototype.ctor.call(this, d, b, c)
  27241. },
  27242. initWithString: function(a, b, c) {
  27243. if (!a || 0 === a.length) throw "Value should be non-null and its length should be greater than 0";
  27244. this._fontName = cc._globalFontName;
  27245. this._fontSize = cc._globalFontSize;
  27246. a = new cc.LabelTTF(a, this._fontName, this._fontSize);
  27247. this.initWithLabel(a, b, c);
  27248. return !0
  27249. },
  27250. setFontSize: function(a) {
  27251. this._fontSize = a;
  27252. this._recreateLabel()
  27253. },
  27254. getFontSize: function() {
  27255. return this._fontSize
  27256. },
  27257. setFontName: function(a) {
  27258. this._fontName = a;
  27259. this._recreateLabel()
  27260. },
  27261. getFontName: function() {
  27262. return this._fontName
  27263. },
  27264. _recreateLabel: function() {
  27265. var a = new cc.LabelTTF(this._label.string, this._fontName, this._fontSize);
  27266. this.setLabel(a)
  27267. }
  27268. });
  27269. cc.MenuItemFont.setFontSize = function(a) {
  27270. cc._globalFontSize = a
  27271. };
  27272. cc.MenuItemFont.fontSize = function() {
  27273. return cc._globalFontSize
  27274. };
  27275. cc.MenuItemFont.setFontName = function(a) {
  27276. cc._globalFontNameRelease && (cc._globalFontName = "");
  27277. cc._globalFontName = a;
  27278. cc._globalFontNameRelease = !0
  27279. };
  27280. _p = cc.MenuItemFont.prototype;
  27281. cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
  27282. cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
  27283. cc.MenuItemFont.fontName = function() {
  27284. return cc._globalFontName
  27285. };
  27286. cc.MenuItemFont.create = function(a, b, c) {
  27287. return new cc.MenuItemFont(a, b, c)
  27288. };
  27289. cc.MenuItemSprite = cc.MenuItem.extend({
  27290. _normalImage: null,
  27291. _selectedImage: null,
  27292. _disabledImage: null,
  27293. ctor: function(a, b, c, d, e) {
  27294. cc.MenuItem.prototype.ctor.call(this);
  27295. this._disabledImage = this._selectedImage = this._normalImage = null;
  27296. if (void 0 !== b) {
  27297. var f, g, h;
  27298. void 0 !== e ? (f = c, h = d, g = e) : void 0 !== d && cc.isFunction(d) ? (f = c, h = d) : void 0 !== d && cc.isFunction(c) ? (g = d, h = c, f = null) : void 0 === c && (f = null);
  27299. this.initWithNormalSprite(a, b, f, h, g)
  27300. }
  27301. },
  27302. getNormalImage: function() {
  27303. return this._normalImage
  27304. },
  27305. setNormalImage: function(a) {
  27306. this._normalImage !==
  27307. 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.addEventListener("load", function(a) {
  27308. this.width = a.width;
  27309. this.height = a.height
  27310. }, this))
  27311. },
  27312. getSelectedImage: function() {
  27313. return this._selectedImage
  27314. },
  27315. setSelectedImage: function(a) {
  27316. this._selectedImage !== a && (a && (this.addChild(a,
  27317. 0, cc.SELECTED_TAG), a.anchorX = 0, a.anchorY = 0), this._selectedImage && this.removeChild(this._selectedImage, !0), this._selectedImage = a, this._updateImagesVisibility())
  27318. },
  27319. getDisabledImage: function() {
  27320. return this._disabledImage
  27321. },
  27322. setDisabledImage: function(a) {
  27323. 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())
  27324. },
  27325. initWithNormalSprite: function(a, b, c, d, e) {
  27326. this.initWithCallback(d,
  27327. e);
  27328. this.setNormalImage(a);
  27329. this.setSelectedImage(b);
  27330. this.setDisabledImage(c);
  27331. if (a = this._normalImage) this.width = a.width, this.height = a.height, a.textureLoaded && !a.textureLoaded() && a.addEventListener("load", function(a) {
  27332. this.width = a.width;
  27333. this.height = a.height;
  27334. this.cascadeOpacity = this.cascadeColor = !0
  27335. }, this);
  27336. return this.cascadeOpacity = this.cascadeColor = !0
  27337. },
  27338. setColor: function(a) {
  27339. this._normalImage.color = a;
  27340. this._selectedImage && (this._selectedImage.color = a);
  27341. this._disabledImage && (this._disabledImage.color = a)
  27342. },
  27343. getColor: function() {
  27344. return this._normalImage.color
  27345. },
  27346. setOpacity: function(a) {
  27347. this._normalImage.opacity = a;
  27348. this._selectedImage && (this._selectedImage.opacity = a);
  27349. this._disabledImage && (this._disabledImage.opacity = a)
  27350. },
  27351. getOpacity: function() {
  27352. return this._normalImage.opacity
  27353. },
  27354. selected: function() {
  27355. cc.MenuItem.prototype.selected.call(this);
  27356. this._normalImage && (this._disabledImage && (this._disabledImage.visible = !1), this._selectedImage ? (this._normalImage.visible = !1, this._selectedImage.visible = !0) : this._normalImage.visible = !0)
  27357. },
  27358. unselected: function() {
  27359. cc.MenuItem.prototype.unselected.call(this);
  27360. this._normalImage && (this._normalImage.visible = !0, this._selectedImage && (this._selectedImage.visible = !1), this._disabledImage && (this._disabledImage.visible = !1))
  27361. },
  27362. setEnabled: function(a) {
  27363. this._enabled !== a && (cc.MenuItem.prototype.setEnabled.call(this, a), this._updateImagesVisibility())
  27364. },
  27365. _updateImagesVisibility: function() {
  27366. var a = this._normalImage,
  27367. b = this._selectedImage,
  27368. c = this._disabledImage;
  27369. this._enabled ? (a && (a.visible = !0), b && (b.visible = !1), c && (c.visible = !1)) : c ? (a && (a.visible = !1), b && (b.visible = !1), c && (c.visible = !0)) : (a && (a.visible = !0), b && (b.visible = !1))
  27370. }
  27371. });
  27372. _p = cc.MenuItemSprite.prototype;
  27373. cc.defineGetterSetter(_p, "normalImage", _p.getNormalImage, _p.setNormalImage);
  27374. cc.defineGetterSetter(_p, "selectedImage", _p.getSelectedImage, _p.setSelectedImage);
  27375. cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledImage);
  27376. cc.MenuItemSprite.create = function(a, b, c, d, e) {
  27377. return new cc.MenuItemSprite(a, b, c, d, e || void 0)
  27378. };
  27379. cc.MenuItemImage = cc.MenuItemSprite.extend({
  27380. ctor: function(a, b, c, d, e) {
  27381. var f = null,
  27382. g = null,
  27383. h = null,
  27384. k = null,
  27385. m = null;
  27386. void 0 === a ? cc.MenuItemSprite.prototype.ctor.call(this) : (f = new cc.Sprite(a), b && (g = new cc.Sprite(b)), void 0 === d ? k = c : void 0 === e ? (k = c, m = d) : e && (h = new cc.Sprite(c), k = d, m = e), cc.MenuItemSprite.prototype.ctor.call(this, f, g, h, k, m))
  27387. },
  27388. setNormalSpriteFrame: function(a) {
  27389. this.setNormalImage(new cc.Sprite(a))
  27390. },
  27391. setSelectedSpriteFrame: function(a) {
  27392. this.setSelectedImage(new cc.Sprite(a))
  27393. },
  27394. setDisabledSpriteFrame: function(a) {
  27395. this.setDisabledImage(new cc.Sprite(a))
  27396. },
  27397. initWithNormalImage: function(a, b, c, d, e) {
  27398. var f = null,
  27399. g = null,
  27400. h = null;
  27401. a && (f = new cc.Sprite(a));
  27402. b && (g = new cc.Sprite(b));
  27403. c && (h = new cc.Sprite(c));
  27404. return this.initWithNormalSprite(f, g, h, d, e)
  27405. }
  27406. });
  27407. cc.MenuItemImage.create = function(a, b, c, d, e) {
  27408. return new cc.MenuItemImage(a, b, c, d, e)
  27409. };
  27410. cc.MenuItemToggle = cc.MenuItem.extend({
  27411. subItems: null,
  27412. _selectedIndex: 0,
  27413. _opacity: null,
  27414. _color: null,
  27415. ctor: function() {
  27416. cc.MenuItem.prototype.ctor.call(this);
  27417. this._selectedIndex = 0;
  27418. this.subItems = [];
  27419. this._opacity = 0;
  27420. this._color = cc.color.WHITE;
  27421. 0 < arguments.length && this.initWithItems(Array.prototype.slice.apply(arguments))
  27422. },
  27423. getOpacity: function() {
  27424. return this._opacity
  27425. },
  27426. setOpacity: function(a) {
  27427. this._opacity = a;
  27428. if (this.subItems && 0 < this.subItems.length)
  27429. for (var b = 0; b < this.subItems.length; b++) this.subItems[b].opacity = a;
  27430. this._color.a = a
  27431. },
  27432. getColor: function() {
  27433. var a = this._color;
  27434. return cc.color(a.r, a.g, a.b, a.a)
  27435. },
  27436. setColor: function(a) {
  27437. var b = this._color;
  27438. b.r = a.r;
  27439. b.g = a.g;
  27440. b.b = a.b;
  27441. if (this.subItems && 0 < this.subItems.length)
  27442. for (b = 0; b < this.subItems.length; b++) this.subItems[b].setColor(a);
  27443. void 0 === a.a || a.a_undefined || this.setOpacity(a.a)
  27444. },
  27445. getSelectedIndex: function() {
  27446. return this._selectedIndex
  27447. },
  27448. setSelectedIndex: function(a) {
  27449. if (a !== this._selectedIndex) {
  27450. this._selectedIndex = a;
  27451. (a = this.getChildByTag(cc.CURRENT_ITEM)) && a.removeFromParent(!1);
  27452. a = this.subItems[this._selectedIndex];
  27453. this.addChild(a, 0, cc.CURRENT_ITEM);
  27454. var b = a.width,
  27455. c = a.height;
  27456. this.width = b;
  27457. this.height = c;
  27458. a.setPosition(b / 2, c / 2)
  27459. }
  27460. },
  27461. getSubItems: function() {
  27462. return this.subItems
  27463. },
  27464. setSubItems: function(a) {
  27465. this.subItems = a
  27466. },
  27467. initWithItems: function(a) {
  27468. var b = a.length;
  27469. cc.isFunction(a[a.length - 2]) ? (this.initWithCallback(a[a.length - 2], a[a.length - 1]), b -= 2) : cc.isFunction(a[a.length - 1]) ? (this.initWithCallback(a[a.length - 1], null), b -= 1) : this.initWithCallback(null, null);
  27470. for (var c = this.subItems, d = c.length =
  27471. 0; d < b; d++) a[d] && c.push(a[d]);
  27472. this._selectedIndex = cc.UINT_MAX;
  27473. this.setSelectedIndex(0);
  27474. return this.cascadeOpacity = this.cascadeColor = !0
  27475. },
  27476. addSubItem: function(a) {
  27477. this.subItems.push(a)
  27478. },
  27479. activate: function() {
  27480. this._enabled && this.setSelectedIndex((this._selectedIndex + 1) % this.subItems.length);
  27481. cc.MenuItem.prototype.activate.call(this)
  27482. },
  27483. selected: function() {
  27484. cc.MenuItem.prototype.selected.call(this);
  27485. this.subItems[this._selectedIndex].selected()
  27486. },
  27487. unselected: function() {
  27488. cc.MenuItem.prototype.unselected.call(this);
  27489. this.subItems[this._selectedIndex].unselected()
  27490. },
  27491. setEnabled: function(a) {
  27492. if (this._enabled !== a) {
  27493. cc.MenuItem.prototype.setEnabled.call(this, a);
  27494. var b = this.subItems;
  27495. if (b && 0 < b.length)
  27496. for (var c = 0; c < b.length; c++) b[c].enabled = a
  27497. }
  27498. },
  27499. selectedItem: function() {
  27500. return this.subItems[this._selectedIndex]
  27501. },
  27502. getSelectedItem: function() {
  27503. return this.subItems[this._selectedIndex]
  27504. },
  27505. onEnter: function() {
  27506. cc.Node.prototype.onEnter.call(this);
  27507. this.setSelectedIndex(this._selectedIndex)
  27508. }
  27509. });
  27510. _p = cc.MenuItemToggle.prototype;
  27511. cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIndex);
  27512. cc.MenuItemToggle.create = function() {
  27513. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  27514. var a = new cc.MenuItemToggle;
  27515. a.initWithItems(Array.prototype.slice.apply(arguments));
  27516. return a
  27517. };
  27518. cc.MENU_STATE_WAITING = 0;
  27519. cc.MENU_STATE_TRACKING_TOUCH = 1;
  27520. cc.MENU_HANDLER_PRIORITY = -128;
  27521. cc.DEFAULT_PADDING = 5;
  27522. cc.Menu = cc.Layer.extend({
  27523. enabled: !1,
  27524. _selectedItem: null,
  27525. _state: -1,
  27526. _touchListener: null,
  27527. _className: "Menu",
  27528. ctor: function(a) {
  27529. cc.Layer.prototype.ctor.call(this);
  27530. this._color = cc.color.WHITE;
  27531. this.enabled = !1;
  27532. this._opacity = 255;
  27533. this._selectedItem = null;
  27534. this._state = -1;
  27535. this._touchListener = cc.EventListener.create({
  27536. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  27537. swallowTouches: !0,
  27538. onTouchBegan: this._onTouchBegan,
  27539. onTouchMoved: this._onTouchMoved,
  27540. onTouchEnded: this._onTouchEnded,
  27541. onTouchCancelled: this._onTouchCancelled
  27542. });
  27543. 0 < arguments.length &&
  27544. null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  27545. var b = arguments.length,
  27546. c;
  27547. if (0 === b) c = [];
  27548. else if (1 === b) c = a instanceof Array ? a : [a];
  27549. else if (1 < b) {
  27550. c = [];
  27551. for (var d = 0; d < b; d++) arguments[d] && c.push(arguments[d])
  27552. }
  27553. this.initWithArray(c)
  27554. },
  27555. onEnter: function() {
  27556. var a = this._touchListener;
  27557. a._isRegistered() || cc.eventManager.addListener(a, this);
  27558. cc.Node.prototype.onEnter.call(this)
  27559. },
  27560. isEnabled: function() {
  27561. return this.enabled
  27562. },
  27563. setEnabled: function(a) {
  27564. this.enabled = a
  27565. },
  27566. initWithItems: function(a) {
  27567. var b = [];
  27568. if (a)
  27569. for (var c = 0; c < a.length; c++) a[c] && b.push(a[c]);
  27570. return this.initWithArray(b)
  27571. },
  27572. initWithArray: function(a) {
  27573. if (cc.Layer.prototype.init.call(this)) {
  27574. this.enabled = !0;
  27575. var b = cc.winSize;
  27576. this.setPosition(b.width / 2, b.height / 2);
  27577. this.setContentSize(b);
  27578. this.setAnchorPoint(0.5, 0.5);
  27579. this.ignoreAnchorPointForPosition(!0);
  27580. if (a)
  27581. for (b = 0; b < a.length; b++) this.addChild(a[b], b);
  27582. this._selectedItem = null;
  27583. this._state = cc.MENU_STATE_WAITING;
  27584. return this.cascadeOpacity = this.cascadeColor = !0
  27585. }
  27586. return !1
  27587. },
  27588. addChild: function(a, b, c) {
  27589. if (!(a instanceof cc.MenuItem)) throw "cc.Menu.addChild() : Menu only supports MenuItem objects as children";
  27590. cc.Layer.prototype.addChild.call(this, a, b, c)
  27591. },
  27592. alignItemsVertically: function() {
  27593. this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
  27594. },
  27595. alignItemsVerticallyWithPadding: function(a) {
  27596. var b = -a,
  27597. c = this._children,
  27598. d, e, f, g;
  27599. if (c && 0 < c.length) {
  27600. e = 0;
  27601. for (d = c.length; e < d; e++) b += c[e].height * c[e].scaleY + a;
  27602. var h = b / 2;
  27603. e = 0;
  27604. for (d = c.length; e < d; e++) g = c[e], f = g.height, b = g.scaleY, g.setPosition(0, h - f * b / 2), h -= f * b + a
  27605. }
  27606. },
  27607. alignItemsHorizontally: function() {
  27608. this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
  27609. },
  27610. alignItemsHorizontallyWithPadding: function(a) {
  27611. var b = -a,
  27612. c = this._children,
  27613. d, e, f, g;
  27614. if (c && 0 < c.length) {
  27615. d = 0;
  27616. for (e = c.length; d < e; d++) b += c[d].width * c[d].scaleX + a;
  27617. var h = -b / 2;
  27618. d = 0;
  27619. for (e = c.length; d < e; d++) g = c[d], b = g.scaleX, f = c[d].width, g.setPosition(h + f * b / 2, 0), h += f * b + a
  27620. }
  27621. },
  27622. alignItemsInColumns: function() {
  27623. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  27624. for (var a = [], b = 0; b < arguments.length; b++) a.push(arguments[b]);
  27625. var c = -5,
  27626. d = 0,
  27627. e = 0,
  27628. f = 0,
  27629. g, h, k, m =
  27630. this._children;
  27631. if (m && 0 < m.length)
  27632. for (b = 0, k = m.length; b < k; b++) d >= a.length || !(g = a[d]) || (h = m[b].height, e = e >= h || isNaN(h) ? e : h, ++f, f >= g && (c += e + 5, e = f = 0, ++d));
  27633. var n = cc.director.getWinSize(),
  27634. p = g = e = d = 0,
  27635. t = 0,
  27636. c = c / 2;
  27637. if (m && 0 < m.length)
  27638. for (b = 0, k = m.length; b < k; b++) {
  27639. var r = m[b];
  27640. 0 === g && (g = a[d], t = p = n.width / (1 + g));
  27641. h = r._getHeight();
  27642. e = e >= h || isNaN(h) ? e : h;
  27643. r.setPosition(t - n.width / 2, c - h / 2);
  27644. t += p;
  27645. ++f;
  27646. f >= g && (c -= e + 5, e = g = f = 0, ++d)
  27647. }
  27648. },
  27649. alignItemsInRows: function() {
  27650. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  27651. var a = [],
  27652. b;
  27653. for (b = 0; b < arguments.length; b++) a.push(arguments[b]);
  27654. var c = [],
  27655. d = [],
  27656. e = -10,
  27657. f = -5,
  27658. g = 0,
  27659. h = 0,
  27660. k = 0,
  27661. m, n, p, t, r = this._children;
  27662. if (r && 0 < r.length)
  27663. for (b = 0, p = r.length; b < p; b++)(n = r[b], g >= a.length || !(m = a[g])) || (t = n.width, h = h >= t || isNaN(t) ? h : t, f += n.height + 5, ++k, k >= m && (c.push(h), d.push(f), e += h + 10, h = k = 0, f = -5, ++g));
  27664. f = cc.director.getWinSize();
  27665. m = h = g = 0;
  27666. var e = -e / 2,
  27667. u = 0;
  27668. if (r && 0 < r.length)
  27669. for (b = 0, p = r.length; b < p; b++) n = r[b], 0 === m && (m = a[g], u = d[g]), t = n._getWidth(), h = h >= t || isNaN(t) ? h : t, n.setPosition(e + c[g] / 2, u - f.height / 2),
  27670. u -= n.height + 10, ++k, k >= m && (e += h + 5, h = m = k = 0, ++g)
  27671. },
  27672. removeChild: function(a, b) {
  27673. null != a && (a instanceof cc.MenuItem ? (this._selectedItem === a && (this._selectedItem = null), cc.Node.prototype.removeChild.call(this, a, b)) : cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children"))
  27674. },
  27675. _onTouchBegan: function(a, b) {
  27676. var c = b.getCurrentTarget();
  27677. if (c._state !== cc.MENU_STATE_WAITING || !c._visible || !c.enabled) return !1;
  27678. for (var d = c.parent; null != d; d = d.parent)
  27679. if (!d.isVisible()) return !1;
  27680. c._selectedItem = c._itemForTouch(a);
  27681. return c._selectedItem ? (c._state = cc.MENU_STATE_TRACKING_TOUCH, c._selectedItem.selected(), c._selectedItem.setNodeDirty(), !0) : !1
  27682. },
  27683. _onTouchEnded: function(a, b) {
  27684. var c = b.getCurrentTarget();
  27685. c._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchEnded(): invalid state") : (c._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty(), c._selectedItem.activate()), c._state = cc.MENU_STATE_WAITING)
  27686. },
  27687. _onTouchCancelled: function(a, b) {
  27688. var c = b.getCurrentTarget();
  27689. c._state !== cc.MENU_STATE_TRACKING_TOUCH ?
  27690. cc.log("cc.Menu.onTouchCancelled(): invalid state") : (this._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty()), c._state = cc.MENU_STATE_WAITING)
  27691. },
  27692. _onTouchMoved: function(a, b) {
  27693. var c = b.getCurrentTarget();
  27694. if (c._state !== cc.MENU_STATE_TRACKING_TOUCH) cc.log("cc.Menu.onTouchMoved(): invalid state");
  27695. else {
  27696. var d = c._itemForTouch(a);
  27697. d !== c._selectedItem && (c._selectedItem && (c._selectedItem.unselected(), c._selectedItem.setNodeDirty()), c._selectedItem = d, c._selectedItem && (c._selectedItem.selected(),
  27698. c._selectedItem.setNodeDirty()))
  27699. }
  27700. },
  27701. onExit: function() {
  27702. this._state === cc.MENU_STATE_TRACKING_TOUCH && (this._selectedItem && (this._selectedItem.unselected(), this._selectedItem = null), this._state = cc.MENU_STATE_WAITING);
  27703. cc.Node.prototype.onExit.call(this)
  27704. },
  27705. setOpacityModifyRGB: function(a) {},
  27706. isOpacityModifyRGB: function() {
  27707. return !1
  27708. },
  27709. _itemForTouch: function(a) {
  27710. a = a.getLocation();
  27711. var b = this._children,
  27712. c;
  27713. if (b && 0 < b.length)
  27714. for (var d = b.length - 1; 0 <= d; d--)
  27715. if (c = b[d], c.isVisible() && c.isEnabled()) {
  27716. var e = c.convertToNodeSpace(a),
  27717. f = c.rect();
  27718. f.x = 0;
  27719. f.y = 0;
  27720. if (cc.rectContainsPoint(f, e)) return c
  27721. }
  27722. return null
  27723. }
  27724. });
  27725. _p = cc.Menu.prototype;
  27726. cc.Menu.create = function(a) {
  27727. var b = arguments.length;
  27728. 0 < b && null == arguments[b - 1] && cc.log("parameters should not be ending with null in Javascript");
  27729. return 0 === b ? new cc.Menu : 1 === b ? new cc.Menu(a) : new cc.Menu(Array.prototype.slice.call(arguments, 0))
  27730. };
  27731. cc.TGA_OK = 0;
  27732. cc.TGA_ERROR_FILE_OPEN = 1;
  27733. cc.TGA_ERROR_READING_FILE = 2;
  27734. cc.TGA_ERROR_INDEXED_COLOR = 3;
  27735. cc.TGA_ERROR_MEMORY = 4;
  27736. cc.TGA_ERROR_COMPRESSED_FILE = 5;
  27737. cc.ImageTGA = function(a, b, c, d, e, f, g) {
  27738. this.status = a || 0;
  27739. this.type = b || 0;
  27740. this.pixelDepth = c || 0;
  27741. this.width = d || 0;
  27742. this.height = e || 0;
  27743. this.imageData = f || [];
  27744. this.flipped = g || 0
  27745. };
  27746. cc.tgaLoadHeader = function(a, b, c) {
  27747. var d = 2;
  27748. if (d + 1 > b) return !1;
  27749. a = new cc.BinaryStreamReader(a);
  27750. a.setOffset(d);
  27751. c.type = a.readByte();
  27752. d += 10;
  27753. if (d + 4 + 1 > b) return !1;
  27754. a.setOffset(d);
  27755. c.width = a.readUnsignedShort();
  27756. c.height = a.readUnsignedInteger();
  27757. c.pixelDepth = a.readByte();
  27758. if (d + 5 + 1 > b) return !1;
  27759. b = a.readByte();
  27760. c.flipped = 0;
  27761. b & 32 && (c.flipped = 1);
  27762. return !0
  27763. };
  27764. cc.tgaLoadImageData = function(a, b, c) {
  27765. var d, e;
  27766. d = 0 | c.pixelDepth / 2;
  27767. e = c.height * c.width * d;
  27768. if (18 + e > b) return !1;
  27769. c.imageData = cc.__getSubArray(a, 18, 18 + e);
  27770. if (3 <= d)
  27771. for (a = 0; a < e; a += d) b = c.imageData[a], c.imageData[a] = c.imageData[a + 2], c.imageData[a + 2] = b;
  27772. return !0
  27773. };
  27774. cc.tgaRGBtogreyscale = function(a) {
  27775. var b, c;
  27776. if (8 !== a.pixelDepth) {
  27777. var d = a.pixelDepth / 8,
  27778. e = new Uint8Array(a.height * a.width);
  27779. if (null !== e) {
  27780. for (c = b = 0; c < a.width * a.height; b += d, c++) e[c] = 0.3 * a.imageData[b] + 0.59 * a.imageData[b + 1] + 0.11 * a.imageData[b + 2];
  27781. a.pixelDepth = 8;
  27782. a.type = 3;
  27783. a.imageData = e
  27784. }
  27785. }
  27786. };
  27787. cc.tgaDestroy = function(a) {
  27788. a && (a.imageData = null)
  27789. };
  27790. cc.tgaLoadRLEImageData = function(a, b, c) {
  27791. var d, e, f, g = 0,
  27792. h = 0,
  27793. k = 0,
  27794. m = [],
  27795. n = 0,
  27796. p = 18;
  27797. d = c.pixelDepth / 8;
  27798. e = c.height * c.width;
  27799. for (f = 0; f < e; f++) {
  27800. if (0 !== n) n--, h = 0 !== k;
  27801. else {
  27802. if (p + 1 > b) break;
  27803. n = a[p];
  27804. p += 1;
  27805. (k = n & 128) && (n -= 128);
  27806. h = 0
  27807. } if (!h) {
  27808. if (p + d > b) break;
  27809. m = cc.__getSubArray(a, p, p + d);
  27810. p += d;
  27811. 3 <= d && (h = m[0], m[0] = m[2], m[2] = h)
  27812. }
  27813. for (h = 0; h < d; h++) c.imageData[g + h] = m[h];
  27814. g += d
  27815. }
  27816. return !0
  27817. };
  27818. cc.tgaFlipImage = function(a) {
  27819. for (var b = a.pixelDepth / 8 * a.width, c = 0; c < a.height / 2; c++) {
  27820. var d = cc.__getSubArray(a.imageData, c * b, c * b + b);
  27821. cc.__setDataToArray(cc.__getSubArray(a.imageData, (a.height - (c + 1)) * b, b), a.imageData, c * b);
  27822. cc.__setDataToArray(d, a.imageData, (a.height - (c + 1)) * b)
  27823. }
  27824. a.flipped = 0
  27825. };
  27826. cc.__getSubArray = function(a, b, c) {
  27827. return a instanceof Array ? a.slice(b, c) : a.subarray(b, c)
  27828. };
  27829. cc.__setDataToArray = function(a, b, c) {
  27830. for (var d = 0; d < a.length; d++) b[c + d] = a[d]
  27831. };
  27832. cc.BinaryStreamReader = cc.Class.extend({
  27833. _binaryData: null,
  27834. _offset: 0,
  27835. ctor: function(a) {
  27836. this._binaryData = a
  27837. },
  27838. setBinaryData: function(a) {
  27839. this._binaryData = a;
  27840. this._offset = 0
  27841. },
  27842. getBinaryData: function() {
  27843. return this._binaryData
  27844. },
  27845. _checkSize: function(a) {
  27846. if (!(this._offset + Math.ceil(a / 8) < this._data.length)) throw Error("Index out of bound");
  27847. },
  27848. _decodeFloat: function(a, b) {
  27849. var c = a + b + 1,
  27850. d = c >> 3;
  27851. this._checkSize(c);
  27852. var c = Math.pow(2, b - 1) - 1,
  27853. e = this._readBits(a + b, 1, d),
  27854. f = this._readBits(a, b, d),
  27855. g = 0,
  27856. h = 2,
  27857. k = 0;
  27858. do
  27859. for (var m = this._readByte(++k,
  27860. d), n = a % 8 || 8, p = 1 << n; p >>= 1;) m & p && (g += 1 / h), h *= 2; while (a -= n);
  27861. this._offset += d;
  27862. return f === (c << 1) + 1 ? g ? NaN : e ? -Infinity : Infinity : (1 + -2 * e) * (f || g ? f ? Math.pow(2, f - c) * (1 + g) : Math.pow(2, -c + 1) * g : 0)
  27863. },
  27864. _readByte: function(a, b) {
  27865. return this._data[this._offset + b - a - 1]
  27866. },
  27867. _decodeInt: function(a, b) {
  27868. var c = this._readBits(0, a, a / 8),
  27869. d = Math.pow(2, a);
  27870. this._offset += a / 8;
  27871. return b && c >= d / 2 ? c - d : c
  27872. },
  27873. _shl: function(a, b) {
  27874. for (++b; --b; a = 1073741824 === ((a %= 2147483648) & 1073741824) ? 2 * a : 2 * (a - 1073741824) + 2147483648);
  27875. return a
  27876. },
  27877. _readBits: function(a, b, c) {
  27878. var d =
  27879. (a + b) % 8,
  27880. e = a % 8,
  27881. f = c - (a >> 3) - 1;
  27882. a = c + (-(a + b) >> 3);
  27883. var g = f - a;
  27884. b = this._readByte(f, c) >> e & (1 << (g ? 8 - e : b)) - 1;
  27885. for (g && d && (b += (this._readByte(a++, c) & (1 << d) - 1) << (g-- << 3) - e); g;) b += this._shl(this._readByte(a++, c), (g-- << 3) - e);
  27886. return b
  27887. },
  27888. readInteger: function() {
  27889. return this._decodeInt(32, !0)
  27890. },
  27891. readUnsignedInteger: function() {
  27892. return this._decodeInt(32, !1)
  27893. },
  27894. readSingle: function() {
  27895. return this._decodeFloat(23, 8)
  27896. },
  27897. readShort: function() {
  27898. return this._decodeInt(16, !0)
  27899. },
  27900. readUnsignedShort: function() {
  27901. return this._decodeInt(16, !1)
  27902. },
  27903. readByte: function() {
  27904. var a =
  27905. this._data[this._offset];
  27906. this._offset += 1;
  27907. return a
  27908. },
  27909. readData: function(a, b) {
  27910. return this._binaryData instanceof Array ? this._binaryData.slice(a, b) : this._binaryData.subarray(a, b)
  27911. },
  27912. setOffset: function(a) {
  27913. this._offset = a
  27914. },
  27915. getOffset: function() {
  27916. return this._offset
  27917. }
  27918. });
  27919. cc.TMX_ORIENTATION_ORTHO = 0;
  27920. cc.TMX_ORIENTATION_HEX = 1;
  27921. cc.TMX_ORIENTATION_ISO = 2;
  27922. cc.TMXTiledMap = cc.Node.extend({
  27923. properties: null,
  27924. mapOrientation: null,
  27925. objectGroups: null,
  27926. _mapSize: null,
  27927. _tileSize: null,
  27928. _tileProperties: null,
  27929. _className: "TMXTiledMap",
  27930. ctor: function(a, b) {
  27931. cc.Node.prototype.ctor.call(this);
  27932. this._mapSize = cc.size(0, 0);
  27933. this._tileSize = cc.size(0, 0);
  27934. void 0 !== b ? this.initWithXML(a, b) : void 0 !== a && this.initWithTMXFile(a)
  27935. },
  27936. getMapSize: function() {
  27937. return cc.size(this._mapSize.width, this._mapSize.height)
  27938. },
  27939. setMapSize: function(a) {
  27940. this._mapSize.width = a.width;
  27941. this._mapSize.height = a.height
  27942. },
  27943. _getMapWidth: function() {
  27944. return this._mapSize.width
  27945. },
  27946. _setMapWidth: function(a) {
  27947. this._mapSize.width = a
  27948. },
  27949. _getMapHeight: function() {
  27950. return this._mapSize.height
  27951. },
  27952. _setMapHeight: function(a) {
  27953. this._mapSize.height = a
  27954. },
  27955. getTileSize: function() {
  27956. return cc.size(this._tileSize.width, this._tileSize.height)
  27957. },
  27958. setTileSize: function(a) {
  27959. this._tileSize.width = a.width;
  27960. this._tileSize.height = a.height
  27961. },
  27962. _getTileWidth: function() {
  27963. return this._tileSize.width
  27964. },
  27965. _setTileWidth: function(a) {
  27966. this._tileSize.width = a
  27967. },
  27968. _getTileHeight: function() {
  27969. return this._tileSize.height
  27970. },
  27971. _setTileHeight: function(a) {
  27972. this._tileSize.height =
  27973. a
  27974. },
  27975. getMapOrientation: function() {
  27976. return this.mapOrientation
  27977. },
  27978. setMapOrientation: function(a) {
  27979. this.mapOrientation = a
  27980. },
  27981. getObjectGroups: function() {
  27982. return this.objectGroups
  27983. },
  27984. setObjectGroups: function(a) {
  27985. this.objectGroups = a
  27986. },
  27987. getProperties: function() {
  27988. return this.properties
  27989. },
  27990. setProperties: function(a) {
  27991. this.properties = a
  27992. },
  27993. initWithTMXFile: function(a) {
  27994. if (!a || 0 === a.length) throw "cc.TMXTiledMap.initWithTMXFile(): tmxFile should be non-null or non-empty string.";
  27995. this.height = this.width = 0;
  27996. a = new cc.TMXMapInfo(a);
  27997. if (!a) return !1;
  27998. var b = a.getTilesets();
  27999. b && 0 !== b.length || cc.log("cc.TMXTiledMap.initWithTMXFile(): Map not found. Please check the filename.");
  28000. this._buildWithMapInfo(a);
  28001. return !0
  28002. },
  28003. initWithXML: function(a, b) {
  28004. this.height = this.width = 0;
  28005. var c = new cc.TMXMapInfo(a, b),
  28006. d = c.getTilesets();
  28007. d && 0 !== d.length || cc.log("cc.TMXTiledMap.initWithXML(): Map not found. Please check the filename.");
  28008. this._buildWithMapInfo(c);
  28009. return !0
  28010. },
  28011. _buildWithMapInfo: function(a) {
  28012. this._mapSize = a.getMapSize();
  28013. this._tileSize = a.getTileSize();
  28014. this.mapOrientation =
  28015. a.orientation;
  28016. this.objectGroups = a.getObjectGroups();
  28017. this.properties = a.properties;
  28018. this._tileProperties = a.getTileProperties();
  28019. var b = 0,
  28020. c = a.getLayers();
  28021. if (c)
  28022. for (var d = null, e = 0, f = c.length; e < f; e++)(d = c[e]) && d.visible && (d = this._parseLayer(d, a), this.addChild(d, b, b), this.width = Math.max(this.width, d.width), this.height = Math.max(this.height, d.height), b++)
  28023. },
  28024. allLayers: function() {
  28025. for (var a = [], b = this._children, c = 0, d = b.length; c < d; c++) {
  28026. var e = b[c];
  28027. e && e instanceof cc.TMXLayer && a.push(e)
  28028. }
  28029. return a
  28030. },
  28031. getLayer: function(a) {
  28032. if (!a ||
  28033. 0 === a.length) throw "cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.";
  28034. for (var b = this._children, c = 0; c < b.length; c++) {
  28035. var d = b[c];
  28036. if (d && d.layerName === a) return d
  28037. }
  28038. return null
  28039. },
  28040. getObjectGroup: function(a) {
  28041. if (!a || 0 === a.length) throw "cc.TMXTiledMap.getObjectGroup(): groupName should be non-null or non-empty string.";
  28042. if (this.objectGroups)
  28043. for (var b = 0; b < this.objectGroups.length; b++) {
  28044. var c = this.objectGroups[b];
  28045. if (c && c.groupName === a) return c
  28046. }
  28047. return null
  28048. },
  28049. getProperty: function(a) {
  28050. return this.properties[a.toString()]
  28051. },
  28052. propertiesForGID: function(a) {
  28053. cc.log("propertiesForGID is deprecated. Please use getPropertiesForGID instead.");
  28054. return this.getPropertiesForGID[a]
  28055. },
  28056. getPropertiesForGID: function(a) {
  28057. return this._tileProperties[a]
  28058. },
  28059. _parseLayer: function(a, b) {
  28060. var c = this._tilesetForLayer(a, b),
  28061. c = new cc.TMXLayer(c, a, b);
  28062. a.ownTiles = !1;
  28063. c.setupTiles();
  28064. return c
  28065. },
  28066. _tilesetForLayer: function(a, b) {
  28067. var c = a._layerSize,
  28068. d = b.getTilesets();
  28069. if (d)
  28070. for (var e = d.length - 1; 0 <= e; e--) {
  28071. var f = d[e];
  28072. if (f)
  28073. for (var g = 0; g < c.height; g++)
  28074. for (var h = 0; h < c.width; h++) {
  28075. var k =
  28076. a._tiles[h + c.width * g];
  28077. if (0 !== k && (k & cc.TMX_TILE_FLIPPED_MASK) >>> 0 >= f.firstGid) return f
  28078. }
  28079. }
  28080. cc.log("cocos2d: Warning: TMX Layer " + a.name + " has no tiles");
  28081. return null
  28082. }
  28083. });
  28084. _p = cc.TMXTiledMap.prototype;
  28085. cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
  28086. cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
  28087. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  28088. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  28089. cc.TMXTiledMap.create = function(a, b) {
  28090. return new cc.TMXTiledMap(a, b)
  28091. };
  28092. cc.TMX_PROPERTY_NONE = 0;
  28093. cc.TMX_PROPERTY_MAP = 1;
  28094. cc.TMX_PROPERTY_LAYER = 2;
  28095. cc.TMX_PROPERTY_OBJECTGROUP = 3;
  28096. cc.TMX_PROPERTY_OBJECT = 4;
  28097. cc.TMX_PROPERTY_TILE = 5;
  28098. cc.TMX_TILE_HORIZONTAL_FLAG = 2147483648;
  28099. cc.TMX_TILE_VERTICAL_FLAG = 1073741824;
  28100. cc.TMX_TILE_DIAGONAL_FLAG = 536870912;
  28101. cc.TMX_TILE_FLIPPED_ALL = (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG | cc.TMX_TILE_DIAGONAL_FLAG) >>> 0;
  28102. cc.TMX_TILE_FLIPPED_MASK = ~cc.TMX_TILE_FLIPPED_ALL >>> 0;
  28103. cc.TMXLayerInfo = cc.Class.extend({
  28104. properties: null,
  28105. name: "",
  28106. _layerSize: null,
  28107. _tiles: null,
  28108. visible: null,
  28109. _opacity: null,
  28110. ownTiles: !0,
  28111. _minGID: 1E5,
  28112. _maxGID: 0,
  28113. offset: null,
  28114. ctor: function() {
  28115. this.properties = [];
  28116. this.name = "";
  28117. this._layerSize = null;
  28118. this._tiles = [];
  28119. this.visible = !0;
  28120. this._opacity = 0;
  28121. this.ownTiles = !0;
  28122. this._minGID = 1E5;
  28123. this._maxGID = 0;
  28124. this.offset = cc.p(0, 0)
  28125. },
  28126. getProperties: function() {
  28127. return this.properties
  28128. },
  28129. setProperties: function(a) {
  28130. this.properties = a
  28131. }
  28132. });
  28133. cc.TMXTilesetInfo = cc.Class.extend({
  28134. name: "",
  28135. firstGid: 0,
  28136. _tileSize: null,
  28137. spacing: 0,
  28138. margin: 0,
  28139. sourceImage: "",
  28140. imageSize: null,
  28141. ctor: function() {
  28142. this._tileSize = cc.size(0, 0);
  28143. this.imageSize = cc.size(0, 0)
  28144. },
  28145. rectForGID: function(a) {
  28146. var b = cc.rect(0, 0, 0, 0);
  28147. b.width = this._tileSize.width;
  28148. b.height = this._tileSize.height;
  28149. a &= cc.TMX_TILE_FLIPPED_MASK;
  28150. a -= parseInt(this.firstGid, 10);
  28151. var c = parseInt((this.imageSize.width - 2 * this.margin + this.spacing) / (this._tileSize.width + this.spacing), 10);
  28152. b.x = parseInt(a % c * (this._tileSize.width + this.spacing) +
  28153. this.margin, 10);
  28154. b.y = parseInt(parseInt(a / c, 10) * (this._tileSize.height + this.spacing) + this.margin, 10);
  28155. return b
  28156. }
  28157. });
  28158. cc.TMXMapInfo = cc.SAXParser.extend({
  28159. properties: null,
  28160. orientation: null,
  28161. parentElement: null,
  28162. parentGID: null,
  28163. layerAttrs: 0,
  28164. storingCharacters: !1,
  28165. tmxFileName: null,
  28166. currentString: null,
  28167. _objectGroups: null,
  28168. _mapSize: null,
  28169. _tileSize: null,
  28170. _layers: null,
  28171. _tilesets: null,
  28172. _tileProperties: null,
  28173. _resources: "",
  28174. _currentFirstGID: 0,
  28175. ctor: function(a, b) {
  28176. cc.SAXParser.prototype.ctor.apply(this);
  28177. this._mapSize = cc.size(0, 0);
  28178. this._tileSize = cc.size(0, 0);
  28179. this._layers = [];
  28180. this._tilesets = [];
  28181. this._objectGroups = [];
  28182. this.properties = [];
  28183. this._tileProperties = {};
  28184. this._currentFirstGID = 0;
  28185. void 0 !== b ? this.initWithXML(a, b) : void 0 !== a && this.initWithTMXFile(a)
  28186. },
  28187. getOrientation: function() {
  28188. return this.orientation
  28189. },
  28190. setOrientation: function(a) {
  28191. this.orientation = a
  28192. },
  28193. getMapSize: function() {
  28194. return cc.size(this._mapSize.width, this._mapSize.height)
  28195. },
  28196. setMapSize: function(a) {
  28197. this._mapSize.width = a.width;
  28198. this._mapSize.height = a.height
  28199. },
  28200. _getMapWidth: function() {
  28201. return this._mapSize.width
  28202. },
  28203. _setMapWidth: function(a) {
  28204. this._mapSize.width = a
  28205. },
  28206. _getMapHeight: function() {
  28207. return this._mapSize.height
  28208. },
  28209. _setMapHeight: function(a) {
  28210. this._mapSize.height = a
  28211. },
  28212. getTileSize: function() {
  28213. return cc.size(this._tileSize.width, this._tileSize.height)
  28214. },
  28215. setTileSize: function(a) {
  28216. this._tileSize.width = a.width;
  28217. this._tileSize.height = a.height
  28218. },
  28219. _getTileWidth: function() {
  28220. return this._tileSize.width
  28221. },
  28222. _setTileWidth: function(a) {
  28223. this._tileSize.width = a
  28224. },
  28225. _getTileHeight: function() {
  28226. return this._tileSize.height
  28227. },
  28228. _setTileHeight: function(a) {
  28229. this._tileSize.height = a
  28230. },
  28231. getLayers: function() {
  28232. return this._layers
  28233. },
  28234. setLayers: function(a) {
  28235. this._layers.push(a)
  28236. },
  28237. getTilesets: function() {
  28238. return this._tilesets
  28239. },
  28240. setTilesets: function(a) {
  28241. this._tilesets.push(a)
  28242. },
  28243. getObjectGroups: function() {
  28244. return this._objectGroups
  28245. },
  28246. setObjectGroups: function(a) {
  28247. this._objectGroups.push(a)
  28248. },
  28249. getParentElement: function() {
  28250. return this.parentElement
  28251. },
  28252. setParentElement: function(a) {
  28253. this.parentElement = a
  28254. },
  28255. getParentGID: function() {
  28256. return this.parentGID
  28257. },
  28258. setParentGID: function(a) {
  28259. this.parentGID = a
  28260. },
  28261. getLayerAttribs: function() {
  28262. return this.layerAttrs
  28263. },
  28264. setLayerAttribs: function(a) {
  28265. this.layerAttrs = a
  28266. },
  28267. getStoringCharacters: function() {
  28268. return this.storingCharacters
  28269. },
  28270. setStoringCharacters: function(a) {
  28271. this.storingCharacters = a
  28272. },
  28273. getProperties: function() {
  28274. return this.properties
  28275. },
  28276. setProperties: function(a) {
  28277. this.properties = a
  28278. },
  28279. initWithTMXFile: function(a) {
  28280. this._internalInit(a, null);
  28281. return this.parseXMLFile(a)
  28282. },
  28283. initWithXML: function(a, b) {
  28284. this._internalInit(null, b);
  28285. return this.parseXMLString(a)
  28286. },
  28287. parseXMLFile: function(a, b) {
  28288. var c = (b = b || !1) ? a : cc.loader.getRes(a);
  28289. if (!c) throw "Please load the resource first : " + a;
  28290. var d, e, c = this._parseXML(c).documentElement;
  28291. d = c.getAttribute("version");
  28292. e = c.getAttribute("orientation");
  28293. if ("map" === c.nodeName && ("1.0" !== d && null !== d && cc.log("cocos2d: TMXFormat: Unsupported TMX version:" + d), "orthogonal" === e ? this.orientation = cc.TMX_ORIENTATION_ORTHO : "isometric" === e ? this.orientation = cc.TMX_ORIENTATION_ISO : "hexagonal" === e ? this.orientation = cc.TMX_ORIENTATION_HEX : null !== e && cc.log("cocos2d: TMXFomat: Unsupported orientation:" + e), d = cc.size(0, 0), d.width = parseFloat(c.getAttribute("width")), d.height = parseFloat(c.getAttribute("height")), this.setMapSize(d), d = cc.size(0,
  28294. 0), d.width = parseFloat(c.getAttribute("tilewidth")), d.height = parseFloat(c.getAttribute("tileheight")), this.setTileSize(d), e = c.querySelectorAll("map \x3e properties \x3e property"))) {
  28295. var f = {};
  28296. for (d = 0; d < e.length; d++) f[e[d].getAttribute("name")] = e[d].getAttribute("value");
  28297. this.properties = f
  28298. }
  28299. f = c.getElementsByTagName("tileset");
  28300. "map" !== c.nodeName && (f = [], f.push(c));
  28301. for (d = 0; d < f.length; d++) {
  28302. e = f[d];
  28303. var g = e.getAttribute("source");
  28304. if (g) e = b ? cc.path.join(this._resources, g) : cc.path.changeBasename(a, g), this.parseXMLFile(e);
  28305. else {
  28306. g = new cc.TMXTilesetInfo;
  28307. g.name = e.getAttribute("name") || "";
  28308. g.firstGid = parseInt(e.getAttribute("firstgid")) || 0;
  28309. g.spacing = parseInt(e.getAttribute("spacing")) || 0;
  28310. g.margin = parseInt(e.getAttribute("margin")) || 0;
  28311. var h = cc.size(0, 0);
  28312. h.width = parseFloat(e.getAttribute("tilewidth"));
  28313. h.height = parseFloat(e.getAttribute("tileheight"));
  28314. g._tileSize = h;
  28315. var h = e.getElementsByTagName("image")[0].getAttribute("source"),
  28316. k = -1;
  28317. this.tmxFileName && (k = this.tmxFileName.lastIndexOf("/")); - 1 !== k ? (k = this.tmxFileName.substr(0,
  28318. k + 1), g.sourceImage = k + h) : g.sourceImage = this._resources + (this._resources ? "/" : "") + h;
  28319. this.setTilesets(g);
  28320. if (h = e.getElementsByTagName("tile"))
  28321. for (k = 0; k < h.length; k++) {
  28322. e = h[k];
  28323. this.parentGID = parseInt(g.firstGid) + parseInt(e.getAttribute("id") || 0);
  28324. var m = e.querySelectorAll("properties \x3e property");
  28325. if (m) {
  28326. var n = {};
  28327. for (e = 0; e < m.length; e++) {
  28328. var p = m[e].getAttribute("name");
  28329. n[p] = m[e].getAttribute("value")
  28330. }
  28331. this._tileProperties[this.parentGID] = n
  28332. }
  28333. }
  28334. }
  28335. }
  28336. if (f = c.getElementsByTagName("layer"))
  28337. for (d = 0; d < f.length; d++) {
  28338. h = f[d];
  28339. k = h.getElementsByTagName("data")[0];
  28340. g = new cc.TMXLayerInfo;
  28341. g.name = h.getAttribute("name");
  28342. e = cc.size(0, 0);
  28343. e.width = parseFloat(h.getAttribute("width"));
  28344. e.height = parseFloat(h.getAttribute("height"));
  28345. g._layerSize = e;
  28346. e = h.getAttribute("visible");
  28347. g.visible = "0" != e;
  28348. e = h.getAttribute("opacity") || 1;
  28349. g._opacity = e ? parseInt(255 * parseFloat(e)) : 255;
  28350. g.offset = cc.p(parseFloat(h.getAttribute("x")) || 0, parseFloat(h.getAttribute("y")) || 0);
  28351. m = "";
  28352. for (e = 0; e < k.childNodes.length; e++) m += k.childNodes[e].nodeValue;
  28353. m = m.trim();
  28354. e = k.getAttribute("compression");
  28355. n = k.getAttribute("encoding");
  28356. if (e && "gzip" !== e && "zlib" !== e) return cc.log("cc.TMXMapInfo.parseXMLFile(): unsupported compression method"), null;
  28357. switch (e) {
  28358. case "gzip":
  28359. g._tiles = cc.unzipBase64AsArray(m, 4);
  28360. break;
  28361. case "zlib":
  28362. e = new Zlib.Inflate(cc.Codec.Base64.decodeAsArray(m, 1));
  28363. g._tiles = cc.uint8ArrayToUint32Array(e.decompress());
  28364. break;
  28365. case null:
  28366. case "":
  28367. if ("base64" === n) g._tiles = cc.Codec.Base64.decodeAsArray(m, 4);
  28368. else if ("csv" === n)
  28369. for (g._tiles = [], e = m.split(","), k = 0; k < e.length; k++) g._tiles.push(parseInt(e[k]));
  28370. else
  28371. for (e = k.getElementsByTagName("tile"), g._tiles = [], k = 0; k < e.length; k++) g._tiles.push(parseInt(e[k].getAttribute("gid")));
  28372. break;
  28373. default:
  28374. this.layerAttrs === cc.TMXLayerInfo.ATTRIB_NONE && cc.log("cc.TMXMapInfo.parseXMLFile(): Only base64 and/or gzip/zlib maps are supported")
  28375. }
  28376. if (h = h.querySelectorAll("properties \x3e property")) {
  28377. k = {};
  28378. for (e = 0; e < h.length; e++) k[h[e].getAttribute("name")] = h[e].getAttribute("value");
  28379. g.properties = k
  28380. }
  28381. this.setLayers(g)
  28382. }
  28383. if (f = c.getElementsByTagName("objectgroup"))
  28384. for (d = 0; d < f.length; d++) {
  28385. h =
  28386. f[d];
  28387. g = new cc.TMXObjectGroup;
  28388. g.groupName = h.getAttribute("name");
  28389. g.setPositionOffset(cc.p(parseFloat(h.getAttribute("x")) * this.getTileSize().width || 0, parseFloat(h.getAttribute("y")) * this.getTileSize().height || 0));
  28390. if (k = h.querySelectorAll("objectgroup \x3e properties \x3e property"))
  28391. for (e = 0; e < k.length; e++) m = {}, m[k[e].getAttribute("name")] = k[e].getAttribute("value"), g.properties = m;
  28392. if (h = h.querySelectorAll("object"))
  28393. for (e = 0; e < h.length; e++) {
  28394. m = h[e];
  28395. k = {};
  28396. k.name = m.getAttribute("name") || "";
  28397. k.type = m.getAttribute("type") ||
  28398. "";
  28399. k.x = parseInt(m.getAttribute("x") || 0) + g.getPositionOffset().x;
  28400. n = parseInt(m.getAttribute("y") || 0) + g.getPositionOffset().y;
  28401. k.width = parseInt(m.getAttribute("width")) || 0;
  28402. k.height = parseInt(m.getAttribute("height")) || 0;
  28403. k.y = parseInt(this.getMapSize().height * this.getTileSize().height) - n - k.height;
  28404. k.rotation = parseInt(m.getAttribute("rotation")) || 0;
  28405. if (n = m.querySelectorAll("properties \x3e property"))
  28406. for (p = 0; p < n.length; p++) k[n[p].getAttribute("name")] = n[p].getAttribute("value");
  28407. (n = m.querySelectorAll("polygon")) &&
  28408. 0 < n.length && (n = n[0].getAttribute("points")) && (k.polygonPoints = this._parsePointsString(n));
  28409. (m = m.querySelectorAll("polyline")) && 0 < m.length && (m = m[0].getAttribute("points")) && (k.polylinePoints = this._parsePointsString(m));
  28410. g.setObjects(k)
  28411. }
  28412. this.setObjectGroups(g)
  28413. }
  28414. return c
  28415. },
  28416. _parsePointsString: function(a) {
  28417. if (!a) return null;
  28418. var b = [];
  28419. a = a.split(" ");
  28420. for (var c = 0; c < a.length; c++) {
  28421. var d = a[c].split(",");
  28422. b.push({
  28423. x: d[0],
  28424. y: d[1]
  28425. })
  28426. }
  28427. return b
  28428. },
  28429. parseXMLString: function(a) {
  28430. return this.parseXMLFile(a, !0)
  28431. },
  28432. getTileProperties: function() {
  28433. return this._tileProperties
  28434. },
  28435. setTileProperties: function(a) {
  28436. this._tileProperties.push(a)
  28437. },
  28438. getCurrentString: function() {
  28439. return this.currentString
  28440. },
  28441. setCurrentString: function(a) {
  28442. this.currentString = a
  28443. },
  28444. getTMXFileName: function() {
  28445. return this.tmxFileName
  28446. },
  28447. setTMXFileName: function(a) {
  28448. this.tmxFileName = a
  28449. },
  28450. _internalInit: function(a, b) {
  28451. this._tilesets.length = 0;
  28452. this._layers.length = 0;
  28453. this.tmxFileName = a;
  28454. b && (this._resources = b);
  28455. this._objectGroups.length = 0;
  28456. this.properties.length = 0;
  28457. this._tileProperties.length = 0;
  28458. this.currentString = "";
  28459. this.storingCharacters = !1;
  28460. this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
  28461. this.parentElement = cc.TMX_PROPERTY_NONE;
  28462. this._currentFirstGID = 0
  28463. }
  28464. });
  28465. _p = cc.TMXMapInfo.prototype;
  28466. cc.defineGetterSetter(_p, "mapWidth", _p._getMapWidth, _p._setMapWidth);
  28467. cc.defineGetterSetter(_p, "mapHeight", _p._getMapHeight, _p._setMapHeight);
  28468. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  28469. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  28470. cc.TMXMapInfo.create = function(a, b) {
  28471. return new cc.TMXMapInfo(a, b)
  28472. };
  28473. cc.loader.register(["tmx", "tsx"], cc._txtLoader);
  28474. cc.TMXLayerInfo.ATTRIB_NONE = 1;
  28475. cc.TMXLayerInfo.ATTRIB_BASE64 = 2;
  28476. cc.TMXLayerInfo.ATTRIB_GZIP = 4;
  28477. cc.TMXLayerInfo.ATTRIB_ZLIB = 8;
  28478. cc.TMXObjectGroup = cc.Class.extend({
  28479. properties: null,
  28480. groupName: "",
  28481. _positionOffset: null,
  28482. _objects: null,
  28483. ctor: function() {
  28484. this.groupName = "";
  28485. this._positionOffset = cc.p(0, 0);
  28486. this.properties = [];
  28487. this._objects = []
  28488. },
  28489. getPositionOffset: function() {
  28490. return cc.p(this._positionOffset)
  28491. },
  28492. setPositionOffset: function(a) {
  28493. this._positionOffset.x = a.x;
  28494. this._positionOffset.y = a.y
  28495. },
  28496. getProperties: function() {
  28497. return this.properties
  28498. },
  28499. setProperties: function(a) {
  28500. this.properties.push(a)
  28501. },
  28502. getGroupName: function() {
  28503. return this.groupName.toString()
  28504. },
  28505. setGroupName: function(a) {
  28506. this.groupName = a
  28507. },
  28508. propertyNamed: function(a) {
  28509. return this.properties[a]
  28510. },
  28511. objectNamed: function(a) {
  28512. this.getObject(a)
  28513. },
  28514. getObject: function(a) {
  28515. if (this._objects && 0 < this._objects.length)
  28516. for (var b = this._objects, c = 0, d = b.length; c < d; c++) {
  28517. var e = b[c].name;
  28518. if (e && e === a) return b[c]
  28519. }
  28520. return null
  28521. },
  28522. getObjects: function() {
  28523. return this._objects
  28524. },
  28525. setObjects: function(a) {
  28526. this._objects.push(a)
  28527. }
  28528. });
  28529. cc.TMXLayer = cc.SpriteBatchNode.extend({
  28530. tiles: null,
  28531. tileset: null,
  28532. layerOrientation: null,
  28533. properties: null,
  28534. layerName: "",
  28535. _layerSize: null,
  28536. _mapTileSize: null,
  28537. _opacity: 255,
  28538. _minGID: null,
  28539. _maxGID: null,
  28540. _vertexZvalue: null,
  28541. _useAutomaticVertexZ: null,
  28542. _reusedTile: null,
  28543. _atlasIndexArray: null,
  28544. _contentScaleFactor: null,
  28545. _className: "TMXLayer",
  28546. ctor: function(a, b, c) {
  28547. cc.SpriteBatchNode.prototype.ctor.call(this);
  28548. this._descendants = [];
  28549. this._layerSize = cc.size(0, 0);
  28550. this._mapTileSize = cc.size(0, 0);
  28551. void 0 !== c && this.initWithTilesetInfo(a,
  28552. b, c)
  28553. },
  28554. _createRenderCmd: function() {
  28555. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.TMXLayer.CanvasRenderCmd(this) : new cc.TMXLayer.WebGLRenderCmd(this)
  28556. },
  28557. setContentSize: function(a, b) {
  28558. cc.Node.prototype.setContentSize.call(this, a, b);
  28559. this._renderCmd._updateCacheContext(a, b)
  28560. },
  28561. getTexture: function() {
  28562. return this._renderCmd.getTexture()
  28563. },
  28564. getLayerSize: function() {
  28565. return cc.size(this._layerSize.width, this._layerSize.height)
  28566. },
  28567. setLayerSize: function(a) {
  28568. this._layerSize.width = a.width;
  28569. this._layerSize.height = a.height
  28570. },
  28571. _getLayerWidth: function() {
  28572. return this._layerSize.width
  28573. },
  28574. _setLayerWidth: function(a) {
  28575. this._layerSize.width = a
  28576. },
  28577. _getLayerHeight: function() {
  28578. return this._layerSize.height
  28579. },
  28580. _setLayerHeight: function(a) {
  28581. this._layerSize.height = a
  28582. },
  28583. getMapTileSize: function() {
  28584. return cc.size(this._mapTileSize.width, this._mapTileSize.height)
  28585. },
  28586. setMapTileSize: function(a) {
  28587. this._mapTileSize.width = a.width;
  28588. this._mapTileSize.height = a.height
  28589. },
  28590. _getTileWidth: function() {
  28591. return this._mapTileSize.width
  28592. },
  28593. _setTileWidth: function(a) {
  28594. this._mapTileSize.width =
  28595. a
  28596. },
  28597. _getTileHeight: function() {
  28598. return this._mapTileSize.height
  28599. },
  28600. _setTileHeight: function(a) {
  28601. this._mapTileSize.height = a
  28602. },
  28603. getTiles: function() {
  28604. return this.tiles
  28605. },
  28606. setTiles: function(a) {
  28607. this.tiles = a
  28608. },
  28609. getTileset: function() {
  28610. return this.tileset
  28611. },
  28612. setTileset: function(a) {
  28613. this.tileset = a
  28614. },
  28615. getLayerOrientation: function() {
  28616. return this.layerOrientation
  28617. },
  28618. setLayerOrientation: function(a) {
  28619. this.layerOrientation = a
  28620. },
  28621. getProperties: function() {
  28622. return this.properties
  28623. },
  28624. setProperties: function(a) {
  28625. this.properties = a
  28626. },
  28627. initWithTilesetInfo: function(a,
  28628. b, c) {
  28629. var d = b._layerSize,
  28630. e = 0.35 * parseInt(d.width * d.height) + 1,
  28631. f;
  28632. a && (f = cc.textureCache.addImage(a.sourceImage));
  28633. return this.initWithTexture(f, e) ? (this.layerName = b.name, this._layerSize = d, this.tiles = b._tiles, this._minGID = b._minGID, this._maxGID = b._maxGID, this._opacity = b._opacity, this.properties = b.properties, this._contentScaleFactor = cc.director.getContentScaleFactor(), this.tileset = a, this._mapTileSize = c.getTileSize(), this.layerOrientation = c.orientation, a = this._calculateLayerOffset(b.offset), this.setPosition(cc.pointPixelsToPoints(a)),
  28634. 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
  28635. },
  28636. releaseMap: function() {
  28637. this.tiles && (this.tiles = null);
  28638. this._atlasIndexArray && (this._atlasIndexArray = null)
  28639. },
  28640. getTileAt: function(a, b) {
  28641. if (!a) throw "cc.TMXLayer.getTileAt(): pos should be non-null";
  28642. void 0 !== b && (a = cc.p(a, b));
  28643. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height ||
  28644. 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileAt(): invalid position";
  28645. if (!this.tiles || !this._atlasIndexArray) return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"), null;
  28646. var c = null,
  28647. d = this.getTileGIDAt(a);
  28648. if (0 === d) return c;
  28649. var e = 0 | a.x + a.y * this._layerSize.width,
  28650. c = this.getChildByTag(e);
  28651. c || (d = this.tileset.rectForGID(d), d = cc.rectPixelsToPoints(d), c = new cc.Sprite, c.initWithTexture(this.texture, d), c.batchNode = this, c.setPosition(this.getPositionAt(a)), c.vertexZ = this._vertexZForPos(a),
  28652. c.anchorX = 0, c.anchorY = 0, c.opacity = this._opacity, d = this._atlasIndexForExistantZ(e), this.addSpriteWithoutQuad(c, d, e));
  28653. return c
  28654. },
  28655. getTileGIDAt: function(a, b) {
  28656. if (null == a) throw "cc.TMXLayer.getTileGIDAt(): pos should be non-null";
  28657. void 0 !== b && (a = cc.p(a, b));
  28658. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileGIDAt(): invalid position";
  28659. return this.tiles && this._atlasIndexArray ? (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_MASK) >>> 0 : (cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"),
  28660. null)
  28661. },
  28662. getTileFlagsAt: function(a, b) {
  28663. if (!a) throw "cc.TMXLayer.getTileFlagsAt(): pos should be non-null";
  28664. void 0 !== b && (a = cc.p(a, b));
  28665. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.getTileFlagsAt(): invalid position";
  28666. return this.tiles && this._atlasIndexArray ? (this.tiles[0 | a.x + a.y * this._layerSize.width] & cc.TMX_TILE_FLIPPED_ALL) >>> 0 : (cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"), null)
  28667. },
  28668. setTileGID: function(a, b, c, d) {
  28669. if (!b) throw "cc.TMXLayer.setTileGID(): pos should be non-null";
  28670. void 0 !== d ? b = cc.p(b, c) : d = c;
  28671. if (b.x >= this._layerSize.width || b.y >= this._layerSize.height || 0 > b.x || 0 > b.y) throw "cc.TMXLayer.setTileGID(): invalid position";
  28672. if (this.tiles && this._atlasIndexArray)
  28673. if (0 !== a && a < this.tileset.firstGid) cc.log("cc.TMXLayer.setTileGID(): invalid gid:" + a);
  28674. else {
  28675. d = d || 0;
  28676. this._setNodeDirtyForCache();
  28677. c = this.getTileFlagsAt(b);
  28678. var e = this.getTileGIDAt(b);
  28679. if (e !== a || c !== d)
  28680. if (c = (a | d) >>> 0, 0 === a) this.removeTileAt(b);
  28681. else if (0 === e) this._insertTileForGID(c, b);
  28682. else {
  28683. var e = b.x + b.y * this._layerSize.width,
  28684. f = this.getChildByTag(e);
  28685. f ? (a = this.tileset.rectForGID(a), a = cc.rectPixelsToPoints(a), f.setTextureRect(a, !1), null != d && this._setupTileSprite(f, b, c), this.tiles[e] = c) : this._updateTileForGID(c, b)
  28686. }
  28687. } else cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released")
  28688. },
  28689. removeTileAt: function(a, b) {
  28690. if (!a) throw "cc.TMXLayer.removeTileAt(): pos should be non-null";
  28691. void 0 !== b && (a = cc.p(a, b));
  28692. if (a.x >= this._layerSize.width || a.y >= this._layerSize.height || 0 > a.x || 0 > a.y) throw "cc.TMXLayer.removeTileAt(): invalid position";
  28693. if (!this.tiles || !this._atlasIndexArray) cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");
  28694. else if (0 !== this.getTileGIDAt(a)) {
  28695. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  28696. var c = 0 | a.x + a.y * this._layerSize.width,
  28697. d = this._atlasIndexForExistantZ(c);
  28698. this.tiles[c] = 0;
  28699. this._atlasIndexArray.splice(d, 1);
  28700. if (c = this.getChildByTag(c)) cc.SpriteBatchNode.prototype.removeChild.call(this, c, !0);
  28701. else if (cc._renderType === cc._RENDER_TYPE_WEBGL && this.textureAtlas.removeQuadAtIndex(d),
  28702. this._children)
  28703. for (var c = this._children, e = 0, f = c.length; e < f; e++) {
  28704. var g = c[e];
  28705. if (g) {
  28706. var h = g.atlasIndex;
  28707. h >= d && (g.atlasIndex = h - 1)
  28708. }
  28709. }
  28710. }
  28711. },
  28712. getPositionAt: function(a, b) {
  28713. void 0 !== b && (a = cc.p(a, b));
  28714. var c = cc.p(0, 0);
  28715. switch (this.layerOrientation) {
  28716. case cc.TMX_ORIENTATION_ORTHO:
  28717. c = this._positionForOrthoAt(a);
  28718. break;
  28719. case cc.TMX_ORIENTATION_ISO:
  28720. c = this._positionForIsoAt(a);
  28721. break;
  28722. case cc.TMX_ORIENTATION_HEX:
  28723. c = this._positionForHexAt(a)
  28724. }
  28725. return cc.pointPixelsToPoints(c)
  28726. },
  28727. getProperty: function(a) {
  28728. return this.properties[a]
  28729. },
  28730. setupTiles: function() {
  28731. this._renderCmd.initImageSize();
  28732. this._parseInternalProperties();
  28733. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  28734. for (var a = this._layerSize.height, b = this._layerSize.width, c = 0; c < a; c++)
  28735. for (var d = 0; d < b; d++) {
  28736. var e = this.tiles[d + b * c];
  28737. 0 !== e && (this._appendTileForGID(e, cc.p(d, c)), this._minGID = Math.min(e, this._minGID), this._maxGID = Math.max(e, this._maxGID))
  28738. }
  28739. this._maxGID >= this.tileset.firstGid && this._minGID >= this.tileset.firstGid || cc.log("cocos2d:TMX: Only 1 tileset per layer is supported")
  28740. },
  28741. addChild: function(a, b, c) {
  28742. cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.")
  28743. },
  28744. removeChild: function(a, b) {
  28745. if (a)
  28746. if (-1 === this._children.indexOf(a)) cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer");
  28747. else {
  28748. cc._renderType === cc._RENDER_TYPE_CANVAS && this._setNodeDirtyForCache();
  28749. var c = a.atlasIndex;
  28750. this.tiles[this._atlasIndexArray[c]] = 0;
  28751. this._atlasIndexArray.splice(c, 1);
  28752. cc.SpriteBatchNode.prototype.removeChild.call(this, a, b);
  28753. cc.renderer.childrenOrderDirty = !0
  28754. }
  28755. },
  28756. getLayerName: function() {
  28757. return this.layerName
  28758. },
  28759. setLayerName: function(a) {
  28760. this.layerName = a
  28761. },
  28762. _positionForIsoAt: function(a) {
  28763. return cc.p(this._mapTileSize.width /
  28764. 2 * (this._layerSize.width + a.x - a.y - 1), this._mapTileSize.height / 2 * (2 * this._layerSize.height - a.x - a.y - 2))
  28765. },
  28766. _positionForOrthoAt: function(a) {
  28767. return cc.p(a.x * this._mapTileSize.width, (this._layerSize.height - a.y - 1) * this._mapTileSize.height)
  28768. },
  28769. _positionForHexAt: function(a) {
  28770. return cc.p(a.x * this._mapTileSize.width * 3 / 4, (this._layerSize.height - a.y - 1) * this._mapTileSize.height + (1 === a.x % 2 ? -this._mapTileSize.height / 2 : 0))
  28771. },
  28772. _calculateLayerOffset: function(a) {
  28773. var b = cc.p(0, 0);
  28774. switch (this.layerOrientation) {
  28775. case cc.TMX_ORIENTATION_ORTHO:
  28776. b =
  28777. cc.p(a.x * this._mapTileSize.width, -a.y * this._mapTileSize.height);
  28778. break;
  28779. case cc.TMX_ORIENTATION_ISO:
  28780. b = cc.p(this._mapTileSize.width / 2 * (a.x - a.y), this._mapTileSize.height / 2 * (-a.x - a.y));
  28781. break;
  28782. case cc.TMX_ORIENTATION_HEX:
  28783. 0 === a.x && 0 === a.y || cc.log("offset for hexagonal map not implemented yet")
  28784. }
  28785. return b
  28786. },
  28787. _appendTileForGID: function(a, b) {
  28788. var c = this.tileset.rectForGID(a),
  28789. c = cc.rectPixelsToPoints(c),
  28790. d = 0 | b.x + b.y * this._layerSize.width,
  28791. c = this._renderCmd._reusedTileWithRect(c);
  28792. this._setupTileSprite(c, b, a);
  28793. var e = this._atlasIndexArray.length;
  28794. this.insertQuadFromSprite(c, e);
  28795. this._atlasIndexArray.splice(e, 0, d);
  28796. return c
  28797. },
  28798. _insertTileForGID: function(a, b) {
  28799. var c = this.tileset.rectForGID(a),
  28800. c = cc.rectPixelsToPoints(c),
  28801. d = 0 | b.x + b.y * this._layerSize.width,
  28802. c = this._renderCmd._reusedTileWithRect(c);
  28803. this._setupTileSprite(c, b, a);
  28804. var e = this._atlasIndexForNewZ(d);
  28805. this.insertQuadFromSprite(c, e);
  28806. this._atlasIndexArray.splice(e, 0, d);
  28807. if (this._children)
  28808. for (var f = this._children, g = 0, h = f.length; g < h; g++) {
  28809. var k = f[g];
  28810. if (k) {
  28811. var m = k.atlasIndex;
  28812. m >= e && (k.atlasIndex = m + 1)
  28813. }
  28814. }
  28815. this.tiles[d] =
  28816. a;
  28817. return c
  28818. },
  28819. _updateTileForGID: function(a, b) {
  28820. var c = this.tileset.rectForGID(a),
  28821. d = this._contentScaleFactor,
  28822. c = cc.rect(c.x / d, c.y / d, c.width / d, c.height / d),
  28823. d = b.x + b.y * this._layerSize.width,
  28824. c = this._renderCmd._reusedTileWithRect(c);
  28825. this._setupTileSprite(c, b, a);
  28826. c.atlasIndex = this._atlasIndexForExistantZ(d);
  28827. c.dirty = !0;
  28828. c.updateTransform();
  28829. this.tiles[d] = a;
  28830. return c
  28831. },
  28832. _parseInternalProperties: function() {
  28833. var a = this.getProperty("cc_vertexz");
  28834. if (a)
  28835. if ("automatic" === a) {
  28836. this._useAutomaticVertexZ = !0;
  28837. var b = this.getProperty("cc_alpha_func"),
  28838. a = 0;
  28839. b && (a = parseFloat(b));
  28840. cc._renderType === cc._RENDER_TYPE_WEBGL && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST), b = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), cc.UNIFORM_ALPHA_TEST_VALUE_S), this.shaderProgram.use(), this.shaderProgram.setUniformLocationWith1f(b, a))
  28841. } else this._vertexZvalue = parseInt(a, 10)
  28842. },
  28843. _setupTileSprite: function(a, b, c) {
  28844. var d = b.x + b.y * this._layerSize.width;
  28845. a.setPosition(this.getPositionAt(b));
  28846. cc._renderType === cc._RENDER_TYPE_WEBGL ?
  28847. a.vertexZ = this._vertexZForPos(b) : a.tag = d;
  28848. a.anchorX = 0;
  28849. a.anchorY = 0;
  28850. a.opacity = this._opacity;
  28851. cc._renderType === cc._RENDER_TYPE_WEBGL && (a.rotation = 0);
  28852. a.setFlippedX(!1);
  28853. a.setFlippedY(!1);
  28854. (c & cc.TMX_TILE_DIAGONAL_FLAG) >>> 0 ? (a.anchorX = 0.5, a.anchorY = 0.5, a.x = this.getPositionAt(b).x + a.width / 2, a.y = this.getPositionAt(b).y + a.height / 2, b = (c & (cc.TMX_TILE_HORIZONTAL_FLAG | cc.TMX_TILE_VERTICAL_FLAG) >>> 0) >>> 0, b === cc.TMX_TILE_HORIZONTAL_FLAG ? a.rotation = 90 : b === cc.TMX_TILE_VERTICAL_FLAG ? a.rotation = 270 : (a.rotation = b === (cc.TMX_TILE_VERTICAL_FLAG |
  28855. cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 ? 90 : 270, a.setFlippedX(!0))) : ((c & cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0 && a.setFlippedX(!0), (c & cc.TMX_TILE_VERTICAL_FLAG) >>> 0 && a.setFlippedY(!0))
  28856. },
  28857. _vertexZForPos: function(a) {
  28858. var b = 0,
  28859. c = 0;
  28860. if (this._useAutomaticVertexZ) switch (this.layerOrientation) {
  28861. case cc.TMX_ORIENTATION_ISO:
  28862. c = this._layerSize.width + this._layerSize.height;
  28863. b = -(c - (a.x + a.y));
  28864. break;
  28865. case cc.TMX_ORIENTATION_ORTHO:
  28866. b = -(this._layerSize.height - a.y);
  28867. break;
  28868. case cc.TMX_ORIENTATION_HEX:
  28869. cc.log("TMX Hexa zOrder not supported");
  28870. break;
  28871. default:
  28872. cc.log("TMX invalid value")
  28873. } else b = this._vertexZvalue;
  28874. return b
  28875. },
  28876. _atlasIndexForExistantZ: function(a) {
  28877. var b;
  28878. if (this._atlasIndexArray)
  28879. for (var c = this._atlasIndexArray, d = 0, e = c.length; d < e && (b = c[d], b !== a); d++);
  28880. cc.isNumber(b) || cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen");
  28881. return d
  28882. },
  28883. _atlasIndexForNewZ: function(a) {
  28884. for (var b = this._atlasIndexArray, c = 0, d = b.length; c < d && !(a < b[c]); c++);
  28885. return c
  28886. }
  28887. });
  28888. _p = cc.TMXLayer.prototype;
  28889. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  28890. cc.defineGetterSetter(_p, "layerWidth", _p._getLayerWidth, _p._setLayerWidth);
  28891. cc.defineGetterSetter(_p, "layerHeight", _p._getLayerHeight, _p._setLayerHeight);
  28892. cc.defineGetterSetter(_p, "tileWidth", _p._getTileWidth, _p._setTileWidth);
  28893. cc.defineGetterSetter(_p, "tileHeight", _p._getTileHeight, _p._setTileHeight);
  28894. cc.TMXLayer.create = function(a, b, c) {
  28895. return new cc.TMXLayer(a, b, c)
  28896. };
  28897. (function() {
  28898. cc.TMXLayer.CanvasRenderCmd = function(a) {
  28899. cc.SpriteBatchNode.CanvasRenderCmd.call(this, a);
  28900. this._needDraw = !0;
  28901. this._realWorldTransform = {
  28902. a: 1,
  28903. b: 0,
  28904. c: 0,
  28905. d: 1,
  28906. tx: 0,
  28907. ty: 0
  28908. };
  28909. var c = cc._canvas;
  28910. a = cc.newElement("canvas");
  28911. a.width = c.width;
  28912. a.height = c.height;
  28913. this._cacheCanvas = a;
  28914. this._cacheContext = new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"));
  28915. c = new cc.Texture2D;
  28916. c.initWithElement(a);
  28917. c.handleLoadedTexture();
  28918. this._cacheTexture = c;
  28919. this._cacheDirty = !1
  28920. };
  28921. var a = cc.TMXLayer.CanvasRenderCmd.prototype =
  28922. Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);
  28923. a.constructor = cc.TMXLayer.CanvasRenderCmd;
  28924. a._setNodeDirtyForCache = function() {
  28925. this._cacheDirty = !0
  28926. };
  28927. a._renderingChildToCache = function() {
  28928. if (this._cacheDirty) {
  28929. var a = this._cacheContext,
  28930. c = a.getContext(),
  28931. d = this._cacheCanvas;
  28932. c.setTransform(1, 0, 0, 1, 0, 0);
  28933. c.clearRect(0, 0, d.width, d.height);
  28934. for (var c = this._node._children, d = 0, e = c.length; d < e; d++)
  28935. if (c[d]) {
  28936. var f = c[d]._renderCmd;
  28937. f && (f.rendering(a, 1, 1), f._cacheDirty = !1)
  28938. }
  28939. this._cacheDirty = !1
  28940. }
  28941. };
  28942. a.rendering = function(a,
  28943. c, d) {
  28944. var e = this._displayedOpacity / 255;
  28945. if (!(0 >= e)) {
  28946. var f = this._node;
  28947. this._renderingChildToCache();
  28948. var g = a || cc._renderContext;
  28949. a = g.getContext();
  28950. g.setGlobalAlpha(e);
  28951. var e = 0 | -this._anchorPointInPoints.x,
  28952. h = 0 | -this._anchorPointInPoints.y,
  28953. k = this._cacheCanvas;
  28954. k && 0 !== k.width && 0 !== k.height && (g.setTransform(this._realWorldTransform, c, d), g = k.height * d, f.layerOrientation === cc.TMX_ORIENTATION_HEX ? a.drawImage(k, 0, 0, k.width, k.height, e, -(h + g) + 0.5 * f._mapTileSize.height * d, k.width * c, g) : a.drawImage(k, 0, 0, k.width, k.height,
  28955. e, -(h + g), k.width * c, g));
  28956. cc.g_NumberOfDraws++
  28957. }
  28958. };
  28959. a._updateCacheContext = function(a, c) {
  28960. var d = this._node,
  28961. e = d._contentSize,
  28962. f = this._cacheCanvas,
  28963. g = cc.contentScaleFactor();
  28964. f.width = 0 | 1.5 * e.width * g;
  28965. f.height = 0 | 1.5 * e.height * g;
  28966. d.layerOrientation === cc.TMX_ORIENTATION_HEX ? this._cacheContext.setOffset(0, 0.5 * -d._mapTileSize.height) : this._cacheContext.setOffset(0, 0);
  28967. d = this._cacheTexture._contentSize;
  28968. d.width = f.width;
  28969. d.height = f.height
  28970. };
  28971. a.getTexture = function() {
  28972. return this._cacheTexture
  28973. };
  28974. a.visit = function(a) {
  28975. var c = this._node,
  28976. d, e = c._children;
  28977. if (c._visible && e && 0 !== e.length) {
  28978. if (a = a || this.getParentRenderCmd()) this._curLevel = a._curLevel + 1;
  28979. this._syncStatus(a);
  28980. if (this._cacheDirty) {
  28981. a = this._cacheContext;
  28982. var f = this._cacheCanvas,
  28983. g = a.getContext(),
  28984. h = c.__instanceId,
  28985. k = cc.renderer;
  28986. k._turnToCacheMode(h);
  28987. c.sortAllChildren();
  28988. c = 0;
  28989. for (d = e.length; c < d; c++)
  28990. if (e[c]) {
  28991. var m = e[c]._renderCmd;
  28992. m && (m.visit(this), m._cacheDirty = !1)
  28993. }
  28994. g.setTransform(1, 0, 0, 1, 0, 0);
  28995. g.clearRect(0, 0, f.width, f.height);
  28996. k._renderingToCacheCanvas(a, h);
  28997. this._cacheDirty = !1
  28998. }
  28999. cc.renderer.pushRenderCommand(this);
  29000. this._dirtyFlag = 0
  29001. }
  29002. };
  29003. a.transform = function(a, c) {
  29004. var d = this.getNodeToParentTransform(),
  29005. e = this._realWorldTransform;
  29006. if (a) {
  29007. var f = a._worldTransform;
  29008. e.a = d.a * f.a + d.b * f.c;
  29009. e.b = d.a * f.b + d.b * f.d;
  29010. e.c = d.c * f.a + d.d * f.c;
  29011. e.d = d.c * f.b + d.d * f.d;
  29012. var g = a._transform,
  29013. h = -(g.b + g.c) * d.tx;
  29014. e.tx = d.tx * f.a + d.ty * f.c + f.tx + -(g.b + g.c) * d.ty;
  29015. e.ty = d.tx * f.b + d.ty * f.d + f.ty + h
  29016. } else e.a = d.a, e.b = d.b, e.c = d.c, e.d = d.d, e.tx = d.tx, e.ty = d.ty; if (c && (d = this._node._children) && 0 !== d.length)
  29017. for (e = 0, f = d.length; e < f; e++) d[e]._renderCmd.transform(this, c)
  29018. };
  29019. a.initImageSize =
  29020. function() {
  29021. this._node.tileset.imageSize = this._originalTexture.getContentSizeInPixels()
  29022. };
  29023. a._reusedTileWithRect = function(a) {
  29024. var c = this._node;
  29025. c._reusedTile = new cc.Sprite;
  29026. c._reusedTile.initWithTexture(c._renderCmd._texture, a, !1);
  29027. c._reusedTile.batchNode = c;
  29028. c._reusedTile.parent = c;
  29029. c._reusedTile._renderCmd._cachedParent = c._renderCmd;
  29030. return c._reusedTile
  29031. }
  29032. })();
  29033. (function() {
  29034. cc.TMXLayer.WebGLRenderCmd = function(a) {
  29035. cc.SpriteBatchNode.WebGLRenderCmd.call(this, a);
  29036. this._needDraw = !0
  29037. };
  29038. var a = cc.TMXLayer.WebGLRenderCmd.prototype = Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);
  29039. a.constructor = cc.TMXLayer.WebGLRenderCmd;
  29040. a._updateCacheContext = function() {};
  29041. a.initImageSize = function() {
  29042. this._node.tileset.imageSize = this._textureAtlas.texture.getContentSizeInPixels();
  29043. this._textureAtlas.texture.setAliasTexParameters()
  29044. };
  29045. a._reusedTileWithRect = function(a) {
  29046. var c = this._node;
  29047. c._reusedTile ? (c._reusedTile.batchNode = null, c._reusedTile.setTextureRect(a, !1)) : (c._reusedTile = new cc.Sprite, c._reusedTile.initWithTexture(c.texture, a, !1));
  29048. c._reusedTile.batchNode = c;
  29049. return c._reusedTile
  29050. }
  29051. })();
  29052. cc.PointObject = cc.Class.extend({
  29053. _ratio: null,
  29054. _offset: null,
  29055. _child: null,
  29056. ctor: function(a, b) {
  29057. this.initWithCCPoint(a, b)
  29058. },
  29059. getRatio: function() {
  29060. return this._ratio
  29061. },
  29062. setRatio: function(a) {
  29063. this._ratio = a
  29064. },
  29065. getOffset: function() {
  29066. return this._offset
  29067. },
  29068. setOffset: function(a) {
  29069. this._offset = a
  29070. },
  29071. getChild: function() {
  29072. return this._child
  29073. },
  29074. setChild: function(a) {
  29075. this._child = a
  29076. },
  29077. initWithCCPoint: function(a, b) {
  29078. this._ratio = a;
  29079. this._offset = b;
  29080. this._child = null;
  29081. return !0
  29082. }
  29083. });
  29084. cc.PointObject.create = function(a, b) {
  29085. return new cc.PointObject(a, b)
  29086. };
  29087. cc.ParallaxNode = cc.Node.extend({
  29088. parallaxArray: null,
  29089. _lastPosition: null,
  29090. _className: "ParallaxNode",
  29091. getParallaxArray: function() {
  29092. return this.parallaxArray
  29093. },
  29094. setParallaxArray: function(a) {
  29095. this.parallaxArray = a
  29096. },
  29097. ctor: function() {
  29098. cc.Node.prototype.ctor.call(this);
  29099. this.parallaxArray = [];
  29100. this._lastPosition = cc.p(-100, -100)
  29101. },
  29102. addChild: function(a, b, c, d) {
  29103. if (3 === arguments.length) cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");
  29104. else {
  29105. if (!a) throw "cc.ParallaxNode.addChild(): child should be non-null";
  29106. var e = new cc.PointObject(c, d);
  29107. e.setChild(a);
  29108. this.parallaxArray.push(e);
  29109. a.setPosition(this._position.x * c.x + d.x, this._position.y * c.y + d.y);
  29110. cc.Node.prototype.addChild.call(this, a, b, a.tag)
  29111. }
  29112. },
  29113. removeChild: function(a, b) {
  29114. for (var c = this.parallaxArray, d = 0; d < c.length; d++)
  29115. if (c[d].getChild() === a) {
  29116. c.splice(d, 1);
  29117. break
  29118. }
  29119. cc.Node.prototype.removeChild.call(this, a, b)
  29120. },
  29121. removeAllChildren: function(a) {
  29122. this.parallaxArray.length = 0;
  29123. cc.Node.prototype.removeAllChildren.call(this, a)
  29124. },
  29125. _updateParallaxPosition: function() {
  29126. var a = this._absolutePosition();
  29127. if (!cc.pointEqualToPoint(a, this._lastPosition)) {
  29128. for (var b = this.parallaxArray, c = 0, d = b.length; c < d; c++) {
  29129. var e = b[c];
  29130. e.getChild().setPosition(-a.x + a.x * e.getRatio().x + e.getOffset().x, -a.y + a.y * e.getRatio().y + e.getOffset().y)
  29131. }
  29132. this._lastPosition = a
  29133. }
  29134. },
  29135. _absolutePosition: function() {
  29136. for (var a = this._position, b = this; null !== b.parent;) b = b.parent, a = cc.pAdd(a, b.getPosition());
  29137. return a
  29138. },
  29139. _createRenderCmd: function() {
  29140. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.ParallaxNode.CanvasRenderCmd(this) : new cc.ParallaxNode.WebGLRenderCmd(this)
  29141. }
  29142. });
  29143. cc.ParallaxNode.create = function() {
  29144. return new cc.ParallaxNode
  29145. };
  29146. (function() {
  29147. cc.ParallaxNode.CanvasRenderCmd = function(a) {
  29148. cc.Node.CanvasRenderCmd.call(this, a);
  29149. this._needDraw = !1
  29150. };
  29151. var a = cc.ParallaxNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  29152. a.constructor = cc.ParallaxNode.CanvasRenderCmd;
  29153. a.updateStatus = function() {
  29154. this._node._updateParallaxPosition();
  29155. cc.Node.CanvasRenderCmd.prototype.updateStatus.call(this)
  29156. };
  29157. a._syncStatus = function(a) {
  29158. this._node._updateParallaxPosition();
  29159. cc.Node.CanvasRenderCmd.prototype._syncStatus.call(this, a)
  29160. }
  29161. })();
  29162. (function() {
  29163. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  29164. cc.ParallaxNode.WebGLRenderCmd = function(a) {
  29165. cc.Node.WebGLRenderCmd.call(this, a);
  29166. this._needDraw = !1
  29167. };
  29168. var a = cc.ParallaxNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  29169. a.constructor = cc.ParallaxNode.WebGLRenderCmd;
  29170. a.updateStatus = function() {
  29171. this._node._updateParallaxPosition();
  29172. cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this)
  29173. };
  29174. a._syncStatus = function(a) {
  29175. this._node._updateParallaxPosition();
  29176. cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this,
  29177. a)
  29178. }
  29179. }
  29180. })();
  29181. (function() {
  29182. var a = cc.sys,
  29183. b = {
  29184. common: {
  29185. multichannel: !0,
  29186. webAudio: cc.sys._supportWebAudio,
  29187. auto: !0
  29188. }
  29189. };
  29190. b[a.BROWSER_TYPE_IE] = {
  29191. multichannel: !0,
  29192. webAudio: cc.sys._supportWebAudio,
  29193. auto: !0,
  29194. emptied: !0
  29195. };
  29196. b[a.BROWSER_TYPE_ANDROID] = {
  29197. multichannel: !1,
  29198. webAudio: !1,
  29199. auto: !1
  29200. };
  29201. b[a.BROWSER_TYPE_CHROME] = {
  29202. multichannel: !0,
  29203. webAudio: !0,
  29204. auto: !1
  29205. };
  29206. b[a.BROWSER_TYPE_FIREFOX] = {
  29207. multichannel: !0,
  29208. webAudio: !0,
  29209. auto: !0,
  29210. delay: !0
  29211. };
  29212. b[a.BROWSER_TYPE_UC] = {
  29213. multichannel: !0,
  29214. webAudio: !1,
  29215. auto: !1
  29216. };
  29217. b[a.BROWSER_TYPE_QQ] = {
  29218. multichannel: !1,
  29219. webAudio: !1,
  29220. auto: !0
  29221. };
  29222. b[a.BROWSER_TYPE_OUPENG] = {
  29223. multichannel: !1,
  29224. webAudio: !1,
  29225. auto: !1,
  29226. replay: !0,
  29227. emptied: !0
  29228. };
  29229. b[a.BROWSER_TYPE_WECHAT] = {
  29230. multichannel: !1,
  29231. webAudio: !1,
  29232. auto: !1,
  29233. replay: !0,
  29234. emptied: !0
  29235. };
  29236. b[a.BROWSER_TYPE_360] = {
  29237. multichannel: !1,
  29238. webAudio: !1,
  29239. auto: !0
  29240. };
  29241. b[a.BROWSER_TYPE_MIUI] = {
  29242. multichannel: !1,
  29243. webAudio: !1,
  29244. auto: !0
  29245. };
  29246. b[a.BROWSER_TYPE_LIEBAO] = {
  29247. multichannel: !1,
  29248. webAudio: !1,
  29249. auto: !1,
  29250. replay: !0,
  29251. emptied: !0
  29252. };
  29253. b[a.BROWSER_TYPE_SOUGOU] = {
  29254. multichannel: !1,
  29255. webAudio: !1,
  29256. auto: !1,
  29257. replay: !0,
  29258. emptied: !0
  29259. };
  29260. b[a.BROWSER_TYPE_BAIDU] = {
  29261. multichannel: !1,
  29262. webAudio: !1,
  29263. auto: !1,
  29264. replay: !0,
  29265. emptied: !0
  29266. };
  29267. b[a.BROWSER_TYPE_BAIDU_APP] = {
  29268. multichannel: !1,
  29269. webAudio: !1,
  29270. auto: !1,
  29271. replay: !0,
  29272. emptied: !0
  29273. };
  29274. b[a.BROWSER_TYPE_SAFARI] = {
  29275. multichannel: !0,
  29276. webAudio: !0,
  29277. auto: !1,
  29278. webAudioCallback: function(a) {
  29279. document.createElement("audio").src = a
  29280. }
  29281. };
  29282. var c, d;
  29283. try {
  29284. var e = navigator.userAgent.toLowerCase();
  29285. switch (a.browserType) {
  29286. case a.BROWSER_TYPE_IE:
  29287. d = e.match(/(msie |rv:)([\d.]+)/);
  29288. break;
  29289. case a.BROWSER_TYPE_FIREFOX:
  29290. d = e.match(/(firefox\/|rv:)([\d.]+)/);
  29291. break;
  29292. case a.BROWSER_TYPE_CHROME:
  29293. d = e.match(/chrome\/([\d.]+)/);
  29294. break;
  29295. case a.BROWSER_TYPE_BAIDU:
  29296. d = e.match(/baidubrowser\/([\d.]+)/);
  29297. break;
  29298. case a.BROWSER_TYPE_UC:
  29299. d = e.match(/ucbrowser\/([\d.]+)/);
  29300. break;
  29301. case a.BROWSER_TYPE_QQ:
  29302. d = e.match(/qqbrowser\/([\d.]+)/);
  29303. break;
  29304. case a.BROWSER_TYPE_OUPENG:
  29305. d = e.match(/oupeng\/([\d.]+)/);
  29306. break;
  29307. case a.BROWSER_TYPE_WECHAT:
  29308. d = e.match(/micromessenger\/([\d.]+)/);
  29309. break;
  29310. case a.BROWSER_TYPE_SAFARI:
  29311. d = e.match(/safari\/([\d.]+)/);
  29312. break;
  29313. case a.BROWSER_TYPE_MIUI:
  29314. d = e.match(/miuibrowser\/([\d.]+)/)
  29315. }
  29316. c = d ? d[1] : ""
  29317. } catch (f) {
  29318. console.log(f)
  29319. }
  29320. if (c) switch (a.browserType) {
  29321. case a.BROWSER_TYPE_CHROME:
  29322. 30 >
  29323. parseInt(c) && (b[a.BROWSER_TYPE_CHROME] = {
  29324. multichannel: !1,
  29325. webAudio: !0,
  29326. auto: !1
  29327. });
  29328. break;
  29329. case a.BROWSER_TYPE_MIUI:
  29330. if (c = c.match(/\d+/g), 2 > c[0] || 2 === c[0] && 0 === c[1] && 1 >= c[2]) b[a.BROWSER_TYPE_MIUI].auto = !1
  29331. }
  29332. if (cc.sys.isMobile) cc.__audioSupport = cc.sys.os !== cc.sys.OS_IOS ? b[a.browserType] || b.common : b[a.BROWSER_TYPE_SAFARI];
  29333. else switch (a.browserType) {
  29334. case a.BROWSER_TYPE_IE:
  29335. cc.__audioSupport = b[a.BROWSER_TYPE_IE];
  29336. break;
  29337. case a.BROWSER_TYPE_FIREFOX:
  29338. cc.__audioSupport = b[a.BROWSER_TYPE_FIREFOX];
  29339. break;
  29340. default:
  29341. cc.__audioSupport =
  29342. b.common
  29343. }
  29344. })();
  29345. cc.Audio = cc.Class.extend({
  29346. volume: 1,
  29347. loop: !1,
  29348. src: null,
  29349. _touch: !1,
  29350. _playing: !1,
  29351. _AUDIO_TYPE: "AUDIO",
  29352. _pause: !1,
  29353. _buffer: null,
  29354. _currentSource: null,
  29355. _startTime: null,
  29356. _currentTime: null,
  29357. _context: null,
  29358. _volume: null,
  29359. _ignoreEnded: !1,
  29360. _element: null,
  29361. ctor: function(a, b, c) {
  29362. a && (this._context = a);
  29363. b && (this._volume = b);
  29364. a && b && (this._AUDIO_TYPE = "WEBAUDIO");
  29365. this.src = c
  29366. },
  29367. _setBufferCallback: null,
  29368. setBuffer: function(a) {
  29369. if (a) {
  29370. var b = this._playing;
  29371. this._AUDIO_TYPE = "WEBAUDIO";
  29372. this._buffer && this._buffer !== a && this.getPlaying() && this.stop();
  29373. this._buffer = a;
  29374. b && this.play();
  29375. this._volume.gain.value = this.volume;
  29376. this._setBufferCallback && this._setBufferCallback(a)
  29377. }
  29378. },
  29379. _setElementCallback: null,
  29380. setElement: function(a) {
  29381. if (a) {
  29382. var b = this._playing;
  29383. this._AUDIO_TYPE = "AUDIO";
  29384. this._element && this._element !== a && this.getPlaying() && this.stop();
  29385. this._element = a;
  29386. b && this.play();
  29387. a.volume = this.volume;
  29388. a.loop = this.loop;
  29389. this._setElementCallback && this._setElementCallback(a)
  29390. }
  29391. },
  29392. play: function(a, b) {
  29393. this._playing = !0;
  29394. this.loop = void 0 === b ? this.loop : b;
  29395. "AUDIO" === this._AUDIO_TYPE ?
  29396. this._playOfAudio(a) : this._playOfWebAudio(a)
  29397. },
  29398. getPlaying: function() {
  29399. if (!this._playing) return this._playing;
  29400. if ("AUDIO" === this._AUDIO_TYPE) {
  29401. var a = this._element;
  29402. return !a || this._pause || a.ended ? this._playing = !1 : !0
  29403. }
  29404. return (a = this._currentSource) ? null == a.playbackState ? this._playing : this._currentTime + this._context.currentTime - this._startTime < this._currentSource.buffer.duration : !0
  29405. },
  29406. _playOfWebAudio: function(a) {
  29407. var b = this._currentSource;
  29408. if (this._buffer) {
  29409. if (!this._pause && b)
  29410. if (0 === this._context.currentTime || this._currentTime +
  29411. this._context.currentTime - this._startTime > this._currentSource.buffer.duration) this._stopOfWebAudio();
  29412. else return;
  29413. b = this._context.createBufferSource();
  29414. b.buffer = this._buffer;
  29415. b.connect(this._volume);
  29416. b.loop = this.loop;
  29417. this._startTime = this._context.currentTime;
  29418. this._currentTime = 0;
  29419. if (b.start) b.start(0, a || 0);
  29420. else if (b.noteGrainOn) {
  29421. var c = b.buffer.duration;
  29422. this.loop ? b.noteGrainOn(0, a, c) : b.noteGrainOn(0, a, c - a)
  29423. } else b.noteOn(0);
  29424. this._currentSource = b;
  29425. var d = this;
  29426. b.onended = function() {
  29427. d._ignoreEnded ? d._ignoreEnded = !1 : d._playing = !1
  29428. }
  29429. }
  29430. },
  29431. _playOfAudio: function() {
  29432. var a = this._element;
  29433. a && (a.loop = this.loop, a.play())
  29434. },
  29435. stop: function() {
  29436. this._playing = !1;
  29437. "AUDIO" === this._AUDIO_TYPE ? this._stopOfAudio() : this._stopOfWebAudio()
  29438. },
  29439. _stopOfWebAudio: function() {
  29440. var a = this._currentSource;
  29441. this._ignoreEnded = !0;
  29442. a && (a.stop(0), this._currentSource = null)
  29443. },
  29444. _stopOfAudio: function() {
  29445. var a = this._element;
  29446. a && (a.pause(), a.duration && Infinity !== a.duration && (a.currentTime = 0))
  29447. },
  29448. pause: function() {
  29449. this._playing = !1;
  29450. this._pause = !0;
  29451. "AUDIO" === this._AUDIO_TYPE ?
  29452. this._pauseOfAudio() : this._pauseOfWebAudio()
  29453. },
  29454. _pauseOfWebAudio: function() {
  29455. this._currentTime += this._context.currentTime - this._startTime;
  29456. var a = this._currentSource;
  29457. a && a.stop(0)
  29458. },
  29459. _pauseOfAudio: function() {
  29460. var a = this._element;
  29461. a && a.pause()
  29462. },
  29463. resume: function() {
  29464. this._pause && ("AUDIO" === this._AUDIO_TYPE ? this._resumeOfAudio() : this._resumeOfWebAudio(), this._pause = !1, this._playing = !0)
  29465. },
  29466. _resumeOfWebAudio: function() {
  29467. var a = this._currentSource;
  29468. a && (this._startTime = this._context.currentTime, this._playOfWebAudio(this._currentTime %
  29469. a.buffer.duration))
  29470. },
  29471. _resumeOfAudio: function() {
  29472. var a = this._element;
  29473. a && a.play()
  29474. },
  29475. setVolume: function(a) {
  29476. 1 < a && (a = 1);
  29477. 0 > a && (a = 0);
  29478. this.volume = a;
  29479. "AUDIO" === this._AUDIO_TYPE ? this._element && (this._element.volume = a) : this._volume && (this._volume.gain.value = a)
  29480. },
  29481. getVolume: function() {
  29482. return this.volume
  29483. },
  29484. cloneNode: function() {
  29485. var a, b;
  29486. if ("AUDIO" === this._AUDIO_TYPE) {
  29487. a = new cc.Audio;
  29488. var c = document.createElement("audio");
  29489. c.src = this.src;
  29490. a.setElement(c)
  29491. } else c = this._context.createGain(), c.gain.value = 1, c.connect(this._context.destination),
  29492. a = new cc.Audio(this._context, c, this.src), this._buffer ? a.setBuffer(this._buffer) : (b = this, this._setBufferCallback = function(c) {
  29493. a.setBuffer(c);
  29494. b._setBufferCallback = null
  29495. });
  29496. a._AUDIO_TYPE = this._AUDIO_TYPE;
  29497. return a
  29498. }
  29499. });
  29500. (function(a) {
  29501. var b = a.webAudio,
  29502. c = a.multichannel,
  29503. d = a.auto,
  29504. e = [];
  29505. (function() {
  29506. var a = document.createElement("audio");
  29507. if (a.canPlayType) {
  29508. var b = a.canPlayType('audio/ogg; codecs\x3d"vorbis"');
  29509. b && "" !== b && e.push(".ogg");
  29510. (b = a.canPlayType("audio/mpeg")) && "" !== b && e.push(".mp3");
  29511. (b = a.canPlayType('audio/wav; codecs\x3d"1"')) && "" !== b && e.push(".wav");
  29512. (b = a.canPlayType("audio/mp4")) && "" !== b && e.push(".mp4");
  29513. (a = a.canPlayType("audio/x-m4a")) && "" !== a && e.push(".m4a")
  29514. }
  29515. })();
  29516. try {
  29517. if (b) {
  29518. var f = new(window.AudioContext || window.webkitAudioContext ||
  29519. window.mozAudioContext);
  29520. a.delay && setTimeout(function() {
  29521. f = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext)
  29522. }, 0)
  29523. }
  29524. } catch (g) {
  29525. b = !1, cc.log("browser don't support webAudio")
  29526. }
  29527. var h = {
  29528. cache: {},
  29529. load: function(a, c, d, g) {
  29530. if (0 === e.length) return g("can not support audio!");
  29531. var k = cc.path.extname(a),
  29532. u = [k];
  29533. for (d = 0; d < e.length; d++) k !== e[d] && u.push(e[d]);
  29534. var s;
  29535. if (h.cache[c]) return g(null, h.cache[c]);
  29536. if (b) try {
  29537. var v = f.createGain();
  29538. v.gain.value = 1;
  29539. v.connect(f.destination);
  29540. s = new cc.Audio(f, v, a)
  29541. } catch (x) {
  29542. b = !1, cc.log("browser don't support webAudio"), s = new cc.Audio(null, null, a)
  29543. } else s = new cc.Audio(null, null, a);
  29544. this.loadAudioFromExtList(a, u, s, g);
  29545. h.cache[c] = s
  29546. },
  29547. loadAudioFromExtList: function(c, d, g, k) {
  29548. if (0 === d.length) {
  29549. var r = "can not found the resource of audio! Last match url is : ",
  29550. r = r + c.replace(/\.(.*)?$/, "(");
  29551. e.forEach(function(a) {
  29552. r += a + "|"
  29553. });
  29554. r = r.replace(/\|$/, ")");
  29555. return k(r)
  29556. }
  29557. c = cc.path.changeExtname(c, d.splice(0, 1));
  29558. if (b) {
  29559. a.webAudioCallback && a.webAudioCallback(c);
  29560. var u = new XMLHttpRequest;
  29561. u.open("GET",
  29562. c, !0);
  29563. u.responseType = "arraybuffer";
  29564. u.onload = function() {
  29565. f.decodeAudioData(u.response, function(a) {
  29566. g.setBuffer(a);
  29567. k(null, g)
  29568. }, function() {
  29569. h.loadAudioFromExtList(c, d, g, k)
  29570. })
  29571. };
  29572. u.send()
  29573. } else {
  29574. var s = document.createElement("audio"),
  29575. v = !1,
  29576. x = !1,
  29577. D = setTimeout(function() {
  29578. 0 === s.readyState ? w() : (x = !0, k("audio load timeout : " + c, g))
  29579. }, 1E4),
  29580. E = function() {
  29581. v || (g.setElement(s), s.removeEventListener("canplaythrough", E, !1), s.removeEventListener("error", A, !1), s.removeEventListener("emptied", w, !1), !x && k(null, g), v = !0, clearTimeout(D))
  29582. },
  29583. A = function() {
  29584. v && (s.removeEventListener("canplaythrough", E, !1), s.removeEventListener("error", A, !1), s.removeEventListener("emptied", w, !1), !x && h.loadAudioFromExtList(c, d, g, k), v = !0, clearTimeout(D))
  29585. },
  29586. w = function() {
  29587. x = !0;
  29588. E();
  29589. k(null, g)
  29590. };
  29591. cc._addEventListener(s, "canplaythrough", E, !1);
  29592. cc._addEventListener(s, "error", A, !1);
  29593. a.emptied && cc._addEventListener(s, "emptied", w, !1);
  29594. s.src = c;
  29595. s.load()
  29596. }
  29597. }
  29598. };
  29599. cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], h);
  29600. cc.audioEngine = {
  29601. _currMusic: null,
  29602. _musicVolume: 1,
  29603. willPlayMusic: function() {
  29604. return !1
  29605. },
  29606. playMusic: function(a, b) {
  29607. var c = this._currMusic;
  29608. c && c.src !== a && c.getPlaying() && c.stop();
  29609. c = h.cache[a];
  29610. c || (cc.loader.load(a), c = h.cache[a]);
  29611. c.play(0, b);
  29612. c.setVolume(this._musicVolume);
  29613. this._currMusic = c
  29614. },
  29615. stopMusic: function(a) {
  29616. var b = this._currMusic;
  29617. b && (b.stop(), a && cc.loader.release(b.src))
  29618. },
  29619. pauseMusic: function() {
  29620. var a = this._currMusic;
  29621. a && a.pause()
  29622. },
  29623. resumeMusic: function() {
  29624. var a = this._currMusic;
  29625. a && a.resume()
  29626. },
  29627. rewindMusic: function() {
  29628. var a = this._currMusic;
  29629. a && (a.stop(), a.play())
  29630. },
  29631. getMusicVolume: function() {
  29632. return this._musicVolume
  29633. },
  29634. setMusicVolume: function(a) {
  29635. a -= 0;
  29636. isNaN(a) && (a = 1);
  29637. 1 < a && (a = 1);
  29638. 0 > a && (a = 0);
  29639. this._musicVolume = a;
  29640. var b = this._currMusic;
  29641. b && b.setVolume(a)
  29642. },
  29643. isMusicPlaying: function() {
  29644. var a = this._currMusic;
  29645. return a ? a.getPlaying() : !1
  29646. },
  29647. _audioPool: {},
  29648. _maxAudioInstance: 5,
  29649. _effectVolume: 1,
  29650. playEffect: function(a, d) {
  29651. if (!c) return null;
  29652. var e = this._audioPool[a];
  29653. e || (e = this._audioPool[a] = []);
  29654. var f;
  29655. for (f = 0; f < e.length && e[f].getPlaying(); f++);
  29656. if (e[f]) g = e[f], g.setVolume(this._effectVolume), g.play(0, d);
  29657. else if (!b && f > this._maxAudioInstance) cc.log("Error: %s greater than %d",
  29658. a, this._maxAudioInstance);
  29659. else {
  29660. var g = h.cache[a];
  29661. g || (cc.loader.load(a), g = h.cache[a]);
  29662. g = g.cloneNode();
  29663. g.setVolume(this._effectVolume);
  29664. g.loop = d || !1;
  29665. g.play();
  29666. e.push(g)
  29667. }
  29668. return g
  29669. },
  29670. setEffectsVolume: function(a) {
  29671. a -= 0;
  29672. isNaN(a) && (a = 1);
  29673. 1 < a && (a = 1);
  29674. 0 > a && (a = 0);
  29675. this._effectVolume = a;
  29676. var b = this._audioPool,
  29677. c;
  29678. for (c in b) {
  29679. var d = b[c];
  29680. if (Array.isArray(d))
  29681. for (var e = 0; e < d.length; e++) d[e].setVolume(a)
  29682. }
  29683. },
  29684. getEffectsVolume: function() {
  29685. return this._effectVolume
  29686. },
  29687. pauseEffect: function(a) {
  29688. a && a.pause()
  29689. },
  29690. pauseAllEffects: function() {
  29691. var a =
  29692. this._audioPool,
  29693. b;
  29694. for (b in a)
  29695. for (var c = a[b], d = 0; d < a[b].length; d++) c[d].getPlaying() && c[d].pause()
  29696. },
  29697. resumeEffect: function(a) {
  29698. a && a.resume()
  29699. },
  29700. resumeAllEffects: function() {
  29701. var a = this._audioPool,
  29702. b;
  29703. for (b in a)
  29704. for (var c = a[b], d = 0; d < a[b].length; d++) c[d].resume()
  29705. },
  29706. stopEffect: function(a) {
  29707. a && a.stop()
  29708. },
  29709. stopAllEffects: function() {
  29710. var a = this._audioPool,
  29711. b;
  29712. for (b in a)
  29713. for (var c = a[b], d = 0; d < a[b].length; d++) c[d].stop()
  29714. },
  29715. unloadEffect: function(a) {
  29716. if (a) {
  29717. cc.loader.release(a);
  29718. var b = this._audioPool[a];
  29719. b && (b.length = 0);
  29720. delete this._audioPool[a];
  29721. delete h.cache[a]
  29722. }
  29723. },
  29724. end: function() {
  29725. this.stopMusic();
  29726. this.stopAllEffects()
  29727. },
  29728. _pauseCache: [],
  29729. _pausePlaying: function() {
  29730. var a = this._currMusic;
  29731. a && a.getPlaying() && (a.pause(), this._pauseCache.push(a));
  29732. var a = this._audioPool,
  29733. b;
  29734. for (b in a)
  29735. for (var c = a[b], d = 0; d < a[b].length; d++) c[d].getPlaying() && (c[d].pause(), this._pauseCache.push(c[d]))
  29736. },
  29737. _resumePlaying: function() {
  29738. for (var a = this._pauseCache, b = 0; b < a.length; b++) a[b].resume();
  29739. a.length = 0
  29740. }
  29741. };
  29742. if (!d) {
  29743. var k = function() {
  29744. var b = cc.audioEngine._currMusic;
  29745. b && !1 === b._touch &&
  29746. b._playing && b.getPlaying() && (b._touch = !0, b.play(0, b.loop), !a.replay && cc._canvas.removeEventListener("touchstart", k))
  29747. };
  29748. setTimeout(function() {
  29749. cc._canvas && cc._canvas.addEventListener("touchstart", k, !1)
  29750. }, 150)
  29751. }
  29752. cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function() {
  29753. cc.audioEngine._pausePlaying()
  29754. });
  29755. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function() {
  29756. cc.audioEngine._resumePlaying()
  29757. })
  29758. })(cc.__audioSupport);
  29759. (function() {
  29760. cc.PhysicsSprite = cc.Sprite.extend({
  29761. _ignoreBodyRotation: !1,
  29762. _body: null,
  29763. _rotation: 1,
  29764. ctor: function(a, c) {
  29765. cc.Sprite.prototype.ctor.call(this);
  29766. if (void 0 === a) cc.PhysicsSprite.prototype.init.call(this);
  29767. else if (cc.isString(a))
  29768. if ("#" === a[0]) {
  29769. var d = a.substr(1, a.length - 1),
  29770. d = cc.spriteFrameCache.getSpriteFrame(d);
  29771. this.initWithSpriteFrame(d)
  29772. } else this.init(a, c);
  29773. else cc.isObject(a) && (a instanceof cc.Texture2D ? this.initWithTexture(a, c) : a instanceof cc.SpriteFrame && this.initWithSpriteFrame(a));
  29774. cc.renderer.pushRenderCommand(this._renderCmd)
  29775. },
  29776. visit: function() {
  29777. cc.renderer.pushRenderCommand(this._renderCmd);
  29778. cc.Sprite.prototype.visit.call(this)
  29779. },
  29780. setBody: function(a) {
  29781. this._body = a
  29782. },
  29783. getBody: function() {
  29784. return this._body
  29785. },
  29786. getPosition: function() {
  29787. var a = this._body;
  29788. return {
  29789. x: a.p.x,
  29790. y: a.p.y
  29791. }
  29792. },
  29793. getPositionX: function() {
  29794. return this._body.p.x
  29795. },
  29796. getPositionY: function() {
  29797. return this._body.p.y
  29798. },
  29799. setPosition: function(a, c) {
  29800. void 0 === c ? (this._body.p.x = a.x, this._body.p.y = a.y) : (this._body.p.x = a, this._body.p.y = c)
  29801. },
  29802. setPositionX: function(a) {
  29803. this._body.p.x = a
  29804. },
  29805. setPositionY: function(a) {
  29806. this._body.p.y =
  29807. a
  29808. },
  29809. _syncPosition: function() {
  29810. var a = this._position,
  29811. c = this._body;
  29812. a.x === c.p.x && a.y === c.p.y || cc.Sprite.prototype.setPosition.call(this, c.p.x, c.p.y)
  29813. },
  29814. getRotation: function() {
  29815. return this._ignoreBodyRotation ? this._rotationX : -cc.radiansToDegrees(this._body.a)
  29816. },
  29817. setRotation: function(a) {
  29818. this._ignoreBodyRotation ? cc.Sprite.prototype.setRotation.call(this, a) : this._body.a = -cc.degreesToRadians(a)
  29819. },
  29820. _syncRotation: function() {
  29821. this._rotationX !== -cc.radiansToDegrees(this._body.a) && cc.Sprite.prototype.setRotation.call(this, -cc.radiansToDegrees(this._body.a))
  29822. },
  29823. getNodeToParentTransform: function() {
  29824. return this._renderCmd.getNodeToParentTransform()
  29825. },
  29826. isDirty: function() {
  29827. return !this._body.isSleeping()
  29828. },
  29829. setDirty: function() {},
  29830. setIgnoreBodyRotation: function(a) {
  29831. this._ignoreBodyRotation = a
  29832. },
  29833. _createRenderCmd: function() {
  29834. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.PhysicsSprite.CanvasRenderCmd(this) : new cc.PhysicsSprite.WebGLRenderCmd(this)
  29835. }
  29836. });
  29837. cc.PhysicsSprite._className = "PhysicsSprite";
  29838. var a = cc.PhysicsSprite.prototype;
  29839. cc.defineGetterSetter(a,
  29840. "body", a.getBody, a.setBody);
  29841. cc.defineGetterSetter(a, "dirty", a.isDirty, a.setDirty);
  29842. cc.PhysicsSprite.create = function(a, c) {
  29843. return new cc.PhysicsSprite(a, c)
  29844. };
  29845. cc.PhysicsSprite.createWithSpriteFrameName = cc.PhysicsSprite.create;
  29846. cc.PhysicsSprite.createWithSpriteFrame = cc.PhysicsSprite.create
  29847. })();
  29848. cc.__convertVerts = function(a) {
  29849. for (var b = [], c = 0; c < a.length / 2; c++) b[c] = {
  29850. x: a[2 * c],
  29851. y: a[2 * c + 1]
  29852. };
  29853. return b
  29854. };
  29855. cc.ColorForBody = function(a) {
  29856. return a.isRogue() || a.isSleeping() ? cc.color(128, 128, 128, 128) : a.nodeIdleTime > a.space.sleepTimeThreshold ? cc.color(84, 84, 84, 128) : cc.color(255, 0, 0, 128)
  29857. };
  29858. cc.DrawShape = function(a, b) {
  29859. var c = a.body,
  29860. d = cc.ColorForBody(c);
  29861. switch (a.collisionCode) {
  29862. case cp.CircleShape.prototype.collisionCode:
  29863. this.drawDot(a.tc, Math.max(a.r, 1), d);
  29864. this.drawSegment(a.tc, cp.v.add(a.tc, cp.v.mult(c.rot, a.r)), 1, d);
  29865. break;
  29866. case cp.SegmentShape.prototype.collisionCode:
  29867. this.drawSegment(a.ta, a.tb, Math.max(a.r, 2), d);
  29868. break;
  29869. case cp.PolyShape.prototype.collisionCode:
  29870. c = cc.color(d.r, d.g, d.b, cc.lerp(d.a, 255, 0.5));
  29871. this.drawPoly(cc.__convertVerts(a.tVerts), d, 1, c);
  29872. break;
  29873. default:
  29874. cc.log("cc.DrawShape(): Bad assertion in DrawShape()")
  29875. }
  29876. };
  29877. cc.DrawConstraint = function(a, b) {
  29878. var c = a.a,
  29879. d = a.b,
  29880. e;
  29881. a instanceof cp.PinJoint ? (e = c.local2World(a.anchr1), c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR)) : a instanceof cp.SlideJoint ? (e = c.local2World(a.anchr1), c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR)) : a instanceof cp.PivotJoint ? (e = c.local2World(a.anchr1),
  29882. c = d.local2World(a.anchr2), this.drawDot(e, 3, cc.CONSTRAINT_COLOR), this.drawDot(c, 3, cc.CONSTRAINT_COLOR)) : a instanceof cp.GrooveJoint && (e = c.local2World(a.grv_a), c = c.local2World(a.grv_b), d = d.local2World(a.anchr2), this.drawDot(d, 3, cc.CONSTRAINT_COLOR), this.drawSegment(e, c, 1, cc.CONSTRAINT_COLOR))
  29883. };
  29884. cc.CONSTRAINT_COLOR = cc.color(0, 255, 0, 128);
  29885. cc.PhysicsDebugNode = cc.DrawNode.extend({
  29886. _space: null,
  29887. _className: "PhysicsDebugNode",
  29888. ctor: function(a) {
  29889. cc.DrawNode.prototype.ctor.call(this);
  29890. this._space = a
  29891. },
  29892. getSpace: function() {
  29893. return this._space
  29894. },
  29895. setSpace: function(a) {
  29896. this._space = a
  29897. },
  29898. draw: function(a) {
  29899. this._space && (this._space.eachShape(cc.DrawShape.bind(this)), this._space.eachConstraint(cc.DrawConstraint.bind(this)), cc.DrawNode.prototype.draw.call(this), this.clear())
  29900. },
  29901. _createRenderCmd: function() {
  29902. return cc._renderType === cc._RENDER_TYPE_CANVAS ? new cc.PhysicsDebugNode.CanvasRenderCmd(this) :
  29903. new cc.PhysicsDebugNode.WebGLRenderCmd(this)
  29904. }
  29905. });
  29906. cc.PhysicsDebugNode.create = function(a) {
  29907. return new cc.PhysicsDebugNode(a)
  29908. };
  29909. (function() {
  29910. cc.PhysicsDebugNode.CanvasRenderCmd = function(a) {
  29911. cc.Node.CanvasRenderCmd.call(this, a);
  29912. this._buffer = a._buffer;
  29913. this._needDraw = !0
  29914. };
  29915. var a = cc.PhysicsDebugNode.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);
  29916. a.constructor = cc.PhysicsDebugNode.CanvasRenderCmd;
  29917. a.rendering = function(a, c, d) {
  29918. var e = this._node;
  29919. e._space && (e._space.eachShape(cc.DrawShape.bind(e)), e._space.eachConstraint(cc.DrawConstraint.bind(e)), cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this, a, c, d),
  29920. e.clear())
  29921. };
  29922. a._drawDot = cc.DrawNode.CanvasRenderCmd.prototype._drawDot;
  29923. a._drawSegment = cc.DrawNode.CanvasRenderCmd.prototype._drawSegment;
  29924. a._drawPoly = cc.DrawNode.CanvasRenderCmd.prototype._drawPoly
  29925. })();
  29926. (function() {
  29927. cc.PhysicsDebugNode.WebGLRenderCmd = function(a) {
  29928. cc.Node.WebGLRenderCmd.call(this, a);
  29929. this._needDraw = !0
  29930. };
  29931. cc.PhysicsDebugNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype);
  29932. cc.PhysicsDebugNode.WebGLRenderCmd.prototype.constructor = cc.PhysicsDebugNode.WebGLRenderCmd;
  29933. cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering = function(a) {
  29934. a = this._node;
  29935. a._space && (a._space.eachShape(cc.DrawShape.bind(a)), a._space.eachConstraint(cc.DrawConstraint.bind(a)), cc.glBlendFunc(a._blendFunc.src,
  29936. a._blendFunc.dst), this._shaderProgram.use(), this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix), a._render(), a.clear())
  29937. }
  29938. })();
  29939. (function() {
  29940. cc.PhysicsSprite.CanvasRenderCmd = function(a) {
  29941. cc.Sprite.CanvasRenderCmd.call(this, a);
  29942. this._needDraw = !0
  29943. };
  29944. var a = cc.PhysicsSprite.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype);
  29945. a.constructor = cc.PhysicsSprite.CanvasRenderCmd;
  29946. a.rendering = function(a, c, d) {
  29947. var e = this._node;
  29948. e._syncPosition();
  29949. e._ignoreBodyRotation || e._syncRotation();
  29950. this.transform(this.getParentRenderCmd());
  29951. cc.Sprite.CanvasRenderCmd.prototype.rendering.call(this, a, c, d)
  29952. };
  29953. a.getNodeToParentTransform = function() {
  29954. var a =
  29955. this._node,
  29956. c = this._transform,
  29957. d = a._body,
  29958. e = a._scaleX,
  29959. f = a._scaleY,
  29960. g = this._anchorPointInPoints;
  29961. c.tx = d.p.x;
  29962. c.ty = d.p.y;
  29963. var d = -d.a,
  29964. h = 1,
  29965. k = 0;
  29966. d && !a._ignoreBodyRotation && (h = Math.cos(d), k = Math.sin(d));
  29967. c.a = c.d = h;
  29968. c.b = -k;
  29969. c.c = k;
  29970. if (1 !== e || 1 !== f) c.a *= e, c.c *= e, c.b *= f, c.d *= f;
  29971. c.tx += h * -g.x * e + -k * g.y * f;
  29972. c.ty -= k * -g.x * e + h * g.y * f;
  29973. this._ignoreAnchorPointForPosition && (c.tx += g.x, c.ty += g.y);
  29974. return this._transform
  29975. }
  29976. })();
  29977. (function() {
  29978. cc.PhysicsSprite.WebGLRenderCmd = function(a) {
  29979. cc.Sprite.WebGLRenderCmd.call(this, a);
  29980. this._needDraw = !0
  29981. };
  29982. var a = cc.PhysicsSprite.WebGLRenderCmd.prototype = Object.create(cc.Sprite.WebGLRenderCmd.prototype);
  29983. a.constructor = cc.PhysicsSprite.WebGLRenderCmd;
  29984. a.rendering = function(a) {
  29985. var c = this._node;
  29986. c._syncPosition();
  29987. c._ignoreBodyRotation || c._syncRotation();
  29988. this.transform(this.getParentRenderCmd());
  29989. cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this, a)
  29990. };
  29991. a.getNodeToParentTransform = function() {
  29992. var a =
  29993. this._node,
  29994. c = a._body,
  29995. d = this._anchorPointInPoints,
  29996. e = a._scaleX,
  29997. f = a._scaleY,
  29998. g = c.p.x,
  29999. h = c.p.y;
  30000. this._ignoreAnchorPointForPosition && (g += d.x, h += d.y);
  30001. var c = c.a,
  30002. k = 1,
  30003. m = 0;
  30004. c && !a._ignoreBodyRotation && (k = Math.cos(c), m = Math.sin(c));
  30005. cc._rectEqualToZero(d) || (g += k * -d.x * e + -m * -d.y * f, h += m * -d.x * e + k * -d.y * f);
  30006. return this._transform = cc.affineTransformMake(k * e, m * e, -m * f, k * f, g, h)
  30007. };
  30008. a.updateTransform = function() {
  30009. this._dirty = this._node.isDirty();
  30010. cc.Sprite.WebGLRenderCmd.prototype.updateTransform.call(this)
  30011. }
  30012. })();
  30013. (function() {
  30014. Object.create = Object.create || function(a) {
  30015. function b() {}
  30016. b.prototype = a;
  30017. return new b
  30018. };
  30019. var a;
  30020. "undefined" === typeof exports ? (a = {}, "object" === typeof window && (window.cp = a)) : a = exports;
  30021. var b = function(a, b) {
  30022. if (!a) throw Error("Assertion failed: " + b);
  30023. },
  30024. c = function(a, b) {
  30025. !a && console && console.warn && (console.warn("ASSERTION FAILED: " + b), console.trace && console.trace())
  30026. },
  30027. d = function(a, b) {
  30028. return a < b ? a : b
  30029. },
  30030. e = function(a, b) {
  30031. return a > b ? a : b
  30032. },
  30033. f, g;
  30034. "object" === typeof window && -1 < window.navigator.userAgent.indexOf("Firefox") ?
  30035. (f = Math.min, g = Math.max) : (f = d, g = e);
  30036. var h = function(a, b) {
  30037. return a < b ? a + " " + b : b + " " + a
  30038. },
  30039. k = function(a, b) {
  30040. for (var c = 0; c < a.length; c++)
  30041. if (a[c] === b) {
  30042. a[c] = a[a.length - 1];
  30043. a.length--;
  30044. break
  30045. }
  30046. };
  30047. a.momentForCircle = function(a, b, c, d) {
  30048. return a * (0.5 * (b * b + c * c) + L(d))
  30049. };
  30050. a.areaForCircle = function(a, b) {
  30051. return Math.PI * Math.abs(a * a - b * b)
  30052. };
  30053. a.momentForSegment = function(a, b, c) {
  30054. var d = y(A(b, c), 0.5);
  30055. return a * (V(c, b) / 12 + L(d))
  30056. };
  30057. a.areaForSegment = function(a, b, c) {
  30058. return c * (Math.PI * c + 2 * U(a, b))
  30059. };
  30060. a.momentForPoly = function(a, b, c) {
  30061. for (var d = 0, e = 0,
  30062. f = b.length, g = 0; g < f; g += 2) var h = b[g] + c.x,
  30063. k = b[g + 1] + c.y,
  30064. m = b[(g + 2) % f] + c.x,
  30065. n = b[(g + 3) % f] + c.y,
  30066. p = m * k - n * h,
  30067. d = d + p * (h * h + k * k + (h * m + k * n) + (m * m + n * n)),
  30068. e = e + p;
  30069. return a * d / (6 * e)
  30070. };
  30071. a.areaForPoly = function(a) {
  30072. for (var b = 0, c = 0, d = a.length; c < d; c += 2) b += z(new s(a[c], a[c + 1]), new s(a[(c + 2) % d], a[(c + 3) % d]));
  30073. return -b / 2
  30074. };
  30075. a.centroidForPoly = function(a) {
  30076. for (var b = 0, c = new s(0, 0), d = 0, e = a.length; d < e; d += 2) var f = new s(a[d], a[d + 1]),
  30077. g = new s(a[(d + 2) % e], a[(d + 3) % e]),
  30078. h = z(f, g),
  30079. b = b + h,
  30080. c = A(c, y(A(f, g), h));
  30081. return y(c, 1 / (3 * b))
  30082. };
  30083. a.recenterPoly = function(b) {
  30084. for (var c =
  30085. a.centroidForPoly(b), d = 0; d < b.length; d += 2) b[d] -= c.x, b[d + 1] -= c.y
  30086. };
  30087. a.momentForBox = function(a, b, c) {
  30088. return a * (b * b + c * c) / 12
  30089. };
  30090. a.momentForBox2 = function(b, c) {
  30091. var d = c.r - c.l,
  30092. e = c.t - c.b,
  30093. f = y([c.l + c.r, c.b + c.t], 0.5);
  30094. return a.momentForBox(b, d, e) + b * L(f)
  30095. };
  30096. var m = a.loopIndexes = function(a) {
  30097. var b = 0,
  30098. c = 0,
  30099. d, e, f, g;
  30100. d = f = a[0];
  30101. e = g = a[1];
  30102. for (var h = a.length >> 1, k = 1; k < h; k++) {
  30103. var m = a[2 * k],
  30104. n = a[2 * k + 1];
  30105. if (m < d || m == d && n < e) d = m, e = n, b = k;
  30106. else if (m > f || m == f && n > g) f = m, g = n, c = k
  30107. }
  30108. return [b, c]
  30109. },
  30110. n = function(a, b, c) {
  30111. var d = a[2 * b];
  30112. a[2 * b] = a[2 * c];
  30113. a[2 * c] = d;
  30114. d = a[2 *
  30115. b + 1];
  30116. a[2 * b + 1] = a[2 * c + 1];
  30117. a[2 * c + 1] = d
  30118. },
  30119. p = function(a, b, c, d, e, f) {
  30120. if (0 === c) return 0;
  30121. var g = 0,
  30122. h = b;
  30123. e = w(e, d);
  30124. f *= D(e);
  30125. var k = b;
  30126. for (c = b + c - 1; k <= c;) {
  30127. var m = new s(a[2 * k], a[2 * k + 1]),
  30128. m = z(e, w(m, d));
  30129. m > f ? (m > g && (g = m, h = k), k++) : (n(a, k, c), c--)
  30130. }
  30131. h != b && n(a, b, h);
  30132. return k - b
  30133. },
  30134. t = function(a, b, c, d, e, f, g, h) {
  30135. if (0 > d) return 0;
  30136. if (0 == d) return b[2 * h] = f.x, b[2 * h + 1] = f.y, 1;
  30137. var k = p(b, c, d, e, f, a),
  30138. m = new s(b[2 * c], b[2 * c + 1]);
  30139. e = t(a, b, c + 1, k - 1, e, m, f, h);
  30140. m = h + e++;
  30141. b[2 * m] = f.x;
  30142. b[2 * m + 1] = f.y;
  30143. d = p(b, c + k, d - k, f, g, a);
  30144. m = new s(b[2 * (c + k)], b[2 * (c + k) + 1]);
  30145. return e + t(a, b, c +
  30146. k + 1, d - 1, f, m, g, h + e)
  30147. };
  30148. a.convexHull = function(a, b, d) {
  30149. if (b)
  30150. for (var e = 0; e < a.length; e++) b[e] = a[e];
  30151. else b = a;
  30152. var f = m(a),
  30153. e = f[0],
  30154. f = f[1];
  30155. if (e == f) return b.length = 2, b;
  30156. n(b, 0, e);
  30157. n(b, 1, 0 == f ? e : f);
  30158. e = new s(b[0], b[1]);
  30159. f = new s(b[2], b[3]);
  30160. a = t(d, b, 2, (a.length >> 1) - 2, e, f, e, 1) + 1;
  30161. b.length = 2 * a;
  30162. c(Ra(b), "Internal error: cpConvexHull() and cpPolyValidate() did not agree.Please report this error with as much info as you can.");
  30163. return b
  30164. };
  30165. var r = function(a, b, c) {
  30166. return f(g(a, b), c)
  30167. },
  30168. u = function(a) {
  30169. return g(0, f(a, 1))
  30170. },
  30171. s = a.Vect = function(a,
  30172. b) {
  30173. this.x = a;
  30174. this.y = b
  30175. };
  30176. a.v = function(a, b) {
  30177. return new s(a, b)
  30178. };
  30179. var v = a.vzero = new s(0, 0),
  30180. x = a.v.dot = function(a, b) {
  30181. return a.x * b.x + a.y * b.y
  30182. },
  30183. D = a.v.len = function(a) {
  30184. return Math.sqrt(x(a, a))
  30185. },
  30186. E = a.v.len2 = function(a, b) {
  30187. return Math.sqrt(a * a + b * b)
  30188. };
  30189. a.v.eql = function(a, b) {
  30190. return a.x === b.x && a.y === b.y
  30191. };
  30192. var A = a.v.add = function(a, b) {
  30193. return new s(a.x + b.x, a.y + b.y)
  30194. };
  30195. s.prototype.add = function(a) {
  30196. this.x += a.x;
  30197. this.y += a.y;
  30198. return this
  30199. };
  30200. var w = a.v.sub = function(a, b) {
  30201. return new s(a.x - b.x, a.y - b.y)
  30202. };
  30203. s.prototype.sub = function(a) {
  30204. this.x -=
  30205. a.x;
  30206. this.y -= a.y;
  30207. return this
  30208. };
  30209. var B = a.v.neg = function(a) {
  30210. return new s(-a.x, -a.y)
  30211. };
  30212. s.prototype.neg = function() {
  30213. this.x = -this.x;
  30214. this.y = -this.y;
  30215. return this
  30216. };
  30217. var y = a.v.mult = function(a, b) {
  30218. return new s(a.x * b, a.y * b)
  30219. };
  30220. s.prototype.mult = function(a) {
  30221. this.x *= a;
  30222. this.y *= a;
  30223. return this
  30224. };
  30225. var z = a.v.cross = function(a, b) {
  30226. return a.x * b.y - a.y * b.x
  30227. },
  30228. F = a.v.perp = function(a) {
  30229. return new s(-a.y, a.x)
  30230. };
  30231. a.v.pvrperp = function(a) {
  30232. return new s(a.y, -a.x)
  30233. };
  30234. var J = a.v.project = function(a, b) {
  30235. return y(b, x(a, b) / L(b))
  30236. };
  30237. s.prototype.project = function(a) {
  30238. this.mult(x(this,
  30239. a) / L(a));
  30240. return this
  30241. };
  30242. var C = a.v.rotate = function(a, b) {
  30243. return new s(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x)
  30244. };
  30245. s.prototype.rotate = function(a) {
  30246. this.x = this.x * a.x - this.y * a.y;
  30247. this.y = this.x * a.y + this.y * a.x;
  30248. return this
  30249. };
  30250. var N = a.v.unrotate = function(a, b) {
  30251. return new s(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y)
  30252. },
  30253. L = a.v.lengthsq = function(a) {
  30254. return x(a, a)
  30255. },
  30256. P = a.v.lengthsq2 = function(a, b) {
  30257. return a * a + b * b
  30258. },
  30259. S = a.v.lerp = function(a, b, c) {
  30260. return A(y(a, 1 - c), y(b, c))
  30261. },
  30262. I = a.v.normalize = function(a) {
  30263. return y(a, 1 / D(a))
  30264. },
  30265. T = a.v.normalize_safe = function(a) {
  30266. return 0 ===
  30267. a.x && 0 === a.y ? v : I(a)
  30268. },
  30269. K = a.v.clamp = function(a, b) {
  30270. return x(a, a) > b * b ? y(I(a), b) : a
  30271. };
  30272. a.v.lerpconst = function(a, b, c) {
  30273. return A(a, K(w(b, a), c))
  30274. };
  30275. var U = a.v.dist = function(a, b) {
  30276. return D(w(a, b))
  30277. },
  30278. V = a.v.distsq = function(a, b) {
  30279. return L(w(a, b))
  30280. };
  30281. a.v.near = function(a, b, c) {
  30282. return V(a, b) < c * c
  30283. };
  30284. var aa = a.v.slerp = function(a, b, c) {
  30285. var d = Math.acos(x(a, b));
  30286. if (d) {
  30287. var e = 1 / Math.sin(d);
  30288. return A(y(a, Math.sin((1 - c) * d) * e), y(b, Math.sin(c * d) * e))
  30289. }
  30290. return a
  30291. };
  30292. a.v.slerpconst = function(a, b, c) {
  30293. var d = Math.acos(x(a, b));
  30294. return aa(a, b, f(c, d) / d)
  30295. };
  30296. a.v.forangle =
  30297. function(a) {
  30298. return new s(Math.cos(a), Math.sin(a))
  30299. };
  30300. a.v.toangle = function(a) {
  30301. return Math.atan2(a.y, a.x)
  30302. };
  30303. a.v.str = function(a) {
  30304. return "(" + a.x.toFixed(3) + ", " + a.y.toFixed(3) + ")"
  30305. };
  30306. var za = 0,
  30307. X = a.BB = function(a, b, c, d) {
  30308. this.l = a;
  30309. this.b = b;
  30310. this.r = c;
  30311. this.t = d;
  30312. za++
  30313. };
  30314. a.bb = function(a, b, c, d) {
  30315. return new X(a, b, c, d)
  30316. };
  30317. var xa = function(a, b) {
  30318. return new X(a.x - b, a.y - b, a.x + b, a.y + b)
  30319. },
  30320. ya = 0;
  30321. a.NO_GROUP = 0;
  30322. var ia = a.ALL_LAYERS = -1;
  30323. a.resetShapeIdCounter = function() {
  30324. ya = 0
  30325. };
  30326. var R = a.Shape = function(a) {
  30327. this.body = a;
  30328. this.bb_l = this.bb_b = this.bb_r =
  30329. this.bb_t = 0;
  30330. this.hashid = ya++;
  30331. this.sensor = !1;
  30332. this.u = this.e = 0;
  30333. this.surface_v = v;
  30334. this.group = this.collision_type = 0;
  30335. this.layers = ia;
  30336. this.space = null;
  30337. this.collisionCode = this.collisionCode
  30338. };
  30339. R.prototype.setElasticity = function(a) {
  30340. this.e = a
  30341. };
  30342. R.prototype.setFriction = function(a) {
  30343. this.body.activate();
  30344. this.u = a
  30345. };
  30346. R.prototype.setLayers = function(a) {
  30347. this.body.activate();
  30348. this.layers = a
  30349. };
  30350. R.prototype.setSensor = function(a) {
  30351. this.body.activate();
  30352. this.sensor = a
  30353. };
  30354. R.prototype.setCollisionType = function(a) {
  30355. this.body.activate();
  30356. this.collision_type =
  30357. a
  30358. };
  30359. R.prototype.getBody = function() {
  30360. return this.body
  30361. };
  30362. R.prototype.active = function() {
  30363. return this.body && -1 !== this.body.shapeList.indexOf(this)
  30364. };
  30365. R.prototype.setBody = function(a) {
  30366. b(!this.active(), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body.");
  30367. this.body = a
  30368. };
  30369. R.prototype.cacheBB = function() {
  30370. return this.update(this.body.p, this.body.rot)
  30371. };
  30372. R.prototype.update = function(a, c) {
  30373. b(!isNaN(c.x), "Rotation is NaN");
  30374. b(!isNaN(a.x), "Position is NaN");
  30375. this.cacheData(a,
  30376. c)
  30377. };
  30378. R.prototype.pointQuery = function(a) {
  30379. a = this.nearestPointQuery(a);
  30380. if (0 > a.d) return a
  30381. };
  30382. R.prototype.getBB = function() {
  30383. return new X(this.bb_l, this.bb_b, this.bb_r, this.bb_t)
  30384. };
  30385. var Aa = function(a, b, c) {
  30386. this.shape = a;
  30387. this.p = b;
  30388. this.d = c
  30389. },
  30390. ma = function(a, b, c) {
  30391. this.shape = a;
  30392. this.t = b;
  30393. this.n = c
  30394. };
  30395. ma.prototype.hitPoint = function(a, b) {
  30396. return S(a, b, this.t)
  30397. };
  30398. ma.prototype.hitDist = function(a, b) {
  30399. return U(a, b) * this.t
  30400. };
  30401. var ka = a.CircleShape = function(a, b, c) {
  30402. this.c = this.tc = c;
  30403. this.r = b;
  30404. this.type = "circle";
  30405. R.call(this, a)
  30406. };
  30407. ka.prototype =
  30408. Object.create(R.prototype);
  30409. ka.prototype.cacheData = function(a, b) {
  30410. var c = this.tc = C(this.c, b).add(a),
  30411. d = this.r;
  30412. this.bb_l = c.x - d;
  30413. this.bb_b = c.y - d;
  30414. this.bb_r = c.x + d;
  30415. this.bb_t = c.y + d
  30416. };
  30417. ka.prototype.nearestPointQuery = function(a) {
  30418. var b = a.x - this.tc.x,
  30419. c = a.y - this.tc.y;
  30420. a = E(b, c);
  30421. var d = this.r,
  30422. b = new s(this.tc.x + b * d / a, this.tc.y + c * d / a);
  30423. return new Aa(this, b, a - d)
  30424. };
  30425. var Ba = function(a, b, c, d, e, f) {
  30426. d = w(d, b);
  30427. e = w(e, b);
  30428. b = x(d, d) - 2 * x(d, e) + x(e, e);
  30429. f = -2 * x(d, d) + 2 * x(d, e);
  30430. c = x(d, d) - c * c;
  30431. c = f * f - 4 * b * c;
  30432. if (0 <= c && (c = (-f - Math.sqrt(c)) / (2 * b), 0 <= c && 1 >=
  30433. c)) return new ma(a, c, I(S(d, e, c)))
  30434. };
  30435. ka.prototype.segmentQuery = function(a, b) {
  30436. return Ba(this, this.tc, this.r, a, b)
  30437. };
  30438. var fa = a.SegmentShape = function(a, b, c, d) {
  30439. this.a = b;
  30440. this.b = c;
  30441. this.n = F(I(w(c, b)));
  30442. this.ta = this.tb = this.tn = null;
  30443. this.r = d;
  30444. this.b_tangent = this.a_tangent = v;
  30445. this.type = "segment";
  30446. R.call(this, a)
  30447. };
  30448. fa.prototype = Object.create(R.prototype);
  30449. fa.prototype.cacheData = function(a, b) {
  30450. this.ta = A(a, C(this.a, b));
  30451. this.tb = A(a, C(this.b, b));
  30452. this.tn = C(this.n, b);
  30453. var c, d, e, f;
  30454. this.ta.x < this.tb.x ? (c = this.ta.x, d = this.tb.x) : (c =
  30455. this.tb.x, d = this.ta.x);
  30456. this.ta.y < this.tb.y ? (e = this.ta.y, f = this.tb.y) : (e = this.tb.y, f = this.ta.y);
  30457. var g = this.r;
  30458. this.bb_l = c - g;
  30459. this.bb_b = e - g;
  30460. this.bb_r = d + g;
  30461. this.bb_t = f + g
  30462. };
  30463. fa.prototype.nearestPointQuery = function(a) {
  30464. var b;
  30465. b = this.tb;
  30466. var c = w(this.ta, b),
  30467. d = u(x(c, w(a, b)) / L(c));
  30468. b = A(b, y(c, d));
  30469. var c = a.x - b.x,
  30470. e = a.y - b.y;
  30471. a = E(c, e);
  30472. d = this.r;
  30473. b = a ? A(b, y(new s(c, e), d / a)) : b;
  30474. return new Aa(this, b, a - d)
  30475. };
  30476. fa.prototype.segmentQuery = function(a, b) {
  30477. var c = this.tn,
  30478. d = x(w(this.ta, a), c),
  30479. e = this.r,
  30480. f = 0 < d ? B(c) : c,
  30481. g = w(y(f, e), a),
  30482. h = A(this.ta, g),
  30483. k = A(this.tb, g),
  30484. g = w(b, a);
  30485. if (0 >= z(g, h) * z(g, k)) {
  30486. if (e = d + (0 < d ? -e : e), d = -e, c = x(g, c) - e, 0 > d * c) return new ma(this, d / (d - c), f)
  30487. } else if (0 !== e) return f = Ba(this, this.ta, this.r, a, b), c = Ba(this, this.tb, this.r, a, b), f ? c && c.t < f.t ? c : f : c
  30488. };
  30489. fa.prototype.setNeighbors = function(a, b) {
  30490. this.a_tangent = w(a, this.a);
  30491. this.b_tangent = w(b, this.b)
  30492. };
  30493. fa.prototype.setEndpoints = function(a, b) {
  30494. this.a = a;
  30495. this.b = b;
  30496. this.n = F(I(w(b, a)))
  30497. };
  30498. var Ra = function(a) {
  30499. for (var b = a.length, c = 0; c < b; c += 2) {
  30500. var d = a[(c + 2) % b],
  30501. e = a[(c + 3) % b];
  30502. if (0 < (d - a[c]) * (a[(c + 5) % b] - e) -
  30503. (e - a[c + 1]) * (a[(c + 4) % b] - d)) return !1
  30504. }
  30505. return !0
  30506. },
  30507. W = a.PolyShape = function(a, b, c) {
  30508. this.setVerts(b, c);
  30509. this.type = "poly";
  30510. R.call(this, a)
  30511. };
  30512. W.prototype = Object.create(R.prototype);
  30513. var Ca = function(a, b) {
  30514. this.n = a;
  30515. this.d = b
  30516. };
  30517. Ca.prototype.compare = function(a) {
  30518. return x(this.n, a) - this.d
  30519. };
  30520. W.prototype.setVerts = function(a, c) {
  30521. b(4 <= a.length, "Polygons require some verts");
  30522. b("number" === typeof a[0], "Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])");
  30523. b(Ra(a), "Polygon is concave or has a reversed winding. Consider using cpConvexHull()");
  30524. var d = a.length,
  30525. e = d >> 1;
  30526. this.verts = Array(d);
  30527. this.tVerts = Array(d);
  30528. this.planes = Array(e);
  30529. this.tPlanes = Array(e);
  30530. for (e = 0; e < d; e += 2) {
  30531. var f = a[e] + c.x,
  30532. g = a[e + 1] + c.y,
  30533. h = I(F(new s(a[(e + 2) % d] + c.x - f, a[(e + 3) % d] + c.y - g)));
  30534. this.verts[e] = f;
  30535. this.verts[e + 1] = g;
  30536. this.planes[e >> 1] = new Ca(h, h.x * f + h.y * g);
  30537. this.tPlanes[e >> 1] = new Ca(new s(0, 0), 0)
  30538. }
  30539. };
  30540. a.BoxShape = function(a, b, c) {
  30541. b /= 2;
  30542. c /= 2;
  30543. return kb(a, new X(-b, -c, b, c))
  30544. };
  30545. var kb = a.BoxShape2 = function(a, b) {
  30546. return new W(a, [b.l, b.b, b.l, b.t, b.r, b.t, b.r, b.b], v)
  30547. };
  30548. W.prototype.transformVerts = function(a,
  30549. b) {
  30550. for (var c = this.verts, d = this.tVerts, e = Infinity, h = -Infinity, k = Infinity, m = -Infinity, n = 0; n < c.length; n += 2) {
  30551. var p = c[n],
  30552. r = c[n + 1],
  30553. s = a.x + p * b.x - r * b.y,
  30554. p = a.y + p * b.y + r * b.x;
  30555. d[n] = s;
  30556. d[n + 1] = p;
  30557. e = f(e, s);
  30558. h = g(h, s);
  30559. k = f(k, p);
  30560. m = g(m, p)
  30561. }
  30562. this.bb_l = e;
  30563. this.bb_b = k;
  30564. this.bb_r = h;
  30565. this.bb_t = m
  30566. };
  30567. W.prototype.transformAxes = function(a, b) {
  30568. for (var c = this.planes, d = this.tPlanes, e = 0; e < c.length; e++) {
  30569. var f = C(c[e].n, b);
  30570. d[e].n = f;
  30571. d[e].d = x(a, f) + c[e].d
  30572. }
  30573. };
  30574. W.prototype.cacheData = function(a, b) {
  30575. this.transformAxes(a, b);
  30576. this.transformVerts(a, b)
  30577. };
  30578. W.prototype.nearestPointQuery =
  30579. function(a) {
  30580. for (var b = this.tPlanes, c = this.tVerts, d = c[c.length - 2], e = c[c.length - 1], f = Infinity, g = v, h = !1, k = 0; k < b.length; k++) {
  30581. 0 < b[k].compare(a) && (h = !0);
  30582. var m = c[2 * k],
  30583. n = c[2 * k + 1],
  30584. p;
  30585. p = m;
  30586. var r = n,
  30587. d = d - p,
  30588. e = e - r,
  30589. t = u((d * (a.x - p) + e * (a.y - r)) / P(d, e));
  30590. p = new s(p + d * t, r + e * t);
  30591. r = U(a, p);
  30592. r < f && (f = r, g = p);
  30593. d = m;
  30594. e = n
  30595. }
  30596. return new Aa(this, g, h ? f : -f)
  30597. };
  30598. W.prototype.segmentQuery = function(a, b) {
  30599. for (var c = this.tPlanes, d = this.tVerts, e = c.length, f = 2 * e, g = 0; g < e; g++) {
  30600. var h = c[g].n,
  30601. k = x(a, h);
  30602. if (!(c[g].d > k)) {
  30603. var m = x(b, h),
  30604. k = (c[g].d - k) / (m - k);
  30605. if (!(0 > k || 1 <
  30606. k)) {
  30607. var m = S(a, b, k),
  30608. m = -z(h, m),
  30609. n = -(h.x * d[(2 * g + 3) % f] - h.y * d[(2 * g + 2) % f]);
  30610. if (-(h.x * d[2 * g + 1] - h.y * d[2 * g]) <= m && m <= n) return new ma(this, k, h)
  30611. }
  30612. }
  30613. }
  30614. };
  30615. W.prototype.valueOnAxis = function(a, b) {
  30616. for (var c = this.tVerts, d = a.x * c[0] + a.y * c[1], e = 2; e < c.length; e += 2) d = f(d, a.x * c[e] + a.y * c[e + 1]);
  30617. return d - b
  30618. };
  30619. W.prototype.containsVert = function(a, b) {
  30620. for (var c = this.tPlanes, d = 0; d < c.length; d++) {
  30621. var e = c[d].n;
  30622. if (0 < e.x * a + e.y * b - c[d].d) return !1
  30623. }
  30624. return !0
  30625. };
  30626. W.prototype.containsVertPartial = function(a, b, c) {
  30627. for (var d = this.tPlanes, e = 0; e < d.length; e++) {
  30628. var f =
  30629. d[e].n;
  30630. if (!(0 > x(f, c)) && 0 < f.x * a + f.y * b - d[e].d) return !1
  30631. }
  30632. return !0
  30633. };
  30634. W.prototype.getNumVerts = function() {
  30635. return this.verts.length / 2
  30636. };
  30637. W.prototype.getVert = function(a) {
  30638. return new s(this.verts[2 * a], this.verts[2 * a + 1])
  30639. };
  30640. var H = a.Body = function(a, b) {
  30641. this.p = new s(0, 0);
  30642. this.vx = this.vy = 0;
  30643. this.f = new s(0, 0);
  30644. this.t = this.w = 0;
  30645. this.w_limit = this.v_limit = Infinity;
  30646. this.w_bias = this.v_biasx = this.v_biasy = 0;
  30647. this.space = null;
  30648. this.shapeList = [];
  30649. this.nodeNext = this.nodeRoot = this.constraintList = this.arbiterList = null;
  30650. this.nodeIdleTime =
  30651. 0;
  30652. this.setMass(a);
  30653. this.setMoment(b);
  30654. this.rot = new s(0, 0);
  30655. this.setAngle(0)
  30656. };
  30657. a.StaticBody = function() {
  30658. var a = new H(Infinity, Infinity);
  30659. a.nodeIdleTime = Infinity;
  30660. return a
  30661. };
  30662. if ("undefined" !== typeof DEBUG && DEBUG) {
  30663. var Da = function(a, c) {
  30664. b(a.x == a.x && a.y == a.y, c)
  30665. },
  30666. Ea = function(a, c) {
  30667. b(Infinity !== Math.abs(a.x) && Infinity !== Math.abs(a.y), c)
  30668. };
  30669. H.prototype.sanityCheck = function() {
  30670. b(this.m === this.m && this.m_inv === this.m_inv, "Body's mass is invalid.");
  30671. b(this.i === this.i && this.i_inv === this.i_inv, "Body's moment is invalid.");
  30672. var a =
  30673. this.p;
  30674. Da(a, "Body's position is invalid.");
  30675. Ea(a, "Body's position is invalid.");
  30676. a = this.f;
  30677. Da(a, "Body's force is invalid.");
  30678. Ea(a, "Body's force is invalid.");
  30679. b(this.vx === this.vx && Infinity !== Math.abs(this.vx), "Body's velocity is invalid.");
  30680. b(this.vy === this.vy && Infinity !== Math.abs(this.vy), "Body's velocity is invalid.");
  30681. b(this.a === this.a && Infinity !== Math.abs(this.a), "Body's angle is invalid.");
  30682. b(this.w === this.w && Infinity !== Math.abs(this.w), "Body's angular velocity is invalid.");
  30683. b(this.t === this.t && Infinity !==
  30684. Math.abs(this.t), "Body's torque is invalid.");
  30685. a = this.rot;
  30686. Da(a, "Body's rotation vector is invalid.");
  30687. Ea(a, "Body's rotation vector is invalid.");
  30688. b(this.v_limit === this.v_limit, "Body's velocity limit is invalid.");
  30689. b(this.w_limit === this.w_limit, "Body's angular velocity limit is invalid.")
  30690. }
  30691. } else H.prototype.sanityCheck = function() {};
  30692. H.prototype.getPos = function() {
  30693. return this.p
  30694. };
  30695. H.prototype.getVel = function() {
  30696. return new s(this.vx, this.vy)
  30697. };
  30698. H.prototype.getAngVel = function() {
  30699. return this.w
  30700. };
  30701. H.prototype.isSleeping =
  30702. function() {
  30703. return null !== this.nodeRoot
  30704. };
  30705. H.prototype.isStatic = function() {
  30706. return Infinity === this.nodeIdleTime
  30707. };
  30708. H.prototype.isRogue = function() {
  30709. return null === this.space
  30710. };
  30711. H.prototype.setMass = function(a) {
  30712. b(0 < a, "Mass must be positive and non-zero.");
  30713. this.activate();
  30714. this.m = a;
  30715. this.m_inv = 1 / a
  30716. };
  30717. H.prototype.setMoment = function(a) {
  30718. b(0 < a, "Moment of Inertia must be positive and non-zero.");
  30719. this.activate();
  30720. this.i = a;
  30721. this.i_inv = 1 / a
  30722. };
  30723. H.prototype.addShape = function(a) {
  30724. this.shapeList.push(a)
  30725. };
  30726. H.prototype.removeShape = function(a) {
  30727. k(this.shapeList,
  30728. a)
  30729. };
  30730. var Ga = function(a, b, c) {
  30731. if (a === c) return a.next(b);
  30732. a.a === b ? a.next_a = Ga(a.next_a, b, c) : a.next_b = Ga(a.next_b, b, c);
  30733. return a
  30734. };
  30735. H.prototype.removeConstraint = function(a) {
  30736. this.constraintList = Ga(this.constraintList, this, a)
  30737. };
  30738. H.prototype.setPos = function(b) {
  30739. this.activate();
  30740. this.sanityCheck();
  30741. b === v && (b = a.v(0, 0));
  30742. this.p = b
  30743. };
  30744. H.prototype.setVel = function(a) {
  30745. this.activate();
  30746. this.vx = a.x;
  30747. this.vy = a.y
  30748. };
  30749. H.prototype.setAngVel = function(a) {
  30750. this.activate();
  30751. this.w = a
  30752. };
  30753. H.prototype.setAngleInternal = function(a) {
  30754. b(!isNaN(a), "Internal Error: Attempting to set body's angle to NaN");
  30755. this.a = a;
  30756. this.rot.x = Math.cos(a);
  30757. this.rot.y = Math.sin(a)
  30758. };
  30759. H.prototype.setAngle = function(a) {
  30760. this.activate();
  30761. this.sanityCheck();
  30762. this.setAngleInternal(a)
  30763. };
  30764. H.prototype.velocity_func = function(a, b, c) {
  30765. var d = this.vx * b + (a.x + this.f.x * this.m_inv) * c;
  30766. a = this.vy * b + (a.y + this.f.y * this.m_inv) * c;
  30767. var e = this.v_limit,
  30768. f = d * d + a * a,
  30769. e = f > e * e ? e / Math.sqrt(f) : 1;
  30770. this.vx = d * e;
  30771. this.vy = a * e;
  30772. d = this.w_limit;
  30773. this.w = r(this.w * b + this.t * this.i_inv * c, -d, d);
  30774. this.sanityCheck()
  30775. };
  30776. H.prototype.position_func = function(a) {
  30777. this.p.x += (this.vx + this.v_biasx) *
  30778. a;
  30779. this.p.y += (this.vy + this.v_biasy) * a;
  30780. this.setAngleInternal(this.a + (this.w + this.w_bias) * a);
  30781. this.w_bias = this.v_biasx = this.v_biasy = 0;
  30782. this.sanityCheck()
  30783. };
  30784. H.prototype.resetForces = function() {
  30785. this.activate();
  30786. this.f = new s(0, 0);
  30787. this.t = 0
  30788. };
  30789. H.prototype.applyForce = function(a, b) {
  30790. this.activate();
  30791. this.f = A(this.f, a);
  30792. this.t += z(b, a)
  30793. };
  30794. H.prototype.applyImpulse = function(a, b) {
  30795. this.activate();
  30796. Ia(this, a.x, a.y, b)
  30797. };
  30798. H.prototype.getVelAtPoint = function(a) {
  30799. return A(new s(this.vx, this.vy), y(F(a), this.w))
  30800. };
  30801. H.prototype.getVelAtWorldPoint =
  30802. function(a) {
  30803. return this.getVelAtPoint(w(a, this.p))
  30804. };
  30805. H.prototype.getVelAtLocalPoint = function(a) {
  30806. return this.getVelAtPoint(C(a, this.rot))
  30807. };
  30808. H.prototype.eachShape = function(a) {
  30809. for (var b = 0, c = this.shapeList.length; b < c; b++) a(this.shapeList[b])
  30810. };
  30811. H.prototype.eachConstraint = function(a) {
  30812. for (var b = this.constraintList; b;) {
  30813. var c = b.next(this);
  30814. a(b);
  30815. b = c
  30816. }
  30817. };
  30818. H.prototype.eachArbiter = function(a) {
  30819. for (var b = this.arbiterList; b;) {
  30820. var c = b.next(this);
  30821. b.swappedColl = this === b.body_b;
  30822. a(b);
  30823. b = c
  30824. }
  30825. };
  30826. H.prototype.local2World = function(a) {
  30827. return A(this.p,
  30828. C(a, this.rot))
  30829. };
  30830. H.prototype.world2Local = function(a) {
  30831. return N(w(a, this.p), this.rot)
  30832. };
  30833. H.prototype.kineticEnergy = function() {
  30834. var a = this.vx * this.vx + this.vy * this.vy,
  30835. b = this.w * this.w;
  30836. return (a ? a * this.m : 0) + (b ? b * this.i : 0)
  30837. };
  30838. var Ha = a.SpatialIndex = function(a) {
  30839. if (this.staticIndex = a) {
  30840. if (a.dynamicIndex) throw Error("This static index is already associated with a dynamic index.");
  30841. a.dynamicIndex = this
  30842. }
  30843. };
  30844. Ha.prototype.collideStatic = function(a, b) {
  30845. if (0 < a.count) {
  30846. var c = a.query;
  30847. this.each(function(a) {
  30848. c(a, new X(a.bb_l, a.bb_b,
  30849. a.bb_r, a.bb_t), b)
  30850. })
  30851. }
  30852. };
  30853. var O = a.BBTree = function(a) {
  30854. Ha.call(this, a);
  30855. this.velocityFunc = null;
  30856. this.leaves = {};
  30857. this.count = 0;
  30858. this.pooledPairs = this.pooledNodes = this.root = null;
  30859. this.stamp = 0
  30860. };
  30861. O.prototype = Object.create(Ha.prototype);
  30862. var lb = 0,
  30863. ba = function(a, b, c) {
  30864. this.obj = null;
  30865. this.bb_l = f(b.bb_l, c.bb_l);
  30866. this.bb_b = f(b.bb_b, c.bb_b);
  30867. this.bb_r = g(b.bb_r, c.bb_r);
  30868. this.bb_t = g(b.bb_t, c.bb_t);
  30869. this.parent = null;
  30870. this.setA(b);
  30871. this.setB(c)
  30872. };
  30873. O.prototype.makeNode = function(a, b) {
  30874. var c = this.pooledNodes;
  30875. if (c) return this.pooledNodes = c.parent,
  30876. c.constructor(this, a, b), c;
  30877. lb++;
  30878. return new ba(this, a, b)
  30879. };
  30880. var mb = 0,
  30881. ca = function(a, b) {
  30882. this.obj = b;
  30883. a.getBB(b, this);
  30884. this.parent = null;
  30885. this.stamp = 1;
  30886. this.pairs = null;
  30887. mb++
  30888. };
  30889. O.prototype.getBB = function(a, b) {
  30890. var c = this.velocityFunc;
  30891. if (c) {
  30892. var d = 0.1 * (a.bb_r - a.bb_l),
  30893. e = 0.1 * (a.bb_t - a.bb_b),
  30894. c = y(c(a), 0.1);
  30895. b.bb_l = a.bb_l + f(-d, c.x);
  30896. b.bb_b = a.bb_b + f(-e, c.y);
  30897. b.bb_r = a.bb_r + g(d, c.x);
  30898. b.bb_t = a.bb_t + g(e, c.y)
  30899. } else b.bb_l = a.bb_l, b.bb_b = a.bb_b, b.bb_r = a.bb_r, b.bb_t = a.bb_t
  30900. };
  30901. O.prototype.getStamp = function() {
  30902. var a = this.dynamicIndex;
  30903. return a &&
  30904. a.stamp ? a.stamp : this.stamp
  30905. };
  30906. O.prototype.incrementStamp = function() {
  30907. this.dynamicIndex && this.dynamicIndex.stamp ? this.dynamicIndex.stamp++ : this.stamp++
  30908. };
  30909. var nb = 0,
  30910. Xa = function(a, b, c, d) {
  30911. this.prevA = null;
  30912. this.leafA = a;
  30913. this.nextA = b;
  30914. this.prevB = null;
  30915. this.leafB = c;
  30916. this.nextB = d
  30917. };
  30918. O.prototype.makePair = function(a, b, c, d) {
  30919. var e = this.pooledPairs;
  30920. if (e) return this.pooledPairs = e.prevA, e.prevA = null, e.leafA = a, e.nextA = b, e.prevB = null, e.leafB = c, e.nextB = d, e;
  30921. nb++;
  30922. return new Xa(a, b, c, d)
  30923. };
  30924. Xa.prototype.recycle = function(a) {
  30925. this.prevA =
  30926. a.pooledPairs;
  30927. a.pooledPairs = this
  30928. };
  30929. var Sa = function(a, b, c) {
  30930. c && (c.leafA === b ? c.prevA = a : c.prevB = a);
  30931. a ? a.leafA === b ? a.nextA = c : a.nextB = c : b.pairs = c
  30932. };
  30933. ca.prototype.clearPairs = function(a) {
  30934. var b = this.pairs,
  30935. c;
  30936. for (this.pairs = null; b;) b.leafA === this ? (c = b.nextA, Sa(b.prevB, b.leafB, b.nextB)) : (c = b.nextB, Sa(b.prevA, b.leafA, b.nextA)), b.recycle(a), b = c
  30937. };
  30938. var Ta = function(a, b, c) {
  30939. var d = a.pairs,
  30940. e = b.pairs;
  30941. c = c.makePair(a, d, b, e);
  30942. a.pairs = b.pairs = c;
  30943. d && (d.leafA === a ? d.prevA = c : d.prevB = c);
  30944. e && (e.leafA === b ? e.prevA = c : e.prevB = c)
  30945. };
  30946. ba.prototype.recycle =
  30947. function(a) {
  30948. this.parent = a.pooledNodes;
  30949. a.pooledNodes = this
  30950. };
  30951. ca.prototype.recycle = function(a) {};
  30952. ba.prototype.setA = function(a) {
  30953. this.A = a;
  30954. a.parent = this
  30955. };
  30956. ba.prototype.setB = function(a) {
  30957. this.B = a;
  30958. a.parent = this
  30959. };
  30960. ca.prototype.isLeaf = !0;
  30961. ba.prototype.isLeaf = !1;
  30962. ba.prototype.otherChild = function(a) {
  30963. return this.A == a ? this.B : this.A
  30964. };
  30965. ba.prototype.replaceChild = function(a, b, d) {
  30966. c(a == this.A || a == this.B, "Node is not a child of parent.");
  30967. this.A == a ? (this.A.recycle(d), this.setA(b)) : (this.B.recycle(d), this.setB(b));
  30968. for (a = this; a; a =
  30969. a.parent) b = a.A, d = a.B, a.bb_l = f(b.bb_l, d.bb_l), a.bb_b = f(b.bb_b, d.bb_b), a.bb_r = g(b.bb_r, d.bb_r), a.bb_t = g(b.bb_t, d.bb_t)
  30970. };
  30971. ba.prototype.bbArea = ca.prototype.bbArea = function() {
  30972. return (this.bb_r - this.bb_l) * (this.bb_t - this.bb_b)
  30973. };
  30974. var Ua = function(a, b) {
  30975. return (g(a.bb_r, b.bb_r) - f(a.bb_l, b.bb_l)) * (g(a.bb_t, b.bb_t) - f(a.bb_b, b.bb_b))
  30976. },
  30977. Va = function(a, b) {
  30978. return Math.abs(a.bb_l + a.bb_r - b.bb_l - b.bb_r) + Math.abs(a.bb_b + a.bb_t - b.bb_b - b.bb_t)
  30979. },
  30980. na = function(a, b, c) {
  30981. if (null == a) return b;
  30982. if (a.isLeaf) return c.makeNode(b, a);
  30983. var d =
  30984. a.B.bbArea() + Ua(a.A, b),
  30985. e = a.A.bbArea() + Ua(a.B, b);
  30986. d === e && (d = Va(a.A, b), e = Va(a.B, b));
  30987. e < d ? a.setB(na(a.B, b, c)) : a.setA(na(a.A, b, c));
  30988. a.bb_l = f(a.bb_l, b.bb_l);
  30989. a.bb_b = f(a.bb_b, b.bb_b);
  30990. a.bb_r = g(a.bb_r, b.bb_r);
  30991. a.bb_t = g(a.bb_t, b.bb_t);
  30992. return a
  30993. };
  30994. ba.prototype.intersectsBB = ca.prototype.intersectsBB = function(a) {
  30995. return this.bb_l <= a.r && a.l <= this.bb_r && this.bb_b <= a.t && a.b <= this.bb_t
  30996. };
  30997. var Fa = function(a, b, c) {
  30998. a.intersectsBB(b) && (a.isLeaf ? c(a.obj) : (Fa(a.A, b, c), Fa(a.B, b, c)))
  30999. },
  31000. Wa = function(a, b, c) {
  31001. var d = 1 / (c.x - b.x),
  31002. e = a.bb_l ==
  31003. b.x ? -Infinity : (a.bb_l - b.x) * d,
  31004. h = a.bb_r == b.x ? Infinity : (a.bb_r - b.x) * d,
  31005. d = f(e, h),
  31006. e = g(e, h),
  31007. h = 1 / (c.y - b.y);
  31008. c = a.bb_b == b.y ? -Infinity : (a.bb_b - b.y) * h;
  31009. b = a.bb_t == b.y ? Infinity : (a.bb_t - b.y) * h;
  31010. a = f(c, b);
  31011. b = g(c, b);
  31012. return a <= e && d <= b && (d = g(d, a), 0 <= f(e, b) && 1 >= d) ? g(d, 0) : Infinity
  31013. },
  31014. oa = function(a, b, c, d, e) {
  31015. if (a.isLeaf) return e(a.obj);
  31016. var g = Wa(a.A, b, c),
  31017. h = Wa(a.B, b, c);
  31018. g < h ? (g < d && (d = f(d, oa(a.A, b, c, d, e))), h < d && (d = f(d, oa(a.B, b, c, d, e)))) : (h < d && (d = f(d, oa(a.B, b, c, d, e))), g < d && (d = f(d, oa(a.A, b, c, d, e))));
  31019. return d
  31020. };
  31021. O.prototype.subtreeRecycle =
  31022. function(a) {
  31023. a.isLeaf && (this.subtreeRecycle(a.A), this.subtreeRecycle(a.B), a.recycle(this))
  31024. };
  31025. var Ya = function(a, b, c) {
  31026. if (b == a) return null;
  31027. var d = b.parent;
  31028. if (d == a) return b = a.otherChild(b), b.parent = a.parent, a.recycle(c), b;
  31029. d.parent.replaceChild(d, d.otherChild(b), c);
  31030. return a
  31031. },
  31032. Za = function(a, b) {
  31033. return a.bb_l <= b.bb_r && b.bb_l <= a.bb_r && a.bb_b <= b.bb_t && b.bb_b <= a.bb_t
  31034. };
  31035. ca.prototype.markLeafQuery = function(a, b, c, d) {
  31036. Za(a, this) && (b ? Ta(a, this, c) : (this.stamp < a.stamp && Ta(this, a, c), d && d(a.obj, this.obj)))
  31037. };
  31038. ba.prototype.markLeafQuery =
  31039. function(a, b, c, d) {
  31040. Za(a, this) && (this.A.markLeafQuery(a, b, c, d), this.B.markLeafQuery(a, b, c, d))
  31041. };
  31042. ca.prototype.markSubtree = function(a, b, c) {
  31043. if (this.stamp == a.getStamp())
  31044. for (b && b.markLeafQuery(this, !1, a, c), b = this; b.parent; b = b.parent) b == b.parent.A ? b.parent.B.markLeafQuery(this, !0, a, c) : b.parent.A.markLeafQuery(this, !1, a, c);
  31045. else
  31046. for (a = this.pairs; a;) this === a.leafB ? (c && c(a.leafA.obj, this.obj), a = a.nextB) : a = a.nextA
  31047. };
  31048. ba.prototype.markSubtree = function(a, b, c) {
  31049. this.A.markSubtree(a, b, c);
  31050. this.B.markSubtree(a, b, c)
  31051. };
  31052. ca.prototype.containsObj =
  31053. function(a) {
  31054. return this.bb_l <= a.bb_l && this.bb_r >= a.bb_r && this.bb_b <= a.bb_b && this.bb_t >= a.bb_t
  31055. };
  31056. ca.prototype.update = function(a) {
  31057. var b = a.root;
  31058. return this.containsObj(this.obj) ? !1 : (a.getBB(this.obj, this), b = Ya(b, this, a), a.root = na(b, this, a), this.clearPairs(a), this.stamp = a.getStamp(), !0)
  31059. };
  31060. ca.prototype.addPairs = function(a) {
  31061. var b = a.dynamicIndex;
  31062. b ? (a = b.root) && a.markLeafQuery(this, !0, b, null) : this.markSubtree(a, a.staticIndex.root, null)
  31063. };
  31064. O.prototype.insert = function(a, b) {
  31065. var c = new ca(this, a);
  31066. this.leaves[b] = c;
  31067. this.root = na(this.root, c, this);
  31068. this.count++;
  31069. c.stamp = this.getStamp();
  31070. c.addPairs(this);
  31071. this.incrementStamp()
  31072. };
  31073. O.prototype.remove = function(a, b) {
  31074. var c = this.leaves[b];
  31075. delete this.leaves[b];
  31076. this.root = Ya(this.root, c, this);
  31077. this.count--;
  31078. c.clearPairs(this);
  31079. c.recycle(this)
  31080. };
  31081. O.prototype.contains = function(a, b) {
  31082. return null != this.leaves[b]
  31083. };
  31084. var ob = function(a, b) {};
  31085. O.prototype.reindexQuery = function(a) {
  31086. if (this.root) {
  31087. var b, c = this.leaves;
  31088. for (b in c) c[b].update(this);
  31089. c = (b = this.staticIndex) && b.root;
  31090. this.root.markSubtree(this,
  31091. c, a);
  31092. b && !c && this.collideStatic(this, b, a);
  31093. this.incrementStamp()
  31094. }
  31095. };
  31096. O.prototype.reindex = function() {
  31097. this.reindexQuery(ob)
  31098. };
  31099. O.prototype.reindexObject = function(a, b) {
  31100. var c = this.leaves[b];
  31101. c && (c.update(this) && c.addPairs(this), this.incrementStamp())
  31102. };
  31103. O.prototype.pointQuery = function(a, b) {
  31104. this.query(new X(a.x, a.y, a.x, a.y), b)
  31105. };
  31106. O.prototype.segmentQuery = function(a, b, c, d) {
  31107. this.root && oa(this.root, a, b, c, d)
  31108. };
  31109. O.prototype.query = function(a, b) {
  31110. this.root && Fa(this.root, a, b)
  31111. };
  31112. O.prototype.count = function() {
  31113. return this.count
  31114. };
  31115. O.prototype.each = function(a) {
  31116. for (var b in this.leaves) a(this.leaves[b].obj)
  31117. };
  31118. var $a = function(a, b, c, d, e) {
  31119. return (g(a.bb_r, d) - f(a.bb_l, b)) * (g(a.bb_t, e) - f(a.bb_b, c))
  31120. },
  31121. Ja = function(a, b, c, d) {
  31122. if (1 == d) return b[c];
  31123. if (2 == d) return a.makeNode(b[c], b[c + 1]);
  31124. for (var e = b[c], h = e.bb_l, k = e.bb_b, m = e.bb_r, n = e.bb_t, p = c + d, r = c + 1; r < p; r++) e = b[r], h = f(h, e.bb_l), k = f(k, e.bb_b), m = g(m, e.bb_r), n = g(n, e.bb_t);
  31125. var e = m - h > n - k,
  31126. s = Array(2 * d);
  31127. if (e)
  31128. for (r = c; r < p; r++) s[2 * r + 0] = b[r].bb_l, s[2 * r + 1] = b[r].bb_r;
  31129. else
  31130. for (r = c; r < p; r++) s[2 * r + 0] = b[r].bb_b,
  31131. s[2 * r + 1] = b[r].bb_t;
  31132. s.sort(function(a, b) {
  31133. return a - b
  31134. });
  31135. var t = 0.5 * (s[d - 1] + s[d]),
  31136. r = h,
  31137. s = k,
  31138. u = m,
  31139. v = n;
  31140. e ? u = h = t : v = k = t;
  31141. for (var t = p, w = c; w < t;) e = b[w], $a(e, h, k, m, n) < $a(e, r, s, u, v) ? (t--, b[w] = b[t], b[t] = e) : w++;
  31142. if (t == d) {
  31143. e = null;
  31144. for (r = c; r < p; r++) e = na(e, b[r], a);
  31145. return e
  31146. }
  31147. return NodeNew(a, Ja(a, b, c, t - c), Ja(a, b, t, p - t))
  31148. };
  31149. O.prototype.optimize = function() {
  31150. var a = Array(this.count),
  31151. b = 0,
  31152. c;
  31153. for (c in this.leaves) a[b++] = this.nodes[c];
  31154. tree.subtreeRecycle(root);
  31155. this.root = Ja(tree, a, a.length)
  31156. };
  31157. var Ka = function(a, b) {
  31158. !a.isLeaf && 10 >= b && (Ka(a.A,
  31159. b + 1), Ka(a.B, b + 1));
  31160. for (var c = "", d = 0; d < b; d++) c += " ";
  31161. console.log(c + a.bb_b + " " + a.bb_t)
  31162. };
  31163. O.prototype.log = function() {
  31164. this.root && Ka(this.root, 0)
  31165. };
  31166. var ja = a.CollisionHandler = function() {
  31167. this.a = this.b = 0
  31168. };
  31169. ja.prototype.begin = function(a, b) {
  31170. return !0
  31171. };
  31172. ja.prototype.preSolve = function(a, b) {
  31173. return !0
  31174. };
  31175. ja.prototype.postSolve = function(a, b) {};
  31176. ja.prototype.separate = function(a, b) {};
  31177. var Q = function(a, b) {
  31178. this.u = this.e = 0;
  31179. this.surface_vr = v;
  31180. this.a = a;
  31181. this.body_a = a.body;
  31182. this.b = b;
  31183. this.body_b = b.body;
  31184. this.contacts = this.thread_b_next =
  31185. this.thread_b_prev = this.thread_a_next = this.thread_a_prev = null;
  31186. this.stamp = 0;
  31187. this.handler = null;
  31188. this.swappedColl = !1;
  31189. this.state = "first coll"
  31190. };
  31191. Q.prototype.getShapes = function() {
  31192. return this.swappedColl ? [this.b, this.a] : [this.a, this.b]
  31193. };
  31194. Q.prototype.totalImpulse = function() {
  31195. for (var a = this.contacts, b = new s(0, 0), c = 0, d = a.length; c < d; c++) {
  31196. var e = a[c];
  31197. b.add(y(e.n, e.jnAcc))
  31198. }
  31199. return this.swappedColl ? b : b.neg()
  31200. };
  31201. Q.prototype.totalImpulseWithFriction = function() {
  31202. for (var a = this.contacts, b = new s(0, 0), c = 0, d = a.length; c < d; c++) {
  31203. var e =
  31204. a[c];
  31205. b.add((new s(e.jnAcc, e.jtAcc)).rotate(e.n))
  31206. }
  31207. return this.swappedColl ? b : b.neg()
  31208. };
  31209. Q.prototype.totalKE = function() {
  31210. for (var a = (1 - this.e) / (1 + this.e), b = 0, c = this.contacts, d = 0, e = c.length; d < e; d++) var f = c[d],
  31211. g = f.jnAcc,
  31212. h = f.jtAcc,
  31213. b = b + (a * g * g / f.nMass + h * h / f.tMass);
  31214. return b
  31215. };
  31216. Q.prototype.ignore = function() {
  31217. this.state = "ignore"
  31218. };
  31219. Q.prototype.getA = function() {
  31220. return this.swappedColl ? this.b : this.a
  31221. };
  31222. Q.prototype.getB = function() {
  31223. return this.swappedColl ? this.a : this.b
  31224. };
  31225. Q.prototype.isFirstContact = function() {
  31226. return "first coll" ===
  31227. this.state
  31228. };
  31229. var ab = function(a, b, c) {
  31230. this.point = a;
  31231. this.normal = b;
  31232. this.dist = c
  31233. };
  31234. Q.prototype.getContactPointSet = function() {
  31235. var a = Array(this.contacts.length),
  31236. b;
  31237. for (b = 0; b < a.length; b++) a[b] = new ab(this.contacts[b].p, this.contacts[b].n, this.contacts[b].dist);
  31238. return a
  31239. };
  31240. Q.prototype.getNormal = function(a) {
  31241. a = this.contacts[a].n;
  31242. return this.swappedColl ? B(a) : a
  31243. };
  31244. Q.prototype.getPoint = function(a) {
  31245. return this.contacts[a].p
  31246. };
  31247. Q.prototype.getDepth = function(a) {
  31248. return this.contacts[a].dist
  31249. };
  31250. var bb = function(a, b, c, d) {
  31251. c ? c.body_a ===
  31252. b ? c.thread_a_next = d : c.thread_b_next = d : b.arbiterList = d;
  31253. d && (d.body_a === b ? d.thread_a_prev = c : d.thread_b_prev = c)
  31254. };
  31255. Q.prototype.unthread = function() {
  31256. bb(this, this.body_a, this.thread_a_prev, this.thread_a_next);
  31257. bb(this, this.body_b, this.thread_b_prev, this.thread_b_next);
  31258. this.thread_b_prev = this.thread_b_next = this.thread_a_prev = this.thread_a_next = null
  31259. };
  31260. Q.prototype.update = function(a, b, c, d) {
  31261. if (this.contacts)
  31262. for (var e = 0; e < this.contacts.length; e++)
  31263. for (var f = this.contacts[e], g = 0; g < a.length; g++) {
  31264. var h = a[g];
  31265. h.hash ===
  31266. f.hash && (h.jnAcc = f.jnAcc, h.jtAcc = f.jtAcc)
  31267. }
  31268. this.contacts = a;
  31269. this.handler = b;
  31270. this.swappedColl = c.collision_type !== b.a;
  31271. this.e = c.e * d.e;
  31272. this.u = c.u * d.u;
  31273. this.surface_vr = w(c.surface_v, d.surface_v);
  31274. this.a = c;
  31275. this.body_a = c.body;
  31276. this.b = d;
  31277. this.body_b = d.body;
  31278. "cached" == this.state && (this.state = "first coll")
  31279. };
  31280. Q.prototype.preStep = function(a, b, c) {
  31281. for (var d = this.body_a, e = this.body_b, g = 0; g < this.contacts.length; g++) {
  31282. var h = this.contacts[g];
  31283. h.r1 = w(h.p, d.p);
  31284. h.r2 = w(h.p, e.p);
  31285. h.nMass = 1 / pa(d, e, h.r1, h.r2, h.n);
  31286. h.tMass = 1 / pa(d, e, h.r1,
  31287. h.r2, F(h.n));
  31288. h.bias = -c * f(0, h.dist + b) / a;
  31289. h.jBias = 0;
  31290. h.bounce = La(d, e, h.r1, h.r2, h.n) * this.e
  31291. }
  31292. };
  31293. Q.prototype.applyCachedImpulse = function(a) {
  31294. if (!this.isFirstContact())
  31295. for (var b = this.body_a, c = this.body_b, d = 0; d < this.contacts.length; d++) {
  31296. var e = this.contacts[d],
  31297. f = e.n.x,
  31298. g = e.n.y;
  31299. Y(b, c, e.r1, e.r2, (f * e.jnAcc - g * e.jtAcc) * a, (f * e.jtAcc + g * e.jnAcc) * a)
  31300. }
  31301. };
  31302. var pb = 0,
  31303. qb = 0;
  31304. Q.prototype.applyImpulse = function() {
  31305. pb++;
  31306. for (var a = this.body_a, b = this.body_b, c = this.surface_vr, d = this.u, e = 0; e < this.contacts.length; e++) {
  31307. qb++;
  31308. var f = this.contacts[e],
  31309. h = f.nMass,
  31310. k = f.n,
  31311. m = f.r1,
  31312. n = f.r2,
  31313. p = b.vx - n.y * b.w - (a.vx - m.y * a.w),
  31314. s = b.vy + n.x * b.w - (a.vy + m.x * a.w),
  31315. t = p * k.x + s * k.y,
  31316. u = (p + c.x) * -k.y + (s + c.y) * k.x,
  31317. s = f.jBias;
  31318. f.jBias = g(s + (f.bias - (k.x * (b.v_biasx - n.y * b.w_bias - a.v_biasx + m.y * a.w_bias) + k.y * (n.x * b.w_bias + b.v_biasy - m.x * a.w_bias - a.v_biasy))) * h, 0);
  31319. p = f.jnAcc;
  31320. f.jnAcc = g(p + -(f.bounce + t) * h, 0);
  31321. t = d * f.jnAcc;
  31322. h = f.jtAcc;
  31323. f.jtAcc = r(h + -u * f.tMass, -t, t);
  31324. t = k.x * (f.jBias - s);
  31325. s = k.y * (f.jBias - s);
  31326. cb(a, -t, -s, m);
  31327. cb(b, t, s, n);
  31328. p = f.jnAcc - p;
  31329. f = f.jtAcc - h;
  31330. Y(a, b, m, n, k.x * p - k.y * f, k.x * f + k.y * p)
  31331. }
  31332. };
  31333. Q.prototype.callSeparate =
  31334. function(a) {
  31335. a.lookupHandler(this.a.collision_type, this.b.collision_type).separate(this, a)
  31336. };
  31337. Q.prototype.next = function(a) {
  31338. return this.body_a == a ? this.thread_a_next : this.thread_b_next
  31339. };
  31340. var rb = 0,
  31341. ea = function(a, b, c, d) {
  31342. this.p = a;
  31343. this.n = b;
  31344. this.dist = c;
  31345. this.r1 = this.r2 = v;
  31346. this.jnAcc = this.jtAcc = this.jBias = this.nMass = this.tMass = this.bounce = this.bias = 0;
  31347. this.hash = d;
  31348. rb++
  31349. },
  31350. Z = [],
  31351. ga = function(a, b, c, d) {
  31352. d = c + d;
  31353. b = w(b, a);
  31354. var e = L(b);
  31355. if (!(e >= d * d)) return e = Math.sqrt(e), new ea(A(a, y(b, 0.5 + (c - 0.5 * d) / (e ? e : Infinity))), e ? y(b, 1 / e) : new s(1,
  31356. 0), e - d, 0)
  31357. },
  31358. Ma = 0,
  31359. db = function(a, b) {
  31360. var c = 0,
  31361. d = a.valueOnAxis(b[0].n, b[0].d);
  31362. if (0 < d) return -1;
  31363. for (var e = 1; e < b.length; e++) {
  31364. var f = a.valueOnAxis(b[e].n, b[e].d);
  31365. if (0 < f) return -1;
  31366. f > d && (d = f, c = e)
  31367. }
  31368. Ma = d;
  31369. return c
  31370. },
  31371. eb = function(a, b, c, d) {
  31372. for (var e = [], f = a.tVerts, g = 0; g < f.length; g += 2) {
  31373. var k = f[g],
  31374. m = f[g + 1];
  31375. b.containsVert(k, m) && e.push(new ea(new s(k, m), c, d, h(a.hashid, g >> 1)))
  31376. }
  31377. f = b.tVerts;
  31378. for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], a.containsVert(k, m) && e.push(new ea(new s(k, m), c, d, h(b.hashid, g >> 1)));
  31379. if (!e.length) {
  31380. e = [];
  31381. f = a.tVerts;
  31382. for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], b.containsVertPartial(k, m, B(c)) && e.push(new ea(new s(k, m), c, d, h(a.hashid, g)));
  31383. f = b.tVerts;
  31384. for (g = 0; g < f.length; g += 2) k = f[g], m = f[g + 1], a.containsVertPartial(k, m, c) && e.push(new ea(new s(k, m), c, d, h(b.hashid, g)))
  31385. }
  31386. return a = e
  31387. },
  31388. fb = function(a, b, c) {
  31389. var d = x(b, a.ta) - a.r;
  31390. a = x(b, a.tb) - a.r;
  31391. return f(d, a) - c
  31392. },
  31393. gb = function(a, b, c, d, e) {
  31394. for (var f = z(b.tn, b.ta), g = z(b.tn, b.tb), k = y(b.tn, e), m = c.tVerts, n = 0; n < m.length; n += 2) {
  31395. var p = m[n],
  31396. r = m[n + 1];
  31397. if (p * k.x + r * k.y < x(b.tn, b.ta) * e + b.r) {
  31398. var t = b.tn.x *
  31399. r - b.tn.y * p;
  31400. f >= t && t >= g && a.push(new ea(new s(p, r), k, d, h(c.hashid, n)))
  31401. }
  31402. }
  31403. };
  31404. ka.prototype.collisionCode = 0;
  31405. fa.prototype.collisionCode = 1;
  31406. W.prototype.collisionCode = 2;
  31407. ka.prototype.collisionTable = [
  31408. function(a, b) {
  31409. var c = ga(a.tc, b.tc, a.r, b.r);
  31410. return c ? [c] : Z
  31411. },
  31412. function(a, b) {
  31413. var c = b.ta,
  31414. d = a.tc,
  31415. e = w(b.tb, c),
  31416. f = u(x(e, w(d, c)) / L(e)),
  31417. c = A(c, y(e, f));
  31418. return (d = ga(d, c, a.r, b.r)) ? (c = d.n, 0 === f && 0 > x(c, b.a_tangent) || 1 === f && 0 > x(c, b.b_tangent) ? Z : [d]) : Z
  31419. },
  31420. function(a, b) {
  31421. for (var c = b.tPlanes, d = 0, e = x(c[0].n, a.tc) - c[0].d - a.r, f = 0; f < c.length; f++) {
  31422. var g =
  31423. x(c[f].n, a.tc) - c[f].d - a.r;
  31424. if (0 < g) return Z;
  31425. g > e && (e = g, d = f)
  31426. }
  31427. var c = c[d].n,
  31428. h = b.tVerts,
  31429. k = h.length,
  31430. m = d << 1,
  31431. d = h[m],
  31432. f = h[m + 1],
  31433. g = h[(m + 2) % k],
  31434. h = h[(m + 3) % k],
  31435. k = c.x * f - c.y * d,
  31436. m = c.x * h - c.y * g,
  31437. n = z(c, a.tc);
  31438. if (n < m) {
  31439. var p = ga(a.tc, new s(g, h), a.r, 0, p);
  31440. return p ? [p] : Z
  31441. }
  31442. return n < k ? [new ea(w(a.tc, y(c, a.r + e / 2)), B(c), e, 0)] : (p = ga(a.tc, new s(d, f), a.r, 0, p)) ? [p] : Z
  31443. }
  31444. ];
  31445. fa.prototype.collisionTable = [null,
  31446. function(a, b) {
  31447. return Z
  31448. },
  31449. function(a, b) {
  31450. var c = [],
  31451. d = b.tPlanes,
  31452. e = d.length,
  31453. f = x(a.tn, a.ta),
  31454. g = b.valueOnAxis(a.tn, f) - a.r,
  31455. f = b.valueOnAxis(B(a.tn), -f) -
  31456. a.r;
  31457. if (0 < f || 0 < g) return Z;
  31458. var k = 0,
  31459. m = fb(a, d[0].n, d[0].d);
  31460. if (0 < m) return Z;
  31461. for (var n = 0; n < e; n++) {
  31462. var p = fb(a, d[n].n, d[n].d);
  31463. if (0 < p) return Z;
  31464. p > m && (m = p, k = n)
  31465. }
  31466. d = B(d[k].n);
  31467. n = A(a.ta, y(d, a.r));
  31468. p = A(a.tb, y(d, a.r));
  31469. b.containsVert(n.x, n.y) && c.push(new ea(n, d, m, h(a.hashid, 0)));
  31470. b.containsVert(p.x, p.y) && c.push(new ea(p, d, m, h(a.hashid, 1)));
  31471. if (g >= m || f >= m) g > f ? gb(c, a, b, g, 1) : gb(c, a, b, f, -1);
  31472. if (0 === c.length) {
  31473. g = 2 * k;
  31474. f = b.tVerts;
  31475. m = new s(f[g], f[g + 1]);
  31476. if ((k = ga(a.ta, m, a.r, 0, c)) || (k = ga(a.tb, m, a.r, 0, c))) return [k];
  31477. e *= 2;
  31478. e = new s(f[(g +
  31479. 2) % e], f[(g + 3) % e]);
  31480. if ((k = ga(a.ta, e, a.r, 0, c)) || (k = ga(a.tb, e, a.r, 0, c))) return [k]
  31481. }
  31482. return c
  31483. }
  31484. ];
  31485. W.prototype.collisionTable = [null, null,
  31486. function(a, b) {
  31487. var c = db(b, a.tPlanes);
  31488. if (-1 == c) return Z;
  31489. var d = Ma,
  31490. e = db(a, b.tPlanes);
  31491. if (-1 == e) return Z;
  31492. var f = Ma;
  31493. return d > f ? eb(a, b, a.tPlanes[c].n, d) : eb(a, b, B(b.tPlanes[e].n), f)
  31494. }
  31495. ];
  31496. var Na = a.collideShapes = function(a, c) {
  31497. b(a.collisionCode <= c.collisionCode, "Collided shapes must be sorted by type");
  31498. return a.collisionTable[c.collisionCode](a, c)
  31499. },
  31500. hb = new ja,
  31501. G = a.Space = function() {
  31502. this.curr_dt =
  31503. this.stamp = 0;
  31504. this.bodies = [];
  31505. this.rousedBodies = [];
  31506. this.sleepingComponents = [];
  31507. this.staticShapes = new O(null);
  31508. this.activeShapes = new O(this.staticShapes);
  31509. this.arbiters = [];
  31510. this.contactBuffersHead = null;
  31511. this.cachedArbiters = {};
  31512. this.constraints = [];
  31513. this.locked = 0;
  31514. this.collisionHandlers = {};
  31515. this.defaultHandler = hb;
  31516. this.postStepCallbacks = [];
  31517. this.iterations = 10;
  31518. this.gravity = v;
  31519. this.damping = 1;
  31520. this.idleSpeedThreshold = 0;
  31521. this.sleepTimeThreshold = Infinity;
  31522. this.collisionSlop = 0.1;
  31523. this.collisionBias = Math.pow(0.9, 60);
  31524. this.collisionPersistence =
  31525. 3;
  31526. this.enableContactGraph = !1;
  31527. this.staticBody = new H(Infinity, Infinity);
  31528. this.staticBody.nodeIdleTime = Infinity;
  31529. this.collideShapes = this.makeCollideShapes()
  31530. };
  31531. G.prototype.getCurrentTimeStep = function() {
  31532. return this.curr_dt
  31533. };
  31534. G.prototype.setIterations = function(a) {
  31535. this.iterations = a
  31536. };
  31537. G.prototype.isLocked = function() {
  31538. return this.locked
  31539. };
  31540. var da = function(a) {
  31541. b(!a.locked, "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. Put these calls into a post-step callback.")
  31542. };
  31543. G.prototype.addCollisionHandler =
  31544. function(a, b, c, d, e, f) {
  31545. da(this);
  31546. this.removeCollisionHandler(a, b);
  31547. var g = new ja;
  31548. g.a = a;
  31549. g.b = b;
  31550. c && (g.begin = c);
  31551. d && (g.preSolve = d);
  31552. e && (g.postSolve = e);
  31553. f && (g.separate = f);
  31554. this.collisionHandlers[h(a, b)] = g
  31555. };
  31556. G.prototype.removeCollisionHandler = function(a, b) {
  31557. da(this);
  31558. delete this.collisionHandlers[h(a, b)]
  31559. };
  31560. G.prototype.setDefaultCollisionHandler = function(a, b, c, d) {
  31561. da(this);
  31562. var e = new ja;
  31563. a && (e.begin = a);
  31564. b && (e.preSolve = b);
  31565. c && (e.postSolve = c);
  31566. d && (e.separate = d);
  31567. this.defaultHandler = e
  31568. };
  31569. G.prototype.lookupHandler = function(a, b) {
  31570. return this.collisionHandlers[h(a,
  31571. b)] || this.defaultHandler
  31572. };
  31573. G.prototype.addShape = function(a) {
  31574. var c = a.body;
  31575. if (c.isStatic()) return this.addStaticShape(a);
  31576. b(!a.space, "This shape is already added to a space and cannot be added to another.");
  31577. da(this);
  31578. c.activate();
  31579. c.addShape(a);
  31580. a.update(c.p, c.rot);
  31581. this.activeShapes.insert(a, a.hashid);
  31582. a.space = this;
  31583. return a
  31584. };
  31585. G.prototype.addStaticShape = function(a) {
  31586. b(!a.space, "This shape is already added to a space and cannot be added to another.");
  31587. da(this);
  31588. var c = a.body;
  31589. c.addShape(a);
  31590. a.update(c.p, c.rot);
  31591. this.staticShapes.insert(a,
  31592. a.hashid);
  31593. a.space = this;
  31594. return a
  31595. };
  31596. G.prototype.addBody = function(a) {
  31597. b(!a.isStatic(), "Static bodies cannot be added to a space as they are not meant to be simulated.");
  31598. b(!a.space, "This body is already added to a space and cannot be added to another.");
  31599. da(this);
  31600. this.bodies.push(a);
  31601. a.space = this;
  31602. return a
  31603. };
  31604. G.prototype.addConstraint = function(a) {
  31605. b(!a.space, "This shape is already added to a space and cannot be added to another.");
  31606. da(this);
  31607. var c = a.a,
  31608. d = a.b;
  31609. c.activate();
  31610. d.activate();
  31611. this.constraints.push(a);
  31612. a.next_a =
  31613. c.constraintList;
  31614. c.constraintList = a;
  31615. a.next_b = d.constraintList;
  31616. d.constraintList = a;
  31617. a.space = this;
  31618. return a
  31619. };
  31620. G.prototype.filterArbiters = function(a, b) {
  31621. for (var c in this.cachedArbiters) {
  31622. var d = this.cachedArbiters[c];
  31623. if (a === d.body_a && (b === d.a || null === b) || a === d.body_b && (b === d.b || null === b)) b && "cached" !== d.state && d.callSeparate(this), d.unthread(), k(this.arbiters, d), delete this.cachedArbiters[c]
  31624. }
  31625. };
  31626. G.prototype.removeShape = function(a) {
  31627. var c = a.body;
  31628. c.isStatic() ? this.removeStaticShape(a) : (b(this.containsShape(a),
  31629. "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"), da(this), c.activate(), c.removeShape(a), this.filterArbiters(c, a), this.activeShapes.remove(a, a.hashid), a.space = null)
  31630. };
  31631. G.prototype.removeStaticShape = function(a) {
  31632. b(this.containsShape(a), "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)");
  31633. da(this);
  31634. var c = a.body;
  31635. c.isStatic() && c.activateStatic(a);
  31636. c.removeShape(a);
  31637. this.filterArbiters(c, a);
  31638. this.staticShapes.remove(a, a.hashid);
  31639. a.space =
  31640. null
  31641. };
  31642. G.prototype.removeBody = function(a) {
  31643. b(this.containsBody(a), "Cannot remove a body that was not added to the space. (Removed twice maybe?)");
  31644. da(this);
  31645. a.activate();
  31646. k(this.bodies, a);
  31647. a.space = null
  31648. };
  31649. G.prototype.removeConstraint = function(a) {
  31650. b(this.containsConstraint(a), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)");
  31651. da(this);
  31652. a.a.activate();
  31653. a.b.activate();
  31654. k(this.constraints, a);
  31655. a.a.removeConstraint(a);
  31656. a.b.removeConstraint(a);
  31657. a.space = null
  31658. };
  31659. G.prototype.containsShape =
  31660. function(a) {
  31661. return a.space === this
  31662. };
  31663. G.prototype.containsBody = function(a) {
  31664. return a.space == this
  31665. };
  31666. G.prototype.containsConstraint = function(a) {
  31667. return a.space == this
  31668. };
  31669. G.prototype.uncacheArbiter = function(a) {
  31670. delete this.cachedArbiters[h(a.a.hashid, a.b.hashid)];
  31671. k(this.arbiters, a)
  31672. };
  31673. G.prototype.eachBody = function(a) {
  31674. this.lock();
  31675. for (var b = this.bodies, c = 0; c < b.length; c++) a(b[c]);
  31676. b = this.sleepingComponents;
  31677. for (c = 0; c < b.length; c++)
  31678. for (var d = b[c]; d;) {
  31679. var e = d.nodeNext;
  31680. a(d);
  31681. d = e
  31682. }
  31683. this.unlock(!0)
  31684. };
  31685. G.prototype.eachShape = function(a) {
  31686. this.lock();
  31687. this.activeShapes.each(a);
  31688. this.staticShapes.each(a);
  31689. this.unlock(!0)
  31690. };
  31691. G.prototype.eachConstraint = function(a) {
  31692. this.lock();
  31693. for (var b = this.constraints, c = 0; c < b.length; c++) a(b[c]);
  31694. this.unlock(!0)
  31695. };
  31696. G.prototype.reindexStatic = function() {
  31697. b(!this.locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");
  31698. this.staticShapes.each(function(a) {
  31699. var b = a.body;
  31700. a.update(b.p, b.rot)
  31701. });
  31702. this.staticShapes.reindex()
  31703. };
  31704. G.prototype.reindexShape = function(a) {
  31705. b(!this.locked,
  31706. "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete.");
  31707. var c = a.body;
  31708. a.update(c.p, c.rot);
  31709. this.activeShapes.reindexObject(a, a.hashid);
  31710. this.staticShapes.reindexObject(a, a.hashid)
  31711. };
  31712. G.prototype.reindexShapesForBody = function(a) {
  31713. for (a = a.shapeList; a; a = a.next) this.reindexShape(a)
  31714. };
  31715. G.prototype.useSpatialHash = function(a, b) {
  31716. throw Error("Spatial Hash not implemented.");
  31717. };
  31718. G.prototype.activateBody = function(a) {
  31719. b(!a.isRogue(), "Internal error: Attempting to activate a rogue body.");
  31720. if (this.locked) - 1 === this.rousedBodies.indexOf(a) && this.rousedBodies.push(a);
  31721. else {
  31722. this.bodies.push(a);
  31723. for (var c = 0; c < a.shapeList.length; c++) {
  31724. var d = a.shapeList[c];
  31725. this.staticShapes.remove(d, d.hashid);
  31726. this.activeShapes.insert(d, d.hashid)
  31727. }
  31728. for (c = a.arbiterList; c; c = c.next(a))
  31729. if (d = c.body_a, a === d || d.isStatic()) {
  31730. var d = c.a,
  31731. e = c.b;
  31732. this.cachedArbiters[h(d.hashid, e.hashid)] = c;
  31733. c.stamp = this.stamp;
  31734. c.handler = this.lookupHandler(d.collision_type, e.collision_type);
  31735. this.arbiters.push(c)
  31736. }
  31737. for (c = a.constraintList; c; c = c.nodeNext) d =
  31738. c.a, (a === d || d.isStatic()) && this.constraints.push(c)
  31739. }
  31740. };
  31741. G.prototype.deactivateBody = function(a) {
  31742. b(!a.isRogue(), "Internal error: Attempting to deactivate a rogue body.");
  31743. k(this.bodies, a);
  31744. for (var c = 0; c < a.shapeList.length; c++) {
  31745. var d = a.shapeList[c];
  31746. this.activeShapes.remove(d, d.hashid);
  31747. this.staticShapes.insert(d, d.hashid)
  31748. }
  31749. for (d = a.arbiterList; d; d = d.next(a)) c = d.body_a, (a === c || c.isStatic()) && this.uncacheArbiter(d);
  31750. for (d = a.constraintList; d; d = d.nodeNext) c = d.a, (a === c || c.isStatic()) && k(this.constraints, d)
  31751. };
  31752. H.prototype.activate =
  31753. function() {
  31754. if (!this.isRogue()) {
  31755. this.nodeIdleTime = 0;
  31756. var a = this ? this.nodeRoot : null;
  31757. if (a && a.isSleeping(a)) {
  31758. b(!a.isRogue(), "Internal Error: componentActivate() called on a rogue body.");
  31759. for (var c = a.space, d = a; d;) {
  31760. var e = d.nodeNext;
  31761. d.nodeIdleTime = 0;
  31762. d.nodeRoot = null;
  31763. d.nodeNext = null;
  31764. c.activateBody(d);
  31765. d = e
  31766. }
  31767. k(c.sleepingComponents, a)
  31768. }
  31769. }
  31770. };
  31771. H.prototype.activateStatic = function(a) {
  31772. b(this.isStatic(), "Body.activateStatic() called on a non-static body.");
  31773. for (var c = this.arbiterList; c; c = c.next(this)) a && a != c.a && a != c.b || (c.body_a ==
  31774. this ? c.body_b : c.body_a).activate()
  31775. };
  31776. H.prototype.pushArbiter = function(a) {
  31777. c(null === (a.body_a === this ? a.thread_a_next : a.thread_b_next), "Internal Error: Dangling contact graph pointers detected. (A)");
  31778. c(null === (a.body_a === this ? a.thread_a_prev : a.thread_b_prev), "Internal Error: Dangling contact graph pointers detected. (B)");
  31779. var b = this.arbiterList;
  31780. c(null === b || null === (b.body_a === this ? b.thread_a_prev : b.thread_b_prev), "Internal Error: Dangling contact graph pointers detected. (C)");
  31781. a.body_a === this ? a.thread_a_next =
  31782. b : a.thread_b_next = b;
  31783. b && (b.body_a === this ? b.thread_a_prev = a : b.thread_b_prev = a);
  31784. this.arbiterList = a
  31785. };
  31786. var Oa = function(a, b) {
  31787. if (!b.isRogue()) {
  31788. var d = b ? b.nodeRoot : null;
  31789. if (null == d) {
  31790. b.nodeRoot = a;
  31791. b !== a && (b.nodeNext = a.nodeNext, a.nodeNext = b);
  31792. for (d = b.arbiterList; d; d = d.next(b)) Oa(a, b == d.body_a ? d.body_b : d.body_a);
  31793. for (d = b.constraintList; d; d = d.next(b)) Oa(a, b == d.a ? d.b : d.a)
  31794. } else c(d === a, "Internal Error: Inconsistency detected in the contact graph.")
  31795. }
  31796. };
  31797. G.prototype.processComponents = function(a) {
  31798. for (var b = Infinity !== this.sleepTimeThreshold,
  31799. d = this.bodies, e = 0; e < d.length; e++) {
  31800. var f = d[e];
  31801. c(null === f.nodeNext, "Internal Error: Dangling next pointer detected in contact graph.");
  31802. c(null === f.nodeRoot, "Internal Error: Dangling root pointer detected in contact graph.")
  31803. }
  31804. if (b)
  31805. for (var g = (e = this.idleSpeedThreshold) ? e * e : L(this.gravity) * a * a, e = 0; e < d.length; e++) {
  31806. var f = d[e],
  31807. h = g ? f.m * g : 0;
  31808. f.nodeIdleTime = f.kineticEnergy() > h ? 0 : f.nodeIdleTime + a
  31809. }
  31810. g = this.arbiters;
  31811. e = 0;
  31812. for (h = g.length; e < h; e++) {
  31813. var k = g[e],
  31814. f = k.body_a;
  31815. a = k.body_b;
  31816. b && ((a.isRogue() && !a.isStatic() || f.isSleeping()) &&
  31817. f.activate(), (f.isRogue() && !f.isStatic() || a.isSleeping()) && a.activate());
  31818. f.pushArbiter(k);
  31819. a.pushArbiter(k)
  31820. }
  31821. if (b) {
  31822. b = this.constraints;
  31823. for (e = 0; e < b.length; e++) a = b[e], f = a.a, a = a.b, a.isRogue() && !a.isStatic() && f.activate(), f.isRogue() && !f.isStatic() && a.activate();
  31824. for (e = 0; e < d.length;) {
  31825. f = d[e];
  31826. if (null === (f ? f.nodeRoot : null)) {
  31827. Oa(f, f);
  31828. a: {
  31829. for (b = f; b; b = b.nodeNext)
  31830. if (b.nodeIdleTime < this.sleepTimeThreshold) {
  31831. b = !0;
  31832. break a
  31833. }
  31834. b = !1
  31835. }
  31836. if (!b) {
  31837. this.sleepingComponents.push(f);
  31838. for (b = f; b; b = b.nodeNext) this.deactivateBody(b);
  31839. continue
  31840. }
  31841. }
  31842. e++;
  31843. f.nodeRoot = null;
  31844. f.nodeNext = null
  31845. }
  31846. }
  31847. };
  31848. H.prototype.sleep = function() {
  31849. this.sleepWithGroup(null)
  31850. };
  31851. H.prototype.sleepWithGroup = function(a) {
  31852. b(!this.isStatic() && !this.isRogue(), "Rogue and static bodies cannot be put to sleep.");
  31853. var c = this.space;
  31854. b(c, "Cannot put a rogue body to sleep.");
  31855. b(!c.locked, "Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback.");
  31856. b(null === a || a.isSleeping(), "Cannot use a non-sleeping body as a group identifier.");
  31857. if (this.isSleeping()) b((this ?
  31858. this.nodeRoot : null) === (a ? a.nodeRoot : null), "The body is already sleeping and it's group cannot be reassigned.");
  31859. else {
  31860. for (var d = 0; d < this.shapeList.length; d++) this.shapeList[d].update(this.p, this.rot);
  31861. c.deactivateBody(this);
  31862. a ? (this.nodeRoot = a = a ? a.nodeRoot : null, this.nodeNext = a.nodeNext, this.nodeIdleTime = 0, a.nodeNext = this) : (this.nodeRoot = this, this.nodeNext = null, this.nodeIdleTime = 0, c.sleepingComponents.push(this));
  31863. k(c.bodies, this)
  31864. }
  31865. };
  31866. G.prototype.activateShapesTouchingShape = function(a) {
  31867. Infinity !== this.sleepTimeThreshold &&
  31868. this.shapeQuery(a, function(a, b) {
  31869. a.body.activate()
  31870. })
  31871. };
  31872. G.prototype.pointQuery = function(a, b, c, d) {
  31873. var e = function(e) {
  31874. (!e.group || c !== e.group) && b & e.layers && e.pointQuery(a) && d(e)
  31875. },
  31876. f = new X(a.x, a.y, a.x, a.y);
  31877. this.lock();
  31878. this.activeShapes.query(f, e);
  31879. this.staticShapes.query(f, e);
  31880. this.unlock(!0)
  31881. };
  31882. G.prototype.pointQueryFirst = function(a, b, c) {
  31883. var d = null;
  31884. this.pointQuery(a, b, c, function(a) {
  31885. a.sensor || (d = a)
  31886. });
  31887. return d
  31888. };
  31889. G.prototype.nearestPointQuery = function(a, b, c, d, e) {
  31890. var f = function(f) {
  31891. if ((!f.group || d !== f.group) && c & f.layers) {
  31892. var g =
  31893. f.nearestPointQuery(a);
  31894. g.d < b && e(f, g.d, g.p)
  31895. }
  31896. },
  31897. g = xa(a, b);
  31898. this.lock();
  31899. this.activeShapes.query(g, f);
  31900. this.staticShapes.query(g, f);
  31901. this.unlock(!0)
  31902. };
  31903. G.prototype.nearestPointQueryNearest = function(a, b, c, d) {
  31904. var e, f = function(f) {
  31905. f.group && d === f.group || !(c & f.layers) || f.sensor || (f = f.nearestPointQuery(a), f.d < b && (!e || f.d < e.d) && (e = f))
  31906. },
  31907. g = xa(a, b);
  31908. this.activeShapes.query(g, f);
  31909. this.staticShapes.query(g, f);
  31910. return e
  31911. };
  31912. G.prototype.segmentQuery = function(a, b, c, d, e) {
  31913. var f = function(f) {
  31914. var g;
  31915. (!f.group || d !== f.group) && c & f.layers &&
  31916. (g = f.segmentQuery(a, b)) && e(f, g.t, g.n);
  31917. return 1
  31918. };
  31919. this.lock();
  31920. this.staticShapes.segmentQuery(a, b, 1, f);
  31921. this.activeShapes.segmentQuery(a, b, 1, f);
  31922. this.unlock(!0)
  31923. };
  31924. G.prototype.segmentQueryFirst = function(a, b, c, d) {
  31925. var e = null,
  31926. f = function(f) {
  31927. var g;
  31928. (!f.group || d !== f.group) && c & f.layers && !f.sensor && (g = f.segmentQuery(a, b)) && (null === e || g.t < e.t) && (e = g);
  31929. return e ? e.t : 1
  31930. };
  31931. this.staticShapes.segmentQuery(a, b, 1, f);
  31932. this.activeShapes.segmentQuery(a, b, e ? e.t : 1, f);
  31933. return e
  31934. };
  31935. G.prototype.bbQuery = function(a, b, c, d) {
  31936. var e = function(e) {
  31937. (!e.group ||
  31938. c !== e.group) && b & e.layers && a.l <= e.bb_r && e.bb_l <= a.r && a.b <= e.bb_t && e.bb_b <= a.t && d(e)
  31939. };
  31940. this.lock();
  31941. this.activeShapes.query(a, e);
  31942. this.staticShapes.query(a, e);
  31943. this.unlock(!0)
  31944. };
  31945. G.prototype.shapeQuery = function(a, b) {
  31946. var c = a.body;
  31947. c && a.update(c.p, c.rot);
  31948. var c = new X(a.bb_l, a.bb_b, a.bb_r, a.bb_t),
  31949. d = !1,
  31950. e = function(c) {
  31951. if ((!a.group || a.group !== c.group) && a.layers & c.layers && a !== c) {
  31952. var e;
  31953. if (a.collisionCode <= c.collisionCode) e = Na(a, c);
  31954. else {
  31955. e = Na(c, a);
  31956. for (var f = 0; f < e.length; f++) e[f].n = B(e[f].n)
  31957. } if (e.length && (d = !(a.sensor ||
  31958. c.sensor), b)) {
  31959. for (var g = Array(e.length), f = 0; f < e.length; f++) g[f] = new ab(e[f].p, e[f].n, e[f].dist);
  31960. b(c, g)
  31961. }
  31962. }
  31963. };
  31964. this.lock();
  31965. this.activeShapes.query(c, e);
  31966. this.staticShapes.query(c, e);
  31967. this.unlock(!0);
  31968. return d
  31969. };
  31970. G.prototype.addPostStepCallback = function(a) {
  31971. c(this.locked, "Adding a post-step callback when the space is not locked is unnecessary. Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query.");
  31972. this.postStepCallbacks.push(a)
  31973. };
  31974. G.prototype.runPostStepCallbacks =
  31975. function() {
  31976. for (var a = 0; a < this.postStepCallbacks.length; a++) this.postStepCallbacks[a]();
  31977. this.postStepCallbacks = []
  31978. };
  31979. G.prototype.lock = function() {
  31980. this.locked++
  31981. };
  31982. G.prototype.unlock = function(a) {
  31983. this.locked--;
  31984. b(0 <= this.locked, "Internal Error: Space lock underflow.");
  31985. if (0 === this.locked && a) {
  31986. a = this.rousedBodies;
  31987. for (var c = 0; c < a.length; c++) this.activateBody(a[c]);
  31988. a.length = 0;
  31989. this.runPostStepCallbacks()
  31990. }
  31991. };
  31992. G.prototype.makeCollideShapes = function() {
  31993. var a = this;
  31994. return function(b, c) {
  31995. if (b.bb_l <= c.bb_r && c.bb_l <= b.bb_r &&
  31996. b.bb_b <= c.bb_t && c.bb_b <= b.bb_t && b.body !== c.body && (!b.group || b.group !== c.group) && b.layers & c.layers) {
  31997. var d = a.lookupHandler(b.collision_type, c.collision_type),
  31998. e = b.sensor || c.sensor;
  31999. if (!e || d !== hb) {
  32000. if (b.collisionCode > c.collisionCode) {
  32001. var f = b;
  32002. b = c;
  32003. c = f
  32004. }
  32005. f = Na(b, c);
  32006. if (0 !== f.length) {
  32007. var g = h(b.hashid, c.hashid),
  32008. k = a.cachedArbiters[g];
  32009. k || (k = a.cachedArbiters[g] = new Q(b, c));
  32010. k.update(f, d, b, c);
  32011. "first coll" != k.state || d.begin(k, a) || k.ignore();
  32012. "ignore" !== k.state && d.preSolve(k, a) && !e ? a.arbiters.push(k) : (k.contacts = null, "ignore" !==
  32013. k.state && (k.state = "normal"));
  32014. k.stamp = a.stamp
  32015. }
  32016. }
  32017. }
  32018. }
  32019. };
  32020. G.prototype.arbiterSetFilter = function(a) {
  32021. var b = this.stamp - a.stamp,
  32022. c = a.body_a,
  32023. d = a.body_b;
  32024. if ((c.isStatic() || c.isSleeping()) && (d.isStatic() || d.isSleeping())) return !0;
  32025. 1 <= b && "cached" != a.state && (a.callSeparate(this), a.state = "cached");
  32026. return b >= this.collisionPersistence ? (a.contacts = null, !1) : !0
  32027. };
  32028. var sb = function(a) {
  32029. var b = a.body;
  32030. a.update(b.p, b.rot)
  32031. };
  32032. G.prototype.step = function(a) {
  32033. if (0 !== a) {
  32034. b(0 === v.x && 0 === v.y, "vzero is invalid");
  32035. this.stamp++;
  32036. var c = this.curr_dt;
  32037. this.curr_dt = a;
  32038. var d, e, f = this.bodies,
  32039. g = this.constraints,
  32040. h = this.arbiters;
  32041. for (d = 0; d < h.length; d++) {
  32042. var k = h[d];
  32043. k.state = "normal";
  32044. k.body_a.isSleeping() || k.body_b.isSleeping() || k.unthread()
  32045. }
  32046. h.length = 0;
  32047. this.lock();
  32048. for (d = 0; d < f.length; d++) f[d].position_func(a);
  32049. this.activeShapes.each(sb);
  32050. this.activeShapes.reindexQuery(this.collideShapes);
  32051. this.unlock(!1);
  32052. this.processComponents(a);
  32053. this.lock();
  32054. for (e in this.cachedArbiters) this.arbiterSetFilter(this.cachedArbiters[e]) || delete this.cachedArbiters[e];
  32055. e = this.collisionSlop;
  32056. k = 1 - Math.pow(this.collisionBias, a);
  32057. for (d = 0; d < h.length; d++) h[d].preStep(a, e, k);
  32058. for (d = 0; d < g.length; d++) e = g[d], e.preSolve(this), e.preStep(a);
  32059. e = Math.pow(this.damping, a);
  32060. k = this.gravity;
  32061. for (d = 0; d < f.length; d++) f[d].velocity_func(k, e, a);
  32062. a = 0 === c ? 0 : a / c;
  32063. for (d = 0; d < h.length; d++) h[d].applyCachedImpulse(a);
  32064. for (d = 0; d < g.length; d++) g[d].applyCachedImpulse(a);
  32065. for (d = 0; d < this.iterations; d++) {
  32066. for (a = 0; a < h.length; a++) h[a].applyImpulse();
  32067. for (a = 0; a < g.length; a++) g[a].applyImpulse()
  32068. }
  32069. for (d = 0; d < g.length; d++) g[d].postSolve(this);
  32070. for (d = 0; d < h.length; d++) h[d].handler.postSolve(h[d], this);
  32071. this.unlock(!0)
  32072. }
  32073. };
  32074. var Pa = function(a, b, c, d) {
  32075. return new s(b.vx + -d.y * b.w - (a.vx + -c.y * a.w), b.vy + d.x * b.w - (a.vy + c.x * a.w))
  32076. },
  32077. La = function(a, b, c, d, e) {
  32078. return (b.vx + -d.y * b.w - (a.vx + -c.y * a.w)) * e.x + (b.vy + d.x * b.w - (a.vy + c.x * a.w)) * e.y
  32079. },
  32080. Ia = function(a, b, c, d) {
  32081. a.vx += b * a.m_inv;
  32082. a.vy += c * a.m_inv;
  32083. a.w += a.i_inv * (d.x * c - d.y * b)
  32084. },
  32085. Y = function(a, b, c, d, e, f) {
  32086. Ia(a, -e, -f, c);
  32087. Ia(b, e, f, d)
  32088. },
  32089. cb = function(a, b, c, d) {
  32090. a.v_biasx += b * a.m_inv;
  32091. a.v_biasy += c * a.m_inv;
  32092. a.w_bias += a.i_inv * (d.x * c - d.y * b)
  32093. },
  32094. ib = function(a, b, c) {
  32095. b = z(b, c);
  32096. return a.m_inv + a.i_inv * b * b
  32097. },
  32098. pa = function(a, b, d, e, f) {
  32099. a = ib(a, d, f) + ib(b, e, f);
  32100. c(0 !== a, "Unsolvable collision or constraint.");
  32101. return a
  32102. },
  32103. jb = function(a, b, d, e, f, g) {
  32104. var h;
  32105. h = a.m_inv + b.m_inv;
  32106. var k = a.i_inv,
  32107. m = d.x * d.x * k;
  32108. a = -d.x * d.y * k;
  32109. d = h + d.y * d.y * k;
  32110. h += m;
  32111. k = b.i_inv;
  32112. b = e.x * e.x * k;
  32113. m = -e.x * e.y * k;
  32114. d += e.y * e.y * k;
  32115. e = 0 + a + m;
  32116. a = 0 + a + m;
  32117. h += b;
  32118. b = d * h - e * a;
  32119. c(0 !== b, "Unsolvable constraint.");
  32120. b = 1 / b;
  32121. f.x = h * b;
  32122. f.y = -e * b;
  32123. g.x = -a * b;
  32124. g.y = d * b
  32125. },
  32126. M = a.Constraint = function(a, b) {
  32127. this.a = a;
  32128. this.b = b;
  32129. this.next_b = this.next_a = this.space =
  32130. null;
  32131. this.maxForce = Infinity;
  32132. this.errorBias = Math.pow(0.9, 60);
  32133. this.maxBias = Infinity
  32134. };
  32135. M.prototype.activateBodies = function() {
  32136. this.a && this.a.activate();
  32137. this.b && this.b.activate()
  32138. };
  32139. M.prototype.preStep = function(a) {};
  32140. M.prototype.applyCachedImpulse = function(a) {};
  32141. M.prototype.applyImpulse = function() {};
  32142. M.prototype.getImpulse = function() {
  32143. return 0
  32144. };
  32145. M.prototype.preSolve = function(a) {};
  32146. M.prototype.postSolve = function(a) {};
  32147. M.prototype.next = function(a) {
  32148. return this.a === a ? this.next_a : this.next_b
  32149. };
  32150. var qa = a.PinJoint = function(a,
  32151. b, d, e) {
  32152. M.call(this, a, b);
  32153. this.anchr1 = d;
  32154. this.anchr2 = e;
  32155. a = a ? A(a.p, C(d, a.rot)) : d;
  32156. b = b ? A(b.p, C(e, b.rot)) : e;
  32157. this.dist = D(w(b, a));
  32158. c(0 < this.dist, "You created a 0 length pin joint. A pivot joint will be much more stable.");
  32159. this.n = this.r1 = this.r2 = null;
  32160. this.bias = this.jnAcc = this.jnMax = this.nMass = 0
  32161. };
  32162. qa.prototype = Object.create(M.prototype);
  32163. qa.prototype.preStep = function(a) {
  32164. var b = this.a,
  32165. c = this.b;
  32166. this.r1 = C(this.anchr1, b.rot);
  32167. this.r2 = C(this.anchr2, c.rot);
  32168. var d = w(A(c.p, this.r2), A(b.p, this.r1)),
  32169. e = D(d);
  32170. this.n = y(d, 1 / (e ? e :
  32171. Infinity));
  32172. this.nMass = 1 / pa(b, c, this.r1, this.r2, this.n);
  32173. b = this.maxBias;
  32174. this.bias = r(-(1 - Math.pow(this.errorBias, a)) * (e - this.dist) / a, -b, b);
  32175. this.jnMax = this.maxForce * a
  32176. };
  32177. qa.prototype.applyCachedImpulse = function(a) {
  32178. a = y(this.n, this.jnAcc * a);
  32179. Y(this.a, this.b, this.r1, this.r2, a.x, a.y)
  32180. };
  32181. qa.prototype.applyImpulse = function() {
  32182. var a = this.a,
  32183. b = this.b,
  32184. c = this.n,
  32185. d = La(a, b, this.r1, this.r2, c),
  32186. d = (this.bias - d) * this.nMass,
  32187. e = this.jnAcc;
  32188. this.jnAcc = r(e + d, -this.jnMax, this.jnMax);
  32189. d = this.jnAcc - e;
  32190. Y(a, b, this.r1, this.r2, c.x * d, c.y * d)
  32191. };
  32192. qa.prototype.getImpulse = function() {
  32193. return Math.abs(this.jnAcc)
  32194. };
  32195. var ra = a.SlideJoint = function(a, b, c, d, e, f) {
  32196. M.call(this, a, b);
  32197. this.anchr1 = c;
  32198. this.anchr2 = d;
  32199. this.min = e;
  32200. this.max = f;
  32201. this.r1 = this.r2 = this.n = null;
  32202. this.bias = this.jnAcc = this.jnMax = this.nMass = 0
  32203. };
  32204. ra.prototype = Object.create(M.prototype);
  32205. ra.prototype.preStep = function(a) {
  32206. var b = this.a,
  32207. c = this.b;
  32208. this.r1 = C(this.anchr1, b.rot);
  32209. this.r2 = C(this.anchr2, c.rot);
  32210. var d = w(A(c.p, this.r2), A(b.p, this.r1)),
  32211. e = D(d),
  32212. f = 0;
  32213. e > this.max ? (f = e - this.max, this.n = T(d)) : e < this.min ? (f =
  32214. this.min - e, this.n = B(T(d))) : (this.n = v, this.jnAcc = 0);
  32215. this.nMass = 1 / pa(b, c, this.r1, this.r2, this.n);
  32216. b = this.maxBias;
  32217. this.bias = r(-(1 - Math.pow(this.errorBias, a)) * f / a, -b, b);
  32218. this.jnMax = this.maxForce * a
  32219. };
  32220. ra.prototype.applyCachedImpulse = function(a) {
  32221. a *= this.jnAcc;
  32222. Y(this.a, this.b, this.r1, this.r2, this.n.x * a, this.n.y * a)
  32223. };
  32224. ra.prototype.applyImpulse = function() {
  32225. if (0 !== this.n.x || 0 !== this.n.y) {
  32226. var a = this.a,
  32227. b = this.b,
  32228. c = this.n,
  32229. d = Pa(a, b, this.r1, this.r2),
  32230. d = x(d, c),
  32231. d = (this.bias - d) * this.nMass,
  32232. e = this.jnAcc;
  32233. this.jnAcc = r(e + d, -this.jnMax,
  32234. 0);
  32235. d = this.jnAcc - e;
  32236. Y(a, b, this.r1, this.r2, c.x * d, c.y * d)
  32237. }
  32238. };
  32239. ra.prototype.getImpulse = function() {
  32240. return Math.abs(this.jnAcc)
  32241. };
  32242. var sa = a.PivotJoint = function(a, b, c, d) {
  32243. M.call(this, a, b);
  32244. "undefined" === typeof d && (d = c, c = a ? a.world2Local(d) : d, d = b ? b.world2Local(d) : d);
  32245. this.anchr1 = c;
  32246. this.anchr2 = d;
  32247. this.r1 = this.r2 = v;
  32248. this.k1 = new s(0, 0);
  32249. this.k2 = new s(0, 0);
  32250. this.jAcc = v;
  32251. this.jMaxLen = 0;
  32252. this.bias = v
  32253. };
  32254. sa.prototype = Object.create(M.prototype);
  32255. sa.prototype.preStep = function(a) {
  32256. var b = this.a,
  32257. c = this.b;
  32258. this.r1 = C(this.anchr1, b.rot);
  32259. this.r2 =
  32260. C(this.anchr2, c.rot);
  32261. jb(b, c, this.r1, this.r2, this.k1, this.k2);
  32262. this.jMaxLen = this.maxForce * a;
  32263. b = w(A(c.p, this.r2), A(b.p, this.r1));
  32264. this.bias = K(y(b, -(1 - Math.pow(this.errorBias, a)) / a), this.maxBias)
  32265. };
  32266. sa.prototype.applyCachedImpulse = function(a) {
  32267. Y(this.a, this.b, this.r1, this.r2, this.jAcc.x * a, this.jAcc.y * a)
  32268. };
  32269. sa.prototype.applyImpulse = function() {
  32270. var a = this.a,
  32271. b = this.b,
  32272. c = Pa(a, b, this.r1, this.r2),
  32273. c = w(this.bias, c),
  32274. d = this.k2,
  32275. c = new s(x(c, this.k1), x(c, d)),
  32276. d = this.jAcc;
  32277. this.jAcc = K(A(this.jAcc, c), this.jMaxLen);
  32278. Y(a, b, this.r1,
  32279. this.r2, this.jAcc.x - d.x, this.jAcc.y - d.y)
  32280. };
  32281. sa.prototype.getImpulse = function() {
  32282. return D(this.jAcc)
  32283. };
  32284. var ha = a.GrooveJoint = function(a, b, c, d, e) {
  32285. M.call(this, a, b);
  32286. this.grv_a = c;
  32287. this.grv_b = d;
  32288. this.grv_n = F(I(w(d, c)));
  32289. this.anchr2 = e;
  32290. this.grv_tn = null;
  32291. this.clamp = 0;
  32292. this.r1 = this.r2 = null;
  32293. this.k1 = new s(0, 0);
  32294. this.k2 = new s(0, 0);
  32295. this.jAcc = v;
  32296. this.jMaxLen = 0;
  32297. this.bias = null
  32298. };
  32299. ha.prototype = Object.create(M.prototype);
  32300. ha.prototype.preStep = function(a) {
  32301. var b = this.a,
  32302. c = this.b,
  32303. d = b.local2World(this.grv_a),
  32304. e = b.local2World(this.grv_b),
  32305. f = C(this.grv_n, b.rot),
  32306. g = x(d, f);
  32307. this.grv_tn = f;
  32308. this.r2 = C(this.anchr2, c.rot);
  32309. var h = z(A(c.p, this.r2), f);
  32310. h <= z(d, f) ? (this.clamp = 1, this.r1 = w(d, b.p)) : h >= z(e, f) ? (this.clamp = -1, this.r1 = w(e, b.p)) : (this.clamp = 0, this.r1 = w(A(y(F(f), -h), y(f, g)), b.p));
  32311. jb(b, c, this.r1, this.r2, this.k1, this.k2);
  32312. this.jMaxLen = this.maxForce * a;
  32313. b = w(A(c.p, this.r2), A(b.p, this.r1));
  32314. this.bias = K(y(b, -(1 - Math.pow(this.errorBias, a)) / a), this.maxBias)
  32315. };
  32316. ha.prototype.applyCachedImpulse = function(a) {
  32317. Y(this.a, this.b, this.r1, this.r2, this.jAcc.x * a, this.jAcc.y *
  32318. a)
  32319. };
  32320. ha.prototype.grooveConstrain = function(a) {
  32321. var b = this.grv_tn;
  32322. a = 0 < this.clamp * z(a, b) ? a : J(a, b);
  32323. return K(a, this.jMaxLen)
  32324. };
  32325. ha.prototype.applyImpulse = function() {
  32326. var a = this.a,
  32327. b = this.b,
  32328. c = Pa(a, b, this.r1, this.r2),
  32329. c = w(this.bias, c),
  32330. d = this.k2,
  32331. c = new s(x(c, this.k1), x(c, d)),
  32332. d = this.jAcc;
  32333. this.jAcc = this.grooveConstrain(A(d, c));
  32334. Y(a, b, this.r1, this.r2, this.jAcc.x - d.x, this.jAcc.y - d.y)
  32335. };
  32336. ha.prototype.getImpulse = function() {
  32337. return D(this.jAcc)
  32338. };
  32339. ha.prototype.setGrooveA = function(a) {
  32340. this.grv_a = a;
  32341. this.grv_n = F(I(w(this.grv_b,
  32342. a)));
  32343. this.activateBodies()
  32344. };
  32345. ha.prototype.setGrooveB = function(a) {
  32346. this.grv_b = a;
  32347. this.grv_n = F(I(w(a, this.grv_a)));
  32348. this.activateBodies()
  32349. };
  32350. var tb = function(a, b) {
  32351. return (a.restLength - b) * a.stiffness
  32352. },
  32353. ta = a.DampedSpring = function(a, b, c, d, e, f, g) {
  32354. M.call(this, a, b);
  32355. this.anchr1 = c;
  32356. this.anchr2 = d;
  32357. this.restLength = e;
  32358. this.stiffness = f;
  32359. this.damping = g;
  32360. this.springForceFunc = tb;
  32361. this.target_vrn = this.v_coef = 0;
  32362. this.r1 = this.r2 = null;
  32363. this.nMass = 0;
  32364. this.n = null
  32365. };
  32366. ta.prototype = Object.create(M.prototype);
  32367. ta.prototype.preStep = function(a) {
  32368. var b =
  32369. this.a,
  32370. d = this.b;
  32371. this.r1 = C(this.anchr1, b.rot);
  32372. this.r2 = C(this.anchr2, d.rot);
  32373. var e = w(A(d.p, this.r2), A(b.p, this.r1)),
  32374. f = D(e);
  32375. this.n = y(e, 1 / (f ? f : Infinity));
  32376. e = pa(b, d, this.r1, this.r2, this.n);
  32377. c(0 !== e, "Unsolvable this.");
  32378. this.nMass = 1 / e;
  32379. this.target_vrn = 0;
  32380. this.v_coef = 1 - Math.exp(-this.damping * a * e);
  32381. f = this.springForceFunc(this, f);
  32382. Y(b, d, this.r1, this.r2, this.n.x * f * a, this.n.y * f * a)
  32383. };
  32384. ta.prototype.applyCachedImpulse = function(a) {};
  32385. ta.prototype.applyImpulse = function() {
  32386. var a = this.a,
  32387. b = this.b,
  32388. c = La(a, b, this.r1, this.r2, this.n),
  32389. d = (this.target_vrn - c) * this.v_coef;
  32390. this.target_vrn = c + d;
  32391. d *= this.nMass;
  32392. Y(a, b, this.r1, this.r2, this.n.x * d, this.n.y * d)
  32393. };
  32394. ta.prototype.getImpulse = function() {
  32395. return 0
  32396. };
  32397. var ub = function(a, b) {
  32398. return (b - a.restAngle) * a.stiffness
  32399. },
  32400. Qa = a.DampedRotarySpring = function(a, b, c, d, e) {
  32401. M.call(this, a, b);
  32402. this.restAngle = c;
  32403. this.stiffness = d;
  32404. this.damping = e;
  32405. this.springTorqueFunc = ub;
  32406. this.iSum = this.w_coef = this.target_wrn = 0
  32407. };
  32408. Qa.prototype = Object.create(M.prototype);
  32409. Qa.prototype.preStep = function(a) {
  32410. var b = this.a,
  32411. d = this.b,
  32412. e = b.i_inv + d.i_inv;
  32413. c(0 !== e, "Unsolvable spring.");
  32414. this.iSum = 1 / e;
  32415. this.w_coef = 1 - Math.exp(-this.damping * a * e);
  32416. this.target_wrn = 0;
  32417. a *= this.springTorqueFunc(this, b.a - d.a);
  32418. b.w -= a * b.i_inv;
  32419. d.w += a * d.i_inv
  32420. };
  32421. Qa.prototype.applyImpulse = function() {
  32422. var a = this.a,
  32423. b = this.b,
  32424. c = a.w - b.w,
  32425. d = (this.target_wrn - c) * this.w_coef;
  32426. this.target_wrn = c + d;
  32427. c = d * this.iSum;
  32428. a.w += c * a.i_inv;
  32429. b.w -= c * b.i_inv
  32430. };
  32431. var ua = a.RotaryLimitJoint = function(a, b, c, d) {
  32432. M.call(this, a, b);
  32433. this.min = c;
  32434. this.max = d;
  32435. this.iSum = this.bias = this.jMax = this.jAcc = 0
  32436. };
  32437. ua.prototype = Object.create(M.prototype);
  32438. ua.prototype.preStep = function(a) {
  32439. var b = this.a,
  32440. c = this.b,
  32441. d = c.a - b.a,
  32442. e = 0;
  32443. d > this.max ? e = this.max - d : d < this.min && (e = this.min - d);
  32444. this.iSum = 1 / (1 / b.i + 1 / c.i);
  32445. b = this.maxBias;
  32446. this.bias = r(-(1 - Math.pow(this.errorBias, a)) * e / a, -b, b);
  32447. this.jMax = this.maxForce * a;
  32448. this.bias || (this.jAcc = 0)
  32449. };
  32450. ua.prototype.applyCachedImpulse = function(a) {
  32451. var b = this.a,
  32452. c = this.b;
  32453. a *= this.jAcc;
  32454. b.w -= a * b.i_inv;
  32455. c.w += a * c.i_inv
  32456. };
  32457. ua.prototype.applyImpulse = function() {
  32458. if (this.bias) {
  32459. var a = this.a,
  32460. b = this.b,
  32461. c = -(this.bias + (b.w - a.w)) * this.iSum,
  32462. d = this.jAcc;
  32463. this.jAcc =
  32464. 0 > this.bias ? r(d + c, 0, this.jMax) : r(d + c, -this.jMax, 0);
  32465. c = this.jAcc - d;
  32466. a.w -= c * a.i_inv;
  32467. b.w += c * b.i_inv
  32468. }
  32469. };
  32470. ua.prototype.getImpulse = function() {
  32471. return Math.abs(joint.jAcc)
  32472. };
  32473. var va = a.RatchetJoint = function(a, b, c, d) {
  32474. M.call(this, a, b);
  32475. this.angle = 0;
  32476. this.phase = c;
  32477. this.ratchet = d;
  32478. this.angle = (b ? b.a : 0) - (a ? a.a : 0);
  32479. this.iSum = this.bias = this.jAcc = this.jMax = 0
  32480. };
  32481. va.prototype = Object.create(M.prototype);
  32482. va.prototype.preStep = function(a) {
  32483. var b = this.a,
  32484. c = this.b,
  32485. d = this.phase,
  32486. e = this.ratchet,
  32487. f = c.a - b.a,
  32488. g = this.angle - f,
  32489. h = 0;
  32490. 0 < g * e ? h = g : this.angle =
  32491. Math.floor((f - d) / e) * e + d;
  32492. this.iSum = 1 / (b.i_inv + c.i_inv);
  32493. b = this.maxBias;
  32494. this.bias = r(-(1 - Math.pow(this.errorBias, a)) * h / a, -b, b);
  32495. this.jMax = this.maxForce * a;
  32496. this.bias || (this.jAcc = 0)
  32497. };
  32498. va.prototype.applyCachedImpulse = function(a) {
  32499. var b = this.a,
  32500. c = this.b;
  32501. a *= this.jAcc;
  32502. b.w -= a * b.i_inv;
  32503. c.w += a * c.i_inv
  32504. };
  32505. va.prototype.applyImpulse = function() {
  32506. if (this.bias) {
  32507. var a = this.a,
  32508. b = this.b,
  32509. c = this.ratchet,
  32510. d = -(this.bias + (b.w - a.w)) * this.iSum,
  32511. e = this.jAcc;
  32512. this.jAcc = r((e + d) * c, 0, this.jMax * Math.abs(c)) / c;
  32513. d = this.jAcc - e;
  32514. a.w -= d * a.i_inv;
  32515. b.w +=
  32516. d * b.i_inv
  32517. }
  32518. };
  32519. va.prototype.getImpulse = function(a) {
  32520. return Math.abs(a.jAcc)
  32521. };
  32522. var la = a.GearJoint = function(a, b, c, d) {
  32523. M.call(this, a, b);
  32524. this.phase = c;
  32525. this.ratio = d;
  32526. this.ratio_inv = 1 / d;
  32527. this.iSum = this.bias = this.jMax = this.jAcc = 0
  32528. };
  32529. la.prototype = Object.create(M.prototype);
  32530. la.prototype.preStep = function(a) {
  32531. var b = this.a,
  32532. c = this.b;
  32533. this.iSum = 1 / (b.i_inv * this.ratio_inv + this.ratio * c.i_inv);
  32534. var d = this.maxBias;
  32535. this.bias = r(-(1 - Math.pow(this.errorBias, a)) * (c.a * this.ratio - b.a - this.phase) / a, -d, d);
  32536. this.jMax = this.maxForce * a
  32537. };
  32538. la.prototype.applyCachedImpulse =
  32539. function(a) {
  32540. var b = this.a,
  32541. c = this.b;
  32542. a *= this.jAcc;
  32543. b.w -= a * b.i_inv * this.ratio_inv;
  32544. c.w += a * c.i_inv
  32545. };
  32546. la.prototype.applyImpulse = function() {
  32547. var a = this.a,
  32548. b = this.b,
  32549. c = (this.bias - (b.w * this.ratio - a.w)) * this.iSum,
  32550. d = this.jAcc;
  32551. this.jAcc = r(d + c, -this.jMax, this.jMax);
  32552. c = this.jAcc - d;
  32553. a.w -= c * a.i_inv * this.ratio_inv;
  32554. b.w += c * b.i_inv
  32555. };
  32556. la.prototype.getImpulse = function() {
  32557. return Math.abs(this.jAcc)
  32558. };
  32559. la.prototype.setRatio = function(a) {
  32560. this.ratio = a;
  32561. this.ratio_inv = 1 / a;
  32562. this.activateBodies()
  32563. };
  32564. var wa = a.SimpleMotor = function(a, b, c) {
  32565. M.call(this,
  32566. a, b);
  32567. this.rate = c;
  32568. this.iSum = this.jMax = this.jAcc = 0
  32569. };
  32570. wa.prototype = Object.create(M.prototype);
  32571. wa.prototype.preStep = function(a) {
  32572. this.iSum = 1 / (this.a.i_inv + this.b.i_inv);
  32573. this.jMax = this.maxForce * a
  32574. };
  32575. wa.prototype.applyCachedImpulse = function(a) {
  32576. var b = this.a,
  32577. c = this.b;
  32578. a *= this.jAcc;
  32579. b.w -= a * b.i_inv;
  32580. c.w += a * c.i_inv
  32581. };
  32582. wa.prototype.applyImpulse = function() {
  32583. var a = this.a,
  32584. b = this.b,
  32585. c = -(b.w - a.w + this.rate) * this.iSum,
  32586. d = this.jAcc;
  32587. this.jAcc = r(d + c, -this.jMax, this.jMax);
  32588. c = this.jAcc - d;
  32589. a.w -= c * a.i_inv;
  32590. b.w += c * b.i_inv
  32591. };
  32592. wa.prototype.getImpulse =
  32593. function() {
  32594. return Math.abs(this.jAcc)
  32595. }
  32596. })();
  32597. var res = {
  32598. Map_png: "res/background.png",
  32599. Food_png: "res/Item_03_New.png",
  32600. R_Get_Star_01_ogg: "res/r_get_star_01.ogg",
  32601. Character_Ani_png: "res/ani.png",
  32602. Food_Zuai1_png: "res/zuai1.png",
  32603. Food_Zuai2_png: "res/zuai2.png",
  32604. Food_Zuai3_png: "res/zuai3.png",
  32605. Food_Zuai4_png: "res/zuai4.png",
  32606. Food_Zuai5_png: "res/zuai5.png",
  32607. Food_Zuai6_png: "res/zuai6.png",
  32608. Food_Zuai7_png: "res/zuai7.png",
  32609. Food_Zuai8_png: "res/zuai8.png",
  32610. Food_Zuai9_png: "res/zuai9.png",
  32611. Food_Zuai10_png: "res/zuai10.png",
  32612. Btn_phbtn_png: "res/phbtn.png",
  32613. Btn_rulebtn_png: "res/rulebtn.png",
  32614. BackGround_mp3: "res/supermary.mp3"
  32615. },
  32616. g_resources = [],
  32617. i;
  32618. for (i in res) g_resources.push(res[i]);
  32619. var TagOfLayer = {
  32620. Background: 0,
  32621. Animation: 1,
  32622. GameLayer: 2,
  32623. Status: 3
  32624. },
  32625. RunnerState = {
  32626. running: 0,
  32627. jumpUp: 1,
  32628. jumpDown: 2
  32629. };
  32630. var HelloWorldLayer = cc.Layer.extend({
  32631. sprite: null,
  32632. ctor: function() {
  32633. this._super();
  32634. var a = cc.winSize,
  32635. b = new cc.MenuItemImage(res.CloseNormal_png, res.CloseSelected_png, function() {
  32636. cc.log("Menu is clicked!")
  32637. }, this);
  32638. b.attr({
  32639. x: a.width - 20,
  32640. y: 20,
  32641. anchorX: 0.5,
  32642. anchorY: 0.5
  32643. });
  32644. b = new cc.Menu(b);
  32645. b.x = 0;
  32646. b.y = 0;
  32647. this.addChild(b, 1);
  32648. b = new cc.LabelTTF("Hello World", "Arial", 38);
  32649. b.x = a.width / 2;
  32650. b.y = 0;
  32651. this.addChild(b, 5);
  32652. this.sprite = new cc.Sprite(res.HelloWorld_png);
  32653. this.sprite.attr({
  32654. x: a.width / 2,
  32655. y: a.height / 2,
  32656. scale: 0.5,
  32657. rotation: 180
  32658. });
  32659. this.addChild(this.sprite, 0);
  32660. this.sprite.runAction(cc.sequence(cc.rotateTo(2, 0), cc.scaleTo(2, 1, 1)));
  32661. b.runAction(cc.spawn(cc.moveBy(2.5, cc.p(0, a.height - 40)), cc.tintTo(2.5, 255, 125, 0)));
  32662. return !0
  32663. }
  32664. }),
  32665. HelloWorldScene = cc.Scene.extend({
  32666. onEnter: function() {
  32667. this._super();
  32668. var a = new HelloWorldLayer;
  32669. this.addChild(a)
  32670. }
  32671. });
  32672. var AnimationLayer = cc.Layer.extend({
  32673. space: null,
  32674. state: RunnerState.running,
  32675. jumpUpAction: null,
  32676. jumpDownAction: null,
  32677. runningAction: null,
  32678. recognizer: null,
  32679. body: null,
  32680. sprite: null,
  32681. sy: null,
  32682. startTouch: null,
  32683. ctor: function(a) {
  32684. this._super();
  32685. this.space = a;
  32686. this.initAction();
  32687. this.init();
  32688. this.scheduleUpdate()
  32689. },
  32690. init: function() {
  32691. this._super();
  32692. this.sprite = new cc.PhysicsSprite(res.Character_Ani_png);
  32693. var a = this.sprite.getContentSize();
  32694. this.body = new cp.Body(1, cp.momentForBox(1, a.width, a.height));
  32695. this.body.p = cc.p(80, 200);
  32696. this.body.applyImpulse(cp.v(240,
  32697. 0), cp.v(0, 0));
  32698. this.space.addBody(this.body);
  32699. this.shape = new cp.BoxShape(this.body, a.width, a.height);
  32700. this.shape.setElasticity(0);
  32701. this.shape.setFriction(0);
  32702. this.space.addShape(this.shape);
  32703. this.sprite.setBody(this.body);
  32704. this.sprite.attr({
  32705. x: 80,
  32706. y: 200
  32707. });
  32708. this.addChild(this.sprite);
  32709. cc.eventManager.addListener({
  32710. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  32711. swallowTouches: !0,
  32712. onTouchBegan: this.onTouchBegan,
  32713. onTouchMoved: this.onTouchMoved,
  32714. onTouchEnded: this.onTouchEnded
  32715. }, this)
  32716. },
  32717. addScore: function(a) {
  32718. var b = this;
  32719. 0 < a ? (this.score =
  32720. new cc.LabelTTF("+" + a, "Arial", 24), this.score.setColor(cc.color(255, 124, 8))) : (this.score = new cc.LabelTTF(a.toString(), "Arial", 24), this.score.setColor(cc.color(255, 8, 8)));
  32721. this.score.attr({
  32722. x: 70,
  32723. y: 80,
  32724. anchorX: 0,
  32725. anchorY: 0
  32726. });
  32727. this.sprite.addChild(this.score, 0, 100);
  32728. this.score.runAction(cc.sequence(cc.spawn(cc.moveBy(2, cc.p(0, 50)), cc.fadeOut(2)), cc.callFunc(function() {
  32729. b.sprite.getChildByTag(100).removeFromParent(!0)
  32730. })))
  32731. },
  32732. initAction: function() {},
  32733. getEyeX: function() {
  32734. return this.sprite.getPositionX() - 40
  32735. },
  32736. onTouchBegan: function(a,
  32737. b) {
  32738. b.getCurrentTarget().jump();
  32739. return !0
  32740. },
  32741. onTouchMoved: function(a, b) {},
  32742. onTouchEnded: function(a, b) {},
  32743. jump: function() {
  32744. this.startTouch = 0;
  32745. this.state == RunnerState.running && (this.body.applyImpulse(cp.v(0, 450), cp.v(0, 0)), this.state = RunnerState.jumpUp)
  32746. },
  32747. update: function() {
  32748. var a = this.body.getVel();
  32749. this.state == RunnerState.jumpUp ? 0 > a.y && (this.state = RunnerState.jumpDown) : this.state == RunnerState.jumpDown && (-450 >= a.y || 0 == a.y) && (this.state = RunnerState.running)
  32750. }
  32751. });
  32752. var FoodList = {
  32753. 0: {
  32754. src: "res/zuai1.png",
  32755. score: 1
  32756. },
  32757. 1: {
  32758. src: "res/zuai2.png",
  32759. score: 2
  32760. },
  32761. 2: {
  32762. src: "res/zuai3.png",
  32763. score: 3
  32764. },
  32765. 3: {
  32766. src: "res/zuai4.png",
  32767. score: 4
  32768. },
  32769. 4: {
  32770. src: "res/zuai5.png",
  32771. score: 5
  32772. },
  32773. 5: {
  32774. src: "res/zuai6.png",
  32775. score: -1
  32776. },
  32777. 6: {
  32778. src: "res/zuai8.png",
  32779. score: -3
  32780. },
  32781. 7: {
  32782. src: "res/zuai10.png",
  32783. score: -5
  32784. }
  32785. },
  32786. Food = cc.Class.extend({
  32787. space: null,
  32788. sprite: null,
  32789. shape: null,
  32790. _mapIndex: 0,
  32791. score: 0,
  32792. mapIndex: function(a) {
  32793. if (void 0 != a) this._mapIndex = a;
  32794. else return this._mapIndex
  32795. },
  32796. ctor: function(a, b, c) {
  32797. this.space = b;
  32798. b = Math.floor(8 * Math.random());
  32799. b = FoodList[b];
  32800. this.score = b.score;
  32801. this.sprite = new cc.PhysicsSprite(b.src);
  32802. b = 0.95 * this.sprite.getContentSize().width / 2;
  32803. var d = new cp.StaticBody;
  32804. d.setPos(c);
  32805. this.sprite.setBody(d);
  32806. this.shape = new cp.CircleShape(d, b, cp.vzero);
  32807. this.shape.setCollisionType(1);
  32808. this.shape.setSensor(!0);
  32809. this.space.addStaticShape(this.shape);
  32810. a.addChild(this.sprite, 1)
  32811. },
  32812. removeFromParent: function() {
  32813. this.space.removeStaticShape(this.shape);
  32814. this.shape = null;
  32815. this.sprite.removeFromParent();
  32816. this.sprite = null
  32817. },
  32818. getShape: function() {
  32819. return this.shape
  32820. }
  32821. });
  32822. var BackgroundLayer = cc.Layer.extend({
  32823. space: null,
  32824. objects: null,
  32825. foodIndex: 1,
  32826. ctor: function(a) {
  32827. this._super();
  32828. this.space = a;
  32829. this.objects = [];
  32830. this.mapIndex = 0;
  32831. this.mapWidth = 3198;
  32832. this.init()
  32833. },
  32834. init: function() {
  32835. this._super();
  32836. this.map = new cc.Sprite(res.Map_png);
  32837. this.map.attr({
  32838. x: 0,
  32839. y: 568,
  32840. anchorX: 0,
  32841. anchorY: 1
  32842. });
  32843. this.addChild(this.map);
  32844. this.map1 = new cc.Sprite(res.Map_png);
  32845. this.map1.attr({
  32846. x: this.mapWidth,
  32847. y: 568,
  32848. anchorX: 0,
  32849. anchorY: 1
  32850. });
  32851. this.addChild(this.map1);
  32852. var a = new cc.Sprite(res.Bottom_png, cc.rect(29, 5, 41, 300)),
  32853. b = new cc.Sprite(res.Bottom_png,
  32854. cc.rect(76, 5, 118, 300)),
  32855. c = new cc.Sprite(res.Bottom_png, cc.rect(199, 5, 118, 300)),
  32856. d = new cc.Sprite(res.Bottom_png, cc.rect(322, 5, 118, 300)),
  32857. e = new cc.Sprite(res.Bottom_png, cc.rect(445, 5, 77, 300)),
  32858. f = 10;
  32859. a.attr({
  32860. x: f,
  32861. y: 30,
  32862. anchorX: 0
  32863. });
  32864. f += a.getContentSize().width;
  32865. b.attr({
  32866. x: f,
  32867. y: 30,
  32868. anchorX: 0
  32869. });
  32870. f += b.getContentSize().width;
  32871. c.attr({
  32872. x: f,
  32873. y: 30,
  32874. anchorX: 0
  32875. });
  32876. f += c.getContentSize().width;
  32877. d.attr({
  32878. x: f,
  32879. y: 30,
  32880. anchorX: 0
  32881. });
  32882. f += d.getContentSize().width;
  32883. e.attr({
  32884. x: f,
  32885. y: 30,
  32886. anchorX: 0
  32887. });
  32888. for (a = this.foodIndex + 5; this.foodIndex < a; this.foodIndex++) b =
  32889. new Food(this, this.space, cc.p(640 * this.foodIndex, 110)), this.objects.push(b);
  32890. this.scheduleUpdate()
  32891. },
  32892. removeObjectByShape: function(a) {
  32893. for (var b = 0, c = this.objects.length; b < c; b += 1)
  32894. if (this.objects[b].getShape() == a) return a = this.objects[b].score, this.objects[b].removeFromParent(), this.objects.splice(b, 1), a
  32895. },
  32896. loadObjects: function(a, b) {
  32897. a.getObjectGroup("coin").getObjects()
  32898. },
  32899. checkAndReload: function(a) {
  32900. a = parseInt(a / this.mapWidth);
  32901. if (this.mapIndex == a) return !1;
  32902. cc.log("speed up");
  32903. this.getParent().getChildByTag(TagOfLayer.Animation).body.applyImpulse(cp.v(20,
  32904. 0), cp.v(0, 0));
  32905. this.space.gravity = cp.v(0, -900 - 20 * this.mapIndex);
  32906. a % 2 ? this.map.setPositionX(this.mapWidth * (a + 1)) : this.map1.setPositionX(this.mapWidth * (a + 1));
  32907. for (var b = this.foodIndex + 5; this.foodIndex < b; this.foodIndex++) {
  32908. var c = new Food(this, this.space, cc.p(640 * this.foodIndex, 110));
  32909. this.objects.push(c)
  32910. }
  32911. this.mapIndex = a;
  32912. return !0
  32913. },
  32914. addDistance: function() {
  32915. this.distanceLabel = new cc.LabelTTF("0", "Arial", 25);
  32916. this.distanceLabel.attr({
  32917. x: 150,
  32918. y: 520
  32919. });
  32920. this.distanceLabel.setColor(cc.color(13, 110, 7));
  32921. this.addChild(this.distanceLabel)
  32922. },
  32923. updateDistance: function(a) {
  32924. this.distanceLabel.setPositionX(a + 150);
  32925. this.distanceLabel.setString(Math.round(a / 20))
  32926. },
  32927. update: function() {
  32928. var a = this.getParent().getChildByTag(TagOfLayer.Animation).getEyeX();
  32929. this.checkAndReload(a)
  32930. }
  32931. });
  32932. var PlayScene = cc.Scene.extend({
  32933. space: null,
  32934. shapesToRemove: null,
  32935. onEnter: function() {
  32936. this._super();
  32937. this.shapesToRemove = [];
  32938. this.initPhysics();
  32939. this.gameLayer = new cc.Layer;
  32940. this.gameLayer.addChild(new BackgroundLayer(this.space), 0, TagOfLayer.Background);
  32941. this.gameLayer.addChild(new AnimationLayer(this.space), 0, TagOfLayer.Animation);
  32942. this.addChild(this.gameLayer);
  32943. this.statusLayer = new cc.Layer;
  32944. this.statusLayer.addChild(new StatusLayer, 0, TagOfLayer.Status);
  32945. this.addChild(this.statusLayer);
  32946. cc.audioEngine.playMusic(res.BackGround_mp3, !0);
  32947. this.scheduleUpdate()
  32948. },
  32949. initPhysics: function() {
  32950. this.space = new cp.Space;
  32951. this.space.gravity = cp.v(0, -900);
  32952. var a = this.space.staticBody;
  32953. a.set;
  32954. for (var b = cc.director.getWinSize(), b = [new cp.SegmentShape(a, cp.v(1, 90), cp.v(cc.UINT_MAX, 90), 0), new cp.SegmentShape(a, cp.v(1, 100), cp.v(b.width, 100), 0), new cp.SegmentShape(a, cp.v(1, b.height), cp.v(b.width - 1, b.height - 1), 0), new cp.SegmentShape(a, cp.v(1, 1), cp.v(1, b.height - 1), 0), new cp.SegmentShape(a, cp.v(b.width - 1, 1), cp.v(b.width - 1, b.height - 1), 0)], c = 0; 4 > c; c += 1) {
  32955. var d =
  32956. b[c];
  32957. c || this.space.addStaticShape(d)
  32958. }
  32959. this.space.addStaticShape(new cp.SegmentShape(a, cp.v(1, 300), cp.v(cc.UINT_MAX, 300), 0));
  32960. this.space.addCollisionHandler(0, 1, this.collisionCoinBegin.bind(this), null, null, null)
  32961. },
  32962. collisionCoinBegin: function(a, b) {
  32963. var c = a.getShapes();
  32964. this.shapesToRemove.push(c[1]);
  32965. cc.audioEngine.playEffect(res.R_Get_Star_01_ogg)
  32966. },
  32967. update: function(a) {
  32968. this.space.step(a);
  32969. a = this.gameLayer.getChildByTag(TagOfLayer.Animation);
  32970. for (var b = 0, c = this.shapesToRemove.length; b < c; b += 1) {
  32971. var d = this.shapesToRemove[b],
  32972. d = this.gameLayer.getChildByTag(TagOfLayer.Background).removeObjectByShape(d);
  32973. this.statusLayer.getChildByTag(TagOfLayer.Status).updateScore(d);
  32974. a.addScore(d)
  32975. }
  32976. this.shapesToRemove = [];
  32977. a = a.getEyeX();
  32978. this.gameLayer.setPosition(cc.p(-a, 0))
  32979. }
  32980. });
  32981. var StatusLayer = cc.Layer.extend({
  32982. labelScore: null,
  32983. labelTimer: null,
  32984. coins: 0,
  32985. score: 0,
  32986. timer: 60,
  32987. ctor: function() {
  32988. this._super();
  32989. this.init()
  32990. },
  32991. init: function() {
  32992. cc.director.getWinSize();
  32993. this.addScore();
  32994. this.addTimer();
  32995. this.schedule(this.updateTimer, 1, 60)
  32996. },
  32997. addScore: function() {
  32998. this.labelScore = new cc.LabelTTF("\u5f97\u5206:" + this.score.toString(), "Arial", 25);
  32999. this.labelScore.attr({
  33000. x: 60,
  33001. y: 540
  33002. });
  33003. this.addChild(this.labelScore)
  33004. },
  33005. addTimer: function() {
  33006. this.labelTimer = new cc.LabelTTF("\u5012\u8ba1\u65f6:" + this.timer.toString(),
  33007. "Arial", 25);
  33008. this.labelTimer.attr({
  33009. x: 240,
  33010. y: 540
  33011. });
  33012. this.addChild(this.labelTimer)
  33013. },
  33014. addBtn: function() {
  33015. this.btnrule = new cc.Sprite(res.Btn_rulebtn_png);
  33016. rule.attr({
  33017. x: 80,
  33018. y: 37
  33019. });
  33020. var a = new cc.LabelTTF(res.Btn_phbtn_png);
  33021. a.attr({
  33022. x: 240,
  33023. y: 37
  33024. });
  33025. cc.eventManager.addListener({
  33026. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  33027. onTouchBegan: function() {
  33028. isInGame = 1;
  33029. cc.director.pause();
  33030. $(".dRule").removeClass("hide")
  33031. }
  33032. }, rule);
  33033. cc.eventManager.addListener({
  33034. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  33035. onTouchBegan: function() {
  33036. isInGame = 1;
  33037. cc.director.pause();
  33038. $(".dList").removeClass("hide");
  33039. getList1()
  33040. }
  33041. }, a);
  33042. this.addChild(rule)
  33043. },
  33044. updateTimer: function() {
  33045. 0 < this.timer ? (this.timer -= 1, this.labelTimer.setString("\u5012\u8ba1\u65f6:" + this.timer.toString())) : (cc.director.pause(), $(".divPM").addClass("hide"), $(".jifen").html(this.score), $("#num").val(this.score), $(".dGameOver").removeClass("hide"), postData())
  33046. },
  33047. updateScore: function(a) {
  33048. this.score += a;
  33049. this.score = 0 > this.score ? 0 : this.score;
  33050. this.labelScore.setString("\u5f97\u5206:" + this.score.toString())
  33051. }
  33052. });
  33053. var g_groundHight = 57,
  33054. g_runnerStartX = 80,
  33055. RunnerState = {
  33056. running: 0,
  33057. jumpUp: 1,
  33058. jumpDown: 2
  33059. };
  33060. var isInGame;
  33061. $("#cantest,#cantest1").val(_Mvar.cantest);
  33062. $("#cantest1").val("can");
  33063. $("#wxid,#wxid1,#wxnum1,#wxnum").val(_Mvar.wxid);
  33064. $("#headimgurl,#headimgurl1").val(_Mvar.headimgurl);
  33065. $("#nickname,#nickname1").val(_Mvar.nickname);
  33066. $(".headimgurl").attr("src", _Mvar.headimgurl);
  33067. $(".nickname").html("\u4eb2\u7231\u7684" + _Mvar.nickname + ":");
  33068. $("#gid").val(_Mvar.gid);
  33069. $("#gid1").val(196);
  33070. function getdate(a) {
  33071. return (new Function("date", "return new " + a.replace(/\//g, "")))()
  33072. }
  33073. var a={"success":1,"msg":{"UpCoinID":310,"IMG":"http://image.qqauto.cn/2/space/20150710142511.jpg","CountDown":0,"StartTime":"\/Date(1449200076000)\/","EndTime":"\/Date(1451034036000)\/","EachCoin":1,"MaxCoin":888888,"RegTime":"\/Date(1449200204357)\/","WxAccountID":15,"Rules":"奔跑吧soho星尚花园酒店","Title":"奔跑吧soho星尚花园酒店","Sts":"A","KeyWord":"http://wx.qqauto.cn/html/upcoin/kupao/2","DaylyCount":3,"TotalCount":0,"Intro":"奔跑吧soho星尚花园酒店","Photo":"http://image.qqauto.cn/2/space/20150710142511.jpg","Pwd":"DJB113644310","Remark":"","Share":3,"TimeSpan":86400,"Type":2,"ShareTimeSpan":0,"ShareCount":0,"ShareDaylyCount":888888,"ShareType":0,"SaveType":0},"user":{"UserListID":509608,"MyGroup":11,"GroupID":310,"WxNum":"o5QYUt7WjoXzzMEYpPyV3qKJimeI","RegTime":"\/Date(1450340767707)\/","Remark":"","Num":61,"Sts":"A","TrueName":"洪俊裕","Tel":"15623652365","NickName":"洪俊裕","HeadimgUrl":"http://wx.qlogo.cn/mmopen/krLSVZObVXNCeNOlorHq1aqjWiah2jmP37smTb4Caru4Opu2uKNVCMlicnMKkXib1cDwzC9F9Z10Ay7UUy155du6N54UIuia5Kjic/0","OtherID":0,"IsShare":0,"LastTime":"\/Date(1450340053830)\/","Prize":"","Remark1":"","Remark2":"","OtherID1":0,"OtherID2":0},"rank":159,"helper":null,"count":249,"hrank":0,"log":[]};
  33074. _Mvar.chance = a.msg.DaylyCount;
  33075. if (a.user) {
  33076. if (a.msg.DaylyCount)
  33077. for (var b = (new Date).setHours(0, 0, 0, 0), c = 0, d = a.log.length; c < d; c++) getdate(a.log[c].RegTime) > b && ("A" == a.log[c].Sts ? _Mvar.times++ : "F" == a.log[c].Sts && (_Mvar.chance += a.msg.Share, _Mvar.share++));
  33078. _Mvar.countdown = a.msg.CountDown;
  33079. $("#phone").val(a.user.Tel);
  33080. $("#truename").val(a.user.TrueName);
  33081. shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + a.user.Num + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.rank + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!";
  33082. // wxShare()
  33083. }
  33084. $(".tAll").html(a.count);
  33085. $(".tMaxCoin").html(a.msg.MaxCoin);
  33086. init(a)
  33087. // $.ajax({
  33088. // url: _Mvar.domain + "/UpcoinMobile/PowerEveryDay" + _Mvar.jsoncallback,
  33089. // type: "get",
  33090. // data: $("#form1").serialize(),
  33091. // dataType: "json",
  33092. // success: function(a) {
  33093. // if (a)
  33094. // if (a.success) {
  33095. // _Mvar.chance = a.msg.DaylyCount;
  33096. // if (a.user) {
  33097. // if (a.msg.DaylyCount)
  33098. // for (var b = (new Date).setHours(0, 0, 0, 0), c = 0, d = a.log.length; c < d; c++) getdate(a.log[c].RegTime) > b && ("A" == a.log[c].Sts ? _Mvar.times++ : "F" == a.log[c].Sts && (_Mvar.chance += a.msg.Share, _Mvar.share++));
  33099. // _Mvar.countdown = a.msg.CountDown;
  33100. // $("#phone").val(a.user.Tel);
  33101. // $("#truename").val(a.user.TrueName);
  33102. // shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + a.user.Num + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.rank + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!";
  33103. // wxShare()
  33104. // }
  33105. // $(".tAll").html(a.count);
  33106. // $(".tMaxCoin").html(a.msg.MaxCoin);
  33107. // init(a)
  33108. // } else a.msg && alert(a.msg)
  33109. // },
  33110. // error: function() {},
  33111. // complete: function() {}
  33112. // });
  33113. function init(a) {
  33114. console.log(a);
  33115. var b;
  33116. $(".iList").click(function() {
  33117. $(".dList").removeClass("hide");
  33118. getList1()
  33119. });
  33120. $(".iList1").click(function() {
  33121. $(".dList").removeClass("hide");
  33122. getList1()
  33123. });
  33124. $(".iAgain").click(function() {
  33125. $(".dGameOver,.dGame").addClass("hide");
  33126. $(".dIndex").removeClass("hide")
  33127. });
  33128. $(".iIndex").click(function() {
  33129. $(".dRule,.dList,.dForm").addClass("hide");
  33130. isInGame && (isInGame = 0, cc.director.resume())
  33131. });
  33132. $(".iIndex1").click(function() {
  33133. $(".dRule,.dList,.dForm,.dRule1,.dGameOver,.dGame").addClass("hide");
  33134. $(".dIndex").removeClass("hide")
  33135. });
  33136. $(".iShare").click(function() {
  33137. $(".dShare").removeClass("hide")
  33138. });
  33139. $(".dShare").click(function() {
  33140. $(this).addClass("hide")
  33141. });
  33142. $(".iStart333").click(function() {
  33143. location.href = "index.html"
  33144. });
  33145. $(".iStartGame").click(function() {
  33146. a.msg.DaylyCount && _Mvar.times >= a.msg.DaylyCount ? alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86\uff0c\u660e\u5929\u518d\u6765\u73a9\u5427\uff01") : $(".wfpop").removeClass("hide")
  33147. });
  33148. $(".iStart").click(function() {
  33149. a.user && a.user.Tel ? (b ? (cc.director.runScene(new PlayScene),
  33150. cc.director.resume()) : (b = 1, cc.game.run(), $("#loading").removeClass("hide")), $(".dIndex,.dGameOver").addClass("hide"), $(".dGame").removeClass("hide")) : $(".dForm").removeClass("hide");
  33151. $(".wfpop").addClass("hide")
  33152. });
  33153. $(".iGift").click(function() {
  33154. _Mvar.go || (_Mvar.go = 1, a.data && a.data.Tel && 30 <= _Mvar.num ? a.data1 ? location.href = "share.html?uid\x3d" + a.data.UserListID : ($("#sts").val("H"), $("#wxnum").val("0"), $.ajax({
  33155. url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback,
  33156. data: $("#form1").serialize(),
  33157. dataType: "json",
  33158. success: function(a) {
  33159. a && a.success && (location.href = "share.html?uid\x3d" + a.msg)
  33160. },
  33161. error: function() {
  33162. alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\u5e26\u6765\u7684\u9519\u8bef,\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5")
  33163. },
  33164. complete: function() {
  33165. _Mvar.go = 0
  33166. }
  33167. })) : (_Mvar.go = 0, alert("\u60a8\u8fd8\u6ca1\u6709\u9886\u53d6\u81ea\u5df1\u7684\u793c\u76d2\uff0c\u5feb\u53bb\u73a9\u6e38\u620f\u9886\u53d6\u5c5e\u4e8e\u81ea\u5df1\u7684\u5e78\u8fd0\u793c\u76d2\u5427\uff01")))
  33168. });
  33169. $(".iStart1").click(function() {
  33170. // if (a.msg.DaylyCount)
  33171. // if (_Mvar.times <
  33172. // a.msg.Share * _Mvar.share + a.msg.DaylyCount){
  33173. // _Mvar.times++;
  33174. // }else {
  33175. // a.msg.Share && _Mvar.times == a.msg.DaylyCount ? alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86,\u5206\u4eab\u5230\u670b\u53cb\u5708\u53ef\u4ee5\u83b7\u5f97\u989d\u5916" + a.msg.Share + "\u6b21\u673a\u4f1a") : alert("\u60a8\u4eca\u5929\u7684\u6e38\u620f\u6b21\u6570\u5df2\u7ecf\u7528\u5b8c\u4e86,\u660e\u5929\u518d\u6765\u73a9\u5427");
  33176. // return
  33177. // }
  33178. // alert(1);
  33179. $(".synum").html(a.msg.Share * _Mvar.share + a.msg.DaylyCount - _Mvar.times);
  33180. $(".wfpop").removeClass("hide")
  33181. });
  33182. $(".iClose1").click(function() {
  33183. $(".dGame_1").addClass("hide")
  33184. });
  33185. $(".iHelp").click(help);
  33186. $(".iBack").click(function() {
  33187. $(".dGameOver,.dGame").addClass("hide");
  33188. $(".dIndex").removeClass("hide");
  33189. return !1
  33190. });
  33191. $(".iInfo").click(function() {
  33192. $(".dIndex,.dGame,.dInfo,.dRule,.dList").addClass("hide");
  33193. $(".dInfo").removeClass("hide")
  33194. });
  33195. $(".iNext").click(function() {
  33196. $(".dGame1").addClass("hide");
  33197. $(".dGame2").removeClass("hide")
  33198. });
  33199. $(".iRule").click(function() {
  33200. $(".dRule").removeClass("hide")
  33201. });
  33202. $(".iRuleClose").click(function() {
  33203. $(".dRule").addClass("hide")
  33204. });
  33205. $(".iRule1").click(function() {
  33206. $(".dIndex").addClass("hide");
  33207. $(".dRule1").removeClass("hide")
  33208. });
  33209. $(".iRule1Close").click(function() {
  33210. $(".dRule1").addClass("hide");
  33211. $(".dIndex").removeClass("hide")
  33212. });
  33213. $(".iClose1").click(function() {
  33214. $(".dForm").addClass("hide")
  33215. });
  33216. $(".iSave").click(function() {
  33217. if (0 > new Date - eval("new " + (a.msg.StartTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u672a\u5f00\u59cb!");
  33218. else if (0 < new Date - eval("new " + (a.msg.EndTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u5df2\u7ed3\u675f!");
  33219. else if (!_Mvar.go)
  33220. if (_Mvar.go = 1, $("#truename").val()) {
  33221. var c = $("#phone").val();
  33222. isNaN(c) || 11 != c.length ? (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u624b\u673a\u53f7\uff01")) : $.ajax({
  33223. url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback,
  33224. data: $("#form1").serialize(),
  33225. dataType: "json",
  33226. success: function(a) {},
  33227. complete: function() {
  33228. alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f\uff01");
  33229. $(".dForm,.dIndex").addClass("hide");
  33230. a.user = {
  33231. Tel: 1
  33232. };
  33233. $("#loading,.dGame").removeClass("hide");
  33234. b = 1;
  33235. cc.game.run();
  33236. _Mvar.go = 0
  33237. }
  33238. })
  33239. } else _Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d\uff01")
  33240. });
  33241. $(".iStart2").click(function() {
  33242. location.href = "index.html"
  33243. });
  33244. $(".iStart4").click(function() {
  33245. $(".dGame1").addClass("hide");
  33246. if ($(".tPrize").html()) $(".dResult").removeClass("hide");
  33247. else {
  33248. $(".dGame2").removeClass("hide");
  33249. var b = 0;
  33250. a.data && a.data.Num && (b = a.data.Num);
  33251. var d = a.msg.MaxCoin - b;
  33252. $(".tHelper").html(b);
  33253. $(".tHelper1").html(d);
  33254. $(".tJingdu").css("width", b / a.msg.MaxCoin * 100 + "%");
  33255. d ? $(".dGame2_1").removeClass("hide") :
  33256. ($(".findhelp").addClass("hide"), $(".dGame2_2").removeClass("hide"))
  33257. }
  33258. });
  33259. $(".iStart3").click(function() {
  33260. if (!_Mvar.go) {
  33261. _Mvar.go = 1;
  33262. $("#sts").val("P1");
  33263. var a = "\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898,\u8bf7\u91cd\u8fdb\u9875\u9762\u91cd\u8bd5!";
  33264. $.ajax({
  33265. url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback,
  33266. data: $("#form1").serialize(),
  33267. cache: !1,
  33268. dataType: "json",
  33269. success: function(b) {
  33270. b && b.success && ($(".tPrize").html(b.data), $(".tPrize1").attr("src", "images/" + _Mvar.prize.indexOf(b.data.substr(0,
  33271. 1)) + ".jpg"), $(".dResult").removeClass("hide"), $(".dGame2,.dGame2_2").addClass("hide"), a = b.data, a = "")
  33272. },
  33273. complete: function() {
  33274. a && alert(a);
  33275. _Mvar.go = 0
  33276. }
  33277. })
  33278. }
  33279. });
  33280. $(".iSave2").click(function() {
  33281. if (0 > new Date - eval("new " + (a.msg.StartTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u672a\u5f00\u59cb!");
  33282. else if (0 < new Date - eval("new " + (a.msg.EndTime + "").replace(/\//g, ""))) alert("\u6d3b\u52a8\u5df2\u7ed3\u675f!");
  33283. else if (!_Mvar.go) {
  33284. _Mvar.go = 1;
  33285. var b = $("#truename").val();
  33286. if (b) {
  33287. var d = $("#phone").val();
  33288. isNaN(d) || 11 != d.length ?
  33289. (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u624b\u673a\u53f7\uff01")) : ($("#truename1").val(b), $("#phone1").val(d), $.ajax({
  33290. url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback,
  33291. data: $("#form").serialize(),
  33292. dataType: "json",
  33293. success: function(b) {
  33294. b ? b.success ? (a.data = {
  33295. Tel: "121212"
  33296. }, alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f!"), $(".dForm").addClass("hide"), _Mvar.times += 1, $("#otherid1").val(_Mvar.times), postData1(), $(".dIndex,.dGameOver").addClass("hide"), $(".dGame").removeClass("hide"),
  33297. mg_Game.on = 0, mg_Game.reStart()) : b.msg && alert(b.msg) : alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")
  33298. },
  33299. error: function() {
  33300. alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")
  33301. },
  33302. complete: function() {}
  33303. }), $.ajax({
  33304. url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback,
  33305. data: $("#form1").serialize(),
  33306. dataType: "json",
  33307. success: function(a) {},
  33308. error: function() {},
  33309. complete: function() {
  33310. _Mvar.go = 0
  33311. }
  33312. }))
  33313. } else _Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d\uff01")
  33314. }
  33315. });
  33316. $(".iSave1").click(function() {
  33317. if (!_Mvar.go) {
  33318. _Mvar.go = 1;
  33319. var a = $("#truename1").val();
  33320. a ? (a = $("#phone1").val(), isNaN(a) || 11 != a.length ? (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801!")) : ($("#truename").val($("#truename1").val()), $("#phone").val($("#phone1").val()), $("#sts").val("A"), $("#wxid").val(_Mvar.wxid), $.ajax({
  33321. url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback,
  33322. data: $("#form1").serialize(),
  33323. dataType: "json",
  33324. success: function(a) {
  33325. a && (a.success ? (alert("\u4fe1\u606f\u63d0\u4ea4\u6210\u529f!"),
  33326. _Mvar.uid = a.msg, $(".dRotateResult").addClass("hide"), $(".dIndex").removeClass("hide")) : alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!"))
  33327. },
  33328. error: function() {
  33329. alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")
  33330. },
  33331. complete: function() {
  33332. _Mvar.go = 0
  33333. }
  33334. }))) : (_Mvar.go = 0, alert("\u8bf7\u7559\u4e0b\u60a8\u7684\u59d3\u540d!"))
  33335. }
  33336. });
  33337. $(".iList111").click(function() {
  33338. $(".dResult").addClass("hide");
  33339. $(".dList1").removeClass("hide");
  33340. if (!_Mvar.go) {
  33341. _Mvar.go =
  33342. 1;
  33343. var a = '\x3cul class\x3d"info_one"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898,\u6570\u636e\u65e0\u6cd5\u52a0\u8f7d,\u8bf7\u91cd\u8bd5!\x3c/li\x3e\x3c/ul\x3e';
  33344. $.ajax({
  33345. url: _Mvar.domain + "/UpCoinMobile/PowerList" + _Mvar.jsoncallback,
  33346. data: $("#form1").serialize(),
  33347. dataType: "json",
  33348. success: function(b) {
  33349. if (b) {
  33350. $(".info_one").remove();
  33351. $(".dAll").html(b.success);
  33352. $(".dTotal").html(b.msg);
  33353. var e = b.data.length;
  33354. e && (a = "");
  33355. for (var f = 0; f < e; f += 1) a += '\x3cul class\x3d"info_one"\x3e\x3cli\x3e\x3cimg src\x3d"' +
  33356. (1 < b.data[f].Img.length ? b.data[f].Img.substr(0, b.data[f].Img.length - 1) + "46" : b.data[f].Img) + '"\x3e\x3c/li\x3e\x3cli\x3e\x3cspan class\x3d"name"\x3e' + b.data[f].Name + '\x3c/span\x3e\x3c/li\x3e\x3cli class\x3d"kj_num"\x3e\uffe5' + b.data[f].Coin + "\x3c/li\x3e\x3c/ul\x3e"
  33357. }
  33358. },
  33359. complete: function() {
  33360. a && ($(".dRList1").after(a), $(".dList1 .info_one:last").addClass("no_dashed"));
  33361. _Mvar.go = 0
  33362. }
  33363. })
  33364. }
  33365. })
  33366. }
  33367. function help() {
  33368. $("#sts").val("H");
  33369. $("#wxnum").val(_Mvar.wxNum);
  33370. $.ajax({
  33371. url: _Mvar.domain + "/UpCoinMobile/PowerRegiste" + _Mvar.jsoncallback,
  33372. data: $("#form1").serialize(),
  33373. dataType: "json",
  33374. success: function(a) {},
  33375. complete: function() {}
  33376. })
  33377. }
  33378. function getList() {
  33379. var a = "\x3cul\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u91cd\u8bd5!\x3c/ul\x3e";
  33380. $.ajax({
  33381. url: _Mvar.domain + "/UpCoinMobile/PowerList2" + _Mvar.jsoncallback,
  33382. data: $("#form1").serialize(),
  33383. dataType: "json",
  33384. success: function(b) {
  33385. var c = "";
  33386. if (b)
  33387. if ($(".tAll").html(b.success), b.success) {
  33388. b = b.msg;
  33389. var d = b.length;
  33390. if (d) {
  33391. for (var e = 0; e < d; e += 1) c += '\x3cul class\x3d"listmd' + (e % 2 ? " jishuline" : "") + '"\x3e\x3cli\x3e\x3cimg src\x3d"' + (1 < b[e].HeadimgUrl.length ? b[e].HeadimgUrl.substr(0, b[e].HeadimgUrl.length -
  33392. 1) + "46" : b[e].HeadimgUrl) + '"/\x3e\x3cspan\x3e' + (8 < b[e].NickName.length ? b[e].NickName.substr(0, 8) : b[e].NickName) + "\x3c/span\x3e\x3c/li\x3e\x3cli\x3e" + b[e].Tel + "\x3c/li\x3e\x3cli\x3e" + b[e].Remark + "\x3c/li\x3e\x3c/ul\x3e";
  33393. a = c
  33394. } else a = '\x3cul class\x3d"listmd"\x3e\u6682\u65e0\u7528\u6237\u83b7\u5956\x3c/ul\x3e'
  33395. } else a = b.msg.length ? b.msg : '\x3cul class\x3d"listmd"\x3e\u6682\u65e0\u7528\u6237\u53c2\u4e0e\x3c/ul\x3e'
  33396. },
  33397. complete: function() {
  33398. $(".dList1").html(a)
  33399. }
  33400. })
  33401. }
  33402. function getList1() {
  33403. var a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u91cd\u8bd5!\x3c/li\x3e\x3c/ul\x3e';
  33404. $.ajax({
  33405. url: _Mvar.domain + "/UpCoinMobile/PowerList1" + _Mvar.jsoncallback,
  33406. data: $("#form1").serialize(),
  33407. dataType: "json",
  33408. success: function(b) {
  33409. var c = "";
  33410. if (b && b.success) {
  33411. var d = b.data,
  33412. e = b.data.length;
  33413. $(".tAll").html(e);
  33414. if (e) {
  33415. for (var f = 0; f < e; f += 1) c += '\x3cul class\x3d"listmd"\x3e\x3cli\x3e' + (f + 1) + '\x3c/li\x3e\x3cli\x3e\x3cimg src\x3d"' +
  33416. (1 < d[f].Img.length ? d[f].Img.substr(0, d[f].Img.length - 1) + "46" : d[f].Img) + '"\x3e\x3cspan\x3e' + (8 < d[f].Name.length ? d[f].Name.substr(0, 8) : d[f].Name) + "\x3c/span\x3e\x3c/li\x3e\x3cli\x3e" + d[f].Coin + "\x3c/li\x3e\x3c/ul\x3e";
  33417. a = c;
  33418. b.data1 && $(".dListResult1").html('\x3ctr class\x3d"my_phb"\x3e\x3ctd width\x3d"25%"\x3e' + (b.data1.count ? b.data1.count : "") + '\x3c/td\x3e\x3ctd width\x3d"50%"\x3e\x3cimg src\x3d"' + (1 < b.data1.Img.length ? b.data1.Img.substr(0, b.data1.Img.length - 1) + "46" : b.data1.Img) + '" alt\x3d""\x3e' + (8 <
  33419. b.data1.Name.length ? b.data1.Name.substr(0, 8) : b.data1.Name) + '\x3c/td\x3e\x3ctd width\x3d"25%"\x3e' + b.data1.Coin + "\x3c/td\x3e\x3c/tr\x3e")
  33420. } else a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u6682\u65e0\u7528\u6237\u53c2\u4e0e\x3c/li\x3e\x3c/ul\x3e'
  33421. } else a = b.msg && b.msg.length ? b.msg : '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u65e0\u6cd5\u8bfb\u53d6\u6570\u636e\x3c/li\x3e\x3c/ul\x3e'
  33422. },
  33423. error: function() {
  33424. a = '\x3cul class\x3d"listmd"\x3e\x3cli\x3e\x3c/li\x3e\x3cli\x3e\u65e0\u6cd5\u8bfb\u53d6\u6570\u636e\x3c/li\x3e\x3c/ul\x3e'
  33425. },
  33426. complete: function() {
  33427. $(".dListResult").html(a)
  33428. }
  33429. })
  33430. }
  33431. function postData() {
  33432. $.ajax({
  33433. url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback,
  33434. data: $("#form1").serialize(),
  33435. dataType: "json",
  33436. success: function(a) {
  33437. a && a.success && ($(".iOrder").html(a.msg), $(".dOrder").removeClass("hide"), shareData.title = "\u6211\u5728\u5954\u8dd1\u5427\uff01soho \u6e38\u620f\u91cc\u62ff\u4e86" + $("#num").val() + "\u79ef\u5206,\u76ee\u524d\u6392\u540d\u7b2c" + a.msg + ",\u5feb\u6765\u4e00\u8d77\u6311\u6218\u5427!", wxShare())
  33438. },
  33439. error: function() {},
  33440. complete: function() {}
  33441. })
  33442. }
  33443. function postData1() {
  33444. $.ajax({
  33445. url: _Mvar.domain + "/UpCoinMobile/UpCoinDZData" + _Mvar.jsoncallback,
  33446. data: $("#form1").serialize(),
  33447. dataType: "json",
  33448. success: function(a) {
  33449. a || alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")
  33450. },
  33451. error: function() {
  33452. alert("\u53ef\u80fd\u662f\u7f51\u7edc\u539f\u56e0\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5!")
  33453. },
  33454. complete: function() {}
  33455. })
  33456. }
  33457. cc.game.onStart = function() {
  33458. cc.log(cc.sys.isNative);
  33459. !cc.sys.isNative && document.getElementById("cocosLoading") && document.body.removeChild(document.getElementById("cocosLoading"));
  33460. cc.view.enableAutoFullScreen(!1);
  33461. cc.view.enableRetina(!1);
  33462. cc.view.adjustViewPort(!0);
  33463. cc.view.setDesignResolutionSize(320, 568, cc.ResolutionPolicy.EXACT_FIT);
  33464. cc.view.resizeWithBrowserSize(!0);
  33465. cc.loader.load(g_resources, function(a, b, c) {
  33466. a = Math.min(100 * c / b | 0, 100);
  33467. $("#loadnum").html("\u52a0\u8f7d\u4e2d" + a + "%")
  33468. }, function() {
  33469. $("#loading").addClass("hide");
  33470. cc.director.runScene(new PlayScene)
  33471. })
  33472. };