d.js 601 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426
  1. var __extends, GameProcessState, GameState, BallState, Ball, Background, Bomb, Bed, CollideGroundEffect, CollideShitEffect, FirstState, LoadingState, PlayerState, Player, Obstacle, ObstacleFactory, Summary, Shit, Game;
  2. ! function() {
  3. var c, d, e, a = this,
  4. b = b || {};
  5. for (b.WEBGL_RENDERER = 0, b.CANVAS_RENDERER = 1, b.VERSION = "v1.6.1", b.blendModes = {
  6. NORMAL: 0,
  7. ADD: 1,
  8. MULTIPLY: 2,
  9. SCREEN: 3,
  10. OVERLAY: 4,
  11. DARKEN: 5,
  12. LIGHTEN: 6,
  13. COLOR_DODGE: 7,
  14. COLOR_BURN: 8,
  15. HARD_LIGHT: 9,
  16. SOFT_LIGHT: 10,
  17. DIFFERENCE: 11,
  18. EXCLUSION: 12,
  19. HUE: 13,
  20. SATURATION: 14,
  21. COLOR: 15,
  22. LUMINOSITY: 16
  23. }, b.scaleModes = {
  24. DEFAULT: 0,
  25. LINEAR: 0,
  26. NEAREST: 1
  27. }, b._UID = 0, "undefined" != typeof Float32Array ? (b.Float32Array = Float32Array, b.Uint16Array = Uint16Array) : (b.Float32Array = Array, b.Uint16Array = Array), b.INTERACTION_FREQUENCY = 30, b.AUTO_PREVENT_DEFAULT = !0, b.RAD_TO_DEG = 180 / Math.PI, b.DEG_TO_RAD = Math.PI / 180, b.dontSayHello = !1, b.sayHello = function(a) {
  28. if (!b.dontSayHello) {
  29. if (navigator.userAgent.toLowerCase().indexOf("chrome") > -1) {
  30. var c = ["%c %c %c Pixi.js " + b.VERSION + " - " + a + " %c " + " %c " + " http://www.pixijs.com/ %c %c ♥%c♥%c♥ ", "background: #ff66a5", "background: #ff66a5", "color: #ff66a5; background: #030307;", "background: #ff66a5", "background: #ffc3dc", "background: #ff66a5", "color: #ff2424; background: #fff", "color: #ff2424; background: #fff", "color: #ff2424; background: #fff"];
  31. console.log.apply(console, c)
  32. } else window["console"] && console.log("Pixi.js " + b.VERSION + " - http://www.pixijs.com/");
  33. b.dontSayHello = !0
  34. }
  35. }, b.Point = function(a, b) {
  36. this.x = a || 0, this.y = b || 0
  37. }, b.Point.prototype.clone = function() {
  38. return new b.Point(this.x, this.y)
  39. }, b.Point.prototype.set = function(a, b) {
  40. this.x = a || 0, this.y = b || (0 !== b ? this.x : 0)
  41. }, b.Point.prototype.constructor = b.Point, b.Rectangle = function(a, b, c, d) {
  42. this.x = a || 0, this.y = b || 0, this.width = c || 0, this.height = d || 0
  43. }, b.Rectangle.prototype.clone = function() {
  44. return new b.Rectangle(this.x, this.y, this.width, this.height)
  45. }, b.Rectangle.prototype.contains = function(a, b) {
  46. var c, d;
  47. return this.width <= 0 || this.height <= 0 ? !1 : (c = this.x, a >= c && a <= c + this.width && (d = this.y, b >= d && b <= d + this.height) ? !0 : !1)
  48. }, b.Rectangle.prototype.constructor = b.Rectangle, b.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Polygon = function(a) {
  49. var c, d, e;
  50. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  51. for (c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  52. a = c
  53. }
  54. this.points = a
  55. }, b.Polygon.prototype.clone = function() {
  56. var c, a = [];
  57. for (c = 0; c < this.points.length; c++) a.push(this.points[c].clone());
  58. return new b.Polygon(a)
  59. }, b.Polygon.prototype.contains = function(a, b) {
  60. var d, e, f, g, h, i, j, c = !1;
  61. for (d = 0, e = this.points.length - 1; d < this.points.length; e = d++) f = this.points[d].x, g = this.points[d].y, h = this.points[e].x, i = this.points[e].y, j = g > b != i > b && (h - f) * (b - g) / (i - g) + f > a, j && (c = !c);
  62. return c
  63. }, b.Polygon.prototype.constructor = b.Polygon, b.Circle = function(a, b, c) {
  64. this.x = a || 0, this.y = b || 0, this.radius = c || 0
  65. }, b.Circle.prototype.clone = function() {
  66. return new b.Circle(this.x, this.y, this.radius)
  67. }, b.Circle.prototype.contains = function(a, b) {
  68. if (this.radius <= 0) return !1;
  69. var c = this.x - a,
  70. d = this.y - b,
  71. e = this.radius * this.radius;
  72. return c *= c, d *= d, e >= c + d
  73. }, b.Circle.prototype.getBounds = function() {
  74. return new b.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height)
  75. }, b.Circle.prototype.constructor = b.Circle, b.Ellipse = function(a, b, c, d) {
  76. this.x = a || 0, this.y = b || 0, this.width = c || 0, this.height = d || 0
  77. }, b.Ellipse.prototype.clone = function() {
  78. return new b.Ellipse(this.x, this.y, this.width, this.height)
  79. }, b.Ellipse.prototype.contains = function(a, b) {
  80. if (this.width <= 0 || this.height <= 0) return !1;
  81. var c = (a - this.x) / this.width,
  82. d = (b - this.y) / this.height;
  83. return c *= c, d *= d, 1 >= c + d
  84. }, b.Ellipse.prototype.getBounds = function() {
  85. return new b.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height)
  86. }, b.Ellipse.prototype.constructor = b.Ellipse, b.Matrix = function() {
  87. this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0
  88. }, b.Matrix.prototype.fromArray = function(a) {
  89. this.a = a[0], this.b = a[1], this.c = a[3], this.d = a[4], this.tx = a[2], this.ty = a[5]
  90. }, b.Matrix.prototype.toArray = function(a) {
  91. this.array || (this.array = new Float32Array(9));
  92. var b = this.array;
  93. return a ? (b[0] = this.a, b[1] = this.c, b[2] = 0, b[3] = this.b, b[4] = this.d, b[5] = 0, b[6] = this.tx, b[7] = this.ty, b[8] = 1) : (b[0] = this.a, b[1] = this.b, b[2] = this.tx, b[3] = this.c, b[4] = this.d, b[5] = this.ty, b[6] = 0, b[7] = 0, b[8] = 1), b
  94. }, b.identityMatrix = new b.Matrix, b.determineMatrixArrayType = function() {
  95. return "undefined" != typeof Float32Array ? Float32Array : Array
  96. }, b.Matrix2 = b.determineMatrixArrayType(), b.DisplayObject = function() {
  97. this.position = new b.Point, this.scale = new b.Point(1, 1), this.pivot = new b.Point(0, 0), this.rotation = 0, this.alpha = 1, this.visible = !0, this.hitArea = null, this.buttonMode = !1, this.renderable = !1, this.parent = null, this.stage = null, this.worldAlpha = 1, this._interactive = !1, this.defaultCursor = "pointer", this.worldTransform = new b.Matrix, this.color = [], this.dynamic = !0, this._sr = 0, this._cr = 1, this.filterArea = null, this._bounds = new b.Rectangle(0, 0, 1, 1), this._currentBounds = null, this._mask = null, this._cacheAsBitmap = !1, this._cacheIsDirty = !1
  98. }, b.DisplayObject.prototype.constructor = b.DisplayObject, b.DisplayObject.prototype.setInteractive = function(a) {
  99. this.interactive = a
  100. }, Object.defineProperty(b.DisplayObject.prototype, "interactive", {
  101. get: function() {
  102. return this._interactive
  103. },
  104. set: function(a) {
  105. this._interactive = a, this.stage && (this.stage.dirty = !0)
  106. }
  107. }), Object.defineProperty(b.DisplayObject.prototype, "worldVisible", {
  108. get: function() {
  109. var a = this;
  110. do {
  111. if (!a.visible) return !1;
  112. a = a.parent
  113. } while (a);
  114. return !0
  115. }
  116. }), Object.defineProperty(b.DisplayObject.prototype, "mask", {
  117. get: function() {
  118. return this._mask
  119. },
  120. set: function(a) {
  121. this._mask && (this._mask.isMask = !1), this._mask = a, this._mask && (this._mask.isMask = !0)
  122. }
  123. }), Object.defineProperty(b.DisplayObject.prototype, "filters", {
  124. get: function() {
  125. return this._filters
  126. },
  127. set: function(a) {
  128. var b, c, d, e;
  129. if (a) {
  130. for (b = [], c = 0; c < a.length; c++)
  131. for (d = a[c].passes, e = 0; e < d.length; e++) b.push(d[e]);
  132. this._filterBlock = {
  133. target: this,
  134. filterPasses: b
  135. }
  136. }
  137. this._filters = a
  138. }
  139. }), Object.defineProperty(b.DisplayObject.prototype, "cacheAsBitmap", {
  140. get: function() {
  141. return this._cacheAsBitmap
  142. },
  143. set: function(a) {
  144. this._cacheAsBitmap !== a && (a ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = a)
  145. }
  146. }), b.DisplayObject.prototype.updateTransform = function() {
  147. var a, b, c, d, e, f, g, h, i, j, k, l, m, n;
  148. this.rotation !== this.rotationCache && (this.rotationCache = this.rotation, this._sr = Math.sin(this.rotation), this._cr = Math.cos(this.rotation)), a = this.parent.worldTransform, b = this.worldTransform, c = this.pivot.x, d = this.pivot.y, e = this._cr * this.scale.x, f = -this._sr * this.scale.y, g = this._sr * this.scale.x, h = this._cr * this.scale.y, i = this.position.x - e * c - d * f, j = this.position.y - h * d - c * g, k = a.a, l = a.b, m = a.c, n = a.d, b.a = k * e + l * g, b.b = k * f + l * h, b.tx = k * i + l * j + a.tx, b.c = m * e + n * g, b.d = m * f + n * h, b.ty = m * i + n * j + a.ty, this.worldAlpha = this.alpha * this.parent.worldAlpha
  149. }, b.DisplayObject.prototype.getBounds = function(a) {
  150. return a = a, b.EmptyRectangle
  151. }, b.DisplayObject.prototype.getLocalBounds = function() {
  152. return this.getBounds(b.identityMatrix)
  153. }, b.DisplayObject.prototype.setStageReference = function(a) {
  154. this.stage = a, this._interactive && (this.stage.dirty = !0)
  155. }, b.DisplayObject.prototype.generateTexture = function(a) {
  156. var c = this.getLocalBounds(),
  157. d = new b.RenderTexture(0 | c.width, 0 | c.height, a);
  158. return d.render(this, new b.Point(-c.x, -c.y)), d
  159. }, b.DisplayObject.prototype.updateCache = function() {
  160. this._generateCachedSprite()
  161. }, b.DisplayObject.prototype._renderCachedSprite = function(a) {
  162. this._cachedSprite.worldAlpha = this.worldAlpha, a.gl ? b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a) : b.Sprite.prototype._renderCanvas.call(this._cachedSprite, a)
  163. }, b.DisplayObject.prototype._generateCachedSprite = function() {
  164. var a, c, d;
  165. this._cacheAsBitmap = !1, a = this.getLocalBounds(), this._cachedSprite ? this._cachedSprite.texture.resize(0 | a.width, 0 | a.height) : (c = new b.RenderTexture(0 | a.width, 0 | a.height), this._cachedSprite = new b.Sprite(c), this._cachedSprite.worldTransform = this.worldTransform), d = this._filters, this._filters = null, this._cachedSprite.filters = d, this._cachedSprite.texture.render(this, new b.Point(-a.x, -a.y)), this._cachedSprite.anchor.x = -(a.x / a.width), this._cachedSprite.anchor.y = -(a.y / a.height), this._filters = d, this._cacheAsBitmap = !0
  166. }, b.DisplayObject.prototype._destroyCachedSprite = function() {
  167. this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null)
  168. }, b.DisplayObject.prototype._renderWebGL = function(a) {
  169. a = a
  170. }, b.DisplayObject.prototype._renderCanvas = function(a) {
  171. a = a
  172. }, Object.defineProperty(b.DisplayObject.prototype, "x", {
  173. get: function() {
  174. return this.position.x
  175. },
  176. set: function(a) {
  177. this.position.x = a
  178. }
  179. }), Object.defineProperty(b.DisplayObject.prototype, "y", {
  180. get: function() {
  181. return this.position.y
  182. },
  183. set: function(a) {
  184. this.position.y = a
  185. }
  186. }), b.DisplayObjectContainer = function() {
  187. b.DisplayObject.call(this), this.children = []
  188. }, b.DisplayObjectContainer.prototype = Object.create(b.DisplayObject.prototype), b.DisplayObjectContainer.prototype.constructor = b.DisplayObjectContainer, Object.defineProperty(b.DisplayObjectContainer.prototype, "width", {
  189. get: function() {
  190. return this.scale.x * this.getLocalBounds().width
  191. },
  192. set: function(a) {
  193. var b = this.getLocalBounds().width;
  194. this.scale.x = 0 !== b ? a / (b / this.scale.x) : 1, this._width = a
  195. }
  196. }), Object.defineProperty(b.DisplayObjectContainer.prototype, "height", {
  197. get: function() {
  198. return this.scale.y * this.getLocalBounds().height
  199. },
  200. set: function(a) {
  201. var b = this.getLocalBounds().height;
  202. this.scale.y = 0 !== b ? a / (b / this.scale.y) : 1, this._height = a
  203. }
  204. }), b.DisplayObjectContainer.prototype.addChild = function(a) {
  205. return this.addChildAt(a, this.children.length)
  206. }, b.DisplayObjectContainer.prototype.addChildAt = function(a, b) {
  207. if (b >= 0 && b <= this.children.length) return a.parent && a.parent.removeChild(a), a.parent = this, this.children.splice(b, 0, a), this.stage && a.setStageReference(this.stage), a;
  208. throw new Error(a + " The index " + b + " supplied is out of bounds " + this.children.length)
  209. }, b.DisplayObjectContainer.prototype.swapChildren = function(a, b) {
  210. var c, d;
  211. if (a !== b) {
  212. if (c = this.children.indexOf(a), d = this.children.indexOf(b), 0 > c || 0 > d) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
  213. this.children[c] = b, this.children[d] = a
  214. }
  215. }, b.DisplayObjectContainer.prototype.getChildAt = function(a) {
  216. if (a >= 0 && a < this.children.length) return this.children[a];
  217. throw new Error("Supplied index does not exist in the child list, or the supplied DisplayObject must be a child of the caller")
  218. }, b.DisplayObjectContainer.prototype.removeChild = function(a) {
  219. return this.removeChildAt(this.children.indexOf(a))
  220. }, b.DisplayObjectContainer.prototype.removeChildAt = function(a) {
  221. var b = this.getChildAt(a);
  222. return this.stage && b.removeStageReference(), b.parent = void 0, this.children.splice(a, 1), b
  223. }, b.DisplayObjectContainer.prototype.removeChildren = function(a, b) {
  224. var f, g, h, c = a || 0,
  225. d = "number" == typeof b ? b : this.children.length,
  226. e = d - c;
  227. if (e > 0 && d >= e) {
  228. for (f = this.children.splice(c, e), g = 0; g < f.length; g++) h = f[g], this.stage && h.removeStageReference(), h.parent = void 0;
  229. return f
  230. }
  231. throw new Error("Range Error, numeric values are outside the acceptable range")
  232. }, b.DisplayObjectContainer.prototype.updateTransform = function() {
  233. if (this.visible && (b.DisplayObject.prototype.updateTransform.call(this), !this._cacheAsBitmap))
  234. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].updateTransform()
  235. }, b.DisplayObjectContainer.prototype.getBounds = function(a) {
  236. var c, d, e, f, g, h, i, j, k, l, m, n, o;
  237. if (0 === this.children.length) return b.EmptyRectangle;
  238. for (a && (c = this.worldTransform, this.worldTransform = a, this.updateTransform(), this.worldTransform = c), d = 1 / 0, e = 1 / 0, f = -1 / 0, g = -1 / 0, k = !1, l = 0, m = this.children.length; m > l; l++) n = this.children[l], n.visible && (k = !0, h = this.children[l].getBounds(a), d = d < h.x ? d : h.x, e = e < h.y ? e : h.y, i = h.width + h.x, j = h.height + h.y, f = f > i ? f : i, g = g > j ? g : j);
  239. return k ? (o = this._bounds, o.x = d, o.y = e, o.width = f - d, o.height = g - e, o) : b.EmptyRectangle
  240. }, b.DisplayObjectContainer.prototype.getLocalBounds = function() {
  241. var c, d, e, a = this.worldTransform;
  242. for (this.worldTransform = b.identityMatrix, c = 0, d = this.children.length; d > c; c++) this.children[c].updateTransform();
  243. return e = this.getBounds(), this.worldTransform = a, e
  244. }, b.DisplayObjectContainer.prototype.setStageReference = function(a) {
  245. var b, c, d;
  246. for (this.stage = a, this._interactive && (this.stage.dirty = !0), b = 0, c = this.children.length; c > b; b++) d = this.children[b], d.setStageReference(a)
  247. }, b.DisplayObjectContainer.prototype.removeStageReference = function() {
  248. var a, b, c;
  249. for (a = 0, b = this.children.length; b > a; a++) c = this.children[a], c.removeStageReference();
  250. this._interactive && (this.stage.dirty = !0), this.stage = null
  251. }, b.DisplayObjectContainer.prototype._renderWebGL = function(a) {
  252. if (this.visible && !(this.alpha <= 0)) {
  253. if (this._cacheAsBitmap) return this._renderCachedSprite(a), void 0;
  254. var b, c;
  255. if (this._mask || this._filters) {
  256. for (this._filters && (a.spriteBatch.flush(), a.filterManager.pushFilter(this._filterBlock)), this._mask && (a.spriteBatch.stop(), a.maskManager.pushMask(this.mask, a), a.spriteBatch.start()), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a);
  257. a.spriteBatch.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), a.spriteBatch.start()
  258. } else
  259. for (b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  260. }
  261. }, b.DisplayObjectContainer.prototype._renderCanvas = function(a) {
  262. var b, c, d;
  263. if (this.visible !== !1 && 0 !== this.alpha) {
  264. if (this._cacheAsBitmap) return this._renderCachedSprite(a), void 0;
  265. for (this._mask && a.maskManager.pushMask(this._mask, a.context), b = 0, c = this.children.length; c > b; b++) d = this.children[b], d._renderCanvas(a);
  266. this._mask && a.maskManager.popMask(a.context)
  267. }
  268. }, b.Sprite = function(a) {
  269. b.DisplayObjectContainer.call(this), this.anchor = new b.Point, this.texture = a, this._width = 0, this._height = 0, this.tint = 16777215, this.blendMode = b.blendModes.NORMAL, a.baseTexture.hasLoaded ? this.onTextureUpdate() : (this.onTextureUpdateBind = this.onTextureUpdate.bind(this), this.texture.addEventListener("update", this.onTextureUpdateBind)), this.renderable = !0
  270. }, b.Sprite.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Sprite.prototype.constructor = b.Sprite, Object.defineProperty(b.Sprite.prototype, "width", {
  271. get: function() {
  272. return this.scale.x * this.texture.frame.width
  273. },
  274. set: function(a) {
  275. this.scale.x = a / this.texture.frame.width, this._width = a
  276. }
  277. }), Object.defineProperty(b.Sprite.prototype, "height", {
  278. get: function() {
  279. return this.scale.y * this.texture.frame.height
  280. },
  281. set: function(a) {
  282. this.scale.y = a / this.texture.frame.height, this._height = a
  283. }
  284. }), b.Sprite.prototype.setTexture = function(a) {
  285. this.texture = a, this.cachedTint = 16777215
  286. }, b.Sprite.prototype.onTextureUpdate = function() {
  287. this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height)
  288. }, b.Sprite.prototype.getBounds = function(a) {
  289. var A, b = this.texture.frame.width,
  290. c = this.texture.frame.height,
  291. d = b * (1 - this.anchor.x),
  292. e = b * -this.anchor.x,
  293. f = c * (1 - this.anchor.y),
  294. g = c * -this.anchor.y,
  295. h = a || this.worldTransform,
  296. i = h.a,
  297. j = h.c,
  298. k = h.b,
  299. l = h.d,
  300. m = h.tx,
  301. n = h.ty,
  302. o = i * e + k * g + m,
  303. p = l * g + j * e + n,
  304. q = i * d + k * g + m,
  305. r = l * g + j * d + n,
  306. s = i * d + k * f + m,
  307. t = l * f + j * d + n,
  308. u = i * e + k * f + m,
  309. v = l * f + j * e + n,
  310. w = -1 / 0,
  311. x = -1 / 0,
  312. y = 1 / 0,
  313. z = 1 / 0;
  314. return y = y > o ? o : y, y = y > q ? q : y, y = y > s ? s : y, y = y > u ? u : y, z = z > p ? p : z, z = z > r ? r : z, z = z > t ? t : z, z = z > v ? v : z, w = o > w ? o : w, w = q > w ? q : w, w = s > w ? s : w, w = u > w ? u : w, x = p > x ? p : x, x = r > x ? r : x, x = t > x ? t : x, x = v > x ? v : x, A = this._bounds, A.x = y, A.width = w - y, A.y = z, A.height = x - z, this._currentBounds = A, A
  315. }, b.Sprite.prototype._renderWebGL = function(a) {
  316. var b, c, d;
  317. if (this.visible && !(this.alpha <= 0))
  318. if (this._mask || this._filters) {
  319. for (d = a.spriteBatch, this._filters && (d.flush(), a.filterManager.pushFilter(this._filterBlock)), this._mask && (d.stop(), a.maskManager.pushMask(this.mask, a), d.start()), d.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a);
  320. d.stop(), this._mask && a.maskManager.popMask(this._mask, a), this._filters && a.filterManager.popFilter(), d.start()
  321. } else
  322. for (a.spriteBatch.render(this), b = 0, c = this.children.length; c > b; b++) this.children[b]._renderWebGL(a)
  323. }, b.Sprite.prototype._renderCanvas = function(a) {
  324. var c, d, e, f;
  325. if (this.visible !== !1 && 0 !== this.alpha) {
  326. for (this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, a.context.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a.context), this.texture.valid && (a.context.globalAlpha = this.worldAlpha, a.roundPixels ? a.context.setTransform(this.worldTransform.a, this.worldTransform.c, this.worldTransform.b, this.worldTransform.d, 0 | this.worldTransform.tx, 0 | this.worldTransform.ty) : a.context.setTransform(this.worldTransform.a, this.worldTransform.c, this.worldTransform.b, this.worldTransform.d, this.worldTransform.tx, this.worldTransform.ty), a.smoothProperty && a.scaleMode !== this.texture.baseTexture.scaleMode && (a.scaleMode = this.texture.baseTexture.scaleMode, a.context[a.smoothProperty] = a.scaleMode === b.scaleModes.LINEAR), c = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width, d = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height, 16777215 !== this.tint ? (this.cachedTint !== this.tint && (this.cachedTint = this.tint, this.tintedTexture = b.CanvasTinter.getTintedTexture(this, this.tint)), a.context.drawImage(this.tintedTexture, 0, 0, this.texture.crop.width, this.texture.crop.height, c, d, this.texture.crop.width, this.texture.crop.height)) : a.context.drawImage(this.texture.baseTexture.source, this.texture.crop.x, this.texture.crop.y, this.texture.crop.width, this.texture.crop.height, c, d, this.texture.crop.width, this.texture.crop.height)), e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
  327. this._mask && a.maskManager.popMask(a.context)
  328. }
  329. }, b.Sprite.fromFrame = function(a) {
  330. var c = b.TextureCache[a];
  331. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache' + this);
  332. return new b.Sprite(c)
  333. }, b.Sprite.fromImage = function(a, c, d) {
  334. var e = b.Texture.fromImage(a, c, d);
  335. return new b.Sprite(e)
  336. }, b.SpriteBatch = function(a) {
  337. b.DisplayObjectContainer.call(this), this.textureThing = a, this.ready = !1
  338. }, b.SpriteBatch.prototype = Object.create(b.DisplayObjectContainer.prototype), b.SpriteBatch.constructor = b.SpriteBatch, b.SpriteBatch.prototype.initWebGL = function(a) {
  339. this.fastSpriteBatch = new b.WebGLFastSpriteBatch(a), this.ready = !0
  340. }, b.SpriteBatch.prototype.updateTransform = function() {
  341. b.DisplayObject.prototype.updateTransform.call(this)
  342. }, b.SpriteBatch.prototype._renderWebGL = function(a) {
  343. !this.visible || this.alpha <= 0 || !this.children.length || (this.ready || this.initWebGL(a.gl), a.spriteBatch.stop(), a.shaderManager.setShader(a.shaderManager.fastShader), this.fastSpriteBatch.begin(this, a), this.fastSpriteBatch.render(this), a.spriteBatch.start())
  344. }, b.SpriteBatch.prototype._renderCanvas = function(a) {
  345. var d, e, f, g, h, i, j, c = a.context;
  346. for (c.globalAlpha = this.worldAlpha, b.DisplayObject.prototype.updateTransform.call(this), d = this.worldTransform, e = !0, f = 0; f < this.children.length; f++) g = this.children[f], g.visible && (h = g.texture, i = h.frame, c.globalAlpha = this.worldAlpha * g.alpha, 0 === g.rotation % (2 * Math.PI) ? (e && (c.setTransform(d.a, d.c, d.b, d.d, d.tx, d.ty), e = !1), c.drawImage(h.baseTexture.source, i.x, i.y, i.width, i.height, 0 | g.anchor.x * -i.width * g.scale.x + g.position.x + .5, 0 | g.anchor.y * -i.height * g.scale.y + g.position.y + .5, i.width * g.scale.x, i.height * g.scale.y)) : (e || (e = !0), b.DisplayObject.prototype.updateTransform.call(g), j = g.worldTransform, a.roundPixels ? c.setTransform(j.a, j.c, j.b, j.d, 0 | j.tx, 0 | j.ty) : c.setTransform(j.a, j.c, j.b, j.d, j.tx, j.ty), c.drawImage(h.baseTexture.source, i.x, i.y, i.width, i.height, 0 | g.anchor.x * -i.width + .5, 0 | g.anchor.y * -i.height + .5, i.width, i.height)))
  347. }, b.AbstractFilter = function(a, b) {
  348. this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = b || {}, this.fragmentSrc = a || []
  349. }, b.FilterBlock = function() {
  350. this.visible = !0, this.renderable = !0
  351. }, b.Text = function(a, c) {
  352. this.canvas = document.createElement("canvas"), this.context = this.canvas.getContext("2d"), b.Sprite.call(this, b.Texture.fromCanvas(this.canvas)), this.setText(a), this.setStyle(c)
  353. }, b.Text.prototype = Object.create(b.Sprite.prototype), b.Text.prototype.constructor = b.Text, Object.defineProperty(b.Text.prototype, "width", {
  354. get: function() {
  355. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width
  356. },
  357. set: function(a) {
  358. this.scale.x = a / this.texture.frame.width, this._width = a
  359. }
  360. }), Object.defineProperty(b.Text.prototype, "height", {
  361. get: function() {
  362. return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height
  363. },
  364. set: function(a) {
  365. this.scale.y = a / this.texture.frame.height, this._height = a
  366. }
  367. }), b.Text.prototype.setStyle = function(a) {
  368. a = a || {}, a.font = a.font || "bold 20pt Arial", a.fill = a.fill || "black", a.align = a.align || "left", a.stroke = a.stroke || "black", a.strokeThickness = a.strokeThickness || 0, a.wordWrap = a.wordWrap || !1, a.wordWrapWidth = a.wordWrapWidth || 100, a.wordWrapWidth = a.wordWrapWidth || 100, a.dropShadow = a.dropShadow || !1, a.dropShadowAngle = a.dropShadowAngle || Math.PI / 6, a.dropShadowDistance = a.dropShadowDistance || 4, a.dropShadowColor = a.dropShadowColor || "black", this.style = a, this.dirty = !0
  369. }, b.Text.prototype.setText = function(a) {
  370. this.text = a.toString() || " ", this.dirty = !0
  371. }, b.Text.prototype.updateText = function() {
  372. var a, b, c, d, e, f, g, h, i, j, k, l, m;
  373. for (this.context.font = this.style.font, a = this.text, this.style.wordWrap && (a = this.wordWrap(this.text)), b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = 0; e < b.length; e++) f = this.context.measureText(b[e]).width, c[e] = f, d = Math.max(d, f);
  374. if (g = d + this.style.strokeThickness, this.style.dropShadow && (g += this.style.dropShadowDistance), this.canvas.width = g + this.context.lineWidth, h = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness, i = h * b.length, this.style.dropShadow && (i += this.style.dropShadowDistance), this.canvas.height = i, navigator.isCocoonJS && this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.font = this.style.font, this.context.strokeStyle = this.style.stroke, this.context.lineWidth = this.style.strokeThickness, this.context.textBaseline = "top", this.style.dropShadow)
  375. for (this.context.fillStyle = this.style.dropShadowColor, l = Math.sin(this.style.dropShadowAngle) * this.style.dropShadowDistance, m = Math.cos(this.style.dropShadowAngle) * this.style.dropShadowDistance, e = 0; e < b.length; e++) j = this.style.strokeThickness / 2, k = this.style.strokeThickness / 2 + e * h, "right" === this.style.align ? j += d - c[e] : "center" === this.style.align && (j += (d - c[e]) / 2), this.style.fill && this.context.fillText(b[e], j + l, k + m);
  376. for (this.context.fillStyle = this.style.fill, e = 0; e < b.length; e++) j = this.style.strokeThickness / 2, k = this.style.strokeThickness / 2 + e * h, "right" === this.style.align ? j += d - c[e] : "center" === this.style.align && (j += (d - c[e]) / 2), this.style.stroke && this.style.strokeThickness && this.context.strokeText(b[e], j, k), this.style.fill && this.context.fillText(b[e], j, k);
  377. this.updateTexture()
  378. }, b.Text.prototype.updateTexture = function() {
  379. this.texture.baseTexture.width = this.canvas.width, this.texture.baseTexture.height = this.canvas.height, this.texture.crop.width = this.texture.frame.width = this.canvas.width, this.texture.crop.height = this.texture.frame.height = this.canvas.height, this._width = this.canvas.width, this._height = this.canvas.height, this.requiresUpdate = !0
  380. }, b.Text.prototype._renderWebGL = function(a) {
  381. this.requiresUpdate && (this.requiresUpdate = !1, b.updateWebGLTexture(this.texture.baseTexture, a.gl)), b.Sprite.prototype._renderWebGL.call(this, a)
  382. }, b.Text.prototype.updateTransform = function() {
  383. this.dirty && (this.updateText(), this.dirty = !1), b.Sprite.prototype.updateTransform.call(this)
  384. }, b.Text.prototype.determineFontHeight = function(a) {
  385. var d, e, f, c = b.Text.heightCache[a];
  386. return c || (d = document.getElementsByTagName("body")[0], e = document.createElement("div"), f = document.createTextNode("M"), e.appendChild(f), e.setAttribute("style", a + ";position:absolute;top:0;left:0"), d.appendChild(e), c = e.offsetHeight, b.Text.heightCache[a] = c, d.removeChild(e)), c
  387. }, b.Text.prototype.wordWrap = function(a) {
  388. var d, e, f, g, h, i, b = "",
  389. c = a.split("\n");
  390. for (d = 0; d < c.length; d++) {
  391. for (e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) h = this.context.measureText(f[g]).width, i = h + this.context.measureText(" ").width, 0 === g || i > e ? (g > 0 && (b += "\n"), b += f[g], e = this.style.wordWrapWidth - h) : (e -= i, b += " " + f[g]);
  392. d < c.length - 1 && (b += "\n")
  393. }
  394. return b
  395. }, b.Text.prototype.destroy = function(a) {
  396. this.context = null, this.canvas = null, this.texture.destroy(void 0 === a ? !0 : a)
  397. }, b.Text.heightCache = {}, b.BitmapText = function(a, c) {
  398. b.DisplayObjectContainer.call(this), this._pool = [], this.setText(a), this.setStyle(c), this.updateText(), this.dirty = !1
  399. }, b.BitmapText.prototype = Object.create(b.DisplayObjectContainer.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setText = function(a) {
  400. this.text = a || " ", this.dirty = !0
  401. }, b.BitmapText.prototype.setStyle = function(a) {
  402. a = a || {}, a.align = a.align || "left", this.style = a;
  403. var c = a.font.split(" ");
  404. this.fontName = c[c.length - 1], this.fontSize = c.length >= 2 ? parseInt(c[c.length - 2], 10) : b.BitmapText.fonts[this.fontName].size, this.dirty = !0, this.tint = a.tint
  405. }, b.BitmapText.prototype.updateText = function() {
  406. var j, k, l, m, n, o, p, q, r, s, a = b.BitmapText.fonts[this.fontName],
  407. c = new b.Point,
  408. d = null,
  409. e = [],
  410. f = 0,
  411. g = [],
  412. h = 0,
  413. i = this.fontSize / a.size;
  414. for (j = 0; j < this.text.length; j++) k = this.text.charCodeAt(j), /(?:\r\n|\r|\n)/.test(this.text.charAt(j)) ? (g.push(c.x), f = Math.max(f, c.x), h++, c.x = 0, c.y += a.lineHeight, d = null) : (l = a.chars[k], l && (d && l[d] && (c.x += l.kerning[d]), e.push({
  415. texture: l.texture,
  416. line: h,
  417. charCode: k,
  418. position: new b.Point(c.x + l.xOffset, c.y + l.yOffset)
  419. }), c.x += l.xAdvance, d = k));
  420. for (g.push(c.x), f = Math.max(f, c.x), m = [], j = 0; h >= j; j++) n = 0, "right" === this.style.align ? n = f - g[j] : "center" === this.style.align && (n = (f - g[j]) / 2), m.push(n);
  421. for (o = this.children.length, p = e.length, q = this.tint || 16777215, j = 0; p > j; j++) r = o > j ? this.children[j] : this._pool.pop(), r ? r.setTexture(e[j].texture) : r = new b.Sprite(e[j].texture), r.position.x = (e[j].position.x + m[e[j].line]) * i, r.position.y = e[j].position.y * i, r.scale.x = r.scale.y = i, r.tint = q, r.parent || this.addChild(r);
  422. for (; this.children.length > p;) s = this.getChildAt(this.children.length - 1), this._pool.push(s), this.removeChild(s);
  423. this.textWidth = f * i, this.textHeight = (c.y + a.lineHeight) * i
  424. }, b.BitmapText.prototype.updateTransform = function() {
  425. this.dirty && (this.updateText(), this.dirty = !1), b.DisplayObjectContainer.prototype.updateTransform.call(this)
  426. }, b.BitmapText.fonts = {}, b.Stage = function(a) {
  427. b.DisplayObjectContainer.call(this), this.worldTransform = new b.Matrix, this.interactive = !0, this.interactionManager = new b.InteractionManager(this), this.dirty = !0, this.stage = this, this.stage.hitArea = new b.Rectangle(0, 0, 1e5, 1e5), this.setBackgroundColor(a)
  428. }, b.Stage.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.setInteractionDelegate = function(a) {
  429. this.interactionManager.setTargetDomElement(a)
  430. }, b.Stage.prototype.updateTransform = function() {
  431. this.worldAlpha = 1;
  432. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].updateTransform();
  433. this.dirty && (this.dirty = !1, this.interactionManager.dirty = !0), this.interactive && this.interactionManager.update()
  434. }, b.Stage.prototype.setBackgroundColor = function(a) {
  435. this.backgroundColor = a || 0, this.backgroundColorSplit = b.hex2rgb(this.backgroundColor);
  436. var c = this.backgroundColor.toString(16);
  437. c = "000000".substr(0, 6 - c.length) + c, this.backgroundColorString = "#" + c
  438. }, b.Stage.prototype.getMousePosition = function() {
  439. return this.interactionManager.mouse.global
  440. }, c = 0, d = ["ms", "moz", "webkit", "o"], e = 0; e < d.length && !window.requestAnimationFrame; ++e) window.requestAnimationFrame = window[d[e] + "RequestAnimationFrame"], window.cancelAnimationFrame = window[d[e] + "CancelAnimationFrame"] || window[d[e] + "CancelRequestAnimationFrame"];
  441. window.requestAnimationFrame || (window.requestAnimationFrame = function(a) {
  442. var b = (new Date).getTime(),
  443. d = Math.max(0, 16 - (b - c)),
  444. e = window.setTimeout(function() {
  445. a(b + d)
  446. }, d);
  447. return c = b + d, e
  448. }), window.cancelAnimationFrame || (window.cancelAnimationFrame = function(a) {
  449. clearTimeout(a)
  450. }), window.requestAnimFrame = window.requestAnimationFrame, b.hex2rgb = function(a) {
  451. return [(255 & a >> 16) / 255, (255 & a >> 8) / 255, (255 & a) / 255]
  452. }, b.rgb2hex = function(a) {
  453. return (255 * a[0] << 16) + (255 * a[1] << 8) + 255 * a[2]
  454. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  455. var a = Array.prototype.slice;
  456. return function(b) {
  457. function e() {
  458. var f = d.concat(a.call(arguments));
  459. c.apply(this instanceof e ? this : b, f)
  460. }
  461. var c = this,
  462. d = a.call(arguments, 1);
  463. if ("function" != typeof c) throw new TypeError;
  464. return e.prototype = function f(a) {
  465. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  466. }(c.prototype), e
  467. }
  468. }()), b.AjaxRequest = function() {
  469. var b, a = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Microsoft.XMLHTTP"];
  470. if (!window.ActiveXObject) return window.XMLHttpRequest ? new window.XMLHttpRequest : !1;
  471. for (b = 0; b < a.length; b++) try {
  472. return new window.ActiveXObject(a[b])
  473. } catch (c) {}
  474. }, b.canUseNewCanvasBlendModes = function() {
  475. var b, a = document.createElement("canvas");
  476. return a.width = 1, a.height = 1, b = a.getContext("2d"), b.fillStyle = "#000", b.fillRect(0, 0, 1, 1), b.globalCompositeOperation = "multiply", b.fillStyle = "#fff", b.fillRect(0, 0, 1, 1), 0 === b.getImageData(0, 0, 1, 1).data[0]
  477. }, b.getNextPowerOfTwo = function(a) {
  478. if (a > 0 && 0 === (a & a - 1)) return a;
  479. for (var b = 1; a > b;) b <<= 1;
  480. return b
  481. }, b.EventTarget = function() {
  482. var a = {};
  483. this.addEventListener = this.on = function(b, c) {
  484. void 0 === a[b] && (a[b] = []), -1 === a[b].indexOf(c) && a[b].unshift(c)
  485. }, this.dispatchEvent = this.emit = function(b) {
  486. if (a[b.type] && a[b.type].length)
  487. for (var c = a[b.type].length - 1; c >= 0; c--) a[b.type][c](b)
  488. }, this.removeEventListener = this.off = function(b, c) {
  489. if (void 0 !== a[b]) {
  490. var d = a[b].indexOf(c); - 1 !== d && a[b].splice(d, 1)
  491. }
  492. }, this.removeAllEventListeners = function(b) {
  493. var c = a[b];
  494. c && (c.length = 0)
  495. }
  496. }, b.PolyK = {}, b.PolyK.Triangulate = function(a) {
  497. var e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, c = !0,
  498. d = a.length >> 1;
  499. if (3 > d) return [];
  500. for (e = [], f = [], g = 0; d > g; g++) f.push(g);
  501. for (g = 0, h = d; h > 3;) {
  502. if (i = f[(g + 0) % h], j = f[(g + 1) % h], k = f[(g + 2) % h], l = a[2 * i], m = a[2 * i + 1], n = a[2 * j], o = a[2 * j + 1], p = a[2 * k], q = a[2 * k + 1], r = !1, b.PolyK._convex(l, m, n, o, p, q, c))
  503. for (r = !0, s = 0; h > s; s++)
  504. if (t = f[s], t !== i && t !== j && t !== k && b.PolyK._PointInTriangle(a[2 * t], a[2 * t + 1], l, m, n, o, p, q)) {
  505. r = !1;
  506. break
  507. }
  508. if (r) e.push(i, j, k), f.splice((g + 1) % h, 1), h--, g = 0;
  509. else if (g++ > 3 * h) {
  510. if (!c) return window.console.log("PIXI Warning: shape too complex to fill"), [];
  511. for (e = [], f = [], g = 0; d > g; g++) f.push(g);
  512. g = 0, h = d, c = !1
  513. }
  514. }
  515. return e.push(f[0], f[1], f[2]), e
  516. }, b.PolyK._PointInTriangle = function(a, b, c, d, e, f, g, h) {
  517. var i = g - c,
  518. j = h - d,
  519. k = e - c,
  520. l = f - d,
  521. m = a - c,
  522. n = b - d,
  523. o = i * i + j * j,
  524. p = i * k + j * l,
  525. q = i * m + j * n,
  526. r = k * k + l * l,
  527. s = k * m + l * n,
  528. t = 1 / (o * r - p * p),
  529. u = (r * q - p * s) * t,
  530. v = (o * s - p * q) * t;
  531. return u >= 0 && v >= 0 && 1 > u + v
  532. }, b.PolyK._convex = function(a, b, c, d, e, f, g) {
  533. return (b - d) * (e - c) + (c - a) * (f - d) >= 0 === g
  534. }, b.initDefaultShaders = function() {}, b.CompileVertexShader = function(a, c) {
  535. return b._CompileShader(a, c, a.VERTEX_SHADER)
  536. }, b.CompileFragmentShader = function(a, c) {
  537. return b._CompileShader(a, c, a.FRAGMENT_SHADER)
  538. }, b._CompileShader = function(a, b, c) {
  539. var d = b.join("\n"),
  540. e = a.createShader(c);
  541. return a.shaderSource(e, d), a.compileShader(e), a.getShaderParameter(e, a.COMPILE_STATUS) ? e : (window.console.log(a.getShaderInfoLog(e)), null)
  542. }, b.compileProgram = function(a, c, d) {
  543. var e = b.CompileFragmentShader(a, d),
  544. f = b.CompileVertexShader(a, c),
  545. g = a.createProgram();
  546. return a.attachShader(g, f), a.attachShader(g, e), a.linkProgram(g), a.getProgramParameter(g, a.LINK_STATUS) || window.console.log("Could not initialise shaders"), g
  547. }, b.PixiShader = function(a) {
  548. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision lowp float;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"], this.textureCount = 0, this.attributes = [], this.init()
  549. }, b.PixiShader.prototype.init = function() {
  550. var d, a = this.gl,
  551. c = b.compileProgram(a, this.vertexSrc || b.PixiShader.defaultVertexSrc, this.fragmentSrc);
  552. a.useProgram(c), this.uSampler = a.getUniformLocation(c, "uSampler"), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.dimensions = a.getUniformLocation(c, "dimensions"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.aTextureCoord = a.getAttribLocation(c, "aTextureCoord"), this.colorAttribute = a.getAttribLocation(c, "aColor"), -1 === this.colorAttribute && (this.colorAttribute = 2), this.attributes = [this.aVertexPosition, this.aTextureCoord, this.colorAttribute];
  553. for (d in this.uniforms) this.uniforms[d].uniformLocation = a.getUniformLocation(c, d);
  554. this.initUniforms(), this.program = c
  555. }, b.PixiShader.prototype.initUniforms = function() {
  556. var a, b, c, d;
  557. this.textureCount = 1, a = this.gl;
  558. for (c in this.uniforms) b = this.uniforms[c], d = b.type, "sampler2D" === d ? (b._init = !1, null !== b.value && this.initSampler2D(b)) : "mat2" === d || "mat3" === d || "mat4" === d ? (b.glMatrix = !0, b.glValueLength = 1, "mat2" === d ? b.glFunc = a.uniformMatrix2fv : "mat3" === d ? b.glFunc = a.uniformMatrix3fv : "mat4" === d && (b.glFunc = a.uniformMatrix4fv)) : (b.glFunc = a["uniform" + d], b.glValueLength = "2f" === d || "2i" === d ? 2 : "3f" === d || "3i" === d ? 3 : "4f" === d || "4i" === d ? 4 : 1)
  559. }, b.PixiShader.prototype.initSampler2D = function(a) {
  560. var b, c, d, e, f, g, h, i, j, k;
  561. a.value && a.value.baseTexture && a.value.baseTexture.hasLoaded && (b = this.gl, b.activeTexture(b["TEXTURE" + this.textureCount]), b.bindTexture(b.TEXTURE_2D, a.value.baseTexture._glTextures[b.id]), a.textureData && (c = a.textureData, d = c.magFilter ? c.magFilter : b.LINEAR, e = c.minFilter ? c.minFilter : b.LINEAR, f = c.wrapS ? c.wrapS : b.CLAMP_TO_EDGE, g = c.wrapT ? c.wrapT : b.CLAMP_TO_EDGE, h = c.luminance ? b.LUMINANCE : b.RGBA, c.repeat && (f = b.REPEAT, g = b.REPEAT), b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL, !!c.flipY), c.width ? (i = c.width ? c.width : 512, j = c.height ? c.height : 2, k = c.border ? c.border : 0, b.texImage2D(b.TEXTURE_2D, 0, h, i, j, k, h, b.UNSIGNED_BYTE, null)) : b.texImage2D(b.TEXTURE_2D, 0, h, b.RGBA, b.UNSIGNED_BYTE, a.value.baseTexture.source), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, d), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, e), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, f), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, g)), b.uniform1i(a.uniformLocation, this.textureCount), a._init = !0, this.textureCount++)
  562. }, b.PixiShader.prototype.syncUniforms = function() {
  563. var a, c, d;
  564. this.textureCount = 1, c = this.gl;
  565. for (d in this.uniforms) a = this.uniforms[d], 1 === a.glValueLength ? a.glMatrix === !0 ? a.glFunc.call(c, a.uniformLocation, a.transpose, a.value) : a.glFunc.call(c, a.uniformLocation, a.value) : 2 === a.glValueLength ? a.glFunc.call(c, a.uniformLocation, a.value.x, a.value.y) : 3 === a.glValueLength ? a.glFunc.call(c, a.uniformLocation, a.value.x, a.value.y, a.value.z) : 4 === a.glValueLength ? a.glFunc.call(c, a.uniformLocation, a.value.x, a.value.y, a.value.z, a.value.w) : "sampler2D" === a.type && (a._init ? (c.activeTexture(c["TEXTURE" + this.textureCount]), c.bindTexture(c.TEXTURE_2D, a.value.baseTexture._glTextures[c.id] || b.createWebGLTexture(a.value.baseTexture, c)), c.uniform1i(a.uniformLocation, this.textureCount), this.textureCount++) : this.initSampler2D(a))
  566. }, b.PixiShader.prototype.destroy = function() {
  567. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  568. }, b.PixiShader.defaultVertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "attribute vec2 aColor;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "const vec2 center = vec2(-1.0, 1.0);", "void main(void) {", " gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", " vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;", " vColor = vec4(color * aColor.x, aColor.x);", "}"], b.PixiFastShader = function(a) {
  569. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision lowp float;", "varying vec2 vTextureCoord;", "varying float vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aPositionCoord;", "attribute vec2 aScale;", "attribute float aRotation;", "attribute vec2 aTextureCoord;", "attribute float aColor;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform mat3 uMatrix;", "varying vec2 vTextureCoord;", "varying float vColor;", "const vec2 center = vec2(-1.0, 1.0);", "void main(void) {", " vec2 v;", " vec2 sv = aVertexPosition * aScale;", " v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);", " v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);", " v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;", " gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", " vColor = aColor;", "}"], this.textureCount = 0, this.init()
  570. }, b.PixiFastShader.prototype.init = function() {
  571. var a = this.gl,
  572. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  573. a.useProgram(c), this.uSampler = a.getUniformLocation(c, "uSampler"), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.dimensions = a.getUniformLocation(c, "dimensions"), this.uMatrix = a.getUniformLocation(c, "uMatrix"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.aPositionCoord = a.getAttribLocation(c, "aPositionCoord"), this.aScale = a.getAttribLocation(c, "aScale"), this.aRotation = a.getAttribLocation(c, "aRotation"), this.aTextureCoord = a.getAttribLocation(c, "aTextureCoord"), this.colorAttribute = a.getAttribLocation(c, "aColor"), -1 === this.colorAttribute && (this.colorAttribute = 2), this.attributes = [this.aVertexPosition, this.aPositionCoord, this.aScale, this.aRotation, this.aTextureCoord, this.colorAttribute], this.program = c
  574. }, b.PixiFastShader.prototype.destroy = function() {
  575. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null
  576. }, b.StripShader = function(a) {
  577. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec2 vTextureCoord;", "uniform float alpha;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", "}"], this.init()
  578. }, b.StripShader.prototype.init = function() {
  579. var a = this.gl,
  580. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  581. a.useProgram(c), this.uSampler = a.getUniformLocation(c, "uSampler"), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.colorAttribute = a.getAttribLocation(c, "aColor"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.aTextureCoord = a.getAttribLocation(c, "aTextureCoord"), this.attributes = [this.aVertexPosition, this.aTextureCoord], this.translationMatrix = a.getUniformLocation(c, "translationMatrix"), this.alpha = a.getUniformLocation(c, "alpha"), this.program = c
  582. }, b.PrimitiveShader = function(a) {
  583. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec4 aColor;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform float alpha;", "uniform vec3 tint;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vColor = aColor * vec4(tint * alpha, alpha);", "}"], this.init()
  584. }, b.PrimitiveShader.prototype.init = function() {
  585. var a = this.gl,
  586. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  587. a.useProgram(c), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.tintColor = a.getUniformLocation(c, "tint"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.colorAttribute = a.getAttribLocation(c, "aColor"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = a.getUniformLocation(c, "translationMatrix"), this.alpha = a.getUniformLocation(c, "alpha"), this.program = c
  588. }, b.PrimitiveShader.prototype.destroy = function() {
  589. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  590. }, b.ComplexPrimitiveShader = function(a) {
  591. this._UID = b._UID++, this.gl = a, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform vec3 tint;", "uniform float alpha;", "uniform vec3 color;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vColor = vec4(color * alpha * tint, alpha);", "}"], this.init()
  592. }, b.ComplexPrimitiveShader.prototype.init = function() {
  593. var a = this.gl,
  594. c = b.compileProgram(a, this.vertexSrc, this.fragmentSrc);
  595. a.useProgram(c), this.projectionVector = a.getUniformLocation(c, "projectionVector"), this.offsetVector = a.getUniformLocation(c, "offsetVector"), this.tintColor = a.getUniformLocation(c, "tint"), this.color = a.getUniformLocation(c, "color"), this.aVertexPosition = a.getAttribLocation(c, "aVertexPosition"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = a.getUniformLocation(c, "translationMatrix"), this.alpha = a.getUniformLocation(c, "alpha"), this.program = c
  596. }, b.ComplexPrimitiveShader.prototype.destroy = function() {
  597. this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null
  598. }, b.WebGLGraphics = function() {}, b.WebGLGraphics.renderGraphics = function(a, c) {
  599. var h, i, j, d = c.gl,
  600. e = c.projection,
  601. f = c.offset,
  602. g = c.shaderManager.primitiveShader;
  603. for (a.dirty && b.WebGLGraphics.updateGraphics(a, d), i = a._webGL[d.id], j = 0; j < i.data.length; j++) 1 === i.data[j].mode ? (h = i.data[j], c.stencilManager.pushStencil(a, h, c), d.drawElements(d.TRIANGLE_FAN, 4, d.UNSIGNED_SHORT, 2 * (h.indices.length - 4)), c.stencilManager.popStencil(a, h, c), this.last = h.mode) : (h = i.data[j], c.shaderManager.setShader(g), g = c.shaderManager.primitiveShader, d.uniformMatrix3fv(g.translationMatrix, !1, a.worldTransform.toArray(!0)), d.uniform2f(g.projectionVector, e.x, -e.y), d.uniform2f(g.offsetVector, -f.x, -f.y), d.uniform3fv(g.tintColor, b.hex2rgb(a.tint)), d.uniform1f(g.alpha, a.worldAlpha), d.bindBuffer(d.ARRAY_BUFFER, h.buffer), d.vertexAttribPointer(g.aVertexPosition, 2, d.FLOAT, !1, 24, 0), d.vertexAttribPointer(g.colorAttribute, 4, d.FLOAT, !1, 24, 8), d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, h.indexBuffer), d.drawElements(d.TRIANGLE_STRIP, h.indices.length, d.UNSIGNED_SHORT, 0))
  604. }, b.WebGLGraphics.updateGraphics = function(a, c) {
  605. var e, f, g, h, d = a._webGL[c.id];
  606. if (d || (d = a._webGL[c.id] = {
  607. lastIndex: 0,
  608. data: [],
  609. gl: c
  610. }), a.dirty = !1, a.clearDirty) {
  611. for (a.clearDirty = !1, e = 0; e < d.data.length; e++) f = d.data[e], f.reset(), b.WebGLGraphics.graphicsDataPool.push(f);
  612. d.data = [], d.lastIndex = 0
  613. }
  614. for (e = d.lastIndex; e < a.graphicsData.length; e++) h = a.graphicsData[e], h.type === b.Graphics.POLY ? (h.fill && h.points.length > 6 && (h.points.length > 10 ? (g = b.WebGLGraphics.switchMode(d, 1), b.WebGLGraphics.buildComplexPoly(h, g)) : (g = b.WebGLGraphics.switchMode(d, 0), b.WebGLGraphics.buildPoly(h, g))), h.lineWidth > 0 && (g = b.WebGLGraphics.switchMode(d, 0), b.WebGLGraphics.buildLine(h, g))) : (g = b.WebGLGraphics.switchMode(d, 0), h.type === b.Graphics.RECT ? b.WebGLGraphics.buildRectangle(h, g) : h.type === b.Graphics.CIRC || h.type === b.Graphics.ELIP ? b.WebGLGraphics.buildCircle(h, g) : h.type === b.Graphics.RREC && b.WebGLGraphics.buildRoundedRectangle(h, g)), d.lastIndex++;
  615. for (e = 0; e < d.data.length; e++) g = d.data[e], g.dirty && g.upload()
  616. }, b.WebGLGraphics.switchMode = function(a, c) {
  617. var d;
  618. return a.data.length ? (d = a.data[a.data.length - 1], (d.mode !== c || 1 === c) && (d = b.WebGLGraphics.graphicsDataPool.pop() || new b.WebGLGraphicsData(a.gl), d.mode = c, a.data.push(d))) : (d = b.WebGLGraphics.graphicsDataPool.pop() || new b.WebGLGraphicsData(a.gl), d.mode = c, a.data.push(d)), d.dirty = !0, d
  619. }, b.WebGLGraphics.buildRectangle = function(a, c) {
  620. var i, j, k, l, m, n, o, p, q, d = a.points,
  621. e = d[0],
  622. f = d[1],
  623. g = d[2],
  624. h = d[3];
  625. a.fill && (i = b.hex2rgb(a.fillColor), j = a.fillAlpha, k = i[0] * j, l = i[1] * j, m = i[2] * j, n = c.points, o = c.indices, p = n.length / 6, n.push(e, f), n.push(k, l, m, j), n.push(e + g, f), n.push(k, l, m, j), n.push(e, f + h), n.push(k, l, m, j), n.push(e + g, f + h), n.push(k, l, m, j), o.push(p, p, p + 1, p + 2, p + 3, p + 3)), a.lineWidth && (q = a.points, a.points = [e, f, e + g, f, e + g, f + h, e, f + h, e, f], b.WebGLGraphics.buildLine(a, c), a.points = q)
  626. }, b.WebGLGraphics.buildRoundedRectangle = function(a, c) {
  627. var k, l, m, n, o, p, q, r, s, t, u, d = a.points,
  628. e = d[0],
  629. f = d[1],
  630. g = d[2],
  631. h = d[3],
  632. i = d[4],
  633. j = [];
  634. if (j.push(e, f + i), j = j.concat(b.WebGLGraphics.quadraticBezierCurve(e, f + h - i, e, f + h, e + i, f + h)), j = j.concat(b.WebGLGraphics.quadraticBezierCurve(e + g - i, f + h, e + g, f + h, e + g, f + h - i)), j = j.concat(b.WebGLGraphics.quadraticBezierCurve(e + g, f + i, e + g, f, e + g - i, f)), j = j.concat(b.WebGLGraphics.quadraticBezierCurve(e + i, f, e, f, e, f + i)), a.fill) {
  635. for (k = b.hex2rgb(a.fillColor), l = a.fillAlpha, m = k[0] * l, n = k[1] * l, o = k[2] * l, p = c.points, q = c.indices, r = p.length / 6, s = b.PolyK.Triangulate(j), t = 0, t = 0; t < s.length; t += 3) q.push(s[t] + r), q.push(s[t] + r), q.push(s[t + 1] + r), q.push(s[t + 2] + r), q.push(s[t + 2] + r);
  636. for (t = 0; t < j.length; t++) p.push(j[t], j[++t], m, n, o, l)
  637. }
  638. a.lineWidth && (u = a.points, a.points = j, b.WebGLGraphics.buildLine(a, c), a.points = u)
  639. }, b.WebGLGraphics.quadraticBezierCurve = function(a, b, c, d, e, f) {
  640. function o(a, b, c) {
  641. var d = b - a;
  642. return a + d * c
  643. }
  644. var g, h, i, j, k, l, q, m = 20,
  645. n = [],
  646. p = 0;
  647. for (q = 0; m >= q; q++) p = q / m, g = o(a, c, p), h = o(b, d, p), i = o(c, e, p), j = o(d, f, p), k = o(g, i, p), l = o(h, j, p), n.push(k, l);
  648. return n
  649. }, b.WebGLGraphics.buildCircle = function(a, c) {
  650. var l, m, n, o, p, q, r, s, t, d = a.points,
  651. e = d[0],
  652. f = d[1],
  653. g = d[2],
  654. h = d[3],
  655. i = 40,
  656. j = 2 * Math.PI / i,
  657. k = 0;
  658. if (a.fill) {
  659. for (l = b.hex2rgb(a.fillColor), m = a.fillAlpha, n = l[0] * m, o = l[1] * m, p = l[2] * m, q = c.points, r = c.indices, s = q.length / 6, r.push(s), k = 0; i + 1 > k; k++) q.push(e, f, n, o, p, m), q.push(e + Math.sin(j * k) * g, f + Math.cos(j * k) * h, n, o, p, m), r.push(s++, s++);
  660. r.push(s - 1)
  661. }
  662. if (a.lineWidth) {
  663. for (t = a.points, a.points = [], k = 0; i + 1 > k; k++) a.points.push(e + Math.sin(j * k) * g, f + Math.cos(j * k) * h);
  664. b.WebGLGraphics.buildLine(a, c), a.points = t
  665. }
  666. }, b.WebGLGraphics.buildLine = function(a, c) {
  667. var f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, d = 0,
  668. e = a.points;
  669. if (0 !== e.length) {
  670. if (a.lineWidth % 2)
  671. for (d = 0; d < e.length; d++) e[d] += .5;
  672. for (f = new b.Point(e[0], e[1]), g = new b.Point(e[e.length - 2], e[e.length - 1]), f.x === g.x && f.y === g.y && (e = e.slice(), e.pop(), e.pop(), g = new b.Point(e[e.length - 2], e[e.length - 1]), h = g.x + .5 * (f.x - g.x), i = g.y + .5 * (f.y - g.y), e.unshift(h, i), e.push(h, i)), j = c.points, k = c.indices, l = e.length / 2, m = e.length, n = j.length / 6, o = a.lineWidth / 2, p = b.hex2rgb(a.lineColor), q = a.lineAlpha, r = p[0] * q, s = p[1] * q, t = p[2] * q, w = e[0], x = e[1], y = e[2], z = e[3], C = -(x - z), D = w - y, Q = Math.sqrt(C * C + D * D), C /= Q, D /= Q, C *= o, D *= o, j.push(w - C, x - D, r, s, t, q), j.push(w + C, x + D, r, s, t, q), d = 1; l - 1 > d; d++) w = e[2 * (d - 1)], x = e[2 * (d - 1) + 1], y = e[2 * d], z = e[2 * d + 1], A = e[2 * (d + 1)], B = e[2 * (d + 1) + 1], C = -(x - z), D = w - y, Q = Math.sqrt(C * C + D * D), C /= Q, D /= Q, C *= o, D *= o, E = -(z - B), F = y - A, Q = Math.sqrt(E * E + F * F), E /= Q, F /= Q, E *= o, F *= o, I = -D + x - (-D + z), J = -C + y - (-C + w), K = (-C + w) * (-D + z) - (-C + y) * (-D + x), L = -F + B - (-F + z), M = -E + y - (-E + A), N = (-E + A) * (-F + z) - (-E + y) * (-F + B), O = I * M - L * J, Math.abs(O) < .1 ? (O += 10.1, j.push(y - C, z - D, r, s, t, q), j.push(y + C, z + D, r, s, t, q)) : (u = (J * N - M * K) / O, v = (L * K - I * N) / O, P = (u - y) * (u - y) + (v - z) + (v - z), P > 19600 ? (G = C - E, H = D - F, Q = Math.sqrt(G * G + H * H), G /= Q, H /= Q, G *= o, H *= o, j.push(y - G, z - H), j.push(r, s, t, q), j.push(y + G, z + H), j.push(r, s, t, q), j.push(y - G, z - H), j.push(r, s, t, q), m++) : (j.push(u, v), j.push(r, s, t, q), j.push(y - (u - y), z - (v - z)), j.push(r, s, t, q)));
  673. for (w = e[2 * (l - 2)], x = e[2 * (l - 2) + 1], y = e[2 * (l - 1)], z = e[2 * (l - 1) + 1], C = -(x - z), D = w - y, Q = Math.sqrt(C * C + D * D), C /= Q, D /= Q, C *= o, D *= o, j.push(y - C, z - D), j.push(r, s, t, q), j.push(y + C, z + D), j.push(r, s, t, q), k.push(n), d = 0; m > d; d++) k.push(n++);
  674. k.push(n - 1)
  675. }
  676. }, b.WebGLGraphics.buildComplexPoly = function(a, c) {
  677. var e, f, g, h, i, j, k, l, m, d = a.points.slice();
  678. if (!(d.length < 6)) {
  679. for (e = c.indices, c.points = d, c.alpha = a.fillAlpha, c.color = b.hex2rgb(a.fillColor), f = 1 / 0, g = -1 / 0, h = 1 / 0, i = -1 / 0, l = 0; l < d.length; l += 2) j = d[l], k = d[l + 1], f = f > j ? j : f, g = j > g ? j : g, h = h > k ? k : h, i = k > i ? k : i;
  680. for (d.push(f, h, g, h, g, i, f, i), m = d.length / 2, l = 0; m > l; l++) e.push(l)
  681. }
  682. }, b.WebGLGraphics.buildPoly = function(a, c) {
  683. var e, f, g, h, i, j, k, l, m, n, o, d = a.points;
  684. if (!(d.length < 6)) {
  685. for (e = c.points, f = c.indices, g = d.length / 2, h = b.hex2rgb(a.fillColor), i = a.fillAlpha, j = h[0] * i, k = h[1] * i, l = h[2] * i, m = b.PolyK.Triangulate(d), n = e.length / 6, o = 0, o = 0; o < m.length; o += 3) f.push(m[o] + n), f.push(m[o] + n), f.push(m[o + 1] + n), f.push(m[o + 2] + n), f.push(m[o + 2] + n);
  686. for (o = 0; g > o; o++) e.push(d[2 * o], d[2 * o + 1], j, k, l, i)
  687. }
  688. }, b.WebGLGraphics.graphicsDataPool = [], b.WebGLGraphicsData = function(a) {
  689. this.gl = a, this.color = [0, 0, 0], this.points = [], this.indices = [], this.lastIndex = 0, this.buffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.mode = 1, this.alpha = 1, this.dirty = !0
  690. }, b.WebGLGraphicsData.prototype.reset = function() {
  691. this.points = [], this.indices = [], this.lastIndex = 0
  692. }, b.WebGLGraphicsData.prototype.upload = function() {
  693. var a = this.gl;
  694. this.glPoints = new Float32Array(this.points), a.bindBuffer(a.ARRAY_BUFFER, this.buffer), a.bufferData(a.ARRAY_BUFFER, this.glPoints, a.STATIC_DRAW), this.glIndicies = new Uint16Array(this.indices), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, this.glIndicies, a.STATIC_DRAW), this.dirty = !1
  695. }, b.glContexts = [], b.WebGLRenderer = function(a, c, d, e, f, g) {
  696. b.defaultRenderer || (b.sayHello("webGL"), b.defaultRenderer = this), this.type = b.WEBGL_RENDERER, this.transparent = !!e, this.preserveDrawingBuffer = g, this.width = a || 800, this.height = c || 600, this.view = d || document.createElement("canvas"), this.view.width = this.width, this.view.height = this.height, this.contextLost = this.handleContextLost.bind(this), this.contextRestoredLost = this.handleContextRestored.bind(this), this.view.addEventListener("webglcontextlost", this.contextLost, !1), this.view.addEventListener("webglcontextrestored", this.contextRestoredLost, !1), this.options = {
  697. alpha: this.transparent,
  698. antialias: !!f,
  699. premultipliedAlpha: !!e,
  700. stencil: !0,
  701. preserveDrawingBuffer: g
  702. };
  703. var h = null;
  704. if (["experimental-webgl", "webgl"].forEach(function(a) {
  705. try {
  706. h = h || this.view.getContext(a, this.options)
  707. } catch (b) {}
  708. }, this), !h) throw new Error("This browser does not support webGL. Try using the canvas renderer" + this);
  709. this.gl = h, this.glContextId = h.id = b.WebGLRenderer.glContextId++, b.glContexts[this.glContextId] = h, b.blendModesWebGL || (b.blendModesWebGL = [], b.blendModesWebGL[b.blendModes.NORMAL] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.ADD] = [h.SRC_ALPHA, h.DST_ALPHA], b.blendModesWebGL[b.blendModes.MULTIPLY] = [h.DST_COLOR, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SCREEN] = [h.SRC_ALPHA, h.ONE], b.blendModesWebGL[b.blendModes.OVERLAY] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.DARKEN] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.LIGHTEN] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR_DODGE] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR_BURN] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.HARD_LIGHT] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SOFT_LIGHT] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.DIFFERENCE] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.EXCLUSION] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.HUE] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.SATURATION] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.COLOR] = [h.ONE, h.ONE_MINUS_SRC_ALPHA], b.blendModesWebGL[b.blendModes.LUMINOSITY] = [h.ONE, h.ONE_MINUS_SRC_ALPHA]), this.projection = new b.Point, this.projection.x = this.width / 2, this.projection.y = -this.height / 2, this.offset = new b.Point(0, 0), this.resize(this.width, this.height), this.contextLost = !1, this.shaderManager = new b.WebGLShaderManager(h), this.spriteBatch = new b.WebGLSpriteBatch(h), this.maskManager = new b.WebGLMaskManager(h), this.filterManager = new b.WebGLFilterManager(h, this.transparent), this.stencilManager = new b.WebGLStencilManager(h), this.blendModeManager = new b.WebGLBlendModeManager(h), this.renderSession = {}, this.renderSession.gl = this.gl, this.renderSession.drawCount = 0, this.renderSession.shaderManager = this.shaderManager, this.renderSession.maskManager = this.maskManager, this.renderSession.filterManager = this.filterManager, this.renderSession.blendModeManager = this.blendModeManager, this.renderSession.spriteBatch = this.spriteBatch, this.renderSession.stencilManager = this.stencilManager, this.renderSession.renderer = this, h.useProgram(this.shaderManager.defaultShader.program), h.disable(h.DEPTH_TEST), h.disable(h.CULL_FACE), h.enable(h.BLEND), h.colorMask(!0, !0, !0, this.transparent)
  710. }, b.WebGLRenderer.prototype.constructor = b.WebGLRenderer, b.WebGLRenderer.prototype.render = function(a) {
  711. if (!this.contextLost) {
  712. this.__stage !== a && (a.interactive && a.interactionManager.removeEvents(), this.__stage = a), b.WebGLRenderer.updateTextures(), a.updateTransform(), a._interactive && (a._interactiveEventsAdded || (a._interactiveEventsAdded = !0, a.interactionManager.setTarget(this)));
  713. var c = this.gl;
  714. c.viewport(0, 0, this.width, this.height), c.bindFramebuffer(c.FRAMEBUFFER, null), this.transparent ? c.clearColor(0, 0, 0, 0) : c.clearColor(a.backgroundColorSplit[0], a.backgroundColorSplit[1], a.backgroundColorSplit[2], 1), c.clear(c.COLOR_BUFFER_BIT), this.renderDisplayObject(a, this.projection), a.interactive ? a._interactiveEventsAdded || (a._interactiveEventsAdded = !0, a.interactionManager.setTarget(this)) : a._interactiveEventsAdded && (a._interactiveEventsAdded = !1, a.interactionManager.setTarget(this))
  715. }
  716. }, b.WebGLRenderer.prototype.renderDisplayObject = function(a, c, d) {
  717. this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL), this.renderSession.drawCount = 0, this.renderSession.currentBlendMode = 9999, this.renderSession.projection = c, this.renderSession.offset = this.offset, this.spriteBatch.begin(this.renderSession), this.filterManager.begin(this.renderSession, d), a._renderWebGL(this.renderSession), this.spriteBatch.end()
  718. }, b.WebGLRenderer.updateTextures = function() {
  719. var a = 0;
  720. for (a = 0; a < b.Texture.frameUpdates.length; a++) b.WebGLRenderer.updateTextureFrame(b.Texture.frameUpdates[a]);
  721. for (a = 0; a < b.texturesToDestroy.length; a++) b.WebGLRenderer.destroyTexture(b.texturesToDestroy[a]);
  722. b.texturesToUpdate.length = 0, b.texturesToDestroy.length = 0, b.Texture.frameUpdates.length = 0
  723. }, b.WebGLRenderer.destroyTexture = function(a) {
  724. var c, d, e;
  725. for (c = a._glTextures.length - 1; c >= 0; c--) d = a._glTextures[c], e = b.glContexts[c], e && d && e.deleteTexture(d);
  726. a._glTextures.length = 0
  727. }, b.WebGLRenderer.updateTextureFrame = function(a) {
  728. a._updateWebGLuvs()
  729. }, b.WebGLRenderer.prototype.resize = function(a, b) {
  730. this.width = a, this.height = b, this.view.width = a, this.view.height = b, this.gl.viewport(0, 0, this.width, this.height), this.projection.x = this.width / 2, this.projection.y = -this.height / 2
  731. }, b.createWebGLTexture = function(a, c) {
  732. return a.hasLoaded && (a._glTextures[c.id] = c.createTexture(), c.bindTexture(c.TEXTURE_2D, a._glTextures[c.id]), c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL, a.premultipliedAlpha), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, c.RGBA, c.UNSIGNED_BYTE, a.source), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MAG_FILTER, a.scaleMode === b.scaleModes.LINEAR ? c.LINEAR : c.NEAREST), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MIN_FILTER, a.scaleMode === b.scaleModes.LINEAR ? c.LINEAR : c.NEAREST), a._powerOf2 ? (c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, c.REPEAT), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, c.REPEAT)) : (c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE)), c.bindTexture(c.TEXTURE_2D, null), a._dirty[c.id] = !1), a._glTextures[c.id]
  733. }, b.updateWebGLTexture = function(a, c) {
  734. a._glTextures[c.id] && (c.bindTexture(c.TEXTURE_2D, a._glTextures[c.id]), c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL, a.premultipliedAlpha), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, c.RGBA, c.UNSIGNED_BYTE, a.source), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MAG_FILTER, a.scaleMode === b.scaleModes.LINEAR ? c.LINEAR : c.NEAREST), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_MIN_FILTER, a.scaleMode === b.scaleModes.LINEAR ? c.LINEAR : c.NEAREST), a._powerOf2 ? (c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, c.REPEAT), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, c.REPEAT)) : (c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE), c.texParameteri(c.TEXTURE_2D, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE)), a._dirty[c.id] = !1)
  735. }, b.WebGLRenderer.prototype.handleContextLost = function(a) {
  736. a.preventDefault(), this.contextLost = !0
  737. }, b.WebGLRenderer.prototype.handleContextRestored = function() {
  738. var d, e, f;
  739. try {
  740. this.gl = this.view.getContext("experimental-webgl", this.options)
  741. } catch (a) {
  742. try {
  743. this.gl = this.view.getContext("webgl", this.options)
  744. } catch (c) {
  745. throw new Error(" This browser does not support webGL. Try using the canvas renderer" + this)
  746. }
  747. }
  748. d = this.gl, d.id = b.WebGLRenderer.glContextId++, this.shaderManager.setContext(d), this.spriteBatch.setContext(d), this.primitiveBatch.setContext(d), this.maskManager.setContext(d), this.filterManager.setContext(d), this.renderSession.gl = this.gl, d.disable(d.DEPTH_TEST), d.disable(d.CULL_FACE), d.enable(d.BLEND), d.colorMask(!0, !0, !0, this.transparent), this.gl.viewport(0, 0, this.width, this.height);
  749. for (e in b.TextureCache) f = b.TextureCache[e].baseTexture, f._glTextures = [];
  750. this.contextLost = !1
  751. }, b.WebGLRenderer.prototype.destroy = function() {
  752. this.view.removeEventListener("webglcontextlost", this.contextLost), this.view.removeEventListener("webglcontextrestored", this.contextRestoredLost), b.glContexts[this.glContextId] = null, this.projection = null, this.offset = null, this.shaderManager.destroy(), this.spriteBatch.destroy(), this.primitiveBatch.destroy(), this.maskManager.destroy(), this.filterManager.destroy(), this.shaderManager = null, this.spriteBatch = null, this.maskManager = null, this.filterManager = null, this.gl = null, this.renderSession = null
  753. }, b.WebGLRenderer.glContextId = 0, b.WebGLBlendModeManager = function(a) {
  754. this.gl = a, this.currentBlendMode = 99999
  755. }, b.WebGLBlendModeManager.prototype.setBlendMode = function(a) {
  756. if (this.currentBlendMode === a) return !1;
  757. this.currentBlendMode = a;
  758. var c = b.blendModesWebGL[this.currentBlendMode];
  759. return this.gl.blendFunc(c[0], c[1]), !0
  760. }, b.WebGLBlendModeManager.prototype.destroy = function() {
  761. this.gl = null
  762. }, b.WebGLMaskManager = function(a) {
  763. this.maskStack = [], this.maskPosition = 0, this.setContext(a), this.reverse = !1, this.count = 0
  764. }, b.WebGLMaskManager.prototype.setContext = function(a) {
  765. this.gl = a
  766. }, b.WebGLMaskManager.prototype.pushMask = function(a, c) {
  767. var d = c.gl;
  768. a.dirty && b.WebGLGraphics.updateGraphics(a, d), a._webGL[d.id].data.length && c.stencilManager.pushStencil(a, a._webGL[d.id].data[0], c)
  769. }, b.WebGLMaskManager.prototype.popMask = function(a, b) {
  770. var c = this.gl;
  771. b.stencilManager.popStencil(a, a._webGL[c.id].data[0], b)
  772. }, b.WebGLMaskManager.prototype.destroy = function() {
  773. this.maskStack = null, this.gl = null
  774. }, b.WebGLStencilManager = function(a) {
  775. this.stencilStack = [], this.setContext(a), this.reverse = !0, this.count = 0
  776. }, b.WebGLStencilManager.prototype.setContext = function(a) {
  777. this.gl = a
  778. }, b.WebGLStencilManager.prototype.pushStencil = function(a, b, c) {
  779. var e, d = this.gl;
  780. this.bindGraphics(a, b, c), 0 === this.stencilStack.length && (d.enable(d.STENCIL_TEST), d.clear(d.STENCIL_BUFFER_BIT), this.reverse = !0, this.count = 0), this.stencilStack.push(b), e = this.count, d.colorMask(!1, !1, !1, !1), d.stencilFunc(d.ALWAYS, 0, 255), d.stencilOp(d.KEEP, d.KEEP, d.INVERT), 1 === b.mode ? (d.drawElements(d.TRIANGLE_FAN, b.indices.length - 4, d.UNSIGNED_SHORT, 0), this.reverse ? (d.stencilFunc(d.EQUAL, 255 - e, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)) : (d.stencilFunc(d.EQUAL, e, 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)), d.drawElements(d.TRIANGLE_FAN, 4, d.UNSIGNED_SHORT, 2 * (b.indices.length - 4)), this.reverse ? d.stencilFunc(d.EQUAL, 255 - (e + 1), 255) : d.stencilFunc(d.EQUAL, e + 1, 255), this.reverse = !this.reverse) : (this.reverse ? (d.stencilFunc(d.EQUAL, e, 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)) : (d.stencilFunc(d.EQUAL, 255 - e, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)), d.drawElements(d.TRIANGLE_STRIP, b.indices.length, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e + 1, 255) : d.stencilFunc(d.EQUAL, 255 - (e + 1), 255)), d.colorMask(!0, !0, !0, !0), d.stencilOp(d.KEEP, d.KEEP, d.KEEP), this.count++
  781. }, b.WebGLStencilManager.prototype.bindGraphics = function(a, c, d) {
  782. var e, h, f, g;
  783. this._currentGraphics = a, e = this.gl, f = d.projection, g = d.offset, 1 === c.mode ? (h = d.shaderManager.complexPrimativeShader, d.shaderManager.setShader(h), e.uniformMatrix3fv(h.translationMatrix, !1, a.worldTransform.toArray(!0)), e.uniform2f(h.projectionVector, f.x, -f.y), e.uniform2f(h.offsetVector, -g.x, -g.y), e.uniform3fv(h.tintColor, b.hex2rgb(a.tint)), e.uniform3fv(h.color, c.color), e.uniform1f(h.alpha, a.worldAlpha * c.alpha), e.bindBuffer(e.ARRAY_BUFFER, c.buffer), e.vertexAttribPointer(h.aVertexPosition, 2, e.FLOAT, !1, 8, 0), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, c.indexBuffer)) : (h = d.shaderManager.primitiveShader, d.shaderManager.setShader(h), e.uniformMatrix3fv(h.translationMatrix, !1, a.worldTransform.toArray(!0)), e.uniform2f(h.projectionVector, f.x, -f.y), e.uniform2f(h.offsetVector, -g.x, -g.y), e.uniform3fv(h.tintColor, b.hex2rgb(a.tint)), e.uniform1f(h.alpha, a.worldAlpha), e.bindBuffer(e.ARRAY_BUFFER, c.buffer), e.vertexAttribPointer(h.aVertexPosition, 2, e.FLOAT, !1, 24, 0), e.vertexAttribPointer(h.colorAttribute, 4, e.FLOAT, !1, 24, 8), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, c.indexBuffer))
  784. }, b.WebGLStencilManager.prototype.popStencil = function(a, b, c) {
  785. var e, d = this.gl;
  786. this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length ? d.disable(d.STENCIL_TEST) : (e = this.count, this.bindGraphics(a, b, c), d.colorMask(!1, !1, !1, !1), 1 === b.mode ? (this.reverse = !this.reverse, this.reverse ? (d.stencilFunc(d.EQUAL, 255 - (e + 1), 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)) : (d.stencilFunc(d.EQUAL, e + 1, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)), d.drawElements(d.TRIANGLE_FAN, 4, d.UNSIGNED_SHORT, 2 * (b.indices.length - 4)), d.stencilFunc(d.ALWAYS, 0, 255), d.stencilOp(d.KEEP, d.KEEP, d.INVERT), d.drawElements(d.TRIANGLE_FAN, b.indices.length - 4, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e, 255) : d.stencilFunc(d.EQUAL, 255 - e, 255)) : (this.reverse ? (d.stencilFunc(d.EQUAL, e + 1, 255), d.stencilOp(d.KEEP, d.KEEP, d.DECR)) : (d.stencilFunc(d.EQUAL, 255 - (e + 1), 255), d.stencilOp(d.KEEP, d.KEEP, d.INCR)), d.drawElements(d.TRIANGLE_STRIP, b.indices.length, d.UNSIGNED_SHORT, 0), this.reverse ? d.stencilFunc(d.EQUAL, e, 255) : d.stencilFunc(d.EQUAL, 255 - e, 255)), d.colorMask(!0, !0, !0, !0), d.stencilOp(d.KEEP, d.KEEP, d.KEEP))
  787. }, b.WebGLStencilManager.prototype.destroy = function() {
  788. this.maskStack = null, this.gl = null
  789. }, b.WebGLShaderManager = function(a) {
  790. this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [], this.shaderMap = [];
  791. for (var b = 0; b < this.maxAttibs; b++) this.attribState[b] = !1;
  792. this.setContext(a)
  793. }, b.WebGLShaderManager.prototype.setContext = function(a) {
  794. this.gl = a, this.primitiveShader = new b.PrimitiveShader(a), this.complexPrimativeShader = new b.ComplexPrimitiveShader(a), this.defaultShader = new b.PixiShader(a), this.fastShader = new b.PixiFastShader(a), this.stripShader = new b.StripShader(a), this.setShader(this.defaultShader)
  795. }, b.WebGLShaderManager.prototype.setAttribs = function(a) {
  796. var b, c, d;
  797. for (b = 0; b < this.tempAttribState.length; b++) this.tempAttribState[b] = !1;
  798. for (b = 0; b < a.length; b++) c = a[b], this.tempAttribState[c] = !0;
  799. for (d = this.gl, b = 0; b < this.attribState.length; b++) this.attribState[b] !== this.tempAttribState[b] && (this.attribState[b] = this.tempAttribState[b], this.tempAttribState[b] ? d.enableVertexAttribArray(b) : d.disableVertexAttribArray(b))
  800. }, b.WebGLShaderManager.prototype.setShader = function(a) {
  801. return this._currentId === a._UID ? !1 : (this._currentId = a._UID, this.currentShader = a, this.gl.useProgram(a.program), this.setAttribs(a.attributes), !0)
  802. }, b.WebGLShaderManager.prototype.destroy = function() {
  803. this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null
  804. }, b.WebGLSpriteBatch = function(a) {
  805. var b, c, d, e;
  806. for (this.vertSize = 6, this.size = 2e3, b = 4 * this.size * this.vertSize, c = 6 * this.size, this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.lastIndexCount = 0, d = 0, e = 0; c > d; d += 6, e += 4) this.indices[d + 0] = e + 0, this.indices[d + 1] = e + 1, this.indices[d + 2] = e + 2, this.indices[d + 3] = e + 0, this.indices[d + 4] = e + 2, this.indices[d + 5] = e + 3;
  807. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.setContext(a), this.dirty = !0, this.textures = [], this.blendModes = []
  808. }, b.WebGLSpriteBatch.prototype.setContext = function(a) {
  809. this.gl = a, this.vertexBuffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, this.indices, a.STATIC_DRAW), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bufferData(a.ARRAY_BUFFER, this.vertices, a.DYNAMIC_DRAW), this.currentBlendMode = 99999
  810. }, b.WebGLSpriteBatch.prototype.begin = function(a) {
  811. this.renderSession = a, this.shader = this.renderSession.shaderManager.defaultShader, this.start()
  812. }, b.WebGLSpriteBatch.prototype.end = function() {
  813. this.flush()
  814. }, b.WebGLSpriteBatch.prototype.render = function(a) {
  815. var c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, b = a.texture;
  816. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = b.baseTexture), c = b._uvs, c && (d = a.worldAlpha, e = a.tint, f = this.vertices, g = a.anchor.x, h = a.anchor.y, b.trim ? (m = b.trim, j = m.x - g * m.width, i = j + b.crop.width, l = m.y - h * m.height, k = l + b.crop.height) : (i = b.frame.width * (1 - g), j = b.frame.width * -g, k = b.frame.height * (1 - h), l = b.frame.height * -h), n = 4 * this.currentBatchSize * this.vertSize, o = a.worldTransform, p = o.a, q = o.c, r = o.b, s = o.d, t = o.tx, u = o.ty, f[n++] = p * j + r * l + t, f[n++] = s * l + q * j + u, f[n++] = c.x0, f[n++] = c.y0, f[n++] = d, f[n++] = e, f[n++] = p * i + r * l + t, f[n++] = s * l + q * i + u, f[n++] = c.x1, f[n++] = c.y1, f[n++] = d, f[n++] = e, f[n++] = p * i + r * k + t, f[n++] = s * k + q * i + u, f[n++] = c.x2, f[n++] = c.y2, f[n++] = d, f[n++] = e, f[n++] = p * j + r * k + t, f[n++] = s * k + q * j + u, f[n++] = c.x3, f[n++] = c.y3, f[n++] = d, f[n++] = e, this.textures[this.currentBatchSize] = a.texture.baseTexture, this.blendModes[this.currentBatchSize] = a.blendMode, this.currentBatchSize++)
  817. }, b.WebGLSpriteBatch.prototype.renderTilingSprite = function(a) {
  818. var d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, c = a.tilingTexture;
  819. this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = c.baseTexture), a._uvs || (a._uvs = new b.TextureUvs), d = a._uvs, a.tilePosition.x %= c.baseTexture.width * a.tileScaleOffset.x, a.tilePosition.y %= c.baseTexture.height * a.tileScaleOffset.y, e = a.tilePosition.x / (c.baseTexture.width * a.tileScaleOffset.x), f = a.tilePosition.y / (c.baseTexture.height * a.tileScaleOffset.y), g = a.width / c.baseTexture.width / (a.tileScale.x * a.tileScaleOffset.x), h = a.height / c.baseTexture.height / (a.tileScale.y * a.tileScaleOffset.y), d.x0 = 0 - e, d.y0 = 0 - f, d.x1 = 1 * g - e, d.y1 = 0 - f, d.x2 = 1 * g - e, d.y2 = 1 * h - f, d.x3 = 0 - e, d.y3 = 1 * h - f, i = a.worldAlpha, j = a.tint, k = this.vertices, l = a.width, m = a.height, n = a.anchor.x, o = a.anchor.y, p = l * (1 - n), q = l * -n, r = m * (1 - o), s = m * -o, t = 4 * this.currentBatchSize * this.vertSize, u = a.worldTransform, v = u.a, w = u.c, x = u.b, y = u.d, z = u.tx, A = u.ty, k[t++] = v * q + x * s + z, k[t++] = y * s + w * q + A, k[t++] = d.x0, k[t++] = d.y0, k[t++] = i, k[t++] = j, k[t++] = v * p + x * s + z, k[t++] = y * s + w * p + A, k[t++] = d.x1, k[t++] = d.y1, k[t++] = i, k[t++] = j, k[t++] = v * p + x * r + z, k[t++] = y * r + w * p + A, k[t++] = d.x2, k[t++] = d.y2, k[t++] = i, k[t++] = j, k[t++] = v * q + x * r + z, k[t++] = y * r + w * q + A, k[t++] = d.x3, k[t++] = d.y3, k[t++] = i, k[t++] = j, this.textures[this.currentBatchSize] = c.baseTexture, this.blendModes[this.currentBatchSize] = a.blendMode, this.currentBatchSize++
  820. }, b.WebGLSpriteBatch.prototype.flush = function() {
  821. var a, b, c, d, e, f, g, h, i, j, k, l;
  822. if (0 !== this.currentBatchSize) {
  823. for (a = this.gl, this.renderSession.shaderManager.setShader(this.renderSession.shaderManager.defaultShader), this.dirty && (this.dirty = !1, a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), b = this.renderSession.projection, a.uniform2f(this.shader.projectionVector, b.x, b.y), c = 4 * this.vertSize, a.vertexAttribPointer(this.shader.aVertexPosition, 2, a.FLOAT, !1, c, 0), a.vertexAttribPointer(this.shader.aTextureCoord, 2, a.FLOAT, !1, c, 8), a.vertexAttribPointer(this.shader.colorAttribute, 2, a.FLOAT, !1, c, 16)), this.currentBatchSize > .5 * this.size ? a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertices) : (d = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize), a.bufferSubData(a.ARRAY_BUFFER, 0, d)), g = 0, h = 0, i = null, j = this.renderSession.blendModeManager.currentBlendMode, k = 0, l = this.currentBatchSize; l > k; k++) e = this.textures[k], f = this.blendModes[k], (i !== e || j !== f) && (this.renderBatch(i, g, h), h = k, g = 0, i = e, j = f, this.renderSession.blendModeManager.setBlendMode(j)), g++;
  824. this.renderBatch(i, g, h), this.currentBatchSize = 0
  825. }
  826. }, b.WebGLSpriteBatch.prototype.renderBatch = function(a, c, d) {
  827. if (0 !== c) {
  828. var e = this.gl;
  829. e.bindTexture(e.TEXTURE_2D, a._glTextures[e.id] || b.createWebGLTexture(a, e)), a._dirty[e.id] && b.updateWebGLTexture(this.currentBaseTexture, e), e.drawElements(e.TRIANGLES, 6 * c, e.UNSIGNED_SHORT, 2 * 6 * d), this.renderSession.drawCount++
  830. }
  831. }, b.WebGLSpriteBatch.prototype.stop = function() {
  832. this.flush()
  833. }, b.WebGLSpriteBatch.prototype.start = function() {
  834. this.dirty = !0
  835. }, b.WebGLSpriteBatch.prototype.destroy = function() {
  836. this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null
  837. }, b.WebGLFastSpriteBatch = function(a) {
  838. var b, c, d, e;
  839. for (this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize, b = 4 * this.size * this.vertSize, c = 6 * this.maxSize, this.vertices = new Float32Array(b), this.indices = new Uint16Array(c), this.vertexBuffer = null, this.indexBuffer = null, this.lastIndexCount = 0, d = 0, e = 0; c > d; d += 6, e += 4) this.indices[d + 0] = e + 0, this.indices[d + 1] = e + 1, this.indices[d + 2] = e + 2, this.indices[d + 3] = e + 0, this.indices[d + 4] = e + 2, this.indices[d + 5] = e + 3;
  840. this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(a)
  841. }, b.WebGLFastSpriteBatch.prototype.setContext = function(a) {
  842. this.gl = a, this.vertexBuffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, this.indices, a.STATIC_DRAW), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bufferData(a.ARRAY_BUFFER, this.vertices, a.DYNAMIC_DRAW)
  843. }, b.WebGLFastSpriteBatch.prototype.begin = function(a, b) {
  844. this.renderSession = b, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = a.worldTransform.toArray(!0), this.start()
  845. }, b.WebGLFastSpriteBatch.prototype.end = function() {
  846. this.flush()
  847. }, b.WebGLFastSpriteBatch.prototype.render = function(a) {
  848. var d, e, b = a.children,
  849. c = b[0];
  850. if (c.texture._uvs) {
  851. for (this.currentBaseTexture = c.texture.baseTexture, c.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(c.blendMode)), d = 0, e = b.length; e > d; d++) this.renderSprite(b[d]);
  852. this.flush()
  853. }
  854. }, b.WebGLFastSpriteBatch.prototype.renderSprite = function(a) {
  855. var b, d, e, f, g, h, i, j, c, k;
  856. a.visible && (a.texture.baseTexture === this.currentBaseTexture || (this.flush(), this.currentBaseTexture = a.texture.baseTexture, a.texture._uvs)) && (c = this.vertices, b = a.texture._uvs, d = a.texture.frame.width, e = a.texture.frame.height, a.texture.trim ? (k = a.texture.trim, g = k.x - a.anchor.x * k.width, f = g + a.texture.crop.width, i = k.y - a.anchor.y * k.height, h = i + a.texture.crop.height) : (f = a.texture.frame.width * (1 - a.anchor.x), g = a.texture.frame.width * -a.anchor.x, h = a.texture.frame.height * (1 - a.anchor.y), i = a.texture.frame.height * -a.anchor.y), j = 4 * this.currentBatchSize * this.vertSize, c[j++] = g, c[j++] = i, c[j++] = a.position.x, c[j++] = a.position.y, c[j++] = a.scale.x, c[j++] = a.scale.y, c[j++] = a.rotation, c[j++] = b.x0, c[j++] = b.y1, c[j++] = a.alpha, c[j++] = f, c[j++] = i, c[j++] = a.position.x, c[j++] = a.position.y, c[j++] = a.scale.x, c[j++] = a.scale.y, c[j++] = a.rotation, c[j++] = b.x1, c[j++] = b.y1, c[j++] = a.alpha, c[j++] = f, c[j++] = h, c[j++] = a.position.x, c[j++] = a.position.y, c[j++] = a.scale.x, c[j++] = a.scale.y, c[j++] = a.rotation, c[j++] = b.x2, c[j++] = b.y2, c[j++] = a.alpha, c[j++] = g, c[j++] = h, c[j++] = a.position.x, c[j++] = a.position.y, c[j++] = a.scale.x, c[j++] = a.scale.y, c[j++] = a.rotation, c[j++] = b.x3, c[j++] = b.y3, c[j++] = a.alpha, this.currentBatchSize++, this.currentBatchSize >= this.size && this.flush())
  857. }, b.WebGLFastSpriteBatch.prototype.flush = function() {
  858. var a, c;
  859. 0 !== this.currentBatchSize && (a = this.gl, this.currentBaseTexture._glTextures[a.id] || b.createWebGLTexture(this.currentBaseTexture, a), a.bindTexture(a.TEXTURE_2D, this.currentBaseTexture._glTextures[a.id]), this.currentBatchSize > .5 * this.size ? a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertices) : (c = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize), a.bufferSubData(a.ARRAY_BUFFER, 0, c)), a.drawElements(a.TRIANGLES, 6 * this.currentBatchSize, a.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++)
  860. }, b.WebGLFastSpriteBatch.prototype.stop = function() {
  861. this.flush()
  862. }, b.WebGLFastSpriteBatch.prototype.start = function() {
  863. var b, c, a = this.gl;
  864. a.activeTexture(a.TEXTURE0), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), b = this.renderSession.projection, a.uniform2f(this.shader.projectionVector, b.x, b.y), a.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix), c = 4 * this.vertSize, a.vertexAttribPointer(this.shader.aVertexPosition, 2, a.FLOAT, !1, c, 0), a.vertexAttribPointer(this.shader.aPositionCoord, 2, a.FLOAT, !1, c, 8), a.vertexAttribPointer(this.shader.aScale, 2, a.FLOAT, !1, c, 16), a.vertexAttribPointer(this.shader.aRotation, 1, a.FLOAT, !1, c, 24), a.vertexAttribPointer(this.shader.aTextureCoord, 2, a.FLOAT, !1, c, 28), a.vertexAttribPointer(this.shader.colorAttribute, 1, a.FLOAT, !1, c, 36)
  865. }, b.WebGLFilterManager = function(a, b) {
  866. this.transparent = b, this.filterStack = [], this.offsetX = 0, this.offsetY = 0, this.setContext(a)
  867. }, b.WebGLFilterManager.prototype.setContext = function(a) {
  868. this.gl = a, this.texturePool = [], this.initShaderBuffers()
  869. }, b.WebGLFilterManager.prototype.begin = function(a, b) {
  870. this.renderSession = a, this.defaultShader = a.shaderManager.defaultShader;
  871. var c = this.renderSession.projection;
  872. this.width = 2 * c.x, this.height = 2 * -c.y, this.buffer = b
  873. }, b.WebGLFilterManager.prototype.pushFilter = function(a) {
  874. var f, g, h, i, c = this.gl,
  875. d = this.renderSession.projection,
  876. e = this.renderSession.offset;
  877. a._filterArea = a.target.filterArea || a.target.getBounds(), this.filterStack.push(a), f = a.filterPasses[0], this.offsetX += a._filterArea.x, this.offsetY += a._filterArea.y, g = this.texturePool.pop(), g ? g.resize(this.width, this.height) : g = new b.FilterTexture(this.gl, this.width, this.height), c.bindTexture(c.TEXTURE_2D, g.texture), h = a._filterArea, i = f.padding, h.x -= i, h.y -= i, h.width += 2 * i, h.height += 2 * i, h.x < 0 && (h.x = 0), h.width > this.width && (h.width = this.width), h.y < 0 && (h.y = 0), h.height > this.height && (h.height = this.height), c.bindFramebuffer(c.FRAMEBUFFER, g.frameBuffer), c.viewport(0, 0, h.width, h.height), d.x = h.width / 2, d.y = -h.height / 2, e.x = -h.x, e.y = -h.y, this.renderSession.shaderManager.setShader(this.defaultShader), c.uniform2f(this.defaultShader.projectionVector, h.width / 2, -h.height / 2), c.uniform2f(this.defaultShader.offsetVector, -h.x, -h.y), c.colorMask(!0, !0, !0, !0), c.clearColor(0, 0, 0, 0), c.clear(c.COLOR_BUFFER_BIT), a._glFilterTexture = g
  878. }, b.WebGLFilterManager.prototype.popFilter = function() {
  879. var h, i, j, k, l, m, n, o, p, q, r, s, t, u, a = this.gl,
  880. c = this.filterStack.pop(),
  881. d = c._filterArea,
  882. e = c._glFilterTexture,
  883. f = this.renderSession.projection,
  884. g = this.renderSession.offset;
  885. if (c.filterPasses.length > 1) {
  886. for (a.viewport(0, 0, d.width, d.height), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = 0, this.vertexArray[1] = d.height, this.vertexArray[2] = d.width, this.vertexArray[3] = d.height, this.vertexArray[4] = 0, this.vertexArray[5] = 0, this.vertexArray[6] = d.width, this.vertexArray[7] = 0, a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertexArray), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = d.width / this.width, this.uvArray[5] = d.height / this.height, this.uvArray[6] = d.width / this.width, this.uvArray[7] = d.height / this.height, a.bufferSubData(a.ARRAY_BUFFER, 0, this.uvArray), h = e, i = this.texturePool.pop(), i || (i = new b.FilterTexture(this.gl, this.width, this.height)), i.resize(this.width, this.height), a.bindFramebuffer(a.FRAMEBUFFER, i.frameBuffer), a.clear(a.COLOR_BUFFER_BIT), a.disable(a.BLEND), j = 0; j < c.filterPasses.length - 1; j++) k = c.filterPasses[j], a.bindFramebuffer(a.FRAMEBUFFER, i.frameBuffer), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, h.texture), this.applyFilterPass(k, d, d.width, d.height), l = h, h = i, i = l;
  887. a.enable(a.BLEND), e = h, this.texturePool.push(i)
  888. }
  889. m = c.filterPasses[c.filterPasses.length - 1], this.offsetX -= d.x, this.offsetY -= d.y, n = this.width, o = this.height, p = 0, q = 0, r = this.buffer, 0 === this.filterStack.length ? a.colorMask(!0, !0, !0, !0) : (s = this.filterStack[this.filterStack.length - 1], d = s._filterArea, n = d.width, o = d.height, p = d.x, q = d.y, r = s._glFilterTexture.frameBuffer), f.x = n / 2, f.y = -o / 2, g.x = p, g.y = q, d = c._filterArea, t = d.x - p, u = d.y - q, a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = t, this.vertexArray[1] = u + d.height, this.vertexArray[2] = t + d.width, this.vertexArray[3] = u + d.height, this.vertexArray[4] = t, this.vertexArray[5] = u, this.vertexArray[6] = t + d.width, this.vertexArray[7] = u, a.bufferSubData(a.ARRAY_BUFFER, 0, this.vertexArray), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = d.width / this.width, this.uvArray[5] = d.height / this.height, this.uvArray[6] = d.width / this.width, this.uvArray[7] = d.height / this.height, a.bufferSubData(a.ARRAY_BUFFER, 0, this.uvArray), a.viewport(0, 0, n, o), a.bindFramebuffer(a.FRAMEBUFFER, r), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, e.texture), this.applyFilterPass(m, d, n, o), this.renderSession.shaderManager.setShader(this.defaultShader), a.uniform2f(this.defaultShader.projectionVector, n / 2, -o / 2), a.uniform2f(this.defaultShader.offsetVector, -p, -q), this.texturePool.push(e), c._glFilterTexture = null
  890. }, b.WebGLFilterManager.prototype.applyFilterPass = function(a, c, d, e) {
  891. var f = this.gl,
  892. g = a.shaders[f.id];
  893. g || (g = new b.PixiShader(f), g.fragmentSrc = a.fragmentSrc, g.uniforms = a.uniforms, g.init(), a.shaders[f.id] = g), this.renderSession.shaderManager.setShader(g), f.uniform2f(g.projectionVector, d / 2, -e / 2), f.uniform2f(g.offsetVector, 0, 0), a.uniforms.dimensions && (a.uniforms.dimensions.value[0] = this.width, a.uniforms.dimensions.value[1] = this.height, a.uniforms.dimensions.value[2] = this.vertexArray[0], a.uniforms.dimensions.value[3] = this.vertexArray[5]), g.syncUniforms(), f.bindBuffer(f.ARRAY_BUFFER, this.vertexBuffer), f.vertexAttribPointer(g.aVertexPosition, 2, f.FLOAT, !1, 0, 0), f.bindBuffer(f.ARRAY_BUFFER, this.uvBuffer), f.vertexAttribPointer(g.aTextureCoord, 2, f.FLOAT, !1, 0, 0), f.bindBuffer(f.ARRAY_BUFFER, this.colorBuffer), f.vertexAttribPointer(g.colorAttribute, 2, f.FLOAT, !1, 0, 0), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, this.indexBuffer), f.drawElements(f.TRIANGLES, 6, f.UNSIGNED_SHORT, 0), this.renderSession.drawCount++
  894. }, b.WebGLFilterManager.prototype.initShaderBuffers = function() {
  895. var a = this.gl;
  896. this.vertexBuffer = a.createBuffer(), this.uvBuffer = a.createBuffer(), this.colorBuffer = a.createBuffer(), this.indexBuffer = a.createBuffer(), this.vertexArray = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), a.bindBuffer(a.ARRAY_BUFFER, this.vertexBuffer), a.bufferData(a.ARRAY_BUFFER, this.vertexArray, a.STATIC_DRAW), this.uvArray = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), a.bindBuffer(a.ARRAY_BUFFER, this.uvBuffer), a.bufferData(a.ARRAY_BUFFER, this.uvArray, a.STATIC_DRAW), this.colorArray = new Float32Array([1, 16777215, 1, 16777215, 1, 16777215, 1, 16777215]), a.bindBuffer(a.ARRAY_BUFFER, this.colorBuffer), a.bufferData(a.ARRAY_BUFFER, this.colorArray, a.STATIC_DRAW), a.bindBuffer(a.ELEMENT_ARRAY_BUFFER, this.indexBuffer), a.bufferData(a.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 1, 3, 2]), a.STATIC_DRAW)
  897. }, b.WebGLFilterManager.prototype.destroy = function() {
  898. var b, a = this.gl;
  899. for (this.filterStack = null, this.offsetX = 0, this.offsetY = 0, b = 0; b < this.texturePool.length; b++) this.texturePool[b].destroy();
  900. this.texturePool = null, a.deleteBuffer(this.vertexBuffer), a.deleteBuffer(this.uvBuffer), a.deleteBuffer(this.colorBuffer), a.deleteBuffer(this.indexBuffer)
  901. }, b.FilterTexture = function(a, c, d, e) {
  902. this.gl = a, this.frameBuffer = a.createFramebuffer(), this.texture = a.createTexture(), e = e || b.scaleModes.DEFAULT, a.bindTexture(a.TEXTURE_2D, this.texture), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MAG_FILTER, e === b.scaleModes.LINEAR ? a.LINEAR : a.NEAREST), a.texParameteri(a.TEXTURE_2D, a.TEXTURE_MIN_FILTER, e === b.scaleModes.LINEAR ? a.LINEAR : a.NEAREST), 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), a.bindFramebuffer(a.FRAMEBUFFER, this.framebuffer), a.bindFramebuffer(a.FRAMEBUFFER, this.frameBuffer), a.framebufferTexture2D(a.FRAMEBUFFER, a.COLOR_ATTACHMENT0, a.TEXTURE_2D, this.texture, 0), this.renderBuffer = a.createRenderbuffer(), a.bindRenderbuffer(a.RENDERBUFFER, this.renderBuffer), a.framebufferRenderbuffer(a.FRAMEBUFFER, a.DEPTH_STENCIL_ATTACHMENT, a.RENDERBUFFER, this.renderBuffer), this.resize(c, d)
  903. }, b.FilterTexture.prototype.clear = function() {
  904. var a = this.gl;
  905. a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT)
  906. }, b.FilterTexture.prototype.resize = function(a, b) {
  907. if (this.width !== a || this.height !== b) {
  908. this.width = a, this.height = b;
  909. var c = this.gl;
  910. c.bindTexture(c.TEXTURE_2D, this.texture), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, a, b, 0, c.RGBA, c.UNSIGNED_BYTE, null), c.bindRenderbuffer(c.RENDERBUFFER, this.renderBuffer), c.renderbufferStorage(c.RENDERBUFFER, c.DEPTH_STENCIL, a, b)
  911. }
  912. }, b.FilterTexture.prototype.destroy = function() {
  913. var a = this.gl;
  914. a.deleteFramebuffer(this.frameBuffer), a.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
  915. }, b.CanvasMaskManager = function() {}, b.CanvasMaskManager.prototype.pushMask = function(a, c) {
  916. var d, e;
  917. c.save(), d = a.alpha, e = a.worldTransform, c.setTransform(e.a, e.c, e.b, e.d, e.tx, e.ty), b.CanvasGraphics.renderGraphicsMask(a, c), c.clip(), a.worldAlpha = d
  918. }, b.CanvasMaskManager.prototype.popMask = function(a) {
  919. a.restore()
  920. }, b.CanvasTinter = function() {}, b.CanvasTinter.getTintedTexture = function(a, c) {
  921. var e, f, g, d = a.texture;
  922. return c = b.CanvasTinter.roundColor(c), e = "#" + ("00000" + (0 | c).toString(16)).substr(-6), d.tintCache = d.tintCache || {}, d.tintCache[e] ? d.tintCache[e] : (f = b.CanvasTinter.canvas || document.createElement("canvas"), b.CanvasTinter.tintMethod(d, c, f), b.CanvasTinter.convertTintToImage ? (g = new Image, g.src = f.toDataURL(), d.tintCache[e] = g) : (d.tintCache[e] = f, b.CanvasTinter.canvas = null), f)
  923. }, b.CanvasTinter.tintWithMultiply = function(a, b, c) {
  924. var d = c.getContext("2d"),
  925. e = a.frame;
  926. c.width = e.width, c.height = e.height, d.fillStyle = "#" + ("00000" + (0 | b).toString(16)).substr(-6), d.fillRect(0, 0, e.width, e.height), d.globalCompositeOperation = "multiply", d.drawImage(a.baseTexture.source, e.x, e.y, e.width, e.height, 0, 0, e.width, e.height), d.globalCompositeOperation = "destination-atop", d.drawImage(a.baseTexture.source, e.x, e.y, e.width, e.height, 0, 0, e.width, e.height)
  927. }, b.CanvasTinter.tintWithOverlay = function(a, b, c) {
  928. var d = c.getContext("2d"),
  929. e = a.frame;
  930. c.width = e.width, c.height = e.height, d.globalCompositeOperation = "copy", d.fillStyle = "#" + ("00000" + (0 | b).toString(16)).substr(-6), d.fillRect(0, 0, e.width, e.height), d.globalCompositeOperation = "destination-atop", d.drawImage(a.baseTexture.source, e.x, e.y, e.width, e.height, 0, 0, e.width, e.height)
  931. }, b.CanvasTinter.tintWithPerPixel = function(a, c, d) {
  932. var g, h, i, j, k, l, m, e = d.getContext("2d"),
  933. f = a.frame;
  934. for (d.width = f.width, d.height = f.height, e.globalCompositeOperation = "copy", e.drawImage(a.baseTexture.source, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height), g = b.hex2rgb(c), h = g[0], i = g[1], j = g[2], k = e.getImageData(0, 0, f.width, f.height), l = k.data, m = 0; m < l.length; m += 4) l[m + 0] *= h, l[m + 1] *= i, l[m + 2] *= j;
  935. e.putImageData(k, 0, 0)
  936. }, b.CanvasTinter.roundColor = function(a) {
  937. var c = b.CanvasTinter.cacheStepsPerColorChannel,
  938. d = b.hex2rgb(a);
  939. return d[0] = Math.min(255, d[0] / c * c), d[1] = Math.min(255, d[1] / c * c), d[2] = Math.min(255, d[2] / c * c), b.rgb2hex(d)
  940. }, b.CanvasTinter.cacheStepsPerColorChannel = 8, b.CanvasTinter.convertTintToImage = !1, b.CanvasTinter.canUseMultiply = b.canUseNewCanvasBlendModes(), b.CanvasTinter.tintMethod = b.CanvasTinter.canUseMultiply ? b.CanvasTinter.tintWithMultiply : b.CanvasTinter.tintWithPerPixel, b.CanvasRenderer = function(a, c, d, e) {
  941. b.defaultRenderer || (b.sayHello("Canvas"), b.defaultRenderer = this), this.type = b.CANVAS_RENDERER, this.clearBeforeRender = !0, this.transparent = !!e, b.blendModesCanvas || (b.blendModesCanvas = [], b.canUseNewCanvasBlendModes() ? (b.blendModesCanvas[b.blendModes.NORMAL] = "source-over", b.blendModesCanvas[b.blendModes.ADD] = "lighter", b.blendModesCanvas[b.blendModes.MULTIPLY] = "multiply", b.blendModesCanvas[b.blendModes.SCREEN] = "screen", b.blendModesCanvas[b.blendModes.OVERLAY] = "overlay", b.blendModesCanvas[b.blendModes.DARKEN] = "darken", b.blendModesCanvas[b.blendModes.LIGHTEN] = "lighten", b.blendModesCanvas[b.blendModes.COLOR_DODGE] = "color-dodge", b.blendModesCanvas[b.blendModes.COLOR_BURN] = "color-burn", b.blendModesCanvas[b.blendModes.HARD_LIGHT] = "hard-light", b.blendModesCanvas[b.blendModes.SOFT_LIGHT] = "soft-light", b.blendModesCanvas[b.blendModes.DIFFERENCE] = "difference", b.blendModesCanvas[b.blendModes.EXCLUSION] = "exclusion", b.blendModesCanvas[b.blendModes.HUE] = "hue", b.blendModesCanvas[b.blendModes.SATURATION] = "saturation", b.blendModesCanvas[b.blendModes.COLOR] = "color", b.blendModesCanvas[b.blendModes.LUMINOSITY] = "luminosity") : (b.blendModesCanvas[b.blendModes.NORMAL] = "source-over", b.blendModesCanvas[b.blendModes.ADD] = "lighter", b.blendModesCanvas[b.blendModes.MULTIPLY] = "source-over", b.blendModesCanvas[b.blendModes.SCREEN] = "source-over", b.blendModesCanvas[b.blendModes.OVERLAY] = "source-over", b.blendModesCanvas[b.blendModes.DARKEN] = "source-over", b.blendModesCanvas[b.blendModes.LIGHTEN] = "source-over", b.blendModesCanvas[b.blendModes.COLOR_DODGE] = "source-over", b.blendModesCanvas[b.blendModes.COLOR_BURN] = "source-over", b.blendModesCanvas[b.blendModes.HARD_LIGHT] = "source-over", b.blendModesCanvas[b.blendModes.SOFT_LIGHT] = "source-over", b.blendModesCanvas[b.blendModes.DIFFERENCE] = "source-over", b.blendModesCanvas[b.blendModes.EXCLUSION] = "source-over", b.blendModesCanvas[b.blendModes.HUE] = "source-over", b.blendModesCanvas[b.blendModes.SATURATION] = "source-over", b.blendModesCanvas[b.blendModes.COLOR] = "source-over", b.blendModesCanvas[b.blendModes.LUMINOSITY] = "source-over")), this.width = a || 800, this.height = c || 600, this.view = d || document.createElement("canvas"), this.context = this.view.getContext("2d", {
  942. alpha: this.transparent
  943. }), this.refresh = !0, this.view.width = this.width, this.view.height = this.height, this.count = 0, this.maskManager = new b.CanvasMaskManager, this.renderSession = {
  944. context: this.context,
  945. maskManager: this.maskManager,
  946. scaleMode: null,
  947. smoothProperty: null,
  948. roundPixels: !1
  949. }, "imageSmoothingEnabled" in this.context ? this.renderSession.smoothProperty = "imageSmoothingEnabled" : "webkitImageSmoothingEnabled" in this.context ? this.renderSession.smoothProperty = "webkitImageSmoothingEnabled" : "mozImageSmoothingEnabled" in this.context ? this.renderSession.smoothProperty = "mozImageSmoothingEnabled" : "oImageSmoothingEnabled" in this.context && (this.renderSession.smoothProperty = "oImageSmoothingEnabled")
  950. }, b.CanvasRenderer.prototype.constructor = b.CanvasRenderer, b.CanvasRenderer.prototype.render = function(a) {
  951. b.texturesToUpdate.length = 0, b.texturesToDestroy.length = 0, a.updateTransform(), this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.globalAlpha = 1, navigator.isCocoonJS && this.view.screencanvas && (this.context.fillStyle = "black", this.context.clear()), !this.transparent && this.clearBeforeRender ? (this.context.fillStyle = a.backgroundColorString, this.context.fillRect(0, 0, this.width, this.height)) : this.transparent && this.clearBeforeRender && this.context.clearRect(0, 0, this.width, this.height), this.renderDisplayObject(a), a.interactive && (a._interactiveEventsAdded || (a._interactiveEventsAdded = !0, a.interactionManager.setTarget(this))), b.Texture.frameUpdates.length > 0 && (b.Texture.frameUpdates.length = 0)
  952. }, b.CanvasRenderer.prototype.resize = function(a, b) {
  953. this.width = a, this.height = b, this.view.width = a, this.view.height = b
  954. }, b.CanvasRenderer.prototype.renderDisplayObject = function(a, b) {
  955. this.renderSession.context = b || this.context, a._renderCanvas(this.renderSession)
  956. }, b.CanvasRenderer.prototype.renderStripFlat = function(a) {
  957. var e, f, g, h, i, j, k, l, b = this.context,
  958. c = a.verticies,
  959. d = c.length / 2;
  960. for (this.count++, b.beginPath(), e = 1; d - 2 > e; e++) f = 2 * e, g = c[f], h = c[f + 2], i = c[f + 4], j = c[f + 1], k = c[f + 3], l = c[f + 5], b.moveTo(g, j), b.lineTo(h, k), b.lineTo(i, l);
  961. b.fillStyle = "#FF0000", b.fill(), b.closePath()
  962. }, b.CanvasRenderer.prototype.renderStrip = function(a) {
  963. var f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, b = this.context,
  964. c = a.verticies,
  965. d = a.uvs,
  966. e = c.length / 2;
  967. for (this.count++, f = 1; e - 2 > f; f++) g = 2 * f, h = c[g], i = c[g + 2], j = c[g + 4], k = c[g + 1], l = c[g + 3], m = c[g + 5], n = d[g] * a.texture.width, o = d[g + 2] * a.texture.width, p = d[g + 4] * a.texture.width, q = d[g + 1] * a.texture.height, r = d[g + 3] * a.texture.height, s = d[g + 5] * a.texture.height, b.save(), b.beginPath(), b.moveTo(h, k), b.lineTo(i, l), b.lineTo(j, m), b.closePath(), b.clip(), t = n * r + q * p + o * s - r * p - q * o - n * s, u = h * r + q * j + i * s - r * j - q * i - h * s, v = n * i + h * p + o * j - i * p - h * o - n * j, w = n * r * j + q * i * p + h * o * s - h * r * p - q * o * j - n * i * s, x = k * r + q * m + l * s - r * m - q * l - k * s, y = n * l + k * p + o * m - l * p - k * o - n * m, z = n * r * m + q * l * p + k * o * s - k * r * p - q * o * m - n * l * s, b.transform(u / t, x / t, v / t, y / t, w / t, z / t), b.drawImage(a.texture.baseTexture.source, 0, 0), b.restore()
  968. }, b.CanvasBuffer = function(a, b) {
  969. this.width = a, this.height = b, this.canvas = document.createElement("canvas"), this.context = this.canvas.getContext("2d"), this.canvas.width = a, this.canvas.height = b
  970. }, b.CanvasBuffer.prototype.clear = function() {
  971. this.context.clearRect(0, 0, this.width, this.height)
  972. }, b.CanvasBuffer.prototype.resize = function(a, b) {
  973. this.width = this.canvas.width = a, this.height = this.canvas.height = b
  974. }, b.CanvasGraphics = function() {}, b.CanvasGraphics.renderGraphics = function(a, c) {
  975. var f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, d = a.worldAlpha,
  976. e = "";
  977. for (f = 0; f < a.graphicsData.length; f++)
  978. if (g = a.graphicsData[f], h = g.points, c.strokeStyle = e = "#" + ("00000" + (0 | g.lineColor).toString(16)).substr(-6), c.lineWidth = g.lineWidth, g.type === b.Graphics.POLY) {
  979. for (c.beginPath(), c.moveTo(h[0], h[1]), i = 1; i < h.length / 2; i++) c.lineTo(h[2 * i], h[2 * i + 1]);
  980. h[0] === h[h.length - 2] && h[1] === h[h.length - 1] && c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())
  981. } else g.type === b.Graphics.RECT ? ((g.fillColor || 0 === g.fillColor) && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fillRect(h[0], h[1], h[2], h[3])), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.strokeRect(h[0], h[1], h[2], h[3]))) : g.type === b.Graphics.CIRC ? (c.beginPath(), c.arc(h[0], h[1], h[2], 0, 2 * Math.PI), c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())) : g.type === b.Graphics.ELIP ? (j = g.points, k = 2 * j[2], l = 2 * j[3], m = j[0] - k / 2, n = j[1] - l / 2, c.beginPath(), o = .5522848, p = k / 2 * o, q = l / 2 * o, r = m + k, s = n + l, t = m + k / 2, u = n + l / 2, c.moveTo(m, u), c.bezierCurveTo(m, u - q, t - p, n, t, n), c.bezierCurveTo(t + p, n, r, u - q, r, u), c.bezierCurveTo(r, u + q, t + p, s, t, s), c.bezierCurveTo(t - p, s, m, u + q, m, u), c.closePath(), g.fill && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke())) : g.type === b.Graphics.RREC && (v = h[0], w = h[1], x = h[2], y = h[3], z = h[4], A = 0 | Math.min(x, y) / 2, z = z > A ? A : z, c.beginPath(), c.moveTo(v, w + z), c.lineTo(v, w + y - z), c.quadraticCurveTo(v, w + y, v + z, w + y), c.lineTo(v + x - z, w + y), c.quadraticCurveTo(v + x, w + y, v + x, w + y - z), c.lineTo(v + x, w + z), c.quadraticCurveTo(v + x, w, v + x - z, w), c.lineTo(v + z, w), c.quadraticCurveTo(v, w, v, w + z), c.closePath(), (g.fillColor || 0 === g.fillColor) && (c.globalAlpha = g.fillAlpha * d, c.fillStyle = e = "#" + ("00000" + (0 | g.fillColor).toString(16)).substr(-6), c.fill()), g.lineWidth && (c.globalAlpha = g.lineAlpha * d, c.stroke()))
  982. }, b.CanvasGraphics.renderGraphicsMask = function(a, c) {
  983. var e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, d = a.graphicsData.length;
  984. if (0 !== d)
  985. for (d > 1 && (d = 1, window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")), e = 0; 1 > e; e++)
  986. if (f = a.graphicsData[e], g = f.points, f.type === b.Graphics.POLY) {
  987. for (c.beginPath(), c.moveTo(g[0], g[1]), h = 1; h < g.length / 2; h++) c.lineTo(g[2 * h], g[2 * h + 1]);
  988. g[0] === g[g.length - 2] && g[1] === g[g.length - 1] && c.closePath()
  989. } else f.type === b.Graphics.RECT ? (c.beginPath(), c.rect(g[0], g[1], g[2], g[3]), c.closePath()) : f.type === b.Graphics.CIRC ? (c.beginPath(), c.arc(g[0], g[1], g[2], 0, 2 * Math.PI), c.closePath()) : f.type === b.Graphics.ELIP ? (i = f.points, j = 2 * i[2], k = 2 * i[3], l = i[0] - j / 2, m = i[1] - k / 2, c.beginPath(), n = .5522848, o = j / 2 * n, p = k / 2 * n, q = l + j, r = m + k, s = l + j / 2, t = m + k / 2, c.moveTo(l, t), c.bezierCurveTo(l, t - p, s - o, m, s, m), c.bezierCurveTo(s + o, m, q, t - p, q, t), c.bezierCurveTo(q, t + p, s + o, r, s, r), c.bezierCurveTo(s - o, r, l, t + p, l, t), c.closePath()) : f.type === b.Graphics.RREC && (u = g[0], v = g[1], w = g[2], x = g[3], y = g[4], z = 0 | Math.min(w, x) / 2, y = y > z ? z : y, c.beginPath(), c.moveTo(u, v + y), c.lineTo(u, v + x - y), c.quadraticCurveTo(u, v + x, u + y, v + x), c.lineTo(u + w - y, v + x), c.quadraticCurveTo(u + w, v + x, u + w, v + x - y), c.lineTo(u + w, v + y), c.quadraticCurveTo(u + w, v, u + w - y, v), c.lineTo(u + y, v), c.quadraticCurveTo(u, v, u, v + y), c.closePath())
  990. }, b.Graphics = function() {
  991. b.DisplayObjectContainer.call(this), this.renderable = !0, this.fillAlpha = 1, this.lineWidth = 0, this.lineColor = "black", this.graphicsData = [], this.tint = 16777215, this.blendMode = b.blendModes.NORMAL, this.currentPath = {
  992. points: []
  993. }, this._webGL = [], this.isMask = !1, this.bounds = null, this.boundsPadding = 10, this.dirty = !0
  994. }, b.Graphics.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Graphics.prototype.constructor = b.Graphics, Object.defineProperty(b.Graphics.prototype, "cacheAsBitmap", {
  995. get: function() {
  996. return this._cacheAsBitmap
  997. },
  998. set: function(a) {
  999. this._cacheAsBitmap = a, this._cacheAsBitmap ? this._generateCachedSprite() : (this.destroyCachedSprite(), this.dirty = !0)
  1000. }
  1001. }), b.Graphics.prototype.lineStyle = function(a, c, d) {
  1002. return this.currentPath.points.length || this.graphicsData.pop(), this.lineWidth = a || 0, this.lineColor = c || 0, this.lineAlpha = arguments.length < 3 ? 1 : d, this.currentPath = {
  1003. lineWidth: this.lineWidth,
  1004. lineColor: this.lineColor,
  1005. lineAlpha: this.lineAlpha,
  1006. fillColor: this.fillColor,
  1007. fillAlpha: this.fillAlpha,
  1008. fill: this.filling,
  1009. points: [],
  1010. type: b.Graphics.POLY
  1011. }, this.graphicsData.push(this.currentPath), this
  1012. }, b.Graphics.prototype.moveTo = function(a, c) {
  1013. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = this.currentPath = {
  1014. lineWidth: this.lineWidth,
  1015. lineColor: this.lineColor,
  1016. lineAlpha: this.lineAlpha,
  1017. fillColor: this.fillColor,
  1018. fillAlpha: this.fillAlpha,
  1019. fill: this.filling,
  1020. points: [],
  1021. type: b.Graphics.POLY
  1022. }, this.currentPath.points.push(a, c), this.graphicsData.push(this.currentPath), this
  1023. }, b.Graphics.prototype.lineTo = function(a, b) {
  1024. return this.currentPath.points.push(a, b), this.dirty = !0, this
  1025. }, b.Graphics.prototype.quadraticCurveTo = function(a, b, c, d) {
  1026. var e, f, g, h, i, j, k, l;
  1027. for (0 === this.currentPath.points.length && this.moveTo(0, 0), g = 20, h = this.currentPath.points, 0 === h.length && this.moveTo(0, 0), i = h[h.length - 2], j = h[h.length - 1], k = 0, l = 1; g >= l; l++) k = l / g, e = i + (a - i) * k, f = j + (b - j) * k, h.push(e + (a + (c - a) * k - e) * k, f + (b + (d - b) * k - f) * k);
  1028. return this.dirty = !0, this
  1029. }, b.Graphics.prototype.bezierCurveTo = function(a, b, c, d, e, f) {
  1030. var h, i, j, k, l, g, m, n, o, p, q;
  1031. for (0 === this.currentPath.points.length && this.moveTo(0, 0), g = 20, m = this.currentPath.points, n = m[m.length - 2], o = m[m.length - 1], p = 0, q = 1; g > q; q++) p = q / g, h = 1 - p, i = h * h, j = i * h, k = p * p, l = k * p, m.push(j * n + 3 * i * p * a + 3 * h * k * c + l * e, j * o + 3 * i * p * b + 3 * h * k * d + l * f);
  1032. return this.dirty = !0, this
  1033. }, b.Graphics.prototype.arcTo = function(a, b, c, d, e) {
  1034. var f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B;
  1035. return 0 === this.currentPath.points.length && this.moveTo(a, b), f = this.currentPath.points, g = f[f.length - 2], h = f[f.length - 1], i = h - b, j = g - a, k = d - b, l = c - a, m = Math.abs(i * l - j * k), 1e-8 > m || 0 === e ? f.push(a, b) : (n = i * i + j * j, o = k * k + l * l, p = i * k + j * l, q = e * Math.sqrt(n) / m, r = e * Math.sqrt(o) / m, s = q * p / n, t = r * p / o, u = q * l + r * j, v = q * k + r * i, w = j * (r + s), x = i * (r + s), y = l * (q + t), z = k * (q + t), A = Math.atan2(x - v, w - u), B = Math.atan2(z - v, y - u), this.arc(u + a, v + b, e, A, B, j * k > l * i)), this.dirty = !0, this
  1036. }, b.Graphics.prototype.arc = function(a, b, c, d, e, f) {
  1037. var j, k, l, m, n, o, p, q, r, s, t, u, v, g = a + Math.cos(d) * c,
  1038. h = b + Math.sin(d) * c,
  1039. i = this.currentPath.points;
  1040. if ((0 !== i.length && i[i.length - 2] !== g || i[i.length - 1] !== h) && (this.moveTo(g, h), i = this.currentPath.points), d === e) return this;
  1041. if (!f && d >= e ? e += 2 * Math.PI : f && e >= d && (d += 2 * Math.PI), j = f ? -1 * (d - e) : e - d, k = 40 * (Math.abs(j) / (2 * Math.PI)), 0 === j) return this;
  1042. for (l = j / (2 * k), m = 2 * l, n = Math.cos(l), o = Math.sin(l), p = k - 1, q = p % 1 / p, r = 0; p >= r; r++) s = r + q * r, t = l + d + m * s, u = Math.cos(t), v = -Math.sin(t), i.push((n * u + o * v) * c + a, (n * -v + o * u) * c + b);
  1043. return this.dirty = !0, this
  1044. }, b.Graphics.prototype.drawPath = function(a) {
  1045. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = this.currentPath = {
  1046. lineWidth: this.lineWidth,
  1047. lineColor: this.lineColor,
  1048. lineAlpha: this.lineAlpha,
  1049. fillColor: this.fillColor,
  1050. fillAlpha: this.fillAlpha,
  1051. fill: this.filling,
  1052. points: [],
  1053. type: b.Graphics.POLY
  1054. }, this.graphicsData.push(this.currentPath), this.currentPath.points = this.currentPath.points.concat(a), this.dirty = !0, this
  1055. }, b.Graphics.prototype.beginFill = function(a, b) {
  1056. return this.filling = !0, this.fillColor = a || 0, this.fillAlpha = arguments.length < 2 ? 1 : b, this
  1057. }, b.Graphics.prototype.endFill = function() {
  1058. return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this
  1059. }, b.Graphics.prototype.drawRect = function(a, c, d, e) {
  1060. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1061. lineWidth: this.lineWidth,
  1062. lineColor: this.lineColor,
  1063. lineAlpha: this.lineAlpha,
  1064. fillColor: this.fillColor,
  1065. fillAlpha: this.fillAlpha,
  1066. fill: this.filling,
  1067. points: [a, c, d, e],
  1068. type: b.Graphics.RECT
  1069. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1070. }, b.Graphics.prototype.drawRoundedRect = function(a, c, d, e, f) {
  1071. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1072. lineWidth: this.lineWidth,
  1073. lineColor: this.lineColor,
  1074. lineAlpha: this.lineAlpha,
  1075. fillColor: this.fillColor,
  1076. fillAlpha: this.fillAlpha,
  1077. fill: this.filling,
  1078. points: [a, c, d, e, f],
  1079. type: b.Graphics.RREC
  1080. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1081. }, b.Graphics.prototype.drawCircle = function(a, c, d) {
  1082. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1083. lineWidth: this.lineWidth,
  1084. lineColor: this.lineColor,
  1085. lineAlpha: this.lineAlpha,
  1086. fillColor: this.fillColor,
  1087. fillAlpha: this.fillAlpha,
  1088. fill: this.filling,
  1089. points: [a, c, d, d],
  1090. type: b.Graphics.CIRC
  1091. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1092. }, b.Graphics.prototype.drawEllipse = function(a, c, d, e) {
  1093. return this.currentPath.points.length || this.graphicsData.pop(), this.currentPath = {
  1094. lineWidth: this.lineWidth,
  1095. lineColor: this.lineColor,
  1096. lineAlpha: this.lineAlpha,
  1097. fillColor: this.fillColor,
  1098. fillAlpha: this.fillAlpha,
  1099. fill: this.filling,
  1100. points: [a, c, d, e],
  1101. type: b.Graphics.ELIP
  1102. }, this.graphicsData.push(this.currentPath), this.dirty = !0, this
  1103. }, b.Graphics.prototype.clear = function() {
  1104. return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this.clearDirty = !0, this.graphicsData = [], this.bounds = null, this
  1105. }, b.Graphics.prototype.generateTexture = function() {
  1106. var a = this.getBounds(),
  1107. c = new b.CanvasBuffer(a.width, a.height),
  1108. d = b.Texture.fromCanvas(c.canvas);
  1109. return c.context.translate(-a.x, -a.y), b.CanvasGraphics.renderGraphics(this, c.context), d
  1110. }, b.Graphics.prototype._renderWebGL = function(a) {
  1111. var c, d, e;
  1112. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  1113. if (this._cacheAsBitmap) return this.dirty && (this._generateCachedSprite(), b.updateWebGLTexture(this._cachedSprite.texture.baseTexture, a.gl), this.dirty = !1), this._cachedSprite.alpha = this.alpha, b.Sprite.prototype._renderWebGL.call(this._cachedSprite, a), void 0;
  1114. if (a.spriteBatch.stop(), a.blendModeManager.setBlendMode(this.blendMode), this._mask && a.maskManager.pushMask(this._mask, a), this._filters && a.filterManager.pushFilter(this._filterBlock), this.blendMode !== a.spriteBatch.currentBlendMode && (a.spriteBatch.currentBlendMode = this.blendMode, c = b.blendModesWebGL[a.spriteBatch.currentBlendMode], a.spriteBatch.gl.blendFunc(c[0], c[1])), b.WebGLGraphics.renderGraphics(this, a), this.children.length) {
  1115. for (a.spriteBatch.start(), d = 0, e = this.children.length; e > d; d++) this.children[d]._renderWebGL(a);
  1116. a.spriteBatch.stop()
  1117. }
  1118. this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(this.mask, a), a.drawCount++, a.spriteBatch.start()
  1119. }
  1120. }, b.Graphics.prototype._renderCanvas = function(a) {
  1121. var c, d, e, f;
  1122. if (this.visible !== !1 && 0 !== this.alpha && this.isMask !== !0) {
  1123. for (c = a.context, d = this.worldTransform, this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]), this._mask && a.maskManager.pushMask(this._mask, a.context), c.setTransform(d.a, d.c, d.b, d.d, d.tx, d.ty), b.CanvasGraphics.renderGraphics(this, c), e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a);
  1124. this._mask && a.maskManager.popMask(a.context)
  1125. }
  1126. }, b.Graphics.prototype.getBounds = function(a) {
  1127. var b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y;
  1128. return this.bounds || this.updateBounds(), b = this.bounds.x, c = this.bounds.width + this.bounds.x, d = this.bounds.y, e = this.bounds.height + this.bounds.y, f = a || this.worldTransform, g = f.a, h = f.c, i = f.b, j = f.d, k = f.tx, l = f.ty, m = g * c + i * e + k, n = j * e + h * c + l, o = g * b + i * e + k, p = j * e + h * b + l, q = g * b + i * d + k, r = j * d + h * b + l, s = g * c + i * d + k, t = j * d + h * c + l, u = m, v = n, w = m, x = n, w = w > o ? o : w, w = w > q ? q : w, w = w > s ? s : w, x = x > p ? p : x, x = x > r ? r : x, x = x > t ? t : x, u = o > u ? o : u, u = q > u ? q : u, u = s > u ? s : u, v = p > v ? p : v, v = r > v ? r : v, v = t > v ? t : v, y = this._bounds, y.x = w, y.width = u - w, y.y = x, y.height = v - x, y
  1129. }, b.Graphics.prototype.updateBounds = function() {
  1130. var f, g, h, i, j, k, l, m, n, o, p, a = 1 / 0,
  1131. c = -1 / 0,
  1132. d = 1 / 0,
  1133. e = -1 / 0;
  1134. for (k = 0; k < this.graphicsData.length; k++)
  1135. if (l = this.graphicsData[k], m = l.type, n = l.lineWidth, f = l.points, m === b.Graphics.RECT) g = f[0] - n / 2, h = f[1] - n / 2, i = f[2] + n, j = f[3] + n, a = a > g ? g : a, c = g + i > c ? g + i : c, d = d > h ? g : d, e = h + j > e ? h + j : e;
  1136. else if (m === b.Graphics.CIRC || m === b.Graphics.ELIP) g = f[0], h = f[1], i = f[2] + n / 2, j = f[3] + n / 2, a = a > g - i ? g - i : a, c = g + i > c ? g + i : c, d = d > h - j ? h - j : d, e = h + j > e ? h + j : e;
  1137. else
  1138. for (o = 0; o < f.length; o += 2) g = f[o], h = f[o + 1], a = a > g - n ? g - n : a, c = g + n > c ? g + n : c, d = d > h - n ? h - n : d, e = h + n > e ? h + n : e;
  1139. p = this.boundsPadding, this.bounds = new b.Rectangle(a - p, d - p, c - a + 2 * p, e - d + 2 * p)
  1140. }, b.Graphics.prototype._generateCachedSprite = function() {
  1141. var c, d, a = this.getLocalBounds();
  1142. this._cachedSprite ? this._cachedSprite.buffer.resize(a.width, a.height) : (c = new b.CanvasBuffer(a.width, a.height), d = b.Texture.fromCanvas(c.canvas), this._cachedSprite = new b.Sprite(d), this._cachedSprite.buffer = c, this._cachedSprite.worldTransform = this.worldTransform), this._cachedSprite.anchor.x = -(a.x / a.width), this._cachedSprite.anchor.y = -(a.y / a.height), this._cachedSprite.buffer.context.translate(-a.x, -a.y), b.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context), this._cachedSprite.alpha = this.alpha
  1143. }, b.Graphics.prototype.destroyCachedSprite = function() {
  1144. this._cachedSprite.texture.destroy(!0), this._cachedSprite = null
  1145. }, b.Graphics.POLY = 0, b.Graphics.RECT = 1, b.Graphics.CIRC = 2, b.Graphics.ELIP = 3, b.Graphics.RREC = 4, b.Strip = function(a) {
  1146. b.DisplayObjectContainer.call(this), this.texture = a, this.uvs = new b.Float32Array([0, 1, 1, 1, 1, 0, 0, 1]), this.verticies = new b.Float32Array([0, 0, 100, 0, 100, 100, 0, 100]), this.colors = new b.Float32Array([1, 1, 1, 1]), this.indices = new b.Uint16Array([0, 1, 2, 3]), this.dirty = !0
  1147. }, b.Strip.prototype = Object.create(b.DisplayObjectContainer.prototype), b.Strip.prototype.constructor = b.Strip, b.Strip.prototype._renderWebGL = function(a) {
  1148. !this.visible || this.alpha <= 0 || (a.spriteBatch.stop(), this._vertexBuffer || this._initWebGL(a), a.shaderManager.setShader(a.shaderManager.stripShader), this._renderStrip(a), a.spriteBatch.start())
  1149. }, b.Strip.prototype._initWebGL = function(a) {
  1150. var b = a.gl;
  1151. this._vertexBuffer = b.createBuffer(), this._indexBuffer = b.createBuffer(), this._uvBuffer = b.createBuffer(), this._colorBuffer = b.createBuffer(), b.bindBuffer(b.ARRAY_BUFFER, this._vertexBuffer), b.bufferData(b.ARRAY_BUFFER, this.verticies, b.DYNAMIC_DRAW), b.bindBuffer(b.ARRAY_BUFFER, this._uvBuffer), b.bufferData(b.ARRAY_BUFFER, this.uvs, b.STATIC_DRAW), b.bindBuffer(b.ARRAY_BUFFER, this._colorBuffer), b.bufferData(b.ARRAY_BUFFER, this.colors, b.STATIC_DRAW), b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, this._indexBuffer), b.bufferData(b.ELEMENT_ARRAY_BUFFER, this.indices, b.STATIC_DRAW)
  1152. }, b.Strip.prototype._renderStrip = function(a) {
  1153. var c = a.gl,
  1154. d = a.projection,
  1155. e = a.offset,
  1156. f = a.shaderManager.stripShader;
  1157. c.blendFunc(c.ONE, c.ONE_MINUS_SRC_ALPHA), c.uniformMatrix3fv(f.translationMatrix, !1, this.worldTransform.toArray(!0)), c.uniform2f(f.projectionVector, d.x, -d.y), c.uniform2f(f.offsetVector, -e.x, -e.y), c.uniform1f(f.alpha, 1), this.dirty ? (this.dirty = !1, c.bindBuffer(c.ARRAY_BUFFER, this._vertexBuffer), c.bufferData(c.ARRAY_BUFFER, this.verticies, c.STATIC_DRAW), c.vertexAttribPointer(f.aVertexPosition, 2, c.FLOAT, !1, 0, 0), c.bindBuffer(c.ARRAY_BUFFER, this._uvBuffer), c.bufferData(c.ARRAY_BUFFER, this.uvs, c.STATIC_DRAW), c.vertexAttribPointer(f.aTextureCoord, 2, c.FLOAT, !1, 0, 0), c.activeTexture(c.TEXTURE0), c.bindTexture(c.TEXTURE_2D, this.texture.baseTexture._glTextures[c.id] || b.createWebGLTexture(this.texture.baseTexture, c)), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indexBuffer), c.bufferData(c.ELEMENT_ARRAY_BUFFER, this.indices, c.STATIC_DRAW)) : (c.bindBuffer(c.ARRAY_BUFFER, this._vertexBuffer), c.bufferSubData(c.ARRAY_BUFFER, 0, this.verticies), c.vertexAttribPointer(f.aVertexPosition, 2, c.FLOAT, !1, 0, 0), c.bindBuffer(c.ARRAY_BUFFER, this._uvBuffer), c.vertexAttribPointer(f.aTextureCoord, 2, c.FLOAT, !1, 0, 0), c.activeTexture(c.TEXTURE0), c.bindTexture(c.TEXTURE_2D, this.texture.baseTexture._glTextures[c.id] || b.createWebGLTexture(this.texture.baseTexture, c)), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, this._indexBuffer)), c.drawElements(c.TRIANGLE_STRIP, this.indices.length, c.UNSIGNED_SHORT, 0)
  1158. }, b.Strip.prototype._renderCanvas = function(a) {
  1159. var d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, b = a.context,
  1160. c = this.worldTransform;
  1161. for (a.roundPixels ? b.setTransform(c.a, c.c, c.b, c.d, 0 | c.tx, 0 | c.ty) : b.setTransform(c.a, c.c, c.b, c.d, c.tx, c.ty), d = this, e = d.verticies, f = d.uvs, g = e.length / 2, this.count++, h = 0; g - 2 > h; h++) i = 2 * h, j = e[i], k = e[i + 2], l = e[i + 4], m = e[i + 1], n = e[i + 3], o = e[i + 5], p = (j + k + l) / 3, q = (m + n + o) / 3, r = j - p, s = m - q, t = Math.sqrt(r * r + s * s), j = p + r / t * (t + 3), m = q + s / t * (t + 3), r = k - p, s = n - q, t = Math.sqrt(r * r + s * s), k = p + r / t * (t + 3), n = q + s / t * (t + 3), r = l - p, s = o - q, t = Math.sqrt(r * r + s * s), l = p + r / t * (t + 3), o = q + s / t * (t + 3), u = f[i] * d.texture.width, v = f[i + 2] * d.texture.width, w = f[i + 4] * d.texture.width, x = f[i + 1] * d.texture.height, y = f[i + 3] * d.texture.height, z = f[i + 5] * d.texture.height, b.save(), b.beginPath(), b.moveTo(j, m), b.lineTo(k, n), b.lineTo(l, o), b.closePath(), b.clip(), A = u * y + x * w + v * z - y * w - x * v - u * z, B = j * y + x * l + k * z - y * l - x * k - j * z, C = u * k + j * w + v * l - k * w - j * v - u * l, D = u * y * l + x * k * w + j * v * z - j * y * w - x * v * l - u * k * z, E = m * y + x * o + n * z - y * o - x * n - m * z, F = u * n + m * w + v * o - n * w - m * v - u * o, G = u * y * o + x * n * w + m * v * z - m * y * w - x * v * o - u * n * z, b.transform(B / A, E / A, C / A, F / A, D / A, G / A), b.drawImage(d.texture.baseTexture.source, 0, 0), b.restore()
  1162. }, b.Strip.prototype.onTextureUpdate = function() {
  1163. this.updateFrame = !0
  1164. }, b.Rope = function(a, c) {
  1165. b.Strip.call(this, a), this.points = c, this.verticies = new b.Float32Array(4 * c.length), this.uvs = new b.Float32Array(4 * c.length), this.colors = new b.Float32Array(2 * c.length), this.indices = new b.Uint16Array(2 * c.length), this.refresh()
  1166. }, b.Rope.prototype = Object.create(b.Strip.prototype), b.Rope.prototype.constructor = b.Rope, b.Rope.prototype.refresh = function() {
  1167. var b, c, d, e, g, h, i, f, j, a = this.points;
  1168. if (!(a.length < 1))
  1169. for (b = this.uvs, c = a[0], d = this.indices, e = this.colors, this.count -= .2, b[0] = 0, b[1] = 0, b[2] = 0, b[3] = 1, e[0] = 1, e[1] = 1, d[0] = 0, d[1] = 1, f = a.length, j = 1; f > j; j++) g = a[j], h = 4 * j, i = j / (f - 1), j % 2 ? (b[h] = i, b[h + 1] = 0, b[h + 2] = i, b[h + 3] = 1) : (b[h] = i, b[h + 1] = 0, b[h + 2] = i, b[h + 3] = 1), h = 2 * j, e[h] = 1, e[h + 1] = 1, h = 2 * j, d[h] = h, d[h + 1] = h + 1, c = g
  1170. }, b.Rope.prototype.updateTransform = function() {
  1171. var c, d, e, f, h, i, j, k, l, g, m, a = this.points;
  1172. if (!(a.length < 1)) {
  1173. for (c = a[0], e = {
  1174. x: 0,
  1175. y: 0
  1176. }, this.count -= .2, f = this.verticies, g = a.length, m = 0; g > m; m++) h = a[m], i = 4 * m, d = m < a.length - 1 ? a[m + 1] : h, e.y = -(d.x - c.x), e.x = d.y - c.y, j = 10 * (1 - m / (g - 1)), j > 1 && (j = 1), k = Math.sqrt(e.x * e.x + e.y * e.y), l = this.texture.height / 2, e.x /= k, e.y /= k, e.x *= l, e.y *= l, f[i] = h.x + e.x, f[i + 1] = h.y + e.y, f[i + 2] = h.x - e.x, f[i + 3] = h.y - e.y, c = h;
  1177. b.DisplayObjectContainer.prototype.updateTransform.call(this)
  1178. }
  1179. }, b.Rope.prototype.setTexture = function(a) {
  1180. this.texture = a
  1181. }, b.TilingSprite = function(a, c, d) {
  1182. b.Sprite.call(this, a), this._width = c || 100, this._height = d || 100, this.tileScale = new b.Point(1, 1), this.tileScaleOffset = new b.Point(1, 1), this.tilePosition = new b.Point(0, 0), this.renderable = !0, this.tint = 16777215, this.blendMode = b.blendModes.NORMAL
  1183. }, b.TilingSprite.prototype = Object.create(b.Sprite.prototype), b.TilingSprite.prototype.constructor = b.TilingSprite, Object.defineProperty(b.TilingSprite.prototype, "width", {
  1184. get: function() {
  1185. return this._width
  1186. },
  1187. set: function(a) {
  1188. this._width = a
  1189. }
  1190. }), Object.defineProperty(b.TilingSprite.prototype, "height", {
  1191. get: function() {
  1192. return this._height
  1193. },
  1194. set: function(a) {
  1195. this._height = a
  1196. }
  1197. }), b.TilingSprite.prototype.setTexture = function(a) {
  1198. this.texture !== a && (this.texture = a, this.refreshTexture = !0, this.cachedTint = 16777215)
  1199. }, b.TilingSprite.prototype._renderWebGL = function(a) {
  1200. if (this.visible !== !1 && 0 !== this.alpha) {
  1201. var c, d;
  1202. for (this._mask && (a.spriteBatch.stop(), a.maskManager.pushMask(this.mask, a), a.spriteBatch.start()), this._filters && (a.spriteBatch.flush(), a.filterManager.pushFilter(this._filterBlock)), !this.tilingTexture || this.refreshTexture ? (this.generateTilingTexture(!0), this.tilingTexture && this.tilingTexture.needsUpdate && (b.updateWebGLTexture(this.tilingTexture.baseTexture, a.gl), this.tilingTexture.needsUpdate = !1)) : a.spriteBatch.renderTilingSprite(this), c = 0, d = this.children.length; d > c; c++) this.children[c]._renderWebGL(a);
  1203. a.spriteBatch.stop(), this._filters && a.filterManager.popFilter(), this._mask && a.maskManager.popMask(a), a.spriteBatch.start()
  1204. }
  1205. }, b.TilingSprite.prototype._renderCanvas = function(a) {
  1206. var c, d, e, f, g, h;
  1207. if (this.visible !== !1 && 0 !== this.alpha) {
  1208. if (c = a.context, this._mask && a.maskManager.pushMask(this._mask, c), c.globalAlpha = this.worldAlpha, d = this.worldTransform, c.setTransform(d.a, d.c, d.b, d.d, d.tx, d.ty), !this.__tilePattern || this.refreshTexture) {
  1209. if (this.generateTilingTexture(!1), !this.tilingTexture) return;
  1210. this.__tilePattern = c.createPattern(this.tilingTexture.baseTexture.source, "repeat")
  1211. }
  1212. for (this.blendMode !== a.currentBlendMode && (a.currentBlendMode = this.blendMode, c.globalCompositeOperation = b.blendModesCanvas[a.currentBlendMode]), g = this.tilePosition, h = this.tileScale, g.x %= this.tilingTexture.baseTexture.width, g.y %= this.tilingTexture.baseTexture.height, c.scale(h.x, h.y), c.translate(g.x, g.y), c.fillStyle = this.__tilePattern, c.fillRect(-g.x + this.anchor.x * -this._width, -g.y + this.anchor.y * -this._height, this._width / h.x, this._height / h.y), c.scale(1 / h.x, 1 / h.y), c.translate(-g.x, -g.y), this._mask && a.maskManager.popMask(a.context), e = 0, f = this.children.length; f > e; e++) this.children[e]._renderCanvas(a)
  1213. }
  1214. }, b.TilingSprite.prototype.getBounds = function() {
  1215. var z, a = this._width,
  1216. b = this._height,
  1217. c = a * (1 - this.anchor.x),
  1218. d = a * -this.anchor.x,
  1219. e = b * (1 - this.anchor.y),
  1220. f = b * -this.anchor.y,
  1221. g = this.worldTransform,
  1222. h = g.a,
  1223. i = g.c,
  1224. j = g.b,
  1225. k = g.d,
  1226. l = g.tx,
  1227. m = g.ty,
  1228. n = h * d + j * f + l,
  1229. o = k * f + i * d + m,
  1230. p = h * c + j * f + l,
  1231. q = k * f + i * c + m,
  1232. r = h * c + j * e + l,
  1233. s = k * e + i * c + m,
  1234. t = h * d + j * e + l,
  1235. u = k * e + i * d + m,
  1236. v = -1 / 0,
  1237. w = -1 / 0,
  1238. x = 1 / 0,
  1239. y = 1 / 0;
  1240. return x = x > n ? n : x, x = x > p ? p : x, x = x > r ? r : x, x = x > t ? t : x, y = y > o ? o : y, y = y > q ? q : y, y = y > s ? s : y, y = y > u ? u : y, v = n > v ? n : v, v = p > v ? p : v, v = r > v ? r : v, v = t > v ? t : v, w = o > w ? o : w, w = q > w ? q : w, w = s > w ? s : w, w = u > w ? u : w, z = this._bounds, z.x = x, z.width = v - x, z.y = y, z.height = w - y, this._currentBounds = z, z
  1241. }, b.TilingSprite.prototype.onTextureUpdate = function() {}, b.TilingSprite.prototype.generateTilingTexture = function(a) {
  1242. var c, d, e, f, g, h, i;
  1243. this.texture.baseTexture.hasLoaded && (c = this.texture, d = c.frame, g = d.width !== c.baseTexture.width || d.height !== c.baseTexture.height, h = !1, a ? (e = b.getNextPowerOfTwo(d.width), f = b.getNextPowerOfTwo(d.height), (d.width !== e || d.height !== f) && (h = !0)) : g && (e = d.width, f = d.height, h = !0), h ? (this.tilingTexture && this.tilingTexture.isTiling ? (i = this.tilingTexture.canvasBuffer, i.resize(e, f), this.tilingTexture.baseTexture.width = e, this.tilingTexture.baseTexture.height = f, this.tilingTexture.needsUpdate = !0) : (i = new b.CanvasBuffer(e, f), this.tilingTexture = b.Texture.fromCanvas(i.canvas), this.tilingTexture.canvasBuffer = i, this.tilingTexture.isTiling = !0), i.context.drawImage(c.baseTexture.source, c.crop.x, c.crop.y, c.crop.width, c.crop.height, 0, 0, e, f), this.tileScaleOffset.x = d.width / e, this.tileScaleOffset.y = d.height / f) : (this.tilingTexture && this.tilingTexture.isTiling && this.tilingTexture.destroy(!0), this.tileScaleOffset.x = 1, this.tileScaleOffset.y = 1, this.tilingTexture = c), this.refreshTexture = !1, this.tilingTexture.baseTexture._powerOf2 = !0)
  1244. }, b.BaseTextureCache = {}, b.texturesToUpdate = [], b.texturesToDestroy = [], b.BaseTextureCacheIdGenerator = 0, b.BaseTexture = function(a, c) {
  1245. if (b.EventTarget.call(this), this.width = 100, this.height = 100, this.scaleMode = c || b.scaleModes.DEFAULT, this.hasLoaded = !1, this.source = a, this.id = b.BaseTextureCacheIdGenerator++, this.premultipliedAlpha = !0, this._glTextures = [], this._dirty = [], a) {
  1246. if ((this.source.complete || this.source.getContext) && this.source.width && this.source.height) this.hasLoaded = !0, this.width = this.source.width, this.height = this.source.height, b.texturesToUpdate.push(this);
  1247. else {
  1248. var d = this;
  1249. this.source.onload = function() {
  1250. d.hasLoaded = !0, d.width = d.source.width, d.height = d.source.height;
  1251. for (var a = 0; a < d._glTextures.length; a++) d._dirty[a] = !0;
  1252. d.dispatchEvent({
  1253. type: "loaded",
  1254. content: d
  1255. })
  1256. }, this.source.onerror = function() {
  1257. d.dispatchEvent({
  1258. type: "error",
  1259. content: d
  1260. })
  1261. }
  1262. }
  1263. this.imageUrl = null, this._powerOf2 = !1
  1264. }
  1265. }, b.BaseTexture.prototype.constructor = b.BaseTexture, b.BaseTexture.prototype.destroy = function() {
  1266. this.imageUrl ? (delete b.BaseTextureCache[this.imageUrl], delete b.TextureCache[this.imageUrl], this.imageUrl = null, this.source.src = null) : this.source && this.source._pixiId && delete b.BaseTextureCache[this.source._pixiId], this.source = null, b.texturesToDestroy.push(this)
  1267. }, b.BaseTexture.prototype.updateSourceImage = function(a) {
  1268. this.hasLoaded = !1, this.source.src = null, this.source.src = a
  1269. }, b.BaseTexture.fromImage = function(a, c, d) {
  1270. var f, e = b.BaseTextureCache[a];
  1271. return void 0 === c && -1 === a.indexOf("data:") && (c = !0), e || (f = new Image, c && (f.crossOrigin = ""), f.src = a, e = new b.BaseTexture(f, d), e.imageUrl = a, b.BaseTextureCache[a] = e), e
  1272. }, b.BaseTexture.fromCanvas = function(a, c) {
  1273. a._pixiId || (a._pixiId = "canvas_" + b.TextureCacheIdGenerator++);
  1274. var d = b.BaseTextureCache[a._pixiId];
  1275. return d || (d = new b.BaseTexture(a, c), b.BaseTextureCache[a._pixiId] = d), d
  1276. }, b.TextureCache = {}, b.FrameCache = {}, b.TextureCacheIdGenerator = 0, b.Texture = function(a, c) {
  1277. if (b.EventTarget.call(this), this.noFrame = !1, c || (this.noFrame = !0, c = new b.Rectangle(0, 0, 1, 1)), a instanceof b.Texture && (a = a.baseTexture), this.baseTexture = a, this.frame = c, this.trim = null, this.valid = !1, this.scope = this, this._uvs = null, this.width = 0, this.height = 0, this.crop = new b.Rectangle(0, 0, 1, 1), a.hasLoaded) this.noFrame && (c = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(c);
  1278. else {
  1279. var d = this;
  1280. a.addEventListener("loaded", function() {
  1281. d.onBaseTextureLoaded()
  1282. })
  1283. }
  1284. }, b.Texture.prototype.constructor = b.Texture, b.Texture.prototype.onBaseTextureLoaded = function() {
  1285. var a = this.baseTexture;
  1286. a.removeEventListener("loaded", this.onLoaded), this.noFrame && (this.frame = new b.Rectangle(0, 0, a.width, a.height)), this.setFrame(this.frame), this.scope.dispatchEvent({
  1287. type: "update",
  1288. content: this
  1289. })
  1290. }, b.Texture.prototype.destroy = function(a) {
  1291. a && this.baseTexture.destroy(), this.valid = !1
  1292. }, b.Texture.prototype.setFrame = function(a) {
  1293. if (this.noFrame = !1, this.frame = a, this.width = a.width, this.height = a.height, this.crop.x = a.x, this.crop.y = a.y, this.crop.width = a.width, this.crop.height = a.height, !this.trim && (a.x + a.width > this.baseTexture.width || a.y + a.height > this.baseTexture.height)) throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
  1294. this.valid = a && a.width && a.height && this.baseTexture.source && this.baseTexture.hasLoaded, this.trim && (this.width = this.trim.width, this.height = this.trim.height, this.frame.width = this.trim.width, this.frame.height = this.trim.height), this.valid && b.Texture.frameUpdates.push(this)
  1295. }, b.Texture.prototype._updateWebGLuvs = function() {
  1296. var a, c, d;
  1297. this._uvs || (this._uvs = new b.TextureUvs), a = this.crop, c = this.baseTexture.width, d = this.baseTexture.height, this._uvs.x0 = a.x / c, this._uvs.y0 = a.y / d, this._uvs.x1 = (a.x + a.width) / c, this._uvs.y1 = a.y / d, this._uvs.x2 = (a.x + a.width) / c, this._uvs.y2 = (a.y + a.height) / d, this._uvs.x3 = a.x / c, this._uvs.y3 = (a.y + a.height) / d
  1298. }, b.Texture.fromImage = function(a, c, d) {
  1299. var e = b.TextureCache[a];
  1300. return e || (e = new b.Texture(b.BaseTexture.fromImage(a, c, d)), b.TextureCache[a] = e), e
  1301. }, b.Texture.fromFrame = function(a) {
  1302. var c = b.TextureCache[a];
  1303. if (!c) throw new Error('The frameId "' + a + '" does not exist in the texture cache ');
  1304. return c
  1305. }, b.Texture.fromCanvas = function(a, c) {
  1306. var d = b.BaseTexture.fromCanvas(a, c);
  1307. return new b.Texture(d)
  1308. }, b.Texture.addTextureToCache = function(a, c) {
  1309. b.TextureCache[c] = a
  1310. }, b.Texture.removeTextureFromCache = function(a) {
  1311. var c = b.TextureCache[a];
  1312. return delete b.TextureCache[a], delete b.BaseTextureCache[a], c
  1313. }, b.Texture.frameUpdates = [], b.TextureUvs = function() {
  1314. this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0
  1315. }, b.RenderTexture = function(a, c, d, e) {
  1316. if (b.EventTarget.call(this), this.width = a || 100, this.height = c || 100, this.frame = new b.Rectangle(0, 0, this.width, this.height), this.crop = new b.Rectangle(0, 0, this.width, this.height), this.baseTexture = new b.BaseTexture, this.baseTexture.width = this.width, this.baseTexture.height = this.height, this.baseTexture._glTextures = [], this.baseTexture.scaleMode = e || b.scaleModes.DEFAULT, this.baseTexture.hasLoaded = !0, this.renderer = d || b.defaultRenderer, this.renderer.type === b.WEBGL_RENDERER) {
  1317. var f = this.renderer.gl;
  1318. this.textureBuffer = new b.FilterTexture(f, this.width, this.height, this.baseTexture.scaleMode), this.baseTexture._glTextures[f.id] = this.textureBuffer.texture, this.render = this.renderWebGL, this.projection = new b.Point(this.width / 2, -this.height / 2)
  1319. } else this.render = this.renderCanvas, this.textureBuffer = new b.CanvasBuffer(this.width, this.height), this.baseTexture.source = this.textureBuffer.canvas;
  1320. this.valid = !0, b.Texture.frameUpdates.push(this)
  1321. }, b.RenderTexture.prototype = Object.create(b.Texture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.resize = function(a, c, d) {
  1322. (a !== this.width || c !== this.height) && (this.width = this.frame.width = this.crop.width = a, this.height = this.frame.height = this.crop.height = c, d && (this.baseTexture.width = this.width, this.baseTexture.height = this.height), this.renderer.type === b.WEBGL_RENDERER && (this.projection.x = this.width / 2, this.projection.y = -this.height / 2), this.textureBuffer.resize(this.width, this.height))
  1323. }, b.RenderTexture.prototype.clear = function() {
  1324. this.renderer.type === b.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear()
  1325. }, b.RenderTexture.prototype.renderWebGL = function(a, c, d) {
  1326. var f, g, h, i, e = this.renderer.gl;
  1327. for (e.colorMask(!0, !0, !0, !0), e.viewport(0, 0, this.width, this.height), e.bindFramebuffer(e.FRAMEBUFFER, this.textureBuffer.frameBuffer), d && this.textureBuffer.clear(), f = a.children, g = a.worldTransform, a.worldTransform = b.RenderTexture.tempMatrix, a.worldTransform.d = -1, a.worldTransform.ty = -2 * this.projection.y, c && (a.worldTransform.tx = c.x, a.worldTransform.ty -= c.y), h = 0, i = f.length; i > h; h++) f[h].updateTransform();
  1328. b.WebGLRenderer.updateTextures(), this.renderer.spriteBatch.dirty = !0, this.renderer.renderDisplayObject(a, this.projection, this.textureBuffer.frameBuffer), a.worldTransform = g, this.renderer.spriteBatch.dirty = !0
  1329. }, b.RenderTexture.prototype.renderCanvas = function(a, c, d) {
  1330. var g, h, i, e = a.children,
  1331. f = a.worldTransform;
  1332. for (a.worldTransform = b.RenderTexture.tempMatrix, c ? (a.worldTransform.tx = c.x, a.worldTransform.ty = c.y) : (a.worldTransform.tx = 0, a.worldTransform.ty = 0), g = 0, h = e.length; h > g; g++) e[g].updateTransform();
  1333. d && this.textureBuffer.clear(), i = this.textureBuffer.context, this.renderer.renderDisplayObject(a, i), i.setTransform(1, 0, 0, 1, 0, 0), a.worldTransform = f
  1334. }, b.RenderTexture.tempMatrix = new b.Matrix, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.PIXI = b) : "undefined" != typeof define && define.amd ? define("PIXI", function() {
  1335. return a.PIXI = b
  1336. }()) : a.PIXI = b
  1337. }.call(this),
  1338. function() {
  1339. var c, a = this,
  1340. b = b || {
  1341. VERSION: "2.0.7",
  1342. GAMES: [],
  1343. AUTO: 0,
  1344. CANVAS: 1,
  1345. WEBGL: 2,
  1346. HEADLESS: 3,
  1347. NONE: 0,
  1348. LEFT: 1,
  1349. RIGHT: 2,
  1350. UP: 3,
  1351. DOWN: 4,
  1352. SPRITE: 0,
  1353. BUTTON: 1,
  1354. IMAGE: 2,
  1355. GRAPHICS: 3,
  1356. TEXT: 4,
  1357. TILESPRITE: 5,
  1358. BITMAPTEXT: 6,
  1359. GROUP: 7,
  1360. RENDERTEXTURE: 8,
  1361. TILEMAP: 9,
  1362. TILEMAPLAYER: 10,
  1363. EMITTER: 11,
  1364. POLYGON: 12,
  1365. BITMAPDATA: 13,
  1366. CANVAS_FILTER: 14,
  1367. WEBGL_FILTER: 15,
  1368. ELLIPSE: 16,
  1369. SPRITEBATCH: 17,
  1370. RETROFONT: 18,
  1371. POINTER: 19,
  1372. blendModes: {
  1373. NORMAL: 0,
  1374. ADD: 1,
  1375. MULTIPLY: 2,
  1376. SCREEN: 3,
  1377. OVERLAY: 4,
  1378. DARKEN: 5,
  1379. LIGHTEN: 6,
  1380. COLOR_DODGE: 7,
  1381. COLOR_BURN: 8,
  1382. HARD_LIGHT: 9,
  1383. SOFT_LIGHT: 10,
  1384. DIFFERENCE: 11,
  1385. EXCLUSION: 12,
  1386. HUE: 13,
  1387. SATURATION: 14,
  1388. COLOR: 15,
  1389. LUMINOSITY: 16
  1390. },
  1391. scaleModes: {
  1392. DEFAULT: 0,
  1393. LINEAR: 0,
  1394. NEAREST: 1
  1395. }
  1396. };
  1397. PIXI.InteractionManager = PIXI.InteractionManager || function() {}, PIXI.dontSayHello = !0, b.Utils = {
  1398. getProperty: function(a, b) {
  1399. for (var c = b.split("."), d = c.pop(), e = c.length, f = 1, g = c[0]; e > f && (a = a[g]);) g = c[f], f++;
  1400. return a ? a[d] : null
  1401. },
  1402. setProperty: function(a, b, c) {
  1403. for (var d = b.split("."), e = d.pop(), f = d.length, g = 1, h = d[0]; f > g && (a = a[h]);) h = d[g], g++;
  1404. return a && (a[e] = c), a
  1405. },
  1406. transposeArray: function(a) {
  1407. var c, d, b = new Array(a[0].length);
  1408. for (c = 0; c < a[0].length; c++)
  1409. for (b[c] = new Array(a.length - 1), d = a.length - 1; d > -1; d--) b[c][d] = a[d][c];
  1410. return b
  1411. },
  1412. rotateArray: function(a, c) {
  1413. if ("string" != typeof c && (c = (c % 360 + 360) % 360), 90 === c || -270 === c || "rotateLeft" === c) a = b.Utils.transposeArray(a), a = a.reverse();
  1414. else if (-90 === c || 270 === c || "rotateRight" === c) a = a.reverse(), a = b.Utils.transposeArray(a);
  1415. else if (180 === Math.abs(c) || "rotate180" === c) {
  1416. for (var d = 0; d < a.length; d++) a[d].reverse();
  1417. a = a.reverse()
  1418. }
  1419. return a
  1420. },
  1421. parseDimension: function(a, b) {
  1422. var c = 0,
  1423. d = 0;
  1424. return "string" == typeof a ? "%" === a.substr(-1) ? (c = parseInt(a, 10) / 100, d = 0 === b ? window.innerWidth * c : window.innerHeight * c) : d = parseInt(a, 10) : d = a, d
  1425. },
  1426. shuffle: function(a) {
  1427. var b, c, d;
  1428. for (b = a.length - 1; b > 0; b--) c = Math.floor(Math.random() * (b + 1)), d = a[b], a[b] = a[c], a[c] = d;
  1429. return a
  1430. },
  1431. pad: function(a, b, c, d) {
  1432. var e, f, g;
  1433. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = " "), "undefined" == typeof d && (d = 3), e = 0, b + 1 >= a.length) switch (d) {
  1434. case 1:
  1435. a = new Array(b + 1 - a.length).join(c) + a;
  1436. break;
  1437. case 3:
  1438. f = Math.ceil((e = b - a.length) / 2), g = e - f, a = new Array(g + 1).join(c) + a + new Array(f + 1).join(c);
  1439. break;
  1440. default:
  1441. a += new Array(b + 1 - a.length).join(c)
  1442. }
  1443. return a
  1444. },
  1445. isPlainObject: function(a) {
  1446. if ("object" != typeof a || a.nodeType || a === a.window) return !1;
  1447. try {
  1448. if (a.constructor && !{}.hasOwnProperty.call(a.constructor.prototype, "isPrototypeOf")) return !1
  1449. } catch (b) {
  1450. return !1
  1451. }
  1452. return !0
  1453. },
  1454. extend: function() {
  1455. var a, c, d, e, f, g, h = arguments[0] || {},
  1456. i = 1,
  1457. j = arguments.length,
  1458. k = !1;
  1459. for ("boolean" == typeof h && (k = h, h = arguments[1] || {}, i = 2), j === i && (h = this, --i); j > i; i++)
  1460. if (null != (a = arguments[i]))
  1461. for (c in a) d = h[c], e = a[c], h !== e && (k && e && (b.Utils.isPlainObject(e) || (f = Array.isArray(e))) ? (f ? (f = !1, g = d && Array.isArray(d) ? d : []) : g = d && b.Utils.isPlainObject(d) ? d : {}, h[c] = b.Utils.extend(k, g, e)) : void 0 !== e && (h[c] = e));
  1462. return h
  1463. },
  1464. mixin: function(a, c) {
  1465. var d, e, f;
  1466. if (!a || "object" != typeof a) return c;
  1467. for (d in a) e = a[d], e.childNodes || e.cloneNode || (f = typeof a[d], c[d] = a[d] && "object" === f ? typeof c[d] === f ? b.Utils.mixin(a[d], c[d]) : b.Utils.mixin(a[d], new e.constructor) : a[d]);
  1468. return c
  1469. }
  1470. }, "function" != typeof Function.prototype.bind && (Function.prototype.bind = function() {
  1471. var a = Array.prototype.slice;
  1472. return function(b) {
  1473. function e() {
  1474. var f = d.concat(a.call(arguments));
  1475. c.apply(this instanceof e ? this : b, f)
  1476. }
  1477. var c = this,
  1478. d = a.call(arguments, 1);
  1479. if ("function" != typeof c) throw new TypeError;
  1480. return e.prototype = function f(a) {
  1481. return a && (f.prototype = a), this instanceof f ? void 0 : new f
  1482. }(c.prototype), e
  1483. }
  1484. }()), Array.isArray || (Array.isArray = function(a) {
  1485. return "[object Array]" == Object.prototype.toString.call(a)
  1486. }), Array.prototype.forEach || (Array.prototype.forEach = function(a) {
  1487. "use strict";
  1488. var b, c, d, e;
  1489. if (void 0 === this || null === this) throw new TypeError;
  1490. if (b = Object(this), c = b.length >>> 0, "function" != typeof a) throw new TypeError;
  1491. for (d = arguments.length >= 2 ? arguments[1] : void 0, e = 0; c > e; e++) e in b && a.call(d, b[e], e, b)
  1492. }), "function" != typeof window.Uint32Array && (c = function(a) {
  1493. var b = new Array;
  1494. window[a] = function(a) {
  1495. var b;
  1496. if ("number" == typeof a)
  1497. for (Array.call(this, a), this.length = a, b = 0; b < this.length; b++) this[b] = 0;
  1498. else
  1499. for (Array.call(this, a.length), this.length = a.length, b = 0; b < this.length; b++) this[b] = a[b]
  1500. }, window[a].prototype = b, window[a].constructor = window[a]
  1501. }, c("Uint32Array"), c("Int16Array")), window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), b.Circle = function(a, b, c) {
  1502. a = a || 0, b = b || 0, c = c || 0, this.x = a, this.y = b, this._diameter = c, this._radius = c > 0 ? .5 * c : 0
  1503. }, b.Circle.prototype = {
  1504. circumference: function() {
  1505. return 2 * Math.PI * this._radius
  1506. },
  1507. setTo: function(a, b, c) {
  1508. return this.x = a, this.y = b, this._diameter = c, this._radius = .5 * c, this
  1509. },
  1510. copyFrom: function(a) {
  1511. return this.setTo(a.x, a.y, a.diameter)
  1512. },
  1513. copyTo: function(a) {
  1514. return a.x = this.x, a.y = this.y, a.diameter = this._diameter, a
  1515. },
  1516. distance: function(a, c) {
  1517. return "undefined" == typeof c && (c = !1), c ? b.Math.distanceRounded(this.x, this.y, a.x, a.y) : b.Math.distance(this.x, this.y, a.x, a.y)
  1518. },
  1519. clone: function(a) {
  1520. return "undefined" == typeof a ? a = new b.Circle(this.x, this.y, this.diameter) : a.setTo(this.x, this.y, this.diameter), a
  1521. },
  1522. contains: function(a, c) {
  1523. return b.Circle.contains(this, a, c)
  1524. },
  1525. circumferencePoint: function(a, c, d) {
  1526. return b.Circle.circumferencePoint(this, a, c, d)
  1527. },
  1528. offset: function(a, b) {
  1529. return this.x += a, this.y += b, this
  1530. },
  1531. offsetPoint: function(a) {
  1532. return this.offset(a.x, a.y)
  1533. },
  1534. toString: function() {
  1535. return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]"
  1536. }
  1537. }, b.Circle.prototype.constructor = b.Circle, Object.defineProperty(b.Circle.prototype, "diameter", {
  1538. get: function() {
  1539. return this._diameter
  1540. },
  1541. set: function(a) {
  1542. a > 0 && (this._diameter = a, this._radius = .5 * a)
  1543. }
  1544. }), Object.defineProperty(b.Circle.prototype, "radius", {
  1545. get: function() {
  1546. return this._radius
  1547. },
  1548. set: function(a) {
  1549. a > 0 && (this._radius = a, this._diameter = 2 * a)
  1550. }
  1551. }), Object.defineProperty(b.Circle.prototype, "left", {
  1552. get: function() {
  1553. return this.x - this._radius
  1554. },
  1555. set: function(a) {
  1556. a > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - a
  1557. }
  1558. }), Object.defineProperty(b.Circle.prototype, "right", {
  1559. get: function() {
  1560. return this.x + this._radius
  1561. },
  1562. set: function(a) {
  1563. a < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.x
  1564. }
  1565. }), Object.defineProperty(b.Circle.prototype, "top", {
  1566. get: function() {
  1567. return this.y - this._radius
  1568. },
  1569. set: function(a) {
  1570. a > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - a
  1571. }
  1572. }), Object.defineProperty(b.Circle.prototype, "bottom", {
  1573. get: function() {
  1574. return this.y + this._radius
  1575. },
  1576. set: function(a) {
  1577. a < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = a - this.y
  1578. }
  1579. }), Object.defineProperty(b.Circle.prototype, "area", {
  1580. get: function() {
  1581. return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
  1582. }
  1583. }), Object.defineProperty(b.Circle.prototype, "empty", {
  1584. get: function() {
  1585. return 0 === this._diameter
  1586. },
  1587. set: function(a) {
  1588. a === !0 && this.setTo(0, 0, 0)
  1589. }
  1590. }), b.Circle.contains = function(a, b, c) {
  1591. var d, e;
  1592. return a.radius > 0 && b >= a.left && b <= a.right && c >= a.top && c <= a.bottom ? (d = (a.x - b) * (a.x - b), e = (a.y - c) * (a.y - c), d + e <= a.radius * a.radius) : !1
  1593. }, b.Circle.equals = function(a, b) {
  1594. return a.x == b.x && a.y == b.y && a.diameter == b.diameter
  1595. }, b.Circle.intersects = function(a, c) {
  1596. return b.Math.distance(a.x, a.y, c.x, c.y) <= a.radius + c.radius
  1597. }, b.Circle.circumferencePoint = function(a, c, d, e) {
  1598. return "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = new b.Point), d === !0 && (c = b.Math.degToRad(c)), e.x = a.x + a.radius * Math.cos(c), e.y = a.y + a.radius * Math.sin(c), e
  1599. }, b.Circle.intersectsRectangle = function(a, b) {
  1600. var e, f, g, h, i, j, k, c = Math.abs(a.x - b.x - b.halfWidth),
  1601. d = b.halfWidth + a.radius;
  1602. return c > d ? !1 : (e = Math.abs(a.y - b.y - b.halfHeight), f = b.halfHeight + a.radius, e > f ? !1 : c <= b.halfWidth || e <= b.halfHeight ? !0 : (g = c - b.halfWidth, h = e - b.halfHeight, i = g * g, j = h * h, k = a.radius * a.radius, k >= i + j))
  1603. }, PIXI.Circle = b.Circle, b.Point = function(a, b) {
  1604. a = a || 0, b = b || 0, this.x = a, this.y = b
  1605. }, b.Point.prototype = {
  1606. copyFrom: function(a) {
  1607. return this.setTo(a.x, a.y)
  1608. },
  1609. invert: function() {
  1610. return this.setTo(this.y, this.x)
  1611. },
  1612. setTo: function(a, b) {
  1613. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  1614. },
  1615. set: function(a, b) {
  1616. return this.x = a || 0, this.y = b || (0 !== b ? this.x : 0), this
  1617. },
  1618. add: function(a, b) {
  1619. return this.x += a, this.y += b, this
  1620. },
  1621. subtract: function(a, b) {
  1622. return this.x -= a, this.y -= b, this
  1623. },
  1624. multiply: function(a, b) {
  1625. return this.x *= a, this.y *= b, this
  1626. },
  1627. divide: function(a, b) {
  1628. return this.x /= a, this.y /= b, this
  1629. },
  1630. clampX: function(a, c) {
  1631. return this.x = b.Math.clamp(this.x, a, c), this
  1632. },
  1633. clampY: function(a, c) {
  1634. return this.y = b.Math.clamp(this.y, a, c), this
  1635. },
  1636. clamp: function(a, c) {
  1637. return this.x = b.Math.clamp(this.x, a, c), this.y = b.Math.clamp(this.y, a, c), this
  1638. },
  1639. clone: function(a) {
  1640. return "undefined" == typeof a ? a = new b.Point(this.x, this.y) : a.setTo(this.x, this.y), a
  1641. },
  1642. copyTo: function(a) {
  1643. return a.x = this.x, a.y = this.y, a
  1644. },
  1645. distance: function(a, c) {
  1646. return b.Point.distance(this, a, c)
  1647. },
  1648. equals: function(a) {
  1649. return a.x === this.x && a.y === this.y
  1650. },
  1651. angle: function(a, c) {
  1652. return "undefined" == typeof c && (c = !1), c ? b.Math.radToDeg(Math.atan2(a.y - this.y, a.x - this.x)) : Math.atan2(a.y - this.y, a.x - this.x)
  1653. },
  1654. angleSq: function(a) {
  1655. return this.subtract(a).angle(a.subtract(this))
  1656. },
  1657. rotate: function(a, c, d, e, f) {
  1658. return b.Point.rotate(this, a, c, d, e, f)
  1659. },
  1660. getMagnitude: function() {
  1661. return Math.sqrt(this.x * this.x + this.y * this.y)
  1662. },
  1663. getMagnitudeSq: function() {
  1664. return this.x * this.x + this.y * this.y
  1665. },
  1666. setMagnitude: function(a) {
  1667. return this.normalize().multiply(a, a)
  1668. },
  1669. normalize: function() {
  1670. if (!this.isZero()) {
  1671. var a = this.getMagnitude();
  1672. this.x /= a, this.y /= a
  1673. }
  1674. return this
  1675. },
  1676. isZero: function() {
  1677. return 0 === this.x && 0 === this.y
  1678. },
  1679. dot: function(a) {
  1680. return this.x * a.x + this.y * a.y
  1681. },
  1682. cross: function(a) {
  1683. return this.x * a.y - this.y * a.x
  1684. },
  1685. perp: function() {
  1686. return this.setTo(-this.y, this.x)
  1687. },
  1688. rperp: function() {
  1689. return this.setTo(this.y, -this.x)
  1690. },
  1691. normalRightHand: function() {
  1692. return this.setTo(-1 * this.y, this.x)
  1693. },
  1694. toString: function() {
  1695. return "[{Point (x=" + this.x + " y=" + this.y + ")}]"
  1696. }
  1697. }, b.Point.prototype.constructor = b.Point, b.Point.add = function(a, c, d) {
  1698. return "undefined" == typeof d && (d = new b.Point), d.x = a.x + c.x, d.y = a.y + c.y, d
  1699. }, b.Point.subtract = function(a, c, d) {
  1700. return "undefined" == typeof d && (d = new b.Point), d.x = a.x - c.x, d.y = a.y - c.y, d
  1701. }, b.Point.multiply = function(a, c, d) {
  1702. return "undefined" == typeof d && (d = new b.Point), d.x = a.x * c.x, d.y = a.y * c.y, d
  1703. }, b.Point.divide = function(a, c, d) {
  1704. return "undefined" == typeof d && (d = new b.Point), d.x = a.x / c.x, d.y = a.y / c.y, d
  1705. }, b.Point.equals = function(a, b) {
  1706. return a.x === b.x && a.y === b.y
  1707. }, b.Point.angle = function(a, b) {
  1708. return Math.atan2(a.y - b.y, a.x - b.x)
  1709. }, b.Point.angleSq = function(a, b) {
  1710. return a.subtract(b).angle(b.subtract(a))
  1711. }, b.Point.negative = function(a, c) {
  1712. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.x, -a.y)
  1713. }, b.Point.multiplyAdd = function(a, c, d, e) {
  1714. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + c.x * d, a.y + c.y * d)
  1715. }, b.Point.interpolate = function(a, c, d, e) {
  1716. return "undefined" == typeof e && (e = new b.Point), e.setTo(a.x + (c.x - a.x) * d, a.y + (c.y - a.y) * d)
  1717. }, b.Point.perp = function(a, c) {
  1718. return "undefined" == typeof c && (c = new b.Point), c.setTo(-a.y, a.x)
  1719. }, b.Point.rperp = function(a, c) {
  1720. return "undefined" == typeof c && (c = new b.Point), c.setTo(a.y, -a.x)
  1721. }, b.Point.distance = function(a, c, d) {
  1722. return "undefined" == typeof d && (d = !1), d ? b.Math.distanceRounded(a.x, a.y, c.x, c.y) : b.Math.distance(a.x, a.y, c.x, c.y)
  1723. }, b.Point.project = function(a, c, d) {
  1724. "undefined" == typeof d && (d = new b.Point);
  1725. var e = a.dot(c) / c.getMagnitudeSq();
  1726. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  1727. }, b.Point.projectUnit = function(a, c, d) {
  1728. "undefined" == typeof d && (d = new b.Point);
  1729. var e = a.dot(c);
  1730. return 0 !== e && d.setTo(e * c.x, e * c.y), d
  1731. }, b.Point.normalRightHand = function(a, c) {
  1732. return "undefined" == typeof c && (c = new b.Point), c.setTo(-1 * a.y, a.x)
  1733. }, b.Point.normalize = function(a, c) {
  1734. "undefined" == typeof c && (c = new b.Point);
  1735. var d = a.getMagnitude();
  1736. return 0 !== d && c.setTo(a.x / d, a.y / d), c
  1737. }, b.Point.rotate = function(a, c, d, e, f, g) {
  1738. return f = f || !1, g = g || null, f && (e = b.Math.degToRad(e)), null === g && (g = Math.sqrt((c - a.x) * (c - a.x) + (d - a.y) * (d - a.y))), a.setTo(c + g * Math.cos(e), d + g * Math.sin(e))
  1739. }, b.Point.centroid = function(a, c) {
  1740. var d, e;
  1741. if ("undefined" == typeof c && (c = new b.Point), "[object Array]" !== Object.prototype.toString.call(a)) throw new Error("Phaser.Point. Parameter 'points' must be an array");
  1742. if (d = a.length, 1 > d) throw new Error("Phaser.Point. Parameter 'points' array must not be empty");
  1743. if (1 === d) return c.copyFrom(a[0]), c;
  1744. for (e = 0; d > e; e++) b.Point.add(c, a[e], c);
  1745. return c.divide(d, d), c
  1746. }, PIXI.Point = b.Point, b.Rectangle = function(a, b, c, d) {
  1747. a = a || 0, b = b || 0, c = c || 0, d = d || 0, this.x = a, this.y = b, this.width = c, this.height = d
  1748. }, b.Rectangle.prototype = {
  1749. offset: function(a, b) {
  1750. return this.x += a, this.y += b, this
  1751. },
  1752. offsetPoint: function(a) {
  1753. return this.offset(a.x, a.y)
  1754. },
  1755. setTo: function(a, b, c, d) {
  1756. return this.x = a, this.y = b, this.width = c, this.height = d, this
  1757. },
  1758. floor: function() {
  1759. this.x = Math.floor(this.x), this.y = Math.floor(this.y)
  1760. },
  1761. floorAll: function() {
  1762. this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height)
  1763. },
  1764. copyFrom: function(a) {
  1765. return this.setTo(a.x, a.y, a.width, a.height)
  1766. },
  1767. copyTo: function(a) {
  1768. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  1769. },
  1770. inflate: function(a, c) {
  1771. return b.Rectangle.inflate(this, a, c)
  1772. },
  1773. size: function(a) {
  1774. return b.Rectangle.size(this, a)
  1775. },
  1776. clone: function(a) {
  1777. return b.Rectangle.clone(this, a)
  1778. },
  1779. contains: function(a, c) {
  1780. return b.Rectangle.contains(this, a, c)
  1781. },
  1782. containsRect: function(a) {
  1783. return b.Rectangle.containsRect(this, a)
  1784. },
  1785. equals: function(a) {
  1786. return b.Rectangle.equals(this, a)
  1787. },
  1788. intersection: function(a, c) {
  1789. return b.Rectangle.intersection(this, a, c)
  1790. },
  1791. intersects: function(a, c) {
  1792. return b.Rectangle.intersects(this, a, c)
  1793. },
  1794. intersectsRaw: function(a, c, d, e, f) {
  1795. return b.Rectangle.intersectsRaw(this, a, c, d, e, f)
  1796. },
  1797. union: function(a, c) {
  1798. return b.Rectangle.union(this, a, c)
  1799. },
  1800. toString: function() {
  1801. return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"
  1802. }
  1803. }, Object.defineProperty(b.Rectangle.prototype, "halfWidth", {
  1804. get: function() {
  1805. return Math.round(this.width / 2)
  1806. }
  1807. }), Object.defineProperty(b.Rectangle.prototype, "halfHeight", {
  1808. get: function() {
  1809. return Math.round(this.height / 2)
  1810. }
  1811. }), Object.defineProperty(b.Rectangle.prototype, "bottom", {
  1812. get: function() {
  1813. return this.y + this.height
  1814. },
  1815. set: function(a) {
  1816. this.height = a <= this.y ? 0 : this.y - a
  1817. }
  1818. }), Object.defineProperty(b.Rectangle.prototype, "bottomRight", {
  1819. get: function() {
  1820. return new b.Point(this.right, this.bottom)
  1821. },
  1822. set: function(a) {
  1823. this.right = a.x, this.bottom = a.y
  1824. }
  1825. }), Object.defineProperty(b.Rectangle.prototype, "left", {
  1826. get: function() {
  1827. return this.x
  1828. },
  1829. set: function(a) {
  1830. this.width = a >= this.right ? 0 : this.right - a, this.x = a
  1831. }
  1832. }), Object.defineProperty(b.Rectangle.prototype, "right", {
  1833. get: function() {
  1834. return this.x + this.width
  1835. },
  1836. set: function(a) {
  1837. this.width = a <= this.x ? 0 : a - this.x
  1838. }
  1839. }), Object.defineProperty(b.Rectangle.prototype, "volume", {
  1840. get: function() {
  1841. return this.width * this.height
  1842. }
  1843. }), Object.defineProperty(b.Rectangle.prototype, "perimeter", {
  1844. get: function() {
  1845. return 2 * this.width + 2 * this.height
  1846. }
  1847. }), Object.defineProperty(b.Rectangle.prototype, "centerX", {
  1848. get: function() {
  1849. return this.x + this.halfWidth
  1850. },
  1851. set: function(a) {
  1852. this.x = a - this.halfWidth
  1853. }
  1854. }), Object.defineProperty(b.Rectangle.prototype, "centerY", {
  1855. get: function() {
  1856. return this.y + this.halfHeight
  1857. },
  1858. set: function(a) {
  1859. this.y = a - this.halfHeight
  1860. }
  1861. }), Object.defineProperty(b.Rectangle.prototype, "randomX", {
  1862. get: function() {
  1863. return this.x + Math.random() * this.width
  1864. }
  1865. }), Object.defineProperty(b.Rectangle.prototype, "randomY", {
  1866. get: function() {
  1867. return this.y + Math.random() * this.height
  1868. }
  1869. }), Object.defineProperty(b.Rectangle.prototype, "top", {
  1870. get: function() {
  1871. return this.y
  1872. },
  1873. set: function(a) {
  1874. a >= this.bottom ? (this.height = 0, this.y = a) : this.height = this.bottom - a
  1875. }
  1876. }), Object.defineProperty(b.Rectangle.prototype, "topLeft", {
  1877. get: function() {
  1878. return new b.Point(this.x, this.y)
  1879. },
  1880. set: function(a) {
  1881. this.x = a.x, this.y = a.y
  1882. }
  1883. }), Object.defineProperty(b.Rectangle.prototype, "empty", {
  1884. get: function() {
  1885. return !this.width || !this.height
  1886. },
  1887. set: function(a) {
  1888. a === !0 && this.setTo(0, 0, 0, 0)
  1889. }
  1890. }), b.Rectangle.prototype.constructor = b.Rectangle, b.Rectangle.inflate = function(a, b, c) {
  1891. return a.x -= b, a.width += 2 * b, a.y -= c, a.height += 2 * c, a
  1892. }, b.Rectangle.inflatePoint = function(a, c) {
  1893. return b.Rectangle.inflate(a, c.x, c.y)
  1894. }, b.Rectangle.size = function(a, c) {
  1895. return "undefined" == typeof c || null === c ? c = new b.Point(a.width, a.height) : c.setTo(a.width, a.height), c
  1896. }, b.Rectangle.clone = function(a, c) {
  1897. return "undefined" == typeof c || null === c ? c = new b.Rectangle(a.x, a.y, a.width, a.height) : c.setTo(a.x, a.y, a.width, a.height), c
  1898. }, b.Rectangle.contains = function(a, b, c) {
  1899. return a.width <= 0 || a.height <= 0 ? !1 : b >= a.x && b <= a.right && c >= a.y && c <= a.bottom
  1900. }, b.Rectangle.containsRaw = function(a, b, c, d, e, f) {
  1901. return e >= a && a + c >= e && f >= b && b + d >= f
  1902. }, b.Rectangle.containsPoint = function(a, c) {
  1903. return b.Rectangle.contains(a, c.x, c.y)
  1904. }, b.Rectangle.containsRect = function(a, b) {
  1905. return a.volume > b.volume ? !1 : a.x >= b.x && a.y >= b.y && a.right <= b.right && a.bottom <= b.bottom
  1906. }, b.Rectangle.equals = function(a, b) {
  1907. return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
  1908. }, b.Rectangle.intersection = function(a, c, d) {
  1909. return "undefined" == typeof d && (d = new b.Rectangle), b.Rectangle.intersects(a, c) && (d.x = Math.max(a.x, c.x), d.y = Math.max(a.y, c.y), d.width = Math.min(a.right, c.right) - d.x, d.height = Math.min(a.bottom, c.bottom) - d.y), d
  1910. }, b.Rectangle.intersects = function(a, b) {
  1911. return a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0 ? !1 : !(a.right < b.x || a.bottom < b.y || a.x > b.right || a.y > b.bottom)
  1912. }, b.Rectangle.intersectsRaw = function(a, b, c, d, e, f) {
  1913. return "undefined" == typeof f && (f = 0), !(b > a.right + f || c < a.left - f || d > a.bottom + f || e < a.top - f)
  1914. }, b.Rectangle.union = function(a, c, d) {
  1915. return "undefined" == typeof d && (d = new b.Rectangle), d.setTo(Math.min(a.x, c.x), Math.min(a.y, c.y), Math.max(a.right, c.right) - Math.min(a.left, c.left), Math.max(a.bottom, c.bottom) - Math.min(a.top, c.top))
  1916. }, PIXI.Rectangle = b.Rectangle, PIXI.EmptyRectangle = new b.Rectangle(0, 0, 0, 0), b.Line = function(a, c, d, e) {
  1917. a = a || 0, c = c || 0, d = d || 0, e = e || 0, this.start = new b.Point(a, c), this.end = new b.Point(d, e)
  1918. }, b.Line.prototype = {
  1919. setTo: function(a, b, c, d) {
  1920. return this.start.setTo(a, b), this.end.setTo(c, d), this
  1921. },
  1922. fromSprite: function(a, b, c) {
  1923. return "undefined" == typeof c && (c = !1), c ? this.setTo(a.center.x, a.center.y, b.center.x, b.center.y) : this.setTo(a.x, a.y, b.x, b.y)
  1924. },
  1925. intersects: function(a, c, d) {
  1926. return b.Line.intersectsPoints(this.start, this.end, a.start, a.end, c, d)
  1927. },
  1928. pointOnLine: function(a, b) {
  1929. return (a - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (b - this.start.y)
  1930. },
  1931. pointOnSegment: function(a, b) {
  1932. var c = Math.min(this.start.x, this.end.x),
  1933. d = Math.max(this.start.x, this.end.x),
  1934. e = Math.min(this.start.y, this.end.y),
  1935. f = Math.max(this.start.y, this.end.y);
  1936. return this.pointOnLine(a, b) && a >= c && d >= a && b >= e && f >= b
  1937. },
  1938. coordinatesOnLine: function(a, b) {
  1939. var c, d, e, f, g, h, i, j, k, l, m;
  1940. for ("undefined" == typeof a && (a = 1), "undefined" == typeof b && (b = []), c = Math.round(this.start.x), d = Math.round(this.start.y), e = Math.round(this.end.x), f = Math.round(this.end.y), g = Math.abs(e - c), h = Math.abs(f - d), i = e > c ? 1 : -1, j = f > d ? 1 : -1, k = g - h, b.push([c, d]), l = 1; c != e || d != f;) m = k << 1, m > -h && (k -= h, c += i), g > m && (k += g, d += j), 0 === l % a && b.push([c, d]), l++;
  1941. return b
  1942. }
  1943. }, Object.defineProperty(b.Line.prototype, "length", {
  1944. get: function() {
  1945. return Math.sqrt((this.end.x - this.start.x) * (this.end.x - this.start.x) + (this.end.y - this.start.y) * (this.end.y - this.start.y))
  1946. }
  1947. }), Object.defineProperty(b.Line.prototype, "angle", {
  1948. get: function() {
  1949. return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x)
  1950. }
  1951. }), Object.defineProperty(b.Line.prototype, "slope", {
  1952. get: function() {
  1953. return (this.end.y - this.start.y) / (this.end.x - this.start.x)
  1954. }
  1955. }), Object.defineProperty(b.Line.prototype, "perpSlope", {
  1956. get: function() {
  1957. return -((this.end.x - this.start.x) / (this.end.y - this.start.y))
  1958. }
  1959. }), Object.defineProperty(b.Line.prototype, "x", {
  1960. get: function() {
  1961. return Math.min(this.start.x, this.end.x)
  1962. }
  1963. }), Object.defineProperty(b.Line.prototype, "y", {
  1964. get: function() {
  1965. return Math.min(this.start.y, this.end.y)
  1966. }
  1967. }), Object.defineProperty(b.Line.prototype, "left", {
  1968. get: function() {
  1969. return Math.min(this.start.x, this.end.x)
  1970. }
  1971. }), Object.defineProperty(b.Line.prototype, "right", {
  1972. get: function() {
  1973. return Math.max(this.start.x, this.end.x)
  1974. }
  1975. }), Object.defineProperty(b.Line.prototype, "top", {
  1976. get: function() {
  1977. return Math.min(this.start.y, this.end.y)
  1978. }
  1979. }), Object.defineProperty(b.Line.prototype, "bottom", {
  1980. get: function() {
  1981. return Math.max(this.start.y, this.end.y)
  1982. }
  1983. }), Object.defineProperty(b.Line.prototype, "width", {
  1984. get: function() {
  1985. return Math.abs(this.start.x - this.end.x)
  1986. }
  1987. }), Object.defineProperty(b.Line.prototype, "height", {
  1988. get: function() {
  1989. return Math.abs(this.start.y - this.end.y)
  1990. }
  1991. }), b.Line.intersectsPoints = function(a, c, d, e, f, g) {
  1992. var h, i, j, k, l, m, n, o, p, q;
  1993. return "undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = new b.Point), h = c.y - a.y, i = e.y - d.y, j = a.x - c.x, k = d.x - e.x, l = c.x * a.y - a.x * c.y, m = e.x * d.y - d.x * e.y, n = h * k - i * j, 0 === n ? null : (g.x = (j * m - k * l) / n, g.y = (i * l - h * m) / n, f ? (o = (e.y - d.y) * (c.x - a.x) - (e.x - d.x) * (c.y - a.y), p = ((e.x - d.x) * (a.y - d.y) - (e.y - d.y) * (a.x - d.x)) / o, q = ((c.x - a.x) * (a.y - d.y) - (c.y - a.y) * (a.x - d.x)) / o, p >= 0 && 1 >= p && q >= 0 && 1 >= q ? g : null) : g)
  1994. }, b.Line.intersects = function(a, c, d, e) {
  1995. return b.Line.intersectsPoints(a.start, a.end, c.start, c.end, d, e)
  1996. }, b.Ellipse = function(a, c, d, e) {
  1997. this.type = b.ELLIPSE, a = a || 0, c = c || 0, d = d || 0, e = e || 0, this.x = a, this.y = c, this.width = d, this.height = e
  1998. }, b.Ellipse.prototype = {
  1999. setTo: function(a, b, c, d) {
  2000. return this.x = a, this.y = b, this.width = c, this.height = d, this
  2001. },
  2002. copyFrom: function(a) {
  2003. return this.setTo(a.x, a.y, a.width, a.height)
  2004. },
  2005. copyTo: function(a) {
  2006. return a.x = this.x, a.y = this.y, a.width = this.width, a.height = this.height, a
  2007. },
  2008. clone: function(a) {
  2009. return "undefined" == typeof a ? a = new b.Ellipse(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  2010. },
  2011. contains: function(a, c) {
  2012. return b.Ellipse.contains(this, a, c)
  2013. },
  2014. toString: function() {
  2015. return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]"
  2016. }
  2017. }, b.Ellipse.prototype.constructor = b.Ellipse, Object.defineProperty(b.Ellipse.prototype, "left", {
  2018. get: function() {
  2019. return this.x
  2020. },
  2021. set: function(a) {
  2022. this.x = a
  2023. }
  2024. }), Object.defineProperty(b.Ellipse.prototype, "right", {
  2025. get: function() {
  2026. return this.x + this.width
  2027. },
  2028. set: function(a) {
  2029. this.width = a < this.x ? 0 : this.x + a
  2030. }
  2031. }), Object.defineProperty(b.Ellipse.prototype, "top", {
  2032. get: function() {
  2033. return this.y
  2034. },
  2035. set: function(a) {
  2036. this.y = a
  2037. }
  2038. }), Object.defineProperty(b.Ellipse.prototype, "bottom", {
  2039. get: function() {
  2040. return this.y + this.height
  2041. },
  2042. set: function(a) {
  2043. this.height = a < this.y ? 0 : this.y + a
  2044. }
  2045. }), Object.defineProperty(b.Ellipse.prototype, "empty", {
  2046. get: function() {
  2047. return 0 === this.width || 0 === this.height
  2048. },
  2049. set: function(a) {
  2050. a === !0 && this.setTo(0, 0, 0, 0)
  2051. }
  2052. }), b.Ellipse.contains = function(a, b, c) {
  2053. var d, e;
  2054. return a.width <= 0 || a.height <= 0 ? !1 : (d = (b - a.x) / a.width - .5, e = (c - a.y) / a.height - .5, d *= d, e *= e, .25 > d + e)
  2055. }, b.Ellipse.prototype.getBounds = function() {
  2056. return new b.Rectangle(this.x, this.y, this.width, this.height)
  2057. }, PIXI.Ellipse = b.Ellipse, b.Polygon = function(a) {
  2058. var c, d, e;
  2059. if (this.type = b.POLYGON, a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  2060. for (c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  2061. a = c
  2062. }
  2063. this._points = a
  2064. }, b.Polygon.prototype = {
  2065. clone: function() {
  2066. var c, a = [];
  2067. for (c = 0; c < this.points.length; c++) a.push(this.points[c].clone());
  2068. return new b.Polygon(a)
  2069. },
  2070. contains: function(a, b) {
  2071. var d, e, f, g, h, i, j, c = !1;
  2072. for (d = 0, e = this.points.length - 1; d < this.points.length; e = d++) f = this.points[d].x, g = this.points[d].y, h = this.points[e].x, i = this.points[e].y, j = g > b != i > b && (h - f) * (b - g) / (i - g) + f > a, j && (c = !c);
  2073. return c
  2074. }
  2075. }, b.Polygon.prototype.constructor = b.Polygon, Object.defineProperty(b.Polygon.prototype, "points", {
  2076. get: function() {
  2077. return this._points
  2078. },
  2079. set: function(a) {
  2080. var c, d, e;
  2081. if (a instanceof Array || (a = Array.prototype.slice.call(arguments)), "number" == typeof a[0]) {
  2082. for (c = [], d = 0, e = a.length; e > d; d += 2) c.push(new b.Point(a[d], a[d + 1]));
  2083. a = c
  2084. }
  2085. this._points = a
  2086. }
  2087. }), Object.defineProperty(b.Polygon.prototype, "area", {
  2088. get: function() {
  2089. var a, b, c, d, e, f = Number.MAX_VALUE,
  2090. g = 0;
  2091. for (e = 0; e < this.points.length; e++) this.points[e].y < f && (f = this.points[e].y);
  2092. for (e = 0; e < this.points.length; e++) a = this.points[e], b = e === this.points.length - 1 ? this.points[0] : this.points[e + 1], c = (a.y - f + (b.y - f)) / 2, d = a.x - b.x, g += c * d;
  2093. return g
  2094. }
  2095. }), PIXI.Polygon = b.Polygon, b.Camera = function(a, c, d, e, f, g) {
  2096. this.game = a, this.world = a.world, this.id = 0, this.view = new b.Rectangle(d, e, f, g), this.screenView = new b.Rectangle(d, e, f, g), this.bounds = new b.Rectangle(d, e, f, g), this.deadzone = null, this.visible = !0, this.atLimit = {
  2097. x: !1,
  2098. y: !1
  2099. }, this.target = null, this._edge = 0, this.displayObject = null, this.scale = null
  2100. }, b.Camera.FOLLOW_LOCKON = 0, b.Camera.FOLLOW_PLATFORMER = 1, b.Camera.FOLLOW_TOPDOWN = 2, b.Camera.FOLLOW_TOPDOWN_TIGHT = 3, b.Camera.prototype = {
  2101. follow: function(a, c) {
  2102. var d, e, f;
  2103. switch ("undefined" == typeof c && (c = b.Camera.FOLLOW_LOCKON), this.target = a, c) {
  2104. case b.Camera.FOLLOW_PLATFORMER:
  2105. e = this.width / 8, f = this.height / 3, this.deadzone = new b.Rectangle((this.width - e) / 2, (this.height - f) / 2 - .25 * f, e, f);
  2106. break;
  2107. case b.Camera.FOLLOW_TOPDOWN:
  2108. d = Math.max(this.width, this.height) / 4, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2109. break;
  2110. case b.Camera.FOLLOW_TOPDOWN_TIGHT:
  2111. d = Math.max(this.width, this.height) / 8, this.deadzone = new b.Rectangle((this.width - d) / 2, (this.height - d) / 2, d, d);
  2112. break;
  2113. case b.Camera.FOLLOW_LOCKON:
  2114. this.deadzone = null;
  2115. break;
  2116. default:
  2117. this.deadzone = null
  2118. }
  2119. },
  2120. unfollow: function() {
  2121. this.target = null
  2122. },
  2123. focusOn: function(a) {
  2124. this.setPosition(Math.round(a.x - this.view.halfWidth), Math.round(a.y - this.view.halfHeight))
  2125. },
  2126. focusOnXY: function(a, b) {
  2127. this.setPosition(Math.round(a - this.view.halfWidth), Math.round(b - this.view.halfHeight))
  2128. },
  2129. update: function() {
  2130. this.target && this.updateTarget(), this.bounds && this.checkBounds(), this.displayObject.position.x = -this.view.x, this.displayObject.position.y = -this.view.y
  2131. },
  2132. updateTarget: function() {
  2133. this.deadzone ? (this._edge = this.target.x - this.view.x, this._edge < this.deadzone.left ? this.view.x = this.target.x - this.deadzone.left : this._edge > this.deadzone.right && (this.view.x = this.target.x - this.deadzone.right), this._edge = this.target.y - this.view.y, this._edge < this.deadzone.top ? this.view.y = this.target.y - this.deadzone.top : this._edge > this.deadzone.bottom && (this.view.y = this.target.y - this.deadzone.bottom)) : (this.view.x = this.target.x - this.view.halfWidth, this.view.y = this.target.y - this.view.halfHeight)
  2134. },
  2135. setBoundsToWorld: function() {
  2136. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  2137. },
  2138. checkBounds: function() {
  2139. this.atLimit.x = !1, this.atLimit.y = !1, this.view.x <= this.bounds.x && (this.atLimit.x = !0, this.view.x = this.bounds.x), this.view.right >= this.bounds.right && (this.atLimit.x = !0, this.view.x = this.bounds.right - this.width), this.view.y <= this.bounds.top && (this.atLimit.y = !0, this.view.y = this.bounds.top), this.view.bottom >= this.bounds.bottom && (this.atLimit.y = !0, this.view.y = this.bounds.bottom - this.height), this.view.floor()
  2140. },
  2141. setPosition: function(a, b) {
  2142. this.view.x = a, this.view.y = b, this.bounds && this.checkBounds()
  2143. },
  2144. setSize: function(a, b) {
  2145. this.view.width = a, this.view.height = b
  2146. },
  2147. reset: function() {
  2148. this.target = null, this.view.x = 0, this.view.y = 0
  2149. }
  2150. }, b.Camera.prototype.constructor = b.Camera, Object.defineProperty(b.Camera.prototype, "x", {
  2151. get: function() {
  2152. return this.view.x
  2153. },
  2154. set: function(a) {
  2155. this.view.x = a, this.bounds && this.checkBounds()
  2156. }
  2157. }), Object.defineProperty(b.Camera.prototype, "y", {
  2158. get: function() {
  2159. return this.view.y
  2160. },
  2161. set: function(a) {
  2162. this.view.y = a, this.bounds && this.checkBounds()
  2163. }
  2164. }), Object.defineProperty(b.Camera.prototype, "width", {
  2165. get: function() {
  2166. return this.view.width
  2167. },
  2168. set: function(a) {
  2169. this.view.width = a
  2170. }
  2171. }), Object.defineProperty(b.Camera.prototype, "height", {
  2172. get: function() {
  2173. return this.view.height
  2174. },
  2175. set: function(a) {
  2176. this.view.height = a
  2177. }
  2178. }), b.State = function() {
  2179. this.game = null, this.add = null, this.make = null, this.camera = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.sound = null, this.scale = null, this.stage = null, this.time = null, this.tweens = null, this.world = null, this.particles = null, this.physics = null, this.rnd = null
  2180. }, b.State.prototype = {
  2181. preload: function() {},
  2182. loadUpdate: function() {},
  2183. loadRender: function() {},
  2184. create: function() {},
  2185. update: function() {},
  2186. render: function() {},
  2187. paused: function() {},
  2188. pauseUpdate: function() {},
  2189. shutdown: function() {}
  2190. }, b.State.prototype.constructor = b.State, b.StateManager = function(a, b) {
  2191. this.game = a, this.states = {}, this._pendingState = null, "undefined" != typeof b && null !== b && (this._pendingState = b), this._clearWorld = !1, this._clearCache = !1, this._created = !1, this._args = [], this.current = "", this.onInitCallback = null, this.onPreloadCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onPreRenderCallback = null, this.onLoadUpdateCallback = null, this.onLoadRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null, this.onShutDownCallback = null
  2192. }, b.StateManager.prototype = {
  2193. boot: function() {
  2194. this.game.onPause.add(this.pause, this), this.game.onResume.add(this.resume, this), this.game.load.onLoadComplete.add(this.loadComplete, this), null !== this._pendingState && ("string" == typeof this._pendingState ? this.start(this._pendingState, !1, !1) : this.add("default", this._pendingState, !0))
  2195. },
  2196. add: function(a, c, d) {
  2197. "undefined" == typeof d && (d = !1);
  2198. var e;
  2199. return c instanceof b.State ? e = c : "object" == typeof c ? (e = c, e.game = this.game) : "function" == typeof c && (e = new c(this.game)), this.states[a] = e, d && (this.game.isBooted ? this.start(a) : this._pendingState = a), e
  2200. },
  2201. remove: function(a) {
  2202. this.current === a && (this.callbackContext = null, this.onInitCallback = null, this.onShutDownCallback = null, this.onPreloadCallback = null, this.onLoadRenderCallback = null, this.onLoadUpdateCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null), delete this.states[a]
  2203. },
  2204. start: function(a, b, c) {
  2205. "undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = !1), this.checkState(a) && (this._pendingState = a, this._clearWorld = b, this._clearCache = c, arguments.length > 3 && (this._args = Array.prototype.splice.call(arguments, 3)))
  2206. },
  2207. restart: function(a, b) {
  2208. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !1), this._pendingState = this.current, this._clearWorld = a, this._clearCache = b, arguments.length > 2 && (this._args = Array.prototype.splice.call(arguments, 2))
  2209. },
  2210. dummy: function() {},
  2211. preUpdate: function() {
  2212. this._pendingState && this.game.isBooted && (this.current && (this.onShutDownCallback && this.onShutDownCallback.call(this.callbackContext, this.game), this.game.tweens.removeAll(), this.game.camera.reset(), this.game.input.reset(!0), this.game.physics.clear(), this.game.time.removeAll(), this._clearWorld && (this.game.world.shutdown(), this._clearCache === !0 && this.game.cache.destroy())), this.setCurrentState(this._pendingState), this.onPreloadCallback ? (this.game.load.reset(), this.onPreloadCallback.call(this.callbackContext, this.game), 0 === this.game.load.totalQueuedFiles() && 0 === this.game.load.totalQueuedPacks() ? this.loadComplete() : this.game.load.start()) : this.loadComplete(), this.current === this._pendingState && (this._pendingState = null))
  2213. },
  2214. checkState: function(a) {
  2215. if (this.states[a]) {
  2216. var b = !1;
  2217. return this.states[a]["preload"] && (b = !0), this.states[a]["create"] && (b = !0), this.states[a]["update"] && (b = !0), this.states[a]["render"] && (b = !0), b === !1 ? (console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render"), !1) : !0
  2218. }
  2219. return console.warn("Phaser.StateManager - No state found with the key: " + a), !1
  2220. },
  2221. link: function(a) {
  2222. this.states[a].game = this.game, this.states[a].add = this.game.add, this.states[a].make = this.game.make, this.states[a].camera = this.game.camera, this.states[a].cache = this.game.cache, this.states[a].input = this.game.input, this.states[a].load = this.game.load, this.states[a].math = this.game.math, this.states[a].sound = this.game.sound, this.states[a].scale = this.game.scale, this.states[a].state = this, this.states[a].stage = this.game.stage, this.states[a].time = this.game.time, this.states[a].tweens = this.game.tweens, this.states[a].world = this.game.world, this.states[a].particles = this.game.particles, this.states[a].rnd = this.game.rnd, this.states[a].physics = this.game.physics
  2223. },
  2224. setCurrentState: function(a) {
  2225. this.callbackContext = this.states[a], this.link(a), this.onInitCallback = this.states[a]["init"] || this.dummy, this.onPreloadCallback = this.states[a]["preload"] || null, this.onLoadRenderCallback = this.states[a]["loadRender"] || null, this.onLoadUpdateCallback = this.states[a]["loadUpdate"] || null, this.onCreateCallback = this.states[a]["create"] || null, this.onUpdateCallback = this.states[a]["update"] || null, this.onPreRenderCallback = this.states[a]["preRender"] || null, this.onRenderCallback = this.states[a]["render"] || null, this.onPausedCallback = this.states[a]["paused"] || null, this.onResumedCallback = this.states[a]["resumed"] || null, this.onPauseUpdateCallback = this.states[a]["pauseUpdate"] || null, this.onShutDownCallback = this.states[a]["shutdown"] || this.dummy, this.current = a, this._created = !1, this.onInitCallback.apply(this.callbackContext, this._args), this._args = []
  2226. },
  2227. getCurrentState: function() {
  2228. return this.states[this.current]
  2229. },
  2230. loadComplete: function() {
  2231. this._created === !1 && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0
  2232. },
  2233. pause: function() {
  2234. this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game)
  2235. },
  2236. resume: function() {
  2237. this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game)
  2238. },
  2239. update: function() {
  2240. this._created && this.onUpdateCallback ? this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2241. },
  2242. pauseUpdate: function() {
  2243. this._created && this.onPauseUpdateCallback ? this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game)
  2244. },
  2245. preRender: function() {
  2246. this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game)
  2247. },
  2248. render: function() {
  2249. this._created && this.onRenderCallback ? (this.game.renderType === b.CANVAS && (this.game.context.save(), this.game.context.setTransform(1, 0, 0, 1, 0, 0)), this.onRenderCallback.call(this.callbackContext, this.game), this.game.renderType === b.CANVAS && this.game.context.restore()) : this.onLoadRenderCallback && this.onLoadRenderCallback.call(this.callbackContext, this.game)
  2250. },
  2251. destroy: function() {
  2252. this.callbackContext = null, this.onInitCallback = null, this.onShutDownCallback = null, this.onPreloadCallback = null, this.onLoadRenderCallback = null, this.onLoadUpdateCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null, this.game = null, this.states = {}, this._pendingState = null
  2253. }
  2254. }, b.StateManager.prototype.constructor = b.StateManager, b.LinkedList = function() {
  2255. this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0
  2256. }, b.LinkedList.prototype = {
  2257. add: function(a) {
  2258. return 0 === this.total && null === this.first && null === this.last ? (this.first = a, this.last = a, this.next = a, a.prev = this, this.total++, a) : (this.last.next = a, a.prev = this.last, this.last = a, this.total++, a)
  2259. },
  2260. reset: function() {
  2261. this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0
  2262. },
  2263. remove: function(a) {
  2264. return 1 === this.total ? (this.reset(), a.next = a.prev = null, void 0) : (a === this.first ? this.first = this.first.next : a === this.last && (this.last = this.last.prev), a.prev && (a.prev.next = a.next), a.next && (a.next.prev = a.prev), a.next = a.prev = null, null === this.first && (this.last = null), this.total--, void 0)
  2265. },
  2266. callAll: function(a) {
  2267. if (this.first && this.last) {
  2268. var b = this.first;
  2269. do b && b[a] && b[a].call(b), b = b.next; while (b != this.last.next)
  2270. }
  2271. }
  2272. }, b.LinkedList.prototype.constructor = b.LinkedList, b.ArrayList = function() {
  2273. this.total = 0, this.position = 0, this.list = []
  2274. }, b.ArrayList.prototype = {
  2275. add: function(a) {
  2276. return this.exists(a) || (this.list.push(a), this.total++), a
  2277. },
  2278. getIndex: function(a) {
  2279. return this.list.indexOf(a)
  2280. },
  2281. exists: function(a) {
  2282. return this.list.indexOf(a) > -1
  2283. },
  2284. reset: function() {
  2285. this.list.length = 0, this.total = 0
  2286. },
  2287. remove: function(a) {
  2288. var b = this.list.indexOf(a);
  2289. return b > -1 ? (this.list.splice(b, 1), this.total--, a) : void 0
  2290. },
  2291. setAll: function(a, b) {
  2292. for (var c = this.list.length; c--;) this.list[c] && this.list[c][a] && (this.list[c][a] = b)
  2293. },
  2294. callAll: function(a) {
  2295. for (var b = Array.prototype.splice.call(arguments, 1), c = this.list.length; c--;) this.list[c] && this.list[c][a] && this.list[c][a].apply(this.list[c], b)
  2296. }
  2297. }, Object.defineProperty(b.ArrayList.prototype, "first", {
  2298. get: function() {
  2299. return this.position = 0, this.total > 0 ? this.list[0] : null
  2300. }
  2301. }), Object.defineProperty(b.ArrayList.prototype, "next", {
  2302. get: function() {
  2303. return this.position < this.total ? (this.position++, this.list[this.position]) : null
  2304. }
  2305. }), b.ArrayList.prototype.constructor = b.ArrayList, b.Signal = function() {
  2306. this._bindings = [], this._prevParams = null;
  2307. var a = this;
  2308. this.dispatch = function() {
  2309. b.Signal.prototype.dispatch.apply(a, arguments)
  2310. }
  2311. }, b.Signal.prototype = {
  2312. memorize: !1,
  2313. _shouldPropagate: !0,
  2314. active: !0,
  2315. validateListener: function(a, b) {
  2316. if ("function" != typeof a) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", b))
  2317. },
  2318. _registerListener: function(a, c, d, e) {
  2319. var g, f = this._indexOfListener(a, d);
  2320. if (-1 !== f) {
  2321. if (g = this._bindings[f], g.isOnce() !== c) throw new Error("You cannot add" + (c ? "" : "Once") + "() then add" + (c ? "Once" : "") + "() the same listener without removing the relationship first.")
  2322. } else g = new b.SignalBinding(this, a, c, d, e), this._addBinding(g);
  2323. return this.memorize && this._prevParams && g.execute(this._prevParams), g
  2324. },
  2325. _addBinding: function(a) {
  2326. var b = this._bindings.length;
  2327. do b--; while (this._bindings[b] && a._priority <= this._bindings[b]._priority);
  2328. this._bindings.splice(b + 1, 0, a)
  2329. },
  2330. _indexOfListener: function(a, b) {
  2331. for (var d, c = this._bindings.length; c--;)
  2332. if (d = this._bindings[c], d._listener === a && d.context === b) return c;
  2333. return -1
  2334. },
  2335. has: function(a, b) {
  2336. return -1 !== this._indexOfListener(a, b)
  2337. },
  2338. add: function(a, b, c) {
  2339. return this.validateListener(a, "add"), this._registerListener(a, !1, b, c)
  2340. },
  2341. addOnce: function(a, b, c) {
  2342. return this.validateListener(a, "addOnce"), this._registerListener(a, !0, b, c)
  2343. },
  2344. remove: function(a, b) {
  2345. this.validateListener(a, "remove");
  2346. var c = this._indexOfListener(a, b);
  2347. return -1 !== c && (this._bindings[c]._destroy(), this._bindings.splice(c, 1)), a
  2348. },
  2349. removeAll: function(a) {
  2350. "undefined" == typeof a && (a = null);
  2351. for (var b = this._bindings.length; b--;) a ? this._bindings[b].context === a && (this._bindings[b]._destroy(), this._bindings.splice(b, 1)) : this._bindings[b]._destroy();
  2352. this._bindings.length = 0
  2353. },
  2354. getNumListeners: function() {
  2355. return this._bindings.length
  2356. },
  2357. halt: function() {
  2358. this._shouldPropagate = !1
  2359. },
  2360. dispatch: function() {
  2361. var a, b, c;
  2362. if (this.active && (a = Array.prototype.slice.call(arguments), b = this._bindings.length, this.memorize && (this._prevParams = a), b)) {
  2363. c = this._bindings.slice(), this._shouldPropagate = !0;
  2364. do b--; while (c[b] && this._shouldPropagate && c[b].execute(a) !== !1)
  2365. }
  2366. },
  2367. forget: function() {
  2368. this._prevParams = null
  2369. },
  2370. dispose: function() {
  2371. this.removeAll(), delete this._bindings, delete this._prevParams
  2372. },
  2373. toString: function() {
  2374. return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]"
  2375. }
  2376. }, b.Signal.prototype.constructor = b.Signal, b.SignalBinding = function(a, b, c, d, e) {
  2377. this._listener = b, this._isOnce = c, this.context = d, this._signal = a, this._priority = e || 0
  2378. }, b.SignalBinding.prototype = {
  2379. active: !0,
  2380. params: null,
  2381. execute: function(a) {
  2382. var b, c;
  2383. return this.active && this._listener && (c = this.params ? this.params.concat(a) : a, b = this._listener.apply(this.context, c), this._isOnce && this.detach()), b
  2384. },
  2385. detach: function() {
  2386. return this.isBound() ? this._signal.remove(this._listener, this.context) : null
  2387. },
  2388. isBound: function() {
  2389. return !!this._signal && !!this._listener
  2390. },
  2391. isOnce: function() {
  2392. return this._isOnce
  2393. },
  2394. getListener: function() {
  2395. return this._listener
  2396. },
  2397. getSignal: function() {
  2398. return this._signal
  2399. },
  2400. _destroy: function() {
  2401. delete this._signal, delete this._listener, delete this.context
  2402. },
  2403. toString: function() {
  2404. return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]"
  2405. }
  2406. }, b.SignalBinding.prototype.constructor = b.SignalBinding, b.Filter = function(a, c, d) {
  2407. this.game = a, this.type = b.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = {
  2408. time: {
  2409. type: "1f",
  2410. value: 0
  2411. },
  2412. resolution: {
  2413. type: "2f",
  2414. value: {
  2415. x: 256,
  2416. y: 256
  2417. }
  2418. },
  2419. mouse: {
  2420. type: "2f",
  2421. value: {
  2422. x: 0,
  2423. y: 0
  2424. }
  2425. }
  2426. }, this.fragmentSrc = d || []
  2427. }, b.Filter.prototype = {
  2428. init: function() {},
  2429. setResolution: function(a, b) {
  2430. this.uniforms.resolution.value.x = a, this.uniforms.resolution.value.y = b
  2431. },
  2432. update: function(a) {
  2433. "undefined" != typeof a && (a.x > 0 && (this.uniforms.mouse.x = a.x.toFixed(2)), a.y > 0 && (this.uniforms.mouse.y = a.y.toFixed(2))), this.uniforms.time.value = this.game.time.totalElapsedSeconds()
  2434. },
  2435. destroy: function() {
  2436. this.game = null
  2437. }
  2438. }, b.Filter.prototype.constructor = b.Filter, Object.defineProperty(b.Filter.prototype, "width", {
  2439. get: function() {
  2440. return this.uniforms.resolution.value.x
  2441. },
  2442. set: function(a) {
  2443. this.uniforms.resolution.value.x = a
  2444. }
  2445. }), Object.defineProperty(b.Filter.prototype, "height", {
  2446. get: function() {
  2447. return this.uniforms.resolution.value.y
  2448. },
  2449. set: function(a) {
  2450. this.uniforms.resolution.value.y = a
  2451. }
  2452. }), b.Plugin = function(a, b) {
  2453. "undefined" == typeof b && (b = null), this.game = a, this.parent = b, this.active = !1, this.visible = !1, this.hasPreUpdate = !1, this.hasUpdate = !1, this.hasPostUpdate = !1, this.hasRender = !1, this.hasPostRender = !1
  2454. }, b.Plugin.prototype = {
  2455. preUpdate: function() {},
  2456. update: function() {},
  2457. render: function() {},
  2458. postRender: function() {},
  2459. destroy: function() {
  2460. this.game = null, this.parent = null, this.active = !1, this.visible = !1
  2461. }
  2462. }, b.Plugin.prototype.constructor = b.Plugin, b.PluginManager = function(a) {
  2463. this.game = a, this.plugins = [], this._len = 0, this._i = 0
  2464. }, b.PluginManager.prototype = {
  2465. add: function(a) {
  2466. var b = Array.prototype.splice.call(arguments, 1),
  2467. c = !1;
  2468. return "function" == typeof a ? a = new a(this.game, this) : (a.game = this.game, a.parent = this), "function" == typeof a["preUpdate"] && (a.hasPreUpdate = !0, c = !0), "function" == typeof a["update"] && (a.hasUpdate = !0, c = !0), "function" == typeof a["postUpdate"] && (a.hasPostUpdate = !0, c = !0), "function" == typeof a["render"] && (a.hasRender = !0, c = !0), "function" == typeof a["postRender"] && (a.hasPostRender = !0, c = !0), c ? ((a.hasPreUpdate || a.hasUpdate || a.hasPostUpdate) && (a.active = !0), (a.hasRender || a.hasPostRender) && (a.visible = !0), this._len = this.plugins.push(a), "function" == typeof a["init"] && a.init.apply(a, b), a) : null
  2469. },
  2470. remove: function(a) {
  2471. for (this._i = this._len; this._i--;)
  2472. if (this.plugins[this._i] === a) return a.destroy(), this.plugins.splice(this._i, 1), this._len--, void 0
  2473. },
  2474. removeAll: function() {
  2475. for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
  2476. this.plugins.length = 0, this._len = 0
  2477. },
  2478. preUpdate: function() {
  2479. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate()
  2480. },
  2481. update: function() {
  2482. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update()
  2483. },
  2484. postUpdate: function() {
  2485. for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate()
  2486. },
  2487. render: function() {
  2488. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render()
  2489. },
  2490. postRender: function() {
  2491. for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender()
  2492. },
  2493. destroy: function() {
  2494. this.removeAll(), this.game = null
  2495. }
  2496. }, b.PluginManager.prototype.constructor = b.PluginManager, b.Stage = function(a, c, d) {
  2497. this.game = a, this.offset = new b.Point, this.bounds = new b.Rectangle(0, 0, c, d), PIXI.Stage.call(this, 0), this.name = "_stage_root", this.interactive = !1, this.disableVisibilityChange = !1, this.checkOffsetInterval = 2500, this.exists = !0, this.currentRenderOrderID = 0, this._hiddenVar = "hidden", this._nextOffsetCheck = 0, this._backgroundColor = 0, a.config && this.parseConfig(a.config)
  2498. }, b.Stage.prototype = Object.create(PIXI.Stage.prototype), b.Stage.prototype.constructor = b.Stage, b.Stage.prototype.preUpdate = function() {
  2499. var a, b;
  2500. for (this.currentRenderOrderID = 0, a = this.children.length, b = 0; a > b; b++) this.children[b].preUpdate()
  2501. }, b.Stage.prototype.update = function() {
  2502. for (var a = this.children.length; a--;) this.children[a].update()
  2503. }, b.Stage.prototype.postUpdate = function() {
  2504. var a;
  2505. if (this.game.world.camera.target)
  2506. for (this.game.world.camera.target.postUpdate(), this.game.world.camera.update(), a = this.children.length; a--;) this.children[a] !== this.game.world.camera.target && this.children[a].postUpdate();
  2507. else
  2508. for (this.game.world.camera.update(), a = this.children.length; a--;) this.children[a].postUpdate();
  2509. this.checkOffsetInterval !== !1 && this.game.time.now > this._nextOffsetCheck && (b.Canvas.getOffset(this.game.canvas, this.offset), this.bounds.x = this.offset.x, this.bounds.y = this.offset.y, this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval)
  2510. }, b.Stage.prototype.parseConfig = function(a) {
  2511. a["checkOffsetInterval"] && (this.checkOffsetInterval = a["checkOffsetInterval"]), a["disableVisibilityChange"] && (this.disableVisibilityChange = a["disableVisibilityChange"]), a["fullScreenScaleMode"] && (this.fullScreenScaleMode = a["fullScreenScaleMode"]), a["scaleMode"] && (this.scaleMode = a["scaleMode"]), a["backgroundColor"] && (this.backgroundColor = a["backgroundColor"])
  2512. }, b.Stage.prototype.boot = function() {
  2513. b.Canvas.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.game.width, this.game.height);
  2514. var a = this;
  2515. this._onChange = function(b) {
  2516. return a.visibilityChange(b)
  2517. }, b.Canvas.setUserSelect(this.game.canvas, "none"), b.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility()
  2518. }, b.Stage.prototype.checkVisibility = function() {
  2519. this._hiddenVar = void 0 !== document.webkitHidden ? "webkitvisibilitychange" : void 0 !== document.mozHidden ? "mozvisibilitychange" : void 0 !== document.msHidden ? "msvisibilitychange" : void 0 !== document.hidden ? "visibilitychange" : null, this._hiddenVar && document.addEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = this._onChange, window.onpageshow = this._onChange, window.onblur = this._onChange, window.onfocus = this._onChange
  2520. }, b.Stage.prototype.visibilityChange = function(a) {
  2521. return "pagehide" === a.type || "blur" === a.type || "pageshow" === a.type || "focus" === a.type ? ("pagehide" === a.type || "blur" === a.type ? this.game.focusLoss(a) : ("pageshow" === a.type || "focus" === a.type) && this.game.focusGain(a), void 0) : (this.disableVisibilityChange || (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden ? this.game.gamePaused(a) : this.game.gameResumed(a)), void 0)
  2522. }, b.Stage.prototype.setBackgroundColor = function(a) {
  2523. var c;
  2524. "string" == typeof a ? (c = b.Color.hexToColor(a), this._backgroundColor = b.Color.getColor(c.r, c.g, c.b)) : (c = b.Color.getRGB(a), this._backgroundColor = a), this.backgroundColorSplit = [c.r / 255, c.g / 255, c.b / 255], this.backgroundColorString = b.Color.RGBtoString(c.r, c.g, c.b, 255, "#")
  2525. }, Object.defineProperty(b.Stage.prototype, "backgroundColor", {
  2526. get: function() {
  2527. return this._backgroundColor
  2528. },
  2529. set: function(a) {
  2530. this.game.transparent || this.setBackgroundColor(a)
  2531. }
  2532. }), Object.defineProperty(b.Stage.prototype, "smoothed", {
  2533. get: function() {
  2534. return !PIXI.scaleModes.LINEAR
  2535. },
  2536. set: function(a) {
  2537. PIXI.scaleModes.LINEAR = a ? 0 : 1
  2538. }
  2539. }), b.Group = function(a, c, d, e, f, g) {
  2540. "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1), "undefined" == typeof g && (g = b.Physics.ARCADE), this.game = a, "undefined" == typeof c && (c = a.world), this.name = d || "group", PIXI.DisplayObjectContainer.call(this), e ? this.game.stage.addChild(this) : c && c.addChild(this), this.z = 0, this.type = b.GROUP, this.alive = !0, this.exists = !0, this.classType = b.Sprite, this.scale = new b.Point(1, 1), this.cursor = null, this.cameraOffset = new b.Point, this.enableBody = f, this.enableBodyDebug = !1, this.physicsBodyType = g, this._sortProperty = "z", this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0, 0]
  2541. }, b.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), b.Group.prototype.constructor = b.Group, b.Group.RETURN_NONE = 0, b.Group.RETURN_TOTAL = 1, b.Group.RETURN_CHILD = 2, b.Group.SORT_ASCENDING = -1, b.Group.SORT_DESCENDING = 1, b.Group.prototype.add = function(a, b) {
  2542. return "undefined" == typeof b && (b = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChild(a), a.z = this.children.length, !b && a.events && a.events.onAddedToGroup.dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  2543. }, b.Group.prototype.addAt = function(a, b, c) {
  2544. return "undefined" == typeof c && (c = !1), a.parent !== this && (this.enableBody && this.game.physics.enable(a, this.physicsBodyType), this.addChildAt(a, b), this.updateZ(), !c && a.events && a.events.onAddedToGroup.dispatch(a, this), null === this.cursor && (this.cursor = a)), a
  2545. }, b.Group.prototype.getAt = function(a) {
  2546. return 0 > a || a >= this.children.length ? -1 : this.getChildAt(a)
  2547. }, b.Group.prototype.create = function(a, b, c, d, e) {
  2548. "undefined" == typeof e && (e = !0);
  2549. var f = new this.classType(this.game, a, b, c, d);
  2550. return this.enableBody && this.game.physics.enable(f, this.physicsBodyType, this.enableBodyDebug), f.exists = e, f.visible = e, f.alive = e, this.addChild(f), f.z = this.children.length, f.events && f.events.onAddedToGroup.dispatch(f, this), null === this.cursor && (this.cursor = f), f
  2551. }, b.Group.prototype.createMultiple = function(a, b, c, d) {
  2552. "undefined" == typeof d && (d = !1);
  2553. for (var e = 0; a > e; e++) this.create(0, 0, b, c, d)
  2554. }, b.Group.prototype.updateZ = function() {
  2555. for (var a = this.children.length; a--;) this.children[a].z = a
  2556. }, b.Group.prototype.resetCursor = function(a) {
  2557. return "undefined" == typeof a && (a = 0), a > this.children.length - 1 && (a = 0), this.cursor ? (this._cache[8] = a, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  2558. }, b.Group.prototype.next = function() {
  2559. return this.cursor ? (this._cache[8] >= this.children.length - 1 ? this._cache[8] = 0 : this._cache[8] ++, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  2560. }, b.Group.prototype.previous = function() {
  2561. return this.cursor ? (0 === this._cache[8] ? this._cache[8] = this.children.length - 1 : this._cache[8] --, this.cursor = this.children[this._cache[8]], this.cursor) : void 0
  2562. }, b.Group.prototype.swap = function(a, b) {
  2563. var c = this.swapChildren(a, b);
  2564. return c && this.updateZ(), c
  2565. }, b.Group.prototype.bringToTop = function(a) {
  2566. return a.parent === this && this.getIndex(a) < this.children.length && (this.remove(a, !1, !0), this.add(a, !0)), a
  2567. }, b.Group.prototype.sendToBack = function(a) {
  2568. return a.parent === this && this.getIndex(a) > 0 && (this.remove(a, !1, !0), this.addAt(a, 0, !0)), a
  2569. }, b.Group.prototype.moveUp = function(a) {
  2570. var b, c;
  2571. return a.parent === this && this.getIndex(a) < this.children.length - 1 && (b = this.getIndex(a), c = this.getAt(b + 1), c && this.swap(a, c)), a
  2572. }, b.Group.prototype.moveDown = function(a) {
  2573. var b, c;
  2574. return a.parent === this && this.getIndex(a) > 0 && (b = this.getIndex(a), c = this.getAt(b - 1), c && this.swap(a, c)), a
  2575. }, b.Group.prototype.xy = function(a, b, c) {
  2576. return 0 > a || a > this.children.length ? -1 : (this.getChildAt(a).x = b, this.getChildAt(a).y = c, void 0)
  2577. }, b.Group.prototype.reverse = function() {
  2578. this.children.reverse(), this.updateZ()
  2579. }, b.Group.prototype.getIndex = function(a) {
  2580. return this.children.indexOf(a)
  2581. }, b.Group.prototype.replace = function(a, c) {
  2582. var e, d = this.getIndex(a);
  2583. return -1 !== d ? (void 0 !== c.parent && (c.events.onRemovedFromGroup.dispatch(c, this), c.parent.removeChild(c), c.parent instanceof b.Group && c.parent.updateZ()), e = a, this.remove(e), this.addAt(c, d), e) : void 0
  2584. }, b.Group.prototype.hasProperty = function(a, b) {
  2585. var c = b.length;
  2586. return 1 === c && b[0] in a ? !0 : 2 === c && b[0] in a && b[1] in a[b[0]] ? !0 : 3 === c && b[0] in a && b[1] in a[b[0]] && b[2] in a[b[0]][b[1]] ? !0 : 4 === c && b[0] in a && b[1] in a[b[0]] && b[2] in a[b[0]][b[1]] && b[3] in a[b[0]][b[1]][b[2]] ? !0 : !1
  2587. }, b.Group.prototype.setProperty = function(a, b, c, d, e) {
  2588. if ("undefined" == typeof e && (e = !1), d = d || 0, !this.hasProperty(a, b) && (!e || d > 0)) return !1;
  2589. var f = b.length;
  2590. return 1 === f ? 0 === d ? a[b[0]] = c : 1 == d ? a[b[0]] += c : 2 == d ? a[b[0]] -= c : 3 == d ? a[b[0]] *= c : 4 == d && (a[b[0]] /= c) : 2 === f ? 0 === d ? a[b[0]][b[1]] = c : 1 == d ? a[b[0]][b[1]] += c : 2 == d ? a[b[0]][b[1]] -= c : 3 == d ? a[b[0]][b[1]] *= c : 4 == d && (a[b[0]][b[1]] /= c) : 3 === f ? 0 === d ? a[b[0]][b[1]][b[2]] = c : 1 == d ? a[b[0]][b[1]][b[2]] += c : 2 == d ? a[b[0]][b[1]][b[2]] -= c : 3 == d ? a[b[0]][b[1]][b[2]] *= c : 4 == d && (a[b[0]][b[1]][b[2]] /= c) : 4 === f && (0 === d ? a[b[0]][b[1]][b[2]][b[3]] = c : 1 == d ? a[b[0]][b[1]][b[2]][b[3]] += c : 2 == d ? a[b[0]][b[1]][b[2]][b[3]] -= c : 3 == d ? a[b[0]][b[1]][b[2]][b[3]] *= c : 4 == d && (a[b[0]][b[1]][b[2]][b[3]] /= c)), !0
  2591. }, b.Group.prototype.checkProperty = function(a, c, d, e) {
  2592. return "undefined" == typeof e && (e = !1), !b.Utils.getProperty(a, c) && e ? !1 : b.Utils.getProperty(a, c) !== d ? !1 : !0
  2593. }, b.Group.prototype.set = function(a, b, c, d, e, f, g) {
  2594. return "undefined" == typeof g && (g = !1), b = b.split("."), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), (d === !1 || d && a.alive) && (e === !1 || e && a.visible) ? this.setProperty(a, b, c, f, g) : void 0
  2595. }, b.Group.prototype.setAll = function(a, b, c, d, e, f) {
  2596. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof f && (f = !1), a = a.split("."), e = e || 0;
  2597. for (var g = 0, h = this.children.length; h > g; g++)(!c || c && this.children[g].alive) && (!d || d && this.children[g].visible) && this.setProperty(this.children[g], a, b, e, f)
  2598. }, b.Group.prototype.setAllChildren = function(a, c, d, e, f, g) {
  2599. "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), "undefined" == typeof g && (g = !1), f = f || 0;
  2600. for (var h = 0, i = this.children.length; i > h; h++)(!d || d && this.children[h].alive) && (!e || e && this.children[h].visible) && (this.children[h] instanceof b.Group ? this.children[h].setAllChildren(a, c, d, e, f, g) : this.setProperty(this.children[h], a.split("."), c, f, g))
  2601. }, b.Group.prototype.checkAll = function(a, b, c, d, e) {
  2602. "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1);
  2603. for (var f = 0, g = this.children.length; g > f; f++)
  2604. if ((!c || c && this.children[f].alive) && (!d || d && this.children[f].visible) && !this.checkProperty(this.children[f], a, b, e)) return !1;
  2605. return !0
  2606. }, b.Group.prototype.addAll = function(a, b, c, d) {
  2607. this.setAll(a, b, c, d, 1)
  2608. }, b.Group.prototype.subAll = function(a, b, c, d) {
  2609. this.setAll(a, b, c, d, 2)
  2610. }, b.Group.prototype.multiplyAll = function(a, b, c, d) {
  2611. this.setAll(a, b, c, d, 3)
  2612. }, b.Group.prototype.divideAll = function(a, b, c, d) {
  2613. this.setAll(a, b, c, d, 4)
  2614. }, b.Group.prototype.callAllExists = function(a, b) {
  2615. var d, e, c = Array.prototype.splice.call(arguments, 2);
  2616. for (d = 0, e = this.children.length; e > d; d++) this.children[d].exists === b && this.children[d][a] && this.children[d][a].apply(this.children[d], c)
  2617. }, b.Group.prototype.callbackFromArray = function(a, b, c) {
  2618. if (1 == c) {
  2619. if (a[b[0]]) return a[b[0]]
  2620. } else if (2 == c) {
  2621. if (a[b[0]][b[1]]) return a[b[0]][b[1]]
  2622. } else if (3 == c) {
  2623. if (a[b[0]][b[1]][b[2]]) return a[b[0]][b[1]][b[2]]
  2624. } else if (4 == c) {
  2625. if (a[b[0]][b[1]][b[2]][b[3]]) return a[b[0]][b[1]][b[2]][b[3]]
  2626. } else if (a[b]) return a[b];
  2627. return !1
  2628. }, b.Group.prototype.callAll = function(a, b) {
  2629. var c, d, e, f, g, h, i;
  2630. if ("undefined" != typeof a)
  2631. for (a = a.split("."), c = a.length, "undefined" == typeof b || null === b || "" === b ? b = null : "string" == typeof b && (b = b.split("."), d = b.length), e = Array.prototype.splice.call(arguments, 2), f = null, g = null, h = 0, i = this.children.length; i > h; h++) f = this.callbackFromArray(this.children[h], a, c), b && f ? (g = this.callbackFromArray(this.children[h], b, d), f && f.apply(g, e)) : f && f.apply(this.children[h], e)
  2632. }, b.Group.prototype.preUpdate = function() {
  2633. if (!this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  2634. for (var a = this.children.length; a--;) this.children[a].preUpdate();
  2635. return !0
  2636. }, b.Group.prototype.update = function() {
  2637. for (var a = this.children.length; a--;) this.children[a].update()
  2638. }, b.Group.prototype.postUpdate = function() {
  2639. 1 === this._cache[7] && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y);
  2640. for (var a = this.children.length; a--;) this.children[a].postUpdate()
  2641. }, b.Group.prototype.forEach = function(a, b, c) {
  2642. var d, e, f;
  2643. for ("undefined" == typeof c && (c = !1), d = Array.prototype.splice.call(arguments, 3), d.unshift(null), e = 0, f = this.children.length; f > e; e++)(!c || c && this.children[e].exists) && (d[0] = this.children[e], a.apply(b, d))
  2644. }, b.Group.prototype.forEachExists = function(a, c) {
  2645. var d = Array.prototype.splice.call(arguments, 2);
  2646. d.unshift(null), this.iterate("exists", !0, b.Group.RETURN_TOTAL, a, c, d)
  2647. }, b.Group.prototype.forEachAlive = function(a, c) {
  2648. var d = Array.prototype.splice.call(arguments, 2);
  2649. d.unshift(null), this.iterate("alive", !0, b.Group.RETURN_TOTAL, a, c, d)
  2650. }, b.Group.prototype.forEachDead = function(a, c) {
  2651. var d = Array.prototype.splice.call(arguments, 2);
  2652. d.unshift(null), this.iterate("alive", !1, b.Group.RETURN_TOTAL, a, c, d)
  2653. }, b.Group.prototype.sort = function(a, c) {
  2654. this.children.length < 2 || ("undefined" == typeof a && (a = "z"), "undefined" == typeof c && (c = b.Group.SORT_ASCENDING), this._sortProperty = a, c === b.Group.SORT_ASCENDING ? this.children.sort(this.ascendingSortHandler.bind(this)) : this.children.sort(this.descendingSortHandler.bind(this)), this.updateZ())
  2655. }, b.Group.prototype.customSort = function(a, b) {
  2656. this.children.length < 2 || (this.children.sort(a.bind(b)), this.updateZ())
  2657. }, b.Group.prototype.ascendingSortHandler = function(a, b) {
  2658. return a[this._sortProperty] < b[this._sortProperty] ? -1 : a[this._sortProperty] > b[this._sortProperty] ? 1 : a.z < b.z ? -1 : 1
  2659. }, b.Group.prototype.descendingSortHandler = function(a, b) {
  2660. return a[this._sortProperty] < b[this._sortProperty] ? 1 : a[this._sortProperty] > b[this._sortProperty] ? -1 : 0
  2661. }, b.Group.prototype.iterate = function(a, c, d, e, f, g) {
  2662. var h, i, j;
  2663. if (d === b.Group.RETURN_TOTAL && 0 === this.children.length) return 0;
  2664. for ("undefined" == typeof e && (e = !1), h = 0, i = 0, j = this.children.length; j > i; i++)
  2665. if (this.children[i][a] === c && (h++, e && (g[0] = this.children[i], e.apply(f, g)), d === b.Group.RETURN_CHILD)) return this.children[i];
  2666. return d === b.Group.RETURN_TOTAL ? h : d === b.Group.RETURN_CHILD ? null : void 0
  2667. }, b.Group.prototype.getFirstExists = function(a) {
  2668. return "boolean" != typeof a && (a = !0), this.iterate("exists", a, b.Group.RETURN_CHILD)
  2669. }, b.Group.prototype.getFirstAlive = function() {
  2670. return this.iterate("alive", !0, b.Group.RETURN_CHILD)
  2671. }, b.Group.prototype.getFirstDead = function() {
  2672. return this.iterate("alive", !1, b.Group.RETURN_CHILD)
  2673. }, b.Group.prototype.getTop = function() {
  2674. return this.children.length > 0 ? this.children[this.children.length - 1] : void 0
  2675. }, b.Group.prototype.getBottom = function() {
  2676. return this.children.length > 0 ? this.children[0] : void 0
  2677. }, b.Group.prototype.countLiving = function() {
  2678. return this.iterate("alive", !0, b.Group.RETURN_TOTAL)
  2679. }, b.Group.prototype.countDead = function() {
  2680. return this.iterate("alive", !1, b.Group.RETURN_TOTAL)
  2681. }, b.Group.prototype.getRandom = function(a, b) {
  2682. return 0 === this.children.length ? null : (a = a || 0, b = b || this.children.length, this.game.math.getRandom(this.children, a, b))
  2683. }, b.Group.prototype.remove = function(a, b, c) {
  2684. if ("undefined" == typeof b && (b = !1), "undefined" == typeof c && (c = !1), 0 === this.children.length || -1 === this.children.indexOf(a)) return !1;
  2685. c || !a.events || a.destroyPhase || a.events.onRemovedFromGroup.dispatch(a, this);
  2686. var d = this.removeChild(a);
  2687. return this.updateZ(), this.cursor === a && this.next(), b && d && d.destroy(!0), !0
  2688. }, b.Group.prototype.removeAll = function(a, b) {
  2689. if ("undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), 0 !== this.children.length) {
  2690. do {
  2691. !b && this.children[0].events && this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
  2692. var c = this.removeChild(this.children[0]);
  2693. a && c && c.destroy(!0)
  2694. } while (this.children.length > 0);
  2695. this.cursor = null
  2696. }
  2697. }, b.Group.prototype.removeBetween = function(a, b, c, d) {
  2698. var e, f;
  2699. if ("undefined" == typeof b && (b = this.children.length), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), 0 !== this.children.length) {
  2700. if (a > b || 0 > a || b > this.children.length) return !1;
  2701. for (e = b; e >= a;) !d && this.children[e].events && this.children[e].events.onRemovedFromGroup.dispatch(this.children[e], this), f = this.removeChild(this.children[e]), c && f && f.destroy(!0), this.cursor === this.children[e] && (this.cursor = null), e--;
  2702. this.updateZ()
  2703. }
  2704. }, b.Group.prototype.destroy = function(a, b) {
  2705. null !== this.game && ("undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !1), this.removeAll(a), this.cursor = null, this.filters = null, b || (this.parent && this.parent.removeChild(this), this.game = null, this.exists = !1))
  2706. }, Object.defineProperty(b.Group.prototype, "total", {
  2707. get: function() {
  2708. return this.iterate("exists", !0, b.Group.RETURN_TOTAL)
  2709. }
  2710. }), Object.defineProperty(b.Group.prototype, "length", {
  2711. get: function() {
  2712. return this.children.length
  2713. }
  2714. }), Object.defineProperty(b.Group.prototype, "angle", {
  2715. get: function() {
  2716. return b.Math.radToDeg(this.rotation)
  2717. },
  2718. set: function(a) {
  2719. this.rotation = b.Math.degToRad(a)
  2720. }
  2721. }), Object.defineProperty(b.Group.prototype, "fixedToCamera", {
  2722. get: function() {
  2723. return !!this._cache[7]
  2724. },
  2725. set: function(a) {
  2726. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  2727. }
  2728. }), b.World = function(a) {
  2729. b.Group.call(this, a, null, "__world", !1), this.bounds = new b.Rectangle(0, 0, a.width, a.height), this.camera = null
  2730. }, b.World.prototype = Object.create(b.Group.prototype), b.World.prototype.constructor = b.World, b.World.prototype.boot = function() {
  2731. this.camera = new b.Camera(this.game, 0, 0, 0, this.game.width, this.game.height), this.camera.displayObject = this, this.camera.scale = this.scale, this.game.camera = this.camera, this.game.stage.addChild(this)
  2732. }, b.World.prototype.setBounds = function(a, b, c, d) {
  2733. c < this.game.width && (c = this.game.width), d < this.game.height && (d = this.game.height), this.bounds.setTo(a, b, c, d), this.camera.bounds && this.camera.bounds.setTo(a, b, c, d), this.game.physics.setBoundsToWorld()
  2734. }, b.World.prototype.shutdown = function() {
  2735. this.destroy(!0, !0)
  2736. }, b.World.prototype.wrap = function(a, b, c, d, e) {
  2737. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = !0), c ? (a.getBounds(), d && (a.x + a._currentBounds.width < this.bounds.x ? a.x = this.bounds.right : a.x > this.bounds.right && (a.x = this.bounds.left)), e && (a.y + a._currentBounds.height < this.bounds.top ? a.y = this.bounds.bottom : a.y > this.bounds.bottom && (a.y = this.bounds.top))) : (d && a.x + b < this.bounds.x ? a.x = this.bounds.right + b : d && a.x - b > this.bounds.right && (a.x = this.bounds.left - b), e && a.y + b < this.bounds.top ? a.y = this.bounds.bottom + b : e && a.y - b > this.bounds.bottom && (a.y = this.bounds.top - b))
  2738. }, Object.defineProperty(b.World.prototype, "width", {
  2739. get: function() {
  2740. return this.bounds.width
  2741. },
  2742. set: function(a) {
  2743. this.bounds.width = a
  2744. }
  2745. }), Object.defineProperty(b.World.prototype, "height", {
  2746. get: function() {
  2747. return this.bounds.height
  2748. },
  2749. set: function(a) {
  2750. this.bounds.height = a
  2751. }
  2752. }), Object.defineProperty(b.World.prototype, "centerX", {
  2753. get: function() {
  2754. return this.bounds.halfWidth
  2755. }
  2756. }), Object.defineProperty(b.World.prototype, "centerY", {
  2757. get: function() {
  2758. return this.bounds.halfHeight
  2759. }
  2760. }), Object.defineProperty(b.World.prototype, "randomX", {
  2761. get: function() {
  2762. return this.bounds.x < 0 ? this.game.rnd.integerInRange(this.bounds.x, this.bounds.width - Math.abs(this.bounds.x)) : this.game.rnd.integerInRange(this.bounds.x, this.bounds.width)
  2763. }
  2764. }), Object.defineProperty(b.World.prototype, "randomY", {
  2765. get: function() {
  2766. return this.bounds.y < 0 ? this.game.rnd.integerInRange(this.bounds.y, this.bounds.height - Math.abs(this.bounds.y)) : this.game.rnd.integerInRange(this.bounds.y, this.bounds.height)
  2767. }
  2768. }), b.ScaleManager = function(a, c, d) {
  2769. this.game = a, this.width = c, this.height = d, this.minWidth = null, this.maxWidth = null, this.minHeight = null, this.maxHeight = null, this.forceLandscape = !1, this.forcePortrait = !1, this.incorrectOrientation = !1, this.pageAlignHorizontally = !1, this.pageAlignVertically = !1, this.maxIterations = 5, this.orientationSprite = null, this.enterLandscape = new b.Signal, this.enterPortrait = new b.Signal, this.enterIncorrectOrientation = new b.Signal, this.leaveIncorrectOrientation = new b.Signal, this.hasResized = new b.Signal, this.fullScreenTarget = this.game.canvas, this.enterFullScreen = new b.Signal, this.leaveFullScreen = new b.Signal, this.orientation = 0, window["orientation"] ? this.orientation = window["orientation"] : window.outerWidth > window.outerHeight && (this.orientation = 90), this.scaleFactor = new b.Point(1, 1), this.scaleFactorInversed = new b.Point(1, 1), this.margin = new b.Point(0, 0), this.bounds = new b.Rectangle(0, 0, c, d), this.aspectRatio = 0, this.sourceAspectRatio = c / d, this.event = null, this.scaleMode = b.ScaleManager.NO_SCALE, this.fullScreenScaleMode = b.ScaleManager.NO_SCALE, this._startHeight = 0, this._width = 0, this._height = 0, this._check = null;
  2770. var e = this;
  2771. window.addEventListener("orientationchange", function(a) {
  2772. return e.checkOrientation(a)
  2773. }, !1), window.addEventListener("resize", function(a) {
  2774. return e.checkResize(a)
  2775. }, !1), this.game.device.cocoonJS || (document.addEventListener("webkitfullscreenchange", function(a) {
  2776. return e.fullScreenChange(a)
  2777. }, !1), document.addEventListener("mozfullscreenchange", function(a) {
  2778. return e.fullScreenChange(a)
  2779. }, !1), document.addEventListener("fullscreenchange", function(a) {
  2780. return e.fullScreenChange(a)
  2781. }, !1))
  2782. }, b.ScaleManager.EXACT_FIT = 0, b.ScaleManager.NO_SCALE = 1, b.ScaleManager.SHOW_ALL = 2, b.ScaleManager.prototype = {
  2783. startFullScreen: function(a) {
  2784. !this.isFullScreen && this.game.device.fullscreen && ("undefined" != typeof a && this.game.renderType === b.CANVAS && (this.game.stage.smoothed = a), this._width = this.width, this._height = this.height, this.game.device.fullscreenKeyboard ? this.fullScreenTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT) : this.fullScreenTarget[this.game.device.requestFullscreen]())
  2785. },
  2786. stopFullScreen: function() {
  2787. document[this.game.device.cancelFullscreen]()
  2788. },
  2789. fullScreenChange: function(a) {
  2790. this.event = a, this.isFullScreen ? (this.fullScreenScaleMode === b.ScaleManager.EXACT_FIT ? (this.fullScreenTarget.style["width"] = "100%", this.fullScreenTarget.style["height"] = "100%", this.width = window.outerWidth, this.height = window.outerHeight, this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.checkResize()) : this.fullScreenScaleMode === b.ScaleManager.SHOW_ALL && (this.setShowAll(), this.refresh()), this.enterFullScreen.dispatch(this.width, this.height)) : (this.fullScreenTarget.style["width"] = this.game.width + "px", this.fullScreenTarget.style["height"] = this.game.height + "px", this.width = this._width, this.height = this._height, this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.leaveFullScreen.dispatch(this.width, this.height))
  2791. },
  2792. forceOrientation: function(a, c, d) {
  2793. "undefined" == typeof c && (c = !1), this.forceLandscape = a, this.forcePortrait = c, "undefined" != typeof d && ((null === d || this.game.cache.checkImageKey(d) === !1) && (d = "__default"), this.orientationSprite = new b.Image(this.game, this.game.width / 2, this.game.height / 2, d), this.orientationSprite.anchor.set(.5), this.checkOrientationState(), this.incorrectOrientation ? (this.orientationSprite.visible = !0, this.game.world.visible = !1) : (this.orientationSprite.visible = !1, this.game.world.visible = !0), this.game.stage.addChild(this.orientationSprite))
  2794. },
  2795. checkOrientationState: function() {
  2796. this.incorrectOrientation ? (this.forceLandscape && window.innerWidth > window.innerHeight || this.forcePortrait && window.innerHeight > window.innerWidth) && (this.incorrectOrientation = !1, this.leaveIncorrectOrientation.dispatch(), this.orientationSprite && (this.orientationSprite.visible = !1, this.game.world.visible = !0), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh()) : (this.forceLandscape && window.innerWidth < window.innerHeight || this.forcePortrait && window.innerHeight < window.innerWidth) && (this.incorrectOrientation = !0, this.enterIncorrectOrientation.dispatch(), this.orientationSprite && this.orientationSprite.visible === !1 && (this.orientationSprite.visible = !0, this.game.world.visible = !1), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh())
  2797. },
  2798. checkOrientation: function(a) {
  2799. this.event = a, this.orientation = window["orientation"], this.isLandscape ? this.enterLandscape.dispatch(this.orientation, !0, !1) : this.enterPortrait.dispatch(this.orientation, !1, !0), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh()
  2800. },
  2801. checkResize: function(a) {
  2802. this.event = a, this.orientation = window.outerWidth > window.outerHeight ? 90 : 0, this.isLandscape ? this.enterLandscape.dispatch(this.orientation, !0, !1) : this.enterPortrait.dispatch(this.orientation, !1, !0), this.scaleMode !== b.ScaleManager.NO_SCALE && this.refresh(), this.checkOrientationState()
  2803. },
  2804. refresh: function() {
  2805. if (this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (this.game.device.android && !this.game.device.chrome ? window.scrollTo(0, 1) : window.scrollTo(0, 0)), null === this._check && this.maxIterations > 0) {
  2806. this._iterations = this.maxIterations;
  2807. var a = this;
  2808. this._check = window.setInterval(function() {
  2809. return a.setScreenSize()
  2810. }, 10), this.setScreenSize()
  2811. }
  2812. },
  2813. setScreenSize: function(a) {
  2814. "undefined" == typeof a && (a = !1), this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (this.game.device.android && !this.game.device.chrome ? window.scrollTo(0, 1) : window.scrollTo(0, 0)), this._iterations--, (a || window.innerHeight > this._startHeight || this._iterations < 0) && (document.documentElement["style"].minHeight = window.innerHeight + "px", this.incorrectOrientation ? this.setMaximum() : this.isFullScreen ? this.fullScreenScaleMode === b.ScaleManager.EXACT_FIT ? this.setExactFit() : this.fullScreenScaleMode === b.ScaleManager.SHOW_ALL && this.setShowAll() : this.scaleMode === b.ScaleManager.EXACT_FIT ? this.setExactFit() : this.scaleMode === b.ScaleManager.SHOW_ALL && this.setShowAll(), this.setSize(), clearInterval(this._check), this._check = null)
  2815. },
  2816. setSize: function() {
  2817. this.incorrectOrientation || (this.maxWidth && this.width > this.maxWidth && (this.width = this.maxWidth), this.maxHeight && this.height > this.maxHeight && (this.height = this.maxHeight), this.minWidth && this.width < this.minWidth && (this.width = this.minWidth), this.minHeight && this.height < this.minHeight && (this.height = this.minHeight)), this.game.canvas.style.width = this.width + "px", this.game.canvas.style.height = this.height + "px", this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height), this.pageAlignHorizontally && (this.width < window.innerWidth && !this.incorrectOrientation ? (this.margin.x = Math.round((window.innerWidth - this.width) / 2), this.game.canvas.style.marginLeft = this.margin.x + "px") : (this.margin.x = 0, this.game.canvas.style.marginLeft = "0px")), this.pageAlignVertically && (this.height < window.innerHeight && !this.incorrectOrientation ? (this.margin.y = Math.round((window.innerHeight - this.height) / 2), this.game.canvas.style.marginTop = this.margin.y + "px") : (this.margin.y = 0, this.game.canvas.style.marginTop = "0px")), b.Canvas.getOffset(this.game.canvas, this.game.stage.offset), this.bounds.setTo(this.game.stage.offset.x, this.game.stage.offset.y, this.width, this.height), this.aspectRatio = this.width / this.height, this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.scaleFactorInversed.x = this.width / this.game.width, this.scaleFactorInversed.y = this.height / this.game.height, this.hasResized.dispatch(this.width, this.height), this.checkOrientationState()
  2818. },
  2819. setMaximum: function() {
  2820. this.width = window.innerWidth, this.height = window.innerHeight
  2821. },
  2822. setShowAll: function() {
  2823. var a = Math.min(window.innerHeight / this.game.height, window.innerWidth / this.game.width);
  2824. this.width = Math.round(this.game.width * a), this.height = Math.round(this.game.height * a)
  2825. },
  2826. setExactFit: function() {
  2827. var a = window.innerWidth,
  2828. b = window.innerHeight;
  2829. this.width = this.maxWidth && a > this.maxWidth ? this.maxWidth : a, this.height = this.maxHeight && b > this.maxHeight ? this.maxHeight : b
  2830. }
  2831. }, b.ScaleManager.prototype.constructor = b.ScaleManager, Object.defineProperty(b.ScaleManager.prototype, "isFullScreen", {
  2832. get: function() {
  2833. return document["fullscreenElement"] || document["mozFullScreenElement"] || document["webkitFullscreenElement"]
  2834. }
  2835. }), Object.defineProperty(b.ScaleManager.prototype, "isPortrait", {
  2836. get: function() {
  2837. return 0 === this.orientation || 180 === this.orientation
  2838. }
  2839. }), Object.defineProperty(b.ScaleManager.prototype, "isLandscape", {
  2840. get: function() {
  2841. return 90 === this.orientation || -90 === this.orientation
  2842. }
  2843. }), b.Game = function(a, c, d, e, f, g, h, i) {
  2844. this.id = b.GAMES.push(this) - 1, this.config = null, this.physicsConfig = i, this.parent = "", this.width = 800, this.height = 600, this.transparent = !1, this.antialias = !0, this.preserveDrawingBuffer = !1, this.renderer = null, this.renderType = b.AUTO, this.state = null, this.isBooted = !1, this.isRunning = !1, this.raf = null, this.add = null, this.make = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.net = null, this.scale = null, this.sound = null, this.stage = null, this.time = null, this.tweens = null, this.world = null, this.physics = null, this.rnd = null, this.device = null, this.camera = null, this.canvas = null, this.context = null, this.debug = null, this.particles = null, this.stepping = !1, this.pendingStep = !1, this.stepCount = 0, this.onPause = null, this.onResume = null, this.onBlur = null, this.onFocus = null, this._paused = !1, this._codePaused = !1, 1 === arguments.length && "object" == typeof arguments[0] ? this.parseConfig(arguments[0]) : (this.config = {
  2845. enableDebug: !0
  2846. }, "undefined" != typeof a && (this.width = a), "undefined" != typeof c && (this.height = c), "undefined" != typeof d && (this.renderer = d, this.renderType = d), "undefined" != typeof e && (this.parent = e), "undefined" != typeof g && (this.transparent = g), "undefined" != typeof h && (this.antialias = h), this.rnd = new b.RandomDataGenerator([(Date.now() * Math.random()).toString()]), this.state = new b.StateManager(this, f));
  2847. var j = this;
  2848. return this._onBoot = function() {
  2849. return j.boot()
  2850. }, "complete" === document.readyState || "interactive" === document.readyState ? window.setTimeout(this._onBoot, 0) : (document.addEventListener("DOMContentLoaded", this._onBoot, !1), window.addEventListener("load", this._onBoot, !1)), this
  2851. }, b.Game.prototype = {
  2852. parseConfig: function(a) {
  2853. var c, d;
  2854. this.config = a, a["width"] && (this.width = b.Utils.parseDimension(a["width"], 0)), a["height"] && (this.height = b.Utils.parseDimension(a["height"], 1)), a["renderer"] && (this.renderer = a["renderer"], this.renderType = a["renderer"]), a["parent"] && (this.parent = a["parent"]), a["transparent"] && (this.transparent = a["transparent"]), a["antialias"] && (this.antialias = a["antialias"]), a["preserveDrawingBuffer"] && (this.preserveDrawingBuffer = a["preserveDrawingBuffer"]), a["physicsConfig"] && (this.physicsConfig = a["physicsConfig"]), c = [(Date.now() * Math.random()).toString()], a["seed"] && (c = a["seed"]), this.rnd = new b.RandomDataGenerator(c), d = null, a["state"] && (d = a["state"]), this.state = new b.StateManager(this, d)
  2855. },
  2856. boot: function() {
  2857. this.isBooted || (document.body ? (document.removeEventListener("DOMContentLoaded", this._onBoot), window.removeEventListener("load", this._onBoot), this.onPause = new b.Signal, this.onResume = new b.Signal, this.onBlur = new b.Signal, this.onFocus = new b.Signal, this.isBooted = !0, this.device = new b.Device(this), this.math = b.Math, this.stage = new b.Stage(this, this.width, this.height), this.setUpRenderer(), this.scale = new b.ScaleManager(this, this.width, this.height), this.device.checkFullScreenSupport(), this.world = new b.World(this), this.add = new b.GameObjectFactory(this), this.make = new b.GameObjectCreator(this), this.cache = new b.Cache(this), this.load = new b.Loader(this), this.time = new b.Time(this), this.tweens = new b.TweenManager(this), this.input = new b.Input(this), this.sound = new b.SoundManager(this), this.physics = new b.Physics(this, this.physicsConfig), this.particles = new b.Particles(this), this.plugins = new b.PluginManager(this), this.net = new b.Net(this), this.time.boot(), this.stage.boot(), this.world.boot(), this.input.boot(), this.sound.boot(), this.state.boot(), this.config["enableDebug"] && (this.debug = new b.Utils.Debug(this), this.debug.boot()), this.showDebugHeader(), this.isRunning = !0, this.raf = this.config && this.config["forceSetTimeOut"] ? new b.RequestAnimationFrame(this, this.config["forceSetTimeOut"]) : new b.RequestAnimationFrame(this, !1), this.raf.start()) : window.setTimeout(this._onBoot, 20))
  2858. },
  2859. showDebugHeader: function() {
  2860. var f, g, a = b.VERSION,
  2861. c = "Canvas",
  2862. d = "HTML Audio",
  2863. e = 1;
  2864. if (this.renderType === b.WEBGL ? (c = "WebGL", e++) : this.renderType == b.HEADLESS && (c = "Headless"), this.device.webAudio && (d = "WebAudio", e++), this.device.chrome) {
  2865. for (f = ["%c %c %c Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " %c %c " + " http://phaser.io %c %c ♥%c♥%c♥ ", "background: #0cf300", "background: #00bc17", "color: #ffffff; background: #00711f;", "background: #00bc17", "background: #0cf300", "background: #00bc17"], g = 0; 3 > g; g++) e > g ? f.push("color: #ff2424; background: #fff") : f.push("color: #959595; background: #fff");
  2866. console.log.apply(console, f)
  2867. } else window["console"] && console.log("Phaser v" + a + " | Pixi.js " + PIXI.VERSION + " | " + c + " | " + d + " | http://phaser.io")
  2868. },
  2869. setUpRenderer: function() {
  2870. if (this.device.trident && (this.renderType = b.CANVAS), this.canvas = this.config["canvasID"] ? b.Canvas.create(this.width, this.height, this.config["canvasID"]) : b.Canvas.create(this.width, this.height), this.config["canvasStyle"] ? this.canvas.style = this.config["canvasStyle"] : this.canvas.style["-webkit-full-screen"] = "width: 100%; height: 100%", this.device.cocoonJS && (this.canvas.screencanvas = !0), this.renderType === b.HEADLESS || this.renderType === b.CANVAS || this.renderType === b.AUTO && this.device.webGL === !1) {
  2871. if (!this.device.canvas) throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");
  2872. this.renderType === b.AUTO && (this.renderType = b.CANVAS), this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.canvas, this.transparent), this.context = this.renderer.context
  2873. } else this.renderType = b.WEBGL, this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.canvas, this.transparent, this.antialias, this.preserveDrawingBuffer), this.context = null;
  2874. this.renderType !== b.HEADLESS && (this.stage.smoothed = this.antialias, b.Canvas.addToDOM(this.canvas, this.parent, !1), b.Canvas.setTouchAction(this.canvas))
  2875. },
  2876. update: function(a) {
  2877. this.time.update(a), this._paused || this.pendingStep ? (this.state.pauseUpdate(), this.config["enableDebug"] && this.debug.preUpdate()) : (this.stepping && (this.pendingStep = !0), this.config["enableDebug"] && this.debug.preUpdate(), this.physics.preUpdate(), this.state.preUpdate(), this.plugins.preUpdate(), this.stage.preUpdate(), this.state.update(), this.stage.update(), this.tweens.update(), this.sound.update(), this.input.update(), this.physics.update(), this.particles.update(), this.plugins.update(), this.stage.postUpdate(), this.plugins.postUpdate()), this.renderType != b.HEADLESS && (this.state.preRender(), this.renderer.render(this.stage), this.plugins.render(), this.state.render(), this.plugins.postRender(), this.device.cocoonJS && this.renderType === b.CANVAS && 1 === this.stage.currentRenderOrderID && this.context.fillRect(0, 0, 0, 0))
  2878. },
  2879. enableStep: function() {
  2880. this.stepping = !0, this.pendingStep = !1, this.stepCount = 0
  2881. },
  2882. disableStep: function() {
  2883. this.stepping = !1, this.pendingStep = !1
  2884. },
  2885. step: function() {
  2886. this.pendingStep = !1, this.stepCount++
  2887. },
  2888. destroy: function() {
  2889. this.raf.stop(), this.input.destroy(), this.state.destroy(), this.physics.destroy(), this.state = null, this.cache = null, this.input = null, this.load = null, this.sound = null, this.stage = null, this.time = null, this.world = null, this.isBooted = !1
  2890. },
  2891. gamePaused: function(a) {
  2892. this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.setMute(), this.onPause.dispatch(a))
  2893. },
  2894. gameResumed: function(a) {
  2895. this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.unsetMute(), this.onResume.dispatch(a))
  2896. },
  2897. focusLoss: function(a) {
  2898. this.onBlur.dispatch(a), this.stage.disableVisibilityChange || this.gamePaused(a)
  2899. },
  2900. focusGain: function(a) {
  2901. this.onFocus.dispatch(a), this.stage.disableVisibilityChange || this.gameResumed(a)
  2902. }
  2903. }, b.Game.prototype.constructor = b.Game, Object.defineProperty(b.Game.prototype, "paused", {
  2904. get: function() {
  2905. return this._paused
  2906. },
  2907. set: function(a) {
  2908. a === !0 ? (this._paused === !1 && (this._paused = !0, this.sound.setMute(), this.time.gamePaused(), this.onPause.dispatch(this)), this._codePaused = !0) : (this._paused && (this._paused = !1, this.input.reset(), this.sound.unsetMute(), this.time.gameResumed(), this.onResume.dispatch(this)), this._codePaused = !1)
  2909. }
  2910. }), b.Input = function(a) {
  2911. this.game = a, this.hitCanvas = null, this.hitContext = null, this.moveCallbacks = [], this.moveCallback = null, this.moveCallbackContext = this, this.pollRate = 0, this.disabled = !1, this.multiInputOverride = b.Input.MOUSE_TOUCH_COMBINE, this.position = null, this.speed = null, this.circle = null, this.scale = null, this.maxPointers = 10, this.currentPointers = 0, this.tapRate = 200, this.doubleTapRate = 300, this.holdRate = 2e3, this.justPressedRate = 200, this.justReleasedRate = 200, this.recordPointerHistory = !1, this.recordRate = 100, this.recordLimit = 100, this.pointer1 = null, this.pointer2 = null, this.pointer3 = null, this.pointer4 = null, this.pointer5 = null, this.pointer6 = null, this.pointer7 = null, this.pointer8 = null, this.pointer9 = null, this.pointer10 = null, this.activePointer = null, this.mousePointer = null, this.mouse = null, this.keyboard = null, this.touch = null, this.mspointer = null, this.gamepad = null, this.resetLocked = !1, this.onDown = null, this.onUp = null, this.onTap = null, this.onHold = null, this.minPriorityID = 0, this.interactiveItems = new b.ArrayList, this._localPoint = new b.Point, this._pollCounter = 0, this._oldPosition = null, this._x = 0, this._y = 0
  2912. }, b.Input.MOUSE_OVERRIDES_TOUCH = 0, b.Input.TOUCH_OVERRIDES_MOUSE = 1, b.Input.MOUSE_TOUCH_COMBINE = 2, b.Input.prototype = {
  2913. boot: function() {
  2914. this.mousePointer = new b.Pointer(this.game, 0), this.pointer1 = new b.Pointer(this.game, 1), this.pointer2 = new b.Pointer(this.game, 2), this.mouse = new b.Mouse(this.game), this.keyboard = new b.Keyboard(this.game), this.touch = new b.Touch(this.game), this.mspointer = new b.MSPointer(this.game), this.gamepad = new b.Gamepad(this.game), this.onDown = new b.Signal, this.onUp = new b.Signal, this.onTap = new b.Signal, this.onHold = new b.Signal, this.scale = new b.Point(1, 1), this.speed = new b.Point, this.position = new b.Point, this._oldPosition = new b.Point, this.circle = new b.Circle(0, 0, 44), this.activePointer = this.mousePointer, this.currentPointers = 0, this.hitCanvas = document.createElement("canvas"), this.hitCanvas.width = 1, this.hitCanvas.height = 1, this.hitContext = this.hitCanvas.getContext("2d"), this.mouse.start(), this.keyboard.start(), this.touch.start(), this.mspointer.start(), this.mousePointer.active = !0
  2915. },
  2916. destroy: function() {
  2917. this.mouse.stop(), this.keyboard.stop(), this.touch.stop(), this.mspointer.stop(), this.gamepad.stop(), this.moveCallbacks = [], this.moveCallback = null
  2918. },
  2919. setMoveCallback: function(a, b) {
  2920. this.moveCallback = a, this.moveCallbackContext = b
  2921. },
  2922. addMoveCallback: function(a, b) {
  2923. return this.moveCallbacks.push({
  2924. callback: a,
  2925. context: b
  2926. }) - 1
  2927. },
  2928. deleteMoveCallback: function(a) {
  2929. this.moveCallbacks[a] && this.moveCallbacks.splice(a, 1)
  2930. },
  2931. addPointer: function() {
  2932. var c, a = 0;
  2933. for (c = 10; c > 0; c--) null === this["pointer" + c] && (a = c);
  2934. return 0 === a ? (console.warn("You can only have 10 Pointer objects"), null) : (this["pointer" + a] = new b.Pointer(this.game, a), this["pointer" + a])
  2935. },
  2936. update: function() {
  2937. return this.keyboard.update(), this.pollRate > 0 && this._pollCounter < this.pollRate ? (this._pollCounter++, void 0) : (this.speed.x = this.position.x - this._oldPosition.x, this.speed.y = this.position.y - this._oldPosition.y, this._oldPosition.copyFrom(this.position), this.mousePointer.update(), this.gamepad.active && this.gamepad.update(), this.pointer1.update(), this.pointer2.update(), this.pointer3 && this.pointer3.update(), this.pointer4 && this.pointer4.update(), this.pointer5 && this.pointer5.update(), this.pointer6 && this.pointer6.update(), this.pointer7 && this.pointer7.update(), this.pointer8 && this.pointer8.update(), this.pointer9 && this.pointer9.update(), this.pointer10 && this.pointer10.update(), this._pollCounter = 0, void 0)
  2938. },
  2939. reset: function(a) {
  2940. if (this.game.isBooted && !this.resetLocked) {
  2941. "undefined" == typeof a && (a = !1), this.keyboard.reset(a), this.mousePointer.reset(), this.gamepad.reset();
  2942. for (var c = 1; 10 >= c; c++) this["pointer" + c] && this["pointer" + c].reset();
  2943. this.currentPointers = 0, "none" !== this.game.canvas.style.cursor && (this.game.canvas.style.cursor = "inherit"), a && (this.onDown.dispose(), this.onUp.dispose(), this.onTap.dispose(), this.onHold.dispose(), this.onDown = new b.Signal, this.onUp = new b.Signal, this.onTap = new b.Signal, this.onHold = new b.Signal, this.moveCallbacks = []), this._pollCounter = 0
  2944. }
  2945. },
  2946. resetSpeed: function(a, b) {
  2947. this._oldPosition.setTo(a, b), this.speed.setTo(0, 0)
  2948. },
  2949. startPointer: function(a) {
  2950. if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) return null;
  2951. if (this.pointer1.active === !1) return this.pointer1.start(a);
  2952. if (this.pointer2.active === !1) return this.pointer2.start(a);
  2953. for (var b = 3; 10 >= b; b++)
  2954. if (this["pointer" + b] && this["pointer" + b].active === !1) return this["pointer" + b].start(a);
  2955. return null
  2956. },
  2957. updatePointer: function(a) {
  2958. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.move(a);
  2959. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.move(a);
  2960. for (var b = 3; 10 >= b; b++)
  2961. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].move(a);
  2962. return null
  2963. },
  2964. stopPointer: function(a) {
  2965. if (this.pointer1.active && this.pointer1.identifier == a.identifier) return this.pointer1.stop(a);
  2966. if (this.pointer2.active && this.pointer2.identifier == a.identifier) return this.pointer2.stop(a);
  2967. for (var b = 3; 10 >= b; b++)
  2968. if (this["pointer" + b] && this["pointer" + b].active && this["pointer" + b].identifier == a.identifier) return this["pointer" + b].stop(a);
  2969. return null
  2970. },
  2971. getPointer: function(a) {
  2972. if (a = a || !1, this.pointer1.active == a) return this.pointer1;
  2973. if (this.pointer2.active == a) return this.pointer2;
  2974. for (var b = 3; 10 >= b; b++)
  2975. if (this["pointer" + b] && this["pointer" + b].active == a) return this["pointer" + b];
  2976. return null
  2977. },
  2978. getPointerFromIdentifier: function(a) {
  2979. if (this.pointer1.identifier === a) return this.pointer1;
  2980. if (this.pointer2.identifier === a) return this.pointer2;
  2981. for (var b = 3; 10 >= b; b++)
  2982. if (this["pointer" + b] && this["pointer" + b].identifier === a) return this["pointer" + b];
  2983. return null
  2984. },
  2985. getPointerFromId: function(a) {
  2986. if (this.pointer1.pointerId === a) return this.pointer1;
  2987. if (this.pointer2.pointerId === a) return this.pointer2;
  2988. for (var b = 3; 10 >= b; b++)
  2989. if (this["pointer" + b] && this["pointer" + b].pointerId === a) return this["pointer" + b];
  2990. return null
  2991. },
  2992. getLocalPosition: function(a, c, d) {
  2993. var e, f;
  2994. return "undefined" == typeof d && (d = new b.Point), e = a.worldTransform, f = 1 / (e.a * e.d + e.b * -e.c), d.setTo(e.d * f * c.x + -e.b * f * c.y + (e.ty * e.b - e.tx * e.d) * f, e.a * f * c.y + -e.c * f * c.x + (-e.ty * e.a + e.tx * e.c) * f)
  2995. },
  2996. hitTest: function(a, c, d) {
  2997. var e, f, g, h, i, j;
  2998. if (!a.worldVisible) return !1;
  2999. if (this.getLocalPosition(a, c, this._localPoint), d.copyFrom(this._localPoint), a.hitArea && a.hitArea.contains) return a.hitArea.contains(this._localPoint.x, this._localPoint.y) ? !0 : !1;
  3000. if (a instanceof b.TileSprite) {
  3001. if (e = a.width, f = a.height, g = -e * a.anchor.x, this._localPoint.x > g && this._localPoint.x < g + e && (h = -f * a.anchor.y, this._localPoint.y > h && this._localPoint.y < h + f)) return !0
  3002. } else if (a instanceof PIXI.Sprite && (e = a.texture.frame.width, f = a.texture.frame.height, g = -e * a.anchor.x, this._localPoint.x > g && this._localPoint.x < g + e && (h = -f * a.anchor.y, this._localPoint.y > h && this._localPoint.y < h + f))) return !0;
  3003. for (i = 0, j = a.children.length; j > i; i++)
  3004. if (this.hitTest(a.children[i], c, d)) return !0;
  3005. return !1
  3006. }
  3007. }, b.Input.prototype.constructor = b.Input, Object.defineProperty(b.Input.prototype, "x", {
  3008. get: function() {
  3009. return this._x
  3010. },
  3011. set: function(a) {
  3012. this._x = Math.floor(a)
  3013. }
  3014. }), Object.defineProperty(b.Input.prototype, "y", {
  3015. get: function() {
  3016. return this._y
  3017. },
  3018. set: function(a) {
  3019. this._y = Math.floor(a)
  3020. }
  3021. }), Object.defineProperty(b.Input.prototype, "pollLocked", {
  3022. get: function() {
  3023. return this.pollRate > 0 && this._pollCounter < this.pollRate
  3024. }
  3025. }), Object.defineProperty(b.Input.prototype, "totalInactivePointers", {
  3026. get: function() {
  3027. return 10 - this.currentPointers
  3028. }
  3029. }), Object.defineProperty(b.Input.prototype, "totalActivePointers", {
  3030. get: function() {
  3031. this.currentPointers = 0;
  3032. for (var a = 1; 10 >= a; a++) this["pointer" + a] && this["pointer" + a].active && this.currentPointers++;
  3033. return this.currentPointers
  3034. }
  3035. }), Object.defineProperty(b.Input.prototype, "worldX", {
  3036. get: function() {
  3037. return this.game.camera.view.x + this.x
  3038. }
  3039. }), Object.defineProperty(b.Input.prototype, "worldY", {
  3040. get: function() {
  3041. return this.game.camera.view.y + this.y
  3042. }
  3043. }), b.Key = function(a, c) {
  3044. this.game = a, this.enabled = !0, this.event = null, this.isDown = !1, this.isUp = !0, this.altKey = !1, this.ctrlKey = !1, this.shiftKey = !1, this.timeDown = 0, this.duration = 0, this.timeUp = -2500, this.repeats = 0, this.keyCode = c, this.onDown = new b.Signal, this.onHoldCallback = null, this.onHoldContext = null, this.onUp = new b.Signal
  3045. }, b.Key.prototype = {
  3046. update: function() {
  3047. this.enabled && this.isDown && (this.duration = this.game.time.now - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this))
  3048. },
  3049. processKeyDown: function(a) {
  3050. this.enabled && (this.event = a, this.isDown || (this.altKey = a.altKey, this.ctrlKey = a.ctrlKey, this.shiftKey = a.shiftKey, this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0, this.onDown.dispatch(this)))
  3051. },
  3052. processKeyUp: function(a) {
  3053. this.enabled && (this.event = a, this.isUp || (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.duration = this.game.time.now - this.timeDown, this.onUp.dispatch(this)))
  3054. },
  3055. reset: function(a) {
  3056. "undefined" == typeof a && (a = !0), this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.duration = 0, this.enabled = !0, a && (this.onDown.removeAll(), this.onUp.removeAll(), this.onHoldCallback = null, this.onHoldContext = null)
  3057. },
  3058. justPressed: function(a) {
  3059. return "undefined" == typeof a && (a = 50), this.isDown && this.duration < a
  3060. },
  3061. justReleased: function(a) {
  3062. return "undefined" == typeof a && (a = 50), !this.isDown && this.game.time.now - this.timeUp < a
  3063. }
  3064. }, b.Key.prototype.constructor = b.Key, b.Keyboard = function(a) {
  3065. this.game = a, this.disabled = !1, this.event = null, this.pressEvent = null, this.callbackContext = this, this.onDownCallback = null, this.onPressCallback = null, this.onUpCallback = null, this._keys = [], this._capture = [], this._onKeyDown = null, this._onKeyPress = null, this._onKeyUp = null, this._i = 0, this._k = 0
  3066. }, b.Keyboard.prototype = {
  3067. addCallbacks: function(a, b, c, d) {
  3068. this.callbackContext = a, "undefined" != typeof b && (this.onDownCallback = b), "undefined" != typeof c && (this.onUpCallback = c), "undefined" != typeof d && (this.onPressCallback = d)
  3069. },
  3070. addKey: function(a) {
  3071. return this._keys[a] || (this._keys[a] = new b.Key(this.game, a), this.addKeyCapture(a)), this._keys[a]
  3072. },
  3073. removeKey: function(a) {
  3074. this._keys[a] && (this._keys[a] = null, this.removeKeyCapture(a))
  3075. },
  3076. createCursorKeys: function() {
  3077. return {
  3078. up: this.addKey(b.Keyboard.UP),
  3079. down: this.addKey(b.Keyboard.DOWN),
  3080. left: this.addKey(b.Keyboard.LEFT),
  3081. right: this.addKey(b.Keyboard.RIGHT)
  3082. }
  3083. },
  3084. start: function() {
  3085. if (!this.game.device.cocoonJS && null === this._onKeyDown) {
  3086. var a = this;
  3087. this._onKeyDown = function(b) {
  3088. return a.processKeyDown(b)
  3089. }, this._onKeyUp = function(b) {
  3090. return a.processKeyUp(b)
  3091. }, this._onKeyPress = function(b) {
  3092. return a.processKeyPress(b)
  3093. }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
  3094. }
  3095. },
  3096. stop: function() {
  3097. window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null
  3098. },
  3099. destroy: function() {
  3100. this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0
  3101. },
  3102. addKeyCapture: function(a) {
  3103. if ("object" == typeof a)
  3104. for (var b in a) this._capture[a[b]] = !0;
  3105. else this._capture[a] = !0
  3106. },
  3107. removeKeyCapture: function(a) {
  3108. delete this._capture[a]
  3109. },
  3110. clearCaptures: function() {
  3111. this._capture = {}
  3112. },
  3113. update: function() {
  3114. for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update()
  3115. },
  3116. processKeyDown: function(a) {
  3117. this.event = a, this.game.input.disabled || this.disabled || (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new b.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyDown(a), this._k = a.keyCode, this.onDownCallback && this.onDownCallback.call(this.callbackContext, a))
  3118. },
  3119. processKeyPress: function(a) {
  3120. this.pressEvent = a, this.game.input.disabled || this.disabled || this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(a.charCode), a)
  3121. },
  3122. processKeyUp: function(a) {
  3123. this.event = a, this.game.input.disabled || this.disabled || (this._capture[a.keyCode] && a.preventDefault(), this._keys[a.keyCode] || (this._keys[a.keyCode] = new b.Key(this.game, a.keyCode)), this._keys[a.keyCode].processKeyUp(a), this.onUpCallback && this.onUpCallback.call(this.callbackContext, a))
  3124. },
  3125. reset: function(a) {
  3126. "undefined" == typeof a && (a = !0), this.event = null;
  3127. for (var b = this._keys.length; b--;) this._keys[b] && this._keys[b].reset(a)
  3128. },
  3129. justPressed: function(a, b) {
  3130. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justPressed(b) : !1
  3131. },
  3132. justReleased: function(a, b) {
  3133. return "undefined" == typeof b && (b = 50), this._keys[a] ? this._keys[a].justReleased(b) : !1
  3134. },
  3135. isDown: function(a) {
  3136. return this._keys[a] ? this._keys[a].isDown : !1
  3137. }
  3138. }, Object.defineProperty(b.Keyboard.prototype, "lastChar", {
  3139. get: function() {
  3140. return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode)
  3141. }
  3142. }), Object.defineProperty(b.Keyboard.prototype, "lastKey", {
  3143. get: function() {
  3144. return this._keys[this._k]
  3145. }
  3146. }), b.Keyboard.prototype.constructor = b.Keyboard, b.Keyboard.A = "A".charCodeAt(0), b.Keyboard.B = "B".charCodeAt(0), b.Keyboard.C = "C".charCodeAt(0), b.Keyboard.D = "D".charCodeAt(0), b.Keyboard.E = "E".charCodeAt(0), b.Keyboard.F = "F".charCodeAt(0), b.Keyboard.G = "G".charCodeAt(0), b.Keyboard.H = "H".charCodeAt(0), b.Keyboard.I = "I".charCodeAt(0), b.Keyboard.J = "J".charCodeAt(0), b.Keyboard.K = "K".charCodeAt(0), b.Keyboard.L = "L".charCodeAt(0), b.Keyboard.M = "M".charCodeAt(0), b.Keyboard.N = "N".charCodeAt(0), b.Keyboard.O = "O".charCodeAt(0), b.Keyboard.P = "P".charCodeAt(0), b.Keyboard.Q = "Q".charCodeAt(0), b.Keyboard.R = "R".charCodeAt(0), b.Keyboard.S = "S".charCodeAt(0), b.Keyboard.T = "T".charCodeAt(0), b.Keyboard.U = "U".charCodeAt(0), b.Keyboard.V = "V".charCodeAt(0), b.Keyboard.W = "W".charCodeAt(0), b.Keyboard.X = "X".charCodeAt(0), b.Keyboard.Y = "Y".charCodeAt(0), b.Keyboard.Z = "Z".charCodeAt(0), b.Keyboard.ZERO = "0".charCodeAt(0), b.Keyboard.ONE = "1".charCodeAt(0), b.Keyboard.TWO = "2".charCodeAt(0), b.Keyboard.THREE = "3".charCodeAt(0), b.Keyboard.FOUR = "4".charCodeAt(0), b.Keyboard.FIVE = "5".charCodeAt(0), b.Keyboard.SIX = "6".charCodeAt(0), b.Keyboard.SEVEN = "7".charCodeAt(0), b.Keyboard.EIGHT = "8".charCodeAt(0), b.Keyboard.NINE = "9".charCodeAt(0), b.Keyboard.NUMPAD_0 = 96, b.Keyboard.NUMPAD_1 = 97, b.Keyboard.NUMPAD_2 = 98, b.Keyboard.NUMPAD_3 = 99, b.Keyboard.NUMPAD_4 = 100, b.Keyboard.NUMPAD_5 = 101, b.Keyboard.NUMPAD_6 = 102, b.Keyboard.NUMPAD_7 = 103, b.Keyboard.NUMPAD_8 = 104, b.Keyboard.NUMPAD_9 = 105, b.Keyboard.NUMPAD_MULTIPLY = 106, b.Keyboard.NUMPAD_ADD = 107, b.Keyboard.NUMPAD_ENTER = 108, b.Keyboard.NUMPAD_SUBTRACT = 109, b.Keyboard.NUMPAD_DECIMAL = 110, b.Keyboard.NUMPAD_DIVIDE = 111, b.Keyboard.F1 = 112, b.Keyboard.F2 = 113, b.Keyboard.F3 = 114, b.Keyboard.F4 = 115, b.Keyboard.F5 = 116, b.Keyboard.F6 = 117, b.Keyboard.F7 = 118, b.Keyboard.F8 = 119, b.Keyboard.F9 = 120, b.Keyboard.F10 = 121, b.Keyboard.F11 = 122, b.Keyboard.F12 = 123, b.Keyboard.F13 = 124, b.Keyboard.F14 = 125, b.Keyboard.F15 = 126, b.Keyboard.COLON = 186, b.Keyboard.EQUALS = 187, b.Keyboard.UNDERSCORE = 189, b.Keyboard.QUESTION_MARK = 191, b.Keyboard.TILDE = 192, b.Keyboard.OPEN_BRACKET = 219, b.Keyboard.BACKWARD_SLASH = 220, b.Keyboard.CLOSED_BRACKET = 221, b.Keyboard.QUOTES = 222, b.Keyboard.BACKSPACE = 8, b.Keyboard.TAB = 9, b.Keyboard.CLEAR = 12, b.Keyboard.ENTER = 13, b.Keyboard.SHIFT = 16, b.Keyboard.CONTROL = 17, b.Keyboard.ALT = 18, b.Keyboard.CAPS_LOCK = 20, b.Keyboard.ESC = 27, b.Keyboard.SPACEBAR = 32, b.Keyboard.PAGE_UP = 33, b.Keyboard.PAGE_DOWN = 34, b.Keyboard.END = 35, b.Keyboard.HOME = 36, b.Keyboard.LEFT = 37, b.Keyboard.UP = 38, b.Keyboard.RIGHT = 39, b.Keyboard.DOWN = 40, b.Keyboard.INSERT = 45, b.Keyboard.DELETE = 46, b.Keyboard.HELP = 47, b.Keyboard.NUM_LOCK = 144, b.Mouse = function(a) {
  3147. this.game = a, this.callbackContext = this.game, this.mouseDownCallback = null, this.mouseMoveCallback = null, this.mouseUpCallback = null, this.mouseOutCallback = null, this.mouseOverCallback = null, this.mouseWheelCallback = null, this.capture = !1, this.button = -1, this.wheelDelta = 0, this.disabled = !1, this.locked = !1, this.stopOnGameOut = !1, this.pointerLock = new b.Signal, this.event = null, this._onMouseDown = null, this._onMouseMove = null, this._onMouseUp = null, this._onMouseOut = null, this._onMouseOver = null, this._onMouseWheel = null
  3148. }, b.Mouse.NO_BUTTON = -1, b.Mouse.LEFT_BUTTON = 0, b.Mouse.MIDDLE_BUTTON = 1, b.Mouse.RIGHT_BUTTON = 2, b.Mouse.WHEEL_UP = 1, b.Mouse.WHEEL_DOWN = -1, b.Mouse.prototype = {
  3149. start: function() {
  3150. if ((!this.game.device.android || this.game.device.chrome !== !1) && null === this._onMouseDown) {
  3151. var a = this;
  3152. this._onMouseDown = function(b) {
  3153. return a.onMouseDown(b)
  3154. }, this._onMouseMove = function(b) {
  3155. return a.onMouseMove(b)
  3156. }, this._onMouseUp = function(b) {
  3157. return a.onMouseUp(b)
  3158. }, this._onMouseOut = function(b) {
  3159. return a.onMouseOut(b)
  3160. }, this._onMouseOver = function(b) {
  3161. return a.onMouseOver(b)
  3162. }, this._onMouseWheel = function(b) {
  3163. return a.onMouseWheel(b)
  3164. }, this.game.canvas.addEventListener("mousedown", this._onMouseDown, !0), this.game.canvas.addEventListener("mousemove", this._onMouseMove, !0), this.game.canvas.addEventListener("mouseup", this._onMouseUp, !0), this.game.canvas.addEventListener("mousewheel", this._onMouseWheel, !0), this.game.canvas.addEventListener("DOMMouseScroll", this._onMouseWheel, !0), this.game.device.cocoonJS || (this.game.canvas.addEventListener("mouseover", this._onMouseOver, !0), this.game.canvas.addEventListener("mouseout", this._onMouseOut, !0))
  3165. }
  3166. },
  3167. onMouseDown: function(a) {
  3168. this.event = a, this.capture && a.preventDefault(), this.button = a.button, this.mouseDownCallback && this.mouseDownCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a["identifier"] = 0, this.game.input.mousePointer.start(a))
  3169. },
  3170. onMouseMove: function(a) {
  3171. this.event = a, this.capture && a.preventDefault(), this.mouseMoveCallback && this.mouseMoveCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a["identifier"] = 0, this.game.input.mousePointer.move(a))
  3172. },
  3173. onMouseUp: function(a) {
  3174. this.event = a, this.capture && a.preventDefault(), this.button = b.Mouse.NO_BUTTON, this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (a["identifier"] = 0, this.game.input.mousePointer.stop(a))
  3175. },
  3176. onMouseOut: function(a) {
  3177. this.event = a, this.capture && a.preventDefault(), this.mouseOutCallback && this.mouseOutCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (this.game.input.mousePointer.withinGame = !1, this.stopOnGameOut && (a["identifier"] = 0, this.game.input.mousePointer.stop(a)))
  3178. },
  3179. onMouseWheel: function(a) {
  3180. this.event = a, this.capture && a.preventDefault(), this.wheelDelta = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail)), this.mouseWheelCallback && this.mouseWheelCallback.call(this.callbackContext, a)
  3181. },
  3182. onMouseOver: function(a) {
  3183. this.event = a, this.capture && a.preventDefault(), this.mouseOverCallback && this.mouseOverCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || (this.game.input.mousePointer.withinGame = !0)
  3184. },
  3185. requestPointerLock: function() {
  3186. var a, b;
  3187. this.game.device.pointerLock && (a = this.game.canvas, a.requestPointerLock = a.requestPointerLock || a.mozRequestPointerLock || a.webkitRequestPointerLock, a.requestPointerLock(), b = this, this._pointerLockChange = function(a) {
  3188. return b.pointerLockChange(a)
  3189. }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0))
  3190. },
  3191. pointerLockChange: function(a) {
  3192. var b = this.game.canvas;
  3193. document.pointerLockElement === b || document.mozPointerLockElement === b || document.webkitPointerLockElement === b ? (this.locked = !0, this.pointerLock.dispatch(!0, a)) : (this.locked = !1, this.pointerLock.dispatch(!1, a))
  3194. },
  3195. releasePointerLock: function() {
  3196. document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock, document.exitPointerLock(), document.removeEventListener("pointerlockchange", this._pointerLockChange, !0), document.removeEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.removeEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
  3197. },
  3198. stop: function() {
  3199. this.game.canvas.removeEventListener("mousedown", this._onMouseDown, !0), this.game.canvas.removeEventListener("mousemove", this._onMouseMove, !0), this.game.canvas.removeEventListener("mouseup", this._onMouseUp, !0), this.game.canvas.removeEventListener("mouseover", this._onMouseOver, !0), this.game.canvas.removeEventListener("mouseout", this._onMouseOut, !0), this.game.canvas.removeEventListener("mousewheel", this._onMouseWheel, !0), this.game.canvas.removeEventListener("DOMMouseScroll", this._onMouseWheel, !0)
  3200. }
  3201. }, b.Mouse.prototype.constructor = b.Mouse, b.MSPointer = function(a) {
  3202. this.game = a, this.callbackContext = this.game, this.disabled = !1, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null
  3203. }, b.MSPointer.prototype = {
  3204. start: function() {
  3205. if (null === this._onMSPointerDown) {
  3206. var a = this;
  3207. this.game.device.mspointer === !0 && (this._onMSPointerDown = function(b) {
  3208. return a.onPointerDown(b)
  3209. }, this._onMSPointerMove = function(b) {
  3210. return a.onPointerMove(b)
  3211. }, this._onMSPointerUp = function(b) {
  3212. return a.onPointerUp(b)
  3213. }, this.game.renderer.view.addEventListener("MSPointerDown", this._onMSPointerDown, !1), this.game.renderer.view.addEventListener("MSPointerMove", this._onMSPointerMove, !1), this.game.renderer.view.addEventListener("MSPointerUp", this._onMSPointerUp, !1), this.game.renderer.view.addEventListener("pointerDown", this._onMSPointerDown, !1), this.game.renderer.view.addEventListener("pointerMove", this._onMSPointerMove, !1), this.game.renderer.view.addEventListener("pointerUp", this._onMSPointerUp, !1), this.game.renderer.view.style["-ms-content-zooming"] = "none", this.game.renderer.view.style["-ms-touch-action"] = "none")
  3214. }
  3215. },
  3216. onPointerDown: function(a) {
  3217. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.startPointer(a))
  3218. },
  3219. onPointerMove: function(a) {
  3220. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.updatePointer(a))
  3221. },
  3222. onPointerUp: function(a) {
  3223. this.game.input.disabled || this.disabled || (a.preventDefault(), a.identifier = a.pointerId, this.game.input.stopPointer(a))
  3224. },
  3225. stop: function() {
  3226. this.game.canvas.removeEventListener("MSPointerDown", this._onMSPointerDown), this.game.canvas.removeEventListener("MSPointerMove", this._onMSPointerMove), this.game.canvas.removeEventListener("MSPointerUp", this._onMSPointerUp), this.game.canvas.removeEventListener("pointerDown", this._onMSPointerDown), this.game.canvas.removeEventListener("pointerMove", this._onMSPointerMove), this.game.canvas.removeEventListener("pointerUp", this._onMSPointerUp)
  3227. }
  3228. }, b.MSPointer.prototype.constructor = b.MSPointer, b.Pointer = function(a, c) {
  3229. this.game = a, this.id = c, this.type = b.POINTER, this.exists = !0, this.identifier = 0, this.pointerId = null, this.target = null, this.button = null, this._holdSent = !1, this._history = [], this._nextDrop = 0, this._stateReset = !1, this.withinGame = !1, this.clientX = -1, this.clientY = -1, this.pageX = -1, this.pageY = -1, this.screenX = -1, this.screenY = -1, this.rawMovementX = 0, this.rawMovementY = 0, this.movementX = 0, this.movementY = 0, this.x = -1, this.y = -1, this.isMouse = !1, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.timeUp = 0, this.previousTapTime = 0, this.totalTouches = 0, this.msSinceLastClick = Number.MAX_VALUE, this.targetObject = null, this.active = !1, this.position = new b.Point, this.positionDown = new b.Point, this.positionUp = new b.Point, this.circle = new b.Circle(0, 0, 44), 0 === c && (this.isMouse = !0)
  3230. }, b.Pointer.prototype = {
  3231. start: function(a) {
  3232. return a["pointerId"] && (this.pointerId = a.pointerId), this.identifier = a.identifier, this.target = a.target, "undefined" != typeof a.button && (this.button = a.button), this._history = [], this.active = !0, this.withinGame = !0, this.isDown = !0, this.isUp = !1, this.msSinceLastClick = this.game.time.now - this.timeDown, this.timeDown = this.game.time.now, this._holdSent = !1, this.move(a, !0), this.positionDown.setTo(this.x, this.y), (this.game.input.multiInputOverride === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.x = this.x, this.game.input.y = this.y, this.game.input.position.setTo(this.x, this.y), this.game.input.onDown.dispatch(this, a), this.game.input.resetSpeed(this.x, this.y)), this._stateReset = !1, this.totalTouches++, this.isMouse || this.game.input.currentPointers++, null !== this.targetObject && this.targetObject._touchedHandler(this), this
  3233. },
  3234. update: function() {
  3235. this.active && (this._holdSent === !1 && this.duration >= this.game.input.holdRate && ((this.game.input.multiInputOverride == b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride == b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && this.game.input.onHold.dispatch(this), this._holdSent = !0), this.game.input.recordPointerHistory && this.game.time.now >= this._nextDrop && (this._nextDrop = this.game.time.now + this.game.input.recordRate, this._history.push({
  3236. x: this.position.x,
  3237. y: this.position.y
  3238. }), this._history.length > this.game.input.recordLimit && this._history.shift()))
  3239. },
  3240. move: function(a, c) {
  3241. if (!this.game.input.pollLocked) {
  3242. if ("undefined" == typeof c && (c = !1), "undefined" != typeof a.button && (this.button = a.button), this.clientX = a.clientX, this.clientY = a.clientY, this.pageX = a.pageX, this.pageY = a.pageY, this.screenX = a.screenX, this.screenY = a.screenY, this.isMouse && this.game.input.mouse.locked && !c && (this.rawMovementX = a.movementX || a.mozMovementX || a.webkitMovementX || 0, this.rawMovementY = a.movementY || a.mozMovementY || a.webkitMovementY || 0, this.movementX += this.rawMovementX, this.movementY += this.rawMovementY), this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x, this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y, this.position.setTo(this.x, this.y), this.circle.x = this.x, this.circle.y = this.y, (this.game.input.multiInputOverride === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.activePointer = this, this.game.input.x = this.x, this.game.input.y = this.y, this.game.input.position.setTo(this.game.input.x, this.game.input.y), this.game.input.circle.x = this.game.input.x, this.game.input.circle.y = this.game.input.y), this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY), this.game.paused) return this;
  3243. this.game.input.moveCallback && this.game.input.moveCallback.call(this.game.input.moveCallbackContext, this, this.x, this.y);
  3244. for (var d = this.game.input.moveCallbacks.length; d--;) this.game.input.moveCallbacks[d].callback.call(this.game.input.moveCallbacks[d].context, this, this.x, this.y);
  3245. return null !== this.targetObject && this.targetObject.isDragged === !0 ? (this.targetObject.update(this) === !1 && (this.targetObject = null), this) : (this.game.input.interactiveItems.total > 0 && this.processInteractiveObjects(c), this)
  3246. }
  3247. },
  3248. processInteractiveObjects: function(a) {
  3249. var b;
  3250. this.game.input.interactiveItems.setAll("checked", !1), this._highestRenderOrderID = Number.MAX_SAFE_INTEGER, this._highestRenderObject = null, this._highestInputPriorityID = -1, b = this.game.input.interactiveItems.first;
  3251. do b && b.validForInput(this._highestInputPriorityID, this._highestRenderOrderID, !1) && (b.checked = !0, (a && b.checkPointerDown(this, !0) || !a && b.checkPointerOver(this, !0)) && (this._highestRenderOrderID = b.sprite._cache[3], this._highestInputPriorityID = b.priorityID, this._highestRenderObject = b)), b = this.game.input.interactiveItems.next; while (null !== b);
  3252. b = this.game.input.interactiveItems.first;
  3253. do b && !b.checked && b.validForInput(this._highestInputPriorityID, this._highestRenderOrderID, !0) && (a && b.checkPointerDown(this, !1) || !a && b.checkPointerOver(this, !1)) && (this._highestRenderOrderID = b.sprite._cache[3], this._highestInputPriorityID = b.priorityID, this._highestRenderObject = b), b = this.game.input.interactiveItems.next; while (null !== b);
  3254. null === this._highestRenderObject ? this.targetObject && (this.targetObject._pointerOutHandler(this), this.targetObject = null) : null === this.targetObject ? (this.targetObject = this._highestRenderObject, this._highestRenderObject._pointerOverHandler(this)) : this.targetObject === this._highestRenderObject ? this._highestRenderObject.update(this) === !1 && (this.targetObject = null) : (this.targetObject._pointerOutHandler(this), this.targetObject = this._highestRenderObject, this.targetObject._pointerOverHandler(this))
  3255. },
  3256. leave: function(a) {
  3257. this.withinGame = !1, this.move(a, !1)
  3258. },
  3259. stop: function(a) {
  3260. return this._stateReset ? (a.preventDefault(), void 0) : (this.timeUp = this.game.time.now, (this.game.input.multiInputOverride === b.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === b.Input.MOUSE_TOUCH_COMBINE || this.game.input.multiInputOverride === b.Input.TOUCH_OVERRIDES_MOUSE && 0 === this.game.input.currentPointers) && (this.game.input.onUp.dispatch(this, a), this.duration >= 0 && this.duration <= this.game.input.tapRate && (this.timeUp - this.previousTapTime < this.game.input.doubleTapRate ? this.game.input.onTap.dispatch(this, !0) : this.game.input.onTap.dispatch(this, !1), this.previousTapTime = this.timeUp)), this.id > 0 && (this.active = !1), this.withinGame = !1, this.isDown = !1, this.isUp = !0, this.pointerId = null, this.identifier = null, this.positionUp.setTo(this.x, this.y), this.isMouse === !1 && this.game.input.currentPointers--, this.game.input.interactiveItems.callAll("_releasedHandler", this), this.targetObject = null, this)
  3261. },
  3262. justPressed: function(a) {
  3263. return a = a || this.game.input.justPressedRate, this.isDown === !0 && this.timeDown + a > this.game.time.now
  3264. },
  3265. justReleased: function(a) {
  3266. return a = a || this.game.input.justReleasedRate, this.isUp === !0 && this.timeUp + a > this.game.time.now
  3267. },
  3268. reset: function() {
  3269. this.isMouse === !1 && (this.active = !1), this.pointerId = null, this.identifier = null, this.isDown = !1, this.isUp = !0, this.totalTouches = 0, this._holdSent = !1, this._history.length = 0, this._stateReset = !0, this.targetObject && this.targetObject._releasedHandler(this), this.targetObject = null
  3270. },
  3271. resetMovement: function() {
  3272. this.movementX = 0, this.movementY = 0
  3273. }
  3274. }, b.Pointer.prototype.constructor = b.Pointer, Object.defineProperty(b.Pointer.prototype, "duration", {
  3275. get: function() {
  3276. return this.isUp ? -1 : this.game.time.now - this.timeDown
  3277. }
  3278. }), Object.defineProperty(b.Pointer.prototype, "worldX", {
  3279. get: function() {
  3280. return this.game.world.camera.x + this.x
  3281. }
  3282. }), Object.defineProperty(b.Pointer.prototype, "worldY", {
  3283. get: function() {
  3284. return this.game.world.camera.y + this.y
  3285. }
  3286. }), b.Touch = function(a) {
  3287. this.game = a, this.disabled = !1, this.callbackContext = this.game, this.touchStartCallback = null, this.touchMoveCallback = null, this.touchEndCallback = null, this.touchEnterCallback = null, this.touchLeaveCallback = null, this.touchCancelCallback = null, this.preventDefault = !0, this.event = null, this._onTouchStart = null, this._onTouchMove = null, this._onTouchEnd = null, this._onTouchEnter = null, this._onTouchLeave = null, this._onTouchCancel = null, this._onTouchMove = null
  3288. }, b.Touch.prototype = {
  3289. start: function() {
  3290. if (null === this._onTouchStart) {
  3291. var a = this;
  3292. this.game.device.touch && (this._onTouchStart = function(b) {
  3293. return a.onTouchStart(b)
  3294. }, this._onTouchMove = function(b) {
  3295. return a.onTouchMove(b)
  3296. }, this._onTouchEnd = function(b) {
  3297. return a.onTouchEnd(b)
  3298. }, this._onTouchEnter = function(b) {
  3299. return a.onTouchEnter(b)
  3300. }, this._onTouchLeave = function(b) {
  3301. return a.onTouchLeave(b)
  3302. }, this._onTouchCancel = function(b) {
  3303. return a.onTouchCancel(b)
  3304. }, this.game.canvas.addEventListener("touchstart", this._onTouchStart, !1), this.game.canvas.addEventListener("touchmove", this._onTouchMove, !1), this.game.canvas.addEventListener("touchend", this._onTouchEnd, !1), this.game.canvas.addEventListener("touchcancel", this._onTouchCancel, !1), this.game.device.cocoonJS || (this.game.canvas.addEventListener("touchenter", this._onTouchEnter, !1), this.game.canvas.addEventListener("touchleave", this._onTouchLeave, !1)))
  3305. }
  3306. },
  3307. consumeDocumentTouches: function() {
  3308. this._documentTouchMove = function(a) {
  3309. a.preventDefault()
  3310. }, document.addEventListener("touchmove", this._documentTouchMove, !1)
  3311. },
  3312. onTouchStart: function(a) {
  3313. if (this.event = a, this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  3314. this.preventDefault && a.preventDefault();
  3315. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.startPointer(a.changedTouches[b])
  3316. }
  3317. },
  3318. onTouchCancel: function(a) {
  3319. if (this.event = a, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, a), !this.game.input.disabled && !this.disabled) {
  3320. this.preventDefault && a.preventDefault();
  3321. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  3322. }
  3323. },
  3324. onTouchEnter: function(a) {
  3325. this.event = a, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, a), this.game.input.disabled || this.disabled || this.preventDefault && a.preventDefault()
  3326. },
  3327. onTouchLeave: function(a) {
  3328. this.event = a, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault()
  3329. },
  3330. onTouchMove: function(a) {
  3331. this.event = a, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  3332. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.updatePointer(a.changedTouches[b])
  3333. },
  3334. onTouchEnd: function(a) {
  3335. this.event = a, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, a), this.preventDefault && a.preventDefault();
  3336. for (var b = 0; b < a.changedTouches.length; b++) this.game.input.stopPointer(a.changedTouches[b])
  3337. },
  3338. stop: function() {
  3339. this.game.device.touch && (this.game.canvas.removeEventListener("touchstart", this._onTouchStart), this.game.canvas.removeEventListener("touchmove", this._onTouchMove), this.game.canvas.removeEventListener("touchend", this._onTouchEnd), this.game.canvas.removeEventListener("touchenter", this._onTouchEnter), this.game.canvas.removeEventListener("touchleave", this._onTouchLeave), this.game.canvas.removeEventListener("touchcancel", this._onTouchCancel))
  3340. }
  3341. }, b.Touch.prototype.constructor = b.Touch, b.Gamepad = function(a) {
  3342. this.game = a, this._gamepads = [new b.SinglePad(a, this), new b.SinglePad(a, this), new b.SinglePad(a, this), new b.SinglePad(a, this)], this._gamepadIndexMap = {}, this._rawPads = [], this._active = !1, this.disabled = !1, this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || -1 != navigator.userAgent.indexOf("Firefox/") || !!navigator.getGamepads, this._prevRawGamepadTypes = [], this._prevTimestamps = [], this.callbackContext = this, this.onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null, this._ongamepadconnected = null, this._gamepaddisconnected = null
  3343. }, b.Gamepad.prototype = {
  3344. addCallbacks: function(a, b) {
  3345. "undefined" != typeof b && (this.onConnectCallback = "function" == typeof b.onConnect ? b.onConnect : this.onConnectCallback, this.onDisconnectCallback = "function" == typeof b.onDisconnect ? b.onDisconnect : this.onDisconnectCallback, this.onDownCallback = "function" == typeof b.onDown ? b.onDown : this.onDownCallback, this.onUpCallback = "function" == typeof b.onUp ? b.onUp : this.onUpCallback, this.onAxisCallback = "function" == typeof b.onAxis ? b.onAxis : this.onAxisCallback, this.onFloatCallback = "function" == typeof b.onFloat ? b.onFloat : this.onFloatCallback)
  3346. },
  3347. start: function() {
  3348. if (!this._active) {
  3349. this._active = !0;
  3350. var a = this;
  3351. this._ongamepadconnected = function(b) {
  3352. var c = b.gamepad;
  3353. a._rawPads.push(c), a._gamepads[c.index].connect(c)
  3354. }, window.addEventListener("gamepadconnected", this._ongamepadconnected, !1), this._ongamepaddisconnected = function(b) {
  3355. var d, c = b.gamepad;
  3356. for (d in a._rawPads) a._rawPads[d].index === c.index && a._rawPads.splice(d, 1);
  3357. a._gamepads[c.index].disconnect()
  3358. }, window.addEventListener("gamepaddisconnected", this._ongamepaddisconnected, !1)
  3359. }
  3360. },
  3361. update: function() {
  3362. this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus()
  3363. },
  3364. _pollGamepads: function() {
  3365. var a, b, c, d, e, f, g, h, i, j;
  3366. if (navigator["getGamepads"] ? a = navigator.getGamepads() : navigator["webkitGetGamepads"] ? a = navigator.webkitGetGamepads() : navigator["webkitGamepads"] && (a = navigator.webkitGamepads()), a) {
  3367. for (this._rawPads = [], b = !1, c = 0; c < a.length && (typeof a[c] !== this._prevRawGamepadTypes[c] && (b = !0, this._prevRawGamepadTypes[c] = typeof a[c]), a[c] && this._rawPads.push(a[c]), 3 !== c); c++);
  3368. if (b) {
  3369. for (d = {
  3370. rawIndices: {},
  3371. padIndices: {}
  3372. }, f = 0; f < this._gamepads.length; f++)
  3373. if (e = this._gamepads[f], e.connected)
  3374. for (g = 0; g < this._rawPads.length; g++) this._rawPads[g].index === e.index && (d.rawIndices[e.index] = !0, d.padIndices[f] = !0);
  3375. for (h = 0; h < this._gamepads.length; h++)
  3376. if (e = this._gamepads[h], !d.padIndices[h])
  3377. for (this._rawPads.length < 1 && e.disconnect(), i = 0; i < this._rawPads.length && !d.padIndices[h]; i++)
  3378. if (j = this._rawPads[i]) {
  3379. if (d.rawIndices[j.index]) {
  3380. e.disconnect();
  3381. continue
  3382. }
  3383. e.connect(j), d.rawIndices[j.index] = !0, d.padIndices[h] = !0
  3384. } else e.disconnect()
  3385. }
  3386. }
  3387. },
  3388. setDeadZones: function(a) {
  3389. for (var b = 0; b < this._gamepads.length; b++) this._gamepads[b].deadZone = a
  3390. },
  3391. stop: function() {
  3392. this._active = !1, window.removeEventListener("gamepadconnected", this._ongamepadconnected), window.removeEventListener("gamepaddisconnected", this._ongamepaddisconnected)
  3393. },
  3394. reset: function() {
  3395. this.update();
  3396. for (var a = 0; a < this._gamepads.length; a++) this._gamepads[a].reset()
  3397. },
  3398. justPressed: function(a, b) {
  3399. for (var c = 0; c < this._gamepads.length; c++)
  3400. if (this._gamepads[c].justPressed(a, b) === !0) return !0;
  3401. return !1
  3402. },
  3403. justReleased: function(a, b) {
  3404. for (var c = 0; c < this._gamepads.length; c++)
  3405. if (this._gamepads[c].justReleased(a, b) === !0) return !0;
  3406. return !1
  3407. },
  3408. isDown: function(a) {
  3409. for (var b = 0; b < this._gamepads.length; b++)
  3410. if (this._gamepads[b].isDown(a) === !0) return !0;
  3411. return !1
  3412. }
  3413. }, b.Gamepad.prototype.constructor = b.Gamepad, Object.defineProperty(b.Gamepad.prototype, "active", {
  3414. get: function() {
  3415. return this._active
  3416. }
  3417. }), Object.defineProperty(b.Gamepad.prototype, "supported", {
  3418. get: function() {
  3419. return this._gamepadSupportAvailable
  3420. }
  3421. }), Object.defineProperty(b.Gamepad.prototype, "padsConnected", {
  3422. get: function() {
  3423. return this._rawPads.length
  3424. }
  3425. }), Object.defineProperty(b.Gamepad.prototype, "pad1", {
  3426. get: function() {
  3427. return this._gamepads[0]
  3428. }
  3429. }), Object.defineProperty(b.Gamepad.prototype, "pad2", {
  3430. get: function() {
  3431. return this._gamepads[1]
  3432. }
  3433. }), Object.defineProperty(b.Gamepad.prototype, "pad3", {
  3434. get: function() {
  3435. return this._gamepads[2]
  3436. }
  3437. }), Object.defineProperty(b.Gamepad.prototype, "pad4", {
  3438. get: function() {
  3439. return this._gamepads[3]
  3440. }
  3441. }), b.Gamepad.BUTTON_0 = 0, b.Gamepad.BUTTON_1 = 1, b.Gamepad.BUTTON_2 = 2, b.Gamepad.BUTTON_3 = 3, b.Gamepad.BUTTON_4 = 4, b.Gamepad.BUTTON_5 = 5, b.Gamepad.BUTTON_6 = 6, b.Gamepad.BUTTON_7 = 7, b.Gamepad.BUTTON_8 = 8, b.Gamepad.BUTTON_9 = 9, b.Gamepad.BUTTON_10 = 10, b.Gamepad.BUTTON_11 = 11, b.Gamepad.BUTTON_12 = 12, b.Gamepad.BUTTON_13 = 13, b.Gamepad.BUTTON_14 = 14, b.Gamepad.BUTTON_15 = 15, b.Gamepad.AXIS_0 = 0, b.Gamepad.AXIS_1 = 1, b.Gamepad.AXIS_2 = 2, b.Gamepad.AXIS_3 = 3, b.Gamepad.AXIS_4 = 4, b.Gamepad.AXIS_5 = 5, b.Gamepad.AXIS_6 = 6, b.Gamepad.AXIS_7 = 7, b.Gamepad.AXIS_8 = 8, b.Gamepad.AXIS_9 = 9, b.Gamepad.XBOX360_A = 0, b.Gamepad.XBOX360_B = 1, b.Gamepad.XBOX360_X = 2, b.Gamepad.XBOX360_Y = 3, b.Gamepad.XBOX360_LEFT_BUMPER = 4, b.Gamepad.XBOX360_RIGHT_BUMPER = 5, b.Gamepad.XBOX360_LEFT_TRIGGER = 6, b.Gamepad.XBOX360_RIGHT_TRIGGER = 7, b.Gamepad.XBOX360_BACK = 8, b.Gamepad.XBOX360_START = 9, b.Gamepad.XBOX360_STICK_LEFT_BUTTON = 10, b.Gamepad.XBOX360_STICK_RIGHT_BUTTON = 11, b.Gamepad.XBOX360_DPAD_LEFT = 14, b.Gamepad.XBOX360_DPAD_RIGHT = 15, b.Gamepad.XBOX360_DPAD_UP = 12, b.Gamepad.XBOX360_DPAD_DOWN = 13, b.Gamepad.XBOX360_STICK_LEFT_X = 0, b.Gamepad.XBOX360_STICK_LEFT_Y = 1, b.Gamepad.XBOX360_STICK_RIGHT_X = 2, b.Gamepad.XBOX360_STICK_RIGHT_Y = 3, b.Gamepad.PS3XC_X = 0, b.Gamepad.PS3XC_CIRCLE = 1, b.Gamepad.PS3XC_SQUARE = 2, b.Gamepad.PS3XC_TRIANGLE = 3, b.Gamepad.PS3XC_L1 = 4, b.Gamepad.PS3XC_R1 = 5, b.Gamepad.PS3XC_L2 = 6, b.Gamepad.PS3XC_R2 = 7, b.Gamepad.PS3XC_SELECT = 8, b.Gamepad.PS3XC_START = 9, b.Gamepad.PS3XC_STICK_LEFT_BUTTON = 10, b.Gamepad.PS3XC_STICK_RIGHT_BUTTON = 11, b.Gamepad.PS3XC_DPAD_UP = 12, b.Gamepad.PS3XC_DPAD_DOWN = 13, b.Gamepad.PS3XC_DPAD_LEFT = 14, b.Gamepad.PS3XC_DPAD_RIGHT = 15, b.Gamepad.PS3XC_STICK_LEFT_X = 0, b.Gamepad.PS3XC_STICK_LEFT_Y = 1, b.Gamepad.PS3XC_STICK_RIGHT_X = 2, b.Gamepad.PS3XC_STICK_RIGHT_Y = 3, b.SinglePad = function(a, b) {
  3442. this.game = a, this.index = null, this.connected = !1, this.callbackContext = this, this.onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null, this.deadZone = .26, this._padParent = b, this._rawPad = null, this._prevTimestamp = null, this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0
  3443. }, b.SinglePad.prototype = {
  3444. addCallbacks: function(a, b) {
  3445. "undefined" != typeof b && (this.onConnectCallback = "function" == typeof b.onConnect ? b.onConnect : this.onConnectCallback, this.onDisconnectCallback = "function" == typeof b.onDisconnect ? b.onDisconnect : this.onDisconnectCallback, this.onDownCallback = "function" == typeof b.onDown ? b.onDown : this.onDownCallback, this.onUpCallback = "function" == typeof b.onUp ? b.onUp : this.onUpCallback, this.onAxisCallback = "function" == typeof b.onAxis ? b.onAxis : this.onAxisCallback, this.onFloatCallback = "function" == typeof b.onFloat ? b.onFloat : this.onFloatCallback)
  3446. },
  3447. addButton: function(a) {
  3448. return this.getButton(a)
  3449. },
  3450. getButton: function(a) {
  3451. return this._buttons[a] ? this._buttons[a] : null
  3452. },
  3453. pollStatus: function() {
  3454. var a, b, c, d;
  3455. if (!(!this.connected || this.game.input.disabled || this.game.input.gamepad.disabled || this._rawPad.timestamp && this._rawPad.timestamp === this._prevTimestamp)) {
  3456. for (a = 0; a < this._buttonsLen; a++) b = isNaN(this._rawPad.buttons[a]) ? this._rawPad.buttons[a].value : this._rawPad.buttons[a], b !== this._buttons[a].value && (1 === b ? this.processButtonDown(a, b) : 0 === b ? this.processButtonUp(a, b) : this.processButtonFloat(a, b));
  3457. for (c = 0; c < this._axesLen; c++) d = this._rawPad.axes[c], d > 0 && d > this.deadZone || 0 > d && d < -this.deadZone ? this.processAxisChange({
  3458. axis: c,
  3459. value: d
  3460. }) : this.processAxisChange({
  3461. axis: c,
  3462. value: 0
  3463. });
  3464. this._prevTimestamp = this._rawPad.timestamp
  3465. }
  3466. },
  3467. connect: function(a) {
  3468. var d, c = !this.connected;
  3469. this.connected = !0, this.index = a.index, this._rawPad = a, this._buttons = [], this._buttonsLen = a.buttons.length, this._axes = a.axes, this._axesLen = a.axes.length;
  3470. for (d in a.buttons) d = parseInt(d, 10), this._buttons[d] = new b.GamepadButton(this, d);
  3471. c && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), c && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
  3472. },
  3473. disconnect: function() {
  3474. var c, a = this.connected,
  3475. b = this.index;
  3476. for (this.connected = !1, this.index = null, this._rawPad = void 0, c = 0; c < this._buttonsLen; c++) this._buttons[c].destroy();
  3477. this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0, a && this._padParent.onDisconnectCallback && this._padParent.onDisconnectCallback.call(this._padParent.callbackContext, b), a && this.onDisconnectCallback && this.onDisconnectCallback.call(this.callbackContext)
  3478. },
  3479. processAxisChange: function(a) {
  3480. this._axes[a.axis] !== a.value && (this._axes[a.axis] = a.value, this._padParent.onAxisCallback && this._padParent.onAxisCallback.call(this._padParent.callbackContext, a, this.index), this.onAxisCallback && this.onAxisCallback.call(this.callbackContext, a))
  3481. },
  3482. processButtonDown: function(a, b) {
  3483. this._padParent.onDownCallback && this._padParent.onDownCallback.call(this._padParent.callbackContext, a, b, this.index), this.onDownCallback && this.onDownCallback.call(this.callbackContext, a, b), this._buttons[a] && this._buttons[a].processButtonDown(b)
  3484. },
  3485. processButtonUp: function(a, b) {
  3486. this._padParent.onUpCallback && this._padParent.onUpCallback.call(this._padParent.callbackContext, a, b, this.index), this.onUpCallback && this.onUpCallback.call(this.callbackContext, a, b), this._buttons[a] && this._buttons[a].processButtonUp(b)
  3487. },
  3488. processButtonFloat: function(a, b) {
  3489. this._padParent.onFloatCallback && this._padParent.onFloatCallback.call(this._padParent.callbackContext, a, b, this.index), this.onFloatCallback && this.onFloatCallback.call(this.callbackContext, a, b), this._buttons[a] && this._buttons[a].processButtonFloat(b)
  3490. },
  3491. axis: function(a) {
  3492. return this._axes[a] ? this._axes[a] : !1
  3493. },
  3494. isDown: function(a) {
  3495. return this._buttons[a] ? this._buttons[a].isDown : !1
  3496. },
  3497. isUp: function(a) {
  3498. return this._buttons[a] ? this._buttons[a].isUp : !1
  3499. },
  3500. justReleased: function(a, b) {
  3501. return this._buttons[a] ? this._buttons[a].justReleased(b) : void 0
  3502. },
  3503. justPressed: function(a, b) {
  3504. return this._buttons[a] ? this._buttons[a].justPressed(b) : void 0
  3505. },
  3506. buttonValue: function(a) {
  3507. return this._buttons[a] ? this._buttons[a].value : null
  3508. },
  3509. reset: function() {
  3510. for (var a = 0; a < this._axes.length; a++) this._axes[a] = 0
  3511. }
  3512. }, b.SinglePad.prototype.constructor = b.SinglePad, b.GamepadButton = function(a, c) {
  3513. this.pad = a, this.game = a.game, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.duration = 0, this.timeUp = 0, this.repeats = 0, this.value = 0, this.buttonCode = c, this.onDown = new b.Signal, this.onUp = new b.Signal, this.onFloat = new b.Signal
  3514. }, b.GamepadButton.prototype = {
  3515. processButtonDown: function(a) {
  3516. this.isDown ? (this.duration = this.game.time.now - this.timeDown, this.repeats++) : (this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0, this.value = a, this.onDown.dispatch(this, a))
  3517. },
  3518. processButtonUp: function(a) {
  3519. this.isDown && (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.now, this.value = a, this.onUp.dispatch(this, a))
  3520. },
  3521. processButtonFloat: function(a) {
  3522. this.value = a, this.onFloat.dispatch(this, a)
  3523. },
  3524. justPressed: function(a) {
  3525. return "undefined" == typeof a && (a = 250), this.isDown && this.duration < a
  3526. },
  3527. justReleased: function(a) {
  3528. return "undefined" == typeof a && (a = 250), this.isDown === !1 && this.game.time.now - this.timeUp < a
  3529. },
  3530. reset: function() {
  3531. this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.now, this.duration = 0, this.repeats = 0
  3532. },
  3533. destroy: function() {
  3534. this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.pad = null, this.game = null
  3535. }
  3536. }, b.GamepadButton.prototype.constructor = b.GamepadButton, b.InputHandler = function(a) {
  3537. this.sprite = a, this.game = a.game, this.enabled = !1, this.checked = !1, this.priorityID = 0, this.useHandCursor = !1, this._setHandCursor = !1, this.isDragged = !1, this.allowHorizontalDrag = !0, this.allowVerticalDrag = !0, this.bringToTop = !1, this.snapOffset = null, this.snapOnDrag = !1, this.snapOnRelease = !1, this.snapX = 0, this.snapY = 0, this.snapOffsetX = 0, this.snapOffsetY = 0, this.pixelPerfectOver = !1, this.pixelPerfectClick = !1, this.pixelPerfectAlpha = 255, this.draggable = !1, this.boundsRect = null, this.boundsSprite = null, this.consumePointerEvent = !1, this._dragPhase = !1, this._wasEnabled = !1, this._tempPoint = new b.Point, this._pointerData = [], this._pointerData.push({
  3538. id: 0,
  3539. x: 0,
  3540. y: 0,
  3541. isDown: !1,
  3542. isUp: !1,
  3543. isOver: !1,
  3544. isOut: !1,
  3545. timeOver: 0,
  3546. timeOut: 0,
  3547. timeDown: 0,
  3548. timeUp: 0,
  3549. downDuration: 0,
  3550. isDragged: !1
  3551. })
  3552. }, b.InputHandler.prototype = {
  3553. start: function(a, c) {
  3554. if (a = a || 0, "undefined" == typeof c && (c = !1), this.enabled === !1) {
  3555. this.game.input.interactiveItems.add(this), this.useHandCursor = c, this.priorityID = a;
  3556. for (var d = 0; 10 > d; d++) this._pointerData[d] = {
  3557. id: d,
  3558. x: 0,
  3559. y: 0,
  3560. isDown: !1,
  3561. isUp: !1,
  3562. isOver: !1,
  3563. isOut: !1,
  3564. timeOver: 0,
  3565. timeOut: 0,
  3566. timeDown: 0,
  3567. timeUp: 0,
  3568. downDuration: 0,
  3569. isDragged: !1
  3570. };
  3571. this.snapOffset = new b.Point, this.enabled = !0, this._wasEnabled = !0, this.sprite.events && null === this.sprite.events.onInputOver && (this.sprite.events.onInputOver = new b.Signal, this.sprite.events.onInputOut = new b.Signal, this.sprite.events.onInputDown = new b.Signal, this.sprite.events.onInputUp = new b.Signal, this.sprite.events.onDragStart = new b.Signal, this.sprite.events.onDragStop = new b.Signal)
  3572. }
  3573. return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.flagged = !1, this.sprite
  3574. },
  3575. addedToGroup: function() {
  3576. this._dragPhase || this._wasEnabled && !this.enabled && this.start()
  3577. },
  3578. removedFromGroup: function() {
  3579. this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1)
  3580. },
  3581. reset: function() {
  3582. this.enabled = !1, this.flagged = !1;
  3583. for (var a = 0; 10 > a; a++) this._pointerData[a] = {
  3584. id: a,
  3585. x: 0,
  3586. y: 0,
  3587. isDown: !1,
  3588. isUp: !1,
  3589. isOver: !1,
  3590. isOut: !1,
  3591. timeOver: 0,
  3592. timeOut: 0,
  3593. timeDown: 0,
  3594. timeUp: 0,
  3595. downDuration: 0,
  3596. isDragged: !1
  3597. }
  3598. },
  3599. stop: function() {
  3600. this.enabled !== !1 && (this.enabled = !1, this.game.input.interactiveItems.remove(this))
  3601. },
  3602. destroy: function() {
  3603. this.sprite && (this._setHandCursor && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), this.enabled = !1, this.game.input.interactiveItems.remove(this), this._pointerData.length = 0, this.boundsRect = null, this.boundsSprite = null, this.sprite = null)
  3604. },
  3605. validForInput: function(a, b, c) {
  3606. return "undefined" == typeof c && (c = !0), 0 === this.sprite.scale.x || 0 === this.sprite.scale.y || this.priorityID < this.game.input.minPriorityID ? !1 : c || !this.pixelPerfectClick && !this.pixelPerfectOver ? this.priorityID > a || this.priorityID === a && this.sprite._cache[3] < b ? !0 : !1 : !1
  3607. },
  3608. isPixelPerfect: function() {
  3609. return this.pixelPerfectClick || this.pixelPerfectOver
  3610. },
  3611. pointerX: function(a) {
  3612. return a = a || 0, this._pointerData[a].x
  3613. },
  3614. pointerY: function(a) {
  3615. return a = a || 0, this._pointerData[a].y
  3616. },
  3617. pointerDown: function(a) {
  3618. return a = a || 0, this._pointerData[a].isDown
  3619. },
  3620. pointerUp: function(a) {
  3621. return a = a || 0, this._pointerData[a].isUp
  3622. },
  3623. pointerTimeDown: function(a) {
  3624. return a = a || 0, this._pointerData[a].timeDown
  3625. },
  3626. pointerTimeUp: function(a) {
  3627. return a = a || 0, this._pointerData[a].timeUp
  3628. },
  3629. pointerOver: function(a) {
  3630. if (this.enabled) {
  3631. if ("undefined" != typeof a) return this._pointerData[a].isOver;
  3632. for (var b = 0; 10 > b; b++)
  3633. if (this._pointerData[b].isOver) return !0
  3634. }
  3635. return !1
  3636. },
  3637. pointerOut: function(a) {
  3638. if (this.enabled) {
  3639. if ("undefined" != typeof a) return this._pointerData[a].isOut;
  3640. for (var b = 0; 10 > b; b++)
  3641. if (this._pointerData[b].isOut) return !0
  3642. }
  3643. return !1
  3644. },
  3645. pointerTimeOver: function(a) {
  3646. return a = a || 0, this._pointerData[a].timeOver
  3647. },
  3648. pointerTimeOut: function(a) {
  3649. return a = a || 0, this._pointerData[a].timeOut
  3650. },
  3651. pointerDragged: function(a) {
  3652. return a = a || 0, this._pointerData[a].isDragged
  3653. },
  3654. checkPointerDown: function(a, b) {
  3655. return a.isDown && this.enabled && this.sprite && this.sprite.parent && this.sprite.visible && this.sprite.parent.visible ? this.game.input.hitTest(this.sprite, a, this._tempPoint) ? ("undefined" == typeof b && (b = !1), !b && this.pixelPerfectClick ? this.checkPixel(this._tempPoint.x, this._tempPoint.y) : !0) : !1 : !1
  3656. },
  3657. checkPointerOver: function(a, b) {
  3658. return this.enabled && this.sprite && this.sprite.parent && this.sprite.visible && this.sprite.parent.visible ? this.game.input.hitTest(this.sprite, a, this._tempPoint) ? ("undefined" == typeof b && (b = !1), !b && this.pixelPerfectOver ? this.checkPixel(this._tempPoint.x, this._tempPoint.y) : !0) : !1 : !1
  3659. },
  3660. checkPixel: function(a, b, c) {
  3661. var d;
  3662. return this.sprite.texture.baseTexture.source && (this.game.input.hitContext.clearRect(0, 0, 1, 1), null === a && null === b && (this.game.input.getLocalPosition(this.sprite, c, this._tempPoint), a = this._tempPoint.x, b = this._tempPoint.y), 0 !== this.sprite.anchor.x && (a -= -this.sprite.texture.frame.width * this.sprite.anchor.x), 0 !== this.sprite.anchor.y && (b -= -this.sprite.texture.frame.height * this.sprite.anchor.y), a += this.sprite.texture.frame.x, b += this.sprite.texture.frame.y, this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, a, b, 1, 1, 0, 0, 1, 1), d = this.game.input.hitContext.getImageData(0, 0, 1, 1), d.data[3] >= this.pixelPerfectAlpha) ? !0 : !1
  3663. },
  3664. update: function(a) {
  3665. return null !== this.sprite && void 0 !== this.sprite.parent ? this.enabled && this.sprite.visible && this.sprite.parent.visible ? this.draggable && this._draggedPointerID == a.id ? this.updateDrag(a) : this._pointerData[a.id].isOver === !0 ? this.checkPointerOver(a) ? (this._pointerData[a.id].x = a.x - this.sprite.x, this._pointerData[a.id].y = a.y - this.sprite.y, !0) : (this._pointerOutHandler(a), !1) : void 0 : (this._pointerOutHandler(a), !1) : void 0
  3666. },
  3667. _pointerOverHandler: function(a) {
  3668. null !== this.sprite && this._pointerData[a.id].isOver === !1 && (this._pointerData[a.id].isOver = !0, this._pointerData[a.id].isOut = !1, this._pointerData[a.id].timeOver = this.game.time.now, this._pointerData[a.id].x = a.x - this.sprite.x, this._pointerData[a.id].y = a.y - this.sprite.y, this.useHandCursor && this._pointerData[a.id].isDragged === !1 && (this.game.canvas.style.cursor = "pointer", this._setHandCursor = !0), this.sprite && this.sprite.events && this.sprite.events.onInputOver.dispatch(this.sprite, a))
  3669. },
  3670. _pointerOutHandler: function(a) {
  3671. null !== this.sprite && (this._pointerData[a.id].isOver = !1, this._pointerData[a.id].isOut = !0, this._pointerData[a.id].timeOut = this.game.time.now, this.useHandCursor && this._pointerData[a.id].isDragged === !1 && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), this.sprite && this.sprite.events && this.sprite.events.onInputOut.dispatch(this.sprite, a))
  3672. },
  3673. _touchedHandler: function(a) {
  3674. if (null !== this.sprite) {
  3675. if (this._pointerData[a.id].isDown === !1 && this._pointerData[a.id].isOver === !0) {
  3676. if (this.pixelPerfectClick && !this.checkPixel(null, null, a)) return;
  3677. this._pointerData[a.id].isDown = !0, this._pointerData[a.id].isUp = !1, this._pointerData[a.id].timeDown = this.game.time.now, this.sprite && this.sprite.events && this.sprite.events.onInputDown.dispatch(this.sprite, a), this.draggable && this.isDragged === !1 && this.startDrag(a), this.bringToTop && this.sprite.bringToTop()
  3678. }
  3679. return this.consumePointerEvent
  3680. }
  3681. },
  3682. _releasedHandler: function(a) {
  3683. null !== this.sprite && this._pointerData[a.id].isDown && a.isUp && (this._pointerData[a.id].isDown = !1, this._pointerData[a.id].isUp = !0, this._pointerData[a.id].timeUp = this.game.time.now, this._pointerData[a.id].downDuration = this._pointerData[a.id].timeUp - this._pointerData[a.id].timeDown, this.checkPointerOver(a) ? this.sprite && this.sprite.events && this.sprite.events.onInputUp.dispatch(this.sprite, a, !0) : (this.sprite && this.sprite.events && this.sprite.events.onInputUp.dispatch(this.sprite, a, !1), this.useHandCursor && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1)), this.draggable && this.isDragged && this._draggedPointerID === a.id && this.stopDrag(a))
  3684. },
  3685. updateDrag: function(a) {
  3686. return a.isUp ? (this.stopDrag(a), !1) : (this.sprite.fixedToCamera ? (this.allowHorizontalDrag && (this.sprite.cameraOffset.x = a.x + this._dragPoint.x + this.dragOffset.x), this.allowVerticalDrag && (this.sprite.cameraOffset.y = a.y + this._dragPoint.y + this.dragOffset.y), this.boundsRect && this.checkBoundsRect(), this.boundsSprite && this.checkBoundsSprite(), this.snapOnDrag && (this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY)) : (this.allowHorizontalDrag && (this.sprite.x = a.x + this._dragPoint.x + this.dragOffset.x), this.allowVerticalDrag && (this.sprite.y = a.y + this._dragPoint.y + this.dragOffset.y), this.boundsRect && this.checkBoundsRect(), this.boundsSprite && this.checkBoundsSprite(), this.snapOnDrag && (this.sprite.x = Math.round((this.sprite.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.y = Math.round((this.sprite.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY)), !0)
  3687. },
  3688. justOver: function(a, b) {
  3689. return a = a || 0, b = b || 500, this._pointerData[a].isOver && this.overDuration(a) < b
  3690. },
  3691. justOut: function(a, b) {
  3692. return a = a || 0, b = b || 500, this._pointerData[a].isOut && this.game.time.now - this._pointerData[a].timeOut < b
  3693. },
  3694. justPressed: function(a, b) {
  3695. return a = a || 0, b = b || 500, this._pointerData[a].isDown && this.downDuration(a) < b
  3696. },
  3697. justReleased: function(a, b) {
  3698. return a = a || 0, b = b || 500, this._pointerData[a].isUp && this.game.time.now - this._pointerData[a].timeUp < b
  3699. },
  3700. overDuration: function(a) {
  3701. return a = a || 0, this._pointerData[a].isOver ? this.game.time.now - this._pointerData[a].timeOver : -1
  3702. },
  3703. downDuration: function(a) {
  3704. return a = a || 0, this._pointerData[a].isDown ? this.game.time.now - this._pointerData[a].timeDown : -1
  3705. },
  3706. enableDrag: function(a, c, d, e, f, g) {
  3707. "undefined" == typeof a && (a = !1), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = null), "undefined" == typeof g && (g = null), this._dragPoint = new b.Point, this.draggable = !0, this.bringToTop = c, this.dragOffset = new b.Point, this.dragFromCenter = a, this.pixelPerfectClick = d, this.pixelPerfectAlpha = e, f && (this.boundsRect = f), g && (this.boundsSprite = g)
  3708. },
  3709. disableDrag: function() {
  3710. if (this._pointerData)
  3711. for (var a = 0; 10 > a; a++) this._pointerData[a].isDragged = !1;
  3712. this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1
  3713. },
  3714. startDrag: function(a) {
  3715. if (this.isDragged = !0, this._draggedPointerID = a.id, this._pointerData[a.id].isDragged = !0, this.sprite.fixedToCamera) this.dragFromCenter ? (this.sprite.centerOn(a.x, a.y), this._dragPoint.setTo(this.sprite.cameraOffset.x - a.x, this.sprite.cameraOffset.y - a.y)) : this._dragPoint.setTo(this.sprite.cameraOffset.x - a.x, this.sprite.cameraOffset.y - a.y);
  3716. else if (this.dragFromCenter) {
  3717. var b = this.sprite.getBounds();
  3718. this.sprite.x = a.x + (this.sprite.x - b.centerX), this.sprite.y = a.y + (this.sprite.y - b.centerY), this._dragPoint.setTo(this.sprite.x - a.x, this.sprite.y - a.y)
  3719. } else this._dragPoint.setTo(this.sprite.x - a.x, this.sprite.y - a.y);
  3720. this.updateDrag(a), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.sprite.events.onDragStart.dispatch(this.sprite, a)
  3721. },
  3722. stopDrag: function(a) {
  3723. this.isDragged = !1, this._draggedPointerID = -1, this._pointerData[a.id].isDragged = !1, this._dragPhase = !1, this.snapOnRelease && (this.sprite.fixedToCamera ? (this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY) : (this.sprite.x = Math.round((this.sprite.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.y = Math.round((this.sprite.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY)), this.sprite.events.onDragStop.dispatch(this.sprite, a), this.checkPointerOver(a) === !1 && this._pointerOutHandler(a)
  3724. },
  3725. setDragLock: function(a, b) {
  3726. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0), this.allowHorizontalDrag = a, this.allowVerticalDrag = b
  3727. },
  3728. enableSnap: function(a, b, c, d, e, f) {
  3729. "undefined" == typeof c && (c = !0), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = 0), this.snapX = a, this.snapY = b, this.snapOffsetX = e, this.snapOffsetY = f, this.snapOnDrag = c, this.snapOnRelease = d
  3730. },
  3731. disableSnap: function() {
  3732. this.snapOnDrag = !1, this.snapOnRelease = !1
  3733. },
  3734. checkBoundsRect: function() {
  3735. this.sprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsRect.left ? this.sprite.cameraOffset.x = this.boundsRect.cameraOffset.x : this.sprite.cameraOffset.x + this.sprite.width > this.boundsRect.right && (this.sprite.cameraOffset.x = this.boundsRect.right - this.sprite.width), this.sprite.cameraOffset.y < this.boundsRect.top ? this.sprite.cameraOffset.y = this.boundsRect.top : this.sprite.cameraOffset.y + this.sprite.height > this.boundsRect.bottom && (this.sprite.cameraOffset.y = this.boundsRect.bottom - this.sprite.height)) : (this.sprite.x < this.boundsRect.left ? this.sprite.x = this.boundsRect.x : this.sprite.x + this.sprite.width > this.boundsRect.right && (this.sprite.x = this.boundsRect.right - this.sprite.width), this.sprite.y < this.boundsRect.top ? this.sprite.y = this.boundsRect.top : this.sprite.y + this.sprite.height > this.boundsRect.bottom && (this.sprite.y = this.boundsRect.bottom - this.sprite.height))
  3736. },
  3737. checkBoundsSprite: function() {
  3738. this.sprite.fixedToCamera && this.boundsSprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsSprite.camerOffset.x ? this.sprite.cameraOffset.x = this.boundsSprite.camerOffset.x : this.sprite.cameraOffset.x + this.sprite.width > this.boundsSprite.camerOffset.x + this.boundsSprite.width && (this.sprite.cameraOffset.x = this.boundsSprite.camerOffset.x + this.boundsSprite.width - this.sprite.width), this.sprite.cameraOffset.y < this.boundsSprite.camerOffset.y ? this.sprite.cameraOffset.y = this.boundsSprite.camerOffset.y : this.sprite.cameraOffset.y + this.sprite.height > this.boundsSprite.camerOffset.y + this.boundsSprite.height && (this.sprite.cameraOffset.y = this.boundsSprite.camerOffset.y + this.boundsSprite.height - this.sprite.height)) : (this.sprite.x < this.boundsSprite.x ? this.sprite.x = this.boundsSprite.x : this.sprite.x + this.sprite.width > this.boundsSprite.x + this.boundsSprite.width && (this.sprite.x = this.boundsSprite.x + this.boundsSprite.width - this.sprite.width), this.sprite.y < this.boundsSprite.y ? this.sprite.y = this.boundsSprite.y : this.sprite.y + this.sprite.height > this.boundsSprite.y + this.boundsSprite.height && (this.sprite.y = this.boundsSprite.y + this.boundsSprite.height - this.sprite.height))
  3739. }
  3740. }, b.InputHandler.prototype.constructor = b.InputHandler, b.Events = function(a) {
  3741. this.parent = a, this.onAddedToGroup = new b.Signal, this.onRemovedFromGroup = new b.Signal, this.onKilled = new b.Signal, this.onRevived = new b.Signal, this.onOutOfBounds = new b.Signal, this.onEnterBounds = new b.Signal, this.onInputOver = null, this.onInputOut = null, this.onInputDown = null, this.onInputUp = null, this.onDragStart = null, this.onDragStop = null, this.onAnimationStart = null, this.onAnimationComplete = null, this.onAnimationLoop = null
  3742. }, b.Events.prototype = {
  3743. destroy: function() {
  3744. this.parent = null, this.onAddedToGroup.dispose(), this.onRemovedFromGroup.dispose(), this.onKilled.dispose(), this.onRevived.dispose(), this.onOutOfBounds.dispose(), this.onInputOver && (this.onInputOver.dispose(), this.onInputOut.dispose(), this.onInputDown.dispose(), this.onInputUp.dispose(), this.onDragStart.dispose(), this.onDragStop.dispose()), this.onAnimationStart && (this.onAnimationStart.dispose(), this.onAnimationComplete.dispose(), this.onAnimationLoop.dispose())
  3745. }
  3746. }, b.Events.prototype.constructor = b.Events, b.GameObjectFactory = function(a) {
  3747. this.game = a, this.world = this.game.world
  3748. }, b.GameObjectFactory.prototype = {
  3749. existing: function(a) {
  3750. return this.world.add(a)
  3751. },
  3752. image: function(a, c, d, e, f) {
  3753. return "undefined" == typeof f && (f = this.world), f.add(new b.Image(this.game, a, c, d, e))
  3754. },
  3755. sprite: function(a, b, c, d, e) {
  3756. return "undefined" == typeof e && (e = this.world), e.create(a, b, c, d)
  3757. },
  3758. tween: function(a) {
  3759. return this.game.tweens.create(a)
  3760. },
  3761. group: function(a, c, d, e, f) {
  3762. return new b.Group(this.game, a, c, d, e, f)
  3763. },
  3764. physicsGroup: function(a, c, d, e) {
  3765. return new b.Group(this.game, c, d, e, !0, a)
  3766. },
  3767. spriteBatch: function(a, c, d) {
  3768. return "undefined" == typeof a && (a = null), "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  3769. },
  3770. audio: function(a, b, c, d) {
  3771. return this.game.sound.add(a, b, c, d)
  3772. },
  3773. sound: function(a, b, c, d) {
  3774. return this.game.sound.add(a, b, c, d)
  3775. },
  3776. tileSprite: function(a, c, d, e, f, g, h) {
  3777. return "undefined" == typeof h && (h = this.world), h.add(new b.TileSprite(this.game, a, c, d, e, f, g))
  3778. },
  3779. text: function(a, c, d, e, f) {
  3780. return "undefined" == typeof f && (f = this.world), f.add(new b.Text(this.game, a, c, d, e))
  3781. },
  3782. button: function(a, c, d, e, f, g, h, i, j, k) {
  3783. return "undefined" == typeof k && (k = this.world), k.add(new b.Button(this.game, a, c, d, e, f, g, h, i, j))
  3784. },
  3785. graphics: function(a, c, d) {
  3786. return "undefined" == typeof d && (d = this.world), d.add(new b.Graphics(this.game, a, c))
  3787. },
  3788. emitter: function(a, c, d) {
  3789. return this.game.particles.add(new b.Particles.Arcade.Emitter(this.game, a, c, d))
  3790. },
  3791. retroFont: function(a, c, d, e, f, g, h, i, j) {
  3792. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  3793. },
  3794. bitmapText: function(a, c, d, e, f, g) {
  3795. return "undefined" == typeof g && (g = this.world), g.add(new b.BitmapText(this.game, a, c, d, e, f))
  3796. },
  3797. tilemap: function(a, c, d, e, f) {
  3798. return new b.Tilemap(this.game, a, c, d, e, f)
  3799. },
  3800. renderTexture: function(a, c, d, e) {
  3801. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  3802. var f = new b.RenderTexture(this.game, a, c, d);
  3803. return e && this.game.cache.addRenderTexture(d, f), f
  3804. },
  3805. bitmapData: function(a, c, d, e) {
  3806. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  3807. var f = new b.BitmapData(this.game, d, a, c);
  3808. return e && this.game.cache.addBitmapData(d, f), f
  3809. },
  3810. filter: function(a) {
  3811. var c = Array.prototype.splice.call(arguments, 1);
  3812. return a = new b.Filter[a](this.game), a.init.apply(a, c), a
  3813. },
  3814. plugin: function(a) {
  3815. return this.game.plugins.add(a)
  3816. }
  3817. }, b.GameObjectFactory.prototype.constructor = b.GameObjectFactory, b.GameObjectCreator = function(a) {
  3818. this.game = a, this.world = this.game.world
  3819. }, b.GameObjectCreator.prototype = {
  3820. image: function(a, c, d, e) {
  3821. return new b.Image(this.game, a, c, d, e)
  3822. },
  3823. sprite: function(a, c, d, e) {
  3824. return new b.Sprite(this.game, a, c, d, e)
  3825. },
  3826. tween: function(a) {
  3827. return new b.Tween(a, this.game)
  3828. },
  3829. group: function(a, c, d, e, f) {
  3830. return new b.Group(this.game, null, c, d, e, f)
  3831. },
  3832. spriteBatch: function(a, c, d) {
  3833. return "undefined" == typeof c && (c = "group"), "undefined" == typeof d && (d = !1), new b.SpriteBatch(this.game, a, c, d)
  3834. },
  3835. audio: function(a, b, c, d) {
  3836. return this.game.sound.add(a, b, c, d)
  3837. },
  3838. sound: function(a, b, c, d) {
  3839. return this.game.sound.add(a, b, c, d)
  3840. },
  3841. tileSprite: function(a, c, d, e, f, g) {
  3842. return new b.TileSprite(this.game, a, c, d, e, f, g)
  3843. },
  3844. text: function(a, c, d, e) {
  3845. return new b.Text(this.game, a, c, d, e)
  3846. },
  3847. button: function(a, c, d, e, f, g, h, i, j) {
  3848. return new b.Button(this.game, a, c, d, e, f, g, h, i, j)
  3849. },
  3850. graphics: function(a, c) {
  3851. return new b.Graphics(this.game, a, c)
  3852. },
  3853. emitter: function(a, c, d) {
  3854. return new b.Particles.Arcade.Emitter(this.game, a, c, d)
  3855. },
  3856. retroFont: function(a, c, d, e, f, g, h, i, j) {
  3857. return new b.RetroFont(this.game, a, c, d, e, f, g, h, i, j)
  3858. },
  3859. bitmapText: function(a, c, d, e, f) {
  3860. return new b.BitmapText(this.game, a, c, d, e, f)
  3861. },
  3862. tilemap: function(a, c, d, e, f) {
  3863. return new b.Tilemap(this.game, a, c, d, e, f)
  3864. },
  3865. renderTexture: function(a, c, d, e) {
  3866. ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid()), "undefined" == typeof e && (e = !1);
  3867. var f = new b.RenderTexture(this.game, a, c, d);
  3868. return e && this.game.cache.addRenderTexture(d, f), f
  3869. },
  3870. bitmapData: function(a, c, d, e) {
  3871. "undefined" == typeof e && (e = !1), ("undefined" == typeof d || "" === d) && (d = this.game.rnd.uuid());
  3872. var f = new b.BitmapData(this.game, d, a, c);
  3873. return e && this.game.cache.addBitmapData(d, f), f
  3874. },
  3875. filter: function(a) {
  3876. var c = Array.prototype.splice.call(arguments, 1);
  3877. return a = new b.Filter[a](this.game), a.init.apply(a, c), a
  3878. }
  3879. }, b.GameObjectCreator.prototype.constructor = b.GameObjectCreator, b.BitmapData = function(a, c, d, e) {
  3880. "undefined" == typeof d && (d = 100), "undefined" == typeof e && (e = 100), this.game = a, this.key = c, this.width = d, this.height = e, this.canvas = b.Canvas.create(d, e, "", !0), this.context = this.canvas.getContext("2d"), this.ctx = this.context, this.imageData = this.context.getImageData(0, 0, d, e), this.data = this.imageData.data, this.pixels = null, this.imageData.data.buffer ? (this.buffer = this.imageData.data.buffer, this.pixels = new Uint32Array(this.buffer)) : window["ArrayBuffer"] ? (this.buffer = new ArrayBuffer(this.imageData.data.length), this.pixels = new Uint32Array(this.buffer)) : this.pixels = this.imageData.data, this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new b.Frame(0, 0, 0, d, e, "bitmapData", a.rnd.uuid()), this.texture.frame = this.textureFrame, this.type = b.BITMAPDATA, this.disableTextureUpload = !1, this.dirty = !1, this.cls = this.clear, this.update = this.refreshBuffer, this._tempR = 0, this._tempG = 0, this._tempB = 0
  3881. }, b.BitmapData.prototype = {
  3882. add: function(a) {
  3883. if (Array.isArray(a))
  3884. for (var b = 0; b < a.length; b++) a[b]["loadTexture"] && a[b].loadTexture(this);
  3885. else a.loadTexture(this)
  3886. },
  3887. load: function(a) {
  3888. "string" == typeof a && (a = this.game.cache.getImage(a)), this.resize(a.width, a.height), this.cls(), a instanceof b.Image || a instanceof b.Sprite ? this.drawSprite(a, 0, 0) : this.draw(a, 0, 0), this.update()
  3889. },
  3890. clear: function() {
  3891. this.context.clearRect(0, 0, this.width, this.height), this.dirty = !0
  3892. },
  3893. fill: function(a, b, c, d) {
  3894. "undefined" == typeof d && (d = 1), this.context.fillStyle = "rgba(" + a + "," + b + "," + c + "," + d + ")", this.context.fillRect(0, 0, this.width, this.height), this.dirty = !0
  3895. },
  3896. resize: function(a, b) {
  3897. (a !== this.width || b !== this.height) && (this.width = a, this.height = b, this.canvas.width = a, this.canvas.height = b, this.baseTexture.width = a, this.baseTexture.height = b, this.textureFrame.width = a, this.textureFrame.height = b, this.texture.width = a, this.texture.height = b, this.texture.crop.width = a, this.texture.crop.height = b, this.refreshBuffer(), this.dirty = !0)
  3898. },
  3899. refreshBuffer: function(a, b, c, d) {
  3900. "undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.width), "undefined" == typeof d && (d = this.height), this.imageData = this.context.getImageData(a, b, c, d), this.data = this.imageData.data, this.imageData.data.buffer ? (this.buffer = this.imageData.data.buffer, this.pixels = new Uint32Array(this.buffer)) : window["ArrayBuffer"] ? (this.buffer = new ArrayBuffer(this.imageData.data.length), this.pixels = new Uint32Array(this.buffer)) : this.pixels = this.imageData.data
  3901. },
  3902. processPixelRGB: function(a, c, d, e, f, g) {
  3903. var h, i, j, k, l, m, n;
  3904. for ("undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = this.width), "undefined" == typeof g && (g = this.height), h = d + f, i = e + g, j = b.Color.createColor(), k = {
  3905. r: 0,
  3906. g: 0,
  3907. b: 0,
  3908. a: 0
  3909. }, l = !1, m = e; i > m; m++)
  3910. for (n = d; h > n; n++) b.Color.unpackPixel(this.getPixel32(n, m), j), k = a.call(c, j, n, m), k !== !1 && null !== k && void 0 !== k && (this.setPixel32(n, m, k.r, k.g, k.b, k.a, !1), l = !0);
  3911. l && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)
  3912. },
  3913. processPixel: function(a, b, c, d, e, f) {
  3914. var g, h, i, j, k, l, m;
  3915. for ("undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = this.width), "undefined" == typeof f && (f = this.height), g = c + e, h = d + f, i = 0, j = 0, k = !1, l = d; h > l; l++)
  3916. for (m = c; g > m; m++) i = this.getPixel32(m, l), j = a.call(b, i, m, l), j !== i && (this.pixels[l * this.width + m] = j, k = !0);
  3917. k && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)
  3918. },
  3919. replaceRGB: function(a, c, d, e, f, g, h, i, j) {
  3920. var p, q, k = 0,
  3921. l = 0,
  3922. m = this.width,
  3923. n = this.height,
  3924. o = b.Color.packPixel(a, c, d, e);
  3925. for (void 0 !== j && j instanceof b.Rectangle && (k = j.x, l = j.y, m = j.width, n = j.height), p = 0; n > p; p++)
  3926. for (q = 0; m > q; q++) this.getPixel32(k + q, l + p) === o && this.setPixel32(k + q, l + p, f, g, h, i, !1);
  3927. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  3928. },
  3929. setHSL: function(a, c, d, e) {
  3930. var f, g, h;
  3931. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof c || null === c) && (c = !1), ("undefined" == typeof d || null === d) && (d = !1), a || c || d) {
  3932. for ("undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height)), f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  3933. for (h = e.x; h < e.right; h++) b.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = a), c && (f.s = c), d && (f.l = d), b.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  3934. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  3935. }
  3936. },
  3937. shiftHSL: function(a, c, d, e) {
  3938. var f, g, h;
  3939. if (("undefined" == typeof a || null === a) && (a = !1), ("undefined" == typeof c || null === c) && (c = !1), ("undefined" == typeof d || null === d) && (d = !1), a || c || d) {
  3940. for ("undefined" == typeof e && (e = new b.Rectangle(0, 0, this.width, this.height)), f = b.Color.createColor(), g = e.y; g < e.bottom; g++)
  3941. for (h = e.x; h < e.right; h++) b.Color.unpackPixel(this.getPixel32(h, g), f, !0), a && (f.h = this.game.math.wrap(f.h + a, 0, 1)), c && (f.s = this.game.math.limitValue(f.s + c, 0, 1)), d && (f.l = this.game.math.limitValue(f.l + d, 0, 1)), b.Color.HSLtoRGB(f.h, f.s, f.l, f), this.setPixel32(h, g, f.r, f.g, f.b, f.a, !1);
  3942. this.context.putImageData(this.imageData, 0, 0), this.dirty = !0
  3943. }
  3944. },
  3945. setPixel32: function(a, c, d, e, f, g, h) {
  3946. "undefined" == typeof h && (h = !0), a >= 0 && a <= this.width && c >= 0 && c <= this.height && (this.pixels[c * this.width + a] = b.Device.LITTLE_ENDIAN ? g << 24 | f << 16 | e << 8 | d : d << 24 | e << 16 | f << 8 | g, h && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0))
  3947. },
  3948. setPixel: function(a, b, c, d, e, f) {
  3949. this.setPixel32(a, b, c, d, e, 255, f)
  3950. },
  3951. getPixel: function(a, c, d) {
  3952. d || (d = b.Color.createColor());
  3953. var e = ~~(a + c * this.width);
  3954. return e *= 4, d.r = this.data[e], d.g = this.data[++e], d.b = this.data[++e], d.a = this.data[++e], d
  3955. },
  3956. getPixel32: function(a, b) {
  3957. return a >= 0 && a <= this.width && b >= 0 && b <= this.height ? this.pixels[b * this.width + a] : void 0
  3958. },
  3959. getPixelRGB: function(a, c, d, e, f) {
  3960. return b.Color.unpackPixel(this.getPixel32(a, c), d, e, f)
  3961. },
  3962. getPixels: function(a) {
  3963. return this.context.getImageData(a.x, a.y, a.width, a.height)
  3964. },
  3965. addToWorld: function(a, b) {
  3966. return this.game.add.image(a, b, this)
  3967. },
  3968. copyPixels: function(a, c, d, e) {
  3969. var f, g, h, i;
  3970. "string" == typeof a && (a = this.game.cache.getImage(a)), f = a, g = 0, h = 0, a instanceof b.Image || a instanceof b.Sprite ? (f = a.texture.baseTexture.source, i = a.texture.frame, g = i.x, h = i.y) : a instanceof b.BitmapData && (f = a.canvas), this.context.drawImage(f, g + c.x, h + c.y, c.width, c.height, d, e, c.width, c.height), this.dirty = !0
  3971. },
  3972. draw: function(a, c, d, e, f) {
  3973. var g, h, i, j, k, l;
  3974. "undefined" == typeof c && (c = 0), "undefined" == typeof d && (d = 0), "string" == typeof a && (a = this.game.cache.getImage(a)), g = a, h = 0, i = 0, j = 0, k = 0, a instanceof b.Image || a instanceof b.Sprite ? (g = a.texture.baseTexture.source, l = a.texture.frame, h = l.x, i = l.y, j = l.width, k = l.height) : (a instanceof b.BitmapData && (g = a.canvas), j = a.width, k = a.height), "undefined" == typeof e && (e = j), "undefined" == typeof f && (f = k), this.context.drawImage(g, h, i, j, k, c, d, e, f), this.dirty = !0
  3975. },
  3976. drawSprite: function(a, b, c) {
  3977. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), this.draw(a, b, c)
  3978. },
  3979. alphaMask: function(a, b, c, d) {
  3980. ("undefined" == typeof b || null === b) && (b = this);
  3981. var e = this.context.globalCompositeOperation;
  3982. "undefined" == typeof d || null === d ? this.draw(b) : this.draw(b, d.x, d.y, d.width, d.height), this.context.globalCompositeOperation = "source-atop", "undefined" == typeof c || null === c ? this.draw(a) : this.draw(a, c.x, c.y, c.width, c.height), this.context.globalCompositeOperation = e, this.update(), this.dirty = !0
  3983. },
  3984. extract: function(a, b, c, d, e, f, g, h, i) {
  3985. return "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = !1), "undefined" == typeof g && (g = b), "undefined" == typeof h && (h = c), "undefined" == typeof i && (i = d), f && a.resize(this.width, this.height), this.processPixelRGB(function(f, j, k) {
  3986. return f.r === b && f.g === c && f.b === d && a.setPixel32(j, k, g, h, i, e, !1), !1
  3987. }, this), a.context.putImageData(a.imageData, 0, 0), a.dirty = !0, a
  3988. },
  3989. rect: function(a, b, c, d, e) {
  3990. "undefined" != typeof e && (this.context.fillStyle = e), this.context.fillRect(a, b, c, d)
  3991. },
  3992. circle: function(a, b, c, d) {
  3993. "undefined" != typeof d && (this.context.fillStyle = d), this.context.beginPath(), this.context.arc(a, b, c, 0, 2 * Math.PI, !1), this.context.closePath(), this.context.fill()
  3994. },
  3995. render: function() {
  3996. !this.disableTextureUpload && this.game.renderType === b.WEBGL && this.dirty && (PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl), this.dirty = !1)
  3997. }
  3998. }, b.BitmapData.prototype.constructor = b.BitmapData, b.Sprite = function(a, c, d, e, f) {
  3999. c = c || 0, d = d || 0, e = e || null, f = f || null, this.game = a, this.name = "", this.type = b.SPRITE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = e, PIXI.Sprite.call(this, PIXI.TextureCache["__default"]), this.position.set(c, d), this.world = new b.Point(c, d), this.autoCull = !1, this.input = null, this.body = null, this.alive = !0, this.health = 1, this.lifespan = 0, this.checkWorldBounds = !1, this.outOfBoundsKill = !1, this.debug = !1, this.cameraOffset = new b.Point, this.cropRect = null, this._cache = [0, 0, 0, 0, 1, 0, 1, 0], this._crop = null, this._frame = null, this._bounds = new b.Rectangle, this.loadTexture(e, f)
  4000. }, b.Sprite.prototype = Object.create(PIXI.Sprite.prototype), b.Sprite.prototype.constructor = b.Sprite, b.Sprite.prototype.preUpdate = function() {
  4001. if (1 === this._cache[4] && this.exists) return this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.body && this.body.preUpdate(), this._cache[4] = 0, !1;
  4002. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  4003. if (this.lifespan > 0 && (this.lifespan -= this.game.time.elapsed, this.lifespan <= 0)) return this.kill(), !1;
  4004. if ((this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds)
  4005. if (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds)) this._cache[5] = 0, this.events.onEnterBounds.dispatch(this);
  4006. else if (0 === this._cache[5] && !this.game.world.bounds.intersects(this._bounds) && (this._cache[5] = 1, this.events.onOutOfBounds.dispatch(this), this.outOfBoundsKill)) return this.kill(), !1;
  4007. this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), this.animations.update(), this.body && this.body.preUpdate();
  4008. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4009. return !0
  4010. }, b.Sprite.prototype.update = function() {}, b.Sprite.prototype.postUpdate = function() {
  4011. this.key instanceof b.BitmapData && this.key.render(), this.exists && this.body && this.body.postUpdate(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  4012. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  4013. }, b.Sprite.prototype.loadTexture = function(a, c, d) {
  4014. var e, f;
  4015. c = c || 0, (d || "undefined" == typeof d) && this.animations.stop(), this.key = a, e = !0, f = this.smoothed, a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? this.setTexture(a.texture) : a instanceof PIXI.Texture ? this.setTexture(a) : null === a || "undefined" == typeof a ? (this.key = "__default", this.setTexture(PIXI.TextureCache[this.key])) : "string" != typeof a || this.game.cache.checkImageKey(a) ? (this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])), e = !this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key])), e && (this._frame = b.Rectangle.clone(this.texture.frame)), f || (this.smoothed = !1)
  4016. }, b.Sprite.prototype.setFrame = function(a) {
  4017. this._frame = a, this.texture.frame.x = a.x, this.texture.frame.y = a.y, this.texture.frame.width = a.width, this.texture.frame.height = a.height, this.texture.crop.x = a.x, this.texture.crop.y = a.y, this.texture.crop.width = a.width, this.texture.crop.height = a.height, a.trimmed && (this.texture.trim ? (this.texture.trim.x = a.spriteSourceSizeX, this.texture.trim.y = a.spriteSourceSizeY, this.texture.trim.width = a.sourceSizeW, this.texture.trim.height = a.sourceSizeH) : this.texture.trim = {
  4018. x: a.spriteSourceSizeX,
  4019. y: a.spriteSourceSizeY,
  4020. width: a.sourceSizeW,
  4021. height: a.sourceSizeH
  4022. }, this.texture.width = a.sourceSizeW, this.texture.height = a.sourceSizeH, this.texture.frame.width = a.sourceSizeW, this.texture.frame.height = a.sourceSizeH), this.cropRect ? this.updateCrop() : this.game.renderType === b.WEBGL && PIXI.WebGLRenderer.updateTextureFrame(this.texture)
  4023. }, b.Sprite.prototype.resetFrame = function() {
  4024. this._frame && this.setFrame(this._frame)
  4025. }, b.Sprite.prototype.crop = function(a, c) {
  4026. "undefined" == typeof c && (c = !1), a ? (c && null !== this.cropRect ? this.cropRect.setTo(a.x, a.y, a.width, a.height) : this.cropRect = c && null === this.cropRect ? new b.Rectangle(a.x, a.y, a.width, a.height) : a, this.updateCrop()) : (this._crop = null, this.cropRect = null, this.resetFrame())
  4027. }, b.Sprite.prototype.updateCrop = function() {
  4028. var a, c, d, e;
  4029. this.cropRect && (this._crop = b.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y, a = Math.max(this._frame.x, this._crop.x), c = Math.max(this._frame.y, this._crop.y), d = Math.min(this._frame.right, this._crop.right) - a, e = Math.min(this._frame.bottom, this._crop.bottom) - c, this.texture.crop.x = a, this.texture.crop.y = c, this.texture.crop.width = d, this.texture.crop.height = e, this.texture.frame.width = Math.min(d, this.cropRect.width), this.texture.frame.height = Math.min(e, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.game.renderType === b.WEBGL && PIXI.WebGLRenderer.updateTextureFrame(this.texture))
  4030. }, b.Sprite.prototype.revive = function(a) {
  4031. return "undefined" == typeof a && (a = 1), this.alive = !0, this.exists = !0, this.visible = !0, this.health = a, this.events && this.events.onRevived.dispatch(this), this
  4032. }, b.Sprite.prototype.kill = function() {
  4033. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  4034. }, b.Sprite.prototype.destroy = function(a) {
  4035. if (null !== this.game && 1 !== this._cache[8]) {
  4036. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.input && this.input.destroy(), this.animations && this.animations.destroy(), this.body && this.body.destroy(), this.events && this.events.destroy();
  4037. var c = this.children.length;
  4038. if (a)
  4039. for (; c--;) this.children[c].destroy(a);
  4040. else
  4041. for (; c--;) this.removeChild(this.children[c]);
  4042. this._crop && (this._crop = null), this._frame && (this._frame = null), this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4043. }
  4044. }, b.Sprite.prototype.damage = function(a) {
  4045. return this.alive && (this.health -= a, this.health <= 0 && this.kill()), this
  4046. }, b.Sprite.prototype.reset = function(a, b, c) {
  4047. return "undefined" == typeof c && (c = 1), this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.health = c, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this
  4048. }, b.Sprite.prototype.bringToTop = function() {
  4049. return this.parent && this.parent.bringToTop(this), this
  4050. }, b.Sprite.prototype.play = function(a, b, c, d) {
  4051. return this.animations ? this.animations.play(a, b, c, d) : void 0
  4052. }, b.Sprite.prototype.overlap = function(a) {
  4053. return b.Rectangle.intersects(this.getBounds(), a.getBounds())
  4054. }, Object.defineProperty(b.Sprite.prototype, "angle", {
  4055. get: function() {
  4056. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  4057. },
  4058. set: function(a) {
  4059. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  4060. }
  4061. }), Object.defineProperty(b.Sprite.prototype, "deltaX", {
  4062. get: function() {
  4063. return this.world.x - this._cache[0]
  4064. }
  4065. }), Object.defineProperty(b.Sprite.prototype, "deltaY", {
  4066. get: function() {
  4067. return this.world.y - this._cache[1]
  4068. }
  4069. }), Object.defineProperty(b.Sprite.prototype, "deltaZ", {
  4070. get: function() {
  4071. return this.rotation - this._cache[2]
  4072. }
  4073. }), Object.defineProperty(b.Sprite.prototype, "inWorld", {
  4074. get: function() {
  4075. return this.game.world.bounds.intersects(this.getBounds())
  4076. }
  4077. }), Object.defineProperty(b.Sprite.prototype, "inCamera", {
  4078. get: function() {
  4079. return this.game.world.camera.screenView.intersects(this.getBounds())
  4080. }
  4081. }), Object.defineProperty(b.Sprite.prototype, "frame", {
  4082. get: function() {
  4083. return this.animations.frame
  4084. },
  4085. set: function(a) {
  4086. this.animations.frame = a
  4087. }
  4088. }), Object.defineProperty(b.Sprite.prototype, "frameName", {
  4089. get: function() {
  4090. return this.animations.frameName
  4091. },
  4092. set: function(a) {
  4093. this.animations.frameName = a
  4094. }
  4095. }), Object.defineProperty(b.Sprite.prototype, "renderOrderID", {
  4096. get: function() {
  4097. return this._cache[3]
  4098. }
  4099. }), Object.defineProperty(b.Sprite.prototype, "inputEnabled", {
  4100. get: function() {
  4101. return this.input && this.input.enabled
  4102. },
  4103. set: function(a) {
  4104. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  4105. }
  4106. }), Object.defineProperty(b.Sprite.prototype, "exists", {
  4107. get: function() {
  4108. return !!this._cache[6]
  4109. },
  4110. set: function(a) {
  4111. a ? (this._cache[6] = 1, this.body && this.body.type === b.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._cache[6] = 0, this.body && this.body.type === b.Physics.P2JS && this.body.removeFromWorld(), this.visible = !1)
  4112. }
  4113. }), Object.defineProperty(b.Sprite.prototype, "fixedToCamera", {
  4114. get: function() {
  4115. return !!this._cache[7]
  4116. },
  4117. set: function(a) {
  4118. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4119. }
  4120. }), Object.defineProperty(b.Sprite.prototype, "smoothed", {
  4121. get: function() {
  4122. return !this.texture.baseTexture.scaleMode
  4123. },
  4124. set: function(a) {
  4125. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  4126. }
  4127. }), Object.defineProperty(b.Sprite.prototype, "x", {
  4128. get: function() {
  4129. return this.position.x
  4130. },
  4131. set: function(a) {
  4132. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4133. }
  4134. }), Object.defineProperty(b.Sprite.prototype, "y", {
  4135. get: function() {
  4136. return this.position.y
  4137. },
  4138. set: function(a) {
  4139. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4140. }
  4141. }), Object.defineProperty(b.Sprite.prototype, "destroyPhase", {
  4142. get: function() {
  4143. return !!this._cache[8]
  4144. }
  4145. }), b.Image = function(a, c, d, e, f) {
  4146. c = c || 0, d = d || 0, e = e || null, f = f || null, this.game = a, this.exists = !0, this.name = "", this.type = b.IMAGE, this.z = 0, this.events = new b.Events(this), this.key = e, this._frame = 0, this._frameName = "", PIXI.Sprite.call(this, PIXI.TextureCache["__default"]), this.loadTexture(e, f), this.position.set(c, d), this.world = new b.Point(c, d), this.autoCull = !1, this.input = null, this.cameraOffset = new b.Point, this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  4147. }, b.Image.prototype = Object.create(PIXI.Sprite.prototype), b.Image.prototype.constructor = b.Image, b.Image.prototype.preUpdate = function() {
  4148. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  4149. this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++);
  4150. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4151. return !0
  4152. }, b.Image.prototype.update = function() {}, b.Image.prototype.postUpdate = function() {
  4153. this.key instanceof b.BitmapData && this.key.render(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  4154. for (var a = 0, c = this.children.length; c > a; a++) this.children[a].postUpdate()
  4155. }, b.Image.prototype.loadTexture = function(a, c) {
  4156. if (c = c || 0, a instanceof b.RenderTexture) return this.key = a.key, this.setTexture(a), void 0;
  4157. if (a instanceof b.BitmapData) return this.key = a, this.setTexture(a.texture), void 0;
  4158. if (a instanceof PIXI.Texture) return this.key = a, this.setTexture(a), void 0;
  4159. if (null === a || "undefined" == typeof a) return this.key = "__default", this.setTexture(PIXI.TextureCache[this.key]), void 0;
  4160. if ("string" == typeof a && !this.game.cache.checkImageKey(a)) return this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key]), void 0;
  4161. if (this.game.cache.isSpriteSheet(a)) {
  4162. this.key = a;
  4163. var d = this.game.cache.getFrameData(a);
  4164. return "string" == typeof c ? (this._frame = 0, this._frameName = c, this.setTexture(PIXI.TextureCache[d.getFrameByName(c).uuid]), void 0) : (this._frame = c, this._frameName = "", this.setTexture(PIXI.TextureCache[d.getFrame(c).uuid]), void 0)
  4165. }
  4166. return this.key = a, this.setTexture(PIXI.TextureCache[a]), void 0
  4167. }, b.Image.prototype.crop = function(a) {
  4168. if ("undefined" == typeof a || null === a) this.texture.hasOwnProperty("sourceWidth") && this.texture.setFrame(new b.Rectangle(0, 0, this.texture.sourceWidth, this.texture.sourceHeight));
  4169. else if (this.texture instanceof PIXI.Texture) {
  4170. var c = {};
  4171. b.Utils.extend(!0, c, this.texture), c.sourceWidth = c.width, c.sourceHeight = c.height, c.frame = a, c.width = a.width, c.height = a.height, this.texture = c, this.texture.updateFrame = !0, PIXI.Texture.frameUpdates.push(this.texture)
  4172. } else this.texture.setFrame(a)
  4173. }, b.Image.prototype.revive = function() {
  4174. return this.alive = !0, this.exists = !0, this.visible = !0, this.events && this.events.onRevived.dispatch(this), this
  4175. }, b.Image.prototype.kill = function() {
  4176. return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled.dispatch(this), this
  4177. }, b.Image.prototype.destroy = function(a) {
  4178. if (null !== this.game && !this.destroyPhase) {
  4179. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.events && this.events.destroy(), this.input && this.input.destroy();
  4180. var c = this.children.length;
  4181. if (a)
  4182. for (; c--;) this.children[c].destroy(a);
  4183. else
  4184. for (; c--;) this.removeChild(this.children[c]);
  4185. this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4186. }
  4187. }, b.Image.prototype.reset = function(a, b) {
  4188. return this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this
  4189. }, b.Image.prototype.bringToTop = function() {
  4190. return this.parent && this.parent.bringToTop(this), this
  4191. }, Object.defineProperty(b.Image.prototype, "angle", {
  4192. get: function() {
  4193. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  4194. },
  4195. set: function(a) {
  4196. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  4197. }
  4198. }), Object.defineProperty(b.Image.prototype, "deltaX", {
  4199. get: function() {
  4200. return this.world.x - this._cache[0]
  4201. }
  4202. }), Object.defineProperty(b.Image.prototype, "deltaY", {
  4203. get: function() {
  4204. return this.world.y - this._cache[1]
  4205. }
  4206. }), Object.defineProperty(b.Image.prototype, "deltaZ", {
  4207. get: function() {
  4208. return this.rotation - this._cache[2]
  4209. }
  4210. }), Object.defineProperty(b.Image.prototype, "inWorld", {
  4211. get: function() {
  4212. return this.game.world.bounds.intersects(this.getBounds())
  4213. }
  4214. }), Object.defineProperty(b.Image.prototype, "inCamera", {
  4215. get: function() {
  4216. return this.game.world.camera.screenView.intersects(this.getBounds())
  4217. }
  4218. }), Object.defineProperty(b.Image.prototype, "frame", {
  4219. get: function() {
  4220. return this._frame
  4221. },
  4222. set: function(a) {
  4223. if (a !== this.frame && this.game.cache.isSpriteSheet(this.key)) {
  4224. var b = this.game.cache.getFrameData(this.key);
  4225. b && a < b.total && b.getFrame(a) && (this.setTexture(PIXI.TextureCache[b.getFrame(a).uuid]), this._frame = a)
  4226. }
  4227. }
  4228. }), Object.defineProperty(b.Image.prototype, "frameName", {
  4229. get: function() {
  4230. return this._frameName
  4231. },
  4232. set: function(a) {
  4233. if (a !== this.frameName && this.game.cache.isSpriteSheet(this.key)) {
  4234. var b = this.game.cache.getFrameData(this.key);
  4235. b && b.getFrameByName(a) && (this.setTexture(PIXI.TextureCache[b.getFrameByName(a).uuid]), this._frameName = a)
  4236. }
  4237. }
  4238. }), Object.defineProperty(b.Image.prototype, "renderOrderID", {
  4239. get: function() {
  4240. return this._cache[3]
  4241. }
  4242. }), Object.defineProperty(b.Image.prototype, "inputEnabled", {
  4243. get: function() {
  4244. return this.input && this.input.enabled
  4245. },
  4246. set: function(a) {
  4247. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  4248. }
  4249. }), Object.defineProperty(b.Image.prototype, "fixedToCamera", {
  4250. get: function() {
  4251. return !!this._cache[7]
  4252. },
  4253. set: function(a) {
  4254. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4255. }
  4256. }), Object.defineProperty(b.Image.prototype, "smoothed", {
  4257. get: function() {
  4258. return !this.texture.baseTexture.scaleMode
  4259. },
  4260. set: function(a) {
  4261. a ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1)
  4262. }
  4263. }), Object.defineProperty(b.Image.prototype, "destroyPhase", {
  4264. get: function() {
  4265. return !!this._cache[8]
  4266. }
  4267. }), b.TileSprite = function(a, c, d, e, f, g, h) {
  4268. c = c || 0, d = d || 0, e = e || 256, f = f || 256, g = g || null, h = h || null, this.game = a, this.name = "", this.type = b.TILESPRITE, this.z = 0, this.events = new b.Events(this), this.animations = new b.AnimationManager(this), this.key = g, this._frame = 0, this._frameName = "", this._scroll = new b.Point, PIXI.TilingSprite.call(this, PIXI.TextureCache["__default"], e, f), this.position.set(c, d), this.input = null, this.world = new b.Point(c, d), this.autoCull = !1, this.checkWorldBounds = !1, this.cameraOffset = new b.Point, this.body = null, this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0], this.loadTexture(g, h)
  4269. }, b.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), b.TileSprite.prototype.constructor = b.TileSprite, b.TileSprite.prototype.preUpdate = function() {
  4270. if (1 === this._cache[4] && this.exists) return this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.body && this.body.preUpdate(), this._cache[4] = 0, !1;
  4271. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this._cache[3] = -1, !1;
  4272. (this.autoCull || this.checkWorldBounds) && this._bounds.copyFrom(this.getBounds()), this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this._bounds)), this.checkWorldBounds && (1 === this._cache[5] && this.game.world.bounds.intersects(this._bounds) ? (this._cache[5] = 0, this.events.onEnterBounds.dispatch(this)) : 0 !== this._cache[5] || this.game.world.bounds.intersects(this._bounds) || (this._cache[5] = 1, this.events.onOutOfBounds.dispatch(this))), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), this.animations.update(), 0 !== this._scroll.x && (this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed), 0 !== this._scroll.y && (this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed), this.body && this.body.preUpdate();
  4273. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4274. return !0
  4275. }, b.TileSprite.prototype.update = function() {}, b.TileSprite.prototype.postUpdate = function() {
  4276. this.exists && this.body && this.body.postUpdate(), 1 === this._cache[7] && (this.position.x = this.game.camera.view.x + this.cameraOffset.x, this.position.y = this.game.camera.view.y + this.cameraOffset.y);
  4277. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  4278. }, b.TileSprite.prototype.autoScroll = function(a, b) {
  4279. this._scroll.set(a, b)
  4280. }, b.TileSprite.prototype.stopScroll = function() {
  4281. this._scroll.set(0, 0)
  4282. }, b.TileSprite.prototype.loadTexture = function(a, c) {
  4283. c = c || 0, this.key = a, a instanceof b.RenderTexture ? (this.key = a.key, this.setTexture(a)) : a instanceof b.BitmapData ? this.setTexture(a.texture) : a instanceof PIXI.Texture ? this.setTexture(a) : null === a || "undefined" == typeof a ? (this.key = "__default", this.setTexture(PIXI.TextureCache[this.key])) : "string" != typeof a || this.game.cache.checkImageKey(a) ? (this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])), this.animations.loadFrameData(this.game.cache.getFrameData(a), c)) : (console.warn("Texture with key '" + a + "' not found."), this.key = "__missing", this.setTexture(PIXI.TextureCache[this.key]))
  4284. }, b.TileSprite.prototype.setFrame = function(a) {
  4285. this.texture.frame.x = a.x, this.texture.frame.y = a.y, this.texture.frame.width = a.width, this.texture.frame.height = a.height, this.texture.crop.x = a.x, this.texture.crop.y = a.y, this.texture.crop.width = a.width, this.texture.crop.height = a.height, a.trimmed && (this.texture.trim ? (this.texture.trim.x = a.spriteSourceSizeX, this.texture.trim.y = a.spriteSourceSizeY, this.texture.trim.width = a.sourceSizeW, this.texture.trim.height = a.sourceSizeH) : this.texture.trim = {
  4286. x: a.spriteSourceSizeX,
  4287. y: a.spriteSourceSizeY,
  4288. width: a.sourceSizeW,
  4289. height: a.sourceSizeH
  4290. }, this.texture.width = a.sourceSizeW, this.texture.height = a.sourceSizeH, this.texture.frame.width = a.sourceSizeW, this.texture.frame.height = a.sourceSizeH), this.game.renderType === b.WEBGL && PIXI.WebGLRenderer.updateTextureFrame(this.texture)
  4291. }, b.TileSprite.prototype.destroy = function(a) {
  4292. if (null !== this.game && !this.destroyPhase) {
  4293. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.filters && (this.filters = null), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.animations.destroy(), this.events.destroy();
  4294. var c = this.children.length;
  4295. if (a)
  4296. for (; c--;) this.children[c].destroy(a);
  4297. else
  4298. for (; c--;) this.removeChild(this.children[c]);
  4299. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4300. }
  4301. }, b.TileSprite.prototype.play = function(a, b, c, d) {
  4302. return this.animations.play(a, b, c, d)
  4303. }, b.TileSprite.prototype.reset = function(a, b) {
  4304. return this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.tilePosition.x = 0, this.tilePosition.y = 0, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this
  4305. }, Object.defineProperty(b.TileSprite.prototype, "angle", {
  4306. get: function() {
  4307. return b.Math.wrapAngle(b.Math.radToDeg(this.rotation))
  4308. },
  4309. set: function(a) {
  4310. this.rotation = b.Math.degToRad(b.Math.wrapAngle(a))
  4311. }
  4312. }), Object.defineProperty(b.TileSprite.prototype, "frame", {
  4313. get: function() {
  4314. return this.animations.frame
  4315. },
  4316. set: function(a) {
  4317. a !== this.animations.frame && (this.animations.frame = a)
  4318. }
  4319. }), Object.defineProperty(b.TileSprite.prototype, "frameName", {
  4320. get: function() {
  4321. return this.animations.frameName
  4322. },
  4323. set: function(a) {
  4324. a !== this.animations.frameName && (this.animations.frameName = a)
  4325. }
  4326. }), Object.defineProperty(b.TileSprite.prototype, "fixedToCamera", {
  4327. get: function() {
  4328. return !!this._cache[7]
  4329. },
  4330. set: function(a) {
  4331. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4332. }
  4333. }), Object.defineProperty(b.TileSprite.prototype, "exists", {
  4334. get: function() {
  4335. return !!this._cache[6]
  4336. },
  4337. set: function(a) {
  4338. a ? (this._cache[6] = 1, this.body && this.body.type === b.Physics.P2JS && this.body.addToWorld(), this.visible = !0) : (this._cache[6] = 0, this.body && this.body.type === b.Physics.P2JS && (this.body.safeRemove = !0), this.visible = !1)
  4339. }
  4340. }), Object.defineProperty(b.TileSprite.prototype, "inputEnabled", {
  4341. get: function() {
  4342. return this.input && this.input.enabled
  4343. },
  4344. set: function(a) {
  4345. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  4346. }
  4347. }), Object.defineProperty(b.TileSprite.prototype, "x", {
  4348. get: function() {
  4349. return this.position.x
  4350. },
  4351. set: function(a) {
  4352. this.position.x = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4353. }
  4354. }), Object.defineProperty(b.TileSprite.prototype, "y", {
  4355. get: function() {
  4356. return this.position.y
  4357. },
  4358. set: function(a) {
  4359. this.position.y = a, this.body && this.body.type === b.Physics.ARCADE && 2 === this.body.phase && (this.body._reset = 1)
  4360. }
  4361. }), Object.defineProperty(b.TileSprite.prototype, "destroyPhase", {
  4362. get: function() {
  4363. return !!this._cache[8]
  4364. }
  4365. }), b.Text = function(a, c, d, e, f) {
  4366. c = c || 0, d = d || 0, e = e || " ", f = f || {}, e = 0 === e.length ? " " : e.toString(), this.game = a, this.exists = !0, this.name = "", this.type = b.TEXT, this.z = 0, this.world = new b.Point(c, d), this._text = e, this._font = "", this._fontSize = 32, this._fontWeight = "normal", this._lineSpacing = 0, this.events = new b.Events(this), this.input = null, this.cameraOffset = new b.Point, this.setStyle(f), PIXI.Text.call(this, e, this.style), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  4367. }, b.Text.prototype = Object.create(PIXI.Text.prototype), b.Text.prototype.constructor = b.Text, b.Text.prototype.preUpdate = function() {
  4368. if (this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, !this.exists || !this.parent.exists) return this.renderOrderID = -1, !1;
  4369. this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++);
  4370. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].preUpdate();
  4371. return !0
  4372. }, b.Text.prototype.update = function() {}, b.Text.prototype.postUpdate = function() {
  4373. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y);
  4374. for (var a = 0, b = this.children.length; b > a; a++) this.children[a].postUpdate()
  4375. }, b.Text.prototype.destroy = function(a) {
  4376. if (null !== this.game && !this.destroyPhase) {
  4377. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.texture.destroy(), this.canvas.parentNode ? this.canvas.parentNode.removeChild(this.canvas) : (this.canvas = null, this.context = null);
  4378. var c = this.children.length;
  4379. if (a)
  4380. for (; c--;) this.children[c].destroy(a);
  4381. else
  4382. for (; c--;) this.removeChild(this.children[c]);
  4383. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4384. }
  4385. }, b.Text.prototype.setShadow = function(a, b, c, d) {
  4386. this.style.shadowOffsetX = a || 0, this.style.shadowOffsetY = b || 0, this.style.shadowColor = c || "rgba(0,0,0,0)", this.style.shadowBlur = d || 0, this.dirty = !0
  4387. }, b.Text.prototype.setStyle = function(a) {
  4388. a = a || {}, a.font = a.font || "bold 20pt Arial", a.fill = a.fill || "black", a.align = a.align || "left", a.stroke = a.stroke || "black", a.strokeThickness = a.strokeThickness || 0, a.wordWrap = a.wordWrap || !1, a.wordWrapWidth = a.wordWrapWidth || 100, a.shadowOffsetX = a.shadowOffsetX || 0, a.shadowOffsetY = a.shadowOffsetY || 0, a.shadowColor = a.shadowColor || "rgba(0,0,0,0)", a.shadowBlur = a.shadowBlur || 0, this.style = a, this.dirty = !0
  4389. }, b.Text.prototype.updateText = function() {
  4390. var a, b, c, d, e, f, g, h;
  4391. for (this.context.font = this.style.font, a = this.text, this.style.wordWrap && (a = this.runWordWrap(this.text)), b = a.split(/(?:\r\n|\r|\n)/), c = [], d = 0, e = 0; e < b.length; e++) f = this.context.measureText(b[e]).width, c[e] = f, d = Math.max(d, f);
  4392. for (this.canvas.width = d + this.style.strokeThickness, g = this.determineFontHeight("font: " + this.style.font + ";") + this.style.strokeThickness + this._lineSpacing + this.style.shadowOffsetY, this.canvas.height = g * b.length, navigator.isCocoonJS && this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.fillStyle = this.style.fill, this.context.font = this.style.font, this.context.strokeStyle = this.style.stroke, this.context.lineWidth = this.style.strokeThickness, this.context.shadowOffsetX = this.style.shadowOffsetX, this.context.shadowOffsetY = this.style.shadowOffsetY, this.context.shadowColor = this.style.shadowColor, this.context.shadowBlur = this.style.shadowBlur, this.context.textBaseline = "top", this.context.lineCap = "round", this.context.lineJoin = "round", e = 0; e < b.length; e++) h = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + e * g), "right" === this.style.align ? h.x += d - c[e] : "center" === this.style.align && (h.x += (d - c[e]) / 2), h.y += this._lineSpacing, this.style.stroke && this.style.strokeThickness && this.context.strokeText(b[e], h.x, h.y), this.style.fill && this.context.fillText(b[e], h.x, h.y);
  4393. this.updateTexture()
  4394. }, b.Text.prototype.runWordWrap = function(a) {
  4395. var d, e, f, g, h, i, b = "",
  4396. c = a.split("\n");
  4397. for (d = 0; d < c.length; d++) {
  4398. for (e = this.style.wordWrapWidth, f = c[d].split(" "), g = 0; g < f.length; g++) h = this.context.measureText(f[g]).width, i = h + this.context.measureText(" ").width, i > e ? (g > 0 && (b += "\n"), b += f[g] + " ", e = this.style.wordWrapWidth - h) : (e -= i, b += f[g] + " ");
  4399. d < c.length - 1 && (b += "\n")
  4400. }
  4401. return b
  4402. }, Object.defineProperty(b.Text.prototype, "angle", {
  4403. get: function() {
  4404. return b.Math.radToDeg(this.rotation)
  4405. },
  4406. set: function(a) {
  4407. this.rotation = b.Math.degToRad(a)
  4408. }
  4409. }), Object.defineProperty(b.Text.prototype, "text", {
  4410. get: function() {
  4411. return this._text
  4412. },
  4413. set: function(a) {
  4414. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0, this.updateTransform())
  4415. }
  4416. }), Object.defineProperty(b.Text.prototype, "font", {
  4417. get: function() {
  4418. return this._font
  4419. },
  4420. set: function(a) {
  4421. a !== this._font && (this._font = a.trim(), this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.updateTransform())
  4422. }
  4423. }), Object.defineProperty(b.Text.prototype, "fontSize", {
  4424. get: function() {
  4425. return this._fontSize
  4426. },
  4427. set: function(a) {
  4428. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.updateTransform())
  4429. }
  4430. }), Object.defineProperty(b.Text.prototype, "fontWeight", {
  4431. get: function() {
  4432. return this._fontWeight
  4433. },
  4434. set: function(a) {
  4435. a !== this._fontWeight && (this._fontWeight = a, this.style.font = this._fontWeight + " " + this._fontSize + "px '" + this._font + "'", this.dirty = !0, this.updateTransform())
  4436. }
  4437. }), Object.defineProperty(b.Text.prototype, "fill", {
  4438. get: function() {
  4439. return this.style.fill
  4440. },
  4441. set: function(a) {
  4442. a !== this.style.fill && (this.style.fill = a, this.dirty = !0)
  4443. }
  4444. }), Object.defineProperty(b.Text.prototype, "align", {
  4445. get: function() {
  4446. return this.style.align
  4447. },
  4448. set: function(a) {
  4449. a !== this.style.align && (this.style.align = a, this.dirty = !0)
  4450. }
  4451. }), Object.defineProperty(b.Text.prototype, "stroke", {
  4452. get: function() {
  4453. return this.style.stroke
  4454. },
  4455. set: function(a) {
  4456. a !== this.style.stroke && (this.style.stroke = a, this.dirty = !0)
  4457. }
  4458. }), Object.defineProperty(b.Text.prototype, "strokeThickness", {
  4459. get: function() {
  4460. return this.style.strokeThickness
  4461. },
  4462. set: function(a) {
  4463. a !== this.style.strokeThickness && (this.style.strokeThickness = a, this.dirty = !0)
  4464. }
  4465. }), Object.defineProperty(b.Text.prototype, "wordWrap", {
  4466. get: function() {
  4467. return this.style.wordWrap
  4468. },
  4469. set: function(a) {
  4470. a !== this.style.wordWrap && (this.style.wordWrap = a, this.dirty = !0)
  4471. }
  4472. }), Object.defineProperty(b.Text.prototype, "wordWrapWidth", {
  4473. get: function() {
  4474. return this.style.wordWrapWidth
  4475. },
  4476. set: function(a) {
  4477. a !== this.style.wordWrapWidth && (this.style.wordWrapWidth = a, this.dirty = !0)
  4478. }
  4479. }), Object.defineProperty(b.Text.prototype, "lineSpacing", {
  4480. get: function() {
  4481. return this._lineSpacing
  4482. },
  4483. set: function(a) {
  4484. a !== this._lineSpacing && (this._lineSpacing = parseFloat(a), this.dirty = !0, this.updateTransform())
  4485. }
  4486. }), Object.defineProperty(b.Text.prototype, "shadowOffsetX", {
  4487. get: function() {
  4488. return this.style.shadowOffsetX
  4489. },
  4490. set: function(a) {
  4491. a !== this.style.shadowOffsetX && (this.style.shadowOffsetX = a, this.dirty = !0)
  4492. }
  4493. }), Object.defineProperty(b.Text.prototype, "shadowOffsetY", {
  4494. get: function() {
  4495. return this.style.shadowOffsetY
  4496. },
  4497. set: function(a) {
  4498. a !== this.style.shadowOffsetY && (this.style.shadowOffsetY = a, this.dirty = !0)
  4499. }
  4500. }), Object.defineProperty(b.Text.prototype, "shadowColor", {
  4501. get: function() {
  4502. return this.style.shadowColor
  4503. },
  4504. set: function(a) {
  4505. a !== this.style.shadowColor && (this.style.shadowColor = a, this.dirty = !0)
  4506. }
  4507. }), Object.defineProperty(b.Text.prototype, "shadowBlur", {
  4508. get: function() {
  4509. return this.style.shadowBlur
  4510. },
  4511. set: function(a) {
  4512. a !== this.style.shadowBlur && (this.style.shadowBlur = a, this.dirty = !0)
  4513. }
  4514. }), Object.defineProperty(b.Text.prototype, "inputEnabled", {
  4515. get: function() {
  4516. return this.input && this.input.enabled
  4517. },
  4518. set: function(a) {
  4519. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  4520. }
  4521. }), Object.defineProperty(b.Text.prototype, "fixedToCamera", {
  4522. get: function() {
  4523. return !!this._cache[7]
  4524. },
  4525. set: function(a) {
  4526. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4527. }
  4528. }), Object.defineProperty(b.Text.prototype, "destroyPhase", {
  4529. get: function() {
  4530. return !!this._cache[8]
  4531. }
  4532. }), b.BitmapText = function(a, c, d, e, f, g) {
  4533. c = c || 0, d = d || 0, e = e || "", f = f || "", g = g || 32, this.game = a, this.exists = !0, this.name = "", this.type = b.BITMAPTEXT, this.z = 0, this.world = new b.Point(c, d), this._text = f, this._font = e, this._fontSize = g, this._align = "left", this._tint = 16777215, this.events = new b.Events(this), this.input = null, this.cameraOffset = new b.Point, PIXI.BitmapText.call(this, f), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  4534. }, b.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype), b.BitmapText.prototype.constructor = b.BitmapText, b.BitmapText.prototype.setStyle = function() {
  4535. this.style = {
  4536. align: this._align
  4537. }, this.fontName = this._font, this.fontSize = this._fontSize, this.dirty = !0
  4538. }, b.BitmapText.prototype.preUpdate = function() {
  4539. return this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.exists && this.parent.exists ? (this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), !0) : (this.renderOrderID = -1, !1)
  4540. }, b.BitmapText.prototype.update = function() {}, b.BitmapText.prototype.postUpdate = function() {
  4541. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  4542. }, b.BitmapText.prototype.destroy = function(a) {
  4543. if (null !== this.game && !this.destroyPhase) {
  4544. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
  4545. var c = this.children.length;
  4546. if (a)
  4547. for (; c--;) this.children[c].destroy ? this.children[c].destroy(a) : this.removeChild(this.children[c]);
  4548. else
  4549. for (; c--;) this.removeChild(this.children[c]);
  4550. this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this._cache[8] = 0
  4551. }
  4552. }, Object.defineProperty(b.BitmapText.prototype, "align", {
  4553. get: function() {
  4554. return this._align
  4555. },
  4556. set: function(a) {
  4557. a !== this._align && (this._align = a, this.setStyle())
  4558. }
  4559. }), Object.defineProperty(b.BitmapText.prototype, "tint", {
  4560. get: function() {
  4561. return this._tint
  4562. },
  4563. set: function(a) {
  4564. a !== this._tint && (this._tint = a, this.dirty = !0)
  4565. }
  4566. }), Object.defineProperty(b.BitmapText.prototype, "angle", {
  4567. get: function() {
  4568. return b.Math.radToDeg(this.rotation)
  4569. },
  4570. set: function(a) {
  4571. this.rotation = b.Math.degToRad(a)
  4572. }
  4573. }), Object.defineProperty(b.BitmapText.prototype, "font", {
  4574. get: function() {
  4575. return this._font
  4576. },
  4577. set: function(a) {
  4578. a !== this._font && (this._font = a.trim(), this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  4579. }
  4580. }), Object.defineProperty(b.BitmapText.prototype, "fontSize", {
  4581. get: function() {
  4582. return this._fontSize
  4583. },
  4584. set: function(a) {
  4585. a = parseInt(a, 10), a !== this._fontSize && (this._fontSize = a, this.style.font = this._fontSize + "px '" + this._font + "'", this.dirty = !0)
  4586. }
  4587. }), Object.defineProperty(b.BitmapText.prototype, "text", {
  4588. get: function() {
  4589. return this._text
  4590. },
  4591. set: function(a) {
  4592. a !== this._text && (this._text = a.toString() || " ", this.dirty = !0)
  4593. }
  4594. }), Object.defineProperty(b.BitmapText.prototype, "inputEnabled", {
  4595. get: function() {
  4596. return this.input && this.input.enabled
  4597. },
  4598. set: function(a) {
  4599. a ? null === this.input ? (this.input = new b.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop()
  4600. }
  4601. }), Object.defineProperty(b.BitmapText.prototype, "fixedToCamera", {
  4602. get: function() {
  4603. return !!this._cache[7]
  4604. },
  4605. set: function(a) {
  4606. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4607. }
  4608. }), Object.defineProperty(b.BitmapText.prototype, "destroyPhase", {
  4609. get: function() {
  4610. return !!this._cache[8]
  4611. }
  4612. }), b.Button = function(a, c, d, e, f, g, h, i, j, k) {
  4613. c = c || 0, d = d || 0, e = e || null, f = f || null, g = g || this, b.Image.call(this, a, c, d, e, i), this.type = b.BUTTON, this._onOverFrameName = null, this._onOutFrameName = null, this._onDownFrameName = null, this._onUpFrameName = null, this._onOverFrameID = null, this._onOutFrameID = null, this._onDownFrameID = null, this._onUpFrameID = null, this.onOverMouseOnly = !1, this.onOverSound = null, this.onOutSound = null, this.onDownSound = null, this.onUpSound = null, this.onOverSoundMarker = "", this.onOutSoundMarker = "", this.onDownSoundMarker = "", this.onUpSoundMarker = "", this.onInputOver = new b.Signal, this.onInputOut = new b.Signal, this.onInputDown = new b.Signal, this.onInputUp = new b.Signal, this.freezeFrames = !1, this.forceOut = !1, this.inputEnabled = !0, this.input.start(0, !0), this.setFrames(h, i, j, k), null !== f && this.onInputUp.add(f, g), this.events.onInputOver.add(this.onInputOverHandler, this), this.events.onInputOut.add(this.onInputOutHandler, this), this.events.onInputDown.add(this.onInputDownHandler, this), this.events.onInputUp.add(this.onInputUpHandler, this)
  4614. }, b.Button.prototype = Object.create(b.Image.prototype), b.Button.prototype.constructor = b.Button, b.Button.prototype.clearFrames = function() {
  4615. this._onOverFrameName = null, this._onOverFrameID = null, this._onOutFrameName = null, this._onOutFrameID = null, this._onDownFrameName = null, this._onDownFrameID = null, this._onUpFrameName = null, this._onUpFrameID = null
  4616. }, b.Button.prototype.setFrames = function(a, b, c, d) {
  4617. this.clearFrames(), null !== a && ("string" == typeof a ? (this._onOverFrameName = a, this.input.pointerOver() && (this.frameName = a)) : (this._onOverFrameID = a, this.input.pointerOver() && (this.frame = a))), null !== b && ("string" == typeof b ? (this._onOutFrameName = b, this.input.pointerOver() === !1 && (this.frameName = b)) : (this._onOutFrameID = b, this.input.pointerOver() === !1 && (this.frame = b))), null !== c && ("string" == typeof c ? (this._onDownFrameName = c, this.input.pointerDown() && (this.frameName = c)) : (this._onDownFrameID = c, this.input.pointerDown() && (this.frame = c))), null !== d && ("string" == typeof d ? (this._onUpFrameName = d, this.input.pointerUp() && (this.frameName = d)) : (this._onUpFrameID = d, this.input.pointerUp() && (this.frame = d)))
  4618. }, b.Button.prototype.setSounds = function(a, b, c, d, e, f, g, h) {
  4619. this.setOverSound(a, b), this.setOutSound(e, f), this.setDownSound(c, d), this.setUpSound(g, h)
  4620. }, b.Button.prototype.setOverSound = function(a, c) {
  4621. this.onOverSound = null, this.onOverSoundMarker = "", a instanceof b.Sound && (this.onOverSound = a), "string" == typeof c && (this.onOverSoundMarker = c)
  4622. }, b.Button.prototype.setOutSound = function(a, c) {
  4623. this.onOutSound = null, this.onOutSoundMarker = "", a instanceof b.Sound && (this.onOutSound = a), "string" == typeof c && (this.onOutSoundMarker = c)
  4624. }, b.Button.prototype.setDownSound = function(a, c) {
  4625. this.onDownSound = null, this.onDownSoundMarker = "", a instanceof b.Sound && (this.onDownSound = a), "string" == typeof c && (this.onDownSoundMarker = c)
  4626. }, b.Button.prototype.setUpSound = function(a, c) {
  4627. this.onUpSound = null, this.onUpSoundMarker = "", a instanceof b.Sound && (this.onUpSound = a), "string" == typeof c && (this.onUpSoundMarker = c)
  4628. }, b.Button.prototype.onInputOverHandler = function(a, b) {
  4629. this.freezeFrames === !1 && this.setState(1), (!this.onOverMouseOnly || b.isMouse) && (this.onOverSound && this.onOverSound.play(this.onOverSoundMarker), this.onInputOver && this.onInputOver.dispatch(this, b))
  4630. }, b.Button.prototype.onInputOutHandler = function(a, b) {
  4631. this.freezeFrames === !1 && this.setState(2), this.onOutSound && this.onOutSound.play(this.onOutSoundMarker), this.onInputOut && this.onInputOut.dispatch(this, b)
  4632. }, b.Button.prototype.onInputDownHandler = function(a, b) {
  4633. this.freezeFrames === !1 && this.setState(3), this.onDownSound && this.onDownSound.play(this.onDownSoundMarker), this.onInputDown && this.onInputDown.dispatch(this, b)
  4634. }, b.Button.prototype.onInputUpHandler = function(a, b, c) {
  4635. this.onUpSound && this.onUpSound.play(this.onUpSoundMarker), this.onInputUp && this.onInputUp.dispatch(this, b, c), this.freezeFrames || (this.forceOut ? this.setState(2) : null !== this._onUpFrameName || null !== this._onUpFrameID ? this.setState(4) : c ? this.setState(1) : this.setState(2))
  4636. }, b.Button.prototype.setState = function(a) {
  4637. 1 === a ? null != this._onOverFrameName ? this.frameName = this._onOverFrameName : null != this._onOverFrameID && (this.frame = this._onOverFrameID) : 2 === a ? null != this._onOutFrameName ? this.frameName = this._onOutFrameName : null != this._onOutFrameID && (this.frame = this._onOutFrameID) : 3 === a ? null != this._onDownFrameName ? this.frameName = this._onDownFrameName : null != this._onDownFrameID && (this.frame = this._onDownFrameID) : 4 === a && (null != this._onUpFrameName ? this.frameName = this._onUpFrameName : null != this._onUpFrameID && (this.frame = this._onUpFrameID))
  4638. }, b.Graphics = function(a, c, d) {
  4639. c = c || 0, d = d || 0, this.game = a, this.exists = !0, this.name = "", this.type = b.GRAPHICS, this.z = 0, this.world = new b.Point(c, d), this.cameraOffset = new b.Point, PIXI.Graphics.call(this), this.position.set(c, d), this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0]
  4640. }, b.Graphics.prototype = Object.create(PIXI.Graphics.prototype), b.Graphics.prototype.constructor = b.Graphics, b.Graphics.prototype.preUpdate = function() {
  4641. return this._cache[0] = this.world.x, this._cache[1] = this.world.y, this._cache[2] = this.rotation, this.exists && this.parent.exists ? (this.autoCull && (this.renderable = this.game.world.camera.screenView.intersects(this.getBounds())), this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this._cache[3] = this.game.stage.currentRenderOrderID++), !0) : (this.renderOrderID = -1, !1)
  4642. }, b.Graphics.prototype.update = function() {}, b.Graphics.prototype.postUpdate = function() {
  4643. 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  4644. }, b.Graphics.prototype.destroy = function(a) {
  4645. if (null !== this.game && !this.destroyPhase) {
  4646. "undefined" == typeof a && (a = !0), this._cache[8] = 1, this.clear(), this.parent && (this.parent instanceof b.Group ? this.parent.remove(this) : this.parent.removeChild(this));
  4647. var c = this.children.length;
  4648. if (a)
  4649. for (; c--;) this.children[c].destroy(a);
  4650. else
  4651. for (; c--;) this.removeChild(this.children[c]);
  4652. this.exists = !1, this.visible = !1, this.game = null, this._cache[8] = 0
  4653. }
  4654. }, b.Graphics.prototype.drawPolygon = function(a) {
  4655. this.moveTo(a.points[0].x, a.points[0].y);
  4656. for (var b = 1; b < a.points.length; b += 1) this.lineTo(a.points[b].x, a.points[b].y);
  4657. this.lineTo(a.points[0].x, a.points[0].y)
  4658. }, b.Graphics.prototype.drawTriangle = function(a, c) {
  4659. var d, e, f, g, h;
  4660. "undefined" == typeof c && (c = !1), d = new b.Polygon(a), c ? (e = new b.Point(this.game.camera.x - a[0].x, this.game.camera.y - a[0].y), f = new b.Point(a[1].x - a[0].x, a[1].y - a[0].y), g = new b.Point(a[1].x - a[2].x, a[1].y - a[2].y), h = g.cross(f), e.dot(h) > 0 && this.drawPolygon(d)) : this.drawPolygon(d)
  4661. }, b.Graphics.prototype.drawTriangles = function(a, c, d) {
  4662. var e, f, g, h, i;
  4663. if ("undefined" == typeof d && (d = !1), e = new b.Point, f = new b.Point, g = new b.Point, h = [], c)
  4664. if (a[0] instanceof b.Point)
  4665. for (i = 0; i < c.length / 3; i++) h.push(a[c[3 * i]]), h.push(a[c[3 * i + 1]]), h.push(a[c[3 * i + 2]]), 3 === h.length && (this.drawTriangle(h, d), h = []);
  4666. else
  4667. for (i = 0; i < c.length; i++) e.x = a[2 * c[i]], e.y = a[2 * c[i] + 1], h.push(e.copyTo({})), 3 === h.length && (this.drawTriangle(h, d), h = []);
  4668. else if (a[0] instanceof b.Point)
  4669. for (i = 0; i < a.length / 3; i++) this.drawTriangle([a[3 * i], a[3 * i + 1], a[3 * i + 2]], d);
  4670. else
  4671. for (i = 0; i < a.length / 6; i++) e.x = a[6 * i + 0], e.y = a[6 * i + 1], f.x = a[6 * i + 2], f.y = a[6 * i + 3], g.x = a[6 * i + 4], g.y = a[6 * i + 5], this.drawTriangle([e, f, g], d)
  4672. }, Object.defineProperty(b.Graphics.prototype, "angle", {
  4673. get: function() {
  4674. return b.Math.radToDeg(this.rotation)
  4675. },
  4676. set: function(a) {
  4677. this.rotation = b.Math.degToRad(a)
  4678. }
  4679. }), Object.defineProperty(b.Graphics.prototype, "fixedToCamera", {
  4680. get: function() {
  4681. return !!this._cache[7]
  4682. },
  4683. set: function(a) {
  4684. a ? (this._cache[7] = 1, this.cameraOffset.set(this.x, this.y)) : this._cache[7] = 0
  4685. }
  4686. }), Object.defineProperty(b.Graphics.prototype, "destroyPhase", {
  4687. get: function() {
  4688. return !!this._cache[8]
  4689. }
  4690. }), b.RenderTexture = function(a, c, d, e, f) {
  4691. "undefined" == typeof e && (e = ""), "undefined" == typeof f && (f = b.scaleModes.DEFAULT), this.game = a, this.key = e, this.type = b.RENDERTEXTURE, this._temp = new b.Point, PIXI.RenderTexture.call(this, c, d, this.game.renderer, f)
  4692. }, b.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), b.RenderTexture.prototype.constructor = b.RenderTexture, b.RenderTexture.prototype.renderXY = function(a, b, c, d) {
  4693. this._temp.set(b, c), this.render(a, this._temp, d)
  4694. }, b.SpriteBatch = function(a, c, d, e) {
  4695. ("undefined" == typeof c || null === c) && (c = a.world), PIXI.SpriteBatch.call(this), b.Group.call(this, a, c, d, e), this.type = b.SPRITEBATCH
  4696. }, b.SpriteBatch.prototype = b.Utils.extend(!0, b.SpriteBatch.prototype, b.Group.prototype, PIXI.SpriteBatch.prototype), b.SpriteBatch.prototype.constructor = b.SpriteBatch, b.RetroFont = function(a, c, d, e, f, g, h, i, j, k) {
  4697. var l, m, n, o, p, q, r;
  4698. if (!a.cache.checkImageKey(c)) return !1;
  4699. for (("undefined" == typeof g || null === g) && (g = a.cache.getImage(c).width / d), this.characterWidth = d, this.characterHeight = e, this.characterSpacingX = h || 0, this.characterSpacingY = i || 0, this.characterPerRow = g, this.offsetX = j || 0, this.offsetY = k || 0, this.align = "left", this.multiLine = !1, this.autoUpperCase = !0, this.customSpacingX = 0, this.customSpacingY = 0, this.fixedWidth = 0, this.fontSet = a.cache.getImage(c), this._text = "", this.grabData = [], l = this.offsetX, m = this.offsetY, n = 0, o = new b.FrameData, p = 0; p < f.length; p++) q = a.rnd.uuid(), r = o.addFrame(new b.Frame(p, l, m, this.characterWidth, this.characterHeight, "", q)), this.grabData[f.charCodeAt(p)] = r.index, PIXI.TextureCache[q] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  4700. x: l,
  4701. y: m,
  4702. width: this.characterWidth,
  4703. height: this.characterHeight
  4704. }), n++, n == this.characterPerRow ? (n = 0, l = this.offsetX, m += this.characterHeight + this.characterSpacingY) : l += this.characterWidth + this.characterSpacingX;
  4705. a.cache.updateFrameData(c, o), this.stamp = new b.Image(a, 0, 0, c, 0), b.RenderTexture.call(this, a, 100, 100, "", b.scaleModes.NEAREST), this.type = b.RETROFONT
  4706. }, b.RetroFont.prototype = Object.create(b.RenderTexture.prototype), b.RetroFont.prototype.constructor = b.RetroFont, b.RetroFont.ALIGN_LEFT = "left", b.RetroFont.ALIGN_RIGHT = "right", b.RetroFont.ALIGN_CENTER = "center", b.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", b.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ", b.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789", b.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789", b.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ", b.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39", b.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!", b.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", b.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789", b.RetroFont.prototype.setFixedWidth = function(a, b) {
  4707. "undefined" == typeof b && (b = "left"), this.fixedWidth = a, this.align = b
  4708. }, b.RetroFont.prototype.setText = function(a, b, c, d, e, f) {
  4709. this.multiLine = b || !1, this.customSpacingX = c || 0, this.customSpacingY = d || 0, this.align = e || "left", this.autoUpperCase = f ? !1 : !0, a.length > 0 && (this.text = a)
  4710. }, b.RetroFont.prototype.buildRetroFontText = function() {
  4711. var d, e, a = 0,
  4712. c = 0;
  4713. if (this.clear(), this.multiLine)
  4714. for (d = this._text.split("\n"), this.fixedWidth > 0 ? this.resize(this.fixedWidth, d.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0) : this.resize(this.getLongestLine() * (this.characterWidth + this.customSpacingX), d.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0), e = 0; e < d.length; e++) {
  4715. switch (this.align) {
  4716. case b.RetroFont.ALIGN_LEFT:
  4717. a = 0;
  4718. break;
  4719. case b.RetroFont.ALIGN_RIGHT:
  4720. a = this.width - d[e].length * (this.characterWidth + this.customSpacingX);
  4721. break;
  4722. case b.RetroFont.ALIGN_CENTER:
  4723. a = this.width / 2 - d[e].length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  4724. }
  4725. 0 > a && (a = 0), this.pasteLine(d[e], a, c, this.customSpacingX), c += this.characterHeight + this.customSpacingY
  4726. } else {
  4727. switch (this.fixedWidth > 0 ? this.resize(this.fixedWidth, this.characterHeight, !0) : this.resize(this._text.length * (this.characterWidth + this.customSpacingX), this.characterHeight, !0), this.align) {
  4728. case b.RetroFont.ALIGN_LEFT:
  4729. a = 0;
  4730. break;
  4731. case b.RetroFont.ALIGN_RIGHT:
  4732. a = this.width - this._text.length * (this.characterWidth + this.customSpacingX);
  4733. break;
  4734. case b.RetroFont.ALIGN_CENTER:
  4735. a = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, a += this.customSpacingX / 2
  4736. }
  4737. this.textureBuffer.clear(), this.pasteLine(this._text, a, 0, this.customSpacingX)
  4738. }
  4739. }, b.RetroFont.prototype.pasteLine = function(a, c, d, e) {
  4740. var g, f = new b.Point;
  4741. for (g = 0; g < a.length; g++)
  4742. if (" " == a.charAt(g)) c += this.characterWidth + e;
  4743. else if (this.grabData[a.charCodeAt(g)] >= 0 && (this.stamp.frame = this.grabData[a.charCodeAt(g)], f.set(c, d), this.render(this.stamp, f, !1), c += this.characterWidth + e, c > this.width)) break
  4744. }, b.RetroFont.prototype.getLongestLine = function() {
  4745. var b, c, a = 0;
  4746. if (this._text.length > 0)
  4747. for (b = this._text.split("\n"), c = 0; c < b.length; c++) b[c].length > a && (a = b[c].length);
  4748. return a
  4749. }, b.RetroFont.prototype.removeUnsupportedCharacters = function(a) {
  4750. var c, d, e, b = "";
  4751. for (c = 0; c < this._text.length; c++) d = this._text[c], e = d.charCodeAt(0), (this.grabData[e] >= 0 || !a && "\n" === d) && (b = b.concat(d));
  4752. return b
  4753. }, b.RetroFont.prototype.updateOffset = function(a, b) {
  4754. var c, d, e, f;
  4755. if (this.offsetX !== a || this.offsetY !== b) {
  4756. for (c = a - this.offsetX, d = b - this.offsetY, e = this.game.cache.getFrameData(this.stamp.key).getFrames(), f = e.length; f--;) e[f].x += c, e[f].y += d, PIXI.TextureCache[e[f].uuid].frame.x = e[f].x, PIXI.TextureCache[e[f].uuid].frame.y = e[f].y;
  4757. this.buildRetroFontText()
  4758. }
  4759. }, Object.defineProperty(b.RetroFont.prototype, "text", {
  4760. get: function() {
  4761. return this._text
  4762. },
  4763. set: function(a) {
  4764. var b;
  4765. b = this.autoUpperCase ? a.toUpperCase() : a, b !== this._text && (this._text = b, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
  4766. }
  4767. }), Object.defineProperty(b.RetroFont.prototype, "smoothed", {
  4768. get: function() {
  4769. return this.stamp.smoothed
  4770. },
  4771. set: function(a) {
  4772. this.stamp.smoothed = a, this.buildRetroFontText()
  4773. }
  4774. }), b.Particle = function(a, c, d, e, f) {
  4775. b.Sprite.call(this, a, c, d, e, f), this.autoScale = !1, this.scaleData = null, this._s = 0, this.autoAlpha = !1, this.alphaData = null, this._a = 0
  4776. }, b.Particle.prototype = Object.create(b.Sprite.prototype), b.Particle.prototype.constructor = b.Particle, b.Particle.prototype.update = function() {
  4777. this.autoScale && (this._s--, this._s ? this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y) : this.autoScale = !1), this.autoAlpha && (this._a--, this._a ? this.alpha = this.alphaData[this._a].v : this.autoAlpha = !1)
  4778. }, b.Particle.prototype.onEmit = function() {}, b.Particle.prototype.setAlphaData = function(a) {
  4779. this.alphaData = a, this._a = a.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0
  4780. }, b.Particle.prototype.setScaleData = function(a) {
  4781. this.scaleData = a, this._s = a.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0
  4782. }, b.Particle.prototype.reset = function(a, b, c) {
  4783. return "undefined" == typeof c && (c = 1), this.world.setTo(a, b), this.position.x = a, this.position.y = b, this.alive = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this._outOfBoundsFired = !1, this.health = c, this.body && this.body.reset(a, b, !1, !1), this._cache[4] = 1, this.alpha = 1, this.scale.set(1), this.autoScale = !1, this.autoAlpha = !1, this
  4784. }, b.Canvas = {
  4785. create: function(a, b, c, d) {
  4786. "undefined" == typeof d && (d = !1), a = a || 256, b = b || 256;
  4787. var e = document.createElement("canvas");
  4788. return "string" == typeof c && "" !== c && (e.id = c), e.width = a, e.height = b, e.style.display = "block", e
  4789. },
  4790. getOffset: function(a, c) {
  4791. var d, e, f, g, h;
  4792. return c = c || new b.Point, d = a.getBoundingClientRect(), e = a.clientTop || document.body.clientTop || 0, f = a.clientLeft || document.body.clientLeft || 0, g = 0, h = 0, "CSS1Compat" === document.compatMode ? (g = window.pageYOffset || document.documentElement.scrollTop || a.scrollTop || 0, h = window.pageXOffset || document.documentElement.scrollLeft || a.scrollLeft || 0) : (g = window.pageYOffset || document.body.scrollTop || a.scrollTop || 0, h = window.pageXOffset || document.body.scrollLeft || a.scrollLeft || 0), c.x = d.left + h - f, c.y = d.top + g - e, c
  4793. },
  4794. getAspectRatio: function(a) {
  4795. return a.width / a.height
  4796. },
  4797. setBackgroundColor: function(a, b) {
  4798. return b = b || "rgb(0,0,0)", a.style.backgroundColor = b, a
  4799. },
  4800. setTouchAction: function(a, b) {
  4801. return b = b || "none", a.style.msTouchAction = b, a.style["ms-touch-action"] = b, a.style["touch-action"] = b, a
  4802. },
  4803. setUserSelect: function(a, b) {
  4804. return b = b || "none", a.style["-webkit-touch-callout"] = b, a.style["-webkit-user-select"] = b, a.style["-khtml-user-select"] = b, a.style["-moz-user-select"] = b, a.style["-ms-user-select"] = b, a.style["user-select"] = b, a.style["-webkit-tap-highlight-color"] = "rgba(0, 0, 0, 0)", a
  4805. },
  4806. addToDOM: function(a, b, c) {
  4807. var d;
  4808. return "undefined" == typeof c && (c = !0), b && ("string" == typeof b ? d = document.getElementById(b) : "object" == typeof b && 1 === b.nodeType && (d = b)), d || (d = document.body), c && d.style && (d.style.overflow = "hidden"), d.appendChild(a), a
  4809. },
  4810. setTransform: function(a, b, c, d, e, f, g) {
  4811. return a.setTransform(d, f, g, e, b, c), a
  4812. },
  4813. setSmoothingEnabled: function(a, b) {
  4814. return a["imageSmoothingEnabled"] = b, a["mozImageSmoothingEnabled"] = b, a["oImageSmoothingEnabled"] = b, a["webkitImageSmoothingEnabled"] = b, a["msImageSmoothingEnabled"] = b, a
  4815. },
  4816. setImageRenderingCrisp: function(a) {
  4817. return a.style["image-rendering"] = "optimizeSpeed", a.style["image-rendering"] = "crisp-edges", a.style["image-rendering"] = "-moz-crisp-edges", a.style["image-rendering"] = "-webkit-optimize-contrast", a.style["image-rendering"] = "optimize-contrast", a.style.msInterpolationMode = "nearest-neighbor", a
  4818. },
  4819. setImageRenderingBicubic: function(a) {
  4820. return a.style["image-rendering"] = "auto", a.style.msInterpolationMode = "bicubic", a
  4821. }
  4822. }, b.Device = function(a) {
  4823. this.game = a, this.desktop = !1, this.iOS = !1, this.cocoonJS = !1, this.ejecta = !1, this.crosswalk = !1, this.android = !1, this.chromeOS = !1, this.linux = !1, this.macOS = !1, this.windows = !1, this.windowsPhone = !1, this.canvas = !1, this.file = !1, this.fileSystem = !1, this.localStorage = !1, this.webGL = !1, this.worker = !1, this.touch = !1, this.mspointer = !1, this.css3D = !1, this.pointerLock = !1, this.typedArray = !1, this.vibration = !1, this.getUserMedia = !1, this.quirksMode = !1, this.arora = !1, this.chrome = !1, this.epiphany = !1, this.firefox = !1, this.ie = !1, this.ieVersion = 0, this.trident = !1, this.tridentVersion = 0, this.mobileSafari = !1, this.midori = !1, this.opera = !1, this.safari = !1, this.webApp = !1, this.silk = !1, this.audioData = !1, this.webAudio = !1, this.ogg = !1, this.opus = !1, this.mp3 = !1, this.wav = !1, this.m4a = !1, this.webm = !1, this.iPhone = !1, this.iPhone4 = !1, this.iPad = !1, this.pixelRatio = 0, this.littleEndian = !1, this.support32bit = !1, this.fullscreen = !1, this.requestFullscreen = "", this.cancelFullscreen = "", this.fullscreenKeyboard = !1, this._checkOS(), this._checkAudio(), this._checkBrowser(), this._checkCSS3D(), this._checkDevice(), this._checkFeatures()
  4824. }, b.Device.LITTLE_ENDIAN = !1, b.Device.prototype = {
  4825. _checkOS: function() {
  4826. var a = navigator.userAgent;
  4827. /Android/.test(a) ? this.android = !0 : /CrOS/.test(a) ? this.chromeOS = !0 : /iP[ao]d|iPhone/i.test(a) ? this.iOS = !0 : /Linux/.test(a) ? this.linux = !0 : /Mac OS/.test(a) ? this.macOS = !0 : /Windows/.test(a) && (this.windows = !0, /Windows Phone/i.test(a) && (this.windowsPhone = !0)), (this.windows || this.macOS || this.linux && this.silk === !1) && (this.desktop = !0), (this.windowsPhone || /Windows NT/i.test(a) && /Touch/i.test(a)) && (this.desktop = !1)
  4828. },
  4829. _checkFeatures: function() {
  4830. this.canvas = !!window["CanvasRenderingContext2D"] || this.cocoonJS;
  4831. try {
  4832. this.localStorage = !!localStorage.getItem
  4833. } catch (a) {
  4834. this.localStorage = !1
  4835. }
  4836. this.file = !!(window["File"] && window["FileReader"] && window["FileList"] && window["Blob"]), this.fileSystem = !!window["requestFileSystem"], this.webGL = function() {
  4837. try {
  4838. var a = document.createElement("canvas");
  4839. return !!window.WebGLRenderingContext && (a.getContext("webgl") || a.getContext("experimental-webgl"))
  4840. } catch (b) {
  4841. return !1
  4842. }
  4843. }(), this.webGL = null === this.webGL || this.webGL === !1 ? !1 : !0, this.worker = !!window["Worker"], ("ontouchstart" in document.documentElement || window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1) && (this.touch = !0), (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) && (this.mspointer = !0), this.pointerLock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document, this.quirksMode = "CSS1Compat" === document.compatMode ? !1 : !0, this.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia)
  4844. },
  4845. checkFullScreenSupport: function() {
  4846. var b, c, a = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"];
  4847. for (b = 0; b < a.length; b++)
  4848. if (this.game.canvas[a[b]]) {
  4849. this.fullscreen = !0, this.requestFullscreen = a[b];
  4850. break
  4851. }
  4852. if (c = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"], this.fullscreen)
  4853. for (b = 0; b < c.length; b++)
  4854. if (document[c[b]]) {
  4855. this.cancelFullscreen = c[b];
  4856. break
  4857. }
  4858. window["Element"] && Element["ALLOW_KEYBOARD_INPUT"] && (this.fullscreenKeyboard = !0)
  4859. },
  4860. _checkBrowser: function() {
  4861. var a = navigator.userAgent;
  4862. /Arora/.test(a) ? this.arora = !0 : /Chrome/.test(a) ? this.chrome = !0 : /Epiphany/.test(a) ? this.epiphany = !0 : /Firefox/.test(a) ? this.firefox = !0 : /AppleWebKit/.test(a) && this.iOS ? this.mobileSafari = !0 : /MSIE(\d+\.\d+);/.test(a) ? (this.ie = !0, this.ieVersion = parseInt(RegExp.$1, 10)) : /Midori/.test(a) ? this.midori = !0 : /Opera/.test(a) ? this.opera = !0 : /Safari/.test(a) ? this.safari = !0 : /Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(a) && (this.ie = !0, this.trident = !0, this.tridentVersion = parseInt(RegExp.$1, 10), this.ieVersion = parseInt(RegExp.$3, 10)), /Silk/.test(a) && (this.silk = !0), navigator["standalone"] && (this.webApp = !0), navigator["isCocoonJS"] && (this.cocoonJS = !0), "undefined" != typeof window.ejecta && (this.ejecta = !0), /Crosswalk/.test(a) && (this.crosswalk = !0)
  4863. },
  4864. _checkAudio: function() {
  4865. var a, b;
  4866. this.audioData = !!window["Audio"], this.webAudio = !(!window["webkitAudioContext"] && !window["AudioContext"]), a = document.createElement("audio"), b = !1;
  4867. try {
  4868. (b = !!a.canPlayType) && (a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.ogg = !0), a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, "") && (this.opus = !0), a.canPlayType("audio/mpeg;").replace(/^no$/, "") && (this.mp3 = !0), a.canPlayType('audio/wav; codecs="1"').replace(/^no$/, "") && (this.wav = !0), (a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/aac;").replace(/^no$/, "")) && (this.m4a = !0), a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "") && (this.webm = !0))
  4869. } catch (c) {}
  4870. },
  4871. _checkDevice: function() {
  4872. this.pixelRatio = window["devicePixelRatio"] || 1, this.iPhone = -1 != navigator.userAgent.toLowerCase().indexOf("iphone"), this.iPhone4 = 2 == this.pixelRatio && this.iPhone, this.iPad = -1 != navigator.userAgent.toLowerCase().indexOf("ipad"), this.typedArray = "undefined" != typeof Int8Array ? !0 : !1, "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array && "undefined" != typeof Uint32Array && (this.littleEndian = this._checkIsLittleEndian(), b.Device.LITTLE_ENDIAN = this.littleEndian), this.support32bit = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8ClampedArray && "undefined" != typeof Int32Array && null !== this.littleEndian && this._checkIsUint8ClampedImageData(), navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate, navigator.vibrate && (this.vibration = !0)
  4873. },
  4874. _checkIsLittleEndian: function() {
  4875. var a = new ArrayBuffer(4),
  4876. b = new Uint8Array(a),
  4877. c = new Uint32Array(a);
  4878. return b[0] = 161, b[1] = 178, b[2] = 195, b[3] = 212, 3569595041 == c[0] ? !0 : 2712847316 == c[0] ? !1 : null
  4879. },
  4880. _checkIsUint8ClampedImageData: function() {
  4881. var a, b, c;
  4882. return "undefined" == typeof Uint8ClampedArray ? !1 : (a = document.createElement("canvas"), (b = a.getContext("2d")) ? (c = b.createImageData(1, 1), c.data instanceof Uint8ClampedArray) : !1)
  4883. },
  4884. _checkCSS3D: function() {
  4885. var b, d, a = document.createElement("p"),
  4886. c = {
  4887. webkitTransform: "-webkit-transform",
  4888. OTransform: "-o-transform",
  4889. msTransform: "-ms-transform",
  4890. MozTransform: "-moz-transform",
  4891. transform: "transform"
  4892. };
  4893. document.body.insertBefore(a, null);
  4894. for (d in c) void 0 !== a.style[d] && (a.style[d] = "translate3d(1px,1px,1px)", b = window.getComputedStyle(a).getPropertyValue(c[d]));
  4895. document.body.removeChild(a), this.css3D = void 0 !== b && b.length > 0 && "none" !== b
  4896. },
  4897. canPlayAudio: function(a) {
  4898. return "mp3" == a && this.mp3 ? !0 : "ogg" == a && (this.ogg || this.opus) ? !0 : "m4a" == a && this.m4a ? !0 : "wav" == a && this.wav ? !0 : "webm" == a && this.webm ? !0 : !1
  4899. },
  4900. isConsoleOpen: function() {
  4901. return window.console && window.console["firebug"] ? !0 : window.console && (console.profile(), console.profileEnd(), console.clear && console.clear(), console["profiles"]) ? console["profiles"].length > 0 : !1
  4902. }
  4903. }, b.Device.prototype.constructor = b.Device, b.RequestAnimationFrame = function(a, b) {
  4904. var c, d;
  4905. for ("undefined" == typeof b && (b = !1), this.game = a, this.isRunning = !1, this.forceSetTimeOut = b, c = ["ms", "moz", "webkit", "o"], d = 0; d < c.length && !window.requestAnimationFrame; d++) window.requestAnimationFrame = window[c[d] + "RequestAnimationFrame"], window.cancelAnimationFrame = window[c[d] + "CancelAnimationFrame"];
  4906. this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
  4907. }, b.RequestAnimationFrame.prototype = {
  4908. start: function() {
  4909. this.isRunning = !0;
  4910. var a = this;
  4911. !window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() {
  4912. return a.updateSetTimeout()
  4913. }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(b) {
  4914. return a.updateRAF(b)
  4915. }, this._timeOutID = window.requestAnimationFrame(this._onLoop))
  4916. },
  4917. updateRAF: function() {
  4918. this.game.update(Date.now()), this._timeOutID = window.requestAnimationFrame(this._onLoop)
  4919. },
  4920. updateSetTimeout: function() {
  4921. this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)
  4922. },
  4923. stop: function() {
  4924. this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1
  4925. },
  4926. isSetTimeOut: function() {
  4927. return this._isSetTimeOut
  4928. },
  4929. isRAF: function() {
  4930. return this._isSetTimeOut === !1
  4931. }
  4932. }, b.RequestAnimationFrame.prototype.constructor = b.RequestAnimationFrame, b.Math = {
  4933. PI2: 2 * Math.PI,
  4934. fuzzyEqual: function(a, b, c) {
  4935. return "undefined" == typeof c && (c = 1e-4), Math.abs(a - b) < c
  4936. },
  4937. fuzzyLessThan: function(a, b, c) {
  4938. return "undefined" == typeof c && (c = 1e-4), b + c > a
  4939. },
  4940. fuzzyGreaterThan: function(a, b, c) {
  4941. return "undefined" == typeof c && (c = 1e-4), a > b - c
  4942. },
  4943. fuzzyCeil: function(a, b) {
  4944. return "undefined" == typeof b && (b = 1e-4), Math.ceil(a - b)
  4945. },
  4946. fuzzyFloor: function(a, b) {
  4947. return "undefined" == typeof b && (b = 1e-4), Math.floor(a + b)
  4948. },
  4949. average: function() {
  4950. var b, c, d, a = [];
  4951. for (b = 0; b < arguments.length - 0; b++) a[b] = arguments[b + 0];
  4952. for (c = 0, d = 0; d < a.length; d++) c += a[d];
  4953. return c / a.length
  4954. },
  4955. truncate: function(a) {
  4956. return a > 0 ? Math.floor(a) : Math.ceil(a)
  4957. },
  4958. shear: function(a) {
  4959. return a % 1
  4960. },
  4961. snapTo: function(a, b, c) {
  4962. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.round(a / b), c + a)
  4963. },
  4964. snapToFloor: function(a, b, c) {
  4965. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.floor(a / b), c + a)
  4966. },
  4967. snapToCeil: function(a, b, c) {
  4968. return "undefined" == typeof c && (c = 0), 0 === b ? a : (a -= c, a = b * Math.ceil(a / b), c + a)
  4969. },
  4970. snapToInArray: function(a, b, c) {
  4971. var d, e, f;
  4972. if ("undefined" == typeof c && (c = !0), c && b.sort(), a < b[0]) return b[0];
  4973. for (d = 1; b[d] < a;) d++;
  4974. return e = b[d - 1], f = d < b.length ? b[d] : Number.POSITIVE_INFINITY, a - e >= f - a ? f : e
  4975. },
  4976. roundTo: function(a, b, c) {
  4977. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  4978. var d = Math.pow(c, -b);
  4979. return Math.round(a * d) / d
  4980. },
  4981. floorTo: function(a, b, c) {
  4982. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  4983. var d = Math.pow(c, -b);
  4984. return Math.floor(a * d) / d
  4985. },
  4986. ceilTo: function(a, b, c) {
  4987. "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 10);
  4988. var d = Math.pow(c, -b);
  4989. return Math.ceil(a * d) / d
  4990. },
  4991. interpolateFloat: function(a, b, c) {
  4992. return (b - a) * c + a
  4993. },
  4994. angleBetween: function(a, b, c, d) {
  4995. return Math.atan2(d - b, c - a)
  4996. },
  4997. angleBetweenPoints: function(a, b) {
  4998. return Math.atan2(b.y - a.y, b.x - a.x)
  4999. },
  5000. reverseAngle: function(a) {
  5001. return this.normalizeAngle(a + Math.PI, !0)
  5002. },
  5003. normalizeAngle: function(a) {
  5004. return a %= 2 * Math.PI, a >= 0 ? a : a + 2 * Math.PI
  5005. },
  5006. normalizeLatitude: function(a) {
  5007. return Math.max(-90, Math.min(90, a))
  5008. },
  5009. normalizeLongitude: function(a) {
  5010. return 180 == a % 360 ? 180 : (a %= 360, -180 > a ? a + 360 : a > 180 ? a - 360 : a)
  5011. },
  5012. chanceRoll: function(a) {
  5013. return "undefined" == typeof a && (a = 50), 0 >= a ? !1 : a >= 100 ? !0 : 100 * Math.random() >= a ? !1 : !0
  5014. },
  5015. numberArray: function(a, b) {
  5016. var d, c = [];
  5017. for (d = a; b >= d; d++) c.push(d);
  5018. return c
  5019. },
  5020. maxAdd: function(a, b, c) {
  5021. return a += b, a > c && (a = c), a
  5022. },
  5023. minSub: function(a, b, c) {
  5024. return a -= b, c > a && (a = c), a
  5025. },
  5026. wrap: function(a, b, c) {
  5027. var e, d = c - b;
  5028. return 0 >= d ? 0 : (e = (a - b) % d, 0 > e && (e += d), e + b)
  5029. },
  5030. wrapValue: function(a, b, c) {
  5031. var d;
  5032. return a = Math.abs(a), b = Math.abs(b), c = Math.abs(c), d = (a + b) % c
  5033. },
  5034. limitValue: function(a, b, c) {
  5035. return b > a ? b : a > c ? c : a
  5036. },
  5037. randomSign: function() {
  5038. return Math.random() > .5 ? 1 : -1
  5039. },
  5040. isOdd: function(a) {
  5041. return 1 & a
  5042. },
  5043. isEven: function(a) {
  5044. return 1 & a ? !1 : !0
  5045. },
  5046. min: function() {
  5047. var a, b, c, d;
  5048. for (a = 1 === arguments.length && "object" == typeof arguments[0] ? arguments[0] : arguments, b = 1, c = 0, d = a.length; d > b; b++) a[b] < a[c] && (c = b);
  5049. return a[c]
  5050. },
  5051. max: function() {
  5052. var a, b, c, d;
  5053. for (a = 1 === arguments.length && "object" == typeof arguments[0] ? arguments[0] : arguments, b = 1, c = 0, d = a.length; d > b; b++) a[b] > a[c] && (c = b);
  5054. return a[c]
  5055. },
  5056. minProperty: function(a) {
  5057. var b, c, d, e;
  5058. for (b = 2 === arguments.length && "object" == typeof arguments[1] ? arguments[1] : arguments.slice(1), c = 1, d = 0, e = b.length; e > c; c++) b[c][a] < b[d][a] && (d = c);
  5059. return b[d][a]
  5060. },
  5061. maxProperty: function(a) {
  5062. var b, c, d, e;
  5063. for (b = 2 === arguments.length && "object" == typeof arguments[1] ? arguments[1] : arguments.slice(1), c = 1, d = 0, e = b.length; e > c; c++) b[c][a] > b[d][a] && (d = c);
  5064. return b[d][a]
  5065. },
  5066. wrapAngle: function(a, b) {
  5067. var c = b ? Math.PI / 180 : 1;
  5068. return this.wrap(a, -180 * c, 180 * c)
  5069. },
  5070. angleLimit: function(a, b, c) {
  5071. var d = a;
  5072. return a > c ? d = c : b > a && (d = b), d
  5073. },
  5074. linearInterpolation: function(a, b) {
  5075. var c = a.length - 1,
  5076. d = c * b,
  5077. e = Math.floor(d);
  5078. return 0 > b ? this.linear(a[0], a[1], d) : b > 1 ? this.linear(a[c], a[c - 1], c - d) : this.linear(a[e], a[e + 1 > c ? c : e + 1], d - e)
  5079. },
  5080. bezierInterpolation: function(a, b) {
  5081. var e, c = 0,
  5082. d = a.length - 1;
  5083. for (e = 0; d >= e; e++) c += Math.pow(1 - b, d - e) * Math.pow(b, e) * a[e] * this.bernstein(d, e);
  5084. return c
  5085. },
  5086. catmullRomInterpolation: function(a, b) {
  5087. var c = a.length - 1,
  5088. d = c * b,
  5089. e = Math.floor(d);
  5090. return a[0] === a[c] ? (0 > b && (e = Math.floor(d = c * (1 + b))), this.catmullRom(a[(e - 1 + c) % c], a[e], a[(e + 1) % c], a[(e + 2) % c], d - e)) : 0 > b ? a[0] - (this.catmullRom(a[0], a[0], a[1], a[1], -d) - a[0]) : b > 1 ? a[c] - (this.catmullRom(a[c], a[c], a[c - 1], a[c - 1], d - c) - a[c]) : this.catmullRom(a[e ? e - 1 : 0], a[e], a[e + 1 > c ? c : e + 1], a[e + 2 > c ? c : e + 2], d - e)
  5091. },
  5092. linear: function(a, b, c) {
  5093. return (b - a) * c + a
  5094. },
  5095. bernstein: function(a, b) {
  5096. return this.factorial(a) / this.factorial(b) / this.factorial(a - b)
  5097. },
  5098. factorial: function(a) {
  5099. if (0 === a) return 1;
  5100. for (var b = a; --a;) b *= a;
  5101. return b
  5102. },
  5103. catmullRom: function(a, b, c, d, e) {
  5104. var f = .5 * (c - a),
  5105. g = .5 * (d - b),
  5106. h = e * e,
  5107. i = e * h;
  5108. return (2 * b - 2 * c + f + g) * i + (-3 * b + 3 * c - 2 * f - g) * h + f * e + b
  5109. },
  5110. difference: function(a, b) {
  5111. return Math.abs(a - b)
  5112. },
  5113. getRandom: function(a, b, c) {
  5114. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a) {
  5115. var d = c;
  5116. if ((0 === d || d > a.length - b) && (d = a.length - b), d > 0) return a[b + Math.floor(Math.random() * d)]
  5117. }
  5118. return null
  5119. },
  5120. removeRandom: function(a, b, c) {
  5121. var d, e, f;
  5122. return "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = 0), null != a && (d = c, (0 === d || d > a.length - b) && (d = a.length - b), d > 0) ? (e = b + Math.floor(Math.random() * d), f = a.splice(e, 1), f[0]) : null
  5123. },
  5124. floor: function(a) {
  5125. var b = 0 | a;
  5126. return a > 0 ? b : b != a ? b - 1 : b
  5127. },
  5128. ceil: function(a) {
  5129. var b = 0 | a;
  5130. return a > 0 ? b != a ? b + 1 : b : b
  5131. },
  5132. sinCosGenerator: function(a, b, c, d) {
  5133. var e, f, g, h, i, j;
  5134. for ("undefined" == typeof b && (b = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1), e = b, f = c, g = d * Math.PI / a, h = [], i = [], j = 0; a > j; j++) f -= e * g, e += f * g, h[j] = f, i[j] = e;
  5135. return {
  5136. sin: i,
  5137. cos: h,
  5138. length: a
  5139. }
  5140. },
  5141. shift: function(a) {
  5142. var b = a.shift();
  5143. return a.push(b), b
  5144. },
  5145. shuffleArray: function(a) {
  5146. var b, c, d;
  5147. for (b = a.length - 1; b > 0; b--) c = Math.floor(Math.random() * (b + 1)), d = a[b], a[b] = a[c], a[c] = d;
  5148. return a
  5149. },
  5150. distance: function(a, b, c, d) {
  5151. var e = a - c,
  5152. f = b - d;
  5153. return Math.sqrt(e * e + f * f)
  5154. },
  5155. distancePow: function(a, b, c, d, e) {
  5156. return "undefined" == typeof e && (e = 2), Math.sqrt(Math.pow(c - a, e) + Math.pow(d - b, e))
  5157. },
  5158. distanceRounded: function(a, c, d, e) {
  5159. return Math.round(b.Math.distance(a, c, d, e))
  5160. },
  5161. clamp: function(a, b, c) {
  5162. return b > a ? b : a > c ? c : a
  5163. },
  5164. clampBottom: function(a, b) {
  5165. return b > a ? b : a
  5166. },
  5167. within: function(a, b, c) {
  5168. return Math.abs(a - b) <= c
  5169. },
  5170. mapLinear: function(a, b, c, d, e) {
  5171. return d + (a - b) * (e - d) / (c - b)
  5172. },
  5173. smoothstep: function(a, b, c) {
  5174. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * (3 - 2 * a)
  5175. },
  5176. smootherstep: function(a, b, c) {
  5177. return a = Math.max(0, Math.min(1, (a - b) / (c - b))), a * a * a * (a * (6 * a - 15) + 10)
  5178. },
  5179. sign: function(a) {
  5180. return 0 > a ? -1 : a > 0 ? 1 : 0
  5181. },
  5182. percent: function(a, b, c) {
  5183. return "undefined" == typeof c && (c = 0), a > b || c > b ? 1 : c > a || c > a ? 0 : (a - c) / b
  5184. },
  5185. degToRad: function() {
  5186. var a = Math.PI / 180;
  5187. return function(b) {
  5188. return b * a
  5189. }
  5190. }(),
  5191. radToDeg: function() {
  5192. var a = 180 / Math.PI;
  5193. return function(b) {
  5194. return b * a
  5195. }
  5196. }()
  5197. }, b.RandomDataGenerator = function(a) {
  5198. "undefined" == typeof a && (a = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.sow(a)
  5199. }, b.RandomDataGenerator.prototype = {
  5200. rnd: function() {
  5201. var a = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c;
  5202. return this.c = 0 | a, this.s0 = this.s1, this.s1 = this.s2, this.s2 = a - this.c, this.s2
  5203. },
  5204. sow: function(a) {
  5205. var b, c;
  5206. for ("undefined" == typeof a && (a = []), this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1, c = 0; b = a[c++];) this.s0 -= this.hash(b), this.s0 += ~~(this.s0 < 0), this.s1 -= this.hash(b), this.s1 += ~~(this.s1 < 0), this.s2 -= this.hash(b), this.s2 += ~~(this.s2 < 0)
  5207. },
  5208. hash: function(a) {
  5209. var b, c, d;
  5210. for (d = 4022871197, a = a.toString(), c = 0; c < a.length; c++) d += a.charCodeAt(c), b = .02519603282416938 * d, d = b >>> 0, b -= d, b *= d, d = b >>> 0, b -= d, d += 4294967296 * b;
  5211. return 2.3283064365386963e-10 * (d >>> 0)
  5212. },
  5213. integer: function() {
  5214. return 4294967296 * this.rnd.apply(this)
  5215. },
  5216. frac: function() {
  5217. return this.rnd.apply(this) + 1.1102230246251565e-16 * (0 | 2097152 * this.rnd.apply(this))
  5218. },
  5219. real: function() {
  5220. return this.integer() + this.frac()
  5221. },
  5222. integerInRange: function(a, b) {
  5223. return Math.floor(this.realInRange(0, b - a + 1) + a)
  5224. },
  5225. between: function(a, b) {
  5226. return this.integerInRange(a, b)
  5227. },
  5228. realInRange: function(a, b) {
  5229. return this.frac() * (b - a) + a
  5230. },
  5231. normal: function() {
  5232. return 1 - 2 * this.frac()
  5233. },
  5234. uuid: function() {
  5235. var a = "",
  5236. b = "";
  5237. for (b = a = ""; a++ < 36; b += ~a % 5 | 4 & 3 * a ? (15 ^ a ? 8 ^ this.frac() * (20 ^ a ? 16 : 4) : 4).toString(16) : "-");
  5238. return b
  5239. },
  5240. pick: function(a) {
  5241. return a[this.integerInRange(0, a.length - 1)]
  5242. },
  5243. weightedPick: function(a) {
  5244. return a[~~(Math.pow(this.frac(), 2) * (a.length - 1))]
  5245. },
  5246. timestamp: function(a, b) {
  5247. return this.realInRange(a || 9466848e5, b || 1577862e6)
  5248. },
  5249. angle: function() {
  5250. return this.integerInRange(-180, 180)
  5251. }
  5252. }, b.RandomDataGenerator.prototype.constructor = b.RandomDataGenerator, b.QuadTree = function(a, b, c, d, e, f, g) {
  5253. this.maxObjects = 10, this.maxLevels = 4, this.level = 0, this.bounds = {}, this.objects = [], this.nodes = [], this._empty = [], this.reset(a, b, c, d, e, f, g)
  5254. }, b.QuadTree.prototype = {
  5255. reset: function(a, b, c, d, e, f, g) {
  5256. this.maxObjects = e || 10, this.maxLevels = f || 4, this.level = g || 0, this.bounds = {
  5257. x: Math.round(a),
  5258. y: Math.round(b),
  5259. width: c,
  5260. height: d,
  5261. subWidth: Math.floor(c / 2),
  5262. subHeight: Math.floor(d / 2),
  5263. right: Math.round(a) + Math.floor(c / 2),
  5264. bottom: Math.round(b) + Math.floor(d / 2)
  5265. }, this.objects.length = 0, this.nodes.length = 0
  5266. },
  5267. populate: function(a) {
  5268. a.forEach(this.populateHandler, this, !0)
  5269. },
  5270. populateHandler: function(a) {
  5271. a.body && a.exists && this.insert(a.body)
  5272. },
  5273. split: function() {
  5274. this.nodes[0] = new b.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[1] = new b.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[2] = new b.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[3] = new b.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1)
  5275. },
  5276. insert: function(a) {
  5277. var c, b = 0;
  5278. if (null != this.nodes[0] && (c = this.getIndex(a), -1 !== c)) return this.nodes[c].insert(a), void 0;
  5279. if (this.objects.push(a), this.objects.length > this.maxObjects && this.level < this.maxLevels)
  5280. for (null == this.nodes[0] && this.split(); b < this.objects.length;) c = this.getIndex(this.objects[b]), -1 !== c ? this.nodes[c].insert(this.objects.splice(b, 1)[0]) : b++
  5281. },
  5282. getIndex: function(a) {
  5283. var b = -1;
  5284. return a.x < this.bounds.right && a.right < this.bounds.right ? a.y < this.bounds.bottom && a.bottom < this.bounds.bottom ? b = 1 : a.y > this.bounds.bottom && (b = 2) : a.x > this.bounds.right && (a.y < this.bounds.bottom && a.bottom < this.bounds.bottom ? b = 0 : a.y > this.bounds.bottom && (b = 3)), b
  5285. },
  5286. retrieve: function(a) {
  5287. var c, d;
  5288. if (a instanceof b.Rectangle) c = this.objects, d = this.getIndex(a);
  5289. else {
  5290. if (!a.body) return this._empty;
  5291. c = this.objects, d = this.getIndex(a.body)
  5292. }
  5293. return this.nodes[0] && (-1 !== d ? c = c.concat(this.nodes[d].retrieve(a)) : (c = c.concat(this.nodes[0].retrieve(a)), c = c.concat(this.nodes[1].retrieve(a)), c = c.concat(this.nodes[2].retrieve(a)), c = c.concat(this.nodes[3].retrieve(a)))), c
  5294. },
  5295. clear: function() {
  5296. this.objects.length = 0;
  5297. for (var a = this.nodes.length; a--;) this.nodes[a].clear(), this.nodes.splice(a, 1);
  5298. this.nodes.length = 0
  5299. }
  5300. }, b.QuadTree.prototype.constructor = b.QuadTree, b.Net = function(a) {
  5301. this.game = a
  5302. }, b.Net.prototype = {
  5303. getHostName: function() {
  5304. return window.location && window.location.hostname ? window.location.hostname : null
  5305. },
  5306. checkDomainName: function(a) {
  5307. return -1 !== window.location.hostname.indexOf(a)
  5308. },
  5309. updateQueryString: function(a, b, c, d) {
  5310. var e, f, g, h;
  5311. return "undefined" == typeof c && (c = !1), ("undefined" == typeof d || "" === d) && (d = window.location.href), e = "", f = new RegExp("([?|&])" + a + "=.*?(&|#|$)(.*)", "gi"), f.test(d) ? e = "undefined" != typeof b && null !== b ? d.replace(f, "$1" + a + "=" + b + "$2$3") : d.replace(f, "$1$3").replace(/(&|\?)$/, "") : "undefined" != typeof b && null !== b ? (g = -1 !== d.indexOf("?") ? "&" : "?", h = d.split("#"), d = h[0] + g + a + "=" + b, h[1] && (d += "#" + h[1]), e = d) : e = d, c ? (window.location.href = e, void 0) : e
  5312. },
  5313. getQueryString: function(a) {
  5314. var b, c, d, e;
  5315. "undefined" == typeof a && (a = ""), b = {}, c = location.search.substring(1).split("&");
  5316. for (d in c)
  5317. if (e = c[d].split("="), e.length > 1) {
  5318. if (a && a == this.decodeURI(e[0])) return this.decodeURI(e[1]);
  5319. b[this.decodeURI(e[0])] = this.decodeURI(e[1])
  5320. }
  5321. return b
  5322. },
  5323. decodeURI: function(a) {
  5324. return decodeURIComponent(a.replace(/\+/g, " "))
  5325. }
  5326. }, b.Net.prototype.constructor = b.Net, b.TweenManager = function(a) {
  5327. this.game = a, this._tweens = [], this._add = [], this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this)
  5328. }, b.TweenManager.prototype = {
  5329. getAll: function() {
  5330. return this._tweens
  5331. },
  5332. removeAll: function() {
  5333. for (var a = 0; a < this._tweens.length; a++) this._tweens[a].pendingDelete = !0;
  5334. this._add = []
  5335. },
  5336. add: function(a) {
  5337. a._manager = this, this._add.push(a)
  5338. },
  5339. create: function(a) {
  5340. return new b.Tween(a, this.game, this)
  5341. },
  5342. remove: function(a) {
  5343. var b = this._tweens.indexOf(a); - 1 !== b ? this._tweens[b].pendingDelete = !0 : (b = this._add.indexOf(a), -1 !== b && (this._add[b].pendingDelete = !0))
  5344. },
  5345. update: function() {
  5346. var c, a = this._add.length,
  5347. b = this._tweens.length;
  5348. if (0 === b && 0 === a) return !1;
  5349. for (c = 0; b > c;) this._tweens[c].update(this.game.time.now) ? c++ : (this._tweens.splice(c, 1), b--);
  5350. return a > 0 && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
  5351. },
  5352. isTweening: function(a) {
  5353. return this._tweens.some(function(b) {
  5354. return b._object === a
  5355. })
  5356. },
  5357. _pauseAll: function() {
  5358. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._pause()
  5359. },
  5360. _resumeAll: function() {
  5361. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a]._resume()
  5362. },
  5363. pauseAll: function() {
  5364. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].pause()
  5365. },
  5366. resumeAll: function() {
  5367. for (var a = this._tweens.length - 1; a >= 0; a--) this._tweens[a].resume(!0)
  5368. }
  5369. }, b.TweenManager.prototype.constructor = b.TweenManager, b.Tween = function(a, c, d) {
  5370. this._object = a, this.game = c, this._manager = d, this._valuesStart = {}, this._valuesEnd = {}, this._valuesStartRepeat = {}, this._duration = 1e3, this._repeat = 0, this._yoyo = !1, this._reversed = !1, this._delayTime = 0, this._startTime = null, this._easingFunction = b.Easing.Linear.None, this._interpolationFunction = b.Math.linearInterpolation, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, this._paused = !1, this._pausedTime = 0, this._codePaused = !1, this.pendingDelete = !1, this.onStart = new b.Signal, this.onLoop = new b.Signal, this.onComplete = new b.Signal, this.isRunning = !1
  5371. }, b.Tween.prototype = {
  5372. to: function(a, b, c, d, e, f, g) {
  5373. b = b || 1e3, c = c || null, d = d || !1, e = e || 0, f = f || 0, g = g || !1, g && 0 === f && (f = 1);
  5374. var h;
  5375. return this._parent ? (h = this._manager.create(this._object), this._lastChild.chain(h), this._lastChild = h) : (h = this, this._parent = this, this._lastChild = this), h._repeat = f, h._duration = b, h._valuesEnd = a, null !== c && (h._easingFunction = c), e > 0 && (h._delayTime = e), h._yoyo = g, d ? this.start() : this
  5376. },
  5377. from: function(a, b, c, d, e, f, g) {
  5378. var i, h = {};
  5379. for (i in a) h[i] = this._object[i], this._object[i] = a[i];
  5380. return this.to(h, b, c, d, e, f, g)
  5381. },
  5382. start: function() {
  5383. if (null !== this.game && null !== this._object) {
  5384. this._manager.add(this), this.isRunning = !0, this._onStartCallbackFired = !1, this._startTime = this.game.time.now + this._delayTime;
  5385. for (var a in this._valuesEnd) {
  5386. if (Array.isArray(this._valuesEnd[a])) {
  5387. if (0 === this._valuesEnd[a].length) continue;
  5388. this._valuesEnd[a] = [this._object[a]].concat(this._valuesEnd[a])
  5389. }
  5390. this._valuesStart[a] = this._object[a], Array.isArray(this._valuesStart[a]) || (this._valuesStart[a] *= 1), this._valuesStartRepeat[a] = this._valuesStart[a] || 0
  5391. }
  5392. return this
  5393. }
  5394. },
  5395. generateData: function(a, b) {
  5396. var c, d, e, f, g, h, i, j, k, l, m;
  5397. if (null === this.game || null === this._object) return null;
  5398. this._startTime = 0;
  5399. for (c in this._valuesEnd) {
  5400. if (Array.isArray(this._valuesEnd[c])) {
  5401. if (0 === this._valuesEnd[c].length) continue;
  5402. this._valuesEnd[c] = [this._object[c]].concat(this._valuesEnd[c])
  5403. }
  5404. this._valuesStart[c] = this._object[c], Array.isArray(this._valuesStart[c]) || (this._valuesStart[c] *= 1), this._valuesStartRepeat[c] = this._valuesStart[c] || 0
  5405. }
  5406. for (d = 0, e = Math.floor(a * (this._duration / 1e3)), f = this._duration / e, g = []; e--;) {
  5407. h = (d - this._startTime) / this._duration, h = h > 1 ? 1 : h, i = this._easingFunction(h), j = {};
  5408. for (c in this._valuesEnd) k = this._valuesStart[c] || 0, l = this._valuesEnd[c], l instanceof Array ? j[c] = this._interpolationFunction(l, i) : ("string" == typeof l && (l = k + parseFloat(l, 10)), "number" == typeof l && (j[c] = k + (l - k) * i));
  5409. g.push(j), d += f
  5410. }
  5411. return this._yoyo && (m = g.slice(), m.reverse(), g = g.concat(m)), "undefined" != typeof b ? b = b.concat(g) : g
  5412. },
  5413. stop: function() {
  5414. return this.isRunning = !1, this._onUpdateCallback = null, this._manager.remove(this), this
  5415. },
  5416. delay: function(a) {
  5417. return this._delayTime = a, this
  5418. },
  5419. repeat: function(a) {
  5420. return this._repeat = a, this
  5421. },
  5422. yoyo: function(a) {
  5423. return this._yoyo = a, a && 0 === this._repeat && (this._repeat = 1), this
  5424. },
  5425. easing: function(a) {
  5426. return this._easingFunction = a, this
  5427. },
  5428. interpolation: function(a) {
  5429. return this._interpolationFunction = a, this
  5430. },
  5431. chain: function() {
  5432. return this._chainedTweens = arguments, this
  5433. },
  5434. loop: function() {
  5435. return this._lastChild.chain(this), this
  5436. },
  5437. onUpdateCallback: function(a, b) {
  5438. return this._onUpdateCallback = a, this._onUpdateCallbackContext = b, this
  5439. },
  5440. pause: function() {
  5441. this._codePaused = !0, this._paused = !0, this._pausedTime = this.game.time.now
  5442. },
  5443. _pause: function() {
  5444. this._codePaused || (this._paused = !0, this._pausedTime = this.game.time.now)
  5445. },
  5446. resume: function() {
  5447. this._paused && (this._paused = !1, this._codePaused = !1, this._startTime += this.game.time.now - this._pausedTime)
  5448. },
  5449. _resume: function() {
  5450. this._codePaused || (this._startTime += this.game.time.pauseDuration, this._paused = !1)
  5451. },
  5452. update: function(a) {
  5453. var b, c, d, e, f, g, h, i;
  5454. if (this.pendingDelete) return !1;
  5455. if (this._paused || a < this._startTime) return !0;
  5456. if (a < this._startTime) return !0;
  5457. this._onStartCallbackFired === !1 && (this.onStart.dispatch(this._object), this._onStartCallbackFired = !0), c = (a - this._startTime) / this._duration, c = c > 1 ? 1 : c, d = this._easingFunction(c);
  5458. for (b in this._valuesEnd) e = this._valuesStart[b] || 0, f = this._valuesEnd[b], f instanceof Array ? this._object[b] = this._interpolationFunction(f, d) : ("string" == typeof f && (f = e + parseFloat(f, 10)), "number" == typeof f && (this._object[b] = e + (f - e) * d));
  5459. if (null !== this._onUpdateCallback && (this._onUpdateCallback.call(this._onUpdateCallbackContext, this, d), !this.isRunning)) return !1;
  5460. if (1 == c) {
  5461. if (this._repeat > 0) {
  5462. isFinite(this._repeat) && this._repeat--;
  5463. for (b in this._valuesStartRepeat) "string" == typeof this._valuesEnd[b] && (this._valuesStartRepeat[b] = this._valuesStartRepeat[b] + parseFloat(this._valuesEnd[b], 10)), this._yoyo && (g = this._valuesStartRepeat[b], this._valuesStartRepeat[b] = this._valuesEnd[b], this._valuesEnd[b] = g), this._valuesStart[b] = this._valuesStartRepeat[b];
  5464. return this._yoyo && (this._reversed = !this._reversed), this._startTime = a + this._delayTime, this.onLoop.dispatch(this._object), !0
  5465. }
  5466. for (this.isRunning = !1, this.onComplete.dispatch(this._object), h = 0, i = this._chainedTweens.length; i > h; h++) this._chainedTweens[h].start(a);
  5467. return !1
  5468. }
  5469. return !0
  5470. }
  5471. }, b.Tween.prototype.constructor = b.Tween, b.Easing = {
  5472. Linear: {
  5473. None: function(a) {
  5474. return a
  5475. }
  5476. },
  5477. Quadratic: {
  5478. In: function(a) {
  5479. return a * a
  5480. },
  5481. Out: function(a) {
  5482. return a * (2 - a)
  5483. },
  5484. InOut: function(a) {
  5485. return (a *= 2) < 1 ? .5 * a * a : -.5 * (--a * (a - 2) - 1)
  5486. }
  5487. },
  5488. Cubic: {
  5489. In: function(a) {
  5490. return a * a * a
  5491. },
  5492. Out: function(a) {
  5493. return --a * a * a + 1
  5494. },
  5495. InOut: function(a) {
  5496. return (a *= 2) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2)
  5497. }
  5498. },
  5499. Quartic: {
  5500. In: function(a) {
  5501. return a * a * a * a
  5502. },
  5503. Out: function(a) {
  5504. return 1 - --a * a * a * a
  5505. },
  5506. InOut: function(a) {
  5507. return (a *= 2) < 1 ? .5 * a * a * a * a : -.5 * ((a -= 2) * a * a * a - 2)
  5508. }
  5509. },
  5510. Quintic: {
  5511. In: function(a) {
  5512. return a * a * a * a * a
  5513. },
  5514. Out: function(a) {
  5515. return --a * a * a * a * a + 1
  5516. },
  5517. InOut: function(a) {
  5518. return (a *= 2) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2)
  5519. }
  5520. },
  5521. Sinusoidal: {
  5522. In: function(a) {
  5523. return 1 - Math.cos(a * Math.PI / 2)
  5524. },
  5525. Out: function(a) {
  5526. return Math.sin(a * Math.PI / 2)
  5527. },
  5528. InOut: function(a) {
  5529. return .5 * (1 - Math.cos(Math.PI * a))
  5530. }
  5531. },
  5532. Exponential: {
  5533. In: function(a) {
  5534. return 0 === a ? 0 : Math.pow(1024, a - 1)
  5535. },
  5536. Out: function(a) {
  5537. return 1 === a ? 1 : 1 - Math.pow(2, -10 * a)
  5538. },
  5539. InOut: function(a) {
  5540. return 0 === a ? 0 : 1 === a ? 1 : (a *= 2) < 1 ? .5 * Math.pow(1024, a - 1) : .5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  5541. }
  5542. },
  5543. Circular: {
  5544. In: function(a) {
  5545. return 1 - Math.sqrt(1 - a * a)
  5546. },
  5547. Out: function(a) {
  5548. return Math.sqrt(1 - --a * a)
  5549. },
  5550. InOut: function(a) {
  5551. return (a *= 2) < 1 ? -.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  5552. }
  5553. },
  5554. Elastic: {
  5555. In: function(a) {
  5556. var b, c = .1,
  5557. d = .4;
  5558. return 0 === a ? 0 : 1 === a ? 1 : (!c || 1 > c ? (c = 1, b = d / 4) : b = d * Math.asin(1 / c) / (2 * Math.PI), -(c * Math.pow(2, 10 * (a -= 1)) * Math.sin((a - b) * 2 * Math.PI / d)))
  5559. },
  5560. Out: function(a) {
  5561. var b, c = .1,
  5562. d = .4;
  5563. return 0 === a ? 0 : 1 === a ? 1 : (!c || 1 > c ? (c = 1, b = d / 4) : b = d * Math.asin(1 / c) / (2 * Math.PI), c * Math.pow(2, -10 * a) * Math.sin((a - b) * 2 * Math.PI / d) + 1)
  5564. },
  5565. InOut: function(a) {
  5566. var b, c = .1,
  5567. d = .4;
  5568. return 0 === a ? 0 : 1 === a ? 1 : (!c || 1 > c ? (c = 1, b = d / 4) : b = d * Math.asin(1 / c) / (2 * Math.PI), (a *= 2) < 1 ? -.5 * c * Math.pow(2, 10 * (a -= 1)) * Math.sin((a - b) * 2 * Math.PI / d) : .5 * c * Math.pow(2, -10 * (a -= 1)) * Math.sin((a - b) * 2 * Math.PI / d) + 1)
  5569. }
  5570. },
  5571. Back: {
  5572. In: function(a) {
  5573. var b = 1.70158;
  5574. return a * a * ((b + 1) * a - b)
  5575. },
  5576. Out: function(a) {
  5577. var b = 1.70158;
  5578. return --a * a * ((b + 1) * a + b) + 1
  5579. },
  5580. InOut: function(a) {
  5581. var b = 2.5949095;
  5582. return (a *= 2) < 1 ? .5 * a * a * ((b + 1) * a - b) : .5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
  5583. }
  5584. },
  5585. Bounce: {
  5586. In: function(a) {
  5587. return 1 - b.Easing.Bounce.Out(1 - a)
  5588. },
  5589. Out: function(a) {
  5590. return 1 / 2.75 > a ? 7.5625 * a * a : 2 / 2.75 > a ? 7.5625 * (a -= 1.5 / 2.75) * a + .75 : 2.5 / 2.75 > a ? 7.5625 * (a -= 2.25 / 2.75) * a + .9375 : 7.5625 * (a -= 2.625 / 2.75) * a + .984375
  5591. },
  5592. InOut: function(a) {
  5593. return .5 > a ? .5 * b.Easing.Bounce.In(2 * a) : .5 * b.Easing.Bounce.Out(2 * a - 1) + .5
  5594. }
  5595. }
  5596. }, b.Time = function(a) {
  5597. this.game = a, this.time = 0, this.now = 0, this.elapsed = 0, this.pausedTime = 0, this.advancedTiming = !1, this.fps = 0, this.fpsMin = 1e3, this.fpsMax = 0, this.msMin = 1e3, this.msMax = 0, this.physicsElapsed = 0, this.deltaCap = 0, this.timeCap = 1e3, this.frames = 0, this.pauseDuration = 0, this.timeToCall = 0, this.lastTime = 0, this.events = new b.Timer(this.game, !1), this._started = 0, this._timeLastSecond = 0, this._pauseStarted = 0, this._justResumed = !1, this._timers = [], this._len = 0, this._i = 0
  5598. }, b.Time.prototype = {
  5599. boot: function() {
  5600. this._started = Date.now(), this.events.start()
  5601. },
  5602. add: function(a) {
  5603. return this._timers.push(a), a
  5604. },
  5605. create: function(a) {
  5606. "undefined" == typeof a && (a = !0);
  5607. var c = new b.Timer(this.game, a);
  5608. return this._timers.push(c), c
  5609. },
  5610. removeAll: function() {
  5611. for (var a = 0; a < this._timers.length; a++) this._timers[a].destroy();
  5612. this._timers = [], this.events.removeAll()
  5613. },
  5614. update: function(a) {
  5615. if (this.now = a, this.timeToCall = this.game.math.max(0, 16 - (a - this.lastTime)), this.elapsed = this.now - this.time, this.elapsed > this.timeCap && (this.elapsed = 1 / 60), this.physicsElapsed = this.elapsed / 1e3 || 1 / 60, this.deltaCap > 0 && this.physicsElapsed > this.deltaCap && (this.physicsElapsed = this.deltaCap), this.advancedTiming && (this.msMin = this.game.math.min(this.msMin, this.elapsed), this.msMax = this.game.math.max(this.msMax, this.elapsed), this.frames++, this.now > this._timeLastSecond + 1e3 && (this.fps = Math.round(1e3 * this.frames / (this.now - this._timeLastSecond)), this.fpsMin = this.game.math.min(this.fpsMin, this.fps), this.fpsMax = this.game.math.max(this.fpsMax, this.fps), this._timeLastSecond = this.now, this.frames = 0)), this.time = this.now, this.lastTime = a + this.timeToCall, !this.game.paused)
  5616. for (this.events.update(this.now), this._i = 0, this._len = this._timers.length; this._i < this._len;) this._timers[this._i].update(this.now) ? this._i++ : (this._timers.splice(this._i, 1), this._len--)
  5617. },
  5618. gamePaused: function() {
  5619. this._pauseStarted = this.now, this.events.pause();
  5620. for (var a = this._timers.length; a--;) this._timers[a]._pause()
  5621. },
  5622. gameResumed: function() {
  5623. this.time = this.now = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume();
  5624. for (var a = this._timers.length; a--;) this._timers[a]._resume()
  5625. },
  5626. totalElapsedSeconds: function() {
  5627. return .001 * (this.now - this._started)
  5628. },
  5629. elapsedSince: function(a) {
  5630. return this.now - a
  5631. },
  5632. elapsedSecondsSince: function(a) {
  5633. return .001 * (this.now - a)
  5634. },
  5635. reset: function() {
  5636. this._started = this.now, this.removeAll()
  5637. }
  5638. }, b.Time.prototype.constructor = b.Time, b.Timer = function(a, c) {
  5639. "undefined" == typeof c && (c = !0), this.game = a, this.running = !1, this.autoDestroy = c, this.expired = !1, this.elapsed = 0, this.events = [], this.onComplete = new b.Signal, this.nextTick = 0, this.timeCap = 1e3, this.paused = !1, this._codePaused = !1, this._started = 0, this._pauseStarted = 0, this._pauseTotal = 0, this._now = Date.now(), this._len = 0, this._marked = 0, this._i = 0, this._diff = 0, this._newTick = 0
  5640. }, b.Timer.MINUTE = 6e4, b.Timer.SECOND = 1e3, b.Timer.HALF = 500, b.Timer.QUARTER = 250, b.Timer.prototype = {
  5641. create: function(a, c, d, e, f, g) {
  5642. var i, h = a;
  5643. return h += 0 === this._now ? this.game.time.now : this._now, i = new b.TimerEvent(this, a, h, d, c, e, f, g), this.events.push(i), this.order(), this.expired = !1, i
  5644. },
  5645. add: function(a, b, c) {
  5646. return this.create(a, !1, 0, b, c, Array.prototype.splice.call(arguments, 3))
  5647. },
  5648. repeat: function(a, b, c, d) {
  5649. return this.create(a, !1, b, c, d, Array.prototype.splice.call(arguments, 4))
  5650. },
  5651. loop: function(a, b, c) {
  5652. return this.create(a, !0, 0, b, c, Array.prototype.splice.call(arguments, 3))
  5653. },
  5654. start: function(a) {
  5655. if (!this.running) {
  5656. this._started = this.game.time.now + (a || 0), this.running = !0;
  5657. for (var b = 0; b < this.events.length; b++) this.events[b].tick = this.events[b].delay + this._started
  5658. }
  5659. },
  5660. stop: function(a) {
  5661. this.running = !1, "undefined" == typeof a && (a = !0), a && (this.events.length = 0)
  5662. },
  5663. remove: function(a) {
  5664. for (var b = 0; b < this.events.length; b++)
  5665. if (this.events[b] === a) return this.events[b].pendingDelete = !0, !0;
  5666. return !1
  5667. },
  5668. order: function() {
  5669. this.events.length > 0 && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick)
  5670. },
  5671. sortHandler: function(a, b) {
  5672. return a.tick < b.tick ? -1 : a.tick > b.tick ? 1 : 0
  5673. },
  5674. clearPendingEvents: function() {
  5675. for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
  5676. this._len = this.events.length, this._i = 0
  5677. },
  5678. update: function(a) {
  5679. if (this.paused) return !0;
  5680. if (this.elapsed = a - this._now, this._now = a, this.elapsed > this.timeCap && this.adjustEvents(a - this.elapsed), this._marked = 0, this.clearPendingEvents(), this.running && this._now >= this.nextTick && this._len > 0) {
  5681. for (; this._i < this._len && this.running && this._now >= this.events[this._i].tick;) this._newTick = this._now + this.events[this._i].delay - (this._now - this.events[this._i].tick), this._newTick < 0 && (this._newTick = this._now + this.events[this._i].delay), this.events[this._i].loop === !0 ? (this.events[this._i].tick = this._newTick, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)) : this.events[this._i].repeatCount > 0 ? (this.events[this._i].repeatCount--, this.events[this._i].tick = this._newTick, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)) : (this._marked++, this.events[this._i].pendingDelete = !0, this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args)), this._i++;
  5682. this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
  5683. }
  5684. return this.expired && this.autoDestroy ? !1 : !0
  5685. },
  5686. pause: function() {
  5687. this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.now, this.paused = !0))
  5688. },
  5689. _pause: function() {
  5690. !this.paused && this.running && (this._pauseStarted = this.game.time.now, this.paused = !0)
  5691. },
  5692. adjustEvents: function(a) {
  5693. var b, c, d;
  5694. for (b = 0; b < this.events.length; b++) this.events[b].pendingDelete || (c = this.events[b].tick - a, 0 > c && (c = 0), this.events[b].tick = this._now + c);
  5695. d = this.nextTick - a, this.nextTick = 0 > d ? this._now : this._now + d
  5696. },
  5697. resume: function() {
  5698. if (this.paused) {
  5699. var a = this.game.time.now;
  5700. this._pauseTotal += a - this._now, this._now = a, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
  5701. }
  5702. },
  5703. _resume: function() {
  5704. this._codePaused || this.resume()
  5705. },
  5706. removeAll: function() {
  5707. this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0
  5708. },
  5709. destroy: function() {
  5710. this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0
  5711. }
  5712. }, Object.defineProperty(b.Timer.prototype, "next", {
  5713. get: function() {
  5714. return this.nextTick
  5715. }
  5716. }), Object.defineProperty(b.Timer.prototype, "duration", {
  5717. get: function() {
  5718. return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0
  5719. }
  5720. }), Object.defineProperty(b.Timer.prototype, "length", {
  5721. get: function() {
  5722. return this.events.length
  5723. }
  5724. }), Object.defineProperty(b.Timer.prototype, "ms", {
  5725. get: function() {
  5726. return this.running ? this._now - this._started - this._pauseTotal : 0
  5727. }
  5728. }), Object.defineProperty(b.Timer.prototype, "seconds", {
  5729. get: function() {
  5730. return this.running ? .001 * this.ms : 0
  5731. }
  5732. }), b.Timer.prototype.constructor = b.Timer, b.TimerEvent = function(a, b, c, d, e, f, g, h) {
  5733. this.timer = a, this.delay = b, this.tick = c, this.repeatCount = d - 1, this.loop = e, this.callback = f, this.callbackContext = g, this.args = h, this.pendingDelete = !1
  5734. }, b.TimerEvent.prototype.constructor = b.TimerEvent, b.AnimationManager = function(a) {
  5735. this.sprite = a, this.game = a.game, this.currentFrame = null, this.currentAnim = null, this.updateIfVisible = !0, this.isLoaded = !1, this._frameData = null, this._anims = {}, this._outputFrames = []
  5736. }, b.AnimationManager.prototype = {
  5737. loadFrameData: function(a, b) {
  5738. if (this.isLoaded)
  5739. for (var c in this._anims) this._anims[c].updateFrameData(a);
  5740. return this._frameData = a, "undefined" == typeof b || null === b ? this.frame = 0 : "string" == typeof b ? this.frameName = b : this.frame = b, this.isLoaded = !0, this._frameData ? !0 : !1
  5741. },
  5742. add: function(a, c, d, e, f) {
  5743. return null === this._frameData ? (console.warn("No FrameData available for Phaser.Animation " + a), void 0) : (c = c || [], d = d || 60, "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = c && "number" == typeof c[0] ? !0 : !1), null === this.sprite.events.onAnimationStart && (this.sprite.events.onAnimationStart = new b.Signal, this.sprite.events.onAnimationComplete = new b.Signal, this.sprite.events.onAnimationLoop = new b.Signal), this._outputFrames.length = 0, this._frameData.getFrameIndexes(c, f, this._outputFrames), this._anims[a] = new b.Animation(this.game, this.sprite, a, this._frameData, this._outputFrames, d, e), this.currentAnim = this._anims[a], this.currentFrame = this.currentAnim.currentFrame, this.sprite.__tilePattern && (this.sprite.__tilePattern = !1, this.tilingTexture = !1), this._anims[a])
  5744. },
  5745. validateFrames: function(a, b) {
  5746. "undefined" == typeof b && (b = !0);
  5747. for (var c = 0; c < a.length; c++)
  5748. if (b === !0) {
  5749. if (a[c] > this._frameData.total) return !1
  5750. } else if (this._frameData.checkFrameName(a[c]) === !1) return !1;
  5751. return !0
  5752. },
  5753. play: function(a, b, c, d) {
  5754. return this._anims[a] ? this.currentAnim === this._anims[a] ? this.currentAnim.isPlaying === !1 ? (this.currentAnim.paused = !1, this.currentAnim.play(b, c, d)) : this.currentAnim : (this.currentAnim && this.currentAnim.isPlaying && this.currentAnim.stop(), this.currentAnim = this._anims[a], this.currentAnim.paused = !1, this.currentFrame = this.currentAnim.currentFrame, this.currentAnim.play(b, c, d)) : void 0
  5755. },
  5756. stop: function(a, b) {
  5757. "undefined" == typeof b && (b = !1), "string" == typeof a ? this._anims[a] && (this.currentAnim = this._anims[a], this.currentAnim.stop(b)) : this.currentAnim && this.currentAnim.stop(b)
  5758. },
  5759. update: function() {
  5760. return this.updateIfVisible && !this.sprite.visible ? !1 : this.currentAnim && this.currentAnim.update() === !0 ? (this.currentFrame = this.currentAnim.currentFrame, !0) : !1
  5761. },
  5762. next: function(a) {
  5763. this.currentAnim && (this.currentAnim.next(a), this.currentFrame = this.currentAnim.currentFrame)
  5764. },
  5765. previous: function(a) {
  5766. this.currentAnim && (this.currentAnim.previous(a), this.currentFrame = this.currentAnim.currentFrame)
  5767. },
  5768. getAnimation: function(a) {
  5769. return "string" == typeof a && this._anims[a] ? this._anims[a] : null
  5770. },
  5771. refreshFrame: function() {
  5772. this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)
  5773. },
  5774. destroy: function() {
  5775. var a = null;
  5776. for (a in this._anims) this._anims.hasOwnProperty(a) && this._anims[a].destroy();
  5777. this._anims = {}, this._frameData = null, this._frameIndex = 0, this.currentAnim = null, this.currentFrame = null
  5778. }
  5779. }, b.AnimationManager.prototype.constructor = b.AnimationManager, Object.defineProperty(b.AnimationManager.prototype, "frameData", {
  5780. get: function() {
  5781. return this._frameData
  5782. }
  5783. }), Object.defineProperty(b.AnimationManager.prototype, "frameTotal", {
  5784. get: function() {
  5785. return this._frameData ? this._frameData.total : -1
  5786. }
  5787. }), Object.defineProperty(b.AnimationManager.prototype, "paused", {
  5788. get: function() {
  5789. return this.currentAnim.isPaused
  5790. },
  5791. set: function(a) {
  5792. this.currentAnim.paused = a
  5793. }
  5794. }), Object.defineProperty(b.AnimationManager.prototype, "frame", {
  5795. get: function() {
  5796. return this.currentFrame ? this._frameIndex : void 0
  5797. },
  5798. set: function(a) {
  5799. "number" == typeof a && this._frameData && null !== this._frameData.getFrame(a) && (this.currentFrame = this._frameData.getFrame(a), this.currentFrame && (this._frameIndex = a, this.sprite.setFrame(this.currentFrame), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1)))
  5800. }
  5801. }), Object.defineProperty(b.AnimationManager.prototype, "frameName", {
  5802. get: function() {
  5803. return this.currentFrame ? this.currentFrame.name : void 0
  5804. },
  5805. set: function(a) {
  5806. "string" == typeof a && this._frameData && null !== this._frameData.getFrameByName(a) ? (this.currentFrame = this._frameData.getFrameByName(a), this.currentFrame && (this._frameIndex = this.currentFrame.index, this.sprite.setFrame(this.currentFrame), this.sprite.__tilePattern && (this.__tilePattern = !1, this.tilingTexture = !1))) : console.warn("Cannot set frameName: " + a)
  5807. }
  5808. }), b.Animation = function(a, c, d, e, f, g, h) {
  5809. this.game = a, this._parent = c, this._frameData = e, this.name = d, this._frames = [], this._frames = this._frames.concat(f), this.delay = 1e3 / g, this.loop = h, this.loopCount = 0, this.killOnComplete = !1, this.isFinished = !1, this.isPlaying = !1, this.isPaused = !1, this._pauseStartTime = 0, this._frameIndex = 0, this._frameDiff = 0, this._frameSkip = 1, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.onStart = new b.Signal, this.onComplete = new b.Signal, this.onLoop = new b.Signal, this.game.onPause.add(this.onPause, this), this.game.onResume.add(this.onResume, this)
  5810. }, b.Animation.prototype = {
  5811. play: function(a, b, c) {
  5812. return "number" == typeof a && (this.delay = 1e3 / a), "boolean" == typeof b && (this.loop = b), "undefined" != typeof c && (this.killOnComplete = c), this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.now, this._timeNextFrame = this.game.time.now + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1), this._parent.events.onAnimationStart.dispatch(this._parent, this), this.onStart.dispatch(this._parent, this), this
  5813. },
  5814. restart: function() {
  5815. this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.now, this._timeNextFrame = this.game.time.now + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), this.onStart.dispatch(this._parent, this)
  5816. },
  5817. setFrame: function(a, b) {
  5818. var c, d;
  5819. if ("undefined" == typeof b && (b = !1), "string" == typeof a)
  5820. for (d = 0; d < this._frames.length; d++) this._frameData.getFrame(this._frames[d]).name === a && (c = d);
  5821. else if ("number" == typeof a)
  5822. if (b) c = a;
  5823. else
  5824. for (d = 0; d < this._frames.length; d++) this.frames[d] === c && (c = d);
  5825. c && (this._frameIndex = c - 1, this._timeNextFrame = this.game.time.now, this.update())
  5826. },
  5827. stop: function(a, b) {
  5828. "undefined" == typeof a && (a = !1), "undefined" == typeof b && (b = !1), this.isPlaying = !1, this.isFinished = !0, this.paused = !1, a && (this.currentFrame = this._frameData.getFrame(this._frames[0]), this._parent.setFrame(this.currentFrame)), b && (this._parent.events.onAnimationComplete.dispatch(this._parent, this), this.onComplete.dispatch(this._parent, this))
  5829. },
  5830. onPause: function() {
  5831. this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.now)
  5832. },
  5833. onResume: function() {
  5834. this.isPlaying && (this._timeNextFrame = this.game.time.now + this._frameDiff)
  5835. },
  5836. update: function() {
  5837. return this.isPaused ? !1 : this.isPlaying && this.game.time.now >= this._timeNextFrame ? (this._frameSkip = 1, this._frameDiff = this.game.time.now - this._timeNextFrame, this._timeLastFrame = this.game.time.now, this._frameDiff > this.delay && (this._frameSkip = Math.floor(this._frameDiff / this.delay), this._frameDiff -= this._frameSkip * this.delay), this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff), this._frameIndex += this._frameSkip, this._frameIndex >= this._frames.length && (this.loop ? (this._frameIndex %= this._frames.length, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.loopCount++, this._parent.events.onAnimationLoop.dispatch(this._parent, this), this.onLoop.dispatch(this._parent, this)) : this.complete()), this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1)), !0) : !1
  5838. },
  5839. next: function(a) {
  5840. "undefined" == typeof a && (a = 1);
  5841. var b = this._frameIndex + a;
  5842. b >= this._frames.length && (this.loop ? b %= this._frames.length : b = this._frames.length - 1), b !== this._frameIndex && (this._frameIndex = b, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1)))
  5843. },
  5844. previous: function(a) {
  5845. "undefined" == typeof a && (a = 1);
  5846. var b = this._frameIndex - a;
  5847. 0 > b && (this.loop ? b = this._frames.length + b : b++), b !== this._frameIndex && (this._frameIndex = b, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (this._parent.setFrame(this.currentFrame), this._parent.__tilePattern && (this._parent.__tilePattern = !1, this._parent.tilingTexture = !1)))
  5848. },
  5849. updateFrameData: function(a) {
  5850. this._frameData = a, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null
  5851. },
  5852. destroy: function() {
  5853. this.game.onPause.remove(this.onPause, this), this.game.onResume.remove(this.onResume, this), this.game = null, this._parent = null, this._frames = null, this._frameData = null, this.currentFrame = null, this.isPlaying = !1, this.onStart.dispose(), this.onLoop.dispose(), this.onComplete.dispose()
  5854. },
  5855. complete: function() {
  5856. this.isPlaying = !1, this.isFinished = !0, this.paused = !1, this._parent.events.onAnimationComplete.dispatch(this._parent, this), this.onComplete.dispatch(this._parent, this), this.killOnComplete && this._parent.kill()
  5857. }
  5858. }, b.Animation.prototype.constructor = b.Animation, Object.defineProperty(b.Animation.prototype, "paused", {
  5859. get: function() {
  5860. return this.isPaused
  5861. },
  5862. set: function(a) {
  5863. this.isPaused = a, a ? this._pauseStartTime = this.game.time.now : this.isPlaying && (this._timeNextFrame = this.game.time.now + this.delay)
  5864. }
  5865. }), Object.defineProperty(b.Animation.prototype, "frameTotal", {
  5866. get: function() {
  5867. return this._frames.length
  5868. }
  5869. }), Object.defineProperty(b.Animation.prototype, "frame", {
  5870. get: function() {
  5871. return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex
  5872. },
  5873. set: function(a) {
  5874. this.currentFrame = this._frameData.getFrame(this._frames[a]), null !== this.currentFrame && (this._frameIndex = a, this._parent.setFrame(this.currentFrame))
  5875. }
  5876. }), Object.defineProperty(b.Animation.prototype, "speed", {
  5877. get: function() {
  5878. return Math.round(1e3 / this.delay)
  5879. },
  5880. set: function(a) {
  5881. a >= 1 && (this.delay = 1e3 / a)
  5882. }
  5883. }), b.Animation.generateFrameNames = function(a, c, d, e, f) {
  5884. var g, h, i;
  5885. if ("undefined" == typeof e && (e = ""), g = [], h = "", d > c)
  5886. for (i = c; d >= i; i++) h = "number" == typeof f ? b.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  5887. else
  5888. for (i = c; i >= d; i--) h = "number" == typeof f ? b.Utils.pad(i.toString(), f, "0", 1) : i.toString(), h = a + h + e, g.push(h);
  5889. return g
  5890. }, b.Frame = function(a, c, d, e, f, g, h) {
  5891. this.index = a, this.x = c, this.y = d, this.width = e, this.height = f, this.name = g, this.uuid = h, this.centerX = Math.floor(e / 2), this.centerY = Math.floor(f / 2), this.distance = b.Math.distance(0, 0, e, f), this.rotated = !1, this.rotationDirection = "cw", this.trimmed = !1, this.sourceSizeW = e, this.sourceSizeH = f, this.spriteSourceSizeX = 0, this.spriteSourceSizeY = 0, this.spriteSourceSizeW = 0, this.spriteSourceSizeH = 0, this.right = this.x + this.width, this.bottom = this.y + this.height
  5892. }, b.Frame.prototype = {
  5893. setTrim: function(a, b, c, d, e, f, g) {
  5894. this.trimmed = a, a && (this.sourceSizeW = b, this.sourceSizeH = c, this.centerX = Math.floor(b / 2), this.centerY = Math.floor(c / 2), this.spriteSourceSizeX = d, this.spriteSourceSizeY = e, this.spriteSourceSizeW = f, this.spriteSourceSizeH = g)
  5895. },
  5896. getRect: function(a) {
  5897. return "undefined" == typeof a ? a = new b.Rectangle(this.x, this.y, this.width, this.height) : a.setTo(this.x, this.y, this.width, this.height), a
  5898. }
  5899. }, b.Frame.prototype.constructor = b.Frame, b.FrameData = function() {
  5900. this._frames = [], this._frameNames = []
  5901. }, b.FrameData.prototype = {
  5902. addFrame: function(a) {
  5903. return a.index = this._frames.length, this._frames.push(a), "" !== a.name && (this._frameNames[a.name] = a.index), a
  5904. },
  5905. getFrame: function(a) {
  5906. return a > this._frames.length && (a = 0), this._frames[a]
  5907. },
  5908. getFrameByName: function(a) {
  5909. return "number" == typeof this._frameNames[a] ? this._frames[this._frameNames[a]] : null
  5910. },
  5911. checkFrameName: function(a) {
  5912. return null == this._frameNames[a] ? !1 : !0
  5913. },
  5914. getFrameRange: function(a, b, c) {
  5915. "undefined" == typeof c && (c = []);
  5916. for (var d = a; b >= d; d++) c.push(this._frames[d]);
  5917. return c
  5918. },
  5919. getFrames: function(a, b, c) {
  5920. var d, e;
  5921. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  5922. for (d = 0; d < this._frames.length; d++) c.push(this._frames[d]);
  5923. else
  5924. for (d = 0, e = a.length; e > d; d++) b ? c.push(this.getFrame(a[d])) : c.push(this.getFrameByName(a[d]));
  5925. return c
  5926. },
  5927. getFrameIndexes: function(a, b, c) {
  5928. var d, e;
  5929. if ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = []), "undefined" == typeof a || 0 === a.length)
  5930. for (d = 0, e = this._frames.length; e > d; d++) c.push(this._frames[d].index);
  5931. else
  5932. for (d = 0, e = a.length; e > d; d++) b ? c.push(a[d]) : this.getFrameByName(a[d]) && c.push(this.getFrameByName(a[d]).index);
  5933. return c
  5934. }
  5935. }, b.FrameData.prototype.constructor = b.FrameData, Object.defineProperty(b.FrameData.prototype, "total", {
  5936. get: function() {
  5937. return this._frames.length
  5938. }
  5939. }), b.AnimationParser = {
  5940. spriteSheet: function(a, c, d, e, f, g, h) {
  5941. var j, k, l, m, n, o, p, q, r, s, i = a.cache.getImage(c);
  5942. if (null == i) return null;
  5943. if (j = i.width, k = i.height, 0 >= d && (d = Math.floor(-j / Math.min(-1, d))), 0 >= e && (e = Math.floor(-k / Math.min(-1, e))), l = Math.floor((j - g) / (d + h)), m = Math.floor((k - g) / (e + h)), n = l * m, -1 !== f && (n = f), 0 === j || 0 === k || d > j || e > k || 0 === n) return console.warn("Phaser.AnimationParser.spriteSheet: '" + c + "'s width/height zero or width/height < given frameWidth/frameHeight"), null;
  5944. for (o = new b.FrameData, p = g, q = g, r = 0; n > r; r++) s = a.rnd.uuid(), o.addFrame(new b.Frame(r, p, q, d, e, "", s)), PIXI.TextureCache[s] = new PIXI.Texture(PIXI.BaseTextureCache[c], {
  5945. x: p,
  5946. y: q,
  5947. width: d,
  5948. height: e
  5949. }), p += d + h, p + d > j && (p = g, q += e + h);
  5950. return o
  5951. },
  5952. JSONData: function(a, c, d) {
  5953. var e, f, g, h, i;
  5954. if (!c["frames"]) return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"), console.log(c), void 0;
  5955. for (e = new b.FrameData, f = c["frames"], h = 0; h < f.length; h++) i = a.rnd.uuid(), g = e.addFrame(new b.Frame(h, f[h].frame.x, f[h].frame.y, f[h].frame.w, f[h].frame.h, f[h].filename, i)), PIXI.TextureCache[i] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  5956. x: f[h].frame.x,
  5957. y: f[h].frame.y,
  5958. width: f[h].frame.w,
  5959. height: f[h].frame.h
  5960. }), f[h].trimmed && g.setTrim(f[h].trimmed, f[h].sourceSize.w, f[h].sourceSize.h, f[h].spriteSourceSize.x, f[h].spriteSourceSize.y, f[h].spriteSourceSize.w, f[h].spriteSourceSize.h);
  5961. return e
  5962. },
  5963. JSONDataHash: function(a, c, d) {
  5964. var e, f, g, h, i, j;
  5965. if (!c["frames"]) return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"), console.log(c), void 0;
  5966. e = new b.FrameData, f = c["frames"], h = 0;
  5967. for (i in f) j = a.rnd.uuid(), g = e.addFrame(new b.Frame(h, f[i].frame.x, f[i].frame.y, f[i].frame.w, f[i].frame.h, i, j)), PIXI.TextureCache[j] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  5968. x: f[i].frame.x,
  5969. y: f[i].frame.y,
  5970. width: f[i].frame.w,
  5971. height: f[i].frame.h
  5972. }), f[i].trimmed && g.setTrim(f[i].trimmed, f[i].sourceSize.w, f[i].sourceSize.h, f[i].spriteSourceSize.x, f[i].spriteSourceSize.y, f[i].spriteSourceSize.w, f[i].spriteSourceSize.h), h++;
  5973. return e
  5974. },
  5975. XMLData: function(a, c, d) {
  5976. var e, f, g, h, i, j, k, l, m, n, o, p, q, r, s;
  5977. if (!c.getElementsByTagName("TextureAtlas")) return console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag"), void 0;
  5978. for (e = new b.FrameData, f = c.getElementsByTagName("SubTexture"), s = 0; s < f.length; s++) h = a.rnd.uuid(), j = f[s].attributes, i = j.name.nodeValue, k = parseInt(j.x.nodeValue, 10), l = parseInt(j.y.nodeValue, 10), m = parseInt(j.width.nodeValue, 10), n = parseInt(j.height.nodeValue, 10), o = null, p = null, j.frameX && (o = Math.abs(parseInt(j.frameX.nodeValue, 10)), p = Math.abs(parseInt(j.frameY.nodeValue, 10)), q = parseInt(j.frameWidth.nodeValue, 10), r = parseInt(j.frameHeight.nodeValue, 10)), g = e.addFrame(new b.Frame(s, k, l, m, n, i, h)), PIXI.TextureCache[h] = new PIXI.Texture(PIXI.BaseTextureCache[d], {
  5979. x: k,
  5980. y: l,
  5981. width: m,
  5982. height: n
  5983. }), (null !== o || null !== p) && g.setTrim(!0, m, n, o, p, q, r);
  5984. return e
  5985. }
  5986. }, b.Cache = function(a) {
  5987. this.game = a, this._canvases = {}, this._images = {}, this._textures = {}, this._sounds = {}, this._text = {}, this._json = {}, this._physics = {}, this._tilemaps = {}, this._binary = {}, this._bitmapDatas = {}, this._bitmapFont = {}, this.addDefaultImage(), this.addMissingImage(), this.onSoundUnlock = new b.Signal, this._cacheMap = [], this._cacheMap[b.Cache.CANVAS] = this._canvases, this._cacheMap[b.Cache.IMAGE] = this._images, this._cacheMap[b.Cache.TEXTURE] = this._textures, this._cacheMap[b.Cache.SOUND] = this._sounds, this._cacheMap[b.Cache.TEXT] = this._text, this._cacheMap[b.Cache.PHYSICS] = this._physics, this._cacheMap[b.Cache.TILEMAP] = this._tilemaps, this._cacheMap[b.Cache.BINARY] = this._binary, this._cacheMap[b.Cache.BITMAPDATA] = this._bitmapDatas, this._cacheMap[b.Cache.BITMAPFONT] = this._bitmapFont, this._cacheMap[b.Cache.JSON] = this._json
  5988. }, b.Cache.CANVAS = 1, b.Cache.IMAGE = 2, b.Cache.TEXTURE = 3, b.Cache.SOUND = 4, b.Cache.TEXT = 5, b.Cache.PHYSICS = 6, b.Cache.TILEMAP = 7, b.Cache.BINARY = 8, b.Cache.BITMAPDATA = 9, b.Cache.BITMAPFONT = 10, b.Cache.JSON = 11, b.Cache.prototype = {
  5989. addCanvas: function(a, b, c) {
  5990. this._canvases[a] = {
  5991. canvas: b,
  5992. context: c
  5993. }
  5994. },
  5995. addBinary: function(a, b) {
  5996. this._binary[a] = b
  5997. },
  5998. addBitmapData: function(a, b) {
  5999. return this._bitmapDatas[a] = b, b
  6000. },
  6001. addRenderTexture: function(a, c) {
  6002. var d = new b.Frame(0, 0, 0, c.width, c.height, "", "");
  6003. this._textures[a] = {
  6004. texture: c,
  6005. frame: d
  6006. }
  6007. },
  6008. addSpriteSheet: function(a, c, d, e, f, g, h, i) {
  6009. this._images[a] = {
  6010. url: c,
  6011. data: d,
  6012. spriteSheet: !0,
  6013. frameWidth: e,
  6014. frameHeight: f,
  6015. margin: h,
  6016. spacing: i
  6017. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), this._images[a].frameData = b.AnimationParser.spriteSheet(this.game, a, e, f, g, h, i)
  6018. },
  6019. addTilemap: function(a, b, c, d) {
  6020. this._tilemaps[a] = {
  6021. url: b,
  6022. data: c,
  6023. format: d
  6024. }
  6025. },
  6026. addTextureAtlas: function(a, c, d, e, f) {
  6027. this._images[a] = {
  6028. url: c,
  6029. data: d,
  6030. spriteSheet: !0
  6031. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), f == b.Loader.TEXTURE_ATLAS_JSON_ARRAY ? this._images[a].frameData = b.AnimationParser.JSONData(this.game, e, a) : f == b.Loader.TEXTURE_ATLAS_JSON_HASH ? this._images[a].frameData = b.AnimationParser.JSONDataHash(this.game, e, a) : f == b.Loader.TEXTURE_ATLAS_XML_STARLING && (this._images[a].frameData = b.AnimationParser.XMLData(this.game, e, a))
  6032. },
  6033. addBitmapFont: function(a, c, d, e, f, g) {
  6034. this._images[a] = {
  6035. url: c,
  6036. data: d,
  6037. spriteSheet: !0
  6038. }, PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a]), b.LoaderParser.bitmapFont(this.game, e, a, f, g)
  6039. },
  6040. addPhysicsData: function(a, b, c, d) {
  6041. this._physics[a] = {
  6042. url: b,
  6043. data: c,
  6044. format: d
  6045. }
  6046. },
  6047. addDefaultImage: function() {
  6048. var a = new Image;
  6049. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==", this._images["__default"] = {
  6050. url: null,
  6051. data: a,
  6052. spriteSheet: !1
  6053. }, this._images["__default"].frame = new b.Frame(0, 0, 0, 32, 32, "", ""), PIXI.BaseTextureCache["__default"] = new PIXI.BaseTexture(a), PIXI.TextureCache["__default"] = new PIXI.Texture(PIXI.BaseTextureCache["__default"])
  6054. },
  6055. addMissingImage: function() {
  6056. var a = new Image;
  6057. a.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==", this._images["__missing"] = {
  6058. url: null,
  6059. data: a,
  6060. spriteSheet: !1
  6061. }, this._images["__missing"].frame = new b.Frame(0, 0, 0, 32, 32, "", ""), PIXI.BaseTextureCache["__missing"] = new PIXI.BaseTexture(a), PIXI.TextureCache["__missing"] = new PIXI.Texture(PIXI.BaseTextureCache["__missing"])
  6062. },
  6063. addText: function(a, b, c) {
  6064. this._text[a] = {
  6065. url: b,
  6066. data: c
  6067. }
  6068. },
  6069. addJSON: function(a, b, c) {
  6070. this._json[a] = {
  6071. url: b,
  6072. data: c
  6073. }
  6074. },
  6075. addImage: function(a, c, d) {
  6076. this._images[a] = {
  6077. url: c,
  6078. data: d,
  6079. spriteSheet: !1
  6080. }, this._images[a].frame = new b.Frame(0, 0, 0, d.width, d.height, a, this.game.rnd.uuid()), PIXI.BaseTextureCache[a] = new PIXI.BaseTexture(d), PIXI.TextureCache[a] = new PIXI.Texture(PIXI.BaseTextureCache[a])
  6081. },
  6082. addSound: function(a, b, c, d, e) {
  6083. d = d || !0, e = e || !1;
  6084. var f = !1;
  6085. e && (f = !0), this._sounds[a] = {
  6086. url: b,
  6087. data: c,
  6088. isDecoding: !1,
  6089. decoded: f,
  6090. webAudio: d,
  6091. audioTag: e,
  6092. locked: this.game.sound.touchLocked
  6093. }
  6094. },
  6095. reloadSound: function(a) {
  6096. var b = this;
  6097. this._sounds[a] && (this._sounds[a].data.src = this._sounds[a].url, this._sounds[a].data.addEventListener("canplaythrough", function() {
  6098. return b.reloadSoundComplete(a)
  6099. }, !1), this._sounds[a].data.load())
  6100. },
  6101. reloadSoundComplete: function(a) {
  6102. this._sounds[a] && (this._sounds[a].locked = !1, this.onSoundUnlock.dispatch(a))
  6103. },
  6104. updateSound: function(a, b, c) {
  6105. this._sounds[a] && (this._sounds[a][b] = c)
  6106. },
  6107. decodedSound: function(a, b) {
  6108. this._sounds[a].data = b, this._sounds[a].decoded = !0, this._sounds[a].isDecoding = !1
  6109. },
  6110. getCanvas: function(a) {
  6111. return this._canvases[a] ? this._canvases[a].canvas : (console.warn('Phaser.Cache.getCanvas: Invalid key: "' + a + '"'), void 0)
  6112. },
  6113. getBitmapData: function(a) {
  6114. return this._bitmapDatas[a] ? this._bitmapDatas[a] : (console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + a + '"'), void 0)
  6115. },
  6116. getBitmapFont: function(a) {
  6117. return this._bitmapFont[a] ? this._bitmapFont[a] : (console.warn('Phaser.Cache.getBitmapFont: Invalid key: "' + a + '"'), void 0)
  6118. },
  6119. getPhysicsData: function(a, b, c) {
  6120. var d, e;
  6121. if ("undefined" == typeof b || null === b) {
  6122. if (this._physics[a]) return this._physics[a].data;
  6123. console.warn('Phaser.Cache.getPhysicsData: Invalid key: "' + a + '"')
  6124. } else if (this._physics[a] && this._physics[a].data[b]) {
  6125. if (d = this._physics[a].data[b], !d || !c) return d;
  6126. for (e in d)
  6127. if (e = d[e], e.fixtureKey === c) return e;
  6128. console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "' + c + " in " + a + '"')
  6129. } else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + a + " / " + b + '"');
  6130. return null
  6131. },
  6132. checkKey: function(a, b) {
  6133. return this._cacheMap[a][b] ? !0 : !1
  6134. },
  6135. checkCanvasKey: function(a) {
  6136. return this.checkKey(b.Cache.CANVAS, a)
  6137. },
  6138. checkImageKey: function(a) {
  6139. return this.checkKey(b.Cache.IMAGE, a)
  6140. },
  6141. checkTextureKey: function(a) {
  6142. return this.checkKey(b.Cache.TEXTURE, a)
  6143. },
  6144. checkSoundKey: function(a) {
  6145. return this.checkKey(b.Cache.SOUND, a)
  6146. },
  6147. checkTextKey: function(a) {
  6148. return this.checkKey(b.Cache.TEXT, a)
  6149. },
  6150. checkPhysicsKey: function(a) {
  6151. return this.checkKey(b.Cache.PHYSICS, a)
  6152. },
  6153. checkTilemapKey: function(a) {
  6154. return this.checkKey(b.Cache.TILEMAP, a)
  6155. },
  6156. checkBinaryKey: function(a) {
  6157. return this.checkKey(b.Cache.BINARY, a)
  6158. },
  6159. checkBitmapDataKey: function(a) {
  6160. return this.checkKey(b.Cache.BITMAPDATA, a)
  6161. },
  6162. checkBitmapFontKey: function(a) {
  6163. return this.checkKey(b.Cache.BITMAPFONT, a)
  6164. },
  6165. checkJSONKey: function(a) {
  6166. return this.checkKey(b.Cache.JSON, a)
  6167. },
  6168. getImage: function(a) {
  6169. return this._images[a] ? this._images[a].data : (console.warn('Phaser.Cache.getImage: Invalid key: "' + a + '"'), void 0)
  6170. },
  6171. getTilemapData: function(a) {
  6172. return this._tilemaps[a] ? this._tilemaps[a] : (console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + a + '"'), void 0)
  6173. },
  6174. getFrameData: function(a) {
  6175. return this._images[a] && this._images[a].frameData ? this._images[a].frameData : null
  6176. },
  6177. updateFrameData: function(a, b) {
  6178. this._images[a] && (this._images[a].spriteSheet = !0, this._images[a].frameData = b)
  6179. },
  6180. getFrameByIndex: function(a, b) {
  6181. return this._images[a] && this._images[a].frameData ? this._images[a].frameData.getFrame(b) : null
  6182. },
  6183. getFrameByName: function(a, b) {
  6184. return this._images[a] && this._images[a].frameData ? this._images[a].frameData.getFrameByName(b) : null
  6185. },
  6186. getFrame: function(a) {
  6187. return this._images[a] && this._images[a].spriteSheet === !1 ? this._images[a].frame : null
  6188. },
  6189. getTextureFrame: function(a) {
  6190. return this._textures[a] ? this._textures[a].frame : null
  6191. },
  6192. getTexture: function(a) {
  6193. return this._textures[a] ? this._textures[a] : (console.warn('Phaser.Cache.getTexture: Invalid key: "' + a + '"'), void 0)
  6194. },
  6195. getSound: function(a) {
  6196. return this._sounds[a] ? this._sounds[a] : (console.warn('Phaser.Cache.getSound: Invalid key: "' + a + '"'), void 0)
  6197. },
  6198. getSoundData: function(a) {
  6199. return this._sounds[a] ? this._sounds[a].data : (console.warn('Phaser.Cache.getSoundData: Invalid key: "' + a + '"'), void 0)
  6200. },
  6201. isSoundDecoded: function(a) {
  6202. return this._sounds[a] ? this._sounds[a].decoded : void 0
  6203. },
  6204. isSoundReady: function(a) {
  6205. return this._sounds[a] && this._sounds[a].decoded && this.game.sound.touchLocked === !1
  6206. },
  6207. isSpriteSheet: function(a) {
  6208. return this._images[a] ? this._images[a].spriteSheet : !1
  6209. },
  6210. getText: function(a) {
  6211. return this._text[a] ? this._text[a].data : (console.warn('Phaser.Cache.getText: Invalid key: "' + a + '"'), void 0)
  6212. },
  6213. getJSON: function(a) {
  6214. return this._json[a] ? this._json[a].data : (console.warn('Phaser.Cache.getJSON: Invalid key: "' + a + '"'), void 0)
  6215. },
  6216. getBinary: function(a) {
  6217. return this._binary[a] ? this._binary[a] : (console.warn('Phaser.Cache.getBinary: Invalid key: "' + a + '"'), void 0)
  6218. },
  6219. getKeys: function(a) {
  6220. var d, e, c = null;
  6221. switch (a) {
  6222. case b.Cache.CANVAS:
  6223. c = this._canvases;
  6224. break;
  6225. case b.Cache.IMAGE:
  6226. c = this._images;
  6227. break;
  6228. case b.Cache.TEXTURE:
  6229. c = this._textures;
  6230. break;
  6231. case b.Cache.SOUND:
  6232. c = this._sounds;
  6233. break;
  6234. case b.Cache.TEXT:
  6235. c = this._text;
  6236. break;
  6237. case b.Cache.PHYSICS:
  6238. c = this._physics;
  6239. break;
  6240. case b.Cache.TILEMAP:
  6241. c = this._tilemaps;
  6242. break;
  6243. case b.Cache.BINARY:
  6244. c = this._binary;
  6245. break;
  6246. case b.Cache.BITMAPDATA:
  6247. c = this._bitmapDatas;
  6248. break;
  6249. case b.Cache.BITMAPFONT:
  6250. c = this._bitmapFont;
  6251. break;
  6252. case b.Cache.JSON:
  6253. c = this._json
  6254. }
  6255. if (c) {
  6256. d = [];
  6257. for (e in c) "__default" !== e && "__missing" !== e && d.push(e);
  6258. return d
  6259. }
  6260. },
  6261. removeCanvas: function(a) {
  6262. delete this._canvases[a]
  6263. },
  6264. removeImage: function(a) {
  6265. delete this._images[a]
  6266. },
  6267. removeSound: function(a) {
  6268. delete this._sounds[a]
  6269. },
  6270. removeText: function(a) {
  6271. delete this._text[a]
  6272. },
  6273. removeJSON: function(a) {
  6274. delete this._json[a]
  6275. },
  6276. removePhysics: function(a) {
  6277. delete this._physics[a]
  6278. },
  6279. removeTilemap: function(a) {
  6280. delete this._tilemaps[a]
  6281. },
  6282. removeBinary: function(a) {
  6283. delete this._binary[a]
  6284. },
  6285. removeBitmapData: function(a) {
  6286. delete this._bitmapDatas[a]
  6287. },
  6288. removeBitmapFont: function(a) {
  6289. delete this._bitmapFont[a]
  6290. },
  6291. destroy: function() {
  6292. var a;
  6293. for (a in this._canvases) delete this._canvases[a];
  6294. for (a in this._images) "__default" !== a && "__missing" !== a && delete this._images[a];
  6295. for (a in this._sounds) delete this._sounds[a];
  6296. for (a in this._text) delete this._text[a];
  6297. for (a in this._json) delete this._json[a];
  6298. for (a in this._textures) delete this._textures[a];
  6299. for (a in this._physics) delete this._physics[a];
  6300. for (a in this._tilemaps) delete this._tilemaps[a];
  6301. for (a in this._binary) delete this._binary[a];
  6302. for (a in this._bitmapDatas) delete this._bitmapDatas[a];
  6303. for (a in this._bitmapFont) delete this._bitmapFont[a]
  6304. }
  6305. }, b.Cache.prototype.constructor = b.Cache, b.Loader = function(a) {
  6306. this.game = a, this.isLoading = !1, this.hasLoaded = !1, this.progress = 0, this.progressFloat = 0, this.preloadSprite = null, this.crossOrigin = !1, this.baseURL = "", this.onLoadStart = new b.Signal, this.onFileStart = new b.Signal, this.onFileComplete = new b.Signal, this.onFileError = new b.Signal, this.onLoadComplete = new b.Signal, this.onPackComplete = new b.Signal, this._packList = [], this._packIndex = 0, this._fileList = [], this._fileIndex = 0, this._progressChunk = 0, this._xhr = new XMLHttpRequest, this._ajax = null
  6307. }, b.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0, b.Loader.TEXTURE_ATLAS_JSON_HASH = 1, b.Loader.TEXTURE_ATLAS_XML_STARLING = 2, b.Loader.PHYSICS_LIME_CORONA_JSON = 3, b.Loader.PHYSICS_PHASER_JSON = 4, b.Loader.prototype = {
  6308. setPreloadSprite: function(a, c) {
  6309. c = c || 0, this.preloadSprite = {
  6310. sprite: a,
  6311. direction: c,
  6312. width: a.width,
  6313. height: a.height,
  6314. rect: null
  6315. }, this.preloadSprite.rect = 0 === c ? new b.Rectangle(0, 0, 1, a.height) : new b.Rectangle(0, 0, a.width, 1), a.crop(this.preloadSprite.rect), a.visible = !0
  6316. },
  6317. checkKeyExists: function(a, b) {
  6318. if (this._fileList.length > 0)
  6319. for (var c = 0; c < this._fileList.length; c++)
  6320. if (this._fileList[c].type === a && this._fileList[c].key === b) return !0;
  6321. return !1
  6322. },
  6323. getAssetIndex: function(a, b) {
  6324. if (this._fileList.length > 0)
  6325. for (var c = 0; c < this._fileList.length; c++)
  6326. if (this._fileList[c].type === a && this._fileList[c].key === b) return c;
  6327. return -1
  6328. },
  6329. getAsset: function(a, b) {
  6330. if (this._fileList.length > 0)
  6331. for (var c = 0; c < this._fileList.length; c++)
  6332. if (this._fileList[c].type === a && this._fileList[c].key === b) return {
  6333. index: c,
  6334. file: this._fileList[c]
  6335. };
  6336. return !1
  6337. },
  6338. reset: function() {
  6339. this.preloadSprite = null, this.isLoading = !1, this._packList.length = 0, this._packIndex = 0, this._fileList.length = 0, this._fileIndex = 0
  6340. },
  6341. addToFileList: function(a, b, c, d) {
  6342. var f, e = {
  6343. type: a,
  6344. key: b,
  6345. url: c,
  6346. data: null,
  6347. error: !1,
  6348. loaded: !1
  6349. };
  6350. if ("undefined" != typeof d)
  6351. for (f in d) e[f] = d[f];
  6352. this.checkKeyExists(a, b) === !1 && this._fileList.push(e)
  6353. },
  6354. replaceInFileList: function(a, b, c, d) {
  6355. var f, g, e = {
  6356. type: a,
  6357. key: b,
  6358. url: c,
  6359. data: null,
  6360. error: !1,
  6361. loaded: !1
  6362. };
  6363. if ("undefined" != typeof d)
  6364. for (f in d) e[f] = d[f];
  6365. g = this.getAssetIndex(a, b), -1 === g ? this._fileList.push(e) : this._fileList[g] = e
  6366. },
  6367. pack: function(a, b, c, d) {
  6368. return "undefined" == typeof b && (b = null), "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = this), null === b && null === c ? (console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."), this) : (c && "string" == typeof c && (c = JSON.parse(c)), this._packList.push({
  6369. key: a,
  6370. url: b,
  6371. data: c,
  6372. loaded: !1,
  6373. error: !1,
  6374. callbackContext: d
  6375. }), this)
  6376. },
  6377. image: function(a, b, c) {
  6378. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("image", a, b) : this.addToFileList("image", a, b), this
  6379. },
  6380. text: function(a, b, c) {
  6381. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("text", a, b) : this.addToFileList("text", a, b), this
  6382. },
  6383. json: function(a, b, c) {
  6384. return "undefined" == typeof c && (c = !1), c ? this.replaceInFileList("json", a, b) : this.addToFileList("json", a, b), this
  6385. },
  6386. script: function(a, b, c, d) {
  6387. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("script", a, b, {
  6388. callback: c,
  6389. callbackContext: d
  6390. }), this
  6391. },
  6392. binary: function(a, b, c, d) {
  6393. return "undefined" == typeof c && (c = !1), c !== !1 && "undefined" == typeof d && (d = c), this.addToFileList("binary", a, b, {
  6394. callback: c,
  6395. callbackContext: d
  6396. }), this
  6397. },
  6398. spritesheet: function(a, b, c, d, e, f, g) {
  6399. return "undefined" == typeof e && (e = -1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), this.addToFileList("spritesheet", a, b, {
  6400. frameWidth: c,
  6401. frameHeight: d,
  6402. frameMax: e,
  6403. margin: f,
  6404. spacing: g
  6405. }), this
  6406. },
  6407. audio: function(a, b, c) {
  6408. return "undefined" == typeof c && (c = !0), this.addToFileList("audio", a, b, {
  6409. buffer: null,
  6410. autoDecode: c
  6411. }), this
  6412. },
  6413. tilemap: function(a, c, d, e) {
  6414. if ("undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = b.Tilemap.CSV), null == c && null == d) return console.warn("Phaser.Loader.tilemap - Both url and data are null. One must be set."), this;
  6415. if (d) {
  6416. switch (e) {
  6417. case b.Tilemap.CSV:
  6418. break;
  6419. case b.Tilemap.TILED_JSON:
  6420. "string" == typeof d && (d = JSON.parse(d))
  6421. }
  6422. this.game.cache.addTilemap(a, null, d, e)
  6423. } else this.addToFileList("tilemap", a, c, {
  6424. format: e
  6425. });
  6426. return this
  6427. },
  6428. physics: function(a, c, d, e) {
  6429. return "undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = b.Physics.LIME_CORONA_JSON), null == c && null == d ? (console.warn("Phaser.Loader.physics - Both url and data are null. One must be set."), this) : (d ? ("string" == typeof d && (d = JSON.parse(d)), this.game.cache.addPhysicsData(a, null, d, e)) : this.addToFileList("physics", a, c, {
  6430. format: e
  6431. }), this)
  6432. },
  6433. bitmapFont: function(a, b, c, d, e, f) {
  6434. var g, h;
  6435. if ("undefined" == typeof c && (c = null), "undefined" == typeof d && (d = null), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = 0), c) this.addToFileList("bitmapfont", a, b, {
  6436. xmlURL: c,
  6437. xSpacing: e,
  6438. ySpacing: f
  6439. });
  6440. else if ("string" == typeof d) {
  6441. try {
  6442. window["DOMParser"] ? (h = new DOMParser, g = h.parseFromString(d, "text/xml")) : (g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(d))
  6443. } catch (i) {
  6444. g = void 0
  6445. }
  6446. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
  6447. this.addToFileList("bitmapfont", a, b, {
  6448. xmlURL: null,
  6449. xmlData: g,
  6450. xSpacing: e,
  6451. ySpacing: f
  6452. })
  6453. }
  6454. return this
  6455. },
  6456. atlasJSONArray: function(a, c, d, e) {
  6457. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_ARRAY)
  6458. },
  6459. atlasJSONHash: function(a, c, d, e) {
  6460. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_JSON_HASH)
  6461. },
  6462. atlasXML: function(a, c, d, e) {
  6463. return this.atlas(a, c, d, e, b.Loader.TEXTURE_ATLAS_XML_STARLING)
  6464. },
  6465. atlas: function(a, c, d, e, f) {
  6466. var g, h;
  6467. if ("undefined" == typeof d && (d = null), "undefined" == typeof e && (e = null), "undefined" == typeof f && (f = b.Loader.TEXTURE_ATLAS_JSON_ARRAY), d) this.addToFileList("textureatlas", a, c, {
  6468. atlasURL: d,
  6469. format: f
  6470. });
  6471. else {
  6472. switch (f) {
  6473. case b.Loader.TEXTURE_ATLAS_JSON_ARRAY:
  6474. "string" == typeof e && (e = JSON.parse(e));
  6475. break;
  6476. case b.Loader.TEXTURE_ATLAS_XML_STARLING:
  6477. if ("string" == typeof e) {
  6478. try {
  6479. window["DOMParser"] ? (h = new DOMParser, g = h.parseFromString(e, "text/xml")) : (g = new ActiveXObject("Microsoft.XMLDOM"), g.async = "false", g.loadXML(e))
  6480. } catch (i) {
  6481. g = void 0
  6482. }
  6483. if (!g || !g.documentElement || g.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
  6484. e = g
  6485. }
  6486. }
  6487. this.addToFileList("textureatlas", a, c, {
  6488. atlasURL: null,
  6489. atlasData: e,
  6490. format: f
  6491. })
  6492. }
  6493. return this
  6494. },
  6495. removeFile: function(a, b) {
  6496. var c = this.getAsset(a, b);
  6497. c !== !1 && this._fileList.splice(c.index, 1)
  6498. },
  6499. removeAll: function() {
  6500. this._fileList.length = 0
  6501. },
  6502. start: function() {
  6503. this.isLoading || (this._packList.length > 0 ? (this._packIndex = 0, this.loadPack()) : this.beginLoad())
  6504. },
  6505. beginLoad: function() {
  6506. this.progress = 0, this.progressFloat = 0, this.hasLoaded = !1, this.isLoading = !0, this.onLoadStart.dispatch(this._fileList.length), this._fileList.length > 0 ? (this._fileIndex = 0, this._progressChunk = 100 / this._fileList.length, this.loadFile()) : (this.progress = 100, this.progressFloat = 100, this.hasLoaded = !0, this.isLoading = !1, this.onLoadComplete.dispatch())
  6507. },
  6508. loadPack: function() {
  6509. if (!this._packList[this._packIndex]) return console.warn("Phaser.Loader loadPackList invalid index " + this._packIndex), void 0;
  6510. var a = this._packList[this._packIndex];
  6511. null !== a.data ? this.packLoadComplete(this._packIndex, !1) : this.xhrLoad(this._packIndex, this.baseURL + a.url, "text", "packLoadComplete", "packLoadError")
  6512. },
  6513. packLoadComplete: function(a, c) {
  6514. var d, e, f, g;
  6515. if ("undefined" == typeof c && (c = !0), !this._packList[a]) return console.warn("Phaser.Loader packLoadComplete invalid index " + a), void 0;
  6516. if (d = this._packList[a], d.loaded = !0, e = c ? JSON.parse(this._xhr.responseText) : this._packList[a].data, e[d.key])
  6517. for (g = 0; g < e[d.key].length; g++) switch (f = e[d.key][g], f.type) {
  6518. case "image":
  6519. this.image(f.key, f.url, f.overwrite);
  6520. break;
  6521. case "text":
  6522. this.text(f.key, f.url, f.overwrite);
  6523. break;
  6524. case "json":
  6525. this.json(f.key, f.url, f.overwrite);
  6526. break;
  6527. case "script":
  6528. this.script(f.key, f.url, f.callback, d.callbackContext);
  6529. break;
  6530. case "binary":
  6531. this.binary(f.key, f.url, f.callback, d.callbackContext);
  6532. break;
  6533. case "spritesheet":
  6534. this.spritesheet(f.key, f.url, f.frameWidth, f.frameHeight, f.frameMax, f.margin, f.spacing);
  6535. break;
  6536. case "audio":
  6537. this.audio(f.key, f.urls, f.autoDecode);
  6538. break;
  6539. case "tilemap":
  6540. this.tilemap(f.key, f.url, f.data, b.Tilemap[f.format]);
  6541. break;
  6542. case "physics":
  6543. this.physics(f.key, f.url, f.data, b.Loader[f.format]);
  6544. break;
  6545. case "bitmapFont":
  6546. this.bitmapFont(f.key, f.textureURL, f.xmlURL, f.xmlData, f.xSpacing, f.ySpacing);
  6547. break;
  6548. case "atlasJSONArray":
  6549. this.atlasJSONArray(f.key, f.textureURL, f.atlasURL, f.atlasData);
  6550. break;
  6551. case "atlasJSONHash":
  6552. this.atlasJSONHash(f.key, f.textureURL, f.atlasURL, f.atlasData);
  6553. break;
  6554. case "atlasXML":
  6555. this.atlasXML(f.key, f.textureURL, f.atlasURL, f.atlasData);
  6556. break;
  6557. case "atlas":
  6558. this.atlas(f.key, f.textureURL, f.atlasURL, f.atlasData, b.Loader[f.format])
  6559. }
  6560. this.nextPack(a, !0)
  6561. },
  6562. packError: function(a) {
  6563. this._packList[a].loaded = !0, this._packList[a].error = !0, this.onFileError.dispatch(this._packList[a].key, this._packList[a]), console.warn("Phaser.Loader error loading pack file: " + this._packList[a].key + " from URL " + this._packList[a].url), this.nextPack(a, !1)
  6564. },
  6565. nextPack: function(a, b) {
  6566. this.onPackComplete.dispatch(this._packList[a].key, b, this.totalLoadedPacks(), this._packList.length), this._packIndex++, this._packIndex < this._packList.length ? this.loadPack() : this.beginLoad()
  6567. },
  6568. loadFile: function() {
  6569. var a, c;
  6570. if (!this._fileList[this._fileIndex]) return console.warn("Phaser.Loader loadFile invalid index " + this._fileIndex), void 0;
  6571. switch (a = this._fileList[this._fileIndex], c = this, this.onFileStart.dispatch(this.progress, a.key), a.type) {
  6572. case "image":
  6573. case "spritesheet":
  6574. case "textureatlas":
  6575. case "bitmapfont":
  6576. a.data = new Image, a.data.name = a.key, a.data.onload = function() {
  6577. return c.fileComplete(c._fileIndex)
  6578. }, a.data.onerror = function() {
  6579. return c.fileError(c._fileIndex)
  6580. }, this.crossOrigin && (a.data.crossOrigin = this.crossOrigin), a.data.src = this.baseURL + a.url;
  6581. break;
  6582. case "audio":
  6583. a.url = this.getAudioURL(a.url), null !== a.url ? this.game.sound.usingWebAudio ? this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError") : this.game.sound.usingAudioTag && (this.game.sound.touchLocked ? (a.data = new Audio, a.data.name = a.key, a.data.preload = "auto", a.data.src = this.baseURL + a.url, this.fileComplete(this._fileIndex)) : (a.data = new Audio, a.data.name = a.key, a.data.onerror = function() {
  6584. return c.fileError(c._fileIndex)
  6585. }, a.data.preload = "auto", a.data.src = this.baseURL + a.url, a.data.addEventListener("canplaythrough", b.GAMES[this.game.id].load.fileComplete(this._fileIndex), !1), a.data.load())) : this.fileError(this._fileIndex);
  6586. break;
  6587. case "json":
  6588. window.XDomainRequest ? (this._ajax = new window.XDomainRequest, this._ajax.timeout = 3e3, this._ajax.onerror = function() {
  6589. return c.dataLoadError(c._fileIndex)
  6590. }, this._ajax.ontimeout = function() {
  6591. return c.dataLoadError(c._fileIndex)
  6592. }, this._ajax.onprogress = function() {}, this._ajax.onload = function() {
  6593. return c.jsonLoadComplete(c._fileIndex)
  6594. }, this._ajax.open("GET", this.baseURL + a.url, !0), this._ajax.send()) : this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  6595. break;
  6596. case "tilemap":
  6597. if (a.format === b.Tilemap.TILED_JSON) this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "jsonLoadComplete", "dataLoadError");
  6598. else {
  6599. if (a.format !== b.Tilemap.CSV) throw new Error("Phaser.Loader. Invalid Tilemap format: " + a.format);
  6600. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "csvLoadComplete", "dataLoadError")
  6601. }
  6602. break;
  6603. case "text":
  6604. case "script":
  6605. case "physics":
  6606. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "text", "fileComplete", "fileError");
  6607. break;
  6608. case "binary":
  6609. this.xhrLoad(this._fileIndex, this.baseURL + a.url, "arraybuffer", "fileComplete", "fileError")
  6610. }
  6611. },
  6612. xhrLoad: function(a, b, c, d, e) {
  6613. this._xhr.open("GET", b, !0), this._xhr.responseType = c;
  6614. var f = this;
  6615. this._xhr.onload = function() {
  6616. return f[d](a)
  6617. }, this._xhr.onerror = function() {
  6618. return f[e](a)
  6619. }, this._xhr.send()
  6620. },
  6621. getAudioURL: function(a) {
  6622. var b, c;
  6623. for ("string" == typeof a && (a = [a]), c = 0; c < a.length; c++)
  6624. if (b = a[c].toLowerCase(), b = b.substr((Math.max(0, b.lastIndexOf(".")) || 1 / 0) + 1), this.game.device.canPlayAudio(b)) return a[c];
  6625. return null
  6626. },
  6627. fileError: function(a) {
  6628. this._fileList[a].loaded = !0, this._fileList[a].error = !0, this.onFileError.dispatch(this._fileList[a].key, this._fileList[a]), console.warn("Phaser.Loader error loading file: " + this._fileList[a].key + " from URL " + this._fileList[a].url), this.nextFile(a, !1)
  6629. },
  6630. fileComplete: function(a) {
  6631. var c, d, e, f, g;
  6632. if (!this._fileList[a]) return console.warn("Phaser.Loader fileComplete invalid index " + a), void 0;
  6633. switch (c = this._fileList[a], c.loaded = !0, d = !0, c.type) {
  6634. case "image":
  6635. this.game.cache.addImage(c.key, c.url, c.data);
  6636. break;
  6637. case "spritesheet":
  6638. this.game.cache.addSpriteSheet(c.key, c.url, c.data, c.frameWidth, c.frameHeight, c.frameMax, c.margin, c.spacing);
  6639. break;
  6640. case "textureatlas":
  6641. if (null == c.atlasURL) this.game.cache.addTextureAtlas(c.key, c.url, c.data, c.atlasData, c.format);
  6642. else if (d = !1, c.format == b.Loader.TEXTURE_ATLAS_JSON_ARRAY || c.format == b.Loader.TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "jsonLoadComplete", "dataLoadError");
  6643. else {
  6644. if (c.format != b.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + c.format);
  6645. this.xhrLoad(this._fileIndex, this.baseURL + c.atlasURL, "text", "xmlLoadComplete", "dataLoadError")
  6646. }
  6647. break;
  6648. case "bitmapfont":
  6649. null == c.xmlURL ? this.game.cache.addBitmapFont(c.key, c.url, c.data, c.xmlData, c.xSpacing, c.ySpacing) : (d = !1, this.xhrLoad(this._fileIndex, this.baseURL + c.xmlURL, "text", "xmlLoadComplete", "dataLoadError"));
  6650. break;
  6651. case "audio":
  6652. this.game.sound.usingWebAudio ? (c.data = this._xhr.response, this.game.cache.addSound(c.key, c.url, c.data, !0, !1), c.autoDecode && (e = this, f = c.key, this.game.cache.updateSound(f, "isDecoding", !0), this.game.sound.context.decodeAudioData(c.data, function(a) {
  6653. a && (e.game.cache.decodedSound(f, a), e.game.sound.onSoundDecode.dispatch(f, e.game.cache.getSound(f)))
  6654. }))) : (c.data.removeEventListener("canplaythrough", b.GAMES[this.game.id].load.fileComplete), this.game.cache.addSound(c.key, c.url, c.data, !1, !0));
  6655. break;
  6656. case "text":
  6657. c.data = this._xhr.responseText, this.game.cache.addText(c.key, c.url, c.data);
  6658. break;
  6659. case "physics":
  6660. g = JSON.parse(this._xhr.responseText), this.game.cache.addPhysicsData(c.key, c.url, g, c.format);
  6661. break;
  6662. case "script":
  6663. c.data = document.createElement("script"), c.data.language = "javascript", c.data.type = "text/javascript", c.data.defer = !1, c.data.text = this._xhr.responseText, document.head.appendChild(c.data), c.callback && (c.data = c.callback.call(c.callbackContext, c.key, this._xhr.responseText));
  6664. break;
  6665. case "binary":
  6666. c.data = c.callback ? c.callback.call(c.callbackContext, c.key, this._xhr.response) : this._xhr.response, this.game.cache.addBinary(c.key, c.data)
  6667. }
  6668. d && this.nextFile(a, !0)
  6669. },
  6670. jsonLoadComplete: function(a) {
  6671. var b, c;
  6672. return this._fileList[a] ? (b = this._fileList[a], c = JSON.parse(this._xhr.responseText), b.loaded = !0, "tilemap" === b.type ? this.game.cache.addTilemap(b.key, b.url, c, b.format) : "json" === b.type ? this.game.cache.addJSON(b.key, b.url, c) : this.game.cache.addTextureAtlas(b.key, b.url, b.data, c, b.format), this.nextFile(a, !0), void 0) : (console.warn("Phaser.Loader jsonLoadComplete invalid index " + a), void 0)
  6673. },
  6674. csvLoadComplete: function(a) {
  6675. var b, c;
  6676. return this._fileList[a] ? (b = this._fileList[a], c = this._xhr.responseText, b.loaded = !0, this.game.cache.addTilemap(b.key, b.url, c, b.format), this.nextFile(a, !0), void 0) : (console.warn("Phaser.Loader csvLoadComplete invalid index " + a), void 0)
  6677. },
  6678. dataLoadError: function(a) {
  6679. var b = this._fileList[a];
  6680. b.loaded = !0, b.error = !0, console.warn("Phaser.Loader dataLoadError: " + b.key), this.nextFile(a, !0)
  6681. },
  6682. xmlLoadComplete: function(a) {
  6683. var c, d, f, b = this._xhr.responseText;
  6684. try {
  6685. window["DOMParser"] ? (d = new DOMParser, c = d.parseFromString(b, "text/xml")) : (c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(b))
  6686. } catch (e) {
  6687. c = void 0
  6688. }
  6689. if (!c || !c.documentElement || c.getElementsByTagName("parsererror").length) throw new Error("Phaser.Loader. Invalid XML given");
  6690. f = this._fileList[a], f.loaded = !0, "bitmapfont" == f.type ? this.game.cache.addBitmapFont(f.key, f.url, f.data, c, f.xSpacing, f.ySpacing) : "textureatlas" == f.type && this.game.cache.addTextureAtlas(f.key, f.url, f.data, c, f.format), this.nextFile(a, !0)
  6691. },
  6692. nextFile: function(a, b) {
  6693. this.progressFloat += this._progressChunk, this.progress = Math.round(this.progressFloat), this.progress > 100 && (this.progress = 100), null !== this.preloadSprite && (0 === this.preloadSprite.direction ? (this.preloadSprite.rect.width = Math.floor(this.preloadSprite.width / 100 * this.progress), this.preloadSprite.sprite.crop(this.preloadSprite.rect)) : (this.preloadSprite.rect.height = Math.floor(this.preloadSprite.height / 100 * this.progress), this.preloadSprite.sprite.crop(this.preloadSprite.rect))), this.onFileComplete.dispatch(this.progress, this._fileList[a].key, b, this.totalLoadedFiles(), this._fileList.length), this.totalQueuedFiles() > 0 ? (this._fileIndex++, this.loadFile()) : (this.hasLoaded = !0, this.isLoading = !1, this.removeAll(), this.onLoadComplete.dispatch())
  6694. },
  6695. totalLoadedFiles: function() {
  6696. var b, a = 0;
  6697. for (b = 0; b < this._fileList.length; b++) this._fileList[b].loaded && a++;
  6698. return a
  6699. },
  6700. totalQueuedFiles: function() {
  6701. var b, a = 0;
  6702. for (b = 0; b < this._fileList.length; b++) this._fileList[b].loaded === !1 && a++;
  6703. return a
  6704. },
  6705. totalLoadedPacks: function() {
  6706. var b, a = 0;
  6707. for (b = 0; b < this._packList.length; b++) this._packList[b].loaded && a++;
  6708. return a
  6709. },
  6710. totalQueuedPacks: function() {
  6711. var b, a = 0;
  6712. for (b = 0; b < this._packList.length; b++) this._packList[b].loaded === !1 && a++;
  6713. return a
  6714. }
  6715. }, b.Loader.prototype.constructor = b.Loader, b.LoaderParser = {
  6716. bitmapFont: function(a, b, c, d, e) {
  6717. var i, j, k, l, m, n, o, p, f = {},
  6718. g = b.getElementsByTagName("info")[0],
  6719. h = b.getElementsByTagName("common")[0];
  6720. for (f.font = g.getAttribute("face"), f.size = parseInt(g.getAttribute("size"), 10), f.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + e, f.chars = {}, i = b.getElementsByTagName("char"), j = 0; j < i.length; j++) k = parseInt(i[j].getAttribute("id"), 10), l = new PIXI.Rectangle(parseInt(i[j].getAttribute("x"), 10), parseInt(i[j].getAttribute("y"), 10), parseInt(i[j].getAttribute("width"), 10), parseInt(i[j].getAttribute("height"), 10)), f.chars[k] = {
  6721. xOffset: parseInt(i[j].getAttribute("xoffset"), 10),
  6722. yOffset: parseInt(i[j].getAttribute("yoffset"), 10),
  6723. xAdvance: parseInt(i[j].getAttribute("xadvance"), 10) + d,
  6724. kerning: {},
  6725. texture: PIXI.TextureCache[c] = new PIXI.Texture(PIXI.BaseTextureCache[c], l)
  6726. };
  6727. for (m = b.getElementsByTagName("kerning"), j = 0; j < m.length; j++) n = parseInt(m[j].getAttribute("first"), 10), o = parseInt(m[j].getAttribute("second"), 10), p = parseInt(m[j].getAttribute("amount"), 10), f.chars[o].kerning[n] = p;
  6728. PIXI.BitmapText.fonts[c] = f
  6729. }
  6730. }, b.Sound = function(a, c, d, e, f) {
  6731. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = a.sound.connectToMaster), this.game = a, this.name = c, this.key = c, this.loop = e, this.volume = d, this.markers = {}, this.context = null, this.autoplay = !1, this.totalDuration = 0, this.startTime = 0, this.currentTime = 0, this.duration = 0, this.durationMS = 0, this.position = 0, this.stopTime = 0, this.paused = !1, this.pausedPosition = 0, this.pausedTime = 0, this.isPlaying = !1, this.currentMarker = "", this.pendingPlayback = !1, this.override = !1, this.usingWebAudio = this.game.sound.usingWebAudio, this.usingAudioTag = this.game.sound.usingAudioTag, this.externalNode = null, this.masterGainNode = null, this.gainNode = null, this.usingWebAudio ? (this.context = this.game.sound.context, this.masterGainNode = this.game.sound.masterGain, this.gainNode = "undefined" == typeof this.context.createGain ? this.context.createGainNode() : this.context.createGain(), this.gainNode.gain.value = d * this.game.sound.volume, f && this.gainNode.connect(this.masterGainNode)) : this.game.cache.getSound(c) && this.game.cache.isSoundReady(c) ? (this._sound = this.game.cache.getSoundData(c), this.totalDuration = 0, this._sound.duration && (this.totalDuration = this._sound.duration)) : this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this), this.onDecoded = new b.Signal, this.onPlay = new b.Signal, this.onPause = new b.Signal, this.onResume = new b.Signal, this.onLoop = new b.Signal, this.onStop = new b.Signal, this.onMute = new b.Signal, this.onMarkerComplete = new b.Signal, this._volume = d, this._buffer = null, this._muted = !1, this._tempMarker = 0, this._tempPosition = 0, this._tempVolume = 0, this._tempLoop = 0, this._paused = !1, this._onDecodedEventDispatched = !1
  6732. }, b.Sound.prototype = {
  6733. soundHasUnlocked: function(a) {
  6734. a == this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration)
  6735. },
  6736. addMarker: function(a, b, c, d, e) {
  6737. "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = !1), this.markers[a] = {
  6738. name: a,
  6739. start: b,
  6740. stop: b + c,
  6741. volume: d,
  6742. duration: c,
  6743. durationMS: 1e3 * c,
  6744. loop: e
  6745. }
  6746. },
  6747. removeMarker: function(a) {
  6748. delete this.markers[a]
  6749. },
  6750. update: function() {
  6751. this.isDecoded && !this._onDecodedEventDispatched && (this.onDecoded.dispatch(this), this._onDecodedEventDispatched = !0), this.pendingPlayback && this.game.cache.isSoundReady(this.key) && (this.pendingPlayback = !1, this.play(this._tempMarker, this._tempPosition, this._tempVolume, this._tempLoop)), this.isPlaying && (this.currentTime = this.game.time.now - this.startTime, this.currentTime >= this.durationMS && (this.usingWebAudio ? this.loop ? (this.onLoop.dispatch(this), "" === this.currentMarker ? (this.currentTime = 0, this.startTime = this.game.time.now) : (this.onMarkerComplete.dispatch(this.currentMarker, this), this.play(this.currentMarker, 0, this.volume, !0, !0))) : this.stop() : this.loop ? (this.onLoop.dispatch(this), this.play(this.currentMarker, 0, this.volume, !0, !0)) : this.stop()))
  6752. },
  6753. play: function(a, b, c, d, e) {
  6754. if ("undefined" == typeof a && (a = ""), "undefined" == typeof e && (e = !0), this.isPlaying === !0 && e === !1 && this.override === !1) return this;
  6755. if (this.isPlaying && this.override && (this.usingWebAudio ? "undefined" == typeof this._sound.stop ? this._sound.noteOff(0) : this._sound.stop(0) : this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0)), this.currentMarker = a, "" !== a) {
  6756. if (!this.markers[a]) return console.warn("Phaser.Sound.play: audio marker " + a + " doesn't exist"), this;
  6757. this.position = this.markers[a].start, this.volume = this.markers[a].volume, this.loop = this.markers[a].loop, this.duration = this.markers[a].duration, this.durationMS = this.markers[a].durationMS, "undefined" != typeof c && (this.volume = c), "undefined" != typeof d && (this.loop = d), this._tempMarker = a, this._tempPosition = this.position, this._tempVolume = this.volume, this._tempLoop = this.loop
  6758. } else b = b || 0, "undefined" == typeof c && (c = this._volume), "undefined" == typeof d && (d = this.loop), this.position = b, this.volume = c, this.loop = d, this.duration = 0, this.durationMS = 0, this._tempMarker = a, this._tempPosition = b, this._tempVolume = c, this._tempLoop = d;
  6759. return this.usingWebAudio ? this.game.cache.isSoundDecoded(this.key) ? (null == this._buffer && (this._buffer = this.game.cache.getSoundData(this.key)), this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this.externalNode ? this._sound.connect(this.externalNode) : this._sound.connect(this.gainNode), this.totalDuration = this._sound.buffer.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = 1e3 * this.totalDuration), this.loop && "" === a && (this._sound.loop = !0), "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, this.position, this.duration) : this._sound.start(0, this.position, this.duration), this.isPlaying = !0, this.startTime = this.game.time.now, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : (this.pendingPlayback = !0, this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding === !1 && this.game.sound.decode(this.key, this)) : this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked ? (this.game.cache.reloadSound(this.key), this.pendingPlayback = !0) : this._sound && (this.game.device.cocoonJS || 4 === this._sound.readyState) ? (this._sound.play(), this.totalDuration = this._sound.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = 1e3 * this.totalDuration), this._sound.currentTime = this.position, this._sound.muted = this._muted, this._sound.volume = this._muted ? 0 : this._volume, this.isPlaying = !0, this.startTime = this.game.time.now, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : this.pendingPlayback = !0, this
  6760. },
  6761. restart: function(a, b, c, d) {
  6762. a = a || "", b = b || 0, c = c || 1, "undefined" == typeof d && (d = !1), this.play(a, b, c, d, !0)
  6763. },
  6764. pause: function() {
  6765. this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.now, this.onPause.dispatch(this), this.stop())
  6766. },
  6767. resume: function() {
  6768. if (this.paused && this._sound) {
  6769. if (this.usingWebAudio) {
  6770. var a = this.position + this.pausedPosition / 1e3;
  6771. this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this.externalNode ? this._sound.connect(this.externalNode) : this._sound.connect(this.gainNode), this.loop && (this._sound.loop = !0), "undefined" == typeof this._sound.start ? this._sound.noteGrainOn(0, a, this.duration) : this._sound.start(0, a, this.duration)
  6772. } else this._sound.play();
  6773. this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.now - this.pausedTime, this.onResume.dispatch(this)
  6774. }
  6775. },
  6776. stop: function() {
  6777. if (this.isPlaying && this._sound)
  6778. if (this.usingWebAudio)
  6779. if ("undefined" == typeof this._sound.stop) this._sound.noteOff(0);
  6780. else try {
  6781. this._sound.stop(0)
  6782. } catch (a) {} else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
  6783. this.isPlaying = !1;
  6784. var b = this.currentMarker;
  6785. "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", this.paused || this.onStop.dispatch(this, b)
  6786. },
  6787. destroy: function(a) {
  6788. "undefined" == typeof a && (a = !0), this.stop(), a ? this.game.sound.remove(this) : (this.markers = {}, this.context = null, this._buffer = null, this.externalNode = null, this.onDecoded.dispose(), this.onPlay.dispose(), this.onPause.dispose(), this.onResume.dispose(), this.onLoop.dispose(), this.onStop.dispose(), this.onMute.dispose(), this.onMarkerComplete.dispose())
  6789. }
  6790. }, b.Sound.prototype.constructor = b.Sound, Object.defineProperty(b.Sound.prototype, "isDecoding", {
  6791. get: function() {
  6792. return this.game.cache.getSound(this.key).isDecoding
  6793. }
  6794. }), Object.defineProperty(b.Sound.prototype, "isDecoded", {
  6795. get: function() {
  6796. return this.game.cache.isSoundDecoded(this.key)
  6797. }
  6798. }), Object.defineProperty(b.Sound.prototype, "mute", {
  6799. get: function() {
  6800. return this._muted || this.game.sound.mute
  6801. },
  6802. set: function(a) {
  6803. a = a || null, a ? (this._muted = !0, this.usingWebAudio ? (this._muteVolume = this.gainNode.gain.value, this.gainNode.gain.value = 0) : this.usingAudioTag && this._sound && (this._muteVolume = this._sound.volume, this._sound.volume = 0)) : (this._muted = !1, this.usingWebAudio ? this.gainNode.gain.value = this._muteVolume : this.usingAudioTag && this._sound && (this._sound.volume = this._muteVolume)), this.onMute.dispatch(this)
  6804. }
  6805. }), Object.defineProperty(b.Sound.prototype, "volume", {
  6806. get: function() {
  6807. return this._volume
  6808. },
  6809. set: function(a) {
  6810. this.usingWebAudio ? (this._volume = a, this.gainNode.gain.value = a) : this.usingAudioTag && this._sound && a >= 0 && 1 >= a && (this._volume = a, this._sound.volume = a)
  6811. }
  6812. }), b.SoundManager = function(a) {
  6813. this.game = a, this.onSoundDecode = new b.Signal, this._codeMuted = !1, this._muted = !1, this._unlockSource = null, this._volume = 1, this._sounds = [], this.context = null, this.usingWebAudio = !0, this.usingAudioTag = !1, this.noAudio = !1, this.connectToMaster = !0, this.touchLocked = !1, this.channels = 32
  6814. }, b.SoundManager.prototype = {
  6815. boot: function() {
  6816. if (this.game.device.iOS && this.game.device.webAudio === !1 && (this.channels = 1), !this.game.device.cocoonJS && this.game.device.iOS || window["PhaserGlobal"] && window["PhaserGlobal"].fakeiOSTouchLock ? (this.game.input.touch.callbackContext = this, this.game.input.touch.touchStartCallback = this.unlock, this.game.input.mouse.callbackContext = this, this.game.input.mouse.mouseDownCallback = this.unlock, this.touchLocked = !0) : this.touchLocked = !1, window["PhaserGlobal"]) {
  6817. if (window["PhaserGlobal"].disableAudio === !0) return this.usingWebAudio = !1, this.noAudio = !0, void 0;
  6818. if (window["PhaserGlobal"].disableWebAudio === !0) return this.usingWebAudio = !1, this.usingAudioTag = !0, this.noAudio = !1, void 0
  6819. }
  6820. if (window["AudioContext"]) try {
  6821. this.context = new window["AudioContext"]
  6822. } catch (a) {
  6823. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  6824. } else if (window["webkitAudioContext"]) try {
  6825. this.context = new window["webkitAudioContext"]
  6826. } catch (a) {
  6827. this.context = null, this.usingWebAudio = !1, this.noAudio = !0
  6828. }
  6829. window["Audio"] && null === this.context && (this.usingWebAudio = !1, this.usingAudioTag = !0, this.noAudio = !1), null !== this.context && (this.masterGain = "undefined" == typeof this.context.createGain ? this.context.createGainNode() : this.context.createGain(), this.masterGain.gain.value = 1, this.masterGain.connect(this.context.destination))
  6830. },
  6831. unlock: function() {
  6832. if (this.touchLocked !== !1)
  6833. if (this.game.device.webAudio === !1 || window["PhaserGlobal"] && window["PhaserGlobal"].disableWebAudio === !0) this.touchLocked = !1, this._unlockSource = null, this.game.input.touch.callbackContext = null, this.game.input.touch.touchStartCallback = null, this.game.input.mouse.callbackContext = null, this.game.input.mouse.mouseDownCallback = null;
  6834. else {
  6835. var a = this.context.createBuffer(1, 1, 22050);
  6836. this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = a, this._unlockSource.connect(this.context.destination), this._unlockSource.noteOn(0)
  6837. }
  6838. },
  6839. stopAll: function() {
  6840. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].stop()
  6841. },
  6842. pauseAll: function() {
  6843. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].pause()
  6844. },
  6845. resumeAll: function() {
  6846. for (var a = 0; a < this._sounds.length; a++) this._sounds[a] && this._sounds[a].resume()
  6847. },
  6848. decode: function(a, b) {
  6849. var c, d;
  6850. b = b || null, c = this.game.cache.getSoundData(a), c && this.game.cache.isSoundDecoded(a) === !1 && (this.game.cache.updateSound(a, "isDecoding", !0), d = this, this.context.decodeAudioData(c, function(c) {
  6851. d.game.cache.decodedSound(a, c), b && d.onSoundDecode.dispatch(a, b)
  6852. }))
  6853. },
  6854. update: function() {
  6855. this.touchLocked && this.game.device.webAudio && null !== this._unlockSource && (this._unlockSource.playbackState === this._unlockSource.PLAYING_STATE || this._unlockSource.playbackState === this._unlockSource.FINISHED_STATE) && (this.touchLocked = !1, this._unlockSource = null, this.game.input.touch.callbackContext = null, this.game.input.touch.touchStartCallback = null);
  6856. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].update()
  6857. },
  6858. add: function(a, c, d, e) {
  6859. "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = this.connectToMaster);
  6860. var f = new b.Sound(this.game, a, c, d, e);
  6861. return this._sounds.push(f), f
  6862. },
  6863. remove: function(a) {
  6864. for (var b = this._sounds.length; b--;)
  6865. if (this._sounds[b] === a) return this._sounds[b].destroy(!1), this._sounds.splice(b, 1), !0;
  6866. return !1
  6867. },
  6868. removeByKey: function(a) {
  6869. for (var b = this._sounds.length, c = 0; b--;) this._sounds[b].key === a && (this._sounds[b].destroy(!1), this._sounds.splice(b, 1), c++);
  6870. return c
  6871. },
  6872. play: function(a, b, c) {
  6873. var d = this.add(a, b, c);
  6874. return d.play(), d
  6875. },
  6876. setMute: function() {
  6877. if (!this._muted) {
  6878. this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
  6879. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !0)
  6880. }
  6881. },
  6882. unsetMute: function() {
  6883. if (this._muted && !this._codeMuted) {
  6884. this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
  6885. for (var a = 0; a < this._sounds.length; a++) this._sounds[a].usingAudioTag && (this._sounds[a].mute = !1)
  6886. }
  6887. }
  6888. }, b.SoundManager.prototype.constructor = b.SoundManager, Object.defineProperty(b.SoundManager.prototype, "mute", {
  6889. get: function() {
  6890. return this._muted
  6891. },
  6892. set: function(a) {
  6893. if (a = a || null) {
  6894. if (this._muted) return;
  6895. this._codeMuted = !0, this.setMute()
  6896. } else {
  6897. if (!this._muted) return;
  6898. this._codeMuted = !1, this.unsetMute()
  6899. }
  6900. }
  6901. }), Object.defineProperty(b.SoundManager.prototype, "volume", {
  6902. get: function() {
  6903. return this.usingWebAudio ? this.masterGain.gain.value : this._volume
  6904. },
  6905. set: function(a) {
  6906. if (this._volume = a, this.usingWebAudio) this.masterGain.gain.value = a;
  6907. else
  6908. for (var b = 0; b < this._sounds.length; b++) this._sounds[b].usingAudioTag && (this._sounds[b].volume = this._sounds[b].volume * a)
  6909. }
  6910. }), b.Utils.Debug = function(a) {
  6911. this.game = a, this.sprite = null, this.canvas = null, this.baseTexture = null, this.texture = null, this.textureFrame = null, this.context = null, this.font = "14px Courier", this.columnWidth = 100, this.lineHeight = 16, this.renderShadow = !0, this.currentX = 0, this.currentY = 0, this.currentAlpha = 1, this.dirty = !1
  6912. }, b.Utils.Debug.prototype = {
  6913. boot: function() {
  6914. this.game.renderType === b.CANVAS ? this.context = this.game.context : (this.canvas = b.Canvas.create(this.game.width, this.game.height, "", !0), this.context = this.canvas.getContext("2d"), this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new b.Frame(0, 0, 0, this.game.width, this.game.height, "debug", this.game.rnd.uuid()), this.sprite = this.game.make.image(0, 0, this.texture, this.textureFrame), this.game.stage.addChild(this.sprite))
  6915. },
  6916. preUpdate: function() {
  6917. this.dirty && this.sprite && (this.context.clearRect(0, 0, this.game.width, this.game.height), this.dirty = !1)
  6918. },
  6919. start: function(a, b, c, d) {
  6920. "number" != typeof a && (a = 0), "number" != typeof b && (b = 0), c = c || "rgb(255,255,255)", "undefined" == typeof d && (d = 0), this.currentX = a, this.currentY = b, this.currentColor = c, this.currentAlpha = this.context.globalAlpha, this.columnWidth = d, this.sprite && (this.dirty = !0), this.context.save(), this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.strokeStyle = c, this.context.fillStyle = c, this.context.font = this.font, this.context.globalAlpha = 1
  6921. },
  6922. stop: function() {
  6923. this.context.restore(), this.context.globalAlpha = this.currentAlpha, this.sprite && PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl)
  6924. },
  6925. line: function() {
  6926. var b, a = this.currentX;
  6927. for (b = 0; b < arguments.length; b++) this.renderShadow && (this.context.fillStyle = "rgb(0,0,0)", this.context.fillText(arguments[b], a + 1, this.currentY + 1), this.context.fillStyle = this.currentColor), this.context.fillText(arguments[b], a, this.currentY), a += this.columnWidth;
  6928. this.currentY += this.lineHeight
  6929. },
  6930. soundInfo: function(a, b, c, d) {
  6931. this.start(b, c, d), this.line("Sound: " + a.key + " Locked: " + a.game.sound.touchLocked), this.line("Is Ready?: " + this.game.cache.isSoundReady(a.key) + " Pending Playback: " + a.pendingPlayback), this.line("Decoded: " + a.isDecoded + " Decoding: " + a.isDecoding), this.line("Total Duration: " + a.totalDuration + " Playing: " + a.isPlaying), this.line("Time: " + a.currentTime), this.line("Volume: " + a.volume + " Muted: " + a.mute), this.line("WebAudio: " + a.usingWebAudio + " Audio: " + a.usingAudioTag), "" !== a.currentMarker && (this.line("Marker: " + a.currentMarker + " Duration: " + a.duration + " (ms: " + a.durationMS + ")"), this.line("Start: " + a.markers[a.currentMarker].start + " Stop: " + a.markers[a.currentMarker].stop), this.line("Position: " + a.position)), this.stop()
  6932. },
  6933. cameraInfo: function(a, b, c, d) {
  6934. this.start(b, c, d), this.line("Camera (" + a.width + " x " + a.height + ")"), this.line("X: " + a.x + " Y: " + a.y), this.line("Bounds x: " + a.bounds.x + " Y: " + a.bounds.y + " w: " + a.bounds.width + " h: " + a.bounds.height), this.line("View x: " + a.view.x + " Y: " + a.view.y + " w: " + a.view.width + " h: " + a.view.height), this.stop()
  6935. },
  6936. timer: function(a, b, c, d) {
  6937. this.start(b, c, d), this.line("Timer (running: " + a.running + " expired: " + a.expired + ")"), this.line("Next Tick: " + a.next + " Duration: " + a.duration), this.line("Paused: " + a.paused + " Length: " + a.length), this.stop()
  6938. },
  6939. pointer: function(a, b, c, d, e) {
  6940. null != a && ("undefined" == typeof b && (b = !1), c = c || "rgba(0,255,0,0.5)", d = d || "rgba(255,0,0,0.5)", (b !== !0 || a.isUp !== !0) && (this.start(a.x, a.y - 100, e), this.context.beginPath(), this.context.arc(a.x, a.y, a.circle.radius, 0, 2 * Math.PI), this.context.fillStyle = a.active ? c : d, this.context.fill(), this.context.closePath(), this.context.beginPath(), this.context.moveTo(a.positionDown.x, a.positionDown.y), this.context.lineTo(a.position.x, a.position.y), this.context.lineWidth = 2, this.context.stroke(), this.context.closePath(), this.line("ID: " + a.id + " Active: " + a.active), this.line("World X: " + a.worldX + " World Y: " + a.worldY), this.line("Screen X: " + a.x + " Screen Y: " + a.y), this.line("Duration: " + a.duration + " ms"), this.line("is Down: " + a.isDown + " is Up: " + a.isUp), this.stop()))
  6941. },
  6942. spriteInputInfo: function(a, b, c, d) {
  6943. this.start(b, c, d), this.line("Sprite Input: (" + a.width + " x " + a.height + ")"), this.line("x: " + a.input.pointerX().toFixed(1) + " y: " + a.input.pointerY().toFixed(1)), this.line("over: " + a.input.pointerOver() + " duration: " + a.input.overDuration().toFixed(0)), this.line("down: " + a.input.pointerDown() + " duration: " + a.input.downDuration().toFixed(0)), this.line("just over: " + a.input.justOver() + " just out: " + a.input.justOut()), this.stop()
  6944. },
  6945. key: function(a, b, c, d) {
  6946. this.start(b, c, d, 150), this.line("Key:", a.keyCode, "isDown:", a.isDown), this.line("justPressed:", a.justPressed(), "justReleased:", a.justReleased()), this.line("Time Down:", a.timeDown.toFixed(0), "duration:", a.duration.toFixed(0)), this.stop()
  6947. },
  6948. inputInfo: function(a, b, c) {
  6949. this.start(a, b, c), this.line("Input"), this.line("X: " + this.game.input.x + " Y: " + this.game.input.y), this.line("World X: " + this.game.input.worldX + " World Y: " + this.game.input.worldY), this.line("Scale X: " + this.game.input.scale.x.toFixed(1) + " Scale Y: " + this.game.input.scale.x.toFixed(1)), this.line("Screen X: " + this.game.input.activePointer.screenX + " Screen Y: " + this.game.input.activePointer.screenY), this.stop()
  6950. },
  6951. spriteBounds: function(a, b, c) {
  6952. var d = a.getBounds();
  6953. d.x += this.game.camera.x, d.y += this.game.camera.y, this.rectangle(d, b, c)
  6954. },
  6955. spriteInfo: function(a, b, c, d) {
  6956. this.start(b, c, d), this.line("Sprite: (" + a.width + " x " + a.height + ") anchor: " + a.anchor.x + " x " + a.anchor.y), this.line("x: " + a.x.toFixed(1) + " y: " + a.y.toFixed(1)), this.line("angle: " + a.angle.toFixed(1) + " rotation: " + a.rotation.toFixed(1)), this.line("visible: " + a.visible + " in camera: " + a.inCamera), this.stop()
  6957. },
  6958. spriteCoords: function(a, b, c, d) {
  6959. this.start(b, c, d, 100), a.name && this.line(a.name), this.line("x:", a.x.toFixed(2), "y:", a.y.toFixed(2)), this.line("pos x:", a.position.x.toFixed(2), "pos y:", a.position.y.toFixed(2)), this.line("world x:", a.world.x.toFixed(2), "world y:", a.world.y.toFixed(2)), this.stop()
  6960. },
  6961. lineInfo: function(a, b, c, d) {
  6962. this.start(b, c, d, 80), this.line("start.x:", a.start.x.toFixed(2), "start.y:", a.start.y.toFixed(2)), this.line("end.x:", a.end.x.toFixed(2), "end.y:", a.end.y.toFixed(2)), this.line("length:", a.length.toFixed(2), "angle:", a.angle), this.stop()
  6963. },
  6964. pixel: function(a, b, c, d) {
  6965. d = d || 2, this.start(), this.context.fillStyle = c, this.context.fillRect(a, b, d, d), this.stop()
  6966. },
  6967. geom: function(a, c, d, e) {
  6968. "undefined" == typeof d && (d = !0), "undefined" == typeof e && (e = 0), c = c || "rgba(0,255,0,0.4)", this.start(), this.context.fillStyle = c, this.context.strokeStyle = c, a instanceof b.Rectangle || 1 === e ? d ? this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height) : this.context.strokeRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height) : a instanceof b.Circle || 2 === e ? (this.context.beginPath(), this.context.arc(a.x - this.game.camera.x, a.y - this.game.camera.y, a.radius, 0, 2 * Math.PI, !1), this.context.closePath(), d ? this.context.fill() : this.context.stroke()) : a instanceof b.Point || 3 === e ? this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, 4, 4) : (a instanceof b.Line || 4 === e) && (this.context.lineWidth = 1, this.context.beginPath(), this.context.moveTo(a.start.x + .5 - this.game.camera.x, a.start.y + .5 - this.game.camera.y), this.context.lineTo(a.end.x + .5 - this.game.camera.x, a.end.y + .5 - this.game.camera.y), this.context.closePath(), this.context.stroke()), this.stop()
  6969. },
  6970. rectangle: function(a, b, c) {
  6971. "undefined" == typeof c && (c = !0), b = b || "rgba(0, 255, 0, 0.4)", this.start(), c ? (this.context.fillStyle = b, this.context.fillRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height)) : (this.context.strokeStyle = b, this.context.strokeRect(a.x - this.game.camera.x, a.y - this.game.camera.y, a.width, a.height)), this.stop()
  6972. },
  6973. text: function(a, b, c, d, e) {
  6974. d = d || "rgb(255,255,255)", e = e || "16px Courier", this.start(), this.context.font = e, this.renderShadow && (this.context.fillStyle = "rgb(0,0,0)", this.context.fillText(a, b + 1, c + 1)), this.context.fillStyle = d, this.context.fillText(a, b, c), this.stop()
  6975. },
  6976. quadTree: function(a, b) {
  6977. var c, d;
  6978. if (b = b || "rgba(255,0,0,0.3)", this.start(), c = a.bounds, 0 === a.nodes.length)
  6979. for (this.context.strokeStyle = b, this.context.strokeRect(c.x, c.y, c.width, c.height), this.text("size: " + a.objects.length, c.x + 4, c.y + 16, "rgb(0,200,0)", "12px Courier"), this.context.strokeStyle = "rgb(0,255,0)", d = 0; d < a.objects.length; d++) this.context.strokeRect(a.objects[d].x, a.objects[d].y, a.objects[d].width, a.objects[d].height);
  6980. else
  6981. for (d = 0; d < a.nodes.length; d++) this.quadTree(a.nodes[d]);
  6982. this.stop()
  6983. },
  6984. body: function(a, c, d) {
  6985. a.body && (a.body.type === b.Physics.ARCADE ? (this.start(), b.Physics.Arcade.Body.render(this.context, a.body, c, d), this.stop()) : a.body.type === b.Physics.NINJA && (this.start(), b.Physics.Ninja.Body.render(this.context, a.body, c, d), this.stop()))
  6986. },
  6987. bodyInfo: function(a, c, d, e) {
  6988. a.body && a.body.type === b.Physics.ARCADE && (this.start(c, d, e, 210), b.Physics.Arcade.Body.renderBodyInfo(this, a.body), this.stop())
  6989. }
  6990. }, b.Utils.Debug.prototype.constructor = b.Utils.Debug, b.Color = {
  6991. packPixel: function(a, c, d, e) {
  6992. return b.Device.LITTLE_ENDIAN ? (e << 24 | d << 16 | c << 8 | a) >>> 0 : (a << 24 | c << 16 | d << 8 | e) >>> 0
  6993. },
  6994. unpackPixel: function(a, c, d, e) {
  6995. return ("undefined" == typeof c || null === c) && (c = b.Color.createColor()), ("undefined" == typeof d || null === d) && (d = !1), ("undefined" == typeof e || null === e) && (e = !1), b.Device.LITTLE_ENDIAN ? (c.a = (4278190080 & a) >>> 24, c.b = (16711680 & a) >>> 16, c.g = (65280 & a) >>> 8, c.r = 255 & a) : (c.r = (4278190080 & a) >>> 24, c.g = (16711680 & a) >>> 16, c.b = (65280 & a) >>> 8, c.a = 255 & a), c.color = a, c.rgba = "rgba(" + c.r + "," + c.g + "," + c.b + "," + c.a / 255 + ")", d && b.Color.RGBtoHSL(c.r, c.g, c.b, c), e && b.Color.RGBtoHSV(c.r, c.g, c.b, c), c
  6996. },
  6997. fromRGBA: function(a, c) {
  6998. return c || (c = b.Color.createColor()), c.r = (4278190080 & a) >>> 24, c.g = (16711680 & a) >>> 16, c.b = (65280 & a) >>> 8, c.a = 255 & a, c.rgba = "rgba(" + c.r + "," + c.g + "," + c.b + "," + c.a + ")", c
  6999. },
  7000. toRGBA: function(a, b, c, d) {
  7001. return a << 24 | b << 16 | c << 8 | d
  7002. },
  7003. RGBtoHSL: function(a, c, d, e) {
  7004. var f, g, h;
  7005. return e || (e = b.Color.createColor(a, c, d, 1)), a /= 255, c /= 255, d /= 255, f = Math.min(a, c, d), g = Math.max(a, c, d), e.h = 0, e.s = 0, e.l = (g + f) / 2, g !== f && (h = g - f, e.s = e.l > .5 ? h / (2 - g - f) : h / (g + f), g === a ? e.h = (c - d) / h + (d > c ? 6 : 0) : g === c ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - c) / h + 4), e.h /= 6), e
  7006. },
  7007. HSLtoRGB: function(a, c, d, e) {
  7008. var f, g;
  7009. return e ? (e.r = d, e.g = d, e.b = d) : e = b.Color.createColor(d, d, d), 0 !== c && (f = .5 > d ? d * (1 + c) : d + c - d * c, g = 2 * d - f, e.r = b.Color.hueToColor(g, f, a + 1 / 3), e.g = b.Color.hueToColor(g, f, a), e.b = b.Color.hueToColor(g, f, a - 1 / 3)), e.r = Math.floor(0 | 255 * e.r), e.g = Math.floor(0 | 255 * e.g), e.b = Math.floor(0 | 255 * e.b), b.Color.updateColor(e), e
  7010. },
  7011. RGBtoHSV: function(a, c, d, e) {
  7012. var f, g, h;
  7013. return e || (e = b.Color.createColor(a, c, d, 255)), a /= 255, c /= 255, d /= 255, f = Math.min(a, c, d), g = Math.max(a, c, d), h = g - f, e.h = 0, e.s = 0 === g ? 0 : h / g, e.v = g, g !== f && (g === a ? e.h = (c - d) / h + (d > c ? 6 : 0) : g === c ? e.h = (d - a) / h + 2 : g === d && (e.h = (a - c) / h + 4), e.h /= 6), e
  7014. },
  7015. HSVtoRGB: function(a, c, d, e) {
  7016. var f, g, h, i, j, k, l, m;
  7017. switch ("undefined" == typeof e && (e = b.Color.createColor(0, 0, 0, 1, a, c, 0, d)), i = Math.floor(6 * a), j = 6 * a - i, k = d * (1 - c), l = d * (1 - j * c), m = d * (1 - (1 - j) * c), i % 6) {
  7018. case 0:
  7019. f = d, g = m, h = k;
  7020. break;
  7021. case 1:
  7022. f = l, g = d, h = k;
  7023. break;
  7024. case 2:
  7025. f = k, g = d, h = m;
  7026. break;
  7027. case 3:
  7028. f = k, g = l, h = d;
  7029. break;
  7030. case 4:
  7031. f = m, g = k, h = d;
  7032. break;
  7033. case 5:
  7034. f = d, g = k, h = l
  7035. }
  7036. return e.r = Math.floor(255 * f), e.g = Math.floor(255 * g), e.b = Math.floor(255 * h), b.Color.updateColor(e), e
  7037. },
  7038. hueToColor: function(a, b, c) {
  7039. return 0 > c && (c += 1), c > 1 && (c -= 1), 1 / 6 > c ? a + 6 * (b - a) * c : .5 > c ? b : 2 / 3 > c ? a + 6 * (b - a) * (2 / 3 - c) : a
  7040. },
  7041. createColor: function(a, b, c, d, e, f, g, h) {
  7042. var i = {
  7043. r: a || 0,
  7044. g: b || 0,
  7045. b: c || 0,
  7046. a: d || 1,
  7047. h: e || 0,
  7048. s: f || 0,
  7049. l: g || 0,
  7050. v: h || 0,
  7051. color: 0
  7052. };
  7053. return i.rgba = "rgba(" + i.r + "," + i.g + "," + i.b + "," + i.a + ")", i
  7054. },
  7055. updateColor: function(a) {
  7056. return a.rgba = "rgba(" + a.r + "," + a.g + "," + a.b + "," + a.a + ")", a
  7057. },
  7058. getColor32: function(a, b, c, d) {
  7059. return a << 24 | b << 16 | c << 8 | d
  7060. },
  7061. getColor: function(a, b, c) {
  7062. return a << 16 | b << 8 | c
  7063. },
  7064. RGBtoString: function(a, c, d, e, f) {
  7065. return "undefined" == typeof e && (e = 255), "undefined" == typeof f && (f = "#"), "#" === f ? "#" + ((1 << 24) + (a << 16) + (c << 8) + d).toString(16).slice(1) : "0x" + b.Color.componentToHex(e) + b.Color.componentToHex(a) + b.Color.componentToHex(c) + b.Color.componentToHex(d)
  7066. },
  7067. hexToRGB: function(a) {
  7068. var c = b.Color.hexToColor(a);
  7069. return c ? b.Color.getColor32(c.a, c.r, c.g, c.b) : void 0
  7070. },
  7071. hexToColor: function(a, c) {
  7072. var d, e;
  7073. return c || (c = b.Color.createColor()), d = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, a = a.replace(d, function(a, b, c, d) {
  7074. return b + b + c + c + d + d
  7075. }), e = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a), e && (c.r = parseInt(e[1], 16), c.g = parseInt(e[2], 16), c.b = parseInt(e[3], 16)), c
  7076. },
  7077. componentToHex: function(a) {
  7078. var b = a.toString(16);
  7079. return 1 == b.length ? "0" + b : b
  7080. },
  7081. HSVColorWheel: function(a, c) {
  7082. var d, e;
  7083. for ("undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1), d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSVtoRGB(e / 359, a, c));
  7084. return d
  7085. },
  7086. HSLColorWheel: function(a, c) {
  7087. var d, e;
  7088. for ("undefined" == typeof a && (a = .5), "undefined" == typeof c && (c = .5), d = [], e = 0; 359 >= e; e++) d.push(b.Color.HSLtoRGB(e / 359, a, c));
  7089. return d
  7090. },
  7091. interpolateColor: function(a, c, d, e, f) {
  7092. var g, h, i, j, k;
  7093. return "undefined" == typeof f && (f = 255), g = b.Color.getRGB(a), h = b.Color.getRGB(c), i = (h.red - g.red) * e / d + g.red, j = (h.green - g.green) * e / d + g.green, k = (h.blue - g.blue) * e / d + g.blue, b.Color.getColor32(f, i, j, k)
  7094. },
  7095. interpolateColorWithRGB: function(a, c, d, e, f, g) {
  7096. var h = b.Color.getRGB(a),
  7097. i = (c - h.red) * g / f + h.red,
  7098. j = (d - h.green) * g / f + h.green,
  7099. k = (e - h.blue) * g / f + h.blue;
  7100. return b.Color.getColor(i, j, k)
  7101. },
  7102. interpolateRGB: function(a, c, d, e, f, g, h, i) {
  7103. var j = (e - a) * i / h + a,
  7104. k = (f - c) * i / h + c,
  7105. l = (g - d) * i / h + d;
  7106. return b.Color.getColor(j, k, l)
  7107. },
  7108. getRandomColor: function(a, c, d) {
  7109. var e, f, g;
  7110. return "undefined" == typeof a && (a = 0), "undefined" == typeof c && (c = 255), "undefined" == typeof d && (d = 255), c > 255 || a > c ? b.Color.getColor(255, 255, 255) : (e = a + Math.round(Math.random() * (c - a)), f = a + Math.round(Math.random() * (c - a)), g = a + Math.round(Math.random() * (c - a)), b.Color.getColor32(d, e, f, g))
  7111. },
  7112. getRGB: function(a) {
  7113. return a > 16777215 ? {
  7114. alpha: a >>> 24,
  7115. red: 255 & a >> 16,
  7116. green: 255 & a >> 8,
  7117. blue: 255 & a,
  7118. a: a >>> 24,
  7119. r: 255 & a >> 16,
  7120. g: 255 & a >> 8,
  7121. b: 255 & a
  7122. } : {
  7123. alpha: 255,
  7124. red: 255 & a >> 16,
  7125. green: 255 & a >> 8,
  7126. blue: 255 & a,
  7127. a: 255,
  7128. r: 255 & a >> 16,
  7129. g: 255 & a >> 8,
  7130. b: 255 & a
  7131. }
  7132. },
  7133. getWebRGB: function(a) {
  7134. if ("object" == typeof a) return "rgba(" + a.r.toString() + "," + a.g.toString() + "," + a.b.toString() + "," + (a.a / 255).toString() + ")";
  7135. var c = b.Color.getRGB(a);
  7136. return "rgba(" + c.r.toString() + "," + c.g.toString() + "," + c.b.toString() + "," + (c.a / 255).toString() + ")"
  7137. },
  7138. getAlpha: function(a) {
  7139. return a >>> 24
  7140. },
  7141. getAlphaFloat: function(a) {
  7142. return (a >>> 24) / 255
  7143. },
  7144. getRed: function(a) {
  7145. return 255 & a >> 16
  7146. },
  7147. getGreen: function(a) {
  7148. return 255 & a >> 8
  7149. },
  7150. getBlue: function(a) {
  7151. return 255 & a
  7152. },
  7153. getColorInfo: function(a) {
  7154. var c = b.Color.getRGB(a),
  7155. d = b.Color.RGBtoHexstring(a) + "\n";
  7156. return d = d.concat("Alpha: " + c.alpha + " Red: " + c.red + " Green: " + c.green + " Blue: " + c.blue) + "\n"
  7157. },
  7158. RGBtoHexstring: function(a) {
  7159. var c = b.Color.getRGB(a);
  7160. return "0x" + b.Color.colorToHexstring(c.alpha) + b.Color.colorToHexstring(c.red) + b.Color.colorToHexstring(c.green) + b.Color.colorToHexstring(c.blue)
  7161. },
  7162. RGBtoWebstring: function(a) {
  7163. var c = b.Color.getRGB(a);
  7164. return "#" + b.Color.colorToHexstring(c.red) + b.Color.colorToHexstring(c.green) + b.Color.colorToHexstring(c.blue)
  7165. },
  7166. colorToHexstring: function(a) {
  7167. var b = "0123456789ABCDEF",
  7168. c = a % 16,
  7169. d = (a - c) / 16,
  7170. e = b.charAt(d) + b.charAt(c);
  7171. return e
  7172. }
  7173. }, b.Physics = function(a, b) {
  7174. b = b || {}, this.game = a, this.config = b, this.arcade = null, this.p2 = null, this.ninja = null, this.box2d = null, this.chipmunk = null, this.parseConfig()
  7175. }, b.Physics.ARCADE = 0, b.Physics.P2JS = 1, b.Physics.NINJA = 2, b.Physics.BOX2D = 3, b.Physics.CHIPMUNK = 5, b.Physics.prototype = {
  7176. parseConfig: function() {
  7177. this.config.hasOwnProperty("arcade") && this.config["arcade"] !== !0 || !b.Physics.hasOwnProperty("Arcade") || (this.arcade = new b.Physics.Arcade(this.game), this.game.time.deltaCap = .2), this.config.hasOwnProperty("ninja") && this.config["ninja"] === !0 && b.Physics.hasOwnProperty("Ninja") && (this.ninja = new b.Physics.Ninja(this.game)), this.config.hasOwnProperty("p2") && this.config["p2"] === !0 && b.Physics.hasOwnProperty("P2") && (this.p2 = new b.Physics.P2(this.game, this.config))
  7178. },
  7179. startSystem: function(a) {
  7180. if (a === b.Physics.ARCADE ? this.arcade = new b.Physics.Arcade(this.game) : a === b.Physics.P2JS && (this.p2 = new b.Physics.P2(this.game, this.config)), a === b.Physics.NINJA) this.ninja = new b.Physics.Ninja(this.game);
  7181. else {
  7182. if (a === b.Physics.BOX2D && null === this.box2d) throw new Error("The Box2D physics system has not been implemented yet.");
  7183. if (a === b.Physics.CHIPMUNK && null === this.chipmunk) throw new Error("The Chipmunk physics system has not been implemented yet.")
  7184. }
  7185. this.setBoundsToWorld()
  7186. },
  7187. enable: function(a, c, d) {
  7188. "undefined" == typeof c && (c = b.Physics.ARCADE), "undefined" == typeof d && (d = !1), c === b.Physics.ARCADE ? this.arcade.enable(a) : c === b.Physics.P2JS && this.p2 ? this.p2.enable(a, d) : c === b.Physics.NINJA && this.ninja && this.ninja.enableAABB(a)
  7189. },
  7190. preUpdate: function() {
  7191. this.p2 && this.p2.preUpdate()
  7192. },
  7193. update: function() {
  7194. this.p2 && this.p2.update()
  7195. },
  7196. setBoundsToWorld: function() {
  7197. this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld()
  7198. },
  7199. clear: function() {
  7200. this.p2 && this.p2.clear()
  7201. },
  7202. destroy: function() {
  7203. this.p2 && this.p2.destroy(), this.arcade = null, this.ninja = null, this.p2 = null
  7204. }
  7205. }, b.Physics.prototype.constructor = b.Physics, b.Physics.Arcade = function(a) {
  7206. this.game = a, this.gravity = new b.Point, this.bounds = new b.Rectangle(0, 0, a.world.width, a.world.height), this.checkCollision = {
  7207. up: !0,
  7208. down: !0,
  7209. left: !0,
  7210. right: !0
  7211. }, this.maxObjects = 10, this.maxLevels = 4, this.OVERLAP_BIAS = 4, this.TILE_BIAS = 16, this.forceX = !1, this.quadTree = new b.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this._overlap = 0, this._maxOverlap = 0, this._velocity1 = 0, this._velocity2 = 0, this._newVelocity1 = 0, this._newVelocity2 = 0, this._average = 0, this._mapData = [], this._result = !1, this._total = 0, this._angle = 0, this._dx = 0, this._dy = 0
  7212. }, b.Physics.Arcade.prototype.constructor = b.Physics.Arcade, b.Physics.Arcade.prototype = {
  7213. setBounds: function(a, b, c, d) {
  7214. this.bounds.setTo(a, b, c, d)
  7215. },
  7216. setBoundsToWorld: function() {
  7217. this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height)
  7218. },
  7219. enable: function(a, c) {
  7220. "undefined" == typeof c && (c = !0);
  7221. var d = 1;
  7222. if (Array.isArray(a))
  7223. for (d = a.length; d--;) a[d] instanceof b.Group ? this.enable(a[d].children, c) : (this.enableBody(a[d]), c && a[d].hasOwnProperty("children") && a[d].children.length > 0 && this.enable(a[d], !0));
  7224. else a instanceof b.Group ? this.enable(a.children, c) : (this.enableBody(a), c && a.hasOwnProperty("children") && a.children.length > 0 && this.enable(a.children, !0))
  7225. },
  7226. enableBody: function(a) {
  7227. a.hasOwnProperty("body") && null === a.body && (a.body = new b.Physics.Arcade.Body(a))
  7228. },
  7229. updateMotion: function(a) {
  7230. this._velocityDelta = this.computeVelocity(0, a, a.angularVelocity, a.angularAcceleration, a.angularDrag, a.maxAngular) - a.angularVelocity, a.angularVelocity += this._velocityDelta, a.rotation += a.angularVelocity * this.game.time.physicsElapsed, a.velocity.x = this.computeVelocity(1, a, a.velocity.x, a.acceleration.x, a.drag.x, a.maxVelocity.x), a.velocity.y = this.computeVelocity(2, a, a.velocity.y, a.acceleration.y, a.drag.y, a.maxVelocity.y)
  7231. },
  7232. computeVelocity: function(a, b, c, d, e, f) {
  7233. return f = f || 1e4, 1 == a && b.allowGravity ? c += (this.gravity.x + b.gravity.x) * this.game.time.physicsElapsed : 2 == a && b.allowGravity && (c += (this.gravity.y + b.gravity.y) * this.game.time.physicsElapsed), d ? c += d * this.game.time.physicsElapsed : e && (this._drag = e * this.game.time.physicsElapsed, c - this._drag > 0 ? c -= this._drag : c + this._drag < 0 ? c += this._drag : c = 0), c > f ? c = f : -f > c && (c = -f), c
  7234. },
  7235. overlap: function(a, b, c, d, e) {
  7236. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  7237. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !0);
  7238. else this.collideHandler(a, b, c, d, e, !0);
  7239. return this._total > 0
  7240. },
  7241. collide: function(a, b, c, d, e) {
  7242. if (c = c || null, d = d || null, e = e || c, this._result = !1, this._total = 0, Array.isArray(b))
  7243. for (var f = 0, g = b.length; g > f; f++) this.collideHandler(a, b[f], c, d, e, !1);
  7244. else this.collideHandler(a, b, c, d, e, !1);
  7245. return this._total > 0
  7246. },
  7247. collideHandler: function(a, c, d, e, f, g) {
  7248. return "undefined" != typeof c || a.type !== b.GROUP && a.type !== b.EMITTER ? (a && c && a.exists && c.exists && (a.type == b.SPRITE || a.type == b.TILESPRITE ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsSprite(a, c, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideSpriteVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideSpriteVsTilemapLayer(a, c, d, e, f) : a.type == b.GROUP ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsGroup(c, a, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideGroupVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, c, d, e, f) : a.type == b.TILEMAPLAYER ? c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsTilemapLayer(c, a, d, e, f) : (c.type == b.GROUP || c.type == b.EMITTER) && this.collideGroupVsTilemapLayer(c, a, d, e, f) : a.type == b.EMITTER && (c.type == b.SPRITE || c.type == b.TILESPRITE ? this.collideSpriteVsGroup(c, a, d, e, f, g) : c.type == b.GROUP || c.type == b.EMITTER ? this.collideGroupVsGroup(a, c, d, e, f, g) : c.type == b.TILEMAPLAYER && this.collideGroupVsTilemapLayer(a, c, d, e, f))), void 0) : (this.collideGroupVsSelf(a, d, e, f, g), void 0)
  7249. },
  7250. collideSpriteVsSprite: function(a, b, c, d, e, f) {
  7251. return a.body && b.body ? (this.separate(a.body, b.body, d, e, f) && (c && c.call(e, a, b), this._total++), !0) : !1
  7252. },
  7253. collideSpriteVsGroup: function(a, b, c, d, e, f) {
  7254. if (0 !== b.length && a.body) {
  7255. this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(b), this._potentials = this.quadTree.retrieve(a);
  7256. for (var g = 0, h = this._potentials.length; h > g; g++) this.separate(a.body, this._potentials[g], d, e, f) && (c && c.call(e, a, this._potentials[g].sprite), this._total++)
  7257. }
  7258. },
  7259. collideGroupVsSelf: function(a, b, c, d, e) {
  7260. var f, g, h;
  7261. if (0 !== a.length)
  7262. for (f = a.children.length, g = 0; f > g; g++)
  7263. for (h = g + 1; f >= h; h++) a.children[g] && a.children[h] && a.children[g].exists && a.children[h].exists && this.collideSpriteVsSprite(a.children[g], a.children[h], b, c, d, e)
  7264. },
  7265. collideGroupVsGroup: function(a, b, c, d, e, f) {
  7266. if (0 !== a.length && 0 !== b.length)
  7267. for (var g = 0, h = a.children.length; h > g; g++) a.children[g].exists && this.collideSpriteVsGroup(a.children[g], b, c, d, e, f)
  7268. },
  7269. collideSpriteVsTilemapLayer: function(a, b, c, d, e) {
  7270. if (a.body && (this._mapData = b.getTiles(a.body.position.x - a.body.tilePadding.x, a.body.position.y - a.body.tilePadding.y, a.body.width + a.body.tilePadding.x, a.body.height + a.body.tilePadding.y, !1, !1), 0 !== this._mapData.length))
  7271. for (var f = 0; f < this._mapData.length; f++) d ? d.call(e, a, this._mapData[f]) && this.separateTile(f, a.body, this._mapData[f]) && (this._total++, c && c.call(e, a, this._mapData[f])) : this.separateTile(f, a.body, this._mapData[f]) && (this._total++, c && c.call(e, a, this._mapData[f]))
  7272. },
  7273. collideGroupVsTilemapLayer: function(a, b, c, d, e) {
  7274. if (0 !== a.length)
  7275. for (var f = 0, g = a.children.length; g > f; f++) a.children[f].exists && this.collideSpriteVsTilemapLayer(a.children[f], b, c, d, e)
  7276. },
  7277. separate: function(a, b, c, d, e) {
  7278. return a.enable && b.enable && this.intersects(a, b) ? c && c.call(d, a.sprite, b.sprite) === !1 ? !1 : e ? !0 : (this._result = this.forceX || Math.abs(this.gravity.y + a.gravity.y) < Math.abs(this.gravity.x + a.gravity.x) ? this.separateX(a, b, e) || this.separateY(a, b, e) : this.separateY(a, b, e) || this.separateX(a, b, e), this._result) : !1
  7279. },
  7280. intersects: function(a, b) {
  7281. return a.right <= b.position.x ? !1 : a.bottom <= b.position.y ? !1 : a.position.x >= b.right ? !1 : a.position.y >= b.bottom ? !1 : !0
  7282. },
  7283. separateX: function(a, b, c) {
  7284. return a.immovable && b.immovable ? !1 : (this._overlap = 0, this.intersects(a, b) && (this._maxOverlap = a.deltaAbsX() + b.deltaAbsX() + this.OVERLAP_BIAS, 0 === a.deltaX() && 0 === b.deltaX() ? (a.embedded = !0, b.embedded = !0) : a.deltaX() > b.deltaX() ? (this._overlap = a.right - b.x, this._overlap > this._maxOverlap || a.checkCollision.right === !1 || b.checkCollision.left === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.right = !0, b.touching.none = !1, b.touching.left = !0)) : a.deltaX() < b.deltaX() && (this._overlap = a.x - b.width - b.x, -this._overlap > this._maxOverlap || a.checkCollision.left === !1 || b.checkCollision.right === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.left = !0, b.touching.none = !1, b.touching.right = !0)), 0 !== this._overlap) ? (a.overlapX = this._overlap, b.overlapX = this._overlap, c || a.customSeparateX || b.customSeparateX ? !0 : (this._velocity1 = a.velocity.x, this._velocity2 = b.velocity.x, a.immovable || b.immovable ? a.immovable ? b.immovable || (b.x += this._overlap, b.velocity.x = this._velocity1 - this._velocity2 * b.bounce.x) : (a.x = a.x - this._overlap, a.velocity.x = this._velocity2 - this._velocity1 * a.bounce.x) : (this._overlap *= .5, a.x = a.x - this._overlap, b.x += this._overlap, this._newVelocity1 = Math.sqrt(this._velocity2 * this._velocity2 * b.mass / a.mass) * (this._velocity2 > 0 ? 1 : -1), this._newVelocity2 = Math.sqrt(this._velocity1 * this._velocity1 * a.mass / b.mass) * (this._velocity1 > 0 ? 1 : -1), this._average = .5 * (this._newVelocity1 + this._newVelocity2), this._newVelocity1 -= this._average, this._newVelocity2 -= this._average, a.velocity.x = this._average + this._newVelocity1 * a.bounce.x, b.velocity.x = this._average + this._newVelocity2 * b.bounce.x), !0)) : !1)
  7285. },
  7286. separateY: function(a, b, c) {
  7287. return a.immovable && b.immovable ? !1 : (this._overlap = 0, this.intersects(a, b) && (this._maxOverlap = a.deltaAbsY() + b.deltaAbsY() + this.OVERLAP_BIAS, 0 === a.deltaY() && 0 === b.deltaY() ? (a.embedded = !0, b.embedded = !0) : a.deltaY() > b.deltaY() ? (this._overlap = a.bottom - b.y, this._overlap > this._maxOverlap || a.checkCollision.down === !1 || b.checkCollision.up === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.down = !0, b.touching.none = !1, b.touching.up = !0)) : a.deltaY() < b.deltaY() && (this._overlap = a.y - b.bottom, -this._overlap > this._maxOverlap || a.checkCollision.up === !1 || b.checkCollision.down === !1 ? this._overlap = 0 : (a.touching.none = !1, a.touching.up = !0, b.touching.none = !1, b.touching.down = !0)), 0 !== this._overlap) ? (a.overlapY = this._overlap, b.overlapY = this._overlap, c || a.customSeparateY || b.customSeparateY ? !0 : (this._velocity1 = a.velocity.y, this._velocity2 = b.velocity.y, a.immovable || b.immovable ? a.immovable ? b.immovable || (b.y += this._overlap, b.velocity.y = this._velocity1 - this._velocity2 * b.bounce.y, a.moves && (b.x += a.x - a.prev.x)) : (a.y = a.y - this._overlap, a.velocity.y = this._velocity2 - this._velocity1 * a.bounce.y, b.moves && (a.x += b.x - b.prev.x)) : (this._overlap *= .5, a.y = a.y - this._overlap, b.y += this._overlap, this._newVelocity1 = Math.sqrt(this._velocity2 * this._velocity2 * b.mass / a.mass) * (this._velocity2 > 0 ? 1 : -1), this._newVelocity2 = Math.sqrt(this._velocity1 * this._velocity1 * a.mass / b.mass) * (this._velocity1 > 0 ? 1 : -1), this._average = .5 * (this._newVelocity1 + this._newVelocity2), this._newVelocity1 -= this._average, this._newVelocity2 -= this._average, a.velocity.y = this._average + this._newVelocity1 * a.bounce.y, b.velocity.y = this._average + this._newVelocity2 * b.bounce.y), !0)) : !1)
  7288. },
  7289. separateTile: function(a, b, c) {
  7290. var d, e, f, g;
  7291. if (!b.enable || !c.intersects(b.position.x, b.position.y, b.right, b.bottom)) return !1;
  7292. if (c.collisionCallback && !c.collisionCallback.call(c.collisionCallbackContext, b.sprite, c)) return !1;
  7293. if (c.layer.callbacks[c.index] && !c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext, b.sprite, c)) return !1;
  7294. if (!(c.faceLeft || c.faceRight || c.faceTop || c.faceBottom)) return !1;
  7295. if (d = 0, e = 0, f = 0, g = 1, b.deltaAbsX() > b.deltaAbsY() ? f = -1 : b.deltaAbsX() < b.deltaAbsY() && (g = -1), 0 !== b.deltaX() && 0 !== b.deltaY() && (c.faceLeft || c.faceRight) && (c.faceTop || c.faceBottom) && (f = Math.min(Math.abs(b.position.x - c.right), Math.abs(b.right - c.left)), g = Math.min(Math.abs(b.position.y - c.bottom), Math.abs(b.bottom - c.top))), g > f) {
  7296. if ((c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c), 0 !== d && !c.intersects(b.position.x, b.position.y, b.right, b.bottom))) return !0;
  7297. (c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c))
  7298. } else {
  7299. if ((c.faceTop || c.faceBottom) && (e = this.tileCheckY(b, c), 0 !== e && !c.intersects(b.position.x, b.position.y, b.right, b.bottom))) return !0;
  7300. (c.faceLeft || c.faceRight) && (d = this.tileCheckX(b, c))
  7301. }
  7302. return 0 !== d || 0 !== e
  7303. },
  7304. tileCheckX: function(a, b) {
  7305. var c = 0;
  7306. return a.deltaX() < 0 && !a.blocked.left && b.collideRight && a.checkCollision.left ? b.faceRight && a.x < b.right && (c = a.x - b.right, c < -this.TILE_BIAS && (c = 0)) : a.deltaX() > 0 && !a.blocked.right && b.collideLeft && a.checkCollision.right && b.faceLeft && a.right > b.left && (c = a.right - b.left, c > this.TILE_BIAS && (c = 0)), 0 !== c && this.processTileSeparationX(a, c), c
  7307. },
  7308. tileCheckY: function(a, b) {
  7309. var c = 0;
  7310. return a.deltaY() < 0 && !a.blocked.up && b.collideDown && a.checkCollision.up ? b.faceBottom && a.y < b.bottom && (c = a.y - b.bottom, c < -this.TILE_BIAS && (c = 0)) : a.deltaY() > 0 && !a.blocked.down && b.collideUp && a.checkCollision.down && b.faceTop && a.bottom > b.top && (c = a.bottom - b.top, c > this.TILE_BIAS && (c = 0)), 0 !== c && this.processTileSeparationY(a, c), c
  7311. },
  7312. processTileSeparationX: function(a, b) {
  7313. 0 > b ? a.blocked.left = !0 : b > 0 && (a.blocked.right = !0), a.position.x -= b, a.velocity.x = 0 === a.bounce.x ? 0 : -a.velocity.x * a.bounce.x
  7314. },
  7315. processTileSeparationY: function(a, b) {
  7316. 0 > b ? a.blocked.up = !0 : b > 0 && (a.blocked.down = !0), a.position.y -= b, a.velocity.y = 0 === a.bounce.y ? 0 : -a.velocity.y * a.bounce.y
  7317. },
  7318. getObjectsUnderPointer: function(a, c, d, e) {
  7319. var f, g, h, i;
  7320. if (0 !== c.length && a.exists) {
  7321. for (this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(c), f = new b.Rectangle(a.x, a.y, 1, 1), g = [], this._potentials = this.quadTree.retrieve(f), h = 0, i = this._potentials.length; i > h; h++) this._potentials[h].hitTest(a.x, a.y) && (d && d.call(e, a, this._potentials[h].sprite), g.push(this._potentials[h].sprite));
  7322. return g
  7323. }
  7324. },
  7325. moveToObject: function(a, b, c, d) {
  7326. return "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 0), this._angle = Math.atan2(b.y - a.y, b.x - a.x), d > 0 && (c = this.distanceBetween(a, b) / (d / 1e3)), a.body.velocity.x = Math.cos(this._angle) * c, a.body.velocity.y = Math.sin(this._angle) * c, this._angle
  7327. },
  7328. moveToPointer: function(a, b, c, d) {
  7329. return "undefined" == typeof b && (b = 60), c = c || this.game.input.activePointer, "undefined" == typeof d && (d = 0), this._angle = this.angleToPointer(a, c), d > 0 && (b = this.distanceToPointer(a, c) / (d / 1e3)), a.body.velocity.x = Math.cos(this._angle) * b, a.body.velocity.y = Math.sin(this._angle) * b, this._angle
  7330. },
  7331. moveToXY: function(a, b, c, d, e) {
  7332. return "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 0), this._angle = Math.atan2(c - a.y, b - a.x), e > 0 && (d = this.distanceToXY(a, b, c) / (e / 1e3)), a.body.velocity.x = Math.cos(this._angle) * d, a.body.velocity.y = Math.sin(this._angle) * d, this._angle
  7333. },
  7334. velocityFromAngle: function(a, c, d) {
  7335. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(this.game.math.degToRad(a)) * c, Math.sin(this.game.math.degToRad(a)) * c)
  7336. },
  7337. velocityFromRotation: function(a, c, d) {
  7338. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  7339. },
  7340. accelerationFromRotation: function(a, c, d) {
  7341. return "undefined" == typeof c && (c = 60), d = d || new b.Point, d.setTo(Math.cos(a) * c, Math.sin(a) * c)
  7342. },
  7343. accelerateToObject: function(a, b, c, d, e) {
  7344. return "undefined" == typeof c && (c = 60), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3), this._angle = this.angleBetween(a, b), a.body.acceleration.setTo(Math.cos(this._angle) * c, Math.sin(this._angle) * c), a.body.maxVelocity.setTo(d, e), this._angle
  7345. },
  7346. accelerateToPointer: function(a, b, c, d, e) {
  7347. return "undefined" == typeof c && (c = 60), "undefined" == typeof b && (b = this.game.input.activePointer), "undefined" == typeof d && (d = 1e3), "undefined" == typeof e && (e = 1e3), this._angle = this.angleToPointer(a, b), a.body.acceleration.setTo(Math.cos(this._angle) * c, Math.sin(this._angle) * c), a.body.maxVelocity.setTo(d, e), this._angle
  7348. },
  7349. accelerateToXY: function(a, b, c, d, e, f) {
  7350. return "undefined" == typeof d && (d = 60), "undefined" == typeof e && (e = 1e3), "undefined" == typeof f && (f = 1e3), this._angle = this.angleToXY(a, b, c), a.body.acceleration.setTo(Math.cos(this._angle) * d, Math.sin(this._angle) * d), a.body.maxVelocity.setTo(e, f), this._angle
  7351. },
  7352. distanceBetween: function(a, b) {
  7353. return this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  7354. },
  7355. distanceToXY: function(a, b, c) {
  7356. return this._dx = a.x - b, this._dy = a.y - c, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  7357. },
  7358. distanceToPointer: function(a, b) {
  7359. return b = b || this.game.input.activePointer, this._dx = a.x - b.x, this._dy = a.y - b.y, Math.sqrt(this._dx * this._dx + this._dy * this._dy)
  7360. },
  7361. angleBetween: function(a, b) {
  7362. return this._dx = b.x - a.x, this._dy = b.y - a.y, Math.atan2(this._dy, this._dx)
  7363. },
  7364. angleToXY: function(a, b, c) {
  7365. return this._dx = b - a.x, this._dy = c - a.y, Math.atan2(this._dy, this._dx)
  7366. },
  7367. angleToPointer: function(a, b) {
  7368. return b = b || this.game.input.activePointer, this._dx = b.worldX - a.x, this._dy = b.worldY - a.y, Math.atan2(this._dy, this._dx)
  7369. }
  7370. }, b.Physics.Arcade.Body = function(a) {
  7371. this.sprite = a, this.game = a.game, this.type = b.Physics.ARCADE, this.enable = !0, this.offset = new b.Point, this.position = new b.Point(a.x, a.y), this.prev = new b.Point(this.position.x, this.position.y), this.allowRotation = !0, this.rotation = a.rotation, this.preRotation = a.rotation, this.sourceWidth = a.texture.frame.width, this.sourceHeight = a.texture.frame.height, this.width = a.width, this.height = a.height, this.halfWidth = Math.abs(a.width / 2), this.halfHeight = Math.abs(a.height / 2), this.center = new b.Point(a.x + this.halfWidth, a.y + this.halfHeight), this.velocity = new b.Point, this.newVelocity = new b.Point(0, 0), this.deltaMax = new b.Point(0, 0), this.acceleration = new b.Point, this.drag = new b.Point, this.allowGravity = !0, this.gravity = new b.Point(0, 0), this.bounce = new b.Point, this.maxVelocity = new b.Point(1e4, 1e4), this.angularVelocity = 0, this.angularAcceleration = 0, this.angularDrag = 0, this.maxAngular = 1e3, this.mass = 1, this.angle = 0, this.speed = 0, this.facing = b.NONE, this.immovable = !1, this.moves = !0, this.customSeparateX = !1, this.customSeparateY = !1, this.overlapX = 0, this.overlapY = 0, this.embedded = !1, this.collideWorldBounds = !1, this.checkCollision = {
  7372. none: !1,
  7373. any: !0,
  7374. up: !0,
  7375. down: !0,
  7376. left: !0,
  7377. right: !0
  7378. }, this.touching = {
  7379. none: !0,
  7380. up: !1,
  7381. down: !1,
  7382. left: !1,
  7383. right: !1
  7384. }, this.wasTouching = {
  7385. none: !0,
  7386. up: !1,
  7387. down: !1,
  7388. left: !1,
  7389. right: !1
  7390. }, this.blocked = {
  7391. up: !1,
  7392. down: !1,
  7393. left: !1,
  7394. right: !1
  7395. }, this.tilePadding = new b.Point, this.phase = 0, this._reset = !0, this._sx = a.scale.x, this._sy = a.scale.y, this._dx = 0, this._dy = 0
  7396. }, b.Physics.Arcade.Body.prototype = {
  7397. updateBounds: function() {
  7398. var a = Math.abs(this.sprite.scale.x),
  7399. b = Math.abs(this.sprite.scale.y);
  7400. (a !== this._sx || b !== this._sy) && (this.width = this.sourceWidth * a, this.height = this.sourceHeight * b, this.halfWidth = Math.floor(this.width / 2), this.halfHeight = Math.floor(this.height / 2), this._sx = a, this._sy = b, this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight), this._reset = !0)
  7401. },
  7402. preUpdate: function() {
  7403. this.enable && (this.phase = 1, this.wasTouching.none = this.touching.none, this.wasTouching.up = this.touching.up, this.wasTouching.down = this.touching.down, this.wasTouching.left = this.touching.left, this.wasTouching.right = this.touching.right, this.touching.none = !0, this.touching.up = !1, this.touching.down = !1, this.touching.left = !1, this.touching.right = !1, this.blocked.up = !1, this.blocked.down = !1, this.blocked.left = !1, this.blocked.right = !1, this.embedded = !1, this.updateBounds(), this.position.x = this.sprite.world.x - this.sprite.anchor.x * this.width + this.offset.x, this.position.y = this.sprite.world.y - this.sprite.anchor.y * this.height + this.offset.y, this.rotation = this.sprite.angle, this.preRotation = this.rotation, (this._reset || 1 === this.sprite._cache[4]) && (this.prev.x = this.position.x, this.prev.y = this.position.y), this.moves && (this.game.physics.arcade.updateMotion(this), this.newVelocity.set(this.velocity.x * this.game.time.physicsElapsed, this.velocity.y * this.game.time.physicsElapsed), this.position.x += this.newVelocity.x, this.position.y += this.newVelocity.y, (this.position.x !== this.prev.x || this.position.y !== this.prev.y) && (this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), this.angle = Math.atan2(this.velocity.y, this.velocity.x)), this.collideWorldBounds && this.checkWorldBounds()), this._dx = this.deltaX(), this._dy = this.deltaY(), this._reset = !1)
  7404. },
  7405. postUpdate: function() {
  7406. this.enable && 2 !== this.phase && (this.phase = 2, this.deltaX() < 0 ? this.facing = b.LEFT : this.deltaX() > 0 && (this.facing = b.RIGHT), this.deltaY() < 0 ? this.facing = b.UP : this.deltaY() > 0 && (this.facing = b.DOWN), this.moves && (this._dx = this.deltaX(), this._dy = this.deltaY(), 0 !== this.deltaMax.x && 0 !== this._dx && (this._dx < 0 && this._dx < -this.deltaMax.x ? this._dx = -this.deltaMax.x : this._dx > 0 && this._dx > this.deltaMax.x && (this._dx = this.deltaMax.x)), 0 !== this.deltaMax.y && 0 !== this._dy && (this._dy < 0 && this._dy < -this.deltaMax.y ? this._dy = -this.deltaMax.y : this._dy > 0 && this._dy > this.deltaMax.y && (this._dy = this.deltaMax.y)), this.sprite.x += this._dx, this.sprite.y += this._dy), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight), this.allowRotation && (this.sprite.angle += this.deltaZ()), this.prev.x = this.position.x, this.prev.y = this.position.y)
  7407. },
  7408. destroy: function() {
  7409. this.sprite = null
  7410. },
  7411. checkWorldBounds: function() {
  7412. this.position.x < this.game.physics.arcade.bounds.x && this.game.physics.arcade.checkCollision.left ? (this.position.x = this.game.physics.arcade.bounds.x, this.velocity.x *= -this.bounce.x, this.blocked.left = !0) : this.right > this.game.physics.arcade.bounds.right && this.game.physics.arcade.checkCollision.right && (this.position.x = this.game.physics.arcade.bounds.right - this.width, this.velocity.x *= -this.bounce.x, this.blocked.right = !0), this.position.y < this.game.physics.arcade.bounds.y && this.game.physics.arcade.checkCollision.up ? (this.position.y = this.game.physics.arcade.bounds.y, this.velocity.y *= -this.bounce.y, this.blocked.up = !0) : this.bottom > this.game.physics.arcade.bounds.bottom && this.game.physics.arcade.checkCollision.down && (this.position.y = this.game.physics.arcade.bounds.bottom - this.height, this.velocity.y *= -this.bounce.y, this.blocked.down = !0)
  7413. },
  7414. setSize: function(a, b, c, d) {
  7415. "undefined" == typeof c && (c = this.offset.x), "undefined" == typeof d && (d = this.offset.y), this.sourceWidth = a, this.sourceHeight = b, this.width = this.sourceWidth * this._sx, this.height = this.sourceHeight * this._sy, this.halfWidth = Math.floor(this.width / 2), this.halfHeight = Math.floor(this.height / 2), this.offset.setTo(c, d), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight)
  7416. },
  7417. reset: function(a, b) {
  7418. this.velocity.set(0), this.acceleration.set(0), this.angularVelocity = 0, this.angularAcceleration = 0, this.position.x = a - this.sprite.anchor.x * this.width + this.offset.x, this.position.y = b - this.sprite.anchor.y * this.height + this.offset.y, this.prev.x = this.position.x, this.prev.y = this.position.y, this.rotation = this.sprite.angle, this.preRotation = this.rotation, this._sx = this.sprite.scale.x, this._sy = this.sprite.scale.y, this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight)
  7419. },
  7420. hitTest: function(a, c) {
  7421. return b.Rectangle.contains(this, a, c)
  7422. },
  7423. onFloor: function() {
  7424. return this.blocked.down
  7425. },
  7426. onWall: function() {
  7427. return this.blocked.left || this.blocked.right
  7428. },
  7429. deltaAbsX: function() {
  7430. return this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
  7431. },
  7432. deltaAbsY: function() {
  7433. return this.deltaY() > 0 ? this.deltaY() : -this.deltaY()
  7434. },
  7435. deltaX: function() {
  7436. return this.position.x - this.prev.x
  7437. },
  7438. deltaY: function() {
  7439. return this.position.y - this.prev.y
  7440. },
  7441. deltaZ: function() {
  7442. return this.rotation - this.preRotation
  7443. }
  7444. }, Object.defineProperty(b.Physics.Arcade.Body.prototype, "bottom", {
  7445. get: function() {
  7446. return this.position.y + this.height
  7447. }
  7448. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "right", {
  7449. get: function() {
  7450. return this.position.x + this.width
  7451. }
  7452. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "x", {
  7453. get: function() {
  7454. return this.position.x
  7455. },
  7456. set: function(a) {
  7457. this.position.x = a
  7458. }
  7459. }), Object.defineProperty(b.Physics.Arcade.Body.prototype, "y", {
  7460. get: function() {
  7461. return this.position.y
  7462. },
  7463. set: function(a) {
  7464. this.position.y = a
  7465. }
  7466. }), b.Physics.Arcade.Body.render = function(a, b, c, d) {
  7467. "undefined" == typeof d && (d = !0), c = c || "rgba(0,255,0,0.4)", d ? (a.fillStyle = c, a.fillRect(b.position.x - b.game.camera.x, b.position.y - b.game.camera.y, b.width, b.height)) : (a.strokeStyle = c, a.strokeRect(b.position.x - b.game.camera.x, b.position.y - b.game.camera.y, b.width, b.height))
  7468. }, b.Physics.Arcade.Body.renderBodyInfo = function(a, b) {
  7469. a.line("x: " + b.x.toFixed(2), "y: " + b.y.toFixed(2), "width: " + b.width, "height: " + b.height), a.line("velocity x: " + b.velocity.x.toFixed(2), "y: " + b.velocity.y.toFixed(2), "deltaX: " + b._dx.toFixed(2), "deltaY: " + b._dy.toFixed(2)), a.line("acceleration x: " + b.acceleration.x.toFixed(2), "y: " + b.acceleration.y.toFixed(2), "speed: " + b.speed.toFixed(2), "angle: " + b.angle.toFixed(2)), a.line("gravity x: " + b.gravity.x, "y: " + b.gravity.y, "bounce x: " + b.bounce.x.toFixed(2), "y: " + b.bounce.y.toFixed(2)), a.line("touching left: " + b.touching.left, "right: " + b.touching.right, "up: " + b.touching.up, "down: " + b.touching.down), a.line("blocked left: " + b.blocked.left, "right: " + b.blocked.right, "up: " + b.blocked.up, "down: " + b.blocked.down)
  7470. }, b.Physics.Arcade.Body.prototype.constructor = b.Physics.Arcade.Body, b.Particles = function(a) {
  7471. this.game = a, this.emitters = {}, this.ID = 0
  7472. }, b.Particles.prototype = {
  7473. add: function(a) {
  7474. return this.emitters[a.name] = a, a
  7475. },
  7476. remove: function(a) {
  7477. delete this.emitters[a.name]
  7478. },
  7479. update: function() {
  7480. for (var a in this.emitters) this.emitters[a].exists && this.emitters[a].update()
  7481. }
  7482. }, b.Particles.prototype.constructor = b.Particles, b.Particles.Arcade = {}, b.Particles.Arcade.Emitter = function(a, c, d, e) {
  7483. this.maxParticles = e || 50, b.Group.call(this, a), this.name = "emitter" + this.game.particles.ID++, this.type = b.EMITTER, this.area = new b.Rectangle(c, d, 1, 1), this.minParticleSpeed = new b.Point(-100, -100), this.maxParticleSpeed = new b.Point(100, 100), this.minParticleScale = 1, this.maxParticleScale = 1, this.scaleData = null, this.minRotation = -360, this.maxRotation = 360, this.minParticleAlpha = 1, this.maxParticleAlpha = 1, this.alphaData = null, this.gravity = 100, this.particleClass = b.Particle, this.particleDrag = new b.Point, this.angularDrag = 0, this.frequency = 100, this.lifespan = 2e3, this.bounce = new b.Point, this.on = !1, this.particleAnchor = new b.Point(.5, .5), this.blendMode = b.blendModes.NORMAL, this.emitX = c, this.emitY = d, this.autoScale = !1, this.autoAlpha = !1, this.particleBringToTop = !1, this.particleSendToBack = !1, this._minParticleScale = new b.Point(1, 1), this._maxParticleScale = new b.Point(1, 1), this._quantity = 0, this._timer = 0, this._counter = 0, this._explode = !0, this._frames = null
  7484. }, b.Particles.Arcade.Emitter.prototype = Object.create(b.Group.prototype), b.Particles.Arcade.Emitter.prototype.constructor = b.Particles.Arcade.Emitter, b.Particles.Arcade.Emitter.prototype.update = function() {
  7485. if (this.on)
  7486. if (this._explode) {
  7487. this._counter = 0;
  7488. do this.emitParticle(), this._counter++; while (this._counter < this._quantity);
  7489. this.on = !1
  7490. } else this.game.time.now >= this._timer && (this.emitParticle(), this._counter++, this._quantity > 0 && this._counter >= this._quantity && (this.on = !1), this._timer = this.game.time.now + this.frequency);
  7491. for (var a = this.children.length; a--;) this.children[a].exists && this.children[a].update()
  7492. }, b.Particles.Arcade.Emitter.prototype.makeParticles = function(a, b, c, d, e) {
  7493. var f, g, h, i;
  7494. for ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.maxParticles), "undefined" == typeof d && (d = !1), "undefined" == typeof e && (e = !1), g = 0, h = a, i = b, this._frames = b; c > g;) Array.isArray(a) && (h = this.game.rnd.pick(a)), Array.isArray(b) && (i = this.game.rnd.pick(b)), f = new this.particleClass(this.game, 0, 0, h, i), this.game.physics.arcade.enable(f, !1), d ? (f.body.checkCollision.any = !0, f.body.checkCollision.none = !1) : f.body.checkCollision.none = !0, f.body.collideWorldBounds = e, f.exists = !1, f.visible = !1, f.anchor.copyFrom(this.particleAnchor), this.add(f), g++;
  7495. return this
  7496. }, b.Particles.Arcade.Emitter.prototype.kill = function() {
  7497. this.on = !1, this.alive = !1, this.exists = !1
  7498. }, b.Particles.Arcade.Emitter.prototype.revive = function() {
  7499. this.alive = !0, this.exists = !0
  7500. }, b.Particles.Arcade.Emitter.prototype.explode = function(a, b) {
  7501. this.start(!0, a, 0, b, !1)
  7502. }, b.Particles.Arcade.Emitter.prototype.flow = function(a, b, c) {
  7503. this.start(!1, a, b, c, !0)
  7504. }, b.Particles.Arcade.Emitter.prototype.start = function(a, b, c, d, e) {
  7505. "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = 0), ("undefined" == typeof c || null === c) && (c = 250), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = !1), this.revive(), this.visible = !0, this.on = !0, this._explode = a, this.lifespan = b, this.frequency = c, a || e ? this._quantity = d : this._quantity += d, this._counter = 0, this._timer = this.game.time.now + c
  7506. }, b.Particles.Arcade.Emitter.prototype.emitParticle = function() {
  7507. var a = this.getFirstExists(!1);
  7508. null !== a && (this.width > 1 || this.height > 1 ? a.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)) : a.reset(this.emitX, this.emitY), a.angle = 0, a.lifespan = this.lifespan, this.particleBringToTop ? this.bringToTop(a) : this.particleSendToBack && this.sendToBack(a), this.autoScale ? a.setScaleData(this.scaleData) : 1 !== this.minParticleScale || 1 !== this.maxParticleScale ? a.scale.set(this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale)) : (this._minParticleScale.x !== this._maxParticleScale.x || this._minParticleScale.y !== this._maxParticleScale.y) && a.scale.set(this.game.rnd.realInRange(this._minParticleScale.x, this._maxParticleScale.x), this.game.rnd.realInRange(this._minParticleScale.y, this._maxParticleScale.y)), a.frame = Array.isArray("object" === this._frames) ? this.game.rnd.pick(this._frames) : this._frames, this.autoAlpha ? a.setAlphaData(this.alphaData) : a.alpha = this.game.rnd.realInRange(this.minParticleAlpha, this.maxParticleAlpha), a.blendMode = this.blendMode, a.body.updateBounds(), a.body.bounce.setTo(this.bounce.x, this.bounce.y), a.body.velocity.x = this.game.rnd.integerInRange(this.minParticleSpeed.x, this.maxParticleSpeed.x), a.body.velocity.y = this.game.rnd.integerInRange(this.minParticleSpeed.y, this.maxParticleSpeed.y), a.body.angularVelocity = this.game.rnd.integerInRange(this.minRotation, this.maxRotation), a.body.gravity.y = this.gravity, a.body.drag.x = this.particleDrag.x, a.body.drag.y = this.particleDrag.y, a.body.angularDrag = this.angularDrag, a.onEmit())
  7509. }, b.Particles.Arcade.Emitter.prototype.setSize = function(a, b) {
  7510. this.area.width = a, this.area.height = b
  7511. }, b.Particles.Arcade.Emitter.prototype.setXSpeed = function(a, b) {
  7512. a = a || 0, b = b || 0, this.minParticleSpeed.x = a, this.maxParticleSpeed.x = b
  7513. }, b.Particles.Arcade.Emitter.prototype.setYSpeed = function(a, b) {
  7514. a = a || 0, b = b || 0, this.minParticleSpeed.y = a, this.maxParticleSpeed.y = b
  7515. }, b.Particles.Arcade.Emitter.prototype.setRotation = function(a, b) {
  7516. a = a || 0, b = b || 0, this.minRotation = a, this.maxRotation = b
  7517. }, b.Particles.Arcade.Emitter.prototype.setAlpha = function(a, c, d, e, f) {
  7518. var g, h;
  7519. "undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 0), "undefined" == typeof e && (e = b.Easing.Linear.None), "undefined" == typeof f && (f = !1), this.minParticleAlpha = a, this.maxParticleAlpha = c, this.autoAlpha = !1, d > 0 && a !== c && (g = {
  7520. v: a
  7521. }, h = this.game.make.tween(g).to({
  7522. v: c
  7523. }, d, e), h.yoyo(f), this.alphaData = h.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0)
  7524. }, b.Particles.Arcade.Emitter.prototype.setScale = function(a, c, d, e, f, g, h) {
  7525. var i, j;
  7526. "undefined" == typeof a && (a = 1), "undefined" == typeof c && (c = 1), "undefined" == typeof d && (d = 1), "undefined" == typeof e && (e = 1), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = b.Easing.Linear.None), "undefined" == typeof h && (h = !1), this.minParticleScale = 1, this.maxParticleScale = 1, this._minParticleScale.set(a, d), this._maxParticleScale.set(c, e), this.autoScale = !1, (f > 0 && a !== c || d !== e) && (i = {
  7527. x: a,
  7528. y: d
  7529. }, j = this.game.make.tween(i).to({
  7530. x: c,
  7531. y: e
  7532. }, f, g), j.yoyo(h), this.scaleData = j.generateData(60), this.scaleData.reverse(), this.autoScale = !0)
  7533. }, b.Particles.Arcade.Emitter.prototype.at = function(a) {
  7534. a.center ? (this.emitX = a.center.x, this.emitY = a.center.y) : (this.emitX = a.world.x + a.anchor.x * a.width, this.emitY = a.world.y + a.anchor.y * a.height)
  7535. }, Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "width", {
  7536. get: function() {
  7537. return this.area.width
  7538. },
  7539. set: function(a) {
  7540. this.area.width = a
  7541. }
  7542. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "height", {
  7543. get: function() {
  7544. return this.area.height
  7545. },
  7546. set: function(a) {
  7547. this.area.height = a
  7548. }
  7549. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "x", {
  7550. get: function() {
  7551. return this.emitX
  7552. },
  7553. set: function(a) {
  7554. this.emitX = a
  7555. }
  7556. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "y", {
  7557. get: function() {
  7558. return this.emitY
  7559. },
  7560. set: function(a) {
  7561. this.emitY = a
  7562. }
  7563. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "left", {
  7564. get: function() {
  7565. return Math.floor(this.x - this.area.width / 2)
  7566. }
  7567. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "right", {
  7568. get: function() {
  7569. return Math.floor(this.x + this.area.width / 2)
  7570. }
  7571. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "top", {
  7572. get: function() {
  7573. return Math.floor(this.y - this.area.height / 2)
  7574. }
  7575. }), Object.defineProperty(b.Particles.Arcade.Emitter.prototype, "bottom", {
  7576. get: function() {
  7577. return Math.floor(this.y + this.area.height / 2)
  7578. }
  7579. }), b.Tile = function(a, b, c, d, e, f) {
  7580. this.layer = a, this.index = b, this.x = c, this.y = d, this.worldX = c * e, this.worldY = d * f, this.width = e, this.height = f, this.centerX = Math.abs(e / 2), this.centerY = Math.abs(f / 2), this.alpha = 1, this.properties = {}, this.scanned = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1, this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.collisionCallback = null, this.collisionCallbackContext = this
  7581. }, b.Tile.prototype = {
  7582. containsPoint: function(a, b) {
  7583. return !(a < this.worldX || b < this.worldY || a > this.right || b > this.bottom)
  7584. },
  7585. intersects: function(a, b, c, d) {
  7586. return c <= this.worldX ? !1 : d <= this.worldY ? !1 : a >= this.worldX + this.width ? !1 : b >= this.worldY + this.height ? !1 : !0
  7587. },
  7588. setCollisionCallback: function(a, b) {
  7589. this.collisionCallback = a, this.collisionCallbackContext = b
  7590. },
  7591. destroy: function() {
  7592. this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null
  7593. },
  7594. setCollision: function(a, b, c, d) {
  7595. this.collideLeft = a, this.collideRight = b, this.collideUp = c, this.collideDown = d
  7596. },
  7597. resetCollision: function() {
  7598. this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1
  7599. },
  7600. isInteresting: function(a, b) {
  7601. return a && b ? this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.faceTop || this.faceBottom || this.faceLeft || this.faceRight || this.collisionCallback : a ? this.collideLeft || this.collideRight || this.collideUp || this.collideDown : b ? this.faceTop || this.faceBottom || this.faceLeft || this.faceRight : !1
  7602. },
  7603. copy: function(a) {
  7604. this.index = a.index, this.alpha = a.alpha, this.properties = a.properties, this.collideUp = a.collideUp, this.collideDown = a.collideDown, this.collideLeft = a.collideLeft, this.collideRight = a.collideRight, this.collisionCallback = a.collisionCallback, this.collisionCallbackContext = a.collisionCallbackContext
  7605. }
  7606. }, b.Tile.prototype.constructor = b.Tile, Object.defineProperty(b.Tile.prototype, "collides", {
  7607. get: function() {
  7608. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown
  7609. }
  7610. }), Object.defineProperty(b.Tile.prototype, "canCollide", {
  7611. get: function() {
  7612. return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback
  7613. }
  7614. }), Object.defineProperty(b.Tile.prototype, "left", {
  7615. get: function() {
  7616. return this.worldX
  7617. }
  7618. }), Object.defineProperty(b.Tile.prototype, "right", {
  7619. get: function() {
  7620. return this.worldX + this.width
  7621. }
  7622. }), Object.defineProperty(b.Tile.prototype, "top", {
  7623. get: function() {
  7624. return this.worldY
  7625. }
  7626. }), Object.defineProperty(b.Tile.prototype, "bottom", {
  7627. get: function() {
  7628. return this.worldY + this.height
  7629. }
  7630. }), b.Tilemap = function(a, c, d, e, f, g) {
  7631. this.game = a, this.key = c;
  7632. var h = b.TilemapParser.parse(this.game, c, d, e, f, g);
  7633. null !== h && (this.width = h.width, this.height = h.height, this.tileWidth = h.tileWidth, this.tileHeight = h.tileHeight, this.orientation = h.orientation, this.format = h.format, this.version = h.version, this.properties = h.properties, this.widthInPixels = h.widthInPixels, this.heightInPixels = h.heightInPixels, this.layers = h.layers, this.tilesets = h.tilesets, this.tiles = h.tiles, this.objects = h.objects, this.collideIndexes = [], this.collision = h.collision, this.images = h.images, this.currentLayer = 0, this.debugMap = [], this._results = [], this._tempA = 0, this._tempB = 0)
  7634. }, b.Tilemap.CSV = 0, b.Tilemap.TILED_JSON = 1, b.Tilemap.NORTH = 0, b.Tilemap.EAST = 1, b.Tilemap.SOUTH = 2, b.Tilemap.WEST = 3, b.Tilemap.prototype = {
  7635. create: function(a, b, c, d, e, f) {
  7636. return "undefined" == typeof f && (f = this.game.world), this.width = b, this.height = c, this.setTileSize(d, e), this.layers.length = 0, this.createBlankLayer(a, b, c, d, e, f)
  7637. },
  7638. setTileSize: function(a, b) {
  7639. this.tileWidth = a, this.tileHeight = b, this.widthInPixels = this.width * a, this.heightInPixels = this.height * b
  7640. },
  7641. addTilesetImage: function(a, c, d, e, f, g, h) {
  7642. var i, j, k, l, m, n, o, p;
  7643. if ("undefined" == typeof d && (d = this.tileWidth), "undefined" == typeof e && (e = this.tileHeight), "undefined" == typeof f && (f = 0), "undefined" == typeof g && (g = 0), "undefined" == typeof h && (h = 0), 0 === d && (d = 32), 0 === e && (e = 32), "undefined" == typeof c) {
  7644. if ("string" != typeof a) return null;
  7645. if (c = a, !this.game.cache.checkImageKey(c)) return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + c + '"'), null
  7646. }
  7647. if ("string" == typeof a && (a = this.getTilesetIndex(a), null === a && this.format === b.Tilemap.TILED_JSON)) return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + c + '"'), null;
  7648. if (this.tilesets[a]) return this.tilesets[a].setImage(this.game.cache.getImage(c)), this.tilesets[a];
  7649. for (i = new b.Tileset(c, h, d, e, f, g, {}), i.setImage(this.game.cache.getImage(c)), this.tilesets.push(i), j = this.tilesets.length - 1, k = f, l = f, m = 0, n = 0, o = 0, p = h; p < h + i.total && (this.tiles[p] = [k, l, j], k += d + g, m++, m !== i.total) && (n++, n !== i.columns || (k = f, l += e + g, n = 0, o++, o !== i.rows)); p++);
  7650. return i
  7651. },
  7652. createFromObjects: function(a, c, d, e, f, g, h, i, j) {
  7653. var k, l, m, n;
  7654. if ("undefined" == typeof f && (f = !0), "undefined" == typeof g && (g = !1), "undefined" == typeof h && (h = this.game.world), "undefined" == typeof i && (i = b.Sprite), "undefined" == typeof j && (j = !0), !this.objects[a]) return console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: " + a), void 0;
  7655. for (l = 0, m = this.objects[a].length; m > l; l++)
  7656. if (this.objects[a][l].gid === c) {
  7657. k = new i(this.game, this.objects[a][l].x, this.objects[a][l].y, d, e), k.name = this.objects[a][l].name, k.visible = this.objects[a][l].visible, k.autoCull = g, k.exists = f, j && (k.y -= k.height), h.add(k);
  7658. for (n in this.objects[a][l].properties) h.set(k, n, this.objects[a][l].properties[n], !1, !1, 0, !0)
  7659. }
  7660. },
  7661. createLayer: function(a, c, d, e) {
  7662. "undefined" == typeof c && (c = this.game.width), "undefined" == typeof d && (d = this.game.height), "undefined" == typeof e && (e = this.game.world);
  7663. var f = a;
  7664. return "string" == typeof a && (f = this.getLayerIndex(a)), null === f || f > this.layers.length ? (console.warn("Tilemap.createLayer: Invalid layer ID given: " + f), void 0) : e.add(new b.TilemapLayer(this.game, this, f, c, d))
  7665. },
  7666. createBlankLayer: function(a, c, d, e, f, g) {
  7667. var h, i, j, k, l, m, n;
  7668. if ("undefined" == typeof g && (g = this.game.world), null !== this.getLayerIndex(a)) return console.warn("Tilemap.createBlankLayer: Layer with matching name already exists"), void 0;
  7669. for (h = {
  7670. name: a,
  7671. x: 0,
  7672. y: 0,
  7673. width: c,
  7674. height: d,
  7675. widthInPixels: c * e,
  7676. heightInPixels: d * f,
  7677. alpha: 1,
  7678. visible: !0,
  7679. properties: {},
  7680. indexes: [],
  7681. callbacks: [],
  7682. bodies: [],
  7683. data: null
  7684. }, j = [], k = 0; d > k; k++) {
  7685. for (i = [], l = 0; c > l; l++) i.push(new b.Tile(h, -1, l, k, e, f));
  7686. j.push(i)
  7687. }
  7688. return h.data = j, this.layers.push(h), this.currentLayer = this.layers.length - 1, m = h.widthInPixels, n = h.heightInPixels, m > this.game.width && (m = this.game.width), n > this.game.height && (n = this.game.height), j = new b.TilemapLayer(this.game, this, this.layers.length - 1, m, n), j.name = a, g.add(j)
  7689. },
  7690. getIndex: function(a, b) {
  7691. for (var c = 0; c < a.length; c++)
  7692. if (a[c].name === b) return c;
  7693. return null
  7694. },
  7695. getLayerIndex: function(a) {
  7696. return this.getIndex(this.layers, a)
  7697. },
  7698. getTilesetIndex: function(a) {
  7699. return this.getIndex(this.tilesets, a)
  7700. },
  7701. getImageIndex: function(a) {
  7702. return this.getIndex(this.images, a)
  7703. },
  7704. getObjectIndex: function(a) {
  7705. return this.getIndex(this.objects, a)
  7706. },
  7707. setTileIndexCallback: function(a, b, c, d) {
  7708. if (d = this.getLayer(d), "number" == typeof a) this.layers[d].callbacks[a] = {
  7709. callback: b,
  7710. callbackContext: c
  7711. };
  7712. else
  7713. for (var e = 0, f = a.length; f > e; e++) this.layers[d].callbacks[a[e]] = {
  7714. callback: b,
  7715. callbackContext: c
  7716. }
  7717. },
  7718. setTileLocationCallback: function(a, b, c, d, e, f, g) {
  7719. if (g = this.getLayer(g), this.copy(a, b, c, d, g), !(this._results.length < 2))
  7720. for (var h = 1; h < this._results.length; h++) this._results[h].setCollisionCallback(e, f)
  7721. },
  7722. setCollision: function(a, b, c, d) {
  7723. if ("undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c), "number" == typeof a) return this.setCollisionByIndex(a, b, c, !0);
  7724. for (var e = 0, f = a.length; f > e; e++) this.setCollisionByIndex(a[e], b, c, !1);
  7725. d && this.calculateFaces(c)
  7726. },
  7727. setCollisionBetween: function(a, b, c, d, e) {
  7728. if ("undefined" == typeof c && (c = !0), "undefined" == typeof e && (e = !0), d = this.getLayer(d), !(a > b)) {
  7729. for (var f = a; b >= f; f++) this.setCollisionByIndex(f, c, d, !1);
  7730. e && this.calculateFaces(d)
  7731. }
  7732. },
  7733. setCollisionByExclusion: function(a, b, c, d) {
  7734. "undefined" == typeof b && (b = !0), "undefined" == typeof d && (d = !0), c = this.getLayer(c);
  7735. for (var e = 0, f = this.tiles.length; f > e; e++) - 1 === a.indexOf(e) && this.setCollisionByIndex(e, b, c, !1);
  7736. d && this.calculateFaces(c)
  7737. },
  7738. setCollisionByIndex: function(a, b, c, d) {
  7739. var e, f, g, h;
  7740. for ("undefined" == typeof b && (b = !0), "undefined" == typeof c && (c = this.currentLayer), "undefined" == typeof d && (d = !0), b ? this.collideIndexes.push(a) : (e = this.collideIndexes.indexOf(a), e > -1 && this.collideIndexes.splice(e, 1)), f = 0; f < this.layers[c].height; f++)
  7741. for (g = 0; g < this.layers[c].width; g++) h = this.layers[c].data[f][g], h && h.index === a && (b ? h.setCollision(!0, !0, !0, !0) : h.resetCollision(), h.faceTop = b, h.faceBottom = b, h.faceLeft = b, h.faceRight = b);
  7742. return d && this.calculateFaces(c), c
  7743. },
  7744. getLayer: function(a) {
  7745. return "undefined" == typeof a ? a = this.currentLayer : "string" == typeof a ? a = this.getLayerIndex(a) : a instanceof b.TilemapLayer && (a = a.index), a
  7746. },
  7747. setPreventRecalculate: function(a) {
  7748. if (a === !0 && this.preventingRecalculate !== !0 && (this.preventingRecalculate = !0, this.needToRecalculate = {}), a === !1 && this.preventingRecalculate === !0) {
  7749. this.preventingRecalculate = !1;
  7750. for (var b in this.needToRecalculate) this.calculateFaces(b);
  7751. this.needToRecalculate = !1
  7752. }
  7753. },
  7754. calculateFaces: function(a) {
  7755. var b, c, d, e, f, g, h, i, j;
  7756. if (this.preventingRecalculate === !0) return this.needToRecalculate[a] = !0, void 0;
  7757. for (b = null, c = null, d = null, e = null, f = 0, g = this.layers[a].height; g > f; f++)
  7758. for (h = 0, i = this.layers[a].width; i > h; h++) j = this.layers[a].data[f][h], j && (b = this.getTileAbove(a, h, f), c = this.getTileBelow(a, h, f), d = this.getTileLeft(a, h, f), e = this.getTileRight(a, h, f), j.collides && (j.faceTop = !0, j.faceBottom = !0, j.faceLeft = !0, j.faceRight = !0), b && b.collides && (j.faceTop = !1), c && c.collides && (j.faceBottom = !1), d && d.collides && (j.faceLeft = !1), e && e.collides && (j.faceRight = !1))
  7759. },
  7760. getTileAbove: function(a, b, c) {
  7761. return c > 0 ? this.layers[a].data[c - 1][b] : null
  7762. },
  7763. getTileBelow: function(a, b, c) {
  7764. return c < this.layers[a].height - 1 ? this.layers[a].data[c + 1][b] : null
  7765. },
  7766. getTileLeft: function(a, b, c) {
  7767. return b > 0 ? this.layers[a].data[c][b - 1] : null
  7768. },
  7769. getTileRight: function(a, b, c) {
  7770. return b < this.layers[a].width - 1 ? this.layers[a].data[c][b + 1] : null
  7771. },
  7772. setLayer: function(a) {
  7773. a = this.getLayer(a), this.layers[a] && (this.currentLayer = a)
  7774. },
  7775. hasTile: function(a, b, c) {
  7776. return c = this.getLayer(c), null !== this.layers[c].data[b] && null !== this.layers[c].data[b][a]
  7777. },
  7778. removeTile: function(a, c, d) {
  7779. if (d = this.getLayer(d), a >= 0 && a < this.layers[d].width && c >= 0 && c < this.layers[d].height && this.hasTile(a, c, d)) {
  7780. var e = this.layers[d].data[c][a];
  7781. return this.layers[d].data[c][a] = new b.Tile(this.layers[d], -1, a, c, this.tileWidth, this.tileHeight), this.layers[d].dirty = !0, this.calculateFaces(d), e
  7782. }
  7783. },
  7784. removeTileWorldXY: function(a, b, c, d, e) {
  7785. return e = this.getLayer(e), a = this.game.math.snapToFloor(a, c) / c, b = this.game.math.snapToFloor(b, d) / d, this.removeTile(a, b, e)
  7786. },
  7787. putTile: function(a, c, d, e) {
  7788. if (null === a) return this.removeTile(c, d, e);
  7789. if (e = this.getLayer(e), c >= 0 && c < this.layers[e].width && d >= 0 && d < this.layers[e].height) {
  7790. var f;
  7791. return a instanceof b.Tile ? (f = a.index, this.hasTile(c, d, e) ? this.layers[e].data[d][c].copy(a) : this.layers[e].data[d][c] = new b.Tile(e, f, c, d, a.width, a.height)) : (f = a, this.hasTile(c, d, e) ? this.layers[e].data[d][c].index = f : this.layers[e].data[d][c] = new b.Tile(this.layers[e], f, c, d, this.tileWidth, this.tileHeight)), this.collideIndexes.indexOf(f) > -1 ? this.layers[e].data[d][c].setCollision(!0, !0, !0, !0) : this.layers[e].data[d][c].resetCollision(), this.layers[e].dirty = !0, this.calculateFaces(e), this.layers[e].data[d][c]
  7792. }
  7793. return null
  7794. },
  7795. putTileWorldXY: function(a, b, c, d, e, f) {
  7796. return f = this.getLayer(f), b = this.game.math.snapToFloor(b, d) / d, c = this.game.math.snapToFloor(c, e) / e, this.putTile(a, b, c, f)
  7797. },
  7798. searchTileIndex: function(a, b, c, d) {
  7799. var e, f, g;
  7800. if ("undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = !1), d = this.getLayer(d), e = 0, c) {
  7801. for (f = this.layers[d].height - 1; f >= 0; f--)
  7802. for (g = this.layers[d].width - 1; g >= 0; g--)
  7803. if (this.layers[d].data[f][g].index === a) {
  7804. if (e === b) return this.layers[d].data[f][g];
  7805. e++
  7806. }
  7807. } else
  7808. for (f = 0; f < this.layers[d].height; f++)
  7809. for (g = 0; g < this.layers[d].width; g++)
  7810. if (this.layers[d].data[f][g].index === a) {
  7811. if (e === b) return this.layers[d].data[f][g];
  7812. e++
  7813. }
  7814. return null
  7815. },
  7816. getTile: function(a, b, c, d) {
  7817. return "undefined" == typeof d && (d = !1), c = this.getLayer(c), a >= 0 && a < this.layers[c].width && b >= 0 && b < this.layers[c].height ? -1 === this.layers[c].data[b][a].index ? d ? this.layers[c].data[b][a] : null : this.layers[c].data[b][a] : null
  7818. },
  7819. getTileWorldXY: function(a, b, c, d, e) {
  7820. return "undefined" == typeof c && (c = this.tileWidth), "undefined" == typeof d && (d = this.tileHeight), e = this.getLayer(e), a = this.game.math.snapToFloor(a, c) / c, b = this.game.math.snapToFloor(b, d) / d, this.getTile(a, b, e)
  7821. },
  7822. copy: function(a, b, c, d, e) {
  7823. var f, g;
  7824. if (e = this.getLayer(e), !this.layers[e]) return this._results.length = 0, void 0;
  7825. for ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), "undefined" == typeof c && (c = this.layers[e].width), "undefined" == typeof d && (d = this.layers[e].height), 0 > a && (a = 0), 0 > b && (b = 0), c > this.layers[e].width && (c = this.layers[e].width), d > this.layers[e].height && (d = this.layers[e].height), this._results.length = 0, this._results.push({
  7826. x: a,
  7827. y: b,
  7828. width: c,
  7829. height: d,
  7830. layer: e
  7831. }), f = b; b + d > f; f++)
  7832. for (g = a; a + c > g; g++) this._results.push(this.layers[e].data[f][g]);
  7833. return this._results
  7834. },
  7835. paste: function(a, b, c, d) {
  7836. var e, f, g;
  7837. if ("undefined" == typeof a && (a = 0), "undefined" == typeof b && (b = 0), d = this.getLayer(d), c && !(c.length < 2)) {
  7838. for (e = c[1].x - a, f = c[1].y - b, g = 1; g < c.length; g++) this.layers[d].data[f + c[g].y][e + c[g].x].copy(c[g]);
  7839. this.layers[d].dirty = !0, this.calculateFaces(d)
  7840. }
  7841. },
  7842. swap: function(a, b, c, d, e, f, g) {
  7843. g = this.getLayer(g), this.copy(c, d, e, f, g), this._results.length < 2 || (this._tempA = a, this._tempB = b, this._results.forEach(this.swapHandler, this), this.paste(c, d, this._results, g))
  7844. },
  7845. swapHandler: function(a) {
  7846. a.index === this._tempA ? a.index = this._tempB : a.index === this._tempB && (a.index = this._tempA)
  7847. },
  7848. forEach: function(a, b, c, d, e, f, g) {
  7849. g = this.getLayer(g), this.copy(c, d, e, f, g), this._results.length < 2 || (this._results.forEach(a, b), this.paste(c, d, this._results, g))
  7850. },
  7851. replace: function(a, b, c, d, e, f, g) {
  7852. if (g = this.getLayer(g), this.copy(c, d, e, f, g), !(this._results.length < 2)) {
  7853. for (var h = 1; h < this._results.length; h++) this._results[h].index === a && (this._results[h].index = b);
  7854. this.paste(c, d, this._results, g)
  7855. }
  7856. },
  7857. random: function(a, b, c, d, e) {
  7858. var f, g, h, i;
  7859. if (e = this.getLayer(e), this.copy(a, b, c, d, e), !(this._results.length < 2)) {
  7860. for (f = [], g = 1; g < this._results.length; g++) this._results[g].index && (h = this._results[g].index, -1 === f.indexOf(h) && f.push(h));
  7861. for (i = 1; i < this._results.length; i++) this._results[i].index = this.game.rnd.pick(f);
  7862. this.paste(a, b, this._results, e)
  7863. }
  7864. },
  7865. shuffle: function(a, c, d, e, f) {
  7866. var g, h, i;
  7867. if (f = this.getLayer(f), this.copy(a, c, d, e, f), !(this._results.length < 2)) {
  7868. for (g = [], h = 1; h < this._results.length; h++) this._results[h].index && g.push(this._results[h].index);
  7869. for (b.Utils.shuffle(g), i = 1; i < this._results.length; i++) this._results[i].index = g[i - 1];
  7870. this.paste(a, c, this._results, f)
  7871. }
  7872. },
  7873. fill: function(a, b, c, d, e, f) {
  7874. if (f = this.getLayer(f), this.copy(b, c, d, e, f), !(this._results.length < 2)) {
  7875. for (var g = 1; g < this._results.length; g++) this._results[g].index = a;
  7876. this.paste(b, c, this._results, f)
  7877. }
  7878. },
  7879. removeAllLayers: function() {
  7880. this.layers.length = 0, this.currentLayer = 0
  7881. },
  7882. dump: function() {
  7883. var c, d, a = "",
  7884. b = [""];
  7885. for (c = 0; c < this.layers[this.currentLayer].height; c++) {
  7886. for (d = 0; d < this.layers[this.currentLayer].width; d++) a += "%c ", this.layers[this.currentLayer].data[c][d] > 1 ? this.debugMap[this.layers[this.currentLayer].data[c][d]] ? b.push("background: " + this.debugMap[this.layers[this.currentLayer].data[c][d]]) : b.push("background: #ffffff") : b.push("background: rgb(0, 0, 0)");
  7887. a += "\n"
  7888. }
  7889. b[0] = a, console.log.apply(console, b)
  7890. },
  7891. destroy: function() {
  7892. this.removeAllLayers(), this.data = [], this.game = null
  7893. }
  7894. }, b.Tilemap.prototype.constructor = b.Tilemap, Object.defineProperty(b.Tilemap.prototype, "layer", {
  7895. get: function() {
  7896. return this.layers[this.currentLayer]
  7897. },
  7898. set: function(a) {
  7899. a !== this.currentLayer && this.setLayer(a)
  7900. }
  7901. }), b.TilemapLayer = function(a, c, d, e, f) {
  7902. this.game = a, this.map = c, this.index = d, this.layer = c.layers[d], this.canvas = b.Canvas.create(e, f, "", !0), this.context = this.canvas.getContext("2d"), this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new b.Frame(0, 0, 0, e, f, "tilemapLayer", a.rnd.uuid()), b.Image.call(this, this.game, 0, 0, this.texture, this.textureFrame), this.name = "", this.type = b.TILEMAPLAYER, this.fixedToCamera = !0, this.cameraOffset = new b.Point(0, 0), this.tileColor = "rgb(255, 255, 255)", this.debug = !1, this.debugAlpha = .5, this.debugColor = "rgba(0, 255, 0, 1)", this.debugFill = !1, this.debugFillColor = "rgba(0, 255, 0, 0.2)", this.debugCallbackColor = "rgba(255, 0, 0, 1)", this.scrollFactorX = 1, this.scrollFactorY = 1, this.dirty = !0, this.rayStepRate = 4, this.wrap = !1, this._mc = {
  7903. cw: c.tileWidth,
  7904. ch: c.tileHeight,
  7905. ga: 1,
  7906. dx: 0,
  7907. dy: 0,
  7908. dw: 0,
  7909. dh: 0,
  7910. tx: 0,
  7911. ty: 0,
  7912. tw: 0,
  7913. th: 0,
  7914. tl: 0,
  7915. maxX: 0,
  7916. maxY: 0,
  7917. startX: 0,
  7918. startY: 0,
  7919. x: 0,
  7920. y: 0,
  7921. prevX: 0,
  7922. prevY: 0
  7923. }, this._results = [], this.updateMax()
  7924. }, b.TilemapLayer.prototype = Object.create(b.Image.prototype), b.TilemapLayer.prototype.constructor = b.TilemapLayer, b.TilemapLayer.prototype.postUpdate = function() {
  7925. b.Image.prototype.postUpdate.call(this), this.scrollX = this.game.camera.x * this.scrollFactorX, this.scrollY = this.game.camera.y * this.scrollFactorY, this.render(), 1 === this._cache[7] && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y)
  7926. }, b.TilemapLayer.prototype.resizeWorld = function() {
  7927. this.game.world.setBounds(0, 0, this.layer.widthInPixels, this.layer.heightInPixels)
  7928. }, b.TilemapLayer.prototype._fixX = function(a) {
  7929. return 0 > a && (a = 0), 1 === this.scrollFactorX ? a : this._mc.x + (a - this._mc.x / this.scrollFactorX)
  7930. }, b.TilemapLayer.prototype._unfixX = function(a) {
  7931. return 1 === this.scrollFactorX ? a : this._mc.x / this.scrollFactorX + (a - this._mc.x)
  7932. }, b.TilemapLayer.prototype._fixY = function(a) {
  7933. return 0 > a && (a = 0), 1 === this.scrollFactorY ? a : this._mc.y + (a - this._mc.y / this.scrollFactorY)
  7934. }, b.TilemapLayer.prototype._unfixY = function(a) {
  7935. return 1 === this.scrollFactorY ? a : this._mc.y / this.scrollFactorY + (a - this._mc.y)
  7936. }, b.TilemapLayer.prototype.getTileX = function(a) {
  7937. return this.game.math.snapToFloor(this._fixX(a), this.map.tileWidth) / this.map.tileWidth
  7938. }, b.TilemapLayer.prototype.getTileY = function(a) {
  7939. return this.game.math.snapToFloor(this._fixY(a), this.map.tileHeight) / this.map.tileHeight
  7940. }, b.TilemapLayer.prototype.getTileXY = function(a, b, c) {
  7941. return c.x = this.getTileX(a), c.y = this.getTileY(b), c
  7942. }, b.TilemapLayer.prototype.getRayCastTiles = function(a, b, c, d) {
  7943. var e, f, g, h, i, j;
  7944. if (("undefined" == typeof b || null === b) && (b = this.rayStepRate), "undefined" == typeof c && (c = !1), "undefined" == typeof d && (d = !1), e = this.getTiles(a.x, a.y, a.width, a.height, c, d), 0 === e.length) return [];
  7945. for (f = a.coordinatesOnLine(b), g = f.length, h = [], i = 0; i < e.length; i++)
  7946. for (j = 0; g > j; j++)
  7947. if (e[i].containsPoint(f[j][0], f[j][1])) {
  7948. h.push(e[i]);
  7949. break
  7950. }
  7951. return h
  7952. }, b.TilemapLayer.prototype.getTiles = function(a, b, c, d, e, f) {
  7953. var g, h;
  7954. for ("undefined" == typeof e && (e = !1), "undefined" == typeof f && (f = !1), a = this._fixX(a), b = this._fixY(b), c > this.layer.widthInPixels && (c = this.layer.widthInPixels), d > this.layer.heightInPixels && (d = this.layer.heightInPixels), this._mc.tx = this.game.math.snapToFloor(a, this._mc.cw) / this._mc.cw, this._mc.ty = this.game.math.snapToFloor(b, this._mc.ch) / this._mc.ch, this._mc.tw = (this.game.math.snapToCeil(c, this._mc.cw) + this._mc.cw) / this._mc.cw, this._mc.th = (this.game.math.snapToCeil(d, this._mc.ch) + this._mc.ch) / this._mc.ch, this._results.length = 0, g = this._mc.ty; g < this._mc.ty + this._mc.th; g++)
  7955. for (h = this._mc.tx; h < this._mc.tx + this._mc.tw; h++) this.layer.data[g] && this.layer.data[g][h] && (!e && !f || this.layer.data[g][h].isInteresting(e, f)) && this._results.push(this.layer.data[g][h]);
  7956. return this._results
  7957. }, b.TilemapLayer.prototype.updateMax = function() {
  7958. this._mc.maxX = this.game.math.ceil(this.canvas.width / this.map.tileWidth) + 1, this._mc.maxY = this.game.math.ceil(this.canvas.height / this.map.tileHeight) + 1, this.dirty = !0
  7959. }, b.TilemapLayer.prototype.render = function() {
  7960. var a, c, d, e, f, g;
  7961. if (this.layer.dirty && (this.dirty = !0), this.dirty && this.visible) {
  7962. for (this._mc.prevX = this._mc.dx, this._mc.prevY = this._mc.dy, this._mc.dx = -(this._mc.x - this._mc.startX * this.map.tileWidth), this._mc.dy = -(this._mc.y - this._mc.startY * this.map.tileHeight), this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.context.fillStyle = this.tileColor, this.debug && (this.context.globalAlpha = this.debugAlpha), d = this._mc.startY, e = this._mc.startY + this._mc.maxY; e > d; d++) {
  7963. if (this._column = null, 0 > d && this.wrap ? this._column = this.layer.data[d + this.map.height] : d >= this.map.height && this.wrap ? this._column = this.layer.data[d - this.map.height] : this.layer.data[d] && (this._column = this.layer.data[d]), this._column)
  7964. for (f = this._mc.startX, g = this._mc.startX + this._mc.maxX; g > f; f++) a = null, 0 > f && this.wrap ? a = this._column[f + this.map.width] : f >= this.map.width && this.wrap ? a = this._column[f - this.map.width] : this._column[f] && (a = this._column[f]), a && a.index > -1 && (c = this.map.tilesets[this.map.tiles[a.index][2]], this.debug === !1 && a.alpha !== this.context.globalAlpha && (this.context.globalAlpha = a.alpha), c.draw(this.context, Math.floor(this._mc.tx), Math.floor(this._mc.ty), a.index), a.debug && (this.context.fillStyle = "rgba(0, 255, 0, 0.4)", this.context.fillRect(Math.floor(this._mc.tx), Math.floor(this._mc.ty), this.map.tileWidth, this.map.tileHeight))), this._mc.tx += this.map.tileWidth;
  7965. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  7966. }
  7967. return this.debug && (this.context.globalAlpha = 1, this.renderDebug()), this.game.renderType === b.WEBGL && PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl), this.dirty = !1, this.layer.dirty = !1, !0
  7968. }
  7969. }, b.TilemapLayer.prototype.renderDebug = function() {
  7970. var a, b, c, d, e;
  7971. for (this._mc.tx = this._mc.dx, this._mc.ty = this._mc.dy, this.context.strokeStyle = this.debugColor, this.context.fillStyle = this.debugFillColor, a = this._mc.startY, b = this._mc.startY + this._mc.maxY; b > a; a++) {
  7972. if (this._column = null, 0 > a && this.wrap ? this._column = this.layer.data[a + this.map.height] : a >= this.map.height && this.wrap ? this._column = this.layer.data[a - this.map.height] : this.layer.data[a] && (this._column = this.layer.data[a]), this._column)
  7973. for (c = this._mc.startX, d = this._mc.startX + this._mc.maxX; d > c; c++) e = null, 0 > c && this.wrap ? e = this._column[c + this.map.width] : c >= this.map.width && this.wrap ? e = this._column[c - this.map.width] : this._column[c] && (e = this._column[c]), e && (e.faceTop || e.faceBottom || e.faceLeft || e.faceRight) && (this._mc.tx = Math.floor(this._mc.tx), this.debugFill && this.context.fillRect(this._mc.tx, this._mc.ty, this._mc.cw, this._mc.ch), this.context.beginPath(), e.faceTop && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty)), e.faceBottom && (this.context.moveTo(this._mc.tx, this._mc.ty + this._mc.ch), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), e.faceLeft && (this.context.moveTo(this._mc.tx, this._mc.ty), this.context.lineTo(this._mc.tx, this._mc.ty + this._mc.ch)), e.faceRight && (this.context.moveTo(this._mc.tx + this._mc.cw, this._mc.ty), this.context.lineTo(this._mc.tx + this._mc.cw, this._mc.ty + this._mc.ch)), this.context.stroke()), this._mc.tx += this.map.tileWidth;
  7974. this._mc.tx = this._mc.dx, this._mc.ty += this.map.tileHeight
  7975. }
  7976. }, Object.defineProperty(b.TilemapLayer.prototype, "scrollX", {
  7977. get: function() {
  7978. return this._mc.x
  7979. },
  7980. set: function(a) {
  7981. a !== this._mc.x && (this._mc.x = a, this._mc.startX = this.game.math.floor(this._mc.x / this.map.tileWidth), this.dirty = !0)
  7982. }
  7983. }), Object.defineProperty(b.TilemapLayer.prototype, "scrollY", {
  7984. get: function() {
  7985. return this._mc.y
  7986. },
  7987. set: function(a) {
  7988. a !== this._mc.y && (this._mc.y = a, this._mc.startY = this.game.math.floor(this._mc.y / this.map.tileHeight), this.dirty = !0)
  7989. }
  7990. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionWidth", {
  7991. get: function() {
  7992. return this._mc.cw
  7993. },
  7994. set: function(a) {
  7995. this._mc.cw = a, this.dirty = !0
  7996. }
  7997. }), Object.defineProperty(b.TilemapLayer.prototype, "collisionHeight", {
  7998. get: function() {
  7999. return this._mc.ch
  8000. },
  8001. set: function(a) {
  8002. this._mc.ch = a, this.dirty = !0
  8003. }
  8004. }), b.TilemapParser = {
  8005. parse: function(a, c, d, e, f, g) {
  8006. if ("undefined" == typeof d && (d = 32), "undefined" == typeof e && (e = 32), "undefined" == typeof f && (f = 10), "undefined" == typeof g && (g = 10), "undefined" == typeof c) return this.getEmptyData();
  8007. if (null === c) return this.getEmptyData(d, e, f, g);
  8008. var h = a.cache.getTilemapData(c);
  8009. if (h) {
  8010. if (h.format === b.Tilemap.CSV) return this.parseCSV(c, h.data, d, e);
  8011. if (!h.format || h.format === b.Tilemap.TILED_JSON) return this.parseTiledJSON(h.data)
  8012. } else console.warn("Phaser.TilemapParser.parse - No map data found for key " + c)
  8013. },
  8014. parseCSV: function(a, c, d, e) {
  8015. var g, h, i, j, k, l, m, f = this.getEmptyData();
  8016. for (c = c.trim(), g = [], h = c.split("\n"), i = h.length, j = 0, k = 0; k < h.length; k++) {
  8017. for (g[k] = [], l = h[k].split(","), m = 0; m < l.length; m++) g[k][m] = new b.Tile(f.layers[0], parseInt(l[m], 10), m, k, d, e);
  8018. 0 === j && (j = l.length)
  8019. }
  8020. return f.format = b.Tilemap.CSV, f.name = a, f.width = j, f.height = i, f.tileWidth = d, f.tileHeight = e, f.widthInPixels = j * d, f.heightInPixels = i * e, f.layers[0].width = j, f.layers[0].height = i, f.layers[0].widthInPixels = f.widthInPixels, f.layers[0].heightInPixels = f.heightInPixels, f.layers[0].data = g, f
  8021. },
  8022. getEmptyData: function(a, b, c, d) {
  8023. var f, g, e = {};
  8024. return e.width = 0, e.height = 0, e.tileWidth = 0, e.tileHeight = 0, "undefined" != typeof a && null !== a && (e.tileWidth = a), "undefined" != typeof b && null !== b && (e.tileHeight = b), "undefined" != typeof c && null !== c && (e.width = c), "undefined" != typeof d && null !== d && (e.height = d), e.orientation = "orthogonal", e.version = "1", e.properties = {}, e.widthInPixels = 0, e.heightInPixels = 0, f = [], g = {
  8025. name: "layer",
  8026. x: 0,
  8027. y: 0,
  8028. width: 0,
  8029. height: 0,
  8030. widthInPixels: 0,
  8031. heightInPixels: 0,
  8032. alpha: 1,
  8033. visible: !0,
  8034. properties: {},
  8035. indexes: [],
  8036. callbacks: [],
  8037. data: []
  8038. }, f.push(g), e.layers = f, e.images = [], e.objects = {}, e.collision = {}, e.tilesets = [], e.tiles = [], e
  8039. },
  8040. parseTiledJSON: function(a) {
  8041. function s(a, b) {
  8042. var d, e, c = {};
  8043. for (d in b) e = b[d], c[e] = a[e];
  8044. return c
  8045. }
  8046. var c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, t, u, v, w, x, y, z;
  8047. if ("orthogonal" !== a.orientation) return console.warn("TilemapParser.parseTiledJSON: Only orthogonal map types are supported in this version of Phaser"), null;
  8048. for (c = {}, c.width = a.width, c.height = a.height, c.tileWidth = a.tilewidth, c.tileHeight = a.tileheight, c.orientation = a.orientation, c.format = b.Tilemap.TILED_JSON, c.version = a.version, c.properties = a.properties, c.widthInPixels = c.width * c.tileWidth, c.heightInPixels = c.height * c.tileHeight, d = [], e = 0; e < a.layers.length; e++)
  8049. if ("tilelayer" === a.layers[e].type) {
  8050. for (f = {
  8051. name: a.layers[e].name,
  8052. x: a.layers[e].x,
  8053. y: a.layers[e].y,
  8054. width: a.layers[e].width,
  8055. height: a.layers[e].height,
  8056. widthInPixels: a.layers[e].width * a.tilewidth,
  8057. heightInPixels: a.layers[e].height * a.tileheight,
  8058. alpha: a.layers[e].opacity,
  8059. visible: a.layers[e].visible,
  8060. properties: {},
  8061. indexes: [],
  8062. callbacks: [],
  8063. bodies: []
  8064. }, a.layers[e].properties && (f.properties = a.layers[e].properties), g = 0, h = [], i = [], j = 0, k = a.layers[e].data.length; k > j; j++) a.layers[e].data[j] > 0 ? h.push(new b.Tile(f, a.layers[e].data[j], g, i.length, a.tilewidth, a.tileheight)) : h.push(new b.Tile(f, -1, g, i.length, a.tilewidth, a.tileheight)), g++, g === a.layers[e].width && (i.push(h), g = 0, h = []);
  8065. f.data = i, d.push(f)
  8066. }
  8067. for (c.layers = d, l = [], e = 0; e < a.layers.length; e++) "imagelayer" === a.layers[e].type && (m = {
  8068. name: a.layers[e].name,
  8069. image: a.layers[e].image,
  8070. x: a.layers[e].x,
  8071. y: a.layers[e].y,
  8072. alpha: a.layers[e].opacity,
  8073. visible: a.layers[e].visible,
  8074. properties: {}
  8075. }, a.layers[e].properties && (m.properties = a.layers[e].properties), l.push(m));
  8076. for (c.images = l, n = [], e = 0; e < a.tilesets.length; e++) o = a.tilesets[e], p = new b.Tileset(o.name, o.firstgid, o.tilewidth, o.tileheight, o.margin, o.spacing, o.properties), o.tileproperties && (p.tileProperties = o.tileproperties), p.rows = Math.round((o.imageheight - o.margin) / (o.tileheight + o.spacing)), p.columns = Math.round((o.imagewidth - o.margin) / (o.tilewidth + o.spacing)), p.total = p.rows * p.columns, 0 !== p.rows % 1 || 0 !== p.columns % 1 ? console.warn("TileSet image dimensions do not match expected dimensions. Tileset width/height must be evenly divisible by Tilemap tile width/height.") : n.push(p);
  8077. for (c.tilesets = n, q = {}, r = {}, e = 0; e < a.layers.length; e++)
  8078. if ("objectgroup" === a.layers[e].type)
  8079. for (q[a.layers[e].name] = [], r[a.layers[e].name] = [], t = 0, k = a.layers[e].objects.length; k > t; t++)
  8080. if (a.layers[e].objects[t].gid) u = {
  8081. gid: a.layers[e].objects[t].gid,
  8082. name: a.layers[e].objects[t].name,
  8083. x: a.layers[e].objects[t].x,
  8084. y: a.layers[e].objects[t].y,
  8085. visible: a.layers[e].objects[t].visible,
  8086. properties: a.layers[e].objects[t].properties
  8087. }, q[a.layers[e].name].push(u);
  8088. else if (a.layers[e].objects[t].polyline) {
  8089. for (u = {
  8090. name: a.layers[e].objects[t].name,
  8091. x: a.layers[e].objects[t].x,
  8092. y: a.layers[e].objects[t].y,
  8093. width: a.layers[e].objects[t].width,
  8094. height: a.layers[e].objects[t].height,
  8095. visible: a.layers[e].objects[t].visible,
  8096. properties: a.layers[e].objects[t].properties
  8097. }, u.polyline = [], v = 0; v < a.layers[e].objects[t].polyline.length; v++) u.polyline.push([a.layers[e].objects[t].polyline[v].x, a.layers[e].objects[t].polyline[v].y]);
  8098. r[a.layers[e].name].push(u)
  8099. } else if (a.layers[e].objects[t].polygon) {
  8100. for (u = s(a.layers[e].objects[t], ["name", "x", "y", "visible", "properties"]), u.polygon = [], v = 0; v < a.layers[e].objects[t].polygon.length; v++) u.polygon.push([a.layers[e].objects[t].polygon[v].x, a.layers[e].objects[t].polygon[v].y]);
  8101. q[a.layers[e].name].push(u)
  8102. } else a.layers[e].objects[t].ellipse ? (u = s(a.layers[e].objects[t], ["name", "ellipse", "x", "y", "width", "height", "visible", "properties"]), q[a.layers[e].name].push(u)) : (u = s(a.layers[e].objects[t], ["name", "x", "y", "width", "height", "visible", "properties"]), u.rectangle = !0, q[a.layers[e].name].push(u));
  8103. for (c.objects = q, c.collision = r, c.tiles = [], e = 0; e < c.tilesets.length; e++)
  8104. for (o = c.tilesets[e], g = o.tileMargin, w = o.tileMargin, x = 0, y = 0, z = 0, j = o.firstgid; j < o.firstgid + o.total && (c.tiles[j] = [g, w, e], g += o.tileWidth + o.tileSpacing, x++, x !== o.total) && (y++, y !== o.columns || (g = o.tileMargin, w += o.tileHeight + o.tileSpacing, y = 0, z++, z !== o.rows)); j++);
  8105. return c
  8106. }
  8107. }, b.Tileset = function(a, b, c, d, e, f, g) {
  8108. ("undefined" == typeof c || 0 >= c) && (c = 32), ("undefined" == typeof d || 0 >= d) && (d = 32), "undefined" == typeof e && (e = 0), "undefined" == typeof f && (f = 0), this.name = a, this.firstgid = b, this.tileWidth = c, this.tileHeight = d, this.tileMargin = e, this.tileSpacing = f, this.properties = g, this.image = null, this.rows = 0, this.columns = 0, this.total = 0, this.drawCoords = []
  8109. }, b.Tileset.prototype = {
  8110. draw: function(a, b, c, d) {
  8111. this.image && this.drawCoords[d] && a.drawImage(this.image, this.drawCoords[d][0], this.drawCoords[d][1], this.tileWidth, this.tileHeight, b, c, this.tileWidth, this.tileHeight)
  8112. },
  8113. setImage: function(a) {
  8114. var b, c, d, e, f;
  8115. for (this.image = a, this.rows = Math.round((a.height - this.tileMargin) / (this.tileHeight + this.tileSpacing)), this.columns = Math.round((a.width - this.tileMargin) / (this.tileWidth + this.tileSpacing)), this.total = this.rows * this.columns, this.drawCoords.length = 0, b = this.tileMargin, c = this.tileMargin, d = this.firstgid, e = 0; e < this.rows; e++) {
  8116. for (f = 0; f < this.columns; f++) this.drawCoords[d] = [b, c], b += this.tileWidth + this.tileSpacing, d++;
  8117. b = this.tileMargin, c += this.tileHeight + this.tileSpacing
  8118. }
  8119. },
  8120. setSpacing: function(a, b) {
  8121. this.tileMargin = a, this.tileSpacing = b, this.setImage(this.image)
  8122. }
  8123. }, b.Tileset.prototype.constructor = b.Tileset, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = b), exports.Phaser = b) : "undefined" != typeof define && define.amd ? define("Phaser", function() {
  8124. return a.Phaser = b
  8125. }()) : a.Phaser = b
  8126. }.call(this), __extends = this.__extends || function(a, b) {
  8127. function d() {
  8128. this.constructor = a
  8129. }
  8130. for (var c in b) b.hasOwnProperty(c) && (a[c] = b[c]);
  8131. d.prototype = b.prototype, a.prototype = new d
  8132. },
  8133. function(a) {
  8134. a[a["Ready"] = 0] = "Ready", a[a["Start"] = 1] = "Start", a[a["End"] = 2] = "End"
  8135. }(GameProcessState || (GameProcessState = {})), GameState = function(a) {
  8136. function b() {
  8137. a.apply(this, arguments), this.ballInitialX = 300, this.groundY = 910
  8138. }
  8139. return __extends(b, a), Object.defineProperty(b.prototype, "currentBall", {
  8140. get: function() {
  8141. return this.ball
  8142. },
  8143. enumerable: !0,
  8144. configurable: !0
  8145. }), Object.defineProperty(b.prototype, "currentGround", {
  8146. get: function() {
  8147. return this.background.currentGround
  8148. },
  8149. enumerable: !0,
  8150. configurable: !0
  8151. }), Object.defineProperty(b.prototype, "currentProcessState", {
  8152. get: function() {
  8153. return this.processState
  8154. },
  8155. enumerable: !0,
  8156. configurable: !0
  8157. }), Object.defineProperty(b.prototype, "currentDistance", {
  8158. get: function() {
  8159. return this.ball.x - this.ballInitialX
  8160. },
  8161. enumerable: !0,
  8162. configurable: !0
  8163. }), b.prototype.create = function() {
  8164. this.game.device.desktop || (this.scale.forceOrientation(!1, !0, "orientationTips"), this.scale.enterIncorrectOrientation.add(this.pauseGame, this), this.scale.leaveIncorrectOrientation.add(this.resumeGame, this)), this.game.physics.startSystem(Phaser.Physics.ARCADE), this.stage.backgroundColor = 16777215, this.game.world.setBounds(0, 0, 1e6, 700), this.background = new Background(this, 0, 0, this.groundY), this.game.add.sprite(-95, 220, "tree"), this.start(), this.summary = new Summary(this.game, 60, 170), this.summary.fixedToCamera = !0, this.distanceSprite = this.game.add.sprite(40, 20, "distance"), this.distanceSprite.fixedToCamera = !0, this.distanceSprite.visible = !1, this.distanceText = this.game.add.text(140, 24, "", {
  8165. font: "32px Arial",
  8166. fill: "#f1ea20",
  8167. align: "center",
  8168. stroke: "#9a5920",
  8169. strokeThickness: 5
  8170. }), this.distanceText.fixedToCamera = !0, this.distanceText.visible = !1
  8171. }, b.prototype.start = function() {
  8172. this.player = new Player(this, 240, 807), this.ball = new Ball(this, this.ballInitialX, 431), this.bombs = this.game.add.group(), this.beds = this.game.add.group(), this.shits = this.game.add.group(), this.obstacleFactory = new ObstacleFactory(this, this.bombs, this.beds, this.shits);
  8173. var a = this.game.time.create(!0);
  8174. a.add(2e3, this.gameStart, this, null), a.start(), this.processState = 0, this.game.camera.follow(this.ball, Phaser.Camera.FOLLOW_PLATFORMER)
  8175. }, b.prototype.gameStart = function() {
  8176. this.ball.dropDown()
  8177. }, b.prototype.update = function() {
  8178. this.background.update(), this.obstacleFactory.updateLogic(), this.distanceText.visible && this.distanceText.setText(this.currentDistance.toFixed(0))
  8179. }, b.prototype.render = function() {}, b.prototype.renderObstacle = function(a) {
  8180. this.game.debug.body(a), this.game.debug.spriteBounds(a, "#ff0000", !1)
  8181. }, b.prototype.restartFromDrop = function() {
  8182. this.player.destroy(), this.ball.over(), this.destroyAllObstacles(), this.playAgain()
  8183. }, b.prototype.playAgain = function() {
  8184. this.camera.view.topLeft = new Phaser.Point(0, 0), this.distanceText.visible = !1, this.distanceSprite.visible = !1, this.start()
  8185. }, b.prototype.dropToGround = function() {
  8186. var a = this.game.time.create(!0);
  8187. a.add(1e3, this.restartFromDrop, this, null), a.start(), this.ball.hitGround(), this.processState = 2
  8188. }, b.prototype.finishGame = function() {
  8189. var a = this.game.time.create(!0);
  8190. a.add(2e3, this.showSummaryDialog, this, null), a.start(), this.processState = 2
  8191. }, b.prototype.startGame = function() {
  8192. this.ball.startFly(), this.processState = 1, this.distanceText.visible = !0, this.distanceSprite.visible = !0
  8193. }, b.prototype.showSummaryDialog = function() {
  8194. this.player.destroy(), this.ball.over(), this.destroyAllObstacles(), this.game.world.bringToTop(this.summary), this.summary.show(this)
  8195. }, b.prototype.destroyAllObstacles = function() {
  8196. this.bombs.destroy(), this.beds.destroy(), this.shits.forEach(this.destoryShitEmitter, this), this.shits.destroy()
  8197. }, b.prototype.destoryShitEmitter = function(a) {
  8198. a.over()
  8199. }, b.prototype.pauseGame = function() {
  8200. this.game.paused = !0
  8201. }, b.prototype.resumeGame = function() {
  8202. this.game.paused = !1
  8203. }, b
  8204. }(Phaser.State),
  8205. function(a) {
  8206. a[a["Normal"] = 0] = "Normal", a[a["Drop"] = 1] = "Drop", a[a["Fly"] = 2] = "Fly"
  8207. }(BallState || (BallState = {})), Ball = function(a) {
  8208. function b(b, c, d) {
  8209. a.call(this, b.game, c, d, "ball"), this.gravity = 400, this.maxRotation = .02, this.shadowMinDistance = 700, this.groundBounceY = .8, this.hitGroundEffectX = 0, this.hitGroundEffectY = 0, this.animations.add("stand", Phaser.Animation.generateFrameNames("ballStand", 1, 2, ".png", 2), 10, !0), this.animations.add("drop", Phaser.Animation.generateFrameNames("ballDrop", 1, 2, ".png", 2), 10, !1), this.animations.add("fly", Phaser.Animation.generateFrameNames("ballFly", 1, 4, ".png", 2), 10, !0);
  8210. var e = this.animations.add("collide", Phaser.Animation.generateFrameNames("ballCollide", 1, 1, ".png", 2), 3, !1);
  8211. this.animations.add("hitGround", Phaser.Animation.generateFrameNames("ballHitGround", 1, 1, ".png", 2), 10, !1), this.animations.add("flyOver", Phaser.Animation.generateFrameNames("ballFlyOver", 1, 1, ".png", 2), 10, !1), e.onComplete.add(this.playFly, this), b.game.physics.enable(this, Phaser.Physics.ARCADE), this.anchor.set(.5, .5), this.body.setSize(40, 40), this.gameState = b, this.body.bounce.setTo(0, 0), this.play("stand"), this.ballState = 0, this.shadow = this.game.add.sprite(c, this.gameState.currentGround.y, "ballShadow"), this.shadow.anchor.set(.5, .5), b.game.add.existing(this)
  8212. }
  8213. return __extends(b, a), b.prototype.dropDown = function() {
  8214. if (this.play("drop"), this.game.device.desktop || this.game.device.iOS) {
  8215. var a = this.game.add.audio("ballDrop");
  8216. a.play()
  8217. }
  8218. this.body.gravity.y = this.gravity, this.ballState = 1, this.body.angularVelocity = 18
  8219. }, b.prototype.update = function() {
  8220. var a, b, c, d, e;
  8221. 2 == this.ballState && (this.body.velocity.x > 200 ? (a = Math.atan(this.body.velocity.y / this.body.velocity.x), b = a >= this.rotation ? 1 : -1, this.rotation += this.maxRotation * b * this.game.time.elapsed, c = a >= this.rotation ? 1 : -1, c != b && (this.rotation = a)) : this.rotation *= .95), this.shadow.x = this.x, d = .1, e = this.gameState.currentGround.y - this.y, e < this.shadowMinDistance && e > 0 ? d = .1 + .9 * ((this.shadowMinDistance - e) / this.shadowMinDistance) : 0 >= e && (d = 1), this.shadow.scale.x = d, this.shadow.scale.y = d
  8222. }, b.prototype.startFly = function() {
  8223. this.body.bounce.setTo(0, this.groundBounceY), this.play("fly"), this.ballState = 2, this.body.angularVelocity = 0
  8224. }, b.prototype.hitGround = function() {
  8225. this.rotation = 0, this.body.angularVelocity = 0, this.play("hitGround"), new CollideGroundEffect(this.game, this.x + this.hitGroundEffectX, this.y + this.hitGroundEffectY)
  8226. }, b.prototype.flyOver = function() {
  8227. this.rotation = 0, this.play("flyOver")
  8228. }, b.prototype.over = function() {
  8229. this.kill(), this.shadow.kill()
  8230. }, b.prototype.collide = function(a) {
  8231. this.play("collide"), a && new CollideGroundEffect(this.game, this.x + this.hitGroundEffectX, this.y + this.hitGroundEffectY)
  8232. }, b.prototype.playFly = function() {
  8233. this.play("fly")
  8234. }, b
  8235. }(Phaser.Sprite), Background = function() {
  8236. function a(a, b, c, d) {
  8237. this.unbounceMinVelocityY = 10, this.unbounceMinVelocityX = 40, this.decelerationX = .8, this.groundY = d, this.gameState = a, this.bg = a.game.add.tileSprite(b, c, this.gameState.game.world.width, this.gameState.game.world.height, "bg"), this.bg.fixedToCamera = !0, this.ground = a.game.add.sprite(b, c + this.groundY, ""), this.ground.scale.x = 1e3, this.ground.scale.y = 1e3, this.ground.fixedToCamera = !0, a.game.physics.enable(this.ground, Phaser.Physics.ARCADE), this.ground.body.immovable = !0, this.isInGround = !1, this.gameState = a
  8238. }
  8239. return Object.defineProperty(a.prototype, "currentGround", {
  8240. get: function() {
  8241. return this.ground
  8242. },
  8243. enumerable: !0,
  8244. configurable: !0
  8245. }), a.prototype.update = function() {
  8246. if (this.bg.tilePosition.x = -this.gameState.game.camera.x, this.gameState.game.physics.arcade.collide(this.ground, this.gameState.currentBall)) {
  8247. if (!this.isInGround) {
  8248. if (this.gameState.game.device.desktop || this.gameState.game.device.iOS) {
  8249. var a = this.gameState.game.add.audio("groundCollide");
  8250. a.play()
  8251. }
  8252. 0 == this.gameState.currentProcessState ? this.gameState.dropToGround() : this.gameState.currentBall.body.velocity.y >= -this.unbounceMinVelocityY || this.gameState.currentBall.body.velocity.x <= this.unbounceMinVelocityX ? (this.gameState.currentBall.body.velocity.x = 0, this.gameState.currentBall.body.velocity.y = 0, this.gameState.currentBall.body.gravity.y = 0, this.gameState.currentBall.flyOver(), this.gameState.finishGame()) : this.gameState.currentBall.body.velocity.x > 0 && (this.gameState.currentBall.body.velocity.x *= this.decelerationX, this.gameState.currentBall.collide(!0)), this.isInGround = !0
  8253. }
  8254. } else this.isInGround = !1
  8255. }, a
  8256. }(), Bomb = function(a) {
  8257. function b(b, c, d) {
  8258. a.call(this, b.game, c, d, "bomb"), this.additionalVelocityX = 900, this.additionalVelocityY = 800, b.game.physics.enable(this, Phaser.Physics.ARCADE), b.game.add.existing(this), this.anchor.set(.5, 1), this.gameState = b, this.isTakeEffect = !1, this.body.immovable = !0, this.body.checkCollision.left = !1, this.body.checkCollision.down = !1, this.body.checkCollision.right = !1, this.body.checkCollision.up = !0, this.body.offset.y = -60, this.body.setSize(60, 80), this.animations.add("normal", Phaser.Animation.generateFrameNames("bombNormal", 1, 1, ".png", 2), 10, !1), this.animations.add("explosion", Phaser.Animation.generateFrameNames("bombExplosion", 1, 4, ".png", 2), 10, !1), this.play("normal")
  8259. }
  8260. return __extends(b, a), b.prototype.refresh = function(a) {
  8261. this.revive(), this.isTakeEffect = !1, this.play("normal"), this.x = a
  8262. }, b.prototype.update = function() {
  8263. this.x < this.game.camera.view.left - 200 ? this.kill() : (this.game.physics.arcade.overlap(this, this.gameState.currentBall), !this.isTakeEffect && this.game.physics.arcade.overlap(this, this.gameState.currentBall) && (this.effect(), this.isTakeEffect = !0))
  8264. }, b.prototype.effect = function() {
  8265. if (this.play("explosion"), this.game.device.desktop || this.game.device.iOS) {
  8266. var a = this.game.add.audio("bombExplode");
  8267. a.play()
  8268. }
  8269. this.gameState.currentBall.collide(!1), this.gameState.currentBall.body.velocity.x += this.additionalVelocityX, this.gameState.currentBall.body.velocity.y = -this.gameState.currentBall.body.velocity.y
  8270. }, b
  8271. }(Phaser.Sprite), Bed = function(a) {
  8272. function b(b, c, d) {
  8273. a.call(this, b.game, c, d, "bed"), this.additionalVelocityY = 230, b.game.physics.enable(this, Phaser.Physics.ARCADE), b.game.add.existing(this), this.anchor.set(.5, 1), this.gameState = b, this.isTakeEffect = !1, this.body.immovable = !0, this.body.checkCollision.left = !1, this.body.checkCollision.down = !1, this.body.checkCollision.right = !1, this.body.checkCollision.up = !0, this.animations.add("normal", Phaser.Animation.generateFrameNames("bedNormal", 1, 1, ".png", 2), 10, !1), this.animations.add("collide", Phaser.Animation.generateFrameNames("bedCollide", 1, 5, ".png", 2), 10, !1), this.play("normal"), this.body.setSize(150, 90)
  8274. }
  8275. return __extends(b, a), b.prototype.refresh = function(a) {
  8276. this.revive(), this.isTakeEffect = !1, this.play("normal"), this.x = a
  8277. }, b.prototype.update = function() {
  8278. this.x < this.game.camera.view.left - 200 ? this.kill() : (this.game.physics.arcade.overlap(this, this.gameState.currentBall), !this.isTakeEffect && this.game.physics.arcade.overlap(this, this.gameState.currentBall) && (this.effect(), this.isTakeEffect = !0))
  8279. }, b.prototype.effect = function() {
  8280. if (this.play("collide"), this.game.device.desktop || this.game.device.iOS) {
  8281. var a = this.game.add.audio("bedCollide");
  8282. a.play()
  8283. }
  8284. this.gameState.currentBall.collide(!1), this.gameState.currentBall.body.velocity.y = -(Math.abs(this.gameState.currentBall.body.velocity.y) + this.additionalVelocityY)
  8285. }, b
  8286. }(Phaser.Sprite), CollideGroundEffect = function(a) {
  8287. function b(b, c, d) {
  8288. a.call(this, b, c, d, "collideGround"), this.anchor.set(.5, .5);
  8289. var e = this.animations.add("effect", Phaser.Animation.generateFrameNames("collideGround", 1, 2, ".png", 2), 10, !1);
  8290. e.onComplete.add(this.effectOver, this), this.game.add.existing(this), this.play("effect")
  8291. }
  8292. return __extends(b, a), b.prototype.effectOver = function() {
  8293. this.kill()
  8294. }, b
  8295. }(Phaser.Sprite), CollideShitEffect = function(a) {
  8296. function b(b, c, d) {
  8297. a.call(this, b, c, d, "collideShit"), this.anchor.set(.5, .5);
  8298. var e = this.animations.add("effect", Phaser.Animation.generateFrameNames("collideShit", 1, 3, ".png", 2), 10, !1);
  8299. e.onComplete.add(this.effectOver, this), this.game.add.existing(this), this.play("effect")
  8300. }
  8301. return __extends(b, a), b.prototype.effectOver = function() {
  8302. this.kill()
  8303. }, b
  8304. }(Phaser.Sprite), FirstState = function(a) {
  8305. function b() {
  8306. a.apply(this, arguments)
  8307. }
  8308. return __extends(b, a), b.prototype.preload = function() {
  8309. this.game.load.onLoadComplete.add(this.onLoadComplete, this), this.game.load.baseURL = "assets/", this.game.load.image("title", "title.png")
  8310. }, b.prototype.onLoadComplete = function() {
  8311. this.game.state.start("LoadingState", !0, !1)
  8312. }, b
  8313. }(Phaser.State), LoadingState = function(a) {
  8314. function b() {
  8315. a.apply(this, arguments)
  8316. }
  8317. return __extends(b, a), b.prototype.preload = function() {
  8318. var a, b;
  8319. this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0, this.scale.scaleMode = this.game.device.desktop ? Phaser.ScaleManager.SHOW_ALL : Phaser.ScaleManager.EXACT_FIT, this.scale.refresh(), this.stage.backgroundColor = 16777215, a = this.game.add.text(this.game.world.width / 2, this.game.world.height / 2 + 100, "拼了老命加载中……", {
  8320. font: "48px Arial",
  8321. fill: "#f0e921",
  8322. align: "center",
  8323. stroke: "#a06520",
  8324. strokeThickness: 5
  8325. }), a.anchor.set(.5, .5), this.percentage = this.game.add.text(this.game.world.width / 2, this.game.world.height / 2, "", {
  8326. font: "48px Arial",
  8327. fill: "#f0e921",
  8328. align: "center",
  8329. stroke: "#a06520",
  8330. strokeThickness: 5
  8331. }), this.percentage.anchor.set(.5, .5), b = this.game.add.sprite(this.game.world.width / 2, this.game.world.height / 2 - 100, "title"), b.anchor.set(.5, .5), this.game.load.onFileComplete.add(this.onFileComplete, this), this.game.load.onLoadComplete.add(this.onLoadComplete, this), this.game.load.baseURL = "assets/", this.game.load.image("bg", "bg.png"), this.game.load.atlasJSONHash("player", "player.png", "player.xml"), this.game.load.atlasJSONHash("ball", "ball.png", "ball.xml"), this.game.load.atlasJSONHash("bomb", "bomb.png", "bomb.xml"), this.game.load.atlasJSONHash("bed", "bed.png", "bed.xml"), this.game.load.atlasJSONHash("shit", "shit.png", "shit.xml"), this.game.load.atlasJSONHash("collideGround", "collideGround.png", "collideGround.xml"), this.game.load.atlasJSONHash("collideShit", "collideShit.png", "collideShit.xml"), this.game.load.image("ballShadow", "ballShadow.png"), this.game.load.image("tree", "tree.png"), this.game.load.image("distance", "distance.png"), this.game.load.image("summaryBG", "summaryBG.png"), this.game.load.image("summaryTitle1", "summaryTitle1.png"), this.game.load.image("summaryTitle2", "summaryTitle2.png"), this.game.load.image("summaryTitle3", "summaryTitle3.png"), this.game.load.image("summaryTitle4", "summaryTitle4.png"), this.game.load.image("summaryTitle5", "summaryTitle5.png"), this.game.load.image("againButton", "againButton.png"), this.game.load.image("notifyButton", "notifyButton.png"), this.game.load.image("moreButton", "moreButton.png"), this.game.load.image("fly", "fly.png"), this.game.load.image("orientationTips", "orientationTips.png"), this.game.load.audio("ballDrop", ["slide.mp3"]), this.game.load.audio("bombExplode", ["explode.mp3"]), this.game.load.audio("bedCollide", ["bounce.mp3"]), this.game.load.audio("hitBall", ["hit.mp3"]), this.game.load.audio("act", ["huibang.mp3"]), this.game.load.audio("shitCollide", ["shit.mp3"]), this.game.load.audio("groundCollide", ["bodyhit.mp3"])
  8332. }, b.prototype.onFileComplete = function(a, b, c, d, e) {
  8333. this.loadedFileCount = d, this.totalFileCount = e, this.percentage.text = this.loadedFileCount.toString() + "/" + this.totalFileCount.toString()
  8334. }, b.prototype.onLoadComplete = function() {
  8335. this.game.state.start("GameState", !0, !1)
  8336. }, b
  8337. }(Phaser.State),
  8338. function(a) {
  8339. a[a["Stand"] = 0] = "Stand", a[a["Hit"] = 1] = "Hit"
  8340. }(PlayerState || (PlayerState = {})), Player = function(a) {
  8341. function b(b, c, d) {
  8342. a.call(this, b.game, c, d, "player"), this.power = 0, this.hitSecond = 200, this.hitCD = 300, this.hitPower = 1200, this.animations.add("stand", Phaser.Animation.generateFrameNames("playerStand", 1, 1, ".png", 2), 10, !1), this.animations.add("hit", Phaser.Animation.generateFrameNames("playerHit", 1, 3, ".png", 2), 10, !1), this.anchor.set(.5, .5), this.game.add.existing(this), this.gameState = b, this.playerState = 0, this.play("stand"), this.game.physics.enable(this, Phaser.Physics.ARCADE), this.body.setSize(100, 100), this.body.immovable = !0, this.currentHitCD = 0
  8343. }
  8344. return __extends(b, a), b.prototype.update = function() {
  8345. var a, b;
  8346. this.currentHitCD > 0 && (this.currentHitCD -= this.game.time.elapsed), 0 == this.playerState ? this.game.input.activePointer.isDown && this.currentHitCD <= 0 && (this.playerState = 1, this.play("hit"), (this.game.device.desktop || this.game.device.iOS) && (a = this.game.add.audio("act"), a.play()), this.currentSecond = 0, this.currentHitCD = this.hitCD) : 1 == this.playerState && this.currentSecond < this.hitSecond && (this.currentSecond += this.game.time.elapsed, this.currentSecond >= this.hitSecond && (this.game.physics.arcade.overlap(this, this.gameState.currentBall) ? (b = Math.atan((this.gameState.currentBall.y - this.y) / (this.gameState.currentBall.x - this.x)), this.gameState.currentBall.body.velocity.x = this.hitPower * Math.cos(b), this.gameState.currentBall.body.velocity.y = this.hitPower * Math.sin(b), (this.game.device.desktop || this.game.device.iOS) && (a = this.game.add.audio("hitBall"), a.play()), this.gameState.startGame()) : this.playerState = 0))
  8347. }, b
  8348. }(Phaser.Sprite), Obstacle = function(a) {
  8349. function b(b, c, d, e) {
  8350. a.call(this, b.game, c, d, e), b.game.physics.enable(this, Phaser.Physics.ARCADE), b.game.add.existing(this), this.anchor.set(.5, 1), this.gameState = b, this.isTakeEffect = !1, this.body.immovable = !0, this.body.checkCollision.left = !1, this.body.checkCollision.down = !1, this.body.checkCollision.right = !1, this.body.checkCollision.up = !0
  8351. }
  8352. return __extends(b, a), b.prototype.update = function() {
  8353. this.x < this.game.camera.view.left ? this.kill() : (this.game.physics.arcade.collide(this, this.gameState.currentBall), !this.isTakeEffect && this.game.physics.arcade.overlap(this, this.gameState.currentBall) && (this.effect(), this.isTakeEffect = !0))
  8354. }, b.prototype.effect = function() {}, b
  8355. }(Phaser.Sprite), ObstacleFactory = function() {
  8356. function a(a, b, c, d) {
  8357. this.generateBombY = 960, this.generateBedY = 922, this.generateShitY = 930, this.generateDistanceBetweenBall = 1e3, this.minGenerateDistance = 1e3, this.maxGenerateDistance = 2e3, this.generateBombPercentage = 35, this.generateBebPercentage = 45, this.generateShitPercentage = 20, this.gameState = a, this.bombs = b, this.beds = c, this.shits = d, this.nextGenerateDistance = this.gameState.currentBall.x + this.gameState.game.rnd.integerInRange(this.minGenerateDistance, this.maxGenerateDistance)
  8358. }
  8359. return a.prototype.updateLogic = function() {
  8360. var a, b, c, d;
  8361. this.nextGenerateDistance - this.gameState.currentBall.x <= this.generateDistanceBetweenBall && (a = this.gameState.game.rnd.integerInRange(0, this.generateBombPercentage + this.generateBebPercentage + this.generateShitPercentage), a < this.generateBombPercentage ? (b = this.bombs.getFirstDead(), null == b ? (b = new Bomb(this.gameState, this.nextGenerateDistance, this.generateBombY), this.bombs.add(b)) : b.refresh(this.nextGenerateDistance)) : a < this.generateBombPercentage + this.generateBebPercentage ? (c = this.beds.getFirstDead(), null == c ? (c = new Bed(this.gameState, this.nextGenerateDistance, this.generateBedY), this.beds.add(c)) : c.refresh(this.nextGenerateDistance)) : (d = this.shits.getFirstDead(), null == d ? (d = new Shit(this.gameState, this.nextGenerateDistance, this.generateShitY), this.shits.add(d)) : d.refresh(this.nextGenerateDistance)), this.nextGenerateDistance += this.gameState.game.rnd.integerInRange(this.minGenerateDistance, this.maxGenerateDistance))
  8362. }, a
  8363. }(), Summary = function(a) {
  8364. function b(b, c, d) {
  8365. if (a.call(this, b), this.maxScore = 1e5, this.maxPlayerCount = 4891735, this.x = c, this.y = d, this.add(this.create(0, 0, "summaryBG", null, !0)), this.score = this.game.add.text(305, 83, "123", {
  8366. font: "35px Arial",
  8367. fill: "#000000",
  8368. align: "center"
  8369. }), this.score.anchor.set(.5, .5), this.add(this.score), this.rank = this.game.add.text(337, 144, "222", {
  8370. font: "35px Arial",
  8371. fill: "#FF0000",
  8372. align: "center"
  8373. }), this.rank.anchor.set(.5, .5), this.add(this.rank), this.percentage = this.game.add.text(227, 211, "33", {
  8374. font: "35px Arial",
  8375. fill: "#FF0000",
  8376. align: "center"
  8377. }), this.percentage.anchor.set(.5, .5), this.add(this.percentage), this.title = this.create(357, 301, "summaryTitle1", null, !0), this.add(this.title), this.title.anchor.set(.5, .5), -1 != navigator.userAgent.toUpperCase().indexOf("MICROMESSENGER")) {
  8378. var e = this.create(88, 480, "notifyButton", null, !0);
  8379. this.add(e), e.inputEnabled = !0, e.events.onInputUp.add(this.notify, this)
  8380. }
  8381. e = this.create(278, 375, "againButton", null, !0), this.add(e), e.inputEnabled = !0, e.events.onInputUp.add(this.playAgain, this), e = this.create(22, 375, "moreButton", null, !0), this.add(e), e.inputEnabled = !0, e.events.onInputUp.add(this.moreGame, this), this.game.add.existing(this), this.visible = !1
  8382. }
  8383. return __extends(b, a), b.prototype.show = function(a) {
  8384. var b, c, d;
  8385. this.visible = !0, this.gameSate = a, this.score.setText(this.gameSate.currentDistance.toFixed(0)), b = this.getRank(this.gameSate.currentDistance), this.rank.setText(b.toString()), c = this.getPercentage(b), this.percentage.setText(c.toString()), d = "“打的是空气”", 5 > c ? (this.title.loadTexture("summaryTitle1", 0), d = "“职业卖萌”") : 20 > c ? (this.title.loadTexture("summaryTitle2", 0), d = "“业余打手”") : 50 > c ? (this.title.loadTexture("summaryTitle3", 0), d = "“棒中豪杰”") : 90 > c ? (this.title.loadTexture("summaryTitle4", 0), d = "“神之一棒”") : (this.title.loadTexture("summaryTitle5", 0), d = "“完美全垒打”");
  8386. // dp_submitScore(this.score.text, "我随手一棒把疯猫打出了" + this.score.text + "米,获得称号" + d +"求超越-68微游戏!");
  8387. // updateShare(this.score.text);
  8388. // Play68.setRankingScoreDesc(this.score.text);
  8389. }, b.prototype.notify = function() {
  8390. play68_submitScore(this.score.text)
  8391. }, b.prototype.playAgain = function() {
  8392. this.visible = !1, this.gameSate.playAgain()
  8393. }, b.prototype.moreGame = function() {
  8394. Play68.goHome();
  8395. }, b.prototype.getRank = function(a) {
  8396. var b, c;
  8397. return a >= this.maxScore ? 1 : (b = this.maxPlayerCount * a / this.maxScore, c = this.maxPlayerCount * (a + 1) / this.maxScore, this.maxPlayerCount - Math.round(b + Math.random() * (c - b)))
  8398. }, b.prototype.getPercentage = function(a) {
  8399. return 100 - Math.round(100 * (a / this.maxPlayerCount))
  8400. }, b
  8401. }(Phaser.Group), Shit = function(a) {
  8402. function b(b, c, d) {
  8403. a.call(this, b.game, c, d, "shit"), this.collideEffectX = 30, this.collideEffectY = -50, b.game.physics.enable(this, Phaser.Physics.ARCADE), b.game.add.existing(this), this.anchor.set(.5, 1), this.gameState = b, this.isTakeEffect = !1, this.body.immovable = !0, this.body.checkCollision.left = !1, this.body.checkCollision.down = !1, this.body.checkCollision.right = !1, this.body.checkCollision.up = !0, this.animations.add("normal", Phaser.Animation.generateFrameNames("shitNormal", 1, 1, ".png", 2), 10, !1), this.animations.add("collide", Phaser.Animation.generateFrameNames("shitCollide", 1, 2, ".png", 2), 4, !1), this.body.offset.x = 60, this.body.setSize(80, 120), this.emitter = this.game.add.emitter(this.x + 60, this.y - 60, 3), this.emitter.makeParticles("fly"), this.emitter.gravity = 0, this.emitter.minParticleSpeed.setTo(-50, -50), this.emitter.maxParticleSpeed.setTo(50, 50), this.emitter.start(!1, 3e3, 1e3), this.play("normal")
  8404. }
  8405. return __extends(b, a), b.prototype.refresh = function(a) {
  8406. this.revive(), this.isTakeEffect = !1, this.play("normal"), this.x = a, this.emitter.x = this.x + 60
  8407. }, b.prototype.update = function() {
  8408. this.x < this.game.camera.view.left - 200 ? this.kill() : (this.game.physics.arcade.overlap(this, this.gameState.currentBall), !this.isTakeEffect && this.game.physics.arcade.overlap(this, this.gameState.currentBall) && (this.effect(), this.isTakeEffect = !0))
  8409. }, b.prototype.effect = function() {
  8410. if (this.play("collide"), this.game.device.desktop || this.game.device.iOS) {
  8411. var a = this.game.add.audio("shitCollide");
  8412. a.play()
  8413. }
  8414. new CollideShitEffect(this.game, this.x + this.collideEffectX, this.y + this.collideEffectY), this.gameState.currentBall.over(), this.gameState.finishGame()
  8415. }, b.prototype.over = function() {
  8416. this.emitter.destroy()
  8417. }, b
  8418. }(Phaser.Sprite), Game = function(a) {
  8419. function b() {
  8420. window.screen.width, a.call(this, 640, 960, Phaser.CANVAS, "gameDiv"), this.state.add("FirstState", FirstState, !0), this.state.add("LoadingState", LoadingState, !1), this.state.add("GameState", GameState, !1)
  8421. }
  8422. return __extends(b, a), b
  8423. }(Phaser.Game), window.onload = function() {
  8424. // updateShare(0);
  8425. new Game
  8426. };