game.min.js 770 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432
  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) if (a instanceof Array) for (var d = 0, e = a.length; d < e && !1 !== b.call(c, a[d], d) ; d++);
  16. else for (d in a) if (!1 === b.call(c, a[d], d)) break
  17. };
  18. cc.extend = function (a) {
  19. var b = 2 <= arguments.length ? Array.prototype.slice.call(arguments, 1) : [];
  20. cc.each(b,
  21. function (b) {
  22. for (var d in b) b.hasOwnProperty(d) && (a[d] = b[d])
  23. });
  24. return a
  25. };
  26. cc.isFunction = function (a) {
  27. return "function" == typeof a
  28. };
  29. cc.isNumber = function (a) {
  30. return "number" == typeof a || "[object Number]" == Object.prototype.toString.call(a)
  31. };
  32. cc.isString = function (a) {
  33. return "string" == typeof a || "[object String]" == Object.prototype.toString.call(a)
  34. };
  35. cc.isArray = function (a) {
  36. return "[object Array]" == Object.prototype.toString.call(a)
  37. };
  38. cc.isUndefined = function (a) {
  39. return "undefined" == typeof a
  40. };
  41. cc.isObject = function (a) {
  42. var b = typeof a;
  43. return "function" == b || a && "object" == b
  44. };
  45. cc.isCrossOrigin = function (a) {
  46. if (!a) return cc.log("invalid URL"),
  47. !1;
  48. var b = a.indexOf("://");
  49. if (-1 == b) return !1;
  50. b = a.indexOf("/", b + 3);
  51. return (-1 == b ? a : a.substring(0, b)) != location.origin
  52. };
  53. cc.AsyncPool = function (a, b, c, d, e) {
  54. var f = this;
  55. f._srcObj = a;
  56. f._limit = b;
  57. f._pool = [];
  58. f._iterator = c;
  59. f._iteratorTarget = e;
  60. f._onEnd = d;
  61. f._onEndTarget = e;
  62. f._results = a instanceof Array ? [] : {};
  63. f._isErr = !1;
  64. cc.each(a,
  65. 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 && !(a._workingSize >= a._limit)) {
  86. var b = a._pool.shift(),
  87. c = b.value,
  88. d = b.index;
  89. a._workingSize++;
  90. a._iterator.call(a._iteratorTarget, c, d,
  91. function (b) {
  92. if (!a._isErr) if (a.finishedSize++, a._workingSize--, b) a._isErr = !0,
  93. 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, null, []);
  104. else for (var a = 0; a < this._limit; a++) this._handleItem()
  105. }
  106. };
  107. cc.async = {
  108. series: function (a, b, c) {
  109. a = new cc.AsyncPool(a, 1,
  110. function (a, b, f) {
  111. a.call(c, f)
  112. },
  113. b, c);
  114. a.flow();
  115. return a
  116. },
  117. parallel: function (a, b, c) {
  118. a = new cc.AsyncPool(a, 0,
  119. function (a, b, f) {
  120. a.call(c, f)
  121. },
  122. b, c);
  123. a.flow();
  124. return a
  125. },
  126. waterfall: function (a, b, c) {
  127. var d = [];
  128. a = new cc.AsyncPool(a, 1,
  129. function (a, b, g) {
  130. d.push(function (a) {
  131. d = Array.prototype.slice.call(arguments, 1);
  132. g.apply(null, arguments)
  133. });
  134. a.apply(c, d)
  135. },
  136. function (a, d) {
  137. if (b) {
  138. if (a) return b.call(c, a);
  139. b.call(c, null, d[d.length - 1])
  140. }
  141. });
  142. a.flow();
  143. return a
  144. },
  145. map: function (a, b, c, d) {
  146. var e = b;
  147. "object" == typeof b && (c = b.cb, d = b.iteratorTarget, e = b.iterator);
  148. a = new cc.AsyncPool(a, 0, e, c, d);
  149. a.flow();
  150. return a
  151. },
  152. mapLimit: function (a, b, c, d, e) {
  153. a = new cc.AsyncPool(a, b, c, d, e);
  154. a.flow();
  155. return a
  156. }
  157. };
  158. cc.path = {
  159. join: function () {
  160. for (var a = arguments.length, b = "", c = 0; c < a; c++) b = (b + ("" == b ? "" : "/") + arguments[c]).replace(/(\/|\\\\)$/, "");
  161. return b
  162. },
  163. extname: function (a) {
  164. return (a = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a)) ? a[1] : null
  165. },
  166. mainFileName: function (a) {
  167. if (a) {
  168. var b = a.lastIndexOf(".");
  169. if (-1 !== b) return a.substring(0, b)
  170. }
  171. return a
  172. },
  173. basename: function (a, b) {
  174. var c = a.indexOf("?");
  175. 0 < c && (a = a.substring(0, c));
  176. c = /(\/|\\\\)([^(\/|\\\\)]+)$/g.exec(a.replace(/(\/|\\\\)$/, ""));
  177. if (!c) return null;
  178. c = c[2];
  179. return b && a.substring(a.length -
  180. b.length).toLowerCase() == b.toLowerCase() ? c.substring(0, c.length - b.length) : c
  181. },
  182. dirname: function (a) {
  183. return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/, "$2")
  184. },
  185. changeExtname: function (a, b) {
  186. b = b || "";
  187. var c = a.indexOf("?"),
  188. d = "";
  189. 0 < c && (d = a.substring(c), a = a.substring(0, c));
  190. c = a.lastIndexOf(".");
  191. return 0 > c ? a + b + d : a.substring(0, c) + b + d
  192. },
  193. changeBasename: function (a, b, c) {
  194. if (0 == b.indexOf(".")) return this.changeExtname(a, b);
  195. var d = a.indexOf("?"),
  196. e = "";
  197. c = c ? this.extname(a) : "";
  198. 0 < d && (e = a.substring(d), a = a.substring(0, d));
  199. d = a.lastIndexOf("/");
  200. return a.substring(0, 0 >= d ? 0 : d + 1) + b + c + e
  201. }
  202. };
  203. cc.loader = {
  204. _jsCache: {},
  205. _register: {},
  206. _langPathCache: {},
  207. _aliases: {},
  208. resPath: "",
  209. audioPath: "",
  210. cache: {},
  211. getXMLHttpRequest: function () {
  212. return window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSXML2.XMLHTTP")
  213. },
  214. _getArgs4Js: function (a) {
  215. var b = a[0],
  216. c = a[1],
  217. d = a[2],
  218. e = ["", null, null];
  219. if (1 === a.length) e[1] = b instanceof Array ? b : [b];
  220. 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]);
  221. else if (3 === a.length) e[0] = b || "",
  222. e[1] = c instanceof
  223. Array ? c : [c],
  224. e[2] = d;
  225. else throw "arguments error to load js!";
  226. return e
  227. },
  228. loadJs: function (a, b, c) {
  229. var d = this,
  230. e = d._jsCache,
  231. f = d._getArgs4Js(arguments),
  232. g = f[0],
  233. h = f[1],
  234. f = f[2]; -1 < navigator.userAgent.indexOf("Trident/5") ? d._loadJs4Dependency(g, h, 0, f) : cc.async.map(h,
  235. function (a, b, c) {
  236. a = cc.path.join(g, a);
  237. if (e[a]) return c(null);
  238. d._createScript(a, !1, c)
  239. },
  240. f)
  241. },
  242. loadJsWithImg: function (a, b, c) {
  243. var d = this._loadJsImg(),
  244. e = this._getArgs4Js(arguments);
  245. this.loadJs(e[0], e[1],
  246. function (a) {
  247. if (a) throw a;
  248. d.parentNode.removeChild(d);
  249. if (e[2]) e[2]()
  250. })
  251. },
  252. _createScript: function (a, b, c) {
  253. var d = document,
  254. e = cc.newElement("script");
  255. e.async = b;
  256. e.src = a;
  257. this._jsCache[a] = !0;
  258. cc._addEventListener(e, "load",
  259. function () {
  260. e.parentNode.removeChild(e);
  261. this.removeEventListener("load", arguments.callee, !1);
  262. c()
  263. },
  264. !1);
  265. cc._addEventListener(e, "error",
  266. function () {
  267. e.parentNode.removeChild(e);
  268. c("Load " + a + " failed!")
  269. },
  270. !1);
  271. d.body.appendChild(e)
  272. },
  273. _loadJs4Dependency: function (a, b, c, d) {
  274. if (c >= b.length) d && d();
  275. else {
  276. var e = this;
  277. e._createScript(cc.path.join(a, b[c]), !1,
  278. function (f) {
  279. if (f) return d(f);
  280. e._loadJs4Dependency(a, b, c + 1, d)
  281. })
  282. }
  283. },
  284. _loadJsImg: function () {
  285. var a = document,
  286. b = a.getElementById("cocos2d_loadJsImg");
  287. if (!b) {
  288. b = cc.newElement("img");
  289. cc._loadingImage && (b.src = cc._loadingImage);
  290. a = a.getElementById(cc.game.config.id);
  291. a.style.backgroundColor = "black";
  292. a.parentNode.appendChild(b);
  293. var c = getComputedStyle ? getComputedStyle(a) : a.currentStyle;
  294. c || (c = {
  295. width: a.width,
  296. height: a.height
  297. });
  298. b.style.left = a.offsetLeft + (parseFloat(c.width) - b.width) / 2 + "px";
  299. b.style.top = a.offsetTop + (parseFloat(c.height) - b.height) / 2 + "px";
  300. b.style.position = "absolute"
  301. }
  302. return b
  303. },
  304. loadTxt: function (a, b) {
  305. if (cc._isNodeJs) require("fs").readFile(a,
  306. function (a, c) {
  307. a ? b(a) : b(null, c.toString())
  308. });
  309. else {
  310. var c = this.getXMLHttpRequest(),
  311. d = "load " + a + " failed!";
  312. c.open("GET", a, !0);
  313. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (c.setRequestHeader("Accept-Charset", "utf-8"), c.onreadystatechange = function () {
  314. 4 == c.readyState && (200 == c.status ? b(null, c.responseText) : b(d))
  315. }) : (c.overrideMimeType && c.overrideMimeType("text/plain; charset\x3dutf-8"), c.onload = function () {
  316. 4 == c.readyState && (200 == c.status ? b(null, c.responseText) : b(d))
  317. });
  318. c.send(null)
  319. }
  320. },
  321. _loadTxtSync: function (a) {
  322. if (cc._isNodeJs) return require("fs").readFileSync(a).toString();
  323. var b = this.getXMLHttpRequest();
  324. b.open("GET", a, !1);
  325. /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");
  326. b.send(null);
  327. return 4 == !b.readyState || 200 != b.status ? null : b.responseText
  328. },
  329. loadJson: function (a, b) {
  330. this.loadTxt(a,
  331. function (c, d) {
  332. try {
  333. c ? b(c) : b(null, JSON.parse(d))
  334. } catch (e) {
  335. throw "load json [" + a + "] failed : " + e;
  336. }
  337. })
  338. },
  339. _checkIsImageURL: function (a) {
  340. return null != /(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a)
  341. },
  342. loadImg: function (a, b, c) {
  343. var d = {
  344. isCrossOrigin: !0
  345. };
  346. void 0 !== c ? d.isCrossOrigin = null == b.isCrossOrigin ? d.isCrossOrigin : b.isCrossOrigin : void 0 !== b && (c = b);
  347. var e = new Image;
  348. d.isCrossOrigin && "file://" != location.origin && (e.crossOrigin = "Anonymous");
  349. var f = function () {
  350. this.removeEventListener("load", f, !1);
  351. this.removeEventListener("error", g, !1);
  352. c && c(null, e)
  353. },
  354. g = function () {
  355. this.removeEventListener("error", g, !1);
  356. "anonymous" == e.crossOrigin.toLowerCase() ? (d.isCrossOrigin = !1, cc.loader.loadImg(a, d, c)) : "function" == typeof c && c("load image failed")
  357. };
  358. cc._addEventListener(e, "load", f);
  359. cc._addEventListener(e, "error", g);
  360. e.src = a;
  361. return e
  362. },
  363. _loadResIterator: function (a, b, c) {
  364. var d = this,
  365. e = null,
  366. f = a.type;
  367. f ? (f = "." + f.toLowerCase(), e = a.src ? a.src : a.name + f) : (e = a, f = cc.path.extname(e));
  368. if (b = d.cache[e]) return c(null, b);
  369. b = d._register[f.toLowerCase()];
  370. if (!b) return cc.error("loader for [" + f + "] not exists!"),
  371. c();
  372. f = b.getBasePath ? b.getBasePath() : d.resPath;
  373. f = d.getUrl(f, e);
  374. b.load(f, e, a,
  375. function (a, b) {
  376. a ? (cc.log(a), d.cache[e] = null, delete d.cache[e], c()) : (d.cache[e] = b, c(null, b))
  377. })
  378. },
  379. getUrl: function (a, b) {
  380. var c = this._langPathCache,
  381. d = cc.path;
  382. if (void 0 !== a && void 0 === b) {
  383. b = a;
  384. var e = d.extname(b),
  385. e = e ? e.toLowerCase() : "";
  386. a = (e = this._register[e]) ? e.getBasePath ? e.getBasePath() : this.resPath : this.resPath
  387. }
  388. b = cc.path.join(a || "", b);
  389. if (b.match(/[\/(\\\\)]lang[\/(\\\\)]/i)) {
  390. if (c[b]) return c[b];
  391. d = d.extname(b) || "";
  392. b = c[b] = b.substring(0, b.length - d.length) + "_" + cc.sys.language + d
  393. }
  394. return b
  395. },
  396. load: function (a, b, c) {
  397. var d = this,
  398. e = arguments.length;
  399. if (0 == e) throw "arguments error!";
  400. 3 == e ? "function" == typeof b && (b = "function" == typeof c ? {
  401. trigger: b,
  402. cb: c
  403. } : {
  404. cb: b,
  405. cbTarget: c
  406. }) : 2 == e ? "function" == typeof b && (b = {
  407. cb: b
  408. }) : 1 == e && (b = {});
  409. a instanceof Array || (a = [a]);
  410. e = new cc.AsyncPool(a, 0,
  411. function (a, c, e, k) {
  412. d._loadResIterator(a, c,
  413. function (a) {
  414. if (a) return e(a);
  415. var c = Array.prototype.slice.call(arguments, 1);
  416. b.trigger && b.trigger.call(b.triggerTarget, c[0], k.size, k.finishedSize);
  417. e(null, c[0])
  418. })
  419. },
  420. b.cb, b.cbTarget);
  421. e.flow();
  422. return e
  423. },
  424. _handleAliases: function (a, b) {
  425. var c = this._aliases,
  426. d = [],
  427. e;
  428. for (e in a) {
  429. var f = a[e];
  430. c[e] = f;
  431. d.push(f)
  432. }
  433. this.load(d, b)
  434. },
  435. loadAliases: function (a, b) {
  436. var c = this,
  437. d = c.getRes(a);
  438. d ? c._handleAliases(d.filenames, b) : c.load(a,
  439. function (a, d) {
  440. c._handleAliases(d[0].filenames, b)
  441. })
  442. },
  443. register: function (a, b) {
  444. if (a && b) {
  445. if ("string" == typeof a) return this._register[a.trim().toLowerCase()] = b;
  446. for (var c = 0, d = a.length; c < d; c++) this._register["." + a[c].trim().toLowerCase()] = b
  447. }
  448. },
  449. getRes: function (a) {
  450. return this.cache[a] || this.cache[this._aliases[a]]
  451. },
  452. release: function (a) {
  453. var b = this.cache,
  454. c = this._aliases;
  455. delete b[a];
  456. delete b[c[a]];
  457. delete c[a]
  458. },
  459. releaseAll: function () {
  460. var a = this.cache,
  461. b = this._aliases,
  462. c;
  463. for (c in a) delete a[c];
  464. for (c in b) delete b[c]
  465. }
  466. };
  467. cc.formatStr = function () {
  468. var a = arguments,
  469. b = a.length;
  470. if (1 > b) return "";
  471. var c = a[0],
  472. d = !0;
  473. "object" == typeof c && (d = !1);
  474. for (var e = 1; e < b; ++e) {
  475. var f = a[e];
  476. if (d) for (; ;) {
  477. var g = null;
  478. if ("number" == typeof f && (g = c.match(/(%d)|(%s)/))) {
  479. c = c.replace(/(%d)|(%s)/, f);
  480. break
  481. }
  482. c = (g = c.match(/%s/)) ? c.replace(/%s/, f) : c + (" " + f);
  483. break
  484. } else c += " " + f
  485. }
  486. return c
  487. }; (function () {
  488. var a = window,
  489. b,
  490. c;
  491. 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");
  492. var d = function () {
  493. cc.eventManager && cc.game._eventHide && cc.eventManager.dispatchEvent(cc.game._eventHide)
  494. },
  495. e = function () {
  496. cc.eventManager && cc.game._eventShow && cc.eventManager.dispatchEvent(cc.game._eventShow);
  497. cc.game._intervalId && (window.cancelAnimationFrame(cc.game._intervalId), cc.game._runMainLoop())
  498. };
  499. b ? cc._addEventListener(document, c,
  500. function () {
  501. document[b] ? d() : e()
  502. },
  503. !1) : (cc._addEventListener(a, "blur", d, !1), cc._addEventListener(a, "focus", e, !1)); -1 < navigator.userAgent.indexOf("MicroMessenger") && (a.onfocus = function () {
  504. e()
  505. });
  506. "onpageshow" in window && "onpagehide" in window && (cc._addEventListener(a, "pagehide", d, !1), cc._addEventListener(a, "pageshow", e, !1));
  507. c = a = null
  508. })();
  509. cc.log = cc.warn = cc.error = cc.assert = function () { };
  510. cc.create3DContext = function (a, b) {
  511. for (var c = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], d = null, e = 0; e < c.length; ++e) {
  512. try {
  513. d = a.getContext(c[e], b)
  514. } catch (f) { }
  515. if (d) break
  516. }
  517. return d
  518. };
  519. cc._initSys = function (a, b) {
  520. cc._RENDER_TYPE_CANVAS = 0;
  521. cc._RENDER_TYPE_WEBGL = 1;
  522. cc.sys = {};
  523. var c = cc.sys;
  524. c.LANGUAGE_ENGLISH = "en";
  525. c.LANGUAGE_CHINESE = "zh";
  526. c.LANGUAGE_FRENCH = "fr";
  527. c.LANGUAGE_ITALIAN = "it";
  528. c.LANGUAGE_GERMAN = "de";
  529. c.LANGUAGE_SPANISH = "es";
  530. c.LANGUAGE_DUTCH = "du";
  531. c.LANGUAGE_RUSSIAN = "ru";
  532. c.LANGUAGE_KOREAN = "ko";
  533. c.LANGUAGE_JAPANESE = "ja";
  534. c.LANGUAGE_HUNGARIAN = "hu";
  535. c.LANGUAGE_PORTUGUESE = "pt";
  536. c.LANGUAGE_ARABIC = "ar";
  537. c.LANGUAGE_NORWEGIAN = "no";
  538. c.LANGUAGE_POLISH = "pl";
  539. c.OS_WINDOWS = "Windows";
  540. c.OS_IOS = "iOS";
  541. c.OS_OSX = "OS X";
  542. c.OS_UNIX = "UNIX";
  543. c.OS_LINUX = "Linux";
  544. c.OS_ANDROID = "Android";
  545. c.OS_UNKNOWN = "Unknown";
  546. c.WINDOWS = 0;
  547. c.LINUX = 1;
  548. c.MACOS = 2;
  549. c.ANDROID = 3;
  550. c.IPHONE = 4;
  551. c.IPAD = 5;
  552. c.BLACKBERRY = 6;
  553. c.NACL = 7;
  554. c.EMSCRIPTEN = 8;
  555. c.TIZEN = 9;
  556. c.WINRT = 10;
  557. c.WP8 = 11;
  558. c.MOBILE_BROWSER = 100;
  559. c.DESKTOP_BROWSER = 101;
  560. c.BROWSER_TYPE_WECHAT = "wechat";
  561. c.BROWSER_TYPE_ANDROID = "androidbrowser";
  562. c.BROWSER_TYPE_IE = "ie";
  563. c.BROWSER_TYPE_QQ = "qqbrowser";
  564. c.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
  565. c.BROWSER_TYPE_UC = "ucbrowser";
  566. c.BROWSER_TYPE_360 = "360browser";
  567. c.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
  568. c.BROWSER_TYPE_BAIDU = "baidubrowser";
  569. c.BROWSER_TYPE_MAXTHON = "maxthon";
  570. c.BROWSER_TYPE_OPERA = "opera";
  571. c.BROWSER_TYPE_OUPENG = "oupeng";
  572. c.BROWSER_TYPE_MIUI = "miuibrowser";
  573. c.BROWSER_TYPE_FIREFOX = "firefox";
  574. c.BROWSER_TYPE_SAFARI = "safari";
  575. c.BROWSER_TYPE_CHROME = "chrome";
  576. c.BROWSER_TYPE_UNKNOWN = "unknown";
  577. c.isNative = !1;
  578. var d = [c.BROWSER_TYPE_BAIDU, c.BROWSER_TYPE_OPERA, c.BROWSER_TYPE_FIREFOX, c.BROWSER_TYPE_CHROME, c.BROWSER_TYPE_SAFARI],
  579. e = [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],
  580. f = window,
  581. g = f.navigator,
  582. h = document.documentElement,
  583. k = g.userAgent.toLowerCase();
  584. c.isMobile = -1 != k.indexOf("mobile") || -1 != k.indexOf("android");
  585. c.platform = c.isMobile ? c.MOBILE_BROWSER : c.DESKTOP_BROWSER;
  586. var m = g.language,
  587. m = (m = m ? m : g.browserLanguage) ? m.split("-")[0] : c.LANGUAGE_ENGLISH;
  588. c.language = m;
  589. var m = c.BROWSER_TYPE_UNKNOWN,
  590. n = k.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baiduboxapp|baidubrowser|maxthon|trident|oupeng|opera|miuibrowser|firefox/i) || k.match(/chrome|safari/i);
  591. n && 0 < n.length && (m = n[0].toLowerCase(), "micromessenger" == m ? m = c.BROWSER_TYPE_WECHAT : "safari" === m && k.match(/android.*applewebkit/) ? m = c.BROWSER_TYPE_ANDROID : "trident" == m && (m = c.BROWSER_TYPE_IE));
  592. c.browserType = m;
  593. c._supportMultipleAudio = -1 < e.indexOf(c.browserType);
  594. e = parseInt(a[b.renderMode]);
  595. m = cc._RENDER_TYPE_WEBGL;
  596. n = cc.newElement("Canvas");
  597. cc._supportRender = !0;
  598. d = -1 == d.indexOf(c.browserType);
  599. if (1 === e || 0 === e && (c.isMobile || d) || "file://" == location.origin) m = cc._RENDER_TYPE_CANVAS;
  600. c._canUseCanvasNewBlendModes = function () {
  601. var a = document.createElement("canvas");
  602. a.width = 1;
  603. a.height = 1;
  604. a = a.getContext("2d");
  605. a.fillStyle = "#000";
  606. a.fillRect(0, 0, 1, 1);
  607. a.globalCompositeOperation = "multiply";
  608. var b = document.createElement("canvas");
  609. b.width = 1;
  610. b.height = 1;
  611. var c = b.getContext("2d");
  612. c.fillStyle = "#fff";
  613. c.fillRect(0, 0, 1, 1);
  614. a.drawImage(b, 0, 0, 1, 1);
  615. return 0 === a.getImageData(0, 0, 1, 1).data[0]
  616. };
  617. c._supportCanvasNewBlendModes = c._canUseCanvasNewBlendModes();
  618. m != cc._RENDER_TYPE_WEBGL || f.WebGLRenderingContext && cc.create3DContext(n, {
  619. stencil: !0,
  620. preserveDrawingBuffer: !0
  621. }) || (0 == e ? m = cc._RENDER_TYPE_CANVAS : cc._supportRender = !1);
  622. if (m == cc._RENDER_TYPE_CANVAS) try {
  623. n.getContext("2d")
  624. } catch (q) {
  625. cc._supportRender = !1
  626. }
  627. cc._renderType = m;
  628. try {
  629. c._supportWebAudio = !!new (f.AudioContext || f.webkitAudioContext || f.mozAudioContext)
  630. } catch (r) {
  631. c._supportWebAudio = !1
  632. }
  633. try {
  634. var s = c.localStorage = f.localStorage;
  635. s.setItem("storage", "");
  636. s.removeItem("storage");
  637. s = null
  638. } catch (t) {
  639. "SECURITY_ERR" !== t.name && "QuotaExceededError" !== t.name || cc.warn("Warning: localStorage isn't enabled. Please confirm browser cookie or privacy option"),
  640. c.localStorage = function () { }
  641. }
  642. s = c.capabilities = {
  643. canvas: !0
  644. };
  645. cc._renderType == cc._RENDER_TYPE_WEBGL && (s.opengl = !0);
  646. if (void 0 !== h.ontouchstart || g.msPointerEnabled) s.touches = !0;
  647. void 0 !== h.onmouseup && (s.mouse = !0);
  648. void 0 !== h.onkeyup && (s.keyboard = !0);
  649. if (f.DeviceMotionEvent || f.DeviceOrientationEvent) s.accelerometer = !0;
  650. f = k.match(/(iPad|iPhone|iPod)/i) ? !0 : !1;
  651. k = k.match(/android/i) || g.platform.match(/android/i) ? !0 : !1;
  652. h = c.OS_UNKNOWN; -1 != g.appVersion.indexOf("Win") ? h = c.OS_WINDOWS : f ? h = c.OS_IOS : -1 != g.appVersion.indexOf("Mac") ? h = c.OS_OSX : -1 != g.appVersion.indexOf("X11") ? h = c.OS_UNIX : k ? h = c.OS_ANDROID : -1 != g.appVersion.indexOf("Linux") && (h = c.OS_LINUX);
  653. c.os = h;
  654. c.garbageCollect = function () { };
  655. c.dumpRoot = function () { };
  656. c.restartVM = function () { };
  657. c.dump = function () {
  658. var a;
  659. a = "" + ("isMobile : " + this.isMobile + "\r\n");
  660. a += "language : " + this.language + "\r\n";
  661. a += "browserType : " + this.browserType + "\r\n";
  662. a += "capabilities : " + JSON.stringify(this.capabilities) + "\r\n";
  663. a += "os : " + this.os + "\r\n";
  664. a += "platform : " + this.platform + "\r\n";
  665. cc.log(a)
  666. }
  667. };
  668. cc.ORIENTATION_PORTRAIT = 0;
  669. cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN = 1;
  670. cc.ORIENTATION_LANDSCAPE_LEFT = 2;
  671. cc.ORIENTATION_LANDSCAPE_RIGHT = 3;
  672. cc._drawingUtil = null;
  673. cc._renderContext = null;
  674. cc._canvas = null;
  675. cc._gameDiv = null;
  676. cc._rendererInitialized = !1;
  677. cc._setupCalled = !1;
  678. cc._setup = function (a, b, c) {
  679. if (!cc._setupCalled) {
  680. cc._setupCalled = !0;
  681. var d = window,
  682. e = new Date,
  683. f = 1E3 / cc.game.config[cc.game.CONFIG_KEY.frameRate],
  684. g = function (a) {
  685. var b = (new Date).getTime(),
  686. c = Math.max(0, f - (b - e)),
  687. d = window.setTimeout(function () {
  688. a()
  689. },
  690. c);
  691. e = b + c;
  692. return d
  693. },
  694. h = function (a) {
  695. clearTimeout(a)
  696. };
  697. cc.sys.os === cc.sys.OS_IOS && cc.sys.browserType === cc.sys.BROWSER_TYPE_WECHAT ? (d.requestAnimFrame = g, d.cancelAnimationFrame = h) : 60 != cc.game.config[cc.game.CONFIG_KEY.frameRate] ? (d.requestAnimFrame = g, d.cancelAnimationFrame = h) : (d.requestAnimFrame = d.requestAnimationFrame || d.webkitRequestAnimationFrame || d.mozRequestAnimationFrame || d.oRequestAnimationFrame || d.msRequestAnimationFrame || g, d.cancelAnimationFrame = window.cancelAnimationFrame || window.cancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.webkitCancelRequestAnimationFrame || window.msCancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.oCancelAnimationFrame || h);
  698. h = cc.$(a) || cc.$("#" + a);
  699. "CANVAS" == h.tagName ? (b = b || h.width, c = c || h.height, g = cc.container = cc.newElement("DIV"), a = cc._canvas = h, a.parentNode.insertBefore(g, a), a.appendTo(g), g.setAttribute("id", "Cocos2dGameContainer")) : ("DIV" != h.tagName && cc.log("Warning: target element is not a DIV or CANVAS"), b = b || h.clientWidth, c = c || h.clientHeight, g = cc.container = h, a = cc._canvas = cc.$(cc.newElement("CANVAS")), h.appendChild(a));
  700. a.addClass("gameCanvas");
  701. a.setAttribute("width", b || 480);
  702. a.setAttribute("height", c || 320);
  703. a.setAttribute("tabindex", 99);
  704. a.style.outline = "none";
  705. h = g.style;
  706. h.width = (b || 480) + "px";
  707. h.height = (c || 320) + "px";
  708. h.margin = "0 auto";
  709. h.position = "relative";
  710. h.overflow = "hidden";
  711. g.top = "100%";
  712. cc._renderType == cc._RENDER_TYPE_WEBGL && (cc._renderContext = cc.webglContext = cc.create3DContext(a, {
  713. stencil: !0,
  714. preserveDrawingBuffer: !0,
  715. antialias: !cc.sys.isMobile,
  716. alpha: !1
  717. }));
  718. cc._renderContext ? (d.gl = cc._renderContext, cc._drawingUtil = new cc.DrawingPrimitiveWebGL(cc._renderContext), cc._rendererInitialized = !0, cc.textureCache._initializingRenderer(), cc.shaderCache._init()) : (cc._renderContext = a.getContext("2d"), cc._mainRenderContextBackup = cc._renderContext, cc._renderContext.translate(0, a.height), cc._drawingUtil = cc.DrawingPrimitiveCanvas ? new cc.DrawingPrimitiveCanvas(cc._renderContext) : null);
  719. cc._gameDiv = g;
  720. cc.log(cc.ENGINE_VERSION);
  721. cc._setContextMenuEnable(!1);
  722. 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);}");
  723. cc.view = cc.EGLView._getInstance();
  724. cc.inputManager.registerSystemEvent(cc._canvas);
  725. cc.director = cc.Director._getInstance();
  726. cc.director.setOpenGLView && cc.director.setOpenGLView(cc.view);
  727. cc.winSize = cc.director.getWinSize();
  728. cc.saxParser = new cc.SAXParser;
  729. cc.plistParser = new cc.PlistParser
  730. }
  731. };
  732. cc._checkWebGLRenderMode = function () {
  733. if (cc._renderType !== cc._RENDER_TYPE_WEBGL) throw "This feature supports WebGL render mode only.";
  734. };
  735. cc._isContextMenuEnable = !1;
  736. cc._setContextMenuEnable = function (a) {
  737. cc._isContextMenuEnable = a;
  738. cc._canvas.oncontextmenu = function () {
  739. if (!cc._isContextMenuEnable) return !1
  740. }
  741. };
  742. cc.game = {
  743. DEBUG_MODE_NONE: 0,
  744. DEBUG_MODE_INFO: 1,
  745. DEBUG_MODE_WARN: 2,
  746. DEBUG_MODE_ERROR: 3,
  747. DEBUG_MODE_INFO_FOR_WEB_PAGE: 4,
  748. DEBUG_MODE_WARN_FOR_WEB_PAGE: 5,
  749. DEBUG_MODE_ERROR_FOR_WEB_PAGE: 6,
  750. EVENT_HIDE: "game_on_hide",
  751. EVENT_SHOW: "game_on_show",
  752. _eventHide: null,
  753. _eventShow: null,
  754. _onBeforeStartArr: [],
  755. CONFIG_KEY: {
  756. engineDir: "engineDir",
  757. dependencies: "dependencies",
  758. debugMode: "debugMode",
  759. showFPS: "showFPS",
  760. frameRate: "frameRate",
  761. id: "id",
  762. renderMode: "renderMode",
  763. jsList: "jsList",
  764. classReleaseMode: "classReleaseMode"
  765. },
  766. _prepareCalled: !1,
  767. _prepared: !1,
  768. _paused: !0,
  769. _intervalId: null,
  770. config: null,
  771. onStart: null,
  772. onStop: null,
  773. setFrameRate: function (a) {
  774. this.config[this.CONFIG_KEY.frameRate] = a;
  775. this._intervalId && window.cancelAnimationFrame(this._intervalId);
  776. this._paused = !0;
  777. this._runMainLoop()
  778. },
  779. _runMainLoop: function () {
  780. var a = this,
  781. b,
  782. c = cc.director;
  783. c.setDisplayStats(a.config[a.CONFIG_KEY.showFPS]);
  784. b = function () {
  785. a._paused || (c.mainLoop(), a._intervalId = window.requestAnimFrame(b))
  786. };
  787. window.requestAnimFrame(b);
  788. a._paused = !1
  789. },
  790. run: function (a) {
  791. var b = this,
  792. c = function () {
  793. a && (b.config[b.CONFIG_KEY.id] = a);
  794. b._prepareCalled || b.prepare(function () {
  795. b._prepared = !0
  796. });
  797. cc._supportRender && (b._checkPrepare = setInterval(function () {
  798. b._prepared && (cc._setup(b.config[b.CONFIG_KEY.id]), b._runMainLoop(), b._eventHide = 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))
  799. },
  800. 10))
  801. };
  802. document.body ? c() : cc._addEventListener(window, "load",
  803. function () {
  804. this.removeEventListener("load", arguments.callee, !1);
  805. c()
  806. },
  807. !1)
  808. },
  809. _initConfig: function () {
  810. var a = this.CONFIG_KEY,
  811. b = function (b) {
  812. b[a.engineDir] = b[a.engineDir] || "frameworks/cocos2d-html5";
  813. null == b[a.debugMode] && (b[a.debugMode] = 0);
  814. b[a.frameRate] = b[a.frameRate] || 60;
  815. null == b[a.renderMode] && (b[a.renderMode] = 1);
  816. return b
  817. };
  818. if (document.ccConfig) this.config = b(document.ccConfig);
  819. else try {
  820. for (var c = document.getElementsByTagName("script"), d = 0; d < c.length; d++) {
  821. var e = c[d].getAttribute("cocos");
  822. if ("" == e || e) break
  823. }
  824. var f,
  825. g,
  826. h;
  827. if (d < c.length) {
  828. if (f = c[d].src) h = /(.*)\//.exec(f)[0],
  829. cc.loader.resPath = h,
  830. f = cc.path.join(h, "project.json");
  831. g = cc.loader._loadTxtSync(f)
  832. }
  833. g || (g = cc.loader._loadTxtSync("project.json"));
  834. var k = JSON.parse(g);
  835. this.config = b(k || {})
  836. } catch (m) {
  837. cc.log("Failed to read or parse project.json"),
  838. this.config = b({})
  839. }
  840. cc._initSys(this.config, a)
  841. },
  842. _jsAddedCache: {},
  843. _getJsListOfModule: function (a, b, c) {
  844. var d = this._jsAddedCache;
  845. if (d[b]) return null;
  846. c = c || "";
  847. var e = [],
  848. f = a[b];
  849. if (!f) throw "can not find module [" + b + "]";
  850. b = cc.path;
  851. for (var g = 0, h = f.length; g < h; g++) {
  852. var k = f[g];
  853. if (!d[k]) {
  854. var m = b.extname(k);
  855. m ? ".js" == m.toLowerCase() && e.push(b.join(c, k)) : (m = this._getJsListOfModule(a, k, c)) && (e = e.concat(m));
  856. d[k] = 1
  857. }
  858. }
  859. return e
  860. },
  861. prepare: function (a) {
  862. var b = this,
  863. c = b.config,
  864. d = b.CONFIG_KEY,
  865. e = c[d.engineDir],
  866. f = cc.loader;
  867. if (!cc._supportRender) throw "The renderer doesn't support the renderMode " + c[d.renderMode];
  868. b._prepareCalled = !0;
  869. var g = c[d.jsList] || [];
  870. cc.Class ? f.loadJsWithImg("", g,
  871. function (c) {
  872. if (c) throw c;
  873. b._prepared = !0;
  874. a && a()
  875. }) : (d = cc.path.join(e, "moduleConfig.json"), f.loadJson(d,
  876. function (d, f) {
  877. if (d) throw d;
  878. var m = c.modules || [],
  879. n = f.module,
  880. q = [];
  881. cc._renderType == cc._RENDER_TYPE_WEBGL ? m.splice(0, 0, "shaders") : 0 > m.indexOf("core") && m.splice(0, 0, "core");
  882. for (var r = 0, s = m.length; r < s; r++) {
  883. var t = b._getJsListOfModule(n, m[r], e);
  884. t && (q = q.concat(t))
  885. }
  886. q = q.concat(g);
  887. cc.loader.loadJsWithImg(q,
  888. function (c) {
  889. if (c) throw c;
  890. b._prepared = !0;
  891. a && a()
  892. })
  893. }))
  894. }
  895. };
  896. cc.game._initConfig();
  897. Function.prototype.bind = Function.prototype.bind ||
  898. function (a) {
  899. if (!cc.isFunction(this)) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
  900. var b = Array.prototype.slice.call(arguments, 1),
  901. c = this,
  902. d = function () { },
  903. e = function () {
  904. return c.apply(this instanceof d && a ? this : a, b.concat(Array.prototype.slice.call(arguments)))
  905. };
  906. d.prototype = this.prototype;
  907. e.prototype = new d;
  908. return e
  909. };
  910. cc._LogInfos = {
  911. ActionManager_addAction: "cc.ActionManager.addAction(): action must be non-null",
  912. ActionManager_removeAction: "cocos2d: removeAction: Target not found",
  913. ActionManager_removeActionByTag: "cc.ActionManager.removeActionByTag(): an invalid tag",
  914. ActionManager_removeActionByTag_2: "cc.ActionManager.removeActionByTag(): target must be non-null",
  915. ActionManager_getActionByTag: "cc.ActionManager.getActionByTag(): an invalid tag",
  916. ActionManager_getActionByTag_2: "cocos2d : getActionByTag(tag \x3d %s): Action not found",
  917. configuration_dumpInfo: "cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",
  918. configuration_loadConfigFile: "Expected 'data' dict, but not found. Config file: %s",
  919. configuration_loadConfigFile_2: "Please load the resource first : %s",
  920. Director_resume: "cocos2d: Director: Error in gettimeofday",
  921. Director_setProjection: "cocos2d: Director: unrecognized projection",
  922. Director_popToSceneStackLevel: "cocos2d: Director: unrecognized projection",
  923. Director_popToSceneStackLevel_2: "cocos2d: Director: Error in gettimeofday",
  924. Director_popScene: "running scene should not null",
  925. Director_pushScene: "the scene should not null",
  926. arrayVerifyType: "element type is wrong!",
  927. Scheduler_scheduleCallbackForTarget: "CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",
  928. Scheduler_scheduleCallbackForTarget_2: "cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",
  929. Scheduler_scheduleCallbackForTarget_3: "cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",
  930. Scheduler_pauseTarget: "cc.Scheduler.pauseTarget():target should be non-null",
  931. Scheduler_resumeTarget: "cc.Scheduler.resumeTarget():target should be non-null",
  932. Scheduler_isTargetPaused: "cc.Scheduler.isTargetPaused():target should be non-null",
  933. Node_getZOrder: "getZOrder is deprecated. Please use getLocalZOrder instead.",
  934. Node_setZOrder: "setZOrder is deprecated. Please use setLocalZOrder instead.",
  935. Node_getRotation: "RotationX !\x3d RotationY. Don't know which one to return",
  936. Node_getScale: "ScaleX !\x3d ScaleY. Don't know which one to return",
  937. Node_addChild: "An Node can't be added as a child of itself.",
  938. Node_addChild_2: "child already added. It can't be added again",
  939. Node_addChild_3: "child must be non-null",
  940. Node_removeFromParentAndCleanup: "removeFromParentAndCleanup is deprecated. Use removeFromParent instead",
  941. Node_boundingBox: "boundingBox is deprecated. Use getBoundingBox instead",
  942. Node_removeChildByTag: "argument tag is an invalid tag",
  943. Node_removeChildByTag_2: "cocos2d: removeChildByTag(tag \x3d %s): child not found!",
  944. Node_removeAllChildrenWithCleanup: "removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",
  945. Node_stopActionByTag: "cc.Node.stopActionBy(): argument tag an invalid tag",
  946. Node_getActionByTag: "cc.Node.getActionByTag(): argument tag is an invalid tag",
  947. Node_resumeSchedulerAndActions: "resumeSchedulerAndActions is deprecated, please use resume instead.",
  948. Node_pauseSchedulerAndActions: "pauseSchedulerAndActions is deprecated, please use pause instead.",
  949. Node__arrayMakeObjectsPerformSelector: "Unknown callback function",
  950. Node_reorderChild: "child must be non-null",
  951. Node_runAction: "cc.Node.runAction(): action must be non-null",
  952. Node_schedule: "callback function must be non-null",
  953. Node_schedule_2: "interval must be positive",
  954. Node_initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  955. AtlasNode_updateAtlasValues: "cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",
  956. AtlasNode_initWithTileFile: "",
  957. AtlasNode__initWithTexture: "cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",
  958. _EventListenerKeyboard_checkAvailable: "cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",
  959. _EventListenerTouchOneByOne_checkAvailable: "cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",
  960. _EventListenerTouchAllAtOnce_checkAvailable: "cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",
  961. _EventListenerAcceleration_checkAvailable: "cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",
  962. EventListener_create: "Invalid parameter.",
  963. __getListenerID: "Don't call this method if the event is for touch.",
  964. eventManager__forceAddEventListener: "Invalid scene graph priority!",
  965. eventManager_addListener: "0 priority is forbidden for fixed priority since it's used for scene graph based priority.",
  966. eventManager_removeListeners: "Invalid listener type!",
  967. eventManager_setPriority: "Can't set fixed priority with scene graph based listener.",
  968. eventManager_addListener_2: "Invalid parameters.",
  969. eventManager_addListener_3: "listener must be a cc.EventListener object when adding a fixed priority listener",
  970. eventManager_addListener_4: "The listener has been registered, please don't register it again.",
  971. LayerMultiplex_initWithLayers: "parameters should not be ending with null in Javascript",
  972. LayerMultiplex_switchTo: "Invalid index in MultiplexLayer switchTo message",
  973. LayerMultiplex_switchToAndReleaseMe: "Invalid index in MultiplexLayer switchTo message",
  974. LayerMultiplex_addLayer: "cc.Layer.addLayer(): layer should be non-null",
  975. EGLView_setDesignResolutionSize: "Resolution not valid",
  976. EGLView_setDesignResolutionSize_2: "should set resolutionPolicy",
  977. inputManager_handleTouchesBegin: "The touches is more than MAX_TOUCHES, nUnusedIndex \x3d %s",
  978. swap: "cc.swap is being modified from original macro, please check usage",
  979. checkGLErrorDebug: "WebGL error %s",
  980. animationCache__addAnimationsWithDictionary: "cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",
  981. animationCache__addAnimationsWithDictionary_2: "cc.AnimationCache. Invalid animation format",
  982. animationCache_addAnimations: "cc.AnimationCache.addAnimations(): File could not be found",
  983. animationCache__parseVersion1: "cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  984. 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.",
  985. 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.",
  986. 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.",
  987. animationCache__parseVersion2: "cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",
  988. 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.",
  989. animationCache_addAnimations_2: "cc.AnimationCache.addAnimations(): Invalid texture file name",
  990. Sprite_reorderChild: "cc.Sprite.reorderChild(): this child is not in children list",
  991. Sprite_ignoreAnchorPointForPosition: "cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",
  992. Sprite_setDisplayFrameWithAnimationName: "cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",
  993. Sprite_setDisplayFrameWithAnimationName_2: "cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",
  994. Sprite_setDisplayFrame: "setDisplayFrame is deprecated, please use setSpriteFrame instead.",
  995. Sprite__updateBlendFunc: "cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",
  996. Sprite_initWithSpriteFrame: "cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",
  997. Sprite_initWithSpriteFrameName: "cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",
  998. Sprite_initWithSpriteFrameName1: " is null, please check.",
  999. Sprite_initWithFile: "cc.Sprite.initWithFile(): filename should be non-null",
  1000. Sprite_setDisplayFrameWithAnimationName_3: "cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",
  1001. Sprite_reorderChild_2: "cc.Sprite.reorderChild(): child should be non-null",
  1002. Sprite_addChild: "cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",
  1003. Sprite_addChild_2: "cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",
  1004. Sprite_addChild_3: "cc.Sprite.addChild(): child should be non-null",
  1005. Sprite_setTexture: "cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",
  1006. Sprite_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1007. Sprite_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1008. Sprite_addChild_4: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1009. Sprite_addChild_5: "cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",
  1010. Sprite_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  1011. Sprite_setSpriteFrame: "Invalid spriteFrameName",
  1012. Sprite_setTexture_2: "Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",
  1013. Sprite_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  1014. Sprite_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  1015. Sprite_addChild_6: "cc.SpriteBatchNode.addChild(): child should be non-null",
  1016. SpriteBatchNode_addSpriteWithoutQuad: "cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",
  1017. SpriteBatchNode_increaseAtlasCapacity: "cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",
  1018. SpriteBatchNode_increaseAtlasCapacity_2: "cocos2d: WARNING: Not enough memory to resize the atlas",
  1019. SpriteBatchNode_reorderChild: "cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",
  1020. SpriteBatchNode_removeChild: "cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",
  1021. SpriteBatchNode_addSpriteWithoutQuad_2: "cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",
  1022. SpriteBatchNode_reorderChild_2: "cc.SpriteBatchNode.addChild():child should be non-null",
  1023. spriteFrameCache__getFrameConfig: "cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",
  1024. spriteFrameCache_addSpriteFrames: "cocos2d: WARNING: an alias with name %s already exists",
  1025. spriteFrameCache__checkConflict: "cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",
  1026. spriteFrameCache_getSpriteFrame: "cocos2d: cc.SpriteFrameCahce: Frame %s not found",
  1027. spriteFrameCache__getFrameConfig_2: "Please load the resource first : %s",
  1028. spriteFrameCache_addSpriteFrames_2: "cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",
  1029. spriteFrameCache_addSpriteFrames_3: "Argument must be non-nil",
  1030. CCSpriteBatchNode_updateQuadFromSprite: "cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1031. CCSpriteBatchNode_insertQuadFromSprite: "cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1032. CCSpriteBatchNode_addChild: "cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",
  1033. CCSpriteBatchNode_initWithTexture: "Sprite.initWithTexture(): Argument must be non-nil ",
  1034. CCSpriteBatchNode_addChild_2: "cc.Sprite.addChild(): child should be non-null",
  1035. CCSpriteBatchNode_setSpriteFrame: "Invalid spriteFrameName",
  1036. CCSpriteBatchNode_setTexture: "Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",
  1037. CCSpriteBatchNode_updateQuadFromSprite_2: "cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",
  1038. CCSpriteBatchNode_insertQuadFromSprite_2: "cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",
  1039. CCSpriteBatchNode_addChild_3: "cc.SpriteBatchNode.addChild(): child should be non-null",
  1040. TextureAtlas_initWithFile: "cocos2d: Could not open file: %s",
  1041. TextureAtlas_insertQuad: "cc.TextureAtlas.insertQuad(): invalid totalQuads",
  1042. TextureAtlas_initWithTexture: "cc.TextureAtlas.initWithTexture():texture should be non-null",
  1043. TextureAtlas_updateQuad: "cc.TextureAtlas.updateQuad(): quad should be non-null",
  1044. TextureAtlas_updateQuad_2: "cc.TextureAtlas.updateQuad(): Invalid index",
  1045. TextureAtlas_insertQuad_2: "cc.TextureAtlas.insertQuad(): Invalid index",
  1046. TextureAtlas_insertQuads: "cc.TextureAtlas.insertQuad(): Invalid index + amount",
  1047. TextureAtlas_insertQuadFromIndex: "cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",
  1048. TextureAtlas_insertQuadFromIndex_2: "cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",
  1049. TextureAtlas_removeQuadAtIndex: "cc.TextureAtlas.removeQuadAtIndex(): Invalid index",
  1050. TextureAtlas_removeQuadsAtIndex: "cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",
  1051. TextureAtlas_moveQuadsFromIndex: "cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",
  1052. TextureAtlas_moveQuadsFromIndex_2: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",
  1053. TextureAtlas_moveQuadsFromIndex_3: "cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",
  1054. textureCache_addPVRTCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  1055. textureCache_addETCImage: "TextureCache:addPVRTCImage does not support on HTML5",
  1056. textureCache_textureForKey: "textureForKey is deprecated. Please use getTextureForKey instead.",
  1057. textureCache_addPVRImage: "addPVRImage does not support on HTML5",
  1058. textureCache_addUIImage: "cocos2d: Couldn't add UIImage in TextureCache",
  1059. textureCache_dumpCachedTextureInfo: "cocos2d: '%s' id\x3d%s %s x %s",
  1060. textureCache_dumpCachedTextureInfo_2: "cocos2d: '%s' id\x3d HTMLCanvasElement %s x %s",
  1061. textureCache_dumpCachedTextureInfo_3: "cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",
  1062. textureCache_addUIImage_2: "cc.Texture.addUIImage(): image should be non-null",
  1063. Texture2D_initWithETCFile: "initWithETCFile does not support on HTML5",
  1064. Texture2D_initWithPVRFile: "initWithPVRFile does not support on HTML5",
  1065. Texture2D_initWithPVRTCData: "initWithPVRTCData does not support on HTML5",
  1066. Texture2D_addImage: "cc.Texture.addImage(): path should be non-null",
  1067. Texture2D_initWithImage: "cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",
  1068. Texture2D_initWithImage_2: "cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",
  1069. Texture2D_initWithString: "initWithString isn't supported on cocos2d-html5",
  1070. Texture2D_initWithETCFile_2: "initWithETCFile does not support on HTML5",
  1071. Texture2D_initWithPVRFile_2: "initWithPVRFile does not support on HTML5",
  1072. Texture2D_initWithPVRTCData_2: "initWithPVRTCData does not support on HTML5",
  1073. Texture2D_bitsPerPixelForFormat: "bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",
  1074. Texture2D__initPremultipliedATextureWithImage: "cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",
  1075. Texture2D_addImage_2: "cc.Texture.addImage(): path should be non-null",
  1076. Texture2D_initWithData: "NSInternalInconsistencyException",
  1077. MissingFile: "Missing file: %s",
  1078. radiansToDegress: "cc.radiansToDegress() should be called cc.radiansToDegrees()",
  1079. RectWidth: "Rect width exceeds maximum margin: %s",
  1080. RectHeight: "Rect height exceeds maximum margin: %s",
  1081. EventManager__updateListeners: "If program goes here, there should be event in dispatch.",
  1082. EventManager__updateListeners_2: "_inDispatch should be 1 here."
  1083. };
  1084. cc._logToWebPage = function (a) {
  1085. if (cc._canvas) {
  1086. var b = cc._logList,
  1087. c = document;
  1088. if (!b) {
  1089. var d = c.createElement("Div"),
  1090. b = d.style;
  1091. d.setAttribute("id", "logInfoDiv");
  1092. cc._canvas.parentNode.appendChild(d);
  1093. d.setAttribute("width", "200");
  1094. d.setAttribute("height", cc._canvas.height);
  1095. b.zIndex = "99999";
  1096. b.position = "absolute";
  1097. b.top = "0";
  1098. b.left = "0";
  1099. b = cc._logList = c.createElement("textarea");
  1100. c = b.style;
  1101. b.setAttribute("rows", "20");
  1102. b.setAttribute("cols", "30");
  1103. b.setAttribute("disabled", !0);
  1104. d.appendChild(b);
  1105. c.backgroundColor = "transparent";
  1106. c.borderBottom = "1px solid #cccccc";
  1107. c.borderRightWidth = "0px";
  1108. c.borderLeftWidth = "0px";
  1109. c.borderTopWidth = "0px";
  1110. c.borderTopStyle = "none";
  1111. c.borderRightStyle = "none";
  1112. c.borderLeftStyle = "none";
  1113. c.padding = "0px";
  1114. c.margin = 0
  1115. }
  1116. b.value = b.value + a + "\r\n";
  1117. b.scrollTop = b.scrollHeight
  1118. }
  1119. };
  1120. cc._formatString = function (a) {
  1121. if (cc.isObject(a)) try {
  1122. return JSON.stringify(a)
  1123. } catch (b) {
  1124. return ""
  1125. } else return a
  1126. };
  1127. cc._initDebugSetting = function (a) {
  1128. var b = cc.game;
  1129. if (a != b.DEBUG_MODE_NONE) {
  1130. var c;
  1131. a > b.DEBUG_MODE_ERROR ? (c = cc._logToWebPage.bind(cc), cc.error = function () {
  1132. c("ERROR : " + cc.formatStr.apply(cc, arguments))
  1133. },
  1134. cc.assert = function (a, b) {
  1135. if (!a && b) {
  1136. for (var f = 2; f < arguments.length; f++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[f]));
  1137. c("Assert: " + b)
  1138. }
  1139. },
  1140. a != b.DEBUG_MODE_ERROR_FOR_WEB_PAGE && (cc.warn = function () {
  1141. c("WARN : " + cc.formatStr.apply(cc, arguments))
  1142. }), a == b.DEBUG_MODE_INFO_FOR_WEB_PAGE && (cc.log = function () {
  1143. c(cc.formatStr.apply(cc, arguments))
  1144. })) : console && (cc.error = function () {
  1145. return console.error.apply(console, arguments)
  1146. },
  1147. cc.assert = function (a, b) {
  1148. if (!a && b) {
  1149. for (var c = 2; c < arguments.length; c++) b = b.replace(/(%s)|(%d)/, cc._formatString(arguments[c]));
  1150. throw b;
  1151. }
  1152. },
  1153. a != b.DEBUG_MODE_ERROR && (cc.warn = function () {
  1154. return console.warn.apply(console, arguments)
  1155. }), a == b.DEBUG_MODE_INFO && (cc.log = function () {
  1156. return console.log.apply(console, arguments)
  1157. }))
  1158. }
  1159. };
  1160. cc._initDebugSetting(cc.game.config[cc.game.CONFIG_KEY.debugMode]);
  1161. cc.loader.loadBinary = function (a, b) {
  1162. var c = this,
  1163. d = this.getXMLHttpRequest(),
  1164. e = "load " + a + " failed!";
  1165. d.open("GET", a, !0);
  1166. /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ? (d.setRequestHeader("Accept-Charset", "x-user-defined"), d.onreadystatechange = function () {
  1167. if (4 == d.readyState && 200 == d.status) {
  1168. var a = cc._convertResponseBodyToText(d.responseBody);
  1169. b(null, c._str2Uint8Array(a))
  1170. } else b(e)
  1171. }) : (d.overrideMimeType && d.overrideMimeType("text/plain; charset\x3dx-user-defined"), d.onload = function () {
  1172. 4 == d.readyState && 200 == d.status ? b(null, c._str2Uint8Array(d.responseText)) : b(e)
  1173. });
  1174. d.send(null)
  1175. };
  1176. cc.loader._str2Uint8Array = function (a) {
  1177. if (!a) return null;
  1178. for (var b = new Uint8Array(a.length), c = 0; c < a.length; c++) b[c] = a.charCodeAt(c) & 255;
  1179. return b
  1180. };
  1181. cc.loader.loadBinarySync = function (a) {
  1182. var b = this.getXMLHttpRequest(),
  1183. c = "load " + a + " failed!";
  1184. b.open("GET", a, !1);
  1185. a = null;
  1186. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1187. b.setRequestHeader("Accept-Charset", "x-user-defined");
  1188. b.send(null);
  1189. if (200 != b.status) return cc.log(c),
  1190. null; (b = cc._convertResponseBodyToText(b.responseBody)) && (a = this._str2Uint8Array(b))
  1191. } else {
  1192. b.overrideMimeType && b.overrideMimeType("text/plain; charset\x3dx-user-defined");
  1193. b.send(null);
  1194. if (200 != b.status) return cc.log(c),
  1195. null;
  1196. a = this._str2Uint8Array(b.responseText)
  1197. }
  1198. return a
  1199. };
  1200. var Uint8Array = Uint8Array || Array;
  1201. if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
  1202. 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',
  1203. myVBScript = cc.newElement("script");
  1204. myVBScript.type = "text/vbscript";
  1205. myVBScript.textContent = IEBinaryToArray_ByteStr_Script;
  1206. document.body.appendChild(myVBScript);
  1207. cc._convertResponseBodyToText = function (a) {
  1208. for (var b = {},
  1209. c = 0; 256 > c; c++) for (var d = 0; 256 > d; d++) b[String.fromCharCode(c + 256 * d)] = String.fromCharCode(c) + String.fromCharCode(d);
  1210. c = IEBinaryToArray_ByteStr(a);
  1211. a = IEBinaryToArray_ByteStr_Last(a);
  1212. return c.replace(/[\s\S]/g,
  1213. function (a) {
  1214. return b[a]
  1215. }) + a
  1216. }
  1217. };
  1218. cc = cc || {};
  1219. cc._loadingImage = "data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7";
  1220. 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";
  1221. 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";
  1222. var cc = cc || {},
  1223. ClassManager = {
  1224. id: 0 | 998 * Math.random(),
  1225. instanceId: 0 | 998 * Math.random(),
  1226. compileSuper: function (a, b, c) {
  1227. a = a.toString();
  1228. var d = a.indexOf("("),
  1229. e = a.indexOf(")"),
  1230. d = a.substring(d + 1, e),
  1231. d = d.trim(),
  1232. e = a.indexOf("{"),
  1233. f = a.lastIndexOf("}");
  1234. for (a = a.substring(e + 1, f) ; -1 != a.indexOf("this._super") ;) {
  1235. var e = a.indexOf("this._super"),
  1236. f = a.indexOf("(", e),
  1237. g = a.indexOf(")", f),
  1238. g = a.substring(f + 1, g),
  1239. g = (g = g.trim()) ? "," : "";
  1240. a = a.substring(0, e) + "ClassManager[" + c + "]." + b + ".call(this" + g + a.substring(f + 1)
  1241. }
  1242. return Function(d, a)
  1243. },
  1244. getNewID: function () {
  1245. return this.id++
  1246. },
  1247. getNewInstanceId: function () {
  1248. return this.instanceId++
  1249. }
  1250. };
  1251. ClassManager.compileSuper.ClassManager = ClassManager; (function () {
  1252. var a = /\b_super\b/,
  1253. b = cc.game.config[cc.game.CONFIG_KEY.classReleaseMode];
  1254. b && console.log("release Mode");
  1255. cc.Class = function () { };
  1256. cc.Class.extend = function (c) {
  1257. function d() {
  1258. this.__instanceId = ClassManager.getNewInstanceId();
  1259. this.ctor && this.ctor.apply(this, arguments)
  1260. }
  1261. var e = this.prototype,
  1262. f = Object.create(e),
  1263. g = ClassManager.getNewID();
  1264. ClassManager[g] = e;
  1265. var h = {
  1266. writable: !0,
  1267. enumerable: !1,
  1268. configurable: !0
  1269. };
  1270. f.__instanceId = null;
  1271. d.id = g;
  1272. h.value = g;
  1273. Object.defineProperty(f, "__pid", h);
  1274. d.prototype = f;
  1275. h.value = d;
  1276. Object.defineProperty(d.prototype, "constructor", h);
  1277. this.__getters__ && (d.__getters__ = cc.clone(this.__getters__));
  1278. this.__setters__ && (d.__setters__ = cc.clone(this.__setters__));
  1279. for (var k = 0, m = arguments.length; k < m; ++k) {
  1280. var n = arguments[k],
  1281. q;
  1282. for (q in n) {
  1283. var r = "function" === typeof n[q],
  1284. s = "function" === typeof e[q],
  1285. t = a.test(n[q]);
  1286. b && r && s && t ? (h.value = ClassManager.compileSuper(n[q], q, g), Object.defineProperty(f, q, h)) : r && s && t ? (h.value = function (a, b) {
  1287. return function () {
  1288. var c = this._super;
  1289. this._super = e[a];
  1290. var d = b.apply(this, arguments);
  1291. this._super = c;
  1292. return d
  1293. }
  1294. }(q, n[q]), Object.defineProperty(f, q, h)) : r ? (h.value = n[q], Object.defineProperty(f, q, h)) : f[q] = n[q];
  1295. if (r) {
  1296. var u,
  1297. v;
  1298. if (this.__getters__ && this.__getters__[q]) {
  1299. var r = this.__getters__[q],
  1300. w;
  1301. for (w in this.__setters__) if (this.__setters__[w] == r) {
  1302. v = w;
  1303. break
  1304. }
  1305. cc.defineGetterSetter(f, r, n[q], n[v] ? n[v] : f[v], q, v)
  1306. }
  1307. if (this.__setters__ && this.__setters__[q]) {
  1308. r = this.__setters__[q];
  1309. for (w in this.__getters__) if (this.__getters__[w] == r) {
  1310. u = w;
  1311. break
  1312. }
  1313. cc.defineGetterSetter(f, r, n[u] ? n[u] : f[u], n[q], u, q)
  1314. }
  1315. }
  1316. }
  1317. }
  1318. d.extend = cc.Class.extend;
  1319. d.implement = function (a) {
  1320. for (var b in a) f[b] = a[b]
  1321. };
  1322. return d
  1323. }
  1324. })();
  1325. cc.defineGetterSetter = function (a, b, c, d, e, f) {
  1326. if (a.__defineGetter__) c && a.__defineGetter__(b, c),
  1327. d && a.__defineSetter__(b, d);
  1328. else if (Object.defineProperty) {
  1329. var g = {
  1330. enumerable: !1,
  1331. configurable: !0
  1332. };
  1333. c && (g.get = c);
  1334. d && (g.set = d);
  1335. Object.defineProperty(a, b, g)
  1336. } else throw Error("browser does not support getters");
  1337. if (!e && !f) for (var g = null != c, h = void 0 != d, k = Object.getOwnPropertyNames(a), m = 0; m < k.length; m++) {
  1338. var n = k[m];
  1339. if ((a.__lookupGetter__ ? !a.__lookupGetter__(n) : !Object.getOwnPropertyDescriptor(a, n)) && "function" === typeof a[n]) {
  1340. var q = a[n];
  1341. if (g && q === c && (e = n, !h || f)) break;
  1342. if (h && q === d && (f = n, !g || e)) break
  1343. }
  1344. }
  1345. a = a.constructor;
  1346. e && (a.__getters__ || (a.__getters__ = {}), a.__getters__[e] = b);
  1347. f && (a.__setters__ || (a.__setters__ = {}), a.__setters__[f] = b)
  1348. };
  1349. cc.clone = function (a) {
  1350. var b = a.constructor ? new a.constructor : {},
  1351. c;
  1352. for (c in a) {
  1353. var d = a[c];
  1354. b[c] = "object" != typeof d || !d || d instanceof cc.Node || d instanceof HTMLElement ? d : cc.clone(d)
  1355. }
  1356. return b
  1357. };
  1358. cc = cc || {};
  1359. cc._tmp = cc._tmp || {};
  1360. cc.associateWithNative = function (a, b) { };
  1361. cc.KEY = {
  1362. backspace: 8,
  1363. tab: 9,
  1364. enter: 13,
  1365. shift: 16,
  1366. ctrl: 17,
  1367. alt: 18,
  1368. pause: 19,
  1369. capslock: 20,
  1370. escape: 27,
  1371. pageup: 33,
  1372. pagedown: 34,
  1373. end: 35,
  1374. home: 36,
  1375. left: 37,
  1376. up: 38,
  1377. right: 39,
  1378. down: 40,
  1379. insert: 45,
  1380. Delete: 46,
  1381. 0: 48,
  1382. 1: 49,
  1383. 2: 50,
  1384. 3: 51,
  1385. 4: 52,
  1386. 5: 53,
  1387. 6: 54,
  1388. 7: 55,
  1389. 8: 56,
  1390. 9: 57,
  1391. a: 65,
  1392. b: 66,
  1393. c: 67,
  1394. d: 68,
  1395. e: 69,
  1396. f: 70,
  1397. g: 71,
  1398. h: 72,
  1399. i: 73,
  1400. j: 74,
  1401. k: 75,
  1402. l: 76,
  1403. m: 77,
  1404. n: 78,
  1405. o: 79,
  1406. p: 80,
  1407. q: 81,
  1408. r: 82,
  1409. s: 83,
  1410. t: 84,
  1411. u: 85,
  1412. v: 86,
  1413. w: 87,
  1414. x: 88,
  1415. y: 89,
  1416. z: 90,
  1417. num0: 96,
  1418. num1: 97,
  1419. num2: 98,
  1420. num3: 99,
  1421. num4: 100,
  1422. num5: 101,
  1423. num6: 102,
  1424. num7: 103,
  1425. num8: 104,
  1426. num9: 105,
  1427. "*": 106,
  1428. "+": 107,
  1429. "-": 109,
  1430. numdel: 110,
  1431. "/": 111,
  1432. f1: 112,
  1433. f2: 113,
  1434. f3: 114,
  1435. f4: 115,
  1436. f5: 116,
  1437. f6: 117,
  1438. f7: 118,
  1439. f8: 119,
  1440. f9: 120,
  1441. f10: 121,
  1442. f11: 122,
  1443. f12: 123,
  1444. numlock: 144,
  1445. scrolllock: 145,
  1446. semicolon: 186,
  1447. ",": 186,
  1448. equal: 187,
  1449. "\x3d": 187,
  1450. ";": 188,
  1451. comma: 188,
  1452. dash: 189,
  1453. ".": 190,
  1454. period: 190,
  1455. forwardslash: 191,
  1456. grave: 192,
  1457. "[": 219,
  1458. openbracket: 219,
  1459. "]": 221,
  1460. closebracket: 221,
  1461. backslash: 220,
  1462. quote: 222,
  1463. space: 32
  1464. };
  1465. cc.FMT_JPG = 0;
  1466. cc.FMT_PNG = 1;
  1467. cc.FMT_TIFF = 2;
  1468. cc.FMT_RAWDATA = 3;
  1469. cc.FMT_WEBP = 4;
  1470. cc.FMT_UNKNOWN = 5;
  1471. cc.getImageFormatByData = function (a) {
  1472. 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
  1473. };
  1474. cc.inherits = function (a, b) {
  1475. function c() { }
  1476. c.prototype = b.prototype;
  1477. a.superClass_ = b.prototype;
  1478. a.prototype = new c;
  1479. a.prototype.constructor = a
  1480. };
  1481. cc.base = function (a, b, c) {
  1482. var d = arguments.callee.caller;
  1483. if (d.superClass_) return ret = d.superClass_.constructor.apply(a, Array.prototype.slice.call(arguments, 1));
  1484. for (var e = Array.prototype.slice.call(arguments, 2), f = !1, g = a.constructor; g; g = g.superClass_ && g.superClass_.constructor) if (g.prototype[b] === d) f = !0;
  1485. else if (f) return g.prototype[b].apply(a, e);
  1486. if (a[b] === d) return a.constructor.prototype[b].apply(a, e);
  1487. throw Error("cc.base called from a method of one name to a method of a different name");
  1488. };
  1489. cc.Point = function (a, b) {
  1490. this.x = a || 0;
  1491. this.y = b || 0
  1492. };
  1493. cc.p = function (a, b) {
  1494. return void 0 == a ? {
  1495. x: 0,
  1496. y: 0
  1497. } : void 0 == b ? {
  1498. x: a.x,
  1499. y: a.y
  1500. } : {
  1501. x: a,
  1502. y: b
  1503. }
  1504. };
  1505. cc.pointEqualToPoint = function (a, b) {
  1506. return a && b && a.x === b.x && a.y === b.y
  1507. };
  1508. cc.Size = function (a, b) {
  1509. this.width = a || 0;
  1510. this.height = b || 0
  1511. };
  1512. cc.size = function (a, b) {
  1513. return void 0 === a ? {
  1514. width: 0,
  1515. height: 0
  1516. } : void 0 === b ? {
  1517. width: a.width,
  1518. height: a.height
  1519. } : {
  1520. width: a,
  1521. height: b
  1522. }
  1523. };
  1524. cc.sizeEqualToSize = function (a, b) {
  1525. return a && b && a.width == b.width && a.height == b.height
  1526. };
  1527. cc.Rect = function (a, b, c, d) {
  1528. this.x = a || 0;
  1529. this.y = b || 0;
  1530. this.width = c || 0;
  1531. this.height = d || 0
  1532. };
  1533. cc.rect = function (a, b, c, d) {
  1534. return void 0 === a ? {
  1535. x: 0,
  1536. y: 0,
  1537. width: 0,
  1538. height: 0
  1539. } : void 0 === b ? {
  1540. x: a.x,
  1541. y: a.y,
  1542. width: a.width,
  1543. height: a.height
  1544. } : {
  1545. x: a,
  1546. y: b,
  1547. width: c,
  1548. height: d
  1549. }
  1550. };
  1551. cc.rectEqualToRect = function (a, b) {
  1552. return a && b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
  1553. };
  1554. cc._rectEqualToZero = function (a) {
  1555. return a && 0 === a.x && 0 === a.y && 0 === a.width && 0 === a.height
  1556. };
  1557. cc.rectContainsRect = function (a, b) {
  1558. 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
  1559. };
  1560. cc.rectGetMaxX = function (a) {
  1561. return a.x + a.width
  1562. };
  1563. cc.rectGetMidX = function (a) {
  1564. return a.x + a.width / 2
  1565. };
  1566. cc.rectGetMinX = function (a) {
  1567. return a.x
  1568. };
  1569. cc.rectGetMaxY = function (a) {
  1570. return a.y + a.height
  1571. };
  1572. cc.rectGetMidY = function (a) {
  1573. return a.y + a.height / 2
  1574. };
  1575. cc.rectGetMinY = function (a) {
  1576. return a.y
  1577. };
  1578. cc.rectContainsPoint = function (a, b) {
  1579. return b.x >= cc.rectGetMinX(a) && b.x <= cc.rectGetMaxX(a) && b.y >= cc.rectGetMinY(a) && b.y <= cc.rectGetMaxY(a)
  1580. };
  1581. cc.rectIntersectsRect = function (a, b) {
  1582. var c = a.y + a.height,
  1583. d = b.x + b.width,
  1584. e = b.y + b.height;
  1585. return !(a.x + a.width < b.x || d < a.x || c < b.y || e < a.y)
  1586. };
  1587. cc.rectOverlapsRect = function (a, b) {
  1588. 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)
  1589. };
  1590. cc.rectUnion = function (a, b) {
  1591. var c = cc.rect(0, 0, 0, 0);
  1592. c.x = Math.min(a.x, b.x);
  1593. c.y = Math.min(a.y, b.y);
  1594. c.width = Math.max(a.x + a.width, b.x + b.width) - c.x;
  1595. c.height = Math.max(a.y + a.height, b.y + b.height) - c.y;
  1596. return c
  1597. };
  1598. cc.rectIntersection = function (a, b) {
  1599. var c = cc.rect(Math.max(cc.rectGetMinX(a), cc.rectGetMinX(b)), Math.max(cc.rectGetMinY(a), cc.rectGetMinY(b)), 0, 0);
  1600. c.width = Math.min(cc.rectGetMaxX(a), cc.rectGetMaxX(b)) - cc.rectGetMinX(c);
  1601. c.height = Math.min(cc.rectGetMaxY(a), cc.rectGetMaxY(b)) - cc.rectGetMinY(c);
  1602. return c
  1603. };
  1604. cc.SAXParser = cc.Class.extend({
  1605. _parser: null,
  1606. _isSupportDOMParser: null,
  1607. ctor: function () {
  1608. window.DOMParser ? (this._isSupportDOMParser = !0, this._parser = new DOMParser) : this._isSupportDOMParser = !1
  1609. },
  1610. parse: function (a) {
  1611. return this._parseXML(a)
  1612. },
  1613. _parseXML: function (a) {
  1614. var b;
  1615. this._isSupportDOMParser ? b = this._parser.parseFromString(a, "text/xml") : (b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a));
  1616. return b
  1617. }
  1618. });
  1619. cc.PlistParser = cc.SAXParser.extend({
  1620. parse: function (a) {
  1621. a = this._parseXML(a).documentElement;
  1622. if ("plist" != a.tagName) throw "Not a plist file!";
  1623. for (var b = null, c = 0, d = a.childNodes.length; c < d && (b = a.childNodes[c], 1 != b.nodeType) ; c++);
  1624. return this._parseNode(b)
  1625. },
  1626. _parseNode: function (a) {
  1627. var b = null,
  1628. c = a.tagName;
  1629. if ("dict" == c) b = this._parseDict(a);
  1630. else if ("array" == c) b = this._parseArray(a);
  1631. else if ("string" == c) if (1 == a.childNodes.length) b = a.firstChild.nodeValue;
  1632. else for (b = "", c = 0; c < a.childNodes.length; c++) b += a.childNodes[c].nodeValue;
  1633. else "false" == c ? b = !1 : "true" == c ? b = !0 : "real" == c ? b = parseFloat(a.firstChild.nodeValue) : "integer" == c && (b = parseInt(a.firstChild.nodeValue, 10));
  1634. return b
  1635. },
  1636. _parseArray: function (a) {
  1637. for (var b = [], c = 0, d = a.childNodes.length; c < d; c++) {
  1638. var e = a.childNodes[c];
  1639. 1 == e.nodeType && b.push(this._parseNode(e))
  1640. }
  1641. return b
  1642. },
  1643. _parseDict: function (a) {
  1644. for (var b = {},
  1645. c = null, d = 0, e = a.childNodes.length; d < e; d++) {
  1646. var f = a.childNodes[d];
  1647. 1 == f.nodeType && ("key" == f.tagName ? c = f.firstChild.nodeValue : b[c] = this._parseNode(f))
  1648. }
  1649. return b
  1650. }
  1651. });
  1652. cc._txtLoader = {
  1653. load: function (a, b, c, d) {
  1654. cc.loader.loadTxt(a, d)
  1655. }
  1656. };
  1657. cc.loader.register(["txt", "xml", "vsh", "fsh", "atlas"], cc._txtLoader);
  1658. cc._jsonLoader = {
  1659. load: function (a, b, c, d) {
  1660. cc.loader.loadJson(a, d)
  1661. }
  1662. };
  1663. cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
  1664. cc._imgLoader = {
  1665. load: function (a, b, c, d) {
  1666. cc.loader.cache[b] = cc.loader.loadImg(a,
  1667. function (a, c) {
  1668. if (a) return d(a);
  1669. cc.textureCache.handleLoadedTexture(b);
  1670. d(null, c)
  1671. })
  1672. }
  1673. };
  1674. cc.loader.register("png jpg bmp jpeg gif ico".split(" "), cc._imgLoader);
  1675. cc._serverImgLoader = {
  1676. load: function (a, b, c, d) {
  1677. cc.loader.cache[b] = cc.loader.loadImg(c.src,
  1678. function (a, c) {
  1679. if (a) return d(a);
  1680. cc.textureCache.handleLoadedTexture(b);
  1681. d(null, c)
  1682. })
  1683. }
  1684. };
  1685. cc.loader.register(["serverImg"], cc._serverImgLoader);
  1686. cc._plistLoader = {
  1687. load: function (a, b, c, d) {
  1688. cc.loader.loadTxt(a,
  1689. function (a, b) {
  1690. if (a) return d(a);
  1691. d(null, cc.plistParser.parse(b))
  1692. })
  1693. }
  1694. };
  1695. cc.loader.register(["plist"], cc._plistLoader);
  1696. cc._fontLoader = {
  1697. TYPE: {
  1698. ".eot": "embedded-opentype",
  1699. ".ttf": "truetype",
  1700. ".woff": "woff",
  1701. ".svg": "svg"
  1702. },
  1703. _loadFont: function (a, b, c) {
  1704. var d = document,
  1705. e = cc.path,
  1706. f = this.TYPE,
  1707. g = cc.newElement("style");
  1708. g.type = "text/css";
  1709. d.body.appendChild(g);
  1710. var h = "@font-face { font-family:" + a + "; src:";
  1711. if (b instanceof Array) for (var k = 0, m = b.length; k < m; k++) c = e.extname(b[k]).toLowerCase(),
  1712. h += "url('" + b[k] + "') format('" + f[c] + "')",
  1713. h += k == m - 1 ? ";" : ",";
  1714. else h += "url('" + b + "') format('" + f[c] + "');";
  1715. g.textContent += h + "};";
  1716. b = cc.newElement("div");
  1717. c = b.style;
  1718. c.fontFamily = a;
  1719. b.innerHTML = ".";
  1720. c.position = "absolute";
  1721. c.left = "-100px";
  1722. c.top = "-100px";
  1723. d.body.appendChild(b)
  1724. },
  1725. load: function (a, b, c, d) {
  1726. b = c.type;
  1727. a = c.name;
  1728. b = c.srcs;
  1729. cc.isString(c) ? (b = cc.path.extname(c), a = cc.path.basename(c, b), this._loadFont(a, c, b)) : this._loadFont(a, b);
  1730. d(null, !0)
  1731. }
  1732. };
  1733. cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
  1734. cc._binaryLoader = {
  1735. load: function (a, b, c, d) {
  1736. cc.loader.loadBinary(a, d)
  1737. }
  1738. };
  1739. window.CocosEngine = cc.ENGINE_VERSION = "Cocos2d-JS v3.0 Final";
  1740. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
  1741. cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
  1742. cc.DIRECTOR_FPS_INTERVAL = 0.5;
  1743. cc.COCOSNODE_RENDER_SUBPIXEL = 1;
  1744. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
  1745. cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
  1746. cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
  1747. cc.TEXTURE_ATLAS_USE_VAO = 0;
  1748. cc.TEXTURE_NPOT_SUPPORT = 0;
  1749. cc.RETINA_DISPLAY_SUPPORT = 1;
  1750. cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
  1751. cc.USE_LA88_LABELS = 1;
  1752. cc.SPRITE_DEBUG_DRAW = 0;
  1753. cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
  1754. cc.LABELBMFONT_DEBUG_DRAW = 0;
  1755. cc.LABELATLAS_DEBUG_DRAW = 0;
  1756. cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
  1757. cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
  1758. cc.ENABLE_STACKABLE_ACTIONS = 1;
  1759. cc.ENABLE_GL_STATE_CACHE = 1;
  1760. cc.$ = function (a) {
  1761. var b = this == cc ? document : this;
  1762. if (a = a instanceof HTMLElement ? a : b.querySelector(a)) a.find = a.find || cc.$,
  1763. a.hasClass = a.hasClass ||
  1764. function (a) {
  1765. return this.className.match(RegExp("(\\s|^)" + a + "(\\s|$)"))
  1766. },
  1767. a.addClass = a.addClass ||
  1768. function (a) {
  1769. this.hasClass(a) || (this.className && (this.className += " "), this.className += a);
  1770. return this
  1771. },
  1772. a.removeClass = a.removeClass ||
  1773. function (a) {
  1774. this.hasClass(a) && (this.className = this.className.replace(a, ""));
  1775. return this
  1776. },
  1777. a.remove = a.remove ||
  1778. function () {
  1779. this.parentNode && this.parentNode.removeChild(this);
  1780. return this
  1781. },
  1782. a.appendTo = a.appendTo ||
  1783. function (a) {
  1784. a.appendChild(this);
  1785. return this
  1786. },
  1787. a.prependTo = a.prependTo ||
  1788. function (a) {
  1789. a.childNodes[0] ? a.insertBefore(this, a.childNodes[0]) : a.appendChild(this);
  1790. return this
  1791. },
  1792. a.transforms = a.transforms ||
  1793. function () {
  1794. this.style[cc.$.trans] = cc.$.translate(this.position) + cc.$.rotate(this.rotation) + cc.$.scale(this.scale) + cc.$.skew(this.skew);
  1795. return this
  1796. },
  1797. a.position = a.position || {
  1798. x: 0,
  1799. y: 0
  1800. },
  1801. a.rotation = a.rotation || 0,
  1802. a.scale = a.scale || {
  1803. x: 1,
  1804. y: 1
  1805. },
  1806. a.skew = a.skew || {
  1807. x: 0,
  1808. y: 0
  1809. },
  1810. a.translates = function (a, b) {
  1811. this.position.x = a;
  1812. this.position.y = b;
  1813. this.transforms();
  1814. return this
  1815. },
  1816. a.rotate = function (a) {
  1817. this.rotation = a;
  1818. this.transforms();
  1819. return this
  1820. },
  1821. a.resize = function (a, b) {
  1822. this.scale.x = a;
  1823. this.scale.y = b;
  1824. this.transforms();
  1825. return this
  1826. },
  1827. a.setSkew = function (a, b) {
  1828. this.skew.x = a;
  1829. this.skew.y = b;
  1830. this.transforms();
  1831. return this
  1832. };
  1833. return a
  1834. };
  1835. switch (cc.sys.browserType) {
  1836. case cc.sys.BROWSER_TYPE_FIREFOX:
  1837. cc.$.pfx = "Moz";
  1838. cc.$.hd = !0;
  1839. break;
  1840. case cc.sys.BROWSER_TYPE_CHROME:
  1841. case cc.sys.BROWSER_TYPE_SAFARI:
  1842. cc.$.pfx = "webkit";
  1843. cc.$.hd = !0;
  1844. break;
  1845. case cc.sys.BROWSER_TYPE_OPERA:
  1846. cc.$.pfx = "O";
  1847. cc.$.hd = !1;
  1848. break;
  1849. case cc.sys.BROWSER_TYPE_IE:
  1850. cc.$.pfx = "ms";
  1851. cc.$.hd = !1;
  1852. break;
  1853. default:
  1854. cc.$.pfx = "webkit",
  1855. cc.$.hd = !0
  1856. }
  1857. cc.$.trans = cc.$.pfx + "Transform";
  1858. cc.$.translate = cc.$.hd ?
  1859. function (a) {
  1860. return "translate3d(" + a.x + "px, " + a.y + "px, 0) "
  1861. } : function (a) {
  1862. return "translate(" + a.x + "px, " + a.y + "px) "
  1863. };
  1864. cc.$.rotate = cc.$.hd ?
  1865. function (a) {
  1866. return "rotateZ(" + a + "deg) "
  1867. } : function (a) {
  1868. return "rotate(" + a + "deg) "
  1869. };
  1870. cc.$.scale = function (a) {
  1871. return "scale(" + a.x + ", " + a.y + ") "
  1872. };
  1873. cc.$.skew = function (a) {
  1874. return "skewX(" + -a.x + "deg) skewY(" + a.y + "deg)"
  1875. };
  1876. cc.$new = function (a) {
  1877. return cc.$(document.createElement(a))
  1878. };
  1879. cc.$.findpos = function (a) {
  1880. var b = 0,
  1881. c = 0;
  1882. do b += a.offsetLeft,
  1883. c += a.offsetTop;
  1884. while (a = a.offsetParent);
  1885. return {
  1886. x: b,
  1887. y: c
  1888. }
  1889. };
  1890. cc.INVALID_INDEX = -1;
  1891. cc.PI = Math.PI;
  1892. cc.FLT_MAX = parseFloat("3.402823466e+38F");
  1893. cc.FLT_MIN = parseFloat("1.175494351e-38F");
  1894. cc.RAD = cc.PI / 180;
  1895. cc.DEG = 180 / cc.PI;
  1896. cc.UINT_MAX = 4294967295;
  1897. cc.swap = function (a, b, c) {
  1898. if (!cc.isObject(c) || cc.isUndefined(c.x) || cc.isUndefined(c.y)) cc.log(cc._LogInfos.swap);
  1899. else {
  1900. var d = c[a];
  1901. c[a] = c[b];
  1902. c[b] = d
  1903. }
  1904. };
  1905. cc.lerp = function (a, b, c) {
  1906. return a + (b - a) * c
  1907. };
  1908. cc.rand = function () {
  1909. return 16777215 * Math.random()
  1910. };
  1911. cc.randomMinus1To1 = function () {
  1912. return 2 * (Math.random() - 0.5)
  1913. };
  1914. cc.random0To1 = Math.random;
  1915. cc.degreesToRadians = function (a) {
  1916. return a * cc.RAD
  1917. };
  1918. cc.radiansToDegrees = function (a) {
  1919. return a * cc.DEG
  1920. };
  1921. cc.radiansToDegress = function (a) {
  1922. cc.log(cc._LogInfos.radiansToDegress);
  1923. return a * cc.DEG
  1924. };
  1925. cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
  1926. cc.BLEND_SRC = cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA ? 1 : 770;
  1927. cc.BLEND_DST = 771;
  1928. cc.nodeDrawSetup = function (a) {
  1929. a._shaderProgram && (a._shaderProgram.use(), a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())
  1930. };
  1931. cc.enableDefaultGLStates = function () { };
  1932. cc.disableDefaultGLStates = function () { };
  1933. cc.incrementGLDraws = function (a) {
  1934. cc.g_NumberOfDraws += a
  1935. };
  1936. cc.FLT_EPSILON = 1.192092896E-7;
  1937. cc.contentScaleFactor = cc.IS_RETINA_DISPLAY_SUPPORTED ?
  1938. function () {
  1939. return cc.director.getContentScaleFactor()
  1940. } : function () {
  1941. return 1
  1942. };
  1943. cc.pointPointsToPixels = function (a) {
  1944. var b = cc.contentScaleFactor();
  1945. return cc.p(a.x * b, a.y * b)
  1946. };
  1947. cc.pointPixelsToPoints = function (a) {
  1948. var b = cc.contentScaleFactor();
  1949. return cc.p(a.x / b, a.y / b)
  1950. };
  1951. cc._pointPixelsToPointsOut = function (a, b) {
  1952. var c = cc.contentScaleFactor();
  1953. b.x = a.x / c;
  1954. b.y = a.y / c
  1955. };
  1956. cc.sizePointsToPixels = function (a) {
  1957. var b = cc.contentScaleFactor();
  1958. return cc.size(a.width * b, a.height * b)
  1959. };
  1960. cc.sizePixelsToPoints = function (a) {
  1961. var b = cc.contentScaleFactor();
  1962. return cc.size(a.width / b, a.height / b)
  1963. };
  1964. cc._sizePixelsToPointsOut = function (a, b) {
  1965. var c = cc.contentScaleFactor();
  1966. b.width = a.width / c;
  1967. b.height = a.height / c
  1968. };
  1969. cc.rectPixelsToPoints = cc.IS_RETINA_DISPLAY_SUPPORTED ?
  1970. function (a) {
  1971. var b = cc.contentScaleFactor();
  1972. return cc.rect(a.x / b, a.y / b, a.width / b, a.height / b)
  1973. } : function (a) {
  1974. return a
  1975. };
  1976. cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ?
  1977. function (a) {
  1978. var b = cc.contentScaleFactor();
  1979. return cc.rect(a.x * b, a.y * b, a.width * b, a.height * b)
  1980. } : function (a) {
  1981. return a
  1982. };
  1983. cc.ONE = 1;
  1984. cc.ZERO = 0;
  1985. cc.SRC_ALPHA = 770;
  1986. cc.SRC_ALPHA_SATURATE = 776;
  1987. cc.SRC_COLOR = 768;
  1988. cc.DST_ALPHA = 772;
  1989. cc.DST_COLOR = 774;
  1990. cc.ONE_MINUS_SRC_ALPHA = 771;
  1991. cc.ONE_MINUS_SRC_COLOR = 769;
  1992. cc.ONE_MINUS_DST_ALPHA = 773;
  1993. cc.ONE_MINUS_DST_COLOR = 775;
  1994. cc.ONE_MINUS_CONSTANT_ALPHA = 32772;
  1995. cc.ONE_MINUS_CONSTANT_COLOR = 32770;
  1996. cc.checkGLErrorDebug = function () {
  1997. if (cc.renderMode == cc._RENDER_TYPE_WEBGL) {
  1998. var a = cc._renderContext.getError();
  1999. a && cc.log(cc._LogInfos.checkGLErrorDebug, a)
  2000. }
  2001. };
  2002. cc.DEVICE_ORIENTATION_PORTRAIT = 0;
  2003. cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
  2004. cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
  2005. cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
  2006. cc.DEVICE_MAX_ORIENTATIONS = 2;
  2007. cc.VERTEX_ATTRIB_FLAG_NONE = 0;
  2008. cc.VERTEX_ATTRIB_FLAG_POSITION = 1;
  2009. cc.VERTEX_ATTRIB_FLAG_COLOR = 2;
  2010. cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 4;
  2011. cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  2012. cc.GL_ALL = 0;
  2013. cc.VERTEX_ATTRIB_POSITION = 0;
  2014. cc.VERTEX_ATTRIB_COLOR = 1;
  2015. cc.VERTEX_ATTRIB_TEX_COORDS = 2;
  2016. cc.VERTEX_ATTRIB_MAX = 3;
  2017. cc.UNIFORM_PMATRIX = 0;
  2018. cc.UNIFORM_MVMATRIX = 1;
  2019. cc.UNIFORM_MVPMATRIX = 2;
  2020. cc.UNIFORM_TIME = 3;
  2021. cc.UNIFORM_SINTIME = 4;
  2022. cc.UNIFORM_COSTIME = 5;
  2023. cc.UNIFORM_RANDOM01 = 6;
  2024. cc.UNIFORM_SAMPLER = 7;
  2025. cc.UNIFORM_MAX = 8;
  2026. cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
  2027. cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
  2028. cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
  2029. cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
  2030. cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
  2031. cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
  2032. cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
  2033. cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
  2034. cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
  2035. cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
  2036. cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
  2037. cc.UNIFORM_TIME_S = "CC_Time";
  2038. cc.UNIFORM_SINTIME_S = "CC_SinTime";
  2039. cc.UNIFORM_COSTIME_S = "CC_CosTime";
  2040. cc.UNIFORM_RANDOM01_S = "CC_Random01";
  2041. cc.UNIFORM_SAMPLER_S = "CC_Texture0";
  2042. cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
  2043. cc.ATTRIBUTE_NAME_COLOR = "a_color";
  2044. cc.ATTRIBUTE_NAME_POSITION = "a_position";
  2045. cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
  2046. cc.ITEM_SIZE = 32;
  2047. cc.CURRENT_ITEM = 3233828865;
  2048. cc.ZOOM_ACTION_TAG = 3233828866;
  2049. cc.NORMAL_TAG = 8801;
  2050. cc.SELECTED_TAG = 8802;
  2051. cc.DISABLE_TAG = 8803;
  2052. cc.arrayVerifyType = function (a, b) {
  2053. if (a && 0 < a.length) for (var c = 0; c < a.length; c++) if (!(a[c] instanceof b)) return cc.log("element type is wrong!"),
  2054. !1;
  2055. return !0
  2056. };
  2057. cc.arrayRemoveObject = function (a, b) {
  2058. for (var c = 0, d = a.length; c < d; c++) if (a[c] == b) {
  2059. a.splice(c, 1);
  2060. break
  2061. }
  2062. };
  2063. cc.arrayRemoveArray = function (a, b) {
  2064. for (var c = 0, d = b.length; c < d; c++) cc.arrayRemoveObject(a, b[c])
  2065. };
  2066. cc.arrayAppendObjectsToIndex = function (a, b, c) {
  2067. a.splice.apply(a, [c, 0].concat(b));
  2068. return a
  2069. };
  2070. cc.copyArray = function (a) {
  2071. var b,
  2072. c = a.length,
  2073. d = Array(c);
  2074. for (b = 0; b < c; b += 1) d[b] = a[b];
  2075. return d
  2076. };
  2077. cc = cc || {};
  2078. cc._tmp = cc._tmp || {};
  2079. cc._tmp.WebGLColor = function () {
  2080. cc.color = function (a, c, d, e, f, g) {
  2081. 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)
  2082. };
  2083. cc.Color = function (a, c, d, e, f, g) {
  2084. this._arrayBuffer = f || new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT);
  2085. this._offset = g || 0;
  2086. f = this._arrayBuffer;
  2087. g = this._offset;
  2088. var h = Uint8Array.BYTES_PER_ELEMENT;
  2089. this._rU8 = new Uint8Array(f, g, 1);
  2090. this._gU8 = new Uint8Array(f, g + h, 1);
  2091. this._bU8 = new Uint8Array(f, g + 2 * h, 1);
  2092. this._aU8 = new Uint8Array(f, g + 3 * h, 1);
  2093. this._rU8[0] = a || 0;
  2094. this._gU8[0] = c || 0;
  2095. this._bU8[0] = d || 0;
  2096. this._aU8[0] = null == e ? 255 : e;
  2097. void 0 === e && (this.a_undefined = !0)
  2098. };
  2099. cc.Color.BYTES_PER_ELEMENT = 4;
  2100. var a = cc.Color.prototype;
  2101. a._getR = function () {
  2102. return this._rU8[0]
  2103. };
  2104. a._setR = function (a) {
  2105. this._rU8[0] = 0 > a ? 0 : a
  2106. };
  2107. a._getG = function () {
  2108. return this._gU8[0]
  2109. };
  2110. a._setG = function (a) {
  2111. this._gU8[0] = 0 > a ? 0 : a
  2112. };
  2113. a._getB = function () {
  2114. return this._bU8[0]
  2115. };
  2116. a._setB = function (a) {
  2117. this._bU8[0] = 0 > a ? 0 : a
  2118. };
  2119. a._getA = function () {
  2120. return this._aU8[0]
  2121. };
  2122. a._setA = function (a) {
  2123. this._aU8[0] = 0 > a ? 0 : a
  2124. };
  2125. cc.defineGetterSetter(a, "r", a._getR, a._setR);
  2126. cc.defineGetterSetter(a, "g", a._getG, a._setG);
  2127. cc.defineGetterSetter(a, "b", a._getB, a._setB);
  2128. cc.defineGetterSetter(a, "a", a._getA, a._setA);
  2129. cc.Vertex2F = function (a, c, d, e) {
  2130. this._arrayBuffer = d || new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT);
  2131. this._offset = e || 0;
  2132. this._xF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  2133. this._yF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  2134. this._xF32[0] = a || 0;
  2135. this._yF32[0] = c || 0
  2136. };
  2137. cc.Vertex2F.BYTES_PER_ELEMENT = 8;
  2138. Object.defineProperties(cc.Vertex2F.prototype, {
  2139. x: {
  2140. get: function () {
  2141. return this._xF32[0]
  2142. },
  2143. set: function (a) {
  2144. this._xF32[0] = a
  2145. },
  2146. enumerable: !0
  2147. },
  2148. y: {
  2149. get: function () {
  2150. return this._yF32[0]
  2151. },
  2152. set: function (a) {
  2153. this._yF32[0] = a
  2154. },
  2155. enumerable: !0
  2156. }
  2157. });
  2158. cc.Vertex3F = function (a, c, d, e, f) {
  2159. this._arrayBuffer = e || new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT);
  2160. this._offset = f || 0;
  2161. e = this._arrayBuffer;
  2162. f = this._offset;
  2163. this._xF32 = new Float32Array(e, f, 1);
  2164. this._xF32[0] = a || 0;
  2165. this._yF32 = new Float32Array(e, f + Float32Array.BYTES_PER_ELEMENT, 1);
  2166. this._yF32[0] = c || 0;
  2167. this._zF32 = new Float32Array(e, f + 2 * Float32Array.BYTES_PER_ELEMENT, 1);
  2168. this._zF32[0] = d || 0
  2169. };
  2170. cc.Vertex3F.BYTES_PER_ELEMENT = 12;
  2171. Object.defineProperties(cc.Vertex3F.prototype, {
  2172. x: {
  2173. get: function () {
  2174. return this._xF32[0]
  2175. },
  2176. set: function (a) {
  2177. this._xF32[0] = a
  2178. },
  2179. enumerable: !0
  2180. },
  2181. y: {
  2182. get: function () {
  2183. return this._yF32[0]
  2184. },
  2185. set: function (a) {
  2186. this._yF32[0] = a
  2187. },
  2188. enumerable: !0
  2189. },
  2190. z: {
  2191. get: function () {
  2192. return this._zF32[0]
  2193. },
  2194. set: function (a) {
  2195. this._zF32[0] = a
  2196. },
  2197. enumerable: !0
  2198. }
  2199. });
  2200. cc.Tex2F = function (a, c, d, e) {
  2201. this._arrayBuffer = d || new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT);
  2202. this._offset = e || 0;
  2203. this._uF32 = new Float32Array(this._arrayBuffer, this._offset, 1);
  2204. this._vF32 = new Float32Array(this._arrayBuffer, this._offset + 4, 1);
  2205. this._uF32[0] = a || 0;
  2206. this._vF32[0] = c || 0
  2207. };
  2208. cc.Tex2F.BYTES_PER_ELEMENT = 8;
  2209. Object.defineProperties(cc.Tex2F.prototype, {
  2210. u: {
  2211. get: function () {
  2212. return this._uF32[0]
  2213. },
  2214. set: function (a) {
  2215. this._uF32[0] = a
  2216. },
  2217. enumerable: !0
  2218. },
  2219. v: {
  2220. get: function () {
  2221. return this._vF32[0]
  2222. },
  2223. set: function (a) {
  2224. this._vF32[0] = a
  2225. },
  2226. enumerable: !0
  2227. }
  2228. });
  2229. cc.Quad2 = function (a, c, d, e, f, g) {
  2230. this._arrayBuffer = f || new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT);
  2231. this._offset = g || 0;
  2232. f = this._arrayBuffer;
  2233. g = cc.Vertex2F.BYTES_PER_ELEMENT;
  2234. this._tl = a ? new cc.Vertex2F(a.x, a.y, f, 0) : new cc.Vertex2F(0, 0, f, 0);
  2235. this._tr = c ? new cc.Vertex2F(c.x, c.y, f, g) : new cc.Vertex2F(0, 0, f, g);
  2236. this._bl = d ? new cc.Vertex2F(d.x, d.y, f, 2 * g) : new cc.Vertex2F(0, 0, f, 2 * g);
  2237. this._br = e ? new cc.Vertex2F(e.x, e.y, f, 3 * g) : new cc.Vertex2F(0, 0, f, 3 * g)
  2238. };
  2239. cc.Quad2.BYTES_PER_ELEMENT = 32;
  2240. cc.Quad3 = function (a, c, d, e) {
  2241. this.bl = a || new cc.Vertex3F(0, 0, 0);
  2242. this.br = c || new cc.Vertex3F(0, 0, 0);
  2243. this.tl = d || new cc.Vertex3F(0, 0, 0);
  2244. this.tr = e || new cc.Vertex3F(0, 0, 0)
  2245. };
  2246. Object.defineProperties(cc.Quad2.prototype, {
  2247. tl: {
  2248. get: function () {
  2249. return this._tl
  2250. },
  2251. set: function (a) {
  2252. this._tl.x = a.x;
  2253. this._tl.y = a.y
  2254. },
  2255. enumerable: !0
  2256. },
  2257. tr: {
  2258. get: function () {
  2259. return this._tr
  2260. },
  2261. set: function (a) {
  2262. this._tr.x = a.x;
  2263. this._tr.y = a.y
  2264. },
  2265. enumerable: !0
  2266. },
  2267. bl: {
  2268. get: function () {
  2269. return this._bl
  2270. },
  2271. set: function (a) {
  2272. this._bl.x = a.x;
  2273. this._bl.y = a.y
  2274. },
  2275. enumerable: !0
  2276. },
  2277. br: {
  2278. get: function () {
  2279. return this._br
  2280. },
  2281. set: function (a) {
  2282. this._br.x = a.x;
  2283. this._br.y = a.y
  2284. },
  2285. enumerable: !0
  2286. }
  2287. });
  2288. cc.V3F_C4B_T2F = function (a, c, d, e, f) {
  2289. this._arrayBuffer = e || new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT);
  2290. this._offset = f || 0;
  2291. e = this._arrayBuffer;
  2292. f = this._offset;
  2293. var g = cc.Vertex3F.BYTES_PER_ELEMENT;
  2294. this._vertices = a ? new cc.Vertex3F(a.x, a.y, a.z, e, f) : new cc.Vertex3F(0, 0, 0, e, f);
  2295. 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);
  2296. 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)
  2297. };
  2298. cc.V3F_C4B_T2F.BYTES_PER_ELEMENT = 24;
  2299. Object.defineProperties(cc.V3F_C4B_T2F.prototype, {
  2300. vertices: {
  2301. get: function () {
  2302. return this._vertices
  2303. },
  2304. set: function (a) {
  2305. var c = this._vertices;
  2306. c.x = a.x;
  2307. c.y = a.y;
  2308. c.z = a.z
  2309. },
  2310. enumerable: !0
  2311. },
  2312. colors: {
  2313. get: function () {
  2314. return this._colors
  2315. },
  2316. set: function (a) {
  2317. var c = this._colors;
  2318. c.r = a.r;
  2319. c.g = a.g;
  2320. c.b = a.b;
  2321. c.a = a.a
  2322. },
  2323. enumerable: !0
  2324. },
  2325. texCoords: {
  2326. get: function () {
  2327. return this._texCoords
  2328. },
  2329. set: function (a) {
  2330. this._texCoords.u = a.u;
  2331. this._texCoords.v = a.v
  2332. },
  2333. enumerable: !0
  2334. }
  2335. });
  2336. cc.V3F_C4B_T2F_Quad = function (a, c, d, e, f, g) {
  2337. this._arrayBuffer = f || new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT);
  2338. this._offset = g || 0;
  2339. f = this._arrayBuffer;
  2340. g = this._offset;
  2341. var h = cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;
  2342. 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);
  2343. 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);
  2344. 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);
  2345. this._br = e ? new cc.V3F_C4B_T2F(e.vertices, e.colors, e.texCoords, f, g + 3 * h) : new cc.V3F_C4B_T2F(null, null, null, f, g + 3 * h)
  2346. };
  2347. cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT = 96;
  2348. Object.defineProperties(cc.V3F_C4B_T2F_Quad.prototype, {
  2349. tl: {
  2350. get: function () {
  2351. return this._tl
  2352. },
  2353. set: function (a) {
  2354. var c = this._tl;
  2355. c.vertices = a.vertices;
  2356. c.colors = a.colors;
  2357. c.texCoords = a.texCoords
  2358. },
  2359. enumerable: !0
  2360. },
  2361. bl: {
  2362. get: function () {
  2363. return this._bl
  2364. },
  2365. set: function (a) {
  2366. var c = this._bl;
  2367. c.vertices = a.vertices;
  2368. c.colors = a.colors;
  2369. c.texCoords = a.texCoords
  2370. },
  2371. enumerable: !0
  2372. },
  2373. tr: {
  2374. get: function () {
  2375. return this._tr
  2376. },
  2377. set: function (a) {
  2378. var c = this._tr;
  2379. c.vertices = a.vertices;
  2380. c.colors = a.colors;
  2381. c.texCoords = a.texCoords
  2382. },
  2383. enumerable: !0
  2384. },
  2385. br: {
  2386. get: function () {
  2387. return this._br
  2388. },
  2389. set: function (a) {
  2390. var c = this._br;
  2391. c.vertices = a.vertices;
  2392. c.colors = a.colors;
  2393. c.texCoords = a.texCoords
  2394. },
  2395. enumerable: !0
  2396. },
  2397. arrayBuffer: {
  2398. get: function () {
  2399. return this._arrayBuffer
  2400. },
  2401. enumerable: !0
  2402. }
  2403. });
  2404. cc.V3F_C4B_T2F_QuadZero = function () {
  2405. return new cc.V3F_C4B_T2F_Quad
  2406. };
  2407. cc.V3F_C4B_T2F_QuadCopy = function (a) {
  2408. if (!a) return cc.V3F_C4B_T2F_QuadZero();
  2409. var c = a.tl,
  2410. d = a.bl,
  2411. e = a.tr;
  2412. a = a.br;
  2413. return {
  2414. tl: {
  2415. vertices: {
  2416. x: c.vertices.x,
  2417. y: c.vertices.y,
  2418. z: c.vertices.z
  2419. },
  2420. colors: {
  2421. r: c.colors.r,
  2422. g: c.colors.g,
  2423. b: c.colors.b,
  2424. a: c.colors.a
  2425. },
  2426. texCoords: {
  2427. u: c.texCoords.u,
  2428. v: c.texCoords.v
  2429. }
  2430. },
  2431. bl: {
  2432. vertices: {
  2433. x: d.vertices.x,
  2434. y: d.vertices.y,
  2435. z: d.vertices.z
  2436. },
  2437. colors: {
  2438. r: d.colors.r,
  2439. g: d.colors.g,
  2440. b: d.colors.b,
  2441. a: d.colors.a
  2442. },
  2443. texCoords: {
  2444. u: d.texCoords.u,
  2445. v: d.texCoords.v
  2446. }
  2447. },
  2448. tr: {
  2449. vertices: {
  2450. x: e.vertices.x,
  2451. y: e.vertices.y,
  2452. z: e.vertices.z
  2453. },
  2454. colors: {
  2455. r: e.colors.r,
  2456. g: e.colors.g,
  2457. b: e.colors.b,
  2458. a: e.colors.a
  2459. },
  2460. texCoords: {
  2461. u: e.texCoords.u,
  2462. v: e.texCoords.v
  2463. }
  2464. },
  2465. br: {
  2466. vertices: {
  2467. x: a.vertices.x,
  2468. y: a.vertices.y,
  2469. z: a.vertices.z
  2470. },
  2471. colors: {
  2472. r: a.colors.r,
  2473. g: a.colors.g,
  2474. b: a.colors.b,
  2475. a: a.colors.a
  2476. },
  2477. texCoords: {
  2478. u: a.texCoords.u,
  2479. v: a.texCoords.v
  2480. }
  2481. }
  2482. }
  2483. };
  2484. cc.V3F_C4B_T2F_QuadsCopy = function (a) {
  2485. if (!a) return [];
  2486. for (var c = [], d = 0; d < a.length; d++) c.push(cc.V3F_C4B_T2F_QuadCopy(a[d]));
  2487. return c
  2488. };
  2489. cc.V2F_C4B_T2F = function (a, c, d, e, f) {
  2490. this._arrayBuffer = e || new ArrayBuffer(cc.V2F_C4B_T2F.BYTES_PER_ELEMENT);
  2491. this._offset = f || 0;
  2492. e = this._arrayBuffer;
  2493. f = this._offset;
  2494. var g = cc.Vertex2F.BYTES_PER_ELEMENT;
  2495. this._vertices = a ? new cc.Vertex2F(a.x, a.y, e, f) : new cc.Vertex2F(0, 0, e, f);
  2496. 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);
  2497. 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)
  2498. };
  2499. cc.V2F_C4B_T2F.BYTES_PER_ELEMENT = 20;
  2500. Object.defineProperties(cc.V2F_C4B_T2F.prototype, {
  2501. vertices: {
  2502. get: function () {
  2503. return this._vertices
  2504. },
  2505. set: function (a) {
  2506. this._vertices.x = a.x;
  2507. this._vertices.y = a.y
  2508. },
  2509. enumerable: !0
  2510. },
  2511. colors: {
  2512. get: function () {
  2513. return this._colors
  2514. },
  2515. set: function (a) {
  2516. var c = this._colors;
  2517. c.r = a.r;
  2518. c.g = a.g;
  2519. c.b = a.b;
  2520. c.a = a.a
  2521. },
  2522. enumerable: !0
  2523. },
  2524. texCoords: {
  2525. get: function () {
  2526. return this._texCoords
  2527. },
  2528. set: function (a) {
  2529. this._texCoords.u = a.u;
  2530. this._texCoords.v = a.v
  2531. },
  2532. enumerable: !0
  2533. }
  2534. });
  2535. cc.V2F_C4B_T2F_Triangle = function (a, c, d, e, f) {
  2536. this._arrayBuffer = e || new ArrayBuffer(cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT);
  2537. this._offset = f || 0;
  2538. e = this._arrayBuffer;
  2539. f = this._offset;
  2540. var g = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  2541. 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);
  2542. 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);
  2543. this._c = d ? new cc.V2F_C4B_T2F(d.vertices, d.colors, d.texCoords, e, f + 2 * g) : new cc.V2F_C4B_T2F(null, null, null, e, f + 2 * g)
  2544. };
  2545. cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT = 60;
  2546. Object.defineProperties(cc.V2F_C4B_T2F_Triangle.prototype, {
  2547. a: {
  2548. get: function () {
  2549. return this._a
  2550. },
  2551. set: function (a) {
  2552. var c = this._a;
  2553. c.vertices = a.vertices;
  2554. c.colors = a.colors;
  2555. c.texCoords = a.texCoords
  2556. },
  2557. enumerable: !0
  2558. },
  2559. b: {
  2560. get: function () {
  2561. return this._b
  2562. },
  2563. set: function (a) {
  2564. var c = this._b;
  2565. c.vertices = a.vertices;
  2566. c.colors = a.colors;
  2567. c.texCoords = a.texCoords
  2568. },
  2569. enumerable: !0
  2570. },
  2571. c: {
  2572. get: function () {
  2573. return this._c
  2574. },
  2575. set: function (a) {
  2576. var c = this._c;
  2577. c.vertices = a.vertices;
  2578. c.colors = a.colors;
  2579. c.texCoords = a.texCoords
  2580. },
  2581. enumerable: !0
  2582. }
  2583. })
  2584. };
  2585. cc._tmp.PrototypeColor = function () {
  2586. var a = cc.color;
  2587. a._getWhite = function () {
  2588. return a(255, 255, 255)
  2589. };
  2590. a._getYellow = function () {
  2591. return a(255, 255, 0)
  2592. };
  2593. a._getBlue = function () {
  2594. return a(0, 0, 255)
  2595. };
  2596. a._getGreen = function () {
  2597. return a(0, 255, 0)
  2598. };
  2599. a._getRed = function () {
  2600. return a(255, 0, 0)
  2601. };
  2602. a._getMagenta = function () {
  2603. return a(255, 0, 255)
  2604. };
  2605. a._getBlack = function () {
  2606. return a(0, 0, 0)
  2607. };
  2608. a._getOrange = function () {
  2609. return a(255, 127, 0)
  2610. };
  2611. a._getGray = function () {
  2612. return a(166, 166, 166)
  2613. };
  2614. cc.defineGetterSetter(a, "WHITE", a._getWhite);
  2615. cc.defineGetterSetter(a, "YELLOW", a._getYellow);
  2616. cc.defineGetterSetter(a, "BLUE", a._getBlue);
  2617. cc.defineGetterSetter(a, "GREEN", a._getGreen);
  2618. cc.defineGetterSetter(a, "RED", a._getRed);
  2619. cc.defineGetterSetter(a, "MAGENTA", a._getMagenta);
  2620. cc.defineGetterSetter(a, "BLACK", a._getBlack);
  2621. cc.defineGetterSetter(a, "ORANGE", a._getOrange);
  2622. cc.defineGetterSetter(a, "GRAY", a._getGray);
  2623. cc.BlendFunc._disable = function () {
  2624. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2625. };
  2626. cc.BlendFunc._alphaPremultiplied = function () {
  2627. return new cc.BlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA)
  2628. };
  2629. cc.BlendFunc._alphaNonPremultiplied = function () {
  2630. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA)
  2631. };
  2632. cc.BlendFunc._additive = function () {
  2633. return new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE)
  2634. };
  2635. cc.defineGetterSetter(cc.BlendFunc, "DISABLE", cc.BlendFunc._disable);
  2636. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_PREMULTIPLIED", cc.BlendFunc._alphaPremultiplied);
  2637. cc.defineGetterSetter(cc.BlendFunc, "ALPHA_NON_PREMULTIPLIED", cc.BlendFunc._alphaNonPremultiplied);
  2638. cc.defineGetterSetter(cc.BlendFunc, "ADDITIVE", cc.BlendFunc._additive)
  2639. };
  2640. cc.Color = function (a, b, c, d) {
  2641. this.r = a || 0;
  2642. this.g = b || 0;
  2643. this.b = c || 0;
  2644. this.a = null == d ? 255 : d
  2645. };
  2646. cc.color = function (a, b, c, d) {
  2647. return void 0 === a ? {
  2648. r: 0,
  2649. g: 0,
  2650. b: 0,
  2651. a: 255
  2652. } : cc.isString(a) ? cc.hexToColor(a) : cc.isObject(a) ? {
  2653. r: a.r,
  2654. g: a.g,
  2655. b: a.b,
  2656. a: null == a.a ? 255 : a.a
  2657. } : {
  2658. r: a,
  2659. g: b,
  2660. b: c,
  2661. a: null == d ? 255 : d
  2662. }
  2663. };
  2664. cc.colorEqual = function (a, b) {
  2665. return a.r === b.r && a.g === b.g && a.b === b.b
  2666. };
  2667. cc.Acceleration = function (a, b, c, d) {
  2668. this.x = a || 0;
  2669. this.y = b || 0;
  2670. this.z = c || 0;
  2671. this.timestamp = d || 0
  2672. };
  2673. cc.Vertex2F = function (a, b) {
  2674. this.x = a || 0;
  2675. this.y = b || 0
  2676. };
  2677. cc.vertex2 = function (a, b) {
  2678. return new cc.Vertex2F(a, b)
  2679. };
  2680. cc.Vertex3F = function (a, b, c) {
  2681. this.x = a || 0;
  2682. this.y = b || 0;
  2683. this.z = c || 0
  2684. };
  2685. cc.vertex3 = function (a, b, c) {
  2686. return new cc.Vertex3F(a, b, c)
  2687. };
  2688. cc.Tex2F = function (a, b) {
  2689. this.u = a || 0;
  2690. this.v = b || 0
  2691. };
  2692. cc.tex2 = function (a, b) {
  2693. return new cc.Tex2F(a, b)
  2694. };
  2695. cc.BlendFunc = function (a, b) {
  2696. this.src = a;
  2697. this.dst = b
  2698. };
  2699. cc.blendFuncDisable = function () {
  2700. return new cc.BlendFunc(cc.ONE, cc.ZERO)
  2701. };
  2702. cc.hexToColor = function (a) {
  2703. a = a.replace(/^#?/, "0x");
  2704. a = parseInt(a);
  2705. return cc.color(a >> 16, (a >> 8) % 256, a % 256)
  2706. };
  2707. cc.colorToHex = function (a) {
  2708. var b = a.r.toString(16),
  2709. c = a.g.toString(16),
  2710. d = a.b.toString(16);
  2711. return "#" + (16 > a.r ? "0" + b : b) + (16 > a.g ? "0" + c : c) + (16 > a.b ? "0" + d : d)
  2712. };
  2713. cc.TEXT_ALIGNMENT_LEFT = 0;
  2714. cc.TEXT_ALIGNMENT_CENTER = 1;
  2715. cc.TEXT_ALIGNMENT_RIGHT = 2;
  2716. cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
  2717. cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
  2718. cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
  2719. cc._Dictionary = cc.Class.extend({
  2720. _keyMapTb: null,
  2721. _valueMapTb: null,
  2722. __currId: 0,
  2723. ctor: function () {
  2724. this._keyMapTb = {};
  2725. this._valueMapTb = {};
  2726. this.__currId = 2 << (0 | 10 * Math.random())
  2727. },
  2728. __getKey: function () {
  2729. this.__currId++;
  2730. return "key_" + this.__currId
  2731. },
  2732. setObject: function (a, b) {
  2733. if (null != b) {
  2734. var c = this.__getKey();
  2735. this._keyMapTb[c] = b;
  2736. this._valueMapTb[c] = a
  2737. }
  2738. },
  2739. objectForKey: function (a) {
  2740. if (null == a) return null;
  2741. var b = this._keyMapTb,
  2742. c;
  2743. for (c in b) if (b[c] === a) return this._valueMapTb[c];
  2744. return null
  2745. },
  2746. valueForKey: function (a) {
  2747. return this.objectForKey(a)
  2748. },
  2749. removeObjectForKey: function (a) {
  2750. if (null != a) {
  2751. var b = this._keyMapTb,
  2752. c;
  2753. for (c in b) if (b[c] === a) {
  2754. delete this._valueMapTb[c];
  2755. delete b[c];
  2756. break
  2757. }
  2758. }
  2759. },
  2760. removeObjectsForKeys: function (a) {
  2761. if (null != a) for (var b = 0; b < a.length; b++) this.removeObjectForKey(a[b])
  2762. },
  2763. allKeys: function () {
  2764. var a = [],
  2765. b = this._keyMapTb,
  2766. c;
  2767. for (c in b) a.push(b[c]);
  2768. return a
  2769. },
  2770. removeAllObjects: function () {
  2771. this._keyMapTb = {};
  2772. this._valueMapTb = {}
  2773. },
  2774. count: function () {
  2775. return this.allKeys().length
  2776. }
  2777. });
  2778. cc.FontDefinition = function () {
  2779. this.fontName = "Arial";
  2780. this.fontSize = 12;
  2781. this.textAlign = cc.TEXT_ALIGNMENT_CENTER;
  2782. this.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  2783. this.fillStyle = cc.color(255, 255, 255, 255);
  2784. this.boundingHeight = this.boundingWidth = 0;
  2785. this.strokeEnabled = !1;
  2786. this.strokeStyle = cc.color(255, 255, 255, 255);
  2787. this.lineWidth = 1;
  2788. this.shadowEnabled = !1;
  2789. this.shadowBlur = this.shadowOffsetY = this.shadowOffsetX = 0;
  2790. this.shadowOpacity = 1
  2791. };
  2792. 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);
  2793. cc.assert(cc.isFunction(cc._tmp.PrototypeColor), cc._LogInfos.MissingFile, "CCTypesPropertyDefine.js");
  2794. cc._tmp.PrototypeColor();
  2795. delete cc._tmp.PrototypeColor;
  2796. cc.Touches = [];
  2797. cc.TouchesIntergerDict = {};
  2798. cc.DENSITYDPI_DEVICE = "device-dpi";
  2799. cc.DENSITYDPI_HIGH = "high-dpi";
  2800. cc.DENSITYDPI_MEDIUM = "medium-dpi";
  2801. cc.DENSITYDPI_LOW = "low-dpi";
  2802. cc.EGLView = cc.Class.extend({
  2803. _delegate: null,
  2804. _frameSize: null,
  2805. _designResolutionSize: null,
  2806. _originalDesignResolutionSize: null,
  2807. _viewPortRect: null,
  2808. _visibleRect: null,
  2809. _retinaEnabled: !1,
  2810. _autoFullScreen: !0,
  2811. _devicePixelRatio: 1,
  2812. _viewName: "",
  2813. _resizeCallback: null,
  2814. _scaleX: 1,
  2815. _originalScaleX: 1,
  2816. _scaleY: 1,
  2817. _originalScaleY: 1,
  2818. _indexBitsUsed: 0,
  2819. _maxTouches: 5,
  2820. _resolutionPolicy: null,
  2821. _rpExactFit: null,
  2822. _rpShowAll: null,
  2823. _rpNoBorder: null,
  2824. _rpFixedHeight: null,
  2825. _rpFixedWidth: null,
  2826. _initialized: !1,
  2827. _captured: !1,
  2828. _wnd: null,
  2829. _hDC: null,
  2830. _hRC: null,
  2831. _supportTouch: !1,
  2832. _contentTranslateLeftTop: null,
  2833. _frame: null,
  2834. _frameZoomFactor: 1,
  2835. __resizeWithBrowserSize: !1,
  2836. _isAdjustViewPort: !0,
  2837. _targetDensityDPI: null,
  2838. ctor: function () {
  2839. var a = document,
  2840. b = cc.ContainerStrategy,
  2841. c = cc.ContentStrategy;
  2842. this._frame = cc.container.parentNode === a.body ? a.documentElement : cc.container.parentNode;
  2843. this._frameSize = cc.size(0, 0);
  2844. this._initFrameSize();
  2845. var a = cc._canvas.width,
  2846. d = cc._canvas.height;
  2847. this._designResolutionSize = cc.size(a, d);
  2848. this._originalDesignResolutionSize = cc.size(a, d);
  2849. this._viewPortRect = cc.rect(0, 0, a, d);
  2850. this._visibleRect = cc.rect(0, 0, a, d);
  2851. this._contentTranslateLeftTop = {
  2852. left: 0,
  2853. top: 0
  2854. };
  2855. this._viewName = "Cocos2dHTML5";
  2856. a = cc.sys;
  2857. this.enableRetina(a.os == a.OS_IOS || a.os == a.OS_OSX);
  2858. cc.visibleRect && cc.visibleRect.init(this._visibleRect);
  2859. this._rpExactFit = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.EXACT_FIT);
  2860. this._rpShowAll = new cc.ResolutionPolicy(b.PROPORTION_TO_FRAME, c.SHOW_ALL);
  2861. this._rpNoBorder = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.NO_BORDER);
  2862. this._rpFixedHeight = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_HEIGHT);
  2863. this._rpFixedWidth = new cc.ResolutionPolicy(b.EQUAL_TO_FRAME, c.FIXED_WIDTH);
  2864. this._hDC = cc._canvas;
  2865. this._hRC = cc._renderContext;
  2866. this._targetDensityDPI = cc.DENSITYDPI_HIGH
  2867. },
  2868. _resizeEvent: function () {
  2869. var a = this._originalDesignResolutionSize.width,
  2870. b = this._originalDesignResolutionSize.height;
  2871. this._resizeCallback && (this._initFrameSize(), this._resizeCallback.call());
  2872. 0 < a && this.setDesignResolutionSize(a, b, this._resolutionPolicy)
  2873. },
  2874. setTargetDensityDPI: function (a) {
  2875. this._targetDensityDPI = a;
  2876. this._setViewPortMeta()
  2877. },
  2878. getTargetDensityDPI: function () {
  2879. return this._targetDensityDPI
  2880. },
  2881. resizeWithBrowserSize: function (a) {
  2882. a ? this.__resizeWithBrowserSize || (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this), cc._addEventListener(window, "resize", a, !1)) : this.__resizeWithBrowserSize && (this.__resizeWithBrowserSize = !0, a = this._resizeEvent.bind(this), window.removeEventListener("resize", a, !1))
  2883. },
  2884. setResizeCallback: function (a) {
  2885. if (cc.isFunction(a) || null == a) this._resizeCallback = a
  2886. },
  2887. _initFrameSize: function () {
  2888. var a = this._frameSize,
  2889. b = Math.min(window.screen.availWidth, window.screen.width) * window.devicePixelRatio,
  2890. c = Math.min(window.screen.availHeight, window.screen.height) * window.devicePixelRatio;
  2891. a.width = cc.sys.isMobile && this._frame.clientWidth >= 0.8 * b ? b / window.devicePixelRatio : this._frame.clientWidth;
  2892. a.height = cc.sys.isMobile && this._frame.clientWidth >= 0.8 * c ? c / window.devicePixelRatio : this._frame.clientHeight
  2893. },
  2894. _adjustSizeKeepCanvasSize: function () {
  2895. var a = this._originalDesignResolutionSize.width,
  2896. b = this._originalDesignResolutionSize.height;
  2897. 0 < a && this.setDesignResolutionSize(a, b, this._resolutionPolicy)
  2898. },
  2899. _setViewPortMeta: function (a, b) {
  2900. if (this._isAdjustViewPort) {
  2901. var c = document.getElementById("cocosMetaElement");
  2902. c && document.head.removeChild(c);
  2903. var d,
  2904. e = document.getElementsByName("viewport"),
  2905. f,
  2906. c = cc.newElement("meta");
  2907. c.id = "cocosMetaElement";
  2908. c.name = "viewport";
  2909. c.content = "";
  2910. d = cc.sys.isMobile && cc.sys.browserType == cc.sys.BROWSER_TYPE_FIREFOX ? {
  2911. width: "device-width",
  2912. "initial-scale": "1.0"
  2913. } : {
  2914. width: "device-width",
  2915. "user-scalable": "no",
  2916. "maximum-scale": "1.0",
  2917. "initial-scale": "1.0"
  2918. };
  2919. cc.sys.isMobile && (d["target-densitydpi"] = this._targetDensityDPI);
  2920. f = e && 0 < e.length ? e[0].content : "";
  2921. for (var g in d) RegExp(g).test(f) || (f += "," + g + "\x3d" + d[g]);
  2922. e || "" == f || (f = f.substr(1));
  2923. c.content = f;
  2924. document.head.appendChild(c)
  2925. }
  2926. },
  2927. _setScaleXYForRenderTexture: function () {
  2928. var a = cc.contentScaleFactor();
  2929. this._scaleY = this._scaleX = a
  2930. },
  2931. _resetScale: function () {
  2932. this._scaleX = this._originalScaleX;
  2933. this._scaleY = this._originalScaleY
  2934. },
  2935. _adjustSizeToBrowser: function () { },
  2936. initialize: function () {
  2937. this._initialized = !0
  2938. },
  2939. adjustViewPort: function (a) {
  2940. this._isAdjustViewPort = a
  2941. },
  2942. enableRetina: function (a) {
  2943. this._retinaEnabled = a ? !0 : !1
  2944. },
  2945. isRetinaEnabled: function () {
  2946. return this._retinaEnabled
  2947. },
  2948. enableAutoFullScreen: function (a) {
  2949. this._autoFullScreen = a ? !0 : !1
  2950. },
  2951. isAutoFullScreenEnabled: function () {
  2952. return this._autoFullScreen
  2953. },
  2954. end: function () { },
  2955. isOpenGLReady: function () {
  2956. return null != this._hDC && null != this._hRC
  2957. },
  2958. setFrameZoomFactor: function (a) {
  2959. this._frameZoomFactor = a;
  2960. this.centerWindow();
  2961. cc.director.setProjection(cc.director.getProjection())
  2962. },
  2963. swapBuffers: function () { },
  2964. setIMEKeyboardState: function (a) { },
  2965. setContentTranslateLeftTop: function (a, b) {
  2966. this._contentTranslateLeftTop = {
  2967. left: a,
  2968. top: b
  2969. }
  2970. },
  2971. getContentTranslateLeftTop: function () {
  2972. return this._contentTranslateLeftTop
  2973. },
  2974. getFrameSize: function () {
  2975. return cc.size(this._frameSize.width, this._frameSize.height)
  2976. },
  2977. setFrameSize: function (a, b) {
  2978. this._frameSize.width = a;
  2979. this._frameSize.height = b;
  2980. this._frame.style.width = a + "px";
  2981. this._frame.style.height = b + "px";
  2982. this._resizeEvent();
  2983. cc.director.setProjection(cc.director.getProjection())
  2984. },
  2985. centerWindow: function () { },
  2986. getVisibleSize: function () {
  2987. return cc.size(this._visibleRect.width, this._visibleRect.height)
  2988. },
  2989. getVisibleOrigin: function () {
  2990. return cc.p(this._visibleRect.x, this._visibleRect.y)
  2991. },
  2992. canSetContentScaleFactor: function () {
  2993. return !0
  2994. },
  2995. getResolutionPolicy: function () {
  2996. return this._resolutionPolicy
  2997. },
  2998. setResolutionPolicy: function (a) {
  2999. if (a instanceof cc.ResolutionPolicy) this._resolutionPolicy = a;
  3000. else {
  3001. var b = cc.ResolutionPolicy;
  3002. a === b.EXACT_FIT && (this._resolutionPolicy = this._rpExactFit);
  3003. a === b.SHOW_ALL && (this._resolutionPolicy = this._rpShowAll);
  3004. a === b.NO_BORDER && (this._resolutionPolicy = this._rpNoBorder);
  3005. a === b.FIXED_HEIGHT && (this._resolutionPolicy = this._rpFixedHeight);
  3006. a === b.FIXED_WIDTH && (this._resolutionPolicy = this._rpFixedWidth)
  3007. }
  3008. },
  3009. setDesignResolutionSize: function (a, b, c) {
  3010. if (isNaN(a) || 0 == a || isNaN(b) || 0 == b) cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);
  3011. else {
  3012. var d = this._resolutionPolicy;
  3013. this.setResolutionPolicy(c);
  3014. if (c = this._resolutionPolicy) {
  3015. c.preApply(this);
  3016. var e = this._frameSize.width,
  3017. f = this._frameSize.height;
  3018. cc.sys.isMobile && this._setViewPortMeta(this._frameSize.width, this._frameSize.height);
  3019. this._initFrameSize();
  3020. if (d != this._resolutionPolicy || a != this._originalDesignResolutionSize.width || b != this._originalDesignResolutionSize.height || e != this._frameSize.width || f != this._frameSize.height) this._designResolutionSize = cc.size(a, b),
  3021. this._originalDesignResolutionSize = cc.size(a, b),
  3022. a = c.apply(this, this._designResolutionSize),
  3023. a.scale && 2 == a.scale.length && (this._scaleX = a.scale[0], this._scaleY = a.scale[1]),
  3024. a.viewport && (a = this._viewPortRect = a.viewport, b = this._visibleRect, b.width = cc._canvas.width / this._scaleX, b.height = cc._canvas.height / this._scaleY, b.x = -a.x / this._scaleX, b.y = -a.y / this._scaleY),
  3025. a = cc.director,
  3026. a._winSizeInPoints.width = this._designResolutionSize.width,
  3027. a._winSizeInPoints.height = this._designResolutionSize.height,
  3028. cc.winSize.width = a._winSizeInPoints.width,
  3029. cc.winSize.height = a._winSizeInPoints.height,
  3030. c.postApply(this),
  3031. cc._renderType == cc._RENDER_TYPE_WEBGL && (a._createStatsLabel(), a.setGLDefaultValues()),
  3032. this._originalScaleX = this._scaleX,
  3033. this._originalScaleY = this._scaleY,
  3034. cc.DOM && cc.DOM._resetEGLViewDiv(),
  3035. cc.visibleRect && cc.visibleRect.init(this._visibleRect)
  3036. } else cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2)
  3037. }
  3038. },
  3039. getDesignResolutionSize: function () {
  3040. return cc.size(this._designResolutionSize.width, this._designResolutionSize.height)
  3041. },
  3042. setViewPortInPoints: function (a, b, c, d) {
  3043. var e = this._frameZoomFactor,
  3044. f = this._scaleX,
  3045. g = this._scaleY;
  3046. cc._renderContext.viewport(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  3047. },
  3048. setScissorInPoints: function (a, b, c, d) {
  3049. var e = this._frameZoomFactor,
  3050. f = this._scaleX,
  3051. g = this._scaleY;
  3052. cc._renderContext.scissor(a * f * e + this._viewPortRect.x * e, b * g * e + this._viewPortRect.y * e, c * f * e, d * g * e)
  3053. },
  3054. isScissorEnabled: function () {
  3055. var a = cc._renderContext;
  3056. return a.isEnabled(a.SCISSOR_TEST)
  3057. },
  3058. getScissorRect: function () {
  3059. var a = cc._renderContext,
  3060. b = this._scaleX,
  3061. c = this._scaleY,
  3062. a = a.getParameter(a.SCISSOR_BOX);
  3063. return cc.rect((a[0] - this._viewPortRect.x) / b, (a[1] - this._viewPortRect.y) / c, a[2] / b, a[3] / c)
  3064. },
  3065. setViewName: function (a) {
  3066. null != a && 0 < a.length && (this._viewName = a)
  3067. },
  3068. getViewName: function () {
  3069. return this._viewName
  3070. },
  3071. getViewPortRect: function () {
  3072. return this._viewPortRect
  3073. },
  3074. getScaleX: function () {
  3075. return this._scaleX
  3076. },
  3077. getScaleY: function () {
  3078. return this._scaleY
  3079. },
  3080. getDevicePixelRatio: function () {
  3081. return this._devicePixelRatio
  3082. },
  3083. convertToLocationInView: function (a, b, c) {
  3084. return {
  3085. x: this._devicePixelRatio * (a - c.left),
  3086. y: this._devicePixelRatio * (c.top + c.height - b)
  3087. }
  3088. },
  3089. _convertMouseToLocationInView: function (a, b) {
  3090. var c = this._viewPortRect;
  3091. a.x = (this._devicePixelRatio * (a.x - b.left) - c.x) / this._scaleX;
  3092. a.y = (this._devicePixelRatio * (b.top + b.height - a.y) - c.y) / this._scaleY
  3093. },
  3094. _convertTouchesWithScale: function (a) {
  3095. for (var b = this._viewPortRect, c = this._scaleX, d = this._scaleY, e, f, g, h = 0; h < a.length; h++) e = a[h],
  3096. f = e._point,
  3097. g = e._prevPoint,
  3098. e._setPoint((f.x - b.x) / c, (f.y - b.y) / d),
  3099. e._setPrevPoint((g.x - b.x) / c, (g.y - b.y) / d)
  3100. }
  3101. });
  3102. cc.EGLView._getInstance = function () {
  3103. this._instance || (this._instance = this._instance || new cc.EGLView, this._instance.initialize());
  3104. return this._instance
  3105. };
  3106. cc.ContainerStrategy = cc.Class.extend({
  3107. preApply: function (a) { },
  3108. apply: function (a, b) { },
  3109. postApply: function (a) { },
  3110. _setupContainer: function (a, b, c) {
  3111. var d = a._frame;
  3112. cc.view._autoFullScreen && cc.sys.isMobile && d == document.documentElement && cc.screen.autoFullScreen(d);
  3113. var d = cc._canvas,
  3114. e = cc.container;
  3115. e.style.width = d.style.width = b + "px";
  3116. e.style.height = d.style.height = c + "px";
  3117. e = a._devicePixelRatio = 1;
  3118. a.isRetinaEnabled() && (e = a._devicePixelRatio = window.devicePixelRatio || 1);
  3119. d.width = b * e;
  3120. d.height = c * e;
  3121. a = document.body;
  3122. var f;
  3123. 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")
  3124. },
  3125. _fixContainer: function () {
  3126. document.body.insertBefore(cc.container, document.body.firstChild);
  3127. var a = document.body.style;
  3128. a.width = window.innerWidth + "px";
  3129. a.height = window.innerHeight + "px";
  3130. a.overflow = "hidden";
  3131. a = cc.container.style;
  3132. a.position = "fixed";
  3133. a.left = a.top = "0px";
  3134. document.body.scrollTop = 0
  3135. }
  3136. });
  3137. cc.ContentStrategy = cc.Class.extend({
  3138. _result: {
  3139. scale: [1, 1],
  3140. viewport: null
  3141. },
  3142. _buildResult: function (a, b, c, d, e, f) {
  3143. 2 > Math.abs(a - c) && (c = a);
  3144. 2 > Math.abs(b - d) && (d = b);
  3145. a = cc.rect(Math.round((a - c) / 2), Math.round((b - d) / 2), c, d);
  3146. cc._renderType == cc._RENDER_TYPE_CANVAS && cc._renderContext.translate(a.x, a.y + d);
  3147. this._result.scale = [e, f];
  3148. this._result.viewport = a;
  3149. return this._result
  3150. },
  3151. preApply: function (a) { },
  3152. apply: function (a, b) {
  3153. return {
  3154. scale: [1, 1]
  3155. }
  3156. },
  3157. postApply: function (a) { }
  3158. }); (function () {
  3159. var a = cc.ContainerStrategy.extend({
  3160. apply: function (a) {
  3161. this._setupContainer(a, a._frameSize.width, a._frameSize.height)
  3162. }
  3163. }),
  3164. b = cc.ContainerStrategy.extend({
  3165. apply: function (a, b) {
  3166. var c = a._frameSize.width,
  3167. d = a._frameSize.height,
  3168. e = cc.container.style,
  3169. n = b.width,
  3170. q = b.height,
  3171. r = c / n,
  3172. s = d / q,
  3173. t,
  3174. u;
  3175. r < s ? (t = c, u = q * r) : (t = n * s, u = d);
  3176. n = Math.round((c - t) / 2);
  3177. u = Math.round((d - u) / 2);
  3178. this._setupContainer(a, c - 2 * n, d - 2 * u);
  3179. e.marginLeft = n + "px";
  3180. e.marginRight = n + "px";
  3181. e.marginTop = u + "px";
  3182. e.marginBottom = u + "px"
  3183. }
  3184. });
  3185. a.extend({
  3186. preApply: function (a) {
  3187. this._super(a);
  3188. a._frame = document.documentElement
  3189. },
  3190. apply: function (a) {
  3191. this._super(a);
  3192. this._fixContainer()
  3193. }
  3194. });
  3195. b.extend({
  3196. preApply: function (a) {
  3197. this._super(a);
  3198. a._frame = document.documentElement
  3199. },
  3200. apply: function (a, b) {
  3201. this._super(a, b);
  3202. this._fixContainer()
  3203. }
  3204. });
  3205. var c = cc.ContainerStrategy.extend({
  3206. apply: function (a) {
  3207. this._setupContainer(a, cc._canvas.width, cc._canvas.height)
  3208. }
  3209. });
  3210. cc.ContainerStrategy.EQUAL_TO_FRAME = new a;
  3211. cc.ContainerStrategy.PROPORTION_TO_FRAME = new b;
  3212. cc.ContainerStrategy.ORIGINAL_CONTAINER = new c;
  3213. var a = cc.ContentStrategy.extend({
  3214. apply: function (a, b) {
  3215. var c = cc._canvas.width,
  3216. d = cc._canvas.height;
  3217. return this._buildResult(c, d, c, d, c / b.width, d / b.height)
  3218. }
  3219. }),
  3220. b = cc.ContentStrategy.extend({
  3221. apply: function (a, b) {
  3222. var c = cc._canvas.width,
  3223. d = cc._canvas.height,
  3224. e = b.width,
  3225. n = b.height,
  3226. q = c / e,
  3227. r = d / n,
  3228. s = 0,
  3229. t,
  3230. u;
  3231. q < r ? (s = q, t = c, u = n * s) : (s = r, t = e * s, u = d);
  3232. return this._buildResult(c, d, t, u, s, s)
  3233. }
  3234. }),
  3235. c = cc.ContentStrategy.extend({
  3236. apply: function (a, b) {
  3237. var c = cc._canvas.width,
  3238. d = cc._canvas.height,
  3239. e = c / b.width,
  3240. n = d / b.height,
  3241. q;
  3242. e < n ? q = n : q = e;
  3243. return this._buildResult(c, d, c, d, q, q)
  3244. }
  3245. }),
  3246. d = cc.ContentStrategy.extend({
  3247. apply: function (a, b) {
  3248. var c = cc._canvas.width,
  3249. d = cc._canvas.height,
  3250. e = d / b.height;
  3251. return this._buildResult(c, d, c, d, e, e)
  3252. },
  3253. postApply: function (a) {
  3254. cc.director._winSizeInPoints = a.getVisibleSize()
  3255. }
  3256. }),
  3257. e = cc.ContentStrategy.extend({
  3258. apply: function (a, b) {
  3259. var c = cc._canvas.width,
  3260. d = cc._canvas.height,
  3261. e = c / b.width;
  3262. return this._buildResult(c, d, c, d, e, e)
  3263. },
  3264. postApply: function (a) {
  3265. cc.director._winSizeInPoints = a.getVisibleSize()
  3266. }
  3267. });
  3268. cc.ContentStrategy.EXACT_FIT = new a;
  3269. cc.ContentStrategy.SHOW_ALL = new b;
  3270. cc.ContentStrategy.NO_BORDER = new c;
  3271. cc.ContentStrategy.FIXED_HEIGHT = new d;
  3272. cc.ContentStrategy.FIXED_WIDTH = new e
  3273. })();
  3274. cc.ResolutionPolicy = cc.Class.extend({
  3275. _containerStrategy: null,
  3276. _contentStrategy: null,
  3277. ctor: function (a, b) {
  3278. this.setContainerStrategy(a);
  3279. this.setContentStrategy(b)
  3280. },
  3281. preApply: function (a) {
  3282. this._containerStrategy.preApply(a);
  3283. this._contentStrategy.preApply(a)
  3284. },
  3285. apply: function (a, b) {
  3286. this._containerStrategy.apply(a, b);
  3287. return this._contentStrategy.apply(a, b)
  3288. },
  3289. postApply: function (a) {
  3290. this._containerStrategy.postApply(a);
  3291. this._contentStrategy.postApply(a)
  3292. },
  3293. setContainerStrategy: function (a) {
  3294. a instanceof cc.ContainerStrategy && (this._containerStrategy = a)
  3295. },
  3296. setContentStrategy: function (a) {
  3297. a instanceof cc.ContentStrategy && (this._contentStrategy = a)
  3298. }
  3299. });
  3300. cc.ResolutionPolicy.EXACT_FIT = 0;
  3301. cc.ResolutionPolicy.NO_BORDER = 1;
  3302. cc.ResolutionPolicy.SHOW_ALL = 2;
  3303. cc.ResolutionPolicy.FIXED_HEIGHT = 3;
  3304. cc.ResolutionPolicy.FIXED_WIDTH = 4;
  3305. cc.ResolutionPolicy.UNKNOWN = 5;
  3306. cc.screen = {
  3307. _supportsFullScreen: !1,
  3308. _preOnFullScreenChange: null,
  3309. _touchEvent: "",
  3310. _fn: null,
  3311. _fnMap: [["requestFullscreen", "exitFullscreen", "fullscreenchange", "fullscreenEnabled", "fullscreenElement"], ["requestFullScreen", "exitFullScreen", "fullScreenchange", "fullScreenEnabled", "fullScreenElement"], ["webkitRequestFullScreen", "webkitCancelFullScreen", "webkitfullscreenchange", "webkitIsFullScreen", "webkitCurrentFullScreenElement"], ["mozRequestFullScreen", "mozCancelFullScreen", "mozfullscreenchange", "mozFullScreen", "mozFullScreenElement"], ["msRequestFullscreen", "msExitFullscreen", "MSFullscreenChange", "msFullscreenEnabled", "msFullscreenElement"]],
  3312. init: function () {
  3313. this._fn = {};
  3314. var a,
  3315. b,
  3316. c = this._fnMap,
  3317. d;
  3318. a = 0;
  3319. for (l = c.length; a < l; a++) if ((b = c[a]) && b[1] in document) {
  3320. a = 0;
  3321. for (d = b.length; a < d; a++) this._fn[c[0][a]] = b[a];
  3322. break
  3323. }
  3324. this._supportsFullScreen = void 0 != this._fn.requestFullscreen;
  3325. this._touchEvent = "ontouchstart" in window ? "touchstart" : "mousedown"
  3326. },
  3327. fullScreen: function () {
  3328. return this._supportsFullScreen && document[this._fn.fullscreenEnabled]
  3329. },
  3330. requestFullScreen: function (a, b) {
  3331. if (this._supportsFullScreen) {
  3332. a = a || document.documentElement;
  3333. a[this._fn.requestFullscreen]();
  3334. if (b) {
  3335. var c = this._fn.fullscreenchange;
  3336. this._preOnFullScreenChange && document.removeEventListener(c, this._preOnFullScreenChange);
  3337. this._preOnFullScreenChange = b;
  3338. cc._addEventListener(document, c, b, !1)
  3339. }
  3340. return a[this._fn.requestFullscreen]()
  3341. }
  3342. },
  3343. exitFullScreen: function () {
  3344. return this._supportsFullScreen ? document[this._fn.exitFullscreen]() : !0
  3345. },
  3346. autoFullScreen: function (a, b) {
  3347. function c() {
  3348. e.requestFullScreen(a, b);
  3349. d.removeEventListener(e._touchEvent, c)
  3350. }
  3351. a = a || document.body;
  3352. var d = cc._canvas || a,
  3353. e = this;
  3354. this.requestFullScreen(a, b);
  3355. cc._addEventListener(d, this._touchEvent, c)
  3356. }
  3357. };
  3358. cc.screen.init();
  3359. cc.visibleRect = {
  3360. topLeft: cc.p(0, 0),
  3361. topRight: cc.p(0, 0),
  3362. top: cc.p(0, 0),
  3363. bottomLeft: cc.p(0, 0),
  3364. bottomRight: cc.p(0, 0),
  3365. bottom: cc.p(0, 0),
  3366. center: cc.p(0, 0),
  3367. left: cc.p(0, 0),
  3368. right: cc.p(0, 0),
  3369. width: 0,
  3370. height: 0,
  3371. init: function (a) {
  3372. var b = this.width = a.width,
  3373. c = this.height = a.height,
  3374. d = a.x;
  3375. a = a.y;
  3376. var e = a + c,
  3377. f = d + b;
  3378. this.topLeft.x = d;
  3379. this.topLeft.y = e;
  3380. this.topRight.x = f;
  3381. this.topRight.y = e;
  3382. this.top.x = d + b / 2;
  3383. this.top.y = e;
  3384. this.bottomLeft.x = d;
  3385. this.bottomLeft.y = a;
  3386. this.bottomRight.x = f;
  3387. this.bottomRight.y = a;
  3388. this.bottom.x = d + b / 2;
  3389. this.bottom.y = a;
  3390. this.center.x = d + b / 2;
  3391. this.center.y = a + c / 2;
  3392. this.left.x = d;
  3393. this.left.y = a + c / 2;
  3394. this.right.x = f;
  3395. this.right.y = a + c / 2
  3396. }
  3397. };
  3398. cc.UIInterfaceOrientationLandscapeLeft = -90;
  3399. cc.UIInterfaceOrientationLandscapeRight = 90;
  3400. cc.UIInterfaceOrientationPortraitUpsideDown = 180;
  3401. cc.UIInterfaceOrientationPortrait = 0;
  3402. cc.inputManager = {
  3403. _mousePressed: !1,
  3404. _isRegisterEvent: !1,
  3405. _preTouchPoint: cc.p(0, 0),
  3406. _prevMousePoint: cc.p(0, 0),
  3407. _preTouchPool: [],
  3408. _preTouchPoolPointer: 0,
  3409. _touches: [],
  3410. _touchesIntegerDict: {},
  3411. _indexBitsUsed: 0,
  3412. _maxTouches: 5,
  3413. _accelEnabled: !1,
  3414. _accelInterval: 1 / 30,
  3415. _accelMinus: 1,
  3416. _accelCurTime: 0,
  3417. _acceleration: null,
  3418. _accelDeviceEvent: null,
  3419. _getUnUsedIndex: function () {
  3420. for (var a = this._indexBitsUsed, b = 0; b < this._maxTouches; b++) {
  3421. if (!(a & 1)) return this._indexBitsUsed |= 1 << b,
  3422. b;
  3423. a >>= 1
  3424. }
  3425. return -1
  3426. },
  3427. _removeUsedIndexBit: function (a) {
  3428. 0 > a || a >= this._maxTouches || (a = ~(1 << a), this._indexBitsUsed &= a)
  3429. },
  3430. _glView: null,
  3431. handleTouchesBegin: function (a) {
  3432. for (var b, c, d, e = [], f = this._touchesIntegerDict, g = 0, h = a.length; g < h; g++) if (b = a[g], d = b.getID(), c = f[d], null == c) {
  3433. 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))
  3434. }
  3435. 0 < e.length && (this._glView._convertTouchesWithScale(e), a = new cc.EventTouch(e), a._eventCode = cc.EventTouch.EventCode.BEGAN, cc.eventManager.dispatchEvent(a))
  3436. },
  3437. handleTouchesMove: function (a) {
  3438. for (var b, c, d = [], e = this._touches, f = 0, g = a.length; f < g; f++) b = a[f],
  3439. c = b.getID(),
  3440. c = this._touchesIntegerDict[c],
  3441. null != c && e[c] && (e[c]._setPoint(b._point), e[c]._setPrevPoint(b._prevPoint), d.push(e[c]));
  3442. 0 < d.length && (this._glView._convertTouchesWithScale(d), a = new cc.EventTouch(d), a._eventCode = cc.EventTouch.EventCode.MOVED, cc.eventManager.dispatchEvent(a))
  3443. },
  3444. handleTouchesEnd: function (a) {
  3445. a = this.getSetOfTouchesEndOrCancel(a);
  3446. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.ENDED, cc.eventManager.dispatchEvent(a))
  3447. },
  3448. handleTouchesCancel: function (a) {
  3449. a = this.getSetOfTouchesEndOrCancel(a);
  3450. 0 < a.length && (this._glView._convertTouchesWithScale(a), a = new cc.EventTouch(a), a._eventCode = cc.EventTouch.EventCode.CANCELLED, cc.eventManager.dispatchEvent(a))
  3451. },
  3452. getSetOfTouchesEndOrCancel: function (a) {
  3453. for (var b, c, d, e = [], f = this._touches, g = this._touchesIntegerDict, h = 0, k = a.length; h < k; h++) b = a[h],
  3454. d = b.getID(),
  3455. c = g[d],
  3456. null != c && f[c] && (f[c]._setPoint(b._point), f[c]._setPrevPoint(b._prevPoint), e.push(f[c]), this._removeUsedIndexBit(c), delete g[d]);
  3457. return e
  3458. },
  3459. getHTMLElementPosition: function (a) {
  3460. var b = document.documentElement,
  3461. c = window,
  3462. d = null,
  3463. d = cc.isFunction(a.getBoundingClientRect) ? a.getBoundingClientRect() : a instanceof HTMLCanvasElement ? {
  3464. left: 0,
  3465. top: 0,
  3466. width: a.width,
  3467. height: a.height
  3468. } : {
  3469. left: 0,
  3470. top: 0,
  3471. width: parseInt(a.style.width),
  3472. height: parseInt(a.style.height)
  3473. };
  3474. return {
  3475. left: d.left + c.pageXOffset -
  3476. b.clientLeft,
  3477. top: d.top + c.pageYOffset - b.clientTop,
  3478. width: d.width,
  3479. height: d.height
  3480. }
  3481. },
  3482. getPreTouch: function (a) {
  3483. for (var b = null, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--) if (c[e].getID() == d) {
  3484. b = c[e];
  3485. break
  3486. }
  3487. b || (b = a);
  3488. return b
  3489. },
  3490. setPreTouch: function (a) {
  3491. for (var b = !1, c = this._preTouchPool, d = a.getID(), e = c.length - 1; 0 <= e; e--) if (c[e].getID() == d) {
  3492. c[e] = a;
  3493. b = !0;
  3494. break
  3495. }
  3496. b || (50 >= c.length ? c.push(a) : (c[this._preTouchPoolPointer] = a, this._preTouchPoolPointer = (this._preTouchPoolPointer + 1) % 50))
  3497. },
  3498. getTouchByXY: function (a, b, c) {
  3499. var d = this._preTouchPoint;
  3500. a = this._glView.convertToLocationInView(a, b, c);
  3501. b = new cc.Touch(a.x, a.y);
  3502. b._setPrevPoint(d.x, d.y);
  3503. d.x = a.x;
  3504. d.y = a.y;
  3505. return b
  3506. },
  3507. getMouseEvent: function (a, b, c) {
  3508. var d = this._prevMousePoint;
  3509. this._glView._convertMouseToLocationInView(a, b);
  3510. b = new cc.EventMouse(c);
  3511. b.setLocation(a.x, a.y);
  3512. b._setPrevCursor(d.x, d.y);
  3513. d.x = a.x;
  3514. d.y = a.y;
  3515. return b
  3516. },
  3517. getPointByEvent: function (a, b) {
  3518. if (null != a.pageX) return {
  3519. x: a.pageX,
  3520. y: a.pageY
  3521. };
  3522. b.left -= document.body.scrollLeft;
  3523. b.top -= document.body.scrollTop;
  3524. return {
  3525. x: a.clientX,
  3526. y: a.clientY
  3527. }
  3528. },
  3529. getTouchesByEvent: function (a, b) {
  3530. for (var c = [], d = this._glView, e, f, g = this._preTouchPoint, h = a.changedTouches.length, k = 0; k < h; k++) if (e = a.changedTouches[k]) {
  3531. var m;
  3532. m = cc.sys.BROWSER_TYPE_FIREFOX === cc.sys.browserType ? d.convertToLocationInView(e.pageX, e.pageY, b) : d.convertToLocationInView(e.clientX, e.clientY, b);
  3533. 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));
  3534. g.x = m.x;
  3535. g.y = m.y;
  3536. c.push(e)
  3537. }
  3538. return c
  3539. },
  3540. registerSystemEvent: function (a) {
  3541. if (!this._isRegisterEvent) {
  3542. var b = this._glView = cc.view,
  3543. c = this,
  3544. d = "touches" in cc.sys.capabilities;
  3545. "mouse" in cc.sys.capabilities && (cc._addEventListener(window, "mousedown",
  3546. function () {
  3547. c._mousePressed = !0
  3548. },
  3549. !1), cc._addEventListener(window, "mouseup",
  3550. function (b) {
  3551. var e = c._mousePressed;
  3552. c._mousePressed = !1;
  3553. if (e) {
  3554. var e = c.getHTMLElementPosition(a),
  3555. f = c.getPointByEvent(b, e);
  3556. cc.rectContainsPoint(new cc.Rect(e.left, e.top, e.width, e.height), f) || (d || c.handleTouchesEnd([c.getTouchByXY(f.x, f.y, e)]), e = c.getMouseEvent(f, e, cc.EventMouse.UP), e.setButton(b.button), cc.eventManager.dispatchEvent(e))
  3557. }
  3558. },
  3559. !1), cc._addEventListener(a, "mousedown",
  3560. function (b) {
  3561. c._mousePressed = !0;
  3562. var e = c.getHTMLElementPosition(a),
  3563. f = c.getPointByEvent(b, e);
  3564. d || c.handleTouchesBegin([c.getTouchByXY(f.x, f.y, e)]);
  3565. e = c.getMouseEvent(f, e, cc.EventMouse.DOWN);
  3566. e.setButton(b.button);
  3567. cc.eventManager.dispatchEvent(e);
  3568. b.stopPropagation();
  3569. b.preventDefault();
  3570. a.focus()
  3571. },
  3572. !1), cc._addEventListener(a, "mouseup",
  3573. function (b) {
  3574. c._mousePressed = !1;
  3575. var e = c.getHTMLElementPosition(a),
  3576. f = c.getPointByEvent(b, e);
  3577. d || c.handleTouchesEnd([c.getTouchByXY(f.x, f.y, e)]);
  3578. e = c.getMouseEvent(f, e, cc.EventMouse.UP);
  3579. e.setButton(b.button);
  3580. cc.eventManager.dispatchEvent(e);
  3581. b.stopPropagation();
  3582. b.preventDefault()
  3583. },
  3584. !1), cc._addEventListener(a, "mousemove",
  3585. function (b) {
  3586. var e = c.getHTMLElementPosition(a),
  3587. f = c.getPointByEvent(b, e);
  3588. d || c.handleTouchesMove([c.getTouchByXY(f.x, f.y, e)]);
  3589. e = c.getMouseEvent(f, e, cc.EventMouse.MOVE);
  3590. c._mousePressed ? e.setButton(b.button) : e.setButton(null);
  3591. cc.eventManager.dispatchEvent(e);
  3592. b.stopPropagation();
  3593. b.preventDefault()
  3594. },
  3595. !1), cc._addEventListener(a, "mousewheel",
  3596. function (b) {
  3597. var d = c.getHTMLElementPosition(a),
  3598. e = c.getPointByEvent(b, d),
  3599. d = c.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  3600. d.setButton(b.button);
  3601. d.setScrollData(0, b.wheelDelta);
  3602. cc.eventManager.dispatchEvent(d);
  3603. b.stopPropagation();
  3604. b.preventDefault()
  3605. },
  3606. !1), cc._addEventListener(a, "DOMMouseScroll",
  3607. function (b) {
  3608. var d = c.getHTMLElementPosition(a),
  3609. e = c.getPointByEvent(b, d),
  3610. d = c.getMouseEvent(e, d, cc.EventMouse.SCROLL);
  3611. d.setButton(b.button);
  3612. d.setScrollData(0, -120 * b.detail);
  3613. cc.eventManager.dispatchEvent(d);
  3614. b.stopPropagation();
  3615. b.preventDefault()
  3616. },
  3617. !1));
  3618. if (window.navigator.msPointerEnabled) {
  3619. var e = {
  3620. MSPointerDown: c.handleTouchesBegin,
  3621. MSPointerMove: c.handleTouchesMove,
  3622. MSPointerUp: c.handleTouchesEnd,
  3623. MSPointerCancel: c.handleTouchesCancel
  3624. },
  3625. f;
  3626. for (f in e) (function (b, d) {
  3627. cc._addEventListener(a, b,
  3628. function (b) {
  3629. var e = c.getHTMLElementPosition(a);
  3630. e.left -= document.documentElement.scrollLeft;
  3631. e.top -= document.documentElement.scrollTop;
  3632. d.call(c, [c.getTouchByXY(b.clientX, b.clientY, e)]);
  3633. b.stopPropagation()
  3634. },
  3635. !1)
  3636. })(f, e[f])
  3637. }
  3638. d && (cc._addEventListener(a, "touchstart",
  3639. function (b) {
  3640. if (b.changedTouches) {
  3641. var d = c.getHTMLElementPosition(a);
  3642. d.left -= document.body.scrollLeft;
  3643. d.top -= document.body.scrollTop;
  3644. c.handleTouchesBegin(c.getTouchesByEvent(b, d));
  3645. b.stopPropagation();
  3646. b.preventDefault();
  3647. a.focus()
  3648. }
  3649. },
  3650. !1), cc._addEventListener(a, "touchmove",
  3651. function (b) {
  3652. if (b.changedTouches) {
  3653. var d = c.getHTMLElementPosition(a);
  3654. d.left -= document.body.scrollLeft;
  3655. d.top -= document.body.scrollTop;
  3656. c.handleTouchesMove(c.getTouchesByEvent(b, d));
  3657. b.stopPropagation();
  3658. b.preventDefault()
  3659. }
  3660. },
  3661. !1), cc._addEventListener(a, "touchend",
  3662. function (b) {
  3663. if (b.changedTouches) {
  3664. var d = c.getHTMLElementPosition(a);
  3665. d.left -= document.body.scrollLeft;
  3666. d.top -= document.body.scrollTop;
  3667. c.handleTouchesEnd(c.getTouchesByEvent(b, d));
  3668. b.stopPropagation();
  3669. b.preventDefault()
  3670. }
  3671. },
  3672. !1), cc._addEventListener(a, "touchcancel",
  3673. function (d) {
  3674. if (d.changedTouches) {
  3675. var e = c.getHTMLElementPosition(a);
  3676. e.left -= document.body.scrollLeft;
  3677. e.top -= document.body.scrollTop;
  3678. b.handleTouchesCancel(c.getTouchesByEvent(d, e));
  3679. d.stopPropagation();
  3680. d.preventDefault()
  3681. }
  3682. },
  3683. !1));
  3684. this._registerKeyboardEvent();
  3685. this._registerAccelerometerEvent();
  3686. this._isRegisterEvent = !0
  3687. }
  3688. },
  3689. _registerKeyboardEvent: function () { },
  3690. _registerAccelerometerEvent: function () { },
  3691. update: function (a) {
  3692. this._accelCurTime > this._accelInterval && (this._accelCurTime -= this._accelInterval, cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration)));
  3693. this._accelCurTime += a
  3694. }
  3695. };
  3696. var _p = cc.inputManager;
  3697. _p.setAccelerometerEnabled = function (a) {
  3698. this._accelEnabled !== a && (this._accelEnabled = a, a = cc.director.getScheduler(), this._accelEnabled ? (this._accelCurTime = 0, a.scheduleUpdateForTarget(this)) : (this._accelCurTime = 0, a.unscheduleUpdateForTarget(this)))
  3699. };
  3700. _p.setAccelerometerInterval = function (a) {
  3701. this._accelInterval !== a && (this._accelInterval = a)
  3702. };
  3703. _p._registerKeyboardEvent = function () {
  3704. cc._addEventListener(cc._canvas, "keydown",
  3705. function (a) {
  3706. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !0));
  3707. a.stopPropagation();
  3708. a.preventDefault()
  3709. },
  3710. !1);
  3711. cc._addEventListener(cc._canvas, "keyup",
  3712. function (a) {
  3713. cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode, !1));
  3714. a.stopPropagation();
  3715. a.preventDefault()
  3716. },
  3717. !1)
  3718. };
  3719. _p._registerAccelerometerEvent = function () {
  3720. var a = window;
  3721. this._acceleration = new cc.Acceleration;
  3722. this._accelDeviceEvent = a.DeviceMotionEvent || a.DeviceOrientationEvent;
  3723. cc.sys.browserType == cc.sys.BROWSER_TYPE_MOBILE_QQ && (this._accelDeviceEvent = window.DeviceOrientationEvent);
  3724. var b = this._accelDeviceEvent == a.DeviceMotionEvent ? "devicemotion" : "deviceorientation",
  3725. c = navigator.userAgent;
  3726. if (/Android/.test(c) || /Adr/.test(c) && cc.sys.browserType == cc.BROWSER_TYPE_UC) this._minus = -1;
  3727. cc._addEventListener(a, b, this.didAccelerate.bind(this), !1)
  3728. };
  3729. _p.didAccelerate = function (a) {
  3730. var b = window;
  3731. if (this._accelEnabled) {
  3732. var c = this._acceleration,
  3733. d,
  3734. e,
  3735. f;
  3736. 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);
  3737. cc.sys.os === cc.sys.OS_ANDROID ? (c.x = -d, c.y = -e) : (c.x = d, c.y = e);
  3738. c.z = f;
  3739. c.timestamp = a.timeStamp || Date.now();
  3740. a = c.x;
  3741. b.orientation === cc.UIInterfaceOrientationLandscapeRight ? (c.x = -c.y, c.y = a) : b.orientation === cc.UIInterfaceOrientationLandscapeLeft ? (c.x = c.y, c.y = -a) : b.orientation === cc.UIInterfaceOrientationPortraitUpsideDown && (c.x = -c.x, c.y = -c.y)
  3742. }
  3743. };
  3744. delete _p;
  3745. cc.AffineTransform = function (a, b, c, d, e, f) {
  3746. this.a = a;
  3747. this.b = b;
  3748. this.c = c;
  3749. this.d = d;
  3750. this.tx = e;
  3751. this.ty = f
  3752. };
  3753. cc.affineTransformMake = function (a, b, c, d, e, f) {
  3754. return {
  3755. a: a,
  3756. b: b,
  3757. c: c,
  3758. d: d,
  3759. tx: e,
  3760. ty: f
  3761. }
  3762. };
  3763. cc.pointApplyAffineTransform = function (a, b) {
  3764. return {
  3765. x: b.a * a.x + b.c * a.y + b.tx,
  3766. y: b.b * a.x + b.d * a.y + b.ty
  3767. }
  3768. };
  3769. cc._pointApplyAffineTransform = function (a, b, c) {
  3770. return {
  3771. x: c.a * a + c.c * b + c.tx,
  3772. y: c.b * a + c.d * b + c.ty
  3773. }
  3774. };
  3775. cc.sizeApplyAffineTransform = function (a, b) {
  3776. return {
  3777. width: b.a * a.width + b.c * a.height,
  3778. height: b.b * a.width + b.d * a.height
  3779. }
  3780. };
  3781. cc.affineTransformMakeIdentity = function () {
  3782. return {
  3783. a: 1,
  3784. b: 0,
  3785. c: 0,
  3786. d: 1,
  3787. tx: 0,
  3788. ty: 0
  3789. }
  3790. };
  3791. cc.affineTransformIdentity = function () {
  3792. return {
  3793. a: 1,
  3794. b: 0,
  3795. c: 0,
  3796. d: 1,
  3797. tx: 0,
  3798. ty: 0
  3799. }
  3800. };
  3801. cc.rectApplyAffineTransform = function (a, b) {
  3802. var c = cc.rectGetMinY(a),
  3803. d = cc.rectGetMinX(a),
  3804. e = cc.rectGetMaxX(a),
  3805. f = cc.rectGetMaxY(a),
  3806. g = cc._pointApplyAffineTransform(d, c, b),
  3807. c = cc._pointApplyAffineTransform(e, c, b),
  3808. d = cc._pointApplyAffineTransform(d, f, b),
  3809. h = cc._pointApplyAffineTransform(e, f, b),
  3810. e = Math.min(g.x, c.x, d.x, h.x),
  3811. f = Math.max(g.x, c.x, d.x, h.x),
  3812. k = Math.min(g.y, c.y, d.y, h.y),
  3813. g = Math.max(g.y, c.y, d.y, h.y);
  3814. return cc.rect(e, k, f - e, g - k)
  3815. };
  3816. cc._rectApplyAffineTransformIn = function (a, b) {
  3817. var c = cc.rectGetMinY(a),
  3818. d = cc.rectGetMinX(a),
  3819. e = cc.rectGetMaxX(a),
  3820. f = cc.rectGetMaxY(a),
  3821. g = cc._pointApplyAffineTransform(d, c, b),
  3822. c = cc._pointApplyAffineTransform(e, c, b),
  3823. d = cc._pointApplyAffineTransform(d, f, b),
  3824. h = cc._pointApplyAffineTransform(e, f, b),
  3825. e = Math.min(g.x, c.x, d.x, h.x),
  3826. f = Math.max(g.x, c.x, d.x, h.x),
  3827. k = Math.min(g.y, c.y, d.y, h.y),
  3828. g = Math.max(g.y, c.y, d.y, h.y);
  3829. a.x = e;
  3830. a.y = k;
  3831. a.width = f - e;
  3832. a.height = g - k;
  3833. return a
  3834. };
  3835. cc.affineTransformTranslate = function (a, b, c) {
  3836. return {
  3837. a: a.a,
  3838. b: a.b,
  3839. c: a.c,
  3840. d: a.d,
  3841. tx: a.tx + a.a * b + a.c * c,
  3842. ty: a.ty + a.b * b + a.d * c
  3843. }
  3844. };
  3845. cc.affineTransformScale = function (a, b, c) {
  3846. return {
  3847. a: a.a * b,
  3848. b: a.b * b,
  3849. c: a.c * c,
  3850. d: a.d * c,
  3851. tx: a.tx,
  3852. ty: a.ty
  3853. }
  3854. };
  3855. cc.affineTransformRotate = function (a, b) {
  3856. var c = Math.sin(b),
  3857. d = Math.cos(b);
  3858. return {
  3859. a: a.a * d + a.c * c,
  3860. b: a.b * d + a.d * c,
  3861. c: a.c * d - a.a * c,
  3862. d: a.d * d - a.b * c,
  3863. tx: a.tx,
  3864. ty: a.ty
  3865. }
  3866. };
  3867. cc.affineTransformConcat = function (a, b) {
  3868. return {
  3869. a: a.a * b.a + a.b * b.c,
  3870. b: a.a * b.b + a.b * b.d,
  3871. c: a.c * b.a + a.d * b.c,
  3872. d: a.c * b.b + a.d * b.d,
  3873. tx: a.tx * b.a + a.ty * b.c + b.tx,
  3874. ty: a.tx * b.b + a.ty * b.d + b.ty
  3875. }
  3876. };
  3877. cc.affineTransformEqualToTransform = function (a, b) {
  3878. 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
  3879. };
  3880. cc.affineTransformInvert = function (a) {
  3881. var b = 1 / (a.a * a.d - a.b * a.c);
  3882. return {
  3883. a: b * a.d,
  3884. b: -b * a.b,
  3885. c: -b * a.c,
  3886. d: b * a.a,
  3887. tx: b * (a.c * a.ty - a.d * a.tx),
  3888. ty: b * (a.b * a.tx - a.a * a.ty)
  3889. }
  3890. };
  3891. cc.POINT_EPSILON = parseFloat("1.192092896e-07F");
  3892. cc.pNeg = function (a) {
  3893. return cc.p(-a.x, -a.y)
  3894. };
  3895. cc.pAdd = function (a, b) {
  3896. return cc.p(a.x + b.x, a.y + b.y)
  3897. };
  3898. cc.pSub = function (a, b) {
  3899. return cc.p(a.x - b.x, a.y - b.y)
  3900. };
  3901. cc.pMult = function (a, b) {
  3902. return cc.p(a.x * b, a.y * b)
  3903. };
  3904. cc.pMidpoint = function (a, b) {
  3905. return cc.pMult(cc.pAdd(a, b), 0.5)
  3906. };
  3907. cc.pDot = function (a, b) {
  3908. return a.x * b.x + a.y * b.y
  3909. };
  3910. cc.pCross = function (a, b) {
  3911. return a.x * b.y - a.y * b.x
  3912. };
  3913. cc.pPerp = function (a) {
  3914. return cc.p(-a.y, a.x)
  3915. };
  3916. cc.pRPerp = function (a) {
  3917. return cc.p(a.y, -a.x)
  3918. };
  3919. cc.pProject = function (a, b) {
  3920. return cc.pMult(b, cc.pDot(a, b) / cc.pDot(b, b))
  3921. };
  3922. cc.pRotate = function (a, b) {
  3923. return cc.p(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x)
  3924. };
  3925. cc.pUnrotate = function (a, b) {
  3926. return cc.p(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y)
  3927. };
  3928. cc.pLengthSQ = function (a) {
  3929. return cc.pDot(a, a)
  3930. };
  3931. cc.pDistanceSQ = function (a, b) {
  3932. return cc.pLengthSQ(cc.pSub(a, b))
  3933. };
  3934. cc.pLength = function (a) {
  3935. return Math.sqrt(cc.pLengthSQ(a))
  3936. };
  3937. cc.pDistance = function (a, b) {
  3938. return cc.pLength(cc.pSub(a, b))
  3939. };
  3940. cc.pNormalize = function (a) {
  3941. return cc.pMult(a, 1 / cc.pLength(a))
  3942. };
  3943. cc.pForAngle = function (a) {
  3944. return cc.p(Math.cos(a), Math.sin(a))
  3945. };
  3946. cc.pToAngle = function (a) {
  3947. return Math.atan2(a.y, a.x)
  3948. };
  3949. cc.clampf = function (a, b, c) {
  3950. if (b > c) {
  3951. var d = b;
  3952. b = c;
  3953. c = d
  3954. }
  3955. return a < b ? b : a < c ? a : c
  3956. };
  3957. cc.pClamp = function (a, b, c) {
  3958. return cc.p(cc.clampf(a.x, b.x, c.x), cc.clampf(a.y, b.y, c.y))
  3959. };
  3960. cc.pFromSize = function (a) {
  3961. return cc.p(a.width, a.height)
  3962. };
  3963. cc.pCompOp = function (a, b) {
  3964. return cc.p(b(a.x), b(a.y))
  3965. };
  3966. cc.pLerp = function (a, b, c) {
  3967. return cc.pAdd(cc.pMult(a, 1 - c), cc.pMult(b, c))
  3968. };
  3969. cc.pFuzzyEqual = function (a, b, c) {
  3970. return a.x - c <= b.x && b.x <= a.x + c && a.y - c <= b.y && b.y <= a.y + c ? !0 : !1
  3971. };
  3972. cc.pCompMult = function (a, b) {
  3973. return cc.p(a.x * b.x, a.y * b.y)
  3974. };
  3975. cc.pAngleSigned = function (a, b) {
  3976. var c = cc.pNormalize(a),
  3977. d = cc.pNormalize(b),
  3978. c = Math.atan2(c.x * d.y - c.y * d.x, cc.pDot(c, d));
  3979. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  3980. };
  3981. cc.pAngle = function (a, b) {
  3982. var c = Math.acos(cc.pDot(cc.pNormalize(a), cc.pNormalize(b)));
  3983. return Math.abs(c) < cc.POINT_EPSILON ? 0 : c
  3984. };
  3985. cc.pRotateByAngle = function (a, b, c) {
  3986. a = cc.pSub(a, b);
  3987. var d = Math.cos(c);
  3988. c = Math.sin(c);
  3989. var e = a.x;
  3990. a.x = e * d - a.y * c + b.x;
  3991. a.y = e * c + a.y * d + b.y;
  3992. return a
  3993. };
  3994. cc.pLineIntersect = function (a, b, c, d, e) {
  3995. if (a.x == b.x && a.y == b.y || c.x == d.x && c.y == d.y) return !1;
  3996. var f = b.x - a.x;
  3997. b = b.y - a.y;
  3998. var g = d.x - c.x;
  3999. d = d.y - c.y;
  4000. var h = a.x - c.x;
  4001. a = a.y - c.y;
  4002. c = d * f - g * b;
  4003. e.x = g * a - d * h;
  4004. e.y = f * a - b * h;
  4005. if (0 == c) return 0 == e.x || 0 == e.y ? !0 : !1;
  4006. e.x /= c;
  4007. e.y /= c;
  4008. return !0
  4009. };
  4010. cc.pSegmentIntersect = function (a, b, c, d) {
  4011. var e = cc.p(0, 0);
  4012. return cc.pLineIntersect(a, b, c, d, e) && 0 <= e.x && 1 >= e.x && 0 <= e.y && 1 >= e.y ? !0 : !1
  4013. };
  4014. cc.pIntersectPoint = function (a, b, c, d) {
  4015. var e = cc.p(0, 0);
  4016. 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)
  4017. };
  4018. cc.pSameAs = function (a, b) {
  4019. return null != a && null != b ? a.x == b.x && a.y == b.y : !1
  4020. };
  4021. cc.pZeroIn = function (a) {
  4022. a.x = 0;
  4023. a.y = 0
  4024. };
  4025. cc.pIn = function (a, b) {
  4026. a.x = b.x;
  4027. a.y = b.y
  4028. };
  4029. cc.pMultIn = function (a, b) {
  4030. a.x *= b;
  4031. a.y *= b
  4032. };
  4033. cc.pSubIn = function (a, b) {
  4034. a.x -= b.x;
  4035. a.y -= b.y
  4036. };
  4037. cc.pAddIn = function (a, b) {
  4038. a.x += b.x;
  4039. a.y += b.y
  4040. };
  4041. cc.pNormalizeIn = function (a) {
  4042. cc.pMultIn(a, 1 / Math.sqrt(a.x * a.x + a.y * a.y))
  4043. };
  4044. cc.vertexLineToPolygon = function (a, b, c, d, e) {
  4045. e += d;
  4046. if (!(1 >= e)) {
  4047. b *= 0.5;
  4048. for (var f, g = e - 1, h = d; h < e; h++) {
  4049. f = 2 * h;
  4050. var k = cc.p(a[2 * h], a[2 * h + 1]),
  4051. m;
  4052. if (0 === h) m = cc.pPerp(cc.pNormalize(cc.pSub(k, cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1]))));
  4053. else if (h === g) m = cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]), k)));
  4054. else {
  4055. m = cc.p(a[2 * (h - 1)], a[2 * (h - 1) + 1]);
  4056. var n = cc.p(a[2 * (h + 1)], a[2 * (h + 1) + 1]),
  4057. q = cc.pNormalize(cc.pSub(n, k)),
  4058. r = cc.pNormalize(cc.pSub(m, k)),
  4059. s = Math.acos(cc.pDot(q, r));
  4060. m = s < cc.degreesToRadians(70) ? cc.pPerp(cc.pNormalize(cc.pMidpoint(q, r))) : s < cc.degreesToRadians(170) ? cc.pNormalize(cc.pMidpoint(q, r)) : cc.pPerp(cc.pNormalize(cc.pSub(n, m)))
  4061. }
  4062. m = cc.pMult(m, b);
  4063. c[2 * f] = k.x + m.x;
  4064. c[2 * f + 1] = k.y + m.y;
  4065. c[2 * (f + 1)] = k.x - m.x;
  4066. c[2 * (f + 1) + 1] = k.y - m.y
  4067. }
  4068. for (h = 0 == d ? 0 : d - 1; h < g; h++) f = 2 * h,
  4069. a = f + 2,
  4070. b = cc.vertex2(c[2 * f], c[2 * f + 1]),
  4071. e = cc.vertex2(c[2 * (f + 1)], c[2 * (f + 1) + 1]),
  4072. f = cc.vertex2(c[2 * a], c[2 * a]),
  4073. d = cc.vertex2(c[2 * (a + 1)], c[2 * (a + 1) + 1]),
  4074. b = !cc.vertexLineIntersect(b.x, b.y, d.x, d.y, e.x, e.y, f.x, f.y),
  4075. !b.isSuccess && (0 > b.value || 1 < b.value) && (b.isSuccess = !0),
  4076. b.isSuccess && (c[2 * a] = d.x, c[2 * a + 1] = d.y, c[2 * (a + 1)] = f.x, c[2 * (a + 1) + 1] = f.y)
  4077. }
  4078. };
  4079. cc.vertexLineIntersect = function (a, b, c, d, e, f, g, h) {
  4080. if (a == c && b == d || e == g && f == h) return {
  4081. isSuccess: !1,
  4082. value: 0
  4083. };
  4084. c -= a;
  4085. d -= b;
  4086. e -= a;
  4087. f -= b;
  4088. g -= a;
  4089. h -= b;
  4090. a = Math.sqrt(c * c + d * d);
  4091. c /= a;
  4092. d /= a;
  4093. b = e * c + f * d;
  4094. f = f * c - e * d;
  4095. e = b;
  4096. b = g * c + h * d;
  4097. h = h * c - g * d;
  4098. g = b;
  4099. return f == h ? {
  4100. isSuccess: !1,
  4101. value: 0
  4102. } : {
  4103. isSuccess: !0,
  4104. value: (g + (e - g) * h / (h - f)) / a
  4105. }
  4106. };
  4107. cc.vertexListIsClockwise = function (a) {
  4108. for (var b = 0, c = a.length; b < c; b++) {
  4109. var d = a[(b + 1) % c],
  4110. e = a[(b + 2) % c];
  4111. if (0 < cc.pCross(cc.pSub(d, a[b]), cc.pSub(e, d))) return !1
  4112. }
  4113. return !0
  4114. };
  4115. cc.CGAffineToGL = function (a, b) {
  4116. b[2] = b[3] = b[6] = b[7] = b[8] = b[9] = b[11] = b[14] = 0;
  4117. b[10] = b[15] = 1;
  4118. b[0] = a.a;
  4119. b[4] = a.c;
  4120. b[12] = a.tx;
  4121. b[1] = a.b;
  4122. b[5] = a.d;
  4123. b[13] = a.ty
  4124. };
  4125. cc.GLToCGAffine = function (a, b) {
  4126. b.a = a[0];
  4127. b.c = a[4];
  4128. b.tx = a[12];
  4129. b.b = a[1];
  4130. b.d = a[5];
  4131. b.ty = a[13]
  4132. };
  4133. cc.Touch = cc.Class.extend({
  4134. _point: null,
  4135. _prevPoint: null,
  4136. _id: 0,
  4137. _startPointCaptured: !1,
  4138. _startPoint: null,
  4139. ctor: function (a, b, c) {
  4140. this._point = cc.p(a || 0, b || 0);
  4141. this._id = c || 0
  4142. },
  4143. getLocation: function () {
  4144. return {
  4145. x: this._point.x,
  4146. y: this._point.y
  4147. }
  4148. },
  4149. getLocationX: function () {
  4150. return this._point.x
  4151. },
  4152. getLocationY: function () {
  4153. return this._point.y
  4154. },
  4155. getPreviousLocation: function () {
  4156. return {
  4157. x: this._prevPoint.x,
  4158. y: this._prevPoint.y
  4159. }
  4160. },
  4161. getStartLocation: function () {
  4162. return {
  4163. x: this._startPoint.x,
  4164. y: this._startPoint.y
  4165. }
  4166. },
  4167. getDelta: function () {
  4168. return cc.pSub(this._point, this._prevPoint)
  4169. },
  4170. getLocationInView: function () {
  4171. return {
  4172. x: this._point.x,
  4173. y: this._point.y
  4174. }
  4175. },
  4176. getPreviousLocationInView: function () {
  4177. return {
  4178. x: this._prevPoint.x,
  4179. y: this._prevPoint.y
  4180. }
  4181. },
  4182. getStartLocationInView: function () {
  4183. return {
  4184. x: this._startPoint.x,
  4185. y: this._startPoint.y
  4186. }
  4187. },
  4188. getID: function () {
  4189. return this._id
  4190. },
  4191. getId: function () {
  4192. cc.log("getId is deprecated. Please use getID instead.");
  4193. return this._id
  4194. },
  4195. setTouchInfo: function (a, b, c) {
  4196. this._prevPoint = this._point;
  4197. this._point = cc.p(b || 0, c || 0);
  4198. this._id = a;
  4199. this._startPointCaptured || (this._startPoint = cc.p(this._point), this._startPointCaptured = !0)
  4200. },
  4201. _setPoint: function (a, b) {
  4202. void 0 === b ? (this._point.x = a.x, this._point.y = a.y) : (this._point.x = a, this._point.y = b)
  4203. },
  4204. _setPrevPoint: function (a, b) {
  4205. this._prevPoint = void 0 === b ? cc.p(a.x, a.y) : cc.p(a || 0, b || 0)
  4206. }
  4207. });
  4208. cc.Event = cc.Class.extend({
  4209. _type: 0,
  4210. _isStopped: !1,
  4211. _currentTarget: null,
  4212. _setCurrentTarget: function (a) {
  4213. this._currentTarget = a
  4214. },
  4215. ctor: function (a) {
  4216. this._type = a
  4217. },
  4218. getType: function () {
  4219. return this._type
  4220. },
  4221. stopPropagation: function () {
  4222. this._isStopped = !0
  4223. },
  4224. isStopped: function () {
  4225. return this._isStopped
  4226. },
  4227. getCurrentTarget: function () {
  4228. return this._currentTarget
  4229. }
  4230. });
  4231. cc.Event.TOUCH = 0;
  4232. cc.Event.KEYBOARD = 1;
  4233. cc.Event.ACCELERATION = 2;
  4234. cc.Event.MOUSE = 3;
  4235. cc.Event.CUSTOM = 4;
  4236. cc.EventCustom = cc.Event.extend({
  4237. _eventName: null,
  4238. _userData: null,
  4239. ctor: function (a) {
  4240. cc.Event.prototype.ctor.call(this, cc.Event.CUSTOM);
  4241. this._eventName = a
  4242. },
  4243. setUserData: function (a) {
  4244. this._userData = a
  4245. },
  4246. getUserData: function () {
  4247. return this._userData
  4248. },
  4249. getEventName: function () {
  4250. return this._eventName
  4251. }
  4252. });
  4253. cc.EventMouse = cc.Event.extend({
  4254. _eventType: 0,
  4255. _button: 0,
  4256. _x: 0,
  4257. _y: 0,
  4258. _prevX: 0,
  4259. _prevY: 0,
  4260. _scrollX: 0,
  4261. _scrollY: 0,
  4262. ctor: function (a) {
  4263. cc.Event.prototype.ctor.call(this, cc.Event.MOUSE);
  4264. this._eventType = a
  4265. },
  4266. setScrollData: function (a, b) {
  4267. this._scrollX = a;
  4268. this._scrollY = b
  4269. },
  4270. getScrollX: function () {
  4271. return this._scrollX
  4272. },
  4273. getScrollY: function () {
  4274. return this._scrollY
  4275. },
  4276. setLocation: function (a, b) {
  4277. this._x = a;
  4278. this._y = b
  4279. },
  4280. getLocation: function () {
  4281. return {
  4282. x: this._x,
  4283. y: this._y
  4284. }
  4285. },
  4286. getLocationInView: function () {
  4287. return {
  4288. x: this._x,
  4289. y: cc.view._designResolutionSize.height -
  4290. this._y
  4291. }
  4292. },
  4293. _setPrevCursor: function (a, b) {
  4294. this._prevX = a;
  4295. this._prevY = b
  4296. },
  4297. getDelta: function () {
  4298. return {
  4299. x: this._x - this._prevX,
  4300. y: this._y - this._prevY
  4301. }
  4302. },
  4303. getDeltaX: function () {
  4304. return this._x - this._prevX
  4305. },
  4306. getDeltaY: function () {
  4307. return this._y - this._prevY
  4308. },
  4309. setButton: function (a) {
  4310. this._button = a
  4311. },
  4312. getButton: function () {
  4313. return this._button
  4314. },
  4315. getLocationX: function () {
  4316. return this._x
  4317. },
  4318. getLocationY: function () {
  4319. return this._y
  4320. }
  4321. });
  4322. cc.EventMouse.NONE = 0;
  4323. cc.EventMouse.DOWN = 1;
  4324. cc.EventMouse.UP = 2;
  4325. cc.EventMouse.MOVE = 3;
  4326. cc.EventMouse.SCROLL = 4;
  4327. cc.EventMouse.BUTTON_LEFT = 0;
  4328. cc.EventMouse.BUTTON_RIGHT = 2;
  4329. cc.EventMouse.BUTTON_MIDDLE = 1;
  4330. cc.EventMouse.BUTTON_4 = 3;
  4331. cc.EventMouse.BUTTON_5 = 4;
  4332. cc.EventMouse.BUTTON_6 = 5;
  4333. cc.EventMouse.BUTTON_7 = 6;
  4334. cc.EventMouse.BUTTON_8 = 7;
  4335. cc.EventTouch = cc.Event.extend({
  4336. _eventCode: 0,
  4337. _touches: null,
  4338. ctor: function (a) {
  4339. cc.Event.prototype.ctor.call(this, cc.Event.TOUCH);
  4340. this._touches = a || []
  4341. },
  4342. getEventCode: function () {
  4343. return this._eventCode
  4344. },
  4345. getTouches: function () {
  4346. return this._touches
  4347. },
  4348. _setEventCode: function (a) {
  4349. this._eventCode = a
  4350. },
  4351. _setTouches: function (a) {
  4352. this._touches = a
  4353. }
  4354. });
  4355. cc.EventTouch.MAX_TOUCHES = 5;
  4356. cc.EventTouch.EventCode = {
  4357. BEGAN: 0,
  4358. MOVED: 1,
  4359. ENDED: 2,
  4360. CANCELLED: 3
  4361. };
  4362. cc.EventListener = cc.Class.extend({
  4363. _onEvent: null,
  4364. _type: 0,
  4365. _listenerID: null,
  4366. _registered: !1,
  4367. _fixedPriority: 0,
  4368. _node: null,
  4369. _paused: !1,
  4370. _isEnabled: !0,
  4371. ctor: function (a, b, c) {
  4372. this._onEvent = c;
  4373. this._type = a || 0;
  4374. this._listenerID = b || ""
  4375. },
  4376. _setPaused: function (a) {
  4377. this._paused = a
  4378. },
  4379. _isPaused: function () {
  4380. return this._paused
  4381. },
  4382. _setRegistered: function (a) {
  4383. this._registered = a
  4384. },
  4385. _isRegistered: function () {
  4386. return this._registered
  4387. },
  4388. _getType: function () {
  4389. return this._type
  4390. },
  4391. _getListenerID: function () {
  4392. return this._listenerID
  4393. },
  4394. _setFixedPriority: function (a) {
  4395. this._fixedPriority = a
  4396. },
  4397. _getFixedPriority: function () {
  4398. return this._fixedPriority
  4399. },
  4400. _setSceneGraphPriority: function (a) {
  4401. this._node = a
  4402. },
  4403. _getSceneGraphPriority: function () {
  4404. return this._node
  4405. },
  4406. checkAvailable: function () {
  4407. return null != this._onEvent
  4408. },
  4409. clone: function () {
  4410. return null
  4411. },
  4412. setEnabled: function (a) {
  4413. this._isEnabled = a
  4414. },
  4415. isEnabled: function () {
  4416. return this._isEnabled
  4417. },
  4418. retain: function () { },
  4419. release: function () { }
  4420. });
  4421. cc.EventListener.UNKNOWN = 0;
  4422. cc.EventListener.TOUCH_ONE_BY_ONE = 1;
  4423. cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
  4424. cc.EventListener.KEYBOARD = 3;
  4425. cc.EventListener.MOUSE = 4;
  4426. cc.EventListener.ACCELERATION = 5;
  4427. cc.EventListener.CUSTOM = 6;
  4428. cc._EventListenerCustom = cc.EventListener.extend({
  4429. _onCustomEvent: null,
  4430. ctor: function (a, b) {
  4431. this._onCustomEvent = b;
  4432. var c = this;
  4433. cc.EventListener.prototype.ctor.call(this, cc.EventListener.CUSTOM, a,
  4434. function (a) {
  4435. null != c._onCustomEvent && c._onCustomEvent(a)
  4436. })
  4437. },
  4438. checkAvailable: function () {
  4439. return cc.EventListener.prototype.checkAvailable.call(this) && null != this._onCustomEvent
  4440. },
  4441. clone: function () {
  4442. return new cc._EventListenerCustom(this._listenerID, this._onCustomEvent)
  4443. }
  4444. });
  4445. cc._EventListenerCustom.create = function (a, b) {
  4446. return new cc._EventListenerCustom(a, b)
  4447. };
  4448. cc._EventListenerMouse = cc.EventListener.extend({
  4449. onMouseDown: null,
  4450. onMouseUp: null,
  4451. onMouseMove: null,
  4452. onMouseScroll: null,
  4453. ctor: function () {
  4454. var a = this;
  4455. cc.EventListener.prototype.ctor.call(this, cc.EventListener.MOUSE, cc._EventListenerMouse.LISTENER_ID,
  4456. function (b) {
  4457. var c = cc.EventMouse;
  4458. switch (b._eventType) {
  4459. case c.DOWN:
  4460. if (a.onMouseDown) a.onMouseDown(b);
  4461. break;
  4462. case c.UP:
  4463. if (a.onMouseUp) a.onMouseUp(b);
  4464. break;
  4465. case c.MOVE:
  4466. if (a.onMouseMove) a.onMouseMove(b);
  4467. break;
  4468. case c.SCROLL:
  4469. if (a.onMouseScroll) a.onMouseScroll(b)
  4470. }
  4471. })
  4472. },
  4473. clone: function () {
  4474. var a = new cc._EventListenerMouse;
  4475. a.onMouseDown = this.onMouseDown;
  4476. a.onMouseUp = this.onMouseUp;
  4477. a.onMouseMove = this.onMouseMove;
  4478. a.onMouseScroll = this.onMouseScroll;
  4479. return a
  4480. },
  4481. checkAvailable: function () {
  4482. return !0
  4483. }
  4484. });
  4485. cc._EventListenerMouse.LISTENER_ID = "__cc_mouse";
  4486. cc._EventListenerMouse.create = function () {
  4487. return new cc._EventListenerMouse
  4488. };
  4489. cc._EventListenerTouchOneByOne = cc.EventListener.extend({
  4490. _claimedTouches: null,
  4491. swallowTouches: !1,
  4492. onTouchBegan: null,
  4493. onTouchMoved: null,
  4494. onTouchEnded: null,
  4495. onTouchCancelled: null,
  4496. ctor: function () {
  4497. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ONE_BY_ONE, cc._EventListenerTouchOneByOne.LISTENER_ID, null);
  4498. this._claimedTouches = []
  4499. },
  4500. setSwallowTouches: function (a) {
  4501. this.swallowTouches = a
  4502. },
  4503. clone: function () {
  4504. var a = new cc._EventListenerTouchOneByOne;
  4505. a.onTouchBegan = this.onTouchBegan;
  4506. a.onTouchMoved = this.onTouchMoved;
  4507. a.onTouchEnded = this.onTouchEnded;
  4508. a.onTouchCancelled = this.onTouchCancelled;
  4509. a.swallowTouches = this.swallowTouches;
  4510. return a
  4511. },
  4512. checkAvailable: function () {
  4513. return this.onTouchBegan ? !0 : (cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable), !1)
  4514. }
  4515. });
  4516. cc._EventListenerTouchOneByOne.LISTENER_ID = "__cc_touch_one_by_one";
  4517. cc._EventListenerTouchOneByOne.create = function () {
  4518. return new cc._EventListenerTouchOneByOne
  4519. };
  4520. cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({
  4521. onTouchesBegan: null,
  4522. onTouchesMoved: null,
  4523. onTouchesEnded: null,
  4524. onTouchesCancelled: null,
  4525. ctor: function () {
  4526. cc.EventListener.prototype.ctor.call(this, cc.EventListener.TOUCH_ALL_AT_ONCE, cc._EventListenerTouchAllAtOnce.LISTENER_ID, null)
  4527. },
  4528. clone: function () {
  4529. var a = new cc._EventListenerTouchAllAtOnce;
  4530. a.onTouchesBegan = this.onTouchesBegan;
  4531. a.onTouchesMoved = this.onTouchesMoved;
  4532. a.onTouchesEnded = this.onTouchesEnded;
  4533. a.onTouchesCancelled = this.onTouchesCancelled;
  4534. return a
  4535. },
  4536. checkAvailable: function () {
  4537. return null == this.onTouchesBegan && null == this.onTouchesMoved && null == this.onTouchesEnded && null == this.onTouchesCancelled ? (cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable), !1) : !0
  4538. }
  4539. });
  4540. cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
  4541. cc._EventListenerTouchAllAtOnce.create = function () {
  4542. return new cc._EventListenerTouchAllAtOnce
  4543. };
  4544. cc.EventListener.create = function (a) {
  4545. cc.assert(a && a.event, cc._LogInfos.EventListener_create);
  4546. var b = a.event;
  4547. delete a.event;
  4548. var c = null;
  4549. 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 : b === cc.EventListener.ACCELERATION && (c = new cc._EventListenerAcceleration(a.callback), delete a.callback);
  4550. for (var d in a) c[d] = a[d];
  4551. return c
  4552. };
  4553. cc._EventListenerVector = cc.Class.extend({
  4554. _fixedListeners: null,
  4555. _sceneGraphListeners: null,
  4556. gt0Index: 0,
  4557. ctor: function () {
  4558. this._fixedListeners = [];
  4559. this._sceneGraphListeners = []
  4560. },
  4561. size: function () {
  4562. return this._fixedListeners.length + this._sceneGraphListeners.length
  4563. },
  4564. empty: function () {
  4565. return 0 === this._fixedListeners.length && 0 === this._sceneGraphListeners.length
  4566. },
  4567. push: function (a) {
  4568. 0 == a._getFixedPriority() ? this._sceneGraphListeners.push(a) : this._fixedListeners.push(a)
  4569. },
  4570. clearSceneGraphListeners: function () {
  4571. this._sceneGraphListeners.length = 0
  4572. },
  4573. clearFixedListeners: function () {
  4574. this._fixedListeners.length = 0
  4575. },
  4576. clear: function () {
  4577. this._sceneGraphListeners.length = 0;
  4578. this._fixedListeners.length = 0
  4579. },
  4580. getFixedPriorityListeners: function () {
  4581. return this._fixedListeners
  4582. },
  4583. getSceneGraphPriorityListeners: function () {
  4584. return this._sceneGraphListeners
  4585. }
  4586. });
  4587. cc.__getListenerID = function (a) {
  4588. var b = cc.Event,
  4589. c = a.getType();
  4590. if (c === b.ACCELERATION) return cc._EventListenerAcceleration.LISTENER_ID;
  4591. if (c === b.CUSTOM) return a.getEventName();
  4592. if (c === b.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID;
  4593. if (c === b.MOUSE) return cc._EventListenerMouse.LISTENER_ID;
  4594. c === b.TOUCH && cc.log(cc._LogInfos.__getListenerID);
  4595. return ""
  4596. };
  4597. cc.eventManager = {
  4598. DIRTY_NONE: 0,
  4599. DIRTY_FIXED_PRIORITY: 1,
  4600. DIRTY_SCENE_GRAPH_PRIORITY: 2,
  4601. DIRTY_ALL: 3,
  4602. _listenersMap: {},
  4603. _priorityDirtyFlagMap: {},
  4604. _nodeListenersMap: {},
  4605. _nodePriorityMap: {},
  4606. _globalZOrderNodeMap: {},
  4607. _toAddedListeners: [],
  4608. _dirtyNodes: [],
  4609. _inDispatch: 0,
  4610. _isEnabled: !1,
  4611. _nodePriorityIndex: 0,
  4612. _internalCustomListenerIDs: [cc.game.EVENT_HIDE, cc.game.EVENT_SHOW],
  4613. _setDirtyForNode: function (a) {
  4614. null != this._nodeListenersMap[a.__instanceId] && this._dirtyNodes.push(a);
  4615. a = a.getChildren();
  4616. for (var b = 0, c = a.length; b < c; b++) this._setDirtyForNode(a[b])
  4617. },
  4618. pauseTarget: function (a, b) {
  4619. var c = this._nodeListenersMap[a.__instanceId],
  4620. d,
  4621. e;
  4622. if (c) for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!0);
  4623. if (!0 === b) for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.pauseTarget(c[d], !0)
  4624. },
  4625. resumeTarget: function (a, b) {
  4626. var c = this._nodeListenersMap[a.__instanceId],
  4627. d,
  4628. e;
  4629. if (c) for (d = 0, e = c.length; d < e; d++) c[d]._setPaused(!1);
  4630. this._setDirtyForNode(a);
  4631. if (!0 === b) for (c = a.getChildren(), d = 0, e = c.length; d < e; d++) this.resumeTarget(c[d], !0)
  4632. },
  4633. _addListener: function (a) {
  4634. 0 === this._inDispatch ? this._forceAddEventListener(a) : this._toAddedListeners.push(a)
  4635. },
  4636. _forceAddEventListener: function (a) {
  4637. var b = a._getListenerID(),
  4638. c = this._listenersMap[b];
  4639. c || (c = new cc._EventListenerVector, this._listenersMap[b] = c);
  4640. c.push(a);
  4641. 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)
  4642. },
  4643. _getListeners: function (a) {
  4644. return this._listenersMap[a]
  4645. },
  4646. _updateDirtyFlagForSceneGraph: function () {
  4647. if (0 != this._dirtyNodes.length) {
  4648. for (var a = this._dirtyNodes, b, c, d = this._nodeListenersMap, e = 0, f = a.length; e < f; e++) if (b = d[a[e].__instanceId]) for (var g = 0, h = b.length; g < h; g++) (c = b[g]) && this._setDirty(c._getListenerID(), this.DIRTY_SCENE_GRAPH_PRIORITY);
  4649. this._dirtyNodes.length = 0
  4650. }
  4651. },
  4652. _removeAllListenersInVector: function (a) {
  4653. if (a) for (var b, c = 0; c < a.length;) b = a[c],
  4654. b._setRegistered(!1),
  4655. null != b._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(b._getSceneGraphPriority(), b), b._setSceneGraphPriority(null)),
  4656. 0 === this._inDispatch ? cc.arrayRemoveObject(a, b) : ++c
  4657. },
  4658. _removeListenersForListenerID: function (a) {
  4659. var b = this._listenersMap[a];
  4660. if (b) {
  4661. var c = b.getFixedPriorityListeners(),
  4662. d = b.getSceneGraphPriorityListeners();
  4663. this._removeAllListenersInVector(d);
  4664. this._removeAllListenersInVector(c);
  4665. delete this._priorityDirtyFlagMap[a];
  4666. this._inDispatch || (b.clear(), delete this._listenersMap[a])
  4667. }
  4668. c = this._toAddedListeners;
  4669. for (b = 0; b < c.length;) (d = c[b]) && d._getListenerID() == a ? cc.arrayRemoveObject(c, d) : ++b
  4670. },
  4671. _sortEventListeners: function (a) {
  4672. var b = this.DIRTY_NONE,
  4673. c = this._priorityDirtyFlagMap;
  4674. c[a] && (b = c[a]);
  4675. 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))
  4676. },
  4677. _sortListenersOfSceneGraphPriority: function (a, b) {
  4678. var c = this._getListeners(a);
  4679. if (c) {
  4680. var d = c.getSceneGraphPriorityListeners();
  4681. d && 0 !== d.length && (this._nodePriorityIndex = 0, this._nodePriorityMap = {},
  4682. this._visitTarget(b, !0), c.getSceneGraphPriorityListeners().sort(this._sortEventListenersOfSceneGraphPriorityDes))
  4683. }
  4684. },
  4685. _sortEventListenersOfSceneGraphPriorityDes: function (a, b) {
  4686. var c = cc.eventManager._nodePriorityMap;
  4687. return a && b && a._getSceneGraphPriority() && b._getSceneGraphPriority() ? c[b._getSceneGraphPriority().__instanceId] - c[a._getSceneGraphPriority().__instanceId] : -1
  4688. },
  4689. _sortListenersOfFixedPriority: function (a) {
  4690. if (a = this._listenersMap[a]) {
  4691. var b = a.getFixedPriorityListeners();
  4692. if (b && 0 !== b.length) {
  4693. b.sort(this._sortListenersOfFixedPriorityAsc);
  4694. for (var c = 0, d = b.length; c < d && !(0 <= b[c]._getFixedPriority()) ;)++c;
  4695. a.gt0Index = c
  4696. }
  4697. }
  4698. },
  4699. _sortListenersOfFixedPriorityAsc: function (a, b) {
  4700. return a._getFixedPriority() - b._getFixedPriority()
  4701. },
  4702. _onUpdateListeners: function (a) {
  4703. if (a = this._listenersMap[a]) {
  4704. var b = a.getFixedPriorityListeners(),
  4705. c = a.getSceneGraphPriorityListeners(),
  4706. d,
  4707. e;
  4708. if (c) for (d = 0; d < c.length;) e = c[d],
  4709. e._isRegistered() ? ++d : cc.arrayRemoveObject(c, e);
  4710. if (b) for (d = 0; d < b.length;) e = b[d],
  4711. e._isRegistered() ? ++d : cc.arrayRemoveObject(b, e);
  4712. c && 0 === c.length && a.clearSceneGraphListeners();
  4713. b && 0 === b.length && a.clearFixedListeners()
  4714. }
  4715. },
  4716. _updateListeners: function (a) {
  4717. var b = this._inDispatch;
  4718. cc.assert(0 < b, cc._LogInfos.EventManager__updateListeners);
  4719. a.getType() == cc.Event.TOUCH ? (this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID), this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)) : this._onUpdateListeners(cc.__getListenerID(a));
  4720. if (!(1 < b)) {
  4721. cc.assert(1 == b, cc._LogInfos.EventManager__updateListeners_2);
  4722. a = this._listenersMap;
  4723. var b = this._priorityDirtyFlagMap,
  4724. c;
  4725. for (c in a) a[c].empty() && (delete b[c], delete a[c]);
  4726. c = this._toAddedListeners;
  4727. if (0 !== c.length) {
  4728. a = 0;
  4729. for (b = c.length; a < b; a++) this._forceAddEventListener(c[a]);
  4730. this._toAddedListeners.length = 0
  4731. }
  4732. }
  4733. },
  4734. _onTouchEventCallback: function (a, b) {
  4735. if (!a._isRegistered) return !1;
  4736. var c = b.event,
  4737. d = b.selTouch;
  4738. c._setCurrentTarget(a._node);
  4739. var e = !1,
  4740. f,
  4741. g = c.getEventCode(),
  4742. h = cc.EventTouch.EventCode;
  4743. if (g == h.BEGAN) a.onTouchBegan && (e = a.onTouchBegan(d, c)) && a._registered && a._claimedTouches.push(d);
  4744. else if (0 < a._claimedTouches.length && -1 != (f = a._claimedTouches.indexOf(d))) if (e = !0, g === h.MOVED && a.onTouchMoved) a.onTouchMoved(d, c);
  4745. else if (g === h.ENDED) {
  4746. if (a.onTouchEnded) a.onTouchEnded(d, c);
  4747. a._registered && a._claimedTouches.splice(f, 1)
  4748. } else if (g === h.CANCELLED) {
  4749. if (a.onTouchCancelled) a.onTouchCancelled(d, c);
  4750. a._registered && a._claimedTouches.splice(f, 1)
  4751. }
  4752. return c.isStopped() ? (cc.eventManager._updateListeners(c), !0) : e && a._registered && a.swallowTouches ? (b.needsMutableSet && b.touches.splice(d, 1), !0) : !1
  4753. },
  4754. _dispatchTouchEvent: function (a) {
  4755. this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID);
  4756. this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4757. var b = this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),
  4758. c = this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);
  4759. if (null != b || null != c) {
  4760. var d = a.getTouches(),
  4761. e = cc.copyArray(d),
  4762. f = {
  4763. event: a,
  4764. needsMutableSet: b && c,
  4765. touches: e,
  4766. selTouch: null
  4767. };
  4768. if (b) for (var g = 0; g < d.length; g++) if (f.selTouch = d[g], this._dispatchEventToListeners(b, this._onTouchEventCallback, f), a.isStopped()) return;
  4769. if (c && 0 < e.length && (this._dispatchEventToListeners(c, this._onTouchesEventCallback, {
  4770. event: a,
  4771. touches: e
  4772. }), a.isStopped())) return;
  4773. this._updateListeners(a)
  4774. }
  4775. },
  4776. _onTouchesEventCallback: function (a, b) {
  4777. if (!a._registered) return !1;
  4778. var c = cc.EventTouch.EventCode,
  4779. d = b.event,
  4780. e = b.touches,
  4781. f = d.getEventCode();
  4782. d._setCurrentTarget(a._node);
  4783. if (f == c.BEGAN && a.onTouchesBegan) a.onTouchesBegan(e, d);
  4784. else if (f == c.MOVED && a.onTouchesMoved) a.onTouchesMoved(e, d);
  4785. else if (f == c.ENDED && a.onTouchesEnded) a.onTouchesEnded(e, d);
  4786. else if (f == c.CANCELLED && a.onTouchesCancelled) a.onTouchesCancelled(e, d);
  4787. return d.isStopped() ? (cc.eventManager._updateListeners(d), !0) : !1
  4788. },
  4789. _associateNodeAndEventListener: function (a, b) {
  4790. var c = this._nodeListenersMap[a.__instanceId];
  4791. c || (c = [], this._nodeListenersMap[a.__instanceId] = c);
  4792. c.push(b)
  4793. },
  4794. _dissociateNodeAndEventListener: function (a, b) {
  4795. var c = this._nodeListenersMap[a.__instanceId];
  4796. c && (cc.arrayRemoveObject(c, b), 0 === c.length && delete this._nodeListenersMap[a.__instanceId])
  4797. },
  4798. _dispatchEventToListeners: function (a, b, c) {
  4799. var d = !1,
  4800. e = a.getFixedPriorityListeners(),
  4801. f = a.getSceneGraphPriorityListeners(),
  4802. g = 0,
  4803. h;
  4804. if (e && 0 !== e.length) for (; g < a.gt0Index; ++g) if (h = e[g], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  4805. d = !0;
  4806. break
  4807. }
  4808. if (f && !d) for (a = 0; a < f.length; a++) if (h = f[a], h.isEnabled() && !h._isPaused() && h._isRegistered() && b(h, c)) {
  4809. d = !0;
  4810. break
  4811. }
  4812. if (e && !d) for (; g < e.length && (h = e[g], !h.isEnabled() || h._isPaused() || !h._isRegistered() || !b(h, c)) ; ++g);
  4813. },
  4814. _setDirty: function (a, b) {
  4815. var c = this._priorityDirtyFlagMap;
  4816. c[a] = null == c[a] ? b : b | c[a]
  4817. },
  4818. _visitTarget: function (a, b) {
  4819. var c = a.getChildren(),
  4820. d = 0,
  4821. e = c.length,
  4822. f = this._globalZOrderNodeMap,
  4823. g = this._nodeListenersMap;
  4824. if (0 < e) {
  4825. for (var h; d < e; d++) if ((h = c[d]) && 0 > h.getLocalZOrder()) this._visitTarget(h, !1);
  4826. else break;
  4827. null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  4828. for (; d < e; d++) (h = c[d]) && this._visitTarget(h, !1)
  4829. } else null != g[a.__instanceId] && (f[a.getGlobalZOrder()] || (f[a.getGlobalZOrder()] = []), f[a.getGlobalZOrder()].push(a.__instanceId));
  4830. if (b) {
  4831. var c = [],
  4832. k;
  4833. for (k in f) c.push(k);
  4834. c.sort(this._sortNumberAsc);
  4835. k = c.length;
  4836. h = this._nodePriorityMap;
  4837. for (d = 0; d < k; d++) for (e = f[c[d]], g = 0; g < e.length; g++) h[e[g]] = ++this._nodePriorityIndex;
  4838. this._globalZOrderNodeMap = {}
  4839. }
  4840. },
  4841. _sortNumberAsc: function (a, b) {
  4842. return a - b
  4843. },
  4844. addListener: function (a, b) {
  4845. cc.assert(a && b, cc._LogInfos.eventManager_addListener_2);
  4846. if (!(a instanceof cc.EventListener)) cc.assert(!cc.isNumber(b), cc._LogInfos.eventManager_addListener_3),
  4847. a = cc.EventListener.create(a);
  4848. else if (a._isRegistered()) {
  4849. cc.log(cc._LogInfos.eventManager_addListener_4);
  4850. return
  4851. }
  4852. a.checkAvailable() && (cc.isNumber(b) ? 0 == b ? cc.log(cc._LogInfos.eventManager_addListener) : (a._setSceneGraphPriority(null), a._setFixedPriority(b), a._setRegistered(!0), a._setPaused(!1), this._addListener(a)) : (a._setSceneGraphPriority(b), a._setFixedPriority(0), a._setRegistered(!0), this._addListener(a)))
  4853. },
  4854. addCustomListener: function (a, b) {
  4855. var c = cc._EventListenerCustom.create(a, b);
  4856. this.addListener(c, 1);
  4857. return c
  4858. },
  4859. removeListener: function (a) {
  4860. if (null != a) {
  4861. var b,
  4862. c = this._listenersMap,
  4863. d;
  4864. for (d in c) {
  4865. var e = c[d],
  4866. f = e.getFixedPriorityListeners();
  4867. b = e.getSceneGraphPriorityListeners(); (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);
  4868. e.empty() && (delete this._priorityDirtyFlagMap[a._getListenerID()], delete c[d]);
  4869. if (b) break
  4870. }
  4871. if (!b) for (c = this._toAddedListeners, d = 0, e = c.length; d < e; d++) if (f = c[d], f == a) {
  4872. cc.arrayRemoveObject(c, f);
  4873. break
  4874. }
  4875. }
  4876. },
  4877. _removeListenerInVector: function (a, b) {
  4878. if (null == a) return !1;
  4879. for (var c = 0, d = a.length; c < d; c++) {
  4880. var e = a[c];
  4881. if (e == b) return e._setRegistered(!1),
  4882. null != e._getSceneGraphPriority() && (this._dissociateNodeAndEventListener(e._getSceneGraphPriority(), e), e._setSceneGraphPriority(null)),
  4883. 0 == this._inDispatch && cc.arrayRemoveObject(a, e),
  4884. !0
  4885. }
  4886. return !1
  4887. },
  4888. removeListeners: function (a, b) {
  4889. if (a instanceof cc.Node) {
  4890. delete this._nodePriorityMap[a.__instanceId];
  4891. cc.arrayRemoveObject(this._dirtyNodes, a);
  4892. var c = this._nodeListenersMap[a.__instanceId];
  4893. if (c) {
  4894. for (var d = cc.copyArray(c), c = 0; c < d.length; c++) this.removeListener(d[c]);
  4895. d.length = 0
  4896. }
  4897. d = this._toAddedListeners;
  4898. for (c = 0; c < d.length;) {
  4899. var e = d[c];
  4900. e._getSceneGraphPriority() == a ? (e._setSceneGraphPriority(null), e._setRegistered(!1), d.splice(c, 1)) : ++c
  4901. }
  4902. if (!0 === b) for (d = a.getChildren(), c = 0, e = d.length; c < e; c++) this.removeListeners(d[c], !0)
  4903. } else a == cc.EventListener.TOUCH_ONE_BY_ONE ? this._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID) : a == cc.EventListener.TOUCH_ALL_AT_ONCE ? this._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID) : a == cc.EventListener.MOUSE ? this._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID) : a == cc.EventListener.ACCELERATION ? this._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID) : a == cc.EventListener.KEYBOARD ? this._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID) : cc.log(cc._LogInfos.eventManager_removeListeners)
  4904. },
  4905. removeCustomListeners: function (a) {
  4906. this._removeListenersForListenerID(a)
  4907. },
  4908. removeAllListeners: function () {
  4909. var a = this._listenersMap,
  4910. b = this._internalCustomListenerIDs,
  4911. c;
  4912. for (c in a) -1 === b.indexOf(c) && this._removeListenersForListenerID(c)
  4913. },
  4914. setPriority: function (a, b) {
  4915. if (null != a) {
  4916. var c = this._listenersMap,
  4917. d;
  4918. for (d in c) {
  4919. var e = c[d].getFixedPriorityListeners();
  4920. if (e && -1 != e.indexOf(a)) {
  4921. null != a._getSceneGraphPriority() && cc.log(cc._LogInfos.eventManager_setPriority);
  4922. a._getFixedPriority() !== b && (a._setFixedPriority(b), this._setDirty(a._getListenerID(), this.DIRTY_FIXED_PRIORITY));
  4923. break
  4924. }
  4925. }
  4926. }
  4927. },
  4928. setEnabled: function (a) {
  4929. this._isEnabled = a
  4930. },
  4931. isEnabled: function () {
  4932. return this._isEnabled
  4933. },
  4934. dispatchEvent: function (a) {
  4935. if (this._isEnabled) {
  4936. this._updateDirtyFlagForSceneGraph();
  4937. this._inDispatch++;
  4938. if (!a || !a.getType) throw "event is undefined";
  4939. if (a.getType() == cc.Event.TOUCH) this._dispatchTouchEvent(a);
  4940. else {
  4941. var b = cc.__getListenerID(a);
  4942. this._sortEventListeners(b);
  4943. b = this._listenersMap[b];
  4944. null != b && this._dispatchEventToListeners(b, this._onListenerCallback, a);
  4945. this._updateListeners(a)
  4946. }
  4947. this._inDispatch--
  4948. }
  4949. },
  4950. _onListenerCallback: function (a, b) {
  4951. b._setCurrentTarget(a._getSceneGraphPriority());
  4952. a._onEvent(b);
  4953. return b.isStopped()
  4954. },
  4955. dispatchCustomEvent: function (a, b) {
  4956. var c = new cc.EventCustom(a);
  4957. c.setUserData(b);
  4958. this.dispatchEvent(c)
  4959. }
  4960. };
  4961. cc.EventAcceleration = cc.Event.extend({
  4962. _acc: null,
  4963. ctor: function (a) {
  4964. cc.Event.prototype.ctor.call(this, cc.Event.ACCELERATION);
  4965. this._acc = a
  4966. }
  4967. });
  4968. cc.EventKeyboard = cc.Event.extend({
  4969. _keyCode: 0,
  4970. _isPressed: !1,
  4971. ctor: function (a, b) {
  4972. cc.Event.prototype.ctor.call(this, cc.Event.KEYBOARD);
  4973. this._keyCode = a;
  4974. this._isPressed = b
  4975. }
  4976. });
  4977. cc._EventListenerAcceleration = cc.EventListener.extend({
  4978. _onAccelerationEvent: null,
  4979. ctor: function (a) {
  4980. this._onAccelerationEvent = a;
  4981. var b = this;
  4982. cc.EventListener.prototype.ctor.call(this, cc.EventListener.ACCELERATION, cc._EventListenerAcceleration.LISTENER_ID,
  4983. function (a) {
  4984. b._onAccelerationEvent(a._acc, a)
  4985. })
  4986. },
  4987. checkAvailable: function () {
  4988. cc.assert(this._onAccelerationEvent, cc._LogInfos._EventListenerAcceleration_checkAvailable);
  4989. return !0
  4990. },
  4991. clone: function () {
  4992. return new cc._EventListenerAcceleration(this._onAccelerationEvent)
  4993. }
  4994. });
  4995. cc._EventListenerAcceleration.LISTENER_ID = "__cc_acceleration";
  4996. cc._EventListenerAcceleration.create = function (a) {
  4997. return new cc._EventListenerAcceleration(a)
  4998. };
  4999. cc._EventListenerKeyboard = cc.EventListener.extend({
  5000. onKeyPressed: null,
  5001. onKeyReleased: null,
  5002. ctor: function () {
  5003. var a = this;
  5004. cc.EventListener.prototype.ctor.call(this, cc.EventListener.KEYBOARD, cc._EventListenerKeyboard.LISTENER_ID,
  5005. function (b) {
  5006. if (b._isPressed) {
  5007. if (a.onKeyPressed) a.onKeyPressed(b._keyCode, b)
  5008. } else if (a.onKeyReleased) a.onKeyReleased(b._keyCode, b)
  5009. })
  5010. },
  5011. clone: function () {
  5012. var a = new cc._EventListenerKeyboard;
  5013. a.onKeyPressed = this.onKeyPressed;
  5014. a.onKeyReleased = this.onKeyReleased;
  5015. return a
  5016. },
  5017. checkAvailable: function () {
  5018. return null == this.onKeyPressed && null == this.onKeyReleased ? (cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable), !1) : !0
  5019. }
  5020. });
  5021. cc._EventListenerKeyboard.LISTENER_ID = "__cc_keyboard";
  5022. cc._EventListenerKeyboard.create = function () {
  5023. return new cc._EventListenerKeyboard
  5024. };
  5025. cc._tmp.WebGLCCNode = function () {
  5026. var a = cc.Node.prototype;
  5027. a._transform4x4 = null;
  5028. a._stackMatrix = null;
  5029. a._glServerState = null;
  5030. a._camera = null;
  5031. a.ctor = function () {
  5032. this._initNode();
  5033. var a = new cc.kmMat4;
  5034. a.mat[2] = a.mat[3] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[14] = 0;
  5035. a.mat[10] = a.mat[15] = 1;
  5036. this._transform4x4 = a;
  5037. this._glServerState = 0;
  5038. this._stackMatrix = new cc.kmMat4
  5039. };
  5040. a.setNodeDirty = function () {
  5041. !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
  5042. };
  5043. a.visit = function () {
  5044. if (this._visible) {
  5045. var a = cc._renderContext,
  5046. c,
  5047. d = cc.current_stack;
  5048. d.stack.push(d.top);
  5049. cc.kmMat4Assign(this._stackMatrix, d.top);
  5050. d.top = this._stackMatrix;
  5051. var e = this.grid;
  5052. e && e._active && e.beforeDraw();
  5053. this.transform();
  5054. var f = this._children;
  5055. if (f && 0 < f.length) {
  5056. var g = f.length;
  5057. this.sortAllChildren();
  5058. for (c = 0; c < g; c++) if (f[c] && 0 > f[c]._localZOrder) f[c].visit();
  5059. else break;
  5060. for (this.draw(a) ; c < g; c++) f[c] && f[c].visit()
  5061. } else this.draw(a);
  5062. this.arrivalOrder = 0;
  5063. e && e._active && e.afterDraw(this);
  5064. d.top = d.stack.pop()
  5065. }
  5066. };
  5067. a.transform = function () {
  5068. var a = this._transform4x4,
  5069. c = cc.current_stack.top,
  5070. d = this.nodeToParentTransform(),
  5071. e = a.mat;
  5072. e[0] = d.a;
  5073. e[4] = d.c;
  5074. e[12] = d.tx;
  5075. e[1] = d.b;
  5076. e[5] = d.d;
  5077. e[13] = d.ty;
  5078. e[14] = this._vertexZ;
  5079. cc.kmMat4Multiply(c, c, a);
  5080. null == this._camera || null != this.grid && this.grid.isActive() || (a = this._anchorPointInPoints.x, c = this._anchorPointInPoints.y, 0 !== a || 0 !== c ? (cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (a |= 0, c |= 0), cc.kmGLTranslatef(a, c, 0), this._camera.locate(), cc.kmGLTranslatef(-a, -c, 0)) : this._camera.locate())
  5081. };
  5082. a.getNodeToParentTransform = a._getNodeToParentTransformForWebGL
  5083. };
  5084. cc._tmp.PrototypeCCNode = function () {
  5085. var a = cc.Node.prototype;
  5086. cc.defineGetterSetter(a, "x", a.getPositionX, a.setPositionX);
  5087. cc.defineGetterSetter(a, "y", a.getPositionY, a.setPositionY);
  5088. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  5089. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight);
  5090. cc.defineGetterSetter(a, "anchorX", a._getAnchorX, a._setAnchorX);
  5091. cc.defineGetterSetter(a, "anchorY", a._getAnchorY, a._setAnchorY);
  5092. cc.defineGetterSetter(a, "skewX", a.getSkewX, a.setSkewX);
  5093. cc.defineGetterSetter(a, "skewY", a.getSkewY, a.setSkewY);
  5094. cc.defineGetterSetter(a, "zIndex", a.getLocalZOrder, a.setLocalZOrder);
  5095. cc.defineGetterSetter(a, "vertexZ", a.getVertexZ, a.setVertexZ);
  5096. cc.defineGetterSetter(a, "rotation", a.getRotation, a.setRotation);
  5097. cc.defineGetterSetter(a, "rotationX", a.getRotationX, a.setRotationX);
  5098. cc.defineGetterSetter(a, "rotationY", a.getRotationY, a.setRotationY);
  5099. cc.defineGetterSetter(a, "scale", a.getScale, a.setScale);
  5100. cc.defineGetterSetter(a, "scaleX", a.getScaleX, a.setScaleX);
  5101. cc.defineGetterSetter(a, "scaleY", a.getScaleY, a.setScaleY);
  5102. cc.defineGetterSetter(a, "children", a.getChildren);
  5103. cc.defineGetterSetter(a, "childrenCount", a.getChildrenCount);
  5104. cc.defineGetterSetter(a, "parent", a.getParent, a.setParent);
  5105. cc.defineGetterSetter(a, "visible", a.isVisible, a.setVisible);
  5106. cc.defineGetterSetter(a, "running", a.isRunning);
  5107. cc.defineGetterSetter(a, "ignoreAnchor", a.isIgnoreAnchorPointForPosition, a.ignoreAnchorPointForPosition);
  5108. cc.defineGetterSetter(a, "actionManager", a.getActionManager, a.setActionManager);
  5109. cc.defineGetterSetter(a, "scheduler", a.getScheduler, a.setScheduler);
  5110. cc.defineGetterSetter(a, "shaderProgram", a.getShaderProgram, a.setShaderProgram);
  5111. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  5112. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB);
  5113. cc.defineGetterSetter(a, "cascadeOpacity", a.isCascadeOpacityEnabled, a.setCascadeOpacityEnabled);
  5114. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  5115. cc.defineGetterSetter(a, "cascadeColor", a.isCascadeColorEnabled, a.setCascadeColorEnabled)
  5116. };
  5117. cc.NODE_TAG_INVALID = -1;
  5118. cc.s_globalOrderOfArrival = 1;
  5119. cc.Node = cc.Class.extend({
  5120. _localZOrder: 0,
  5121. _globalZOrder: 0,
  5122. _vertexZ: 0,
  5123. _rotationX: 0,
  5124. _rotationY: 0,
  5125. _scaleX: 1,
  5126. _scaleY: 1,
  5127. _position: null,
  5128. _skewX: 0,
  5129. _skewY: 0,
  5130. _children: null,
  5131. _visible: !0,
  5132. _anchorPoint: null,
  5133. _anchorPointInPoints: null,
  5134. _contentSize: null,
  5135. _running: !1,
  5136. _parent: null,
  5137. _ignoreAnchorPointForPosition: !1,
  5138. tag: cc.NODE_TAG_INVALID,
  5139. userData: null,
  5140. userObject: null,
  5141. _transformDirty: !0,
  5142. _inverseDirty: !0,
  5143. _cacheDirty: !0,
  5144. _cachedParent: null,
  5145. _transformGLDirty: null,
  5146. _transform: null,
  5147. _inverse: null,
  5148. _reorderChildDirty: !1,
  5149. _shaderProgram: null,
  5150. arrivalOrder: 0,
  5151. _actionManager: null,
  5152. _scheduler: null,
  5153. _eventDispatcher: null,
  5154. _initializedNode: !1,
  5155. _additionalTransformDirty: !1,
  5156. _additionalTransform: null,
  5157. _componentContainer: null,
  5158. _isTransitionFinished: !1,
  5159. _rotationRadiansX: 0,
  5160. _rotationRadiansY: 0,
  5161. _className: "Node",
  5162. _showNode: !1,
  5163. _name: "",
  5164. _displayedOpacity: 255,
  5165. _realOpacity: 255,
  5166. _displayedColor: null,
  5167. _realColor: null,
  5168. _cascadeColorEnabled: !1,
  5169. _cascadeOpacityEnabled: !1,
  5170. _usingNormalizedPosition: !1,
  5171. _hashOfName: 0,
  5172. _initNode: function () {
  5173. this._anchorPoint = cc.p(0, 0);
  5174. this._anchorPointInPoints = cc.p(0, 0);
  5175. this._contentSize = cc.size(0, 0);
  5176. this._position = cc.p(0, 0);
  5177. this._children = [];
  5178. this._transform = {
  5179. a: 1,
  5180. b: 0,
  5181. c: 0,
  5182. d: 1,
  5183. tx: 0,
  5184. ty: 0
  5185. };
  5186. var a = cc.director;
  5187. this._actionManager = a.getActionManager();
  5188. this._scheduler = a.getScheduler();
  5189. this._initializedNode = !0;
  5190. this._additionalTransform = cc.affineTransformMakeIdentity();
  5191. cc.ComponentContainer && (this._componentContainer = new cc.ComponentContainer(this));
  5192. this._realOpacity = this._displayedOpacity = 255;
  5193. this._displayedColor = cc.color(255, 255, 255, 255);
  5194. this._realColor = cc.color(255, 255, 255, 255);
  5195. this._cascadeOpacityEnabled = this._cascadeColorEnabled = !1
  5196. },
  5197. init: function () {
  5198. !1 === this._initializedNode && this._initNode();
  5199. return !0
  5200. },
  5201. _arrayMakeObjectsPerformSelector: function (a, b) {
  5202. if (a && 0 !== a.length) {
  5203. var c,
  5204. d = a.length,
  5205. e;
  5206. c = cc.Node._StateCallbackType;
  5207. switch (b) {
  5208. case c.onEnter:
  5209. for (c = 0; c < d; c++) if (e = a[c]) e.onEnter();
  5210. break;
  5211. case c.onExit:
  5212. for (c = 0; c < d; c++) if (e = a[c]) e.onExit();
  5213. break;
  5214. case c.onEnterTransitionDidFinish:
  5215. for (c = 0; c < d; c++) if (e = a[c]) e.onEnterTransitionDidFinish();
  5216. break;
  5217. case c.cleanup:
  5218. for (c = 0; c < d; c++) (e = a[c]) && e.cleanup();
  5219. break;
  5220. case c.updateTransform:
  5221. for (c = 0; c < d; c++) (e = a[c]) && e.updateTransform();
  5222. break;
  5223. case c.onExitTransitionDidStart:
  5224. for (c = 0; c < d; c++) if (e = a[c]) e.onExitTransitionDidStart();
  5225. break;
  5226. case c.sortAllChildren:
  5227. for (c = 0; c < d; c++) (e = a[c]) && e.sortAllChildren();
  5228. break;
  5229. default:
  5230. cc.assert(0, cc._LogInfos.Node__arrayMakeObjectsPerformSelector)
  5231. }
  5232. }
  5233. },
  5234. setNodeDirty: null,
  5235. attr: function (a) {
  5236. for (var b in a) this[b] = a[b]
  5237. },
  5238. getSkewX: function () {
  5239. return this._skewX
  5240. },
  5241. setSkewX: function (a) {
  5242. this._skewX = a;
  5243. this.setNodeDirty()
  5244. },
  5245. getSkewY: function () {
  5246. return this._skewY
  5247. },
  5248. setSkewY: function (a) {
  5249. this._skewY = a;
  5250. this.setNodeDirty()
  5251. },
  5252. setLocalZOrder: function (a) {
  5253. this._localZOrder = a;
  5254. this._parent && this._parent.reorderChild(this, a);
  5255. cc.eventManager._setDirtyForNode(this)
  5256. },
  5257. _setLocalZOrder: function (a) {
  5258. this._localZOrder = a
  5259. },
  5260. getLocalZOrder: function () {
  5261. return this._localZOrder
  5262. },
  5263. getZOrder: function () {
  5264. cc.log(cc._LogInfos.Node_getZOrder);
  5265. return this.getLocalZOrder()
  5266. },
  5267. setZOrder: function (a) {
  5268. cc.log(cc._LogInfos.Node_setZOrder);
  5269. this.setLocalZOrder(a)
  5270. },
  5271. setGlobalZOrder: function (a) {
  5272. this._globalZOrder != a && (this._globalZOrder = a, cc.eventManager._setDirtyForNode(this))
  5273. },
  5274. getGlobalZOrder: function () {
  5275. return this._globalZOrder
  5276. },
  5277. getVertexZ: function () {
  5278. return this._vertexZ
  5279. },
  5280. setVertexZ: function (a) {
  5281. this._vertexZ = a
  5282. },
  5283. getRotation: function () {
  5284. this._rotationX !== this._rotationY && cc.log(cc._LogInfos.Node_getRotation);
  5285. return this._rotationX
  5286. },
  5287. setRotation: function (a) {
  5288. this._rotationX = this._rotationY = a;
  5289. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  5290. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  5291. this.setNodeDirty()
  5292. },
  5293. getRotationX: function () {
  5294. return this._rotationX
  5295. },
  5296. setRotationX: function (a) {
  5297. this._rotationX = a;
  5298. this._rotationRadiansX = 0.017453292519943295 * this._rotationX;
  5299. this.setNodeDirty()
  5300. },
  5301. getRotationY: function () {
  5302. return this._rotationY
  5303. },
  5304. setRotationY: function (a) {
  5305. this._rotationY = a;
  5306. this._rotationRadiansY = 0.017453292519943295 * this._rotationY;
  5307. this.setNodeDirty()
  5308. },
  5309. getScale: function () {
  5310. this._scaleX !== this._scaleY && cc.log(cc._LogInfos.Node_getScale);
  5311. return this._scaleX
  5312. },
  5313. setScale: function (a, b) {
  5314. this._scaleX = a;
  5315. this._scaleY = b || 0 === b ? b : a;
  5316. this.setNodeDirty()
  5317. },
  5318. getScaleX: function () {
  5319. return this._scaleX
  5320. },
  5321. setScaleX: function (a) {
  5322. this._scaleX = a;
  5323. this.setNodeDirty()
  5324. },
  5325. getScaleY: function () {
  5326. return this._scaleY
  5327. },
  5328. setScaleY: function (a) {
  5329. this._scaleY = a;
  5330. this.setNodeDirty()
  5331. },
  5332. setPosition: function (a, b) {
  5333. var c = this._position;
  5334. void 0 === b ? (c.x = a.x, c.y = a.y) : (c.x = a, c.y = b);
  5335. this.setNodeDirty()
  5336. },
  5337. getPosition: function () {
  5338. return cc.p(this._position)
  5339. },
  5340. getPositionX: function () {
  5341. return this._position.x
  5342. },
  5343. setPositionX: function (a) {
  5344. this._position.x = a;
  5345. this.setNodeDirty()
  5346. },
  5347. getPositionY: function () {
  5348. return this._position.y
  5349. },
  5350. setPositionY: function (a) {
  5351. this._position.y = a;
  5352. this.setNodeDirty()
  5353. },
  5354. getChildrenCount: function () {
  5355. return this._children.length
  5356. },
  5357. getChildren: function () {
  5358. return this._children
  5359. },
  5360. isVisible: function () {
  5361. return this._visible
  5362. },
  5363. setVisible: function (a) {
  5364. this._visible != a && (this._visible = a) && this.setNodeDirty()
  5365. },
  5366. getAnchorPoint: function () {
  5367. return cc.p(this._anchorPoint)
  5368. },
  5369. setAnchorPoint: function (a, b) {
  5370. var c = this._anchorPoint;
  5371. if (void 0 === b) {
  5372. if (a.x === c.x && a.y === c.y) return;
  5373. c.x = a.x;
  5374. c.y = a.y
  5375. } else {
  5376. if (a === c.x && b === c.y) return;
  5377. c.x = a;
  5378. c.y = b
  5379. }
  5380. var d = this._anchorPointInPoints,
  5381. e = this._contentSize;
  5382. d.x = e.width * c.x;
  5383. d.y = e.height * c.y;
  5384. this.setNodeDirty()
  5385. },
  5386. _getAnchor: function () {
  5387. return this._anchorPoint
  5388. },
  5389. _setAnchor: function (a) {
  5390. var b = a.x;
  5391. a = a.y;
  5392. this._anchorPoint.x !== b && (this._anchorPoint.x = b, this._anchorPointInPoints.x = this._contentSize.width * b);
  5393. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a);
  5394. this.setNodeDirty()
  5395. },
  5396. _getAnchorX: function () {
  5397. return this._anchorPoint.x
  5398. },
  5399. _setAnchorX: function (a) {
  5400. this._anchorPoint.x !== a && (this._anchorPoint.x = a, this._anchorPointInPoints.x = this._contentSize.width * a, this.setNodeDirty())
  5401. },
  5402. _getAnchorY: function () {
  5403. return this._anchorPoint.y
  5404. },
  5405. _setAnchorY: function (a) {
  5406. this._anchorPoint.y !== a && (this._anchorPoint.y = a, this._anchorPointInPoints.y = this._contentSize.height * a, this.setNodeDirty())
  5407. },
  5408. getAnchorPointInPoints: function () {
  5409. return cc.p(this._anchorPointInPoints)
  5410. },
  5411. _getWidth: function () {
  5412. return this._contentSize.width
  5413. },
  5414. _setWidth: function (a) {
  5415. this._contentSize.width = a;
  5416. this._anchorPointInPoints.x = a * this._anchorPoint.x;
  5417. this.setNodeDirty()
  5418. },
  5419. _getHeight: function () {
  5420. return this._contentSize.height
  5421. },
  5422. _setHeight: function (a) {
  5423. this._contentSize.height = a;
  5424. this._anchorPointInPoints.y = a * this._anchorPoint.y;
  5425. this.setNodeDirty()
  5426. },
  5427. getContentSize: function () {
  5428. return cc.size(this._contentSize)
  5429. },
  5430. setContentSize: function (a, b) {
  5431. var c = this._contentSize;
  5432. if (void 0 === b) {
  5433. if (a.width === c.width && a.height === c.height) return;
  5434. c.width = a.width;
  5435. c.height = a.height
  5436. } else {
  5437. if (a === c.width && b === c.height) return;
  5438. c.width = a;
  5439. c.height = b
  5440. }
  5441. var d = this._anchorPointInPoints,
  5442. e = this._anchorPoint;
  5443. d.x = c.width * e.x;
  5444. d.y = c.height * e.y;
  5445. this.setNodeDirty()
  5446. },
  5447. isRunning: function () {
  5448. return this._running
  5449. },
  5450. getParent: function () {
  5451. return this._parent
  5452. },
  5453. setParent: function (a) {
  5454. this._parent = a
  5455. },
  5456. isIgnoreAnchorPointForPosition: function () {
  5457. return this._ignoreAnchorPointForPosition
  5458. },
  5459. ignoreAnchorPointForPosition: function (a) {
  5460. a != this._ignoreAnchorPointForPosition && (this._ignoreAnchorPointForPosition = a, this.setNodeDirty())
  5461. },
  5462. getTag: function () {
  5463. return this.tag
  5464. },
  5465. setTag: function (a) {
  5466. this.tag = a
  5467. },
  5468. setName: function (a) {
  5469. this._name = a
  5470. },
  5471. getName: function () {
  5472. return this._name
  5473. },
  5474. getUserData: function () {
  5475. return this.userData
  5476. },
  5477. setUserData: function (a) {
  5478. this.userData = a
  5479. },
  5480. getUserObject: function () {
  5481. return this.userObject
  5482. },
  5483. setUserObject: function (a) {
  5484. this.userObject != a && (this.userObject = a)
  5485. },
  5486. getOrderOfArrival: function () {
  5487. return this.arrivalOrder
  5488. },
  5489. setOrderOfArrival: function (a) {
  5490. this.arrivalOrder = a
  5491. },
  5492. getActionManager: function () {
  5493. this._actionManager || (this._actionManager = cc.director.getActionManager());
  5494. return this._actionManager
  5495. },
  5496. setActionManager: function (a) {
  5497. this._actionManager != a && (this.stopAllActions(), this._actionManager = a)
  5498. },
  5499. getScheduler: function () {
  5500. this._scheduler || (this._scheduler = cc.director.getScheduler());
  5501. return this._scheduler
  5502. },
  5503. setScheduler: function (a) {
  5504. this._scheduler != a && (this.unscheduleAllCallbacks(), this._scheduler = a)
  5505. },
  5506. boundingBox: function () {
  5507. cc.log(cc._LogInfos.Node_boundingBox);
  5508. return this.getBoundingBox()
  5509. },
  5510. getBoundingBox: function () {
  5511. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  5512. return cc._rectApplyAffineTransformIn(a, this.getNodeToParentTransform())
  5513. },
  5514. cleanup: function () {
  5515. this.stopAllActions();
  5516. this.unscheduleAllCallbacks();
  5517. cc.eventManager.removeListeners(this);
  5518. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup)
  5519. },
  5520. getChildByTag: function (a) {
  5521. var b = this._children;
  5522. if (null != b) for (var c = 0; c < b.length; c++) {
  5523. var d = b[c];
  5524. if (d && d.tag == a) return d
  5525. }
  5526. return null
  5527. },
  5528. getChildByName: function (a) {
  5529. if (!a) return cc.log("Invalid name"),
  5530. null;
  5531. for (var b = this._children, c = 0, d = b.length; c < d; c++) if (b[c]._name == a) return b[c];
  5532. return null
  5533. },
  5534. addChild: function (a, b, c) {
  5535. b = void 0 === b ? a._localZOrder : b;
  5536. var d,
  5537. e = !1;
  5538. cc.isUndefined(c) ? (c = void 0, d = a._name) : cc.isString(c) ? (d = c, c = void 0) : cc.isNumber(c) && (e = !0, d = "");
  5539. cc.assert(a, cc._LogInfos.Node_addChild_3);
  5540. cc.assert(null === a._parent, "child already added. It can't be added again");
  5541. this._addChildHelper(a, b, c, d, e)
  5542. },
  5543. _addChildHelper: function (a, b, c, d, e) {
  5544. this._children || (this._children = []);
  5545. this._insertChild(a, b);
  5546. e ? a.setTag(c) : a.setName(d);
  5547. a.setParent(this);
  5548. a.setOrderOfArrival(cc.s_globalOrderOfArrival++);
  5549. if (this._running && (a.onEnter(), this._isTransitionFinished)) a.onEnterTransitionDidFinish();
  5550. this._cascadeColorEnabled && this._enableCascadeColor();
  5551. this._cascadeOpacityEnabled && this._enableCascadeOpacity()
  5552. },
  5553. removeFromParent: function (a) {
  5554. this._parent && (null == a && (a = !0), this._parent.removeChild(this, a))
  5555. },
  5556. removeFromParentAndCleanup: function (a) {
  5557. cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
  5558. this.removeFromParent(a)
  5559. },
  5560. removeChild: function (a, b) {
  5561. 0 !== this._children.length && (null == b && (b = !0), -1 < this._children.indexOf(a) && this._detachChild(a, b), this.setNodeDirty())
  5562. },
  5563. removeChildByTag: function (a, b) {
  5564. a === cc.NODE_TAG_INVALID && cc.log(cc._LogInfos.Node_removeChildByTag);
  5565. var c = this.getChildByTag(a);
  5566. null == c ? cc.log(cc._LogInfos.Node_removeChildByTag_2, a) : this.removeChild(c, b)
  5567. },
  5568. removeAllChildrenWithCleanup: function (a) {
  5569. this.removeAllChildren(a)
  5570. },
  5571. removeAllChildren: function (a) {
  5572. var b = this._children;
  5573. if (null != b) {
  5574. null == a && (a = !0);
  5575. for (var c = 0; c < b.length; c++) {
  5576. var d = b[c];
  5577. d && (this._running && (d.onExitTransitionDidStart(), d.onExit()), a && d.cleanup(), d.parent = null)
  5578. }
  5579. this._children.length = 0
  5580. }
  5581. },
  5582. _detachChild: function (a, b) {
  5583. this._running && (a.onExitTransitionDidStart(), a.onExit());
  5584. b && a.cleanup();
  5585. a.parent = null;
  5586. cc.arrayRemoveObject(this._children, a)
  5587. },
  5588. _insertChild: function (a, b) {
  5589. this._reorderChildDirty = !0;
  5590. this._children.push(a);
  5591. a._setLocalZOrder(b)
  5592. },
  5593. reorderChild: function (a, b) {
  5594. cc.assert(a, cc._LogInfos.Node_reorderChild);
  5595. this._reorderChildDirty = !0;
  5596. a.arrivalOrder = cc.s_globalOrderOfArrival;
  5597. cc.s_globalOrderOfArrival++;
  5598. a._setLocalZOrder(b);
  5599. this.setNodeDirty()
  5600. },
  5601. sortAllChildren: function () {
  5602. if (this._reorderChildDirty) {
  5603. var a = this._children,
  5604. b = a.length,
  5605. c,
  5606. d,
  5607. e;
  5608. for (c = 1; c < b; c++) {
  5609. e = a[c];
  5610. for (d = c - 1; 0 <= d;) {
  5611. if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d];
  5612. else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d];
  5613. else break;
  5614. d--
  5615. }
  5616. a[d + 1] = e
  5617. }
  5618. this._reorderChildDirty = !1
  5619. }
  5620. },
  5621. draw: function (a) { },
  5622. transformAncestors: function () {
  5623. null != this._parent && (this._parent.transformAncestors(), this._parent.transform())
  5624. },
  5625. onEnter: function () {
  5626. this._isTransitionFinished = !1;
  5627. this._running = !0;
  5628. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnter);
  5629. this.resume()
  5630. },
  5631. onEnterTransitionDidFinish: function () {
  5632. this._isTransitionFinished = !0;
  5633. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnterTransitionDidFinish)
  5634. },
  5635. onExitTransitionDidStart: function () {
  5636. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExitTransitionDidStart)
  5637. },
  5638. onExit: function () {
  5639. this._running = !1;
  5640. this.pause();
  5641. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit);
  5642. this.removeAllComponents()
  5643. },
  5644. runAction: function (a) {
  5645. cc.assert(a, cc._LogInfos.Node_runAction);
  5646. this.actionManager.addAction(a, this, !this._running);
  5647. return a
  5648. },
  5649. stopAllActions: function () {
  5650. this.actionManager && this.actionManager.removeAllActionsFromTarget(this)
  5651. },
  5652. stopAction: function (a) {
  5653. this.actionManager.removeAction(a)
  5654. },
  5655. stopActionByTag: function (a) {
  5656. a === cc.ACTION_TAG_INVALID ? cc.log(cc._LogInfos.Node_stopActionByTag) : this.actionManager.removeActionByTag(a, this)
  5657. },
  5658. getActionByTag: function (a) {
  5659. return a === cc.ACTION_TAG_INVALID ? (cc.log(cc._LogInfos.Node_getActionByTag), null) : this.actionManager.getActionByTag(a, this)
  5660. },
  5661. getNumberOfRunningActions: function () {
  5662. return this.actionManager.numberOfRunningActionsInTarget(this)
  5663. },
  5664. scheduleUpdate: function () {
  5665. this.scheduleUpdateWithPriority(0)
  5666. },
  5667. scheduleUpdateWithPriority: function (a) {
  5668. this.scheduler.scheduleUpdateForTarget(this, a, !this._running)
  5669. },
  5670. unscheduleUpdate: function () {
  5671. this.scheduler.unscheduleUpdateForTarget(this)
  5672. },
  5673. schedule: function (a, b, c, d) {
  5674. b = b || 0;
  5675. cc.assert(a, cc._LogInfos.Node_schedule);
  5676. cc.assert(0 <= b, cc._LogInfos.Node_schedule_2);
  5677. c = null == c ? cc.REPEAT_FOREVER : c;
  5678. this.scheduler.scheduleCallbackForTarget(this, a, b, c, d || 0, !this._running)
  5679. },
  5680. scheduleOnce: function (a, b) {
  5681. this.schedule(a, 0, 0, b)
  5682. },
  5683. unschedule: function (a) {
  5684. a && this.scheduler.unscheduleCallbackForTarget(this, a)
  5685. },
  5686. unscheduleAllCallbacks: function () {
  5687. this.scheduler.unscheduleAllCallbacksForTarget(this)
  5688. },
  5689. resumeSchedulerAndActions: function () {
  5690. cc.log(cc._LogInfos.Node_resumeSchedulerAndActions);
  5691. this.resume()
  5692. },
  5693. resume: function () {
  5694. this.scheduler.resumeTarget(this);
  5695. this.actionManager && this.actionManager.resumeTarget(this);
  5696. cc.eventManager.resumeTarget(this)
  5697. },
  5698. pauseSchedulerAndActions: function () {
  5699. cc.log(cc._LogInfos.Node_pauseSchedulerAndActions);
  5700. this.pause()
  5701. },
  5702. pause: function () {
  5703. this.scheduler.pauseTarget(this);
  5704. this.actionManager && this.actionManager.pauseTarget(this);
  5705. cc.eventManager.pauseTarget(this)
  5706. },
  5707. setAdditionalTransform: function (a) {
  5708. this._additionalTransform = a;
  5709. this._additionalTransformDirty = this._transformDirty = !0
  5710. },
  5711. getParentToNodeTransform: function () {
  5712. this._inverseDirty && (this._inverse = cc.affineTransformInvert(this.getNodeToParentTransform()), this._inverseDirty = !1);
  5713. return this._inverse
  5714. },
  5715. parentToNodeTransform: function () {
  5716. return this.getParentToNodeTransform()
  5717. },
  5718. getNodeToWorldTransform: function () {
  5719. for (var a = this.getNodeToParentTransform(), b = this._parent; null != b; b = b.parent) a = cc.affineTransformConcat(a, b.getNodeToParentTransform());
  5720. return a
  5721. },
  5722. nodeToWorldTransform: function () {
  5723. return this.getNodeToWorldTransform()
  5724. },
  5725. getWorldToNodeTransform: function () {
  5726. return cc.affineTransformInvert(this.getNodeToWorldTransform())
  5727. },
  5728. worldToNodeTransform: function () {
  5729. return this.getWorldToNodeTransform()
  5730. },
  5731. convertToNodeSpace: function (a) {
  5732. return cc.pointApplyAffineTransform(a, this.getWorldToNodeTransform())
  5733. },
  5734. convertToWorldSpace: function (a) {
  5735. a = a || cc.p(0, 0);
  5736. return cc.pointApplyAffineTransform(a, this.getNodeToWorldTransform())
  5737. },
  5738. convertToNodeSpaceAR: function (a) {
  5739. return cc.pSub(this.convertToNodeSpace(a), this._anchorPointInPoints)
  5740. },
  5741. convertToWorldSpaceAR: function (a) {
  5742. a = a || cc.p(0, 0);
  5743. a = cc.pAdd(a, this._anchorPointInPoints);
  5744. return this.convertToWorldSpace(a)
  5745. },
  5746. _convertToWindowSpace: function (a) {
  5747. a = this.convertToWorldSpace(a);
  5748. return cc.director.convertToUI(a)
  5749. },
  5750. convertTouchToNodeSpace: function (a) {
  5751. a = a.getLocation();
  5752. return this.convertToNodeSpace(a)
  5753. },
  5754. convertTouchToNodeSpaceAR: function (a) {
  5755. a = a.getLocation();
  5756. a = cc.director.convertToGL(a);
  5757. return this.convertToNodeSpaceAR(a)
  5758. },
  5759. update: function (a) {
  5760. this._componentContainer && !this._componentContainer.isEmpty() && this._componentContainer.visit(a)
  5761. },
  5762. updateTransform: function () {
  5763. this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform)
  5764. },
  5765. retain: function () { },
  5766. release: function () { },
  5767. getComponent: function (a) {
  5768. return this._componentContainer ? this._componentContainer.getComponent(a) : null
  5769. },
  5770. addComponent: function (a) {
  5771. this._componentContainer && this._componentContainer.add(a)
  5772. },
  5773. removeComponent: function (a) {
  5774. return this._componentContainer ? this._componentContainer.remove(a) : !1
  5775. },
  5776. removeAllComponents: function () {
  5777. this._componentContainer && this._componentContainer.removeAll()
  5778. },
  5779. grid: null,
  5780. ctor: null,
  5781. visit: null,
  5782. transform: null,
  5783. nodeToParentTransform: function () {
  5784. return this.getNodeToParentTransform()
  5785. },
  5786. getNodeToParentTransform: null,
  5787. _setNodeDirtyForCache: function () {
  5788. if (!1 === this._cacheDirty) {
  5789. this._cacheDirty = !0;
  5790. var a = this._cachedParent;
  5791. a && a != this && a._setNodeDirtyForCache()
  5792. }
  5793. },
  5794. _setCachedParent: function (a) {
  5795. if (this._cachedParent != a) {
  5796. this._cachedParent = a;
  5797. for (var b = this._children, c = 0, d = b.length; c < d; c++) b[c]._setCachedParent(a)
  5798. }
  5799. },
  5800. getCamera: function () {
  5801. this._camera || (this._camera = new cc.Camera);
  5802. return this._camera
  5803. },
  5804. getGrid: function () {
  5805. return this.grid
  5806. },
  5807. setGrid: function (a) {
  5808. this.grid = a
  5809. },
  5810. getShaderProgram: function () {
  5811. return this._shaderProgram
  5812. },
  5813. setShaderProgram: function (a) {
  5814. this._shaderProgram = a
  5815. },
  5816. getGLServerState: function () {
  5817. return this._glServerState
  5818. },
  5819. setGLServerState: function (a) {
  5820. this._glServerState = a
  5821. },
  5822. getBoundingBoxToWorld: function () {
  5823. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
  5824. b = this.getNodeToWorldTransform(),
  5825. a = cc.rectApplyAffineTransform(a, this.getNodeToWorldTransform());
  5826. if (!this._children) return a;
  5827. for (var c = this._children, d = 0; d < c.length; d++) {
  5828. var e = c[d];
  5829. e && e._visible && (e = e._getBoundingBoxToCurrentNode(b)) && (a = cc.rectUnion(a, e))
  5830. }
  5831. return a
  5832. },
  5833. _getBoundingBoxToCurrentNode: function (a) {
  5834. var b = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
  5835. a = null == a ? this.getNodeToParentTransform() : cc.affineTransformConcat(this.getNodeToParentTransform(), a);
  5836. b = cc.rectApplyAffineTransform(b, a);
  5837. if (!this._children) return b;
  5838. for (var c = this._children, d = 0; d < c.length; d++) {
  5839. var e = c[d];
  5840. e && e._visible && (e = e._getBoundingBoxToCurrentNode(a)) && (b = cc.rectUnion(b, e))
  5841. }
  5842. return b
  5843. },
  5844. _getNodeToParentTransformForWebGL: function () {
  5845. if (this._transformDirty) {
  5846. var a = this._position.x,
  5847. b = this._position.y,
  5848. c = this._anchorPointInPoints.x,
  5849. d = -c,
  5850. e = this._anchorPointInPoints.y,
  5851. f = -e,
  5852. g = this._scaleX,
  5853. h = this._scaleY;
  5854. this._ignoreAnchorPointForPosition && (a += c, b += e);
  5855. var k = 1,
  5856. m = 0,
  5857. n = 1,
  5858. q = 0;
  5859. if (0 !== this._rotationX || 0 !== this._rotationY) k = Math.cos(-this._rotationRadiansX),
  5860. m = Math.sin(-this._rotationRadiansX),
  5861. n = Math.cos(-this._rotationRadiansY),
  5862. q = Math.sin(-this._rotationRadiansY);
  5863. var r = this._skewX || this._skewY;
  5864. r || 0 === c && 0 === e || (a += n * d * g + -m * f * h, b += q * d * g + k * f * h);
  5865. var s = this._transform;
  5866. s.a = n * g;
  5867. s.b = q * g;
  5868. s.c = -m * h;
  5869. s.d = k * h;
  5870. s.tx = a;
  5871. s.ty = b;
  5872. r && (s = cc.affineTransformConcat({
  5873. a: 1,
  5874. b: Math.tan(cc.degreesToRadians(this._skewY)),
  5875. c: Math.tan(cc.degreesToRadians(this._skewX)),
  5876. d: 1,
  5877. tx: 0,
  5878. ty: 0
  5879. },
  5880. s), 0 !== c || 0 !== e) && (s = cc.affineTransformTranslate(s, d, f));
  5881. this._additionalTransformDirty && (s = cc.affineTransformConcat(s, this._additionalTransform), this._additionalTransformDirty = !1);
  5882. this._transform = s;
  5883. this._transformDirty = !1
  5884. }
  5885. return this._transform
  5886. },
  5887. _updateColor: function () { },
  5888. getOpacity: function () {
  5889. return this._realOpacity
  5890. },
  5891. getDisplayedOpacity: function () {
  5892. return this._displayedOpacity
  5893. },
  5894. setOpacity: function (a) {
  5895. this._displayedOpacity = this._realOpacity = a;
  5896. var b = 255,
  5897. c = this._parent;
  5898. c && c.cascadeOpacity && (b = c.getDisplayedOpacity());
  5899. this.updateDisplayedOpacity(b);
  5900. this._displayedColor.a = this._realColor.a = a
  5901. },
  5902. updateDisplayedOpacity: function (a) {
  5903. this._displayedOpacity = this._realOpacity * a / 255;
  5904. if (this._cascadeOpacityEnabled) {
  5905. a = this._children;
  5906. for (var b = 0; b < a.length; b++) {
  5907. var c = a[b];
  5908. c && c.updateDisplayedOpacity(this._displayedOpacity)
  5909. }
  5910. }
  5911. },
  5912. isCascadeOpacityEnabled: function () {
  5913. return this._cascadeOpacityEnabled
  5914. },
  5915. setCascadeOpacityEnabled: function (a) {
  5916. this._cascadeOpacityEnabled !== a && ((this._cascadeOpacityEnabled = a) ? this._enableCascadeOpacity() : this._disableCascadeOpacity())
  5917. },
  5918. _enableCascadeOpacity: function () {
  5919. var a = 255,
  5920. b = this._parent;
  5921. b && b.cascadeOpacity && (a = b.getDisplayedOpacity());
  5922. this.updateDisplayedOpacity(a)
  5923. },
  5924. _disableCascadeOpacity: function () {
  5925. this._displayedOpacity = this._realOpacity;
  5926. for (var a = this._children, b = 0; b < a.length; b++) {
  5927. var c = a[b];
  5928. c && c.updateDisplayedOpacity(255)
  5929. }
  5930. },
  5931. getColor: function () {
  5932. var a = this._realColor;
  5933. return cc.color(a.r, a.g, a.b, a.a)
  5934. },
  5935. getDisplayedColor: function () {
  5936. var a = this._displayedColor;
  5937. return cc.color(a.r, a.g, a.b, a.a)
  5938. },
  5939. setColor: function (a) {
  5940. var b = this._displayedColor,
  5941. c = this._realColor;
  5942. b.r = c.r = a.r;
  5943. b.g = c.g = a.g;
  5944. b.b = c.b = a.b;
  5945. a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
  5946. this.updateDisplayedColor(a)
  5947. },
  5948. updateDisplayedColor: function (a) {
  5949. var b = this._displayedColor,
  5950. c = this._realColor;
  5951. b.r = 0 | c.r * a.r / 255;
  5952. b.g = 0 | c.g * a.g / 255;
  5953. b.b = 0 | c.b * a.b / 255;
  5954. if (this._cascadeColorEnabled) for (a = this._children, c = 0; c < a.length; c++) {
  5955. var d = a[c];
  5956. d && d.updateDisplayedColor(b)
  5957. }
  5958. },
  5959. isCascadeColorEnabled: function () {
  5960. return this._cascadeColorEnabled
  5961. },
  5962. setCascadeColorEnabled: function (a) {
  5963. this._cascadeColorEnabled !== a && ((this._cascadeColorEnabled = a) ? this._enableCascadeColor() : this._disableCascadeColor())
  5964. },
  5965. _enableCascadeColor: function () {
  5966. var a;
  5967. a = (a = this._parent) && a.cascadeColor ? a.getDisplayedColor() : cc.color.WHITE;
  5968. this.updateDisplayedColor(a)
  5969. },
  5970. _disableCascadeColor: function () {
  5971. var a = this._displayedColor,
  5972. b = this._realColor;
  5973. a.r = b.r;
  5974. a.g = b.g;
  5975. a.b = b.b;
  5976. for (var a = this._children, b = cc.color.WHITE, c = 0; c < a.length; c++) {
  5977. var d = a[c];
  5978. d && d.updateDisplayedColor(b)
  5979. }
  5980. },
  5981. setOpacityModifyRGB: function (a) { },
  5982. isOpacityModifyRGB: function () {
  5983. return !1
  5984. }
  5985. });
  5986. cc.Node.create = function () {
  5987. return new cc.Node
  5988. };
  5989. cc.Node._StateCallbackType = {
  5990. onEnter: 1,
  5991. onExit: 2,
  5992. cleanup: 3,
  5993. onEnterTransitionDidFinish: 4,
  5994. updateTransform: 5,
  5995. onExitTransitionDidStart: 6,
  5996. sortAllChildren: 7
  5997. };
  5998. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Node.prototype, _p.ctor = function () {
  5999. this._initNode()
  6000. },
  6001. _p.setNodeDirty = function () {
  6002. this._setNodeDirtyForCache(); !1 === this._transformDirty && (this._transformDirty = this._inverseDirty = !0)
  6003. },
  6004. _p.visit = function (a) {
  6005. if (this._visible) {
  6006. a = a || cc._renderContext;
  6007. var b,
  6008. c = this._children,
  6009. d;
  6010. a.save();
  6011. this.transform(a);
  6012. var e = c.length;
  6013. if (0 < e) {
  6014. this.sortAllChildren();
  6015. for (b = 0; b < e; b++) if (d = c[b], 0 > d._localZOrder) d.visit(a);
  6016. else break;
  6017. for (this.draw(a) ; b < e; b++) c[b].visit(a)
  6018. } else this.draw(a);
  6019. this._cacheDirty = !1;
  6020. this.arrivalOrder = 0;
  6021. a.restore()
  6022. }
  6023. },
  6024. _p.transform = function (a) {
  6025. a = a || cc._renderContext;
  6026. var b = cc.view,
  6027. c = this.getNodeToParentTransform();
  6028. a.transform(c.a, c.c, c.b, c.d, c.tx * b.getScaleX(), -c.ty * b.getScaleY())
  6029. },
  6030. _p.getNodeToParentTransform = function () {
  6031. if (this._transformDirty) {
  6032. var a = this._transform;
  6033. a.tx = this._position.x;
  6034. a.ty = this._position.y;
  6035. var b = 1,
  6036. c = 0;
  6037. this._rotationX && (b = Math.cos(this._rotationRadiansX), c = Math.sin(this._rotationRadiansX));
  6038. a.a = a.d = b;
  6039. a.b = -c;
  6040. a.c = c;
  6041. var d = this._scaleX,
  6042. e = this._scaleY,
  6043. f = this._anchorPointInPoints.x,
  6044. g = this._anchorPointInPoints.y,
  6045. h = 1E-6 > d && -1E-6 < d ? 1E-6 : d,
  6046. k = 1E-6 > e && -1E-6 < e ? 1E-6 : e;
  6047. if (this._skewX || this._skewY) {
  6048. var m = Math.tan(-this._skewX * Math.PI / 180),
  6049. n = Math.tan(-this._skewY * Math.PI / 180);
  6050. Infinity === m && (m = 99999999);
  6051. Infinity === n && (n = 99999999);
  6052. var q = g * m * h,
  6053. r = f * n * k;
  6054. a.a = b + -c * n;
  6055. a.b = b * m + -c;
  6056. a.c = c + b * n;
  6057. a.d = c * m + b;
  6058. a.tx += b * q + -c * r;
  6059. a.ty += c * q + b * r
  6060. }
  6061. if (1 !== d || 1 !== e) a.a *= h,
  6062. a.c *= h,
  6063. a.b *= k,
  6064. a.d *= k;
  6065. a.tx += b * -f * h + -c * g * k;
  6066. a.ty -= c * -f * h + b * g * k;
  6067. this._ignoreAnchorPointForPosition && (a.tx += f, a.ty += g);
  6068. this._additionalTransformDirty && (this._transform = cc.affineTransformConcat(a, this._additionalTransform), this._additionalTransformDirty = !1);
  6069. this._transformDirty = !1
  6070. }
  6071. return this._transform
  6072. },
  6073. _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLCCNode), cc._LogInfos.MissingFile, "BaseNodesWebGL.js"), cc._tmp.WebGLCCNode(), delete cc._tmp.WebGLCCNode);
  6074. cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode), cc._LogInfos.MissingFile, "BaseNodesPropertyDefine.js");
  6075. cc._tmp.PrototypeCCNode();
  6076. delete cc._tmp.PrototypeCCNode;
  6077. cc.AtlasNode = cc.Node.extend({
  6078. textureAtlas: null,
  6079. quadsToDraw: 0,
  6080. _itemsPerRow: 0,
  6081. _itemsPerColumn: 0,
  6082. _itemWidth: 0,
  6083. _itemHeight: 0,
  6084. _colorUnmodified: null,
  6085. _opacityModifyRGB: !1,
  6086. _blendFunc: null,
  6087. _ignoreContentScaleFactor: !1,
  6088. _className: "AtlasNode",
  6089. ctor: function (a, b, c, d) {
  6090. cc.Node.prototype.ctor.call(this);
  6091. this._colorUnmodified = cc.color.WHITE;
  6092. this._blendFunc = {
  6093. src: cc.BLEND_SRC,
  6094. dst: cc.BLEND_DST
  6095. };
  6096. this._ignoreContentScaleFactor = !1;
  6097. void 0 !== d && this.initWithTileFile(a, b, c, d)
  6098. },
  6099. updateAtlasValues: function () {
  6100. cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)
  6101. },
  6102. getColor: function () {
  6103. return this._opacityModifyRGB ? this._colorUnmodified : cc.Node.prototype.getColor.call(this)
  6104. },
  6105. setOpacityModifyRGB: function (a) {
  6106. var b = this.color;
  6107. this._opacityModifyRGB = a;
  6108. this.color = b
  6109. },
  6110. isOpacityModifyRGB: function () {
  6111. return this._opacityModifyRGB
  6112. },
  6113. getBlendFunc: function () {
  6114. return this._blendFunc
  6115. },
  6116. setBlendFunc: function (a, b) {
  6117. this._blendFunc = void 0 === b ? a : {
  6118. src: a,
  6119. dst: b
  6120. }
  6121. },
  6122. setTextureAtlas: function (a) {
  6123. this.textureAtlas = a
  6124. },
  6125. getTextureAtlas: function () {
  6126. return this.textureAtlas
  6127. },
  6128. getQuadsToDraw: function () {
  6129. return this.quadsToDraw
  6130. },
  6131. setQuadsToDraw: function (a) {
  6132. this.quadsToDraw = a
  6133. },
  6134. _textureForCanvas: null,
  6135. _originalTexture: null,
  6136. _uniformColor: null,
  6137. _colorF32Array: null,
  6138. initWithTileFile: function (a, b, c, d) {
  6139. if (!a) throw "cc.AtlasNode.initWithTileFile(): title should not be null";
  6140. a = cc.textureCache.addImage(a);
  6141. return this.initWithTexture(a, b, c, d)
  6142. },
  6143. initWithTexture: null,
  6144. _initWithTextureForCanvas: function (a, b, c, d) {
  6145. this._itemWidth = b;
  6146. this._itemHeight = c;
  6147. this._opacityModifyRGB = !0;
  6148. this._originalTexture = a;
  6149. if (!this._originalTexture) return cc.log(cc._LogInfos.AtlasNode__initWithTexture),
  6150. !1;
  6151. this._textureForCanvas = this._originalTexture;
  6152. this._calculateMaxItems();
  6153. this.quadsToDraw = d;
  6154. return !0
  6155. },
  6156. _initWithTextureForWebGL: function (a, b, c, d) {
  6157. this._itemWidth = b;
  6158. this._itemHeight = c;
  6159. this._colorUnmodified = cc.color.WHITE;
  6160. this._opacityModifyRGB = !0;
  6161. this._blendFunc.src = cc.BLEND_SRC;
  6162. this._blendFunc.dst = cc.BLEND_DST;
  6163. b = this._realColor;
  6164. this._colorF32Array = new Float32Array([b.r / 255, b.g / 255, b.b / 255, this._realOpacity / 255]);
  6165. this.textureAtlas = new cc.TextureAtlas;
  6166. this.textureAtlas.initWithTexture(a, d);
  6167. if (!this.textureAtlas) return cc.log(cc._LogInfos.AtlasNode__initWithTexture),
  6168. !1;
  6169. this._updateBlendFunc();
  6170. this._updateOpacityModifyRGB();
  6171. this._calculateMaxItems();
  6172. this.quadsToDraw = d;
  6173. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  6174. this._uniformColor = cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(), "u_color");
  6175. return !0
  6176. },
  6177. draw: null,
  6178. _drawForWebGL: function (a) {
  6179. a = a || cc._renderContext;
  6180. cc.nodeDrawSetup(this);
  6181. cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
  6182. this._uniformColor && this._colorF32Array && (a.uniform4fv(this._uniformColor, this._colorF32Array), this.textureAtlas.drawNumberOfQuads(this.quadsToDraw, 0))
  6183. },
  6184. setColor: null,
  6185. _setColorForCanvas: function (a) {
  6186. var b = this._realColor;
  6187. if (b.r != a.r || b.g != a.g || b.b != a.b) {
  6188. b = cc.color(a.r, a.g, a.b);
  6189. this._colorUnmodified = a;
  6190. if (this._opacityModifyRGB) {
  6191. var c = this._displayedOpacity;
  6192. b.r = b.r * c / 255;
  6193. b.g = b.g * c / 255;
  6194. b.b = b.b * c / 255
  6195. }
  6196. cc.Node.prototype.setColor.call(this, a);
  6197. this._changeTextureColor()
  6198. }
  6199. },
  6200. _changeTextureColor: function () {
  6201. var a = this.getTexture();
  6202. if (a && this._originalTexture) {
  6203. var b = this._originalTexture.getHtmlElementObj();
  6204. if (b) {
  6205. var c = a.getHtmlElementObj(),
  6206. a = cc.rect(0, 0, b.width, b.height);
  6207. c instanceof HTMLCanvasElement ? cc.generateTintImageWithMultiply(b, this._displayedColor, a, c) : (c = cc.generateTintImageWithMultiply(b, this._displayedColor, a), a = new cc.Texture2D, a.initWithElement(c), a.handleLoadedTexture(), this.setTexture(a))
  6208. }
  6209. }
  6210. },
  6211. _setColorForWebGL: function (a) {
  6212. var b = cc.color(a.r, a.g, a.b);
  6213. this._colorUnmodified = a;
  6214. var c = this._displayedOpacity;
  6215. this._opacityModifyRGB && (b.r = b.r * c / 255, b.g = b.g * c / 255, b.b = b.b * c / 255);
  6216. cc.Node.prototype.setColor.call(this, a);
  6217. a = this._displayedColor;
  6218. this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, c / 255])
  6219. },
  6220. setOpacity: function (a) { },
  6221. _setOpacityForCanvas: function (a) {
  6222. cc.Node.prototype.setOpacity.call(this, a);
  6223. this._opacityModifyRGB && (this.color = this._colorUnmodified)
  6224. },
  6225. _setOpacityForWebGL: function (a) {
  6226. cc.Node.prototype.setOpacity.call(this, a);
  6227. this._opacityModifyRGB ? this.color = this._colorUnmodified : (a = this._displayedColor, this._colorF32Array = new Float32Array([a.r / 255, a.g / 255, a.b / 255, this._displayedOpacity / 255]))
  6228. },
  6229. getTexture: null,
  6230. _getTextureForCanvas: function () {
  6231. return this._textureForCanvas
  6232. },
  6233. _getTextureForWebGL: function () {
  6234. return this.textureAtlas.texture
  6235. },
  6236. setTexture: null,
  6237. _setTextureForCanvas: function (a) {
  6238. this._textureForCanvas = a
  6239. },
  6240. _setTextureForWebGL: function (a) {
  6241. this.textureAtlas.texture = a;
  6242. this._updateBlendFunc();
  6243. this._updateOpacityModifyRGB()
  6244. },
  6245. _calculateMaxItems: null,
  6246. _calculateMaxItemsForCanvas: function () {
  6247. var a = this.texture.getContentSize();
  6248. this._itemsPerColumn = 0 | a.height / this._itemHeight;
  6249. this._itemsPerRow = 0 | a.width / this._itemWidth
  6250. },
  6251. _calculateMaxItemsForWebGL: function () {
  6252. var a = this.texture,
  6253. b = a.getContentSize();
  6254. this._ignoreContentScaleFactor && (b = a.getContentSizeInPixels());
  6255. this._itemsPerColumn = 0 | b.height / this._itemHeight;
  6256. this._itemsPerRow = 0 | b.width / this._itemWidth
  6257. },
  6258. _updateBlendFunc: function () {
  6259. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  6260. },
  6261. _updateOpacityModifyRGB: function () {
  6262. this._opacityModifyRGB = this.textureAtlas.texture.hasPremultipliedAlpha()
  6263. },
  6264. _setIgnoreContentScaleFactor: function (a) {
  6265. this._ignoreContentScaleFactor = a
  6266. }
  6267. });
  6268. _p = cc.AtlasNode.prototype;
  6269. cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.initWithTexture = _p._initWithTextureForWebGL, _p.draw = _p._drawForWebGL, _p.setColor = _p._setColorForWebGL, _p.setOpacity = _p._setOpacityForWebGL, _p.getTexture = _p._getTextureForWebGL, _p.setTexture = _p._setTextureForWebGL, _p._calculateMaxItems = _p._calculateMaxItemsForWebGL) : (_p.initWithTexture = _p._initWithTextureForCanvas, _p.draw = cc.Node.prototype.draw, _p.setColor = _p._setColorForCanvas, _p.setOpacity = _p._setOpacityForCanvas, _p.getTexture = _p._getTextureForCanvas, _p.setTexture = _p._setTextureForCanvas, _p._calculateMaxItems = _p._calculateMaxItemsForCanvas, cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function () {
  6270. var a,
  6271. b = this.getTexture();
  6272. if (b && this._originalTexture && (a = b.getHtmlElementObj())) {
  6273. var c = this._originalTexture.getHtmlElementObj();
  6274. if (b = cc.textureCache.getTextureColors(c)) c = cc.rect(0, 0, c.width, c.height),
  6275. a instanceof HTMLCanvasElement ? cc.generateTintImage(a, b, this._displayedColor, c, a) : (a = cc.generateTintImage(a, b, this._displayedColor, c), b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.setTexture(b))
  6276. }
  6277. }));
  6278. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  6279. cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor);
  6280. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  6281. cc.AtlasNode.create = function (a, b, c, d) {
  6282. return new cc.AtlasNode(a, b, c, d)
  6283. };
  6284. cc._tmp.WebGLTexture2D = function () {
  6285. cc.Texture2D = cc.Class.extend({
  6286. _pVRHaveAlphaPremultiplied: !0,
  6287. _pixelFormat: null,
  6288. _pixelsWide: 0,
  6289. _pixelsHigh: 0,
  6290. _name: "",
  6291. _contentSize: null,
  6292. maxS: 0,
  6293. maxT: 0,
  6294. _hasPremultipliedAlpha: !1,
  6295. _hasMipmaps: !1,
  6296. shaderProgram: null,
  6297. _isLoaded: !1,
  6298. _htmlElementObj: null,
  6299. _webTextureObj: null,
  6300. url: null,
  6301. _loadedEventListeners: null,
  6302. ctor: function () {
  6303. this._contentSize = cc.size(0, 0);
  6304. this._pixelFormat = cc.Texture2D.defaultPixelFormat
  6305. },
  6306. releaseTexture: function () {
  6307. this._webTextureObj && cc._renderContext.deleteTexture(this._webTextureObj);
  6308. cc.loader.release(this.url)
  6309. },
  6310. getPixelFormat: function () {
  6311. return this._pixelFormat
  6312. },
  6313. getPixelsWide: function () {
  6314. return this._pixelsWide
  6315. },
  6316. getPixelsHigh: function () {
  6317. return this._pixelsHigh
  6318. },
  6319. getName: function () {
  6320. return this._webTextureObj
  6321. },
  6322. getContentSize: function () {
  6323. return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor())
  6324. },
  6325. _getWidth: function () {
  6326. return this._contentSize.width / cc.contentScaleFactor()
  6327. },
  6328. _getHeight: function () {
  6329. return this._contentSize.height / cc.contentScaleFactor()
  6330. },
  6331. getContentSizeInPixels: function () {
  6332. return this._contentSize
  6333. },
  6334. getMaxS: function () {
  6335. return this.maxS
  6336. },
  6337. setMaxS: function (a) {
  6338. this.maxS = a
  6339. },
  6340. getMaxT: function () {
  6341. return this.maxT
  6342. },
  6343. setMaxT: function (a) {
  6344. this.maxT = a
  6345. },
  6346. getShaderProgram: function () {
  6347. return this.shaderProgram
  6348. },
  6349. setShaderProgram: function (a) {
  6350. this.shaderProgram = a
  6351. },
  6352. hasPremultipliedAlpha: function () {
  6353. return this._hasPremultipliedAlpha
  6354. },
  6355. hasMipmaps: function () {
  6356. return this._hasMipmaps
  6357. },
  6358. description: function () {
  6359. return "\x3ccc.Texture2D | Name \x3d " + this._name + " | Dimensions \x3d " +
  6360. this._pixelsWide + " x " + this._pixelsHigh + " | Coordinates \x3d (" + this.maxS + ", " + this.maxT + ")\x3e"
  6361. },
  6362. releaseData: function (a) { },
  6363. keepData: function (a, b) {
  6364. return a
  6365. },
  6366. initWithData: function (a, b, c, d, e) {
  6367. var f = cc.Texture2D,
  6368. g = cc._renderContext,
  6369. h = g.RGBA,
  6370. k = g.UNSIGNED_BYTE,
  6371. m = c * cc.Texture2D._B[b] / 8;
  6372. 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);
  6373. this._webTextureObj = g.createTexture();
  6374. cc.glBindTexture2D(this);
  6375. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MIN_FILTER, g.LINEAR);
  6376. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_MAG_FILTER, g.LINEAR);
  6377. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE);
  6378. g.texParameteri(g.TEXTURE_2D, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE);
  6379. switch (b) {
  6380. case f.PIXEL_FORMAT_RGBA8888:
  6381. h = g.RGBA;
  6382. break;
  6383. case f.PIXEL_FORMAT_RGB888:
  6384. h = g.RGB;
  6385. break;
  6386. case f.PIXEL_FORMAT_RGBA4444:
  6387. k = g.UNSIGNED_SHORT_4_4_4_4;
  6388. break;
  6389. case f.PIXEL_FORMAT_RGB5A1:
  6390. k = g.UNSIGNED_SHORT_5_5_5_1;
  6391. break;
  6392. case f.PIXEL_FORMAT_RGB565:
  6393. k = g.UNSIGNED_SHORT_5_6_5;
  6394. break;
  6395. case f.PIXEL_FORMAT_AI88:
  6396. h = g.LUMINANCE_ALPHA;
  6397. break;
  6398. case f.PIXEL_FORMAT_A8:
  6399. h = g.ALPHA;
  6400. break;
  6401. case f.PIXEL_FORMAT_I8:
  6402. h = g.LUMINANCE;
  6403. break;
  6404. default:
  6405. cc.assert(0, cc._LogInfos.Texture2D_initWithData)
  6406. }
  6407. g.texImage2D(g.TEXTURE_2D, 0, h, c, d, 0, h, k, a);
  6408. this._contentSize.width = e.width;
  6409. this._contentSize.height = e.height;
  6410. this._pixelsWide = c;
  6411. this._pixelsHigh = d;
  6412. this._pixelFormat = b;
  6413. this.maxS = e.width / c;
  6414. this.maxT = e.height / d;
  6415. this._hasMipmaps = this._hasPremultipliedAlpha = !1;
  6416. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
  6417. return this._isLoaded = !0
  6418. },
  6419. drawAtPoint: function (a) {
  6420. var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0],
  6421. c = this._pixelsWide * this.maxS,
  6422. d = this._pixelsHigh * this.maxT;
  6423. 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];
  6424. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  6425. this._shaderProgram.use();
  6426. this._shaderProgram.setUniformsForBuiltins();
  6427. cc.glBindTexture2D(this);
  6428. c = cc._renderContext;
  6429. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a);
  6430. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, b);
  6431. c.drawArrays(c.TRIANGLE_STRIP, 0, 4)
  6432. },
  6433. drawInRect: function (a) {
  6434. var b = [0, this.maxT, this.maxS, this.maxT, 0, 0, this.maxS, 0];
  6435. 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];
  6436. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
  6437. this._shaderProgram.use();
  6438. this._shaderProgram.setUniformsForBuiltins();
  6439. cc.glBindTexture2D(this);
  6440. var c = cc._renderContext;
  6441. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, a);
  6442. c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, c.FLOAT, !1, 0, b);
  6443. c.drawArrays(c.TRIANGLE_STRIP, 0, 4)
  6444. },
  6445. initWithImage: function (a) {
  6446. if (null == a) return cc.log(cc._LogInfos.Texture2D_initWithImage),
  6447. !1;
  6448. var b = a.getWidth(),
  6449. c = a.getHeight(),
  6450. d = cc.configuration.getMaxTextureSize();
  6451. if (b > d || c > d) return cc.log(cc._LogInfos.Texture2D_initWithImage_2, b, c, d, d),
  6452. !1;
  6453. this._isLoaded = !0;
  6454. return this._initPremultipliedATextureWithImage(a, b, c)
  6455. },
  6456. initWithElement: function (a) {
  6457. a && (this._webTextureObj = cc._renderContext.createTexture(), this._htmlElementObj = a)
  6458. },
  6459. getHtmlElementObj: function () {
  6460. return this._htmlElementObj
  6461. },
  6462. isLoaded: function () {
  6463. return this._isLoaded
  6464. },
  6465. handleLoadedTexture: function () {
  6466. if (cc._rendererInitialized) {
  6467. if (!this._htmlElementObj) {
  6468. var a = cc.loader.getRes(this.url);
  6469. if (!a) return;
  6470. this.initWithElement(a)
  6471. }
  6472. this._htmlElementObj.width && this._htmlElementObj.height && (this._isLoaded = !0, a = cc._renderContext, cc.glBindTexture2D(this), a.pixelStorei(a.UNPACK_ALIGNMENT, 4), a.texImage2D(a.TEXTURE_2D, 0, a.RGBA, a.RGBA, a.UNSIGNED_BYTE, this._htmlElementObj), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.LINEAR), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_S, a.CLAMP_TO_EDGE), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_WRAP_T, a.CLAMP_TO_EDGE), this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE), cc.glBindTexture2D(null), a = this._htmlElementObj.height, this._pixelsWide = this._contentSize.width = this._htmlElementObj.width, this._pixelsHigh = this._contentSize.height = a, this._pixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888, this.maxT = this.maxS = 1, this._hasMipmaps = this._hasPremultipliedAlpha = !1, this._callLoadedEventCallbacks())
  6473. }
  6474. },
  6475. initWithString: function (a, b, c, d, e, f) {
  6476. cc.log(cc._LogInfos.Texture2D_initWithString);
  6477. return null
  6478. },
  6479. initWithETCFile: function (a) {
  6480. cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
  6481. return !1
  6482. },
  6483. initWithPVRFile: function (a) {
  6484. cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);
  6485. return !1
  6486. },
  6487. initWithPVRTCData: function (a, b, c, d, e, f) {
  6488. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);
  6489. return !1
  6490. },
  6491. setTexParameters: function (a, b, c, d) {
  6492. var e = cc._renderContext;
  6493. void 0 !== b && (a = {
  6494. minFilter: a,
  6495. magFilter: b,
  6496. wrapS: c,
  6497. wrapT: d
  6498. });
  6499. 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");
  6500. cc.glBindTexture2D(this);
  6501. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, a.minFilter);
  6502. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, a.magFilter);
  6503. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, a.wrapS);
  6504. e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, a.wrapT)
  6505. },
  6506. setAntiAliasTexParameters: function () {
  6507. var a = cc._renderContext;
  6508. cc.glBindTexture2D(this);
  6509. 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);
  6510. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
  6511. },
  6512. setAliasTexParameters: function () {
  6513. var a = cc._renderContext;
  6514. cc.glBindTexture2D(this);
  6515. 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);
  6516. a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, a.NEAREST)
  6517. },
  6518. generateMipmap: function () {
  6519. cc.assert(this._pixelsWide == cc.NextPOT(this._pixelsWide) && this._pixelsHigh == cc.NextPOT(this._pixelsHigh), "Mimpap texture only works in POT textures");
  6520. cc.glBindTexture2D(this);
  6521. cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
  6522. this._hasMipmaps = !0
  6523. },
  6524. stringForFormat: function () {
  6525. return cc.Texture2D._M[this._pixelFormat]
  6526. },
  6527. bitsPerPixelForFormat: function (a) {
  6528. a = a || this._pixelFormat;
  6529. var b = cc.Texture2D._B[a];
  6530. if (null != b) return b;
  6531. cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, a);
  6532. return -1
  6533. },
  6534. _initPremultipliedATextureWithImage: function (a, b, c) {
  6535. var d = cc.Texture2D,
  6536. e = a.getData(),
  6537. f = null,
  6538. f = null,
  6539. g = a.hasAlpha(),
  6540. h = cc.size(a.getWidth(), a.getHeight()),
  6541. k = d.defaultPixelFormat,
  6542. m = a.getBitsPerComponent();
  6543. g || (8 <= m ? k = d.PIXEL_FORMAT_RGB888 : (cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage), k = d.PIXEL_FORMAT_RGB565));
  6544. var n = b * c;
  6545. if (k == d.PIXEL_FORMAT_RGB565) if (g) 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;
  6546. else 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;
  6547. else if (k == d.PIXEL_FORMAT_RGBA4444) for (e = new Uint16Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = (f[m] >> 0 & 255) >> 4 << 12 | (f[m] >> 8 & 255) >> 4 << 8 | (f[m] >> 16 & 255) >> 4 << 4 | (f[m] >> 24 & 255) >> 4 << 0;
  6548. else if (k == d.PIXEL_FORMAT_RGB5A1) 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;
  6549. else if (k == d.PIXEL_FORMAT_A8) for (e = new Uint8Array(b * c), f = a.getData(), m = 0; m < n; ++m) e[m] = f >> 24 & 255;
  6550. if (g && k == d.PIXEL_FORMAT_RGB888) for (f = a.getData(), e = new Uint8Array(b * c * 3), m = 0; m < n; ++m) e[3 * m] = f >> 0 & 255,
  6551. e[3 * m + 1] = f >> 8 & 255,
  6552. e[3 * m + 2] = f >> 16 & 255;
  6553. this.initWithData(e, k, b, c, h);
  6554. a.getData();
  6555. this._hasPremultipliedAlpha = a.isPremultipliedAlpha();
  6556. return !0
  6557. },
  6558. addLoadedEventListener: function (a, b) {
  6559. this._loadedEventListeners || (this._loadedEventListeners = []);
  6560. this._loadedEventListeners.push({
  6561. eventCallback: a,
  6562. eventTarget: b
  6563. })
  6564. },
  6565. removeLoadedEventListener: function (a) {
  6566. if (this._loadedEventListeners) for (var b = this._loadedEventListeners, c = 0; c < b.length; c++) b[c].eventTarget == a && b.splice(c, 1)
  6567. },
  6568. _callLoadedEventCallbacks: function () {
  6569. if (this._loadedEventListeners) {
  6570. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  6571. var d = a[b];
  6572. d.eventCallback.call(d.eventTarget, this)
  6573. }
  6574. a.length = 0
  6575. }
  6576. }
  6577. })
  6578. };
  6579. cc._tmp.WebGLTextureAtlas = function () {
  6580. var a = cc.TextureAtlas.prototype;
  6581. a._setupVBO = function () {
  6582. var a = cc._renderContext;
  6583. this._buffersVBO[0] = a.createBuffer();
  6584. this._buffersVBO[1] = a.createBuffer();
  6585. this._quadsWebBuffer = a.createBuffer();
  6586. this._mapBuffers()
  6587. };
  6588. a._mapBuffers = function () {
  6589. var a = cc._renderContext;
  6590. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  6591. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  6592. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  6593. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  6594. };
  6595. a.drawNumberOfQuads = function (a, c) {
  6596. c = c || 0;
  6597. if (0 !== a && this.texture && this.texture.isLoaded()) {
  6598. var d = cc._renderContext;
  6599. cc.glBindTexture2D(this.texture);
  6600. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  6601. d.bindBuffer(d.ARRAY_BUFFER, this._quadsWebBuffer);
  6602. this.dirty && d.bufferData(d.ARRAY_BUFFER, this._quadsArrayBuffer, d.DYNAMIC_DRAW);
  6603. d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, d.FLOAT, !1, 24, 0);
  6604. d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, d.UNSIGNED_BYTE, !0, 24, 12);
  6605. d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, d.FLOAT, !1, 24, 16);
  6606. this.dirty && (this.dirty = !1);
  6607. d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  6608. 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);
  6609. cc.g_NumberOfDraws++
  6610. }
  6611. }
  6612. };
  6613. cc._tmp.WebGLTextureCache = function () {
  6614. var a = cc.textureCache;
  6615. a.handleLoadedTexture = function (a) {
  6616. var c = this._textures;
  6617. cc._rendererInitialized || (c = this._loadedTexturesBefore);
  6618. var d = c[a];
  6619. d || (d = c[a] = new cc.Texture2D, d.url = a);
  6620. d.handleLoadedTexture()
  6621. };
  6622. a.addImage = function (a, c, d) {
  6623. cc.assert(a, cc._LogInfos.Texture2D_addImage_2);
  6624. var e = this._textures;
  6625. cc._rendererInitialized || (e = this._loadedTexturesBefore);
  6626. var f = e[a] || e[cc.loader._aliases[a]];
  6627. if (f) return c && c.call(d, f),
  6628. f;
  6629. cc.loader.getRes(a) || (cc.loader._checkIsImageURL(a) ? cc.loader.load(a,
  6630. function (a) {
  6631. c && c.call(d)
  6632. }) : cc.loader.loadImg(a,
  6633. function (e, h) {
  6634. if (e) return c ? c(e) : e;
  6635. cc.loader.cache[a] = h;
  6636. cc.textureCache.handleLoadedTexture(a);
  6637. c && c.call(d, f)
  6638. }));
  6639. f = e[a] = new cc.Texture2D;
  6640. f.url = a;
  6641. return f
  6642. };
  6643. delete a
  6644. };
  6645. cc._tmp.PrototypeTexture2D = function () {
  6646. var a = cc.Texture2D;
  6647. a.PVRImagesHavePremultipliedAlpha = function (a) {
  6648. cc.PVRHaveAlphaPremultiplied_ = a
  6649. };
  6650. a.PIXEL_FORMAT_RGBA8888 = 2;
  6651. a.PIXEL_FORMAT_RGB888 = 3;
  6652. a.PIXEL_FORMAT_RGB565 = 4;
  6653. a.PIXEL_FORMAT_A8 = 5;
  6654. a.PIXEL_FORMAT_I8 = 6;
  6655. a.PIXEL_FORMAT_AI88 = 7;
  6656. a.PIXEL_FORMAT_RGBA4444 = 8;
  6657. a.PIXEL_FORMAT_RGB5A1 = 7;
  6658. a.PIXEL_FORMAT_PVRTC4 = 9;
  6659. a.PIXEL_FORMAT_PVRTC2 = 10;
  6660. a.PIXEL_FORMAT_DEFAULT = a.PIXEL_FORMAT_RGBA8888;
  6661. var b = cc.Texture2D._M = {};
  6662. b[a.PIXEL_FORMAT_RGBA8888] = "RGBA8888";
  6663. b[a.PIXEL_FORMAT_RGB888] = "RGB888";
  6664. b[a.PIXEL_FORMAT_RGB565] = "RGB565";
  6665. b[a.PIXEL_FORMAT_A8] = "A8";
  6666. b[a.PIXEL_FORMAT_I8] = "I8";
  6667. b[a.PIXEL_FORMAT_AI88] = "AI88";
  6668. b[a.PIXEL_FORMAT_RGBA4444] = "RGBA4444";
  6669. b[a.PIXEL_FORMAT_RGB5A1] = "RGB5A1";
  6670. b[a.PIXEL_FORMAT_PVRTC4] = "PVRTC4";
  6671. b[a.PIXEL_FORMAT_PVRTC2] = "PVRTC2";
  6672. b = cc.Texture2D._B = {};
  6673. b[a.PIXEL_FORMAT_RGBA8888] = 32;
  6674. b[a.PIXEL_FORMAT_RGB888] = 24;
  6675. b[a.PIXEL_FORMAT_RGB565] = 16;
  6676. b[a.PIXEL_FORMAT_A8] = 8;
  6677. b[a.PIXEL_FORMAT_I8] = 8;
  6678. b[a.PIXEL_FORMAT_AI88] = 16;
  6679. b[a.PIXEL_FORMAT_RGBA4444] = 16;
  6680. b[a.PIXEL_FORMAT_RGB5A1] = 16;
  6681. b[a.PIXEL_FORMAT_PVRTC4] = 4;
  6682. b[a.PIXEL_FORMAT_PVRTC2] = 3;
  6683. b = cc.Texture2D.prototype;
  6684. cc.defineGetterSetter(b, "name", b.getName);
  6685. cc.defineGetterSetter(b, "pixelFormat", b.getPixelFormat);
  6686. cc.defineGetterSetter(b, "pixelsWidth", b.getPixelsWide);
  6687. cc.defineGetterSetter(b, "pixelsHeight", b.getPixelsHigh);
  6688. cc.defineGetterSetter(b, "width", b._getWidth);
  6689. cc.defineGetterSetter(b, "height", b._getHeight);
  6690. a.defaultPixelFormat = a.PIXEL_FORMAT_DEFAULT
  6691. };
  6692. cc._tmp.PrototypeTextureAtlas = function () {
  6693. var a = cc.TextureAtlas.prototype;
  6694. cc.defineGetterSetter(a, "totalQuads", a.getTotalQuads);
  6695. cc.defineGetterSetter(a, "capacity", a.getCapacity);
  6696. cc.defineGetterSetter(a, "quads", a.getQuads, a.setQuads)
  6697. };
  6698. cc.ALIGN_CENTER = 51;
  6699. cc.ALIGN_TOP = 19;
  6700. cc.ALIGN_TOP_RIGHT = 18;
  6701. cc.ALIGN_RIGHT = 50;
  6702. cc.ALIGN_BOTTOM_RIGHT = 34;
  6703. cc.ALIGN_BOTTOM = 35;
  6704. cc.ALIGN_BOTTOM_LEFT = 33;
  6705. cc.ALIGN_LEFT = 49;
  6706. cc.ALIGN_TOP_LEFT = 17;
  6707. cc.PVRHaveAlphaPremultiplied_ = !1;
  6708. cc._renderType === cc._RENDER_TYPE_CANVAS ? cc.Texture2D = cc.Class.extend({
  6709. _contentSize: null,
  6710. _isLoaded: !1,
  6711. _htmlElementObj: null,
  6712. _loadedEventListeners: null,
  6713. url: null,
  6714. ctor: function () {
  6715. this._contentSize = cc.size(0, 0);
  6716. this._isLoaded = !1;
  6717. this._htmlElementObj = null
  6718. },
  6719. getPixelsWide: function () {
  6720. return this._contentSize.width
  6721. },
  6722. getPixelsHigh: function () {
  6723. return this._contentSize.height
  6724. },
  6725. getContentSize: function () {
  6726. var a = cc.contentScaleFactor();
  6727. return cc.size(this._contentSize.width / a, this._contentSize.height / a)
  6728. },
  6729. _getWidth: function () {
  6730. return this._contentSize.width / cc.contentScaleFactor()
  6731. },
  6732. _getHeight: function () {
  6733. return this._contentSize.height / cc.contentScaleFactor()
  6734. },
  6735. getContentSizeInPixels: function () {
  6736. return this._contentSize
  6737. },
  6738. initWithElement: function (a) {
  6739. a && (this._htmlElementObj = a)
  6740. },
  6741. getHtmlElementObj: function () {
  6742. return this._htmlElementObj
  6743. },
  6744. isLoaded: function () {
  6745. return this._isLoaded
  6746. },
  6747. handleLoadedTexture: function () {
  6748. if (!this._isLoaded) {
  6749. if (!this._htmlElementObj) {
  6750. var a = cc.loader.getRes(this.url);
  6751. if (!a) return;
  6752. this.initWithElement(a)
  6753. }
  6754. this._isLoaded = !0;
  6755. a = this._htmlElementObj;
  6756. this._contentSize.width = a.width;
  6757. this._contentSize.height = a.height;
  6758. this._callLoadedEventCallbacks()
  6759. }
  6760. },
  6761. description: function () {
  6762. return "\x3ccc.Texture2D | width \x3d " + this._contentSize.width + " height " + this._contentSize.height + "\x3e"
  6763. },
  6764. initWithData: function (a, b, c, d, e) {
  6765. return !1
  6766. },
  6767. initWithImage: function (a) {
  6768. return !1
  6769. },
  6770. initWithString: function (a, b, c, d, e, f) {
  6771. return !1
  6772. },
  6773. releaseTexture: function () { },
  6774. getName: function () {
  6775. return null
  6776. },
  6777. getMaxS: function () {
  6778. return 1
  6779. },
  6780. setMaxS: function (a) { },
  6781. getMaxT: function () {
  6782. return 1
  6783. },
  6784. setMaxT: function (a) { },
  6785. getPixelFormat: function () {
  6786. return null
  6787. },
  6788. getShaderProgram: function () {
  6789. return null
  6790. },
  6791. setShaderProgram: function (a) { },
  6792. hasPremultipliedAlpha: function () {
  6793. return !1
  6794. },
  6795. hasMipmaps: function () {
  6796. return !1
  6797. },
  6798. releaseData: function (a) { },
  6799. keepData: function (a, b) {
  6800. return a
  6801. },
  6802. drawAtPoint: function (a) { },
  6803. drawInRect: function (a) { },
  6804. initWithETCFile: function (a) {
  6805. cc.log(cc._LogInfos.Texture2D_initWithETCFile);
  6806. return !1
  6807. },
  6808. initWithPVRFile: function (a) {
  6809. cc.log(cc._LogInfos.Texture2D_initWithPVRFile);
  6810. return !1
  6811. },
  6812. initWithPVRTCData: function (a, b, c, d, e, f) {
  6813. cc.log(cc._LogInfos.Texture2D_initWithPVRTCData);
  6814. return !1
  6815. },
  6816. setTexParameters: function (a) { },
  6817. setAntiAliasTexParameters: function () { },
  6818. setAliasTexParameters: function () { },
  6819. generateMipmap: function () { },
  6820. stringForFormat: function () {
  6821. return ""
  6822. },
  6823. bitsPerPixelForFormat: function (a) {
  6824. return -1
  6825. },
  6826. addLoadedEventListener: function (a, b) {
  6827. this._loadedEventListeners || (this._loadedEventListeners = []);
  6828. this._loadedEventListeners.push({
  6829. eventCallback: a,
  6830. eventTarget: b
  6831. })
  6832. },
  6833. removeLoadedEventListener: function (a) {
  6834. if (this._loadedEventListeners) for (var b = this._loadedEventListeners, c = 0; c < b.length; c++) b[c].eventTarget == a && b.splice(c, 1)
  6835. },
  6836. _callLoadedEventCallbacks: function () {
  6837. if (this._loadedEventListeners) {
  6838. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  6839. var d = a[b];
  6840. d.eventCallback.call(d.eventTarget, this)
  6841. }
  6842. a.length = 0
  6843. }
  6844. }
  6845. }) : (cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTexture2D(), delete cc._tmp.WebGLTexture2D);
  6846. cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  6847. cc._tmp.PrototypeTexture2D();
  6848. delete cc._tmp.PrototypeTexture2D;
  6849. cc.textureCache = {
  6850. _textures: {},
  6851. _textureColorsCache: {},
  6852. _textureKeySeq: 0 | 1E3 * Math.random(),
  6853. _loadedTexturesBefore: {},
  6854. _initializingRenderer: function () {
  6855. var a,
  6856. b = this._loadedTexturesBefore,
  6857. c = this._textures;
  6858. for (a in b) {
  6859. var d = b[a];
  6860. d.handleLoadedTexture();
  6861. c[a] = d
  6862. }
  6863. this._loadedTexturesBefore = {}
  6864. },
  6865. addPVRTCImage: function (a) {
  6866. cc.log(cc._LogInfos.textureCache_addPVRTCImage)
  6867. },
  6868. addETCImage: function (a) {
  6869. cc.log(cc._LogInfos.textureCache_addETCImage)
  6870. },
  6871. description: function () {
  6872. return "\x3cTextureCache | Number of textures \x3d " +
  6873. this._textures.length + "\x3e"
  6874. },
  6875. textureForKey: function (a) {
  6876. cc.log(cc._LogInfos.textureCache_textureForKey);
  6877. return this.getTextureForKey(a)
  6878. },
  6879. getTextureForKey: function (a) {
  6880. return this._textures[a] || this._textures[cc.loader._aliases[a]]
  6881. },
  6882. getKeyByTexture: function (a) {
  6883. for (var b in this._textures) if (this._textures[b] == a) return b;
  6884. return null
  6885. },
  6886. _generalTextureKey: function () {
  6887. this._textureKeySeq++;
  6888. return "_textureKey_" + this._textureKeySeq
  6889. },
  6890. getTextureColors: function (a) {
  6891. var b = this.getKeyByTexture(a);
  6892. b || (b = a instanceof
  6893. HTMLImageElement ? a.src : this._generalTextureKey());
  6894. this._textureColorsCache[b] || (this._textureColorsCache[b] = cc.generateTextureCacheForColor(a));
  6895. return this._textureColorsCache[b]
  6896. },
  6897. addPVRImage: function (a) {
  6898. cc.log(cc._LogInfos.textureCache_addPVRImage)
  6899. },
  6900. removeAllTextures: function () {
  6901. var a = this._textures,
  6902. b;
  6903. for (b in a) a[b] && a[b].releaseTexture();
  6904. this._textures = {}
  6905. },
  6906. removeTexture: function (a) {
  6907. if (a) {
  6908. var b = this._textures,
  6909. c;
  6910. for (c in b) b[c] == a && (b[c].releaseTexture(), delete b[c])
  6911. }
  6912. },
  6913. removeTextureForKey: function (a) {
  6914. null != a && this._textures[a] && delete this._textures[a]
  6915. },
  6916. cacheImage: function (a, b) {
  6917. if (b instanceof cc.Texture2D) this._textures[a] = b;
  6918. else {
  6919. var c = new cc.Texture2D;
  6920. c.initWithElement(b);
  6921. c.handleLoadedTexture();
  6922. this._textures[a] = c
  6923. }
  6924. },
  6925. addUIImage: function (a, b) {
  6926. cc.assert(a, cc._LogInfos.textureCache_addUIImage_2);
  6927. if (b && this._textures[b]) return this._textures[b];
  6928. var c = new cc.Texture2D;
  6929. c.initWithImage(a);
  6930. null != b && null != c ? this._textures[b] = c : cc.log(cc._LogInfos.textureCache_addUIImage);
  6931. return c
  6932. },
  6933. dumpCachedTextureInfo: function () {
  6934. var a = 0,
  6935. b = 0,
  6936. c = this._textures,
  6937. d;
  6938. for (d in c) {
  6939. var e = c[d];
  6940. a++;
  6941. 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);
  6942. b += e.pixelsWidth * e.pixelsHeight * 4
  6943. }
  6944. c = this._textureColorsCache;
  6945. for (d in c) {
  6946. var e = c[d],
  6947. f;
  6948. for (f in e) {
  6949. var g = e[f];
  6950. a++;
  6951. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2, d, g.width, g.height);
  6952. b += g.width * g.height * 4
  6953. }
  6954. }
  6955. cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3, a, b / 1024, (b / 1048576).toFixed(2))
  6956. },
  6957. _clear: function () {
  6958. this._textures = {};
  6959. this._textureColorsCache = {};
  6960. this._textureKeySeq = 0 | 1E3 * Math.random();
  6961. this._loadedTexturesBefore = {}
  6962. }
  6963. };
  6964. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.textureCache, _p.handleLoadedTexture = function (a) {
  6965. var b = this._textures,
  6966. c = b[a];
  6967. c || (c = b[a] = new cc.Texture2D, c.url = a);
  6968. c.handleLoadedTexture()
  6969. },
  6970. _p.addImage = function (a, b, c) {
  6971. cc.assert(a, cc._LogInfos.Texture2D_addImage);
  6972. var d = this._textures,
  6973. e = d[a] || d[cc.loader._aliases[a]];
  6974. if (e) return b && b.call(c, e),
  6975. e;
  6976. e = d[a] = new cc.Texture2D;
  6977. e.url = a;
  6978. cc.loader.getRes(a) ? e.handleLoadedTexture() : cc.loader._checkIsImageURL(a) ? cc.loader.load(a,
  6979. function (a) {
  6980. b && b.call(c)
  6981. }) : cc.loader.loadImg(a,
  6982. function (d, g) {
  6983. if (d) return b ? b(d) : d;
  6984. cc.loader.cache[a] = g;
  6985. cc.textureCache.handleLoadedTexture(a);
  6986. b && b.call(c, e)
  6987. });
  6988. return e
  6989. },
  6990. _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache), cc._LogInfos.MissingFile, "TexturesWebGL.js"), cc._tmp.WebGLTextureCache(), delete cc._tmp.WebGLTextureCache);
  6991. cc.TextureAtlas = cc.Class.extend({
  6992. dirty: !1,
  6993. texture: null,
  6994. _indices: null,
  6995. _buffersVBO: null,
  6996. _capacity: 0,
  6997. _quads: null,
  6998. _quadsArrayBuffer: null,
  6999. _quadsWebBuffer: null,
  7000. _quadsReader: null,
  7001. ctor: function (a, b) {
  7002. this._buffersVBO = [];
  7003. cc.isString(a) ? this.initWithFile(a, b) : a instanceof cc.Texture2D && this.initWithTexture(a, b)
  7004. },
  7005. getTotalQuads: function () {
  7006. return this._totalQuads
  7007. },
  7008. getCapacity: function () {
  7009. return this._capacity
  7010. },
  7011. getTexture: function () {
  7012. return this.texture
  7013. },
  7014. setTexture: function (a) {
  7015. this.texture = a
  7016. },
  7017. setDirty: function (a) {
  7018. this.dirty = a
  7019. },
  7020. isDirty: function () {
  7021. return this.dirty
  7022. },
  7023. getQuads: function () {
  7024. return this._quads
  7025. },
  7026. setQuads: function (a) {
  7027. this._quads = a
  7028. },
  7029. _copyQuadsToTextureAtlas: function (a, b) {
  7030. if (a) for (var c = 0; c < a.length; c++) this._setQuadToArray(a[c], b + c)
  7031. },
  7032. _setQuadToArray: function (a, b) {
  7033. var c = this._quads;
  7034. 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)
  7035. },
  7036. description: function () {
  7037. return "\x3ccc.TextureAtlas | totalQuads \x3d" +
  7038. this._totalQuads + "\x3e"
  7039. },
  7040. _setupIndices: function () {
  7041. if (0 !== this._capacity) 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)
  7042. },
  7043. _setupVBO: function () {
  7044. var a = cc._renderContext;
  7045. this._buffersVBO[0] = a.createBuffer();
  7046. this._buffersVBO[1] = a.createBuffer();
  7047. this._quadsWebBuffer = a.createBuffer();
  7048. this._mapBuffers()
  7049. },
  7050. _mapBuffers: function () {
  7051. var a = cc._renderContext;
  7052. a.bindBuffer(a.ARRAY_BUFFER, this._quadsWebBuffer);
  7053. a.bufferData(a.ARRAY_BUFFER, this._quadsArrayBuffer, a.DYNAMIC_DRAW);
  7054. a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this._buffersVBO[1]);
  7055. a.bufferData(a.ELEMENT_ARRAY_BUFFER, this._indices, a.STATIC_DRAW)
  7056. },
  7057. initWithFile: function (a, b) {
  7058. var c = cc.textureCache.addImage(a);
  7059. if (c) return this.initWithTexture(c, b);
  7060. cc.log(cc._LogInfos.TextureAtlas_initWithFile, a);
  7061. return !1
  7062. },
  7063. initWithTexture: function (a, b) {
  7064. cc.assert(a, cc._LogInfos.TextureAtlas_initWithTexture);
  7065. this._capacity = b |= 0;
  7066. this._totalQuads = 0;
  7067. this.texture = a;
  7068. this._quads = [];
  7069. this._indices = new Uint16Array(6 * b);
  7070. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7071. this._quadsArrayBuffer = new ArrayBuffer(c * b);
  7072. this._quadsReader = new Uint8Array(this._quadsArrayBuffer);
  7073. if ((!this._quads || !this._indices) && 0 < b) return !1;
  7074. 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);
  7075. this._setupIndices();
  7076. this._setupVBO();
  7077. return this.dirty = !0
  7078. },
  7079. updateQuad: function (a, b) {
  7080. cc.assert(a, cc._LogInfos.TextureAtlas_updateQuad);
  7081. cc.assert(0 <= b && b < this._capacity, cc._LogInfos.TextureAtlas_updateQuad_2);
  7082. this._totalQuads = Math.max(b + 1, this._totalQuads);
  7083. this._setQuadToArray(a, b);
  7084. this.dirty = !0
  7085. },
  7086. insertQuad: function (a, b) {
  7087. cc.assert(b < this._capacity, cc._LogInfos.TextureAtlas_insertQuad_2);
  7088. this._totalQuads++;
  7089. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  7090. else {
  7091. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7092. d = b * c,
  7093. e = (this._totalQuads -
  7094. 1 - b) * c;
  7095. this._quads[this._totalQuads - 1] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, this._quadsArrayBuffer, (this._totalQuads - 1) * c);
  7096. this._quadsReader.set(this._quadsReader.subarray(d, d + e), d + c);
  7097. this._setQuadToArray(a, b);
  7098. this.dirty = !0
  7099. }
  7100. },
  7101. insertQuads: function (a, b, c) {
  7102. c = c || a.length;
  7103. cc.assert(b + c <= this._capacity, cc._LogInfos.TextureAtlas_insertQuads);
  7104. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7105. this._totalQuads += c;
  7106. if (this._totalQuads > this._capacity) cc.log(cc._LogInfos.TextureAtlas_insertQuad);
  7107. else {
  7108. var e = b * d,
  7109. f = (this._totalQuads - 1 - b - c) * d,
  7110. g = this._totalQuads - 1 - c,
  7111. h;
  7112. 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);
  7113. this._quadsReader.set(this._quadsReader.subarray(e, e + f), e + d * c);
  7114. for (h = 0; h < c; h++) this._setQuadToArray(a[h], b + h);
  7115. this.dirty = !0
  7116. }
  7117. },
  7118. insertQuadFromIndex: function (a, b) {
  7119. if (a !== b) {
  7120. cc.assert(0 <= b || b < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex);
  7121. cc.assert(0 <= a || a < this._totalQuads, cc._LogInfos.TextureAtlas_insertQuadFromIndex_2);
  7122. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7123. d = this._quadsReader,
  7124. e = d.subarray(a * c, c),
  7125. f;
  7126. 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));
  7127. this.dirty = !0
  7128. }
  7129. },
  7130. removeQuadAtIndex: function (a) {
  7131. cc.assert(a < this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadAtIndex);
  7132. var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;
  7133. this._totalQuads--;
  7134. this._quads.length = this._totalQuads;
  7135. if (a !== this._totalQuads) {
  7136. var c = (a + 1) * b;
  7137. this._quadsReader.set(this._quadsReader.subarray(c, c + (this._totalQuads - a) * b), c - b)
  7138. }
  7139. this.dirty = !0
  7140. },
  7141. removeQuadsAtIndex: function (a, b) {
  7142. cc.assert(a + b <= this._totalQuads, cc._LogInfos.TextureAtlas_removeQuadsAtIndex);
  7143. this._totalQuads -= b;
  7144. if (a !== this._totalQuads) {
  7145. var c = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7146. d = (a + b) * c,
  7147. e = a * c;
  7148. this._quadsReader.set(this._quadsReader.subarray(d, d + (this._totalQuads - a) * c), e)
  7149. }
  7150. this.dirty = !0
  7151. },
  7152. removeAllQuads: function () {
  7153. this._totalQuads = this._quads.length = 0
  7154. },
  7155. _setDirty: function (a) {
  7156. this.dirty = a
  7157. },
  7158. resizeCapacity: function (a) {
  7159. if (a == this._capacity) return !0;
  7160. var b = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7161. c = this._capacity;
  7162. this._totalQuads = Math.min(this._totalQuads, a);
  7163. var d = this._capacity = 0 | a,
  7164. e = this._totalQuads;
  7165. if (null == this._quads) 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);
  7166. else {
  7167. var f,
  7168. g,
  7169. h = this._quads;
  7170. if (d > c) {
  7171. f = [];
  7172. g = new ArrayBuffer(b * d);
  7173. for (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);
  7174. for (; a < d; a++) f[a] = new cc.V3F_C4B_T2F_Quad(null, null, null, null, g, a * b)
  7175. } else 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);
  7176. this._quadsReader = new Uint8Array(g);
  7177. this._quads = f;
  7178. this._quadsArrayBuffer = g
  7179. }
  7180. 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);
  7181. this._setupIndices();
  7182. this._mapBuffers();
  7183. return this.dirty = !0
  7184. },
  7185. increaseTotalQuadsWith: function (a) {
  7186. this._totalQuads += a
  7187. },
  7188. moveQuadsFromIndex: function (a, b, c) {
  7189. if (void 0 === c) {
  7190. if (c = b, b = this._totalQuads - a, cc.assert(c + (this._totalQuads - a) <= this._capacity, cc._LogInfos.TextureAtlas_moveQuadsFromIndex), 0 === b) return
  7191. } 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;
  7192. var d = cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,
  7193. e = a * d,
  7194. f = b * d,
  7195. g = this._quadsReader,
  7196. h = g.subarray(e, e + f),
  7197. k = c * d;
  7198. 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));
  7199. g.set(h, k);
  7200. this.dirty = !0
  7201. },
  7202. fillWithEmptyQuadsFromIndex: function (a, b) {
  7203. 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
  7204. },
  7205. drawQuads: function () {
  7206. this.drawNumberOfQuads(this._totalQuads, 0)
  7207. },
  7208. _releaseBuffer: function () {
  7209. var a = cc._renderContext;
  7210. this._buffersVBO && (this._buffersVBO[0] && a.deleteBuffer(this._buffersVBO[0]), this._buffersVBO[1] && a.deleteBuffer(this._buffersVBO[1]));
  7211. this._quadsWebBuffer && a.deleteBuffer(this._quadsWebBuffer)
  7212. }
  7213. });
  7214. _p = cc.TextureAtlas.prototype;
  7215. cc.defineGetterSetter(_p, "totalQuads", _p.getTotalQuads);
  7216. cc.defineGetterSetter(_p, "capacity", _p.getCapacity);
  7217. cc.defineGetterSetter(_p, "quads", _p.getQuads, _p.setQuads);
  7218. cc.TextureAtlas.create = function (a, b) {
  7219. return new cc.TextureAtlas(a, b)
  7220. };
  7221. cc.TextureAtlas.createWithTexture = cc.TextureAtlas.create;
  7222. 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);
  7223. cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas), cc._LogInfos.MissingFile, "TexturesPropertyDefine.js");
  7224. cc._tmp.PrototypeTextureAtlas();
  7225. delete cc._tmp.PrototypeTextureAtlas;
  7226. cc.Scene = cc.Node.extend({
  7227. _className: "Scene",
  7228. ctor: function () {
  7229. cc.Node.prototype.ctor.call(this);
  7230. this._ignoreAnchorPointForPosition = !0;
  7231. this.setAnchorPoint(0.5, 0.5);
  7232. this.setContentSize(cc.director.getWinSize())
  7233. }
  7234. });
  7235. cc.Scene.create = function () {
  7236. return new cc.Scene
  7237. };
  7238. cc.LoaderScene = cc.Scene.extend({
  7239. _interval: null,
  7240. _label: null,
  7241. _className: "LoaderScene",
  7242. init: function () {
  7243. var a = this,
  7244. b = 200,
  7245. c = a._bgLayer = new cc.LayerColor(cc.color(32, 32, 32, 255));
  7246. c.setPosition(cc.visibleRect.bottomLeft);
  7247. a.addChild(c, 0);
  7248. var d = 24,
  7249. e = -b / 2 + 100;
  7250. cc._loaderImage && (cc.loader.loadImg(cc._loaderImage, {
  7251. isCrossOrigin: !1
  7252. },
  7253. function (c, d) {
  7254. b = d.height;
  7255. a._initStage(d, cc.visibleRect.center)
  7256. }), d = 14, e = -b / 2 - 10);
  7257. d = a._label = cc.LabelTTF.create("Loading... 0%", "Arial", d);
  7258. d.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, e)));
  7259. d.setColor(cc.color(180, 180, 180));
  7260. c.addChild(this._label, 10);
  7261. return !0
  7262. },
  7263. _initStage: function (a, b) {
  7264. var c = this._texture2d = new cc.Texture2D;
  7265. c.initWithElement(a);
  7266. c.handleLoadedTexture();
  7267. c = this._logo = cc.Sprite.create(c);
  7268. c.setScale(cc.contentScaleFactor());
  7269. c.x = b.x;
  7270. c.y = b.y;
  7271. this._bgLayer.addChild(c, 10)
  7272. },
  7273. onEnter: function () {
  7274. cc.Node.prototype.onEnter.call(this);
  7275. this.schedule(this._startLoading, 0.3)
  7276. },
  7277. onExit: function () {
  7278. cc.Node.prototype.onExit.call(this);
  7279. this._label.setString("Loading... 0%")
  7280. },
  7281. initWithResources: function (a, b) {
  7282. cc.isString(a) && (a = [a]);
  7283. this.resources = a || [];
  7284. this.cb = b
  7285. },
  7286. _startLoading: function () {
  7287. var a = this;
  7288. a.unschedule(a._startLoading);
  7289. cc.loader.load(a.resources,
  7290. function (b, c, d) {
  7291. b = Math.min(d / c * 100 | 0, 100);
  7292. a._label.setString("Loading... " + b + "%")
  7293. },
  7294. function () {
  7295. a.cb && a.cb()
  7296. })
  7297. }
  7298. });
  7299. cc.LoaderScene.preload = function (a, b) {
  7300. var c = cc;
  7301. c.loaderScene || (c.loaderScene = new cc.LoaderScene, c.loaderScene.init());
  7302. c.loaderScene.initWithResources(a, b);
  7303. cc.director.runScene(c.loaderScene);
  7304. return c.loaderScene
  7305. };
  7306. cc._tmp.LayerDefineForWebGL = function () {
  7307. var a = cc.Layer.prototype;
  7308. a.bake = function () { };
  7309. a.unbake = function () { };
  7310. a.visit = cc.Node.prototype.visit
  7311. };
  7312. cc._tmp.WebGLLayerColor = function () {
  7313. var a = cc.LayerColor.prototype;
  7314. a._squareVertices = null;
  7315. a._squareColors = null;
  7316. a._verticesFloat32Buffer = null;
  7317. a._colorsUint8Buffer = null;
  7318. a._squareVerticesAB = null;
  7319. a._squareColorsAB = null;
  7320. a.ctor = function (a, c, d) {
  7321. this._squareVerticesAB = new ArrayBuffer(32);
  7322. this._squareColorsAB = new ArrayBuffer(16);
  7323. var e = this._squareVerticesAB,
  7324. f = this._squareColorsAB,
  7325. g = cc.Vertex2F.BYTES_PER_ELEMENT,
  7326. h = cc.Color.BYTES_PER_ELEMENT;
  7327. this._squareVertices = [new cc.Vertex2F(0, 0, e, 0), new cc.Vertex2F(0, 0, e, g), new cc.Vertex2F(0, 0, e, 2 * g), new cc.Vertex2F(0, 0, e, 3 * g)];
  7328. this._squareColors = [cc.color(0, 0, 0, 255, f, 0), cc.color(0, 0, 0, 255, f, h), cc.color(0, 0, 0, 255, f, 2 * h), cc.color(0, 0, 0, 255, f, 3 * h)];
  7329. this._verticesFloat32Buffer = cc._renderContext.createBuffer();
  7330. this._colorsUint8Buffer = cc._renderContext.createBuffer();
  7331. cc.Layer.prototype.ctor.call(this);
  7332. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  7333. cc.LayerColor.prototype.init.call(this, a, c, d)
  7334. };
  7335. a.setContentSize = function (a, c) {
  7336. var d = this._squareVertices;
  7337. void 0 === c ? (d[1].x = a.width, d[2].y = a.height, d[3].x = a.width, d[3].y = a.height) : (d[1].x = a, d[2].y = c, d[3].x = a, d[3].y = c);
  7338. this._bindLayerVerticesBufferData();
  7339. cc.Layer.prototype.setContentSize.call(this, a, c)
  7340. };
  7341. a._setWidth = function (a) {
  7342. var c = this._squareVertices;
  7343. c[1].x = a;
  7344. c[3].x = a;
  7345. this._bindLayerVerticesBufferData();
  7346. cc.Layer.prototype._setWidth.call(this, a)
  7347. };
  7348. a._setHeight = function (a) {
  7349. var c = this._squareVertices;
  7350. c[2].y = a;
  7351. c[3].y = a;
  7352. this._bindLayerVerticesBufferData();
  7353. cc.Layer.prototype._setHeight.call(this, a)
  7354. };
  7355. a._updateColor = function () {
  7356. for (var a = this._displayedColor, c = this._displayedOpacity, d = this._squareColors, e = 0; 4 > e; e++) d[e].r = a.r,
  7357. d[e].g = a.g,
  7358. d[e].b = a.b,
  7359. d[e].a = c;
  7360. this._bindLayerColorsBufferData()
  7361. };
  7362. a.draw = function (a) {
  7363. a = a || cc._renderContext;
  7364. cc.nodeDrawSetup(this);
  7365. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR);
  7366. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  7367. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  7368. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  7369. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 0, 0);
  7370. cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst);
  7371. a.drawArrays(a.TRIANGLE_STRIP, 0, 4)
  7372. };
  7373. a._bindLayerVerticesBufferData = function () {
  7374. var a = cc._renderContext;
  7375. a.bindBuffer(a.ARRAY_BUFFER, this._verticesFloat32Buffer);
  7376. a.bufferData(a.ARRAY_BUFFER, this._squareVerticesAB, a.STATIC_DRAW)
  7377. };
  7378. a._bindLayerColorsBufferData = function () {
  7379. var a = cc._renderContext;
  7380. a.bindBuffer(a.ARRAY_BUFFER, this._colorsUint8Buffer);
  7381. a.bufferData(a.ARRAY_BUFFER, this._squareColorsAB, a.STATIC_DRAW)
  7382. }
  7383. };
  7384. cc._tmp.WebGLLayerGradient = function () {
  7385. var a = cc.LayerGradient.prototype;
  7386. a.draw = cc.LayerColor.prototype.draw;
  7387. a._updateColor = function () {
  7388. var a = this._alongVector,
  7389. c = cc.pLength(a);
  7390. if (0 !== c) {
  7391. var d = Math.sqrt(2),
  7392. a = cc.p(a.x / c, a.y / c);
  7393. this._compressedInterpolation && (c = 1 / (Math.abs(a.x) + Math.abs(a.y)), a = cc.pMult(a, c * d));
  7394. var e = this._displayedOpacity / 255,
  7395. c = this._displayedColor,
  7396. f = this._endColor,
  7397. c = {
  7398. r: c.r,
  7399. g: c.g,
  7400. b: c.b,
  7401. a: this._startOpacity * e
  7402. },
  7403. e = {
  7404. r: f.r,
  7405. g: f.g,
  7406. b: f.b,
  7407. a: this._endOpacity * e
  7408. },
  7409. g = this._squareColors,
  7410. f = g[0],
  7411. h = g[1],
  7412. k = g[2],
  7413. g = g[3];
  7414. f.r = e.r + (d + a.x + a.y) / (2 * d) * (c.r - e.r);
  7415. f.g = e.g + (d + a.x + a.y) / (2 * d) * (c.g - e.g);
  7416. f.b = e.b + (d + a.x + a.y) / (2 * d) * (c.b - e.b);
  7417. f.a = e.a + (d + a.x + a.y) / (2 * d) * (c.a - e.a);
  7418. h.r = e.r + (d - a.x + a.y) / (2 * d) * (c.r - e.r);
  7419. h.g = e.g + (d - a.x + a.y) / (2 * d) * (c.g - e.g);
  7420. h.b = e.b + (d - a.x + a.y) / (2 * d) * (c.b - e.b);
  7421. h.a = e.a + (d - a.x + a.y) / (2 * d) * (c.a - e.a);
  7422. k.r = e.r + (d + a.x - a.y) / (2 * d) * (c.r - e.r);
  7423. k.g = e.g + (d + a.x - a.y) / (2 * d) * (c.g - e.g);
  7424. k.b = e.b + (d + a.x - a.y) / (2 * d) * (c.b - e.b);
  7425. k.a = e.a + (d + a.x - a.y) / (2 * d) * (c.a - e.a);
  7426. g.r = e.r + (d - a.x - a.y) / (2 * d) * (c.r - e.r);
  7427. g.g = e.g + (d - a.x - a.y) / (2 * d) * (c.g - e.g);
  7428. g.b = e.b + (d - a.x - a.y) / (2 * d) * (c.b - e.b);
  7429. g.a = e.a + (d - a.x - a.y) / (2 * d) * (c.a - e.a);
  7430. this._bindLayerColorsBufferData()
  7431. }
  7432. }
  7433. };
  7434. cc._tmp.PrototypeLayerColor = function () {
  7435. var a = cc.LayerColor.prototype;
  7436. cc.defineGetterSetter(a, "width", a._getWidth, a._setWidth);
  7437. cc.defineGetterSetter(a, "height", a._getHeight, a._setHeight)
  7438. };
  7439. cc._tmp.PrototypeLayerGradient = function () {
  7440. var a = cc.LayerGradient.prototype;
  7441. cc.defineGetterSetter(a, "startColor", a.getStartColor, a.setStartColor);
  7442. cc.defineGetterSetter(a, "endColor", a.getEndColor, a.setEndColor);
  7443. cc.defineGetterSetter(a, "startOpacity", a.getStartOpacity, a.setStartOpacity);
  7444. cc.defineGetterSetter(a, "endOpacity", a.getEndOpacity, a.setEndOpacity);
  7445. cc.defineGetterSetter(a, "vector", a.getVector, a.setVector)
  7446. };
  7447. cc.Layer = cc.Node.extend({
  7448. _isBaked: !1,
  7449. _bakeSprite: null,
  7450. _className: "Layer",
  7451. ctor: function () {
  7452. var a = cc.Node.prototype;
  7453. a.ctor.call(this);
  7454. this._ignoreAnchorPointForPosition = !0;
  7455. a.setAnchorPoint.call(this, 0.5, 0.5);
  7456. a.setContentSize.call(this, cc.winSize)
  7457. },
  7458. init: function () {
  7459. this._ignoreAnchorPointForPosition = !0;
  7460. this.setAnchorPoint(0.5, 0.5);
  7461. this.setContentSize(cc.winSize);
  7462. this.cascadeColor = this.cascadeOpacity = !1;
  7463. return !0
  7464. },
  7465. bake: null,
  7466. unbake: null,
  7467. isBaked: function () {
  7468. return this._isBaked
  7469. },
  7470. visit: null
  7471. });
  7472. cc.Layer.create = function () {
  7473. return new cc.Layer
  7474. };
  7475. if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
  7476. var p = cc.Layer.prototype;
  7477. p.bake = function () {
  7478. if (!this._isBaked) {
  7479. this._isBaked = this._cacheDirty = !0;
  7480. this._cachedParent = this;
  7481. for (var a = this._children, b = 0, c = a.length; b < c; b++) a[b]._setCachedParent(this);
  7482. this._bakeSprite || (this._bakeSprite = new cc.BakeSprite)
  7483. }
  7484. };
  7485. p.unbake = function () {
  7486. if (this._isBaked) {
  7487. this._isBaked = !1;
  7488. this._cacheDirty = !0;
  7489. this._cachedParent = null;
  7490. for (var a = this._children, b = 0, c = a.length; b < c; b++) a[b]._setCachedParent(null)
  7491. }
  7492. };
  7493. p.addChild = function (a, b, c) {
  7494. cc.Node.prototype.addChild.call(this, a, b, c);
  7495. a._parent == this && this._isBaked && a._setCachedParent(this)
  7496. };
  7497. p.visit = function (a) {
  7498. if (this._isBaked) {
  7499. a = a || cc._renderContext;
  7500. var b,
  7501. c = this._children,
  7502. d = c.length;
  7503. if (this._visible && 0 !== d) {
  7504. var e = this._bakeSprite;
  7505. a.save();
  7506. this.transform(a);
  7507. if (this._cacheDirty) {
  7508. b = this._getBoundingBoxForBake();
  7509. b.width |= 0;
  7510. b.height |= 0;
  7511. var f = e.getCacheContext();
  7512. e.resetCanvasSize(b.width, b.height);
  7513. f.translate(0 - b.x, b.height + b.y);
  7514. var g = e.getAnchorPointInPoints();
  7515. e.setPosition(g.x + b.x, g.y + b.y);
  7516. this.sortAllChildren();
  7517. cc.view._setScaleXYForRenderTexture();
  7518. for (b = 0; b < d; b++) c[b].visit(f);
  7519. cc.view._resetScale();
  7520. this._cacheDirty = !1
  7521. }
  7522. e.visit(a);
  7523. this.arrivalOrder = 0;
  7524. a.restore()
  7525. }
  7526. } else cc.Node.prototype.visit.call(this, a)
  7527. };
  7528. p._getBoundingBoxForBake = function () {
  7529. var a = null;
  7530. if (!this._children || 0 === this._children.length) return cc.rect(0, 0, 10, 10);
  7531. for (var b = this._children, c = 0; c < b.length; c++) {
  7532. var d = b[c];
  7533. d && d._visible && (a ? (d = d._getBoundingBoxToCurrentNode()) && (a = cc.rectUnion(a, d)) : a = d._getBoundingBoxToCurrentNode())
  7534. }
  7535. return a
  7536. };
  7537. p = null
  7538. } else cc.assert(cc.isFunction(cc._tmp.LayerDefineForWebGL), cc._LogInfos.MissingFile, "CCLayerWebGL.js"),
  7539. cc._tmp.LayerDefineForWebGL(),
  7540. delete cc._tmp.LayerDefineForWebGL;
  7541. cc.LayerColor = cc.Layer.extend({
  7542. _blendFunc: null,
  7543. _className: "LayerColor",
  7544. getBlendFunc: function () {
  7545. return this._blendFunc
  7546. },
  7547. changeWidthAndHeight: function (a, b) {
  7548. this.width = a;
  7549. this.height = b
  7550. },
  7551. changeWidth: function (a) {
  7552. this.width = a
  7553. },
  7554. changeHeight: function (a) {
  7555. this.height = a
  7556. },
  7557. setOpacityModifyRGB: function (a) { },
  7558. isOpacityModifyRGB: function () {
  7559. return !1
  7560. },
  7561. setColor: function (a) {
  7562. cc.Layer.prototype.setColor.call(this, a);
  7563. this._updateColor()
  7564. },
  7565. setOpacity: function (a) {
  7566. cc.Layer.prototype.setOpacity.call(this, a);
  7567. this._updateColor()
  7568. },
  7569. _blendFuncStr: "source",
  7570. ctor: null,
  7571. init: function (a, b, c) {
  7572. cc._renderType !== cc._RENDER_TYPE_CANVAS && (this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));
  7573. var d = cc.director.getWinSize();
  7574. a = a || cc.color(0, 0, 0, 255);
  7575. b = void 0 === b ? d.width : b;
  7576. c = void 0 === c ? d.height : c;
  7577. d = this._displayedColor;
  7578. d.r = a.r;
  7579. d.g = a.g;
  7580. d.b = a.b;
  7581. d = this._realColor;
  7582. d.r = a.r;
  7583. d.g = a.g;
  7584. d.b = a.b;
  7585. this._realOpacity = this._displayedOpacity = a.a;
  7586. a = cc.LayerColor.prototype;
  7587. a.setContentSize.call(this, b, c);
  7588. a._updateColor.call(this);
  7589. return !0
  7590. },
  7591. setBlendFunc: function (a, b) {
  7592. var c = this._blendFunc;
  7593. void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b);
  7594. cc._renderType === cc._RENDER_TYPE_CANVAS && (this._blendFuncStr = cc._getCompositeOperationByBlendFunc(c))
  7595. },
  7596. _setWidth: null,
  7597. _setHeight: null,
  7598. _updateColor: null,
  7599. updateDisplayedColor: function (a) {
  7600. cc.Layer.prototype.updateDisplayedColor.call(this, a);
  7601. this._updateColor()
  7602. },
  7603. updateDisplayedOpacity: function (a) {
  7604. cc.Layer.prototype.updateDisplayedOpacity.call(this, a);
  7605. this._updateColor()
  7606. },
  7607. draw: null
  7608. });
  7609. cc.LayerColor.create = function (a, b, c) {
  7610. return new cc.LayerColor(a, b, c)
  7611. };
  7612. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerColor.prototype, _p.ctor = function (a, b, c) {
  7613. cc.Layer.prototype.ctor.call(this);
  7614. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  7615. cc.LayerColor.prototype.init.call(this, a, b, c)
  7616. },
  7617. _p._setWidth = cc.Layer.prototype._setWidth, _p._setHeight = cc.Layer.prototype._setHeight, _p._updateColor = function () { },
  7618. _p.draw = function (a) {
  7619. a = a || cc._renderContext;
  7620. var b = cc.view,
  7621. c = this._displayedColor;
  7622. a.fillStyle = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + "," + this._displayedOpacity / 255 + ")";
  7623. a.fillRect(0, 0, this.width * b.getScaleX(), -this.height * b.getScaleY());
  7624. cc.g_NumberOfDraws++
  7625. },
  7626. _p.visit = function (a) {
  7627. if (this._isBaked) {
  7628. a = a || cc._renderContext;
  7629. var b,
  7630. c = this._children,
  7631. d = c.length;
  7632. if (this._visible) {
  7633. var e = this._bakeSprite;
  7634. a.save();
  7635. this.transform(a);
  7636. if (this._cacheDirty) {
  7637. b = this._getBoundingBoxForBake();
  7638. b.width |= 0;
  7639. b.height |= 0;
  7640. var f = e.getCacheContext();
  7641. e.resetCanvasSize(b.width, b.height);
  7642. var g = e.getAnchorPointInPoints(),
  7643. h = this._position;
  7644. if (this._ignoreAnchorPointForPosition) f.translate(0 -
  7645. b.x + h.x, b.height + b.y - h.y),
  7646. e.setPosition(g.x + b.x - h.x, g.y + b.y - h.y);
  7647. else {
  7648. var k = this.getAnchorPointInPoints(),
  7649. m = h.x - k.x,
  7650. h = h.y - k.y;
  7651. f.translate(0 - b.x + m, b.height + b.y - h);
  7652. e.setPosition(g.x + b.x - m, g.y + b.y - h)
  7653. }
  7654. cc.view._setScaleXYForRenderTexture();
  7655. if (0 < d) {
  7656. this.sortAllChildren();
  7657. for (b = 0; b < d; b++) if (g = c[b], 0 > g._localZOrder) g.visit(f);
  7658. else break;
  7659. for (this.draw(f) ; b < d; b++) c[b].visit(f)
  7660. } else this.draw(f);
  7661. cc.view._resetScale();
  7662. this._cacheDirty = !1
  7663. }
  7664. e.visit(a);
  7665. this.arrivalOrder = 0;
  7666. a.restore()
  7667. }
  7668. } else cc.Node.prototype.visit.call(this, a)
  7669. },
  7670. _p._getBoundingBoxForBake = function () {
  7671. var a = cc.rect(0, 0, this._contentSize.width, this._contentSize.height),
  7672. b = this.nodeToWorldTransform(),
  7673. a = cc.rectApplyAffineTransform(a, this.nodeToWorldTransform());
  7674. if (!this._children || 0 === this._children.length) return a;
  7675. for (var c = this._children, d = 0; d < c.length; d++) {
  7676. var e = c[d];
  7677. e && e._visible && (e = e._getBoundingBoxToCurrentNode(b), a = cc.rectUnion(a, e))
  7678. }
  7679. return a
  7680. },
  7681. _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLLayerColor), cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerColor(), delete cc._tmp.WebGLLayerColor);
  7682. cc.assert(cc.isFunction(cc._tmp.PrototypeLayerColor), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  7683. cc._tmp.PrototypeLayerColor();
  7684. delete cc._tmp.PrototypeLayerColor;
  7685. cc.LayerGradient = cc.LayerColor.extend({
  7686. _startColor: null,
  7687. _endColor: null,
  7688. _startOpacity: 255,
  7689. _endOpacity: 255,
  7690. _alongVector: null,
  7691. _compressedInterpolation: !1,
  7692. _gradientStartPoint: null,
  7693. _gradientEndPoint: null,
  7694. _className: "LayerGradient",
  7695. ctor: function (a, b, c) {
  7696. cc.LayerColor.prototype.ctor.call(this);
  7697. this._startColor = cc.color(0, 0, 0, 255);
  7698. this._endColor = cc.color(0, 0, 0, 255);
  7699. this._alongVector = cc.p(0, -1);
  7700. this._endOpacity = this._startOpacity = 255;
  7701. this._gradientStartPoint = cc.p(0, 0);
  7702. this._gradientEndPoint = cc.p(0, 0);
  7703. cc.LayerGradient.prototype.init.call(this, a, b, c)
  7704. },
  7705. init: function (a, b, c) {
  7706. a = a || cc.color(0, 0, 0, 255);
  7707. b = b || cc.color(0, 0, 0, 255);
  7708. c = c || cc.p(0, -1);
  7709. var d = this._startColor,
  7710. e = this._endColor;
  7711. d.r = a.r;
  7712. d.g = a.g;
  7713. d.b = a.b;
  7714. this._startOpacity = a.a;
  7715. e.r = b.r;
  7716. e.g = b.g;
  7717. e.b = b.b;
  7718. this._endOpacity = b.a;
  7719. this._alongVector = c;
  7720. this._compressedInterpolation = !0;
  7721. this._gradientStartPoint = cc.p(0, 0);
  7722. this._gradientEndPoint = cc.p(0, 0);
  7723. cc.LayerColor.prototype.init.call(this, cc.color(a.r, a.g, a.b, 255));
  7724. cc.LayerGradient.prototype._updateColor.call(this);
  7725. return !0
  7726. },
  7727. setContentSize: function (a, b) {
  7728. cc.LayerColor.prototype.setContentSize.call(this, a, b);
  7729. this._updateColor()
  7730. },
  7731. _setWidth: function (a) {
  7732. cc.LayerColor.prototype._setWidth.call(this, a);
  7733. this._updateColor()
  7734. },
  7735. _setHeight: function (a) {
  7736. cc.LayerColor.prototype._setHeight.call(this, a);
  7737. this._updateColor()
  7738. },
  7739. getStartColor: function () {
  7740. return this._realColor
  7741. },
  7742. setStartColor: function (a) {
  7743. this.color = a
  7744. },
  7745. setEndColor: function (a) {
  7746. this._endColor = a;
  7747. this._updateColor()
  7748. },
  7749. getEndColor: function () {
  7750. return this._endColor
  7751. },
  7752. setStartOpacity: function (a) {
  7753. this._startOpacity = a;
  7754. this._updateColor()
  7755. },
  7756. getStartOpacity: function () {
  7757. return this._startOpacity
  7758. },
  7759. setEndOpacity: function (a) {
  7760. this._endOpacity = a;
  7761. this._updateColor()
  7762. },
  7763. getEndOpacity: function () {
  7764. return this._endOpacity
  7765. },
  7766. setVector: function (a) {
  7767. this._alongVector.x = a.x;
  7768. this._alongVector.y = a.y;
  7769. this._updateColor()
  7770. },
  7771. getVector: function () {
  7772. return cc.p(this._alongVector.x, this._alongVector.y)
  7773. },
  7774. isCompressedInterpolation: function () {
  7775. return this._compressedInterpolation
  7776. },
  7777. setCompressedInterpolation: function (a) {
  7778. this._compressedInterpolation = a;
  7779. this._updateColor()
  7780. },
  7781. _draw: null,
  7782. _updateColor: null
  7783. });
  7784. cc.LayerGradient.create = function (a, b, c) {
  7785. return new cc.LayerGradient(a, b, c)
  7786. };
  7787. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LayerGradient.prototype, _p.draw = function (a) {
  7788. a = a || cc._renderContext;
  7789. "source" != this._blendFuncStr && (a.globalCompositeOperation = this._blendFuncStr);
  7790. a.save();
  7791. var b = this._displayedOpacity / 255,
  7792. c = cc.view.getScaleX(),
  7793. d = cc.view.getScaleY(),
  7794. e = this.width * c,
  7795. f = this.height * d,
  7796. c = a.createLinearGradient(this._gradientStartPoint.x * c, this._gradientStartPoint.y * d, this._gradientEndPoint.x * c, this._gradientEndPoint.y * d),
  7797. d = this._displayedColor,
  7798. g = this._endColor;
  7799. c.addColorStop(0, "rgba(" + Math.round(d.r) + "," + Math.round(d.g) + "," + Math.round(d.b) + "," + (this._startOpacity / 255 * b).toFixed(4) + ")");
  7800. c.addColorStop(1, "rgba(" + Math.round(g.r) + "," + Math.round(g.g) + "," + Math.round(g.b) + "," + (this._endOpacity / 255 * b).toFixed(4) + ")");
  7801. a.fillStyle = c;
  7802. a.fillRect(0, 0, e, -f);
  7803. 0 != this._rotation && a.rotate(this._rotationRadians);
  7804. a.restore();
  7805. cc.g_NumberOfDraws++
  7806. },
  7807. _p._updateColor = function () {
  7808. var a = this._alongVector,
  7809. b = 0.5 * this.width,
  7810. c = 0.5 * this.height;
  7811. this._gradientStartPoint.x = b * -a.x + b;
  7812. this._gradientStartPoint.y = c * a.y - c;
  7813. this._gradientEndPoint.x = b * a.x + b;
  7814. this._gradientEndPoint.y = c * -a.y - c
  7815. },
  7816. _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLLayerGradient), cc._LogInfos.MissingFile, "CCLayerWebGL.js"), cc._tmp.WebGLLayerGradient(), delete cc._tmp.WebGLLayerGradient);
  7817. cc.assert(cc.isFunction(cc._tmp.PrototypeLayerGradient), cc._LogInfos.MissingFile, "CCLayerPropertyDefine.js");
  7818. cc._tmp.PrototypeLayerGradient();
  7819. delete cc._tmp.PrototypeLayerGradient;
  7820. cc.LayerMultiplex = cc.Layer.extend({
  7821. _enabledLayer: 0,
  7822. _layers: null,
  7823. _className: "LayerMultiplex",
  7824. ctor: function (a) {
  7825. cc.Layer.prototype.ctor.call(this);
  7826. a instanceof Array ? cc.LayerMultiplex.prototype.initWithLayers.call(this, a) : cc.LayerMultiplex.prototype.initWithLayers.call(this, Array.prototype.slice.call(arguments))
  7827. },
  7828. initWithLayers: function (a) {
  7829. 0 < a.length && null == a[a.length - 1] && cc.log(cc._LogInfos.LayerMultiplex_initWithLayers);
  7830. this._layers = a;
  7831. this._enabledLayer = 0;
  7832. this.addChild(this._layers[this._enabledLayer]);
  7833. return !0
  7834. },
  7835. switchTo: function (a) {
  7836. 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]))
  7837. },
  7838. switchToAndReleaseMe: function (a) {
  7839. 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]))
  7840. },
  7841. addLayer: function (a) {
  7842. a ? this._layers.push(a) : cc.log(cc._LogInfos.LayerMultiplex_addLayer)
  7843. }
  7844. });
  7845. cc.LayerMultiplex.create = function () {
  7846. return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))
  7847. };
  7848. cc._tmp.WebGLSprite = function () {
  7849. var a = cc.Sprite.prototype;
  7850. a._spriteFrameLoadedCallback = function (a) {
  7851. this.setNodeDirty(!0);
  7852. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  7853. this._callLoadedEventCallbacks()
  7854. };
  7855. a.setOpacityModifyRGB = function (a) {
  7856. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.updateColor())
  7857. };
  7858. a.updateDisplayedOpacity = function (a) {
  7859. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  7860. this.updateColor()
  7861. };
  7862. a.ctor = function (a, c, d) {
  7863. cc.Node.prototype.ctor.call(this);
  7864. this._shouldBeHidden = !1;
  7865. this._offsetPosition = cc.p(0, 0);
  7866. this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
  7867. this._blendFunc = {
  7868. src: cc.BLEND_SRC,
  7869. dst: cc.BLEND_DST
  7870. };
  7871. this._rect = cc.rect(0, 0, 0, 0);
  7872. this._quad = new cc.V3F_C4B_T2F_Quad;
  7873. this._quadWebBuffer = cc._renderContext.createBuffer();
  7874. this._textureLoaded = this._quadDirty = !0;
  7875. this._softInit(a, c, d)
  7876. };
  7877. a.setBlendFunc = function (a, c) {
  7878. var d = this._blendFunc;
  7879. void 0 === c ? (d.src = a.src, d.dst = a.dst) : (d.src = a, d.dst = c)
  7880. };
  7881. a.init = function () {
  7882. if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
  7883. cc.Node.prototype.init.call(this);
  7884. this.dirty = this._recursiveDirty = !1;
  7885. this._opacityModifyRGB = !0;
  7886. this._blendFunc.src = cc.BLEND_SRC;
  7887. this._blendFunc.dst = cc.BLEND_DST;
  7888. this.texture = null;
  7889. this._textureLoaded = !0;
  7890. this._flippedX = this._flippedY = !1;
  7891. this.anchorY = this.anchorX = 0.5;
  7892. this._offsetPosition.x = 0;
  7893. this._offsetPosition.y = 0;
  7894. this._hasChildren = !1;
  7895. var a = {
  7896. r: 255,
  7897. g: 255,
  7898. b: 255,
  7899. a: 255
  7900. };
  7901. this._quad.bl.colors = a;
  7902. this._quad.br.colors = a;
  7903. this._quad.tl.colors = a;
  7904. this._quad.tr.colors = a;
  7905. this._quadDirty = !0;
  7906. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  7907. return !0
  7908. };
  7909. a.initWithTexture = function (a, c, d) {
  7910. cc.assert(0 != arguments.length, cc._LogInfos.Sprite_initWithTexture);
  7911. d = d || !1;
  7912. if (!cc.Node.prototype.init.call(this)) return !1;
  7913. this._batchNode = null;
  7914. this.dirty = this._recursiveDirty = !1;
  7915. this._opacityModifyRGB = !0;
  7916. this._blendFunc.src = cc.BLEND_SRC;
  7917. this._blendFunc.dst = cc.BLEND_DST;
  7918. this._flippedX = this._flippedY = !1;
  7919. this.anchorY = this.anchorX = 0.5;
  7920. this._offsetPosition.x = 0;
  7921. this._offsetPosition.y = 0;
  7922. this._hasChildren = !1;
  7923. var e = cc.color(255, 255, 255, 255),
  7924. f = this._quad;
  7925. f.bl.colors = e;
  7926. f.br.colors = e;
  7927. f.tl.colors = e;
  7928. f.tr.colors = e;
  7929. this._textureLoaded = e = a.isLoaded();
  7930. if (!e) return this._rectRotated = d || !1,
  7931. c && (e = this._rect, e.x = c.x, e.y = c.y, e.width = c.width, e.height = c.height),
  7932. a.addLoadedEventListener(this._textureLoadedCallback, this),
  7933. !0;
  7934. c || (c = cc.rect(0, 0, a.width, a.height));
  7935. a && a.url && (d ? (e = c.x + c.height, f = c.y + c.width) : (e = c.x + c.width, f = c.y + c.height), e > a.width && cc.error(cc._LogInfos.RectWidth, a.url), f > a.height && cc.error(cc._LogInfos.RectHeight, a.url));
  7936. this.texture = a;
  7937. this.setTextureRect(c, d);
  7938. this.batchNode = null;
  7939. return this._quadDirty = !0
  7940. };
  7941. a._textureLoadedCallback = function (a) {
  7942. if (!this._textureLoaded) {
  7943. this._textureLoaded = !0;
  7944. var c = this._rect;
  7945. c ? cc._rectEqualToZero(c) && (c.width = a.width, c.height = a.height) : c = cc.rect(0, 0, a.width, a.height);
  7946. this.texture = a;
  7947. this.setTextureRect(c, this._rectRotated);
  7948. this.batchNode = this._batchNode;
  7949. this._quadDirty = !0;
  7950. this._callLoadedEventCallbacks()
  7951. }
  7952. };
  7953. a.setTextureRect = function (a, c, d) {
  7954. this._rectRotated = c || !1;
  7955. this.setContentSize(d || a);
  7956. this.setVertexRect(a);
  7957. this._setTextureCoords(a);
  7958. a = this._unflippedOffsetPositionFromCenter;
  7959. this._flippedX && (a.x = -a.x);
  7960. this._flippedY && (a.y = -a.y);
  7961. var e = this._rect;
  7962. this._offsetPosition.x = a.x + (this._contentSize.width - e.width) / 2;
  7963. this._offsetPosition.y = a.y + (this._contentSize.height - e.height) / 2;
  7964. if (this._batchNode) this.dirty = !0;
  7965. else {
  7966. a = 0 + this._offsetPosition.x;
  7967. c = 0 + this._offsetPosition.y;
  7968. d = a + e.width;
  7969. var e = c + e.height,
  7970. f = this._quad;
  7971. f.bl.vertices = {
  7972. x: a,
  7973. y: c,
  7974. z: 0
  7975. };
  7976. f.br.vertices = {
  7977. x: d,
  7978. y: c,
  7979. z: 0
  7980. };
  7981. f.tl.vertices = {
  7982. x: a,
  7983. y: e,
  7984. z: 0
  7985. };
  7986. f.tr.vertices = {
  7987. x: d,
  7988. y: e,
  7989. z: 0
  7990. };
  7991. this._quadDirty = !0
  7992. }
  7993. };
  7994. a.updateTransform = function () {
  7995. if (this.dirty) {
  7996. var a = this._quad,
  7997. c = this._parent;
  7998. if (!this._visible || c && c != this._batchNode && c._shouldBeHidden) a.br.vertices = a.tl.vertices = a.tr.vertices = a.bl.vertices = {
  7999. x: 0,
  8000. y: 0,
  8001. z: 0
  8002. },
  8003. this._shouldBeHidden = !0;
  8004. else {
  8005. this._shouldBeHidden = !1;
  8006. var d = this._transformToBatch = c && c != this._batchNode ? cc.affineTransformConcat(this.nodeToParentTransform(), c._transformToBatch) : this.nodeToParentTransform(),
  8007. e = this._rect,
  8008. c = this._offsetPosition.x,
  8009. f = this._offsetPosition.y,
  8010. g = c + e.width,
  8011. h = f + e.height,
  8012. k = d.tx,
  8013. m = d.ty,
  8014. n = d.a,
  8015. q = d.b,
  8016. r = d.d,
  8017. s = -d.c,
  8018. d = c * n - f * s + k,
  8019. e = c * q + f * r + m,
  8020. t = g * n - f * s + k,
  8021. f = g * q + f * r + m,
  8022. u = g * n - h * s + k,
  8023. g = g * q + h * r + m,
  8024. k = c * n - h * s + k,
  8025. c = c * q + h * r + m,
  8026. h = this._vertexZ;
  8027. cc.SPRITEBATCHNODE_RENDER_SUBPIXEL || (d |= 0, e |= 0, t |= 0, f |= 0, u |= 0, g |= 0, k |= 0, c |= 0);
  8028. a.bl.vertices = {
  8029. x: d,
  8030. y: e,
  8031. z: h
  8032. };
  8033. a.br.vertices = {
  8034. x: t,
  8035. y: f,
  8036. z: h
  8037. };
  8038. a.tl.vertices = {
  8039. x: k,
  8040. y: c,
  8041. z: h
  8042. };
  8043. a.tr.vertices = {
  8044. x: u,
  8045. y: g,
  8046. z: h
  8047. }
  8048. }
  8049. this.textureAtlas.updateQuad(a, this.atlasIndex);
  8050. this.dirty = this._recursiveDirty = !1
  8051. }
  8052. this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform);
  8053. cc.SPRITE_DEBUG_DRAW && (a = [cc.p(this._quad.bl.vertices.x, this._quad.bl.vertices.y), cc.p(this._quad.br.vertices.x, this._quad.br.vertices.y), cc.p(this._quad.tr.vertices.x, this._quad.tr.vertices.y), cc.p(this._quad.tl.vertices.x, this._quad.tl.vertices.y)], cc._drawingUtil.drawPoly(a, 4, !0))
  8054. };
  8055. a.addChild = function (a, c, d) {
  8056. cc.assert(a, cc._LogInfos.Sprite_addChild_3);
  8057. null == c && (c = a._localZOrder);
  8058. null == d && (d = a.tag);
  8059. if (this._batchNode) {
  8060. if (!(a instanceof cc.Sprite)) {
  8061. cc.log(cc._LogInfos.Sprite_addChild);
  8062. return
  8063. }
  8064. a.texture._webTextureObj !== this.textureAtlas.texture._webTextureObj && cc.log(cc._LogInfos.Sprite_addChild_2);
  8065. this._batchNode.appendChild(a);
  8066. this._reorderChildDirty || this._setReorderChildDirtyRecursively()
  8067. }
  8068. cc.Node.prototype.addChild.call(this, a, c, d);
  8069. this._hasChildren = !0
  8070. };
  8071. a.setOpacity = function (a) {
  8072. cc.Node.prototype.setOpacity.call(this, a);
  8073. this.updateColor()
  8074. };
  8075. a.setColor = function (a) {
  8076. cc.Node.prototype.setColor.call(this, a);
  8077. this.updateColor()
  8078. };
  8079. a.updateDisplayedColor = function (a) {
  8080. cc.Node.prototype.updateDisplayedColor.call(this, a);
  8081. this.updateColor()
  8082. };
  8083. a.setSpriteFrame = function (a) {
  8084. var c = this;
  8085. cc.isString(a) && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.Sprite_setSpriteFrame));
  8086. c.setNodeDirty(!0);
  8087. var d = a.getOffset();
  8088. c._unflippedOffsetPositionFromCenter.x = d.x;
  8089. c._unflippedOffsetPositionFromCenter.y = d.y;
  8090. d = a.getTexture();
  8091. a.textureLoaded() || (c._textureLoaded = !1, a.addLoadedEventListener(function (a) {
  8092. c._textureLoaded = !0;
  8093. var b = a.getTexture();
  8094. b != c._texture && (c.texture = b);
  8095. c.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8096. c._callLoadedEventCallbacks()
  8097. },
  8098. c));
  8099. d != c._texture && (c.texture = d);
  8100. c._rectRotated = a.isRotated();
  8101. c.setTextureRect(a.getRect(), c._rectRotated, a.getOriginalSize())
  8102. };
  8103. a.isFrameDisplayed = function (a) {
  8104. return cc.rectEqualToRect(a.getRect(), this._rect) && a.getTexture().getName() == this._texture.getName() && cc.pointEqualToPoint(a.getOffset(), this._unflippedOffsetPositionFromCenter)
  8105. };
  8106. a.setBatchNode = function (a) {
  8107. if (this._batchNode = a) this._transformToBatch = cc.affineTransformIdentity(),
  8108. this.textureAtlas = this._batchNode.textureAtlas;
  8109. else {
  8110. this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED;
  8111. this.textureAtlas = null;
  8112. this.dirty = this._recursiveDirty = !1;
  8113. a = this._offsetPosition.x;
  8114. var c = this._offsetPosition.y,
  8115. d = a + this._rect.width,
  8116. e = c + this._rect.height,
  8117. f = this._quad;
  8118. f.bl.vertices = {
  8119. x: a,
  8120. y: c,
  8121. z: 0
  8122. };
  8123. f.br.vertices = {
  8124. x: d,
  8125. y: c,
  8126. z: 0
  8127. };
  8128. f.tl.vertices = {
  8129. x: a,
  8130. y: e,
  8131. z: 0
  8132. };
  8133. f.tr.vertices = {
  8134. x: d,
  8135. y: e,
  8136. z: 0
  8137. };
  8138. this._quadDirty = !0
  8139. }
  8140. };
  8141. a.setTexture = function (a) {
  8142. a && cc.isString(a) ? (a = cc.textureCache.addImage(a), this.setTexture(a), a = a.getContentSize(), this.setTextureRect(cc.rect(0, 0, a.width, a.height))) : (cc.assert(!a || a instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2), this._batchNode && this._batchNode.texture != a ? cc.log(cc._LogInfos.Sprite_setTexture) : (this.shaderProgram = a ? cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR) : cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR), this._batchNode || this._texture == a || (this._texture = a, this._updateBlendFunc())))
  8143. };
  8144. a.draw = function () {
  8145. if (this._textureLoaded) {
  8146. var a = cc._renderContext,
  8147. c = this._texture;
  8148. c ? c._isLoaded && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2DN(0, c), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.DYNAMIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(0, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(1, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.vertexAttribPointer(2, 2, a.FLOAT, !1, 24, 16), a.drawArrays(a.TRIANGLE_STRIP, 0, 4)) : (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2D(null), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (cc._renderContext.bufferData(cc._renderContext.ARRAY_BUFFER, this._quad.arrayBuffer, cc._renderContext.STATIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4));
  8149. cc.g_NumberOfDraws++;
  8150. if (0 !== cc.SPRITE_DEBUG_DRAW || this._showNode) 1 === cc.SPRITE_DEBUG_DRAW || this._showNode ? (a = this._quad, a = [cc.p(a.tl.vertices.x, a.tl.vertices.y), cc.p(a.bl.vertices.x, a.bl.vertices.y), cc.p(a.br.vertices.x, a.br.vertices.y), cc.p(a.tr.vertices.x, a.tr.vertices.y)], cc._drawingUtil.drawPoly(a, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (a = this.getTextureRect(), c = this.getOffsetPosition(), a = [cc.p(c.x, c.y), cc.p(c.x + a.width, c.y), cc.p(c.x + a.width, c.y + a.height), cc.p(c.x, c.y + a.height)], cc._drawingUtil.drawPoly(a, 4, !0))
  8151. }
  8152. };
  8153. delete a
  8154. };
  8155. cc._tmp.PrototypeSprite = function () {
  8156. var a = cc.Sprite.prototype;
  8157. cc.defineGetterSetter(a, "opacityModifyRGB", a.isOpacityModifyRGB, a.setOpacityModifyRGB);
  8158. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  8159. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  8160. cc.defineGetterSetter(a, "flippedX", a.isFlippedX, a.setFlippedX);
  8161. cc.defineGetterSetter(a, "flippedY", a.isFlippedY, a.setFlippedY);
  8162. cc.defineGetterSetter(a, "offsetX", a._getOffsetX);
  8163. cc.defineGetterSetter(a, "offsetY", a._getOffsetY);
  8164. cc.defineGetterSetter(a, "texture", a.getTexture, a.setTexture);
  8165. cc.defineGetterSetter(a, "textureRectRotated", a.isTextureRectRotated);
  8166. cc.defineGetterSetter(a, "batchNode", a.getBatchNode, a.setBatchNode);
  8167. cc.defineGetterSetter(a, "quad", a.getQuad)
  8168. };
  8169. cc.generateTintImageWithMultiply = function (a, b, c, d) {
  8170. d = d || cc.newElement("canvas");
  8171. c = c || cc.rect(0, 0, a.width, a.height);
  8172. var e = d.getContext("2d");
  8173. d.width != c.width || d.height != c.height ? (d.width = c.width, d.height = c.height) : e.globalCompositeOperation = "source-over";
  8174. e.fillStyle = "rgb(" + (0 | b.r) + "," + (0 | b.g) + "," + (0 | b.b) + ")";
  8175. e.fillRect(0, 0, c.width, c.height);
  8176. e.globalCompositeOperation = "multiply";
  8177. e.drawImage(a, c.x, c.y, c.width, c.height, 0, 0, c.width, c.height);
  8178. e.globalCompositeOperation = "destination-atop";
  8179. e.drawImage(a, c.x, c.y, c.width, c.height, 0, 0, c.width, c.height);
  8180. return d
  8181. };
  8182. cc.generateTintImage = function (a, b, c, d, e) {
  8183. d || (d = cc.rect(0, 0, a.width, a.height));
  8184. a = c.r / 255;
  8185. var f = c.g / 255;
  8186. c = c.b / 255;
  8187. var g = Math.min(d.width, b[0].width),
  8188. h = Math.min(d.height, b[0].height),
  8189. k;
  8190. e ? (k = e.getContext("2d"), k.clearRect(0, 0, g, h)) : (e = cc.newElement("canvas"), e.width = g, e.height = h, k = e.getContext("2d"));
  8191. k.save();
  8192. k.globalCompositeOperation = "lighter";
  8193. var m = k.globalAlpha;
  8194. 0 < a && (k.globalAlpha = a * m, k.drawImage(b[0], d.x, d.y, g, h, 0, 0, g, h));
  8195. 0 < f && (k.globalAlpha = f * m, k.drawImage(b[1], d.x, d.y, g, h, 0, 0, g, h));
  8196. 0 < c && (k.globalAlpha = c * m, k.drawImage(b[2], d.x, d.y, g, h, 0, 0, g, h));
  8197. 1 > a + f + c && (k.globalAlpha = m, k.drawImage(b[3], d.x, d.y, g, h, 0, 0, g, h));
  8198. k.restore();
  8199. return e
  8200. };
  8201. cc.generateTextureCacheForColor = function (a) {
  8202. function b() {
  8203. var b = cc.generateTextureCacheForColor,
  8204. d = a.width,
  8205. g = a.height;
  8206. c[0].width = d;
  8207. c[0].height = g;
  8208. c[1].width = d;
  8209. c[1].height = g;
  8210. c[2].width = d;
  8211. c[2].height = g;
  8212. c[3].width = d;
  8213. c[3].height = g;
  8214. b.canvas.width = d;
  8215. b.canvas.height = g;
  8216. var h = b.canvas.getContext("2d");
  8217. h.drawImage(a, 0, 0);
  8218. b.tempCanvas.width = d;
  8219. b.tempCanvas.height = g;
  8220. for (var h = h.getImageData(0, 0, d, g).data, k = 0; 4 > k; k++) {
  8221. var m = c[k].getContext("2d");
  8222. m.getImageData(0, 0, d, g).data;
  8223. b.tempCtx.drawImage(a, 0, 0);
  8224. for (var n = b.tempCtx.getImageData(0, 0, d, g), q = n.data, r = 0; r < h.length; r += 4) q[r] = 0 === k ? h[r] : 0,
  8225. q[r + 1] = 1 === k ? h[r + 1] : 0,
  8226. q[r + 2] = 2 === k ? h[r + 2] : 0,
  8227. q[r + 3] = h[r + 3];
  8228. m.putImageData(n, 0, 0)
  8229. }
  8230. a.onload = null
  8231. }
  8232. if (a.channelCache) return a.channelCache;
  8233. var c = [cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas"), cc.newElement("canvas")];
  8234. try {
  8235. b()
  8236. } catch (d) {
  8237. a.onload = b
  8238. }
  8239. return a.channelCache = c
  8240. };
  8241. cc.generateTextureCacheForColor.canvas = cc.newElement("canvas");
  8242. cc.generateTextureCacheForColor.tempCanvas = cc.newElement("canvas");
  8243. cc.generateTextureCacheForColor.tempCtx = cc.generateTextureCacheForColor.tempCanvas.getContext("2d");
  8244. cc.cutRotateImageToCanvas = function (a, b) {
  8245. if (!a) return null;
  8246. if (!b) return a;
  8247. var c = cc.newElement("canvas");
  8248. c.width = b.width;
  8249. c.height = b.height;
  8250. var d = c.getContext("2d");
  8251. d.translate(c.width / 2, c.height / 2);
  8252. d.rotate(-1.5707963267948966);
  8253. d.drawImage(a, b.x, b.y, b.height, b.width, -b.height / 2, -b.width / 2, b.height, b.width);
  8254. return c
  8255. };
  8256. cc._getCompositeOperationByBlendFunc = function (a) {
  8257. return a ? 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" : "source"
  8258. };
  8259. cc.Sprite = cc.Node.extend({
  8260. dirty: !1,
  8261. atlasIndex: 0,
  8262. textureAtlas: null,
  8263. _batchNode: null,
  8264. _recursiveDirty: null,
  8265. _hasChildren: null,
  8266. _shouldBeHidden: !1,
  8267. _transformToBatch: null,
  8268. _blendFunc: null,
  8269. _texture: null,
  8270. _rect: null,
  8271. _rectRotated: !1,
  8272. _offsetPosition: null,
  8273. _unflippedOffsetPositionFromCenter: null,
  8274. _opacityModifyRGB: !1,
  8275. _flippedX: !1,
  8276. _flippedY: !1,
  8277. _textureLoaded: !1,
  8278. _loadedEventListeners: null,
  8279. _newTextureWhenChangeColor: null,
  8280. _className: "Sprite",
  8281. _oldDisplayColor: cc.color.WHITE,
  8282. textureLoaded: function () {
  8283. return this._textureLoaded
  8284. },
  8285. addLoadedEventListener: function (a, b) {
  8286. this._loadedEventListeners || (this._loadedEventListeners = []);
  8287. this._loadedEventListeners.push({
  8288. eventCallback: a,
  8289. eventTarget: b
  8290. })
  8291. },
  8292. _callLoadedEventCallbacks: function () {
  8293. if (this._loadedEventListeners) {
  8294. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  8295. var d = a[b];
  8296. d.eventCallback.call(d.eventTarget, this)
  8297. }
  8298. a.length = 0
  8299. }
  8300. },
  8301. isDirty: function () {
  8302. return this.dirty
  8303. },
  8304. setDirty: function (a) {
  8305. this.dirty = a
  8306. },
  8307. isTextureRectRotated: function () {
  8308. return this._rectRotated
  8309. },
  8310. getAtlasIndex: function () {
  8311. return this.atlasIndex
  8312. },
  8313. setAtlasIndex: function (a) {
  8314. this.atlasIndex = a
  8315. },
  8316. getTextureRect: function () {
  8317. return cc.rect(this._rect.x, this._rect.y, this._rect.width, this._rect.height)
  8318. },
  8319. getTextureAtlas: function () {
  8320. return this.textureAtlas
  8321. },
  8322. setTextureAtlas: function (a) {
  8323. this.textureAtlas = a
  8324. },
  8325. getOffsetPosition: function () {
  8326. return cc.p(this._offsetPosition)
  8327. },
  8328. _getOffsetX: function () {
  8329. return this._offsetPosition.x
  8330. },
  8331. _getOffsetY: function () {
  8332. return this._offsetPosition.y
  8333. },
  8334. getBlendFunc: function () {
  8335. return this._blendFunc
  8336. },
  8337. initWithSpriteFrame: function (a) {
  8338. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrame);
  8339. a.textureLoaded() || (this._textureLoaded = !1, a.addLoadedEventListener(this._spriteFrameLoadedCallback, this));
  8340. var b = cc._renderType === cc._RENDER_TYPE_CANVAS ? !1 : a._rotated,
  8341. b = this.initWithTexture(a.getTexture(), a.getRect(), b);
  8342. this.setSpriteFrame(a);
  8343. return b
  8344. },
  8345. _spriteFrameLoadedCallback: null,
  8346. initWithSpriteFrameName: function (a) {
  8347. cc.assert(a, cc._LogInfos.Sprite_initWithSpriteFrameName);
  8348. var b = cc.spriteFrameCache.getSpriteFrame(a);
  8349. cc.assert(b, a + cc._LogInfos.Sprite_initWithSpriteFrameName1);
  8350. return this.initWithSpriteFrame(b)
  8351. },
  8352. useBatchNode: function (a) {
  8353. this.textureAtlas = a.textureAtlas;
  8354. this._batchNode = a
  8355. },
  8356. setVertexRect: function (a) {
  8357. this._rect.x = a.x;
  8358. this._rect.y = a.y;
  8359. this._rect.width = a.width;
  8360. this._rect.height = a.height
  8361. },
  8362. sortAllChildren: function () {
  8363. if (this._reorderChildDirty) {
  8364. var a = this._children,
  8365. b = a.length,
  8366. c,
  8367. d,
  8368. e;
  8369. for (c = 1; c < b; c++) {
  8370. e = a[c];
  8371. for (d = c - 1; 0 <= d;) {
  8372. if (e._localZOrder < a[d]._localZOrder) a[d + 1] = a[d];
  8373. else if (e._localZOrder === a[d]._localZOrder && e.arrivalOrder < a[d].arrivalOrder) a[d + 1] = a[d];
  8374. else break;
  8375. d--
  8376. }
  8377. a[d + 1] = e
  8378. }
  8379. this._batchNode && this._arrayMakeObjectsPerformSelector(a, cc.Node._StateCallbackType.sortAllChildren);
  8380. this._reorderChildDirty = !1
  8381. }
  8382. },
  8383. reorderChild: function (a, b) {
  8384. cc.assert(a, 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))
  8385. },
  8386. removeChild: function (a, b) {
  8387. this._batchNode && this._batchNode.removeSpriteFromAtlas(a);
  8388. cc.Node.prototype.removeChild.call(this, a, b)
  8389. },
  8390. setVisible: function (a) {
  8391. cc.Node.prototype.setVisible.call(this, a);
  8392. this.setDirtyRecursively(!0)
  8393. },
  8394. removeAllChildren: function (a) {
  8395. var b = this._children,
  8396. c = this._batchNode;
  8397. if (c && null != b) for (var d = 0, e = b.length; d < e; d++) c.removeSpriteFromAtlas(b[d]);
  8398. cc.Node.prototype.removeAllChildren.call(this, a);
  8399. this._hasChildren = !1
  8400. },
  8401. setDirtyRecursively: function (a) {
  8402. this.dirty = this._recursiveDirty = a;
  8403. a = this._children;
  8404. for (var b, c = a ? a.length : 0, d = 0; d < c; d++) b = a[d],
  8405. b instanceof cc.Sprite && b.setDirtyRecursively(!0)
  8406. },
  8407. setNodeDirty: function (a) {
  8408. cc.Node.prototype.setNodeDirty.call(this);
  8409. a || !this._batchNode || this._recursiveDirty || (this._hasChildren ? this.setDirtyRecursively(!0) : this.dirty = this._recursiveDirty = !0)
  8410. },
  8411. ignoreAnchorPointForPosition: function (a) {
  8412. this._batchNode ? cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition) : cc.Node.prototype.ignoreAnchorPointForPosition.call(this, a)
  8413. },
  8414. setFlippedX: function (a) {
  8415. this._flippedX != a && (this._flippedX = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  8416. },
  8417. setFlippedY: function (a) {
  8418. this._flippedY != a && (this._flippedY = a, this.setTextureRect(this._rect, this._rectRotated, this._contentSize), this.setNodeDirty(!0))
  8419. },
  8420. isFlippedX: function () {
  8421. return this._flippedX
  8422. },
  8423. isFlippedY: function () {
  8424. return this._flippedY
  8425. },
  8426. setOpacityModifyRGB: null,
  8427. isOpacityModifyRGB: function () {
  8428. return this._opacityModifyRGB
  8429. },
  8430. updateDisplayedOpacity: null,
  8431. setDisplayFrameWithAnimationName: function (a, b) {
  8432. cc.assert(a, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
  8433. var c = cc.animationCache.getAnimation(a);
  8434. c ? (c = c.getFrames()[b]) ? this.setSpriteFrame(c.getSpriteFrame()) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2) : cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName)
  8435. },
  8436. getBatchNode: function () {
  8437. return this._batchNode
  8438. },
  8439. _setReorderChildDirtyRecursively: function () {
  8440. if (!this._reorderChildDirty) {
  8441. this._reorderChildDirty = !0;
  8442. for (var a = this._parent; a && a != this._batchNode;) a._setReorderChildDirtyRecursively(),
  8443. a = a.parent
  8444. }
  8445. },
  8446. getTexture: function () {
  8447. return this._texture
  8448. },
  8449. _quad: null,
  8450. _quadWebBuffer: null,
  8451. _quadDirty: !1,
  8452. _colorized: !1,
  8453. _blendFuncStr: "source",
  8454. _originalTexture: null,
  8455. _textureRect_Canvas: null,
  8456. _drawSize_Canvas: null,
  8457. ctor: null,
  8458. _softInit: function (a, b, c) {
  8459. if (void 0 === a) cc.Sprite.prototype.init.call(this);
  8460. 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);
  8461. else if (cc.isObject(a)) if (a instanceof
  8462. cc.Texture2D) this.initWithTexture(a, b, c);
  8463. else if (a instanceof cc.SpriteFrame) this.initWithSpriteFrame(a);
  8464. else if (a instanceof HTMLImageElement || a instanceof HTMLCanvasElement) b = new cc.Texture2D,
  8465. b.initWithElement(a),
  8466. b.handleLoadedTexture(),
  8467. this.initWithTexture(b)
  8468. },
  8469. getQuad: function () {
  8470. return this._quad
  8471. },
  8472. setBlendFunc: null,
  8473. init: null,
  8474. initWithFile: function (a, b) {
  8475. cc.assert(a, cc._LogInfos.Sprite_initWithFile);
  8476. var c = cc.textureCache.getTextureForKey(a);
  8477. if (c) {
  8478. if (!b) {
  8479. var d = c.getContentSize();
  8480. b = cc.rect(0, 0, d.width, d.height)
  8481. }
  8482. return this.initWithTexture(c, b)
  8483. }
  8484. c = cc.textureCache.addImage(a);
  8485. return this.initWithTexture(c, b || cc.rect(0, 0, c._contentSize.width, c._contentSize.height))
  8486. },
  8487. initWithTexture: null,
  8488. _textureLoadedCallback: null,
  8489. setTextureRect: null,
  8490. updateTransform: null,
  8491. addChild: null,
  8492. updateColor: function () {
  8493. var a = this._displayedColor,
  8494. b = this._displayedOpacity,
  8495. a = {
  8496. r: a.r,
  8497. g: a.g,
  8498. b: a.b,
  8499. a: b
  8500. };
  8501. this._opacityModifyRGB && (a.r *= b / 255, a.g *= b / 255, a.b *= b / 255);
  8502. b = this._quad;
  8503. b.bl.colors = a;
  8504. b.br.colors = a;
  8505. b.tl.colors = a;
  8506. b.tr.colors = a;
  8507. this._batchNode && (this.atlasIndex != cc.Sprite.INDEX_NOT_INITIALIZED ? this.textureAtlas.updateQuad(b, this.atlasIndex) : this.dirty = !0);
  8508. this._quadDirty = !0
  8509. },
  8510. setOpacity: null,
  8511. setColor: null,
  8512. updateDisplayedColor: null,
  8513. setSpriteFrame: null,
  8514. setDisplayFrame: function (a) {
  8515. cc.log(cc._LogInfos.Sprite_setDisplayFrame);
  8516. this.setSpriteFrame(a)
  8517. },
  8518. isFrameDisplayed: null,
  8519. displayFrame: function () {
  8520. return cc.SpriteFrame.create(this._texture, cc.rectPointsToPixels(this._rect), this._rectRotated, cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter), cc.sizePointsToPixels(this._contentSize))
  8521. },
  8522. setBatchNode: null,
  8523. setTexture: null,
  8524. _updateBlendFunc: function () {
  8525. this._batchNode ? cc.log(cc._LogInfos.Sprite__updateBlendFunc) : this._texture && this._texture.hasPremultipliedAlpha() ? (this._blendFunc.src = cc.BLEND_SRC, this._blendFunc.dst = cc.BLEND_DST, this.opacityModifyRGB = !0) : (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA, this.opacityModifyRGB = !1)
  8526. },
  8527. _changeTextureColor: function () {
  8528. var a,
  8529. b = this._texture,
  8530. c = this._textureRect_Canvas;
  8531. b && c.validRect && this._originalTexture && (a = b.getHtmlElementObj()) && (this._colorized = !0, a instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor && this._originalTexture._htmlElementObj != a ? cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, c, a) : (a = cc.generateTintImageWithMultiply(this._originalTexture._htmlElementObj, this._displayedColor, c), b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.texture = b))
  8532. },
  8533. _setTextureCoords: function (a) {
  8534. a = cc.rectPointsToPixels(a);
  8535. var b = this._batchNode ? this.textureAtlas.texture : this._texture;
  8536. if (b) {
  8537. var c = b.pixelsWidth,
  8538. d = b.pixelsHeight,
  8539. e,
  8540. f = this._quad;
  8541. this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.height - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.width - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.height) / c, e = a.y / d, a = (a.y + a.width) / d), this._flippedX && (d = e, e = a, a = d), this._flippedY && (d = b, b = c, c = d), f.bl.texCoords.u = b, f.bl.texCoords.v = e, f.br.texCoords.u = b, f.br.texCoords.v = a, f.tl.texCoords.u = c, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.width - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.height - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.width) / c, e = a.y / d, a = (a.y + a.height) / d), this._flippedX && (d = b, b = c, c = d), this._flippedY && (d = e, e = a, a = d), f.bl.texCoords.u = b, f.bl.texCoords.v = a, f.br.texCoords.u = c, f.br.texCoords.v = a, f.tl.texCoords.u = b, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = e);
  8542. this._quadDirty = !0
  8543. }
  8544. },
  8545. draw: null
  8546. });
  8547. cc.Sprite.create = function (a, b, c) {
  8548. return new cc.Sprite(a, b, c)
  8549. };
  8550. cc.Sprite.createWithTexture = cc.Sprite.create;
  8551. cc.Sprite.createWithSpriteFrameName = cc.Sprite.create;
  8552. cc.Sprite.createWithSpriteFrame = cc.Sprite.create;
  8553. cc.Sprite.INDEX_NOT_INITIALIZED = -1;
  8554. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Sprite.prototype, _p._spriteFrameLoadedCallback = function (a) {
  8555. this.setNodeDirty(!0);
  8556. this.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8557. a = this.color;
  8558. 255 === a.r && 255 === a.g && 255 === a.b || this._changeTextureColor();
  8559. this._callLoadedEventCallbacks()
  8560. },
  8561. _p.setOpacityModifyRGB = function (a) {
  8562. this._opacityModifyRGB !== a && (this._opacityModifyRGB = a, this.setNodeDirty(!0))
  8563. },
  8564. _p.updateDisplayedOpacity = function (a) {
  8565. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  8566. this._setNodeDirtyForCache()
  8567. },
  8568. _p.ctor = function (a, b, c) {
  8569. cc.Node.prototype.ctor.call(this);
  8570. this._shouldBeHidden = !1;
  8571. this._offsetPosition = cc.p(0, 0);
  8572. this._unflippedOffsetPositionFromCenter = cc.p(0, 0);
  8573. this._blendFunc = {
  8574. src: cc.BLEND_SRC,
  8575. dst: cc.BLEND_DST
  8576. };
  8577. this._rect = cc.rect(0, 0, 0, 0);
  8578. this._newTextureWhenChangeColor = !1;
  8579. this._textureLoaded = !0;
  8580. this._textureRect_Canvas = {
  8581. x: 0,
  8582. y: 0,
  8583. width: 0,
  8584. height: 0,
  8585. validRect: !1
  8586. };
  8587. this._drawSize_Canvas = cc.size(0, 0);
  8588. this._softInit(a, b, c)
  8589. },
  8590. _p.setBlendFunc = function (a, b) {
  8591. var c = this._blendFunc;
  8592. void 0 === b ? (c.src = a.src, c.dst = a.dst) : (c.src = a, c.dst = b);
  8593. cc._renderType === cc._RENDER_TYPE_CANVAS && (this._blendFuncStr = cc._getCompositeOperationByBlendFunc(c))
  8594. },
  8595. _p.init = function () {
  8596. if (0 < arguments.length) return this.initWithFile(arguments[0], arguments[1]);
  8597. cc.Node.prototype.init.call(this);
  8598. this.dirty = this._recursiveDirty = !1;
  8599. this._opacityModifyRGB = !0;
  8600. this._blendFunc.src = cc.BLEND_SRC;
  8601. this._blendFunc.dst = cc.BLEND_DST;
  8602. this.texture = null;
  8603. this._textureLoaded = !0;
  8604. this._flippedX = this._flippedY = !1;
  8605. this.anchorY = this.anchorX = 0.5;
  8606. this._offsetPosition.x = 0;
  8607. this._offsetPosition.y = 0;
  8608. this._hasChildren = !1;
  8609. this.setTextureRect(cc.rect(0, 0, 0, 0), !1, cc.size(0, 0));
  8610. return !0
  8611. },
  8612. _p.initWithTexture = function (a, b, c) {
  8613. cc.assert(0 != arguments.length, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
  8614. if ((c = c || !1) && a.isLoaded()) {
  8615. var d = a.getHtmlElementObj(),
  8616. d = cc.cutRotateImageToCanvas(d, b),
  8617. e = new cc.Texture2D;
  8618. e.initWithElement(d);
  8619. e.handleLoadedTexture();
  8620. a = e;
  8621. this._rect = cc.rect(0, 0, b.width, b.height)
  8622. }
  8623. if (!cc.Node.prototype.init.call(this)) return !1;
  8624. this._batchNode = null;
  8625. this.dirty = this._recursiveDirty = !1;
  8626. this._opacityModifyRGB = !0;
  8627. this._blendFunc.src = cc.BLEND_SRC;
  8628. this._blendFunc.dst = cc.BLEND_DST;
  8629. this._flippedX = this._flippedY = !1;
  8630. this.anchorY = this.anchorX = 0.5;
  8631. this._offsetPosition.x = 0;
  8632. this._offsetPosition.y = 0;
  8633. this._hasChildren = !1;
  8634. this._textureLoaded = d = a.isLoaded();
  8635. if (!d) return this._rectRotated = c,
  8636. b && (this._rect.x = b.x, this._rect.y = b.y, this._rect.width = b.width, this._rect.height = b.height),
  8637. this.texture && this.texture.removeLoadedEventListener(this),
  8638. a.addLoadedEventListener(this._textureLoadedCallback, this),
  8639. this.texture = a,
  8640. !0;
  8641. b || (b = cc.rect(0, 0, a.width, a.height));
  8642. a && a.url && (d = b.y + b.height, b.x + b.width > a.width && cc.error(cc._LogInfos.RectWidth, a.url), d > a.height && cc.error(cc._LogInfos.RectHeight, a.url));
  8643. this.texture = this._originalTexture = a;
  8644. this.setTextureRect(b, c);
  8645. this.batchNode = null;
  8646. return !0
  8647. },
  8648. _p._textureLoadedCallback = function (a) {
  8649. if (!this._textureLoaded) {
  8650. this._textureLoaded = !0;
  8651. var b = this._rect;
  8652. b ? cc._rectEqualToZero(b) && (b.width = a.width, b.height = a.height) : b = cc.rect(0, 0, a.width, a.height);
  8653. this.texture = this._originalTexture = a;
  8654. this.setTextureRect(b, this._rectRotated);
  8655. a = this._displayedColor;
  8656. 255 == a.r && 255 == a.g && 255 == a.b || this._changeTextureColor();
  8657. this.batchNode = this._batchNode;
  8658. this._callLoadedEventCallbacks()
  8659. }
  8660. },
  8661. _p.setTextureRect = function (a, b, c) {
  8662. this._rectRotated = b || !1;
  8663. this.setContentSize(c || a);
  8664. this.setVertexRect(a);
  8665. b = this._textureRect_Canvas;
  8666. c = cc.contentScaleFactor();
  8667. b.x = 0 | a.x * c;
  8668. b.y = 0 | a.y * c;
  8669. b.width = 0 | a.width * c;
  8670. b.height = 0 | a.height * c;
  8671. b.validRect = !(0 === b.width || 0 === b.height || 0 > b.x || 0 > b.y);
  8672. a = this._unflippedOffsetPositionFromCenter;
  8673. this._flippedX && (a.x = -a.x);
  8674. this._flippedY && (a.y = -a.y);
  8675. this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
  8676. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  8677. this._batchNode && (this.dirty = !0)
  8678. },
  8679. _p.updateTransform = function () {
  8680. if (this.dirty) {
  8681. var a = this._parent; !this._visible || a && a != this._batchNode && a._shouldBeHidden ? this._shouldBeHidden = !0 : (this._shouldBeHidden = !1, this._transformToBatch = a && a != this._batchNode ? cc.affineTransformConcat(this.nodeToParentTransform(), a._transformToBatch) : this.nodeToParentTransform());
  8682. this.dirty = this._recursiveDirty = !1
  8683. }
  8684. this._hasChildren && this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform)
  8685. },
  8686. _p.addChild = function (a, b, c) {
  8687. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_addChild_2);
  8688. null == b && (b = a._localZOrder);
  8689. null == c && (c = a.tag);
  8690. cc.Node.prototype.addChild.call(this, a, b, c);
  8691. this._hasChildren = !0
  8692. },
  8693. _p.setOpacity = function (a) {
  8694. cc.Node.prototype.setOpacity.call(this, a);
  8695. this._setNodeDirtyForCache()
  8696. },
  8697. _p.setColor = function (a) {
  8698. var b = this.color;
  8699. this._oldDisplayColor = b;
  8700. b.r === a.r && b.g === a.g && b.b === a.b || cc.Node.prototype.setColor.call(this, a)
  8701. },
  8702. _p.updateDisplayedColor = function (a) {
  8703. cc.Node.prototype.updateDisplayedColor.call(this, a);
  8704. a = this._oldDisplayColor;
  8705. var b = this._displayedColor;
  8706. if (a.r !== b.r || a.g !== b.g || a.b !== b.b) this._changeTextureColor(),
  8707. this._setNodeDirtyForCache()
  8708. },
  8709. _p.setSpriteFrame = function (a) {
  8710. var b = this;
  8711. cc.isString(a) && (a = cc.spriteFrameCache.getSpriteFrame(a), cc.assert(a, cc._LogInfos.CCSpriteBatchNode_setSpriteFrame));
  8712. b.setNodeDirty(!0);
  8713. var c = a.getOffset();
  8714. b._unflippedOffsetPositionFromCenter.x = c.x;
  8715. b._unflippedOffsetPositionFromCenter.y = c.y;
  8716. b._rectRotated = a.isRotated();
  8717. var c = a.getTexture(),
  8718. d = a.textureLoaded();
  8719. d || (b._textureLoaded = !1, a.addLoadedEventListener(function (a) {
  8720. b._textureLoaded = !0;
  8721. var c = a.getTexture();
  8722. c != b._texture && (b.texture = c);
  8723. b.setTextureRect(a.getRect(), a.isRotated(), a.getOriginalSize());
  8724. b._callLoadedEventCallbacks()
  8725. },
  8726. b));
  8727. c != b._texture && (b.texture = c);
  8728. b._rectRotated && (b._originalTexture = c);
  8729. b.setTextureRect(a.getRect(), b._rectRotated, a.getOriginalSize());
  8730. b._colorized = !1;
  8731. d && (a = b.color, 255 === a.r && 255 === a.g && 255 === a.b || b._changeTextureColor())
  8732. },
  8733. _p.isFrameDisplayed = function (a) {
  8734. return a.getTexture() != this._texture ? !1 : cc.rectEqualToRect(a.getRect(), this._rect)
  8735. },
  8736. _p.setBatchNode = function (a) {
  8737. (this._batchNode = a) ? (this._transformToBatch = cc.affineTransformIdentity(), this.textureAtlas = this._batchNode.textureAtlas) : (this.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED, this.textureAtlas = null, this.dirty = this._recursiveDirty = !1)
  8738. },
  8739. _p.setTexture = function (a) {
  8740. a && cc.isString(a) ? (a = cc.textureCache.addImage(a), this.setTexture(a), a = a.getContentSize(), this.setTextureRect(cc.rect(0, 0, a.width, a.height))) : (cc.assert(!a || a instanceof cc.Texture2D, cc._LogInfos.CCSpriteBatchNode_setTexture), this._texture != a && (a && a.getHtmlElementObj() instanceof HTMLImageElement && (this._originalTexture = a), this._texture = a))
  8741. },
  8742. _p.draw = function (a) {
  8743. if (this._textureLoaded) {
  8744. a = a || cc._renderContext;
  8745. "source" != this._blendFuncStr && (a.globalCompositeOperation = this._blendFuncStr);
  8746. var b = cc.view.getScaleX(),
  8747. c = cc.view.getScaleY();
  8748. a.globalAlpha = this._displayedOpacity / 255;
  8749. var d = this._rect,
  8750. e = this._contentSize,
  8751. f = this._offsetPosition,
  8752. g = this._drawSize_Canvas,
  8753. h = 0 | f.x,
  8754. k = -f.y - d.height,
  8755. m = this._textureRect_Canvas;
  8756. g.width = d.width * b;
  8757. g.height = d.height * c;
  8758. if (this._flippedX || this._flippedY) a.save(),
  8759. this._flippedX && (h = -f.x - d.width, a.scale(-1, 1)),
  8760. this._flippedY && (k = f.y, a.scale(1, -1));
  8761. h *= b;
  8762. k *= c;
  8763. this._texture && m.validRect ? (e = this._texture.getHtmlElementObj(), this._colorized ? a.drawImage(e, 0, 0, m.width, m.height, h, k, g.width, g.height) : a.drawImage(e, m.x, m.y, m.width, m.height, h, k, g.width, g.height)) : !this._texture && m.validRect && (g = this.color, a.fillStyle = "rgba(" + g.r + "," + g.g + "," + g.b + ",1)", a.fillRect(h, k, e.width * b, e.height * c));
  8764. 1 === cc.SPRITE_DEBUG_DRAW || this._showNode ? (a.strokeStyle = "rgba(0,255,0,1)", h /= b, k = -(k / c), h = [cc.p(h, k), cc.p(h + d.width, k), cc.p(h + d.width, k - d.height), cc.p(h, k - d.height)], cc._drawingUtil.drawPoly(h, 4, !0)) : 2 === cc.SPRITE_DEBUG_DRAW && (a.strokeStyle = "rgba(0,255,0,1)", b = this._rect, k = -k, h = [cc.p(h, k), cc.p(h + b.width, k), cc.p(h + b.width, k - b.height), cc.p(h, k - b.height)], cc._drawingUtil.drawPoly(h, 4, !0)); (this._flippedX || this._flippedY) && a.restore();
  8765. cc.g_NumberOfDraws++
  8766. }
  8767. },
  8768. cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function () {
  8769. var a,
  8770. b = this._texture,
  8771. c = this._textureRect_Canvas;
  8772. b && c.validRect && this._originalTexture && (a = b.getHtmlElementObj()) && (b = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj())) && (this._colorized = !0, a instanceof HTMLCanvasElement && !this._rectRotated && !this._newTextureWhenChangeColor ? cc.generateTintImage(a, b, this._displayedColor, c, a) : (a = cc.generateTintImage(a, b, this._displayedColor, c), b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture(), this.texture = b))
  8773. }), delete _p) : (cc.assert(cc.isFunction(cc._tmp.WebGLSprite), cc._LogInfos.MissingFile, "SpritesWebGL.js"), cc._tmp.WebGLSprite(), delete cc._tmp.WebGLSprite);
  8774. cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
  8775. cc._tmp.PrototypeSprite();
  8776. delete cc._tmp.PrototypeSprite;
  8777. cc.DEFAULT_SPRITE_BATCH_CAPACITY = 29;
  8778. cc.SpriteBatchNode = cc.Node.extend({
  8779. textureAtlas: null,
  8780. _blendFunc: null,
  8781. _descendants: null,
  8782. _className: "SpriteBatchNode",
  8783. addSpriteWithoutQuad: function (a, b, c) {
  8784. cc.assert(a, cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2);
  8785. if (!(a instanceof cc.Sprite)) return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad),
  8786. null;
  8787. a.atlasIndex = b;
  8788. var d = 0,
  8789. e = this._descendants;
  8790. if (e && 0 < e.length) for (var f = 0; f < e.length; f++) {
  8791. var g = e[f];
  8792. g && g.atlasIndex >= b && ++d
  8793. }
  8794. e.splice(d, 0, a);
  8795. cc.Node.prototype.addChild.call(this, a, b, c);
  8796. this.reorderBatch(!1);
  8797. return this
  8798. },
  8799. getTextureAtlas: function () {
  8800. return this.textureAtlas
  8801. },
  8802. setTextureAtlas: function (a) {
  8803. a != this.textureAtlas && (this.textureAtlas = a)
  8804. },
  8805. getDescendants: function () {
  8806. return this._descendants
  8807. },
  8808. initWithFile: function (a, b) {
  8809. var c = cc.textureCache.getTextureForKey(a);
  8810. c || (c = cc.textureCache.addImage(a));
  8811. return this.initWithTexture(c, b)
  8812. },
  8813. _setNodeDirtyForCache: function () {
  8814. this._cacheDirty = !0
  8815. },
  8816. init: function (a, b) {
  8817. var c = cc.textureCache.getTextureForKey(a);
  8818. c || (c = cc.textureCache.addImage(a));
  8819. return this.initWithTexture(c, b)
  8820. },
  8821. increaseAtlasCapacity: function () {
  8822. var a = this.textureAtlas.capacity,
  8823. b = Math.floor(4 * (a + 1) / 3);
  8824. cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity, a, b);
  8825. this.textureAtlas.resizeCapacity(b) || cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)
  8826. },
  8827. removeChildAtIndex: function (a, b) {
  8828. this.removeChild(this._children[a], b)
  8829. },
  8830. rebuildIndexInOrder: function (a, b) {
  8831. var c = a.children;
  8832. if (c && 0 < c.length) for (var d = 0; d < c.length; d++) {
  8833. var e = c[d];
  8834. e && 0 > e.zIndex && (b = this.rebuildIndexInOrder(e, b))
  8835. } !a == this && (a.atlasIndex = b, b++);
  8836. if (c && 0 < c.length) for (d = 0; d < c.length; d++) (e = c[d]) && 0 <= e.zIndex && (b = this.rebuildIndexInOrder(e, b));
  8837. return b
  8838. },
  8839. highestAtlasIndexInChild: function (a) {
  8840. var b = a.children;
  8841. return b && 0 != b.length ? this.highestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex
  8842. },
  8843. lowestAtlasIndexInChild: function (a) {
  8844. var b = a.children;
  8845. return b && 0 != b.length ? this.lowestAtlasIndexInChild(b[b.length - 1]) : a.atlasIndex
  8846. },
  8847. atlasIndexForChild: function (a, b) {
  8848. var c = a.parent,
  8849. d = c.children,
  8850. e = d.indexOf(a),
  8851. f = null;
  8852. 0 < e && e < cc.UINT_MAX && (f = d[e - 1]);
  8853. 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
  8854. },
  8855. reorderBatch: function (a) {
  8856. this._reorderChildDirty = a
  8857. },
  8858. setBlendFunc: function (a, b) {
  8859. this._blendFunc = void 0 === b ? a : {
  8860. src: a,
  8861. dst: b
  8862. }
  8863. },
  8864. getBlendFunc: function () {
  8865. return this._blendFunc
  8866. },
  8867. reorderChild: function (a, b) {
  8868. 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), this.setNodeDirty())
  8869. },
  8870. removeChild: function (a, b) {
  8871. null != a && (-1 === this._children.indexOf(a) ? cc.log(cc._LogInfos.SpriteBatchNode_removeChild) : (this.removeSpriteFromAtlas(a), cc.Node.prototype.removeChild.call(this, a, b)))
  8872. },
  8873. _mvpMatrix: null,
  8874. _textureForCanvas: null,
  8875. _useCache: !1,
  8876. _originalTexture: null,
  8877. ctor: null,
  8878. _ctorForCanvas: function (a, b) {
  8879. cc.Node.prototype.ctor.call(this);
  8880. var c;
  8881. b = b || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8882. cc.isString(a) ? (c = cc.textureCache.getTextureForKey(a)) || (c = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (c = a);
  8883. c && this.initWithTexture(c, b)
  8884. },
  8885. _ctorForWebGL: function (a, b) {
  8886. cc.Node.prototype.ctor.call(this);
  8887. this._mvpMatrix = new cc.kmMat4;
  8888. var c;
  8889. b = b || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8890. cc.isString(a) ? (c = cc.textureCache.getTextureForKey(a)) || (c = cc.textureCache.addImage(a)) : a instanceof cc.Texture2D && (c = a);
  8891. c && this.initWithTexture(c, b)
  8892. },
  8893. updateQuadFromSprite: null,
  8894. _updateQuadFromSpriteForCanvas: function (a, b) {
  8895. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2);
  8896. a instanceof cc.Sprite ? (a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform()) : cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
  8897. },
  8898. _updateQuadFromSpriteForWebGL: function (a, b) {
  8899. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite);
  8900. if (a instanceof cc.Sprite) {
  8901. for (var c = this.textureAtlas.capacity; b >= c || c == this.textureAtlas.totalQuads;) this.increaseAtlasCapacity();
  8902. a.batchNode = this;
  8903. a.atlasIndex = b;
  8904. a.dirty = !0;
  8905. a.updateTransform()
  8906. } else cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)
  8907. },
  8908. _swap: function (a, b) {
  8909. var c = this._descendants,
  8910. d = this.textureAtlas,
  8911. e = d.quads,
  8912. f = c[a],
  8913. g = cc.V3F_C4B_T2F_QuadCopy(e[a]);
  8914. c[b].atlasIndex = a;
  8915. c[a] = c[b];
  8916. d.updateQuad(e[b], a);
  8917. c[b] = f;
  8918. d.updateQuad(g, b)
  8919. },
  8920. insertQuadFromSprite: null,
  8921. _insertQuadFromSpriteForCanvas: function (a, b) {
  8922. cc.assert(a, cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2);
  8923. a instanceof cc.Sprite ? (a.batchNode = this, a.atlasIndex = b, a.dirty = !0, a.updateTransform(), a._setCachedParent(this), this._children.splice(b, 0, a)) : cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite)
  8924. },
  8925. _insertQuadFromSpriteForWebGL: function (a, b) {
  8926. cc.assert(a, cc._LogInfos.Sprite_insertQuadFromSprite_2);
  8927. if (a instanceof cc.Sprite) {
  8928. for (var c = this.textureAtlas; b >= c.capacity || c.capacity === c.totalQuads;) this.increaseAtlasCapacity();
  8929. a.batchNode = this;
  8930. a.atlasIndex = b;
  8931. c.insertQuad(a.quad, b);
  8932. a.dirty = !0;
  8933. a.updateTransform()
  8934. } else cc.log(cc._LogInfos.Sprite_insertQuadFromSprite)
  8935. },
  8936. _updateAtlasIndex: function (a, b) {
  8937. var c = 0,
  8938. d = a.children;
  8939. d && (c = d.length);
  8940. var e = 0;
  8941. if (0 === c) e = a.atlasIndex,
  8942. a.atlasIndex = b,
  8943. a.arrivalOrder = 0,
  8944. e != b && this._swap(e, b),
  8945. b++;
  8946. else {
  8947. e = !0;
  8948. 0 <= d[0].zIndex && (e = a.atlasIndex, a.atlasIndex = b, a.arrivalOrder = 0, e != b && this._swap(e, b), b++, e = !1);
  8949. for (c = 0; c < d.length; c++) {
  8950. var f = d[c];
  8951. e && 0 <= f.zIndex && (e = a.atlasIndex, a.atlasIndex = b, a.arrivalOrder = 0, e != b && this._swap(e, b), b++, e = !1);
  8952. b = this._updateAtlasIndex(f, b)
  8953. }
  8954. e && (e = a.atlasIndex, a.atlasIndex = b, a.arrivalOrder = 0, e != b && this._swap(e, b), b++)
  8955. }
  8956. return b
  8957. },
  8958. _updateBlendFunc: function () {
  8959. this.textureAtlas.texture.hasPremultipliedAlpha() || (this._blendFunc.src = cc.SRC_ALPHA, this._blendFunc.dst = cc.ONE_MINUS_SRC_ALPHA)
  8960. },
  8961. initWithTexture: null,
  8962. _initWithTextureForCanvas: function (a, b) {
  8963. this._children = [];
  8964. this._descendants = [];
  8965. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  8966. this._textureForCanvas = this._originalTexture = a;
  8967. return !0
  8968. },
  8969. _initWithTextureForWebGL: function (a, b) {
  8970. this._children = [];
  8971. this._descendants = [];
  8972. this._blendFunc = new cc.BlendFunc(cc.BLEND_SRC, cc.BLEND_DST);
  8973. b = b || cc.DEFAULT_SPRITE_BATCH_CAPACITY;
  8974. this.textureAtlas = new cc.TextureAtlas;
  8975. this.textureAtlas.initWithTexture(a, b);
  8976. this._updateBlendFunc();
  8977. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  8978. return !0
  8979. },
  8980. insertChild: function (a, b) {
  8981. a.batchNode = this;
  8982. a.atlasIndex = b;
  8983. a.dirty = !0;
  8984. var c = this.textureAtlas;
  8985. c.totalQuads >= c.capacity && this.increaseAtlasCapacity();
  8986. c.insertQuad(a.quad, b);
  8987. this._descendants.splice(b, 0, a);
  8988. var c = b + 1,
  8989. d = this._descendants;
  8990. if (d && 0 < d.length) for (; c < d.length; c++) d[c].atlasIndex++;
  8991. var d = a.children,
  8992. e;
  8993. if (d) for (c = 0, l = d.length || 0; c < l; c++) if (e = d[c]) {
  8994. var f = this.atlasIndexForChild(e, e.zIndex);
  8995. this.insertChild(e, f)
  8996. }
  8997. },
  8998. appendChild: null,
  8999. _appendChildForCanvas: function (a) {
  9000. this._reorderChildDirty = !0;
  9001. a.batchNode = this;
  9002. a.dirty = !0;
  9003. this._descendants.push(a);
  9004. a.atlasIndex = this._descendants.length - 1;
  9005. a = a.children;
  9006. for (var b = 0, c = a.length || 0; b < c; b++) this.appendChild(a[b])
  9007. },
  9008. _appendChildForWebGL: function (a) {
  9009. this._reorderChildDirty = !0;
  9010. a.batchNode = this;
  9011. a.dirty = !0;
  9012. this._descendants.push(a);
  9013. var b = this._descendants.length - 1;
  9014. a.atlasIndex = b;
  9015. var c = this.textureAtlas;
  9016. c.totalQuads == c.capacity && this.increaseAtlasCapacity();
  9017. c.insertQuad(a.quad, b);
  9018. a = a.children;
  9019. b = 0;
  9020. for (c = a.length || 0; b < c; b++) this.appendChild(a[b])
  9021. },
  9022. removeSpriteFromAtlas: null,
  9023. _removeSpriteFromAtlasForCanvas: function (a) {
  9024. a.batchNode = null;
  9025. var b = this._descendants,
  9026. c = b.indexOf(a);
  9027. if (-1 != c) {
  9028. b.splice(c, 1);
  9029. for (var d = b.length; c < d; ++c) b[c].atlasIndex--
  9030. }
  9031. if (a = a.children) for (b = 0, c = a.length || 0; b < c; b++) a[b] && this.removeSpriteFromAtlas(a[b])
  9032. },
  9033. _removeSpriteFromAtlasForWebGL: function (a) {
  9034. this.textureAtlas.removeQuadAtIndex(a.atlasIndex);
  9035. a.batchNode = null;
  9036. var b = this._descendants,
  9037. c = b.indexOf(a);
  9038. if (-1 != c) {
  9039. b.splice(c, 1);
  9040. for (var d = b.length; c < d; ++c) b[c].atlasIndex--
  9041. }
  9042. if (a = a.children) for (b = 0, c = a.length || 0; b < c; b++) a[b] && this.removeSpriteFromAtlas(a[b])
  9043. },
  9044. getTexture: null,
  9045. _getTextureForCanvas: function () {
  9046. return this._textureForCanvas
  9047. },
  9048. _getTextureForWebGL: function () {
  9049. return this.textureAtlas.texture
  9050. },
  9051. setTexture: null,
  9052. _setTextureForCanvas: function (a) {
  9053. this._textureForCanvas = a;
  9054. for (var b = this._children, c = 0; c < b.length; c++) b[c].texture = a
  9055. },
  9056. _setTextureForWebGL: function (a) {
  9057. this.textureAtlas.texture = a;
  9058. this._updateBlendFunc()
  9059. },
  9060. visit: null,
  9061. _visitForCanvas: function (a) {
  9062. var b = a || cc._renderContext;
  9063. if (this._visible) {
  9064. b.save();
  9065. this.transform(a);
  9066. var c = this._children;
  9067. if (c) for (this.sortAllChildren(), a = 0; a < c.length; a++) c[a] && c[a].visit(b);
  9068. b.restore()
  9069. }
  9070. },
  9071. _visitForWebGL: function (a) {
  9072. a = a || cc._renderContext;
  9073. if (this._visible) {
  9074. cc.kmGLPushMatrix();
  9075. var b = this.grid;
  9076. b && b.isActive() && (b.beforeDraw(), this.transformAncestors());
  9077. this.sortAllChildren();
  9078. this.transform(a);
  9079. this.draw(a);
  9080. b && b.isActive() && b.afterDraw(this);
  9081. cc.kmGLPopMatrix();
  9082. this.arrivalOrder = 0
  9083. }
  9084. },
  9085. addChild: null,
  9086. _addChildForCanvas: function (a, b, c) {
  9087. cc.assert(null != a, cc._LogInfos.CCSpriteBatchNode_addChild_3);
  9088. a instanceof cc.Sprite ? (b = null == b ? a.zIndex : b, c = null == c ? a.tag : c, cc.Node.prototype.addChild.call(this, a, b, c), this.appendChild(a), this.setNodeDirty()) : cc.log(cc._LogInfos.CCSpriteBatchNode_addChild)
  9089. },
  9090. _addChildForWebGL: function (a, b, c) {
  9091. cc.assert(null != a, cc._LogInfos.Sprite_addChild_6);
  9092. a instanceof cc.Sprite ? a.texture != this.textureAtlas.texture ? cc.log(cc._LogInfos.Sprite_addChild_5) : (b = null == b ? a.zIndex : b, c = null == c ? a.tag : c, cc.Node.prototype.addChild.call(this, a, b, c), this.appendChild(a), this.setNodeDirty()) : cc.log(cc._LogInfos.Sprite_addChild_4)
  9093. },
  9094. removeAllChildren: null,
  9095. _removeAllChildrenForCanvas: function (a) {
  9096. var b = this._descendants;
  9097. if (b && 0 < b.length) for (var c = 0, d = b.length; c < d; c++) b[c] && (b[c].batchNode = null);
  9098. cc.Node.prototype.removeAllChildren.call(this, a);
  9099. this._descendants.length = 0
  9100. },
  9101. _removeAllChildrenForWebGL: function (a) {
  9102. var b = this._descendants;
  9103. if (b && 0 < b.length) for (var c = 0, d = b.length; c < d; c++) b[c] && (b[c].batchNode = null);
  9104. cc.Node.prototype.removeAllChildren.call(this, a);
  9105. this._descendants.length = 0;
  9106. this.textureAtlas.removeAllQuads()
  9107. },
  9108. sortAllChildren: null,
  9109. _sortAllChildrenForCanvas: function () {
  9110. if (this._reorderChildDirty) {
  9111. var a,
  9112. b = 0,
  9113. c = this._children,
  9114. d = c.length,
  9115. e;
  9116. for (a = 1; a < d; a++) {
  9117. var f = c[a],
  9118. b = a - 1;
  9119. for (e = c[b]; 0 <= b && (f._localZOrder < e._localZOrder || f._localZOrder == e._localZOrder && f.arrivalOrder < e.arrivalOrder) ;) c[b + 1] = e,
  9120. b -= 1,
  9121. e = c[b];
  9122. c[b + 1] = f
  9123. }
  9124. 0 < c.length && this._arrayMakeObjectsPerformSelector(c, cc.Node._StateCallbackType.sortAllChildren);
  9125. this._reorderChildDirty = !1
  9126. }
  9127. },
  9128. _sortAllChildrenForWebGL: function () {
  9129. if (this._reorderChildDirty) {
  9130. var a = this._children,
  9131. b,
  9132. c = 0,
  9133. d = a.length,
  9134. e;
  9135. for (b = 1; b < d; b++) {
  9136. var f = a[b],
  9137. c = b - 1;
  9138. for (e = a[c]; 0 <= c && (f._localZOrder < e._localZOrder || f._localZOrder == e._localZOrder && f.arrivalOrder < e.arrivalOrder) ;) a[c + 1] = e,
  9139. c -= 1,
  9140. e = a[c];
  9141. a[c + 1] = f
  9142. }
  9143. if (0 < a.length) for (this._arrayMakeObjectsPerformSelector(a, cc.Node._StateCallbackType.sortAllChildren), b = c = 0; b < a.length; b++) c = this._updateAtlasIndex(a[b], c);
  9144. this._reorderChildDirty = !1
  9145. }
  9146. },
  9147. draw: null,
  9148. _drawForWebGL: function () {
  9149. 0 !== this.textureAtlas.totalQuads && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), this.textureAtlas.drawQuads())
  9150. }
  9151. });
  9152. _p = cc.SpriteBatchNode.prototype;
  9153. cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.ctor = _p._ctorForWebGL, _p.updateQuadFromSprite = _p._updateQuadFromSpriteForWebGL, _p.insertQuadFromSprite = _p._insertQuadFromSpriteForWebGL, _p.initWithTexture = _p._initWithTextureForWebGL, _p.appendChild = _p._appendChildForWebGL, _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForWebGL, _p.getTexture = _p._getTextureForWebGL, _p.setTexture = _p._setTextureForWebGL, _p.visit = _p._visitForWebGL, _p.addChild = _p._addChildForWebGL, _p.removeAllChildren = _p._removeAllChildrenForWebGL, _p.sortAllChildren = _p._sortAllChildrenForWebGL, _p.draw = _p._drawForWebGL) : (_p.ctor = _p._ctorForCanvas, _p.updateQuadFromSprite = _p._updateQuadFromSpriteForCanvas, _p.insertQuadFromSprite = _p._insertQuadFromSpriteForCanvas, _p.initWithTexture = _p._initWithTextureForCanvas, _p.appendChild = _p._appendChildForCanvas, _p.removeSpriteFromAtlas = _p._removeSpriteFromAtlasForCanvas, _p.getTexture = _p._getTextureForCanvas, _p.setTexture = _p._setTextureForCanvas, _p.visit = _p._visitForCanvas, _p.removeAllChildren = _p._removeAllChildrenForCanvas, _p.addChild = _p._addChildForCanvas, _p.sortAllChildren = _p._sortAllChildrenForCanvas, _p.draw = cc.Node.prototype.draw);
  9154. cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
  9155. cc.defineGetterSetter(_p, "descendants", _p.getDescendants);
  9156. cc.SpriteBatchNode.create = function (a, b) {
  9157. return new cc.SpriteBatchNode(a, b)
  9158. };
  9159. cc.SpriteBatchNode.createWithTexture = cc.SpriteBatchNode.create;
  9160. cc.BakeSprite = cc.Sprite.extend({
  9161. _cacheCanvas: null,
  9162. _cacheContext: null,
  9163. ctor: function () {
  9164. cc.Sprite.prototype.ctor.call(this);
  9165. var a = document.createElement("canvas");
  9166. a.width = a.height = 10;
  9167. this._cacheCanvas = a;
  9168. this._cacheContext = a.getContext("2d");
  9169. var b = new cc.Texture2D;
  9170. b.initWithElement(a);
  9171. b.handleLoadedTexture();
  9172. this.setTexture(b)
  9173. },
  9174. getCacheContext: function () {
  9175. return this._cacheContext
  9176. },
  9177. getCacheCanvas: function () {
  9178. return this._cacheCanvas
  9179. },
  9180. resetCanvasSize: function (a, b) {
  9181. void 0 === b && (b = a.height, a = a.width);
  9182. var c = this._cacheCanvas;
  9183. c.width = a;
  9184. c.height = b;
  9185. this.getTexture().handleLoadedTexture();
  9186. this.setTextureRect(cc.rect(0, 0, a, b), !1)
  9187. }
  9188. });
  9189. cc.AnimationFrame = cc.Class.extend({
  9190. _spriteFrame: null,
  9191. _delayPerUnit: 0,
  9192. _userInfo: null,
  9193. ctor: function (a, b, c) {
  9194. this._spriteFrame = a || null;
  9195. this._delayPerUnit = b || 0;
  9196. this._userInfo = c || null
  9197. },
  9198. clone: function () {
  9199. var a = new cc.AnimationFrame;
  9200. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  9201. return a
  9202. },
  9203. copyWithZone: function (a) {
  9204. return cc.clone(this)
  9205. },
  9206. copy: function (a) {
  9207. a = new cc.AnimationFrame;
  9208. a.initWithSpriteFrame(this._spriteFrame.clone(), this._delayPerUnit, this._userInfo);
  9209. return a
  9210. },
  9211. initWithSpriteFrame: function (a, b, c) {
  9212. this._spriteFrame = a;
  9213. this._delayPerUnit = b;
  9214. this._userInfo = c;
  9215. return !0
  9216. },
  9217. getSpriteFrame: function () {
  9218. return this._spriteFrame
  9219. },
  9220. setSpriteFrame: function (a) {
  9221. this._spriteFrame = a
  9222. },
  9223. getDelayUnits: function () {
  9224. return this._delayPerUnit
  9225. },
  9226. setDelayUnits: function (a) {
  9227. this._delayPerUnit = a
  9228. },
  9229. getUserInfo: function () {
  9230. return this._userInfo
  9231. },
  9232. setUserInfo: function (a) {
  9233. this._userInfo = a
  9234. }
  9235. });
  9236. cc.AnimationFrame.create = function (a, b, c) {
  9237. return new cc.AnimationFrame(a, b, c)
  9238. };
  9239. cc.Animation = cc.Class.extend({
  9240. _frames: null,
  9241. _loops: 0,
  9242. _restoreOriginalFrame: !1,
  9243. _duration: 0,
  9244. _delayPerUnit: 0,
  9245. _totalDelayUnits: 0,
  9246. ctor: function (a, b, c) {
  9247. this._frames = [];
  9248. if (void 0 === a) this.initWithSpriteFrames(null, 0);
  9249. else {
  9250. var d = a[0];
  9251. d && (d instanceof cc.SpriteFrame ? this.initWithSpriteFrames(a, b, c) : d instanceof cc.AnimationFrame && this.initWithAnimationFrames(a, b, c))
  9252. }
  9253. },
  9254. getFrames: function () {
  9255. return this._frames
  9256. },
  9257. setFrames: function (a) {
  9258. this._frames = a
  9259. },
  9260. addSpriteFrame: function (a) {
  9261. var b = new cc.AnimationFrame;
  9262. b.initWithSpriteFrame(a, 1, null);
  9263. this._frames.push(b);
  9264. this._totalDelayUnits++
  9265. },
  9266. addSpriteFrameWithFile: function (a) {
  9267. a = cc.textureCache.addImage(a);
  9268. var b = cc.rect(0, 0, 0, 0);
  9269. b.width = a.width;
  9270. b.height = a.height;
  9271. a = cc.SpriteFrame.create(a, b);
  9272. this.addSpriteFrame(a)
  9273. },
  9274. addSpriteFrameWithTexture: function (a, b) {
  9275. var c = cc.SpriteFrame.create(a, b);
  9276. this.addSpriteFrame(c)
  9277. },
  9278. initWithAnimationFrames: function (a, b, c) {
  9279. cc.arrayVerifyType(a, cc.AnimationFrame);
  9280. this._delayPerUnit = b;
  9281. this._loops = void 0 === c ? 1 : c;
  9282. this._totalDelayUnits = 0;
  9283. b = this._frames;
  9284. for (c = b.length = 0; c < a.length; c++) {
  9285. var d = a[c];
  9286. b.push(d);
  9287. this._totalDelayUnits += d.getDelayUnits()
  9288. }
  9289. return !0
  9290. },
  9291. clone: function () {
  9292. var a = new cc.Animation;
  9293. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9294. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9295. return a
  9296. },
  9297. copyWithZone: function (a) {
  9298. a = new cc.Animation;
  9299. a.initWithAnimationFrames(this._copyFrames(), this._delayPerUnit, this._loops);
  9300. a.setRestoreOriginalFrame(this._restoreOriginalFrame);
  9301. return a
  9302. },
  9303. _copyFrames: function () {
  9304. for (var a = [], b = 0; b < this._frames.length; b++) a.push(this._frames[b].clone());
  9305. return a
  9306. },
  9307. copy: function (a) {
  9308. return this.copyWithZone(null)
  9309. },
  9310. getLoops: function () {
  9311. return this._loops
  9312. },
  9313. setLoops: function (a) {
  9314. this._loops = a
  9315. },
  9316. setRestoreOriginalFrame: function (a) {
  9317. this._restoreOriginalFrame = a
  9318. },
  9319. getRestoreOriginalFrame: function () {
  9320. return this._restoreOriginalFrame
  9321. },
  9322. getDuration: function () {
  9323. return this._totalDelayUnits * this._delayPerUnit
  9324. },
  9325. getDelayPerUnit: function () {
  9326. return this._delayPerUnit
  9327. },
  9328. setDelayPerUnit: function (a) {
  9329. this._delayPerUnit = a
  9330. },
  9331. getTotalDelayUnits: function () {
  9332. return this._totalDelayUnits
  9333. },
  9334. initWithSpriteFrames: function (a, b, c) {
  9335. cc.arrayVerifyType(a, cc.SpriteFrame);
  9336. this._loops = void 0 === c ? 1 : c;
  9337. this._delayPerUnit = b || 0;
  9338. this._totalDelayUnits = 0;
  9339. b = this._frames;
  9340. b.length = 0;
  9341. if (a) {
  9342. for (c = 0; c < a.length; c++) {
  9343. var d = a[c],
  9344. e = new cc.AnimationFrame;
  9345. e.initWithSpriteFrame(d, 1, null);
  9346. b.push(e)
  9347. }
  9348. this._totalDelayUnits += a.length
  9349. }
  9350. return !0
  9351. },
  9352. retain: function () { },
  9353. release: function () { }
  9354. });
  9355. cc.Animation.create = function (a, b, c) {
  9356. return new cc.Animation(a, b, c)
  9357. };
  9358. cc.Animation.createWithAnimationFrames = cc.Animation.create;
  9359. cc.animationCache = {
  9360. _animations: {},
  9361. addAnimation: function (a, b) {
  9362. this._animations[b] = a
  9363. },
  9364. removeAnimation: function (a) {
  9365. a && this._animations[a] && delete this._animations[a]
  9366. },
  9367. getAnimation: function (a) {
  9368. return this._animations[a] ? this._animations[a] : null
  9369. },
  9370. _addAnimationsWithDictionary: function (a, b) {
  9371. var c = a.animations;
  9372. if (c) {
  9373. var d = 1,
  9374. e = a.properties;
  9375. if (e) 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]));
  9376. switch (d) {
  9377. case 1:
  9378. this._parseVersion1(c);
  9379. break;
  9380. case 2:
  9381. this._parseVersion2(c);
  9382. break;
  9383. default:
  9384. cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary_2)
  9385. }
  9386. } else cc.log(cc._LogInfos.animationCache__addAnimationsWithDictionary)
  9387. },
  9388. addAnimations: function (a) {
  9389. cc.assert(a, cc._LogInfos.animationCache_addAnimations_2);
  9390. var b = cc.loader.getRes(a);
  9391. b ? this._addAnimationsWithDictionary(b, a) : cc.log(cc._LogInfos.animationCache_addAnimations)
  9392. },
  9393. _parseVersion1: function (a) {
  9394. var b = cc.spriteFrameCache,
  9395. c;
  9396. for (c in a) {
  9397. var d = a[c],
  9398. e = d.frames,
  9399. d = parseFloat(d.delay) || 0,
  9400. f = null;
  9401. if (e) {
  9402. for (var f = [], g = 0; g < e.length; g++) {
  9403. var h = b.getSpriteFrame(e[g]);
  9404. if (h) {
  9405. var k = new cc.AnimationFrame;
  9406. k.initWithSpriteFrame(h, 1, null);
  9407. f.push(k)
  9408. } else cc.log(cc._LogInfos.animationCache__parseVersion1_2, c, e[g])
  9409. }
  9410. 0 === f.length ? cc.log(cc._LogInfos.animationCache__parseVersion1_3, c) : (f.length != e.length && cc.log(cc._LogInfos.animationCache__parseVersion1_4, c), f = cc.Animation.create(f, d, 1), cc.animationCache.addAnimation(f, c))
  9411. } else cc.log(cc._LogInfos.animationCache__parseVersion1, c)
  9412. }
  9413. },
  9414. _parseVersion2: function (a) {
  9415. var b = cc.spriteFrameCache,
  9416. c;
  9417. for (c in a) {
  9418. var d = a[c],
  9419. e = d.loop,
  9420. f = parseInt(d.loops),
  9421. e = e ? cc.REPEAT_FOREVER : isNaN(f) ? 1 : f,
  9422. f = d.restoreOriginalFrame && !0 == d.restoreOriginalFrame ? !0 : !1,
  9423. g = d.frames;
  9424. if (g) {
  9425. for (var h = [], k = 0; k < g.length; k++) {
  9426. var m = g[k],
  9427. n = m.spriteframe,
  9428. q = b.getSpriteFrame(n);
  9429. if (q) {
  9430. var n = parseFloat(m.delayUnits) || 0,
  9431. m = m.notification,
  9432. r = new cc.AnimationFrame;
  9433. r.initWithSpriteFrame(q, n, m);
  9434. h.push(r)
  9435. } else cc.log(cc._LogInfos.animationCache__parseVersion2_2, c, n)
  9436. }
  9437. d = parseFloat(d.delayPerUnit) || 0;
  9438. g = new cc.Animation;
  9439. g.initWithAnimationFrames(h, d, e);
  9440. g.setRestoreOriginalFrame(f);
  9441. cc.animationCache.addAnimation(g, c)
  9442. } else cc.log(cc._LogInfos.animationCache__parseVersion2, c)
  9443. }
  9444. },
  9445. _clear: function () {
  9446. this._animations = {}
  9447. }
  9448. };
  9449. cc.SpriteFrame = cc.Class.extend({
  9450. _offset: null,
  9451. _originalSize: null,
  9452. _rectInPixels: null,
  9453. _rotated: !1,
  9454. _rect: null,
  9455. _offsetInPixels: null,
  9456. _originalSizeInPixels: null,
  9457. _texture: null,
  9458. _textureFilename: "",
  9459. _textureLoaded: !1,
  9460. _eventListeners: null,
  9461. ctor: function (a, b, c, d, e) {
  9462. this._offset = cc.p(0, 0);
  9463. this._offsetInPixels = cc.p(0, 0);
  9464. this._originalSize = cc.size(0, 0);
  9465. this._rotated = !1;
  9466. this._originalSizeInPixels = cc.size(0, 0);
  9467. this._textureFilename = "";
  9468. this._texture = null;
  9469. this._textureLoaded = !1;
  9470. void 0 !== a && void 0 !== b && (void 0 === c || void 0 === d || void 0 === e ? this.initWithTexture(a, b) : this.initWithTexture(a, b, c, d, e))
  9471. },
  9472. textureLoaded: function () {
  9473. return this._textureLoaded
  9474. },
  9475. addLoadedEventListener: function (a, b) {
  9476. null == this._eventListeners && (this._eventListeners = []);
  9477. this._eventListeners.push({
  9478. eventCallback: a,
  9479. eventTarget: b
  9480. })
  9481. },
  9482. _callLoadedEventCallbacks: function () {
  9483. var a = this._eventListeners;
  9484. if (a) {
  9485. for (var b = 0, c = a.length; b < c; b++) {
  9486. var d = a[b];
  9487. d.eventCallback.call(d.eventTarget, this)
  9488. }
  9489. a.length = 0
  9490. }
  9491. },
  9492. getRectInPixels: function () {
  9493. var a = this._rectInPixels;
  9494. return cc.rect(a.x, a.y, a.width, a.height)
  9495. },
  9496. setRectInPixels: function (a) {
  9497. this._rectInPixels || (this._rectInPixels = cc.rect(0, 0, 0, 0));
  9498. this._rectInPixels.x = a.x;
  9499. this._rectInPixels.y = a.y;
  9500. this._rectInPixels.width = a.width;
  9501. this._rectInPixels.height = a.height;
  9502. this._rect = cc.rectPixelsToPoints(a)
  9503. },
  9504. isRotated: function () {
  9505. return this._rotated
  9506. },
  9507. setRotated: function (a) {
  9508. this._rotated = a
  9509. },
  9510. getRect: function () {
  9511. var a = this._rect;
  9512. return cc.rect(a.x, a.y, a.width, a.height)
  9513. },
  9514. setRect: function (a) {
  9515. this._rect || (this._rect = cc.rect(0, 0, 0, 0));
  9516. this._rect.x = a.x;
  9517. this._rect.y = a.y;
  9518. this._rect.width = a.width;
  9519. this._rect.height = a.height;
  9520. this._rectInPixels = cc.rectPointsToPixels(this._rect)
  9521. },
  9522. getOffsetInPixels: function () {
  9523. return cc.p(this._offsetInPixels)
  9524. },
  9525. setOffsetInPixels: function (a) {
  9526. this._offsetInPixels.x = a.x;
  9527. this._offsetInPixels.y = a.y;
  9528. cc._pointPixelsToPointsOut(this._offsetInPixels, this._offset)
  9529. },
  9530. getOriginalSizeInPixels: function () {
  9531. return cc.size(this._originalSizeInPixels)
  9532. },
  9533. setOriginalSizeInPixels: function (a) {
  9534. this._originalSizeInPixels.width = a.width;
  9535. this._originalSizeInPixels.height = a.height
  9536. },
  9537. getOriginalSize: function () {
  9538. return cc.size(this._originalSize)
  9539. },
  9540. setOriginalSize: function (a) {
  9541. this._originalSize.width = a.width;
  9542. this._originalSize.height = a.height
  9543. },
  9544. getTexture: function () {
  9545. if (this._texture) return this._texture;
  9546. if ("" !== this._textureFilename) {
  9547. var a = cc.textureCache.addImage(this._textureFilename);
  9548. a && (this._textureLoaded = a.isLoaded());
  9549. return a
  9550. }
  9551. return null
  9552. },
  9553. setTexture: function (a) {
  9554. if (this._texture != a) {
  9555. var b = a.isLoaded();
  9556. this._textureLoaded = b;
  9557. this._texture = a;
  9558. b || a.addLoadedEventListener(function (a) {
  9559. this._textureLoaded = !0;
  9560. if (this._rotated && cc._renderType === cc._RENDER_TYPE_CANVAS) {
  9561. var b = a.getHtmlElementObj(),
  9562. b = cc.cutRotateImageToCanvas(b, this.getRect()),
  9563. e = new cc.Texture2D;
  9564. e.initWithElement(b);
  9565. e.handleLoadedTexture();
  9566. this.setTexture(e);
  9567. b = this.getRect();
  9568. this.setRect(cc.rect(0, 0, b.width, b.height))
  9569. }
  9570. b = this._rect;
  9571. 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);
  9572. this._callLoadedEventCallbacks()
  9573. },
  9574. this)
  9575. }
  9576. },
  9577. getOffset: function () {
  9578. return cc.p(this._offset)
  9579. },
  9580. setOffset: function (a) {
  9581. this._offset.x = a.x;
  9582. this._offset.y = a.y
  9583. },
  9584. clone: function () {
  9585. var a = new cc.SpriteFrame;
  9586. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  9587. a.setTexture(this._texture);
  9588. return a
  9589. },
  9590. copyWithZone: function () {
  9591. var a = new cc.SpriteFrame;
  9592. a.initWithTexture(this._textureFilename, this._rectInPixels, this._rotated, this._offsetInPixels, this._originalSizeInPixels);
  9593. a.setTexture(this._texture);
  9594. return a
  9595. },
  9596. copy: function () {
  9597. return this.copyWithZone()
  9598. },
  9599. initWithTexture: function (a, b, c, d, e) {
  9600. 2 === arguments.length && (b = cc.rectPointsToPixels(b));
  9601. d = d || cc.p(0, 0);
  9602. e = e || b;
  9603. c = c || !1;
  9604. cc.isString(a) ? (this._texture = null, this._textureFilename = a) : a instanceof cc.Texture2D && this.setTexture(a);
  9605. a = this.getTexture();
  9606. this._rectInPixels = b;
  9607. b = this._rect = cc.rectPixelsToPoints(b);
  9608. if (a && a.url && a.isLoaded()) {
  9609. var f,
  9610. g;
  9611. c ? (f = b.x + b.height, g = b.y + b.width) : (f = b.x + b.width, g = b.y + b.height);
  9612. f > a.getPixelsWide() && cc.error(cc._LogInfos.RectWidth, a.url);
  9613. g > a.getPixelsHigh() && cc.error(cc._LogInfos.RectHeight, a.url)
  9614. }
  9615. this._offsetInPixels.x = d.x;
  9616. this._offsetInPixels.y = d.y;
  9617. cc._pointPixelsToPointsOut(d, this._offset);
  9618. this._originalSizeInPixels.width = e.width;
  9619. this._originalSizeInPixels.height = e.height;
  9620. cc._sizePixelsToPointsOut(e, this._originalSize);
  9621. this._rotated = c;
  9622. return !0
  9623. }
  9624. });
  9625. cc.SpriteFrame.create = function (a, b, c, d, e) {
  9626. return new cc.SpriteFrame(a, b, c, d, e)
  9627. };
  9628. cc.SpriteFrame.createWithTexture = cc.SpriteFrame.create;
  9629. cc.SpriteFrame._frameWithTextureForCanvas = function (a, b, c, d, e) {
  9630. var f = new cc.SpriteFrame;
  9631. f._texture = a;
  9632. f._rectInPixels = b;
  9633. f._rect = cc.rectPixelsToPoints(b);
  9634. f._offsetInPixels.x = d.x;
  9635. f._offsetInPixels.y = d.y;
  9636. cc._pointPixelsToPointsOut(f._offsetInPixels, f._offset);
  9637. f._originalSizeInPixels.width = e.width;
  9638. f._originalSizeInPixels.height = e.height;
  9639. cc._sizePixelsToPointsOut(f._originalSizeInPixels, f._originalSize);
  9640. f._rotated = c;
  9641. return f
  9642. };
  9643. cc.spriteFrameCache = {
  9644. _CCNS_REG1: /^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,
  9645. _CCNS_REG2: /^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,
  9646. _spriteFrames: {},
  9647. _spriteFramesAliases: {},
  9648. _frameConfigCache: {},
  9649. _rectFromString: function (a) {
  9650. 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)
  9651. },
  9652. _pointFromString: function (a) {
  9653. return (a = this._CCNS_REG1.exec(a)) ? cc.p(parseFloat(a[1]), parseFloat(a[2])) : cc.p(0, 0)
  9654. },
  9655. _sizeFromString: function (a) {
  9656. return (a = this._CCNS_REG1.exec(a)) ? cc.size(parseFloat(a[1]), parseFloat(a[2])) : cc.size(0, 0)
  9657. },
  9658. _getFrameConfig: function (a) {
  9659. var b = cc.loader.getRes(a);
  9660. cc.assert(b, cc._LogInfos.spriteFrameCache__getFrameConfig_2, a);
  9661. cc.loader.release(a);
  9662. if (b._inited) return this._frameConfigCache[a] = b;
  9663. var c = b.frames,
  9664. d = b.metadata || b.meta,
  9665. b = {},
  9666. e = {},
  9667. f = 0;
  9668. d && (f = d.format, f = 1 >= f.length ? parseInt(f) : f, e.image = d.textureFileName || d.textureFileName || d.image);
  9669. for (var g in c) {
  9670. var h = c[g];
  9671. if (h) {
  9672. d = {};
  9673. if (0 == f) {
  9674. d.rect = cc.rect(h.x, h.y, h.width, h.height);
  9675. d.rotated = !1;
  9676. d.offset = cc.p(h.offsetX, h.offsetY);
  9677. var k = h.originalWidth,
  9678. h = h.originalHeight;
  9679. k && h || cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig);
  9680. k = Math.abs(k);
  9681. h = Math.abs(h);
  9682. d.size = cc.size(k, h)
  9683. } else if (1 == f || 2 == f) d.rect = this._rectFromString(h.frame),
  9684. d.rotated = h.rotated || !1,
  9685. d.offset = this._pointFromString(h.offset),
  9686. d.size = this._sizeFromString(h.sourceSize);
  9687. else if (3 == f) {
  9688. var k = this._sizeFromString(h.spriteSize),
  9689. m = this._rectFromString(h.textureRect);
  9690. k && (m = cc.rect(m.x, m.y, k.width, k.height));
  9691. d.rect = m;
  9692. d.rotated = h.textureRotated || !1;
  9693. d.offset = this._pointFromString(h.spriteOffset);
  9694. d.size = this._sizeFromString(h.spriteSourceSize);
  9695. d.aliases = h.aliases
  9696. } else k = h.frame,
  9697. m = h.sourceSize,
  9698. g = h.filename || g,
  9699. d.rect = cc.rect(k.x, k.y, k.w, k.h),
  9700. d.rotated = h.rotated || !1,
  9701. d.offset = cc.p(0, 0),
  9702. d.size = cc.size(m.w, m.h);
  9703. b[g] = d
  9704. }
  9705. }
  9706. return this._frameConfigCache[a] = {
  9707. _inited: !0,
  9708. frames: b,
  9709. meta: e
  9710. }
  9711. },
  9712. addSpriteFrames: function (a, b) {
  9713. cc.assert(a, cc._LogInfos.spriteFrameCache_addSpriteFrames_2);
  9714. var c = this._frameConfigCache[a] || cc.loader.getRes(a);
  9715. if (c && c.frames) {
  9716. var d = this._frameConfigCache[a] || this._getFrameConfig(a),
  9717. c = d.frames,
  9718. d = d.meta;
  9719. b ? b instanceof cc.Texture2D || (cc.isString(b) ? b = cc.textureCache.addImage(b) : cc.assert(0, cc._LogInfos.spriteFrameCache_addSpriteFrames_3)) : (d = cc.path.changeBasename(a, d.image || ".png"), b = cc.textureCache.addImage(d));
  9720. var d = this._spriteFramesAliases,
  9721. e = this._spriteFrames,
  9722. f;
  9723. for (f in c) {
  9724. var g = c[f],
  9725. h = e[f];
  9726. if (!h) {
  9727. h = cc.SpriteFrame.create(b, g.rect, g.rotated, g.offset, g.size);
  9728. if (g = g.aliases) for (var k = 0, m = g.length; k < m; k++) {
  9729. var n = g[k];
  9730. d[n] && cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames, n);
  9731. d[n] = f
  9732. }
  9733. cc._renderType === cc._RENDER_TYPE_CANVAS && h.isRotated() && h.getTexture().isLoaded() && (g = h.getTexture().getHtmlElementObj(), g = cc.cutRotateImageToCanvas(g, h.getRectInPixels()), k = new cc.Texture2D, k.initWithElement(g), k.handleLoadedTexture(), h.setTexture(k), g = h._rect, h.setRect(cc.rect(0, 0, g.width, g.height)));
  9734. e[f] = h
  9735. }
  9736. }
  9737. }
  9738. },
  9739. _checkConflict: function (a) {
  9740. a = a.frames;
  9741. for (var b in a) this._spriteFrames[b] && cc.log(cc._LogInfos.spriteFrameCache__checkConflict, b)
  9742. },
  9743. addSpriteFrame: function (a, b) {
  9744. this._spriteFrames[b] = a
  9745. },
  9746. removeSpriteFrames: function () {
  9747. this._spriteFrames = {};
  9748. this._spriteFramesAliases = {}
  9749. },
  9750. removeSpriteFrameByName: function (a) {
  9751. a && (this._spriteFramesAliases[a] && delete this._spriteFramesAliases[a], this._spriteFrames[a] && delete this._spriteFrames[a])
  9752. },
  9753. removeSpriteFramesFromFile: function (a) {
  9754. var b = this._spriteFrames,
  9755. c = this._spriteFramesAliases;
  9756. if (a = this._frameConfigCache[a]) {
  9757. a = a.frames;
  9758. for (var d in a) if (b[d]) {
  9759. delete b[d];
  9760. for (var e in c) c[e] == d && delete c[e]
  9761. }
  9762. }
  9763. },
  9764. removeSpriteFramesFromTexture: function (a) {
  9765. var b = this._spriteFrames,
  9766. c = this._spriteFramesAliases,
  9767. d;
  9768. for (d in b) {
  9769. var e = b[d];
  9770. if (e && e.getTexture() == a) {
  9771. delete b[d];
  9772. for (var f in c) c[f] == d && delete c[f]
  9773. }
  9774. }
  9775. },
  9776. getSpriteFrame: function (a) {
  9777. var b = this._spriteFrames[a];
  9778. if (!b) {
  9779. var c = this._spriteFramesAliases[a];
  9780. c && ((b = this._spriteFrames[c.toString()]) || delete this._spriteFramesAliases[a])
  9781. }
  9782. b || cc.log(cc._LogInfos.spriteFrameCache_getSpriteFrame, a);
  9783. return b
  9784. },
  9785. _clear: function () {
  9786. this._spriteFrames = {};
  9787. this._spriteFramesAliases = {};
  9788. this._frameConfigCache = {}
  9789. }
  9790. };
  9791. cc.configuration = {
  9792. ERROR: 0,
  9793. STRING: 1,
  9794. INT: 2,
  9795. DOUBLE: 3,
  9796. BOOLEAN: 4,
  9797. _maxTextureSize: 0,
  9798. _maxModelviewStackDepth: 0,
  9799. _supportsPVRTC: !1,
  9800. _supportsNPOT: !1,
  9801. _supportsBGRA8888: !1,
  9802. _supportsDiscardFramebuffer: !1,
  9803. _supportsShareableVAO: !1,
  9804. _maxSamplesAllowed: 0,
  9805. _maxTextureUnits: 0,
  9806. _GlExtensions: "",
  9807. _valueDict: {},
  9808. _inited: !1,
  9809. _init: function () {
  9810. var a = this._valueDict;
  9811. a["cocos2d.x.version"] = cc.ENGINE_VERSION;
  9812. a["cocos2d.x.compiled_with_profiler"] = !1;
  9813. a["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
  9814. this._inited = !0
  9815. },
  9816. getMaxTextureSize: function () {
  9817. return this._maxTextureSize
  9818. },
  9819. getMaxModelviewStackDepth: function () {
  9820. return this._maxModelviewStackDepth
  9821. },
  9822. getMaxTextureUnits: function () {
  9823. return this._maxTextureUnits
  9824. },
  9825. supportsNPOT: function () {
  9826. return this._supportsNPOT
  9827. },
  9828. supportsPVRTC: function () {
  9829. return this._supportsPVRTC
  9830. },
  9831. supportsETC: function () {
  9832. return !1
  9833. },
  9834. supportsS3TC: function () {
  9835. return !1
  9836. },
  9837. supportsATITC: function () {
  9838. return !1
  9839. },
  9840. supportsBGRA8888: function () {
  9841. return this._supportsBGRA8888
  9842. },
  9843. supportsDiscardFramebuffer: function () {
  9844. return this._supportsDiscardFramebuffer
  9845. },
  9846. supportsShareableVAO: function () {
  9847. return this._supportsShareableVAO
  9848. },
  9849. checkForGLExtension: function (a) {
  9850. return -1 < this._GlExtensions.indexOf(a)
  9851. },
  9852. getValue: function (a, b) {
  9853. this._inited || this._init();
  9854. var c = this._valueDict;
  9855. return c[a] ? c[a] : b
  9856. },
  9857. setValue: function (a, b) {
  9858. this._valueDict[a] = b
  9859. },
  9860. dumpInfo: function () {
  9861. 0 === cc.ENABLE_GL_STATE_CACHE && (cc.log(""), cc.log(cc._LogInfos.configuration_dumpInfo), cc.log(""))
  9862. },
  9863. gatherGPUInfo: function () {
  9864. if (cc._renderType !== cc._RENDER_TYPE_CANVAS) {
  9865. this._inited || this._init();
  9866. var a = cc._renderContext,
  9867. b = this._valueDict;
  9868. b["gl.vendor"] = a.getParameter(a.VENDOR);
  9869. b["gl.renderer"] = a.getParameter(a.RENDERER);
  9870. b["gl.version"] = a.getParameter(a.VERSION);
  9871. this._GlExtensions = "";
  9872. for (var c = a.getSupportedExtensions(), d = 0; d < c.length; d++) this._GlExtensions += c[d] + " ";
  9873. this._maxTextureSize = a.getParameter(a.MAX_TEXTURE_SIZE);
  9874. b["gl.max_texture_size"] = this._maxTextureSize;
  9875. this._maxTextureUnits = a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  9876. b["gl.max_texture_units"] = this._maxTextureUnits;
  9877. this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
  9878. b["gl.supports_PVRTC"] = this._supportsPVRTC;
  9879. this._supportsNPOT = !1;
  9880. b["gl.supports_NPOT"] = this._supportsNPOT;
  9881. this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888");
  9882. b["gl.supports_BGRA8888"] = this._supportsBGRA8888;
  9883. this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer");
  9884. b["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer;
  9885. this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object");
  9886. b["gl.supports_vertex_array_object"] = this._supportsShareableVAO;
  9887. cc.checkGLErrorDebug()
  9888. }
  9889. },
  9890. loadConfigFile: function (a) {
  9891. this._inited || this._init();
  9892. var b = cc.loader.getRes(a);
  9893. if (!b) throw "Please load the resource first : " + a;
  9894. cc.assert(b, cc._LogInfos.configuration_loadConfigFile_2, a);
  9895. if (b = b.data) for (var c in b) this._valueDict[c] = b[c];
  9896. else cc.log(cc._LogInfos.configuration_loadConfigFile, a)
  9897. }
  9898. };
  9899. cc._tmp.DirectorWebGL = function () {
  9900. cc.DirectorDelegate = cc.Class.extend({
  9901. updateProjection: function () { }
  9902. });
  9903. var a = cc.Director.prototype;
  9904. a.setProjection = function (a) {
  9905. var c = this._winSizeInPoints;
  9906. this.setViewport();
  9907. var d = this._openGLView,
  9908. e = d._viewPortRect.x / d._scaleX,
  9909. f = d._viewPortRect.y / d._scaleY;
  9910. switch (a) {
  9911. case cc.Director.PROJECTION_2D:
  9912. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  9913. cc.kmGLLoadIdentity();
  9914. d = new cc.kmMat4;
  9915. cc.kmMat4OrthographicProjection(d, 0, c.width, 0, c.height, -1024, 1024);
  9916. cc.kmGLMultMatrix(d);
  9917. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  9918. cc.kmGLLoadIdentity();
  9919. break;
  9920. case cc.Director.PROJECTION_3D:
  9921. var g = this.getZEye(),
  9922. h = new cc.kmMat4,
  9923. d = new cc.kmMat4;
  9924. cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
  9925. cc.kmGLLoadIdentity();
  9926. cc.kmMat4PerspectiveProjection(h, 60, c.width / c.height, 0.1, 2 * g);
  9927. cc.kmGLMultMatrix(h);
  9928. cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
  9929. cc.kmGLLoadIdentity();
  9930. g = cc.kmVec3Fill(null, -e + c.width / 2, -f + c.height / 2, g);
  9931. c = cc.kmVec3Fill(null, -e + c.width / 2, -f + c.height / 2, 0);
  9932. e = cc.kmVec3Fill(null, 0, 1, 0);
  9933. cc.kmMat4LookAt(d, g, c, e);
  9934. cc.kmGLMultMatrix(d);
  9935. break;
  9936. case cc.Director.PROJECTION_CUSTOM:
  9937. this._projectionDelegate && this._projectionDelegate.updateProjection();
  9938. break;
  9939. default:
  9940. cc.log(cc._LogInfos.Director_setProjection)
  9941. }
  9942. this._projection = a;
  9943. cc.eventManager.dispatchEvent(this._eventProjectionChanged);
  9944. cc.setProjectionMatrixDirty()
  9945. };
  9946. a.setDepthTest = function (a) {
  9947. var c = cc._renderContext;
  9948. a ? (c.clearDepth(1), c.enable(c.DEPTH_TEST), c.depthFunc(c.LEQUAL)) : c.disable(c.DEPTH_TEST)
  9949. };
  9950. a.setOpenGLView = function (a) {
  9951. this._winSizeInPoints.width = cc._canvas.width;
  9952. this._winSizeInPoints.height = cc._canvas.height;
  9953. this._openGLView = a || cc.view;
  9954. a = cc.configuration;
  9955. a.gatherGPUInfo();
  9956. a.dumpInfo();
  9957. this._createStatsLabel();
  9958. this.setGLDefaultValues();
  9959. cc.eventManager && cc.eventManager.setEnabled(!0)
  9960. };
  9961. a._clear = function () {
  9962. var a = cc._renderContext;
  9963. a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT)
  9964. };
  9965. a._beforeVisitScene = function () {
  9966. cc.kmGLPushMatrix()
  9967. };
  9968. a._afterVisitScene = function () {
  9969. cc.kmGLPopMatrix()
  9970. };
  9971. a._createStatsLabel = function () {
  9972. if (!cc.LabelAtlas) this._createStatsLabelForCanvas();
  9973. else if (null != cc.Director._fpsImageLoaded && !1 != cc.Director._fpsImageLoaded) {
  9974. var a = new cc.Texture2D;
  9975. a.initWithElement(cc.Director._fpsImage);
  9976. a.handleLoadedTexture();
  9977. var c = cc.view.getDesignResolutionSize().height / 320;
  9978. 0 === c && (c = this._winSizeInPoints.height / 320);
  9979. var d = new cc.LabelAtlas;
  9980. d._setIgnoreContentScaleFactor(!0);
  9981. d.initWithString("00.0", a, 12, 32, ".");
  9982. d.scale = c;
  9983. this._FPSLabel = d;
  9984. d = new cc.LabelAtlas;
  9985. d._setIgnoreContentScaleFactor(!0);
  9986. d.initWithString("0.000", a, 12, 32, ".");
  9987. d.scale = c;
  9988. this._SPFLabel = d;
  9989. d = new cc.LabelAtlas;
  9990. d._setIgnoreContentScaleFactor(!0);
  9991. d.initWithString("000", a, 12, 32, ".");
  9992. d.scale = c;
  9993. this._drawsLabel = d;
  9994. a = cc.DIRECTOR_STATS_POSITION;
  9995. this._drawsLabel.setPosition(a.x, 34 * c + a.y);
  9996. this._SPFLabel.setPosition(a.x, 17 * c + a.y);
  9997. this._FPSLabel.setPosition(a)
  9998. }
  9999. };
  10000. a._createStatsLabelForCanvas = function () {
  10001. var a = 0,
  10002. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24;
  10003. this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
  10004. this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
  10005. this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
  10006. a = cc.DIRECTOR_STATS_POSITION;
  10007. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  10008. this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  10009. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  10010. };
  10011. a.convertToGL = function (a) {
  10012. var c = new cc.kmMat4;
  10013. cc.GLToClipTransform(c);
  10014. var d = new cc.kmMat4;
  10015. cc.kmMat4Inverse(d, c);
  10016. var c = c.mat[14] / c.mat[15],
  10017. e = this._openGLView.getDesignResolutionSize();
  10018. a = new cc.kmVec3(2 * a.x / e.width - 1, 1 - 2 * a.y / e.height, c);
  10019. c = new cc.kmVec3;
  10020. cc.kmVec3TransformCoord(c, a, d);
  10021. return cc.p(c.x, c.y)
  10022. };
  10023. a.convertToUI = function (a) {
  10024. var c = new cc.kmMat4;
  10025. cc.GLToClipTransform(c);
  10026. var d = new cc.kmVec3;
  10027. a = new cc.kmVec3(a.x, a.y, 0);
  10028. cc.kmVec3TransformCoord(d, a, c);
  10029. c = this._openGLView.getDesignResolutionSize();
  10030. return cc.p(c.width * (0.5 * d.x + 0.5), c.height * (0.5 * -d.y + 0.5))
  10031. };
  10032. a.getVisibleSize = function () {
  10033. return this._openGLView.getVisibleSize()
  10034. };
  10035. a.getVisibleOrigin = function () {
  10036. return this._openGLView.getVisibleOrigin()
  10037. };
  10038. a.getZEye = function () {
  10039. return this._winSizeInPoints.height / 1.1566
  10040. };
  10041. a.setViewport = function () {
  10042. var a = this._openGLView;
  10043. if (a) {
  10044. var c = this._winSizeInPoints;
  10045. a.setViewPortInPoints(-a._viewPortRect.x / a._scaleX, -a._viewPortRect.y / a._scaleY, c.width, c.height)
  10046. }
  10047. };
  10048. a.getOpenGLView = function () {
  10049. return this._openGLView
  10050. };
  10051. a.getProjection = function () {
  10052. return this._projection
  10053. };
  10054. a.setAlphaBlending = function (a) {
  10055. a ? cc.glBlendFunc(cc.BLEND_SRC, cc.BLEND_DST) : cc.glBlendFunc(cc._renderContext.ONE, cc._renderContext.ZERO)
  10056. };
  10057. a.setGLDefaultValues = function () {
  10058. this.setAlphaBlending(!0);
  10059. this.setDepthTest(!1);
  10060. this.setProjection(this._projection);
  10061. cc._renderContext.clearColor(0, 0, 0, 1)
  10062. }
  10063. };
  10064. cc.g_NumberOfDraws = 0;
  10065. cc.GLToClipTransform = function (a) {
  10066. var b = new cc.kmMat4;
  10067. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, b);
  10068. var c = new cc.kmMat4;
  10069. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, c);
  10070. cc.kmMat4Multiply(a, b, c)
  10071. };
  10072. cc.Director = cc.Class.extend({
  10073. _landscape: !1,
  10074. _nextDeltaTimeZero: !1,
  10075. _paused: !1,
  10076. _purgeDirectorInNextLoop: !1,
  10077. _sendCleanupToScene: !1,
  10078. _animationInterval: 0,
  10079. _oldAnimationInterval: 0,
  10080. _projection: 0,
  10081. _accumDt: 0,
  10082. _contentScaleFactor: 1,
  10083. _displayStats: !1,
  10084. _deltaTime: 0,
  10085. _frameRate: 0,
  10086. _FPSLabel: null,
  10087. _SPFLabel: null,
  10088. _drawsLabel: null,
  10089. _winSizeInPoints: null,
  10090. _lastUpdate: null,
  10091. _nextScene: null,
  10092. _notificationNode: null,
  10093. _openGLView: null,
  10094. _scenesStack: null,
  10095. _projectionDelegate: null,
  10096. _runningScene: null,
  10097. _frames: 0,
  10098. _totalFrames: 0,
  10099. _secondsPerFrame: 0,
  10100. _dirtyRegion: null,
  10101. _scheduler: null,
  10102. _actionManager: null,
  10103. _eventProjectionChanged: null,
  10104. _eventAfterDraw: null,
  10105. _eventAfterVisit: null,
  10106. _eventAfterUpdate: null,
  10107. ctor: function () {
  10108. var a = this;
  10109. a._lastUpdate = Date.now();
  10110. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,
  10111. function () {
  10112. a._lastUpdate = Date.now()
  10113. })
  10114. },
  10115. init: function () {
  10116. this._oldAnimationInterval = this._animationInterval = 1 / cc.defaultFPS;
  10117. this._scenesStack = [];
  10118. this._projection = cc.Director.PROJECTION_DEFAULT;
  10119. this._projectionDelegate = null;
  10120. this._frameRate = this._accumDt = 0;
  10121. this._displayStats = !1;
  10122. this._totalFrames = this._frames = 0;
  10123. this._lastUpdate = Date.now();
  10124. this._purgeDirectorInNextLoop = this._paused = !1;
  10125. this._winSizeInPoints = cc.size(0, 0);
  10126. this._openGLView = null;
  10127. this._contentScaleFactor = 1;
  10128. this._scheduler = new cc.Scheduler;
  10129. this._actionManager = cc.ActionManager ? new cc.ActionManager : null;
  10130. this._scheduler.scheduleUpdateForTarget(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, !1);
  10131. this._eventAfterDraw = new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW);
  10132. this._eventAfterDraw.setUserData(this);
  10133. this._eventAfterVisit = new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT);
  10134. this._eventAfterVisit.setUserData(this);
  10135. this._eventAfterUpdate = new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE);
  10136. this._eventAfterUpdate.setUserData(this);
  10137. this._eventProjectionChanged = new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED);
  10138. this._eventProjectionChanged.setUserData(this);
  10139. return !0
  10140. },
  10141. calculateDeltaTime: function () {
  10142. var a = Date.now();
  10143. this._nextDeltaTimeZero ? (this._deltaTime = 0, this._nextDeltaTimeZero = !1) : this._deltaTime = (a - this._lastUpdate) / 1E3;
  10144. 0 < cc.game.config[cc.game.CONFIG_KEY.debugMode] && 0.2 < this._deltaTime && (this._deltaTime = 1 / 60);
  10145. this._lastUpdate = a
  10146. },
  10147. convertToGL: null,
  10148. convertToUI: null,
  10149. drawScene: function () {
  10150. this.calculateDeltaTime();
  10151. this._paused || (this._scheduler.update(this._deltaTime), cc.eventManager.dispatchEvent(this._eventAfterUpdate));
  10152. this._clear();
  10153. this._nextScene && this.setNextScene();
  10154. this._beforeVisitScene && this._beforeVisitScene();
  10155. this._runningScene && (this._runningScene.visit(), cc.eventManager.dispatchEvent(this._eventAfterVisit));
  10156. this._notificationNode && this._notificationNode.visit();
  10157. this._displayStats && this._showStats();
  10158. this._afterVisitScene && this._afterVisitScene();
  10159. cc.eventManager.dispatchEvent(this._eventAfterDraw);
  10160. this._totalFrames++;
  10161. this._displayStats && this._calculateMPF()
  10162. },
  10163. _beforeVisitScene: null,
  10164. _afterVisitScene: null,
  10165. end: function () {
  10166. this._purgeDirectorInNextLoop = !0
  10167. },
  10168. getContentScaleFactor: function () {
  10169. return this._contentScaleFactor
  10170. },
  10171. getNotificationNode: function () {
  10172. return this._notificationNode
  10173. },
  10174. getWinSize: function () {
  10175. return cc.size(this._winSizeInPoints)
  10176. },
  10177. getWinSizeInPixels: function () {
  10178. return cc.size(this._winSizeInPoints.width * this._contentScaleFactor, this._winSizeInPoints.height * this._contentScaleFactor)
  10179. },
  10180. getVisibleSize: null,
  10181. getVisibleOrigin: null,
  10182. getZEye: null,
  10183. pause: function () {
  10184. this._paused || (this._oldAnimationInterval = this._animationInterval, this.setAnimationInterval(0.25), this._paused = !0)
  10185. },
  10186. popScene: function () {
  10187. cc.assert(this._runningScene, cc._LogInfos.Director_popScene);
  10188. this._scenesStack.pop();
  10189. var a = this._scenesStack.length;
  10190. 0 == a ? this.end() : (this._sendCleanupToScene = !0, this._nextScene = this._scenesStack[a - 1])
  10191. },
  10192. purgeCachedData: function () {
  10193. cc.animationCache._clear();
  10194. cc.spriteFrameCache._clear();
  10195. cc.textureCache._clear()
  10196. },
  10197. purgeDirector: function () {
  10198. this.getScheduler().unscheduleAllCallbacks();
  10199. cc.eventManager && cc.eventManager.setEnabled(!1);
  10200. this._runningScene && (this._runningScene.onExitTransitionDidStart(), this._runningScene.onExit(), this._runningScene.cleanup());
  10201. this._nextScene = this._runningScene = null;
  10202. this._scenesStack.length = 0;
  10203. this.stopAnimation();
  10204. this.purgeCachedData();
  10205. cc.checkGLErrorDebug()
  10206. },
  10207. pushScene: function (a) {
  10208. cc.assert(a, cc._LogInfos.Director_pushScene);
  10209. this._sendCleanupToScene = !1;
  10210. this._scenesStack.push(a);
  10211. this._nextScene = a
  10212. },
  10213. runScene: function (a) {
  10214. cc.assert(a, cc._LogInfos.Director_pushScene);
  10215. if (this._runningScene) {
  10216. var b = this._scenesStack.length;
  10217. 0 === b ? (this._sendCleanupToScene = !0, this._scenesStack[b] = a) : (this._sendCleanupToScene = !0, this._scenesStack[b - 1] = a);
  10218. this._nextScene = a
  10219. } else this.pushScene(a),
  10220. this.startAnimation()
  10221. },
  10222. resume: function () {
  10223. this._paused && (this.setAnimationInterval(this._oldAnimationInterval), (this._lastUpdate = Date.now()) || cc.log(cc._LogInfos.Director_resume), this._paused = !1, this._deltaTime = 0)
  10224. },
  10225. setContentScaleFactor: function (a) {
  10226. a != this._contentScaleFactor && (this._contentScaleFactor = a, this._createStatsLabel())
  10227. },
  10228. setDepthTest: null,
  10229. setDefaultValues: function () { },
  10230. setNextDeltaTimeZero: function (a) {
  10231. this._nextDeltaTimeZero = a
  10232. },
  10233. setNextScene: function () {
  10234. var a = !1,
  10235. b = !1;
  10236. cc.TransitionScene && (a = this._runningScene ? this._runningScene instanceof cc.TransitionScene : !1, b = this._nextScene ? this._nextScene instanceof
  10237. cc.TransitionScene : !1);
  10238. if (!b) {
  10239. if (b = this._runningScene) b.onExitTransitionDidStart(),
  10240. b.onExit();
  10241. this._sendCleanupToScene && b && b.cleanup()
  10242. }
  10243. this._runningScene = this._nextScene;
  10244. this._nextScene = null;
  10245. a || null == this._runningScene || (this._runningScene.onEnter(), this._runningScene.onEnterTransitionDidFinish())
  10246. },
  10247. setNotificationNode: function (a) {
  10248. this._notificationNode = a
  10249. },
  10250. getDelegate: function () {
  10251. return this._projectionDelegate
  10252. },
  10253. setDelegate: function (a) {
  10254. this._projectionDelegate = a
  10255. },
  10256. setOpenGLView: null,
  10257. setProjection: null,
  10258. setViewport: null,
  10259. getOpenGLView: null,
  10260. getProjection: null,
  10261. setAlphaBlending: null,
  10262. _showStats: function () {
  10263. this._frames++;
  10264. this._accumDt += this._deltaTime;
  10265. this._FPSLabel && this._SPFLabel && this._drawsLabel ? (this._accumDt > cc.DIRECTOR_FPS_INTERVAL && (this._SPFLabel.string = this._secondsPerFrame.toFixed(3), this._frameRate = this._frames / this._accumDt, this._accumDt = this._frames = 0, this._FPSLabel.string = this._frameRate.toFixed(1), this._drawsLabel.string = (0 | cc.g_NumberOfDraws).toString()), this._FPSLabel.visit(), this._SPFLabel.visit(), this._drawsLabel.visit()) : this._createStatsLabel();
  10266. cc.g_NumberOfDraws = 0
  10267. },
  10268. isSendCleanupToScene: function () {
  10269. return this._sendCleanupToScene
  10270. },
  10271. getRunningScene: function () {
  10272. return this._runningScene
  10273. },
  10274. getAnimationInterval: function () {
  10275. return this._animationInterval
  10276. },
  10277. isDisplayStats: function () {
  10278. return this._displayStats
  10279. },
  10280. setDisplayStats: function (a) {
  10281. this._displayStats = a
  10282. },
  10283. getSecondsPerFrame: function () {
  10284. return this._secondsPerFrame
  10285. },
  10286. isNextDeltaTimeZero: function () {
  10287. return this._nextDeltaTimeZero
  10288. },
  10289. isPaused: function () {
  10290. return this._paused
  10291. },
  10292. getTotalFrames: function () {
  10293. return this._totalFrames
  10294. },
  10295. popToRootScene: function () {
  10296. this.popToSceneStackLevel(1)
  10297. },
  10298. popToSceneStackLevel: function (a) {
  10299. cc.assert(this._runningScene, cc._LogInfos.Director_popToSceneStackLevel_2);
  10300. var b = this._scenesStack,
  10301. c = b.length;
  10302. if (0 == c) this.end();
  10303. else if (!(a > c)) {
  10304. for (; c > a;) {
  10305. var d = b.pop();
  10306. d.running && (d.onExitTransitionDidStart(), d.onExit());
  10307. d.cleanup();
  10308. c--
  10309. }
  10310. this._nextScene = b[b.length - 1];
  10311. this._sendCleanupToScene = !1
  10312. }
  10313. },
  10314. getScheduler: function () {
  10315. return this._scheduler
  10316. },
  10317. setScheduler: function (a) {
  10318. this._scheduler != a && (this._scheduler = a)
  10319. },
  10320. getActionManager: function () {
  10321. return this._actionManager
  10322. },
  10323. setActionManager: function (a) {
  10324. this._actionManager != a && (this._actionManager = a)
  10325. },
  10326. getDeltaTime: function () {
  10327. return this._deltaTime
  10328. },
  10329. _createStatsLabel: null,
  10330. _calculateMPF: function () {
  10331. this._secondsPerFrame = (Date.now() - this._lastUpdate) / 1E3
  10332. }
  10333. });
  10334. cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
  10335. cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
  10336. cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
  10337. cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
  10338. cc.DisplayLinkDirector = cc.Director.extend({
  10339. invalid: !1,
  10340. startAnimation: function () {
  10341. this._nextDeltaTimeZero = !0;
  10342. this.invalid = !1
  10343. },
  10344. mainLoop: function () {
  10345. this._purgeDirectorInNextLoop ? (this._purgeDirectorInNextLoop = !1, this.purgeDirector()) : this.invalid || this.drawScene()
  10346. },
  10347. stopAnimation: function () {
  10348. this.invalid = !0
  10349. },
  10350. setAnimationInterval: function (a) {
  10351. this._animationInterval = a;
  10352. this.invalid || (this.stopAnimation(), this.startAnimation())
  10353. }
  10354. });
  10355. cc.Director.sharedDirector = null;
  10356. cc.Director.firstUseDirector = !0;
  10357. cc.Director._getInstance = function () {
  10358. cc.Director.firstUseDirector && (cc.Director.firstUseDirector = !1, cc.Director.sharedDirector = new cc.DisplayLinkDirector, cc.Director.sharedDirector.init());
  10359. return cc.Director.sharedDirector
  10360. };
  10361. cc.defaultFPS = 60;
  10362. cc.Director.PROJECTION_2D = 0;
  10363. cc.Director.PROJECTION_3D = 1;
  10364. cc.Director.PROJECTION_CUSTOM = 3;
  10365. cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;
  10366. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.Director.prototype, _p.setProjection = function (a) {
  10367. this._projection = a;
  10368. cc.eventManager.dispatchEvent(this._eventProjectionChanged)
  10369. },
  10370. _p.setDepthTest = function () { },
  10371. _p.setOpenGLView = function (a) {
  10372. this._winSizeInPoints.width = cc._canvas.width;
  10373. this._winSizeInPoints.height = cc._canvas.height;
  10374. this._openGLView = a || cc.view;
  10375. cc.eventManager && cc.eventManager.setEnabled(!0)
  10376. },
  10377. _p._clear = function () {
  10378. var a = this._openGLView.getViewPortRect();
  10379. cc._renderContext.clearRect(-a.x, a.y, a.width, -a.height)
  10380. },
  10381. _p._createStatsLabel = function () {
  10382. var a = 0,
  10383. a = this._winSizeInPoints.width > this._winSizeInPoints.height ? 0 | this._winSizeInPoints.height / 320 * 24 : 0 | this._winSizeInPoints.width / 320 * 24;
  10384. this._FPSLabel = cc.LabelTTF.create("000.0", "Arial", a);
  10385. this._SPFLabel = cc.LabelTTF.create("0.000", "Arial", a);
  10386. this._drawsLabel = cc.LabelTTF.create("0000", "Arial", a);
  10387. a = cc.DIRECTOR_STATS_POSITION;
  10388. this._drawsLabel.setPosition(this._drawsLabel.width / 2 + a.x, 5 * this._drawsLabel.height / 2 + a.y);
  10389. this._SPFLabel.setPosition(this._SPFLabel.width / 2 + a.x, 3 * this._SPFLabel.height / 2 + a.y);
  10390. this._FPSLabel.setPosition(this._FPSLabel.width / 2 + a.x, this._FPSLabel.height / 2 + a.y)
  10391. },
  10392. _p.getVisibleSize = function () {
  10393. return this.getWinSize()
  10394. },
  10395. _p.getVisibleOrigin = function () {
  10396. return cc.p(0, 0)
  10397. }) : (cc.Director._fpsImage = new Image, cc._addEventListener(cc.Director._fpsImage, "load",
  10398. function () {
  10399. cc.Director._fpsImageLoaded = !0
  10400. }), cc._fpsImage && (cc.Director._fpsImage.src = cc._fpsImage), cc.assert(cc.isFunction(cc._tmp.DirectorWebGL), cc._LogInfos.MissingFile, "CCDirectorWebGL.js"), cc._tmp.DirectorWebGL(), delete cc._tmp.DirectorWebGL);
  10401. cc.Camera = cc.Class.extend({
  10402. _eyeX: null,
  10403. _eyeY: null,
  10404. _eyeZ: null,
  10405. _centerX: null,
  10406. _centerY: null,
  10407. _centerZ: null,
  10408. _upX: null,
  10409. _upY: null,
  10410. _upZ: null,
  10411. _dirty: null,
  10412. _lookupMatrix: null,
  10413. ctor: function () {
  10414. this._lookupMatrix = new cc.kmMat4;
  10415. this.restore()
  10416. },
  10417. description: function () {
  10418. return "\x3cCCCamera | center \x3d(" + this._centerX + "," + this._centerY + "," + this._centerZ + ")\x3e"
  10419. },
  10420. setDirty: function (a) {
  10421. this._dirty = a
  10422. },
  10423. isDirty: function () {
  10424. return this._dirty
  10425. },
  10426. restore: function () {
  10427. this._eyeX = this._eyeY = 0;
  10428. this._eyeZ = cc.Camera.getZEye();
  10429. this._upX = this._centerX = this._centerY = this._centerZ = 0;
  10430. this._upY = 1;
  10431. this._upZ = 0;
  10432. cc.kmMat4Identity(this._lookupMatrix);
  10433. this._dirty = !1
  10434. },
  10435. locate: function () {
  10436. if (this._dirty) {
  10437. var a = new cc.kmVec3,
  10438. b = new cc.kmVec3,
  10439. c = new cc.kmVec3;
  10440. cc.kmVec3Fill(a, this._eyeX, this._eyeY, this._eyeZ);
  10441. cc.kmVec3Fill(b, this._centerX, this._centerY, this._centerZ);
  10442. cc.kmVec3Fill(c, this._upX, this._upY, this._upZ);
  10443. cc.kmMat4LookAt(this._lookupMatrix, a, b, c);
  10444. this._dirty = !1
  10445. }
  10446. cc.kmGLMultMatrix(this._lookupMatrix)
  10447. },
  10448. setEyeXYZ: function (a, b, c) {
  10449. this.setEye(a, b, c)
  10450. },
  10451. setEye: function (a, b, c) {
  10452. this._eyeX = a;
  10453. this._eyeY = b;
  10454. this._eyeZ = c;
  10455. this._dirty = !0
  10456. },
  10457. setCenterXYZ: function (a, b, c) {
  10458. this.setCenter(a, b, c)
  10459. },
  10460. setCenter: function (a, b, c) {
  10461. this._centerX = a;
  10462. this._centerY = b;
  10463. this._centerZ = c;
  10464. this._dirty = !0
  10465. },
  10466. setUpXYZ: function (a, b, c) {
  10467. this.setUp(a, b, c)
  10468. },
  10469. setUp: function (a, b, c) {
  10470. this._upX = a;
  10471. this._upY = b;
  10472. this._upZ = c;
  10473. this._dirty = !0
  10474. },
  10475. getEyeXYZ: function (a, b, c) {
  10476. return {
  10477. x: this._eyeX,
  10478. y: this._eyeY,
  10479. z: this._eyeZ
  10480. }
  10481. },
  10482. getEye: function () {
  10483. return {
  10484. x: this._eyeX,
  10485. y: this._eyeY,
  10486. z: this._eyeZ
  10487. }
  10488. },
  10489. getCenterXYZ: function (a, b, c) {
  10490. return {
  10491. x: this._centerX,
  10492. y: this._centerY,
  10493. z: this._centerZ
  10494. }
  10495. },
  10496. getCenter: function () {
  10497. return {
  10498. x: this._centerX,
  10499. y: this._centerY,
  10500. z: this._centerZ
  10501. }
  10502. },
  10503. getUpXYZ: function (a, b, c) {
  10504. return {
  10505. x: this._upX,
  10506. y: this._upY,
  10507. z: this._upZ
  10508. }
  10509. },
  10510. getUp: function () {
  10511. return {
  10512. x: this._upX,
  10513. y: this._upY,
  10514. z: this._upZ
  10515. }
  10516. },
  10517. _DISALLOW_COPY_AND_ASSIGN: function (a) { }
  10518. });
  10519. cc.Camera.getZEye = function () {
  10520. return cc.FLT_EPSILON
  10521. };
  10522. cc.PRIORITY_NON_SYSTEM = cc.PRIORITY_SYSTEM + 1;
  10523. cc.ListEntry = function (a, b, c, d, e, f) {
  10524. this.prev = a;
  10525. this.next = b;
  10526. this.target = c;
  10527. this.priority = d;
  10528. this.paused = e;
  10529. this.markedForDeletion = f
  10530. };
  10531. cc.HashUpdateEntry = function (a, b, c, d) {
  10532. this.list = a;
  10533. this.entry = b;
  10534. this.target = c;
  10535. this.hh = d
  10536. };
  10537. cc.HashTimerEntry = function (a, b, c, d, e, f, g) {
  10538. this.timers = a;
  10539. this.target = b;
  10540. this.timerIndex = c;
  10541. this.currentTimer = d;
  10542. this.currentTimerSalvaged = e;
  10543. this.paused = f;
  10544. this.hh = g
  10545. };
  10546. cc.Timer = cc.Class.extend({
  10547. _interval: 0,
  10548. _callback: null,
  10549. _target: null,
  10550. _elapsed: 0,
  10551. _runForever: !1,
  10552. _useDelay: !1,
  10553. _timesExecuted: 0,
  10554. _repeat: 0,
  10555. _delay: 0,
  10556. getInterval: function () {
  10557. return this._interval
  10558. },
  10559. setInterval: function (a) {
  10560. this._interval = a
  10561. },
  10562. getCallback: function () {
  10563. return this._callback
  10564. },
  10565. ctor: function (a, b, c, d, e) {
  10566. this._target = a;
  10567. this._callback = b;
  10568. this._elapsed = -1;
  10569. this._interval = c || 0;
  10570. this._delay = e || 0;
  10571. this._useDelay = 0 < this._delay;
  10572. this._repeat = null == d ? cc.REPEAT_FOREVER : d;
  10573. this._runForever = this._repeat == cc.REPEAT_FOREVER
  10574. },
  10575. _doCallback: function () {
  10576. if (cc.isString(this._callback)) this._target[this._callback](this._elapsed);
  10577. else this._callback.call(this._target, this._elapsed)
  10578. },
  10579. update: function (a) {
  10580. if (-1 == this._elapsed) this._timesExecuted = this._elapsed = 0;
  10581. else {
  10582. var b = this._target,
  10583. c = this._callback;
  10584. this._elapsed += a;
  10585. this._runForever && !this._useDelay ? this._elapsed >= this._interval && (b && c && this._doCallback(), this._elapsed = 0) : (this._useDelay ? this._elapsed >= this._delay && (b && c && this._doCallback(), this._elapsed -= this._delay, this._timesExecuted += 1, this._useDelay = !1) : this._elapsed >= this._interval && (b && c && this._doCallback(), this._elapsed = 0, this._timesExecuted += 1), this._timesExecuted > this._repeat && cc.director.getScheduler().unscheduleCallbackForTarget(b, c))
  10586. }
  10587. }
  10588. });
  10589. cc.Scheduler = cc.Class.extend({
  10590. _timeScale: 1,
  10591. _updates: null,
  10592. _hashForUpdates: null,
  10593. _arrayForUpdates: null,
  10594. _hashForTimers: null,
  10595. _arrayForTimes: null,
  10596. _currentTarget: null,
  10597. _currentTargetSalvaged: !1,
  10598. _updateHashLocked: !1,
  10599. ctor: function () {
  10600. this._timeScale = 1;
  10601. this._updates = [[], [], []];
  10602. this._hashForUpdates = {};
  10603. this._arrayForUpdates = [];
  10604. this._hashForTimers = {};
  10605. this._arrayForTimers = [];
  10606. this._currentTarget = null;
  10607. this._updateHashLocked = this._currentTargetSalvaged = !1
  10608. },
  10609. _removeHashElement: function (a) {
  10610. delete this._hashForTimers[a.target.__instanceId];
  10611. cc.arrayRemoveObject(this._arrayForTimers, a);
  10612. a.Timer = null;
  10613. a.target = null
  10614. },
  10615. _removeUpdateFromHash: function (a) {
  10616. if (a = this._hashForUpdates[a.target.__instanceId]) cc.arrayRemoveObject(a.list, a.entry),
  10617. delete this._hashForUpdates[a.target.__instanceId],
  10618. cc.arrayRemoveObject(this._arrayForUpdates, a),
  10619. a.entry = null,
  10620. a.target = null
  10621. },
  10622. _priorityIn: function (a, b, c, d) {
  10623. d = new cc.ListEntry(null, null, b, c, d, !1);
  10624. if (a) {
  10625. for (var e = a.length - 1, f = 0; f <= e && !(c < a[f].priority) ; f++);
  10626. a.splice(f, 0, d)
  10627. } else a = [],
  10628. a.push(d);
  10629. c = new cc.HashUpdateEntry(a, d, b, null);
  10630. this._arrayForUpdates.push(c);
  10631. this._hashForUpdates[b.__instanceId] = c;
  10632. return a
  10633. },
  10634. _appendIn: function (a, b, c) {
  10635. c = new cc.ListEntry(null, null, b, 0, c, !1);
  10636. a.push(c);
  10637. a = new cc.HashUpdateEntry(a, c, b, null);
  10638. this._arrayForUpdates.push(a);
  10639. this._hashForUpdates[b.__instanceId] = a
  10640. },
  10641. setTimeScale: function (a) {
  10642. this._timeScale = a
  10643. },
  10644. getTimeScale: function () {
  10645. return this._timeScale
  10646. },
  10647. update: function (a) {
  10648. var b = this._updates,
  10649. c = this._arrayForTimers,
  10650. d,
  10651. e,
  10652. f;
  10653. this._updateHashLocked = !0;
  10654. 1 != this._timeScale && (a *= this._timeScale);
  10655. e = 0;
  10656. for (f = b.length; e < f && 0 <= e; e++) for (var g = this._updates[e], h = 0, k = g.length; h < k; h++) d = g[h],
  10657. d.paused || d.markedForDeletion || d.target.update(a);
  10658. e = 0;
  10659. for (f = c.length; e < f; e++) {
  10660. d = c[e];
  10661. if (!d) break;
  10662. this._currentTarget = d;
  10663. this._currentTargetSalvaged = !1;
  10664. if (!d.paused) for (d.timerIndex = 0; d.timerIndex < d.timers.length; d.timerIndex++) d.currentTimer = d.timers[d.timerIndex],
  10665. d.currentTimerSalvaged = !1,
  10666. d.currentTimer.update(a),
  10667. d.currentTimer = null;
  10668. this._currentTargetSalvaged && 0 == d.timers.length && (this._removeHashElement(d), e--)
  10669. }
  10670. e = 0;
  10671. for (f = b.length; e < f; e++) for (g = this._updates[e], h = 0, k = g.length; h < k;) {
  10672. d = g[h];
  10673. if (!d) break;
  10674. d.markedForDeletion ? this._removeUpdateFromHash(d) : h++
  10675. }
  10676. this._updateHashLocked = !1;
  10677. this._currentTarget = null
  10678. },
  10679. scheduleCallbackForTarget: function (a, b, c, d, e, f) {
  10680. cc.assert(b, cc._LogInfos.Scheduler_scheduleCallbackForTarget_2);
  10681. cc.assert(a, cc._LogInfos.Scheduler_scheduleCallbackForTarget_3);
  10682. c = c || 0;
  10683. d = null == d ? cc.REPEAT_FOREVER : d;
  10684. e = e || 0;
  10685. f = f || !1;
  10686. var g = this._hashForTimers[a.__instanceId];
  10687. g || (g = new cc.HashTimerEntry(null, a, 0, null, null, f, null), this._arrayForTimers.push(g), this._hashForTimers[a.__instanceId] = g);
  10688. if (null == g.timers) g.timers = [];
  10689. else for (var h = 0; h < g.timers.length; h++) if (f = g.timers[h], b == f._callback) {
  10690. cc.log(cc._LogInfos.Scheduler_scheduleCallbackForTarget, f.getInterval().toFixed(4), c.toFixed(4));
  10691. f._interval = c;
  10692. return
  10693. }
  10694. f = new cc.Timer(a, b, c, d, e);
  10695. g.timers.push(f)
  10696. },
  10697. scheduleUpdateForTarget: function (a, b, c) {
  10698. if (null !== a) {
  10699. var d = this._updates,
  10700. e = this._hashForUpdates[a.__instanceId];
  10701. e ? e.entry.markedForDeletion = !1 : 0 == b ? this._appendIn(d[1], a, c) : 0 > b ? d[0] = this._priorityIn(d[0], a, b, c) : d[2] = this._priorityIn(d[2], a, b, c)
  10702. }
  10703. },
  10704. unscheduleCallbackForTarget: function (a, b) {
  10705. if (null != a && null != b) {
  10706. var c = this._hashForTimers[a.__instanceId];
  10707. if (c) for (var d = c.timers, e = 0, f = d.length; e < f; e++) {
  10708. var g = d[e];
  10709. if (b == g._callback) {
  10710. g != c.currentTimer || c.currentTimerSalvaged || (c.currentTimerSalvaged = !0);
  10711. d.splice(e, 1);
  10712. c.timerIndex >= e && c.timerIndex--;
  10713. 0 == d.length && (this._currentTarget == c ? this._currentTargetSalvaged = !0 : this._removeHashElement(c));
  10714. break
  10715. }
  10716. }
  10717. }
  10718. },
  10719. unscheduleUpdateForTarget: function (a) {
  10720. null != a && (a = this._hashForUpdates[a.__instanceId], null != a && (this._updateHashLocked ? a.entry.markedForDeletion = !0 : this._removeUpdateFromHash(a.entry)))
  10721. },
  10722. unscheduleAllCallbacksForTarget: function (a) {
  10723. if (null != a) {
  10724. var b = this._hashForTimers[a.__instanceId];
  10725. if (b) {
  10726. var c = b.timers; !b.currentTimerSalvaged && 0 <= c.indexOf(b.currentTimer) && (b.currentTimerSalvaged = !0);
  10727. c.length = 0;
  10728. this._currentTarget == b ? this._currentTargetSalvaged = !0 : this._removeHashElement(b)
  10729. }
  10730. this.unscheduleUpdateForTarget(a)
  10731. }
  10732. },
  10733. unscheduleAllCallbacks: function () {
  10734. this.unscheduleAllCallbacksWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  10735. },
  10736. unscheduleAllCallbacksWithMinPriority: function (a) {
  10737. for (var b = this._arrayForTimers, c = this._updates, d = 0, e = b.length; d < e; d++) this.unscheduleAllCallbacksForTarget(b[d].target);
  10738. for (d = 2; 0 <= d; d--) if (!(1 == d && 0 < a || 0 == d && 0 <= a)) for (var b = c[d], e = 0, f = b.length; e < f; e++) this.unscheduleUpdateForTarget(b[e].target)
  10739. },
  10740. pauseAllTargets: function () {
  10741. return this.pauseAllTargetsWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)
  10742. },
  10743. pauseAllTargetsWithMinPriority: function (a) {
  10744. a = [];
  10745. for (var b, c = this._arrayForTimers, d = this._updates, e = 0, f = c.length; e < f; e++) if (b = c[e]) b.paused = !0,
  10746. a.push(b.target);
  10747. e = 0;
  10748. for (f = d.length; e < f; e++) for (var c = d[e], g = 0, h = c.length; g < h; g++) if (b = c[g]) b.paused = !0,
  10749. a.push(b.target);
  10750. return a
  10751. },
  10752. resumeTargets: function (a) {
  10753. if (a) for (var b = 0; b < a.length; b++) this.resumeTarget(a[b])
  10754. },
  10755. pauseTarget: function (a) {
  10756. cc.assert(a, cc._LogInfos.Scheduler_pauseTarget);
  10757. var b = this._hashForTimers[a.__instanceId];
  10758. b && (b.paused = !0);
  10759. if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !0
  10760. },
  10761. resumeTarget: function (a) {
  10762. cc.assert(a, cc._LogInfos.Scheduler_resumeTarget);
  10763. var b = this._hashForTimers[a.__instanceId];
  10764. b && (b.paused = !1);
  10765. if (a = this._hashForUpdates[a.__instanceId]) a.entry.paused = !1
  10766. },
  10767. isTargetPaused: function (a) {
  10768. cc.assert(a, cc._LogInfos.Scheduler_isTargetPaused);
  10769. return (a = this._hashForTimers[a.__instanceId]) ? a.paused : !1
  10770. }
  10771. });
  10772. cc.Scheduler.PRIORITY_SYSTEM = -2147483648;
  10773. cc.PI2 = 2 * Math.PI;
  10774. cc.DrawingPrimitiveCanvas = cc.Class.extend({
  10775. _cacheArray: [],
  10776. _renderContext: null,
  10777. ctor: function (a) {
  10778. this._renderContext = a
  10779. },
  10780. drawPoint: function (a, b) {
  10781. b || (b = 1);
  10782. var c = cc.view.getScaleX(),
  10783. d = cc.view.getScaleY(),
  10784. d = cc.p(a.x * c, a.y * d);
  10785. this._renderContext.beginPath();
  10786. this._renderContext.arc(d.x, -d.y, b * c, 0, 2 * Math.PI, !1);
  10787. this._renderContext.closePath();
  10788. this._renderContext.fill()
  10789. },
  10790. drawPoints: function (a, b, c) {
  10791. if (null != a) {
  10792. c || (c = 1);
  10793. b = this._renderContext;
  10794. var d = cc.view.getScaleX(),
  10795. e = cc.view.getScaleY();
  10796. b.beginPath();
  10797. for (var f = 0, g = a.length; f < g; f++) b.arc(a[f].x * d, -a[f].y * e, c * d, 0, 2 * Math.PI, !1);
  10798. b.closePath();
  10799. b.fill()
  10800. }
  10801. },
  10802. drawLine: function (a, b) {
  10803. var c = this._renderContext,
  10804. d = cc.view.getScaleX(),
  10805. e = cc.view.getScaleY();
  10806. c.beginPath();
  10807. c.moveTo(a.x * d, -a.y * e);
  10808. c.lineTo(b.x * d, -b.y * e);
  10809. c.closePath();
  10810. c.stroke()
  10811. },
  10812. drawRect: function (a, b) {
  10813. this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y));
  10814. this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y));
  10815. this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y));
  10816. this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y))
  10817. },
  10818. drawSolidRect: function (a, b, c) {
  10819. a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)];
  10820. this.drawSolidPoly(a, 4, c)
  10821. },
  10822. drawPoly: function (a, b, c, d) {
  10823. d = d || !1;
  10824. if (null != a) {
  10825. if (3 > a.length) throw Error("Polygon's point must greater than 2");
  10826. var e = a[0];
  10827. b = this._renderContext;
  10828. var f = cc.view.getScaleX(),
  10829. g = cc.view.getScaleY();
  10830. b.beginPath();
  10831. b.moveTo(e.x * f, -e.y * g);
  10832. for (var e = 1, h = a.length; e < h; e++) b.lineTo(a[e].x * f, -a[e].y * g);
  10833. c && b.closePath();
  10834. d ? b.fill() : b.stroke()
  10835. }
  10836. },
  10837. drawSolidPoly: function (a, b, c) {
  10838. this.setDrawColor(c.r, c.g, c.b, c.a);
  10839. this.drawPoly(a, b, !0, !0)
  10840. },
  10841. drawCircle: function (a, b, c, d, e) {
  10842. e = e || !1;
  10843. d = this._renderContext;
  10844. var f = cc.view.getScaleX(),
  10845. g = cc.view.getScaleY();
  10846. d.beginPath();
  10847. d.arc(0 | a.x * f, 0 | -(a.y * g), b * f, -c, -(c - 2 * Math.PI), !1);
  10848. e && d.lineTo(0 | a.x * f, 0 | -(a.y * g));
  10849. d.stroke()
  10850. },
  10851. drawQuadBezier: function (a, b, c, d) {
  10852. for (var e = this._cacheArray, f = e.length = 0, g = 0; g < d; g++) {
  10853. var h = Math.pow(1 - f, 2) * a.x + 2 * (1 - f) * f * b.x + f * f * c.x,
  10854. k = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y;
  10855. e.push(cc.p(h, k));
  10856. f += 1 / d
  10857. }
  10858. e.push(cc.p(c.x, c.y));
  10859. this.drawPoly(e, d + 1, !1, !1)
  10860. },
  10861. drawCubicBezier: function (a, b, c, d, e) {
  10862. for (var f = this._cacheArray, g = f.length = 0, h = 0; h < e; h++) {
  10863. 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,
  10864. 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;
  10865. f.push(cc.p(k, m));
  10866. g += 1 / e
  10867. }
  10868. f.push(cc.p(d.x, d.y));
  10869. this.drawPoly(f, e + 1, !1, !1)
  10870. },
  10871. drawCatmullRom: function (a, b) {
  10872. this.drawCardinalSpline(a, 0.5, b)
  10873. },
  10874. drawCardinalSpline: function (a, b, c) {
  10875. cc._renderContext.strokeStyle = "rgba(255,255,255,1)";
  10876. var d = this._cacheArray;
  10877. d.length = 0;
  10878. for (var e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c,
  10879. 1 == f ? (e = a.length - 1, f = 1) : (e = 0 | f / g, f = (f - g * e) / g),
  10880. 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),
  10881. d.push(e);
  10882. this.drawPoly(d, c + 1, !1, !1)
  10883. },
  10884. drawImage: function (a, b, c, d, e) {
  10885. switch (arguments.length) {
  10886. case 2:
  10887. this._renderContext.drawImage(a, b.x, -(b.y + a.height));
  10888. break;
  10889. case 3:
  10890. this._renderContext.drawImage(a, b.x, -(b.y + c.height), c.width, c.height);
  10891. break;
  10892. case 5:
  10893. this._renderContext.drawImage(a, b.x, b.y, c.width, c.height, d.x, -(d.y + e.height), e.width, e.height);
  10894. break;
  10895. default:
  10896. throw Error("Argument must be non-nil");
  10897. }
  10898. },
  10899. drawStar: function (a, b, c) {
  10900. a = a || this._renderContext;
  10901. b *= cc.view.getScaleX();
  10902. c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b);
  10903. a.fillStyle = c + ",1)";
  10904. var d = b / 10;
  10905. a.beginPath();
  10906. a.moveTo(-b, b);
  10907. a.lineTo(0, d);
  10908. a.lineTo(b, b);
  10909. a.lineTo(d, 0);
  10910. a.lineTo(b, -b);
  10911. a.lineTo(0, -d);
  10912. a.lineTo(-b, -b);
  10913. a.lineTo(-d, 0);
  10914. a.lineTo(-b, b);
  10915. a.closePath();
  10916. a.fill();
  10917. var e = a.createRadialGradient(0, 0, d, 0, 0, b);
  10918. e.addColorStop(0, c + ", 1)");
  10919. e.addColorStop(0.3, c + ", 0.8)");
  10920. e.addColorStop(1, c + ", 0.0)");
  10921. a.fillStyle = e;
  10922. a.beginPath();
  10923. a.arc(0, 0, b - d, 0, cc.PI2, !1);
  10924. a.closePath();
  10925. a.fill()
  10926. },
  10927. drawColorBall: function (a, b, c) {
  10928. a = a || this._renderContext;
  10929. b *= cc.view.getScaleX();
  10930. c = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b);
  10931. var d = a.createRadialGradient(0, 0, b / 10, 0, 0, b);
  10932. d.addColorStop(0, c + ", 1)");
  10933. d.addColorStop(0.3, c + ", 0.8)");
  10934. d.addColorStop(0.6, c + ", 0.4)");
  10935. d.addColorStop(1, c + ", 0.0)");
  10936. a.fillStyle = d;
  10937. a.beginPath();
  10938. a.arc(0, 0, b, 0, cc.PI2, !1);
  10939. a.closePath();
  10940. a.fill()
  10941. },
  10942. fillText: function (a, b, c) {
  10943. this._renderContext.fillText(a, b, -c)
  10944. },
  10945. setDrawColor: function (a, b, c, d) {
  10946. this._renderContext.fillStyle = "rgba(" + a + "," + b + "," + c + "," + d / 255 + ")";
  10947. this._renderContext.strokeStyle = "rgba(" + a + "," + b + "," + c + "," + d / 255 + ")"
  10948. },
  10949. setPointSize: function (a) { },
  10950. setLineWidth: function (a) {
  10951. this._renderContext.lineWidth = a * cc.view.getScaleX()
  10952. }
  10953. });
  10954. cc.DrawingPrimitiveWebGL = cc.Class.extend({
  10955. _renderContext: null,
  10956. _initialized: !1,
  10957. _shader: null,
  10958. _colorLocation: -1,
  10959. _colorArray: null,
  10960. _pointSizeLocation: -1,
  10961. _pointSize: -1,
  10962. ctor: function (a) {
  10963. null == a && (a = cc._renderContext);
  10964. if (!a instanceof WebGLRenderingContext) throw "Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext";
  10965. this._renderContext = a;
  10966. this._colorArray = new Float32Array([1, 1, 1, 1])
  10967. },
  10968. lazy_init: function () {
  10969. this._initialized || (this._shader = cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR), this._colorLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_color"), this._pointSizeLocation = this._renderContext.getUniformLocation(this._shader.getProgram(), "u_pointSize"), this._initialized = !0)
  10970. },
  10971. drawInit: function () {
  10972. this._initialized = !1
  10973. },
  10974. drawPoint: function (a) {
  10975. this.lazy_init();
  10976. var b = this._renderContext;
  10977. this._shader.use();
  10978. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10979. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10980. b.uniform4fv(this._colorLocation, this._colorArray);
  10981. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  10982. var c = b.createBuffer();
  10983. b.bindBuffer(b.ARRAY_BUFFER, c);
  10984. b.bufferData(b.ARRAY_BUFFER, new Float32Array([a.x, a.y]), b.STATIC_DRAW);
  10985. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  10986. b.drawArrays(b.POINTS, 0, 1);
  10987. b.deleteBuffer(c);
  10988. cc.incrementGLDraws(1)
  10989. },
  10990. drawPoints: function (a, b) {
  10991. if (a && 0 != a.length) {
  10992. this.lazy_init();
  10993. var c = this._renderContext;
  10994. this._shader.use();
  10995. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  10996. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  10997. c.uniform4fv(this._colorLocation, this._colorArray);
  10998. this._shader.setUniformLocationWith1f(this._pointSizeLocation, this._pointSize);
  10999. var d = c.createBuffer();
  11000. c.bindBuffer(c.ARRAY_BUFFER, d);
  11001. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray(a), c.STATIC_DRAW);
  11002. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  11003. c.drawArrays(c.POINTS, 0, a.length);
  11004. c.deleteBuffer(d);
  11005. cc.incrementGLDraws(1)
  11006. }
  11007. },
  11008. _pointsToTypeArray: function (a) {
  11009. for (var b = new Float32Array(2 * a.length), c = 0; c < a.length; c++) b[2 * c] = a[c].x,
  11010. b[2 * c + 1] = a[c].y;
  11011. return b
  11012. },
  11013. drawLine: function (a, b) {
  11014. this.lazy_init();
  11015. var c = this._renderContext;
  11016. this._shader.use();
  11017. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11018. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11019. c.uniform4fv(this._colorLocation, this._colorArray);
  11020. var d = c.createBuffer();
  11021. c.bindBuffer(c.ARRAY_BUFFER, d);
  11022. c.bufferData(c.ARRAY_BUFFER, this._pointsToTypeArray([a, b]), c.STATIC_DRAW);
  11023. c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, c.FLOAT, !1, 0, 0);
  11024. c.drawArrays(c.LINES, 0, 2);
  11025. c.deleteBuffer(d);
  11026. cc.incrementGLDraws(1)
  11027. },
  11028. drawRect: function (a, b) {
  11029. this.drawLine(cc.p(a.x, a.y), cc.p(b.x, a.y));
  11030. this.drawLine(cc.p(b.x, a.y), cc.p(b.x, b.y));
  11031. this.drawLine(cc.p(b.x, b.y), cc.p(a.x, b.y));
  11032. this.drawLine(cc.p(a.x, b.y), cc.p(a.x, a.y))
  11033. },
  11034. drawSolidRect: function (a, b, c) {
  11035. a = [a, cc.p(b.x, a.y), b, cc.p(a.x, b.y)];
  11036. this.drawSolidPoly(a, 4, c)
  11037. },
  11038. drawPoly: function (a, b, c) {
  11039. this.lazy_init();
  11040. b = this._renderContext;
  11041. this._shader.use();
  11042. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11043. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11044. b.uniform4fv(this._colorLocation, this._colorArray);
  11045. var d = b.createBuffer();
  11046. b.bindBuffer(b.ARRAY_BUFFER, d);
  11047. b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW);
  11048. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  11049. c ? b.drawArrays(b.LINE_LOOP, 0, a.length) : b.drawArrays(b.LINE_STRIP, 0, a.length);
  11050. b.deleteBuffer(d);
  11051. cc.incrementGLDraws(1)
  11052. },
  11053. drawSolidPoly: function (a, b, c) {
  11054. this.lazy_init();
  11055. c && this.setDrawColor(c.r, c.g, c.b, c.a);
  11056. b = this._renderContext;
  11057. this._shader.use();
  11058. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11059. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11060. b.uniform4fv(this._colorLocation, this._colorArray);
  11061. c = b.createBuffer();
  11062. b.bindBuffer(b.ARRAY_BUFFER, c);
  11063. b.bufferData(b.ARRAY_BUFFER, this._pointsToTypeArray(a), b.STATIC_DRAW);
  11064. b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, b.FLOAT, !1, 0, 0);
  11065. b.drawArrays(b.TRIANGLE_FAN, 0, a.length);
  11066. b.deleteBuffer(c);
  11067. cc.incrementGLDraws(1)
  11068. },
  11069. drawCircle: function (a, b, c, d, e) {
  11070. this.lazy_init();
  11071. var f = 1;
  11072. e && f++;
  11073. var g = 2 * Math.PI / d;
  11074. if (e = new Float32Array(2 * (d + 2))) {
  11075. for (var h = 0; h <= d; h++) {
  11076. var k = h * g,
  11077. m = b * Math.cos(k + c) + a.x,
  11078. k = b * Math.sin(k + c) + a.y;
  11079. e[2 * h] = m;
  11080. e[2 * h + 1] = k
  11081. }
  11082. e[2 * (d + 1)] = a.x;
  11083. e[2 * (d + 1) + 1] = a.y;
  11084. a = this._renderContext;
  11085. this._shader.use();
  11086. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11087. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11088. a.uniform4fv(this._colorLocation, this._colorArray);
  11089. b = a.createBuffer();
  11090. a.bindBuffer(a.ARRAY_BUFFER, b);
  11091. a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW);
  11092. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11093. a.drawArrays(a.LINE_STRIP, 0, d + f);
  11094. a.deleteBuffer(b);
  11095. cc.incrementGLDraws(1)
  11096. }
  11097. },
  11098. drawQuadBezier: function (a, b, c, d) {
  11099. this.lazy_init();
  11100. 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,
  11101. e[2 * g + 1] = Math.pow(1 - f, 2) * a.y + 2 * (1 - f) * f * b.y + f * f * c.y,
  11102. f += 1 / d;
  11103. e[2 * d] = c.x;
  11104. e[2 * d + 1] = c.y;
  11105. a = this._renderContext;
  11106. this._shader.use();
  11107. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11108. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11109. a.uniform4fv(this._colorLocation, this._colorArray);
  11110. b = a.createBuffer();
  11111. a.bindBuffer(a.ARRAY_BUFFER, b);
  11112. a.bufferData(a.ARRAY_BUFFER, e, a.STATIC_DRAW);
  11113. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11114. a.drawArrays(a.LINE_STRIP, 0, d + 1);
  11115. a.deleteBuffer(b);
  11116. cc.incrementGLDraws(1)
  11117. },
  11118. drawCubicBezier: function (a, b, c, d, e) {
  11119. this.lazy_init();
  11120. 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,
  11121. f[2 * h + 1] = Math.pow(1 - g, 3) * a.y + 3 * Math.pow(1 -
  11122. g, 2) * g * b.y + 3 * (1 - g) * g * g * c.y + g * g * g * d.y,
  11123. g += 1 / e;
  11124. f[2 * e] = d.x;
  11125. f[2 * e + 1] = d.y;
  11126. a = this._renderContext;
  11127. this._shader.use();
  11128. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11129. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11130. a.uniform4fv(this._colorLocation, this._colorArray);
  11131. b = a.createBuffer();
  11132. a.bindBuffer(a.ARRAY_BUFFER, b);
  11133. a.bufferData(a.ARRAY_BUFFER, f, a.STATIC_DRAW);
  11134. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11135. a.drawArrays(a.LINE_STRIP, 0, e + 1);
  11136. a.deleteBuffer(b);
  11137. cc.incrementGLDraws(1)
  11138. },
  11139. drawCatmullRom: function (a, b) {
  11140. this.drawCardinalSpline(a, 0.5, b)
  11141. },
  11142. drawCardinalSpline: function (a, b, c) {
  11143. this.lazy_init();
  11144. for (var d = new Float32Array(2 * (c + 1)), e, f, g = 1 / a.length, h = 0; h < c + 1; h++) f = h / c,
  11145. 1 == f ? (e = a.length - 1, f = 1) : (e = 0 | f / g, f = (f - g * e) / g),
  11146. e = cc.CardinalSplineAt(cc.getControlPointAt(a, e - 1), cc.getControlPointAt(a, e), cc.getControlPointAt(a, e + 1), cc.getControlPointAt(a, e + 2), b, f),
  11147. d[2 * h] = e.x,
  11148. d[2 * h + 1] = e.y;
  11149. a = this._renderContext;
  11150. this._shader.use();
  11151. this._shader.setUniformForModelViewAndProjectionMatrixWithMat4();
  11152. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION);
  11153. a.uniform4fv(this._colorLocation, this._colorArray);
  11154. b = a.createBuffer();
  11155. a.bindBuffer(a.ARRAY_BUFFER, b);
  11156. a.bufferData(a.ARRAY_BUFFER, d, a.STATIC_DRAW);
  11157. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, 0, 0);
  11158. a.drawArrays(a.LINE_STRIP, 0, c + 1);
  11159. a.deleteBuffer(b);
  11160. cc.incrementGLDraws(1)
  11161. },
  11162. setDrawColor: function (a, b, c, d) {
  11163. this._colorArray[0] = a / 255;
  11164. this._colorArray[1] = b / 255;
  11165. this._colorArray[2] = c / 255;
  11166. this._colorArray[3] = d / 255
  11167. },
  11168. setPointSize: function (a) {
  11169. this._pointSize = a * cc.contentScaleFactor()
  11170. },
  11171. setLineWidth: function (a) {
  11172. this._renderContext.lineWidth && this._renderContext.lineWidth(a)
  11173. }
  11174. });
  11175. cc._tmp.WebGLLabelTTF = function () {
  11176. var a = cc.LabelTTF.prototype;
  11177. a.setColor = cc.Sprite.prototype.setColor;
  11178. a._setColorsString = function () {
  11179. this._needUpdateTexture = !0;
  11180. var a = this._strokeColor,
  11181. c = this._textFillColor;
  11182. this._shadowColorStr = "rgba(128,128,128," + this._shadowOpacity + ")";
  11183. this._fillColorStr = "rgba(" + (0 | c.r) + "," + (0 | c.g) + "," + (0 | c.b) + ", 1)";
  11184. this._strokeColorStr = "rgba(" + (0 | a.r) + "," + (0 | a.g) + "," + (0 | a.b) + ", 1)"
  11185. };
  11186. a.updateDisplayedColor = cc.Sprite.prototype.updateDisplayedColor;
  11187. a.setOpacity = cc.Sprite.prototype.setOpacity;
  11188. a.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity;
  11189. a.initWithStringAndTextDefinition = function (a, c) {
  11190. if (!cc.Sprite.prototype.init.call(this)) return !1;
  11191. this.shaderProgram = cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM);
  11192. this._updateWithTextDefinition(c, !1);
  11193. this.string = a;
  11194. return !0
  11195. };
  11196. a.setFontFillColor = function (a) {
  11197. var c = this._textFillColor;
  11198. if (c.r != a.r || c.g != a.g || c.b != a.b) c.r = a.r,
  11199. c.g = a.g,
  11200. c.b = a.b,
  11201. this._setColorsString(),
  11202. this._needUpdateTexture = !0
  11203. };
  11204. a.draw = function (a) {
  11205. if (this._string && "" != this._string) {
  11206. a = a || cc._renderContext;
  11207. var c = this._texture;
  11208. c && c._isLoaded && (this._shaderProgram.use(), this._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4(), cc.glBlendFunc(this._blendFunc.src, this._blendFunc.dst), cc.glBindTexture2D(c), cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX), a.bindBuffer(a.ARRAY_BUFFER, this._quadWebBuffer), this._quadDirty && (a.bufferData(a.ARRAY_BUFFER, this._quad.arrayBuffer, a.STATIC_DRAW), this._quadDirty = !1), a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, a.FLOAT, !1, 24, 0), a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, 24, 16), a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, 24, 12), a.drawArrays(a.TRIANGLE_STRIP, 0, 4));
  11209. if (1 === cc.SPRITE_DEBUG_DRAW) a = this._quad,
  11210. a = [cc.p(a.tl.vertices.x, a.tl.vertices.y), cc.p(a.bl.vertices.x, a.bl.vertices.y), cc.p(a.br.vertices.x, a.br.vertices.y), cc.p(a.tr.vertices.x, a.tr.vertices.y)],
  11211. cc._drawingUtil.drawPoly(a, 4, !0);
  11212. else if (2 === cc.SPRITE_DEBUG_DRAW) {
  11213. a = this.getTextureRect();
  11214. var c = this.offsetX,
  11215. d = this.offsetY;
  11216. a = [cc.p(c, d), cc.p(c + a.width, d), cc.p(c + a.width, d + a.height), cc.p(c, d + a.height)];
  11217. cc._drawingUtil.drawPoly(a, 4, !0)
  11218. }
  11219. cc.g_NumberOfDraws++
  11220. }
  11221. };
  11222. a.setTextureRect = cc.Sprite.prototype.setTextureRect
  11223. };
  11224. cc._tmp.PrototypeLabelTTF = function () {
  11225. var a = cc.LabelTTF.prototype;
  11226. cc.defineGetterSetter(a, "color", a.getColor, a.setColor);
  11227. cc.defineGetterSetter(a, "opacity", a.getOpacity, a.setOpacity);
  11228. cc.defineGetterSetter(a, "string", a.getString, a.setString);
  11229. cc.defineGetterSetter(a, "textAlign", a.getHorizontalAlignment, a.setHorizontalAlignment);
  11230. cc.defineGetterSetter(a, "verticalAlign", a.getVerticalAlignment, a.setVerticalAlignment);
  11231. cc.defineGetterSetter(a, "fontSize", a.getFontSize, a.setFontSize);
  11232. cc.defineGetterSetter(a, "fontName", a.getFontName, a.setFontName);
  11233. cc.defineGetterSetter(a, "font", a._getFont, a._setFont);
  11234. cc.defineGetterSetter(a, "boundingWidth", a._getBoundingWidth, a._setBoundingWidth);
  11235. cc.defineGetterSetter(a, "boundingHeight", a._getBoundingHeight, a._setBoundingHeight);
  11236. cc.defineGetterSetter(a, "fillStyle", a._getFillStyle, a.setFontFillColor);
  11237. cc.defineGetterSetter(a, "strokeStyle", a._getStrokeStyle, a._setStrokeStyle);
  11238. cc.defineGetterSetter(a, "lineWidth", a._getLineWidth, a._setLineWidth);
  11239. cc.defineGetterSetter(a, "shadowOffsetX", a._getShadowOffsetX, a._setShadowOffsetX);
  11240. cc.defineGetterSetter(a, "shadowOffsetY", a._getShadowOffsetY, a._setShadowOffsetY);
  11241. cc.defineGetterSetter(a, "shadowOpacity", a._getShadowOpacity, a._setShadowOpacity);
  11242. cc.defineGetterSetter(a, "shadowBlur", a._getShadowBlur, a._setShadowBlur)
  11243. };
  11244. cc.LabelTTF = cc.Sprite.extend({
  11245. _dimensions: null,
  11246. _hAlignment: cc.TEXT_ALIGNMENT_CENTER,
  11247. _vAlignment: cc.VERTICAL_TEXT_ALIGNMENT_TOP,
  11248. _fontName: null,
  11249. _fontSize: 0,
  11250. _string: "",
  11251. _originalText: null,
  11252. _isMultiLine: !1,
  11253. _fontStyleStr: null,
  11254. _shadowEnabled: !1,
  11255. _shadowOffset: null,
  11256. _shadowOpacity: 0,
  11257. _shadowBlur: 0,
  11258. _shadowColorStr: null,
  11259. _strokeEnabled: !1,
  11260. _strokeColor: null,
  11261. _strokeSize: 0,
  11262. _strokeColorStr: null,
  11263. _textFillColor: null,
  11264. _fillColorStr: null,
  11265. _strokeShadowOffsetX: 0,
  11266. _strokeShadowOffsetY: 0,
  11267. _needUpdateTexture: !1,
  11268. _labelCanvas: null,
  11269. _labelContext: null,
  11270. _lineWidths: null,
  11271. _className: "LabelTTF",
  11272. initWithString: function (a, b, c, d, e, f) {
  11273. a = a ? a + "" : "";
  11274. c = c || 16;
  11275. d = d || cc.size(0, 0);
  11276. e = e || cc.TEXT_ALIGNMENT_LEFT;
  11277. f = f || cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  11278. this._opacityModifyRGB = !1;
  11279. this._dimensions = cc.size(d.width, d.height);
  11280. this._fontName = b || "Arial";
  11281. this._hAlignment = e;
  11282. this._vAlignment = f;
  11283. this._fontSize = c;
  11284. this._fontStyleStr = this._fontSize + "px '" + b + "'";
  11285. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(b, this._fontSize);
  11286. this.string = a;
  11287. this._setColorsString();
  11288. this._updateTexture();
  11289. this._needUpdateTexture = !1;
  11290. return !0
  11291. },
  11292. ctor: function (a, b, c, d, e, f) {
  11293. cc.Sprite.prototype.ctor.call(this);
  11294. this._dimensions = cc.size(0, 0);
  11295. this._hAlignment = cc.TEXT_ALIGNMENT_LEFT;
  11296. this._vAlignment = cc.VERTICAL_TEXT_ALIGNMENT_TOP;
  11297. this._opacityModifyRGB = !1;
  11298. this._fontStyleStr = "";
  11299. this._fontName = "Arial";
  11300. this._shadowEnabled = this._isMultiLine = !1;
  11301. this._shadowOffset = cc.p(0, 0);
  11302. this._shadowBlur = this._shadowOpacity = 0;
  11303. this._shadowColorStr = "rgba(128, 128, 128, 0.5)";
  11304. this._strokeEnabled = !1;
  11305. this._strokeColor = cc.color(255, 255, 255, 255);
  11306. this._strokeSize = 0;
  11307. this._strokeColorStr = "";
  11308. this._textFillColor = cc.color(255, 255, 255, 255);
  11309. this._fillColorStr = "rgba(255,255,255,1)";
  11310. this._strokeShadowOffsetY = this._strokeShadowOffsetX = 0;
  11311. this._needUpdateTexture = !1;
  11312. this._lineWidths = [];
  11313. this._setColorsString();
  11314. b && b instanceof cc.FontDefinition ? this.initWithStringAndTextDefinition(a, b) : cc.LabelTTF.prototype.initWithString.call(this, a, b, c, d, e, f)
  11315. },
  11316. init: function () {
  11317. return this.initWithString(" ", this._fontName, this._fontSize)
  11318. },
  11319. _measureConfig: function () {
  11320. this._getLabelContext().font = this._fontStyleStr
  11321. },
  11322. _measure: function (a) {
  11323. return this._getLabelContext().measureText(a).width
  11324. },
  11325. description: function () {
  11326. return "\x3ccc.LabelTTF | FontName \x3d" + this._fontName + " FontSize \x3d " + this._fontSize.toFixed(1) + "\x3e"
  11327. },
  11328. setColor: null,
  11329. _setColorsString: null,
  11330. updateDisplayedColor: null,
  11331. setOpacity: null,
  11332. updateDisplayedOpacity: null,
  11333. updateDisplayedOpacityForCanvas: function (a) {
  11334. cc.Node.prototype.updateDisplayedOpacity.call(this, a);
  11335. this._setColorsString()
  11336. },
  11337. getString: function () {
  11338. return this._string
  11339. },
  11340. getHorizontalAlignment: function () {
  11341. return this._hAlignment
  11342. },
  11343. getVerticalAlignment: function () {
  11344. return this._vAlignment
  11345. },
  11346. getDimensions: function () {
  11347. return cc.size(this._dimensions)
  11348. },
  11349. getFontSize: function () {
  11350. return this._fontSize
  11351. },
  11352. getFontName: function () {
  11353. return this._fontName
  11354. },
  11355. initWithStringAndTextDefinition: null,
  11356. setTextDefinition: function (a) {
  11357. a && this._updateWithTextDefinition(a, !0)
  11358. },
  11359. getTextDefinition: function () {
  11360. return this._prepareTextDefinition(!1)
  11361. },
  11362. enableShadow: function (a, b, c, d) {
  11363. c = c || 0.5; !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11364. var e = this._shadowOffset;
  11365. if (e && e.x != a || e._y != b) e.x = a,
  11366. e.y = b;
  11367. this._shadowOpacity != c && (this._shadowOpacity = c);
  11368. this._setColorsString();
  11369. this._shadowBlur != d && (this._shadowBlur = d);
  11370. this._needUpdateTexture = !0
  11371. },
  11372. _getShadowOffsetX: function () {
  11373. return this._shadowOffset.x
  11374. },
  11375. _setShadowOffsetX: function (a) {
  11376. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11377. this._shadowOffset.x != a && (this._shadowOffset.x = a, this._needUpdateTexture = !0)
  11378. },
  11379. _getShadowOffsetY: function () {
  11380. return this._shadowOffset._y
  11381. },
  11382. _setShadowOffsetY: function (a) {
  11383. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11384. this._shadowOffset._y != a && (this._shadowOffset._y = a, this._needUpdateTexture = !0)
  11385. },
  11386. _getShadowOffset: function () {
  11387. return cc.p(this._shadowOffset.x, this._shadowOffset.y)
  11388. },
  11389. _setShadowOffset: function (a) {
  11390. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11391. if (this._shadowOffset.x != a.x || this._shadowOffset.y != a.y) this._shadowOffset.x = a.x,
  11392. this._shadowOffset.y = a.y,
  11393. this._needUpdateTexture = !0
  11394. },
  11395. _getShadowOpacity: function () {
  11396. return this._shadowOpacity
  11397. },
  11398. _setShadowOpacity: function (a) {
  11399. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11400. this._shadowOpacity != a && (this._shadowOpacity = a, this._setColorsString(), this._needUpdateTexture = !0)
  11401. },
  11402. _getShadowBlur: function () {
  11403. return this._shadowBlur
  11404. },
  11405. _setShadowBlur: function (a) {
  11406. !1 === this._shadowEnabled && (this._shadowEnabled = !0);
  11407. this._shadowBlur != a && (this._shadowBlur = a, this._needUpdateTexture = !0)
  11408. },
  11409. disableShadow: function () {
  11410. this._shadowEnabled && (this._shadowEnabled = !1, this._needUpdateTexture = !0)
  11411. },
  11412. enableStroke: function (a, b) {
  11413. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11414. var c = this._strokeColor;
  11415. if (c.r !== a.r || c.g !== a.g || c.b !== a.b) c.r = a.r,
  11416. c.g = a.g,
  11417. c.b = a.b,
  11418. this._setColorsString();
  11419. this._strokeSize !== b && (this._strokeSize = b || 0);
  11420. this._needUpdateTexture = !0
  11421. },
  11422. _getStrokeStyle: function () {
  11423. return this._strokeColor
  11424. },
  11425. _setStrokeStyle: function (a) {
  11426. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11427. var b = this._strokeColor;
  11428. if (b.r !== a.r || b.g !== a.g || b.b !== a.b) b.r = a.r,
  11429. b.g = a.g,
  11430. b.b = a.b,
  11431. this._setColorsString(),
  11432. this._needUpdateTexture = !0
  11433. },
  11434. _getLineWidth: function () {
  11435. return this._strokeSize
  11436. },
  11437. _setLineWidth: function (a) {
  11438. !1 === this._strokeEnabled && (this._strokeEnabled = !0);
  11439. this._strokeSize !== a && (this._strokeSize = a || 0, this._needUpdateTexture = !0)
  11440. },
  11441. disableStroke: function () {
  11442. this._strokeEnabled && (this._strokeEnabled = !1, this._needUpdateTexture = !0)
  11443. },
  11444. setFontFillColor: null,
  11445. _getFillStyle: function () {
  11446. return this._textFillColor
  11447. },
  11448. _updateWithTextDefinition: function (a, b) {
  11449. a.fontDimensions ? (this._dimensions.width = a.boundingWidth, this._dimensions.height = a.boundingHeight) : (this._dimensions.width = 0, this._dimensions.height = 0);
  11450. this._hAlignment = a.textAlign;
  11451. this._vAlignment = a.verticalAlign;
  11452. this._fontName = a.fontName;
  11453. this._fontSize = a.fontSize || 12;
  11454. this._fontStyleStr = this._fontSize + "px '" + this._fontName + "'";
  11455. this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize);
  11456. a.shadowEnabled && this.enableShadow(a.shadowOffsetX, a.shadowOffsetY, a.shadowOpacity, a.shadowBlur);
  11457. a.strokeEnabled && this.enableStroke(a.strokeStyle, a.lineWidth);
  11458. this.setFontFillColor(a.fillStyle);
  11459. b && this._updateTexture()
  11460. },
  11461. _prepareTextDefinition: function (a) {
  11462. var b = new cc.FontDefinition;
  11463. 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);
  11464. b.fontName = this._fontName;
  11465. b.textAlign = this._hAlignment;
  11466. b.verticalAlign = this._vAlignment;
  11467. if (this._strokeEnabled) {
  11468. b.strokeEnabled = !0;
  11469. var c = this._strokeColor;
  11470. b.strokeStyle = cc.color(c.r, c.g, c.b);
  11471. b.lineWidth = this._strokeSize
  11472. } else b.strokeEnabled = !1;
  11473. 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;
  11474. a = this._textFillColor;
  11475. b.fillStyle = cc.color(a.r, a.g, a.b);
  11476. return b
  11477. },
  11478. _fontClientHeight: 18,
  11479. setString: function (a) {
  11480. a = String(a);
  11481. this._originalText != a && (this._originalText = a + "", this._updateString(), this._needUpdateTexture = !0)
  11482. },
  11483. _updateString: function () {
  11484. this._string = this._originalText
  11485. },
  11486. setHorizontalAlignment: function (a) {
  11487. a !== this._hAlignment && (this._hAlignment = a, this._needUpdateTexture = !0)
  11488. },
  11489. setVerticalAlignment: function (a) {
  11490. a != this._vAlignment && (this._vAlignment = a, this._needUpdateTexture = !0)
  11491. },
  11492. setDimensions: function (a, b) {
  11493. var c;
  11494. void 0 === b ? (c = a.width, b = a.height) : c = a;
  11495. if (c != this._dimensions.width || b != this._dimensions.height) this._dimensions.width = c,
  11496. this._dimensions.height = b,
  11497. this._updateString(),
  11498. this._needUpdateTexture = !0
  11499. },
  11500. _getBoundingWidth: function () {
  11501. return this._dimensions.width
  11502. },
  11503. _setBoundingWidth: function (a) {
  11504. a != this._dimensions.width && (this._dimensions.width = a, this._updateString(), this._needUpdateTexture = !0)
  11505. },
  11506. _getBoundingHeight: function () {
  11507. return this._dimensions.height
  11508. },
  11509. _setBoundingHeight: function (a) {
  11510. a != this._dimensions.height && (this._dimensions.height = a, this._updateString(), this._needUpdateTexture = !0)
  11511. },
  11512. setFontSize: function (a) {
  11513. this._fontSize !== a && (this._fontSize = a, this._fontStyleStr = a + "px '" + this._fontName + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, a), this._needUpdateTexture = !0)
  11514. },
  11515. setFontName: function (a) {
  11516. this._fontName && this._fontName != a && (this._fontName = a, this._fontStyleStr = this._fontSize + "px '" + a + "'", this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(a, this._fontSize), this._needUpdateTexture = !0)
  11517. },
  11518. _getFont: function () {
  11519. return this._fontStyleStr
  11520. },
  11521. _setFont: function (a) {
  11522. var b = cc.LabelTTF._fontStyleRE.exec(a);
  11523. b && (this._fontSize = parseInt(b[1]), this._fontName = b[2], this._fontStyleStr = a, this._fontClientHeight = cc.LabelTTF.__getFontHeightByDiv(this._fontName, this._fontSize), this._needUpdateTexture = !0)
  11524. },
  11525. _drawTTFInCanvas: function (a) {
  11526. if (a) {
  11527. var b = this._strokeShadowOffsetX,
  11528. c = this._strokeShadowOffsetY,
  11529. d = this._contentSize.height - c,
  11530. e = this._vAlignment,
  11531. f = this._hAlignment,
  11532. g = this._fontClientHeight,
  11533. h = this._strokeSize;
  11534. a.setTransform(1, 0, 0, 1, 0 + 0.5 * b, d + 0.5 * c);
  11535. a.font != this._fontStyleStr && (a.font = this._fontStyleStr);
  11536. a.fillStyle = this._fillColorStr;
  11537. var k = c = 0,
  11538. m = this._strokeEnabled;
  11539. m && (a.lineWidth = 2 * h, a.strokeStyle = this._strokeColorStr);
  11540. this._shadowEnabled && (h = this._shadowOffset, a.shadowColor = this._shadowColorStr, a.shadowOffsetX = h.x, a.shadowOffsetY = -h.y, a.shadowBlur = this._shadowBlur);
  11541. a.textBaseline = cc.LabelTTF._textBaseline[e];
  11542. a.textAlign = cc.LabelTTF._textAlign[f];
  11543. b = this._contentSize.width - b;
  11544. c = f === cc.TEXT_ALIGNMENT_RIGHT ? c + b : f === cc.TEXT_ALIGNMENT_CENTER ? c + b / 2 : c + 0;
  11545. if (this._isMultiLine) for (f = this._strings.length, e === cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM ? k = g + d - g * f : e === cc.VERTICAL_TEXT_ALIGNMENT_CENTER && (k = g / 2 + (d - g * f) / 2), e = 0; e < f; e++) b = this._strings[e],
  11546. h = -d + g * e + k,
  11547. m && a.strokeText(b, c, h),
  11548. a.fillText(b, c, h);
  11549. else e !== cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM && (k = e === cc.VERTICAL_TEXT_ALIGNMENT_TOP ? k - d : k - 0.5 * d),
  11550. m && a.strokeText(this._string, c, k),
  11551. a.fillText(this._string, c, k)
  11552. }
  11553. },
  11554. _getLabelContext: function () {
  11555. if (this._labelContext) return this._labelContext;
  11556. if (!this._labelCanvas) {
  11557. var a = cc.newElement("canvas"),
  11558. b = new cc.Texture2D;
  11559. b.initWithElement(a);
  11560. this.texture = b;
  11561. this._labelCanvas = a
  11562. }
  11563. return this._labelContext = this._labelCanvas.getContext("2d")
  11564. },
  11565. _checkWarp: function (a, b, c) {
  11566. var d = a[b],
  11567. e = this._measure(d);
  11568. if (e > c && 1 < d.length) {
  11569. for (var f = c / e * d.length | 0, g = d.substr(f), h = e - this._measure(g), k, m = 0, n = 0; h > c && 100 > n++;) f *= c / h,
  11570. f |= 0,
  11571. g = d.substr(f),
  11572. h = e - this._measure(g);
  11573. for (n = 0; h < c && 100 > n++;) g && (m = (k = cc.LabelTTF._wordRex.exec(g)) ? k[0].length : 1, k = g),
  11574. f += m,
  11575. g = d.substr(f),
  11576. h = e - this._measure(g);
  11577. f -= m;
  11578. c = d.substr(0, f);
  11579. cc.LabelTTF.wrapInspection && cc.LabelTTF._symbolRex.test(k || g) && (e = cc.LabelTTF._lastWordRex.exec(c), f -= e ? e[0].length : 0, k = d.substr(f), c = d.substr(0, f));
  11580. cc.LabelTTF._firsrEnglish.test(k) && (e = cc.LabelTTF._lastEnglish.exec(c)) && c !== e[0] && (f -= e[0].length, k = d.substr(f), c = d.substr(0, f));
  11581. a[b] = k || g;
  11582. a.splice(b, 0, c)
  11583. }
  11584. },
  11585. _updateTTF: function () {
  11586. var a = this._dimensions.width,
  11587. b,
  11588. c,
  11589. d = this._lineWidths;
  11590. d.length = 0;
  11591. this._isMultiLine = !1;
  11592. this._measureConfig();
  11593. if (0 !== a) for (this._strings = this._string.split("\n"), b = 0; b < this._strings.length; b++) this._checkWarp(this._strings, b, a);
  11594. else for (this._strings = this._string.split("\n"), b = 0, c = this._strings.length; b < c; b++) d.push(this._measure(this._strings[b]));
  11595. 0 < this._strings.length && (this._isMultiLine = !0);
  11596. c = b = 0;
  11597. this._strokeEnabled && (b = c = 2 * this._strokeSize);
  11598. if (this._shadowEnabled) {
  11599. var e = this._shadowOffset;
  11600. b += 2 * Math.abs(e.x);
  11601. c += 2 * Math.abs(e.y)
  11602. }
  11603. a = 0 === a ? this._isMultiLine ? cc.size(0 | Math.max.apply(Math, d) + b, 0 | this._fontClientHeight * this._strings.length + c) : cc.size(0 | this._measure(this._string) + b, 0 | this._fontClientHeight + c) : 0 === this._dimensions.height ? this._isMultiLine ? cc.size(0 | a + b, 0 | this._fontClientHeight * this._strings.length + c) : cc.size(0 | a + b, 0 | this._fontClientHeight + c) : cc.size(0 | a + b, 0 | this._dimensions.height +
  11604. c);
  11605. this.setContentSize(a);
  11606. this._strokeShadowOffsetX = b;
  11607. this._strokeShadowOffsetY = c;
  11608. d = this._anchorPoint;
  11609. this._anchorPointInPoints.x = 0.5 * b + (a.width - b) * d.x;
  11610. this._anchorPointInPoints.y = 0.5 * c + (a.height - c) * d.y
  11611. },
  11612. getContentSize: function () {
  11613. this._needUpdateTexture && this._updateTTF();
  11614. return cc.Sprite.prototype.getContentSize.call(this)
  11615. },
  11616. _getWidth: function () {
  11617. this._needUpdateTexture && this._updateTTF();
  11618. return cc.Sprite.prototype._getWidth.call(this)
  11619. },
  11620. _getHeight: function () {
  11621. this._needUpdateTexture && this._updateTTF();
  11622. return cc.Sprite.prototype._getHeight.call(this)
  11623. },
  11624. _updateTexture: function () {
  11625. var a = this._getLabelContext(),
  11626. b = this._labelCanvas,
  11627. c = this._contentSize;
  11628. if (0 === this._string.length) return b.width = 1,
  11629. b.height = c.height || 1,
  11630. this._texture && this._texture.handleLoadedTexture(),
  11631. this.setTextureRect(cc.rect(0, 0, 1, c.height)),
  11632. !0;
  11633. a.font = this._fontStyleStr;
  11634. this._updateTTF();
  11635. var d = c.width,
  11636. c = c.height,
  11637. e = b.width == d && b.height == c;
  11638. b.width = d;
  11639. b.height = c;
  11640. e && a.clearRect(0, 0, d, c);
  11641. this._drawTTFInCanvas(a);
  11642. this._texture && this._texture.handleLoadedTexture();
  11643. this.setTextureRect(cc.rect(0, 0, d, c));
  11644. return !0
  11645. },
  11646. visit: function (a) {
  11647. this._string && "" != this._string && (this._needUpdateTexture && (this._needUpdateTexture = !1, this._updateTexture()), cc.Sprite.prototype.visit.call(this, a || cc._renderContext))
  11648. },
  11649. draw: null,
  11650. _setTextureCoords: function (a) {
  11651. var b = this._batchNode ? this.textureAtlas.texture : this._texture;
  11652. if (b) {
  11653. var c = b.pixelsWidth,
  11654. d = b.pixelsHeight,
  11655. e,
  11656. f = this._quad;
  11657. this._rectRotated ? (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.height - 2) / (2 * c), e = (2 * a.y +
  11658. 1) / (2 * d), a = e + (2 * a.width - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.height) / c, e = a.y / d, a = (a.y + a.width) / d), this._flippedX && (d = e, e = a, a = d), this._flippedY && (d = b, b = c, c = d), f.bl.texCoords.u = b, f.bl.texCoords.v = e, f.br.texCoords.u = b, f.br.texCoords.v = a, f.tl.texCoords.u = c, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = a) : (cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (b = (2 * a.x + 1) / (2 * c), c = b + (2 * a.width - 2) / (2 * c), e = (2 * a.y + 1) / (2 * d), a = e + (2 * a.height - 2) / (2 * d)) : (b = a.x / c, c = (a.x + a.width) / c, e = a.y / d, a = (a.y + a.height) / d), this._flippedX && (d = b, b = c, c = d), this._flippedY && (d = e, e = a, a = d), f.bl.texCoords.u = b, f.bl.texCoords.v = a, f.br.texCoords.u = c, f.br.texCoords.v = a, f.tl.texCoords.u = b, f.tl.texCoords.v = e, f.tr.texCoords.u = c, f.tr.texCoords.v = e);
  11659. this._quadDirty = !0
  11660. }
  11661. }
  11662. });
  11663. cc._renderType === cc._RENDER_TYPE_CANVAS ? (_p = cc.LabelTTF.prototype, _p.setColor = function (a) {
  11664. cc.Node.prototype.setColor.call(this, a);
  11665. this._setColorsString()
  11666. },
  11667. _p._setColorsString = function () {
  11668. this._needUpdateTexture = !0;
  11669. var a = this._displayedColor,
  11670. b = this._displayedOpacity,
  11671. c = this._strokeColor,
  11672. d = this._textFillColor;
  11673. this._shadowColorStr = "rgba(" + (0 | 0.5 * a.r) + "," + (0 | 0.5 * a.g) + "," + (0 | 0.5 * a.b) + "," + this._shadowOpacity + ")";
  11674. this._fillColorStr = "rgba(" + (0 | a.r / 255 * d.r) + "," + (0 | a.g / 255 * d.g) + "," + (0 | a.b / 255 * d.b) + ", " + b / 255 + ")";
  11675. this._strokeColorStr = "rgba(" + (0 | a.r / 255 * c.r) + "," + (0 | a.g / 255 * c.g) + "," + (0 | a.b / 255 * c.b) + ", " + b / 255 + ")"
  11676. },
  11677. _p.updateDisplayedColor = function (a) {
  11678. cc.Node.prototype.updateDisplayedColor.call(this, a);
  11679. this._setColorsString()
  11680. },
  11681. _p.setOpacity = function (a) {
  11682. this._opacity !== a && (cc.Sprite.prototype.setOpacity.call(this, a), this._setColorsString(), this._needUpdateTexture = !0)
  11683. },
  11684. _p.updateDisplayedOpacity = cc.Sprite.prototype.updateDisplayedOpacity, _p.initWithStringAndTextDefinition = function (a, b) {
  11685. this._updateWithTextDefinition(b, !1);
  11686. this.string = a;
  11687. return !0
  11688. },
  11689. _p.setFontFillColor = function (a) {
  11690. var b = this._textFillColor;
  11691. if (b.r != a.r || b.g != a.g || b.b != a.b) b.r = a.r,
  11692. b.g = a.g,
  11693. b.b = a.b,
  11694. this._setColorsString(),
  11695. this._needUpdateTexture = !0
  11696. },
  11697. _p.draw = cc.Sprite.prototype.draw, _p.setTextureRect = function (a, b, c) {
  11698. this._rectRotated = b || !1;
  11699. this.setContentSize(c || a);
  11700. this.setVertexRect(a);
  11701. b = this._textureRect_Canvas;
  11702. b.x = a.x;
  11703. b.y = a.y;
  11704. b.width = a.width;
  11705. b.height = a.height;
  11706. b.validRect = !(0 === b.width || 0 === b.height || 0 > b.x || 0 > b.y);
  11707. a = this._unflippedOffsetPositionFromCenter;
  11708. this._flippedX && (a.x = -a.x);
  11709. this._flippedY && (a.y = -a.y);
  11710. this._offsetPosition.x = a.x + (this._contentSize.width - this._rect.width) / 2;
  11711. this._offsetPosition.y = a.y + (this._contentSize.height - this._rect.height) / 2;
  11712. this._batchNode && (this.dirty = !0)
  11713. },
  11714. _p = null) : (cc.assert(cc.isFunction(cc._tmp.WebGLLabelTTF), cc._LogInfos.MissingFile, "LabelTTFWebGL.js"), cc._tmp.WebGLLabelTTF(), delete cc._tmp.WebGLLabelTTF);
  11715. cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF), cc._LogInfos.MissingFile, "LabelTTFPropertyDefine.js");
  11716. cc._tmp.PrototypeLabelTTF();
  11717. delete cc._tmp.PrototypeLabelTTF;
  11718. cc.LabelTTF._textAlign = ["left", "center", "right"];
  11719. cc.LabelTTF._textBaseline = ["top", "middle", "bottom"];
  11720. cc.LabelTTF.wrapInspection = !0;
  11721. cc.LabelTTF._wordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/;
  11722. cc.LabelTTF._symbolRex = /^[!,.:;}\]%\?>\u3001\u2018\u201c\u300b\uff1f\u3002\uff0c\uff01]/;
  11723. cc.LabelTTF._lastWordRex = /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/;
  11724. cc.LabelTTF._lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/;
  11725. cc.LabelTTF._firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
  11726. cc.LabelTTF._fontStyleRE = /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/;
  11727. cc.LabelTTF.create = function (a, b, c, d, e, f) {
  11728. return new cc.LabelTTF(a, b, c, d, e, f)
  11729. };
  11730. cc.LabelTTF.createWithFontDefinition = cc.LabelTTF.create;
  11731. cc.LabelTTF._SHADER_PROGRAM = cc.USE_LA88_LABELS ? cc.SHADER_POSITION_TEXTURECOLOR : cc.SHADER_POSITION_TEXTUREA8COLOR;
  11732. cc.LabelTTF.__labelHeightDiv = cc.newElement("div");
  11733. cc.LabelTTF.__labelHeightDiv.style.fontFamily = "Arial";
  11734. cc.LabelTTF.__labelHeightDiv.style.position = "absolute";
  11735. cc.LabelTTF.__labelHeightDiv.style.left = "-100px";
  11736. cc.LabelTTF.__labelHeightDiv.style.top = "-100px";
  11737. cc.LabelTTF.__labelHeightDiv.style.lineHeight = "normal";
  11738. document.body ? document.body.appendChild(cc.LabelTTF.__labelHeightDiv) : cc._addEventListener(window, "load",
  11739. function () {
  11740. this.removeEventListener("load", arguments.callee, !1);
  11741. document.body.appendChild(cc.LabelTTF.__labelHeightDiv)
  11742. },
  11743. !1);
  11744. cc.LabelTTF.__getFontHeightByDiv = function (a, b) {
  11745. var c = cc.LabelTTF.__fontHeightCache[a + "." + b];
  11746. if (0 < c) return c;
  11747. var d = cc.LabelTTF.__labelHeightDiv;
  11748. d.innerHTML = "ajghl~!";
  11749. d.style.fontFamily = a;
  11750. d.style.fontSize = b + "px";
  11751. c = d.clientHeight;
  11752. cc.LabelTTF.__fontHeightCache[a + "." + b] = c;
  11753. d.innerHTML = "";
  11754. return c
  11755. };
  11756. cc.LabelTTF.__fontHeightCache = {};
  11757. cc.HashElement = cc.Class.extend({
  11758. actions: null,
  11759. target: null,
  11760. actionIndex: 0,
  11761. currentAction: null,
  11762. currentActionSalvaged: !1,
  11763. paused: !1,
  11764. hh: null,
  11765. ctor: function () {
  11766. this.actions = [];
  11767. this.target = null;
  11768. this.actionIndex = 0;
  11769. this.currentAction = null;
  11770. this.paused = this.currentActionSalvaged = !1;
  11771. this.hh = null
  11772. }
  11773. });
  11774. cc.ActionManager = cc.Class.extend({
  11775. _hashTargets: null,
  11776. _arrayTargets: null,
  11777. _currentTarget: null,
  11778. _currentTargetSalvaged: !1,
  11779. _searchElementByTarget: function (a, b) {
  11780. for (var c = 0; c < a.length; c++) if (b == a[c].target) return a[c];
  11781. return null
  11782. },
  11783. ctor: function () {
  11784. this._hashTargets = {};
  11785. this._arrayTargets = [];
  11786. this._currentTarget = null;
  11787. this._currentTargetSalvaged = !1
  11788. },
  11789. addAction: function (a, b, c) {
  11790. if (!a) throw "cc.ActionManager.addAction(): action must be non-null";
  11791. if (!b) throw "cc.ActionManager.addAction(): action must be non-null";
  11792. var d = this._hashTargets[b.__instanceId];
  11793. d || (d = new cc.HashElement, d.paused = c, d.target = b, this._hashTargets[b.__instanceId] = d, this._arrayTargets.push(d));
  11794. this._actionAllocWithHashElement(d);
  11795. d.actions.push(a);
  11796. a.startWithTarget(b)
  11797. },
  11798. removeAllActions: function () {
  11799. for (var a = this._arrayTargets, b = 0; b < a.length; b++) {
  11800. var c = a[b];
  11801. c && this.removeAllActionsFromTarget(c.target, !0)
  11802. }
  11803. },
  11804. removeAllActionsFromTarget: function (a, b) {
  11805. if (null != a) {
  11806. var c = this._hashTargets[a.__instanceId];
  11807. c && (-1 === c.actions.indexOf(c.currentAction) || c.currentActionSalvaged || (c.currentActionSalvaged = !0), c.actions.length = 0, this._currentTarget != c || b ? this._deleteHashElement(c) : this._currentTargetSalvaged = !0)
  11808. }
  11809. },
  11810. removeAction: function (a) {
  11811. if (null != a) {
  11812. var b = a.getOriginalTarget();
  11813. if (b = this._hashTargets[b.__instanceId]) for (var c = 0; c < b.actions.length; c++) {
  11814. if (b.actions[c] == a) {
  11815. b.actions.splice(c, 1);
  11816. break
  11817. }
  11818. } else cc.log(cc._LogInfos.ActionManager_removeAction)
  11819. }
  11820. },
  11821. removeActionByTag: function (a, b) {
  11822. a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_addAction);
  11823. cc.assert(b, cc._LogInfos.ActionManager_addAction);
  11824. var c = this._hashTargets[b.__instanceId];
  11825. if (c) for (var d = c.actions.length, e = 0; e < d; ++e) {
  11826. var f = c.actions[e];
  11827. if (f && f.getTag() === a && f.getOriginalTarget() == b) {
  11828. this._removeActionAtIndex(e, c);
  11829. break
  11830. }
  11831. }
  11832. },
  11833. getActionByTag: function (a, b) {
  11834. a == cc.ACTION_TAG_INVALID && cc.log(cc._LogInfos.ActionManager_getActionByTag);
  11835. var c = this._hashTargets[b.__instanceId];
  11836. if (c) {
  11837. if (null != c.actions) for (var d = 0; d < c.actions.length; ++d) {
  11838. var e = c.actions[d];
  11839. if (e && e.getTag() === a) return e
  11840. }
  11841. cc.log(cc._LogInfos.ActionManager_getActionByTag_2, a)
  11842. }
  11843. return null
  11844. },
  11845. numberOfRunningActionsInTarget: function (a) {
  11846. return (a = this._hashTargets[a.__instanceId]) ? a.actions ? a.actions.length : 0 : 0
  11847. },
  11848. pauseTarget: function (a) {
  11849. if (a = this._hashTargets[a.__instanceId]) a.paused = !0
  11850. },
  11851. resumeTarget: function (a) {
  11852. if (a = this._hashTargets[a.__instanceId]) a.paused = !1
  11853. },
  11854. pauseAllRunningActions: function () {
  11855. for (var a = [], b = this._arrayTargets, c = 0; c < b.length; c++) {
  11856. var d = b[c];
  11857. d && !d.paused && (d.paused = !0, a.push(d.target))
  11858. }
  11859. return a
  11860. },
  11861. resumeTargets: function (a) {
  11862. if (a) for (var b = 0; b < a.length; b++) a[b] && this.resumeTarget(a[b])
  11863. },
  11864. purgeSharedManager: function () {
  11865. cc.director.getScheduler().unscheduleUpdateForTarget(this)
  11866. },
  11867. _removeActionAtIndex: function (a, b) {
  11868. b.actions[a] != b.currentAction || b.currentActionSalvaged || (b.currentActionSalvaged = !0);
  11869. b.actions.splice(a, 1);
  11870. b.actionIndex >= a && b.actionIndex--;
  11871. 0 == b.actions.length && (this._currentTarget == b ? this._currentTargetSalvaged = !0 : this._deleteHashElement(b))
  11872. },
  11873. _deleteHashElement: function (a) {
  11874. a && (delete this._hashTargets[a.target.__instanceId], cc.arrayRemoveObject(this._arrayTargets, a), a.actions = null, a.target = null)
  11875. },
  11876. _actionAllocWithHashElement: function (a) {
  11877. null == a.actions && (a.actions = [])
  11878. },
  11879. update: function (a) {
  11880. for (var b = this._arrayTargets, c, d = 0; d < b.length; d++) {
  11881. c = this._currentTarget = b[d];
  11882. if (!c.paused) for (c.actionIndex = 0; c.actionIndex < c.actions.length; c.actionIndex++) if (c.currentAction = c.actions[c.actionIndex], c.currentAction) {
  11883. c.currentActionSalvaged = !1;
  11884. c.currentAction.step(a * (c.currentAction._speedMethod ? c.currentAction._speed : 1));
  11885. if (c.currentActionSalvaged) c.currentAction = null;
  11886. else if (c.currentAction.isDone()) {
  11887. c.currentAction.stop();
  11888. var e = c.currentAction;
  11889. c.currentAction = null;
  11890. this.removeAction(e)
  11891. }
  11892. c.currentAction = null
  11893. }
  11894. this._currentTargetSalvaged && 0 === c.actions.length && this._deleteHashElement(c)
  11895. }
  11896. }
  11897. });
  11898. cc.kmScalar = Number;
  11899. cc.kmBool = Number;
  11900. cc.kmEnum = Number;
  11901. cc.KM_FALSE = 0;
  11902. cc.KM_TRUE = 1;
  11903. cc.kmPI = 3.141592;
  11904. cc.kmPIOver180 = 0.017453;
  11905. cc.kmPIUnder180 = 57.295779;
  11906. cc.kmEpsilon = 0.015625;
  11907. cc.kmSQR = function (a) {
  11908. return a * a
  11909. };
  11910. cc.kmDegreesToRadians = function (a) {
  11911. return a * cc.kmPIOver180
  11912. };
  11913. cc.kmRadiansToDegrees = function (a) {
  11914. return a * cc.kmPIUnder180
  11915. };
  11916. cc.kmMin = function (a, b) {
  11917. return a < b ? a : b
  11918. };
  11919. cc.kmMax = function (a, b) {
  11920. return a > b ? a : b
  11921. };
  11922. cc.kmAlmostEqual = function (a, b) {
  11923. return a + cc.kmEpsilon > b && a - cc.kmEpsilon < b
  11924. };
  11925. cc.kmVec2 = function (a, b) {
  11926. this.x = a || 0;
  11927. this.y = b || 0
  11928. };
  11929. cc.kmVec2Fill = function (a, b, c) {
  11930. a.x = b;
  11931. a.y = c;
  11932. return a
  11933. };
  11934. cc.kmVec2Length = function (a) {
  11935. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y))
  11936. };
  11937. cc.kmVec2LengthSq = function (a) {
  11938. return cc.kmSQR(a.x) + cc.kmSQR(a.y)
  11939. };
  11940. cc.kmVec2Normalize = function (a, b) {
  11941. var c = 1 / cc.kmVec2Length(b),
  11942. d = new cc.kmVec2;
  11943. d.x = b.x * c;
  11944. d.y = b.y * c;
  11945. a.x = d.x;
  11946. a.y = d.y;
  11947. return a
  11948. };
  11949. cc.kmVec2Add = function (a, b, c) {
  11950. a.x = b.x + c.x;
  11951. a.y = b.y + c.y;
  11952. return a
  11953. };
  11954. cc.kmVec2Dot = function (a, b) {
  11955. return a.x * b.x + a.y * b.y
  11956. };
  11957. cc.kmVec2Subtract = function (a, b, c) {
  11958. a.x = b.x - c.x;
  11959. a.y = b.y - c.y;
  11960. return a
  11961. };
  11962. cc.kmVec2Transform = function (a, b, c) {
  11963. var d = new cc.kmVec2;
  11964. d.x = b.x * c.mat[0] + b.y * c.mat[3] + c.mat[6];
  11965. d.y = b.x * c.mat[1] + b.y * c.mat[4] + c.mat[7];
  11966. a.x = d.x;
  11967. a.y = d.y;
  11968. return a
  11969. };
  11970. cc.kmVec2TransformCoord = function (a, b, c) {
  11971. return null
  11972. };
  11973. cc.kmVec2Scale = function (a, b, c) {
  11974. a.x = b.x * c;
  11975. a.y = b.y * c;
  11976. return a
  11977. };
  11978. cc.kmVec2AreEqual = function (a, b) {
  11979. return a.x < b.x + cc.kmEpsilon && a.x > b.x - cc.kmEpsilon && a.y < b.y + cc.kmEpsilon && a.y > b.y - cc.kmEpsilon
  11980. };
  11981. cc.kmVec3 = function (a, b, c) {
  11982. this.x = a || 0;
  11983. this.y = b || 0;
  11984. this.z = c || 0
  11985. };
  11986. cc.kmVec3Fill = function (a, b, c, d) {
  11987. if (!a) return new cc.kmVec3(b, c, d);
  11988. a.x = b;
  11989. a.y = c;
  11990. a.z = d;
  11991. return a
  11992. };
  11993. cc.kmVec3Length = function (a) {
  11994. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z))
  11995. };
  11996. cc.kmVec3LengthSq = function (a) {
  11997. return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z)
  11998. };
  11999. cc.kmVec3Normalize = function (a, b) {
  12000. var c = 1 / cc.kmVec3Length(b);
  12001. a.x = b.x * c;
  12002. a.y = b.y * c;
  12003. a.z = b.z * c;
  12004. return a
  12005. };
  12006. cc.kmVec3Cross = function (a, b, c) {
  12007. a.x = b.y * c.z - b.z * c.y;
  12008. a.y = b.z * c.x - b.x * c.z;
  12009. a.z = b.x * c.y - b.y * c.x;
  12010. return a
  12011. };
  12012. cc.kmVec3Dot = function (a, b) {
  12013. return a.x * b.x + a.y * b.y + a.z * b.z
  12014. };
  12015. cc.kmVec3Add = function (a, b, c) {
  12016. a.x = b.x + c.x;
  12017. a.y = b.y + c.y;
  12018. a.z = b.z + c.z;
  12019. return a
  12020. };
  12021. cc.kmVec3Subtract = function (a, b, c) {
  12022. a.x = b.x - c.x;
  12023. a.y = b.y - c.y;
  12024. a.z = b.z - c.z;
  12025. return a
  12026. };
  12027. cc.kmVec3Transform = function (a, b, c) {
  12028. a.x = b.x * c.mat[0] + b.y * c.mat[4] + b.z * c.mat[8] + c.mat[12];
  12029. a.y = b.x * c.mat[1] + b.y * c.mat[5] + b.z * c.mat[9] + c.mat[13];
  12030. a.z = b.x * c.mat[2] + b.y * c.mat[6] + b.z * c.mat[10] + c.mat[14];
  12031. return a
  12032. };
  12033. cc.kmVec3TransformNormal = function (a, b, c) {
  12034. a.x = b.x * c.mat[0] + b.y * c.mat[4] + b.z * c.mat[8];
  12035. a.y = b.x * c.mat[1] + b.y * c.mat[5] + b.z * c.mat[9];
  12036. a.z = b.x * c.mat[2] + b.y * c.mat[6] + b.z * c.mat[10];
  12037. return a
  12038. };
  12039. cc.kmVec3TransformCoord = function (a, b, c) {
  12040. var d = new cc.kmVec4,
  12041. e = new cc.kmVec4;
  12042. cc.kmVec4Fill(e, b.x, b.y, b.z, 1);
  12043. cc.kmVec4Transform(d, e, c);
  12044. a.x = d.x / d.w;
  12045. a.y = d.y / d.w;
  12046. a.z = d.z / d.w;
  12047. return a
  12048. };
  12049. cc.kmVec3Scale = function (a, b, c) {
  12050. a.x = b.x * c;
  12051. a.y = b.y * c;
  12052. a.z = b.z * c;
  12053. return a
  12054. };
  12055. cc.kmVec3AreEqual = function (a, b) {
  12056. return a.x < b.x + cc.kmEpsilon && a.x > b.x - cc.kmEpsilon && a.y < b.y + cc.kmEpsilon && a.y > b.y - cc.kmEpsilon && a.z < b.z + cc.kmEpsilon && a.z > b.z - cc.kmEpsilon ? 1 : 0
  12057. };
  12058. cc.kmVec3InverseTransform = function (a, b, c) {
  12059. b = new cc.kmVec3(b.x - c.mat[12], b.y - c.mat[13], b.z - c.mat[14]);
  12060. a.x = b.x * c.mat[0] + b.y * c.mat[1] + b.z * c.mat[2];
  12061. a.y = b.x * c.mat[4] + b.y * c.mat[5] + b.z * c.mat[6];
  12062. a.z = b.x * c.mat[8] + b.y * c.mat[9] + b.z * c.mat[10];
  12063. return a
  12064. };
  12065. cc.kmVec3InverseTransformNormal = function (a, b, c) {
  12066. a.x = b.x * c.mat[0] + b.y * c.mat[1] + b.z * c.mat[2];
  12067. a.y = b.x * c.mat[4] + b.y * c.mat[5] + b.z * c.mat[6];
  12068. a.z = b.x * c.mat[8] + b.y * c.mat[9] + b.z * c.mat[10];
  12069. return a
  12070. };
  12071. cc.kmVec3Assign = function (a, b) {
  12072. if (a == b) return a;
  12073. a.x = b.x;
  12074. a.y = b.y;
  12075. a.z = b.z;
  12076. return a
  12077. };
  12078. cc.kmVec3Zero = function (a) {
  12079. a.x = 0;
  12080. a.y = 0;
  12081. a.z = 0;
  12082. return a
  12083. };
  12084. cc.kmVec3ToTypeArray = function (a) {
  12085. if (!a) return null;
  12086. var b = new Float32Array(3);
  12087. b[0] = a.x;
  12088. b[1] = a.y;
  12089. b[2] = a.z;
  12090. return b
  12091. };
  12092. cc.kmVec4 = function (a, b, c, d) {
  12093. this.x = a || 0;
  12094. this.y = b || 0;
  12095. this.z = c || 0;
  12096. this.w = d || 0
  12097. };
  12098. cc.kmVec4Fill = function (a, b, c, d, e) {
  12099. a.x = b;
  12100. a.y = c;
  12101. a.z = d;
  12102. a.w = e;
  12103. return a
  12104. };
  12105. cc.kmVec4Add = function (a, b, c) {
  12106. a.x = b.x + c.x;
  12107. a.y = b.y + c.y;
  12108. a.z = b.z + c.z;
  12109. a.w = b.w + c.w;
  12110. return a
  12111. };
  12112. cc.kmVec4Dot = function (a, b) {
  12113. return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
  12114. };
  12115. cc.kmVec4Length = function (a) {
  12116. return Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w))
  12117. };
  12118. cc.kmVec4LengthSq = function (a) {
  12119. return cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z) + cc.kmSQR(a.w)
  12120. };
  12121. cc.kmVec4Lerp = function (a, b, c, d) {
  12122. return a
  12123. };
  12124. cc.kmVec4Normalize = function (a, b) {
  12125. var c = 1 / cc.kmVec4Length(b);
  12126. a.x *= c;
  12127. a.y *= c;
  12128. a.z *= c;
  12129. a.w *= c;
  12130. return a
  12131. };
  12132. cc.kmVec4Scale = function (a, b, c) {
  12133. cc.kmVec4Normalize(a, b);
  12134. a.x *= c;
  12135. a.y *= c;
  12136. a.z *= c;
  12137. a.w *= c;
  12138. return a
  12139. };
  12140. cc.kmVec4Subtract = function (a, b, c) {
  12141. a.x = b.x - c.x;
  12142. a.y = b.y - c.y;
  12143. a.z = b.z - c.z;
  12144. a.w = b.w - c.w;
  12145. return a
  12146. };
  12147. cc.kmVec4Transform = function (a, b, c) {
  12148. a.x = b.x * c.mat[0] + b.y * c.mat[4] + b.z * c.mat[8] + b.w * c.mat[12];
  12149. a.y = b.x * c.mat[1] + b.y * c.mat[5] + b.z * c.mat[9] + b.w * c.mat[13];
  12150. a.z = b.x * c.mat[2] + b.y * c.mat[6] + b.z * c.mat[10] + b.w * c.mat[14];
  12151. a.w = b.x * c.mat[3] + b.y * c.mat[7] + b.z * c.mat[11] + b.w * c.mat[15];
  12152. return a
  12153. };
  12154. cc.kmVec4TransformArray = function (a, b, c, d, e, f) {
  12155. for (var g = 0; g < f;) cc.kmVec4Transform(a + g * b, c + g * d, e),
  12156. ++g;
  12157. return a
  12158. };
  12159. cc.kmVec4AreEqual = function (a, b) {
  12160. return a.x < b.x + cc.kmEpsilon && a.x > b.x - cc.kmEpsilon && a.y < b.y + cc.kmEpsilon && a.y > b.y - cc.kmEpsilon && a.z < b.z + cc.kmEpsilon && a.z > b.z - cc.kmEpsilon && a.w < b.w + cc.kmEpsilon && a.w > b.w - cc.kmEpsilon
  12161. };
  12162. cc.kmVec4Assign = function (a, b) {
  12163. if (a == b) return cc.log("destVec and srcVec are same object"),
  12164. a;
  12165. a.x = b.x;
  12166. a.y = b.y;
  12167. a.z = b.z;
  12168. a.w = b.w;
  12169. return a
  12170. };
  12171. cc.kmVec4ToTypeArray = function (a) {
  12172. if (!a) return null;
  12173. var b = new Float32Array(4);
  12174. b[0] = a.x;
  12175. b[1] = a.y;
  12176. b[2] = a.z;
  12177. b[3] = a.w;
  12178. return b
  12179. };
  12180. cc.kmRay2 = function (a, b) {
  12181. this.start = a || new cc.kmVec2;
  12182. this.start = a || new cc.kmVec2
  12183. };
  12184. cc.kmRay2Fill = function (a, b, c, d, e) {
  12185. a.start.x = b;
  12186. a.start.y = c;
  12187. a.dir.x = d;
  12188. a.dir.y = e
  12189. };
  12190. cc.kmRay2IntersectLineSegment = function (a, b, c, d) {
  12191. var e = a.start.x,
  12192. f = a.start.y,
  12193. g = a.start.x + a.dir.x;
  12194. a = a.start.y + a.dir.y;
  12195. var h = b.x,
  12196. k = b.y,
  12197. m = c.x,
  12198. n = c.y,
  12199. q = (n - k) * (g - e) - (m - h) * (a - f);
  12200. if (q > -cc.kmEpsilon && q < cc.kmEpsilon) return cc.KM_FALSE;
  12201. k = ((m - h) * (f - k) - (n - k) * (e - h)) / q;
  12202. h = e + k * (g - e);
  12203. k = f + k * (a - f);
  12204. if (h < cc.kmMin(b.x, c.x) - cc.kmEpsilon || h > cc.kmMax(b.x, c.x) + cc.kmEpsilon || k < cc.kmMin(b.y, c.y) - cc.kmEpsilon || k > cc.kmMax(b.y, c.y) + cc.kmEpsilon || h < cc.kmMin(e, g) - cc.kmEpsilon || h > cc.kmMax(e, g) + cc.kmEpsilon || k < cc.kmMin(f, a) - cc.kmEpsilon || k > cc.kmMax(f, a) + cc.kmEpsilon) return cc.KM_FALSE;
  12205. d.x = h;
  12206. d.y = k;
  12207. return cc.KM_TRUE
  12208. };
  12209. cc.calculate_line_normal = function (a, b, c) {
  12210. var d = new cc.kmVec2;
  12211. cc.kmVec2Subtract(d, b, a);
  12212. c.x = -d.y;
  12213. c.y = d.x;
  12214. cc.kmVec2Normalize(c, c)
  12215. };
  12216. cc.kmRay2IntersectTriangle = function (a, b, c, d, e, f) {
  12217. var g = new cc.kmVec2,
  12218. h = new cc.kmVec2,
  12219. k = new cc.kmVec2,
  12220. m = 1E4,
  12221. n = cc.KM_FALSE,
  12222. q;
  12223. cc.kmRay2IntersectLineSegment(a, b, c, g) && (q = new cc.kmVec2, n = cc.KM_TRUE, q = cc.kmVec2Length(cc.kmVec2Subtract(q, g, a.start)), q < m && (h.x = g.x, h.y = g.y, m = q, cc.calculate_line_normal(b, c, k)));
  12224. cc.kmRay2IntersectLineSegment(a, c, d, g) && (q = new cc.kmVec2, n = cc.KM_TRUE, q = cc.kmVec2Length(cc.kmVec2Subtract(q, g, a.start)), q < m && (h.x = g.x, h.y = g.y, m = q, cc.calculate_line_normal(c, d, k)));
  12225. cc.kmRay2IntersectLineSegment(a, d, b, g) && (q = new cc.kmVec2, n = cc.KM_TRUE, q = cc.kmVec2Length(cc.kmVec2Subtract(q, g, a.start)), q < m && (h.x = g.x, h.y = g.y, cc.calculate_line_normal(d, b, k)));
  12226. n && (e.x = h.x, e.y = h.y, f && (f.x = k.x, f.y = k.y));
  12227. return n
  12228. };
  12229. cc.kmRay2IntersectCircle = function (a, b, c, d) {
  12230. cc.log("cc.kmRay2IntersectCircle() has not been implemented.")
  12231. };
  12232. var Float32Array = Float32Array || Array;
  12233. cc.kmMat3 = function () {
  12234. this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0])
  12235. };
  12236. cc.kmMat3Fill = function (a, b) {
  12237. for (var c = 0; 9 > c; c++) a.mat[c] = b;
  12238. return a
  12239. };
  12240. cc.kmMat3Adjugate = function (a, b) {
  12241. a.mat[0] = b.mat[4] * b.mat[8] - b.mat[5] * b.mat[7];
  12242. a.mat[1] = b.mat[2] * b.mat[7] - b.mat[1] * b.mat[8];
  12243. a.mat[2] = b.mat[1] * b.mat[5] - b.mat[2] * b.mat[4];
  12244. a.mat[3] = b.mat[5] * b.mat[6] - b.mat[3] * b.mat[8];
  12245. a.mat[4] = b.mat[0] * b.mat[8] - b.mat[2] * b.mat[6];
  12246. a.mat[5] = b.mat[2] * b.mat[3] - b.mat[0] * b.mat[5];
  12247. a.mat[6] = b.mat[3] * b.mat[7] - b.mat[4] * b.mat[6];
  12248. a.mat[8] = b.mat[0] * b.mat[4] - b.mat[1] * b.mat[3];
  12249. return a
  12250. };
  12251. cc.kmMat3Identity = function (a) {
  12252. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[5] = a.mat[6] = a.mat[7] = 0;
  12253. a.mat[0] = a.mat[4] = a.mat[8] = 1;
  12254. return a
  12255. };
  12256. cc.kmMat3Inverse = function (a, b, c) {
  12257. var d = new cc.kmMat3;
  12258. if (0 === b) return null;
  12259. b = 1 / b;
  12260. cc.kmMat3Adjugate(d, c);
  12261. cc.kmMat3ScalarMultiply(a, d, b);
  12262. return a
  12263. };
  12264. cc.kmMat3._identity = new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  12265. cc.kmMat3IsIdentity = function (a) {
  12266. for (var b = 0; 9 > b; b++) if (cc.kmMat3._identity[b] !== a.mat[b]) return !1;
  12267. return !0
  12268. };
  12269. cc.kmMat3Transpose = function (a, b) {
  12270. var c,
  12271. d;
  12272. for (c = 0; 3 > c; ++c) for (d = 0; 3 > d; ++d) a.mat[3 * c + d] = b.mat[3 * d + c];
  12273. return a
  12274. };
  12275. cc.kmMat3Determinant = function (a) {
  12276. var b;
  12277. b = a.mat[0] * a.mat[4] * a.mat[8] + a.mat[1] * a.mat[5] * a.mat[6] + a.mat[2] * a.mat[3] * a.mat[7];
  12278. return b -= a.mat[2] * a.mat[4] * a.mat[6] + a.mat[0] * a.mat[5] * a.mat[7] + a.mat[1] * a.mat[3] * a.mat[8]
  12279. };
  12280. cc.kmMat3Multiply = function (a, b, c) {
  12281. b = b.mat;
  12282. c = c.mat;
  12283. a.mat[0] = b[0] * c[0] + b[3] * c[1] + b[6] * c[2];
  12284. a.mat[1] = b[1] * c[0] + b[4] * c[1] + b[7] * c[2];
  12285. a.mat[2] = b[2] * c[0] + b[5] * c[1] + b[8] * c[2];
  12286. a.mat[3] = b[0] * c[3] + b[3] * c[4] + b[6] * c[5];
  12287. a.mat[4] = b[1] * c[3] + b[4] * c[4] + b[7] * c[5];
  12288. a.mat[5] = b[2] * c[3] + b[5] * c[4] + b[8] * c[5];
  12289. a.mat[6] = b[0] * c[6] + b[3] * c[7] + b[6] * c[8];
  12290. a.mat[7] = b[1] * c[6] + b[4] * c[7] + b[7] * c[8];
  12291. a.mat[8] = b[2] * c[6] + b[5] * c[7] + b[8] * c[8];
  12292. return a
  12293. };
  12294. cc.kmMat3ScalarMultiply = function (a, b, c) {
  12295. for (var d = 0; 9 > d; d++) a.mat[d] = b.mat[d] * c;
  12296. return a
  12297. };
  12298. cc.kmMat3RotationAxisAngle = function (a, b, c) {
  12299. var d = Math.cos(c);
  12300. c = Math.sin(c);
  12301. a.mat[0] = d + b.x * b.x * (1 - d);
  12302. a.mat[1] = b.z * c + b.y * b.x * (1 - d);
  12303. a.mat[2] = -b.y * c + b.z * b.x * (1 - d);
  12304. a.mat[3] = -b.z * c + b.x * b.y * (1 - d);
  12305. a.mat[4] = d + b.y * b.y * (1 - d);
  12306. a.mat[5] = b.x * c + b.z * b.y * (1 - d);
  12307. a.mat[6] = b.y * c + b.x * b.z * (1 - d);
  12308. a.mat[7] = -b.x * c + b.y * b.z * (1 - d);
  12309. a.mat[8] = d + b.z * b.z * (1 - d);
  12310. return a
  12311. };
  12312. cc.kmMat3Assign = function (a, b) {
  12313. if (a == b) return cc.log("cc.kmMat3Assign(): pOut equals pIn"),
  12314. a;
  12315. for (var c = 0; 9 > c; c++) a.mat[c] = b.mat[c];
  12316. return a
  12317. };
  12318. cc.kmMat3AreEqual = function (a, b) {
  12319. if (a == b) return !0;
  12320. for (var c = 0; 9 > c; ++c) if (!(a.mat[c] + cc.kmEpsilon > b.mat[c] && a.mat[c] - cc.kmEpsilon < b.mat[c])) return !1;
  12321. return !0
  12322. };
  12323. cc.kmMat3RotationX = function (a, b) {
  12324. a.mat[0] = 1;
  12325. a.mat[1] = 0;
  12326. a.mat[2] = 0;
  12327. a.mat[3] = 0;
  12328. a.mat[4] = Math.cos(b);
  12329. a.mat[5] = Math.sin(b);
  12330. a.mat[6] = 0;
  12331. a.mat[7] = -Math.sin(b);
  12332. a.mat[8] = Math.cos(b);
  12333. return a
  12334. };
  12335. cc.kmMat3RotationY = function (a, b) {
  12336. a.mat[0] = Math.cos(b);
  12337. a.mat[1] = 0;
  12338. a.mat[2] = -Math.sin(b);
  12339. a.mat[3] = 0;
  12340. a.mat[4] = 1;
  12341. a.mat[5] = 0;
  12342. a.mat[6] = Math.sin(b);
  12343. a.mat[7] = 0;
  12344. a.mat[8] = Math.cos(b);
  12345. return a
  12346. };
  12347. cc.kmMat3RotationZ = function (a, b) {
  12348. a.mat[0] = Math.cos(b);
  12349. a.mat[1] = -Math.sin(b);
  12350. a.mat[2] = 0;
  12351. a.mat[3] = Math.sin(b);
  12352. a.mat[4] = Math.cos(b);
  12353. a.mat[5] = 0;
  12354. a.mat[6] = 0;
  12355. a.mat[7] = 0;
  12356. a.mat[8] = 1;
  12357. return a
  12358. };
  12359. cc.kmMat3Rotation = function (a, b) {
  12360. a.mat[0] = Math.cos(b);
  12361. a.mat[1] = Math.sin(b);
  12362. a.mat[2] = 0;
  12363. a.mat[3] = -Math.sin(b);
  12364. a.mat[4] = Math.cos(b);
  12365. a.mat[5] = 0;
  12366. a.mat[6] = 0;
  12367. a.mat[7] = 0;
  12368. a.mat[8] = 1;
  12369. return a
  12370. };
  12371. cc.kmMat3Scaling = function (a, b, c) {
  12372. cc.kmMat3Identity(a);
  12373. a.mat[0] = b;
  12374. a.mat[4] = c;
  12375. return a
  12376. };
  12377. cc.kmMat3Translation = function (a, b, c) {
  12378. cc.kmMat3Identity(a);
  12379. a.mat[6] = b;
  12380. a.mat[7] = c;
  12381. return a
  12382. };
  12383. cc.kmMat3RotationQuaternion = function (a, b) {
  12384. if (!b || !a) return null;
  12385. a.mat[0] = 1 - 2 * (b.y * b.y + b.z * b.z);
  12386. a.mat[1] = 2 * (b.x * b.y - b.w * b.z);
  12387. a.mat[2] = 2 * (b.x * b.z + b.w * b.y);
  12388. a.mat[3] = 2 * (b.x * b.y + b.w * b.z);
  12389. a.mat[4] = 1 - 2 * (b.x * b.x + b.z * b.z);
  12390. a.mat[5] = 2 * (b.y * b.z - b.w * b.x);
  12391. a.mat[6] = 2 * (b.x * b.z - b.w * b.y);
  12392. a.mat[7] = 2 * (b.y * b.z + b.w * b.x);
  12393. a.mat[8] = 1 - 2 * (b.x * b.x + b.y * b.y);
  12394. return a
  12395. };
  12396. cc.kmMat3RotationToAxisAngle = function (a, b, c) {
  12397. cc.kmQuaternionRotationMatrix(void 0, c);
  12398. cc.kmQuaternionToAxisAngle(void 0, a, b);
  12399. return a
  12400. };
  12401. cc.kmMat4 = function () {
  12402. this.mat = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
  12403. };
  12404. cc.kmMat4Fill = function (a, b) {
  12405. a.mat[0] = a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[5] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[10] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = a.mat[15] = b
  12406. };
  12407. cc.kmMat4Identity = function (a) {
  12408. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = 0;
  12409. a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
  12410. return a
  12411. };
  12412. cc.kmMat4._get = function (a, b, c) {
  12413. return a.mat[b + 4 * c]
  12414. };
  12415. cc.kmMat4._set = function (a, b, c, d) {
  12416. a.mat[b + 4 * c] = d
  12417. };
  12418. cc.kmMat4._swap = function (a, b, c, d, e) {
  12419. var f = cc.kmMat4._get(a, b, c);
  12420. cc.kmMat4._set(a, b, c, cc.kmMat4._get(a, d, e));
  12421. cc.kmMat4._set(a, d, e, f)
  12422. };
  12423. cc.kmMat4._gaussj = function (a, b) {
  12424. var c,
  12425. d = 0,
  12426. e = 0,
  12427. f,
  12428. g,
  12429. h,
  12430. k = [0, 0, 0, 0],
  12431. m = [0, 0, 0, 0],
  12432. n = [0, 0, 0, 0];
  12433. for (c = 0; 4 > c; c++) {
  12434. for (f = h = 0; 4 > f; f++) if (1 != n[f]) for (g = 0; 4 > g; g++) 0 == n[g] && Math.abs(cc.kmMat4._get(a, f, g)) >= h && (h = Math.abs(cc.kmMat4._get(a, f, g)), e = f, d = g); ++n[d];
  12435. if (e != d) {
  12436. for (f = 0; 4 > f; f++) cc.kmMat4._swap(a, e, f, d, f);
  12437. for (f = 0; 4 > f; f++) cc.kmMat4._swap(b, e, f, d, f)
  12438. }
  12439. m[c] = e;
  12440. k[c] = d;
  12441. if (0 == cc.kmMat4._get(a, d, d)) return cc.KM_FALSE;
  12442. g = 1 / cc.kmMat4._get(a, d, d);
  12443. cc.kmMat4._set(a, d, d, 1);
  12444. for (f = 0; 4 > f; f++) cc.kmMat4._set(a, d, f, cc.kmMat4._get(a, d, f) * g);
  12445. for (f = 0; 4 > f; f++) cc.kmMat4._set(b, d, f, cc.kmMat4._get(b, d, f) * g);
  12446. for (g = 0; 4 > g; g++) if (g != d) {
  12447. h = cc.kmMat4._get(a, g, d);
  12448. cc.kmMat4._set(a, g, d, 0);
  12449. for (f = 0; 4 > f; f++) cc.kmMat4._set(a, g, f, cc.kmMat4._get(a, g, f) - cc.kmMat4._get(a, d, f) * h);
  12450. for (f = 0; 4 > f; f++) cc.kmMat4._set(b, g, f, cc.kmMat4._get(a, g, f) - cc.kmMat4._get(b, d, f) * h)
  12451. }
  12452. }
  12453. for (f = 3; 0 <= f; f--) if (m[f] != k[f]) for (g = 0; 4 > g; g++) cc.kmMat4._swap(a, g, m[f], g, k[f]);
  12454. return cc.KM_TRUE
  12455. };
  12456. cc.kmMat4._identity = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
  12457. cc.kmMat4Inverse = function (a, b) {
  12458. var c = new cc.kmMat4,
  12459. d = new cc.kmMat4;
  12460. cc.kmMat4Assign(c, b);
  12461. cc.kmMat4Identity(d);
  12462. if (cc.kmMat4._gaussj(c, d) == cc.KM_FALSE) return null;
  12463. cc.kmMat4Assign(a, c);
  12464. return a
  12465. };
  12466. cc.kmMat4IsIdentity = function (a) {
  12467. for (var b = 0; 16 > b; b++) if (cc.kmMat4._identity[b] != a.mat[b]) return !1;
  12468. return !0
  12469. };
  12470. cc.kmMat4Transpose = function (a, b) {
  12471. var c,
  12472. d,
  12473. e = a.mat,
  12474. f = b.mat;
  12475. for (d = 0; 4 > d; ++d) for (c = 0; 4 > c; ++c) e[4 * d + c] = f[4 * c + d];
  12476. return a
  12477. };
  12478. cc.kmMat4Multiply = function (a, b, c) {
  12479. var d = a.mat,
  12480. e = b.mat[0],
  12481. f = b.mat[1],
  12482. g = b.mat[2],
  12483. h = b.mat[3],
  12484. k = b.mat[4],
  12485. m = b.mat[5],
  12486. n = b.mat[6],
  12487. q = b.mat[7],
  12488. r = b.mat[8],
  12489. s = b.mat[9],
  12490. t = b.mat[10],
  12491. u = b.mat[11],
  12492. v = b.mat[12],
  12493. w = b.mat[13],
  12494. x = b.mat[14];
  12495. b = b.mat[15];
  12496. var y = c.mat[0],
  12497. z = c.mat[1],
  12498. A = c.mat[2],
  12499. B = c.mat[3],
  12500. C = c.mat[4],
  12501. D = c.mat[5],
  12502. E = c.mat[6],
  12503. F = c.mat[7],
  12504. G = c.mat[8],
  12505. H = c.mat[9],
  12506. I = c.mat[10],
  12507. J = c.mat[11],
  12508. K = c.mat[12],
  12509. L = c.mat[13],
  12510. M = c.mat[14];
  12511. c = c.mat[15];
  12512. d[0] = y * e + z * k + A * r + B * v;
  12513. d[1] = y * f + z * m + A * s + B * w;
  12514. d[2] = y * g + z * n + A * t + B * x;
  12515. d[3] = y * h + z * q + A * u + B * b;
  12516. d[4] = C * e + D * k + E * r + F * v;
  12517. d[5] = C * f + D * m + E * s + F * w;
  12518. d[6] = C * g + D * n + E * t + F * x;
  12519. d[7] = C * h + D * q + E * u + F * b;
  12520. d[8] = G * e + H * k + I * r + J * v;
  12521. d[9] = G * f + H * m + I * s + J * w;
  12522. d[10] = G * g + H * n + I * t + J * x;
  12523. d[11] = G * h + H * q + I * u + J * b;
  12524. d[12] = K * e + L * k + M * r + c * v;
  12525. d[13] = K * f + L * m + M * s + c * w;
  12526. d[14] = K * g + L * n + M * t + c * x;
  12527. d[15] = K * h + L * q + M * u + c * b;
  12528. return a
  12529. };
  12530. cc.getMat4MultiplyValue = function (a, b) {
  12531. var c = a.mat,
  12532. d = b.mat,
  12533. e = new Float32Array(16);
  12534. e[0] = c[0] * d[0] + c[4] * d[1] + c[8] * d[2] + c[12] * d[3];
  12535. e[1] = c[1] * d[0] + c[5] * d[1] + c[9] * d[2] + c[13] * d[3];
  12536. e[2] = c[2] * d[0] + c[6] * d[1] + c[10] * d[2] + c[14] * d[3];
  12537. e[3] = c[3] * d[0] + c[7] * d[1] + c[11] * d[2] + c[15] * d[3];
  12538. e[4] = c[0] * d[4] + c[4] * d[5] + c[8] * d[6] + c[12] * d[7];
  12539. e[5] = c[1] * d[4] + c[5] * d[5] + c[9] * d[6] + c[13] * d[7];
  12540. e[6] = c[2] * d[4] + c[6] * d[5] + c[10] * d[6] + c[14] * d[7];
  12541. e[7] = c[3] * d[4] + c[7] * d[5] + c[11] * d[6] + c[15] * d[7];
  12542. e[8] = c[0] * d[8] + c[4] * d[9] + c[8] * d[10] + c[12] * d[11];
  12543. e[9] = c[1] * d[8] + c[5] * d[9] + c[9] * d[10] + c[13] * d[11];
  12544. e[10] = c[2] * d[8] + c[6] * d[9] + c[10] * d[10] + c[14] * d[11];
  12545. e[11] = c[3] * d[8] + c[7] * d[9] + c[11] * d[10] + c[15] * d[11];
  12546. e[12] = c[0] * d[12] + c[4] * d[13] + c[8] * d[14] + c[12] * d[15];
  12547. e[13] = c[1] * d[12] + c[5] * d[13] + c[9] * d[14] + c[13] * d[15];
  12548. e[14] = c[2] * d[12] + c[6] * d[13] + c[10] * d[14] + c[14] * d[15];
  12549. e[15] = c[3] * d[12] + c[7] * d[13] + c[11] * d[14] + c[15] * d[15];
  12550. return e
  12551. };
  12552. cc.getMat4MultiplyWithMat4 = function (a, b, c) {
  12553. a = a.mat;
  12554. b = b.mat;
  12555. var d = c.mat;
  12556. d[0] = a[0] * b[0] + a[4] * b[1] + a[8] * b[2] + a[12] * b[3];
  12557. d[1] = a[1] * b[0] + a[5] * b[1] + a[9] * b[2] + a[13] * b[3];
  12558. d[2] = a[2] * b[0] + a[6] * b[1] + a[10] * b[2] + a[14] * b[3];
  12559. d[3] = a[3] * b[0] + a[7] * b[1] + a[11] * b[2] + a[15] * b[3];
  12560. d[4] = a[0] * b[4] + a[4] * b[5] + a[8] * b[6] + a[12] * b[7];
  12561. d[5] = a[1] * b[4] + a[5] * b[5] + a[9] * b[6] + a[13] * b[7];
  12562. d[6] = a[2] * b[4] + a[6] * b[5] + a[10] * b[6] + a[14] * b[7];
  12563. d[7] = a[3] * b[4] + a[7] * b[5] + a[11] * b[6] + a[15] * b[7];
  12564. d[8] = a[0] * b[8] + a[4] * b[9] + a[8] * b[10] + a[12] * b[11];
  12565. d[9] = a[1] * b[8] + a[5] * b[9] + a[9] * b[10] + a[13] * b[11];
  12566. d[10] = a[2] * b[8] + a[6] * b[9] + a[10] * b[10] + a[14] * b[11];
  12567. d[11] = a[3] * b[8] + a[7] * b[9] + a[11] * b[10] + a[15] * b[11];
  12568. d[12] = a[0] * b[12] + a[4] * b[13] + a[8] * b[14] + a[12] * b[15];
  12569. d[13] = a[1] * b[12] + a[5] * b[13] + a[9] * b[14] + a[13] * b[15];
  12570. d[14] = a[2] * b[12] + a[6] * b[13] + a[10] * b[14] + a[14] * b[15];
  12571. d[15] = a[3] * b[12] + a[7] * b[13] + a[11] * b[14] + a[15] * b[15];
  12572. return c.mat
  12573. };
  12574. cc.kmMat4Assign = function (a, b) {
  12575. if (a == b) return cc.log("cc.kmMat4Assign(): pOut equals pIn"),
  12576. a;
  12577. var c = a.mat,
  12578. d = b.mat;
  12579. c[0] = d[0];
  12580. c[1] = d[1];
  12581. c[2] = d[2];
  12582. c[3] = d[3];
  12583. c[4] = d[4];
  12584. c[5] = d[5];
  12585. c[6] = d[6];
  12586. c[7] = d[7];
  12587. c[8] = d[8];
  12588. c[9] = d[9];
  12589. c[10] = d[10];
  12590. c[11] = d[11];
  12591. c[12] = d[12];
  12592. c[13] = d[13];
  12593. c[14] = d[14];
  12594. c[15] = d[15];
  12595. return a
  12596. };
  12597. cc.kmMat4AreEqual = function (a, b) {
  12598. if (a == b) return cc.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."),
  12599. !0;
  12600. for (var c = 0; 16 > c; c++) if (!(a.mat[c] + cc.kmEpsilon > b.mat[c] && a.mat[c] - cc.kmEpsilon < b.mat[c])) return !1;
  12601. return !0
  12602. };
  12603. cc.kmMat4RotationX = function (a, b) {
  12604. a.mat[0] = 1;
  12605. a.mat[1] = 0;
  12606. a.mat[2] = 0;
  12607. a.mat[3] = 0;
  12608. a.mat[4] = 0;
  12609. a.mat[5] = Math.cos(b);
  12610. a.mat[6] = Math.sin(b);
  12611. a.mat[7] = 0;
  12612. a.mat[8] = 0;
  12613. a.mat[9] = -Math.sin(b);
  12614. a.mat[10] = Math.cos(b);
  12615. a.mat[11] = 0;
  12616. a.mat[12] = 0;
  12617. a.mat[13] = 0;
  12618. a.mat[14] = 0;
  12619. a.mat[15] = 1;
  12620. return a
  12621. };
  12622. cc.kmMat4RotationY = function (a, b) {
  12623. a.mat[0] = Math.cos(b);
  12624. a.mat[1] = 0;
  12625. a.mat[2] = -Math.sin(b);
  12626. a.mat[3] = 0;
  12627. a.mat[4] = 0;
  12628. a.mat[5] = 1;
  12629. a.mat[6] = 0;
  12630. a.mat[7] = 0;
  12631. a.mat[8] = Math.sin(b);
  12632. a.mat[9] = 0;
  12633. a.mat[10] = Math.cos(b);
  12634. a.mat[11] = 0;
  12635. a.mat[12] = 0;
  12636. a.mat[13] = 0;
  12637. a.mat[14] = 0;
  12638. a.mat[15] = 1;
  12639. return a
  12640. };
  12641. cc.kmMat4RotationZ = function (a, b) {
  12642. a.mat[0] = Math.cos(b);
  12643. a.mat[1] = Math.sin(b);
  12644. a.mat[2] = 0;
  12645. a.mat[3] = 0;
  12646. a.mat[4] = -Math.sin(b);
  12647. a.mat[5] = Math.cos(b);
  12648. a.mat[6] = 0;
  12649. a.mat[7] = 0;
  12650. a.mat[8] = 0;
  12651. a.mat[9] = 0;
  12652. a.mat[10] = 1;
  12653. a.mat[11] = 0;
  12654. a.mat[12] = 0;
  12655. a.mat[13] = 0;
  12656. a.mat[14] = 0;
  12657. a.mat[15] = 1;
  12658. return a
  12659. };
  12660. cc.kmMat4RotationPitchYawRoll = function (a, b, c, d) {
  12661. var e = Math.cos(b);
  12662. b = Math.sin(b);
  12663. var f = Math.cos(c);
  12664. c = Math.sin(c);
  12665. var g = Math.cos(d);
  12666. d = Math.sin(d);
  12667. var h = b * c,
  12668. k = e * c;
  12669. a.mat[0] = f * g;
  12670. a.mat[4] = f * d;
  12671. a.mat[8] = -c;
  12672. a.mat[1] = h * g - e * d;
  12673. a.mat[5] = h * d + e * g;
  12674. a.mat[9] = b * f;
  12675. a.mat[2] = k * g + b * d;
  12676. a.mat[6] = k * d - b * g;
  12677. a.mat[10] = e * f;
  12678. a.mat[3] = a.mat[7] = a.mat[11] = 0;
  12679. a.mat[15] = 1;
  12680. return a
  12681. };
  12682. cc.kmMat4RotationQuaternion = function (a, b) {
  12683. a.mat[0] = 1 - 2 * (b.y * b.y + b.z * b.z);
  12684. a.mat[1] = 2 * (b.x * b.y + b.z * b.w);
  12685. a.mat[2] = 2 * (b.x * b.z - b.y * b.w);
  12686. a.mat[3] = 0;
  12687. a.mat[4] = 2 * (b.x * b.y - b.z * b.w);
  12688. a.mat[5] = 1 - 2 * (b.x * b.x + b.z * b.z);
  12689. a.mat[6] = 2 * (b.z * b.y + b.x * b.w);
  12690. a.mat[7] = 0;
  12691. a.mat[8] = 2 * (b.x * b.z + b.y * b.w);
  12692. a.mat[9] = 2 * (b.y * b.z - b.x * b.w);
  12693. a.mat[10] = 1 - 2 * (b.x * b.x + b.y * b.y);
  12694. a.mat[11] = 0;
  12695. a.mat[12] = 0;
  12696. a.mat[13] = 0;
  12697. a.mat[14] = 0;
  12698. a.mat[15] = 1;
  12699. return a
  12700. };
  12701. cc.kmMat4RotationTranslation = function (a, b, c) {
  12702. a.mat[0] = b.mat[0];
  12703. a.mat[1] = b.mat[1];
  12704. a.mat[2] = b.mat[2];
  12705. a.mat[3] = 0;
  12706. a.mat[4] = b.mat[3];
  12707. a.mat[5] = b.mat[4];
  12708. a.mat[6] = b.mat[5];
  12709. a.mat[7] = 0;
  12710. a.mat[8] = b.mat[6];
  12711. a.mat[9] = b.mat[7];
  12712. a.mat[10] = b.mat[8];
  12713. a.mat[11] = 0;
  12714. a.mat[12] = c.x;
  12715. a.mat[13] = c.y;
  12716. a.mat[14] = c.z;
  12717. a.mat[15] = 1;
  12718. return a
  12719. };
  12720. cc.kmMat4Scaling = function (a, b, c, d) {
  12721. a.mat[0] = b;
  12722. a.mat[5] = c;
  12723. a.mat[10] = d;
  12724. a.mat[15] = 1;
  12725. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = a.mat[12] = a.mat[13] = a.mat[14] = 0;
  12726. return a
  12727. };
  12728. cc.kmMat4Translation = function (a, b, c, d) {
  12729. a.mat[0] = a.mat[5] = a.mat[10] = a.mat[15] = 1;
  12730. a.mat[1] = a.mat[2] = a.mat[3] = a.mat[4] = a.mat[6] = a.mat[7] = a.mat[8] = a.mat[9] = a.mat[11] = 0;
  12731. a.mat[12] = b;
  12732. a.mat[13] = c;
  12733. a.mat[14] = d;
  12734. return a
  12735. };
  12736. cc.kmMat4GetUpVec3 = function (a, b) {
  12737. a.x = b.mat[4];
  12738. a.y = b.mat[5];
  12739. a.z = b.mat[6];
  12740. cc.kmVec3Normalize(a, a);
  12741. return a
  12742. };
  12743. cc.kmMat4GetRightVec3 = function (a, b) {
  12744. a.x = b.mat[0];
  12745. a.y = b.mat[1];
  12746. a.z = b.mat[2];
  12747. cc.kmVec3Normalize(a, a);
  12748. return a
  12749. };
  12750. cc.kmMat4GetForwardVec3 = function (a, b) {
  12751. a.x = b.mat[8];
  12752. a.y = b.mat[9];
  12753. a.z = b.mat[10];
  12754. cc.kmVec3Normalize(a, a);
  12755. return a
  12756. };
  12757. cc.kmMat4PerspectiveProjection = function (a, b, c, d, e) {
  12758. var f = cc.kmDegreesToRadians(b / 2);
  12759. b = e - d;
  12760. var g = Math.sin(f);
  12761. if (0 == b || 0 == g || 0 == c) return null;
  12762. f = Math.cos(f) / g;
  12763. cc.kmMat4Identity(a);
  12764. a.mat[0] = f / c;
  12765. a.mat[5] = f;
  12766. a.mat[10] = -(e + d) / b;
  12767. a.mat[11] = -1;
  12768. a.mat[14] = -2 * d * e / b;
  12769. a.mat[15] = 0;
  12770. return a
  12771. };
  12772. cc.kmMat4OrthographicProjection = function (a, b, c, d, e, f, g) {
  12773. cc.kmMat4Identity(a);
  12774. a.mat[0] = 2 / (c - b);
  12775. a.mat[5] = 2 / (e - d);
  12776. a.mat[10] = -2 / (g - f);
  12777. a.mat[12] = -((c + b) / (c - b));
  12778. a.mat[13] = -((e + d) / (e - d));
  12779. a.mat[14] = -((g + f) / (g - f));
  12780. return a
  12781. };
  12782. cc.kmMat4LookAt = function (a, b, c, d) {
  12783. var e = new cc.kmVec3,
  12784. f = new cc.kmVec3,
  12785. g = new cc.kmVec3,
  12786. h = new cc.kmVec3,
  12787. k = new cc.kmMat4;
  12788. cc.kmVec3Subtract(e, c, b);
  12789. cc.kmVec3Normalize(e, e);
  12790. cc.kmVec3Assign(f, d);
  12791. cc.kmVec3Normalize(f, f);
  12792. cc.kmVec3Cross(g, e, f);
  12793. cc.kmVec3Normalize(g, g);
  12794. cc.kmVec3Cross(h, g, e);
  12795. cc.kmVec3Normalize(g, g);
  12796. cc.kmMat4Identity(a);
  12797. a.mat[0] = g.x;
  12798. a.mat[4] = g.y;
  12799. a.mat[8] = g.z;
  12800. a.mat[1] = h.x;
  12801. a.mat[5] = h.y;
  12802. a.mat[9] = h.z;
  12803. a.mat[2] = -e.x;
  12804. a.mat[6] = -e.y;
  12805. a.mat[10] = -e.z;
  12806. cc.kmMat4Translation(k, -b.x, -b.y, -b.z);
  12807. cc.kmMat4Multiply(a, a, k);
  12808. return a
  12809. };
  12810. cc.kmMat4RotationAxisAngle = function (a, b, c) {
  12811. var d = Math.cos(c);
  12812. c = Math.sin(c);
  12813. var e = new cc.kmVec3;
  12814. cc.kmVec3Normalize(e, b);
  12815. a.mat[0] = d + e.x * e.x * (1 - d);
  12816. a.mat[1] = e.z * c + e.y * e.x * (1 - d);
  12817. a.mat[2] = -e.y * c + e.z * e.x * (1 - d);
  12818. a.mat[3] = 0;
  12819. a.mat[4] = -e.z * c + e.x * e.y * (1 - d);
  12820. a.mat[5] = d + e.y * e.y * (1 - d);
  12821. a.mat[6] = e.x * c + e.z * e.y * (1 - d);
  12822. a.mat[7] = 0;
  12823. a.mat[8] = e.y * c + e.x * e.z * (1 - d);
  12824. a.mat[9] = -e.x * c + e.y * e.z * (1 - d);
  12825. a.mat[10] = d + e.z * e.z * (1 - d);
  12826. a.mat[11] = 0;
  12827. a.mat[12] = 0;
  12828. a.mat[13] = 0;
  12829. a.mat[14] = 0;
  12830. a.mat[15] = 1;
  12831. return a
  12832. };
  12833. cc.kmMat4ExtractRotation = function (a, b) {
  12834. a.mat[0] = b.mat[0];
  12835. a.mat[1] = b.mat[1];
  12836. a.mat[2] = b.mat[2];
  12837. a.mat[3] = b.mat[4];
  12838. a.mat[4] = b.mat[5];
  12839. a.mat[5] = b.mat[6];
  12840. a.mat[6] = b.mat[8];
  12841. a.mat[7] = b.mat[9];
  12842. a.mat[8] = b.mat[10];
  12843. return a
  12844. };
  12845. cc.kmMat4ExtractPlane = function (a, b, c) {
  12846. switch (c) {
  12847. case cc.KM_PLANE_RIGHT:
  12848. a.a = b.mat[3] - b.mat[0];
  12849. a.b = b.mat[7] - b.mat[4];
  12850. a.c = b.mat[11] - b.mat[8];
  12851. a.d = b.mat[15] - b.mat[12];
  12852. break;
  12853. case cc.KM_PLANE_LEFT:
  12854. a.a = b.mat[3] + b.mat[0];
  12855. a.b = b.mat[7] + b.mat[4];
  12856. a.c = b.mat[11] + b.mat[8];
  12857. a.d = b.mat[15] + b.mat[12];
  12858. break;
  12859. case cc.KM_PLANE_BOTTOM:
  12860. a.a = b.mat[3] + b.mat[1];
  12861. a.b = b.mat[7] + b.mat[5];
  12862. a.c = b.mat[11] + b.mat[9];
  12863. a.d = b.mat[15] + b.mat[13];
  12864. break;
  12865. case cc.KM_PLANE_TOP:
  12866. a.a = b.mat[3] - b.mat[1];
  12867. a.b = b.mat[7] - b.mat[5];
  12868. a.c = b.mat[11] - b.mat[9];
  12869. a.d = b.mat[15] -
  12870. b.mat[13];
  12871. break;
  12872. case cc.KM_PLANE_FAR:
  12873. a.a = b.mat[3] - b.mat[2];
  12874. a.b = b.mat[7] - b.mat[6];
  12875. a.c = b.mat[11] - b.mat[10];
  12876. a.d = b.mat[15] - b.mat[14];
  12877. break;
  12878. case cc.KM_PLANE_NEAR:
  12879. a.a = b.mat[3] + b.mat[2];
  12880. a.b = b.mat[7] + b.mat[6];
  12881. a.c = b.mat[11] + b.mat[10];
  12882. a.d = b.mat[15] + b.mat[14];
  12883. break;
  12884. default:
  12885. cc.log("cc.kmMat4ExtractPlane(): Invalid plane index")
  12886. }
  12887. b = Math.sqrt(a.a * a.a + a.b * a.b + a.c * a.c);
  12888. a.a /= b;
  12889. a.b /= b;
  12890. a.c /= b;
  12891. a.d /= b;
  12892. return a
  12893. };
  12894. cc.kmMat4RotationToAxisAngle = function (a, b, c) {
  12895. var d = new cc.kmQuaternion,
  12896. e = new cc.kmMat3;
  12897. cc.kmMat4ExtractRotation(e, c);
  12898. cc.kmQuaternionRotationMatrix(d, e);
  12899. cc.kmQuaternionToAxisAngle(d, a, b);
  12900. return a
  12901. };
  12902. cc.KM_PLANE_LEFT = 0;
  12903. cc.KM_PLANE_RIGHT = 1;
  12904. cc.KM_PLANE_BOTTOM = 2;
  12905. cc.KM_PLANE_TOP = 3;
  12906. cc.KM_PLANE_NEAR = 4;
  12907. cc.KM_PLANE_FAR = 5;
  12908. cc.kmPlane = function (a, b, c, d) {
  12909. this.a = a || 0;
  12910. this.b = b || 0;
  12911. this.c = c || 0;
  12912. this.d = d || 0
  12913. };
  12914. cc.POINT_INFRONT_OF_PLANE = 0;
  12915. cc.POINT_BEHIND_PLANE = 1;
  12916. cc.POINT_ON_PLANE = 2;
  12917. cc.kmPlaneDot = function (a, b) {
  12918. return a.a * b.x + a.b * b.y + a.c * b.z + a.d * b.w
  12919. };
  12920. cc.kmPlaneDotCoord = function (a, b) {
  12921. return a.a * b.x + a.b * b.y + a.c * b.z + a.d
  12922. };
  12923. cc.kmPlaneDotNormal = function (a, b) {
  12924. return a.a * b.x + a.b * b.y + a.c * b.z
  12925. };
  12926. cc.kmPlaneFromPointNormal = function (a, b, c) {
  12927. a.a = c.x;
  12928. a.b = c.y;
  12929. a.c = c.z;
  12930. a.d = -cc.kmVec3Dot(c, b);
  12931. return a
  12932. };
  12933. cc.kmPlaneFromPoints = function (a, b, c, d) {
  12934. var e = new cc.kmVec3,
  12935. f = new cc.kmVec3,
  12936. g = new cc.kmVec3;
  12937. cc.kmVec3Subtract(f, c, b);
  12938. cc.kmVec3Subtract(g, d, b);
  12939. cc.kmVec3Cross(e, f, g);
  12940. cc.kmVec3Normalize(e, e);
  12941. a.a = e.x;
  12942. a.b = e.y;
  12943. a.c = e.z;
  12944. a.d = cc.kmVec3Dot(cc.kmVec3Scale(e, e, -1), b);
  12945. return a
  12946. };
  12947. cc.kmPlaneIntersectLine = function (a, b, c, d) {
  12948. throw "cc.kmPlaneIntersectLine() hasn't been implemented.";
  12949. };
  12950. cc.kmPlaneNormalize = function (a, b) {
  12951. var c = new cc.kmVec3;
  12952. c.x = b.a;
  12953. c.y = b.b;
  12954. c.z = b.c;
  12955. var d = 1 / cc.kmVec3Length(c);
  12956. cc.kmVec3Normalize(c, c);
  12957. a.a = c.x;
  12958. a.b = c.y;
  12959. a.c = c.z;
  12960. a.d = b.d * d;
  12961. return a
  12962. };
  12963. cc.kmPlaneScale = function (a, b, c) {
  12964. cc.log("cc.kmPlaneScale() has not been implemented.")
  12965. };
  12966. cc.kmPlaneClassifyPoint = function (a, b) {
  12967. var c = a.a * b.x + a.b * b.y + a.c * b.z + a.d;
  12968. return 0.001 < c ? cc.POINT_INFRONT_OF_PLANE : -0.001 > c ? cc.POINT_BEHIND_PLANE : cc.POINT_ON_PLANE
  12969. };
  12970. cc.kmQuaternion = function (a, b, c, d) {
  12971. this.x = a || 0;
  12972. this.y = b || 0;
  12973. this.z = c || 0;
  12974. this.w = d || 0
  12975. };
  12976. cc.kmQuaternionConjugate = function (a, b) {
  12977. a.x = -b.x;
  12978. a.y = -b.y;
  12979. a.z = -b.z;
  12980. a.w = b.w;
  12981. return a
  12982. };
  12983. cc.kmQuaternionDot = function (a, b) {
  12984. return a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z
  12985. };
  12986. cc.kmQuaternionExp = function (a, b) {
  12987. return a
  12988. };
  12989. cc.kmQuaternionIdentity = function (a) {
  12990. a.x = 0;
  12991. a.y = 0;
  12992. a.z = 0;
  12993. a.w = 1;
  12994. return a
  12995. };
  12996. cc.kmQuaternionInverse = function (a, b) {
  12997. var c = cc.kmQuaternionLength(b),
  12998. d = new cc.kmQuaternion;
  12999. if (Math.abs(c) > cc.kmEpsilon) return a.x = 0,
  13000. a.y = 0,
  13001. a.z = 0,
  13002. a.w = 0,
  13003. a;
  13004. cc.kmQuaternionScale(a, cc.kmQuaternionConjugate(d, b), 1 / c);
  13005. return a
  13006. };
  13007. cc.kmQuaternionIsIdentity = function (a) {
  13008. return 0 == a.x && 0 == a.y && 0 == a.z && 1 == a.w
  13009. };
  13010. cc.kmQuaternionLength = function (a) {
  13011. return Math.sqrt(cc.kmQuaternionLengthSq(a))
  13012. };
  13013. cc.kmQuaternionLengthSq = function (a) {
  13014. return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w
  13015. };
  13016. cc.kmQuaternionLn = function (a, b) {
  13017. return a
  13018. };
  13019. cc.kmQuaternionMultiply = function (a, b, c) {
  13020. a.w = b.w * c.w - b.x * c.x - b.y * c.y - b.z * c.z;
  13021. a.x = b.w * c.x + b.x * c.w + b.y * c.z - b.z * c.y;
  13022. a.y = b.w * c.y + b.y * c.w + b.z * c.x - b.x * c.z;
  13023. a.z = b.w * c.z + b.z * c.w + b.x * c.y - b.y * c.x;
  13024. return a
  13025. };
  13026. cc.kmQuaternionNormalize = function (a, b) {
  13027. var c = cc.kmQuaternionLength(b);
  13028. if (Math.abs(c) <= cc.kmEpsilon) throw "cc.kmQuaternionNormalize(): pIn is an invalid value";
  13029. cc.kmQuaternionScale(a, b, 1 / c);
  13030. return a
  13031. };
  13032. cc.kmQuaternionRotationAxis = function (a, b, c) {
  13033. c *= 0.5;
  13034. var d = Math.sin(c);
  13035. a.w = Math.cos(c);
  13036. a.x = b.x * d;
  13037. a.y = b.y * d;
  13038. a.z = b.z * d;
  13039. return a
  13040. };
  13041. cc.kmQuaternionRotationMatrix = function (a, b) {
  13042. var c,
  13043. d,
  13044. e,
  13045. f;
  13046. c = [];
  13047. d = f = 0;
  13048. if (!b) return null;
  13049. c[0] = b.mat[0];
  13050. c[1] = b.mat[3];
  13051. c[2] = b.mat[6];
  13052. c[4] = b.mat[1];
  13053. c[5] = b.mat[4];
  13054. c[6] = b.mat[7];
  13055. c[8] = b.mat[2];
  13056. c[9] = b.mat[5];
  13057. c[10] = b.mat[8];
  13058. c[15] = 1;
  13059. var g = c[0];
  13060. d = g[0] + g[5] + g[10] + 1;
  13061. d > cc.kmEpsilon ? (f = 2 * Math.sqrt(d), c = (g[9] - g[6]) / f, d = (g[2] - g[8]) / f, e = (g[4] - g[1]) / f, f *= 0.25) : g[0] > g[5] && g[0] > g[10] ? (f = 2 * Math.sqrt(1 + g[0] - g[5] - g[10]), c = 0.25 * f, d = (g[4] + g[1]) / f, e = (g[2] + g[8]) / f, f = (g[9] - g[6]) / f) : g[5] > g[10] ? (f = 2 * Math.sqrt(1 + g[5] - g[0] - g[10]), c = (g[4] + g[1]) / f, d = 0.25 * f, e = (g[9] + g[6]) / f, f = (g[2] - g[8]) / f) : (f = 2 * Math.sqrt(1 + g[10] - g[0] - g[5]), c = (g[2] + g[8]) / f, d = (g[9] + g[6]) / f, e = 0.25 * f, f = (g[4] - g[1]) / f);
  13062. a.x = c;
  13063. a.y = d;
  13064. a.z = e;
  13065. a.w = f;
  13066. return a
  13067. };
  13068. cc.kmQuaternionRotationYawPitchRoll = function (a, b, c, d) {
  13069. var e,
  13070. f,
  13071. g,
  13072. h,
  13073. k;
  13074. e = cc.kmDegreesToRadians(c) / 2;
  13075. f = cc.kmDegreesToRadians(b) / 2;
  13076. g = cc.kmDegreesToRadians(d) / 2;
  13077. d = Math.cos(e);
  13078. b = Math.cos(f);
  13079. c = Math.cos(g);
  13080. e = Math.sin(e);
  13081. f = Math.sin(f);
  13082. g = Math.sin(g);
  13083. h = b * c;
  13084. k = f * g;
  13085. a.w = d * h + e * k;
  13086. a.x = e * h - d * k;
  13087. a.y = d * f * c + e * b * g;
  13088. a.z = d * b * g - e * f * c;
  13089. cc.kmQuaternionNormalize(a, a);
  13090. return a
  13091. };
  13092. cc.kmQuaternionSlerp = function (a, b, c, d) {
  13093. if (b.x == c.x && b.y == c.y && b.z == c.z && b.w == c.w) return a.x = b.x,
  13094. a.y = b.y,
  13095. a.z = b.z,
  13096. a.w = b.w,
  13097. a;
  13098. var e = cc.kmQuaternionDot(b, c),
  13099. f = Math.acos(e),
  13100. g = Math.sqrt(1 - cc.kmSQR(e)),
  13101. e = Math.sin(d * f) / g;
  13102. d = Math.sin((1 - d) * f) / g;
  13103. f = new cc.kmQuaternion;
  13104. g = new cc.kmQuaternion;
  13105. cc.kmQuaternionScale(f, b, d);
  13106. cc.kmQuaternionScale(g, c, e);
  13107. cc.kmQuaternionAdd(a, f, g);
  13108. return a
  13109. };
  13110. cc.kmQuaternionToAxisAngle = function (a, b, c) {
  13111. Math.acos(a.w);
  13112. c = Math.sqrt(cc.kmSQR(a.x) + cc.kmSQR(a.y) + cc.kmSQR(a.z));
  13113. c > -cc.kmEpsilon && c < cc.kmEpsilon || c < 2 * cc.kmPI + cc.kmEpsilon && c > 2 * cc.kmPI - cc.kmEpsilon ? (b.x = 0, b.y = 0, b.z = 1) : (b.x = a.x / c, b.y = a.y / c, b.z = a.z / c, cc.kmVec3Normalize(b, b))
  13114. };
  13115. cc.kmQuaternionScale = function (a, b, c) {
  13116. a.x = b.x * c;
  13117. a.y = b.y * c;
  13118. a.z = b.z * c;
  13119. a.w = b.w * c;
  13120. return a
  13121. };
  13122. cc.kmQuaternionAssign = function (a, b) {
  13123. a.x = b.x;
  13124. a.y = b.y;
  13125. a.z = b.z;
  13126. a.w = b.w;
  13127. return a
  13128. };
  13129. cc.kmQuaternionAdd = function (a, b, c) {
  13130. a.x = b.x + c.x;
  13131. a.y = b.y + c.y;
  13132. a.z = b.z + c.z;
  13133. a.w = b.w + c.w;
  13134. return a
  13135. };
  13136. cc.kmQuaternionRotationBetweenVec3 = function (a, b, c, d) {
  13137. var e = new cc.kmVec3,
  13138. f = new cc.kmVec3;
  13139. cc.kmVec3Assign(e, b);
  13140. cc.kmVec3Assign(f, c);
  13141. cc.kmVec3Normalize(e, e);
  13142. cc.kmVec3Normalize(f, f);
  13143. c = cc.kmVec3Dot(e, f);
  13144. if (1 <= c) return cc.kmQuaternionIdentity(a),
  13145. a; -0.999999 > c ? Math.abs(cc.kmVec3LengthSq(d)) < cc.kmEpsilon ? cc.kmQuaternionRotationAxis(a, d, cc.kmPI) : (e = new cc.kmVec3, f = new cc.kmVec3, f.x = 1, f.y = 0, f.z = 0, cc.kmVec3Cross(e, f, b), Math.abs(cc.kmVec3LengthSq(e)) < cc.kmEpsilon && (f = new cc.kmVec3, f.x = 0, f.y = 1, f.z = 0, cc.kmVec3Cross(e, f, b)), cc.kmVec3Normalize(e, e), cc.kmQuaternionRotationAxis(a, e, cc.kmPI)) : (b = Math.sqrt(2 * (1 + c)), d = 1 / b, c = new cc.kmVec3, cc.kmVec3Cross(c, e, f), a.x = c.x * d, a.y = c.y * d, a.z = c.z * d, a.w = 0.5 * b, cc.kmQuaternionNormalize(a, a));
  13146. return a
  13147. };
  13148. cc.kmQuaternionMultiplyVec3 = function (a, b, c) {
  13149. var d = new cc.kmVec3,
  13150. e = new cc.kmVec3,
  13151. f = new cc.kmVec3;
  13152. f.x = b.x;
  13153. f.y = b.y;
  13154. f.z = b.z;
  13155. cc.kmVec3Cross(d, f, c);
  13156. cc.kmVec3Cross(e, f, d);
  13157. cc.kmVec3Scale(d, d, 2 * b.w);
  13158. cc.kmVec3Scale(e, e, 2);
  13159. cc.kmVec3Add(a, c, d);
  13160. cc.kmVec3Add(a, a, e);
  13161. return a
  13162. };
  13163. cc.kmAABB = function (a, b) {
  13164. this.min = a || new cc.kmVec3;
  13165. this.max = b || new cc.kmVec3
  13166. };
  13167. cc.kmAABBContainsPoint = function (a, b) {
  13168. 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 ? cc.KM_TRUE : cc.KM_FALSE
  13169. };
  13170. cc.kmAABBAssign = function (a, b) {
  13171. cc.kmVec3Assign(a.min, b.min);
  13172. cc.kmVec3Assign(a.max, b.max);
  13173. return a
  13174. };
  13175. cc.kmAABBScale = function (a, b, c) {
  13176. cc.log("cc.kmAABBScale hasn't been supported.")
  13177. };
  13178. cc.km_mat4_stack = function (a, b, c, d) {
  13179. this.top = c;
  13180. this.stack = d
  13181. };
  13182. cc.km_mat4_stack.INITIAL_SIZE = 30;
  13183. cc.km_mat4_stack_initialize = function (a) {
  13184. a.stack = [];
  13185. a.top = null
  13186. };
  13187. cc.km_mat4_stack_push = function (a, b) {
  13188. a.stack.push(a.top);
  13189. a.top = new cc.kmMat4;
  13190. cc.kmMat4Assign(a.top, b)
  13191. };
  13192. cc.km_mat4_stack_pop = function (a, b) {
  13193. a.top = a.stack.pop()
  13194. };
  13195. cc.km_mat4_stack_release = function (a) {
  13196. a.stack = null;
  13197. a.top = null
  13198. };
  13199. cc.KM_GL_MODELVIEW = 5888;
  13200. cc.KM_GL_PROJECTION = 5889;
  13201. cc.KM_GL_TEXTURE = 5890;
  13202. cc.modelview_matrix_stack = new cc.km_mat4_stack;
  13203. cc.projection_matrix_stack = new cc.km_mat4_stack;
  13204. cc.texture_matrix_stack = new cc.km_mat4_stack;
  13205. cc.current_stack = null;
  13206. cc.initialized = !1;
  13207. cc.lazyInitialize = function () {
  13208. if (!cc.initialized) {
  13209. var a = new cc.kmMat4;
  13210. cc.km_mat4_stack_initialize(cc.modelview_matrix_stack);
  13211. cc.km_mat4_stack_initialize(cc.projection_matrix_stack);
  13212. cc.km_mat4_stack_initialize(cc.texture_matrix_stack);
  13213. cc.current_stack = cc.modelview_matrix_stack;
  13214. cc.initialized = !0;
  13215. cc.kmMat4Identity(a);
  13216. cc.km_mat4_stack_push(cc.modelview_matrix_stack, a);
  13217. cc.km_mat4_stack_push(cc.projection_matrix_stack, a);
  13218. cc.km_mat4_stack_push(cc.texture_matrix_stack, a)
  13219. }
  13220. };
  13221. cc.lazyInitialize();
  13222. cc.kmGLFreeAll = function () {
  13223. cc.km_mat4_stack_release(cc.modelview_matrix_stack);
  13224. cc.km_mat4_stack_release(cc.projection_matrix_stack);
  13225. cc.km_mat4_stack_release(cc.texture_matrix_stack);
  13226. cc.initialized = !1;
  13227. cc.current_stack = null
  13228. };
  13229. cc.kmGLPushMatrix = function () {
  13230. cc.km_mat4_stack_push(cc.current_stack, cc.current_stack.top)
  13231. };
  13232. cc.kmGLPushMatrixWitMat4 = function (a) {
  13233. cc.current_stack.stack.push(cc.current_stack.top);
  13234. cc.kmMat4Assign(a, cc.current_stack.top);
  13235. cc.current_stack.top = a
  13236. };
  13237. cc.kmGLPopMatrix = function () {
  13238. cc.current_stack.top = cc.current_stack.stack.pop()
  13239. };
  13240. cc.kmGLMatrixMode = function (a) {
  13241. switch (a) {
  13242. case cc.KM_GL_MODELVIEW:
  13243. cc.current_stack = cc.modelview_matrix_stack;
  13244. break;
  13245. case cc.KM_GL_PROJECTION:
  13246. cc.current_stack = cc.projection_matrix_stack;
  13247. break;
  13248. case cc.KM_GL_TEXTURE:
  13249. cc.current_stack = cc.texture_matrix_stack;
  13250. break;
  13251. default:
  13252. throw "Invalid matrix mode specified";
  13253. }
  13254. };
  13255. cc.kmGLLoadIdentity = function () {
  13256. cc.kmMat4Identity(cc.current_stack.top)
  13257. };
  13258. cc.kmGLLoadMatrix = function (a) {
  13259. cc.kmMat4Assign(cc.current_stack.top, a)
  13260. };
  13261. cc.kmGLMultMatrix = function (a) {
  13262. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, a)
  13263. };
  13264. cc.kmGLTranslatef = function (a, b, c) {
  13265. var d = new cc.kmMat4;
  13266. cc.kmMat4Translation(d, a, b, c);
  13267. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, d)
  13268. };
  13269. cc.kmGLRotatef = function (a, b, c, d) {
  13270. b = new cc.kmVec3(b, c, d);
  13271. c = new cc.kmMat4;
  13272. cc.kmMat4RotationAxisAngle(c, b, cc.kmDegreesToRadians(a));
  13273. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, c)
  13274. };
  13275. cc.kmGLScalef = function (a, b, c) {
  13276. var d = new cc.kmMat4;
  13277. cc.kmMat4Scaling(d, a, b, c);
  13278. cc.kmMat4Multiply(cc.current_stack.top, cc.current_stack.top, d)
  13279. };
  13280. cc.kmGLGetMatrix = function (a, b) {
  13281. switch (a) {
  13282. case cc.KM_GL_MODELVIEW:
  13283. cc.kmMat4Assign(b, cc.modelview_matrix_stack.top);
  13284. break;
  13285. case cc.KM_GL_PROJECTION:
  13286. cc.kmMat4Assign(b, cc.projection_matrix_stack.top);
  13287. break;
  13288. case cc.KM_GL_TEXTURE:
  13289. cc.kmMat4Assign(b, cc.texture_matrix_stack.top);
  13290. break;
  13291. default:
  13292. throw "Invalid matrix mode specified";
  13293. }
  13294. };
  13295. cc.SHADER_POSITION_UCOLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n}\n";
  13296. 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}";
  13297. cc.SHADER_POSITION_COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor; \n} ";
  13298. 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}";
  13299. 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}";
  13300. 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}";
  13301. cc.SHADER_POSITION_TEXTURE_FRAG = "precision lowp float; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord); \n}";
  13302. 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}";
  13303. cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG = "precision lowp float; \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d texture2D(CC_Texture0, v_texCoord) * u_color; \n}";
  13304. 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}";
  13305. cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d vec4( v_fragmentColor.rgb, \n v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a \n ); \n}";
  13306. 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}";
  13307. cc.SHADER_POSITION_TEXTURE_COLOR_FRAG = "precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nvoid main() \n{ \n gl_FragColor \x3d v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}";
  13308. 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}";
  13309. cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = "precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D CC_Texture0; \nuniform float CC_alpha_value; \nvoid main() \n{ \n vec4 texColor \x3d texture2D(CC_Texture0, v_texCoord); \n if ( texColor.a \x3c\x3d CC_alpha_value ) \n discard; \n gl_FragColor \x3d texColor * v_fragmentColor; \n}";
  13310. 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}";
  13311. cc.shaderCache = {
  13312. TYPE_POSITION_TEXTURECOLOR: 0,
  13313. TYPE_POSITION_TEXTURECOLOR_ALPHATEST: 1,
  13314. TYPE_POSITION_COLOR: 2,
  13315. TYPE_POSITION_TEXTURE: 3,
  13316. TYPE_POSITION_TEXTURE_UCOLOR: 4,
  13317. TYPE_POSITION_TEXTURE_A8COLOR: 5,
  13318. TYPE_POSITION_UCOLOR: 6,
  13319. TYPE_POSITION_LENGTH_TEXTURECOLOR: 7,
  13320. TYPE_MAX: 8,
  13321. _programs: {},
  13322. _init: function () {
  13323. this.loadDefaultShaders();
  13324. return !0
  13325. },
  13326. _loadDefaultShader: function (a, b) {
  13327. switch (b) {
  13328. case this.TYPE_POSITION_TEXTURECOLOR:
  13329. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_FRAG);
  13330. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13331. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13332. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13333. break;
  13334. case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:
  13335. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG);
  13336. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13337. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13338. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13339. break;
  13340. case this.TYPE_POSITION_COLOR:
  13341. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT, cc.SHADER_POSITION_COLOR_FRAG);
  13342. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13343. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13344. break;
  13345. case this.TYPE_POSITION_TEXTURE:
  13346. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT, cc.SHADER_POSITION_TEXTURE_FRAG);
  13347. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13348. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13349. break;
  13350. case this.TYPE_POSITION_TEXTURE_UCOLOR:
  13351. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT, cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG);
  13352. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13353. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13354. break;
  13355. case this.TYPE_POSITION_TEXTURE_A8COLOR:
  13356. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT, cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG);
  13357. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13358. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13359. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13360. break;
  13361. case this.TYPE_POSITION_UCOLOR:
  13362. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT, cc.SHADER_POSITION_UCOLOR_FRAG);
  13363. a.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION);
  13364. break;
  13365. case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:
  13366. a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT, cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG);
  13367. a.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
  13368. a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
  13369. a.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
  13370. break;
  13371. default:
  13372. cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type");
  13373. return
  13374. }
  13375. a.link();
  13376. a.updateUniforms()
  13377. },
  13378. loadDefaultShaders: function () {
  13379. var a = new cc.GLProgram;
  13380. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  13381. this._programs[cc.SHADER_POSITION_TEXTURECOLOR] = a;
  13382. this._programs.ShaderPositionTextureColor = a;
  13383. a = new cc.GLProgram;
  13384. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  13385. this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST] = a;
  13386. this._programs.ShaderPositionTextureColorAlphaTest = a;
  13387. a = new cc.GLProgram;
  13388. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  13389. this._programs[cc.SHADER_POSITION_COLOR] = a;
  13390. this._programs.ShaderPositionColor = a;
  13391. a = new cc.GLProgram;
  13392. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  13393. this._programs[cc.SHADER_POSITION_TEXTURE] = a;
  13394. this._programs.ShaderPositionTexture = a;
  13395. a = new cc.GLProgram;
  13396. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  13397. this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR] = a;
  13398. this._programs.ShaderPositionTextureUColor = a;
  13399. a = new cc.GLProgram;
  13400. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  13401. this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR] = a;
  13402. this._programs.ShaderPositionTextureA8Color = a;
  13403. a = new cc.GLProgram;
  13404. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR);
  13405. this._programs[cc.SHADER_POSITION_UCOLOR] = a;
  13406. this._programs.ShaderPositionUColor = a;
  13407. a = new cc.GLProgram;
  13408. this._loadDefaultShader(a, this.TYPE_POSITION_LENGTH_TEXTURECOLOR);
  13409. this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR] = a;
  13410. this._programs.ShaderPositionLengthTextureColor = a
  13411. },
  13412. reloadDefaultShaders: function () {
  13413. var a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  13414. a.reset();
  13415. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR);
  13416. a = this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);
  13417. a.reset();
  13418. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST);
  13419. a = this.programForKey(cc.SHADER_POSITION_COLOR);
  13420. a.reset();
  13421. this._loadDefaultShader(a, this.TYPE_POSITION_COLOR);
  13422. a = this.programForKey(cc.SHADER_POSITION_TEXTURE);
  13423. a.reset();
  13424. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE);
  13425. a = this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR);
  13426. a.reset();
  13427. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_UCOLOR);
  13428. a = this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR);
  13429. a.reset();
  13430. this._loadDefaultShader(a, this.TYPE_POSITION_TEXTURE_A8COLOR);
  13431. a = this.programForKey(cc.SHADER_POSITION_UCOLOR);
  13432. a.reset();
  13433. this._loadDefaultShader(a, this.TYPE_POSITION_UCOLOR)
  13434. },
  13435. programForKey: function (a) {
  13436. return this._programs[a]
  13437. },
  13438. getProgram: function (a) {
  13439. return this._programs[a]
  13440. },
  13441. addProgram: function (a, b) {
  13442. this._programs[b] = a
  13443. }
  13444. };
  13445. cc.HashUniformEntry = function (a, b, c) {
  13446. this.value = a;
  13447. this.location = b;
  13448. this.hh = c || {}
  13449. };
  13450. cc.GLProgram = cc.Class.extend({
  13451. _glContext: null,
  13452. _programObj: null,
  13453. _vertShader: null,
  13454. _fragShader: null,
  13455. _uniforms: null,
  13456. _hashForUniforms: null,
  13457. _usesTime: !1,
  13458. _updateUniformLocation: function (a, b, c) {
  13459. if (null == a) return !1;
  13460. c = !0;
  13461. for (var d = null, e = 0; e < this._hashForUniforms.length; e++) this._hashForUniforms[e].location == a && (d = this._hashForUniforms[e]);
  13462. d ? d.value == b ? c = !1 : d.value = b : (d = new cc.HashUniformEntry, d.location = a, d.value = b, this._hashForUniforms.push(d));
  13463. return c
  13464. },
  13465. _description: function () {
  13466. return "\x3cCCGLProgram \x3d " +
  13467. this.toString() + " | Program \x3d " + this._programObj.toString() + ", VertexShader \x3d " + this._vertShader.toString() + ", FragmentShader \x3d " + this._fragShader.toString() + "\x3e"
  13468. },
  13469. _compileShader: function (a, b, c) {
  13470. if (!c || !a) return !1;
  13471. this._glContext.shaderSource(a, "precision highp float; \nuniform mat4 CC_PMatrix; \nuniform mat4 CC_MVMatrix; \nuniform mat4 CC_MVPMatrix; \nuniform vec4 CC_Time; \nuniform vec4 CC_SinTime; \nuniform vec4 CC_CosTime; \nuniform vec4 CC_Random01; \n//CC INCLUDES END \n" +
  13472. c);
  13473. this._glContext.compileShader(a);
  13474. c = this._glContext.getShaderParameter(a, this._glContext.COMPILE_STATUS);
  13475. 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()));
  13476. return 1 == c
  13477. },
  13478. ctor: function (a, b, c) {
  13479. this._uniforms = [];
  13480. this._hashForUniforms = [];
  13481. this._glContext = c || cc._renderContext;
  13482. a && b && this.init(a, b)
  13483. },
  13484. destroyProgram: function () {
  13485. this._hashForUniforms = this._uniforms = this._fragShader = this._vertShader = null;
  13486. this._glContext.deleteProgram(this._programObj)
  13487. },
  13488. initWithVertexShaderByteArray: function (a, b) {
  13489. var c = this._glContext;
  13490. this._programObj = c.createProgram();
  13491. this._fragShader = this._vertShader = null;
  13492. 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"));
  13493. b && (this._fragShader = c.createShader(c.FRAGMENT_SHADER), this._compileShader(this._fragShader, c.FRAGMENT_SHADER, b) || cc.log("cocos2d: ERROR: Failed to compile fragment shader"));
  13494. this._vertShader && c.attachShader(this._programObj, this._vertShader);
  13495. cc.checkGLErrorDebug();
  13496. this._fragShader && c.attachShader(this._programObj, this._fragShader);
  13497. this._hashForUniforms.length = 0;
  13498. cc.checkGLErrorDebug();
  13499. return !0
  13500. },
  13501. initWithString: function (a, b) {
  13502. return this.initWithVertexShaderByteArray(a, b)
  13503. },
  13504. initWithVertexShaderFilename: function (a, b) {
  13505. var c = cc.loader.getRes(a);
  13506. if (!c) throw "Please load the resource firset : " + a;
  13507. var d = cc.loader.getRes(b);
  13508. if (!d) throw "Please load the resource firset : " + b;
  13509. return this.initWithVertexShaderByteArray(c, d)
  13510. },
  13511. init: function (a, b) {
  13512. return this.initWithVertexShaderFilename(a, b)
  13513. },
  13514. addAttribute: function (a, b) {
  13515. this._glContext.bindAttribLocation(this._programObj, b, a)
  13516. },
  13517. link: function () {
  13518. if (!this._programObj) return cc.log("cc.GLProgram.link(): Cannot link invalid program"),
  13519. !1;
  13520. this._glContext.linkProgram(this._programObj);
  13521. this._vertShader && this._glContext.deleteShader(this._vertShader);
  13522. this._fragShader && this._glContext.deleteShader(this._fragShader);
  13523. this._fragShader = this._vertShader = null;
  13524. 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
  13525. },
  13526. use: function () {
  13527. cc.glUseProgram(this._programObj)
  13528. },
  13529. updateUniforms: function () {
  13530. this._uniforms[cc.UNIFORM_PMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_PMATRIX_S);
  13531. this._uniforms[cc.UNIFORM_MVMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVMATRIX_S);
  13532. this._uniforms[cc.UNIFORM_MVPMATRIX] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_MVPMATRIX_S);
  13533. this._uniforms[cc.UNIFORM_TIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_TIME_S);
  13534. this._uniforms[cc.UNIFORM_SINTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SINTIME_S);
  13535. this._uniforms[cc.UNIFORM_COSTIME] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_COSTIME_S);
  13536. this._usesTime = null != this._uniforms[cc.UNIFORM_TIME] || null != this._uniforms[cc.UNIFORM_SINTIME] || null != this._uniforms[cc.UNIFORM_COSTIME];
  13537. this._uniforms[cc.UNIFORM_RANDOM01] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_RANDOM01_S);
  13538. this._uniforms[cc.UNIFORM_SAMPLER] = this._glContext.getUniformLocation(this._programObj, cc.UNIFORM_SAMPLER_S);
  13539. this.use();
  13540. this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER], 0)
  13541. },
  13542. getUniformLocationForName: function (a) {
  13543. if (!a) throw "cc.GLProgram.getUniformLocationForName(): uniform name should be non-null";
  13544. if (!this._programObj) throw "cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized";
  13545. return this._glContext.getUniformLocation(this._programObj, a)
  13546. },
  13547. getUniformMVPMatrix: function () {
  13548. return this._uniforms[cc.UNIFORM_MVPMATRIX]
  13549. },
  13550. getUniformSampler: function () {
  13551. return this._uniforms[cc.UNIFORM_SAMPLER]
  13552. },
  13553. setUniformLocationWith1i: function (a, b) {
  13554. this._updateUniformLocation(a, b) && this._glContext.uniform1i(a, b)
  13555. },
  13556. setUniformLocationWith2i: function (a, b, c) {
  13557. this._updateUniformLocation(a, [b, c]) && this._glContext.uniform2i(a, b, c)
  13558. },
  13559. setUniformLocationWith3i: function (a, b, c, d) {
  13560. this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3i(a, b, c, d)
  13561. },
  13562. setUniformLocationWith4i: function (a, b, c, d, e) {
  13563. this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4i(a, b, c, d, e)
  13564. },
  13565. setUniformLocationWith2iv: function (a, b, c) {
  13566. this._updateUniformLocation(a, b) && this._glContext.uniform2iv(a, b)
  13567. },
  13568. setUniformLocationWith3iv: function (a, b, c) {
  13569. this._updateUniformLocation(a, b) && this._glContext.uniform3iv(a, b)
  13570. },
  13571. setUniformLocationWith4iv: function (a, b, c) {
  13572. this._updateUniformLocation(a, b) && this._glContext.uniform4iv(a, b)
  13573. },
  13574. setUniformLocationI32: function (a, b) {
  13575. this.setUniformLocationWith1i(a, b)
  13576. },
  13577. setUniformLocationWith1f: function (a, b) {
  13578. this._updateUniformLocation(a, b) && this._glContext.uniform1f(a, b)
  13579. },
  13580. setUniformLocationWith2f: function (a, b, c) {
  13581. this._updateUniformLocation(a, [b, c]) && this._glContext.uniform2f(a, b, c)
  13582. },
  13583. setUniformLocationWith3f: function (a, b, c, d) {
  13584. this._updateUniformLocation(a, [b, c, d]) && this._glContext.uniform3f(a, b, c, d)
  13585. },
  13586. setUniformLocationWith4f: function (a, b, c, d, e) {
  13587. this._updateUniformLocation(a, [b, c, d, e]) && this._glContext.uniform4f(a, b, c, d, e)
  13588. },
  13589. setUniformLocationWith2fv: function (a, b, c) {
  13590. this._updateUniformLocation(a, b) && this._glContext.uniform2fv(a, b)
  13591. },
  13592. setUniformLocationWith3fv: function (a, b, c) {
  13593. this._updateUniformLocation(a, b) && this._glContext.uniform3fv(a, b)
  13594. },
  13595. setUniformLocationWith4fv: function (a, b, c) {
  13596. this._updateUniformLocation(a, b) && this._glContext.uniform4fv(a, b)
  13597. },
  13598. setUniformLocationWithMatrix4fv: function (a, b, c) {
  13599. this._updateUniformLocation(a, b) && this._glContext.uniformMatrix4fv(a, !1, b)
  13600. },
  13601. setUniformLocationF32: function () {
  13602. if (!(2 > arguments.length)) switch (arguments.length) {
  13603. case 2:
  13604. this.setUniformLocationWith1f(arguments[0], arguments[1]);
  13605. break;
  13606. case 3:
  13607. this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]);
  13608. break;
  13609. case 4:
  13610. this.setUniformLocationWith3f(arguments[0], arguments[1], arguments[2], arguments[3]);
  13611. break;
  13612. case 5:
  13613. this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
  13614. }
  13615. },
  13616. setUniformsForBuiltins: function () {
  13617. var a = new cc.kmMat4,
  13618. b = new cc.kmMat4,
  13619. c = new cc.kmMat4;
  13620. cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, a);
  13621. cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW, b);
  13622. cc.kmMat4Multiply(c, a, b);
  13623. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], a.mat, 1);
  13624. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], b.mat, 1);
  13625. this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], c.mat, 1);
  13626. 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())
  13627. },
  13628. setUniformForModelViewProjectionMatrix: function () {
  13629. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, cc.getMat4MultiplyValue(cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top))
  13630. },
  13631. setUniformForModelViewProjectionMatrixWithMat4: function (a) {
  13632. cc.kmMat4Multiply(a, cc.projection_matrix_stack.top, cc.modelview_matrix_stack.top);
  13633. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX], !1, a.mat)
  13634. },
  13635. setUniformForModelViewAndProjectionMatrixWithMat4: function () {
  13636. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX], !1, cc.modelview_matrix_stack.top.mat);
  13637. this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX], !1, cc.projection_matrix_stack.top.mat)
  13638. },
  13639. vertexShaderLog: function () {
  13640. return this._glContext.getShaderInfoLog(this._vertShader)
  13641. },
  13642. getVertexShaderLog: function () {
  13643. return this._glContext.getShaderInfoLog(this._vertShader)
  13644. },
  13645. getFragmentShaderLog: function () {
  13646. return this._glContext.getShaderInfoLog(this._vertShader)
  13647. },
  13648. fragmentShaderLog: function () {
  13649. return this._glContext.getShaderInfoLog(this._fragShader)
  13650. },
  13651. programLog: function () {
  13652. return this._glContext.getProgramInfoLog(this._programObj)
  13653. },
  13654. getProgramLog: function () {
  13655. return this._glContext.getProgramInfoLog(this._programObj)
  13656. },
  13657. reset: function () {
  13658. this._fragShader = this._vertShader = null;
  13659. this._uniforms.length = 0;
  13660. this._glContext.deleteProgram(this._programObj);
  13661. this._programObj = null;
  13662. for (var a = 0; a < this._hashForUniforms.length; a++) this._hashForUniforms[a].value = null,
  13663. this._hashForUniforms[a] = null;
  13664. this._hashForUniforms.length = 0
  13665. },
  13666. getProgram: function () {
  13667. return this._programObj
  13668. },
  13669. retain: function () { },
  13670. release: function () { }
  13671. });
  13672. cc.GLProgram.create = function (a, b) {
  13673. return new cc.GLProgram(a, b)
  13674. };
  13675. cc._currentProjectionMatrix = -1;
  13676. cc._vertexAttribPosition = !1;
  13677. cc._vertexAttribColor = !1;
  13678. cc._vertexAttribTexCoords = !1;
  13679. 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));
  13680. cc.glInvalidateStateCache = function () {
  13681. cc.kmGLFreeAll();
  13682. cc._currentProjectionMatrix = -1;
  13683. cc._vertexAttribPosition = !1;
  13684. cc._vertexAttribColor = !1;
  13685. cc._vertexAttribTexCoords = !1;
  13686. if (cc.ENABLE_GL_STATE_CACHE) {
  13687. cc._currentShaderProgram = -1;
  13688. for (var a = 0; a < cc.MAX_ACTIVETEXTURE; a++) cc._currentBoundTexture[a] = -1;
  13689. cc._blendingSource = -1;
  13690. cc._blendingDest = -1;
  13691. cc._GLServerState = 0
  13692. }
  13693. };
  13694. cc.glUseProgram = function (a) {
  13695. a !== cc._currentShaderProgram && (cc._currentShaderProgram = a, cc._renderContext.useProgram(a))
  13696. };
  13697. cc.ENABLE_GL_STATE_CACHE || (cc.glUseProgram = function (a) {
  13698. cc._renderContext.useProgram(a)
  13699. });
  13700. cc.glDeleteProgram = function (a) {
  13701. cc.ENABLE_GL_STATE_CACHE && a === cc._currentShaderProgram && (cc._currentShaderProgram = -1);
  13702. gl.deleteProgram(a)
  13703. };
  13704. cc.glBlendFunc = function (a, b) {
  13705. if (a !== cc._blendingSource || b !== cc._blendingDest) cc._blendingSource = a,
  13706. cc._blendingDest = b,
  13707. cc.setBlending(a, b)
  13708. };
  13709. cc.setBlending = function (a, b) {
  13710. var c = cc._renderContext;
  13711. a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), cc._renderContext.blendFunc(a, b))
  13712. };
  13713. cc.glBlendFuncForParticle = function (a, b) {
  13714. if (a !== cc._blendingSource || b !== cc._blendingDest) {
  13715. cc._blendingSource = a;
  13716. cc._blendingDest = b;
  13717. var c = cc._renderContext;
  13718. a === c.ONE && b === c.ZERO ? c.disable(c.BLEND) : (c.enable(c.BLEND), c.blendFuncSeparate(c.SRC_ALPHA, b, a, b))
  13719. }
  13720. };
  13721. cc.ENABLE_GL_STATE_CACHE || (cc.glBlendFunc = cc.setBlending);
  13722. cc.glBlendResetToCache = function () {
  13723. var a = cc._renderContext;
  13724. a.blendEquation(a.FUNC_ADD);
  13725. cc.ENABLE_GL_STATE_CACHE ? cc.setBlending(cc._blendingSource, cc._blendingDest) : cc.setBlending(a.BLEND_SRC, a.BLEND_DST)
  13726. };
  13727. cc.setProjectionMatrixDirty = function () {
  13728. cc._currentProjectionMatrix = -1
  13729. };
  13730. cc.glEnableVertexAttribs = function (a) {
  13731. var b = cc._renderContext,
  13732. c = a & cc.VERTEX_ATTRIB_FLAG_POSITION;
  13733. c !== cc._vertexAttribPosition && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_POSITION), cc._vertexAttribPosition = c);
  13734. c = a & cc.VERTEX_ATTRIB_FLAG_COLOR;
  13735. c !== cc._vertexAttribColor && (c ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_COLOR), cc._vertexAttribColor = c);
  13736. a &= cc.VERTEX_ATTRIB_FLAG_TEX_COORDS;
  13737. a !== cc._vertexAttribTexCoords && (a ? b.enableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS) : b.disableVertexAttribArray(cc.VERTEX_ATTRIB_TEX_COORDS), cc._vertexAttribTexCoords = a)
  13738. };
  13739. cc.glBindTexture2D = function (a) {
  13740. cc.glBindTexture2DN(0, a)
  13741. };
  13742. cc.glBindTexture2DN = function (a, b) {
  13743. if (cc._currentBoundTexture[a] != b) {
  13744. cc._currentBoundTexture[a] = b;
  13745. var c = cc._renderContext;
  13746. c.activeTexture(c.TEXTURE0 + a);
  13747. b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null)
  13748. }
  13749. };
  13750. cc.ENABLE_GL_STATE_CACHE || (cc.glBindTexture2DN = function (a, b) {
  13751. var c = cc._renderContext;
  13752. c.activeTexture(c.TEXTURE0 + a);
  13753. b ? c.bindTexture(c.TEXTURE_2D, b._webTextureObj) : c.bindTexture(c.TEXTURE_2D, null)
  13754. });
  13755. cc.glDeleteTexture = function (a) {
  13756. cc.glDeleteTextureN(0, a)
  13757. };
  13758. cc.glDeleteTextureN = function (a, b) {
  13759. cc.ENABLE_GL_STATE_CACHE && b == cc._currentBoundTexture[a] && (cc._currentBoundTexture[a] = -1);
  13760. cc._renderContext.deleteTexture(b)
  13761. };
  13762. cc.glBindVAO = function (a) {
  13763. cc.TEXTURE_ATLAS_USE_VAO && cc.ENABLE_GL_STATE_CACHE && cc._uVAO != a && (cc._uVAO = a)
  13764. };
  13765. cc.glEnable = function (a) { };
  13766. cc.ACTION_TAG_INVALID = -1;
  13767. cc.Action = cc.Class.extend({
  13768. originalTarget: null,
  13769. target: null,
  13770. tag: cc.ACTION_TAG_INVALID,
  13771. ctor: function () {
  13772. this.target = this.originalTarget = null;
  13773. this.tag = cc.ACTION_TAG_INVALID
  13774. },
  13775. copy: function () {
  13776. cc.log("copy is deprecated. Please use clone instead.");
  13777. return this.clone()
  13778. },
  13779. clone: function () {
  13780. var a = new cc.Action;
  13781. a.originalTarget = null;
  13782. a.target = null;
  13783. a.tag = this.tag;
  13784. return a
  13785. },
  13786. isDone: function () {
  13787. return !0
  13788. },
  13789. startWithTarget: function (a) {
  13790. this.target = this.originalTarget = a
  13791. },
  13792. stop: function () {
  13793. this.target = null
  13794. },
  13795. step: function (a) {
  13796. cc.log("[Action step]. override me")
  13797. },
  13798. update: function (a) {
  13799. cc.log("[Action update]. override me")
  13800. },
  13801. getTarget: function () {
  13802. return this.target
  13803. },
  13804. setTarget: function (a) {
  13805. this.target = a
  13806. },
  13807. getOriginalTarget: function () {
  13808. return this.originalTarget
  13809. },
  13810. setOriginalTarget: function (a) {
  13811. this.originalTarget = a
  13812. },
  13813. getTag: function () {
  13814. return this.tag
  13815. },
  13816. setTag: function (a) {
  13817. this.tag = a
  13818. },
  13819. retain: function () { },
  13820. release: function () { }
  13821. });
  13822. cc.action = function () {
  13823. return new cc.Action
  13824. };
  13825. cc.Action.create = cc.action;
  13826. cc.FiniteTimeAction = cc.Action.extend({
  13827. _duration: 0,
  13828. ctor: function () {
  13829. cc.Action.prototype.ctor.call(this);
  13830. this._duration = 0
  13831. },
  13832. getDuration: function () {
  13833. return this._duration * (this._times || 1)
  13834. },
  13835. setDuration: function (a) {
  13836. this._duration = a
  13837. },
  13838. reverse: function () {
  13839. cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");
  13840. return null
  13841. },
  13842. clone: function () {
  13843. return new cc.FiniteTimeAction
  13844. }
  13845. });
  13846. cc.Speed = cc.Action.extend({
  13847. _speed: 0,
  13848. _innerAction: null,
  13849. ctor: function (a, b) {
  13850. cc.Action.prototype.ctor.call(this);
  13851. this._speed = 0;
  13852. this._innerAction = null;
  13853. a && this.initWithAction(a, b)
  13854. },
  13855. getSpeed: function () {
  13856. return this._speed
  13857. },
  13858. setSpeed: function (a) {
  13859. this._speed = a
  13860. },
  13861. initWithAction: function (a, b) {
  13862. if (!a) throw "cc.Speed.initWithAction(): action must be non nil";
  13863. this._innerAction = a;
  13864. this._speed = b;
  13865. return !0
  13866. },
  13867. clone: function () {
  13868. var a = new cc.Speed;
  13869. a.initWithAction(this._innerAction.clone(), this._speed);
  13870. return a
  13871. },
  13872. startWithTarget: function (a) {
  13873. cc.Action.prototype.startWithTarget.call(this, a);
  13874. this._innerAction.startWithTarget(a)
  13875. },
  13876. stop: function () {
  13877. this._innerAction.stop();
  13878. cc.Action.prototype.stop.call(this)
  13879. },
  13880. step: function (a) {
  13881. this._innerAction.step(a * this._speed)
  13882. },
  13883. isDone: function () {
  13884. return this._innerAction.isDone()
  13885. },
  13886. reverse: function () {
  13887. return new cc.Speed(this._innerAction.reverse(), this._speed)
  13888. },
  13889. setInnerAction: function (a) {
  13890. this._innerAction != a && (this._innerAction = a)
  13891. },
  13892. getInnerAction: function () {
  13893. return this._innerAction
  13894. }
  13895. });
  13896. cc.speed = function (a, b) {
  13897. return new cc.Speed(a, b)
  13898. };
  13899. cc.Speed.create = cc.speed;
  13900. cc.Follow = cc.Action.extend({
  13901. _followedNode: null,
  13902. _boundarySet: !1,
  13903. _boundaryFullyCovered: !1,
  13904. _halfScreenSize: null,
  13905. _fullScreenSize: null,
  13906. _worldRect: null,
  13907. leftBoundary: 0,
  13908. rightBoundary: 0,
  13909. topBoundary: 0,
  13910. bottomBoundary: 0,
  13911. ctor: function (a, b) {
  13912. cc.Action.prototype.ctor.call(this);
  13913. this._followedNode = null;
  13914. this._boundaryFullyCovered = this._boundarySet = !1;
  13915. this._fullScreenSize = this._halfScreenSize = null;
  13916. this.bottomBoundary = this.topBoundary = this.rightBoundary = this.leftBoundary = 0;
  13917. this._worldRect = cc.rect(0, 0, 0, 0);
  13918. a && (b ? this.initWithTarget(a, b) : this.initWithTarget(a))
  13919. },
  13920. clone: function () {
  13921. var a = new cc.Follow,
  13922. b = this._worldRect,
  13923. b = new cc.Rect(b.x, b.y, b.width, b.height);
  13924. a.initWithTarget(this._followedNode, b);
  13925. return a
  13926. },
  13927. isBoundarySet: function () {
  13928. return this._boundarySet
  13929. },
  13930. setBoudarySet: function (a) {
  13931. this._boundarySet = a
  13932. },
  13933. initWithTarget: function (a, b) {
  13934. if (!a) throw "cc.Follow.initWithAction(): followedNode must be non nil";
  13935. b = b || cc.rect(0, 0, 0, 0);
  13936. this._followedNode = a;
  13937. this._worldRect = b;
  13938. this._boundarySet = !cc._rectEqualToZero(b);
  13939. this._boundaryFullyCovered = !1;
  13940. var c = cc.director.getWinSize();
  13941. this._fullScreenSize = cc.p(c.width, c.height);
  13942. this._halfScreenSize = cc.pMult(this._fullScreenSize, 0.5);
  13943. 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 = (this.topBoundary + this.bottomBoundary) / 2), this.topBoundary == this.bottomBoundary && this.leftBoundary == this.rightBoundary && (this._boundaryFullyCovered = !0));
  13944. return !0
  13945. },
  13946. step: function (a) {
  13947. a = this._followedNode.x;
  13948. var b = this._followedNode.y;
  13949. a = this._halfScreenSize.x - a;
  13950. b = this._halfScreenSize.y - b;
  13951. 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, b)
  13952. },
  13953. isDone: function () {
  13954. return !this._followedNode.running
  13955. },
  13956. stop: function () {
  13957. this.target = null;
  13958. cc.Action.prototype.stop.call(this)
  13959. }
  13960. });
  13961. cc.follow = function (a, b) {
  13962. return new cc.Follow(a, b)
  13963. };
  13964. cc.Follow.create = cc.follow;
  13965. cc.ActionInterval = cc.FiniteTimeAction.extend({
  13966. _elapsed: 0,
  13967. _firstTick: !1,
  13968. _easeList: null,
  13969. _times: 1,
  13970. _repeatForever: !1,
  13971. _repeatMethod: !1,
  13972. _speed: 1,
  13973. _speedMethod: !1,
  13974. ctor: function (a) {
  13975. this._times = this._speed = 1;
  13976. this._repeatForever = !1;
  13977. this.MAX_VALUE = 2;
  13978. this._speedMethod = this._repeatMethod = !1;
  13979. cc.FiniteTimeAction.prototype.ctor.call(this);
  13980. void 0 !== a && this.initWithDuration(a)
  13981. },
  13982. getElapsed: function () {
  13983. return this._elapsed
  13984. },
  13985. initWithDuration: function (a) {
  13986. this._duration = 0 === a ? cc.FLT_EPSILON : a;
  13987. this._elapsed = 0;
  13988. return this._firstTick = !0
  13989. },
  13990. isDone: function () {
  13991. return this._elapsed >= this._duration
  13992. },
  13993. _cloneDecoration: function (a) {
  13994. a._repeatForever = this._repeatForever;
  13995. a._speed = this._speed;
  13996. a._times = this._times;
  13997. a._easeList = this._easeList;
  13998. a._speedMethod = this._speedMethod;
  13999. a._repeatMethod = this._repeatMethod
  14000. },
  14001. _reverseEaseList: function (a) {
  14002. if (this._easeList) {
  14003. a._easeList = [];
  14004. for (var b = 0; b < this._easeList.length; b++) a._easeList.push(this._easeList[b].reverse())
  14005. }
  14006. },
  14007. clone: function () {
  14008. var a = new cc.ActionInterval(this._duration);
  14009. this._cloneDecoration(a);
  14010. return a
  14011. },
  14012. easing: function (a) {
  14013. this._easeList ? this._easeList.length = 0 : this._easeList = [];
  14014. for (var b = 0; b < arguments.length; b++) this._easeList.push(arguments[b]);
  14015. return this
  14016. },
  14017. _computeEaseTime: function (a) {
  14018. var b = this._easeList;
  14019. if (!b || 0 === b.length) return a;
  14020. for (var c = 0, d = b.length; c < d; c++) a = b[c].easing(a);
  14021. return a
  14022. },
  14023. step: function (a) {
  14024. this._firstTick ? (this._firstTick = !1, this._elapsed = 0) : this._elapsed += a;
  14025. a = this._elapsed / (1.192092896E-7 < this._duration ? this._duration : 1.192092896E-7);
  14026. a = 1 > a ? a : 1;
  14027. this.update(0 < a ? a : 0);
  14028. this._repeatMethod && 1 < this._times && this.isDone() && (this._repeatForever || this._times--, this.startWithTarget(this.target), this.step(this._elapsed - this._duration))
  14029. },
  14030. startWithTarget: function (a) {
  14031. cc.Action.prototype.startWithTarget.call(this, a);
  14032. this._elapsed = 0;
  14033. this._firstTick = !0
  14034. },
  14035. reverse: function () {
  14036. cc.log("cc.IntervalAction: reverse not implemented.");
  14037. return null
  14038. },
  14039. setAmplitudeRate: function (a) {
  14040. cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")
  14041. },
  14042. getAmplitudeRate: function () {
  14043. cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
  14044. return 0
  14045. },
  14046. speed: function (a) {
  14047. if (0 >= a) return cc.log("The speed parameter error"),
  14048. this;
  14049. this._speedMethod = !0;
  14050. this._speed *= a;
  14051. return this
  14052. },
  14053. getSpeed: function () {
  14054. return this._speed
  14055. },
  14056. setSpeed: function (a) {
  14057. this._speed = a;
  14058. return this
  14059. },
  14060. repeat: function (a) {
  14061. a = Math.round(a);
  14062. if (isNaN(a) || 1 > a) return cc.log("The repeat parameter error"),
  14063. this;
  14064. this._repeatMethod = !0;
  14065. this._times *= a;
  14066. return this
  14067. },
  14068. repeatForever: function () {
  14069. this._repeatMethod = !0;
  14070. this._times = this.MAX_VALUE;
  14071. this._repeatForever = !0;
  14072. return this
  14073. }
  14074. });
  14075. cc.actionInterval = function (a) {
  14076. return new cc.ActionInterval(a)
  14077. };
  14078. cc.ActionInterval.create = cc.actionInterval;
  14079. cc.Sequence = cc.ActionInterval.extend({
  14080. _actions: null,
  14081. _split: null,
  14082. _last: 0,
  14083. ctor: function (a) {
  14084. cc.ActionInterval.prototype.ctor.call(this);
  14085. this._actions = [];
  14086. var b = a instanceof Array ? a : arguments,
  14087. c = b.length - 1;
  14088. 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript");
  14089. if (0 <= c) {
  14090. for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Sequence._actionOneTwo(d, b[e]));
  14091. this.initWithTwoActions(d, b[c])
  14092. }
  14093. },
  14094. initWithTwoActions: function (a, b) {
  14095. if (!a || !b) throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil";
  14096. this.initWithDuration(a._duration + b._duration);
  14097. this._actions[0] = a;
  14098. this._actions[1] = b;
  14099. return !0
  14100. },
  14101. clone: function () {
  14102. var a = new cc.Sequence;
  14103. this._cloneDecoration(a);
  14104. a.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
  14105. return a
  14106. },
  14107. startWithTarget: function (a) {
  14108. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14109. this._split = this._actions[0]._duration / this._duration;
  14110. this._last = -1
  14111. },
  14112. stop: function () {
  14113. -1 !== this._last && this._actions[this._last].stop();
  14114. cc.Action.prototype.stop.call(this)
  14115. },
  14116. update: function (a) {
  14117. a = this._computeEaseTime(a);
  14118. var b = 0,
  14119. c = this._split,
  14120. d = this._actions,
  14121. e = this._last;
  14122. 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()));
  14123. e === b && d[b].isDone() || (e !== b && d[b].startWithTarget(this.target), d[b].update(a), this._last = b)
  14124. },
  14125. reverse: function () {
  14126. var a = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
  14127. this._cloneDecoration(a);
  14128. this._reverseEaseList(a);
  14129. return a
  14130. }
  14131. });
  14132. cc.sequence = function (a) {
  14133. var b = a instanceof Array ? a : arguments;
  14134. 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  14135. for (var c = b[0], d = 1; d < b.length; d++) b[d] && (c = cc.Sequence._actionOneTwo(c, b[d]));
  14136. return c
  14137. };
  14138. cc.Sequence.create = cc.sequence;
  14139. cc.Sequence._actionOneTwo = function (a, b) {
  14140. var c = new cc.Sequence;
  14141. c.initWithTwoActions(a, b);
  14142. return c
  14143. };
  14144. cc.Repeat = cc.ActionInterval.extend({
  14145. _times: 0,
  14146. _total: 0,
  14147. _nextDt: 0,
  14148. _actionInstant: !1,
  14149. _innerAction: null,
  14150. ctor: function (a, b) {
  14151. cc.ActionInterval.prototype.ctor.call(this);
  14152. void 0 !== b && this.initWithAction(a, b)
  14153. },
  14154. initWithAction: function (a, b) {
  14155. 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
  14156. },
  14157. clone: function () {
  14158. var a = new cc.Repeat;
  14159. this._cloneDecoration(a);
  14160. a.initWithAction(this._innerAction.clone(), this._times);
  14161. return a
  14162. },
  14163. startWithTarget: function (a) {
  14164. this._total = 0;
  14165. this._nextDt = this._innerAction._duration / this._duration;
  14166. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14167. this._innerAction.startWithTarget(a)
  14168. },
  14169. stop: function () {
  14170. this._innerAction.stop();
  14171. cc.Action.prototype.stop.call(this)
  14172. },
  14173. update: function (a) {
  14174. a = this._computeEaseTime(a);
  14175. var b = this._innerAction,
  14176. c = this._duration,
  14177. d = this._times,
  14178. e = this._nextDt;
  14179. if (a >= e) {
  14180. for (; a > e && this._total < d;) b.update(1),
  14181. this._total++,
  14182. b.stop(),
  14183. b.startWithTarget(this.target),
  14184. this._nextDt = e += b._duration / c;
  14185. 1 <= a && this._total < d && this._total++;
  14186. this._actionInstant || (this._total === d ? (b.update(1), b.stop()) : b.update(a - (e - b._duration / c)))
  14187. } else b.update(a * d % 1)
  14188. },
  14189. isDone: function () {
  14190. return this._total == this._times
  14191. },
  14192. reverse: function () {
  14193. var a = new cc.Repeat(this._innerAction.reverse(), this._times);
  14194. this._cloneDecoration(a);
  14195. this._reverseEaseList(a);
  14196. return a
  14197. },
  14198. setInnerAction: function (a) {
  14199. this._innerAction != a && (this._innerAction = a)
  14200. },
  14201. getInnerAction: function () {
  14202. return this._innerAction
  14203. }
  14204. });
  14205. cc.repeat = function (a, b) {
  14206. return new cc.Repeat(a, b)
  14207. };
  14208. cc.Repeat.create = cc.repeat;
  14209. cc.RepeatForever = cc.ActionInterval.extend({
  14210. _innerAction: null,
  14211. ctor: function (a) {
  14212. cc.ActionInterval.prototype.ctor.call(this);
  14213. this._innerAction = null;
  14214. a && this.initWithAction(a)
  14215. },
  14216. initWithAction: function (a) {
  14217. if (!a) throw "cc.RepeatForever.initWithAction(): action must be non null";
  14218. this._innerAction = a;
  14219. return !0
  14220. },
  14221. clone: function () {
  14222. var a = new cc.RepeatForever;
  14223. this._cloneDecoration(a);
  14224. a.initWithAction(this._innerAction.clone());
  14225. return a
  14226. },
  14227. startWithTarget: function (a) {
  14228. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14229. this._innerAction.startWithTarget(a)
  14230. },
  14231. step: function (a) {
  14232. var b = this._innerAction;
  14233. b.step(a);
  14234. b.isDone() && (b.startWithTarget(this.target), b.step(b.getElapsed() - b._duration))
  14235. },
  14236. isDone: function () {
  14237. return !1
  14238. },
  14239. reverse: function () {
  14240. var a = new cc.RepeatForever(this._innerAction.reverse());
  14241. this._cloneDecoration(a);
  14242. this._reverseEaseList(a);
  14243. return a
  14244. },
  14245. setInnerAction: function (a) {
  14246. this._innerAction != a && (this._innerAction = a)
  14247. },
  14248. getInnerAction: function () {
  14249. return this._innerAction
  14250. }
  14251. });
  14252. cc.repeatForever = function (a) {
  14253. return new cc.RepeatForever(a)
  14254. };
  14255. cc.RepeatForever.create = cc.repeatForever;
  14256. cc.Spawn = cc.ActionInterval.extend({
  14257. _one: null,
  14258. _two: null,
  14259. ctor: function (a) {
  14260. cc.ActionInterval.prototype.ctor.call(this);
  14261. this._two = this._one = null;
  14262. var b = a instanceof Array ? a : arguments,
  14263. c = b.length - 1;
  14264. 0 <= c && null == b[c] && cc.log("parameters should not be ending with null in Javascript");
  14265. if (0 <= c) {
  14266. for (var d = b[0], e = 1; e < c; e++) b[e] && (d = cc.Spawn._actionOneTwo(d, b[e]));
  14267. this.initWithTwoActions(d, b[c])
  14268. }
  14269. },
  14270. initWithTwoActions: function (a, b) {
  14271. if (!a || !b) throw "cc.Spawn.initWithTwoActions(): arguments must all be non null";
  14272. var c = !1,
  14273. d = a._duration,
  14274. e = b._duration;
  14275. 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);
  14276. return c
  14277. },
  14278. clone: function () {
  14279. var a = new cc.Spawn;
  14280. this._cloneDecoration(a);
  14281. a.initWithTwoActions(this._one.clone(), this._two.clone());
  14282. return a
  14283. },
  14284. startWithTarget: function (a) {
  14285. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14286. this._one.startWithTarget(a);
  14287. this._two.startWithTarget(a)
  14288. },
  14289. stop: function () {
  14290. this._one.stop();
  14291. this._two.stop();
  14292. cc.Action.prototype.stop.call(this)
  14293. },
  14294. update: function (a) {
  14295. a = this._computeEaseTime(a);
  14296. this._one && this._one.update(a);
  14297. this._two && this._two.update(a)
  14298. },
  14299. reverse: function () {
  14300. var a = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
  14301. this._cloneDecoration(a);
  14302. this._reverseEaseList(a);
  14303. return a
  14304. }
  14305. });
  14306. cc.spawn = function (a) {
  14307. var b = a instanceof Array ? a : arguments;
  14308. 0 < b.length && null == b[b.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  14309. for (var c = b[0], d = 1; d < b.length; d++) null != b[d] && (c = cc.Spawn._actionOneTwo(c, b[d]));
  14310. return c
  14311. };
  14312. cc.Spawn.create = cc.spawn;
  14313. cc.Spawn._actionOneTwo = function (a, b) {
  14314. var c = new cc.Spawn;
  14315. c.initWithTwoActions(a, b);
  14316. return c
  14317. };
  14318. cc.RotateTo = cc.ActionInterval.extend({
  14319. _dstAngleX: 0,
  14320. _startAngleX: 0,
  14321. _diffAngleX: 0,
  14322. _dstAngleY: 0,
  14323. _startAngleY: 0,
  14324. _diffAngleY: 0,
  14325. ctor: function (a, b, c) {
  14326. cc.ActionInterval.prototype.ctor.call(this);
  14327. void 0 !== b && this.initWithDuration(a, b, c)
  14328. },
  14329. initWithDuration: function (a, b, c) {
  14330. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._dstAngleX = b || 0, this._dstAngleY = c || this._dstAngleX, !0) : !1
  14331. },
  14332. clone: function () {
  14333. var a = new cc.RotateTo;
  14334. this._cloneDecoration(a);
  14335. a.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
  14336. return a
  14337. },
  14338. startWithTarget: function (a) {
  14339. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14340. var b = a.rotationX % 360,
  14341. c = this._dstAngleX - b;
  14342. 180 < c && (c -= 360); -180 > c && (c += 360);
  14343. this._startAngleX = b;
  14344. this._diffAngleX = c;
  14345. this._startAngleY = a.rotationY % 360;
  14346. a = this._dstAngleY - this._startAngleY;
  14347. 180 < a && (a -= 360); -180 > a && (a += 360);
  14348. this._diffAngleY = a
  14349. },
  14350. reverse: function () {
  14351. cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")
  14352. },
  14353. update: function (a) {
  14354. a = this._computeEaseTime(a);
  14355. this.target && (this.target.rotationX = this._startAngleX + this._diffAngleX * a, this.target.rotationY = this._startAngleY + this._diffAngleY * a)
  14356. }
  14357. });
  14358. cc.rotateTo = function (a, b, c) {
  14359. return new cc.RotateTo(a, b, c)
  14360. };
  14361. cc.RotateTo.create = cc.rotateTo;
  14362. cc.RotateBy = cc.ActionInterval.extend({
  14363. _angleX: 0,
  14364. _startAngleX: 0,
  14365. _angleY: 0,
  14366. _startAngleY: 0,
  14367. ctor: function (a, b, c) {
  14368. cc.ActionInterval.prototype.ctor.call(this);
  14369. void 0 !== b && this.initWithDuration(a, b, c)
  14370. },
  14371. initWithDuration: function (a, b, c) {
  14372. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._angleX = b || 0, this._angleY = c || this._angleX, !0) : !1
  14373. },
  14374. clone: function () {
  14375. var a = new cc.RotateBy;
  14376. this._cloneDecoration(a);
  14377. a.initWithDuration(this._duration, this._angleX, this._angleY);
  14378. return a
  14379. },
  14380. startWithTarget: function (a) {
  14381. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14382. this._startAngleX = a.rotationX;
  14383. this._startAngleY = a.rotationY
  14384. },
  14385. update: function (a) {
  14386. a = this._computeEaseTime(a);
  14387. this.target && (this.target.rotationX = this._startAngleX + this._angleX * a, this.target.rotationY = this._startAngleY + this._angleY * a)
  14388. },
  14389. reverse: function () {
  14390. var a = new cc.RotateBy(this._duration, -this._angleX, -this._angleY);
  14391. this._cloneDecoration(a);
  14392. this._reverseEaseList(a);
  14393. return a
  14394. }
  14395. });
  14396. cc.rotateBy = function (a, b, c) {
  14397. return new cc.RotateBy(a, b, c)
  14398. };
  14399. cc.RotateBy.create = cc.rotateBy;
  14400. cc.MoveBy = cc.ActionInterval.extend({
  14401. _positionDelta: null,
  14402. _startPosition: null,
  14403. _previousPosition: null,
  14404. ctor: function (a, b, c) {
  14405. cc.ActionInterval.prototype.ctor.call(this);
  14406. this._positionDelta = cc.p(0, 0);
  14407. this._startPosition = cc.p(0, 0);
  14408. this._previousPosition = cc.p(0, 0);
  14409. void 0 !== b && this.initWithDuration(a, b, c)
  14410. },
  14411. initWithDuration: function (a, b, c) {
  14412. 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
  14413. },
  14414. clone: function () {
  14415. var a = new cc.MoveBy;
  14416. this._cloneDecoration(a);
  14417. a.initWithDuration(this._duration, this._positionDelta);
  14418. return a
  14419. },
  14420. startWithTarget: function (a) {
  14421. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14422. var b = a.getPositionX();
  14423. a = a.getPositionY();
  14424. this._previousPosition.x = b;
  14425. this._previousPosition.y = a;
  14426. this._startPosition.x = b;
  14427. this._startPosition.y = a
  14428. },
  14429. update: function (a) {
  14430. a = this._computeEaseTime(a);
  14431. if (this.target) {
  14432. var b = this._positionDelta.x * a;
  14433. a *= this._positionDelta.y;
  14434. var c = this._startPosition;
  14435. if (cc.ENABLE_STACKABLE_ACTIONS) {
  14436. var d = this.target.getPositionX(),
  14437. e = this.target.getPositionY(),
  14438. f = this._previousPosition;
  14439. c.x = c.x + d - f.x;
  14440. c.y = c.y + e - f.y;
  14441. b += c.x;
  14442. a += c.y;
  14443. f.x = b;
  14444. f.y = a;
  14445. this.target.setPosition(b, a)
  14446. } else this.target.setPosition(c.x + b, c.y + a)
  14447. }
  14448. },
  14449. reverse: function () {
  14450. var a = new cc.MoveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
  14451. this._cloneDecoration(a);
  14452. this._reverseEaseList(a);
  14453. return a
  14454. }
  14455. });
  14456. cc.moveBy = function (a, b, c) {
  14457. return new cc.MoveBy(a, b, c)
  14458. };
  14459. cc.MoveBy.create = cc.moveBy;
  14460. cc.MoveTo = cc.MoveBy.extend({
  14461. _endPosition: null,
  14462. ctor: function (a, b, c) {
  14463. cc.MoveBy.prototype.ctor.call(this);
  14464. this._endPosition = cc.p(0, 0);
  14465. void 0 !== b && this.initWithDuration(a, b, c)
  14466. },
  14467. initWithDuration: function (a, b, c) {
  14468. 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
  14469. },
  14470. clone: function () {
  14471. var a = new cc.MoveTo;
  14472. this._cloneDecoration(a);
  14473. a.initWithDuration(this._duration, this._endPosition);
  14474. return a
  14475. },
  14476. startWithTarget: function (a) {
  14477. cc.MoveBy.prototype.startWithTarget.call(this, a);
  14478. this._positionDelta.x = this._endPosition.x - a.getPositionX();
  14479. this._positionDelta.y = this._endPosition.y - a.getPositionY()
  14480. }
  14481. });
  14482. cc.moveTo = function (a, b, c) {
  14483. return new cc.MoveTo(a, b, c)
  14484. };
  14485. cc.MoveTo.create = cc.moveTo;
  14486. cc.SkewTo = cc.ActionInterval.extend({
  14487. _skewX: 0,
  14488. _skewY: 0,
  14489. _startSkewX: 0,
  14490. _startSkewY: 0,
  14491. _endSkewX: 0,
  14492. _endSkewY: 0,
  14493. _deltaX: 0,
  14494. _deltaY: 0,
  14495. ctor: function (a, b, c) {
  14496. cc.ActionInterval.prototype.ctor.call(this);
  14497. void 0 !== c && this.initWithDuration(a, b, c)
  14498. },
  14499. initWithDuration: function (a, b, c) {
  14500. var d = !1;
  14501. cc.ActionInterval.prototype.initWithDuration.call(this, a) && (this._endSkewX = b, this._endSkewY = c, d = !0);
  14502. return d
  14503. },
  14504. clone: function () {
  14505. var a = new cc.SkewTo;
  14506. this._cloneDecoration(a);
  14507. a.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
  14508. return a
  14509. },
  14510. startWithTarget: function (a) {
  14511. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14512. this._startSkewX = a.skewX % 180;
  14513. this._deltaX = this._endSkewX - this._startSkewX;
  14514. 180 < this._deltaX && (this._deltaX -= 360); -180 > this._deltaX && (this._deltaX += 360);
  14515. this._startSkewY = a.skewY % 360;
  14516. this._deltaY = this._endSkewY - this._startSkewY;
  14517. 180 < this._deltaY && (this._deltaY -= 360); -180 > this._deltaY && (this._deltaY += 360)
  14518. },
  14519. update: function (a) {
  14520. a = this._computeEaseTime(a);
  14521. this.target.skewX = this._startSkewX + this._deltaX * a;
  14522. this.target.skewY = this._startSkewY + this._deltaY * a
  14523. }
  14524. });
  14525. cc.skewTo = function (a, b, c) {
  14526. return new cc.SkewTo(a, b, c)
  14527. };
  14528. cc.SkewTo.create = cc.skewTo;
  14529. cc.SkewBy = cc.SkewTo.extend({
  14530. ctor: function (a, b, c) {
  14531. cc.SkewTo.prototype.ctor.call(this);
  14532. void 0 !== c && this.initWithDuration(a, b, c)
  14533. },
  14534. initWithDuration: function (a, b, c) {
  14535. var d = !1;
  14536. cc.SkewTo.prototype.initWithDuration.call(this, a, b, c) && (this._skewX = b, this._skewY = c, d = !0);
  14537. return d
  14538. },
  14539. clone: function () {
  14540. var a = new cc.SkewBy;
  14541. this._cloneDecoration(a);
  14542. a.initWithDuration(this._duration, this._skewX, this._skewY);
  14543. return a
  14544. },
  14545. startWithTarget: function (a) {
  14546. cc.SkewTo.prototype.startWithTarget.call(this, a);
  14547. this._deltaX = this._skewX;
  14548. this._deltaY = this._skewY;
  14549. this._endSkewX = this._startSkewX + this._deltaX;
  14550. this._endSkewY = this._startSkewY + this._deltaY
  14551. },
  14552. reverse: function () {
  14553. var a = new cc.SkewBy(this._duration, -this._skewX, -this._skewY);
  14554. this._cloneDecoration(a);
  14555. this._reverseEaseList(a);
  14556. return a
  14557. }
  14558. });
  14559. cc.skewBy = function (a, b, c) {
  14560. return new cc.SkewBy(a, b, c)
  14561. };
  14562. cc.SkewBy.create = cc.skewBy;
  14563. cc.JumpBy = cc.ActionInterval.extend({
  14564. _startPosition: null,
  14565. _delta: null,
  14566. _height: 0,
  14567. _jumps: 0,
  14568. _previousPosition: null,
  14569. ctor: function (a, b, c, d, e) {
  14570. cc.ActionInterval.prototype.ctor.call(this);
  14571. this._startPosition = cc.p(0, 0);
  14572. this._previousPosition = cc.p(0, 0);
  14573. this._delta = cc.p(0, 0);
  14574. void 0 !== d && this.initWithDuration(a, b, c, d, e)
  14575. },
  14576. initWithDuration: function (a, b, c, d, e) {
  14577. 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 = e, !0) : !1
  14578. },
  14579. clone: function () {
  14580. var a = new cc.JumpBy;
  14581. this._cloneDecoration(a);
  14582. a.initWithDuration(this._duration, this._delta, this._height, this._jumps);
  14583. return a
  14584. },
  14585. startWithTarget: function (a) {
  14586. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14587. var b = a.getPositionX();
  14588. a = a.getPositionY();
  14589. this._previousPosition.x = b;
  14590. this._previousPosition.y = a;
  14591. this._startPosition.x = b;
  14592. this._startPosition.y = a
  14593. },
  14594. update: function (a) {
  14595. a = this._computeEaseTime(a);
  14596. if (this.target) {
  14597. var b = a * this._jumps % 1,
  14598. b = 4 * this._height * b * (1 - b),
  14599. b = b + this._delta.y * a;
  14600. a *= this._delta.x;
  14601. var c = this._startPosition;
  14602. if (cc.ENABLE_STACKABLE_ACTIONS) {
  14603. var d = this.target.getPositionX(),
  14604. e = this.target.getPositionY(),
  14605. f = this._previousPosition;
  14606. c.x = c.x + d - f.x;
  14607. c.y = c.y + e - f.y;
  14608. a += c.x;
  14609. b += c.y;
  14610. f.x = a;
  14611. f.y = b;
  14612. this.target.setPosition(a, b)
  14613. } else this.target.setPosition(c.x + a, c.y + b)
  14614. }
  14615. },
  14616. reverse: function () {
  14617. var a = new cc.JumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
  14618. this._cloneDecoration(a);
  14619. this._reverseEaseList(a);
  14620. return a
  14621. }
  14622. });
  14623. cc.jumpBy = function (a, b, c, d, e) {
  14624. return new cc.JumpBy(a, b, c, d, e)
  14625. };
  14626. cc.JumpBy.create = cc.jumpBy;
  14627. cc.JumpTo = cc.JumpBy.extend({
  14628. _endPosition: null,
  14629. ctor: function (a, b, c, d, e) {
  14630. cc.JumpBy.prototype.ctor.call(this);
  14631. this._endPosition = cc.p(0, 0);
  14632. void 0 !== d && this.initWithDuration(a, b, c, d, e)
  14633. },
  14634. initWithDuration: function (a, b, c, d, e) {
  14635. 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
  14636. },
  14637. startWithTarget: function (a) {
  14638. cc.JumpBy.prototype.startWithTarget.call(this, a);
  14639. this._delta.x = this._endPosition.x - this._startPosition.x;
  14640. this._delta.y = this._endPosition.y - this._startPosition.y
  14641. },
  14642. clone: function () {
  14643. var a = new cc.JumpTo;
  14644. this._cloneDecoration(a);
  14645. a.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
  14646. return a
  14647. }
  14648. });
  14649. cc.jumpTo = function (a, b, c, d, e) {
  14650. return new cc.JumpTo(a, b, c, d, e)
  14651. };
  14652. cc.JumpTo.create = cc.jumpTo;
  14653. cc.bezierAt = function (a, b, c, d, e) {
  14654. 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
  14655. };
  14656. cc.BezierBy = cc.ActionInterval.extend({
  14657. _config: null,
  14658. _startPosition: null,
  14659. _previousPosition: null,
  14660. ctor: function (a, b) {
  14661. cc.ActionInterval.prototype.ctor.call(this);
  14662. this._config = [];
  14663. this._startPosition = cc.p(0, 0);
  14664. this._previousPosition = cc.p(0, 0);
  14665. b && this.initWithDuration(a, b)
  14666. },
  14667. initWithDuration: function (a, b) {
  14668. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._config = b, !0) : !1
  14669. },
  14670. clone: function () {
  14671. var a = new cc.BezierBy;
  14672. this._cloneDecoration(a);
  14673. for (var b = [], c = 0; c < this._config.length; c++) {
  14674. var d = this._config[c];
  14675. b.push(cc.p(d.x, d.y))
  14676. }
  14677. a.initWithDuration(this._duration, b);
  14678. return a
  14679. },
  14680. startWithTarget: function (a) {
  14681. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14682. var b = a.getPositionX();
  14683. a = a.getPositionY();
  14684. this._previousPosition.x = b;
  14685. this._previousPosition.y = a;
  14686. this._startPosition.x = b;
  14687. this._startPosition.y = a
  14688. },
  14689. update: function (a) {
  14690. a = this._computeEaseTime(a);
  14691. if (this.target) {
  14692. var b = this._config,
  14693. c = b[0].y,
  14694. d = b[1].y,
  14695. e = b[2].y,
  14696. b = cc.bezierAt(0, b[0].x, b[1].x, b[2].x, a);
  14697. a = cc.bezierAt(0, c, d, e, a);
  14698. c = this._startPosition;
  14699. if (cc.ENABLE_STACKABLE_ACTIONS) {
  14700. var d = this.target.getPositionX(),
  14701. e = this.target.getPositionY(),
  14702. f = this._previousPosition;
  14703. c.x = c.x + d - f.x;
  14704. c.y = c.y + e - f.y;
  14705. b += c.x;
  14706. a += c.y;
  14707. f.x = b;
  14708. f.y = a;
  14709. this.target.setPosition(b, a)
  14710. } else this.target.setPosition(c.x + b, c.y + a)
  14711. }
  14712. },
  14713. reverse: function () {
  14714. var a = this._config,
  14715. a = [cc.pAdd(a[1], cc.pNeg(a[2])), cc.pAdd(a[0], cc.pNeg(a[2])), cc.pNeg(a[2])],
  14716. a = new cc.BezierBy(this._duration, a);
  14717. this._cloneDecoration(a);
  14718. this._reverseEaseList(a);
  14719. return a
  14720. }
  14721. });
  14722. cc.bezierBy = function (a, b) {
  14723. return new cc.BezierBy(a, b)
  14724. };
  14725. cc.BezierBy.create = cc.bezierBy;
  14726. cc.BezierTo = cc.BezierBy.extend({
  14727. _toConfig: null,
  14728. ctor: function (a, b) {
  14729. cc.BezierBy.prototype.ctor.call(this);
  14730. this._toConfig = [];
  14731. b && this.initWithDuration(a, b)
  14732. },
  14733. initWithDuration: function (a, b) {
  14734. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toConfig = b, !0) : !1
  14735. },
  14736. clone: function () {
  14737. var a = new cc.BezierTo;
  14738. this._cloneDecoration(a);
  14739. a.initWithDuration(this._duration, this._toConfig);
  14740. return a
  14741. },
  14742. startWithTarget: function (a) {
  14743. cc.BezierBy.prototype.startWithTarget.call(this, a);
  14744. a = this._startPosition;
  14745. var b = this._toConfig,
  14746. c = this._config;
  14747. c[0] = cc.pSub(b[0], a);
  14748. c[1] = cc.pSub(b[1], a);
  14749. c[2] = cc.pSub(b[2], a)
  14750. }
  14751. });
  14752. cc.bezierTo = function (a, b) {
  14753. return new cc.BezierTo(a, b)
  14754. };
  14755. cc.BezierTo.create = cc.bezierTo;
  14756. cc.ScaleTo = cc.ActionInterval.extend({
  14757. _scaleX: 1,
  14758. _scaleY: 1,
  14759. _startScaleX: 1,
  14760. _startScaleY: 1,
  14761. _endScaleX: 0,
  14762. _endScaleY: 0,
  14763. _deltaX: 0,
  14764. _deltaY: 0,
  14765. ctor: function (a, b, c) {
  14766. cc.ActionInterval.prototype.ctor.call(this);
  14767. void 0 !== b && this.initWithDuration(a, b, c)
  14768. },
  14769. initWithDuration: function (a, b, c) {
  14770. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._endScaleX = b, this._endScaleY = null != c ? c : b, !0) : !1
  14771. },
  14772. clone: function () {
  14773. var a = new cc.ScaleTo;
  14774. this._cloneDecoration(a);
  14775. a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
  14776. return a
  14777. },
  14778. startWithTarget: function (a) {
  14779. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14780. this._startScaleX = a.scaleX;
  14781. this._startScaleY = a.scaleY;
  14782. this._deltaX = this._endScaleX - this._startScaleX;
  14783. this._deltaY = this._endScaleY - this._startScaleY
  14784. },
  14785. update: function (a) {
  14786. a = this._computeEaseTime(a);
  14787. this.target && (this.target.scaleX = this._startScaleX + this._deltaX * a, this.target.scaleY = this._startScaleY + this._deltaY * a)
  14788. }
  14789. });
  14790. cc.scaleTo = function (a, b, c) {
  14791. return new cc.ScaleTo(a, b, c)
  14792. };
  14793. cc.ScaleTo.create = cc.scaleTo;
  14794. cc.ScaleBy = cc.ScaleTo.extend({
  14795. startWithTarget: function (a) {
  14796. cc.ScaleTo.prototype.startWithTarget.call(this, a);
  14797. this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
  14798. this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY
  14799. },
  14800. reverse: function () {
  14801. var a = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
  14802. this._cloneDecoration(a);
  14803. this._reverseEaseList(a);
  14804. return a
  14805. },
  14806. clone: function () {
  14807. var a = new cc.ScaleBy;
  14808. this._cloneDecoration(a);
  14809. a.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
  14810. return a
  14811. }
  14812. });
  14813. cc.scaleBy = function (a, b, c) {
  14814. return new cc.ScaleBy(a, b, c)
  14815. };
  14816. cc.ScaleBy.create = cc.scaleBy;
  14817. cc.Blink = cc.ActionInterval.extend({
  14818. _times: 0,
  14819. _originalState: !1,
  14820. ctor: function (a, b) {
  14821. cc.ActionInterval.prototype.ctor.call(this);
  14822. void 0 !== b && this.initWithDuration(a, b)
  14823. },
  14824. initWithDuration: function (a, b) {
  14825. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._times = b, !0) : !1
  14826. },
  14827. clone: function () {
  14828. var a = new cc.Blink;
  14829. this._cloneDecoration(a);
  14830. a.initWithDuration(this._duration, this._times);
  14831. return a
  14832. },
  14833. update: function (a) {
  14834. a = this._computeEaseTime(a);
  14835. if (this.target && !this.isDone()) {
  14836. var b = 1 / this._times;
  14837. this.target.visible = a % b > b / 2
  14838. }
  14839. },
  14840. startWithTarget: function (a) {
  14841. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14842. this._originalState = a.visible
  14843. },
  14844. stop: function () {
  14845. this.target.visible = this._originalState;
  14846. cc.ActionInterval.prototype.stop.call(this)
  14847. },
  14848. reverse: function () {
  14849. var a = new cc.Blink(this._duration, this._times);
  14850. this._cloneDecoration(a);
  14851. this._reverseEaseList(a);
  14852. return a
  14853. }
  14854. });
  14855. cc.blink = function (a, b) {
  14856. return new cc.Blink(a, b)
  14857. };
  14858. cc.Blink.create = cc.blink;
  14859. cc.FadeTo = cc.ActionInterval.extend({
  14860. _toOpacity: 0,
  14861. _fromOpacity: 0,
  14862. ctor: function (a, b) {
  14863. cc.ActionInterval.prototype.ctor.call(this);
  14864. void 0 !== b && this.initWithDuration(a, b)
  14865. },
  14866. initWithDuration: function (a, b) {
  14867. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._toOpacity = b, !0) : !1
  14868. },
  14869. clone: function () {
  14870. var a = new cc.FadeTo;
  14871. this._cloneDecoration(a);
  14872. a.initWithDuration(this._duration, this._toOpacity);
  14873. return a
  14874. },
  14875. update: function (a) {
  14876. a = this._computeEaseTime(a);
  14877. var b = void 0 !== this._fromOpacity ? this._fromOpacity : 255;
  14878. this.target.opacity = b + (this._toOpacity - b) * a
  14879. },
  14880. startWithTarget: function (a) {
  14881. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14882. this._fromOpacity = a.opacity
  14883. }
  14884. });
  14885. cc.fadeTo = function (a, b) {
  14886. return new cc.FadeTo(a, b)
  14887. };
  14888. cc.FadeTo.create = cc.fadeTo;
  14889. cc.FadeIn = cc.FadeTo.extend({
  14890. _reverseAction: null,
  14891. ctor: function (a) {
  14892. cc.FadeTo.prototype.ctor.call(this);
  14893. a && this.initWithDuration(a, 255)
  14894. },
  14895. reverse: function () {
  14896. var a = new cc.FadeOut;
  14897. a.initWithDuration(this._duration, 0);
  14898. this._cloneDecoration(a);
  14899. this._reverseEaseList(a);
  14900. return a
  14901. },
  14902. clone: function () {
  14903. var a = new cc.FadeIn;
  14904. this._cloneDecoration(a);
  14905. a.initWithDuration(this._duration, this._toOpacity);
  14906. return a
  14907. },
  14908. startWithTarget: function (a) {
  14909. this._reverseAction && (this._toOpacity = this._reverseAction._fromOpacity);
  14910. cc.FadeTo.prototype.startWithTarget.call(this, a)
  14911. }
  14912. });
  14913. cc.fadeIn = function (a) {
  14914. return new cc.FadeIn(a)
  14915. };
  14916. cc.FadeIn.create = cc.fadeIn;
  14917. cc.FadeOut = cc.FadeTo.extend({
  14918. ctor: function (a) {
  14919. cc.FadeTo.prototype.ctor.call(this);
  14920. a && this.initWithDuration(a, 0)
  14921. },
  14922. reverse: function () {
  14923. var a = new cc.FadeIn;
  14924. a._reverseAction = this;
  14925. a.initWithDuration(this._duration, 255);
  14926. this._cloneDecoration(a);
  14927. this._reverseEaseList(a);
  14928. return a
  14929. },
  14930. clone: function () {
  14931. var a = new cc.FadeOut;
  14932. this._cloneDecoration(a);
  14933. a.initWithDuration(this._duration, this._toOpacity);
  14934. return a
  14935. }
  14936. });
  14937. cc.fadeOut = function (a) {
  14938. return new cc.FadeOut(a)
  14939. };
  14940. cc.FadeOut.create = cc.fadeOut;
  14941. cc.TintTo = cc.ActionInterval.extend({
  14942. _to: null,
  14943. _from: null,
  14944. ctor: function (a, b, c, d) {
  14945. cc.ActionInterval.prototype.ctor.call(this);
  14946. this._to = cc.color(0, 0, 0);
  14947. this._from = cc.color(0, 0, 0);
  14948. void 0 !== d && this.initWithDuration(a, b, c, d)
  14949. },
  14950. initWithDuration: function (a, b, c, d) {
  14951. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = cc.color(b, c, d), !0) : !1
  14952. },
  14953. clone: function () {
  14954. var a = new cc.TintTo;
  14955. this._cloneDecoration(a);
  14956. var b = this._to;
  14957. a.initWithDuration(this._duration, b.r, b.g, b.b);
  14958. return a
  14959. },
  14960. startWithTarget: function (a) {
  14961. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14962. this._from = this.target.color
  14963. },
  14964. update: function (a) {
  14965. a = this._computeEaseTime(a);
  14966. var b = this._from,
  14967. c = this._to;
  14968. 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))
  14969. }
  14970. });
  14971. cc.tintTo = function (a, b, c, d) {
  14972. return new cc.TintTo(a, b, c, d)
  14973. };
  14974. cc.TintTo.create = cc.tintTo;
  14975. cc.TintBy = cc.ActionInterval.extend({
  14976. _deltaR: 0,
  14977. _deltaG: 0,
  14978. _deltaB: 0,
  14979. _fromR: 0,
  14980. _fromG: 0,
  14981. _fromB: 0,
  14982. ctor: function (a, b, c, d) {
  14983. cc.ActionInterval.prototype.ctor.call(this);
  14984. void 0 !== d && this.initWithDuration(a, b, c, d)
  14985. },
  14986. initWithDuration: function (a, b, c, d) {
  14987. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._deltaR = b, this._deltaG = c, this._deltaB = d, !0) : !1
  14988. },
  14989. clone: function () {
  14990. var a = new cc.TintBy;
  14991. this._cloneDecoration(a);
  14992. a.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
  14993. return a
  14994. },
  14995. startWithTarget: function (a) {
  14996. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  14997. a = a.color;
  14998. this._fromR = a.r;
  14999. this._fromG = a.g;
  15000. this._fromB = a.b
  15001. },
  15002. update: function (a) {
  15003. a = this._computeEaseTime(a);
  15004. this.target.color = cc.color(this._fromR + this._deltaR * a, this._fromG + this._deltaG * a, this._fromB + this._deltaB * a)
  15005. },
  15006. reverse: function () {
  15007. var a = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
  15008. this._cloneDecoration(a);
  15009. this._reverseEaseList(a);
  15010. return a
  15011. }
  15012. });
  15013. cc.tintBy = function (a, b, c, d) {
  15014. return new cc.TintBy(a, b, c, d)
  15015. };
  15016. cc.TintBy.create = cc.tintBy;
  15017. cc.DelayTime = cc.ActionInterval.extend({
  15018. update: function (a) { },
  15019. reverse: function () {
  15020. var a = new cc.DelayTime(this._duration);
  15021. this._cloneDecoration(a);
  15022. this._reverseEaseList(a);
  15023. return a
  15024. },
  15025. clone: function () {
  15026. var a = new cc.DelayTime;
  15027. this._cloneDecoration(a);
  15028. a.initWithDuration(this._duration);
  15029. return a
  15030. }
  15031. });
  15032. cc.delayTime = function (a) {
  15033. return new cc.DelayTime(a)
  15034. };
  15035. cc.DelayTime.create = cc.delayTime;
  15036. cc.ReverseTime = cc.ActionInterval.extend({
  15037. _other: null,
  15038. ctor: function (a) {
  15039. cc.ActionInterval.prototype.ctor.call(this);
  15040. this._other = null;
  15041. a && this.initWithAction(a)
  15042. },
  15043. initWithAction: function (a) {
  15044. if (!a) throw "cc.ReverseTime.initWithAction(): action must be non null";
  15045. if (a == this._other) throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
  15046. return cc.ActionInterval.prototype.initWithDuration.call(this, a._duration) ? (this._other = a, !0) : !1
  15047. },
  15048. clone: function () {
  15049. var a = new cc.ReverseTime;
  15050. this._cloneDecoration(a);
  15051. a.initWithAction(this._other.clone());
  15052. return a
  15053. },
  15054. startWithTarget: function (a) {
  15055. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15056. this._other.startWithTarget(a)
  15057. },
  15058. update: function (a) {
  15059. a = this._computeEaseTime(a);
  15060. this._other && this._other.update(1 - a)
  15061. },
  15062. reverse: function () {
  15063. return this._other.clone()
  15064. },
  15065. stop: function () {
  15066. this._other.stop();
  15067. cc.Action.prototype.stop.call(this)
  15068. }
  15069. });
  15070. cc.reverseTime = function (a) {
  15071. return new cc.ReverseTime(a)
  15072. };
  15073. cc.ReverseTime.create = cc.reverseTime;
  15074. cc.Animate = cc.ActionInterval.extend({
  15075. _animation: null,
  15076. _nextFrame: 0,
  15077. _origFrame: null,
  15078. _executedLoops: 0,
  15079. _splitTimes: null,
  15080. ctor: function (a) {
  15081. cc.ActionInterval.prototype.ctor.call(this);
  15082. this._splitTimes = [];
  15083. a && this.initWithAnimation(a)
  15084. },
  15085. getAnimation: function () {
  15086. return this._animation
  15087. },
  15088. setAnimation: function (a) {
  15089. this._animation = a
  15090. },
  15091. initWithAnimation: function (a) {
  15092. if (!a) throw "cc.Animate.initWithAnimation(): animation must be non-NULL";
  15093. var b = a.getDuration();
  15094. if (this.initWithDuration(b * a.getLoops())) {
  15095. this._nextFrame = 0;
  15096. this.setAnimation(a);
  15097. this._origFrame = null;
  15098. this._executedLoops = 0;
  15099. var c = this._splitTimes,
  15100. d = c.length = 0,
  15101. e = b / a.getTotalDelayUnits();
  15102. a = a.getFrames();
  15103. cc.arrayVerifyType(a, cc.AnimationFrame);
  15104. for (var f = 0; f < a.length; f++) {
  15105. var g = d * e / b,
  15106. d = d + a[f].getDelayUnits();
  15107. c.push(g)
  15108. }
  15109. return !0
  15110. }
  15111. return !1
  15112. },
  15113. clone: function () {
  15114. var a = new cc.Animate;
  15115. this._cloneDecoration(a);
  15116. a.initWithAnimation(this._animation.clone());
  15117. return a
  15118. },
  15119. startWithTarget: function (a) {
  15120. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15121. this._animation.getRestoreOriginalFrame() && (this._origFrame = a.displayFrame());
  15122. this._executedLoops = this._nextFrame = 0
  15123. },
  15124. update: function (a) {
  15125. a = this._computeEaseTime(a);
  15126. 1 > a && (a *= this._animation.getLoops(), (0 | a) > this._executedLoops && (this._nextFrame = 0, this._executedLoops++), a %= 1);
  15127. for (var b = this._animation.getFrames(), c = b.length, d = this._splitTimes, e = this._nextFrame; e < c; e++) if (d[e] <= a) this.target.setSpriteFrame(b[e].getSpriteFrame()),
  15128. this._nextFrame = e + 1;
  15129. else break
  15130. },
  15131. reverse: function () {
  15132. var a = this._animation,
  15133. b = a.getFrames(),
  15134. c = [];
  15135. cc.arrayVerifyType(b, cc.AnimationFrame);
  15136. if (0 < b.length) for (var d = b.length - 1; 0 <= d; d--) {
  15137. var e = b[d];
  15138. if (!e) break;
  15139. c.push(e.clone())
  15140. }
  15141. b = new cc.Animation(c, a.getDelayPerUnit(), a.getLoops());
  15142. b.setRestoreOriginalFrame(a.getRestoreOriginalFrame());
  15143. a = new cc.Animate(b);
  15144. this._cloneDecoration(a);
  15145. this._reverseEaseList(a);
  15146. return a
  15147. },
  15148. stop: function () {
  15149. this._animation.getRestoreOriginalFrame() && this.target && this.target.setSpriteFrame(this._origFrame);
  15150. cc.Action.prototype.stop.call(this)
  15151. }
  15152. });
  15153. cc.animate = function (a) {
  15154. return new cc.Animate(a)
  15155. };
  15156. cc.Animate.create = cc.animate;
  15157. cc.TargetedAction = cc.ActionInterval.extend({
  15158. _action: null,
  15159. _forcedTarget: null,
  15160. ctor: function (a, b) {
  15161. cc.ActionInterval.prototype.ctor.call(this);
  15162. b && this.initWithTarget(a, b)
  15163. },
  15164. initWithTarget: function (a, b) {
  15165. return this.initWithDuration(b._duration) ? (this._forcedTarget = a, this._action = b, !0) : !1
  15166. },
  15167. clone: function () {
  15168. var a = new cc.TargetedAction;
  15169. this._cloneDecoration(a);
  15170. a.initWithTarget(this._forcedTarget, this._action.clone());
  15171. return a
  15172. },
  15173. startWithTarget: function (a) {
  15174. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15175. this._action.startWithTarget(this._forcedTarget)
  15176. },
  15177. stop: function () {
  15178. this._action.stop()
  15179. },
  15180. update: function (a) {
  15181. a = this._computeEaseTime(a);
  15182. this._action.update(a)
  15183. },
  15184. getForcedTarget: function () {
  15185. return this._forcedTarget
  15186. },
  15187. setForcedTarget: function (a) {
  15188. this._forcedTarget != a && (this._forcedTarget = a)
  15189. }
  15190. });
  15191. cc.targetedAction = function (a, b) {
  15192. return new cc.TargetedAction(a, b)
  15193. };
  15194. cc.TargetedAction.create = cc.targetedAction;
  15195. cc.ActionInstant = cc.FiniteTimeAction.extend({
  15196. isDone: function () {
  15197. return !0
  15198. },
  15199. step: function (a) {
  15200. this.update(1)
  15201. },
  15202. update: function (a) { },
  15203. reverse: function () {
  15204. return this.clone()
  15205. },
  15206. clone: function () {
  15207. return new cc.ActionInstant
  15208. }
  15209. });
  15210. cc.Show = cc.ActionInstant.extend({
  15211. update: function (a) {
  15212. this.target.visible = !0
  15213. },
  15214. reverse: function () {
  15215. return new cc.Hide
  15216. },
  15217. clone: function () {
  15218. return new cc.Show
  15219. }
  15220. });
  15221. cc.show = function () {
  15222. return new cc.Show
  15223. };
  15224. cc.Show.create = cc.show;
  15225. cc.Hide = cc.ActionInstant.extend({
  15226. update: function (a) {
  15227. this.target.visible = !1
  15228. },
  15229. reverse: function () {
  15230. return new cc.Show
  15231. },
  15232. clone: function () {
  15233. return new cc.Hide
  15234. }
  15235. });
  15236. cc.hide = function () {
  15237. return new cc.Hide
  15238. };
  15239. cc.Hide.create = cc.hide;
  15240. cc.ToggleVisibility = cc.ActionInstant.extend({
  15241. update: function (a) {
  15242. this.target.visible = !this.target.visible
  15243. },
  15244. reverse: function () {
  15245. return new cc.ToggleVisibility
  15246. },
  15247. clone: function () {
  15248. return new cc.ToggleVisibility
  15249. }
  15250. });
  15251. cc.toggleVisibility = function () {
  15252. return new cc.ToggleVisibility
  15253. };
  15254. cc.ToggleVisibility.create = cc.toggleVisibility;
  15255. cc.RemoveSelf = cc.ActionInstant.extend({
  15256. _isNeedCleanUp: !0,
  15257. ctor: function (a) {
  15258. cc.FiniteTimeAction.prototype.ctor.call(this);
  15259. void 0 !== a && this.init(a)
  15260. },
  15261. update: function (a) {
  15262. this.target.removeFromParent(this._isNeedCleanUp)
  15263. },
  15264. init: function (a) {
  15265. this._isNeedCleanUp = a;
  15266. return !0
  15267. },
  15268. reverse: function () {
  15269. return new cc.RemoveSelf(this._isNeedCleanUp)
  15270. },
  15271. clone: function () {
  15272. return new cc.RemoveSelf(this._isNeedCleanUp)
  15273. }
  15274. });
  15275. cc.removeSelf = function (a) {
  15276. return new cc.RemoveSelf(a)
  15277. };
  15278. cc.RemoveSelf.create = cc.removeSelf;
  15279. cc.FlipX = cc.ActionInstant.extend({
  15280. _flippedX: !1,
  15281. ctor: function (a) {
  15282. cc.FiniteTimeAction.prototype.ctor.call(this);
  15283. this._flippedX = !1;
  15284. void 0 !== a && this.initWithFlipX(a)
  15285. },
  15286. initWithFlipX: function (a) {
  15287. this._flippedX = a;
  15288. return !0
  15289. },
  15290. update: function (a) {
  15291. this.target.flippedX = this._flippedX
  15292. },
  15293. reverse: function () {
  15294. return new cc.FlipX(!this._flippedX)
  15295. },
  15296. clone: function () {
  15297. var a = new cc.FlipX;
  15298. a.initWithFlipX(this._flippedX);
  15299. return a
  15300. }
  15301. });
  15302. cc.flipX = function (a) {
  15303. return new cc.FlipX(a)
  15304. };
  15305. cc.FlipX.create = cc.flipX;
  15306. cc.FlipY = cc.ActionInstant.extend({
  15307. _flippedY: !1,
  15308. ctor: function (a) {
  15309. cc.FiniteTimeAction.prototype.ctor.call(this);
  15310. this._flippedY = !1;
  15311. void 0 !== a && this.initWithFlipY(a)
  15312. },
  15313. initWithFlipY: function (a) {
  15314. this._flippedY = a;
  15315. return !0
  15316. },
  15317. update: function (a) {
  15318. this.target.flippedY = this._flippedY
  15319. },
  15320. reverse: function () {
  15321. return new cc.FlipY(!this._flippedY)
  15322. },
  15323. clone: function () {
  15324. var a = new cc.FlipY;
  15325. a.initWithFlipY(this._flippedY);
  15326. return a
  15327. }
  15328. });
  15329. cc.flipY = function (a) {
  15330. return new cc.FlipY(a)
  15331. };
  15332. cc.FlipY.create = cc.flipY;
  15333. cc.Place = cc.ActionInstant.extend({
  15334. _x: 0,
  15335. _y: 0,
  15336. ctor: function (a, b) {
  15337. cc.FiniteTimeAction.prototype.ctor.call(this);
  15338. this._y = this._x = 0;
  15339. void 0 !== a && (void 0 !== a.x && (b = a.y, a = a.x), this.initWithPosition(a, b))
  15340. },
  15341. initWithPosition: function (a, b) {
  15342. this._x = a;
  15343. this._y = b;
  15344. return !0
  15345. },
  15346. update: function (a) {
  15347. this.target.setPosition(this._x, this._y)
  15348. },
  15349. clone: function () {
  15350. var a = new cc.Place;
  15351. a.initWithPosition(this._x, this._y);
  15352. return a
  15353. }
  15354. });
  15355. cc.place = function (a, b) {
  15356. return new cc.Place(a, b)
  15357. };
  15358. cc.Place.create = cc.place;
  15359. cc.CallFunc = cc.ActionInstant.extend({
  15360. _selectorTarget: null,
  15361. _callFunc: null,
  15362. _function: null,
  15363. _data: null,
  15364. ctor: function (a, b, c) {
  15365. cc.FiniteTimeAction.prototype.ctor.call(this);
  15366. void 0 !== a && (void 0 === b ? this.initWithFunction(a) : this.initWithFunction(a, b, c))
  15367. },
  15368. initWithFunction: function (a, b, c) {
  15369. b ? (this._data = c, this._callFunc = a, this._selectorTarget = b) : a && (this._function = a);
  15370. return !0
  15371. },
  15372. execute: function () {
  15373. null != this._callFunc ? this._callFunc.call(this._selectorTarget, this.target, this._data) : this._function && this._function.call(null, this.target)
  15374. },
  15375. update: function (a) {
  15376. this.execute()
  15377. },
  15378. getTargetCallback: function () {
  15379. return this._selectorTarget
  15380. },
  15381. setTargetCallback: function (a) {
  15382. a != this._selectorTarget && (this._selectorTarget && (this._selectorTarget = null), this._selectorTarget = a)
  15383. },
  15384. clone: function () {
  15385. var a = new cc.CallFunc;
  15386. this._selectorTarget ? a.initWithFunction(this._callFunc, this._selectorTarget, this._data) : this._function && a.initWithFunction(this._function);
  15387. return a
  15388. }
  15389. });
  15390. cc.callFunc = function (a, b, c) {
  15391. return new cc.CallFunc(a, b, c)
  15392. };
  15393. cc.CallFunc.create = cc.callFunc;
  15394. cc.ActionCamera = cc.ActionInterval.extend({
  15395. _centerXOrig: 0,
  15396. _centerYOrig: 0,
  15397. _centerZOrig: 0,
  15398. _eyeXOrig: 0,
  15399. _eyeYOrig: 0,
  15400. _eyeZOrig: 0,
  15401. _upXOrig: 0,
  15402. _upYOrig: 0,
  15403. _upZOrig: 0,
  15404. ctor: function () {
  15405. cc.ActionInterval.prototype.ctor.call(this);
  15406. this._upZOrig = this._upYOrig = this._upXOrig = this._eyeZOrig = this._eyeYOrig = this._eyeXOrig = this._centerZOrig = this._centerYOrig = this._centerXOrig = 0
  15407. },
  15408. startWithTarget: function (a) {
  15409. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15410. a = a.getCamera();
  15411. var b = a.getCenter();
  15412. this._centerXOrig = b.x;
  15413. this._centerYOrig = b.y;
  15414. this._centerZOrig = b.z;
  15415. b = a.getEye();
  15416. this._eyeXOrig = b.x;
  15417. this._eyeYOrig = b.y;
  15418. this._eyeZOrig = b.z;
  15419. a = a.getUp();
  15420. this._upXOrig = a.x;
  15421. this._upYOrig = a.y;
  15422. this._upZOrig = a.z
  15423. },
  15424. clone: function () {
  15425. return new cc.ActionCamera
  15426. },
  15427. reverse: function () {
  15428. return new cc.ReverseTime(this)
  15429. }
  15430. });
  15431. cc.OrbitCamera = cc.ActionCamera.extend({
  15432. _radius: 0,
  15433. _deltaRadius: 0,
  15434. _angleZ: 0,
  15435. _deltaAngleZ: 0,
  15436. _angleX: 0,
  15437. _deltaAngleX: 0,
  15438. _radZ: 0,
  15439. _radDeltaZ: 0,
  15440. _radX: 0,
  15441. _radDeltaX: 0,
  15442. ctor: function (a, b, c, d, e, f, g) {
  15443. cc.ActionCamera.prototype.ctor.call(this);
  15444. void 0 !== g && this.initWithDuration(a, b, c, d, e, f, g)
  15445. },
  15446. initWithDuration: function (a, b, c, d, e, f, g) {
  15447. 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 = cc.degreesToRadians(e), this._radDeltaX = cc.degreesToRadians(g), !0) : !1
  15448. },
  15449. sphericalRadius: function () {
  15450. var a,
  15451. b;
  15452. b = this.target.getCamera();
  15453. var c = b.getEye();
  15454. a = b.getCenter();
  15455. b = c.x - a.x;
  15456. var d = c.y - a.y;
  15457. a = c.z - a.z;
  15458. var c = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2) + Math.pow(a, 2)),
  15459. e = Math.sqrt(Math.pow(b, 2) + Math.pow(d, 2));
  15460. 0 === e && (e = cc.FLT_EPSILON);
  15461. 0 === c && (c = cc.FLT_EPSILON);
  15462. a = Math.acos(a / c);
  15463. b = 0 > b ? Math.PI - Math.asin(d / e) : Math.asin(d / e);
  15464. return {
  15465. newRadius: c / cc.Camera.getZEye(),
  15466. zenith: a,
  15467. azimuth: b
  15468. }
  15469. },
  15470. startWithTarget: function (a) {
  15471. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15472. a = this.sphericalRadius();
  15473. isNaN(this._radius) && (this._radius = a.newRadius);
  15474. isNaN(this._angleZ) && (this._angleZ = cc.radiansToDegrees(a.zenith));
  15475. isNaN(this._angleX) && (this._angleX = cc.radiansToDegrees(a.azimuth));
  15476. this._radZ = cc.degreesToRadians(this._angleZ);
  15477. this._radX = cc.degreesToRadians(this._angleX)
  15478. },
  15479. clone: function () {
  15480. var a = new cc.OrbitCamera;
  15481. a.initWithDuration(this._duration, this._radius, this._deltaRadius, this._angleZ, this._deltaAngleZ, this._angleX, this._deltaAngleX);
  15482. return a
  15483. },
  15484. update: function (a) {
  15485. a = this._computeEaseTime(a);
  15486. var b = (this._radius + this._deltaRadius * a) * cc.Camera.getZEye(),
  15487. c = this._radZ + this._radDeltaZ * a,
  15488. d = this._radX + this._radDeltaX * a;
  15489. a = Math.sin(c) * Math.cos(d) * b + this._centerXOrig;
  15490. d = Math.sin(c) * Math.sin(d) * b + this._centerYOrig;
  15491. b = Math.cos(c) * b + this._centerZOrig;
  15492. this.target.getCamera().setEye(a, d, b)
  15493. }
  15494. });
  15495. cc.orbitCamera = function (a, b, c, d, e, f, g) {
  15496. return new cc.OrbitCamera(a, b, c, d, e, f, g)
  15497. };
  15498. cc.OrbitCamera.create = cc.orbitCamera;
  15499. cc.ActionEase = cc.ActionInterval.extend({
  15500. _inner: null,
  15501. ctor: function (a) {
  15502. cc.ActionInterval.prototype.ctor.call(this);
  15503. a && this.initWithAction(a)
  15504. },
  15505. initWithAction: function (a) {
  15506. if (!a) throw "cc.ActionEase.initWithAction(): action must be non nil";
  15507. return this.initWithDuration(a.getDuration()) ? (this._inner = a, !0) : !1
  15508. },
  15509. clone: function () {
  15510. var a = new cc.ActionEase;
  15511. a.initWithAction(this._inner.clone());
  15512. return a
  15513. },
  15514. startWithTarget: function (a) {
  15515. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  15516. this._inner.startWithTarget(this.target)
  15517. },
  15518. stop: function () {
  15519. this._inner.stop();
  15520. cc.ActionInterval.prototype.stop.call(this)
  15521. },
  15522. update: function (a) {
  15523. this._inner.update(a)
  15524. },
  15525. reverse: function () {
  15526. return new cc.ActionEase(this._inner.reverse())
  15527. },
  15528. getInnerAction: function () {
  15529. return this._inner
  15530. }
  15531. });
  15532. cc.actionEase = function (a) {
  15533. return new cc.ActionEase(a)
  15534. };
  15535. cc.ActionEase.create = cc.actionEase;
  15536. cc.EaseRateAction = cc.ActionEase.extend({
  15537. _rate: 0,
  15538. ctor: function (a, b) {
  15539. cc.ActionEase.prototype.ctor.call(this);
  15540. void 0 !== b && this.initWithAction(a, b)
  15541. },
  15542. setRate: function (a) {
  15543. this._rate = a
  15544. },
  15545. getRate: function () {
  15546. return this._rate
  15547. },
  15548. initWithAction: function (a, b) {
  15549. return cc.ActionEase.prototype.initWithAction.call(this, a) ? (this._rate = b, !0) : !1
  15550. },
  15551. clone: function () {
  15552. var a = new cc.EaseRateAction;
  15553. a.initWithAction(this._inner.clone(), this._rate);
  15554. return a
  15555. },
  15556. reverse: function () {
  15557. return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate)
  15558. }
  15559. });
  15560. cc.easeRateAction = function (a, b) {
  15561. return new cc.EaseRateAction(a, b)
  15562. };
  15563. cc.EaseRateAction.create = cc.easeRateAction;
  15564. cc.EaseIn = cc.EaseRateAction.extend({
  15565. update: function (a) {
  15566. this._inner.update(Math.pow(a, this._rate))
  15567. },
  15568. reverse: function () {
  15569. return new cc.EaseIn(this._inner.reverse(), 1 / this._rate)
  15570. },
  15571. clone: function () {
  15572. var a = new cc.EaseIn;
  15573. a.initWithAction(this._inner.clone(), this._rate);
  15574. return a
  15575. }
  15576. });
  15577. cc.EaseIn.create = function (a, b) {
  15578. return new cc.EaseIn(a, b)
  15579. };
  15580. cc.easeIn = function (a) {
  15581. return {
  15582. _rate: a,
  15583. easing: function (a) {
  15584. return Math.pow(a, this._rate)
  15585. },
  15586. reverse: function () {
  15587. return cc.easeIn(1 / this._rate)
  15588. }
  15589. }
  15590. };
  15591. cc.EaseOut = cc.EaseRateAction.extend({
  15592. update: function (a) {
  15593. this._inner.update(Math.pow(a, 1 / this._rate))
  15594. },
  15595. reverse: function () {
  15596. return new cc.EaseOut(this._inner.reverse(), 1 / this._rate)
  15597. },
  15598. clone: function () {
  15599. var a = new cc.EaseOut;
  15600. a.initWithAction(this._inner.clone(), this._rate);
  15601. return a
  15602. }
  15603. });
  15604. cc.EaseOut.create = function (a, b) {
  15605. return new cc.EaseOut(a, b)
  15606. };
  15607. cc.easeOut = function (a) {
  15608. return {
  15609. _rate: a,
  15610. easing: function (a) {
  15611. return Math.pow(a, 1 / this._rate)
  15612. },
  15613. reverse: function () {
  15614. return cc.easeOut(1 / this._rate)
  15615. }
  15616. }
  15617. };
  15618. cc.EaseInOut = cc.EaseRateAction.extend({
  15619. update: function (a) {
  15620. a *= 2;
  15621. 1 > a ? this._inner.update(0.5 * Math.pow(a, this._rate)) : this._inner.update(1 - 0.5 * Math.pow(2 - a, this._rate))
  15622. },
  15623. clone: function () {
  15624. var a = new cc.EaseInOut;
  15625. a.initWithAction(this._inner.clone(), this._rate);
  15626. return a
  15627. },
  15628. reverse: function () {
  15629. return new cc.EaseInOut(this._inner.reverse(), this._rate)
  15630. }
  15631. });
  15632. cc.EaseInOut.create = function (a, b) {
  15633. return new cc.EaseInOut(a, b)
  15634. };
  15635. cc.easeInOut = function (a) {
  15636. return {
  15637. _rate: a,
  15638. easing: function (a) {
  15639. a *= 2;
  15640. return 1 > a ? 0.5 * Math.pow(a, this._rate) : 1 - 0.5 * Math.pow(2 - a, this._rate)
  15641. },
  15642. reverse: function () {
  15643. return cc.easeInOut(this._rate)
  15644. }
  15645. }
  15646. };
  15647. cc.EaseExponentialIn = cc.ActionEase.extend({
  15648. update: function (a) {
  15649. this._inner.update(0 === a ? 0 : Math.pow(2, 10 * (a - 1)))
  15650. },
  15651. reverse: function () {
  15652. return new cc.EaseExponentialOut(this._inner.reverse())
  15653. },
  15654. clone: function () {
  15655. var a = new cc.EaseExponentialIn;
  15656. a.initWithAction(this._inner.clone());
  15657. return a
  15658. }
  15659. });
  15660. cc.EaseExponentialIn.create = function (a) {
  15661. return new cc.EaseExponentialIn(a)
  15662. };
  15663. cc._easeExponentialInObj = {
  15664. easing: function (a) {
  15665. return 0 === a ? 0 : Math.pow(2, 10 * (a - 1))
  15666. },
  15667. reverse: function () {
  15668. return cc._easeExponentialOutObj
  15669. }
  15670. };
  15671. cc.easeExponentialIn = function () {
  15672. return cc._easeExponentialInObj
  15673. };
  15674. cc.EaseExponentialOut = cc.ActionEase.extend({
  15675. update: function (a) {
  15676. this._inner.update(1 == a ? 1 : -Math.pow(2, -10 * a) + 1)
  15677. },
  15678. reverse: function () {
  15679. return new cc.EaseExponentialIn(this._inner.reverse())
  15680. },
  15681. clone: function () {
  15682. var a = new cc.EaseExponentialOut;
  15683. a.initWithAction(this._inner.clone());
  15684. return a
  15685. }
  15686. });
  15687. cc.EaseExponentialOut.create = function (a) {
  15688. return new cc.EaseExponentialOut(a)
  15689. };
  15690. cc._easeExponentialOutObj = {
  15691. easing: function (a) {
  15692. return 1 == a ? 1 : -Math.pow(2, -10 * a) + 1
  15693. },
  15694. reverse: function () {
  15695. return cc._easeExponentialInObj
  15696. }
  15697. };
  15698. cc.easeExponentialOut = function () {
  15699. return cc._easeExponentialOutObj
  15700. };
  15701. cc.EaseExponentialInOut = cc.ActionEase.extend({
  15702. update: function (a) {
  15703. 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));
  15704. this._inner.update(a)
  15705. },
  15706. reverse: function () {
  15707. return new cc.EaseExponentialInOut(this._inner.reverse())
  15708. },
  15709. clone: function () {
  15710. var a = new cc.EaseExponentialInOut;
  15711. a.initWithAction(this._inner.clone());
  15712. return a
  15713. }
  15714. });
  15715. cc.EaseExponentialInOut.create = function (a) {
  15716. return new cc.EaseExponentialInOut(a)
  15717. };
  15718. cc._easeExponentialInOutObj = {
  15719. easing: function (a) {
  15720. 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
  15721. },
  15722. reverse: function () {
  15723. return cc._easeExponentialInOutObj
  15724. }
  15725. };
  15726. cc.easeExponentialInOut = function () {
  15727. return cc._easeExponentialInOutObj
  15728. };
  15729. cc.EaseSineIn = cc.ActionEase.extend({
  15730. update: function (a) {
  15731. a = 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1;
  15732. this._inner.update(a)
  15733. },
  15734. reverse: function () {
  15735. return new cc.EaseSineOut(this._inner.reverse())
  15736. },
  15737. clone: function () {
  15738. var a = new cc.EaseSineIn;
  15739. a.initWithAction(this._inner.clone());
  15740. return a
  15741. }
  15742. });
  15743. cc.EaseSineIn.create = function (a) {
  15744. return new cc.EaseSineIn(a)
  15745. };
  15746. cc._easeSineInObj = {
  15747. easing: function (a) {
  15748. return 0 === a || 1 === a ? a : -1 * Math.cos(a * Math.PI / 2) + 1
  15749. },
  15750. reverse: function () {
  15751. return cc._easeSineOutObj
  15752. }
  15753. };
  15754. cc.easeSineIn = function () {
  15755. return cc._easeSineInObj
  15756. };
  15757. cc.EaseSineOut = cc.ActionEase.extend({
  15758. update: function (a) {
  15759. a = 0 === a || 1 === a ? a : Math.sin(a * Math.PI / 2);
  15760. this._inner.update(a)
  15761. },
  15762. reverse: function () {
  15763. return new cc.EaseSineIn(this._inner.reverse())
  15764. },
  15765. clone: function () {
  15766. var a = new cc.EaseSineOut;
  15767. a.initWithAction(this._inner.clone());
  15768. return a
  15769. }
  15770. });
  15771. cc.EaseSineOut.create = function (a) {
  15772. return new cc.EaseSineOut(a)
  15773. };
  15774. cc._easeSineOutObj = {
  15775. easing: function (a) {
  15776. return 0 === a || 1 == a ? a : Math.sin(a * Math.PI / 2)
  15777. },
  15778. reverse: function () {
  15779. return cc._easeSineInObj
  15780. }
  15781. };
  15782. cc.easeSineOut = function () {
  15783. return cc._easeSineOutObj
  15784. };
  15785. cc.EaseSineInOut = cc.ActionEase.extend({
  15786. update: function (a) {
  15787. a = 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1);
  15788. this._inner.update(a)
  15789. },
  15790. clone: function () {
  15791. var a = new cc.EaseSineInOut;
  15792. a.initWithAction(this._inner.clone());
  15793. return a
  15794. },
  15795. reverse: function () {
  15796. return new cc.EaseSineInOut(this._inner.reverse())
  15797. }
  15798. });
  15799. cc.EaseSineInOut.create = function (a) {
  15800. return new cc.EaseSineInOut(a)
  15801. };
  15802. cc._easeSineInOutObj = {
  15803. easing: function (a) {
  15804. return 0 === a || 1 === a ? a : -0.5 * (Math.cos(Math.PI * a) - 1)
  15805. },
  15806. reverse: function () {
  15807. return cc._easeSineInOutObj
  15808. }
  15809. };
  15810. cc.easeSineInOut = function () {
  15811. return cc._easeSineInOutObj
  15812. };
  15813. cc.EaseElastic = cc.ActionEase.extend({
  15814. _period: 0.3,
  15815. ctor: function (a, b) {
  15816. cc.ActionEase.prototype.ctor.call(this);
  15817. a && this.initWithAction(a, b)
  15818. },
  15819. getPeriod: function () {
  15820. return this._period
  15821. },
  15822. setPeriod: function (a) {
  15823. this._period = a
  15824. },
  15825. initWithAction: function (a, b) {
  15826. cc.ActionEase.prototype.initWithAction.call(this, a);
  15827. this._period = null == b ? 0.3 : b;
  15828. return !0
  15829. },
  15830. reverse: function () {
  15831. cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
  15832. return null
  15833. },
  15834. clone: function () {
  15835. var a = new cc.EaseElastic;
  15836. a.initWithAction(this._inner.clone(), this._period);
  15837. return a
  15838. }
  15839. });
  15840. cc.EaseElastic.create = function (a, b) {
  15841. return new cc.EaseElastic(a, b)
  15842. };
  15843. cc.EaseElasticIn = cc.EaseElastic.extend({
  15844. update: function (a) {
  15845. var b = 0;
  15846. 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));
  15847. this._inner.update(b)
  15848. },
  15849. reverse: function () {
  15850. return new cc.EaseElasticOut(this._inner.reverse(), this._period)
  15851. },
  15852. clone: function () {
  15853. var a = new cc.EaseElasticIn;
  15854. a.initWithAction(this._inner.clone(), this._period);
  15855. return a
  15856. }
  15857. });
  15858. cc.EaseElasticIn.create = function (a, b) {
  15859. return new cc.EaseElasticIn(a, b)
  15860. };
  15861. cc._easeElasticInObj = {
  15862. easing: function (a) {
  15863. if (0 === a || 1 === a) return a;
  15864. a -= 1;
  15865. return -Math.pow(2, 10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3)
  15866. },
  15867. reverse: function () {
  15868. return cc._easeElasticOutObj
  15869. }
  15870. };
  15871. cc.easeElasticIn = function (a) {
  15872. return a && 0.3 !== a ? {
  15873. _period: a,
  15874. easing: function (a) {
  15875. if (0 === a || 1 === a) return a;
  15876. a -= 1;
  15877. return -Math.pow(2, 10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period)
  15878. },
  15879. reverse: function () {
  15880. return cc.easeElasticOut(this._period)
  15881. }
  15882. } : cc._easeElasticInObj
  15883. };
  15884. cc.EaseElasticOut = cc.EaseElastic.extend({
  15885. update: function (a) {
  15886. var b = 0;
  15887. 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);
  15888. this._inner.update(b)
  15889. },
  15890. reverse: function () {
  15891. return new cc.EaseElasticIn(this._inner.reverse(), this._period)
  15892. },
  15893. clone: function () {
  15894. var a = new cc.EaseElasticOut;
  15895. a.initWithAction(this._inner.clone(), this._period);
  15896. return a
  15897. }
  15898. });
  15899. cc.EaseElasticOut.create = function (a, b) {
  15900. return new cc.EaseElasticOut(a, b)
  15901. };
  15902. cc._easeElasticOutObj = {
  15903. easing: function (a) {
  15904. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - 0.075) * Math.PI * 2 / 0.3) + 1
  15905. },
  15906. reverse: function () {
  15907. return cc._easeElasticInObj
  15908. }
  15909. };
  15910. cc.easeElasticOut = function (a) {
  15911. return a && 0.3 !== a ? {
  15912. _period: a,
  15913. easing: function (a) {
  15914. return 0 === a || 1 === a ? a : Math.pow(2, -10 * a) * Math.sin((a - this._period / 4) * Math.PI * 2 / this._period) + 1
  15915. },
  15916. reverse: function () {
  15917. return cc.easeElasticIn(this._period)
  15918. }
  15919. } : cc._easeElasticOutObj
  15920. };
  15921. cc.EaseElasticInOut = cc.EaseElastic.extend({
  15922. update: function (a) {
  15923. var b = 0,
  15924. b = this._period;
  15925. if (0 === a || 1 == a) b = a;
  15926. else {
  15927. b || (b = this._period = 0.3 * 1.5);
  15928. var c = b / 4;
  15929. a = 2 * a - 1;
  15930. 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
  15931. }
  15932. this._inner.update(b)
  15933. },
  15934. reverse: function () {
  15935. return new cc.EaseElasticInOut(this._inner.reverse(), this._period)
  15936. },
  15937. clone: function () {
  15938. var a = new cc.EaseElasticInOut;
  15939. a.initWithAction(this._inner.clone(), this._period);
  15940. return a
  15941. }
  15942. });
  15943. cc.EaseElasticInOut.create = function (a, b) {
  15944. return new cc.EaseElasticInOut(a, b)
  15945. };
  15946. cc.easeElasticInOut = function (a) {
  15947. return {
  15948. _period: a || 0.3,
  15949. easing: function (a) {
  15950. var c = 0,
  15951. c = this._period;
  15952. if (0 === a || 1 === a) c = a;
  15953. else {
  15954. c || (c = this._period = 0.3 * 1.5);
  15955. var d = c / 4;
  15956. a = 2 * a - 1;
  15957. 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
  15958. }
  15959. return c
  15960. },
  15961. reverse: function () {
  15962. return cc.easeElasticInOut(this._period)
  15963. }
  15964. }
  15965. };
  15966. cc.EaseBounce = cc.ActionEase.extend({
  15967. bounceTime: function (a) {
  15968. if (a < 1 / 2.75) return 7.5625 * a * a;
  15969. if (a < 2 / 2.75) return a -= 1.5 / 2.75,
  15970. 7.5625 * a * a + 0.75;
  15971. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75,
  15972. 7.5625 * a * a + 0.9375;
  15973. a -= 2.625 / 2.75;
  15974. return 7.5625 * a * a + 0.984375
  15975. },
  15976. clone: function () {
  15977. var a = new cc.EaseBounce;
  15978. a.initWithAction(this._inner.clone());
  15979. return a
  15980. },
  15981. reverse: function () {
  15982. return new cc.EaseBounce(this._inner.reverse())
  15983. }
  15984. });
  15985. cc.EaseBounce.create = function (a) {
  15986. return new cc.EaseBounce(a)
  15987. };
  15988. cc.EaseBounceIn = cc.EaseBounce.extend({
  15989. update: function (a) {
  15990. a = 1 - this.bounceTime(1 - a);
  15991. this._inner.update(a)
  15992. },
  15993. reverse: function () {
  15994. return new cc.EaseBounceOut(this._inner.reverse())
  15995. },
  15996. clone: function () {
  15997. var a = new cc.EaseBounceIn;
  15998. a.initWithAction(this._inner.clone());
  15999. return a
  16000. }
  16001. });
  16002. cc.EaseBounceIn.create = function (a) {
  16003. return new cc.EaseBounceIn(a)
  16004. };
  16005. cc._bounceTime = function (a) {
  16006. if (a < 1 / 2.75) return 7.5625 * a * a;
  16007. if (a < 2 / 2.75) return a -= 1.5 / 2.75,
  16008. 7.5625 * a * a + 0.75;
  16009. if (a < 2.5 / 2.75) return a -= 2.25 / 2.75,
  16010. 7.5625 * a * a + 0.9375;
  16011. a -= 2.625 / 2.75;
  16012. return 7.5625 * a * a + 0.984375
  16013. };
  16014. cc._easeBounceInObj = {
  16015. easing: function (a) {
  16016. return 1 - cc._bounceTime(1 - a)
  16017. },
  16018. reverse: function () {
  16019. return cc._easeBounceOutObj
  16020. }
  16021. };
  16022. cc.easeBounceIn = function () {
  16023. return cc._easeBounceInObj
  16024. };
  16025. cc.EaseBounceOut = cc.EaseBounce.extend({
  16026. update: function (a) {
  16027. a = this.bounceTime(a);
  16028. this._inner.update(a)
  16029. },
  16030. reverse: function () {
  16031. return new cc.EaseBounceIn(this._inner.reverse())
  16032. },
  16033. clone: function () {
  16034. var a = new cc.EaseBounceOut;
  16035. a.initWithAction(this._inner.clone());
  16036. return a
  16037. }
  16038. });
  16039. cc.EaseBounceOut.create = function (a) {
  16040. return new cc.EaseBounceOut(a)
  16041. };
  16042. cc._easeBounceOutObj = {
  16043. easing: function (a) {
  16044. return cc._bounceTime(a)
  16045. },
  16046. reverse: function () {
  16047. return cc._easeBounceInObj
  16048. }
  16049. };
  16050. cc.easeBounceOut = function () {
  16051. return cc._easeBounceOutObj
  16052. };
  16053. cc.EaseBounceInOut = cc.EaseBounce.extend({
  16054. update: function (a) {
  16055. var b = 0,
  16056. b = 0.5 > a ? 0.5 * (1 - this.bounceTime(1 - 2 * a)) : 0.5 * this.bounceTime(2 * a - 1) + 0.5;
  16057. this._inner.update(b)
  16058. },
  16059. clone: function () {
  16060. var a = new cc.EaseBounceInOut;
  16061. a.initWithAction(this._inner.clone());
  16062. return a
  16063. },
  16064. reverse: function () {
  16065. return new cc.EaseBounceInOut(this._inner.reverse())
  16066. }
  16067. });
  16068. cc.EaseBounceInOut.create = function (a) {
  16069. return new cc.EaseBounceInOut(a)
  16070. };
  16071. cc._easeBounceInOutObj = {
  16072. easing: function (a) {
  16073. return a = 0.5 > a ? 0.5 * (1 - cc._bounceTime(1 - 2 * a)) : 0.5 * cc._bounceTime(2 * a - 1) + 0.5
  16074. },
  16075. reverse: function () {
  16076. return cc._easeBounceInOutObj
  16077. }
  16078. };
  16079. cc.easeBounceInOut = function () {
  16080. return cc._easeBounceInOutObj
  16081. };
  16082. cc.EaseBackIn = cc.ActionEase.extend({
  16083. update: function (a) {
  16084. this._inner.update(0 === a || 1 == a ? a : a * a * (2.70158 * a - 1.70158))
  16085. },
  16086. reverse: function () {
  16087. return new cc.EaseBackOut(this._inner.reverse())
  16088. },
  16089. clone: function () {
  16090. var a = new cc.EaseBackIn;
  16091. a.initWithAction(this._inner.clone());
  16092. return a
  16093. }
  16094. });
  16095. cc.EaseBackIn.create = function (a) {
  16096. return new cc.EaseBackIn(a)
  16097. };
  16098. cc._easeBackInObj = {
  16099. easing: function (a) {
  16100. return 0 === a || 1 === a ? a : a * a * (2.70158 * a - 1.70158)
  16101. },
  16102. reverse: function () {
  16103. return cc._easeBackOutObj
  16104. }
  16105. };
  16106. cc.easeBackIn = function () {
  16107. return cc._easeBackInObj
  16108. };
  16109. cc.EaseBackOut = cc.ActionEase.extend({
  16110. update: function (a) {
  16111. a -= 1;
  16112. this._inner.update(a * a * (2.70158 * a + 1.70158) + 1)
  16113. },
  16114. reverse: function () {
  16115. return new cc.EaseBackIn(this._inner.reverse())
  16116. },
  16117. clone: function () {
  16118. var a = new cc.EaseBackOut;
  16119. a.initWithAction(this._inner.clone());
  16120. return a
  16121. }
  16122. });
  16123. cc.EaseBackOut.create = function (a) {
  16124. return new cc.EaseBackOut(a)
  16125. };
  16126. cc._easeBackOutObj = {
  16127. easing: function (a) {
  16128. a -= 1;
  16129. return a * a * (2.70158 * a + 1.70158) + 1
  16130. },
  16131. reverse: function () {
  16132. return cc._easeBackInObj
  16133. }
  16134. };
  16135. cc.easeBackOut = function () {
  16136. return cc._easeBackOutObj
  16137. };
  16138. cc.EaseBackInOut = cc.ActionEase.extend({
  16139. update: function (a) {
  16140. a *= 2;
  16141. 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))
  16142. },
  16143. clone: function () {
  16144. var a = new cc.EaseBackInOut;
  16145. a.initWithAction(this._inner.clone());
  16146. return a
  16147. },
  16148. reverse: function () {
  16149. return new cc.EaseBackInOut(this._inner.reverse())
  16150. }
  16151. });
  16152. cc.EaseBackInOut.create = function (a) {
  16153. return new cc.EaseBackInOut(a)
  16154. };
  16155. cc._easeBackInOutObj = {
  16156. easing: function (a) {
  16157. a *= 2;
  16158. if (1 > a) return a * a * (3.5949095 * a - 2.5949095) / 2;
  16159. a -= 2;
  16160. return a * a * (3.5949095 * a + 2.5949095) / 2 + 1
  16161. },
  16162. reverse: function () {
  16163. return cc._easeBackInOutObj
  16164. }
  16165. };
  16166. cc.easeBackInOut = function () {
  16167. return cc._easeBackInOutObj
  16168. };
  16169. cc.EaseBezierAction = cc.ActionEase.extend({
  16170. _p0: null,
  16171. _p1: null,
  16172. _p2: null,
  16173. _p3: null,
  16174. ctor: function (a) {
  16175. cc.ActionEase.prototype.ctor.call(this, a)
  16176. },
  16177. _updateTime: function (a, b, c, d, e) {
  16178. 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
  16179. },
  16180. update: function (a) {
  16181. a = this._updateTime(this._p0, this._p1, this._p2, this._p3, a);
  16182. this._inner.update(a)
  16183. },
  16184. clone: function () {
  16185. var a = new cc.EaseBezierAction;
  16186. a.initWithAction(this._inner.clone());
  16187. a.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
  16188. return a
  16189. },
  16190. reverse: function () {
  16191. var a = new cc.EaseBezierAction(this._inner.reverse());
  16192. a.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
  16193. return a
  16194. },
  16195. setBezierParamer: function (a, b, c, d) {
  16196. this._p0 = a || 0;
  16197. this._p1 = b || 0;
  16198. this._p2 = c || 0;
  16199. this._p3 = d || 0
  16200. }
  16201. });
  16202. cc.EaseBezierAction.create = function (a) {
  16203. return new cc.EaseBezierAction(a)
  16204. };
  16205. cc.easeBezierAction = function (a, b, c, d) {
  16206. return {
  16207. easing: function (e) {
  16208. return cc.EaseBezierAction.prototype._updateTime(a, b, c, d, e)
  16209. },
  16210. reverse: function () {
  16211. return cc.easeBezierAction(d, c, b, a)
  16212. }
  16213. }
  16214. };
  16215. cc.EaseQuadraticActionIn = cc.ActionEase.extend({
  16216. _updateTime: function (a) {
  16217. return Math.pow(a, 2)
  16218. },
  16219. update: function (a) {
  16220. this._inner.update(this._updateTime(a))
  16221. },
  16222. clone: function () {
  16223. var a = new cc.EaseQuadraticActionIn;
  16224. a.initWithAction(this._inner.clone());
  16225. return a
  16226. },
  16227. reverse: function () {
  16228. return new cc.EaseQuadraticActionIn(this._inner.reverse())
  16229. }
  16230. });
  16231. cc.EaseQuadraticActionIn.create = function (a) {
  16232. return new cc.EaseQuadraticActionIn(a)
  16233. };
  16234. cc._easeQuadraticActionIn = {
  16235. easing: cc.EaseQuadraticActionIn.prototype._updateTime,
  16236. reverse: function () {
  16237. return cc._easeQuadraticActionIn
  16238. }
  16239. };
  16240. cc.easeQuadraticActionIn = function () {
  16241. return cc._easeQuadraticActionIn
  16242. };
  16243. cc.EaseQuadraticActionOut = cc.ActionEase.extend({
  16244. _updateTime: function (a) {
  16245. return -a * (a - 2)
  16246. },
  16247. update: function (a) {
  16248. this._inner.update(this._updateTime(a))
  16249. },
  16250. clone: function () {
  16251. var a = new cc.EaseQuadraticActionOut;
  16252. a.initWithAction();
  16253. return a
  16254. },
  16255. reverse: function () {
  16256. return new cc.EaseQuadraticActionOut(this._inner.reverse())
  16257. }
  16258. });
  16259. cc.EaseQuadraticActionOut.create = function (a) {
  16260. return new cc.EaseQuadraticActionOut(a)
  16261. };
  16262. cc._easeQuadraticActionOut = {
  16263. easing: cc.EaseQuadraticActionOut.prototype._updateTime,
  16264. reverse: function () {
  16265. return cc._easeQuadraticActionOut
  16266. }
  16267. };
  16268. cc.easeQuadraticActionOut = function () {
  16269. return cc._easeQuadraticActionOut
  16270. };
  16271. cc.EaseQuadraticActionInOut = cc.ActionEase.extend({
  16272. _updateTime: function (a) {
  16273. var b = a;
  16274. a *= 2;
  16275. 1 > a ? b = a * a * 0.5 : (--a, b = -0.5 * (a * (a - 2) - 1));
  16276. return b
  16277. },
  16278. update: function (a) {
  16279. this._inner.update(this._updateTime(a))
  16280. },
  16281. clone: function () {
  16282. var a = new cc.EaseQuadraticActionInOut;
  16283. a.initWithAction(this._inner.clone());
  16284. return a
  16285. },
  16286. reverse: function () {
  16287. return new cc.EaseQuadraticActionInOut(this._inner.reverse())
  16288. }
  16289. });
  16290. cc.EaseQuadraticActionInOut.create = function (a) {
  16291. return new cc.EaseQuadraticActionInOut(a)
  16292. };
  16293. cc._easeQuadraticActionInOut = {
  16294. easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
  16295. reverse: function () {
  16296. return cc._easeQuadraticActionInOut
  16297. }
  16298. };
  16299. cc.easeQuadraticActionInOut = function () {
  16300. return cc._easeQuadraticActionInOut
  16301. };
  16302. cc.EaseQuarticActionIn = cc.ActionEase.extend({
  16303. _updateTime: function (a) {
  16304. return a * a * a * a
  16305. },
  16306. update: function (a) {
  16307. this._inner.update(this._updateTime(a))
  16308. },
  16309. clone: function () {
  16310. var a = new cc.EaseQuarticActionIn;
  16311. a.initWithAction(this._inner.clone());
  16312. return a
  16313. },
  16314. reverse: function () {
  16315. return new cc.EaseQuarticActionIn(this._inner.reverse())
  16316. }
  16317. });
  16318. cc.EaseQuarticActionIn.create = function (a) {
  16319. return new cc.EaseQuarticActionIn(a)
  16320. };
  16321. cc._easeQuarticActionIn = {
  16322. easing: cc.EaseQuarticActionIn.prototype._updateTime,
  16323. reverse: function () {
  16324. return cc._easeQuarticActionIn
  16325. }
  16326. };
  16327. cc.easeQuarticActionIn = function () {
  16328. return cc._easeQuarticActionIn
  16329. };
  16330. cc.EaseQuarticActionOut = cc.ActionEase.extend({
  16331. _updateTime: function (a) {
  16332. a -= 1;
  16333. return -(a * a * a * a - 1)
  16334. },
  16335. update: function (a) {
  16336. this._inner.update(this._updateTime(a))
  16337. },
  16338. clone: function () {
  16339. var a = new cc.EaseQuarticActionOut;
  16340. a.initWithAction(this._inner.clone());
  16341. return a
  16342. },
  16343. reverse: function () {
  16344. return new cc.EaseQuarticActionOut(this._inner.reverse())
  16345. }
  16346. });
  16347. cc.EaseQuarticActionOut.create = function (a) {
  16348. return new cc.EaseQuarticActionOut(a)
  16349. };
  16350. cc._easeQuarticActionOut = {
  16351. easing: cc.EaseQuarticActionOut.prototype._updateTime,
  16352. reverse: function () {
  16353. return cc._easeQuarticActionOut
  16354. }
  16355. };
  16356. cc.easeQuarticActionOut = function () {
  16357. return cc._easeQuarticActionOut
  16358. };
  16359. cc.EaseQuarticActionInOut = cc.ActionEase.extend({
  16360. _updateTime: function (a) {
  16361. a *= 2;
  16362. if (1 > a) return 0.5 * a * a * a * a;
  16363. a -= 2;
  16364. return -0.5 * (a * a * a * a - 2)
  16365. },
  16366. update: function (a) {
  16367. this._inner.update(this._updateTime(a))
  16368. },
  16369. clone: function () {
  16370. var a = new cc.EaseQuarticActionInOut;
  16371. a.initWithAction(this._inner.clone());
  16372. return a
  16373. },
  16374. reverse: function () {
  16375. return new cc.EaseQuarticActionInOut(this._inner.reverse())
  16376. }
  16377. });
  16378. cc.EaseQuarticActionInOut.create = function (a) {
  16379. return new cc.EaseQuarticActionInOut(a)
  16380. };
  16381. cc._easeQuarticActionInOut = {
  16382. easing: cc.EaseQuarticActionInOut.prototype._updateTime,
  16383. reverse: function () {
  16384. return cc._easeQuarticActionInOut
  16385. }
  16386. };
  16387. cc.easeQuarticActionInOut = function () {
  16388. return cc._easeQuarticActionInOut
  16389. };
  16390. cc.EaseQuinticActionIn = cc.ActionEase.extend({
  16391. _updateTime: function (a) {
  16392. return a * a * a * a * a
  16393. },
  16394. update: function (a) {
  16395. this._inner.update(this._updateTime(a))
  16396. },
  16397. clone: function () {
  16398. var a = new cc.EaseQuinticActionIn;
  16399. a.initWithAction(this._inner.clone());
  16400. return a
  16401. },
  16402. reverse: function () {
  16403. return new cc.EaseQuinticActionIn(this._inner.reverse())
  16404. }
  16405. });
  16406. cc.EaseQuinticActionIn.create = function (a) {
  16407. return new cc.EaseQuinticActionIn(a)
  16408. };
  16409. cc._easeQuinticActionIn = {
  16410. easing: cc.EaseQuinticActionIn.prototype._updateTime,
  16411. reverse: function () {
  16412. return cc._easeQuinticActionIn
  16413. }
  16414. };
  16415. cc.easeQuinticActionIn = function () {
  16416. return cc._easeQuinticActionIn
  16417. };
  16418. cc.EaseQuinticActionOut = cc.ActionEase.extend({
  16419. _updateTime: function (a) {
  16420. a -= 1;
  16421. return a * a * a * a * a + 1
  16422. },
  16423. update: function (a) {
  16424. this._inner.update(this._updateTime(a))
  16425. },
  16426. clone: function () {
  16427. var a = new cc.EaseQuinticActionOut;
  16428. a.initWithAction(this._inner.clone());
  16429. return a
  16430. },
  16431. reverse: function () {
  16432. return new cc.EaseQuinticActionOut(this._inner.reverse())
  16433. }
  16434. });
  16435. cc.EaseQuinticActionOut.create = function (a) {
  16436. return new cc.EaseQuinticActionOut(a)
  16437. };
  16438. cc._easeQuinticActionOut = {
  16439. easing: cc.EaseQuinticActionOut.prototype._updateTime,
  16440. reverse: function () {
  16441. return cc._easeQuinticActionOut
  16442. }
  16443. };
  16444. cc.easeQuinticActionOut = function () {
  16445. return cc._easeQuinticActionOut
  16446. };
  16447. cc.EaseQuinticActionInOut = cc.ActionEase.extend({
  16448. _updateTime: function (a) {
  16449. a *= 2;
  16450. if (1 > a) return 0.5 * a * a * a * a * a;
  16451. a -= 2;
  16452. return 0.5 * (a * a * a * a * a + 2)
  16453. },
  16454. update: function (a) {
  16455. this._inner.update(this._updateTime(a))
  16456. },
  16457. clone: function () {
  16458. var a = new cc.EaseQuinticActionInOut;
  16459. a.initWithAction(this._inner.clone());
  16460. return a
  16461. },
  16462. reverse: function () {
  16463. return new cc.EaseQuinticActionInOut(this._inner.reverse())
  16464. }
  16465. });
  16466. cc.EaseQuinticActionInOut.create = function (a) {
  16467. return new cc.EaseQuinticActionInOut(a)
  16468. };
  16469. cc._easeQuinticActionInOut = {
  16470. easing: cc.EaseQuinticActionInOut.prototype._updateTime,
  16471. reverse: function () {
  16472. return cc._easeQuinticActionInOut
  16473. }
  16474. };
  16475. cc.easeQuinticActionInOut = function () {
  16476. return cc._easeQuinticActionInOut
  16477. };
  16478. cc.EaseCircleActionIn = cc.ActionEase.extend({
  16479. _updateTime: function (a) {
  16480. return -1 * (Math.sqrt(1 - a * a) - 1)
  16481. },
  16482. update: function (a) {
  16483. this._inner.update(this._updateTime(a))
  16484. },
  16485. clone: function () {
  16486. var a = new cc.EaseCircleActionIn;
  16487. a.initWithAction(this._inner.clone());
  16488. return a
  16489. },
  16490. reverse: function () {
  16491. return new cc.EaseCircleActionIn(this._inner.reverse())
  16492. }
  16493. });
  16494. cc.EaseCircleActionIn.create = function (a) {
  16495. return new cc.EaseCircleActionIn(a)
  16496. };
  16497. cc._easeCircleActionIn = {
  16498. easing: cc.EaseCircleActionIn.prototype._updateTime,
  16499. reverse: function () {
  16500. return cc._easeCircleActionIn
  16501. }
  16502. };
  16503. cc.easeCircleActionIn = function () {
  16504. return cc._easeCircleActionIn
  16505. };
  16506. cc.EaseCircleActionOut = cc.ActionEase.extend({
  16507. _updateTime: function (a) {
  16508. a -= 1;
  16509. return Math.sqrt(1 - a * a)
  16510. },
  16511. update: function (a) {
  16512. this._inner.update(this._updateTime(a))
  16513. },
  16514. clone: function () {
  16515. var a = new cc.EaseCircleActionOut;
  16516. a.initWithAction(this._inner.clone());
  16517. return a
  16518. },
  16519. reverse: function () {
  16520. return new cc.EaseCircleActionOut(this._inner.reverse())
  16521. }
  16522. });
  16523. cc.EaseCircleActionOut.create = function (a) {
  16524. return new cc.EaseCircleActionOut(a)
  16525. };
  16526. cc._easeCircleActionOut = {
  16527. easing: cc.EaseCircleActionOut.prototype._updateTime,
  16528. reverse: function () {
  16529. return cc._easeCircleActionOut
  16530. }
  16531. };
  16532. cc.easeCircleActionOut = function () {
  16533. return cc._easeCircleActionOut
  16534. };
  16535. cc.EaseCircleActionInOut = cc.ActionEase.extend({
  16536. _updateTime: function (a) {
  16537. a *= 2;
  16538. if (1 > a) return -0.5 * (Math.sqrt(1 - a * a) - 1);
  16539. a -= 2;
  16540. return 0.5 * (Math.sqrt(1 - a * a) + 1)
  16541. },
  16542. update: function (a) {
  16543. this._inner.update(this._updateTime(a))
  16544. },
  16545. clone: function () {
  16546. var a = new cc.EaseCircleActionInOut;
  16547. a.initWithAction(this._inner.clone());
  16548. return a
  16549. },
  16550. reverse: function () {
  16551. return new cc.EaseCircleActionInOut(this._inner.reverse())
  16552. }
  16553. });
  16554. cc.EaseCircleActionInOut.create = function (a) {
  16555. return new cc.EaseCircleActionInOut(a)
  16556. };
  16557. cc._easeCircleActionInOut = {
  16558. easing: cc.EaseCircleActionInOut.prototype._updateTime,
  16559. reverse: function () {
  16560. return cc._easeCircleActionInOut
  16561. }
  16562. };
  16563. cc.easeCircleActionInOut = function () {
  16564. return cc._easeCircleActionInOut
  16565. };
  16566. cc.EaseCubicActionIn = cc.ActionEase.extend({
  16567. _updateTime: function (a) {
  16568. return a * a * a
  16569. },
  16570. update: function (a) {
  16571. this._inner.update(this._updateTime(a))
  16572. },
  16573. clone: function () {
  16574. var a = new cc.EaseCubicActionIn;
  16575. a.initWithAction(this._inner.clone());
  16576. return a
  16577. },
  16578. reverse: function () {
  16579. return new cc.EaseCubicActionIn(this._inner.reverse())
  16580. }
  16581. });
  16582. cc.EaseCubicActionIn.create = function (a) {
  16583. return new cc.EaseCubicActionIn(a)
  16584. };
  16585. cc._easeCubicActionIn = {
  16586. easing: cc.EaseCubicActionIn.prototype._updateTime,
  16587. reverse: function () {
  16588. return cc._easeCubicActionIn
  16589. }
  16590. };
  16591. cc.easeCubicActionIn = function () {
  16592. return cc._easeCubicActionIn
  16593. };
  16594. cc.EaseCubicActionOut = cc.ActionEase.extend({
  16595. _updateTime: function (a) {
  16596. a -= 1;
  16597. return a * a * a + 1
  16598. },
  16599. update: function (a) {
  16600. this._inner.update(this._updateTime(a))
  16601. },
  16602. clone: function () {
  16603. var a = new cc.EaseCubicActionOut;
  16604. a.initWithAction(this._inner.clone());
  16605. return a
  16606. },
  16607. reverse: function () {
  16608. return new cc.EaseCubicActionOut(this._inner.reverse())
  16609. }
  16610. });
  16611. cc.EaseCubicActionOut.create = function (a) {
  16612. return new cc.EaseCubicActionOut(a)
  16613. };
  16614. cc._easeCubicActionOut = {
  16615. easing: cc.EaseCubicActionOut.prototype._updateTime,
  16616. reverse: function () {
  16617. return cc._easeCubicActionOut
  16618. }
  16619. };
  16620. cc.easeCubicActionOut = function () {
  16621. return cc._easeCubicActionOut
  16622. };
  16623. cc.EaseCubicActionInOut = cc.ActionEase.extend({
  16624. _updateTime: function (a) {
  16625. a *= 2;
  16626. if (1 > a) return 0.5 * a * a * a;
  16627. a -= 2;
  16628. return 0.5 * (a * a * a + 2)
  16629. },
  16630. update: function (a) {
  16631. this._inner.update(this._updateTime(a))
  16632. },
  16633. clone: function () {
  16634. var a = new cc.EaseCubicActionInOut;
  16635. a.initWithAction(this._inner.clone());
  16636. return a
  16637. },
  16638. reverse: function () {
  16639. return new cc.EaseCubicActionInOut(this._inner.reverse())
  16640. }
  16641. });
  16642. cc.EaseCubicActionInOut.create = function (a) {
  16643. return new cc.EaseCubicActionInOut(a)
  16644. };
  16645. cc._easeCubicActionInOut = {
  16646. easing: cc.EaseCubicActionInOut.prototype._updateTime,
  16647. reverse: function () {
  16648. return cc._easeCubicActionInOut
  16649. }
  16650. };
  16651. cc.easeCubicActionInOut = function () {
  16652. return cc._easeCubicActionInOut
  16653. };
  16654. cc.cardinalSplineAt = function (a, b, c, d, e, f) {
  16655. var g = f * f,
  16656. h = g * f,
  16657. k = (1 - e) / 2;
  16658. e = k * (-h + 2 * g - f);
  16659. var m = k * (-h + g) + (2 * h - 3 * g + 1);
  16660. f = k * (h - 2 * g + f) + (-2 * h + 3 * g);
  16661. g = k * (h - g);
  16662. 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)
  16663. };
  16664. cc.reverseControlPoints = function (a) {
  16665. for (var b = [], c = a.length - 1; 0 <= c; c--) b.push(cc.p(a[c].x, a[c].y));
  16666. return b
  16667. };
  16668. cc.cloneControlPoints = function (a) {
  16669. for (var b = [], c = 0; c < a.length; c++) b.push(cc.p(a[c].x, a[c].y));
  16670. return b
  16671. };
  16672. cc.copyControlPoints = cc.cloneControlPoints;
  16673. cc.getControlPointAt = function (a, b) {
  16674. var c = Math.min(a.length - 1, Math.max(b, 0));
  16675. return a[c]
  16676. };
  16677. cc.reverseControlPointsInline = function (a) {
  16678. for (var b = a.length, c = 0 | b / 2, d = 0; d < c; ++d) {
  16679. var e = a[d];
  16680. a[d] = a[b - d - 1];
  16681. a[b - d - 1] = e
  16682. }
  16683. };
  16684. cc.CardinalSplineTo = cc.ActionInterval.extend({
  16685. _points: null,
  16686. _deltaT: 0,
  16687. _tension: 0,
  16688. _previousPosition: null,
  16689. _accumulatedDiff: null,
  16690. ctor: function (a, b, c) {
  16691. cc.ActionInterval.prototype.ctor.call(this);
  16692. this._points = [];
  16693. void 0 !== c && this.initWithDuration(a, b, c)
  16694. },
  16695. initWithDuration: function (a, b, c) {
  16696. if (!b || 0 == b.length) throw "Invalid configuration. It must at least have one control point";
  16697. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.setPoints(b), this._tension = c, !0) : !1
  16698. },
  16699. clone: function () {
  16700. var a = new cc.CardinalSplineTo;
  16701. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  16702. return a
  16703. },
  16704. startWithTarget: function (a) {
  16705. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16706. this._deltaT = 1 / (this._points.length - 1);
  16707. this._previousPosition = cc.p(this.target.getPositionX(), this.target.getPositionY());
  16708. this._accumulatedDiff = cc.p(0, 0)
  16709. },
  16710. update: function (a) {
  16711. a = this._computeEaseTime(a);
  16712. var b,
  16713. c = this._points;
  16714. if (1 == a) b = c.length - 1,
  16715. a = 1;
  16716. else {
  16717. var d = this._deltaT;
  16718. b = 0 | a / d;
  16719. a = (a - d * b) / d
  16720. }
  16721. b = cc.cardinalSplineAt(cc.getControlPointAt(c, b - 1), cc.getControlPointAt(c, b - 0), cc.getControlPointAt(c, b + 1), cc.getControlPointAt(c, b + 2), this._tension, a);
  16722. 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);
  16723. this.updatePosition(b)
  16724. },
  16725. reverse: function () {
  16726. var a = cc.reverseControlPoints(this._points);
  16727. return cc.cardinalSplineTo(this._duration, a, this._tension)
  16728. },
  16729. updatePosition: function (a) {
  16730. this.target.setPosition(a);
  16731. this._previousPosition = a
  16732. },
  16733. getPoints: function () {
  16734. return this._points
  16735. },
  16736. setPoints: function (a) {
  16737. this._points = a
  16738. }
  16739. });
  16740. cc.cardinalSplineTo = function (a, b, c) {
  16741. return new cc.CardinalSplineTo(a, b, c)
  16742. };
  16743. cc.CardinalSplineTo.create = cc.cardinalSplineTo;
  16744. cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
  16745. _startPosition: null,
  16746. ctor: function (a, b, c) {
  16747. cc.CardinalSplineTo.prototype.ctor.call(this);
  16748. this._startPosition = cc.p(0, 0);
  16749. void 0 !== c && this.initWithDuration(a, b, c)
  16750. },
  16751. startWithTarget: function (a) {
  16752. cc.CardinalSplineTo.prototype.startWithTarget.call(this, a);
  16753. this._startPosition.x = a.getPositionX();
  16754. this._startPosition.y = a.getPositionY()
  16755. },
  16756. reverse: function () {
  16757. for (var a = this._points.slice(), b, c = a[0], d = 1; d < a.length; ++d) b = a[d],
  16758. a[d] = cc.pSub(b, c),
  16759. c = b;
  16760. a = cc.reverseControlPoints(a);
  16761. c = a[a.length - 1];
  16762. a.pop();
  16763. c.x = -c.x;
  16764. c.y = -c.y;
  16765. a.unshift(c);
  16766. for (d = 1; d < a.length; ++d) b = a[d],
  16767. b.x = -b.x,
  16768. b.y = -b.y,
  16769. b.x += c.x,
  16770. b.y += c.y,
  16771. c = a[d] = b;
  16772. return cc.cardinalSplineBy(this._duration, a, this._tension)
  16773. },
  16774. updatePosition: function (a) {
  16775. var b = this._startPosition,
  16776. c = a.x + b.x;
  16777. a = a.y + b.y;
  16778. this._previousPosition.x = c;
  16779. this._previousPosition.y = a;
  16780. this.target.setPosition(c, a)
  16781. },
  16782. clone: function () {
  16783. var a = new cc.CardinalSplineBy;
  16784. a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
  16785. return a
  16786. }
  16787. });
  16788. cc.cardinalSplineBy = function (a, b, c) {
  16789. return new cc.CardinalSplineBy(a, b, c)
  16790. };
  16791. cc.CardinalSplineBy.create = cc.cardinalSplineBy;
  16792. cc.CatmullRomTo = cc.CardinalSplineTo.extend({
  16793. ctor: function (a, b) {
  16794. b && this.initWithDuration(a, b)
  16795. },
  16796. initWithDuration: function (a, b) {
  16797. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5)
  16798. },
  16799. clone: function () {
  16800. var a = new cc.CatmullRomTo;
  16801. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  16802. return a
  16803. }
  16804. });
  16805. cc.catmullRomTo = function (a, b) {
  16806. return new cc.CatmullRomTo(a, b)
  16807. };
  16808. cc.CatmullRomTo.create = cc.catmullRomTo;
  16809. cc.CatmullRomBy = cc.CardinalSplineBy.extend({
  16810. ctor: function (a, b) {
  16811. cc.CardinalSplineBy.prototype.ctor.call(this);
  16812. b && this.initWithDuration(a, b)
  16813. },
  16814. initWithDuration: function (a, b) {
  16815. return cc.CardinalSplineTo.prototype.initWithDuration.call(this, a, b, 0.5)
  16816. },
  16817. clone: function () {
  16818. var a = new cc.CatmullRomBy;
  16819. a.initWithDuration(this._duration, cc.copyControlPoints(this._points));
  16820. return a
  16821. }
  16822. });
  16823. cc.catmullRomBy = function (a, b) {
  16824. return new cc.CatmullRomBy(a, b)
  16825. };
  16826. cc.CatmullRomBy.create = cc.catmullRomBy;
  16827. cc.ActionTweenDelegate = cc.Class.extend({
  16828. updateTweenAction: function (a, b) { }
  16829. });
  16830. cc.ActionTween = cc.ActionInterval.extend({
  16831. key: "",
  16832. from: 0,
  16833. to: 0,
  16834. delta: 0,
  16835. ctor: function (a, b, c, d) {
  16836. cc.ActionInterval.prototype.ctor.call(this);
  16837. this.key = "";
  16838. void 0 !== d && this.initWithDuration(a, b, c, d)
  16839. },
  16840. initWithDuration: function (a, b, c, d) {
  16841. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this.key = b, this.to = d, this.from = c, !0) : !1
  16842. },
  16843. startWithTarget: function (a) {
  16844. if (!a || !a.updateTweenAction) throw "cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function";
  16845. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  16846. this.delta = this.to - this.from
  16847. },
  16848. update: function (a) {
  16849. this.target.updateTweenAction(this.to - this.delta * (1 - a), this.key)
  16850. },
  16851. reverse: function () {
  16852. return new cc.ActionTween(this.duration, this.key, this.to, this.from)
  16853. },
  16854. clone: function () {
  16855. var a = new cc.ActionTween;
  16856. a.initWithDuration(this._duration, this.key, this.from, this.to);
  16857. return a
  16858. }
  16859. });
  16860. cc.actionTween = function (a, b, c, d) {
  16861. return new cc.ActionTween(a, b, c, d)
  16862. };
  16863. cc.ActionTween.create = cc.actionTween;
  16864. cc._globalFontSize = cc.ITEM_SIZE;
  16865. cc._globalFontName = "Arial";
  16866. cc._globalFontNameRelease = !1;
  16867. cc.MenuItem = cc.Node.extend({
  16868. _enabled: !1,
  16869. _target: null,
  16870. _callback: null,
  16871. _isSelected: !1,
  16872. _className: "MenuItem",
  16873. ctor: function (a, b) {
  16874. var c = cc.Node.prototype;
  16875. c.ctor.call(this);
  16876. this._callback = this._target = null;
  16877. this._enabled = this._isSelected = !1;
  16878. c.setAnchorPoint.call(this, 0.5, 0.5);
  16879. this._target = b || null;
  16880. if (this._callback = a || null) this._enabled = !0
  16881. },
  16882. isSelected: function () {
  16883. return this._isSelected
  16884. },
  16885. setOpacityModifyRGB: function (a) { },
  16886. isOpacityModifyRGB: function () {
  16887. return !1
  16888. },
  16889. setTarget: function (a, b) {
  16890. this._target = b;
  16891. this._callback = a
  16892. },
  16893. isEnabled: function () {
  16894. return this._enabled
  16895. },
  16896. setEnabled: function (a) {
  16897. this._enabled = a
  16898. },
  16899. initWithCallback: function (a, b) {
  16900. this.anchorY = this.anchorX = 0.5;
  16901. this._target = b;
  16902. this._callback = a;
  16903. this._enabled = !0;
  16904. this._isSelected = !1;
  16905. return !0
  16906. },
  16907. rect: function () {
  16908. var a = this._position,
  16909. b = this._contentSize,
  16910. c = this._anchorPoint;
  16911. return cc.rect(a.x - b.width * c.x, a.y - b.height * c.y, b.width, b.height)
  16912. },
  16913. selected: function () {
  16914. this._isSelected = !0
  16915. },
  16916. unselected: function () {
  16917. this._isSelected = !1
  16918. },
  16919. setCallback: function (a, b) {
  16920. this._target = b;
  16921. this._callback = a
  16922. },
  16923. activate: function () {
  16924. if (this._enabled) {
  16925. var a = this._target,
  16926. b = this._callback;
  16927. if (b) if (a && cc.isString(b)) a[b](this);
  16928. else a && cc.isFunction(b) ? b.call(a, this) : b(this)
  16929. }
  16930. }
  16931. });
  16932. _p = cc.MenuItem.prototype;
  16933. cc.defineGetterSetter(_p, "enabled", _p.isEnabled, _p.setEnabled);
  16934. cc.MenuItem.create = function (a, b) {
  16935. return new cc.MenuItem(a, b)
  16936. };
  16937. cc.MenuItemLabel = cc.MenuItem.extend({
  16938. _disabledColor: null,
  16939. _label: null,
  16940. _orginalScale: 0,
  16941. _colorBackup: null,
  16942. ctor: function (a, b, c) {
  16943. cc.MenuItem.prototype.ctor.call(this, b, c);
  16944. this._label = this._disabledColor = null;
  16945. this._orginalScale = 0;
  16946. this._colorBackup = null;
  16947. a && (this._originalScale = 1, this._colorBackup = cc.color.WHITE, this._disabledColor = cc.color(126, 126, 126), this.setLabel(a), this.cascadeOpacity = this.cascadeColor = !0)
  16948. },
  16949. getDisabledColor: function () {
  16950. return this._disabledColor
  16951. },
  16952. setDisabledColor: function (a) {
  16953. this._disabledColor = a
  16954. },
  16955. getLabel: function () {
  16956. return this._label
  16957. },
  16958. setLabel: function (a) {
  16959. a && (this.addChild(a), a.anchorX = 0, a.anchorY = 0, this.width = a.width, this.height = a.height);
  16960. this._label && this.removeChild(this._label, !0);
  16961. this._label = a
  16962. },
  16963. setEnabled: function (a) {
  16964. if (this._enabled != a) {
  16965. var b = this._label;
  16966. a ? b.color = this._colorBackup : (this._colorBackup = b.color, b.color = this._disabledColor)
  16967. }
  16968. cc.MenuItem.prototype.setEnabled.call(this, a)
  16969. },
  16970. setOpacity: function (a) {
  16971. this._label.opacity = a
  16972. },
  16973. getOpacity: function () {
  16974. return this._label.opacity
  16975. },
  16976. setColor: function (a) {
  16977. this._label.color = a
  16978. },
  16979. getColor: function () {
  16980. return this._label.color
  16981. },
  16982. initWithLabel: function (a, b, c) {
  16983. this.initWithCallback(b, c);
  16984. this._originalScale = 1;
  16985. this._colorBackup = cc.color.WHITE;
  16986. this._disabledColor = cc.color(126, 126, 126);
  16987. this.setLabel(a);
  16988. return this.cascadeOpacity = this.cascadeColor = !0
  16989. },
  16990. setString: function (a) {
  16991. this._label.string = a;
  16992. this.width = this._label.width;
  16993. this.height = this._label.height
  16994. },
  16995. getString: function () {
  16996. return this._label.string
  16997. },
  16998. activate: function () {
  16999. this._enabled && (this.stopAllActions(), this.scale = this._originalScale, cc.MenuItem.prototype.activate.call(this))
  17000. },
  17001. selected: function () {
  17002. if (this._enabled) {
  17003. cc.MenuItem.prototype.selected.call(this);
  17004. var a = this.getActionByTag(cc.ZOOM_ACTION_TAG);
  17005. a ? this.stopAction(a) : this._originalScale = this.scale;
  17006. a = cc.ScaleTo.create(0.1, 1.2 * this._originalScale);
  17007. a.setTag(cc.ZOOM_ACTION_TAG);
  17008. this.runAction(a)
  17009. }
  17010. },
  17011. unselected: function () {
  17012. if (this._enabled) {
  17013. cc.MenuItem.prototype.unselected.call(this);
  17014. this.stopActionByTag(cc.ZOOM_ACTION_TAG);
  17015. var a = cc.ScaleTo.create(0.1, this._originalScale);
  17016. a.setTag(cc.ZOOM_ACTION_TAG);
  17017. this.runAction(a)
  17018. }
  17019. }
  17020. });
  17021. _p = cc.MenuItemLabel.prototype;
  17022. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  17023. cc.defineGetterSetter(_p, "disabledColor", _p.getDisabledColor, _p.setDisabledColor);
  17024. cc.defineGetterSetter(_p, "label", _p.getLabel, _p.setLabel);
  17025. cc.MenuItemLabel.create = function (a, b, c) {
  17026. return new cc.MenuItemLabel(a, b, c)
  17027. };
  17028. cc.MenuItemAtlasFont = cc.MenuItemLabel.extend({
  17029. ctor: function (a, b, c, d, e, f, g) {
  17030. var h;
  17031. a && 0 < a.length && (h = cc.LabelAtlas.create(a, b, c, d, e));
  17032. cc.MenuItemLabel.prototype.ctor.call(this, h, f, g)
  17033. },
  17034. initWithString: function (a, b, c, d, e, f, g) {
  17035. if (!a || 0 == a.length) throw "cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0";
  17036. var h = new cc.LabelAtlas;
  17037. h.initWithString(a, b, c, d, e);
  17038. this.initWithLabel(h, f, g);
  17039. return !0
  17040. }
  17041. });
  17042. cc.MenuItemAtlasFont.create = function (a, b, c, d, e, f, g) {
  17043. return new cc.MenuItemAtlasFont(a, b, c, d, e, f, g)
  17044. };
  17045. cc.MenuItemFont = cc.MenuItemLabel.extend({
  17046. _fontSize: null,
  17047. _fontName: null,
  17048. ctor: function (a, b, c) {
  17049. var d;
  17050. a && 0 < a.length ? (this._fontName = cc._globalFontName, this._fontSize = cc._globalFontSize, d = cc.LabelTTF.create(a, this._fontName, this._fontSize)) : (this._fontSize = 0, this._fontName = "");
  17051. cc.MenuItemLabel.prototype.ctor.call(this, d, b, c)
  17052. },
  17053. initWithString: function (a, b, c) {
  17054. if (!a || 0 == a.length) throw "Value should be non-null and its length should be greater than 0";
  17055. this._fontName = cc._globalFontName;
  17056. this._fontSize = cc._globalFontSize;
  17057. a = cc.LabelTTF.create(a, this._fontName, this._fontSize);
  17058. this.initWithLabel(a, b, c);
  17059. return !0
  17060. },
  17061. setFontSize: function (a) {
  17062. this._fontSize = a;
  17063. this._recreateLabel()
  17064. },
  17065. getFontSize: function () {
  17066. return this._fontSize
  17067. },
  17068. setFontName: function (a) {
  17069. this._fontName = a;
  17070. this._recreateLabel()
  17071. },
  17072. getFontName: function () {
  17073. return this._fontName
  17074. },
  17075. _recreateLabel: function () {
  17076. var a = cc.LabelTTF.create(this._label.string, this._fontName, this._fontSize);
  17077. this.setLabel(a)
  17078. }
  17079. });
  17080. cc.MenuItemFont.setFontSize = function (a) {
  17081. cc._globalFontSize = a
  17082. };
  17083. cc.MenuItemFont.fontSize = function () {
  17084. return cc._globalFontSize
  17085. };
  17086. cc.MenuItemFont.setFontName = function (a) {
  17087. cc._globalFontNameRelease && (cc._globalFontName = "");
  17088. cc._globalFontName = a;
  17089. cc._globalFontNameRelease = !0
  17090. };
  17091. _p = cc.MenuItemFont.prototype;
  17092. cc.defineGetterSetter(_p, "fontSize", _p.getFontSize, _p.setFontSize);
  17093. cc.defineGetterSetter(_p, "fontName", _p.getFontName, _p.setFontName);
  17094. cc.MenuItemFont.fontName = function () {
  17095. return cc._globalFontName
  17096. };
  17097. cc.MenuItemFont.create = function (a, b, c) {
  17098. return new cc.MenuItemFont(a, b, c)
  17099. };
  17100. cc.MenuItemSprite = cc.MenuItem.extend({
  17101. _normalImage: null,
  17102. _selectedImage: null,
  17103. _disabledImage: null,
  17104. ctor: function (a, b, c, d, e) {
  17105. cc.MenuItem.prototype.ctor.call(this);
  17106. this._disabledImage = this._selectedImage = this._normalImage = null;
  17107. if (void 0 !== b) {
  17108. var f,
  17109. g,
  17110. h;
  17111. 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 = cc.Sprite.create(b)) : void 0 === c && (f = cc.Sprite.create(b));
  17112. this.initWithNormalSprite(a, b, f, h, g)
  17113. }
  17114. },
  17115. getNormalImage: function () {
  17116. return this._normalImage
  17117. },
  17118. setNormalImage: function (a) {
  17119. this._normalImage != a && (a && (this.addChild(a, 0, cc.NORMAL_TAG), a.anchorX = 0, a.anchorY = 0), this._normalImage && this.removeChild(this._normalImage, !0), this._normalImage = a, this.width = this._normalImage.width, this.height = this._normalImage.height, this._updateImagesVisibility(), a.textureLoaded && !a.textureLoaded() && a.addLoadedEventListener(function (a) {
  17120. this.width = a.width;
  17121. this.height = a.height
  17122. },
  17123. this))
  17124. },
  17125. getSelectedImage: function () {
  17126. return this._selectedImage
  17127. },
  17128. setSelectedImage: function (a) {
  17129. this._selectedImage != a && (a && (this.addChild(a, 0, cc.SELECTED_TAG), a.anchorX = 0, a.anchorY = 0), this._selectedImage && this.removeChild(this._selectedImage, !0), this._selectedImage = a, this._updateImagesVisibility())
  17130. },
  17131. getDisabledImage: function () {
  17132. return this._disabledImage
  17133. },
  17134. setDisabledImage: function (a) {
  17135. 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())
  17136. },
  17137. initWithNormalSprite: function (a, b, c, d, e) {
  17138. this.initWithCallback(d, e);
  17139. this.setNormalImage(a);
  17140. this.setSelectedImage(b);
  17141. this.setDisabledImage(c);
  17142. if (a = this._normalImage) this.width = a.width,
  17143. this.height = a.height,
  17144. a.textureLoaded && !a.textureLoaded() && a.addLoadedEventListener(function (a) {
  17145. this.width = a.width;
  17146. this.height = a.height;
  17147. this.cascadeOpacity = this.cascadeColor = !0
  17148. },
  17149. this);
  17150. return this.cascadeOpacity = this.cascadeColor = !0
  17151. },
  17152. setColor: function (a) {
  17153. this._normalImage.color = a;
  17154. this._selectedImage && (this._selectedImage.color = a);
  17155. this._disabledImage && (this._disabledImage.color = a)
  17156. },
  17157. getColor: function () {
  17158. return this._normalImage.color
  17159. },
  17160. setOpacity: function (a) {
  17161. this._normalImage.opacity = a;
  17162. this._selectedImage && (this._selectedImage.opacity = a);
  17163. this._disabledImage && (this._disabledImage.opacity = a)
  17164. },
  17165. getOpacity: function () {
  17166. return this._normalImage.opacity
  17167. },
  17168. selected: function () {
  17169. cc.MenuItem.prototype.selected.call(this);
  17170. this._normalImage && (this._disabledImage && (this._disabledImage.visible = !1), this._selectedImage ? (this._normalImage.visible = !1, this._selectedImage.visible = !0) : this._normalImage.visible = !0)
  17171. },
  17172. unselected: function () {
  17173. cc.MenuItem.prototype.unselected.call(this);
  17174. this._normalImage && (this._normalImage.visible = !0, this._selectedImage && (this._selectedImage.visible = !1), this._disabledImage && (this._disabledImage.visible = !1))
  17175. },
  17176. setEnabled: function (a) {
  17177. this._enabled != a && (cc.MenuItem.prototype.setEnabled.call(this, a), this._updateImagesVisibility())
  17178. },
  17179. _updateImagesVisibility: function () {
  17180. var a = this._normalImage,
  17181. b = this._selectedImage,
  17182. c = this._disabledImage;
  17183. 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))
  17184. }
  17185. });
  17186. _p = cc.MenuItemSprite.prototype;
  17187. cc.defineGetterSetter(_p, "normalImage", _p.getNormalImage, _p.setNormalImage);
  17188. cc.defineGetterSetter(_p, "selectedImage", _p.getSelectedImage, _p.setSelectedImage);
  17189. cc.defineGetterSetter(_p, "disabledImage", _p.getDisabledImage, _p.setDisabledImage);
  17190. cc.MenuItemSprite.create = function (a, b, c, d, e) {
  17191. return new cc.MenuItemSprite(a, b, c, d, e || void 0)
  17192. };
  17193. cc.MenuItemImage = cc.MenuItemSprite.extend({
  17194. ctor: function (a, b, c, d, e) {
  17195. var f = null,
  17196. g = null,
  17197. h = null,
  17198. k = null,
  17199. m = null;
  17200. void 0 === a ? cc.MenuItemSprite.prototype.ctor.call(this) : (f = cc.Sprite.create(a), b && (g = cc.Sprite.create(b)), void 0 === d ? k = c : void 0 === e ? (k = c, m = d) : e && (h = cc.Sprite.create(c), k = d, m = e), cc.MenuItemSprite.prototype.ctor.call(this, f, g, h, k, m))
  17201. },
  17202. setNormalSpriteFrame: function (a) {
  17203. this.setNormalImage(cc.Sprite.create(a))
  17204. },
  17205. setSelectedSpriteFrame: function (a) {
  17206. this.setSelectedImage(cc.Sprite.create(a))
  17207. },
  17208. setDisabledSpriteFrame: function (a) {
  17209. this.setDisabledImage(cc.Sprite.create(a))
  17210. },
  17211. initWithNormalImage: function (a, b, c, d, e) {
  17212. var f = null,
  17213. g = null,
  17214. h = null;
  17215. a && (f = cc.Sprite.create(a));
  17216. b && (g = cc.Sprite.create(b));
  17217. c && (h = cc.Sprite.create(c));
  17218. return this.initWithNormalSprite(f, g, h, d, e)
  17219. }
  17220. });
  17221. cc.MenuItemImage.create = function (a, b, c, d, e) {
  17222. return new cc.MenuItemImage(a, b, c, d, e)
  17223. };
  17224. cc.MenuItemToggle = cc.MenuItem.extend({
  17225. subItems: null,
  17226. _selectedIndex: 0,
  17227. _opacity: null,
  17228. _color: null,
  17229. ctor: function () {
  17230. cc.MenuItem.prototype.ctor.call(this);
  17231. this._selectedIndex = 0;
  17232. this.subItems = [];
  17233. this._opacity = 0;
  17234. this._color = cc.color.WHITE;
  17235. 0 < arguments.length && this.initWithItems(Array.prototype.slice.apply(arguments))
  17236. },
  17237. getOpacity: function () {
  17238. return this._opacity
  17239. },
  17240. setOpacity: function (a) {
  17241. this._opacity = a;
  17242. if (this.subItems && 0 < this.subItems.length) for (var b = 0; b < this.subItems.length; b++) this.subItems[b].opacity = a;
  17243. this._color.a = a
  17244. },
  17245. getColor: function () {
  17246. var a = this._color;
  17247. return cc.color(a.r, a.g, a.b, a.a)
  17248. },
  17249. setColor: function (a) {
  17250. var b = this._color;
  17251. b.r = a.r;
  17252. b.g = a.g;
  17253. b.b = a.b;
  17254. if (this.subItems && 0 < this.subItems.length) for (b = 0; b < this.subItems.length; b++) this.subItems[b].setColor(a);
  17255. void 0 === a.a || a.a_undefined || this.setOpacity(a.a)
  17256. },
  17257. getSelectedIndex: function () {
  17258. return this._selectedIndex
  17259. },
  17260. setSelectedIndex: function (a) {
  17261. if (a != this._selectedIndex) {
  17262. this._selectedIndex = a; (a = this.getChildByTag(cc.CURRENT_ITEM)) && a.removeFromParent(!1);
  17263. a = this.subItems[this._selectedIndex];
  17264. this.addChild(a, 0, cc.CURRENT_ITEM);
  17265. var b = a.width,
  17266. c = a.height;
  17267. this.width = b;
  17268. this.height = c;
  17269. a.setPosition(b / 2, c / 2)
  17270. }
  17271. },
  17272. getSubItems: function () {
  17273. return this.subItems
  17274. },
  17275. setSubItems: function (a) {
  17276. this.subItems = a
  17277. },
  17278. initWithItems: function (a) {
  17279. var b = a.length;
  17280. 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);
  17281. for (var c = this.subItems, d = c.length = 0; d < b; d++) a[d] && c.push(a[d]);
  17282. this._selectedIndex = cc.UINT_MAX;
  17283. this.setSelectedIndex(0);
  17284. return this.cascadeOpacity = this.cascadeColor = !0
  17285. },
  17286. addSubItem: function (a) {
  17287. this.subItems.push(a)
  17288. },
  17289. activate: function () {
  17290. this._enabled && this.setSelectedIndex((this._selectedIndex + 1) % this.subItems.length);
  17291. cc.MenuItem.prototype.activate.call(this)
  17292. },
  17293. selected: function () {
  17294. cc.MenuItem.prototype.selected.call(this);
  17295. this.subItems[this._selectedIndex].selected()
  17296. },
  17297. unselected: function () {
  17298. cc.MenuItem.prototype.unselected.call(this);
  17299. this.subItems[this._selectedIndex].unselected()
  17300. },
  17301. setEnabled: function (a) {
  17302. if (this._enabled != a) {
  17303. cc.MenuItem.prototype.setEnabled.call(this, a);
  17304. var b = this.subItems;
  17305. if (b && 0 < b.length) for (var c = 0; c < b.length; c++) b[c].enabled = a
  17306. }
  17307. },
  17308. selectedItem: function () {
  17309. return this.subItems[this._selectedIndex]
  17310. },
  17311. onEnter: function () {
  17312. cc.Node.prototype.onEnter.call(this);
  17313. this.setSelectedIndex(this._selectedIndex)
  17314. }
  17315. });
  17316. _p = cc.MenuItemToggle.prototype;
  17317. cc.defineGetterSetter(_p, "selectedIndex", _p.getSelectedIndex, _p.setSelectedIndex);
  17318. cc.MenuItemToggle.create = function () {
  17319. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  17320. var a = new cc.MenuItemToggle;
  17321. a.initWithItems(Array.prototype.slice.apply(arguments));
  17322. return a
  17323. };
  17324. cc.MENU_STATE_WAITING = 0;
  17325. cc.MENU_STATE_TRACKING_TOUCH = 1;
  17326. cc.MENU_HANDLER_PRIORITY = -128;
  17327. cc.DEFAULT_PADDING = 5;
  17328. cc.Menu = cc.Layer.extend({
  17329. enabled: !1,
  17330. _selectedItem: null,
  17331. _state: -1,
  17332. _touchListener: null,
  17333. _className: "Menu",
  17334. ctor: function (a) {
  17335. cc.Layer.prototype.ctor.call(this);
  17336. this._color = cc.color.WHITE;
  17337. this.enabled = !1;
  17338. this._opacity = 255;
  17339. this._selectedItem = null;
  17340. this._state = -1;
  17341. this._touchListener = cc.EventListener.create({
  17342. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  17343. swallowTouches: !0,
  17344. onTouchBegan: this._onTouchBegan,
  17345. onTouchMoved: this._onTouchMoved,
  17346. onTouchEnded: this._onTouchEnded,
  17347. onTouchCancelled: this._onTouchCancelled
  17348. });
  17349. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  17350. var b = arguments.length,
  17351. c;
  17352. if (0 == b) c = [];
  17353. else if (1 == b) c = a instanceof Array ? a : [a];
  17354. else if (1 < b) {
  17355. c = [];
  17356. for (var d = 0; d < b; d++) arguments[d] && c.push(arguments[d])
  17357. }
  17358. this.initWithArray(c)
  17359. },
  17360. onEnter: function () {
  17361. var a = this._touchListener;
  17362. a._isRegistered() || cc.eventManager.addListener(a, this);
  17363. cc.Node.prototype.onEnter.call(this)
  17364. },
  17365. isEnabled: function () {
  17366. return this.enabled
  17367. },
  17368. setEnabled: function (a) {
  17369. this.enabled = a
  17370. },
  17371. initWithItems: function (a) {
  17372. var b = [];
  17373. if (a) for (var c = 0; c < a.length; c++) a[c] && b.push(a[c]);
  17374. return this.initWithArray(b)
  17375. },
  17376. initWithArray: function (a) {
  17377. if (cc.Layer.prototype.init.call(this)) {
  17378. this.enabled = !0;
  17379. var b = cc.winSize;
  17380. this.setPosition(b.width / 2, b.height / 2);
  17381. this.setContentSize(b);
  17382. this.setAnchorPoint(0.5, 0.5);
  17383. this.ignoreAnchorPointForPosition(!0);
  17384. if (a) for (b = 0; b < a.length; b++) this.addChild(a[b], b);
  17385. this._selectedItem = null;
  17386. this._state = cc.MENU_STATE_WAITING;
  17387. return this.cascadeOpacity = this.cascadeColor = !0
  17388. }
  17389. return !1
  17390. },
  17391. addChild: function (a, b, c) {
  17392. if (!(a instanceof
  17393. cc.MenuItem)) throw "cc.Menu.addChild() : Menu only supports MenuItem objects as children";
  17394. cc.Layer.prototype.addChild.call(this, a, b, c)
  17395. },
  17396. alignItemsVertically: function () {
  17397. this.alignItemsVerticallyWithPadding(cc.DEFAULT_PADDING)
  17398. },
  17399. alignItemsVerticallyWithPadding: function (a) {
  17400. var b = -a,
  17401. c = this._children,
  17402. d,
  17403. e,
  17404. f,
  17405. g;
  17406. if (c && 0 < c.length) {
  17407. e = 0;
  17408. for (d = c.length; e < d; e++) b += c[e].height * c[e].scaleY + a;
  17409. var h = b / 2;
  17410. e = 0;
  17411. for (d = c.length; e < d; e++) g = c[e],
  17412. f = g.height,
  17413. b = g.scaleY,
  17414. g.setPosition(0, h - f * b / 2),
  17415. h -= f * b + a
  17416. }
  17417. },
  17418. alignItemsHorizontally: function () {
  17419. this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)
  17420. },
  17421. alignItemsHorizontallyWithPadding: function (a) {
  17422. var b = -a,
  17423. c = this._children,
  17424. d,
  17425. e,
  17426. f,
  17427. g;
  17428. if (c && 0 < c.length) {
  17429. d = 0;
  17430. for (e = c.length; d < e; d++) b += c[d].width * c[d].scaleX + a;
  17431. var h = -b / 2;
  17432. d = 0;
  17433. for (e = c.length; d < e; d++) g = c[d],
  17434. b = g.scaleX,
  17435. f = c[d].width,
  17436. g.setPosition(h + f * b / 2, 0),
  17437. h += f * b + a
  17438. }
  17439. },
  17440. alignItemsInColumns: function () {
  17441. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  17442. for (var a = [], b = 0; b < arguments.length; b++) a.push(arguments[b]);
  17443. var c = -5,
  17444. d = 0,
  17445. e = 0,
  17446. f = 0,
  17447. g,
  17448. h,
  17449. k,
  17450. m = this._children;
  17451. if (m && 0 < m.length) 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));
  17452. var n = cc.director.getWinSize(),
  17453. q = g = e = d = 0,
  17454. r = 0,
  17455. c = c / 2;
  17456. if (m && 0 < m.length) for (b = 0, k = m.length; b < k; b++) {
  17457. var s = m[b];
  17458. 0 == g && (g = a[d], r = q = n.width / (1 + g));
  17459. h = s._getHeight();
  17460. e = e >= h || isNaN(h) ? e : h;
  17461. s.setPosition(r - n.width / 2, c - h / 2);
  17462. r += q; ++f;
  17463. f >= g && (c -= e + 5, e = g = f = 0, ++d)
  17464. }
  17465. },
  17466. alignItemsInRows: function () {
  17467. 0 < arguments.length && null == arguments[arguments.length - 1] && cc.log("parameters should not be ending with null in Javascript");
  17468. var a = [],
  17469. b;
  17470. for (b = 0; b < arguments.length; b++) a.push(arguments[b]);
  17471. var c = [],
  17472. d = [],
  17473. e = -10,
  17474. f = -5,
  17475. g = 0,
  17476. h = 0,
  17477. k = 0,
  17478. m,
  17479. n,
  17480. q,
  17481. r,
  17482. s = this._children;
  17483. if (s && 0 < s.length) for (b = 0, q = s.length; b < q; b++) (n = s[b], g >= a.length || !(m = a[g])) || (r = n.width, h = h >= r || isNaN(r) ? h : r, f += n.height + 5, ++k, k >= m && (c.push(h), d.push(f), e += h + 10, h = k = 0, f = -5, ++g));
  17484. f = cc.director.getWinSize();
  17485. m = h = g = 0;
  17486. var e = -e / 2,
  17487. t = 0;
  17488. if (s && 0 < s.length) for (b = 0, q = s.length; b < q; b++) n = s[b],
  17489. 0 == m && (m = a[g], t = d[g]),
  17490. r = n._getWidth(),
  17491. h = h >= r || isNaN(r) ? h : r,
  17492. n.setPosition(e + c[g] / 2, t - f.height / 2),
  17493. t -= n.height + 10,
  17494. ++k,
  17495. k >= m && (e += h + 5, h = m = k = 0, ++g)
  17496. },
  17497. removeChild: function (a, b) {
  17498. 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"))
  17499. },
  17500. _onTouchBegan: function (a, b) {
  17501. var c = b.getCurrentTarget();
  17502. if (c._state != cc.MENU_STATE_WAITING || !c._visible || !c.enabled) return !1;
  17503. for (var d = c.parent; null != d; d = d.parent) if (!d.isVisible()) return !1;
  17504. c._selectedItem = c._itemForTouch(a);
  17505. return c._selectedItem ? (c._state = cc.MENU_STATE_TRACKING_TOUCH, c._selectedItem.selected(), !0) : !1
  17506. },
  17507. _onTouchEnded: function (a, b) {
  17508. var c = b.getCurrentTarget();
  17509. c._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchEnded(): invalid state") : (c._selectedItem && (c._selectedItem.unselected(), c._selectedItem.activate()), c._state = cc.MENU_STATE_WAITING)
  17510. },
  17511. _onTouchCancelled: function (a, b) {
  17512. var c = b.getCurrentTarget();
  17513. c._state !== cc.MENU_STATE_TRACKING_TOUCH ? cc.log("cc.Menu.onTouchCancelled(): invalid state") : (this._selectedItem && c._selectedItem.unselected(), c._state = cc.MENU_STATE_WAITING)
  17514. },
  17515. _onTouchMoved: function (a, b) {
  17516. var c = b.getCurrentTarget();
  17517. if (c._state !== cc.MENU_STATE_TRACKING_TOUCH) cc.log("cc.Menu.onTouchMoved(): invalid state");
  17518. else {
  17519. var d = c._itemForTouch(a);
  17520. d != c._selectedItem && (c._selectedItem && c._selectedItem.unselected(), c._selectedItem = d, c._selectedItem && c._selectedItem.selected())
  17521. }
  17522. },
  17523. onExit: function () {
  17524. this._state == cc.MENU_STATE_TRACKING_TOUCH && (this._selectedItem && (this._selectedItem.unselected(), this._selectedItem = null), this._state = cc.MENU_STATE_WAITING);
  17525. cc.Node.prototype.onExit.call(this)
  17526. },
  17527. setOpacityModifyRGB: function (a) { },
  17528. isOpacityModifyRGB: function () {
  17529. return !1
  17530. },
  17531. _itemForTouch: function (a) {
  17532. a = a.getLocation();
  17533. var b = this._children,
  17534. c;
  17535. if (b && 0 < b.length) for (var d = b.length - 1; 0 <= d; d--) if (c = b[d], c.isVisible() && c.isEnabled()) {
  17536. var e = c.convertToNodeSpace(a),
  17537. f = c.rect();
  17538. f.x = 0;
  17539. f.y = 0;
  17540. if (cc.rectContainsPoint(f, e)) return c
  17541. }
  17542. return null
  17543. }
  17544. });
  17545. _p = cc.Menu.prototype;
  17546. cc.Menu.create = function (a) {
  17547. var b = arguments.length;
  17548. 0 < b && null == arguments[b - 1] && cc.log("parameters should not be ending with null in Javascript");
  17549. return 0 == b ? new cc.Menu : 1 == b ? new cc.Menu(a) : new cc.Menu(Array.prototype.slice.call(arguments, 0))
  17550. };
  17551. cc.ProgressTimer = cc.Node.extend({
  17552. _type: null,
  17553. _percentage: 0,
  17554. _sprite: null,
  17555. _midPoint: null,
  17556. _barChangeRate: null,
  17557. _reverseDirection: !1,
  17558. _className: "ProgressTimer",
  17559. getMidpoint: function () {
  17560. return cc.p(this._midPoint.x, this._midPoint.y)
  17561. },
  17562. setMidpoint: function (a) {
  17563. this._midPoint = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
  17564. },
  17565. getBarChangeRate: function () {
  17566. return cc.p(this._barChangeRate.x, this._barChangeRate.y)
  17567. },
  17568. setBarChangeRate: function (a) {
  17569. this._barChangeRate = cc.pClamp(a, cc.p(0, 0), cc.p(1, 1))
  17570. },
  17571. getType: function () {
  17572. return this._type
  17573. },
  17574. getPercentage: function () {
  17575. return this._percentage
  17576. },
  17577. getSprite: function () {
  17578. return this._sprite
  17579. },
  17580. setPercentage: function (a) {
  17581. this._percentage != a && (this._percentage = cc.clampf(a, 0, 100), this._updateProgress())
  17582. },
  17583. setOpacityModifyRGB: function (a) { },
  17584. isOpacityModifyRGB: function () {
  17585. return !1
  17586. },
  17587. isReverseDirection: function () {
  17588. return this._reverseDirection
  17589. },
  17590. _boundaryTexCoord: function (a) {
  17591. if (a < cc.ProgressTimer.TEXTURE_COORDS_COUNT) {
  17592. var b = cc.ProgressTimer.TEXTURE_COORDS;
  17593. return this._reverseDirection ? cc.p(b >> 7 - (a << 1) & 1, b >> 7 -
  17594. ((a << 1) + 1) & 1) : cc.p(b >> (a << 1) + 1 & 1, b >> (a << 1) & 1)
  17595. }
  17596. return cc.p(0, 0)
  17597. },
  17598. _origin: null,
  17599. _startAngle: 270,
  17600. _endAngle: 270,
  17601. _radius: 0,
  17602. _counterClockWise: !1,
  17603. _barRect: null,
  17604. _vertexDataCount: 0,
  17605. _vertexData: null,
  17606. _vertexArrayBuffer: null,
  17607. _vertexWebGLBuffer: null,
  17608. _vertexDataDirty: !1,
  17609. ctor: null,
  17610. _ctorForCanvas: function (a) {
  17611. cc.Node.prototype.ctor.call(this);
  17612. this._type = cc.ProgressTimer.TYPE_RADIAL;
  17613. this._percentage = 0;
  17614. this._midPoint = cc.p(0, 0);
  17615. this._barChangeRate = cc.p(0, 0);
  17616. this._reverseDirection = !1;
  17617. this._sprite = null;
  17618. this._origin = cc.p(0, 0);
  17619. this._endAngle = this._startAngle = 270;
  17620. this._radius = 0;
  17621. this._counterClockWise = !1;
  17622. this._barRect = cc.rect(0, 0, 0, 0);
  17623. a && this._initWithSpriteForCanvas(a)
  17624. },
  17625. _ctorForWebGL: function (a) {
  17626. cc.Node.prototype.ctor.call(this);
  17627. this._type = cc.ProgressTimer.TYPE_RADIAL;
  17628. this._percentage = 0;
  17629. this._midPoint = cc.p(0, 0);
  17630. this._barChangeRate = cc.p(0, 0);
  17631. this._reverseDirection = !1;
  17632. this._sprite = null;
  17633. this._vertexWebGLBuffer = cc._renderContext.createBuffer();
  17634. this._vertexDataCount = 0;
  17635. this._vertexArrayBuffer = this._vertexData = null;
  17636. this._vertexDataDirty = !1;
  17637. a && this._initWithSpriteForWebGL(a)
  17638. },
  17639. setColor: function (a) {
  17640. this._sprite.color = a;
  17641. this._updateColor()
  17642. },
  17643. setOpacity: function (a) {
  17644. this._sprite.opacity = a;
  17645. this._updateColor()
  17646. },
  17647. getColor: function () {
  17648. return this._sprite.color
  17649. },
  17650. getOpacity: function () {
  17651. return this._sprite.opacity
  17652. },
  17653. setReverseProgress: null,
  17654. _setReverseProgressForCanvas: function (a) {
  17655. this._reverseDirection !== a && (this._reverseDirection = a)
  17656. },
  17657. _setReverseProgressForWebGL: function (a) {
  17658. this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
  17659. },
  17660. setSprite: null,
  17661. _setSpriteForCanvas: function (a) {
  17662. this._sprite != a && (this._sprite = a, this.width = this._sprite.width, this.height = this._sprite.height)
  17663. },
  17664. _setSpriteForWebGL: function (a) {
  17665. a && this._sprite != a && (this._sprite = a, this.width = a.width, this.height = a.height, this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0))
  17666. },
  17667. setType: null,
  17668. _setTypeForCanvas: function (a) {
  17669. a !== this._type && (this._type = a)
  17670. },
  17671. _setTypeForWebGL: function (a) {
  17672. a !== this._type && (this._vertexData && (this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0), this._type = a)
  17673. },
  17674. setReverseDirection: null,
  17675. _setReverseDirectionForCanvas: function (a) {
  17676. this._reverseDirection !== a && (this._reverseDirection = a)
  17677. },
  17678. _setReverseDirectionForWebGL: function (a) {
  17679. this._reverseDirection !== a && (this._reverseDirection = a, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0)
  17680. },
  17681. _textureCoordFromAlphaPoint: function (a) {
  17682. var b = this._sprite;
  17683. if (!b) return {
  17684. u: 0,
  17685. v: 0
  17686. };
  17687. var c = b.quad,
  17688. d = cc.p(c.bl.texCoords.u, c.bl.texCoords.v),
  17689. c = cc.p(c.tr.texCoords.u, c.tr.texCoords.v);
  17690. b.textureRectRotated && (b = a.x, a.x = a.y, a.y = b);
  17691. return {
  17692. u: d.x * (1 - a.x) + c.x * a.x,
  17693. v: d.y * (1 - a.y) + c.y * a.y
  17694. }
  17695. },
  17696. _vertexFromAlphaPoint: function (a) {
  17697. if (!this._sprite) return {
  17698. x: 0,
  17699. y: 0
  17700. };
  17701. var b = this._sprite.quad,
  17702. c = cc.p(b.bl.vertices.x, b.bl.vertices.y),
  17703. b = cc.p(b.tr.vertices.x, b.tr.vertices.y);
  17704. return {
  17705. x: c.x * (1 - a.x) + b.x * a.x,
  17706. y: c.y * (1 - a.y) + b.y * a.y
  17707. }
  17708. },
  17709. initWithSprite: null,
  17710. _initWithSpriteForCanvas: function (a) {
  17711. this.percentage = 0;
  17712. this.anchorY = this.anchorX = 0.5;
  17713. this._type = cc.ProgressTimer.TYPE_RADIAL;
  17714. this._reverseDirection = !1;
  17715. this.midPoint = cc.p(0.5, 0.5);
  17716. this.barChangeRate = cc.p(1, 1);
  17717. this.sprite = a;
  17718. return !0
  17719. },
  17720. _initWithSpriteForWebGL: function (a) {
  17721. this.percentage = 0;
  17722. this._vertexArrayBuffer = this._vertexData = null;
  17723. this._vertexDataCount = 0;
  17724. this.anchorY = this.anchorX = 0.5;
  17725. this._type = cc.ProgressTimer.TYPE_RADIAL;
  17726. this._reverseDirection = !1;
  17727. this.midPoint = cc.p(0.5, 0.5);
  17728. this.barChangeRate = cc.p(1, 1);
  17729. this.sprite = a;
  17730. this.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);
  17731. return !0
  17732. },
  17733. draw: null,
  17734. _drawForCanvas: function (a) {
  17735. a = a || cc._renderContext;
  17736. var b = this._sprite;
  17737. "source" != b._blendFuncStr && (a.globalCompositeOperation = b._blendFuncStr);
  17738. var c = cc.view.getScaleX(),
  17739. d = cc.view.getScaleY();
  17740. a.globalAlpha = b._displayedOpacity / 255;
  17741. var e = b._rect,
  17742. f = b._contentSize,
  17743. g = b._offsetPosition,
  17744. h = b._drawSize_Canvas,
  17745. k = 0 | g.x,
  17746. m = -g.y - e.height,
  17747. n = b._textureRect_Canvas;
  17748. h.width = e.width * c;
  17749. h.height = e.height * d;
  17750. a.save();
  17751. b._flippedX && (k = -g.x - e.width, a.scale(-1, 1));
  17752. b._flippedY && (m = g.y, a.scale(1, -1));
  17753. k *= c;
  17754. m *= d;
  17755. this._type == cc.ProgressTimer.TYPE_BAR ? (e = this._barRect, a.beginPath(), a.rect(e.x * c, e.y * d, e.width * c, e.height * d), a.clip(), a.closePath()) : this._type == cc.ProgressTimer.TYPE_RADIAL && (e = this._origin.x * c, g = this._origin.y * d, a.beginPath(), a.arc(e, g, this._radius * d, Math.PI / 180 * this._startAngle, Math.PI / 180 * this._endAngle, this._counterClockWise), a.lineTo(e, g), a.clip(), a.closePath());
  17756. b._texture && n.validRect ? (c = b._texture.getHtmlElementObj(), b._colorized ? a.drawImage(c, 0, 0, n.width, n.height, k, m, h.width, h.height) : a.drawImage(c, n.x, n.y, n.width, n.height, k, m, h.width, h.height)) : 0 !== f.width && (b = this.color, a.fillStyle = "rgba(" + b.r + "," + b.g + "," + b.b + ",1)", a.fillRect(k, m, f.width * c, f.height * d));
  17757. a.restore();
  17758. cc.incrementGLDraws(1)
  17759. },
  17760. _drawForWebGL: function (a) {
  17761. a = a || cc._renderContext;
  17762. if (this._vertexData && this._sprite) {
  17763. cc.nodeDrawSetup(this);
  17764. var b = this._sprite.getBlendFunc();
  17765. cc.glBlendFunc(b.src, b.dst);
  17766. cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
  17767. cc.glBindTexture2D(this._sprite.texture);
  17768. a.bindBuffer(a.ARRAY_BUFFER, this._vertexWebGLBuffer);
  17769. this._vertexDataDirty && (a.bufferData(a.ARRAY_BUFFER, this._vertexArrayBuffer, a.DYNAMIC_DRAW), this._vertexDataDirty = !1);
  17770. b = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  17771. a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, a.FLOAT, !1, b, 0);
  17772. a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, a.UNSIGNED_BYTE, !0, b, 8);
  17773. a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, a.FLOAT, !1, b, 12);
  17774. this._type === cc.ProgressTimer.TYPE_RADIAL ? a.drawArrays(a.TRIANGLE_FAN, 0, this._vertexDataCount) : this._type == cc.ProgressTimer.TYPE_BAR && (this._reverseDirection ? (a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount / 2), a.drawArrays(a.TRIANGLE_STRIP, 4, this._vertexDataCount / 2), cc.g_NumberOfDraws++) : a.drawArrays(a.TRIANGLE_STRIP, 0, this._vertexDataCount));
  17775. cc.g_NumberOfDraws++
  17776. }
  17777. },
  17778. _updateRadial: function () {
  17779. if (this._sprite) {
  17780. var a,
  17781. b = this._midPoint;
  17782. a = this._percentage / 100;
  17783. var c = 2 * cc.PI * (this._reverseDirection ? a : 1 - a),
  17784. d = cc.p(b.x, 1),
  17785. e = cc.pRotateByAngle(d, b, c),
  17786. c = 0;
  17787. if (0 == a) e = d,
  17788. c = 0;
  17789. else if (1 == a) e = d,
  17790. c = 4;
  17791. else {
  17792. var f = cc.FLT_MAX,
  17793. g = cc.ProgressTimer.TEXTURE_COORDS_COUNT;
  17794. for (a = 0; a <= g; ++a) {
  17795. var h = (a + (g - 1)) % g,
  17796. k = this._boundaryTexCoord(a % g),
  17797. h = this._boundaryTexCoord(h);
  17798. 0 == a ? h = cc.pLerp(k, h, 1 - b.x) : 4 == a && (k = cc.pLerp(k, h, 1 - b.x));
  17799. var m = cc.p(0, 0);
  17800. cc.pLineIntersect(k, h, b, e, m) && (0 != a && 4 != a || 0 <= m.x && 1 >= m.x) && 0 <= m.y && m.y < f && (f = m.y, c = a)
  17801. }
  17802. e = cc.pAdd(b, cc.pMult(cc.pSub(e, b), f))
  17803. }
  17804. f = !0;
  17805. this._vertexDataCount != c + 3 && (f = !1, this._vertexArrayBuffer = this._vertexData = null, this._vertexDataCount = 0);
  17806. if (!this._vertexData) {
  17807. g = this._vertexDataCount = c + 3;
  17808. k = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  17809. this._vertexArrayBuffer = new ArrayBuffer(g * k);
  17810. h = [];
  17811. for (a = 0; a < g; a++) h[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * k);
  17812. this._vertexData = h;
  17813. if (!this._vertexData) {
  17814. cc.log("cc.ProgressTimer._updateRadial() : Not enough memory");
  17815. return
  17816. }
  17817. }
  17818. this._updateColor();
  17819. g = this._vertexData;
  17820. if (!f) for (g[0].texCoords = this._textureCoordFromAlphaPoint(b), g[0].vertices = this._vertexFromAlphaPoint(b), g[1].texCoords = this._textureCoordFromAlphaPoint(d), g[1].vertices = this._vertexFromAlphaPoint(d), a = 0; a < c; a++) b = this._boundaryTexCoord(a),
  17821. g[a + 2].texCoords = this._textureCoordFromAlphaPoint(b),
  17822. g[a + 2].vertices = this._vertexFromAlphaPoint(b);
  17823. g[this._vertexDataCount - 1].texCoords = this._textureCoordFromAlphaPoint(e);
  17824. g[this._vertexDataCount - 1].vertices = this._vertexFromAlphaPoint(e)
  17825. }
  17826. },
  17827. _updateBar: function () {
  17828. if (this._sprite) {
  17829. var a,
  17830. b = this._percentage / 100,
  17831. c = this._barChangeRate,
  17832. c = cc.pMult(cc.p(1 - c.x + b * c.x, 1 - c.y + b * c.y), 0.5),
  17833. b = cc.pSub(this._midPoint, c),
  17834. c = cc.pAdd(this._midPoint, c);
  17835. 0 > b.x && (c.x += -b.x, b.x = 0);
  17836. 1 < c.x && (b.x -= c.x - 1, c.x = 1);
  17837. 0 > b.y && (c.y += -b.y, b.y = 0);
  17838. 1 < c.y && (b.y -= c.y - 1, c.y = 1);
  17839. if (this._reverseDirection) {
  17840. if (!this._vertexData) {
  17841. this._vertexDataCount = 8;
  17842. var d = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
  17843. this._vertexArrayBuffer = new ArrayBuffer(8 * d);
  17844. var e = [];
  17845. for (a = 0; 8 > a; a++) e[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * d);
  17846. e[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 1));
  17847. e[0].vertices = this._vertexFromAlphaPoint(cc.p(0, 1));
  17848. e[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(0, 0));
  17849. e[1].vertices = this._vertexFromAlphaPoint(cc.p(0, 0));
  17850. e[6].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 1));
  17851. e[6].vertices = this._vertexFromAlphaPoint(cc.p(1, 1));
  17852. e[7].texCoords = this._textureCoordFromAlphaPoint(cc.p(1, 0));
  17853. e[7].vertices = this._vertexFromAlphaPoint(cc.p(1, 0));
  17854. this._vertexData = e
  17855. }
  17856. a = this._vertexData;
  17857. a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(b.x, c.y));
  17858. a[2].vertices = this._vertexFromAlphaPoint(cc.p(b.x, c.y));
  17859. a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(b.x, b.y));
  17860. a[3].vertices = this._vertexFromAlphaPoint(cc.p(b.x, b.y));
  17861. a[4].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
  17862. a[4].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
  17863. a[5].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, b.y));
  17864. a[5].vertices = this._vertexFromAlphaPoint(cc.p(c.x, b.y))
  17865. } else {
  17866. if (!this._vertexData) for (this._vertexDataCount = 4, d = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT, this._vertexArrayBuffer = new ArrayBuffer(4 * d), this._vertexData = [], a = 0; 4 > a; a++) this._vertexData[a] = new cc.V2F_C4B_T2F(null, null, null, this._vertexArrayBuffer, a * d);
  17867. a = this._vertexData;
  17868. a[0].texCoords = this._textureCoordFromAlphaPoint(cc.p(b.x, c.y));
  17869. a[0].vertices = this._vertexFromAlphaPoint(cc.p(b.x, c.y));
  17870. a[1].texCoords = this._textureCoordFromAlphaPoint(cc.p(b.x, b.y));
  17871. a[1].vertices = this._vertexFromAlphaPoint(cc.p(b.x, b.y));
  17872. a[2].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, c.y));
  17873. a[2].vertices = this._vertexFromAlphaPoint(cc.p(c.x, c.y));
  17874. a[3].texCoords = this._textureCoordFromAlphaPoint(cc.p(c.x, b.y));
  17875. a[3].vertices = this._vertexFromAlphaPoint(cc.p(c.x, b.y))
  17876. }
  17877. this._updateColor()
  17878. }
  17879. },
  17880. _updateColor: function () {
  17881. if (this._sprite && this._vertexData) {
  17882. for (var a = this._sprite.quad.tl.colors, b = this._vertexData, c = 0, d = this._vertexDataCount; c < d; ++c) b[c].colors = a;
  17883. this._vertexDataDirty = !0
  17884. }
  17885. },
  17886. _updateProgress: null,
  17887. _updateProgressForCanvas: function () {
  17888. var a = this._sprite,
  17889. b = a.width,
  17890. c = a.height,
  17891. d = this._midPoint;
  17892. if (this._type == cc.ProgressTimer.TYPE_RADIAL) {
  17893. this._radius = Math.round(Math.sqrt(b * b + c * c));
  17894. var e,
  17895. f = !1,
  17896. g = this._origin;
  17897. g.x = b * d.x;
  17898. g.y = -c * d.y;
  17899. this._reverseDirection ? (e = 270, d = 270 - 3.6 * this._percentage) : (d = -90, e = -90 + 3.6 * this._percentage);
  17900. a._flippedX && (g.x -= 2 * b * this._midPoint.x, d = -d - 180, e = -e - 180, f = !f);
  17901. a._flippedY && (g.y += 2 * c * this._midPoint.y, f = !f, d = -d, e = -e);
  17902. this._startAngle = d;
  17903. this._endAngle = e;
  17904. this._counterClockWise = f
  17905. } else {
  17906. e = this._barChangeRate;
  17907. g = this._percentage / 100;
  17908. f = this._barRect;
  17909. e = cc.size(b * (1 - e.x), c * (1 - e.y));
  17910. var g = cc.size((b - e.width) * g, (c - e.height) * g),
  17911. g = cc.size(e.width + g.width, e.height + g.height),
  17912. h = cc.p(b * d.x, c * d.y);
  17913. e = h.x - g.width / 2;
  17914. 0.5 < d.x && g.width / 2 >= b - h.x && (e = b - g.width);
  17915. b = h.y - g.height / 2;
  17916. 0.5 < d.y && g.height / 2 >= c - h.y && (b = c - g.height);
  17917. f.x = 0;
  17918. c = 1;
  17919. a._flippedX && (f.x -= g.width, c = -1);
  17920. 0 < e && (f.x += e * c);
  17921. f.y = 0;
  17922. c = 1;
  17923. a._flippedY && (f.y += g.height, c = -1);
  17924. 0 < b && (f.y -= b * c);
  17925. f.width = g.width;
  17926. f.height = -g.height
  17927. }
  17928. },
  17929. _updateProgressForWebGL: function () {
  17930. var a = this._type;
  17931. a === cc.ProgressTimer.TYPE_RADIAL ? this._updateRadial() : a === cc.ProgressTimer.TYPE_BAR && this._updateBar();
  17932. this._vertexDataDirty = !0
  17933. }
  17934. });
  17935. _p = cc.ProgressTimer.prototype;
  17936. cc._renderType == cc._RENDER_TYPE_WEBGL ? (_p.ctor = _p._ctorForWebGL, _p.setReverseProgress = _p._setReverseProgressForWebGL, _p.setSprite = _p._setSpriteForWebGL, _p.setType = _p._setTypeForWebGL, _p.setReverseDirection = _p._setReverseDirectionForWebGL, _p.initWithSprite = _p._initWithSpriteForWebGL, _p.draw = _p._drawForWebGL, _p._updateProgress = _p._updateProgressForWebGL) : (_p.ctor = _p._ctorForCanvas, _p.setReverseProgress = _p._setReverseProgressForCanvas, _p.setSprite = _p._setSpriteForCanvas, _p.setType = _p._setTypeForCanvas, _p.setReverseDirection = _p._setReverseDirectionForCanvas, _p.initWithSprite = _p._initWithSpriteForCanvas, _p.draw = _p._drawForCanvas, _p._updateProgress = cc.ProgressTimer.prototype._updateProgressForCanvas);
  17937. cc.defineGetterSetter(_p, "midPoint", _p.getMidpoint, _p.setMidpoint);
  17938. cc.defineGetterSetter(_p, "barChangeRate", _p.getBarChangeRate, _p.setBarChangeRate);
  17939. cc.defineGetterSetter(_p, "type", _p.getType, _p.setType);
  17940. cc.defineGetterSetter(_p, "percentage", _p.getPercentage, _p.setPercentage);
  17941. cc.defineGetterSetter(_p, "sprite", _p.getSprite, _p.setSprite);
  17942. cc.defineGetterSetter(_p, "reverseDir", _p.isReverseDirection, _p.setReverseDirection);
  17943. cc.ProgressTimer.create = function (a) {
  17944. return new cc.ProgressTimer(a)
  17945. };
  17946. cc.ProgressTimer.TEXTURE_COORDS_COUNT = 4;
  17947. cc.ProgressTimer.TEXTURE_COORDS = 75;
  17948. cc.ProgressTimer.TYPE_RADIAL = 0;
  17949. cc.ProgressTimer.TYPE_BAR = 1;
  17950. cc.ProgressTo = cc.ActionInterval.extend({
  17951. _to: 0,
  17952. _from: 0,
  17953. ctor: function (a, b) {
  17954. cc.ActionInterval.prototype.ctor.call(this);
  17955. this._from = this._to = 0;
  17956. void 0 !== b && this.initWithDuration(a, b)
  17957. },
  17958. initWithDuration: function (a, b) {
  17959. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = b, !0) : !1
  17960. },
  17961. clone: function () {
  17962. var a = new cc.ProgressTo;
  17963. a.initWithDuration(this._duration, this._to);
  17964. return a
  17965. },
  17966. reverse: function () {
  17967. cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported.");
  17968. return null
  17969. },
  17970. startWithTarget: function (a) {
  17971. cc.ActionInterval.prototype.startWithTarget.call(this, a);
  17972. this._from = a.percentage;
  17973. 100 == this._from && (this._from = 0)
  17974. },
  17975. update: function (a) {
  17976. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  17977. }
  17978. });
  17979. cc.progressTo = function (a, b) {
  17980. return new cc.ProgressTo(a, b)
  17981. };
  17982. cc.ProgressTo.create = cc.progressTo;
  17983. cc.ProgressFromTo = cc.ActionInterval.extend({
  17984. _to: 0,
  17985. _from: 0,
  17986. ctor: function (a, b, c) {
  17987. cc.ActionInterval.prototype.ctor.call(this);
  17988. this._from = this._to = 0;
  17989. void 0 !== c && this.initWithDuration(a, b, c)
  17990. },
  17991. initWithDuration: function (a, b, c) {
  17992. return cc.ActionInterval.prototype.initWithDuration.call(this, a) ? (this._to = c, this._from = b, !0) : !1
  17993. },
  17994. clone: function () {
  17995. var a = new cc.ProgressFromTo;
  17996. a.initWithDuration(this._duration, this._from, this._to);
  17997. return a
  17998. },
  17999. reverse: function () {
  18000. return cc.progressFromTo(this._duration, this._to, this._from)
  18001. },
  18002. startWithTarget: function (a) {
  18003. cc.ActionInterval.prototype.startWithTarget.call(this, a)
  18004. },
  18005. update: function (a) {
  18006. this.target instanceof cc.ProgressTimer && (this.target.percentage = this._from + (this._to - this._from) * a)
  18007. }
  18008. });
  18009. cc.progressFromTo = function (a, b, c) {
  18010. return new cc.ProgressFromTo(a, b, c)
  18011. };
  18012. cc.ProgressFromTo.create = cc.progressFromTo;
  18013. cc.LabelAtlas = cc.AtlasNode.extend({
  18014. _string: null,
  18015. _mapStartChar: null,
  18016. _textureLoaded: !1,
  18017. _loadedEventListeners: null,
  18018. _className: "LabelAtlas",
  18019. ctor: function (a, b, c, d, e) {
  18020. cc.AtlasNode.prototype.ctor.call(this);
  18021. b && cc.LabelAtlas.prototype.initWithString.call(this, a, b, c, d, e)
  18022. },
  18023. textureLoaded: function () {
  18024. return this._textureLoaded
  18025. },
  18026. addLoadedEventListener: function (a, b) {
  18027. this._loadedEventListeners || (this._loadedEventListeners = []);
  18028. this._loadedEventListeners.push({
  18029. eventCallback: a,
  18030. eventTarget: b
  18031. })
  18032. },
  18033. _callLoadedEventCallbacks: function () {
  18034. if (this._loadedEventListeners) {
  18035. this._textureLoaded = !0;
  18036. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  18037. var d = a[b];
  18038. d.eventCallback.call(d.eventTarget, this)
  18039. }
  18040. a.length = 0
  18041. }
  18042. },
  18043. initWithString: function (a, b, c, d, e) {
  18044. var f = a + "",
  18045. g,
  18046. h;
  18047. if (void 0 === c) {
  18048. c = cc.loader.getRes(b);
  18049. if (1 !== parseInt(c.version, 10)) return cc.log("cc.LabelAtlas.initWithString(): Unsupported version. Upgrade cocos2d version"),
  18050. !1;
  18051. b = cc.path.changeBasename(b, c.textureFilename);
  18052. d = cc.contentScaleFactor();
  18053. g = parseInt(c.itemWidth, 10) / d;
  18054. h = parseInt(c.itemHeight, 10) / d;
  18055. c = String.fromCharCode(parseInt(c.firstChar, 10))
  18056. } else g = c || 0,
  18057. h = d || 0,
  18058. c = e || " ";
  18059. var k = null,
  18060. k = b instanceof cc.Texture2D ? b : cc.textureCache.addImage(b); (this._textureLoaded = b = k.isLoaded()) || k.addLoadedEventListener(function (a) {
  18061. this.initWithTexture(k, g, h, f.length);
  18062. this.string = f;
  18063. this._callLoadedEventCallbacks()
  18064. },
  18065. this);
  18066. return this.initWithTexture(k, g, h, f.length) ? (this._mapStartChar = c, this.string = f, !0) : !1
  18067. },
  18068. setColor: function (a) {
  18069. cc.AtlasNode.prototype.setColor.call(this, a);
  18070. this.updateAtlasValues()
  18071. },
  18072. getString: function () {
  18073. return this._string
  18074. },
  18075. draw: function (a) {
  18076. cc.AtlasNode.prototype.draw.call(this, a);
  18077. cc.LABELATLAS_DEBUG_DRAW && (a = this.size, a = [cc.p(0, 0), cc.p(a.width, 0), cc.p(a.width, a.height), cc.p(0, a.height)], cc._drawingUtil.drawPoly(a, 4, !0))
  18078. },
  18079. _addChildForCanvas: function (a, b, c) {
  18080. a._lateChild = !0;
  18081. cc.Node.prototype.addChild.call(this, a, b, c)
  18082. },
  18083. updateAtlasValues: null,
  18084. _updateAtlasValuesForCanvas: function () {
  18085. for (var a = this._string || "", b = a.length, c = this.texture, d = this._itemWidth, e = this._itemHeight, f = 0; f < b; f++) {
  18086. var g = a.charCodeAt(f) - this._mapStartChar.charCodeAt(0),
  18087. h = parseInt(g % this._itemsPerRow, 10),
  18088. g = parseInt(g / this._itemsPerRow, 10),
  18089. h = cc.rect(h * d, g * e, d, e),
  18090. g = a.charCodeAt(f),
  18091. k = this.getChildByTag(f);
  18092. k ? 32 == g ? (k.init(), k.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : (k.initWithTexture(c, h), k.visible = !0, k.opacity = this._displayedOpacity) : (k = new cc.Sprite, 32 == g ? (k.init(), k.setTextureRect(cc.rect(0, 0, 10, 10), !1, cc.size(0, 0))) : k.initWithTexture(c, h), cc.Node.prototype.addChild.call(this, k, 0, f));
  18093. k.setPosition(f * d + d / 2, e / 2)
  18094. }
  18095. },
  18096. _updateAtlasValuesForWebGL: function () {
  18097. var a = this._string,
  18098. b = a.length,
  18099. c = this.textureAtlas,
  18100. d = c.texture,
  18101. e = d.pixelsWidth,
  18102. d = d.pixelsHeight,
  18103. f = this._itemWidth,
  18104. g = this._itemHeight;
  18105. this._ignoreContentScaleFactor || (f = this._itemWidth * cc.contentScaleFactor(), g = this._itemHeight * cc.contentScaleFactor());
  18106. b > c.getCapacity() && cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");
  18107. for (var h = c.quads, k = this._displayedColor, k = {
  18108. r: k.r,
  18109. g: k.g,
  18110. b: k.b,
  18111. a: this._displayedOpacity
  18112. },
  18113. m = this._itemWidth, n = 0; n < b; n++) {
  18114. var q = a.charCodeAt(n) - this._mapStartChar.charCodeAt(0),
  18115. r = q % this._itemsPerRow,
  18116. s = 0 | q / this._itemsPerRow,
  18117. t;
  18118. cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? (r = (2 * r * f + 1) / (2 * e), q = r + (2 * f - 2) / (2 * e), s = (2 * s * g + 1) / (2 * d), t = s + (2 * g - 2) / (2 * d)) : (r = r * f / e, q = r + f / e, s = s * g / d, t = s + g / d);
  18119. var u = h[n],
  18120. v = u.tl,
  18121. w = u.tr,
  18122. x = u.bl,
  18123. u = u.br;
  18124. v.texCoords.u = r;
  18125. v.texCoords.v = s;
  18126. w.texCoords.u = q;
  18127. w.texCoords.v = s;
  18128. x.texCoords.u = r;
  18129. x.texCoords.v = t;
  18130. u.texCoords.u = q;
  18131. u.texCoords.v = t;
  18132. x.vertices.x = n * m;
  18133. x.vertices.y = 0;
  18134. x.vertices.z = 0;
  18135. u.vertices.x = n * m + m;
  18136. u.vertices.y = 0;
  18137. u.vertices.z = 0;
  18138. v.vertices.x = n * m;
  18139. v.vertices.y = this._itemHeight;
  18140. v.vertices.z = 0;
  18141. w.vertices.x = n * m + m;
  18142. w.vertices.y = this._itemHeight;
  18143. w.vertices.z = 0;
  18144. v.colors = k;
  18145. w.colors = k;
  18146. x.colors = k;
  18147. u.colors = k
  18148. }
  18149. 0 < b && (c.dirty = !0, a = c.totalQuads, b > a && c.increaseTotalQuadsWith(b - a))
  18150. },
  18151. setString: null,
  18152. _setStringForCanvas: function (a) {
  18153. a = String(a);
  18154. var b = a.length;
  18155. this._string = a;
  18156. this.width = b * this._itemWidth;
  18157. this.height = this._itemHeight;
  18158. if (this._children) {
  18159. a = this._children;
  18160. for (var b = a.length, c = 0; c < b; c++) {
  18161. var d = a[c];
  18162. d && !d._lateChild && (d.visible = !1)
  18163. }
  18164. }
  18165. this.updateAtlasValues();
  18166. this.quadsToDraw = b
  18167. },
  18168. _setStringForWebGL: function (a) {
  18169. a = String(a);
  18170. var b = a.length;
  18171. b > this.textureAtlas.totalQuads && this.textureAtlas.resizeCapacity(b);
  18172. this._string = a;
  18173. this.width = b * this._itemWidth;
  18174. this.height = this._itemHeight;
  18175. this.updateAtlasValues();
  18176. this.quadsToDraw = b
  18177. },
  18178. setOpacity: null,
  18179. _setOpacityForCanvas: function (a) {
  18180. if (this._displayedOpacity !== a) {
  18181. cc.AtlasNode.prototype.setOpacity.call(this, a);
  18182. for (var b = this._children, c = 0, d = b.length; c < d; c++) b[c] && (b[c].opacity = a)
  18183. }
  18184. },
  18185. _setOpacityForWebGL: function (a) {
  18186. this._opacity !== a && cc.AtlasNode.prototype.setOpacity.call(this, a)
  18187. }
  18188. });
  18189. _p = cc.LabelAtlas.prototype;
  18190. cc._renderType === cc._RENDER_TYPE_WEBGL ? (_p.updateAtlasValues = _p._updateAtlasValuesForWebGL, _p.setString = _p._setStringForWebGL, _p.setOpacity = _p._setOpacityForWebGL) : (_p.updateAtlasValues = _p._updateAtlasValuesForCanvas, _p.setString = _p._setStringForCanvas, _p.setOpacity = _p._setOpacityForCanvas, _p.addChild = _p._addChildForCanvas);
  18191. cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity);
  18192. cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
  18193. cc.LabelAtlas.create = function (a, b, c, d, e) {
  18194. return new cc.LabelAtlas(a, b, c, d, e)
  18195. };
  18196. cc.LABEL_AUTOMATIC_WIDTH = -1;
  18197. cc.LabelBMFont = cc.SpriteBatchNode.extend({
  18198. _opacityModifyRGB: !1,
  18199. _string: "",
  18200. _config: null,
  18201. _fntFile: "",
  18202. _initialString: "",
  18203. _alignment: cc.TEXT_ALIGNMENT_CENTER,
  18204. _width: -1,
  18205. _lineBreakWithoutSpaces: !1,
  18206. _imageOffset: null,
  18207. _reusedChar: null,
  18208. _displayedOpacity: 255,
  18209. _realOpacity: 255,
  18210. _displayedColor: null,
  18211. _realColor: null,
  18212. _cascadeColorEnabled: !0,
  18213. _cascadeOpacityEnabled: !0,
  18214. _textureLoaded: !1,
  18215. _loadedEventListeners: null,
  18216. _className: "LabelBMFont",
  18217. _setString: function (a, b) {
  18218. b ? this._initialString = a : this._string = a;
  18219. var c = this._children;
  18220. if (c) for (var d = 0; d < c.length; d++) {
  18221. var e = c[d];
  18222. e && e.setVisible(!1)
  18223. }
  18224. this._textureLoaded && (this.createFontChars(), b && this.updateLabel())
  18225. },
  18226. ctor: function (a, b, c, d, e) {
  18227. cc.SpriteBatchNode.prototype.ctor.call(this);
  18228. this._imageOffset = cc.p(0, 0);
  18229. this._displayedColor = cc.color(255, 255, 255, 255);
  18230. this._realColor = cc.color(255, 255, 255, 255);
  18231. this._reusedChar = [];
  18232. this.initWithString(a, b, c, d, e)
  18233. },
  18234. textureLoaded: function () {
  18235. return this._textureLoaded
  18236. },
  18237. addLoadedEventListener: function (a, b) {
  18238. this._loadedEventListeners || (this._loadedEventListeners = []);
  18239. this._loadedEventListeners.push({
  18240. eventCallback: a,
  18241. eventTarget: b
  18242. })
  18243. },
  18244. _callLoadedEventCallbacks: function () {
  18245. if (this._loadedEventListeners) {
  18246. for (var a = this._loadedEventListeners, b = 0, c = a.length; b < c; b++) {
  18247. var d = a[b];
  18248. d.eventCallback.call(d.eventTarget, this)
  18249. }
  18250. a.length = 0
  18251. }
  18252. },
  18253. draw: function (a) {
  18254. cc.SpriteBatchNode.prototype.draw.call(this, a);
  18255. if (cc.LABELBMFONT_DEBUG_DRAW) {
  18256. a = this.getContentSize();
  18257. var b = cc.p(0 | -this._anchorPointInPoints.x, 0 | -this._anchorPointInPoints.y);
  18258. a = [cc.p(b.x, b.y), cc.p(b.x + a.width, b.y), cc.p(b.x +
  18259. a.width, b.y + a.height), cc.p(b.x, b.y + a.height)];
  18260. cc._drawingUtil.setDrawColor(0, 255, 0, 255);
  18261. cc._drawingUtil.drawPoly(a, 4, !0)
  18262. }
  18263. },
  18264. setColor: function (a) {
  18265. var b = this._displayedColor,
  18266. c = this._realColor;
  18267. if (c.r != a.r || c.g != a.g || c.b != a.b || c.a != a.a) b.r = c.r = a.r,
  18268. b.g = c.g = a.g,
  18269. b.b = c.b = a.b,
  18270. this._textureLoaded && this._cascadeColorEnabled && (a = cc.color.WHITE, (b = this._parent) && b.cascadeColor && (a = b.getDisplayedColor()), this.updateDisplayedColor(a))
  18271. },
  18272. isOpacityModifyRGB: function () {
  18273. return this._opacityModifyRGB
  18274. },
  18275. setOpacityModifyRGB: function (a) {
  18276. this._opacityModifyRGB = a;
  18277. if (a = this._children) for (var b = 0; b < a.length; b++) {
  18278. var c = a[b];
  18279. c && (c.opacityModifyRGB = this._opacityModifyRGB)
  18280. }
  18281. },
  18282. getOpacity: function () {
  18283. return this._realOpacity
  18284. },
  18285. getDisplayedOpacity: function () {
  18286. return this._displayedOpacity
  18287. },
  18288. setOpacity: function (a) {
  18289. this._displayedOpacity = this._realOpacity = a;
  18290. if (this._cascadeOpacityEnabled) {
  18291. var b = 255,
  18292. c = this._parent;
  18293. c && c.cascadeOpacity && (b = c.getDisplayedOpacity());
  18294. this.updateDisplayedOpacity(b)
  18295. }
  18296. this._displayedColor.a = this._realColor.a = a
  18297. },
  18298. updateDisplayedOpacity: function (a) {
  18299. this._displayedOpacity = this._realOpacity * a / 255;
  18300. a = this._children;
  18301. for (var b = 0; b < a.length; b++) {
  18302. var c = a[b];
  18303. cc._renderType == cc._RENDER_TYPE_WEBGL ? c.updateDisplayedOpacity(this._displayedOpacity) : (cc.Node.prototype.updateDisplayedOpacity.call(c, this._displayedOpacity), c.setNodeDirty())
  18304. }
  18305. this._changeTextureColor()
  18306. },
  18307. isCascadeOpacityEnabled: function () {
  18308. return !1
  18309. },
  18310. setCascadeOpacityEnabled: function (a) {
  18311. this._cascadeOpacityEnabled = a
  18312. },
  18313. getColor: function () {
  18314. var a = this._realColor;
  18315. return cc.color(a.r, a.g, a.b, a.a)
  18316. },
  18317. getDisplayedColor: function () {
  18318. var a = this._displayedColor;
  18319. return cc.color(a.r, a.g, a.b, a.a)
  18320. },
  18321. updateDisplayedColor: function (a) {
  18322. var b = this._displayedColor,
  18323. c = this._realColor;
  18324. b.r = c.r * a.r / 255;
  18325. b.g = c.g * a.g / 255;
  18326. b.b = c.b * a.b / 255;
  18327. a = this._children;
  18328. for (b = 0; b < a.length; b++) c = a[b],
  18329. cc._renderType == cc._RENDER_TYPE_WEBGL ? c.updateDisplayedColor(this._displayedColor) : (cc.Node.prototype.updateDisplayedColor.call(c, this._displayedColor), c.setNodeDirty());
  18330. this._changeTextureColor()
  18331. },
  18332. _changeTextureColor: function () {
  18333. if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
  18334. var a = this.getTexture();
  18335. if (a && 0 < a.getContentSize().width) {
  18336. var b = this._originalTexture.getHtmlElementObj();
  18337. if (b) {
  18338. var c = a.getHtmlElementObj(),
  18339. d = cc.rect(0, 0, b.width, b.height);
  18340. c instanceof HTMLCanvasElement && !this._rectRotated ? cc.generateTintImageWithMultiply(b, this._displayedColor, d, c) : (c = cc.generateTintImageWithMultiply(b, this._displayedColor, d), a = new cc.Texture2D, a.initWithElement(c), a.handleLoadedTexture());
  18341. this.setTexture(a)
  18342. }
  18343. }
  18344. }
  18345. },
  18346. isCascadeColorEnabled: function () {
  18347. return !1
  18348. },
  18349. setCascadeColorEnabled: function (a) {
  18350. this._cascadeColorEnabled = a
  18351. },
  18352. init: function () {
  18353. return this.initWithString(null, null, null, null, null)
  18354. },
  18355. initWithString: function (a, b, c, d, e) {
  18356. a = a || "";
  18357. this._config && cc.log("cc.LabelBMFont.initWithString(): re-init is no longer supported");
  18358. if (b) {
  18359. var f = cc.loader.getRes(b);
  18360. if (!f) return cc.log("cc.LabelBMFont.initWithString(): Impossible to create font. Please check file"),
  18361. !1;
  18362. this._config = f;
  18363. this._fntFile = b;
  18364. b = cc.textureCache.addImage(f.atlasName); (this._textureLoaded = f = b.isLoaded()) || b.addLoadedEventListener(function (a) {
  18365. this._textureLoaded = !0;
  18366. this.initWithTexture(a, this._initialString.length);
  18367. this.setString(this._initialString, !0);
  18368. this._callLoadedEventCallbacks()
  18369. },
  18370. this)
  18371. } else b = new cc.Texture2D,
  18372. f = new Image,
  18373. b.initWithElement(f),
  18374. this._textureLoaded = !1;
  18375. return this.initWithTexture(b, a.length) ? (this._alignment = d || cc.TEXT_ALIGNMENT_LEFT, this._imageOffset = e || cc.p(0, 0), this._width = null == c ? -1 : c, this._displayedOpacity = this._realOpacity = 255, this._displayedColor = cc.color(255, 255, 255, 255), this._realColor = cc.color(255, 255, 255, 255), this._cascadeColorEnabled = this._cascadeOpacityEnabled = !0, this._contentSize.width = 0, this._contentSize.height = 0, this.setAnchorPoint(0.5, 0.5), cc._renderType === cc._RENDER_TYPE_WEBGL && (c = this.textureAtlas.texture, this._opacityModifyRGB = c.hasPremultipliedAlpha(), d = this._reusedChar = new cc.Sprite, d.initWithTexture(c, cc.rect(0, 0, 0, 0), !1), d.batchNode = this), this.setString(a, !0), !0) : !1
  18376. },
  18377. createFontChars: function () {
  18378. var a = cc._renderType,
  18379. b = a === cc._RENDER_TYPE_CANVAS ? this.texture : this.textureAtlas.texture,
  18380. c = 0,
  18381. d = cc.size(0, 0),
  18382. e = 0,
  18383. f = 1,
  18384. g = this._string,
  18385. h = g ? g.length : 0;
  18386. if (0 !== h) {
  18387. var k,
  18388. m = this._config,
  18389. n = m.kerningDict,
  18390. q = m.commonHeight,
  18391. r = m.fontDefDictionary;
  18392. for (k = 0; k < h - 1; k++) 10 == g.charCodeAt(k) && f++;
  18393. var s = q * f,
  18394. f = -(q - q * f),
  18395. t = -1;
  18396. for (k = 0; k < h; k++) if (q = g.charCodeAt(k), 0 != q) if (10 === q) c = 0,
  18397. f -= m.commonHeight;
  18398. else {
  18399. var u = n[t << 16 | q & 65535] || 0,
  18400. v = r[q];
  18401. if (v) {
  18402. var w = cc.rect(v.rect.x, v.rect.y, v.rect.width, v.rect.height),
  18403. w = cc.rectPixelsToPoints(w);
  18404. w.x += this._imageOffset.x;
  18405. w.y += this._imageOffset.y; (t = this.getChildByTag(k)) ? 32 === q && a === cc._RENDER_TYPE_CANVAS ? t.setTextureRect(w, !1, cc.size(0, 0)) : (t.setTextureRect(w, !1), t.visible = !0) : (t = new cc.Sprite, 32 === q && a === cc._RENDER_TYPE_CANVAS && (w = cc.rect(0, 0, 0, 0)), t.initWithTexture(b, w, !1), t._newTextureWhenChangeColor = !0, this.addChild(t, 0, k));
  18406. t.opacityModifyRGB = this._opacityModifyRGB;
  18407. cc._renderType == cc._RENDER_TYPE_WEBGL ? (t.updateDisplayedColor(this._displayedColor), t.updateDisplayedOpacity(this._displayedOpacity)) : (cc.Node.prototype.updateDisplayedColor.call(t, this._displayedColor), cc.Node.prototype.updateDisplayedOpacity.call(t, this._displayedOpacity), t.setNodeDirty());
  18408. w = cc.p(c + v.xOffset + 0.5 * v.rect.width + u, f + (m.commonHeight - v.yOffset) - 0.5 * w.height * cc.contentScaleFactor());
  18409. t.setPosition(cc.pointPixelsToPoints(w));
  18410. c += v.xAdvance + u;
  18411. t = q;
  18412. e < c && (e = c)
  18413. } else cc.log("cocos2d: LabelBMFont: character not found " + g[k])
  18414. }
  18415. d.width = v && v.xAdvance < v.rect.width ? e - v.xAdvance + v.rect.width : e;
  18416. d.height = s;
  18417. this.setContentSize(cc.sizePixelsToPoints(d))
  18418. }
  18419. },
  18420. updateString: function (a) {
  18421. var b = this._children;
  18422. if (b) for (var c = 0, d = b.length; c < d; c++) {
  18423. var e = b[c];
  18424. e && (e.visible = !1)
  18425. }
  18426. this._config && this.createFontChars();
  18427. a || this.updateLabel()
  18428. },
  18429. getString: function () {
  18430. return this._initialString
  18431. },
  18432. setString: function (a, b) {
  18433. a = String(a);
  18434. null == b && (b = !0);
  18435. null != a && cc.isString(a) || (a += "");
  18436. this._initialString = a;
  18437. this._setString(a, b)
  18438. },
  18439. _setStringForSetter: function (a) {
  18440. this.setString(a, !1)
  18441. },
  18442. setCString: function (a) {
  18443. this.setString(a, !0)
  18444. },
  18445. updateLabel: function () {
  18446. this.string = this._initialString;
  18447. if (0 < this._width) {
  18448. for (var a = this._string.length, b = [], c = [], d = 1, e = 0, f = !1, g = !1, h = -1, k = -1, m = 0, n, q = 0, r = this._children.length; q < r; q++) {
  18449. for (var s = 0; !(n = this.getChildByTag(q + m + s)) ;) s++;
  18450. m += s;
  18451. if (e >= a) break;
  18452. var t = this._string[e];
  18453. g || (k = this._getLetterPosXLeft(n), g = !0);
  18454. f || (h = k, f = !0);
  18455. if (10 == t.charCodeAt(0)) {
  18456. c.push("\n");
  18457. b = b.concat(c);
  18458. c.length = 0;
  18459. f = g = !1;
  18460. h = k = -1;
  18461. q--;
  18462. m -= s;
  18463. d++;
  18464. if (e >= a) break;
  18465. k || (k = this._getLetterPosXLeft(n), g = !0);
  18466. h || (h = k, f = !0);
  18467. e++
  18468. } else if (this._isspace_unicode(t)) c.push(t),
  18469. b = b.concat(c),
  18470. c.length = 0,
  18471. g = !1,
  18472. k = -1,
  18473. e++;
  18474. else if (this._getLetterPosXRight(n) - h > this._width) if (this._lineBreakWithoutSpaces) {
  18475. this._utf8_trim_ws(c);
  18476. c.push("\n");
  18477. b = b.concat(c);
  18478. c.length = 0;
  18479. f = g = !1;
  18480. h = k = -1;
  18481. d++;
  18482. if (e >= a) break;
  18483. k || (k = this._getLetterPosXLeft(n), g = !0);
  18484. h || (h = k, f = !0);
  18485. q--
  18486. } else c.push(t),
  18487. -1 != b.lastIndexOf(" ") ? this._utf8_trim_ws(b) : b = [],
  18488. 0 < b.length && b.push("\n"),
  18489. d++,
  18490. f = !1,
  18491. h = -1,
  18492. e++;
  18493. else c.push(t),
  18494. e++
  18495. }
  18496. b = b.concat(c);
  18497. q = b.length;
  18498. n = "";
  18499. for (e = 0; e < q; ++e) n += b[e];
  18500. n += String.fromCharCode(0);
  18501. this._setString(n, !1)
  18502. }
  18503. if (this._alignment != cc.TEXT_ALIGNMENT_LEFT) for (b = e = 0, a = this._string.length, c = [], d = 0; d < a; d++) if (10 == this._string[d].charCodeAt(0) || 0 == this._string[d].charCodeAt(0)) if (q = 0, f = c.length, 0 == f) b++;
  18504. else {
  18505. if (n = e + f - 1 + b, !(0 > n) && (q = this.getChildByTag(n), null != q)) {
  18506. q = q.getPositionX() + q._getWidth() / 2;
  18507. g = 0;
  18508. switch (this._alignment) {
  18509. case cc.TEXT_ALIGNMENT_CENTER:
  18510. g = this.width / 2 - q / 2;
  18511. break;
  18512. case cc.TEXT_ALIGNMENT_RIGHT:
  18513. g = this.width - q
  18514. }
  18515. if (0 != g) for (q = 0; q < f; q++) (n = e + q + b, 0 > n || !(n = this.getChildByTag(n))) || (n.x += g);
  18516. e += f;
  18517. b++;
  18518. c.length = 0
  18519. }
  18520. } else c.push(this._string[e])
  18521. },
  18522. setAlignment: function (a) {
  18523. this._alignment = a;
  18524. this.updateLabel()
  18525. },
  18526. _getAlignment: function () {
  18527. return this._alignment
  18528. },
  18529. setBoundingWidth: function (a) {
  18530. this._width = a;
  18531. this.updateLabel()
  18532. },
  18533. _getBoundingWidth: function () {
  18534. return this._width
  18535. },
  18536. setLineBreakWithoutSpace: function (a) {
  18537. this._lineBreakWithoutSpaces = a;
  18538. this.updateLabel()
  18539. },
  18540. setScale: function (a, b) {
  18541. cc.Node.prototype.setScale.call(this, a, b);
  18542. this.updateLabel()
  18543. },
  18544. setScaleX: function (a) {
  18545. cc.Node.prototype.setScaleX.call(this, a);
  18546. this.updateLabel()
  18547. },
  18548. setScaleY: function (a) {
  18549. cc.Node.prototype.setScaleY.call(this, a);
  18550. this.updateLabel()
  18551. },
  18552. setFntFile: function (a) {
  18553. if (null != a && a != this._fntFile) {
  18554. var b = cc.loader.getRes(a);
  18555. b ? (this._fntFile = a, this._config = b, a = cc.textureCache.addImage(b.atlasName), this._textureLoaded = b = a.isLoaded(), this.texture = a, cc._renderType === cc._RENDER_TYPE_CANVAS && (this._originalTexture = this.texture), b ? this.createFontChars() : a.addLoadedEventListener(function (a) {
  18556. this._textureLoaded = !0;
  18557. this.texture = a;
  18558. this.createFontChars();
  18559. this._changeTextureColor();
  18560. this.updateLabel();
  18561. this._callLoadedEventCallbacks()
  18562. },
  18563. this)) : cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file")
  18564. }
  18565. },
  18566. getFntFile: function () {
  18567. return this._fntFile
  18568. },
  18569. setAnchorPoint: function (a, b) {
  18570. cc.Node.prototype.setAnchorPoint.call(this, a, b);
  18571. this.updateLabel()
  18572. },
  18573. _setAnchor: function (a) {
  18574. cc.Node.prototype._setAnchor.call(this, a);
  18575. this.updateLabel()
  18576. },
  18577. _setAnchorX: function (a) {
  18578. cc.Node.prototype._setAnchorX.call(this, a);
  18579. this.updateLabel()
  18580. },
  18581. _setAnchorY: function (a) {
  18582. cc.Node.prototype._setAnchorY.call(this, a);
  18583. this.updateLabel()
  18584. },
  18585. _atlasNameFromFntFile: function (a) { },
  18586. _kerningAmountForFirst: function (a, b) {
  18587. var c = 0;
  18588. if (this._configuration.kerningDictionary) {
  18589. var d = this._configuration.kerningDictionary[(a << 16 | b & 65535).toString()];
  18590. d && (c = d.amount)
  18591. }
  18592. return c
  18593. },
  18594. _getLetterPosXLeft: function (a) {
  18595. return a.getPositionX() * this._scaleX - a._getWidth() * this._scaleX * a._getAnchorX()
  18596. },
  18597. _getLetterPosXRight: function (a) {
  18598. return a.getPositionX() * this._scaleX + a._getWidth() * this._scaleX * a._getAnchorX()
  18599. },
  18600. _isspace_unicode: function (a) {
  18601. a = a.charCodeAt(0);
  18602. 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
  18603. },
  18604. _utf8_trim_ws: function (a) {
  18605. var b = a.length;
  18606. if (!(0 >= b) && (b -= 1, this._isspace_unicode(a[b]))) {
  18607. for (var c = b - 1; 0 <= c; --c) if (this._isspace_unicode(a[c])) b = c;
  18608. else break;
  18609. this._utf8_trim_from(a, b)
  18610. }
  18611. },
  18612. _utf8_trim_from: function (a, b) {
  18613. var c = a.length;
  18614. b >= c || 0 > b || a.splice(b, c)
  18615. }
  18616. });
  18617. _p = cc.LabelBMFont.prototype;
  18618. cc._renderType === cc._RENDER_TYPE_CANVAS && (cc.sys._supportCanvasNewBlendModes || (_p._changeTextureColor = function () {
  18619. if (cc._renderType != cc._RENDER_TYPE_WEBGL) {
  18620. var a,
  18621. b = this.getTexture();
  18622. if (b && 0 < b.getContentSize().width && (a = b.getHtmlElementObj())) {
  18623. var c = cc.textureCache.getTextureColors(this._originalTexture.getHtmlElementObj());
  18624. c && (a instanceof HTMLCanvasElement && !this._rectRotated ? cc.generateTintImage(a, c, this._displayedColor, null, a) : (a = cc.generateTintImage(a, c, this._displayedColor), b = new cc.Texture2D, b.initWithElement(a), b.handleLoadedTexture()), this.setTexture(b))
  18625. }
  18626. }
  18627. }), _p.setTexture = function (a) {
  18628. for (var b = this._children, c = this._displayedColor, d = 0; d < b.length; d++) {
  18629. var e = b[d],
  18630. f = e._displayedColor;
  18631. if (this._textureForCanvas == e._texture || f.r === c.r && f.g === c.g && f.b === c.b) e.texture = a
  18632. }
  18633. this._textureForCanvas = a
  18634. });
  18635. cc.defineGetterSetter(_p, "string", _p.getString, _p._setStringForSetter);
  18636. cc.defineGetterSetter(_p, "boundingWidth", _p._getBoundingWidth, _p.setBoundingWidth);
  18637. cc.defineGetterSetter(_p, "textAlign", _p._getAlignment, _p.setAlignment);
  18638. cc.LabelBMFont.create = function (a, b, c, d, e) {
  18639. return new cc.LabelBMFont(a, b, c, d, e)
  18640. };
  18641. cc._fntLoader = {
  18642. INFO_EXP: /info [^\n]*(\n|$)/gi,
  18643. COMMON_EXP: /common [^\n]*(\n|$)/gi,
  18644. PAGE_EXP: /page [^\n]*(\n|$)/gi,
  18645. CHAR_EXP: /char [^\n]*(\n|$)/gi,
  18646. KERNING_EXP: /kerning [^\n]*(\n|$)/gi,
  18647. ITEM_EXP: /\w+=[^ \r\n]+/gi,
  18648. INT_EXP: /^[\-]?\d+$/,
  18649. _parseStrToObj: function (a) {
  18650. a = a.match(this.ITEM_EXP);
  18651. var b = {};
  18652. if (a) for (var c = 0, d = a.length; c < d; c++) {
  18653. var e = a[c],
  18654. f = e.indexOf("\x3d"),
  18655. g = e.substring(0, f),
  18656. e = e.substring(f + 1);
  18657. e.match(this.INT_EXP) ? e = parseInt(e) : '"' == e[0] && (e = e.substring(1, e.length - 1));
  18658. b[g] = e
  18659. }
  18660. return b
  18661. },
  18662. parseFnt: function (a, b) {
  18663. var c = {},
  18664. d = this._parseStrToObj(a.match(this.INFO_EXP)[0]).padding.split(",");
  18665. parseInt(d[0]);
  18666. parseInt(d[1]);
  18667. parseInt(d[2]);
  18668. parseInt(d[3]);
  18669. d = this._parseStrToObj(a.match(this.COMMON_EXP)[0]);
  18670. c.commonHeight = d.lineHeight;
  18671. if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
  18672. var e = cc.configuration.getMaxTextureSize(); (d.scaleW > e.width || d.scaleH > e.height) && cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")
  18673. }
  18674. 1 !== d.pages && cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
  18675. d = this._parseStrToObj(a.match(this.PAGE_EXP)[0]);
  18676. 0 !== d.id && cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
  18677. c.atlasName = cc.path.changeBasename(b, d.file);
  18678. for (var f = a.match(this.CHAR_EXP), g = c.fontDefDictionary = {},
  18679. d = 0, e = f.length; d < e; d++) {
  18680. var h = this._parseStrToObj(f[d]);
  18681. g[h.id] = {
  18682. rect: {
  18683. x: h.x,
  18684. y: h.y,
  18685. width: h.width,
  18686. height: h.height
  18687. },
  18688. xOffset: h.xoffset,
  18689. yOffset: h.yoffset,
  18690. xAdvance: h.xadvance
  18691. }
  18692. }
  18693. f = c.kerningDict = {};
  18694. if (g = a.match(this.KERNING_EXP)) for (d = 0, e = g.length; d < e; d++) h = this._parseStrToObj(g[d]),
  18695. f[h.first << 16 | h.second & 65535] = h.amount;
  18696. return c
  18697. },
  18698. load: function (a, b, c, d) {
  18699. var e = this;
  18700. cc.loader.loadTxt(a,
  18701. function (a, c) {
  18702. if (a) return d(a);
  18703. d(null, e.parseFnt(c, b))
  18704. })
  18705. }
  18706. };
  18707. cc.loader.register(["fnt"], cc._fntLoader);
  18708. var res_img = {
  18709. WelcomeBG_jpg: "Scenes/WelcomeBG.jpg",
  18710. GoBtn_png: "Functions/Go.png",
  18711. GoBtnS_png: "Functions/GoSel.png",
  18712. RefreshBtnN_png: "Functions/RefreshN.png",
  18713. RefreshBtnS_png: "Functions/RefreshS.png",
  18714. ShareBtnN_png: "Functions/ShareN.png",
  18715. ShareBtnS_png: "Functions/ShareS.png",
  18716. TimeBar_png: "Functions/TimeBar.png",
  18717. TimeBarBtm_png: "Functions/TimeBarBtm.png",
  18718. GameBG_jpg: "Scenes/GameBG.jpg",
  18719. PauseBG_jpg: "Scenes/PauseBG.jpg",
  18720. Grid_png: "Scenes/Grid.png",
  18721. Superb_png: "Objects/Superb.png",
  18722. NumBack_png: "Objects/NumBack.png",
  18723. NumBackSel_png: "Objects/NumBackSel.png",
  18724. ScoreCycle_png: "Objects/ScoreCycle.png",
  18725. Brain_0_png: "Objects/Brain_0.png",
  18726. Brain_1_png: "Objects/Brain_1.png",
  18727. Brain_2_png: "Objects/Brain_2.png",
  18728. Brain_3_png: "Objects/Brain_3.png",
  18729. Brain_4_png: "Objects/Brain_4.png",
  18730. Brain_5_png: "Objects/Brain_5.png",
  18731. Brain_6_png: "Objects/Brain_6.png",
  18732. Brain_7_png: "Objects/Dog.png"
  18733. },
  18734. res_sound = {},
  18735. res_obj = {
  18736. Object_png: "Objects/Objects.png",
  18737. Object_plist: "Objects/Objects.plist"
  18738. },
  18739. res_ani = {},
  18740. res_font = {
  18741. NumFont: "Objects/NumFont.fnt",
  18742. NumFont_png: "Objects/NumFont.png"
  18743. },
  18744. g_resources = [res_img.WelcomeBG_jpg, res_img.GoBtn_png, res_img.GoBtnS_png, res_img.RefreshBtnN_png, res_img.RefreshBtnS_png, res_img.ShareBtnN_png, res_img.ShareBtnS_png, res_img.TimeBar_png, res_img.TimeBarBtm_png, res_img.GameBG_jpg, res_img.PauseBG_jpg, res_img.Grid_png, res_img.Superb_png, res_img.NumBack_png, res_img.NumBackSel_png, res_img.ScoreCycle_png, res_img.Brain_0_png, res_img.Brain_1_png, res_img.Brain_2_png, res_img.Brain_3_png, res_img.Brain_4_png, res_img.Brain_5_png, res_img.Brain_6_png, res_img.Brain_7_png, res_obj.Object_plist, res_obj.Object_png, res_font.NumFont, res_font.NumFont_png];
  18745. var WelcomeLayer = cc.Layer.extend({
  18746. sprite: null,
  18747. ctor: function () {
  18748. this._super()
  18749. },
  18750. init: function () {
  18751. this._super();
  18752. var a = cc.director.getWinSize();
  18753. cc.p(a.width / 2, a.height / 2);
  18754. this.sprite = cc.Sprite.create(res_img.WelcomeBG_jpg);
  18755. this.sprite.setAnchorPoint(0.5, 0.5);
  18756. this.sprite.setPosition(a.width / 2, a.height / 2);
  18757. this.sprite.setScale(a.height / this.sprite.getContentSize().height);
  18758. this.addChild(this.sprite, 0);
  18759. this_layer = this;
  18760. cc.eventManager.addListener({
  18761. prevTouchId: -1,
  18762. event: cc.EventListener.TOUCH_ALL_AT_ONCE,
  18763. swallowTouches: !0,
  18764. onTouchesBegan: function (a, c) { },
  18765. onTouchesMoved: function (a, c) { },
  18766. onTouchesEnded: function (a, c) {
  18767. this_layer.onStart()
  18768. }
  18769. },
  18770. this)
  18771. },
  18772. onStart: function () {
  18773. var a = new GameScene;
  18774. cc.director.runScene(a)
  18775. },
  18776. onHelp: function () {
  18777. cc.log("Help")
  18778. }
  18779. }),
  18780. WelcomeScene = cc.Scene.extend({
  18781. onEnter: function () {
  18782. this._super();
  18783. var a = new WelcomeLayer;
  18784. this.addChild(a);
  18785. a.init()
  18786. }
  18787. });
  18788. var GameScene = cc.Scene.extend({
  18789. onEnter: function () {
  18790. this._super();
  18791. var a = new GameLayer;
  18792. this.addChild(a)
  18793. }
  18794. }),
  18795. GameLayer = cc.Layer.extend({
  18796. countTotal: 0,
  18797. stepTime: 0,
  18798. timeBar: null,
  18799. numGrid: null,
  18800. gameBGSp: null,
  18801. scoreCycle: null,
  18802. targetNum: 10,
  18803. winSize: null,
  18804. refresh: 1,
  18805. lastTag: 0,
  18806. specialTimeTotal: 0,
  18807. specialScoreTotal: 0,
  18808. scoreCurrent: 0,
  18809. tmpScore: 0,
  18810. fontSize: 0,
  18811. tmp: 0,
  18812. batchNode: null,
  18813. selNumAccumulated: 0,
  18814. selectedNum: 0,
  18815. selectedNumArray: null,
  18816. dropNumArray: null,
  18817. numMatrix: null,
  18818. array: null,
  18819. hintArray: null,
  18820. drawLineLayer: null,
  18821. scoreLabel: null,
  18822. lastTouchLocation: null,
  18823. currentTouchLocation: null,
  18824. ctor: function (a) {
  18825. this._super();
  18826. this.tmp = a;
  18827. var b = this;
  18828. cc.eventManager.addCustomListener("NumSelected",
  18829. function (a) {
  18830. a = a._userData;
  18831. if (a.Status) b.selectedNumArray.push({
  18832. Num: a.Num,
  18833. Tag: a.Tag
  18834. });
  18835. else {
  18836. var d = 0,
  18837. e;
  18838. for (e in b.selectedNumArray) {
  18839. if (b.selectedNumArray[e].Tag == a.Tag) {
  18840. b.selectedNumArray.splice(d, 1);
  18841. break
  18842. }
  18843. d++
  18844. }
  18845. }
  18846. });
  18847. this.init()
  18848. },
  18849. init: function () {
  18850. this._super();
  18851. this.numMatrix = [];
  18852. this.selectedNumArray = [];
  18853. this.dropNumArray = [];
  18854. this.hintArray = [];
  18855. for (var a = 0; a <= NJ.Matrix; a++) {
  18856. this.numMatrix[a] = [];
  18857. for (var b = 0; b <= NJ.Matrix; b++) this.numMatrix[a][b] = 0
  18858. }
  18859. this.winSize = cc.director.getWinSize();
  18860. cc.spriteFrameCache.addSpriteFrames(res_obj.Object_plist);
  18861. cc.textureCache.addImage(res_img.NumBack_png);
  18862. cc.textureCache.addImage(res_img.NumBackSel_png);
  18863. this.gameBGSp = cc.Sprite.create(res_img.GameBG_jpg);
  18864. this.gameBGSp.setAnchorPoint(0.5, 0.5);
  18865. this.gameBGSp.setPosition(this.winSize.width / 2, this.winSize.height / 2);
  18866. this.gameBGSp.setScale(this.winSize.height / this.gameBGSp.getContentSize().height);
  18867. this.addChild(this.gameBGSp, 0);
  18868. this.numGrid = new cc.Sprite(res_img.Grid_png);
  18869. this.numGrid.setPosition(this.winSize.width / 2, this.winSize.height / 2);
  18870. this.addChild(this.numGrid, 1, NJ.Tags.GridTag);
  18871. this.targetNum = parseInt(Math.random() * NJ.Difficulty + 5);
  18872. this.scoreCycle = new cc.Sprite("#ScoreCycle.png");
  18873. a = this.scoreCycle.getTextureRect();
  18874. this.scoreCycle.setPosition(a.width / 2 * 1.2, this.winSize.height - a.height / 2 * 1.2);
  18875. this.addChild(this.scoreCycle, 10);
  18876. b = cc.repeatForever(cc.rotateBy(1, 60));
  18877. this.scoreCycle.runAction(b);
  18878. this.fontSize = parseInt(25 * a.width / 130);
  18879. a = this.scoreCycle.getPosition();
  18880. this.scoreLabel = new cc.LabelTTF("0", "Helvetica", this.fontSize);
  18881. this.scoreLabel.setPosition(a.x, a.y);
  18882. this.addChild(this.scoreLabel, 10);
  18883. a = new cc.LabelTTF("" + this.targetNum, "Helvetica", parseInt(1.6 * this.fontSize));
  18884. a.setPosition(0.9 * this.winSize.width, 0.87 * this.winSize.height);
  18885. this.addChild(a);
  18886. a = new cc.Sprite("#TimeBarBtm.png");
  18887. a.setPosition(this.winSize.width - a.getTextureRect().width / 2, this.winSize.height - a.getTextureRect().height);
  18888. this.addChild(a, 10);
  18889. b = new cc.Sprite("#TimeBar.png");
  18890. this.timeBar = new cc.ProgressTimer(b);
  18891. this.timeBar.setType(cc.ProgressTimer.TYPE_BAR);
  18892. this.timeBar.setMidpoint(cc.p(0, 1));
  18893. this.timeBar.setBarChangeRate(cc.p(1, 0));
  18894. this.timeBar.setPercentage(100);
  18895. this.timeBar.setPosition(a.getPosition().x, a.getPosition().y);
  18896. this.addChild(this.timeBar, 10);
  18897. this.addMenus();
  18898. this.initNums();
  18899. this.makeNumMatrix();
  18900. this.scheduleUpdate()
  18901. },
  18902. initNums: function () {
  18903. for (var a = NJ.Tags.NumTag, b = 0; b < NJ.Matrix; b++) for (var c = 0; c < NJ.Matrix; c++) this.makeNewNumSp(a, b, c, null),
  18904. a++
  18905. },
  18906. makeNewNumSp: function (a, b, c, d) {
  18907. d = 0 != parseInt(4 * Math.random()) ? parseInt(Math.random() * (this.targetNum - 1)) : parseInt(this.targetNum + 1 + 5 * Math.random());
  18908. d = new NumSprite(d + 1, a);
  18909. this.numGrid.addChild(d, b + c, a);
  18910. d.setPosition(0.5 * NJ.Adjust + c * NJ.Adjust, 0.5 * NJ.Adjust + NJ.Matrix * NJ.Adjust + b * NJ.Adjust);
  18911. a = new cc.MoveBy(0.1 * b, 0, -b * NJ.Adjust);
  18912. c = new cc.CallFunc(this.setVis, d);
  18913. b = new cc.MoveBy(0.1 * (NJ.Matrix - b), cc.p(0, (b - NJ.Matrix) * NJ.Adjust));
  18914. b = new cc.Sequence(a, c, b);
  18915. d.runAction(b)
  18916. },
  18917. addMenus: function () {
  18918. var a = new cc.MenuItemImage(res_img.GoBtn_png, res_img.GoBtnS_png, this.onGo, this),
  18919. b = (new cc.Sprite(res_img.GoBtn_png)).getTextureRect();
  18920. a.setPosition(this.winSize.width / 2 - b.width, b.height - this.winSize.height / 2);
  18921. a = new cc.Menu(a);
  18922. this.addChild(a, 1)
  18923. },
  18924. onGo: function () {
  18925. var a = 0,
  18926. b = 0,
  18927. c;
  18928. for (c in this.selectedNumArray) a += parseInt(this.selectedNumArray[c].Num);
  18929. var d = this.selectedNumArray.length;
  18930. if (0 < d) if (b = d * d + d * this.targetNum, 0 == a % this.targetNum) {
  18931. for (c in this.selectedNumArray) {
  18932. var e = this.numGrid.getChildByTag(this.selectedNumArray[c].Tag);
  18933. if (e) {
  18934. e.setTag(-1);
  18935. var f = this.scoreLabel.getPosition(),
  18936. f = 800 <= this.winSize.height ? cc.sequence(cc.spawn(cc.moveTo(0.7, cc.p(f.x, f.y - (this.winSize.height / 2 - NJ.Grid / 2))), cc.rotateBy(0.5, Math.random() % 2 ? 360 : -360).repeat(7), cc.fadeOut(0.5), cc.scaleTo(0.5, 0.5)), cc.callFunc(this.rmNumSp, e)) : cc.sequence(cc.scaleTo(0.3, 0), cc.callFunc(this.rmNumSp, e));
  18937. e.runAction(f)
  18938. }
  18939. }
  18940. this.countTotal += this.selectedNumArray.length;
  18941. d >= NJ.Matrix * (NJ.Matrix - 1) && this.screenShake();
  18942. this.bonusShow(a, b, d);
  18943. this.superbShow(d);
  18944. this.selectedNumArray.length = 0;
  18945. this.scoreCurrent += a + b;
  18946. this.dropAni(this.selectedNumArray.length)
  18947. } else this.countTotal -= this.selectedNumArray.length,
  18948. this.scoreCurrent -= a + b,
  18949. this.bonusShow(-a, -b)
  18950. },
  18951. vanishEff: function (a, b) {
  18952. var c = new cc.ParticleSystem(res_eff.Eff_vanish);
  18953. c.autoRemoveOnFinish = !0;
  18954. c.setPosition(b);
  18955. a.addChild(c)
  18956. },
  18957. rmLabel: function (a) {
  18958. this.removeFromParent(a, !0)
  18959. },
  18960. setVis: function (a) {
  18961. a.setVisible(!0)
  18962. },
  18963. rmNumSp: function (a) {
  18964. this.removeFromParent(a, !0)
  18965. },
  18966. screenShake: function () {
  18967. var a = cc.director.getRunningScene(),
  18968. b = cc.moveBy(0.05, cc.p(5, 0)),
  18969. c = cc.moveBy(0.05, cc.p(-5, 0)),
  18970. d = cc.moveBy(0.05, cc.p(0, 5)),
  18971. e = cc.moveBy(0.05, cc.p(0, -5)),
  18972. b = cc.sequence(b, c, d, e),
  18973. b = cc.repeat(b, 6);
  18974. a.runAction(b)
  18975. },
  18976. superbShow: function (a) {
  18977. if (a == NJ.Matrix * NJ.Matrix) {
  18978. a = new cc.Sprite("#Superb.png");
  18979. a.setPosition(this.winSize.width / 2, this.winSize.height / 2);
  18980. this.addChild(a, 100);
  18981. var b = cc.scaleTo(0.3, 1);
  18982. a.setScale(0);
  18983. b = cc.sequence(cc.delayTime(0.25), cc.scaleTo(0, 6), b.easing(cc.easeBounceOut()), cc.fadeOut(0.9), cc.callFunc(this.rmLabel, a));
  18984. a.runAction(b)
  18985. }
  18986. },
  18987. bonusShow: function (a, b, c) {
  18988. var d = null,
  18989. d = 0 < b ? "+" : "-",
  18990. e = new cc.LabelTTF(c + "\u8fde\u6d88! " + d + Math.abs(b), "Helvetica", parseInt(1.2 * this.fontSize));
  18991. b = new cc.LabelTTF(d + Math.abs(a + b), "Helvetica", parseInt(1.9 * this.fontSize));
  18992. e.color = cc.color.YELLOW;
  18993. b.color = cc.color.WHITE;
  18994. e.setPosition(0.6 * this.winSize.width, 0.87 * this.winSize.height);
  18995. b.setPosition(this.winSize.width / 2, this.winSize.height / 2);
  18996. 0 < a && this.addChild(e, 100);
  18997. e.setVisible(!1);
  18998. this.addChild(b, 100);
  18999. var f = cc.sequence(cc.blink(2, 2), cc.fadeOut(1), cc.callFunc(this.rmLabel, e));
  19000. a = cc.sequence(cc.spawn(cc.moveBy(1.3, cc.p(0, 80)), cc.fadeOut(1.3)), cc.callFunc(this.rmLabel, b));
  19001. b.runAction(a);
  19002. b.runAction(cc.callFunc(function () {
  19003. e.setVisible(!0);
  19004. e.runAction(f)
  19005. }))
  19006. },
  19007. dropAni: function (a) {
  19008. var b = NJ.Tags.NumTag,
  19009. c,
  19010. d,
  19011. e,
  19012. f;
  19013. for (a = 0; a < NJ.Matrix * NJ.Matrix; a++) {
  19014. d = 0;
  19015. c = b - NJ.Matrix;
  19016. e = this.numGrid.getChildByTag(b);
  19017. for (f = this.numGrid.getChildByTag(c) ; null == f && c >= NJ.Tags.NumTag && null != e;) e.tag = c,
  19018. c = e.tag - NJ.Matrix,
  19019. f = this.numGrid.getChildByTag(c),
  19020. d++;
  19021. null != e && (c = "" + e.tag, this.dropNumArray[c] = d);
  19022. b++
  19023. }
  19024. for (a = 0; a < NJ.Matrix * NJ.Matrix; a++) c = a + NJ.Tags.NumTag + "",
  19025. e = this.numGrid.getChildByTag(a + NJ.Tags.NumTag),
  19026. null == e ? (e = parseInt(a / NJ.Matrix), b = parseInt(a % NJ.Matrix), this.makeNewNumSp(a + NJ.Tags.NumTag, e, b, null)) : (b = parseInt(this.dropNumArray[c]), b = new cc.MoveBy(0.2, cc.p(0, -parseInt(NJ.Adjust * b))), e.runAction(b));
  19027. this.dropNumArray.length = 0
  19028. },
  19029. makeNumMatrix: function () {
  19030. for (var a, b = NJ.Tags.NumTag, c = 1; c <= NJ.Matrix; c++) for (var d = 1; d <= NJ.Matrix; d++) a = this.numGrid.getChildByTag(b),
  19031. a = a.getNum(),
  19032. this.numMatrix[d][c] = {
  19033. Num: a,
  19034. Tag: b
  19035. },
  19036. b++
  19037. },
  19038. update: function (a) {
  19039. var b = 0;
  19040. this.tmpScore < this.scoreCurrent ? (b = parseInt((this.scoreCurrent - this.tmpScore) / 4), this.tmpScore += b) : this.tmpScore > this.scoreCurrent && (b = parseInt((this.tmpScore - this.scoreCurrent) / 4), this.tmpScore -= b);
  19041. 0 == b && (this.tmpScore = this.scoreCurrent);
  19042. this.scoreLabel.setString("" + this.tmpScore);
  19043. this.stepTime += a;
  19044. 1 <= this.stepTime && (0 < this.timeBar.percentage ? this.timeBar.setPercentage(this.timeBar.percentage - 1) : (this.endGame(), this.unscheduleUpdate()), this.stepTime = 0)
  19045. },
  19046. endGame: function () {
  19047. var a = cc.color(0, 0, 0, 185),
  19048. a = new PauseLayer(a, this.scoreCurrent, this.countTotal, this.targetNum);
  19049. cc.eventManager.removeAllListeners();
  19050. this.parent.addChild(a, 10)
  19051. }
  19052. });
  19053. var NumSprite = cc.Sprite.extend({
  19054. num: 0,
  19055. tag: 0,
  19056. spriteL: null,
  19057. spriteR: null,
  19058. spriteB: null,
  19059. lastTouchLocation: null,
  19060. currentTouchLocation: null,
  19061. isSelected: 0,
  19062. isTouched: 0,
  19063. ctor: function (a, b) {
  19064. this.num = a;
  19065. this.tag = b;
  19066. var c = this;
  19067. cc.eventManager.addListener({
  19068. prevTouchId: -1,
  19069. event: cc.EventListener.TOUCH_ALL_AT_ONCE,
  19070. swallowTouches: !1,
  19071. onTouchesBegan: function (a, b) {
  19072. var d = a[0];
  19073. c.lastTouchLocation = d.getLocation();
  19074. var e = cc.rect(0, 0, c._rect.width, c._rect.height);
  19075. cc.rectContainsPoint(e, c.convertTouchToNodeSpace(d)) && (c.touchAni(), c.isTouched = 1, c.isSelected = !c.isSelected, c.isSelected ? c.setSpriteFrame("NumBackSel.png") : c.setSpriteFrame("NumBack.png"), c.disListener())
  19076. },
  19077. onTouchesMoved: function (a, b) {
  19078. var d = a[0];
  19079. c.currentTouchLocation = d.getLocation();
  19080. var e = cc.rect(0, 0, c._rect.width, c._rect.height);
  19081. cc.rectContainsPoint(e, c.convertTouchToNodeSpace(d)) ? c.isTouched || (c.isTouched = 1, c.isSelected = !c.isSelected, c.isSelected ? c.setSpriteFrame("NumBackSel.png") : c.setSpriteFrame("NumBack.png"), c.disListener(), c.touchAni()) : c.isTouched = 0
  19082. },
  19083. onTouchesEnded: function (a, b) {
  19084. c.isTouched = 0
  19085. }
  19086. },
  19087. this);
  19088. this._super("#NumBack.png");
  19089. this.spriteB = cc.Sprite.create(res_img.NumBack_png);
  19090. var d = this.spriteB.getContentSize(),
  19091. e = parseInt(5 * d.width / 8),
  19092. e = new cc.LabelBMFont("" + this.num, res_font.NumFont, e, cc.TEXT_ALIGNMENT_LEFT);
  19093. e.setPosition(d.width / 2, d.height / 2);
  19094. this.addChild(e, 1)
  19095. },
  19096. rect: function (a) {
  19097. return cc.rect(-a.width / 2, -a.height / 2, a.width, a.height)
  19098. },
  19099. touchAni: function () {
  19100. var a = new cc.ScaleTo(0.1, 1.3),
  19101. b = new cc.ScaleTo(0.1, 1),
  19102. a = new cc.Sequence(a, b);
  19103. this.runAction(a)
  19104. },
  19105. init: function () { },
  19106. numEffect: function (a) {
  19107. a = new cc.ParticleSystem(res_eff.Eff_tmp);
  19108. var b = this.getContentSize();
  19109. a.setPosition(b.width / 2, b.height / 2);
  19110. this.addChild(a, -1)
  19111. },
  19112. disListener: function () {
  19113. cc.eventManager.dispatchCustomEvent("NumSelected", {
  19114. Num: this.num,
  19115. Status: this.isSelected,
  19116. Tag: this.tag
  19117. })
  19118. },
  19119. getNum: function () {
  19120. return this.num
  19121. },
  19122. setNum: function (a) {
  19123. this.num = a
  19124. }
  19125. });
  19126. var DrawLines = cc.LayerColor.extend({
  19127. POINT_NUM: 16,
  19128. MIDDLE_POINT_R: 255,
  19129. MIDDLE_POINT_G: 255,
  19130. MIDDLE_POINT_B: 255,
  19131. MIDDLE_POINT_A: 255,
  19132. TOP_POINT_R: 255,
  19133. TOP_POINT_G: 200,
  19134. TOP_POINT_B: 0,
  19135. TOP_POINT_A: 255,
  19136. BOTTOM_POINT_R: 255,
  19137. BOTTOM_POINT_G: 255,
  19138. BOTTOM_POINT_B: 0,
  19139. BOTTOM_POINT_A: 255,
  19140. m_pointPath: null,
  19141. m_pParticle: null,
  19142. m_Index: 0,
  19143. m_bTouched: !1,
  19144. m_touchBeganPoint: null,
  19145. m_touchEndPoint: null,
  19146. m_timer: 0,
  19147. ctor: function () {
  19148. this._super();
  19149. this.init();
  19150. var a = this;
  19151. cc.eventManager.addListener({
  19152. event: cc.EventListener.TOUCH_ALL_AT_ONCE,
  19153. swallowTouches: !0,
  19154. onTouchesBegan: function (a, c) { },
  19155. onTouchesMoved: function (b, c) {
  19156. a.m_touchEndPoint = b[0].getLocation();
  19157. var d = new cc.ParticleSystem(res_eff.Eff_line);
  19158. d.setPosition(a.m_touchEndPoint);
  19159. a.addChild(d, 10)
  19160. },
  19161. onTouchesEnded: function (b, c) {
  19162. a.removeAllChildrenWithCleanup(!0)
  19163. }
  19164. },
  19165. this)
  19166. },
  19167. init: function () {
  19168. this.m_pParticle = new cc.ParticleSystem(res_eff.Eff_line);
  19169. this.addChild(this.m_pParticle, 10);
  19170. this.m_pParticle.setVisible(!1);
  19171. this.m_touchBeganPoint = this.m_touchEndPoint = cc.p(0, 0)
  19172. },
  19173. draw: function () { }
  19174. });
  19175. var NJ = NJ || {};
  19176. NJ.Grid = 480;
  19177. NJ.Matrix = 5;
  19178. NJ.Adjust = 96;
  19179. NJ.Difficulty = 6;
  19180. NJ.Tags = {
  19181. NumTag: 100,
  19182. GridTag: 1001,
  19183. LabelTag: 1002
  19184. };
  19185. NJ.ScoreLevels = {
  19186. Level_0: ["\u592a\u60e8\u4e86\uff0c", " \u300c\u7c97\u7cd9\u5927\u8111\u300d", "\u7070\u8272"],
  19187. Level_1: ["\u51d1\u5408\u5427\uff0c", " \u300c\u666e\u901a\u5927\u8111\u300d", "\u7eff\u8272"],
  19188. Level_2: ["\u8fd8\u4e0d\u9519\uff0c", " \u300c\u4f18\u79c0\u5927\u8111\u300d", "\u84dd\u8272"],
  19189. Level_3: ["\u5f88\u817b\u5bb3\uff0c", " \u300c\u7cbe\u82f1\u5927\u8111\u300d", "\u7d2b\u8272"],
  19190. Level_4: ["\u725bX\u554a~", " \u300c\u6770\u51fa\u5927\u8111\u300d\uff01", "\u6a59\u8272"],
  19191. Level_5: ["\u540a\u7206\u4e86\uff01", " \u300c\u53f2\u8bd7\u5927\u8111\u300d\uff01\uff01", "\u7ea2\u8272"],
  19192. Level_6: ["OMG\uff01", " \u300c\u4f20\u5947\u5927\u8111\u300d\uff01\uff01\uff01", "\u91d1\u8272"],
  19193. Level_7: ["\u6211\u53bb\uff01", " \u300c\u4e71\u4e22\u4e3b\u4eba\u624b\u673a\u7684\u5c0f\u72d7\u300d\uff01", ""]
  19194. };
  19195. var WeixinApi = function () {
  19196. return {
  19197. version: "2.5",
  19198. enableDebugMode: function (a) {
  19199. window.onerror = function (b, c, d, e) {
  19200. if ("function" === typeof a) a({
  19201. message: b,
  19202. script: c,
  19203. line: d,
  19204. column: e
  19205. });
  19206. else {
  19207. var f = [];
  19208. f.push("\u989d\uff0c\u4ee3\u7801\u6709\u9519\u3002\u3002\u3002");
  19209. f.push("\n\u9519\u8bef\u4fe1\u606f\uff1a", b);
  19210. f.push("\n\u51fa\u9519\u6587\u4ef6\uff1a", c);
  19211. f.push("\n\u51fa\u9519\u4f4d\u7f6e\uff1a", d + "\u884c\uff0c" + e + "\u5217");
  19212. alert(f.join(""))
  19213. }
  19214. }
  19215. },
  19216. ready: function (a) {
  19217. if (a && "function" == typeof a) {
  19218. var b = this,
  19219. c = function () {
  19220. a(b)
  19221. };
  19222. "undefined" == typeof window.WeixinJSBridge ? document.addEventListener ? document.addEventListener("WeixinJSBridgeReady", c, !1) : document.attachEvent && (document.attachEvent("WeixinJSBridgeReady", c), document.attachEvent("onWeixinJSBridgeReady", c)) : c()
  19223. }
  19224. },
  19225. shareToTimeline: function (a, b) {
  19226. b = b || {};
  19227. },
  19228. shareToWeibo: function (a, b) {
  19229. b = b || {};
  19230. },
  19231. shareToFriend: function (a, b) {
  19232. b = b || {};
  19233. },
  19234. generalShare: function (a, b) {
  19235. b = b || {};
  19236. },
  19237. addContact: function (a, b) {
  19238. b = b || {};
  19239. },
  19240. showOptionMenu: function () {
  19241. },
  19242. hideOptionMenu: function () {
  19243. },
  19244. showToolbar: function () {
  19245. },
  19246. hideToolbar: function () {
  19247. },
  19248. getNetworkType: function (a) {
  19249. },
  19250. imagePreview: function (a, b) {
  19251. },
  19252. closeWindow: function (a) {
  19253. a = a || {};
  19254. },
  19255. openInWeixin: function () {
  19256. return /MicroMessenger/i.test(navigator.userAgent)
  19257. },
  19258. getInstallState: function (a, b) {
  19259. b = b || {};
  19260. },
  19261. scanQRCode: function (a) {
  19262. a = a || {};
  19263. }
  19264. }
  19265. }();
  19266. var PauseLayer = cc.LayerColor.extend({
  19267. backSp: null,
  19268. winSize: null,
  19269. scoLevel: null,
  19270. score: 0,
  19271. count: 0,
  19272. target: 0,
  19273. ctor: function (a, b, c, d) {
  19274. this._super(a);
  19275. this.score = b;
  19276. this.count = c;
  19277. this.target = d;
  19278. this.init()
  19279. },
  19280. init: function () {
  19281. this.winSize = cc.director.getWinSize();
  19282. this.backSp = new cc.Sprite(res_img.PauseBG_jpg);
  19283. this.backSp.setPosition(this.winSize.width / 2, this.winSize.height / 2);
  19284. this.addChild(this.backSp, 0);
  19285. this.backSp.tag = 100;
  19286. this.backSp.setScale(0);
  19287. var a = this.backSp.getContentSize(),
  19288. b = this.count * this.target + parseInt(this.score / 2),
  19289. c = "",
  19290. d = 0;
  19291. 600 >= b && 0 < b ? (d = 0, c = "\u6b8b\u6b21\u54c1\u7684") : 600 < b && 1E3 >= b ? (d = 1, c = "\u4e94\u54c1\u7684") : 1E3 < b && 1500 >= b ? (d = 2, c = "\u56db\u54c1\u7684") : 1500 < b && 2200 >= b ? (d = 3, c = "\u4e09\u54c1\u7684") : 2200 < b && 3E3 >= b ? (d = 4, c = "\u4e8c\u54c1\u7684") : 3E3 < b && 3300 >= b ? (d = 5, c = "\u4e00\u54c1\u7684") : 3300 < b ? (d = 6, c = "\u6781\u54c1\u7684") : 0 >= b && (d = 7);
  19292. var e = "Level_" + d,
  19293. f = new cc.LabelTTF(NJ.ScoreLevels[e][0] + "\n\u4f60\u83b7\u5f97\u4e86\uff1a" + this.score + "\u5206,\n\u8ba1\u7b97\u80fd\u529b\uff1a" + b + ", \n\u5c5e\u4e8e\uff1a" + NJ.ScoreLevels[e][1], "Helvetica", parseInt(a.width / 16));
  19294. f.textAlign = cc.TEXT_ALIGNMENT_CENTER;
  19295. f.boundingWidth = a.width;
  19296. f.setPosition(a.width / 2, 3 * a.height / 4);
  19297. this.backSp.addChild(f, 1);
  19298. var d = res_img["Brain_" + d + "_png"],
  19299. g = new cc.Sprite(d),
  19300. h = g.getTextureRect(),
  19301. k = f.getContentSize();
  19302. g.setPosition(f.getPosition().x, f.getPosition().y - (k.height / 2 + h.width / 2));
  19303. g.setScale(0.8);
  19304. this.backSp.addChild(g, 1);
  19305. updateShare(NJ.ScoreLevels[e][1],this.score);
  19306. Play68.setRankingScoreDesc(this.score);
  19307. b = new cc.MenuItemImage(res_img.RefreshBtnN_png, res_img.RefreshBtnS_png, this.refresh, this);
  19308. c = new cc.MenuItemImage(res_img.ShareBtnN_png, res_img.ShareBtnS_png, this.share, this);
  19309. e = (new cc.Sprite(res_img.RefreshBtnN_png)).getTextureRect();
  19310. b.setPosition(a.width / 2 - e.width / 2, -a.height / 11 * 7);
  19311. c.setPosition(-b.getPosition().x, b.getPosition().y);
  19312. a = new cc.Menu(b, c);
  19313. this.backSp.addChild(a, 1);
  19314. a = cc.sequence(cc.spawn(cc.scaleTo(0.5, 1), cc.jumpBy(0.5, cc.p(0, 0), this.winSize.height / 3, 1)), cc.jumpBy(0.5, cc.p(0, 0), this.winSize.height / 20, 1));
  19315. this.backSp.runAction(a)
  19316. },
  19317. refresh: function () {
  19318. var a = new GameScene;
  19319. cc.director.runScene(a)
  19320. },
  19321. share: function () {
  19322. var a = new ShareGuideLayer;
  19323. this.parent.addChild(a, 100)
  19324. }
  19325. });
  19326. var ShareGuideLayer = cc.LayerColor.extend({
  19327. ctor: function () {
  19328. this._super(cc.color(0, 0, 0, 220));
  19329. var a = new cc.LabelTTF('\u70b9\u51fb\"+\"\u83dc\u5355\n"\u5206\u4eab\u5230\u670b\u53cb\u5708"\n\u68c0\u6d4b\u4e0b\u670b\u53cb\u4eec\u4e0d\u582a\u7684\u5927\u8111 (\u2192_\u2192)', "\u5b8b\u4f53", 30, cc.size(0.7 * cc.winSize.width, 253), cc.TEXT_ALIGNMENT_CENTER),
  19330. b = cc.director.getWinSize();
  19331. a.setPosition(b.width / 2, b.height / 2);
  19332. this.addChild(a)
  19333. },
  19334. onEnter: function () {
  19335. this._super();
  19336. var a = this;
  19337. cc.eventManager.addListener({
  19338. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  19339. onTouchBegan: function (b, c) {
  19340. a.removeFromParent()
  19341. }
  19342. },
  19343. this)
  19344. }
  19345. });
  19346. logoData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM4AAADwCAYAAABIb1sZAAAACXBIWXMAAAsTAAALEwEAmpwYAABD1WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS41LWMwMTQgNzkuMTUxNDgxLCAyMDEzLzAzLzEzLTEyOjA5OjE1ICAgICAgICAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpjcnM9Imh0dHA6Ly9ucy5hZG9iZS5jb20vY2FtZXJhLXJhdy1zZXR0aW5ncy8xLjAvIgogICAgICAgICAgICB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgICAgICAgICB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIKICAgICAgICAgICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgICAgICAgICAgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxjcnM6QWxyZWFkeUFwcGxpZWQ+VHJ1ZTwvY3JzOkFscmVhZHlBcHBsaWVkPgogICAgICAgICA8cGhvdG9zaG9wOkNvbG9yTW9kZT4zPC9waG90b3Nob3A6Q29sb3JNb2RlPgogICAgICAgICA8cGhvdG9zaG9wOkRvY3VtZW50QW5jZXN0b3JzPgogICAgICAgICAgICA8cmRmOkJhZz4KICAgICAgICAgICAgICAgPHJkZjpsaT54bXAuZGlkOjc1MDQ5MjY2RUExREUzMTE4MTE0QTc3RUM3QThCMEYzPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGk+eG1wLmRpZDo3RDE5OTdCOUREMURFMzExODExNEE3N0VDN0E4QjBGMzwvcmRmOmxpPgogICAgICAgICAgICA8L3JkZjpCYWc+CiAgICAgICAgIDwvcGhvdG9zaG9wOkRvY3VtZW50QW5jZXN0b3JzPgogICAgICAgICA8eG1wOkNyZWF0ZURhdGU+MjAxNC0wNC0xMlQxODo1MTo0OCswODowMDwveG1wOkNyZWF0ZURhdGU+CiAgICAgICAgIDx4bXA6TW9kaWZ5RGF0ZT4yMDE1LTAxLTIxVDE2OjIzOjAxKzA4OjAwPC94bXA6TW9kaWZ5RGF0ZT4KICAgICAgICAgPHhtcDpNZXRhZGF0YURhdGU+MjAxNS0wMS0yMVQxNjoyMzowMSswODowMDwveG1wOk1ldGFkYXRhRGF0ZT4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5BZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpPC94bXA6Q3JlYXRvclRvb2w+CiAgICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2UvcG5nPC9kYzpmb3JtYXQ+CiAgICAgICAgIDx4bXBNTTpIaXN0b3J5PgogICAgICAgICAgICA8cmRmOlNlcT4KICAgICAgICAgICAgICAgPHJkZjpsaSByZGY6cGFyc2VUeXBlPSJSZXNvdXJjZSI+CiAgICAgICAgICAgICAgICAgIDxzdEV2dDphY3Rpb24+ZGVyaXZlZDwvc3RFdnQ6YWN0aW9uPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6cGFyYW1ldGVycz5jb252ZXJ0ZWQgZnJvbSBpbWFnZS9qcGVnIHRvIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3A8L3N0RXZ0OnBhcmFtZXRlcnM+CiAgICAgICAgICAgICAgIDwvcmRmOmxpPgogICAgICAgICAgICAgICA8cmRmOmxpIHJkZjpwYXJzZVR5cGU9IlJlc291cmNlIj4KICAgICAgICAgICAgICAgICAgPHN0RXZ0OmFjdGlvbj5zYXZlZDwvc3RFdnQ6YWN0aW9uPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6aW5zdGFuY2VJRD54bXAuaWlkOjBFMzMzOTEyMzJDMkUzMTFCNzYzRjAwMkQwQUEzQ0FFPC9zdEV2dDppbnN0YW5jZUlEPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6d2hlbj4yMDE0LTA0LTEyVDE5OjA2OjUzKzA4OjAwPC9zdEV2dDp3aGVuPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6c29mdHdhcmVBZ2VudD5BZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3M8L3N0RXZ0OnNvZnR3YXJlQWdlbnQ+CiAgICAgICAgICAgICAgICAgIDxzdEV2dDpjaGFuZ2VkPi88L3N0RXZ0OmNoYW5nZWQ+CiAgICAgICAgICAgICAgIDwvcmRmOmxpPgogICAgICAgICAgICAgICA8cmRmOmxpIHJkZjpwYXJzZVR5cGU9IlJlc291cmNlIj4KICAgICAgICAgICAgICAgICAgPHN0RXZ0OmFjdGlvbj5zYXZlZDwvc3RFdnQ6YWN0aW9uPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6aW5zdGFuY2VJRD54bXAuaWlkOjViMTE4M2U2LTkyYmYtOTc0Zi04OGNmLTQwYTBiYmIyMTRhYzwvc3RFdnQ6aW5zdGFuY2VJRD4KICAgICAgICAgICAgICAgICAgPHN0RXZ0OndoZW4+MjAxNS0wMS0yMVQxNjoyMzowMSswODowMDwvc3RFdnQ6d2hlbj4KICAgICAgICAgICAgICAgICAgPHN0RXZ0OnNvZnR3YXJlQWdlbnQ+QWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKTwvc3RFdnQ6c29mdHdhcmVBZ2VudD4KICAgICAgICAgICAgICAgICAgPHN0RXZ0OmNoYW5nZWQ+Lzwvc3RFdnQ6Y2hhbmdlZD4KICAgICAgICAgICAgICAgPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGkgcmRmOnBhcnNlVHlwZT0iUmVzb3VyY2UiPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6YWN0aW9uPmNvbnZlcnRlZDwvc3RFdnQ6YWN0aW9uPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6cGFyYW1ldGVycz5mcm9tIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3AgdG8gaW1hZ2UvcG5nPC9zdEV2dDpwYXJhbWV0ZXJzPgogICAgICAgICAgICAgICA8L3JkZjpsaT4KICAgICAgICAgICAgICAgPHJkZjpsaSByZGY6cGFyc2VUeXBlPSJSZXNvdXJjZSI+CiAgICAgICAgICAgICAgICAgIDxzdEV2dDphY3Rpb24+ZGVyaXZlZDwvc3RFdnQ6YWN0aW9uPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6cGFyYW1ldGVycz5jb252ZXJ0ZWQgZnJvbSBhcHBsaWNhdGlvbi92bmQuYWRvYmUucGhvdG9zaG9wIHRvIGltYWdlL3BuZzwvc3RFdnQ6cGFyYW1ldGVycz4KICAgICAgICAgICAgICAgPC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGkgcmRmOnBhcnNlVHlwZT0iUmVzb3VyY2UiPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6YWN0aW9uPnNhdmVkPC9zdEV2dDphY3Rpb24+CiAgICAgICAgICAgICAgICAgIDxzdEV2dDppbnN0YW5jZUlEPnhtcC5paWQ6ZDVjMDg0NWUtZjI4NS00ZjRiLWEwZTQtMzY4NGYzZjkyMjdiPC9zdEV2dDppbnN0YW5jZUlEPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6d2hlbj4yMDE1LTAxLTIxVDE2OjIzOjAxKzA4OjAwPC9zdEV2dDp3aGVuPgogICAgICAgICAgICAgICAgICA8c3RFdnQ6c29mdHdhcmVBZ2VudD5BZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpPC9zdEV2dDpzb2Z0d2FyZUFnZW50PgogICAgICAgICAgICAgICAgICA8c3RFdnQ6Y2hhbmdlZD4vPC9zdEV2dDpjaGFuZ2VkPgogICAgICAgICAgICAgICA8L3JkZjpsaT4KICAgICAgICAgICAgPC9yZGY6U2VxPgogICAgICAgICA8L3htcE1NOkhpc3Rvcnk+CiAgICAgICAgIDx4bXBNTTpEZXJpdmVkRnJvbSByZGY6cGFyc2VUeXBlPSJSZXNvdXJjZSI+CiAgICAgICAgICAgIDxzdFJlZjppbnN0YW5jZUlEPnhtcC5paWQ6NWIxMTgzZTYtOTJiZi05NzRmLTg4Y2YtNDBhMGJiYjIxNGFjPC9zdFJlZjppbnN0YW5jZUlEPgogICAgICAgICAgICA8c3RSZWY6ZG9jdW1lbnRJRD5hZG9iZTpkb2NpZDpwaG90b3Nob3A6ZWY2NDM2OWItNDc3YS0xMWU0LWJlZDgtZTQxYWE1YTcxOWYzPC9zdFJlZjpkb2N1bWVudElEPgogICAgICAgICAgICA8c3RSZWY6b3JpZ2luYWxEb2N1bWVudElEPnhtcC5kaWQ6MEUzMzM5MTIzMkMyRTMxMUI3NjNGMDAyRDBBQTNDQUU8L3N0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD4KICAgICAgICAgPC94bXBNTTpEZXJpdmVkRnJvbT4KICAgICAgICAgPHhtcE1NOkRvY3VtZW50SUQ+YWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOmVmNjQzNjliLTQ3N2EtMTFlNC1iZWQ4LWU0MWFhNWE3MTlmMzwveG1wTU06RG9jdW1lbnRJRD4KICAgICAgICAgPHhtcE1NOkluc3RhbmNlSUQ+eG1wLmlpZDpkNWMwODQ1ZS1mMjg1LTRmNGItYTBlNC0zNjg0ZjNmOTIyN2I8L3htcE1NOkluc3RhbmNlSUQ+CiAgICAgICAgIDx4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ+eG1wLmRpZDowRTMzMzkxMjMyQzJFMzExQjc2M0YwMDJEMEFBM0NBRTwveG1wTU06T3JpZ2luYWxEb2N1bWVudElEPgogICAgICAgICA8dGlmZjpJbWFnZVdpZHRoPjE2MDwvdGlmZjpJbWFnZVdpZHRoPgogICAgICAgICA8dGlmZjpJbWFnZUxlbmd0aD4xNzI8L3RpZmY6SW1hZ2VMZW5ndGg+CiAgICAgICAgIDx0aWZmOkJpdHNQZXJTYW1wbGU+CiAgICAgICAgICAgIDxyZGY6U2VxPgogICAgICAgICAgICAgICA8cmRmOmxpPjg8L3JkZjpsaT4KICAgICAgICAgICAgICAgPHJkZjpsaT44PC9yZGY6bGk+CiAgICAgICAgICAgICAgIDxyZGY6bGk+ODwvcmRmOmxpPgogICAgICAgICAgICA8L3JkZjpTZXE+CiAgICAgICAgIDwvdGlmZjpCaXRzUGVyU2FtcGxlPgogICAgICAgICA8dGlmZjpQaG90b21ldHJpY0ludGVycHJldGF0aW9uPjI8L3RpZmY6UGhvdG9tZXRyaWNJbnRlcnByZXRhdGlvbj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHRpZmY6U2FtcGxlc1BlclBpeGVsPjM8L3RpZmY6U2FtcGxlc1BlclBpeGVsPgogICAgICAgICA8dGlmZjpYUmVzb2x1dGlvbj43MjAwMDAvMTAwMDA8L3RpZmY6WFJlc29sdXRpb24+CiAgICAgICAgIDx0aWZmOllSZXNvbHV0aW9uPjcyMDAwMC8xMDAwMDwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6UmVzb2x1dGlvblVuaXQ+MjwvdGlmZjpSZXNvbHV0aW9uVW5pdD4KICAgICAgICAgPGV4aWY6RXhpZlZlcnNpb24+MDIyMTwvZXhpZjpFeGlmVmVyc2lvbj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT42NTUzNTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+MjA2PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjI0MDwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNrZXQgZW5kPSJ3Ij8+Mo8UAQAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAynUlEQVR42uydeXgUZZ7Hv9VHujvpXCQkciQhJJySQw4VkFMEHEXUcZWdBQYQz8UBddFdWVccrxVU8ER8mMkwMDg6rsIwKoIMKgRQzoQzJCEXITdJJ510d/qo/SNdTXXVW9XVSSeQ7vf7PPVA+qiq7n4/7+94f+/7MizLgoqKyj+p6FdARUXBoaKi4FBRUXCoqCg4VFQUHCoqKgoOFRUFh4qKgkNFRcGhoqLgUFFRUXCoqCg4VFQUHCoqCg4VFQWHioqKgkNFRcGhoqLgUFFRcKioKDhUVFQUHCoqCg4VFQWHioqCQ0VFwaGioqLgUFFRcKioKDhUVBQcKioKDhUVFQWHioqCQ0VFwaGiouBQUVFwqKioZKUJtg/EMEyvvfe3frx/KgBsWL4fxSfrfL281H1cdwqFDZmZYPuQvQicQbfOSc2+ff6w7NgbwucCyOY/WXyyHrtzzvkD0I8ATrqPUgoOBSdYwIkBMBXA3PCosKn3/HvGoLGzU3y+6bM3juHIrjJ/r1UKYDuAzW6QKDgUnF4FTgyAewHMdf8LADAYtXjhs9kwGLWKTvL6Q7twpbqts/fAQfRuT1miUACHJge6R9kAcgCUuP+9l/+kxWzH/i+KFJ9s5uIRXXIJAaxw38s+4b1QUXCuB011N84TABa5LQ5R+/9WhMtFJkUnHTs7RbF1UnB/X7khWkR/LuqqXWtXbSqAl9z/Klb/9Gg88e5kRVAMKKhBn2aL5++84haYWh3Yn9eEsmoLymqsnbnvHwC87P6XumoUnB6NYdb523unJOoxZ2JfTMqKQf/0GJwcGA8b5O97nNOKcU5pOMpqrNif14if8pqw82AdTGaHP7e03g1QEwWHgtPdutcdv8QoeXFmmhHzZ/bDnIl9kZKo93quhVHhn5pwVDLSw2qpLjvudLQqvrmdB+uwM7ceW3dX+ZNEuA8ByMJRcCg4XbIy0UYN5kzoi2X3JyEzzejzxJdVGuSpdChRiV03HVjEs07P33EuJ+JZJ1Jddugg/RuazA588FUFtn5XpdSdWwzgTxQcCk4gNcgdXGf7AmbZ/UlYdl8Soo2dK84oUWlxQG1ACyOfv9GBRabTJuvGcdq6uwqv/blECUBdgoeCQ8HhKxsdGbOY7gQGAPLVOhxRd7hzmU6b5/9yimedeNDe4vN1nAV67c8lvl76MoDVFBwKTrdCM2dCX6x5cogofvFHNjDYpY1AJaNBPOvEnY5WRLIu7NAaZeMfpQkEYTLhoZfykV9sDrjloeBQcLiYpkQKmmijBp+sHIE5E/p26SI2MNihNaKeUWO4qx3THVcrBQ6oDchX63yeQwcWD7eb/LrucxsK8cGXFXIvmQY/09W0coAqRs7SZKYZcfjjmwMKTarL7gUNAAxm7YrPc1nln4u45okh+GSlbGXCV1CYOQwlUXDktU8qEZCZZsR3b43ukmvGKVdjQD2jRiTrEkEDAP1dDgxglY3L1DNqv68/f2Y/OXhi0JFFpKLgKFKOL2i6kgDgVKLS4rwqDABwu7NNMrU80WGRTTvzrU5nNH9mP6xamCr19CL4WRVBwQlNrYDEOE0goeHiFwAYwDrQ3yVtVeJZJ6Y72nzCwx/r8VerFqRiclas1NMv0WZBwZHTvVKuSUciYGTAoMlX6zzjNEqyYakuO+bazbJumxKrJKeNK0dIfb6p1OpQcKQ0yO2iEaH57q3RiioAlCpPpfNYCTlrI7Qoc+1m3OswI9NpE1mYOJezS/eUkqjHsvuTpJ7+LW0iHaLpaG+dkIprPlk5AvNn9gvYfV5WabBd0wHhbU4LMp22Lp2vnlGjnWEUAygnk9mB4QsOkgpFmwDE+no/TUeHltZJQbNqYWpAoQE6MmV3OlqR6rIj1WXv8vn8sVq+xNXYERQDOhGOgiOIa1aQnpgzoS9WLUjtlotyFc+RrOu6+0Jk3LW5tLlQcLhelBjXZKYZfQ0OBq0y04xSY1Q0QUDBASAzpyaQGbTeqEnk1PQg0EqCkAdnqpTPvuaJIQHNoPVGTc6S5CObgkOtDaHBxMr5+KFucai7FuLgrHa7HV6KNmqwMUTjGqFk6vBSKDihmxBYTnpi1YLUgBRuBo+7JhnnUHBCUOtIAW5mmpG6aEILHKGhMQ4Fx9NbLiI9sfaJoZQUYWeSbpSy2BScEBOxynfOhI51zqgUK5uCE1qxDdHarHlyCEWBFONkxsp9lxScENEK0oPzZ/ajCYHOdUIUnBAROZO2MJViIBXjSA8CU1ctRLSI1EvOmdCXWhsZhXLJEQWnQ8RJWDT97FsSHcsUCk7waxAIZSIpiXqaSVMCzg0GGuOEKDiLSA/+O7U2XYlzaIwTqm7aggDP6gzBOCebghO8ygahtmrOhL408FUombGckAUnFFoO0drMmRgflB82v9gsuxtbZprR7w5DJiU9BV3cS4eCc/1qKhGcLqz3vD+vCcDVfThJvXNnGmhnZDI7sHJDIfKLW3ztPODlemWlRWJSVgwy04yYnBkre6/RRg1SEvWkfXWmhqrFCfbloQahY6cBETSfvZyh6HxlNVbszK3D/rwm5Be3+LVJ7aqFqd220Adf4Xf8s8vnmDOhL+ZMjJd0YR9de05qW8RUdGyD6FEoLA8V7BZnamfctLIaK7burvJn+79er50H67DzYB2ijYUdK/ss9J6XNDkrRgqcqaHorgU7OMSljKSmBO/Pa8IHX1Zg58G6XvUhM9OMit00Ja7f1t1V2Lq7yrMQe8d4VyyNc0LZ4pCWPdqf14TXtpTgp7zGgF5cJhsVUMUYtd1y3q27q7DzYB2W3Z/kmRlL45wOBXM6OhuE0W3+VGCT2YGHXjqFWf9xPODQBItMZgd25ta5XVxiQmUQQnAqdTCDM1UqCObimOELDvY6t4zsesZ06/m5ej6Z69xLwQkeZck1sp6oiA6Wddm4zkbG9ZxCwQny+Iav7i656anKhO7sBPjp6WijRqozmErBCR4NEoMT6fV3sBR5piQaug8cQepeYrmoGIRY+U2wgjNVieuUkqiX27qvV1ib7raYwgoLmTgnpKxOsKajBxGDHoHFAYD5M28ISEYtJVHvNW+lJ+ObSVkx+O6t0ZLPN7XaPeM8ZdVWlNdYUVZt8Tm4S6oi8BHnrKfgBCE4pMY8f2Y/rNxQKFsYyX9/ZlokUm7QIzPNiJgI7XUzEc7XfUjV5u3Pa0JecQv25zXhp/xGr++BVGHBxTmEAdeQctWCFZws0g8u5T4tuz8Jr/1ZVNKGyVmxmJQVg8mZsUE7U3RSVgwmZcV4Us47D9ZhZ249dh6sk4RtclYsCZxB7qOUgtN7FaPETeNbHQ6cyVmxmD/zhpCdrzNnQl83MCNkLa+Esik4QeiqycUna54YgslZsSG/J44yKyU7sW07BSeIwPHlatHVbvzraKKNGlJcGDIDoXQrQ6rOBZFk1zebgkNF5SOpIBFbxlBwgii+kdjnhaoL7ppMnEPBCRZw5LJqVJ0Bx+DX90/BoaKCbEqagkNFJSWZMa5oCk4QqazGQlt7z1gdGuP0Uv1ABsdKW3qA1V1rHVBwqKgoOFRUygwRBaf3qkn4ALdsLRWNcSg40jpJm3X3q6w6dOPGkLE4dN20wEu44HwodVrBCk4esYekmbVr0mkFo4K1gIvY6+UXt4TMDtNcTCezpBMVBUcZOPvzmrq0L44v5RebPSuDZqYZu/VaUtp5sA6Prj3nNVcmJVGPNU8OCfj9SLi/1OL0YpW6f8CYnohzTGYHHlp9SnT+lEQ9Plk5ssfWK9i6uwqPrj1HdFEfeukUPns5I2DwyCxukkdjnN6tH0gWQclqNv42IKlF28tqrHhwdX7AtuCQU1mNFSs3FMq+hgRVp61NfqNcp0XB6cX6UcqVCaS27K6SBcNkdhBX0Am4i5Zb57NTMJkdARvPkjnPSQpO79Z2cgOrD+hF/nHQ9/l6YkcEidSwP5YiUPENBScI4pyTpEYcymnpQGQVy2qsUlb2h1D5HoO9Vm2zVBAdbFIa9E8KwFrZMq7nDgpOELtrH3xZEbAkwd0T4gPWqLsiJenvZfcnddnimMwOKdezCSGyploogFNK+jFNZgc++KoiIBdYMLOf7ABjtFGDVQtTe+TDfrJyhOTuC/Nn9sOaJ4Z0+Roy62xvR4iM4QAAE2x70jMMI3xoKoB9pAZ9fsuEgCxzKzeO89nLmT0+cs8toL4/rymga1/vz2vCrP84LvV0qrujQrC1qVAFB25wppJcqM9ezgjYtfOLzfgprxGmVkfQLdRuMjtw6+O/SCVW/gRgMfcHBSd4wCFaHQABHU0PVnGDvDLjVR5rQ8EJLnAA4CsQdkeONmpw+OObg6r402lSob1WDXst2Q3VJdmhTXRCpWMDAc3LAFbzH6DgBBc4gwCcAGFqb2aaEd+9NdqveMdlY2CvUcNWIV6wQqVzQZvgVNw4AwVLy1E9rIVaOEzKcj7aBCeibrPAMMROfL6jxk22ZOgkgJuED1JwggscAFgBYB3pCSXxjsvGoO1UGFpP6WCvVSu6H12yA1ETLdAlO7rtM7edCkPT3nC4bEyn3m8ca0PM7W1ej5GqrAVqcrtoTRScnm3E1+RLZhiG6LIBHSnbtU8MIVoee60addsiO904o26zImpi96ztdnl9TKfvi9PA5xs9rtmja8/5KhNqAjCNZdmTCr7vTt8Yq6Bx+Dp9d7WvUFzlZjEkKni37q7CrP84Tuxlmw8YutQ4beXdN4NDHe3qXMN0HxFjbWBZ4LUtJRi+4GCXoGGuSsUwjMrdxtTuQ+M+tISDe457rYo7B3dCanGusVlnGCYbHVm2GNLz0UYNPl+d6ZVObtobDvNRXaev2edXrQjPaO+Wz+OyMTDtDUfrqTBFsHDfuybahcgJFnxVVYY3tpYqqeErA3A/OubcsLzTAQDD+1d4qAiPSXHMHS7ev8LnPdboWlmckARHCTxc3LPmySGejFtzrgHmIzq/LE9PxDj8BIGlUAt7rQYOkwouK+OJxTQJTqj0LJgwF8KS7GjrY8Xuomq8saUU5bWKil53AnjUbXFYAjggwMI/1ASIhNC4eIdT8LdLCBfLsiwF5zqFh4t9lt2f5KkAsJVrYKvQwl6jJkKkS3ZAE+WELtnRaTcqkOK+YhfLoqzaio++qsBfvq9WWq9nArAWwMeCxs23CnxwhLCoeS4Y/3Hu9UJonO7Dwfs//yBdm6XgXKfwAB1p6/kz+2HBzH69akfq0mor/p5bh7/srsKpi37NRt0D4DmelSFZA+EPqBYcWh44/BiG4YHDP6/Dfdjdh4P3L/c891qhK0fB6WF4YtAxQDpV6XsmZ8Xi7gnxmDOx73U5eMotHLIzt64zU7cLALwN4CivUbokLADfZeMsCgdIGCEBoJUAxykAph2Azf0vd9gFEJFcOArONQBoBYCX4Of6xymJekxyb/WelRbZ4zVqJrOjo04uvxH5RR3/dnLaRBU66s5289wpPjgO3iGEBzw3jA+Lzg0Qd3DZMxUPHO48fGCs7n8tgr/5ADkFAIksDwWnZ63PS+gYLO20MtOMSEk0IDPdiJREPVISDV1e44yb559X3AJTa8f6AWXVlkDMaD0B4HsA+x588MGUgoICW15enoUXwJMsAh8gPjicVQlzQ6MHoHv++eezJkyYMGzkyJHpAwcOHKjX6z1m2mq1WisrKyvOnj1blJubW/Dmm2+ecANjAdDGOywCgBwS1oeCcw0BGgRgEYDl6KYV+Cf7mI3ZZLZ39wo5/wCwd+zYsdXbtm37Xf/+/UdERETEAIDJZGqor6+/cvr06YsFBQXVZ8+erdm8efNFgtvk5PX2XBwTBkA/efLk/u+9994DWVlZWSCnoCWbxaFDhw7+5je/+UtpaWk9ADPvsAgAErpuXi4bBefaWqB73QBlo/frHIBPARwGgHnz5g3dtGnTKxEREYrmVJeWlpYWFBSUHD58+MLWrVsLioqKTO4Gy3Bumkql0u/bt2/e5MmTb+5qQjAnJ+evS5Ys+QZAs/sQAsSB7CTB023ti2XZbjuu9fW74fMMcrtwJyAesLuej28APONOfmQDuA3AnQDmlZSUnGO7oIKCgsJp06a9CeB5AKvmzZu3qbKyso4NoIqKii7MnTv3P90d2DQAYwEMB5AEoC+AKAAGQeKhW9tXSFmcAJdtxAKY4j6mAsi6jqxKrvs4BOCIO9bQAQgHYAQQCSD6D3/4w91LliyZ19WLtbe3O6ZMmbI1MzMz7v33378zLCws4Ln62tra6kceeeS9v//97+fc6XGT2/K0Cdw2r4RFULtqhAbNSPxf9Halt0I4D0M4P+vHeUllJZPdACUDyACQie7dhbkCwCU3IJcAnAVwBt4DjVxmywAgwg1O9NChQwecP3/+deFXz1obAE04GI3Brxs5duxYzahRo+J1Oh2xbJy1NsBZewTOhmNgm/PA2huufpHaODBRWVDHjYG6/xTJa9fW1lY/+uij63fs2HFWAp52HjxcdUFQgcNINECpv5U2cFYGDrlrCN9PrI8ivFfF8+1VgsdUvPPf6AYoyX2A93iUTEfR4o5JuMfOu/38SgCXZUDmj6eE8axNhPt6MT///PPDN9988wjhD2M78jxcpqNgwtPBGJKhjhsDxpAARt8Xqsgkyd/aZrO5dDqdqGiYdVjgKPsajpINytqMNg6a1CXQJM8mPn/x4sULaWlpvwdwxX00A2h1w2MTxDtBAw4j01tL/UuyGCwBHl+1U6RiQ/49sYIxCxbkwTVh4xSOlPNLThgF1k7u8wu/AzmLKfyc/AyXwX0YAUT9+te/Hv7FF1/8VvjjOMp3wX5hrexvqoqbDlXUMKgTbpEFCQBcLRVoP/Uq2LYiv9uOKnoswm5aTbQ+OTk5ny5ZsuRLAA1uy9PihscicNl6PTiMTK+o4jU4YT2Tr6JAQFyzxBKuybcMUgAJgREWGZLAEZaUaAkAyVUEk4oh5eCRgwaC92oE4HDxTVRhYeGC9PT0OKErZfv5CS8XSkqapAXQDlvkG5rjzyo6XyfgYVNTU58sLS2tcFsdkxsezmXjUtSu7mrfPVlwxQgaBr+X1kA8H0Mt4QKRys+FAIEAjUpwPmGhIXiwCAsNhecW9uikuSV8+OUsj0qiE5Fy+6Q6IwBQ9enTJ2zp0qVDWZZVOZ1OtdPp1DocjrAtW7Y0NDc365cvX36jEBoAsBdtU9TIVdFjoUl7SD5udVg6LE0XoAEAl+ko2k+shm7cm6K29Omnn/7b+PHj33NbmjBep6WS6ah6lcWRsjCkSU1h8J7UpCH0xFLulItgdYTQSFkDfqGhQ+Lgzsvv0YUlJTrBj6gWpEdJsYy6T58+uqVLl6azLKtKS0uLj4mJiXC5XCqWZRkAjFar1WRlZaXwv9u8vLzyH374ofyjjz4qHTduXMyqVavG3HTTTYOTk5P7Sf0eBQUFpv79+4dHRkZ6LZTgaiyA7diTiuIP3cTNPhMH9uIvFMc0SqQdulIU81it1jaDwfAEgFq31eFcNm5w1AHA2V2+Wk+BIwUMv7HpBY1QK4CHVDultMxdLXEIQeTqpezwHh3nfGZOat596hcuXJg+a9asURERETEqlUo/cuTIdJfLpXJnDRkAiI+P79OnT5+Yixcvlp8+fbr81VdfPZqammpcu3btXXKNXUlW0mKxtIeHh4d19hy2E6/B1fBPn9CEjX7bZ1zDWhtgPfBgYNuRBLBLlix5NScn5yiAegCN7kQBP8PWbeB0t6smF7BysOh5wauB95hXUaC7V07jTrxjx47SgoICM8Ql5kJw1ADUs2bNSszKykpMS0vrK+jRodPp1JmZmYNUKpWLYRhWpVK5Lly4cP7w4cNn/ud//uc4rtZFsbzvLezjjz+eumjRoqU6nS5C6RcyePDg5MGDByfPmTPntkAMKzEMg65A47i83yc0AKAZ8pRPaADAUbkv4I2ItTfAWXsUmv6TvB6fPn36iJycnHxBnNkjU6y72+IwBEvDByacF7RGPPfcczdNnDgxY/DgwYP1er0xLi4uLjY2VrYUpKKioqqkpORyfn5+5TfffFP27bffVnMuVVpaWsRf//rXuUOHDk2OioqK7FRvbLO1btq06U/Lli07wHPV1OvXr5+0fPnyx9DLZT34mM+slyb1CWjTHhA9fvnyZWv//v31pHR2oKW+4V6EjXrK67H8/Pz8rKys/+W5ayaeu2YD4Oitrho/CcB3zbjBuIhbbrllwNatW59JT08fH4jeorW11fbTTz8Vv/jiiyf27Nlzb2xsbEQgPstbb72Vs3LlyiPue9RaLJbX9Xp9+PUIQ1uBeEvD8GFDiNbGfna1/G8Yng7dzetFbpJ74Fr0esv3t3fLZ1JFjxUlCSorKysHDhz4XwBqBKnptmABhwv+9TxojOPHjx/w/fffbwoPD+9zvffMFovFEh4e/joArFu37tYVK1bc1R2N3VFXD6e5Vfz88XxvEEZnInb2DNE5Kpf9l+i90fPvR8JvfyO2pgqsg27MR1DFDlP+PXUTOABgmLGX1MYWucGpJ4Bj760xDj/O4cc3OgDhW7ZsebY3QAMABoPBcPvttw/Zu3dvQ1ZWVrrw+eYDhzwNXtjIAcBeUQl7URnin31c1OABoHnPD2jZ8Z3i+7FXVIrOYyspI7429m7xKLyrscAnNOob7vULGn+sR1jGc2D0cWCtDWg/taYr7p2v1XPQG8EhJQY8licpKcmvwki+C6JPHgiVQXk9lb3hCuz1DYp79MjJ4xF123ivx6ZNm5a+d+9e14033jhA+P4rf/kC9qIy3zFTEXk3s4SH56PtwM9wNjQp+zxFZTAfz4NxdJbsuaPn3w9tnLhvctYe8pnJ0qb/plsahXb4MjD6jqEkRh+HsIznfGbiGG2cOD6zWq2QrxzpteAI4fGkoRcvXjwkLCzMKGzc5iPHYSsqgbO5xdNLy0k/JgO6EUOgT0uFcUy2JEy2sgpUPf+K4psOH50pesxoNEYDiElISDCSGrIi+A/8DCx7RNwLGwyIXTQP9W9/rLwjOXXGC5y2Az8rsjaswwJn9Tc+EgJLOlzH8l1gLdVwtVWC0UZBFTUE6oRxnoZPionkkg2q6LGi7Byjj4Mqbrpsdo+JyiIlhiohvfYa29vBAcHqhM2aNUu0ULPlXIFfDQcArMdOwXrsFEwA6uNiYLxzOuIfvE8EkCqi63G8w+HQZWRkJJCsmVI5G5rQVlBIDNZjZ89A2/F8tO07qOhcpq1fej6rraJSZK0i586SsDZHfY7qO2v2EevWnNWA/UJHpk2TcpcoaaCKGgVnJ2rTfLp3UWKXsbi4uALioYgesTqqHgCGu45XDdX58+dF+31r+sZ36WLOhiaYtn6J0sVPwXw8z9s9iI/r8odxuVyq4cOHi7J09nr/SkukYhEASHhsEdRxMYrPZfoxFwBg/uWY6LmoO6YS38O2FPv+rD5iDkfJBrSfWA3W4b0etqpPts/zCt/TccJmH+AMFj128uTJCnjXFQpXAe214EjBo7506ZJohQl1eGCyu86GJlQ9/wqaD1z140k9b2c0bty4SH9AILpYhOQB/z5jFymfW2ba8S0AoOX7H71dzWkTiFat4/s5FJDvwmU6Cvv5Td6/YcJYYjzidf3L3vfqaqmQBZUJT4e672jR41988UUhxCvdBIXFIblrKgDqTZs2XRK+QJc0IKAXrHn5ba+Egj89eXeqbd9BuCzSOxfEzp4BbXqK4iRB467vRTFW7K/nkK2NtaFTZf6SEFRvh7Pu6r6gjMbgiY8k7/nCWjjKd3mye/bzH8i+PmzEM6LH6uvrm44dO3YF0kvlBg04wkRBj1y7dv3VmEmXObLL58vOzo5UmimThefcBdnnE1Y8rvhcwrhQPyZD0tqwlvqAf8eO0s+8Xe7k2VBFj/UJj+X722E79qSstdGOXE1MiW/dujUX3uu7EdeX7q3gsDKuG1NeXl5NypIFUlzaNlBKSkoSLdtpv3TZ7/P4cu/Chw1B+LQJnbrH6LtnSrtXLSUB/5FdpqNwtVR4W4mbVvuER7aHDU9HWNZaUX0aAJSUlDQ8/fTTRwjQuHoqq9YTvT4r+L/n77a2Nqs4CIwM+A20nTrT0RgJKWZ/NXz4cNENWo+d8vs8wphEKlHgr7TpKaLxp56Qq/GMd8PXGKAb9yY0qU90ssdrBKMnb2r88ssvH4Z4IXZnTyUGetpVEy1b1NraKnL01d0Aju1cYbd9KH9S0UJL6Ou92rg+6PP4Qv+szdw7A+NTh6dDO3QltENXgglP79wP7rDAdeVI595rb+iYQWoVZyyfeeaZLIh3LuB30r3e4rAS0LgAuM6dOyfycXTpqQG/Cc4iaBMCvy27v6lovsxHjvt8Teyv7vArqRE9ZWKXP5P6hnuhn7ARmuTZ0CTPhu7m9T7dLmeDOB3uKPu6S5XSrL0B7efE43oZGRkDQZ7IGDTjOJLQAHAxDNPlD+lPTBSIQVB/YxXZ9ypIKqgMBkT/yz2Kzhc+bYJfZUiS1xSMxTAaAzSDHvLvR7c2BGQWqKvhn6L4iWEYLF26NAXSi6oEjatG3HGrpKRE1F37YxUGfPAGkv73JaT9fQui59/vuyft4jhRamqqqFXaa2o7H3sRSmR6Cnh5WBPE3x1hHEXWAtUe8W3Vpv4D+qn/gCZpgV/xEwDccccdKYLYpseg6WmLI5zq7GpoaGgNRCNRGQzEsnnPj+R2dbo6TjRq1ChjIOMnrvzGl3SpKYH7NTQRuB6kHb4UjMbQYc3SHvL/N1epXCBPn0ewgQPhB3V/+IBJKn0biPEbQHlGLXLuLMUDmEpcvUCUC3l+8MhBvt0jQsqaWCbj1TmN8X69pVo++cCrcWM0BtkYytVcSPotBkK8Nw6CBRypRf5cAFw5OTmioimpgTtFro9EcSQ/DR3I6gFbRSX5etmj0OffHlCWIPgh1zc4XSgXstlsLm9wknyXxNTsI7heR/2yZIzhBv9iGZkkgipK3CaKiopK4b18l3AZr14/jiOVJHA2NjYGbP/y2s3bJN00fqYpUNYHAGxl5cTHDSOGIeq28YqsjvXYKdnym84kQfjKy8sziX70uEk+GzG/jIZ1WOAo3eqfJfPhEnIlN8L/E60TIeYqKyurgffeOD0a52iuATD83sFpsVhsBoNBJ2zsSiZ0mQ8fga2kDOYfciUHIWMXzQtIpokke00dsYFzFiJ67p2KpkmYj530OWgZyIFhdeJEOKu3y3+2s/8LNnUJGEMCHKWfyda3MeHpojk26oSxcBTGSU5fsF9YC8elr8BoYzpV4Pn555+fgY9NpYIxq+b5f2lpaXVnYxLT1i9R//bHktCET5sgml4cyAFWa4G4MRmnXrVuSsdUrMW+09KBqHrgZ8h8DWqy9gbYL6xFe95Kn2MxmoH3EWMYX8WebFuRz3OTCjybmprqDx48WC0Ah78zXFCko0mDoJ6UdCDGcqSg6fe0uNwjkAOspJiKnwFTGQyK0uTmb//ZrT9AZWWlyBfUDgnMylaMNg7q/lPIQCXP9plqlo3tJAo8d+zY8Q06FuPg7wXqRBBOKxAmCTzrMwe67EYdF4P4Zx/HgBee6TYXDZAutdEnD0RbQSEad32P2s3bFEHhbGiSTDR4Ppex82nk999/v5xkdbrSqK827v+UXRJXO2xRp66jHbmaWOBZVVV1adGiRd/i6tpp7YI4p0fg0fQgNHw3zVOgd/78+coxY8aMEFqFlk5YmPDRmYieMjFgwLgsFljLL3kW+LAVlcB65jwGbXgbtrIK4nuK7+lcY2w7c052nKkrs2PffPPNqqeeeip5wIABBmGjBgBHxZbOQTN0paKBUe2wRVD1yYS9cKPPuUCquOnQpi+UXDX01VdfzcHV/XC8diZAD6ale2rNAa9sGs/iOBiG6fSHjZ5/P2Lvnu1XulbpYGL92x8TA3turMheK04MaNNTFC/aIXLXfsglLhvVVWVlZUUfOnQo6+mnn77w+eefZ5EaNWO4wee+OEotAml1T87Cqftu7Fhy98pJsJZLnvhGFTcdqvABUCeMl12O6r333tv00Ucf5eHq5rnXzFXraXC83DQA9ubm5pbOuiXaxISATYlWbNncQTpp+nP8IwtRu+Z9r4wgB5qvBTi4tLSUtdQnD+zU/ep0OtWtt94a+/nnn0suJaxJng11wjg4ynbCWf2NZCaM0cZBfcOvoEmZI7nKzcqVK0/NmDEjbvHixYOJ1+o/Ceg/ye/P8e677/5hxYoVe0DeRMqBHq4euJbg2AHYS0pKagLplnhdVGKZ1kDIln9WDNWIoZ4lntRxMYhdNA+xs2fAfDxP0co1cmlplcGAPo8vJJYkcVa0K7V4jD4O2mGLoB22CK6WCrDWOrAWdx2eJgIqQ4LPxQlff/31g9u2bTuzbds2V3h4+K0PPfRQlzcUttvt9g0bNmx2Q9OEq1sX8vf8dIC8zUuvBwcCV43bc6Zdo9HYA34hlsXf/va3y7/73e9KqqurJwai5+Y3UnvDFY9VUcfFeNLnKoMB0VMmwrTjW/R74RlPzGIcnYX4Zx+XdBWVVkvE/fqeHvmhVJFJgIKdCfhat27d7lWrVv3MNeJ58+Z9uX///tOrV6++Kz4+PqYz91FcXFywfPnynK+//rrIbWmaeW6aZysPeI8NBk2Mw8+o8Xc6swNoz8/PF6WTulKb9c4771x49tlnC9zXYVpbW+0RERFafs/Nb+xeUA1Ll+3ROfBUBgOG7PlC0jIM2vC26HF/45dy8xUcqi3FuearawREaXUY06c/pvQjg9bmaEdZy9VsX4Q2DMlGsSt7tK4cxS31XucGgGmJqZLnlnQxrVbrunXrtr/wwgs/81wnFgDz4Ycf1nz44YeHP/7448kLFy6822BQlrW5fPlyxQcffPC3N95446jbupjdR6sAGr616dHq6J7aA5RbiJDb2oPb/TgWQJzVav2TTqfz+lIvzlvqs3HrUlNEvfWiRYv2bN68udQNDn755ZdfjRs3LhnXgcrNV1BrMaPGcjWsy+jTz6txtznasbP8NNaVSE9yGx+ViFUZ0xCv7yjW/rr8DF4pJC/59I+J8zyv43TPT1tRaxfNWseLQ8bjruQbFX+ekydP5i1fvvxvP/300yVBoO7C1fXCub1rwhYvXpw+Y8aMYRkZGUPj4uLi+vfvPxAAysrKSi5fvlx94sSJgp07d57dtWtXhRsQizt71sYDhoOmndcJC9cb8PI+enuMA342zd1b2ABYKioqCtLT07P5bxj8102dutD27dvz3V+0EwDOnj1beC3B4UD4y6Wzko2VD87HBYfwebX8VINDzTVY8st2/HXCgwjXhCHRID3utb3sNJYOu9Xz949VhcT7UKqysrLqAwcO5OXk5OTu3bu3jOc68RuzcMtHDQBtTk5OY05Ozglc3eqR4bULj/uOq4ObVt5h413DDunVbYLGVQPvyxF+QVYAbRcvXjwtBKczqqysvGQymS7xfkC8+OKL386dO/emmJiYHt8V4WhdOX5/7ifZhlrFsz5fl5/xCQ2nWrsVa07/gNXZMxGhkd6QbdOl07g3ZZTH6uyr8W+Vm7Vr115saWlpuXTp0uUvv/zyrMlkqkHHtoEmnvtEGogExJuKCTdIZgQdKpc0aud1rHxYSCU2PQ4N98F6Oqvm5FsbAK0rVqz4P7PZXNvVi7zyyit/RMdeKbUA6gDUVVRUlH/44YebmpubA7agWElJidmTCTObHSR34FxjNZbl7/bZu1+yXF36dWPpCb/uY1dDOc41VqOvwSj7ug/OH/Tc066Gcv96Vo3G/sorrxzPycnJd0PTgI7dz7ijyQ1Rs/to4R3cY03uo5H3vgbeITxfMy971iawOHZf7lmwWRyhq9bO9T7nzp2r3bx587u//e1vlxuNxgR/T1pbW1vy+uuvb9y4ceMZ3pfLZVjU//3f/713y5Ytx9avX3/PkCFDRiYlJQ2rrKys4PYB5Y6CgoIqk8lkFdbPHTp0qMblcqmdTmfYt99+a6qoqNACiAYQ+cgjj/T95JNPbhS6Z8+f+t5v69QZFyq3ttTLFZMCbFz5GRy5Uun3+bVardUNhsnd8JsEaWELyOX9gHibF/6O3ypBx+o1rV5gWa7JooPXWzqac9dU7p6EAYBly5b9sGHDhtPr16//9eDBg0cNHDhweGVlZQXXqHkpygqz2WzWaDSOvLy8Cx9++OHJmpqaZkGvxE9NqgBoCwoKWu+8884/gryzNd91YAhWmdsQy8BLbDAANJMmTYoWftB9l5XHEaWWjuky/ISBPzpwpQJLcavP120sPdEpMDUaTTvPevCtCd9Ns4O8BK1w82TuEG4ERZzoSDjAPz/Lsmx3jdNdT8kBvqtG2kWLPXPmjOOOO+74I7y3bucaNienRBBJKr8gbWrFAUOCRsW7H0aQGdK7z+9yvy4MQMS4ceNE4Hxfc1HxF3O+rQOcghayJ5mg1WN0VAJMdhsONddIvn92XLKsG6YEGlKSoaysrN4NCP/gZ7psEM+HEe78zUj85oygffAhgpR1YbszFXydWxwOoHbec05B0kDYsEGIk/iBIz/bIuz1VIQAVSNwHRie+6CC9/aLOve9cd+ZgXNPSOsQkBq4EIZ7EtPRj9dQm+02cnwy+leerNs7Z35UnDzojEhJBpPJ1MzLbFl4h1XwnQsbPwjwCB8jZV4BiYUFrwdgrlWMw68ekEpTc+CQGjYryMA4eP41P0VJ8rPVgkMlA41K4KI53K/R8qwaO3PmzBjhByw3y6/OOT4qEa/dNAvhgkY60BAleu3suGSvVPWd/YdJghOl1XVP9kilcsB77osww+WAuEZMbs1wZQ3lOoLkerA4QlMsdOE4APiNm2/eSVZLSXpSJfCzGZ4V47tnQmi0PNeSA4gbo2D69Omj9/dLWJUxTQQNAC/rI6URsdILYAyLjAe6aI1aHeIlIBITE7U8UPiwOOHflGVWAhD0RmmuwTVdBN+WD4Fa0ND5/rBwmSmn4P18KMFr5Ep8baFl0vLiGU8RoUqlUu3Zs+eeadOmjSYFpqQSF74FEY7iy8UXQtVbzaLHhodHB+yHISUo0tPTo2U6p2uWDr7W6un9caRmgjp4cYpNwqduE/xrEbgQdoG75oB3QalDEBfxkwv8BANpvAAAmAceeKB/dXX1qunTp4+Wy+Z0pjGPJFiTXQ3lXrCcaawSvea2PkmScZSvOGt8VKISV82F62DAMdTBAcgr3vAPu0TDtkn42kLXgbRnivA6DoH70S74W5hgUAHQvPPOO0v79u3bz9cHlGrMXOqZpHBNGJYOHCV6/M/FHYuZtzna8XaheMnciQmDAACDI70LY0dHJeDFIdIr5zw26CZEK4iL3OA4fGTOKDg9DZBbUo1b2MB9gcIG4OAHs5zbpvnjH/84JSkpSVEF5L0poyRTz1+Xn/HrfZ9XF+Ken7Zi+o9/FqWUZ8cly8Y9dyXfSIRxdlwy7kq+UVFCQa1WS33PCGV4VNfLjbCdVDf9eKIR78zMTFELbHO04+vyM1h9cje+Lj+DNndwHa834ulU8lz8VwoPYVPBYZxrrMa5xmp8XX7Gk4mL1xuJVoI0BpOg1WNJuvSysdyYztJht3q5ZAlaPZYNn3A1oeArCNZoHCBPTw5pi6MBFQkYITyqlJSUEaIM2YnvPGM2uxrKceRKJVZnd2wj+NDg0TjcUEkc09l06TQ2XTrt+fufUxZ6WQmzwyY7rSBBq/ca3wGAlEjppMRrN83y3Otjg26STFDIWBzhGJmLgkMlBZCX4uPjRXPohVAcb/auU103bg4+u3hcFoLh4dGi9PRDg0cjM7Y/vr1c4DVuww2c8qud+TESd75BhmjRc0+PmIikslNe821uSUhBDi82IhWL5ubm5kNcys+GurvWUxPZ5Fy0br+GH7BwlQL8urRIADHV1dUbEhMTvazOpoLDXpbjzZFTiDMozzVWI7e2FH+vKfJyu4aHR+NfBoz0OXms3HwF4ZowvyxFoDxohmHuQUdxJ1erxmU1+e5bV1z0bv39u6t9U3C8wREWdIYDMAKI/vnnn1fcfPPND5Aadau9HX0NxmvRsLtVxcXFuenp6S8SoBGuZxZy4Kh6+4/LsmygDmHJiFfq+t13391Jun6ysQ9GxN4QdNC0tbVdWbBgwVsQryjj5ap19XunWbXgkFRJT/u2bdtKjh49+n/dfQOFhYWKt7E+cODAxba2tk5tlWIymcwSwDQWFxfnzpgx4+FDhw5VSbhmzlDPrPV6Vy3A96sSxDk6t8tmcLtsxl9++eWpcePGya6kbrFYbL///e/3P/LII1mDBw9WtKkpy7JYv3797meeeeb4fffdl7Bw4cLhGRkZSWlpaZ7RVKvVai0sLCw7efJk+caNG0/n5uY23nLLLVEvvPDCLRkZGcmpqakpjY2NjXV1dY0AkJ+fX/rjjz+W1dTUWGfNmpU8ZsyYlBMnTpTs2bPn4qefflp2xx13xIwbNy5ao9E4NBqNPT8/v+KLL74ocYPCTVLjKjQ498xra41rXYxJY5zrAxxhrZoQnnAAEf/6r/+avmbNmqf69es3XK1We1JiLS0tzUVFRaVPPvnkrsOHDzcDYG677bbYxx57bFR2dnZyenr6IL1e76mFaWpqunLhwoWSEydOXHz88ccPwrvezjNe8vDDDydXVVW1fvPNN3UE6yjMBMpVKfPPzS9JElZr8BfIEJY0eY3nUHAoOBw4wgUmOHg4gPS8Q/f000+P6Nu3b8wvv/zSsH379np4V2DzGzS/IfOLUYWFqsICSj4kJBCUgiO8NqnUyQ5xPR+/WoMPjet6KP2n4Fw/4JBmjXIA8SHiT70mzR2SAocEA8nSkEpbOjN2wkrEcMIF8PmFsSRYhPV/bCiDQwdAvb9kbg47v1cWNjjOteHPJFUpgAYS1kMIitxiFL4mi0HB8y4CQC4CRE5BksTr/tjenBKj4HR7ds0JcSW3GuLJdvyFPuSmCLMSAJHm2cu5aCRAGJm4BjLXJe2U5yLFWqA1ahQcBVaHm3AnnN6txtWp1PxFPoSQMArABAEWl0xsotSqKOkUWAUwiV4f6paGgqPcZVPxXDbu/0JYGPg5p54AhT9Wxh9oWD8fE4FKYaHg+AsPw3OhGIJbxCiwLkrBUfJ4VyyN6PPRX5mC023w8P9kemD1O9qge4cY+jtRUfkvWqtGRUXBoaKi4FBRUXCoqCg4VFQUHCoqKgoOFRUFh4qKgkNFRcGhoqLgUFFRUXCoqCg4VFQUHCoqCg4VFQWHioqKgkNFRcGhoqLgUFFRcKioKDhUVFQUHCoqCg4VFQWHioqCQ0VFwaGioqLgUFFRcKioKDhUVBQcKqpQ0/8PAPoEKu8ItdqpAAAAAElFTkSuQmCC";
  19347. sceneLoad = cc.Scene.extend({
  19348. _interval: null,
  19349. _label: null,
  19350. _className: "LoaderScene",
  19351. init: function () {
  19352. var a = this,
  19353. b = 200,
  19354. c = a._bgLayer = new cc.LayerColor(cc.color(4, 5, 23, 255));
  19355. c.setPosition(cc.visibleRect.bottomLeft);
  19356. a.addChild(c, 0);
  19357. var d = 24,
  19358. e = -b / 2 + 100;
  19359. cc._loaderImage && (cc.loader.loadImg(logoData, {
  19360. isCrossOrigin: !1
  19361. },
  19362. function (c, d) {
  19363. b = d.height;
  19364. a._initStage(d, cc.visibleRect.center)
  19365. }), d = 14, e = -b / 2 - 10);
  19366. d = a._label = cc.LabelTTF.create("\u6570\u4e0d\u72ec\u52a0\u8f7d\u4e2d... 0%", "Arial", d);
  19367. d.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(0, e)));
  19368. d.setColor(cc.color(180, 180, 180));
  19369. c.addChild(this._label, 10);
  19370. return !0
  19371. },
  19372. _initStage: function (a, b) {
  19373. var c = this._texture2d = new cc.Texture2D;
  19374. c.initWithElement(a);
  19375. c.handleLoadedTexture();
  19376. c = this._logo = cc.Sprite.create(c);
  19377. c.setScale(cc.contentScaleFactor());
  19378. c.x = b.x;
  19379. c.y = b.y;
  19380. this._bgLayer.addChild(c, 10)
  19381. },
  19382. onEnter: function () {
  19383. cc.Node.prototype.onEnter.call(this);
  19384. this.schedule(this._startLoading, 0.3)
  19385. },
  19386. onExit: function () {
  19387. cc.Node.prototype.onExit.call(this);
  19388. this._label.setString("\u6570\u4e0d\u72ec\u52a0\u8f7d\u4e2d... 0%")
  19389. },
  19390. initWithResources: function (a, b) {
  19391. cc.isString(a) && (a = [a]);
  19392. this.resources = a || [];
  19393. this.cb = b
  19394. },
  19395. _startLoading: function () {
  19396. var a = this;
  19397. a.unschedule(a._startLoading);
  19398. cc.loader.load(a.resources,
  19399. function (b, c, d) {
  19400. b = Math.min(d / c * 100 | 0, 100);
  19401. a._label.setString("\u6570\u4e0d\u72ec\u52a0\u8f7d\u4e2d... " + b + "%")
  19402. },
  19403. function () {
  19404. a.cb && a.cb()
  19405. })
  19406. }
  19407. });
  19408. sceneLoad.preload = function (a, b) {
  19409. var c = cc;
  19410. c.sceneLoad || (c.sceneLoad = new sceneLoad, c.sceneLoad.init());
  19411. c.sceneLoad.initWithResources(a, b);
  19412. cc.director.runScene(c.sceneLoad);
  19413. return c.sceneLoad
  19414. };
  19415. cc.game.onStart = function () {
  19416. var a = cc.size(480, 800);
  19417. cc.loader.resPath = "res";
  19418. cc.view.setDesignResolutionSize(a.width, a.height, cc.ResolutionPolicy.SHOW_ALL);
  19419. cc.view.resizeWithBrowserSize(!0);
  19420. cc.view.canSetContentScaleFactor("RW/DW");
  19421. sceneLoad.preload(g_resources,
  19422. function () {
  19423. cc.director.runScene(new WelcomeScene)
  19424. },
  19425. this)
  19426. };
  19427. cc.game.run();